@github/copilot-sdk 1.0.13-preview.6 → 1.0.14-preview.0

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/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./facto
11
11
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
12
12
  export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
13
13
  export type * from "./generated/session-events.js";
14
- export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
14
+ export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, MessageSource, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
15
15
  export type { RunOptions, ResumeOptions, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryListRunsOptions, FactoryRunsPage, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
package/dist/session.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createSessionRpc } from "./generated/rpc.js";
2
+ import type { ModelSwitchAutoTierResult } from "./generated/rpc.js";
2
3
  import type { OpenCanvasInstance } from "./generated/rpc.js";
3
- import type { MessageOptions, ContextTier, ReasoningEffort, ReasoningSummary, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";
4
+ import type { MessageOptions, ContextTier, ReasoningEffort, ReasoningSummary, AutoTier, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";
4
5
  import { type SessionFactoryApi } from "./factory.js";
5
6
  /** Assistant message event - the final response from the assistant. */
6
7
  export type AssistantMessageEvent = Extract<SessionEvent, {
@@ -43,6 +44,7 @@ export declare class CopilotSession {
43
44
  private eventHandlers;
44
45
  private typedEventHandlers;
45
46
  private toolHandlers;
47
+ private pendingExternalTools;
46
48
  private canvases;
47
49
  private bearerTokenProviders;
48
50
  private commandHandlers;
@@ -62,6 +64,7 @@ export declare class CopilotSession {
62
64
  private _capabilities;
63
65
  private openCanvasInstances;
64
66
  private disconnected;
67
+ private disconnecting;
65
68
  private onDisconnected?;
66
69
  /**
67
70
  * Friendly factory API for running registered factories by name or handle.
@@ -212,6 +215,7 @@ export declare class CopilotSession {
212
215
  private removeOpenCanvasFromEvent;
213
216
  private removeOpenCanvas;
214
217
  private upsertOpenCanvas;
218
+ private _claimExternalTool;
215
219
  /**
216
220
  * Snapshot of canvas instances currently known to be open for this session.
217
221
  * Populated from the `session.resume` response and live `session.canvas.opened`
@@ -300,6 +304,9 @@ export declare class CopilotSession {
300
304
  * ```typescript
301
305
  * await session.setModel("gpt-5.4");
302
306
  * await session.setModel("claude-sonnet-4.6", { reasoningEffort: "high" });
307
+ *
308
+ * // Select the Auto model and its routing preference in one call.
309
+ * await session.setModel("auto", { autoTier: "intelligence" });
303
310
  * ```
304
311
  */
305
312
  setModel(model: string, options?: {
@@ -307,7 +314,51 @@ export declare class CopilotSession {
307
314
  reasoningSummary?: ReasoningSummary;
308
315
  contextTier?: ContextTier;
309
316
  modelCapabilities?: ModelCapabilitiesOverride;
317
+ /**
318
+ * Routing preference to apply when `model` is `auto`.
319
+ *
320
+ * Pass `null` to return to the provider's default Auto routing. The
321
+ * runtime rejects this option when `model` is anything other than
322
+ * `auto`; use {@link setAutoTier} to change the preference without
323
+ * changing the selected model.
324
+ *
325
+ * @experimental Part of an experimental Auto routing surface and may
326
+ * change or be removed in a future release.
327
+ */
328
+ autoTier?: AutoTier | null;
310
329
  }): Promise<void>;
330
+ /**
331
+ * Change the Auto routing preference without changing the selected model.
332
+ *
333
+ * The runtime does not apply the preference immediately. It records the
334
+ * request and commits it only when a later user turn using the `auto` model
335
+ * successfully obtains a usable model from the provider. A `pending` status
336
+ * therefore confirms that the request was accepted, not that it took effect.
337
+ *
338
+ * Watch for the outcome through the `session.model_change` event on success,
339
+ * or the ephemeral `session.auto_tier_switch_failed` event on failure. You
340
+ * can also read the current committed and in-flight state at any time with
341
+ * `session.rpc.model.getCurrent()`.
342
+ *
343
+ * Only the most recent request survives: issuing a new request replaces any
344
+ * earlier one that has not yet been claimed by a turn.
345
+ *
346
+ * @param autoTier - Routing preference to activate, or `null` to return to
347
+ * the provider's default Auto routing
348
+ * @returns The runtime's immediate acknowledgement and Auto preference snapshot
349
+ *
350
+ * @experimental Part of an experimental Auto routing surface and may change
351
+ * or be removed in a future release.
352
+ *
353
+ * @example
354
+ * ```typescript
355
+ * const result = await session.setAutoTier("intelligence");
356
+ * if (result.status === "pending") {
357
+ * // Takes effect on a later turn that uses the `auto` model.
358
+ * }
359
+ * ```
360
+ */
361
+ setAutoTier(autoTier: AutoTier | null): Promise<ModelSwitchAutoTierResult>;
311
362
  /**
312
363
  * Log a message to the session timeline.
313
364
  * The message appears in the session event stream and is visible to SDK consumers
package/dist/session.js CHANGED
@@ -231,6 +231,7 @@ class CopilotSession {
231
231
  eventHandlers = /* @__PURE__ */ new Set();
232
232
  typedEventHandlers = /* @__PURE__ */ new Map();
233
233
  toolHandlers = /* @__PURE__ */ new Map();
234
+ pendingExternalTools = /* @__PURE__ */ new Map();
234
235
  canvases = /* @__PURE__ */ new Map();
235
236
  bearerTokenProviders = /* @__PURE__ */ new Map();
236
237
  commandHandlers = /* @__PURE__ */ new Map();
@@ -250,6 +251,7 @@ class CopilotSession {
250
251
  _capabilities = {};
251
252
  openCanvasInstances = [];
252
253
  disconnected = false;
254
+ disconnecting = false;
253
255
  onDisconnected;
254
256
  /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
255
257
  clientSessionApis = {};
@@ -449,6 +451,7 @@ class CopilotSession {
449
451
  ...await getTraceContext(this.traceContextProvider),
450
452
  sessionId: this.sessionId,
451
453
  prompt: options.prompt,
454
+ source: options.source,
452
455
  displayPrompt: options.displayPrompt,
453
456
  attachments: options.attachments,
454
457
  mode: options.mode,
@@ -507,6 +510,10 @@ class CopilotSession {
507
510
  return;
508
511
  }
509
512
  this.disconnected = true;
513
+ for (const controller of this.pendingExternalTools.values()) {
514
+ controller.abort();
515
+ }
516
+ this.pendingExternalTools.clear();
510
517
  this._runOnDisconnected();
511
518
  this.eventHandlers.clear();
512
519
  this.typedEventHandlers.clear();
@@ -610,6 +617,15 @@ class CopilotSession {
610
617
  tracestate
611
618
  );
612
619
  }
620
+ } else if (event.type === "external_tool.completed") {
621
+ const { requestId } = event.data;
622
+ if (requestId) {
623
+ const controller = this.pendingExternalTools.get(requestId);
624
+ if (controller) {
625
+ this.pendingExternalTools.delete(requestId);
626
+ controller.abort();
627
+ }
628
+ }
613
629
  } else if (event.type === "permission.requested") {
614
630
  const { requestId, permissionRequest, resolvedByHook } = event.data;
615
631
  if (resolvedByHook) {
@@ -690,16 +706,35 @@ class CopilotSession {
690
706
  * @internal
691
707
  */
692
708
  async _executeToolAndRespond(requestId, toolName, toolCallId, args, handler, traceparent, tracestate) {
709
+ const controller = new AbortController();
710
+ if (this.disconnected || this.pendingExternalTools.has(requestId)) {
711
+ return;
712
+ }
713
+ this.pendingExternalTools.set(requestId, controller);
693
714
  try {
694
715
  let availableTools;
695
716
  if (toolName === TOOL_SEARCH_TOOL_NAME) {
717
+ if (controller.signal.aborted) {
718
+ return;
719
+ }
720
+ const aborted = new Promise((resolve) => {
721
+ controller.signal.addEventListener("abort", () => resolve(void 0), {
722
+ once: true
723
+ });
724
+ });
696
725
  try {
697
- const metadata = await this.rpc.tools.getCurrentMetadata();
698
- availableTools = metadata.tools ?? void 0;
726
+ const metadata = await Promise.race([
727
+ this.rpc.tools.getCurrentMetadata(),
728
+ aborted
729
+ ]);
730
+ availableTools = metadata?.tools ?? void 0;
699
731
  } catch {
700
732
  availableTools = void 0;
701
733
  }
702
734
  }
735
+ if (controller.signal.aborted) {
736
+ return;
737
+ }
703
738
  const rawResult = await handler(args, {
704
739
  sessionId: this.sessionId,
705
740
  toolCallId,
@@ -707,7 +742,8 @@ class CopilotSession {
707
742
  arguments: args,
708
743
  availableTools,
709
744
  traceparent,
710
- tracestate
745
+ tracestate,
746
+ signal: controller.signal
711
747
  });
712
748
  let result;
713
749
  if (rawResult == null) {
@@ -719,12 +755,12 @@ class CopilotSession {
719
755
  } else {
720
756
  result = JSON.stringify(rawResult);
721
757
  }
722
- if (this.disconnected) {
758
+ if (!this._claimExternalTool(requestId, controller)) {
723
759
  return;
724
760
  }
725
761
  await this.rpc.tools.handlePendingToolCall({ requestId, result });
726
762
  } catch (error) {
727
- if (this.disconnected) {
763
+ if (!this._claimExternalTool(requestId, controller)) {
728
764
  return;
729
765
  }
730
766
  const message = error instanceof Error ? error.message : String(error);
@@ -735,7 +771,19 @@ class CopilotSession {
735
771
  throw rpcError;
736
772
  }
737
773
  }
774
+ } finally {
775
+ if (this.pendingExternalTools.get(requestId) === controller) {
776
+ this.pendingExternalTools.delete(requestId);
777
+ }
778
+ controller.abort();
779
+ }
780
+ }
781
+ _claimExternalTool(requestId, controller) {
782
+ if (this.disconnected || this.pendingExternalTools.get(requestId) !== controller) {
783
+ return false;
738
784
  }
785
+ this.pendingExternalTools.delete(requestId);
786
+ return true;
739
787
  }
740
788
  /**
741
789
  * Executes a permission handler and sends the result back via RPC.
@@ -1489,13 +1537,27 @@ class CopilotSession {
1489
1537
  * ```
1490
1538
  */
1491
1539
  async disconnect() {
1492
- if (this.disconnected) {
1540
+ if (this.disconnected || this.disconnecting) {
1493
1541
  return;
1494
1542
  }
1495
- await this.connection.sendRequest("session.destroy", {
1496
- sessionId: this.sessionId
1497
- });
1498
- this._markDisconnected();
1543
+ this.disconnecting = true;
1544
+ try {
1545
+ let response = { success: false };
1546
+ for (let attempt = 0; attempt < 2 && !response.success; attempt++) {
1547
+ response = await this.connection.sendRequest("session.detach", {
1548
+ sessionId: this.sessionId
1549
+ });
1550
+ }
1551
+ if (!response.success) {
1552
+ throw new Error(
1553
+ `Failed to disconnect session ${this.sessionId}: ${response.error || "Unknown error"}`
1554
+ );
1555
+ }
1556
+ this._markDisconnected();
1557
+ } catch (error) {
1558
+ this.disconnecting = false;
1559
+ throw error;
1560
+ }
1499
1561
  }
1500
1562
  /** Enables `await using session = ...` syntax for automatic cleanup. */
1501
1563
  async [Symbol.asyncDispose]() {
@@ -1537,11 +1599,48 @@ class CopilotSession {
1537
1599
  * ```typescript
1538
1600
  * await session.setModel("gpt-5.4");
1539
1601
  * await session.setModel("claude-sonnet-4.6", { reasoningEffort: "high" });
1602
+ *
1603
+ * // Select the Auto model and its routing preference in one call.
1604
+ * await session.setModel("auto", { autoTier: "intelligence" });
1540
1605
  * ```
1541
1606
  */
1542
1607
  async setModel(model, options) {
1543
1608
  await this.rpc.model.switchTo({ modelId: model, ...options });
1544
1609
  }
1610
+ /**
1611
+ * Change the Auto routing preference without changing the selected model.
1612
+ *
1613
+ * The runtime does not apply the preference immediately. It records the
1614
+ * request and commits it only when a later user turn using the `auto` model
1615
+ * successfully obtains a usable model from the provider. A `pending` status
1616
+ * therefore confirms that the request was accepted, not that it took effect.
1617
+ *
1618
+ * Watch for the outcome through the `session.model_change` event on success,
1619
+ * or the ephemeral `session.auto_tier_switch_failed` event on failure. You
1620
+ * can also read the current committed and in-flight state at any time with
1621
+ * `session.rpc.model.getCurrent()`.
1622
+ *
1623
+ * Only the most recent request survives: issuing a new request replaces any
1624
+ * earlier one that has not yet been claimed by a turn.
1625
+ *
1626
+ * @param autoTier - Routing preference to activate, or `null` to return to
1627
+ * the provider's default Auto routing
1628
+ * @returns The runtime's immediate acknowledgement and Auto preference snapshot
1629
+ *
1630
+ * @experimental Part of an experimental Auto routing surface and may change
1631
+ * or be removed in a future release.
1632
+ *
1633
+ * @example
1634
+ * ```typescript
1635
+ * const result = await session.setAutoTier("intelligence");
1636
+ * if (result.status === "pending") {
1637
+ * // Takes effect on a later turn that uses the `auto` model.
1638
+ * }
1639
+ * ```
1640
+ */
1641
+ async setAutoTier(autoTier) {
1642
+ return await this.rpc.model.switchAutoTier({ autoTier });
1643
+ }
1545
1644
  /**
1546
1645
  * Log a message to the session timeline.
1547
1646
  * The message appears in the session event stream and is visible to SDK consumers
package/dist/types.d.ts CHANGED
@@ -35,6 +35,7 @@ export type SessionEvent = Exclude<GeneratedSessionEvent, {
35
35
  type: "permission.requested";
36
36
  }> | PermissionRequestedEvent;
37
37
  export type { AutoTier, ReasoningSummary } from "./generated/session-events.js";
38
+ export type { CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, } from "./generated/rpc.js";
38
39
  export type { SessionFsProvider } from "./sessionFsProvider.js";
39
40
  export { createSessionFsAdapter } from "./sessionFsProvider.js";
40
41
  export type { SessionFsFileInfo } from "./sessionFsProvider.js";
@@ -45,7 +46,8 @@ export type { SessionFsSqliteStatement } from "./sessionFsProvider.js";
45
46
  export type { SessionFsSqliteTransactionErrorClass } from "./sessionFsProvider.js";
46
47
  export { SessionFsSqliteTransactionFailure } from "./sessionFsProvider.js";
47
48
  export type { LlmInferenceHeaders } from "./generated/rpc.js";
48
- export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, } from "./generated/rpc.js";
49
+ export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSurface, PermissionResponseCapability, } from "./generated/rpc.js";
50
+ export type { PermissionDecisionSource } from "./generated/session-events.js";
49
51
  export type { CopilotRequestContext } from "./copilotRequestHandler.js";
50
52
  export { CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, } from "./copilotRequestHandler.js";
51
53
  /**
@@ -496,6 +498,8 @@ export interface ToolInvocation {
496
498
  traceparent?: string;
497
499
  /** W3C Trace Context tracestate from the CLI's execute_tool span. */
498
500
  tracestate?: string;
501
+ /** Aborted when the runtime completes this request or the session disconnects. */
502
+ signal?: AbortSignal;
499
503
  }
500
504
  export type ToolHandler<TArgs = unknown> = (args: TArgs, invocation: ToolInvocation) => Promise<unknown> | unknown;
501
505
  /**
@@ -1746,9 +1750,13 @@ export interface CapiSessionOptions {
1746
1750
  * Requires a runtime with Auto tier support and V2 Auto routing.
1747
1751
  *
1748
1752
  * When omitted on create, the runtime uses its default routing behavior.
1749
- * The runtime persists this preference across cold resume; an explicit tier
1750
- * on cold resume overrides the persisted value. For an already-resident
1751
- * session, omission preserves the current tier and a different tier is rejected.
1753
+ * The runtime persists this preference across cold resume; when omitted on
1754
+ * cold resume, it restores the last committed preference. On resident
1755
+ * resume, a different tier requests a safe switch that takes effect after
1756
+ * resume succeeds, and never disturbs a turn that is already running.
1757
+ *
1758
+ * To change the preference on a live session, call
1759
+ * {@link CopilotSession.setAutoTier} instead.
1752
1760
  */
1753
1761
  autoTier?: AutoTier;
1754
1762
  /**
@@ -2237,6 +2245,11 @@ export interface SessionConfigBase {
2237
2245
  * @default "in-memory"
2238
2246
  */
2239
2247
  mcpOAuthTokenStorage?: "persistent" | "in-memory";
2248
+ /**
2249
+ * OAuth Client ID Metadata Document URL identifying the host for MCP authorization.
2250
+ * When unset, no host identity is supplied.
2251
+ */
2252
+ authClientIdMetadataUrl?: string;
2240
2253
  /**
2241
2254
  * MCP server configurations for the session.
2242
2255
  * Keys are server names, values are server configurations.
@@ -2723,11 +2736,21 @@ export interface ProviderModelConfig {
2723
2736
  */
2724
2737
  capabilities?: ModelCapabilitiesOverride;
2725
2738
  }
2739
+ /**
2740
+ * Message provenance, independent of delivery mode.
2741
+ */
2742
+ export type MessageSource = "user" | "system" | `agent-${string}`;
2726
2743
  export interface MessageOptions {
2727
2744
  /**
2728
2745
  * The prompt/message to send
2729
2746
  */
2730
2747
  prompt: string;
2748
+ /**
2749
+ * Optional message provenance. Omitted by default to preserve the runtime's
2750
+ * default for user messages. Use "system" for application-generated context
2751
+ * or `agent-${id}` for messages originating from an identified agent.
2752
+ */
2753
+ source?: MessageSource;
2731
2754
  /**
2732
2755
  * File, directory, selection, or blob attachments
2733
2756
  */
@@ -2902,6 +2925,7 @@ export interface ModelCapabilities {
2902
2925
  };
2903
2926
  limits: {
2904
2927
  max_prompt_tokens?: number;
2928
+ max_output_tokens?: number;
2905
2929
  max_context_window_tokens: number;
2906
2930
  vision?: {
2907
2931
  supported_media_types: string[];
package/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "1.0.13-preview.6",
8
- "copilotCliVersion": "1.0.83-3",
7
+ "version": "1.0.14-preview.0",
8
+ "copilotCliVersion": "1.0.84-5",
9
9
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
10
10
  "main": "./dist/cjs/index.js",
11
11
  "types": "./dist/index.d.ts",
@@ -33,6 +33,7 @@
33
33
  },
34
34
  "type": "module",
35
35
  "scripts": {
36
+ "auth:refresh": "node ../scripts/npm-auth-refresh.mjs --run",
36
37
  "clean": "rimraf --glob dist *.tgz",
37
38
  "build": "tsx esbuild-copilotsdk-nodejs.ts",
38
39
  "pack:release": "tsx scripts/package-sdk.ts",
@@ -61,7 +62,7 @@
61
62
  "author": "GitHub",
62
63
  "license": "MIT",
63
64
  "dependencies": {
64
- "koffi": "^3.1.0",
65
+ "koffi": "^3.2.1",
65
66
  "vscode-jsonrpc": "^8.2.1",
66
67
  "zod": "^4.3.6"
67
68
  },
@@ -95,13 +96,13 @@
95
96
  "README.md"
96
97
  ],
97
98
  "optionalDependencies": {
98
- "@github/copilot-sdk-darwin-arm64": "1.0.13-preview.6",
99
- "@github/copilot-sdk-darwin-x64": "1.0.13-preview.6",
100
- "@github/copilot-sdk-linux-arm64": "1.0.13-preview.6",
101
- "@github/copilot-sdk-linux-x64": "1.0.13-preview.6",
102
- "@github/copilot-sdk-linuxmusl-arm64": "1.0.13-preview.6",
103
- "@github/copilot-sdk-linuxmusl-x64": "1.0.13-preview.6",
104
- "@github/copilot-sdk-win32-arm64": "1.0.13-preview.6",
105
- "@github/copilot-sdk-win32-x64": "1.0.13-preview.6"
99
+ "@github/copilot-sdk-darwin-arm64": "1.0.14-preview.0",
100
+ "@github/copilot-sdk-darwin-x64": "1.0.14-preview.0",
101
+ "@github/copilot-sdk-linux-arm64": "1.0.14-preview.0",
102
+ "@github/copilot-sdk-linux-x64": "1.0.14-preview.0",
103
+ "@github/copilot-sdk-linuxmusl-arm64": "1.0.14-preview.0",
104
+ "@github/copilot-sdk-linuxmusl-x64": "1.0.14-preview.0",
105
+ "@github/copilot-sdk-win32-arm64": "1.0.14-preview.0",
106
+ "@github/copilot-sdk-win32-x64": "1.0.14-preview.0"
106
107
  }
107
108
  }