0sec-cli 0.22.0 → 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.
Files changed (107) hide show
  1. package/0.js +56 -45
  2. package/README.md +12 -0
  3. package/chunks/{adapt-loop-7I57LXXR.js → adapt-loop-3CCOWE43.js} +4 -4
  4. package/chunks/{artifact-scraper-PYZ3RU3O.js → artifact-scraper-Z4UUIOH3.js} +2 -2
  5. package/chunks/{assumption-mining-MFLF43IR.js → assumption-mining-2UAKQB6V.js} +18 -14
  6. package/chunks/{chunk-RE5EZDG2.js → chunk-2WWAPKAW.js} +126 -1089
  7. package/chunks/{chunk-LPTRPRZR.js → chunk-3BPX75OR.js} +1 -1
  8. package/chunks/chunk-4ZYYX5GY.js +74 -0
  9. package/chunks/{chunk-RSIUX3RW.js → chunk-5JNTMWPK.js} +2 -2
  10. package/chunks/{chunk-RRD4XXPU.js → chunk-5WAJGLCW.js} +3 -3
  11. package/chunks/{chunk-76KSBWOQ.js → chunk-6KFB6AYN.js} +515 -20
  12. package/chunks/{chunk-HR2TU42B.js → chunk-6WQDXWQC.js} +169 -15
  13. package/chunks/chunk-6YZE552K.js +5603 -0
  14. package/chunks/chunk-BGX53365.js +309 -0
  15. package/chunks/{chunk-7DEHG7YT.js → chunk-C6JPA32H.js} +1 -1
  16. package/chunks/chunk-CF3MNS3O.js +990 -0
  17. package/chunks/{chunk-4VGLO2YS.js → chunk-CPCHLL6A.js} +5 -2
  18. package/chunks/{chunk-DM5C5L5D.js → chunk-DPUXXMJW.js} +1 -1
  19. package/chunks/{chunk-LYUAM3TG.js → chunk-E3OOBVOK.js} +30 -12
  20. package/chunks/{chunk-HUNAPTKV.js → chunk-E74LXQFY.js} +1 -1
  21. package/chunks/{chunk-UU7PQP6N.js → chunk-ELI3BVIK.js} +3 -3
  22. package/chunks/chunk-FFHRANYC.js +547 -0
  23. package/chunks/{chunk-IO7R7WBM.js → chunk-G2BE2FC7.js} +1 -1
  24. package/chunks/chunk-GQ3DGHWE.js +1659 -0
  25. package/chunks/{chunk-V36HVTUL.js → chunk-GVY3S5E5.js} +21 -18
  26. package/chunks/{chunk-UV5QWZGE.js → chunk-H4DH7COV.js} +192 -40
  27. package/chunks/{chunk-SJBCK2EI.js → chunk-H6Q2QAIY.js} +23475 -22747
  28. package/chunks/{chunk-VMRRNRMR.js → chunk-IHPTOTLL.js} +1 -1
  29. package/chunks/chunk-IXAHQICR.js +31 -0
  30. package/chunks/{chunk-TH2LW437.js → chunk-KCA35IL3.js} +2 -190
  31. package/chunks/{chunk-VNRY6AWF.js → chunk-L2CCO4KE.js} +282 -34
  32. package/chunks/{chunk-6YNKRUMC.js → chunk-NJLKFC66.js} +321 -5
  33. package/chunks/{chunk-W6UWZFKL.js → chunk-O6KPVYOI.js} +100 -5
  34. package/chunks/{chunk-EGZGZFAH.js → chunk-OAS5SAVZ.js} +6768 -2100
  35. package/chunks/chunk-PS5E7LUQ.js +277 -0
  36. package/chunks/{chunk-2GV4HQKE.js → chunk-QVIRWJ45.js} +257 -145
  37. package/chunks/{chunk-OWLJYJ5O.js → chunk-QWK4R3DB.js} +9 -9
  38. package/chunks/{chunk-XFCTUKXR.js → chunk-RCRTSKQN.js} +1 -1
  39. package/chunks/chunk-RS4MAN3Q.js +73 -0
  40. package/chunks/{chunk-7UFUALR2.js → chunk-RTBZ36BD.js} +8 -274
  41. package/chunks/{chunk-TZFIAMWZ.js → chunk-SCWWLABR.js} +1 -1
  42. package/chunks/chunk-VDOWARMJ.js +63 -0
  43. package/chunks/{chunk-5MWAG3FT.js → chunk-WBRGXCU2.js} +79 -18
  44. package/chunks/{chunk-LCRTAQN2.js → chunk-WHUAUFSX.js} +1 -1
  45. package/chunks/{chunk-YIQSGNAA.js → chunk-XODDLNBI.js} +1535 -1306
  46. package/chunks/chunk-YAZARMJY.js +355 -0
  47. package/chunks/{chunk-OAYUPGF6.js → chunk-YED25PA4.js} +1 -1
  48. package/chunks/{codex-models-7TLJSY3L.js → codex-models-Z43V3427.js} +9 -3
  49. package/chunks/{commands-NEI7L3QA.js → commands-EUGF4FUZ.js} +5844 -4095
  50. package/chunks/{db-5AP3JB4W.js → db-NVAW4WWR.js} +3 -3
  51. package/chunks/{dist-3FNZIBB4.js → dist-27BNG6WD.js} +195 -112
  52. package/chunks/{dist-5YHYNLI3.js → dist-7RUOKPRJ.js} +12 -2
  53. package/chunks/{dist-KEULE5IQ.js → dist-LNXGATR2.js} +2 -2
  54. package/chunks/{dist-XZB53PS5.js → dist-M2X367VW.js} +2 -2
  55. package/chunks/{dist-DD4H6HMQ.js → dist-NG2HT5XU.js} +27 -1
  56. package/chunks/{eval-runner-43BO2C4T.js → eval-runner-6Q3H52SP.js} +13 -9
  57. package/chunks/{exploit-agent-N4A5ELBK.js → exploit-agent-FCCR2HYX.js} +1 -1
  58. package/chunks/{exploit-autoclimb-N7P6KIF5.js → exploit-autoclimb-X5ZS5FAO.js} +1 -1
  59. package/chunks/{exploit-climb-WNEJUB5W.js → exploit-climb-3JHGEO36.js} +2 -2
  60. package/chunks/{fix-Z452M4EC.js → fix-NSNPU33B.js} +12 -6
  61. package/chunks/{harness-QJJJVSG4.js → harness-KXQOVIDQ.js} +3 -3
  62. package/chunks/{hunt-scan-K6D2V3PX.js → hunt-scan-ELTKGKC4.js} +16 -12
  63. package/chunks/{kernel-primitive-TKUACPKD.js → kernel-primitive-MT7YZSIG.js} +2 -2
  64. package/chunks/{kernel-vm-runner-RAAO2PGT.js → kernel-vm-runner-YFRHYC6G.js} +2 -2
  65. package/chunks/{native-loop-2ZRJENZ3.js → native-loop-OFJDRHPI.js} +18 -8
  66. package/chunks/orchestrate-DRZ2SVCP.js +62 -0
  67. package/chunks/{prepare-KYHGFWCJ.js → prepare-72GWTRVI.js} +6 -2
  68. package/chunks/{process-N245QIQG.js → process-MJYJ2K5E.js} +2 -1
  69. package/chunks/{run-U3XU4CTC.js → run-WTJCZZHV.js} +3091 -6037
  70. package/chunks/{runtime-G75TEWQY.js → runtime-FCKOUB7V.js} +10 -4
  71. package/chunks/{runtime-XFWJTBUO.js → runtime-LCJ4XSKE.js} +5 -1
  72. package/chunks/{scan-stream-BMOCPKQX.js → scan-stream-GT6GKQ3U.js} +7 -1
  73. package/chunks/{scope-WXI46UHJ.js → scope-E5QZUOOH.js} +2 -2
  74. package/chunks/service-plugins-MSK2EQP6.js +62 -0
  75. package/chunks/{session-store-27L3ZU73.js → session-store-H3Q7KCYG.js} +6 -4
  76. package/chunks/{variant-candidates-YWZORZMK.js → variant-candidates-SZKDCOLK.js} +9 -3
  77. package/chunks/{web-recon-prepass-YVMFXCIK.js → web-recon-prepass-IO3GXQMW.js} +11 -6
  78. package/dashboard/apple-touch-icon.png +0 -0
  79. package/dashboard/assets/operations-BvB5Qpmk.css +1 -0
  80. package/dashboard/assets/operations-D8Ii01SV.js +114 -0
  81. package/dashboard/assets/zero-peek-Dzm3MT3X.png +0 -0
  82. package/dashboard/favicon.ico +0 -0
  83. package/dashboard/favicon.svg +10 -0
  84. package/dashboard/index.html +5 -3
  85. package/package.json +1 -1
  86. package/chunks/chunk-6GHSR47F.js +0 -147
  87. package/chunks/chunk-CAYANSH6.js +0 -3524
  88. package/chunks/chunk-GHWODZMR.js +0 -16
  89. package/chunks/chunk-MICHDTBK.js +0 -193
  90. package/chunks/orchestrate-2GWGNTBF.js +0 -58
  91. package/dashboard/assets/bot-Bg1Tp9_d.js +0 -1
  92. package/dashboard/assets/dist-B_dDCPbu.js +0 -1
  93. package/dashboard/assets/findings-page-mayGhNx6.js +0 -5
  94. package/dashboard/assets/format--susmHX7.js +0 -1
  95. package/dashboard/assets/input-TuVPR3Zl.js +0 -1
  96. package/dashboard/assets/jsx-runtime-MGseXjj5.js +0 -3
  97. package/dashboard/assets/live-page-HWWHX99U.js +0 -1
  98. package/dashboard/assets/meta-tile-ckHo-w7k.js +0 -1
  99. package/dashboard/assets/operations-BxZ0OoXO.js +0 -10
  100. package/dashboard/assets/operations-CMFVrXEe.css +0 -2
  101. package/dashboard/assets/operations-app-D3d35rgo.js +0 -46
  102. package/dashboard/assets/overview-page-W_4IteEr.js +0 -1
  103. package/dashboard/assets/page-header-Bw9AJgBV.js +0 -1
  104. package/dashboard/assets/scans-page-CgzVXHnn.js +0 -1
  105. package/dashboard/assets/siren-KQj8QAnJ.js +0 -1
  106. package/dashboard/assets/table-8EDklulN.js +0 -1
  107. package/dashboard/assets/tabs-CFHPOwg8.js +0 -1
