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.
Files changed (107) hide show
  1. package/0.js +56 -45
  2. package/README.md +12 -0
  3. package/chunks/{adapt-loop-J6QCZZTB.js → adapt-loop-3CCOWE43.js} +4 -4
  4. package/chunks/{artifact-scraper-MFKT6OI4.js → artifact-scraper-Z4UUIOH3.js} +2 -2
  5. package/chunks/{assumption-mining-646LYSJY.js → assumption-mining-2UAKQB6V.js} +18 -14
  6. package/chunks/{chunk-OHHCGDJ2.js → chunk-2WWAPKAW.js} +126 -1089
  7. package/chunks/{chunk-XDKB2P5X.js → chunk-3BPX75OR.js} +1 -1
  8. package/chunks/chunk-4ZYYX5GY.js +74 -0
  9. package/chunks/{chunk-3E2KALZ5.js → chunk-5JNTMWPK.js} +2 -2
  10. package/chunks/{chunk-CPWA6RWE.js → chunk-5WAJGLCW.js} +3 -3
  11. package/chunks/{chunk-KAU6NLGP.js → chunk-6KFB6AYN.js} +515 -20
  12. package/chunks/{chunk-XA2O4WXA.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-X7LAEEUW.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-ZKQ2I3S2.js → chunk-DPUXXMJW.js} +1 -1
  19. package/chunks/{chunk-XCISCI4T.js → chunk-E3OOBVOK.js} +30 -12
  20. package/chunks/{chunk-4G7OVYJX.js → chunk-E74LXQFY.js} +1 -1
  21. package/chunks/{chunk-OSBPGWTE.js → chunk-ELI3BVIK.js} +3 -3
  22. package/chunks/chunk-FFHRANYC.js +547 -0
  23. package/chunks/{chunk-WSDDGFA6.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-5BTJMINS.js → chunk-H4DH7COV.js} +192 -40
  27. package/chunks/{chunk-HHPWRY2M.js → chunk-H6Q2QAIY.js} +23475 -22747
  28. package/chunks/{chunk-7XCKYNLO.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-VWITLWXB.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-LGCASF2C.js → chunk-OAS5SAVZ.js} +6767 -2100
  35. package/chunks/chunk-PS5E7LUQ.js +277 -0
  36. package/chunks/{chunk-AV2LG2L7.js → chunk-QVIRWJ45.js} +257 -145
  37. package/chunks/{chunk-TV27OWIW.js → chunk-QWK4R3DB.js} +9 -9
  38. package/chunks/{chunk-WZRVS7SB.js → chunk-RCRTSKQN.js} +1 -1
  39. package/chunks/chunk-RS4MAN3Q.js +73 -0
  40. package/chunks/{chunk-V6GHX34G.js → chunk-RTBZ36BD.js} +8 -274
  41. package/chunks/{chunk-YL6YAGLL.js → chunk-SCWWLABR.js} +1 -1
  42. package/chunks/chunk-VDOWARMJ.js +63 -0
  43. package/chunks/{chunk-IFME676H.js → chunk-WBRGXCU2.js} +79 -18
  44. package/chunks/{chunk-IVQV574Y.js → chunk-WHUAUFSX.js} +1 -1
  45. package/chunks/{chunk-GOEA3NW6.js → chunk-XODDLNBI.js} +1534 -1305
  46. package/chunks/chunk-YAZARMJY.js +355 -0
  47. package/chunks/{chunk-NLH4LMWH.js → chunk-YED25PA4.js} +1 -1
  48. package/chunks/{codex-models-NHQW45SO.js → codex-models-Z43V3427.js} +9 -3
  49. package/chunks/{commands-N6GN5SBF.js → commands-EUGF4FUZ.js} +5842 -4093
  50. package/chunks/{db-5IWEJUYV.js → db-NVAW4WWR.js} +3 -3
  51. package/chunks/{dist-L3XJWWZ6.js → dist-27BNG6WD.js} +193 -112
  52. package/chunks/{dist-FSS7MBDF.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-BS4CY4RG.js → dist-NG2HT5XU.js} +27 -1
  56. package/chunks/{eval-runner-EMEGF24P.js → eval-runner-6Q3H52SP.js} +13 -9
  57. package/chunks/{exploit-agent-KW4EB7BE.js → exploit-agent-FCCR2HYX.js} +1 -1
  58. package/chunks/{exploit-autoclimb-CXJ2ERRO.js → exploit-autoclimb-X5ZS5FAO.js} +1 -1
  59. package/chunks/{exploit-climb-TJWLY4XC.js → exploit-climb-3JHGEO36.js} +2 -2
  60. package/chunks/{fix-UUKPXCFB.js → fix-NSNPU33B.js} +12 -6
  61. package/chunks/{harness-C5HOKIEV.js → harness-KXQOVIDQ.js} +3 -3
  62. package/chunks/{hunt-scan-KZZ444V2.js → hunt-scan-ELTKGKC4.js} +16 -12
  63. package/chunks/{kernel-primitive-Z77IR7YS.js → kernel-primitive-MT7YZSIG.js} +2 -2
  64. package/chunks/{kernel-vm-runner-JW77P276.js → kernel-vm-runner-YFRHYC6G.js} +2 -2
  65. package/chunks/{native-loop-P6P5GYVJ.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-GAFKBCTN.js → run-WTJCZZHV.js} +1901 -4816
  70. package/chunks/{runtime-H7YBR5IZ.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-QWY4VQZ7.js → scope-E5QZUOOH.js} +2 -2
  74. package/chunks/service-plugins-MSK2EQP6.js +62 -0
  75. package/chunks/{session-store-XIDFGG7K.js → session-store-H3Q7KCYG.js} +6 -4
  76. package/chunks/{variant-candidates-7D4F5E4H.js → variant-candidates-SZKDCOLK.js} +9 -3
  77. package/chunks/{web-recon-prepass-VXXBPDAV.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-BCSRRQG5.js +0 -3514
  88. package/chunks/chunk-BOUGKEKA.js +0 -193
  89. package/chunks/chunk-GHWODZMR.js +0 -16
  90. package/chunks/orchestrate-DWWUT5RC.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
@@ -0,0 +1,547 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __0CreateRequire } from "node:module";
3
+ const require = __0CreateRequire(import.meta.url);
4
+ import {
5
+ SETTING_DEFS,
6
+ isOperatorSetting,
7
+ loadGlobalSettings,
8
+ loadLayeredSettings,
9
+ normalizeSettings,
10
+ projectSettingsExist,
11
+ readProjectOverrides,
12
+ resolveLayeredSettings,
13
+ saveProjectOverrides,
14
+ saveSettings
15
+ } from "./chunk-XODDLNBI.js";
16
+ import {
17
+ expandHomePath,
18
+ isExistingLocalTargetPath,
19
+ isExplicitLocalTargetPath
20
+ } from "./chunk-GVY3S5E5.js";
21
+ import {
22
+ ANALYTICS_LEVEL_ENV,
23
+ analyticsOptedOut,
24
+ analyticsPipeline,
25
+ levelAtLeast,
26
+ resolveAnalyticsLevel
27
+ } from "./chunk-2WWAPKAW.js";
28
+ import {
29
+ createPresentationEvent
30
+ } from "./chunk-6KFB6AYN.js";
31
+
32
+ // packages/cli/src/tui/settings-store.ts
33
+ import { useSyncExternalStore } from "react";
34
+ var cached = null;
35
+ var globalDraft = null;
36
+ var projectDraft = null;
37
+ var homeDir;
38
+ var projectDir;
39
+ var subscribers = /* @__PURE__ */ new Set();
40
+ function notify(settings) {
41
+ bridgeAnalyticsLevel(settings);
42
+ for (const fn of [...subscribers]) {
43
+ try {
44
+ fn(settings);
45
+ } catch {
46
+ }
47
+ }
48
+ }
49
+ function loadLayered() {
50
+ return globalDraft === null && projectDraft === null ? loadLayeredSettings({ homeDir, projectDir }) : resolveLayeredSettings(globalDraft ?? loadGlobalSettings(homeDir), projectDraft ?? readProjectOverrides(projectDir));
51
+ }
52
+ function getSettings() {
53
+ if (cached === null) {
54
+ cached = loadLayered();
55
+ bridgeAnalyticsLevel(cached.settings);
56
+ }
57
+ return cached.settings;
58
+ }
59
+ function getSettingSources() {
60
+ getSettings();
61
+ return cached.sources;
62
+ }
63
+ function getAnalyticsSetupDraft() {
64
+ const settings = getSettings();
65
+ const current = process.env[ANALYTICS_LEVEL_ENV];
66
+ const shellPreference = current !== void 0 && current !== bridgedAnalyticsEnv;
67
+ if (analyticsOptedOut() || shellPreference && resolveAnalyticsLevel() === "off") return "off";
68
+ return cached.sources.analyticsLevel === "default" ? "usage" : settings.analyticsLevel;
69
+ }
70
+ function setSettings(next) {
71
+ const value = normalizeSettings(next);
72
+ const saved = saveSettings(value, homeDir);
73
+ globalDraft = saved ? null : value;
74
+ cached = loadLayered();
75
+ notify(cached.settings);
76
+ return saved;
77
+ }
78
+ function defaultWriteLayer() {
79
+ return projectSettingsExist(projectDir) ? "project" : "global";
80
+ }
81
+ function updateSetting(key, value, opts = {}) {
82
+ const operatorOnly = isOperatorSetting(key);
83
+ if (operatorOnly && opts.scope === "project") return false;
84
+ const layer = operatorOnly ? "global" : opts.scope ?? defaultWriteLayer();
85
+ if (layer === "global") {
86
+ return setSettings({ ...globalDraft ?? loadGlobalSettings(homeDir), [key]: value });
87
+ }
88
+ const patch = { ...projectDraft ?? readProjectOverrides(projectDir), [key]: value };
89
+ const saved = saveProjectOverrides(patch, projectDir);
90
+ projectDraft = saved ? null : patch;
91
+ cached = loadLayered();
92
+ notify(cached.settings);
93
+ return saved;
94
+ }
95
+ function resetSettings(next, keys) {
96
+ const selected = keys.filter((key) => SETTING_DEFS.some((def) => def.key === key));
97
+ if (selected.length === 0) return true;
98
+ const global = { ...globalDraft ?? loadGlobalSettings(homeDir) };
99
+ const project = { ...projectDraft ?? readProjectOverrides(projectDir) };
100
+ let projectChanged = false;
101
+ for (const key of selected) {
102
+ global[key] = next[key];
103
+ if (Object.hasOwn(project, key)) {
104
+ delete project[key];
105
+ projectChanged = true;
106
+ }
107
+ }
108
+ const value = normalizeSettings(global);
109
+ const globalSaved = saveSettings(value, homeDir);
110
+ globalDraft = globalSaved ? null : value;
111
+ const projectSaved = !projectChanged || saveProjectOverrides(project, projectDir);
112
+ if (projectChanged) projectDraft = projectSaved ? null : project;
113
+ cached = loadLayered();
114
+ notify(cached.settings);
115
+ return globalSaved && projectSaved;
116
+ }
117
+ function previewSetting(key, value) {
118
+ if (cached === null) cached = loadLayered();
119
+ cached = { settings: { ...cached.settings, [key]: value }, sources: cached.sources };
120
+ notify(cached.settings);
121
+ }
122
+ function subscribeSettings(fn) {
123
+ subscribers.add(fn);
124
+ return () => {
125
+ subscribers.delete(fn);
126
+ };
127
+ }
128
+ var bridgedAnalyticsEnv;
129
+ function bridgeAnalyticsLevel(settings) {
130
+ try {
131
+ const current = process.env[ANALYTICS_LEVEL_ENV];
132
+ if (current === void 0 || current === bridgedAnalyticsEnv) {
133
+ process.env[ANALYTICS_LEVEL_ENV] = settings.analyticsLevel;
134
+ bridgedAnalyticsEnv = settings.analyticsLevel;
135
+ } else {
136
+ bridgedAnalyticsEnv = void 0;
137
+ }
138
+ const environmentLevel = resolveAnalyticsLevel();
139
+ analyticsPipeline.setLevel(levelAtLeast(environmentLevel, settings.analyticsLevel) ? settings.analyticsLevel : environmentLevel);
140
+ } catch {
141
+ }
142
+ }
143
+ function reloadSettings() {
144
+ globalDraft = null;
145
+ projectDraft = null;
146
+ cached = loadLayered();
147
+ notify(cached.settings);
148
+ return cached.settings;
149
+ }
150
+ function configureSettingsStore(options) {
151
+ homeDir = options.homeDir;
152
+ projectDir = options.projectDir;
153
+ reloadSettings();
154
+ }
155
+ function useSettings() {
156
+ return useSyncExternalStore(subscribeSettings, getSettings, getSettings);
157
+ }
158
+
159
+ // packages/cli/src/codex-auth.ts
160
+ import { readFileSync, existsSync } from "node:fs";
161
+ import { homedir } from "node:os";
162
+ import { join } from "node:path";
163
+ var AUTH_FILE_ENV = "ZERO_CHATGPT_AUTH_FILE";
164
+ var LEGACY_AUTH_FILE_ENV = "ZERO_CODEX_AUTH_JSON_PATH";
165
+ function maybeLoadCodexAuth(options = {}) {
166
+ const env = options.env ?? process.env;
167
+ if (!options.force && (env["ZERO_CHATGPT_ACCESS_TOKEN"] || env["ZERO_CHATGPT_OAUTH_REFRESH_TOKEN"])) {
168
+ return;
169
+ }
170
+ const home = options.home ?? homedir();
171
+ const override = nonEmpty(env[AUTH_FILE_ENV]) ?? nonEmpty(env[LEGACY_AUTH_FILE_ENV]);
172
+ const path = override ?? join(home, ".codex", "auth.json");
173
+ if (!existsSync(path)) return;
174
+ try {
175
+ const raw = JSON.parse(readFileSync(path, "utf8"));
176
+ const accessToken = nonEmpty(asString(raw.tokens?.access_token));
177
+ const refreshToken = nonEmpty(asString(raw.tokens?.refresh_token));
178
+ if (!accessToken && !refreshToken) return;
179
+ if (options.force) {
180
+ delete env["ZERO_CHATGPT_ACCESS_TOKEN"];
181
+ delete env["ZERO_CHATGPT_OAUTH_REFRESH_TOKEN"];
182
+ }
183
+ if (accessToken) {
184
+ env["ZERO_CHATGPT_ACCESS_TOKEN"] = accessToken;
185
+ }
186
+ if (refreshToken) {
187
+ env["ZERO_CHATGPT_OAUTH_REFRESH_TOKEN"] = refreshToken;
188
+ }
189
+ } catch {
190
+ }
191
+ }
192
+ function nonEmpty(value) {
193
+ return typeof value === "string" && value.length > 0 ? value : void 0;
194
+ }
195
+ function asString(value) {
196
+ return typeof value === "string" ? value : void 0;
197
+ }
198
+
199
+ // packages/cli/src/presentation/event-bus.ts
200
+ var PresentationEventBus = class {
201
+ listeners = [];
202
+ subscribe(listener) {
203
+ this.listeners.push(listener);
204
+ return () => {
205
+ const index = this.listeners.indexOf(listener);
206
+ if (index >= 0) this.listeners.splice(index, 1);
207
+ };
208
+ }
209
+ emit(event) {
210
+ for (const listener of [...this.listeners]) {
211
+ try {
212
+ listener.emit(event);
213
+ } catch {
214
+ }
215
+ }
216
+ }
217
+ get size() {
218
+ return this.listeners.length;
219
+ }
220
+ };
221
+ var presentationEventBus = new PresentationEventBus();
222
+ function createPresentationEmitter(options = {}) {
223
+ const source = options.source ?? "cli";
224
+ const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
225
+ const bus = options.bus ?? presentationEventBus;
226
+ let sequence = 0;
227
+ return {
228
+ emit(eventType, payload, correlation = {}) {
229
+ const event = createPresentationEvent({
230
+ source,
231
+ sequence: ++sequence,
232
+ at: now(),
233
+ eventType,
234
+ payload,
235
+ ...correlation.scanId ? { scanId: correlation.scanId } : {},
236
+ ...correlation.sessionId ? { sessionId: correlation.sessionId } : {}
237
+ });
238
+ bus.emit(event);
239
+ return event;
240
+ }
241
+ };
242
+ }
243
+
244
+ // packages/cli/src/presentation/process-output.ts
245
+ import { format } from "node:util";
246
+ var streamBridgeSuppressionDepth = 0;
247
+ var activeStreamBridge = null;
248
+ function currentPresentationTimestamp() {
249
+ return (/* @__PURE__ */ new Date()).toISOString();
250
+ }
251
+ function createProcessPresentationOutput(options = {}) {
252
+ const stdout = options.stdout ?? { write: process.stdout.write.bind(process.stdout) };
253
+ const stderr = options.stderr ?? { write: process.stderr.write.bind(process.stderr) };
254
+ const source = options.source ?? "cli";
255
+ const now = options.now ?? currentPresentationTimestamp;
256
+ let sequence = 0;
257
+ const write = (channel, target, text, eventType) => {
258
+ const event = createPresentationEvent({
259
+ source,
260
+ sequence: ++sequence,
261
+ at: now(),
262
+ eventType,
263
+ payload: { channel, text }
264
+ });
265
+ streamBridgeSuppressionDepth += 1;
266
+ try {
267
+ target.write(text);
268
+ } finally {
269
+ streamBridgeSuppressionDepth -= 1;
270
+ }
271
+ options.onEvent?.(event);
272
+ return event;
273
+ };
274
+ return {
275
+ stdout(text, eventType = "output.stdout") {
276
+ return write("stdout", stdout, text, eventType);
277
+ },
278
+ stderr(text, eventType = "output.stderr") {
279
+ return write("stderr", stderr, text, eventType);
280
+ }
281
+ };
282
+ }
283
+ function createConsolePresentationOutput(options = {}) {
284
+ const source = options.source ?? "cli";
285
+ const now = options.now ?? currentPresentationTimestamp;
286
+ let sequence = 0;
287
+ const emit = (channel, text, eventType) => {
288
+ const event = createPresentationEvent({
289
+ source,
290
+ sequence: ++sequence,
291
+ at: now(),
292
+ eventType,
293
+ payload: { channel, text }
294
+ });
295
+ streamBridgeSuppressionDepth += 1;
296
+ try {
297
+ if (channel === "stdout") {
298
+ (options.log ?? console.log)(text);
299
+ } else {
300
+ (options.error ?? console.error)(text);
301
+ }
302
+ } finally {
303
+ streamBridgeSuppressionDepth -= 1;
304
+ }
305
+ options.onEvent?.(event);
306
+ return event;
307
+ };
308
+ return {
309
+ stdout(text, eventType = "output.stdout") {
310
+ return emit("stdout", text, eventType);
311
+ },
312
+ stderr(text, eventType = "output.stderr") {
313
+ return emit("stderr", text, eventType);
314
+ }
315
+ };
316
+ }
317
+ var consolePresentationOutput = createConsolePresentationOutput({
318
+ onEvent(event) {
319
+ presentationEventBus.emit(event);
320
+ }
321
+ });
322
+ function installConsolePresentationBridge(options = {}) {
323
+ const target = options.target ?? console;
324
+ const originals = {
325
+ log: target.log,
326
+ info: target.info,
327
+ warn: target.warn,
328
+ error: target.error
329
+ };
330
+ const source = options.source ?? "cli";
331
+ const now = options.now ?? currentPresentationTimestamp;
332
+ let sequence = 0;
333
+ const emit = (method, channel, args, eventType) => {
334
+ const text = format(...args);
335
+ if (streamBridgeSuppressionDepth > 0) {
336
+ originals[method].call(target, text);
337
+ return;
338
+ }
339
+ const event = createPresentationEvent({
340
+ source,
341
+ sequence: ++sequence,
342
+ at: now(),
343
+ eventType,
344
+ payload: { channel, text }
345
+ });
346
+ streamBridgeSuppressionDepth += 1;
347
+ try {
348
+ originals[method].call(target, text);
349
+ } finally {
350
+ streamBridgeSuppressionDepth -= 1;
351
+ }
352
+ presentationEventBus.emit(event);
353
+ options.onEvent?.(event);
354
+ };
355
+ const bridgedLog = (...args) => emit("log", "stdout", args, "output.console.log");
356
+ const bridgedInfo = (...args) => emit("info", "stdout", args, "output.console.info");
357
+ const bridgedWarn = (...args) => emit("warn", "stderr", args, "output.console.warn");
358
+ const bridgedError = (...args) => emit("error", "stderr", args, "output.console.error");
359
+ target.log = bridgedLog;
360
+ target.info = bridgedInfo;
361
+ target.warn = bridgedWarn;
362
+ target.error = bridgedError;
363
+ return {
364
+ restore() {
365
+ if (target.log === bridgedLog) target.log = originals.log;
366
+ if (target.info === bridgedInfo) target.info = originals.info;
367
+ if (target.warn === bridgedWarn) target.warn = originals.warn;
368
+ if (target.error === bridgedError) target.error = originals.error;
369
+ }
370
+ };
371
+ }
372
+ function installProcessPresentationStreamBridge(options = {}) {
373
+ if (activeStreamBridge) return activeStreamBridge;
374
+ const source = options.source ?? "cli";
375
+ const now = options.now ?? currentPresentationTimestamp;
376
+ let sequence = 0;
377
+ let suspended = false;
378
+ const streams = [];
379
+ const emit = (channel, chunk, encoding) => {
380
+ const text = typeof chunk === "string" ? chunk : chunk instanceof Uint8Array ? Buffer.from(chunk).toString(typeof encoding === "string" ? encoding : "utf8") : String(chunk ?? "");
381
+ if (channel === "stdout" && text.startsWith("ZERO_EVENT_")) return;
382
+ const event = createPresentationEvent({
383
+ source,
384
+ sequence: ++sequence,
385
+ at: now(),
386
+ eventType: channel === "stdout" ? "output.stream.stdout" : "output.stream.stderr",
387
+ payload: { channel, text }
388
+ });
389
+ presentationEventBus.emit(event);
390
+ options.onEvent?.(event);
391
+ };
392
+ for (const [channel, stream] of [
393
+ ["stdout", options.stdout ?? process.stdout],
394
+ ["stderr", options.stderr ?? process.stderr]
395
+ ]) {
396
+ const original = stream.write;
397
+ const patched = ((chunk, encoding, callback) => {
398
+ const result = original.call(stream, chunk, encoding, callback);
399
+ if (!suspended && streamBridgeSuppressionDepth === 0) emit(channel, chunk, encoding);
400
+ return result;
401
+ });
402
+ streams.push({ channel, stream, original, patched });
403
+ }
404
+ const bridge = {
405
+ suspend() {
406
+ if (suspended) return;
407
+ suspended = true;
408
+ for (const item of streams) {
409
+ if (item.stream.write === item.patched) item.stream.write = item.original;
410
+ }
411
+ },
412
+ resume() {
413
+ if (!suspended) return;
414
+ suspended = false;
415
+ for (const item of streams) {
416
+ if (item.stream.write === item.original) item.stream.write = item.patched;
417
+ }
418
+ },
419
+ restore() {
420
+ for (const item of streams) {
421
+ if (item.stream.write === item.patched) item.stream.write = item.original;
422
+ }
423
+ if (activeStreamBridge === bridge) activeStreamBridge = null;
424
+ }
425
+ };
426
+ for (const item of streams) item.stream.write = item.patched;
427
+ activeStreamBridge = bridge;
428
+ return bridge;
429
+ }
430
+ function suspendProcessPresentationStreamBridge() {
431
+ activeStreamBridge?.suspend();
432
+ }
433
+ function resumeProcessPresentationStreamBridge() {
434
+ activeStreamBridge?.resume();
435
+ }
436
+ var processPresentationOutput = createProcessPresentationOutput({
437
+ onEvent(event) {
438
+ presentationEventBus.emit(event);
439
+ }
440
+ });
441
+ function writePresentationLine(text, eventType = "output.stdout") {
442
+ return processPresentationOutput.stdout(`${text}
443
+ `, eventType);
444
+ }
445
+
446
+ // packages/cli/src/engagement-plan.ts
447
+ var PACKAGE_PREFIXES = {
448
+ "npm:": { ecosystem: "npm", targetType: "npm-package" },
449
+ "pypi:": { ecosystem: "pypi", targetType: "pypi-package" },
450
+ "cargo:": { ecosystem: "cargo", targetType: "cargo-package" },
451
+ "oci:": { ecosystem: "oci", targetType: "oci-image" }
452
+ };
453
+ function resolveEngagement(rawTarget) {
454
+ const raw = rawTarget.trim();
455
+ if (raw.length === 0) return { ok: false, message: "Enter a URL, source path, git URL, or ecosystem-prefixed package." };
456
+ for (const [prefix, packagePlan] of Object.entries(PACKAGE_PREFIXES)) {
457
+ if (!raw.startsWith(prefix)) continue;
458
+ const target = raw.slice(prefix.length).trim();
459
+ if (target.length === 0) return { ok: false, message: `${prefix} requires a package name.` };
460
+ return {
461
+ ok: true,
462
+ plan: {
463
+ kind: "package",
464
+ target,
465
+ targetType: packagePlan.targetType,
466
+ ecosystem: packagePlan.ecosystem,
467
+ label: `${packagePlan.ecosystem} package ${target}`
468
+ }
469
+ };
470
+ }
471
+ if (raw.startsWith("source:")) {
472
+ const target = raw.slice("source:".length).trim();
473
+ if (target.length === 0) return { ok: false, message: "source: requires a local path or git URL." };
474
+ return {
475
+ ok: true,
476
+ plan: {
477
+ kind: "source",
478
+ target: expandHomePath(target),
479
+ targetType: "source-code",
480
+ label: `source review ${target}`
481
+ }
482
+ };
483
+ }
484
+ if (raw.startsWith("git@") || raw.startsWith("git://") || raw.endsWith(".git") || raw.startsWith("https://github.com/")) {
485
+ return {
486
+ ok: true,
487
+ plan: {
488
+ kind: "source",
489
+ target: raw,
490
+ targetType: "source-code",
491
+ label: `source review ${raw}`
492
+ }
493
+ };
494
+ }
495
+ if (raw.startsWith("mcp://") || raw.startsWith("http://") || raw.startsWith("https://")) {
496
+ return {
497
+ ok: true,
498
+ plan: {
499
+ kind: "web",
500
+ target: raw,
501
+ targetType: "url",
502
+ label: `web target ${raw}`
503
+ }
504
+ };
505
+ }
506
+ if (isExplicitLocalTargetPath(raw) || isExistingLocalTargetPath(raw)) {
507
+ const target = expandHomePath(raw);
508
+ return {
509
+ ok: true,
510
+ plan: {
511
+ kind: "source",
512
+ target,
513
+ targetType: "source-code",
514
+ label: `source review ${target}`
515
+ }
516
+ };
517
+ }
518
+ return {
519
+ ok: false,
520
+ message: "Ambiguous target. Use https://\u2026, ./path, source:\u2026, npm:\u2026, pypi:\u2026, cargo:\u2026, or oci:\u2026."
521
+ };
522
+ }
523
+
524
+ export {
525
+ getSettings,
526
+ getSettingSources,
527
+ getAnalyticsSetupDraft,
528
+ defaultWriteLayer,
529
+ updateSetting,
530
+ resetSettings,
531
+ previewSetting,
532
+ subscribeSettings,
533
+ reloadSettings,
534
+ configureSettingsStore,
535
+ useSettings,
536
+ maybeLoadCodexAuth,
537
+ presentationEventBus,
538
+ createPresentationEmitter,
539
+ consolePresentationOutput,
540
+ installConsolePresentationBridge,
541
+ installProcessPresentationStreamBridge,
542
+ suspendProcessPresentationStreamBridge,
543
+ resumeProcessPresentationStreamBridge,
544
+ processPresentationOutput,
545
+ writePresentationLine,
546
+ resolveEngagement
547
+ };
@@ -5,7 +5,7 @@ import {
5
5
  CODEX_CLIENT_VERSION,
6
6
  CODEX_PROTOCOL_HEADERS,
7
7
  getChatGptCodexAccessToken
8
- } from "./chunk-AV2LG2L7.js";
8
+ } from "./chunk-QVIRWJ45.js";
9
9
 
10
10
  // packages/core/dist/runtime/codex-models.js
11
11
  import { createHash } from "node:crypto";