@agen-ai/acp-transport 0.0.0-stage → 0.4.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/LICENSE +21 -0
- package/README.md +227 -2
- package/dist/client.d.ts +5 -0
- package/dist/client.js +475 -0
- package/dist/clientContracts.d.ts +68 -0
- package/dist/clientContracts.js +0 -0
- package/dist/clientState.d.ts +31 -0
- package/dist/clientState.js +34 -0
- package/dist/diagnostics.d.ts +7 -0
- package/dist/diagnostics.js +29 -0
- package/dist/errors.d.ts +24 -0
- package/dist/errors.js +53 -0
- package/dist/extensions.d.ts +16 -0
- package/dist/extensions.js +42 -0
- package/dist/generated/protocolMetadata.d.ts +246 -0
- package/dist/generated/protocolMetadata.js +313 -0
- package/dist/generated/schemaV1_23_0Metadata.d.ts +122 -0
- package/dist/generated/schemaV1_23_0Metadata.js +159 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +13 -0
- package/dist/json.d.ts +10 -0
- package/dist/json.js +62 -0
- package/dist/limits.d.ts +22 -0
- package/dist/limits.js +62 -0
- package/dist/lineFramer.d.ts +13 -0
- package/dist/lineFramer.js +83 -0
- package/dist/messageWriter.d.ts +12 -0
- package/dist/messageWriter.js +134 -0
- package/dist/protocol.d.ts +33 -0
- package/dist/protocol.js +72 -0
- package/dist/schema.d.ts +13 -0
- package/dist/schema.js +113 -0
- package/dist/standardSessionOperations.d.ts +139 -0
- package/dist/standardSessionOperations.js +36 -0
- package/package.json +70 -3
- package/schema/schema-v1.23.0/LICENSE +190 -0
- package/schema/schema-v1.23.0/meta.json +34 -0
- package/schema/schema-v1.23.0/protocol.generated.json +148 -0
- package/schema/schema-v1.23.0/provenance.json +38 -0
- package/schema/schema-v1.23.0/schema.json +5855 -0
- package/schema/v0.11.4/LICENSE +190 -0
- package/schema/v0.11.4/meta.json +25 -0
- package/schema/v0.11.4/meta.unstable.json +45 -0
- package/schema/v0.11.4/protocol.generated.json +301 -0
- package/schema/v0.11.4/provenance.json +39 -0
- package/schema/v0.11.4/schema.json +3597 -0
- package/schema/v0.11.4/schema.unstable.json +6970 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Trevor Nichols
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,228 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @agen-ai/acp-transport
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bounded Agent Client Protocol (ACP) JSON-RPC transport for Node.js 22 and newer.
|
|
4
|
+
This optional AgenAI Agent SDK package connects a host to streams supplied by the
|
|
5
|
+
host. It validates messages against packaged, hash-pinned ACP schemas and owns
|
|
6
|
+
framing, correlation, reverse requests, deadlines and connection cleanup.
|
|
7
|
+
|
|
8
|
+
The coordinated SDK version is `0.4.0`. The package is ESM, MIT
|
|
9
|
+
licensed and side-effect-free on import, with exact Ajv `8.17.1` as its sole runtime
|
|
10
|
+
dependency. It is independent of the provider-neutral `@agen-ai/agent-protocol`
|
|
11
|
+
and `@agen-ai/agent-runtime` packages.
|
|
12
|
+
|
|
13
|
+
## Connect existing streams
|
|
14
|
+
|
|
15
|
+
The host supplies the agent's stdin, stdout and optional stderr streams. Process
|
|
16
|
+
creation, filesystem access, terminal execution, credentials and containment are
|
|
17
|
+
host responsibilities. Register only the reverse methods that the host supports,
|
|
18
|
+
and advertise those capabilities during initialization.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import {
|
|
22
|
+
createAcpClient,
|
|
23
|
+
createAcpStandardSessionOperations,
|
|
24
|
+
} from '@agen-ai/acp-transport/client';
|
|
25
|
+
|
|
26
|
+
const client = createAcpClient({
|
|
27
|
+
stdin: agentInput,
|
|
28
|
+
stdout: agentOutput,
|
|
29
|
+
stderr: agentDiagnostics,
|
|
30
|
+
schemaChannel: 'stable',
|
|
31
|
+
schemaProfile: 'schema-v1.23.0',
|
|
32
|
+
disposeTransport: closeOwnedConnection,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const operations = createAcpStandardSessionOperations(client);
|
|
37
|
+
const initialization = await operations.initialize({
|
|
38
|
+
protocolVersion: 1,
|
|
39
|
+
clientInfo: { name: 'my-host', version: '1.0.0' },
|
|
40
|
+
clientCapabilities: {},
|
|
41
|
+
}, { timeoutMs: 10_000 });
|
|
42
|
+
|
|
43
|
+
// Inspect the negotiated capabilities before selecting optional operations.
|
|
44
|
+
const session = await operations.newSession({
|
|
45
|
+
cwd: projectDirectory,
|
|
46
|
+
mcpServers: [],
|
|
47
|
+
}, { timeoutMs: 10_000 });
|
|
48
|
+
} finally {
|
|
49
|
+
await client.dispose();
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The root entrypoint additionally exports JSON/message parsers, schema validation,
|
|
54
|
+
bounded protocol limits, typed errors and explicit extension registration.
|
|
55
|
+
`./client` exports the client contracts and typed standard session invocations.
|
|
56
|
+
No internal file path is a supported import.
|
|
57
|
+
|
|
58
|
+
Transport errors and validated remote JSON-RPC errors retain their ACP meanings. Provider adapters
|
|
59
|
+
own translation into Agent Protocol V10 failures and any provider-owned retry observation; the
|
|
60
|
+
transport has no dependency on that protocol and grants no turn replay or quota authority.
|
|
61
|
+
|
|
62
|
+
An adapter migrating from a private transport import should use these public
|
|
63
|
+
entrypoints and retain its explicit schema selection. There is no compatibility
|
|
64
|
+
re-export for private import specifiers. Using the modern schema requires its own
|
|
65
|
+
negotiation and semantic mapping; renaming an import does not enable capabilities.
|
|
66
|
+
|
|
67
|
+
Notification and reverse-request handlers begin synchronously in received frame
|
|
68
|
+
order. Their returned promises settle independently, so a pending permission or
|
|
69
|
+
slow output consumer does not block correlated responses or cancellation. Hosts
|
|
70
|
+
must reserve bounded queue capacity during handler admission and retain that
|
|
71
|
+
reservation until processing completes.
|
|
72
|
+
|
|
73
|
+
Request deadlines and bounded shutdown drains keep Node's event loop alive until
|
|
74
|
+
the operation settles, including when the supplied streams have no active I/O
|
|
75
|
+
handles. Settlement clears the operation's timer. Always await `client.dispose()`
|
|
76
|
+
when the connection is no longer needed to reject pending requests and complete
|
|
77
|
+
bounded cleanup before releasing the owned transport.
|
|
78
|
+
|
|
79
|
+
Disposal stops new writes and rejects pending write promises promptly. An already-entered Node
|
|
80
|
+
write can settle afterward; the writer retains error/close observation until its callback succeeds
|
|
81
|
+
or its stream reports failure or closure. The configured shutdown drain bounds waiting for handler
|
|
82
|
+
promises, so transport closure alone does not prove arbitrary host callback work has stopped.
|
|
83
|
+
The supplied transport disposer and any provider/facility owners must quiesce their own producers
|
|
84
|
+
and retain cleanup ownership when that fails.
|
|
85
|
+
|
|
86
|
+
A reverse-request handler fulfills before its validated JSON-RPC response is serialized and written.
|
|
87
|
+
Successful local writing does not establish peer receipt: the transport tracks no acknowledgment
|
|
88
|
+
of a reverse response. A provider's canonical answer receipt must state its own acceptance boundary.
|
|
89
|
+
|
|
90
|
+
Requests can set `onResponseReceived` to admit a validated result or remote error
|
|
91
|
+
synchronously before the request promise settles and before the next frame is
|
|
92
|
+
delivered. This lets a session order its terminal marker behind preceding updates.
|
|
93
|
+
The hook performs bounded admission and returns immediately. Local aborts,
|
|
94
|
+
timeouts, write failures and invalid responses do not invoke it. A throwing hook
|
|
95
|
+
rejects the request and closes the connection; remote errors retain the same
|
|
96
|
+
`AcpRemoteError` instance through the hook and promise rejection.
|
|
97
|
+
|
|
98
|
+
## Protocol contract
|
|
99
|
+
|
|
100
|
+
The packaged profiles are upstream `v0.11.4` and `schema-v1.23.0`, both using
|
|
101
|
+
ACP wire protocol version `1`. Client `schemaProfile` defaults to `v0.11.4` so
|
|
102
|
+
existing hosts retain the exact legacy method/schema contract. Select
|
|
103
|
+
`schemaProfile: 'schema-v1.23.0'` explicitly for the newer stable v1 schema.
|
|
104
|
+
|
|
105
|
+
`v0.11.4` supports explicit `stable` or `unstable` channels; `schema-v1.23.0`
|
|
106
|
+
supports only `stable`. Unknown profiles/channels and unsupported combinations
|
|
107
|
+
fail during construction before stream subscriptions or writes. The schema
|
|
108
|
+
validator also defaults to legacy stable:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { createAcpSchemaValidator } from '@agen-ai/acp-transport';
|
|
112
|
+
|
|
113
|
+
const legacy = createAcpSchemaValidator();
|
|
114
|
+
const selected = createAcpSchemaValidator('stable', 'schema-v1.23.0');
|
|
115
|
+
selected.validate('agent', 'session/delete', 'request', { sessionId: 'session-1' });
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The root's existing `ACP_SCHEMA_RELEASE`, `ACP_STABLE_PROTOCOL` and
|
|
119
|
+
`ACP_UNSTABLE_PROTOCOL` exports retain their legacy meanings. Version-specific
|
|
120
|
+
`ACP_V1_23_0_*` metadata describes the new stable profile. Initialization rejects
|
|
121
|
+
wire versions other than `1`; that version does not identify a schema profile or
|
|
122
|
+
prove optional peer capabilities. Standard invocation helpers validate protocol
|
|
123
|
+
structure; hosts still inspect negotiated capabilities and own session state.
|
|
124
|
+
|
|
125
|
+
The newer stable profile adds session resume/close/delete, logout, elicitation,
|
|
126
|
+
boolean configuration and usage updates. It uses `elicitation/create` and
|
|
127
|
+
`elicitation/complete`; these are distinct from the legacy unstable elicitation
|
|
128
|
+
methods. Protocol-level `$/cancel_request` is available under legacy unstable and
|
|
129
|
+
newer stable, and is rejected under legacy stable. Cancel notifications remain
|
|
130
|
+
separate from proof of native settlement. ACP v2 and newer unstable definitions
|
|
131
|
+
are not enabled by selecting this profile.
|
|
132
|
+
|
|
133
|
+
The transport bounds frame bytes, JSON complexity, outstanding requests, reverse
|
|
134
|
+
request and notification concurrency, notification rate, outbound buffering and
|
|
135
|
+
retained stderr. An excess concurrent reverse request receives a correlated limit refusal; admitted
|
|
136
|
+
callbacks remain active. Frame or outbound-buffer overflow closes the connection. These admission
|
|
137
|
+
bounds prevent unbounded accumulation. Handlers must preserve their own semantic ordering
|
|
138
|
+
and output backpressure. Notification delivery alone does not provide a durable
|
|
139
|
+
event journal or a provider-neutral turn state machine.
|
|
140
|
+
|
|
141
|
+
Request cancellation or timeout does not prove that the peer stopped execution.
|
|
142
|
+
`onRequestDispatch` receives the exact allocated `requestId` at the boundary immediately
|
|
143
|
+
before the first write, allowing request-scoped reverse traffic to be correlated before
|
|
144
|
+
the peer can respond. A callback that aborts or rejects admission prevents the request
|
|
145
|
+
write. This local dispatch callback
|
|
146
|
+
does not acknowledge native execution or durable completion. Hosts decide when an
|
|
147
|
+
uncertain operation makes their session unusable. Outbound extension methods and
|
|
148
|
+
supported inbound extension handlers require explicit registration with
|
|
149
|
+
parameter/result validation.
|
|
150
|
+
|
|
151
|
+
## Extension interoperability
|
|
152
|
+
|
|
153
|
+
`CreateAcpClientOptions.unknownExtensionPolicy` accepts `'reject'` or `'standard'`.
|
|
154
|
+
The transport defaults to `'reject'`, preserving strict handling for existing
|
|
155
|
+
callers. The [public ACP provider constructors](../provider-acp/README.md#unknown-extensions)
|
|
156
|
+
select `'standard'` by default; a direct transport client must select it explicitly.
|
|
157
|
+
Use `'standard'` when connecting to a peer that can emit
|
|
158
|
+
optional extensions:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
const client = createAcpClient({
|
|
162
|
+
stdin: agentInput,
|
|
163
|
+
stdout: agentOutput,
|
|
164
|
+
schemaChannel: 'stable',
|
|
165
|
+
schemaProfile: 'schema-v1.23.0',
|
|
166
|
+
unknownExtensionPolicy: 'standard',
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
In standard mode, an unknown incoming method whose name starts with `_` has two
|
|
171
|
+
bounded outcomes. A notification is ignored; a request receives the correlated
|
|
172
|
+
JSON-RPC error `-32601` with the fixed message `Method not found`. Neither invokes
|
|
173
|
+
a host handler. Framing, JSON complexity, envelope validation and notification
|
|
174
|
+
rate limits still apply. Rejection responses share the existing outbound byte
|
|
175
|
+
budget, and their request IDs remain reserved until writing finishes, including
|
|
176
|
+
stream backpressure. Duplicate IDs and response collisions still fail the
|
|
177
|
+
connection.
|
|
178
|
+
|
|
179
|
+
An exact registration for the incoming message kind takes precedence and must
|
|
180
|
+
validate its parameters and any result. A registration for the opposite direction
|
|
181
|
+
or message kind does not authorize an incoming handler. Core methods,
|
|
182
|
+
`$/cancel_request`, malformed messages and unexpected responses retain their
|
|
183
|
+
profile-specific validation and failure behavior. Standard mode does not enable
|
|
184
|
+
outbound extension calls, change the selected schema, or certify a peer's optional
|
|
185
|
+
features. Required extensions still need explicit host support and semantic
|
|
186
|
+
mapping. Discarded notifications produce no provider-neutral events and grant
|
|
187
|
+
no tool, filesystem, terminal, authentication or other effect authority.
|
|
188
|
+
|
|
189
|
+
Frame or outbound-buffer admission failure closes the connection synchronously,
|
|
190
|
+
so a single received batch cannot enqueue further rejection work after overflow.
|
|
191
|
+
The `onFatalError` observer can therefore run during delivery of that batch.
|
|
192
|
+
Public `request()` and `notify()` operations continue to report write failures
|
|
193
|
+
through their returned promises. Await `dispose()` before releasing the owned
|
|
194
|
+
transport.
|
|
195
|
+
|
|
196
|
+
## Schema generation and licensing
|
|
197
|
+
|
|
198
|
+
`schema/v0.11.4/` and `schema/schema-v1.23.0/` contain exact pinned upstream inputs,
|
|
199
|
+
method metadata, provenance, Apache-2.0 licenses and derived method inventories.
|
|
200
|
+
The newer stable release is pinned to commit
|
|
201
|
+
`6d08f412a7a1370d3cc9a124e3be3d6acf92641e`; its source files match the release
|
|
202
|
+
assets byte for byte. Generation reads only package-owned inputs, checks fixed
|
|
203
|
+
hashes and derives both TypeScript/JSON inventories without network access. It
|
|
204
|
+
preserves the legacy inventory byte for byte.
|
|
205
|
+
|
|
206
|
+
| Profile | Pinned upstream commit | Schema channels |
|
|
207
|
+
| --- | --- | --- |
|
|
208
|
+
| `v0.11.4` | `e931357254ff44573294d5cee214a269e0cd6c54` | Stable and explicitly selected unstable |
|
|
209
|
+
| `schema-v1.23.0` | `6d08f412a7a1370d3cc9a124e3be3d6acf92641e` | Stable only |
|
|
210
|
+
|
|
211
|
+
The modern `schema.json` SHA-256 is
|
|
212
|
+
`3c17bd6385d90cf672d8a661fddc359d73422cf8b8ce6865213d25cfd4c0eca7`;
|
|
213
|
+
its `meta.json` SHA-256 is
|
|
214
|
+
`061edb6efa8fb2aa2792459a86ec7268de5fe665bba48b2ffe7939df01481f88`.
|
|
215
|
+
These hashes identify packaged inputs, without authenticating a native agent or
|
|
216
|
+
granting host execution permission. Valid schema messages can still request
|
|
217
|
+
unsupported or unauthorized effects; hosts must validate those separately.
|
|
218
|
+
|
|
219
|
+
From a source checkout, run `pnpm generate`, `pnpm check:generated`, `pnpm build`,
|
|
220
|
+
`pnpm typecheck` and `pnpm test` in this package. Published packages include compiled
|
|
221
|
+
JavaScript/declarations and the exact schema assets, without source maps, source
|
|
222
|
+
files, tests or build caches.
|
|
223
|
+
|
|
224
|
+
AgenAI transport code is [MIT licensed](LICENSE). The unmodified ACP schema inputs
|
|
225
|
+
retain their [Apache-2.0 license](schema/v0.11.4/LICENSE) and
|
|
226
|
+
[legacy source provenance](schema/v0.11.4/provenance.json). The new stable profile
|
|
227
|
+
retains the same [upstream license](schema/schema-v1.23.0/LICENSE) with its own
|
|
228
|
+
[immutable source provenance](schema/schema-v1.23.0/provenance.json).
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AcpClient, CreateAcpClientOptions } from './clientContracts.js';
|
|
2
|
+
export declare function createAcpClient(options: CreateAcpClientOptions): AcpClient;
|
|
3
|
+
export type { AcpClient, AcpClientCloseResult, AcpNotificationContext, AcpNotificationHandler, AcpRequestOptions, AcpRequestDispatchContext, AcpResponseReceived, AcpReverseRequestContext, AcpReverseRequestHandler, AcpUnknownExtensionPolicy, CreateAcpClientOptions, } from './clientContracts.js';
|
|
4
|
+
export * from './standardSessionOperations.js';
|
|
5
|
+
//# sourceMappingURL=client.d.ts.map
|