@hyperwindmill/caretaker-cli 0.12.2 → 0.13.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.
Files changed (33) hide show
  1. package/dist/cli/web/scheduler/task_review.d.ts +6 -0
  2. package/dist/cli/web/scheduler/task_review.d.ts.map +1 -1
  3. package/dist/cli/web/scheduler/task_review.js +22 -5
  4. package/dist/cli/web/scheduler/task_roles.d.ts +6 -0
  5. package/dist/cli/web/scheduler/task_roles.d.ts.map +1 -1
  6. package/dist/cli/web/scheduler/task_roles.js +9 -0
  7. package/dist/cli/web/scheduler/task_strategy.d.ts.map +1 -1
  8. package/dist/cli/web/scheduler/task_strategy.js +116 -11
  9. package/dist/cli/web/server.d.ts.map +1 -1
  10. package/dist/cli/web/server.js +15 -1
  11. package/dist/harness/claude_code_runner.d.ts +5 -0
  12. package/dist/harness/claude_code_runner.d.ts.map +1 -1
  13. package/dist/harness/claude_code_runner.js +24 -4
  14. package/dist/harness/loop.d.ts +2 -0
  15. package/dist/harness/loop.d.ts.map +1 -1
  16. package/dist/harness/loop.js +1 -0
  17. package/dist/harness/tools/builtin/bash.d.ts.map +1 -1
  18. package/dist/harness/tools/builtin/bash.js +18 -9
  19. package/dist/harness/tools/builtin/task_tools.d.ts.map +1 -1
  20. package/dist/harness/tools/builtin/task_tools.js +13 -0
  21. package/dist/harness/tools/types.d.ts +4 -0
  22. package/dist/harness/tools/types.d.ts.map +1 -1
  23. package/dist/lib/docker.d.ts +55 -0
  24. package/dist/lib/docker.d.ts.map +1 -0
  25. package/dist/lib/docker.js +172 -0
  26. package/dist/lib/task_git.d.ts +9 -1
  27. package/dist/lib/task_git.d.ts.map +1 -1
  28. package/dist/lib/task_git.js +24 -1
  29. package/dist/store/db.d.ts +3 -0
  30. package/dist/store/db.d.ts.map +1 -1
  31. package/dist/webview/standalone.js +80 -7
  32. package/dist/webview/standalone.js.map +2 -2
  33. package/package.json +3 -3
@@ -2,6 +2,7 @@ import { randomUUID } from 'node:crypto';
2
2
  import { getDb, getTaskById, saveTask, createTask, addTaskMessage, deleteTask, tryNormalizeChecklistStatus } from '../../../store/db.js';
3
3
  import { loadConfig, loadAgents } from '../../../store/json.js';
4
4
  import { discardWorktree } from '../../../lib/task_git.js';
5
+ import { removeContainer } from '../../../lib/docker.js';
5
6
  import { runningTasks } from '../../../cli/web/scheduler/locks.js';
6
7
  import { resolveReviewEnabled, resolvePlanningEnabled, activationStatus } from '../../../cli/web/scheduler/task_roles.js';
