@pensar/apex 0.0.111 → 0.0.112

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 (64) hide show
  1. package/README.md +2 -3
  2. package/bin/pensar.js +31 -276
  3. package/build/agent-5qdmmchx.js +206 -0
  4. package/build/agent-s2z0dasf.js +16 -0
  5. package/build/auth-jvq72ekc.js +263 -0
  6. package/build/authentication-nya4td5k.js +310 -0
  7. package/build/blackboxAgent-qa9ze2hn.js +17 -0
  8. package/build/blackboxPentest-85hwznet.js +41 -0
  9. package/build/cli-15vxn9zj.js +1358 -0
  10. package/build/cli-2ckm5es2.js +50 -0
  11. package/build/cli-49cd9yfk.js +4475 -0
  12. package/build/cli-5d6cs4dq.js +53 -0
  13. package/build/cli-6gtnyaqf.js +109 -0
  14. package/build/cli-7ckctq7a.js +45 -0
  15. package/build/cli-8rxa073f.js +104 -0
  16. package/build/cli-bp6d08sg.js +110 -0
  17. package/build/cli-e20q3hqz.js +307 -0
  18. package/build/cli-f9shhcxf.js +1498 -0
  19. package/build/cli-hmrzx8am.js +507 -0
  20. package/build/cli-j66pect7.js +202 -0
  21. package/build/cli-jb0gcnrs.js +60 -0
  22. package/build/cli-jh38b6zv.js +1074 -0
  23. package/build/cli-kqtgcdzn.js +54784 -0
  24. package/build/cli-r8r90gka.js +96700 -0
  25. package/build/cli-va4y0089.js +395 -0
  26. package/build/cli-w04ggbe4.js +104 -0
  27. package/build/cli-x1msjf55.js +103 -0
  28. package/build/cli-yj3dy0vg.js +180 -0
  29. package/build/cli.js +509 -0
  30. package/build/doctor-b7612pzw.js +117 -0
  31. package/build/fixes-1r6v7kh2.js +49 -0
  32. package/build/index-5ke2yd32.js +17 -0
  33. package/build/index-9ze42wn7.js +68412 -0
  34. package/build/index-rd11fk7h.js +1257 -0
  35. package/build/index-tke6896d.js +1097 -0
  36. package/build/index-vwvh1rdw.js +535 -0
  37. package/build/issues-kx721wja.js +94 -0
  38. package/build/logs-hav7d0nm.js +77 -0
  39. package/build/main-2483qzbq.js +397 -0
  40. package/build/multipart-parser-r38qdp5v.js +350 -0
  41. package/build/pentest-zzebnfa0.js +25 -0
  42. package/build/pentests-s9fwd71b.js +70 -0
  43. package/build/projects-tr719twv.js +35 -0
  44. package/build/targetedPentest-w2c85whf.js +32 -0
  45. package/build/token-6x6aavpc.js +58 -0
  46. package/build/token-util-na95bqjj.js +6 -0
  47. package/build/uninstall-2j0pymb0.js +231 -0
  48. package/build/utils-jky0th19.js +107 -0
  49. package/package.json +3 -4
  50. package/build/auth.js +0 -625
  51. package/build/highlights-eq9cgrbb.scm +0 -604
  52. package/build/highlights-ghv9g403.scm +0 -205
  53. package/build/highlights-hk7bwhj4.scm +0 -284
  54. package/build/highlights-r812a2qc.scm +0 -150
  55. package/build/highlights-x6tmsnaa.scm +0 -115
  56. package/build/index.js +0 -292069
  57. package/build/injections-73j83es3.scm +0 -27
  58. package/build/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
  59. package/build/tree-sitter-markdown-411r6y9b.wasm +0 -0
  60. package/build/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
  61. package/build/tree-sitter-typescript-zxjzwt75.wasm +0 -0
  62. package/build/tree-sitter-zig-e78zbjpm.wasm +0 -0
  63. package/src/core/installation/index.ts +0 -223
  64. package/src/core/installation/installation.test.ts +0 -454
