@github/copilot-sdk 1.0.0-beta.1 → 1.0.0-beta.11

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.
@@ -1,155 +1,1447 @@
1
1
  function createServerRpc(connection) {
2
2
  return {
3
+ /**
4
+ * Checks server responsiveness and returns protocol information.
5
+ *
6
+ * @param params Optional message to echo back to the caller.
7
+ *
8
+ * @returns Server liveness response, including the echoed message, current server timestamp, and protocol version.
9
+ */
3
10
  ping: async (params) => connection.sendRequest("ping", params),
4
11
  models: {
12
+ /**
13
+ * Lists Copilot models available to the authenticated user.
14
+ *
15
+ * @param params Optional GitHub token used to list models for a specific user instead of the global auth context.
16
+ *
17
+ * @returns List of Copilot models available to the resolved user, including capabilities and billing metadata.
18
+ */
5
19
  list: async (params) => connection.sendRequest("models.list", params)
6
20
  },
7
21
  tools: {
22
+ /**
23
+ * Lists built-in tools available for a model.
24
+ *
25
+ * @param params Optional model identifier whose tool overrides should be applied to the listing.
26
+ *
27
+ * @returns Built-in tools available for the requested model, with their parameters and instructions.
28
+ */
8
29
  list: async (params) => connection.sendRequest("tools.list", params)
9
30
  },
10
31
  account: {
32
+ /**
33
+ * Gets Copilot quota usage for the authenticated user or supplied GitHub token.
34
+ *
35
+ * @param params Optional GitHub token used to look up quota for a specific user instead of the global auth context.
36
+ *
37
+ * @returns Quota usage snapshots for the resolved user, keyed by quota type.
38
+ */
11
39
  getQuota: async (params) => connection.sendRequest("account.getQuota", params)
12
40
  },
41
+ secrets: {
42
+ /**
43
+ * Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
44
+ *
45
+ * @param params Secret values to add to the redaction filter.
46
+ *
47
+ * @returns Confirmation that the secret values were registered.
48
+ */
49
+ addFilterValues: async (params) => connection.sendRequest("secrets.addFilterValues", params)
50
+ },
13
51
  mcp: {
14
52
  config: {
53
+ /**
54
+ * Lists MCP servers from user configuration.
55
+ *
56
+ * @returns User-configured MCP servers, keyed by server name.
57
+ */
15
58
  list: async () => connection.sendRequest("mcp.config.list", {}),
59
+ /**
60
+ * Adds an MCP server to user configuration.
61
+ *
62
+ * @param params MCP server name and configuration to add to user configuration.
63
+ */
16
64
  add: async (params) => connection.sendRequest("mcp.config.add", params),
65
+ /**
66
+ * Updates an MCP server in user configuration.
67
+ *
68
+ * @param params MCP server name and replacement configuration to write to user configuration.
69
+ */
17
70
  update: async (params) => connection.sendRequest("mcp.config.update", params),
71
+ /**
72
+ * Removes an MCP server from user configuration.
73
+ *
74
+ * @param params MCP server name to remove from user configuration.
75
+ */
18
76
  remove: async (params) => connection.sendRequest("mcp.config.remove", params),
77
+ /**
78
+ * Enables MCP servers in user configuration for new sessions.
79
+ *
80
+ * @param params MCP server names to enable for new sessions.
81
+ */
19
82
  enable: async (params) => connection.sendRequest("mcp.config.enable", params),
20
- disable: async (params) => connection.sendRequest("mcp.config.disable", params)
83
+ /**
84
+ * Disables MCP servers in user configuration for new sessions.
85
+ *
86
+ * @param params MCP server names to disable for new sessions.
87
+ */
88
+ disable: async (params) => connection.sendRequest("mcp.config.disable", params),
89
+ /**
90
+ * Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
91
+ */
92
+ reload: async () => connection.sendRequest("mcp.config.reload", {})
21
93
  },
94
+ /**
95
+ * Discovers MCP servers from user, workspace, plugin, and builtin sources.
96
+ *
97
+ * @param params Optional working directory used as context for MCP server discovery.
98
+ *
99
+ * @returns MCP servers discovered from user, workspace, plugin, and built-in sources.
100
+ */
22
101
  discover: async (params) => connection.sendRequest("mcp.discover", params)
23
102
  },
24
103
  skills: {
25
104
  config: {
105
+ /**
106
+ * Replaces the global list of disabled skills.
107
+ *
108
+ * @param params Skill names to mark as disabled in global configuration, replacing any previous list.
109
+ */
26
110
  setDisabledSkills: async (params) => connection.sendRequest("skills.config.setDisabledSkills", params)
27
111
  },
112
+ /**
113
+ * Discovers skills across global and project sources.
114
+ *
115
+ * @param params Optional project paths and additional skill directories to include in discovery.
116
+ *
117
+ * @returns Skills discovered across global and project sources.
118
+ */
28
119
  discover: async (params) => connection.sendRequest("skills.discover", params)
29
120
  },
121
+ user: {
122
+ settings: {
123
+ /**
124
+ * Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
125
+ */
126
+ reload: async () => connection.sendRequest("user.settings.reload", {})
127
+ }
128
+ },
129
+ runtime: {
130
+ /**
131
+ * Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
132
+ */
133
+ shutdown: async () => connection.sendRequest("runtime.shutdown", {})
134
+ },
30
135
  sessionFs: {
136
+ /**
137
+ * Registers an SDK client as the session filesystem provider.
138
+ *
139
+ * @param params Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
140
+ *
141
+ * @returns Indicates whether the calling client was registered as the session filesystem provider.
142
+ */
31
143
  setProvider: async (params) => connection.sendRequest("sessionFs.setProvider", params)
32
144
  },
33
145
  /** @experimental */
34
146
  sessions: {
35
- fork: async (params) => connection.sendRequest("sessions.fork", params)
147
+ /**
148
+ * Creates a new session by forking persisted history from an existing session.
149
+ *
150
+ * @param params Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
151
+ *
152
+ * @returns Identifier and optional friendly name assigned to the newly forked session.
153
+ */
154
+ fork: async (params) => connection.sendRequest("sessions.fork", params),
155
+ /**
156
+ * Connects to an existing remote session and exposes it as an SDK session.
157
+ *
158
+ * @param params Remote session connection parameters.
159
+ *
160
+ * @returns Remote session connection result.
161
+ */
162
+ connect: async (params) => connection.sendRequest("sessions.connect", params),
163
+ /**
164
+ * Lists persisted sessions, optionally filtered by working-directory context.
165
+ *
166
+ * @param params Optional metadata-load limit and filters applied to the returned sessions.
167
+ *
168
+ * @returns Persisted sessions matching the filter, ordered most-recently-modified first.
169
+ */
170
+ list: async (params) => connection.sendRequest("sessions.list", params),
171
+ /**
172
+ * Finds the local session bound to a GitHub task ID, if any.
173
+ *
174
+ * @param params GitHub task ID to look up.
175
+ *
176
+ * @returns ID of the local session bound to the given GitHub task, or omitted when none.
177
+ */
178
+ findByTaskId: async (params) => connection.sendRequest("sessions.findByTaskId", params),
179
+ /**
180
+ * Resolves a UUID prefix to a unique session ID, if exactly one session matches.
181
+ *
182
+ * @param params UUID prefix to resolve to a unique session ID.
183
+ *
184
+ * @returns Session ID matching the prefix, omitted when no unique match exists.
185
+ */
186
+ findByPrefix: async (params) => connection.sendRequest("sessions.findByPrefix", params),
187
+ /**
188
+ * Returns the most-relevant prior session for a given working-directory context.
189
+ *
190
+ * @param params Optional working-directory context used to score session relevance.
191
+ *
192
+ * @returns Most-relevant session ID for the supplied context, or omitted when no sessions exist.
193
+ */
194
+ getLastForContext: async (params) => connection.sendRequest("sessions.getLastForContext", params),
195
+ /**
196
+ * Computes the absolute path to a session's persisted events.jsonl file.
197
+ *
198
+ * @param params Session ID whose event-log file path to compute.
199
+ *
200
+ * @returns Absolute path to the session's events.jsonl file on disk.
201
+ */
202
+ getEventFilePath: async (params) => connection.sendRequest("sessions.getEventFilePath", params),
203
+ /**
204
+ * Returns the on-disk byte size of each session's workspace directory.
205
+ *
206
+ * @returns Map of sessionId -> on-disk size in bytes for each session's workspace directory.
207
+ */
208
+ getSizes: async () => connection.sendRequest("sessions.getSizes", {}),
209
+ /**
210
+ * Returns the subset of the supplied session IDs that are currently held by another running process.
211
+ *
212
+ * @param params Session IDs to test for live in-use locks.
213
+ *
214
+ * @returns Session IDs from the input set that are currently in use by another process.
215
+ */
216
+ checkInUse: async (params) => connection.sendRequest("sessions.checkInUse", params),
217
+ /**
218
+ * Returns a session's persisted remote-steerable flag, if any has been recorded.
219
+ *
220
+ * @param params Session ID to look up the persisted remote-steerable flag for.
221
+ *
222
+ * @returns The session's persisted remote-steerable flag, or omitted when no value has been persisted.
223
+ */
224
+ getPersistedRemoteSteerable: async (params) => connection.sendRequest("sessions.getPersistedRemoteSteerable", params),
225
+ /**
226
+ * Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
227
+ *
228
+ * @param params Session ID to close.
229
+ *
230
+ * @returns Closes a session: emits shutdown, flushes pending events to disk, releases the in-use lock, disposes the active session. Idempotent: succeeds even if the session is not currently active.
231
+ */
232
+ close: async (params) => connection.sendRequest("sessions.close", params),
233
+ /**
234
+ * Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
235
+ *
236
+ * @param params Session IDs to close, deactivate, and delete from disk.
237
+ *
238
+ * @returns Map of sessionId -> bytes freed by removing the session's workspace directory.
239
+ */
240
+ bulkDelete: async (params) => connection.sendRequest("sessions.bulkDelete", params),
241
+ /**
242
+ * Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
243
+ *
244
+ * @param params Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
245
+ *
246
+ * @returns Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
247
+ */
248
+ pruneOld: async (params) => connection.sendRequest("sessions.pruneOld", params),
249
+ /**
250
+ * Flushes a session's pending events to disk.
251
+ *
252
+ * @param params Session ID whose pending events should be flushed to disk.
253
+ *
254
+ * @returns Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
255
+ */
256
+ save: async (params) => connection.sendRequest("sessions.save", params),
257
+ /**
258
+ * Releases the in-use lock held by this process for a session.
259
+ *
260
+ * @param params Session ID whose in-use lock should be released.
261
+ *
262
+ * @returns Release the in-use lock held by this process for the given session. No-op when this process does not currently hold a lock for the session.
263
+ */
264
+ releaseLock: async (params) => connection.sendRequest("sessions.releaseLock", params),
265
+ /**
266
+ * Backfills missing summary and context fields on the supplied session metadata records.
267
+ *
268
+ * @param params Session metadata records to enrich with summary and context information.
269
+ *
270
+ * @returns The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
271
+ */
272
+ enrichMetadata: async (params) => connection.sendRequest("sessions.enrichMetadata", params),
273
+ /**
274
+ * Reloads user, plugin, and (optionally) repo hooks on the active session.
275
+ *
276
+ * @param params Active session ID and an optional flag for deferring repo-level hooks until folder trust.
277
+ *
278
+ * @returns Reload all hooks (user, plugin, optionally repo) and apply them to the active session. Call after installing or removing plugins so their hooks take effect immediately. No-op when no active session matches the given sessionId.
279
+ */
280
+ reloadPluginHooks: async (params) => connection.sendRequest("sessions.reloadPluginHooks", params),
281
+ /**
282
+ * Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
283
+ *
284
+ * @param params Active session ID whose deferred repo-level hooks should be loaded.
285
+ *
286
+ * @returns Queued repo-level startup prompts and the total hook command count after loading.
287
+ */
288
+ loadDeferredRepoHooks: async (params) => connection.sendRequest("sessions.loadDeferredRepoHooks", params),
289
+ /**
290
+ * Replaces the manager-wide additional plugins registered with the session manager.
291
+ *
292
+ * @param params Manager-wide additional plugins to register; replaces any previously-configured set.
293
+ *
294
+ * @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.
295
+ */
296
+ setAdditionalPlugins: async (params) => connection.sendRequest("sessions.setAdditionalPlugins", params)
297
+ },
298
+ /** @experimental */
299
+ agentRegistry: {
300
+ /**
301
+ * Spawns a managed-server child with the supplied configuration and returns a discriminated-union result. The caller (typically the CLI controller) is responsible for attaching to the spawned child and sending any follow-up prompt. When the controller-local spawn gate is closed the server returns JSON-RPC MethodNotFound.
302
+ *
303
+ * @param params Inputs to spawn a managed-server child via the controller's spawn delegate.
304
+ *
305
+ * @returns Outcome of an agentRegistry.spawn call.
306
+ */
307
+ spawn: async (params) => connection.sendRequest("agentRegistry.spawn", params)
36
308
  }
37
309
  };
38
310
  }
