@github/copilot-sdk 1.0.0-beta.2 → 1.0.0-beta.4

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
@@ -38,7 +38,7 @@ const session = await client.createSession({
38
38
  onPermissionRequest: approveAll,
39
39
  });
40
40
 
41
- // Wait for response using typed event handlers
41
+ // Wait for the response using typed event handlers
42
42
  const done = new Promise<void>((resolve) => {
43
43
  session.on("assistant.message", (event) => {
44
44
  console.log(event.data.content);
@@ -530,6 +530,12 @@ class CopilotClient {
530
530
  if (config.onElicitationRequest) {
531
531
  session.registerElicitationHandler(config.onElicitationRequest);
532
532
  }
533
+ if (config.onExitPlanMode) {
534
+ session.registerExitPlanModeHandler(config.onExitPlanMode);
535
+ }
536
+ if (config.onAutoModeSwitch) {
537
+ session.registerAutoModeSwitchHandler(config.onAutoModeSwitch);
538
+ }
533
539
  if (config.hooks) {
534
540
  session.registerHooks(config.hooks);
535
541
  }
@@ -576,10 +582,13 @@ class CopilotClient {
576
582
  availableTools: config.availableTools,
577
583
  excludedTools: config.excludedTools,
578
584
  provider: config.provider ? toWireProviderConfig(config.provider) : void 0,
585
+ enableSessionTelemetry: config.enableSessionTelemetry,
579
586
  modelCapabilities: config.modelCapabilities,
580
587
  requestPermission: true,
581
588
  requestUserInput: !!config.onUserInputRequest,
582
589
  requestElicitation: !!config.onElicitationRequest,
590
+ requestExitPlanMode: !!config.onExitPlanMode,
591
+ requestAutoModeSwitch: !!config.onAutoModeSwitch,
583
592
  hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
584
593
  workingDirectory: config.workingDirectory,
585
594
  streaming: config.streaming,
@@ -658,6 +667,12 @@ class CopilotClient {
658
667
  if (config.onElicitationRequest) {
659
668
  session.registerElicitationHandler(config.onElicitationRequest);
660
669
  }
670
+ if (config.onExitPlanMode) {
671
+ session.registerExitPlanModeHandler(config.onExitPlanMode);
672
+ }
673
+ if (config.onAutoModeSwitch) {
674
+ session.registerAutoModeSwitchHandler(config.onAutoModeSwitch);
675
+ }
661
676
  if (config.hooks) {
662
677
  session.registerHooks(config.hooks);
663
678
  }
@@ -692,6 +707,7 @@ class CopilotClient {
692
707
  systemMessage: wireSystemMessage,
693
708
  availableTools: config.availableTools,
694
709
  excludedTools: config.excludedTools,
710
+ enableSessionTelemetry: config.enableSessionTelemetry,
695
711
  tools: config.tools?.map((tool) => ({
696
712
  name: tool.name,
697
713
  description: tool.description,
@@ -708,6 +724,8 @@ class CopilotClient {
708
724
  requestPermission: config.onPermissionRequest !== import_types.defaultJoinSessionPermissionHandler,
709
725
  requestUserInput: !!config.onUserInputRequest,
710
726
  requestElicitation: !!config.onElicitationRequest,
727
+ requestExitPlanMode: !!config.onExitPlanMode,
728
+ requestAutoModeSwitch: !!config.onAutoModeSwitch,
711
729
  hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
712
730
  workingDirectory: config.workingDirectory,
713
731
  configDir: config.configDir,
@@ -1332,6 +1350,14 @@ stderr: ${stderrOutput}`
1332
1350
  "userInput.request",
1333
1351
  async (params) => await this.handleUserInputRequest(params)
1334
1352
  );
1353
+ this.connection.onRequest(
1354
+ "exitPlanMode.request",
1355
+ async (params) => await this.handleExitPlanModeRequest(params)
1356
+ );
1357
+ this.connection.onRequest(
1358
+ "autoModeSwitch.request",
1359
+ async (params) => await this.handleAutoModeSwitchRequest(params)
1360
+ );
1335
1361
  this.connection.onRequest(
1336
1362
  "hooks.invoke",
1337
1363
  async (params) => await this.handleHooksInvoke(params)
@@ -1398,6 +1424,35 @@ stderr: ${stderrOutput}`
1398
1424
  });
1399
1425
  return result;
1400
1426
  }
1427
+ async handleExitPlanModeRequest(params) {
1428
+ if (!params || typeof params.sessionId !== "string" || typeof params.summary !== "string" || !Array.isArray(params.actions) || typeof params.recommendedAction !== "string") {
1429
+ throw new Error("Invalid exit plan mode request payload");
1430
+ }
1431
+ const session = this.sessions.get(params.sessionId);
1432
+ if (!session) {
1433
+ throw new Error(`Session not found: ${params.sessionId}`);
1434
+ }
1435
+ return await session._handleExitPlanModeRequest({
1436
+ summary: params.summary,
1437
+ planContent: params.planContent,
1438
+ actions: params.actions,
1439
+ recommendedAction: params.recommendedAction
1440
+ });
1441
+ }
1442
+ async handleAutoModeSwitchRequest(params) {
1443
+ if (!params || typeof params.sessionId !== "string") {
1444
+ throw new Error("Invalid auto mode switch request payload");
1445
+ }
1446
+ const session = this.sessions.get(params.sessionId);
1447
+ if (!session) {
1448
+ throw new Error(`Session not found: ${params.sessionId}`);
1449
+ }
1450
+ const response = await session._handleAutoModeSwitchRequest({
1451
+ errorCode: params.errorCode,
1452
+ retryAfterSeconds: params.retryAfterSeconds
1453
+ });
1454
+ return { response };
1455
+ }
1401
1456
  async handleHooksInvoke(params) {
1402
1457
  if (!params || typeof params.sessionId !== "string" || typeof params.hookType !== "string") {
1403
1458
  throw new Error("Invalid hooks invoke payload");
@@ -117,7 +117,8 @@ function createSessionRpc(connection, sessionId) {
117
117
  list: async () => connection.sendRequest("session.tasks.list", { sessionId }),
118
118
  promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { sessionId, ...params }),
119
119
  cancel: async (params) => connection.sendRequest("session.tasks.cancel", { sessionId, ...params }),
120
- remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params })
120
+ remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params }),
121
+ sendMessage: async (params) => connection.sendRequest("session.tasks.sendMessage", { sessionId, ...params })
121
122
  },
122
123
  /** @experimental */
123
124
  skills: {
@@ -152,7 +153,8 @@ function createSessionRpc(connection, sessionId) {
152
153
  handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { sessionId, ...params })
153
154
  },
154
155
  commands: {
155
- handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params })
156
+ handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params }),
157
+ respondToQueuedCommand: async (params) => connection.sendRequest("session.commands.respondToQueuedCommand", { sessionId, ...params })
156
158
  },
157
159
  ui: {
158
160
  elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params }),
@@ -49,6 +49,8 @@ class CopilotSession {
49
49
  permissionHandler;
50
50
  userInputHandler;
51
51
  elicitationHandler;
52
+ exitPlanModeHandler;
53
+ autoModeSwitchHandler;
52
54
  hooks;
53
55
  transformCallbacks;
54
56
  _rpc = null;
@@ -444,6 +446,24 @@ class CopilotSession {
444
446
  registerElicitationHandler(handler) {
445
447
  this.elicitationHandler = handler;
446
448
  }
449
+ /**
450
+ * Registers the exit-plan-mode handler for this session.
451
+ *
452
+ * @param handler - The handler to invoke when the server dispatches an exit-plan-mode request
453
+ * @internal This method is typically called internally when creating/resuming a session.
454
+ */
455
+ registerExitPlanModeHandler(handler) {
456
+ this.exitPlanModeHandler = handler;
457
+ }
458
+ /**
459
+ * Registers the auto-mode-switch handler for this session.
460
+ *
461
+ * @param handler - The handler to invoke when the server dispatches an auto-mode-switch request
462
+ * @internal This method is typically called internally when creating/resuming a session.
463
+ */
464
+ registerAutoModeSwitchHandler(handler) {
465
+ this.autoModeSwitchHandler = handler;
466
+ }
447
467
  /**
448
468
  * Handles an elicitation.requested broadcast event.
449
469
  * Invokes the registered handler and responds via handlePendingElicitation RPC.
@@ -469,6 +489,26 @@ class CopilotSession {
469
489
  }
470
490
  }
471
491
  }
492
+ /**
493
+ * Handles an exitPlanMode.request callback from the runtime.
494
+ * @internal
495
+ */
496
+ async _handleExitPlanModeRequest(request) {
497
+ if (!this.exitPlanModeHandler) {
498
+ return { approved: true };
499
+ }
500
+ return await this.exitPlanModeHandler(request, { sessionId: this.sessionId });
501
+ }
502
+ /**
503
+ * Handles an autoModeSwitch.request callback from the runtime.
504
+ * @internal
505
+ */
506
+ async _handleAutoModeSwitchRequest(request) {
507
+ if (!this.autoModeSwitchHandler) {
508
+ return "no";
509
+ }
510
+ return await this.autoModeSwitchHandler(request, { sessionId: this.sessionId });
511
+ }
472
512
  /**
473
513
  * Sets the host capabilities for this session.
474
514
  *
@@ -749,6 +789,10 @@ class CopilotSession {
749
789
  this.typedEventHandlers.clear();
750
790
  this.toolHandlers.clear();
751
791
  this.permissionHandler = void 0;
792
+ this.userInputHandler = void 0;
793
+ this.elicitationHandler = void 0;
794
+ this.exitPlanModeHandler = void 0;
795
+ this.autoModeSwitchHandler = void 0;
752
796
  }
753
797
  /**
754
798
  * @deprecated Use {@link disconnect} instead. This method will be removed in a future release.
package/dist/cjs/types.js CHANGED
@@ -51,9 +51,10 @@ function convertMcpCallToolResult(callResult) {
51
51
  textParts.push(block.resource.text);
52
52
  }
53
53
  if (block.resource?.blob) {
54
+ const mimeType = block.resource.mimeType;
54
55
  binaryResults.push({
55
56
  data: block.resource.blob,
56
- mimeType: block.resource.mimeType ?? "application/octet-stream",
57
+ mimeType: typeof mimeType === "string" && mimeType ? mimeType : "application/octet-stream",
57
58
  type: "resource",
58
59
  description: block.resource.uri
59
60
  });
package/dist/client.d.ts CHANGED
@@ -455,6 +455,8 @@ export declare class CopilotClient {
455
455
  private handleSessionEventNotification;
456
456
  private handleSessionLifecycleNotification;
457
457
  private handleUserInputRequest;
458
+ private handleExitPlanModeRequest;
459
+ private handleAutoModeSwitchRequest;
458
460
  private handleHooksInvoke;
459
461
  private handleSystemMessageTransform;
460
462
  /**
package/dist/client.js CHANGED
@@ -516,6 +516,12 @@ class CopilotClient {
516
516
  if (config.onElicitationRequest) {
517
517
  session.registerElicitationHandler(config.onElicitationRequest);
518
518
  }
519
+ if (config.onExitPlanMode) {
520
+ session.registerExitPlanModeHandler(config.onExitPlanMode);
521
+ }
522
+ if (config.onAutoModeSwitch) {
523
+ session.registerAutoModeSwitchHandler(config.onAutoModeSwitch);
524
+ }
519
525
  if (config.hooks) {
520
526
  session.registerHooks(config.hooks);
521
527
  }
@@ -562,10 +568,13 @@ class CopilotClient {
562
568
  availableTools: config.availableTools,
563
569
  excludedTools: config.excludedTools,
564
570
  provider: config.provider ? toWireProviderConfig(config.provider) : void 0,
571
+ enableSessionTelemetry: config.enableSessionTelemetry,
565
572
  modelCapabilities: config.modelCapabilities,
566
573
  requestPermission: true,
567
574
  requestUserInput: !!config.onUserInputRequest,
568
575
  requestElicitation: !!config.onElicitationRequest,
576
+ requestExitPlanMode: !!config.onExitPlanMode,
577
+ requestAutoModeSwitch: !!config.onAutoModeSwitch,
569
578
  hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
570
579
  workingDirectory: config.workingDirectory,
571
580
  streaming: config.streaming,
@@ -644,6 +653,12 @@ class CopilotClient {
644
653
  if (config.onElicitationRequest) {
645
654
  session.registerElicitationHandler(config.onElicitationRequest);
646
655
  }
656
+ if (config.onExitPlanMode) {
657
+ session.registerExitPlanModeHandler(config.onExitPlanMode);
658
+ }
659
+ if (config.onAutoModeSwitch) {
660
+ session.registerAutoModeSwitchHandler(config.onAutoModeSwitch);
661
+ }
647
662
  if (config.hooks) {
648
663
  session.registerHooks(config.hooks);
649
664
  }
@@ -678,6 +693,7 @@ class CopilotClient {
678
693
  systemMessage: wireSystemMessage,
679
694
  availableTools: config.availableTools,
680
695
  excludedTools: config.excludedTools,
696
+ enableSessionTelemetry: config.enableSessionTelemetry,
681
697
  tools: config.tools?.map((tool) => ({
682
698
  name: tool.name,
683
699
  description: tool.description,
@@ -694,6 +710,8 @@ class CopilotClient {
694
710
  requestPermission: config.onPermissionRequest !== defaultJoinSessionPermissionHandler,
695
711
  requestUserInput: !!config.onUserInputRequest,
696
712
  requestElicitation: !!config.onElicitationRequest,
713
+ requestExitPlanMode: !!config.onExitPlanMode,
714
+ requestAutoModeSwitch: !!config.onAutoModeSwitch,
697
715
  hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
698
716
  workingDirectory: config.workingDirectory,
699
717
  configDir: config.configDir,
@@ -1318,6 +1336,14 @@ stderr: ${stderrOutput}`
1318
1336
  "userInput.request",
1319
1337
  async (params) => await this.handleUserInputRequest(params)
1320
1338
  );
1339
+ this.connection.onRequest(
1340
+ "exitPlanMode.request",
1341
+ async (params) => await this.handleExitPlanModeRequest(params)
1342
+ );
1343
+ this.connection.onRequest(
1344
+ "autoModeSwitch.request",
1345
+ async (params) => await this.handleAutoModeSwitchRequest(params)
1346
+ );
1321
1347
  this.connection.onRequest(
1322
1348
  "hooks.invoke",
1323
1349
  async (params) => await this.handleHooksInvoke(params)
@@ -1384,6 +1410,35 @@ stderr: ${stderrOutput}`
1384
1410
  });
1385
1411
  return result;
1386
1412
  }
1413
+ async handleExitPlanModeRequest(params) {
1414
+ if (!params || typeof params.sessionId !== "string" || typeof params.summary !== "string" || !Array.isArray(params.actions) || typeof params.recommendedAction !== "string") {
1415
+ throw new Error("Invalid exit plan mode request payload");
1416
+ }
1417
+ const session = this.sessions.get(params.sessionId);
1418
+ if (!session) {
1419
+ throw new Error(`Session not found: ${params.sessionId}`);
1420
+ }
1421
+ return await session._handleExitPlanModeRequest({
1422
+ summary: params.summary,
1423
+ planContent: params.planContent,
1424
+ actions: params.actions,
1425
+ recommendedAction: params.recommendedAction
1426
+ });
1427
+ }
1428
+ async handleAutoModeSwitchRequest(params) {
1429
+ if (!params || typeof params.sessionId !== "string") {
1430
+ throw new Error("Invalid auto mode switch request payload");
1431
+ }
1432
+ const session = this.sessions.get(params.sessionId);
1433
+ if (!session) {
1434
+ throw new Error(`Session not found: ${params.sessionId}`);
1435
+ }
1436
+ const response = await session._handleAutoModeSwitchRequest({
1437
+ errorCode: params.errorCode,
1438
+ retryAfterSeconds: params.retryAfterSeconds
1439
+ });
1440
+ return { response };
1441
+ }
1387
1442
  async handleHooksInvoke(params) {
1388
1443
  if (!params || typeof params.sessionId !== "string" || typeof params.hookType !== "string") {
1389
1444
  throw new Error("Invalid hooks invoke payload");
@@ -10,6 +10,13 @@ import type { MessageConnection } from "vscode-jsonrpc/node.js";
10
10
  * via the `definition` "AuthInfoType".
11
11
  */
12
12
  export type AuthInfoType = "hmac" | "env" | "user" | "gh-cli" | "api-key" | "token" | "copilot-api-token";
13
+ /**
14
+ * Result of the queued command execution
15
+ *
16
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
17
+ * via the `definition` "QueuedCommandResult".
18
+ */
19
+ export type QueuedCommandResult = QueuedCommandHandled | QueuedCommandNotHandled;
13
20
  /**
14
21
  * Server transport type: stdio, http, sse, or memory (local configs are normalized to stdio)
15
22
  *
@@ -122,6 +129,20 @@ export type McpServerStatus = "connected" | "failed" | "needs-auth" | "pending"
122
129
  * via the `definition` "McpServerSource".
123
130
  */
124
131
  export type McpServerSource = "user" | "workspace" | "plugin" | "builtin";
132
+ /**
133
+ * Model capability category for grouping in the model picker
134
+ *
135
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
136
+ * via the `definition` "ModelPickerCategory".
137
+ */
138
+ export type ModelPickerCategory = "lightweight" | "versatile" | "powerful";
139
+ /**
140
+ * Relative cost tier for token-based billing users
141
+ *
142
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
143
+ * via the `definition` "ModelPickerPriceCategory".
144
+ */
145
+ export type ModelPickerPriceCategory = "low" | "medium" | "high" | "very_high";
125
146
  /**
126
147
  * The agent mode. Valid values: "interactive", "plan", "autopilot".
127
148
  *
@@ -136,14 +157,14 @@ export type PermissionDecision = PermissionDecisionApproveOnce | PermissionDecis
136
157
  * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
137
158
  * via the `definition` "PermissionDecisionApproveForSessionApproval".
138
159
  */
139
- export type PermissionDecisionApproveForSessionApproval = PermissionDecisionApproveForSessionApprovalCommands | PermissionDecisionApproveForSessionApprovalRead | PermissionDecisionApproveForSessionApprovalWrite | PermissionDecisionApproveForSessionApprovalMcp | PermissionDecisionApproveForSessionApprovalMcpSampling | PermissionDecisionApproveForSessionApprovalMemory | PermissionDecisionApproveForSessionApprovalCustomTool;
160
+ export type PermissionDecisionApproveForSessionApproval = PermissionDecisionApproveForSessionApprovalCommands | PermissionDecisionApproveForSessionApprovalRead | PermissionDecisionApproveForSessionApprovalWrite | PermissionDecisionApproveForSessionApprovalMcp | PermissionDecisionApproveForSessionApprovalMcpSampling | PermissionDecisionApproveForSessionApprovalMemory | PermissionDecisionApproveForSessionApprovalCustomTool | PermissionDecisionApproveForSessionApprovalExtensionManagement | PermissionDecisionApproveForSessionApprovalExtensionPermissionAccess;
140
161
  /**
141
162
  * The approval to persist for this location
142
163
  *
143
164
  * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
144
165
  * via the `definition` "PermissionDecisionApproveForLocationApproval".
145
166
  */
146
- export type PermissionDecisionApproveForLocationApproval = PermissionDecisionApproveForLocationApprovalCommands | PermissionDecisionApproveForLocationApprovalRead | PermissionDecisionApproveForLocationApprovalWrite | PermissionDecisionApproveForLocationApprovalMcp | PermissionDecisionApproveForLocationApprovalMcpSampling | PermissionDecisionApproveForLocationApprovalMemory | PermissionDecisionApproveForLocationApprovalCustomTool;
167
+ export type PermissionDecisionApproveForLocationApproval = PermissionDecisionApproveForLocationApprovalCommands | PermissionDecisionApproveForLocationApprovalRead | PermissionDecisionApproveForLocationApprovalWrite | PermissionDecisionApproveForLocationApprovalMcp | PermissionDecisionApproveForLocationApprovalMcpSampling | PermissionDecisionApproveForLocationApprovalMemory | PermissionDecisionApproveForLocationApprovalCustomTool | PermissionDecisionApproveForLocationApprovalExtensionManagement | PermissionDecisionApproveForLocationApprovalExtensionPermissionAccess;
147
168
  /**
148
169
  * Error classification
149
170
  *
@@ -333,6 +354,35 @@ export interface CommandsHandlePendingCommandResult {
333
354
  */
334
355
  success: boolean;
335
356
  }
357
+ export interface CommandsRespondToQueuedCommandRequest {
358
+ /**
359
+ * Request ID from the queued command event
360
+ */
361
+ requestId: string;
362
+ result: QueuedCommandResult;
363
+ }
364
+ export interface QueuedCommandHandled {
365
+ /**
366
+ * The command was handled
367
+ */
368
+ handled: true;
369
+ /**
370
+ * If true, stop processing remaining queued items
371
+ */
372
+ stopProcessingQueue?: boolean;
373
+ }
374
+ export interface QueuedCommandNotHandled {
375
+ /**
376
+ * The command was not handled
377
+ */
378
+ handled: false;
379
+ }
380
+ export interface CommandsRespondToQueuedCommandResult {
381
+ /**
382
+ * Whether the response was accepted (false if the requestId was not found or already resolved)
383
+ */
384
+ success: boolean;
385
+ }
336
386
  /** @internal */
337
387
  export interface ConnectRequest {
338
388
  /**
@@ -945,6 +995,8 @@ export interface Model {
945
995
  * Default reasoning effort level (only present if model supports reasoning effort)
946
996
  */
947
997
  defaultReasoningEffort?: string;
998
+ modelPickerCategory?: ModelPickerCategory;
999
+ modelPickerPriceCategory?: ModelPickerPriceCategory;
948
1000
  }
949
1001
  /**
950
1002
  * Model capabilities and limits
@@ -1039,7 +1091,7 @@ export interface ModelBilling {
1039
1091
  /**
1040
1092
  * Billing cost multiplier relative to the base rate
1041
1093
  */
1042
- multiplier: number;
1094
+ multiplier?: number;
1043
1095
  }
1044
1096
  /**
1045
1097
  * Override individual model capabilities resolved by the runtime
@@ -1177,6 +1229,14 @@ export interface PermissionDecisionApproveForSessionApprovalCustomTool {
1177
1229
  kind: "custom-tool";
1178
1230
  toolName: string;
1179
1231
  }
1232
+ export interface PermissionDecisionApproveForSessionApprovalExtensionManagement {
1233
+ kind: "extension-management";
1234
+ operation?: string;
1235
+ }
1236
+ export interface PermissionDecisionApproveForSessionApprovalExtensionPermissionAccess {
1237
+ kind: "extension-permission-access";
1238
+ extensionName: string;
1239
+ }
1180
1240
  export interface PermissionDecisionApproveForLocation {
1181
1241
  /**
1182
1242
  * Approved and persisted for this project location
@@ -1214,6 +1274,14 @@ export interface PermissionDecisionApproveForLocationApprovalCustomTool {
1214
1274
  kind: "custom-tool";
1215
1275
  toolName: string;
1216
1276
  }
1277
+ export interface PermissionDecisionApproveForLocationApprovalExtensionManagement {
1278
+ kind: "extension-management";
1279
+ operation?: string;
1280
+ }
1281
+ export interface PermissionDecisionApproveForLocationApprovalExtensionPermissionAccess {
1282
+ kind: "extension-permission-access";
1283
+ extensionName: string;
1284
+ }
1217
1285
  export interface PermissionDecisionApprovePermanently {
1218
1286
  /**
1219
1287
  * Approved and persisted across sessions
@@ -1904,6 +1972,32 @@ export interface TasksRemoveResult {
1904
1972
  removed: boolean;
1905
1973
  }
1906
1974
  /** @experimental */
1975
+ export interface TasksSendMessageRequest {
1976
+ /**
1977
+ * Agent task identifier
1978
+ */
1979
+ id: string;
1980
+ /**
1981
+ * Message content to send to the agent
1982
+ */
1983
+ message: string;
1984
+ /**
1985
+ * Agent ID of the sender, if sent on behalf of another agent
1986
+ */
1987
+ fromAgentId?: string;
1988
+ }
1989
+ /** @experimental */
1990
+ export interface TasksSendMessageResult {
1991
+ /**
1992
+ * Whether the message was successfully delivered or steered
1993
+ */
1994
+ sent: boolean;
1995
+ /**
1996
+ * Error message if delivery failed
1997
+ */
1998
+ error?: string;
1999
+ }
2000
+ /** @experimental */
1907
2001
  export interface TasksStartAgentRequest {
1908
2002
  /**
1909
2003
  * Type of agent to start (e.g., 'explore', 'task', 'general-purpose')
@@ -2262,7 +2356,6 @@ export interface WorkspacesGetWorkspaceResult {
2262
2356
  branch?: string;
2263
2357
  name?: string;
2264
2358
  user_named?: boolean;
2265
- summary?: string;
2266
2359
  summary_count?: number;
2267
2360
  created_at?: string;
2268
2361
  updated_at?: string;
@@ -2270,7 +2363,6 @@ export interface WorkspacesGetWorkspaceResult {
2270
2363
  mc_task_id?: string;
2271
2364
  mc_session_id?: string;
2272
2365
  mc_last_event_id?: string;
2273
- session_sync_level?: "local" | "user" | "repo_and_user";
2274
2366
  chronicle_sync_dismissed?: boolean;
2275
2367
  } | null;
2276
2368
  }
@@ -2388,6 +2480,7 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
2388
2480
  promoteToBackground: (params: TasksPromoteToBackgroundRequest) => Promise<TasksPromoteToBackgroundResult>;
2389
2481
  cancel: (params: TasksCancelRequest) => Promise<TasksCancelResult>;
2390
2482
  remove: (params: TasksRemoveRequest) => Promise<TasksRemoveResult>;
2483
+ sendMessage: (params: TasksSendMessageRequest) => Promise<TasksSendMessageResult>;
2391
2484
  };
2392
2485
  /** @experimental */
2393
2486
  skills: {
@@ -2423,6 +2516,7 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
2423
2516
  };
2424
2517
  commands: {
2425
2518
  handlePendingCommand: (params: CommandsHandlePendingCommandRequest) => Promise<CommandsHandlePendingCommandResult>;
2519
+ respondToQueuedCommand: (params: CommandsRespondToQueuedCommandRequest) => Promise<CommandsRespondToQueuedCommandResult>;
2426
2520
  };
2427
2521
  ui: {
2428
2522
  elicitation: (params: UIElicitationRequest) => Promise<UIElicitationResponse>;
@@ -91,7 +91,8 @@ function createSessionRpc(connection, sessionId) {
91
91
  list: async () => connection.sendRequest("session.tasks.list", { sessionId }),
92
92
  promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { sessionId, ...params }),
93
93
  cancel: async (params) => connection.sendRequest("session.tasks.cancel", { sessionId, ...params }),
94
- remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params })
94
+ remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params }),
95
+ sendMessage: async (params) => connection.sendRequest("session.tasks.sendMessage", { sessionId, ...params })
95
96
  },
