Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/agentHost/common/state/protocol/commands.ts
13405 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
// allow-any-unicode-comment-file
7
// DO NOT EDIT -- auto-generated by scripts/sync-agent-host-protocol.ts
8
9
import type { URI, Snapshot, SessionConfigSchema, SessionSummary, ModelSelection, Turn, TerminalClaim, SessionActiveClient } from './state.js';
10
import type { ActionEnvelope, StateAction } from './actions.js';
11
12
export type { ConfigPropertySchema, ConfigSchema, SessionConfigPropertySchema, SessionConfigSchema } from './state.js';
13
14
// ─── initialize ──────────────────────────────────────────────────────────────
15
16
/**
17
* Establishes a new connection and negotiates the protocol version.
18
* This MUST be the first message sent by the client.
19
*
20
* @category Commands
21
* @method initialize
22
* @direction Client → Server
23
* @messageType Request
24
* @version 1
25
* @see {@link /specification/lifecycle | Lifecycle} for the full handshake flow.
26
*/
27
export interface InitializeParams {
28
/** Protocol version the client speaks */
29
protocolVersion: number;
30
/** Unique client identifier */
31
clientId: string;
32
/** URIs to subscribe to during handshake */
33
initialSubscriptions?: URI[];
34
/**
35
* IETF BCP 47 language tag indicating the client's preferred locale
36
* (e.g. `"en-US"`, `"ja"`). The server SHOULD use this to localise
37
* user-facing strings such as confirmation option labels.
38
*/
39
locale?: string;
40
}
41
42
/**
43
* Result of the `initialize` command.
44
*
45
* If the server does not support the client's protocol version, it MUST return
46
* error code `-32005` (`UnsupportedProtocolVersion`).
47
*/
48
export interface InitializeResult {
49
/** Protocol version the server speaks */
50
protocolVersion: number;
51
/** Current server sequence number */
52
serverSeq: number;
53
/** Snapshots for each `initialSubscriptions` URI */
54
snapshots: Snapshot[];
55
/** Suggested default directory for remote filesystem browsing */
56
defaultDirectory?: URI;
57
}
58
59
// ─── reconnect ───────────────────────────────────────────────────────────────
60
61
/**
62
* Discriminant for reconnect result types.
63
*
64
* @category Commands
65
*/
66
export const enum ReconnectResultType {
67
Replay = 'replay',
68
Snapshot = 'snapshot',
69
}
70
71
/**
72
* Re-establishes a dropped connection. The server replays missed actions or
73
* provides fresh snapshots.
74
*
75
* @category Commands
76
* @method reconnect
77
* @direction Client → Server
78
* @messageType Request
79
* @version 1
80
* @see {@link /specification/lifecycle | Lifecycle} for details.
81
*/
82
export interface ReconnectParams {
83
/** Client identifier from the original connection */
84
clientId: string;
85
/** Last `serverSeq` the client received */
86
lastSeenServerSeq: number;
87
/** URIs the client was subscribed to */
88
subscriptions: URI[];
89
}
90
91
/**
92
* Reconnect result when the server can replay from the requested sequence.
93
*
94
* The server MUST include all replayed data in the response.
95
*/
96
export interface ReconnectReplayResult {
97
/** Discriminant */
98
type: ReconnectResultType.Replay;
99
/** Missed action envelopes since `lastSeenServerSeq` */
100
actions: ActionEnvelope[];
101
}
102
103
/**
104
* Reconnect result when the gap exceeds the replay buffer.
105
*/
106
export interface ReconnectSnapshotResult {
107
/** Discriminant */
108
type: ReconnectResultType.Snapshot;
109
/** Fresh snapshots for each subscription */
110
snapshots: Snapshot[];
111
}
112
113
/** Result of the `reconnect` command. */
114
export type ReconnectResult = ReconnectReplayResult | ReconnectSnapshotResult;
115
116
// ─── subscribe ───────────────────────────────────────────────────────────────
117
118
/**
119
* Subscribe to a URI-identified state resource.
120
*
121
* @category Commands
122
* @method subscribe
123
* @direction Client → Server
124
* @messageType Request
125
* @version 1
126
* @see {@link /specification/subscriptions | Subscriptions}
127
*/
128
export interface SubscribeParams {
129
/** URI to subscribe to */
130
resource: URI;
131
}
132
133
/**
134
* Result of the `subscribe` command.
135
*/
136
export interface SubscribeResult {
137
/** Snapshot of the subscribed resource */
138
snapshot: Snapshot;
139
}
140
141
// ─── createSession ───────────────────────────────────────────────────────────
142
143
/**
144
* Creates a new session with the specified agent provider.
145
*
146
* If the session URI already exists, the server MUST return an error with code
147
* `-32003` (`SessionAlreadyExists`).
148
*
149
* After creation, the client should subscribe to the session URI to receive state
150
* updates. The server also broadcasts a `notify/sessionAdded` notification to all
151
* clients.
152
*
153
* @category Commands
154
* @method createSession
155
* @direction Client → Server
156
* @messageType Request
157
* @version 1
158
* @example
159
* ```jsonc
160
* // Client → Server
161
* { "jsonrpc": "2.0", "id": 2, "method": "createSession",
162
* "params": { "session": "copilot:/<uuid>", "provider": "copilot", "model": "gpt-4o" } }
163
*
164
* // Server → Client (success)
165
* { "jsonrpc": "2.0", "id": 2, "result": null }
166
*
167
* // Server → Client (failure — provider not found)
168
* { "jsonrpc": "2.0", "id": 2, "error": { "code": -32002, "message": "No agent for provider" } }
169
*
170
* // Server → Client (failure — session already exists)
171
* { "jsonrpc": "2.0", "id": 2, "error": { "code": -32003, "message": "Session already exists" } }
172
* ```
173
*/
174
/**
175
* Identifies a source session and turn to fork from.
176
*
177
* When provided in `createSession`, the server populates the new session with
178
* content from the source session up to and including the response of the
179
* specified turn.
180
*/
181
export interface SessionForkSource {
182
/** URI of the existing session to fork from */
183
session: URI;
184
/** Turn ID in the source session; content up to and including this turn's response is copied */
185
turnId: string;
186
}
187
188
export interface CreateSessionParams {
189
/** Session URI (client-chosen, e.g. `copilot:/<uuid>`) */
190
session: URI;
191
/** Agent provider ID */
192
provider?: string;
193
/** Model selection (ID and optional model-specific configuration) */
194
model?: ModelSelection;
195
/** Working directory for the session */
196
workingDirectory?: URI;
197
/**
198
* Fork from an existing session. The new session is populated with content
199
* from the source session up to and including the specified turn's response.
200
*/
201
fork?: SessionForkSource;
202
/**
203
* Agent-specific configuration values collected via `resolveSessionConfig`.
204
* Keys and values correspond to the schema returned by the server.
205
*/
206
config?: Record<string, unknown>;
207
/**
208
* Eagerly claim the active client role for the new session.
209
*
210
* When provided, the server initializes the session with this client as the
211
* active client, equivalent to dispatching a `session/activeClientChanged`
212
* action immediately after creation. The `clientId` MUST match the
213
* `clientId` the creating client supplied in `initialize`.
214
*/
215
activeClient?: SessionActiveClient;
216
}
217
218
// ─── disposeSession ──────────────────────────────────────────────────────────
219
220
/**
221
* Disposes a session and cleans up server-side resources.
222
*
223
* The server broadcasts a `notify/sessionRemoved` notification to all clients.
224
*
225
* @category Commands
226
* @method disposeSession
227
* @direction Client → Server
228
* @messageType Request
229
* @version 1
230
*/
231
export interface DisposeSessionParams {
232
/** Session URI to dispose */
233
session: URI;
234
}
235
236
// ─── createTerminal ──────────────────────────────────────────────────────────
237
238
/**
239
* Creates a new terminal on the server.
240
*
241
* After creation, the client should subscribe to the terminal URI to receive
242
* state updates. The server dispatches `root/terminalsChanged` to update the
243
* root terminal list.
244
*
245
* @category Commands
246
* @method createTerminal
247
* @direction Client → Server
248
* @messageType Request
249
* @version 1
250
*/
251
export interface CreateTerminalParams {
252
/** Terminal URI (client-chosen) */
253
terminal: URI;
254
/** Initial owner of the terminal */
255
claim: TerminalClaim;
256
/** Human-readable terminal name */
257
name?: string;
258
/** Initial working directory URI */
259
cwd?: URI;
260
/** Initial terminal width in columns */
261
cols?: number;
262
/** Initial terminal height in rows */
263
rows?: number;
264
}
265
266
// ─── disposeTerminal ─────────────────────────────────────────────────────────
267
268
/**
269
* Disposes a terminal and kills its process if still running.
270
*
271
* The server dispatches `root/terminalsChanged` to remove the terminal from
272
* the root terminal list.
273
*
274
* @category Commands
275
* @method disposeTerminal
276
* @direction Client → Server
277
* @messageType Request
278
* @version 1
279
*/
280
export interface DisposeTerminalParams {
281
/** Terminal URI to dispose */
282
terminal: URI;
283
}
284
285
// ─── listSessions ────────────────────────────────────────────────────────────
286
287
/**
288
* Returns a list of session summaries. Used to populate session lists and sidebars.
289
*
290
* The session list is **not** part of the state tree because it can be arbitrarily
291
* large. Clients fetch it imperatively and maintain a local cache updated by
292
* `notify/sessionAdded` and `notify/sessionRemoved` notifications.
293
*
294
* @category Commands
295
* @method listSessions
296
* @direction Client → Server
297
* @messageType Request
298
* @version 1
299
*/
300
export interface ListSessionsParams {
301
/** Optional filter criteria */
302
filter?: object;
303
}
304
305
/** Result of the `listSessions` command. */
306
export interface ListSessionsResult {
307
/** The list of session summaries. */
308
items: SessionSummary[];
309
}
310
311
// ─── resourceRead ────────────────────────────────────────────────────────
312
313
/**
314
* Encoding of fetched content data.
315
*
316
* @category Commands
317
*/
318
export const enum ContentEncoding {
319
Base64 = 'base64',
320
Utf8 = 'utf-8',
321
}
322
323
/**
324
* Reads the content of a resource by URI.
325
*
326
* Content references keep the state tree small by storing large data (images,
327
* long tool outputs) by reference rather than inline.
328
*
329
* Binary content (images, etc.) MUST use `base64` encoding. Text content MAY
330
* use `utf-8` encoding.
331
*
332
* @category Commands
333
* @method resourceRead
334
* @direction Client → Server
335
* @messageType Request
336
* @version 1
337
* @throws `NotFound` (`-32008`) if the URI does not exist.
338
* @throws `PermissionDenied` (`-32009`) if the client is not permitted to read the URI.
339
* @example
340
* ```jsonc
341
* // Client → Server
342
* { "jsonrpc": "2.0", "id": 10, "method": "resourceRead",
343
* "params": { "uri": "copilot:/<uuid>/content/img-1" } }
344
*
345
* // Server → Client
346
* { "jsonrpc": "2.0", "id": 10, "result": {
347
* "data": "iVBORw0KGgo...",
348
* "encoding": "base64",
349
* "contentType": "image/png"
350
* }}
351
* ```
352
*/
353
export interface ResourceReadParams {
354
/** Content URI from a `ContentRef` */
355
uri: string;
356
/** Preferred encoding for the returned data (default: server-chosen) */
357
encoding?: ContentEncoding;
358
}
359
360
/**
361
* Result of the `resourceRead` command.
362
*
363
* The server SHOULD honor the `encoding` requested in the params. If the
364
* server cannot provide the requested encoding, it MUST fall back to either
365
* `base64` or `utf-8`.
366
*/
367
export interface ResourceReadResult {
368
/** Content encoded as a string */
369
data: string;
370
/** How `data` is encoded */
371
encoding: ContentEncoding;
372
/** Content type (e.g. `"image/png"`, `"text/plain"`) */
373
contentType?: string;
374
}
375
376
// ─── resourceWrite ───────────────────────────────────────────────────────────
377
378
/**
379
* Writes content to a file on the server's filesystem.
380
*
381
* Binary content (images, etc.) MUST use `base64` encoding. Text content MAY
382
* use `utf-8` encoding.
383
*
384
* If the file does not exist, it is created. If the file already exists, it is
385
* overwritten unless `createOnly` is set.
386
*
387
* @category Commands
388
* @method resourceWrite
389
* @direction Client → Server
390
* @messageType Request
391
* @version 1
392
* @throws `NotFound` (`-32008`) if the parent directory does not exist.
393
* @throws `PermissionDenied` (`-32009`) if the client is not permitted to write to the path.
394
* @throws `AlreadyExists` (`-32010`) if `createOnly` is set and the file already exists.
395
* @example
396
* ```jsonc
397
* // Client → Server
398
* { "jsonrpc": "2.0", "id": 11, "method": "resourceWrite",
399
* "params": { "uri": "file:///workspace/hello.txt", "data": "SGVsbG8=",
400
* "encoding": "base64", "contentType": "text/plain" } }
401
*
402
* // Server → Client
403
* { "jsonrpc": "2.0", "id": 11, "result": {} }
404
* ```
405
*/
406
export interface ResourceWriteParams {
407
/** Target file URI on the server filesystem */
408
uri: URI;
409
/** Content encoded as a string */
410
data: string;
411
/** How `data` is encoded */
412
encoding: ContentEncoding;
413
/** Content type (e.g. `"text/plain"`, `"image/png"`) */
414
contentType?: string;
415
/**
416
* If `true`, the server MUST fail if the file already exists instead of
417
* overwriting it. Useful for safe creation of new files.
418
*/
419
createOnly?: boolean;
420
}
421
422
/**
423
* Result of the `resourceWrite` command.
424
*
425
* An empty object on success.
426
*/
427
export interface ResourceWriteResult {
428
}
429
430
// ─── resourceList ────────────────────────────────────────────────────────
431
432
/**
433
* Lists directory entries at a file URI on the server's filesystem.
434
*
435
* This is intended for remote folder pickers and similar UI that needs to let
436
* users navigate the server's local filesystem.
437
*
438
* The server MUST return success only if the target exists and is a directory.
439
* If the target does not exist, is not a directory, or cannot be accessed, the
440
* server MUST return a JSON-RPC error.
441
*
442
* @category Commands
443
* @method resourceList
444
* @direction Client → Server
445
* @messageType Request
446
* @version 1
447
* @throws `NotFound` (`-32008`) if the directory does not exist.
448
* @throws `PermissionDenied` (`-32009`) if the client is not permitted to browse the directory.
449
*/
450
export interface ResourceListParams {
451
/** Directory URI on the server filesystem */
452
uri: URI;
453
}
454
455
/**
456
* Directory entry returned by `resourceList`.
457
*/
458
export interface DirectoryEntry {
459
/** Base name of the entry */
460
name: string;
461
/** Whether the entry is a file or directory */
462
type: 'file' | 'directory';
463
}
464
465
/**
466
* Result of the `resourceList` command.
467
*/
468
export interface ResourceListResult {
469
/** Entries directly contained in the requested directory */
470
entries: DirectoryEntry[];
471
}
472
473
// ─── fetchTurns ──────────────────────────────────────────────────────────────
474
475
/**
476
* Fetches historical turns for a session. Used for lazy loading of conversation
477
* history.
478
*
479
* @category Commands
480
* @method fetchTurns
481
* @direction Client → Server
482
* @messageType Request
483
* @version 1
484
* @example
485
* ```jsonc
486
* // Client → Server (fetch the 20 most recent turns)
487
* { "jsonrpc": "2.0", "id": 8, "method": "fetchTurns",
488
* "params": { "session": "copilot:/<uuid>", "limit": 20 } }
489
*
490
* // Server → Client
491
* { "jsonrpc": "2.0", "id": 8, "result": {
492
* "turns": [ { "id": "t1", ... }, { "id": "t2", ... } ],
493
* "hasMore": true
494
* }}
495
*
496
* // Client → Server (fetch 20 turns before t1)
497
* { "jsonrpc": "2.0", "id": 9, "method": "fetchTurns",
498
* "params": { "session": "copilot:/<uuid>", "before": "t1", "limit": 20 } }
499
* ```
500
*/
501
export interface FetchTurnsParams {
502
/** Session URI */
503
session: URI;
504
/** Turn ID to fetch before (exclusive). Omit to fetch from the most recent turn. */
505
before?: string;
506
/** Maximum number of turns to return. Server MAY impose its own upper bound. */
507
limit?: number;
508
}
509
510
/**
511
* Result of the `fetchTurns` command.
512
*/
513
export interface FetchTurnsResult {
514
/** The requested turns, ordered oldest-first */
515
turns: Turn[];
516
/** Whether more turns exist before the returned range */
517
hasMore: boolean;
518
}
519
520
// ─── unsubscribe ─────────────────────────────────────────────────────────────
521
522
/**
523
* Stop receiving updates for a URI.
524
*
525
* @category Commands
526
* @method unsubscribe
527
* @direction Client → Server
528
* @messageType Notification
529
* @version 1
530
* @see {@link /specification/subscriptions | Subscriptions}
531
*/
532
export interface UnsubscribeParams {
533
/** URI to unsubscribe from */
534
resource: URI;
535
}
536
537
// ─── dispatchAction ──────────────────────────────────────────────────────────
538
539
/**
540
* Fire-and-forget action dispatch (write-ahead). The client applies actions
541
* optimistically to local state.
542
*
543
* @category Commands
544
* @method dispatchAction
545
* @direction Client → Server
546
* @messageType Notification
547
* @version 1
548
* @see {@link /guide/actions | Actions} for the full list of client-dispatchable actions.
549
*/
550
export interface DispatchActionParams {
551
/** Client sequence number */
552
clientSeq: number;
553
/** The action to dispatch */
554
action: StateAction;
555
}
556
557
// ─── resourceCopy ────────────────────────────────────────────────────────────
558
559
/**
560
* Copies a resource from one URI to another on the server's filesystem.
561
*
562
* If the destination already exists, it is overwritten unless `failIfExists`
563
* is set.
564
*
565
* @category Commands
566
* @method resourceCopy
567
* @direction Client → Server
568
* @messageType Request
569
* @version 1
570
* @throws `NotFound` (`-32008`) if the source does not exist.
571
* @throws `PermissionDenied` (`-32009`) if the client is not permitted to read the source or write to the destination.
572
* @throws `AlreadyExists` (`-32010`) if `failIfExists` is set and the destination already exists.
573
*/
574
export interface ResourceCopyParams {
575
/** Source URI to copy from */
576
source: URI;
577
/** Destination URI to copy to */
578
destination: URI;
579
/**
580
* If `true`, the server MUST fail if the destination already exists instead
581
* of overwriting it.
582
*/
583
failIfExists?: boolean;
584
}
585
586
/**
587
* Result of the `resourceCopy` command.
588
*
589
* An empty object on success.
590
*/
591
export interface ResourceCopyResult {
592
}
593
594
// ─── resourceDelete ──────────────────────────────────────────────────────────
595
596
/**
597
* Deletes a resource at a URI on the server's filesystem.
598
*
599
* @category Commands
600
* @method resourceDelete
601
* @direction Client → Server
602
* @messageType Request
603
* @version 1
604
* @throws `NotFound` (`-32008`) if the resource does not exist.
605
* @throws `PermissionDenied` (`-32009`) if the client is not permitted to delete the resource.
606
*/
607
export interface ResourceDeleteParams {
608
/** URI of the resource to delete */
609
uri: URI;
610
/**
611
* If `true` and the target is a directory, delete it and all its contents
612
* recursively. If `false` (default), deleting a non-empty directory MUST fail.
613
*/
614
recursive?: boolean;
615
}
616
617
/**
618
* Result of the `resourceDelete` command.
619
*
620
* An empty object on success.
621
*/
622
export interface ResourceDeleteResult {
623
}
624
625
// ─── resourceMove ────────────────────────────────────────────────────────────
626
627
/**
628
* Moves (renames) a resource from one URI to another on the server's filesystem.
629
*
630
* If the destination already exists, it is overwritten unless `failIfExists`
631
* is set.
632
*
633
* @category Commands
634
* @method resourceMove
635
* @direction Client → Server
636
* @messageType Request
637
* @version 1
638
* @throws `NotFound` (`-32008`) if the source does not exist.
639
* @throws `PermissionDenied` (`-32009`) if the client is not permitted to move the resource.
640
* @throws `AlreadyExists` (`-32010`) if `failIfExists` is set and the destination already exists.
641
*/
642
export interface ResourceMoveParams {
643
/** Source URI to move from */
644
source: URI;
645
/** Destination URI to move to */
646
destination: URI;
647
/**
648
* If `true`, the server MUST fail if the destination already exists instead
649
* of overwriting it.
650
*/
651
failIfExists?: boolean;
652
}
653
654
/**
655
* Result of the `resourceMove` command.
656
*
657
* An empty object on success.
658
*/
659
export interface ResourceMoveResult {
660
}
661
662
// ─── authenticate ────────────────────────────────────────────────────────────
663
664
/**
665
* Pushes a Bearer token for a protected resource. The `resource` field MUST
666
* match a `ProtectedResourceMetadata.resource` value declared by an agent
667
* in `AgentInfo.protectedResources`.
668
*
669
* Tokens are delivered using [RFC 6750](https://datatracker.ietf.org/doc/html/rfc6750)
670
* (Bearer Token Usage) semantics. The client obtains the token from the
671
* authorization server(s) listed in the resource's metadata and pushes it
672
* to the server via this command.
673
*
674
* @category Commands
675
* @method authenticate
676
* @direction Client → Server
677
* @messageType Request
678
* @version 1
679
* @see {@link /specification/authentication | Authentication}
680
* @example
681
* ```jsonc
682
* // Client → Server
683
* { "jsonrpc": "2.0", "id": 3, "method": "authenticate",
684
* "params": { "resource": "https://api.github.com", "token": "gho_xxxx" } }
685
*
686
* // Server → Client (success)
687
* { "jsonrpc": "2.0", "id": 3, "result": {} }
688
*
689
* // Server → Client (failure — invalid token)
690
* { "jsonrpc": "2.0", "id": 3, "error": { "code": -32007, "message": "Invalid token" } }
691
* ```
692
*/
693
export interface AuthenticateParams {
694
/**
695
* The protected resource identifier. MUST match a `resource` value from
696
* `ProtectedResourceMetadata` declared in `AgentInfo.protectedResources`.
697
*/
698
resource: string;
699
/** Bearer token obtained from the resource's authorization server */
700
token: string;
701
}
702
703
/**
704
* Result of the `authenticate` command.
705
*
706
* An empty object on success. If the token is invalid or the resource is
707
* unrecognized, the server MUST return a JSON-RPC error (e.g. `AuthRequired`
708
* `-32007` or `InvalidParams` `-32602`).
709
*/
710
export interface AuthenticateResult {
711
}
712
713
// ─── resolveSessionConfig ────────────────────────────────────────────────────
714
715
/**
716
* Iteratively resolves the session configuration schema. The client sends the
717
* current partial session config and any user-filled metadata values. The server
718
* returns a property schema describing what additional metadata is needed,
719
* contextual to the current selections.
720
*
721
* The client calls this command whenever the user changes a significant input
722
* (e.g. picks a working directory, toggles a property). Each response returns
723
* the full current property set (not a delta). The returned `values` contain
724
* server-resolved defaults to pass to `createSession`.
725
*
726
* @category Commands
727
* @method resolveSessionConfig
728
* @direction Client → Server
729
* @messageType Request
730
* @version 1
731
* @example
732
* ```jsonc
733
* // Step 1: Client picks a working directory
734
* // Client → Server
735
* { "jsonrpc": "2.0", "id": 5, "method": "resolveSessionConfig",
736
* "params": { "workingDirectory": "file:///home/user/my-project" } }
737
*
738
* // Server → Client (git repo detected, offers worktree option)
739
* { "jsonrpc": "2.0", "id": 5, "result": {
740
* "schema": {
741
* "type": "object",
742
* "properties": {
743
* "target": { "type": "string", "title": "Target", "enum": ["workspace", "worktree"] }
744
* }
745
* },
746
* "values": {}
747
* }}
748
*
749
* // Step 2: User enables worktree
750
* // Client → Server
751
* { "jsonrpc": "2.0", "id": 6, "method": "resolveSessionConfig",
752
* "params": { "workingDirectory": "file:///home/user/my-project",
753
* "config": { "target": "worktree" } } }
754
*
755
* // Server → Client (now requires branch selection)
756
* { "jsonrpc": "2.0", "id": 6, "result": {
757
* "schema": {
758
* "type": "object",
759
* "properties": {
760
* "target": { "type": "string", "title": "Target", "enum": ["workspace", "worktree"] },
761
* "baseBranch": { "type": "string", "title": "Base Branch",
762
* "enum": ["main", "develop"],
763
* "enumLabels": ["main", "develop"] }
764
* },
765
* "required": ["baseBranch"]
766
* },
767
* "values": { "target": "worktree" }
768
* }}
769
* ```
770
*/
771
export interface ResolveSessionConfigParams {
772
/** Agent provider ID */
773
provider?: string;
774
/** Working directory for the session */
775
workingDirectory?: URI;
776
/** Current user-filled configuration values */
777
config?: Record<string, unknown>;
778
}
779
780
/**
781
* Result of the `resolveSessionConfig` command.
782
*/
783
export interface ResolveSessionConfigResult {
784
/** JSON Schema describing available configuration properties given the current context */
785
schema: SessionConfigSchema;
786
/** Current configuration values (echoed back with server-resolved defaults applied) */
787
values: Record<string, unknown>;
788
}
789
790
// ─── sessionConfigCompletions ────────────────────────────────────────────────
791
792
/**
793
* A single value item returned by `sessionConfigCompletions`.
794
*
795
* @category Commands
796
*/
797
export interface SessionConfigValueItem {
798
/** The value to store in config */
799
value: string;
800
/** Human-readable display label */
801
label: string;
802
/** Optional secondary description */
803
description?: string;
804
}
805
806
/**
807
* Queries the server for allowed values of a dynamic session config property.
808
*
809
* Used when a property in the schema returned by `resolveSessionConfig` has
810
* `enumDynamic: true`. The client sends a search query and receives matching
811
* values with display metadata.
812
*
813
* @category Commands
814
* @method sessionConfigCompletions
815
* @direction Client → Server
816
* @messageType Request
817
* @version 1
818
* @example
819
* ```jsonc
820
* // Client → Server (user types "ma" in branch picker)
821
* { "jsonrpc": "2.0", "id": 7, "method": "sessionConfigCompletions",
822
* "params": { "workingDirectory": "file:///home/user/my-project",
823
* "config": { "target": "worktree" },
824
* "property": "baseBranch", "query": "ma" } }
825
*
826
* // Server → Client
827
* { "jsonrpc": "2.0", "id": 7, "result": {
828
* "items": [
829
* { "value": "main", "label": "main", "icon": "git-branch" },
830
* { "value": "main-v2", "label": "main-v2", "icon": "git-branch" }
831
* ]
832
* }}
833
* ```
834
*/
835
export interface SessionConfigCompletionsParams {
836
/** Agent provider ID */
837
provider?: string;
838
/** Working directory for the session */
839
workingDirectory?: URI;
840
/** Current user-filled configuration values (provides context for the query) */
841
config?: Record<string, unknown>;
842
/** Property id from the schema to query values for */
843
property: string;
844
/** Search filter text (empty or omitted returns default/recent values) */
845
query?: string;
846
}
847
848
/**
849
* Result of the `sessionConfigCompletions` command.
850
*/
851
export interface SessionConfigCompletionsResult {
852
/** Matching value items */
853
items: SessionConfigValueItem[];
854
}
855
856