@github/copilot-sdk 1.0.0 → 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 CHANGED
@@ -1035,7 +1035,7 @@ try {
1035
1035
 
1036
1036
  ## Requirements
1037
1037
 
1038
- - Node.js >= 18.0.0
1038
+ - Node.js ^20.19.0 or >=22.12.0
1039
1039
  - GitHub Copilot CLI installed and in PATH (or provide a custom `connection`)
1040
1040
 
1041
1041
  ## License
@@ -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
  /**
@@ -144,6 +235,28 @@ function createServerRpc(connection) {
144
235
  */
145
236
  discover: async (params) => connection.sendRequest("skills.discover", params)
146
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
+ },
147
260
  user: {
148
261
  settings: {
149
262
  /**
@@ -170,6 +283,14 @@ function createServerRpc(connection) {
170
283
  },
171
284
  /** @experimental */
172
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),
173
294
  /**
174
295
  * Creates a new session by forking persisted history from an existing session.
175
296
  *
@@ -187,11 +308,11 @@ function createServerRpc(connection) {
187
308
  */
188
309
  connect: async (params) => connection.sendRequest("sessions.connect", params),
189
310
  /**
190
- * Lists persisted sessions, optionally filtered by working-directory context.
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.).
191
312
  *
192
- * @param params Optional metadata-load limit and filters applied to the returned sessions.
313
+ * @param params Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
193
314
  *
194
- * @returns Persisted sessions matching the filter, ordered most-recently-modified first.
315
+ * @returns Sessions matching the filter, ordered most-recently-modified first.
195
316
  */
196
317
  list: async (params) => connection.sendRequest("sessions.list", params),
197
318
  /**
@@ -218,14 +339,6 @@ function createServerRpc(connection) {
218
339
  * @returns Most-relevant session ID for the supplied context, or omitted when no sessions exist.
219
340
  */
220
341
  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
342
  /**
230
343
  * Returns the on-disk byte size of each session's workspace directory.
231
344
  *
@@ -240,14 +353,6 @@ function createServerRpc(connection) {
240
353
  * @returns Session IDs from the input set that are currently in use by another process.
241
354
  */
242
355
  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
356
  /**
252
357
  * Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
253
358
  *
@@ -319,7 +424,45 @@ function createServerRpc(connection) {
319
424
  *
320
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.
321
426
  */
322
- 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", {})
323
466
  },
324
467
  /** @experimental */
325
468
  agentRegistry: {
@@ -337,13 +480,62 @@ function createServerRpc(connection) {
337
480
  function createInternalServerRpc(connection) {
338
481
  return {
339
482
  /**
340
- * 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.
341
484
  *
342
485
  * @param params Optional connection token presented by the SDK client during the handshake.
343
486
  *
344
487
  * @returns Handshake result reporting the server's protocol version and package version on success.
345
488
  */
346
- 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
+ }
347
539
  };
348
540
  }
349
541
  function createSessionRpc(connection, sessionId) {
@@ -527,7 +719,13 @@ function createSessionRpc(connection, sessionId) {
527
719
  /**
528
720
  * Deletes the session plan file from the workspace.
529
721
  */
530
- 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 })
531
729
  },
532
730
  /** @experimental */
533
731
  workspaces: {
@@ -762,11 +960,19 @@ function createSessionRpc(connection, sessionId) {
762
960
  /** @experimental */
763
961
  mcp: {
764
962
  /**
765
- * Lists MCP servers configured for the session and their connection status.
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.
766
964
  *
767
- * @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.
768
966
  */
769
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 }),
770
976
  /**
771
977
  * Enables an MCP server for the session.
772
978
  *
@@ -813,6 +1019,20 @@ function createSessionRpc(connection, sessionId) {
813
1019
  * @returns Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
814
1020
  */
815
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 }),
816
1036
  /** @experimental */
817
1037
  oauth: {
818
1038
  /**
@@ -879,7 +1099,13 @@ function createSessionRpc(connection, sessionId) {
879
1099
  *
880
1100
  * @returns Plugins installed for the session, with their enabled state and version metadata.
881
1101
  */
882
- 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 })
883
1109
  },
