@hyperwindmill/caretaker-cli 0.12.0 → 0.12.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.
@@ -1 +1 @@
1
- {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../../src/harness/tools/builtin/bash.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAqCxC,eAAO,MAAM,QAAQ,EAAE,IA4GtB,CAAC"}
1
+ {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../../src/harness/tools/builtin/bash.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAkBxC,eAAO,MAAM,QAAQ,EAAE,IA4GtB,CAAC"}
@@ -1,36 +1,18 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { StringDecoder } from 'node:string_decoder';
3
- import { mergeShellEnv } from './shell-env.js';
3
+ import { commandEnv } from './shell-env.js';
4
4
  const DEFAULT_TIMEOUT_MS = 30_000;
5
5
  /** Cap on stdout+stderr we echo back to the model. The harness applies a
6
6
  * separate global cap on tool results; this keeps memory bounded inside
7
7
  * the bash tool itself for very chatty commands. */
8
8
  const MAX_OUTPUT_BYTES = 50_000;
9
- // Env var patterns scrubbed from the spawned child env. Mirrors caretaker
10
- // server's policy in src/mcp/shell.ts: keep tokens/keys/secrets out of
11
- // command-line tools the agent runs.
12
- const SECRET_ENV_PATTERNS = [/^OPENCODE_/, /^CLAUDE_/, /_TOKEN$/, /_KEY$/, /_SECRET$/];
13
- function scrubbedEnv() {
14
- const out = {};
15
- for (const [k, v] of Object.entries(process.env)) {
16
- if (SECRET_ENV_PATTERNS.some((re) => re.test(k)))
17
- continue;
18
- out[k] = v;
19
- }
20
- return out;
21
- }
22
9
  /**
23
- * Build the environment for bash subprocesses.
24
- * On Linux, merges the probed interactive shell environment to capture
25
- * PATH and version manager variables (NVM, volta, fnm, etc.) that
26
- * .bashrc sets but which are missing in non-interactive shells.
10
+ * Build the environment for bash subprocesses. Delegates to the shared
11
+ * `commandEnv()` so the bash tool and the task bootstrap/git helpers use
12
+ * one scrub + probe-merge policy.
27
13
  */
28
14
  function bashEnv() {
29
- const base = scrubbedEnv();
30
- if (process.platform === 'linux') {
31
- return mergeShellEnv(base);
32
- }
33
- return base;
15
+ return commandEnv();
34
16
  }
35
17
  export const bashTool = {
36
18
  name: 'bash',
@@ -52,4 +52,29 @@ export declare function getShellEnv(): Record<string, string>;
52
52
  * variables are set only if not already present in the env.
53
53
  */
54
54
  export declare function mergeShellEnv(existingEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
55
+ /**
56
+ * Env var patterns scrubbed from spawned command envs. Shared by the bash
57
+ * tool and by bootstrap/git spawns so unattended runs don't leak tokens.
58
+ * Mirrors the caretaker server's policy in src/mcp/shell.ts.
59
+ */
60
+ export declare const SECRET_ENV_PATTERNS: RegExp[];
61
+ /**
62
+ * Base env for spawned shells: process.env with secret vars scrubbed.
63
+ * Used by both the bash tool and the task bootstrap/git helpers so the
64
+ * same scrub policy applies everywhere a command is spawned.
65
+ */
66
+ export declare function scrubbedEnv(): NodeJS.ProcessEnv;
67
+ /**
68
+ * Build the env for a spawned shell command: scrubbed process.env, with the
69
+ * probed interactive-shell PATH and version-manager vars merged in on Linux.
70
+ * macOS/Windows return the scrubbed env unchanged (login shells there already
71
+ * source profiles correctly). Mirrors what the `bash` tool uses.
72
+ */
73
+ export declare function commandEnv(): NodeJS.ProcessEnv;
74
+ /**
75
+ * @internal Test-only: set the cached probe result directly so tests can
76
+ * exercise the env-merge path without running a real interactive shell probe.
77
+ * Production code never calls this.
78
+ */
79
+ export declare function setShellEnvForTest(env: Record<string, string>): void;
55
80
  //# sourceMappingURL=shell-env.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell-env.d.ts","sourceRoot":"","sources":["../../../../src/harness/tools/builtin/shell-env.ts"],"names":[],"mappings":"A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IG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAAC,UAAU,CAO/C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAAC,UAAU,CAM9C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAEpE"}
@@ -179,3 +179,50 @@ export function mergeShellEnv(existingEnv) {
179
179
  }
180
180
  return merged;
181
181
  }
182
+ /**
183
+ * Env var patterns scrubbed from spawned command envs. Shared by the bash
184
+ * tool and by bootstrap/git spawns so unattended runs don't leak tokens.
185
+ * Mirrors the caretaker server's policy in src/mcp/shell.ts.
186
+ */
187
+ export const SECRET_ENV_PATTERNS = [
188
+ /^OPENCODE_/,
189
+ /^CLAUDE_/,
190
+ /_TOKEN$/,
191
+ /_KEY$/,
192
+ /_SECRET$/,
193
+ ];
194
+ /**
195
+ * Base env for spawned shells: process.env with secret vars scrubbed.
196
+ * Used by both the bash tool and the task bootstrap/git helpers so the
197
+ * same scrub policy applies everywhere a command is spawned.
198
+ */
199
+ export function scrubbedEnv() {
200
+ const out = {};
201
+ for (const [k, v] of Object.entries(process.env)) {
202
+ if (SECRET_ENV_PATTERNS.some((re) => re.test(k)))
203
+ continue;
204
+ out[k] = v;
205
+ }
206
+ return out;
207
+ }
208
+ /**
209
+ * Build the env for a spawned shell command: scrubbed process.env, with the
210
+ * probed interactive-shell PATH and version-manager vars merged in on Linux.
211
+ * macOS/Windows return the scrubbed env unchanged (login shells there already
212
+ * source profiles correctly). Mirrors what the `bash` tool uses.
213
+ */
214
+ export function commandEnv() {
215
+ const base = scrubbedEnv();
216
+ if (process.platform === "linux") {
217
+ return mergeShellEnv(base);
218
+ }
219
+ return base;
220
+ }
221
+ /**
222
+ * @internal Test-only: set the cached probe result directly so tests can
223
+ * exercise the env-merge path without running a real interactive shell probe.
224
+ * Production code never calls this.
225
+ */
226
+ export function setShellEnvForTest(env) {
227
+ cachedResult = { env, success: true };
228
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"task_git.d.ts","sourceRoot":"","sources":["../../src/lib/task_git.ts"],"names":[],"mappings":"AAcA,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,EACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC,CAe5E;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAYjF;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"}
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,EACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC,CAe5E;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBjF;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"}
@@ -3,10 +3,15 @@ import { promisify } from 'node:util';
3
3
  import { rm } from 'node:fs/promises';
4
4
  import { join, relative, dirname } from 'node:path';
5
5
  import { dataDir } from '../store/db.js';
6
+ import { commandEnv } from '../harness/tools/builtin/shell-env.js';
6
7
  const exec = promisify(execFile);
7
8
  const execShell = promisify(execCb);
8
9
  async function git(cwd, args) {
9
- const { stdout } = await exec('git', args, { cwd, maxBuffer: 32 * 1024 * 1024 });
10
+ const { stdout } = await exec('git', args, {
11
+ cwd,
12
+ env: commandEnv(),
13
+ maxBuffer: 32 * 1024 * 1024,
14
+ });
10
15
  return stdout.trim();
11
16
  }
12
17
  export async function isGitRepo(dir) {
@@ -61,7 +66,12 @@ export async function runBootstrap(cwd, commands) {
61
66
  if (!cmd)
62
67
  continue;
63
68
  try {
64
- await execShell(cmd, { cwd, timeout: 10 * 60 * 1000, maxBuffer: 32 * 1024 * 1024 });
69
+ await execShell(cmd, {
70
+ cwd,
71
+ env: commandEnv(),
72
+ timeout: 10 * 60 * 1000,
73
+ maxBuffer: 32 * 1024 * 1024,
74
+ });
65
75
  }
66
76
  catch (err) {
67
77
  const e = err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperwindmill/caretaker-cli",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "type": "module",
5
5
  "description": "Caretaker — in-process agent harness, TUI, file-based state.",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -83,8 +83,8 @@
83
83
  "typescript": "^5.9.3",
84
84
  "typescript-eslint": "^8.59.2",
85
85
  "zod": "^4.4.3",
86
- "caretaker-types": "0.12.0",
87
- "webview-ui": "0.12.0"
86
+ "caretaker-types": "0.12.1",
87
+ "webview-ui": "0.12.1"
88
88
  },
89
89
  "dependencies": {
90
90
  "@hono/node-server": "^2.0.4",