@github/copilot-sdk 1.0.5-preview.0 → 1.0.5

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.
@@ -6,8 +6,11 @@ function createServerRpc(connection) {
6
6
  * @param params Optional message to echo back to the caller.
7
7
  *
8
8
  * @returns Server liveness response, including the echoed message, current server timestamp, and protocol version.
9
+ *
10
+ * @experimental
9
11
  */
10
12
  ping: async (params) => connection.sendRequest("ping", params),
13
+ /** @experimental */
11
14
  models: {
12
15
  /**
13
16
  * Lists Copilot models available to the authenticated user.
@@ -18,6 +21,7 @@ function createServerRpc(connection) {
18
21
  */
19
22
  list: async (params) => connection.sendRequest("models.list", params)
20
23
  },
24
+ /** @experimental */
21
25
  tools: {
22
26
  /**
23
27
  * Lists built-in tools available for a model.
@@ -28,6 +32,7 @@ function createServerRpc(connection) {
28
32
  */
29
33
  list: async (params) => connection.sendRequest("tools.list", params)
30
34
  },
35
+ /** @experimental */
31
36
  account: {
32
37
  /**
33
38
  * Gets Copilot quota usage for the authenticated user or supplied GitHub token.
@@ -66,6 +71,7 @@ function createServerRpc(connection) {
66
71
  */
67
72
  logout: async (params) => connection.sendRequest("account.logout", params)
68
73
  },
74
+ /** @experimental */
69
75
  secrets: {
70
76
  /**
71
77
  * Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
@@ -76,7 +82,9 @@ function createServerRpc(connection) {
76
82
  */
77
83
  addFilterValues: async (params) => connection.sendRequest("secrets.addFilterValues", params)
78
84
  },
85
+ /** @experimental */
79
86
  mcp: {
87
+ /** @experimental */
80
88
  config: {
81
89
  /**
82
90
  * Lists MCP servers from user configuration.
@@ -218,7 +226,9 @@ function createServerRpc(connection) {
218
226
  refresh: async (params) => connection.sendRequest("plugins.marketplaces.refresh", params)
219
227
  }
220
228
  },
229
+ /** @experimental */
221
230
  skills: {
231
+ /** @experimental */
222
232
  config: {
223
233
  /**
224
234
  * Replaces the global list of disabled skills.
@@ -241,8 +251,6 @@ function createServerRpc(connection) {
241
251
  * @param params Optional project paths to enumerate.
242
252
  *
243
253
  * @returns Canonical locations where skills can be created so the runtime will recognize them.
244
- *
245
- * @experimental
246
254
  */
247
255
  getDiscoveryPaths: async (params) => connection.sendRequest("skills.getDiscoveryPaths", params)
248
256
  },
@@ -284,20 +292,38 @@ function createServerRpc(connection) {
284
292
  */
285
293
  getDiscoveryPaths: async (params) => connection.sendRequest("instructions.getDiscoveryPaths", params)
286
294
  },
295
+ /** @experimental */
287
296
  user: {
297
+ /** @experimental */
288
298
  settings: {
289
299
  /**
290
300
  * Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
291
301
  */
292
- reload: async () => connection.sendRequest("user.settings.reload", {})
302
+ reload: async () => connection.sendRequest("user.settings.reload", {}),
303
+ /**
304
+ * Lists every known user setting (settings.json overlaid with the legacy config.json, config.json wins), each with its effective value, its default, and whether it is at the default — so settings the user has never set still appear with their default value. Does not include repository- or enterprise-managed overrides that the runtime layers on top at session time.
305
+ *
306
+ * @returns Per-key metadata for every known user setting (settings.json overlaid with the legacy config.json, config.json wins), including settings left at their default. Excludes repository- and enterprise-managed overrides.
307
+ */
308
+ get: async () => connection.sendRequest("user.settings.get", {}),
309
+ /**
310
+ * Writes one or more user settings to settings.json, replacing each provided top-level key. A key whose value is null is removed. Returns the keys whose new value is shadowed by a legacy config.json entry (config.json wins on read), which the runtime leaves in place — such writes do not take effect until the legacy value is removed.
311
+ *
312
+ * @param params Partial user settings to write to settings.json. Each top-level key is written individually, replacing the existing value; a key whose value is null is removed.
313
+ *
314
+ * @returns Outcome of writing user settings.
315
+ */
316
+ set: async (params) => connection.sendRequest("user.settings.set", params)
293
317
  }
294
318
  },
319
+ /** @experimental */
295
320
  runtime: {
296
321
  /**
297
322
  * Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
298
323
  */
299
324
  shutdown: async () => connection.sendRequest("runtime.shutdown", {})
300
325
  },
326
+ /** @experimental */
301
327
  sessionFs: {
302
328
  /**
303
329
  * Registers an SDK client as the session filesystem provider.
@@ -537,6 +563,8 @@ function createInternalServerRpc(connection) {
537
563
  * @param params Optional connection token presented by the SDK client during the handshake.
538
564
  *
539
565
  * @returns Handshake result reporting the server's protocol version and package version on success.
566
+ *
567
+ * @experimental
540
568
  */
541
569
  connect: async (params) => connection.sendRequest("connect", params),
542
570
  /** @experimental */
@@ -845,6 +873,23 @@ function createSessionRpc(connection, sessionId) {
845
873
  diff: async (params) => connection.sendRequest("session.workspaces.diff", { sessionId, ...params })
846
874
  },
847
875
  /** @experimental */
876
+ completions: {
877
+ /**
878
+ * Gets the characters that should trigger host-driven completions for the session. Empty disables host-driven completions (e.g. local sessions, or a relay host that does not advertise them).
879
+ *
880
+ * @returns Characters that, when typed in the composer, should trigger a `completions.request`. Empty when the session has no host-driven completions (e.g. local sessions, or a relay host that does not advertise `completionTriggerCharacters`).
881
+ */
882
+ getTriggerCharacters: async () => connection.sendRequest("session.completions.getTriggerCharacters", { sessionId }),
883
+ /**
884
+ * Requests host-driven completion items for the current composer input. Returns an empty list when the host has no items or does not support completions.
885
+ *
886
+ * @param params Request host-driven completions for the current composer input.
887
+ *
888
+ * @returns Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
889
+ */
890
+ request: async (params) => connection.sendRequest("session.completions.request", { sessionId, ...params })
891
+ },
892
+ /** @experimental */
848
893
  instructions: {
849
894
  /**
850
895
  * Gets instruction sources loaded for the session.
@@ -1401,6 +1446,14 @@ function createSessionRpc(connection, sessionId) {
1401
1446
  * @returns Indicates whether the pending UI request was resolved by this call.
1402
1447
  */
1403
1448
  handlePendingAutoModeSwitch: async (params) => connection.sendRequest("session.ui.handlePendingAutoModeSwitch", { sessionId, ...params }),
1449
+ /**
1450
+ * Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
1451
+ *
1452
+ * @param params Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
1453
+ *
1454
+ * @returns Indicates whether the pending UI request was resolved by this call.
1455
+ */
1456
+ handlePendingSessionLimitsExhausted: async (params) => connection.sendRequest("session.ui.handlePendingSessionLimitsExhausted", { sessionId, ...params }),
1404
1457
  /**
1405
1458
  * Resolves a pending `exit_plan_mode.requested` event with the user's response.
1406
1459
  *
@@ -1819,6 +1872,23 @@ function createSessionRpc(connection, sessionId) {
1819
1872
  notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { sessionId, ...params })
1820
1873
  },
1821
1874
  /** @experimental */
1875
+ visibility: {
1876
+ /**
1877
+ * Returns the session's current Mission Control sharing status and shareable GitHub URL. Reflects whether the synced session is visible to repository readers ("repo") or restricted to its creator and collaborators ("unshared").
1878
+ *
1879
+ * @returns Current sharing status and shareable GitHub URL for a session.
1880
+ */
1881
+ get: async () => connection.sendRequest("session.visibility.get", { sessionId }),
1882
+ /**
1883
+ * Sets the session's Mission Control sharing status, controlling whether the synced session is visible to repository readers. Returns the effective status and shareable GitHub URL after the change.
1884
+ *
1885
+ * @param params Desired sharing status for the session.
1886
+ *
1887
+ * @returns Effective sharing status and shareable GitHub URL after updating session visibility.
1888
+ */
1889
+ set: async (params) => connection.sendRequest("session.visibility.set", { sessionId, ...params })
1890
+ },
1891
+ /** @experimental */
1822
1892
  schedule: {
1823
1893
  /**
1824
1894
  * Lists the session's currently active scheduled prompts.
@@ -1988,6 +2058,11 @@ function registerClientGlobalApiHandlers(connection, handlers) {
1988
2058
  if (!handler) throw new Error("No llmInference client-global handler registered");
1989
2059
  return handler.httpRequestChunk(params);
1990
2060
  });
2061
+ connection.onRequest("gitHubTelemetry.event", async (params) => {
2062
+ const handler = handlers.gitHubTelemetry;
2063
+ if (!handler) throw new Error("No gitHubTelemetry client-global handler registered");
2064
+ return handler.event(params);
2065
+ });
1991
2066
  }
1992
2067
  export {
1993
2068
  createInternalServerRpc,
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Union of all session event variants emitted by the Copilot CLI runtime.
7
7
  */
8
- export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | ScheduleRearmedEvent | AutopilotObjectiveChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | PermissionsChangedEvent | PlanChangedEvent | TodosChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | ContextChangedEvent | UsageInfoEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
8
+ 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 | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | SessionLimitsExhaustedRequestedEvent | SessionLimitsExhaustedCompletedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
9
9
  /**
10
10
  * Hosting platform type of the repository (github or ado)
11
11
  */
@@ -246,7 +246,7 @@ export type BinaryAssetReferenceType =
246
246
  /**
247
247
  * A content block within a tool result, which may be text, terminal output, image, audio, or a resource
248
248
  */
249
- export type ToolExecutionCompleteContent = ToolExecutionCompleteContentText | ToolExecutionCompleteContentTerminal | ToolExecutionCompleteContentImage | ToolExecutionCompleteContentAudio | ToolExecutionCompleteContentResourceLink | ToolExecutionCompleteContentResource;
249
+ export type ToolExecutionCompleteContent = ToolExecutionCompleteContentText | ToolExecutionCompleteContentTerminal | ToolExecutionCompleteContentShellExit | ToolExecutionCompleteContentImage | ToolExecutionCompleteContentAudio | ToolExecutionCompleteContentResourceLink | ToolExecutionCompleteContentResource;
250
250
  /**
251
251
  * Theme variant this icon is intended for
252
252
  */
@@ -415,6 +415,18 @@ export type AutoModeSwitchResponse =
415
415
  | "yes_always"
416
416
  /** Do not switch models. */
417
417
  | "no";
418
+ /**
419
+ * User action selected for an exhausted session limit.
420
+ */
421
+ export type SessionLimitsExhaustedResponseAction =
422
+ /** Increase the current max by an exact AI Credits amount. */
423
+ "add"
424
+ /** Set a new absolute max AI Credits value. */
425
+ | "set"
426
+ /** Remove the current session limit. */
427
+ | "unset"
428
+ /** Leave the limit unchanged and cancel the blocked model request. */
429
+ | "cancel";
418
430
  /**
419
431
  * Exit plan mode action
420
432
  */
@@ -573,7 +585,6 @@ export interface StartData {
573
585
  * Whether this session supports remote steering via GitHub
574
586
  */
575
587
  remoteSteerable?: boolean;
576
- responseBudget?: ResponseBudgetConfig;
577
588
  /**
578
589
  * Model selected at session creation time, if any
579
590
  */
@@ -582,6 +593,7 @@ export interface StartData {
582
593
  * Unique identifier for the session
583
594
  */
584
595
  sessionId: string;
596
+ sessionLimits?: SessionLimitsConfig;
585
597
  /**
586
598
  * ISO 8601 timestamp when the session was created
587
599
  */
@@ -626,17 +638,13 @@ export interface WorkingDirectoryContext {
626
638
  repositoryHost?: string;
627
639
  }
628
640
  /**
629
- * Optional response budget limits.
641
+ * Optional session limits.
630
642
  */
631
- export interface ResponseBudgetConfig {
643
+ export interface SessionLimitsConfig {
632
644
  /**
633
- * Maximum AI Credits allowed while responding to one top-level user message.
645
+ * Maximum AI Credits allowed across the session's current accounting window.
634
646
  */
635
647
  maxAiCredits?: number;
636
- /**
637
- * Maximum model-call iterations allowed while responding to one top-level user message.
638
- */
639
- maxModelIterations?: number;
640
648
  }
641
649
  /**
642
650
  * Session event "session.resume". Session resume metadata including current context and event count
@@ -702,10 +710,6 @@ export interface ResumeData {
702
710
  * Whether this session supports remote steering via GitHub
703
711
  */
704
712
  remoteSteerable?: boolean;
705
- /**
706
- * Response budget limits currently configured at resume time; null when no budget is active
707
- */
708
- responseBudget?: ResponseBudgetConfig | null;
709
713
  /**
710
714
  * ISO 8601 timestamp when the session was resumed
711
715
  */
@@ -714,6 +718,10 @@ export interface ResumeData {
714
718
  * Model currently selected at resume time
715
719
  */
716
720
  selectedModel?: string;
721
+ /**
722
+ * Session limits currently configured at resume time; null when no limits are active
723
+ */
724
+ sessionLimits?: SessionLimitsConfig | null;
717
725
  /**
718
726
  * True when this resume attached to a session that the runtime already had running in-memory (for example, an extension joining a session another client was actively driving). False (or omitted) for cold resumes — the runtime had to reconstitute the session from its persisted event log.
719
727
  */
@@ -1297,6 +1305,45 @@ export interface ModeChangedData {
1297
1305
  newMode: SessionMode;
1298
1306
  previousMode: SessionMode;
1299
1307
  }
1308
+ /**
1309
+ * Session event "session.session_limits_changed". Session limits update details. Null clears the limits.
1310
+ */
1311
+ export interface SessionLimitsChangedEvent {
1312
+ /**
1313
+ * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
1314
+ */
1315
+ agentId?: string;
1316
+ data: SessionLimitsChangedData;
1317
+ /**
1318
+ * When true, the event is transient and not persisted to the session event log on disk
1319
+ */
1320
+ ephemeral?: boolean;
1321
+ /**
1322
+ * Unique event identifier (UUID v4), generated when the event is emitted
1323
+ */
1324
+ id: string;
1325
+ /**
1326
+ * ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
1327
+ */
1328
+ parentId: string | null;
1329
+ /**
1330
+ * ISO 8601 timestamp when the event was created
1331
+ */
1332
+ timestamp: string;
1333
+ /**
1334
+ * Type discriminator. Always "session.session_limits_changed".
1335
+ */
1336
+ type: "session.session_limits_changed";
1337
+ }
1338
+ /**
1339
+ * Session limits update details. Null clears the limits.
1340
+ */
1341
+ export interface SessionLimitsChangedData {
1342
+ /**
1343
+ * Current session limits, or null when no limits are active
1344
+ */
1345
+ sessionLimits: SessionLimitsConfig | null;
1346
+ }
1300
1347
  /**
1301
1348
  * Session event "session.permissions_changed". Permissions change details carrying the aggregate allow-all boolean transition.
1302
1349
  */
@@ -1822,6 +1869,45 @@ export interface ShutdownTokenDetail {
1822
1869
  */
1823
1870
  tokenCount: number;
1824
1871
  }
1872
+ /**
1873
+ * Session event "session.usage_checkpoint". Durable session usage checkpoint for reconstructing aggregate accounting on resume
1874
+ */
1875
+ export interface UsageCheckpointEvent {
1876
+ /**
1877
+ * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
1878
+ */
1879
+ agentId?: string;
1880
+ data: UsageCheckpointData;
1881
+ /**
1882
+ * When true, the event is transient and not persisted to the session event log on disk
1883
+ */
1884
+ ephemeral?: boolean;
1885
+ /**
1886
+ * Unique event identifier (UUID v4), generated when the event is emitted
1887
+ */
1888
+ id: string;
1889
+ /**
1890
+ * ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
1891
+ */
1892
+ parentId: string | null;
1893
+ /**
1894
+ * ISO 8601 timestamp when the event was created
1895
+ */
1896
+ timestamp: string;
1897
+ /**
1898
+ * Type discriminator. Always "session.usage_checkpoint".
1899
+ */
1900
+ type: "session.usage_checkpoint";
1901
+ }
1902
+ /**
1903
+ * Durable session usage checkpoint for reconstructing aggregate accounting on resume
1904
+ */
1905
+ export interface UsageCheckpointData {
1906
+ /**
1907
+ * Session-wide accumulated nano-AI units cost at checkpoint time
1908
+ */
1909
+ totalNanoAiu: number;
1910
+ }
1825
1911
  /**
1826
1912
  * Session event "session.context_changed". Updated working directory and git context after the change
1827
1913
  */
@@ -2999,6 +3085,10 @@ export interface AssistantMessageData {
2999
3085
  * Readable reasoning text from the model's extended thinking
3000
3086
  */
3001
3087
  reasoningText?: string;
3088
+ /**
3089
+ * OpenAI-compatible wire field the provider used for reasoning (e.g. reasoning_content/reasoning). Populated only when non-canonical, so the dialect round-trips across turns.
3090
+ */
3091
+ reasoningWireField?: string;
3002
3092
  /**
3003
3093
  * GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
3004
3094
  */
@@ -4156,7 +4246,8 @@ export interface ToolExecutionCompleteContentText {
4156
4246
  type: "text";
4157
4247
  }
4158
4248
  /**
4159
- * Terminal/shell output content block with optional exit code and working directory
4249
+ * @deprecated
4250
+ * Deprecated for shell command exit metadata. Use ToolExecutionCompleteContentShellExit instead.
4160
4251
  */
4161
4252
  export interface ToolExecutionCompleteContentTerminal {
4162
4253
  /**
@@ -4176,6 +4267,35 @@ export interface ToolExecutionCompleteContentTerminal {
4176
4267
  */
4177
4268
  type: "terminal";
4178
4269
  }
4270
+ /**
4271
+ * Shell command exit metadata with optional output preview
4272
+ */
4273
+ export interface ToolExecutionCompleteContentShellExit {
4274
+ /**
4275
+ * Working directory where the shell command was executed
4276
+ */
4277
+ cwd?: string;
4278
+ /**
4279
+ * Exit code from the completed shell command
4280
+ */
4281
+ exitCode: number;
4282
+ /**
4283
+ * Output associated with this shell command, if available. May be partial, truncated, or a preview; not guaranteed to be full output.
4284
+ */
4285
+ outputPreview?: string;
4286
+ /**
4287
+ * Whether outputPreview is known to be incomplete or truncated
4288
+ */
4289
+ outputTruncated?: boolean;
4290
+ /**
4291
+ * Shell id, as assigned by Copilot runtime
4292
+ */
4293
+ shellId: string;
4294
+ /**
4295
+ * Content block type discriminator
4296
+ */
4297
+ type: "shell_exit";
4298
+ }
4179
4299
  /**
4180
4300
  * Image content block with base64-encoded data
4181
4301
  */
@@ -5382,6 +5502,14 @@ export interface PermissionRequestRead {
5382
5502
  * Path of the file or directory being read
5383
5503
  */
5384
5504
  path: string;
5505
+ /**
5506
+ * True when the model has requested to run this search outside the sandbox (it set requestSandboxBypass: true and the host opted in via sandbox.allowBypass). This is a request, not a grant: the search runs unsandboxed only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
5507
+ */
5508
+ requestSandboxBypass?: boolean;
5509
+ /**
5510
+ * Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
5511
+ */
5512
+ requestSandboxBypassReason?: string;
5385
5513
  /**
5386
5514
  * Tool call ID that triggered this permission request
5387
5515
  */
@@ -7053,6 +7181,107 @@ export interface AutoModeSwitchCompletedData {
7053
7181
  requestId: string;
7054
7182
  response: AutoModeSwitchResponse;
7055
7183
  }
7184
+ /**
7185
+ * Session event "session_limits_exhausted.requested". Session limit exhaustion notification requiring user action.
7186
+ */
7187
+ export interface SessionLimitsExhaustedRequestedEvent {
7188
+ /**
7189
+ * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
7190
+ */
7191
+ agentId?: string;
7192
+ data: SessionLimitsExhaustedRequestedData;
7193
+ /**
7194
+ * Always true for events that are transient and not persisted to the session event log on disk.
7195
+ */
7196
+ ephemeral: true;
7197
+ /**
7198
+ * Unique event identifier (UUID v4), generated when the event is emitted
7199
+ */
7200
+ id: string;
7201
+ /**
7202
+ * ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
7203
+ */
7204
+ parentId: string | null;
7205
+ /**
7206
+ * ISO 8601 timestamp when the event was created
7207
+ */
7208
+ timestamp: string;
7209
+ /**
7210
+ * Type discriminator. Always "session_limits_exhausted.requested".
7211
+ */
7212
+ type: "session_limits_exhausted.requested";
7213
+ }
7214
+ /**
7215
+ * Session limit exhaustion notification requiring user action.
7216
+ */
7217
+ export interface SessionLimitsExhaustedRequestedData {
7218
+ /**
7219
+ * Configured max AI Credits for the current accounting window.
7220
+ */
7221
+ maxAiCredits: number;
7222
+ /**
7223
+ * Unique identifier for this request; used to respond via session.ui.handlePendingSessionLimitsExhausted().
7224
+ */
7225
+ requestId: string;
7226
+ /**
7227
+ * AI Credits already consumed in the current accounting window.
7228
+ */
7229
+ usedAiCredits: number;
7230
+ }
7231
+ /**
7232
+ * Session event "session_limits_exhausted.completed". Session limit exhaustion prompt completion notification.
7233
+ */
7234
+ export interface SessionLimitsExhaustedCompletedEvent {
7235
+ /**
7236
+ * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
7237
+ */
7238
+ agentId?: string;
7239
+ data: SessionLimitsExhaustedCompletedData;
7240
+ /**
7241
+ * Always true for events that are transient and not persisted to the session event log on disk.
7242
+ */
7243
+ ephemeral: true;
7244
+ /**
7245
+ * Unique event identifier (UUID v4), generated when the event is emitted
7246
+ */
7247
+ id: string;
7248
+ /**
7249
+ * ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
7250
+ */
7251
+ parentId: string | null;
7252
+ /**
7253
+ * ISO 8601 timestamp when the event was created
7254
+ */
7255
+ timestamp: string;
7256
+ /**
7257
+ * Type discriminator. Always "session_limits_exhausted.completed".
7258
+ */
7259
+ type: "session_limits_exhausted.completed";
7260
+ }
7261
+ /**
7262
+ * Session limit exhaustion prompt completion notification.
7263
+ */
7264
+ export interface SessionLimitsExhaustedCompletedData {
7265
+ /**
7266
+ * Request ID of the resolved request; clients should dismiss any UI for this request.
7267
+ */
7268
+ requestId: string;
7269
+ response: SessionLimitsExhaustedResponse;
7270
+ }
7271
+ /**
7272
+ * The user's selected action for an exhausted session limit.
7273
+ */
7274
+ export interface SessionLimitsExhaustedResponse {
7275
+ action: SessionLimitsExhaustedResponseAction;
7276
+ /**
7277
+ * AI Credits to add to the current max when action is 'add'.
7278
+ */
7279
+ additionalAiCredits?: number;
7280
+ /**
7281
+ * New absolute max AI Credits when action is 'set'.
7282
+ */
7283
+ maxAiCredits?: number;
7284
+ }
7056
7285
  /**
7057
7286
  * Session event "commands.changed". SDK command registration change notification
7058
7287
  */
package/dist/session.d.ts CHANGED
@@ -41,6 +41,7 @@ export declare class CopilotSession {
41
41
  private bearerTokenProviders;
42
42
  private commandHandlers;
43
43
  private permissionHandler?;
44
+ private mcpAuthHandler?;
44
45
  private userInputHandler?;
45
46
  private elicitationHandler?;
46
47
  private exitPlanModeHandler?;
package/dist/session.js CHANGED
@@ -27,11 +27,12 @@ class CopilotSession {
27
27
  * @param traceContextProvider - Optional callback to get W3C Trace Context for outbound RPCs
28
28
  * @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
29
29
  */
30
- constructor(sessionId, connection, _workspacePath, traceContextProvider) {
30
+ constructor(sessionId, connection, _workspacePath, traceContextProvider, options) {
31
31
  this.sessionId = sessionId;
32
32
  this.connection = connection;
33
33
  this._workspacePath = _workspacePath;
34
34
  this.traceContextProvider = traceContextProvider;
35
+ this.mcpAuthHandler = options?.mcpAuthHandler;
35
36
  }
36
37
  sessionId;
37
38
  connection;
@@ -43,6 +44,7 @@ class CopilotSession {
43
44
  bearerTokenProviders = /* @__PURE__ */ new Map();
44
45
  commandHandlers = /* @__PURE__ */ new Map();
45
46
  permissionHandler;
47
+ mcpAuthHandler;
46
48
  userInputHandler;
47
49
  elicitationHandler;
48
50
  exitPlanModeHandler;
@@ -254,6 +256,18 @@ class CopilotSession {
254
256
  if (this.permissionHandler) {
255
257
  void this._executePermissionAndRespond(requestId, permissionRequest);
256
258
  }
259
+ } else if (event.type === "mcp.oauth_required") {
260
+ const data = event.data;
261
+ if (!data?.requestId) {
262
+ return;
263
+ }
264
+ if (!this.mcpAuthHandler) {
265
+ console.warn(
266
+ `Received MCP OAuth request without a registered MCP auth handler. SessionId=${this.sessionId}, RequestId=${data.requestId}`
267
+ );
268
+ return;
269
+ }
270
+ void this._executeMcpAuthAndRespond(data);
257
271
  } else if (event.type === "command.execute") {
258
272
  const { requestId, commandName, command, args } = event.data;
259
273
  void this._executeCommandAndRespond(requestId, commandName, command, args);
@@ -385,6 +399,31 @@ class CopilotSession {
385
399
  }
386
400
  }
387
401
  }
402
+ /**
403
+ * Executes an MCP auth handler and sends the result back via RPC.
404
+ * @internal
405
+ */
406
+ async _executeMcpAuthAndRespond(request) {
407
+ try {
408
+ const result = await this.mcpAuthHandler(request, { sessionId: this.sessionId });
409
+ const response = result && "accessToken" in result ? { kind: "token", ...result } : { kind: "cancelled" };
410
+ await this.rpc.mcp.oauth.handlePendingRequest({
411
+ requestId: request.requestId,
412
+ result: response
413
+ });
414
+ } catch (_error) {
415
+ try {
416
+ await this.rpc.mcp.oauth.handlePendingRequest({
417
+ requestId: request.requestId,
418
+ result: { kind: "cancelled" }
419
+ });
420
+ } catch (rpcError) {
421
+ if (!(rpcError instanceof ConnectionError || rpcError instanceof ResponseError)) {
422
+ throw rpcError;
423
+ }
424
+ }
425
+ }
426
+ }
388
427
  /**
389
428
  * Executes a command handler and sends the result back via RPC.
390
429
  * @internal