39
311
  function createInternalServerRpc(connection) {
40
312
  return {
313
+ /**
314
+ * Performs the SDK server connection handshake and validates the optional connection token.
315
+ *
316
+ * @param params Optional connection token presented by the SDK client during the handshake.
317
+ *
318
+ * @returns Handshake result reporting the server's protocol version and package version on success.
319
+ */
41
320
  connect: async (params) => connection.sendRequest("connect", params)
42
321
  };
43
322
  }
44
323
  function createSessionRpc(connection, sessionId) {
45
324
  return {
325
+ /**
326
+ * Suspends the session while preserving persisted state for later resume.
327
+ *
328
+ * @experimental
329
+ */
46
330
  suspend: async () => connection.sendRequest("session.suspend", { sessionId }),
331
+ /**
332
+ * Sends a user message to the session and returns its message ID.
333
+ *
334
+ * @param params Parameters for sending a user message to the session
335
+ *
336
+ * @returns Result of sending a user message
337
+ *
338
+ * @experimental
339
+ */
340
+ send: async (params) => connection.sendRequest("session.send", { sessionId, ...params }),
341
+ /**
342
+ * Aborts the current agent turn.
343
+ *
344
+ * @param params Parameters for aborting the current turn
345
+ *
346
+ * @returns Result of aborting the current turn
347
+ *
348
+ * @experimental
349
+ */
350
+ abort: async (params) => connection.sendRequest("session.abort", { sessionId, ...params }),
351
+ /**
352
+ * Shuts down the session and persists its final state. Awaits any deferred sessionEnd hooks before resolving so user-supplied hook scripts complete before the runtime tears down.
353
+ *
354
+ * @param params Parameters for shutting down the session
355
+ *
356
+ * @experimental
357
+ */
358
+ shutdown: async (params) => connection.sendRequest("session.shutdown", { sessionId, ...params }),
359
+ /** @experimental */
47
360
  auth: {
48
- getStatus: async () => connection.sendRequest("session.auth.getStatus", { sessionId })
361
+ /**
362
+ * Gets authentication status and account metadata for the session.
363
+ *
364
+ * @returns Authentication status and account metadata for the session.
365
+ */
366
+ getStatus: async () => connection.sendRequest("session.auth.getStatus", { sessionId }),
367
+ /**
368
+ * Updates the session's auth credentials used for outbound model and API requests.
369
+ *
370
+ * @param params New auth credentials to install on the session. Omit to leave credentials unchanged.
371
+ *
372
+ * @returns Indicates whether the credential update succeeded.
373
+ */
374
+ setCredentials: async (params) => connection.sendRequest("session.auth.setCredentials", { sessionId, ...params })
49
375
  },
376
+ /** @experimental */
377
+ canvas: {
378
+ /**
379
+ * Lists canvases declared for the session.
380
+ *
381
+ * @returns Declared canvases available in this session.
382
+ */
383
+ list: async () => connection.sendRequest("session.canvas.list", { sessionId }),
384
+ /**
385
+ * Lists currently open canvas instances for the live session.
386
+ *
387
+ * @returns Live open-canvas snapshot.
388
+ */
389
+ listOpen: async () => connection.sendRequest("session.canvas.listOpen", { sessionId }),
390
+ /**
391
+ * Opens or focuses a canvas instance.
392
+ *
393
+ * @param params Canvas open parameters.
394
+ *
395
+ * @returns Open canvas instance snapshot.
396
+ */
397
+ open: async (params) => connection.sendRequest("session.canvas.open", { sessionId, ...params }),
398
+ /**
399
+ * Closes an open canvas instance.
400
+ *
401
+ * @param params Canvas close parameters.
402
+ */
403
+ close: async (params) => connection.sendRequest("session.canvas.close", { sessionId, ...params }),
404
+ /** @experimental */
405
+ action: {
406
+ /**
407
+ * Invokes an action on an open canvas instance.
408
+ *
409
+ * @param params Canvas action invocation parameters.
410
+ *
411
+ * @returns Canvas action invocation result.
412
+ */
413
+ invoke: async (params) => connection.sendRequest("session.canvas.action.invoke", { sessionId, ...params })
414
+ }
415
+ },
416
+ /** @experimental */
50
417
  model: {
418
+ /**
419
+ * Gets the currently selected model for the session.
420
+ *
421
+ * @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.
422
+ */
51
423
  getCurrent: async () => connection.sendRequest("session.model.getCurrent", { sessionId }),
52
- switchTo: async (params) => connection.sendRequest("session.model.switchTo", { sessionId, ...params })
424
+ /**
425
+ * Switches the session to a model and optional reasoning configuration.
426
+ *
427
+ * @param params Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
428
+ *
429
+ * @returns The model identifier active on the session after the switch.
430
+ */
431
+ switchTo: async (params) => connection.sendRequest("session.model.switchTo", { sessionId, ...params }),
432
+ /**
433
+ * Updates the session's reasoning effort without changing the selected model.
434
+ *
435
+ * @param params Reasoning effort level to apply to the currently selected model.
436
+ *
437
+ * @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.
438
+ */
439
+ setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { sessionId, ...params }),
440
+ /**
441
+ * 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.
442
+ *
443
+ * @param params Optional listing options.
444
+ *
445
+ * @returns The list of models available to this session.
446
+ */
447
+ list: async (params) => connection.sendRequest("session.model.list", { sessionId, ...params })
53
448
  },
449
+ /** @experimental */
54
450
  mode: {
451
+ /**
452
+ * Gets the current agent interaction mode.
453
+ *
454
+ * @returns The session mode the agent is operating in
455
+ */
55
456
  get: async () => connection.sendRequest("session.mode.get", { sessionId }),
457
+ /**
458
+ * Sets the current agent interaction mode.
459
+ *
460
+ * @param params Agent interaction mode to apply to the session.
461
+ */
56
462
  set: async (params) => connection.sendRequest("session.mode.set", { sessionId, ...params })
57
463
  },
464
+ /** @experimental */
58
465
  name: {
466
+ /**
467
+ * Gets the session's friendly name.
468
+ *
469
+ * @returns The session's friendly name, or null when not yet set.
470
+ */
59
471
  get: async () => connection.sendRequest("session.name.get", { sessionId }),
60
- set: async (params) => connection.sendRequest("session.name.set", { sessionId, ...params })
472
+ /**
473
+ * Sets the session's friendly name.
474
+ *
475
+ * @param params New friendly name to apply to the session.
476
+ */
477
+ set: async (params) => connection.sendRequest("session.name.set", { sessionId, ...params }),
478
+ /**
479
+ * Persists an auto-generated session summary as the session's name when no user-set name exists.
480
+ *
481
+ * @param params Auto-generated session summary to apply as the session's name when no user-set name exists.
482
+ *
483
+ * @returns Indicates whether the auto-generated summary was applied as the session's name.
484
+ */
485
+ setAuto: async (params) => connection.sendRequest("session.name.setAuto", { sessionId, ...params })
61
486
  },
487
+ /** @experimental */
62
488
  plan: {
489
+ /**
490
+ * Reads the session plan file from the workspace.
491
+ *
492
+ * @returns Existence, contents, and resolved path of the session plan file.
493
+ */
63
494
  read: async () => connection.sendRequest("session.plan.read", { sessionId }),
495
+ /**
496
+ * Writes new content to the session plan file.
497
+ *
498
+ * @param params Replacement contents to write to the session plan file.
499
+ */
64
500
  update: async (params) => connection.sendRequest("session.plan.update", { sessionId, ...params }),
501
+ /**
502
+ * Deletes the session plan file from the workspace.
503
+ */
65
504
  delete: async () => connection.sendRequest("session.plan.delete", { sessionId })
66
505
  },
506
+ /** @experimental */
67
507
  workspaces: {
508
+ /**
509
+ * Gets current workspace metadata for the session.
510
+ *
511
+ * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
512
+ */
68
513
  getWorkspace: async () => connection.sendRequest("session.workspaces.getWorkspace", { sessionId }),
514
+ /**
515
+ * Lists files stored in the session workspace files directory.
516
+ *
517
+ * @returns Relative paths of files stored in the session workspace files directory.
518
+ */
69
519
  listFiles: async () => connection.sendRequest("session.workspaces.listFiles", { sessionId }),
520
+ /**
521
+ * Reads a file from the session workspace files directory.
522
+ *
523
+ * @param params Relative path of the workspace file to read.
524
+ *
525
+ * @returns Contents of the requested workspace file as a UTF-8 string.
526
+ */
70
527
  readFile: async (params) => connection.sendRequest("session.workspaces.readFile", { sessionId, ...params }),
71
- createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params })
528
+ /**
529
+ * Creates or overwrites a file in the session workspace files directory.
530
+ *
531
+ * @param params Relative path and UTF-8 content for the workspace file to create or overwrite.
532
+ */
533
+ createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params }),
534
+ /**
535
+ * Lists workspace checkpoints in chronological order.
536
+ *
537
+ * @returns Workspace checkpoints in chronological order; empty when the workspace is not enabled.
538
+ */
539
+ listCheckpoints: async () => connection.sendRequest("session.workspaces.listCheckpoints", { sessionId }),
540
+ /**
541
+ * Reads the content of a workspace checkpoint by number.
542
+ *
543
+ * @param params Checkpoint number to read.
544
+ *
545
+ * @returns Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
546
+ */
547
+ readCheckpoint: async (params) => connection.sendRequest("session.workspaces.readCheckpoint", { sessionId, ...params }),
548
+ /**
549
+ * Saves pasted content as a UTF-8 file in the session workspace.
550
+ *
551
+ * @param params Pasted content to save as a UTF-8 file in the session workspace.
552
+ *
553
+ * @returns Descriptor for the saved paste file, or null when the workspace is unavailable.
554
+ */
555
+ saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params }),
556
+ /**
557
+ * Computes a diff for the session workspace.
558
+ *
559
+ * @param params Parameters for computing a workspace diff.
560
+ *
561
+ * @returns Workspace diff result for the requested mode.
562
+ */
563
+ diff: async (params) => connection.sendRequest("session.workspaces.diff", { sessionId, ...params })
72
564
  },
