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