bugxhunter 0.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bugxhunter",
3
- "version": "0.8.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, SessionFamily, childSessions, 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";
@@ -515,19 +515,24 @@ app.get("/api/agent/session/:id/messages", async (req, res) => {
515
515
  // with the subagent's title, so a resumed chat shows what the live stream
516
516
  // did. Their user messages (the delegation prompt) are skipped: the parent's
517
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";
518
523
  const stamped = [];
519
- const stamp = (raw, subagent) => {
520
- const ui = toUiMessages(raw);
524
+ const stamp = (raw, sessionID, subagent) => {
525
+ const ui = markInterrupted(toUiMessages(raw), idle(sessionID));
521
526
  raw.forEach((m, i) => {
522
527
  if (subagent && m?.info?.role === "user")
523
528
  return;
524
529
  stamped.push({ at: m?.info?.time?.created ?? 0, msg: subagent ? { ...ui[i], subagent } : ui[i] });
525
530
  });
526
531
  };
527
- stamp(msgs);
532
+ stamp(msgs, req.params.id);
528
533
  for (const child of await childSessions(directory, req.params.id)) {
529
534
  try {
530
- stamp(unwrap(await client.session.messages({ path: { id: child.id }, query: { directory } })) ?? [], child.title || "subagent");
535
+ stamp(unwrap(await client.session.messages({ path: { id: child.id }, query: { directory } })) ?? [], child.id, child.title || "subagent");
531
536
  }
532
537
  catch { /* a vanished subagent session is not worth failing the resume */ }
533
538
  }
@@ -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 } } : {}),
@@ -515,6 +529,20 @@ export function toUiMessages(raw) {
515
529
  };
516
530
  });
517
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
+ }
518
546
  /** Pull a readable message out of an OpenCode error payload. */
519
547
  function errorText(err) {
520
548
  const msg = err?.data?.message ?? err?.message ?? err?.name;