0sec-cli 0.22.4 → 0.24.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/0.js +73 -68
- package/README.md +95 -61
- package/chunks/{adapt-loop-3CCOWE43.js → adapt-loop-TEJPXWFG.js} +4 -4
- package/chunks/{artifact-scraper-Z4UUIOH3.js → artifact-scraper-AJZ3LOQY.js} +2 -2
- package/chunks/{assumption-mining-2UAKQB6V.js → assumption-mining-EATDC4BB.js} +18 -18
- package/chunks/backend-connections-QE4NASAK.js +23 -0
- package/chunks/chunk-3XLEDCFX.js +566 -0
- package/chunks/{chunk-BGX53365.js → chunk-3XLFB46W.js} +5 -3
- package/chunks/{chunk-IXAHQICR.js → chunk-4TUR47H5.js} +8 -3
- package/chunks/{chunk-5WAJGLCW.js → chunk-4YRXIVPZ.js} +3 -3
- package/chunks/{chunk-4ZYYX5GY.js → chunk-52AWIBCT.js} +1 -1
- package/chunks/{chunk-TO35Y326.js → chunk-554D4AYM.js} +5 -2
- package/chunks/{chunk-GQ3DGHWE.js → chunk-5FHFG5P2.js} +174 -710
- package/chunks/chunk-5POT5OYF.js +733 -0
- package/chunks/chunk-62PGWN7Y.js +700 -0
- package/chunks/{chunk-H6Q2QAIY.js → chunk-A3EKBUEM.js} +1424 -859
- package/chunks/{chunk-6WQDXWQC.js → chunk-A6AZZ6XX.js} +2 -2
- package/chunks/{chunk-6YZE552K.js → chunk-AV5BF4V7.js} +1281 -2580
- package/chunks/{chunk-2WWAPKAW.js → chunk-BIJPMYFA.js} +6 -6
- package/chunks/{chunk-SCWWLABR.js → chunk-CIMN2AO6.js} +1 -1
- package/chunks/{chunk-H4DH7COV.js → chunk-CSPF47S3.js} +30 -20
- package/chunks/{chunk-RCRTSKQN.js → chunk-DNV3ZMPX.js} +1 -1
- package/chunks/{chunk-GVY3S5E5.js → chunk-E42XEJTK.js} +2 -2
- package/chunks/{chunk-VDOWARMJ.js → chunk-ESM447R6.js} +15 -1
- package/chunks/{chunk-WBRGXCU2.js → chunk-EXTN4SQV.js} +1 -1
- package/chunks/{chunk-QVIRWJ45.js → chunk-EYBMTELO.js} +108 -24
- package/chunks/chunk-FEOPHBMY.js +56 -0
- package/chunks/{chunk-IHPTOTLL.js → chunk-FKGFHLLS.js} +1 -1
- package/chunks/chunk-G2EJ3R5I.js +5198 -0
- package/chunks/chunk-GHEBZKUS.js +5417 -0
- package/chunks/chunk-GNR3APR6.js +295 -0
- package/chunks/{chunk-ELI3BVIK.js → chunk-H76JYUPE.js} +3 -3
- package/chunks/{chunk-E74LXQFY.js → chunk-HRBOZBMC.js} +1 -1
- package/chunks/{chunk-TM74SSHC.js → chunk-IIBNQTOK.js} +3 -2
- package/chunks/{chunk-UELXHK2Y.js → chunk-IK27KMVV.js} +16 -5
- package/chunks/{chunk-WHUAUFSX.js → chunk-J6G73WYF.js} +1 -1
- package/chunks/chunk-JSTLXPJS.js +284 -0
- package/chunks/{chunk-G2BE2FC7.js → chunk-O3ADFN2A.js} +1 -1
- package/chunks/chunk-O7Q2G2KW.js +117 -0
- package/chunks/{chunk-XODDLNBI.js → chunk-QEA2VHBD.js} +284 -33
- package/chunks/{chunk-C6JPA32H.js → chunk-RBOMXUYL.js} +3 -111
- package/chunks/{chunk-L2CCO4KE.js → chunk-RCHAFSWS.js} +838 -39
- package/chunks/{chunk-3BPX75OR.js → chunk-RD4FKFWR.js} +1 -1
- package/chunks/{chunk-DPUXXMJW.js → chunk-RPTO5FY2.js} +1 -1
- package/chunks/{chunk-6KFB6AYN.js → chunk-RZR2XXAK.js} +531 -17
- package/chunks/chunk-SGILXLR3.js +289 -0
- package/chunks/{chunk-E3OOBVOK.js → chunk-TOAAYJVN.js} +2 -2
- package/chunks/chunk-TOFIGQ63.js +83 -0
- package/chunks/{chunk-QWK4R3DB.js → chunk-TTDFBFNZ.js} +6 -6
- package/chunks/chunk-TZRHWP7R.js +736 -0
- package/chunks/chunk-UHUW45S3.js +164 -0
- package/chunks/{chunk-5JNTMWPK.js → chunk-V4BD7GSP.js} +2 -2
- package/chunks/{chunk-OAS5SAVZ.js → chunk-V5I5GAQH.js} +3226 -1683
- package/chunks/{chunk-PS5E7LUQ.js → chunk-W6IYTSZH.js} +79 -9
- package/chunks/{chunk-RTBZ36BD.js → chunk-WUPN3D37.js} +22 -248
- package/chunks/{chunk-CF3MNS3O.js → chunk-Y7KV7WV6.js} +2 -2
- package/chunks/{chunk-2OQOQ2FZ.js → chunk-YERUDEXT.js} +763 -688
- package/chunks/{chunk-CPCHLL6A.js → chunk-YJU7QACE.js} +1 -1
- package/chunks/{chunk-YED25PA4.js → chunk-YORL5S5V.js} +1 -1
- package/chunks/{chunk-YAZARMJY.js → chunk-YYOQADBB.js} +4 -3
- package/chunks/chunk-ZPFBQ3SD.js +127 -0
- package/chunks/{codex-models-Z43V3427.js → codex-models-FQPCWRPC.js} +7 -7
- package/chunks/{commands-EUGF4FUZ.js → commands-I5L3VD2A.js} +6187 -12196
- package/chunks/dashboard-B2AEGCFM.js +76 -0
- package/chunks/{db-NVAW4WWR.js → db-P5EIKMLP.js} +3 -3
- package/chunks/deep-review-I7RD5QSS.js +82 -0
- package/chunks/{disclose-LDNKAVRH.js → disclose-PFBWESVJ.js} +4 -2
- package/chunks/{dist-7RUOKPRJ.js → dist-3SWWY5FZ.js} +18 -2
- package/chunks/{dist-27BNG6WD.js → dist-AJU25UXA.js} +112 -63
- package/chunks/{dist-NG2HT5XU.js → dist-VK2M4HNW.js} +85 -1
- package/chunks/eval-runner-XVRX3R2Y.js +31 -0
- package/chunks/{exploit-agent-FCCR2HYX.js → exploit-agent-A4RTIJ4J.js} +1 -1
- package/chunks/{exploit-autoclimb-X5ZS5FAO.js → exploit-autoclimb-ABMMBC3M.js} +1 -1
- package/chunks/{exploit-climb-3JHGEO36.js → exploit-climb-BQ2SVU63.js} +2 -2
- package/chunks/{fix-NSNPU33B.js → fix-4YCLHFDT.js} +7 -7
- package/chunks/{harness-KXQOVIDQ.js → harness-DHWULEIZ.js} +3 -3
- package/chunks/{hunt-scan-ELTKGKC4.js → hunt-scan-DXV5H6YN.js} +16 -16
- package/chunks/{kernel-primitive-MT7YZSIG.js → kernel-primitive-SF4NALVR.js} +2 -2
- package/chunks/{kernel-vm-runner-YFRHYC6G.js → kernel-vm-runner-WEBEZEIC.js} +2 -2
- package/chunks/local-engine-XUG7XRKM.js +21 -0
- package/chunks/managed-operation-SQFMBWHG.js +60 -0
- package/chunks/{memsafety-scan-FCPAXIZE.js → memsafety-scan-L2Z7E7TE.js} +2 -2
- package/chunks/{native-loop-OFJDRHPI.js → native-loop-ZNAELJGB.js} +14 -13
- package/chunks/orchestrate-YHFJXGID.js +63 -0
- package/chunks/{prepare-72GWTRVI.js → prepare-SODWQN6O.js} +5 -5
- package/chunks/provider-model-discovery-QGUGL3XW.js +277 -0
- package/chunks/remote-workflow-runtime-XNNGI2PG.js +12 -0
- package/chunks/{run-WTJCZZHV.js → run-5T4Z3Q2D.js} +924 -327
- package/chunks/{runtime-LCJ4XSKE.js → runtime-HFFRUOPL.js} +4 -2
- package/chunks/{runtime-FCKOUB7V.js → runtime-MB4GEFBY.js} +7 -7
- package/chunks/{scan-stream-GT6GKQ3U.js → scan-stream-GXBJHCDF.js} +3 -2
- package/chunks/{scope-E5QZUOOH.js → scope-M7L3CD6X.js} +2 -2
- package/chunks/service-plugins-BGS6QKSZ.js +64 -0
- package/chunks/{session-store-H3Q7KCYG.js → session-store-K7I4GLNH.js} +2 -2
- package/chunks/{variant-candidates-SZKDCOLK.js → variant-candidates-2KSP5EHH.js} +7 -7
- package/chunks/{web-recon-prepass-IO3GXQMW.js → web-recon-prepass-RAXXTEWH.js} +5 -5
- package/chunks/workflow-runtime-V26HIJO3.js +178 -0
- package/dashboard/assets/abnfDiagram-VCTEODGH-CGCueOp5.js +1 -0
- package/dashboard/assets/arc-BjZaQcCc.js +1 -0
- package/dashboard/assets/architecture-7GRP2DOG-hcbO-9zX.js +1 -0
- package/dashboard/assets/architectureDiagram-5GKGNRK7-DReOXTSq.js +36 -0
- package/dashboard/assets/array-BifhSqXX.js +1 -0
- package/dashboard/assets/blockDiagram-I7D4REHJ-C-byT12_.js +129 -0
- package/dashboard/assets/c4Diagram-7LVT6UL2-DoYjz-Uv.js +38 -0
- package/dashboard/assets/channel-CUURBnpZ.js +1 -0
- package/dashboard/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/dashboard/assets/chunk-4HAMMTFA-NBNp2zdt.js +62 -0
- package/dashboard/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/dashboard/assets/chunk-75Z2AOVW-BHmkuP0B.js +2 -0
- package/dashboard/assets/chunk-DU6HZSFF-DgfLNaL2.js +127 -0
- package/dashboard/assets/chunk-F27PBJKO-3wwNFUgZ.js +1 -0
- package/dashboard/assets/chunk-FOHPRMQF-DHwB1DNv.js +161 -0
- package/dashboard/assets/chunk-GMAD6QVW-Btg7huZW.js +72 -0
- package/dashboard/assets/chunk-GVQU2GXP-ihCURK5O.js +1 -0
- package/dashboard/assets/chunk-IMKFNOWR-FsXj7slg.js +231 -0
- package/dashboard/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/dashboard/assets/chunk-L3NEJ4N5-DorFIxJY.js +1 -0
- package/dashboard/assets/chunk-OSK3NFVY-DKun_KfC.js +10 -0
- package/dashboard/assets/chunk-P2QGCYS3-XGgiU1Bz.js +1 -0
- package/dashboard/assets/chunk-POPQ4Y6H-BTXEnGhJ.js +1 -0
- package/dashboard/assets/chunk-PWAF6VOD-DYZcGkTL.js +1 -0
- package/dashboard/assets/chunk-SHT3W25Y-C4WQfwf8.js +168 -0
- package/dashboard/assets/chunk-SVP7TREG-C4nCh0-1.js +88 -0
- package/dashboard/assets/chunk-TICWLB2K-DSB-IiGc.js +206 -0
- package/dashboard/assets/chunk-XXDRQBXY-CS6fjUcj.js +1 -0
- package/dashboard/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/dashboard/assets/classDiagram-ZZMXUADV-CD1Buc26.js +1 -0
- package/dashboard/assets/classDiagram-v2-VYDZK3BY-CD1Buc26.js +1 -0
- package/dashboard/assets/common-BMdQBwfR.js +5 -0
- package/dashboard/assets/cose-bilkent-JH36ORCC-CUjQHTML.js +1 -0
- package/dashboard/assets/cynefin-OW5HDTMX-BC7zCtFq.js +1 -0
- package/dashboard/assets/cynefinDiagram-5FMLGOSQ-CgDOOY67.js +62 -0
- package/dashboard/assets/cytoscape.esm-CGd-uY3x.js +321 -0
- package/dashboard/assets/dagre-GXQ25YYZ-Dqc8FS9x.js +4 -0
- package/dashboard/assets/dagre-PrKaheQc.js +1 -0
- package/dashboard/assets/defaultLocale-BFoDCU3G.js +1 -0
- package/dashboard/assets/diagram-S7CK7UJ4-CrKqRXZb.js +30 -0
- package/dashboard/assets/diagram-UQ7AKVKN-Cu6Es0-v.js +41 -0
- package/dashboard/assets/diagram-VSXAHHWV-eK4d8FwS.js +3 -0
- package/dashboard/assets/diagram-VX7I27RA-bFxeFKOc.js +24 -0
- package/dashboard/assets/diagram-Z3DM3KII-C0ClmnhC.js +24 -0
- package/dashboard/assets/dist-BZh8Kb3O.js +1 -0
- package/dashboard/assets/ebnfDiagram-PWID7BFC-CUqxFPzf.js +1 -0
- package/dashboard/assets/erDiagram-RLTQ6QDP-CcYM7pLi.js +99 -0
- package/dashboard/assets/eventmodeling-NTZA5JFV-D8ZNnPkV.js +1 -0
- package/dashboard/assets/flowDiagram-HODETNUW-pDb1AYm8.js +1 -0
- package/dashboard/assets/ganttDiagram-EL5Y4UJY-UmZfbMyD.js +292 -0
- package/dashboard/assets/gitGraph-4MIJSDKK-mvNUo0ZA.js +1 -0
- package/dashboard/assets/gitGraphDiagram-WWUBYQGX-CvzeCxVy.js +106 -0
- package/dashboard/assets/graphlib-DS17s2tU.js +1 -0
- package/dashboard/assets/info-A6RAGUB7-DChKqZMi.js +1 -0
- package/dashboard/assets/infoDiagram-27XIBGKW-DjkpNtVW.js +2 -0
- package/dashboard/assets/init-C-OQMol4.js +1 -0
- package/dashboard/assets/ishikawaDiagram-5VMMS53U-8FhjJaWT.js +70 -0
- package/dashboard/assets/journeyDiagram-3NMN7TZE-DyNJ755f.js +139 -0
- package/dashboard/assets/kanban-definition-UXKFOSKX-_jCmtaY1.js +89 -0
- package/dashboard/assets/katex-BdBmVSus.js +257 -0
- package/dashboard/assets/line-Bf0nxyWf.js +1 -0
- package/dashboard/assets/linear-Bl6JKbf4.js +1 -0
- package/dashboard/assets/mermaid-parser.core-Cc6sgCzs.js +7 -0
- package/dashboard/assets/mermaid.core-B4yCwiN-.js +44 -0
- package/dashboard/assets/mindmap-definition-YA3MSWOX-D5DjWyXj.js +96 -0
- package/dashboard/assets/operations-B7JAWOi6.js +130 -0
- package/dashboard/assets/operations-QjKT0Hwi.css +1 -0
- package/dashboard/assets/ordinal-BDEzSJ7C.js +1 -0
- package/dashboard/assets/packet-AYTQ26CC-bQXLDhQC.js +1 -0
- package/dashboard/assets/path-fybaL0A-.js +1 -0
- package/dashboard/assets/pegDiagram-XKGWAZYB-Bf6a1vaf.js +1 -0
- package/dashboard/assets/pie-WAS4IAKB-DfzoABIi.js +1 -0
- package/dashboard/assets/pieDiagram-E7YTZNPT-D0L1qbch.js +39 -0
- package/dashboard/assets/quadrantDiagram-AXDQQJYC-CbFyy2Pe.js +7 -0
- package/dashboard/assets/radar-RG4KPBEZ-CZ2pyeUT.js +1 -0
- package/dashboard/assets/railroad-74A4TZTK-CP4Jazfd.js +1 -0
- package/dashboard/assets/railroad-abnf-HS5TGJTU-3MvEiHwD.js +1 -0
- package/dashboard/assets/railroad-ebnf-LZEXJU2U-BWto6cXE.js +1 -0
- package/dashboard/assets/railroad-peg-WCYAUIDC-DasEjbyf.js +1 -0
- package/dashboard/assets/railroadDiagram-O6MQD6OU-t7Gp9g2R.js +1 -0
- package/dashboard/assets/requirementDiagram-BXWQKSXE-LYmqeBXi.js +84 -0
- package/dashboard/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/dashboard/assets/sankeyDiagram-P5KCCOFB-DnpfA_94.js +40 -0
- package/dashboard/assets/sequenceDiagram-WJ2MYXX4-C8s3pTUE.js +162 -0
- package/dashboard/assets/sizeCapture-INFHLROL-B0uUizjq.js +1 -0
- package/dashboard/assets/src-CaNUT1AQ.js +1 -0
- package/dashboard/assets/stateDiagram-D77RDMKH-BMzm6fK1.js +1 -0
- package/dashboard/assets/stateDiagram-v2-MP3YSRHH-B3REMjpY.js +1 -0
- package/dashboard/assets/swimlanes-42K2YHIH-uJE05Tt_.js +1 -0
- package/dashboard/assets/swimlanesDiagram-VR7AAH4N-CIaVMZEy.js +8 -0
- package/dashboard/assets/timeline-definition-24CTP7MA-BfLJMVeG.js +120 -0
- package/dashboard/assets/treeView-Q6P3EWNA-ZOE2enu2.js +1 -0
- package/dashboard/assets/treemap-WGGIJYW6-yIZoPBF5.js +1 -0
- package/dashboard/assets/vennDiagram-4TSXK5OY-BYJRHEaL.js +34 -0
- package/dashboard/assets/wardley-WFR3VGLG-D5V-jLbB.js +1 -0
- package/dashboard/assets/wardleyDiagram-VM6X3IG4-DgPN4nSe.js +78 -0
- package/dashboard/assets/xychartDiagram-S5SC5T6Z-BhkAMAOT.js +7 -0
- package/dashboard/index.html +3 -3
- package/package.json +3 -2
- package/worker-assets/demo-target/README.md +15 -0
- package/worker-assets/demo-target/include/decoder.h +27 -0
- package/worker-assets/demo-target/patched-decoder.c +40 -0
- package/worker-assets/demo-target/src/decoder.c +50 -0
- package/worker-assets/demo-target/witness-65537x1.bin +0 -0
- package/chunks/chunk-FFHRANYC.js +0 -547
- package/chunks/eval-runner-6Q3H52SP.js +0 -30
- package/chunks/orchestrate-DRZ2SVCP.js +0 -62
- package/chunks/service-plugins-MSK2EQP6.js +0 -62
- package/dashboard/assets/operations-BvB5Qpmk.css +0 -1
- package/dashboard/assets/operations-D8Ii01SV.js +0 -114
- package/dashboard/assets/zero-peek-Dzm3MT3X.png +0 -0
|
@@ -7,23 +7,31 @@ import {
|
|
|
7
7
|
loadGlobalSettings,
|
|
8
8
|
loadWorkbenchConfig,
|
|
9
9
|
resolveWorkbenchGuestSettings,
|
|
10
|
+
validateWorkbenchSourceLesson,
|
|
10
11
|
workbenchConfigPath,
|
|
11
12
|
workbenchNetworkEnabled
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QEA2VHBD.js";
|
|
13
14
|
import {
|
|
14
15
|
createWorkbenchProviderBroker
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-V5I5GAQH.js";
|
|
16
17
|
import {
|
|
18
|
+
HuntMemoryStore,
|
|
19
|
+
LearningService
|
|
20
|
+
} from "./chunk-A3EKBUEM.js";
|
|
21
|
+
import {
|
|
22
|
+
LearningStore,
|
|
23
|
+
learningArtifactDigest,
|
|
24
|
+
learningProjectId,
|
|
17
25
|
osecDB
|
|
18
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-RCHAFSWS.js";
|
|
19
27
|
import {
|
|
20
28
|
isAdmittedSmolvmWorkbench
|
|
21
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-BIJPMYFA.js";
|
|
22
30
|
import {
|
|
23
31
|
SERVICE_PLUGIN_CATALOG,
|
|
24
32
|
findingSchema,
|
|
25
33
|
homeStateDir
|
|
26
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-RZR2XXAK.js";
|
|
27
35
|
|
|
28
36
|
// packages/cli/src/web/service-plugins.ts
|
|
29
37
|
import { constants, closeSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeFileSync, chmodSync } from "node:fs";
|
|
@@ -32,6 +40,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
|
|
|
32
40
|
|
|
33
41
|
// packages/cli/src/console-execution.ts
|
|
34
42
|
import { existsSync, realpathSync } from "node:fs";
|
|
43
|
+
import { relative, resolve, sep } from "node:path";
|
|
35
44
|
import { randomUUID } from "node:crypto";
|
|
36
45
|
function consoleExecutionProfile(homeDir) {
|
|
37
46
|
if (process.platform === "linux" && isAdmittedSmolvmWorkbench()) return "local";
|
|
@@ -53,19 +62,80 @@ function createIsolatedConsoleSession(config, options = {}) {
|
|
|
53
62
|
const models = [.../* @__PURE__ */ new Set([model, ...Object.values(routing?.agentModels ?? {}).filter((value) => value !== "auto")])];
|
|
54
63
|
if (!runtime.workbenchCredentialResolver) throw new Error("The selected runtime cannot bind its account to the host provider broker.");
|
|
55
64
|
const broker = createWorkbenchProviderBroker({ provider, models, resolveCredentials: runtime.workbenchCredentialResolver() });
|
|
56
|
-
const { runtime: _runtime, ...guestConfig } = config;
|
|
65
|
+
const { runtime: _runtime, learningStore: hostLearningStore, huntMemoryStore: hostMemoryStore, sourceLessonHints: _hostHints, ...guestConfig } = config;
|
|
66
|
+
const learningEnabled = config.codebaseLearning === true && config.role !== "verify";
|
|
67
|
+
if (/^(1|true)$/i.test(process.env.ZERO_DISABLE_HUNT_MEMORY ?? "")) guestConfig.codebaseLearning = false;
|
|
68
|
+
let memory = hostMemoryStore;
|
|
69
|
+
const hostMemory = () => memory ??= new HuntMemoryStore({ home: options.homeDir });
|
|
70
|
+
const withLearning = (use) => {
|
|
71
|
+
const store = hostLearningStore ?? new LearningStore(options.dbPath);
|
|
72
|
+
try {
|
|
73
|
+
return use(new LearningService(store));
|
|
74
|
+
} finally {
|
|
75
|
+
if (!hostLearningStore) store.close();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const approvedWorkspace = realpathSync(workbench.workspaceRoot ?? options.workspaceRoot ?? config.workspaceRoot ?? process.cwd());
|
|
57
79
|
const scanId = config.scanId ?? `console-${randomUUID()}`;
|
|
58
80
|
try {
|
|
59
81
|
return createWorkbenchConsoleSession({
|
|
60
|
-
config: { ...guestConfig, scanId, workspaceRoot:
|
|
82
|
+
config: { ...guestConfig, scanId, workspaceRoot: approvedWorkspace },
|
|
61
83
|
workbench,
|
|
62
84
|
selection: { provider, model, contextWindowTokens: config.contextWindowTokens, ...routing },
|
|
63
85
|
provider: { ...broker.grant, request: broker.request, close: broker.close },
|
|
64
86
|
pluginHomeDir: options.homeDir,
|
|
65
|
-
assets: currentWorkbenchAssets(),
|
|
87
|
+
assets: options.assets ?? currentWorkbenchAssets(),
|
|
66
88
|
guestSettings: resolveWorkbenchGuestSettings(loadGlobalSettings(options.homeDir)),
|
|
67
89
|
network: workbenchNetworkEnabled(),
|
|
68
90
|
onExecution: options.onExecution,
|
|
91
|
+
onSourceLesson: (artifact, context) => {
|
|
92
|
+
if (!learningEnabled || /^(1|true)$/i.test(process.env.ZERO_DISABLE_HUNT_MEMORY ?? "")) return;
|
|
93
|
+
if (realpathSync(context.workspaceRoot) !== approvedWorkspace) throw new Error("Source lesson workspace differs from host grant");
|
|
94
|
+
const lesson = validateWorkbenchSourceLesson(artifact, approvedWorkspace, context.scopePath);
|
|
95
|
+
const memory2 = hostMemory();
|
|
96
|
+
const paths = lesson.sourceLinks.map((link) => relative(context.scopePath, resolve(context.workspaceRoot, link.path)).split(sep).join("/"));
|
|
97
|
+
const prior = memory2.all().find((note) => note.codebase?.root === realpathSync(context.scopePath) && note.title === lesson.title && note.summary === lesson.summary && JSON.stringify(note.codebase?.files.map((file) => ({ path: file.path, hash: file.digest }))) === JSON.stringify(lesson.sourceLinks.map((link, index) => ({ path: paths[index], hash: link.hash }))));
|
|
98
|
+
if (!prior) memory2.rememberCodebase({ root: context.scopePath, paths, title: lesson.title, summary: lesson.summary, source: `smolvm:${context.scanId}` });
|
|
99
|
+
withLearning((service) => service.importCodebaseNotes(learningProjectId(context.scopePath), context.scopePath, memory2, 8));
|
|
100
|
+
},
|
|
101
|
+
readSourceLessons: (context) => {
|
|
102
|
+
if (!learningEnabled || /^(1|true)$/i.test(process.env.ZERO_DISABLE_HUNT_MEMORY ?? "")) return [];
|
|
103
|
+
if (realpathSync(context.workspaceRoot) !== approvedWorkspace) return [];
|
|
104
|
+
const memory2 = hostMemory();
|
|
105
|
+
return withLearning((service) => {
|
|
106
|
+
const entries = service.importCodebaseNotes(learningProjectId(context.scopePath), context.scopePath, memory2, 8);
|
|
107
|
+
return memory2.recallCodebase(context.scopePath, 6).flatMap((note) => {
|
|
108
|
+
const sourceLinks = note.codebase.files.map((file) => ({ path: file.path, hash: file.digest }));
|
|
109
|
+
if (!entries.some((entry) => entry.status === "current" && entry.summary === note.summary && JSON.stringify(entry.sourceLinks) === JSON.stringify(sourceLinks))) return [];
|
|
110
|
+
const lesson = { title: note.title, summary: note.summary, sourceLinks: sourceLinks.map((link) => ({ ...link, path: relative(context.workspaceRoot, resolve(context.scopePath, link.path)).split(sep).join("/") })) };
|
|
111
|
+
try {
|
|
112
|
+
return [validateWorkbenchSourceLesson(lesson, context.workspaceRoot, context.scopePath)];
|
|
113
|
+
} catch {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
onSourceContext: (artifact, context) => {
|
|
120
|
+
if (!learningEnabled || /^(1|true)$/i.test(process.env.ZERO_DISABLE_HUNT_MEMORY ?? "")) return;
|
|
121
|
+
const store = new LearningStore(options.dbPath);
|
|
122
|
+
try {
|
|
123
|
+
const digest = learningArtifactDigest(JSON.stringify(artifact.sourceLinks));
|
|
124
|
+
store.recordExperience({
|
|
125
|
+
idempotencyKey: `vm-source:${learningArtifactDigest(context.runId + digest)}`,
|
|
126
|
+
projectId: learningProjectId(context.workspaceRoot),
|
|
127
|
+
kind: "source-context",
|
|
128
|
+
outcome: "current",
|
|
129
|
+
evidenceStrength: "hypothesis",
|
|
130
|
+
summary: "Source references retained from an isolated workspace.",
|
|
131
|
+
runId: context.runId,
|
|
132
|
+
sourceLinks: artifact.sourceLinks,
|
|
133
|
+
evidenceDigests: [digest]
|
|
134
|
+
});
|
|
135
|
+
} finally {
|
|
136
|
+
store.close();
|
|
137
|
+
}
|
|
138
|
+
},
|
|
69
139
|
onFindings: (findings, completion) => {
|
|
70
140
|
const validated = findings.map((finding) => findingSchema.parse(finding));
|
|
71
141
|
const db = new osecDB(options.dbPath);
|
|
@@ -217,7 +287,7 @@ var ServicePluginServices = class {
|
|
|
217
287
|
}
|
|
218
288
|
async #probe(connection) {
|
|
219
289
|
try {
|
|
220
|
-
const probe = this.#options.probe ?? (await import("./dist-
|
|
290
|
+
const probe = this.#options.probe ?? (await import("./dist-AJU25UXA.js")).testServicePluginConnection;
|
|
221
291
|
const result = await probe(connection);
|
|
222
292
|
if (!Array.isArray(result.tools) || result.tools.length > 512 || result.tools.some((tool) => typeof tool.name !== "string" || tool.name.length > 256 || typeof tool.description !== "string" || tool.description.length > 16384)) throw new Error("Invalid tool catalog.");
|
|
223
293
|
const configurations = [...readStore(this.#options.homeDir), connection];
|
|
@@ -1,12 +1,6 @@
|
|
|
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
|
-
loadLayeredSettings
|
|
6
|
-
} from "./chunk-XODDLNBI.js";
|
|
7
|
-
import {
|
|
8
|
-
homeStateDir
|
|
9
|
-
} from "./chunk-6KFB6AYN.js";
|
|
10
4
|
import {
|
|
11
5
|
__commonJS,
|
|
12
6
|
__require,
|
|
@@ -948,7 +942,7 @@ var require_command = __commonJS({
|
|
|
948
942
|
var childProcess = __require("node:child_process");
|
|
949
943
|
var path = __require("node:path");
|
|
950
944
|
var fs = __require("node:fs");
|
|
951
|
-
var
|
|
945
|
+
var process = __require("node:process");
|
|
952
946
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
953
947
|
var { CommanderError: CommanderError2 } = require_error();
|
|
954
948
|
var { Help: Help2 } = require_help();
|
|
@@ -994,10 +988,10 @@ var require_command = __commonJS({
|
|
|
994
988
|
this._showHelpAfterError = false;
|
|
995
989
|
this._showSuggestionAfterError = true;
|
|
996
990
|
this._outputConfiguration = {
|
|
997
|
-
writeOut: (str) =>
|
|
998
|
-
writeErr: (str) =>
|
|
999
|
-
getOutHelpWidth: () =>
|
|
1000
|
-
getErrHelpWidth: () =>
|
|
991
|
+
writeOut: (str) => process.stdout.write(str),
|
|
992
|
+
writeErr: (str) => process.stderr.write(str),
|
|
993
|
+
getOutHelpWidth: () => process.stdout.isTTY ? process.stdout.columns : void 0,
|
|
994
|
+
getErrHelpWidth: () => process.stderr.isTTY ? process.stderr.columns : void 0,
|
|
1001
995
|
outputError: (str, write) => write(str)
|
|
1002
996
|
};
|
|
1003
997
|
this._hidden = false;
|
|
@@ -1376,7 +1370,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1376
1370
|
if (this._exitCallback) {
|
|
1377
1371
|
this._exitCallback(new CommanderError2(exitCode, code, message));
|
|
1378
1372
|
}
|
|
1379
|
-
|
|
1373
|
+
process.exit(exitCode);
|
|
1380
1374
|
}
|
|
1381
1375
|
/**
|
|
1382
1376
|
* Register callback `fn` for the command.
|
|
@@ -1774,16 +1768,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1774
1768
|
}
|
|
1775
1769
|
parseOptions = parseOptions || {};
|
|
1776
1770
|
if (argv === void 0 && parseOptions.from === void 0) {
|
|
1777
|
-
if (
|
|
1771
|
+
if (process.versions?.electron) {
|
|
1778
1772
|
parseOptions.from = "electron";
|
|
1779
1773
|
}
|
|
1780
|
-
const execArgv =
|
|
1774
|
+
const execArgv = process.execArgv ?? [];
|
|
1781
1775
|
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
|
|
1782
1776
|
parseOptions.from = "eval";
|
|
1783
1777
|
}
|
|
1784
1778
|
}
|
|
1785
1779
|
if (argv === void 0) {
|
|
1786
|
-
argv =
|
|
1780
|
+
argv = process.argv;
|
|
1787
1781
|
}
|
|
1788
1782
|
this.rawArgs = argv.slice();
|
|
1789
1783
|
let userArgs;
|
|
@@ -1794,7 +1788,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1794
1788
|
userArgs = argv.slice(2);
|
|
1795
1789
|
break;
|
|
1796
1790
|
case "electron":
|
|
1797
|
-
if (
|
|
1791
|
+
if (process.defaultApp) {
|
|
1798
1792
|
this._scriptPath = argv[1];
|
|
1799
1793
|
userArgs = argv.slice(2);
|
|
1800
1794
|
} else {
|
|
@@ -1922,23 +1916,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1922
1916
|
}
|
|
1923
1917
|
launchWithNode = sourceExt.includes(path.extname(executableFile));
|
|
1924
1918
|
let proc;
|
|
1925
|
-
if (
|
|
1919
|
+
if (process.platform !== "win32") {
|
|
1926
1920
|
if (launchWithNode) {
|
|
1927
1921
|
args.unshift(executableFile);
|
|
1928
|
-
args = incrementNodeInspectorPort(
|
|
1929
|
-
proc = childProcess.spawn(
|
|
1922
|
+
args = incrementNodeInspectorPort(process.execArgv).concat(args);
|
|
1923
|
+
proc = childProcess.spawn(process.argv[0], args, { stdio: "inherit" });
|
|
1930
1924
|
} else {
|
|
1931
1925
|
proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
|
|
1932
1926
|
}
|
|
1933
1927
|
} else {
|
|
1934
1928
|
args.unshift(executableFile);
|
|
1935
|
-
args = incrementNodeInspectorPort(
|
|
1936
|
-
proc = childProcess.spawn(
|
|
1929
|
+
args = incrementNodeInspectorPort(process.execArgv).concat(args);
|
|
1930
|
+
proc = childProcess.spawn(process.execPath, args, { stdio: "inherit" });
|
|
1937
1931
|
}
|
|
1938
1932
|
if (!proc.killed) {
|
|
1939
1933
|
const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
|
|
1940
1934
|
signals.forEach((signal) => {
|
|
1941
|
-
|
|
1935
|
+
process.on(signal, () => {
|
|
1942
1936
|
if (proc.killed === false && proc.exitCode === null) {
|
|
1943
1937
|
proc.kill(signal);
|
|
1944
1938
|
}
|
|
@@ -1949,7 +1943,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1949
1943
|
proc.on("close", (code) => {
|
|
1950
1944
|
code = code ?? 1;
|
|
1951
1945
|
if (!exitCallback) {
|
|
1952
|
-
|
|
1946
|
+
process.exit(code);
|
|
1953
1947
|
} else {
|
|
1954
1948
|
exitCallback(
|
|
1955
1949
|
new CommanderError2(
|
|
@@ -1972,7 +1966,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1972
1966
|
throw new Error(`'${executableFile}' not executable`);
|
|
1973
1967
|
}
|
|
1974
1968
|
if (!exitCallback) {
|
|
1975
|
-
|
|
1969
|
+
process.exit(1);
|
|
1976
1970
|
} else {
|
|
1977
1971
|
const wrappedError = new CommanderError2(
|
|
1978
1972
|
1,
|
|
@@ -2464,13 +2458,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2464
2458
|
*/
|
|
2465
2459
|
_parseOptionsEnv() {
|
|
2466
2460
|
this.options.forEach((option) => {
|
|
2467
|
-
if (option.envVar && option.envVar in
|
|
2461
|
+
if (option.envVar && option.envVar in process.env) {
|
|
2468
2462
|
const optionKey = option.attributeName();
|
|
2469
2463
|
if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
|
|
2470
2464
|
this.getOptionValueSource(optionKey)
|
|
2471
2465
|
)) {
|
|
2472
2466
|
if (option.required || option.optional) {
|
|
2473
|
-
this.emit(`optionEnv:${option.name()}`,
|
|
2467
|
+
this.emit(`optionEnv:${option.name()}`, process.env[option.envVar]);
|
|
2474
2468
|
} else {
|
|
2475
2469
|
this.emit(`optionEnv:${option.name()}`);
|
|
2476
2470
|
}
|
|
@@ -2899,7 +2893,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2899
2893
|
*/
|
|
2900
2894
|
help(contextOptions) {
|
|
2901
2895
|
this.outputHelp(contextOptions);
|
|
2902
|
-
let exitCode =
|
|
2896
|
+
let exitCode = process.exitCode || 0;
|
|
2903
2897
|
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
2904
2898
|
exitCode = 1;
|
|
2905
2899
|
}
|
|
@@ -3023,228 +3017,8 @@ var {
|
|
|
3023
3017
|
Help
|
|
3024
3018
|
} = import_index.default;
|
|
3025
3019
|
|
|
3026
|
-
// packages/cli/src/utils/update-check.ts
|
|
3027
|
-
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
3028
|
-
import { join } from "node:path";
|
|
3029
|
-
import { spawn } from "node:child_process";
|
|
3030
|
-
var REPO = "0sec-labs/0";
|
|
3031
|
-
var INSTALL_URL = `https://raw.githubusercontent.com/${REPO}/main/install.sh`;
|
|
3032
|
-
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
3033
|
-
var FETCH_TIMEOUT_MS = 4e3;
|
|
3034
|
-
var INSTALL_TIMEOUT_MS = 12e4;
|
|
3035
|
-
function parseVersion(value) {
|
|
3036
|
-
if (value.length > 128) return null;
|
|
3037
|
-
const match = /^v?(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?)?(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(value);
|
|
3038
|
-
if (!match) return null;
|
|
3039
|
-
const parts = [Number(match[1]), Number(match[2] ?? 0), Number(match[3] ?? 0)];
|
|
3040
|
-
if (!parts.every(Number.isSafeInteger)) return null;
|
|
3041
|
-
const prerelease = match[4]?.split(".") ?? [];
|
|
3042
|
-
if (prerelease.some((part) => /^\d+$/.test(part) && part.length > 1 && part.startsWith("0"))) return null;
|
|
3043
|
-
return { parts, prerelease, complete: match[3] !== void 0 };
|
|
3044
|
-
}
|
|
3045
|
-
function compareVersions(a, b) {
|
|
3046
|
-
const left = parseVersion(a);
|
|
3047
|
-
const right = parseVersion(b);
|
|
3048
|
-
if (!left || !right) return 0;
|
|
3049
|
-
for (let i = 0; i < 3; i++) {
|
|
3050
|
-
if (left.parts[i] !== right.parts[i]) return left.parts[i] < right.parts[i] ? -1 : 1;
|
|
3051
|
-
}
|
|
3052
|
-
if (!left.prerelease.length || !right.prerelease.length) {
|
|
3053
|
-
return left.prerelease.length ? -1 : right.prerelease.length ? 1 : 0;
|
|
3054
|
-
}
|
|
3055
|
-
for (let i = 0; i < Math.max(left.prerelease.length, right.prerelease.length); i++) {
|
|
3056
|
-
const l = left.prerelease[i];
|
|
3057
|
-
const r = right.prerelease[i];
|
|
3058
|
-
if (l === void 0) return -1;
|
|
3059
|
-
if (r === void 0) return 1;
|
|
3060
|
-
if (l === r) continue;
|
|
3061
|
-
const ln = /^\d+$/.test(l);
|
|
3062
|
-
const rn = /^\d+$/.test(r);
|
|
3063
|
-
if (ln !== rn) return ln ? -1 : 1;
|
|
3064
|
-
if (ln && l.length !== r.length) return l.length < r.length ? -1 : 1;
|
|
3065
|
-
return l < r ? -1 : 1;
|
|
3066
|
-
}
|
|
3067
|
-
return 0;
|
|
3068
|
-
}
|
|
3069
|
-
function disabled(value) {
|
|
3070
|
-
return value !== void 0 && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
3071
|
-
}
|
|
3072
|
-
function shouldRunCheck(env = process.env, isTty = Boolean(process.stdout.isTTY), policy) {
|
|
3073
|
-
if (!isTty || disabled(env.CI) || disabled(env["ZERO_OFFLINE"]) || disabled(env["ZERO_NO_UPDATE_CHECK"])) return false;
|
|
3074
|
-
if (policy !== void 0) return policy !== "off";
|
|
3075
|
-
return env["ZERO_UPDATE_CHECK"] === "1";
|
|
3076
|
-
}
|
|
3077
|
-
function recent(timestamp, now) {
|
|
3078
|
-
const age = now - Date.parse(timestamp ?? "");
|
|
3079
|
-
return Number.isFinite(age) && age >= 0 && age < CHECK_INTERVAL_MS;
|
|
3080
|
-
}
|
|
3081
|
-
function readCache() {
|
|
3082
|
-
try {
|
|
3083
|
-
const raw = JSON.parse(readFileSync(join(homeStateDir(), "last-update-check"), "utf8"));
|
|
3084
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
3085
|
-
const value = raw;
|
|
3086
|
-
if (typeof value.lastCheckedAt !== "string") return null;
|
|
3087
|
-
return {
|
|
3088
|
-
lastCheckedAt: value.lastCheckedAt,
|
|
3089
|
-
latestVersion: typeof value.latestVersion === "string" ? value.latestVersion : void 0,
|
|
3090
|
-
lastInstallAttemptAt: typeof value.lastInstallAttemptAt === "string" ? value.lastInstallAttemptAt : void 0,
|
|
3091
|
-
lastInstallTag: typeof value.lastInstallTag === "string" ? value.lastInstallTag : void 0
|
|
3092
|
-
};
|
|
3093
|
-
} catch {
|
|
3094
|
-
return null;
|
|
3095
|
-
}
|
|
3096
|
-
}
|
|
3097
|
-
function writeCache(cache) {
|
|
3098
|
-
try {
|
|
3099
|
-
mkdirSync(homeStateDir(), { recursive: true });
|
|
3100
|
-
writeFileSync(join(homeStateDir(), "last-update-check"), JSON.stringify(cache));
|
|
3101
|
-
} catch {
|
|
3102
|
-
}
|
|
3103
|
-
}
|
|
3104
|
-
async function fetchLatestTag() {
|
|
3105
|
-
const controller = new AbortController();
|
|
3106
|
-
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
3107
|
-
try {
|
|
3108
|
-
const response = await fetch(`https://api.github.com/repos/${REPO}/releases/latest`, {
|
|
3109
|
-
headers: { Accept: "application/vnd.github+json", "User-Agent": "@0/cli/update-check" },
|
|
3110
|
-
signal: controller.signal
|
|
3111
|
-
});
|
|
3112
|
-
if (!response.ok) return null;
|
|
3113
|
-
const data = await response.json();
|
|
3114
|
-
if (typeof data.tag_name !== "string" || data.prerelease === true || data.draft === true) return null;
|
|
3115
|
-
const version = parseVersion(data.tag_name);
|
|
3116
|
-
return version?.complete && version.prerelease.length === 0 ? data.tag_name : null;
|
|
3117
|
-
} catch {
|
|
3118
|
-
return null;
|
|
3119
|
-
} finally {
|
|
3120
|
-
clearTimeout(timer);
|
|
3121
|
-
}
|
|
3122
|
-
}
|
|
3123
|
-
var installInProgress = false;
|
|
3124
|
-
var attemptedAutomaticTags = /* @__PURE__ */ new Set();
|
|
3125
|
-
async function performAutoUpdate(options = {}) {
|
|
3126
|
-
if (process.platform === "win32") return { success: false, installed: false, error: "Automatic installation is unavailable on Windows; download a release from https://github.com/0sec-labs/0/releases/latest." };
|
|
3127
|
-
if (disabled(process.env["ZERO_OFFLINE"]) || disabled(process.env["ZERO_NO_UPDATE_CHECK"])) {
|
|
3128
|
-
return { success: false, installed: false, error: "Updates are disabled by the current offline/update policy." };
|
|
3129
|
-
}
|
|
3130
|
-
if (installInProgress) return { success: false, installed: false, error: "An update is already in progress." };
|
|
3131
|
-
installInProgress = true;
|
|
3132
|
-
try {
|
|
3133
|
-
const tag = options.version ?? await fetchLatestTag();
|
|
3134
|
-
const version = tag ? parseVersion(tag) : null;
|
|
3135
|
-
if (!tag || !version?.complete) return { success: false, installed: false, error: "Could not resolve a valid release tag." };
|
|
3136
|
-
const normalizedTag = tag.startsWith("v") ? tag : `v${tag}`;
|
|
3137
|
-
const env = { ...process.env, RELEASE_BASE_URL: `https://github.com/${REPO}/releases/download/${normalizedTag}` };
|
|
3138
|
-
const installDir = options.installDir ?? process.env["ZERO_INSTALL_DIR"];
|
|
3139
|
-
if (installDir !== void 0) env.INSTALL_DIR = installDir;
|
|
3140
|
-
const timeoutMs = Number.isFinite(options.timeoutMs) && options.timeoutMs > 0 ? Math.min(options.timeoutMs, INSTALL_TIMEOUT_MS) : INSTALL_TIMEOUT_MS;
|
|
3141
|
-
return await new Promise((resolve) => {
|
|
3142
|
-
const child = spawn("bash", ["-o", "pipefail", "-c", `curl -fsSL --connect-timeout 10 --max-time 30 "${INSTALL_URL}" | bash`], {
|
|
3143
|
-
stdio: "inherit",
|
|
3144
|
-
env,
|
|
3145
|
-
detached: true
|
|
3146
|
-
});
|
|
3147
|
-
let timedOut = false;
|
|
3148
|
-
let settled = false;
|
|
3149
|
-
let parentSignal;
|
|
3150
|
-
let killTimer;
|
|
3151
|
-
const finish = (result) => {
|
|
3152
|
-
if (settled) return;
|
|
3153
|
-
settled = true;
|
|
3154
|
-
clearTimeout(timer);
|
|
3155
|
-
clearTimeout(killTimer);
|
|
3156
|
-
process.removeListener("SIGINT", onInterrupt);
|
|
3157
|
-
process.removeListener("SIGTERM", onTerminate);
|
|
3158
|
-
resolve(result);
|
|
3159
|
-
};
|
|
3160
|
-
const terminate = (signal) => {
|
|
3161
|
-
if (child.pid === void 0) return;
|
|
3162
|
-
try {
|
|
3163
|
-
process.kill(-child.pid, signal);
|
|
3164
|
-
} catch {
|
|
3165
|
-
}
|
|
3166
|
-
};
|
|
3167
|
-
const interrupt = (signal) => {
|
|
3168
|
-
if (parentSignal || settled) return;
|
|
3169
|
-
parentSignal = signal;
|
|
3170
|
-
clearTimeout(timer);
|
|
3171
|
-
terminate(signal);
|
|
3172
|
-
clearTimeout(killTimer);
|
|
3173
|
-
killTimer = setTimeout(() => {
|
|
3174
|
-
terminate("SIGKILL");
|
|
3175
|
-
finish({ success: false, installed: false, signal, error: `Installer stopped by ${signal}.` });
|
|
3176
|
-
}, 1e3);
|
|
3177
|
-
};
|
|
3178
|
-
const onInterrupt = () => interrupt("SIGINT");
|
|
3179
|
-
const onTerminate = () => interrupt("SIGTERM");
|
|
3180
|
-
const timer = setTimeout(() => {
|
|
3181
|
-
timedOut = true;
|
|
3182
|
-
terminate("SIGTERM");
|
|
3183
|
-
killTimer = setTimeout(() => {
|
|
3184
|
-
terminate("SIGKILL");
|
|
3185
|
-
finish({ success: false, installed: false, exitCode: 1, error: `Installer exceeded its ${timeoutMs}ms deadline.` });
|
|
3186
|
-
}, 1e3);
|
|
3187
|
-
}, timeoutMs);
|
|
3188
|
-
process.on("SIGINT", onInterrupt);
|
|
3189
|
-
process.on("SIGTERM", onTerminate);
|
|
3190
|
-
child.once("error", (error) => finish({ success: false, installed: false, exitCode: 1, error: `Could not start the installer: ${error.message}. Ensure bash and curl are available.` }));
|
|
3191
|
-
child.once("close", (code, signal) => {
|
|
3192
|
-
if (timedOut || parentSignal) return;
|
|
3193
|
-
if (signal) finish({ success: false, installed: false, signal, error: `Installer stopped by ${signal}.` });
|
|
3194
|
-
else if (code === 0) finish({ success: true, installed: true, installedVersion: normalizedTag, exitCode: 0 });
|
|
3195
|
-
else finish({ success: false, installed: false, exitCode: code ?? 1, error: `Installer exited with code ${code ?? 1}.` });
|
|
3196
|
-
});
|
|
3197
|
-
});
|
|
3198
|
-
} catch (error) {
|
|
3199
|
-
return { success: false, installed: false, exitCode: 1, error: error instanceof Error ? error.message : "Update failed." };
|
|
3200
|
-
} finally {
|
|
3201
|
-
installInProgress = false;
|
|
3202
|
-
}
|
|
3203
|
-
}
|
|
3204
|
-
async function maybeNotifyUpdate(currentVersion, options = {}) {
|
|
3205
|
-
const policy = options.policy;
|
|
3206
|
-
if (!shouldRunCheck(process.env, Boolean(process.stdout.isTTY), policy) || !parseVersion(currentVersion)) return;
|
|
3207
|
-
const now = Date.now();
|
|
3208
|
-
let cache = readCache();
|
|
3209
|
-
if (!cache || !recent(cache.lastCheckedAt, now)) {
|
|
3210
|
-
const tag2 = await fetchLatestTag();
|
|
3211
|
-
cache = { ...cache, lastCheckedAt: new Date(now).toISOString(), latestVersion: tag2 ?? cache?.latestVersion };
|
|
3212
|
-
writeCache(cache);
|
|
3213
|
-
}
|
|
3214
|
-
const tag = cache.latestVersion;
|
|
3215
|
-
const candidate = tag ? parseVersion(tag) : null;
|
|
3216
|
-
if (!tag || !candidate?.complete || candidate.prerelease.length > 0 || compareVersions(tag, currentVersion) <= 0) return;
|
|
3217
|
-
if (policy !== "automatic") {
|
|
3218
|
-
process.stderr.write(`[0] Update available: ${currentVersion} \u2192 ${tag}. Run 0 upgrade.
|
|
3219
|
-
`);
|
|
3220
|
-
return;
|
|
3221
|
-
}
|
|
3222
|
-
if (attemptedAutomaticTags.has(tag) || cache.lastInstallTag === tag && recent(cache.lastInstallAttemptAt, now)) return;
|
|
3223
|
-
attemptedAutomaticTags.add(tag);
|
|
3224
|
-
writeCache({ ...cache, lastInstallTag: tag, lastInstallAttemptAt: new Date(now).toISOString() });
|
|
3225
|
-
process.stderr.write(`[0] Updating to ${tag} before starting the console\u2026
|
|
3226
|
-
`);
|
|
3227
|
-
const result = await performAutoUpdate({ version: tag });
|
|
3228
|
-
if (result.signal) {
|
|
3229
|
-
process.kill(process.pid, result.signal);
|
|
3230
|
-
return;
|
|
3231
|
-
}
|
|
3232
|
-
process.stderr.write(result.success ? `[0] Installed ${result.installedVersion}. This process is still ${currentVersion}; restart to use the update.
|
|
3233
|
-
` : `[0] Update not installed: ${result.error ?? "unknown error"} Continuing with ${currentVersion}.
|
|
3234
|
-
`);
|
|
3235
|
-
}
|
|
3236
|
-
async function runStartupUpdate(version) {
|
|
3237
|
-
if (!shouldRunCheck(process.env, Boolean(process.stdout.isTTY), "notify")) return;
|
|
3238
|
-
const { settings, sources } = loadLayeredSettings();
|
|
3239
|
-
const policy = sources.updatePolicy === "global" ? settings.updatePolicy : void 0;
|
|
3240
|
-
if (policy === "automatic") await maybeNotifyUpdate(version, { policy });
|
|
3241
|
-
else if (policy !== "off") void maybeNotifyUpdate(version, { policy });
|
|
3242
|
-
}
|
|
3243
|
-
|
|
3244
3020
|
export {
|
|
3245
3021
|
InvalidArgumentError,
|
|
3246
3022
|
Command,
|
|
3247
|
-
Option
|
|
3248
|
-
performAutoUpdate,
|
|
3249
|
-
runStartupUpdate
|
|
3023
|
+
Option
|
|
3250
3024
|
};
|
|
@@ -3,10 +3,10 @@ import { createRequire as __0CreateRequire } from "node:module";
|
|
|
3
3
|
const require = __0CreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
isAdmittedSmolvmWorkbench
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BIJPMYFA.js";
|
|
7
7
|
import {
|
|
8
8
|
isScopeEnforcementEnabled
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RBOMXUYL.js";
|
|
10
10
|
import {
|
|
11
11
|
external_exports
|
|
12
12
|
} from "./chunk-VIT5ALXF.js";
|