@wildorder/nightshift 0.13.0 → 0.15.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.
Files changed (73) hide show
  1. package/README.md +64 -26
  2. package/dist/agent-probe.d.ts +21 -2
  3. package/dist/agent-probe.d.ts.map +1 -1
  4. package/dist/agent-probe.js +76 -22
  5. package/dist/agent-probe.js.map +1 -1
  6. package/dist/agent-runner.d.ts +90 -2
  7. package/dist/agent-runner.d.ts.map +1 -1
  8. package/dist/agent-runner.js +382 -24
  9. package/dist/agent-runner.js.map +1 -1
  10. package/dist/agent-summary.d.ts +15 -0
  11. package/dist/agent-summary.d.ts.map +1 -1
  12. package/dist/agent-summary.js +32 -2
  13. package/dist/agent-summary.js.map +1 -1
  14. package/dist/as-built.d.ts +6 -0
  15. package/dist/as-built.d.ts.map +1 -1
  16. package/dist/as-built.js +7 -0
  17. package/dist/as-built.js.map +1 -1
  18. package/dist/author.d.ts +13 -3
  19. package/dist/author.d.ts.map +1 -1
  20. package/dist/author.js +267 -30
  21. package/dist/author.js.map +1 -1
  22. package/dist/ci-init.d.ts.map +1 -1
  23. package/dist/ci-init.js +17 -12
  24. package/dist/ci-init.js.map +1 -1
  25. package/dist/cli.js +74 -15
  26. package/dist/cli.js.map +1 -1
  27. package/dist/config.d.ts +11 -0
  28. package/dist/config.d.ts.map +1 -1
  29. package/dist/config.js +13 -0
  30. package/dist/config.js.map +1 -1
  31. package/dist/crash-report.d.ts +58 -0
  32. package/dist/crash-report.d.ts.map +1 -0
  33. package/dist/crash-report.js +115 -0
  34. package/dist/crash-report.js.map +1 -0
  35. package/dist/decide.js +1 -1
  36. package/dist/decide.js.map +1 -1
  37. package/dist/decider-review.d.ts +33 -5
  38. package/dist/decider-review.d.ts.map +1 -1
  39. package/dist/decider-review.js +55 -9
  40. package/dist/decider-review.js.map +1 -1
  41. package/dist/decision-ledger.d.ts +44 -1
  42. package/dist/decision-ledger.d.ts.map +1 -1
  43. package/dist/decision-ledger.js +46 -1
  44. package/dist/decision-ledger.js.map +1 -1
  45. package/dist/decision-view.d.ts +10 -1
  46. package/dist/decision-view.d.ts.map +1 -1
  47. package/dist/decision-view.js +41 -0
  48. package/dist/decision-view.js.map +1 -1
  49. package/dist/manifest.d.ts +29 -1
  50. package/dist/manifest.d.ts.map +1 -1
  51. package/dist/manifest.js +236 -11
  52. package/dist/manifest.js.map +1 -1
  53. package/dist/permits.d.ts +135 -0
  54. package/dist/permits.d.ts.map +1 -0
  55. package/dist/permits.js +397 -0
  56. package/dist/permits.js.map +1 -0
  57. package/dist/publish.d.ts +35 -0
  58. package/dist/publish.d.ts.map +1 -1
  59. package/dist/publish.js +149 -16
  60. package/dist/publish.js.map +1 -1
  61. package/dist/run-program.d.ts +53 -2
  62. package/dist/run-program.d.ts.map +1 -1
  63. package/dist/run-program.js +539 -56
  64. package/dist/run-program.js.map +1 -1
  65. package/dist/whole-program-review.d.ts +4 -0
  66. package/dist/whole-program-review.d.ts.map +1 -1
  67. package/dist/whole-program-review.js +9 -1
  68. package/dist/whole-program-review.js.map +1 -1
  69. package/package.json +2 -2
  70. package/dist/verify-allowlist.d.ts +0 -23
  71. package/dist/verify-allowlist.d.ts.map +0 -1
  72. package/dist/verify-allowlist.js +0 -46
  73. package/dist/verify-allowlist.js.map +0 -1
package/README.md CHANGED
@@ -73,23 +73,61 @@ things only you can write:
73
73
 