565
+ /** @experimental */
73
566
  instructions: {
567
+ /**
568
+ * Gets instruction sources loaded for the session.
569
+ *
570
+ * @returns Instruction sources loaded for the session, in merge order.
571
+ */
74
572
  getSources: async () => connection.sendRequest("session.instructions.getSources", { sessionId })
75
573
  },
76
574
  /** @experimental */
77
575
  fleet: {
576
+ /**
577
+ * Starts fleet mode by submitting the fleet orchestration prompt to the session.
578
+ *
579
+ * @param params Optional user prompt to combine with the fleet orchestration instructions.
580
+ *
581
+ * @returns Indicates whether fleet mode was successfully activated.
582
+ */
78
583
  start: async (params) => connection.sendRequest("session.fleet.start", { sessionId, ...params })
79
584
  },
80
585
  /** @experimental */
81
586
  agent: {
587
+ /**
588
+ * Lists custom agents available to the session.
589
+ *
590
+ * @returns Custom agents available to the session.
591
+ */
82
592
  list: async () => connection.sendRequest("session.agent.list", { sessionId }),
593
+ /**
594
+ * Gets the currently selected custom agent for the session.
595
+ *
596
+ * @returns The currently selected custom agent, or null when using the default agent.
597
+ */
83
598
  getCurrent: async () => connection.sendRequest("session.agent.getCurrent", { sessionId }),
599
+ /**
600
+ * Selects a custom agent for subsequent turns in the session.
601
+ *
602
+ * @param params Name of the custom agent to select for subsequent turns.
603
+ *
604
+ * @returns The newly selected custom agent.
605
+ */
84
606
  select: async (params) => connection.sendRequest("session.agent.select", { sessionId, ...params }),
607
+ /**
608
+ * Clears the selected custom agent and returns the session to the default agent.
609
+ */
85
610
  deselect: async () => connection.sendRequest("session.agent.deselect", { sessionId }),
611
+ /**
612
+ * Reloads custom agent definitions and returns the refreshed list.
613
+ *
614
+ * @returns Custom agents available to the session after reloading definitions from disk.
615
+ */
86
616
  reload: async () => connection.sendRequest("session.agent.reload", { sessionId })
87
617
  },
