@pensar/apex 2.3.0 → 2.4.0-canary.01e519de

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 (81) hide show
  1. package/build/{agent-9xna7jhw.js → agent-0h5eec5c.js} +12 -11
  2. package/build/agent-31reckde.js +20 -0
  3. package/build/agent-5mr8620j.js +30 -0
  4. package/build/{apps-43pqbz7r.js → apps-6595cxzf.js} +75 -34
  5. package/build/{auth-c1z670rx.js → auth-3k12kd2j.js} +46 -23
  6. package/build/authentication-4090egvp.js +20 -0
  7. package/build/blackboxAgent-gz4y6mcv.js +20 -0
  8. package/build/blackboxPentest-3nass7dk.js +70 -0
  9. package/build/{cli-baqhqbe5.js → cli-0e3qxh7j.js} +3 -3
  10. package/build/{cli-bv2807tj.js → cli-4aakh7qb.js} +5 -3
  11. package/build/{cli-j0n189ee.js → cli-51g5fkhp.js} +2 -2
  12. package/build/cli-53rm0rrz.js +15 -0
  13. package/build/cli-68260ckj.js +12136 -0
  14. package/build/cli-7q3ae3ft.js +6 -0
  15. package/build/cli-9pbk8m32.js +32 -0
  16. package/build/{cli-3k1x5rn3.js → cli-avmhkjtv.js} +2970 -4450
  17. package/build/{cli-8rxa073f.js → cli-bc05qbss.js} +8 -6
  18. package/build/{cli-n2m2yy5b.js → cli-c5wcg4h3.js} +2103 -956
  19. package/build/{cli-q24twygk.js → cli-dm0fc0bm.js} +1 -1
  20. package/build/{cli-yz80qkzn.js → cli-ee3axgts.js} +7 -1
  21. package/build/{cli-zx8gk8xv.js → cli-er8qc2y9.js} +661 -328
  22. package/build/{cli-bnkgdywr.js → cli-f4d9h659.js} +1 -1
  23. package/build/{cli-barsn8br.js → cli-g106a565.js} +11 -5
  24. package/build/{cli-72b18z0n.js → cli-j18by3n1.js} +28 -5
  25. package/build/{cli-gpnb45ck.js → cli-j54qa6tm.js} +7 -7
  26. package/build/{cli-50906d27.js → cli-jxnwyczj.js} +122 -43
  27. package/build/{cli-wszshs5e.js → cli-k71t434r.js} +4 -4
  28. package/build/cli-knd276ed.js +1485 -0
  29. package/build/{cli-f71s6kcw.js → cli-nbz7034e.js} +81 -215
  30. package/build/{cli-7tw4xfnw.js → cli-nyj54g4k.js} +1 -1
  31. package/build/{cli-zm8tfpv7.js → cli-r2cvbp82.js} +62 -44
  32. package/build/{cli-f7hanqbw.js → cli-r4z9n4q4.js} +2 -2
  33. package/build/{cli-eveg9djy.js → cli-rnwxtghc.js} +3 -2
  34. package/build/{cli-vckbhnyk.js → cli-tam9trnb.js} +2 -2
  35. package/build/{cli-zk1ch6qf.js → cli-xz5thhya.js} +61 -10
  36. package/build/{cli-jyp2c6th.js → cli-y6tyk0ms.js} +5 -3
  37. package/build/cli.js +546 -98
  38. package/build/{config-jzqjz606.js → config-52zkpmx4.js} +20 -17
  39. package/build/{doctor-q3qws68e.js → doctor-5eyfxzvy.js} +11 -9
  40. package/build/{fastStrike-ebz1ph9a.js → fastStrike-z2917eqj.js} +39 -16
  41. package/build/{fixes-86yebsj0.js → fixes-3rvsps8m.js} +27 -22
  42. package/build/getMachineId-bsd-xj3bn2fv.js +36 -0
  43. package/build/getMachineId-darwin-07jzjcx6.js +36 -0
  44. package/build/getMachineId-linux-ahngynxd.js +29 -0
  45. package/build/getMachineId-unsupported-vy43b44z.js +19 -0
  46. package/build/getMachineId-win-8x66cynz.js +38 -0
  47. package/build/{index-468j74f3.js → index-50aysats.js} +121 -97
  48. package/build/{index-gq9h8j5j.js → index-5wh7gq37.js} +135 -133
  49. package/build/{index-h2hj2hj9.js → index-cbwn03kz.js} +16 -16
  50. package/build/{index-32hn8rrw.js → index-cf1rrakg.js} +3 -3
  51. package/build/{index-tke6896d.js → index-psqjpw5m.js} +10 -10
  52. package/build/index-qf8trkme.js +12 -0
  53. package/build/{index-e8c8zcrf.js → index-t9q6d8ff.js} +32 -26
  54. package/build/{index-8db1d2q3.js → index-trccwx07.js} +18 -18
  55. package/build/{index-mr2cseg4.js → index-yy1fdh9w.js} +20 -19
  56. package/build/{index-97vx1a24.js → index-zhscmpd1.js} +2774 -2236
  57. package/build/{issues-kh4wg8c5.js → issues-015zf705.js} +36 -28
  58. package/build/{logs-bj28xmbf.js → logs-ra7c7my0.js} +27 -22
  59. package/build/{multipart-parser-6zd16497.js → multipart-parser-g2xxkezz.js} +2 -2
  60. package/build/{offesecAgent-8ky7gccp.js → offesecAgent-cvjy788j.js} +12 -11
  61. package/build/{parse-7djk9jyf.js → parse-rtccymzn.js} +3 -3
  62. package/build/pentest-kkw7zgge.js +30 -0
  63. package/build/{pentests-62d6zw6p.js → pentests-cs7km4sy.js} +28 -23
  64. package/build/{targetedPentest-me4jnr3z.js → targetedPentest-n33mm8bp.js} +15 -14
  65. package/build/{targets-e5k1mrky.js → targets-8nq8d33w.js} +29 -24
  66. package/build/threatModel-wmp658sv.js +29 -0
  67. package/build/{token-rdcbn380.js → token-3bbp59y6.js} +3 -3
  68. package/build/{token-util-sxb85ahn.js → token-util-6xjme11b.js} +2 -2
  69. package/build/{uninstall-jt1bca2p.js → uninstall-jvk3gtnx.js} +7 -4
  70. package/build/{upload-krd8bnex.js → upload-vwnzgrh6.js} +12 -11
  71. package/build/{utils-skmqhyfg.js → utils-132nk1dd.js} +18 -13
  72. package/package.json +8 -2
  73. package/build/agent-71z4e7jg.js +0 -19
  74. package/build/agent-ga5fecfs.js +0 -27
  75. package/build/authentication-hgs7ym0m.js +0 -19
  76. package/build/blackboxAgent-gem3mxa9.js +0 -19
  77. package/build/blackboxPentest-tgc2t3y6.js +0 -37
  78. package/build/index-ag14v3sg.js +0 -12
  79. package/build/main-3d7dfdvs.js +0 -324
  80. package/build/pentest-rs0181nf.js +0 -29
  81. package/build/threatModel-k4f3zgqd.js +0 -27
