import { ApiPaginationOptions, ApiRequestOptions } from "@codingame/monaco-vscode-github-service-override/vscode/vs/platform/github/common/client/request"; import { JsonObject, JsonValue, PageOptions, RepositoryRef } from "@codingame/monaco-vscode-github-service-override/vscode/vs/platform/github/common/client/types"; import type { EnvironmentKind, PaginatedResponse, User } from "./missionControl.js"; /** The current task state, derived from its most recent session. */ export type TaskState = "queued" | "in_progress" | "completed" | "failed" | "idle" | "waiting_for_user" | "timed_out" | "cancelled"; /** The current state of a session. */ export type SessionState = TaskState; /** Receive-only feed credentials. The URL must not be persisted or logged. */ export interface SessionFeedConnection { readonly url: string; readonly subprotocol: "json.webpubsub.azure.v1"; readonly group: string; readonly expires_at: string; readonly reconnect_after: string; /** Milliseconds remaining at response generation; omitted by older servers. */ readonly expires_in?: number; /** Milliseconds until renewal at response generation; independent of the client clock. */ readonly reconnect_in?: number; readonly frame_schema_version: 1; } /** The visibility of a task to its collaborators, repository readers, and listings. */ export type TaskSharingStatus = "unshared" | "shared" | "unlisted"; /** Compute associated with a task. */ export interface TaskCompute { /** The compute provider. */ readonly provider?: "codespaces" | "sandboxes"; /** The identifier of the compute resource. */ readonly resource_id?: string; /** The user or organization login against which compute is provisioned. */ readonly scope?: string; } /** Compute selection supplied when creating a task. */ export interface TaskComputeRequest extends TaskCompute { /** The sandbox owner, required for organization-owned app-principal sandbox tasks. */ readonly user_id?: number; } /** The canonical environment binding for a task. */ export interface TaskEnvironment { /** The stable identifier of the bound environment. */ readonly id: string; /** The canonical class of compute backing the environment. */ readonly kind: EnvironmentKind; } /** An agent integration that has worked on a task. */ export interface TaskCollaborator { /** The type of agent integration, such as a GitHub App. */ readonly agent_type?: string; /** The numeric identifier of the agent integration. */ readonly agent_id?: number; /** The task identifier assigned by the agent integration. */ readonly agent_task_id?: string; /** The machine-readable integration slug. */ readonly slug?: string; } /** Custom-agent metadata associated with a task. */ export interface TaskCustomAgent { /** The custom agent's filename without its extension. */ readonly id?: string; /** The custom-agent identifier. */ readonly name?: string; /** Whether an automation rather than a direct user action initiated the task. */ readonly is_automation?: boolean; } /** A repository reference returned with a task or session. */ export interface Repository { /** The unique numeric identifier of the repository. */ readonly id?: number; /** The repository name without its owner. */ readonly name?: string; /** The repository name in owner/name form. */ readonly full_name?: string; /** The account that owns the repository. */ readonly owner?: User; } /** A repository resource created or used by a task, such as an issue or pull request. */ export interface RepositoryResource { /** The numeric resource identifier. */ readonly id: number; /** The resource type, such as pull_request or issue. */ readonly type: string; /** The GraphQL global identifier of the resource. */ readonly global_id?: string; /** The lifecycle state of the resource. */ readonly state?: "open" | "draft" | "closed" | "merged"; } /** A Git branch reference generated by a task. */ export interface BranchResource { /** The head branch name. */ readonly head_ref: string; /** The base branch name. */ readonly base_ref: string; } /** An Azure DevOps resource identified by its canonical URL. */ export interface AzureDevOpsResource { /** The canonical Azure DevOps resource URL. */ readonly url: string; } /** A resource generated by a task. */ export interface TaskArtifact { /** The provider namespace of the resource. */ readonly provider: "github" | "azure_devops"; /** The artifact type determining the resource data shape. */ readonly type: "pull" | "branch" | "github_resource" | "azure_devops_resource"; /** The resource data carried by the artifact. */ readonly data: RepositoryResource | BranchResource | AzureDevOpsResource; } /** Descriptive Azure DevOps repository metadata supplied by an authorized caller. */ export interface AzureDevOpsRepositoryContext extends AzureDevOpsResource { /** The repository name. */ readonly name?: string; /** The default branch of the repository. */ readonly default_branch?: string; } /** The experiment assignment used when creating a task. */ export interface ExperimentAssignmentResponse { /** The stable experiment name. */ readonly experiment_name: string; /** The numeric experiment variant. */ readonly variant: number; /** The stable experiment variant name. */ readonly variant_name: string; /** Opaque assignment context returned by the experiment provider. */ readonly assignment_context: string; } /** An authenticated application that created or participated in a task or session. */ export interface TaskClient { readonly integration_id: string; readonly slug: string; readonly creator: boolean; } /** Task metadata returned by listings and task lifecycle operations. */ export interface Task { /** The unique task identifier. */ readonly id: string; /** The API URL for the task. */ readonly url?: string; /** The web URL for the task. */ readonly html_url?: string; /** The human-readable name derived from the task prompt. */ readonly name?: string; /** The entity that created the task. */ readonly creator?: User; /** The type of the task creator. */ readonly creator_type?: "user" | "organization"; /** Creating and participating applications, independent of agent integrations. */ readonly clients?: readonly TaskClient[]; /** Collaborating users, represented by user references or numeric IDs. */ readonly user_collaborators?: readonly (User | number)[]; /** Agent integrations that have worked on the task. */ readonly agent_collaborators?: readonly TaskCollaborator[]; /** The account that owns the repository. */ readonly owner?: User; /** The task's primary repository. */ readonly repository?: Repository; /** Ordered associated repositories, all of which a viewer must be able to read. */ readonly repositories?: readonly Repository[]; /** The deprecated task status, replaced by state. */ readonly status?: TaskState; /** The current state derived from the most recent session. */ readonly state: TaskState; /** The number of sessions in the task. */ readonly session_count?: number; /** The event type that originated the task. */ readonly event_type?: string; /** Resources generated by the task. */ readonly artifacts?: readonly TaskArtifact[]; /** The archive timestamp, or null when the task is not archived. */ readonly archived_at?: string | null; /** The timestamp of the most recent update. */ readonly updated_at?: string; /** The deprecated legacy name for updated_at. */ readonly last_updated_at?: string; /** The timestamp when the task was created. */ readonly created_at: string; /** Whether the latest session supports remote steering through Mission Control. */ readonly remote_steerable: boolean; /** The current environment binding, null or omitted when unavailable. */ readonly current_environment?: TaskEnvironment | null; /** Custom-agent metadata associated with the task. */ readonly custom_agent?: TaskCustomAgent; /** The experiment assignment used while creating the task. */ readonly experiment_assignment?: ExperimentAssignmentResponse; /** The automation that created the task, omitted for non-automation tasks. */ readonly automation_id?: string; /** The exact automation revision used for the run, omitted when not recorded. */ readonly automation_revision_id?: string; /** The deadline after which the session becomes stale without a heartbeat. */ readonly stale_at?: string; /** The compute environment associated with the task. */ readonly compute?: TaskCompute; /** The visibility of the task to readers and collection listings. */ readonly sharing_status?: TaskSharingStatus; /** The Azure DevOps repository against which the task is running. */ readonly azure_devops_repository_context?: AzureDevOpsRepositoryContext; } /** Billing units consumed by a session. */ export interface SessionUsage { /** The billing unit, using AI credits for newer sessions and premium requests for older ones. */ readonly type: "ai_credits" | "premium_requests"; /** Consumed units; AI credits are whole nano units and premium requests may be fractional. */ readonly amount: number; /** Deprecated alias for amount. */ readonly credits?: number; } /** Error details for a failed session. */ export interface SessionError { /** The session failure message. */ readonly message?: string; } /** Full session details within a task. */ export interface Session { /** The unique session identifier. */ readonly id: string; /** The session name. */ readonly name?: string; /** Creating and participating applications; creator attribution can differ from the task's. */ readonly clients?: readonly TaskClient[]; /** The user who created the session. */ readonly user?: User; /** The account that owns the repository. */ readonly owner?: User; /** The session's primary repository. */ readonly repository?: Repository; /** Ordered repositories inherited from the parent task. */ readonly repositories?: readonly Repository[]; /** The numeric agent identifier. */ readonly agent_id?: number; /** The machine-readable agent integration slug. */ readonly agent_slug?: string; /** The task identifier assigned by the agent integration. */ readonly agent_task_id?: string; /** The identifier of the task containing the session. */ readonly task_id?: string; /** The current session state. */ readonly state: SessionState; /** The session creation timestamp. */ readonly created_at: string; /** The most recent update timestamp. */ readonly updated_at?: string; /** The deprecated legacy name for updated_at. */ readonly last_updated_at?: string; /** The session completion timestamp. */ readonly completed_at?: string; /** The event type that triggered the session. */ readonly event_type?: string; /** The URL of the triggering event. */ readonly event_url?: string; /** The content of the triggering event. */ readonly prompt?: string; /** Structured content of the triggering event. */ readonly event_content?: string; /** Identifiers used for tracking the triggering event. */ readonly event_identifiers?: readonly string[]; /** The type of resource associated with the session. */ readonly resource_type?: string; /** The numeric identifier of the associated resource. */ readonly resource_id?: number; /** The resource number, such as a pull request number. */ readonly resource_number?: number; /** The GraphQL global identifier of the associated resource. */ readonly resource_global_id?: string; /** The state of the associated resource. */ readonly resource_state?: string; /** The head branch name. */ readonly head_ref?: string; /** The base branch name. */ readonly base_ref?: string; /** The associated GitHub Actions workflow run identifier. */ readonly workflow_run_id?: number; /** The model used for the session. */ readonly model?: string; /** The reasoning-effort override, empty when no override applies. */ readonly reasoning_effort?: string; /** The number of premium requests consumed by the session. */ readonly premium_requests?: number; /** Structured billing usage for the session. */ readonly usage?: SessionUsage; /** Whether the session supports remote steering through Mission Control. */ readonly remote_steerable?: boolean; /** Error details when the session failed. */ readonly error?: SessionError; /** The deadline after which the session becomes stale without a heartbeat. */ readonly stale_at?: string; /** The immutable environment binding established at session creation. */ readonly environment_id?: string; /** The producer's verbatim AHP resource URI, which cannot be derived from the session ID. */ readonly ahp_resource_uri?: string; } /** A task detail response including its associated sessions. */ export interface GetTaskResponse extends Task { /** The sessions associated with the task. */ readonly sessions?: readonly Session[]; } /** A selected Copilot Space to load as instructions during sandbox provisioning. */ export interface TaskSpace { /** The slug of the selected Space. */ readonly slug: string; /** The owner login of the selected Space. */ readonly owner: string; } /** Parameters for creating a task with optional repository and compute context. */ export interface CreateTaskRequest { /** The user's prompt for the agent. */ readonly prompt: string; /** An existing caller-owned online environment, or github-sandbox to provision a managed sandbox. */ readonly environment_id?: string; /** The agent identifier, defaulting to the coding agent. */ readonly agent_id?: number; /** Up to 50 same-owner repositories in primary-first order; omit or use an empty array for repo-less tasks. */ readonly repositories?: readonly RepositoryRef[]; /** Additional prompting for the agent. */ readonly problem_statement?: string; /** Structured prompt content for the triggering event. */ readonly event_content?: string; /** The model identifier, subject to the caller's plan and organization policies. */ readonly model?: string; /** The reasoning-effort override, omitted or empty for no override. */ readonly reasoning_effort?: string; /** The cloud agent permission mode, defaulting to default. */ readonly permission_mode?: "default" | "allow_all"; /** The managed sandbox principal; app mode is restricted to allowlisted internal integrations. */ readonly github_principal_mode?: "unspecified" | "user" | "copilot_swe_agent_app"; /** The custom agent filename without its extension. */ readonly custom_agent?: string; /** Whether to create a pull request; defaults differ between public and internal requests. */ readonly create_pull_request?: boolean; /** The base ref for a new branch or pull request. */ readonly base_ref?: string; /** An existing head ref to commit to instead of creating a new branch. */ readonly head_ref?: string; /** The event type that originated the task. */ readonly event_type?: string; /** The originating integration identifier for attribution. */ readonly integration_slug?: "copilot-mobile-ios" | "copilot-mobile-android"; /** The URL of the triggering event. */ readonly event_url?: string; /** Event identifiers used for tracking. */ readonly event_identifiers?: readonly string[]; /** Compute selection, including a required scope for repository-less sandbox provisioning. */ readonly compute?: TaskComputeRequest; /** Caller-authorized Azure DevOps repository context. */ readonly azure_devops_repository_context?: AzureDevOpsRepositoryContext; /** An existing caller-authorized Azure DevOps pull request to record as an artifact. */ readonly azure_devops_pull_request?: AzureDevOpsResource; /** A selected Copilot Space, supported only when provisioning a new compatible sandbox. */ readonly space?: TaskSpace; /** The task visibility at creation, defaulting to unshared. */ readonly sharing_status?: TaskSharingStatus; } /** Properties to update on a task; at least one field must be supplied. */ export interface UpdateTaskRequest { /** The new human-readable name, from 1 to 100 characters. */ readonly name?: string; /** The new visibility of the task to readers and collection listings. */ readonly sharing_status?: TaskSharingStatus; } /** User input or an abort command for an existing task. */ export type SteerTaskRequest = { /** Stop the currently running session. */ readonly type: "abort"; } | { /** The command type, defaulting to user_message. */ readonly type?: "user_message" | "ask_user_response" | "plan_approval_response" | "permission_response" | "elicitation_response" | "mode_switch"; /** The user's message, required for every non-abort command. */ readonly content: string; /** Additional prompting for the agent. */ readonly problem_statement?: string; /** The model identifier for the request. */ readonly model?: string; /** The reasoning-effort override, omitted or empty for no override. */ readonly reasoning_effort?: string; /** The custom-agent identifier. */ readonly custom_agent?: string; /** The type of event originating this command. */ readonly event_type?: string; /** Tracking identifiers, including plan_approved or plan_dismissed for plan decisions. */ readonly event_identifiers?: readonly string[]; }; /** Filters and ordering options for task collections. */ interface TaskListQuery extends PageOptions { /** The field to sort by, defaulting to updated_at. */ readonly sort?: "updated_at" | "created_at"; /** The sort direction, defaulting to descending. */ readonly direction?: "asc" | "desc"; /** Comma-separated task states to include. */ readonly state?: string; /** Whether to return archived tasks instead of non-archived tasks, defaulting to false. */ readonly is_archived?: boolean; /** Whether to include aggregate active, archived, and waiting-for-user counts. */ readonly include_counts?: boolean; } /** Query parameters and request options for task collections. */ export type TaskListOptions = ApiPaginationOptions; /** Additional query filters for the authenticated user's task list. */ export type ListTasksOptions = ApiPaginationOptions; /** One page of tasks with optional aggregate counts. */ export interface ListTasksResponse { /** The tasks on this page. */ readonly tasks: readonly Task[]; /** The total number of active, non-archived tasks. */ readonly total_active_count?: number; /** The total number of active tasks waiting for user input. */ readonly total_waiting_for_user_count?: number; /** The total number of archived tasks. */ readonly total_archived_count?: number; } /** An SDK session event with an event-specific payload. */ export interface TaskEvent { /** The unique event identifier. */ readonly id: string; /** The ISO 8601 timestamp when the event occurred. */ readonly timestamp: string; /** The parent event identifier, or null when there is no parent. */ readonly parentId: string | null; /** The session-event discriminator. */ readonly type: string; /** Payload for the event's type. */ readonly data: JsonValue; /** Whether the event is transient rather than persistent. */ readonly ephemeral?: boolean; /** Whether this is a placeholder for user input not yet confirmed by the agent. */ readonly pending?: boolean; /** Whether this user action was never processed by the agent. */ readonly dismissed?: boolean; /** The parent task tool-call identifier for a sub-agent's events. */ readonly agentId?: string; } /** A page of SDK events aggregated across the sessions of a task. */ export interface ListTaskEventsResponse { /** The session events on this page. */ readonly events: readonly TaskEvent[]; /** The total number of events across all sessions, not just this page. */ readonly total: number; } /** An extensible Agent Host Protocol state action. */ export interface AhpAction extends JsonObject { /** The action discriminator, such as session/delta. */ readonly type: string; } /** An AHP state action with its target resource and sequencing information. */ export interface AhpActionEnvelope { /** The resource URI targeted by the action. */ readonly channel: string; /** The host state action, including unrecognized fields. */ readonly action: AhpAction; /** The host's authoritative per-channel sequence number. */ readonly serverSeq: number; /** The reason for a rejected action, or null when it was not rejected. */ readonly rejectionReason?: string | null; } /** A complete AHP message or an unreassembled base64 fragment of a larger message. */ export type AhpPayload = { /** This payload contains one complete action envelope. */ readonly kind: "message"; /** The complete inner AHP action envelope. */ readonly data: AhpActionEnvelope; } | { /** This payload contains one segment of a split action envelope. */ readonly kind: "chunk"; /** The opaque identifier correlating all segments of one logical message. */ readonly group_id: string; /** The zero-based index of this segment. */ readonly seq: number; /** The total number of segments in the group. */ readonly total: number; /** This segment's bytes, encoded as standard padded base64. */ readonly bytes: string; }; /** A host-generated replication frame. */ export interface AhpEvent { /** The producing environment, omitted when supplied by routing metadata. */ readonly environment_id?: string; /** The Mission Control session identifier for this frame. */ readonly session_id: string; /** The replication namespace; AHP history uses ahp. */ readonly ns: "ahp" | "sdk"; /** The monotonic, gap-free sequence within the session and namespace. */ readonly seq: number; /** The RFC 3339 timestamp when the frame was produced. */ readonly at: string; /** The repository or local folder associated with the session, when available. */ readonly project?: { /** The canonical repository or local-folder URI. */ readonly uri?: string; /** The human-readable project name. */ readonly display_name?: string; }; /** The complete message or unreassembled chunk carried by this frame. */ readonly payload: AhpPayload; } /** The complete AHP event stream across all sessions in a task. */ export interface TaskAHPEventsResponse { /** Raw frames in emission order per session. */ readonly events: readonly AhpEvent[]; /** The number of returned frames across all sessions; equals events.length. */ readonly total: number; } /** Operations for creating and managing tasks, sending input, and reading task history. */ export interface ITasksClient { /** Negotiate a receive-only task feed through the approved GitHub gateway. */ connectFeed(signal: AbortSignal, options?: ApiRequestOptions): Promise; /** GET /agents/tasks: list one page of the authenticated user's tasks. */ list(signal: AbortSignal, options?: ListTasksOptions): Promise>; /** GET /agents/tasks/{task_id}: read task details and associated sessions. */ get(taskId: string, signal: AbortSignal, options?: ApiRequestOptions): Promise; /** POST /agents/tasks: create a task and optionally bind or provision its environment. */ create(request: CreateTaskRequest, signal: AbortSignal, options?: ApiRequestOptions): Promise; /** PATCH /agents/tasks/{task_id}: update the task name or sharing status without waking compute. */ update(taskId: string, request: UpdateTaskRequest, signal: AbortSignal, options?: ApiRequestOptions): Promise; /** DELETE /agents/tasks/{task_id}: mark a task for deletion; only its creator may delete it. */ delete(taskId: string, signal: AbortSignal, options?: ApiRequestOptions): Promise; /** POST /agents/tasks/{task_id}/archive: archive a task without waking compute. */ archive(taskId: string, signal: AbortSignal, options?: ApiRequestOptions): Promise; /** POST /agents/tasks/{task_id}/unarchive: restore an archived task without waking compute. */ unarchive(taskId: string, signal: AbortSignal, options?: ApiRequestOptions): Promise; /** POST /agents/tasks/{task_id}/steer: submit input or a control command, acknowledged with HTTP 202. */ steer(taskId: string, request: SteerTaskRequest, signal: AbortSignal, options?: ApiRequestOptions): Promise; /** POST /agents/tasks/{task_id}/steer with type=abort: stop the running session. */ abort(taskId: string, signal: AbortSignal, options?: ApiRequestOptions): Promise; /** GET /agents/tasks/{task_id}/events as application/json: read one page of session events. */ getEvents(taskId: string, signal: AbortSignal, options?: ApiPaginationOptions): Promise>; /** GET /agents/tasks/{task_id}/events as application/vnd.github.ahp+json: read the complete AHP event stream. */ getAhpEvents(taskId: string, signal: AbortSignal, options?: ApiRequestOptions): Promise; } export {};