@hyperwindmill/caretaker-cli 0.24.0 → 0.25.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/dist/acp/index.d.ts +3 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +2 -0
- package/dist/acp/install.d.ts +12 -0
- package/dist/acp/install.d.ts.map +1 -0
- package/dist/acp/install.js +110 -0
- package/dist/acp/registry.d.ts +10 -0
- package/dist/acp/registry.d.ts.map +1 -0
- package/dist/acp/registry.js +116 -0
- package/dist/cli/web/mcp_bridge.d.ts +7 -1
- package/dist/cli/web/mcp_bridge.d.ts.map +1 -1
- package/dist/cli/web/mcp_bridge.js +10 -6
- package/dist/cli/web/scheduler/memory_sweep.d.ts.map +1 -1
- package/dist/cli/web/scheduler/memory_sweep.js +1 -0
- package/dist/cli/web/scheduler/task_review.d.ts.map +1 -1
- package/dist/cli/web/scheduler/task_review.js +25 -0
- package/dist/cli/web/scheduler/task_roles.d.ts +1 -1
- package/dist/cli/web/scheduler/task_roles.d.ts.map +1 -1
- package/dist/cli/web/scheduler/task_roles.js +6 -6
- package/dist/cli/web/scheduler/task_strategy.d.ts.map +1 -1
- package/dist/cli/web/scheduler/task_strategy.js +23 -2
- package/dist/cli/web/server.d.ts +1 -1
- package/dist/cli/web/server.d.ts.map +1 -1
- package/dist/cli/web/server.js +27 -5
- package/dist/harness/acp_policy.d.ts +41 -0
- package/dist/harness/acp_policy.d.ts.map +1 -0
- package/dist/harness/acp_policy.js +59 -0
- package/dist/harness/acp_pool.d.ts +34 -0
- package/dist/harness/acp_pool.d.ts.map +1 -0
- package/dist/harness/acp_pool.js +154 -0
- package/dist/harness/acp_runner.d.ts +4 -0
- package/dist/harness/acp_runner.d.ts.map +1 -0
- package/dist/harness/acp_runner.js +385 -0
- package/dist/harness/claude_code_runner.d.ts +2 -0
- package/dist/harness/claude_code_runner.d.ts.map +1 -1
- package/dist/harness/claude_code_runner.js +1 -1
- package/dist/harness/confirm_gate.d.ts +12 -0
- package/dist/harness/confirm_gate.d.ts.map +1 -0
- package/dist/harness/confirm_gate.js +33 -0
- package/dist/harness/index.d.ts +1 -0
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +1 -0
- package/dist/harness/loop.d.ts +3 -0
- package/dist/harness/loop.d.ts.map +1 -1
- package/dist/harness/loop.js +6 -0
- package/dist/harness/memory_recall.d.ts +8 -3
- package/dist/harness/memory_recall.d.ts.map +1 -1
- package/dist/harness/memory_recall.js +11 -7
- package/dist/harness/title.js +1 -1
- package/dist/mcp/builtin_server.d.ts +1 -0
- package/dist/mcp/builtin_server.d.ts.map +1 -1
- package/dist/mcp/builtin_server.js +3 -2
- package/dist/mcp/run_command_tool.d.ts +13 -0
- package/dist/mcp/run_command_tool.d.ts.map +1 -0
- package/dist/mcp/run_command_tool.js +51 -0
- package/dist/session/store.d.ts +1 -0
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +6 -0
- package/dist/session/types.d.ts +3 -0
- package/dist/session/types.d.ts.map +1 -1
- package/dist/tui/agents.d.ts.map +1 -1
- package/dist/tui/agents.js +57 -23
- package/dist/tui/chat.d.ts.map +1 -1
- package/dist/tui/chat.js +7 -8
- package/dist/tui/providers.d.ts.map +1 -1
- package/dist/tui/providers.js +116 -17
- package/dist/webview/standalone.css +18 -0
- package/dist/webview/standalone.css.map +2 -2
- package/dist/webview/standalone.js +230 -25
- package/dist/webview/standalone.js.map +2 -2
- package/package.json +8 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/acp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AcpAgentPreset } from '../types.js';
|
|
2
|
+
type FetchLike = (url: string) => Promise<Response>;
|
|
3
|
+
export declare function __setFetch(f: FetchLike): void;
|
|
4
|
+
export declare function __resetFetch(): void;
|
|
5
|
+
export type InstalledAcp = {
|
|
6
|
+
command: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
env?: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
export declare function installAcpAgent(preset: AcpAgentPreset, onProgress?: (line: string) => void): Promise<InstalledAcp>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/acp/install.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOlD,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAGpD,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAE7C;AACD,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAwB7F,wBAAsB,eAAe,CACnC,MAAM,EAAE,cAAc,EACtB,UAAU,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAe,GAC5C,OAAO,CAAC,YAAY,CAAC,CAqEvB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Managed install of binary-distributed ACP agents (spec:
|
|
2
|
+
// 2026-08-25-acp-registry-presets). Download → sha256 verify → extract →
|
|
3
|
+
// chmod, all into a tmp sibling renamed into place on success, so a failed
|
|
4
|
+
// install leaves nothing behind. Idempotent per <id>/<version>: the saved
|
|
5
|
+
// provider just points at the resulting absolute path — nothing else in
|
|
6
|
+
// caretaker knows the binary is "managed".
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { createWriteStream } from 'node:fs';
|
|
9
|
+
import { chmod, mkdir, rename, rm, rmdir, stat } from 'node:fs/promises';
|
|
10
|
+
import { pipeline } from 'node:stream/promises';
|
|
11
|
+
import { Readable, Transform } from 'node:stream';
|
|
12
|
+
import { execFile } from 'node:child_process';
|
|
13
|
+
import { promisify } from 'node:util';
|
|
14
|
+
import { basename, join, resolve } from 'node:path';
|
|
15
|
+
import { dataDir } from '../store/json.js';
|
|
16
|
+
const exec = promisify(execFile);
|
|
17
|
+
/** Whole-download ceiling (headers + body): archives are tens of MB, so this is
|
|
18
|
+
* generous, but a stalled mirror must not leave the Install button spinning. */
|
|
19
|
+
const DOWNLOAD_TIMEOUT_MS = 10 * 60_000;
|
|
20
|
+
const defaultFetch = (url) => fetch(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
|
|
21
|
+
let fetchImpl = defaultFetch;
|
|
22
|
+
export function __setFetch(f) {
|
|
23
|
+
fetchImpl = f;
|
|
24
|
+
}
|
|
25
|
+
export function __resetFetch() {
|
|
26
|
+
fetchImpl = defaultFetch;
|
|
27
|
+
}
|
|
28
|
+
function isExtractable(name) {
|
|
29
|
+
return /\.(tar\.(gz|bz2|xz)|tgz|tbz2|tar|zip)$/i.test(name);
|
|
30
|
+
}
|
|
31
|
+
async function extract(archive, dest) {
|
|
32
|
+
if (/\.zip$/i.test(archive) && process.platform === 'linux') {
|
|
33
|
+
// GNU tar has no zip support; macOS and Windows ship bsdtar (which does).
|
|
34
|
+
try {
|
|
35
|
+
await exec('unzip', ['-o', archive, '-d', dest]);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
if (err?.code === 'ENOENT') {
|
|
40
|
+
throw new Error('unzip is required to extract .zip archives on Linux — install it (e.g. apt install unzip)');
|
|
41
|
+
}
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
await exec('tar', ['-xf', archive, '-C', dest]);
|
|
46
|
+
}
|
|
47
|
+
export async function installAcpAgent(preset, onProgress = () => { }) {
|
|
48
|
+
const d = preset.dist;
|
|
49
|
+
if (!d || d.kind !== 'binary') {
|
|
50
|
+
throw new Error(`"${preset.id}" has no binary distribution for this platform`);
|
|
51
|
+
}
|
|
52
|
+
const dir = join(dataDir(), 'acp', preset.id, preset.version || 'latest');
|
|
53
|
+
const command = resolve(dir, d.cmd);
|
|
54
|
+
const result = { command, args: d.args ?? [], ...(d.env ? { env: d.env } : {}) };
|
|
55
|
+
if (await stat(command).then(() => true).catch(() => false)) {
|
|
56
|
+
onProgress('already installed');
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
const tmp = `${dir}.tmp-${process.pid}`;
|
|
60
|
+
try {
|
|
61
|
+
await mkdir(tmp, { recursive: true });
|
|
62
|
+
onProgress(`downloading ${d.archive}`);
|
|
63
|
+
const res = await fetchImpl(d.archive);
|
|
64
|
+
if (!res.ok || !res.body)
|
|
65
|
+
throw new Error(`download failed: HTTP ${res.status}`);
|
|
66
|
+
const archiveName = basename(new URL(d.archive).pathname);
|
|
67
|
+
const archivePath = join(tmp, archiveName);
|
|
68
|
+
// Hash while streaming to disk: archives are tens of MB, no need to
|
|
69
|
+
// re-read them into memory for the checksum.
|
|
70
|
+
const hasher = createHash('sha256');
|
|
71
|
+
await pipeline(Readable.fromWeb(res.body), new Transform({
|
|
72
|
+
transform(chunk, _enc, cb) {
|
|
73
|
+
hasher.update(chunk);
|
|
74
|
+
cb(null, chunk);
|
|
75
|
+
},
|
|
76
|
+
}), createWriteStream(archivePath));
|
|
77
|
+
if (d.sha256) {
|
|
78
|
+
onProgress('verifying checksum');
|
|
79
|
+
const hash = hasher.digest('hex');
|
|
80
|
+
if (hash !== d.sha256)
|
|
81
|
+
throw new Error(`sha256 mismatch: expected ${d.sha256}, got ${hash}`);
|
|
82
|
+
}
|
|
83
|
+
if (isExtractable(archiveName)) {
|
|
84
|
+
onProgress('extracting');
|
|
85
|
+
await extract(archivePath, tmp);
|
|
86
|
+
await rm(archivePath, { force: true });
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Raw executable download (no archive): move it to the cmd path.
|
|
90
|
+
const target = resolve(tmp, d.cmd);
|
|
91
|
+
await mkdir(join(target, '..'), { recursive: true });
|
|
92
|
+
await rename(archivePath, target);
|
|
93
|
+
}
|
|
94
|
+
const cmdInTmp = resolve(tmp, d.cmd);
|
|
95
|
+
if (!(await stat(cmdInTmp).then(() => true).catch(() => false))) {
|
|
96
|
+
throw new Error(`archive did not contain the expected command "${d.cmd}"`);
|
|
97
|
+
}
|
|
98
|
+
await chmod(cmdInTmp, 0o755).catch(() => { }); // no-op semantics on Windows
|
|
99
|
+
await rm(dir, { recursive: true, force: true });
|
|
100
|
+
await rename(tmp, dir);
|
|
101
|
+
onProgress('installed');
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
await rm(tmp, { recursive: true, force: true });
|
|
106
|
+
// Remove the (possibly just-created, empty) id dir if this was the first version.
|
|
107
|
+
await rmdir(join(dataDir(), 'acp', preset.id)).catch(() => { });
|
|
108
|
+
throw err instanceof Error ? err : new Error(String(err));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AcpAgentPreset } from '../types.js';
|
|
2
|
+
export declare const REGISTRY_URL = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json";
|
|
3
|
+
type FetchLike = (url: string) => Promise<Response>;
|
|
4
|
+
export declare function __setFetch(f: FetchLike): void;
|
|
5
|
+
export declare function __resetFetch(): void;
|
|
6
|
+
export declare function platformKey(platform?: NodeJS.Platform, arch?: string): string;
|
|
7
|
+
export declare function normalizeRegistry(raw: unknown, platKey?: string): AcpAgentPreset[];
|
|
8
|
+
export declare function fetchAcpRegistry(now?: number): Promise<AcpAgentPreset[]>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/acp/registry.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,YAAY,yEAAyE,CAAC;AAOnG,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAGpD,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAE7C;AACD,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAUD,wBAAgB,WAAW,CACzB,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,IAAI,GAAE,MAAqB,GAC1B,MAAM,CAIR;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,MAAsB,GAAG,cAAc,EAAE,CA4CjG;AAMD,wBAAsB,gBAAgB,CAAC,GAAG,GAAE,MAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CA0B1F"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// ACP Agent Registry client: fetch + normalize + disk cache. The registry is
|
|
2
|
+
// the census of known ACP agents (spec: 2026-08-25-acp-registry-presets);
|
|
3
|
+
// the provider form offers these as presets instead of hand-typed commands.
|
|
4
|
+
import { mkdir, readFile, writeFile, rename } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { dataDir } from '../store/json.js';
|
|
7
|
+
export const REGISTRY_URL = 'https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json';
|
|
8
|
+
const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
9
|
+
/** A CDN that accepts the socket and goes silent must not pin the provider
|
|
10
|
+
* form on "loading presets…" forever (same rationale as NET_TIMEOUT_MS in
|
|
11
|
+
* lib/task_git.ts). */
|
|
12
|
+
const FETCH_TIMEOUT_MS = 15_000;
|
|
13
|
+
const defaultFetch = (url) => fetch(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
14
|
+
let fetchImpl = defaultFetch;
|
|
15
|
+
export function __setFetch(f) {
|
|
16
|
+
fetchImpl = f;
|
|
17
|
+
}
|
|
18
|
+
export function __resetFetch() {
|
|
19
|
+
fetchImpl = defaultFetch;
|
|
20
|
+
}
|
|
21
|
+
/** What the registry does not know: context files an agent self-loads (the
|
|
22
|
+
* fabricated context block must skip them — see the ACP runner spec). */
|
|
23
|
+
const SELF_LOADED = {
|
|
24
|
+
'claude-acp': ['CLAUDE.md'],
|
|
25
|
+
'codex-acp': ['AGENTS.md'],
|
|
26
|
+
gemini: ['GEMINI.md'],
|
|
27
|
+
};
|
|
28
|
+
export function platformKey(platform = process.platform, arch = process.arch) {
|
|
29
|
+
const os = platform === 'win32' ? 'windows' : platform === 'darwin' ? 'darwin' : 'linux';
|
|
30
|
+
const cpu = arch === 'arm64' ? 'aarch64' : 'x86_64';
|
|
31
|
+
return `${os}-${cpu}`;
|
|
32
|
+
}
|
|
33
|
+
export function normalizeRegistry(raw, platKey = platformKey()) {
|
|
34
|
+
const agents = Array.isArray(raw?.agents) ? raw.agents : [];
|
|
35
|
+
const out = [];
|
|
36
|
+
for (const a of agents) {
|
|
37
|
+
if (!a?.id || !a?.name)
|
|
38
|
+
continue;
|
|
39
|
+
const d = a.distribution ?? {};
|
|
40
|
+
let dist = null;
|
|
41
|
+
if (d.npx?.package) {
|
|
42
|
+
// -y: without it, npx prompts "Ok to proceed?" on stdin on first run,
|
|
43
|
+
// which would corrupt the ACP JSON-RPC handshake on the same pipe.
|
|
44
|
+
dist = {
|
|
45
|
+
kind: 'npx',
|
|
46
|
+
command: 'npx',
|
|
47
|
+
args: ['-y', String(d.npx.package), ...(d.npx.args ?? [])],
|
|
48
|
+
...(d.npx.env ? { env: d.npx.env } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
else if (d.uvx?.package) {
|
|
52
|
+
dist = {
|
|
53
|
+
kind: 'uvx',
|
|
54
|
+
command: 'uvx',
|
|
55
|
+
args: [String(d.uvx.package), ...(d.uvx.args ?? [])],
|
|
56
|
+
...(d.uvx.env ? { env: d.uvx.env } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
else if (d.binary?.[platKey]) {
|
|
60
|
+
const b = d.binary[platKey];
|
|
61
|
+
dist = {
|
|
62
|
+
kind: 'binary',
|
|
63
|
+
archive: String(b.archive),
|
|
64
|
+
cmd: String(b.cmd),
|
|
65
|
+
...(b.args ? { args: b.args } : {}),
|
|
66
|
+
...(b.env ? { env: b.env } : {}),
|
|
67
|
+
...(b.sha256 ? { sha256: String(b.sha256) } : {}),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
out.push({
|
|
71
|
+
id: String(a.id),
|
|
72
|
+
name: String(a.name),
|
|
73
|
+
description: String(a.description ?? ''),
|
|
74
|
+
version: String(a.version ?? ''),
|
|
75
|
+
dist,
|
|
76
|
+
selfLoadedContextFiles: SELF_LOADED[a.id] ?? [],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
function cachePath() {
|
|
82
|
+
return join(dataDir(), 'cache', 'acp-registry.json');
|
|
83
|
+
}
|
|
84
|
+
export async function fetchAcpRegistry(now = Date.now()) {
|
|
85
|
+
let cached = null;
|
|
86
|
+
try {
|
|
87
|
+
cached = JSON.parse(await readFile(cachePath(), 'utf8'));
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
/* no cache */
|
|
91
|
+
}
|
|
92
|
+
if (cached && now - cached.fetchedAt < CACHE_TTL_MS)
|
|
93
|
+
return normalizeRegistry(cached.raw);
|
|
94
|
+
try {
|
|
95
|
+
const res = await fetchImpl(REGISTRY_URL);
|
|
96
|
+
if (!res.ok)
|
|
97
|
+
throw new Error(`ACP registry fetch failed: HTTP ${res.status}`);
|
|
98
|
+
const raw = await res.json();
|
|
99
|
+
const list = normalizeRegistry(raw); // validate before caching
|
|
100
|
+
// An agentless 200 (edge error page, half-deployed CDN) must not overwrite
|
|
101
|
+
// a good last-good with an empty census for 24h.
|
|
102
|
+
if (list.length === 0)
|
|
103
|
+
throw new Error('ACP registry returned no agents');
|
|
104
|
+
await mkdir(join(dataDir(), 'cache'), { recursive: true });
|
|
105
|
+
const tmp = `${cachePath()}.tmp-${process.pid}`;
|
|
106
|
+
await writeFile(tmp, JSON.stringify({ fetchedAt: now, raw }), { mode: 0o600 });
|
|
107
|
+
await rename(tmp, cachePath());
|
|
108
|
+
return list;
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
// Last-good: a stale cache beats an error (offline-first).
|
|
112
|
+
if (cached)
|
|
113
|
+
return normalizeRegistry(cached.raw);
|
|
114
|
+
throw err instanceof Error ? err : new Error(String(err));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { Hono } from 'hono';
|
|
2
|
-
export declare function issueBridgeToken(agentId?: string
|
|
2
|
+
export declare function issueBridgeToken(agentId?: string, opts?: {
|
|
3
|
+
exec?: {
|
|
4
|
+
container: string;
|
|
5
|
+
workdir: string;
|
|
6
|
+
};
|
|
7
|
+
execOnly?: boolean;
|
|
8
|
+
}): string;
|
|
3
9
|
export declare function revokeBridgeToken(token: string): void;
|
|
4
10
|
export declare function setTaskBridgeUrl(url: string): void;
|
|
5
11
|
export declare function getTaskBridgeUrl(): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp_bridge.d.ts","sourceRoot":"","sources":["../../../src/cli/web/mcp_bridge.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp_bridge.d.ts","sourceRoot":"","sources":["../../../src/cli/web/mcp_bridge.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAiBjC,wBAAgB,gBAAgB,CAC9B,OAAO,SAAK,EACZ,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAC/E,MAAM,CAIR;AACD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAErD;AAGD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAElD;AACD,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEhD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CA0BlD"}
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
import { randomBytes } from 'node:crypto';
|
|
15
15
|
import { RESPONSE_ALREADY_SENT } from '@hono/node-server/utils/response';
|
|
16
16
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
17
|
-
import { buildBuiltinMcpServer } from '../../mcp/builtin_server.js';
|
|
17
|
+
import { buildBuiltinMcpServer, builtinMcpTools } from '../../mcp/builtin_server.js';
|
|
18
|
+
import { makeRunCommandTool } from '../../mcp/run_command_tool.js';
|
|
18
19
|
import { loadAgents } from '../../store/json.js';
|
|
19
|
-
/** token →
|
|
20
|
+
/** token → token info (agent id, exec binding, exec-only mode). */
|
|
20
21
|
const activeTokens = new Map();
|
|
21
|
-
export function issueBridgeToken(agentId = '') {
|
|
22
|
+
export function issueBridgeToken(agentId = '', opts = {}) {
|
|
22
23
|
const token = randomBytes(24).toString('hex');
|
|
23
|
-
activeTokens.set(token, agentId);
|
|
24
|
+
activeTokens.set(token, { agentId, exec: opts.exec, execOnly: opts.execOnly });
|
|
24
25
|
return token;
|
|
25
26
|
}
|
|
26
27
|
export function revokeBridgeToken(token) {
|
|
@@ -43,11 +44,14 @@ export function registerTaskBridge(app) {
|
|
|
43
44
|
// Resolve the run's agent so ctx.callerAgent is set for the tools that scope
|
|
44
45
|
// by it. A token issued without an agent id (or pointing at a since-deleted
|
|
45
46
|
// agent) leaves it unset, which the email tools treat as an unscoped caller.
|
|
46
|
-
const
|
|
47
|
+
const tokenInfo = activeTokens.get(token);
|
|
48
|
+
const agentId = tokenInfo.agentId;
|
|
47
49
|
const callerAgent = agentId
|
|
48
50
|
? (await loadAgents().catch(() => [])).find((a) => a.id === agentId)
|
|
49
51
|
: undefined;
|
|
50
|
-
const
|
|
52
|
+
const extraTools = tokenInfo.exec ? [makeRunCommandTool(tokenInfo.exec)] : [];
|
|
53
|
+
const tools = tokenInfo.execOnly ? extraTools : [...builtinMcpTools(), ...extraTools];
|
|
54
|
+
const server = buildBuiltinMcpServer(undefined, { callerAgent, tools });
|
|
51
55
|
const transport = new StreamableHTTPServerTransport({
|
|
52
56
|
sessionIdGenerator: undefined, // stateless
|
|
53
57
|
enableJsonResponse: true, // plain JSON responses, no SSE needed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory_sweep.d.ts","sourceRoot":"","sources":["../../../../src/cli/web/scheduler/memory_sweep.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAa/D,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO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gBAAgB,KAAK,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;AAEpF;;;;;;sDAMsD;AACtD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,oBAAoB,GAAG,WAAW,CA8B1E;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;8EAE8E;AAC9E,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,oBAAoB,EAC9B,SAAS,EAAE,WAAW,GACrB,OAAO,CAAC,WAAW,CAAC,CAqJtB;AAMD;6EAC6E;AAC7E,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,IAAI,EACT,iBAAiB,CAAC,EAAE,WAAW,GAC9B,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED,eAAO,MAAM,oBAAoB;aACtB,IAAI;CAKd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task_review.d.ts","sourceRoot":"","sources":["../../../../src/cli/web/scheduler/task_review.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"task_review.d.ts","sourceRoot":"","sources":["../../../../src/cli/web/scheduler/task_review.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AAK5D,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA2BrF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMnE;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB;yEACqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;wDAEoD;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA+EzD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as harness from '../../../harness/index.js';
|
|
2
2
|
import { CLAUDE_CODE_DEFAULT_RUN_SECONDS } from './task_roles.js';
|
|
3
3
|
import { dockerDevAllowlist } from '../../../lib/docker.js';
|
|
4
|
+
import { getTaskBridgeUrl, issueBridgeToken, revokeBridgeToken } from '../mcp_bridge.js';
|
|
4
5
|
export const MAX_REVIEW_ROUNDS = 3;
|
|
5
6
|
export function reviewPrompt(objective, branch, round) {
|
|
6
7
|
return `You are an INDEPENDENT code reviewer. You did not write this code, and your job is to find real problems — not to be agreeable. Do not rubber-stamp.
|
|
@@ -54,6 +55,27 @@ export async function runDoneReview(opts) {
|
|
|
54
55
|
}
|
|
55
56
|
: { permissionMode: 'bypassPermissions' }
|
|
56
57
|
: undefined;
|
|
58
|
+
const isAcp = opts.provider.type === 'acp';
|
|
59
|
+
let acp;
|
|
60
|
+
let reviewBridgeToken;
|
|
61
|
+
if (isAcp) {
|
|
62
|
+
const exec = opts.dockerContainer
|
|
63
|
+
? { container: opts.dockerContainer, workdir: opts.workingDir }
|
|
64
|
+
: undefined;
|
|
65
|
+
let extraMcpServers;
|
|
66
|
+
if (exec) {
|
|
67
|
+
// The reviewer needs shell in the container but must NOT see the task
|
|
68
|
+
// state tools: an exec-only bridge token serves run_command alone.
|
|
69
|
+
const bridgeUrl = getTaskBridgeUrl();
|
|
70
|
+
reviewBridgeToken = bridgeUrl ? issueBridgeToken(opts.agent.id, { exec, execOnly: true }) : undefined;
|
|
71
|
+
if (bridgeUrl && reviewBridgeToken) {
|
|
72
|
+
extraMcpServers = {
|
|
73
|
+
task: { type: 'http', url: bridgeUrl, headers: { Authorization: `Bearer ${reviewBridgeToken}` } },
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
acp = { mode: 'unattended', docker: exec, extraMcpServers };
|
|
78
|
+
}
|
|
57
79
|
// Wall-clock backstop for the review pass, enforced for every provider (the
|
|
58
80
|
// Claude Code CLI has no --max-turns equivalent). Combined with any external
|
|
59
81
|
// signal (a Pause landing mid-review) so either can abort the run.
|
|
@@ -82,6 +104,7 @@ export async function runDoneReview(opts) {
|
|
|
82
104
|
signal,
|
|
83
105
|
dockerContainer: opts.dockerContainer,
|
|
84
106
|
...(claudeCode ? { claudeCode } : {}),
|
|
107
|
+
...(acp ? { acp } : {}),
|
|
85
108
|
}, {
|
|
86
109
|
confirmTool: async () => 'once', // unattended
|
|
87
110
|
});
|
|
@@ -89,5 +112,7 @@ export async function runDoneReview(opts) {
|
|
|
89
112
|
}
|
|
90
113
|
finally {
|
|
91
114
|
clearTimeout(runTimer);
|
|
115
|
+
if (reviewBridgeToken)
|
|
116
|
+
revokeBridgeToken(reviewBridgeToken);
|
|
92
117
|
}
|
|
93
118
|
}
|
|
@@ -5,7 +5,7 @@ export type TaskRole = 'planner' | 'developer' | 'reviewer';
|
|
|
5
5
|
export declare const DEFAULT_RUN_SECONDS = 120;
|
|
6
6
|
export declare const CLAUDE_CODE_DEFAULT_RUN_SECONDS: number;
|
|
7
7
|
/** Resolve the per-invocation budget (seconds): task → project → provider default. */
|
|
8
|
-
export declare function resolveMaxRunSeconds(task: Pick<Task, 'maxRunSeconds'>, project: Pick<ProjectConfig, 'maxRunSeconds'> | null | undefined,
|
|
8
|
+
export declare function resolveMaxRunSeconds(task: Pick<Task, 'maxRunSeconds'>, project: Pick<ProjectConfig, 'maxRunSeconds'> | null | undefined, isExternalRunner: boolean): number;
|
|
9
9
|
/**
|
|
10
10
|
* Resolve the docker image for a task's runs. Phase-1: project-level only, so
|
|
11
11
|
* the task arg is accepted (for a future per-task override tier) but unused.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task_roles.d.ts","sourceRoot":"","sources":["../../../../src/cli/web/scheduler/task_roles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,IAAI,EAAe,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AAE5D,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AAO5D,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,+BAA+B,QAAU,CAAC;AAEvD,sFAAsF;AACtF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EACjC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,eAAe,CAAC,GAAG,IAAI,GAAG,SAAS,EAChE,
|
|
1
|
+
{"version":3,"file":"task_roles.d.ts","sourceRoot":"","sources":["../../../../src/cli/web/scheduler/task_roles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,IAAI,EAAe,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,IA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,GAAG,IAAI,GACjD,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,aAAa,GAAG,SAAS,GACjC,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,CAIhC;AAYD,eAAO,MAAM,qBAAqB,aAKhC,CAAC;AAsBH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,UAAQ,GAAG,IAAI,EAAE,CAOrE"}
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
// developer role; planner/reviewer optionally override and degrade onto it.
|
|
4
4
|
import { runQuery } from '../../../store/db.js';
|
|
5
5
|
// Per-invocation wall-clock budget defaults, in seconds. A run is aborted when
|
|
6
|
-
// it exceeds the resolved budget — for every provider.
|
|
7
|
-
//
|
|
8
|
-
// turn-bounded by agent.maxTurns), so without a generous
|
|
9
|
-
// run would stall the heartbeat (and, for reviews, the review gate).
|
|
6
|
+
// it exceeds the resolved budget — for every provider. External runners
|
|
7
|
+
// (claude-code, acp) get a larger default because they manage their own loop
|
|
8
|
+
// (native runs are also turn-bounded by agent.maxTurns), so without a generous
|
|
9
|
+
// backstop an external runner run would stall the heartbeat (and, for reviews, the review gate).
|
|
10
10
|
export const DEFAULT_RUN_SECONDS = 120;
|
|
11
11
|
export const CLAUDE_CODE_DEFAULT_RUN_SECONDS = 15 * 60;
|
|
12
12
|
/** Resolve the per-invocation budget (seconds): task → project → provider default. */
|
|
13
|
-
export function resolveMaxRunSeconds(task, project,
|
|
13
|
+
export function resolveMaxRunSeconds(task, project, isExternalRunner) {
|
|
14
14
|
const configured = task.maxRunSeconds ?? project?.maxRunSeconds;
|
|
15
15
|
if (typeof configured === 'number' && configured > 0)
|
|
16
16
|
return configured;
|
|
17
|
-
return
|
|
17
|
+
return isExternalRunner ? CLAUDE_CODE_DEFAULT_RUN_SECONDS : DEFAULT_RUN_SECONDS;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Resolve the docker image for a task's runs. Phase-1: project-level only, so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task_strategy.d.ts","sourceRoot":"","sources":["../../../../src/cli/web/scheduler/task_strategy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"task_strategy.d.ts","sourceRoot":"","sources":["../../../../src/cli/web/scheduler/task_strategy.ts"],"names":[],"mappings":"AA0HA,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA4enE"}
|
|
@@ -6,6 +6,7 @@ import { runningTasks, runningTaskControllers, syncingProjects } from './locks.j
|
|
|
6
6
|
import { isGitRepo, ensureWorktree, agentDirIn, commitWip, finalizeDone, runBootstrap, gitCommonDir, syncProjectRepo, projectWorkingDir, pushBranch } from '../../../lib/task_git.js';
|
|
7
7
|
import { runDoneReview, MAX_REVIEW_ROUNDS } from './task_review.js';
|
|
8
8
|
import { claudeCodeTaskExtras } from '../../../harness/claude_code_runner.js';
|
|
9
|
+
import { acpTaskExtras } from '../../../harness/acp_policy.js';
|
|
9
10
|
import { issueBridgeToken, revokeBridgeToken, getTaskBridgeUrl } from '../mcp_bridge.js';
|
|
10
11
|
import { resolveRoleAgent, resolveReviewEnabled, resolveSddEnabled, resolveMaxRunSeconds, filterPlannerTools, resolveDockerImage, } from './task_roles.js';
|
|
11
12
|
import { resolve as resolvePath, dirname } from 'node:path';
|
|
@@ -299,9 +300,10 @@ export async function runTaskHeartbeatTick(now) {
|
|
|
299
300
|
// Max turns: standard sonnet settings or maxTurns
|
|
300
301
|
const maxTurns = agent.maxTurns || 30;
|
|
301
302
|
const isClaudeCode = provider.type === 'claude-code';
|
|
303
|
+
const isAcp = provider.type === 'acp';
|
|
302
304
|
// Per-invocation wall-clock budget (task → project → provider default),
|
|
303
305
|
// enforced below via the abort timer for every provider.
|
|
304
|
-
const maxRunSeconds = resolveMaxRunSeconds(task, project, isClaudeCode);
|
|
306
|
+
const maxRunSeconds = resolveMaxRunSeconds(task, project, isClaudeCode || isAcp);
|
|
305
307
|
// 5. Construct prompt
|
|
306
308
|
const prompt = planning
|
|
307
309
|
? buildPlanningPrompt(agent.systemPrompt, task.id, task.title, maxRunSeconds, maxTurns, workingDir, sdd)
|
|
@@ -311,6 +313,9 @@ export async function runTaskHeartbeatTick(now) {
|
|
|
311
313
|
let effectivePrompt = prompt;
|
|
312
314
|
if (dockerContainer && !planning) {
|
|
313
315
|
let env = `\n\n**Execution environment:** your shell commands run inside a Docker container (image \`${dockerImage}\`) mounted at \`${workingDir}\`. File reads/writes are confined to this directory.`;
|
|
316
|
+
if (isAcp) {
|
|
317
|
+
env += ` Shell commands MUST go through the \`run_command\` tool — direct shell/execute tool calls are denied in this run.`;
|
|
318
|
+
}
|
|
314
319
|
if (!dockerHasGit) {
|
|
315
320
|
env += ` Note: \`git\` is NOT available in this container — do not run git commands (commits are handled automatically for you).`;
|
|
316
321
|
}
|
|
@@ -361,6 +366,7 @@ export async function runTaskHeartbeatTick(now) {
|
|
|
361
366
|
// still call task_get_state/task_submit_plan/etc despite --strict-mcp-config.
|
|
362
367
|
let bridgeToken;
|
|
363
368
|
let claudeCode;
|
|
369
|
+
let acp;
|
|
364
370
|
// Same handle Pause aborts; the wall-clock budget (resolved above) also
|
|
365
371
|
// aborts it. Enforced for every provider — native runs stay additionally
|
|
366
372
|
// turn-bounded by maxTurns.
|
|
@@ -395,6 +401,20 @@ export async function runTaskHeartbeatTick(now) {
|
|
|
395
401
|
console.warn('[tasks] claude-code agent without task bridge URL — task tools unavailable this run');
|
|
396
402
|
}
|
|
397
403
|
}
|
|
404
|
+
if (isAcp) {
|
|
405
|
+
const bridgeUrl = getTaskBridgeUrl();
|
|
406
|
+
const exec = dockerContainer && !planning ? { container: dockerContainer, workdir: workingDir } : undefined;
|
|
407
|
+
bridgeToken = bridgeUrl ? issueBridgeToken(effectiveAgent.id, { exec }) : undefined;
|
|
408
|
+
acp = acpTaskExtras({
|
|
409
|
+
planning,
|
|
410
|
+
sdd,
|
|
411
|
+
bridge: bridgeUrl && bridgeToken ? { url: bridgeUrl, token: bridgeToken } : undefined,
|
|
412
|
+
docker: exec,
|
|
413
|
+
});
|
|
414
|
+
if (!bridgeUrl) {
|
|
415
|
+
console.warn('[tasks] acp agent without task bridge URL — task tools unavailable this run');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
398
418
|
try {
|
|
399
419
|
await harness.run({
|
|
400
420
|
agent: effectiveAgent,
|
|
@@ -407,6 +427,7 @@ export async function runTaskHeartbeatTick(now) {
|
|
|
407
427
|
// the recall block gets the project scope explicitly.
|
|
408
428
|
memoryProjectId: task.projectId,
|
|
409
429
|
claudeCode,
|
|
430
|
+
acp,
|
|
410
431
|
dockerContainer,
|
|
411
432
|
signal,
|
|
412
433
|
}, {
|
|
@@ -561,7 +582,7 @@ async function pushOrBlock(task, project) {
|
|
|
561
582
|
}
|
|
562
583
|
async function runReviewCycle(opts) {
|
|
563
584
|
const { task, project, agent, provider, tools, workingDir, signal, dockerContainer, dockerHasGit } = opts;
|
|
564
|
-
const maxRunSeconds = resolveMaxRunSeconds(task, project, provider.type === 'claude-code');
|
|
585
|
+
const maxRunSeconds = resolveMaxRunSeconds(task, project, provider.type === 'claude-code' || provider.type === 'acp');
|
|
565
586
|
if (!task.worktreePath)
|
|
566
587
|
return; // reviewing implies a worktree; nothing to review otherwise
|
|
567
588
|
// Review gate disabled (task or project level): finalize directly, no review.
|
package/dist/cli/web/server.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/cli/web/server.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AA0ClD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAgC,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3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,CAAC,IAAI,EAAE,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;IAMH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,eAAe,IAAI,GAAG;IAIhB,KAAK,CACT,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,aAAa,EACjB,cAAc,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,EACtE,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,IAAI,CAAC;IAgFhB,KAAK,IAAI,IAAI;CAGd;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqpC3E"}
|
package/dist/cli/web/server.js
CHANGED
|
@@ -25,6 +25,7 @@ import { fsRouter } from './fs.js';
|
|
|
25
25
|
import { activationStatus, resolvePlanningEnabled } from './scheduler/task_roles.js';
|
|
26
26
|
import { registerVoiceProxy, voiceClientConfig, fetchVoiceCatalog } from './voice_proxy.js';
|
|
27
27
|
import { registerVoiceBackend, maybeAutoStartBackend } from './voice_backend.js';
|
|
28
|
+
import { fetchAcpRegistry, installAcpAgent } from '../../acp/index.js';
|
|
28
29
|
// Resolve Webview static files path.
|
|
29
30
|
// Published npm package ships the assets under dist/webview (see scripts/copy-webview.mjs);
|
|
30
31
|
// in the monorepo dev tree they live in the sibling webview-ui package.
|
|
@@ -37,11 +38,11 @@ export class WebSessionController {
|
|
|
37
38
|
metaRecord = null;
|
|
38
39
|
history = [];
|
|
39
40
|
inflight = null;
|
|
40
|
-
|
|
41
|
+
confirmGate;
|
|
41
42
|
sessionId;
|
|
42
43
|
constructor(opts) {
|
|
43
44
|
this.opts = opts;
|
|
44
|
-
this.
|
|
45
|
+
this.confirmGate = new harness.ConfirmGateState(opts.provider.type, opts.agent.confirmTools);
|
|
45
46
|
this.sessionId = opts.sessionId;
|
|
46
47
|
}
|
|
47
48
|
get isRunning() {
|
|
@@ -105,11 +106,10 @@ export class WebSessionController {
|
|
|
105
106
|
onToolCall: cb.onToolCall,
|
|
106
107
|
onToolResult: cb.onToolResult,
|
|
107
108
|
confirmTool: async (id, name, args) => {
|
|
108
|
-
if (!this.
|
|
109
|
+
if (!this.confirmGate.needsAsk(name))
|
|
109
110
|
return 'once';
|
|
110
111
|
const decision = await cb.askConfirm(id, name, args);
|
|
111
|
-
|
|
112
|
-
this.confirmSet.delete(name);
|
|
112
|
+
this.confirmGate.remember(name, decision);
|
|
113
113
|
return decision;
|
|
114
114
|
},
|
|
115
115
|
onMessage: async (msg) => {
|
|
@@ -1209,6 +1209,28 @@ export async function startServer(port, host) {
|
|
|
1209
1209
|
});
|
|
1210
1210
|
}
|
|
1211
1211
|
return;
|
|
1212
|
+
case 'fetchAcpRegistry':
|
|
1213
|
+
try {
|
|
1214
|
+
const agents = await fetchAcpRegistry();
|
|
1215
|
+
post({ type: 'acpRegistryFetched', result: { ok: true, agents } });
|
|
1216
|
+
}
|
|
1217
|
+
catch (err) {
|
|
1218
|
+
post({ type: 'acpRegistryFetched', result: { ok: false, error: String(err) } });
|
|
1219
|
+
}
|
|
1220
|
+
return;
|
|
1221
|
+
case 'installAcpAgent':
|
|
1222
|
+
try {
|
|
1223
|
+
const agents = await fetchAcpRegistry();
|
|
1224
|
+
const preset = agents.find((a) => a.id === msg.agentId);
|
|
1225
|
+
if (!preset)
|
|
1226
|
+
throw new Error(`unknown ACP agent "${msg.agentId}"`);
|
|
1227
|
+
const installed = await installAcpAgent(preset, (line) => post({ type: 'acpInstallProgress', agentId: msg.agentId, line }));
|
|
1228
|
+
post({ type: 'acpInstallResult', agentId: msg.agentId, ok: true, ...installed });
|
|
1229
|
+
}
|
|
1230
|
+
catch (err) {
|
|
1231
|
+
post({ type: 'acpInstallResult', agentId: msg.agentId, ok: false, error: String(err) });
|
|
1232
|
+
}
|
|
1233
|
+
return;
|
|
1212
1234
|
case 'fetchVoiceModels':
|
|
1213
1235
|
try {
|
|
1214
1236
|
const catalog = await fetchVoiceCatalog(msg.endpoint, msg.apiKey ?? null);
|