@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.
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +16 -2
- package/conformance/cases.json +951 -0
- package/conformance/run.d.mts +32 -0
- package/conformance/run.mjs +403 -0
- package/dist/connection.d.ts +22 -0
- package/dist/connection.js +0 -0
- package/dist/contract-v1.d.ts +9563 -0
- package/dist/contract-v1.js +5 -0
- package/dist/contract.d.ts +25 -0
- package/dist/contract.js +28 -0
- package/dist/dto.d.ts +109 -0
- package/dist/dto.js +0 -0
- package/dist/events.d.ts +360 -0
- package/dist/events.js +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2 -0
- package/dist/public.d.ts +1 -0
- package/dist/public.js +2 -0
- package/dist/rpc.d.ts +1402 -0
- package/dist/rpc.js +0 -0
- package/dist/schedule.d.ts +48 -0
- package/dist/schedule.js +0 -0
- package/dist/session.d.ts +286 -0
- package/dist/session.js +0 -0
- package/dist/validate.d.ts +12 -0
- package/dist/validate.js +151 -0
- package/dist/wire.d.ts +210 -0
- package/dist/wire.js +139 -0
- package/fixtures/ipc-v1.jsonl +4 -0
- package/fixtures/v1/cases.json +8131 -0
- package/package.json +127 -4
- package/schema/ipc-v1.json +3366 -0
- package/schema/methods-v1.json +9620 -0
- package/src/connection.ts +19 -0
- package/src/contract-v1.js +2 -0
- package/src/contract.js +44 -0
- package/src/dto.ts +78 -0
- package/src/events.ts +209 -0
- package/src/index.ts +7 -0
- package/src/public.js +2 -0
- package/src/rpc.ts +318 -0
- package/src/schedule.ts +48 -0
- package/src/session.ts +213 -0
- package/src/validate.js +115 -0
- package/src/wire.js +221 -0
package/src/dto.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export type RuntimeKind = 'codex' | 'claude' | 'acp' | 'antigravity';
|
|
2
|
+
|
|
3
|
+
export type MailKind = 'question' | 'answer' | 'note' | 'steer' | 'result' | 'stalled' | 'board' | 'checkin';
|
|
4
|
+
|
|
5
|
+
export type MailEvent = {
|
|
6
|
+
id: string;
|
|
7
|
+
kind: MailKind;
|
|
8
|
+
from: string;
|
|
9
|
+
assignment: string;
|
|
10
|
+
body?: string;
|
|
11
|
+
replyTo?: string;
|
|
12
|
+
result?: Record<string, unknown>;
|
|
13
|
+
redelivered?: boolean;
|
|
14
|
+
/** Informational; never steers or wakes a session by itself. */
|
|
15
|
+
passive?: boolean;
|
|
16
|
+
/** Delivered between turns, never steered into a running one or taken by alp_wait. */
|
|
17
|
+
defer?: boolean;
|
|
18
|
+
/** Turn that received the event; acknowledged when that turn completes. */
|
|
19
|
+
deliveredTurn?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export type PinKind = 'claim' | 'decision' | 'finding';
|
|
24
|
+
|
|
25
|
+
export type Pin = {
|
|
26
|
+
id: string;
|
|
27
|
+
/** The project root the board belongs to. */
|
|
28
|
+
project: string;
|
|
29
|
+
kind: PinKind;
|
|
30
|
+
body: string;
|
|
31
|
+
/** Project-relative files or directories, or absolute paths in an external write root; required for claims. */
|
|
32
|
+
paths?: string[];
|
|
33
|
+
agent: string;
|
|
34
|
+
sessionId: string;
|
|
35
|
+
rootId: string;
|
|
36
|
+
at: string;
|
|
37
|
+
/** When a claim ended, or any pin was taken down. */
|
|
38
|
+
released?: string;
|
|
39
|
+
/** The task the claiming assignment works on. */
|
|
40
|
+
task?: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** A project's task as task screens show it (schema/methods-v1.json `taskRow`). */
|
|
44
|
+
export type TaskRow = {
|
|
45
|
+
id: string;
|
|
46
|
+
title: string;
|
|
47
|
+
type: string;
|
|
48
|
+
priority: number;
|
|
49
|
+
status: 'open' | 'in_progress' | 'review' | 'closed';
|
|
50
|
+
/** Changes with every write; task.update and task.gate.resolve refuse an older one given as `ifRev`. */
|
|
51
|
+
rev: number;
|
|
52
|
+
parent?: string;
|
|
53
|
+
assignee?: string;
|
|
54
|
+
ready: boolean;
|
|
55
|
+
blockedBy?: string[];
|
|
56
|
+
waits?: string[];
|
|
57
|
+
approvals?: Array<{ gate: string; note: string; /** Answers to pick from; any approves. */ options?: string[]; /** The user's latest rejection; the gate stays open. */ rejected?: { at: string; reason?: string } }>;
|
|
58
|
+
handoff?: { outcome: string; summary: string; agent?: string };
|
|
59
|
+
closed?: { reason: string; summary?: string; at: string };
|
|
60
|
+
description?: string;
|
|
61
|
+
labels?: string[];
|
|
62
|
+
paths?: string[];
|
|
63
|
+
progress?: { done: number; total: number };
|
|
64
|
+
createdAt?: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type LibraryKind = 'agents' | 'skills' | 'mcp' | 'hooks' | 'teams' | 'providers';
|
|
69
|
+
export type LibraryScope = 'library' | 'project';
|
|
70
|
+
export type LibrarySource = 'builtin' | 'library' | 'project';
|
|
71
|
+
/** Letters, digits, '.', '_' or '-', not '.' or '..'. */
|
|
72
|
+
export type EntryName = string;
|
|
73
|
+
export type LibraryEntryRow = { name: string; source: LibrarySource; overrides?: LibrarySource; description?: string; usedBy?: string[] };
|
|
74
|
+
export type TeamRow = { id: string; label?: string; description?: string; source: LibrarySource; overrides?: LibrarySource; error?: string };
|
|
75
|
+
/** language null: unset, so `default` applies. */
|
|
76
|
+
export type LanguageSetting = { language: string | null; applies: string; default: string };
|
|
77
|
+
/** Stands for a stored secret in library.get content; sent back in library.save it keeps the stored value. */
|
|
78
|
+
export type SecretMarker = { $secret: 'keep' };
|
package/src/events.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { RuntimeKind, MailEvent, Pin } from './dto.js';
|
|
2
|
+
|
|
3
|
+
/** Provider-neutral session events (plans/reference/ALPD.md §4). Viewers project them; the runtime never imports a viewer. */
|
|
4
|
+
|
|
5
|
+
/** `code: 'outcome_unknown'` when the provider may or may not have received the request (ALPD §66). */
|
|
6
|
+
export type AlpError = { message: string; code?: string };
|
|
7
|
+
|
|
8
|
+
export type TimelineItem =
|
|
9
|
+
| {
|
|
10
|
+
kind: 'user_message'; id: string; text: string; clientMessageId?: string; /** How many images the message carried; their data is not replayed. */ images?: number;
|
|
11
|
+
/** Files attached to the message (capability `attachments`, §12.6): ids, display names, types and sizes, never a host path. */
|
|
12
|
+
attachments?: Array<{ attachmentId: string; name: string; mimeType: string; size: number }>;
|
|
13
|
+
/** Who wrote it: the user, or ALP itself (mail, a brief, a resume); absent when the runtime cannot tell. Only the user's words name a root (ALPD §15). */
|
|
14
|
+
origin?: TurnOrigin;
|
|
15
|
+
}
|
|
16
|
+
| { kind: 'assistant_message'; id: string; text: string }
|
|
17
|
+
/** Something about ALP as a whole the user should see, such as a usage limit or a pause (ALPD §29). */
|
|
18
|
+
| { kind: 'notice'; id: string; level: 'info' | 'warning' | 'error'; text: string }
|
|
19
|
+
/** The runtime compacting the session's context (ALPD §57). */
|
|
20
|
+
| { kind: 'compaction'; id: string; status: 'running' | 'completed' | 'failed'; trigger?: 'auto' | 'manual'; preTokens?: number; postTokens?: number }
|
|
21
|
+
/** The tasks a root's tree created or worked on (plans/reference/ALPD.md §21). */
|
|
22
|
+
| { kind: 'todo'; id: string; items: Array<{ id: string; text: string; status: 'pending' | 'in_progress' | 'completed' }> }
|
|
23
|
+
| {
|
|
24
|
+
kind: 'tool_call';
|
|
25
|
+
id: string;
|
|
26
|
+
callId: string;
|
|
27
|
+
name: string;
|
|
28
|
+
status: 'running' | 'completed' | 'failed';
|
|
29
|
+
error?: string;
|
|
30
|
+
detail: ToolCallDetail;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* What a tool call did, typed by kind (ALPD §4.2), in the shapes of Paseo's ToolCallDetail.
|
|
35
|
+
* `shell` is a command; `unknown` the fallback with the tool's raw input and output. The typed
|
|
36
|
+
* kinds between come from the runtime's own tools; filePath is the path the runtime reported.
|
|
37
|
+
* The runtime clips each string field of a typed detail (not shell, not unknown) to 65,536
|
|
38
|
+
* characters, filePaths to 200 entries and webResults to 50. A receiver shows a detail whose
|
|
39
|
+
* type it does not know as unknown: new types may be added within v1.
|
|
40
|
+
*/
|
|
41
|
+
export type ToolCallDetail =
|
|
42
|
+
| { type: 'shell'; command: string; cwd?: string; output: string; exitCode?: number | null }
|
|
43
|
+
| { type: 'read'; filePath: string; content?: string; offset?: number; limit?: number }
|
|
44
|
+
| { type: 'edit'; filePath: string; oldString?: string; newString?: string; unifiedDiff?: string }
|
|
45
|
+
| { type: 'write'; filePath: string; content?: string }
|
|
46
|
+
| {
|
|
47
|
+
type: 'search';
|
|
48
|
+
query: string;
|
|
49
|
+
toolName?: 'search' | 'grep' | 'glob' | 'web_search';
|
|
50
|
+
content?: string;
|
|
51
|
+
filePaths?: string[];
|
|
52
|
+
webResults?: Array<{ title: string; url: string }>;
|
|
53
|
+
numFiles?: number;
|
|
54
|
+
numMatches?: number;
|
|
55
|
+
truncated?: boolean;
|
|
56
|
+
}
|
|
57
|
+
| { type: 'fetch'; url: string; prompt?: string; result?: string; code?: number }
|
|
58
|
+
| { type: 'sub_agent'; subAgentType?: string; description?: string; log?: string }
|
|
59
|
+
| { type: 'plan'; text: string }
|
|
60
|
+
| { type: 'plain_text'; label?: string; text?: string }
|
|
61
|
+
| { type: 'unknown'; input: unknown; output: unknown };
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* How much a session has used, from its runtime's latest token report (ALPD §57), as Paseo's
|
|
65
|
+
* AgentUsage: the context window's fill, the latest model response's tokens, and the session's
|
|
66
|
+
* cost when the runtime says it. A field the runtime does not report is absent; a later report
|
|
67
|
+
* replaces the fields it carries and keeps the others.
|
|
68
|
+
*/
|
|
69
|
+
export type SessionUsage = {
|
|
70
|
+
/** Tokens the context holds now: the latest model call's input and output. */
|
|
71
|
+
contextWindowUsedTokens?: number;
|
|
72
|
+
/** The context window, once the runtime has said what it is. */
|
|
73
|
+
contextWindowMaxTokens?: number;
|
|
74
|
+
/** The latest model response's input tokens, of which cachedInputTokens came from cache, and output tokens. */
|
|
75
|
+
inputTokens?: number;
|
|
76
|
+
cachedInputTokens?: number;
|
|
77
|
+
outputTokens?: number;
|
|
78
|
+
/** The session's cost in US dollars so far, as the runtime counts it (Claude, or ACP in USD). */
|
|
79
|
+
totalCostUsd?: number;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type SessionSnapshot = {
|
|
83
|
+
id: string;
|
|
84
|
+
projectRoot: string;
|
|
85
|
+
agent: string;
|
|
86
|
+
runtime: RuntimeKind;
|
|
87
|
+
model: string;
|
|
88
|
+
mode: string;
|
|
89
|
+
thinking: string;
|
|
90
|
+
workflow: { mode: string; maxPeers: number; supervisor: boolean };
|
|
91
|
+
/** The label of the session's team, such as Phở (ALPD §42); absent for a custom graph. */
|
|
92
|
+
teamLabel?: string;
|
|
93
|
+
threadId: string;
|
|
94
|
+
/** The native thread is kept and the session can be resumed. */
|
|
95
|
+
persistent: boolean;
|
|
96
|
+
parentId?: string;
|
|
97
|
+
/** The requester's tool call that started this assignment. */
|
|
98
|
+
toolCallId?: string;
|
|
99
|
+
activeTurnId?: string;
|
|
100
|
+
/** A turn, an assignment, a child, or undelivered mail keeps the session working. */
|
|
101
|
+
busy: boolean;
|
|
102
|
+
/** Why a usage limit or a pause parked this assignment (ALPD §29). */
|
|
103
|
+
parked?: string;
|
|
104
|
+
/** A digest of the instructions the session runs with (ALPD §34). */
|
|
105
|
+
instructionsSha?: string;
|
|
106
|
+
/** The session's runtime takes images in session.prompt (capability `prompt.images`); absent means it does not. */
|
|
107
|
+
promptImages?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* How the session's runtime can use files attached in session.prompt (§12.6): `file.path` (its tools
|
|
110
|
+
* read a staged read-only copy), `document.native`, `text.extract`. Absent: it takes no attachment parts.
|
|
111
|
+
*/
|
|
112
|
+
promptAttachments?: Array<'file.path' | 'document.native' | 'text.extract'>;
|
|
113
|
+
/** The latest usage the session's runtime reported (ALPD §57); absent before its first report. */
|
|
114
|
+
usage?: SessionUsage;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type AssignmentSnapshot = {
|
|
118
|
+
id: string;
|
|
119
|
+
agent: string;
|
|
120
|
+
mode: string;
|
|
121
|
+
status: string;
|
|
122
|
+
startedAt: string;
|
|
123
|
+
/** An isolated assignment's branch and working directory. */
|
|
124
|
+
worktree?: { branch: string; path: string };
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** runtime: a turn the native runtime started by itself, such as Claude after a background task ended. */
|
|
128
|
+
export type TurnOrigin = 'user' | 'wake' | 'assignment' | 'runtime';
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A root's turn that ended while nobody looked (Paseo's attention): `finished` for a completed turn,
|
|
132
|
+
* `error` for a failed one. alpd keeps it for every client until one acknowledges it or the root
|
|
133
|
+
* starts another turn (docs/protocol/alp-json-rpc-v1.md §12.2).
|
|
134
|
+
*/
|
|
135
|
+
export type TurnAttention = { reason: 'finished' | 'error'; at: string; turnId?: string; message?: string };
|
|
136
|
+
|
|
137
|
+
/** A question an agent asked the user with alp_ask to: "user". */
|
|
138
|
+
export type UserQuestion = {
|
|
139
|
+
id: string;
|
|
140
|
+
sessionId: string;
|
|
141
|
+
rootId: string;
|
|
142
|
+
agent: string;
|
|
143
|
+
body: string;
|
|
144
|
+
options?: string[];
|
|
145
|
+
askedAt: string;
|
|
146
|
+
/** A card that mirrors an open human gate of the project's tasks: choosing an option approves it, dismissing rejects it. It has no timeout. */
|
|
147
|
+
gate?: { projectRoot: string; taskId: string; gateId: string };
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type SessionState = 'running' | 'waiting' | 'waiting_parent' | 'waiting_user' | 'idle';
|
|
151
|
+
|
|
152
|
+
/** A live tree at one moment, for dashboards (plans/reference/ALPD.md §17). */
|
|
153
|
+
export type TreeStatus = {
|
|
154
|
+
rootId: string;
|
|
155
|
+
sessions: Array<SessionSnapshot & { state: SessionState; idleMs: number; workdir: string; unreadMail: number }>;
|
|
156
|
+
assignments: Array<AssignmentSnapshot & { requester: string; isolation: 'shared' | 'worktree'; idleMs: number }>;
|
|
157
|
+
questions: UserQuestion[];
|
|
158
|
+
/** Finished worktree assignments waiting for alp_merge or alp_discard. */
|
|
159
|
+
worktrees: Array<{ assignmentId: string; requester: string; agent: string; branch: string; files: string[]; stat: string }>;
|
|
160
|
+
leases: Array<{ checkout: string; assignmentId: string; agent: string }>;
|
|
161
|
+
/** Live claims on the project board held by this tree's sessions. */
|
|
162
|
+
claims: Pin[];
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type AlpEvent =
|
|
166
|
+
| { type: 'session.opened'; session: SessionSnapshot; cwd: string; effective: { model: string; thinking: string } }
|
|
167
|
+
| { type: 'session.ready' }
|
|
168
|
+
/** `title` comes with alpd's announcement of a root's name (its first prompt, or `session.rename`). */
|
|
169
|
+
| { type: 'session.updated'; session: SessionSnapshot & { title?: string } }
|
|
170
|
+
| { type: 'session.closed' }
|
|
171
|
+
| { type: 'session.failed'; error: AlpError }
|
|
172
|
+
| { type: 'prompt.accepted'; clientMessageId: string; result: 'turn' | 'steer'; turnId: string }
|
|
173
|
+
| { type: 'prompt.failed'; clientMessageId: string; error: AlpError }
|
|
174
|
+
| { type: 'turn.started'; turnId: string; origin: TurnOrigin }
|
|
175
|
+
| { type: 'turn.ended'; turnId: string; state: 'completed' | 'failed' | 'canceled'; error?: AlpError }
|
|
176
|
+
| { type: 'item'; item: TimelineItem }
|
|
177
|
+
/** The session's usage changed: the whole latest SessionUsage, not a delta (ALPD §57). */
|
|
178
|
+
| { type: 'usage'; usage: SessionUsage }
|
|
179
|
+
| { type: 'mail'; mail: Omit<MailEvent, 'passive' | 'deliveredTurn'> }
|
|
180
|
+
| { type: 'assignment'; assignment: AssignmentSnapshot }
|
|
181
|
+
| { type: 'question'; question: UserQuestion }
|
|
182
|
+
| { type: 'question.resolved'; questionId: string; outcome: 'answered' | 'dismissed' | 'timeout' | 'canceled'; answer?: string }
|
|
183
|
+
/** Emitted on the session that pinned it (plans/reference/ALPD.md §18). */
|
|
184
|
+
| { type: 'pin'; pin: Pin }
|
|
185
|
+
| { type: 'unpin'; pinId: string; reason: 'unpinned' | 'session_ended' }
|
|
186
|
+
/** A root's attention set, or cleared when absent: sent only to `question.watch { attention: true }` connections, never kept. */
|
|
187
|
+
| { type: 'attention'; attention?: TurnAttention }
|
|
188
|
+
/**
|
|
189
|
+
* The root's conversation was rewound (capability `session.rewind`, §12.7): history pages and cursors of
|
|
190
|
+
* the earlier generation are stale. Sent to attached connections only, never kept: drop the cached
|
|
191
|
+
* history, fetch a new tail and attach again with this generation.
|
|
192
|
+
*/
|
|
193
|
+
| { type: 'history.reset'; generation: string; reason: 'rewind'; branchId: string };
|
|
194
|
+
|
|
195
|
+
export type Envelope = {
|
|
196
|
+
sessionId: string;
|
|
197
|
+
/** Random per runtime instance; a cursor from another epoch is stale. */
|
|
198
|
+
epoch: string;
|
|
199
|
+
/** Strictly increasing per session. */
|
|
200
|
+
seq: number;
|
|
201
|
+
/**
|
|
202
|
+
* Position in its tree's stored timeline, set by alpd on the events it keeps: strictly
|
|
203
|
+
* increasing per root across restarts, so `session.attach { after }` replays only what
|
|
204
|
+
* a reconnecting client missed (ALPD §66).
|
|
205
|
+
*/
|
|
206
|
+
cursor?: number;
|
|
207
|
+
ts: string;
|
|
208
|
+
event: AlpEvent;
|
|
209
|
+
};
|
package/src/index.ts
ADDED
package/src/public.js
ADDED
package/src/rpc.ts
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
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
|
+
|
|
8
|
+
export type RpcId = string | number | null;
|
|
9
|
+
export type RpcErrorData = { code: number; message: string; data?: unknown };
|
|
10
|
+
export type RpcRequest = { jsonrpc: '2.0'; id?: RpcId; method: string; params?: Record<string, unknown> };
|
|
11
|
+
export type RpcResponse = { jsonrpc: '2.0'; id: RpcId } & ({ result: unknown; error?: never } | { error: RpcErrorData; result?: never });
|
|
12
|
+
export type EventNotification = { jsonrpc: '2.0'; method: 'event'; params: Envelope };
|
|
13
|
+
/** Why a terminal ended (§12.10). */
|
|
14
|
+
export type TerminalEndReason = 'exited' | 'closed' | 'idle' | 'lifetime' | 'detached' | 'revoked' | 'disabled' | 'shutdown';
|
|
15
|
+
/** A terminal as clients see it (capability `terminal`, §12.10): never a process id, shell path or host path. */
|
|
16
|
+
export type TerminalInfo = {
|
|
17
|
+
terminalId: string; workspaceId: string; title: string; cols: number; rows: number; state: 'running' | 'exited';
|
|
18
|
+
attached: boolean; createdAt: string; lastActivityAt: string; expiresAt: string;
|
|
19
|
+
exitCode?: number | null; signal?: number | null; endReason?: TerminalEndReason;
|
|
20
|
+
/** Absent: full native protection. root-only: best-effort Linux. none: Windows ConPTY, best-effort cleanup. */
|
|
21
|
+
protection?: 'root-only' | 'none';
|
|
22
|
+
};
|
|
23
|
+
/** Effective terminal limits a daemon.hello advertises with capability `terminal`. */
|
|
24
|
+
export type TerminalLimits = {
|
|
25
|
+
maxPerPrincipal: number; maxPerDaemon: number; maxInputBytes: number; maxOutputFrameBytes: number;
|
|
26
|
+
replayBytes: number; idleMs: number; maxLifetimeMs: number; reconnectMs: number;
|
|
27
|
+
};
|
|
28
|
+
/** params of a terminal.event notification, sent only to the connection attached to the terminal. */
|
|
29
|
+
export type TerminalEvent =
|
|
30
|
+
| { terminalId: string; type: 'output'; seq: number; data: string }
|
|
31
|
+
| { terminalId: string; type: 'exit'; seq: number; exitCode: number | null; signal: number | null; reason: TerminalEndReason }
|
|
32
|
+
| { terminalId: string; type: 'detached'; reason: 'replaced' | 'slow_consumer' };
|
|
33
|
+
export type CatalogUpdatedNotification = { jsonrpc: '2.0'; method: 'catalog.updated'; params: { fetchedAt?: string } };
|
|
34
|
+
export type TerminalChangedNotification = { jsonrpc: '2.0'; method: 'terminal.changed'; params: { watchId: string; cursor: string } };
|
|
35
|
+
export type TerminalNotification = { jsonrpc: '2.0'; method: 'terminal.event'; params: TerminalEvent };
|
|
36
|
+
|
|
37
|
+
/** Names a daemon may list in its daemon.hello result (schema/methods-v1.json `capabilities`). */
|
|
38
|
+
export type HistoryItem = Envelope | { cursor: number; oversized: { bytes: number } };
|
|
39
|
+
export type HistoryPage = { generation: string; items: HistoryItem[]; olderCursor?: string; hasOlder: boolean; tipCursor: number };
|
|
40
|
+
|
|
41
|
+
/** One entry of session.commands: inserted as `/<name>` into the composer. */
|
|
42
|
+
export type SessionCommand = { name: string; description: string; argumentHint?: string; kind: 'command' | 'skill' };
|
|
43
|
+
|
|
44
|
+
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';
|
|
45
|
+
|
|
46
|
+
/** `data.reason` values alpd sets on errors (docs/protocol/alp-json-rpc-v1.md §5.3). */
|
|
47
|
+
export type ErrorReason =
|
|
48
|
+
| 'hello_required' | 'protocol_version' | 'invalid_params' | 'invalid_id' | 'batch_unsupported' | 'frame_too_large'
|
|
49
|
+
| 'invalid_cursor' | 'stale_cursor' | 'history_gap'
|
|
50
|
+
| 'stale_revision' | 'request_conflict' | 'cwd_mismatch' | 'workspace_mismatch' | 'corrupt_registry' | 'identity_changed'
|
|
51
|
+
| 'response_too_large' | 'persistence_failed' | 'outcome_unknown' | 'key_conflict'
|
|
52
|
+
// Project, task and library methods (docs/protocol/alp-json-rpc-v1.md §5.3).
|
|
53
|
+
| 'invalid_path' | 'invalid_scope' | 'invalid_entry' | 'secret_marker' | 'not_alp_project' | 'unknown_task' | 'not_found'
|
|
54
|
+
| 'library_policy' | 'unsafe_path' | 'revision_conflict' | 'task_state' | 'in_use' | 'busy' | 'unreadable'
|
|
55
|
+
// workspace.files.search (§12.3); workspace.files.list and read (§12.4).
|
|
56
|
+
| 'not_directory' | 'blocked_path' | 'ignored' | 'linked' | 'binary' | 'too_large'
|
|
57
|
+
// workspace.files.find, workspace.files.preview and internal links (§12.11).
|
|
58
|
+
| 'outside' | 'changed'
|
|
59
|
+
// workspace.git.status and workspace.git.diff (§12.5).
|
|
60
|
+
| 'not_repository' | 'unknown_ref' | 'invalid_compare' | 'stale_snapshot' | 'git_unavailable' | 'git_failed'
|
|
61
|
+
// session.prompt: a Claude command ALP does not follow (t-e906).
|
|
62
|
+
| 'native_command_unsupported'
|
|
63
|
+
// Attachments (§12.6).
|
|
64
|
+
| 'invalid_name' | 'invalid_data' | 'attachment_too_large' | 'offset_mismatch' | 'chunk_conflict' | 'upload_incomplete'
|
|
65
|
+
| 'hash_mismatch' | 'upload_expired' | 'quota_exceeded' | 'attachment_referenced' | 'attachment_limit'
|
|
66
|
+
| 'attachment_unavailable' | 'attachment_unsupported'
|
|
67
|
+
// session.fork and session.rewind (§12.7).
|
|
68
|
+
| 'session_busy' | 'stale_generation' | 'turn_not_found' | 'turn_in_progress' | 'empty_prefix' | 'boundary_unmapped'
|
|
69
|
+
| 'runtime_unsupported' | 'native_refused' | 'branch_not_found' | 'attachment_forbidden'
|
|
70
|
+
// session.reload (§12.8).
|
|
71
|
+
| 'session_closed' | 'no_history'
|
|
72
|
+
// session.configure with model, thinking or team (§12.9).
|
|
73
|
+
| 'runtime_mismatch' | 'agent_mismatch' | 'permission_escalation' | 'team_not_found'
|
|
74
|
+
// Terminal (§12.10).
|
|
75
|
+
| 'terminal_capture_unavailable' | 'terminal_capture_too_large' | 'terminal_snapshot_too_large'
|
|
76
|
+
| 'terminal_disabled' | 'terminal_unsupported' | 'terminal_limit' | 'not_attached' | 'terminal_exited' | 'input_too_large';
|
|
77
|
+
|
|
78
|
+
type Empty = Record<string, never>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Params and result of every v1 method, as schema/methods-v1.json defines them; the protocol tests
|
|
82
|
+
* type-check the golden fixtures against this map, so the two cannot drift. Results may carry
|
|
83
|
+
* properties this map does not name: clients ignore them.
|
|
84
|
+
*/
|
|
85
|
+
export type RegistryProject = { id: string; root: string; canonical?: string; customName?: string | null; addedAt: string; removedAt?: string | null; revision?: number };
|
|
86
|
+
export type RegistryWorkspace = { branch?: string | null; managedWorktree?: boolean; id: string; projectId: string; directory: string; canonical?: string; title?: string | null; pinnedAt?: string | null; archivedAt?: string | null; labels: string[]; createdAt: string; revision?: number; idempotencyKey?: string };
|
|
87
|
+
/** workspace.git.status and workspace.git.diff (capability `workspace.git`, §12.5): paths are relative to the workspace, never host paths. */
|
|
88
|
+
export type GitChange = 'modified' | 'added' | 'deleted' | 'renamed' | 'copied' | 'typechange' | 'untracked' | 'conflicted';
|
|
89
|
+
export type GitCompare = { mode: 'uncommitted' | 'staged' | 'unstaged' | 'base'; baseRef?: string; ignoreWhitespace?: boolean };
|
|
90
|
+
export type GitStatusFile = { path: string; oldPath?: string; change: GitChange; staged: boolean; unstaged: boolean };
|
|
91
|
+
export type GitStatus = {
|
|
92
|
+
state: 'repository' | 'not_repository' | 'unsupported'; reason?: string;
|
|
93
|
+
branch: string | null; detached: boolean; head: string | null;
|
|
94
|
+
upstream: { ref: string; ahead: number; behind: number } | null;
|
|
95
|
+
baseRef: string | null; aheadBehind: { ahead: number; behind: number } | null;
|
|
96
|
+
hasRemote: boolean; remoteUrl: string | null; dirty: boolean;
|
|
97
|
+
files: GitStatusFile[]; hiddenCount: number; truncated: boolean; snapshot: string;
|
|
98
|
+
};
|
|
99
|
+
export type GitDiffLine = { type: 'add' | 'remove' | 'context'; content: string; noNewline?: true };
|
|
100
|
+
export type GitDiffHunk = { oldStart: number; oldCount: number; newStart: number; newCount: number; context?: string; lines: GitDiffLine[] };
|
|
101
|
+
export type GitDiffFile = { path: string; oldPath?: string; change: GitChange; kind: 'text' | 'binary' | 'too_large' | 'withheld' | 'symlink' | 'submodule'; additions: number; deletions: number; hunks: GitDiffHunk[] };
|
|
102
|
+
export type GitDiffPage = { compare: { mode: GitCompare['mode']; baseRef?: string; ignoreWhitespace: boolean }; snapshot: string; files: GitDiffFile[]; hiddenCount: number; truncated: boolean; nextCursor?: string };
|
|
103
|
+
/**
|
|
104
|
+
* workspace.git.facts (capability `workspace.git.facts`, §12.5): an owner-only answer for a host
|
|
105
|
+
* directory, so `repoRoot` is a host path (the directory's real path, or the enclosing repository's
|
|
106
|
+
* top level for `not_repository_root`). Never forwarded by a gateway.
|
|
107
|
+
*/
|
|
108
|
+
export type GitCheckoutFacts = { repoRoot: string; branch: string | null; detached: boolean; head: string | null; hasRemote: boolean; remoteUrl: string | null; dirty: boolean };
|
|
109
|
+
export type GitFacts =
|
|
110
|
+
| ({ kind: 'ok' | 'not_repository_root' } & GitCheckoutFacts)
|
|
111
|
+
| { kind: 'unknown' }
|
|
112
|
+
| { kind: 'unsupported'; reason: 'worktree_elsewhere' | 'inside_git_dir' };
|
|
113
|
+
/**
|
|
114
|
+
* Capability `attachments` (§12.6). Principal context is set only by a trusted gateway on its own
|
|
115
|
+
* connection; a local client leaves it out and acts as the owner.
|
|
116
|
+
*/
|
|
117
|
+
export type PrincipalContext = { principalId?: string; principalEpoch?: string; authorizedRoots?: string[] };
|
|
118
|
+
/** A committed attachment as clients see it: ids and display metadata, never a host path or URL. */
|
|
119
|
+
export type AttachmentInfo = {
|
|
120
|
+
attachmentId: string; sessionId: string; name: string; mimeType: string; detectedMimeType: string;
|
|
121
|
+
size: number; sha256: string; createdAt: string; committedAt: string; referenced: boolean;
|
|
122
|
+
};
|
|
123
|
+
/** Effective attachment limits a daemon.hello advertises with capability `attachments`. */
|
|
124
|
+
export type AttachmentLimits = {
|
|
125
|
+
maxObjectBytes: number; maxPerPrompt: number; maxPromptBytes: number; maxChunkBytes: number; maxActiveUploads: number;
|
|
126
|
+
maxPrincipalBytes: number; maxDaemonBytes: number; uploadTimeoutMs: number; unreferencedRetentionMs: number; releasedGraceMs: number;
|
|
127
|
+
};
|
|
128
|
+
/** Where a fork cuts the source conversation (§12.7): after a completed turn, or before a turn. */
|
|
129
|
+
export type ForkBoundary = { throughTurnId: string } | { beforeTurnId: string };
|
|
130
|
+
export type RegistryMutation = { requestId: string; ifRevision: number };
|
|
131
|
+
export type RegistryPage = { revision: number; total: number; nextCursor: string | null };
|
|
132
|
+
export type RpcMethodMap = {
|
|
133
|
+
'terminal.create': { params: PrincipalContext & { workspaceId: string; cols: number; rows: number; requestId: string; protectionAcknowledgment?: 'linux-root-only-v1' /* deprecated, ignored */ }; result: { terminal: TerminalInfo } };
|
|
134
|
+
'terminal.list': { params: PrincipalContext & { workspaceId?: string }; result: { terminals: TerminalInfo[] } };
|
|
135
|
+
'terminal.watch': { params: PrincipalContext & { workspaceId?: string; after?: string }; result: { terminals: TerminalInfo[]; watchId: string; cursor: string; reset: boolean } };
|
|
136
|
+
'terminal.unwatch': { params: Empty; result: { closed: true } };
|
|
137
|
+
'terminal.capture': { params: PrincipalContext & { terminalId: string; start?: number; end?: number; stripAnsi?: boolean }; result: { lines: string[]; totalLines: number } };
|
|
138
|
+
'terminal.attach': { params: PrincipalContext & { terminalId: string; after?: number; protectionAcknowledgment?: 'linux-root-only-v1' /* deprecated, ignored */ }; result: { terminal: TerminalInfo; nextSeq: number; gap?: { fromSeq: number; toSeq: number } } };
|
|
139
|
+
'terminal.input': { params: PrincipalContext & { terminalId: string; data: string }; result: { bytes: number } };
|
|
140
|
+
'terminal.resize': { params: PrincipalContext & { terminalId: string; cols: number; rows: number }; result: { cols: number; rows: number } };
|
|
141
|
+
'terminal.close': { params: PrincipalContext & { terminalId: string }; result: { closed: true } };
|
|
142
|
+
'terminal.revoke': { params: { principalId: string }; result: { closed: number } };
|
|
143
|
+
'attachment.begin': { params: PrincipalContext & { sessionId: string; name: string; size: number; mimeType: string; sha256?: string; requestId: string }; result: { uploadId: string; state: 'uploading' | 'committed'; received: number; size: number; maxChunkBytes: number; expiresAt?: string; attachmentId?: string } };
|
|
144
|
+
'attachment.chunk': { params: PrincipalContext & { uploadId: string; offset: number; data: string }; result: { received: number; size: number } };
|
|
145
|
+
'attachment.commit': { params: PrincipalContext & { uploadId: string; sha256: string }; result: { attachment: AttachmentInfo } };
|
|
146
|
+
'attachment.abort': { params: PrincipalContext & { uploadId: string }; result: { aborted: true } };
|
|
147
|
+
'attachment.get': { params: PrincipalContext & { attachmentId: string }; result: { attachment: AttachmentInfo } };
|
|
148
|
+
'attachment.delete': { params: PrincipalContext & { attachmentId: string }; result: { deleted: true } };
|
|
149
|
+
'workspace.git.status': { params: { workspaceId: string }; result: GitStatus };
|
|
150
|
+
'workspace.git.diff': { params: { workspaceId: string; compare: GitCompare; path?: string; cursor?: string }; result: GitDiffPage };
|
|
151
|
+
'workspace.git.facts': { params: { directory: string }; result: GitFacts };
|
|
152
|
+
'workspace.worktree.options': { params: { workspaceId: string }; result: { mappingIds: string[] } };
|
|
153
|
+
'workspace.worktree.create': { params: RegistryMutation & { workspaceId: string; mappingId: string }; result: { workspace: RegistryWorkspace; revision: number } };
|
|
154
|
+
'workspace.worktree.remove': { params: RegistryMutation & { workspaceId: string }; result: { workspace: RegistryWorkspace; revision: number; filesRemoved: true; branchRetained: true } };
|
|
155
|
+
'registry.worktree': { params: { principalId?: string; principalEpoch?: string; mappingIds?: string[]; authorizedRoots?: string[] }; result: { mappings: Array<{id:string;source:string}>; workspaces: unknown[] } };
|
|
156
|
+
'project.list': { params: { cursor?: string; limit?: number; projectRoots?: string[] }; result: RegistryPage & { projects: RegistryProject[] } };
|
|
157
|
+
'workspace.list': { params: { cursor?: string; limit?: number; projectRoots?: string[] }; result: RegistryPage & { workspaces: RegistryWorkspace[] } };
|
|
158
|
+
'workspace.get': { params: { workspaceId: string }; result: { workspace: RegistryWorkspace; revision: number } };
|
|
159
|
+
'project.register': { params: RegistryMutation & { directory: string }; result: { project: RegistryProject; revision: number } };
|
|
160
|
+
'project.remove': { params: RegistryMutation & { projectId: string }; result: { project: RegistryProject; revision: number } };
|
|
161
|
+
'workspace.update': { params: RegistryMutation & { workspaceId: string; title?: string | null; pinned?: boolean; archived?: boolean }; result: { workspace: RegistryWorkspace; revision: number } };
|
|
162
|
+
'registry.owner': { params: { operation?: string; args?: Record<string, unknown>; requestId?: string; ifRevision?: number }; result: { registry: Record<string, unknown> } };
|
|
163
|
+
|
|
164
|
+
'daemon.hello': { params: { protocolVersion: 1; client?: { name: string; version: string }; capabilities?: string[] }; result: { protocolVersion: 1; daemonVersion?: string; pid?: number; /** The daemon host's machine name (os.hostname()), a label for clients. */ hostname?: string; promptImageLimits?: { maxCount: number; maxBytes: number; maxTotalBytes: number }; attachmentLimits?: AttachmentLimits; terminalLimits?: TerminalLimits; capabilities?: string[] } };
|
|
165
|
+
'daemon.status': {
|
|
166
|
+
params: Empty;
|
|
167
|
+
result: {
|
|
168
|
+
pid: number; startedAt: string; version: string; protocolVersion: number; sessions: number; questions: number;
|
|
169
|
+
previousExit?: { kind: 'clean' | 'crash'; at?: string };
|
|
170
|
+
persistence?: Record<string, unknown>;
|
|
171
|
+
health: { live: boolean; ready: boolean; checks: Array<{ id: string; ok: boolean; code?: string; message?: string }> };
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
'daemon.shutdown': { params: Empty; result: Empty };
|
|
175
|
+
'daemon.pause': { params: { runtime?: RuntimeKind; now?: boolean; reason?: string }; result: PauseState };
|
|
176
|
+
'daemon.resume': { params: { runtime?: RuntimeKind }; result: PauseState };
|
|
177
|
+
'daemon.pauses': { params: Empty; result: PauseState };
|
|
178
|
+
'daemon.usage': { params: { refresh?: boolean }; result: { providers: Array<Record<string, unknown>> } };
|
|
179
|
+
'catalog.get': { params: Empty; result: { models: Array<Record<string, unknown>>; modes: Array<Record<string, unknown>>; thinkingOptions?: unknown; defaultModel: string; fetchedAt?: string; providers?: Record<string, { status: string; fetchedAt?: string; error?: string }> } };
|
|
180
|
+
'catalog.refresh': { params: Empty; result: { models: Array<Record<string, unknown>>; modes: Array<Record<string, unknown>>; thinkingOptions?: unknown; defaultModel: string; fetchedAt?: string; providers?: Record<string, { status: string; fetchedAt?: string; error?: string }> } };
|
|
181
|
+
'assignment.recall': { params: { assignmentId?: string; taskId?: string; projectRoot?: string; question: string }; result: RecallAnswer };
|
|
182
|
+
'board.list': { params: { projectRoot: string }; result: { pins: Pin[] } };
|
|
183
|
+
'question.list': { params: { projectRoot?: string }; result: { questions: UserQuestion[] } };
|
|
184
|
+
/** 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. */
|
|
185
|
+
'question.watch': { params: { projectRoot?: string; turns?: boolean; attention?: boolean }; result: { questions: UserQuestion[]; attention?: Array<{ sessionId: string; attention: TurnAttention }> } };
|
|
186
|
+
/** Capability `session.attention`: acknowledges a root's attention for every client; with `at`, only that one (a later turn's stays). */
|
|
187
|
+
'session.attention.clear': { params: { sessionId: string; at?: string }; result: { cleared: boolean } };
|
|
188
|
+
/** Capability `workspace.files`: files under `projectRoot` whose relative path matches `query`, best first; read-only, links not followed. */
|
|
189
|
+
'workspace.files.search': { params: { projectRoot: string; query?: string; limit?: number }; result: { files: Array<{ path: string }>; truncated?: boolean } };
|
|
190
|
+
/** 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`). */
|
|
191
|
+
'workspace.files.list': { params: { projectRoot: string; path?: string; includeIgnored?: boolean; cursor?: string; internalLinks?: boolean }; result: { entries: Array<{ name: string; path: string; kind: 'file' | 'directory'; size?: number; modifiedAt?: string; target?: string }>; truncated?: boolean; nextCursor?: string; target?: string } };
|
|
192
|
+
/** Capability `workspace.files.read`: a UTF-8 text file under `projectRoot`, at most 1 MiB; read-only, links not followed. */
|
|
193
|
+
'workspace.files.read': { params: { projectRoot: string; path: string; includeIgnored?: boolean }; result: { path: string; content: string; size: number; modifiedAt?: string } };
|
|
194
|
+
/** 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. */
|
|
195
|
+
'workspace.files.find': { params: { projectRoot: string; query?: string; kinds?: Array<'file' | 'directory'>; matchMode?: 'subsequence' | 'suffix'; limit?: number; cursor?: string }; result: { entries: Array<{ path: string; kind: 'file' | 'directory' }>; nextCursor?: string; truncated?: boolean } };
|
|
196
|
+
/** 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`. */
|
|
197
|
+
'workspace.files.preview': { params: { projectRoot: string; path: string; includeIgnored?: boolean; internalLinks?: boolean; maxBytes?: number; offset?: number; revision?: string }; result: { path: string; target?: string; kind: 'text' | 'image' | 'binary'; mimeType: string; size: number; modifiedAt: string; revision: string; encoding: 'base64' | 'none'; content?: string; offset?: number; nextOffset?: number } };
|
|
198
|
+
/** Capability `host.directories`: directories of the daemon host whose path completes `query` (absolute or under ~), or whose name matches it under the home directory. */
|
|
199
|
+
'host.directories.search': { params: { query: string; limit?: number }; result: { entries: Array<{ path: string }>; truncated?: boolean } };
|
|
200
|
+
'question.answer': { params: { questionId: string; text?: string; dismiss?: boolean; reason?: string }; result: { questionId: string } };
|
|
201
|
+
'session.create': {
|
|
202
|
+
params: { sessionId?: string; history?: 'skip' | 'replay'; delegation?: boolean; resume?: boolean } & ({ workspaceId: string; spec: Omit<SessionSpec, 'cwd'> & { cwd?: string } } | { workspaceId?: undefined; spec: SessionSpec });
|
|
203
|
+
result: { session: SessionSnapshot; attached: boolean; resumed?: true; durable?: boolean };
|
|
204
|
+
};
|
|
205
|
+
'session.preview': { params: { spec: SessionSpec }; result: { preview: SessionPreview } };
|
|
206
|
+
'session.history': { params: { sessionId: string; before?: string; limit?: number; maxBytes?: number }; result: HistoryPage };
|
|
207
|
+
'session.attach': { params: { sessionId: string; replay?: boolean; after?: number; generation?: string }; result: { session: SessionSummary; cursor: number; reset?: true } };
|
|
208
|
+
'session.release': { params: { sessionId: string }; result: { closed: boolean } };
|
|
209
|
+
'session.prompt': {
|
|
210
|
+
params: PrincipalContext & { sessionId: string; clientMessageId: string; delivery?: 'auto' | 'steer'; content: PromptContent };
|
|
211
|
+
/** `{}` from a daemon without prompt.receipts. */
|
|
212
|
+
result: { outcome?: 'accepted' | 'failed'; error?: AlpError; duplicate?: boolean; durable?: boolean };
|
|
213
|
+
};
|
|
214
|
+
'session.interrupt': { params: { sessionId: string; /** With session.interrupt.turn, cancel only this turn. */ turnId?: string }; result: { /** Conditional request only: false means the named turn is no longer active. */ interrupted?: boolean } };
|
|
215
|
+
/**
|
|
216
|
+
* Changes a session's permissions mode while idle; with capability `session.configure.live`, also a live
|
|
217
|
+
* root's model, effort or team (§12.9): those need requestId and ifGeneration, apply at the idle barrier
|
|
218
|
+
* through a restart of its native process on the same conversation, and answer `configured`. Answered
|
|
219
|
+
* once per (sessionId, requestId): a repeat answers the first result with `duplicate: true`.
|
|
220
|
+
*/
|
|
221
|
+
'session.configure': {
|
|
222
|
+
params: { sessionId: string; mode?: string; model?: string; thinking?: string; team?: string; requestId?: string; ifGeneration?: string };
|
|
223
|
+
result: { session: SessionSnapshot | SessionSummary; configured?: ConfigureOutcome; duplicate?: true };
|
|
224
|
+
};
|
|
225
|
+
/** What session.configure would run a live root with, and whether it would take it now (capability `session.configure.live`, §12.9). */
|
|
226
|
+
'session.configure.preview': {
|
|
227
|
+
params: { sessionId: string; mode?: string; model?: string; thinking?: string; team?: string };
|
|
228
|
+
result: { preview: ConfigurePreview };
|
|
229
|
+
};
|
|
230
|
+
'session.close': { params: { sessionId: string }; result: Empty };
|
|
231
|
+
'session.rename': { params: { sessionId: string; title: string }; result: { session: SessionSummary } };
|
|
232
|
+
/**
|
|
233
|
+
* A new root whose conversation is the source's up to a completed turn (capability `session.fork`, §12.7).
|
|
234
|
+
* Answered once per (sessionId, requestId): a repeat answers the first result with `duplicate: true`.
|
|
235
|
+
*/
|
|
236
|
+
'session.fork': {
|
|
237
|
+
params: PrincipalContext & { sessionId: string; requestId: string; ifGeneration: string; boundary?: ForkBoundary; branchId?: string; workspaceId?: string; newSessionId?: string; title?: string };
|
|
238
|
+
result: { session: SessionSummary; forkedFrom: ForkProvenance; duplicate?: true };
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* The root's conversation from before a turn on, under the same session id; the later turns stay as a
|
|
242
|
+
* recoverable branch and no file is changed (capability `session.rewind`, §12.7).
|
|
243
|
+
*/
|
|
244
|
+
'session.rewind': {
|
|
245
|
+
params: { sessionId: string; requestId: string; ifGeneration: string; beforeTurnId: string };
|
|
246
|
+
result: { session: SessionSummary; generation: string; branch: ConversationBranch; duplicate?: true };
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Restarts a live root's native process on its own conversation and configuration at the idle
|
|
250
|
+
* barrier, keeping its session id, history and receipts (capability `session.reload`, §12.8).
|
|
251
|
+
* Answered once per (sessionId, requestId): a repeat answers the first result with `duplicate: true`.
|
|
252
|
+
*/
|
|
253
|
+
'session.reload': {
|
|
254
|
+
params: { sessionId: string; requestId: string; ifGeneration: string };
|
|
255
|
+
result: { session: SessionSummary; duplicate?: true };
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* The ALP CLI command that continues a session in a terminal, built by alpd (capability
|
|
259
|
+
* `session.resumeCommand`, §12.8): argv and its POSIX and Windows command lines, for the clipboard only.
|
|
260
|
+
*/
|
|
261
|
+
/**
|
|
262
|
+
* Compacts a live root's context (t-0e56): main writes a checkpoint by skill compact, then its runtime
|
|
263
|
+
* compacts, or ALP starts a fresh conversation seeded with it. Idle: now; otherwise at its next turn boundary.
|
|
264
|
+
*/
|
|
265
|
+
'session.compact': {
|
|
266
|
+
params: { sessionId: string };
|
|
267
|
+
result: { status: 'started' | 'deferred' | 'running' };
|
|
268
|
+
};
|
|
269
|
+
/** The slash commands and skills a live session's composer offers after "/" (capability `session.commands`, t-f628). */
|
|
270
|
+
'session.commands': {
|
|
271
|
+
params: { sessionId: string };
|
|
272
|
+
result: { commands: SessionCommand[] };
|
|
273
|
+
};
|
|
274
|
+
'session.resumeCommand': {
|
|
275
|
+
params: { sessionId: string };
|
|
276
|
+
result: ResumeCommand;
|
|
277
|
+
};
|
|
278
|
+
'session.archive': { params: { sessionId: string; archived?: boolean }; result: { session: SessionSummary } };
|
|
279
|
+
'session.get': { params: { sessionId: string }; result: { session: SessionSummary } };
|
|
280
|
+
/** `limit`, `cursor`, `query` and `projectRoots` with capability `session.list.page`: a page, and `nextCursor` while more follow. */
|
|
281
|
+
'session.list': { params: { projectRoot?: string; projectRoots?: string[]; rootsOnly?: boolean; includeClosed?: boolean; includeArchived?: boolean; limit?: number; cursor?: string; query?: string }; result: { sessions: SessionSummary[]; nextCursor?: string } };
|
|
282
|
+
'session.status': { params: { sessionId: string }; result: { status: TreeStatus } };
|
|
283
|
+
'session.message': { params: { sessionId: string; text: string }; result: Empty };
|
|
284
|
+
'session.log': { params: { sessionId: string }; result: { rootId: string; entries: Array<Record<string, unknown>> } };
|
|
285
|
+
'extension.register': { params: { method: string }; result: { registered: string } };
|
|
286
|
+
'extension.unregister': { params: { method: string }; result: { unregistered: string } };
|
|
287
|
+
'team.list': { params: { projectRoot?: string }; result: { projectRoot: string | null; teams: TeamRow[] } };
|
|
288
|
+
'task.list': { params: { projectRoot: string }; result: { projectRoot: string; tasks: TaskRow[]; unreadable: Array<{ file: string; error: string }>; revision: string } };
|
|
289
|
+
'task.create': { params: { projectRoot: string; title: string; priority?: number; requestId?: string }; result: { id: string; duplicate?: true } };
|
|
290
|
+
'task.update': { params: { projectRoot: string; id: string; action: 'close' | 'reopen'; note?: string; ifRev?: number }; result: { id: string; status: string; rev: number; landed?: string } };
|
|
291
|
+
'task.gate.resolve': { params: { projectRoot: string; id: string; gate: string; note?: string; ifRev?: number; /** One of a human gate's options; picking one approves it. */ choice?: string; /** Record the user's rejection instead (note is the reason); the gate stays open. */ reject?: boolean; /** Where the user decided, recorded on the gate. Default web. */ channel?: 'paseo' | 'web' }; result: { id: string; status: string; rev: number } };
|
|
292
|
+
'library.list': { params: { kind: LibraryKind; projectRoot?: string }; result: { projectRoot: string | null; entries: LibraryEntryRow[] } };
|
|
293
|
+
'library.get': {
|
|
294
|
+
params: { kind: LibraryKind; name: EntryName; projectRoot?: string; scope?: LibraryScope };
|
|
295
|
+
/** `content` carries `{ $secret: 'keep' }` in place of each secret value; `secrets` lists their JSON Pointers. */
|
|
296
|
+
result: { kind: LibraryKind; name: string; source: LibrarySource; overrides?: LibrarySource; content: Record<string, unknown>; revision: string | null; usedBy: string[]; librarySkills?: string[]; secrets?: string[] };
|
|
297
|
+
};
|
|
298
|
+
'library.save': {
|
|
299
|
+
params: { kind: LibraryKind; name: EntryName; scope: LibraryScope; projectRoot?: string; policy?: 'project-data'; content: Record<string, unknown>; revision?: string | null; sync?: 'none' | 'known-projects' };
|
|
300
|
+
result: { revision: string | null; syncedProjects?: number; syncErrors?: string[] };
|
|
301
|
+
};
|
|
302
|
+
'library.delete': { params: { kind: LibraryKind; name: EntryName; scope: LibraryScope; projectRoot?: string; policy?: 'project-data'; revision?: string }; result: { removed: true; now?: 'builtin' | 'library' } };
|
|
303
|
+
'library.duplicate': { params: { kind: LibraryKind; from: EntryName; to: EntryName; scope: LibraryScope; projectRoot?: string; policy?: 'project-data' }; result: { revision: string | null } };
|
|
304
|
+
'library.rename': { params: { kind: LibraryKind; from: EntryName; to: EntryName; scope: LibraryScope; projectRoot?: string; policy?: 'project-data' }; result: { revision: string | null } };
|
|
305
|
+
'library.skills.set': { params: { agent: EntryName; skills: EntryName[] }; result: { skills: string[] } };
|
|
306
|
+
'library.models': { params: Empty; result: { models: Array<{ id: string; label: string; efforts: string[]; effort?: string }> } };
|
|
307
|
+
'settings.language.get': { params: Empty; result: LanguageSetting };
|
|
308
|
+
'settings.language.set': { params: { language: string | null }; result: LanguageSetting };
|
|
309
|
+
/** Capability `schedule`: a one-shot continuation of a root session, due at `dueAt` (UTC, ISO 8601). */
|
|
310
|
+
'schedule.create': { params: { projectRoot: string; sessionId: string; dueAt: string; prompt: string; keepsSession?: boolean }; result: { job: ScheduleJob } };
|
|
311
|
+
'schedule.list': { params: { projectRoot: string; status?: ScheduleStatus }; result: { jobs: ScheduleJob[] } };
|
|
312
|
+
'schedule.get': { params: { id: string; projectRoot: string }; result: { job: ScheduleJob } };
|
|
313
|
+
'schedule.cancel': { params: { id: string; projectRoot: string }; result: { job: ScheduleJob } };
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export type RpcMethod = keyof RpcMethodMap;
|
|
317
|
+
export type RpcParams<M extends RpcMethod> = RpcMethodMap[M]['params'];
|
|
318
|
+
export type RpcResult<M extends RpcMethod> = RpcMethodMap[M]['result'];
|