@vibe-agent-toolkit/utils 0.1.39-rc.1 → 0.1.39-rc.11

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 (70) hide show
  1. package/dist/fs/file-hash.d.ts +17 -0
  2. package/dist/fs/file-hash.d.ts.map +1 -0
  3. package/dist/fs/file-hash.js +23 -0
  4. package/dist/fs/file-hash.js.map +1 -0
  5. package/dist/git-url.d.ts +43 -0
  6. package/dist/git-url.d.ts.map +1 -0
  7. package/dist/git-url.js +135 -0
  8. package/dist/git-url.js.map +1 -0
  9. package/dist/glob/glob-pattern.d.ts +62 -0
  10. package/dist/glob/glob-pattern.d.ts.map +1 -0
  11. package/dist/glob/glob-pattern.js +115 -0
  12. package/dist/glob/glob-pattern.js.map +1 -0
  13. package/dist/index.d.ts +9 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +12 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/link-auth/build-headers.d.ts +34 -0
  18. package/dist/link-auth/build-headers.d.ts.map +1 -0
  19. package/dist/link-auth/build-headers.js +58 -0
  20. package/dist/link-auth/build-headers.js.map +1 -0
  21. package/dist/link-auth/expand-macro.d.ts +38 -0
  22. package/dist/link-auth/expand-macro.d.ts.map +1 -0
  23. package/dist/link-auth/expand-macro.js +131 -0
  24. package/dist/link-auth/expand-macro.js.map +1 -0
  25. package/dist/link-auth/macros.yaml +50 -0
  26. package/dist/link-auth/resolve-token.d.ts +49 -0
  27. package/dist/link-auth/resolve-token.d.ts.map +1 -0
  28. package/dist/link-auth/resolve-token.js +72 -0
  29. package/dist/link-auth/resolve-token.js.map +1 -0
  30. package/dist/link-auth/resolve.d.ts +58 -0
  31. package/dist/link-auth/resolve.d.ts.map +1 -0
  32. package/dist/link-auth/resolve.js +55 -0
  33. package/dist/link-auth/resolve.js.map +1 -0
  34. package/dist/link-auth/rewrite.d.ts +52 -0
  35. package/dist/link-auth/rewrite.d.ts.map +1 -0
  36. package/dist/link-auth/rewrite.js +102 -0
  37. package/dist/link-auth/rewrite.js.map +1 -0
  38. package/dist/link-auth/select-provider.d.ts +30 -0
  39. package/dist/link-auth/select-provider.d.ts.map +1 -0
  40. package/dist/link-auth/select-provider.js +55 -0
  41. package/dist/link-auth/select-provider.js.map +1 -0
  42. package/dist/link-auth/template.d.ts +40 -0
  43. package/dist/link-auth/template.d.ts.map +1 -0
  44. package/dist/link-auth/template.js +89 -0
  45. package/dist/link-auth/template.js.map +1 -0
  46. package/dist/link-auth/transforms.d.ts +46 -0
  47. package/dist/link-auth/transforms.d.ts.map +1 -0
  48. package/dist/link-auth/transforms.js +52 -0
  49. package/dist/link-auth/transforms.js.map +1 -0
  50. package/dist/path-utils.d.ts +35 -3
  51. package/dist/path-utils.d.ts.map +1 -1
  52. package/dist/path-utils.js +63 -3
  53. package/dist/path-utils.js.map +1 -1
  54. package/dist/skill-test/auth-resolver.d.ts +34 -0
  55. package/dist/skill-test/auth-resolver.d.ts.map +1 -0
  56. package/dist/skill-test/auth-resolver.js +68 -0
  57. package/dist/skill-test/auth-resolver.js.map +1 -0
  58. package/dist/skill-test/env-scrub.d.ts +61 -0
  59. package/dist/skill-test/env-scrub.d.ts.map +1 -0
  60. package/dist/skill-test/env-scrub.js +112 -0
  61. package/dist/skill-test/env-scrub.js.map +1 -0
  62. package/dist/skill-test/index.d.ts +4 -0
  63. package/dist/skill-test/index.d.ts.map +1 -0
  64. package/dist/skill-test/index.js +4 -0
  65. package/dist/skill-test/index.js.map +1 -0
  66. package/dist/skill-test/spawn-claude.d.ts +45 -0
  67. package/dist/skill-test/spawn-claude.d.ts.map +1 -0
  68. package/dist/skill-test/spawn-claude.js +92 -0
  69. package/dist/skill-test/spawn-claude.js.map +1 -0
  70. package/package.json +4 -3
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Build the forwarded environment for the headless `claude` child using a
3
+ * STRICT exact-name allowlist (spec §14). We never forward ANTHROPIC_* by
4
+ * prefix — that would silently leak ANTHROPIC_ADMIN_API_KEY, proxy overrides,
5
+ * etc. into untrusted skill code. Anything not enumerated is dropped.
6
+ */
7
+ export interface ForwardEnvOptions {
8
+ /** True under --auth subscription (and inherit-with-subscription): drop the inference key so the child uses OAuth. */
9
+ scrubInferenceKey: boolean;
10
+ /** Additional exact model var names the run needs (e.g. ANTHROPIC_MODEL). */
11
+ modelVars?: string[];
12
+ }
13
+ export declare function buildForwardedEnv(source: NodeJS.ProcessEnv, opts: ForwardEnvOptions): NodeJS.ProcessEnv;
14
+ /**
15
+ * The full set of env var names protected from declared override. A declared
16
+ * passEnv/injectEnv entry naming one of these is ignored (the protected value
17
+ * wins) and a warning is surfaced — a test must never clobber PATH, the auth
18
+ * credentials, or the admin key. `modelVars` (run-specific model env var names)
19
+ * join the set so a declared var can't shadow them either.
20
+ */
21
+ export declare function protectedEnvNames(modelVars?: readonly string[]): Set<string>;
22
+ /** Declared test env (Features A + B) to union onto a forwarded env. */
23
+ export interface DeclaredEnvInput {
24
+ /** Parent env to read Feature-A pass-through values from. */
25
+ source: NodeJS.ProcessEnv;
26
+ /** Feature A: names to forward from `source` if present. */
27
+ passEnv?: readonly string[];
28
+ /** Feature B: explicit key→value injections (already interpolated). */
29
+ injectEnv?: Record<string, string>;
30
+ /** Run-specific model env var names that are also protected. */
31
+ modelVars?: readonly string[];
32
+ }
33
+ export interface DeclaredEnvResult {
34
+ /** The forwarded env with declared additions unioned in. */
35
+ env: NodeJS.ProcessEnv;
36
+ /** Human-readable warnings (protected-key collisions). */
37
+ warnings: string[];
38
+ /** Names injected via Feature B (shown in the transparency line). */
39
+ injected: string[];
40
+ /** Names passed through via Feature A (redacted in the transparency line). */
41
+ passedThrough: string[];
42
+ }
43
+ /**
44
+ * Union declared test env (Features A + B) onto an already-built forwarded env.
45
+ * Protected keys always win: a declared name colliding with a process-essential,
46
+ * auth, model, or admin var is ignored and a warning emitted. Feature-B injection
47
+ * (explicit value) takes precedence over Feature-A pass-through for the same key.
48
+ * The input `base` object is never mutated.
49
+ */
50
+ export declare function applyDeclaredEnv(base: NodeJS.ProcessEnv, input: DeclaredEnvInput): DeclaredEnvResult;
51
+ /**
52
+ * Render the single-line stderr transparency summary of the forwarded env. Key
53
+ * names are always shown. Auth/secret values are redacted; Feature-A pass-through
54
+ * values are redacted (host-sourced, may be a secret); Feature-B injected values
55
+ * are shown (they come from committed config).
56
+ */
57
+ export declare function formatForwardedEnvLine(env: NodeJS.ProcessEnv, classified: {
58
+ injected: readonly string[];
59
+ passedThrough: readonly string[];
60
+ }): string;
61
+ //# sourceMappingURL=env-scrub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-scrub.d.ts","sourceRoot":"","sources":["../../src/skill-test/env-scrub.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,iBAAiB;IAChC,sHAAsH;IACtH,iBAAiB,EAAE,OAAO,CAAC;IAC3B,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAWD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,IAAI,EAAE,iBAAiB,GACtB,MAAM,CAAC,UAAU,CAuBnB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,GAAE,SAAS,MAAM,EAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAQhF;AAED,wEAAwE;AACxE,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,gEAAgE;IAChE,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,8EAA8E;IAC9E,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,CAiCpG;AAKD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,UAAU,EAAE;IAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC5E,MAAM,CAUR"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Build the forwarded environment for the headless `claude` child using a
3
+ * STRICT exact-name allowlist (spec §14). We never forward ANTHROPIC_* by
4
+ * prefix — that would silently leak ANTHROPIC_ADMIN_API_KEY, proxy overrides,
5
+ * etc. into untrusted skill code. Anything not enumerated is dropped.
6
+ */
7
+ /** Process-essential vars that must survive for the child to even start. */
8
+ const PROCESS_ESSENTIALS = ['PATH', 'Path', 'HOME', 'USERPROFILE', 'SystemRoot', 'TEMP', 'TMP', 'TMPDIR', 'LANG', 'LC_ALL'];
9
+ /** The only auth/config vars ever forwarded. */
10
+ const AUTH_CONFIG_ALLOWLIST = ['CLAUDE_CONFIG_DIR'];
11
+ /** The active inference credential candidates (forwarded unless scrubbed). */
12
+ const INFERENCE_CREDENTIALS = ['ANTHROPIC_API_KEY', 'ANTHROPIC_AUTH_TOKEN'];
13
+ export function buildForwardedEnv(source, opts) {
14
+ const out = {};
15
+ const allow = new Set([
16
+ ...PROCESS_ESSENTIALS,
17
+ ...AUTH_CONFIG_ALLOWLIST,
18
+ ...(opts.modelVars ?? []),
19
+ ]);
20
+ if (!opts.scrubInferenceKey) {
21
+ for (const name of INFERENCE_CREDENTIALS)
22
+ allow.add(name);
23
+ }
24
+ for (const name of allow) {
25
+ const value = source[name];
26
+ if (value !== undefined)
27
+ out[name] = value;
28
+ }
29
+ // ANTHROPIC_ADMIN_API_KEY and CLAUDECODE/CLAUDE_CODE_* are never in `allow`,
30
+ // so they are dropped by construction. No explicit delete needed — but assert
31
+ // the invariant defensively so a future allowlist edit can't reintroduce it.
32
+ delete out['ANTHROPIC_ADMIN_API_KEY'];
33
+ return out;
34
+ }
35
+ /**
36
+ * The full set of env var names protected from declared override. A declared
37
+ * passEnv/injectEnv entry naming one of these is ignored (the protected value
38
+ * wins) and a warning is surfaced — a test must never clobber PATH, the auth
39
+ * credentials, or the admin key. `modelVars` (run-specific model env var names)
40
+ * join the set so a declared var can't shadow them either.
41
+ */
42
+ export function protectedEnvNames(modelVars = []) {
43
+ return new Set([
44
+ ...PROCESS_ESSENTIALS,
45
+ ...AUTH_CONFIG_ALLOWLIST,
46
+ ...INFERENCE_CREDENTIALS,
47
+ 'ANTHROPIC_ADMIN_API_KEY',
48
+ ...modelVars,
49
+ ]);
50
+ }
51
+ /**
52
+ * Union declared test env (Features A + B) onto an already-built forwarded env.
53
+ * Protected keys always win: a declared name colliding with a process-essential,
54
+ * auth, model, or admin var is ignored and a warning emitted. Feature-B injection
55
+ * (explicit value) takes precedence over Feature-A pass-through for the same key.
56
+ * The input `base` object is never mutated.
57
+ */
58
+ export function applyDeclaredEnv(base, input) {
59
+ const out = { ...base };
60
+ const protectedNames = protectedEnvNames(input.modelVars);
61
+ const warnings = [];
62
+ const injected = [];
63
+ const passedThrough = [];
64
+ const injectKeys = new Set(Object.keys(input.injectEnv ?? {}));
65
+ // Feature A: pass-through by name.
66
+ for (const name of input.passEnv ?? []) {
67
+ if (protectedNames.has(name)) {
68
+ warnings.push(`passEnv "${name}" ignored: it collides with a protected variable.`);
69
+ continue;
70
+ }
71
+ if (injectKeys.has(name))
72
+ continue; // Feature B wins for the same key.
73
+ const value = input.source[name];
74
+ if (value === undefined)
75
+ continue; // absent host var → simply not forwarded.
76
+ out[name] = value;
77
+ passedThrough.push(name);
78
+ }
79
+ // Feature B: explicit value injection.
80
+ for (const [name, value] of Object.entries(input.injectEnv ?? {})) {
81
+ if (protectedNames.has(name)) {
82
+ warnings.push(`env "${name}" ignored: it collides with a protected variable.`);
83
+ continue;
84
+ }
85
+ out[name] = value;
86
+ injected.push(name);
87
+ }
88
+ return { env: out, warnings, injected, passedThrough };
89
+ }
90
+ /** Names whose VALUES are secrets and must be redacted in the transparency line. */
91
+ const SECRET_NAMES = new Set(INFERENCE_CREDENTIALS);
92
+ /**
93
+ * Render the single-line stderr transparency summary of the forwarded env. Key
94
+ * names are always shown. Auth/secret values are redacted; Feature-A pass-through
95
+ * values are redacted (host-sourced, may be a secret); Feature-B injected values
96
+ * are shown (they come from committed config).
97
+ */
98
+ export function formatForwardedEnvLine(env, classified) {
99
+ const injected = new Set(classified.injected);
100
+ const passedThrough = new Set(classified.passedThrough);
101
+ const parts = Object.keys(env).map((name) => {
102
+ if (injected.has(name))
103
+ return `${name}=${env[name] ?? ''}`;
104
+ if (passedThrough.has(name))
105
+ return `${name}(passed-through, redacted)`;
106
+ if (SECRET_NAMES.has(name))
107
+ return `${name}(redacted)`;
108
+ return name;
109
+ });
110
+ return `forwarded env: ${parts.join(', ')}`;
111
+ }
112
+ //# sourceMappingURL=env-scrub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-scrub.js","sourceRoot":"","sources":["../../src/skill-test/env-scrub.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,4EAA4E;AAC5E,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAU,CAAC;AAErI,gDAAgD;AAChD,MAAM,qBAAqB,GAAG,CAAC,mBAAmB,CAAU,CAAC;AAE7D,8EA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D,CAAC;AAED,oFAAoF;AACpF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS,qBAAqB,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,GAAsB,EACtB,UAA6E;IAE7E,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,GAAG,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5D,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,GAAG,IAAI,4BAA4B,CAAC;QACxE,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,GAAG,IAAI,YAAY,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,OAAO,kBAAkB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { applyDeclaredEnv, buildForwardedEnv, formatForwardedEnvLine, protectedEnvNames, type DeclaredEnvInput, type DeclaredEnvResult, type ForwardEnvOptions, } from './env-scrub.js';
2
+ export { AuthPreflightError, probeAuthStatus, resolveAuth, type AuthMechanism, type AuthMode, type AuthStatusProbe, type AuthStatusResult, type ResolveAuthOptions, type ResolvedAuth, } from './auth-resolver.js';
3
+ export { assembleClaudeArgs, spawnHeadlessClaude, type ClaudeSpawnArgs, type SpawnHeadlessOptions, type SpawnResult, } from './spawn-claude.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/skill-test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { applyDeclaredEnv, buildForwardedEnv, formatForwardedEnvLine, protectedEnvNames, } from './env-scrub.js';
2
+ export { AuthPreflightError, probeAuthStatus, resolveAuth, } from './auth-resolver.js';
3
+ export { assembleClaudeArgs, spawnHeadlessClaude, } from './spawn-claude.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skill-test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,GAIlB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,WAAW,GAOZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GAIpB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,45 @@
1
+ export interface ClaudeSpawnArgs {
2
+ pluginDirs: string[];
3
+ sandboxDir: string;
4
+ model?: string;
5
+ maxTurns?: number;
6
+ maxBudgetUsd?: number;
7
+ }
8
+ /**
9
+ * Pure assembly of the headless `claude -p` argv (spec §9). The prompt is never
10
+ * inlined as an argv string (Windows cmd-quoting safety) and claude 2.x has no
11
+ * `--prompt-file` flag — the prompt is fed to the child's stdin by
12
+ * {@link spawnHeadlessClaude} instead. `--setting-sources ""` suppresses
13
+ * user/project settings; built-in skills remain (§5).
14
+ */
15
+ export declare function assembleClaudeArgs(opts: ClaudeSpawnArgs): string[];
16
+ export interface SpawnResult {
17
+ status: number;
18
+ timedOut: boolean;
19
+ stalled: boolean;
20
+ }
21
+ export interface SpawnHeadlessOptions extends ClaudeSpawnArgs {
22
+ /**
23
+ * Path to the experimenter-prompt file. Its contents are streamed to the
24
+ * child's stdin (claude 2.x reads the `-p` prompt from stdin; there is no
25
+ * `--prompt-file` flag). Kept off argv so the prompt is never inlined
26
+ * (Windows cmd-quoting safety).
27
+ */
28
+ promptFile: string;
29
+ cwd: string;
30
+ env: NodeJS.ProcessEnv;
31
+ timeoutMs: number;
32
+ /** If set, SIGKILL the child if no stdout/stderr output is received for this many ms. */
33
+ stallMs?: number;
34
+ onStdout?: (chunk: string) => void;
35
+ onStderr?: (chunk: string) => void;
36
+ }
37
+ /**
38
+ * Spawn the headless `claude`. The prompt file is streamed to the child's stdin
39
+ * so the session reads its prompt and then sees EOF (it cannot block on input,
40
+ * §16). Wall-clock kill on timeout. If `stallMs` is set, a resettable stall
41
+ * watchdog kills the child when no output is received for that duration
42
+ * (stalled: true in result).
43
+ */
44
+ export declare function spawnHeadlessClaude(opts: SpawnHeadlessOptions): Promise<SpawnResult>;
45
+ //# sourceMappingURL=spawn-claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn-claude.d.ts","sourceRoot":"","sources":["../../src/skill-test/spawn-claude.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,EAAE,CAmBlE;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAsD1F"}
@@ -0,0 +1,92 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { createReadStream } from 'node:fs';
3
+ import which from 'which';
4
+ /**
5
+ * Pure assembly of the headless `claude -p` argv (spec §9). The prompt is never
6
+ * inlined as an argv string (Windows cmd-quoting safety) and claude 2.x has no
7
+ * `--prompt-file` flag — the prompt is fed to the child's stdin by
8
+ * {@link spawnHeadlessClaude} instead. `--setting-sources ""` suppresses
9
+ * user/project settings; built-in skills remain (§5).
10
+ */
11
+ export function assembleClaudeArgs(opts) {
12
+ const args = [
13
+ '-p',
14
+ // claude 2.x rejects `-p --output-format stream-json` unless --verbose is
15
+ // also passed ("--output-format=stream-json requires --verbose"). The
16
+ // streamed JSON is piped to stderr for progress visibility.
17
+ '--output-format', 'stream-json',
18
+ '--verbose',
19
+ '--setting-sources', '',
20
+ '--permission-mode', 'bypassPermissions',
21
+ '--add-dir', opts.sandboxDir,
22
+ ];
23
+ for (const dir of opts.pluginDirs) {
24
+ args.push('--plugin-dir', dir);
25
+ }
26
+ if (opts.model !== undefined)
27
+ args.push('--model', opts.model);
28
+ if (opts.maxTurns !== undefined)
29
+ args.push('--max-turns', String(opts.maxTurns));
30
+ if (opts.maxBudgetUsd !== undefined)
31
+ args.push('--max-budget-usd', String(opts.maxBudgetUsd));
32
+ return args;
33
+ }
34
+ /**
35
+ * Spawn the headless `claude`. The prompt file is streamed to the child's stdin
36
+ * so the session reads its prompt and then sees EOF (it cannot block on input,
37
+ * §16). Wall-clock kill on timeout. If `stallMs` is set, a resettable stall
38
+ * watchdog kills the child when no output is received for that duration
39
+ * (stalled: true in result).
40
+ */
41
+ export async function spawnHeadlessClaude(opts) {
42
+ const bin = which.sync('claude');
43
+ const args = assembleClaudeArgs(opts);
44
+ return await new Promise((resolve, reject) => {
45
+ const child = spawn(bin, args, { cwd: opts.cwd, env: opts.env, stdio: ['pipe', 'pipe', 'pipe'] });
46
+ let timedOut = false;
47
+ let stalled = false;
48
+ const wallTimer = setTimeout(() => {
49
+ timedOut = true;
50
+ child.kill('SIGKILL');
51
+ }, opts.timeoutMs);
52
+ // Stall watchdog: reset on every stdout/stderr chunk; fire if silent for stallMs.
53
+ let stallTimer;
54
+ if (opts.stallMs !== undefined) {
55
+ const stallMs = opts.stallMs;
56
+ const resetStallTimer = () => {
57
+ if (stallTimer !== undefined)
58
+ clearTimeout(stallTimer);
59
+ stallTimer = setTimeout(() => {
60
+ stalled = true;
61
+ child.kill('SIGKILL');
62
+ }, stallMs);
63
+ };
64
+ resetStallTimer();
65
+ child.stdout.on('data', () => { resetStallTimer(); });
66
+ child.stderr.on('data', () => { resetStallTimer(); });
67
+ }
68
+ const clearAllTimers = () => {
69
+ clearTimeout(wallTimer);
70
+ if (stallTimer !== undefined)
71
+ clearTimeout(stallTimer);
72
+ };
73
+ // Feed the prompt to the child via stdin (claude 2.x has no --prompt-file).
74
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- our own derived prompt path
75
+ const promptStream = createReadStream(opts.promptFile);
76
+ promptStream.on('error', err => {
77
+ clearAllTimers();
78
+ child.kill('SIGKILL');
79
+ reject(err);
80
+ });
81
+ // Swallow EPIPE: if the child exits before consuming all stdin, the write
82
+ // end errors — that is not a harness failure (the close handler reports the
83
+ // child's real exit status).
84
+ child.stdin.on('error', () => { });
85
+ promptStream.pipe(child.stdin);
86
+ child.stdout.on('data', (d) => { opts.onStdout?.(d.toString()); });
87
+ child.stderr.on('data', (d) => { opts.onStderr?.(d.toString()); });
88
+ child.on('error', err => { clearAllTimers(); reject(err); });
89
+ child.on('close', code => { clearAllTimers(); resolve({ status: code ?? -1, timedOut, stalled }); });
90
+ });
91
+ }
92
+ //# sourceMappingURL=spawn-claude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn-claude.js","sourceRoot":"","sources":["../../src/skill-test/spawn-claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAqB;IACtD,MAAM,IAAI,GAAa;QACrB,IAAI;QACJ,0EAA0E;QAC1E,sEAAsE;QACtE,4DAA4D;QAC5D,iBAAiB,EAAE,aAAa;QAChC,WAAW;QACX,mBAAmB,EAAE,EAAE;QACvB,mBAAmB,EAAE,mBAAmB;QACxC,WAAW,EAAE,IAAI,CAAC,UAAU;KAC7B,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,I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AAK,CAAC,CAAC;QAC/B,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvG,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-agent-toolkit/utils",
3
- "version": "0.1.39-rc.1",
3
+ "version": "0.1.39-rc.11",
4
4
  "type": "module",
5
5
  "description": "Core utility functions with no external dependencies",
6
6
  "keywords": [
@@ -23,7 +23,7 @@
23
23
  "README.md"
24
24
  ],
25
25
  "scripts": {
26
- "build": "tsc",
26
+ "build": "tsc && tsx ../dev-tools/src/copy-yaml-assets.ts",
27
27
  "test": "vitest run",
28
28
  "test:watch": "vitest",
29
29
  "typecheck": "tsc --noEmit",
@@ -33,7 +33,8 @@
33
33
  "handlebars": "^4.7.8",
34
34
  "ignore": "^7.0.5",
35
35
  "picomatch": "^4.0.3",
36
- "which": "^5.0.0"
36
+ "which": "^5.0.0",
37
+ "yaml": "^2.6.1"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "zod": "^3.25.0 || ^4.0.0"