bugxhunter 0.7.0 → 0.8.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/README.md CHANGED
@@ -215,6 +215,10 @@ labs, CTFs). Build with `--build-arg SECTOOLS=0` to leave them out.
215
215
  (passive).
216
216
  - **Secrets (local, no network):** `gitleaks` — scan copied-in repos and JS bundles for leaked keys.
217
217
  - **Raw-socket:** `nmap`, `ping`, `traceroute`, `dig`/`host` (incl. zone transfer).
218
+ - **Not included — LLM red-teaming:** `promptfoo` (~1.4 GB installed) and `garak` (~2 GB with
219
+ CPU-only PyTorch, 5 GB+ if pip is left to pull the CUDA build) would more than double the image,
220
+ so the agent installs them on demand into the persistent `/workspace/.tools` volume. The recipe,
221
+ including pointing them at the runner's model proxy for grading, is in `docker/agent-AGENTS.md`.
218
222
 
219
223
  All tools run directly against targets. The agent's `AGENTS.md` tells it to confirm authorisation
220
224
  before scanning and to scan only hosts you name.
@@ -271,6 +275,7 @@ GHCR images by digest) and the signed `checksums.txt` that covers them all.
271
275
  <!-- releases:start -->
272
276
  | Release | Published | Checksums | Signature | Signature check | Build |
273
277
  | --- | --- | --- | --- | --- | --- |
278
+ | [v0.7.0](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.7.0) | 2026-10-08 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.7.0/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.7.0/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/37718565914) |
274
279
  | [v0.6.0](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.6.0) | 2026-10-08 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.6.0/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.6.0/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/37705423314) |
275
280
  | [v0.5.0](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.5.0) | 2026-10-07 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.5.0/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.5.0/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/37702342512) |
276
281
  | [v0.4.0](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.4.0) | 2026-10-07 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.4.0/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.4.0/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/37640130325) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bugxhunter",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
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",
@@ -13,7 +13,7 @@ import path from "node:path";
13
13
  import { SCXError } from "./scx.js";
14
14
  import { PROVIDERS, PROXY_TOKEN, PORT, OPENROUTER_MODELS, apiKey, clients, clientFor, keySource, listModels } from "./providers.js";
15
15
  import { KnowledgeBase, buildContextBlock } from "./rag.js";
16
- import { getClient, serverUrl, resolveDirectory, projectFile, listAgentModels, toUiEvent, toUiMessages, parseModelId, oc, query, httpError, DEFAULT_DIRECTORY, DEFAULT_MODEL, REMOTE_URL, REPO_ROOT, ALLOWED_ROOTS, } from "./opencode.js";
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";
18
18
  import { audit, followOpencode, LOG_DIR } from "./audit.js";
19
19
  import { saveAttachments } from "./attachments.js";