74
74
  ```json
75
75
  {
76
- "agent": { "command": "claude", "args": ["-p", "--model", "sonnet", "--permission-mode", "acceptEdits", "--allowedTools", "Bash(npm run build:*)", "Bash(npm run typecheck:*)", "Bash(npm run lint:*)", "Bash(npm test:*)"], "promptMode": "stdin" },
77
- "authorAgent": { "command": "claude", "args": ["-p", "--model", "opus", "--permission-mode", "acceptEdits"], "promptMode": "stdin" },
76
+ "agent": { "command": "claude", "args": ["-p", "--model", "sonnet"], "promptMode": "stdin" },
77
+ "authorAgent": { "command": "claude", "args": ["-p", "--model", "opus"], "promptMode": "stdin" },
78
78
  "deciderAgent": { "command": "codex", "args": ["exec", "--model", "gpt-5.6-sol"], "promptMode": "stdin" },
79
79
  "reviewerAgent": { "command": "codex", "args": ["exec"] },
80
- "recoveryAgent": { "command": "codex", "args": ["exec", "--model", "gpt-5.6-sol", "--sandbox", "workspace-write"], "promptMode": "stdin" }
80
+ "recoveryAgent": { "command": "codex", "args": ["exec", "--model", "gpt-5.6-sol"], "promptMode": "stdin" },
81
+ "permits": {
82
+ "policy": "Anything inside this repository is fine, including installing dev dependencies and creating fixture files. Do not reach the network beyond npm install. Never push, publish, or change global git or npm configuration.",
83
+ "allow": ["Bash(git stash:*)"],
84
+ "deny": ["Bash(git push:*)", "Bash(npm publish:*)", "Bash(git config --global:*)", "Bash(npm config set:*)"]
85
+ }
81
86
  }
82
87
  ```
83
88
 
89
+ Notice what is missing: no `--permission-mode`, no `--allowedTools`, no
90
+ `--sandbox`. nightshift derives each role's permission posture itself — from
91
+ the role (`agent`, `authorAgent`, and `recoveryAgent` get a workspace posture;
92
+ `deciderAgent` and `reviewerAgent` get read-only, never edit-capable
93
+ regardless of the host) and from the host it runs on (a claude `auto`
94
+ classifier plus an OS sandbox on macOS/Linux, a `--sandbox workspace-write`
95
+ grant on codex write seats and `--sandbox read-only` on its reply-only seats,
96
+ a documented fallback when a capability cannot be detected). Any
97
+ permission-bearing flag an operator writes anyway — `--permission-mode`,
98
+ `--allowedTools`, `--sandbox`, and their siblings — always wins untouched,
99
+ and that role is reported as operator-configured rather than silently
100
+ overridden.
101
+
102
+ The optional `permits` block, shown above as this repository uses it, widens
103
+ or narrows the derived posture without hand-writing provider flags: `policy`
104
+ is prose the implementer and recovery briefs quote verbatim (the same thing
105
+ you would tell a contractor on day one), `allow` names commands that never
106
+ wait on the classifier, and `deny` is the short catastrophic list that binds
107
+ in every mode.
108
+
109
+ `allow`/`deny` use Claude's rule syntax and fold into the generated settings
110
+ file every claude spawn reads; codex has no per-command rules, so on those
111
+ seats only the sandbox and the brief's policy apply. On a throwaway CI runner, set
112
+ `NIGHTSHIFT_CONTAINMENT=ephemeral` in the environment to let workspace-posture
113
+ roles skip permission prompts entirely (`ci init github`'s hosted variant sets
114
+ this for you; never set it on a machine you or someone else works on
115
+ directly — read-only roles ignore it regardless).
116
+
84
117
  Check the roster before the first run with `nightshift doctor --agents`: it
