@anhlp/alp-protocol 0.0.1-beta.3 → 0.0.1-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/dist/rpc.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /** Portable JSON-RPC structures; implementations and provider SDKs stay outside protocol. */
2
2
  import type { RuntimeKind, Pin } from './dto.js';
3
- import type { AlpError, Envelope, SessionSnapshot, TreeStatus, UserQuestion } from './events.js';
4
- import type { PauseState, PromptContent, RecallAnswer, SessionPreview, SessionSpec, SessionSummary } from './session.js';
3
+ import type { AlpError, Envelope, SessionSnapshot, TreeStatus, TurnAttention, UserQuestion } from './events.js';
4
+ import type { ConfigureOutcome, ConfigurePreview, ConversationBranch, ForkProvenance, PauseState, PromptContent, RecallAnswer, ResumeCommand, SessionPreview, SessionSpec, SessionSummary } from './session.js';
5
5
  import type { EntryName, LanguageSetting, LibraryEntryRow, LibraryKind, LibraryScope, LibrarySource, TaskRow, TeamRow } from './dto.js';
6
+ import type { ScheduleJob, ScheduleStatus } from './schedule.js';
6
7
  export type RpcId = string | number | null;
7
8
  export type RpcErrorData = {
8
9
  code: number;
@@ -30,17 +31,566 @@ export type EventNotification = {
30
31
  method: 'event';
31
32
  params: Envelope;
32
33
  };
34
+ /** Why a terminal ended (§12.10). */
35
+ export type TerminalEndReason = 'exited' | 'closed' | 'idle' | 'lifetime' | 'detached' | 'revoked' | 'disabled' | 'shutdown';
36
+ /** A terminal as clients see it (capability `terminal`, §12.10): never a process id, shell path or host path. */
37
+ export type TerminalInfo = {
38
+ terminalId: string;
39
+ workspaceId: string;
40
+ title: string;
41
+ cols: number;
42
+ rows: number;
43
+ state: 'running' | 'exited';
44
+ attached: boolean;
45
+ createdAt: string;
46
+ lastActivityAt: string;
47
+ expiresAt: string;
48
+ exitCode?: number | null;
49
+ signal?: number | null;
50
+ endReason?: TerminalEndReason;
51
+ /** Absent: full native protection. root-only: best-effort Linux. none: Windows ConPTY, best-effort cleanup. */
52
+ protection?: 'root-only' | 'none';
53
+ };
54
+ /** Effective terminal limits a daemon.hello advertises with capability `terminal`. */
55
+ export type TerminalLimits = {
56
+ maxPerPrincipal: number;
57
+ maxPerDaemon: number;
58
+ maxInputBytes: number;
59
+ maxOutputFrameBytes: number;
60
+ replayBytes: number;
61
+ idleMs: number;
62
+ maxLifetimeMs: number;
63
+ reconnectMs: number;
64
+ };
65
+ /** params of a terminal.event notification, sent only to the connection attached to the terminal. */
66
+ export type TerminalEvent = {
67
+ terminalId: string;
68
+ type: 'output';
69
+ seq: number;
70
+ data: string;
71
+ } | {
72
+ terminalId: string;
73
+ type: 'exit';
74
+ seq: number;
75
+ exitCode: number | null;
76
+ signal: number | null;
77
+ reason: TerminalEndReason;
78
+ } | {
79
+ terminalId: string;
80
+ type: 'detached';
81
+ reason: 'replaced' | 'slow_consumer';
82
+ };
83
+ export type CatalogUpdatedNotification = {
84
+ jsonrpc: '2.0';
85
+ method: 'catalog.updated';
86
+ params: {
87
+ fetchedAt?: string;
88
+ };
89
+ };
90
+ export type TerminalChangedNotification = {
91
+ jsonrpc: '2.0';
92
+ method: 'terminal.changed';
93
+ params: {
94
+ watchId: string;
95
+ cursor: string;
96
+ };
97
+ };
98
+ export type TerminalNotification = {
99
+ jsonrpc: '2.0';
100
+ method: 'terminal.event';
101
+ params: TerminalEvent;
102
+ };
33
103
  /** Names a daemon may list in its daemon.hello result (schema/methods-v1.json `capabilities`). */
34
- export type Capability = 'attach.after' | 'prompt.receipts' | 'extension.methods' | 'team' | 'task' | 'library' | 'library.project.write' | 'settings.language' | 'session.list.page' | 'question.watch' | 'question.watch.turns' | 'workspace.files' | 'workspace.files.read' | 'prompt.images';
104
+ export type HistoryItem = Envelope | {
105
+ cursor: number;
106
+ oversized: {
107
+ bytes: number;
108
+ };
109
+ };
110
+ export type HistoryPage = {
111
+ generation: string;
112
+ items: HistoryItem[];
113
+ olderCursor?: string;
114
+ hasOlder: boolean;
115
+ tipCursor: number;
116
+ };
117
+ export type Capability = 'session.interrupt.turn' | 'session.fork' | 'session.rewind' | 'session.reload' | 'session.resumeCommand' | 'session.configure.live' | 'terminal' | 'terminal.capture' | 'terminal.watch' | 'attachments' | 'workspace.git' | 'workspace.git.facts' | 'workspace.worktree' | 'workspace.registry' | 'session.history' | 'attach.after' | 'prompt.receipts' | 'extension.methods' | 'team' | 'task' | 'library' | 'library.project.write' | 'settings.language' | 'session.list.page' | 'question.watch' | 'question.watch.turns' | 'session.attention' | 'workspace.files' | 'workspace.files.read' | 'workspace.files.browse' | 'host.directories' | 'prompt.images' | 'schedule' | 'catalog.live';
35
118
  /** `data.reason` values alpd sets on errors (docs/protocol/alp-json-rpc-v1.md §5.3). */
36
- export type ErrorReason = 'hello_required' | 'protocol_version' | 'invalid_params' | 'invalid_id' | 'batch_unsupported' | 'frame_too_large' | 'response_too_large' | 'persistence_failed' | 'outcome_unknown' | 'key_conflict' | 'invalid_path' | 'invalid_scope' | 'invalid_entry' | 'secret_marker' | 'not_alp_project' | 'unknown_task' | 'not_found' | 'library_policy' | 'unsafe_path' | 'revision_conflict' | 'task_state' | 'in_use' | 'busy' | 'unreadable' | 'not_directory' | 'blocked_path' | 'ignored' | 'linked' | 'binary' | 'too_large';
119
+ export type ErrorReason = 'hello_required' | 'protocol_version' | 'invalid_params' | 'invalid_id' | 'batch_unsupported' | 'frame_too_large' | 'invalid_cursor' | 'stale_cursor' | 'history_gap' | 'stale_revision' | 'request_conflict' | 'cwd_mismatch' | 'workspace_mismatch' | 'corrupt_registry' | 'identity_changed' | 'response_too_large' | 'persistence_failed' | 'outcome_unknown' | 'key_conflict' | 'invalid_path' | 'invalid_scope' | 'invalid_entry' | 'secret_marker' | 'not_alp_project' | 'unknown_task' | 'not_found' | 'library_policy' | 'unsafe_path' | 'revision_conflict' | 'task_state' | 'in_use' | 'busy' | 'unreadable' | 'not_directory' | 'blocked_path' | 'ignored' | 'linked' | 'binary' | 'too_large' | 'outside' | 'changed' | 'not_repository' | 'unknown_ref' | 'invalid_compare' | 'stale_snapshot' | 'git_unavailable' | 'git_failed' | 'invalid_name' | 'invalid_data' | 'attachment_too_large' | 'offset_mismatch' | 'chunk_conflict' | 'upload_incomplete' | 'hash_mismatch' | 'upload_expired' | 'quota_exceeded' | 'attachment_referenced' | 'attachment_limit' | 'attachment_unavailable' | 'attachment_unsupported' | 'session_busy' | 'stale_generation' | 'turn_not_found' | 'turn_in_progress' | 'empty_prefix' | 'boundary_unmapped' | 'runtime_unsupported' | 'native_refused' | 'branch_not_found' | 'attachment_forbidden' | 'session_closed' | 'no_history' | 'runtime_mismatch' | 'agent_mismatch' | 'permission_escalation' | 'team_not_found' | 'terminal_capture_unavailable' | 'terminal_capture_too_large' | 'terminal_snapshot_too_large' | 'terminal_disabled' | 'terminal_unsupported' | 'terminal_limit' | 'not_attached' | 'terminal_exited' | 'input_too_large';
37
120
  type Empty = Record<string, never>;
38
121
  /**
39
122
  * Params and result of every v1 method, as schema/methods-v1.json defines them; the protocol tests
40
123
  * type-check the golden fixtures against this map, so the two cannot drift. Results may carry
41
124
  * properties this map does not name: clients ignore them.
42
125
  */
126
+ export type RegistryProject = {
127
+ id: string;
128
+ root: string;
129
+ canonical?: string;
130
+ customName?: string | null;
131
+ addedAt: string;
132
+ removedAt?: string | null;
133
+ revision?: number;
134
+ };
135
+ export type RegistryWorkspace = {
136
+ branch?: string | null;
137
+ managedWorktree?: boolean;
138
+ id: string;
139
+ projectId: string;
140
+ directory: string;
141
+ canonical?: string;
142
+ title?: string | null;
143
+ pinnedAt?: string | null;
144
+ archivedAt?: string | null;
145
+ labels: string[];
146
+ createdAt: string;
147
+ revision?: number;
148
+ idempotencyKey?: string;
149
+ };
150
+ /** workspace.git.status and workspace.git.diff (capability `workspace.git`, §12.5): paths are relative to the workspace, never host paths. */
151
+ export type GitChange = 'modified' | 'added' | 'deleted' | 'renamed' | 'copied' | 'typechange' | 'untracked' | 'conflicted';
152
+ export type GitCompare = {
153
+ mode: 'uncommitted' | 'staged' | 'unstaged' | 'base';
154
+ baseRef?: string;
155
+ ignoreWhitespace?: boolean;
156
+ };
157
+ export type GitStatusFile = {
158
+ path: string;
159
+ oldPath?: string;
160
+ change: GitChange;
161
+ staged: boolean;
162
+ unstaged: boolean;
163
+ };
164
+ export type GitStatus = {
165
+ state: 'repository' | 'not_repository' | 'unsupported';
166
+ reason?: string;
167
+ branch: string | null;
168
+ detached: boolean;
169
+ head: string | null;
170
+ upstream: {
171
+ ref: string;
172
+ ahead: number;
173
+ behind: number;
174
+ } | null;
175
+ baseRef: string | null;
176
+ aheadBehind: {
177
+ ahead: number;
178
+ behind: number;
179
+ } | null;
180
+ hasRemote: boolean;
181
+ remoteUrl: string | null;
182
+ dirty: boolean;
183
+ files: GitStatusFile[];
184
+ hiddenCount: number;
185
+ truncated: boolean;
186
+ snapshot: string;
187
+ };
188
+ export type GitDiffLine = {
189
+ type: 'add' | 'remove' | 'context';
190
+ content: string;
191
+ noNewline?: true;
192
+ };
193
+ export type GitDiffHunk = {
194
+ oldStart: number;
195
+ oldCount: number;
196
+ newStart: number;
197
+ newCount: number;
198
+ context?: string;
199
+ lines: GitDiffLine[];
200
+ };
201
+ export type GitDiffFile = {
202
+ path: string;
203
+ oldPath?: string;
204
+ change: GitChange;
205
+ kind: 'text' | 'binary' | 'too_large' | 'withheld' | 'symlink' | 'submodule';
206
+ additions: number;
207
+ deletions: number;
208
+ hunks: GitDiffHunk[];
209
+ };
210
+ export type GitDiffPage = {
211
+ compare: {
212
+ mode: GitCompare['mode'];
213
+ baseRef?: string;
214
+ ignoreWhitespace: boolean;
215
+ };
216
+ snapshot: string;
217
+ files: GitDiffFile[];
218
+ hiddenCount: number;
219
+ truncated: boolean;
220
+ nextCursor?: string;
221
+ };
222
+ /**
223
+ * workspace.git.facts (capability `workspace.git.facts`, §12.5): an owner-only answer for a host
224
+ * directory, so `repoRoot` is a host path (the directory's real path, or the enclosing repository's
225
+ * top level for `not_repository_root`). Never forwarded by a gateway.
226
+ */
227
+ export type GitCheckoutFacts = {
228
+ repoRoot: string;
229
+ branch: string | null;
230
+ detached: boolean;
231
+ head: string | null;
232
+ hasRemote: boolean;
233
+ remoteUrl: string | null;
234
+ dirty: boolean;
235
+ };
236
+ export type GitFacts = ({
237
+ kind: 'ok' | 'not_repository_root';
238
+ } & GitCheckoutFacts) | {
239
+ kind: 'unknown';
240
+ } | {
241
+ kind: 'unsupported';
242
+ reason: 'worktree_elsewhere' | 'inside_git_dir';
243
+ };
244
+ /**
245
+ * Capability `attachments` (§12.6). Principal context is set only by a trusted gateway on its own
246
+ * connection; a local client leaves it out and acts as the owner.
247
+ */
248
+ export type PrincipalContext = {
249
+ principalId?: string;
250
+ principalEpoch?: string;
251
+ authorizedRoots?: string[];
252
+ };
253
+ /** A committed attachment as clients see it: ids and display metadata, never a host path or URL. */
254
+ export type AttachmentInfo = {
255
+ attachmentId: string;
256
+ sessionId: string;
257
+ name: string;
258
+ mimeType: string;
259
+ detectedMimeType: string;
260
+ size: number;
261
+ sha256: string;
262
+ createdAt: string;
263
+ committedAt: string;
264
+ referenced: boolean;
265
+ };
266
+ /** Effective attachment limits a daemon.hello advertises with capability `attachments`. */
267
+ export type AttachmentLimits = {
268
+ maxObjectBytes: number;
269
+ maxPerPrompt: number;
270
+ maxPromptBytes: number;
271
+ maxChunkBytes: number;
272
+ maxActiveUploads: number;
273
+ maxPrincipalBytes: number;
274
+ maxDaemonBytes: number;
275
+ uploadTimeoutMs: number;
276
+ unreferencedRetentionMs: number;
277
+ releasedGraceMs: number;
278
+ };
279
+ /** Where a fork cuts the source conversation (§12.7): after a completed turn, or before a turn. */
280
+ export type ForkBoundary = {
281
+ throughTurnId: string;
282
+ } | {
283
+ beforeTurnId: string;
284
+ };
285
+ export type RegistryMutation = {
286
+ requestId: string;
287
+ ifRevision: number;
288
+ };
289
+ export type RegistryPage = {
290
+ revision: number;
291
+ total: number;
292
+ nextCursor: string | null;
293
+ };
43
294
  export type RpcMethodMap = {
295
+ 'terminal.create': {
296
+ params: PrincipalContext & {
297
+ workspaceId: string;
298
+ cols: number;
299
+ rows: number;
300
+ requestId: string;
301
+ protectionAcknowledgment?: 'linux-root-only-v1';
302
+ };
303
+ result: {
304
+ terminal: TerminalInfo;
305
+ };
306
+ };
307
+ 'terminal.list': {
308
+ params: PrincipalContext & {
309
+ workspaceId?: string;
310
+ };
311
+ result: {
312
+ terminals: TerminalInfo[];
313
+ };
314
+ };
315
+ 'terminal.watch': {
316
+ params: PrincipalContext & {
317
+ workspaceId?: string;
318
+ after?: string;
319
+ };
320
+ result: {
321
+ terminals: TerminalInfo[];
322
+ watchId: string;
323
+ cursor: string;
324
+ reset: boolean;
325
+ };
326
+ };
327
+ 'terminal.unwatch': {
328
+ params: Empty;
329
+ result: {
330
+ closed: true;
331
+ };
332
+ };
333
+ 'terminal.capture': {
334
+ params: PrincipalContext & {
335
+ terminalId: string;
336
+ start?: number;
337
+ end?: number;
338
+ stripAnsi?: boolean;
339
+ };
340
+ result: {
341
+ lines: string[];
342
+ totalLines: number;
343
+ };
344
+ };
345
+ 'terminal.attach': {
346
+ params: PrincipalContext & {
347
+ terminalId: string;
348
+ after?: number;
349
+ protectionAcknowledgment?: 'linux-root-only-v1';
350
+ };
351
+ result: {
352
+ terminal: TerminalInfo;
353
+ nextSeq: number;
354
+ gap?: {
355
+ fromSeq: number;
356
+ toSeq: number;
357
+ };
358
+ };
359
+ };
360
+ 'terminal.input': {
361
+ params: PrincipalContext & {
362
+ terminalId: string;
363
+ data: string;
364
+ };
365
+ result: {
366
+ bytes: number;
367
+ };
368
+ };
369
+ 'terminal.resize': {
370
+ params: PrincipalContext & {
371
+ terminalId: string;
372
+ cols: number;
373
+ rows: number;
374
+ };
375
+ result: {
376
+ cols: number;
377
+ rows: number;
378
+ };
379
+ };
380
+ 'terminal.close': {
381
+ params: PrincipalContext & {
382
+ terminalId: string;
383
+ };
384
+ result: {
385
+ closed: true;
386
+ };
387
+ };
388
+ 'terminal.revoke': {
389
+ params: {
390
+ principalId: string;
391
+ };
392
+ result: {
393
+ closed: number;
394
+ };
395
+ };
396
+ 'attachment.begin': {
397
+ params: PrincipalContext & {
398
+ sessionId: string;
399
+ name: string;
400
+ size: number;
401
+ mimeType: string;
402
+ sha256?: string;
403
+ requestId: string;
404
+ };
405
+ result: {
406
+ uploadId: string;
407
+ state: 'uploading' | 'committed';
408
+ received: number;
409
+ size: number;
410
+ maxChunkBytes: number;
411
+ expiresAt?: string;
412
+ attachmentId?: string;
413
+ };
414
+ };
415
+ 'attachment.chunk': {
416
+ params: PrincipalContext & {
417
+ uploadId: string;
418
+ offset: number;
419
+ data: string;
420
+ };
421
+ result: {
422
+ received: number;
423
+ size: number;
424
+ };
425
+ };
426
+ 'attachment.commit': {
427
+ params: PrincipalContext & {
428
+ uploadId: string;
429
+ sha256: string;
430
+ };
431
+ result: {
432
+ attachment: AttachmentInfo;
433
+ };
434
+ };
435
+ 'attachment.abort': {
436
+ params: PrincipalContext & {
437
+ uploadId: string;
438
+ };
439
+ result: {
440
+ aborted: true;
441
+ };
442
+ };
443
+ 'attachment.get': {
444
+ params: PrincipalContext & {
445
+ attachmentId: string;
446
+ };
447
+ result: {
448
+ attachment: AttachmentInfo;
449
+ };
450
+ };
451
+ 'attachment.delete': {
452
+ params: PrincipalContext & {
453
+ attachmentId: string;
454
+ };
455
+ result: {
456
+ deleted: true;
457
+ };
458
+ };
459
+ 'workspace.git.status': {
460
+ params: {
461
+ workspaceId: string;
462
+ };
463
+ result: GitStatus;
464
+ };
465
+ 'workspace.git.diff': {
466
+ params: {
467
+ workspaceId: string;
468
+ compare: GitCompare;
469
+ path?: string;
470
+ cursor?: string;
471
+ };
472
+ result: GitDiffPage;
473
+ };
474
+ 'workspace.git.facts': {
475
+ params: {
476
+ directory: string;
477
+ };
478
+ result: GitFacts;
479
+ };
480
+ 'workspace.worktree.options': {
481
+ params: {
482
+ workspaceId: string;
483
+ };
484
+ result: {
485
+ mappingIds: string[];
486
+ };
487
+ };
488
+ 'workspace.worktree.create': {
489
+ params: RegistryMutation & {
490
+ workspaceId: string;
491
+ mappingId: string;
492
+ };
493
+ result: {
494
+ workspace: RegistryWorkspace;
495
+ revision: number;
496
+ };
497
+ };
498
+ 'workspace.worktree.remove': {
499
+ params: RegistryMutation & {
500
+ workspaceId: string;
501
+ };
502
+ result: {
503
+ workspace: RegistryWorkspace;
504
+ revision: number;
505
+ filesRemoved: true;
506
+ branchRetained: true;
507
+ };
508
+ };
509
+ 'registry.worktree': {
510
+ params: {
511
+ principalId?: string;
512
+ principalEpoch?: string;
513
+ mappingIds?: string[];
514
+ authorizedRoots?: string[];
515
+ };
516
+ result: {
517
+ mappings: Array<{
518
+ id: string;
519
+ source: string;
520
+ }>;
521
+ workspaces: unknown[];
522
+ };
523
+ };
524
+ 'project.list': {
525
+ params: {
526
+ cursor?: string;
527
+ limit?: number;
528
+ projectRoots?: string[];
529
+ };
530
+ result: RegistryPage & {
531
+ projects: RegistryProject[];
532
+ };
533
+ };
534
+ 'workspace.list': {
535
+ params: {
536
+ cursor?: string;
537
+ limit?: number;
538
+ projectRoots?: string[];
539
+ };
540
+ result: RegistryPage & {
541
+ workspaces: RegistryWorkspace[];
542
+ };
543
+ };
544
+ 'workspace.get': {
545
+ params: {
546
+ workspaceId: string;
547
+ };
548
+ result: {
549
+ workspace: RegistryWorkspace;
550
+ revision: number;
551
+ };
552
+ };
553
+ 'project.register': {
554
+ params: RegistryMutation & {
555
+ directory: string;
556
+ };
557
+ result: {
558
+ project: RegistryProject;
559
+ revision: number;
560
+ };
561
+ };
562
+ 'project.remove': {
563
+ params: RegistryMutation & {
564
+ projectId: string;
565
+ };
566
+ result: {
567
+ project: RegistryProject;
568
+ revision: number;
569
+ };
570
+ };
571
+ 'workspace.update': {
572
+ params: RegistryMutation & {
573
+ workspaceId: string;
574
+ title?: string | null;
575
+ pinned?: boolean;
576
+ archived?: boolean;
577
+ };
578
+ result: {
579
+ workspace: RegistryWorkspace;
580
+ revision: number;
581
+ };
582
+ };
583
+ 'registry.owner': {
584
+ params: {
585
+ operation?: string;
586
+ args?: Record<string, unknown>;
587
+ requestId?: string;
588
+ ifRevision?: number;
589
+ };
590
+ result: {
591
+ registry: Record<string, unknown>;
592
+ };
593
+ };
44
594
  'daemon.hello': {
45
595
  params: {
46
596
  protocolVersion: 1;
@@ -60,6 +610,8 @@ export type RpcMethodMap = {
60
610
  maxBytes: number;
61
611
  maxTotalBytes: number;
62
612
  };
613
+ attachmentLimits?: AttachmentLimits;
614
+ terminalLimits?: TerminalLimits;
63
615
  capabilities?: string[];
64
616
  };
65
617
  };
@@ -126,6 +678,27 @@ export type RpcMethodMap = {
126
678
  modes: Array<Record<string, unknown>>;
127
679
  thinkingOptions?: unknown;
128
680
  defaultModel: string;
681
+ fetchedAt?: string;
682
+ providers?: Record<string, {
683
+ status: string;
684
+ fetchedAt?: string;
685
+ error?: string;
686
+ }>;
687
+ };
688
+ };
689
+ 'catalog.refresh': {
690
+ params: Empty;
691
+ result: {
692
+ models: Array<Record<string, unknown>>;
693
+ modes: Array<Record<string, unknown>>;
694
+ thinkingOptions?: unknown;
695
+ defaultModel: string;
696
+ fetchedAt?: string;
697
+ providers?: Record<string, {
698
+ status: string;
699
+ fetchedAt?: string;
700
+ error?: string;
701
+ }>;
129
702
  };
130
703
  };
131
704
  'assignment.recall': {
@@ -153,14 +726,29 @@ export type RpcMethodMap = {
153
726
  questions: UserQuestion[];
154
727
  };
155
728
  };
156
- /** Capability `question.watch`: the waiting questions now; then this connection is told of every tree's `question` and `question.resolved` (of `projectRoot` when given). `turns` (capability `question.watch.turns`): also every root's `turn.ended`. */
729
+ /** Capability `question.watch`: the waiting questions now; then this connection is told of every tree's `question` and `question.resolved` (of `projectRoot` when given). `turns` (capability `question.watch.turns`): also every root's `turn.ended`. `attention` (capability `session.attention`): also each root's attention, now and as it changes. */
157
730
  'question.watch': {
158
731
  params: {
159
732
  projectRoot?: string;
160
733
  turns?: boolean;
734
+ attention?: boolean;
161
735
  };
162
736
  result: {
163
737
  questions: UserQuestion[];
738
+ attention?: Array<{
739
+ sessionId: string;
740
+ attention: TurnAttention;
741
+ }>;
742
+ };
743
+ };
744
+ /** Capability `session.attention`: acknowledges a root's attention for every client; with `at`, only that one (a later turn's stays). */
745
+ 'session.attention.clear': {
746
+ params: {
747
+ sessionId: string;
748
+ at?: string;
749
+ };
750
+ result: {
751
+ cleared: boolean;
164
752
  };
165
753
  };
166
754
  /** Capability `workspace.files`: files under `projectRoot` whose relative path matches `query`, best first; read-only, links not followed. */
@@ -177,12 +765,14 @@ export type RpcMethodMap = {
177
765
  truncated?: boolean;
178
766
  };
179
767
  };