96
97
  /** @experimental */
97
98
  skills: {
@@ -126,7 +127,8 @@ function createSessionRpc(connection, sessionId) {
126
127
  handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { sessionId, ...params })
127
128
  },
128
129
  commands: {
129
- handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params })
130
+ handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params }),
131
+ respondToQueuedCommand: async (params) => connection.sendRequest("session.commands.respondToQueuedCommand", { sessionId, ...params })
130
132
  },
131
133
  ui: {
132
134
  elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params }),
@@ -43,6 +43,10 @@ export type AssistantMessageToolRequestType = "function" | "custom";
43
43
  * Where the failed model call originated
44
44
  */
45
45
  export type ModelCallFailureSource = "top_level" | "subagent" | "mcp_sampling";
46
+ /**
47
+ * Finite reason code describing why the current turn was aborted
48
+ */
49
+ export type AbortReason = "user_initiated" | "remote_command" | "user_abort";
46
50
  /**
47
51
  * A content block within a tool result, which may be text, terminal output, image, audio, or a resource
48
52
  */
@@ -70,7 +74,7 @@ export type SystemNotificationAgentCompletedStatus = "completed" | "failed";
70
74
  /**
71
75
  * Details of the permission being requested
72
76
  */
73
- export type PermissionRequest = PermissionRequestShell | PermissionRequestWrite | PermissionRequestRead | PermissionRequestMcp | PermissionRequestUrl | PermissionRequestMemory | PermissionRequestCustomTool | PermissionRequestHook;
77
+ export type PermissionRequest = PermissionRequestShell | PermissionRequestWrite | PermissionRequestRead | PermissionRequestMcp | PermissionRequestUrl | PermissionRequestMemory | PermissionRequestCustomTool | PermissionRequestHook | PermissionRequestExtensionManagement | PermissionRequestExtensionPermissionAccess;
74
78
  /**
75
79
  * Whether this is a store or vote memory operation
76
80
  */
