@github/copilot-sdk 0.2.1 → 0.2.2-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.
@@ -166,6 +166,9 @@ class CopilotClient {
166
166
  "githubToken and useLoggedInUser cannot be used with cliUrl (external server manages its own auth)"
167
167
  );
168
168
  }
169
+ if (options.sessionFs) {
170
+ this.validateSessionFsConfig(options.sessionFs);
171
+ }
169
172
  if (options.cliUrl) {
170
173
  const { host, port } = this.parseCliUrl(options.cliUrl);
171
174
  this.actualHost = host;
@@ -220,6 +223,17 @@ class CopilotClient {
220
223
  }
221
224
  return { host, port };
222
225
  }
226
+ validateSessionFsConfig(config) {
227
+ if (!config.initialCwd) {
228
+ throw new Error("sessionFs.initialCwd is required");
229
+ }
230
+ if (!config.sessionStatePath) {
231
+ throw new Error("sessionFs.sessionStatePath is required");
232
+ }
233
+ if (config.conventions !== "windows" && config.conventions !== "posix") {
234
+ throw new Error("sessionFs.conventions must be either 'windows' or 'posix'");
235
+ }
236
+ }
223
237
  /**
224
238
  * Starts the CLI server and establishes a connection.
225
239
  *
@@ -514,6 +528,7 @@ class CopilotClient {
514
528
  availableTools: config.availableTools,
515
529
  excludedTools: config.excludedTools,
516
530
  provider: config.provider,
531
+ modelCapabilities: config.modelCapabilities,
517
532
  requestPermission: true,
518
533
  requestUserInput: !!config.onUserInputRequest,
519
534
  requestElicitation: !!config.onElicitationRequest,
@@ -634,6 +649,7 @@ class CopilotClient {
634
649
  description: cmd.description
635
650
  })),
636
651
  provider: config.provider,
652
+ modelCapabilities: config.modelCapabilities,
637
653
  requestPermission: true,
638
654
  requestUserInput: !!config.onUserInputRequest,
639
655
  requestElicitation: !!config.onElicitationRequest,
package/dist/client.d.ts CHANGED
@@ -89,6 +89,7 @@ export declare class CopilotClient {
89
89
  * Supports formats: "host:port", "http://host:port", "https://host:port", or just "port"
90
90
  */
91
91
  private parseCliUrl;
92
+ private validateSessionFsConfig;
92
93
  /**
93
94
  * Starts the CLI server and establishes a connection.
94
95
  *
package/dist/client.js CHANGED
@@ -146,6 +146,9 @@ class CopilotClient {
146
146
  "githubToken and useLoggedInUser cannot be used with cliUrl (external server manages its own auth)"
147
147
  );
148
148
  }
149
+ if (options.sessionFs) {
150
+ this.validateSessionFsConfig(options.sessionFs);
151
+ }
149
152
  if (options.cliUrl) {
150
153
  const { host, port } = this.parseCliUrl(options.cliUrl);
151
154
  this.actualHost = host;
@@ -200,6 +203,17 @@ class CopilotClient {
200
203
  }
201
204
  return { host, port };
202
205
  }
206
+ validateSessionFsConfig(config) {
207
+ if (!config.initialCwd) {
208
+ throw new Error("sessionFs.initialCwd is required");
209
+ }
210
+ if (!config.sessionStatePath) {
211
+ throw new Error("sessionFs.sessionStatePath is required");
212
+ }
213
+ if (config.conventions !== "windows" && config.conventions !== "posix") {
214
+ throw new Error("sessionFs.conventions must be either 'windows' or 'posix'");
215
+ }
216
+ }
203
217
  /**
204
218
  * Starts the CLI server and establishes a connection.
205
219
  *
@@ -494,6 +508,7 @@ class CopilotClient {
494
508
  availableTools: config.availableTools,
495
509
  excludedTools: config.excludedTools,
496
510
  provider: config.provider,
511
+ modelCapabilities: config.modelCapabilities,
497
512
  requestPermission: true,
498
513
  requestUserInput: !!config.onUserInputRequest,
499
514
  requestElicitation: !!config.onElicitationRequest,
@@ -614,6 +629,7 @@ class CopilotClient {
614
629
  description: cmd.description
615
630
  })),
616
631
  provider: config.provider,
632
+ modelCapabilities: config.modelCapabilities,
617
633
  requestPermission: true,
618
634
  requestUserInput: !!config.onUserInputRequest,
619
635
  requestElicitation: !!config.onElicitationRequest,
@@ -36,41 +36,7 @@ export interface ModelsListResult {
36
36
  * Display name
37
37
  */
