@pensar/apex 2.4.0 → 2.5.0-canary.aa559068

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 (68) hide show
  1. package/build/agent-48xj79bj.js +20 -0
  2. package/build/{agent-nhs1w5w0.js → agent-7q3c9cjt.js} +11 -10
  3. package/build/{agent-5ejt5vpz.js → agent-ve8pkr6q.js} +9 -8
  4. package/build/{apps-17wvz1d7.js → apps-4rsrnftx.js} +72 -31
  5. package/build/{auth-z3h9859n.js → auth-0w07dbg2.js} +25 -20
  6. package/build/authentication-87zzmjdd.js +20 -0
  7. package/build/blackboxAgent-x0e1wqjx.js +20 -0
  8. package/build/blackboxPentest-0hwj49dr.js +70 -0
  9. package/build/{cli-32z0017y.js → cli-12ky98ey.js} +2 -2
  10. package/build/{cli-5k33webc.js → cli-2ar3m569.js} +45 -43
  11. package/build/cli-53rm0rrz.js +15 -0
  12. package/build/{cli-72cvcqhg.js → cli-54egv3xw.js} +1 -1
  13. package/build/cli-68260ckj.js +12136 -0
  14. package/build/{cli-gq40s5b3.js → cli-6cq67y5m.js} +5 -3
  15. package/build/{cli-mavved45.js → cli-7735d17s.js} +46 -25
  16. package/build/cli-7q3ae3ft.js +6 -0
  17. package/build/{cli-tznv8pf1.js → cli-8mws7sa5.js} +1 -1
  18. package/build/cli-9pbk8m32.js +32 -0
  19. package/build/{cli-swpbx60z.js → cli-avmhkjtv.js} +1 -1481
  20. package/build/{cli-9rhzhgx2.js → cli-eaaqeve1.js} +1 -1
  21. package/build/{cli-qqt4gj1w.js → cli-g0whajsq.js} +5 -3
  22. package/build/{cli-vq52kp7j.js → cli-gb1s7k3v.js} +17 -5
  23. package/build/{cli-2cbwdk78.js → cli-h8xsqggy.js} +1 -1
  24. package/build/{cli-0n4r54hq.js → cli-jsw8vt43.js} +1 -1
  25. package/build/cli-knd276ed.js +1485 -0
  26. package/build/{cli-repbyhkk.js → cli-kya26m6f.js} +1136 -525
  27. package/build/{cli-k8kc47pq.js → cli-mmyn6wmb.js} +3 -3
  28. package/build/{cli-tkc598ey.js → cli-qwv4jsj2.js} +371 -279
  29. package/build/{cli-xshasbwe.js → cli-r3w58pmq.js} +30 -4
  30. package/build/{cli-vnynf0js.js → cli-w51z9qjr.js} +10 -4
  31. package/build/{cli-b1adytsy.js → cli-whp0f8gp.js} +28 -5
  32. package/build/cli.js +553 -95
  33. package/build/{config-f1mj4nhd.js → config-z9k13rvy.js} +18 -15
  34. package/build/{doctor-ekneewa3.js → doctor-tc5zs6pn.js} +8 -7
  35. package/build/{fastStrike-8zka43xs.js → fastStrike-ssm7df42.js} +13 -10
  36. package/build/{fixes-b89s5haw.js → fixes-av9nq0hq.js} +25 -20
  37. package/build/getMachineId-bsd-xj3bn2fv.js +36 -0
  38. package/build/getMachineId-darwin-07jzjcx6.js +36 -0
  39. package/build/getMachineId-linux-ahngynxd.js +29 -0
  40. package/build/getMachineId-unsupported-vy43b44z.js +19 -0
  41. package/build/getMachineId-win-8x66cynz.js +38 -0
  42. package/build/{index-hqjdg6fg.js → index-1ppbwgf9.js} +17 -9
  43. package/build/{index-mtq7kmxz.js → index-5wh7gq37.js} +4 -2
  44. package/build/{index-6d22pyxt.js → index-718m7jw9.js} +1669 -1193
  45. package/build/{index-rbzhk712.js → index-gng8ebqf.js} +11 -10
  46. package/build/{index-y5w6n3tb.js → index-hhcjyc6j.js} +2 -2
  47. package/build/{index-sf16jm0m.js → index-mffgf5hg.js} +9 -7
  48. package/build/{index-ghwf5z3v.js → index-p1atm3ha.js} +3 -3
  49. package/build/{index-4ad3sdwk.js → index-vvkvwmyr.js} +4 -4
  50. package/build/{issues-xx5bs4md.js → issues-hfg8jydv.js} +72 -26
  51. package/build/{logs-qtxe51w2.js → logs-0rd1z7ct.js} +25 -20
  52. package/build/{offesecAgent-b9e2xm6v.js → offesecAgent-j4epj93p.js} +10 -9
  53. package/build/pentest-dp9w88pw.js +30 -0
  54. package/build/{pentests-6ks3szc4.js → pentests-enyxjtg6.js} +26 -21
  55. package/build/{targetedPentest-s1ptvq8e.js → targetedPentest-kwabfy86.js} +11 -10
  56. package/build/{targets-sxygyj87.js → targets-7x0pcmws.js} +27 -22
  57. package/build/threatModel-zwk5eb6r.js +29 -0
  58. package/build/{uninstall-tvsh81v8.js → uninstall-psm9btpt.js} +6 -3
  59. package/build/{upload-7wdyyqmr.js → upload-dybnknjs.js} +8 -7
  60. package/build/{utils-7fwdkqk6.js → utils-dsfk965b.js} +7 -6
  61. package/package.json +8 -2
  62. package/build/agent-mvpgvgks.js +0 -19
  63. package/build/authentication-3s97cpk4.js +0 -19
  64. package/build/blackboxAgent-gw0a1ca4.js +0 -19
  65. package/build/blackboxPentest-44333zss.js +0 -37
  66. package/build/main-mmjp338j.js +0 -324
  67. package/build/pentest-xtc1sjdw.js +0 -29
  68. package/build/threatModel-xsm6fwk5.js +0 -27
