@noetic-tools/acp 1.4.0 → 2.0.0-next.2
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/bin.js +19 -2
- package/dist/client-adapters.d.ts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -1
- package/dist/connection.d.ts +6 -2
- package/dist/connection.js +213 -31
- package/dist/define.js +92 -4
- package/dist/items.d.ts +1 -1
- package/dist/keeper/client.d.ts +84 -0
- package/dist/keeper/client.js +436 -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 +422 -0
- package/dist/keeper/protocol.d.ts +72 -0
- package/dist/keeper/protocol.js +101 -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 +7 -2
- package/dist/permission-channel.js +39 -13
- package/dist/permissions.d.ts +6 -0
- package/dist/permissions.js +7 -0
- 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-permissions.d.ts +8 -2
- package/dist/serve-permissions.js +26 -5
- package/dist/serve-types.d.ts +7 -6
- package/dist/serve.d.ts +2 -2
- package/dist/serve.js +1 -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 +28 -6
- package/dist/stdio.js +145 -51
- 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 +22 -0
- package/dist/update-filter.js +119 -0
- package/package.json +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session updates newer than the protocol library.
|
|
3
|
+
*
|
|
4
|
+
* The SDK validates every `session/update` notification against the variants
|
|
5
|
+
* it knows and answers any other with `-32602 Invalid params`, dropping it. An
|
|
6
|
+
* agent built on a newer protocol revision would then lose data and log an
|
|
7
|
+
* error for normal traffic. This filter sits on the agent's byte stream before
|
|
8
|
+
* the SDK: a `session/update` whose variant the SDK does not know is handed to
|
|
9
|
+
* the host as it is and kept from the SDK. Every other line passes through
|
|
10
|
+
* byte-identical.
|
|
11
|
+
*/
|
|
12
|
+
import type { AcpSessionNotification } from '@noetic-tools/types';
|
|
13
|
+
/**
|
|
14
|
+
* The notification when `line` is a `session/update` with a variant the SDK
|
|
15
|
+
* does not know; otherwise undefined.
|
|
16
|
+
*/
|
|
17
|
+
export declare function newerSessionUpdate(line: string): AcpSessionNotification | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Pass the agent's stream through, handing `deliver` each `session/update`
|
|
20
|
+
* the SDK would reject for its variant instead of passing it on.
|
|
21
|
+
*/
|
|
22
|
+
export declare function divertNewerUpdates(readable: ReadableStream<Uint8Array>, deliver: (notification: AcpSessionNotification) => void): ReadableStream<Uint8Array>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session updates newer than the protocol library.
|
|
3
|
+
*
|
|
4
|
+
* The SDK validates every `session/update` notification against the variants
|
|
5
|
+
* it knows and answers any other with `-32602 Invalid params`, dropping it. An
|
|
6
|
+
* agent built on a newer protocol revision would then lose data and log an
|
|
7
|
+
* error for normal traffic. This filter sits on the agent's byte stream before
|
|
8
|
+
* the SDK: a `session/update` whose variant the SDK does not know is handed to
|
|
9
|
+
* the host as it is and kept from the SDK. Every other line passes through
|
|
10
|
+
* byte-identical.
|
|
11
|
+
*/
|
|
12
|
+
import { frameworkCast } from '@noetic-tools/types';
|
|
13
|
+
/**
|
|
14
|
+
* Every variant the pinned SDK parses. A `Record` over the union, so a library
|
|
15
|
+
* bump that adds one fails to compile until it is listed here.
|
|
16
|
+
*/
|
|
17
|
+
const KNOWN = {
|
|
18
|
+
user_message_chunk: true,
|
|
19
|
+
agent_message_chunk: true,
|
|
20
|
+
agent_thought_chunk: true,
|
|
21
|
+
tool_call: true,
|
|
22
|
+
tool_call_update: true,
|
|
23
|
+
plan: true,
|
|
24
|
+
plan_update: true,
|
|
25
|
+
plan_removed: true,
|
|
26
|
+
available_commands_update: true,
|
|
27
|
+
current_mode_update: true,
|
|
28
|
+
config_option_update: true,
|
|
29
|
+
session_info_update: true,
|
|
30
|
+
usage_update: true,
|
|
31
|
+
notice: true,
|
|
32
|
+
compaction_update: true,
|
|
33
|
+
compaction_summary_chunk: true,
|
|
34
|
+
subagent_update: true,
|
|
35
|
+
session_message: true,
|
|
36
|
+
session_message_chunk: true,
|
|
37
|
+
};
|
|
38
|
+
function isKnown(kind) {
|
|
39
|
+
return Object.hasOwn(KNOWN, kind);
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region Helpers
|
|
43
|
+
function isRecord(value) {
|
|
44
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The notification when `line` is a `session/update` with a variant the SDK
|
|
48
|
+
* does not know; otherwise undefined.
|
|
49
|
+
*/
|
|
50
|
+
export function newerSessionUpdate(line) {
|
|
51
|
+
if (!line.includes('"session/update"')) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
let message;
|
|
55
|
+
try {
|
|
56
|
+
message = JSON.parse(line);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
if (!isRecord(message) || message.method !== 'session/update' || 'id' in message) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const params = message.params;
|
|
65
|
+
if (!isRecord(params) || typeof params.sessionId !== 'string' || !isRecord(params.update)) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const kind = params.update.sessionUpdate;
|
|
69
|
+
if (typeof kind !== 'string' || isKnown(kind)) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
// A variant from a newer protocol revision: the host's handlers treat an
|
|
73
|
+
// unknown `sessionUpdate` as opaque (the event bridge's `acp.<name>` event).
|
|
74
|
+
return frameworkCast(params);
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region Public API
|
|
78
|
+
/**
|
|
79
|
+
* Pass the agent's stream through, handing `deliver` each `session/update`
|
|
80
|
+
* the SDK would reject for its variant instead of passing it on.
|
|
81
|
+
*/
|
|
82
|
+
export function divertNewerUpdates(readable, deliver) {
|
|
83
|
+
const decoder = new TextDecoder();
|
|
84
|
+
const encoder = new TextEncoder();
|
|
85
|
+
let carry = '';
|
|
86
|
+
const pass = (line, controller) => {
|
|
87
|
+
const newer = newerSessionUpdate(line);
|
|
88
|
+
if (newer) {
|
|
89
|
+
deliver(newer);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
controller.enqueue(encoder.encode(`${line}\n`));
|
|
93
|
+
};
|
|
94
|
+
return readable.pipeThrough(new TransformStream({
|
|
95
|
+
transform(chunk, controller) {
|
|
96
|
+
carry += decoder.decode(chunk, {
|
|
97
|
+
stream: true,
|
|
98
|
+
});
|
|
99
|
+
let newline = carry.indexOf('\n');
|
|
100
|
+
while (newline >= 0) {
|
|
101
|
+
pass(carry.slice(0, newline), controller);
|
|
102
|
+
carry = carry.slice(newline + 1);
|
|
103
|
+
newline = carry.indexOf('\n');
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
flush(controller) {
|
|
107
|
+
const tail = carry + decoder.decode();
|
|
108
|
+
if (tail.length > 0) {
|
|
109
|
+
const newer = newerSessionUpdate(tail);
|
|
110
|
+
if (newer) {
|
|
111
|
+
deliver(newer);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
controller.enqueue(encoder.encode(tail));
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noetic-tools/acp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Both directions of the Agent Client Protocol for Noetic. Drives any ACP-speaking coding agent (Claude Code, Codex, Gemini CLI, …) as a step, and serves a Noetic harness as an ACP agent for editors like Zed (toAcpAgent / serveAcp).",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@modelcontextprotocol/node": "2.1.2",
|
|
66
66
|
"@modelcontextprotocol/server": "2.4.0",
|
|
67
|
-
"@noetic-tools/types": "^3.
|
|
68
|
-
"@
|
|
67
|
+
"@noetic-tools/types": "^3.19.0-next.4",
|
|
68
|
+
"@agentclientprotocol/sdk": "1.9.0",
|
|
69
69
|
"ws": "8.22.1",
|
|
70
70
|
"zod": "^4.0.0"
|
|
71
71
|
},
|