@@ -1,27 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __0CreateRequire } from "node:module";
3
3
  const require = __0CreateRequire(import.meta.url);
4
- import {
5
- agenticScan
6
- } from "./chunk-EGZGZFAH.js";
7
4
  import {
8
5
  source_default
9
6
  } from "./chunk-HLFS6WV2.js";
7
+ import {
8
+ agenticScan
9
+ } from "./chunk-OAS5SAVZ.js";
10
10
  import {
11
11
  runAgentLoop
12
- } from "./chunk-UV5QWZGE.js";
12
+ } from "./chunk-H4DH7COV.js";
13
13
  import {
14
14
  getToolsForRole
15
- } from "./chunk-SJBCK2EI.js";
15
+ } from "./chunk-H6Q2QAIY.js";
16
16
  import {
17
17
  createRuntime
18
- } from "./chunk-5MWAG3FT.js";
18
+ } from "./chunk-WBRGXCU2.js";
19
19
  import {
20
20
  osecDB
21
- } from "./chunk-VNRY6AWF.js";
21
+ } from "./chunk-L2CCO4KE.js";
22
22
  import {
23
23
  LlmApiRuntime
24
- } from "./chunk-2GV4HQKE.js";
24
+ } from "./chunk-QVIRWJ45.js";
25
25
 
