@github/copilot-sdk 1.0.0-beta.9 → 1.0.1
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 +13 -9
- package/dist/canvas.d.ts +26 -3
- package/dist/cjs/client.js +118 -40
- package/dist/cjs/extension.js +3 -1
- package/dist/cjs/generated/rpc.js +405 -43
- package/dist/cjs/session.js +46 -5
- package/dist/client.js +118 -40
- package/dist/extension.d.ts +1 -1
- package/dist/extension.js +3 -1
- package/dist/generated/rpc.d.ts +3268 -712
- package/dist/generated/rpc.js +404 -43
- package/dist/generated/session-events.d.ts +199 -28
- package/dist/index.d.ts +2 -2
- package/dist/session.d.ts +11 -5
- package/dist/session.js +46 -5
- package/dist/types.d.ts +172 -2
- package/docs/examples.md +7 -4
- package/package.json +4 -4
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var rpc_exports = {};
|
|
20
20
|
__export(rpc_exports, {
|
|
21
21
|
createInternalServerRpc: () => createInternalServerRpc,
|
|
22
|
+
createInternalSessionRpc: () => createInternalSessionRpc,
|
|
22
23
|
createServerRpc: () => createServerRpc,
|
|
23
24
|
createSessionRpc: () => createSessionRpc,
|
|
24
25
|
registerClientSessionApiHandlers: () => registerClientSessionApiHandlers
|
|
@@ -111,7 +112,11 @@ function createServerRpc(connection) {
|
|
|
111
112
|
*
|
|
112
113
|
* @param params MCP server names to disable for new sessions.
|
|
113
114
|
*/
|
|
114
|
-
disable: async (params) => connection.sendRequest("mcp.config.disable", params)
|
|
115
|
+
disable: async (params) => connection.sendRequest("mcp.config.disable", params),
|
|
116
|
+
/**
|
|
117
|
+
* Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
|
|
118
|
+
*/
|
|
119
|
+
reload: async () => connection.sendRequest("mcp.config.reload", {})
|
|
115
120
|
},
|
|
116
121
|
/**
|
|
117
122
|
* Discovers MCP servers from user, workspace, plugin, and builtin sources.
|
|
@@ -122,6 +127,96 @@ function createServerRpc(connection) {
|
|
|
122
127
|
*/
|
|
123
128
|
discover: async (params) => connection.sendRequest("mcp.discover", params)
|
|
124
129
|
},
|
|
130
|
+
/** @experimental */
|
|
131
|
+
plugins: {
|
|
132
|
+
/**
|
|
133
|
+
* Lists plugins installed in user/global state.
|
|
134
|
+
*
|
|
135
|
+
* @returns Plugins installed in user/global state.
|
|
136
|
+
*/
|
|
137
|
+
list: async () => connection.sendRequest("plugins.list", {}),
|
|
138
|
+
/**
|
|
139
|
+
* Installs a plugin from a marketplace, GitHub repo, URL, or local path.
|
|
140
|
+
*
|
|
141
|
+
* @param params Plugin source and optional working directory for relative-path resolution.
|
|
142
|
+
*
|
|
143
|
+
* @returns Result of installing a plugin.
|
|
144
|
+
*/
|
|
145
|
+
install: async (params) => connection.sendRequest("plugins.install", params),
|
|
146
|
+
/**
|
|
147
|
+
* Uninstalls an installed plugin.
|
|
148
|
+
*
|
|
149
|
+
* @param params Name (or spec) of the plugin to uninstall.
|
|
150
|
+
*/
|
|
151
|
+
uninstall: async (params) => connection.sendRequest("plugins.uninstall", params),
|
|
152
|
+
/**
|
|
153
|
+
* Updates an installed plugin to its latest published version.
|
|
154
|
+
*
|
|
155
|
+
* @param params Name (or spec) of the plugin to update.
|
|
156
|
+
*
|
|
157
|
+
* @returns Result of updating a single plugin.
|
|
158
|
+
*/
|
|
159
|
+
update: async (params) => connection.sendRequest("plugins.update", params),
|
|
160
|
+
/**
|
|
161
|
+
* Updates every installed plugin to its latest published version.
|
|
162
|
+
*
|
|
163
|
+
* @returns Result of updating all installed plugins.
|
|
164
|
+
*/
|
|
165
|
+
updateAll: async () => connection.sendRequest("plugins.updateAll", {}),
|
|
166
|
+
/**
|
|
167
|
+
* Enables installed plugins for new sessions.
|
|
168
|
+
*
|
|
169
|
+
* @param params Plugin names (or specs) to enable.
|
|
170
|
+
*/
|
|
171
|
+
enable: async (params) => connection.sendRequest("plugins.enable", params),
|
|
172
|
+
/**
|
|
173
|
+
* Disables installed plugins for new sessions.
|
|
174
|
+
*
|
|
175
|
+
* @param params Plugin names (or specs) to disable.
|
|
176
|
+
*/
|
|
177
|
+
disable: async (params) => connection.sendRequest("plugins.disable", params),
|
|
178
|
+
/** @experimental */
|
|
179
|
+
marketplaces: {
|
|
180
|
+
/**
|
|
181
|
+
* Lists all registered marketplaces (defaults + user-added).
|
|
182
|
+
*
|
|
183
|
+
* @returns All registered marketplaces, including built-in defaults.
|
|
184
|
+
*/
|
|
185
|
+
list: async () => connection.sendRequest("plugins.marketplaces.list", {}),
|
|
186
|
+
/**
|
|
187
|
+
* Registers a new marketplace from a source (owner/repo, URL, or local path).
|
|
188
|
+
*
|
|
189
|
+
* @param params Marketplace source to register.
|
|
190
|
+
*
|
|
191
|
+
* @returns Result of registering a new marketplace.
|
|
192
|
+
*/
|
|
193
|
+
add: async (params) => connection.sendRequest("plugins.marketplaces.add", params),
|
|
194
|
+
/**
|
|
195
|
+
* Removes a previously-registered marketplace. When the marketplace has dependent plugins and `force` is not set, the marketplace is left intact and the result lists the dependents so the caller can decide whether to retry with `force=true`.
|
|
196
|
+
*
|
|
197
|
+
* @param params Name of the marketplace to remove and an optional force flag.
|
|
198
|
+
*
|
|
199
|
+
* @returns Outcome of the remove attempt, including dependent-plugin info when applicable.
|
|
200
|
+
*/
|
|
201
|
+
remove: async (params) => connection.sendRequest("plugins.marketplaces.remove", params),
|
|
202
|
+
/**
|
|
203
|
+
* Lists plugins advertised by a registered marketplace.
|
|
204
|
+
*
|
|
205
|
+
* @param params Name of the marketplace whose plugin catalog to fetch.
|
|
206
|
+
*
|
|
207
|
+
* @returns Plugins advertised by the marketplace.
|
|
208
|
+
*/
|
|
209
|
+
browse: async (params) => connection.sendRequest("plugins.marketplaces.browse", params),
|
|
210
|
+
/**
|
|
211
|
+
* Re-fetches one or all registered marketplace catalogs.
|
|
212
|
+
*
|
|
213
|
+
* @param params Optional marketplace name; omit to refresh all.
|
|
214
|
+
*
|
|
215
|
+
* @returns Result of refreshing one or more marketplace catalogs.
|
|
216
|
+
*/
|
|
217
|
+
refresh: async (params) => connection.sendRequest("plugins.marketplaces.refresh", params)
|
|
218
|
+
}
|
|
219
|
+
},
|
|
125
220
|
skills: {
|
|
126
221
|
config: {
|
|
127
222
|
/**
|
|
@@ -140,6 +235,42 @@ function createServerRpc(connection) {
|
|
|
140
235
|
*/
|
|
141
236
|
discover: async (params) => connection.sendRequest("skills.discover", params)
|
|
142
237
|
},
|
|
238
|
+
/** @experimental */
|
|
239
|
+
agents: {
|
|
240
|
+
/**
|
|
241
|
+
* Discovers custom agents across user, project, plugin, and remote sources.
|
|
242
|
+
*
|
|
243
|
+
* @param params Optional project paths to include in agent discovery.
|
|
244
|
+
*
|
|
245
|
+
* @returns Agents discovered across user, project, plugin, and remote sources.
|
|
246
|
+
*/
|
|
247
|
+
discover: async (params) => connection.sendRequest("agents.discover", params)
|
|
248
|
+
},
|
|
249
|
+
/** @experimental */
|
|
250
|
+
instructions: {
|
|
251
|
+
/**
|
|
252
|
+
* Discovers instruction sources across user, repository, and plugin sources.
|
|
253
|
+
*
|
|
254
|
+
* @param params Optional project paths to include in instruction discovery.
|
|
255
|
+
*
|
|
256
|
+
* @returns Instruction sources discovered across user, repository, and plugin sources.
|
|
257
|
+
*/
|
|
258
|
+
discover: async (params) => connection.sendRequest("instructions.discover", params)
|
|
259
|
+
},
|
|
260
|
+
user: {
|
|
261
|
+
settings: {
|
|
262
|
+
/**
|
|
263
|
+
* Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
|
|
264
|
+
*/
|
|
265
|
+
reload: async () => connection.sendRequest("user.settings.reload", {})
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
runtime: {
|
|
269
|
+
/**
|
|
270
|
+
* Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
|
|
271
|
+
*/
|
|
272
|
+
shutdown: async () => connection.sendRequest("runtime.shutdown", {})
|
|
273
|
+
},
|
|
143
274
|
sessionFs: {
|
|
144
275
|
/**
|
|
145
276
|
* Registers an SDK client as the session filesystem provider.
|
|
@@ -152,6 +283,14 @@ function createServerRpc(connection) {
|
|
|
152
283
|
},
|
|
153
284
|
/** @experimental */
|
|
154
285
|
sessions: {
|
|
286
|
+
/**
|
|
287
|
+
* Creates or resumes a local session and returns the opened session ID.
|
|
288
|
+
*
|
|
289
|
+
* @param params Open a session by creating, resuming, attaching, connecting to a remote, or handing off.
|
|
290
|
+
*
|
|
291
|
+
* @returns Result of opening a session.
|
|
292
|
+
*/
|
|
293
|
+
open: async (params) => connection.sendRequest("sessions.open", params),
|
|
155
294
|
/**
|
|
156
295
|
* Creates a new session by forking persisted history from an existing session.
|
|
157
296
|
*
|
|
@@ -169,11 +308,11 @@ function createServerRpc(connection) {
|
|
|
169
308
|
*/
|
|
170
309
|
connect: async (params) => connection.sendRequest("sessions.connect", params),
|
|
171
310
|
/**
|
|
172
|
-
* Lists
|
|
311
|
+
* Lists sessions, optionally filtered by source and working-directory context. Returned entries are discriminated by `isRemote`: local entries carry only the lightweight `LocalSessionMetadataValue` shape; remote entries carry the full `RemoteSessionMetadataValue` shape (repository, PR number, taskType, etc.).
|
|
173
312
|
*
|
|
174
|
-
* @param params Optional metadata-load limit and
|
|
313
|
+
* @param params Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
|
|
175
314
|
*
|
|
176
|
-
* @returns
|
|
315
|
+
* @returns Sessions matching the filter, ordered most-recently-modified first.
|
|
177
316
|
*/
|
|
178
317
|
list: async (params) => connection.sendRequest("sessions.list", params),
|
|
179
318
|
/**
|
|
@@ -200,14 +339,6 @@ function createServerRpc(connection) {
|
|
|
200
339
|
* @returns Most-relevant session ID for the supplied context, or omitted when no sessions exist.
|
|
201
340
|
*/
|
|
202
341
|
getLastForContext: async (params) => connection.sendRequest("sessions.getLastForContext", params),
|
|
203
|
-
/**
|
|
204
|
-
* Computes the absolute path to a session's persisted events.jsonl file.
|
|
205
|
-
*
|
|
206
|
-
* @param params Session ID whose event-log file path to compute.
|
|
207
|
-
*
|
|
208
|
-
* @returns Absolute path to the session's events.jsonl file on disk.
|
|
209
|
-
*/
|
|
210
|
-
getEventFilePath: async (params) => connection.sendRequest("sessions.getEventFilePath", params),
|
|
211
342
|
/**
|
|
212
343
|
* Returns the on-disk byte size of each session's workspace directory.
|
|
213
344
|
*
|
|
@@ -222,14 +353,6 @@ function createServerRpc(connection) {
|
|
|
222
353
|
* @returns Session IDs from the input set that are currently in use by another process.
|
|
223
354
|
*/
|
|
224
355
|
checkInUse: async (params) => connection.sendRequest("sessions.checkInUse", params),
|
|
225
|
-
/**
|
|
226
|
-
* Returns a session's persisted remote-steerable flag, if any has been recorded.
|
|
227
|
-
*
|
|
228
|
-
* @param params Session ID to look up the persisted remote-steerable flag for.
|
|
229
|
-
*
|
|
230
|
-
* @returns The session's persisted remote-steerable flag, or omitted when no value has been persisted.
|
|
231
|
-
*/
|
|
232
|
-
getPersistedRemoteSteerable: async (params) => connection.sendRequest("sessions.getPersistedRemoteSteerable", params),
|
|
233
356
|
/**
|
|
234
357
|
* Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
|
|
235
358
|
*
|
|
@@ -301,7 +424,45 @@ function createServerRpc(connection) {
|
|
|
301
424
|
*
|
|
302
425
|
* @returns Replace the manager-wide additional plugins. New session creations and subsequent hook reloads see the new set; already-running sessions keep their existing hook installation until the next reload.
|
|
303
426
|
*/
|
|
304
|
-
setAdditionalPlugins: async (params) => connection.sendRequest("sessions.setAdditionalPlugins", params)
|
|
427
|
+
setAdditionalPlugins: async (params) => connection.sendRequest("sessions.setAdditionalPlugins", params),
|
|
428
|
+
/**
|
|
429
|
+
* Attaches the runtime-managed remote-control singleton to a session, awaiting initial setup. If remote control is already attached to a different session, the singleton is transferred (preserving the underlying Mission Control connection). Returns the final status.
|
|
430
|
+
*
|
|
431
|
+
* @param params Parameters for attaching the remote-control singleton to a session.
|
|
432
|
+
*
|
|
433
|
+
* @returns Wrapper for the singleton's current status.
|
|
434
|
+
*/
|
|
435
|
+
startRemoteControl: async (params) => connection.sendRequest("sessions.startRemoteControl", params),
|
|
436
|
+
/**
|
|
437
|
+
* Atomically rebinds the remote-control singleton to a different session, preserving the underlying Mission Control connection. When `expectedFromSessionId` is provided and does not match the singleton's current `attachedSessionId`, the transfer is rejected with `transferred: false` and the current status is returned unchanged.
|
|
438
|
+
*
|
|
439
|
+
* @param params Parameters for atomically rebinding the remote-control singleton.
|
|
440
|
+
*
|
|
441
|
+
* @returns Outcome of a transferRemoteControl call.
|
|
442
|
+
*/
|
|
443
|
+
transferRemoteControl: async (params) => connection.sendRequest("sessions.transferRemoteControl", params),
|
|
444
|
+
/**
|
|
445
|
+
* Patches the steering state of the active remote-control singleton. When remote control is off, this is a no-op and the off status is returned. Today only `enabled: true` is actionable on the underlying exporter; passing `false` is reserved for future use.
|
|
446
|
+
*
|
|
447
|
+
* @param params Patch for the singleton's steering state.
|
|
448
|
+
*
|
|
449
|
+
* @returns Wrapper for the singleton's current status.
|
|
450
|
+
*/
|
|
451
|
+
setRemoteControlSteering: async (params) => connection.sendRequest("sessions.setRemoteControlSteering", params),
|
|
452
|
+
/**
|
|
453
|
+
* Stops the remote-control singleton. When `expectedSessionId` is provided and does not match the singleton's current `attachedSessionId`, the stop is rejected with `stopped: false` and the current status is returned unchanged (unless `force` is set, in which case the singleton is unconditionally torn down).
|
|
454
|
+
*
|
|
455
|
+
* @param params Parameters for stopping the remote-control singleton.
|
|
456
|
+
*
|
|
457
|
+
* @returns Outcome of a stopRemoteControl call.
|
|
458
|
+
*/
|
|
459
|
+
stopRemoteControl: async (params) => connection.sendRequest("sessions.stopRemoteControl", params),
|
|
460
|
+
/**
|
|
461
|
+
* Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
|
|
462
|
+
*
|
|
463
|
+
* @returns Wrapper for the singleton's current status.
|
|
464
|
+
*/
|
|
465
|
+
getRemoteControlStatus: async () => connection.sendRequest("sessions.getRemoteControlStatus", {})
|
|
305
466
|
},
|
|
306
467
|
/** @experimental */
|
|
307
468
|
agentRegistry: {
|
|
@@ -319,13 +480,62 @@ function createServerRpc(connection) {
|
|
|
319
480
|
function createInternalServerRpc(connection) {
|
|
320
481
|
return {
|
|
321
482
|
/**
|
|
322
|
-
* Performs the SDK server connection handshake and validates the optional connection token.
|
|
483
|
+
* Performs the SDK server connection handshake and validates the optional connection token. Marked internal because this is JSON-RPC transport plumbing invoked automatically by an SDK client's own `connect()` wrapper, not a user-facing method. Stays internal as long as the SDK client owns the handshake; would only become public if the SDK ever exposed the raw schema surface to consumers without a connection wrapper.
|
|
323
484
|
*
|
|
324
485
|
* @param params Optional connection token presented by the SDK client during the handshake.
|
|
325
486
|
*
|
|
326
487
|
* @returns Handshake result reporting the server's protocol version and package version on success.
|
|
327
488
|
*/
|
|
328
|
-
connect: async (params) => connection.sendRequest("connect", params)
|
|
489
|
+
connect: async (params) => connection.sendRequest("connect", params),
|
|
490
|
+
/** @experimental */
|
|
491
|
+
sessions: {
|
|
492
|
+
/**
|
|
493
|
+
* Computes the absolute path to a session's persisted events.jsonl file. Internal: filesystem paths are only meaningful in-process (CLI and runtime share a filesystem). Currently used by the CLI's contribution-graph feature to read historical events directly. Remote SDK consumers must not depend on this; a proper event-query API would replace it if the contribution graph ever needed to work over the wire.
|
|
494
|
+
*
|
|
495
|
+
* @param params Session ID whose event-log file path to compute.
|
|
496
|
+
*
|
|
497
|
+
* @returns Absolute path to the session's events.jsonl file on disk.
|
|
498
|
+
*/
|
|
499
|
+
getEventFilePath: async (params) => connection.sendRequest("sessions.getEventFilePath", params),
|
|
500
|
+
/**
|
|
501
|
+
* Returns a session's persisted remote-steerable flag, if any has been recorded. Internal: this is CLI-specific book-keeping used by `--continue` / `--resume` to inherit the prior session's remote-steerable preference. SDK consumers that want similar behavior should manage their own persistence around start/stop calls rather than relying on this runtime-side flag.
|
|
502
|
+
*
|
|
503
|
+
* @param params Session ID to look up the persisted remote-steerable flag for.
|
|
504
|
+
*
|
|
505
|
+
* @returns The session's persisted remote-steerable flag, or omitted when no value has been persisted.
|
|
506
|
+
*/
|
|
507
|
+
getPersistedRemoteSteerable: async (params) => connection.sendRequest("sessions.getPersistedRemoteSteerable", params),
|
|
508
|
+
/**
|
|
509
|
+
* Gets the dynamic-context board entry count associated with a session, when available. Internal: this exists solely so CLI telemetry events (`rem_spawn_gate`, `rem_consolidation_complete`) can pair START / END board counts around the detached rem-agent spawn. "Dynamic context board" is a runtime-internal concept that is not part of the public SDK contract; the long-term plan is to relocate the telemetry emission into the runtime so this method can be deleted entirely.
|
|
510
|
+
*
|
|
511
|
+
* @param params Session ID whose board entry count should be returned.
|
|
512
|
+
*
|
|
513
|
+
* @returns Dynamic-context board entry count, when available.
|
|
514
|
+
*/
|
|
515
|
+
getBoardEntryCount: async (params) => connection.sendRequest("sessions.getBoardEntryCount", params),
|
|
516
|
+
/**
|
|
517
|
+
* Cursor-based long-poll for sessions spawned by the runtime (e.g. in response to a Mission Control `start_session` command). The cursor is an opaque token; pass it back to receive only spawn events that occurred AFTER the cursor was issued. Omit the cursor on the first call to receive any events buffered since the runtime started. Internal: this is a CLI background-daemon plumbing primitive. SDK consumers that need to react to runtime-spawned sessions should subscribe to a higher-level event stream rather than driving a long-poll loop.
|
|
518
|
+
*
|
|
519
|
+
* @param params Cursor and optional long-poll wait for polling runtime-spawned sessions.
|
|
520
|
+
*
|
|
521
|
+
* @returns Batch of spawn events plus a cursor for follow-up polls.
|
|
522
|
+
*/
|
|
523
|
+
pollSpawnedSessions: async (params) => connection.sendRequest("sessions.pollSpawnedSessions", params),
|
|
524
|
+
/**
|
|
525
|
+
* Registers extension-provided tools on the given session, gated by an optional `enabled` callback. Returns an opaque unsubscribe function the caller must invoke to deregister the tools when the extension is torn down. Marked internal because `loader`, `enabled`, and the returned `unsubscribe` are in-process handles that cannot cross the JSON-RPC boundary. Disappears once extension discovery / launch / tool registration are owned by the runtime: SDK consumers will pass pure config (search paths, disabled ids) via `SessionOptions` and the runtime will resolve, launch, register, and tear down extensions itself.
|
|
526
|
+
*
|
|
527
|
+
* @param params Params to attach an extension loader's tools to a session.
|
|
528
|
+
*
|
|
529
|
+
* @returns Handle for releasing the extension tool registration.
|
|
530
|
+
*/
|
|
531
|
+
registerExtensionToolsOnSession: async (params) => connection.sendRequest("sessions.registerExtensionToolsOnSession", params),
|
|
532
|
+
/**
|
|
533
|
+
* Attaches (or detaches) an in-process ExtensionController delegate for the given session, used by shared-API surfaces that need to query or modify the session's extension state. Pass `controller: undefined` to detach. Marked internal because the controller is an in-process object that cannot cross the JSON-RPC boundary. Disappears alongside `registerExtensionToolsOnSession`: once the runtime owns extension management, the public surface exposes list/enable/disable/reload as dedicated RPCs served by the runtime.
|
|
534
|
+
*
|
|
535
|
+
* @param params Params to attach or detach an in-process ExtensionController delegate.
|
|
536
|
+
*/
|
|
537
|
+
configureSessionExtensions: async (params) => connection.sendRequest("sessions.configureSessionExtensions", params)
|
|
538
|
+
}
|
|
329
539
|
};
|
|
330
540
|
}
|
|
331
541
|
function createSessionRpc(connection, sessionId) {
|
|
@@ -409,27 +619,30 @@ function createSessionRpc(connection, sessionId) {
|
|
|
409
619
|
* @param params Canvas close parameters.
|
|
410
620
|
*/
|
|
411
621
|
close: async (params) => connection.sendRequest("session.canvas.close", { sessionId, ...params }),
|
|
412
|
-
/**
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
622
|
+
/** @experimental */
|
|
623
|
+
action: {
|
|
624
|
+
/**
|
|
625
|
+
* Invokes an action on an open canvas instance.
|
|
626
|
+
*
|
|
627
|
+
* @param params Canvas action invocation parameters.
|
|
628
|
+
*
|
|
629
|
+
* @returns Canvas action invocation result.
|
|
630
|
+
*/
|
|
631
|
+
invoke: async (params) => connection.sendRequest("session.canvas.action.invoke", { sessionId, ...params })
|
|
632
|
+
}
|
|
420
633
|
},
|
|
421
634
|
/** @experimental */
|
|
422
635
|
model: {
|
|
423
636
|
/**
|
|
424
637
|
* Gets the currently selected model for the session.
|
|
425
638
|
*
|
|
426
|
-
* @returns The currently selected model
|
|
639
|
+
* @returns The currently selected model, reasoning effort, and context tier for the session. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
|
|
427
640
|
*/
|
|
428
641
|
getCurrent: async () => connection.sendRequest("session.model.getCurrent", { sessionId }),
|
|
429
642
|
/**
|
|
430
643
|
* Switches the session to a model and optional reasoning configuration.
|
|
431
644
|
*
|
|
432
|
-
* @param params Target model identifier and optional reasoning effort, summary, and
|
|
645
|
+
* @param params Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
|
|
433
646
|
*
|
|
434
647
|
* @returns The model identifier active on the session after the switch.
|
|
435
648
|
*/
|
|
@@ -441,7 +654,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
441
654
|
*
|
|
442
655
|
* @returns Update the session's reasoning effort without changing the selected model. Use `switchTo` instead when you also need to change the model. The runtime stores the effort on the session and applies it to subsequent turns.
|
|
443
656
|
*/
|
|
444
|
-
setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { sessionId, ...params })
|
|
657
|
+
setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { sessionId, ...params }),
|
|
658
|
+
/**
|
|
659
|
+
* Lists models available to this session using its own auth and integration context. Connected hosts (CLI TUI, GitHub App) should call this through the session client so remote sessions return the remote CLI's available models rather than the caller's.
|
|
660
|
+
*
|
|
661
|
+
* @param params Optional listing options.
|
|
662
|
+
*
|
|
663
|
+
* @returns The list of models available to this session.
|
|
664
|
+
*/
|
|
665
|
+
list: async (params) => connection.sendRequest("session.model.list", { sessionId, ...params })
|
|
445
666
|
},
|
|
446
667
|
/** @experimental */
|
|
447
668
|
mode: {
|
|
@@ -498,7 +719,13 @@ function createSessionRpc(connection, sessionId) {
|
|
|
498
719
|
/**
|
|
499
720
|
* Deletes the session plan file from the workspace.
|
|
500
721
|
*/
|
|
501
|
-
delete: async () => connection.sendRequest("session.plan.delete", { sessionId })
|
|
722
|
+
delete: async () => connection.sendRequest("session.plan.delete", { sessionId }),
|
|
723
|
+
/**
|
|
724
|
+
* Reads todo rows from the session SQL database for plan rendering.
|
|
725
|
+
*
|
|
726
|
+
* @returns Todo rows read from the session SQL database. Empty when no session database is available.
|
|
727
|
+
*/
|
|
728
|
+
readSqlTodos: async () => connection.sendRequest("session.plan.readSqlTodos", { sessionId })
|
|
502
729
|
},
|
|
503
730
|
/** @experimental */
|
|
504
731
|
workspaces: {
|
|
@@ -733,11 +960,19 @@ function createSessionRpc(connection, sessionId) {
|
|
|
733
960
|
/** @experimental */
|
|
734
961
|
mcp: {
|
|
735
962
|
/**
|
|
736
|
-
* Lists MCP servers configured for the session
|
|
963
|
+
* Lists MCP servers configured for the session, their connection status, and host-level state. The host-level state (disabled/filtered servers, failed/needs-auth/pending connections, mcp3p policy, full config) is empty/zero when no MCP host has been initialized for the session.
|
|
737
964
|
*
|
|
738
|
-
* @returns MCP servers configured for the session, with their connection status.
|
|
965
|
+
* @returns MCP servers configured for the session, with their connection status and host-level state.
|
|
739
966
|
*/
|
|
740
967
|
list: async () => connection.sendRequest("session.mcp.list", { sessionId }),
|
|
968
|
+
/**
|
|
969
|
+
* Lists the tools exposed by a connected MCP server on this session's host.
|
|
970
|
+
*
|
|
971
|
+
* @param params Server name whose tool list should be returned.
|
|
972
|
+
*
|
|
973
|
+
* @returns Tools exposed by the connected MCP server. Throws when the server is not connected.
|
|
974
|
+
*/
|
|
975
|
+
listTools: async (params) => connection.sendRequest("session.mcp.listTools", { sessionId, ...params }),
|
|
741
976
|
/**
|
|
742
977
|
* Enables an MCP server for the session.
|
|
743
978
|
*
|
|
@@ -784,6 +1019,20 @@ function createSessionRpc(connection, sessionId) {
|
|
|
784
1019
|
* @returns Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
|
|
785
1020
|
*/
|
|
786
1021
|
removeGitHub: async () => connection.sendRequest("session.mcp.removeGitHub", { sessionId }),
|
|
1022
|
+
/**
|
|
1023
|
+
* Stops an individual MCP server on the session's host.
|
|
1024
|
+
*
|
|
1025
|
+
* @param params Server name for an individual MCP server stop.
|
|
1026
|
+
*/
|
|
1027
|
+
stopServer: async (params) => connection.sendRequest("session.mcp.stopServer", { sessionId, ...params }),
|
|
1028
|
+
/**
|
|
1029
|
+
* Checks whether a named MCP server is currently running on the session's host.
|
|
1030
|
+
*
|
|
1031
|
+
* @param params Server name to check running status for.
|
|
1032
|
+
*
|
|
1033
|
+
* @returns Whether the named MCP server is running.
|
|
1034
|
+
*/
|
|
1035
|
+
isServerRunning: async (params) => connection.sendRequest("session.mcp.isServerRunning", { sessionId, ...params }),
|
|
787
1036
|
/** @experimental */
|
|
788
1037
|
oauth: {
|
|
789
1038
|
/**
|
|
@@ -850,7 +1099,13 @@ function createSessionRpc(connection, sessionId) {
|
|
|
850
1099
|
*
|
|
851
1100
|
* @returns Plugins installed for the session, with their enabled state and version metadata.
|
|
852
1101
|
*/
|
|
853
|
-
list: async () => connection.sendRequest("session.plugins.list", { sessionId })
|
|
1102
|
+
list: async () => connection.sendRequest("session.plugins.list", { sessionId }),
|
|
1103
|
+
/**
|
|
1104
|
+
* Reloads the session's plugin set, refreshing MCP servers, custom agents, hooks, and skills cache so SDK-driven changes via `server.plugins.*` take effect immediately.
|
|
1105
|
+
*
|
|
1106
|
+
* @param params Optional flags controlling which side effects the reload performs.
|
|
1107
|
+
*/
|
|
1108
|
+
reload: async (params) => connection.sendRequest("session.plugins.reload", { sessionId, ...params })
|
|
854
1109
|
},
|
|
855
1110
|
/** @experimental */
|
|
856
1111
|
options: {
|
|
@@ -895,7 +1150,13 @@ function createSessionRpc(connection, sessionId) {
|
|
|
895
1150
|
/**
|
|
896
1151
|
* Reloads extension definitions and processes for the session.
|
|
897
1152
|
*/
|
|
898
|
-
reload: async () => connection.sendRequest("session.extensions.reload", { sessionId })
|
|
1153
|
+
reload: async () => connection.sendRequest("session.extensions.reload", { sessionId }),
|
|
1154
|
+
/**
|
|
1155
|
+
* Push attachments into the next user-message turn from an extension. The host should surface them as composer pills and forward them via the next session.send call. Callable only by extension-owned connections.
|
|
1156
|
+
*
|
|
1157
|
+
* @param params Parameters for session.extensions.sendAttachmentsToMessage.
|
|
1158
|
+
*/
|
|
1159
|
+
sendAttachmentsToMessage: async (params) => connection.sendRequest("session.extensions.sendAttachmentsToMessage", { sessionId, ...params })
|
|
899
1160
|
},
|
|
900
1161
|
/** @experimental */
|
|
901
1162
|
tools: {
|
|
@@ -912,7 +1173,13 @@ function createSessionRpc(connection, sessionId) {
|
|
|
912
1173
|
*
|
|
913
1174
|
* @returns Resolve, build, and validate the runtime tool list for this session. Subagent sessions and consumer flows that need an initialized tool set before `send` invoke this. Default base-class implementation is a no-op for sessions that don't support tool validation.
|
|
914
1175
|
*/
|
|
915
|
-
initializeAndValidate: async () => connection.sendRequest("session.tools.initializeAndValidate", { sessionId })
|
|
1176
|
+
initializeAndValidate: async () => connection.sendRequest("session.tools.initializeAndValidate", { sessionId }),
|
|
1177
|
+
/**
|
|
1178
|
+
* Returns lightweight metadata for the session's currently initialized tools.
|
|
1179
|
+
*
|
|
1180
|
+
* @returns Current lightweight tool metadata snapshot for the session.
|
|
1181
|
+
*/
|
|
1182
|
+
getCurrentMetadata: async () => connection.sendRequest("session.tools.getCurrentMetadata", { sessionId })
|
|
916
1183
|
},
|
|
917
1184
|
/** @experimental */
|
|
918
1185
|
commands: {
|
|
@@ -967,6 +1234,12 @@ function createSessionRpc(connection, sessionId) {
|
|
|
967
1234
|
},
|
|
968
1235
|
/** @experimental */
|
|
969
1236
|
telemetry: {
|
|
1237
|
+
/**
|
|
1238
|
+
* Gets the telemetry engagement ID currently associated with the session, when available.
|
|
1239
|
+
*
|
|
1240
|
+
* @returns Telemetry engagement ID for the session, when available.
|
|
1241
|
+
*/
|
|
1242
|
+
getEngagementId: async () => connection.sendRequest("session.telemetry.getEngagementId", { sessionId }),
|
|
970
1243
|
/**
|
|
971
1244
|
* Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
|
|
972
1245
|
*
|
|
@@ -976,6 +1249,14 @@ function createSessionRpc(connection, sessionId) {
|
|
|
976
1249
|
},
|
|
977
1250
|
/** @experimental */
|
|
978
1251
|
ui: {
|
|
1252
|
+
/**
|
|
1253
|
+
* Runs a transient no-tools model query against the current conversation context.
|
|
1254
|
+
*
|
|
1255
|
+
* @param params Transient question to answer without adding it to conversation history.
|
|
1256
|
+
*
|
|
1257
|
+
* @returns Transient answer generated from current conversation context.
|
|
1258
|
+
*/
|
|
1259
|
+
ephemeralQuery: async (params) => connection.sendRequest("session.ui.ephemeralQuery", { sessionId, ...params }),
|
|
979
1260
|
/**
|
|
980
1261
|
* Requests structured input from a UI-capable client.
|
|
981
1262
|
*
|
|
@@ -1238,6 +1519,12 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1238
1519
|
* @returns Indicates whether the local session is currently processing a turn or background continuation.
|
|
1239
1520
|
*/
|
|
1240
1521
|
isProcessing: async () => connection.sendRequest("session.metadata.isProcessing", { sessionId }),
|
|
1522
|
+
/**
|
|
1523
|
+
* Returns a snapshot of activity flags for the session.
|
|
1524
|
+
*
|
|
1525
|
+
* @returns Current activity flags for the session.
|
|
1526
|
+
*/
|
|
1527
|
+
activity: async () => connection.sendRequest("session.metadata.activity", { sessionId }),
|
|
1241
1528
|
/**
|
|
1242
1529
|
* Returns the token breakdown for the session's current context window for a given model.
|
|
1243
1530
|
*
|
|
@@ -1288,7 +1575,23 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1288
1575
|
*
|
|
1289
1576
|
* @returns Indicates whether the signal was delivered; false if the process was unknown or already exited.
|
|
1290
1577
|
*/
|
|
1291
|
-
kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params })
|
|
1578
|
+
kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params }),
|
|
1579
|
+
/**
|
|
1580
|
+
* Executes a user-requested shell command through the session runtime.
|
|
1581
|
+
*
|
|
1582
|
+
* @param params User-requested shell command and cancellation handle.
|
|
1583
|
+
*
|
|
1584
|
+
* @returns Result of a user-requested shell command.
|
|
1585
|
+
*/
|
|
1586
|
+
executeUserRequested: async (params) => connection.sendRequest("session.shell.executeUserRequested", { sessionId, ...params }),
|
|
1587
|
+
/**
|
|
1588
|
+
* Cancels a user-requested shell command by request ID.
|
|
1589
|
+
*
|
|
1590
|
+
* @param params User-requested shell execution cancellation handle.
|
|
1591
|
+
*
|
|
1592
|
+
* @returns Cancellation result for a user-requested shell command.
|
|
1593
|
+
*/
|
|
1594
|
+
cancelUserRequested: async (params) => connection.sendRequest("session.shell.cancelUserRequested", { sessionId, ...params })
|
|
1292
1595
|
},
|
|
1293
1596
|
/** @experimental */
|
|
1294
1597
|
history: {
|
|
@@ -1430,6 +1733,64 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1430
1733
|
}
|
|
1431
1734
|
};
|
|
1432
1735
|
}
|
|
1736
|
+
function createInternalSessionRpc(connection, sessionId) {
|
|
1737
|
+
return {
|
|
1738
|
+
/** @experimental */
|
|
1739
|
+
mcp: {
|
|
1740
|
+
/**
|
|
1741
|
+
* Reloads MCP server connections for the session with an explicit host-provided configuration.
|
|
1742
|
+
*
|
|
1743
|
+
* @param params Opaque MCP reload configuration.
|
|
1744
|
+
*
|
|
1745
|
+
* @returns MCP server startup filtering result.
|
|
1746
|
+
*/
|
|
1747
|
+
reloadWithConfig: async (params) => connection.sendRequest("session.mcp.reloadWithConfig", { sessionId, ...params }),
|
|
1748
|
+
/**
|
|
1749
|
+
* Configures the built-in GitHub MCP server for the session's current auth context.
|
|
1750
|
+
*
|
|
1751
|
+
* @param params Opaque auth info used to configure GitHub MCP.
|
|
1752
|
+
*
|
|
1753
|
+
* @returns Result of configuring GitHub MCP.
|
|
1754
|
+
*/
|
|
1755
|
+
configureGitHub: async (params) => connection.sendRequest("session.mcp.configureGitHub", { sessionId, ...params }),
|
|
1756
|
+
/**
|
|
1757
|
+
* Starts an individual MCP server on the session's host.
|
|
1758
|
+
*
|
|
1759
|
+
* @param params Server name and opaque configuration for an individual MCP server start.
|
|
1760
|
+
*/
|
|
1761
|
+
startServer: async (params) => connection.sendRequest("session.mcp.startServer", { sessionId, ...params }),
|
|
1762
|
+
/**
|
|
1763
|
+
* Restarts an individual MCP server on the session's host (stops then starts).
|
|
1764
|
+
*
|
|
1765
|
+
* @param params Server name and opaque configuration for an individual MCP server restart.
|
|
1766
|
+
*/
|
|
1767
|
+
restartServer: async (params) => connection.sendRequest("session.mcp.restartServer", { sessionId, ...params }),
|
|
1768
|
+
/**
|
|
1769
|
+
* Registers a pre-connected external MCP client (e.g. IDE) on the session's host. The caller retains lifecycle ownership of the client and transport. Marked internal because the `client` and `transport` arguments are in-process MCP SDK instances that cannot be serialized across the JSON-RPC boundary; once the CLI moves on top of the SDK, external clients will be expressed as transport configs the runtime can construct itself.
|
|
1770
|
+
*
|
|
1771
|
+
* @param params Registration parameters for an external MCP client.
|
|
1772
|
+
*/
|
|
1773
|
+
registerExternalClient: async (params) => connection.sendRequest("session.mcp.registerExternalClient", { sessionId, ...params }),
|
|
1774
|
+
/**
|
|
1775
|
+
* Unregisters a previously registered external MCP client by server name. Marked internal as the paired companion of `registerExternalClient`: only in-process callers that registered a client this way can meaningfully unregister it. Disappears alongside `registerExternalClient`: once external clients are described to the runtime as config rather than handed in as instances, lifecycle (including deregistration) is owned entirely by the runtime.
|
|
1776
|
+
*
|
|
1777
|
+
* @param params Server name identifying the external client to remove.
|
|
1778
|
+
*/
|
|
1779
|
+
unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params }),
|
|
1780
|
+
/** @experimental */
|
|
1781
|
+
oauth: {
|
|
1782
|
+
/**
|
|
1783
|
+
* Responds to a pending MCP OAuth provider request. Marked internal because the `provider` argument is an in-process OAuthClientProvider instance that cannot be carried over the wire; the public OAuth surface will route the response through a wire-clean handshake once the CLI moves on top of the SDK.
|
|
1784
|
+
*
|
|
1785
|
+
* @param params MCP OAuth request id and optional provider response.
|
|
1786
|
+
*
|
|
1787
|
+
* @returns Empty result after recording the MCP OAuth response.
|
|
1788
|
+
*/
|
|
1789
|
+
respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { sessionId, ...params })
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
}
|
|
1433
1794
|
function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
1434
1795
|
connection.onRequest("sessionFs.readFile", async (params) => {
|
|
1435
1796
|
const handler = getHandlers(params.sessionId).sessionFs;
|
|
@@ -1501,15 +1862,16 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
1501
1862
|
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1502
1863
|
return handler.close(params);
|
|
1503
1864
|
});
|
|
1504
|
-
connection.onRequest("canvas.
|
|
1865
|
+
connection.onRequest("canvas.action.invoke", async (params) => {
|
|
1505
1866
|
const handler = getHandlers(params.sessionId).canvas;
|
|
1506
1867
|
if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
|
|
1507
|
-
return handler.
|
|
1868
|
+
return handler.invoke(params);
|
|
1508
1869
|
});
|
|
1509
1870
|
}
|
|
1510
1871
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1511
1872
|
0 && (module.exports = {
|
|
1512
1873
|
createInternalServerRpc,
|
|
1874
|
+
createInternalSessionRpc,
|
|
1513
1875
|
createServerRpc,
|
|
1514
1876
|
createSessionRpc,
|
|
1515
1877
|
registerClientSessionApiHandlers
|