@@ -82,7 +86,7 @@ export type PermissionRequestMemoryDirection = "upvote" | "downvote";
82
86
  /**
83
87
  * Derived user-facing permission prompt details for UI consumers
84
88
  */
85
- export type PermissionPromptRequest = PermissionPromptRequestCommands | PermissionPromptRequestWrite | PermissionPromptRequestRead | PermissionPromptRequestMcp | PermissionPromptRequestUrl | PermissionPromptRequestMemory | PermissionPromptRequestCustomTool | PermissionPromptRequestPath | PermissionPromptRequestHook;
89
+ export type PermissionPromptRequest = PermissionPromptRequestCommands | PermissionPromptRequestWrite | PermissionPromptRequestRead | PermissionPromptRequestMcp | PermissionPromptRequestUrl | PermissionPromptRequestMemory | PermissionPromptRequestCustomTool | PermissionPromptRequestPath | PermissionPromptRequestHook | PermissionPromptRequestExtensionManagement | PermissionPromptRequestExtensionPermissionAccess;
86
90
  /**
87
91
  * Whether this is a store or vote memory operation
88
92
  */
@@ -102,7 +106,7 @@ export type PermissionResult = PermissionApproved | PermissionApprovedForSession
102
106
  /**
103
107
  * The approval to add as a session-scoped rule
104
108
  */
