@noetic-tools/acp 1.0.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 +201 -0
- package/README.md +89 -0
- package/dist/agents.d.ts +74 -0
- package/dist/agents.js +136 -0
- package/dist/client.d.ts +92 -0
- package/dist/client.js +288 -0
- package/dist/connection.d.ts +37 -0
- package/dist/connection.js +337 -0
- package/dist/define.d.ts +23 -0
- package/dist/define.js +29 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +41 -0
- package/dist/items.d.ts +36 -0
- package/dist/items.js +76 -0
- package/dist/liveness.d.ts +46 -0
- package/dist/liveness.js +73 -0
- package/dist/paths.d.ts +46 -0
- package/dist/paths.js +84 -0
- package/dist/permission-channel.d.ts +99 -0
- package/dist/permission-channel.js +172 -0
- package/dist/permissions.d.ts +58 -0
- package/dist/permissions.js +150 -0
- package/dist/registry.d.ts +10 -0
- package/dist/registry.js +13 -0
- package/dist/stdio.d.ts +27 -0
- package/dist/stdio.js +82 -0
- package/dist/terminals.d.ts +70 -0
- package/dist/terminals.js +221 -0
- package/dist/transport-loopback.d.ts +31 -0
- package/dist/transport-loopback.js +60 -0
- package/dist/turn.d.ts +43 -0
- package/dist/turn.js +214 -0
- package/package.json +70 -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 describing the origin of the Work and
|
|
141
|
+
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 Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
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 Matt Apperson
|
|
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
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @noetic-tools/acp
|
|
2
|
+
|
|
3
|
+
An [Agent Client Protocol](https://agentclientprotocol.com/) client for [Noetic](https://noetic.tools). Run any ACP-speaking coding agent — Claude Code, Codex, Gemini CLI — as a step in a Noetic agent.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
bun add @noetic-tools/acp
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { AgentHarness, step } from '@noetic-tools/core';
|
|
13
|
+
import { claudeCode } from '@noetic-tools/acp';
|
|
14
|
+
|
|
15
|
+
const review = step.acpAgent({
|
|
16
|
+
id: 'review',
|
|
17
|
+
agent: claudeCode(),
|
|
18
|
+
prompt: 'Review the working tree and summarize the risks',
|
|
19
|
+
permissions: { default: 'deny', allow: [{ kind: 'read' }] },
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const harness = new AgentHarness({ name: 'reviewer', params: {} });
|
|
23
|
+
const summary = await harness.run(review, 'go', harness.createContext());
|
|
24
|
+
console.log(summary);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## What this package does
|
|
28
|
+
|
|
29
|
+
ACP is bidirectional: the agent does not reach for the machine itself, it asks the client to read files, write files, and run terminals, and it asks permission before running a tool. This package implements that client side against Noetic's own adapters, so a sub-agent's file and shell access goes through them rather than around them — and **`fs/*` paths are confined to the session working directory by default**, since ACP puts boundary enforcement on the client.
|
|
30
|
+
|
|
31
|
+
- `fs/read_text_file`, `fs/write_text_file` → the execution context's `FsAdapter`
|
|
32
|
+
- `terminal/create`, `output`, `wait_for_exit`, `kill`, `release` → its `ShellAdapter`
|
|
33
|
+
- `session/request_permission` → a declarative policy, then steering, then an async handler; the default is **deny**
|
|
34
|
+
- `session/update` → the harness event surface, so ACP output streams like a `callModel` step's
|
|
35
|
+
|
|
36
|
+
Every `fs/*` and `terminal/*` call is also emitted as an `acp_client_activity` event, allowed or refused — an observed record of what the agent reached for, not its own account of itself.
|
|
37
|
+
|
|
38
|
+
Because every ACP agent is a uniform JSON-RPC peer, there is no vendor SDK per agent and no closed list of supported agents.
|
|
39
|
+
|
|
40
|
+
## Agents
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { claudeCode, codex, gemini, opencode, pi, customAcpAgent } from '@noetic-tools/acp';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Each preset is only a launch recipe (which binary, which flags) and accepts `command` / `args` / `env` overrides plus a `transport` for agents that are not local child processes. opencode speaks ACP natively; pi is reached through the community `pi-acp` adapter. `customAcpAgent({ agentId, command, args })` covers anything else that speaks the protocol.
|
|
47
|
+
|
|
48
|
+
## Entry points
|
|
49
|
+
|
|
50
|
+
| Import | Contents |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `@noetic-tools/acp` | Protocol client, permission resolver, terminal registry, agent presets, loopback transport. No static `node:*` import; `child_process` loads only when a stdio connection opens. |
|
|
53
|
+
| `@noetic-tools/acp/stdio` | The Node stdio transport (`node:child_process`). Presets reach it through a lazy `import()`. |
|
|
54
|
+
|
|
55
|
+
## Testing
|
|
56
|
+
|
|
57
|
+
`loopbackTransport` stands an in-process agent on the far end of a **real** protocol connection — full handshake, sessions, notifications, and client callbacks — with no process to spawn:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { defineAcpAgent, loopbackTransport } from '@noetic-tools/acp';
|
|
61
|
+
|
|
62
|
+
const fake = defineAcpAgent({
|
|
63
|
+
agentId: 'fake',
|
|
64
|
+
transport: loopbackTransport((conn) => ({
|
|
65
|
+
async initialize(params) {
|
|
66
|
+
return { protocolVersion: params.protocolVersion, agentCapabilities: {}, authMethods: [] };
|
|
67
|
+
},
|
|
68
|
+
async newSession() { return { sessionId: 's1' }; },
|
|
69
|
+
async authenticate() { return {}; },
|
|
70
|
+
async prompt(params) {
|
|
71
|
+
await conn.sessionUpdate({
|
|
72
|
+
sessionId: params.sessionId,
|
|
73
|
+
update: { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'done' } },
|
|
74
|
+
});
|
|
75
|
+
return { stopReason: 'end_turn' };
|
|
76
|
+
},
|
|
77
|
+
async cancel() {},
|
|
78
|
+
})),
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
- [ACP Agent Steps](https://noetic.tools/docs/framework/acp-agents)
|
|
85
|
+
- [Agent Client Protocol](https://agentclientprotocol.com/)
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
Apache-2.0
|
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presets for the coding agents that speak ACP today.
|
|
3
|
+
*
|
|
4
|
+
* A preset is only a launch recipe: which binary to run and with which flags.
|
|
5
|
+
* There is no vendor SDK, no optional peer dependency, and no per-agent
|
|
6
|
+
* protocol code — that is the whole point of standardising on ACP. Any agent
|
|
7
|
+
* not listed here works through {@link customAcpAgent}.
|
|
8
|
+
*
|
|
9
|
+
* The stdio transport is reached through a dynamic `import()`, so this module
|
|
10
|
+
* has no static `node:*` import and nothing loads `child_process` until a
|
|
11
|
+
* connection is actually opened. Note that is a runtime property, not a
|
|
12
|
+
* bundling one: the specifier is static, so a bundler still resolves and
|
|
13
|
+
* includes `./stdio`. A browser build wanting it excluded should alias or
|
|
14
|
+
* externalise `@noetic-tools/acp/stdio`.
|
|
15
|
+
*/
|
|
16
|
+
import type { AcpAgent, AcpTransportFactory } from '@noetic-tools/types';
|
|
17
|
+
/** @public How to launch an agent as a local child process. */
|
|
18
|
+
export interface AcpProcessSpec {
|
|
19
|
+
command: string;
|
|
20
|
+
args?: ReadonlyArray<string>;
|
|
21
|
+
env?: Record<string, string | undefined>;
|
|
22
|
+
}
|
|
23
|
+
/** @public Options common to every process-backed preset. */
|
|
24
|
+
export interface AcpPresetOptions {
|
|
25
|
+
/** Override the executable (e.g. a locally built binary). */
|
|
26
|
+
command?: string;
|
|
27
|
+
/** Extra arguments appended after the preset's own. */
|
|
28
|
+
args?: ReadonlyArray<string>;
|
|
29
|
+
/** Environment overrides for the agent process — API keys, feature flags. */
|
|
30
|
+
env?: Record<string, string | undefined>;
|
|
31
|
+
/** Supply a non-stdio transport (remote agent, test loopback, sandbox bridge). */
|
|
32
|
+
transport?: AcpTransportFactory;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Claude Code via `@zed-industries/claude-code-acp`, the ACP bridge over the
|
|
36
|
+
* Claude Code SDK.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare function claudeCode(opts?: AcpPresetOptions): AcpAgent;
|
|
40
|
+
/**
|
|
41
|
+
* OpenAI Codex via `@zed-industries/codex-acp`.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function codex(opts?: AcpPresetOptions): AcpAgent;
|
|
45
|
+
/**
|
|
46
|
+
* Gemini CLI, which speaks ACP natively behind its experimental flag.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare function gemini(opts?: AcpPresetOptions): AcpAgent;
|
|
50
|
+
/**
|
|
51
|
+
* opencode, which speaks ACP natively via its `opencode acp` command.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare function opencode(opts?: AcpPresetOptions): AcpAgent;
|
|
55
|
+
/**
|
|
56
|
+
* The pi coding agent, reached through the community `pi-acp` adapter — the
|
|
57
|
+
* same adapter Zed's agent registry points at. pi itself has no native ACP
|
|
58
|
+
* mode yet, so this preset depends on a third-party bridge; if it misbehaves,
|
|
59
|
+
* the issue belongs there rather than in pi or here.
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export declare function pi(opts?: AcpPresetOptions): AcpAgent;
|
|
63
|
+
/**
|
|
64
|
+
* Any other ACP-speaking agent. Because the protocol is uniform, this is a
|
|
65
|
+
* first-class way to use an agent — not a fallback.
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare function customAcpAgent(opts: {
|
|
69
|
+
agentId: string;
|
|
70
|
+
command?: string;
|
|
71
|
+
args?: ReadonlyArray<string>;
|
|
72
|
+
env?: Record<string, string | undefined>;
|
|
73
|
+
transport?: AcpTransportFactory;
|
|
74
|
+
}): AcpAgent;
|
package/dist/agents.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presets for the coding agents that speak ACP today.
|
|
3
|
+
*
|
|
4
|
+
* A preset is only a launch recipe: which binary to run and with which flags.
|
|
5
|
+
* There is no vendor SDK, no optional peer dependency, and no per-agent
|
|
6
|
+
* protocol code — that is the whole point of standardising on ACP. Any agent
|
|
7
|
+
* not listed here works through {@link customAcpAgent}.
|
|
8
|
+
*
|
|
9
|
+
* The stdio transport is reached through a dynamic `import()`, so this module
|
|
10
|
+
* has no static `node:*` import and nothing loads `child_process` until a
|
|
11
|
+
* connection is actually opened. Note that is a runtime property, not a
|
|
12
|
+
* bundling one: the specifier is static, so a bundler still resolves and
|
|
13
|
+
* includes `./stdio`. A browser build wanting it excluded should alias or
|
|
14
|
+
* externalise `@noetic-tools/acp/stdio`.
|
|
15
|
+
*/
|
|
16
|
+
import { defineAcpAgent } from './define.js';
|
|
17
|
+
/**
|
|
18
|
+
* Defer the `node:child_process` import until a connection is actually opened,
|
|
19
|
+
* so importing `@noetic-tools/acp` in a browser or worker stays safe.
|
|
20
|
+
*/
|
|
21
|
+
function lazyStdioTransport(agentId, spec) {
|
|
22
|
+
return async (opts) => {
|
|
23
|
+
const { stdioAcpTransport } = await import('./stdio.js');
|
|
24
|
+
return await stdioAcpTransport({
|
|
25
|
+
agentId,
|
|
26
|
+
command: spec.command,
|
|
27
|
+
args: spec.args,
|
|
28
|
+
env: spec.env,
|
|
29
|
+
})(opts);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function preset(agentId, base, opts = {}) {
|
|
33
|
+
const spec = {
|
|
34
|
+
command: opts.command ?? base.command,
|
|
35
|
+
args: [
|
|
36
|
+
...(base.args ?? []),
|
|
37
|
+
...(opts.args ?? []),
|
|
38
|
+
],
|
|
39
|
+
env: {
|
|
40
|
+
...base.env,
|
|
41
|
+
...opts.env,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
return defineAcpAgent({
|
|
45
|
+
agentId,
|
|
46
|
+
transport: opts.transport ?? lazyStdioTransport(agentId, spec),
|
|
47
|
+
env: spec.env,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region Presets
|
|
52
|
+
/**
|
|
53
|
+
* Claude Code via `@zed-industries/claude-code-acp`, the ACP bridge over the
|
|
54
|
+
* Claude Code SDK.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export function claudeCode(opts = {}) {
|
|
58
|
+
return preset('claude-code', {
|
|
59
|
+
command: 'npx',
|
|
60
|
+
args: [
|
|
61
|
+
'-y',
|
|
62
|
+
'@zed-industries/claude-code-acp',
|
|
63
|
+
],
|
|
64
|
+
}, opts);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* OpenAI Codex via `@zed-industries/codex-acp`.
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export function codex(opts = {}) {
|
|
71
|
+
return preset('codex', {
|
|
72
|
+
command: 'npx',
|
|
73
|
+
args: [
|
|
74
|
+
'-y',
|
|
75
|
+
'@zed-industries/codex-acp',
|
|
76
|
+
],
|
|
77
|
+
}, opts);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Gemini CLI, which speaks ACP natively behind its experimental flag.
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
export function gemini(opts = {}) {
|
|
84
|
+
return preset('gemini', {
|
|
85
|
+
command: 'gemini',
|
|
86
|
+
args: [
|
|
87
|
+
'--experimental-acp',
|
|
88
|
+
],
|
|
89
|
+
}, opts);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* opencode, which speaks ACP natively via its `opencode acp` command.
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export function opencode(opts = {}) {
|
|
96
|
+
return preset('opencode', {
|
|
97
|
+
command: 'opencode',
|
|
98
|
+
args: [
|
|
99
|
+
'acp',
|
|
100
|
+
],
|
|
101
|
+
}, opts);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The pi coding agent, reached through the community `pi-acp` adapter — the
|
|
105
|
+
* same adapter Zed's agent registry points at. pi itself has no native ACP
|
|
106
|
+
* mode yet, so this preset depends on a third-party bridge; if it misbehaves,
|
|
107
|
+
* the issue belongs there rather than in pi or here.
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
export function pi(opts = {}) {
|
|
111
|
+
return preset('pi', {
|
|
112
|
+
command: 'npx',
|
|
113
|
+
args: [
|
|
114
|
+
'-y',
|
|
115
|
+
'pi-acp',
|
|
116
|
+
],
|
|
117
|
+
}, opts);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Any other ACP-speaking agent. Because the protocol is uniform, this is a
|
|
121
|
+
* first-class way to use an agent — not a fallback.
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
export function customAcpAgent(opts) {
|
|
125
|
+
if (!opts.transport && !opts.command) {
|
|
126
|
+
throw new TypeError(`customAcpAgent(${JSON.stringify(opts.agentId)}) requires either a 'command' to spawn or a 'transport'.`);
|
|
127
|
+
}
|
|
128
|
+
return preset(opts.agentId, {
|
|
129
|
+
command: opts.command ?? '',
|
|
130
|
+
args: opts.args,
|
|
131
|
+
env: opts.env,
|
|
132
|
+
}, {
|
|
133
|
+
transport: opts.transport,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noetic's implementation of the ACP **Client** side.
|
|
3
|
+
*
|
|
4
|
+
* ACP inverts the usual control flow: rather than reaching for the machine
|
|
5
|
+
* itself, the agent asks the client to read files, write files, and run
|
|
6
|
+
* terminals. Serving those requests here means every file and
|
|
7
|
+
* shell operation a sub-agent performs flows through Noetic's own
|
|
8
|
+
* {@link FsAdapter} and {@link ShellAdapter} — the same sandboxing, virtual
|
|
9
|
+
* filesystem, and audit path as first-party steps.
|
|
10
|
+
*
|
|
11
|
+
* Capabilities are advertised from what the host can actually back, narrowed by
|
|
12
|
+
* the step's config. A withdrawn capability is answered with a JSON-RPC
|
|
13
|
+
* method-not-found rather than silently doing the work anyway.
|
|
14
|
+
*/
|
|
15
|
+
import type { AcpClientHost } from '@noetic-tools/types';
|
|
16
|
+
import type * as acp from '@zed-industries/agent-client-protocol';
|
|
17
|
+
/** Build the `ClientCapabilities` sent during `initialize`. */
|
|
18
|
+
export declare function clientCapabilitiesFor(host: AcpClientHost): acp.ClientCapabilities;
|
|
19
|
+
/**
|
|
20
|
+
* Apply ACP's `line` / `limit` window. Line numbers are 1-indexed per the
|
|
21
|
+
* specification; `limit` counts lines, not bytes.
|
|
22
|
+
*/
|
|
23
|
+
export declare function sliceLines(content: string, line?: number | null, limit?: number | null): string;
|
|
24
|
+
/** @public Options for {@link NoeticAcpClient}. */
|
|
25
|
+
export interface NoeticAcpClientOptions {
|
|
26
|
+
/**
|
|
27
|
+
* The live host. Held by reference, never copied: the runtime rebinds its
|
|
28
|
+
* per-turn fields when a session is reused, and a copy would freeze every
|
|
29
|
+
* later step to the policy of the step that opened the connection.
|
|
30
|
+
*/
|
|
31
|
+
host: AcpClientHost;
|
|
32
|
+
/**
|
|
33
|
+
* Where `session/update` notifications go. Separate from the host so the
|
|
34
|
+
* connection can fan them out to its own turn accumulator as well, without
|
|
35
|
+
* having to wrap (and thereby copy) the host.
|
|
36
|
+
*/
|
|
37
|
+
onNotify: (notification: acp.SessionNotification) => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The `Client` handed to the ACP connection. One instance per connection; it
|
|
41
|
+
* owns the terminal registry, so closing the connection kills every command the
|
|
42
|
+
* agent started.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare class NoeticAcpClient implements acp.Client {
|
|
46
|
+
private readonly host;
|
|
47
|
+
private readonly onNotify;
|
|
48
|
+
private readonly terminals;
|
|
49
|
+
constructor(opts: NoeticAcpClientOptions);
|
|
50
|
+
/**
|
|
51
|
+
* Read the permission tiers off the host at CALL time, never snapshot them.
|
|
52
|
+
* A connection outlives the step that opened it, and the host is rebound
|
|
53
|
+
* per turn — snapshotting would answer every later step with the first
|
|
54
|
+
* step's policy.
|
|
55
|
+
*/
|
|
56
|
+
private get permissions();
|
|
57
|
+
/** Release every terminal this connection created. */
|
|
58
|
+
dispose(): Promise<void>;
|
|
59
|
+
requestPermission(params: acp.RequestPermissionRequest): Promise<acp.RequestPermissionResponse>;
|
|
60
|
+
sessionUpdate(params: acp.SessionNotification): Promise<void>;
|
|
61
|
+
readTextFile(params: acp.ReadTextFileRequest): Promise<acp.ReadTextFileResponse>;
|
|
62
|
+
writeTextFile(params: acp.WriteTextFileRequest): Promise<acp.WriteTextFileResponse>;
|
|
63
|
+
createTerminal(params: acp.CreateTerminalRequest): Promise<acp.CreateTerminalResponse>;
|
|
64
|
+
terminalOutput(params: acp.TerminalOutputRequest): Promise<acp.TerminalOutputResponse>;
|
|
65
|
+
waitForTerminalExit(params: acp.WaitForTerminalExitRequest): Promise<acp.WaitForTerminalExitResponse>;
|
|
66
|
+
killTerminal(params: acp.KillTerminalCommandRequest): Promise<acp.KillTerminalResponse>;
|
|
67
|
+
releaseTerminal(params: acp.ReleaseTerminalRequest): Promise<acp.ReleaseTerminalResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Run a client method, reporting it either way. A refusal is the more
|
|
70
|
+
* interesting record of the two — it is the moment an agent reached for
|
|
71
|
+
* something it was not allowed to have.
|
|
72
|
+
*
|
|
73
|
+
* Read the observer at call time, never snapshot it: the host is rebound per
|
|
74
|
+
* turn, so a session shared across steps must report to the CURRENT step.
|
|
75
|
+
*/
|
|
76
|
+
private audited;
|
|
77
|
+
/**
|
|
78
|
+
* The roots an agent may reach: the session working directory plus whatever
|
|
79
|
+
* the step explicitly added.
|
|
80
|
+
*/
|
|
81
|
+
private get allowedRoots();
|
|
82
|
+
/**
|
|
83
|
+
* Reject a path outside the workspace before it reaches the adapter.
|
|
84
|
+
*
|
|
85
|
+
* The specification requires absolute paths, so a relative one is malformed
|
|
86
|
+
* input rather than something to resolve against a guessed base.
|
|
87
|
+
*/
|
|
88
|
+
private assertPathAllowed;
|
|
89
|
+
private assertTerminalCapability;
|
|
90
|
+
/** A withdrawn capability must fail loudly, not quietly do the work anyway. */
|
|
91
|
+
private assertCapability;
|
|
92
|
+
}
|