0sec-cli 0.22.1 → 0.22.4
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/0.js +56 -45
- package/README.md +12 -0
- package/chunks/{adapt-loop-J6QCZZTB.js → adapt-loop-3CCOWE43.js} +4 -4
- package/chunks/{artifact-scraper-MFKT6OI4.js → artifact-scraper-Z4UUIOH3.js} +2 -2
- package/chunks/{assumption-mining-646LYSJY.js → assumption-mining-2UAKQB6V.js} +18 -14
- package/chunks/{chunk-OHHCGDJ2.js → chunk-2WWAPKAW.js} +126 -1089
- package/chunks/{chunk-XDKB2P5X.js → chunk-3BPX75OR.js} +1 -1
- package/chunks/chunk-4ZYYX5GY.js +74 -0
- package/chunks/{chunk-3E2KALZ5.js → chunk-5JNTMWPK.js} +2 -2
- package/chunks/{chunk-CPWA6RWE.js → chunk-5WAJGLCW.js} +3 -3
- package/chunks/{chunk-KAU6NLGP.js → chunk-6KFB6AYN.js} +515 -20
- package/chunks/{chunk-XA2O4WXA.js → chunk-6WQDXWQC.js} +169 -15
- package/chunks/chunk-6YZE552K.js +5603 -0
- package/chunks/chunk-BGX53365.js +309 -0
- package/chunks/{chunk-X7LAEEUW.js → chunk-C6JPA32H.js} +1 -1
- package/chunks/chunk-CF3MNS3O.js +990 -0
- package/chunks/{chunk-4VGLO2YS.js → chunk-CPCHLL6A.js} +5 -2
- package/chunks/{chunk-ZKQ2I3S2.js → chunk-DPUXXMJW.js} +1 -1
- package/chunks/{chunk-XCISCI4T.js → chunk-E3OOBVOK.js} +30 -12
- package/chunks/{chunk-4G7OVYJX.js → chunk-E74LXQFY.js} +1 -1
- package/chunks/{chunk-OSBPGWTE.js → chunk-ELI3BVIK.js} +3 -3
- package/chunks/chunk-FFHRANYC.js +547 -0
- package/chunks/{chunk-WSDDGFA6.js → chunk-G2BE2FC7.js} +1 -1
- package/chunks/chunk-GQ3DGHWE.js +1659 -0
- package/chunks/{chunk-V36HVTUL.js → chunk-GVY3S5E5.js} +21 -18
- package/chunks/{chunk-5BTJMINS.js → chunk-H4DH7COV.js} +192 -40
- package/chunks/{chunk-HHPWRY2M.js → chunk-H6Q2QAIY.js} +23475 -22747
- package/chunks/{chunk-7XCKYNLO.js → chunk-IHPTOTLL.js} +1 -1
- package/chunks/chunk-IXAHQICR.js +31 -0
- package/chunks/{chunk-TH2LW437.js → chunk-KCA35IL3.js} +2 -190
- package/chunks/{chunk-VWITLWXB.js → chunk-L2CCO4KE.js} +282 -34
- package/chunks/{chunk-6YNKRUMC.js → chunk-NJLKFC66.js} +321 -5
- package/chunks/{chunk-W6UWZFKL.js → chunk-O6KPVYOI.js} +100 -5
- package/chunks/{chunk-LGCASF2C.js → chunk-OAS5SAVZ.js} +6767 -2100
- package/chunks/chunk-PS5E7LUQ.js +277 -0
- package/chunks/{chunk-AV2LG2L7.js → chunk-QVIRWJ45.js} +257 -145
- package/chunks/{chunk-TV27OWIW.js → chunk-QWK4R3DB.js} +9 -9
- package/chunks/{chunk-WZRVS7SB.js → chunk-RCRTSKQN.js} +1 -1
- package/chunks/chunk-RS4MAN3Q.js +73 -0
- package/chunks/{chunk-V6GHX34G.js → chunk-RTBZ36BD.js} +8 -274
- package/chunks/{chunk-YL6YAGLL.js → chunk-SCWWLABR.js} +1 -1
- package/chunks/chunk-VDOWARMJ.js +63 -0
- package/chunks/{chunk-IFME676H.js → chunk-WBRGXCU2.js} +79 -18
- package/chunks/{chunk-IVQV574Y.js → chunk-WHUAUFSX.js} +1 -1
- package/chunks/{chunk-GOEA3NW6.js → chunk-XODDLNBI.js} +1534 -1305
- package/chunks/chunk-YAZARMJY.js +355 -0
- package/chunks/{chunk-NLH4LMWH.js → chunk-YED25PA4.js} +1 -1
- package/chunks/{codex-models-NHQW45SO.js → codex-models-Z43V3427.js} +9 -3
- package/chunks/{commands-N6GN5SBF.js → commands-EUGF4FUZ.js} +5842 -4093
- package/chunks/{db-5IWEJUYV.js → db-NVAW4WWR.js} +3 -3
- package/chunks/{dist-L3XJWWZ6.js → dist-27BNG6WD.js} +193 -112
- package/chunks/{dist-FSS7MBDF.js → dist-7RUOKPRJ.js} +12 -2
- package/chunks/{dist-KEULE5IQ.js → dist-LNXGATR2.js} +2 -2
- package/chunks/{dist-XZB53PS5.js → dist-M2X367VW.js} +2 -2
- package/chunks/{dist-BS4CY4RG.js → dist-NG2HT5XU.js} +27 -1
- package/chunks/{eval-runner-EMEGF24P.js → eval-runner-6Q3H52SP.js} +13 -9
- package/chunks/{exploit-agent-KW4EB7BE.js → exploit-agent-FCCR2HYX.js} +1 -1
- package/chunks/{exploit-autoclimb-CXJ2ERRO.js → exploit-autoclimb-X5ZS5FAO.js} +1 -1
- package/chunks/{exploit-climb-TJWLY4XC.js → exploit-climb-3JHGEO36.js} +2 -2
- package/chunks/{fix-UUKPXCFB.js → fix-NSNPU33B.js} +12 -6
- package/chunks/{harness-C5HOKIEV.js → harness-KXQOVIDQ.js} +3 -3
- package/chunks/{hunt-scan-KZZ444V2.js → hunt-scan-ELTKGKC4.js} +16 -12
- package/chunks/{kernel-primitive-Z77IR7YS.js → kernel-primitive-MT7YZSIG.js} +2 -2
- package/chunks/{kernel-vm-runner-JW77P276.js → kernel-vm-runner-YFRHYC6G.js} +2 -2
- package/chunks/{native-loop-P6P5GYVJ.js → native-loop-OFJDRHPI.js} +18 -8
- package/chunks/orchestrate-DRZ2SVCP.js +62 -0
- package/chunks/{prepare-KYHGFWCJ.js → prepare-72GWTRVI.js} +6 -2
- package/chunks/{process-N245QIQG.js → process-MJYJ2K5E.js} +2 -1
- package/chunks/{run-GAFKBCTN.js → run-WTJCZZHV.js} +1901 -4816
- package/chunks/{runtime-H7YBR5IZ.js → runtime-FCKOUB7V.js} +10 -4
- package/chunks/{runtime-XFWJTBUO.js → runtime-LCJ4XSKE.js} +5 -1
- package/chunks/{scan-stream-BMOCPKQX.js → scan-stream-GT6GKQ3U.js} +7 -1
- package/chunks/{scope-QWY4VQZ7.js → scope-E5QZUOOH.js} +2 -2
- package/chunks/service-plugins-MSK2EQP6.js +62 -0
- package/chunks/{session-store-XIDFGG7K.js → session-store-H3Q7KCYG.js} +6 -4
- package/chunks/{variant-candidates-7D4F5E4H.js → variant-candidates-SZKDCOLK.js} +9 -3
- package/chunks/{web-recon-prepass-VXXBPDAV.js → web-recon-prepass-IO3GXQMW.js} +11 -6
- package/dashboard/apple-touch-icon.png +0 -0
- package/dashboard/assets/operations-BvB5Qpmk.css +1 -0
- package/dashboard/assets/operations-D8Ii01SV.js +114 -0
- package/dashboard/assets/zero-peek-Dzm3MT3X.png +0 -0
- package/dashboard/favicon.ico +0 -0
- package/dashboard/favicon.svg +10 -0
- package/dashboard/index.html +5 -3
- package/package.json +1 -1
- package/chunks/chunk-6GHSR47F.js +0 -147
- package/chunks/chunk-BCSRRQG5.js +0 -3514
- package/chunks/chunk-BOUGKEKA.js +0 -193
- package/chunks/chunk-GHWODZMR.js +0 -16
- package/chunks/orchestrate-DWWUT5RC.js +0 -58
- package/dashboard/assets/bot-Bg1Tp9_d.js +0 -1
- package/dashboard/assets/dist-B_dDCPbu.js +0 -1
- package/dashboard/assets/findings-page-mayGhNx6.js +0 -5
- package/dashboard/assets/format--susmHX7.js +0 -1
- package/dashboard/assets/input-TuVPR3Zl.js +0 -1
- package/dashboard/assets/jsx-runtime-MGseXjj5.js +0 -3
- package/dashboard/assets/live-page-HWWHX99U.js +0 -1
- package/dashboard/assets/meta-tile-ckHo-w7k.js +0 -1
- package/dashboard/assets/operations-BxZ0OoXO.js +0 -10
- package/dashboard/assets/operations-CMFVrXEe.css +0 -2
- package/dashboard/assets/operations-app-D3d35rgo.js +0 -46
- package/dashboard/assets/overview-page-W_4IteEr.js +0 -1
- package/dashboard/assets/page-header-Bw9AJgBV.js +0 -1
- package/dashboard/assets/scans-page-CgzVXHnn.js +0 -1
- package/dashboard/assets/siren-KQj8QAnJ.js +0 -1
- package/dashboard/assets/table-8EDklulN.js +0 -1
- package/dashboard/assets/tabs-CFHPOwg8.js +0 -1
|
@@ -3,19 +3,23 @@ import { createRequire as __0CreateRequire } from "node:module";
|
|
|
3
3
|
const require = __0CreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
ProcessRuntime
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-O6KPVYOI.js";
|
|
7
7
|
import {
|
|
8
8
|
LlmApiRuntime
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QVIRWJ45.js";
|
|
10
|
+
import {
|
|
11
|
+
readCacheUsage
|
|
12
|
+
} from "./chunk-RS4MAN3Q.js";
|
|
10
13
|
|
|
11
14
|
// packages/core/dist/runtime/cli-native.js
|
|
12
15
|
import { spawn } from "node:child_process";
|
|
13
|
-
var CliNativeRuntime = class {
|
|
16
|
+
var CliNativeRuntime = class _CliNativeRuntime {
|
|
14
17
|
type;
|
|
15
18
|
config;
|
|
16
19
|
command;
|
|
17
20
|
/** Populated from the first turn's stream-json `system` event. */
|
|
18
21
|
sessionId;
|
|
22
|
+
observedModel;
|
|
19
23
|
constructor(config) {
|
|
20
24
|
if (config.type === "api") {
|
|
21
25
|
throw new Error("CliNativeRuntime does not support type=api. Use LlmApiRuntime instead.");
|
|
@@ -31,6 +35,18 @@ var CliNativeRuntime = class {
|
|
|
31
35
|
resetSession() {
|
|
32
36
|
this.sessionId = void 0;
|
|
33
37
|
}
|
|
38
|
+
resolvedModel() {
|
|
39
|
+
return this.observedModel ?? this.config.model ?? "unknown";
|
|
40
|
+
}
|
|
41
|
+
async forkForSubagent(timeout, selection) {
|
|
42
|
+
const pin = selection?.role && Object.hasOwn(this.config.agentModels ?? {}, selection.role) ? this.config.agentModels?.[selection.role] : void 0;
|
|
43
|
+
const parentModel = this.observedModel ?? this.config.model;
|
|
44
|
+
const model = this.config.singleModel ? parentModel : selection?.model ?? (pin && pin !== "auto" ? pin : parentModel);
|
|
45
|
+
if (model !== parentModel && !Object.values(this.config.agentModels ?? {}).some((approved) => approved !== "auto" && approved === model)) {
|
|
46
|
+
throw new Error(`Model '${model}' was not approved for this CLI runtime.`);
|
|
47
|
+
}
|
|
48
|
+
return new _CliNativeRuntime({ ...this.config, timeout, model });
|
|
49
|
+
}
|
|
34
50
|
async isAvailable() {
|
|
35
51
|
return new Promise((resolve) => {
|
|
36
52
|
const proc = spawn(this.command, ["--version"], {
|
|
@@ -52,8 +68,10 @@ var CliNativeRuntime = class {
|
|
|
52
68
|
});
|
|
53
69
|
});
|
|
54
70
|
}
|
|
55
|
-
async executeNative(system, messages, _tools, callbacks) {
|
|
71
|
+
async executeNative(system, messages, _tools, callbacks, signal) {
|
|
56
72
|
const start = Date.now();
|
|
73
|
+
if (signal?.aborted)
|
|
74
|
+
return { content: [], stopReason: "error", durationMs: 0, cancelled: true, error: "CLI execution cancelled." };
|
|
57
75
|
if (this.type !== "claude") {
|
|
58
76
|
return {
|
|
59
77
|
content: [{ type: "text", text: "" }],
|
|
@@ -72,6 +90,8 @@ var CliNativeRuntime = class {
|
|
|
72
90
|
};
|
|
73
91
|
}
|
|
74
92
|
const args = ["-p", promptText, "--verbose", "--output-format", "stream-json"];
|
|
93
|
+
if (this.config.model)
|
|
94
|
+
args.push("--model", this.config.model);
|
|
75
95
|
if (this.sessionId) {
|
|
76
96
|
args.push("--resume", this.sessionId);
|
|
77
97
|
} else if (system && system.trim().length > 0) {
|
|
@@ -88,7 +108,8 @@ var CliNativeRuntime = class {
|
|
|
88
108
|
const proc = spawn(this.command, args, {
|
|
89
109
|
cwd: this.config.cwd ?? process.cwd(),
|
|
90
110
|
env: { ...process.env, ...this.config.env },
|
|
91
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
111
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
112
|
+
detached: process.platform !== "win32"
|
|
92
113
|
});
|
|
93
114
|
proc.stdout?.on("data", (chunk) => {
|
|
94
115
|
stdoutBuf += chunk.toString("utf-8");
|
|
@@ -127,6 +148,8 @@ var CliNativeRuntime = class {
|
|
|
127
148
|
callbacks?.onUsage?.(partial);
|
|
128
149
|
}
|
|
129
150
|
}
|
|
151
|
+
if (typeof event.message?.model === "string")
|
|
152
|
+
this.observedModel = event.message.model;
|
|
130
153
|
if (event.type === "result") {
|
|
131
154
|
sawAssistantEnd = true;
|
|
132
155
|
stopReason = mapClaudeStopReason(event.stop_reason ?? event.subtype);
|
|
@@ -139,13 +162,38 @@ var CliNativeRuntime = class {
|
|
|
139
162
|
proc.stderr?.on("data", (chunk) => {
|
|
140
163
|
stderrBuf += chunk.toString("utf-8");
|
|
141
164
|
});
|
|
165
|
+
let killTimer;
|
|
166
|
+
const terminate = () => {
|
|
167
|
+
if (proc.pid && process.platform !== "win32") {
|
|
168
|
+
try {
|
|
169
|
+
process.kill(-proc.pid, "SIGTERM");
|
|
170
|
+
} catch {
|
|
171
|
+
proc.kill("SIGTERM");
|
|
172
|
+
}
|
|
173
|
+
} else
|
|
174
|
+
proc.kill("SIGTERM");
|
|
175
|
+
killTimer ??= setTimeout(() => {
|
|
176
|
+
if (proc.pid && process.platform !== "win32") {
|
|
177
|
+
try {
|
|
178
|
+
process.kill(-proc.pid, "SIGKILL");
|
|
179
|
+
} catch {
|
|
180
|
+
proc.kill("SIGKILL");
|
|
181
|
+
}
|
|
182
|
+
} else
|
|
183
|
+
proc.kill("SIGKILL");
|
|
184
|
+
}, 1e3);
|
|
185
|
+
};
|
|
142
186
|
const timer = setTimeout(() => {
|
|
143
187
|
timedOut = true;
|
|
144
|
-
|
|
145
|
-
setTimeout(() => proc.kill("SIGKILL"), 5e3).unref();
|
|
188
|
+
terminate();
|
|
146
189
|
}, this.config.timeout || 6e5);
|
|
190
|
+
signal?.addEventListener("abort", terminate, { once: true });
|
|
191
|
+
if (signal?.aborted)
|
|
192
|
+
terminate();
|
|
147
193
|
proc.on("error", (err) => {
|
|
148
194
|
clearTimeout(timer);
|
|
195
|
+
clearTimeout(killTimer);
|
|
196
|
+
signal?.removeEventListener("abort", terminate);
|
|
149
197
|
this.sessionId = void 0;
|
|
150
198
|
resolve({
|
|
151
199
|
content: [{ type: "text", text: "" }],
|
|
@@ -156,6 +204,13 @@ var CliNativeRuntime = class {
|
|
|
156
204
|
});
|
|
157
205
|
proc.on("close", (code) => {
|
|
158
206
|
clearTimeout(timer);
|
|
207
|
+
clearTimeout(killTimer);
|
|
208
|
+
signal?.removeEventListener("abort", terminate);
|
|
209
|
+
if (signal?.aborted) {
|
|
210
|
+
this.sessionId = void 0;
|
|
211
|
+
resolve({ content, stopReason: "error", usage, durationMs: Date.now() - start, cancelled: true, error: "CLI execution cancelled." });
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
159
214
|
if (timedOut) {
|
|
160
215
|
this.sessionId = void 0;
|
|
161
216
|
resolve({
|
|
@@ -257,8 +312,11 @@ function tryParseJson(line) {
|
|
|
257
312
|
function readUsage(u) {
|
|
258
313
|
const input = num(u.input_tokens) ?? num(u.prompt_tokens);
|
|
259
314
|
const output = num(u.output_tokens) ?? num(u.completion_tokens);
|
|
260
|
-
if (input === void 0 && output === void 0)
|
|
315
|
+
if (input === void 0 && output === void 0 && num(u.cache_read_input_tokens) === void 0 && num(u.cache_creation_input_tokens) === void 0)
|
|
261
316
|
return void 0;
|
|
317
|
+
if (u.input_tokens !== void 0 || u.cache_read_input_tokens !== void 0 || u.cache_creation_input_tokens !== void 0) {
|
|
318
|
+
return readCacheUsage({ ...u, input_tokens: input ?? 0, output_tokens: output ?? 0 });
|
|
319
|
+
}
|
|
262
320
|
return { inputTokens: input ?? 0, outputTokens: output ?? 0 };
|
|
263
321
|
}
|
|
264
322
|
function num(v) {
|
|
@@ -540,7 +598,7 @@ var OllamaRuntime = class {
|
|
|
540
598
|
}
|
|
541
599
|
}
|
|
542
600
|
/** Legacy text-in/text-out path. Used by stages that haven't migrated to NativeRuntime. */
|
|
543
|
-
async execute(prompt,
|
|
601
|
+
async execute(prompt, context) {
|
|
544
602
|
const start = Date.now();
|
|
545
603
|
try {
|
|
546
604
|
const body = {
|
|
@@ -549,7 +607,7 @@ var OllamaRuntime = class {
|
|
|
549
607
|
stream: false,
|
|
550
608
|
options: { temperature: this.temperature }
|
|
551
609
|
};
|
|
552
|
-
const res = await this.postChat(body);
|
|
610
|
+
const res = await this.postChat(body, context?.signal);
|
|
553
611
|
const usage = readUsage2(res);
|
|
554
612
|
return {
|
|
555
613
|
output: res.message.content,
|
|
@@ -569,7 +627,7 @@ var OllamaRuntime = class {
|
|
|
569
627
|
};
|
|
570
628
|
}
|
|
571
629
|
}
|
|
572
|
-
async executeNative(system, messages, tools, callbacks) {
|
|
630
|
+
async executeNative(system, messages, tools, callbacks, signal) {
|
|
573
631
|
const start = Date.now();
|
|
574
632
|
const useStream = this.stream;
|
|
575
633
|
try {
|
|
@@ -580,7 +638,7 @@ var OllamaRuntime = class {
|
|
|
580
638
|
stream: useStream,
|
|
581
639
|
options: { temperature: this.temperature }
|
|
582
640
|
};
|
|
583
|
-
const aggregate = useStream ? await this.streamChat(body, callbacks) : await this.postChat(body);
|
|
641
|
+
const aggregate = useStream ? await this.streamChat(body, callbacks, signal) : await this.postChat(body, signal);
|
|
584
642
|
const usage = readUsage2(aggregate);
|
|
585
643
|
if (callbacks?.onUsage && usage)
|
|
586
644
|
callbacks.onUsage(usage);
|
|
@@ -609,19 +667,21 @@ var OllamaRuntime = class {
|
|
|
609
667
|
content: [{ type: "text", text: "" }],
|
|
610
668
|
stopReason: "error",
|
|
611
669
|
durationMs: Date.now() - start,
|
|
612
|
-
error: msg
|
|
670
|
+
error: msg,
|
|
671
|
+
...signal?.aborted ? { cancelled: true } : {}
|
|
613
672
|
};
|
|
614
673
|
}
|
|
615
674
|
}
|
|
616
|
-
async postChat(body) {
|
|
675
|
+
async postChat(body, signal) {
|
|
617
676
|
const ctl = new AbortController();
|
|
618
677
|
const timer = setTimeout(() => ctl.abort(), this.timeout);
|
|
619
678
|
try {
|
|
679
|
+
signal?.throwIfAborted();
|
|
620
680
|
const res = await this.fetchImpl(`${this.host}/api/chat`, {
|
|
621
681
|
method: "POST",
|
|
622
682
|
headers: { "content-type": "application/json" },
|
|
623
683
|
body: JSON.stringify(body),
|
|
624
|
-
signal: ctl.signal
|
|
684
|
+
signal: signal ? AbortSignal.any([ctl.signal, signal]) : ctl.signal
|
|
625
685
|
});
|
|
626
686
|
if (!res.ok) {
|
|
627
687
|
const text = await res.text().catch(() => "");
|
|
@@ -648,15 +708,16 @@ var OllamaRuntime = class {
|
|
|
648
708
|
* the synthetic `OllamaChatResponse` so the rest of `executeNative`
|
|
649
709
|
* can keep its non-streaming-shape codepath.
|
|
650
710
|
*/
|
|
651
|
-
async streamChat(body, callbacks) {
|
|
711
|
+
async streamChat(body, callbacks, signal) {
|
|
652
712
|
const ctl = new AbortController();
|
|
653
713
|
const timer = setTimeout(() => ctl.abort(), this.timeout);
|
|
654
714
|
try {
|
|
715
|
+
signal?.throwIfAborted();
|
|
655
716
|
const res = await this.fetchImpl(`${this.host}/api/chat`, {
|
|
656
717
|
method: "POST",
|
|
657
718
|
headers: { "content-type": "application/json" },
|
|
658
719
|
body: JSON.stringify(body),
|
|
659
|
-
signal: ctl.signal
|
|
720
|
+
signal: signal ? AbortSignal.any([ctl.signal, signal]) : ctl.signal
|
|
660
721
|
});
|
|
661
722
|
if (!res.ok) {
|
|
662
723
|
const text = await res.text().catch(() => "");
|
|
@@ -806,7 +867,7 @@ function pickRuntimeForStage(stage, availableRuntimes) {
|
|
|
806
867
|
return first.done ? "claude" : first.value;
|
|
807
868
|
}
|
|
808
869
|
async function detectAvailableRuntimes() {
|
|
809
|
-
const { ProcessRuntime: ProcessRuntime2 } = await import("./process-
|
|
870
|
+
const { ProcessRuntime: ProcessRuntime2 } = await import("./process-MJYJ2K5E.js");
|
|
810
871
|
const available = /* @__PURE__ */ new Set();
|
|
811
872
|
const checks = RUNTIME_REGISTRY.map(async (info) => {
|
|
812
873
|
const rt = new ProcessRuntime2({ type: info.type, timeout: 5e3 });
|