@anhlp/alp-protocol 0.0.0-beta.1
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 +17 -0
- package/conformance/cases.json +951 -0
- package/conformance/run.d.mts +32 -0
- package/conformance/run.mjs +403 -0
- package/dist/connection.d.ts +9 -0
- package/dist/connection.js +0 -0
- package/dist/contract-v1.d.ts +4171 -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 +104 -0
- package/dist/dto.js +0 -0
- package/dist/events.d.ts +225 -0
- package/dist/events.js +0 -0
- package/dist/index.d.ts +6 -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 +498 -0
- package/dist/rpc.js +0 -0
- package/dist/session.d.ts +134 -0
- package/dist/session.js +0 -0
- package/dist/validate.d.ts +12 -0
- package/dist/validate.js +147 -0
- package/dist/wire.d.ts +41 -0
- package/dist/wire.js +32 -0
- package/fixtures/ipc-v1.jsonl +4 -0
- package/fixtures/v1/cases.json +2827 -0
- package/package.json +129 -0
- package/schema/ipc-v1.json +2007 -0
- package/schema/methods-v1.json +4070 -0
- package/src/connection.ts +9 -0
- package/src/contract-v1.js +2 -0
- package/src/contract.js +44 -0
- package/src/dto.ts +78 -0
- package/src/events.ts +127 -0
- package/src/index.ts +6 -0
- package/src/public.js +2 -0
- package/src/rpc.ts +102 -0
- package/src/session.ts +94 -0
- package/src/validate.js +113 -0
- package/src/wire.js +26 -0
package/dist/rpc.d.ts
ADDED
|
@@ -0,0 +1,498 @@
|
|
|
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, UserQuestion } from './events.js';
|
|
4
|
+
import type { PauseState, PromptContent, RecallAnswer, SessionPreview, SessionSpec, SessionSummary } from './session.js';
|
|
5
|
+
import type { EntryName, LanguageSetting, LibraryEntryRow, LibraryKind, LibraryScope, LibrarySource, TaskRow, TeamRow } from './dto.js';
|
|
6
|
+
export type RpcId = string | number | null;
|
|
7
|
+
export type RpcErrorData = {
|
|
8
|
+
code: number;
|
|
9
|
+
message: string;
|
|
10
|
+
data?: unknown;
|
|
11
|
+
};
|
|
12
|
+
export type RpcRequest = {
|
|
13
|
+
jsonrpc: '2.0';
|
|
14
|
+
id?: RpcId;
|
|
15
|
+
method: string;
|
|
16
|
+
params?: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
export type RpcResponse = {
|
|
19
|
+
jsonrpc: '2.0';
|
|
20
|
+
id: RpcId;
|
|
21
|
+
} & ({
|
|
22
|
+
result: unknown;
|
|
23
|
+
error?: never;
|
|
24
|
+
} | {
|
|
25
|
+
error: RpcErrorData;
|
|
26
|
+
result?: never;
|
|
27
|
+
});
|
|
28
|
+
export type EventNotification = {
|
|
29
|
+
jsonrpc: '2.0';
|
|
30
|
+
method: 'event';
|
|
31
|
+
params: Envelope;
|
|
32
|
+
};
|
|
33
|
+
/** Names a daemon may list in its daemon.hello result (schema/methods-v1.json `capabilities`). */
|
|
34
|
+
export type Capability = 'attach.after' | 'prompt.receipts' | 'extension.methods' | 'team' | 'task' | 'library' | 'settings.language';
|
|
35
|
+
/** `data.reason` values alpd sets on errors (docs/protocol/alp-json-rpc-v1.md §5.3). */
|
|
36
|
+
export type ErrorReason = 'hello_required' | 'protocol_version' | 'invalid_params' | 'invalid_id' | 'batch_unsupported' | 'frame_too_large' | 'response_too_large' | 'persistence_failed' | 'outcome_unknown' | 'key_conflict' | 'invalid_path' | 'invalid_scope' | 'invalid_entry' | 'secret_marker' | 'not_alp_project' | 'unknown_task' | 'not_found' | 'unsafe_path' | 'revision_conflict' | 'task_state' | 'in_use' | 'busy' | 'unreadable';
|
|
37
|
+
type Empty = Record<string, never>;
|
|
38
|
+
/**
|
|
39
|
+
* Params and result of every v1 method, as schema/methods-v1.json defines them; the protocol tests
|
|
40
|
+
* type-check the golden fixtures against this map, so the two cannot drift. Results may carry
|
|
41
|
+
* properties this map does not name: clients ignore them.
|
|
42
|
+
*/
|
|
43
|
+
export type RpcMethodMap = {
|
|
44
|
+
'daemon.hello': {
|
|
45
|
+
params: {
|
|
46
|
+
protocolVersion: 1;
|
|
47
|
+
client?: {
|
|
48
|
+
name: string;
|
|
49
|
+
version: string;
|
|
50
|
+
};
|
|
51
|
+
capabilities?: string[];
|
|
52
|
+
};
|
|
53
|
+
result: {
|
|
54
|
+
protocolVersion: 1;
|
|
55
|
+
daemonVersion?: string;
|
|
56
|
+
pid?: number;
|
|
57
|
+
capabilities?: string[];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
'daemon.status': {
|
|
61
|
+
params: Empty;
|
|
62
|
+
result: {
|
|
63
|
+
pid: number;
|
|
64
|
+
startedAt: string;
|
|
65
|
+
version: string;
|
|
66
|
+
protocolVersion: number;
|
|
67
|
+
sessions: number;
|
|
68
|
+
questions: number;
|
|
69
|
+
previousExit?: {
|
|
70
|
+
kind: 'clean' | 'crash';
|
|
71
|
+
at?: string;
|
|
72
|
+
};
|
|
73
|
+
persistence?: Record<string, unknown>;
|
|
74
|
+
health: {
|
|
75
|
+
live: boolean;
|
|
76
|
+
ready: boolean;
|
|
77
|
+
checks: Array<{
|
|
78
|
+
id: string;
|
|
79
|
+
ok: boolean;
|
|
80
|
+
code?: string;
|
|
81
|
+
message?: string;
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
'daemon.shutdown': {
|
|
87
|
+
params: Empty;
|
|
88
|
+
result: Empty;
|
|
89
|
+
};
|
|
90
|
+
'daemon.pause': {
|
|
91
|
+
params: {
|
|
92
|
+
runtime?: RuntimeKind;
|
|
93
|
+
now?: boolean;
|
|
94
|
+
reason?: string;
|
|
95
|
+
};
|
|
96
|
+
result: PauseState;
|
|
97
|
+
};
|
|
98
|
+
'daemon.resume': {
|
|
99
|
+
params: {
|
|
100
|
+
runtime?: RuntimeKind;
|
|
101
|
+
};
|
|
102
|
+
result: PauseState;
|
|
103
|
+
};
|
|
104
|
+
'daemon.pauses': {
|
|
105
|
+
params: Empty;
|
|
106
|
+
result: PauseState;
|
|
107
|
+
};
|
|
108
|
+
'daemon.usage': {
|
|
109
|
+
params: {
|
|
110
|
+
refresh?: boolean;
|
|
111
|
+
};
|
|
112
|
+
result: {
|
|
113
|
+
providers: Array<Record<string, unknown>>;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
'catalog.get': {
|
|
117
|
+
params: Empty;
|
|
118
|
+
result: {
|
|
119
|
+
models: Array<Record<string, unknown>>;
|
|
120
|
+
modes: Array<Record<string, unknown>>;
|
|
121
|
+
thinkingOptions?: unknown;
|
|
122
|
+
defaultModel: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
'assignment.recall': {
|
|
126
|
+
params: {
|
|
127
|
+
assignmentId?: string;
|
|
128
|
+
taskId?: string;
|
|
129
|
+
projectRoot?: string;
|
|
130
|
+
question: string;
|
|
131
|
+
};
|
|
132
|
+
result: RecallAnswer;
|
|
133
|
+
};
|
|
134
|
+
'board.list': {
|
|
135
|
+
params: {
|
|
136
|
+
projectRoot: string;
|
|
137
|
+
};
|
|
138
|
+
result: {
|
|
139
|
+
pins: Pin[];
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
'question.list': {
|
|
143
|
+
params: {
|
|
144
|
+
projectRoot?: string;
|
|
145
|
+
};
|
|
146
|
+
result: {
|
|
147
|
+
questions: UserQuestion[];
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
'question.answer': {
|
|
151
|
+
params: {
|
|
152
|
+
questionId: string;
|
|
153
|
+
text?: string;
|
|
154
|
+
dismiss?: boolean;
|
|
155
|
+
reason?: string;
|
|
156
|
+
};
|
|
157
|
+
result: {
|
|
158
|
+
questionId: string;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
'session.create': {
|
|
162
|
+
params: {
|
|
163
|
+
sessionId?: string;
|
|
164
|
+
spec: SessionSpec;
|
|
165
|
+
history?: 'skip' | 'replay';
|
|
166
|
+
delegation?: boolean;
|
|
167
|
+
resume?: boolean;
|
|
168
|
+
};
|
|
169
|
+
result: {
|
|
170
|
+
session: SessionSnapshot;
|
|
171
|
+
attached: boolean;
|
|
172
|
+
resumed?: true;
|
|
173
|
+
durable?: boolean;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
'session.preview': {
|
|
177
|
+
params: {
|
|
178
|
+
spec: SessionSpec;
|
|
179
|
+
};
|
|
180
|
+
result: {
|
|
181
|
+
preview: SessionPreview;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
'session.attach': {
|
|
185
|
+
params: {
|
|
186
|
+
sessionId: string;
|
|
187
|
+
replay?: boolean;
|
|
188
|
+
after?: number;
|
|
189
|
+
};
|
|
190
|
+
result: {
|
|
191
|
+
session: SessionSummary;
|
|
192
|
+
cursor: number;
|
|
193
|
+
reset?: true;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
'session.release': {
|
|
197
|
+
params: {
|
|
198
|
+
sessionId: string;
|
|
199
|
+
};
|
|
200
|
+
result: {
|
|
201
|
+
closed: boolean;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
'session.prompt': {
|
|
205
|
+
params: {
|
|
206
|
+
sessionId: string;
|
|
207
|
+
clientMessageId: string;
|
|
208
|
+
delivery?: 'auto' | 'steer';
|
|
209
|
+
content: PromptContent;
|
|
210
|
+
};
|
|
211
|
+
/** `{}` from a daemon without prompt.receipts. */
|
|
212
|
+
result: {
|
|
213
|
+
outcome?: 'accepted' | 'failed';
|
|
214
|
+
error?: AlpError;
|
|
215
|
+
duplicate?: boolean;
|
|
216
|
+
durable?: boolean;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
'session.interrupt': {
|
|
220
|
+
params: {
|
|
221
|
+
sessionId: string;
|
|
222
|
+
};
|
|
223
|
+
result: Empty;
|
|
224
|
+
};
|
|
225
|
+
'session.configure': {
|
|
226
|
+
params: {
|
|
227
|
+
sessionId: string;
|
|
228
|
+
mode?: string;
|
|
229
|
+
};
|
|
230
|
+
result: {
|
|
231
|
+
session: SessionSnapshot;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
'session.close': {
|
|
235
|
+
params: {
|
|
236
|
+
sessionId: string;
|
|
237
|
+
};
|
|
238
|
+
result: Empty;
|
|
239
|
+
};
|
|
240
|
+
'session.rename': {
|
|
241
|
+
params: {
|
|
242
|
+
sessionId: string;
|
|
243
|
+
title: string;
|
|
244
|
+
};
|
|
245
|
+
result: {
|
|
246
|
+
session: SessionSummary;
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
'session.archive': {
|
|
250
|
+
params: {
|
|
251
|
+
sessionId: string;
|
|
252
|
+
archived?: boolean;
|
|
253
|
+
};
|
|
254
|
+
result: {
|
|
255
|
+
session: SessionSummary;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
'session.get': {
|
|
259
|
+
params: {
|
|
260
|
+
sessionId: string;
|
|
261
|
+
};
|
|
262
|
+
result: {
|
|
263
|
+
session: SessionSummary;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
'session.list': {
|
|
267
|
+
params: {
|
|
268
|
+
projectRoot?: string;
|
|
269
|
+
rootsOnly?: boolean;
|
|
270
|
+
includeClosed?: boolean;
|
|
271
|
+
includeArchived?: boolean;
|
|
272
|
+
};
|
|
273
|
+
result: {
|
|
274
|
+
sessions: SessionSummary[];
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
'session.status': {
|
|
278
|
+
params: {
|
|
279
|
+
sessionId: string;
|
|
280
|
+
};
|
|
281
|
+
result: {
|
|
282
|
+
status: TreeStatus;
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
'session.message': {
|
|
286
|
+
params: {
|
|
287
|
+
sessionId: string;
|
|
288
|
+
text: string;
|
|
289
|
+
};
|
|
290
|
+
result: Empty;
|
|
291
|
+
};
|
|
292
|
+
'session.log': {
|
|
293
|
+
params: {
|
|
294
|
+
sessionId: string;
|
|
295
|
+
};
|
|
296
|
+
result: {
|
|
297
|
+
rootId: string;
|
|
298
|
+
entries: Array<Record<string, unknown>>;
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
'extension.register': {
|
|
302
|
+
params: {
|
|
303
|
+
method: string;
|
|
304
|
+
};
|
|
305
|
+
result: {
|
|
306
|
+
registered: string;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
'extension.unregister': {
|
|
310
|
+
params: {
|
|
311
|
+
method: string;
|
|
312
|
+
};
|
|
313
|
+
result: {
|
|
314
|
+
unregistered: string;
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
'team.list': {
|
|
318
|
+
params: {
|
|
319
|
+
projectRoot?: string;
|
|
320
|
+
};
|
|
321
|
+
result: {
|
|
322
|
+
projectRoot: string | null;
|
|
323
|
+
teams: TeamRow[];
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
'task.list': {
|
|
327
|
+
params: {
|
|
328
|
+
projectRoot: string;
|
|
329
|
+
};
|
|
330
|
+
result: {
|
|
331
|
+
projectRoot: string;
|
|
332
|
+
tasks: TaskRow[];
|
|
333
|
+
unreadable: Array<{
|
|
334
|
+
file: string;
|
|
335
|
+
error: string;
|
|
336
|
+
}>;
|
|
337
|
+
revision: string;
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
'task.create': {
|
|
341
|
+
params: {
|
|
342
|
+
projectRoot: string;
|
|
343
|
+
title: string;
|
|
344
|
+
priority?: number;
|
|
345
|
+
requestId?: string;
|
|
346
|
+
};
|
|
347
|
+
result: {
|
|
348
|
+
id: string;
|
|
349
|
+
duplicate?: true;
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
'task.update': {
|
|
353
|
+
params: {
|
|
354
|
+
projectRoot: string;
|
|
355
|
+
id: string;
|
|
356
|
+
action: 'close' | 'reopen';
|
|
357
|
+
note?: string;
|
|
358
|
+
ifRev?: number;
|
|
359
|
+
};
|
|
360
|
+
result: {
|
|
361
|
+
id: string;
|
|
362
|
+
status: string;
|
|
363
|
+
rev: number;
|
|
364
|
+
landed?: string;
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
'task.gate.resolve': {
|
|
368
|
+
params: {
|
|
369
|
+
projectRoot: string;
|
|
370
|
+
id: string;
|
|
371
|
+
gate: string;
|
|
372
|
+
note?: string;
|
|
373
|
+
ifRev?: number;
|
|
374
|
+
};
|
|
375
|
+
result: {
|
|
376
|
+
id: string;
|
|
377
|
+
status: string;
|
|
378
|
+
rev: number;
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
'library.list': {
|
|
382
|
+
params: {
|
|
383
|
+
kind: LibraryKind;
|
|
384
|
+
projectRoot?: string;
|
|
385
|
+
};
|
|
386
|
+
result: {
|
|
387
|
+
projectRoot: string | null;
|
|
388
|
+
entries: LibraryEntryRow[];
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
'library.get': {
|
|
392
|
+
params: {
|
|
393
|
+
kind: LibraryKind;
|
|
394
|
+
name: EntryName;
|
|
395
|
+
projectRoot?: string;
|
|
396
|
+
scope?: LibraryScope;
|
|
397
|
+
};
|
|
398
|
+
/** `content` carries `{ $secret: 'keep' }` in place of each secret value; `secrets` lists their JSON Pointers. */
|
|
399
|
+
result: {
|
|
400
|
+
kind: LibraryKind;
|
|
401
|
+
name: string;
|
|
402
|
+
source: LibrarySource;
|
|
403
|
+
overrides?: LibrarySource;
|
|
404
|
+
content: Record<string, unknown>;
|
|
405
|
+
revision: string | null;
|
|
406
|
+
usedBy: string[];
|
|
407
|
+
librarySkills?: string[];
|
|
408
|
+
secrets?: string[];
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
'library.save': {
|
|
412
|
+
params: {
|
|
413
|
+
kind: LibraryKind;
|
|
414
|
+
name: EntryName;
|
|
415
|
+
scope: LibraryScope;
|
|
416
|
+
projectRoot?: string;
|
|
417
|
+
content: Record<string, unknown>;
|
|
418
|
+
revision?: string | null;
|
|
419
|
+
sync?: 'none' | 'known-projects';
|
|
420
|
+
};
|
|
421
|
+
result: {
|
|
422
|
+
revision: string | null;
|
|
423
|
+
syncedProjects?: number;
|
|
424
|
+
syncErrors?: string[];
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
'library.delete': {
|
|
428
|
+
params: {
|
|
429
|
+
kind: LibraryKind;
|
|
430
|
+
name: EntryName;
|
|
431
|
+
scope: LibraryScope;
|
|
432
|
+
projectRoot?: string;
|
|
433
|
+
revision?: string;
|
|
434
|
+
};
|
|
435
|
+
result: {
|
|
436
|
+
removed: true;
|
|
437
|
+
now?: 'builtin' | 'library';
|
|
438
|
+
};
|
|
439
|
+
};
|
|
440
|
+
'library.duplicate': {
|
|
441
|
+
params: {
|
|
442
|
+
kind: LibraryKind;
|
|
443
|
+
from: EntryName;
|
|
444
|
+
to: EntryName;
|
|
445
|
+
scope: LibraryScope;
|
|
446
|
+
projectRoot?: string;
|
|
447
|
+
};
|
|
448
|
+
result: {
|
|
449
|
+
revision: string | null;
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
'library.rename': {
|
|
453
|
+
params: {
|
|
454
|
+
kind: LibraryKind;
|
|
455
|
+
from: EntryName;
|
|
456
|
+
to: EntryName;
|
|
457
|
+
scope: LibraryScope;
|
|
458
|
+
projectRoot?: string;
|
|
459
|
+
};
|
|
460
|
+
result: {
|
|
461
|
+
revision: string | null;
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
'library.skills.set': {
|
|
465
|
+
params: {
|
|
466
|
+
agent: EntryName;
|
|
467
|
+
skills: EntryName[];
|
|
468
|
+
};
|
|
469
|
+
result: {
|
|
470
|
+
skills: string[];
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
'library.models': {
|
|
474
|
+
params: Empty;
|
|
475
|
+
result: {
|
|
476
|
+
models: Array<{
|
|
477
|
+
id: string;
|
|
478
|
+
label: string;
|
|
479
|
+
efforts: string[];
|
|
480
|
+
effort?: string;
|
|
481
|
+
}>;
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
'settings.language.get': {
|
|
485
|
+
params: Empty;
|
|
486
|
+
result: LanguageSetting;
|
|
487
|
+
};
|
|
488
|
+
'settings.language.set': {
|
|
489
|
+
params: {
|
|
490
|
+
language: string | null;
|
|
491
|
+
};
|
|
492
|
+
result: LanguageSetting;
|
|
493
|
+
};
|
|
494
|
+
};
|
|
495
|
+
export type RpcMethod = keyof RpcMethodMap;
|
|
496
|
+
export type RpcParams<M extends RpcMethod> = RpcMethodMap[M]['params'];
|
|
497
|
+
export type RpcResult<M extends RpcMethod> = RpcMethodMap[M]['result'];
|
|
498
|
+
export {};
|
package/dist/rpc.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { RuntimeKind } from './dto.js';
|
|
2
|
+
import type { SessionSnapshot } from './events.js';
|
|
3
|
+
/** MCP servers a client adds to the agent's own; the agent's names win no collisions. */
|
|
4
|
+
export type HostMcpServer = {
|
|
5
|
+
type: 'stdio';
|
|
6
|
+
command: string;
|
|
7
|
+
args?: string[];
|
|
8
|
+
env?: Record<string, string>;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'http' | 'sse';
|
|
11
|
+
url: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
/** What a client asks for; resolveSession turns it into a launchable session. */
|
|
15
|
+
export type SessionSpec = {
|
|
16
|
+
cwd: string;
|
|
17
|
+
agent?: string;
|
|
18
|
+
/** Workflow selected for a new session; omitted uses settings or the restored snapshot. */
|
|
19
|
+
workflow?: string;
|
|
20
|
+
/** Native model, or runtime-prefixed (`codex:`/`claude:`, or `acp:<provider>[/<model>]`) to also choose the runtime. */
|
|
21
|
+
model?: string;
|
|
22
|
+
mode?: string;
|
|
23
|
+
thinking?: string;
|
|
24
|
+
systemPrompt?: string;
|
|
25
|
+
env?: Record<string, string>;
|
|
26
|
+
mcpServers?: Record<string, HostMcpServer>;
|
|
27
|
+
/** Keep the native thread so the session can be resumed. */
|
|
28
|
+
persist?: boolean;
|
|
29
|
+
/** Keep the native thread on disk though the session cannot be resumed: an assignment, which alp_recall may question later. */
|
|
30
|
+
keepThread?: boolean;
|
|
31
|
+
restore?: {
|
|
32
|
+
agent: string;
|
|
33
|
+
threadId: string;
|
|
34
|
+
runtime?: string;
|
|
35
|
+
model?: string;
|
|
36
|
+
workflow?: {
|
|
37
|
+
mode: string;
|
|
38
|
+
maxPeers: number;
|
|
39
|
+
supervisor?: boolean;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/** Where the native harness works, when not the project root: an assignment's git worktree. ALP files are still read from cwd. */
|
|
43
|
+
workdir?: string;
|
|
44
|
+
/** Explicit shared-assignment write scope; workdir points here while ALP uses cwd for its project. */
|
|
45
|
+
writeRoot?: string;
|
|
46
|
+
/** The workdir is a disposable copy the session may write, though its mode is read-only for the requester's tree. */
|
|
47
|
+
copy?: boolean;
|
|
48
|
+
/** The requester's directory the copy mirrors. */
|
|
49
|
+
copyOf?: string;
|
|
50
|
+
};
|
|
51
|
+
export type OpenOptions = {
|
|
52
|
+
history?: 'replay' | 'skip';
|
|
53
|
+
/** False when the client cannot show child sessions; delegation is then refused in this tree. */
|
|
54
|
+
delegation?: boolean;
|
|
55
|
+
};
|
|
56
|
+
export type PromptContent = Array<{
|
|
57
|
+
type: string;
|
|
58
|
+
text?: string;
|
|
59
|
+
}>;
|
|
60
|
+
export type PromptInput = {
|
|
61
|
+
clientMessageId: string;
|
|
62
|
+
/** auto starts a turn; steer adds to the running one. */
|
|
63
|
+
delivery: 'auto' | 'steer';
|
|
64
|
+
content: PromptContent;
|
|
65
|
+
};
|
|
66
|
+
/** A root before it opens: the team and main it would run with, for viewers that let the user choose first (ALPD §60). */
|
|
67
|
+
export type SessionPreview = {
|
|
68
|
+
teams: Array<{
|
|
69
|
+
id: string;
|
|
70
|
+
label: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
}>;
|
|
73
|
+
/** The team the spec selects, else settings' workflow.mode, else Phở. */
|
|
74
|
+
team: string;
|
|
75
|
+
teamLabel?: string;
|
|
76
|
+
agent: string;
|
|
77
|
+
runtime: RuntimeKind;
|
|
78
|
+
model: string;
|
|
79
|
+
mode: string;
|
|
80
|
+
thinking: string;
|
|
81
|
+
};
|
|
82
|
+
/** What became of one assignment an earlier alpd left running. */
|
|
83
|
+
export type RecoveryOutcome = {
|
|
84
|
+
assignmentId: string;
|
|
85
|
+
agent: string;
|
|
86
|
+
outcome: 'resumed' | 'parked' | 'failed';
|
|
87
|
+
error?: string;
|
|
88
|
+
};
|
|
89
|
+
export type Pause = {
|
|
90
|
+
since: string;
|
|
91
|
+
by: string;
|
|
92
|
+
reason: string;
|
|
93
|
+
resetsAt?: string; /** When alpd last asked the runtime about the limit (ALPD §58). */
|
|
94
|
+
checkedAt?: string;
|
|
95
|
+
};
|
|
96
|
+
export type PauseState = {
|
|
97
|
+
all?: Pause;
|
|
98
|
+
runtimes: Partial<Record<RuntimeKind, Pause>>;
|
|
99
|
+
parked: Array<{
|
|
100
|
+
assignmentId: string;
|
|
101
|
+
agent: string;
|
|
102
|
+
runtime: RuntimeKind;
|
|
103
|
+
rootId: string;
|
|
104
|
+
reason: string;
|
|
105
|
+
since: string;
|
|
106
|
+
}>;
|
|
107
|
+
};
|
|
108
|
+
export type RecallAnswer = {
|
|
109
|
+
assignmentId: string;
|
|
110
|
+
agent: string;
|
|
111
|
+
taskId?: string;
|
|
112
|
+
finishedAt: string;
|
|
113
|
+
answer: string;
|
|
114
|
+
};
|
|
115
|
+
/** A session's lifecycle as alpd records it; neutral, so viewers and integrations share one union. */
|
|
116
|
+
export type SessionStatus = 'initializing' | 'idle' | 'running' | 'error' | 'closed';
|
|
117
|
+
/** The last failure recorded for a session (daemon store `SessionRecord.lastError`). */
|
|
118
|
+
export type SessionError = {
|
|
119
|
+
code?: string;
|
|
120
|
+
message: string;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* A session as clients list it: its last snapshot plus lifecycle (ALPD §18). This is the portable
|
|
124
|
+
* shape served by `session.list`; the daemon and every viewer agree on it, so it is the same type
|
|
125
|
+
* the daemon's store and server use rather than a lossy summary.
|
|
126
|
+
*/
|
|
127
|
+
export type SessionSummary = SessionSnapshot & {
|
|
128
|
+
status: SessionStatus;
|
|
129
|
+
title?: string;
|
|
130
|
+
archived?: boolean;
|
|
131
|
+
lastError?: SessionError;
|
|
132
|
+
createdAt?: string;
|
|
133
|
+
updatedAt?: string;
|
|
134
|
+
};
|
package/dist/session.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks `value` against `schema`, resolving `#/$defs/...` against `root`.
|
|
3
|
+
* @param {any} schema
|
|
4
|
+
* @param {unknown} value
|
|
5
|
+
* @param {any} [root]
|
|
6
|
+
* @returns {SchemaIssue[]} empty when the value conforms
|
|
7
|
+
*/
|
|
8
|
+
export function validateSchema(schema: any, value: unknown, root?: any): SchemaIssue[];
|
|
9
|
+
export type SchemaIssue = {
|
|
10
|
+
path: string;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|