import { CancellationToken } from "../../../base/common/cancellation.js"; import type { IDisposable } from "../../../base/common/lifecycle.js"; import type { IAgentHostCredentialSource } from "./agentHostCredentials.js"; import type { ChangesetKind } from "./changesetUri.js"; import type { InvokeChangesetOperationParams, InvokeChangesetOperationResult } from "./state/protocol/channels-changeset/commands.js"; import type { ChangesetOperation, ISessionGitHubState, ISessionGitState, URI } from "./state/sessionState.js"; export declare const AGENT_HOST_MERGE_CHANGESET_OPERATION_ID = "merge"; export declare const AGENT_HOST_CHECKOUT_CHANGESET_OPERATION_ID = "checkout"; export declare const AGENT_HOST_COMMIT_CHANGESET_OPERATION_ID = "commit"; export declare const AGENT_HOST_SYNC_CHANGESET_OPERATION_ID = "sync"; export declare const AGENT_HOST_DISCARD_CHANGES_OPERATION_ID = "discard-changes"; export declare const AGENT_HOST_ACCEPT_CHANGES_OPERATION_ID = "accept-changes"; /** * Changeset operations advertised for a branch that already has a pull * request. Declared here rather than next to their handler so the client can * recognise them without reaching into the host-only implementation. */ export declare const AgentHostPullRequestOperationId: { readonly MarkReady: "pr-mark-ready"; readonly MarkReadyWithAgentMerge: "pr-mark-ready-with-agent-merge"; readonly Merge: "pr-merge"; readonly EnableAutoMerge: "pr-enable-auto-merge"; readonly DisableAutoMerge: "pr-disable-auto-merge"; }; export declare const AGENT_HOST_PULL_REQUEST_OPERATION_IDS: ReadonlySet; /** * Changeset operations that create a pull request for the session's branch. * Declared here for the same reason as {@link AgentHostPullRequestOperationId}. * Current hosts advertise only `Create` (configured through request metadata); * the other variants are still handled and may be advertised by older hosts. */ export declare const AgentHostCreatePullRequestOperationId: { readonly Create: "create-pr"; readonly CreateDraft: "create-draft-pr"; readonly CreateAutoMerge: "create-pr-auto-merge"; readonly CreateAutoSquash: "create-pr-auto-squash"; readonly CreateAutoRebase: "create-pr-auto-rebase"; readonly CreateAgentMerge: "create-pr-agent-merge"; readonly CreateDraftAgentMerge: "create-draft-pr-agent-merge"; }; /** * The subset that hands the merge off to GitHub's own auto-merge. Agent Merge * covers the same intent and replaces them on the changes button bar, which * drops them from the button and its dropdown. * * They stay advertised rather than being withdrawn, because the Agent Merge * menu keys off them to know it should stand in. */ export declare const AGENT_HOST_AUTO_MERGE_OPERATION_IDS: ReadonlySet; /** * Server-side handler for a changeset operation advertised via * `changeset/operationsChanged`. * * The agent service validates the request shape (changeset exists, operation id * known, target scope matches) before invoking the handler; the handler is only * responsible for executing the operation. */ export interface IChangesetOperationHandler { /** Captures credentials at admission, before the operation waits for another operation to finish. */ captureCredentialSource?(params: InvokeChangesetOperationParams, source?: IAgentHostCredentialSource): IAgentHostCredentialSource | undefined; /** * Executes a previously advertised changeset operation. * * The handler receives the original protocol params so it can inspect the * changeset channel and optional target. Validation that the operation exists * on the changeset and supports the requested target scope happens before this * method is called. * The optional credential source is supplied by the host, never by protocol metadata. */ invoke(params: InvokeChangesetOperationParams, token: CancellationToken, source?: IAgentHostCredentialSource): Promise; } /** * Context used by changeset operation contributions to decide which operations * to advertise for a session changeset. * * Keep this interface intentionally small. Add new fields here only when a * contribution genuinely needs them to compute operation availability. Likely * future additions include the concrete changeset URI, the session state, the * changeset state, or the working directory URI. */ export interface IChangesetOperationContext { /** String form of the containing session URI. */ readonly sessionKey: string; /** Resource that owns the changeset. */ readonly ownerKey?: string; /** Session or chat whose workspace and Git state back the changeset. */ readonly sourceKey?: string; /** Expanded changeset URI whose operations are being computed. */ readonly changesetUri: URI; /** Well-known changeset kind for {@link changesetUri}. */ readonly changesetKind: ChangesetKind; /** Current git metadata for the session used to compute operation availability. */ readonly gitState?: ISessionGitState; /** Current GitHub metadata for the session used to compute operation availability. */ readonly gitHubState?: ISessionGitHubState; } /** * Registration surface handed to changeset operation contributions. * * Contributions use this object to install operation handlers and request a * refresh when external state changes which operations should be advertised. */ export interface IChangesetOperationRegistry { /** * Registers the server-side handler for one {@link ChangesetOperation.id}. * The returned disposable removes only this registration. */ registerChangesetOperationHandler(operationId: string, handler: IChangesetOperationHandler): IDisposable; /** * Notifies the contribution service that advertised operations for all static * changesets in `sessionKey` should be recomputed from current session state. */ onDidChangeOperations(sessionKey: string): void; /** * Recomputes the session's git metadata and then refreshes advertised * operations if that metadata can be resolved. */ refreshSessionGitState(sessionKey: string, source?: IAgentHostCredentialSource): Promise; } /** * Provider of changeset operations for one feature area. * * A contribution owns the decision about which operations are available for a * changeset and registers the handlers that execute those operations. */ export interface IChangesetOperationContribution extends IDisposable { /** * Registers every operation handler owned by this contribution. Called once * when the contribution is added to the service. */ registerHandlers(registry: IChangesetOperationRegistry): IDisposable; /** * Returns operations that should be advertised for the given changeset, or * `undefined` when this contribution has nothing to offer in the context. */ getOperations(context: IChangesetOperationContext): readonly ChangesetOperation[] | undefined; }