package/build/cli.js CHANGED
@@ -1,5 +1,14 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
+ import {
4
+ require_index_node_http,
5
+ require_index_shim,
6
+ require_src as require_src2,
7
+ require_src1 as require_src3,
8
+ require_src2 as require_src4,
9
+ require_src3 as require_src5,
10
+ require_src4 as require_src6
11
+ } from "./cli-68260ckj.js";
3
12
  import"./cli-dm0fc0bm.js";
4
13
  import {
5
14
  createThreatModelPrompt
@@ -8,26 +17,355 @@ import"./cli-c8131c4q.js";
8
17
  import {
9
18
  buildAuthConfig,
10
19
  init_ai1 as init_ai,
20
+ init_model_history,
11
21
  init_models,
12
22
  init_session,
13
23
  init_structured,
14
24
  init_toolset,
15
25
  init_utils,
16
26
  logger
17
- } from "./cli-tkc598ey.js";
18
- import"./cli-0n4r54hq.js";
19
- import"./cli-swpbx60z.js";
27
+ } from "./cli-qwv4jsj2.js";
28
+ import"./cli-jsw8vt43.js";
29
+ import"./cli-avmhkjtv.js";
20
30
  import"./cli-j54qa6tm.js";
21
- import"./cli-72cvcqhg.js";
22
- import"./cli-9rhzhgx2.js";
31
+ import"./cli-54egv3xw.js";
32
+ import"./cli-eaaqeve1.js";
23
33
  import {
34
+ init_installation,
24
35
  init_package,
25
- package_default
26
- } from "./cli-vnynf0js.js";
36
+ package_default,
37
+ version
38
+ } from "./cli-w51z9qjr.js";
39
+ import {
40
+ require_src
41
+ } from "./cli-knd276ed.js";
27
42
  import {
43
+ __commonJS,
28
44
  __require,
29
45
  __toESM
30
46
  } from "./cli-bc05qbss.js";
