@github/copilot-sdk 1.0.17-preview.1 → 1.0.17-preview.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -644,6 +644,24 @@ if (result.status === "pending") {
644
644
 
645
645
  See [Auto tier persistence](../docs/features/session-persistence.md#auto-tier-persistence) for the full lifecycle rules.
646
646
 
647
+ ##### `setTools(tools: Tool[]): Promise<void>`
648
+
649
+ Replace the tools this client supplies to the session, together with the handlers that serve them (experimental). `tools` takes the same definitions as `createSession` and becomes this client's complete tool set; pass `[]` to remove all of this client's tools. Built-in, MCP, and plugin tools, and tools other connected clients supply, are unaffected.
650
+
651
+ Once the runtime accepts the replacement, every tool call this session dispatches uses the new handlers; calls already running finish on their original handlers. If the runtime rejects it, the promise rejects and the previous tools and handlers stay in place. Concurrent calls are applied one at a time, in call order.
652
+
653
+ ```typescript
654
+ await session.setTools([
655
+ defineTool("search_issues", {
656
+ description: "Search the issues shown on the current page",
657
+ parameters: z.object({ query: z.string() }),
658
+ handler: async ({ query }) => searchIssues(query),
659
+ }),
660
+ ]);
661
+ ```
662
+
663
+ The agent sees the new tools from its next model request, which can fall within a turn in progress, so a model request already in flight can still call a tool you removed. See [Changing tools during a session](../docs/features/changing-tools.md) for the details.
664
+
647
665
  ##### `abort(): Promise<void>`
648
666
 
649
667
  Abort the currently processing message in this session.
@@ -22,7 +22,7 @@ __export(cliVersion_exports, {
22
22
  COPILOT_CLI_VERSION: () => COPILOT_CLI_VERSION
23
23
  });
24
24
  module.exports = __toCommonJS(cliVersion_exports);
25
- const COPILOT_CLI_VERSION = "1.0.92-1";
25
+ const COPILOT_CLI_VERSION = "1.0.92-3";
26
26
  const COPILOT_CLI_USE_NPM_PACKAGE = false;
27
27
  // Annotate the CommonJS export names for ESM import in node:
28
28
  0 && (module.exports = {
@@ -38,6 +38,18 @@ function copyDefinedWorkflowAgentOption(source, target, key) {
38
38
  target[key] = value;
39
39
  }
40
40
  }
41
+ function toToolDefinition(tool) {
42
+ return {
43
+ name: tool.name,
44
+ description: tool.description ?? "",
45
+ parameters: (0, import_schema.toJsonSchema)(tool.parameters),
46
+ overridesBuiltInTool: tool.overridesBuiltInTool,
47
+ skipPermission: tool.skipPermission,
48
+ defer: tool.defer,
49
+ metadata: tool.metadata,
50
+ isTerminal: tool.isTerminal
51
+ };
52
+ }
41
53
  const workflowExecutionStore = new import_node_async_hooks.AsyncLocalStorage();
42
54
  function throwIfWorkflowExecutionIsActive() {
43
55
  if (workflowExecutionStore.getStore()?.active) {
@@ -258,6 +270,8 @@ class CopilotSession {
258
270
  eventHandlers = /* @__PURE__ */ new Set();
259
271
  typedEventHandlers = /* @__PURE__ */ new Map();
260
272
  toolHandlers = /* @__PURE__ */ new Map();
273
+ /** Settles once every earlier `setTools` call has finished. */
274
+ setToolsQueue = Promise.resolve();
261
275
  pendingExternalTools = /* @__PURE__ */ new Map();
262
276
  canvases = /* @__PURE__ */ new Map();
263
277
  bearerTokenProviders = /* @__PURE__ */ new Map();
@@ -1828,6 +1842,59 @@ class CopilotSession {
1828
1842
  async setAutoTier(autoTier) {
1829
1843
  return await this.rpc.model.switchAutoTier({ autoTier });
1830
1844
  }
1845
+ /**
1846
+ * Replace the tools this client supplies to the session.
1847
+ *
1848
+ * `tools` becomes the complete set of tools this client implements,
1849
+ * replacing the ones it supplied when the session was created or resumed,
1850
+ * or in an earlier call. Built-in, MCP, and plugin tools, and tools other
1851
+ * connected clients supply, are unaffected. Pass an empty array to remove
1852
+ * all of this client's tools.
1853
+ *
1854
+ * Tools are defined the same way as for `createSession`: calls to tools
1855
+ * with a `handler` are dispatched to it, and tools without one are
1856
+ * declaration-only. Once the runtime accepts the replacement, every tool
1857
+ * call this session dispatches uses the new handlers; calls already
1858
+ * running finish on their original handlers. If the runtime rejects the
1859
+ * replacement, this rejects and the previous tools and handlers stay in
1860
+ * place. Concurrent calls on the same session are applied one at a time,
1861
+ * in the order they are made.
1862
+ *
1863
+ * The agent sees the new tools from its next model request, which can fall
1864
+ * within a turn in progress. A model request already in flight was made
1865
+ * with the previous tools, so the agent can still call a tool you removed.
1866
+ * This session doesn't answer that call, and it can stay pending until the
1867
+ * turn is aborted. If a running turn might still call a tool you remove,
1868
+ * replace tools while the session is idle.
1869
+ *
1870
+ * @param tools - The complete set of tools this client supplies
1871
+ *
1872
+ * @experimental Wraps the experimental `session.tools.set` RPC and may change
1873
+ * or be removed in a future release.
1874
+ *
1875
+ * @example
1876
+ * ```typescript
1877
+ * await session.setTools([
1878
+ * defineTool("search_issues", {
1879
+ * description: "Search the issues shown on the current page",
1880
+ * parameters: z.object({ query: z.string() }),
1881
+ * handler: async ({ query }) => searchIssues(query),
1882
+ * }),
1883
+ * ]);
1884
+ * ```
1885
+ */
1886
+ async setTools(tools) {
1887
+ const definitions = tools.map(toToolDefinition);
1888
+ const replacement = this.setToolsQueue.then(async () => {
1889
+ await this.rpc.tools.set({ tools: definitions });
1890
+ this.registerTools(tools);
1891
+ });
1892
+ this.setToolsQueue = replacement.then(
1893
+ () => void 0,
1894
+ () => void 0
1895
+ );
1896
+ await replacement;
1897
+ }
1831
1898
  /**
1832
1899
  * Log a message to the session timeline.
1833
1900
  * The message appears in the session event stream and is visible to SDK consumers
@@ -1,2 +1,2 @@
1
- export declare const COPILOT_CLI_VERSION = "1.0.92-1";
1
+ export declare const COPILOT_CLI_VERSION = "1.0.92-3";
2
2
  export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
@@ -1,4 +1,4 @@
1
- const COPILOT_CLI_VERSION = "1.0.92-1";
1
+ const COPILOT_CLI_VERSION = "1.0.92-3";
2
2
  const COPILOT_CLI_USE_NPM_PACKAGE = false;
3
3
  export {
4
4
  COPILOT_CLI_USE_NPM_PACKAGE,
@@ -3653,6 +3653,28 @@ export type ProviderConfigTransport =
3653
3653
  "http"
3654
3654
  /** WebSocket transport. */
3655
3655
  | "websockets";
3656
+ /**
3657
+ * The product serving the model, reported in telemetry as `model_provider`.
3658
+ *
3659
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
3660
+ * via the `definition` "ProviderConfigModelProvider".
3661
+ */
3662
+ /** @experimental */
3663
+ export type ProviderConfigModelProvider =
3664
+ /** OpenAI API. */
3665
+ "openai"
3666
+ /** Anthropic API. */
3667
+ | "anthropic"
3668
+ /** Azure OpenAI Service. */
3669
+ | "azure_openai"
3670
+ /** Ollama. */
3671
+ | "ollama"
3672
+ /** LM Studio. */
3673
+ | "lm_studio"
3674
+ /** Foundry Local. */
3675
+ | "foundry_local"
3676
+ /** llama.cpp server. */
3677
+ | "llama_cpp";
3656
3678
  /**
3657
3679
  * Allowed values for the `OptionsUpdateAdditionalContentExclusionPolicyScope` enumeration.
3658
3680
  *
@@ -16710,6 +16732,7 @@ export interface NamedProviderConfig {
16710
16732
  headers?: {
16711
16733
  [k: string]: string | undefined;
16712
16734
  };
16735
+ modelProvider?: ProviderConfigModelProvider;
16713
16736
  /**
16714
16737
  * Whether the host supplies bearer tokens dynamically.
16715
16738
  */
@@ -19036,6 +19059,7 @@ export interface ProviderConfig {
19036
19059
  * Provider name used for model and telemetry attribution.
19037
19060
  */
19038
19061
  providerName?: string;
19062
+ modelProvider?: ProviderConfigModelProvider;
19039
19063
  /**
19040
19064
  * The model identifier sent to the provider API for inference (the "wire" model), as opposed to modelId which is the well-known base.
19041
19065
  */
@@ -5804,6 +5804,10 @@ export interface AssistantUsageData {
5804
5804
  */
5805
5805
  apiCallId?: string;
5806
5806
  apiEndpoint?: AssistantUsageApiEndpoint;
5807
+ /**
5808
+ * Where the bring-your-own-key model runs and who manages it: "local_managed" (on the device, managed by Copilot), "local_user" (on the device, managed by the user), or "remote_user" (off the device, managed by the user). Absent for Copilot-served models.
5809
+ */
5810
+ byokKind?: string;
5807
5811
  /**
5808
5812
  * Updated prompt-cache expiration for this model call. Present only when the call establishes or refreshes known cache state.
5809
5813
  */
@@ -5877,6 +5881,10 @@ export interface AssistantUsageData {
5877
5881
  * Model identifier used for this API call
5878
5882
  */
5879
5883
  model: string;
5884
+ /**
5885
+ * Fixed-set provider family serving the bring-your-own-key model (for example "openai", "anthropic", "azure_openai", "ollama", "llama_cpp", or "other"). Never the caller-supplied provider name. Absent for Copilot-served models.
5886
+ */
5887
+ modelProvider?: string;
5880
5888
  /**
5881
5889
  * Number of output tokens produced
5882
5890
  */
@@ -5999,6 +6007,10 @@ export interface ModelCallFailureData {
5999
6007
  apiCallId?: string;
6000
6008
  apiEndpoint?: AssistantUsageApiEndpoint;
6001
6009
  badRequestKind?: ModelCallFailureBadRequestKind;
6010
+ /**
6011
+ * Where the bring-your-own-key model for the failed call runs and who manages it: "local_managed" (on the device, managed by Copilot), "local_user" (on the device, managed by the user), or "remote_user" (off the device, managed by the user). Absent for Copilot-served models.
6012
+ */
6013
+ byokKind?: string;
6002
6014
  /**
6003
6015
  * Duration of the failed API call in milliseconds
6004
6016
  */
@@ -6050,6 +6062,10 @@ export interface ModelCallFailureData {
6050
6062
  * Model identifier used for the failed API call
6051
6063
  */
6052
6064
  model?: string;
6065
+ /**
6066
+ * Fixed-set provider family serving the bring-your-own-key model for the failed call (for example "openai", "anthropic", "azure_openai", "ollama", "llama_cpp", or "other"). Never the caller-supplied provider name. Absent for Copilot-served models.
6067
+ */
6068
+ modelProvider?: string;
6053
6069
  /**
6054
6070
  * Parent task tool call ID when this failed model call belongs to a sub-agent
6055
6071
  */
package/dist/index.d.ts CHANGED
@@ -13,5 +13,5 @@ export { defineWorkflow, WorkflowResumeError, isWorkflowRunTerminal } from "./wo
13
13
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
14
14
  export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
15
15
  export type * from "./generated/session-events.js";
16
- export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AuthIdentityMetadata, AuthInfoType, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorSessionAccount, ConnectorSessionAccountResult, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, InstallationConfirmationHandler, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionLaunchProfile, ExtensionLaunchProvider, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, ExtensionContextAttachment, MessageOptions, ResponseSchema, 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, SandboxConfigSource, ResumeSessionConfig, TranscriptRecovery, 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";
16
+ export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AuthIdentityMetadata, AuthInfoType, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorSessionAccount, ConnectorSessionAccountResult, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, InstallationConfirmationHandler, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionLaunchProfile, ExtensionLaunchProvider, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, ExtensionContextAttachment, MessageOptions, ResponseSchema, 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, ProviderConfigModelProvider, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, SandboxConfigSource, ResumeSessionConfig, TranscriptRecovery, 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";
17
17
  export type { JsonValue, WorkflowRunOptions, WorkflowResumeOptions, WorkflowLimitOverrides, WorkflowResumeErrorCode, SessionWorkflowApi, WorkflowAgentOptions, WorkflowContext, WorkflowDefinition, WorkflowHandle, WorkflowJsonSchema, WorkflowLimits, WorkflowMeta, WorkflowPipelineStage, WorkflowStepOptions, WorkflowRunResult, WorkflowRunStatus, WorkflowRunSummary, WorkflowListRunsOptions, WorkflowRunsPage, WorkflowRunDetail, WorkflowProgressPage, WorkflowProgressLine, WorkflowPhaseObservation, WorkflowPhaseStatus, WorkflowAgentSummary, } from "./workflow.js";
package/dist/session.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createSessionRpc } from "./generated/rpc.js";
2
2
  import type { ModelSwitchAutoTierResult } from "./generated/rpc.js";
3
3
  import type { OpenCanvasInstance } from "./generated/rpc.js";
4
- import type { MessageOptions, ResponseSchema, ContextTier, ReasoningEffort, ReasoningSummary, AutoTier, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TranscriptRecovery, TypedSessionEventHandler } from "./types.js";
4
+ import type { MessageOptions, ResponseSchema, ContextTier, ReasoningEffort, ReasoningSummary, AutoTier, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, Tool, TranscriptRecovery, TypedSessionEventHandler } from "./types.js";
5
5
  import { type SessionWorkflowApi } from "./workflow.js";
6
6
  /** Assistant message event - the final response from the assistant. */
7
7
  export type AssistantMessageEvent = Extract<SessionEvent, {
@@ -45,6 +45,8 @@ export declare class CopilotSession {
45
45
  private eventHandlers;
46
46
  private typedEventHandlers;
47
47
  private toolHandlers;
48
+ /** Settles once every earlier `setTools` call has finished. */
49
+ private setToolsQueue;
48
50
  private pendingExternalTools;
49
51
  private canvases;
50
52
  private bearerTokenProviders;
@@ -364,6 +366,48 @@ export declare class CopilotSession {
364
366
  * ```
365
367
  */
366
368
  setAutoTier(autoTier: AutoTier | null): Promise<ModelSwitchAutoTierResult>;
369
+ /**
370
+ * Replace the tools this client supplies to the session.
371
+ *
372
+ * `tools` becomes the complete set of tools this client implements,
373
+ * replacing the ones it supplied when the session was created or resumed,
374
+ * or in an earlier call. Built-in, MCP, and plugin tools, and tools other
375
+ * connected clients supply, are unaffected. Pass an empty array to remove
376
+ * all of this client's tools.
377
+ *
378
+ * Tools are defined the same way as for `createSession`: calls to tools
379
+ * with a `handler` are dispatched to it, and tools without one are
380
+ * declaration-only. Once the runtime accepts the replacement, every tool
381
+ * call this session dispatches uses the new handlers; calls already
382
+ * running finish on their original handlers. If the runtime rejects the
383
+ * replacement, this rejects and the previous tools and handlers stay in
384
+ * place. Concurrent calls on the same session are applied one at a time,
385
+ * in the order they are made.
386
+ *
387
+ * The agent sees the new tools from its next model request, which can fall
388
+ * within a turn in progress. A model request already in flight was made
389
+ * with the previous tools, so the agent can still call a tool you removed.
390
+ * This session doesn't answer that call, and it can stay pending until the
391
+ * turn is aborted. If a running turn might still call a tool you remove,
392
+ * replace tools while the session is idle.
393
+ *
394
+ * @param tools - The complete set of tools this client supplies
395
+ *
396
+ * @experimental Wraps the experimental `session.tools.set` RPC and may change
397
+ * or be removed in a future release.
398
+ *
399
+ * @example
400
+ * ```typescript
401
+ * await session.setTools([
402
+ * defineTool("search_issues", {
403
+ * description: "Search the issues shown on the current page",
404
+ * parameters: z.object({ query: z.string() }),
405
+ * handler: async ({ query }) => searchIssues(query),
406
+ * }),
407
+ * ]);
408
+ * ```
409
+ */
410
+ setTools(tools: Tool[]): Promise<void>;
367
411
  /**
368
412
  * Log a message to the session timeline.
369
413
  * The message appears in the session event stream and is visible to SDK consumers
package/dist/session.js CHANGED
@@ -20,6 +20,18 @@ function copyDefinedWorkflowAgentOption(source, target, key) {
20
20
  target[key] = value;
21
21
  }
22
22
  }
23
+ function toToolDefinition(tool) {
24
+ return {
25
+ name: tool.name,
26
+ description: tool.description ?? "",
27
+ parameters: toJsonSchema(tool.parameters),
28
+ overridesBuiltInTool: tool.overridesBuiltInTool,
29
+ skipPermission: tool.skipPermission,
30
+ defer: tool.defer,
31
+ metadata: tool.metadata,
32
+ isTerminal: tool.isTerminal
33
+ };
34
+ }
23
35
  const workflowExecutionStore = new AsyncLocalStorage();
24
36
  function throwIfWorkflowExecutionIsActive() {
25
37
  if (workflowExecutionStore.getStore()?.active) {
@@ -240,6 +252,8 @@ class CopilotSession {
240
252
  eventHandlers = /* @__PURE__ */ new Set();
241
253
  typedEventHandlers = /* @__PURE__ */ new Map();
242
254
  toolHandlers = /* @__PURE__ */ new Map();
255
+ /** Settles once every earlier `setTools` call has finished. */
256
+ setToolsQueue = Promise.resolve();
243
257
  pendingExternalTools = /* @__PURE__ */ new Map();
244
258
  canvases = /* @__PURE__ */ new Map();
245
259
  bearerTokenProviders = /* @__PURE__ */ new Map();
@@ -1810,6 +1824,59 @@ class CopilotSession {
1810
1824
  async setAutoTier(autoTier) {
1811
1825
  return await this.rpc.model.switchAutoTier({ autoTier });
1812
1826
  }
1827
+ /**
1828
+ * Replace the tools this client supplies to the session.
1829
+ *
1830
+ * `tools` becomes the complete set of tools this client implements,
1831
+ * replacing the ones it supplied when the session was created or resumed,
1832
+ * or in an earlier call. Built-in, MCP, and plugin tools, and tools other
1833
+ * connected clients supply, are unaffected. Pass an empty array to remove
1834
+ * all of this client's tools.
1835
+ *
1836
+ * Tools are defined the same way as for `createSession`: calls to tools
1837
+ * with a `handler` are dispatched to it, and tools without one are
1838
+ * declaration-only. Once the runtime accepts the replacement, every tool
1839
+ * call this session dispatches uses the new handlers; calls already
1840
+ * running finish on their original handlers. If the runtime rejects the
1841
+ * replacement, this rejects and the previous tools and handlers stay in
1842
+ * place. Concurrent calls on the same session are applied one at a time,
1843
+ * in the order they are made.
1844
+ *
1845
+ * The agent sees the new tools from its next model request, which can fall
1846
+ * within a turn in progress. A model request already in flight was made
1847
+ * with the previous tools, so the agent can still call a tool you removed.
1848
+ * This session doesn't answer that call, and it can stay pending until the
1849
+ * turn is aborted. If a running turn might still call a tool you remove,
1850
+ * replace tools while the session is idle.
1851
+ *
1852
+ * @param tools - The complete set of tools this client supplies
1853
+ *
1854
+ * @experimental Wraps the experimental `session.tools.set` RPC and may change
1855
+ * or be removed in a future release.
1856
+ *
1857
+ * @example
1858
+ * ```typescript
1859
+ * await session.setTools([
1860
+ * defineTool("search_issues", {
1861
+ * description: "Search the issues shown on the current page",
1862
+ * parameters: z.object({ query: z.string() }),
1863
+ * handler: async ({ query }) => searchIssues(query),
1864
+ * }),
1865
+ * ]);
1866
+ * ```
1867
+ */
1868
+ async setTools(tools) {
1869
+ const definitions = tools.map(toToolDefinition);
1870
+ const replacement = this.setToolsQueue.then(async () => {
1871
+ await this.rpc.tools.set({ tools: definitions });
1872
+ this.registerTools(tools);
1873
+ });
1874
+ this.setToolsQueue = replacement.then(
1875
+ () => void 0,
1876
+ () => void 0
1877
+ );
1878
+ await replacement;
1879
+ }
1813
1880
  /**
1814
1881
  * Log a message to the session timeline.
1815
1882
  * The message appears in the session event stream and is visible to SDK consumers
package/dist/types.d.ts CHANGED
@@ -2522,6 +2522,12 @@ export interface ProviderTokenArgs {
2522
2522
  * surface and may change or be removed in future SDK or CLI releases.
2523
2523
  */
2524
2524
  export type BearerTokenProvider = (args: ProviderTokenArgs) => Promise<string>;
2525
+ /**
2526
+ * Product serving a configured provider's model. Allowed values are
2527
+ * "openai", "anthropic", "azure_openai", "ollama", "lm_studio",
2528
+ * "foundry_local", and "llama_cpp".
2529
+ */
2530
+ export type ProviderConfigModelProvider = "openai" | "anthropic" | "azure_openai" | "ollama" | "lm_studio" | "foundry_local" | "llama_cpp";
2525
2531
  /**
2526
2532
  * Configuration for a custom API provider.
2527
2533
  */
@@ -2544,6 +2550,11 @@ export interface ProviderConfig {
2544
2550
  * providers using `wireApi: "responses"`.
2545
2551
  */
2546
2552
  transport?: "http" | "websockets";
2553
+ /**
2554
+ * Product serving the model, such as "ollama" or "lm_studio", reported in
2555
+ * telemetry as `model_provider`. Only affects telemetry.
2556
+ */
2557
+ modelProvider?: ProviderConfigModelProvider;
2547
2558
  /**
2548
2559
  * API endpoint URL
2549
2560
  */
@@ -2637,6 +2648,11 @@ export interface NamedProviderConfig {
2637
2648
  * Wire API format (openai/azure only). Defaults to "completions".
2638
2649
  */
2639
2650
  wireApi?: "completions" | "responses";
2651
+ /**
2652
+ * Product serving this provider's models, such as "ollama" or "lm_studio",
2653
+ * reported in telemetry as `model_provider`. Only affects telemetry.
2654
+ */
2655
+ modelProvider?: ProviderConfigModelProvider;
2640
2656
  /**
2641
2657
  * API endpoint URL.
2642
2658
  */
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "url": "https://github.com/github/copilot-agent-runtime.git",
6
6
  "directory": "src/sdk/nodejs"
7
7
  },
8
- "version": "1.0.17-preview.1",
9
- "copilotCliVersion": "1.0.92-1",
8
+ "version": "1.0.17-preview.3",
9
+ "copilotCliVersion": "1.0.92-3",
10
10
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
11
11
  "main": "./dist/cjs/index.js",
12
12
  "types": "./dist/index.d.ts",
@@ -102,18 +102,18 @@
102
102
  "README.md"
103
103
  ],
104
104
  "copilotRuntime": {
105
- "sourceSha": "f35a336da8899d7c919157780bdb088504c81fd2",
106
- "version": "1.0.92-1",
105
+ "sourceSha": "7a09ab7e985d69cf9f6d446d5c83ae897c7f7daa",
106
+ "version": "1.0.92-3",
107
107
  "visibility": "public"
108
108
  },
109
109
  "optionalDependencies": {
110
- "@github/copilot-sdk-darwin-arm64": "1.0.17-preview.1",
111
- "@github/copilot-sdk-darwin-x64": "1.0.17-preview.1",
112
- "@github/copilot-sdk-linux-arm64": "1.0.17-preview.1",
113
- "@github/copilot-sdk-linux-x64": "1.0.17-preview.1",
114
- "@github/copilot-sdk-linuxmusl-arm64": "1.0.17-preview.1",
115
- "@github/copilot-sdk-linuxmusl-x64": "1.0.17-preview.1",
116
- "@github/copilot-sdk-win32-arm64": "1.0.17-preview.1",
117
- "@github/copilot-sdk-win32-x64": "1.0.17-preview.1"
110
+ "@github/copilot-sdk-darwin-arm64": "1.0.17-preview.3",
111
+ "@github/copilot-sdk-darwin-x64": "1.0.17-preview.3",
112
+ "@github/copilot-sdk-linux-arm64": "1.0.17-preview.3",
113
+ "@github/copilot-sdk-linux-x64": "1.0.17-preview.3",
114
+ "@github/copilot-sdk-linuxmusl-arm64": "1.0.17-preview.3",
115
+ "@github/copilot-sdk-linuxmusl-x64": "1.0.17-preview.3",
116
+ "@github/copilot-sdk-win32-arm64": "1.0.17-preview.3",
117
+ "@github/copilot-sdk-win32-x64": "1.0.17-preview.3"
118
118
  }
119
119
  }