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

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/types.d.ts CHANGED
@@ -4,10 +4,15 @@
4
4
  import type { SessionFsProvider } from "./sessionFsProvider.js";
5
5
  import type { SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
6
6
  import type { CopilotSession } from "./session.js";
7
+ import type { RemoteSessionMode } from "./generated/rpc.js";
8
+ export type { RemoteSessionMode } from "./generated/rpc.js";
7
9
  export type SessionEvent = GeneratedSessionEvent;
8
10
  export type { SessionFsProvider } from "./sessionFsProvider.js";
9
11
  export { createSessionFsAdapter } from "./sessionFsProvider.js";
10
12
  export type { SessionFsFileInfo } from "./sessionFsProvider.js";
13
+ export type { SessionFsSqliteQueryResult } from "./sessionFsProvider.js";
14
+ export type { SessionFsSqliteQueryType } from "./sessionFsProvider.js";
15
+ export type { SessionFsSqliteProvider } from "./sessionFsProvider.js";
11
16
  /**
12
17
  * Options for creating a CopilotClient
13
18
  */
@@ -43,80 +48,120 @@ export interface TelemetryConfig {
43
48
  /** Whether to capture message content (prompts, responses). Sets OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT. */
44
49
  captureContent?: boolean;
45
50
  }
46
- export interface CopilotClientOptions {
51
+ /**
52
+ * Configures how a {@link CopilotClient} connects to the Copilot runtime.
53
+ * Construct via the factory functions on {@link RuntimeConnection}.
54
+ */
55
+ export type RuntimeConnection = StdioRuntimeConnection | TcpRuntimeConnection | UriRuntimeConnection;
56
+ /**
57
+ * Spawns a runtime child process and communicates over its stdin/stdout.
58
+ * This is the default if no {@link CopilotClientOptions.connection} is set.
59
+ */
60
+ export interface StdioRuntimeConnection {
61
+ readonly kind: "stdio";
62
+ /** Path to the runtime executable. When omitted, the bundled runtime is used. */
63
+ readonly path?: string;
64
+ /** Extra command-line arguments to pass to the runtime process. */
65
+ readonly args?: readonly string[];
66
+ }
67
+ /**
68
+ * Spawns a runtime child process that listens on a TCP socket and connects to it.
69
+ */
70
+ export interface TcpRuntimeConnection {
71
+ readonly kind: "tcp";
47
72
  /**
48
- * Path to the CLI executable or JavaScript entry point.
49
- * If not specified, uses the bundled CLI from the @github/copilot package.
73
+ * TCP port to listen on. `0` (the default) auto-allocates a free port.
74
+ * If the chosen port is already in use, startup fails.
50
75
  */
51
- cliPath?: string;
76
+ readonly port?: number;
52
77
  /**
53
- * Extra arguments to pass to the CLI executable (inserted before SDK-managed args)
78
+ * Optional shared secret the SDK sends to the spawned runtime to authenticate
79
+ * the TCP connection. When omitted, a UUID is generated automatically so the
80
+ * loopback listener is safe by default.
54
81
  */
55
- cliArgs?: string[];
82
+ readonly connectionToken?: string;
83
+ /** Path to the runtime executable. When omitted, the bundled runtime is used. */
84
+ readonly path?: string;
85
+ /** Extra command-line arguments to pass to the runtime process. */
86
+ readonly args?: readonly string[];
87
+ }
88
+ /**
89
+ * Connects to an already-running runtime at the specified URL. The SDK does not
90
+ * spawn a process in this mode.
91
+ */
92
+ export interface UriRuntimeConnection {
93
+ readonly kind: "uri";
56
94
  /**
57
- * Working directory for the CLI process
58
- * If not set, inherits the current process's working directory
95
+ * URL of the runtime to connect to. Accepts `"port"`, `"host:port"`, or a
96
+ * full URL (`"http://host:port"`).
59
97
  */
60
- cwd?: string;
61
- /**
62
- * Base directory for Copilot data (session state, config, etc.).
63
- * Sets the COPILOT_HOME environment variable on the spawned CLI process.
64
- * When not set, the CLI defaults to ~/.copilot.
65
- * This option is only used when the SDK spawns the CLI process; it is ignored
66
- * when connecting to an external server via {@link cliUrl}.
67
- */
68
- copilotHome?: string;
98
+ readonly url: string;
99
+ /** Optional shared secret to authenticate the connection. */
100
+ readonly connectionToken?: string;
101
+ }
102
+ /** Factory functions for constructing {@link RuntimeConnection} instances. */
103
+ export declare const RuntimeConnection: {
69
104
  /**
70
- * Port for the CLI server (TCP mode only)
71
- * @default 0 (random available port)
105
+ * Spawn a runtime child process and communicate over its stdin/stdout.
106
+ * This is the default if no {@link CopilotClientOptions.connection} is set.
72
107
  */
73
- port?: number;
108
+ readonly forStdio: (opts?: {
109
+ path?: string;
110
+ args?: readonly string[];
111
+ }) => StdioRuntimeConnection;
74
112
  /**
75
- * Use stdio transport instead of TCP
76
- * When true, communicates with CLI via stdin/stdout pipes
77
- * @default true
113
+ * Spawn a runtime child process that listens on a TCP socket and connect to it.
78
114
  */
79
- useStdio?: boolean;
115
+ readonly forTcp: (opts?: {
116
+ port?: number;
117
+ connectionToken?: string;
118
+ path?: string;
119
+ args?: readonly string[];
120
+ }) => TcpRuntimeConnection;
80
121
  /**
81
- * When true, indicates the SDK is running as a child process of the Copilot CLI server, and should
82
- * use its own stdio for communicating with the existing parent process. Can only be used in combination
83
- * with useStdio: true.
122
+ * Connect to an already-running runtime at the given URL. The SDK does not
123
+ * spawn a process in this mode.
84
124
  */
85
- isChildProcess?: boolean;
125
+ readonly forUri: (url: string, opts?: {
126
+ connectionToken?: string;
127
+ }) => UriRuntimeConnection;
128
+ };
129
+ export interface CopilotClientOptions {
86
130
  /**
87
- * URL of an existing Copilot CLI server to connect to over TCP
88
- * When provided, the client will not spawn a CLI process
89
- * Format: "host:port" or "http://host:port" or just "port" (defaults to localhost)
90
- * Examples: "localhost:8080", "http://127.0.0.1:9000", "8080"
91
- * Mutually exclusive with cliPath, useStdio
131
+ * How to connect to the Copilot runtime. When omitted, defaults to
132
+ * {@link RuntimeConnection.forStdio} with the bundled runtime.
92
133
  */
93
- cliUrl?: string;
134
+ connection?: RuntimeConnection;
94
135
  /**
95
- * Log level for the CLI server
136
+ * Working directory for the runtime process.
137
+ * If not set, inherits the current process's working directory.
96
138
  */
97
- logLevel?: "none" | "error" | "warning" | "info" | "debug" | "all";
139
+ workingDirectory?: string;
98
140
  /**
99
- * Auto-start the CLI server on first use
100
- * @default true
141
+ * Base directory for Copilot data (session state, config, etc.).
142
+ * Sets the COPILOT_HOME environment variable on the spawned runtime.
143
+ * When not set, the runtime defaults to ~/.copilot.
144
+ * Ignored when connecting to an existing runtime via {@link RuntimeConnection.forUri}.
101
145
  */
102
- autoStart?: boolean;
146
+ baseDirectory?: string;
103
147
  /**
104
- * @deprecated This option has no effect and will be removed in a future release.
148
+ * Log level for the Copilot runtime. When omitted, the runtime uses its
149
+ * own default (currently `"info"`).
105
150
  */
106
- autoRestart?: boolean;
151
+ logLevel?: "none" | "error" | "warning" | "info" | "debug" | "all";
107
152
  /**
108
- * Environment variables to pass to the CLI process. If not set, inherits process.env.
153
+ * Environment variables to pass to the runtime process. If not set, inherits process.env.
109
154
  */
110
155
  env?: Record<string, string | undefined>;
111
156
  /**
112
157
  * GitHub token to use for authentication.
113
- * When provided, the token is passed to the CLI server via environment variable.
158
+ * When provided, the token is passed to the runtime via environment variable.
114
159
  * This takes priority over other authentication methods.
115
160
  */
116
161
  gitHubToken?: string;
117
162
  /**
118
163
  * Whether to use the logged-in user for authentication.
119
- * When true, the CLI server will attempt to use stored OAuth tokens or gh CLI auth.
164
+ * When true, the runtime will attempt to use stored OAuth tokens or gh CLI auth.
120
165
  * When false, only explicit tokens (gitHubToken or environment variables) are used.
121
166
  * @default true (but defaults to false when gitHubToken is provided)
122
167
  */
@@ -124,14 +169,14 @@ export interface CopilotClientOptions {
124
169
  /**
125
170
  * Custom handler for listing available models.
126
171
  * When provided, client.listModels() calls this handler instead of
127
- * querying the CLI server. Useful in BYOK mode to return models
172
+ * querying the runtime. Useful in BYOK mode to return models
128
173
  * available from your custom provider.
129
174
  */
130
175
  onListModels?: () => Promise<ModelInfo[]> | ModelInfo[];
131
176
  /**
132
- * OpenTelemetry configuration for the CLI process.
177
+ * OpenTelemetry configuration for the runtime process.
133
178
  * When provided, the corresponding OTel environment variables are set
134
- * on the spawned CLI server.
179
+ * on the spawned runtime.
135
180
  */
136
181
  telemetry?: TelemetryConfig;
137
182
  /**
@@ -170,27 +215,18 @@ export interface CopilotClientOptions {
170
215
  * Server-wide idle timeout for sessions in seconds.
171
216
  * Sessions without activity for this duration are automatically cleaned up.
172
217
  * Set to 0 or omit to disable (sessions live indefinitely).
173
- * This option is only used when the SDK spawns the CLI process; it is ignored
174
- * when connecting to an external server via {@link cliUrl}.
218
+ * Ignored when connecting to an existing runtime via {@link RuntimeConnection.forUri}.
175
219
  * @default undefined (disabled)
176
220
  */
177
221
  sessionIdleTimeoutSeconds?: number;
178
- /**
179
- * Connection token for the headless CLI server (TCP only). When the SDK
180
- * spawns its own CLI in TCP mode and this is omitted, a UUID is generated
181
- * automatically so the loopback listener is safe by default. Rejected with
182
- * `useStdio: true` (stdio is pre-authenticated by transport).
183
- */
184
- tcpConnectionToken?: string;
185
222
  /**
186
223
  * Enable remote session support (Mission Control integration).
187
224
  * When true, sessions in a GitHub repository working directory are
188
225
  * accessible from GitHub web and mobile.
189
- * This option is only used when the SDK spawns the CLI process; it is ignored
190
- * when connecting to an external server via {@link cliUrl}.
226
+ * Ignored when connecting to an existing runtime via {@link RuntimeConnection.forUri}.
191
227
  * @default false
192
228
  */
193
- remote?: boolean;
229
+ enableRemoteSessions?: boolean;
194
230
  }
195
231
  /**
196
232
  * Configuration for creating a session
@@ -199,18 +235,33 @@ export type ToolResultType = "success" | "failure" | "rejected" | "denied" | "ti
199
235
  export type ToolBinaryResult = {
200
236
  data: string;
201
237
  mimeType: string;
202
- type: string;
238
+ type: "image" | "resource";
203
239
  description?: string;
204
240
  };
241
+ export type ToolTelemetry = Record<string, Record<string, unknown> | undefined>;
205
242
  export type ToolResultObject = {
206
243
  textResultForLlm: string;
207
244
  binaryResultsForLlm?: ToolBinaryResult[];
208
245
  resultType: ToolResultType;
209
246
  error?: string;
210
247
  sessionLog?: string;
211
- toolTelemetry?: Record<string, unknown>;
248
+ toolTelemetry?: ToolTelemetry;
212
249
  };
213
250
  export type ToolResult = string | ToolResultObject;
251
+ /**
252
+ * GitHub repository metadata to associate with a cloud session.
253
+ */
254
+ export interface CloudSessionRepository {
255
+ owner: string;
256
+ name: string;
257
+ branch?: string;
258
+ }
259
+ /**
260
+ * Options for creating a remote session in the cloud.
261
+ */
262
+ export interface CloudSessionOptions {
263
+ repository?: CloudSessionRepository;
264
+ }
214
265
  /**
215
266
  * Content block types within an MCP CallToolResult.
216
267
  */
@@ -269,12 +320,16 @@ export interface ZodSchema<T = unknown> {
269
320
  * - A Zod schema (provides type inference for handler)
270
321
  * - A raw JSON schema object
271
322
  * - Omitted (no parameters)
323
+ *
324
+ * If `handler` is omitted, the SDK exposes the declaration but does not
325
+ * automatically invoke the tool. Consumers can resolve tool calls by observing
326
+ * external tool request events and calling the pending-tool RPC.
272
327
  */
273
328
  export interface Tool<TArgs = unknown> {
274
329
  name: string;
275
330
  description?: string;
276
331
  parameters?: ZodSchema<TArgs> | Record<string, unknown>;
277
- handler: ToolHandler<TArgs>;
332
+ handler?: ToolHandler<TArgs>;
278
333
  /**
279
334
  * When true, explicitly indicates this tool is intended to override a built-in tool
280
335
  * of the same name. If not set and the name clashes with a built-in tool, the runtime
@@ -293,7 +348,7 @@ export interface Tool<TArgs = unknown> {
293
348
  export declare function defineTool<T = unknown>(name: string, config: {
294
349
  description?: string;
295
350
  parameters?: ZodSchema<T> | Record<string, unknown>;
296
- handler: ToolHandler<T>;
351
+ handler?: ToolHandler<T>;
297
352
  overridesBuiltInTool?: boolean;
298
353
  skipPermission?: boolean;
299
354
  }): Tool<T>;
@@ -458,7 +513,7 @@ export type ElicitationHandler = (context: ElicitationContext) => Promise<Elicit
458
513
  /**
459
514
  * Options for the `input()` convenience method.
460
515
  */
461
- export interface InputOptions {
516
+ export interface UiInputOptions {
462
517
  /** Title label for the input field. */
463
518
  title?: string;
464
519
  /** Descriptive text shown below the field. */
@@ -499,7 +554,7 @@ export interface SessionUiApi {
499
554
  * Returns the entered text, or `null` if the user declines/cancels.
500
555
  * @throws Error if the host does not support elicitation.
501
556
  */
502
- input(message: string, options?: InputOptions): Promise<string | null>;
557
+ input(message: string, options?: UiInputOptions): Promise<string | null>;
503
558
  }
504
559
  export interface ToolCallRequestPayload {
505
560
  sessionId: string;
@@ -598,13 +653,20 @@ export interface SystemMessageCustomizeConfig {
598
653
  */
599
654
  export type SystemMessageConfig = SystemMessageAppendConfig | SystemMessageReplaceConfig | SystemMessageCustomizeConfig;
600
655
  /**
601
- * Permission request types from the server
656
+ * Permission request types from the server. This is the generated
657
+ * discriminated union from the runtime schema — switch on `kind` to
658
+ * access the variant-specific fields (e.g. shell `commands`, write
659
+ * `fileName`/`diff`, mcp `toolName`/`args`).
602
660
  */
603
- export interface PermissionRequest {
604
- kind: "shell" | "write" | "mcp" | "read" | "url" | "custom-tool" | "memory" | "hook";
605
- toolCallId?: string;
606
- }
661
+ export type { PermissionRequest } from "./generated/session-events.js";
662
+ import type { PermissionRequest } from "./generated/session-events.js";
607
663
  import type { PermissionDecisionRequest } from "./generated/rpc.js";
664
+ /**
665
+ * Permission decision result returned from a {@link PermissionHandler}.
666
+ * The discriminated `kind` field selects the decision. Variant-specific
667
+ * fields (e.g. `feedback` on `{ kind: "reject" }`) come from the generated
668
+ * `PermissionDecisionRequest["result"]` union.
669
+ */
608
670
  export type PermissionRequestResult = PermissionDecisionRequest["result"] | {
609
671
  kind: "no-result";
610
672
  };
@@ -703,8 +765,12 @@ export type AutoModeSwitchHandler = (request: AutoModeSwitchRequest, invocation:
703
765
  * Base interface for all hook inputs
704
766
  */
705
767
  export interface BaseHookInput {
706
- timestamp: number;
707
- cwd: string;
768
+ /** The runtime session ID of the session that triggered the hook.
769
+ * For sub-agent hooks this differs from `invocation.sessionId`. */
770
+ sessionId: string;
771
+ /** Time at which the hook event was emitted by the runtime. */
772
+ timestamp: Date;
773
+ workingDirectory: string;
708
774
  }
709
775
  /**
710
776
  * Input for pre-tool-use hook
@@ -729,6 +795,34 @@ export interface PreToolUseHookOutput {
729
795
  export type PreToolUseHandler = (input: PreToolUseHookInput, invocation: {
730
796
  sessionId: string;
731
797
  }) => Promise<PreToolUseHookOutput | void> | PreToolUseHookOutput | void;
798
+ /**
799
+ * Input for pre-MCP-tool-call hook
800
+ */
801
+ export interface PreMcpToolCallHookInput extends BaseHookInput {
802
+ toolCallId?: string;
803
+ serverName: string;
804
+ toolName: string;
805
+ arguments: unknown;
806
+ _meta?: Record<string, unknown>;
807
+ }
808
+ /**
809
+ * Output for pre-MCP-tool-call hook
810
+ */
811
+ export interface PreMcpToolCallHookOutput {
812
+ /**
813
+ * Hook-controlled metadata to use for the outgoing MCP request.
814
+ * - undefined/absent: preserve the current request `_meta`
815
+ * - object: use this object as request `_meta`
816
+ * - null: omit `_meta`
817
+ */
818
+ metaToUse?: Record<string, unknown> | null;
819
+ }
820
+ /**
821
+ * Handler for pre-MCP-tool-call hook
822
+ */
823
+ export type PreMcpToolCallHandler = (input: PreMcpToolCallHookInput, invocation: {
824
+ sessionId: string;
825
+ }) => Promise<PreMcpToolCallHookOutput | void> | PreMcpToolCallHookOutput | void;
732
826
  /**
733
827
  * Input for post-tool-use hook
734
828
  */
@@ -844,6 +938,10 @@ export interface SessionHooks {
844
938
  * Called before a tool is executed
845
939
  */
846
940
  onPreToolUse?: PreToolUseHandler;
941
+ /**
942
+ * Called before an MCP tool is called
943
+ */
944
+ onPreMcpToolCall?: PreMcpToolCallHandler;
847
945
  /**
848
946
  * Called after a tool is executed
849
947
  */
@@ -870,9 +968,11 @@ export interface SessionHooks {
870
968
  */
871
969
  interface MCPServerConfigBase {
872
970
  /**
873
- * List of tools to include from this server. [] means none. "*" means all.
971
+ * List of tools to include from this server.
972
+ * `undefined` (the default) or `["*"]` means include all tools.
973
+ * `[]` means include none.
874
974
  */
875
- tools: string[];
975
+ tools?: string[];
876
976
  /**
877
977
  * Indicates the server type: "stdio" for local/subprocess servers, "http"/"sse" for remote servers.
878
978
  * If not specified, defaults to "stdio".
@@ -889,12 +989,15 @@ interface MCPServerConfigBase {
889
989
  export interface MCPStdioServerConfig extends MCPServerConfigBase {
890
990
  type?: "local" | "stdio";
891
991
  command: string;
892
- args: string[];
992
+ args?: string[];
893
993
  /**
894
994
  * Environment variables to pass to the server.
895
995
  */
896
996
  env?: Record<string, string>;
897
- cwd?: string;
997
+ /**
998
+ * Working directory for the server process.
999
+ */
1000
+ workingDirectory?: string;
898
1001
  }
899
1002
  /**
900
1003
  * Configuration for a remote MCP server (HTTP or SSE).
@@ -956,6 +1059,12 @@ export interface CustomAgentConfig {
956
1059
  * When omitted, no skills are injected (opt-in model).
957
1060
  */
958
1061
  skills?: string[];
1062
+ /**
1063
+ * Model identifier for this agent (e.g. "claude-haiku-4.5").
1064
+ * When set, the runtime will attempt to use this model for the agent,
1065
+ * falling back to the parent session model if unavailable.
1066
+ */
1067
+ model?: string;
959
1068
  }
960
1069
  /**
961
1070
  * Configuration for the default agent (the built-in agent that handles
@@ -999,12 +1108,12 @@ export interface InfiniteSessionConfig {
999
1108
  * Valid reasoning effort levels for models that support it.
1000
1109
  */
1001
1110
  export type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
1002
- export interface SessionConfig {
1003
- /**
1004
- * Optional custom session ID
1005
- * If not provided, server will generate one
1006
- */
1007
- sessionId?: string;
1111
+ /**
1112
+ * Shared configuration fields used by both {@link SessionConfig} (for
1113
+ * creating a new session) and {@link ResumeSessionConfig} (for resuming
1114
+ * an existing one).
1115
+ */
1116
+ export interface SessionConfigBase {
1008
1117
  /**
1009
1118
  * Client name to identify the application using the SDK.
1010
1119
  * Included in the User-Agent header for API requests.
@@ -1040,7 +1149,8 @@ export interface SessionConfig {
1040
1149
  */
1041
1150
  enableConfigDiscovery?: boolean;
1042
1151
  /**
1043
- * Tools exposed to the CLI server
1152
+ * Tools exposed to the CLI server. Tools without a handler are declaration-only
1153
+ * and must be resolved by the consumer via pending external tool request RPCs.
1044
1154
  */
1045
1155
  tools?: Tool<any>[];
1046
1156
  /**
@@ -1079,10 +1189,11 @@ export interface SessionConfig {
1079
1189
  */
1080
1190
  enableSessionTelemetry?: boolean;
1081
1191
  /**
1082
- * Handler for permission requests from the server.
1083
- * When provided, the server will call this handler to request permission for operations.
1192
+ * Optional handler for permission requests from the server.
1193
+ * When omitted, permission requests are surfaced as events and left pending for
1194
+ * the consumer to resolve via the pending permission RPC.
1084
1195
  */
1085
- onPermissionRequest: PermissionHandler;
1196
+ onPermissionRequest?: PermissionHandler;
1086
1197
  /**
1087
1198
  * Handler for user input requests from the agent.
1088
1199
  * When provided, enables the ask_user tool allowing the agent to ask questions.
@@ -1098,12 +1209,12 @@ export interface SessionConfig {
1098
1209
  * Handler for exit-plan-mode requests from the agent.
1099
1210
  * When provided, enables `exitPlanMode.request` callbacks.
1100
1211
  */
1101
- onExitPlanMode?: ExitPlanModeHandler;
1212
+ onExitPlanModeRequest?: ExitPlanModeHandler;
1102
1213
  /**
1103
1214
  * Handler for auto-mode-switch requests from the agent.
1104
1215
  * When provided, enables `autoModeSwitch.request` callbacks.
1105
1216
  */
1106
- onAutoModeSwitch?: AutoModeSwitchHandler;
1217
+ onAutoModeSwitchRequest?: AutoModeSwitchHandler;
1107
1218
  /**
1108
1219
  * Hook handlers for intercepting session lifecycle events.
1109
1220
  * When provided, enables hooks callback allowing custom logic at various points.
@@ -1114,6 +1225,13 @@ export interface SessionConfig {
1114
1225
  * Tool operations will be relative to this directory.
1115
1226
  */
1116
1227
  workingDirectory?: string;
1228
+ /**
1229
+ * Enable streaming of assistant message and reasoning chunks.
1230
+ * When true, ephemeral assistant.message_delta and assistant.reasoning_delta
1231
+ * events are sent as the response is generated. Clients should accumulate
1232
+ * deltaContent values to build the full response.
1233
+ * @default false
1234
+ */
1117
1235
  streaming?: boolean;
1118
1236
  /**
1119
1237
  * Include sub-agent streaming events in the event stream. When true, streaming
@@ -1176,6 +1294,13 @@ export interface SessionConfig {
1176
1294
  * the identity used for content exclusion, model routing, and quota checks.
1177
1295
  */
1178
1296
  gitHubToken?: string;
1297
+ /**
1298
+ * Per-session remote behavior control:
1299
+ * - `"off"` — local only, no remote export (default)
1300
+ * - `"export"` — export session events to GitHub without enabling remote steering
1301
+ * - `"on"` — export to GitHub AND enable remote steering
1302
+ */
1303
+ remoteSession?: RemoteSessionMode;
1179
1304
  /**
1180
1305
  * Optional event handler that is registered on the session before the
1181
1306
  * session.create RPC is issued. This guarantees that early events emitted
@@ -1190,18 +1315,33 @@ export interface SessionConfig {
1190
1315
  * Supplies a handler for session filesystem operations. This takes effect
1191
1316
  * only if {@link CopilotClientOptions.sessionFs} is configured.
1192
1317
  */
1193
- createSessionFsHandler?: (session: CopilotSession) => SessionFsProvider;
1318
+ createSessionFsProvider?: (session: CopilotSession) => SessionFsProvider;
1194
1319
  }
1195
1320
  /**
1196
- * Configuration for resuming a session
1321
+ * Configuration for creating a new session via {@link CopilotClient.createSession}.
1197
1322
  */
1198
- export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "commands" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "enableSessionTelemetry" | "modelCapabilities" | "streaming" | "includeSubAgentStreamingEvents" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "onElicitationRequest" | "onExitPlanMode" | "onAutoModeSwitch" | "hooks" | "workingDirectory" | "configDir" | "enableConfigDiscovery" | "mcpServers" | "customAgents" | "defaultAgent" | "agent" | "skillDirectories" | "instructionDirectories" | "disabledSkills" | "infiniteSessions" | "gitHubToken" | "onEvent" | "createSessionFsHandler"> & {
1323
+ export interface SessionConfig extends SessionConfigBase {
1324
+ /**
1325
+ * Optional custom session ID. If not provided, the server generates one.
1326
+ */
1327
+ sessionId?: string;
1328
+ /**
1329
+ * Creates a remote session in the cloud instead of a local session.
1330
+ * The optional repository is associated with the cloud session.
1331
+ */
1332
+ cloud?: CloudSessionOptions;
1333
+ }
1334
+ /**
1335
+ * Configuration for resuming an existing session via
1336
+ * {@link CopilotClient.resumeSession}.
1337
+ */
1338
+ export interface ResumeSessionConfig extends SessionConfigBase {
1199
1339
  /**
1200
1340
  * When true, skips emitting the session.resume event.
1201
1341
  * Useful for reconnecting to a session without triggering resume-related side effects.
1202
1342
  * @default false
1203
1343
  */
1204
- disableResume?: boolean;
1344
+ suppressResumeEvent?: boolean;
1205
1345
  /**
1206
1346
  * When true, the runtime continues any tool calls or permission prompts that were
1207
1347
  * still pending when the session was last suspended. When false (the default), the
@@ -1214,7 +1354,7 @@ export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "
1214
1354
  * @default false
1215
1355
  */
1216
1356
  continuePendingWork?: boolean;
1217
- };
1357
+ }
1218
1358
  /**
1219
1359
  * Configuration for a custom API provider.
1220
1360
  */
@@ -1274,7 +1414,7 @@ export interface ProviderConfig {
1274
1414
  * prompt (system message, history, tool definitions, user message) would
1275
1415
  * exceed this limit.
1276
1416
  */
1277
- maxInputTokens?: number;
1417
+ maxPromptTokens?: number;
1278
1418
  /**
1279
1419
  * Overrides the resolved model's default max output tokens. When hit, the
1280
1420
  * model stops generating and returns a truncated response.
@@ -1359,7 +1499,7 @@ export type ConnectionState = "disconnected" | "connecting" | "connected" | "err
1359
1499
  */
1360
1500
  export interface SessionContext {
1361
1501
  /** Working directory where the session was created */
1362
- cwd: string;
1502
+ workingDirectory: string;
1363
1503
  /** Git repository root (if in a git repo) */
1364
1504
  gitRoot?: string;
1365
1505
  /** GitHub repository in "owner/repo" format */
@@ -1384,13 +1524,26 @@ export interface SessionFsConfig {
1384
1524
  * Path conventions used by this filesystem provider.
1385
1525
  */
1386
1526
  conventions: "windows" | "posix";
1527
+ /**
1528
+ * Optional capabilities declared by this provider.
1529
+ * The runtime uses these to determine which features are available.
1530
+ */
1531
+ capabilities?: {
1532
+ /**
1533
+ * Whether this provider supports SQLite query/exists operations.
1534
+ * When false or omitted, the runtime will not offer SQL tools or
1535
+ * todo tracking for sessions using this provider.
1536
+ * @default false
1537
+ */
1538
+ sqlite?: boolean;
1539
+ };
1387
1540
  }
1388
1541
  /**
1389
1542
  * Filter options for listing sessions
1390
1543
  */
1391
1544
  export interface SessionListFilter {
1392
- /** Filter by exact cwd match */
1393
- cwd?: string;
1545
+ /** Filter by exact working directory match */
1546
+ workingDirectory?: string;
1394
1547
  /** Filter by git root */
1395
1548
  gitRoot?: string;
1396
1549
  /** Filter by repository (owner/repo format) */
@@ -1407,7 +1560,7 @@ export interface SessionMetadata {
1407
1560
  modifiedTime: Date;
1408
1561
  summary?: string;
1409
1562
  isRemote: boolean;
1410
- /** Working directory context (cwd, git info) from session creation */
1563
+ /** Working directory context (working directory, git info) from session creation */
1411
1564
  context?: SessionContext;
1412
1565
  }
1413
1566
  /**
@@ -1492,35 +1645,68 @@ export interface ModelInfo {
1492
1645
  defaultReasoningEffort?: ReasoningEffort;
1493
1646
  }
1494
1647
  /**
1495
- * Types of session lifecycle events
1648
+ * Types of session lifecycle events.
1496
1649
  */
1497
1650
  export type SessionLifecycleEventType = "session.created" | "session.deleted" | "session.updated" | "session.foreground" | "session.background";
1498
1651
  /**
1499
- * Session lifecycle event notification
1500
- * Sent when sessions are created, deleted, updated, or change foreground/background state
1652
+ * Metadata payload for session lifecycle events. Not present on
1653
+ * `session.deleted` events.
1501
1654
  */
1502
- export interface SessionLifecycleEvent {
1503
- /** Type of lifecycle event */
1504
- type: SessionLifecycleEventType;
1505
- /** ID of the session this event relates to */
1655
+ export interface SessionLifecycleEventMetadata {
1656
+ /** Time the session was created. */
1657
+ startTime: Date;
1658
+ /** Time the session was last modified. */
1659
+ modifiedTime: Date;
1660
+ /** Human-readable summary of the session, if available. */
1661
+ summary?: string;
1662
+ }
1663
+ /** Base shape shared by every lifecycle event variant. */
1664
+ interface SessionLifecycleEventBase {
1665
+ /** ID of the session this event relates to. */
1506
1666
  sessionId: string;
1507
- /** Session metadata (not included for deleted sessions) */
1508
- metadata?: {
1509
- startTime: string;
1510
- modifiedTime: string;
1511
- summary?: string;
1512
- };
1667
+ /** Session metadata (not included for `session.deleted`). */
1668
+ metadata?: SessionLifecycleEventMetadata;
1669
+ }
1670
+ /** Emitted when a new session is created. */
1671
+ export interface SessionCreatedEvent extends SessionLifecycleEventBase {
1672
+ type: "session.created";
1673
+ metadata: SessionLifecycleEventMetadata;
1513
1674
  }
1675
+ /** Emitted when a session is deleted. The metadata field is omitted. */
1676
+ export interface SessionDeletedEvent extends SessionLifecycleEventBase {
1677
+ type: "session.deleted";
1678
+ metadata?: undefined;
1679
+ }
1680
+ /** Emitted when a session's metadata is updated. */
1681
+ export interface SessionUpdatedEvent extends SessionLifecycleEventBase {
1682
+ type: "session.updated";
1683
+ metadata: SessionLifecycleEventMetadata;
1684
+ }
1685
+ /** Emitted when a session is brought to the foreground (TUI+server mode). */
1686
+ export interface SessionForegroundEvent extends SessionLifecycleEventBase {
1687
+ type: "session.foreground";
1688
+ metadata: SessionLifecycleEventMetadata;
1689
+ }
1690
+ /** Emitted when a session is moved to the background (TUI+server mode). */
1691
+ export interface SessionBackgroundEvent extends SessionLifecycleEventBase {
1692
+ type: "session.background";
1693
+ metadata: SessionLifecycleEventMetadata;
1694
+ }
1695
+ /**
1696
+ * Discriminated union of all session lifecycle events emitted in TUI+server mode.
1697
+ * Switch on `type` to access the variant-specific metadata.
1698
+ */
1699
+ export type SessionLifecycleEvent = SessionCreatedEvent | SessionDeletedEvent | SessionUpdatedEvent | SessionForegroundEvent | SessionBackgroundEvent;
1514
1700
  /**
1515
- * Handler for session lifecycle events
1701
+ * Handler for session lifecycle events.
1516
1702
  */
1517
1703
  export type SessionLifecycleHandler = (event: SessionLifecycleEvent) => void;
1518
1704
  /**
1519
- * Typed handler for specific session lifecycle event types
1705
+ * Typed handler for specific session lifecycle event types.
1520
1706
  */
1521
- export type TypedSessionLifecycleHandler<K extends SessionLifecycleEventType> = (event: SessionLifecycleEvent & {
1707
+ export type TypedSessionLifecycleHandler<K extends SessionLifecycleEventType> = (event: Extract<SessionLifecycleEvent, {
1522
1708
  type: K;
1523
- }) => void;
1709
+ }>) => void;
1524
1710
  /**
1525
1711
  * Information about the foreground session in TUI+server mode
1526
1712
  */