package/build/cli.js CHANGED
@@ -1,6 +1,15 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import"./cli-q24twygk.js";
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";
12
+ import"./cli-dm0fc0bm.js";
4
13
  import {
5
14
  createThreatModelPrompt
6
15
  } from "./cli-fw5r7pfj.js";
@@ -8,26 +17,354 @@ 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-zx8gk8xv.js";
18
- import"./cli-vckbhnyk.js";
19
- import"./cli-3k1x5rn3.js";
20
- import"./cli-gpnb45ck.js";
21
- import"./cli-f7hanqbw.js";
22
- import"./cli-eveg9djy.js";
27
+ } from "./cli-er8qc2y9.js";
28
+ import"./cli-tam9trnb.js";
29
+ import"./cli-avmhkjtv.js";
30
+ import"./cli-j54qa6tm.js";
31
+ import"./cli-r4z9n4q4.js";
32
+ import"./cli-rnwxtghc.js";
23
33
  import {
24
34
  init_package,
25
- package_default
26
- } from "./cli-barsn8br.js";
35
+ package_default,
36
+ version
37
+ } from "./cli-g106a565.js";
38
+ import {
39
+ require_src
40
+ } from "./cli-knd276ed.js";
27
41
  import {
42
+ __commonJS,
28
43
  __require,
29
44
  __toESM
30
- } from "./cli-8rxa073f.js";
45
+ } from "./cli-bc05qbss.js";
46
+
47
+ // node_modules/dotenv/lib/main.js
48
+ var require_main = __commonJS(function(exports, module) {
49
+ var fs = __require("fs");
50
+ var path = __require("path");
51
+ var os = __require("os");
52
+ var crypto = __require("crypto");
53
+ var TIPS = [
54
+ "◈ encrypted .env [www.dotenvx.com]",
55
+ "◈ secrets for agents [www.dotenvx.com]",
56
+ "⌁ auth for agents [www.vestauth.com]",
57
+ "⌘ custom filepath { path: '/custom/path/.env' }",
58
+ "⌘ enable debugging { debug: true }",
59
+ "⌘ override existing { override: true }",
60
+ "⌘ suppress logs { quiet: true }",
61
+ "⌘ multiple files { path: ['.env.local', '.env'] }"
62
+ ];
63
+ function _getRandomTip() {
64
+ return TIPS[Math.floor(Math.random() * TIPS.length)];
65
+ }
66
+ function parseBoolean(value) {
67
+ if (typeof value === "string") {
68
+ return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
69
+ }
70
+ return Boolean(value);
71
+ }
72
+ function supportsAnsi() {
73
+ return process.stdout.isTTY;
74
+ }
75
+ function dim(text) {
76
+ return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
77
+ }
78
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
79
+ function parse(src) {
80
+ const obj = {};
81
+ let lines = src.toString();
82
+ lines = lines.replace(/\r\n?/mg, `
83
+ `);
84
+ let match;
85
+ while ((match = LINE.exec(lines)) != null) {
86
+ const key = match[1];
87
+ let value = match[2] || "";
88
+ value = value.trim();
89
+ const maybeQuote = value[0];
90
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
91
+ if (maybeQuote === '"') {
92
+ value = value.replace(/\\n/g, `
93
+ `);
94
+ value = value.replace(/\\r/g, "\r");
95
+ }
96
+ obj[key] = value;
97
+ }
98
+ return obj;
99
+ }
100
+ function _parseVault(options) {
101
+ options = options || {};
102
+ const vaultPath = _vaultPath(options);
103
+ options.path = vaultPath;
104
+ const result = DotenvModule.configDotenv(options);
105
+ if (!result.parsed) {
106
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
107
+ err.code = "MISSING_DATA";
108
+ throw err;
109
+ }
110
+ const keys = _dotenvKey(options).split(",");
111
+ const length = keys.length;
112
+ let decrypted;
113
+ for (let i = 0;i < length; i++) {
114
+ try {
115
+ const key = keys[i].trim();
116
+ const attrs = _instructions(result, key);
117
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
118
+ break;
119
+ } catch (error) {
120
+ if (i + 1 >= length) {
121
+ throw error;
122
+ }
123
+ }
124
+ }
125
+ return DotenvModule.parse(decrypted);
126
+ }
127
+ function _warn(message) {
128
+ console.error(`⚠ ${message}`);
129
+ }
130
+ function _debug(message) {
131
+ console.log(`┆ ${message}`);
132
+ }
133
+ function _log(message) {
134
+ console.log(`◇ ${message}`);
135
+ }
136
+ function _dotenvKey(options) {
137
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
138
+ return options.DOTENV_KEY;
139
+ }
140
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
141
+ return process.env.DOTENV_KEY;
142
+ }
143
+ return "";
144
+ }
145
+ function _instructions(result, dotenvKey) {
146
+ let uri;
147
+ try {
148
+ uri = new URL(dotenvKey);
149
+ } catch (error) {
150
+ if (error.code === "ERR_INVALID_URL") {
151
+ 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");
152
+ err.code = "INVALID_DOTENV_KEY";
153
+ throw err;
154
+ }
155
+ throw error;
156
+ }
157
+ const key = uri.password;
158
+ if (!key) {
159
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
160
+ err.code = "INVALID_DOTENV_KEY";
161
+ throw err;
162
+ }
163
+ const environment = uri.searchParams.get("environment");
164
+ if (!environment) {
165
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
166
+ err.code = "INVALID_DOTENV_KEY";
167
+ throw err;
168
+ }
169
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
170
+ const ciphertext = result.parsed[environmentKey];
171
+ if (!ciphertext) {
172
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
173
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
174
+ throw err;
175
+ }
176
+ return { ciphertext, key };
177
+ }
178
+ function _vaultPath(options) {
179
+ let possibleVaultPath = null;
180
+ if (options && options.path && options.path.length > 0) {
181
+ if (Array.isArray(options.path)) {
182
+ for (const filepath of options.path) {
183
+ if (fs.existsSync(filepath)) {
184
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
185
+ }
186
+ }
187
+ } else {
188
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
189
+ }
190
+ } else {
191
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
192
+ }
193
+ if (fs.existsSync(possibleVaultPath)) {
194
+ return possibleVaultPath;
195
+ }
196
+ return null;
197
+ }
198
+ function _resolveHome(envPath) {
199
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
200
+ }
201
+ function _configVault(options) {
202
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
203
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
204
+ if (debug || !quiet) {
205
+ _log("loading env from encrypted .env.vault");
206
+ }
207
+ const parsed = DotenvModule._parseVault(options);
208
+ let processEnv = process.env;
209
+ if (options && options.processEnv != null) {
210
+ processEnv = options.processEnv;
211
+ }
212
+ DotenvModule.populate(processEnv, parsed, options);
213
+ return { parsed };
214
+ }
215
+ function configDotenv(options) {
216
+ const dotenvPath = path.resolve(process.cwd(), ".env");
217
+ let encoding = "utf8";
218
+ let processEnv = process.env;
219
+ if (options && options.processEnv != null) {
220
+ processEnv = options.processEnv;
221
+ }
222
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
223
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
224
+ if (options && options.encoding) {
225
+ encoding = options.encoding;
226
+ } else {
227
+ if (debug) {
228
+ _debug("no encoding is specified (UTF-8 is used by default)");
229
+ }
230
+ }
231
+ let optionPaths = [dotenvPath];
232
+ if (options && options.path) {
233
+ if (!Array.isArray(options.path)) {
234
+ optionPaths = [_resolveHome(options.path)];
235
+ } else {
236
+ optionPaths = [];
237
+ for (const filepath of options.path) {
238
+ optionPaths.push(_resolveHome(filepath));
239
+ }
240
+ }
241
+ }
242
+ let lastError;
243
+ const parsedAll = {};
244
+ for (const path2 of optionPaths) {
245
+ try {
246
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
247
+ DotenvModule.populate(parsedAll, parsed, options);
248
+ } catch (e) {
249
+ if (debug) {
250
+ _debug(`failed to load ${path2} ${e.message}`);
251
+ }
252
+ lastError = e;
253
+ }
254
+ }
255
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
256
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
257
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
258
+ if (debug || !quiet) {
259
+ const keysCount = Object.keys(populated).length;
260
+ const shortPaths = [];
261
+ for (const filePath of optionPaths) {
262
+ try {
263
+ const relative = path.relative(process.cwd(), filePath);
264
+ shortPaths.push(relative);
265
+ } catch (e) {
266
+ if (debug) {
267
+ _debug(`failed to load ${filePath} ${e.message}`);
268
+ }
269
+ lastError = e;
270
+ }
271
+ }
272
+ _log(`injected env (${keysCount}) from ${shortPaths.join(",")} ${dim(`// tip: ${_getRandomTip()}`)}`);
273
+ }
274
+ if (lastError) {
275
+ return { parsed: parsedAll, error: lastError };
276
+ } else {
277
+ return { parsed: parsedAll };
278
+ }
279
+ }
280
+ function config(options) {
281
+ if (_dotenvKey(options).length === 0) {
282
+ return DotenvModule.configDotenv(options);
283
+ }
284
+ const vaultPath = _vaultPath(options);
285
+ if (!vaultPath) {
286
+ _warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
287
+ return DotenvModule.configDotenv(options);
288
+ }
289
+ return DotenvModule._configVault(options);
290
+ }
291
+ function decrypt(encrypted, keyStr) {
292
+ const key = Buffer.from(keyStr.slice(-64), "hex");
293
+ let ciphertext = Buffer.from(encrypted, "base64");
294
+ const nonce = ciphertext.subarray(0, 12);
295
+ const authTag = ciphertext.subarray(-16);
296
+ ciphertext = ciphertext.subarray(12, -16);
297
+ try {
298
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
299
+ aesgcm.setAuthTag(authTag);
300
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
301
+ } catch (error) {
302
+ const isRange = error instanceof RangeError;
303
+ const invalidKeyLength = error.message === "Invalid key length";
304
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
305
+ if (isRange || invalidKeyLength) {
306
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
307
+ err.code = "INVALID_DOTENV_KEY";
308
+ throw err;
309
+ } else if (decryptionFailed) {
310
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
311
+ err.code = "DECRYPTION_FAILED";
312
+ throw err;
313
+ } else {
314
+ throw error;
315
+ }
316
+ }
317
+ }
318
+ function populate(processEnv, parsed, options = {}) {
319
+ const debug = Boolean(options && options.debug);
320
+ const override = Boolean(options && options.override);
321
+ const populated = {};
322
+ if (typeof parsed !== "object") {
323
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
324
+ err.code = "OBJECT_REQUIRED";
325
+ throw err;
326
+ }
327
+ for (const key of Object.keys(parsed)) {
328
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
329
+ if (override === true) {
330
+ processEnv[key] = parsed[key];
331
+ populated[key] = parsed[key];
332
+ }
333
+ if (debug) {
334
+ if (override === true) {
335
+ _debug(`"${key}" is already defined and WAS overwritten`);
336
+ } else {
337
+ _debug(`"${key}" is already defined and was NOT overwritten`);
338
+ }
339
+ }
340
+ } else {
341
+ processEnv[key] = parsed[key];
342
+ populated[key] = parsed[key];
343
+ }
344
+ }
345
+ return populated;
346
+ }
347
+ var DotenvModule = {
348
+ configDotenv,
349
+ _configVault,
350
+ _parseVault,
351
+ config,
352
+ decrypt,
353
+ parse,
354
+ populate
355
+ };
356
+ module.exports.configDotenv = DotenvModule.configDotenv;
357
+ module.exports._configVault = DotenvModule._configVault;
358
+ module.exports._parseVault = DotenvModule._parseVault;
359
+ module.exports.config = DotenvModule.config;
360
+ module.exports.decrypt = DotenvModule.decrypt;
361
+ module.exports.parse = DotenvModule.parse;
362
+ module.exports.populate = DotenvModule.populate;
363
+ module.exports = DotenvModule;
364
+ });
365
+
366
+ // src/cli.ts
367
+ var import_dotenv = __toESM(require_main(), 1);
31
368
  // package.json