26
26
  // packages/cli/src/commands/orchestrate.ts
27
27
  import { randomUUID } from "node:crypto";
@@ -483,7 +483,7 @@ async function runFamilyCandidate(candidate, opts) {
483
483
  }
484
484
  }
485
485
  function registerOrchestrateCommand(program) {
486
- program.command("orchestrate").description("Run the autonomous verification worker against persisted queued case work").option("--db-path <path>", "Path to SQLite database").option("--limit <n>", "Maximum queued cases to claim per pass", "1").option("--runtime <runtime>", "Runtime override: auto, claude, codex, gemini, api").option("--timeout <ms>", "Request timeout in milliseconds", "30000").option("--api-key <key>", "API key for LLM provider").option("-m, --model <model>", "LLM model to use").option("--watch", "Run as a persistent daemon loop", false).option("--poll-interval <ms>", "Idle poll interval for watch mode", "5000").option("--label <name>", "Operator-facing worker label").action(async (opts) => {
486
+ program.command("orchestrate").description("Run the verification worker against queued cases").option("--db-path <path>", "Path to SQLite database").option("--limit <n>", "Maximum queued cases to claim per pass", "1").option("--runtime <runtime>", "Runtime override: auto, claude, codex, gemini, api").option("--timeout <ms>", "Request timeout in milliseconds", "30000").option("--api-key <key>", "API key for LLM provider").option("-m, --model <model>", "LLM model to use").option("--watch", "Run as a persistent daemon loop", false).option("--poll-interval <ms>", "Idle poll interval for watch mode", "5000").option("--label <name>", "Operator-facing worker label").action(async (opts) => {
487
487
  const workerId = `orchestrator:${randomUUID()}`;
488
488
  const label = opts.label?.trim() || `${hostname()}:${process.pid}`;
489
489
  const limit = Math.max(1, parseInt(opts.limit ?? "1", 10));
@@ -3,7 +3,7 @@ import { createRequire as __0CreateRequire } from "node:module";
3
3
  const require = __0CreateRequire(import.meta.url);
4
4
  import {
5
5
  homeStateDir
6
- } from "./chunk-76KSBWOQ.js";
6
+ } from "./chunk-6KFB6AYN.js";
7
7
 
8
8
  // packages/core/dist/triage/kernel-vm-runner.js
9
9
  import { execFileSync, spawn } from "node:child_process";
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0CreateRequire } from "node:module";
3
+ const require = __0CreateRequire(import.meta.url);
4
+
5
+ // packages/core/dist/runtime/prompt-cache.js
6
+ var MAX_CACHE_BREAKPOINTS = 4;
7
+ var MESSAGE_CACHE_BREAKPOINTS = MAX_CACHE_BREAKPOINTS - 1;
8
+ var BREAKPOINT_SPACING_BLOCKS = 15;
9
+ var NATIVE_CACHE_PROVIDERS = /* @__PURE__ */ new Set(["anthropic"]);
10
+ var OPT_IN_CACHE_PROVIDERS = /* @__PURE__ */ new Set(["z-ai", "kimi"]);
11
+ function providerSupportsPromptCache(provider) {
12
+ if (NATIVE_CACHE_PROVIDERS.has(provider))
13
+ return true;
14
+ if (!OPT_IN_CACHE_PROVIDERS.has(provider))
15
+ return false;
16
+ return readExtraCacheProviders().has(provider);
17
+ }
18
+ function readExtraCacheProviders() {
19
+ const raw = process.env["ZERO_PROMPT_CACHE_EXTRA_PROVIDERS"];
20
+ if (!raw)
21
+ return /* @__PURE__ */ new Set();
22
+ return new Set(raw.split(",").map((entry) => entry.trim().toLowerCase()).filter((entry) => entry.length > 0));
23
+ }
24
+ function planMessageBreakpoints(messages, budget = MESSAGE_CACHE_BREAKPOINTS) {
25
+ if (messages.length === 0 || budget <= 0)
26
+ return [];
27
+ const lastIndex = messages.length - 1;
28
+ const picks = /* @__PURE__ */ new Set([lastIndex]);
29
+ const rollingBudget = Math.max(1, budget - 1);
30
+ let blocksSincePick = blockCount(messages[lastIndex]);
31
+ for (let i = lastIndex - 1; i >= 0 && picks.size < rollingBudget; i--) {
32
+ if (blocksSincePick >= BREAKPOINT_SPACING_BLOCKS) {
33
+ picks.add(i);
34
+ blocksSincePick = 0;
35
+ }
36
+ blocksSincePick += blockCount(messages[i]);
37
+ }
38
+ if (picks.size < budget)
39
+ picks.add(0);
40
+ return [...picks].sort((a, b) => a - b).slice(0, budget);
41
+ }
42
+ function blockCount(message) {
43
+ return message?.content.length ?? 0;
44
+ }
45
+ function withCacheControl(block) {
46
+ return { ...block, cache_control: { type: "ephemeral" } };
47
+ }
48
+ function readCacheUsage(raw) {
49
+ if (typeof raw !== "object" || raw === null)
50
+ return void 0;
51
+ const usage = raw;
52
+ const uncachedInput = numberOr(usage.input_tokens, 0);
53
+ const outputTokens = numberOr(usage.output_tokens, 0);
54
+ const cacheRead = numberOr(usage.cache_read_input_tokens, void 0);
55
+ const cacheWrite = numberOr(usage.cache_creation_input_tokens, void 0);
56
+ return {
57
+ inputTokens: uncachedInput + (cacheRead ?? 0) + (cacheWrite ?? 0),
58
+ outputTokens,
59
+ ...cacheRead !== void 0 ? { cachedInputTokens: cacheRead } : {},
60
+ ...cacheWrite !== void 0 ? { cacheWriteTokens: cacheWrite } : {}
61
+ };
62
+ }
63
+ function numberOr(value, fallback) {
64
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
65
+ }
66
+
67
+ export {
68
+ MESSAGE_CACHE_BREAKPOINTS,
69
+ providerSupportsPromptCache,
70
+ planMessageBreakpoints,
71
+ withCacheControl,
72
+ readCacheUsage
73
+ };
@@ -2,30 +2,11 @@
2
2
  import { createRequire as __0CreateRequire } from "node:module";
3
3
  const require = __0CreateRequire(import.meta.url);
4
4
  import {
5
- FEEDBACK_OPT_OUT_ENV,
6
- PROVIDERS,
7
- accountEnvPatch,
8
- loadAccountStore,
9
- loadGlobalSettings,
10
- loadLayeredSettings,
11
- maybeLoadCodexAuth,
12
- normalizeSettings,
13
- saveSettings,
14
- submissionBlockedReason
15
- } from "./chunk-YIQSGNAA.js";
16
- import {
17
- runSmolvmWorkbench
18
- } from "./chunk-EGZGZFAH.js";
19
- import {
20
- ANALYTICS_LEVEL_ENV,
21
- getSmolvmWorkbenchStatus,
22
- isAdmittedSmolvmWorkbench,
23
- levelAtLeast,
24
- resolveAnalyticsLevel
25
- } from "./chunk-RE5EZDG2.js";
5
+ loadLayeredSettings
6
+ } from "./chunk-XODDLNBI.js";
26
7
  import {
27
8
  homeStateDir
28
- } from "./chunk-76KSBWOQ.js";
9
+ } from "./chunk-6KFB6AYN.js";
29
10
  import {
30
11
  __commonJS,
31
12
  __require,
@@ -3042,247 +3023,9 @@ var {
3042
3023
  Help
3043
3024
  } = import_index.default;
3044
3025
 
3045
- // packages/cli/src/workbench.ts
3046
- import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
3047
- import { homedir } from "node:os";
3048
- import { dirname, isAbsolute, join } from "node:path";
3049
- import { execFile } from "node:child_process";
3050
- import { promisify } from "node:util";
3051
- var execFileAsync = promisify(execFile);
3052
- var WORKBENCH_INNER_ARGUMENT = "--workbench-inner";
3053
- function workbenchConfigPath(home = process.env.HOME || homedir()) {
3054
- return join(homeStateDir(home), "workbench.json");
3055
- }
3056
- function defaultWorkbenchStateRoot(home = process.env.HOME || homedir()) {
3057
- return join(homeStateDir(home), "workbench");
3058
- }
3059
- function positiveInteger(value, maximum) {
3060
- return typeof value === "number" && Number.isInteger(value) && value > 0 && value <= maximum;
3061
- }
3062
- function isPinnedWorkbenchImageReference(value) {
3063
- return typeof value === "string" && /^[a-z0-9][a-z0-9._:/-]*@sha256:[a-f0-9]{64}$/.test(value) && !value.slice(0, value.indexOf("@")).slice(value.lastIndexOf("/") + 1).includes(":");
3064
- }
3065
- function normalizeWorkbenchConfig(raw) {
3066
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("Invalid workbench operator choices.");
3067
- const config = raw;
3068
- const approvedImages = [];
3069
- if (config.approvedImages !== void 0) {
3070
- if (!Array.isArray(config.approvedImages)) throw new Error("Invalid workbench sandbox image catalog.");
3071
- const references = /* @__PURE__ */ new Set();
3072
- for (const rawImage of config.approvedImages) {
3073
- if (typeof rawImage !== "object" || rawImage === null || Array.isArray(rawImage)) throw new Error("Invalid workbench sandbox image catalog.");
3074
- const image = rawImage;
3075
- if (!isPinnedWorkbenchImageReference(image.reference) || typeof image.archive !== "string" || !isAbsolute(image.archive) || typeof image.digest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(image.digest) || references.has(image.reference)) throw new Error("Sandbox image grants require unique immutable repository@sha256 references and approved local archives.");
3076
- references.add(image.reference);
3077
- approvedImages.push({ reference: image.reference, archive: image.archive, digest: image.digest });
3078
- }
3079
- }
3080
- if (config.schemaVersion !== 1 || typeof config.image !== "string" || !isAbsolute(config.image) || typeof config.imageDigest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(config.imageDigest) || typeof config.stateRoot !== "string" || !isAbsolute(config.stateRoot) || config.workspaceRoot !== void 0 && (typeof config.workspaceRoot !== "string" || !isAbsolute(config.workspaceRoot)) || !Array.isArray(config.providers) || config.providers.some((id) => typeof id !== "string" || !PROVIDERS.some((provider) => provider.id === id)) || typeof config.github !== "boolean" || !positiveInteger(config.cpus, 64) || !positiveInteger(config.memoryMb, 262144) || !positiveInteger(config.storageGb, 1024)) {
3081
- throw new Error("Invalid workbench operator choices.");
3082
- }
3083
- return {
3084
- schemaVersion: 1,
3085
- image: config.image,
3086
- imageDigest: config.imageDigest,
3087
- stateRoot: config.stateRoot,
3088
- ...config.workspaceRoot === void 0 ? {} : { workspaceRoot: config.workspaceRoot },
3089
- providers: [...new Set(config.providers)],
3090
- github: config.github,
3091
- cpus: config.cpus,
3092
- memoryMb: config.memoryMb,
3093
- storageGb: config.storageGb,
3094
- ...approvedImages.length ? { approvedImages } : {}
3095
- };
3096
- }
3097
- function loadWorkbenchConfig(home) {
3098
- const file = workbenchConfigPath(home);
3099
- if (!existsSync(file)) return void 0;
3100
- try {
3101
- const stat = lstatSync(file);
3102
- if (!stat.isFile() || stat.isSymbolicLink() || (stat.mode & 63) !== 0 || stat.uid !== process.getuid?.()) {
3103
- throw new Error("Workbench configuration must be an operator-owned, private regular file (mode 0600).");
3104
- }
3105
- return normalizeWorkbenchConfig(JSON.parse(readFileSync(file, "utf8")));
3106
- } catch (error) {
3107
- if (error instanceof Error && error.message.startsWith("Workbench configuration must")) throw error;
3108
- throw new Error(`Unreadable or invalid workbench configuration at ${file}. Repair the operator choices before setup or launch; no profile fallback is allowed.`);
3109
- }
3110
- }
3111
- function saveWorkbenchConfig(config, home) {
3112
- const path = workbenchConfigPath(home);
3113
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
3114
- const temporary = `${path}.${process.pid}.tmp`;
3115
- writeFileSync(temporary, `${JSON.stringify(normalizeWorkbenchConfig(config), null, 2)}
3116
- `, { encoding: "utf8", mode: 384, flag: "wx" });
3117
- renameSync(temporary, path);
3118
- chmodSync(path, 384);
3119
- }
3120
- var PROVIDER_CONFIGURATION = {
3121
- "chatgpt-codex": ["ZERO_CHATGPT_ACCOUNT_ID", "ZERO_CHATGPT_BASE_URL"],
3122
- deepseek: ["DEEPSEEK_BASE_URL"],
3123
- openrouter: ["OPENROUTER_BASE_URL"],
3124
- azure: ["AZURE_OPENAI_BASE_URL", "AZURE_OPENAI_API_VERSION", "AZURE_OPENAI_DEPLOYMENT", "OPENAI_BASE_URL"],
3125
- openai: ["OPENAI_BASE_URL"],
3126
- "z-ai": ["Z_AI_BASE_URL"],
3127
- kimi: ["KIMI_BASE_URL"],
3128
- qwen: ["QWEN_BASE_URL"],
3129
- xai: ["XAI_BASE_URL"],
3130
- opencode: ["OPENCODE_BASE_URL"],
3131
- copilot: ["COPILOT_BASE_URL"],
3132
- google: ["GOOGLE_CLOUD_PROJECT", "ZERO_GEMINI_PROJECT"],
3133
- anthropic: ["ANTHROPIC_BASE_URL"]
3134
- };
3135
- function selectedWorkbenchEnvironment(config, env, accounts) {
3136
- const selected = { version: 2, providers: {} };
3137
- const result = {};
3138
- for (const id of config.providers) {
3139
- const provider = PROVIDERS.find((candidate) => candidate.id === id);
3140
- if (!provider) throw new Error(`Unknown workbench provider grant: ${id}`);
3141
- const account = accounts.providers[id];
3142
- if (account) selected.providers[id] = account;
3143
- for (const name of [...provider.envVars, ...PROVIDER_CONFIGURATION[id] ?? []]) {
3144
- const value = env[name];
3145
- if (value?.trim()) result[name] = value;
3146
- }
3147
- }
3148
- Object.assign(result, accountEnvPatch(selected, result));
3149
- if (config.github) {
3150
- const token = env.GH_TOKEN?.trim() || env.GITHUB_TOKEN?.trim();
3151
- if (token) result.GH_TOKEN = token;
3152
- }
3153
- for (const name of ["TERM", "COLORTERM", "NO_COLOR", "LANG", "LC_ALL"]) {
3154
- const value = env[name];
3155
- if (value !== void 0) result[name] = value;
3156
- }
3157
- return result;
3158
- }
3159
- async function integrationEnvironment(config, home) {
3160
- const accounts = config.providers.length ? loadAccountStore(home) : { version: 2, providers: {} };
3161
- const environment = selectedWorkbenchEnvironment(config, process.env, accounts);
3162
- if (config.providers.includes("chatgpt-codex")) {
3163
- const codexEnvironment = {
3164
- ...environment,
3165
- ZERO_CHATGPT_AUTH_FILE: process.env.ZERO_CHATGPT_AUTH_FILE,
3166
- ZERO_CODEX_AUTH_JSON_PATH: process.env.ZERO_CODEX_AUTH_JSON_PATH
3167
- };
3168
- maybeLoadCodexAuth({ env: codexEnvironment, home });
3169
- for (const name of ["ZERO_CHATGPT_ACCESS_TOKEN", "ZERO_CHATGPT_OAUTH_REFRESH_TOKEN"]) {
3170
- const value = codexEnvironment[name];
3171
- if (value) environment[name] = value;
3172
- }
3173
- }
3174
- if (config.github && !environment.GH_TOKEN) {
3175
- try {
3176
- const { stdout } = await execFileAsync("gh", ["auth", "token"], { encoding: "utf8", timeout: 1e4, maxBuffer: 65536 });
3177
- if (stdout.trim()) environment.GH_TOKEN = stdout.trim();
3178
- } catch {
3179
- throw new Error("GitHub grant is enabled but no token is available. Connect gh on the host or run 0 workbench setup --no-github.");
3180
- }
3181
- }
3182
- return environment;
3183
- }
3184
- function resolveWorkbenchGuestSettings(settings, env = process.env) {
3185
- const privacy = { [ANALYTICS_LEVEL_ENV]: env[ANALYTICS_LEVEL_ENV] ?? settings.analyticsLevel };
3186
- for (const name of FEEDBACK_OPT_OUT_ENV) privacy[name] = env[name];
3187
- const environmentLevel = resolveAnalyticsLevel(privacy);
3188
- return normalizeSettings({
3189
- ...settings,
3190
- executionProfile: "local",
3191
- updatePolicy: "off",
3192
- analyticsLevel: levelAtLeast(environmentLevel, settings.analyticsLevel) ? settings.analyticsLevel : environmentLevel,
3193
- diagnosticReporting: submissionBlockedReason(privacy, { allowCloud: false }) === "opt-out" ? "off" : settings.diagnosticReporting
3194
- });
3195
- }
3196
- function workbenchNetworkEnabled(env = process.env) {
3197
- return submissionBlockedReason({ ZERO_OFFLINE: env.ZERO_OFFLINE }, { allowCloud: false }) !== "opt-out";
3198
- }
3199
- async function launchConfiguredWorkbench(args) {
3200
- const home = process.env.HOME || homedir();
3201
- if (args[0] === WORKBENCH_INNER_ARGUMENT) {
3202
- if (process.platform !== "linux" || !isAdmittedSmolvmWorkbench()) {
3203
- throw new Error("Missing authenticated SmolVM broker admission; refusing internal invocation.");
3204
- }
3205
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
3206
- return void 0;
3207
- }
3208
- if (process.platform === "linux" && isAdmittedSmolvmWorkbench()) return void 0;
3209
- if (args[0] === "workbench" || args[0] === "config") return void 0;
3210
- const hostSettings = loadGlobalSettings(home, { requireExecutionProfile: existsSync(workbenchConfigPath(home)) });
3211
- if (hostSettings.executionProfile !== "smolvm") return void 0;
3212
- const config = loadWorkbenchConfig(home);
3213
- if (!config) throw new Error("SmolVM profile is selected but no workbench is configured. Run 0 workbench setup --image <approved-archive>.");
3214
- const workspaceRoot = realpathSync(config.workspaceRoot ?? process.cwd());
3215
- if (!lstatSync(workspaceRoot).isDirectory()) throw new Error("The configured workbench workspace is not a directory.");
3216
- const status = await getSmolvmWorkbenchStatus({ stateRoot: config.stateRoot, image: config.image });
3217
- if (status.retainedRuns.length) throw new Error("SmolVM has retained admission from an unproven cleanup. Resolve it before launching another workbench.");
3218
- if (!status.platformSupported || !status.runtimeReady || !status.imageApproved) {
3219
- throw new Error(status.error ?? "SmolVM runtime or approved image is unavailable. Run 0 workbench setup; host fallback is refused.");
3220
- }
3221
- const environment = await integrationEnvironment(config, home);
3222
- const network = workbenchNetworkEnabled();
3223
- if (!network) environment.ZERO_OFFLINE = "1";
3224
- const guestState = join(config.stateRoot, "guest-state");
3225
- mkdirSync(guestState, { recursive: true, mode: 448 });
3226
- if (!lstatSync(guestState).isDirectory() || lstatSync(guestState).isSymbolicLink()) throw new Error("Workbench guest-state must be a real private directory.");
3227
- const settingsFile = join(guestState, "tui-settings.json");
3228
- const temporarySettings = `${settingsFile}.${process.pid}.tmp`;
3229
- writeFileSync(temporarySettings, `${JSON.stringify(resolveWorkbenchGuestSettings(hostSettings), null, 2)}
3230
- `, { mode: 384, flag: "wx" });
3231
- renameSync(temporarySettings, settingsFile);
3232
- const controller = new AbortController();
3233
- let signalCode;
3234
- const interrupt = () => {
3235
- signalCode = 130;
3236
- controller.abort();
3237
- };
3238
- const terminate = () => {
3239
- signalCode = 143;
3240
- controller.abort();
3241
- };
3242
- const hangup = () => {
3243
- signalCode = 129;
3244
- controller.abort();
3245
- };
3246
- process.once("SIGINT", interrupt);
3247
- process.once("SIGTERM", terminate);
3248
- process.once("SIGHUP", hangup);
3249
- let result;
3250
- try {
3251
- result = await runSmolvmWorkbench({
3252
- image: config.image,
3253
- workspaceRoot,
3254
- stateRoot: config.stateRoot,
3255
- command: ["/usr/local/bin/0", WORKBENCH_INNER_ARGUMENT, ...args],
3256
- environment,
3257
- network,
3258
- tty: !!process.stdin.isTTY && !!process.stdout.isTTY,
3259
- cpus: config.cpus,
3260
- memoryMb: config.memoryMb,
3261
- storageGb: config.storageGb,
3262
- signal: controller.signal,
3263
- approvedImages: config.approvedImages ?? []
3264
- });
3265
- } finally {
3266
- process.removeListener("SIGINT", interrupt);
3267
- process.removeListener("SIGTERM", terminate);
3268
- process.removeListener("SIGHUP", hangup);
3269
- }
3270
- if (result.cleanupFailed) {
3271
- process.stderr.write("[0] SmolVM cleanup could not be proven. Workbench admission/state is retained; host execution is refused.\n");
3272
- return 125;
3273
- }
3274
- if (result.error) process.stderr.write(`[0] ${result.error}
3275
- `);
3276
- if (result.timedOut) return 124;
3277
- return signalCode ?? result.exitCode ?? 125;
3278
- }
3279
- function selectWorkbenchProfile(profile, home) {
3280
- if (!saveSettings({ ...loadGlobalSettings(home), executionProfile: profile }, home)) throw new Error("Could not persist the operator execution profile.");
3281
- }
3282
-
3283
3026
  // packages/cli/src/utils/update-check.ts
3284
- import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
3285
- import { join as join2 } from "node:path";
3027
+ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
3028
+ import { join } from "node:path";
3286
3029
  import { spawn } from "node:child_process";
3287
3030
  var REPO = "0sec-labs/0";
3288
3031
  var INSTALL_URL = `https://raw.githubusercontent.com/${REPO}/main/install.sh`;
@@ -3337,7 +3080,7 @@ function recent(timestamp, now) {
3337
3080
  }
3338
3081
  function readCache() {
3339
3082
  try {
3340
- const raw = JSON.parse(readFileSync2(join2(homeStateDir(), "last-update-check"), "utf8"));
3083
+ const raw = JSON.parse(readFileSync(join(homeStateDir(), "last-update-check"), "utf8"));
3341
3084
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
3342
3085
  const value = raw;
3343
3086
  if (typeof value.lastCheckedAt !== "string") return null;
@@ -3353,8 +3096,8 @@ function readCache() {
3353
3096
  }
3354
3097
  function writeCache(cache) {
3355
3098
  try {
3356
- mkdirSync2(homeStateDir(), { recursive: true });
3357
- writeFileSync2(join2(homeStateDir(), "last-update-check"), JSON.stringify(cache));
3099
+ mkdirSync(homeStateDir(), { recursive: true });
3100
+ writeFileSync(join(homeStateDir(), "last-update-check"), JSON.stringify(cache));
3358
3101
  } catch {
3359
3102
  }
3360
3103
  }
@@ -3502,15 +3245,6 @@ export {
3502
3245
  InvalidArgumentError,
3503
3246
  Command,
3504
3247
  Option,
3505
- workbenchConfigPath,
3506
- defaultWorkbenchStateRoot,
3507
- isPinnedWorkbenchImageReference,
3508
- loadWorkbenchConfig,
3509
- saveWorkbenchConfig,
3510
- resolveWorkbenchGuestSettings,
3511
- workbenchNetworkEnabled,
3512
- launchConfiguredWorkbench,
3513
- selectWorkbenchProfile,
3514
3248
  performAutoUpdate,
3515
3249
  runStartupUpdate
3516
3250
  };
@@ -3,7 +3,7 @@ import { createRequire as __0CreateRequire } from "node:module";
3
3
  const require = __0CreateRequire(import.meta.url);
4
4
  import {
5
5
  homeStateDir
6
- } from "./chunk-76KSBWOQ.js";
6
+ } from "./chunk-6KFB6AYN.js";
7
7
 
8
8
  // packages/core/dist/scope/waf-detect.js
9
9
  function readHeader(headers, name) {
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0CreateRequire } from "node:module";
3
+ const require = __0CreateRequire(import.meta.url);
4
+
5
+ // packages/cli/src/herdr-state.ts
6
+ var sink = null;
7
+ function setHerdrSink(next) {
8
+ sink = next;
9
+ }
10
+ function reportOperatorGate(blocked) {
11
+ if (!sink) return;
12
+ try {
13
+ if (blocked) sink.reportBlocked();
14
+ else sink.reportWorking();
15
+ } catch {
16
+ }
17
+ }
18
+ function withSink(fn) {
19
+ if (!sink) return;
20
+ try {
21
+ fn(sink);
22
+ } catch {
23
+ }
24
+ }
25
+ function reportHerdrModel(model, provider) {
26
+ withSink((s) => s.setModel(model, provider));
27
+ }
28
+ function reportHerdrContextPercent(percent) {
29
+ withSink((s) => s.setContextPercent(percent));
30
+ }
31
+ function reportHerdrTarget(target) {
32
+ withSink((s) => s.setTarget(target));
33
+ }
34
+ function reportHerdrObjective(objective) {
35
+ withSink((s) => s.setObjective(objective));
36
+ }
37
+ function reportHerdrActivity(activity) {
38
+ withSink((s) => s.setActivity(activity));
39
+ }
40
+ function reportHerdrCompaction() {
41
+ withSink((s) => s.reportCompacting());
42
+ }
43
+ function reportHerdrSession(ref) {
44
+ withSink((s) => s.reportSession(ref));
45
+ }
46
+ function reportHerdrSessionClose() {
47
+ withSink((s) => {
48
+ void s.release();
49
+ });
50
+ }
51
+
52
+ export {
53
+ setHerdrSink,
54
+ reportOperatorGate,
55
+ reportHerdrModel,
56
+ reportHerdrContextPercent,
57
+ reportHerdrTarget,
58
+ reportHerdrObjective,
59
+ reportHerdrActivity,
60
+ reportHerdrCompaction,
61
+ reportHerdrSession,
62
+ reportHerdrSessionClose
63
+ };