@github/copilot-sdk 1.0.9-preview.3 → 1.0.9

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
@@ -131,10 +131,11 @@ Create a new conversation session.
131
131
 
132
132
  - `sessionId?: string` - Custom session ID.
133
133
  - `model?: string` - Model to use ("gpt-5", "claude-sonnet-4.5", etc.). **Required when using custom provider.**
134
- - `reasoningEffort?: "low" | "medium" | "high" | "xhigh"` - Reasoning effort level for models that support it. Use `listModels()` to check which models support this option.
134
+ - `reasoningEffort?: "low" | "medium" | "high" | "xhigh" | "max"` - Reasoning effort level for models that support it. Use `listModels()` to check which models support this option.
135
135
  - `tools?: Tool[]` - Custom tools exposed to the CLI. Tools without `handler` are declaration-only and must be resolved via pending tool-call RPCs.
136
136
  - `systemMessage?: SystemMessageConfig` - System message customization (see below)
137
137
  - `infiniteSessions?: InfiniteSessionConfig` - Configure automatic context compaction (see below)
138
+ - `workingDirectory?: string` - Working directory for the session (default: runtime process cwd).
138
139
  - `enableSessionStore?: boolean` - Enables the cross-session store for search and retrieval across sessions. When unset in `"copilot-cli"` mode, the runtime default applies (enabled). In `"empty"` mode, defaults to disabled.
