@harapter/transport-acp 0.1.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 +201 -0
- package/README.md +184 -0
- package/dist/client.d.ts +81 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +644 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +18 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +22 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +395 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +47 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +1181 -0
- package/dist/validation.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Harapter contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# `@harapter/transport-acp`
|
|
2
|
+
|
|
3
|
+
`@harapter/transport-acp` is Harapter's Provider-neutral client for the stable
|
|
4
|
+
Agent Client Protocol v1 wire contract. It composes
|
|
5
|
+
[`@harapter/transport-jsonrpc-stdio`](../transport-jsonrpc-stdio/README.md) and
|
|
6
|
+
adds ACP negotiation, runtime validation, capability gates, bidirectional
|
|
7
|
+
permission handling, typed Session updates, and bounded unknown-message
|
|
8
|
+
observation.
|
|
9
|
+
|
|
10
|
+
The package does not spawn an ACP Agent, select a Provider, map ACP events into
|
|
11
|
+
portable Harapter lifecycle events, or infer capabilities from an Agent name.
|
|
12
|
+
The consuming Provider Adapter owns process policy, Provider meaning, Session
|
|
13
|
+
ownership, compatibility, and portable event and error mapping.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @harapter/transport-acp@next
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Stable profile
|
|
22
|
+
|
|
23
|
+
The client sends and requires JSON-RPC `"2.0"` and negotiates
|
|
24
|
+
`protocolVersion: 1`. String, integer numeric, and `null` request identifiers
|
|
25
|
+
are accepted; fractional numeric identifiers fail closed. It implements the
|
|
26
|
+
stable client-side path needed by ACP Provider Adapters:
|
|
27
|
+
|
|
28
|
+
- `initialize` with normalized Agent capability validation;
|
|
29
|
+
- `session/new` and capability-gated `session/load`, `session/list`,
|
|
30
|
+
`session/delete`, `session/resume`, and `session/close`;
|
|
31
|
+
- `session/prompt` with negotiated content and MCP transport checks;
|
|
32
|
+
- `session/cancel` as an explicit ACP notification;
|
|
33
|
+
- `session/update` for every stable v1 update discriminator;
|
|
34
|
+
- `session/request_permission` through a caller-supplied handler;
|
|
35
|
+
- extension requests and notifications whose methods begin with `_`.
|
|
36
|
+
|
|
37
|
+
The initial client profile advertises filesystem, terminal, and terminal-auth
|
|
38
|
+
client services as unsupported. It does not implement authentication, logout,
|
|
39
|
+
terminal, filesystem, elicitation, Session mode, or Session configuration
|
|
40
|
+
methods. Supplying a client capability that claims an unimplemented service is
|
|
41
|
+
rejected instead of silently advertising support.
|
|
42
|
+
|
|
43
|
+
ACP v2 messages are outside this stable profile. A peer that selects another
|
|
44
|
+
protocol version or omits the required JSON-RPC version fails negotiation or
|
|
45
|
+
transport validation; it is never treated as a compatible v1 peer.
|
|
46
|
+
|
|
47
|
+
## Public API
|
|
48
|
+
|
|
49
|
+
- `AcpClient` owns one negotiated ACP connection over caller-owned streams.
|
|
50
|
+
- `AcpInitializeResult` exposes normalized Agent capabilities plus validated
|
|
51
|
+
implementation identity and untrusted authentication-method metadata.
|
|
52
|
+
- `AcpContentBlock`, Session mode and configuration types, tool content and
|
|
53
|
+
location types, plan and command types, `AcpSessionUpdate`, and
|
|
54
|
+
`AcpPermissionRequest` describe the implemented stable message surface.
|
|
55
|
+
- `AcpClientError` provides fixed, content-free protocol and configuration
|
|
56
|
+
errors.
|
|
57
|
+
- `AcpEvent` preserves ordered typed Session updates and bounded, redacted
|
|
58
|
+
observations of future or unknown traffic.
|
|
59
|
+
- `requestExtension()` and `notifyExtension()` are explicit native protocol
|
|
60
|
+
escape hatches; extension handlers receive untrusted values and remain outside
|
|
61
|
+
portable Harapter semantics.
|
|
62
|
+
|
|
63
|
+
## Connection and lifecycle
|
|
64
|
+
|
|
65
|
+
The caller injects Node readable and writable streams and may provide a cleanup
|
|
66
|
+
callback. The ACP client never starts, kills, or restarts the process that owns
|
|
67
|
+
those streams. Closing the client closes the composed logical transport and
|
|
68
|
+
invokes the caller's cleanup callback at most once without ending or destroying
|
|
69
|
+
the streams itself.
|
|
70
|
+
|
|
71
|
+
Initialization is attempted once per connection. All Session and extension
|
|
72
|
+
operations require successful negotiation. Optional Session methods and
|
|
73
|
+
additional directories are enabled only by the corresponding handshake
|
|
74
|
+
capability. HTTP and SSE MCP configurations require the matching Agent MCP
|
|
75
|
+
capability; stdio MCP remains the baseline.
|
|
76
|
+
|
|
77
|
+
Only one prompt may be active for a Session through one client. A prompt result
|
|
78
|
+
becomes authoritative only after a validated `session/prompt` response with one
|
|
79
|
+
of the closed stable stop reasons. EOF, malformed input, an unknown stop reason,
|
|
80
|
+
or a future update never becomes success.
|
|
81
|
+
|
|
82
|
+
When `events()` has a consumer, prompt settlement also waits until that consumer
|
|
83
|
+
finishes every ACP event received before the prompt response. The composed
|
|
84
|
+
JSON-RPC inbound barrier fixes the wire boundary, and the ACP event checkpoint
|
|
85
|
+
fixes the consumer boundary. Events received after the response do not delay or
|
|
86
|
+
mutate the settled prompt. The original prompt deadline and `AbortSignal` remain
|
|
87
|
+
active through both barriers, and event-checkpoint waiters are bounded.
|
|
88
|
+
|
|
89
|
+
`cancelSession()` sends the ACP `session/cancel` notification. Before doing so,
|
|
90
|
+
it answers every pending permission request for that Session with the required
|
|
91
|
+
`cancelled` outcome, including requests that race while the prompt is settling.
|
|
92
|
+
The Session remains cancelling until both the local cancel write and the prompt
|
|
93
|
+
wait settle, so an old cancellation cannot target a newly started prompt. A
|
|
94
|
+
permission handler that remains pending after local settlement is detached from
|
|
95
|
+
client task tracking; its late outcome or rejection is ignored.
|
|
96
|
+
|
|
97
|
+
`closeSession()` similarly answers pending and racing permission requests as
|
|
98
|
+
cancelled before requesting authoritative Session closure. A locally aborted or
|
|
99
|
+
timed-out close wait leaves the Session blocked because the remote close result
|
|
100
|
+
is unknown; only connection closure can clear that uncertainty.
|
|
101
|
+
|
|
102
|
+
A request timeout or `AbortSignal` only stops the local prompt wait; it sends no
|
|
103
|
+
cancellation notification and proves no remote cancellation. When it ends before
|
|
104
|
+
a terminal response is validated, that Session remains blocked from another
|
|
105
|
+
prompt because the remote turn may still be active. The caller may still send
|
|
106
|
+
explicit cancellation, but reuse requires an advertised `session/close`
|
|
107
|
+
operation or closing the connection because the aborted local wait can no longer
|
|
108
|
+
validate the late prompt response.
|
|
109
|
+
|
|
110
|
+
## Events, extensions, and sensitive data
|
|
111
|
+
|
|
112
|
+
`events()` has one consumer and a finite queue, defaulting to 128 unread events.
|
|
113
|
+
Exhausting it fails the connection. Known `session/update` notifications retain
|
|
114
|
+
their validated protocol fields for the Provider Adapter, including content
|
|
115
|
+
annotations and nested tool, plan, command, mode, and configuration structures.
|
|
116
|
+
Future update discriminators, unknown notifications, and unknown requests become
|
|
117
|
+
structural `AcpRawObservation` values bounded by depth, node count, collection
|
|
118
|
+
size, and hashed unknown names. Prompt text, file content, paths, identifiers,
|
|
119
|
+
credentials, headers, booleans, numbers, and arbitrary string values are not
|
|
120
|
+
retained in that raw observation.
|
|
121
|
+
|
|
122
|
+
Unknown requests receive JSON-RPC `Method not found`; unknown notifications are
|
|
123
|
+
observed and otherwise ignored. Synchronous throws and rejected Promises from an
|
|
124
|
+
extension notification observer are contained and cannot alter connection
|
|
125
|
+
lifecycle. Extension callbacks are an explicit unredacted native boundary. Their
|
|
126
|
+
payloads, negotiated `_meta`, known tool `rawInput` and `rawOutput`, remote
|
|
127
|
+
errors, and authentication-method values must not be logged or attached to
|
|
128
|
+
portable errors without Adapter-owned validation and redaction.
|
|
129
|
+
|
|
130
|
+
## Example
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { AcpClient } from '@harapter/transport-acp';
|
|
134
|
+
|
|
135
|
+
const client = new AcpClient({
|
|
136
|
+
readable: controlledProcess.stdout,
|
|
137
|
+
writable: controlledProcess.stdin,
|
|
138
|
+
cleanup: () => stopControlledProcess(controlledProcess),
|
|
139
|
+
requestPermission: async (request) =>
|
|
140
|
+
decidePermissionWithoutLoggingRawFields(request),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const initialized = await client.initialize({
|
|
144
|
+
clientInfo: { name: 'harapter-provider', version: 'current' },
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const session = await client.newSession({
|
|
148
|
+
cwd: controlledWorkspace,
|
|
149
|
+
mcpServers: [],
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const events = client.events();
|
|
153
|
+
const eventTask = (async () => {
|
|
154
|
+
for await (const event of events) {
|
|
155
|
+
handleValidatedAcpEvent(event);
|
|
156
|
+
}
|
|
157
|
+
})();
|
|
158
|
+
|
|
159
|
+
await client.prompt({
|
|
160
|
+
sessionId: session.sessionId,
|
|
161
|
+
prompt: [{ type: 'text', text: controlledPrompt }],
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
await client.close();
|
|
165
|
+
await eventTask;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The example names host-owned values symbolically. Applications must not log
|
|
169
|
+
prompt, workspace, process, extension, or permission payloads by default.
|
|
170
|
+
|
|
171
|
+
## Compatibility evidence
|
|
172
|
+
|
|
173
|
+
The implemented profile follows the official stable ACP v1 schema and
|
|
174
|
+
extensibility rules. Synthetic fixtures record the inspected schema revision in
|
|
175
|
+
[`fixtures/acp/v1-stable`](../../fixtures/acp/v1-stable/manifest.json) for
|
|
176
|
+
reproducible protocol evidence; the revision is evidence provenance, not a
|
|
177
|
+
Provider runtime version pin.
|
|
178
|
+
|
|
179
|
+
Unit evidence covers exact JSON-RPC framing, negotiation, capability defaults
|
|
180
|
+
and gates, MCP and content validation, every stable Session update family,
|
|
181
|
+
Session lifecycle methods, terminal reasons, permission settlement and races,
|
|
182
|
+
unknown-message redaction, queue exhaustion, local wait abort, malformed input,
|
|
183
|
+
EOF, cleanup, and extension behavior. No Provider support claim follows from
|
|
184
|
+
this package alone.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { AcpAgentCapabilities, AcpClientOptions, AcpEvent, AcpInitializeInput, AcpInitializeResult, AcpListSessionsInput, AcpListSessionsResult, AcpLoadSessionInput, AcpMeta, AcpNewSessionInput, AcpNewSessionResult, AcpPromptInput, AcpPromptResult, AcpRequestOptions, AcpResumeSessionInput, AcpSessionState } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Provider-neutral stable ACP v1 client over bounded JSON-RPC stdio streams.
|
|
4
|
+
* It owns ACP negotiation and message semantics, never process lifecycle.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AcpClient {
|
|
7
|
+
private readonly transport;
|
|
8
|
+
private readonly eventQueue;
|
|
9
|
+
private readonly requestPermissionHandler;
|
|
10
|
+
private readonly extensionRequestHandler;
|
|
11
|
+
private readonly extensionNotificationHandler;
|
|
12
|
+
private readonly pendingPermissions;
|
|
13
|
+
private readonly activePromptSessions;
|
|
14
|
+
private readonly cancellingSessions;
|
|
15
|
+
private readonly cancellationOperations;
|
|
16
|
+
private readonly closingSessions;
|
|
17
|
+
private readonly handlerTasks;
|
|
18
|
+
private readonly dispatchPromise;
|
|
19
|
+
private readonly requestTimeoutMs;
|
|
20
|
+
private initializeAttempted;
|
|
21
|
+
private initializePromise;
|
|
22
|
+
private initializeResult;
|
|
23
|
+
private eventsClaimed;
|
|
24
|
+
private open;
|
|
25
|
+
constructor(options: AcpClientOptions);
|
|
26
|
+
/** Negotiate the stable ACP v1 protocol exactly once. */
|
|
27
|
+
initialize(input?: AcpInitializeInput, options?: AcpRequestOptions): Promise<AcpInitializeResult>;
|
|
28
|
+
/** Return the normalized capabilities established by initialization. */
|
|
29
|
+
capabilities(): AcpAgentCapabilities;
|
|
30
|
+
/** Create a new ACP Session. */
|
|
31
|
+
newSession(input: AcpNewSessionInput, options?: AcpRequestOptions): Promise<AcpNewSessionResult>;
|
|
32
|
+
/** Load an existing Session and allow the Agent to replay its history. */
|
|
33
|
+
loadSession(input: AcpLoadSessionInput, options?: AcpRequestOptions): Promise<AcpSessionState>;
|
|
34
|
+
/** Resume an existing Session without replaying its history. */
|
|
35
|
+
resumeSession(input: AcpResumeSessionInput, options?: AcpRequestOptions): Promise<AcpSessionState>;
|
|
36
|
+
/** List Sessions when advertised by the Agent. */
|
|
37
|
+
listSessions(input?: AcpListSessionsInput, options?: AcpRequestOptions): Promise<AcpListSessionsResult>;
|
|
38
|
+
/** Delete a listed Session when advertised by the Agent. */
|
|
39
|
+
deleteSession(sessionId: string, options?: AcpRequestOptions): Promise<Readonly<{
|
|
40
|
+
_meta?: AcpMeta;
|
|
41
|
+
}>>;
|
|
42
|
+
/** Close an active Session when advertised by the Agent. */
|
|
43
|
+
closeSession(sessionIdValue: string, options?: AcpRequestOptions): Promise<Readonly<{
|
|
44
|
+
_meta?: AcpMeta;
|
|
45
|
+
}>>;
|
|
46
|
+
/** Submit one prompt turn and resolve only from its terminal response. */
|
|
47
|
+
prompt(input: AcpPromptInput, options?: AcpRequestOptions): Promise<AcpPromptResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Send native ACP Session cancellation. Pending permission prompts for the
|
|
50
|
+
* Session are answered as cancelled first, as required by ACP v1.
|
|
51
|
+
*/
|
|
52
|
+
cancelSession(sessionIdValue: string): Promise<void>;
|
|
53
|
+
/** Invoke an explicitly namespaced ACP extension request. */
|
|
54
|
+
requestExtension<TResult = unknown>(methodValue: string, params?: unknown, options?: AcpRequestOptions): Promise<TResult>;
|
|
55
|
+
/** Send an explicitly namespaced ACP extension notification. */
|
|
56
|
+
notifyExtension(methodValue: string, params?: unknown): Promise<void>;
|
|
57
|
+
/** Iterate typed Session updates and redacted unknown observations in order. */
|
|
58
|
+
events(): AsyncIterableIterator<AcpEvent>;
|
|
59
|
+
/** Whether the logical ACP connection can still accept operations. */
|
|
60
|
+
isOpen(): boolean;
|
|
61
|
+
/** Close ACP dispatch and the composed transport without owning its streams. */
|
|
62
|
+
close(): Promise<void>;
|
|
63
|
+
private dispatch;
|
|
64
|
+
private handleNotification;
|
|
65
|
+
private handleRequest;
|
|
66
|
+
private emit;
|
|
67
|
+
private track;
|
|
68
|
+
private fail;
|
|
69
|
+
private iterateEvents;
|
|
70
|
+
private requireInitialized;
|
|
71
|
+
private requireReadyCapabilities;
|
|
72
|
+
private requireCapability;
|
|
73
|
+
private requestParsed;
|
|
74
|
+
private settleSessionPermissions;
|
|
75
|
+
private releasePendingPermission;
|
|
76
|
+
private releaseAllPendingPermissions;
|
|
77
|
+
private beginCancellationOperation;
|
|
78
|
+
private endCancellationOperation;
|
|
79
|
+
private maybeClearCancellation;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EAC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