bugxhunter 0.11.1 → 0.12.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/.env.example +3 -0
- package/README.md +9 -1
- package/docker-compose.yml +1 -0
- package/package.json +1 -1
- package/server/dist/anthropic.js +66 -8
- package/server/dist/index.js +11 -5
- package/server/dist/nvidia-health.js +12 -10
- package/web/dist/assets/{index-DpgMdCiQ.js → index-0S40kM52.js} +69 -69
- package/web/dist/index.html +1 -1
package/.env.example
CHANGED
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
# claude-mythos-5-2 is verified-organisations-only: include it only if your key
|
|
24
24
|
# has access (it may not appear in the Playground's live list even when it does).
|
|
25
25
|
# ANTHROPIC_MODELS=claude-opus-5-5,claude-sonnet-5-5,claude-haiku-5-5,claude-mythos-5-2
|
|
26
|
+
# The Playground caches a Claude chat's prompt for an hour after its last use. 5m is cheaper
|
|
27
|
+
# to write and suits quick back-and-forth; a pause longer than that then pays for the chat again.
|
|
28
|
+
# ANTHROPIC_CACHE_TTL=5m
|
|
26
29
|
|
|
27
30
|
# Optional: models on Amazon Bedrock in your own AWS account (GLM 5.3 by
|
|
28
31
|
# default), called directly. See "GLM 5.3 on Amazon Bedrock" in the README.
|
package/README.md
CHANGED
|
@@ -326,7 +326,13 @@ Things that differ from the OpenAI-style providers:
|
|
|
326
326
|
as an error naming the category. For authorised security work, Anthropic's
|
|
327
327
|
[Cyber Verification Program](https://support.claude.com/en/articles/14604842-real-time-cyber-safeguards-on-claude-opus-and-sonnet)
|
|
328
328
|
can lift cyber-category declines.
|
|
329
|
-
- **Prompt caching** is on, so repeated history in a long chat is billed at the cached rate
|
|
329
|
+
- **Prompt caching** is on, so repeated history in a long chat is billed at the cached rate, and
|
|
330
|
+
chats that share a preset share its cached system prompt. Each reply's token line shows it:
|
|
331
|
+
`9340 in (9000 cached, 300 written)`. Entries last an hour from their last use, so a pause to read a
|
|
332
|
+
long reply does not lose them (`ANTHROPIC_CACHE_TTL=5m` for five minutes, which is cheaper to write:
|
|
333
|
+
1.25 times the input price against 2). Knowledge-base
|
|
334
|
+
passages are sent with the question, not in the system prompt, so they do not reset the cache.
|
|
335
|
+
Changing the system prompt, the tools or JSON mode mid-chat does.
|
|
330
336
|
|
|
331
337
|
## GitHub repositories (read-only)
|
|
332
338
|
|
|
@@ -459,6 +465,7 @@ nobody is there to unlock.
|
|
|
459
465
|
| `ANTHROPIC_API_KEY_FILE` | unset | A file holding the Anthropic key, as `SCX_API_FILE` |
|
|
460
466
|
| `ANTHROPIC_API_KEY` | the vault, else unset | Anthropic key in the clear; prefer the vault item of the same name |
|
|
461
467
|
| `ANTHROPIC_MODELS` | `claude-opus-5-5,claude-sonnet-5-5,claude-haiku-5-5` | Claude model ids in the agent's picker (local mode; Docker: `docker/opencode.json`) |
|
|
468
|
+
| `ANTHROPIC_CACHE_TTL` | `1h` | `1h` or `5m`: how long a Playground chat's cached Claude prompt lasts after its last use. An hour costs 2 times the input price to write, five minutes 1.25 times |
|
|
462
469
|
| `ANTHROPIC_BASE_URL` | `https://api.anthropic.com/v1` | Anthropic endpoint |
|
|
463
470
|
| `BEDROCK_REGION` | `AWS_REGION`, else `us-east-1` | AWS region whose Bedrock endpoint is called |
|
|
464
471
|
| `BEDROCK_MODELS` | `global.zai.glm-5.3` | Comma list of Bedrock model or inference-profile ids (Docker: set it to show them in the agent's picker) |
|
|
@@ -501,6 +508,7 @@ GHCR images by digest) and the signed `checksums.txt` that covers them all.
|
|
|
501
508
|
<!-- releases:start -->
|
|
502
509
|
| Release | Published | Checksums | Signature | Signature check | Build |
|
|
503
510
|
| --- | --- | --- | --- | --- | --- |
|
|
511
|
+
| [v0.11.1](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.11.1) | 2026-11-27 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.11.1/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.11.1/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/45953964866) |
|
|
504
512
|
| [v0.11.0](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.11.0) | 2026-11-26 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.11.0/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.11.0/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/45788161293) |
|
|
505
513
|
| [v0.10.0](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.10.0) | 2026-11-21 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.10.0/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.10.0/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/44896163152) |
|
|
506
514
|
| [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) |
|
package/docker-compose.yml
CHANGED
|
@@ -43,6 +43,7 @@ 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
|
+
ANTHROPIC_CACHE_TTL: ${ANTHROPIC_CACHE_TTL:-} # 1h (default) or 5m: how long a Playground chat's cached prompt lasts
|
|
46
47
|
# Optional: models on Amazon Bedrock, called directly (GLM 5.3 by default). Sign in
|
|
47
48
|
# with ONE of these (see "Amazon Bedrock" in the README):
|
|
48
49
|
# - an AWS profile: mount your ~/.aws read-only (the volume below) and name the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugxhunter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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",
|
package/server/dist/anthropic.js
CHANGED
|
@@ -16,8 +16,13 @@
|
|
|
16
16
|
* fallback (`fallbacks: "default"`), so a declined request is re-run on the model
|
|
17
17
|
* Anthropic recommends for that category instead of just failing. A decline that
|
|
18
18
|
* still stands is reported as an error that names the category.
|
|
19
|
-
* - Prompt caching is on (
|
|
20
|
-
*
|
|
19
|
+
* - Prompt caching is on. The system prompt (with the tools, which render before it)
|
|
20
|
+
* has its own breakpoint, so chats that share a preset read it from cache; the
|
|
21
|
+
* conversation is cached up to its last turn, so history is not billed in full on
|
|
22
|
+
* every turn. Knowledge-base passages change every turn, so they go after the last
|
|
23
|
+
* breakpoint, never into the system prompt. What was read and written is reported
|
|
24
|
+
* in `usage.prompt_tokens_details`. Entries last an hour from their last use
|
|
25
|
+
* (ANTHROPIC_CACHE_TTL=5m for five minutes).
|
|
21
26
|
*
|
|
22
27
|
* The agent does not use this module: OpenCode talks to Claude natively, through
|
|
23
28
|
* the runner's key-injecting proxy (see index.ts and providers.ts).
|
|
@@ -33,6 +38,23 @@ const FALLBACK_MODELS = new Set(["claude-fable-5-1", "claude-opus-5-5", "claude-
|
|
|
33
38
|
const FALLBACK_BETA = "server-side-fallback-2026-07-01";
|
|
34
39
|
/** Image types the Messages API accepts. */
|
|
35
40
|
const IMAGE_TYPES = new Set(["image/jpeg", "image/png", "image/gif", "image/webp"]);
|
|
41
|
+
/**
|
|
42
|
+
* ANTHROPIC_CACHE_TTL as a cache lifetime: "1h" (the default) or "5m". Throws on anything else.
|
|
43
|
+
* An entry's time runs from its last use. One hour costs twice the input price to write, five
|
|
44
|
+
* minutes 1.25 times; a read costs a fraction either way. A person reading a long reply often
|
|
45
|
+
* takes more than five minutes, and an entry that has lapsed is written again in full, so the
|
|
46
|
+
* Playground defaults to the hour.
|
|
47
|
+
*/
|
|
48
|
+
export function readCacheTtl(value) {
|
|
49
|
+
const v = value?.trim().toLowerCase();
|
|
50
|
+
if (!v)
|
|
51
|
+
return "1h";
|
|
52
|
+
if (v !== "5m" && v !== "1h")
|
|
53
|
+
throw new Error(`ANTHROPIC_CACHE_TTL: "${value}" is not 5m or 1h.`);
|
|
54
|
+
return v;
|
|
55
|
+
}
|
|
56
|
+
/** Every breakpoint in a request carries the same lifetime (a longer one may not follow a shorter one). */
|
|
57
|
+
const CACHE = { type: "ephemeral", ttl: readCacheTtl(process.env.ANTHROPIC_CACHE_TTL) };
|
|
36
58
|
const JSON_ONLY = "Reply with one valid JSON object and nothing else: no prose before or after it, no code fences.";
|
|
37
59
|
/** The text of an OpenAI message's content (a string, or the text parts of a part list). */
|
|
38
60
|
function textOf(content) {
|
|
@@ -89,6 +111,11 @@ function parseArgs(args) {
|
|
|
89
111
|
/**
|
|
90
112
|
* An OpenAI-shaped Playground request as a Claude Messages request.
|
|
91
113
|
* `model` is the bare Claude id; `modelMax` is its output limit, if known.
|
|
114
|
+
*
|
|
115
|
+
* `params.turnContext` is text for this turn only (knowledge-base passages). It is sent
|
|
116
|
+
* as the last block of the last user turn, after the conversation's cache breakpoint:
|
|
117
|
+
* the next request will not carry it, and anything before a breakpoint must come back
|
|
118
|
+
* unchanged for the cache to be read.
|
|
92
119
|
*/
|
|
93
120
|
export function toAnthropicRequest(params, model, modelMax) {
|
|
94
121
|
const system = [];
|
|
@@ -135,11 +162,31 @@ export function toAnthropicRequest(params, model, modelMax) {
|
|
|
135
162
|
messages.unshift({ role: "user", content: [{ type: "text", text: "(conversation start)" }] });
|
|
136
163
|
if (params.response_format?.type === "json_object")
|
|
137
164
|
system.push(JSON_ONLY);
|
|
138
|
-
const
|
|
165
|
+
const systemText = system.join("\n\n");
|
|
166
|
+
const tools = params.tools?.map((t, i, all) => ({
|
|
139
167
|
name: t.function.name,
|
|
140
168
|
...(t.function.description ? { description: t.function.description } : {}),
|
|
141
169
|
input_schema: { type: "object", ...(t.function.parameters ?? {}) },
|
|
170
|
+
// Tools render before the system prompt, so its breakpoint covers them; with no system prompt they get their own.
|
|
171
|
+
...(!systemText && i === all.length - 1 ? { cache_control: CACHE } : {}),
|
|
142
172
|
}));
|
|
173
|
+
// The conversation's breakpoint: automatic (the last block) unless this turn carries context
|
|
174
|
+
// of its own, which then follows a breakpoint placed on the block before it.
|
|
175
|
+
const context = typeof params.turnContext === "string" ? params.turnContext.trim() : "";
|
|
176
|
+
let automatic = true;
|
|
177
|
+
if (context) {
|
|
178
|
+
const last = messages[messages.length - 1];
|
|
179
|
+
if (last?.role === "user") {
|
|
180
|
+
const blocks = last.content;
|
|
181
|
+
const tail = blocks[blocks.length - 1];
|
|
182
|
+
tail.cache_control = CACHE;
|
|
183
|
+
blocks.push({ type: "text", text: context });
|
|
184
|
+
automatic = false;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
messages.push({ role: "user", content: [{ type: "text", text: context }] });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
143
190
|
const stops = (Array.isArray(params.stop) ? params.stop : params.stop ? [params.stop] : []).filter((s) => typeof s === "string" && s.trim());
|
|
144
191
|
const cap = modelMax && modelMax > 0 ? modelMax : 128_000;
|
|
145
192
|
const maxTokens = Math.max(1, Math.min(params.max_tokens && params.max_tokens > 0 ? params.max_tokens : DEFAULT_MAX_TOKENS, cap));
|
|
@@ -148,8 +195,8 @@ export function toAnthropicRequest(params, model, modelMax) {
|
|
|
148
195
|
max_tokens: maxTokens,
|
|
149
196
|
messages,
|
|
150
197
|
stream: true,
|
|
151
|
-
|
|
152
|
-
...(
|
|
198
|
+
...(automatic ? { cache_control: CACHE } : {}),
|
|
199
|
+
...(systemText ? { system: [{ type: "text", text: systemText, cache_control: CACHE }] } : {}),
|
|
153
200
|
...(tools?.length ? { tools, tool_choice: params.tool_choice === "none" ? { type: "none" } : { type: "auto" } } : {}),
|
|
154
201
|
...(stops.length ? { stop_sequences: stops } : {}),
|
|
155
202
|
...(FALLBACK_MODELS.has(model) ? { betas: [FALLBACK_BETA], fallbacks: "default" } : {}),
|
|
@@ -194,9 +241,20 @@ function turnToolCalls(msg) {
|
|
|
194
241
|
.filter((b) => b.type === "tool_use")
|
|
195
242
|
.map((t) => ({ id: t.id, type: "function", function: { name: t.name, arguments: JSON.stringify(t.input ?? {}) } }));
|
|
196
243
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
244
|
+
/**
|
|
245
|
+
* Claude's usage in OpenAI form. `prompt_tokens` is the whole prompt; of it, `cached_tokens`
|
|
246
|
+
* were read from the cache (billed at a fraction) and `cache_write_tokens` were written to it
|
|
247
|
+
* (billed at a premium). The rest was billed at the normal input rate.
|
|
248
|
+
*/
|
|
249
|
+
export function usageOf(u) {
|
|
250
|
+
const read = u.cache_read_input_tokens ?? 0, written = u.cache_creation_input_tokens ?? 0;
|
|
251
|
+
const prompt = (u.input_tokens ?? 0) + read + written;
|
|
252
|
+
return {
|
|
253
|
+
prompt_tokens: prompt,
|
|
254
|
+
completion_tokens: u.output_tokens ?? 0,
|
|
255
|
+
total_tokens: prompt + (u.output_tokens ?? 0),
|
|
256
|
+
prompt_tokens_details: { cached_tokens: read, cache_write_tokens: written },
|
|
257
|
+
};
|
|
200
258
|
}
|
|
201
259
|
/** An SDK error as an SCXError the routes already know how to report. */
|
|
202
260
|
export function toSCXError(e) {
|
package/server/dist/index.js
CHANGED
|
@@ -382,17 +382,24 @@ app.get("/api/models", async (_req, res) => {
|
|
|
382
382
|
* Otherwise returns the full completion JSON.
|
|
383
383
|
*/
|
|
384
384
|
app.post("/api/chat", async (req, res) => {
|
|
385
|
-
|
|
385
|
+
// `turnContext` is the runner's own field (set below for Claude): one sent by the browser is dropped.
|
|
386
|
+
const { rag, ragTopK, turnContext: _dropped, ...params } = req.body;
|
|
386
387
|
let retrieved = [];
|
|
387
388
|
try {
|
|
388
|
-
|
|
389
|
+
const { client, model, provider } = clientFor(String(params.model ?? ""));
|
|
390
|
+
// RAG: retrieve context for the latest user turn. For Claude it rides at the end of that
|
|
391
|
+
// turn (anthropic.ts), because a system prompt that changes every turn would throw away
|
|
392
|
+
// the cached conversation; the other providers get it as a system preamble.
|
|
393
|
+
let turnContext;
|
|
389
394
|
if (rag && kb.size) {
|
|
390
395
|
const lastUser = [...params.messages].reverse().find((m) => m.role === "user");
|
|
391
396
|
const query = typeof lastUser?.content === "string" ? lastUser.content : "";
|
|
392
397
|
if (query) {
|
|
393
398
|
retrieved = await kb.search(query, ragTopK ?? 4);
|
|
394
399
|
const block = buildContextBlock(retrieved);
|
|
395
|
-
if (block)
|
|
400
|
+
if (block && provider === "anthropic")
|
|
401
|
+
turnContext = block;
|
|
402
|
+
else if (block) {
|
|
396
403
|
const sys = params.messages.find((m) => m.role === "system");
|
|
397
404
|
if (sys && typeof sys.content === "string")
|
|
398
405
|
sys.content = `${sys.content}\n\n${block}`;
|
|
@@ -401,8 +408,7 @@ app.post("/api/chat", async (req, res) => {
|
|
|
401
408
|
}
|
|
402
409
|
}
|
|
403
410
|
}
|
|
404
|
-
const {
|
|
405
|
-
const call = { ...params, model };
|
|
411
|
+
const call = { ...params, model, ...(turnContext ? { turnContext } : {}) };
|
|
406
412
|
// Keep the NVIDIA list honest: a 404 or 410 means the model was retired upstream.
|
|
407
413
|
const track = (p) => provider !== "nvidia" ? p : p.then((v) => { nvidiaHealth.markAlive(model); return v; }, (e) => { if (e instanceof SCXError && isRetiredStatus(e.status))
|
|
408
414
|
nvidiaHealth.markRetired(model); throw e; });
|
|
@@ -21,10 +21,11 @@ function load() {
|
|
|
21
21
|
return state;
|
|
22
22
|
try {
|
|
23
23
|
const s = JSON.parse(fs.readFileSync(HEALTH_FILE, "utf8"));
|
|
24
|
-
|
|
24
|
+
const saved = s.retired && typeof s.retired === "object" ? Object.entries(s.retired) : [];
|
|
25
|
+
state = { checkedAt: s.checkedAt ?? null, retired: new Map(saved.map(([id, at]) => [id, String(at)])) };
|
|
25
26
|
}
|
|
26
27
|
catch {
|
|
27
|
-
state = { checkedAt: null, retired:
|
|
28
|
+
state = { checkedAt: null, retired: new Map() };
|
|
28
29
|
}
|
|
29
30
|
return state;
|
|
30
31
|
}
|
|
@@ -32,28 +33,29 @@ function save() {
|
|
|
32
33
|
try {
|
|
33
34
|
fs.mkdirSync(path.dirname(HEALTH_FILE), { recursive: true });
|
|
34
35
|
const tmp = `${HEALTH_FILE}.tmp`;
|
|
35
|
-
|
|
36
|
+
const s = load();
|
|
37
|
+
fs.writeFileSync(tmp, JSON.stringify({ checkedAt: s.checkedAt, retired: Object.fromEntries(s.retired) }, null, 2));
|
|
36
38
|
fs.renameSync(tmp, HEALTH_FILE);
|
|
37
39
|
}
|
|
38
40
|
catch (e) {
|
|
39
41
|
console.error("[nvidia] could not save model health:", e.message);
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
|
-
export const isRetired = (id) =>
|
|
43
|
-
export const retiredIds = () =>
|
|
44
|
+
export const isRetired = (id) => load().retired.has(id);
|
|
45
|
+
export const retiredIds = () => [...load().retired.keys()].sort();
|
|
44
46
|
export function markRetired(id) {
|
|
45
47
|
const s = load();
|
|
46
|
-
if (s.retired
|
|
48
|
+
if (s.retired.has(id))
|
|
47
49
|
return;
|
|
48
|
-
s.retired
|
|
49
|
-
|
|
50
|
+
s.retired.set(id, new Date().toISOString());
|
|
51
|
+
// The id can come from a request: quoted and escaped, so it cannot break the log line.
|
|
52
|
+
console.log(`[nvidia] ${JSON.stringify(id)} answers 404, hiding it from the Playground`);
|
|
50
53
|
save();
|
|
51
54
|
}
|
|
52
55
|
export function markAlive(id) {
|
|
53
56
|
const s = load();
|
|
54
|
-
if (!s.retired
|
|
57
|
+
if (!s.retired.delete(id))
|
|
55
58
|
return;
|
|
56
|
-
delete s.retired[id];
|
|
57
59
|
save();
|
|
58
60
|
}
|
|
59
61
|
export function status() {
|