88
618
  /** @experimental */
89
619
  tasks: {
620
+ /**
621
+ * Starts a background agent task in the session.
622
+ *
623
+ * @param params Agent type, prompt, name, and optional description and model override for the new task.
624
+ *
625
+ * @returns Identifier assigned to the newly started background agent task.
626
+ */
90
627
  startAgent: async (params) => connection.sendRequest("session.tasks.startAgent", { sessionId, ...params }),
628
+ /**
629
+ * Lists background tasks tracked by the session.
630
+ *
631
+ * @returns Background tasks currently tracked by the session.
632
+ */
91
633
  list: async () => connection.sendRequest("session.tasks.list", { sessionId }),
634
+ /**
635
+ * Refreshes metadata for any detached background shells the runtime knows about.
636
+ *
637
+ * @returns Refresh metadata for any detached background shells the runtime knows about. Use after a long pause to pick up exit/output state for shells running outside the agent loop.
638
+ */
639
+ refresh: async () => connection.sendRequest("session.tasks.refresh", { sessionId }),
640
+ /**
641
+ * Waits for all in-flight background tasks and any follow-up turns to settle.
642
+ *
643
+ * @returns Wait until all in-flight background tasks (agents + shells) and any follow-up turns scheduled by their completions have settled. Returns when the runtime is fully drained or after an internal timeout (default 10 minutes; configurable via COPILOT_TASK_WAIT_TIMEOUT_SECONDS).
644
+ */
645
+ waitForPending: async () => connection.sendRequest("session.tasks.waitForPending", { sessionId }),
646
+ /**
647
+ * Returns progress information for a background task by ID.
648
+ *
649
+ * @param params Identifier of the background task to fetch progress for.
650
+ *
651
+ * @returns Progress information for the task, or null when no task with that ID is tracked.
652
+ */
653
+ getProgress: async (params) => connection.sendRequest("session.tasks.getProgress", { sessionId, ...params }),
654
+ /**
655
+ * Returns the first sync-waiting task that can currently be promoted to background mode.
656
+ *
657
+ * @returns The first sync-waiting task that can currently be promoted to background mode.
658
+ */
659
+ getCurrentPromotable: async () => connection.sendRequest("session.tasks.getCurrentPromotable", { sessionId }),
660
+ /**
661
+ * Promotes an eligible synchronously-waited task so it continues running in the background.
662
+ *
663
+ * @param params Identifier of the task to promote to background mode.
664
+ *
665
+ * @returns Indicates whether the task was successfully promoted to background mode.
666
+ */
92
667
  promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { sessionId, ...params }),
668
+ /**
669
+ * Atomically promotes the first promotable sync-waiting task to background mode and returns it.
670
+ *
671
+ * @returns The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
672
+ */
673
+ promoteCurrentToBackground: async () => connection.sendRequest("session.tasks.promoteCurrentToBackground", { sessionId }),
674
+ /**
675
+ * Cancels a background task.
676
+ *
677
+ * @param params Identifier of the background task to cancel.
678
+ *
679
+ * @returns Indicates whether the background task was successfully cancelled.
680
+ */
93
681
  cancel: async (params) => connection.sendRequest("session.tasks.cancel", { sessionId, ...params }),
94
- remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params })
682
+ /**
683
+ * Removes a completed or cancelled background task from tracking.
684
+ *
685
+ * @param params Identifier of the completed or cancelled task to remove from tracking.
686
+ *
687
+ * @returns Indicates whether the task was removed. False when the task does not exist or is still running/idle.
688
+ */
689
+ remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params }),
690
+ /**
691
+ * Sends a message to a background agent task.
692
+ *
693
+ * @param params Identifier of the target agent task, message content, and optional sender agent ID.
694
+ *
695
+ * @returns Indicates whether the message was delivered, with an error message when delivery failed.
696
+ */
697
+ sendMessage: async (params) => connection.sendRequest("session.tasks.sendMessage", { sessionId, ...params })
95
698
  },
96
699
  /** @experimental */
97
700
  skills: {
701
+ /**
702
+ * Lists skills available to the session.
703
+ *
704
+ * @returns Skills available to the session, with their enabled state.
705
+ */
98
706
  list: async () => connection.sendRequest("session.skills.list", { sessionId }),
707
+ /**
708
+ * Returns the skills that have been invoked during this session.
709
+ *
710
+ * @returns Skills invoked during this session, ordered by invocation time (most recent last).
711
+ */
712
+ getInvoked: async () => connection.sendRequest("session.skills.getInvoked", { sessionId }),
713
+ /**
714
+ * Enables a skill for the session.
715
+ *
716
+ * @param params Name of the skill to enable for the session.
717
+ */
99
718
  enable: async (params) => connection.sendRequest("session.skills.enable", { sessionId, ...params }),
719
+ /**
720
+ * Disables a skill for the session.
721
+ *
722
+ * @param params Name of the skill to disable for the session.
723
+ */
100
724
  disable: async (params) => connection.sendRequest("session.skills.disable", { sessionId, ...params }),
101
- reload: async () => connection.sendRequest("session.skills.reload", { sessionId })
725
+ /**
726
+ * Reloads skill definitions for the session.
727
+ *
728
+ * @returns Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
729
+ */
730
+ reload: async () => connection.sendRequest("session.skills.reload", { sessionId }),
731
+ /**
732
+ * Ensures the session's skill definitions have been loaded from disk.
733
+ */
734
+ ensureLoaded: async () => connection.sendRequest("session.skills.ensureLoaded", { sessionId })
102
735
  },
103
736
  /** @experimental */
104
737
  mcp: {
738
+ /**
739
+ * Lists MCP servers configured for the session and their connection status.
740
+ *
741
+ * @returns MCP servers configured for the session, with their connection status.
742
+ */
105
743
  list: async () => connection.sendRequest("session.mcp.list", { sessionId }),
744
+ /**
745
+ * Enables an MCP server for the session.
746
+ *
747
+ * @param params Name of the MCP server to enable for the session.
748
+ */
106
749
  enable: async (params) => connection.sendRequest("session.mcp.enable", { sessionId, ...params }),
750
+ /**
751
+ * Disables an MCP server for the session.
752
+ *
753
+ * @param params Name of the MCP server to disable for the session.
754
+ */
107
755
  disable: async (params) => connection.sendRequest("session.mcp.disable", { sessionId, ...params }),
756
+ /**
757
+ * Reloads MCP server connections for the session.
758
+ */
108
759
  reload: async () => connection.sendRequest("session.mcp.reload", { sessionId }),
760
+ /**
761
+ * Runs an MCP sampling inference on behalf of an MCP server.
762
+ *
763
+ * @param params Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
764
+ *
765
+ * @returns Outcome of an MCP sampling execution: success result, failure error, or cancellation.
766
+ */
767
+ executeSampling: async (params) => connection.sendRequest("session.mcp.executeSampling", { sessionId, ...params }),
768
+ /**
769
+ * Cancels an in-flight MCP sampling execution by request ID.
770
+ *
771
+ * @param params The requestId previously passed to executeSampling that should be cancelled.
772
+ *
773
+ * @returns Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
774
+ */
775
+ cancelSamplingExecution: async (params) => connection.sendRequest("session.mcp.cancelSamplingExecution", { sessionId, ...params }),
776
+ /**
777
+ * Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
778
+ *
779
+ * @param params Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
780
+ *
781
+ * @returns Env-value mode recorded on the session after the update.
782
+ */
783
+ setEnvValueMode: async (params) => connection.sendRequest("session.mcp.setEnvValueMode", { sessionId, ...params }),
784
+ /**
785
+ * Removes the auto-managed `github` MCP server when present.
786
+ *
787
+ * @returns Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
788
+ */
789
+ removeGitHub: async () => connection.sendRequest("session.mcp.removeGitHub", { sessionId }),
109
790
  /** @experimental */
110
791
  oauth: {
792
+ /**
793
+ * Starts OAuth authentication for a remote MCP server.
794
+ *
795
+ * @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, and the callback success-page copy.
796
+ *
797
+ * @returns OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
798
+ */
111
799
  login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params })