180
- /** Capability `workspace.files.read`: the entries of a directory under `projectRoot` (its root when `path` is left out); links, blocked and (unless `includeIgnored`) .gitignore'd entries left out. */
768
+ /** Capability `workspace.files.read`: the entries of a directory under `projectRoot` (its root when `path` is left out); links, blocked and (unless `includeIgnored`) .gitignore'd entries left out. With `workspace.files.browse`: `cursor` pages past 1000 entries; `internalLinks` lists links inside the root as what they lead to (`target`). */
181
769
  'workspace.files.list': {
182
770
  params: {
183
771
  projectRoot: string;
184
772
  path?: string;
185
773
  includeIgnored?: boolean;
774
+ cursor?: string;
775
+ internalLinks?: boolean;
186
776
  };
187
777
  result: {
188
778
  entries: Array<{
@@ -191,8 +781,11 @@ export type RpcMethodMap = {
191
781
  kind: 'file' | 'directory';
192
782
  size?: number;
193
783
  modifiedAt?: string;
784
+ target?: string;
194
785
  }>;
195
786
  truncated?: boolean;
787
+ nextCursor?: string;
788
+ target?: string;
196
789
  };
197
790
  };
198
791
  /** Capability `workspace.files.read`: a UTF-8 text file under `projectRoot`, at most 1 MiB; read-only, links not followed. */
@@ -209,6 +802,63 @@ export type RpcMethodMap = {
209
802
  modifiedAt?: string;
210
803
  };
211
804
  };
