bugxhunter 0.9.6 → 0.10.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.
package/README.md CHANGED
@@ -307,6 +307,42 @@ before scanning and to scan only hosts you name.
307
307
  To fence the agent to a specific lab/target range, add firewall rules on the Docker host or the VM
308
308
  you run this in — Docker's bridge NAT doesn't restrict outbound on its own.
309
309
 
310
+ ## Supervised recon
311
+
312
+ The Runner's **recon** button starts a supervised test of one target. You give the target (one
313
+ host or URL), an objective, the environment (local, staging or production) and how it differs
314
+ from production, and confirm you are authorised to test it. The runner then drives the session
315
+ round after round:
316
+
317
+ 1. **Route.** Each round the executor runs on the model its profile gives it. After two stuck
318
+ rounds, or a High or Critical finding, the next round runs on the escalation model; a model
319
+ that answers "rate limited" is routed around for a minute.
320
+ 2. **Probe, under the gate.** Every shell command the executor (or a subagent) wants to run raises
321
+ an approval. The gate answers the ones it can prove safe: a `curl` GET or HEAD to exactly the
322
+ in-scope origin, an `nmap` version scan of the in-scope host, piped into read filters with
323
+ allow-listed flags. A handful of shapes that would wreck or hijack the agent's own machine are
324
+ rejected. Everything else waits for you, as an approval card. "Always allow" is off during a
325
+ run, and the recon agents cannot use webfetch or websearch.
326
+ 3. **Verify.** The executor hands each candidate to the `recon-verify` subagent, which rejects it
327
+ without reproduction evidence and marks it *config-dependent* when it relies on a setting that
328
+ differs from production. Only its verdicts become findings.
329
+ 4. **Stop.** The run ends when the executor reports the surface exhausted, a round finds nothing
330
+ new, the round or token cap is reached, it stays stuck after escalating, every model is
331
+ rate-limited, a round fails, or you press stop.
332
+
333
+ A strip above the composer shows the round, tokens, model and how many approvals the gate
334
+ answered; the findings appear in the transcript. Gate decisions and the run's start and end go to
335
+ the audit log (`recon.gate`, `recon.started`, `recon.finished`). A run lives in the runner's
336
+ memory: restarting the runner ends it (the session and its transcript stay).
337
+
338
+ **Models.** `RECON_PROFILE` picks a profile: `recon-open` (SCX models only), `recon-balanced`
339
+ (GLM executor, Claude for triage, verification and escalation) or `recon-quality`. With no
340
+ Anthropic key the default is `recon-open`, otherwise `recon-balanced`. `RECON_EXECUTOR_MODEL`,
341
+ `RECON_TRIAGE_MODEL`, `RECON_VERIFY_MODEL` and `RECON_ESCALATE_MODEL` (`provider/model`) override
342
+ one role. In Docker the subagents are defined in `docker/opencode.json` on SCX models; the
343
+ per-role variables in `.env` reach both containers, so set them there to put a role on Claude.
344
+ The security model is in [docs/recon-security.md](docs/recon-security.md).
345
+
310
346
  ## Through Sigilant (governed runs)
311
347
 
312
348
  The runner can run under [Sigilant](https://sigilant.io), Cintelis's agent governance platform: it is a
@@ -349,6 +385,9 @@ nobody is there to unlock.
349
385
  | `OPEN_RUNNER_PLAYGROUND_DIR` | `playground/` beside the vault | Saved Playground chats and canvases, sealed with the vault key |
350
386
  | `OPEN_RUNNER_WORKSPACE` | `/workspace` (local: `~/bugxhunter/repos`) | Remote mode: projects must live under this folder. Both modes: where GitHub clones land |
351
387
  | `SCX_PROXY_TOKEN` | unset | Enables the `/scx/v1` key proxy for the sandboxed agent |
388
+ | `RECON_PROFILE` | `recon-balanced` (`recon-open` without an Anthropic key) | Model profile for [supervised recon](#supervised-recon); `RECON_PROFILES_FILE` adds your own (JSON) |
389
+ | `RECON_EXECUTOR_MODEL`, `RECON_TRIAGE_MODEL`, `RECON_VERIFY_MODEL`, `RECON_ESCALATE_MODEL` | from the profile | One recon role's model, as `provider/model` |
390
+ | `RECON_ESCALATE_AFTER` | `2` | Stuck rounds before the executor moves to the escalation model |
352
391
 
353
392
  Releases are on the [releases page](https://github.com/cintelis/bugxhunter-runner/releases).
354
393
  See [SECURITY.md](SECURITY.md) to verify one by hand, or to report a vulnerability.
@@ -364,6 +403,9 @@ GHCR images by digest) and the signed `checksums.txt` that covers them all.
364
403
  <!-- releases:start -->
365
404
  | Release | Published | Checksums | Signature | Signature check | Build |
366
405
  | --- | --- | --- | --- | --- | --- |
406
+ | [v0.9.7](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.9.7) | 2026-11-19 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.7/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.7/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/44437259098) |
407
+ | [v0.9.6](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.9.6) | 2026-11-18 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.6/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.6/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/44381703840) |
408
+ | [v0.9.5](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.9.5) | 2026-10-29 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.5/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.5/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/40882124130) |
367
409
  | [v0.9.4](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.9.4) | 2026-10-29 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.4/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.4/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/40877466861) |