32
369
  var package_default2 = {
33
370
  author: "Pensar",
@@ -47,6 +384,10 @@ var package_default2 = {
47
384
  "@modelcontextprotocol/sdk": "^1.29.0",
48
385
  "@openrouter/ai-sdk-provider": "^2.9.1",
49
386
  "@opentelemetry/api": "^1.9.1",
387
+ "@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
388
+ "@opentelemetry/otlp-exporter-base": "^0.221.0",
389
+ "@opentelemetry/otlp-transformer": "^0.221.0",
390
+ "@opentelemetry/resources": "^2.10.0",
50
391
  "@opentui/core": "^0.1.107",
51
392
  "@opentui/react": "^0.1.107",
52
393
  "@pensar/surface": "0.3.0",
@@ -70,6 +411,8 @@ var package_default2 = {
70
411
  description: "AI-powered penetration testing CLI tool with terminal UI",
71
412
  devDependencies: {
72
413
  "@biomejs/biome": "2.4.14",
414
+ "@opentelemetry/context-async-hooks": "^2.10.0",
415
+ "@opentelemetry/sdk-trace-base": "^2.10.0",
73
416
  "@types/bun": "^1.3.14",
74
417
  "@types/mailparser": "^3.4.6",
75
418
  "@types/mime-types": "^3.0.1",
@@ -116,7 +459,7 @@ var package_default2 = {
116
459
  url: "https://github.com/pensarai/apex.git"
117
460
  },
118
461
  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",
462
+ 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
463
  "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
464
  "build:binary": "bun run generate:ascii && bun build src/cli.ts --compile --external electron --external chromium-bidi --external camoufox-js --outfile pensar",
122
465
  "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,11 +487,12 @@ var package_default2 = {
144
487
  tsc: "tsc --noEmit"
145
488
  },
146
489
  type: "module",
147
- version: "2.3.0"
490
+ version: "2.4.0-canary.01e519de"
148
491
  };
149
492
 
150
493
  // src/core/ai/index.ts
151
494
  init_ai();
495
+ init_model_history();
152
496
  init_models();
153
497
  init_utils();
154
498
 
@@ -299,13 +643,18 @@ class AgentEventBus {
299
643
  });
300
644
  break;
301
645
  case "reasoning-start":
302
- this.emit("reasoning-start", { subagentId });
646
+ this.emit("reasoning-start", { subagentId, sessionId, messageId });
303
647
  break;
304
648
  case "reasoning-delta":
305
- this.emit("reasoning-delta", { text: chunk.text, subagentId });
649
+ this.emit("reasoning-delta", {
650
+ text: chunk.text,
651
+ subagentId,
652
+ sessionId,
653
+ messageId
654
+ });
306
655
  break;
307
656
  case "reasoning-end":
308
- this.emit("reasoning-end", { subagentId });
657
+ this.emit("reasoning-end", { subagentId, sessionId, messageId });
309
658
  break;
310
659
  case "tool-input-start":
311
660
  this.emit("tool-call-start", {
@@ -503,6 +852,103 @@ import os from "node:os";
503
852
  import path from "node:path";
504
853
  var ERROR_LOG_PATH = path.join(os.homedir(), ".pensar", "error.log");
505
854
 
855
+ // src/core/observability/runtime.ts
856
+ init_package();
857
+ var import_api = __toESM(require_src(), 1);
858
+ var import_context_async_hooks = __toESM(require_src2(), 1);
859
+ var import_exporter_trace_otlp_http = __toESM(require_src6(), 1);
860
+ var import_otlp_exporter_base = __toESM(require_src3(), 1);
861
+ var import_node_http = __toESM(require_index_node_http(), 1);
862
+ var import_otlp_transformer = __toESM(require_src5(), 1);
863
+ var import_resources = __toESM(require_src4(), 1);
864
+ var import_sdk_trace_base = __toESM(require_index_shim(), 1);
865
+ import { randomUUID } from "node:crypto";
866
+ var NOOP_RUNTIME = {
867
+ async forceFlush() {},
868
+ async shutdown() {}
869
+ };
870
+ function isOtelSdkDisabled(env) {
871
+ return env.OTEL_SDK_DISABLED === "true";
872
+ }
873
+ function resolveTracesEndpoint(env) {
874
+ const specific = env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT?.trim();
875
+ if (specific)
876
+ return specific;
877
+ const generic = env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();
878
+ if (!generic)
879
+ return null;
880
+ return `${generic.endsWith("/") ? generic : `${generic}/`}v1/traces`;
881
+ }
882
+ function resolveTracesProtocol(env) {
883
+ const raw = (env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL ?? env.OTEL_EXPORTER_OTLP_PROTOCOL ?? "").trim();
884
+ return raw === "http/protobuf" ? "http/protobuf" : "http/json";
885
+ }
886
+ function parseResourceAttributes(env) {
887
+ const raw = env.OTEL_RESOURCE_ATTRIBUTES;
888
+ if (!raw)
889
+ return {};
890
+ const attrs = {};
891
+ for (const pair of raw.split(",")) {
892
+ const eq = pair.indexOf("=");
893
+ if (eq <= 0)
894
+ continue;
895
+ const key = pair.slice(0, eq).trim();
896
+ const value = pair.slice(eq + 1).trim();
897
+ if (key && value)
898
+ attrs[key] = value;
899
+ }
900
+ return attrs;
901
+ }
902
+ function buildResource(env) {
903
+ const resourceAttributes = parseResourceAttributes(env);
904
+ return import_resources.resourceFromAttributes({
905
+ "service.version": version,
906
+ "service.instance.id": randomUUID(),
907
+ ...resourceAttributes,
908
+ "service.name": env.OTEL_SERVICE_NAME?.trim() || resourceAttributes["service.name"] || "apex"
909
+ });
910
+ }
911
+ function createTraceExporter(protocol) {
912
+ if (protocol === "http/json") {
913
+ return new import_exporter_trace_otlp_http.OTLPTraceExporter;
914
+ }
915
+ return new import_otlp_exporter_base.OTLPExporterBase(import_node_http.createOtlpHttpExportDelegate(import_node_http.convertLegacyHttpOptions({}, "TRACES", "v1/traces", {
916
+ "Content-Type": "application/x-protobuf"
917
+ }), import_otlp_transformer.ProtobufTraceSerializer, "otlp_http_span_exporter", import_otlp_transformer.TraceExporterMetricsHelper, undefined));
918
+ }
919
+ var activeRuntime = null;
920
+ function startObservabilityRuntime(env = process.env) {
921
+ if (activeRuntime)
922
+ return activeRuntime;
923
+ if (isOtelSdkDisabled(env))
924
+ return NOOP_RUNTIME;
925
+ if (!resolveTracesEndpoint(env))
926
+ return NOOP_RUNTIME;
927
+ const exporter = createTraceExporter(resolveTracesProtocol(env));
928
+ const provider = new import_sdk_trace_base.BasicTracerProvider({
929
+ resource: buildResource(env),
930
+ spanProcessors: [new import_sdk_trace_base.BatchSpanProcessor(exporter)]
931
+ });
932
+ const contextManager = new import_context_async_hooks.AsyncLocalStorageContextManager;
933
+ contextManager.enable();
934
+ import_api.trace.setGlobalTracerProvider(provider);
935
+ import_api.context.setGlobalContextManager(contextManager);
936
+ const runtime = {
937
+ async forceFlush() {
938
+ await provider.forceFlush();
939
+ },
940
+ async shutdown() {
941
+ activeRuntime = null;
942
+ await provider.shutdown();
943
+ contextManager.disable();
944
+ import_api.trace.disable();
945
+ import_api.context.disable();
946
+ }
947
+ };
948
+ activeRuntime = runtime;
949
+ return runtime;
950
+ }
951
+
506
952
  // src/tui/utils/command-flags.ts
507
953
  import { readFileSync } from "node:fs";
508
954
  import { isAbsolute, resolve } from "node:path";
@@ -532,7 +978,8 @@ function resolveThreatModelPrompt(value) {
532
978
 
533
979
  // src/cli.ts
534
980
  var args = process.argv.slice(2);
535
- var version = package_default2.version;
981
+ var version2 = package_default2.version;
982
+ import_dotenv.config();
536
983
  var OBFUSCATE_FLAGS = new Set(["--obfuscate", "--redact", "-O"]);
537
984
  var obfuscateRequested = args.some((a) => OBFUSCATE_FLAGS.has(a));
538
985
  if (obfuscateRequested) {
@@ -587,7 +1034,7 @@ function attachCliAgentStreamListeners(bus) {
587
1034
  async function createInstrumentedBus(session) {
588
1035
  const bus = new AgentEventBus;
589
1036
  attachCliAgentStreamListeners(bus);
590
- const { attachWandbToEventBus } = await import("./upload-krd8bnex.js");
1037
+ const { attachWandbToEventBus } = await import("./upload-vwnzgrh6.js");
591
1038
  const wandbCleanup = await attachWandbToEventBus(session, bus).catch((e) => {
592
1039
  console.warn("[wandb] Tracing disabled:", e.message);
593
1040
  return null;
@@ -601,10 +1048,10 @@ async function resolveCliHeaders() {
601
1048
  if (headerArgs.length === 0 && !headersFromArg && !noGlobal) {
602
1049
  return;
603
1050
  }
604
- const { parseHeaderLine: parseHeaderLine2, parseHeadersFromFile, formatParseError: formatParseError2 } = await import("./parse-7djk9jyf.js");
1051
+ const { parseHeaderLine: parseHeaderLine2, parseHeadersFromFile, formatParseError: formatParseError2 } = await import("./parse-rtccymzn.js");
605
1052
  const merged = {};
606
1053
  if (!noGlobal) {
607
- const { config: appConfig } = await import("./index-32hn8rrw.js");
1054
+ const { config: appConfig } = await import("./index-cf1rrakg.js");
608
1055
  const cfg = await appConfig.get();
609
1056
  if (cfg.defaultHeaders) {
610
1057
  Object.assign(merged, cfg.defaultHeaders);
@@ -638,8 +1085,8 @@ async function resolveCliModel() {
638
1085
  const explicit = getArg("--model");
639
1086
  if (explicit)
640
1087
  return explicit;
641
- const { config: appConfig } = await import("./index-32hn8rrw.js");
642
- const { getDefaultModelForConfig } = await import("./utils-skmqhyfg.js");
1088
+ const { config: appConfig } = await import("./index-cf1rrakg.js");
1089
+ const { getDefaultModelForConfig } = await import("./utils-132nk1dd.js");
643
1090
  const pensarConfig = await appConfig.get();
644
1091
  const defaultModel = getDefaultModelForConfig(pensarConfig);
645
1092
  if (!defaultModel) {
@@ -648,6 +1095,7 @@ async function resolveCliModel() {
648
1095
  ` + ` ANTHROPIC_API_KEY \u2014 Anthropic direct
649
1096
  ` + ` OPENAI_API_KEY \u2014 OpenAI
650
1097
  ` + ` OPENROUTER_API_KEY \u2014 OpenRouter
1098
+ ` + ` CONCENTRATE_API_KEY \u2014 Concentrate
651
1099
  ` + `
652
1100
  Or run 'pensar login' to connect to Pensar Console.`);
653
1101
  process.exit(1);
@@ -725,11 +1173,9 @@ Global options:
725
1173
  `);
726
1174
  }
727
1175
  async function runPentest() {
728
- const { config } = await import("./main-3d7dfdvs.js").then((m)=>__toESM(m.default,1));
729
- config();
730
- const { runPentestAgent } = await import("./blackboxPentest-tgc2t3y6.js");
731
- const { sessions: sessions2 } = await import("./index-e8c8zcrf.js");
732
- const { config: appConfig } = await import("./index-32hn8rrw.js");
1176
+ const { runPentestAgent } = await import("./blackboxPentest-3nass7dk.js");
1177
+ const { sessions: sessions2 } = await import("./index-t9q6d8ff.js");
1178
+ const { config: appConfig } = await import("./index-cf1rrakg.js");
733
1179
  const target = getArgRequired("--target");
734
1180
  const cwd = getArg("--cwd");
735
1181
  const mode = getArg("--mode");
@@ -800,14 +1246,11 @@ Report: ${reportPath}` : ""}`);
800
1246
  } finally {
801
1247
  await wandbCleanup();
802
1248
  }
803
- process.exit(0);
804
1249
  }
805
1250
  async function runTargetedPentest() {
806
- const { config } = await import("./main-3d7dfdvs.js").then((m)=>__toESM(m.default,1));
807
- config();
808
- const { runTargetedPentestAgent } = await import("./targetedPentest-me4jnr3z.js");
809
- const { sessions: sessions2 } = await import("./index-e8c8zcrf.js");
810
- const { config: appConfig } = await import("./index-32hn8rrw.js");
1251
+ const { runTargetedPentestAgent } = await import("./targetedPentest-n33mm8bp.js");
1252
+ const { sessions: sessions2 } = await import("./index-t9q6d8ff.js");
1253
+ const { config: appConfig } = await import("./index-cf1rrakg.js");
811
1254
  const target = getArgRequired("--target");
812
1255
  const objectives = getAllArgs("--objective");
813
1256
  const pensarConfig = await appConfig.get();
@@ -854,13 +1297,10 @@ POCs: ${pocsPath}`);
854
1297
  } finally {
855
1298
  await wandbCleanup();
856
1299
  }
857
- process.exit(0);
858
1300
  }
859
1301
  async function runThreatModel() {
860
- const { config } = await import("./main-3d7dfdvs.js").then((m)=>__toESM(m.default,1));
861
- config();
862
- const { runThreatModelWorkflow } = await import("./threatModel-k4f3zgqd.js");
863
- const { config: appConfig } = await import("./index-32hn8rrw.js");
1302
+ const { runThreatModelWorkflow } = await import("./threatModel-wmp658sv.js");
1303
+ const { config: appConfig } = await import("./index-cf1rrakg.js");
864
1304
  const path2 = await import("path");
865
1305
  const pensarConfig = await appConfig.get();
866
1306
  const model = await resolveCliModel();
@@ -894,16 +1334,14 @@ ${sep}
894
1334
  Threat model written to: ${resolvedPath}`);
895
1335
  }
896
1336
  async function runOperator() {
897
- const { config } = await import("./main-3d7dfdvs.js").then((m)=>__toESM(m.default,1));
898
- config();
899
- const { runOffensiveSecurityAgent } = await import("./offesecAgent-8ky7gccp.js");
900
- const { sessions: sessions2, normalizeMessages, getResumeMessages } = await import("./index-e8c8zcrf.js");
901
- const { ALL_TOOL_NAMES, SKILL_TOOL_NAMES } = await import("./index-468j74f3.js");
902
- const { config: appConfig } = await import("./index-32hn8rrw.js");
1337
+ const { runOffensiveSecurityAgent } = await import("./offesecAgent-cvjy788j.js");
1338
+ const { sessions: sessions2, normalizeMessages, getResumeMessages } = await import("./index-t9q6d8ff.js");
1339
+ const { ALL_TOOL_NAMES, SKILL_TOOL_NAMES } = await import("./index-50aysats.js");
1340
+ const { config: appConfig } = await import("./index-cf1rrakg.js");
903
1341
  const { createInterface } = await import("readline");
904
1342
  const { readFileSync: readFileSync2, existsSync } = await import("fs");
905
1343
  const path2 = await import("path");
906
- const { stepCountIs } = await import("./index-gq9h8j5j.js");
1344
+ const { stepCountIs } = await import("./index-5wh7gq37.js");
907
1345
  const promptRaw = getArg("-p") ?? getArg("--prompt");
908
1346
  if (!promptRaw) {
909
1347
  console.error("Error: -p <prompt> is required");
@@ -999,60 +1437,70 @@ Checking for updates...`);
999
1437
  ${result.message}`);
1000
1438
  process.exit(result.success ? 0 : 1);
1001
1439
  }
1002
- if (hasFlag("-p") || command === "--prompt") {
1003
- await runOperator();
1004
- } else if (command === "version" || command === "--version" || command === "-v") {
1005
- console.log(`v${version}`);
1006
- } else if (command === "help" || command === "--help" || command === "-h") {
1007
- showHelp();
1008
- } else if (command === "upgrade" || command === "update") {
1009
- await runUpgrade2();
1010
- } else if (command === "pentest") {
1011
- await runPentest();
1012
- } else if (command === "targeted-pentest") {
1013
- await runTargetedPentest();
1014
- } else if (command === "login" || command === "auth") {
1015
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1016
- await import("./auth-c1z670rx.js");
1017
- } else if (command === "uninstall") {
1018
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1019
- await import("./uninstall-jt1bca2p.js");
1020
- } else if (command === "apps") {
1021
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1022
- await import("./apps-43pqbz7r.js");
1023
- } else if (command === "pentests") {
1024
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1025
- await import("./pentests-62d6zw6p.js");
1026
- } else if (command === "targets") {
1027
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1028
- await import("./targets-e5k1mrky.js");
1029
- } else if (command === "issues") {
1030
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1031
- await import("./issues-kh4wg8c5.js");
1032
- } else if (command === "fixes") {
1033
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1034
- await import("./fixes-86yebsj0.js");
1035
- } else if (command === "logs") {
1036
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1037
- await import("./logs-bj28xmbf.js");
1038
- } else if (command === "config") {
1039
- process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1040
- await import("./config-jzqjz606.js");
1041
- } else if (command === "threat-model") {
1042
- await runThreatModel();
1043
- } else if (command === "doctor") {
1044
- const { runDoctor } = await import("./doctor-q3qws68e.js");
1045
- await runDoctor();
1046
- } else if (args.length === 0) {
1047
- if (process.env.PENSAR_NO_TUI === "1") {
1048
- console.error("TUI mode requires Bun. Install Bun (https://bun.sh) or use a standalone binary release for interactive mode.");
1049
- console.error("All other commands work with Node \u2014 run 'pensar --help'.");
1440
+ var observabilityRuntime = startObservabilityRuntime();
1441
+ try {
1442
+ if (hasFlag("-p") || command === "--prompt") {
1443
+ await runOperator();
1444
+ } else if (command === "version" || command === "--version" || command === "-v") {
1445
+ console.log(`v${version2}`);
1446
+ } else if (command === "help" || command === "--help" || command === "-h") {
1447
+ showHelp();
1448
+ } else if (command === "upgrade" || command === "update") {
1449
+ await runUpgrade2();
1450
+ } else if (command === "pentest") {
1451
+ await runPentest();
1452
+ } else if (command === "targeted-pentest") {
1453
+ await runTargetedPentest();
1454
+ } else if (command === "login" || command === "auth") {
1455
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1456
+ await import("./auth-3k12kd2j.js");
1457
+ } else if (command === "uninstall") {
1458
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1459
+ await import("./uninstall-jvk3gtnx.js");
1460
+ } else if (command === "apps") {
1461
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1462
+ await import("./apps-6595cxzf.js");
1463
+ } else if (command === "pentests") {
1464
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1465
+ await import("./pentests-cs7km4sy.js");
1466
+ } else if (command === "targets") {
1467
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1468
+ await import("./targets-8nq8d33w.js");
1469
+ } else if (command === "issues") {
1470
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1471
+ await import("./issues-015zf705.js");
1472
+ } else if (command === "fixes") {
1473
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1474
+ await import("./fixes-3rvsps8m.js");
1475
+ } else if (command === "logs") {
1476
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1477
+ await import("./logs-ra7c7my0.js");
1478
+ } else if (command === "config") {
1479
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
1480
+ await import("./config-52zkpmx4.js");
1481
+ } else if (command === "threat-model") {
1482
+ await runThreatModel();
1483
+ } else if (command === "doctor") {
1484
+ const { runDoctor } = await import("./doctor-5eyfxzvy.js");
1485
+ await runDoctor();
1486
+ } else if (args.length === 0) {
1487
+ if (process.env.PENSAR_NO_TUI === "1") {
1488
+ console.error("TUI mode requires Bun. Install Bun (https://bun.sh) or use a standalone binary release for interactive mode.");
1489
+ console.error("All other commands work with Node \u2014 run 'pensar --help'.");
1490
+ process.exit(1);
1491
+ }
1492
+ await import("./index-zhscmpd1.js");
1493
+ } else {
1494
+ console.error(`Error: Unknown command '${command}'`);
1495
+ console.error();
1496
+ console.error("Run 'pensar --help' for usage information");
1050
1497
  process.exit(1);
1051
1498
  }
1052
- await import("./index-97vx1a24.js");
1053
- } else {
1054
- console.error(`Error: Unknown command '${command}'`);
1055
- console.error();
1056
- console.error("Run 'pensar --help' for usage information");
1057
- process.exit(1);
1499
+ } finally {
1500
+ if (args.length !== 0) {
1501
+ await observabilityRuntime.shutdown().catch(() => {});
1502
+ }
1503
+ }
1504
+ if (command === "pentest" || command === "targeted-pentest") {
1505
+ process.exit(0);
1058
1506
  }