7
8
  function ok(data = {}) {
@@ -532,6 +533,10 @@ export const taskDiscardWorktreeTool = {
532
533
  return err(`Task ${taskId} not found`);
533
534
  if (!task.worktreePath)
534
535
  return err(`Task ${taskId} has no active worktree`);
536
+ if (task.dockerContainer) {
537
+ await removeContainer(task.dockerContainer);
538
+ task.dockerContainer = null;
539
+ }
535
540
  await discardWorktree(task.worktreePath, task.title);
536
541
  task.worktreePath = null;
537
542
  task.updatedAt = new Date().toISOString();
@@ -623,6 +628,14 @@ export const taskDeleteTool = {
623
628
  return err(`Task ${taskId} is currently running (locked). Wait for it to finish or pause it first.`);
624
629
  }
625
630
  // Clean up any active worktree before deleting the task record.
631
+ if (task.dockerContainer) {
632
+ try {
633
+ await removeContainer(task.dockerContainer);
634
+ }
635
+ catch {
636
+ // Best-effort
637
+ }
638
+ }
626
639
  if (task.worktreePath) {
627
640
  try {
628
641
  await discardWorktree(task.worktreePath, task.title);
@@ -40,6 +40,10 @@ export interface ToolContext {
40
40
  };
41
41
  /** The session ID of the current conversation run. Useful for attachment directories. */
42
42
  sessionId?: string;
43
+ /** When set, the `bash` tool runs commands inside this docker container
44
+ * (`docker exec`) instead of on the host. A run-level isolation property —
45
+ * the caller decides; the tool only honors it. */
46
+ dockerContainer?: string;
43
47
  }
44
48
  export interface ToolAttachment {
45
49
  mime: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/types.ts"],"names":[],"mappings":"AAMA,O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E,MAAM,CAAC;IACvB;;oCAEgC;IAChC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;wEAEoE;IACpE,SAAS,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,cAAc,CAAC;QAAC,UAAU,EAAE,cAAc,CAAA;KAAE,CAAC;IACtE,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;uDAEmD;IACnD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,IAAI;IACnB;;8EAE0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC;uCACmC;IACnC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAClE;;;yBAGqB;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;CACH;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAS3D"}
@@ -0,0 +1,55 @@
1
+ /** Deterministic container name for a task — the caller's naming policy. */
2
+ export declare function containerName(projectId: number, taskId: number): string;
3
+ /** `docker run` argv. Mount is identical-path (`-v <root>:<root>`) so host and
4
+ * container agree on absolute paths. `--user` keeps written files owned by the
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.
18
+ * ponytail: if an image lacks a matching /etc/passwd entry, set HOME=/tmp; tune when a real image needs it. */
19
+ export declare function containerRunArgs(name: string, image: string, mountRoot: string, workdir: string, uid?: number, gid?: number, extraMounts?: string[]): string[];
20
+ export declare function containerExecArgs(name: string, cwd: string, cmd: string): string[];
21
+ /** Idempotent: reuse a running container of this name; recreate a stopped/absent one. */
22
+ export declare function ensureContainer(name: string, image: string, mountRoot: string, workdir: string, extraMounts?: string[]): Promise<void>;
23
+ /** True if `git` is on PATH inside the container. In-container git is
24
+ * best-effort — a minimal image may not ship it; the harness commits
25
+ * host-side regardless, so a missing git only affects the agent's own git
26
+ * commands (we warn it via the prompt). */
27
+ export declare function containerHasGit(name: string): Promise<boolean>;
28
+ /** Run one command in the container. Never throws on a non-zero exit — returns
29
+ * the code + combined output, mirroring the bash tool's contract. */
30
+ export declare function execInContainer(name: string, cwd: string, cmd: string, timeoutMs: number, signal?: AbortSignal): Promise<{
31
+ exitCode: number;
32
+ output: string;
33
+ }>;
34
+ export declare function removeContainer(name: string): Promise<void>;
35
+ /** True if a container of this name is currently running. */
36
+ export declare function containerRunning(name: string): Promise<boolean>;
37
+ /** True when the dockerImage value is a Dockerfile path rather than a pullable
38
+ * image ref. Image refs never start with '.', '/', or '\', so a leading one of
39
+ * those unambiguously marks a path (relative `./Dockerfile`, absolute, Windows). */
40
+ export declare function isDockerfilePath(image: string): boolean;
41
+ /** Build an image from a Dockerfile into `tag`. `contextDir` is the build
42
+ * context. Throws with the build output on failure so the caller can surface
43
+ * why setup broke (same policy as a failed bootstrap). */
44
+ export declare function buildImage(dockerfilePath: string, contextDir: string, tag: string): Promise<void>;
45
+ export declare const DOCKER_BASH_HOOK_SCRIPT = "let raw = '';\nprocess.stdin.on('data', (c) => { raw += c; });\nprocess.stdin.on('end', () => {\n const [container, workdir] = process.argv.slice(2);\n let cmd = '';\n try { cmd = JSON.parse(raw)?.tool_input?.command ?? ''; } catch { cmd = ''; }\n const b64 = Buffer.from(cmd, 'utf8').toString('base64');\n const wrapped = `docker exec -w ${workdir} ${container} sh -lc \"echo ${b64} | base64 -d | sh\"`;\n process.stdout.write(JSON.stringify({\n hookSpecificOutput: { hookEventName: 'PreToolUse', updatedInput: { command: wrapped } },\n }));\n});\n";
46
+ export declare function dockerClaudeSettings(container: string, workdir: string, hookScriptPath: string): Record<string, unknown>;
47
+ /** Confine claude-code file tools to the working dir. Bash is allowed (the docker
48
+ * hook contains it); readers/writers are path-scoped to workdir; mcp__task stays
49
+ * open. NOTE: Claude Code's Read/Edit/Write rule syntax uses `//path` for an
50
+ * ABSOLUTE path and `/path` for project-relative. `workdir` is absolute (leads
51
+ * with `/`), so the rule must be `//<workdir>/**` — hence the extra leading `/`.
52
+ * With a single slash the rule is read as project-relative, matches nothing, and
53
+ * `--permission-mode dontAsk` then denies every file-tool call (even in-workspace). */
54
+ export declare function dockerDevAllowlist(workdir: string): string[];
55
+ //# sourceMappingURL=docker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/lib/docker.ts"],"names":[],"mappings":"AAS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B,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"}
@@ -0,0 +1,172 @@
1
+ // Task-agnostic Docker container primitives. The container NAME is always a
2
+ // parameter — this module knows nothing about tasks/projects, so a future
3
+ // agent-level isolation can reuse it with a different naming scheme + mount.
4
+ import { execFile } from 'node:child_process';
5
+ import { promisify } from 'node:util';
6
+ import { commandEnv } from '../harness/tools/builtin/shell-env.js';
7
+ const exec = promisify(execFile);
8
+ /** Deterministic container name for a task — the caller's naming policy. */
9
+ export function containerName(projectId, taskId) {
10
+ return `caretaker-task-${projectId}-${taskId}`;
11
+ }
12
+ /** `docker run` argv. Mount is identical-path (`-v <root>:<root>`) so host and
13
+ * container agree on absolute paths. `--user` keeps written files owned by the
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.
27
+ * ponytail: if an image lacks a matching /etc/passwd entry, set HOME=/tmp; tune when a real image needs it. */
28
+ export function containerRunArgs(name, image, mountRoot, workdir, uid, gid, extraMounts = []) {
29
+ const args = ['run', '-d', '--entrypoint', 'sleep'];
30
+ if (typeof uid === 'number' && typeof gid === 'number') {
31
+ args.push('--user', `${uid}:${gid}`);
32
+ }
33
+ args.push('-v', `${mountRoot}:${mountRoot}`);
34
+ // Extra identical-path mounts (e.g. the git common dir, so a linked
35
+ // worktree's gitdir resolves and in-container git works).
36
+ for (const m of extraMounts)
37
+ args.push('-v', `${m}:${m}`);
38
+ args.push('-w', workdir, '--name', name, image, 'infinity');
39
+ return args;
40
+ }
41
+ export function containerExecArgs(name, cwd, cmd) {
42
+ return ['exec', '-w', cwd, name, 'sh', '-lc', cmd];
43
+ }
44
+ /** Returns 'running' | 'stopped' | 'absent' for a container name. */
45
+ async function containerState(name) {
46
+ try {
47
+ const { stdout } = await exec('docker', ['inspect', '-f', '{{.State.Running}}', name], {
48
+ env: commandEnv(),
49
+ });
50
+ return stdout.trim() === 'true' ? 'running' : 'stopped';
51
+ }
52
+ catch {
53
+ return 'absent';
54
+ }
55
+ }
56
+ /** Idempotent: reuse a running container of this name; recreate a stopped/absent one. */
57
+ export async function ensureContainer(name, image, mountRoot, workdir, extraMounts = []) {
58
+ const state = await containerState(name);
59
+ if (state === 'running')
60
+ return;
61
+ if (state === 'stopped')
62
+ await removeContainer(name);
63
+ const uid = process.getuid?.();
64
+ const gid = process.getgid?.();
65
+ await exec('docker', containerRunArgs(name, image, mountRoot, workdir, uid, gid, extraMounts), {
66
+ env: commandEnv(),
67
+ maxBuffer: 8 * 1024 * 1024,
68
+ });
69
+ }
70
+ /** True if `git` is on PATH inside the container. In-container git is
71
+ * best-effort — a minimal image may not ship it; the harness commits
72
+ * host-side regardless, so a missing git only affects the agent's own git
73
+ * commands (we warn it via the prompt). */
74
+ export async function containerHasGit(name) {
75
+ const { exitCode } = await execInContainer(name, '/', 'command -v git', 5000);
76
+ return exitCode === 0;
77
+ }
78
+ /** Run one command in the container. Never throws on a non-zero exit — returns
79
+ * the code + combined output, mirroring the bash tool's contract. */
80
+ export async function execInContainer(name, cwd, cmd, timeoutMs, signal) {
81
+ try {
82
+ const { stdout, stderr } = await exec('docker', containerExecArgs(name, cwd, cmd), {
83
+ env: commandEnv(),
84
+ timeout: timeoutMs,
85
+ maxBuffer: 32 * 1024 * 1024,
86
+ signal,
87
+ });
88
+ return { exitCode: 0, output: stdout + stderr };
89
+ }
90
+ catch (err) {
91
+ const e = err;
92
+ const code = typeof e.code === 'number' ? e.code : 1;
93
+ return { exitCode: code, output: (e.stdout ?? '') + (e.stderr ?? '') + (e.message ?? '') };
94
+ }
95
+ }
96
+ export async function removeContainer(name) {
97
+ await exec('docker', ['rm', '-f', name], { env: commandEnv() }).catch(() => { });
98
+ }
99
+ /** True if a container of this name is currently running. */
100
+ export async function containerRunning(name) {
101
+ return (await containerState(name)) === 'running';
102
+ }
103
+ /** True when the dockerImage value is a Dockerfile path rather than a pullable
104
+ * image ref. Image refs never start with '.', '/', or '\', so a leading one of
105
+ * those unambiguously marks a path (relative `./Dockerfile`, absolute, Windows). */
106
+ export function isDockerfilePath(image) {
107
+ return /^[./\\]/.test(image);
108
+ }
109
+ /** Build an image from a Dockerfile into `tag`. `contextDir` is the build
110
+ * context. Throws with the build output on failure so the caller can surface
111
+ * why setup broke (same policy as a failed bootstrap). */
112
+ export async function buildImage(dockerfilePath, contextDir, tag) {
113
+ try {
114
+ await exec('docker', ['build', '-f', dockerfilePath, '-t', tag, contextDir], {
115
+ env: commandEnv(),
116
+ maxBuffer: 64 * 1024 * 1024,
117
+ });
118
+ }
119
+ catch (err) {
120
+ const e = err;
121
+ const detail = (e.stderr || e.stdout || e.message || '').toString().trim();
122
+ throw new Error(`docker build failed for \`${dockerfilePath}\`:\n${detail}`);
123
+ }
124
+ }
125
+ // PreToolUse hook: rewrite every Bash command so it runs inside the container.
126
+ // Mechanical (not a prompt instruction) — the agent cannot forget. argv:
127
+ // [container, workdir]. base64 dodges nested-quote hell in the wrapped command.
128
+ export const DOCKER_BASH_HOOK_SCRIPT = `let raw = '';
129
+ process.stdin.on('data', (c) => { raw += c; });
130
+ process.stdin.on('end', () => {
131
+ const [container, workdir] = process.argv.slice(2);
132
+ let cmd = '';
133
+ try { cmd = JSON.parse(raw)?.tool_input?.command ?? ''; } catch { cmd = ''; }
134
+ const b64 = Buffer.from(cmd, 'utf8').toString('base64');
135
+ const wrapped = \`docker exec -w \${workdir} \${container} sh -lc "echo \${b64} | base64 -d | sh"\`;
136
+ process.stdout.write(JSON.stringify({
137
+ hookSpecificOutput: { hookEventName: 'PreToolUse', updatedInput: { command: wrapped } },
138
+ }));
139
+ });
140
+ `;
141
+ export function dockerClaudeSettings(container, workdir, hookScriptPath) {
142
+ return {
143
+ hooks: {
144
+ PreToolUse: [
145
+ {
146
+ matcher: 'Bash',
147
+ hooks: [{ type: 'command', command: `node ${hookScriptPath} ${container} ${workdir}` }],
148
+ },
149
+ ],
150
+ },
151
+ };
152
+ }
153
+ /** Confine claude-code file tools to the working dir. Bash is allowed (the docker
154
+ * hook contains it); readers/writers are path-scoped to workdir; mcp__task stays
155
+ * open. NOTE: Claude Code's Read/Edit/Write rule syntax uses `//path` for an
156
+ * ABSOLUTE path and `/path` for project-relative. `workdir` is absolute (leads
157
+ * with `/`), so the rule must be `//<workdir>/**` — hence the extra leading `/`.
158
+ * With a single slash the rule is read as project-relative, matches nothing, and
159
+ * `--permission-mode dontAsk` then denies every file-tool call (even in-workspace). */
160
+ export function dockerDevAllowlist(workdir) {
161
+ const scope = `/${workdir}/**`; // workdir starts with '/', so this yields '//<abs>/**'
162
+ return [
163
+ `Read(${scope})`,
164
+ `Edit(${scope})`,
165
+ `Write(${scope})`,
166
+ `MultiEdit(${scope})`,
167
+ 'Glob',
168
+ 'Grep',
169
+ 'mcp__task',
170
+ 'Bash',
171
+ ];
172
+ }
@@ -1,4 +1,12 @@
1
1
  export declare function isGitRepo(dir: string): Promise<boolean>;
2
+ /**
3
+ * Absolute git common dir for a (linked) worktree — the main repo's shared
4
+ * `.git`, which holds the object store and `worktrees/<id>`. A worktree's own
5
+ * `.git` file points inside here, so mounting this path into a container (at
6
+ * an identical path) is what makes in-container git resolve. Returns null when
7
+ * it can't be determined (e.g. not a git dir).
8
+ */
9
+ export declare function gitCommonDir(worktreePath: string): Promise<string | null>;
2
10
  export declare function agentDirIn(worktreePath: string, projectWorkingDir: string): Promise<string>;
3
11
  export declare function ensureWorktree(projectWorkingDir: string, projectId: number, taskId: number, title: string): Promise<{
4
12
  branch: string;
@@ -12,7 +20,7 @@ export declare function ensureWorktree(projectWorkingDir: string, projectId: num
12
20
  * generous timeout so a hung install can't wedge the scheduler tick.
13
21
  * ponytail: 10-min per-command timeout; make it configurable if a real project needs longer.
14
22
  */
15
- export declare function runBootstrap(cwd: string, commands: string[]): Promise<void>;
23
+ export declare function runBootstrap(cwd: string, commands: string[], dockerContainer?: string): Promise<void>;
16
24
  export declare function commitWip(worktreePath: string, title: string): Promise<boolean>;
17
25
  export declare function finalizeDone(worktreePath: string): Promise<void>;
18
26
  export declare function discardWorktree(worktreePath: string, title: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"task_git.d.ts","sourceRoot":"","sources":["../../src/lib/task_git.ts"],"names":[],"mappings":"AAmBA,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAM7D;AAgBD,wBAAsB,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKjG;AAED,wBAAsB,cAAc,CAClC,iBAAiB,EAAE,MAAM,EACzB,SAAS,EAAE,MAAM,E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MG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAAE,EAClB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CAwBf;AAcD,wBAAsB,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAcrF;AAED,wBAAsB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBtE;AAED,wBAAsB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxF"}
@@ -4,6 +4,7 @@ import { rm } from 'node:fs/promises';
4
4
  import { join, relative, dirname } from 'node:path';
5
5
  import { dataDir } from '../store/db.js';
6
6
  import { commandEnv } from '../harness/tools/builtin/shell-env.js';
7
+ import { execInContainer } from './docker.js';
7
8
  const exec = promisify(execFile);
8
9
  const execShell = promisify(execCb);
9
10
  async function git(cwd, args) {
@@ -32,6 +33,21 @@ function slug(title) {
32
33
  function worktreePathFor(projectId, taskId) {
33
34
  return join(dataDir(), 'worktrees', `${projectId}-${taskId}`);
34
35
  }
36
+ /**
37
+ * Absolute git common dir for a (linked) worktree — the main repo's shared
38
+ * `.git`, which holds the object store and `worktrees/<id>`. A worktree's own
39
+ * `.git` file points inside here, so mounting this path into a container (at
40
+ * an identical path) is what makes in-container git resolve. Returns null when
41
+ * it can't be determined (e.g. not a git dir).
42
+ */
43
+ export async function gitCommonDir(worktreePath) {
44
+ try {
45
+ return await git(worktreePath, ['rev-parse', '--path-format=absolute', '--git-common-dir']);
46
+ }
47
+ catch {
48
+ return null;
49
+ }
50
+ }
35
51
  export async function agentDirIn(worktreePath, projectWorkingDir) {
36
52
  // Preserve a sub-directory working dir when the project points below the repo root.
37
53
  const repoRoot = await git(projectWorkingDir, ['rev-parse', '--show-toplevel']);
@@ -60,11 +76,18 @@ export async function ensureWorktree(projectWorkingDir, projectId, taskId, title
60
76
  * generous timeout so a hung install can't wedge the scheduler tick.
61
77
  * ponytail: 10-min per-command timeout; make it configurable if a real project needs longer.
62
78
  */
63
- export async function runBootstrap(cwd, commands) {
79
+ export async function runBootstrap(cwd, commands, dockerContainer) {
64
80
  for (const command of commands) {
65
81
  const cmd = command.trim();
66
82
  if (!cmd)
67
83
  continue;
84
+ if (dockerContainer) {
85
+ const { exitCode, output } = await execInContainer(dockerContainer, cwd, cmd, 10 * 60 * 1000);
86
+ if (exitCode !== 0) {
87
+ throw new Error(`Bootstrap command failed: \`${cmd}\`\n${output.trim()}`);
88
+ }
89
+ continue;
90
+ }
68
91
  try {
69
92
  await execShell(cmd, {
70
93
  cwd,
@@ -40,6 +40,9 @@ export interface Task {
40
40
  sddEnabled?: boolean | null;
41
41
  /** Per-invocation wall-clock budget (seconds). Inherits from the project; unset = default. */
42
42
  maxRunSeconds?: number | null;
43
+ /** Name of the docker container isolating this task's runs (set when the
44
+ * project has a dockerImage). Parallel to branch/worktreePath. */
45
+ dockerContainer?: string | null;
43
46
  createdAt: string;
44
47
  updatedAt: string;
45
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/store/db.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAA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F;IACnF,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAID,wBAAgB,KAAK,IAAI,KAAK,CAS7B;AAID,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAe9G;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAKxD;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAOlE;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxD;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBlG;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAerG;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC,CAUf;AAID,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9D"}
@@ -16151,6 +16151,7 @@ ${text}</tr>
16151
16151
  const [sddEnabled, setSddEnabled] = (0, import_react7.useState)(null);
16152
16152
  const [bootstrapText, setBootstrapText] = (0, import_react7.useState)("");
16153
16153
  const [maxRunSecondsText, setMaxRunSecondsText] = (0, import_react7.useState)("");
16154
+ const [dockerImage, setDockerImage] = (0, import_react7.useState)("");
16154
16155
  const [errorMsg, setErrorMsg] = (0, import_react7.useState)(null);
16155
16156
  const projects = config.projects || [];
16156
16157
  const startEdit = (proj) => {
@@ -16167,6 +16168,7 @@ ${text}</tr>
16167
16168
  setSddEnabled(proj.sddEnabled !== void 0 ? proj.sddEnabled : null);
16168
16169
  setBootstrapText((proj.bootstrapCommands || []).join("\n"));
16169
16170
  setMaxRunSecondsText(proj.maxRunSeconds ? String(proj.maxRunSeconds) : "");
16171
+ setDockerImage(proj.dockerImage || "");
16170
16172
  setErrorMsg(null);
16171
16173
  };
16172
16174
  const startCreate = () => {
@@ -16183,6 +16185,7 @@ ${text}</tr>
16183
16185
  setSddEnabled(null);
16184
16186
  setBootstrapText("");
16185
16187
  setMaxRunSecondsText("");
16188
+ setDockerImage("");
16186
16189
  setErrorMsg(null);
16187
16190
  };
16188
16191
  const cancelForm = () => {
@@ -16209,6 +16212,7 @@ ${text}</tr>
16209
16212
  const bootstrapCommands = bootstrapText.split("\n").map((c) => c.trim()).filter(Boolean);
16210
16213
  const parsedMaxRun = parseInt(maxRunSecondsText.trim(), 10);
16211
16214
  const maxRunSeconds = Number.isFinite(parsedMaxRun) && parsedMaxRun > 0 ? parsedMaxRun : null;
16215
+ const trimmedDocker = dockerImage.trim();
16212
16216
  const updatedProjects = [...projects];
16213
16217
  if (isCreating) {
16214
16218
  const nextId = projects.length > 0 ? Math.max(...projects.map((p) => p.id)) + 1 : 1;
@@ -16225,7 +16229,8 @@ ${text}</tr>
16225
16229
  reviewEnabled,
16226
16230
  sddEnabled,
16227
16231
  bootstrapCommands,
16228
- maxRunSeconds
16232
+ maxRunSeconds,
16233
+ dockerImage: trimmedDocker || null
16229
16234
  };
16230
16235
  updatedProjects.push(newProj);
16231
16236
  } else if (editingProject) {
@@ -16243,7 +16248,8 @@ ${text}</tr>
16243
16248
  reviewEnabled,
16244
16249
  sddEnabled,
16245
16250
  bootstrapCommands,
16246
- maxRunSeconds
16251
+ maxRunSeconds,
16252
+ dockerImage: trimmedDocker || null
16247
16253
  };
16248
16254
  }
16249
16255
  }
@@ -16433,10 +16439,35 @@ ${text}</tr>
16433
16439
  style: { fontFamily: "var(--font-mono)", fontSize: "11px" }
16434
16440
  }
16435
16441
  ),
16436
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { style: { fontSize: "11px", opacity: 0.65, margin: "6px 0 0 0" }, children: [
16442
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { style: { fontSize: "11px", opacity: 0.65, margin: "6px 0 0 0", lineHeight: 1.5 }, children: [
16437
16443
  "Run once, in order, right after a task worktree is created (git projects only) \u2014 before the agent's first cycle, so it doesn't spend tokens on setup like ",
16438
16444
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "pnpm install" }),
16439
- ". The run stops and the task is blocked if any command fails."
16445
+ ". The run stops and the task is blocked if any command fails.",
16446
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("br", {}),
16447
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("strong", { children: "One line = one command." }),
16448
+ " Each line is run as a ",
16449
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("em", { children: "separate" }),
16450
+ " shell at the worktree root \u2014 this is ",
16451
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("em", { children: "not" }),
16452
+ " a single script. Shell state does not carry over, so a ",
16453
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "cd" }),
16454
+ " on one line has ",
16455
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("em", { children: "no effect" }),
16456
+ " on the next. Chain dependent steps on one line with ",
16457
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "&&" }),
16458
+ " instead, e.g.",
16459
+ " ",
16460
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "cd sub && composer install" }),
16461
+ ".",
16462
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("br", {}),
16463
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("strong", { children: "Heads up on how tasks work:" }),
16464
+ " each task runs on its own git worktree/branch, and every cycle commits ",
16465
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("em", { children: "all" }),
16466
+ " changes in that tree. So anything your bootstrap or the agent writes to the workspace that isn't in ",
16467
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: ".gitignore" }),
16468
+ " gets committed to the branch \u2014 e.g. a package manager that drops a local store or cache in the repo (pnpm's",
16469
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: ".pnpm-store/" }),
16470
+ " under a bind-mounted Docker worktree is a common one). Make sure build/dependency artifacts are gitignored so they don't bloat the task branch."
16440
16471
  ] })
16441
16472
  ] }),