368
410
  | [v0.9.3](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.9.3) | 2026-10-29 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.3/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.3/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/40817756725) |
369
411
  | [v0.9.2](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.9.2) | 2026-10-28 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.2/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.2/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/40789797062) |
@@ -446,6 +488,7 @@ publisher** on npmjs.com set to this repository and `release.yml`, once; no npm
446
488
  |---|---|
447
489
  | `server/src/opencode.ts` | Starts/stops the OpenCode server, one SDK client per project folder, event mapping |
448
490
  | `server/src/index.ts` | Express: `/api/agent/*` (OpenCode) and `/api/chat`, `/api/models`, `/api/kb` (SCX) |
491
+ | `server/src/recon.ts`, `recon-driver.ts`, `recon-run.ts` | Supervised recon: the model router and approval gate, the driver loop, and the OpenCode side of a turn (`web/src/ReconPanel.tsx` is its UI) |
449
492
  | `server/src/scx.ts`, `rag.ts` | SCX client and in-memory knowledge base (Playground) |
450
493
  | `server/src/providers.ts`, `anthropic.ts`, `nvidia-health.ts` | Anthropic / NVIDIA / OpenRouter providers (Claude via the official SDK); hides NVIDIA models whose endpoints are retired |
451
494
  | `server/src/playground-store.ts` | Saved Playground sessions, sealed with the vault key |
@@ -43,6 +43,14 @@ services:
43
43
  # (ANTHROPIC_API_KEY) or here; ANTHROPIC_MODELS lists the ids the agent's picker shows.
44
44
  ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
45
45
  ANTHROPIC_MODELS: ${ANTHROPIC_MODELS:-}
46
+ # Supervised recon: the model profile (recon-open | recon-balanced | recon-quality;
47
+ # default recon-balanced with an Anthropic key, recon-open without) and optional
48
+ # per-role models. The agent gets the same per-role values (below).
49
+ RECON_PROFILE: ${RECON_PROFILE:-}
50
+ RECON_EXECUTOR_MODEL: ${RECON_EXECUTOR_MODEL:-}
51
+ RECON_TRIAGE_MODEL: ${RECON_TRIAGE_MODEL:-}
52
+ RECON_VERIFY_MODEL: ${RECON_VERIFY_MODEL:-}
53
+ RECON_ESCALATE_MODEL: ${RECON_ESCALATE_MODEL:-}
46
54
  OPEN_RUNNER_VAULT_FILE: /data/vault.json
47
55
  OPEN_RUNNER_VAULT_IDLE_MINUTES: ${OPEN_RUNNER_VAULT_IDLE_MINUTES:-120}
48
56
  OPEN_RUNNER_SECRET: ${OPEN_RUNNER_SECRET:-}
@@ -79,6 +87,11 @@ services:
79
87
  SCX_PROXY_TOKEN: ${SCX_PROXY_TOKEN:?run docker/setup.ps1 first}
80
88
  OPENCODE_ENABLE_EXA: "1" # turns on OpenCode's websearch tool (Exa)
81
89
  OPENROUTER_MODELS: ${OPENROUTER_MODELS:-} # same list as runner: becomes an OpenCode provider via runner's proxy
90
+ # Recon subagents run on open-weight models unless a role is set here (see docker/agent-entrypoint.sh).
91
+ RECON_EXECUTOR_MODEL: ${RECON_EXECUTOR_MODEL:-}
92
+ RECON_TRIAGE_MODEL: ${RECON_TRIAGE_MODEL:-}
93
+ RECON_VERIFY_MODEL: ${RECON_VERIFY_MODEL:-}
94
+ RECON_ESCALATE_MODEL: ${RECON_ESCALATE_MODEL:-}
82
95
  networks: [net]
