@anhlp/alp-protocol 0.0.0-stage → 0.0.1-beta.10

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.
Files changed (47) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +7 -0
  3. package/README.md +16 -2
  4. package/conformance/cases.json +951 -0
  5. package/conformance/run.d.mts +32 -0
  6. package/conformance/run.mjs +403 -0
  7. package/dist/connection.d.ts +22 -0
  8. package/dist/connection.js +0 -0
  9. package/dist/contract-v1.d.ts +9563 -0
  10. package/dist/contract-v1.js +5 -0
  11. package/dist/contract.d.ts +25 -0
  12. package/dist/contract.js +28 -0
  13. package/dist/dto.d.ts +109 -0
  14. package/dist/dto.js +0 -0
  15. package/dist/events.d.ts +360 -0
  16. package/dist/events.js +0 -0
  17. package/dist/index.d.ts +7 -0
  18. package/dist/index.js +2 -0
  19. package/dist/public.d.ts +1 -0
  20. package/dist/public.js +2 -0
  21. package/dist/rpc.d.ts +1402 -0
  22. package/dist/rpc.js +0 -0
  23. package/dist/schedule.d.ts +48 -0
  24. package/dist/schedule.js +0 -0
  25. package/dist/session.d.ts +286 -0
  26. package/dist/session.js +0 -0
  27. package/dist/validate.d.ts +12 -0
  28. package/dist/validate.js +151 -0
  29. package/dist/wire.d.ts +210 -0
  30. package/dist/wire.js +139 -0
  31. package/fixtures/ipc-v1.jsonl +4 -0
  32. package/fixtures/v1/cases.json +8131 -0
  33. package/package.json +127 -4
  34. package/schema/ipc-v1.json +3366 -0
  35. package/schema/methods-v1.json +9620 -0
  36. package/src/connection.ts +19 -0
  37. package/src/contract-v1.js +2 -0
  38. package/src/contract.js +44 -0
  39. package/src/dto.ts +78 -0
  40. package/src/events.ts +209 -0
  41. package/src/index.ts +7 -0
  42. package/src/public.js +2 -0
  43. package/src/rpc.ts +318 -0
  44. package/src/schedule.ts +48 -0
  45. package/src/session.ts +213 -0
  46. package/src/validate.js +115 -0
  47. package/src/wire.js +221 -0
