@pensar/apex 0.0.83 → 0.0.85-canary.0c4c4734
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +109 -15
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -31956,7 +31956,7 @@ var package_default2;
|
|
|
31956
31956
|
var init_package = __esm(() => {
|
|
31957
31957
|
package_default2 = {
|
|
31958
31958
|
name: "@pensar/apex",
|
|
31959
|
-
version: "0.0.
|
|
31959
|
+
version: "0.0.85-canary.0c4c4734",
|
|
31960
31960
|
description: "AI-powered penetration testing CLI tool with terminal UI",
|
|
31961
31961
|
module: "src/tui/index.tsx",
|
|
31962
31962
|
main: "build/index.js",
|
|
@@ -104991,7 +104991,8 @@ var init_createPoc = __esm(() => {
|
|
|
104991
104991
|
|
|
104992
104992
|
// src/core/agents/offSecAgent/tools/readFile.ts
|
|
104993
104993
|
import { readFile as fsReadFile } from "fs/promises";
|
|
104994
|
-
|
|
104994
|
+
import { resolve as resolve6, isAbsolute as isAbsolute2 } from "path";
|
|
104995
|
+
function readFile(ctx4) {
|
|
104995
104996
|
return tool({
|
|
104996
104997
|
description: `Read the contents of a file from the filesystem.
|
|
104997
104998
|
|
|
@@ -105002,8 +105003,9 @@ the end. If only endLine is given, reads from the beginning to that line.
|
|
|
105002
105003
|
Output lines are prefixed with their line number for easy reference.`,
|
|
105003
105004
|
inputSchema: readFileInputSchema,
|
|
105004
105005
|
execute: async ({ path: path6, startLine, endLine }) => {
|
|
105006
|
+
const resolved = isAbsolute2(path6) ? path6 : resolve6(ctx4.session.rootPath, path6);
|
|
105005
105007
|
try {
|
|
105006
|
-
const raw = await fsReadFile(
|
|
105008
|
+
const raw = await fsReadFile(resolved, "utf-8");
|
|
105007
105009
|
const allLines = raw.split(`
|
|
105008
105010
|
`);
|
|
105009
105011
|
const totalLines = allLines.length;
|
|
@@ -105048,7 +105050,7 @@ var init_readFile = __esm(() => {
|
|
|
105048
105050
|
|
|
105049
105051
|
// src/core/agents/offSecAgent/tools/listFiles.ts
|
|
105050
105052
|
import { readdir as readdir2, stat } from "fs/promises";
|
|
105051
|
-
import { join as join12, relative } from "path";
|
|
105053
|
+
import { join as join12, relative, resolve as resolve7, isAbsolute as isAbsolute3 } from "path";
|
|
105052
105054
|
async function listRecursive(dir, maxEntries) {
|
|
105053
105055
|
const results = [];
|
|
105054
105056
|
let total = 0;
|
|
@@ -105082,7 +105084,7 @@ function toRelative(base, paths) {
|
|
|
105082
105084
|
return isDir ? `${rel}/` : rel;
|
|
105083
105085
|
});
|
|
105084
105086
|
}
|
|
105085
|
-
function listFiles(
|
|
105087
|
+
function listFiles(ctx4) {
|
|
105086
105088
|
return tool({
|
|
105087
105089
|
description: `List files and directories at a given path.
|
|
105088
105090
|
|
|
@@ -105098,7 +105100,7 @@ Each directory entry is suffixed with "/" for easy identification.`,
|
|
|
105098
105100
|
directory,
|
|
105099
105101
|
recursive = false
|
|
105100
105102
|
}) => {
|
|
105101
|
-
const dir = directory
|
|
105103
|
+
const dir = directory ? isAbsolute3(directory) ? directory : resolve7(ctx4.session.rootPath, directory) : ctx4.session.rootPath;
|
|
105102
105104
|
try {
|
|
105103
105105
|
const info = await stat(dir);
|
|
105104
105106
|
if (!info.isDirectory()) {
|
|
@@ -105193,6 +105195,7 @@ search with flags or a more specific directory if results are truncated.`,
|
|
|
105193
105195
|
};
|
|
105194
105196
|
}
|
|
105195
105197
|
const dir = directory || ".";
|
|
105198
|
+
const cwd = ctx4.session.rootPath;
|
|
105196
105199
|
const userFlags = flags ? flags.trim().split(/\s+/) : [];
|
|
105197
105200
|
const hasRecursive = userFlags.some((f) => /^-[a-zA-Z]*r[a-zA-Z]*$/.test(f) || f === "--recursive");
|
|
105198
105201
|
const defaultFlags = hasRecursive ? [] : ["-r"];
|
|
@@ -105200,6 +105203,7 @@ search with flags or a more specific directory if results are truncated.`,
|
|
|
105200
105203
|
const command = `grep ${args.join(" ")}`;
|
|
105201
105204
|
return new Promise((resolve4) => {
|
|
105202
105205
|
const child = spawn3("grep", args, {
|
|
105206
|
+
cwd,
|
|
105203
105207
|
stdio: ["ignore", "pipe", "pipe"]
|
|
105204
105208
|
});
|
|
105205
105209
|
let stdout = "";
|
|
@@ -105267,7 +105271,7 @@ var init_grep = __esm(() => {
|
|
|
105267
105271
|
|
|
105268
105272
|
// src/core/agents/offSecAgent/tools/createFile.ts
|
|
105269
105273
|
import { writeFile, mkdir } from "fs/promises";
|
|
105270
|
-
import { dirname as dirname4 } from "path";
|
|
105274
|
+
import { dirname as dirname4, resolve as resolve8, isAbsolute as isAbsolute4 } from "path";
|
|
105271
105275
|
import { existsSync as existsSync15 } from "fs";
|
|
105272
105276
|
function createFile(ctx4) {
|
|
105273
105277
|
return tool({
|
|
@@ -105283,10 +105287,11 @@ Parent directories are created automatically if they don't exist.`,
|
|
|
105283
105287
|
content,
|
|
105284
105288
|
overwrite = false
|
|
105285
105289
|
}) => {
|
|
105290
|
+
const resolved = isAbsolute4(filePath) ? filePath : resolve8(ctx4.session.rootPath, filePath);
|
|
105286
105291
|
if (ctx4.sandbox) {
|
|
105287
|
-
return executeSandboxCreate(ctx4,
|
|
105292
|
+
return executeSandboxCreate(ctx4, resolved, content, overwrite);
|
|
105288
105293
|
}
|
|
105289
|
-
return executeLocalCreate(
|
|
105294
|
+
return executeLocalCreate(resolved, content, overwrite);
|
|
105290
105295
|
}
|
|
105291
105296
|
});
|
|
105292
105297
|
}
|
|
@@ -105364,6 +105369,7 @@ var init_createFile = __esm(() => {
|
|
|
105364
105369
|
|
|
105365
105370
|
// src/core/agents/offSecAgent/tools/updateFile.ts
|
|
105366
105371
|
import { readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
105372
|
+
import { resolve as resolve9, isAbsolute as isAbsolute5 } from "path";
|
|
105367
105373
|
function updateFile(ctx4) {
|
|
105368
105374
|
return tool({
|
|
105369
105375
|
description: `Update a file by replacing exact string matches.
|
|
@@ -105384,10 +105390,11 @@ operation fails with an error — double-check whitespace and indentation.`,
|
|
|
105384
105390
|
newContent,
|
|
105385
105391
|
replaceAll = false
|
|
105386
105392
|
}) => {
|
|
105393
|
+
const resolved = isAbsolute5(filePath) ? filePath : resolve9(ctx4.session.rootPath, filePath);
|
|
105387
105394
|
if (ctx4.sandbox) {
|
|
105388
|
-
return executeSandboxUpdate(ctx4,
|
|
105395
|
+
return executeSandboxUpdate(ctx4, resolved, oldContent, newContent, replaceAll);
|
|
105389
105396
|
}
|
|
105390
|
-
return executeLocalUpdate(
|
|
105397
|
+
return executeLocalUpdate(resolved, oldContent, newContent, replaceAll);
|
|
105391
105398
|
}
|
|
105392
105399
|
});
|
|
105393
105400
|
}
|
|
@@ -173650,7 +173657,7 @@ var require_transport = __commonJS((exports, module2) => {
|
|
|
173650
173657
|
var { createRequire: createRequire3 } = __require("module");
|
|
173651
173658
|
var { existsSync: existsSync4 } = __require("node:fs");
|
|
173652
173659
|
var getCallers = require_caller();
|
|
173653
|
-
var { join: join21, isAbsolute:
|
|
173660
|
+
var { join: join21, isAbsolute: isAbsolute6, sep } = __require("node:path");
|
|
173654
173661
|
var { fileURLToPath: fileURLToPath2 } = __require("node:url");
|
|
173655
173662
|
var sleep2 = require_atomic_sleep();
|
|
173656
173663
|
var onExit = require_on_exit_leak_free();
|
|
@@ -173722,7 +173729,7 @@ var require_transport = __commonJS((exports, module2) => {
|
|
|
173722
173729
|
return false;
|
|
173723
173730
|
}
|
|
173724
173731
|
}
|
|
173725
|
-
return
|
|
173732
|
+
return isAbsolute6(path6) && !existsSync4(path6);
|
|
173726
173733
|
}
|
|
173727
173734
|
function stripQuotes(value) {
|
|
173728
173735
|
const first = value[0];
|
|
@@ -173839,7 +173846,7 @@ var require_transport = __commonJS((exports, module2) => {
|
|
|
173839
173846
|
return buildStream(fixTarget(target), options, worker, sync, name26);
|
|
173840
173847
|
function fixTarget(origin) {
|
|
173841
173848
|
origin = bundlerOverrides[origin] || origin;
|
|
173842
|
-
if (
|
|
173849
|
+
if (isAbsolute6(origin) || origin.indexOf("file://") === 0) {
|
|
173843
173850
|
return origin;
|
|
173844
173851
|
}
|
|
173845
173852
|
if (origin === "pino/file") {
|
|
@@ -188543,7 +188550,7 @@ var init_imap_flow = __esm(() => {
|
|
|
188543
188550
|
}
|
|
188544
188551
|
processedCount++;
|
|
188545
188552
|
if (processedCount % 5 === 0) {
|
|
188546
|
-
await new Promise((
|
|
188553
|
+
await new Promise((resolve10) => setImmediate(resolve10));
|
|
188547
188554
|
}
|
|
188548
188555
|
const release = () => {
|
|
188549
188556
|
if (this.currentLock) {
|
|
@@ -277623,6 +277630,10 @@ function extractStreamableContent(args) {
|
|
|
277623
277630
|
` + args.remediation;
|
|
277624
277631
|
return text2;
|
|
277625
277632
|
}
|
|
277633
|
+
if (typeof args.title === "string" && typeof args.content === "string") {
|
|
277634
|
+
return `${args.title}
|
|
277635
|
+
${args.content}`;
|
|
277636
|
+
}
|
|
277626
277637
|
return null;
|
|
277627
277638
|
}
|
|
277628
277639
|
function tryParsePartialJson(text2) {
|
|
@@ -277727,6 +277738,16 @@ var TOOL_SUMMARY_MAP = {
|
|
|
277727
277738
|
return `pentest swarm ×${targets?.length ?? "?"}`;
|
|
277728
277739
|
},
|
|
277729
277740
|
delegate_to_auth_subagent: (args) => `auth ${args.target || ""} — ${args.reason || ""}`,
|
|
277741
|
+
add_memory: (args) => `remember "${args.title || ""}"`,
|
|
277742
|
+
list_memories: (args) => {
|
|
277743
|
+
const parts = ["list memories"];
|
|
277744
|
+
if (args.category)
|
|
277745
|
+
parts.push(`[${args.category}]`);
|
|
277746
|
+
if (args.tag)
|
|
277747
|
+
parts.push(`tag:${args.tag}`);
|
|
277748
|
+
return parts.join(" ");
|
|
277749
|
+
},
|
|
277750
|
+
get_memory: (args) => `recall ${args.category || ""}/${args.id || ""}`,
|
|
277730
277751
|
scratchpad: () => "note"
|
|
277731
277752
|
};
|
|
277732
277753
|
function getToolSummary(toolName, args) {
|
|
@@ -278342,6 +278363,79 @@ ${preview}${suffix}` : preview + suffix || "POC passed",
|
|
|
278342
278363
|
}
|
|
278343
278364
|
return { text: "Console retrieved", isError: false };
|
|
278344
278365
|
}
|
|
278366
|
+
case "list_memories": {
|
|
278367
|
+
if (typeof result === "object" && result !== null) {
|
|
278368
|
+
const obj = result;
|
|
278369
|
+
if (obj.success === false) {
|
|
278370
|
+
return {
|
|
278371
|
+
text: String(obj.error || "Failed to list memories").slice(0, 120),
|
|
278372
|
+
isError: true
|
|
278373
|
+
};
|
|
278374
|
+
}
|
|
278375
|
+
const memories = Array.isArray(obj.memories) ? obj.memories : [];
|
|
278376
|
+
const count = Number(obj.count ?? memories.length);
|
|
278377
|
+
if (count === 0) {
|
|
278378
|
+
return { text: "No memories found", isError: false };
|
|
278379
|
+
}
|
|
278380
|
+
const preview = memories.slice(0, 8).map((m4) => {
|
|
278381
|
+
const cat = m4.category ? `[${m4.category}]` : "";
|
|
278382
|
+
return `${cat} ${m4.title || m4.id || "untitled"}`;
|
|
278383
|
+
}).join(`
|
|
278384
|
+
`);
|
|
278385
|
+
const suffix = count > 8 ? `
|
|
278386
|
+
… (${count} total)` : "";
|
|
278387
|
+
return {
|
|
278388
|
+
text: `${count} memor${count === 1 ? "y" : "ies"}`,
|
|
278389
|
+
isError: false,
|
|
278390
|
+
fullText: preview + suffix
|
|
278391
|
+
};
|
|
278392
|
+
}
|
|
278393
|
+
break;
|
|
278394
|
+
}
|
|
278395
|
+
case "add_memory": {
|
|
278396
|
+
if (typeof result === "object" && result !== null) {
|
|
278397
|
+
const obj = result;
|
|
278398
|
+
if (obj.success === false) {
|
|
278399
|
+
return {
|
|
278400
|
+
text: String(obj.error || "Failed to save memory").slice(0, 120),
|
|
278401
|
+
isError: true
|
|
278402
|
+
};
|
|
278403
|
+
}
|
|
278404
|
+
const title = obj.title || args?.title || "memory";
|
|
278405
|
+
const cat = obj.category ? `[${obj.category}] ` : "";
|
|
278406
|
+
return { text: `${cat}Saved "${title}"`, isError: false };
|
|
278407
|
+
}
|
|
278408
|
+
break;
|
|
278409
|
+
}
|
|
278410
|
+
case "get_memory": {
|
|
278411
|
+
if (typeof result === "object" && result !== null) {
|
|
278412
|
+
const obj = result;
|
|
278413
|
+
if (obj.success === false) {
|
|
278414
|
+
return {
|
|
278415
|
+
text: String(obj.error || "Memory not found").slice(0, 120),
|
|
278416
|
+
isError: true
|
|
278417
|
+
};
|
|
278418
|
+
}
|
|
278419
|
+
const memory = typeof obj.memory === "object" && obj.memory !== null ? obj.memory : null;
|
|
278420
|
+
if (memory) {
|
|
278421
|
+
const title = String(memory.title || "untitled");
|
|
278422
|
+
const content = typeof memory.content === "string" ? memory.content : "";
|
|
278423
|
+
const lines = content.split(`
|
|
278424
|
+
`);
|
|
278425
|
+
const preview = lines.slice(0, 4).join(`
|
|
278426
|
+
`);
|
|
278427
|
+
const suffix = lines.length > 4 ? `
|
|
278428
|
+
… (${lines.length} lines)` : "";
|
|
278429
|
+
return {
|
|
278430
|
+
text: title,
|
|
278431
|
+
isError: false,
|
|
278432
|
+
fullText: content.length > 0 ? preview + suffix : undefined
|
|
278433
|
+
};
|
|
278434
|
+
}
|
|
278435
|
+
return { text: "Memory retrieved", isError: false };
|
|
278436
|
+
}
|
|
278437
|
+
break;
|
|
278438
|
+
}
|
|
278345
278439
|
case "scratchpad": {
|
|
278346
278440
|
return { text: "Note saved", isError: false };
|
|
278347
278441
|
}
|