85
- spawns each distinct agent once (one real model call each), verifies on
86
- disk that the writing seats can write, and reports whether they can run
87
- the verify commands the environment failures that otherwise burn a whole
88
- run's budget (a sandboxed shell, an untrusted workspace, a read-only
89
- recovery agent) show up as one labeled line each instead. Note
90
- `recoveryAgent`'s `--sandbox workspace-write` above: `codex exec` defaults
91
- to a read-only sandbox, which is the right posture for the decider and
92
- reviewer seats and exactly wrong for a seat that must fix a failing tree.
118
+ spawns each distinct agent once (one real model call each) with the same
119
+ derived posture a real run would use, verifies on disk that the writing seats
120
+ can write, and reports whether they can run the verify commands — the
121
+ environment failures that otherwise burn a whole run's budget (a sandboxed
122
+ shell, an untrusted workspace, a read-only recovery agent) show up as one
123
+ labeled line each instead. On codex, `exec` defaults to a read-only sandbox,
124
+ which is the right posture for the decider and reviewer seats and exactly
125
+ wrong for a seat that must fix a failing tree — so nightshift spawns
126
+ `recoveryAgent` with `--sandbox workspace-write` and, rather than trusting the
127
+ default, the decider and reviewer with an explicit `--sandbox read-only`. A
128
+ codex user config can widen the default (a `sandbox = "elevated"` setting, a
129
+ trusted-project entry), and a seat labeled read-only that can write is exactly
130
+ the kind of quiet mismatch the posture lines exist to prevent.
93
131
 
94
132
  Only `agent` is required to run; every other role degrades loudly, not
95
133
  silently, when absent. The verify commands are the contract every
@@ -98,15 +136,6 @@ the first agent spawns and refuses to start if they are red, so the first
98
136
  failure you debug is the environment's, named as such, not eight
99
137
  workstreams' worth of budget spent on it.
100
138
 
101
- The implementer's `--allowedTools` grant mirrors the verify commands on
102
- purpose: a headless Claude invocation with only `--permission-mode
103
- acceptEdits` can edit files but cannot run Bash, which leaves the agent
104
- fixing test failures it can never re-run. Granting exactly the verify
105
- commands lets it run the same gate it is graded against — the runner's own
106
- independent verification remains the only thing that gates a commit. The
107
- runner warns at startup when it detects a Claude implementer without such
108
- a grant.
109
-
110
139
  **3. Plan a program** — in your agent tool (e.g. Claude Code), run:
111
140
 
112
141
  ```text
@@ -203,16 +232,25 @@ or to see the specs before a build starts:
203
232
  nightshift author <program-id>
204
233
  ```
205
234
 
206
- A `taskFile` that already exists is always kept, never overwritten. To
207
- deliberately re-author one after a plan edit, name it explicitly and force it:
235
+ A finished `taskFile` is always kept, never overwritten, and an interrupted
236
+ attempt one a crash or a killed process cut off partway through is
237
+ re-authored automatically, without `--force`: a durable marker in the
238
+ manifest, not the file's existence, is what proves authoring finished.
239
+
240
+ Two flags select a range and a force level, independently:
208
241
 
209
242
  ```sh
210
- nightshift author <program-id> --only WS-03 --force
243
+ nightshift author <program-id> --from WS-03
244
+ nightshift author <program-id> --from WS-03 --force
211
245
  ```
212
246
 
213
- `--force` on its own does nothing to existing specs — it only takes effect
214
- for ids named in `--only`, so a bare `--force` can never silently regenerate
215
- a program's worth of hand-reviewed specs.
247
+ `--from <workstream-id>` resumes from that workstream onward, in dependency
248
+ order; everything before it is left untouched. Within the selected range,
249
+ plain authoring (no `--force`) only writes missing or interrupted specs
250
+ completed and hand-authored ones are kept. Adding `--force` regenerates
251
+ every selected spec, including already-completed ones, so `--from WS-03
252
+ --force` regenerates WS-03 and everything after it. A bare `--force` with no
253
+ `--from` selects the whole roster and regenerates every spec in the program.
216
254
 
217
255
  ## Flipping a decision
218
256
 
@@ -1,5 +1,6 @@
1
1
  import { type AgentRunner } from "./agent-runner.js";
2
2
  import type { AgentConfig, NightshiftConfig } from "./config.js";
3
+ import { type ContainmentLabel, type PermitsContext } from "./permits.js";
3
4
  /**
4
5
  * The doctor's agent capability probe: spawn each configured agent role the
5
6
  * exact way a run would, ask it to write one file and run one permission-
@@ -15,12 +16,24 @@ export interface AgentProbe {
15
16
  /** Every configured role sharing this exact agent invocation. */