105
- export type UserToolSessionApproval = UserToolSessionApprovalCommands | UserToolSessionApprovalRead | UserToolSessionApprovalWrite | UserToolSessionApprovalMcp | UserToolSessionApprovalMemory | UserToolSessionApprovalCustomTool;
109
+ export type UserToolSessionApproval = UserToolSessionApprovalCommands | UserToolSessionApprovalRead | UserToolSessionApprovalWrite | UserToolSessionApprovalMcp | UserToolSessionApprovalMemory | UserToolSessionApprovalCustomTool | UserToolSessionApprovalExtensionManagement | UserToolSessionApprovalExtensionPermissionAccess;
106
110
  /**
107
111
  * Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
108
112
  */
@@ -165,6 +169,10 @@ export interface StartData {
165
169
  * Version string of the Copilot application
166
170
  */
167
171
  copilotVersion: string;
172
+ /**
173
+ * When set, identifies a parent session whose context this session continues — e.g., a detached headless rem-agent run launched on the parent's interactive shutdown. Telemetry from this session is reported under the parent's session_id.
174
+ */
175
+ detachedFromSpawningParentSessionId?: string;
168
176
  /**
169
177
  * Identifier of the software producing the events (e.g., "copilot-agent")
170
178
  */
@@ -1818,6 +1826,14 @@ export interface AssistantMessageEvent {
1818
1826
  * Assistant response containing text content, optional tool requests, and interaction metadata
1819
1827
  */
1820
1828
  export interface AssistantMessageData {
1829
+ /**
1830
+ * Raw Anthropic content array with advisor blocks (server_tool_use, advisor_tool_result) for verbatim round-tripping
1831
+ */
1832
+ anthropicAdvisorBlocks?: unknown[];
1833
+ /**
1834
+ * Anthropic advisor model ID used for this response, for timeline display on replay
1835
+ */
1836
+ anthropicAdvisorModel?: string;
1821
1837
  /**
1822
1838
  * The assistant's text response content
1823
1839
  */
@@ -1834,6 +1850,10 @@ export interface AssistantMessageData {
1834
1850
  * Unique identifier for this assistant message
1835
1851
  */
1836
1852
  messageId: string;
1853
+ /**
1854
+ * Model that produced this assistant message, if known
1855
+ */
1856
+ model?: string;
1837
1857
  /**
1838
1858
  * Actual output token count from the API response (completion_tokens), used for accurate token accounting
1839
1859
  */
@@ -2255,10 +2275,7 @@ export interface AbortEvent {
2255
2275
  * Turn abort information including the reason for termination
2256
2276
  */
2257
2277
  export interface AbortData {
2258
- /**
2259
- * Reason the current turn was aborted (e.g., "user initiated")
2260
- */
2261
- reason: string;
2278
+ reason: AbortReason;
2262
2279
  }
2263
2280
  export interface ToolUserRequestedEvent {
2264
2281
  /**
@@ -2785,6 +2802,10 @@ export interface SubagentStartedData {
2785
2802
  * Internal name of the sub-agent
2786
2803
  */
2787
2804
  agentName: string;
2805
+ /**
2806
+ * Model the sub-agent will run with, when known at start. Surfaced in the timeline for auto-selected sub-agents (e.g. rubber-duck).
2807
+ */
2808
+ model?: string;
2788
2809
  /**
2789
2810
  * Tool call ID of the parent tool invocation that spawned this sub-agent
2790
2811
  */
@@ -3564,6 +3585,48 @@ export interface PermissionRequestHook {
3564
3585
  */
3565
3586
  toolName: string;
3566
3587
  }
3588
+ /**
3589
+ * Extension management permission request
3590
+ */
3591
+ export interface PermissionRequestExtensionManagement {
3592
+ /**
3593
+ * Name of the extension being managed
3594
+ */
3595
+ extensionName?: string;
3596
+ /**
3597
+ * Permission kind discriminator
3598
+ */
3599
+ kind: "extension-management";
3600
+ /**
3601
+ * The extension management operation (scaffold, reload)
3602
+ */
3603
+ operation: string;
3604
+ /**
3605
+ * Tool call ID that triggered this permission request
3606
+ */
3607
+ toolCallId?: string;
3608
+ }
3609
+ /**
3610
+ * Extension permission access request
3611
+ */
3612
+ export interface PermissionRequestExtensionPermissionAccess {
3613
+ /**
3614
+ * Capabilities the extension is requesting
3615
+ */
3616
+ capabilities: string[];
3617
+ /**
3618
+ * Name of the extension requesting permission access
3619
+ */
3620
+ extensionName: string;
3621
+ /**
3622
+ * Permission kind discriminator
3623
+ */
3624
+ kind: "extension-permission-access";
3625
+ /**
3626
+ * Tool call ID that triggered this permission request
3627
+ */
3628
+ toolCallId?: string;
3629
+ }
3567
3630
  /**
3568
3631
  * Shell command permission prompt
3569
3632
  */
@@ -3801,6 +3864,48 @@ export interface PermissionPromptRequestHook {
3801
3864
  */
3802
3865
  toolName: string;
3803
3866
  }
3867
+ /**
3868
+ * Extension management permission prompt
3869
+ */
3870
+ export interface PermissionPromptRequestExtensionManagement {
3871
+ /**
3872
+ * Name of the extension being managed
3873
+ */
3874
+ extensionName?: string;
3875
+ /**
3876
+ * Prompt kind discriminator
3877
+ */
3878
+ kind: "extension-management";
3879
+ /**
3880
+ * The extension management operation (scaffold, reload)
3881
+ */
3882
+ operation: string;
3883
+ /**
3884
+ * Tool call ID that triggered this permission request
3885
+ */
3886
+ toolCallId?: string;
3887
+ }
3888
+ /**
3889
+ * Extension permission access prompt
3890
+ */
3891
+ export interface PermissionPromptRequestExtensionPermissionAccess {
3892
+ /**
3893
+ * Capabilities the extension is requesting
3894
+ */
3895
+ capabilities: string[];
3896
+ /**
3897
+ * Name of the extension requesting permission access
3898
+ */
3899
+ extensionName: string;
3900
+ /**
3901
+ * Prompt kind discriminator
3902
+ */
3903
+ kind: "extension-permission-access";
3904
+ /**
3905
+ * Tool call ID that triggered this permission request
3906
+ */
3907
+ toolCallId?: string;
3908
+ }
3804
3909
  export interface PermissionCompletedEvent {
3805
3910
  /**
3806
3911
  * Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
@@ -3904,6 +4009,26 @@ export interface UserToolSessionApprovalCustomTool {
3904
4009
  */
3905
4010
  toolName: string;
3906
4011
  }
4012
+ export interface UserToolSessionApprovalExtensionManagement {
4013
+ /**
4014
+ * Extension management approval kind
4015
+ */
4016
+ kind: "extension-management";
4017
+ /**
4018
+ * Optional operation identifier
4019
+ */
4020
+ operation?: string;
4021
+ }
4022
+ export interface UserToolSessionApprovalExtensionPermissionAccess {
4023
+ /**
4024
+ * Extension name
4025
+ */
4026
+ extensionName: string;
4027
+ /**
4028
+ * Extension permission access approval kind
4029
+ */
4030
+ kind: "extension-permission-access";
4031
+ }
3907
4032
  export interface PermissionApprovedForLocation {
3908
4033
  approval: UserToolSessionApproval;
3909
4034
  /**
package/dist/index.d.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  export { CopilotClient } from "./client.js";
7
7
  export { CopilotSession, type AssistantMessageEvent } from "./session.js";
8
8
  export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, SYSTEM_PROMPT_SECTIONS, } from "./types.js";
9
- export type { CommandContext, CommandDefinition, CommandHandler, ConnectionState, CopilotClientOptions, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, InputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventType, SessionLifecycleHandler, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemPromptSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
9
+ export type { CommandContext, CommandDefinition, CommandHandler, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, ConnectionState, CopilotClientOptions, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, InputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventType, SessionLifecycleHandler, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemPromptSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
package/dist/session.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  import type { MessageConnection } from "vscode-jsonrpc/node.js";
6
6
  import { createSessionRpc } from "./generated/rpc.js";
7
7
  import type { ClientSessionApiHandlers } from "./generated/rpc.js";
8
- import type { CommandHandler, ElicitationHandler, ElicitationContext, MessageOptions, PermissionHandler, PermissionRequestResult, ReasoningEffort, ModelCapabilitiesOverride, SectionTransformFn, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionHooks, SessionUiApi, Tool, ToolHandler, TraceContextProvider, TypedSessionEventHandler, UserInputHandler, UserInputResponse } from "./types.js";
8
+ import type { CommandHandler, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, ElicitationHandler, ElicitationContext, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, MessageOptions, PermissionHandler, PermissionRequestResult, ReasoningEffort, ModelCapabilitiesOverride, SectionTransformFn, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionHooks, SessionUiApi, Tool, ToolHandler, TraceContextProvider, TypedSessionEventHandler, UserInputHandler, UserInputResponse } from "./types.js";
9
9
  export declare const NO_RESULT_PERMISSION_V2_ERROR = "Permission handlers cannot return 'no-result' when connected to a protocol v2 server.";
10
10
  /** Assistant message event - the final response from the assistant. */
11
11
  export type AssistantMessageEvent = Extract<SessionEvent, {
@@ -47,6 +47,8 @@ export declare class CopilotSession {
47
47
  private permissionHandler?;
48
48
  private userInputHandler?;
49
49
  private elicitationHandler?;
50
+ private exitPlanModeHandler?;
51
+ private autoModeSwitchHandler?;
50
52
  private hooks?;
51
53
  private transformCallbacks?;
52
54
  private _rpc;
@@ -246,12 +248,36 @@ export declare class CopilotSession {
246
248
  * @internal This method is typically called internally when creating/resuming a session.
247
249
  */
248
250
  registerElicitationHandler(handler?: ElicitationHandler): void;
251
+ /**
252
+ * Registers the exit-plan-mode handler for this session.
253
+ *
254
+ * @param handler - The handler to invoke when the server dispatches an exit-plan-mode request
255
+ * @internal This method is typically called internally when creating/resuming a session.
256
+ */
257
+ registerExitPlanModeHandler(handler?: ExitPlanModeHandler): void;
258
+ /**
259
+ * Registers the auto-mode-switch handler for this session.
260
+ *
261
+ * @param handler - The handler to invoke when the server dispatches an auto-mode-switch request
262
+ * @internal This method is typically called internally when creating/resuming a session.
263
+ */
264
+ registerAutoModeSwitchHandler(handler?: AutoModeSwitchHandler): void;
249
265
  /**
250
266
  * Handles an elicitation.requested broadcast event.
251
267
  * Invokes the registered handler and responds via handlePendingElicitation RPC.
252
268
  * @internal
253
269
  */
254
270
  _handleElicitationRequest(context: ElicitationContext, requestId: string): Promise<void>;
271
+ /**
272
+ * Handles an exitPlanMode.request callback from the runtime.
273
+ * @internal
274
+ */
275
+ _handleExitPlanModeRequest(request: ExitPlanModeRequest): Promise<ExitPlanModeResult>;
276
+ /**
277
+ * Handles an autoModeSwitch.request callback from the runtime.
278
+ * @internal
279
+ */
280
+ _handleAutoModeSwitchRequest(request: AutoModeSwitchRequest): Promise<AutoModeSwitchResponse>;
255
281
  /**
256
282
  * Sets the host capabilities for this session.
257
283
  *
package/dist/session.js CHANGED
@@ -25,6 +25,8 @@ class CopilotSession {
25
25
  permissionHandler;
26
26
  userInputHandler;
27
27
  elicitationHandler;
28
+ exitPlanModeHandler;
29
+ autoModeSwitchHandler;
28
30
  hooks;
29
31
  transformCallbacks;
30
32
  _rpc = null;
@@ -420,6 +422,24 @@ class CopilotSession {
420
422
  registerElicitationHandler(handler) {
421
423
  this.elicitationHandler = handler;
422
424
  }
425
+ /**
426
+ * Registers the exit-plan-mode handler for this session.
427
+ *
428
+ * @param handler - The handler to invoke when the server dispatches an exit-plan-mode request
429
+ * @internal This method is typically called internally when creating/resuming a session.
430
+ */
431
+ registerExitPlanModeHandler(handler) {
432
+ this.exitPlanModeHandler = handler;
433
+ }
434
+ /**
435
+ * Registers the auto-mode-switch handler for this session.
436
+ *
437
+ * @param handler - The handler to invoke when the server dispatches an auto-mode-switch request
438
+ * @internal This method is typically called internally when creating/resuming a session.
439
+ */
440
+ registerAutoModeSwitchHandler(handler) {
441
+ this.autoModeSwitchHandler = handler;
442
+ }
423
443
  /**
424
444
  * Handles an elicitation.requested broadcast event.
425
445
  * Invokes the registered handler and responds via handlePendingElicitation RPC.
@@ -445,6 +465,26 @@ class CopilotSession {
445
465
  }
446
466
  }
447
467
  }
468
+ /**
469
+ * Handles an exitPlanMode.request callback from the runtime.
470
+ * @internal
471
+ */
472
+ async _handleExitPlanModeRequest(request) {
473
+ if (!this.exitPlanModeHandler) {
474
+ return { approved: true };
475
+ }
476
+ return await this.exitPlanModeHandler(request, { sessionId: this.sessionId });
477
+ }
478
+ /**
479
+ * Handles an autoModeSwitch.request callback from the runtime.
480
+ * @internal
481
+ */
482
+ async _handleAutoModeSwitchRequest(request) {
483
+ if (!this.autoModeSwitchHandler) {
484
+ return "no";
485
+ }
486
+ return await this.autoModeSwitchHandler(request, { sessionId: this.sessionId });
487
+ }
448
488
  /**
449
489
  * Sets the host capabilities for this session.
450
490
  *
@@ -725,6 +765,10 @@ class CopilotSession {
725
765
  this.typedEventHandlers.clear();
726
766
  this.toolHandlers.clear();
727
767
  this.permissionHandler = void 0;
768
+ this.userInputHandler = void 0;
769
+ this.elicitationHandler = void 0;
770
+ this.exitPlanModeHandler = void 0;
771
+ this.autoModeSwitchHandler = void 0;
728
772
  }
729
773
  /**
730
774
  * @deprecated Use {@link disconnect} instead. This method will be removed in a future release.
@@ -6,7 +6,7 @@ import type { SessionFsHandler, SessionFsStatResult, SessionFsReaddirWithTypesEn
6
6
  */
7
7
  export type SessionFsFileInfo = Omit<SessionFsStatResult, "error">;
8
8
  /**
9
- * Interface for session filesystem providers. Implementors use idiomatic
9
+ * Interface for session filesystem providers. Implementers use idiomatic
10
10
  * TypeScript patterns: throw on error, return values directly. Use
11
11
  * {@link createSessionFsAdapter} to convert a provider into the
12
12
  * {@link SessionFsHandler} expected by the SDK.
package/dist/types.d.ts CHANGED
@@ -650,6 +650,55 @@ export interface UserInputResponse {
650
650
  export type UserInputHandler = (request: UserInputRequest, invocation: {
651
651
  sessionId: string;
652
652
  }) => Promise<UserInputResponse> | UserInputResponse;
653
+ /**
654
+ * Request to exit plan mode and continue with a selected action.
655
+ */
656
+ export interface ExitPlanModeRequest {
657
+ /** Summary of the plan or proposed next step. */
658
+ summary: string;
659
+ /** Full plan content, when available. */
660
+ planContent?: string;
661
+ /** Available actions the user can select. */
662
+ actions: string[];
663
+ /** The action recommended by the runtime. */
664
+ recommendedAction: string;
665
+ }
666
+ /**
667
+ * Response to an exit-plan-mode request.
668
+ */
669
+ export interface ExitPlanModeResult {
670
+ /** Whether the user approved exiting plan mode. */
671
+ approved: boolean;
672
+ /** Selected action, if the user chose one. */
673
+ selectedAction?: string;
674
+ /** Optional feedback provided by the user. */
675
+ feedback?: string;
676
+ }
677
+ /**
678
+ * Handler for exit-plan-mode requests from the agent.
679
+ */
680
+ export type ExitPlanModeHandler = (request: ExitPlanModeRequest, invocation: {
681
+ sessionId: string;
682
+ }) => Promise<ExitPlanModeResult> | ExitPlanModeResult;
683
+ /**
684
+ * Request to switch to auto mode after an eligible rate limit.
685
+ */
686
+ export interface AutoModeSwitchRequest {
687
+ /** The rate-limit error code that triggered the request. */
688
+ errorCode?: string;
689
+ /** Seconds until the rate limit resets, when known. */
690
+ retryAfterSeconds?: number;
691
+ }
692
+ /**
693
+ * Response to an auto-mode-switch request.
694
+ */
695
+ export type AutoModeSwitchResponse = "yes" | "yes_always" | "no";
696
+ /**
697
+ * Handler for auto-mode-switch requests from the agent.
698
+ */
699
+ export type AutoModeSwitchHandler = (request: AutoModeSwitchRequest, invocation: {
700
+ sessionId: string;
701
+ }) => Promise<AutoModeSwitchResponse> | AutoModeSwitchResponse;
653
702
  /**
654
703
  * Base interface for all hook inputs
655
704
  */
@@ -1020,6 +1069,15 @@ export interface SessionConfig {
1020
1069
  * When specified, uses the provided API endpoint instead of the Copilot API.
1021
1070
  */
1022
1071
  provider?: ProviderConfig;
1072
+ /**
1073
+ * Enables or disables internal session telemetry for this session.
1074
+ * When `false`, disables session telemetry. When omitted (the default) or `true`,
1075
+ * telemetry is enabled for GitHub-authenticated sessions.
1076
+ * When a custom {@link provider} (BYOK) is configured, session telemetry is always
1077
+ * disabled regardless of this setting.
1078
+ * This is independent of the OpenTelemetry configuration in {@link CopilotClientOptions.telemetry}.
1079
+ */
1080
+ enableSessionTelemetry?: boolean;
1023
1081
  /**
1024
1082
  * Handler for permission requests from the server.
1025
1083
  * When provided, the server will call this handler to request permission for operations.
@@ -1036,6 +1094,16 @@ export interface SessionConfig {
1036
1094
  * Also enables the `elicitation` capability on the session.
1037
1095
  */
1038
1096
  onElicitationRequest?: ElicitationHandler;
1097
+ /**
1098
+ * Handler for exit-plan-mode requests from the agent.
1099
+ * When provided, enables `exitPlanMode.request` callbacks.
1100
+ */
1101
+ onExitPlanMode?: ExitPlanModeHandler;
1102
+ /**
1103
+ * Handler for auto-mode-switch requests from the agent.
1104
+ * When provided, enables `autoModeSwitch.request` callbacks.
1105
+ */
1106
+ onAutoModeSwitch?: AutoModeSwitchHandler;
1039
1107
  /**
1040
1108
  * Hook handlers for intercepting session lifecycle events.
1041
1109
  * When provided, enables hooks callback allowing custom logic at various points.
@@ -1127,7 +1195,7 @@ export interface SessionConfig {
1127
1195
  /**
1128
1196
  * Configuration for resuming a session
1129
1197
  */
1130
- export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "commands" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "modelCapabilities" | "streaming" | "includeSubAgentStreamingEvents" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "onElicitationRequest" | "hooks" | "workingDirectory" | "configDir" | "enableConfigDiscovery" | "mcpServers" | "customAgents" | "defaultAgent" | "agent" | "skillDirectories" | "instructionDirectories" | "disabledSkills" | "infiniteSessions" | "gitHubToken" | "onEvent" | "createSessionFsHandler"> & {
1198
+ export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "commands" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "enableSessionTelemetry" | "modelCapabilities" | "streaming" | "includeSubAgentStreamingEvents" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "onElicitationRequest" | "onExitPlanMode" | "onAutoModeSwitch" | "hooks" | "workingDirectory" | "configDir" | "enableConfigDiscovery" | "mcpServers" | "customAgents" | "defaultAgent" | "agent" | "skillDirectories" | "instructionDirectories" | "disabledSkills" | "infiniteSessions" | "gitHubToken" | "onEvent" | "createSessionFsHandler"> & {
1131
1199
  /**
1132
1200
  * When true, skips emitting the session.resume event.
1133
1201
  * Useful for reconnecting to a session without triggering resume-related side effects.
@@ -1402,7 +1470,7 @@ export interface ModelPolicy {
1402
1470
  * Model billing information
1403
1471
  */
1404
1472
  export interface ModelBilling {
1405
- multiplier: number;
1473
+ multiplier?: number;
1406
1474
  }
1407
1475
  /**
1408
1476
  * Information about an available model
package/dist/types.js CHANGED
@@ -23,9 +23,10 @@ function convertMcpCallToolResult(callResult) {
23
23
  textParts.push(block.resource.text);
24
24
  }
25
25
  if (block.resource?.blob) {
26
+ const mimeType = block.resource.mimeType;
26
27
  binaryResults.push({
27
28
  data: block.resource.blob,
28
- mimeType: block.resource.mimeType ?? "application/octet-stream",
29
+ mimeType: typeof mimeType === "string" && mimeType ? mimeType : "application/octet-stream",
29
30
  type: "resource",
30
31
  description: block.resource.uri
31
32
  });
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.0-beta.2",
7
+ "version": "1.0.0-beta.4",
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.43-0",
59
+ "@github/copilot": "^1.0.46",
60
60
  "vscode-jsonrpc": "^8.2.1",
61
61
  "zod": "^4.3.6"
62
62
  },