800
+ },
801
+ /** @experimental */
802
+ apps: {
803
+ /**
804
+ * Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
805
+ *
806
+ * @param params MCP server and resource URI to fetch.
807
+ *
808
+ * @returns Resource contents returned by the MCP server.
809
+ */
810
+ readResource: async (params) => connection.sendRequest("session.mcp.apps.readResource", { sessionId, ...params }),
811
+ /**
812
+ * List tools that an MCP App view is allowed to call (SEP-1865 visibility filter). Returns tools whose `_meta.ui.visibility` is unset (default `["model","app"]`) or includes `"app"`.
813
+ *
814
+ * @param params MCP server to list app-callable tools for.
815
+ *
816
+ * @returns App-callable tools from the named MCP server.
817
+ */
818
+ listTools: async (params) => connection.sendRequest("session.mcp.apps.listTools", { sessionId, ...params }),
819
+ /**
820
+ * Call an MCP tool from an MCP App view (SEP-1865). Enforces the visibility check that prevents an app iframe from invoking model-only tools. Returns the standard MCP `CallToolResult`.
821
+ *
822
+ * @param params MCP server, tool name, and arguments to invoke from an MCP App view.
823
+ *
824
+ * @returns Standard MCP CallToolResult
825
+ */
826
+ callTool: async (params) => connection.sendRequest("session.mcp.apps.callTool", { sessionId, ...params }),
827
+ /**
828
+ * Replace the host context returned to MCP App guests on `ui/initialize`. Hosts use this to advertise theme, locale, or other metadata to the guest UI.
829
+ *
830
+ * @param params Host context to advertise to MCP App guests.
831
+ */
832
+ setHostContext: async (params) => connection.sendRequest("session.mcp.apps.setHostContext", { sessionId, ...params }),
833
+ /**
834
+ * Read the current host context advertised to MCP App guests.
835
+ *
836
+ * @returns Current host context advertised to MCP App guests.
837
+ */
838
+ getHostContext: async () => connection.sendRequest("session.mcp.apps.getHostContext", { sessionId }),
839
+ /**
840
+ * Diagnose MCP Apps wiring for a specific MCP server. Reports the session capability, feature-flag state, advertised extension, and how many tools have `_meta.ui` populated.
841
+ *
842
+ * @param params MCP server to diagnose MCP Apps wiring for.
843
+ *
844
+ * @returns Diagnostic snapshot of MCP Apps wiring for the named server.
845
+ */
846
+ diagnose: async (params) => connection.sendRequest("session.mcp.apps.diagnose", { sessionId, ...params })
112
847
  }
113
848
  },
114
849
  /** @experimental */
115
850
  plugins: {
851
+ /**
852
+ * Lists plugins installed for the session.
853
+ *
854
+ * @returns Plugins installed for the session, with their enabled state and version metadata.
855
+ */
116
856
  list: async () => connection.sendRequest("session.plugins.list", { sessionId })
117
857
  },
118
858
  /** @experimental */
859
+ options: {
860
+ /**
861
+ * Patches the genuinely-mutable subset of session options.
862
+ *
863
+ * @param params Patch of mutable session options to apply to the running session.
864
+ *
865
+ * @returns Indicates whether the session options patch was applied successfully.
866
+ */
867
+ update: async (params) => connection.sendRequest("session.options.update", { sessionId, ...params })
868
+ },
869
+ /** @experimental */
870
+ lsp: {
871
+ /**
872
+ * Loads the merged LSP configuration set for the session's working directory.
873
+ *
874
+ * @param params Parameters for (re)loading the merged LSP configuration set.
875
+ */
876
+ initialize: async (params) => connection.sendRequest("session.lsp.initialize", { sessionId, ...params })
877
+ },
878
+ /** @experimental */
119
879
  extensions: {
880
+ /**
881
+ * Lists extensions discovered for the session and their current status.
882
+ *
883
+ * @returns Extensions discovered for the session, with their current status.
884
+ */
120
885
  list: async () => connection.sendRequest("session.extensions.list", { sessionId }),
886
+ /**
887
+ * Enables an extension for the session.
888
+ *
889
+ * @param params Source-qualified extension identifier to enable for the session.
890
+ */
121
891
  enable: async (params) => connection.sendRequest("session.extensions.enable", { sessionId, ...params }),
892
+ /**
893
+ * Disables an extension for the session.
894
+ *
895
+ * @param params Source-qualified extension identifier to disable for the session.
896
+ */
122
897
  disable: async (params) => connection.sendRequest("session.extensions.disable", { sessionId, ...params }),
123
- reload: async () => connection.sendRequest("session.extensions.reload", { sessionId })
898
+ /**
899
+ * Reloads extension definitions and processes for the session.
900
+ */
901
+ reload: async () => connection.sendRequest("session.extensions.reload", { sessionId }),
902
+ /**
903
+ * 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.
904
+ *
905
+ * @param params Parameters for session.extensions.sendAttachmentsToMessage.
906
+ */
907
+ sendAttachmentsToMessage: async (params) => connection.sendRequest("session.extensions.sendAttachmentsToMessage", { sessionId, ...params })
124
908
  },
909
+ /** @experimental */
125
910
  tools: {
126
- handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { sessionId, ...params })
911
+ /**
912
+ * Provides the result for a pending external tool call.
913
+ *
914
+ * @param params Pending external tool call request ID, with the tool result or an error describing why it failed.
915
+ *
916
+ * @returns Indicates whether the external tool call result was handled successfully.
917
+ */
918
+ handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { sessionId, ...params }),
919
+ /**
920
+ * Resolves, builds, and validates the runtime tool list for the session.
921
+ *
922
+ * @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.
923
+ */
924
+ initializeAndValidate: async () => connection.sendRequest("session.tools.initializeAndValidate", { sessionId }),
925
+ /**
926
+ * Returns lightweight metadata for the session's currently initialized tools.
927
+ *
928
+ * @returns Current lightweight tool metadata snapshot for the session.
929
+ */
930
+ getCurrentMetadata: async () => connection.sendRequest("session.tools.getCurrentMetadata", { sessionId })
127
931
  },
932
+ /** @experimental */
128
933
  commands: {
129
- handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params })
934
+ /**
935
+ * Lists slash commands available in the session.
936
+ *
937
+ * @param params Optional filters controlling which command sources to include in the listing.
938
+ *
939
+ * @returns Slash commands available in the session, after applying any include/exclude filters.
940
+ */
941
+ list: async (params) => connection.sendRequest("session.commands.list", { sessionId, ...params }),
942
+ /**
943
+ * Invokes a slash command in the session.
944
+ *
945
+ * @param params Slash command name and optional raw input string to invoke.
946
+ *
947
+ * @returns Result of invoking the slash command (text output, prompt to send to the agent, or completion).
948
+ */
949
+ invoke: async (params) => connection.sendRequest("session.commands.invoke", { sessionId, ...params }),
950
+ /**
951
+ * Reports completion of a pending client-handled slash command.
952
+ *
953
+ * @param params Pending command request ID and an optional error if the client handler failed.
954
+ *
955
+ * @returns Indicates whether the pending client-handled command was completed successfully.
956
+ */
957
+ handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params }),
958
+ /**
959
+ * Executes a slash command synchronously and returns any error.
960
+ *
961
+ * @param params Slash command name and argument string to execute synchronously.
962
+ *
963
+ * @returns Error message produced while executing the command, if any.
964
+ */
965
+ execute: async (params) => connection.sendRequest("session.commands.execute", { sessionId, ...params }),
966
+ /**
967
+ * Enqueues a slash command for FIFO processing on the local session.
968
+ *
969
+ * @param params Slash-prefixed command string to enqueue for FIFO processing.
970
+ *
971
+ * @returns Indicates whether the command was accepted into the local execution queue.
972
+ */
973
+ enqueue: async (params) => connection.sendRequest("session.commands.enqueue", { sessionId, ...params }),
974
+ /**
975
+ * Reports whether the host actually executed a queued command and whether to continue processing.
976
+ *
977
+ * @param params Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
978
+ *
979
+ * @returns Indicates whether the queued-command response was matched to a pending request.
980
+ */
981
+ respondToQueuedCommand: async (params) => connection.sendRequest("session.commands.respondToQueuedCommand", { sessionId, ...params })
130
982
  },