805
+ /** Capability `workspace.files.browse`: every name under `projectRoot` holding `query`'s letters in order (or ending with it), in path order, in pages of a snapshot; read-only, links not entered. */
806
+ 'workspace.files.find': {
807
+ params: {
808
+ projectRoot: string;
809
+ query?: string;
810
+ kinds?: Array<'file' | 'directory'>;
811
+ matchMode?: 'subsequence' | 'suffix';
812
+ limit?: number;
813
+ cursor?: string;
814
+ };
815
+ result: {
816
+ entries: Array<{
817
+ path: string;
818
+ kind: 'file' | 'directory';
819
+ }>;
820
+ nextCursor?: string;
821
+ truncated?: boolean;
822
+ };
823
+ };
824
+ /** Capability `workspace.files.browse`: a file under `projectRoot` as a preview, text, image or binary, at most 50 MiB, its bytes in chunks from `offset`. */
825
+ 'workspace.files.preview': {
826
+ params: {
827
+ projectRoot: string;
828
+ path: string;
829
+ includeIgnored?: boolean;
830
+ internalLinks?: boolean;
831
+ maxBytes?: number;
832
+ offset?: number;
833
+ revision?: string;
834
+ };
835
+ result: {
836
+ path: string;
837
+ target?: string;
838
+ kind: 'text' | 'image' | 'binary';
839
+ mimeType: string;
840
+ size: number;
841
+ modifiedAt: string;
842
+ revision: string;
843
+ encoding: 'base64' | 'none';
844
+ content?: string;
845
+ offset?: number;
846
+ nextOffset?: number;
847
+ };
848
+ };
849
+ /** Capability `host.directories`: directories of the daemon host whose path completes `query` (absolute or under ~), or whose name matches it under the home directory. */
850
+ 'host.directories.search': {
851
+ params: {
852
+ query: string;
853
+ limit?: number;
854
+ };
855
+ result: {
856
+ entries: Array<{
857
+ path: string;
858
+ }>;
859
+ truncated?: boolean;
860
+ };
861
+ };
212
862
  'question.answer': {
213
863
  params: {
214
864
  questionId: string;
@@ -223,11 +873,18 @@ export type RpcMethodMap = {
223
873
  'session.create': {
224
874
  params: {
225
875
  sessionId?: string;
226
- spec: SessionSpec;
227
876
  history?: 'skip' | 'replay';
228
877
  delegation?: boolean;
229
878
  resume?: boolean;
230
- };
879
+ } & ({
880
+ workspaceId: string;
881
+ spec: Omit<SessionSpec, 'cwd'> & {
882
+ cwd?: string;
883
+ };
884
+ } | {
885
+ workspaceId?: undefined;
886
+ spec: SessionSpec;
887
+ });
231
888
  result: {
232
889
  session: SessionSnapshot;
233
890
  attached: boolean;
@@ -243,11 +900,21 @@ export type RpcMethodMap = {
243
900
  preview: SessionPreview;
244
901
  };
245
902
  };
903
+ 'session.history': {
904
+ params: {
905
+ sessionId: string;
906
+ before?: string;
907
+ limit?: number;
908
+ maxBytes?: number;
909
+ };
910
+ result: HistoryPage;
911
+ };
246
912
  'session.attach': {
247
913
  params: {
248
914
  sessionId: string;
249
915
  replay?: boolean;
250
916
  after?: number;
917
+ generation?: string;
251
918
  };
252
919
  result: {
253
920
  session: SessionSummary;
@@ -264,7 +931,7 @@ export type RpcMethodMap = {
264
931
  };
265
932
  };
266
933
  'session.prompt': {
267
- params: {
934
+ params: PrincipalContext & {
268
935
  sessionId: string;
269
936
  clientMessageId: string;
270
937
  delivery?: 'auto' | 'steer';
@@ -280,17 +947,46 @@ export type RpcMethodMap = {
280
947
  };
281
948
  'session.interrupt': {
282
949
  params: {
283
- sessionId: string;
950
+ sessionId: string; /** With session.interrupt.turn, cancel only this turn. */
951
+ turnId?: string;
952
+ };
953
+ result: {
954
+ interrupted?: boolean;
284
955
  };
285
- result: Empty;
286
956
  };
957
+ /**
958
+ * Changes a session's permissions mode while idle; with capability `session.configure.live`, also a live
959
+ * root's model, effort or team (§12.9): those need requestId and ifGeneration, apply at the idle barrier
960
+ * through a restart of its native process on the same conversation, and answer `configured`. Answered
961
+ * once per (sessionId, requestId): a repeat answers the first result with `duplicate: true`.
962
+ */
287
963
  'session.configure': {
288
964
  params: {
289
965
  sessionId: string;
290
966
  mode?: string;
967
+ model?: string;
968
+ thinking?: string;
969
+ team?: string;
970
+ requestId?: string;
971
+ ifGeneration?: string;
972
+ };
973
+ result: {
974
+ session: SessionSnapshot | SessionSummary;
975
+ configured?: ConfigureOutcome;
976
+ duplicate?: true;
977
+ };
978
+ };
979
+ /** What session.configure would run a live root with, and whether it would take it now (capability `session.configure.live`, §12.9). */
980
+ 'session.configure.preview': {
981
+ params: {
982
+ sessionId: string;
983
+ mode?: string;
984
+ model?: string;
985
+ thinking?: string;
986
+ team?: string;
291
987
  };
292
988
  result: {
293
- session: SessionSnapshot;
989
+ preview: ConfigurePreview;
294
990
  };
295
991
  };
296
992
  'session.close': {
@@ -308,6 +1004,83 @@ export type RpcMethodMap = {
308
1004
  session: SessionSummary;
309
1005
  };
310
1006
  };
1007
+ /**
1008
+ * A new root whose conversation is the source's up to a completed turn (capability `session.fork`, §12.7).
1009
+ * Answered once per (sessionId, requestId): a repeat answers the first result with `duplicate: true`.
1010
+ */
1011
+ 'session.fork': {
1012
+ params: PrincipalContext & {
1013
+ sessionId: string;
1014
+ requestId: string;
1015
+ ifGeneration: string;
1016
+ boundary?: ForkBoundary;
1017
+ branchId?: string;
1018
+ workspaceId?: string;
1019
+ newSessionId?: string;
1020
+ title?: string;
1021
+ };
1022
+ result: {
1023
+ session: SessionSummary;
1024
+ forkedFrom: ForkProvenance;
1025
+ duplicate?: true;
1026
+ };
1027
+ };
1028
+ /**
1029
+ * The root's conversation from before a turn on, under the same session id; the later turns stay as a
1030
+ * recoverable branch and no file is changed (capability `session.rewind`, §12.7).
1031
+ */
1032
+ 'session.rewind': {
1033
+ params: {
1034
+ sessionId: string;
1035
+ requestId: string;
1036
+ ifGeneration: string;
1037
+ beforeTurnId: string;
1038
+ };
1039
+ result: {
1040
+ session: SessionSummary;
1041
+ generation: string;
1042
+ branch: ConversationBranch;
1043
+ duplicate?: true;
1044
+ };
1045
+ };
1046
+ /**
1047
+ * Restarts a live root's native process on its own conversation and configuration at the idle
1048
+ * barrier, keeping its session id, history and receipts (capability `session.reload`, §12.8).
1049
+ * Answered once per (sessionId, requestId): a repeat answers the first result with `duplicate: true`.
1050
+ */
1051
+ 'session.reload': {
1052
+ params: {
1053
+ sessionId: string;
1054
+ requestId: string;
1055
+ ifGeneration: string;
1056
+ };
1057
+ result: {
1058
+ session: SessionSummary;
1059
+ duplicate?: true;
1060
+ };
1061
+ };
1062
+ /**
1063
+ * The ALP CLI command that continues a session in a terminal, built by alpd (capability
1064
+ * `session.resumeCommand`, §12.8): argv and its POSIX and Windows command lines, for the clipboard only.
1065
+ */
1066
+ /**
1067
+ * Compacts a live root's context (t-0e56): main writes a checkpoint by skill compact, then its runtime
1068
+ * compacts, or ALP starts a fresh conversation seeded with it. Idle: now; otherwise at its next turn boundary.
1069
+ */
1070
+ 'session.compact': {
1071
+ params: {
1072
+ sessionId: string;
1073
+ };
1074
+ result: {
1075
+ status: 'started' | 'deferred' | 'running';
1076
+ };
1077
+ };
1078
+ 'session.resumeCommand': {
1079
+ params: {
1080
+ sessionId: string;
1081
+ };
1082
+ result: ResumeCommand;
1083
+ };
311
1084
  'session.archive': {
312
1085
  params: {
313
1086
  sessionId: string;
@@ -438,7 +1211,10 @@ export type RpcMethodMap = {
438
1211
  id: string;
439
1212
  gate: string;
440
1213
  note?: string;
441
- ifRev?: number;
1214
+ ifRev?: number; /** One of a human gate's options; picking one approves it. */
1215
+ choice?: string; /** Record the user's rejection instead (note is the reason); the gate stays open. */
1216
+ reject?: boolean; /** Where the user decided, recorded on the gate. Default web. */
1217
+ channel?: 'paseo' | 'web';
442
1218
  };
443
1219
  result: {
444
1220
  id: string;
@@ -563,6 +1339,45 @@ export type RpcMethodMap = {
563
1339
  };
564
1340
  result: LanguageSetting;
565
1341
  };
1342
+ /** Capability `schedule`: a one-shot continuation of a root session, due at `dueAt` (UTC, ISO 8601). */
1343
+ 'schedule.create': {
1344
+ params: {
1345
+ projectRoot: string;
1346
+ sessionId: string;
1347
+ dueAt: string;
1348
+ prompt: string;
1349
+ };
1350
+ result: {
1351
+ job: ScheduleJob;
1352
+ };
1353
+ };
1354
+ 'schedule.list': {
1355
+ params: {
1356
+ projectRoot: string;
1357
+ status?: ScheduleStatus;
1358
+ };
1359
+ result: {
1360
+ jobs: ScheduleJob[];
1361
+ };
1362
+ };
1363
+ 'schedule.get': {
1364
+ params: {
1365
+ id: string;
1366
+ projectRoot: string;
1367
+ };
1368
+ result: {
1369
+ job: ScheduleJob;
1370
+ };
1371
+ };
1372
+ 'schedule.cancel': {
1373
+ params: {
1374
+ id: string;
1375
+ projectRoot: string;
1376
+ };
1377
+ result: {
1378
+ job: ScheduleJob;
1379
+ };
1380
+ };
566
1381
  };
567
1382
  export type RpcMethod = keyof RpcMethodMap;
568
1383
  export type RpcParams<M extends RpcMethod> = RpcMethodMap[M]['params'];