16
17
  roles: string[];
17
18
  agent: AgentConfig;
19
+ /** The containment nightshift derived for this invocation (WS-01). */
20
+ label: ContainmentLabel;
21
+ /** The settings file this invocation reads, when one applies (claude
22
+ * only) — printed so doctor shows the same posture information as a
23
+ * run's `permissions:` startup line (SC-07). */
24
+ settingsPath?: string;
18
25
  exitCode: number;
19
26
  /** Runner-verified: the probe file existed on disk with the expected token. */
20
27
  write: ProbeVerdict;
21
- /** The agent's own EXEC report the runner cannot observe a denied shell
22
- * from outside, so this verdict is the agent's claim, labeled as such. */
28
+ /** Runner-observed when a stream-json transcript exists for this spawn
29
+ * (WS-02: `ok` when the exec command ran with no matching denial, `failed`
30
+ * when it was denied or never ran); otherwise the agent's own EXEC report,
31
+ * labeled as such — the runner cannot observe a denied shell from outside
32
+ * a Claude spawn's transcript. See `execRunnerObserved`. */
23
33
  exec: ProbeVerdict;
34
+ /** True when `exec` came from the runner's observed transcript rather than
35
+ * the agent's self-report (WS-02). */
36
+ execRunnerObserved: boolean;
24
37
  /** The command the exec step asked for, when one was derived from verify. */
25
38
  execCommand?: string;
26
39
  /** The agent's verbatim WRITE:/EXEC: lines when they carry an error. */
@@ -34,7 +47,13 @@ export interface ProbeAgentsOptions {
34
47
  cwd: string;
35
48
  config: NightshiftConfig;
36
49
  agentRunner?: AgentRunner;
50
+ /** Defaults to a real context built from `config`; tests inject one to
51
+ * avoid a real capability-detection spawn and settings-file write. */
52
+ permits?: PermitsContext;
37
53
  log?: (line: string) => void;
54
+ /** Names the probe's transcripts under `build-logs/<programId>/` (WS-02).
55
+ * The probe runs outside any one program, so this defaults to `"doctor"`. */
56
+ programId?: string;
38
57
  }