983
+ /** @experimental */
984
+ telemetry: {
985
+ /**
986
+ * Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
987
+ *
988
+ * @param params Feature override key/value pairs to attach to subsequent telemetry events from this session.
989
+ */
990
+ setFeatureOverrides: async (params) => connection.sendRequest("session.telemetry.setFeatureOverrides", { sessionId, ...params })
991
+ },
992
+ /** @experimental */
131
993
  ui: {
994
+ /**
995
+ * Requests structured input from a UI-capable client.
996
+ *
997
+ * @param params Prompt message and JSON schema describing the form fields to elicit from the user.
998
+ *
999
+ * @returns The elicitation response (accept with form values, decline, or cancel)
1000
+ */
132
1001
  elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params }),
133
- handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { sessionId, ...params })
1002
+ /**
1003
+ * Provides the user response for a pending elicitation request.
1004
+ *
1005
+ * @param params Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
1006
+ *
1007
+ * @returns Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
1008
+ */
1009
+ handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { sessionId, ...params }),
1010
+ /**
1011
+ * Resolves a pending `user_input.requested` event with the user's response.
1012
+ *
1013
+ * @param params Request ID of a pending `user_input.requested` event and the user's response.
1014
+ *
1015
+ * @returns Indicates whether the pending UI request was resolved by this call.
1016
+ */
1017
+ handlePendingUserInput: async (params) => connection.sendRequest("session.ui.handlePendingUserInput", { sessionId, ...params }),
1018
+ /**
1019
+ * Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
1020
+ *
1021
+ * @param params Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
1022
+ *
1023
+ * @returns Indicates whether the pending UI request was resolved by this call.
1024
+ */
1025
+ handlePendingSampling: async (params) => connection.sendRequest("session.ui.handlePendingSampling", { sessionId, ...params }),
1026
+ /**
1027
+ * Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
1028
+ *
1029
+ * @param params Request ID of a pending `auto_mode_switch.requested` event and the user's response.
1030
+ *
1031
+ * @returns Indicates whether the pending UI request was resolved by this call.
1032
+ */
1033
+ handlePendingAutoModeSwitch: async (params) => connection.sendRequest("session.ui.handlePendingAutoModeSwitch", { sessionId, ...params }),
1034
+ /**
1035
+ * Resolves a pending `exit_plan_mode.requested` event with the user's response.
1036
+ *
1037
+ * @param params Request ID of a pending `exit_plan_mode.requested` event and the user's response.
1038
+ *
1039
+ * @returns Indicates whether the pending UI request was resolved by this call.
1040
+ */
1041
+ handlePendingExitPlanMode: async (params) => connection.sendRequest("session.ui.handlePendingExitPlanMode", { sessionId, ...params }),
1042
+ /**
1043
+ * Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
1044
+ *
1045
+ * @returns Register an in-process handler for `auto_mode_switch.requested` events. The caller still attaches the actual listener via the standard event-subscription mechanism; this registration solely tells the server bridge to skip its own dispatch (so a remote client doesn't race the in-process handler for the same requestId).
1046
+ */
1047
+ registerDirectAutoModeSwitchHandler: async () => connection.sendRequest("session.ui.registerDirectAutoModeSwitchHandler", { sessionId }),
1048
+ /**
1049
+ * Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
1050
+ *
1051
+ * @param params Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
1052
+ *
1053
+ * @returns Indicates whether the handle was active and the registration count was decremented.
1054
+ */
1055
+ unregisterDirectAutoModeSwitchHandler: async (params) => connection.sendRequest("session.ui.unregisterDirectAutoModeSwitchHandler", { sessionId, ...params })
134
1056
  },
1057
+ /** @experimental */
135
1058
  permissions: {
1059
+ /**
1060
+ * Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
1061
+ *
1062
+ * @param params Patch of permission policy fields to apply (omit a field to leave it unchanged).
1063
+ *
1064
+ * @returns Indicates whether the operation succeeded.
1065
+ */
1066
+ configure: async (params) => connection.sendRequest("session.permissions.configure", { sessionId, ...params }),
1067
+ /**
1068
+ * Provides a decision for a pending tool permission request.
1069
+ *
1070
+ * @param params Pending permission request ID and the decision to apply (approve/reject and scope).
1071
+ *
1072
+ * @returns Indicates whether the permission decision was applied; false when the request was already resolved.
1073
+ */
136
1074
  handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params }),
1075
+ /**
1076
+ * Reconstructs the set of pending tool permission requests from the session's event history.
1077
+ *
1078
+ * @returns List of pending permission requests reconstructed from event history.
1079
+ */
1080
+ pendingRequests: async () => connection.sendRequest("session.permissions.pendingRequests", { sessionId }),
1081
+ /**
1082
+ * Enables or disables automatic approval of tool permission requests for the session.
1083
+ *
1084
+ * @param params Allow-all toggle for tool permission requests, with an optional telemetry source.
1085
+ *
1086
+ * @returns Indicates whether the operation succeeded.
1087
+ */
137
1088
  setApproveAll: async (params) => connection.sendRequest("session.permissions.setApproveAll", { sessionId, ...params }),