83
96
  volumes:
84
97
  - workspace:/workspace
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bugxhunter",
3
- "version": "0.9.6",
3
+ "version": "0.10.0",
4
4
  "description": "BugXHunter: an AI security-testing agent with a sandboxed runner, a passkey-sealed key vault and read-only GitHub access. `npx bugxhunter` runs it on your machine.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://bugxhunter.com",
@@ -11,7 +11,7 @@ import express from "express";
11
11
  import fs from "node:fs";
12
12
  import path from "node:path";
13
13
  import { SCXError } from "./scx.js";
14
- import { PROVIDERS, PROXY_TOKEN, PORT, OPENROUTER_MODELS, apiKey, clients, clientFor, isRetiredStatus, keySource, listModels, proxyPaths, proxyTokenOk, upstreamHeaders, } from "./providers.js";
14
+ import { PROVIDERS, PROXY_TOKEN, PORT, OPENROUTER_MODELS, apiKey, clients, clientFor, configured, isRetiredStatus, keySource, listModels, proxyPaths, proxyTokenOk, upstreamHeaders, } from "./providers.js";
15
15
  import { KnowledgeBase, buildContextBlock } from "./rag.js";
16
16
  import { getClient, serverUrl, resolveDirectory, projectFile, listAgentModels, toUiEvent, toUiMessages, parseModelId, oc, query, httpError, SessionFamily, childSessions, markInterrupted, DEFAULT_DIRECTORY, DEFAULT_MODEL, REMOTE_URL, REPO_ROOT, ALLOWED_ROOTS, } from "./opencode.js";
17
17
  import { mountAuth, authRequired, issueSession } from "./auth.js";
@@ -25,6 +25,8 @@ import { VERSION } from "./version.js";
25
25
  import { apiLimiter, fileLimiter, staticLimiter } from "./ratelimit.js";
26
26
  import { createWorkspace, deleteWorkspace, listFiles, listWorkspaces, saveUpload, WORKSPACES_ROOT } from "./workspaces.js";
27
27
  import * as github from "./github.js";
28
+ import { parseReconHarness, setAnthropicAvailable } from "./recon.js";
29
+ import { EXECUTOR_AGENT, inRunningRecon, parseEnvFidelity, reconState, startRecon, stopRecon, } from "./recon-run.js";
28
30
  // Keys, the proxy token and the provider clients live in providers.ts, which
29
31
  // also scrubs every secret from the environment before OpenCode is spawned.
30
32
  const scx = clients.scx;
@@ -795,10 +797,14 @@ app.post("/api/agent/permission", async (req, res) => {
795
797
  }
796
798
  const directory = await resolveDirectory(dir);
797
799
  const client = await getClient(directory);
800
+ // During a recon run every approval is for one command: "always" would make
801
+ // OpenCode stop asking for that command pattern, and the gate would never
802
+ // see it again.
803
+ const reply = response === "always" && inRunningRecon(sessionID) ? "once" : response;
798
804
  unwrap(await client.postSessionIdPermissionsPermissionId({
799
805
  path: { id: sessionID, permissionID },
800
806
  query: { directory },
801
- body: { response },
807
+ body: { response: reply },
802
808
  }));
803
809
  res.json({ ok: true });
804
810
  }
@@ -806,6 +812,82 @@ app.post("/api/agent/permission", async (req, res) => {
806
812
  sendError(res, e);
807
813
  }
808
814
  });
