@noetic-tools/acp 2.0.0-next.1 → 2.0.0-next.3
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/dist/agents.d.ts +5 -0
- package/dist/agents.js +13 -1
- package/dist/bin.js +19 -2
- package/dist/client-adapters.d.ts +2 -2
- package/dist/client.d.ts +9 -2
- package/dist/client.js +40 -1
- package/dist/connection.d.ts +25 -2
- package/dist/connection.js +455 -36
- package/dist/define.d.ts +13 -0
- package/dist/define.js +122 -4
- package/dist/index.d.ts +1 -1
- package/dist/items.d.ts +1 -1
- package/dist/keeper/client.d.ts +93 -0
- package/dist/keeper/client.js +468 -0
- package/dist/keeper/main.d.ts +6 -0
- package/dist/keeper/main.js +31 -0
- package/dist/keeper/process.d.ts +24 -0
- package/dist/keeper/process.js +425 -0
- package/dist/keeper/protocol.d.ts +74 -0
- package/dist/keeper/protocol.js +108 -0
- package/dist/keeper/relay.d.ts +88 -0
- package/dist/keeper/relay.js +420 -0
- package/dist/mcp/node.d.ts +6 -1
- package/dist/mcp/node.js +4 -4
- package/dist/permission-channel.d.ts +5 -0
- package/dist/permission-channel.js +16 -1
- package/dist/runner/host.js +74 -16
- package/dist/runner/options.d.ts +2 -0
- package/dist/runner/options.js +2 -0
- package/dist/runner/protocol.d.ts +12 -0
- package/dist/runner/protocol.js +24 -0
- package/dist/runner/serve.d.ts +5 -0
- package/dist/runner/serve.js +93 -3
- package/dist/serve-events.d.ts +2 -0
- package/dist/serve-events.js +1 -0
- package/dist/serve-questions.d.ts +26 -0
- package/dist/serve-questions.js +105 -0
- package/dist/serve-types.d.ts +1 -1
- package/dist/serve.d.ts +2 -2
- package/dist/serve.js +10 -1
- package/dist/server.js +1 -1
- package/dist/stdio-process.d.ts +38 -0
- package/dist/stdio-process.js +214 -0
- package/dist/stdio.d.ts +50 -7
- package/dist/stdio.js +192 -52
- package/dist/tool-bridge.d.ts +9 -0
- package/dist/tool-bridge.js +5 -1
- package/dist/transport-loopback.d.ts +2 -2
- package/dist/transport-loopback.js +1 -1
- package/dist/turn.d.ts +3 -2
- package/dist/turn.js +22 -2
- package/dist/update-filter.d.ts +38 -0
- package/dist/update-filter.js +193 -0
- package/package.json +3 -3
package/dist/agents.d.ts
CHANGED
|
@@ -75,6 +75,11 @@ export interface AcpPresetOptions {
|
|
|
75
75
|
machine?: AcpMachineFactory;
|
|
76
76
|
/** Attach to an agent this package does not start, in place of the preset's command. */
|
|
77
77
|
transport?: AcpTransportFactory;
|
|
78
|
+
/**
|
|
79
|
+
* The agent's own session options, sent as `_meta` on every session it opens
|
|
80
|
+
* (Claude Code's `{ claudeCode: { options } }`).
|
|
81
|
+
*/
|
|
82
|
+
sessionMeta?: Readonly<Record<string, unknown>>;
|
|
78
83
|
}
|
|
79
84
|
/**
|
|
80
85
|
* Claude Code via `@agentclientprotocol/claude-agent-acp`, the ACP bridge over
|
package/dist/agents.js
CHANGED
|
@@ -89,7 +89,7 @@ export const PRESET_ENV = {
|
|
|
89
89
|
'NOETIC_TOOLS_HEADERS',
|
|
90
90
|
],
|
|
91
91
|
};
|
|
92
|
-
function preset({ agentId, base, opts = {}, wiring, }) {
|
|
92
|
+
function preset({ agentId, base, opts = {}, wiring, instructionsMeta, }) {
|
|
93
93
|
const spec = {
|
|
94
94
|
command: opts.command ?? base.command,
|
|
95
95
|
args: [
|
|
@@ -116,9 +116,20 @@ function preset({ agentId, base, opts = {}, wiring, }) {
|
|
|
116
116
|
}),
|
|
117
117
|
env: spec.env,
|
|
118
118
|
tools: wiring,
|
|
119
|
+
instructionsMeta,
|
|
120
|
+
sessionMeta: opts.sessionMeta,
|
|
119
121
|
});
|
|
120
122
|
}
|
|
121
123
|
//#endregion
|
|
124
|
+
/**
|
|
125
|
+
* claude-agent-acp's own system prompt extension, read by bridges that predate
|
|
126
|
+
* `sessionCapabilities.systemPrompt`: appended to Claude Code's own prompt.
|
|
127
|
+
*/
|
|
128
|
+
const claudeInstructionsMeta = (instructions) => ({
|
|
129
|
+
systemPrompt: {
|
|
130
|
+
append: instructions,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
122
133
|
//#region Presets
|
|
123
134
|
/**
|
|
124
135
|
* Claude Code via `@agentclientprotocol/claude-agent-acp`, the ACP bridge over
|
|
@@ -131,6 +142,7 @@ export function claudeCode(opts = {}) {
|
|
|
131
142
|
base: PRESET_COMMANDS['claude-code'],
|
|
132
143
|
opts,
|
|
133
144
|
wiring: claudeToolWiring,
|
|
145
|
+
instructionsMeta: claudeInstructionsMeta,
|
|
134
146
|
});
|
|
135
147
|
}
|
|
136
148
|
/**
|
package/dist/bin.js
CHANGED
|
@@ -19,7 +19,18 @@
|
|
|
19
19
|
import { parseArgs } from 'node:util';
|
|
20
20
|
import { runnerOptions, trustWarning } from './runner/options.js';
|
|
21
21
|
import { listenAcpRunner, newRunnerToken, readPem, serveAcpRunnerOverStdio } from './runner/serve.js';
|
|
22
|
-
const USAGE = 'usage: noetic-acp serve [--stdio] [--host <host>] [--port <port>] [--agent <id>] [--spawn <command>]... [--env <name>]... [--cwd <dir>] [--tls-cert <pem> --tls-key <pem>]';
|
|
22
|
+
const USAGE = 'usage: noetic-acp serve [--stdio] [--host <host>] [--port <port>] [--agent <id>] [--spawn <command>]... [--env <name>]... [--cwd <dir>] [--detached-timeout <ms>] [--tls-cert <pem> --tls-key <pem>]';
|
|
23
|
+
/** `--detached-timeout <ms>`: a whole number of milliseconds, `0` for no limit. */
|
|
24
|
+
function detachedTimeout(value) {
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const ms = Number(value);
|
|
29
|
+
if (!Number.isInteger(ms) || ms < 0) {
|
|
30
|
+
fail('--detached-timeout takes a whole number of milliseconds (0 for no limit).');
|
|
31
|
+
}
|
|
32
|
+
return ms;
|
|
33
|
+
}
|
|
23
34
|
async function main(argv) {
|
|
24
35
|
const [verb, ...rest] = argv;
|
|
25
36
|
if (verb !== 'serve') {
|
|
@@ -53,6 +64,9 @@ async function main(argv) {
|
|
|
53
64
|
cwd: {
|
|
54
65
|
type: 'string',
|
|
55
66
|
},
|
|
67
|
+
'detached-timeout': {
|
|
68
|
+
type: 'string',
|
|
69
|
+
},
|
|
56
70
|
'tls-cert': {
|
|
57
71
|
type: 'string',
|
|
58
72
|
},
|
|
@@ -61,7 +75,10 @@ async function main(argv) {
|
|
|
61
75
|
},
|
|
62
76
|
},
|
|
63
77
|
});
|
|
64
|
-
const options = runnerOptions(
|
|
78
|
+
const options = runnerOptions({
|
|
79
|
+
...values,
|
|
80
|
+
detachedTimeoutMs: detachedTimeout(values['detached-timeout']),
|
|
81
|
+
});
|
|
65
82
|
process.stderr.write(`${trustWarning(options)}\n`);
|
|
66
83
|
if (values.stdio) {
|
|
67
84
|
await serveAcpRunnerOverStdio(options);
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* {@link AcpCapabilityError} rather than pretending, and a factory author who
|
|
12
12
|
* needs those falls back to a local adapter for them.
|
|
13
13
|
*/
|
|
14
|
+
import type * as acp from '@agentclientprotocol/sdk';
|
|
15
|
+
import type { AgentSideConnection } from '@agentclientprotocol/sdk';
|
|
14
16
|
import type { FsAdapter, ShellAdapter } from '@noetic-tools/types';
|
|
15
|
-
import type * as acp from '@zed-industries/agent-client-protocol';
|
|
16
|
-
import type { AgentSideConnection } from '@zed-industries/agent-client-protocol';
|
|
17
17
|
/** @public Options for {@link clientFsAdapter}. */
|
|
18
18
|
export interface ClientFsAdapterOptions {
|
|
19
19
|
conn: AgentSideConnection;
|
package/dist/client.d.ts
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* the step's config. A withdrawn capability is answered with a JSON-RPC
|
|
13
13
|
* method-not-found rather than silently doing the work anyway.
|
|
14
14
|
*/
|
|
15
|
+
import type * as acp from '@agentclientprotocol/sdk';
|
|
15
16
|
import type { AcpClientHost } from '@noetic-tools/types';
|
|
16
|
-
import type * as acp from '@zed-industries/agent-client-protocol';
|
|
17
17
|
import type { BridgedPermissionCheck } from './tool-permissions.js';
|
|
18
18
|
/** Build the `ClientCapabilities` sent during `initialize`. */
|
|
19
19
|
export declare function clientCapabilitiesFor(host: AcpClientHost): acp.ClientCapabilities;
|
|
@@ -63,6 +63,13 @@ export declare class NoeticAcpClient implements acp.Client {
|
|
|
63
63
|
/** Release every terminal this connection created. */
|
|
64
64
|
dispose(): Promise<void>;
|
|
65
65
|
requestPermission(params: acp.RequestPermissionRequest): Promise<acp.RequestPermissionResponse>;
|
|
66
|
+
/**
|
|
67
|
+
* Ask the current step's handler. With none, or when it throws, the answer
|
|
68
|
+
* is `cancel`: the agent stops asking rather than waiting forever.
|
|
69
|
+
*/
|
|
70
|
+
createElicitation(params: acp.CreateElicitationRequest): Promise<acp.CreateElicitationResponse>;
|
|
71
|
+
/** A URL-mode elicitation finished; nothing waits on it here. */
|
|
72
|
+
completeElicitation(_params: acp.CompleteElicitationNotification): Promise<void>;
|
|
66
73
|
sessionUpdate(params: acp.SessionNotification): Promise<void>;
|
|
67
74
|
/**
|
|
68
75
|
* Keep each `tool_call` until it settles; a permission request can only
|
|
@@ -77,7 +84,7 @@ export declare class NoeticAcpClient implements acp.Client {
|
|
|
77
84
|
createTerminal(params: acp.CreateTerminalRequest): Promise<acp.CreateTerminalResponse>;
|
|
78
85
|
terminalOutput(params: acp.TerminalOutputRequest): Promise<acp.TerminalOutputResponse>;
|
|
79
86
|
waitForTerminalExit(params: acp.WaitForTerminalExitRequest): Promise<acp.WaitForTerminalExitResponse>;
|
|
80
|
-
killTerminal(params: acp.
|
|
87
|
+
killTerminal(params: acp.KillTerminalRequest): Promise<acp.KillTerminalResponse>;
|
|
81
88
|
releaseTerminal(params: acp.ReleaseTerminalRequest): Promise<acp.ReleaseTerminalResponse>;
|
|
82
89
|
/**
|
|
83
90
|
* Run a client method, reporting it either way. A refusal is the more
|
package/dist/client.js
CHANGED
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
* the step's config. A withdrawn capability is answered with a JSON-RPC
|
|
13
13
|
* method-not-found rather than silently doing the work anyway.
|
|
14
14
|
*/
|
|
15
|
-
import { RequestError } from '@
|
|
15
|
+
import { RequestError } from '@agentclientprotocol/sdk';
|
|
16
16
|
import { isAbsolutePath, isWithinRoots } from './paths.js';
|
|
17
17
|
import { resolvePermission, selectPermissionOption } from './permissions.js';
|
|
18
18
|
import { buildCommandLine, TerminalRegistry } from './terminals.js';
|
|
19
19
|
import { allowOnceOption } from './tool-permissions.js';
|
|
20
|
+
import { untagElicitation } from './update-filter.js';
|
|
20
21
|
//#region Capability advertisement
|
|
21
22
|
/** Build the `ClientCapabilities` sent during `initialize`. */
|
|
22
23
|
export function clientCapabilitiesFor(host) {
|
|
@@ -27,6 +28,15 @@ export function clientCapabilitiesFor(host) {
|
|
|
27
28
|
writeTextFile: config?.writeTextFile !== false,
|
|
28
29
|
},
|
|
29
30
|
terminal: config?.terminal !== false,
|
|
31
|
+
// An agent's questions are held for a person (spec 27 § Questions the agent
|
|
32
|
+
// asks); URL questions are not advertised, since nothing here opens a page.
|
|
33
|
+
...(config?.elicitation === false
|
|
34
|
+
? {}
|
|
35
|
+
: {
|
|
36
|
+
elicitation: {
|
|
37
|
+
form: {},
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
30
40
|
};
|
|
31
41
|
}
|
|
32
42
|
//#endregion
|
|
@@ -122,6 +132,35 @@ export class NoeticAcpClient {
|
|
|
122
132
|
outcome: selected,
|
|
123
133
|
};
|
|
124
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Ask the current step's handler. With none, or when it throws, the answer
|
|
137
|
+
* is `cancel`: the agent stops asking rather than waiting forever.
|
|
138
|
+
*/
|
|
139
|
+
async createElicitation(params) {
|
|
140
|
+
const { request, requestId } = untagElicitation(params);
|
|
141
|
+
const handler = this.host.onElicitation;
|
|
142
|
+
// A withdrawn capability is refused here too: an agent that asks anyway
|
|
143
|
+
// must not reach a person nobody set up to answer.
|
|
144
|
+
if (!handler || this.host.capabilities?.elicitation === false) {
|
|
145
|
+
return {
|
|
146
|
+
action: 'cancel',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
return await handler(request, {
|
|
151
|
+
requestId,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return {
|
|
156
|
+
action: 'cancel',
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** A URL-mode elicitation finished; nothing waits on it here. */
|
|
161
|
+
async completeElicitation(_params) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
125
164
|
async sessionUpdate(params) {
|
|
126
165
|
this.trackAnnounced(params.update);
|
|
127
166
|
this.onNotify(params);
|
package/dist/connection.d.ts
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* - translate an aborted turn into `session/cancel` plus the `cancelled`
|
|
15
15
|
* stop reason the specification requires.
|
|
16
16
|
*/
|
|
17
|
-
import type
|
|
18
|
-
import type
|
|
17
|
+
import type * as acp from '@agentclientprotocol/sdk';
|
|
18
|
+
import type { AcpAgentConnection, AcpClientHost, AcpContentBlock, AcpReattachHandle, AcpSessionNotification, AcpTransport } from '@noetic-tools/types';
|
|
19
19
|
import type { ToolBridge } from './tool-bridge.js';
|
|
20
20
|
/** @public Options for {@link openAcpConnection}. */
|
|
21
21
|
export interface OpenAcpConnectionOptions {
|
|
@@ -25,13 +25,36 @@ export interface OpenAcpConnectionOptions {
|
|
|
25
25
|
signal?: AbortSignal;
|
|
26
26
|
/** The tool bridge serving `host.tools`, closed with the connection. */
|
|
27
27
|
tools?: ToolBridge;
|
|
28
|
+
/** How a later host reaches this agent, when it can outlive this one. */
|
|
29
|
+
reattach?: AcpReattachHandle;
|
|
30
|
+
/** The transport reaches an agent an earlier host started (through its keeper). */
|
|
31
|
+
reattached?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The agent's own way to take instructions when it does not advertise
|
|
34
|
+
* `sessionCapabilities.systemPrompt`: the `_meta` to send instead.
|
|
35
|
+
*/
|
|
36
|
+
instructionsMeta?: InstructionsMeta;
|
|
37
|
+
/**
|
|
38
|
+
* The agent's own session options, sent as `_meta` on every session this
|
|
39
|
+
* connection opens. Its keys win over {@link instructionsMeta}'s.
|
|
40
|
+
*/
|
|
41
|
+
sessionMeta?: Readonly<Record<string, unknown>>;
|
|
28
42
|
}
|
|
43
|
+
/** @public See {@link OpenAcpConnectionOptions.instructionsMeta}. */
|
|
44
|
+
export type InstructionsMeta = (instructions: string) => Record<string, unknown>;
|
|
29
45
|
/**
|
|
30
46
|
* The spec requires clients to restrict prompt content to what the agent
|
|
31
47
|
* advertised, so an unsupported block is a configuration error raised here
|
|
32
48
|
* rather than an opaque failure on the wire.
|
|
33
49
|
*/
|
|
34
50
|
export declare function assertPromptContentSupported(agentId: string, content: ReadonlyArray<AcpContentBlock>, capabilities: acp.PromptCapabilities | undefined): void;
|
|
51
|
+
/** JSON with object keys sorted, so two spellings of one value compare equal. */
|
|
52
|
+
export declare function canonicalJson(value: unknown): string;
|
|
53
|
+
/**
|
|
54
|
+
* The child session an update announces: the subagents RFD's
|
|
55
|
+
* `subagent_update`, or codex-acp's earlier draft `subagent_spawned`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function announcedChild(update: AcpSessionNotification['update']): string | undefined;
|
|
35
58
|
/**
|
|
36
59
|
* Open a transport, run the `initialize` handshake, and return the negotiated
|
|
37
60
|
* connection.
|