@github/copilot-sdk 1.0.0-beta.1 → 1.0.0-beta.10
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 +52 -43
- package/dist/canvas.d.ts +126 -0
- package/dist/canvas.js +49 -0
- package/dist/cjs/canvas.js +75 -0
- package/dist/cjs/client.js +536 -299
- package/dist/cjs/extension.js +9 -2
- package/dist/cjs/generated/rpc.js +1319 -14
- package/dist/cjs/index.js +22 -7
- package/dist/cjs/session.js +179 -93
- package/dist/cjs/sessionFsProvider.js +34 -0
- package/dist/cjs/toolSet.js +107 -0
- package/dist/cjs/types.js +38 -4
- package/dist/client.d.ts +63 -73
- package/dist/client.js +537 -300
- package/dist/extension.d.ts +3 -1
- package/dist/extension.js +10 -2
- package/dist/generated/rpc.d.ts +10187 -1028
- package/dist/generated/rpc.js +1319 -14
- package/dist/generated/session-events.d.ts +1982 -195
- package/dist/index.d.ts +6 -2
- package/dist/index.js +15 -2
- package/dist/session.d.ts +18 -186
- package/dist/session.js +179 -92
- package/dist/sessionFsProvider.d.ts +29 -2
- package/dist/sessionFsProvider.js +34 -0
- package/dist/toolSet.d.ts +75 -0
- package/dist/toolSet.js +82 -0
- package/dist/types.d.ts +730 -123
- package/dist/types.js +36 -3
- package/docs/agent-author.md +31 -7
- package/docs/examples.md +23 -16
- package/package.json +3 -3
package/dist/types.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for the Copilot SDK
|
|
3
3
|
*/
|
|
4
|
+
import type { Canvas } from "./canvas.js";
|
|
4
5
|
import type { SessionFsProvider } from "./sessionFsProvider.js";
|
|
5
|
-
import type { SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
|
|
6
|
+
import type { ReasoningSummary, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
|
|
6
7
|
import type { CopilotSession } from "./session.js";
|
|
8
|
+
import type { RemoteSessionMode } from "./generated/rpc.js";
|
|
9
|
+
import type { OpenCanvasInstance } from "./generated/rpc.js";
|
|
10
|
+
import type { ToolSet } from "./toolSet.js";
|
|
11
|
+
export type { RemoteSessionMode } from "./generated/rpc.js";
|
|
7
12
|
export type SessionEvent = GeneratedSessionEvent;
|
|
13
|
+
export type { ReasoningSummary } from "./generated/session-events.js";
|
|
8
14
|
export type { SessionFsProvider } from "./sessionFsProvider.js";
|
|
9
15
|
export { createSessionFsAdapter } from "./sessionFsProvider.js";
|
|
10
16
|
export type { SessionFsFileInfo } from "./sessionFsProvider.js";
|
|
17
|
+
export type { SessionFsSqliteQueryResult } from "./sessionFsProvider.js";
|
|
18
|
+
export type { SessionFsSqliteQueryType } from "./sessionFsProvider.js";
|
|
19
|
+
export type { SessionFsSqliteProvider } from "./sessionFsProvider.js";
|
|
11
20
|
/**
|
|
12
21
|
* Options for creating a CopilotClient
|
|
13
22
|
*/
|
|
@@ -43,80 +52,146 @@ export interface TelemetryConfig {
|
|
|
43
52
|
/** Whether to capture message content (prompts, responses). Sets OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT. */
|
|
44
53
|
captureContent?: boolean;
|
|
45
54
|
}
|
|
46
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Configures how a {@link CopilotClient} connects to the Copilot runtime.
|
|
57
|
+
* Construct via the factory functions on {@link RuntimeConnection}.
|
|
58
|
+
*/
|
|
59
|
+
export type RuntimeConnection = StdioRuntimeConnection | TcpRuntimeConnection | UriRuntimeConnection;
|
|
60
|
+
/**
|
|
61
|
+
* Spawns a runtime child process and communicates over its stdin/stdout.
|
|
62
|
+
* This is the default if no {@link CopilotClientOptions.connection} is set.
|
|
63
|
+
*/
|
|
64
|
+
export interface StdioRuntimeConnection {
|
|
65
|
+
readonly kind: "stdio";
|
|
66
|
+
/** Path to the runtime executable. When omitted, the bundled runtime is used. */
|
|
67
|
+
readonly path?: string;
|
|
68
|
+
/** Extra command-line arguments to pass to the runtime process. */
|
|
69
|
+
readonly args?: readonly string[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Spawns a runtime child process that listens on a TCP socket and connects to it.
|
|
73
|
+
*/
|
|
74
|
+
export interface TcpRuntimeConnection {
|
|
75
|
+
readonly kind: "tcp";
|
|
47
76
|
/**
|
|
48
|
-
*
|
|
49
|
-
* If
|
|
77
|
+
* TCP port to listen on. `0` (the default) auto-allocates a free port.
|
|
78
|
+
* If the chosen port is already in use, startup fails.
|
|
50
79
|
*/
|
|
51
|
-
|
|
80
|
+
readonly port?: number;
|
|
52
81
|
/**
|
|
53
|
-
*
|
|
82
|
+
* Optional shared secret the SDK sends to the spawned runtime to authenticate
|
|
83
|
+
* the TCP connection. When omitted, a UUID is generated automatically so the
|
|
84
|
+
* loopback listener is safe by default.
|
|
54
85
|
*/
|
|
55
|
-
|
|
86
|
+
readonly connectionToken?: string;
|
|
87
|
+
/** Path to the runtime executable. When omitted, the bundled runtime is used. */
|
|
88
|
+
readonly path?: string;
|
|
89
|
+
/** Extra command-line arguments to pass to the runtime process. */
|
|
90
|
+
readonly args?: readonly string[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Connects to an already-running runtime at the specified URL. The SDK does not
|
|
94
|
+
* spawn a process in this mode.
|
|
95
|
+
*/
|
|
96
|
+
export interface UriRuntimeConnection {
|
|
97
|
+
readonly kind: "uri";
|
|
56
98
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
99
|
+
* URL of the runtime to connect to. Accepts `"port"`, `"host:port"`, or a
|
|
100
|
+
* full URL (`"http://host:port"`).
|
|
59
101
|
*/
|
|
60
|
-
|
|
102
|
+
readonly url: string;
|
|
103
|
+
/** Optional shared secret to authenticate the connection. */
|
|
104
|
+
readonly connectionToken?: string;
|
|
105
|
+
}
|
|
106
|
+
/** Factory functions for constructing {@link RuntimeConnection} instances. */
|
|
107
|
+
export declare const RuntimeConnection: {
|
|
61
108
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
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}.
|
|
109
|
+
* Spawn a runtime child process and communicate over its stdin/stdout.
|
|
110
|
+
* This is the default if no {@link CopilotClientOptions.connection} is set.
|
|
67
111
|
*/
|
|
68
|
-
|
|
112
|
+
readonly forStdio: (opts?: {
|
|
113
|
+
path?: string;
|
|
114
|
+
args?: readonly string[];
|
|
115
|
+
}) => StdioRuntimeConnection;
|
|
69
116
|
/**
|
|
70
|
-
*
|
|
71
|
-
* @default 0 (random available port)
|
|
117
|
+
* Spawn a runtime child process that listens on a TCP socket and connect to it.
|
|
72
118
|
*/
|
|
73
|
-
|
|
119
|
+
readonly forTcp: (opts?: {
|
|
120
|
+
port?: number;
|
|
121
|
+
connectionToken?: string;
|
|
122
|
+
path?: string;
|
|
123
|
+
args?: readonly string[];
|
|
124
|
+
}) => TcpRuntimeConnection;
|
|
74
125
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @default true
|
|
126
|
+
* Connect to an already-running runtime at the given URL. The SDK does not
|
|
127
|
+
* spawn a process in this mode.
|
|
78
128
|
*/
|
|
79
|
-
|
|
129
|
+
readonly forUri: (url: string, opts?: {
|
|
130
|
+
connectionToken?: string;
|
|
131
|
+
}) => UriRuntimeConnection;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Controls SDK defaults for ambient features.
|
|
135
|
+
*
|
|
136
|
+
* - `"copilot-cli"` (default): Defaults equivalent to Copilot CLI. Useful when
|
|
137
|
+
* building a coding agent that shares sessions with Copilot CLI. Do not use
|
|
138
|
+
* this mode for server-based multi-user applications — the default coding
|
|
139
|
+
* agent has tools and capabilities that operate across sessions and can
|
|
140
|
+
* access the host OS environment.
|
|
141
|
+
* - `"empty"`: Disables optional features by default. The app must explicitly
|
|
142
|
+
* opt into anything it needs. Required for any scenario where CLI-like
|
|
143
|
+
* ambient behavior is unsafe (e.g. multi-user servers).
|
|
144
|
+
*/
|
|
145
|
+
export type CopilotClientMode = "empty" | "copilot-cli";
|
|
146
|
+
export interface CopilotClientOptions {
|
|
80
147
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* with useStdio: true.
|
|
148
|
+
* How to connect to the Copilot runtime. When omitted, defaults to
|
|
149
|
+
* {@link RuntimeConnection.forStdio} with the bundled runtime.
|
|
84
150
|
*/
|
|
85
|
-
|
|
151
|
+
connection?: RuntimeConnection;
|
|
86
152
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
153
|
+
* Selects the SDK defaulting strategy. See {@link CopilotClientMode}.
|
|
154
|
+
*
|
|
155
|
+
* When set to `"empty"`, the SDK validates that the app has supplied the
|
|
156
|
+
* required configuration ({@link CopilotClientOptions.baseDirectory} or
|
|
157
|
+
* {@link CopilotClientOptions.sessionFs}, plus
|
|
158
|
+
* {@link SessionConfigBase.availableTools} on each session) and translates
|
|
159
|
+
* session creation requests into runtime options that flip tool filter
|
|
160
|
+
* precedence to deny-wins so exclusions are expressible.
|
|
161
|
+
*
|
|
162
|
+
* @default "copilot-cli"
|
|
92
163
|
*/
|
|
93
|
-
|
|
164
|
+
mode?: CopilotClientMode;
|
|
94
165
|
/**
|
|
95
|
-
*
|
|
166
|
+
* Working directory for the runtime process.
|
|
167
|
+
* If not set, inherits the current process's working directory.
|
|
96
168
|
*/
|
|
97
|
-
|
|
169
|
+
workingDirectory?: string;
|
|
98
170
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
171
|
+
* Base directory for Copilot data (session state, config, etc.).
|
|
172
|
+
* Sets the COPILOT_HOME environment variable on the spawned runtime.
|
|
173
|
+
* When not set, the runtime defaults to ~/.copilot.
|
|
174
|
+
* Ignored when connecting to an existing runtime via {@link RuntimeConnection.forUri}.
|
|
101
175
|
*/
|
|
102
|
-
|
|
176
|
+
baseDirectory?: string;
|
|
103
177
|
/**
|
|
104
|
-
*
|
|
178
|
+
* Log level for the Copilot runtime. When omitted, the runtime uses its
|
|
179
|
+
* own default (currently `"info"`).
|
|
105
180
|
*/
|
|
106
|
-
|
|
181
|
+
logLevel?: "none" | "error" | "warning" | "info" | "debug" | "all";
|
|
107
182
|
/**
|
|
108
|
-
* Environment variables to pass to the
|
|
183
|
+
* Environment variables to pass to the runtime process. If not set, inherits process.env.
|
|
109
184
|
*/
|
|
110
185
|
env?: Record<string, string | undefined>;
|
|
111
186
|
/**
|
|
112
187
|
* GitHub token to use for authentication.
|
|
113
|
-
* When provided, the token is passed to the
|
|
188
|
+
* When provided, the token is passed to the runtime via environment variable.
|
|
114
189
|
* This takes priority over other authentication methods.
|
|
115
190
|
*/
|
|
116
191
|
gitHubToken?: string;
|
|
117
192
|
/**
|
|
118
193
|
* Whether to use the logged-in user for authentication.
|
|
119
|
-
* When true, the
|
|
194
|
+
* When true, the runtime will attempt to use stored OAuth tokens or gh CLI auth.
|
|
120
195
|
* When false, only explicit tokens (gitHubToken or environment variables) are used.
|
|
121
196
|
* @default true (but defaults to false when gitHubToken is provided)
|
|
122
197
|
*/
|
|
@@ -124,14 +199,14 @@ export interface CopilotClientOptions {
|
|
|
124
199
|
/**
|
|
125
200
|
* Custom handler for listing available models.
|
|
126
201
|
* When provided, client.listModels() calls this handler instead of
|
|
127
|
-
* querying the
|
|
202
|
+
* querying the runtime. Useful in BYOK mode to return models
|
|
128
203
|
* available from your custom provider.
|
|
129
204
|
*/
|
|
130
205
|
onListModels?: () => Promise<ModelInfo[]> | ModelInfo[];
|
|
131
206
|
/**
|
|
132
|
-
* OpenTelemetry configuration for the
|
|
207
|
+
* OpenTelemetry configuration for the runtime process.
|
|
133
208
|
* When provided, the corresponding OTel environment variables are set
|
|
134
|
-
* on the spawned
|
|
209
|
+
* on the spawned runtime.
|
|
135
210
|
*/
|
|
136
211
|
telemetry?: TelemetryConfig;
|
|
137
212
|
/**
|
|
@@ -170,18 +245,18 @@ export interface CopilotClientOptions {
|
|
|
170
245
|
* Server-wide idle timeout for sessions in seconds.
|
|
171
246
|
* Sessions without activity for this duration are automatically cleaned up.
|
|
172
247
|
* Set to 0 or omit to disable (sessions live indefinitely).
|
|
173
|
-
*
|
|
174
|
-
* when connecting to an external server via {@link cliUrl}.
|
|
248
|
+
* Ignored when connecting to an existing runtime via {@link RuntimeConnection.forUri}.
|
|
175
249
|
* @default undefined (disabled)
|
|
176
250
|
*/
|
|
177
251
|
sessionIdleTimeoutSeconds?: number;
|
|
178
252
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
253
|
+
* Enable remote session support (Mission Control integration).
|
|
254
|
+
* When true, sessions in a GitHub repository working directory are
|
|
255
|
+
* accessible from GitHub web and mobile.
|
|
256
|
+
* Ignored when connecting to an existing runtime via {@link RuntimeConnection.forUri}.
|
|
257
|
+
* @default false
|
|
183
258
|
*/
|
|
184
|
-
|
|
259
|
+
enableRemoteSessions?: boolean;
|
|
185
260
|
}
|
|
186
261
|
/**
|
|
187
262
|
* Configuration for creating a session
|
|
@@ -190,18 +265,33 @@ export type ToolResultType = "success" | "failure" | "rejected" | "denied" | "ti
|
|
|
190
265
|
export type ToolBinaryResult = {
|
|
191
266
|
data: string;
|
|
192
267
|
mimeType: string;
|
|
193
|
-
type:
|
|
268
|
+
type: "image" | "resource";
|
|
194
269
|
description?: string;
|
|
195
270
|
};
|
|
271
|
+
export type ToolTelemetry = Record<string, Record<string, unknown> | undefined>;
|
|
196
272
|
export type ToolResultObject = {
|
|
197
273
|
textResultForLlm: string;
|
|
198
274
|
binaryResultsForLlm?: ToolBinaryResult[];
|
|
199
275
|
resultType: ToolResultType;
|
|
200
276
|
error?: string;
|
|
201
277
|
sessionLog?: string;
|
|
202
|
-
toolTelemetry?:
|
|
278
|
+
toolTelemetry?: ToolTelemetry;
|
|
203
279
|
};
|
|
204
280
|
export type ToolResult = string | ToolResultObject;
|
|
281
|
+
/**
|
|
282
|
+
* GitHub repository metadata to associate with a cloud session.
|
|
283
|
+
*/
|
|
284
|
+
export interface CloudSessionRepository {
|
|
285
|
+
owner: string;
|
|
286
|
+
name: string;
|
|
287
|
+
branch?: string;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Options for creating a remote session in the cloud.
|
|
291
|
+
*/
|
|
292
|
+
export interface CloudSessionOptions {
|
|
293
|
+
repository?: CloudSessionRepository;
|
|
294
|
+
}
|
|
205
295
|
/**
|
|
206
296
|
* Content block types within an MCP CallToolResult.
|
|
207
297
|
*/
|
|
@@ -260,12 +350,16 @@ export interface ZodSchema<T = unknown> {
|
|
|
260
350
|
* - A Zod schema (provides type inference for handler)
|
|
261
351
|
* - A raw JSON schema object
|
|
262
352
|
* - Omitted (no parameters)
|
|
353
|
+
*
|
|
354
|
+
* If `handler` is omitted, the SDK exposes the declaration but does not
|
|
355
|
+
* automatically invoke the tool. Consumers can resolve tool calls by observing
|
|
356
|
+
* external tool request events and calling the pending-tool RPC.
|
|
263
357
|
*/
|
|
264
358
|
export interface Tool<TArgs = unknown> {
|
|
265
359
|
name: string;
|
|
266
360
|
description?: string;
|
|
267
361
|
parameters?: ZodSchema<TArgs> | Record<string, unknown>;
|
|
268
|
-
handler
|
|
362
|
+
handler?: ToolHandler<TArgs>;
|
|
269
363
|
/**
|
|
270
364
|
* When true, explicitly indicates this tool is intended to override a built-in tool
|
|
271
365
|
* of the same name. If not set and the name clashes with a built-in tool, the runtime
|
|
@@ -284,7 +378,7 @@ export interface Tool<TArgs = unknown> {
|
|
|
284
378
|
export declare function defineTool<T = unknown>(name: string, config: {
|
|
285
379
|
description?: string;
|
|
286
380
|
parameters?: ZodSchema<T> | Record<string, unknown>;
|
|
287
|
-
handler
|
|
381
|
+
handler?: ToolHandler<T>;
|
|
288
382
|
overridesBuiltInTool?: boolean;
|
|
289
383
|
skipPermission?: boolean;
|
|
290
384
|
}): Tool<T>;
|
|
@@ -325,6 +419,19 @@ export interface SessionCapabilities {
|
|
|
325
419
|
ui?: {
|
|
326
420
|
/** Whether the host supports interactive elicitation dialogs. */
|
|
327
421
|
elicitation?: boolean;
|
|
422
|
+
/**
|
|
423
|
+
* Whether the runtime has accepted the session's MCP Apps (SEP-1865)
|
|
424
|
+
* opt-in. `true` when the consumer set `enableMcpApps: true` on
|
|
425
|
+
* create/resume **and** the runtime's `MCP_APPS` feature flag (or
|
|
426
|
+
* `COPILOT_MCP_APPS=true` env override) is on. Otherwise absent or
|
|
427
|
+
* `false`, indicating the runtime silently dropped the opt-in.
|
|
428
|
+
*
|
|
429
|
+
* @experimental This property is part of an experimental wire-protocol surface
|
|
430
|
+
* (SEP-1865) and may change or be removed in a future release.
|
|
431
|
+
*/
|
|
432
|
+
mcpApps?: boolean;
|
|
433
|
+
/** Whether the host supports canvas rendering. */
|
|
434
|
+
canvases?: boolean;
|
|
328
435
|
};
|
|
329
436
|
}
|
|
330
437
|
/**
|
|
@@ -449,7 +556,7 @@ export type ElicitationHandler = (context: ElicitationContext) => Promise<Elicit
|
|
|
449
556
|
/**
|
|
450
557
|
* Options for the `input()` convenience method.
|
|
451
558
|
*/
|
|
452
|
-
export interface
|
|
559
|
+
export interface UiInputOptions {
|
|
453
560
|
/** Title label for the input field. */
|
|
454
561
|
title?: string;
|
|
455
562
|
/** Descriptive text shown below the field. */
|
|
@@ -490,7 +597,7 @@ export interface SessionUiApi {
|
|
|
490
597
|
* Returns the entered text, or `null` if the user declines/cancels.
|
|
491
598
|
* @throws Error if the host does not support elicitation.
|
|
492
599
|
*/
|
|
493
|
-
input(message: string, options?:
|
|
600
|
+
input(message: string, options?: UiInputOptions): Promise<string | null>;
|
|
494
601
|
}
|
|
495
602
|
export interface ToolCallRequestPayload {
|
|
496
603
|
sessionId: string;
|
|
@@ -502,12 +609,12 @@ export interface ToolCallResponsePayload {
|
|
|
502
609
|
result: ToolResult;
|
|
503
610
|
}
|
|
504
611
|
/**
|
|
505
|
-
* Known system
|
|
612
|
+
* Known system message section identifiers for the "customize" mode.
|
|
506
613
|
* Each section corresponds to a distinct part of the system prompt.
|
|
507
614
|
*/
|
|
508
|
-
export type
|
|
615
|
+
export type SystemMessageSection = "identity" | "tone" | "tool_efficiency" | "environment_context" | "code_change_rules" | "guidelines" | "safety" | "tool_instructions" | "custom_instructions" | "runtime_instructions" | "last_instructions";
|
|
509
616
|
/** Section metadata for documentation and tooling. */
|
|
510
|
-
export declare const
|
|
617
|
+
export declare const SYSTEM_MESSAGE_SECTIONS: Record<SystemMessageSection, {
|
|
511
618
|
description: string;
|
|
512
619
|
}>;
|
|
513
620
|
/**
|
|
@@ -525,7 +632,7 @@ export type SectionTransformFn = (currentContent: string) => string | Promise<st
|
|
|
525
632
|
*/
|
|
526
633
|
export type SectionOverrideAction = "replace" | "remove" | "append" | "prepend" | SectionTransformFn;
|
|
527
634
|
/**
|
|
528
|
-
* Override operation for a single system
|
|
635
|
+
* Override operation for a single system message section.
|
|
529
636
|
*/
|
|
530
637
|
export interface SectionOverride {
|
|
531
638
|
/**
|
|
@@ -574,7 +681,7 @@ export interface SystemMessageCustomizeConfig {
|
|
|
574
681
|
* Unknown section IDs gracefully fall back: content-bearing overrides are appended
|
|
575
682
|
* to additional instructions, and "remove" on unknown sections is a silent no-op.
|
|
576
683
|
*/
|
|
577
|
-
sections?: Partial<Record<
|
|
684
|
+
sections?: Partial<Record<SystemMessageSection, SectionOverride>>;
|
|
578
685
|
/**
|
|
579
686
|
* Additional content appended after all sections.
|
|
580
687
|
* Equivalent to append mode's content field — provided for convenience.
|
|
@@ -589,13 +696,20 @@ export interface SystemMessageCustomizeConfig {
|
|
|
589
696
|
*/
|
|
590
697
|
export type SystemMessageConfig = SystemMessageAppendConfig | SystemMessageReplaceConfig | SystemMessageCustomizeConfig;
|
|
591
698
|
/**
|
|
592
|
-
* Permission request types from the server
|
|
699
|
+
* Permission request types from the server. This is the generated
|
|
700
|
+
* discriminated union from the runtime schema — switch on `kind` to
|
|
701
|
+
* access the variant-specific fields (e.g. shell `commands`, write
|
|
702
|
+
* `fileName`/`diff`, mcp `toolName`/`args`).
|
|
593
703
|
*/
|
|
594
|
-
export
|
|
595
|
-
|
|
596
|
-
toolCallId?: string;
|
|
597
|
-
}
|
|
704
|
+
export type { PermissionRequest } from "./generated/session-events.js";
|
|
705
|
+
import type { PermissionRequest } from "./generated/session-events.js";
|
|
598
706
|
import type { PermissionDecisionRequest } from "./generated/rpc.js";
|
|
707
|
+
/**
|
|
708
|
+
* Permission decision result returned from a {@link PermissionHandler}.
|
|
709
|
+
* The discriminated `kind` field selects the decision. Variant-specific
|
|
710
|
+
* fields (e.g. `feedback` on `{ kind: "reject" }`) come from the generated
|
|
711
|
+
* `PermissionDecisionRequest["result"]` union.
|
|
712
|
+
*/
|
|
599
713
|
export type PermissionRequestResult = PermissionDecisionRequest["result"] | {
|
|
600
714
|
kind: "no-result";
|
|
601
715
|
};
|
|
@@ -641,12 +755,65 @@ export interface UserInputResponse {
|
|
|
641
755
|
export type UserInputHandler = (request: UserInputRequest, invocation: {
|
|
642
756
|
sessionId: string;
|
|
643
757
|
}) => Promise<UserInputResponse> | UserInputResponse;
|
|
758
|
+
/**
|
|
759
|
+
* Request to exit plan mode and continue with a selected action.
|
|
760
|
+
*/
|
|
761
|
+
export interface ExitPlanModeRequest {
|
|
762
|
+
/** Summary of the plan or proposed next step. */
|
|
763
|
+
summary: string;
|
|
764
|
+
/** Full plan content, when available. */
|
|
765
|
+
planContent?: string;
|
|
766
|
+
/** Available actions the user can select. */
|
|
767
|
+
actions: string[];
|
|
768
|
+
/** The action recommended by the runtime. */
|
|
769
|
+
recommendedAction: string;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Response to an exit-plan-mode request.
|
|
773
|
+
*/
|
|
774
|
+
export interface ExitPlanModeResult {
|
|
775
|
+
/** Whether the user approved exiting plan mode. */
|
|
776
|
+
approved: boolean;
|
|
777
|
+
/** Selected action, if the user chose one. */
|
|
778
|
+
selectedAction?: string;
|
|
779
|
+
/** Optional feedback provided by the user. */
|
|
780
|
+
feedback?: string;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Handler for exit-plan-mode requests from the agent.
|
|
784
|
+
*/
|
|
785
|
+
export type ExitPlanModeHandler = (request: ExitPlanModeRequest, invocation: {
|
|
786
|
+
sessionId: string;
|
|
787
|
+
}) => Promise<ExitPlanModeResult> | ExitPlanModeResult;
|
|
788
|
+
/**
|
|
789
|
+
* Request to switch to auto mode after an eligible rate limit.
|
|
790
|
+
*/
|
|
791
|
+
export interface AutoModeSwitchRequest {
|
|
792
|
+
/** The rate-limit error code that triggered the request. */
|
|
793
|
+
errorCode?: string;
|
|
794
|
+
/** Seconds until the rate limit resets, when known. */
|
|
795
|
+
retryAfterSeconds?: number;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Response to an auto-mode-switch request.
|
|
799
|
+
*/
|
|
800
|
+
export type AutoModeSwitchResponse = "yes" | "yes_always" | "no";
|
|
801
|
+
/**
|
|
802
|
+
* Handler for auto-mode-switch requests from the agent.
|
|
803
|
+
*/
|
|
804
|
+
export type AutoModeSwitchHandler = (request: AutoModeSwitchRequest, invocation: {
|
|
805
|
+
sessionId: string;
|
|
806
|
+
}) => Promise<AutoModeSwitchResponse> | AutoModeSwitchResponse;
|
|
644
807
|
/**
|
|
645
808
|
* Base interface for all hook inputs
|
|
646
809
|
*/
|
|
647
810
|
export interface BaseHookInput {
|
|
648
|
-
|
|
649
|
-
|
|
811
|
+
/** The runtime session ID of the session that triggered the hook.
|
|
812
|
+
* For sub-agent hooks this differs from `invocation.sessionId`. */
|
|
813
|
+
sessionId: string;
|
|
814
|
+
/** Time at which the hook event was emitted by the runtime. */
|
|
815
|
+
timestamp: Date;
|
|
816
|
+
workingDirectory: string;
|
|
650
817
|
}
|
|
651
818
|
/**
|
|
652
819
|
* Input for pre-tool-use hook
|
|
@@ -671,6 +838,34 @@ export interface PreToolUseHookOutput {
|
|
|
671
838
|
export type PreToolUseHandler = (input: PreToolUseHookInput, invocation: {
|
|
672
839
|
sessionId: string;
|
|
673
840
|
}) => Promise<PreToolUseHookOutput | void> | PreToolUseHookOutput | void;
|
|
841
|
+
/**
|
|
842
|
+
* Input for pre-MCP-tool-call hook
|
|
843
|
+
*/
|
|
844
|
+
export interface PreMcpToolCallHookInput extends BaseHookInput {
|
|
845
|
+
toolCallId?: string;
|
|
846
|
+
serverName: string;
|
|
847
|
+
toolName: string;
|
|
848
|
+
arguments: unknown;
|
|
849
|
+
_meta?: Record<string, unknown>;
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Output for pre-MCP-tool-call hook
|
|
853
|
+
*/
|
|
854
|
+
export interface PreMcpToolCallHookOutput {
|
|
855
|
+
/**
|
|
856
|
+
* Hook-controlled metadata to use for the outgoing MCP request.
|
|
857
|
+
* - undefined/absent: preserve the current request `_meta`
|
|
858
|
+
* - object: use this object as request `_meta`
|
|
859
|
+
* - null: omit `_meta`
|
|
860
|
+
*/
|
|
861
|
+
metaToUse?: Record<string, unknown> | null;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Handler for pre-MCP-tool-call hook
|
|
865
|
+
*/
|
|
866
|
+
export type PreMcpToolCallHandler = (input: PreMcpToolCallHookInput, invocation: {
|
|
867
|
+
sessionId: string;
|
|
868
|
+
}) => Promise<PreMcpToolCallHookOutput | void> | PreMcpToolCallHookOutput | void;
|
|
674
869
|
/**
|
|
675
870
|
* Input for post-tool-use hook
|
|
676
871
|
*/
|
|
@@ -693,6 +888,47 @@ export interface PostToolUseHookOutput {
|
|
|
693
888
|
export type PostToolUseHandler = (input: PostToolUseHookInput, invocation: {
|
|
694
889
|
sessionId: string;
|
|
695
890
|
}) => Promise<PostToolUseHookOutput | void> | PostToolUseHookOutput | void;
|
|
891
|
+
/**
|
|
892
|
+
* Input for post-tool-use-failure hook.
|
|
893
|
+
*
|
|
894
|
+
* Dispatched after a tool execution whose `resultType` is `"failure"`.
|
|
895
|
+
* The input differs from {@link PostToolUseHookInput}: the host CLI does not
|
|
896
|
+
* forward the full `ToolResultObject` to failure hooks — only `error`, the
|
|
897
|
+
* stringified failure message extracted from the tool's result, is provided.
|
|
898
|
+
*/
|
|
899
|
+
export interface PostToolUseFailureHookInput extends BaseHookInput {
|
|
900
|
+
toolName: string;
|
|
901
|
+
toolArgs: unknown;
|
|
902
|
+
/**
|
|
903
|
+
* Failure message from the tool's result (the `error` field of the
|
|
904
|
+
* underlying `ToolResultObject`, falling back to its text/log fields).
|
|
905
|
+
*/
|
|
906
|
+
error: string;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Output for post-tool-use-failure hook.
|
|
910
|
+
*
|
|
911
|
+
* Only `additionalContext` is consumed by the host CLI — it is appended as
|
|
912
|
+
* hidden guidance to the model alongside the failed tool result. Other fields
|
|
913
|
+
* such as `modifiedResult` or `suppressOutput` are not honored for failure
|
|
914
|
+
* hooks (see {@link PostToolUseHookOutput} for the success-only hook).
|
|
915
|
+
*/
|
|
916
|
+
export interface PostToolUseFailureHookOutput {
|
|
917
|
+
additionalContext?: string;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Handler for post-tool-use-failure hook.
|
|
921
|
+
*
|
|
922
|
+
* Fires after a tool execution whose result was `"failure"`. `onPostToolUse`
|
|
923
|
+
* only fires for successful results, so register this handler to observe or
|
|
924
|
+
* react to failed tool outcomes.
|
|
925
|
+
*
|
|
926
|
+
* Note: `"rejected"`, `"denied"`, and `"timeout"` results do not currently
|
|
927
|
+
* trigger this hook either — only `"failure"` does.
|
|
928
|
+
*/
|
|
929
|
+
export type PostToolUseFailureHandler = (input: PostToolUseFailureHookInput, invocation: {
|
|
930
|
+
sessionId: string;
|
|
931
|
+
}) => Promise<PostToolUseFailureHookOutput | void> | PostToolUseFailureHookOutput | void;
|
|
696
932
|
/**
|
|
697
933
|
* Input for user-prompt-submitted hook
|
|
698
934
|
*/
|
|
@@ -787,9 +1023,24 @@ export interface SessionHooks {
|
|
|
787
1023
|
*/
|
|
788
1024
|
onPreToolUse?: PreToolUseHandler;
|
|
789
1025
|
/**
|
|
790
|
-
* Called
|
|
1026
|
+
* Called before an MCP tool is called
|
|
1027
|
+
*/
|
|
1028
|
+
onPreMcpToolCall?: PreMcpToolCallHandler;
|
|
1029
|
+
/**
|
|
1030
|
+
* Called after a tool is executed with a successful result.
|
|
1031
|
+
*
|
|
1032
|
+
* For failed tool executions, register {@link onPostToolUseFailure} instead;
|
|
1033
|
+
* this handler does not fire for non-success results.
|
|
791
1034
|
*/
|
|
792
1035
|
onPostToolUse?: PostToolUseHandler;
|
|
1036
|
+
/**
|
|
1037
|
+
* Called after a tool execution whose result was `"failure"`.
|
|
1038
|
+
*
|
|
1039
|
+
* Register this handler alongside {@link onPostToolUse} to observe failed
|
|
1040
|
+
* tool calls — `onPostToolUse` only fires for successful results, so
|
|
1041
|
+
* without this hook failed tool calls are invisible to extensions.
|
|
1042
|
+
*/
|
|
1043
|
+
onPostToolUseFailure?: PostToolUseFailureHandler;
|
|
793
1044
|
/**
|
|
794
1045
|
* Called when the user submits a prompt
|
|
795
1046
|
*/
|
|
@@ -812,9 +1063,11 @@ export interface SessionHooks {
|
|
|
812
1063
|
*/
|
|
813
1064
|
interface MCPServerConfigBase {
|
|
814
1065
|
/**
|
|
815
|
-
* List of tools to include from this server.
|
|
1066
|
+
* List of tools to include from this server.
|
|
1067
|
+
* `undefined` (the default) or `["*"]` means include all tools.
|
|
1068
|
+
* `[]` means include none.
|
|
816
1069
|
*/
|
|
817
|
-
tools
|
|
1070
|
+
tools?: string[];
|
|
818
1071
|
/**
|
|
819
1072
|
* Indicates the server type: "stdio" for local/subprocess servers, "http"/"sse" for remote servers.
|
|
820
1073
|
* If not specified, defaults to "stdio".
|
|
@@ -831,12 +1084,15 @@ interface MCPServerConfigBase {
|
|
|
831
1084
|
export interface MCPStdioServerConfig extends MCPServerConfigBase {
|
|
832
1085
|
type?: "local" | "stdio";
|
|
833
1086
|
command: string;
|
|
834
|
-
args
|
|
1087
|
+
args?: string[];
|
|
835
1088
|
/**
|
|
836
1089
|
* Environment variables to pass to the server.
|
|
837
1090
|
*/
|
|
838
1091
|
env?: Record<string, string>;
|
|
839
|
-
|
|
1092
|
+
/**
|
|
1093
|
+
* Working directory for the server process.
|
|
1094
|
+
*/
|
|
1095
|
+
workingDirectory?: string;
|
|
840
1096
|
}
|
|
841
1097
|
/**
|
|
842
1098
|
* Configuration for a remote MCP server (HTTP or SSE).
|
|
@@ -898,6 +1154,12 @@ export interface CustomAgentConfig {
|
|
|
898
1154
|
* When omitted, no skills are injected (opt-in model).
|
|
899
1155
|
*/
|
|
900
1156
|
skills?: string[];
|
|
1157
|
+
/**
|
|
1158
|
+
* Model identifier for this agent (e.g. "claude-haiku-4.5").
|
|
1159
|
+
* When set, the runtime will attempt to use this model for the agent,
|
|
1160
|
+
* falling back to the parent session model if unavailable.
|
|
1161
|
+
*/
|
|
1162
|
+
model?: string;
|
|
901
1163
|
}
|
|
902
1164
|
/**
|
|
903
1165
|
* Configuration for the default agent (the built-in agent that handles
|
|
@@ -938,15 +1200,47 @@ export interface InfiniteSessionConfig {
|
|
|
938
1200
|
bufferExhaustionThreshold?: number;
|
|
939
1201
|
}
|
|
940
1202
|
/**
|
|
941
|
-
*
|
|
1203
|
+
* Configuration for handling large tool outputs.
|
|
1204
|
+
*
|
|
1205
|
+
* When a tool produces output exceeding the configured size, the output is
|
|
1206
|
+
* written to a temp file and a reference is returned to the model instead of
|
|
1207
|
+
* the full payload.
|
|
942
1208
|
*/
|
|
943
|
-
export
|
|
944
|
-
export interface SessionConfig {
|
|
1209
|
+
export interface LargeToolOutputConfig {
|
|
945
1210
|
/**
|
|
946
|
-
*
|
|
947
|
-
*
|
|
1211
|
+
* Whether large output handling is enabled.
|
|
1212
|
+
* @default true
|
|
948
1213
|
*/
|
|
949
|
-
|
|
1214
|
+
enabled?: boolean;
|
|
1215
|
+
/**
|
|
1216
|
+
* Maximum size in bytes before output is written to a temp file.
|
|
1217
|
+
* @default 51200
|
|
1218
|
+
*/
|
|
1219
|
+
maxSizeBytes?: number;
|
|
1220
|
+
/**
|
|
1221
|
+
* Directory to write temp files to. Defaults to the OS temp directory.
|
|
1222
|
+
*/
|
|
1223
|
+
outputDirectory?: string;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Valid reasoning effort levels for models that support it.
|
|
1227
|
+
*/
|
|
1228
|
+
export type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
|
|
1229
|
+
/**
|
|
1230
|
+
* Stable extension identity for session participants that provide canvases.
|
|
1231
|
+
*/
|
|
1232
|
+
export interface ExtensionInfo {
|
|
1233
|
+
/** Extension namespace/source, e.g. "github-app". */
|
|
1234
|
+
source: string;
|
|
1235
|
+
/** Stable provider name within the source namespace. */
|
|
1236
|
+
name: string;
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Shared configuration fields used by both {@link SessionConfig} (for
|
|
1240
|
+
* creating a new session) and {@link ResumeSessionConfig} (for resuming
|
|
1241
|
+
* an existing one).
|
|
1242
|
+
*/
|
|
1243
|
+
export interface SessionConfigBase {
|
|
950
1244
|
/**
|
|
951
1245
|
* Client name to identify the application using the SDK.
|
|
952
1246
|
* Included in the User-Agent header for API requests.
|
|
@@ -962,13 +1256,25 @@ export interface SessionConfig {
|
|
|
962
1256
|
* Use client.listModels() to check supported values for each model.
|
|
963
1257
|
*/
|
|
964
1258
|
reasoningEffort?: ReasoningEffort;
|
|
1259
|
+
/**
|
|
1260
|
+
* Reasoning summary mode for models that support configurable reasoning summaries.
|
|
1261
|
+
* Use "none" to suppress summary output regardless of whether reasoning is enabled.
|
|
1262
|
+
*/
|
|
1263
|
+
reasoningSummary?: ReasoningSummary;
|
|
965
1264
|
/** Per-property overrides for model capabilities, deep-merged over runtime defaults. */
|
|
966
1265
|
modelCapabilities?: ModelCapabilitiesOverride;
|
|
1266
|
+
/**
|
|
1267
|
+
* Configuration for handling large tool outputs. When a tool produces
|
|
1268
|
+
* output exceeding the configured size, the output is written to a temp
|
|
1269
|
+
* file and a reference is returned to the model instead of the full
|
|
1270
|
+
* payload.
|
|
1271
|
+
*/
|
|
1272
|
+
largeOutput?: LargeToolOutputConfig;
|
|
967
1273
|
/**
|
|
968
1274
|
* Override the default configuration directory location.
|
|
969
1275
|
* When specified, the session will use this directory for storing config and state.
|
|
970
1276
|
*/
|
|
971
|
-
|
|
1277
|
+
configDirectory?: string;
|
|
972
1278
|
/**
|
|
973
1279
|
* When true, automatically discovers MCP server configurations (e.g. `.mcp.json`,
|
|
974
1280
|
* `.vscode/mcp.json`) and skill directories from the working directory and merges
|
|
@@ -982,9 +1288,38 @@ export interface SessionConfig {
|
|
|
982
1288
|
*/
|
|
983
1289
|
enableConfigDiscovery?: boolean;
|
|
984
1290
|
/**
|
|
985
|
-
* Tools exposed to the CLI server
|
|
1291
|
+
* Tools exposed to the CLI server. Tools without a handler are declaration-only
|
|
1292
|
+
* and must be resolved by the consumer via pending external tool request RPCs.
|
|
986
1293
|
*/
|
|
987
1294
|
tools?: Tool<any>[];
|
|
1295
|
+
/**
|
|
1296
|
+
* Canvases contributed by this session participant. The declaring
|
|
1297
|
+
* connection becomes the live provider for `canvas.open|focus|close|reload`
|
|
1298
|
+
* and `canvas.action.invoke` dispatches targeting each canvas's `id` for
|
|
1299
|
+
* the lifetime of the connection. Re-declaring the same id on resume
|
|
1300
|
+
* replaces the prior declaration.
|
|
1301
|
+
*/
|
|
1302
|
+
canvases?: Canvas[];
|
|
1303
|
+
/**
|
|
1304
|
+
* Renderer-side opt-in: when true, the runtime surfaces canvas agent tools
|
|
1305
|
+
* (`list_canvas_capabilities`, `open_canvas`, `invoke_canvas_action`) to
|
|
1306
|
+
* the model for this connection. Default off so SDK callers that cannot
|
|
1307
|
+
* display canvases stay clean.
|
|
1308
|
+
*/
|
|
1309
|
+
requestCanvasRenderer?: boolean;
|
|
1310
|
+
/**
|
|
1311
|
+
* Extension surface opt-in: when true, the runtime wires extension
|
|
1312
|
+
* management tools and per-extension tool dispatch onto the session for
|
|
1313
|
+
* this connection. Default off so callers that do not expose extensions
|
|
1314
|
+
* stay clean.
|
|
1315
|
+
*/
|
|
1316
|
+
requestExtensions?: boolean;
|
|
1317
|
+
/**
|
|
1318
|
+
* Stable extension identity for canvas providers on this connection. When
|
|
1319
|
+
* set, the runtime uses `${source}:${name}` as the agent-facing extension
|
|
1320
|
+
* id instead of a reconnect-specific connection id.
|
|
1321
|
+
*/
|
|
1322
|
+
extensionInfo?: ExtensionInfo;
|
|
988
1323
|
/**
|
|
989
1324
|
* Slash commands registered for this session.
|
|
990
1325
|
* When the CLI has a TUI, each command appears as `/name` for the user to invoke.
|
|
@@ -998,24 +1333,78 @@ export interface SessionConfig {
|
|
|
998
1333
|
systemMessage?: SystemMessageConfig;
|
|
999
1334
|
/**
|
|
1000
1335
|
* List of tool names to allow. When specified, only these tools will be available.
|
|
1001
|
-
*
|
|
1336
|
+
*
|
|
1337
|
+
* Supports source-qualified filter patterns (`builtin:*`, `builtin:<name>`,
|
|
1338
|
+
* `mcp:*`, `mcp:<name>`, `custom:*`, `custom:<name>`) as well as the bare
|
|
1339
|
+
* name form (exact match across any source). Build this list with
|
|
1340
|
+
* {@link ToolSet} for type safety and readable intent.
|
|
1341
|
+
*
|
|
1342
|
+
* Composes with {@link excludedTools}: a tool is enabled when it matches
|
|
1343
|
+
* `availableTools` (or `availableTools` is unset) AND it does not match
|
|
1344
|
+
* `excludedTools`. This lets you express "everything matching X except Y".
|
|
1002
1345
|
*/
|
|
1003
|
-
availableTools?: string[];
|
|
1346
|
+
availableTools?: string[] | ToolSet;
|
|
1004
1347
|
/**
|
|
1005
|
-
* List of tool names to disable.
|
|
1006
|
-
*
|
|
1348
|
+
* List of tool names to disable. Supports the same pattern syntax as
|
|
1349
|
+
* {@link availableTools}.
|
|
1350
|
+
*
|
|
1351
|
+
* Always takes precedence over {@link availableTools}: a tool listed here
|
|
1352
|
+
* is disabled even if it also matches `availableTools`.
|
|
1007
1353
|
*/
|
|
1008
|
-
excludedTools?: string[];
|
|
1354
|
+
excludedTools?: string[] | ToolSet;
|
|
1009
1355
|
/**
|
|
1010
1356
|
* Custom provider configuration (BYOK - Bring Your Own Key).
|
|
1011
1357
|
* When specified, uses the provided API endpoint instead of the Copilot API.
|
|
1012
1358
|
*/
|
|
1013
1359
|
provider?: ProviderConfig;
|
|
1014
1360
|
/**
|
|
1015
|
-
*
|
|
1016
|
-
* When
|
|
1361
|
+
* Enables or disables internal session telemetry for this session.
|
|
1362
|
+
* When `false`, disables session telemetry. When omitted (the default) or `true`,
|
|
1363
|
+
* telemetry is enabled for GitHub-authenticated sessions.
|
|
1364
|
+
* When a custom {@link provider} (BYOK) is configured, session telemetry is always
|
|
1365
|
+
* disabled regardless of this setting.
|
|
1366
|
+
* This is independent of the OpenTelemetry configuration in {@link CopilotClientOptions.telemetry}.
|
|
1367
|
+
*/
|
|
1368
|
+
enableSessionTelemetry?: boolean;
|
|
1369
|
+
/**
|
|
1370
|
+
* When true, the runtime skips loading custom-instruction sources
|
|
1371
|
+
* (e.g. `.github/copilot-instructions.md`, `AGENTS.md`, `CLAUDE.md`).
|
|
1372
|
+
*
|
|
1373
|
+
* Defaults to `false` (custom instructions are loaded). Under
|
|
1374
|
+
* {@link CopilotClientOptions.mode} = `"empty"`, defaults to `true`; apps
|
|
1375
|
+
* can pass `false` here to opt back in.
|
|
1376
|
+
*/
|
|
1377
|
+
skipCustomInstructions?: boolean;
|
|
1378
|
+
/**
|
|
1379
|
+
* When true, custom agents default to local-only execution and are not
|
|
1380
|
+
* dispatched to remote workers.
|
|
1381
|
+
*
|
|
1382
|
+
* Defaults to `false`. Under {@link CopilotClientOptions.mode} = `"empty"`,
|
|
1383
|
+
* defaults to `true`; apps can pass `false` here to opt back in.
|
|
1384
|
+
*/
|
|
1385
|
+
customAgentsLocalOnly?: boolean;
|
|
1386
|
+
/**
|
|
1387
|
+
* When true, the runtime instructs the agent to include a `Co-authored-by`
|
|
1388
|
+
* trailer in commit messages it composes.
|
|
1389
|
+
*
|
|
1390
|
+
* Defaults to `true`. Under {@link CopilotClientOptions.mode} = `"empty"`,
|
|
1391
|
+
* defaults to `false`; apps can pass `true` here to opt back in.
|
|
1392
|
+
*/
|
|
1393
|
+
coauthorEnabled?: boolean;
|
|
1394
|
+
/**
|
|
1395
|
+
* When true, the `manage_schedule` tool is exposed to the agent.
|
|
1396
|
+
*
|
|
1397
|
+
* Defaults to whatever the runtime exposes (typically gated to staff
|
|
1398
|
+
* users). Under {@link CopilotClientOptions.mode} = `"empty"`, defaults to
|
|
1399
|
+
* `false`; apps can pass `true` here to opt back in.
|
|
1400
|
+
*/
|
|
1401
|
+
manageScheduleEnabled?: boolean;
|
|
1402
|
+
/**
|
|
1403
|
+
* Optional handler for permission requests from the server.
|
|
1404
|
+
* When omitted, permission requests are surfaced as events and left pending for
|
|
1405
|
+
* the consumer to resolve via the pending permission RPC.
|
|
1017
1406
|
*/
|
|
1018
|
-
onPermissionRequest
|
|
1407
|
+
onPermissionRequest?: PermissionHandler;
|
|
1019
1408
|
/**
|
|
1020
1409
|
* Handler for user input requests from the agent.
|
|
1021
1410
|
* When provided, enables the ask_user tool allowing the agent to ask questions.
|
|
@@ -1027,6 +1416,43 @@ export interface SessionConfig {
|
|
|
1027
1416
|
* Also enables the `elicitation` capability on the session.
|
|
1028
1417
|
*/
|
|
1029
1418
|
onElicitationRequest?: ElicitationHandler;
|
|
1419
|
+
/**
|
|
1420
|
+
* Enable MCP Apps (SEP-1865) UI passthrough on this session.
|
|
1421
|
+
*
|
|
1422
|
+
* When `true` **and** the runtime has MCP Apps enabled (via the
|
|
1423
|
+
* `MCP_APPS` feature flag or `COPILOT_MCP_APPS=true` environment
|
|
1424
|
+
* override), the runtime adds the `mcp-apps` capability to the session,
|
|
1425
|
+
* which causes it to advertise the `extensions.io.modelcontextprotocol/ui`
|
|
1426
|
+
* extension to MCP servers (so they expose `_meta.ui.resourceUri` on
|
|
1427
|
+
* tools) and to expose the `session.rpc.mcp.apps.{listTools,callTool,
|
|
1428
|
+
* readResource,setHostContext,getHostContext,diagnose}` JSON-RPC methods.
|
|
1429
|
+
*
|
|
1430
|
+
* If the runtime gate is off, the opt-in is silently dropped server-side
|
|
1431
|
+
* (the runtime logs a warning); the session is created normally but the
|
|
1432
|
+
* MCP Apps surface is unavailable. Inspect the runtime's
|
|
1433
|
+
* `capabilities.ui.mcpApps` on the create/resume response to detect this.
|
|
1434
|
+
*
|
|
1435
|
+
* SDK consumers MUST set this to `true` only when they have an iframe
|
|
1436
|
+
* renderer that can display `ui://` MCP App bundles. Setting it without a
|
|
1437
|
+
* renderer will cause MCP servers to register UI-enabled tool variants
|
|
1438
|
+
* the consumer cannot display.
|
|
1439
|
+
*
|
|
1440
|
+
* @experimental This option is part of an experimental wire-protocol surface
|
|
1441
|
+
* (SEP-1865) and may change or be removed in a future release.
|
|
1442
|
+
*
|
|
1443
|
+
* @default false
|
|
1444
|
+
*/
|
|
1445
|
+
enableMcpApps?: boolean;
|
|
1446
|
+
/**
|
|
1447
|
+
* Handler for exit-plan-mode requests from the agent.
|
|
1448
|
+
* When provided, enables `exitPlanMode.request` callbacks.
|
|
1449
|
+
*/
|
|
1450
|
+
onExitPlanModeRequest?: ExitPlanModeHandler;
|
|
1451
|
+
/**
|
|
1452
|
+
* Handler for auto-mode-switch requests from the agent.
|
|
1453
|
+
* When provided, enables `autoModeSwitch.request` callbacks.
|
|
1454
|
+
*/
|
|
1455
|
+
onAutoModeSwitchRequest?: AutoModeSwitchHandler;
|
|
1030
1456
|
/**
|
|
1031
1457
|
* Hook handlers for intercepting session lifecycle events.
|
|
1032
1458
|
* When provided, enables hooks callback allowing custom logic at various points.
|
|
@@ -1037,6 +1463,13 @@ export interface SessionConfig {
|
|
|
1037
1463
|
* Tool operations will be relative to this directory.
|
|
1038
1464
|
*/
|
|
1039
1465
|
workingDirectory?: string;
|
|
1466
|
+
/**
|
|
1467
|
+
* Enable streaming of assistant message and reasoning chunks.
|
|
1468
|
+
* When true, ephemeral assistant.message_delta and assistant.reasoning_delta
|
|
1469
|
+
* events are sent as the response is generated. Clients should accumulate
|
|
1470
|
+
* deltaContent values to build the full response.
|
|
1471
|
+
* @default false
|
|
1472
|
+
*/
|
|
1040
1473
|
streaming?: boolean;
|
|
1041
1474
|
/**
|
|
1042
1475
|
* Include sub-agent streaming events in the event stream. When true, streaming
|
|
@@ -1048,6 +1481,14 @@ export interface SessionConfig {
|
|
|
1048
1481
|
* @default true
|
|
1049
1482
|
*/
|
|
1050
1483
|
includeSubAgentStreamingEvents?: boolean;
|
|
1484
|
+
/**
|
|
1485
|
+
* Controls how MCP OAuth tokens are stored for this session.
|
|
1486
|
+
* - `"persistent"` — tokens are stored in the OS keychain (shared across sessions)
|
|
1487
|
+
* - `"in-memory"` — tokens are stored in memory and discarded when the session ends
|
|
1488
|
+
*
|
|
1489
|
+
* @default "in-memory"
|
|
1490
|
+
*/
|
|
1491
|
+
mcpOAuthTokenStorage?: "persistent" | "in-memory";
|
|
1051
1492
|
/**
|
|
1052
1493
|
* MCP server configurations for the session.
|
|
1053
1494
|
* Keys are server names, values are server configurations.
|
|
@@ -1074,6 +1515,20 @@ export interface SessionConfig {
|
|
|
1074
1515
|
* Directories to load skills from.
|
|
1075
1516
|
*/
|
|
1076
1517
|
skillDirectories?: string[];
|
|
1518
|
+
/**
|
|
1519
|
+
* Local filesystem paths to Open Plugins-format directories
|
|
1520
|
+
* (https://open-plugins.com/) to load for this session.
|
|
1521
|
+
*
|
|
1522
|
+
* Relative paths resolve against `workingDirectory` (or the runtime cwd if
|
|
1523
|
+
* unset); absolute paths are recommended. Invalid entries are logged and
|
|
1524
|
+
* skipped.
|
|
1525
|
+
*
|
|
1526
|
+
* Treated as an explicit opt-in: plugin agents and rules load even when
|
|
1527
|
+
* {@link SessionConfigBase.enableConfigDiscovery} is false. Loaded assets
|
|
1528
|
+
* slot between project (cwd) sources and personal/home sources in the
|
|
1529
|
+
* session-wide precedence order.
|
|
1530
|
+
*/
|
|
1531
|
+
pluginDirectories?: string[];
|
|
1077
1532
|
/**
|
|
1078
1533
|
* Additional directories to search for custom instruction files.
|
|
1079
1534
|
*/
|
|
@@ -1099,6 +1554,60 @@ export interface SessionConfig {
|
|
|
1099
1554
|
* the identity used for content exclusion, model routing, and quota checks.
|
|
1100
1555
|
*/
|
|
1101
1556
|
gitHubToken?: string;
|
|
1557
|
+
/**
|
|
1558
|
+
* When true, skips embedding-based retrieval for this session.
|
|
1559
|
+
* Use in multitenant deployments to prevent cross-session information leakage
|
|
1560
|
+
* through the shared embedding cache.
|
|
1561
|
+
*/
|
|
1562
|
+
skipEmbeddingRetrieval?: boolean;
|
|
1563
|
+
/**
|
|
1564
|
+
* Controls how the embedding cache is stored for this session.
|
|
1565
|
+
* - `"persistent"`: Embeddings are cached on disk and shared across sessions/restarts.
|
|
1566
|
+
* - `"in-memory"`: Embeddings are cached in memory only and discarded when the session ends.
|
|
1567
|
+
*/
|
|
1568
|
+
embeddingCacheStorage?: "persistent" | "in-memory";
|
|
1569
|
+
/**
|
|
1570
|
+
* Organization-level custom instructions to include in the system prompt.
|
|
1571
|
+
* Allows hosts to inject organization-specific guidance without relying on
|
|
1572
|
+
* filesystem-based instruction discovery.
|
|
1573
|
+
*/
|
|
1574
|
+
organizationCustomInstructions?: string;
|
|
1575
|
+
/**
|
|
1576
|
+
* When true, enables on-demand discovery of instruction files (AGENTS.md,
|
|
1577
|
+
* .github/copilot-instructions.md, etc.) after successful file views.
|
|
1578
|
+
*/
|
|
1579
|
+
enableOnDemandInstructionDiscovery?: boolean;
|
|
1580
|
+
/**
|
|
1581
|
+
* When true, enables loading of file-based hooks from `.github/hooks/`.
|
|
1582
|
+
* This is separate from the `hooks` callback parameter which gates SDK
|
|
1583
|
+
* hook event registration.
|
|
1584
|
+
*/
|
|
1585
|
+
enableFileHooks?: boolean;
|
|
1586
|
+
/**
|
|
1587
|
+
* When true, enables git operations on the host filesystem (branch detection,
|
|
1588
|
+
* file status, commit history). When false, no git context is surfaced in
|
|
1589
|
+
* the system prompt.
|
|
1590
|
+
*/
|
|
1591
|
+
enableHostGitOperations?: boolean;
|
|
1592
|
+
/**
|
|
1593
|
+
* When true, enables the cross-session store for search and retrieval
|
|
1594
|
+
* across sessions. When false, session content is not written to or
|
|
1595
|
+
* read from the shared session store.
|
|
1596
|
+
*/
|
|
1597
|
+
enableSessionStore?: boolean;
|
|
1598
|
+
/**
|
|
1599
|
+
* When true, enables skill loading (including builtin skills and discovered
|
|
1600
|
+
* skill directories). When false, no skills are loaded regardless of
|
|
1601
|
+
* `skillDirectories` or `enableConfigDiscovery` settings.
|
|
1602
|
+
*/
|
|
1603
|
+
enableSkills?: boolean;
|
|
1604
|
+
/**
|
|
1605
|
+
* Per-session remote behavior control:
|
|
1606
|
+
* - `"off"` — local only, no remote export (default)
|
|
1607
|
+
* - `"export"` — export session events to GitHub without enabling remote steering
|
|
1608
|
+
* - `"on"` — export to GitHub AND enable remote steering
|
|
1609
|
+
*/
|
|
1610
|
+
remoteSession?: RemoteSessionMode;
|
|
1102
1611
|
/**
|
|
1103
1612
|
* Optional event handler that is registered on the session before the
|
|
1104
1613
|
* session.create RPC is issued. This guarantees that early events emitted
|
|
@@ -1113,18 +1622,33 @@ export interface SessionConfig {
|
|
|
1113
1622
|
* Supplies a handler for session filesystem operations. This takes effect
|
|
1114
1623
|
* only if {@link CopilotClientOptions.sessionFs} is configured.
|
|
1115
1624
|
*/
|
|
1116
|
-
|
|
1625
|
+
createSessionFsProvider?: (session: CopilotSession) => SessionFsProvider;
|
|
1117
1626
|
}
|
|
1118
1627
|
/**
|
|
1119
|
-
* Configuration for
|
|
1628
|
+
* Configuration for creating a new session via {@link CopilotClient.createSession}.
|
|
1120
1629
|
*/
|
|
1121
|
-
export
|
|
1630
|
+
export interface SessionConfig extends SessionConfigBase {
|
|
1631
|
+
/**
|
|
1632
|
+
* Optional custom session ID. If not provided, the server generates one.
|
|
1633
|
+
*/
|
|
1634
|
+
sessionId?: string;
|
|
1635
|
+
/**
|
|
1636
|
+
* Creates a remote session in the cloud instead of a local session.
|
|
1637
|
+
* The optional repository is associated with the cloud session.
|
|
1638
|
+
*/
|
|
1639
|
+
cloud?: CloudSessionOptions;
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Configuration for resuming an existing session via
|
|
1643
|
+
* {@link CopilotClient.resumeSession}.
|
|
1644
|
+
*/
|
|
1645
|
+
export interface ResumeSessionConfig extends SessionConfigBase {
|
|
1122
1646
|
/**
|
|
1123
1647
|
* When true, skips emitting the session.resume event.
|
|
1124
1648
|
* Useful for reconnecting to a session without triggering resume-related side effects.
|
|
1125
1649
|
* @default false
|
|
1126
1650
|
*/
|
|
1127
|
-
|
|
1651
|
+
suppressResumeEvent?: boolean;
|
|
1128
1652
|
/**
|
|
1129
1653
|
* When true, the runtime continues any tool calls or permission prompts that were
|
|
1130
1654
|
* still pending when the session was last suspended. When false (the default), the
|
|
@@ -1137,7 +1661,13 @@ export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "
|
|
|
1137
1661
|
* @default false
|
|
1138
1662
|
*/
|
|
1139
1663
|
continuePendingWork?: boolean;
|
|
1140
|
-
|
|
1664
|
+
/**
|
|
1665
|
+
* Snapshot of canvases that were already open when the session was suspended.
|
|
1666
|
+
* When provided on resume, the runtime can rehydrate canvas state so consumers
|
|
1667
|
+
* do not need to re-open canvases that were active before the previous shutdown.
|
|
1668
|
+
*/
|
|
1669
|
+
openCanvases?: OpenCanvasInstance[];
|
|
1670
|
+
}
|
|
1141
1671
|
/**
|
|
1142
1672
|
* Configuration for a custom API provider.
|
|
1143
1673
|
*/
|
|
@@ -1177,6 +1707,32 @@ export interface ProviderConfig {
|
|
|
1177
1707
|
* Custom HTTP headers to include in outbound provider requests.
|
|
1178
1708
|
*/
|
|
1179
1709
|
headers?: Record<string, string>;
|
|
1710
|
+
/**
|
|
1711
|
+
* Well-known model name used by the runtime to look up agent configuration
|
|
1712
|
+
* (tools, prompts, reasoning behavior) and default token limits. Also used
|
|
1713
|
+
* as the wire model when {@link wireModel} is not set.
|
|
1714
|
+
* Falls back to {@link SessionConfig.model}.
|
|
1715
|
+
*/
|
|
1716
|
+
modelId?: string;
|
|
1717
|
+
/**
|
|
1718
|
+
* Model name sent to the provider API for inference. Use this when the
|
|
1719
|
+
* provider's model name (e.g. an Azure deployment name or a custom
|
|
1720
|
+
* fine-tune name) differs from {@link modelId}.
|
|
1721
|
+
* Falls back to {@link modelId}, then {@link SessionConfig.model}.
|
|
1722
|
+
*/
|
|
1723
|
+
wireModel?: string;
|
|
1724
|
+
/**
|
|
1725
|
+
* Overrides the resolved model's default max prompt tokens. The runtime
|
|
1726
|
+
* triggers conversation compaction before sending a request when the
|
|
1727
|
+
* prompt (system message, history, tool definitions, user message) would
|
|
1728
|
+
* exceed this limit.
|
|
1729
|
+
*/
|
|
1730
|
+
maxPromptTokens?: number;
|
|
1731
|
+
/**
|
|
1732
|
+
* Overrides the resolved model's default max output tokens. When hit, the
|
|
1733
|
+
* model stops generating and returns a truncated response.
|
|
1734
|
+
*/
|
|
1735
|
+
maxOutputTokens?: number;
|
|
1180
1736
|
}
|
|
1181
1737
|
/**
|
|
1182
1738
|
* Options for sending a message to a session
|
|
@@ -1224,10 +1780,19 @@ export interface MessageOptions {
|
|
|
1224
1780
|
* - "immediate": Send immediately
|
|
1225
1781
|
*/
|
|
1226
1782
|
mode?: "enqueue" | "immediate";
|
|
1783
|
+
/**
|
|
1784
|
+
* The UI mode the agent was in when this message was sent (for example "plan" or "autopilot").
|
|
1785
|
+
* Defaults to the session's current mode when unset.
|
|
1786
|
+
*/
|
|
1787
|
+
agentMode?: "interactive" | "plan" | "autopilot" | "shell";
|
|
1227
1788
|
/**
|
|
1228
1789
|
* Custom HTTP headers to include in outbound model requests for this turn.
|
|
1229
1790
|
*/
|
|
1230
1791
|
requestHeaders?: Record<string, string>;
|
|
1792
|
+
/**
|
|
1793
|
+
* If provided, this is shown in the timeline instead of `prompt`.
|
|
1794
|
+
*/
|
|
1795
|
+
displayPrompt?: string;
|
|
1231
1796
|
}
|
|
1232
1797
|
/**
|
|
1233
1798
|
* All possible event type strings from SessionEvent
|
|
@@ -1247,16 +1812,12 @@ export type TypedSessionEventHandler<T extends SessionEventType> = (event: Sessi
|
|
|
1247
1812
|
* Event handler callback type (for all events)
|
|
1248
1813
|
*/
|
|
1249
1814
|
export type SessionEventHandler = (event: SessionEvent) => void;
|
|
1250
|
-
/**
|
|
1251
|
-
* Connection state
|
|
1252
|
-
*/
|
|
1253
|
-
export type ConnectionState = "disconnected" | "connecting" | "connected" | "error";
|
|
1254
1815
|
/**
|
|
1255
1816
|
* Working directory context for a session
|
|
1256
1817
|
*/
|
|
1257
1818
|
export interface SessionContext {
|
|
1258
1819
|
/** Working directory where the session was created */
|
|
1259
|
-
|
|
1820
|
+
workingDirectory: string;
|
|
1260
1821
|
/** Git repository root (if in a git repo) */
|
|
1261
1822
|
gitRoot?: string;
|
|
1262
1823
|
/** GitHub repository in "owner/repo" format */
|
|
@@ -1281,13 +1842,26 @@ export interface SessionFsConfig {
|
|
|
1281
1842
|
* Path conventions used by this filesystem provider.
|
|
1282
1843
|
*/
|
|
1283
1844
|
conventions: "windows" | "posix";
|
|
1845
|
+
/**
|
|
1846
|
+
* Optional capabilities declared by this provider.
|
|
1847
|
+
* The runtime uses these to determine which features are available.
|
|
1848
|
+
*/
|
|
1849
|
+
capabilities?: {
|
|
1850
|
+
/**
|
|
1851
|
+
* Whether this provider supports SQLite query/exists operations.
|
|
1852
|
+
* When false or omitted, the runtime will not offer SQL tools or
|
|
1853
|
+
* todo tracking for sessions using this provider.
|
|
1854
|
+
* @default false
|
|
1855
|
+
*/
|
|
1856
|
+
sqlite?: boolean;
|
|
1857
|
+
};
|
|
1284
1858
|
}
|
|
1285
1859
|
/**
|
|
1286
1860
|
* Filter options for listing sessions
|
|
1287
1861
|
*/
|
|
1288
1862
|
export interface SessionListFilter {
|
|
1289
|
-
/** Filter by exact
|
|
1290
|
-
|
|
1863
|
+
/** Filter by exact working directory match */
|
|
1864
|
+
workingDirectory?: string;
|
|
1291
1865
|
/** Filter by git root */
|
|
1292
1866
|
gitRoot?: string;
|
|
1293
1867
|
/** Filter by repository (owner/repo format) */
|
|
@@ -1304,7 +1878,7 @@ export interface SessionMetadata {
|
|
|
1304
1878
|
modifiedTime: Date;
|
|
1305
1879
|
summary?: string;
|
|
1306
1880
|
isRemote: boolean;
|
|
1307
|
-
/** Working directory context (
|
|
1881
|
+
/** Working directory context (working directory, git info) from session creation */
|
|
1308
1882
|
context?: SessionContext;
|
|
1309
1883
|
}
|
|
1310
1884
|
/**
|
|
@@ -1367,7 +1941,7 @@ export interface ModelPolicy {
|
|
|
1367
1941
|
* Model billing information
|
|
1368
1942
|
*/
|
|
1369
1943
|
export interface ModelBilling {
|
|
1370
|
-
multiplier
|
|
1944
|
+
multiplier?: number;
|
|
1371
1945
|
}
|
|
1372
1946
|
/**
|
|
1373
1947
|
* Information about an available model
|
|
@@ -1389,35 +1963,68 @@ export interface ModelInfo {
|
|
|
1389
1963
|
defaultReasoningEffort?: ReasoningEffort;
|
|
1390
1964
|
}
|
|
1391
1965
|
/**
|
|
1392
|
-
* Types of session lifecycle events
|
|
1966
|
+
* Types of session lifecycle events.
|
|
1393
1967
|
*/
|
|
1394
1968
|
export type SessionLifecycleEventType = "session.created" | "session.deleted" | "session.updated" | "session.foreground" | "session.background";
|
|
1395
1969
|
/**
|
|
1396
|
-
*
|
|
1397
|
-
*
|
|
1970
|
+
* Metadata payload for session lifecycle events. Not present on
|
|
1971
|
+
* `session.deleted` events.
|
|
1398
1972
|
*/
|
|
1399
|
-
export interface
|
|
1400
|
-
/**
|
|
1401
|
-
|
|
1402
|
-
/**
|
|
1973
|
+
export interface SessionLifecycleEventMetadata {
|
|
1974
|
+
/** Time the session was created. */
|
|
1975
|
+
startTime: Date;
|
|
1976
|
+
/** Time the session was last modified. */
|
|
1977
|
+
modifiedTime: Date;
|
|
1978
|
+
/** Human-readable summary of the session, if available. */
|
|
1979
|
+
summary?: string;
|
|
1980
|
+
}
|
|
1981
|
+
/** Base shape shared by every lifecycle event variant. */
|
|
1982
|
+
interface SessionLifecycleEventBase {
|
|
1983
|
+
/** ID of the session this event relates to. */
|
|
1403
1984
|
sessionId: string;
|
|
1404
|
-
/** Session metadata (not included for deleted
|
|
1405
|
-
metadata?:
|
|
1406
|
-
startTime: string;
|
|
1407
|
-
modifiedTime: string;
|
|
1408
|
-
summary?: string;
|
|
1409
|
-
};
|
|
1985
|
+
/** Session metadata (not included for `session.deleted`). */
|
|
1986
|
+
metadata?: SessionLifecycleEventMetadata;
|
|
1410
1987
|
}
|
|
1988
|
+
/** Emitted when a new session is created. */
|
|
1989
|
+
export interface SessionCreatedEvent extends SessionLifecycleEventBase {
|
|
1990
|
+
type: "session.created";
|
|
1991
|
+
metadata: SessionLifecycleEventMetadata;
|
|
1992
|
+
}
|
|
1993
|
+
/** Emitted when a session is deleted. The metadata field is omitted. */
|
|
1994
|
+
export interface SessionDeletedEvent extends SessionLifecycleEventBase {
|
|
1995
|
+
type: "session.deleted";
|
|
1996
|
+
metadata?: undefined;
|
|
1997
|
+
}
|
|
1998
|
+
/** Emitted when a session's metadata is updated. */
|
|
1999
|
+
export interface SessionUpdatedEvent extends SessionLifecycleEventBase {
|
|
2000
|
+
type: "session.updated";
|
|
2001
|
+
metadata: SessionLifecycleEventMetadata;
|
|
2002
|
+
}
|
|
2003
|
+
/** Emitted when a session is brought to the foreground (TUI+server mode). */
|
|
2004
|
+
export interface SessionForegroundEvent extends SessionLifecycleEventBase {
|
|
2005
|
+
type: "session.foreground";
|
|
2006
|
+
metadata: SessionLifecycleEventMetadata;
|
|
2007
|
+
}
|
|
2008
|
+
/** Emitted when a session is moved to the background (TUI+server mode). */
|
|
2009
|
+
export interface SessionBackgroundEvent extends SessionLifecycleEventBase {
|
|
2010
|
+
type: "session.background";
|
|
2011
|
+
metadata: SessionLifecycleEventMetadata;
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Discriminated union of all session lifecycle events emitted in TUI+server mode.
|
|
2015
|
+
* Switch on `type` to access the variant-specific metadata.
|
|
2016
|
+
*/
|
|
2017
|
+
export type SessionLifecycleEvent = SessionCreatedEvent | SessionDeletedEvent | SessionUpdatedEvent | SessionForegroundEvent | SessionBackgroundEvent;
|
|
1411
2018
|
/**
|
|
1412
|
-
* Handler for session lifecycle events
|
|
2019
|
+
* Handler for session lifecycle events.
|
|
1413
2020
|
*/
|
|
1414
2021
|
export type SessionLifecycleHandler = (event: SessionLifecycleEvent) => void;
|
|
1415
2022
|
/**
|
|
1416
|
-
* Typed handler for specific session lifecycle event types
|
|
2023
|
+
* Typed handler for specific session lifecycle event types.
|
|
1417
2024
|
*/
|
|
1418
|
-
export type TypedSessionLifecycleHandler<K extends SessionLifecycleEventType> = (event: SessionLifecycleEvent
|
|
2025
|
+
export type TypedSessionLifecycleHandler<K extends SessionLifecycleEventType> = (event: Extract<SessionLifecycleEvent, {
|
|
1419
2026
|
type: K;
|
|
1420
|
-
}) => void;
|
|
2027
|
+
}>) => void;
|
|
1421
2028
|
/**
|
|
1422
2029
|
* Information about the foreground session in TUI+server mode
|
|
1423
2030
|
*/
|