@wrongstack/acp 0.0.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 +21 -0
- package/dist/agent/index.d.ts +7 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +5 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/protocol-handler.d.ts +40 -0
- package/dist/agent/protocol-handler.d.ts.map +1 -0
- package/dist/agent/protocol-handler.js +144 -0
- package/dist/agent/protocol-handler.js.map +1 -0
- package/dist/agent/stdio-transport.d.ts +74 -0
- package/dist/agent/stdio-transport.d.ts.map +1 -0
- package/dist/agent/stdio-transport.js +239 -0
- package/dist/agent/stdio-transport.js.map +1 -0
- package/dist/agent/tools-registry.d.ts +33 -0
- package/dist/agent/tools-registry.d.ts.map +1 -0
- package/dist/agent/tools-registry.js +137 -0
- package/dist/agent/tools-registry.js.map +1 -0
- package/dist/agent/wrongstack-acp-agent.d.ts +32 -0
- package/dist/agent/wrongstack-acp-agent.d.ts.map +1 -0
- package/dist/agent/wrongstack-acp-agent.js +82 -0
- package/dist/agent/wrongstack-acp-agent.js.map +1 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/tool-translator.d.ts +63 -0
- package/dist/client/tool-translator.d.ts.map +1 -0
- package/dist/client/tool-translator.js +112 -0
- package/dist/client/tool-translator.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/integration/acp-subagent-runner.d.ts +34 -0
- package/dist/integration/acp-subagent-runner.d.ts.map +1 -0
- package/dist/integration/acp-subagent-runner.js +218 -0
- package/dist/integration/acp-subagent-runner.js.map +1 -0
- package/dist/types/acp-messages.d.ts +133 -0
- package/dist/types/acp-messages.d.ts.map +1 -0
- package/dist/types/acp-messages.js +2 -0
- package/dist/types/acp-messages.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
const WRONGSTACK_CAPABILITIES = [
|
|
2
|
+
'code-generation',
|
|
3
|
+
'async-tools',
|
|
4
|
+
'streaming',
|
|
5
|
+
'progress',
|
|
6
|
+
];
|
|
7
|
+
export class ACPToolsRegistry {
|
|
8
|
+
tools = new Map();
|
|
9
|
+
owner;
|
|
10
|
+
constructor(owner = 'wrongstack') {
|
|
11
|
+
this.owner = owner;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Register one or more tools.
|
|
15
|
+
* Throws on duplicate name unless force=true.
|
|
16
|
+
*/
|
|
17
|
+
register(tools) {
|
|
18
|
+
for (const tool of tools) {
|
|
19
|
+
this.tools.set(tool.name, tool);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Replace the current tool set.
|
|
24
|
+
*/
|
|
25
|
+
setTools(tools) {
|
|
26
|
+
this.tools.clear();
|
|
27
|
+
for (const tool of tools)
|
|
28
|
+
this.tools.set(tool.name, tool);
|
|
29
|
+
}
|
|
30
|
+
get(name) {
|
|
31
|
+
return this.tools.get(name);
|
|
32
|
+
}
|
|
33
|
+
has(name) {
|
|
34
|
+
return this.tools.has(name);
|
|
35
|
+
}
|
|
36
|
+
list() {
|
|
37
|
+
return Array.from(this.tools.values());
|
|
38
|
+
}
|
|
39
|
+
/** Build the ACP tools/list payload from registered tools. */
|
|
40
|
+
buildToolList() {
|
|
41
|
+
return {
|
|
42
|
+
tools: Array.from(this.tools.values()).map((t) => toACPToolDefinition(t, this.owner)),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Execute a tool by name and return ACP-formatted result.
|
|
47
|
+
* Returns null if the tool is not found.
|
|
48
|
+
*/
|
|
49
|
+
async execute(name, args, ctx, signal) {
|
|
50
|
+
const tool = this.tools.get(name);
|
|
51
|
+
if (!tool)
|
|
52
|
+
return null;
|
|
53
|
+
try {
|
|
54
|
+
const result = await tool.execute(args, ctx, {
|
|
55
|
+
signal,
|
|
56
|
+
});
|
|
57
|
+
return toACPToolResult(result);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
61
|
+
return { content: [{ type: 'text', text: msg }], isError: true };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Convert a WrongStack Tool → ACP ACPToolDefinition */
|
|
66
|
+
function toACPToolDefinition(tool, owner) {
|
|
67
|
+
return {
|
|
68
|
+
name: tool.name,
|
|
69
|
+
description: tool.description,
|
|
70
|
+
inputSchema: toACPInputSchema(tool.inputSchema),
|
|
71
|
+
annotations: {
|
|
72
|
+
title: tool.name,
|
|
73
|
+
description: tool.usageHint ?? tool.description,
|
|
74
|
+
priority: toolToPriority(tool),
|
|
75
|
+
alwaysAccept: tool.permission === 'auto',
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Minimal JSON Schema → ACP input schema. ACP uses JSON Schema draft-07. */
|
|
80
|
+
function toACPInputSchema(src) {
|
|
81
|
+
if (!src || typeof src !== 'object') {
|
|
82
|
+
return {};
|
|
83
|
+
}
|
|
84
|
+
const s = src;
|
|
85
|
+
// Recursively convert properties
|
|
86
|
+
if (s.properties && typeof s.properties === 'object') {
|
|
87
|
+
const props = {};
|
|
88
|
+
for (const [k, v] of Object.entries(s.properties)) {
|
|
89
|
+
props[k] = toACPInputSchema(v);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
type: typeof s.type === 'string' ? s.type : undefined,
|
|
93
|
+
properties: props,
|
|
94
|
+
required: Array.isArray(s.required) ? s.required : undefined,
|
|
95
|
+
items: s.items ? toACPInputSchema(s.items) : undefined,
|
|
96
|
+
enum: Array.isArray(s.enum) ? s.enum : undefined,
|
|
97
|
+
description: typeof s.description === 'string' ? s.description : undefined,
|
|
98
|
+
default: s.default,
|
|
99
|
+
minimum: typeof s.minimum === 'number' ? s.minimum : undefined,
|
|
100
|
+
maximum: typeof s.maximum === 'number' ? s.maximum : undefined,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
type: typeof s.type === 'string' ? s.type : undefined,
|
|
105
|
+
items: s.items ? toACPInputSchema(s.items) : undefined,
|
|
106
|
+
enum: Array.isArray(s.enum) ? s.enum : undefined,
|
|
107
|
+
description: typeof s.description === 'string' ? s.description : undefined,
|
|
108
|
+
default: s.default,
|
|
109
|
+
minimum: typeof s.minimum === 'number' ? s.minimum : undefined,
|
|
110
|
+
maximum: typeof s.maximum === 'number' ? s.maximum : undefined,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** Convert a WrongStack ToolResult → ACP ContentBlock[] */
|
|
114
|
+
function toACPToolResult(result) {
|
|
115
|
+
const blocks = [];
|
|
116
|
+
if (result === undefined || result === null) {
|
|
117
|
+
return { content: [{ type: 'text', text: 'ok' }] };
|
|
118
|
+
}
|
|
119
|
+
if (typeof result === 'string') {
|
|
120
|
+
blocks.push({ type: 'text', text: result });
|
|
121
|
+
}
|
|
122
|
+
else if (typeof result === 'object') {
|
|
123
|
+
blocks.push({ type: 'text', text: JSON.stringify(result, null, 2) });
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
blocks.push({ type: 'text', text: String(result) });
|
|
127
|
+
}
|
|
128
|
+
return { content: blocks };
|
|
129
|
+
}
|
|
130
|
+
function toolToPriority(tool) {
|
|
131
|
+
if (tool.riskTier === 'destructive')
|
|
132
|
+
return 'high';
|
|
133
|
+
if (tool.riskTier === 'standard' || tool.permission === 'confirm')
|
|
134
|
+
return 'medium';
|
|
135
|
+
return 'low';
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=tools-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-registry.js","sourceRoot":"","sources":["../../src/agent/tools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AK,QAAQ,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC,CAAC;IAC5C,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,CAAC;AAC3B,CAAC;AAED,SAAS,cAAc,CAAC,IAAU;IAChC,IAAI,IAAI,CAAC,QAAQ,KAAK,aAAa;QAAE,OAAO,MAAM,CAAC;IACnD,IAAI,IAAI,CAAC,QAAQ,KAAK,UAAU,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACnF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Tool } from '@wrongstack/core';
|
|
2
|
+
export interface WrongStackACPServerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Initial tool set. Typically loaded from the WrongStack tool registry
|
|
5
|
+
* via `api.tools.list()` so the ACP server exposes exactly the tools the
|
|
6
|
+
* CLI has configured.
|
|
7
|
+
*/
|
|
8
|
+
tools: Tool[];
|
|
9
|
+
/**
|
|
10
|
+
* Owner label for tool metadata. Passed to ACPToolsRegistry.
|
|
11
|
+
* @default 'wrongstack'
|
|
12
|
+
*/
|
|
13
|
+
owner?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class WrongStackACPServer {
|
|
16
|
+
private readonly transport;
|
|
17
|
+
private readonly registry;
|
|
18
|
+
private readonly handler;
|
|
19
|
+
private running;
|
|
20
|
+
constructor(opts: WrongStackACPServerOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Start the server. Blocks until the client disconnects.
|
|
23
|
+
*
|
|
24
|
+
* 1. Send the startup marker `[wstack-acp]` so the client
|
|
25
|
+
* knows which stdout line is the protocol boundary.
|
|
26
|
+
* 2. Loop: read messages, dispatch to handler, until EOF or error.
|
|
27
|
+
*/
|
|
28
|
+
start(): Promise<void>;
|
|
29
|
+
/** Stop the server. */
|
|
30
|
+
stop(): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=wrongstack-acp-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrongstack-acp-agent.d.ts","sourceRoot":"","sources":["../../src/agent/wrongstack-acp-agent.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAE3C,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,KAAK,EAAE,IAAI,EAAE,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,OAAO,CAAS;gBAEZ,IAAI,EAAE,0BAA0B;IAW5C;;;;;;OAMG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB5B,uBAAuB;IACvB,IAAI,IAAI,IAAI;CAIb"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WrongStackACPServer — ACP server-side entry point.
|
|
3
|
+
*
|
|
4
|
+
* Exposes WrongStack as an ACP-compatible agent. ACP clients (Zed, JetBrains,
|
|
5
|
+
* VS Code ACP extension) spawn this as a subprocess, send JSON-RPC messages
|
|
6
|
+
* over stdio, and receive tool responses.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* node dist/agent/wrongstack-acp-agent.js
|
|
10
|
+
*
|
|
11
|
+
* Or via the CLI:
|
|
12
|
+
* wstack acp-server
|
|
13
|
+
*
|
|
14
|
+
* Startup: sends `[wstack-acp]\n` to stdout so the client knows which process
|
|
15
|
+
* is the ACP server before protocol messages begin.
|
|
16
|
+
*/
|
|
17
|
+
import { StdioTransport } from './stdio-transport.js';
|
|
18
|
+
import { ACPToolsRegistry } from './tools-registry.js';
|
|
19
|
+
import { ACPProtocolHandler } from './protocol-handler.js';
|
|
20
|
+
export class WrongStackACPServer {
|
|
21
|
+
transport;
|
|
22
|
+
registry;
|
|
23
|
+
handler;
|
|
24
|
+
running = false;
|
|
25
|
+
constructor(opts) {
|
|
26
|
+
this.transport = new StdioTransport();
|
|
27
|
+
this.registry = new ACPToolsRegistry(opts.owner);
|
|
28
|
+
this.registry.register(opts.tools);
|
|
29
|
+
this.handler = new ACPProtocolHandler(this.transport, this.registry,
|
|
30
|
+
/* TODO: load WrongStack Context */ {});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Start the server. Blocks until the client disconnects.
|
|
34
|
+
*
|
|
35
|
+
* 1. Send the startup marker `[wstack-acp]` so the client
|
|
36
|
+
* knows which stdout line is the protocol boundary.
|
|
37
|
+
* 2. Loop: read messages, dispatch to handler, until EOF or error.
|
|
38
|
+
*/
|
|
39
|
+
async start() {
|
|
40
|
+
this.transport.sendStartupMarker();
|
|
41
|
+
this.running = true;
|
|
42
|
+
// Handle messages via callback + read loop hybrid
|
|
43
|
+
this.transport.onMessage((msg) => {
|
|
44
|
+
void this.handler.handleMessage(msg); // fire-and-forget; ordering is per-message
|
|
45
|
+
});
|
|
46
|
+
while (this.running) {
|
|
47
|
+
const msg = await this.transport.read();
|
|
48
|
+
if (!msg)
|
|
49
|
+
break; // EOF
|
|
50
|
+
const terminal = await this.handler.handleMessage(msg);
|
|
51
|
+
if (terminal)
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
this.transport.close();
|
|
55
|
+
}
|
|
56
|
+
/** Stop the server. */
|
|
57
|
+
stop() {
|
|
58
|
+
this.running = false;
|
|
59
|
+
this.transport.close();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Bootstrap function for `node dist/agent/wrongstack-acp-agent.js`.
|
|
64
|
+
* Instantiates the server with the default tool set.
|
|
65
|
+
*
|
|
66
|
+
* Tool loading: the ACP agent is a subprocess without the full CLI context,
|
|
67
|
+
* so it needs to receive its tools from the parent via environment or a
|
|
68
|
+
* pre-main bootstrap. For now, it uses an empty tool set unless tools are
|
|
69
|
+
* explicitly passed via constructor options.
|
|
70
|
+
*
|
|
71
|
+
* In practice the CLI will instantiate and run WrongStackACPServer directly,
|
|
72
|
+
* passing `api.tools.list()` as the tool set.
|
|
73
|
+
*/
|
|
74
|
+
async function main() {
|
|
75
|
+
const server = new WrongStackACPServer({ tools: [] });
|
|
76
|
+
await server.start();
|
|
77
|
+
}
|
|
78
|
+
main().catch((err) => {
|
|
79
|
+
process.stderr.write(`[wstack-acp fatal] ${err}\n`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=wrongstack-acp-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrongstack-acp-agent.js","sourceRoot":"","sources":["../../src/agent/wrongstack-acp-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAiBzD,MAAM,OAAO,mBAAmB;IACb,SAAS,CAAiB;I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zB,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,EAAC,KAAK,EAAE,EAAE,EAAC,CAAC,CAAC;IACpD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;AACvB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ClientTransport } from '../agent/stdio-transport.js';
|
|
2
|
+
export type { ClientTransportOptions, ACPChildProcess } from '../agent/stdio-transport.js';
|
|
3
|
+
export { ToolTranslator } from './tool-translator.js';
|
|
4
|
+
export { makeACPSubagentRunner } from '../integration/acp-subagent-runner.js';
|
|
5
|
+
export type { ACPSubagentRunnerOptions } from '../integration/acp-subagent-runner.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,YAAY,EAAC,sBAAsB,EAAE,eAAe,EAAC,MAAM,6BAA6B,CAAC;AACzF,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,qBAAqB,EAAC,MAAM,uCAAuC,CAAC;AAC5E,YAAY,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,qBAAqB,EAAC,MAAM,uCAAuC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolTranslator — bidirectional translation between WrongStack tools and
|
|
3
|
+
* ACP tool representations.
|
|
4
|
+
*
|
|
5
|
+
* Used by DIR-1 (WrongStack as ACP client) to:
|
|
6
|
+
* - Map WrongStack TaskSpec → ACP task payload
|
|
7
|
+
* - Map ACP tool responses → TaskResult
|
|
8
|
+
*
|
|
9
|
+
* Used by DIR-2 (WrongStack as ACP server) to:
|
|
10
|
+
* - Convert the WrongStack Tool.inputSchema → ACPToolDefinition.inputSchema
|
|
11
|
+
* - (handled by tools-registry.ts — same logic lives there)
|
|
12
|
+
*
|
|
13
|
+
* For DIR-1 async tool calls: ACP agents send progress notifications while
|
|
14
|
+
* a tool is running, then send a final result. The translator handles this
|
|
15
|
+
* by polling for the final [result] notification on the transport.
|
|
16
|
+
*/
|
|
17
|
+
import type { ACPMessage, ACPToolDefinition, ACPToolCallResponse, ContentBlock } from '../types/acp-messages.js';
|
|
18
|
+
import type { TaskSpec, TaskResult } from '@wrongstack/core';
|
|
19
|
+
export interface ToolTranslatorOptions {
|
|
20
|
+
/**
|
|
21
|
+
* If true (default), wrap tool calls in an async poll loop that waits
|
|
22
|
+
* for progress notifications until a final result arrives.
|
|
23
|
+
*/
|
|
24
|
+
asyncTools?: boolean;
|
|
25
|
+
pollIntervalMs?: number;
|
|
26
|
+
totalTimeoutMs?: number;
|
|
27
|
+
}
|
|
28
|
+
/** Convert an ACP ACPToolDefinition → a JSON schema object recognisable by WrongStack */
|
|
29
|
+
export declare function acpToolToSchema(def: ACPToolDefinition): Record<string, unknown>;
|
|
30
|
+
/** Extract tool result text from ACP ContentBlock[] */
|
|
31
|
+
export declare function extractTextFromContent(blocks: ContentBlock[]): string;
|
|
32
|
+
/** Build a TaskSpec from an ACP task payload */
|
|
33
|
+
export declare function buildTaskSpec(payload: {
|
|
34
|
+
taskId: string;
|
|
35
|
+
task: string;
|
|
36
|
+
subagentId?: string;
|
|
37
|
+
}): TaskSpec;
|
|
38
|
+
/** Parse an ACP tools/call response → TaskResult */
|
|
39
|
+
export declare function parseToolResponse(taskId: string, subagentId: string, response: ACPToolCallResponse): TaskResult;
|
|
40
|
+
/** ToolTranslator for DIR-1 — wraps ACP client transport, adds task semantics */
|
|
41
|
+
export declare class ToolTranslator {
|
|
42
|
+
private readonly opts;
|
|
43
|
+
private readonly pending;
|
|
44
|
+
constructor(opts?: ToolTranslatorOptions);
|
|
45
|
+
/**
|
|
46
|
+
* Start listening to a transport for tool responses and cancellations.
|
|
47
|
+
* Call this once after constructing the translator and before sending tasks.
|
|
48
|
+
*/
|
|
49
|
+
attachToTransport(transport: {
|
|
50
|
+
onMessage: (h: (msg: ACPMessage) => void) => () => void;
|
|
51
|
+
send: (msg: ACPMessage) => Promise<void>;
|
|
52
|
+
}): void;
|
|
53
|
+
/**
|
|
54
|
+
* Send a tool call over the transport and wait for a response.
|
|
55
|
+
* If asyncTools is true, polls for progress and resolves when the final
|
|
56
|
+
* response arrives.
|
|
57
|
+
*/
|
|
58
|
+
callTool(transport: {
|
|
59
|
+
send: (msg: ACPMessage) => Promise<void>;
|
|
60
|
+
}, name: string, args: Record<string, unknown>, callId?: string | number): Promise<ACPToolCallResponse>;
|
|
61
|
+
cancelAll(): void;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=tool-translator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-translator.d.ts","sourceRoot":"","sources":["../../src/client/tool-translator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAC,UAAU,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAC/G,OAAO,KAAK,EAAC,QAAQ,EAA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,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,GAAE,MAAM,GAAG,MAA4B,GAC5C,OAAO,CAAC,mBAAmB,CAAC;IAiB/B,SAAS,IAAI,IAAI;CAMlB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const DEFAULT_OPTIONS = {
|
|
2
|
+
asyncTools: true,
|
|
3
|
+
pollIntervalMs: 500,
|
|
4
|
+
totalTimeoutMs: 120_000,
|
|
5
|
+
};
|
|
6
|
+
/** Convert an ACP ACPToolDefinition → a JSON schema object recognisable by WrongStack */
|
|
7
|
+
export function acpToolToSchema(def) {
|
|
8
|
+
if (!def.inputSchema)
|
|
9
|
+
return { type: 'object', properties: {} };
|
|
10
|
+
return def.inputSchema;
|
|
11
|
+
}
|
|
12
|
+
/** Extract tool result text from ACP ContentBlock[] */
|
|
13
|
+
export function extractTextFromContent(blocks) {
|
|
14
|
+
const parts = [];
|
|
15
|
+
for (const b of blocks) {
|
|
16
|
+
if (b.type === 'text')
|
|
17
|
+
parts.push(b.text);
|
|
18
|
+
else if (b.type === 'resource')
|
|
19
|
+
parts.push(`[resource: ${b.resource.uri}]`);
|
|
20
|
+
else if (b.type === 'image')
|
|
21
|
+
parts.push(`[image: ${b.data.slice(0, 20)}...]`);
|
|
22
|
+
else if (b.type === 'progress') {
|
|
23
|
+
if (b.messages?.length)
|
|
24
|
+
parts.push(b.messages.join('\n'));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return parts.join('\n');
|
|
28
|
+
}
|
|
29
|
+
/** Build a TaskSpec from an ACP task payload */
|
|
30
|
+
export function buildTaskSpec(payload) {
|
|
31
|
+
return {
|
|
32
|
+
id: payload.taskId,
|
|
33
|
+
description: payload.task,
|
|
34
|
+
subagentId: payload.subagentId,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Parse an ACP tools/call response → TaskResult */
|
|
38
|
+
export function parseToolResponse(taskId, subagentId, response) {
|
|
39
|
+
const blocks = response.result.content;
|
|
40
|
+
const text = extractTextFromContent(blocks);
|
|
41
|
+
// Detect error state from isError flag or error-like text
|
|
42
|
+
const isError = response.result.isError || text.toLowerCase().includes('error') ||
|
|
43
|
+
text.toLowerCase().includes('failed');
|
|
44
|
+
return {
|
|
45
|
+
taskId,
|
|
46
|
+
subagentId,
|
|
47
|
+
status: isError ? 'failed' : 'success',
|
|
48
|
+
result: text,
|
|
49
|
+
iterations: 1,
|
|
50
|
+
toolCalls: 1,
|
|
51
|
+
durationMs: 0,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** ToolTranslator for DIR-1 — wraps ACP client transport, adds task semantics */
|
|
55
|
+
export class ToolTranslator {
|
|
56
|
+
opts;
|
|
57
|
+
pending = new Map();
|
|
58
|
+
constructor(opts = {}) {
|
|
59
|
+
this.opts = { ...DEFAULT_OPTIONS, ...opts };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Start listening to a transport for tool responses and cancellations.
|
|
63
|
+
* Call this once after constructing the translator and before sending tasks.
|
|
64
|
+
*/
|
|
65
|
+
attachToTransport(transport) {
|
|
66
|
+
transport.onMessage((msg) => {
|
|
67
|
+
if (msg.method === 'tools/call' && msg.id !== undefined) {
|
|
68
|
+
const pending = this.pending.get(msg.id);
|
|
69
|
+
if (pending) {
|
|
70
|
+
clearTimeout(pending.timeout);
|
|
71
|
+
this.pending.delete(msg.id);
|
|
72
|
+
pending.resolve(msg);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Handle cancellation notifications
|
|
76
|
+
if (msg.method === 'cancel' && msg.id !== undefined) {
|
|
77
|
+
const pending = this.pending.get(msg.id);
|
|
78
|
+
if (pending) {
|
|
79
|
+
clearTimeout(pending.timeout);
|
|
80
|
+
this.pending.delete(msg.id);
|
|
81
|
+
pending.reject(new Error('Call cancelled by client'));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Send a tool call over the transport and wait for a response.
|
|
88
|
+
* If asyncTools is true, polls for progress and resolves when the final
|
|
89
|
+
* response arrives.
|
|
90
|
+
*/
|
|
91
|
+
async callTool(transport, name, args, callId = crypto.randomUUID()) {
|
|
92
|
+
await transport.send({
|
|
93
|
+
method: 'tools/call',
|
|
94
|
+
id: callId,
|
|
95
|
+
params: { name, arguments: args },
|
|
96
|
+
});
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
const timeout = setTimeout(() => {
|
|
99
|
+
this.pending.delete(callId);
|
|
100
|
+
reject(new Error(`Tool call ${name} timed out after ${this.opts.totalTimeoutMs}ms`));
|
|
101
|
+
}, this.opts.totalTimeoutMs);
|
|
102
|
+
this.pending.set(callId, { resolve, reject, timeout });
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
cancelAll() {
|
|
106
|
+
for (const [, p] of this.pending) {
|
|
107
|
+
clearTimeout(p.timeout);
|
|
108
|
+
}
|
|
109
|
+
this.pending.clear();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=tool-translator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-translator.js","sourceRoot":"","sources":["../../src/client/tool-translator.ts"],"names":[],"mappings":"AA6BA,MAAM,eAAe,GAAoC;IACvD,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,GAAG;IACnB,cAAc,EAAE,OAAO;CACxB,CAAC;AAEF,yFAAyF;AACzF,MAAM,UAAU,eAAe,CAAC,GAAsB;IACpD,IAAI,CAAC,GAAG,CAAC,WAAW;QAAE,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAC,CAAC;IAC9D,OAAO,GAAG,CAAC,WAAsC,CAAC;AACpD,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,sBAAsB,CAAC,MAAsB;IAC3D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAA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CAAC;IACvB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @wrongstack/acp — ACP integration public surface.
|
|
3
|
+
*
|
|
4
|
+
* DIR-2: WrongStack as ACP Server
|
|
5
|
+
* import { WrongStackACPServer } from '@wrongstack/acp/agent';
|
|
6
|
+
*
|
|
7
|
+
* DIR-1: WrongStack as ACP Client
|
|
8
|
+
* import { makeACPSubagentRunner } from '@wrongstack/acp/client';
|
|
9
|
+
*/
|
|
10
|
+
export { StdioTransport } from './agent/stdio-transport.js';
|
|
11
|
+
export type { AgentServerTransport } from './agent/stdio-transport.js';
|
|
12
|
+
export { ACPToolsRegistry } from './agent/tools-registry.js';
|
|
13
|
+
export { ACPProtocolHandler } from './agent/protocol-handler.js';
|
|
14
|
+
export { WrongStackACPServer } from './agent/wrongstack-acp-agent.js';
|
|
15
|
+
export type { WrongStackACPServerOptions } from './agent/wrongstack-acp-agent.js';
|
|
16
|
+
export { ClientTransport } from './agent/stdio-transport.js';
|
|
17
|
+
export type { ClientTransportOptions, ACPChildProcess } from './agent/stdio-transport.js';
|
|
18
|
+
export { ToolTranslator } from './client/tool-translator.js';
|
|
19
|
+
export type { ToolTranslatorOptions } from './client/tool-translator.js';
|
|
20
|
+
export { makeACPSubagentRunner, makeACPSubagentRunnerWithStop } from './integration/acp-subagent-runner.js';
|
|
21
|
+
export type { ACPSubagentRunnerOptions } from './integration/acp-subagent-runner.js';
|
|
22
|
+
export { ACP_AGENT_COMMANDS } from './integration/acp-subagent-runner.js';
|
|
23
|
+
export * from './types/acp-messages.js';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,YAAY,EAAC,0BAA0B,EAAC,MAAM,iCAAiC,CAAC;AAGhF,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAC,sBAAsB,EAAE,eAAe,EAAC,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,YAAY,EAAC,qBAAqB,EAAC,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAC,qBAAqB,EAAE,6BAA6B,EAAC,MAAM,sCAAsC,CAAC;AAC1G,YAAY,EAAC,wBAAwB,EAAC,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAGxE,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @wrongstack/acp — ACP integration public surface.
|
|
3
|
+
*
|
|
4
|
+
* DIR-2: WrongStack as ACP Server
|
|
5
|
+
* import { WrongStackACPServer } from '@wrongstack/acp/agent';
|
|
6
|
+
*
|
|
7
|
+
* DIR-1: WrongStack as ACP Client
|
|
8
|
+
* import { makeACPSubagentRunner } from '@wrongstack/acp/client';
|
|
9
|
+
*/
|
|
10
|
+
// Agent (server) side
|
|
11
|
+
export { StdioTransport } from './agent/stdio-transport.js';
|
|
12
|
+
export { ACPToolsRegistry } from './agent/tools-registry.js';
|
|
13
|
+
export { ACPProtocolHandler } from './agent/protocol-handler.js';
|
|
14
|
+
export { WrongStackACPServer } from './agent/wrongstack-acp-agent.js';
|
|
15
|
+
// Client side (DIR-1: WrongStack spawns external ACP agents)
|
|
16
|
+
export { ClientTransport } from './agent/stdio-transport.js';
|
|
17
|
+
export { ToolTranslator } from './client/tool-translator.js';
|
|
18
|
+
export { makeACPSubagentRunner, makeACPSubagentRunnerWithStop } from './integration/acp-subagent-runner.js';
|
|
19
|
+
export { ACP_AGENT_COMMANDS } from './integration/acp-subagent-runner.js';
|
|
20
|
+
// Types
|
|
21
|
+
export * from './types/acp-messages.js';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,sBAAsB;AACtB,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAGpE,6DAA6D;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAC,qBAAqB,EAAE,6BAA6B,EAAC,MAAM,sCAAsC,CAAC;AAE1G,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAExE,QAAQ;AACR,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ACPSubagentRunner — SubagentRunner implementation for DIR-1.
|
|
3
|
+
*
|
|
4
|
+
* Wraps an external ACP agent (Cline, Gemini CLI, Codex CLI, Copilot, etc.)
|
|
5
|
+
* as a WrongStack subagent. The external agent runs its own agent loop;
|
|
6
|
+
* we send it a task via ACP and return the result.
|
|
7
|
+
*
|
|
8
|
+
* Connected to Director / MultiAgentCoordinator via the SubagentRunner
|
|
9
|
+
* interface (same as AgentSubagentRunner).
|
|
10
|
+
*/
|
|
11
|
+
import type { SubagentRunner } from '@wrongstack/core';
|
|
12
|
+
import type { ToolTranslatorOptions } from '../client/tool-translator.js';
|
|
13
|
+
export interface ACPSubagentRunnerOptions {
|
|
14
|
+
/** ACP agent command or npm package (e.g. 'npx', 'gemini', 'gh') */
|
|
15
|
+
command: string;
|
|
16
|
+
args?: string[];
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
cwd?: string;
|
|
19
|
+
/** Subagent role — used for protocol negotiation and prompt overrides */
|
|
20
|
+
role?: string;
|
|
21
|
+
toolTranslatorOpts?: ToolTranslatorOptions;
|
|
22
|
+
}
|
|
23
|
+
/** Map WrongStack ACP agent role → how to spawn it. */
|
|
24
|
+
export declare const ACP_AGENT_COMMANDS: Record<string, ACPSubagentRunnerOptions>;
|
|
25
|
+
/**
|
|
26
|
+
* Build an ACPSubagentRunner for a given role, or a generic one from explicit options.
|
|
27
|
+
*/
|
|
28
|
+
export declare function makeACPSubagentRunner(options: ACPSubagentRunnerOptions): Promise<SubagentRunner>;
|
|
29
|
+
/** Returns the runner and a stop function to clean up the transport. */
|
|
30
|
+
export declare function makeACPSubagentRunnerWithStop(options: ACPSubagentRunnerOptions): Promise<{
|
|
31
|
+
runner: SubagentRunner;
|
|
32
|
+
stop: () => void;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=acp-subagent-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-subagent-runner.d.ts","sourceRoot":"","sources":["../../src/integration/acp-subagent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAqB,cAAc,EAAW,MAAM,kBAAkB,CAAC;AAInF,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,8BAA8B,CAAC;AAExE,MAAM,WAAW,wBAAwB;IACvC,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,qBAAqB,CAAC;CAC5C;AAED,uDAAuD;AACvD,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAuBvE,CAAC;AAEF;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,cAAc,CAAC,CAgHzB;AAED,wEAAwE;AACxE,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC;IAAC,MAAM,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,IAAI,CAAA;CAAC,CAAC,CAiHrD"}
|