138
- resetSessionApprovals: async () => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId })
1089
+ /**
1090
+ * Enables or disables full allow-all permissions (tools, paths, and URLs) for the session. Used by attach-mode clients (e.g. LocalRpcSession's `/allow-all` forwarder) to flip the target session's permission state. Unlike `setApproveAll`, this swaps in the unrestricted path and URL managers and emits `session.permissions_changed` on transition. The result returns the authoritative post-mutation state so callers can update their local mirrors without racing the `session.permissions_changed` notification on the same wire.
1091
+ *
1092
+ * @param params Whether to enable full allow-all permissions for the session.
1093
+ *
1094
+ * @returns Indicates whether the operation succeeded and reports the post-mutation state.
1095
+ */
1096
+ setAllowAll: async (params) => connection.sendRequest("session.permissions.setAllowAll", { sessionId, ...params }),
1097
+ /**
1098
+ * Returns whether full allow-all permissions are currently active for the session.
1099
+ *
1100
+ * @returns Current full allow-all permission state.
1101
+ */
1102
+ getAllowAll: async () => connection.sendRequest("session.permissions.getAllowAll", { sessionId }),
1103
+ /**
1104
+ * Adds or removes session-scoped or location-scoped permission rules.
1105
+ *
1106
+ * @param params Scope and add/remove instructions for modifying session- or location-scoped permission rules.
1107
+ *
1108
+ * @returns Indicates whether the operation succeeded.
1109
+ */
1110
+ modifyRules: async (params) => connection.sendRequest("session.permissions.modifyRules", { sessionId, ...params }),
1111
+ /**
1112
+ * Sets whether the client wants permission prompts bridged into session events.
1113
+ *
1114
+ * @param params Toggles whether permission prompts should be bridged into session events for this client.
1115
+ *
1116
+ * @returns Indicates whether the operation succeeded.
1117
+ */
1118
+ setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { sessionId, ...params }),
1119
+ /**
1120
+ * Clears session-scoped tool permission approvals.
1121
+ *
1122
+ * @returns Indicates whether the operation succeeded.
1123
+ */
1124
+ resetSessionApprovals: async () => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId }),
1125
+ /**
1126
+ * Notifies the runtime that a permission prompt UI has been shown to the user.
1127
+ *
1128
+ * @param params Notification payload describing the permission prompt that the client just rendered.
1129
+ *
1130
+ * @returns Indicates whether the operation succeeded.
1131
+ */
1132
+ notifyPromptShown: async (params) => connection.sendRequest("session.permissions.notifyPromptShown", { sessionId, ...params }),
1133
+ /** @experimental */
1134
+ paths: {
1135
+ /**
1136
+ * Returns the session's allowed directories and primary working directory.
1137
+ *
1138
+ * @returns Snapshot of the session's allow-listed directories and primary working directory.
1139
+ */
1140
+ list: async () => connection.sendRequest("session.permissions.paths.list", { sessionId }),
1141
+ /**
1142
+ * Adds a directory to the session's allow-list.
1143
+ *
1144
+ * @param params Directory path to add to the session's allowed directories.
1145
+ *
1146
+ * @returns Indicates whether the operation succeeded.
1147
+ */
1148
+ add: async (params) => connection.sendRequest("session.permissions.paths.add", { sessionId, ...params }),
1149
+ /**
1150
+ * Updates the session's primary working directory used by the permission policy.
1151
+ *
1152
+ * @param params Directory path to set as the session's new primary working directory.
1153
+ *
1154
+ * @returns Indicates whether the operation succeeded.
1155
+ */
1156
+ updatePrimary: async (params) => connection.sendRequest("session.permissions.paths.updatePrimary", { sessionId, ...params }),
1157
+ /**
1158
+ * Reports whether a path falls within any of the session's allowed directories.
1159
+ *
1160
+ * @param params Path to evaluate against the session's allowed directories.
1161
+ *
1162
+ * @returns Indicates whether the supplied path is within the session's allowed directories.
1163
+ */
1164
+ isPathWithinAllowedDirectories: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinAllowedDirectories", { sessionId, ...params }),
1165
+ /**
1166
+ * Reports whether a path falls within the session's workspace (primary) directory.
1167
+ *
1168
+ * @param params Path to evaluate against the session's workspace (primary) directory.
1169
+ *
1170
+ * @returns Indicates whether the supplied path is within the session's workspace directory.
1171
+ */
1172
+ isPathWithinWorkspace: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinWorkspace", { sessionId, ...params })
1173
+ },
1174
+ /** @experimental */
1175
+ locations: {
1176
+ /**
1177
+ * Resolves the permission location key and type for a working directory.
1178
+ *
1179
+ * @param params Working directory to resolve into a location-permissions key.
1180
+ *
1181
+ * @returns Resolved location-permissions key and type.
1182
+ */
1183
+ resolve: async (params) => connection.sendRequest("session.permissions.locations.resolve", { sessionId, ...params }),
1184
+ /**
1185
+ * Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
1186
+ *
1187
+ * @param params Working directory to load persisted location permissions for.
1188
+ *
1189
+ * @returns Summary of persisted location permissions applied to the session.
1190
+ */
1191
+ apply: async (params) => connection.sendRequest("session.permissions.locations.apply", { sessionId, ...params }),
1192
+ /**
1193
+ * Persists a tool approval for a permission location and applies its rules to this session's live permission service.
1194
+ *
1195
+ * @param params Location-scoped tool approval to persist.
1196
+ *
1197
+ * @returns Indicates whether the operation succeeded.
1198
+ */
1199
+ addToolApproval: async (params) => connection.sendRequest("session.permissions.locations.addToolApproval", { sessionId, ...params })
1200
+ },
1201
+ /** @experimental */
1202
+ folderTrust: {
1203
+ /**
1204
+ * Reports whether a folder is trusted according to the user's folder trust state.
1205
+ *
1206
+ * @param params Folder path to check for trust.
1207
+ *
1208
+ * @returns Folder trust check result.
1209
+ */
1210
+ isTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.isTrusted", { sessionId, ...params }),
1211
+ /**
1212
+ * Adds a folder to the user's trusted folders list.
1213
+ *
1214
+ * @param params Folder path to add to trusted folders.
1215
+ *
1216
+ * @returns Indicates whether the operation succeeded.
1217
+ */
1218
+ addTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.addTrusted", { sessionId, ...params })
1219
+ },
1220
+ /** @experimental */
1221
+ urls: {
1222
+ /**
1223
+ * Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
1224
+ *
1225
+ * @param params Whether the URL-permission policy should run in unrestricted mode.
1226
+ *
1227
+ * @returns Indicates whether the operation succeeded.
1228
+ */
1229
+ setUnrestrictedMode: async (params) => connection.sendRequest("session.permissions.urls.setUnrestrictedMode", { sessionId, ...params })
1230
+ }
139
1231
  },
1232
+ /**
1233
+ * Emits a user-visible session log event.
1234
+ *
1235
+ * @param params Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
1236
+ *
1237
+ * @returns Identifier of the session event that was emitted for the log message.
1238
+ *
1239
+ * @experimental
1240
+ */
140
1241
  log: async (params) => connection.sendRequest("session.log", { sessionId, ...params }),
1242
+ /** @experimental */
1243
+ metadata: {
1244
+ /**
1245
+ * Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
1246
+ *
1247
+ * @returns Point-in-time snapshot of slow-changing session identifier and state fields
1248
+ */
1249
+ snapshot: async () => connection.sendRequest("session.metadata.snapshot", { sessionId }),
1250
+ /**
1251
+ * Reports whether the local session is currently processing user/agent messages.
1252
+ *
1253
+ * @returns Indicates whether the local session is currently processing a turn or background continuation.
1254
+ */
1255
+ isProcessing: async () => connection.sendRequest("session.metadata.isProcessing", { sessionId }),
1256
+ /**
1257
+ * Returns the token breakdown for the session's current context window for a given model.
1258
+ *
1259
+ * @param params Model identifier and token limits used to compute the context-info breakdown.
1260
+ *
1261
+ * @returns Token breakdown for the session's current context window, or null if uninitialized.
1262
+ */
1263
+ contextInfo: async (params) => connection.sendRequest("session.metadata.contextInfo", { sessionId, ...params }),
1264
+ /**
1265
+ * Records a working-directory/git context change and emits a `session.context_changed` event.
1266
+ *
1267
+ * @param params Updated working-directory/git context to record on the session.
1268
+ *
1269
+ * @returns Notify the session that its working directory context has changed. Emits a `session.context_changed` event so consumers (telemetry, OTel tracker, ACP, the timeline UI) can react. Use this when the host has detected a cwd/branch/repo change outside the session's normal lifecycle (e.g., after a shell command in interactive mode).
1270
+ */
1271
+ recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { sessionId, ...params }),
1272
+ /**
1273
+ * Updates the session's recorded working directory.
1274
+ *
1275
+ * @param params Absolute path to set as the session's new working directory.
1276
+ *
1277
+ * @returns Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for `process.chdir` and any related side-effects (file index, etc.); this method only updates the session's own recorded path.
1278
+ */
1279
+ setWorkingDirectory: async (params) => connection.sendRequest("session.metadata.setWorkingDirectory", { sessionId, ...params }),
1280
+ /**
1281
+ * Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
1282
+ *
1283
+ * @param params Model identifier to use when re-tokenizing the session's existing messages.
1284
+ *
1285
+ * @returns Re-tokenize the session's existing messages against `modelId` and return the token totals. Useful for hosts that want an initial estimate of context usage on session resume, before the next agent turn fires `session.context_info_changed` events. Returns zeros for an empty session.
1286
+ */
1287
+ recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { sessionId, ...params })
1288
+ },
1289
+ /** @experimental */
141
1290
  shell: {
1291
+ /**
1292
+ * Starts a shell command and streams output through session notifications.
1293
+ *
1294
+ * @param params Shell command to run, with optional working directory and timeout in milliseconds.
1295
+ *
1296
+ * @returns Identifier of the spawned process, used to correlate streamed output and exit notifications.
1297
+ */
142
1298
  exec: async (params) => connection.sendRequest("session.shell.exec", { sessionId, ...params }),
1299
+ /**
1300
+ * Sends a signal to a shell process previously started via "shell.exec".
1301
+ *
1302
+ * @param params Identifier of a process previously returned by "shell.exec" and the signal to send.
1303
+ *
1304
+ * @returns Indicates whether the signal was delivered; false if the process was unknown or already exited.
1305
+ */
143
1306
  kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params })