47
+
48
+ // node_modules/dotenv/lib/main.js
49
+ var require_main = __commonJS(function(exports, module) {
50
+ var fs = __require("fs");
51
+ var path = __require("path");
52
+ var os = __require("os");
53
+ var crypto = __require("crypto");
54
+ var TIPS = [
55
+ "◈ encrypted .env [www.dotenvx.com]",
56
+ "◈ secrets for agents [www.dotenvx.com]",
57
+ "⌁ auth for agents [www.vestauth.com]",
58
+ "⌘ custom filepath { path: '/custom/path/.env' }",
59
+ "⌘ enable debugging { debug: true }",
60
+ "⌘ override existing { override: true }",
61
+ "⌘ suppress logs { quiet: true }",
62
+ "⌘ multiple files { path: ['.env.local', '.env'] }"
63
+ ];
64
+ function _getRandomTip() {
65
+ return TIPS[Math.floor(Math.random() * TIPS.length)];
66
+ }
67
+ function parseBoolean(value) {
68
+ if (typeof value === "string") {
69
+ return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
70
+ }
71
+ return Boolean(value);
72
+ }
73
+ function supportsAnsi() {
74
+ return process.stdout.isTTY;
75
+ }
76
+ function dim(text) {
77
+ return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
78
+ }
79
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
80
+ function parse(src) {
81
+ const obj = {};
82
+ let lines = src.toString();
83
+ lines = lines.replace(/\r\n?/mg, `
84
+ `);
85
+ let match;
86
+ while ((match = LINE.exec(lines)) != null) {
87
+ const key = match[1];
88
+ let value = match[2] || "";
89
+ value = value.trim();
90
+ const maybeQuote = value[0];
91
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
92
+ if (maybeQuote === '"') {
93
+ value = value.replace(/\\n/g, `
94
+ `);
95
+ value = value.replace(/\\r/g, "\r");
96
+ }
97
+ obj[key] = value;
98
+ }
99
+ return obj;
100
+ }
101
+ function _parseVault(options) {
102
+ options = options || {};
103
+ const vaultPath = _vaultPath(options);
104
+ options.path = vaultPath;
105
+ const result = DotenvModule.configDotenv(options);
106
+ if (!result.parsed) {
107
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
108
+ err.code = "MISSING_DATA";
109
+ throw err;
110
+ }
111
+ const keys = _dotenvKey(options).split(",");
112
+ const length = keys.length;
113
+ let decrypted;
114
+ for (let i = 0;i < length; i++) {
115
+ try {
116
+ const key = keys[i].trim();
117
+ const attrs = _instructions(result, key);
118
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
119
+ break;
120
+ } catch (error) {
121
+ if (i + 1 >= length) {
122
+ throw error;
123
+ }
124
+ }
125
+ }
126
+ return DotenvModule.parse(decrypted);
127
+ }
128
+ function _warn(message) {
129
+ console.error(`⚠ ${message}`);
130
+ }
131
+ function _debug(message) {
132
+ console.log(`┆ ${message}`);
133
+ }
134
+ function _log(message) {
135
+ console.log(`◇ ${message}`);
136
+ }
137
+ function _dotenvKey(options) {
138
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
139
+ return options.DOTENV_KEY;
140
+ }
141
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
142
+ return process.env.DOTENV_KEY;
143
+ }
144
+ return "";
145
+ }
146
+ function _instructions(result, dotenvKey) {
147
+ let uri;
148
+ try {
149
+ uri = new URL(dotenvKey);
150
+ } catch (error) {
151
+ if (error.code === "ERR_INVALID_URL") {
152
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
153
+ err.code = "INVALID_DOTENV_KEY";
154
+ throw err;
155
+ }
156
+ throw error;
157
+ }
158
+ const key = uri.password;
159
+ if (!key) {
160
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
161
+ err.code = "INVALID_DOTENV_KEY";
162
+ throw err;
163
+ }
164
+ const environment = uri.searchParams.get("environment");
165
+ if (!environment) {
166
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
167
+ err.code = "INVALID_DOTENV_KEY";
168
+ throw err;
169
+ }
170
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
171
+ const ciphertext = result.parsed[environmentKey];
172
+ if (!ciphertext) {
173
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
174
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
175
+ throw err;
176
+ }
177
+ return { ciphertext, key };
178
+ }
179
+ function _vaultPath(options) {
180
+ let possibleVaultPath = null;
181
+ if (options && options.path && options.path.length > 0) {
182
+ if (Array.isArray(options.path)) {
183
+ for (const filepath of options.path) {
184
+ if (fs.existsSync(filepath)) {
185
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
186
+ }
187
+ }
188
+ } else {
189
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
190
+ }
191
+ } else {
192
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
193
+ }
194
+ if (fs.existsSync(possibleVaultPath)) {
195
+ return possibleVaultPath;
196
+ }
197
+ return null;
198
+ }
199
+ function _resolveHome(envPath) {
200
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
201
+ }
202
+ function _configVault(options) {
203
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
204
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
205
+ if (debug || !quiet) {
206
+ _log("loading env from encrypted .env.vault");
207
+ }
208
+ const parsed = DotenvModule._parseVault(options);
209
+ let processEnv = process.env;
210
+ if (options && options.processEnv != null) {
211
+ processEnv = options.processEnv;
212
+ }
213
+ DotenvModule.populate(processEnv, parsed, options);
214
+ return { parsed };
215
+ }
216
+ function configDotenv(options) {
217
+ const dotenvPath = path.resolve(process.cwd(), ".env");
218
+ let encoding = "utf8";
219
+ let processEnv = process.env;
220
+ if (options && options.processEnv != null) {
221
+ processEnv = options.processEnv;
222
+ }
223
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
224
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
225
+ if (options && options.encoding) {
226
+ encoding = options.encoding;
227
+ } else {
228
+ if (debug) {
229
+ _debug("no encoding is specified (UTF-8 is used by default)");
230
+ }
231
+ }
232
+ let optionPaths = [dotenvPath];
233
+ if (options && options.path) {
234
+ if (!Array.isArray(options.path)) {
235
+ optionPaths = [_resolveHome(options.path)];
236
+ } else {
237
+ optionPaths = [];
238
+ for (const filepath of options.path) {
239
+ optionPaths.push(_resolveHome(filepath));
240
+ }
241
+ }
242
+ }
243
+ let lastError;
244
+ const parsedAll = {};
245
+ for (const path2 of optionPaths) {
246
+ try {
247
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
248
+ DotenvModule.populate(parsedAll, parsed, options);
249
+ } catch (e) {
250
+ if (debug) {
251
+ _debug(`failed to load ${path2} ${e.message}`);
252
+ }
253
+ lastError = e;
254
+ }
255
+ }
256
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
257
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
258
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
259
+ if (debug || !quiet) {
260
+ const keysCount = Object.keys(populated).length;
261
+ const shortPaths = [];
262
+ for (const filePath of optionPaths) {
263
+ try {
264
+ const relative = path.relative(process.cwd(), filePath);
265
+ shortPaths.push(relative);
266
+ } catch (e) {
267
+ if (debug) {
268
+ _debug(`failed to load ${filePath} ${e.message}`);
269
+ }
270
+ lastError = e;
271
+ }
272
+ }
273
+ _log(`injected env (${keysCount}) from ${shortPaths.join(",")} ${dim(`// tip: ${_getRandomTip()}`)}`);
274
+ }
275
+ if (lastError) {
276
+ return { parsed: parsedAll, error: lastError };
277
+ } else {
278
+ return { parsed: parsedAll };
279
+ }
280
+ }
281
+ function config(options) {
282
+ if (_dotenvKey(options).length === 0) {
283
+ return DotenvModule.configDotenv(options);
284
+ }
285
+ const vaultPath = _vaultPath(options);
286
+ if (!vaultPath) {
287
+ _warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
288
+ return DotenvModule.configDotenv(options);
289
+ }
290
+ return DotenvModule._configVault(options);
291
+ }
292
+ function decrypt(encrypted, keyStr) {
293
+ const key = Buffer.from(keyStr.slice(-64), "hex");
294
+ let ciphertext = Buffer.from(encrypted, "base64");
295
+ const nonce = ciphertext.subarray(0, 12);
296
+ const authTag = ciphertext.subarray(-16);
297
+ ciphertext = ciphertext.subarray(12, -16);
298
+ try {
299
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
300
+ aesgcm.setAuthTag(authTag);
301
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
302
+ } catch (error) {
303
+ const isRange = error instanceof RangeError;
304
+ const invalidKeyLength = error.message === "Invalid key length";
305
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
306
+ if (isRange || invalidKeyLength) {
307
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
308
+ err.code = "INVALID_DOTENV_KEY";
309
+ throw err;
310
+ } else if (decryptionFailed) {
311
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
312
+ err.code = "DECRYPTION_FAILED";
313
+ throw err;
314
+ } else {
315
+ throw error;
316
+ }
317
+ }
318
+ }
319
+ function populate(processEnv, parsed, options = {}) {
320
+ const debug = Boolean(options && options.debug);
321
+ const override = Boolean(options && options.override);
322
+ const populated = {};
323
+ if (typeof parsed !== "object") {
324
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
325
+ err.code = "OBJECT_REQUIRED";
326
+ throw err;
327
+ }
328
+ for (const key of Object.keys(parsed)) {
329
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
330
+ if (override === true) {
331
+ processEnv[key] = parsed[key];
332
+ populated[key] = parsed[key];
333
+ }
334
+ if (debug) {
335
+ if (override === true) {
336
+ _debug(`"${key}" is already defined and WAS overwritten`);
337
+ } else {
338
+ _debug(`"${key}" is already defined and was NOT overwritten`);
339
+ }
340
+ }
341
+ } else {
342
+ processEnv[key] = parsed[key];
343
+ populated[key] = parsed[key];
344
+ }
345
+ }
346
+ return populated;
347
+ }
348
+ var DotenvModule = {
349
+ configDotenv,
350
+ _configVault,
351
+ _parseVault,
352
+ config,
353
+ decrypt,
354
+ parse,
355
+ populate
356
+ };
357
+ module.exports.configDotenv = DotenvModule.configDotenv;
358
+ module.exports._configVault = DotenvModule._configVault;
359
+ module.exports._parseVault = DotenvModule._parseVault;
360
+ module.exports.config = DotenvModule.config;
361
+ module.exports.decrypt = DotenvModule.decrypt;
362
+ module.exports.parse = DotenvModule.parse;
363
+ module.exports.populate = DotenvModule.populate;
364
+ module.exports = DotenvModule;
365
+ });
366
+
367
+ // src/cli.ts
368
+ var import_dotenv = __toESM(require_main(), 1);
31
369
  // package.json
