@anhlp/alp-protocol 0.0.1-beta.7 → 0.0.1-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract-v1.d.ts +7 -0
- package/dist/contract-v1.js +1 -1
- package/dist/rpc.d.ts +2 -1
- package/dist/wire.d.ts +5 -0
- package/dist/wire.js +2 -0
- package/fixtures/v1/cases.json +88 -1
- package/package.json +1 -1
- package/schema/ipc-v1.json +3 -0
- package/schema/methods-v1.json +8 -2
- package/src/contract-v1.js +1 -1
- package/src/rpc.ts +3 -1
- package/src/wire.js +5 -0
package/dist/rpc.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ export type SessionCommand = {
|
|
|
123
123
|
};
|
|
124
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
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' | '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';
|
|
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
127
|
type Empty = Record<string, never>;
|
|
128
128
|
/**
|
|
129
129
|
* Params and result of every v1 method, as schema/methods-v1.json defines them; the protocol tests
|
|
@@ -1362,6 +1362,7 @@ export type RpcMethodMap = {
|
|
|
1362
1362
|
sessionId: string;
|
|
1363
1363
|
dueAt: string;
|
|
1364
1364
|
prompt: string;
|
|
1365
|
+
keepsSession?: boolean;
|
|
1365
1366
|
};
|
|
1366
1367
|
result: {
|
|
1367
1368
|
job: ScheduleJob;
|
package/dist/wire.d.ts
CHANGED
|
@@ -200,6 +200,11 @@ export const TERMINAL: Readonly<{
|
|
|
200
200
|
}>;
|
|
201
201
|
/** The TERMINAL limits a daemon.hello `terminalLimits` carries (the size bounds are fixed). */
|
|
202
202
|
export const TERMINAL_LIMIT_KEYS: readonly string[];
|
|
203
|
+
/**
|
|
204
|
+
* An agent's name: lower-case letters, digits and single hyphens, starting with a letter, 1 to 64
|
|
205
|
+
* characters. One pattern for `principal.agent` in daemon.hello and a gateway credential's agent.
|
|
206
|
+
*/
|
|
207
|
+
export const AGENT_NAME: RegExp;
|
|
203
208
|
export function isTerminalId(id: unknown): boolean;
|
|
204
209
|
/** Room an attachment.chunk request needs besides its base64 data. */
|
|
205
210
|
export const ATTACHMENT_CHUNK_OVERHEAD: number;
|
package/dist/wire.js
CHANGED
|
@@ -44,6 +44,7 @@ var TERMINAL = Object.freeze({
|
|
|
44
44
|
maxRows: 200
|
|
45
45
|
});
|
|
46
46
|
var TERMINAL_LIMIT_KEYS = Object.freeze(["maxPerPrincipal", "maxPerDaemon", "maxInputBytes", "maxOutputFrameBytes", "replayBytes", "idleMs", "maxLifetimeMs", "reconnectMs"]);
|
|
47
|
+
var AGENT_NAME = /^[a-z](?:[a-z0-9]|-(?=[a-z0-9])){0,63}$/;
|
|
47
48
|
var isTerminalId = (id) => typeof id === "string" && /^term_[0-9a-f]{32}$/.test(id);
|
|
48
49
|
var ATTACHMENT_CHUNK_OVERHEAD = 64 * 1024;
|
|
49
50
|
function attachmentChunkBytes(maxFrame = MAX_FRAME, maxChunkBytes = ATTACHMENTS.maxChunkBytes) {
|
|
@@ -110,6 +111,7 @@ function resumeCommandOf(sessionId, platform) {
|
|
|
110
111
|
return { argv, posix, windows, display: platform === "windows" ? windows : posix, platform };
|
|
111
112
|
}
|
|
112
113
|
export {
|
|
114
|
+
AGENT_NAME,
|
|
113
115
|
ATTACHMENTS,
|
|
114
116
|
ATTACHMENT_CHUNK_OVERHEAD,
|
|
115
117
|
AlpRpcError,
|
package/fixtures/v1/cases.json
CHANGED
|
@@ -101,7 +101,28 @@
|
|
|
101
101
|
"method": "extension.invoke",
|
|
102
102
|
"params": {
|
|
103
103
|
"method": "web.pairing",
|
|
104
|
-
"params": {}
|
|
104
|
+
"params": {},
|
|
105
|
+
"caller": {
|
|
106
|
+
"agent": false
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "extension.invoke request from an agent caller",
|
|
113
|
+
"check": "message",
|
|
114
|
+
"valid": true,
|
|
115
|
+
"value": {
|
|
116
|
+
"jsonrpc": "2.0",
|
|
117
|
+
"id": 4,
|
|
118
|
+
"method": "extension.invoke",
|
|
119
|
+
"params": {
|
|
120
|
+
"method": "web.pairing",
|
|
121
|
+
"params": {},
|
|
122
|
+
"caller": {
|
|
123
|
+
"agent": true,
|
|
124
|
+
"agentName": "lead"
|
|
125
|
+
}
|
|
105
126
|
}
|
|
106
127
|
}
|
|
107
128
|
},
|
|
@@ -4407,6 +4428,72 @@
|
|
|
4407
4428
|
"prompt": "Check the provider quota and continue."
|
|
4408
4429
|
}
|
|
4409
4430
|
},
|
|
4431
|
+
{
|
|
4432
|
+
"name": "schedule.create with keepsSession false",
|
|
4433
|
+
"check": "params",
|
|
4434
|
+
"method": "schedule.create",
|
|
4435
|
+
"valid": true,
|
|
4436
|
+
"value": {
|
|
4437
|
+
"projectRoot": "/work/project",
|
|
4438
|
+
"sessionId": "ses_0123456789abcdef",
|
|
4439
|
+
"dueAt": "2026-10-20T10:00:00.000Z",
|
|
4440
|
+
"prompt": "Check the provider quota and continue.",
|
|
4441
|
+
"keepsSession": false
|
|
4442
|
+
}
|
|
4443
|
+
},
|
|
4444
|
+
{
|
|
4445
|
+
"name": "schedule.create with a keepsSession that is not a boolean",
|
|
4446
|
+
"check": "params",
|
|
4447
|
+
"method": "schedule.create",
|
|
4448
|
+
"valid": false,
|
|
4449
|
+
"value": {
|
|
4450
|
+
"projectRoot": "/work/project",
|
|
4451
|
+
"sessionId": "ses_0123456789abcdef",
|
|
4452
|
+
"dueAt": "2026-10-20T10:00:00.000Z",
|
|
4453
|
+
"prompt": "Check the provider quota and continue.",
|
|
4454
|
+
"keepsSession": "no"
|
|
4455
|
+
}
|
|
4456
|
+
},
|
|
4457
|
+
{
|
|
4458
|
+
"name": "schedule.create result that does not keep its session",
|
|
4459
|
+
"check": "result",
|
|
4460
|
+
"method": "schedule.create",
|
|
4461
|
+
"valid": true,
|
|
4462
|
+
"value": {
|
|
4463
|
+
"job": {
|
|
4464
|
+
"id": "sch_0123456789abcdef",
|
|
4465
|
+
"projectRoot": "/work/project",
|
|
4466
|
+
"sessionId": "ses_0123456789abcdef",
|
|
4467
|
+
"prompt": "Check the provider quota and continue.",
|
|
4468
|
+
"dueAt": "2026-10-20T10:00:00.000Z",
|
|
4469
|
+
"status": "pending",
|
|
4470
|
+
"attempts": 0,
|
|
4471
|
+
"createdAt": "2026-10-20T09:59:00.000Z",
|
|
4472
|
+
"updatedAt": "2026-10-20T09:59:00.000Z",
|
|
4473
|
+
"keepsSession": false
|
|
4474
|
+
}
|
|
4475
|
+
}
|
|
4476
|
+
},
|
|
4477
|
+
{
|
|
4478
|
+
"name": "schedule.create result with keepsSession true",
|
|
4479
|
+
"check": "result",
|
|
4480
|
+
"method": "schedule.create",
|
|
4481
|
+
"valid": false,
|
|
4482
|
+
"value": {
|
|
4483
|
+
"job": {
|
|
4484
|
+
"id": "sch_0123456789abcdef",
|
|
4485
|
+
"projectRoot": "/work/project",
|
|
4486
|
+
"sessionId": "ses_0123456789abcdef",
|
|
4487
|
+
"prompt": "Check the provider quota and continue.",
|
|
4488
|
+
"dueAt": "2026-10-20T10:00:00.000Z",
|
|
4489
|
+
"status": "pending",
|
|
4490
|
+
"attempts": 0,
|
|
4491
|
+
"createdAt": "2026-10-20T09:59:00.000Z",
|
|
4492
|
+
"updatedAt": "2026-10-20T09:59:00.000Z",
|
|
4493
|
+
"keepsSession": true
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
},
|
|
4410
4497
|
{
|
|
4411
4498
|
"name": "schedule.create result",
|
|
4412
4499
|
"check": "result",
|
package/package.json
CHANGED
package/schema/ipc-v1.json
CHANGED
package/schema/methods-v1.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"capabilities": {
|
|
18
18
|
"attach.after": "session.attach accepts `after` and answers `cursor`/`reset`; envelopes kept in a tree timeline carry `cursor`.",
|
|
19
19
|
"prompt.receipts": "session.prompt is answered at most once per (sessionId, clientMessageId) from a durable receipt; repeats answer the first outcome or outcome_unknown.",
|
|
20
|
-
"extension.methods": "extension.register/unregister, and the daemon sends extension.invoke requests to the owning connection.",
|
|
20
|
+
"extension.methods": "extension.register/unregister (refused to an agent-marked connection, user_only), and the daemon sends extension.invoke requests to the owning connection, with a `caller: { agent, agentName? }` the daemon sets itself from the calling connection, never from the caller's params.",
|
|
21
21
|
"team": "team.list: the teams a project can use, from the daemon host's built-ins, library and project.",
|
|
22
22
|
"task": "task.list, task.create, task.update and task.gate.resolve on a project's .alp/tasks, written by the daemon under the task lock.",
|
|
23
23
|
"library": "library.list/get/save/delete/duplicate/rename, library.skills.set and library.models on the daemon user's library and a project's .alp overrides; secrets are redacted on read.",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"session.interrupt.turn": "session.interrupt accepts turnId and atomically cancels only that active turn, including its subtree. Conditional requests answer interrupted:true when canceled, false when the named turn is no longer active; false changes nothing. Without this capability clients must not send turnId or infer targeted cancellation from a legacy interrupt.",
|
|
50
50
|
"terminal.capture": "terminal.capture: bounded daemon-owned rendered text, inclusive zero-based/negative line ranges; same terminal principal/host opt-in. Exceeding resource/result limits is an explicit refusal.",
|
|
51
51
|
"terminal.watch": "terminal.watch/unwatch and terminal.changed: atomic scoped snapshot/subscription. Opaque per-subscription cursor, latest snapshot replaces invalidation history on reconnect/reset; older hosts use explicit polling fallback.",
|
|
52
|
-
"catalog.live": "catalog.get answers the live model catalog (provider lists merged over ALP's static rows) with fetchedAt and per-provider status; catalog.refresh asks the providers again; alpd sends catalog.updated to every helloed connection when the catalog changes."
|
|
52
|
+
"catalog.live": "catalog.get answers the live model catalog (provider lists merged over ALP's static rows) with fetchedAt and per-provider status; catalog.refresh asks the providers again and probes enabled ACP providers. ACP providers (library providers/<id>.json) add rows acp:<id> and acp:<id>/<model> with runtime, provider, source, enabled and status, and a providers key acp:<id> whose status is unprobed, ok or failed; alpd sends catalog.updated to every helloed connection when the catalog changes."
|
|
53
53
|
},
|
|
54
54
|
"methods": {
|
|
55
55
|
"assignment.recall": {
|
|
@@ -1471,6 +1471,9 @@
|
|
|
1471
1471
|
"minLength": 1,
|
|
1472
1472
|
"maxLength": 8000,
|
|
1473
1473
|
"pattern": "\\S"
|
|
1474
|
+
},
|
|
1475
|
+
"keepsSession": {
|
|
1476
|
+
"type": "boolean"
|
|
1474
1477
|
}
|
|
1475
1478
|
},
|
|
1476
1479
|
"required": [
|
|
@@ -8921,6 +8924,9 @@
|
|
|
8921
8924
|
},
|
|
8922
8925
|
"lastError": {
|
|
8923
8926
|
"$ref": "#/$defs/scheduleError"
|
|
8927
|
+
},
|
|
8928
|
+
"keepsSession": {
|
|
8929
|
+
"const": false
|
|
8924
8930
|
}
|
|
8925
8931
|
},
|
|
8926
8932
|
"required": [
|