@github/copilot-sdk 1.0.0 → 1.0.2-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -5
- package/dist/canvas.js +1 -0
- package/dist/cjs/canvas.js +1 -0
- package/dist/cjs/client.js +107 -11
- package/dist/cjs/generated/rpc.js +401 -29
- package/dist/cjs/session.js +19 -2
- package/dist/client.d.ts +4 -2
- package/dist/client.js +107 -11
- package/dist/generated/rpc.d.ts +3763 -805
- package/dist/generated/rpc.js +400 -29
- package/dist/generated/session-events.d.ts +399 -20
- package/dist/index.d.ts +1 -1
- package/dist/session.d.ts +4 -2
- package/dist/session.js +19 -2
- package/dist/types.d.ts +29 -2
- 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
|
|
@@ -126,6 +127,96 @@ function createServerRpc(connection) {
|
|
|
126
127
|
*/
|
|
127
128
|
discover: async (params) => connection.sendRequest("mcp.discover", params)
|
|
128
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
|
+
},
|
|
129
220
|
skills: {
|
|
130
221
|
config: {
|
|
131
222
|
/**
|
|
@@ -142,7 +233,55 @@ function createServerRpc(connection) {
|
|
|
142
233
|
*
|
|
143
234
|
* @returns Skills discovered across global and project sources.
|
|
144
235
|
*/
|
|
145
|
-
discover: async (params) => connection.sendRequest("skills.discover", params)
|
|
236
|
+
discover: async (params) => connection.sendRequest("skills.discover", params),
|
|
237
|
+
/**
|
|
238
|
+
* Returns the canonical directories where a client may create skills that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
|
|
239
|
+
*
|
|
240
|
+
* @param params Optional project paths to enumerate.
|
|
241
|
+
*
|
|
242
|
+
* @returns Canonical locations where skills can be created so the runtime will recognize them.
|
|
243
|
+
*
|
|
244
|
+
* @experimental
|
|
245
|
+
*/
|
|
246
|
+
getDiscoveryPaths: async (params) => connection.sendRequest("skills.getDiscoveryPaths", params)
|
|
247
|
+
},
|
|
248
|
+
/** @experimental */
|
|
249
|
+
agents: {
|
|
250
|
+
/**
|
|
251
|
+
* Discovers custom agents across user, project, plugin, and remote sources.
|
|
252
|
+
*
|
|
253
|
+
* @param params Optional project paths to include in agent discovery.
|
|
254
|
+
*
|
|
255
|
+
* @returns Agents discovered across user, project, plugin, and remote sources.
|
|
256
|
+
*/
|
|
257
|
+
discover: async (params) => connection.sendRequest("agents.discover", params),
|
|
258
|
+
/**
|
|
259
|
+
* Returns the canonical directories where a client may create custom agents that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
|
|
260
|
+
*
|
|
261
|
+
* @param params Optional project paths to include when enumerating agent discovery directories.
|
|
262
|
+
*
|
|
263
|
+
* @returns Canonical locations where custom agents can be created so the runtime will recognize them.
|
|
264
|
+
*/
|
|
265
|
+
getDiscoveryPaths: async (params) => connection.sendRequest("agents.getDiscoveryPaths", params)
|
|
266
|
+
},
|
|
267
|
+
/** @experimental */
|
|
268
|
+
instructions: {
|
|
269
|
+
/**
|
|
270
|
+
* Discovers instruction sources across user, repository, and plugin sources.
|
|
271
|
+
*
|
|
272
|
+
* @param params Optional project paths to include in instruction discovery.
|
|
273
|
+
*
|
|
274
|
+
* @returns Instruction sources discovered across user, repository, and plugin sources.
|
|
275
|
+
*/
|
|
276
|
+
discover: async (params) => connection.sendRequest("instructions.discover", params),
|
|
277
|
+
/**
|
|
278
|
+
* Returns the canonical files and directories where a client may create custom instructions that the runtime will recognize, including ones that do not exist yet. Repository targets become active once created.
|
|
279
|
+
*
|
|
280
|
+
* @param params Optional project paths to include when enumerating instruction discovery targets.
|
|
281
|
+
*
|
|
282
|
+
* @returns Canonical files and directories where custom instructions can be created so the runtime will recognize them.
|
|
283
|
+
*/
|
|
284
|
+
getDiscoveryPaths: async (params) => connection.sendRequest("instructions.getDiscoveryPaths", params)
|
|
146
285
|
},
|
|
147
286
|
user: {
|
|
148
287
|
settings: {
|
|
@@ -170,6 +309,14 @@ function createServerRpc(connection) {
|
|
|
170
309
|
},
|
|
171
310
|
/** @experimental */
|
|
172
311
|
sessions: {
|
|
312
|
+
/**
|
|
313
|
+
* Creates or resumes a local session and returns the opened session ID.
|
|
314
|
+
*
|
|
315
|
+
* @param params Open a session by creating, resuming, attaching, connecting to a remote, or handing off.
|
|
316
|
+
*
|
|
317
|
+
* @returns Result of opening a session.
|
|
318
|
+
*/
|
|
319
|
+
open: async (params) => connection.sendRequest("sessions.open", params),
|
|
173
320
|
/**
|
|
174
321
|
* Creates a new session by forking persisted history from an existing session.
|
|
175
322
|
*
|
|
@@ -187,11 +334,11 @@ function createServerRpc(connection) {
|
|
|
187
334
|
*/
|
|
188
335
|
connect: async (params) => connection.sendRequest("sessions.connect", params),
|
|
189
336
|
/**
|
|
190
|
-
* Lists
|
|
337
|
+
* 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.).
|
|
191
338
|
*
|
|
192
|
-
* @param params Optional metadata-load limit and
|
|
339
|
+
* @param params Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
|
|
193
340
|
*
|
|
194
|
-
* @returns
|
|
341
|
+
* @returns Sessions matching the filter, ordered most-recently-modified first.
|
|
195
342
|
*/
|
|
196
343
|
list: async (params) => connection.sendRequest("sessions.list", params),
|
|
197
344
|
/**
|
|
@@ -218,14 +365,6 @@ function createServerRpc(connection) {
|
|
|
218
365
|
* @returns Most-relevant session ID for the supplied context, or omitted when no sessions exist.
|
|
219
366
|
*/
|
|
220
367
|
getLastForContext: async (params) => connection.sendRequest("sessions.getLastForContext", params),
|
|
221
|
-
/**
|
|
222
|
-
* Computes the absolute path to a session's persisted events.jsonl file.
|
|
223
|
-
*
|
|
224
|
-
* @param params Session ID whose event-log file path to compute.
|
|
225
|
-
*
|
|
226
|
-
* @returns Absolute path to the session's events.jsonl file on disk.
|
|
227
|
-
*/
|
|
228
|
-
getEventFilePath: async (params) => connection.sendRequest("sessions.getEventFilePath", params),
|
|
229
368
|
/**
|
|
230
369
|
* Returns the on-disk byte size of each session's workspace directory.
|
|
231
370
|
*
|
|
@@ -240,14 +379,6 @@ function createServerRpc(connection) {
|
|
|
240
379
|
* @returns Session IDs from the input set that are currently in use by another process.
|
|
241
380
|
*/
|
|
242
381
|
checkInUse: async (params) => connection.sendRequest("sessions.checkInUse", params),
|
|
243
|
-
/**
|
|
244
|
-
* Returns a session's persisted remote-steerable flag, if any has been recorded.
|
|
245
|
-
*
|
|
246
|
-
* @param params Session ID to look up the persisted remote-steerable flag for.
|
|
247
|
-
*
|
|
248
|
-
* @returns The session's persisted remote-steerable flag, or omitted when no value has been persisted.
|
|
249
|
-
*/
|
|
250
|
-
getPersistedRemoteSteerable: async (params) => connection.sendRequest("sessions.getPersistedRemoteSteerable", params),
|
|
251
382
|
/**
|
|
252
383
|
* Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
|
|
253
384
|
*
|
|
@@ -319,7 +450,45 @@ function createServerRpc(connection) {
|
|
|
319
450
|
*
|
|
320
451
|
* @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.
|
|
321
452
|
*/
|
|
322
|
-
setAdditionalPlugins: async (params) => connection.sendRequest("sessions.setAdditionalPlugins", params)
|
|
453
|
+
setAdditionalPlugins: async (params) => connection.sendRequest("sessions.setAdditionalPlugins", params),
|
|
454
|
+
/**
|
|
455
|
+
* 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.
|
|
456
|
+
*
|
|
457
|
+
* @param params Parameters for attaching the remote-control singleton to a session.
|
|
458
|
+
*
|
|
459
|
+
* @returns Wrapper for the singleton's current status.
|
|
460
|
+
*/
|
|
461
|
+
startRemoteControl: async (params) => connection.sendRequest("sessions.startRemoteControl", params),
|
|
462
|
+
/**
|
|
463
|
+
* 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.
|
|
464
|
+
*
|
|
465
|
+
* @param params Parameters for atomically rebinding the remote-control singleton.
|
|
466
|
+
*
|
|
467
|
+
* @returns Outcome of a transferRemoteControl call.
|
|
468
|
+
*/
|
|
469
|
+
transferRemoteControl: async (params) => connection.sendRequest("sessions.transferRemoteControl", params),
|
|
470
|
+
/**
|
|
471
|
+
* 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.
|
|
472
|
+
*
|
|
473
|
+
* @param params Patch for the singleton's steering state.
|
|
474
|
+
*
|
|
475
|
+
* @returns Wrapper for the singleton's current status.
|
|
476
|
+
*/
|
|
477
|
+
setRemoteControlSteering: async (params) => connection.sendRequest("sessions.setRemoteControlSteering", params),
|
|
478
|
+
/**
|
|
479
|
+
* 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).
|
|
480
|
+
*
|
|
481
|
+
* @param params Parameters for stopping the remote-control singleton.
|
|
482
|
+
*
|
|
483
|
+
* @returns Outcome of a stopRemoteControl call.
|
|
484
|
+
*/
|
|
485
|
+
stopRemoteControl: async (params) => connection.sendRequest("sessions.stopRemoteControl", params),
|
|
486
|
+
/**
|
|
487
|
+
* Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
|
|
488
|
+
*
|
|
489
|
+
* @returns Wrapper for the singleton's current status.
|
|
490
|
+
*/
|
|
491
|
+
getRemoteControlStatus: async () => connection.sendRequest("sessions.getRemoteControlStatus", {})
|
|
323
492
|
},
|
|
324
493
|
/** @experimental */
|
|
325
494
|
agentRegistry: {
|
|
@@ -337,13 +506,62 @@ function createServerRpc(connection) {
|
|
|
337
506
|
function createInternalServerRpc(connection) {
|
|
338
507
|
return {
|
|
339
508
|
/**
|
|
340
|
-
* Performs the SDK server connection handshake and validates the optional connection token.
|
|
509
|
+
* 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.
|
|
341
510
|
*
|
|
342
511
|
* @param params Optional connection token presented by the SDK client during the handshake.
|
|
343
512
|
*
|
|
344
513
|
* @returns Handshake result reporting the server's protocol version and package version on success.
|
|
345
514
|
*/
|
|
346
|
-
connect: async (params) => connection.sendRequest("connect", params)
|
|
515
|
+
connect: async (params) => connection.sendRequest("connect", params),
|
|
516
|
+
/** @experimental */
|
|
517
|
+
sessions: {
|
|
518
|
+
/**
|
|
519
|
+
* 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.
|
|
520
|
+
*
|
|
521
|
+
* @param params Session ID whose event-log file path to compute.
|
|
522
|
+
*
|
|
523
|
+
* @returns Absolute path to the session's events.jsonl file on disk.
|
|
524
|
+
*/
|
|
525
|
+
getEventFilePath: async (params) => connection.sendRequest("sessions.getEventFilePath", params),
|
|
526
|
+
/**
|
|
527
|
+
* 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.
|
|
528
|
+
*
|
|
529
|
+
* @param params Session ID to look up the persisted remote-steerable flag for.
|
|
530
|
+
*
|
|
531
|
+
* @returns The session's persisted remote-steerable flag, or omitted when no value has been persisted.
|
|
532
|
+
*/
|
|
533
|
+
getPersistedRemoteSteerable: async (params) => connection.sendRequest("sessions.getPersistedRemoteSteerable", params),
|
|
534
|
+
/**
|
|
535
|
+
* 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.
|
|
536
|
+
*
|
|
537
|
+
* @param params Session ID whose board entry count should be returned.
|
|
538
|
+
*
|
|
539
|
+
* @returns Dynamic-context board entry count, when available.
|
|
540
|
+
*/
|
|
541
|
+
getBoardEntryCount: async (params) => connection.sendRequest("sessions.getBoardEntryCount", params),
|
|
542
|
+
/**
|
|
543
|
+
* 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.
|
|
544
|
+
*
|
|
545
|
+
* @param params Cursor and optional long-poll wait for polling runtime-spawned sessions.
|
|
546
|
+
*
|
|
547
|
+
* @returns Batch of spawn events plus a cursor for follow-up polls.
|
|
548
|
+
*/
|
|
549
|
+
pollSpawnedSessions: async (params) => connection.sendRequest("sessions.pollSpawnedSessions", params),
|
|
550
|
+
/**
|
|
551
|
+
* 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.
|
|
552
|
+
*
|
|
553
|
+
* @param params Params to attach an extension loader's tools to a session.
|
|
554
|
+
*
|
|
555
|
+
* @returns Handle for releasing the extension tool registration.
|
|
556
|
+
*/
|
|
557
|
+
registerExtensionToolsOnSession: async (params) => connection.sendRequest("sessions.registerExtensionToolsOnSession", params),
|
|
558
|
+
/**
|
|
559
|
+
* 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.
|
|
560
|
+
*
|
|
561
|
+
* @param params Params to attach or detach an in-process ExtensionController delegate.
|
|
562
|
+
*/
|
|
563
|
+
configureSessionExtensions: async (params) => connection.sendRequest("sessions.configureSessionExtensions", params)
|
|
564
|
+
}
|
|
347
565
|
};
|
|
348
566
|
}
|
|
349
567
|
function createSessionRpc(connection, sessionId) {
|
|
@@ -527,7 +745,19 @@ function createSessionRpc(connection, sessionId) {
|
|
|
527
745
|
/**
|
|
528
746
|
* Deletes the session plan file from the workspace.
|
|
529
747
|
*/
|
|
530
|
-
delete: async () => connection.sendRequest("session.plan.delete", { sessionId })
|
|
748
|
+
delete: async () => connection.sendRequest("session.plan.delete", { sessionId }),
|
|
749
|
+
/**
|
|
750
|
+
* Reads todo rows from the session SQL database for plan rendering.
|
|
751
|
+
*
|
|
752
|
+
* @returns Todo rows read from the session SQL database. Empty when no session database is available.
|
|
753
|
+
*/
|
|
754
|
+
readSqlTodos: async () => connection.sendRequest("session.plan.readSqlTodos", { sessionId }),
|
|
755
|
+
/**
|
|
756
|
+
* Reads todo rows AND dependency edges from the session SQL database for structured progress UI. Same defensive behavior as readSqlTodos — returns empty arrays when the database, tables, or columns aren't available. Clients should call this on session start and after every `session.todos_changed` event to refresh structured-UI rendering.
|
|
757
|
+
*
|
|
758
|
+
* @returns Todo rows + dependency edges read from the session SQL database.
|
|
759
|
+
*/
|
|
760
|
+
readSqlTodosWithDependencies: async () => connection.sendRequest("session.plan.readSqlTodosWithDependencies", { sessionId })
|
|
531
761
|
},
|
|
532
762
|
/** @experimental */
|
|
533
763
|
workspaces: {
|
|
@@ -762,11 +992,19 @@ function createSessionRpc(connection, sessionId) {
|
|
|
762
992
|
/** @experimental */
|
|
763
993
|
mcp: {
|
|
764
994
|
/**
|
|
765
|
-
* Lists MCP servers configured for the session
|
|
995
|
+
* 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.
|
|
766
996
|
*
|
|
767
|
-
* @returns MCP servers configured for the session, with their connection status.
|
|
997
|
+
* @returns MCP servers configured for the session, with their connection status and host-level state.
|
|
768
998
|
*/
|
|
769
999
|
list: async () => connection.sendRequest("session.mcp.list", { sessionId }),
|
|
1000
|
+
/**
|
|
1001
|
+
* Lists the tools exposed by a connected MCP server on this session's host.
|
|
1002
|
+
*
|
|
1003
|
+
* @param params Server name whose tool list should be returned.
|
|
1004
|
+
*
|
|
1005
|
+
* @returns Tools exposed by the connected MCP server. Throws when the server is not connected.
|
|
1006
|
+
*/
|
|
1007
|
+
listTools: async (params) => connection.sendRequest("session.mcp.listTools", { sessionId, ...params }),
|
|
770
1008
|
/**
|
|
771
1009
|
* Enables an MCP server for the session.
|
|
772
1010
|
*
|
|
@@ -813,6 +1051,20 @@ function createSessionRpc(connection, sessionId) {
|
|
|
813
1051
|
* @returns Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
|
|
814
1052
|
*/
|
|
815
1053
|
removeGitHub: async () => connection.sendRequest("session.mcp.removeGitHub", { sessionId }),
|
|
1054
|
+
/**
|
|
1055
|
+
* Stops an individual MCP server on the session's host.
|
|
1056
|
+
*
|
|
1057
|
+
* @param params Server name for an individual MCP server stop.
|
|
1058
|
+
*/
|
|
1059
|
+
stopServer: async (params) => connection.sendRequest("session.mcp.stopServer", { sessionId, ...params }),
|
|
1060
|
+
/**
|
|
1061
|
+
* Checks whether a named MCP server is currently running on the session's host.
|
|
1062
|
+
*
|
|
1063
|
+
* @param params Server name to check running status for.
|
|
1064
|
+
*
|
|
1065
|
+
* @returns Whether the named MCP server is running.
|
|
1066
|
+
*/
|
|
1067
|
+
isServerRunning: async (params) => connection.sendRequest("session.mcp.isServerRunning", { sessionId, ...params }),
|
|
816
1068
|
/** @experimental */
|
|
817
1069
|
oauth: {
|
|
818
1070
|
/**
|
|
@@ -879,7 +1131,24 @@ function createSessionRpc(connection, sessionId) {
|
|
|
879
1131
|
*
|
|
880
1132
|
* @returns Plugins installed for the session, with their enabled state and version metadata.
|
|
881
1133
|
*/
|
|
882
|
-
list: async () => connection.sendRequest("session.plugins.list", { sessionId })
|
|
1134
|
+
list: async () => connection.sendRequest("session.plugins.list", { sessionId }),
|
|
1135
|
+
/**
|
|
1136
|
+
* 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.
|
|
1137
|
+
*
|
|
1138
|
+
* @param params Optional flags controlling which side effects the reload performs.
|
|
1139
|
+
*/
|
|
1140
|
+
reload: async (params) => connection.sendRequest("session.plugins.reload", { sessionId, ...params })
|
|
1141
|
+
},
|
|
1142
|
+
/** @experimental */
|
|
1143
|
+
provider: {
|
|
1144
|
+
/**
|
|
1145
|
+
* Returns the provider endpoint and credentials the session is currently configured to talk to, so the caller can make inference calls directly against the same backend the session uses.
|
|
1146
|
+
*
|
|
1147
|
+
* @param params Optional model identifier to scope the endpoint snapshot to.
|
|
1148
|
+
*
|
|
1149
|
+
* @returns A snapshot of the provider endpoint the session is currently configured to talk to.
|
|
1150
|
+
*/
|
|
1151
|
+
getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { sessionId, ...params })
|
|
883
1152
|
},
|
|
884
1153
|
/** @experimental */
|
|
885
1154
|
options: {
|
|
@@ -953,7 +1222,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
953
1222
|
*
|
|
954
1223
|
* @returns Current lightweight tool metadata snapshot for the session.
|
|
955
1224
|
*/
|
|
956
|
-
getCurrentMetadata: async () => connection.sendRequest("session.tools.getCurrentMetadata", { sessionId })
|
|
1225
|
+
getCurrentMetadata: async () => connection.sendRequest("session.tools.getCurrentMetadata", { sessionId }),
|
|
1226
|
+
/**
|
|
1227
|
+
* Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
|
|
1228
|
+
*
|
|
1229
|
+
* @param params Subagent settings to apply to the current session
|
|
1230
|
+
*
|
|
1231
|
+
* @returns Empty result after applying subagent settings
|
|
1232
|
+
*/
|
|
1233
|
+
updateSubagentSettings: async (params) => connection.sendRequest("session.tools.updateSubagentSettings", { sessionId, ...params })
|
|
957
1234
|
},
|
|
958
1235
|
/** @experimental */
|
|
959
1236
|
commands: {
|
|
@@ -1008,6 +1285,12 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1008
1285
|
},
|
|
1009
1286
|
/** @experimental */
|
|
1010
1287
|
telemetry: {
|
|
1288
|
+
/**
|
|
1289
|
+
* Gets the telemetry engagement ID currently associated with the session, when available.
|
|
1290
|
+
*
|
|
1291
|
+
* @returns Telemetry engagement ID for the session, when available.
|
|
1292
|
+
*/
|
|
1293
|
+
getEngagementId: async () => connection.sendRequest("session.telemetry.getEngagementId", { sessionId }),
|
|
1011
1294
|
/**
|
|
1012
1295
|
* Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
|
|
1013
1296
|
*
|
|
@@ -1017,6 +1300,14 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1017
1300
|
},
|
|
1018
1301
|
/** @experimental */
|
|
1019
1302
|
ui: {
|
|
1303
|
+
/**
|
|
1304
|
+
* Runs a transient no-tools model query against the current conversation context.
|
|
1305
|
+
*
|
|
1306
|
+
* @param params Transient question to answer without adding it to conversation history.
|
|
1307
|
+
*
|
|
1308
|
+
* @returns Transient answer generated from current conversation context.
|
|
1309
|
+
*/
|
|
1310
|
+
ephemeralQuery: async (params) => connection.sendRequest("session.ui.ephemeralQuery", { sessionId, ...params }),
|
|
1020
1311
|
/**
|
|
1021
1312
|
* Requests structured input from a UI-capable client.
|
|
1022
1313
|
*
|
|
@@ -1279,6 +1570,12 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1279
1570
|
* @returns Indicates whether the local session is currently processing a turn or background continuation.
|
|
1280
1571
|
*/
|
|
1281
1572
|
isProcessing: async () => connection.sendRequest("session.metadata.isProcessing", { sessionId }),
|
|
1573
|
+
/**
|
|
1574
|
+
* Returns a snapshot of activity flags for the session.
|
|
1575
|
+
*
|
|
1576
|
+
* @returns Current activity flags for the session.
|
|
1577
|
+
*/
|
|
1578
|
+
activity: async () => connection.sendRequest("session.metadata.activity", { sessionId }),
|
|
1282
1579
|
/**
|
|
1283
1580
|
* Returns the token breakdown for the session's current context window for a given model.
|
|
1284
1581
|
*
|
|
@@ -1329,7 +1626,23 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1329
1626
|
*
|
|
1330
1627
|
* @returns Indicates whether the signal was delivered; false if the process was unknown or already exited.
|
|
1331
1628
|
*/
|
|
1332
|
-
kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params })
|
|
1629
|
+
kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params }),
|
|
1630
|
+
/**
|
|
1631
|
+
* Executes a user-requested shell command through the session runtime.
|
|
1632
|
+
*
|
|
1633
|
+
* @param params User-requested shell command and cancellation handle.
|
|
1634
|
+
*
|
|
1635
|
+
* @returns Result of a user-requested shell command.
|
|
1636
|
+
*/
|
|
1637
|
+
executeUserRequested: async (params) => connection.sendRequest("session.shell.executeUserRequested", { sessionId, ...params }),
|
|
1638
|
+
/**
|
|
1639
|
+
* Cancels a user-requested shell command by request ID.
|
|
1640
|
+
*
|
|
1641
|
+
* @param params User-requested shell execution cancellation handle.
|
|
1642
|
+
*
|
|
1643
|
+
* @returns Cancellation result for a user-requested shell command.
|
|
1644
|
+
*/
|
|
1645
|
+
cancelUserRequested: async (params) => connection.sendRequest("session.shell.cancelUserRequested", { sessionId, ...params })
|
|
1333
1646
|
},
|
|
1334
1647
|
/** @experimental */
|
|
1335
1648
|
history: {
|
|
@@ -1471,6 +1784,64 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1471
1784
|
}
|
|
1472
1785
|
};
|
|
1473
1786
|
}
|
|
1787
|
+
function createInternalSessionRpc(connection, sessionId) {
|
|
1788
|
+
return {
|
|
1789
|
+
/** @experimental */
|
|
1790
|
+
mcp: {
|
|
1791
|
+
/**
|
|
1792
|
+
* Reloads MCP server connections for the session with an explicit host-provided configuration.
|
|
1793
|
+
*
|
|
1794
|
+
* @param params Opaque MCP reload configuration.
|
|
1795
|
+
*
|
|
1796
|
+
* @returns MCP server startup filtering result.
|
|
1797
|
+
*/
|
|
1798
|
+
reloadWithConfig: async (params) => connection.sendRequest("session.mcp.reloadWithConfig", { sessionId, ...params }),
|
|
1799
|
+
/**
|
|
1800
|
+
* Configures the built-in GitHub MCP server for the session's current auth context.
|
|
1801
|
+
*
|
|
1802
|
+
* @param params Opaque auth info used to configure GitHub MCP.
|
|
1803
|
+
*
|
|
1804
|
+
* @returns Result of configuring GitHub MCP.
|
|
1805
|
+
*/
|
|
1806
|
+
configureGitHub: async (params) => connection.sendRequest("session.mcp.configureGitHub", { sessionId, ...params }),
|
|
1807
|
+
/**
|
|
1808
|
+
* Starts an individual MCP server on the session's host.
|
|
1809
|
+
*
|
|
1810
|
+
* @param params Server name and opaque configuration for an individual MCP server start.
|
|
1811
|
+
*/
|
|
1812
|
+
startServer: async (params) => connection.sendRequest("session.mcp.startServer", { sessionId, ...params }),
|
|
1813
|
+
/**
|
|
1814
|
+
* Restarts an individual MCP server on the session's host (stops then starts).
|
|
1815
|
+
*
|
|
1816
|
+
* @param params Server name and opaque configuration for an individual MCP server restart.
|
|
1817
|
+
*/
|
|
1818
|
+
restartServer: async (params) => connection.sendRequest("session.mcp.restartServer", { sessionId, ...params }),
|
|
1819
|
+
/**
|
|
1820
|
+
* 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.
|
|
1821
|
+
*
|
|
1822
|
+
* @param params Registration parameters for an external MCP client.
|
|
1823
|
+
*/
|
|
1824
|
+
registerExternalClient: async (params) => connection.sendRequest("session.mcp.registerExternalClient", { sessionId, ...params }),
|
|
1825
|
+
/**
|
|
1826
|
+
* 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.
|
|
1827
|
+
*
|
|
1828
|
+
* @param params Server name identifying the external client to remove.
|
|
1829
|
+
*/
|
|
1830
|
+
unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params }),
|
|
1831
|
+
/** @experimental */
|
|
1832
|
+
oauth: {
|
|
1833
|
+
/**
|
|
1834
|
+
* 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.
|
|
1835
|
+
*
|
|
1836
|
+
* @param params MCP OAuth request id and optional provider response.
|
|
1837
|
+
*
|
|
1838
|
+
* @returns Empty result after recording the MCP OAuth response.
|
|
1839
|
+
*/
|
|
1840
|
+
respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { sessionId, ...params })
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1474
1845
|
function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
1475
1846
|
connection.onRequest("sessionFs.readFile", async (params) => {
|
|
1476
1847
|
const handler = getHandlers(params.sessionId).sessionFs;
|
|
@@ -1551,6 +1922,7 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
1551
1922
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1552
1923
|
0 && (module.exports = {
|
|
1553
1924
|
createInternalServerRpc,
|
|
1925
|
+
createInternalSessionRpc,
|
|
1554
1926
|
createServerRpc,
|
|
1555
1927
|
createSessionRpc,
|
|
1556
1928
|
registerClientSessionApiHandlers
|
package/dist/cjs/session.js
CHANGED
|
@@ -56,6 +56,9 @@ class CopilotSession {
|
|
|
56
56
|
this._workspacePath = _workspacePath;
|
|
57
57
|
this.traceContextProvider = traceContextProvider;
|
|
58
58
|
}
|
|
59
|
+
sessionId;
|
|
60
|
+
connection;
|
|
61
|
+
_workspacePath;
|
|
59
62
|
eventHandlers = /* @__PURE__ */ new Set();
|
|
60
63
|
typedEventHandlers = /* @__PURE__ */ new Map();
|
|
61
64
|
toolHandlers = /* @__PURE__ */ new Map();
|
|
@@ -276,6 +279,8 @@ class CopilotSession {
|
|
|
276
279
|
this._capabilities = { ...this._capabilities, ...event.data };
|
|
277
280
|
} else if (event.type === "session.canvas.opened") {
|
|
278
281
|
this.upsertOpenCanvasFromEvent(event.data);
|
|
282
|
+
} else if (event.type === "session.canvas.closed") {
|
|
283
|
+
this.removeOpenCanvasFromEvent(event.data);
|
|
279
284
|
}
|
|
280
285
|
}
|
|
281
286
|
upsertOpenCanvasFromEvent(data) {
|
|
@@ -285,6 +290,18 @@ class CopilotSession {
|
|
|
285
290
|
}
|
|
286
291
|
this.upsertOpenCanvas(data);
|
|
287
292
|
}
|
|
293
|
+
removeOpenCanvasFromEvent(data) {
|
|
294
|
+
if (!data || typeof data !== "object" || typeof data.instanceId !== "string" || data.instanceId.length === 0) {
|
|
295
|
+
console.warn("failed to deserialize session.canvas.closed payload");
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
this.removeOpenCanvas(data.instanceId);
|
|
299
|
+
}
|
|
300
|
+
removeOpenCanvas(instanceId) {
|
|
301
|
+
this.openCanvasInstances = this.openCanvasInstances.filter(
|
|
302
|
+
(open) => open.instanceId !== instanceId
|
|
303
|
+
);
|
|
304
|
+
}
|
|
288
305
|
upsertOpenCanvas(instance) {
|
|
289
306
|
const index = this.openCanvasInstances.findIndex(
|
|
290
307
|
(open) => open.instanceId === instance.instanceId
|
|
@@ -576,8 +593,8 @@ class CopilotSession {
|
|
|
576
593
|
/**
|
|
577
594
|
* Snapshot of canvas instances currently known to be open for this session.
|
|
578
595
|
* Populated from the `session.resume` response and live `session.canvas.opened`
|
|
579
|
-
* events. Returns a defensive copy — mutating the
|
|
580
|
-
* on the session.
|
|
596
|
+
* and `session.canvas.closed` events. Returns a defensive copy — mutating the
|
|
597
|
+
* returned array has no effect on the session.
|
|
581
598
|
*/
|
|
582
599
|
get openCanvases() {
|
|
583
600
|
return [...this.openCanvasInstances];
|
package/dist/client.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export declare class CopilotClient {
|
|
|
72
72
|
* @throws Error if the client is not connected
|
|
73
73
|
*/
|
|
74
74
|
get rpc(): ReturnType<typeof createServerRpc>;
|
|
75
|
+
private logDebugTiming;
|
|
75
76
|
/**
|
|
76
77
|
* Creates a new CopilotClient instance.
|
|
77
78
|
*
|
|
@@ -132,8 +133,9 @@ export declare class CopilotClient {
|
|
|
132
133
|
*
|
|
133
134
|
* This method performs graceful cleanup:
|
|
134
135
|
* 1. Closes all active sessions (releases in-memory resources)
|
|
135
|
-
* 2.
|
|
136
|
-
* 3.
|
|
136
|
+
* 2. Requests runtime shutdown for SDK-owned CLI processes
|
|
137
|
+
* 3. Closes the JSON-RPC connection
|
|
138
|
+
* 4. Terminates the CLI server process (if spawned by this client)
|
|
137
139
|
*
|
|
138
140
|
* Note: session data on disk is preserved, so sessions can be resumed later.
|
|
139
141
|
* To permanently remove session data before stopping, call
|