38
38
  name: string;
39
- /**
40
- * Model capabilities and limits
41
- */
42
- capabilities: {
43
- /**
44
- * Feature flags indicating what the model supports
45
- */
46
- supports: {
47
- /**
48
- * Whether this model supports vision/image input
49
- */
50
- vision?: boolean;
51
- /**
52
- * Whether this model supports reasoning effort configuration
53
- */
54
- reasoningEffort?: boolean;
55
- };
56
- /**
57
- * Token limits for prompts, outputs, and context window
58
- */
59
- limits: {
60
- /**
61
- * Maximum number of prompt/input tokens
62
- */
63
- max_prompt_tokens?: number;
64
- /**
65
- * Maximum number of output/completion tokens
66
- */
67
- max_output_tokens?: number;
68
- /**
69
- * Maximum total context window size in tokens
70
- */
71
- max_context_window_tokens: number;
72
- };
73
- };
39
+ capabilities: ModelCapabilities;
74
40
  /**
75
41
  * Policy state (if applicable)
76
42
  */
@@ -103,6 +69,61 @@ export interface ModelsListResult {
103
69
  defaultReasoningEffort?: string;
104
70
  }[];
105
71
  }
72
+ /**
73
+ * Model capabilities and limits
74
+ */
75
+ export interface ModelCapabilities {
76
+ supports: ModelCapabilitiesSupports;
77
+ limits: ModelCapabilitiesLimits;
78
+ }
79
+ /**
80
+ * Feature flags indicating what the model supports
81
+ */
82
+ export interface ModelCapabilitiesSupports {
83
+ /**
84
+ * Whether this model supports vision/image input
85
+ */
86
+ vision?: boolean;
87
+ /**
88
+ * Whether this model supports reasoning effort configuration
89
+ */
90
+ reasoningEffort?: boolean;
91
+ }
92
+ /**
93
+ * Token limits for prompts, outputs, and context window
94
+ */
95
+ export interface ModelCapabilitiesLimits {
96
+ /**
97
+ * Maximum number of prompt/input tokens
98
+ */
99
+ max_prompt_tokens?: number;
100
+ /**
101
+ * Maximum number of output/completion tokens
102
+ */
103
+ max_output_tokens?: number;
104
+ /**
105
+ * Maximum total context window size in tokens
106
+ */
107
+ max_context_window_tokens: number;
108
+ vision?: ModelCapabilitiesLimitsVision;
109
+ }
110
+ /**
111
+ * Vision-specific limits
112
+ */
113
+ export interface ModelCapabilitiesLimitsVision {
114
+ /**
115
+ * MIME types the model accepts
116
+ */
117
+ supported_media_types: string[];
118
+ /**
119
+ * Maximum number of images per prompt
120
+ */
121
+ max_prompt_images: number;
122
+ /**
123
+ * Maximum image size in bytes
124
+ */
125
+ max_prompt_image_size: number;
126
+ }
106
127
  export interface ToolsListResult {
107
128
  /**
108
129
  * List of available built-in tools with metadata
@@ -361,6 +382,47 @@ export interface SessionModelSwitchToParams {
361
382
  * Reasoning effort level to use for the model
362
383
  */
363
384
  reasoningEffort?: string;
385
+ modelCapabilities?: ModelCapabilitiesOverride;
386
+ }
387
+ /**
388
+ * Override individual model capabilities resolved by the runtime
389
+ */
390
+ export interface ModelCapabilitiesOverride {
391
+ supports?: ModelCapabilitiesOverrideSupports;
392
+ limits?: ModelCapabilitiesOverrideLimits;
393
+ }
394
+ /**
395
+ * Feature flags indicating what the model supports
396
+ */
397
+ export interface ModelCapabilitiesOverrideSupports {
398
+ vision?: boolean;
399
+ reasoningEffort?: boolean;
400
+ }
401
+ /**
402
+ * Token limits for prompts, outputs, and context window
403
+ */
404
+ export interface ModelCapabilitiesOverrideLimits {
405
+ max_prompt_tokens?: number;
406
+ max_output_tokens?: number;
407
+ /**
408
+ * Maximum total context window size in tokens
409
+ */
410
+ max_context_window_tokens?: number;
411
+ vision?: ModelCapabilitiesOverrideLimitsVision;
412
+ }
413
+ export interface ModelCapabilitiesOverrideLimitsVision {
414
+ /**
415
+ * MIME types the model accepts
416
+ */
417
+ supported_media_types?: string[];
418
+ /**
419
+ * Maximum number of images per prompt
420
+ */
421
+ max_prompt_images?: number;
422
+ /**
423
+ * Maximum image size in bytes
424
+ */
425
+ max_prompt_image_size?: number;
364
426
  }
