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