815
+ // --- Supervised recon (recon-run.ts) ---------------------------------------------
816
+ /** The recon runner's view of OpenCode for one project folder. */
817
+ async function reconBackend(directory) {
818
+ const client = await getClient(directory);
819
+ return {
820
+ async events() {
821
+ const sub = await client.event.subscribe({ query: { directory } });
822
+ return { stream: sub.stream, close: () => { void sub.stream.return?.(undefined); } };
823
+ },
824
+ async prompt({ sessionID, agent, model, text }) {
825
+ unwrap(await client.session.promptAsync({
826
+ path: { id: sessionID }, query: { directory },
827
+ body: { agent, model: parseModelId(model), parts: [{ type: "text", text }] },
828
+ }));
829
+ },
830
+ async replyPermission(sessionID, permissionID, response) {
831
+ unwrap(await client.postSessionIdPermissionsPermissionId({ path: { id: sessionID, permissionID }, query: { directory }, body: { response } }));
832
+ },
833
+ async abort(sessionID) {
834
+ await client.session.abort({ path: { id: sessionID }, query: { directory } });
835
+ },
836
+ };
837
+ }
838
+ /**
839
+ * Start a supervised recon run on a session: the driver loop prompts the
840
+ * `recon` agent round after round, answers the approvals the gate clears and
841
+ * leaves the rest for the person. Needs the operator's statement that they are
842
+ * authorised to test the scope.
843
+ */
844
+ app.post("/api/agent/recon", async (req, res) => {
845
+ try {
846
+ const b = (req.body ?? {});
847
+ if (!b.sessionID)
848
+ return res.status(400).json({ error: { message: "sessionID required" } });
849
+ if (b.authorised !== true)
850
+ return res.status(400).json({ error: { message: "Confirm that you are authorised to test this target." } });
851
+ const directory = await resolveDirectory(b.directory);
852
+ // The agents come from the agent's own config: an image or server from
853
+ // before recon was wired in doesn't have them.
854
+ const agents = await oc(`/agent${query({ directory })}`).catch(() => []);
855
+ if (!agents.some((a) => a?.name === EXECUTOR_AGENT)) {
856
+ return res.status(409).json({ error: { message: REMOTE_URL
857
+ ? "The agent container has no recon agent. Rebuild or pull the agent image for this version."
858
+ : "OpenCode has no recon agent. Restart BugXHunter." } });
859
+ }
860
+ setAnthropicAvailable(configured("anthropic"));
861
+ const state = await startRecon({
862
+ sessionID: b.sessionID,
863
+ scope: String(b.scope ?? ""),
864
+ objective: String(b.objective ?? ""),
865
+ env: parseEnvFidelity(b.env),
866
+ harness: parseReconHarness({ maxRounds: b.maxRounds, budgetTokens: b.budgetTokens }),
867
+ backend: await reconBackend(directory),
868
+ log: (event, data) => audit(event, { directory, ...data }),
869
+ });
870
+ res.json({ recon: state });
871
+ }
872
+ catch (e) {
873
+ sendError(res, e);
874
+ }
875
+ });
876
+ app.get("/api/agent/recon", (req, res) => {
877
+ res.json({ recon: reconState(String(req.query.sessionID || "")) });
878
+ });
879
+ app.post("/api/agent/recon/stop", async (req, res) => {
880
+ try {
881
+ const sessionID = String(req.body?.sessionID || "");
882
+ const state = await stopRecon(sessionID);
883
+ if (state)
884
+ audit("recon.stop", { session: sessionID });
885
+ res.json({ recon: state });
886
+ }
887
+ catch (e) {
888
+ sendError(res, e);
889
+ }
890
+ });
809
891
  // Audit log of agent activity (see audit.ts), fed by OpenCode's event stream.
810
892
  if (LOG_DIR)
811
893
  serverUrl().then(followOpencode).catch((e) => console.error("[audit] not following OpenCode:", e));
@@ -21,7 +21,7 @@ import { fileURLToPath } from "node:url";
21
21
  import { createOpencodeServer, createOpencodeClient } from "@opencode-ai/sdk";
22
22
  import { httpError } from "./errors.js";
23
23
  import { anthropicOpencodeProvider, openrouterOpencodeProvider, nvidiaOpencodeProvider, ANTHROPIC_MODELS, OPENROUTER_MODELS, PORT } from "./providers.js";
24
- import { RECON_AGENTS, withScrubbedEnv } from "./recon.js";
24
+ import { reconAgents, setAnthropicAvailable, tierOrder, withScrubbedEnv } from "./recon.js";
25
25
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
26
26
  /** BugXHunter's own folder: the default project when none is chosen. */
27
27
  export const REPO_ROOT = path.resolve(__dirname, "../..");