32
370
  var package_default2 = {
33
371
  author: "Pensar",
@@ -47,6 +385,10 @@ var package_default2 = {
47
385
  "@modelcontextprotocol/sdk": "^1.29.0",
48
386
  "@openrouter/ai-sdk-provider": "^2.9.1",
49
387
  "@opentelemetry/api": "^1.9.1",
388
+ "@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
389
+ "@opentelemetry/otlp-exporter-base": "^0.221.0",
390
+ "@opentelemetry/otlp-transformer": "^0.221.0",
391
+ "@opentelemetry/resources": "^2.10.0",
50
392
  "@opentui/core": "^0.1.107",
51
393
  "@opentui/react": "^0.1.107",
52
394
  "@pensar/surface": "0.3.0",
@@ -70,6 +412,8 @@ var package_default2 = {
70
412
  description: "AI-powered penetration testing CLI tool with terminal UI",
71
413
  devDependencies: {
72
414
  "@biomejs/biome": "2.4.14",
415
+ "@opentelemetry/context-async-hooks": "^2.10.0",
416
+ "@opentelemetry/sdk-trace-base": "^2.10.0",
73
417
  "@types/bun": "^1.3.14",
74
418
  "@types/mailparser": "^3.4.6",
75
419
  "@types/mime-types": "^3.0.1",
@@ -116,7 +460,7 @@ var package_default2 = {
116
460
  url: "https://github.com/pensarai/apex.git"
117
461
  },
118
462
  scripts: {
119
- build: "bun build src/cli.ts --outdir build --target node --format esm --splitting --external @opentui/core --external @opentui/react --external @opentui/react/* --external react --external react/jsx-runtime --external react/jsx-dev-runtime --external react-reconciler --external weave --external electron --external chromium-bidi --external camoufox-js",
463
+ build: "rm -rf build && bun build src/cli.ts --outdir build --target node --format esm --splitting --external @opentui/core --external @opentui/react --external @opentui/react/* --external react --external react/jsx-runtime --external react/jsx-dev-runtime --external react-reconciler --external weave --external electron --external chromium-bidi --external camoufox-js",
120
464
  "build:binaries": "bun run generate:ascii && mkdir -p dist && bun run build:binary:macos-arm64 && bun run build:binary:macos-x64 && bun run build:binary:linux-x64 && bun run build:binary:linux-arm64",
121
465
  "build:binary": "bun run generate:ascii && bun build src/cli.ts --compile --external electron --external chromium-bidi --external camoufox-js --outfile pensar",
122
466
  "build:binary:linux-arm64": "bun build src/cli.ts --compile --external electron --external chromium-bidi --external camoufox-js --target=bun-linux-arm64 --outfile dist/pensar-linux-arm64",
@@ -144,14 +488,29 @@ var package_default2 = {
144
488
  tsc: "tsc --noEmit"
145
489
  },
146
490
  type: "module",
147
- version: "2.4.0"
491
+ version: "2.5.0-canary.aa559068"
148
492
  };
149
493
 
150
494
  // src/core/ai/index.ts
151
495
  init_ai();
496
+ init_model_history();
152
497
  init_models();
153
498
  init_utils();
154
499
 
500
+ // src/core/api/clientIdentity.ts
501
+ init_installation();
502
+ var currentCommand;
503
+ function setCurrentCommand(command) {
504
+ currentCommand = normalizeCommand(command);
505
+ }
506
+ var COMMAND_SHAPE = /^[a-z][a-z0-9-]{0,31}$/;
507
+ function normalizeCommand(command) {
508
+ if (!command)
509
+ return;
510
+ const trimmed = command.trim().toLowerCase();
511
+ return COMMAND_SHAPE.test(trimmed) ? trimmed : undefined;
512
+ }
513
+
155
514
  // src/core/cli/logLevelArgs.ts
156
515
  var VALID_LOG_LEVELS = new Set([
157
516
  "DEBUG",
@@ -371,7 +730,7 @@ class AgentEventBus {
371
730
  // src/core/installation/index.ts
372
731
  init_package();
373
732
  import { spawnSync } from "node:child_process";
374
- function getCurrentVersion() {
733
+ function getCurrentVersion2() {
375
734
  return package_default.version;
376
735
  }
377
736
  function isNewerVersion(current, latest) {
@@ -436,7 +795,7 @@ function getUpgradeCommandString(method) {
436
795
  return `${cmd} ${args.join(" ")}`;
437
796
  }
438
797
  function runUpgrade(method, options) {
439
- const currentVersion = getCurrentVersion();
798
+ const currentVersion = getCurrentVersion2();
440
799
  const { cmd, args } = getUpgradeCommand(method);
441
800
  const interactive = options?.interactive ?? false;
442
801
  const result = spawnSync(cmd, args, {
@@ -461,7 +820,7 @@ function runUpgrade(method, options) {
461
820
  };
462
821
  }
463
822
  async function upgrade(options) {
464
- const currentVersion = getCurrentVersion();
823
+ const currentVersion = getCurrentVersion2();
465
824
  let latestVersion;
466
825
  try {
467
826
  latestVersion = await getLatestVersion();
@@ -508,6 +867,103 @@ import os from "node:os";
508
867
  import path from "node:path";
509
868
  var ERROR_LOG_PATH = path.join(os.homedir(), ".pensar", "error.log");
510
869
 
870
+ // src/core/observability/runtime.ts
871
+ init_package();
872
+ var import_api = __toESM(require_src(), 1);
873
+ var import_context_async_hooks = __toESM(require_src2(), 1);
874
+ var import_exporter_trace_otlp_http = __toESM(require_src6(), 1);
875
+ var import_otlp_exporter_base = __toESM(require_src3(), 1);
876
+ var import_node_http = __toESM(require_index_node_http(), 1);
877
+ var import_otlp_transformer = __toESM(require_src5(), 1);
878
+ var import_resources = __toESM(require_src4(), 1);
879
+ var import_sdk_trace_base = __toESM(require_index_shim(), 1);
880
+ import { randomUUID } from "node:crypto";
881
+ var NOOP_RUNTIME = {
882
+ async forceFlush() {},
883
+ async shutdown() {}
884
+ };
885
+ function isOtelSdkDisabled(env) {
886
+ return env.OTEL_SDK_DISABLED === "true";
887
+ }
888
+ function resolveTracesEndpoint(env) {
889
+ const specific = env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT?.trim();
890
+ if (specific)
891
+ return specific;
892
+ const generic = env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();
893
+ if (!generic)
894
+ return null;
895
+ return `${generic.endsWith("/") ? generic : `${generic}/`}v1/traces`;
896
+ }
897
+ function resolveTracesProtocol(env) {
898
+ const raw = (env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL ?? env.OTEL_EXPORTER_OTLP_PROTOCOL ?? "").trim();
899
+ return raw === "http/protobuf" ? "http/protobuf" : "http/json";
900
+ }
901
+ function parseResourceAttributes(env) {
902
+ const raw = env.OTEL_RESOURCE_ATTRIBUTES;
903
+ if (!raw)
904
+ return {};
905
+ const attrs = {};
906
+ for (const pair of raw.split(",")) {
907
+ const eq = pair.indexOf("=");
908
+ if (eq <= 0)
909
+ continue;
910
+ const key = pair.slice(0, eq).trim();
911
+ const value = pair.slice(eq + 1).trim();
912
+ if (key && value)
913
+ attrs[key] = value;
914
+ }
915
+ return attrs;
916
+ }
917
+ function buildResource(env) {
918
+ const resourceAttributes = parseResourceAttributes(env);
919
+ return import_resources.resourceFromAttributes({
920
+ "service.version": version,
921
+ "service.instance.id": randomUUID(),
922
+ ...resourceAttributes,
923
+ "service.name": env.OTEL_SERVICE_NAME?.trim() || resourceAttributes["service.name"] || "apex"
924
+ });
925
+ }
926
+ function createTraceExporter(protocol) {
927
+ if (protocol === "http/json") {
928
+ return new import_exporter_trace_otlp_http.OTLPTraceExporter;
929
+ }
930
+ return new import_otlp_exporter_base.OTLPExporterBase(import_node_http.createOtlpHttpExportDelegate(import_node_http.convertLegacyHttpOptions({}, "TRACES", "v1/traces", {
931
+ "Content-Type": "application/x-protobuf"
932
+ }), import_otlp_transformer.ProtobufTraceSerializer, "otlp_http_span_exporter", import_otlp_transformer.TraceExporterMetricsHelper, undefined));
933
+ }
934
+ var activeRuntime = null;
935
+ function startObservabilityRuntime(env = process.env) {
936
+ if (activeRuntime)
937
+ return activeRuntime;
938
+ if (isOtelSdkDisabled(env))
939
+ return NOOP_RUNTIME;
940
+ if (!resolveTracesEndpoint(env))
941
+ return NOOP_RUNTIME;
942
+ const exporter = createTraceExporter(resolveTracesProtocol(env));
943
+ const provider = new import_sdk_trace_base.BasicTracerProvider({
944
+ resource: buildResource(env),
945
+ spanProcessors: [new import_sdk_trace_base.BatchSpanProcessor(exporter)]
946
+ });
947
+ const contextManager = new import_context_async_hooks.AsyncLocalStorageContextManager;
948
+ contextManager.enable();
949
+ import_api.trace.setGlobalTracerProvider(provider);
950
+ import_api.context.setGlobalContextManager(contextManager);
951
+ const runtime = {
952
+ async forceFlush() {
953
+ await provider.forceFlush();
954
+ },
955
+ async shutdown() {
956
+ activeRuntime = null;
957
+ await provider.shutdown();
958
+ contextManager.disable();
959
+ import_api.trace.disable();
960
+ import_api.context.disable();
961
+ }
962
+ };
963
+ activeRuntime = runtime;
964
+ return runtime;
965
+ }
966
+
511
967
  // src/tui/utils/command-flags.ts
512
968
  import { readFileSync } from "node:fs";
513
969
  import { isAbsolute, resolve } from "node:path";
@@ -537,7 +993,8 @@ function resolveThreatModelPrompt(value) {
537
993
 
538
994
  // src/cli.ts
539
995
  var args = process.argv.slice(2);
540
- var version = package_default2.version;
996
+ var version2 = package_default2.version;
997
+ import_dotenv.config();
541
998
  var OBFUSCATE_FLAGS = new Set(["--obfuscate", "--redact", "-O"]);
542
999
  var obfuscateRequested = args.some((a) => OBFUSCATE_FLAGS.has(a));
543
1000
  if (obfuscateRequested) {
@@ -592,7 +1049,7 @@ function attachCliAgentStreamListeners(bus) {
592
1049
  async function createInstrumentedBus(session) {
593
1050
  const bus = new AgentEventBus;
594
1051
  attachCliAgentStreamListeners(bus);
595
- const { attachWandbToEventBus } = await import("./upload-7wdyyqmr.js");
1052
+ const { attachWandbToEventBus } = await import("./upload-dybnknjs.js");
596
1053
  const wandbCleanup = await attachWandbToEventBus(session, bus).catch((e) => {
597
1054
  console.warn("[wandb] Tracing disabled:", e.message);
598
1055
  return null;
@@ -609,7 +1066,7 @@ async function resolveCliHeaders() {
609
1066
  const { parseHeaderLine: parseHeaderLine2, parseHeadersFromFile, formatParseError: formatParseError2 } = await import("./parse-rtccymzn.js");
610
1067
  const merged = {};
611
1068
  if (!noGlobal) {
612
- const { config: appConfig } = await import("./index-y5w6n3tb.js");
1069
+ const { config: appConfig } = await import("./index-hhcjyc6j.js");
613
1070
  const cfg = await appConfig.get();
614
1071
  if (cfg.defaultHeaders) {
615
1072
  Object.assign(merged, cfg.defaultHeaders);
@@ -643,8 +1100,8 @@ async function resolveCliModel() {
643
1100
  const explicit = getArg("--model");
644
1101
  if (explicit)
645
1102
  return explicit;
646
- const { config: appConfig } = await import("./index-y5w6n3tb.js");
647
- const { getDefaultModelForConfig } = await import("./utils-7fwdkqk6.js");
1103
+ const { config: appConfig } = await import("./index-hhcjyc6j.js");
1104
+ const { getDefaultModelForConfig } = await import("./utils-dsfk965b.js");
648
1105
  const pensarConfig = await appConfig.get();
649
1106
  const defaultModel = getDefaultModelForConfig(pensarConfig);
650
1107
  if (!defaultModel) {
@@ -731,11 +1188,9 @@ Global options:
731
1188
  `);
732
1189
  }
733
1190
  async function runPentest() {
734
- const { config } = await import("./main-mmjp338j.js").then((m)=>__toESM(m.default,1));
735
- config();
736
- const { runPentestAgent } = await import("./blackboxPentest-44333zss.js");
737
- const { sessions: sessions2 } = await import("./index-sf16jm0m.js");
738
- const { config: appConfig } = await import("./index-y5w6n3tb.js");
1191
+ const { runPentestAgent } = await import("./blackboxPentest-0hwj49dr.js");
1192
+ const { sessions: sessions2 } = await import("./index-mffgf5hg.js");
1193
+ const { config: appConfig } = await import("./index-hhcjyc6j.js");
739
1194
  const target = getArgRequired("--target");
740
1195
  const cwd = getArg("--cwd");
741
1196
  const mode = getArg("--mode");
@@ -806,14 +1261,11 @@ Report: ${reportPath}` : ""}`);
806
1261
  } finally {
807
1262
  await wandbCleanup();
808
1263
  }
809
- process.exit(0);
810
1264
  }
811
1265
  async function runTargetedPentest() {
812
- const { config } = await import("./main-mmjp338j.js").then((m)=>__toESM(m.default,1));
813
- config();
814
- const { runTargetedPentestAgent } = await import("./targetedPentest-s1ptvq8e.js");
815
- const { sessions: sessions2 } = await import("./index-sf16jm0m.js");
816
- const { config: appConfig } = await import("./index-y5w6n3tb.js");
1266
+ const { runTargetedPentestAgent } = await import("./targetedPentest-kwabfy86.js");
1267
+ const { sessions: sessions2 } = await import("./index-mffgf5hg.js");
1268
+ const { config: appConfig } = await import("./index-hhcjyc6j.js");
817
1269
  const target = getArgRequired("--target");
818
1270
  const objectives = getAllArgs("--objective");
819
1271
  const pensarConfig = await appConfig.get();
@@ -860,13 +1312,10 @@ POCs: ${pocsPath}`);
860
1312
  } finally {
861
1313
  await wandbCleanup();
862
1314
  }
863
- process.exit(0);
864
1315
  }
865
1316
  async function runThreatModel() {
866
- const { config } = await import("./main-mmjp338j.js").then((m)=>__toESM(m.default,1));
867
- config();
868
- const { runThreatModelWorkflow } = await import("./threatModel-xsm6fwk5.js");
869
- const { config: appConfig } = await import("./index-y5w6n3tb.js");
1317
+ const { runThreatModelWorkflow } = await import("./threatModel-zwk5eb6r.js");
1318
+ const { config: appConfig } = await import("./index-hhcjyc6j.js");
870
1319
  const path2 = await import("path");
871
1320
  const pensarConfig = await appConfig.get();
872
1321
  const model = await resolveCliModel();
@@ -900,16 +1349,14 @@ ${sep}
900
1349
  Threat model written to: ${resolvedPath}`);
901
1350
  }
902
1351
  async function runOperator() {
903
- const { config } = await import("./main-mmjp338j.js").then((m)=>__toESM(m.default,1));
904
- config();
905
- const { runOffensiveSecurityAgent } = await import("./offesecAgent-b9e2xm6v.js");
906
- const { sessions: sessions2, normalizeMessages, getResumeMessages } = await import("./index-sf16jm0m.js");
907
- const { ALL_TOOL_NAMES, SKILL_TOOL_NAMES } = await import("./index-hqjdg6fg.js");
908
- const { config: appConfig } = await import("./index-y5w6n3tb.js");
1352
+ const { runOffensiveSecurityAgent } = await import("./offesecAgent-j4epj93p.js");
1353
+ const { sessions: sessions2, normalizeMessages, getResumeMessages } = await import("./index-mffgf5hg.js");
1354
+ const { ALL_TOOL_NAMES, SKILL_TOOL_NAMES } = await import("./index-1ppbwgf9.js");
1355
+ const { config: appConfig } = await import("./index-hhcjyc6j.js");
909
1356
  const { createInterface } = await import("readline");
910
1357
  const { readFileSync: readFileSync2, existsSync } = await import("fs");
911
1358
  const path2 = await import("path");
912
- const { stepCountIs } = await import("./index-mtq7kmxz.js");
1359
+ const { stepCountIs } = await import("./index-5wh7gq37.js");
913
1360
  const promptRaw = getArg("-p") ?? getArg("--prompt");
914
1361
  if (!promptRaw) {
915
1362
  console.error("Error: -p <prompt> is required");
@@ -997,7 +1444,7 @@ ${sep}
997
1444
  Session: ${session.rootPath}`);
998
1445
  }
999
1446
  async function runUpgrade2() {
1000
- const currentVersion = getCurrentVersion();
1447
+ const currentVersion = getCurrentVersion2();
1001
1448
  console.log(`Current version: v${currentVersion}
1002
1449
  Checking for updates...`);
1003
1450
  const result = await upgrade({ interactive: true });
@@ -1005,60 +1452,71 @@ Checking for updates...`);
1005
1452
  ${result.message}`);
1006
1453
  process.exit(result.success ? 0 : 1);
1007
1454
  }
1008
- if (hasFlag("-p") || command === "--prompt") {
1009
- await runOperator();
1010
- } else if (command === "version" || command === "--version" || command === "-v") {
1011
- console.log(`v${version}`);
1012
- } else if (command === "help" || command === "--help" || command === "-h") {
1013
- showHelp();
1014
- } else if (command === "upgrade" || command === "update") {
1015
- await runUpgrade2();
1016
- } else if (command === "pentest") {
1017
- await runPentest();
1018
- } else if (command === "targeted-pentest") {
1019
- await runTargetedPentest();
1020
- } else if (command === "login" || command === "auth") {
1021
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1022
- await import("./auth-z3h9859n.js");
1023
- } else if (command === "uninstall") {
1024
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1025
- await import("./uninstall-tvsh81v8.js");
1026
- } else if (command === "apps") {
1027
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1028
- await import("./apps-17wvz1d7.js");
1029
- } else if (command === "pentests") {
1030
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1031
- await import("./pentests-6ks3szc4.js");
1032
- } else if (command === "targets") {
1033
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1034
- await import("./targets-sxygyj87.js");
1035
- } else if (command === "issues") {
1036
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1037
- await import("./issues-xx5bs4md.js");
1038
- } else if (command === "fixes") {
1039
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1040
- await import("./fixes-b89s5haw.js");
1041
- } else if (command === "logs") {
1042
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1043
- await import("./logs-qtxe51w2.js");
1044
- } else if (command === "config") {
1045
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1046
- await import("./config-f1mj4nhd.js");
1047
- } else if (command === "threat-model") {
1048
- await runThreatModel();
1049
- } else if (command === "doctor") {
1050
- const { runDoctor } = await import("./doctor-ekneewa3.js");
1051
- await runDoctor();
1052
- } else if (args.length === 0) {
1053
- if (process.env.PENSAR_NO_TUI === "1") {
1054
- console.error("TUI mode requires Bun. Install Bun (https://bun.sh) or use a standalone binary release for interactive mode.");
1055
- console.error("All other commands work with Node \u2014 run 'pensar --help'.");
1455
+ var observabilityRuntime = startObservabilityRuntime();
1456
+ setCurrentCommand(command);
1457
+ try {
1458
+ if (hasFlag("-p") || command === "--prompt") {
1459
+ await runOperator();
1460
+ } else if (command === "version" || command === "--version" || command === "-v") {
1461
+ console.log(`v${version2}`);
1462
+ } else if (command === "help" || command === "--help" || command === "-h") {
1463
+ showHelp();
1464
+ } else if (command === "upgrade" || command === "update") {
1465
+ await runUpgrade2();
1466
+ } else if (command === "pentest") {
1467
+ await runPentest();
1468
+ } else if (command === "targeted-pentest") {
1469
+ await runTargetedPentest();
1470
+ } else if (command === "login" || command === "auth") {
1471
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1472
+ await import("./auth-0w07dbg2.js");
1473
+ } else if (command === "uninstall") {
1474
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1475
+ await import("./uninstall-psm9btpt.js");
1476
+ } else if (command === "apps") {
1477
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1478
+ await import("./apps-4rsrnftx.js");
1479
+ } else if (command === "pentests") {
1480
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1481
+ await import("./pentests-enyxjtg6.js");
1482
+ } else if (command === "targets") {
1483
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1484
+ await import("./targets-7x0pcmws.js");
1485
+ } else if (command === "issues") {
1486
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1487
+ await import("./issues-hfg8jydv.js");
1488
+ } else if (command === "fixes") {
1489
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1490
+ await import("./fixes-av9nq0hq.js");
1491
+ } else if (command === "logs") {
1492
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1493
+ await import("./logs-0rd1z7ct.js");
1494
+ } else if (command === "config") {
1495
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1496
+ await import("./config-z9k13rvy.js");
1497
+ } else if (command === "threat-model") {
1498
+ await runThreatModel();
1499
+ } else if (command === "doctor") {
1500
+ const { runDoctor } = await import("./doctor-tc5zs6pn.js");
1501
+ await runDoctor();
1502
+ } else if (args.length === 0) {
1503
+ if (process.env.PENSAR_NO_TUI === "1") {
1504
+ console.error("TUI mode requires Bun. Install Bun (https://bun.sh) or use a standalone binary release for interactive mode.");
1505
+ console.error("All other commands work with Node \u2014 run 'pensar --help'.");
1506
+ process.exit(1);
1507
+ }
1508
+ await import("./index-718m7jw9.js");
1509
+ } else {
1510
+ console.error(`Error: Unknown command '${command}'`);
1511
+ console.error();
1512
+ console.error("Run 'pensar --help' for usage information");
1056
1513
  process.exit(1);
1057
1514
  }
1058
- await import("./index-6d22pyxt.js");
1059
- } else {
1060
- console.error(`Error: Unknown command '${command}'`);
1061
- console.error();
1062
- console.error("Run 'pensar --help' for usage information");
1063
- process.exit(1);
1515
+ } finally {
1516
+ if (args.length !== 0) {
1517
+ await observabilityRuntime.shutdown().catch(() => {});
1518
+ }
1519
+ }
1520
+ if (command === "pentest" || command === "targeted-pentest") {
1521
+ process.exit(0);
1064
1522
  }