@dzhechkov/harness-cli 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.d.ts CHANGED
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * @packageDocumentation
5
5
  */
6
+ import { spawn, type ChildProcess } from 'node:child_process';
7
+ import { runSyncCodexHooks, type CodexHooksSyncReport, type BridgeFamily } from '@dzhechkov/harness-core';
6
8
  /** Output sink + working directory — injectable so the CLI is testable. */
7
9
  export interface CliIo {
8
10
  readonly cwd?: string;
@@ -50,5 +52,101 @@ export type ReleaseExecRunner = (cmd: string, opts: {
50
52
  stderr: string;
51
53
  timedOut?: boolean;
52
54
  };
55
+ export interface CodexHooksSyncInput {
56
+ readonly codexHome?: string | undefined;
57
+ readonly project?: string | undefined;
58
+ readonly check?: boolean;
59
+ readonly remove?: boolean;
60
+ /** `false` = the user's `--no-verify`. Anything else runs the live probe. */
61
+ readonly verify?: boolean;
62
+ }
63
+ /**
64
+ * The argv → operation mapping, extracted so it can be PINNED.
65
+ *
66
+ * It is the mapping that was broken: `--verify`, `--no-verify` and `--project` were parsed,
67
+ * validated, listed in the usage line — and then never reached `runSyncCodexHooks`, so the CRITICAL
68
+ * finding (a `ready` with no live proof behind it) lived entirely in three missing object keys.
69
+ * A function that returns the options object is testable without a codex binary; an inline literal
70
+ * is not.
71
+ */
72
+ export declare function codexHooksSyncOptions(input: CodexHooksSyncInput): Parameters<typeof runSyncCodexHooks>[0];
73
+ export interface CodexHooksSummary {
74
+ readonly ok: boolean;
75
+ readonly stdout: readonly string[];
76
+ readonly stderr: readonly string[];
77
+ }
78
+ /**
79
+ * What the user is told about a sync report — the ONE place the success word can be printed.
80
+ *
81
+ * `report.ready` is the whole gate: installed ∧ executable ∧ trusted ∧ a live, non-bypassed probe
82
+ * that WITNESSED our block. Nothing else may print "ready" (AM-17 / G-G), and `--no-verify` never
83
+ * can, because it never measured.
84
+ */
85
+ export declare function codexHooksSummary(report: CodexHooksSyncReport, label?: string): CodexHooksSummary;
86
+ export declare function deliverCodexHooks(input: CodexHooksSyncInput, sync?: (options: Parameters<typeof runSyncCodexHooks>[0]) => CodexHooksSyncReport, label?: string): CodexHooksSummary & {
87
+ readonly report: CodexHooksSyncReport;
88
+ };
89
+ /** Test seam for the chokepoint: NEW-C4's proof needs to call it with a hostile pid. */
90
+ export declare function __wfSignalChildTestSeam(child: unknown, signal: string, detached: boolean): boolean;
91
+ /** Exposed for the unit test: the kill set must NAME every live child's pid. */
92
+ export declare function __wfKillGroupTestSeam(): {
93
+ register: (pid: number, child: ChildProcess) => void;
94
+ killAll: () => number[];
95
+ size: () => number;
96
+ };
97
+ export interface ClaudeBridgeRun {
98
+ stdout: string;
99
+ stderr: string;
100
+ exitCode: number | null;
101
+ timedOut: boolean;
102
+ spawnError: string | null;
103
+ }
104
+ /**
105
+ * Run one `claude` call with the prompt on STDIN. Spawn-injectable, and NEVER throws: a missing
106
+ * binary, a crash and a hang all come back as DATA, because the taxonomy above them can only name
107
+ * a failure it is handed. (The first draft of this function let the ENOENT escape as an uncaught
108
+ * exception and the command never settled — the acid A1 red, quoted in red-green.md.)
109
+ *
110
+ * Mirrors `probeContent`'s settled-flag + SIGTERM deadline shape (`cli.ts` probes) and scrubs
111
+ * `PROBE_SCRUB_ENV`, so a bridge launched from inside a nested Claude session cannot inherit the
112
+ * parent's session identity (SEC-4).
113
+ */
114
+ export declare function runClaudeBridge(bin: string, argv: string[], promptStdin: string, timeoutMs: number, cwd?: string, spawnImpl?: typeof spawn): Promise<ClaudeBridgeRun>;
115
+ /** Test seam for H9: the exact environment ONE family's child would receive. */
116
+ export declare function __wfChildEnvTestSeam(family: BridgeFamily, parent: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
117
+ /**
118
+ * THE child-process wrapper both the qe-bridge and the loop runner ride (ADR-002 O1: ONE impure
119
+ * wrapper, not two). Generalized from `runClaudeBridge` with the same guarantees — a settled flag so
120
+ * no path resolves twice, a deadline timer that SIGTERMs, the `PROBE_SCRUB_ENV` scrub so a bridge
121
+ * launched from inside a nested Claude session cannot inherit it, and an injectable `spawnImpl` —
122
+ * plus the two knobs the generalization adds:
123
+ *
124
+ * • `stdinText: null` ⇒ `stdio[0] = 'ignore'`. MEASURED: codex-cli 0.148.0 prints
125
+ * `Reading additional input from stdin...` and WAITS when stdin is left open. Passing an empty
126
+ * string is not the same thing as closing it.
127
+ * • `detached: true` ⇒ the child leads its OWN process group, so the runner can kill the whole
128
+ * group (AM-10). `onSpawn` hands the live child to the caller's registry at the only moment the
129
+ * pid is knowable.
130
+ *
131
+ * Never throws: a spawn failure resolves with `spawnError` set, exactly like the original.
132
+ */
133
+ export declare function runChildBridge(bin: string, argv: string[], opts: {
134
+ stdinText: string | null;
135
+ timeoutMs: number;
136
+ cwd: string;
137
+ detached: boolean;
138
+ spawnImpl?: typeof spawn;
139
+ onSpawn?: (child: ChildProcess) => void;
140
+ /**
141
+ * `'scrub'` (default) — inherit the parent environment minus `PROBE_SCRUB_ENV`. The historical
142
+ * qe-bridge posture; unchanged so its suites keep their meaning.
143
+ * `'allowlist'` — build the child's environment from a NAMED list and nothing else
144
+ * (Step-8 HIGH-9). A deny-list can only remove what somebody thought of; every cloud token,
145
+ * registry credential and unrelated secret in the parent survived it. The loop runner uses this.
146
+ */
147
+ envMode?: 'scrub' | 'allowlist';
148
+ /** Extra variable names the allowlist should carry (a family's own auth, named by the caller). */
149
+ envExtra?: readonly string[];
150
+ }): Promise<ClaudeBridgeRun>;
53
151
  export declare function runCli(argv: string[], io?: CliIo): Promise<number>;
54
152
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAsdH,2EAA2E;AAC3E,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAA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