@github/copilot-sdk 1.0.13-preview.2 → 1.0.13-preview.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -140,7 +140,8 @@ Create a new conversation session.
140
140
  - `gitHubTokenProvider?: GitHubTokenProvider` - Acquires rotating, session-scoped GitHub tokens. Token results require a positive `expiresIn` value in seconds remaining when the callback completes; production tokens typically last eight hours. Cannot be combined with `gitHubToken`.
141
141
  - `provider?: ProviderConfig` - Custom API provider configuration (BYOK - Bring Your Own Key). See [Custom Providers](#custom-providers) section.
142
142
  - `onPermissionRequest?: PermissionHandler` - Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. `approveAll` approves requests when managed settings are disabled and throws when `enableManagedSettings` is true. Custom handlers can inspect `managedApprovalRequired` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section.
143
- - `onUserInputRequest?: UserInputHandler` - Handler for user input requests from the agent. Enables the `ask_user` tool. See [User Input Requests](#user-input-requests) section.
143
+ - `onUserInputRequest?: UserInputHandler` - Handler for legacy question-and-answer requests from the agent. Enables the legacy `ask_user` tool. See [User Input Requests](#user-input-requests) section.
144
+ - `askUserVariant?: "legacy" | "elicitation"` - Selects the model-facing `ask_user` tool shape when creating or cold-resuming a session. Defaults to `"legacy"`; use `"elicitation"` with `onElicitationRequest`.
144
145
  - `onElicitationRequest?: ElicitationHandler` - Handler for elicitation requests dispatched by the server. Enables this client to present form-based UI dialogs on behalf of the agent or other session participants. See [Elicitation Requests](#elicitation-requests) section.
145
146
  - `hooks?: SessionHooks` - Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section.
146
147
 
@@ -959,7 +960,7 @@ To let a specific custom tool bypass the permission prompt entirely, set `skipPe
959
960
 
960
961
  ## User Input Requests
961
962
 
962
- Enable the agent to ask questions to the user using the `ask_user` tool by providing an `onUserInputRequest` handler:
963
+ Enable the legacy question-and-answer `ask_user` tool by providing an `onUserInputRequest` handler:
963
964
 
964
965
  ```typescript
965
966
  const session = await client.createSession({
@@ -991,6 +992,7 @@ Register an `onElicitationRequest` handler to let your client act as an elicitat
991
992
  const session = await client.createSession({
992
993
  model: "gpt-5",
993
994
  onPermissionRequest: approveAll,
995
+ askUserVariant: "elicitation",
994
996
  onElicitationRequest: async (context) => {
995
997
  // context.sessionId - Session that triggered the request
996
998
  // context.message - Description of what information is needed
@@ -1012,6 +1014,9 @@ const session = await client.createSession({
1012
1014
  console.log(session.capabilities.ui?.elicitation); // true
1013
1015
  ```
1014
1016
 
1017
+ Set `askUserVariant: "elicitation"` to expose the structured form as the model's
1018
+ `ask_user` tool. Omit it to retain the legacy SDK behavior.
1019
+
1015
1020
  When `onElicitationRequest` is provided, the SDK sends `requestElicitation: true` during session create/resume, which enables `session.capabilities.ui.elicitation` on the session.
1016
1021
 
1017
1022
  In multi-client scenarios:
@@ -1208,6 +1208,7 @@ class CopilotClient {
1208
1208
  requestPermission: !!config.onPermissionRequest,
1209
1209
  requestUserInput: !!config.onUserInputRequest,
1210
1210
  requestElicitation: !!config.onElicitationRequest,
1211
+ askUserVariant: config.askUserVariant,
1211
1212
  ...config.enableMcpApps ? { requestMcpApps: true } : {},
1212
1213
  ...config.githubMcpToolConfig != null ? { githubMcpToolConfig: config.githubMcpToolConfig } : {},
1213
1214
  requestExitPlanMode: !!config.onExitPlanModeRequest,
@@ -1440,6 +1441,7 @@ class CopilotClient {
1440
1441
  requestPermission: config.onPermissionRequest !== import_types.defaultJoinSessionPermissionHandler,
1441
1442
  requestUserInput: !!config.onUserInputRequest,
1442
1443
  requestElicitation: !!config.onElicitationRequest,
1444
+ askUserVariant: config.askUserVariant,
1443
1445
  ...config.enableMcpApps ? { requestMcpApps: true } : {},
1444
1446
  ...config.githubMcpToolConfig != null ? { githubMcpToolConfig: config.githubMcpToolConfig } : {},
1445
1447
  requestExitPlanMode: !!config.onExitPlanModeRequest,
@@ -200,7 +200,7 @@ function createServerRpc(connection) {
200
200
  disable: async (params) => connection.sendRequest("extensions.disable", params)
201
201
  },
202
202
  /**
203
- * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime temporarily falls back to its built-in Node launcher for backward compatibility.
203
+ * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
204
204
  *
205
205
  * @experimental
206
206
  */
@@ -773,6 +773,15 @@ function createSessionRpc(connection, sessionId) {
773
773
  * @experimental
774
774
  */
775
775
  sendMessages: async (params) => connection.sendRequest("session.sendMessages", { sessionId, ...params }),
776
+ /** @experimental */
777
+ sandbox: {
778
+ /**
779
+ * Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
780
+ *
781
+ * @returns Managed sandbox enforcement state for a session.
782
+ */
783
+ getEnforcementStatus: async () => connection.sendRequest("session.sandbox.getEnforcementStatus", { sessionId })
784
+ },
776
785
  /**
777
786
  * Aborts the current agent turn.
778
787
  *
@@ -283,14 +283,18 @@ class CopilotSession {
283
283
  const name = typeof nameOrHandle === "string" ? nameOrHandle : (0, import_factory.getFactoryDefinition)(nameOrHandle).meta.name;
284
284
  if (options?.resumeFromRunId !== void 0) {
285
285
  return this.factory.resume(options.resumeFromRunId, {
286
- limits: options.limits
286
+ limits: options.limits,
287
+ notifyOnComplete: options.notifyOnComplete,
288
+ logPhaseNames: options.logPhaseNames
287
289
  });
288
290
  }
289
291
  const envelope = await this.rpc.factory.run({
290
292
  name,
291
293
  args: options?.args === void 0 ? {} : options.args,
292
294
  options: {
293
- limits: options?.limits
295
+ limits: options?.limits,
296
+ notifyOnComplete: options?.notifyOnComplete,
297
+ logPhaseNames: options?.logPhaseNames
294
298
  }
295
299
  });
296
300
  return this.settleFactoryRun(envelope);
@@ -301,7 +305,9 @@ class CopilotSession {
301
305
  try {
302
306
  response = await this.rpc.factory.resume({
303
307
  runId,
304
- limits: options?.limits
308
+ limits: options?.limits,
309
+ notifyOnComplete: options?.notifyOnComplete,
310
+ logPhaseNames: options?.logPhaseNames
305
311
  });
306
312
  } catch (error) {
307
313
  if (error instanceof import_node.ResponseError && typeof error.data === "object" && error.data !== null) {
@@ -316,7 +322,10 @@ class CopilotSession {
316
322
  }),
317
323
  getRun: async (runId) => this.rpc.factory.getRun({ runId }),
318
324
  waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
319
- listRuns: async () => (await this.rpc.factory.listRuns({})).runs,
325
+ listRuns: (async (options) => {
326
+ const page = await this.rpc.factory.listRuns(options ?? {});
327
+ return options === void 0 ? page.runs : page;
328
+ }),
320
329
  getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
321
330
  getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
322
331
  cancel: async (runId) => this.rpc.factory.cancel({ runId })
package/dist/client.js CHANGED
@@ -1185,6 +1185,7 @@ class CopilotClient {
1185
1185
  requestPermission: !!config.onPermissionRequest,
1186
1186
  requestUserInput: !!config.onUserInputRequest,
1187
1187
  requestElicitation: !!config.onElicitationRequest,
1188
+ askUserVariant: config.askUserVariant,
1188
1189
  ...config.enableMcpApps ? { requestMcpApps: true } : {},
1189
1190
  ...config.githubMcpToolConfig != null ? { githubMcpToolConfig: config.githubMcpToolConfig } : {},
1190
1191
  requestExitPlanMode: !!config.onExitPlanModeRequest,
@@ -1417,6 +1418,7 @@ class CopilotClient {
1417
1418
  requestPermission: config.onPermissionRequest !== defaultJoinSessionPermissionHandler,
1418
1419
  requestUserInput: !!config.onUserInputRequest,
1419
1420
  requestElicitation: !!config.onElicitationRequest,
1421
+ askUserVariant: config.askUserVariant,
1420
1422
  ...config.enableMcpApps ? { requestMcpApps: true } : {},
1421
1423
  ...config.githubMcpToolConfig != null ? { githubMcpToolConfig: config.githubMcpToolConfig } : {},
1422
1424
  requestExitPlanMode: !!config.onExitPlanModeRequest,
@@ -42,7 +42,7 @@ export type JoinSessionConfig = Omit<ResumeSessionConfig, "onPermissionRequest"
42
42
  factories?: FactoryHandle[];
43
43
  };
44
44
  export type { ExtensionInfo, FactoryLimits, FactoryMeta } from "./types.js";
45
- export { defineFactory, FactoryResumeError, isFactoryRunTerminal, type RunOptions, type ResumeOptions, type FactoryResumeErrorCode, type SessionFactoryApi, type FactoryAgentOptions, type FactoryContext, type FactoryDefinition, type FactoryHandle, type FactoryJsonSchema, type JsonValue, type FactoryPipelineStage, type FactoryStepOptions, type FactoryRunResult, type FactoryRunStatus, type FactoryRunSummary, type FactoryRunDetail, type FactoryProgressPage, type FactoryProgressLine, type FactoryPhaseObservation, type FactoryPhaseStatus, type FactoryAgentSummary, } from "./factory.js";
45
+ export { defineFactory, FactoryResumeError, isFactoryRunTerminal, type RunOptions, type ResumeOptions, type FactoryResumeErrorCode, type SessionFactoryApi, type FactoryAgentOptions, type FactoryContext, type FactoryDefinition, type FactoryHandle, type FactoryJsonSchema, type JsonValue, type FactoryPipelineStage, type FactoryStepOptions, type FactoryRunResult, type FactoryRunStatus, type FactoryRunSummary, type FactoryListRunsOptions, type FactoryRunsPage, type FactoryRunDetail, type FactoryProgressPage, type FactoryProgressLine, type FactoryPhaseObservation, type FactoryPhaseStatus, type FactoryAgentSummary, } from "./factory.js";
46
46
  /**
47
47
  * Joins the current foreground session.
48
48
  *
package/dist/factory.d.ts CHANGED
@@ -1,9 +1,23 @@
1
- import type { FactoryGetRunProgressRequest, FactoryProgressPage, FactoryRunDetail, FactoryRunResult, FactoryRunStatus, FactoryRunSummary } from "./generated/rpc.js";
1
+ import type { FactoryGetRunProgressRequest, FactoryListRunsRequest, FactoryListRunsResult, FactoryProgressPage, FactoryRunDetail, FactoryRunResult, FactoryRunStatus, FactoryRunSummary } from "./generated/rpc.js";
2
2
  import type { ContextTier } from "./generated/session-events.js";
3
3
  import type { CopilotSession } from "./session.js";
4
4
  import type { FactoryLimits, FactoryMeta } from "./types.js";
5
5
  export type { FactoryRunResult };
6
6
  export type { FactoryAgentSummary, FactoryPhaseStatus, FactoryPhaseObservation, FactoryProgressLine, FactoryProgressPage, FactoryRunDetail, FactoryRunStatus, FactoryRunSummary, } from "./generated/rpc.js";
7
+ /**
8
+ * Options for paging durable factory runs.
9
+ *
10
+ * @experimental Part of the experimental Agent Factories surface and may
11
+ * change or be removed in future SDK or CLI releases.
12
+ */
13
+ export type FactoryListRunsOptions = FactoryListRunsRequest;
14
+ /**
15
+ * A page of durable factory runs and its paging metadata.
16
+ *
17
+ * @experimental Part of the experimental Agent Factories surface and may
18
+ * change or be removed in future SDK or CLI releases.
19
+ */
20
+ export type FactoryRunsPage = FactoryListRunsResult;
7
21
  /**
8
22
  * Whether a factory run status is terminal.
9
23
  *
@@ -165,6 +179,10 @@ export interface RunOptions<TArgs extends JsonValue = JsonValue> {
165
179
  args?: TArgs;
166
180
  /** Optional per-invocation resource ceiling overrides. */
167
181
  limits?: FactoryLimits;
182
+ /** Whether to notify the originating session when the factory completes. */
183
+ notifyOnComplete?: boolean;
184
+ /** Whether to emit factory phase names to the session transcript. */
185
+ logPhaseNames?: boolean;
168
186
  /**
169
187
  * Prior run whose persisted identity, arguments, journal, and accounting should be resumed.
170
188
  *
@@ -181,6 +199,10 @@ export interface RunOptions<TArgs extends JsonValue = JsonValue> {
181
199
  export interface ResumeOptions {
182
200
  /** Optional per-invocation resource ceiling overrides. */
183
201
  limits?: FactoryLimits;
202
+ /** Whether to notify the originating session when the factory completes. */
203
+ notifyOnComplete?: boolean;
204
+ /** Whether to emit factory phase names to the session transcript. */
205
+ logPhaseNames?: boolean;
184
206
  }
185
207
  /**
186
208
  * Machine-readable pre-execution factory resume failure.
@@ -239,8 +261,20 @@ export interface SessionFactoryApi {
239
261
  }): Promise<FactoryRunResult>;
240
262
  /**
241
263
  * List the newest default page of this session's durable factory runs.
264
+ *
265
+ * This backwards-compatible overload returns only the runs array. Pass
266
+ * paging options to receive the full page, including its cursors and
267
+ * truncation metadata.
242
268
  */
243
269
  listRuns(): Promise<FactoryRunSummary[]>;
270
+ /**
271
+ * Page this session's durable factory runs.
272
+ *
273
+ * `afterSeq` and `beforeSeq` are exclusive cursors. The result includes
274
+ * `oldestSeq`, `newestSeq`, `hasMoreNewer`, and `omittedOlder` so callers
275
+ * can continue paging without using the raw RPC client.
276
+ */
277
+ listRuns(options: FactoryListRunsOptions): Promise<FactoryRunsPage>;
244
278
  /** Read durable phases, direct agents, and the latest progress tail for a run. */
245
279
  getRunDetail(runId: string): Promise<FactoryRunDetail>;
246
280
  /** Page durable progress forward, backward, or from the latest tail. */
@@ -3,7 +3,7 @@
3
3
  * Generated from: api.schema.json
4
4
  */
5
5
  import type { MessageConnection } from "vscode-jsonrpc/node.js";
6
- import type { AbortReason, Attachment, ContextTier, EmbeddedBlobResourceContents, EmbeddedTextResourceContents, McpOauthHttpResponse, McpOauthWWWAuthenticateParams, McpServerSource, McpServerStatus, ModelChangeSource, PermissionMode, PermissionPromptRequest, PermissionRule, ReasoningSummary, SessionEvent, SessionLimitsConfig, SessionMode, ShutdownType, SkillSource, TaskCompleteData, TaskCompletionOutcome, UserToolSessionApproval, Verbosity } from "./session-events.js";
6
+ import type { AbortReason, Attachment, AutoTier, ContextTier, EmbeddedBlobResourceContents, EmbeddedTextResourceContents, McpOauthHttpResponse, McpOauthWWWAuthenticateParams, McpServerSource, McpServerStatus, ModelChangeSource, PermissionMode, PermissionPromptRequest, PermissionRule, ReasoningSummary, SessionEvent, SessionLimitsConfig, SessionMode, ShutdownType, SkillSource, TaskCompleteData, TaskCompletionOutcome, UserToolSessionApproval, Verbosity } from "./session-events.js";
7
7
  /** A value that can be represented losslessly on the SDK JSON wire. */
8
8
  export type JsonValue = null | boolean | number | string | JsonValue[] | {
9
9
  [key: string]: JsonValue;
@@ -5180,6 +5180,7 @@ export interface CanvasProviderUnregisterRequest {
5180
5180
  */
5181
5181
  /** @experimental */
5182
5182
  export interface CapiSessionOptions {
5183
+ autoTier?: AutoTier;
5183
5184
  /**
5184
5185
  * Whether to use WebSocket transport for the CAPI Responses API. Enabled by default when the model advertises `ws:/responses` support; set to `false` to force the HTTP Responses transport in environments where WebSockets are blocked (e.g. behind a proxy). Setting this to `false` is equivalent to the `COPILOT_CLI_DISABLE_WEBSOCKET_RESPONSES` environment variable.
5185
5186
  */
@@ -6463,6 +6464,10 @@ export interface EnqueueCommandParams {
6463
6464
  * Slash-prefixed command string to enqueue, e.g. '/compact' or '/model gpt-4'. Queued FIFO with any in-flight items; if the session is idle, processing kicks off immediately.
6464
6465
  */
6465
6466
  command: string;
6467
+ /**
6468
+ * Optional user-facing text for the queue row. The command string is shown when omitted.
6469
+ */
6470
+ displayText?: string | null;
6466
6471
  }
6467
6472
  /**
6468
6473
  * Indicates whether the command was accepted into the local execution queue.
@@ -15877,6 +15882,27 @@ export interface SandboxConfigAuth {
15877
15882
  */
15878
15883
  gh?: boolean;
15879
15884
  }
15885
+ /**
15886
+ * Managed sandbox enforcement state for a session.
15887
+ *
15888
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
15889
+ * via the `definition` "SandboxEnforcementStatus".
15890
+ */
15891
+ /** @experimental */
15892
+ export interface SandboxEnforcementStatus {
15893
+ /**
15894
+ * Whether the effective managed policy requires an available sandbox backend.
15895
+ */
15896
+ required: boolean;
15897
+ /**
15898
+ * Whether an enforcement failure has permanently blocked the session.
15899
+ */
15900
+ blocked: boolean;
15901
+ /**
15902
+ * The first sandbox enforcement failure that blocked the session.
15903
+ */
15904
+ reason?: string;
15905
+ }
15880
15906
  /**
15881
15907
  * Register an absolute-time scheduled prompt.
15882
15908
  *
@@ -22160,7 +22186,7 @@ export declare function createServerRpc(connection: MessageConnection): {
22160
22186
  disable: (params: DiscoveredExtensionsDisableRequest) => Promise<void>;
22161
22187
  };
22162
22188
  /**
22163
- * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime temporarily falls back to its built-in Node launcher for backward compatibility.
22189
+ * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
22164
22190
  *
22165
22191
  * @experimental
22166
22192
  */
@@ -22655,6 +22681,15 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
22655
22681
  * @experimental
22656
22682
  */
22657
22683
  sendMessages: (params: SendMessagesRequest) => Promise<SendMessagesResult>;
22684
+ /** @experimental */
22685
+ sandbox: {
22686
+ /**
22687
+ * Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
22688
+ *
22689
+ * @returns Managed sandbox enforcement state for a session.
22690
+ */
22691
+ getEnforcementStatus: () => Promise<SandboxEnforcementStatus>;
22692
+ };
22658
22693
  /**
22659
22694
  * Aborts the current agent turn.
22660
22695
  *
@@ -172,7 +172,7 @@ function createServerRpc(connection) {
172
172
  disable: async (params) => connection.sendRequest("extensions.disable", params)
173
173
  },
174
174
  /**
175
- * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime temporarily falls back to its built-in Node launcher for backward compatibility.
175
+ * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
176
176
  *
177
177
  * @experimental
178
178
  */
@@ -745,6 +745,15 @@ function createSessionRpc(connection, sessionId) {
745
745
  * @experimental
746
746
  */
747
747
  sendMessages: async (params) => connection.sendRequest("session.sendMessages", { sessionId, ...params }),
748
+ /** @experimental */
749
+ sandbox: {
750
+ /**
751
+ * Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
752
+ *
753
+ * @returns Managed sandbox enforcement state for a session.
754
+ */
755
+ getEnforcementStatus: async () => connection.sendRequest("session.sandbox.getEnforcementStatus", { sessionId })
756
+ },
748
757
  /**
749
758
  * Aborts the current agent turn.
750
759
  *
@@ -10,6 +10,16 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
10
10
  * Union of all session event variants emitted by the Copilot CLI runtime.
11
11
  */
12
12
  export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | ScheduleRearmedEvent | AutopilotObjectiveChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | SessionLimitsChangedEvent | PermissionsChangedEvent | PlanChangedEvent | TodosChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | UsageCheckpointEvent | ContextChangedEvent | UsageInfoEvent | ContextClearedEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | FusionRouteStartedEvent | FusionRouteFailedEvent | FusionResolvedEvent | FusionCompletedEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantFusionPhaseStartedEvent | AssistantFusionPhaseCompletedEvent | AssistantFusionPhaseFailedEvent | AssistantServerToolProgressEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantToolCallDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | ModelCallFinishedEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | ToolSearchActivatedEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentConfiguredEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | UIEphemeralQueryEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | SessionLimitsExhaustedRequestedEvent | SessionLimitsExhaustedCompletedEvent | AutoModeResolvedEvent | ManagedSettingsResolvedEvent | ManagedSettingsEnforcedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | FactoryRunUpdatedEvent | FactoryRunStartedEvent | FactoryRunSettledEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | McpToolsListChangedEvent | McpResourcesListChangedEvent | McpPromptsListChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
13
+ /**
14
+ * Routing preference used when the session model is `auto`.
15
+ */
16
+ export type AutoTier =
17
+ /** Optimize for efficiency. */
18
+ "efficiency"
19
+ /** Balance efficiency and intelligence. */
20
+ | "balance"
21
+ /** Optimize for intelligence. */
22
+ | "intelligence";
13
23
  /**
14
24
  * Hosting platform type of the repository (github or ado)
15
25
  */
@@ -317,6 +327,10 @@ export type CitationProvider =
317
327
  */
318
328
  /** @experimental */
319
329
  export type CitationLocation = CitationLocationChar | CitationLocationPage | CitationLocationBlock;
330
+ /**
331
+ * Hosted program caller type
332
+ */
333
+ export type AssistantMessageToolRequestCallerType = "program";
320
334
  /**
321
335
  * API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
322
336
  */
@@ -894,6 +908,7 @@ export interface StartData {
894
908
  * Whether the session was already in use by another client at start time
895
909
  */
896
910
  alreadyInUse?: boolean;
911
+ autoTier?: AutoTier;
897
912
  context?: WorkingDirectoryContext;
898
913
  /**
899
914
  * Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
@@ -1046,6 +1061,7 @@ export interface ResumeData {
1046
1061
  * Whether the session was already in use by another client at resume time
1047
1062
  */
1048
1063
  alreadyInUse?: boolean;
1064
+ autoTier?: AutoTier;
1049
1065
  context?: WorkingDirectoryContext;
1050
1066
  /**
1051
1067
  * Context tier currently selected at resume time; null when no tier is active
@@ -4537,6 +4553,7 @@ export interface AssistantMessageToolRequest {
4537
4553
  * Arguments to pass to the tool, format depends on the tool
4538
4554
  */
4539
4555
  arguments?: JsonValue;
4556
+ caller?: AssistantMessageToolRequestCaller;
4540
4557
  /**
4541
4558
  * Resolved intention summary describing what this specific call does
4542
4559
  */
@@ -4563,6 +4580,16 @@ export interface AssistantMessageToolRequest {
4563
4580
  toolTitle?: string;
4564
4581
  type?: AssistantMessageToolRequestType;
4565
4582
  }
4583
+ /**
4584
+ * Hosted program that requested this client tool call
4585
+ */
4586
+ export interface AssistantMessageToolRequestCaller {
4587
+ /**
4588
+ * Provider-assigned identifier for the hosted caller.
4589
+ */
4590
+ callerId: string;
4591
+ type: AssistantMessageToolRequestCallerType;
4592
+ }
4566
4593
  /**
4567
4594
  * Session event "assistant.message_start". Streaming assistant message start metadata
4568
4595
  */
@@ -6553,7 +6580,7 @@ export interface HookStartData {
6553
6580
  */
6554
6581
  hookType: string;
6555
6582
  /**
6556
- * Input data passed to the hook
6583
+ * Input data passed to the hook. For postToolUse hooks the retained copy served by session.eventLog.read (and by a resumed session) elides the tool result's inline `contents`/`uiResource` and replaces an over-long `textResultForLlm` with a `[copilot:elided ...]` marker, to keep a multi-megabyte payload out of the durable event log; the live subscription stream still delivers the full value. Read the adjacent tool.execution_complete event for the tool result itself.
6557
6584
  */
6558
6585
  input?: JsonValue;
6559
6586
  /**
package/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./facto
11
11
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
12
12
  export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
13
13
  export type * from "./generated/session-events.js";
14
- export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
15
- export type { RunOptions, ResumeOptions, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
14
+ export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
15
+ export type { RunOptions, ResumeOptions, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryListRunsOptions, FactoryRunsPage, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
package/dist/session.js CHANGED
@@ -265,14 +265,18 @@ class CopilotSession {
265
265
  const name = typeof nameOrHandle === "string" ? nameOrHandle : getFactoryDefinition(nameOrHandle).meta.name;
266
266
  if (options?.resumeFromRunId !== void 0) {
267
267
  return this.factory.resume(options.resumeFromRunId, {
268
- limits: options.limits
268
+ limits: options.limits,
269
+ notifyOnComplete: options.notifyOnComplete,
270
+ logPhaseNames: options.logPhaseNames
269
271
  });
270
272
  }
271
273
  const envelope = await this.rpc.factory.run({
272
274
  name,
273
275
  args: options?.args === void 0 ? {} : options.args,
274
276
  options: {
275
- limits: options?.limits
277
+ limits: options?.limits,
278
+ notifyOnComplete: options?.notifyOnComplete,
279
+ logPhaseNames: options?.logPhaseNames
276
280
  }
277
281
  });
278
282
  return this.settleFactoryRun(envelope);
@@ -283,7 +287,9 @@ class CopilotSession {
283
287
  try {
284
288
  response = await this.rpc.factory.resume({
285
289
  runId,
286
- limits: options?.limits
290
+ limits: options?.limits,
291
+ notifyOnComplete: options?.notifyOnComplete,
292
+ logPhaseNames: options?.logPhaseNames
287
293
  });
288
294
  } catch (error) {
289
295
  if (error instanceof ResponseError && typeof error.data === "object" && error.data !== null) {
@@ -298,7 +304,10 @@ class CopilotSession {
298
304
  }),
299
305
  getRun: async (runId) => this.rpc.factory.getRun({ runId }),
300
306
  waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
301
- listRuns: async () => (await this.rpc.factory.listRuns({})).runs,
307
+ listRuns: (async (options) => {
308
+ const page = await this.rpc.factory.listRuns(options ?? {});
309
+ return options === void 0 ? page.runs : page;
310
+ }),
302
311
  getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
303
312
  getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
304
313
  cancel: async (runId) => this.rpc.factory.cancel({ runId })
package/dist/types.d.ts CHANGED
@@ -943,7 +943,7 @@ export type PermissionHandler = (request: PermissionRequest, invocation: {
943
943
  export declare const approveAll: PermissionHandler;
944
944
  export declare const defaultJoinSessionPermissionHandler: PermissionHandler;
945
945
  /**
946
- * Request for user input from the agent (enables ask_user tool)
946
+ * Legacy question-and-answer request from the `ask_user` tool.
947
947
  */
948
948
  export interface UserInputRequest {
949
949
  /**
@@ -1813,6 +1813,8 @@ export interface ManagedSettings {
1813
1813
  /** Managed permission policy for the session. */
1814
1814
  permissions?: ManagedSettingsPermissions;
1815
1815
  }
1816
+ /** Selects the model-facing shape of the built-in `ask_user` tool. */
1817
+ export type AskUserVariant = "legacy" | "elicitation";
1816
1818
  /**
1817
1819
  * Shared configuration fields used by both {@link SessionConfig} (for
1818
1820
  * creating a new session) and {@link ResumeSessionConfig} (for resuming
@@ -2085,9 +2087,18 @@ export interface SessionConfigBase {
2085
2087
  onMcpAuthRequest?: McpAuthHandler;
2086
2088
  /**
2087
2089
  * Handler for user input requests from the agent.
2088
- * When provided, enables the ask_user tool allowing the agent to ask questions.
2090
+ * When provided with the default `legacy` {@link AskUserVariant}, enables the
2091
+ * question-and-answer form of the `ask_user` tool.
2089
2092
  */
2090
2093
  onUserInputRequest?: UserInputHandler;
2094
+ /**
2095
+ * Selects the model-facing shape of the built-in `ask_user` tool.
2096
+ *
2097
+ * The default is `"legacy"`. To use `"elicitation"`, also provide
2098
+ * {@link onElicitationRequest} so the host can answer structured forms.
2099
+ * The runtime resolves this option when it creates or cold-resumes the session.
2100
+ */
2101
+ askUserVariant?: AskUserVariant;
2091
2102
  /**
2092
2103
  * Handler for elicitation requests from the agent.
2093
2104
  * When provided, the server calls back to this client for form-based UI dialogs.
package/docs/factories.md CHANGED
@@ -139,6 +139,8 @@ Run by registered name or handle:
139
139
  const run = await session.factory.run("review-changed", {
140
140
  args: { files: ["src/a.ts"] },
141
141
  limits: { maxAiCredits: 3 },
142
+ notifyOnComplete: true,
143
+ logPhaseNames: true,
142
144
  });
143
145
 
144
146
  if (run.status === "completed") {
@@ -153,7 +155,12 @@ The name overload is:
153
155
  ```ts
154
156
  session.factory.run(
155
157
  name: string,
156
- options?: { args?: JsonValue; limits?: FactoryLimits },
158
+ options?: {
159
+ args?: JsonValue;
160
+ limits?: FactoryLimits;
161
+ notifyOnComplete?: boolean;
162
+ logPhaseNames?: boolean;
163
+ },
157
164
  ): Promise<FactoryRunResult>;
158
165
  ```
159
166
 
@@ -162,6 +169,8 @@ Resume by run ID without resending the name or arguments:
162
169
  ```ts
163
170
  const run = await session.factory.resume(runId, {
164
171
  limits: { maxAiCredits: 6 },
172
+ notifyOnComplete: true,
173
+ logPhaseNames: true,
165
174
  });
166
175
  ```
167
176
 
@@ -170,10 +179,16 @@ The signature is:
170
179
  ```ts
171
180
  session.factory.resume(
172
181
  runId: string,
173
- options?: { limits?: FactoryLimits },
182
+ options?: {
183
+ limits?: FactoryLimits;
184
+ notifyOnComplete?: boolean;
185
+ logPhaseNames?: boolean;
186
+ },
174
187
  ): Promise<FactoryRunResult>;
175
188
  ```
176
189
 
190
+ Set `notifyOnComplete` to `true` for factories that are likely to be invoked by an agent, so the originating session is notified when the factory completes. Set it to `false` for factories intended to be invoked programmatically, where the caller awaits the result directly. Set `logPhaseNames` to emit factory phase names to the session transcript. Both options apply to new and resumed runs.
191
+
177
192
  Both resolve with the run envelope (`FactoryRunResult`) for **every** outcome — `completed`, `error`, `halted`, and `cancelled` alike. Inspect `status` and read `result` only when the run completed; a limit breach carries a typed `failure`. SDK-initiated `run` and `resume` do not request permission, so they have no declined outcome. The model's `run_factory` tool requests permission before the durable row exists; declining it creates no run row. An SDK-initiated run is refused only when the session already has its maximum number of active top-level runs. Pre-execution resume failures throw `FactoryResumeError`, whose `code` is one of `not_found`, `non_resumable`, `already_active`, `factory_already_running`, `factory_limits_invalid`, `factory_session_disposed`, `factory_storage_unavailable`, or `factory_storage_corrupt`.
178
193
 
179
194
  An agent that no longer has a prior run's ID in context can recover it with `factories_manage` and `operation: "runs"`, which lists the session's factory runs with their IDs and statuses. This matters for resume: a run that reached a limit keeps its journal, so resuming it replays completed work for free, while restarting it from scratch pays for that work twice.
@@ -219,8 +234,13 @@ The calling session can inspect its own factory runs:
219
234
 
220
235
  ```ts
221
236
  const runs = await session.factory.listRuns();
237
+ const runsPage = await session.factory.listRuns({
238
+ afterSeq,
239
+ beforeSeq,
240
+ limit,
241
+ });
222
242
  const detail = await session.factory.getRunDetail(runId);
223
- const page = await session.factory.getRunProgress(runId, {
243
+ const progressPage = await session.factory.getRunProgress(runId, {
224
244
  phaseId,
225
245
  afterSeq,
226
246
  beforeSeq,
@@ -228,7 +248,8 @@ const page = await session.factory.getRunProgress(runId, {
228
248
  });
229
249
  ```
230
250
 
231
- - `listRuns()` returns the newest default page of this session's durable factory runs.
251
+ - `listRuns()` returns only the runs array from the newest default page of this session's durable factory runs. This overload preserves the original convenience API.
252
+ - `listRuns({ afterSeq, beforeSeq, limit })` returns the full page. Its `oldestSeq`, `newestSeq`, `hasMoreNewer`, and `omittedOlder` fields let callers continue paging without raw RPC calls.
232
253
  - `getRunDetail(runId)` returns phases, prompt-safe agent summaries, and the latest progress page.
233
254
  - `getRunProgress(runId, options?)` pages progress forward, backward, by phase, or from the latest tail.
234
255
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "1.0.13-preview.2",
7
+ "version": "1.0.13-preview.3",
8
8
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
9
9
  "main": "./dist/cjs/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "author": "GitHub",
57
57
  "license": "MIT",
58
58
  "dependencies": {
59
- "@github/copilot": "^1.0.82-0",
59
+ "@github/copilot": "^1.0.83-0",
60
60
  "koffi": "^3.1.0",
61
61
  "vscode-jsonrpc": "^8.2.1",
62
62
  "zod": "^4.3.6"