@@ -509,9 +509,34 @@ app.get("/api/agent/session/:id/messages", async (req, res) => {
509
509
  try {
510
510
  const directory = await resolveDirectory(req.query.directory);
511
511
  const client = await getClient(directory);
512
- const msgs = unwrap(await client.session.messages({ path: { id: req.params.id }, query: { directory } }));
512
+ const msgs = unwrap(await client.session.messages({ path: { id: req.params.id }, query: { directory } })) ?? [];
513
513
  const todos = await oc(`/session/${encodeURIComponent(req.params.id)}/todo${query({ directory })}`).catch(() => []);
514
- const messages = toUiMessages(msgs ?? []);
514
+ // Subagent sessions' messages are merged in by creation time and tagged
515
+ // with the subagent's title, so a resumed chat shows what the live stream
516
+ // did. Their user messages (the delegation prompt) are skipped: the parent's
517
+ // task tool call already shows it.
518
+ // Tool calls left "running" by an idle session were cut off: shown as
519
+ // interrupted rather than spinning forever. /session/status lists the
520
+ // non-idle sessions; one it doesn't mention is idle.
521
+ const status = await oc(`/session/status${query({ directory })}`).catch(() => ({}));
522
+ const idle = (id) => (status?.[id]?.type ?? "idle") === "idle";
523
+ const stamped = [];
524
+ const stamp = (raw, sessionID, subagent) => {
525
+ const ui = markInterrupted(toUiMessages(raw), idle(sessionID));
526
+ raw.forEach((m, i) => {
527
+ if (subagent && m?.info?.role === "user")
528
+ return;
529
+ stamped.push({ at: m?.info?.time?.created ?? 0, msg: subagent ? { ...ui[i], subagent } : ui[i] });
530
+ });
531
+ };
532
+ stamp(msgs, req.params.id);
533
+ for (const child of await childSessions(directory, req.params.id)) {
534
+ try {
535
+ stamp(unwrap(await client.session.messages({ path: { id: child.id }, query: { directory } })) ?? [], child.id, child.title || "subagent");
536
+ }
537
+ catch { /* a vanished subagent session is not worth failing the resume */ }
538
+ }
539
+ const messages = stamped.sort((a, b) => a.at - b.at).map((s) => s.msg);
515
540
  res.json({ messages, todos });
516
541
  }
517
542
  catch (e) {
@@ -592,13 +617,16 @@ app.get("/api/agent/pending", async (req, res) => {
592
617
  try {
593
618
  const sessionID = String(req.query.sessionID || "");
594
619
  const directory = await resolveDirectory(req.query.directory);
620
+ // A subagent's prompt blocks the chat just like the root session's own.
621
+ const family = sessionID ? new SessionFamily(sessionID, await childSessions(directory, sessionID)) : null;
622
+ const inScope = (sid) => !family || family.has(sid);
595
623
  const permsRaw = await oc(`/permission${query({ directory })}`).catch(() => []);
596
624
  // GET /question lists every pending question request (same shape as the
597
625
  // question.asked event); filter to this session like the permissions.
598
626
  const qRaw = await oc(`/question${query({ directory })}`).catch(() => []);
599
627
  const pending = {
600
628
  permissions: permsRaw
601
- .filter((p) => !sessionID || p.sessionID === sessionID)
629
+ .filter((p) => inScope(p.sessionID))
602
630
  .map((p) => ({
603
631
  kind: "permission",
604
632
  sessionID: p.sessionID,
@@ -607,15 +635,17 @@ app.get("/api/agent/pending", async (req, res) => {
607
635
  title: p.metadata?.command ?? p.title,
608
636
  pattern: p.patterns ?? p.pattern,
609
637
  callID: p.callID,
638
+ subagent: family?.subagent(p.sessionID),
610
639
  })),
611
640
  questions: qRaw
612
- .filter((q) => !sessionID || q.sessionID === sessionID)
641
+ .filter((q) => inScope(q.sessionID))
613
642
  .map((q) => ({
614
643
  kind: "question",
615
644
  sessionID: q.sessionID,
616
645
  requestID: q.id,
617
646
  questions: q.questions ?? [],
618
647
  callID: q.tool?.callID,
648
+ subagent: family?.subagent(q.sessionID),
619
649
  })),
620
650
  };
621
651
  res.json(pending);
@@ -720,16 +750,14 @@ app.get("/api/agent/events", async (req, res) => {
720
750
  const sub = await client.event.subscribe({ query: { directory } });
721
751
  let closed = false;
722
752
  req.on("close", () => { closed = true; clearInterval(keepAlive); sub.stream.return?.(undefined); });
753
+ // This session's events plus its subagents' (tagged), seeded with the
754
+ // subagents that already exist; ones spawned later announce themselves on
755
+ // the stream. Without a session id everything is forwarded.
756
+ const family = sessionID ? new SessionFamily(sessionID, await childSessions(directory, sessionID)) : null;
723
757
  for await (const evt of sub.stream) {
724
758
  if (closed)
725
759
  break;
726
- // Filter to this session (events carry the id in different spots).
727
- const sid = evt?.properties?.part?.sessionID ??
728
- evt?.properties?.sessionID ??
729
- evt?.properties?.info?.sessionID;
730
- if (sessionID && sid && sid !== sessionID)
731
- continue;
732
- const ui = toUiEvent(evt);
760
+ const ui = family ? family.relay(evt) : toUiEvent(evt);
733
761
  if (ui)
734
762
  res.write(`data: ${JSON.stringify(ui)}\n\n`);
735
763
  }
@@ -33,6 +33,19 @@ export const REMOTE_URL = process.env.OPENCODE_URL?.replace(/\/$/, "");
33
33
  export const WORKSPACE_ROOT = process.env.OPEN_RUNNER_WORKSPACE ?? "/workspace";
34
34
  export const DEFAULT_DIRECTORY = process.env.OPEN_RUNNER_DIR ?? (REMOTE_URL ? WORKSPACE_ROOT : REPO_ROOT);
35
35
  export const DEFAULT_MODEL = process.env.OPEN_RUNNER_MODEL ?? "scx/GLM-5.3";
36
+ /**
37
+ * Model for the `vision` subagent. Not every model takes images (SCX's GLM-5.3
38
+ * receives an attachment as base64 text and tries to decode it by hand);
39
+ * the main agent delegates screenshots to this one instead.
40
+ */
41
+ export const VISION_MODEL = process.env.OPEN_RUNNER_VISION_MODEL ?? "scx/GLM-5.3-Flash";
42
+ export const VISION_AGENT = {
43
+ model: VISION_MODEL,
44
+ mode: "subagent",
45
+ description: "Looks at screenshots and other images and reports exactly what they show. Use when the current model cannot view images: give it the file path(s) and what to look for.",
46
+ prompt: "You look at images for another agent that cannot. Read the image file(s) you are given (screenshots, diagrams, photos) with the read tool and report precisely what they show: visible text verbatim, layout, UI elements and their labels/placement, error messages, colours where they matter. Do not speculate beyond what is visible. Do not run commands or edit files.",
47
+ tools: { bash: false, edit: false, write: false, task: false },
48
+ };
36
49
  /**
37
50
  * Config layered on the user's own OpenCode setup. With OPENROUTER_MODELS set,
38
51
  * it adds an `openrouter` provider that calls back through this server's
@@ -45,6 +58,7 @@ async function inlineConfig() {
45
58
  agent: {
46
59
  build: { model: DEFAULT_MODEL },
47
60
  plan: { model: DEFAULT_MODEL },
61
+ vision: VISION_AGENT,
48
62
  },
49
63
  permission: { edit: "ask", bash: "ask" },
50
64
  ...(openrouter ? { provider: { openrouter } } : {}),
@@ -399,6 +413,83 @@ export function toUiEvent(evt) {
399
413
  return null;
400
414
  }
401
415
  }
416
+ /**
417
+ * One chat's sessions: the root session plus the subagent sessions it spawns
418
+ * (OpenCode's task tool creates a child session per delegation, with
419
+ * `parentID` set). Without this the browser only ever saw the root: a
420
+ * subagent's output was invisible and its approval prompts went unanswered,
421
+ * leaving the chat "spinning" forever.
422
+ */
423
+ export class SessionFamily {
424
+ rootID;
425
+ titles = new Map();
426
+ constructor(rootID, children = []) {
427
+ this.rootID = rootID;
428
+ // Parents may be listed after their children; a second pass catches grandchildren.
429
+ for (let i = 0; i < 2; i++)
430
+ for (const c of children)
431
+ this.add(c);
432
+ }
433
+ /** Adopt a session if its parent is in the family. Returns true when adopted. */
434
+ add(s) {
435
+ if (!s?.id || !s.parentID)
436
+ return false;
437
+ if (s.parentID !== this.rootID && !this.titles.has(s.parentID))
438
+ return false;
439
+ this.titles.set(s.id, s.title || "subagent");
440
+ return true;
441
+ }
442
+ has(sessionID) {
443
+ return sessionID === this.rootID || this.titles.has(sessionID);
444
+ }
445
+ /** The subagent's title, or undefined for the root session itself. */
446
+ subagent(sessionID) {
447
+ return this.titles.get(sessionID);
448
+ }
449
+ /**
450
+ * What the browser gets for a raw OpenCode event: the root's events as they
451
+ * are, a subagent's tagged with its title, everything else dropped. A
452
+ * subagent's idle/error must not end the parent's turn, and its session and
453
+ * todo updates are not the chat's.
454
+ */
455
+ relay(evt) {
456
+ const p = evt?.properties;
457
+ if ((evt?.type === "session.created" || evt?.type === "session.updated") && p?.info?.id)
458
+ this.add(p.info);
459
+ const ui = toUiEvent(evt);
460
+ if (!ui)
461
+ return null;
462
+ // Events carry the session id in different spots; some (permission.replied
463
+ // on older servers, question.*) carry none and pass through.
464
+ const sid = p?.part?.sessionID ?? p?.sessionID ?? p?.info?.sessionID ?? p?.permission?.sessionID ?? ui.sessionID;
465
+ if (!sid || sid === this.rootID)
466
+ return ui;
467
+ const title = this.titles.get(sid);
468
+ if (!title)
469
+ return null;
470
+ if (ui.kind === "idle" || ui.kind === "error" || ui.kind === "session" || ui.kind === "todo")
471
+ return null;
472
+ return { ...ui, subagent: title };
473
+ }
474
+ }
475
+ /**
476
+ * Every subagent session under `rootID` (children, grandchildren, …), via
477
+ * OpenCode's children endpoint. Depth-limited; a failure yields an empty list
478
+ * so the chat still works without the subagent view.
479
+ */
480
+ export async function childSessions(directory, rootID, depth = 3) {
481
+ if (depth <= 0)
482
+ return [];
483
+ const kids = await oc(`/session/${encodeURIComponent(rootID)}/children${query({ directory })}`).catch(() => []);
484
+ const out = [];
485
+ for (const k of kids ?? []) {
486
+ if (!k?.id)
487
+ continue;
488
+ out.push({ id: k.id, parentID: k.parentID ?? rootID, title: k.title });
489
+ out.push(...(await childSessions(directory, k.id, depth - 1)));
490
+ }
491
+ return out;
492
+ }
402
493
  /**
403
494
  * Stored messages (GET /session/:id/message) -> the same shape the browser
404
495
  * builds from live events, so a resumed chat renders like a live one.
@@ -438,6 +529,20 @@ export function toUiMessages(raw) {
438
529
  };
439
530
  });
440
531
  }
532
+ /**
533
+ * A tool call still "running" in a session that is idle was cut off (the turn
534
+ * was aborted, or OpenCode restarted mid-call): nothing will ever complete it,
535
+ * and the browser would spin on it forever. Mark such calls interrupted. A
536
+ * busy session's messages are returned unchanged.
537
+ */
538
+ export function markInterrupted(messages, idle) {
539
+ if (!idle)
540
+ return messages;
541
+ return messages.map((m) => ({
542
+ ...m,
543
+ parts: m.parts.map((p) => p.type === "tool" && (p.status === "running" || p.status === "pending") ? { ...p, status: "interrupted" } : p),
544
+ }));
545
+ }
441
546
  /** Pull a readable message out of an OpenCode error payload. */
442
547
  function errorText(err) {
443
548
  const msg = err?.data?.message ?? err?.message ?? err?.name;