@airterm/protocol 0.4.0 → 0.6.0
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/README.md +22 -2
- package/dist/acp-agents.d.ts +66 -0
- package/dist/acp-agents.d.ts.map +1 -0
- package/dist/acp-agents.js +141 -0
- package/dist/acp-agents.js.map +1 -0
- package/dist/acp-middleware.d.ts +426 -0
- package/dist/acp-middleware.d.ts.map +1 -0
- package/dist/acp-middleware.js +626 -0
- package/dist/acp-middleware.js.map +1 -0
- package/dist/framing.d.ts +24 -1
- package/dist/framing.d.ts.map +1 -1
- package/dist/framing.js +23 -0
- package/dist/framing.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +131 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +272 -0
- package/dist/messages.js.map +1 -1
- package/dist/relay-usage.d.ts.map +1 -1
- package/dist/relay-usage.js +4 -1
- package/dist/relay-usage.js.map +1 -1
- package/dist/sharing.d.ts +42 -0
- package/dist/sharing.d.ts.map +1 -0
- package/dist/sharing.js +87 -0
- package/dist/sharing.js.map +1 -0
- package/dist/shellIntegration.d.ts +116 -0
- package/dist/shellIntegration.d.ts.map +1 -0
- package/dist/shellIntegration.js +243 -0
- package/dist/shellIntegration.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,25 @@ the public APIs from the package root.
|
|
|
21
21
|
import { deriveCapabilityKeys, NoiseTransport } from '@airterm/protocol';
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
## ACP middleware
|
|
25
|
+
|
|
26
|
+
The additive `acp-middleware-v4` feature carries a bounded canonical ACP model
|
|
27
|
+
between the CLI and browser. `AcpCommand` frames contain only validated user
|
|
28
|
+
actions; `AcpEvent` frames contain reducer mutations, snapshots, and bounded
|
|
29
|
+
catalog results. Raw provider JSON-RPC, request identifiers, extension fields,
|
|
30
|
+
and tool payloads are intentionally outside this browser-facing contract.
|
|
31
|
+
Snapshots are committed atomically after their declared SHA-256 digest
|
|
32
|
+
(computed over canonical key-sorted JSON serialization via `canonicalJsonStringify`)
|
|
33
|
+
and mutation counts validate. Terminal framing remains protocol version 1. The
|
|
34
|
+
reserved raw ACP frame (28) is rejected; there is no raw browser fallback.
|
|
35
|
+
|
|
36
|
+
Version 4 adds identified plans: `plan-upsert` and `plan-remove` mutations over a
|
|
37
|
+
canonical plan that is an item checklist, bounded markdown, or an opaque file
|
|
38
|
+
reference. Each part is bounded in bytes and in count, and a plan that exceeds a
|
|
39
|
+
bound is truncated by its producer with an explicit marker, because the codec
|
|
40
|
+
refuses an oversized plan rather than trimming it. There is no v3 compatibility
|
|
41
|
+
path: the browser and the CLI are released together.
|
|
42
|
+
|
|
24
43
|
Requires Node.js 22.12 or newer for Node-based consumers. Browser consumers need
|
|
25
44
|
Web Crypto and WebAssembly support.
|
|
26
45
|
|
|
@@ -48,10 +67,11 @@ Output acknowledgements refer to contiguous PTY byte offsets consumed by the
|
|
|
48
67
|
terminal renderer, not merely received by the socket. Never acknowledge across
|
|
49
68
|
a gap, reuse a cipher after failure, or replay uncertain terminal input.
|
|
50
69
|
|
|
51
|
-
## Account encryption envelopes
|
|
70
|
+
## Account encryption envelopes
|
|
52
71
|
|
|
53
72
|
The vault and pairing exports are additive application envelopes; terminal protocol v1 framing is unchanged. Vaults use RSA-OAEP-3072/SHA-256, AES-256-GCM, and context-bound HKDF. Version 1 fixes passphrase Argon2id parameters at 64 MiB, three iterations, one lane, 16-byte salt, and 32-byte output; browser derivation lives in the application worker. Unknown fields, algorithms, versions, sizes, or substituted account/session context must fail closed.
|
|
54
73
|
|
|
55
74
|
Exactly one primary vault wrapper and one user-held recovery wrapper are supported. The pairing encryption secret is distinct from the polling credential and never reaches the server. These primitives do not authenticate a downloaded browser application or provide an independent cryptographic audit.
|
|
56
75
|
|
|
57
|
-
|
|
76
|
+
Publish `@airterm/protocol` before any CLI release that depends on it; the CLI
|
|
77
|
+
package pins an exact protocol version.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent identity and capability normalisation.
|
|
3
|
+
*
|
|
4
|
+
* ACP capability payloads are shaped by each agent, and they differ in practice:
|
|
5
|
+
* opencode, Codex, and pi each advertise a different subset, and some add keys
|
|
6
|
+
* of their own. Clients should not read those payloads feature by feature, so
|
|
7
|
+
* everything an agent says is reduced here to one shape that both the CLI and
|
|
8
|
+
* the browser agree on. Unknown keys are ignored, never rejected, because an
|
|
9
|
+
* agent adding one is not an error.
|
|
10
|
+
*/
|
|
11
|
+
export interface AcpAgentCapabilities {
|
|
12
|
+
/** Can enumerate its own chats (`session/list`). */
|
|
13
|
+
listChats?: boolean;
|
|
14
|
+
loadSession?: boolean;
|
|
15
|
+
resume?: boolean;
|
|
16
|
+
fork?: boolean;
|
|
17
|
+
close?: boolean;
|
|
18
|
+
delete?: boolean;
|
|
19
|
+
images?: boolean;
|
|
20
|
+
audio?: boolean;
|
|
21
|
+
embeddedContext?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* An ACP agent a CLI can start.
|
|
25
|
+
*
|
|
26
|
+
* Browsers choose an agent by id and never by command: ids resolve against the
|
|
27
|
+
* CLI's own registry, so a request can never name a program to run.
|
|
28
|
+
*/
|
|
29
|
+
export interface AcpAgentDescription {
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
available: boolean;
|
|
33
|
+
/** Starting it may fetch an adapter, so the first launch can be slow. */
|
|
34
|
+
slowStart?: boolean;
|
|
35
|
+
/** Preview support: the agent is usable but not yet a settled integration. */
|
|
36
|
+
beta?: boolean;
|
|
37
|
+
/** Absent until the agent has been asked what it supports. */
|
|
38
|
+
capabilities?: AcpAgentCapabilities;
|
|
39
|
+
}
|
|
40
|
+
export declare const ACP_AGENT_LIMIT = 32;
|
|
41
|
+
export declare const ACP_AGENT_LABEL_LIMIT = 96;
|
|
42
|
+
/**
|
|
43
|
+
* Reduces an `initialize` response's `agentCapabilities` to what this client
|
|
44
|
+
* understands.
|
|
45
|
+
*
|
|
46
|
+
* A session capability is advertised by the presence of an entry (an empty
|
|
47
|
+
* object means supported, `null` means not), while `loadSession` is a plain
|
|
48
|
+
* boolean - so each is read the way the protocol defines it rather than by
|
|
49
|
+
* truthiness of the whole object.
|
|
50
|
+
*/
|
|
51
|
+
export declare function readAgentCapabilities(value: unknown): AcpAgentCapabilities;
|
|
52
|
+
/** Whether an agent id is one this protocol allows on the wire. */
|
|
53
|
+
export declare function isAcpAgentId(value: unknown): value is string;
|
|
54
|
+
/** A display label an agent may have chosen, bounded and free of control characters. */
|
|
55
|
+
export declare function readAgentLabel(value: unknown): string | undefined;
|
|
56
|
+
export declare function encodeAgentCapabilities(capabilities: AcpAgentCapabilities): Record<string, boolean>;
|
|
57
|
+
export declare function decodeAgentCapabilities(value: unknown): AcpAgentCapabilities | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Reads the agent list from a session description.
|
|
60
|
+
*
|
|
61
|
+
* An unusable entry is dropped rather than thrown: one bad agent must not cost
|
|
62
|
+
* the browser the whole description. `undefined` means the CLI predates the
|
|
63
|
+
* field, which is different from an empty list.
|
|
64
|
+
*/
|
|
65
|
+
export declare function decodeAcpAgents(value: unknown): AcpAgentDescription[] | undefined;
|
|
66
|
+
//# sourceMappingURL=acp-agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-agents.d.ts","sourceRoot":"","sources":["../src/acp-agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,oBAAoB;IACjC,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,8DAA8D;IAC9D,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACvC;AAED,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAKxC;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAuB1E;AAOD,mEAAmE;AACnE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE5D;AAED,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAgBjE;AAED,wBAAgB,uBAAuB,CACnC,YAAY,EAAE,oBAAoB,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB;AAED,wBAAgB,uBAAuB,CACnC,KAAK,EAAE,OAAO,GACf,oBAAoB,GAAG,SAAS,CAkBlC;AAMD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,EAAE,GAAG,SAAS,CAqCjF"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent identity and capability normalisation.
|
|
3
|
+
*
|
|
4
|
+
* ACP capability payloads are shaped by each agent, and they differ in practice:
|
|
5
|
+
* opencode, Codex, and pi each advertise a different subset, and some add keys
|
|
6
|
+
* of their own. Clients should not read those payloads feature by feature, so
|
|
7
|
+
* everything an agent says is reduced here to one shape that both the CLI and
|
|
8
|
+
* the browser agree on. Unknown keys are ignored, never rejected, because an
|
|
9
|
+
* agent adding one is not an error.
|
|
10
|
+
*/
|
|
11
|
+
export const ACP_AGENT_LIMIT = 32;
|
|
12
|
+
export const ACP_AGENT_LABEL_LIMIT = 96;
|
|
13
|
+
const AGENT_ID = /^[a-z][a-z0-9-]{0,63}$/;
|
|
14
|
+
const CONTROL_CHARACTERS = /[\p{Cc}\p{Cf}]/u;
|
|
15
|
+
/**
|
|
16
|
+
* Reduces an `initialize` response's `agentCapabilities` to what this client
|
|
17
|
+
* understands.
|
|
18
|
+
*
|
|
19
|
+
* A session capability is advertised by the presence of an entry (an empty
|
|
20
|
+
* object means supported, `null` means not), while `loadSession` is a plain
|
|
21
|
+
* boolean - so each is read the way the protocol defines it rather than by
|
|
22
|
+
* truthiness of the whole object.
|
|
23
|
+
*/
|
|
24
|
+
export function readAgentCapabilities(value) {
|
|
25
|
+
if (!isRecord(value)) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
const session = isRecord(value.sessionCapabilities)
|
|
29
|
+
? value.sessionCapabilities
|
|
30
|
+
: {};
|
|
31
|
+
const prompt = isRecord(value.promptCapabilities)
|
|
32
|
+
? value.promptCapabilities
|
|
33
|
+
: {};
|
|
34
|
+
return {
|
|
35
|
+
...(value.loadSession === true ? { loadSession: true } : {}),
|
|
36
|
+
...(isAdvertised(session.list) ? { listChats: true } : {}),
|
|
37
|
+
...(isAdvertised(session.resume) ? { resume: true } : {}),
|
|
38
|
+
...(isAdvertised(session.fork) ? { fork: true } : {}),
|
|
39
|
+
...(isAdvertised(session.close) ? { close: true } : {}),
|
|
40
|
+
...(isAdvertised(session.delete) ? { delete: true } : {}),
|
|
41
|
+
...(prompt.image === true ? { images: true } : {}),
|
|
42
|
+
...(prompt.audio === true ? { audio: true } : {}),
|
|
43
|
+
...(prompt.embeddedContext === true ? { embeddedContext: true } : {}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** An advertised session capability is a capability object, or absent/null. */
|
|
47
|
+
function isAdvertised(value) {
|
|
48
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
49
|
+
}
|
|
50
|
+
/** Whether an agent id is one this protocol allows on the wire. */
|
|
51
|
+
export function isAcpAgentId(value) {
|
|
52
|
+
return typeof value === 'string' && AGENT_ID.test(value);
|
|
53
|
+
}
|
|
54
|
+
/** A display label an agent may have chosen, bounded and free of control characters. */
|
|
55
|
+
export function readAgentLabel(value) {
|
|
56
|
+
if (typeof value !== 'string') {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const label = value.trim();
|
|
60
|
+
if (label.length === 0 ||
|
|
61
|
+
label.length > ACP_AGENT_LABEL_LIMIT ||
|
|
62
|
+
CONTROL_CHARACTERS.test(label)) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
return label;
|
|
66
|
+
}
|
|
67
|
+
export function encodeAgentCapabilities(capabilities) {
|
|
68
|
+
return {
|
|
69
|
+
...(capabilities.listChats === true ? { list_chats: true } : {}),
|
|
70
|
+
...(capabilities.loadSession === true ? { load_session: true } : {}),
|
|
71
|
+
...(capabilities.resume === true ? { resume: true } : {}),
|
|
72
|
+
...(capabilities.fork === true ? { fork: true } : {}),
|
|
73
|
+
...(capabilities.close === true ? { close: true } : {}),
|
|
74
|
+
...(capabilities.delete === true ? { delete: true } : {}),
|
|
75
|
+
...(capabilities.images === true ? { images: true } : {}),
|
|
76
|
+
...(capabilities.audio === true ? { audio: true } : {}),
|
|
77
|
+
...(capabilities.embeddedContext === true ? { embedded_context: true } : {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function decodeAgentCapabilities(value) {
|
|
81
|
+
if (!isRecord(value)) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
...(hasCapability(value.list_chats) || hasCapability(value.listChats) ? { listChats: true } : {}),
|
|
86
|
+
...(hasCapability(value.load_session) || hasCapability(value.loadSession) ? { loadSession: true } : {}),
|
|
87
|
+
...(hasCapability(value.resume) ? { resume: true } : {}),
|
|
88
|
+
...(hasCapability(value.fork) ? { fork: true } : {}),
|
|
89
|
+
...(hasCapability(value.close) ? { close: true } : {}),
|
|
90
|
+
...(hasCapability(value.delete) ? { delete: true } : {}),
|
|
91
|
+
...(hasCapability(value.images) ? { images: true } : {}),
|
|
92
|
+
...(hasCapability(value.audio) ? { audio: true } : {}),
|
|
93
|
+
...(hasCapability(value.embedded_context) || hasCapability(value.embeddedContext)
|
|
94
|
+
? { embeddedContext: true }
|
|
95
|
+
: {}),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function hasCapability(value) {
|
|
99
|
+
return value === true || (typeof value === 'object' && value !== null && !Array.isArray(value));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Reads the agent list from a session description.
|
|
103
|
+
*
|
|
104
|
+
* An unusable entry is dropped rather than thrown: one bad agent must not cost
|
|
105
|
+
* the browser the whole description. `undefined` means the CLI predates the
|
|
106
|
+
* field, which is different from an empty list.
|
|
107
|
+
*/
|
|
108
|
+
export function decodeAcpAgents(value) {
|
|
109
|
+
if (value === undefined) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
if (!Array.isArray(value)) {
|
|
113
|
+
throw new Error('Invalid agent list payload.');
|
|
114
|
+
}
|
|
115
|
+
const agents = [];
|
|
116
|
+
for (const entry of value.slice(0, ACP_AGENT_LIMIT)) {
|
|
117
|
+
if (!isRecord(entry) || !isAcpAgentId(entry.id)) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const label = readAgentLabel(entry.label);
|
|
121
|
+
if (label === undefined) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const capabilities = entry.capabilities === undefined
|
|
125
|
+
? undefined
|
|
126
|
+
: decodeAgentCapabilities(entry.capabilities);
|
|
127
|
+
agents.push({
|
|
128
|
+
id: entry.id,
|
|
129
|
+
label,
|
|
130
|
+
available: entry.available === true,
|
|
131
|
+
...(entry.slow_start === true ? { slowStart: true } : {}),
|
|
132
|
+
...(entry.beta === true ? { beta: true } : {}),
|
|
133
|
+
...(capabilities === undefined ? {} : { capabilities }),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return agents;
|
|
137
|
+
}
|
|
138
|
+
function isRecord(value) {
|
|
139
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=acp-agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-agents.js","sourceRoot":"","sources":["../src/acp-agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiCH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AAC1C,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAChD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,mBAAmB,CAAC;QAC/C,CAAC,CAAC,KAAK,CAAC,mBAAmB;QAC3B,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,kBAAkB,CAAC;QAC7C,CAAC,CAAC,KAAK,CAAC,kBAAkB;QAC1B,CAAC,CAAC,EAAE,CAAC;IAET,OAAO;QACH,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,EA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AC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
/** Provider-neutral ACP messages exchanged across AirTerm's encrypted transport. */
|
|
2
|
+
export declare const ACP_MIDDLEWARE_VERSION: 4;
|
|
3
|
+
export declare const ACP_MIDDLEWARE_FEATURE: "acp-middleware-v4";
|
|
4
|
+
export declare const ACP_MIDDLEWARE_MAX_COMMAND_BYTES: number;
|
|
5
|
+
export declare const ACP_MIDDLEWARE_MAX_EVENT_BYTES: number;
|
|
6
|
+
export declare const ACP_MIDDLEWARE_MAX_MUTATIONS = 64;
|
|
7
|
+
export declare const ACP_MIDDLEWARE_MAX_SNAPSHOT_BYTES: number;
|
|
8
|
+
export declare const ACP_MIDDLEWARE_MAX_SNAPSHOT_CHUNKS = 128;
|
|
9
|
+
export declare const ACP_MIDDLEWARE_MAX_SNAPSHOT_MUTATIONS = 4096;
|
|
10
|
+
export declare const ACP_MIDDLEWARE_MAX_TEXT_BYTES: number;
|
|
11
|
+
/** How many attachment paths one prompt may carry. */
|
|
12
|
+
export declare const ACP_MIDDLEWARE_MAX_PROMPT_FILES: 10;
|
|
13
|
+
/** A path is a host path, bounded the same way every other one is. */
|
|
14
|
+
export declare const ACP_MIDDLEWARE_MAX_PATH_BYTES = 4096;
|
|
15
|
+
export declare const ACP_MIDDLEWARE_MAX_TURNS = 50;
|
|
16
|
+
export declare const ACP_MIDDLEWARE_MAX_HISTORY_BYTES: number;
|
|
17
|
+
export declare const ACP_MIDDLEWARE_MAX_ACTIVE_TURN_BYTES: number;
|
|
18
|
+
export declare const ACP_MIDDLEWARE_MAX_PENDING_REQUESTS = 16;
|
|
19
|
+
export declare const ACP_MIDDLEWARE_MAX_PENDING_BYTES: number;
|
|
20
|
+
export declare const ACP_MIDDLEWARE_MAX_REASONING_BYTES: number;
|
|
21
|
+
export declare const ACP_MIDDLEWARE_MAX_CONFIG_OPTIONS: 64;
|
|
22
|
+
export declare const ACP_MIDDLEWARE_MAX_CONFIG_CHOICES: 255;
|
|
23
|
+
export declare const ACP_MIDDLEWARE_MAX_COMMANDS: 128;
|
|
24
|
+
export declare const ACP_MIDDLEWARE_MAX_COMMAND_NAME_BYTES = 128;
|
|
25
|
+
export declare const ACP_MIDDLEWARE_MAX_COMMAND_DESCRIPTION_BYTES = 256;
|
|
26
|
+
export declare const ACP_MIDDLEWARE_MAX_COMMAND_HINT_BYTES = 128;
|
|
27
|
+
/**
|
|
28
|
+
* Bounds on an agent's plan.
|
|
29
|
+
*
|
|
30
|
+
* A plan is display-only content an agent may rewrite as often as it likes, so
|
|
31
|
+
* every part of it is bounded here rather than at the point a pane happens to
|
|
32
|
+
* render it: the identifier an update is correlated by, how many entries an item
|
|
33
|
+
* plan may show, how long each entry may be, and how much markdown a markdown
|
|
34
|
+
* plan may carry. A plan that exceeds a bound is truncated by its producer with a
|
|
35
|
+
* marker saying so, never silently cut.
|
|
36
|
+
*/
|
|
37
|
+
export declare const ACP_MIDDLEWARE_MAX_PLAN_ID_BYTES = 128;
|
|
38
|
+
export declare const ACP_MIDDLEWARE_MAX_PLAN_ITEMS = 32;
|
|
39
|
+
export declare const ACP_MIDDLEWARE_MAX_PLAN_ITEM_BYTES = 512;
|
|
40
|
+
export declare const ACP_MIDDLEWARE_MAX_PLAN_MARKDOWN_BYTES: number;
|
|
41
|
+
/** How many plans one turn may carry at once, newest kept. */
|
|
42
|
+
export declare const ACP_MIDDLEWARE_MAX_PLANS_PER_TURN = 8;
|
|
43
|
+
export type AcpCanonicalPhase = 'starting' | 'loading' | 'ready' | 'error' | 'closed';
|
|
44
|
+
export interface AcpCanonicalCapabilities {
|
|
45
|
+
resume: boolean;
|
|
46
|
+
load: boolean;
|
|
47
|
+
cancel: boolean;
|
|
48
|
+
configuration: boolean;
|
|
49
|
+
permissions: boolean;
|
|
50
|
+
elicitation: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface AcpCanonicalConfigOption {
|
|
53
|
+
id: string;
|
|
54
|
+
category?: string;
|
|
55
|
+
type?: string;
|
|
56
|
+
currentValue?: string;
|
|
57
|
+
options?: Array<{
|
|
58
|
+
value: string;
|
|
59
|
+
label?: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A command a provider advertises for its slash picker.
|
|
64
|
+
*
|
|
65
|
+
* ACP requires every command to carry a description, so the provider's
|
|
66
|
+
* `input.hint` becomes the only optional field and an entry without a
|
|
67
|
+
* description is malformed rather than a blank row.
|
|
68
|
+
*/
|
|
69
|
+
export interface AcpCanonicalCommand {
|
|
70
|
+
name: string;
|
|
71
|
+
description: string;
|
|
72
|
+
inputHint?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface AcpCanonicalTool {
|
|
75
|
+
id: string;
|
|
76
|
+
title: string;
|
|
77
|
+
kind?: string;
|
|
78
|
+
status: 'pending' | 'in_progress' | 'completed' | 'failed' | 'cancelled';
|
|
79
|
+
detail?: string;
|
|
80
|
+
failureReason?: string;
|
|
81
|
+
locations?: string[];
|
|
82
|
+
}
|
|
83
|
+
export interface AcpCanonicalMessage {
|
|
84
|
+
id: string;
|
|
85
|
+
role: 'assistant' | 'thought';
|
|
86
|
+
text: string;
|
|
87
|
+
}
|
|
88
|
+
export type AcpCanonicalTurnItem = {
|
|
89
|
+
kind: 'message';
|
|
90
|
+
id: string;
|
|
91
|
+
role: 'assistant' | 'thought';
|
|
92
|
+
text: string;
|
|
93
|
+
} | {
|
|
94
|
+
kind: 'tool';
|
|
95
|
+
tool: AcpCanonicalTool;
|
|
96
|
+
} | {
|
|
97
|
+
kind: 'omission';
|
|
98
|
+
id: string;
|
|
99
|
+
reason: string;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* A plan an agent published, in one of the formats ACP defines.
|
|
103
|
+
*
|
|
104
|
+
* The three variants are deliberately different shapes rather than one shape with
|
|
105
|
+
* optional fields: an item plan is a checklist a pane can summarise progress
|
|
106
|
+
* from, a markdown plan is prose it renders, and a file plan is only a promise
|
|
107
|
+
* that a plan exists somewhere this client cannot reach.
|
|
108
|
+
*/
|
|
109
|
+
export type AcpPlan = {
|
|
110
|
+
id: string;
|
|
111
|
+
type: 'items';
|
|
112
|
+
/** The entries a pane shows, newest state of the plan. */
|
|
113
|
+
entries: AcpPlanItem[];
|
|
114
|
+
/** The count before truncation, present only when entries were cut. */
|
|
115
|
+
totalEntries?: number;
|
|
116
|
+
} | {
|
|
117
|
+
id: string;
|
|
118
|
+
type: 'markdown';
|
|
119
|
+
content: string;
|
|
120
|
+
/** Set when the agent's markdown was longer than this contract allows. */
|
|
121
|
+
truncated?: boolean;
|
|
122
|
+
} | {
|
|
123
|
+
id: string;
|
|
124
|
+
/**
|
|
125
|
+
* Identity only. The host URI an agent sends is deliberately discarded:
|
|
126
|
+
* it names a path on the agent's machine, which this client cannot read
|
|
127
|
+
* and must not pretend to.
|
|
128
|
+
*/
|
|
129
|
+
type: 'file';
|
|
130
|
+
};
|
|
131
|
+
export interface AcpPlanItem {
|
|
132
|
+
content: string;
|
|
133
|
+
/** ACP's own statuses; an unknown one is shown as-is rather than refused. */
|
|
134
|
+
status: string;
|
|
135
|
+
priority?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface AcpCanonicalTurn {
|
|
138
|
+
id: string;
|
|
139
|
+
origin: 'user' | 'agent';
|
|
140
|
+
userText?: string;
|
|
141
|
+
items: AcpCanonicalTurnItem[];
|
|
142
|
+
status: 'active' | 'complete' | 'interrupted';
|
|
143
|
+
stopReason?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Plans this turn published, in the order they were first seen.
|
|
146
|
+
*
|
|
147
|
+
* Held beside `items` rather than in it because a plan is not a step of the
|
|
148
|
+
* transcript: it is replaced in place as the agent revises it, so it has no
|
|
149
|
+
* position in the narration it must keep.
|
|
150
|
+
*/
|
|
151
|
+
plans?: AcpPlan[];
|
|
152
|
+
}
|
|
153
|
+
export interface AcpCanonicalInteraction {
|
|
154
|
+
id: string;
|
|
155
|
+
kind: 'permission' | 'elicitation';
|
|
156
|
+
message: string;
|
|
157
|
+
options?: Array<{
|
|
158
|
+
id: string;
|
|
159
|
+
label: string;
|
|
160
|
+
kind?: string;
|
|
161
|
+
}>;
|
|
162
|
+
schema?: Record<string, unknown>;
|
|
163
|
+
}
|
|
164
|
+
export interface AcpCanonicalNotice {
|
|
165
|
+
id: string;
|
|
166
|
+
level: 'info' | 'warning' | 'error';
|
|
167
|
+
message: string;
|
|
168
|
+
}
|
|
169
|
+
export interface AcpCanonicalState {
|
|
170
|
+
version: typeof ACP_MIDDLEWARE_VERSION;
|
|
171
|
+
phase: AcpCanonicalPhase;
|
|
172
|
+
agent: string;
|
|
173
|
+
sessionId?: string;
|
|
174
|
+
title?: string;
|
|
175
|
+
error?: string;
|
|
176
|
+
capabilities: AcpCanonicalCapabilities;
|
|
177
|
+
configOptions: AcpCanonicalConfigOption[];
|
|
178
|
+
currentModel?: string;
|
|
179
|
+
mode?: string;
|
|
180
|
+
commands: AcpCanonicalCommand[];
|
|
181
|
+
usage?: {
|
|
182
|
+
used: number;
|
|
183
|
+
size: number;
|
|
184
|
+
cost?: number;
|
|
185
|
+
currency?: string;
|
|
186
|
+
};
|
|
187
|
+
historyBoundary?: 'complete' | 'omitted';
|
|
188
|
+
turns: AcpCanonicalTurn[];
|
|
189
|
+
activeTurnId?: string;
|
|
190
|
+
interactions: AcpCanonicalInteraction[];
|
|
191
|
+
notices: AcpCanonicalNotice[];
|
|
192
|
+
}
|
|
193
|
+
export type AcpMutation = {
|
|
194
|
+
type: 'session';
|
|
195
|
+
phase: AcpCanonicalPhase;
|
|
196
|
+
sessionId?: string;
|
|
197
|
+
title?: string;
|
|
198
|
+
error?: string;
|
|
199
|
+
} | {
|
|
200
|
+
type: 'history-boundary';
|
|
201
|
+
boundary: 'complete' | 'omitted';
|
|
202
|
+
} | {
|
|
203
|
+
type: 'turn-start';
|
|
204
|
+
turnId: string;
|
|
205
|
+
origin: 'user' | 'agent';
|
|
206
|
+
userText?: string;
|
|
207
|
+
} | {
|
|
208
|
+
type: 'turn-user-append';
|
|
209
|
+
turnId: string;
|
|
210
|
+
text: string;
|
|
211
|
+
} | {
|
|
212
|
+
type: 'message-append';
|
|
213
|
+
turnId: string;
|
|
214
|
+
messageId: string;
|
|
215
|
+
role: 'assistant' | 'thought';
|
|
216
|
+
text: string;
|
|
217
|
+
} | {
|
|
218
|
+
type: 'tool-upsert';
|
|
219
|
+
turnId: string;
|
|
220
|
+
tool: AcpCanonicalTool;
|
|
221
|
+
} | {
|
|
222
|
+
type: 'omission-append';
|
|
223
|
+
turnId: string;
|
|
224
|
+
omissionId: string;
|
|
225
|
+
reason: string;
|
|
226
|
+
} | {
|
|
227
|
+
type: 'plan-upsert';
|
|
228
|
+
turnId: string;
|
|
229
|
+
plan: AcpPlan;
|
|
230
|
+
} | {
|
|
231
|
+
type: 'plan-remove';
|
|
232
|
+
turnId: string;
|
|
233
|
+
planId: string;
|
|
234
|
+
} | {
|
|
235
|
+
type: 'turn-finish';
|
|
236
|
+
turnId: string;
|
|
237
|
+
status: 'complete' | 'interrupted';
|
|
238
|
+
stopReason?: string;
|
|
239
|
+
} | {
|
|
240
|
+
type: 'config';
|
|
241
|
+
options: AcpCanonicalConfigOption[];
|
|
242
|
+
model?: string;
|
|
243
|
+
} | {
|
|
244
|
+
type: 'mode';
|
|
245
|
+
mode?: string;
|
|
246
|
+
} | {
|
|
247
|
+
type: 'commands';
|
|
248
|
+
commands: AcpCanonicalCommand[];
|
|
249
|
+
} | {
|
|
250
|
+
type: 'usage';
|
|
251
|
+
used: number;
|
|
252
|
+
size: number;
|
|
253
|
+
cost?: number;
|
|
254
|
+
currency?: string;
|
|
255
|
+
} | {
|
|
256
|
+
type: 'interaction-upsert';
|
|
257
|
+
interaction: AcpCanonicalInteraction;
|
|
258
|
+
} | {
|
|
259
|
+
type: 'interaction-remove';
|
|
260
|
+
interactionId: string;
|
|
261
|
+
} | {
|
|
262
|
+
type: 'notice';
|
|
263
|
+
notice: AcpCanonicalNotice;
|
|
264
|
+
} | {
|
|
265
|
+
type: 'notice-remove';
|
|
266
|
+
noticeId: string;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* A file's contents, as the CLI read them.
|
|
270
|
+
*
|
|
271
|
+
* The browser has no filesystem access, so a file reaches it the same way the
|
|
272
|
+
* workspace and session catalogs do - as the answer to a typed command. The
|
|
273
|
+
* count is of the whole file rather than of `content`, which is what lets a
|
|
274
|
+
* truncated read say how much was left behind.
|
|
275
|
+
*/
|
|
276
|
+
export interface AcpFileContent {
|
|
277
|
+
/** The path as resolved on the CLI's machine, for the viewer's header. */
|
|
278
|
+
path: string;
|
|
279
|
+
/** The file's text, empty when the file is binary. */
|
|
280
|
+
content: string;
|
|
281
|
+
/** The file's size in bytes, whether or not all of it was sent. */
|
|
282
|
+
totalBytes: number;
|
|
283
|
+
/** Set when `content` is a prefix of the file. */
|
|
284
|
+
truncated?: boolean;
|
|
285
|
+
/** Set when the file is not text; `content` is then empty. */
|
|
286
|
+
isBinary?: boolean;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* A file's uncommitted changes, as `git diff` reported them.
|
|
290
|
+
*
|
|
291
|
+
* `isGit` separates "no changes" from "cannot tell": a workspace outside any
|
|
292
|
+
* repository is a different statement from a clean one, and the viewer says so
|
|
293
|
+
* rather than showing an empty diff the reader would read as "up to date".
|
|
294
|
+
*/
|
|
295
|
+
export interface AcpFileDiff {
|
|
296
|
+
path: string;
|
|
297
|
+
/** Unified diff text, empty when there are no changes. */
|
|
298
|
+
diff: string;
|
|
299
|
+
/** False when the file is outside a git work tree. */
|
|
300
|
+
isGit: boolean;
|
|
301
|
+
/** True when the file matches HEAD (or is not in git). */
|
|
302
|
+
clean: boolean;
|
|
303
|
+
/** Count of added lines, counted from the diff itself. */
|
|
304
|
+
additions?: number;
|
|
305
|
+
/** Count of removed lines. */
|
|
306
|
+
deletions?: number;
|
|
307
|
+
/** Set when `diff` is a prefix of the whole change. */
|
|
308
|
+
truncated?: boolean;
|
|
309
|
+
}
|
|
310
|
+
export type AcpCommand = {
|
|
311
|
+
kind: 'sync';
|
|
312
|
+
epoch?: string;
|
|
313
|
+
afterSequence?: number;
|
|
314
|
+
} | {
|
|
315
|
+
kind: 'prompt';
|
|
316
|
+
text: string;
|
|
317
|
+
files?: string[];
|
|
318
|
+
} | {
|
|
319
|
+
kind: 'cancel';
|
|
320
|
+
} | {
|
|
321
|
+
kind: 'set-config';
|
|
322
|
+
id: string;
|
|
323
|
+
value: string;
|
|
324
|
+
} | {
|
|
325
|
+
kind: 'respond-interaction';
|
|
326
|
+
interactionId: string;
|
|
327
|
+
action: 'accept' | 'decline' | 'cancel';
|
|
328
|
+
values?: Record<string, unknown>;
|
|
329
|
+
} | {
|
|
330
|
+
kind: 'history';
|
|
331
|
+
action: 'retry' | 'continue';
|
|
332
|
+
} | {
|
|
333
|
+
kind: 'catalog-workspaces';
|
|
334
|
+
agent: string;
|
|
335
|
+
} | {
|
|
336
|
+
kind: 'catalog-sessions';
|
|
337
|
+
agent: string;
|
|
338
|
+
cwd: string;
|
|
339
|
+
} | {
|
|
340
|
+
kind: 'catalog-directories';
|
|
341
|
+
path?: string;
|
|
342
|
+
} | {
|
|
343
|
+
kind: 'read-file';
|
|
344
|
+
path: string;
|
|
345
|
+
cwd?: string;
|
|
346
|
+
} | {
|
|
347
|
+
kind: 'file-diff';
|
|
348
|
+
path: string;
|
|
349
|
+
cwd?: string;
|
|
350
|
+
};
|
|
351
|
+
export interface AcpCommandEnvelope {
|
|
352
|
+
version: typeof ACP_MIDDLEWARE_VERSION;
|
|
353
|
+
type: 'command';
|
|
354
|
+
commandId: string;
|
|
355
|
+
command: AcpCommand;
|
|
356
|
+
}
|
|
357
|
+
export type AcpEventEnvelope = {
|
|
358
|
+
version: typeof ACP_MIDDLEWARE_VERSION;
|
|
359
|
+
type: 'delta';
|
|
360
|
+
epoch: string;
|
|
361
|
+
firstSequence: number;
|
|
362
|
+
mutations: AcpMutation[];
|
|
363
|
+
} | {
|
|
364
|
+
version: typeof ACP_MIDDLEWARE_VERSION;
|
|
365
|
+
type: 'snapshot-start';
|
|
366
|
+
snapshotId: string;
|
|
367
|
+
epoch: string;
|
|
368
|
+
throughSequence: number;
|
|
369
|
+
chunkCount: number;
|
|
370
|
+
mutationCount: number;
|
|
371
|
+
digest: string;
|
|
372
|
+
} | {
|
|
373
|
+
version: typeof ACP_MIDDLEWARE_VERSION;
|
|
374
|
+
type: 'snapshot-chunk';
|
|
375
|
+
snapshotId: string;
|
|
376
|
+
index: number;
|
|
377
|
+
mutations: AcpMutation[];
|
|
378
|
+
} | {
|
|
379
|
+
version: typeof ACP_MIDDLEWARE_VERSION;
|
|
380
|
+
type: 'snapshot-complete';
|
|
381
|
+
snapshotId: string;
|
|
382
|
+
chunkCount: number;
|
|
383
|
+
mutationCount: number;
|
|
384
|
+
} | {
|
|
385
|
+
version: typeof ACP_MIDDLEWARE_VERSION;
|
|
386
|
+
type: 'command-result';
|
|
387
|
+
commandId: string;
|
|
388
|
+
accepted: boolean;
|
|
389
|
+
error?: string;
|
|
390
|
+
} | {
|
|
391
|
+
version: typeof ACP_MIDDLEWARE_VERSION;
|
|
392
|
+
type: 'catalog-result';
|
|
393
|
+
commandId: string;
|
|
394
|
+
value: unknown;
|
|
395
|
+
};
|
|
396
|
+
export declare function createAcpCanonicalState(agent?: string, capabilities?: Partial<AcpCanonicalCapabilities>): AcpCanonicalState;
|
|
397
|
+
export declare function isAcpGenerating(state: AcpCanonicalState): boolean;
|
|
398
|
+
/** Pure reducer used by the CLI authority and the browser projection. */
|
|
399
|
+
export declare function reduceAcpCanonicalState(state: AcpCanonicalState, mutation: AcpMutation): AcpCanonicalState;
|
|
400
|
+
/**
|
|
401
|
+
* Cuts text to a byte budget without splitting a character.
|
|
402
|
+
*
|
|
403
|
+
* Every bound in this file is a UTF-8 byte count, but a JavaScript `slice`
|
|
404
|
+
* counts UTF-16 code units - so a producer that truncated by character count
|
|
405
|
+
* could emit a title or a message whose bytes exceed the bound the decoder
|
|
406
|
+
* enforces. The decoder would then reject the whole mutation, and because a
|
|
407
|
+
* mutation is validated as a unit, one over-long field would take the entire
|
|
408
|
+
* state restore with it. Truncating by bytes is what keeps a producer's own
|
|
409
|
+
* bound and the decoder's bound the same number.
|
|
410
|
+
*/
|
|
411
|
+
export declare function truncateUtf8(text: string, maximum: number): string;
|
|
412
|
+
/** Reads text a byte-bounded field can hold, or nothing when it holds none. */
|
|
413
|
+
export declare function boundedUtf8Text(value: unknown, maximum: number): string | undefined;
|
|
414
|
+
export declare function encodeAcpCommand(commandIdValue: string, command: AcpCommand): Uint8Array;
|
|
415
|
+
export declare function decodeAcpCommand(payload: Uint8Array): AcpCommandEnvelope;
|
|
416
|
+
export declare function encodeAcpEvent(event: AcpEventEnvelope): Uint8Array;
|
|
417
|
+
export declare function decodeAcpEvent(payload: Uint8Array): AcpEventEnvelope;
|
|
418
|
+
/**
|
|
419
|
+
* Deterministic JSON serialization where object keys are recursively sorted.
|
|
420
|
+
*
|
|
421
|
+
* Arrays preserve their order; primitive values, null, and booleans match
|
|
422
|
+
* standard JSON.stringify; object keys whose values are undefined, functions,
|
|
423
|
+
* or symbols are omitted, matching standard JSON object serialization.
|
|
424
|
+
*/
|
|
425
|
+
export declare function canonicalJsonStringify(value: unknown): string;
|
|
426
|
+
//# sourceMappingURL=acp-middleware.d.ts.map
|