@@ -58,6 +58,22 @@ async function inlineConfig() {
58
58
  const openrouter = await openrouterOpencodeProvider(`http://127.0.0.1:${PORT}/openrouter/v1`);
59
59
  const nvidia = await nvidiaOpencodeProvider(`http://127.0.0.1:${PORT}/nvidia/v1`);
60
60
  const anthropic = await anthropicOpencodeProvider(`http://127.0.0.1:${PORT}/anthropic/v1`);
61
+ // Recon: without an Anthropic key the default profile falls back to the
62
+ // open-weight one; with a key, every Claude model a recon role names is
63
+ // registered (the picker still shows only ANTHROPIC_MODELS, see listAgentModels).
64
+ setAnthropicAvailable(Boolean(anthropic));
65
+ if (anthropic) {
66
+ const models = anthropic.models;
67
+ for (const id of tierOrder()) {
68
+ const m = parseModelId(id);
69
+ if (m?.providerID !== "anthropic" || Object.hasOwn(models, m.modelID))
70
+ continue;
71
+ models[m.modelID] = {
72
+ name: m.modelID, limit: { context: 1_000_000, output: 128_000 },
73
+ attachment: true, modalities: { input: ["text", "image"], output: ["text"] },
74
+ };
75
+ }
76
+ }
61
77
  const provider = { ...(openrouter ? { openrouter } : {}), ...(nvidia ? { nvidia } : {}), ...(anthropic ? { anthropic } : {}) };
62
78
  return {
63
79
  model: DEFAULT_MODEL,
@@ -65,9 +81,9 @@ async function inlineConfig() {
65
81
  build: { model: DEFAULT_MODEL },
66
82
  plan: { model: DEFAULT_MODEL },
67
83
  vision: VISION_AGENT,
68
- // Supervised recon/autopwn: executor (GLM) + triage (Haiku) + verify
69
- // (Sonnet) + escalate (Mythos), each on the job it is good at. See recon.ts.
70
- ...RECON_AGENTS,
84
+ // Supervised recon: executor + triage + verify + escalate, each on the
85
+ // model the active profile gives it. See recon.ts and recon-run.ts.
86
+ ...reconAgents(),
71
87
  },
72
88
  permission: { edit: "ask", bash: "ask" },
73
89
  ...(Object.keys(provider).length ? { provider } : {}),
@@ -17,7 +17,7 @@
17
17
  * decision has to ride the event stream. The runner is handed `gate` and calls
18
18
  * it on each permission as it arrives.
19
19
  */
20
- import { routeModel, harnessFor, classifyCommand, commandHazard, allCapped, originOf, escalateAfter, } from "./recon.js";
20
+ import { routeModel, harnessFor, classifyCommand, commandHazard, allCapped, originOf, escalateAfter, STATUS_LINE, } from "./recon.js";
21
21
  const SEVERITY_RANK = { low: 0, medium: 1, high: 2, critical: 3 };
22
22
  const worstSeverity = (fs) => {
23
23
  let best;
@@ -35,7 +35,7 @@ const DEFAULT_RECON_HARNESS = {
35
35
  const posInt = (v, d) => (typeof v === "number" && Number.isInteger(v) && v >= 1 ? v : d);
36
36
  /** Merge harness overrides over the profile and hard defaults WITHOUT letting an
37
37
  * undefined/NaN/Infinity override erase a cap — the loop is never unbounded. */
38
- function resolveHarness(override) {
38
+ export function resolveHarness(override) {
39
39
  const merged = { ...DEFAULT_RECON_HARNESS, ...harnessFor("executor"), ...override };
40
40
  return {
41
41
  ...merged,
@@ -123,6 +123,7 @@ export class ReconRun {
123
123
  return { attempts: this.attempts, budgetRemaining: this.budgetRemaining(), ...extra };
124
124
  }
125
125
  }
126
+ const STATUS_REMINDER = `End your turn with one final line: "${STATUS_LINE}: continue", "${STATUS_LINE}: stuck" or "${STATUS_LINE}: done".`;
126
127
  /** Build the executor's seed prompt: scope fence + env-fidelity gate + objective. */
127
128
  export function buildReconKickoff(opts) {
128
129
  const { objective, scope, env } = opts;
@@ -132,10 +133,93 @@ export function buildReconKickoff(opts) {
132
133
  `ENVIRONMENT FIDELITY: this is a ${env.kind} instance. ${env.divergences}${nonProd} Tag every finding with this environment; if a finding depends on a setting that differs from production, mark it config-dependent and say what to re-test against production — never report it as a clean production bug.`,
133
134
  `OBJECTIVE: ${objective}`,
134
135
  `Work one hypothesis at a time with the smallest low-impact probe. Read-only probes run freely; anything that changes state pauses for human approval. When you have a candidate, hand it to the recon-verify subagent — do not promote it yourself.`,
136
+ STATUS_REMINDER,
135
137
  ].join("\n\n");
136
138
  }
137
139
  /** Prompt that nudges the executor forward after a turn goes idle with work left. */
138
- export const RECON_CONTINUE = "Continue: take the next untested hypothesis within scope. If the in-scope surface is genuinely exhausted, stop and say so rather than widening scope. Hand any new candidate to recon-verify.";
140
+ export const RECON_CONTINUE = "Continue: take the next untested hypothesis within scope. If the in-scope surface is genuinely exhausted, stop and say so rather than widening scope. Hand any new candidate to recon-verify. " + STATUS_REMINDER;
141
+ /* ─────────────── reading a turn back (pure; the session runner calls these) ─────────────── */
142
+ /**
143
+ * What the executor said about its own turn, from its final `RECON-STATUS:` line
144
+ * (the last one wins). Without the line, a turn that completed at least one tool
145
+ * call is taken to have made progress, and one that did nothing is idle.
146
+ */
147
+ export function parseTurnStatus(text, toolsCompleted) {
148
+ const all = [...text.matchAll(new RegExp(`${STATUS_LINE}:\\s*\\**\\s*(continue|stuck|done)\\b`, "gi"))];
149
+ const status = all.length ? all[all.length - 1][1].toLowerCase() : undefined;
150
+ if (status === "done")
151
+ return { madeProgress: true, done: true };
152
+ if (status === "stuck")
153
+ return { madeProgress: false, stuck: true };
154
+ if (status === "continue")
155
+ return { madeProgress: true };
156
+ return { madeProgress: toolsCompleted > 0 };
157
+ }
158
+ const VERDICTS = ["real", "config-dependent", "rejected"];
159
+ const SEVERITIES = ["low", "medium", "high", "critical"];
160
+ const clipText = (v, n) => {
161
+ const s = str(v)?.trim();
162
+ return s ? (s.length > n ? s.slice(0, n) + "…" : s) : undefined;
163
+ };
164
+ /** Every top-level `{…}` span in `text` (string-aware brace matching). */
165
+ function jsonObjects(text) {
166
+ const out = [];
167
+ let depth = 0, start = -1, inStr = false, esc = false;
168
+ for (let i = 0; i < text.length; i++) {
169
+ const c = text[i];
170
+ if (inStr) {
171
+ if (esc)
172
+ esc = false;
173
+ else if (c === "\\")
174
+ esc = true;
175
+ else if (c === '"')
176
+ inStr = false;
177
+ continue;
178
+ }
179
+ if (c === '"') {
180
+ if (depth)
181
+ inStr = true;
182
+ continue;
183
+ }
184
+ if (c === "{") {
185
+ if (depth++ === 0)
186
+ start = i;
187
+ }
188
+ else if (c === "}" && depth && --depth === 0)
189
+ out.push(text.slice(start, i + 1));
190
+ }
191
+ return out;
192
+ }
193
+ /**
194
+ * The verifier's verdicts, parsed from its reply (the JSON block its prompt asks
195
+ * for). Anything that is not valid JSON with a known verdict AND severity is
196
+ * dropped: an unparseable verdict is never promoted to a finding. The text is
197
+ * model output about an adversarial target, so it is clipped and stays data.
198
+ */
199
+ export function parseVerifierFindings(text, env) {
200
+ const out = [];
201
+ for (const raw of jsonObjects(text ?? "")) {
202
+ let o;
203
+ try {
204
+ o = JSON.parse(raw);
205
+ }
206
+ catch {
207
+ continue;
208
+ }
209
+ const verdict = VERDICTS.find((v) => v === String(get(o, "verdict")).toLowerCase());
210
+ const severity = SEVERITIES.find((s) => s === String(get(o, "severity")).toLowerCase());
211
+ const repro = clipText(get(o, "repro"), 4000);
212
+ if (!verdict || !severity || !repro)
213
+ continue;
214
+ out.push({
215
+ title: clipText(get(o, "title"), 200) ?? repro.slice(0, 80),
216
+ severity, verdict, repro, env,
217
+ standardId: clipText(get(o, "standard_id") ?? get(o, "standardId"), 60),
218
+ prodCaveat: clipText(get(o, "prod_caveat") ?? get(o, "prodCaveat"), 1000),
219
+ });
220
+ }
221
+ return out;
222
+ }
139
223
  /**
140
224
  * Drive one supervised recon run to completion. Pure control flow over the
141
225
  * injected runner: route (and escalate) the executor model each round, run a