139
140
  - `provider?: ProviderConfig` - Custom API provider configuration (BYOK - Bring Your Own Key). See [Custom Providers](#custom-providers) section.
140
141
  - `onPermissionRequest?: PermissionHandler` - Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. `approveAll` approves requests when managed settings are disabled and throws when `enableManagedSettings` is true. Custom handlers can inspect `managedApprovalRequired` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section.
@@ -1108,6 +1109,21 @@ try {
1108
1109
  }
1109
1110
  ```
1110
1111
 
1112
+ ## Development
1113
+
1114
+ From the repository root:
1115
+
1116
+ ```bash
1117
+ cd test/harness
1118
+ npm ci
1119
+ ```
1120
+
1121
+ ```bash
1122
+ cd nodejs
1123
+ npm ci
1124
+ npm test
1125
+ ```
1126
+
1111
1127
  ## License
1112
1128
 
1113
1129
  MIT
@@ -1147,6 +1147,7 @@ class CopilotClient {
1147
1147
  pluginDirectories: config.pluginDirectories,
1148
1148
  instructionDirectories: config.instructionDirectories,
1149
1149
  disabledSkills: config.disabledSkills,
1150
+ disabledMcpServers: config.disabledMcpServers,
1150
1151
  infiniteSessions: config.infiniteSessions,
1151
1152
  memory: config.memory,
1152
1153
  gitHubToken: config.gitHubToken,
@@ -1357,6 +1358,7 @@ class CopilotClient {
1357
1358
  pluginDirectories: config.pluginDirectories,
1358
1359
  instructionDirectories: config.instructionDirectories,
1359
1360
  disabledSkills: config.disabledSkills,
1361
+ disabledMcpServers: config.disabledMcpServers,
1360
1362
  infiniteSessions: config.infiniteSessions,
1361
1363
  memory: config.memory,
1362
1364
  disableResume: config.suppressResumeEvent,
@@ -449,22 +449,20 @@ class CopilotSession {
449
449
  async sendAndWait(optionsOrPrompt, timeout) {
450
450
  const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
451
451
  const effectiveTimeout = timeout ?? 6e4;
452
- let resolveIdle;
453
- let rejectWithError;
454
- const idlePromise = new Promise((resolve, reject) => {
455
- resolveIdle = resolve;
456
- rejectWithError = reject;
452
+ let resolveOutcome;
453
+ const outcomePromise = new Promise((resolve) => {
454
+ resolveOutcome = resolve;
457
455
  });
458
456
  let lastAssistantMessage;
459
457
  const unsubscribe = this.on((event) => {
460
458
  if (event.type === "assistant.message") {
461
459
  lastAssistantMessage = event;
462
460
  } else if (event.type === "session.idle") {
463
- resolveIdle();
461
+ resolveOutcome({ kind: "idle" });
464
462
  } else if (event.type === "session.error") {
465
463
  const error = new Error(event.data.message);
466
464
  error.stack = event.data.stack;
467
- rejectWithError(error);
465
+ resolveOutcome({ kind: "error", error });
468
466
  }
469
467
  });
470
468
  let timeoutId;
@@ -480,7 +478,10 @@ class CopilotSession {
480
478
  effectiveTimeout
481
479
  );
482
480
  });
483
- await Promise.race([idlePromise, timeoutPromise]);
481
+ const outcome = await Promise.race([outcomePromise, timeoutPromise]);
482
+ if (outcome.kind === "error") {
483
+ throw outcome.error;
484
+ }
484
485
  return lastAssistantMessage;
485
486
  } finally {
486
487
  if (timeoutId !== void 0) {
@@ -1382,6 +1383,7 @@ class CopilotSession {
1382
1383
  postToolUse: this.hooks.onPostToolUse,
1383
1384
  postToolUseFailure: this.hooks.onPostToolUseFailure,
1384
1385
  userPromptSubmitted: this.hooks.onUserPromptSubmitted,
1386
+ userPromptTransformed: this.hooks.onUserPromptTransformed,
1385
1387
  sessionStart: this.hooks.onSessionStart,
1386
1388
  sessionEnd: this.hooks.onSessionEnd,
1387
1389
  errorOccurred: this.hooks.onErrorOccurred,
package/dist/client.js CHANGED
@@ -1124,6 +1124,7 @@ class CopilotClient {
1124
1124
  pluginDirectories: config.pluginDirectories,
1125
1125
  instructionDirectories: config.instructionDirectories,
1126
1126
  disabledSkills: config.disabledSkills,
1127
+ disabledMcpServers: config.disabledMcpServers,
1127
1128
  infiniteSessions: config.infiniteSessions,
1128
1129
  memory: config.memory,
1129
1130
  gitHubToken: config.gitHubToken,
@@ -1334,6 +1335,7 @@ class CopilotClient {
1334
1335
  pluginDirectories: config.pluginDirectories,
1335
1336
  instructionDirectories: config.instructionDirectories,
1336
1337
  disabledSkills: config.disabledSkills,
1338
+ disabledMcpServers: config.disabledMcpServers,
1337
1339
  infiniteSessions: config.infiniteSessions,
1338
1340
  memory: config.memory,
1339
1341
  disableResume: config.suppressResumeEvent,
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, 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 { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, 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, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, 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 { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, 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, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, 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, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
package/dist/session.js CHANGED
@@ -430,22 +430,20 @@ class CopilotSession {
430
430
  async sendAndWait(optionsOrPrompt, timeout) {
431
431
  const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
432
432
  const effectiveTimeout = timeout ?? 6e4;
433
- let resolveIdle;
434
- let rejectWithError;
435
- const idlePromise = new Promise((resolve, reject) => {
436
- resolveIdle = resolve;
437
- rejectWithError = reject;
433
+ let resolveOutcome;
434
+ const outcomePromise = new Promise((resolve) => {
435
+ resolveOutcome = resolve;
438
436
  });
439
437
  let lastAssistantMessage;
440
438
  const unsubscribe = this.on((event) => {
441
439
  if (event.type === "assistant.message") {
442
440
  lastAssistantMessage = event;
443
441
  } else if (event.type === "session.idle") {
444
- resolveIdle();
442
+ resolveOutcome({ kind: "idle" });
445
443
  } else if (event.type === "session.error") {
446
444
  const error = new Error(event.data.message);
447
445
  error.stack = event.data.stack;
448
- rejectWithError(error);
446
+ resolveOutcome({ kind: "error", error });
449
447
  }
450
448
  });
451
449
  let timeoutId;
@@ -461,7 +459,10 @@ class CopilotSession {
461
459
  effectiveTimeout
462
460
  );
463
461
  });
464
- await Promise.race([idlePromise, timeoutPromise]);
462
+ const outcome = await Promise.race([outcomePromise, timeoutPromise]);
463
+ if (outcome.kind === "error") {
464
+ throw outcome.error;
465
+ }
465
466
  return lastAssistantMessage;
466
467
  } finally {
467
468
  if (timeoutId !== void 0) {
@@ -1363,6 +1364,7 @@ class CopilotSession {
1363
1364
  postToolUse: this.hooks.onPostToolUse,
1364
1365
  postToolUseFailure: this.hooks.onPostToolUseFailure,
1365
1366
  userPromptSubmitted: this.hooks.onUserPromptSubmitted,
1367
+ userPromptTransformed: this.hooks.onUserPromptTransformed,
1366
1368
  sessionStart: this.hooks.onSessionStart,
1367
1369
  sessionEnd: this.hooks.onSessionEnd,
1368
1370
  errorOccurred: this.hooks.onErrorOccurred,
package/dist/types.d.ts CHANGED
@@ -1110,6 +1110,29 @@ export interface UserPromptSubmittedHookOutput {
1110
1110
  export type UserPromptSubmittedHandler = (input: UserPromptSubmittedHookInput, invocation: {
1111
1111
  sessionId: string;
1112
1112
  }) => Promise<UserPromptSubmittedHookOutput | void> | UserPromptSubmittedHookOutput | void;
1113
+ /**
1114
+ * Input for the user-prompt-transformed hook.
1115
+ *
1116
+ * This hook runs after the runtime has transformed the submitted prompt with
1117
+ * generated context, but before it is persisted to session history or sent to
1118
+ * the model.
1119
+ */
1120
+ export interface UserPromptTransformedHookInput extends BaseHookInput {
1121
+ prompt: string;
1122
+ transformedPrompt: string;
1123
+ }
1124
+ /**
1125
+ * Output for the user-prompt-transformed hook.
1126
+ */
1127
+ export interface UserPromptTransformedHookOutput {
1128
+ modifiedTransformedPrompt?: string;
1129
+ }
1130
+ /**
1131
+ * Handler for the user-prompt-transformed hook.
1132
+ */
1133
+ export type UserPromptTransformedHandler = (input: UserPromptTransformedHookInput, invocation: {
1134
+ sessionId: string;
1135
+ }) => Promise<UserPromptTransformedHookOutput | void> | UserPromptTransformedHookOutput | void;
1113
1136
  /**
1114
1137
  * Input for session-start hook
1115
1138
  */
@@ -1245,6 +1268,10 @@ export interface SessionHooks {
1245
1268
  * Called when the user submits a prompt
1246
1269
  */
1247
1270
  onUserPromptSubmitted?: UserPromptSubmittedHandler;
1271
+ /**
1272
+ * Called after the runtime transforms a submitted prompt and before it is stored.
1273
+ */
1274
+ onUserPromptTransformed?: UserPromptTransformedHandler;
1248
1275
  /**
1249
1276
  * Called when a session starts
1250
1277
  */
@@ -1450,7 +1477,7 @@ export interface LargeToolOutputConfig {
1450
1477
  /**
1451
1478
  * Valid reasoning effort levels for models that support it.
1452
1479
  */
1453
- export type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
1480
+ export type ReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max";
1454
1481
  /**
1455
1482
  * Context window tier for the session. "long_context" pins the session to the
1456
1483
  * long-context tier when the selected model supports it.
@@ -2057,6 +2084,12 @@ export interface SessionConfigBase {
2057
2084
  * List of skill names to disable.
2058
2085
  */
2059
2086
  disabledSkills?: string[];
2087
+ /**
2088
+ * Exact MCP server names to disable for this session. Disabled servers are not
2089
+ * started or authenticated when creating or cold-resuming a session. Supplying
2090
+ * this on a resident resume cannot stop servers that are already running.
2091
+ */
2092
+ disabledMcpServers?: string[];
2060
2093
  /**
2061
2094
  * Infinite session configuration for persistent workspaces and automatic compaction.
2062
2095
  * When enabled (default), sessions automatically manage context limits and persist state.
@@ -270,7 +270,7 @@ const unsub = session.on("tool.execution_complete", (event) => {
270
270
  | `tool.execution_start` | `toolCallId`, `toolName`, `arguments` |
271
271
  | `tool.execution_complete` | `toolCallId`, `success`, `result`, `error` |
272
272
  | `user.message` | `content`, `attachments`, `source` |
273
- | `session.idle` | `backgroundTasks` |
273
+ | `session.idle` | `aborted` |
274
274
  | `session.error` | `errorType`, `message`, `stack` |
275
275
  | `permission.requested` | `requestId`, `permissionRequest.kind` |
276
276
  | `session.shutdown` | `shutdownType`, `totalPremiumRequests` |
package/docs/examples.md CHANGED
@@ -419,7 +419,7 @@ session.on("assistant.message", (event) => {
419
419
  | `tool.execution_start` | A tool is about to run | `toolCallId`, `toolName`, `arguments` |
420
420
  | `tool.execution_complete` | A tool finished running | `toolCallId`, `success`, `result`, `error` |
421
421
  | `user.message` | User sent a message | `content`, `attachments`, `source` |
422
- | `session.idle` | Session finished processing a turn | `backgroundTasks` |
422
+ | `session.idle` | Session finished processing a turn | `aborted` |
423
423
  | `session.error` | An error occurred | `errorType`, `message`, `stack` |
424
424
  | `permission.requested` | Agent needs permission (shell, file write, etc.) | `requestId`, `permissionRequest.kind` |
425
425
  | `session.shutdown` | Session is ending | `shutdownType`, `totalPremiumRequests`, `codeChanges` |
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.9-preview.3",
7
+ "version": "1.0.9",
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",