39
58
  export interface ProbeAgentsResult {
40
59
  probes: AgentProbe[];
@@ -1 +1 @@
1
- {"version":3,"file":"agent-probe.d.ts","sourceRoot":"","sources":["../src/agent-probe.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,E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C/B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAsD5B;AA2JD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAsDrE"}
@@ -1,7 +1,8 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import { readFile, unlink } from "node:fs/promises";
3
3
  import { join, resolve } from "node:path";
4
- import { defaultAgentRunner, describeAgent, invokeAgent, resolveAgent, tail, } from "./agent-runner.js";
4
+ import { defaultAgentRunner, describeAgent, recordAgentTranscript, resolveAgent, tail, } from "./agent-runner.js";
5
+ import { buildPermitsContext, ROLE_POSTURE, } from "./permits.js";
5
6
  /**
6
7
  * What each seat actually needs. The implementer, author, and recovery
7
8
  * agents write the tree; the implementer and recovery agents also fix
@@ -10,7 +11,7 @@ import { defaultAgentRunner, describeAgent, invokeAgent, resolveAgent, tail, } f
10
11
  * posture, not a failure (codex exec ships read-only by default, which is
11
12
  * exactly right for those two seats and exactly wrong for recovery).
12
13
  */
13
- const WRITE_ROLES = new Set(["agent", "authorAgent", "recoveryAgent"]);
14
+ const WRITE_ROLES = new Set(Object.keys(ROLE_POSTURE).filter((role) => ROLE_POSTURE[role] === "workspace"));
14
15
  const EXEC_ROLES = new Set(["agent", "recoveryAgent"]);
15
16
  /**
16
17
  * Output lines that explain a failed probe better than the verdict alone —
@@ -77,9 +78,12 @@ function configuredRoles(config) {
77
78
  export async function probeAgents(options) {
78
79
  const root = resolve(options.cwd);
79
80
  const agentRunner = options.agentRunner ?? defaultAgentRunner;
81
+ const permits = options.permits ?? (await buildPermitsContext({ config: options.config }));
80
82
  const log = options.log ?? ((line) => console.log(line));
81
- // One probe per distinct invocation: roles that share an agent block
82
- // would produce the identical spawn, and each spawn is a paid model call.
83
+ // One probe per distinct DERIVED invocation, not the raw config: two roles
84
+ // sharing an agent block can still derive different spawns once posture
85
+ // is per-role (a workspace seat and a read-only seat pointed at the same
86
+ // claude block), and each spawn is a paid model call.
83
87
  const distinct = new Map();
84
88
  const unconfigured = [];
85
89
  for (const { role, agent } of configuredRoles(options.config)) {
@@ -87,30 +91,53 @@ export async function probeAgents(options) {
87
91
  unconfigured.push(role);
88
92
  continue;
89
93
  }
90
- const key = JSON.stringify([agent.command, agent.args, agent.promptMode]);
94
+ const derived = await permits.derive(role, agent);
95
+ const key = JSON.stringify([derived.agent.command, derived.agent.args, derived.agent.promptMode]);
91
96
  const entry = distinct.get(key);
92
97
  if (entry)
93
98
  entry.roles.push(role);
94
- else
95
- distinct.set(key, { agent, roles: [role] });
99
+ else {
100
+ distinct.set(key, {
101
+ agent: derived.agent,
102
+ roles: [role],
103
+ label: derived.label,
104
+ ...(derived.settingsPath === undefined ? {} : { settingsPath: derived.settingsPath }),
105
+ });
106
+ }
96
107
  }
97
108
  const firstVerify = Object.values(options.config.verify)[0];
98
109
  // `--help` keeps the probe cheap while still matching the same
99
110
  // `Bash(<command>:*)` prefix rule the real verify command needs — the
100
111
  // permission machinery is what is under test, not the suite.
101
112
  const execCommand = firstVerify === undefined ? undefined : `${firstVerify} --help`;
113
+ const programId = options.programId ?? "doctor";
102
114
  const probes = [];
103
- for (const { agent, roles } of distinct.values()) {
104
- log(`probing ${roles.join(", ")}: ${describeAgent(agent)}`);
105
- probes.push(await probeOne(root, agent, roles, agentRunner, execCommand));
115
+ for (const { agent, roles, label, settingsPath } of distinct.values()) {
116
+ log(`probing ${roles.join(", ")}: ${describeAgent(agent)} [${label}]`);
117
+ const observe = { root, programId, label: `probe-${roles.join("-")}`, log };
118
+ probes.push(await probeOne(root, agent, roles, label, agentRunner, execCommand, settingsPath, observe));
106
119
  }
120
+ if (options.permits === undefined)
121
+ await permits.dispose?.();
107
122
  return {
108
123
  probes,
109
124
  unconfigured,
110
125
  healthy: probes.every((probe) => probe.healthy),
111
126
  };
112
127
  }
113
- async function probeOne(root, agent, roles, agentRunner, execCommand) {
128
+ /** Spawns an already-derived agent config directly `probeAgents` derives
129
+ * once per role up front (to dedup on the derived invocation), so this
130
+ * never re-derives. */
131
+ function spawnDerived(runner, agent, prompt, cwd) {
132
+ return runner({ command: agent.command, args: agent.args, prompt, promptMode: agent.promptMode, cwd });
133
+ }
134
+ /** Loose match on the exec command a probe asked for against a transcript
135
+ * entry — trimmed equality, tolerant of nothing else: the brief demands the
136
+ * command run bare, so an honest agent's transcript entry is exact. */
137
+ function sameCommand(a, b) {
138
+ return a.trim() === b.trim();
139
+ }
140
+ async function probeOne(root, agent, roles, label, agentRunner, execCommand, settingsPath, observe) {
114
141
  const nonce = randomBytes(4).toString("hex");
115
142
  const probeFile = `nightshift-probe-${nonce}.txt`;
116
143
  const token = `nightshift-probe-ok-${nonce}`;
@@ -119,21 +146,25 @@ async function probeOne(root, agent, roles, agentRunner, execCommand) {
119
146
  // probe's failure, never the doctor's crash.
120
147
  let invocation;
121
148
  try {
122
- invocation = await invokeAgent(agentRunner, agent, brief, root);
149
+ invocation = await spawnDerived(agentRunner, agent, brief, root);
123
150
  }
124
151
  catch (error) {
125
152
  return {
126
153
  roles,
127
154
  agent,
155
+ label,
156
+ ...(settingsPath === undefined ? {} : { settingsPath }),
128
157
  exitCode: -1,
129
158
  write: "failed",
130
159
  exec: execCommand === undefined ? "skipped" : "failed",
160
+ execRunnerObserved: false,
131
161
  ...(execCommand === undefined ? {} : { execCommand }),
132
162
  claims: [],
133
163
  notes: [`the agent could not be spawned at all: ${error.message}`],
134
164
  healthy: false,
135
165
  };
136
166
  }
167
+ await recordAgentTranscript(observe, roles.join("+"), invocation);
137
168
  // The write verdict never trusts the reply: the file either landed with
138
169
  // the token or it did not.
139
170
  let write = "failed";
@@ -152,16 +183,32 @@ async function probeOne(root, agent, roles, agentRunner, execCommand) {
152
183
  claims.push(`WRITE: ${writeClaim}`);
153
184
  }
154
185
  let exec = "skipped";
186
+ const execRunnerObserved = execCommand !== undefined && invocation.transcript?.observed === true;
155
187
  if (execCommand !== undefined) {
156
- const execClaim = claimLine(invocation.output, "EXEC");
157
- if (execClaim !== undefined && /^(done|ok)\b/iu.test(execClaim)) {
158
- exec = "ok";
188
+ if (invocation.transcript?.observed) {
189
+ // Runner-observed (WS-02): the transcript is what actually happened,
190
+ // not what the agent claims happened. Denied wins over ran, in the
191
+ // (should not occur) case a CLI reports both.
192
+ const denied = invocation.transcript.denials.some((denial) => sameCommand(denial.command, execCommand));
193
+ const ran = invocation.transcript.commands.some((command) => sameCommand(command.command, execCommand));
194
+ exec = !denied && ran ? "ok" : "failed";
195
+ if (exec === "failed") {
196
+ claims.push(denied
197
+ ? `EXEC: (denied by the CLI's own permission check — see the transcript)`
198
+ : "EXEC: (the transcript shows the command never ran)");
199
+ }
159
200
  }
160
201
  else {
161
- exec = "failed";
162
- claims.push(execClaim === undefined
163
- ? "EXEC: (the reply never reported the exec step — the agent may have crashed before reaching it)"
164
- : `EXEC: ${execClaim}`);
202
+ const execClaim = claimLine(invocation.output, "EXEC");
203
+ if (execClaim !== undefined && /^(done|ok)\b/iu.test(execClaim)) {
204
+ exec = "ok";
205
+ }
206
+ else {
207
+ exec = "failed";
208
+ claims.push(execClaim === undefined
209
+ ? "EXEC: (the reply never reported the exec step — the agent may have crashed before reaching it)"
210
+ : `EXEC: ${execClaim}`);
211
+ }
165
212
  }
166
213
  }
167
214
  // Notes restating a claim are noise: the signature scanner re-matches the
@@ -186,9 +233,12 @@ async function probeOne(root, agent, roles, agentRunner, execCommand) {
186
233
  return {
187
234
  roles,
188
235
  agent,
236
+ label,
237
+ ...(settingsPath === undefined ? {} : { settingsPath }),
189
238
  exitCode: invocation.exitCode,
190
239
  write,
191
240
  exec,
241
+ execRunnerObserved,
192
242
  ...(execCommand === undefined ? {} : { execCommand }),
193
243
  claims,
194
244
  notes,
@@ -206,6 +256,10 @@ export function renderProbeResult(result) {
206
256
  const writers = probe.roles.filter((role) => WRITE_ROLES.has(role));
207
257
  const execers = probe.roles.filter((role) => EXEC_ROLES.has(role));
208
258
  lines.push(`${probe.roles.join(", ")}: ${describeAgent(probe.agent)}`);
259
+ lines.push(probe.settingsPath === undefined
260
+ ? ` permissions: ${probe.label}`
261
+ : ` permissions: ${probe.label} — settings: ${probe.settingsPath}`);
262
+ const execSource = probe.execRunnerObserved ? "runner-observed" : "agent's report";
209
263
  if (probe.healthy) {
210
264
  const parts = [];
211
265
  if (probe.write === "ok")
@@ -213,7 +267,7 @@ export function renderProbeResult(result) {
213
267
  else
214
268
  parts.push("reply-only seat (a read-only sandbox is its correct posture)");
215
269
  if (probe.exec === "ok") {
216
- parts.push(`reports it can run \`${probe.execCommand ?? ""}\``);
270
+ parts.push(`can run \`${probe.execCommand ?? ""}\` (${execSource})`);
217
271
  }
218
272
  else if (probe.exec === "failed") {
219
273
  parts.push("cannot run the gate (fine — this seat never fixes verify failures)");
@@ -228,10 +282,10 @@ export function renderProbeResult(result) {
228
282
  lines.push(` write: FAILED — no probe file landed, and ${writers.join(", ")} must write the tree`);
229
283
  }
230
284
  if (probe.exec === "ok") {
231
- lines.push(` exec \`${probe.execCommand ?? ""}\`: ok (agent's report)`);
285
+ lines.push(` exec \`${probe.execCommand ?? ""}\`: ok (${execSource})`);
232
286
  }
233
287
  else if (probe.exec === "failed" && execers.length > 0) {
234
- lines.push(` exec \`${probe.execCommand ?? ""}\`: FAILED — ${execers.join(", ")} ` +
288
+ lines.push(` exec \`${probe.execCommand ?? ""}\`: FAILED (${execSource}) — ${execers.join(", ")} ` +
235
289
  "must run the verify commands to fix failures with open eyes");
236
290
  }
237
291
  for (const claim of probe.claims)
@@ -1 +1 @@
1
- {"version":3,"file":"agent-probe.js","sourceRoot":"","sources":["../src/agent-probe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,WAAW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;IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,qCAAqC,CAAC,CAAC;IAC3D,CAAC;IACD,KAAK,CAAC,IAAI,CACR,MAAM,CAAC,OAAO;QACZ,CAAC,CAAC,mDAAmD;QACrD,CAAC,CAAC,+GAA+G,CACpH,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,9 +1,43 @@
1
1
  import type { AgentConfig, NightshiftConfig } from "./config.js";
2
+ import type { AgentRole, PermitsContext } from "./permits.js";
3
+ /** A Bash command a Claude spawn actually ran, observed from its stream-json `tool_use` block. */
4
+ export interface TranscriptCommand {
5
+ command: string;
6
+ description?: string;
7
+ }
8
+ /** A command the CLI itself refused, observed from its stream-json permission events. */
9
+ export interface TranscriptDenial {
10
+ command: string;
11
+ reason: string;
12
+ tool?: string;
13
+ }
14
+ /**
15
+ * What the runner observed a Claude spawn do, demultiplexed from its
16
+ * `--output-format stream-json` NDJSON stream. `observed: false` marks a
17
+ * stream that could not be demultiplexed (an older CLI ignoring the flag, a
18
+ * crash before the first event) — the raw-text fallback, not a failure.
19
+ */
20
+ export interface AgentTranscript {
21
+ observed: boolean;
22
+ commands: TranscriptCommand[];
23
+ denials: TranscriptDenial[];
24
+ /**
25
+ * True when a line *after* the first was valid enough to keep the stream
26
+ * classified as NDJSON, but itself failed to parse and was skipped
27
+ * (fail-open, per spec). A skipped line could have been a `tool_use` or a
28
+ * denial — there is no way to know which — so this is the transcript's own
29
+ * admission that `commands`/`denials` may be missing an entry, and it must
30
+ * never be silently blessed as fully authoritative alongside `observed: true`.
31
+ */
32
+ corrupted?: boolean;
33
+ }
2
34
  export interface CommandResult {
3
35
  exitCode: number;
4
36
  output: string;
5
37
  /** Set when the prompt could not be fully delivered to the process stdin. */
6
38
  inputError?: string;
39
+ /** Present only for a Claude spawn whose args requested stream-json output. */
40
+ transcript?: AgentTranscript;
7
41
  }
8
42
  export interface AgentInvocation {
9
43
  command: string;
@@ -27,13 +61,67 @@ export declare function runProcess(command: string, args: string[], options: {
27
61
  input?: string;
28
62
  shell: boolean;
29
63
  onOutput?: (chunk: string) => void;
64
+ /**
65
+ * Stdout-only chunks, separate from `onOutput`'s combined stdout+stderr
66
+ * stream. The NDJSON demultiplexer feeds from this instead: Claude's
67
+ * structured stream-json events are only ever written to stdout, while
68
+ * stderr carries human-readable warnings and diagnostics that are not
69
+ * JSON at all. Feeding those into the same line parser as the NDJSON
70
+ * stream would corrupt or invalidate it depending on arrival order — a
71
+ * stderr line arriving before the first stdout event would look like an
72
+ * unparseable first line and force the whole spawn to the raw-text
73
+ * fallback even though stdout was itself well-formed NDJSON.
74
+ */
75
+ onStdout?: (chunk: string) => void;
30
76
  env?: NodeJS.ProcessEnv;
31
77
  }): Promise<CommandResult>;
78
+ /**
79
+ * Demultiplexes a whole captured stream-json string in one call — what
80
+ * fixture-replay tests exercise. `undefined` means the input did not parse as
81
+ * NDJSON at all (the raw-text fallback applies).
82
+ */
83
+ export declare function demultiplexClaudeStreamJson(raw: string): {
84
+ output: string;
85
+ transcript: AgentTranscript;
86
+ } | undefined;
32
87
  export declare const defaultAgentRunner: AgentRunner;
33
88
  export declare const defaultVerifyRunner: VerifyRunner;
34
89
  export declare function tail(output: string, limit?: number): string;
35
- /** Spawns a configured agent role with a prompt; shared by every brief spawner. */
36
- export declare function invokeAgent(runner: AgentRunner, agent: AgentConfig, prompt: string, cwd: string): Promise<CommandResult>;
90
+ /**
91
+ * Names where a spawn's transcript is written and how its path is logged —
92
+ * one home for both, shared by every `invokeAgent` call site, so the write
93
+ * and its log line are not duplicated across each spawning command.
94
+ */
95
+ export interface TranscriptSink {
96
+ root: string;
97
+ programId: string;
98
+ /** Names the JSONL file, e.g. "ws-02-implementer" or "probe-agent". */
99
+ label: string;
100
+ log: (line: string) => void;
101
+ }
102
+ /**
103
+ * Writes a spawn's transcript as JSONL under `build-logs/<programId>/` and
104
+ * logs the path — the one place this happens, shared by `invokeAgent` and
105
+ * the doctor probe (`agent-probe.ts`, which spawns through an already-derived
106
+ * invocation and so cannot go through `invokeAgent` itself). A no-op when the
107
+ * result carries no transcript at all (a non-Claude spawn, an operator-
108
+ * configured or operator-`--output-format` role — never asked to be
109
+ * observed).
110
+ */
111
+ export declare function recordAgentTranscript(observe: TranscriptSink, role: string, result: CommandResult): Promise<void>;
112
+ /**
113
+ * Spawns a configured agent role with a prompt; shared by every brief
114
+ * spawner. `permits` derives the posture for this role/agent/host before the
115
+ * process ever starts — an operator-authored permission flag in `agent.args`
116
+ * is spawned untouched (WS-01 SC-05); everything else gets the flags
117
+ * `src/permits.ts` derives from the role's fixed posture and the run's
118
+ * containment.
119
+ *
120
+ * `observe`, when given, writes the spawn's transcript (if one was observed)
121
+ * as JSONL under `build-logs/<programId>/` and logs the path — the one place
122
+ * this happens, rather than duplicated across every spawning call site.
123
+ */
124
+ export declare function invokeAgent(runner: AgentRunner, agent: AgentConfig, prompt: string, cwd: string, permits: PermitsContext, role: AgentRole, observe?: TranscriptSink): Promise<CommandResult>;
37
125
  /**
38
126
  * The implementer: the `agent` block, or the environment fallback for hosts
39
127
  * that have no config file yet.
@@ -1 +1 @@
1
- {"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../src/agent-runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC;IAC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