@hyperwindmill/caretaker-cli 0.13.0 → 0.14.0

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.
@@ -0,0 +1,9 @@
1
+ /** Runs a command and normalizes the result to a plain exit code + output,
2
+ * so a non-zero exit is data (not a throw). Injectable for tests. */
3
+ export type Runner = (cmd: string, args: string[]) => Promise<{
4
+ stdout: string;
5
+ stderr: string;
6
+ code: number;
7
+ }>;
8
+ export declare function configureClaude(run?: Runner, log?: (msg: string) => void): Promise<number>;
9
+ //# sourceMappingURL=config_claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config_claude.d.ts","sourceRoot":"","sources":["../../src/cli/config_claude.ts"],"names":[],"mappings":"AAiBA;sEACsE;AACtE,MAAM,MAAM,MAAM,GAAG,CACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,KACX,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAgB/D,wBAAsB,eAAe,CACnC,GAAG,GAAE,MAAsB,EAC3B,GAAG,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAkB,GACvC,OAAO,CAAC,MAAM,CAAC,CAoCjB"}
@@ -0,0 +1,62 @@
1
+ // `caretaker-cli config claude` — one-shot setup that registers caretaker's
2
+ // stdio MCP server (`caretaker-cli mcp`) in the user's Claude Code config, so
3
+ // an external Claude Code session can drive caretaker's task/project tools.
4
+ //
5
+ // This lives in the CLI (not the web/TUI settings) on purpose: the whole
6
+ // feature depends on `caretaker-cli` being installed, and if you can run this
7
+ // command then `caretaker-cli` is on your PATH — so the `caretaker-cli mcp`
8
+ // command we register is guaranteed to resolve when Claude Code spawns it.
9
+ //
10
+ // Writing the config is delegated to `claude mcp add` rather than editing
11
+ // ~/.claude.json ourselves, so we stay forward-compatible with their format.
12
+ import { execFile } from 'node:child_process';
13
+ import { promisify } from 'node:util';
14
+ const pexec = promisify(execFile);
15
+ const defaultRunner = async (cmd, args) => {
16
+ try {
17
+ const { stdout, stderr } = await pexec(cmd, args);
18
+ return { stdout, stderr, code: 0 };
19
+ }
20
+ catch (e) {
21
+ const err = e;
22
+ return {
23
+ stdout: err.stdout ?? '',
24
+ stderr: err.stderr ?? err.message ?? '',
25
+ code: typeof err.code === 'number' ? err.code : 1,
26
+ };
27
+ }
28
+ };
29
+ export async function configureClaude(run = defaultRunner, log = console.log) {
30
+ // 1. Is Claude Code installed?
31
+ const version = await run('claude', ['--version']);
32
+ if (version.code !== 0) {
33
+ log('✗ Claude Code CLI not found on PATH.');
34
+ log(' Install it first: https://claude.com/product/claude-code');
35
+ return 1;
36
+ }
37
+ log(`✓ Claude Code CLI found (${version.stdout.trim() || 'unknown version'})`);
38
+ // Best-effort: warn if the command we're about to register won't resolve for
39
+ // Claude Code (e.g. desktop-only users who never installed the CLI globally).
40
+ const whichCmd = process.platform === 'win32' ? 'where' : 'which';
41
+ const resolved = await run(whichCmd, ['caretaker-cli']);
42
+ if (resolved.code !== 0) {
43
+ log(' ⚠ caretaker-cli is not on your PATH — Claude Code may fail to launch the server.');
44
+ log(' Install the CLI globally: npm i -g @hyperwindmill/caretaker-cli');
45
+ }
46
+ // 2. Already configured?
47
+ const existing = await run('claude', ['mcp', 'get', 'caretaker']);
48
+ if (existing.code === 0) {
49
+ log('✓ caretaker MCP server already configured in Claude Code (user scope). Nothing to do.');
50
+ return 0;
51
+ }
52
+ // 3. Add it (user scope = the standard per-user config).
53
+ const add = await run('claude', ['mcp', 'add', 'caretaker', '-s', 'user', '--', 'caretaker-cli', 'mcp']);
54
+ if (add.code !== 0) {
55
+ log('✗ Failed to add the caretaker MCP server:');
56
+ log(` ${add.stderr.trim() || add.stdout.trim() || `exit ${add.code}`}`);
57
+ return 1;
58
+ }
59
+ log('✓ Added caretaker MCP server to Claude Code (user scope).');
60
+ log(' Restart your Claude Code sessions to pick it up, then the task/project tools are available.');
61
+ return 0;
62
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAcA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkD1D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAcA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmE1D"}
package/dist/cli/index.js CHANGED
@@ -46,5 +46,20 @@ export async function runCli(argv) {
46
46
  const { startServer } = await import('./web/server.js');
47
47
  await startServer(parseInt(opts.port, 10), opts.host);
48
48
  });