365
427
  export interface SessionModeGetResult {
366
428
  /**
@@ -264,44 +264,9 @@ export type SessionEvent = {
264
264
  ephemeral: true;
265
265
  type: "session.idle";
266
266
  /**
267
- * Payload indicating the agent is idle; includes any background tasks still in flight
267
+ * Payload indicating the session is fully idle with no background tasks in flight
268
268
  */
269
269
  data: {
270
- /**
271
- * Background tasks still running when the agent became idle
272
- */
273
- backgroundTasks?: {
274
- /**
275
- * Currently running background agents
276
- */
277
- agents: {
278
- /**
279
- * Unique identifier of the background agent
280
- */
281
- agentId: string;
282
- /**
283
- * Type of the background agent
284
- */
285
- agentType: string;
286
- /**
287
- * Human-readable description of the agent task
288
- */
289
- description?: string;
290
- }[];
291
- /**
292
- * Currently running background shell commands
293
- */
294
- shells: {
295
- /**
296
- * Unique identifier of the background shell
297
- */
298
- shellId: string;
299
- /**
300
- * Human-readable description of the shell command
301
- */
302
- description?: string;
303
- }[];
304
- };
305
270
  /**
306
271
  * True when the preceding agentic loop was cancelled via abort signal
307
272
  */
@@ -2893,13 +2858,21 @@ export type SessionEvent = {
2893
2858
  ephemeral: true;
2894
2859
  type: "user_input.completed";
2895
2860
  /**
2896
- * User input request completion notification signaling UI dismissal
2861
+ * User input request completion with the user's response
2897
2862
  */
2898
2863
  data: {
2899
2864
  /**
2900
2865
  * Request ID of the resolved user input request; clients should dismiss any UI for this request
2901
2866
  */
2902
2867
  requestId: string;
2868
+ /**
2869
+ * The user's answer to the input request
2870
+ */
2871
+ answer?: string;
2872
+ /**
2873
+ * Whether the answer was typed as free-form text rather than selected from choices
2874
+ */
2875
+ wasFreeform?: boolean;
2903
2876
  };
2904
2877
  } | {
2905
2878
  /**
@@ -2981,13 +2954,23 @@ export type SessionEvent = {
2981
2954
  ephemeral: true;
2982
2955
  type: "elicitation.completed";
2983
2956
  /**
2984
- * Elicitation request completion notification signaling UI dismissal
2957
+ * Elicitation request completion with the user's response
2985
2958
  */
2986
2959
  data: {
2987
2960
  /**
2988
2961
  * Request ID of the resolved elicitation request; clients should dismiss any UI for this request
2989
2962
  */
2990
2963
  requestId: string;
2964
+ /**
2965
+ * The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
2966
+ */
2967
+ action?: "accept" | "decline" | "cancel";
2968
+ /**
2969
+ * The submitted form data when action is 'accept'; keys match the requested schema fields
2970
+ */
2971
+ content?: {
2972
+ [k: string]: string | number | boolean | string[];
2973
+ };
2991
2974
  };
2992
2975
  } | {
2993
2976
  /**
@@ -3389,13 +3372,29 @@ export type SessionEvent = {
3389
3372
  ephemeral: true;
3390
3373
  type: "exit_plan_mode.completed";
3391
3374
  /**
3392
- * Plan mode exit completion notification signaling UI dismissal
3375
+ * Plan mode exit completion with the user's approval decision and optional feedback
3393
3376
  */
3394
3377
  data: {
3395
3378
  /**
3396
3379
  * Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request
3397
3380
  */
3398
3381
  requestId: string;
3382
+ /**
3383
+ * Whether the plan was approved by the user
3384
+ */
3385
+ approved?: boolean;
3386
+ /**
3387
+ * Which action the user selected (e.g. 'autopilot', 'interactive', 'exit_only')
3388
+ */
3389
+ selectedAction?: string;
3390
+ /**
3391
+ * Whether edits should be auto-approved without confirmation
3392
+ */
3393
+ autoApproveEdits?: boolean;
3394
+ /**
3395
+ * Free-form feedback from the user if they requested changes to the plan
3396
+ */
3397
+ feedback?: string;
3399
3398
  };
3400
3399
  } | {
3401
3400
  /**
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, 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, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventType, SessionLifecycleHandler, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsHandler, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemPromptSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
9
+ export type { CommandContext, CommandDefinition, CommandHandler, ConnectionState, CopilotClientOptions, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, InfiniteSessionConfig, InputOptions, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventType, SessionLifecycleHandler, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsHandler, 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, SectionTransformFn, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionHooks, SessionUiApi, Tool, ToolHandler, TraceContextProvider, TypedSessionEventHandler, UserInputHandler, UserInputResponse } from "./types.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";
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, {
@@ -432,6 +432,7 @@ export declare class CopilotSession {
432
432
  */
433
433
  setModel(model: string, options?: {
434
434
  reasoningEffort?: ReasoningEffort;
435
+ modelCapabilities?: ModelCapabilitiesOverride;
435
436
  }): Promise<void>;
436
437
  /**
437
438
  * Log a message to the session timeline.
package/dist/types.d.ts CHANGED
@@ -880,6 +880,8 @@ export interface SessionConfig {
880
880
  * Use client.listModels() to check supported values for each model.
881
881
  */
882
882
  reasoningEffort?: ReasoningEffort;
883
+ /** Per-property overrides for model capabilities, deep-merged over runtime defaults. */
884
+ modelCapabilities?: ModelCapabilitiesOverride;
883
885
  /**
884
886
  * Override the default configuration directory location.
885
887
  * When specified, the session will use this directory for storing config and state.
@@ -990,7 +992,7 @@ export interface SessionConfig {
990
992
  /**
991
993
  * Configuration for resuming a session
992
994
  */
993
- export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "commands" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "streaming" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "onElicitationRequest" | "hooks" | "workingDirectory" | "configDir" | "mcpServers" | "customAgents" | "agent" | "skillDirectories" | "disabledSkills" | "infiniteSessions" | "onEvent" | "createSessionFsHandler"> & {
995
+ export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "commands" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "modelCapabilities" | "streaming" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "onElicitationRequest" | "hooks" | "workingDirectory" | "configDir" | "mcpServers" | "customAgents" | "agent" | "skillDirectories" | "disabledSkills" | "infiniteSessions" | "onEvent" | "createSessionFsHandler"> & {
994
996
  /**
995
997
  * When true, skips emitting the session.resume event.
996
998
  * Useful for reconnecting to a session without triggering resume-related side effects.
@@ -1202,6 +1204,12 @@ export interface ModelCapabilities {
1202
1204
  };
1203
1205
  };
1204
1206
  }
1207
+ /** Recursively makes all properties optional, preserving arrays as-is. */
1208
+ type DeepPartial<T> = T extends readonly (infer U)[] ? DeepPartial<U>[] : T extends object ? {
1209
+ [K in keyof T]?: DeepPartial<T[K]>;
1210
+ } : T;
1211
+ /** Deep-partial override for model capabilities — every property at any depth is optional. */
1212
+ export type ModelCapabilitiesOverride = DeepPartial<ModelCapabilities>;
1205
1213
  /**
1206
1214
  * Model policy state
1207
1215
  */
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": "0.2.1",
7
+ "version": "0.2.2-preview.0",
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.17",
59
+ "@github/copilot": "^1.0.20-1",
60
60
  "vscode-jsonrpc": "^8.2.1",
61
61
  "zod": "^4.3.6"
62
62
  },