@@ -0,0 +1,53 @@
1
+ // src/core/providers/types.ts
2
+ var AVAILABLE_PROVIDERS = [
3
+ {
4
+ id: "anthropic",
5
+ name: "Anthropic",
6
+ description: "Claude Pro/Max or API key",
7
+ requiresAPIKey: true
8
+ },
9
+ {
10
+ id: "openai",
11
+ name: "OpenAI",
12
+ description: "GPT-4 and other OpenAI models",
13
+ requiresAPIKey: true
14
+ },
15
+ {
16
+ id: "google",
17
+ name: "Google",
18
+ description: "Gemini and other Google AI models",
19
+ requiresAPIKey: true
20
+ },
21
+ {
22
+ id: "openrouter",
23
+ name: "OpenRouter",
24
+ description: "Access multiple AI models through one API",
25
+ requiresAPIKey: true
26
+ },
27
+ {
28
+ id: "inception",
29
+ name: "Inception",
30
+ description: "Mercury and other Inception models",
31
+ requiresAPIKey: true
32
+ },
33
+ {
34
+ id: "bedrock",
35
+ name: "AWS Bedrock",
36
+ description: "Amazon Bedrock AI models",
37
+ requiresAPIKey: true
38
+ },
39
+ {
40
+ id: "local",
41
+ name: "Local LLM",
42
+ description: "OpenAI-compatible local model (vLLM, LM Studio, Ollama)",
43
+ requiresAPIKey: false
44
+ },
45
+ {
46
+ id: "pensar",
47
+ name: "Pensar",
48
+ description: "Managed inference via Pensar Console (usage-based billing)",
49
+ requiresAPIKey: false
50
+ }
51
+ ];
52
+
53
+ export { AVAILABLE_PROVIDERS };
@@ -0,0 +1,109 @@
1
+ // src/core/agents/specialized/utils.ts
2
+ import { readFileSync, existsSync } from "fs";
3
+ import { execSync } from "child_process";
4
+ function readOsRelease() {
5
+ try {
6
+ const content = readFileSync("/etc/os-release", "utf8");
7
+ const lines = content.split(/\r?\n/);
8
+ const map = {};
9
+ for (const line of lines) {
10
+ const idx = line.indexOf("=");
11
+ if (idx === -1)
12
+ continue;
13
+ const key = line.slice(0, idx);
14
+ let value = line.slice(idx + 1);
15
+ if (value.startsWith('"') && value.endsWith('"')) {
16
+ value = value.slice(1, -1);
17
+ }
18
+ map[key] = value;
19
+ }
20
+ return map;
21
+ } catch {
22
+ return {};
23
+ }
24
+ }
25
+ function detectDocker() {
26
+ try {
27
+ if (existsSync("/.dockerenv"))
28
+ return true;
29
+ } catch {}
30
+ try {
31
+ const cgroup = readFileSync("/proc/1/cgroup", "utf8");
32
+ if (/docker|containerd|kubepods/i.test(cgroup))
33
+ return true;
34
+ } catch {}
35
+ return false;
36
+ }
37
+ function toolExists(commandName) {
38
+ try {
39
+ execSync(`command -v ${commandName} >/dev/null 2>&1`, {
40
+ stdio: "ignore",
41
+ shell: "/bin/bash"
42
+ });
43
+ return true;
44
+ } catch {
45
+ try {
46
+ execSync(`which ${commandName} >/dev/null 2>&1`, {
47
+ stdio: "ignore",
48
+ shell: "/bin/bash"
49
+ });
50
+ return true;
51
+ } catch {
52
+ return false;
53
+ }
54
+ }
55
+ }
56
+ function detectEnvironment() {
57
+ const osRelease = readOsRelease();
58
+ const prettyName = osRelease["PRETTY_NAME"];
59
+ const id = osRelease["ID"]?.toLowerCase();
60
+ const idLike = osRelease["ID_LIKE"];
61
+ const isKali = Boolean(id && /kali/.test(id) || prettyName && /kali/i.test(prettyName));
62
+ const isDocker = detectDocker();
63
+ const toolsToCheck = [
64
+ "nmap",
65
+ "gobuster",
66
+ "sqlmap",
67
+ "nikto",
68
+ "hydra",
69
+ "john",
70
+ "hashcat",
71
+ "tcpdump",
72
+ "tshark",
73
+ "nc",
74
+ "socat",
75
+ "curl",
76
+ "wget",
77
+ "git"
78
+ ];
79
+ const availableTools = [];
80
+ const missingTools = [];
81
+ for (const tool of toolsToCheck) {
82
+ (toolExists(tool) ? availableTools : missingTools).push(tool);
83
+ }
84
+ return { isDocker, isKali, prettyName, idLike, availableTools, missingTools };
85
+ }
86
+ function detectOSAndEnhancePrompt(prompt) {
87
+ try {
88
+ const env = detectEnvironment();
89
+ const lines = [];
90
+ lines.push("[ENV CONTEXT]");
91
+ lines.push(`OS: ${env.prettyName ?? process.platform} | InDocker: ${env.isDocker ? "yes" : "no"} | Kali: ${env.isKali ? "yes" : "no"}`);
92
+ if (env.availableTools.length > 0) {
93
+ lines.push(`Tools available: ${env.availableTools.sort().join(", ")}`);
94
+ }
95
+ if (env.missingTools.length > 0) {
96
+ lines.push(`Tools missing: ${env.missingTools.sort().join(", ")}`);
97
+ }
98
+ lines.push(`[/ENV CONTEXT]
99
+ `);
100
+ return `${lines.join(`
101
+ `)}
102
+ ${prompt}`;
103
+ } catch (error) {
104
+ console.error("Error detecting environment:", error);
105
+ return prompt;
106
+ }
107
+ }
108
+
109
+ export { toolExists, detectOSAndEnhancePrompt };
@@ -0,0 +1,45 @@
1
+ import {
2
+ __commonJS
3
+ } from "./cli-8rxa073f.js";
4
+
5
+ // node_modules/@vercel/oidc/dist/token-error.js
6
+ var require_token_error = __commonJS((exports, module) => {
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var token_error_exports = {};
25
+ __export(token_error_exports, {
26
+ VercelOidcTokenError: () => VercelOidcTokenError
27
+ });
28
+ module.exports = __toCommonJS(token_error_exports);
29
+
30
+ class VercelOidcTokenError extends Error {
31
+ constructor(message, cause) {
32
+ super(message);
33
+ this.name = "VercelOidcTokenError";
34
+ this.cause = cause;
35
+ }
36
+ toString() {
37
+ if (this.cause) {
38
+ return `${this.name}: ${this.message}: ${this.cause}`;
39
+ }
40
+ return `${this.name}: ${this.message}`;
41
+ }
42
+ }
43
+ });
44
+
45
+ export { require_token_error };
@@ -0,0 +1,104 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
13
+ var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
21
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
22
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
29
+ if (canCache)
30
+ cache.set(mod, to);
31
+ return to;
32
+ };
33
+ var __toCommonJS = (from) => {
34
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
35
+ if (entry)
36
+ return entry;
37
+ entry = __defProp({}, "__esModule", { value: true });
38
+ if (from && typeof from === "object" || typeof from === "function") {
39
+ for (var key of __getOwnPropNames(from))
40
+ if (!__hasOwnProp.call(entry, key))
41
+ __defProp(entry, key, {
42
+ get: __accessProp.bind(from, key),
43
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
44
+ });
45
+ }
46
+ __moduleCache.set(from, entry);
47
+ return entry;
48
+ };
49
+ var __moduleCache;
50
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
51
+ var __returnValue = (v) => v;
52
+ function __exportSetter(name, newValue) {
53
+ this[name] = __returnValue.bind(null, newValue);
54
+ }
55
+ var __export = (target, all) => {
56
+ for (var name in all)
57
+ __defProp(target, name, {
58
+ get: all[name],
59
+ enumerable: true,
60
+ configurable: true,
61
+ set: __exportSetter.bind(all, name)
62
+ });
63
+ };
64
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
65
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
66
+ var __dispose = Symbol.dispose || /* @__PURE__ */ Symbol.for("Symbol.dispose");
67
+ var __asyncDispose = Symbol.asyncDispose || /* @__PURE__ */ Symbol.for("Symbol.asyncDispose");
68
+ var __using = (stack, value, async) => {
69
+ if (value != null) {
70
+ if (typeof value !== "object" && typeof value !== "function")
71
+ throw TypeError('Object expected to be assigned to "using" declaration');
72
+ var dispose;
73
+ if (async)
74
+ dispose = value[__asyncDispose];
75
+ if (dispose === undefined)
76
+ dispose = value[__dispose];
77
+ if (typeof dispose !== "function")
78
+ throw TypeError("Object not disposable");
79
+ stack.push([async, dispose, value]);
80
+ } else if (async) {
81
+ stack.push([async]);
82
+ }
83
+ return value;
84
+ };
85
+ var __callDispose = (stack, error, hasError) => {
86
+ var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
87
+ return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
88
+ }, fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e), next = (it) => {
89
+ while (it = stack.pop()) {
90
+ try {
91
+ var result = it[1] && it[1].call(it[2]);
92
+ if (it[0])
93
+ return Promise.resolve(result).then(next, (e) => (fail(e), next()));
94
+ } catch (e) {
95
+ fail(e);
96
+ }
97
+ }
98
+ if (hasError)
99
+ throw error;
100
+ };
101
+ return next();
102
+ };
103
+
104
+ export { __toESM, __toCommonJS, __commonJS, __export, __esm, __require, __using, __callDispose };
@@ -0,0 +1,110 @@
1
+ import {
2
+ get,
3
+ init,
4
+ update
5
+ } from "./cli-jb0gcnrs.js";
6
+
7
+ // src/core/api/constants.ts
8
+ var PENSAR_API_BASE_URL = "https://api.pensar.dev";
9
+ var PENSAR_GATEWAY_BASE_URL = "https://gateway.pensar.dev";
10
+ var PENSAR_CONSOLE_BASE_URL = "https://console.pensar.dev";
11
+ function getPensarApiUrl() {
12
+ return process.env.PENSAR_API_URL || PENSAR_API_BASE_URL;
13
+ }
14
+ function getPensarGatewayUrl() {
15
+ return process.env.PENSAR_GATEWAY_URL || PENSAR_GATEWAY_BASE_URL;
16
+ }
17
+ function getPensarConsoleUrl() {
18
+ return process.env.PENSAR_CONSOLE_URL || PENSAR_CONSOLE_BASE_URL;
19
+ }
20
+
21
+ // src/core/config/index.ts
22
+ var config = {
23
+ get,
24
+ init,
25
+ update
26
+ };
27
+
28
+ // src/core/auth/token.ts
29
+ function decodeJwtPayload(token) {
30
+ try {
31
+ const parts = token.split(".");
32
+ if (parts.length !== 3)
33
+ return null;
34
+ const payload = Buffer.from(parts[1], "base64url").toString("utf-8");
35
+ return JSON.parse(payload);
36
+ } catch {
37
+ return null;
38
+ }
39
+ }
40
+ function isTokenExpired(token, bufferSeconds = 60) {
41
+ const payload = decodeJwtPayload(token);
42
+ if (!payload || typeof payload.exp !== "number")
43
+ return true;
44
+ const nowSeconds = Math.floor(Date.now() / 1000);
45
+ return payload.exp - nowSeconds < bufferSeconds;
46
+ }
47
+ var cachedClientId = null;
48
+ async function fetchWorkOSClientId() {
49
+ if (cachedClientId)
50
+ return cachedClientId;
51
+ try {
52
+ const apiUrl = getPensarApiUrl();
53
+ const response = await fetch(`${apiUrl}/api/cli/config`);
54
+ if (!response.ok)
55
+ return null;
56
+ const data = await response.json();
57
+ cachedClientId = data.workosClientId;
58
+ return cachedClientId;
59
+ } catch {
60
+ return null;
61
+ }
62
+ }
63
+ async function refreshAccessToken(clientId, refreshToken) {
64
+ try {
65
+ const response = await fetch("https://api.workos.com/user_management/authenticate", {
66
+ method: "POST",
67
+ headers: { "Content-Type": "application/json" },
68
+ body: JSON.stringify({
69
+ client_id: clientId,
70
+ grant_type: "refresh_token",
71
+ refresh_token: refreshToken
72
+ })
73
+ });
74
+ if (!response.ok) {
75
+ console.error(`[pensar] Token refresh failed: ${response.status} ${response.statusText}`);
76
+ return null;
77
+ }
78
+ const data = await response.json();
79
+ await config.update({
80
+ accessToken: data.access_token,
81
+ refreshToken: data.refresh_token
82
+ });
83
+ return data.access_token;
84
+ } catch (err) {
85
+ console.error("[pensar] Token refresh error:", err);
86
+ return null;
87
+ }
88
+ }
89
+ async function ensureValidToken(cfg) {
90
+ if (cfg.accessToken) {
91
+ if (!isTokenExpired(cfg.accessToken)) {
92
+ return { token: cfg.accessToken, type: "workos" };
93
+ }
94
+ if (cfg.refreshToken) {
95
+ const clientId = await fetchWorkOSClientId();
96
+ if (clientId) {
97
+ const newToken = await refreshAccessToken(clientId, cfg.refreshToken);
98
+ if (newToken) {
99
+ return { token: newToken, type: "workos" };
100
+ }
101
+ }
102
+ }
103
+ }
104
+ if (cfg.pensarAPIKey) {
105
+ return { token: cfg.pensarAPIKey, type: "legacy" };
106
+ }
107
+ return null;
108
+ }
109
+
110
+ export { getPensarApiUrl, getPensarGatewayUrl, getPensarConsoleUrl, config, ensureValidToken };