16442
16473
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "form-group", children: [
@@ -16453,6 +16484,42 @@ ${text}</tr>
16453
16484
  }
16454
16485
  ),
16455
16486
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { style: { fontSize: "11px", opacity: 0.65, margin: "6px 0 0 0" }, children: "Wall-clock budget for a single heartbeat cycle, enforced as an abort for every provider. Tasks inherit this and can override it. Leave empty for the default." })
16487
+ ] }),
16488
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "form-group", children: [
16489
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: "project-docker-image", children: "Docker image (optional)" }),
16490
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
16491
+ "input",
16492
+ {
16493
+ id: "project-docker-image",
16494
+ type: "text",
16495
+ value: dockerImage,
16496
+ onChange: (e) => setDockerImage(e.target.value),
16497
+ placeholder: "e.g. node:22 or ./Dockerfile"
16498
+ }
16499
+ ),
16500
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { style: { fontSize: "11px", opacity: 0.65, margin: "6px 0 0 0", lineHeight: 1.5 }, children: [
16501
+ "Run this project's autonomous task agents (dev, planning & review) inside this image. Empty = run on the host.",
16502
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("br", {}),
16503
+ "A value starting with ",
16504
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "." }),
16505
+ ", ",
16506
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "/" }),
16507
+ " or ",
16508
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "\\" }),
16509
+ " is treated as a path to a ",
16510
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("strong", { children: "Dockerfile" }),
16511
+ " (built per-project); anything else is a pullable image ref (e.g. ",
16512
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "node:22" }),
16513
+ ").",
16514
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("br", {}),
16515
+ "The container runs as your user, so put the package manager ",
16516
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("em", { children: "in the image" }),
16517
+ " (e.g. ",
16518
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "corepack enable pnpm" }),
16519
+ ") \u2014 ",
16520
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "npm i -g" }),
16521
+ " fails as non-root. Docker must be installed on the scheduler host."
16522
+ ] })
16456
16523
  ] })
16457
16524
  ] }),
16458
16525
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "form-actions", children: [
@@ -16470,9 +16537,15 @@ ${text}</tr>
16470
16537
  ] }),
16471
16538
  proj.description && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "settings-card__subtitle", style: { fontSize: "11px", opacity: 0.8, marginBottom: "4px" }, children: proj.description }),
16472
16539
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "settings-card__subtitle", style: { fontFamily: "var(--font-mono)", fontSize: "10px" }, children: proj.workingDir }),
16473
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "settings-card__badge", style: { marginTop: "6px" }, children: [
16474
- "Agent: ",
16475
- assignedAgent
16540
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px", marginTop: "6px" }, children: [
16541
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "settings-card__badge", children: [
16542
+ "Agent: ",
16543
+ assignedAgent
16544
+ ] }),
16545
+ proj.dockerImage && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "settings-card__badge", children: [
16546
+ "Docker: ",
16547
+ proj.dockerImage
16548
+ ] })
16476
16549
  ] })
16477
16550
  ] }),
16478
16551
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "settings-card__actions", children: [