144
1307
  },
145
1308
  /** @experimental */
146
1309
  history: {
147
- compact: async () => connection.sendRequest("session.history.compact", { sessionId }),
148
- truncate: async (params) => connection.sendRequest("session.history.truncate", { sessionId, ...params })
1310
+ /**
1311
+ * Compacts the session history to reduce context usage.
1312
+ *
1313
+ * @param params Optional compaction parameters.
1314
+ *
1315
+ * @returns Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
1316
+ */
1317
+ compact: async (params) => connection.sendRequest("session.history.compact", { sessionId, ...params }),
1318
+ /**
1319
+ * Truncates persisted session history to a specific event.
1320
+ *
1321
+ * @param params Identifier of the event to truncate to; this event and all later events are removed.
1322
+ *
1323
+ * @returns Number of events that were removed by the truncation.
1324
+ */
1325
+ truncate: async (params) => connection.sendRequest("session.history.truncate", { sessionId, ...params }),
1326
+ /**
1327
+ * Cancels any in-progress background compaction on a local session.
1328
+ *
1329
+ * @returns Indicates whether an in-progress background compaction was cancelled.
1330
+ */
1331
+ cancelBackgroundCompaction: async () => connection.sendRequest("session.history.cancelBackgroundCompaction", { sessionId }),
1332
+ /**
1333
+ * Aborts any in-progress manual compaction on a local session.
1334
+ *
1335
+ * @returns Indicates whether an in-progress manual compaction was aborted.
1336
+ */
1337
+ abortManualCompaction: async () => connection.sendRequest("session.history.abortManualCompaction", { sessionId }),
1338
+ /**
1339
+ * Produces a markdown summary of the session's conversation context for hand-off scenarios.
1340
+ *
1341
+ * @returns Markdown summary of the conversation context (empty when not available).
1342
+ */
1343
+ summarizeForHandoff: async () => connection.sendRequest("session.history.summarizeForHandoff", { sessionId })
1344
+ },
1345
+ /** @experimental */
1346
+ queue: {
1347
+ /**
1348
+ * Returns the local session's pending user-facing queued items and steering messages.
1349
+ *
1350
+ * @returns Snapshot of the session's pending queued items and immediate-steering messages.
1351
+ */
1352
+ pendingItems: async () => connection.sendRequest("session.queue.pendingItems", { sessionId }),
1353
+ /**
1354
+ * Removes the most recently queued user-facing item (LIFO).
1355
+ *
1356
+ * @returns Indicates whether a user-facing pending item was removed.
1357
+ */
1358
+ removeMostRecent: async () => connection.sendRequest("session.queue.removeMostRecent", { sessionId }),
1359
+ /**
1360
+ * Clears all pending queued items on the local session.
1361
+ */
1362
+ clear: async () => connection.sendRequest("session.queue.clear", { sessionId })
1363
+ },
1364
+ /** @experimental */
1365
+ eventLog: {
1366
+ /**
1367
+ * Reads a batch of session events from a cursor, optionally waiting for new events.
1368
+ *
1369
+ * @param params Cursor, batch size, and optional long-poll/filter parameters for reading session events.
1370
+ *
1371
+ * @returns Batch of session events returned by a read, with cursor and continuation metadata.
1372
+ */
1373
+ read: async (params) => connection.sendRequest("session.eventLog.read", { sessionId, ...params }),
1374
+ /**
1375
+ * Returns a snapshot of the current tail cursor without consuming events.
1376
+ *
1377
+ * @returns Snapshot of the current tail cursor without returning any events. Use this when a consumer wants to subscribe to live events going forward without first paginating through the entire persisted history (which would happen if `read` were called without a cursor on a long-lived session).
1378
+ */
1379
+ tail: async () => connection.sendRequest("session.eventLog.tail", { sessionId }),
1380
+ /**
1381
+ * Registers consumer interest in an event type for runtime gating purposes.
1382
+ *
1383
+ * @param params Event type to register consumer interest for, used by runtime gating logic.
1384
+ *
1385
+ * @returns Opaque handle representing an event-type interest registration.
1386
+ */
1387
+ registerInterest: async (params) => connection.sendRequest("session.eventLog.registerInterest", { sessionId, ...params }),
1388
+ /**
1389
+ * Releases a consumer's previously-registered interest in an event type.
1390
+ *
1391
+ * @param params Opaque handle previously returned by `registerInterest` to release.
1392
+ *
1393
+ * @returns Indicates whether the operation succeeded.
1394
+ */
1395
+ releaseInterest: async (params) => connection.sendRequest("session.eventLog.releaseInterest", { sessionId, ...params })
149
1396
  },
150
1397
  /** @experimental */
151
1398
  usage: {
1399
+ /**
1400
+ * Gets accumulated usage metrics for the session.
1401
+ *
1402
+ * @returns Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
1403
+ */
152
1404
  getMetrics: async () => connection.sendRequest("session.usage.getMetrics", { sessionId })
1405
+ },
1406
+ /** @experimental */
1407
+ remote: {
1408
+ /**
1409
+ * Enables remote session export or steering.
1410
+ *
1411
+ * @param params Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
1412
+ *
1413
+ * @returns GitHub URL for the session and a flag indicating whether remote steering is enabled.
1414
+ */
1415
+ enable: async (params) => connection.sendRequest("session.remote.enable", { sessionId, ...params }),
1416
+ /**
1417
+ * Disables remote session export and steering.
1418
+ */
1419
+ disable: async () => connection.sendRequest("session.remote.disable", { sessionId }),
1420
+ /**
1421
+ * Persists a remote-steerability change emitted by the host as a session event.
1422
+ *
1423
+ * @param params New remote-steerability state to persist as a `session.remote_steerable_changed` event.
1424
+ *
1425
+ * @returns Persist a steerability change as a `session.remote_steerable_changed` event. Used by the host (CLI / SDK consumer) when it has just finished enabling or disabling steering on a remote exporter that the runtime does not directly own.
1426
+ */
1427
+ notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { sessionId, ...params })
1428
+ },
1429
+ /** @experimental */
1430
+ schedule: {
1431
+ /**
1432
+ * Lists the session's currently active scheduled prompts.
1433
+ *
1434
+ * @returns Snapshot of the currently active recurring prompts for this session.
1435
+ */
1436
+ list: async () => connection.sendRequest("session.schedule.list", { sessionId }),
1437
+ /**
1438
+ * Removes a scheduled prompt by id.
1439
+ *
1440
+ * @param params Identifier of the scheduled prompt to remove.
1441
+ *
1442
+ * @returns Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
1443
+ */
1444
+ stop: async (params) => connection.sendRequest("session.schedule.stop", { sessionId, ...params })
153
1445
  }
154
1446
  };
155
1447
  }
@@ -204,6 +1496,31 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
204
1496
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
205
1497
  return handler.rename(params);
206
1498
  });
1499
+ connection.onRequest("sessionFs.sqliteQuery", async (params) => {
1500
+ const handler = getHandlers(params.sessionId).sessionFs;
1501
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
1502
+ return handler.sqliteQuery(params);
1503
+ });
1504
+ connection.onRequest("sessionFs.sqliteExists", async (params) => {
1505
+ const handler = getHandlers(params.sessionId).sessionFs;
1506
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
1507
+ return handler.sqliteExists(params);
1508
+ });
1509
+ connection.onRequest("canvas.open", async (params) => {
1510
+ const handler = getHandlers(params.sessionId).canvas;
1511
+ if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
1512
+ return handler.open(params);
1513
+ });
1514
+ connection.onRequest("canvas.close", async (params) => {
1515
+ const handler = getHandlers(params.sessionId).canvas;
1516
+ if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
1517
+ return handler.close(params);
1518
+ });
1519
+ connection.onRequest("canvas.action.invoke", async (params) => {
1520
+ const handler = getHandlers(params.sessionId).canvas;
1521
+ if (!handler) throw new Error(`No canvas handler registered for session: ${params.sessionId}`);
1522
+ return handler.invoke(params);
1523
+ });
207
1524
  }
208
1525
  export {
209
1526
  createInternalServerRpc,