884
1110
  /** @experimental */
885
1111
  options: {
@@ -1008,6 +1234,12 @@ function createSessionRpc(connection, sessionId) {
1008
1234
  },
1009
1235
  /** @experimental */
1010
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 }),
1011
1243
  /**
1012
1244
  * Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
1013
1245
  *
@@ -1017,6 +1249,14 @@ function createSessionRpc(connection, sessionId) {
1017
1249
  },
1018
1250
  /** @experimental */
1019
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 }),
1020
1260
  /**
1021
1261
  * Requests structured input from a UI-capable client.
1022
1262
  *
@@ -1279,6 +1519,12 @@ function createSessionRpc(connection, sessionId) {
1279
1519
  * @returns Indicates whether the local session is currently processing a turn or background continuation.
1280
1520
  */
1281
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 }),
1282
1528
  /**
1283
1529
  * Returns the token breakdown for the session's current context window for a given model.
1284
1530
  *
@@ -1329,7 +1575,23 @@ function createSessionRpc(connection, sessionId) {
1329
1575
  *
1330
1576
  * @returns Indicates whether the signal was delivered; false if the process was unknown or already exited.
1331
1577
  */
1332
- 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 })
1333
1595
  },
1334
1596
  /** @experimental */
1335
1597
  history: {
@@ -1471,6 +1733,64 @@ function createSessionRpc(connection, sessionId) {
1471
1733
  }
1472
1734
  };
1473
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
+ }
1474
1794
  function registerClientSessionApiHandlers(connection, getHandlers) {
1475
1795
  connection.onRequest("sessionFs.readFile", async (params) => {
1476
1796
  const handler = getHandlers(params.sessionId).sessionFs;
@@ -1551,6 +1871,7 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
1551
1871
  // Annotate the CommonJS export names for ESM import in node:
1552
1872
  0 && (module.exports = {
1553
1873
  createInternalServerRpc,
1874
+ createInternalSessionRpc,
1554
1875
  createServerRpc,
1555
1876
  createSessionRpc,
1556
1877
  registerClientSessionApiHandlers
@@ -276,6 +276,8 @@ class CopilotSession {
276
276
  this._capabilities = { ...this._capabilities, ...event.data };
277
277
  } else if (event.type === "session.canvas.opened") {
278
278
  this.upsertOpenCanvasFromEvent(event.data);
279
+ } else if (event.type === "session.canvas.closed") {
280
+ this.removeOpenCanvasFromEvent(event.data);
279
281
  }
280
282
  }
281
283
  upsertOpenCanvasFromEvent(data) {
@@ -285,6 +287,18 @@ class CopilotSession {
285
287
  }
286
288
  this.upsertOpenCanvas(data);
287
289
  }
290
+ removeOpenCanvasFromEvent(data) {
291
+ if (!data || typeof data !== "object" || typeof data.instanceId !== "string" || data.instanceId.length === 0) {
292
+ console.warn("failed to deserialize session.canvas.closed payload");
293
+ return;
294
+ }
295
+ this.removeOpenCanvas(data.instanceId);
296
+ }
297
+ removeOpenCanvas(instanceId) {
298
+ this.openCanvasInstances = this.openCanvasInstances.filter(
299
+ (open) => open.instanceId !== instanceId
300
+ );
301
+ }
288
302
  upsertOpenCanvas(instance) {
289
303
  const index = this.openCanvasInstances.findIndex(
290
304
  (open) => open.instanceId === instance.instanceId
@@ -576,8 +590,8 @@ class CopilotSession {
576
590
  /**
577
591
  * Snapshot of canvas instances currently known to be open for this session.
578
592
  * Populated from the `session.resume` response and live `session.canvas.opened`
579
- * events. Returns a defensive copy — mutating the returned array has no effect
580
- * on the session.
593
+ * and `session.canvas.closed` events. Returns a defensive copy — mutating the
594
+ * returned array has no effect on the session.
581
595
  */
582
596
  get openCanvases() {
583
597
  return [...this.openCanvasInstances];