49
+ program
50
+ .command('mcp')
51
+ .description('Serve the caretaker task/project tools over stdio for an external MCP client.')
52
+ .action(async () => {
53
+ const { startMcpStdioServer } = await import('./mcp.js');
54
+ await startMcpStdioServer();
55
+ });
56
+ const config = program.command('config').description('Configure caretaker integrations.');
57
+ config
58
+ .command('claude')
59
+ .description("Register caretaker's MCP server in your Claude Code config (user scope).")
60
+ .action(async () => {
61
+ const { configureClaude } = await import('./config_claude.js');
62
+ process.exit(await configureClaude());
63
+ });
49
64
  await program.parseAsync(argv);
50
65
  }
@@ -0,0 +1,2 @@
1
+ export declare function startMcpStdioServer(): Promise<void>;
2
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/cli/mcp.ts"],"names":[],"mappings":"AASA,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CASzD"}
@@ -0,0 +1,17 @@
1
+ // `caretaker-cli mcp` — serve the built-in mcp__task__* tools over stdio so an
2
+ // external MCP client (e.g. Claude Code) can steer caretaker's task/project
3
+ // system symmetrically. No auth: the trust boundary is local process access to
4
+ // CARETAKER_HOME (the caller could edit the folder DB directly). stdout carries
5
+ // the JSON-RPC wire — never write anything else to it here.
6
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
+ import { buildTaskMcpServer } from '../mcp/task_server.js';
8
+ export async function startMcpStdioServer() {
9
+ const server = buildTaskMcpServer({ name: 'caretaker', version: '0.0.0' });
10
+ const transport = new StdioServerTransport();
11
+ await server.connect(transport);
12
+ // Stay alive until the client closes stdin. Resolve on transport close so
13
+ // the caller can let the process exit cleanly.
14
+ await new Promise((resolve) => {
15
+ transport.onclose = () => resolve();
16
+ });
17
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"mcp_bridge.d.ts","sourceRoot":"","sources":["../../../src/cli/web/mcp_bridge.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAWjC,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC;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;AA6CD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAgBlD"}
1
+ {"version":3,"file":"mcp_bridge.d.ts","sourceRoot":"","sources":["../../../src/cli/web/mcp_bridge.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAOjC,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC;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,CAgBlD"}
@@ -6,11 +6,8 @@
6
6
  // injection is needed.
7
7
  import { randomBytes } from 'node:crypto';
8
8
  import { RESPONSE_ALREADY_SENT } from '@hono/node-server/utils/response';
9
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
10
9
  import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
11
- import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
12
- import { tools as registry } from '../../harness/tools/instance.js';
13
- const TASK_PREFIX = 'mcp__task__';
10
+ import { buildTaskMcpServer } from '../../mcp/task_server.js';
14
11
  const activeTokens = new Set();
15
12
  export function issueBridgeToken() {
16
13
  const token = randomBytes(24).toString('hex');
@@ -27,45 +24,6 @@ export function setTaskBridgeUrl(url) {
27
24
  export function getTaskBridgeUrl() {
28
25
  return bridgeUrl;
29
26
  }
30
- function taskTools() {
31
- return registry.list().filter((t) => t.name.startsWith(TASK_PREFIX));
32
- }
33
- function buildServer() {
34
- const server = new Server({ name: 'caretaker-task', version: '0.0.0' }, { capabilities: { tools: {} } });
35
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
36
- tools: taskTools().map((t) => ({
37
- name: t.name.slice(TASK_PREFIX.length),
38
- description: t.description,
39
- inputSchema: t.parameters,
40
- })),
41
- }));
42
- server.setRequestHandler(CallToolRequestSchema, async (req) => {
43
- const tool = taskTools().find((t) => t.name === TASK_PREFIX + req.params.name);
44
- if (!tool) {
45
- return {
46
- content: [{ type: 'text', text: `Error: unknown tool "${req.params.name}"` }],
47
- isError: true,
48
- };
49
- }
50
- // ponytail: task tools ignore ctx entirely; a stub keeps the types happy.
51
- const ctx = {
52
- workingDir: process.cwd(),
53
- signal: new AbortController().signal,
54
- readPaths: new Set(),
55
- };
56
- try {
57
- const result = await tool.execute(req.params.arguments ?? {}, ctx);
58
- return { content: [{ type: 'text', text: result.content }] };
59
- }
60
- catch (err) {
61
- return {
62
- content: [{ type: 'text', text: `Error: ${err?.message ?? String(err)}` }],
63
- isError: true,
64
- };
65
- }
66
- });
67
- return server;
68
- }
69
27
  export function registerTaskBridge(app) {
70
28
  app.post('/api/mcp/task', async (c) => {
71
29
  const auth = c.req.header('authorization') ?? '';
@@ -73,7 +31,7 @@ export function registerTaskBridge(app) {
73
31
  if (!token || !activeTokens.has(token))
74
32
  return c.json({ error: 'unauthorized' }, 401);
75
33
  const body = await c.req.json().catch(() => null);
76
- const server = buildServer();
34
+ const server = buildTaskMcpServer();
77
35
  const transport = new StreamableHTTPServerTransport({
78
36
  sessionIdGenerator: undefined, // stateless
79
37
  enableJsonResponse: true, // plain JSON responses, no SSE needed
@@ -41,14 +41,14 @@ export function parseReviewVerdict(text) {
41
41
  export async function runDoneReview(opts) {
42
42
  // Strip task-state tools: the reviewer must not mutate the task; the harness decides.
43
43
  const reviewTools = opts.tools.filter((t) => !t.name.startsWith('mcp__task__'));
44
- // claude-code reviewer: in a docker container it uses the same manual +
44
+ // claude-code reviewer: in a docker container it uses the same dontAsk +
45
45
  // workdir-scoped allowlist as the dev cycle (the Bash-rewrite hook is attached
46
46
  // by the runner via `docker`); otherwise bypassPermissions, no task bridge.
47
47
  const isClaudeCode = opts.provider.type === 'claude-code';
48
48
  const claudeCode = isClaudeCode
49
49
  ? opts.dockerContainer
50
50
  ? {
51
- permissionMode: 'manual',
51
+ permissionMode: 'dontAsk',
52
52
  allowedTools: dockerDevAllowlist(opts.workingDir),
53
53
  docker: { container: opts.dockerContainer, workdir: opts.workingDir },
54
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"task_strategy.d.ts","sourceRoot":"","sources":["../../../../src/cli/web/scheduler/task_strategy.ts"],"names":[],"mappings":"AAyHA,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAoanE"}
1
+ {"version":3,"file":"task_strategy.d.ts","sourceRoot":"","sources":["../../../../src/cli/web/scheduler/task_strategy.ts"],"names":[],"mappings":"AAyHA,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAsanE"}
@@ -343,12 +343,14 @@ export async function runTaskHeartbeatTick(now) {
343
343
  bridge: bridgeUrl && bridgeToken ? { url: bridgeUrl, token: bridgeToken } : undefined,
344
344
  });
345
345
  // Docker isolation for claude-code (non-planning): swap bypassPermissions
346
- // for manual + a workdir-scoped allowlist and attach the Bash-rewrite hook.
346
+ // for dontAsk + a workdir-scoped allowlist and attach the Bash-rewrite hook.
347
+ // dontAsk auto-denies (and keeps running) anything off the allowlist and is
348
+ // valid on every CLI version, unlike 'manual' (a >=2.1.200 alias of 'default').
347
349
  // Planning stays as-is (read-only; no shell to contain).
348
350
  if (dockerContainer && !planning) {
349
351
  claudeCode = {
350
352
  ...claudeCode,
351
- permissionMode: 'manual',
353
+ permissionMode: 'dontAsk',
352
354
  allowedTools: dockerDevAllowlist(workingDir),
353
355
  disallowedTools: undefined,
354
356
  docker: { container: dockerContainer, workdir: workingDir },
@@ -33,6 +33,9 @@ export interface ClaudeArgsInput {
33
33
  allowedTools?: string[];
34
34
  disallowedTools?: string[];
35
35
  mcpConfigPath?: string;
36
+ /** Pass --strict-mcp-config alongside --mcp-config so ONLY caretaker's
37
+ * servers are used. Off (default) merges the user's native ~/.claude MCP. */
38
+ strictMcp?: boolean;
36
39
  settingsPath?: string;
37
40
  resumeId?: string;
38
41
  persistSession: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"claude_code_runner.d.ts","sourceRoot":"","sources":["../../src/harness/claude_code_runner.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAM3E,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAerE,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAA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CAAC,EAAE,MAAM,CAAC;IACvB;kFAC8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,EAAE,CAe5D;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,CAAC,EAAE;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC,GAAG,mBAAmB,CAoBtB;AA+LD,wBAAsB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,GAAE,YAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CAmI/F"}
@@ -44,8 +44,11 @@ export function buildClaudeArgs(i) {
44
44
  args.push('--allowedTools', ...i.allowedTools);
45
45
  if (i.disallowedTools?.length)
46
46
  args.push('--disallowedTools', ...i.disallowedTools);
47
- if (i.mcpConfigPath)
48
- args.push('--mcp-config', i.mcpConfigPath, '--strict-mcp-config');
47
+ if (i.mcpConfigPath) {
48
+ args.push('--mcp-config', i.mcpConfigPath);
49
+ if (i.strictMcp)
50
+ args.push('--strict-mcp-config');
51
+ }
49
52
  if (i.settingsPath)
50
53
  args.push('--settings', i.settingsPath);
51
54
  if (i.resumeId)
@@ -67,13 +70,16 @@ export function claudeCodeTaskExtras(p) {
67
70
  : undefined;
68
71
  if (!p.planning)
69
72
  return { permissionMode: 'bypassPermissions', extraMcpServers };
70
- // Planner: 'manual' mode + explicit allowlist. In -p mode unanswered
71
- // permission prompts are denied, so everything off-list is blocked.
72
- // (Not 'plan' mode: it could also block mcp task_submit_plan.)
73
+ // Planner: 'dontAsk' mode + explicit allowlist. dontAsk auto-DENIES (and keeps
74
+ // running) any tool call not covered by the allowlist — exactly the headless
75
+ // "confine + never hang" contract. NOT 'default' (in -p an off-list prompt
76
+ // aborts the whole run, not a clean per-call deny), NOT 'plan' (could also
77
+ // block mcp task_submit_plan). ('manual' is only a >=2.1.200 alias of 'default'
78
+ // and errors on older CLIs, so it's the wrong choice on both counts.)
73
79
  const allowedTools = ['Read', 'Glob', 'Grep', 'mcp__task'];
74
80
  if (p.sdd)
75
81
  allowedTools.push('Write(**/*.md)', 'Edit(**/*.md)', 'MultiEdit(**/*.md)');
76
- return { permissionMode: 'manual', allowedTools, disallowedTools: ['Bash'], extraMcpServers };
82
+ return { permissionMode: 'dontAsk', allowedTools, disallowedTools: ['Bash'], extraMcpServers };
77
83
  }
78
84
  async function buildMcpConfigFile(serverIds, extra) {
79
85
  const servers = {};
@@ -282,6 +288,7 @@ export async function runClaudeCode(opts, cb = {}) {
282
288
  allowedTools: opts.claudeCode?.allowedTools,
283
289
  disallowedTools: opts.claudeCode?.disallowedTools,
284
290
  mcpConfigPath: mcp?.configPath,
291
+ strictMcp: agent.strictMcp ?? false,
285
292
  settingsPath: settings?.settingsPath,
286
293
  resumeId: resume,
287
294
  persistSession: Boolean(opts.sessionId),
package/dist/index.js CHANGED
@@ -7,21 +7,27 @@ import { closeAll as closeAllMcp } from './mcp/client.js';
7
7
  import { initModelLimits } from './harness/model_limits.js';
8
8
  import { probeShellEnv } from './harness/tools/builtin/shell-env.js';
9
9
  import { runCli } from './cli/index.js';
10
- // Fire refresh-on-start in the background — startup must not block on a
11
- // slow git fetch. The next agent run reads plugins.json fresh so it picks
12
- // up newly-discovered plugins automatically.
13
- void refreshSourcesOnStart().catch((err) => {
14
- console.error('[boot] refresh-on-start failed:', err);
15
- });
16
- // Probe the interactive shell environment on Linux to capture PATH and
17
- // version manager variables (NVM, volta, fnm, etc.) that .bashrc sets.
18
- // This runs in the background and the result is cached for bash tool use.
19
- void probeShellEnv().catch((err) => {
20
- console.error('[boot] shell-env probe failed:', err);
21
- });
22
- // Populate the model-context registry from models.dev in the background.
23
- // Degrades gracefully (percent stays null) until the first fetch lands.
24
- initModelLimits();
10
+ // The `mcp` subcommand serves JSON-RPC over stdout — it must stay pristine
11
+ // (no banner, no log lines) and needs none of these boot side-effects, which
12
+ // also spawn child processes / network fetches. Skip them for that path.
13
+ const isMcpStdio = process.argv[2] === 'mcp';
14
+ if (!isMcpStdio) {
15
+ // Fire refresh-on-start in the background — startup must not block on a
16
+ // slow git fetch. The next agent run reads plugins.json fresh so it picks
17
+ // up newly-discovered plugins automatically.
18
+ void refreshSourcesOnStart().catch((err) => {
19
+ console.error('[boot] refresh-on-start failed:', err);
20
+ });
21
+ // Probe the interactive shell environment on Linux to capture PATH and
22
+ // version manager variables (NVM, volta, fnm, etc.) that .bashrc sets.
23
+ // This runs in the background and the result is cached for bash tool use.
24
+ void probeShellEnv().catch((err) => {
25
+ console.error('[boot] shell-env probe failed:', err);
26
+ });
27
+ // Populate the model-context registry from models.dev in the background.
28
+ // Degrades gracefully (percent stays null) until the first fetch lands.
29
+ initModelLimits();
30
+ }
25
31
  // Tear pooled MCP connections down on shutdown so child stdio processes are
26
32
  // not orphaned and HTTP sessions get a chance to send DELETE. Best-effort:
27
33
  // SIGINT/SIGTERM may not yield enough time for the close handshake.
@@ -3,6 +3,18 @@ export declare function containerName(projectId: number, taskId: number): string
3
3
  /** `docker run` argv. Mount is identical-path (`-v <root>:<root>`) so host and
4
4
  * container agree on absolute paths. `--user` keeps written files owned by the
5
5
  * host user (else root-owned files break the host WIP commit / review diff).
6
+ *
7
+ * We keep the container alive with `sleep infinity`, but pass it via
8
+ * `--entrypoint sleep` (arg `infinity`) rather than as the CMD. A CMD only
9
+ * overrides the image's CMD, not its ENTRYPOINT: a product's runtime image
10
+ * commonly defines an ENTRYPOINT that boots services (apache/supervisord/…)
11
+ * and never `exec "$@"`s, so our `sleep infinity` would be swallowed as args,
12
+ * the entrypoint would run its services (and, under `--user`, fail to setuid to
13
+ * root and exit non-zero), and the container would die mid-bootstrap — taking
14
+ * every in-flight `docker exec` (bootstrap, the agent) down with it. Overriding
15
+ * the entrypoint makes PID 1 be `sleep infinity` regardless of the image, which
16
+ * is exactly what we want: caretaker uses the container as an isolated shell
17
+ * target via `docker exec`, not to run the image's service stack.
6
18
  * ponytail: if an image lacks a matching /etc/passwd entry, set HOME=/tmp; tune when a real image needs it. */
7
19
  export declare function containerRunArgs(name: string, image: string, mountRoot: string, workdir: string, uid?: number, gid?: number, extraMounts?: string[]): string[];
8
20
  export declare function containerExecArgs(name: string, cwd: string, cmd: string): string[];
@@ -38,6 +50,6 @@ export declare function dockerClaudeSettings(container: string, workdir: string,
38
50
  * ABSOLUTE path and `/path` for project-relative. `workdir` is absolute (leads
39
51
  * with `/`), so the rule must be `//<workdir>/**` — hence the extra leading `/`.
40
52
  * With a single slash the rule is read as project-relative, matches nothing, and
41
- * `--permission-mode manual` then denies every file-tool call (even in-workspace). */
53
+ * `--permission-mode dontAsk` then denies every file-tool call (even in-workspace). */
42
54
  export declare function dockerDevAllowlist(workdir: string): string[];
43
55
  //# sourceMappingURL=docker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/lib/docker.ts"],"names":[],"mappings":"AASA,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;;gHAGgH;AAChH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,EACZ,WAAW,GAAE,MAAM,EAAO,GACzB,MAAM,EAAE,CAWV;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,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AgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAErE;AAED;;qFAEqF;AACrF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;2DAE2D;AAC3D,wBAAsB,UAAU,CAC9B,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAWf;AAKD,eAAO,MAAM,uBAAuB,ojBAYnC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB;AAED;;;;;;wFAMwF;AACxF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAY5D"}
@@ -12,9 +12,21 @@ export function containerName(projectId, taskId) {
12
12
  /** `docker run` argv. Mount is identical-path (`-v <root>:<root>`) so host and
13
13
  * container agree on absolute paths. `--user` keeps written files owned by the
14
14
  * host user (else root-owned files break the host WIP commit / review diff).
15
+ *
16
+ * We keep the container alive with `sleep infinity`, but pass it via
17
+ * `--entrypoint sleep` (arg `infinity`) rather than as the CMD. A CMD only
18
+ * overrides the image's CMD, not its ENTRYPOINT: a product's runtime image
19
+ * commonly defines an ENTRYPOINT that boots services (apache/supervisord/…)
20
+ * and never `exec "$@"`s, so our `sleep infinity` would be swallowed as args,
21
+ * the entrypoint would run its services (and, under `--user`, fail to setuid to
22
+ * root and exit non-zero), and the container would die mid-bootstrap — taking
23
+ * every in-flight `docker exec` (bootstrap, the agent) down with it. Overriding
24
+ * the entrypoint makes PID 1 be `sleep infinity` regardless of the image, which
25
+ * is exactly what we want: caretaker uses the container as an isolated shell
26
+ * target via `docker exec`, not to run the image's service stack.
15
27
  * ponytail: if an image lacks a matching /etc/passwd entry, set HOME=/tmp; tune when a real image needs it. */
16
28
  export function containerRunArgs(name, image, mountRoot, workdir, uid, gid, extraMounts = []) {
17
- const args = ['run', '-d'];
29
+ const args = ['run', '-d', '--entrypoint', 'sleep'];
18
30
  if (typeof uid === 'number' && typeof gid === 'number') {
19
31
  args.push('--user', `${uid}:${gid}`);
20
32
  }
@@ -23,7 +35,7 @@ export function containerRunArgs(name, image, mountRoot, workdir, uid, gid, extr
23
35
  // worktree's gitdir resolves and in-container git works).
24
36
  for (const m of extraMounts)
25
37
  args.push('-v', `${m}:${m}`);
26
- args.push('-w', workdir, '--name', name, image, 'sleep', 'infinity');
38
+ args.push('-w', workdir, '--name', name, image, 'infinity');
27
39
  return args;
28
40
  }
29
41
  export function containerExecArgs(name, cwd, cmd) {
@@ -144,7 +156,7 @@ export function dockerClaudeSettings(container, workdir, hookScriptPath) {
144
156
  * ABSOLUTE path and `/path` for project-relative. `workdir` is absolute (leads
145
157
  * with `/`), so the rule must be `//<workdir>/**` — hence the extra leading `/`.
146
158
  * With a single slash the rule is read as project-relative, matches nothing, and
147
- * `--permission-mode manual` then denies every file-tool call (even in-workspace). */
159
+ * `--permission-mode dontAsk` then denies every file-tool call (even in-workspace). */
148
160
  export function dockerDevAllowlist(workdir) {
149
161
  const scope = `/${workdir}/**`; // workdir starts with '/', so this yields '//<abs>/**'
150
162
  return [
@@ -0,0 +1,9 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import type { Tool } from '../harness/tools/index.js';
3
+ export declare const TASK_PREFIX = "mcp__task__";
4
+ export declare function taskTools(): Tool[];
5
+ export declare function buildTaskMcpServer(info?: {
6
+ name: string;
7
+ version: string;
8
+ }): Server;
9
+ //# sourceMappingURL=task_server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task_server.d.ts","sourceRoot":"","sources":["../../src/mcp/task_server.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,2BAA2B,CAAC;AAEnE,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC,wBAAgB,SAAS,IAAI,IAAI,EAAE,CAElC;AAED,wBAAgB,kBAAkB,CAChC,IAAI,GAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAiD,GACrF,MAAM,CAkCR"}
@@ -0,0 +1,48 @@
1
+ // Shared builder: wraps the built-in mcp__task__* registry tools as an MCP
2
+ // Server. Used by BOTH the per-task HTTP bridge (cli/web/mcp_bridge.ts) and
3
+ // the general stdio subcommand (cli/mcp.ts) so the task surface has one
4
+ // definition and one wrapping. The task tools are context-free (they take
5
+ // task_id/project_id as arguments), so a stub ToolContext is sufficient.
6
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
7
+ import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
8
+ import { tools as registry } from '../harness/tools/instance.js';
9
+ export const TASK_PREFIX = 'mcp__task__';
10
+ export function taskTools() {
11
+ return registry.list().filter((t) => t.name.startsWith(TASK_PREFIX));
12
+ }
13
+ export function buildTaskMcpServer(info = { name: 'caretaker-task', version: '0.0.0' }) {
14
+ const server = new Server(info, { capabilities: { tools: {} } });
15
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
16
+ tools: taskTools().map((t) => ({
17
+ name: t.name.slice(TASK_PREFIX.length),
18
+ description: t.description,
19
+ inputSchema: t.parameters,
20
+ })),
21
+ }));
22
+ server.setRequestHandler(CallToolRequestSchema, async (req) => {
23
+ const tool = taskTools().find((t) => t.name === TASK_PREFIX + req.params.name);
24
+ if (!tool) {
25
+ return {
26
+ content: [{ type: 'text', text: `Error: unknown tool "${req.params.name}"` }],
27
+ isError: true,
28
+ };
29
+ }
30
+ // ponytail: task tools ignore ctx entirely; a stub keeps the types happy.
31
+ const ctx = {
32
+ workingDir: process.cwd(),
33
+ signal: new AbortController().signal,
34
+ readPaths: new Set(),
35
+ };
36
+ try {
37
+ const result = await tool.execute(req.params.arguments ?? {}, ctx);
38
+ return { content: [{ type: 'text', text: result.content }] };
39
+ }
40
+ catch (err) {
41
+ return {
42
+ content: [{ type: 'text', text: `Error: ${err?.message ?? String(err)}` }],
43
+ isError: true,
44
+ };
45
+ }
46
+ });
47
+ return server;
48
+ }
@@ -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,2CAsXhE"}
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,2CAyXhE"}
@@ -196,7 +196,7 @@ export default function Agents({ onBack }) {
196
196
  if (mode === 'detail' && selected) {
197
197
  const managed = !!selected.pluginId;
198
198
  const isClaudeCode = providers.find((p) => p.name === selected.provider)?.type === 'claude-code';
199
- 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(Text, { children: ["permissionMode: ", selected.permissionMode || 'Auto (Claude Code default)'] })) : (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["maxTurns: ", selected.maxTurns === 0 ? 'unlimited' : selected.maxTurns] }), _jsxs(Text, { children: ["tools:", ' ', selected.allowedTools.length === 0
199
+ 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)'] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["maxTurns: ", selected.maxTurns === 0 ? 'unlimited' : selected.maxTurns] }), _jsxs(Text, { children: ["tools:", ' ', selected.allowedTools.length === 0
200
200
  ? '(none)'
201
201
  : 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
202
  { label: 'New chat', value: 'new-chat' },
@@ -263,7 +263,7 @@ function stepSequence(managed, isClaudeCode) {
263
263
  if (!managed)
264
264
  seq.push('systemPrompt');
265
265
  if (isClaudeCode) {
266
- seq.push('mcpServers', 'workingDir', 'permissionMode');
266
+ seq.push('mcpServers', 'workingDir', 'permissionMode', 'strictMcp');
267
267
  }
268
268
  else {
269
269
  seq.push('tools', 'plugins', 'mcpServers', 'workingDir', 'maxTurns');
@@ -282,6 +282,7 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
282
282
  const [model, setModel] = useState(initial?.model ?? '');
283
283
  const [systemPrompt, setSystemPrompt] = useState(initial?.systemPrompt ?? '');
284
284
  const [permissionMode, setPermissionMode] = useState(initial?.permissionMode ?? '');
285
+ const [strictMcp, setStrictMcp] = useState(initial?.strictMcp ?? false);
285
286
  const normalizeTools = (tools) => {
286
287
  const hasTaskTools = tools.some((t) => t.startsWith('mcp__task__'));
287
288
  if (hasTaskTools) {
@@ -314,8 +315,9 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
314
315
  const idx = steps.indexOf(s);
315
316
  return idx >= 0 && idx + 1 < steps.length ? steps[idx + 1] : s;
316
317
  };
317
- const finalize = (n, permissionModeOverride) => {
318
+ const finalize = (n, permissionModeOverride, strictMcpOverride) => {
318
319
  const pm = permissionModeOverride ?? permissionMode;
320
+ const sm = strictMcpOverride ?? strictMcp;
319
321
  const a = {
320
322
  id: initial?.id ?? randomUUID(),
321
323
  name: name.trim(),
@@ -329,6 +331,7 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
329
331
  ...(activeMcp.length > 0 ? { mcpServers: activeMcp } : {}),
330
332
  ...(workingDir.trim() ? { workingDir: workingDir.trim() } : {}),
331
333
  ...(isClaudeCode && pm ? { permissionMode: pm } : {}),
334
+ ...(isClaudeCode && sm ? { strictMcp: true } : {}),
332
335
  // Preserve plugin-managed origin tags so the next sync recognizes
333
336
  // this row instead of orphaning it.
334
337
  ...(initial?.pluginId ? { pluginId: initial.pluginId } : {}),
@@ -413,9 +416,17 @@ function AgentForm({ providers, existingNames, initial, onSave, onCancel, }) {
413
416
  : 0, onSelect: (item) => {
414
417
  setPermissionMode(item.value);
415
418
  setError(null);
419
+ setStep('strictMcp');
420
+ } })) : ['name', 'provider', 'model', 'systemPrompt', 'mcpServers', 'workingDir'].includes(step) ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: permissionMode || 'Auto (Claude Code default)' })), _jsx(Text, { dimColor: true, children: "Uses your local Claude Code session; Anthropic may bill programmatic use as extra usage." })] })), isClaudeCode && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "strictMcp: " }), step === 'strictMcp' ? (_jsx(SelectInput, { items: [
421
+ { label: 'off — merge your ~/.claude MCP servers (default)', value: 'off' },
422
+ { label: 'on — use only caretaker servers (--strict-mcp-config)', value: 'on' },
423
+ ], initialIndex: strictMcp ? 1 : 0, onSelect: (item) => {
424
+ const val = item.value === 'on';
425
+ setStrictMcp(val);
426
+ setError(null);
416
427
  const n = Number.parseInt(maxTurns.trim(), 10);
417
- finalize(Number.isFinite(n) && n >= 0 ? n : 30, item.value);
418
- } })) : ['name', 'provider', 'model', 'systemPrompt', 'mcpServers', 'workingDir'].includes(step) ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: permissionMode || 'Auto (Claude Code default)' })), _jsx(Text, { dimColor: true, children: "Uses your local Claude Code session; Anthropic may bill programmatic use as extra usage." })] })), 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)" }) })] }));
428
+ finalize(Number.isFinite(n) && n >= 0 ? n : 30, undefined, val);
429
+ } })) : step === 'permissionMode' ? (_jsx(Text, { dimColor: true, children: "(pending)" })) : (_jsx(Text, { children: strictMcp ? 'on' : 'off' }))] })), 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)" }) })] }));
419
430
  }
420
431
  function ModelStep({ provider, initialModel, onPick, }) {
421
432
  const isClaudeCode = provider.type === 'claude-code';