@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,13 @@
|
|
|
1
|
+
import type { Tool } from '../harness/tools/index.js';
|
|
2
|
+
type ExecFn = (cmd: string, args: string[], opts: object) => Promise<{
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function __setExec(fn: ExecFn): void;
|
|
7
|
+
export declare function __resetExec(): void;
|
|
8
|
+
export declare function makeRunCommandTool(bind: {
|
|
9
|
+
container: string;
|
|
10
|
+
workdir: string;
|
|
11
|
+
}): Tool;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=run_command_tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run_command_tool.d.ts","sourceRoot":"","sources":["../../src/mcp/run_command_tool.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAOtD,KAAK,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAGzG,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE1C;AACD,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAMD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA+BrF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Per-task shell tool for ACP runs under Docker confinement: the ACP policy
|
|
2
|
+
// denies every kind:'execute' tool call, and this bridge-injected tool is the
|
|
3
|
+
// only shell path — confined to the task's container by construction. Built
|
|
4
|
+
// per token (bound container), so it is never part of the registry and never
|
|
5
|
+
// served by the stdio `caretaker-cli mcp` server (no container to bind there).
|
|
6
|
+
import { execFile } from 'node:child_process';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
8
|
+
import { containerExecArgs } from '../lib/docker.js';
|
|
9
|
+
import { commandEnv } from '../harness/tools/builtin/shell-env.js';
|
|
10
|
+
const TIMEOUT_MS = 5 * 60_000;
|
|
11
|
+
const MAX_OUTPUT_CHARS = 30_000;
|
|
12
|
+
const realExec = promisify(execFile);
|
|
13
|
+
let execImpl = realExec;
|
|
14
|
+
export function __setExec(fn) {
|
|
15
|
+
execImpl = fn;
|
|
16
|
+
}
|
|
17
|
+
export function __resetExec() {
|
|
18
|
+
execImpl = realExec;
|
|
19
|
+
}
|
|
20
|
+
function cap(s) {
|
|
21
|
+
return s.length > MAX_OUTPUT_CHARS ? s.slice(0, MAX_OUTPUT_CHARS) + '\n…[truncated]' : s;
|
|
22
|
+
}
|
|
23
|
+
export function makeRunCommandTool(bind) {
|
|
24
|
+
return {
|
|
25
|
+
name: 'mcp__task__run_command',
|
|
26
|
+
description: "Run a shell command inside this task's Docker container (the only way to execute " +
|
|
27
|
+
'commands in this run — direct shell tool calls are denied). Runs from the task ' +
|
|
28
|
+
`working directory. 5-minute timeout, output capped at ${MAX_OUTPUT_CHARS} chars.`,
|
|
29
|
+
parameters: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
command: { type: 'string', description: 'The shell command to run (sh -c syntax).' },
|
|
33
|
+
},
|
|
34
|
+
required: ['command'],
|
|
35
|
+
},
|
|
36
|
+
execute: async (args) => {
|
|
37
|
+
const command = String(args?.command ?? '').trim();
|
|
38
|
+
if (!command)
|
|
39
|
+
return { content: 'Error: command is required' };
|
|
40
|
+
try {
|
|
41
|
+
const { stdout, stderr } = await execImpl('docker', containerExecArgs(bind.container, bind.workdir, command), { env: commandEnv(), timeout: TIMEOUT_MS, maxBuffer: 10 * 1024 * 1024 });
|
|
42
|
+
return { content: cap([stdout, stderr].filter(Boolean).join('\n')) || '(no output)' };
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
const out = [err?.stdout, err?.stderr].filter(Boolean).join('\n');
|
|
46
|
+
const code = err?.code ?? 'unknown';
|
|
47
|
+
return { content: cap(`Error: exit code ${code}\n${out || err?.message || ''}`) };
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
package/dist/session/store.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare function updateTitle(meta: Pick<SessionMetaRecord, 'agentId' | 'i
|
|
|
42
42
|
/** Persist the Claude Code session id by appending a fresh meta line
|
|
43
43
|
* (readSession picks the latest meta; listForAgent keeps using the first). */
|
|
44
44
|
export declare function updateClaudeSessionId(meta: Pick<SessionMetaRecord, 'agentId' | 'id'>, claudeSessionId: string): Promise<void>;
|
|
45
|
+
export declare function updateAcpSessionId(meta: Pick<SessionMetaRecord, 'agentId' | 'id'>, acpSessionId: string): Promise<void>;
|
|
45
46
|
export declare function deleteSession(agentId: string, sessionId: string): Promise<void>;
|
|
46
47
|
export declare function userMessage(content: string, opts?: {
|
|
47
48
|
id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/session/store.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,iBAAS,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED,iBAAS,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/D;AAmDD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4EAA4E;AAC5E,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAczF;AAED,gFAAgF;AAChF,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,GAAG,IAAI,CAAC,EAC/C,MAAM,EAAE,aAA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aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKrF;AAID,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAA;CAAE,GAC/E,aAAa,CAUf;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EAAE,EACtB,KAAK,CAAC,EAAE,cAAc,EACtB,IAAI,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,aAAa,CAYf;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnF;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,oBAAoB,EAAE,EACpC,IAAI,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,aAAa,CAWf;AAID,eAAO,MAAM,YAAY;;;;CAA2C,CAAC"}
|
package/dist/session/store.js
CHANGED
|
@@ -205,6 +205,12 @@ export async function updateClaudeSessionId(meta, claudeSessionId) {
|
|
|
205
205
|
const path = sessionPath(meta.agentId, meta.id);
|
|
206
206
|
await appendFile(path, serialize(record), { mode: 0o600 });
|
|
207
207
|
}
|
|
208
|
+
export async function updateAcpSessionId(meta, acpSessionId) {
|
|
209
|
+
const current = await readSession(meta.agentId, meta.id);
|
|
210
|
+
const record = { ...current.meta, acpSessionId };
|
|
211
|
+
const path = sessionPath(meta.agentId, meta.id);
|
|
212
|
+
await appendFile(path, serialize(record), { mode: 0o600 });
|
|
213
|
+
}
|
|
208
214
|
export async function deleteSession(agentId, sessionId) {
|
|
209
215
|
const path = sessionPath(agentId, sessionId);
|
|
210
216
|
await rm(path, { force: true });
|
package/dist/session/types.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export interface SessionMetaRecord {
|
|
|
27
27
|
/** Claude Code CLI session id for claude-code runner agents; the next
|
|
28
28
|
* turn resumes it via `claude -p --resume <id>`. */
|
|
29
29
|
claudeSessionId?: string;
|
|
30
|
+
/** ACP session id for acp runner agents; reused across turns and offered
|
|
31
|
+
* to session/load when the agent supports it. */
|
|
32
|
+
acpSessionId?: string;
|
|
30
33
|
}
|
|
31
34
|
export type Role = 'user' | 'assistant' | 'tool';
|
|
32
35
|
export interface ToolAttachmentRecord {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/session/types.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,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GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX;;2DAEuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,aAAa,CAAC;AAE9D,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B"}
|
package/dist/tui/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/tui/agents.tsx"],"names":[],"mappings":"AAoCA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/tui/agents.tsx"],"names":[],"mappings":"AAoCA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,2CA+XhE"}
|
package/dist/tui/agents.js
CHANGED
|
@@ -195,8 +195,10 @@ export default function Agents({ onBack }) {
|
|
|
195
195
|
}
|
|
196
196
|
if (mode === 'detail' && selected) {
|
|
197
197
|
const managed = !!selected.pluginId;
|
|
198
|
-
const
|
|
199
|
-
|
|
198
|
+
const providerType = providers.find((p) => p.name === selected.provider)?.type ?? 'openai';
|
|
199
|
+
const isClaudeCode = providerType === 'claude-code';
|
|
200
|
+
const isAcp = providerType === 'acp';
|
|
201
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, children: selected.name }), managed && (_jsx(Text, { color: "cyan", children: "[managed by plugin \u00B7 name + system prompt come from the manifest]" })), _jsxs(Text, { children: ["provider: ", selected.provider] }), _jsxs(Text, { children: ["model: ", selected.model] }), isClaudeCode ? (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["permissionMode: ", selected.permissionMode || 'Auto (Claude Code default)'] }), _jsxs(Text, { children: ["strictMcp: ", selected.strictMcp ? 'on' : 'off (merge ~/.claude MCP)'] })] })) : isAcp ? (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["acpMode: ", selected.acpMode || '(none)'] }), _jsx(Text, { dimColor: true, children: "ACP agent \u2014 tools and permissions are the agent's own" })] })) : (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["maxTurns: ", selected.maxTurns === 0 ? 'unlimited' : selected.maxTurns] }), _jsxs(Text, { children: ["tools:", ' ', selected.allowedTools.length === 0
|
|
200
202
|
? '(none)'
|
|
201
203
|
: formatToolsForDetail(selected.allowedTools, selected.confirmTools ?? [])] }), _jsxs(Text, { children: ["plugins:", ' ', (selected.plugins ?? []).length === 0 ? '(none)' : selected.plugins.join(', ')] })] })), _jsxs(Text, { children: ["mcp: ", (selected.mcpServers ?? []).length === 0 ? '(none)' : selected.mcpServers.length, ' ', "server(s)"] }), _jsxs(Text, { children: ["workDir: ", selected.workingDir || '(cwd)'] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "system prompt:" }), _jsx(Text, { children: selected.systemPrompt || '(empty)' })] }), _jsx(Box, { marginTop: 1, children: _jsx(SelectInput, { items: [
|
|
202
204
|
{ label: 'New chat', value: 'new-chat' },
|
|
@@ -275,19 +277,24 @@ function namespacedToolList(allTools) {
|
|
|
275
277
|
})),
|
|
276
278
|
];
|
|
277
279
|
}
|
|
278
|
-
// Computes the step sequence for a given form flavor, so
|
|
279
|
-
// skip
|
|
280
|
-
// place instead of scattered across
|
|
281
|
-
|
|
280
|
+
// Computes the step sequence for a given form flavor, so the external-runner
|
|
281
|
+
// branching (claude-code, acp: skip tools/plugins/maxTurns; claude-code adds
|
|
282
|
+
// permissionMode/strictMcp) lives in one place instead of scattered across
|
|
283
|
+
// every transition.
|
|
284
|
+
function stepSequence(managed, flavor) {
|
|
282
285
|
const seq = [];
|
|
283
286
|
if (!managed)
|
|
284
287
|
seq.push('name');
|
|
285
288
|
seq.push('provider', 'model');
|
|
286
289
|
if (!managed)
|
|
287
290
|
seq.push('systemPrompt');
|
|
288
|
-
if (
|
|
291
|
+
if (flavor === 'claude-code') {
|
|
289
292
|
seq.push('mcpServers', 'workingDir', 'permissionMode', 'strictMcp');
|
|
290
293
|
}
|
|
294
|
+
else if (flavor === 'acp') {
|
|
295
|
+
// acp agents own their tools/permissions; acpMode is the last step.
|
|
296
|
+
seq.push('mcpServers', 'workingDir', 'acpMode');
|
|
297
|
+
}
|
|
291
298
|
else {
|
|
292
299
|
seq.push('tools', 'plugins', 'mcpServers', 'workingDir', 'maxTurns');
|
|
293
300
|
}
|
|
@@ -301,11 +308,15 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
|
|
|
301
308
|
const [step, setStep] = useState(managed ? 'provider' : 'name');
|
|
302
309
|
const [name, setName] = useState(initial?.name ?? '');
|
|
303
310
|
const [provider, setProvider] = useState(initial?.provider ?? '');
|
|
304
|
-
const
|
|
311
|
+
const providerType = providers.find((p) => p.name === provider)?.type ?? 'openai';
|
|
312
|
+
const isClaudeCode = providerType === 'claude-code';
|
|
313
|
+
const isAcp = providerType === 'acp';
|
|
314
|
+
const isExternalRunner = isClaudeCode || isAcp;
|
|
305
315
|
const [model, setModel] = useState(initial?.model ?? '');
|
|
306
316
|
const [systemPrompt, setSystemPrompt] = useState(initial?.systemPrompt ?? '');
|
|
307
317
|
const [permissionMode, setPermissionMode] = useState(initial?.permissionMode ?? '');
|
|
308
318
|
const [strictMcp, setStrictMcp] = useState(initial?.strictMcp ?? false);
|
|
319
|
+
const [acpMode, setAcpMode] = useState(initial?.acpMode ?? '');
|
|
309
320
|
// The picker offers one entry per `mcp__<ns>__` namespace (task, email, …),
|
|
310
321
|
// not the individual tools, so a stored per-tool selection is collapsed onto
|
|
311
322
|
// the wildcard. resolveAgentTools expands it back at run time.
|
|
@@ -341,16 +352,17 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
|
|
|
341
352
|
onCancel();
|
|
342
353
|
});
|
|
343
354
|
// Step sequence computed as a filtered array (rather than scattering
|
|
344
|
-
//
|
|
345
|
-
// tools/plugins/maxTurns
|
|
346
|
-
const steps = stepSequence(managed,
|
|
355
|
+
// provider-type conditionals across every transition): external runners skip
|
|
356
|
+
// tools/plugins/maxTurns; claude-code gets a permissionMode step instead.
|
|
357
|
+
const steps = stepSequence(managed, providerType);
|
|
347
358
|
const nextAfter = (s) => {
|
|
348
359
|
const idx = steps.indexOf(s);
|
|
349
360
|
return idx >= 0 && idx + 1 < steps.length ? steps[idx + 1] : s;
|
|
350
361
|
};
|
|
351
|
-
const finalize = (n, permissionModeOverride, strictMcpOverride) => {
|
|
362
|
+
const finalize = (n, permissionModeOverride, strictMcpOverride, acpModeOverride) => {
|
|
352
363
|
const pm = permissionModeOverride ?? permissionMode;
|
|
353
364
|
const sm = strictMcpOverride ?? strictMcp;
|
|
365
|
+
const am = acpModeOverride ?? acpMode;
|
|
354
366
|
const a = {
|
|
355
367
|
id: initial?.id ?? randomUUID(),
|
|
356
368
|
name: name.trim(),
|
|
@@ -365,6 +377,7 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
|
|
|
365
377
|
...(workingDir.trim() ? { workingDir: workingDir.trim() } : {}),
|
|
366
378
|
...(isClaudeCode && pm ? { permissionMode: pm } : {}),
|
|
367
379
|
...(isClaudeCode && sm ? { strictMcp: true } : {}),
|
|
380
|
+
...(isAcp && am.trim() ? { acpMode: am.trim() } : {}),
|
|
368
381
|
// Preserve plugin-managed origin tags so the next sync recognizes
|
|
369
382
|
// this row instead of orphaning it.
|
|
370
383
|
...(initial?.pluginId ? { pluginId: initial.pluginId } : {}),
|
|
@@ -403,8 +416,18 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
|
|
|
403
416
|
if (v && !isAbsolute(v))
|
|
404
417
|
return setError('workingDir must be an absolute path (or empty for cwd)');
|
|
405
418
|
setError(null);
|
|
419
|
+
if (steps[steps.length - 1] === 'workingDir') {
|
|
420
|
+
// acp flavor: workingDir is the last step — no maxTurns to collect.
|
|
421
|
+
const n = Number.parseInt(maxTurns.trim(), 10);
|
|
422
|
+
finalize(Number.isFinite(n) && n >= 0 ? n : 30);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
406
425
|
setStep(nextAfter('workingDir'));
|
|
407
426
|
}
|
|
427
|
+
else if (step === 'acpMode') {
|
|
428
|
+
const n = Number.parseInt(maxTurns.trim(), 10);
|
|
429
|
+
finalize(Number.isFinite(n) && n >= 0 ? n : 30);
|
|
430
|
+
}
|
|
408
431
|
else if (step === 'maxTurns') {
|
|
409
432
|
const n = Number.parseInt(maxTurns.trim(), 10);
|
|
410
433
|
if (!Number.isFinite(n) || n < 0)
|
|
@@ -420,10 +443,10 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
|
|
|
420
443
|
setModel(id);
|
|
421
444
|
setError(null);
|
|
422
445
|
setStep(nextAfter('model'));
|
|
423
|
-
} })) : ['name', 'provider'].includes(step) ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: model }))] }), _jsxs(Box, { children: [_jsx(Text, { children: "prompt: " }), managed ? (_jsxs(Text, { children: [_jsxs(Text, { children: [(systemPrompt || '(empty)').slice(0, 80), systemPrompt.length > 80 ? '…' : ''] }), _jsx(Text, { dimColor: true, children: ' (managed by plugin)' })] })) : step === 'systemPrompt' ? (_jsx(TextInput, { value: systemPrompt, onChange: setSystemPrompt, onSubmit: advance, placeholder: isEdit ? '(enter to keep current)' : '(optional system prompt)' })) : ['name', 'provider', 'model'].includes(step) ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: systemPrompt || '(empty)' }))] }), !
|
|
446
|
+
} })) : ['name', 'provider'].includes(step) ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: model }))] }), _jsxs(Box, { children: [_jsx(Text, { children: "prompt: " }), managed ? (_jsxs(Text, { children: [_jsxs(Text, { children: [(systemPrompt || '(empty)').slice(0, 80), systemPrompt.length > 80 ? '…' : ''] }), _jsx(Text, { dimColor: true, children: ' (managed by plugin)' })] })) : step === 'systemPrompt' ? (_jsx(TextInput, { value: systemPrompt, onChange: setSystemPrompt, onSubmit: advance, placeholder: isEdit ? '(enter to keep current)' : '(optional system prompt)' })) : ['name', 'provider', 'model'].includes(step) ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: systemPrompt || '(empty)' }))] }), !isExternalRunner && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "tools:" }), step === 'tools' ? (_jsx(ToolPicker, { tools: namespacedToolList(toolRegistry.list()), allowed: allowedTools, confirm: confirmTools, onChange: (a, c) => {
|
|
424
447
|
setAllowedTools(a);
|
|
425
448
|
setConfirmTools(c);
|
|
426
|
-
}, onSubmit: advance })) : ['name', 'provider', 'model', 'systemPrompt'].includes(step) ? (_jsx(Text, { dimColor: true, children: " (pending)" })) : (_jsx(Text, { children: ` ${allowedTools.length === 0 ? '(none)' : formatToolsForDetail(allowedTools, confirmTools)}` }))] })), !
|
|
449
|
+
}, onSubmit: advance })) : ['name', 'provider', 'model', 'systemPrompt'].includes(step) ? (_jsx(Text, { dimColor: true, children: " (pending)" })) : (_jsx(Text, { children: ` ${allowedTools.length === 0 ? '(none)' : formatToolsForDetail(allowedTools, confirmTools)}` }))] })), !isExternalRunner && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "plugins:" }), step === 'plugins' ? (_jsx(PluginPicker, { plugins: discoveredPlugins, value: activePlugins, onChange: setActivePlugins, onSubmit: advance })) : ['name', 'provider', 'model', 'systemPrompt', 'tools'].includes(step) ? (_jsx(Text, { dimColor: true, children: " (pending)" })) : (_jsx(Text, { children: ` ${activePlugins.length === 0 ? '(none)' : activePlugins.join(', ')}` }))] })), _jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "mcp:" }), step === 'mcpServers' ? (_jsx(McpPicker, { servers: mcpServers, value: activeMcp, onChange: setActiveMcp, onSubmit: advance })) : ['name', 'provider', 'model', 'systemPrompt', 'tools', 'plugins'].includes(step) ? (_jsx(Text, { dimColor: true, children: " (pending)" })) : (_jsx(Text, { children: ` ${activeMcp.length === 0
|
|
427
450
|
? '(none)'
|
|
428
451
|
: activeMcp.map((id) => mcpServers.find((s) => s.id === id)?.name ?? id).join(', ')}` }))] }), _jsxs(Box, { children: [_jsx(Text, { children: "workDir: " }), step === 'workingDir' ? (_jsx(TextInput, { value: workingDir, onChange: setWorkingDir, onSubmit: advance, placeholder: "(empty = process.cwd() \u2014 absolute path otherwise)" })) : [
|
|
429
452
|
'name',
|
|
@@ -433,7 +456,7 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
|
|
|
433
456
|
'tools',
|
|
434
457
|
'plugins',
|
|
435
458
|
'mcpServers',
|
|
436
|
-
].includes(step) ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: workingDir.trim() || '(cwd)' }))] }), !
|
|
459
|
+
].includes(step) ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: workingDir.trim() || '(cwd)' }))] }), !isExternalRunner && (_jsxs(Box, { children: [_jsx(Text, { children: "maxTurns: " }), step === 'maxTurns' ? (_jsx(TextInput, { value: maxTurns, onChange: setMaxTurns, onSubmit: advance, placeholder: "0 = unlimited" })) : (_jsx(Text, { dimColor: true, children: "(pending)" }))] })), isClaudeCode && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "permissionMode: " }), step === 'permissionMode' ? (_jsx(SelectInput, { items: [
|
|
437
460
|
{ label: 'Auto (Claude Code default)', value: '' },
|
|
438
461
|
...CLAUDE_CODE_PERMISSION_MODES.map((m) => ({ label: m, value: m })),
|
|
439
462
|
], initialIndex: permissionMode
|
|
@@ -451,16 +474,21 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
|
|
|
451
474
|
setError(null);
|
|
452
475
|
const n = Number.parseInt(maxTurns.trim(), 10);
|
|
453
476
|
finalize(Number.isFinite(n) && n >= 0 ? n : 30, undefined, val);
|
|
454
|
-
} })) : step === 'permissionMode' ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: strictMcp ? 'on' : 'off' }))] })),
|
|
477
|
+
} })) : step === 'permissionMode' ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: strictMcp ? 'on' : 'off' }))] })), isAcp && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "acpMode: " }), step === 'acpMode' ? (_jsx(TextInput, { value: acpMode, onChange: setAcpMode, onSubmit: (val) => {
|
|
478
|
+
const n = Number.parseInt(maxTurns.trim(), 10);
|
|
479
|
+
finalize(Number.isFinite(n) && n >= 0 ? n : 30, undefined, undefined, val);
|
|
480
|
+
}, placeholder: "optional \u2014 e.g. acceptEdits | bypassPermissions" })) : steps.indexOf(step) < steps.indexOf('acpMode') ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: acpMode || '(none)' })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Pins the agent to one of its own session modes at start (session/set_mode)." }) })] })), error && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "red", children: error }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "(esc to cancel)" }) })] }));
|
|
455
481
|
}
|
|
456
482
|
function ModelStep({ provider, initialModel, onPick, }) {
|
|
457
483
|
const isClaudeCode = provider.type === 'claude-code';
|
|
458
|
-
const
|
|
484
|
+
const isAcp = provider.type === 'acp';
|
|
485
|
+
const isExternalRunner = isClaudeCode || isAcp;
|
|
486
|
+
const [state, setState] = useState(isExternalRunner ? { mode: 'manual', reason: null } : { mode: 'loading' });
|
|
459
487
|
const [manualValue, setManualValue] = useState(initialModel ?? '');
|
|
460
488
|
useEffect(() => {
|
|
461
|
-
// claude-code
|
|
462
|
-
// endpoint — always go straight to manual entry.
|
|
463
|
-
if (
|
|
489
|
+
// External-runner providers (claude-code, acp) never expose an OpenAI-style
|
|
490
|
+
// model-listing endpoint — always go straight to manual entry.
|
|
491
|
+
if (isExternalRunner)
|
|
464
492
|
return;
|
|
465
493
|
let cancelled = false;
|
|
466
494
|
void fetchOpenAiStyleModels(provider.endpoint, provider.apiKey ?? null).then((res) => {
|
|
@@ -479,16 +507,22 @@ function ModelStep({ provider, initialModel, onPick, }) {
|
|
|
479
507
|
return () => {
|
|
480
508
|
cancelled = true;
|
|
481
509
|
};
|
|
482
|
-
}, [
|
|
510
|
+
}, [isExternalRunner, provider.endpoint, provider.apiKey]);
|
|
483
511
|
if (state.mode === 'loading') {
|
|
484
512
|
return _jsxs(Text, { dimColor: true, children: ["fetching models from ", provider.name, "\u2026"] });
|
|
485
513
|
}
|
|
486
514
|
if (state.mode === 'manual') {
|
|
487
515
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(TextInput, { value: manualValue, onChange: setManualValue, onSubmit: () => {
|
|
488
516
|
const v = manualValue.trim();
|
|
489
|
-
|
|
517
|
+
// acp: the agent server picks its own model — the field is only an
|
|
518
|
+
// optional label (shown in task threads), so empty is fine.
|
|
519
|
+
if (v || isAcp)
|
|
490
520
|
onPick(v);
|
|
491
|
-
}, placeholder: isClaudeCode
|
|
521
|
+
}, placeholder: isClaudeCode
|
|
522
|
+
? 'sonnet | opus | haiku (or full model id)'
|
|
523
|
+
: isAcp
|
|
524
|
+
? 'optional — label shown in task threads'
|
|
525
|
+
: 'e.g. gpt-4o-mini' }), state.reason && (_jsx(Text, { dimColor: true, color: "yellow", children: state.reason.slice(0, 200) }))] }));
|
|
492
526
|
}
|
|
493
527
|
const items = [
|
|
494
528
|
...state.ids.map((id) => ({ label: id, value: `m:${id}` })),
|
package/dist/tui/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/tui/chat.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/tui/chat.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAgC,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI/D,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,cAAc,EACd,MAAM,GACP,EAAE;IACD,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,8FAA8F;IAC9F,cAAc,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,2CAsSA"}
|
package/dist/tui/chat.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Box, Text, useInput } from 'ink';
|
|
|
4
4
|
import SelectInput from 'ink-select-input';
|
|
5
5
|
import TextInput from 'ink-text-input';
|
|
6
6
|
import { run } from '../harness/loop.js';
|
|
7
|
+
import { ConfirmGateState } from '../harness/confirm_gate.js';
|
|
7
8
|
import { tools as toolRegistry } from '../harness/tools/instance.js';
|
|
8
9
|
import { resolveAgentTools } from '../harness/tools/index.js';
|
|
9
10
|
import { expandTemplate, parseSlashInvocation, resolveCommand } from '../commands/loader.js';
|
|
@@ -21,10 +22,10 @@ export default function ChatScreen({ agent, provider, initialSession, onBack, })
|
|
|
21
22
|
const abortRef = useRef(null);
|
|
22
23
|
const titleAbortRef = useRef(null);
|
|
23
24
|
const titlePendingRef = useRef(false);
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
const
|
|
25
|
+
// Confirm-gate state: native/claude-code agents prompt only for
|
|
26
|
+
// agent.confirmTools names; ACP agents prompt on every permission request
|
|
27
|
+
// the agent raises. "always" is remembered in-memory only.
|
|
28
|
+
const confirmGateRef = useRef(new ConfirmGateState(provider.type, agent.confirmTools));
|
|
28
29
|
const [pendingConfirm, setPendingConfirm] = useState(null);
|
|
29
30
|
useEffect(() => {
|
|
30
31
|
if (!initialSession)
|
|
@@ -133,7 +134,7 @@ export default function ChatScreen({ agent, provider, initialSession, onBack, })
|
|
|
133
134
|
onChunk: (s) => setLiveText((prev) => prev + s),
|
|
134
135
|
onThinking: (s) => setLiveThinking((prev) => prev + s),
|
|
135
136
|
confirmTool: (id, name, args) => new Promise((resolve) => {
|
|
136
|
-
if (!
|
|
137
|
+
if (!confirmGateRef.current.needsAsk(name)) {
|
|
137
138
|
resolve('once');
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
@@ -208,9 +209,7 @@ export default function ChatScreen({ agent, provider, initialSession, onBack, })
|
|
|
208
209
|
{ label: 'Reject', value: 'reject' },
|
|
209
210
|
], onSelect: (item) => {
|
|
210
211
|
const decision = item.value;
|
|
211
|
-
|
|
212
|
-
confirmSetRef.current.delete(pendingConfirm.name);
|
|
213
|
-
}
|
|
212
|
+
confirmGateRef.current.remember(pendingConfirm.name, decision);
|
|
214
213
|
pendingConfirm.resolve(decision);
|
|
215
214
|
setPendingConfirm(null);
|
|
216
215
|
} }) })] })), mode === 'running' && !pendingConfirm && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "(running\u2026 esc to abort)" }) })), _jsx(ContextBar, { messages: messages, model: agent.model })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/tui/providers.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/tui/providers.tsx"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,2CAmLnE"}
|
package/dist/tui/providers.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Box, Text, useInput } from 'ink';
|
|
|
4
4
|
import SelectInput from 'ink-select-input';
|
|
5
5
|
import TextInput from 'ink-text-input';
|
|
6
6
|
import { loadAgents, loadConfig, saveConfig } from '../store/json.js';
|
|
7
|
+
import { fetchAcpRegistry } from '../acp/index.js';
|
|
7
8
|
export default function Providers({ onBack }) {
|
|
8
9
|
const [providers, setProviders] = useState([]);
|
|
9
10
|
const [loaded, setLoaded] = useState(false);
|
|
@@ -67,8 +68,7 @@ export default function Providers({ onBack }) {
|
|
|
67
68
|
} }) })] }));
|
|
68
69
|
}
|
|
69
70
|
if (mode === 'detail' && selected) {
|
|
70
|
-
|
|
71
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, children: selected.name }), isClaudeCode ? (_jsxs(_Fragment, { children: [_jsx(Text, { children: "type: claude-code" }), _jsxs(Text, { children: ["command: ", selected.command || '(default: claude on PATH)'] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["endpoint: ", selected.endpoint] }), _jsxs(Text, { children: ["apiKey: ", selected.apiKey ? '(set)' : '(none)'] })] })), _jsx(Box, { marginTop: 1, children: _jsx(SelectInput, { items: [
|
|
71
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, children: selected.name }), selected.type === 'acp' ? (_jsxs(_Fragment, { children: [_jsx(Text, { children: "type: External agent (ACP)" }), _jsxs(Text, { children: ["command: ", selected.command || '(none)'] }), _jsxs(Text, { children: ["args: ", (selected.args ?? []).join(' ') || '(none)'] })] })) : selected.type === 'claude-code' ? (_jsxs(_Fragment, { children: [_jsx(Text, { children: "type: claude-code" }), _jsxs(Text, { children: ["command: ", selected.command || '(default: claude on PATH)'] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["endpoint: ", selected.endpoint] }), _jsxs(Text, { children: ["apiKey: ", selected.apiKey ? '(set)' : '(none)'] })] })), _jsx(Box, { marginTop: 1, children: _jsx(SelectInput, { items: [
|
|
72
72
|
{ label: 'Edit', value: 'edit' },
|
|
73
73
|
{ label: 'Delete', value: 'delete' },
|
|
74
74
|
{ label: '← Back', value: 'back' },
|
|
@@ -85,25 +85,24 @@ export default function Providers({ onBack }) {
|
|
|
85
85
|
}
|
|
86
86
|
const items = [
|
|
87
87
|
...providers.map((p) => ({
|
|
88
|
-
label: p.type === '
|
|
89
|
-
? `${p.name} —
|
|
90
|
-
:
|
|
88
|
+
label: p.type === 'acp'
|
|
89
|
+
? `${p.name} — External agent (ACP) — ${p.command ?? ''} ${(p.args ?? []).join(' ')}`.trim()
|
|
90
|
+
: p.type === 'claude-code'
|
|
91
|
+
? `${p.name} — Claude Code (local CLI)${p.command ? ` — ${p.command}` : ''}`
|
|
92
|
+
: `${p.name} — ${p.endpoint}`,
|
|
91
93
|
value: `p:${p.name}`,
|
|
92
94
|
})),
|
|
93
95
|
{ label: '+ Create new', value: '__new__' },
|
|
94
96
|
{ label: '← Back', value: '__back__' },
|
|
95
97
|
];
|
|
96
|
-
return (_jsxs(Box, { flexDirection: "column", children: [
|
|
98
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, children: "Providers" }), _jsx(Box, { marginTop: 1, children: _jsx(SelectInput, { items: items, onSelect: (item) => {
|
|
97
99
|
if (item.value === '__back__')
|
|
98
100
|
return onBack();
|
|
99
101
|
if (item.value === '__new__')
|
|
100
102
|
return setMode('create');
|
|
101
|
-
const name = item.value.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
setSelected(p);
|
|
105
|
-
setMode('detail');
|
|
106
|
-
}
|
|
103
|
+
const name = item.value.slice(2);
|
|
104
|
+
setSelected(providers.find((p) => p.name === name) ?? null);
|
|
105
|
+
setMode('detail');
|
|
107
106
|
} }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "(esc to go back)" }) })] }));
|
|
108
107
|
}
|
|
109
108
|
function ProviderForm({ existingNames, initial, onSave, onCancel, }) {
|
|
@@ -112,17 +111,87 @@ function ProviderForm({ existingNames, initial, onSave, onCancel, }) {
|
|
|
112
111
|
// providers by name, so switching type out from under them is a footgun
|
|
113
112
|
// (same rationale as the webview form).
|
|
114
113
|
const [type, setType] = useState(initial?.type ?? 'openai');
|
|
115
|
-
const [step, setStep] = useState(isEdit ? (type === 'claude-code' ? 'command' : 'endpoint') : 'type');
|
|
114
|
+
const [step, setStep] = useState(isEdit ? (type === 'acp' || type === 'claude-code' ? 'command' : 'endpoint') : 'type');
|
|
116
115
|
const [name, setName] = useState(initial?.name ?? '');
|
|
117
116
|
const [endpoint, setEndpoint] = useState(initial?.endpoint ?? '');
|
|
118
117
|
const [apiKey, setApiKey] = useState(initial?.apiKey ?? '');
|
|
119
118
|
const [command, setCommand] = useState(initial?.command ?? '');
|
|
119
|
+
const [args, setArgs] = useState((initial?.args ?? []).join(' '));
|
|
120
|
+
const [presets, setPresets] = useState([]);
|
|
121
|
+
const [presetError, setPresetError] = useState(null);
|
|
122
|
+
const [presetLabel, setPresetLabel] = useState('Custom (manual command)');
|
|
123
|
+
const [selfLoaded, setSelfLoaded] = useState(initial?.selfLoadedContextFiles ?? []);
|
|
124
|
+
const [env, setEnv] = useState(initial?.env);
|
|
120
125
|
const [error, setError] = useState(null);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (step === 'preset') {
|
|
128
|
+
void fetchAcpRegistry()
|
|
129
|
+
.then(setPresets)
|
|
130
|
+
.catch((e) => {
|
|
131
|
+
setPresetError(String(e));
|
|
132
|
+
setStep('command');
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}, [step]);
|
|
121
136
|
useInput((_input, key) => {
|
|
122
137
|
if (key.escape)
|
|
123
138
|
onCancel();
|
|
124
139
|
});
|
|
140
|
+
const presetItems = [
|
|
141
|
+
{ label: 'Custom (manual command)', value: 'custom' },
|
|
142
|
+
...presets.map((p) => ({
|
|
143
|
+
label: p.dist
|
|
144
|
+
? p.dist.kind === 'binary'
|
|
145
|
+
? `${p.name} (binary — install from the web GUI, or enter the path manually)`
|
|
146
|
+
: p.name
|
|
147
|
+
: `${p.name} (not available on this platform)`,
|
|
148
|
+
value: p.id,
|
|
149
|
+
})),
|
|
150
|
+
];
|
|
151
|
+
const handleSelectPreset = (item) => {
|
|
152
|
+
if (item.value === 'custom') {
|
|
153
|
+
setPresetLabel('Custom (manual command)');
|
|
154
|
+
setSelfLoaded([]);
|
|
155
|
+
setEnv(undefined);
|
|
156
|
+
setStep('command');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const chosen = presets.find((p) => p.id === item.value);
|
|
160
|
+
if (!chosen) {
|
|
161
|
+
setStep('command');
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
setPresetLabel(chosen.name);
|
|
165
|
+
setSelfLoaded(chosen.selfLoadedContextFiles);
|
|
166
|
+
if (chosen.dist?.env)
|
|
167
|
+
setEnv(chosen.dist.env);
|
|
168
|
+
// Prefill only — the user reviews command/args before saving. A binary
|
|
169
|
+
// preset has no command yet (install from the web GUI or type the path) but
|
|
170
|
+
// its registry args still apply (Antigravity on Linux needs `--uid=`).
|
|
171
|
+
setCommand(chosen.dist && chosen.dist.kind !== 'binary' ? chosen.dist.command : '');
|
|
172
|
+
setArgs((chosen.dist?.args ?? []).join(' '));
|
|
173
|
+
setStep('command');
|
|
174
|
+
};
|
|
125
175
|
const finalize = () => {
|
|
176
|
+
if (type === 'acp') {
|
|
177
|
+
const p = {
|
|
178
|
+
name: name.trim(),
|
|
179
|
+
type: 'acp',
|
|
180
|
+
endpoint: '',
|
|
181
|
+
command: command.trim(),
|
|
182
|
+
};
|
|
183
|
+
const argList = args.trim() ? args.trim().split(/\s+/) : [];
|
|
184
|
+
if (argList.length)
|
|
185
|
+
p.args = argList;
|
|
186
|
+
const envToSave = env ?? initial?.env;
|
|
187
|
+
if (envToSave)
|
|
188
|
+
p.env = envToSave;
|
|
189
|
+
const selfLoadedToSave = selfLoaded.length ? selfLoaded : initial?.selfLoadedContextFiles;
|
|
190
|
+
if (selfLoadedToSave?.length)
|
|
191
|
+
p.selfLoadedContextFiles = selfLoadedToSave;
|
|
192
|
+
void onSave(p);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
126
195
|
if (type === 'claude-code') {
|
|
127
196
|
const p = { name: name.trim(), type: 'claude-code', endpoint: '' };
|
|
128
197
|
if (command.trim())
|
|
@@ -147,7 +216,15 @@ function ProviderForm({ existingNames, initial, onSave, onCancel, }) {
|
|
|
147
216
|
if (existingNames.includes(v))
|
|
148
217
|
return setError('name already exists');
|
|
149
218
|
setError(null);
|
|
150
|
-
|
|
219
|
+
if (type === 'acp') {
|
|
220
|
+
setStep('preset');
|
|
221
|
+
}
|
|
222
|
+
else if (type === 'claude-code') {
|
|
223
|
+
setStep('command');
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
setStep('endpoint');
|
|
227
|
+
}
|
|
151
228
|
}
|
|
152
229
|
else if (step === 'endpoint') {
|
|
153
230
|
const v = endpoint.trim();
|
|
@@ -157,6 +234,19 @@ function ProviderForm({ existingNames, initial, onSave, onCancel, }) {
|
|
|
157
234
|
setStep('apiKey');
|
|
158
235
|
}
|
|
159
236
|
else if (step === 'command') {
|
|
237
|
+
if (type === 'acp') {
|
|
238
|
+
const v = command.trim();
|
|
239
|
+
if (!v)
|
|
240
|
+
return setError('command is required (e.g. npx or binary path)');
|
|
241
|
+
setError(null);
|
|
242
|
+
setStep('args');
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
setError(null);
|
|
246
|
+
finalize();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
else if (step === 'args') {
|
|
160
250
|
setError(null);
|
|
161
251
|
finalize();
|
|
162
252
|
}
|
|
@@ -164,15 +254,24 @@ function ProviderForm({ existingNames, initial, onSave, onCancel, }) {
|
|
|
164
254
|
finalize();
|
|
165
255
|
}
|
|
166
256
|
};
|
|
167
|
-
const stepOrder = type === '
|
|
257
|
+
const stepOrder = type === 'acp'
|
|
258
|
+
? ['type', 'name', 'preset', 'command', 'args']
|
|
259
|
+
: type === 'claude-code'
|
|
260
|
+
? ['type', 'name', 'command']
|
|
261
|
+
: ['type', 'name', 'endpoint', 'apiKey'];
|
|
168
262
|
const currentIdx = stepOrder.indexOf(step);
|
|
169
263
|
const isPending = (s) => stepOrder.indexOf(s) > currentIdx;
|
|
170
264
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, children: isEdit ? `Edit provider "${initial.name}"` : 'New provider' }), _jsxs(Box, { marginTop: 1, children: [_jsx(Text, { children: "type: " }), !isEdit && step === 'type' ? (_jsx(SelectInput, { items: [
|
|
171
265
|
{ label: 'OpenAI-compatible endpoint', value: 'openai' },
|
|
172
266
|
{ label: 'Claude Code (local CLI)', value: 'claude-code' },
|
|
173
|
-
|
|
267
|
+
{ label: 'External agent (ACP)', value: 'acp' },
|
|
268
|
+
], initialIndex: type === 'acp' ? 2 : type === 'claude-code' ? 1 : 0, onSelect: (item) => {
|
|
174
269
|
setType(item.value);
|
|
175
270
|
setError(null);
|
|
176
271
|
setStep('name');
|
|
177
|
-
} })) : (_jsx(Text, { children: type === '
|
|
272
|
+
} })) : (_jsx(Text, { children: type === 'acp'
|
|
273
|
+
? 'External agent (ACP)'
|
|
274
|
+
: type === 'claude-code'
|
|
275
|
+
? 'Claude Code (local CLI)'
|
|
276
|
+
: 'OpenAI-compatible endpoint' }))] }), _jsxs(Box, { children: [_jsx(Text, { children: "name: " }), !isEdit && step === 'name' ? (_jsx(TextInput, { value: name, onChange: setName, onSubmit: submit })) : isPending('name') ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: name }))] }), type === 'acp' ? (_jsxs(_Fragment, { children: [!isEdit && (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { children: "preset: " }), step === 'preset' ? (presets.length === 0 && !presetError ? (_jsx(Text, { dimColor: true, children: "loading presets\u2026" })) : (_jsx(SelectInput, { items: presetItems, onSelect: handleSelectPreset }))) : isPending('preset') ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: presetLabel }))] }), presetError && (_jsx(Box, { children: _jsxs(Text, { dimColor: true, children: ["Registry unavailable (", presetError, ") \u2014 enter command manually"] }) }))] })), _jsxs(Box, { children: [_jsx(Text, { children: "command: " }), step === 'command' ? (_jsx(TextInput, { value: command, onChange: setCommand, onSubmit: submit, placeholder: "npx or /path/to/binary" })) : isPending('command') ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: command }))] }), _jsxs(Box, { children: [_jsx(Text, { children: "arguments: " }), step === 'args' ? (_jsx(TextInput, { value: args, onChange: setArgs, onSubmit: submit, placeholder: "@agentclientprotocol/claude-agent-acp" })) : isPending('args') ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: args || '(none)' }))] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Space-separated arguments for the agent server. Edit caretaker.json for env vars." }) })] })) : type === 'claude-code' ? (_jsxs(_Fragment, { children: [_jsxs(Box, { children: [_jsx(Text, { children: "command: " }), step === 'command' ? (_jsx(TextInput, { value: command, onChange: setCommand, onSubmit: submit, placeholder: "claude (default: resolved from PATH)" })) : isPending('command') ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: command || '(default: claude on PATH)' }))] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Uses your local Claude Code session; Anthropic may bill programmatic use as extra usage." }) })] })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { children: [_jsx(Text, { children: "endpoint: " }), step === 'endpoint' ? (_jsx(TextInput, { value: endpoint, onChange: setEndpoint, onSubmit: submit, placeholder: "https://api.openai.com" })) : isPending('endpoint') ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: endpoint }))] }), _jsxs(Box, { children: [_jsx(Text, { children: "apiKey: " }), step === 'apiKey' ? (_jsx(TextInput, { value: apiKey, onChange: setApiKey, onSubmit: submit, placeholder: isEdit ? '(enter to keep current)' : '(optional, enter to skip)', mask: "*" })) : isPending('apiKey') ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: apiKey ? '(set)' : '(none)' }))] })] })), error && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "red", children: error }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "(esc to cancel)" }) })] }));
|
|
178
277
|
}
|