2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { basename } from '../../../base/common/resources.js';
7
>
import { CancellationToken } from '../../../base/common/cancellation.js';
8
>
import { URI } from '../../../base/common/uri.js';
9
>
import { localize } from '../../../nls.js';
10
>
import { IAgentService } from '../common/agentService.js';
11
>
import { IAgentHostGitHubEndpointService } from './agentHostGitHubEndpointService.js';
12
>
import { parseChangesetUri } from '../common/changesetUri.js';
13
>
import { type IChangesetOperationHandler } from '../common/agentHostChangesetOperationService.js';
14
>
import type { InvokeChangesetOperationParams, InvokeChangesetOperationResult } from '../common/state/protocol/channels-changeset/commands.js';
15
>
import { AHP_AUTH_REQUIRED, AHP_SESSION_NOT_FOUND, JsonRpcErrorCodes, ProtocolError } from '../common/state/sessionProtocol.js';
16
>
import { readSessionGitState, type ISessionFileDiff, type SessionState } from '../common/state/sessionState.js';
17
>
import { ILogService } from '../../log/common/log.js';
18
>
import { IAgentHostGitService } from '../common/agentHostGitService.js';
19
>
import { CopilotApiError, ICopilotApiService } from './shared/copilotApiService.js';
20
>
21
>
const MAX_CHANGE_SUMMARY_PROMPT_CHARS = 20_000;
22
>
23
>
export class AgentHostCommitOperationHandler implements IChangesetOperationHandler {
24
>
25
>
public static readonly OPERATION_COMMIT = 'commit';
26
>
27
>
constructor(
28
private readonly _getSessionState: (sessionKey: string) => SessionState | undefined,
29
private readonly _onCommitted: (sessionKey: string) => Promise<void>,