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

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 */
@@ -1819,6 +1847,23 @@ function createSessionRpc(connection, sessionId) {
1819
1847
  notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { sessionId, ...params })
1820
1848
  },
1821
1849
  /** @experimental */
1850
+ visibility: {
1851
+ /**
1852
+ * 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").
1853
+ *
1854
+ * @returns Current sharing status and shareable GitHub URL for a session.
1855
+ */
1856
+ get: async () => connection.sendRequest("session.visibility.get", { sessionId }),
1857
+ /**
1858
+ * 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.
1859
+ *
1860
+ * @param params Desired sharing status for the session.
1861
+ *
1862
+ * @returns Effective sharing status and shareable GitHub URL after updating session visibility.
1863
+ */
1864
+ set: async (params) => connection.sendRequest("session.visibility.set", { sessionId, ...params })
1865
+ },
1866
+ /** @experimental */
1822
1867
  schedule: {
1823
1868
  /**
1824
1869
  * Lists the session's currently active scheduled prompts.
@@ -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 | ResponseLimitsChangedEvent | 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;
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
  */
@@ -573,7 +573,7 @@ export interface StartData {
573
573
  * Whether this session supports remote steering via GitHub
574
574
  */
575
575
  remoteSteerable?: boolean;
576
- responseBudget?: ResponseBudgetConfig;
576
+ responseLimits?: ResponseLimitsConfig;
577
577
  /**
578
578
  * Model selected at session creation time, if any
579
579
  */
@@ -626,17 +626,13 @@ export interface WorkingDirectoryContext {
626
626
  repositoryHost?: string;
627
627
  }
628
628
  /**
629
- * Optional response budget limits.
629
+ * Optional response limits.
630
630
  */
631
- export interface ResponseBudgetConfig {
631
+ export interface ResponseLimitsConfig {
632
632
  /**
633
633
  * Maximum AI Credits allowed while responding to one top-level user message.
634
634
  */
635
635
  maxAiCredits?: number;
636
- /**
637
- * Maximum model-call iterations allowed while responding to one top-level user message.
638
- */
639
- maxModelIterations?: number;
640
636
  }
641
637
  /**
642
638
  * Session event "session.resume". Session resume metadata including current context and event count
@@ -703,9 +699,9 @@ export interface ResumeData {
703
699
  */
704
700
  remoteSteerable?: boolean;
705
701
  /**
706
- * Response budget limits currently configured at resume time; null when no budget is active
702
+ * Response limits currently configured at resume time; null when no limits are active
707
703
  */
708
- responseBudget?: ResponseBudgetConfig | null;
704
+ responseLimits?: ResponseLimitsConfig | null;
709
705
  /**
710
706
  * ISO 8601 timestamp when the session was resumed
711
707
  */
@@ -1297,6 +1293,45 @@ export interface ModeChangedData {
1297
1293
  newMode: SessionMode;
1298
1294
  previousMode: SessionMode;
1299
1295
  }
1296
+ /**
1297
+ * Session event "session.response_limits_changed". Response limits update details. Null clears the limits.
1298
+ */
1299
+ export interface ResponseLimitsChangedEvent {
1300
+ /**
1301
+ * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
1302
+ */
1303
+ agentId?: string;
1304
+ data: ResponseLimitsChangedData;
1305
+ /**
1306
+ * When true, the event is transient and not persisted to the session event log on disk
1307
+ */
1308
+ ephemeral?: boolean;
1309
+ /**
1310
+ * Unique event identifier (UUID v4), generated when the event is emitted
1311
+ */
1312
+ id: string;
1313
+ /**
1314
+ * ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
1315
+ */
1316
+ parentId: string | null;
1317
+ /**
1318
+ * ISO 8601 timestamp when the event was created
1319
+ */
1320
+ timestamp: string;
1321
+ /**
1322
+ * Type discriminator. Always "session.response_limits_changed".
1323
+ */
1324
+ type: "session.response_limits_changed";
1325
+ }
1326
+ /**
1327
+ * Response limits update details. Null clears the limits.
1328
+ */
1329
+ export interface ResponseLimitsChangedData {
1330
+ /**
1331
+ * Current response limits for the session, or null when no limits are active
1332
+ */
1333
+ responseLimits: ResponseLimitsConfig | null;
1334
+ }
1300
1335
  /**
1301
1336
  * Session event "session.permissions_changed". Permissions change details carrying the aggregate allow-all boolean transition.
1302
1337
  */
@@ -4156,7 +4191,8 @@ export interface ToolExecutionCompleteContentText {
4156
4191
  type: "text";
4157
4192
  }
4158
4193
  /**
4159
- * Terminal/shell output content block with optional exit code and working directory
4194
+ * @deprecated
4195
+ * Deprecated for shell command exit metadata. Use ToolExecutionCompleteContentShellExit instead.
4160
4196
  */
4161
4197
  export interface ToolExecutionCompleteContentTerminal {
4162
4198
  /**
@@ -4176,6 +4212,35 @@ export interface ToolExecutionCompleteContentTerminal {
4176
4212
  */
4177
4213
  type: "terminal";
4178
4214
  }
4215
+ /**
4216
+ * Shell command exit metadata with optional output preview
4217
+ */
4218
+ export interface ToolExecutionCompleteContentShellExit {
4219
+ /**
4220
+ * Working directory where the shell command was executed
4221
+ */
4222
+ cwd?: string;
4223
+ /**
4224
+ * Exit code from the completed shell command
4225
+ */
4226
+ exitCode: number;
4227
+ /**
4228
+ * Output associated with this shell command, if available. May be partial, truncated, or a preview; not guaranteed to be full output.
4229
+ */
4230
+ outputPreview?: string;
4231
+ /**
4232
+ * Whether outputPreview is known to be incomplete or truncated
4233
+ */
4234
+ outputTruncated?: boolean;
4235
+ /**
4236
+ * Shell id, as assigned by Copilot runtime
4237
+ */
4238
+ shellId: string;
4239
+ /**
4240
+ * Content block type discriminator
4241
+ */
4242
+ type: "shell_exit";
4243
+ }
4179
4244
  /**
4180
4245
  * Image content block with base64-encoded data
4181
4246
  */
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
package/dist/types.d.ts CHANGED
@@ -1280,6 +1280,68 @@ export type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
1280
1280
  * long-context tier when the selected model supports it.
1281
1281
  */
1282
1282
  export type ContextTier = "default" | "long_context";
1283
+ /** Parsed parameters from an MCP server's WWW-Authenticate response. */
1284
+ export interface McpAuthWwwAuthenticateParams {
1285
+ /** Parsed resource_metadata URL used for protected-resource metadata discovery, if present. */
1286
+ resourceMetadataUrl?: string;
1287
+ /** Parsed OAuth scope, if present. */
1288
+ scope?: string;
1289
+ /** Parsed OAuth error, if present. */
1290
+ error?: string;
1291
+ }
1292
+ /** Static OAuth client configuration supplied by the MCP server, if available. */
1293
+ export interface McpAuthStaticClientConfig {
1294
+ /** OAuth client ID for the server. */
1295
+ clientId: string;
1296
+ /** Optional OAuth client secret for confidential static clients. */
1297
+ clientSecret?: string;
1298
+ /** Optional non-default OAuth grant type. */
1299
+ grantType?: "client_credentials";
1300
+ /** Whether this is a public OAuth client. */
1301
+ publicClient?: boolean;
1302
+ }
1303
+ /** MCP OAuth request that the SDK host can satisfy with a host-acquired token. */
1304
+ export interface McpAuthRequest {
1305
+ /** Unique request identifier used by the SDK when responding. */
1306
+ requestId: string;
1307
+ /** Display name of the MCP server that requires OAuth. */
1308
+ serverName: string;
1309
+ /** URL of the MCP server that requires OAuth. */
1310
+ serverUrl: string;
1311
+ /** Why the runtime is requesting host-provided OAuth credentials. */
1312
+ reason: "initial" | "refresh" | "reauth" | "upscope";
1313
+ /** Parsed WWW-Authenticate parameters from the MCP server. */
1314
+ wwwAuthenticateParams?: McpAuthWwwAuthenticateParams;
1315
+ /** Raw RFC 9728 protected-resource metadata JSON fetched by the runtime, if available. */
1316
+ resourceMetadata?: string;
1317
+ /** Static OAuth client configuration, if the server specifies one. */
1318
+ staticClientConfig?: McpAuthStaticClientConfig;
1319
+ }
1320
+ /** Host-provided OAuth token data for a pending MCP OAuth request. */
1321
+ export interface McpAuthToken {
1322
+ /** Access token acquired by the SDK host. */
1323
+ accessToken: string;
1324
+ /** OAuth token type. Defaults to Bearer when omitted. */
1325
+ tokenType?: string;
1326
+ /** Token lifetime in seconds, if known. */
1327
+ expiresIn?: number;
1328
+ }
1329
+ /**
1330
+ * Result returned by an MCP auth request handler.
1331
+ *
1332
+ * Return `null`/`undefined` or `{ kind: "cancelled" }` to cancel the pending
1333
+ * OAuth request. Return `{ kind: "token", ... }` to provide host-acquired
1334
+ * OAuth token data.
1335
+ */
1336
+ export type McpAuthResult = ({
1337
+ kind: "token";
1338
+ } & McpAuthToken) | {
1339
+ kind: "cancelled";
1340
+ };
1341
+ /** Callback invoked when an MCP server requires OAuth and the SDK host opted in. */
1342
+ export type McpAuthHandler = (request: McpAuthRequest, context: {
1343
+ sessionId: string;
1344
+ }) => McpAuthResult | McpAuthToken | null | undefined | Promise<McpAuthResult | McpAuthToken | null | undefined>;
1283
1345
  /**
1284
1346
  * Stable extension identity for session participants that provide canvases.
1285
1347
  */
@@ -1531,6 +1593,12 @@ export interface SessionConfigBase {
1531
1593
  * the consumer to resolve via the pending permission RPC.
1532
1594
  */
1533
1595
  onPermissionRequest?: PermissionHandler;
1596
+ /**
1597
+ * Optional handler for MCP OAuth requests from MCP servers.
1598
+ * When provided, the SDK can satisfy MCP server OAuth requests with
1599
+ * host-provided token data or cancellation.
1600
+ */
1601
+ onMcpAuthRequest?: McpAuthHandler;
1534
1602
  /**
1535
1603
  * Handler for user input requests from the agent.
1536
1604
  * When provided, enables the ask_user tool allowing the agent to ask questions.
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.5-preview.0",
7
+ "version": "1.0.5-preview.1",
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.66-1",
59
+ "@github/copilot": "^1.0.66-2",
60
60
  "vscode-jsonrpc": "^8.2.1",
61
61
  "zod": "^4.3.6"
62
62
  },