package/dist/rpc.d.ts ADDED
@@ -0,0 +1,1402 @@
1
+ /** Portable JSON-RPC structures; implementations and provider SDKs stay outside protocol. */
2
+ import type { RuntimeKind, Pin } from './dto.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
+ import type { EntryName, LanguageSetting, LibraryEntryRow, LibraryKind, LibraryScope, LibrarySource, TaskRow, TeamRow } from './dto.js';
6
+ import type { ScheduleJob, ScheduleStatus } from './schedule.js';
7
+ export type RpcId = string | number | null;
8
+ export type RpcErrorData = {
9
+ code: number;
10
+ message: string;
11
+ data?: unknown;
12
+ };
13
+ export type RpcRequest = {
14
+ jsonrpc: '2.0';
15
+ id?: RpcId;
16
+ method: string;
17
+ params?: Record<string, unknown>;
18
+ };
19
+ export type RpcResponse = {
20
+ jsonrpc: '2.0';
21
+ id: RpcId;
22
+ } & ({
23
+ result: unknown;
24
+ error?: never;
25
+ } | {
26
+ error: RpcErrorData;
27
+ result?: never;
28
+ });
29
+ export type EventNotification = {
30
+ jsonrpc: '2.0';
31
+ method: 'event';
32
+ params: Envelope;
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
+ };
103
+ /** Names a daemon may list in its daemon.hello result (schema/methods-v1.json `capabilities`). */
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
+ /** One entry of session.commands: inserted as `/<name>` into the composer. */
118
+ export type SessionCommand = {
119
+ name: string;
120
+ description: string;
121
+ argumentHint?: string;
122
+ kind: 'command' | 'skill';
123
+ };
124
+ export type Capability = 'session.interrupt.turn' | 'session.fork' | 'session.rewind' | 'session.reload' | 'session.resumeCommand' | 'session.commands' | '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';
125
+ /** `data.reason` values alpd sets on errors (docs/protocol/alp-json-rpc-v1.md §5.3). */
126
+ 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' | 'native_command_unsupported' | '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';
127
+ type Empty = Record<string, never>;
128
+ /**
129
+ * Params and result of every v1 method, as schema/methods-v1.json defines them; the protocol tests
130
+ * type-check the golden fixtures against this map, so the two cannot drift. Results may carry
131
+ * properties this map does not name: clients ignore them.
132
+ */
133
+ export type RegistryProject = {
134
+ id: string;
135
+ root: string;
136
+ canonical?: string;
137
+ customName?: string | null;
138
+ addedAt: string;
139
+ removedAt?: string | null;
140
+ revision?: number;
141
+ };
142
+ export type RegistryWorkspace = {
143
+ branch?: string | null;
144
+ managedWorktree?: boolean;
145
+ id: string;
146
+ projectId: string;
147
+ directory: string;
148
+ canonical?: string;
149
+ title?: string | null;
150
+ pinnedAt?: string | null;
151
+ archivedAt?: string | null;
152
+ labels: string[];
153
+ createdAt: string;
154
+ revision?: number;
155
+ idempotencyKey?: string;
156
+ };
157
+ /** workspace.git.status and workspace.git.diff (capability `workspace.git`, §12.5): paths are relative to the workspace, never host paths. */
158
+ export type GitChange = 'modified' | 'added' | 'deleted' | 'renamed' | 'copied' | 'typechange' | 'untracked' | 'conflicted';
159
+ export type GitCompare = {
160
+ mode: 'uncommitted' | 'staged' | 'unstaged' | 'base';
161
+ baseRef?: string;
162
+ ignoreWhitespace?: boolean;
163
+ };
164
+ export type GitStatusFile = {
165
+ path: string;
166
+ oldPath?: string;
167
+ change: GitChange;
168
+ staged: boolean;
169
+ unstaged: boolean;
170
+ };
171
+ export type GitStatus = {
172
+ state: 'repository' | 'not_repository' | 'unsupported';
173
+ reason?: string;
174
+ branch: string | null;
175
+ detached: boolean;
176
+ head: string | null;
177
+ upstream: {
178
+ ref: string;
179
+ ahead: number;
180
+ behind: number;
181
+ } | null;
182
+ baseRef: string | null;
183
+ aheadBehind: {
184
+ ahead: number;
185
+ behind: number;
186
+ } | null;
187
+ hasRemote: boolean;
188
+ remoteUrl: string | null;
189
+ dirty: boolean;
190
+ files: GitStatusFile[];
191
+ hiddenCount: number;
192
+ truncated: boolean;
193
+ snapshot: string;
194
+ };
195
+ export type GitDiffLine = {
196
+ type: 'add' | 'remove' | 'context';
197
+ content: string;
198
+ noNewline?: true;
199
+ };
200
+ export type GitDiffHunk = {
201
+ oldStart: number;
202
+ oldCount: number;
203
+ newStart: number;
204
+ newCount: number;
205
+ context?: string;
206
+ lines: GitDiffLine[];
207
+ };
208
+ export type GitDiffFile = {
209
+ path: string;
210
+ oldPath?: string;
211
+ change: GitChange;
212
+ kind: 'text' | 'binary' | 'too_large' | 'withheld' | 'symlink' | 'submodule';
213
+ additions: number;
214
+ deletions: number;
215
+ hunks: GitDiffHunk[];
216
+ };
217
+ export type GitDiffPage = {
218
+ compare: {
219
+ mode: GitCompare['mode'];
220
+ baseRef?: string;
221
+ ignoreWhitespace: boolean;
222
+ };
223
+ snapshot: string;
224
+ files: GitDiffFile[];
225
+ hiddenCount: number;
226
+ truncated: boolean;
227
+ nextCursor?: string;
228
+ };
229
+ /**
230
+ * workspace.git.facts (capability `workspace.git.facts`, §12.5): an owner-only answer for a host
231
+ * directory, so `repoRoot` is a host path (the directory's real path, or the enclosing repository's
232
+ * top level for `not_repository_root`). Never forwarded by a gateway.
233
+ */
234
+ export type GitCheckoutFacts = {
235
+ repoRoot: string;
236
+ branch: string | null;
237
+ detached: boolean;
238
+ head: string | null;
239
+ hasRemote: boolean;
240
+ remoteUrl: string | null;
241
+ dirty: boolean;
242
+ };
243
+ export type GitFacts = ({
244
+ kind: 'ok' | 'not_repository_root';
245
+ } & GitCheckoutFacts) | {
246
+ kind: 'unknown';
247
+ } | {
248
+ kind: 'unsupported';
249
+ reason: 'worktree_elsewhere' | 'inside_git_dir';
250
+ };
251
+ /**
252
+ * Capability `attachments` (§12.6). Principal context is set only by a trusted gateway on its own
253
+ * connection; a local client leaves it out and acts as the owner.
254
+ */
255
+ export type PrincipalContext = {
256
+ principalId?: string;
257
+ principalEpoch?: string;
258
+ authorizedRoots?: string[];
259
+ };
260
+ /** A committed attachment as clients see it: ids and display metadata, never a host path or URL. */
261
+ export type AttachmentInfo = {
262
+ attachmentId: string;
263
+ sessionId: string;
264
+ name: string;
265
+ mimeType: string;
266
+ detectedMimeType: string;
267
+ size: number;
268
+ sha256: string;
269
+ createdAt: string;
270
+ committedAt: string;
271
+ referenced: boolean;
272
+ };
273
+ /** Effective attachment limits a daemon.hello advertises with capability `attachments`. */
274
+ export type AttachmentLimits = {
275
+ maxObjectBytes: number;
276
+ maxPerPrompt: number;
277
+ maxPromptBytes: number;
278
+ maxChunkBytes: number;
279
+ maxActiveUploads: number;
280
+ maxPrincipalBytes: number;
281
+ maxDaemonBytes: number;
282
+ uploadTimeoutMs: number;
283
+ unreferencedRetentionMs: number;
284
+ releasedGraceMs: number;
285
+ };
286
+ /** Where a fork cuts the source conversation (§12.7): after a completed turn, or before a turn. */
287
+ export type ForkBoundary = {
288
+ throughTurnId: string;
289
+ } | {
290
+ beforeTurnId: string;
291
+ };
292
+ export type RegistryMutation = {
293
+ requestId: string;
294
+ ifRevision: number;
295
+ };
296
+ export type RegistryPage = {
297
+ revision: number;
298
+ total: number;
299
+ nextCursor: string | null;
300
+ };
301
+ export type RpcMethodMap = {
302
+ 'terminal.create': {
303
+ params: PrincipalContext & {
304
+ workspaceId: string;
305
+ cols: number;
306
+ rows: number;
307
+ requestId: string;
308
+ protectionAcknowledgment?: 'linux-root-only-v1';
309
+ };
310
+ result: {
311
+ terminal: TerminalInfo;
312
+ };
313
+ };
314
+ 'terminal.list': {
315
+ params: PrincipalContext & {
316
+ workspaceId?: string;
317
+ };
318
+ result: {
319
+ terminals: TerminalInfo[];
320
+ };
321
+ };
322
+ 'terminal.watch': {
323
+ params: PrincipalContext & {
324
+ workspaceId?: string;
325
+ after?: string;
326
+ };
327
+ result: {
328
+ terminals: TerminalInfo[];
329
+ watchId: string;
330
+ cursor: string;
331
+ reset: boolean;
332
+ };
333
+ };
334
+ 'terminal.unwatch': {
335
+ params: Empty;
336
+ result: {
337
+ closed: true;
338
+ };
339
+ };
340
+ 'terminal.capture': {
341
+ params: PrincipalContext & {
342
+ terminalId: string;
343
+ start?: number;
344
+ end?: number;
345
+ stripAnsi?: boolean;
346
+ };
347
+ result: {
348
+ lines: string[];
349
+ totalLines: number;
350
+ };
351
+ };
352
+ 'terminal.attach': {
353
+ params: PrincipalContext & {
354
+ terminalId: string;
355
+ after?: number;
356
+ protectionAcknowledgment?: 'linux-root-only-v1';
357
+ };
358
+ result: {
359
+ terminal: TerminalInfo;
360
+ nextSeq: number;
361
+ gap?: {
362
+ fromSeq: number;
363
+ toSeq: number;
364
+ };
365
+ };
366
+ };
367
+ 'terminal.input': {
368
+ params: PrincipalContext & {
369
+ terminalId: string;
370
+ data: string;
371
+ };
372
+ result: {
373
+ bytes: number;
374
+ };
375
+ };
376
+ 'terminal.resize': {
377
+ params: PrincipalContext & {
378
+ terminalId: string;
379
+ cols: number;
380
+ rows: number;
381
+ };
382
+ result: {
383
+ cols: number;
384
+ rows: number;
385
+ };
386
+ };
387
+ 'terminal.close': {
388
+ params: PrincipalContext & {
389
+ terminalId: string;
390
+ };
391
+ result: {
392
+ closed: true;
393
+ };
394
+ };
395
+ 'terminal.revoke': {
396
+ params: {
397
+ principalId: string;
398
+ };
399
+ result: {
400
+ closed: number;
401
+ };
402
+ };
403
+ 'attachment.begin': {
404
+ params: PrincipalContext & {
405
+ sessionId: string;
406
+ name: string;
407
+ size: number;
408
+ mimeType: string;
409
+ sha256?: string;
410
+ requestId: string;
411
+ };
412
+ result: {
413
+ uploadId: string;
414
+ state: 'uploading' | 'committed';
415
+ received: number;
416
+ size: number;
417
+ maxChunkBytes: number;
418
+ expiresAt?: string;
419
+ attachmentId?: string;
420
+ };
421
+ };
422
+ 'attachment.chunk': {
423
+ params: PrincipalContext & {
424
+ uploadId: string;
425
+ offset: number;
426
+ data: string;
427
+ };
428
+ result: {
429
+ received: number;
430
+ size: number;
431
+ };
432
+ };
433
+ 'attachment.commit': {
434
+ params: PrincipalContext & {
435
+ uploadId: string;
436
+ sha256: string;
437
+ };
438
+ result: {
439
+ attachment: AttachmentInfo;
440
+ };
441
+ };
442
+ 'attachment.abort': {
443
+ params: PrincipalContext & {
444
+ uploadId: string;
445
+ };
446
+ result: {
447
+ aborted: true;
448
+ };
449
+ };
450
+ 'attachment.get': {
451
+ params: PrincipalContext & {
452
+ attachmentId: string;
453
+ };
454
+ result: {
455
+ attachment: AttachmentInfo;
456
+ };
457
+ };
458
+ 'attachment.delete': {
459
+ params: PrincipalContext & {
460
+ attachmentId: string;
461
+ };
462
+ result: {
463
+ deleted: true;
464
+ };
465
+ };
466
+ 'workspace.git.status': {
467
+ params: {
468
+ workspaceId: string;
469
+ };
470
+ result: GitStatus;
471
+ };
472
+ 'workspace.git.diff': {
473
+ params: {
474
+ workspaceId: string;
475
+ compare: GitCompare;
476
+ path?: string;
477
+ cursor?: string;
478
+ };
479
+ result: GitDiffPage;
480
+ };
481
+ 'workspace.git.facts': {
482
+ params: {
483
+ directory: string;
484
+ };
485
+ result: GitFacts;
486
+ };
487
+ 'workspace.worktree.options': {
488
+ params: {
489
+ workspaceId: string;
490
+ };
491
+ result: {
492
+ mappingIds: string[];
493
+ };
494
+ };
495
+ 'workspace.worktree.create': {
496
+ params: RegistryMutation & {
497
+ workspaceId: string;
498
+ mappingId: string;
499
+ };
500
+ result: {
501
+ workspace: RegistryWorkspace;
502
+ revision: number;
503
+ };
504
+ };
505
+ 'workspace.worktree.remove': {
506
+ params: RegistryMutation & {
507
+ workspaceId: string;
508
+ };
509
+ result: {
510
+ workspace: RegistryWorkspace;
511
+ revision: number;
512
+ filesRemoved: true;
513
+ branchRetained: true;
514
+ };
515
+ };
516
+ 'registry.worktree': {
517
+ params: {
518
+ principalId?: string;
519
+ principalEpoch?: string;
520
+ mappingIds?: string[];
521
+ authorizedRoots?: string[];
522
+ };
523
+ result: {
524
+ mappings: Array<{
525
+ id: string;
526
+ source: string;
527
+ }>;
528
+ workspaces: unknown[];
529
+ };
530
+ };
531
+ 'project.list': {
532
+ params: {
533
+ cursor?: string;
534
+ limit?: number;
535
+ projectRoots?: string[];
536
+ };
537
+ result: RegistryPage & {
538
+ projects: RegistryProject[];
539
+ };
540
+ };
541
+ 'workspace.list': {
542
+ params: {
543
+ cursor?: string;
544
+ limit?: number;
545
+ projectRoots?: string[];
546
+ };
547
+ result: RegistryPage & {
548
+ workspaces: RegistryWorkspace[];
549
+ };
550
+ };
551
+ 'workspace.get': {
552
+ params: {
553
+ workspaceId: string;
554
+ };
555
+ result: {
556
+ workspace: RegistryWorkspace;
557
+ revision: number;
558
+ };
559
+ };
560
+ 'project.register': {
561
+ params: RegistryMutation & {
562
+ directory: string;
563
+ };
564
+ result: {
565
+ project: RegistryProject;
566
+ revision: number;
567
+ };
568
+ };
569
+ 'project.remove': {
570
+ params: RegistryMutation & {
571
+ projectId: string;
572
+ };
573
+ result: {
574
+ project: RegistryProject;
575
+ revision: number;
576
+ };
577
+ };
578
+ 'workspace.update': {
579
+ params: RegistryMutation & {
580
+ workspaceId: string;
581
+ title?: string | null;
582
+ pinned?: boolean;
583
+ archived?: boolean;
584
+ };
585
+ result: {
586
+ workspace: RegistryWorkspace;
587
+ revision: number;
588
+ };
589
+ };
590
+ 'registry.owner': {
591
+ params: {
592
+ operation?: string;
593
+ args?: Record<string, unknown>;
594
+ requestId?: string;
595
+ ifRevision?: number;
596
+ };
597
+ result: {
598
+ registry: Record<string, unknown>;
599
+ };
600
+ };
601
+ 'daemon.hello': {
602
+ params: {
603
+ protocolVersion: 1;
604
+ client?: {
605
+ name: string;
606
+ version: string;
607
+ };
608
+ capabilities?: string[];
609
+ };
610
+ result: {
611
+ protocolVersion: 1;
612
+ daemonVersion?: string;
613
+ pid?: number; /** The daemon host's machine name (os.hostname()), a label for clients. */
614
+ hostname?: string;
615
+ promptImageLimits?: {
616
+ maxCount: number;
617
+ maxBytes: number;
618
+ maxTotalBytes: number;
619
+ };
620
+ attachmentLimits?: AttachmentLimits;
621
+ terminalLimits?: TerminalLimits;
622
+ capabilities?: string[];
623
+ };
624
+ };
625
+ 'daemon.status': {
626
+ params: Empty;
627
+ result: {
628
+ pid: number;
629
+ startedAt: string;
630
+ version: string;
631
+ protocolVersion: number;
632
+ sessions: number;
633
+ questions: number;
634
+ previousExit?: {
635
+ kind: 'clean' | 'crash';
636
+ at?: string;
637
+ };
638
+ persistence?: Record<string, unknown>;
639
+ health: {
640
+ live: boolean;
641
+ ready: boolean;
642
+ checks: Array<{
643
+ id: string;
644
+ ok: boolean;
645
+ code?: string;
646
+ message?: string;
647
+ }>;
648
+ };
649
+ };
650
+ };
651
+ 'daemon.shutdown': {
652
+ params: Empty;
653
+ result: Empty;
654
+ };
655
+ 'daemon.pause': {
656
+ params: {
657
+ runtime?: RuntimeKind;
658
+ now?: boolean;
659
+ reason?: string;
660
+ };
661
+ result: PauseState;
662
+ };
663
+ 'daemon.resume': {
664
+ params: {
665
+ runtime?: RuntimeKind;
666
+ };
667
+ result: PauseState;
668
+ };
669
+ 'daemon.pauses': {
670
+ params: Empty;
671
+ result: PauseState;
672
+ };
673
+ 'daemon.usage': {
674
+ params: {
675
+ refresh?: boolean;
676
+ };
677
+ result: {
678
+ providers: Array<Record<string, unknown>>;
679
+ };
680
+ };
681
+ 'catalog.get': {
682
+ params: Empty;
683
+ result: {
684
+ models: Array<Record<string, unknown>>;
685
+ modes: Array<Record<string, unknown>>;
686
+ thinkingOptions?: unknown;
687
+ defaultModel: string;
688
+ fetchedAt?: string;
689
+ providers?: Record<string, {
690
+ status: string;
691
+ fetchedAt?: string;
692
+ error?: string;
693
+ }>;
694
+ };
695
+ };
696
+ 'catalog.refresh': {
697
+ params: Empty;
698
+ result: {
699
+ models: Array<Record<string, unknown>>;
700
+ modes: Array<Record<string, unknown>>;
701
+ thinkingOptions?: unknown;
702
+ defaultModel: string;
703
+ fetchedAt?: string;
704
+ providers?: Record<string, {
705
+ status: string;
706
+ fetchedAt?: string;
707
+ error?: string;
708
+ }>;
709
+ };
710
+ };
711
+ 'assignment.recall': {
712
+ params: {
713
+ assignmentId?: string;
714
+ taskId?: string;
715
+ projectRoot?: string;
716
+ question: string;
717
+ };
718
+ result: RecallAnswer;
719
+ };
720
+ 'board.list': {
721
+ params: {
722
+ projectRoot: string;
723
+ };
724
+ result: {
725
+ pins: Pin[];
726
+ };
727
+ };
728
+ 'question.list': {
729
+ params: {
730
+ projectRoot?: string;
731
+ };
732
+ result: {
733
+ questions: UserQuestion[];
734
+ };
735
+ };
736
+ /** 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. */
737
+ 'question.watch': {
738
+ params: {
739
+ projectRoot?: string;
740
+ turns?: boolean;
741
+ attention?: boolean;
742
+ };
743
+ result: {
744
+ questions: UserQuestion[];
745
+ attention?: Array<{
746
+ sessionId: string;
747
+ attention: TurnAttention;
748
+ }>;
749
+ };
750
+ };
751
+ /** Capability `session.attention`: acknowledges a root's attention for every client; with `at`, only that one (a later turn's stays). */
752
+ 'session.attention.clear': {
753
+ params: {
754
+ sessionId: string;
755
+ at?: string;
756
+ };
757
+ result: {
758
+ cleared: boolean;
759
+ };
760
+ };
761
+ /** Capability `workspace.files`: files under `projectRoot` whose relative path matches `query`, best first; read-only, links not followed. */
762
+ 'workspace.files.search': {
763
+ params: {
764
+ projectRoot: string;
765
+ query?: string;
766
+ limit?: number;
767
+ };
768
+ result: {
769
+ files: Array<{
770
+ path: string;
771
+ }>;
772
+ truncated?: boolean;
773
+ };
774
+ };
775
+ /** 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`). */
776
+ 'workspace.files.list': {
777
+ params: {
778
+ projectRoot: string;
779
+ path?: string;
780
+ includeIgnored?: boolean;
781
+ cursor?: string;
782
+ internalLinks?: boolean;
783
+ };
784
+ result: {
785
+ entries: Array<{
786
+ name: string;
787
+ path: string;
788
+ kind: 'file' | 'directory';
789
+ size?: number;
790
+ modifiedAt?: string;
791
+ target?: string;
792
+ }>;
793
+ truncated?: boolean;
794
+ nextCursor?: string;
795
+ target?: string;
796
+ };
797
+ };
798
+ /** Capability `workspace.files.read`: a UTF-8 text file under `projectRoot`, at most 1 MiB; read-only, links not followed. */
799
+ 'workspace.files.read': {
800
+ params: {
801
+ projectRoot: string;
802
+ path: string;
803
+ includeIgnored?: boolean;
804
+ };
805
+ result: {
806
+ path: string;
807
+ content: string;
808
+ size: number;
809
+ modifiedAt?: string;
810
+ };
811
+ };
812
+ /** 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. */
813
+ 'workspace.files.find': {
814
+ params: {
815
+ projectRoot: string;
816
+ query?: string;
817
+ kinds?: Array<'file' | 'directory'>;
818
+ matchMode?: 'subsequence' | 'suffix';
819
+ limit?: number;
820
+ cursor?: string;
821
+ };
822
+ result: {
823
+ entries: Array<{
824
+ path: string;
825
+ kind: 'file' | 'directory';
826
+ }>;
827
+ nextCursor?: string;
828
+ truncated?: boolean;
829
+ };
830
+ };
831
+ /** 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`. */
832
+ 'workspace.files.preview': {
833
+ params: {
834
+ projectRoot: string;
835
+ path: string;
836
+ includeIgnored?: boolean;
837
+ internalLinks?: boolean;
838
+ maxBytes?: number;
839
+ offset?: number;
840
+ revision?: string;
841
+ };
842
+ result: {
843
+ path: string;
844
+ target?: string;
845
+ kind: 'text' | 'image' | 'binary';
846
+ mimeType: string;
847
+ size: number;
848
+ modifiedAt: string;
849
+ revision: string;
850
+ encoding: 'base64' | 'none';
851
+ content?: string;
852
+ offset?: number;
853
+ nextOffset?: number;
854
+ };
855
+ };
856
+ /** Capability `host.directories`: directories of the daemon host whose path completes `query` (absolute or under ~), or whose name matches it under the home directory. */
857
+ 'host.directories.search': {
858
+ params: {
859
+ query: string;
860
+ limit?: number;
861
+ };
862
+ result: {
863
+ entries: Array<{
864
+ path: string;
865
+ }>;
866
+ truncated?: boolean;
867
+ };
868
+ };
869
+ 'question.answer': {
870
+ params: {
871
+ questionId: string;
872
+ text?: string;
873
+ dismiss?: boolean;
874
+ reason?: string;
875
+ };
876
+ result: {
877
+ questionId: string;
878
+ };
879
+ };
880
+ 'session.create': {
881
+ params: {
882
+ sessionId?: string;
883
+ history?: 'skip' | 'replay';
884
+ delegation?: boolean;
885
+ resume?: boolean;
886
+ } & ({
887
+ workspaceId: string;
888
+ spec: Omit<SessionSpec, 'cwd'> & {
889
+ cwd?: string;
890
+ };
891
+ } | {
892
+ workspaceId?: undefined;
893
+ spec: SessionSpec;
894
+ });
895
+ result: {
896
+ session: SessionSnapshot;
897
+ attached: boolean;
898
+ resumed?: true;
899
+ durable?: boolean;
900
+ };
901
+ };
902
+ 'session.preview': {
903
+ params: {
904
+ spec: SessionSpec;
905
+ };
906
+ result: {
907
+ preview: SessionPreview;
908
+ };
909
+ };
910
+ 'session.history': {
911
+ params: {
912
+ sessionId: string;
913
+ before?: string;
914
+ limit?: number;
915
+ maxBytes?: number;
916
+ };
917
+ result: HistoryPage;
918
+ };
919
+ 'session.attach': {
920
+ params: {
921
+ sessionId: string;
922
+ replay?: boolean;
923
+ after?: number;
924
+ generation?: string;
925
+ };
926
+ result: {
927
+ session: SessionSummary;
928
+ cursor: number;
929
+ reset?: true;
930
+ };
931
+ };
932
+ 'session.release': {
933
+ params: {
934
+ sessionId: string;
935
+ };
936
+ result: {
937
+ closed: boolean;
938
+ };
939
+ };
940
+ 'session.prompt': {
941
+ params: PrincipalContext & {
942
+ sessionId: string;
943
+ clientMessageId: string;
944
+ delivery?: 'auto' | 'steer';
945
+ content: PromptContent;
946
+ };
947
+ /** `{}` from a daemon without prompt.receipts. */
948
+ result: {
949
+ outcome?: 'accepted' | 'failed';
950
+ error?: AlpError;
951
+ duplicate?: boolean;
952
+ durable?: boolean;
953
+ };
954
+ };
955
+ 'session.interrupt': {
956
+ params: {
957
+ sessionId: string; /** With session.interrupt.turn, cancel only this turn. */
958
+ turnId?: string;
959
+ };
960
+ result: {
961
+ interrupted?: boolean;
962
+ };
963
+ };
964
+ /**
965
+ * Changes a session's permissions mode while idle; with capability `session.configure.live`, also a live
966
+ * root's model, effort or team (§12.9): those need requestId and ifGeneration, apply at the idle barrier
967
+ * through a restart of its native process on the same conversation, and answer `configured`. Answered
968
+ * once per (sessionId, requestId): a repeat answers the first result with `duplicate: true`.
969
+ */
970
+ 'session.configure': {
971
+ params: {
972
+ sessionId: string;
973
+ mode?: string;
974
+ model?: string;
975
+ thinking?: string;
976
+ team?: string;
977
+ requestId?: string;
978
+ ifGeneration?: string;
979
+ };
980
+ result: {
981
+ session: SessionSnapshot | SessionSummary;
982
+ configured?: ConfigureOutcome;
983
+ duplicate?: true;
984
+ };
985
+ };
986
+ /** What session.configure would run a live root with, and whether it would take it now (capability `session.configure.live`, §12.9). */
987
+ 'session.configure.preview': {
988
+ params: {
989
+ sessionId: string;
990
+ mode?: string;
991
+ model?: string;
992
+ thinking?: string;
993
+ team?: string;
994
+ };
995
+ result: {
996
+ preview: ConfigurePreview;
997
+ };
998
+ };
999
+ 'session.close': {
1000
+ params: {
1001
+ sessionId: string;
1002
+ };
1003
+ result: Empty;
1004
+ };
1005
+ 'session.rename': {
1006
+ params: {
1007
+ sessionId: string;
1008
+ title: string;
1009
+ };
1010
+ result: {
1011
+ session: SessionSummary;
1012
+ };
1013
+ };
1014
+ /**
1015
+ * A new root whose conversation is the source's up to a completed turn (capability `session.fork`, §12.7).
1016
+ * Answered once per (sessionId, requestId): a repeat answers the first result with `duplicate: true`.
1017
+ */
1018
+ 'session.fork': {
1019
+ params: PrincipalContext & {
1020
+ sessionId: string;
1021
+ requestId: string;
1022
+ ifGeneration: string;
1023
+ boundary?: ForkBoundary;
1024
+ branchId?: string;
1025
+ workspaceId?: string;
1026
+ newSessionId?: string;
1027
+ title?: string;
1028
+ };
1029
+ result: {
1030
+ session: SessionSummary;
1031
+ forkedFrom: ForkProvenance;
1032
+ duplicate?: true;
1033
+ };
1034
+ };
1035
+ /**
1036
+ * The root's conversation from before a turn on, under the same session id; the later turns stay as a
1037
+ * recoverable branch and no file is changed (capability `session.rewind`, §12.7).
1038
+ */
1039
+ 'session.rewind': {
1040
+ params: {
1041
+ sessionId: string;
1042
+ requestId: string;
1043
+ ifGeneration: string;
1044
+ beforeTurnId: string;
1045
+ };
1046
+ result: {
1047
+ session: SessionSummary;
1048
+ generation: string;
1049
+ branch: ConversationBranch;
1050
+ duplicate?: true;
1051
+ };
1052
+ };
1053
+ /**
1054
+ * Restarts a live root's native process on its own conversation and configuration at the idle
1055
+ * barrier, keeping its session id, history and receipts (capability `session.reload`, §12.8).
1056
+ * Answered once per (sessionId, requestId): a repeat answers the first result with `duplicate: true`.
1057
+ */
1058
+ 'session.reload': {
1059
+ params: {
1060
+ sessionId: string;
1061
+ requestId: string;
1062
+ ifGeneration: string;
1063
+ };
1064
+ result: {
1065
+ session: SessionSummary;
1066
+ duplicate?: true;
1067
+ };
1068
+ };
1069
+ /**
1070
+ * The ALP CLI command that continues a session in a terminal, built by alpd (capability
1071
+ * `session.resumeCommand`, §12.8): argv and its POSIX and Windows command lines, for the clipboard only.
1072
+ */
1073
+ /**
1074
+ * Compacts a live root's context (t-0e56): main writes a checkpoint by skill compact, then its runtime
1075
+ * compacts, or ALP starts a fresh conversation seeded with it. Idle: now; otherwise at its next turn boundary.
1076
+ */
1077
+ 'session.compact': {
1078
+ params: {
1079
+ sessionId: string;
1080
+ };
1081
+ result: {
1082
+ status: 'started' | 'deferred' | 'running';
1083
+ };
1084
+ };
1085
+ /** The slash commands and skills a live session's composer offers after "/" (capability `session.commands`, t-f628). */
1086
+ 'session.commands': {
1087
+ params: {
1088
+ sessionId: string;
1089
+ };
1090
+ result: {
1091
+ commands: SessionCommand[];
1092
+ };
1093
+ };
1094
+ 'session.resumeCommand': {
1095
+ params: {
1096
+ sessionId: string;
1097
+ };
1098
+ result: ResumeCommand;
1099
+ };
1100
+ 'session.archive': {
1101
+ params: {
1102
+ sessionId: string;
1103
+ archived?: boolean;
1104
+ };
1105
+ result: {
1106
+ session: SessionSummary;
1107
+ };
1108
+ };
1109
+ 'session.get': {
1110
+ params: {
1111
+ sessionId: string;
1112
+ };
1113
+ result: {
1114
+ session: SessionSummary;
1115
+ };
1116
+ };
1117
+ /** `limit`, `cursor`, `query` and `projectRoots` with capability `session.list.page`: a page, and `nextCursor` while more follow. */
1118
+ 'session.list': {
1119
+ params: {
1120
+ projectRoot?: string;
1121
+ projectRoots?: string[];
1122
+ rootsOnly?: boolean;
1123
+ includeClosed?: boolean;
1124
+ includeArchived?: boolean;
1125
+ limit?: number;
1126
+ cursor?: string;
1127
+ query?: string;
1128
+ };
1129
+ result: {
1130
+ sessions: SessionSummary[];
1131
+ nextCursor?: string;
1132
+ };
1133
+ };
1134
+ 'session.status': {
1135
+ params: {
1136
+ sessionId: string;
1137
+ };
1138
+ result: {
1139
+ status: TreeStatus;
1140
+ };
1141
+ };
1142
+ 'session.message': {
1143
+ params: {
1144
+ sessionId: string;
1145
+ text: string;
1146
+ };
1147
+ result: Empty;
1148
+ };
1149
+ 'session.log': {
1150
+ params: {
1151
+ sessionId: string;
1152
+ };
1153
+ result: {
1154
+ rootId: string;
1155
+ entries: Array<Record<string, unknown>>;
1156
+ };
1157
+ };
1158
+ 'extension.register': {
1159
+ params: {
1160
+ method: string;
1161
+ };
1162
+ result: {
1163
+ registered: string;
1164
+ };
1165
+ };
1166
+ 'extension.unregister': {
1167
+ params: {
1168
+ method: string;
1169
+ };
1170
+ result: {
1171
+ unregistered: string;
1172
+ };
1173
+ };
1174
+ 'team.list': {
1175
+ params: {
1176
+ projectRoot?: string;
1177
+ };
1178
+ result: {
1179
+ projectRoot: string | null;
1180
+ teams: TeamRow[];
1181
+ };
1182
+ };
1183
+ 'task.list': {
1184
+ params: {
1185
+ projectRoot: string;
1186
+ };
1187
+ result: {
1188
+ projectRoot: string;
1189
+ tasks: TaskRow[];
1190
+ unreadable: Array<{
1191
+ file: string;
1192
+ error: string;
1193
+ }>;
1194
+ revision: string;
1195
+ };
1196
+ };
1197
+ 'task.create': {
1198
+ params: {
1199
+ projectRoot: string;
1200
+ title: string;
1201
+ priority?: number;
1202
+ requestId?: string;
1203
+ };
1204
+ result: {
1205
+ id: string;
1206
+ duplicate?: true;
1207
+ };
1208
+ };
1209
+ 'task.update': {
1210
+ params: {
1211
+ projectRoot: string;
1212
+ id: string;
1213
+ action: 'close' | 'reopen';
1214
+ note?: string;
1215
+ ifRev?: number;
1216
+ };
1217
+ result: {
1218
+ id: string;
1219
+ status: string;
1220
+ rev: number;
1221
+ landed?: string;
1222
+ };
1223
+ };
1224
+ 'task.gate.resolve': {
1225
+ params: {
1226
+ projectRoot: string;
1227
+ id: string;
1228
+ gate: string;
1229
+ note?: string;
1230
+ ifRev?: number; /** One of a human gate's options; picking one approves it. */
1231
+ choice?: string; /** Record the user's rejection instead (note is the reason); the gate stays open. */
1232
+ reject?: boolean; /** Where the user decided, recorded on the gate. Default web. */
1233
+ channel?: 'paseo' | 'web';
1234
+ };
1235
+ result: {
1236
+ id: string;
1237
+ status: string;
1238
+ rev: number;
1239
+ };
1240
+ };
1241
+ 'library.list': {
1242
+ params: {
1243
+ kind: LibraryKind;
1244
+ projectRoot?: string;
1245
+ };
1246
+ result: {
1247
+ projectRoot: string | null;
1248
+ entries: LibraryEntryRow[];
1249
+ };
1250
+ };
1251
+ 'library.get': {
1252
+ params: {
1253
+ kind: LibraryKind;
1254
+ name: EntryName;
1255
+ projectRoot?: string;
1256
+ scope?: LibraryScope;
1257
+ };
1258
+ /** `content` carries `{ $secret: 'keep' }` in place of each secret value; `secrets` lists their JSON Pointers. */
1259
+ result: {
1260
+ kind: LibraryKind;
1261
+ name: string;
1262
+ source: LibrarySource;
1263
+ overrides?: LibrarySource;
1264
+ content: Record<string, unknown>;
1265
+ revision: string | null;
1266
+ usedBy: string[];
1267
+ librarySkills?: string[];
1268
+ secrets?: string[];
1269
+ };
1270
+ };
1271
+ 'library.save': {
1272
+ params: {
1273
+ kind: LibraryKind;
1274
+ name: EntryName;
1275
+ scope: LibraryScope;
1276
+ projectRoot?: string;
1277
+ policy?: 'project-data';
1278
+ content: Record<string, unknown>;
1279
+ revision?: string | null;
1280
+ sync?: 'none' | 'known-projects';
1281
+ };
1282
+ result: {
1283
+ revision: string | null;
1284
+ syncedProjects?: number;
1285
+ syncErrors?: string[];
1286
+ };
1287
+ };
1288
+ 'library.delete': {
1289
+ params: {
1290
+ kind: LibraryKind;
1291
+ name: EntryName;
1292
+ scope: LibraryScope;
1293
+ projectRoot?: string;
1294
+ policy?: 'project-data';
1295
+ revision?: string;
1296
+ };
1297
+ result: {
1298
+ removed: true;
1299
+ now?: 'builtin' | 'library';
1300
+ };
1301
+ };
1302
+ 'library.duplicate': {
1303
+ params: {
1304
+ kind: LibraryKind;
1305
+ from: EntryName;
1306
+ to: EntryName;
1307
+ scope: LibraryScope;
1308
+ projectRoot?: string;
1309
+ policy?: 'project-data';
1310
+ };
1311
+ result: {
1312
+ revision: string | null;
1313
+ };
1314
+ };
1315
+ 'library.rename': {
1316
+ params: {
1317
+ kind: LibraryKind;
1318
+ from: EntryName;
1319
+ to: EntryName;
1320
+ scope: LibraryScope;
1321
+ projectRoot?: string;
1322
+ policy?: 'project-data';
1323
+ };
1324
+ result: {
1325
+ revision: string | null;
1326
+ };
1327
+ };
1328
+ 'library.skills.set': {
1329
+ params: {
1330
+ agent: EntryName;
1331
+ skills: EntryName[];
1332
+ };
1333
+ result: {
1334
+ skills: string[];
1335
+ };
1336
+ };
1337
+ 'library.models': {
1338
+ params: Empty;
1339
+ result: {
1340
+ models: Array<{
1341
+ id: string;
1342
+ label: string;
1343
+ efforts: string[];
1344
+ effort?: string;
1345
+ }>;
1346
+ };
1347
+ };
1348
+ 'settings.language.get': {
1349
+ params: Empty;
1350
+ result: LanguageSetting;
1351
+ };
1352
+ 'settings.language.set': {
1353
+ params: {
1354
+ language: string | null;
1355
+ };
1356
+ result: LanguageSetting;
1357
+ };
1358
+ /** Capability `schedule`: a one-shot continuation of a root session, due at `dueAt` (UTC, ISO 8601). */
1359
+ 'schedule.create': {
1360
+ params: {
1361
+ projectRoot: string;
1362
+ sessionId: string;
1363
+ dueAt: string;
1364
+ prompt: string;
1365
+ keepsSession?: boolean;
1366
+ };
1367
+ result: {
1368
+ job: ScheduleJob;
1369
+ };
1370
+ };
1371
+ 'schedule.list': {
1372
+ params: {
1373
+ projectRoot: string;
1374
+ status?: ScheduleStatus;
1375
+ };
1376
+ result: {
1377
+ jobs: ScheduleJob[];
1378
+ };
1379
+ };
1380
+ 'schedule.get': {
1381
+ params: {
1382
+ id: string;
1383
+ projectRoot: string;
1384
+ };
1385
+ result: {
1386
+ job: ScheduleJob;
1387
+ };
1388
+ };
1389
+ 'schedule.cancel': {
1390
+ params: {
1391
+ id: string;
1392
+ projectRoot: string;
1393
+ };
1394
+ result: {
1395
+ job: ScheduleJob;
1396
+ };
1397
+ };
1398
+ };
1399
+ export type RpcMethod = keyof RpcMethodMap;
1400
+ export type RpcParams<M extends RpcMethod> = RpcMethodMap[M]['params'];
1401
+ export type RpcResult<M extends RpcMethod> = RpcMethodMap[M]['result'];
1402
+ export {};