@pensar/apex 0.0.80 → 0.0.81-canary.5d4e2cba
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 +874 -410
- 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.81-canary.5d4e2cba",
|
|
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",
|
|
@@ -36137,6 +36137,279 @@ var init_zod = __esm(() => {
|
|
|
36137
36137
|
zod_default = exports_external;
|
|
36138
36138
|
});
|
|
36139
36139
|
|
|
36140
|
+
// src/util/errors.ts
|
|
36141
|
+
var NamedError;
|
|
36142
|
+
var init_errors2 = __esm(() => {
|
|
36143
|
+
init_zod();
|
|
36144
|
+
NamedError = class NamedError extends Error {
|
|
36145
|
+
static create(name, data) {
|
|
36146
|
+
const schema2 = zod_default.object({
|
|
36147
|
+
name: zod_default.literal(name),
|
|
36148
|
+
data
|
|
36149
|
+
});
|
|
36150
|
+
const result = class extends NamedError {
|
|
36151
|
+
data;
|
|
36152
|
+
static Schema = schema2;
|
|
36153
|
+
name = name;
|
|
36154
|
+
constructor(data2, options) {
|
|
36155
|
+
super(name, options);
|
|
36156
|
+
this.data = data2;
|
|
36157
|
+
this.name = name;
|
|
36158
|
+
}
|
|
36159
|
+
static isInstance(input) {
|
|
36160
|
+
return typeof input === "object" && input !== null && "name" in input && input.name === name;
|
|
36161
|
+
}
|
|
36162
|
+
schema() {
|
|
36163
|
+
return schema2;
|
|
36164
|
+
}
|
|
36165
|
+
toObject() {
|
|
36166
|
+
return {
|
|
36167
|
+
name,
|
|
36168
|
+
data: this.data
|
|
36169
|
+
};
|
|
36170
|
+
}
|
|
36171
|
+
};
|
|
36172
|
+
Object.defineProperty(result, "name", { value: name });
|
|
36173
|
+
return result;
|
|
36174
|
+
}
|
|
36175
|
+
static Unknown = NamedError.create("UnknownError", zod_default.object({
|
|
36176
|
+
message: zod_default.string()
|
|
36177
|
+
}));
|
|
36178
|
+
};
|
|
36179
|
+
});
|
|
36180
|
+
|
|
36181
|
+
// src/util/lock.ts
|
|
36182
|
+
function getLock(key) {
|
|
36183
|
+
if (!locks.has(key)) {
|
|
36184
|
+
locks.set(key, {
|
|
36185
|
+
readers: 0,
|
|
36186
|
+
writer: false,
|
|
36187
|
+
waitingReaders: [],
|
|
36188
|
+
waitingWriters: []
|
|
36189
|
+
});
|
|
36190
|
+
}
|
|
36191
|
+
return locks.get(key);
|
|
36192
|
+
}
|
|
36193
|
+
function processQueue(key) {
|
|
36194
|
+
const lock = locks.get(key);
|
|
36195
|
+
if (!lock || lock.writer || lock.readers > 0)
|
|
36196
|
+
return;
|
|
36197
|
+
if (lock.waitingWriters.length > 0) {
|
|
36198
|
+
const nextWriter = lock.waitingWriters.shift();
|
|
36199
|
+
nextWriter();
|
|
36200
|
+
return;
|
|
36201
|
+
}
|
|
36202
|
+
while (lock.waitingReaders.length > 0) {
|
|
36203
|
+
const nextReader = lock.waitingReaders.shift();
|
|
36204
|
+
nextReader();
|
|
36205
|
+
}
|
|
36206
|
+
if (lock.readers === 0 && !lock.writer && lock.waitingReaders.length === 0 && lock.waitingWriters.length === 0) {
|
|
36207
|
+
locks.delete(key);
|
|
36208
|
+
}
|
|
36209
|
+
}
|
|
36210
|
+
async function read(key) {
|
|
36211
|
+
const lock = getLock(key);
|
|
36212
|
+
return new Promise((resolve3) => {
|
|
36213
|
+
if (!lock.writer && lock.waitingWriters.length === 0) {
|
|
36214
|
+
lock.readers++;
|
|
36215
|
+
resolve3({
|
|
36216
|
+
[Symbol.dispose]: () => {
|
|
36217
|
+
lock.readers--;
|
|
36218
|
+
processQueue(key);
|
|
36219
|
+
}
|
|
36220
|
+
});
|
|
36221
|
+
} else {
|
|
36222
|
+
lock.waitingReaders.push(() => {
|
|
36223
|
+
lock.readers++;
|
|
36224
|
+
resolve3({
|
|
36225
|
+
[Symbol.dispose]: () => {
|
|
36226
|
+
lock.readers--;
|
|
36227
|
+
processQueue(key);
|
|
36228
|
+
}
|
|
36229
|
+
});
|
|
36230
|
+
});
|
|
36231
|
+
}
|
|
36232
|
+
});
|
|
36233
|
+
}
|
|
36234
|
+
async function write(key) {
|
|
36235
|
+
const lock = getLock(key);
|
|
36236
|
+
return new Promise((resolve3) => {
|
|
36237
|
+
if (!lock.writer && lock.readers === 0) {
|
|
36238
|
+
lock.writer = true;
|
|
36239
|
+
resolve3({
|
|
36240
|
+
[Symbol.dispose]: () => {
|
|
36241
|
+
lock.writer = false;
|
|
36242
|
+
processQueue(key);
|
|
36243
|
+
}
|
|
36244
|
+
});
|
|
36245
|
+
} else {
|
|
36246
|
+
lock.waitingWriters.push(() => {
|
|
36247
|
+
lock.writer = true;
|
|
36248
|
+
resolve3({
|
|
36249
|
+
[Symbol.dispose]: () => {
|
|
36250
|
+
lock.writer = false;
|
|
36251
|
+
processQueue(key);
|
|
36252
|
+
}
|
|
36253
|
+
});
|
|
36254
|
+
});
|
|
36255
|
+
}
|
|
36256
|
+
});
|
|
36257
|
+
}
|
|
36258
|
+
var locks;
|
|
36259
|
+
var init_lock = __esm(() => {
|
|
36260
|
+
locks = new Map;
|
|
36261
|
+
});
|
|
36262
|
+
|
|
36263
|
+
// src/core/storage/index.ts
|
|
36264
|
+
import os3 from "os";
|
|
36265
|
+
import path3 from "path";
|
|
36266
|
+
import fs3 from "fs/promises";
|
|
36267
|
+
import { readdir } from "fs/promises";
|
|
36268
|
+
function getBaseDir() {
|
|
36269
|
+
return process.env.PENSAR_DATA_DIR ?? path3.join(os3.homedir(), ".pensar");
|
|
36270
|
+
}
|
|
36271
|
+
async function remove(key) {
|
|
36272
|
+
const dir = getBaseDir();
|
|
36273
|
+
const target = path3.join(dir, ...key) + ".json";
|
|
36274
|
+
return withErrorHandling(async () => {
|
|
36275
|
+
await fs3.unlink(target).catch(() => {});
|
|
36276
|
+
});
|
|
36277
|
+
}
|
|
36278
|
+
async function write2(key, content, ext) {
|
|
36279
|
+
const dir = getBaseDir();
|
|
36280
|
+
const target = path3.join(dir, ...key) + (ext ? ext : ".json");
|
|
36281
|
+
return withErrorHandling(async () => {
|
|
36282
|
+
let __stack = [];
|
|
36283
|
+
try {
|
|
36284
|
+
const _2 = __using(__stack, await write(target), 0);
|
|
36285
|
+
await fs3.mkdir(path3.dirname(target), { recursive: true });
|
|
36286
|
+
await fs3.writeFile(target, JSON.stringify(content, null, 2), "utf-8");
|
|
36287
|
+
} catch (_catch) {
|
|
36288
|
+
var _err = _catch, _hasErr = 1;
|
|
36289
|
+
} finally {
|
|
36290
|
+
__callDispose(__stack, _err, _hasErr);
|
|
36291
|
+
}
|
|
36292
|
+
});
|
|
36293
|
+
}
|
|
36294
|
+
async function createDir(key) {
|
|
36295
|
+
const dir = getBaseDir();
|
|
36296
|
+
const target = path3.join(dir, ...key);
|
|
36297
|
+
return withErrorHandling(async () => {
|
|
36298
|
+
let __stack = [];
|
|
36299
|
+
try {
|
|
36300
|
+
const _2 = __using(__stack, await write(target), 0);
|
|
36301
|
+
await fs3.mkdir(target, { recursive: true });
|
|
36302
|
+
} catch (_catch) {
|
|
36303
|
+
var _err = _catch, _hasErr = 1;
|
|
36304
|
+
} finally {
|
|
36305
|
+
__callDispose(__stack, _err, _hasErr);
|
|
36306
|
+
}
|
|
36307
|
+
});
|
|
36308
|
+
}
|
|
36309
|
+
async function writeRaw(key, content) {
|
|
36310
|
+
const dir = getBaseDir();
|
|
36311
|
+
const target = path3.join(dir, ...key);
|
|
36312
|
+
return withErrorHandling(async () => {
|
|
36313
|
+
let __stack = [];
|
|
36314
|
+
try {
|
|
36315
|
+
const _2 = __using(__stack, await write(target), 0);
|
|
36316
|
+
const parentDir = path3.dirname(target);
|
|
36317
|
+
await fs3.mkdir(parentDir, { recursive: true });
|
|
36318
|
+
await fs3.writeFile(target, content, "utf-8");
|
|
36319
|
+
} catch (_catch) {
|
|
36320
|
+
var _err = _catch, _hasErr = 1;
|
|
36321
|
+
} finally {
|
|
36322
|
+
__callDispose(__stack, _err, _hasErr);
|
|
36323
|
+
}
|
|
36324
|
+
});
|
|
36325
|
+
}
|
|
36326
|
+
async function read2(key, ext) {
|
|
36327
|
+
const dir = getBaseDir();
|
|
36328
|
+
const target = path3.join(dir, ...key) + (ext ? ext : ".json");
|
|
36329
|
+
return withErrorHandling(async () => {
|
|
36330
|
+
let __stack = [];
|
|
36331
|
+
try {
|
|
36332
|
+
const _2 = __using(__stack, await read(target), 0);
|
|
36333
|
+
const text = await fs3.readFile(target, "utf-8");
|
|
36334
|
+
const result = ext ? text : JSON.parse(text);
|
|
36335
|
+
return result;
|
|
36336
|
+
} catch (_catch) {
|
|
36337
|
+
var _err = _catch, _hasErr = 1;
|
|
36338
|
+
} finally {
|
|
36339
|
+
__callDispose(__stack, _err, _hasErr);
|
|
36340
|
+
}
|
|
36341
|
+
});
|
|
36342
|
+
}
|
|
36343
|
+
async function update2(key, fn, ext) {
|
|
36344
|
+
const dir = getBaseDir();
|
|
36345
|
+
const target = path3.join(dir, ...key) + (ext ? ext : ".json");
|
|
36346
|
+
return withErrorHandling(async () => {
|
|
36347
|
+
let __stack = [];
|
|
36348
|
+
try {
|
|
36349
|
+
const _2 = __using(__stack, await write(target), 0);
|
|
36350
|
+
const text = await fs3.readFile(target, "utf-8");
|
|
36351
|
+
const content = ext ? text : JSON.parse(text);
|
|
36352
|
+
fn(content);
|
|
36353
|
+
await fs3.writeFile(target, JSON.stringify(content, null, 2), "utf-8");
|
|
36354
|
+
return content;
|
|
36355
|
+
} catch (_catch) {
|
|
36356
|
+
var _err = _catch, _hasErr = 1;
|
|
36357
|
+
} finally {
|
|
36358
|
+
__callDispose(__stack, _err, _hasErr);
|
|
36359
|
+
}
|
|
36360
|
+
});
|
|
36361
|
+
}
|
|
36362
|
+
async function withErrorHandling(body) {
|
|
36363
|
+
return body().catch((e) => {
|
|
36364
|
+
if (!(e instanceof Error))
|
|
36365
|
+
throw e;
|
|
36366
|
+
const errnoExcpetion = e;
|
|
36367
|
+
if (errnoExcpetion.code === "ENOENT") {
|
|
36368
|
+
throw new NotFoundError({
|
|
36369
|
+
message: `Resource not found: ${errnoExcpetion.path}`
|
|
36370
|
+
});
|
|
36371
|
+
}
|
|
36372
|
+
throw e;
|
|
36373
|
+
});
|
|
36374
|
+
}
|
|
36375
|
+
async function listFilesRecursively(dir) {
|
|
36376
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
36377
|
+
const files = [];
|
|
36378
|
+
for (const entry of entries) {
|
|
36379
|
+
const fullPath = path3.join(dir, entry.name);
|
|
36380
|
+
if (entry.isDirectory()) {
|
|
36381
|
+
files.push(...await listFilesRecursively(fullPath));
|
|
36382
|
+
} else {
|
|
36383
|
+
files.push(fullPath);
|
|
36384
|
+
}
|
|
36385
|
+
}
|
|
36386
|
+
return files;
|
|
36387
|
+
}
|
|
36388
|
+
async function list(prefix) {
|
|
36389
|
+
const dir = getBaseDir();
|
|
36390
|
+
const targetDir = path3.join(dir, ...prefix);
|
|
36391
|
+
try {
|
|
36392
|
+
const files = await listFilesRecursively(targetDir);
|
|
36393
|
+
const result = files.map((filePath) => {
|
|
36394
|
+
const relativePath = path3.relative(targetDir, filePath);
|
|
36395
|
+
return [...prefix, ...relativePath.slice(0, -5).split(path3.sep)];
|
|
36396
|
+
});
|
|
36397
|
+
result.sort();
|
|
36398
|
+
return result;
|
|
36399
|
+
} catch {
|
|
36400
|
+
return [];
|
|
36401
|
+
}
|
|
36402
|
+
}
|
|
36403
|
+
var NotFoundError;
|
|
36404
|
+
var init_storage = __esm(() => {
|
|
36405
|
+
init_zod();
|
|
36406
|
+
init_errors2();
|
|
36407
|
+
init_lock();
|
|
36408
|
+
NotFoundError = NamedError.create("NotFoundError", zod_default.object({
|
|
36409
|
+
message: zod_default.string()
|
|
36410
|
+
}));
|
|
36411
|
+
});
|
|
36412
|
+
|
|
36140
36413
|
// src/core/credentials/manager.ts
|
|
36141
36414
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
36142
36415
|
function generateCredentialId() {
|
|
@@ -36615,6 +36888,30 @@ var init_toolset = __esm(() => {
|
|
|
36615
36888
|
detail: "Validate that testing is complete by checking coverage against the original scope and identifying any gaps.",
|
|
36616
36889
|
category: "utility",
|
|
36617
36890
|
defaultEnabled: true
|
|
36891
|
+
},
|
|
36892
|
+
{
|
|
36893
|
+
id: "add_memory",
|
|
36894
|
+
name: "Add Memory",
|
|
36895
|
+
description: "Save to memory",
|
|
36896
|
+
detail: "Save a piece of knowledge to persistent memory. Memories survive across sessions and can store reusable techniques, target notes, credential patterns, useful payloads, or any information worth remembering.",
|
|
36897
|
+
category: "utility",
|
|
36898
|
+
defaultEnabled: true
|
|
36899
|
+
},
|
|
36900
|
+
{
|
|
36901
|
+
id: "list_memories",
|
|
36902
|
+
name: "List Memories",
|
|
36903
|
+
description: "Browse saved memories",
|
|
36904
|
+
detail: "List all saved memories with optional tag filtering. Returns summaries sorted by most recent first. Use the returned id with Get Memory to retrieve full content.",
|
|
36905
|
+
category: "utility",
|
|
36906
|
+
defaultEnabled: true
|
|
36907
|
+
},
|
|
36908
|
+
{
|
|
36909
|
+
id: "get_memory",
|
|
36910
|
+
name: "Get Memory",
|
|
36911
|
+
description: "Retrieve a memory",
|
|
36912
|
+
detail: "Retrieve the full content of a saved memory by its id. Use List Memories first to discover available memory ids.",
|
|
36913
|
+
category: "utility",
|
|
36914
|
+
defaultEnabled: true
|
|
36618
36915
|
}
|
|
36619
36916
|
];
|
|
36620
36917
|
TOOLSETS = [
|
|
@@ -37017,9 +37314,9 @@ function saveSubagentData(session, data) {
|
|
|
37017
37314
|
const filename = `${data.agentName}-${ts}.json`;
|
|
37018
37315
|
writeFileSync2(join4(subagentsDir, filename), JSON.stringify(savedData, null, 2));
|
|
37019
37316
|
}
|
|
37020
|
-
function writeAgentManifest(session,
|
|
37317
|
+
function writeAgentManifest(session, entries2) {
|
|
37021
37318
|
const manifestPath = join4(session.rootPath, MANIFEST_FILE);
|
|
37022
|
-
writeFileSync2(manifestPath, JSON.stringify(
|
|
37319
|
+
writeFileSync2(manifestPath, JSON.stringify(entries2, null, 2));
|
|
37023
37320
|
}
|
|
37024
37321
|
function buildManifestEntries(targets) {
|
|
37025
37322
|
return targets.map((t2, i) => ({
|
|
@@ -37032,8 +37329,8 @@ function buildManifestEntries(targets) {
|
|
|
37032
37329
|
spawnedAt: new Date().toISOString()
|
|
37033
37330
|
}));
|
|
37034
37331
|
}
|
|
37035
|
-
function finalizeManifest(session,
|
|
37036
|
-
const finalManifest =
|
|
37332
|
+
function finalizeManifest(session, entries2, results) {
|
|
37333
|
+
const finalManifest = entries2.map((entry, i) => ({
|
|
37037
37334
|
...entry,
|
|
37038
37335
|
status: results[i] != null ? "completed" : "failed",
|
|
37039
37336
|
completedAt: new Date().toISOString()
|
|
@@ -37612,9 +37909,9 @@ function assertNever(_x) {
|
|
|
37612
37909
|
throw new Error;
|
|
37613
37910
|
}
|
|
37614
37911
|
function assert(_2) {}
|
|
37615
|
-
function getEnumValues(
|
|
37616
|
-
const numericValues = Object.values(
|
|
37617
|
-
const values = Object.entries(
|
|
37912
|
+
function getEnumValues(entries2) {
|
|
37913
|
+
const numericValues = Object.values(entries2).filter((v2) => typeof v2 === "number");
|
|
37914
|
+
const values = Object.entries(entries2).filter(([k2, _2]) => numericValues.indexOf(+k2) === -1).map(([_2, v2]) => v2);
|
|
37618
37915
|
return values;
|
|
37619
37916
|
}
|
|
37620
37917
|
function joinValues(array, separator = "|") {
|
|
@@ -38208,7 +38505,7 @@ var initializer = (inst, def) => {
|
|
|
38208
38505
|
enumerable: false
|
|
38209
38506
|
});
|
|
38210
38507
|
}, $ZodError, $ZodRealError;
|
|
38211
|
-
var
|
|
38508
|
+
var init_errors3 = __esm(() => {
|
|
38212
38509
|
init_core();
|
|
38213
38510
|
init_util2();
|
|
38214
38511
|
$ZodError = $constructor("$ZodError", initializer);
|
|
@@ -38261,7 +38558,7 @@ var _parse = (_Err) => (schema2, value, _ctx, _params) => {
|
|
|
38261
38558
|
}, safeParseAsync;
|
|
38262
38559
|
var init_parse = __esm(() => {
|
|
38263
38560
|
init_core();
|
|
38264
|
-
|
|
38561
|
+
init_errors3();
|
|
38265
38562
|
init_util2();
|
|
38266
38563
|
parse2 = /* @__PURE__ */ _parse($ZodRealError);
|
|
38267
38564
|
parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
@@ -46216,17 +46513,17 @@ function _set(Class2, valueType, params) {
|
|
|
46216
46513
|
});
|
|
46217
46514
|
}
|
|
46218
46515
|
function _enum(Class2, values, params) {
|
|
46219
|
-
const
|
|
46516
|
+
const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
46220
46517
|
return new Class2({
|
|
46221
46518
|
type: "enum",
|
|
46222
|
-
entries,
|
|
46519
|
+
entries: entries2,
|
|
46223
46520
|
...normalizeParams(params)
|
|
46224
46521
|
});
|
|
46225
46522
|
}
|
|
46226
|
-
function _nativeEnum(Class2,
|
|
46523
|
+
function _nativeEnum(Class2, entries2, params) {
|
|
46227
46524
|
return new Class2({
|
|
46228
46525
|
type: "enum",
|
|
46229
|
-
entries,
|
|
46526
|
+
entries: entries2,
|
|
46230
46527
|
...normalizeParams(params)
|
|
46231
46528
|
});
|
|
46232
46529
|
}
|
|
@@ -47513,7 +47810,7 @@ var init_core2 = __esm(() => {
|
|
|
47513
47810
|
init_json_schema();
|
|
47514
47811
|
init_core();
|
|
47515
47812
|
init_parse();
|
|
47516
|
-
|
|
47813
|
+
init_errors3();
|
|
47517
47814
|
init_schemas2();
|
|
47518
47815
|
init_checks();
|
|
47519
47816
|
init_versions();
|
|
@@ -47598,7 +47895,7 @@ var initializer2 = (inst, issues) => {
|
|
|
47598
47895
|
}
|
|
47599
47896
|
});
|
|
47600
47897
|
}, ZodError3, ZodRealError;
|
|
47601
|
-
var
|
|
47898
|
+
var init_errors4 = __esm(() => {
|
|
47602
47899
|
init_core2();
|
|
47603
47900
|
init_core2();
|
|
47604
47901
|
ZodError3 = $constructor("ZodError", initializer2);
|
|
@@ -47611,7 +47908,7 @@ var init_errors3 = __esm(() => {
|
|
|
47611
47908
|
var parse4, parseAsync2, safeParse2, safeParseAsync2;
|
|
47612
47909
|
var init_parse2 = __esm(() => {
|
|
47613
47910
|
init_core2();
|
|
47614
|
-
|
|
47911
|
+
init_errors4();
|
|
47615
47912
|
parse4 = /* @__PURE__ */ _parse(ZodRealError);
|
|
47616
47913
|
parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
47617
47914
|
safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
@@ -47850,17 +48147,17 @@ function set(valueType, params) {
|
|
|
47850
48147
|
});
|
|
47851
48148
|
}
|
|
47852
48149
|
function _enum2(values, params) {
|
|
47853
|
-
const
|
|
48150
|
+
const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
47854
48151
|
return new ZodEnum2({
|
|
47855
48152
|
type: "enum",
|
|
47856
|
-
entries,
|
|
48153
|
+
entries: entries2,
|
|
47857
48154
|
...exports_util.normalizeParams(params)
|
|
47858
48155
|
});
|
|
47859
48156
|
}
|
|
47860
|
-
function nativeEnum(
|
|
48157
|
+
function nativeEnum(entries2, params) {
|
|
47861
48158
|
return new ZodEnum2({
|
|
47862
48159
|
type: "enum",
|
|
47863
|
-
entries,
|
|
48160
|
+
entries: entries2,
|
|
47864
48161
|
...exports_util.normalizeParams(params)
|
|
47865
48162
|
});
|
|
47866
48163
|
}
|
|
@@ -48835,7 +49132,7 @@ var init_external2 = __esm(() => {
|
|
|
48835
49132
|
init_coerce();
|
|
48836
49133
|
init_schemas3();
|
|
48837
49134
|
init_checks2();
|
|
48838
|
-
|
|
49135
|
+
init_errors4();
|
|
48839
49136
|
init_parse2();
|
|
48840
49137
|
init_compat();
|
|
48841
49138
|
config2(en_default2());
|
|
@@ -53268,8 +53565,8 @@ var require_baggage_impl = __commonJS((exports) => {
|
|
|
53268
53565
|
exports.BaggageImpl = undefined;
|
|
53269
53566
|
|
|
53270
53567
|
class BaggageImpl {
|
|
53271
|
-
constructor(
|
|
53272
|
-
this._entries =
|
|
53568
|
+
constructor(entries2) {
|
|
53569
|
+
this._entries = entries2 ? new Map(entries2) : new Map;
|
|
53273
53570
|
}
|
|
53274
53571
|
getEntry(key) {
|
|
53275
53572
|
const entry = this._entries.get(key);
|
|
@@ -53320,8 +53617,8 @@ var require_utils = __commonJS((exports) => {
|
|
|
53320
53617
|
var baggage_impl_1 = require_baggage_impl();
|
|
53321
53618
|
var symbol_1 = require_symbol();
|
|
53322
53619
|
var diag = diag_1.DiagAPI.instance();
|
|
53323
|
-
function createBaggage(
|
|
53324
|
-
return new baggage_impl_1.BaggageImpl(new Map(Object.entries(
|
|
53620
|
+
function createBaggage(entries2 = {}) {
|
|
53621
|
+
return new baggage_impl_1.BaggageImpl(new Map(Object.entries(entries2)));
|
|
53325
53622
|
}
|
|
53326
53623
|
exports.createBaggage = createBaggage;
|
|
53327
53624
|
function baggageEntryMetadataFromString(str) {
|
|
@@ -99560,8 +99857,8 @@ var require_dist2 = __commonJS((exports, module2) => {
|
|
|
99560
99857
|
return ajv;
|
|
99561
99858
|
}
|
|
99562
99859
|
const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
|
|
99563
|
-
const
|
|
99564
|
-
addFormats(ajv,
|
|
99860
|
+
const list3 = opts.formats || formats_1.formatNames;
|
|
99861
|
+
addFormats(ajv, list3, formats, exportName);
|
|
99565
99862
|
if (opts.keywords)
|
|
99566
99863
|
(0, limit_1.default)(ajv);
|
|
99567
99864
|
return ajv;
|
|
@@ -99573,11 +99870,11 @@ var require_dist2 = __commonJS((exports, module2) => {
|
|
|
99573
99870
|
throw new Error(`Unknown format "${name26}"`);
|
|
99574
99871
|
return f;
|
|
99575
99872
|
};
|
|
99576
|
-
function addFormats(ajv,
|
|
99873
|
+
function addFormats(ajv, list3, fs5, exportName) {
|
|
99577
99874
|
var _a26;
|
|
99578
99875
|
var _b16;
|
|
99579
99876
|
(_a26 = (_b16 = ajv.opts.code).formats) !== null && _a26 !== undefined || (_b16.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`);
|
|
99580
|
-
for (const f of
|
|
99877
|
+
for (const f of list3)
|
|
99581
99878
|
ajv.addFormat(f, fs5[f]);
|
|
99582
99879
|
}
|
|
99583
99880
|
module2.exports = exports = formatsPlugin;
|
|
@@ -103892,19 +104189,19 @@ var init_readFile = __esm(() => {
|
|
|
103892
104189
|
});
|
|
103893
104190
|
|
|
103894
104191
|
// src/core/agents/offSecAgent/tools/listFiles.ts
|
|
103895
|
-
import { readdir, stat } from "fs/promises";
|
|
104192
|
+
import { readdir as readdir2, stat } from "fs/promises";
|
|
103896
104193
|
import { join as join12, relative } from "path";
|
|
103897
104194
|
async function listRecursive(dir, maxEntries) {
|
|
103898
104195
|
const results = [];
|
|
103899
104196
|
let total = 0;
|
|
103900
104197
|
async function walk(current) {
|
|
103901
|
-
let
|
|
104198
|
+
let entries2;
|
|
103902
104199
|
try {
|
|
103903
|
-
|
|
104200
|
+
entries2 = await readdir2(current, { withFileTypes: true });
|
|
103904
104201
|
} catch {
|
|
103905
104202
|
return;
|
|
103906
104203
|
}
|
|
103907
|
-
for (const entry of
|
|
104204
|
+
for (const entry of entries2) {
|
|
103908
104205
|
total++;
|
|
103909
104206
|
const fullPath = join12(current, entry.name);
|
|
103910
104207
|
if (entry.isDirectory()) {
|
|
@@ -103967,8 +104264,8 @@ Each directory entry is suffixed with "/" for easy identification.`,
|
|
|
103967
104264
|
totalFound: total > MAX_RECURSIVE ? total : undefined
|
|
103968
104265
|
};
|
|
103969
104266
|
}
|
|
103970
|
-
const
|
|
103971
|
-
const fullPaths =
|
|
104267
|
+
const entries2 = await readdir2(dir, { withFileTypes: true });
|
|
104268
|
+
const fullPaths = entries2.map((e) => {
|
|
103972
104269
|
const name26 = join12(dir, e.name);
|
|
103973
104270
|
return e.isDirectory() ? `${name26}/` : name26;
|
|
103974
104271
|
});
|
|
@@ -103976,11 +104273,11 @@ Each directory entry is suffixed with "/" for easy identification.`,
|
|
|
103976
104273
|
const relPaths = toRelative(dir, capped);
|
|
103977
104274
|
return {
|
|
103978
104275
|
success: true,
|
|
103979
|
-
error:
|
|
104276
|
+
error: entries2.length > MAX_NON_RECURSIVE ? `Showing ${MAX_NON_RECURSIVE} of ${entries2.length} entries` : "",
|
|
103980
104277
|
files: relPaths,
|
|
103981
104278
|
directory: dir,
|
|
103982
104279
|
count: relPaths.length,
|
|
103983
|
-
totalFound:
|
|
104280
|
+
totalFound: entries2.length > MAX_NON_RECURSIVE ? entries2.length : undefined
|
|
103984
104281
|
};
|
|
103985
104282
|
} catch (err) {
|
|
103986
104283
|
return {
|
|
@@ -104982,6 +105279,13 @@ When to use delegate_to_auth_subagent vs authenticate_session:
|
|
|
104982
105279
|
tokens = { ...stored.tokens };
|
|
104983
105280
|
}
|
|
104984
105281
|
}
|
|
105282
|
+
const subagentId = "auth-agent";
|
|
105283
|
+
const cbs = ctx4.subagentCallbacks;
|
|
105284
|
+
cbs?.onSubagentSpawn?.({
|
|
105285
|
+
subagentId,
|
|
105286
|
+
input: { target, reason },
|
|
105287
|
+
status: "pending"
|
|
105288
|
+
});
|
|
104985
105289
|
console.log(`
|
|
104986
105290
|
\uD83D\uDD10 Delegating to authentication subagent...`);
|
|
104987
105291
|
console.log(` Target: ${target}`);
|
|
@@ -105033,6 +105337,12 @@ When to use delegate_to_auth_subagent vs authenticate_session:
|
|
|
105033
105337
|
ctx4.session.credentialManager.addFromAuthCredentials(credentials);
|
|
105034
105338
|
}
|
|
105035
105339
|
const { runAuthenticationAgent: runAuthenticationAgent3 } = await Promise.resolve().then(() => (init_authentication(), exports_authentication));
|
|
105340
|
+
const subagentCallbacks = cbs ? {
|
|
105341
|
+
onTextDelta: (d2) => cbs.onTextDelta?.({ ...d2, subagentId }),
|
|
105342
|
+
onToolCall: (d2) => cbs.onToolCall?.({ ...d2, subagentId }),
|
|
105343
|
+
onToolResult: (d2) => cbs.onToolResult?.({ ...d2, subagentId }),
|
|
105344
|
+
onError: (e) => cbs.onError?.(e)
|
|
105345
|
+
} : undefined;
|
|
105036
105346
|
const result = await runAuthenticationAgent3({
|
|
105037
105347
|
target,
|
|
105038
105348
|
session: ctx4.session,
|
|
@@ -105040,7 +105350,15 @@ When to use delegate_to_auth_subagent vs authenticate_session:
|
|
|
105040
105350
|
model: ctx4.model,
|
|
105041
105351
|
authConfig: ctx4.authConfig,
|
|
105042
105352
|
abortSignal: ctx4.abortSignal,
|
|
105043
|
-
callbacks:
|
|
105353
|
+
callbacks: {
|
|
105354
|
+
...ctx4.callbacks,
|
|
105355
|
+
subagentCallbacks
|
|
105356
|
+
}
|
|
105357
|
+
});
|
|
105358
|
+
cbs?.onSubagentComplete?.({
|
|
105359
|
+
subagentId,
|
|
105360
|
+
input: { target, reason },
|
|
105361
|
+
status: result.success ? "completed" : "failed"
|
|
105044
105362
|
});
|
|
105045
105363
|
if (result.success) {
|
|
105046
105364
|
const sessionInfoPath = join16(ctx4.session.rootPath, "session-info.json");
|
|
@@ -105088,6 +105406,11 @@ To make authenticated requests, use the returned values:
|
|
|
105088
105406
|
Auth data saved to: ${result.authDataPath}` : ""}` : `Authentication subagent failed. ${result.summary}${result.authBarrier ? ` Barrier: ${result.authBarrier.type} - ${result.authBarrier.details}` : ""}`
|
|
105089
105407
|
};
|
|
105090
105408
|
} catch (error40) {
|
|
105409
|
+
ctx4.subagentCallbacks?.onSubagentComplete?.({
|
|
105410
|
+
subagentId: "auth-agent",
|
|
105411
|
+
input: { target, reason },
|
|
105412
|
+
status: "failed"
|
|
105413
|
+
});
|
|
105091
105414
|
const errorMessage = error40 instanceof Error ? error40.message : String(error40);
|
|
105092
105415
|
return {
|
|
105093
105416
|
success: false,
|
|
@@ -106170,6 +106493,11 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
106170
106493
|
onToolResult: (d2) => cbs.onToolResult?.({ ...d2, subagentId }),
|
|
106171
106494
|
onError: (e) => cbs.onError?.(e)
|
|
106172
106495
|
} : undefined;
|
|
106496
|
+
cbs?.onSubagentSpawn?.({
|
|
106497
|
+
subagentId,
|
|
106498
|
+
input: { target, cwd },
|
|
106499
|
+
status: "pending"
|
|
106500
|
+
});
|
|
106173
106501
|
if (cwd) {
|
|
106174
106502
|
try {
|
|
106175
106503
|
const { WhiteboxAttackSurfaceAgent: WhiteboxAttackSurfaceAgent2 } = await Promise.resolve().then(() => (init_agent2(), exports_agent));
|
|
@@ -106193,6 +106521,11 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
106193
106521
|
})));
|
|
106194
106522
|
console.log(`
|
|
106195
106523
|
✓ Whitebox attack surface complete: ${targets.length} targets from ${result.apps.length} apps`);
|
|
106524
|
+
cbs?.onSubagentComplete?.({
|
|
106525
|
+
subagentId,
|
|
106526
|
+
input: { target, cwd },
|
|
106527
|
+
status: "completed"
|
|
106528
|
+
});
|
|
106196
106529
|
return {
|
|
106197
106530
|
success: true,
|
|
106198
106531
|
mode: "whitebox",
|
|
@@ -106204,6 +106537,11 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
106204
106537
|
} catch (error40) {
|
|
106205
106538
|
const errorMsg = error40 instanceof Error ? error40.message : String(error40);
|
|
106206
106539
|
console.error(`✗ Whitebox attack surface agent failed: ${errorMsg}`);
|
|
106540
|
+
cbs?.onSubagentComplete?.({
|
|
106541
|
+
subagentId,
|
|
106542
|
+
input: { target, cwd },
|
|
106543
|
+
status: "failed"
|
|
106544
|
+
});
|
|
106207
106545
|
return {
|
|
106208
106546
|
success: false,
|
|
106209
106547
|
targets: [],
|
|
@@ -106230,6 +106568,11 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
106230
106568
|
const targetCount = result.targets.length;
|
|
106231
106569
|
console.log(`
|
|
106232
106570
|
✓ Blackbox attack surface complete: ${targetCount} targets identified`);
|
|
106571
|
+
cbs?.onSubagentComplete?.({
|
|
106572
|
+
subagentId,
|
|
106573
|
+
input: { target },
|
|
106574
|
+
status: "completed"
|
|
106575
|
+
});
|
|
106233
106576
|
return {
|
|
106234
106577
|
success: true,
|
|
106235
106578
|
mode: "blackbox",
|
|
@@ -106248,6 +106591,11 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
106248
106591
|
} catch (error40) {
|
|
106249
106592
|
const errorMsg = error40 instanceof Error ? error40.message : String(error40);
|
|
106250
106593
|
console.error(`✗ Blackbox attack surface agent failed: ${errorMsg}`);
|
|
106594
|
+
cbs?.onSubagentComplete?.({
|
|
106595
|
+
subagentId,
|
|
106596
|
+
input: { target },
|
|
106597
|
+
status: "failed"
|
|
106598
|
+
});
|
|
106251
106599
|
return {
|
|
106252
106600
|
success: false,
|
|
106253
106601
|
targets: [],
|
|
@@ -106878,6 +107226,215 @@ var init_provideComparisonResults = __esm(() => {
|
|
|
106878
107226
|
init_zod();
|
|
106879
107227
|
});
|
|
106880
107228
|
|
|
107229
|
+
// src/core/memory/index.ts
|
|
107230
|
+
function storageKey(category, id) {
|
|
107231
|
+
return [MEMORIES_PREFIX, category, id];
|
|
107232
|
+
}
|
|
107233
|
+
function slugify2(text2) {
|
|
107234
|
+
return text2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
107235
|
+
}
|
|
107236
|
+
function makeId(title) {
|
|
107237
|
+
const slug = slugify2(title);
|
|
107238
|
+
const ts = Date.now().toString(36);
|
|
107239
|
+
return slug ? `${slug}-${ts}` : ts;
|
|
107240
|
+
}
|
|
107241
|
+
function validateId(id) {
|
|
107242
|
+
if (id.includes("/") || id.includes("\\") || id.includes("..")) {
|
|
107243
|
+
throw new Error("Invalid memory id: contains path traversal characters");
|
|
107244
|
+
}
|
|
107245
|
+
}
|
|
107246
|
+
async function addMemory(input) {
|
|
107247
|
+
const category = input.category ?? "general";
|
|
107248
|
+
const id = makeId(input.title);
|
|
107249
|
+
const now2 = new Date().toISOString();
|
|
107250
|
+
const memory = {
|
|
107251
|
+
id,
|
|
107252
|
+
category,
|
|
107253
|
+
title: input.title,
|
|
107254
|
+
content: input.content,
|
|
107255
|
+
tags: input.tags ?? [],
|
|
107256
|
+
createdAt: now2,
|
|
107257
|
+
updatedAt: now2
|
|
107258
|
+
};
|
|
107259
|
+
await write2(storageKey(category, id), memory);
|
|
107260
|
+
return memory;
|
|
107261
|
+
}
|
|
107262
|
+
async function getMemory(category, id) {
|
|
107263
|
+
validateId(id);
|
|
107264
|
+
try {
|
|
107265
|
+
return await read2(storageKey(category, id));
|
|
107266
|
+
} catch (e) {
|
|
107267
|
+
if (e instanceof NotFoundError)
|
|
107268
|
+
return null;
|
|
107269
|
+
throw e;
|
|
107270
|
+
}
|
|
107271
|
+
}
|
|
107272
|
+
async function listMemories(opts) {
|
|
107273
|
+
const prefix = opts?.category ? [MEMORIES_PREFIX, opts.category] : [MEMORIES_PREFIX];
|
|
107274
|
+
const keys = await list(prefix);
|
|
107275
|
+
const summaries = [];
|
|
107276
|
+
for (const key of keys) {
|
|
107277
|
+
try {
|
|
107278
|
+
const memory = await read2(key);
|
|
107279
|
+
if (opts?.tag && !memory.tags.includes(opts.tag))
|
|
107280
|
+
continue;
|
|
107281
|
+
summaries.push({
|
|
107282
|
+
id: memory.id,
|
|
107283
|
+
category: memory.category,
|
|
107284
|
+
title: memory.title,
|
|
107285
|
+
tags: memory.tags,
|
|
107286
|
+
createdAt: memory.createdAt
|
|
107287
|
+
});
|
|
107288
|
+
} catch {}
|
|
107289
|
+
}
|
|
107290
|
+
summaries.sort((a, b2) => new Date(b2.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
107291
|
+
return summaries;
|
|
107292
|
+
}
|
|
107293
|
+
var MEMORY_CATEGORIES, MEMORIES_PREFIX = "memories";
|
|
107294
|
+
var init_memory = __esm(() => {
|
|
107295
|
+
init_storage();
|
|
107296
|
+
MEMORY_CATEGORIES = ["app", "framework", "general"];
|
|
107297
|
+
});
|
|
107298
|
+
|
|
107299
|
+
// src/core/agents/offSecAgent/tools/addMemory.ts
|
|
107300
|
+
function addMemory2(_ctx) {
|
|
107301
|
+
return tool({
|
|
107302
|
+
description: `Save a piece of knowledge to persistent memory.
|
|
107303
|
+
|
|
107304
|
+
Memories are stored across sessions in ~/.pensar/memories/ and survive restarts.
|
|
107305
|
+
They are organised into categories:
|
|
107306
|
+
- "app" — application-specific notes (e.g. target quirks, endpoints)
|
|
107307
|
+
- "framework" — framework-specific notes (e.g. Rails tricks, Django patterns)
|
|
107308
|
+
- "general" — catch-all (default when category is omitted)
|
|
107309
|
+
|
|
107310
|
+
Use this to record reusable techniques, target-specific notes, credential
|
|
107311
|
+
patterns, useful payloads, or any information worth remembering for future
|
|
107312
|
+
engagements.`,
|
|
107313
|
+
inputSchema: addMemoryInputSchema,
|
|
107314
|
+
execute: async ({
|
|
107315
|
+
title,
|
|
107316
|
+
content,
|
|
107317
|
+
category,
|
|
107318
|
+
tags
|
|
107319
|
+
}) => {
|
|
107320
|
+
try {
|
|
107321
|
+
const memory = await addMemory({ title, content, category, tags });
|
|
107322
|
+
return {
|
|
107323
|
+
success: true,
|
|
107324
|
+
error: "",
|
|
107325
|
+
id: memory.id,
|
|
107326
|
+
category: memory.category,
|
|
107327
|
+
title: memory.title
|
|
107328
|
+
};
|
|
107329
|
+
} catch (err) {
|
|
107330
|
+
return {
|
|
107331
|
+
success: false,
|
|
107332
|
+
error: err instanceof Error ? err.message : String(err)
|
|
107333
|
+
};
|
|
107334
|
+
}
|
|
107335
|
+
}
|
|
107336
|
+
});
|
|
107337
|
+
}
|
|
107338
|
+
var addMemoryInputSchema;
|
|
107339
|
+
var init_addMemory = __esm(() => {
|
|
107340
|
+
init_dist5();
|
|
107341
|
+
init_zod();
|
|
107342
|
+
init_memory();
|
|
107343
|
+
addMemoryInputSchema = exports_external.object({
|
|
107344
|
+
title: exports_external.string().describe("Short, descriptive title for the memory (used to generate id)"),
|
|
107345
|
+
content: exports_external.string().describe("Free-form text content to persist as a memory"),
|
|
107346
|
+
category: exports_external.enum(MEMORY_CATEGORIES).optional().describe('Storage category: "app" for application-specific knowledge, ' + '"framework" for framework-specific knowledge, or omit for the ' + '"general" catch-all'),
|
|
107347
|
+
tags: exports_external.array(exports_external.string()).optional().describe("Optional tags for categorisation and filtering"),
|
|
107348
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Saving XSS payload pattern')")
|
|
107349
|
+
});
|
|
107350
|
+
});
|
|
107351
|
+
|
|
107352
|
+
// src/core/agents/offSecAgent/tools/listMemories.ts
|
|
107353
|
+
function listMemories2(_ctx) {
|
|
107354
|
+
return tool({
|
|
107355
|
+
description: `List saved memories, optionally filtered by category and/or tag.
|
|
107356
|
+
|
|
107357
|
+
Returns lightweight summaries (id, category, title, tags, createdAt) sorted by
|
|
107358
|
+
most recent first. Use the returned category + id with get_memory to retrieve
|
|
107359
|
+
full content.`,
|
|
107360
|
+
inputSchema: listMemoriesInputSchema,
|
|
107361
|
+
execute: async ({ category, tag }) => {
|
|
107362
|
+
try {
|
|
107363
|
+
const memories = await listMemories({ category, tag });
|
|
107364
|
+
return {
|
|
107365
|
+
success: true,
|
|
107366
|
+
error: "",
|
|
107367
|
+
memories,
|
|
107368
|
+
count: memories.length
|
|
107369
|
+
};
|
|
107370
|
+
} catch (err) {
|
|
107371
|
+
return {
|
|
107372
|
+
success: false,
|
|
107373
|
+
error: err instanceof Error ? err.message : String(err),
|
|
107374
|
+
memories: [],
|
|
107375
|
+
count: 0
|
|
107376
|
+
};
|
|
107377
|
+
}
|
|
107378
|
+
}
|
|
107379
|
+
});
|
|
107380
|
+
}
|
|
107381
|
+
var listMemoriesInputSchema;
|
|
107382
|
+
var init_listMemories = __esm(() => {
|
|
107383
|
+
init_dist5();
|
|
107384
|
+
init_zod();
|
|
107385
|
+
init_memory();
|
|
107386
|
+
listMemoriesInputSchema = exports_external.object({
|
|
107387
|
+
category: exports_external.enum(MEMORY_CATEGORIES).optional().describe('Filter by category: "app", "framework", or "general". ' + "Omit to list memories across all categories."),
|
|
107388
|
+
tag: exports_external.string().optional().describe("Optional tag to filter memories by (exact match)"),
|
|
107389
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Listing stored recon notes')")
|
|
107390
|
+
});
|
|
107391
|
+
});
|
|
107392
|
+
|
|
107393
|
+
// src/core/agents/offSecAgent/tools/getMemory.ts
|
|
107394
|
+
function getMemory2(_ctx) {
|
|
107395
|
+
return tool({
|
|
107396
|
+
description: `Retrieve the full content of a memory by its category and id.
|
|
107397
|
+
|
|
107398
|
+
Use list_memories first to discover available memories, then call this tool
|
|
107399
|
+
with the category and id from that listing to fetch full content.`,
|
|
107400
|
+
inputSchema: getMemoryInputSchema,
|
|
107401
|
+
execute: async ({ category, id }) => {
|
|
107402
|
+
try {
|
|
107403
|
+
const memory = await getMemory(category, id);
|
|
107404
|
+
if (!memory) {
|
|
107405
|
+
return {
|
|
107406
|
+
success: false,
|
|
107407
|
+
error: `Memory not found: ${category}/${id}`,
|
|
107408
|
+
memory: null
|
|
107409
|
+
};
|
|
107410
|
+
}
|
|
107411
|
+
return {
|
|
107412
|
+
success: true,
|
|
107413
|
+
error: "",
|
|
107414
|
+
memory
|
|
107415
|
+
};
|
|
107416
|
+
} catch (err) {
|
|
107417
|
+
return {
|
|
107418
|
+
success: false,
|
|
107419
|
+
error: err instanceof Error ? err.message : String(err),
|
|
107420
|
+
memory: null
|
|
107421
|
+
};
|
|
107422
|
+
}
|
|
107423
|
+
}
|
|
107424
|
+
});
|
|
107425
|
+
}
|
|
107426
|
+
var getMemoryInputSchema;
|
|
107427
|
+
var init_getMemory = __esm(() => {
|
|
107428
|
+
init_dist5();
|
|
107429
|
+
init_zod();
|
|
107430
|
+
init_memory();
|
|
107431
|
+
getMemoryInputSchema = exports_external.object({
|
|
107432
|
+
category: exports_external.enum(MEMORY_CATEGORIES).describe('The memory category: "app", "framework", or "general" (returned by list_memories)'),
|
|
107433
|
+
id: exports_external.string().describe("The unique memory id (returned by list_memories)"),
|
|
107434
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Retrieving SQL injection cheatsheet')")
|
|
107435
|
+
});
|
|
107436
|
+
});
|
|
107437
|
+
|
|
106881
107438
|
// src/core/agents/offSecAgent/tools/email/listInboxes.ts
|
|
106882
107439
|
function emailListInboxes(ctx4) {
|
|
106883
107440
|
return tool({
|
|
@@ -129707,7 +130264,7 @@ var require_libmime = __commonJS((exports, module2) => {
|
|
|
129707
130264
|
return response;
|
|
129708
130265
|
}
|
|
129709
130266
|
buildHeaderParam(key, data, maxLength, fromCharset) {
|
|
129710
|
-
let
|
|
130267
|
+
let list3 = [];
|
|
129711
130268
|
let encodedStr = typeof data === "string" ? data : this.decode(data, fromCharset);
|
|
129712
130269
|
let encodedStrArr;
|
|
129713
130270
|
let chr, ord;
|
|
@@ -129726,13 +130283,13 @@ var require_libmime = __commonJS((exports, module2) => {
|
|
|
129726
130283
|
];
|
|
129727
130284
|
}
|
|
129728
130285
|
encodedStr = encodedStr.replace(new RegExp(".{" + maxLength + "}", "g"), (str) => {
|
|
129729
|
-
|
|
130286
|
+
list3.push({
|
|
129730
130287
|
line: str
|
|
129731
130288
|
});
|
|
129732
130289
|
return "";
|
|
129733
130290
|
});
|
|
129734
130291
|
if (encodedStr) {
|
|
129735
|
-
|
|
130292
|
+
list3.push({
|
|
129736
130293
|
line: encodedStr
|
|
129737
130294
|
});
|
|
129738
130295
|
}
|
|
@@ -129763,7 +130320,7 @@ var require_libmime = __commonJS((exports, module2) => {
|
|
|
129763
130320
|
chr = chr === " " ? chr : this.safeEncodeURIComponent(chr);
|
|
129764
130321
|
if (chr !== encodedStr[i]) {
|
|
129765
130322
|
if ((this.safeEncodeURIComponent(line) + chr).length >= maxLength) {
|
|
129766
|
-
|
|
130323
|
+
list3.push({
|
|
129767
130324
|
line,
|
|
129768
130325
|
encoded: isEncoded
|
|
129769
130326
|
});
|
|
@@ -129778,7 +130335,7 @@ var require_libmime = __commonJS((exports, module2) => {
|
|
|
129778
130335
|
}
|
|
129779
130336
|
}
|
|
129780
130337
|
if ((line + chr).length >= maxLength) {
|
|
129781
|
-
|
|
130338
|
+
list3.push({
|
|
129782
130339
|
line,
|
|
129783
130340
|
encoded: isEncoded
|
|
129784
130341
|
});
|
|
@@ -129794,13 +130351,13 @@ var require_libmime = __commonJS((exports, module2) => {
|
|
|
129794
130351
|
}
|
|
129795
130352
|
}
|
|
129796
130353
|
if (line) {
|
|
129797
|
-
|
|
130354
|
+
list3.push({
|
|
129798
130355
|
line,
|
|
129799
130356
|
encoded: isEncoded
|
|
129800
130357
|
});
|
|
129801
130358
|
}
|
|
129802
130359
|
}
|
|
129803
|
-
return
|
|
130360
|
+
return list3.map((item, i2) => ({
|
|
129804
130361
|
key: key + "*" + i2 + (item.encoded ? "*" : ""),
|
|
129805
130362
|
value: item.line
|
|
129806
130363
|
}));
|
|
@@ -131165,7 +131722,7 @@ var require_addressparser = __commonJS((exports, module2) => {
|
|
|
131165
131722
|
};
|
|
131166
131723
|
}
|
|
131167
131724
|
tokenize() {
|
|
131168
|
-
let
|
|
131725
|
+
let list3 = [];
|
|
131169
131726
|
for (let i = 0, len = this.str.length;i < len; i++) {
|
|
131170
131727
|
let chr = this.str.charAt(i);
|
|
131171
131728
|
let nextChr = i < len - 1 ? this.str.charAt(i + 1) : null;
|
|
@@ -131174,10 +131731,10 @@ var require_addressparser = __commonJS((exports, module2) => {
|
|
|
131174
131731
|
this.list.forEach((node) => {
|
|
131175
131732
|
node.value = (node.value || "").toString().trim();
|
|
131176
131733
|
if (node.value) {
|
|
131177
|
-
|
|
131734
|
+
list3.push(node);
|
|
131178
131735
|
}
|
|
131179
131736
|
});
|
|
131180
|
-
return
|
|
131737
|
+
return list3;
|
|
131181
131738
|
}
|
|
131182
131739
|
checkChar(chr, nextChr) {
|
|
131183
131740
|
if (this.escaped) {} else if (chr === this.operatorExpecting) {
|
|
@@ -131258,8 +131815,8 @@ var require_addressparser = __commonJS((exports, module2) => {
|
|
|
131258
131815
|
});
|
|
131259
131816
|
if (options.flatten) {
|
|
131260
131817
|
let addresses2 = [];
|
|
131261
|
-
let walkAddressList = (
|
|
131262
|
-
|
|
131818
|
+
let walkAddressList = (list3) => {
|
|
131819
|
+
list3.forEach((address2) => {
|
|
131263
131820
|
if (address2.group) {
|
|
131264
131821
|
return walkAddressList(address2.group);
|
|
131265
131822
|
} else {
|
|
@@ -140602,30 +141159,30 @@ var require_html_to_text = __commonJS((exports) => {
|
|
|
140602
141159
|
if (!(this._stackItem instanceof ListStackItem)) {
|
|
140603
141160
|
throw new Error("Can't add a list item to something that is not a list! Check the formatter.");
|
|
140604
141161
|
}
|
|
140605
|
-
const
|
|
140606
|
-
const prefixLength = Math.max(prefix.length,
|
|
140607
|
-
const maxLineLength = Math.max(20,
|
|
140608
|
-
this._stackItem = new ListItemStackItem(this.options,
|
|
141162
|
+
const list3 = this._stackItem;
|
|
141163
|
+
const prefixLength = Math.max(prefix.length, list3.maxPrefixLength);
|
|
141164
|
+
const maxLineLength = Math.max(20, list3.inlineTextBuilder.maxLineLength - prefixLength);
|
|
141165
|
+
this._stackItem = new ListItemStackItem(this.options, list3, {
|
|
140609
141166
|
prefix,
|
|
140610
141167
|
maxLineLength,
|
|
140611
|
-
leadingLineBreaks:
|
|
141168
|
+
leadingLineBreaks: list3.interRowLineBreaks
|
|
140612
141169
|
});
|
|
140613
141170
|
}
|
|
140614
141171
|
closeListItem() {
|
|
140615
141172
|
const listItem = this._popStackItem();
|
|
140616
|
-
const
|
|
140617
|
-
const prefixLength = Math.max(listItem.prefix.length,
|
|
141173
|
+
const list3 = listItem.next;
|
|
141174
|
+
const prefixLength = Math.max(listItem.prefix.length, list3.maxPrefixLength);
|
|
140618
141175
|
const spacing = `
|
|
140619
141176
|
` + " ".repeat(prefixLength);
|
|
140620
|
-
const prefix =
|
|
141177
|
+
const prefix = list3.prefixAlign === "right" ? listItem.prefix.padStart(prefixLength) : listItem.prefix.padEnd(prefixLength);
|
|
140621
141178
|
const text2 = prefix + getText(listItem).replace(/\n/g, spacing);
|
|
140622
|
-
addText(
|
|
141179
|
+
addText(list3, text2, listItem.leadingLineBreaks, Math.max(listItem.stashedLineBreaks, list3.interRowLineBreaks));
|
|
140623
141180
|
}
|
|
140624
141181
|
closeList({ trailingLineBreaks = 2 } = {}) {
|
|
140625
|
-
const
|
|
140626
|
-
const text2 = getText(
|
|
141182
|
+
const list3 = this._popStackItem();
|
|
141183
|
+
const text2 = getText(list3);
|
|
140627
141184
|
if (text2) {
|
|
140628
|
-
addText(this._stackItem, text2,
|
|
141185
|
+
addText(this._stackItem, text2, list3.leadingLineBreaks, trailingLineBreaks);
|
|
140629
141186
|
}
|
|
140630
141187
|
}
|
|
140631
141188
|
openTable() {
|
|
@@ -140780,9 +141337,9 @@ var require_html_to_text = __commonJS((exports) => {
|
|
|
140780
141337
|
if (!dict || Object.keys(dict).length === 0) {
|
|
140781
141338
|
return;
|
|
140782
141339
|
}
|
|
140783
|
-
const
|
|
140784
|
-
const regex = new RegExp(
|
|
140785
|
-
const values =
|
|
141340
|
+
const entries2 = Object.entries(dict).filter(([, v2]) => v2 !== false);
|
|
141341
|
+
const regex = new RegExp(entries2.map(([c]) => `(${unicodeEscape([...c][0])})`).join("|"), "g");
|
|
141342
|
+
const values = entries2.map(([, v2]) => v2);
|
|
140786
141343
|
const replacer = (m2, ...cgs) => values[cgs.findIndex((cg) => cg)];
|
|
140787
141344
|
return (str) => str.replace(regex, replacer);
|
|
140788
141345
|
}
|
|
@@ -141967,15 +142524,15 @@ var require_index_cjs2 = __commonJS((exports, module2) => {
|
|
|
141967
142524
|
this.__last_index__ = m2.index + m2[0].length + len;
|
|
141968
142525
|
return createMatch(this, 0);
|
|
141969
142526
|
};
|
|
141970
|
-
LinkifyIt.prototype.tlds = function tlds(
|
|
141971
|
-
|
|
142527
|
+
LinkifyIt.prototype.tlds = function tlds(list3, keepOld) {
|
|
142528
|
+
list3 = Array.isArray(list3) ? list3 : [list3];
|
|
141972
142529
|
if (!keepOld) {
|
|
141973
|
-
this.__tlds__ =
|
|
142530
|
+
this.__tlds__ = list3.slice();
|
|
141974
142531
|
this.__tlds_replaced__ = true;
|
|
141975
142532
|
compile(this);
|
|
141976
142533
|
return this;
|
|
141977
142534
|
}
|
|
141978
|
-
this.__tlds__ = this.__tlds__.concat(
|
|
142535
|
+
this.__tlds__ = this.__tlds__.concat(list3).sort().filter(function(el, idx, arr) {
|
|
141979
142536
|
return el !== arr[idx - 1];
|
|
141980
142537
|
}).reverse();
|
|
141981
142538
|
compile(this);
|
|
@@ -145295,7 +145852,7 @@ var require_common2 = __commonJS((exports, module2) => {
|
|
|
145295
145852
|
var require_browser = __commonJS((exports, module2) => {
|
|
145296
145853
|
exports.formatArgs = formatArgs;
|
|
145297
145854
|
exports.save = save;
|
|
145298
|
-
exports.load =
|
|
145855
|
+
exports.load = load2;
|
|
145299
145856
|
exports.useColors = useColors;
|
|
145300
145857
|
exports.storage = localstorage();
|
|
145301
145858
|
exports.destroy = (() => {
|
|
@@ -145425,7 +145982,7 @@ var require_browser = __commonJS((exports, module2) => {
|
|
|
145425
145982
|
}
|
|
145426
145983
|
} catch (error40) {}
|
|
145427
145984
|
}
|
|
145428
|
-
function
|
|
145985
|
+
function load2() {
|
|
145429
145986
|
let r;
|
|
145430
145987
|
try {
|
|
145431
145988
|
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
@@ -145459,7 +146016,7 @@ var require_node3 = __commonJS((exports, module2) => {
|
|
|
145459
146016
|
exports.log = log2;
|
|
145460
146017
|
exports.formatArgs = formatArgs;
|
|
145461
146018
|
exports.save = save;
|
|
145462
|
-
exports.load =
|
|
146019
|
+
exports.load = load2;
|
|
145463
146020
|
exports.useColors = useColors;
|
|
145464
146021
|
exports.destroy = util4.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
145465
146022
|
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
@@ -145599,7 +146156,7 @@ var require_node3 = __commonJS((exports, module2) => {
|
|
|
145599
146156
|
delete process.env.DEBUG;
|
|
145600
146157
|
}
|
|
145601
146158
|
}
|
|
145602
|
-
function
|
|
146159
|
+
function load2() {
|
|
145603
146160
|
return process.env.DEBUG;
|
|
145604
146161
|
}
|
|
145605
146162
|
function init2(debug) {
|
|
@@ -161065,8 +161622,8 @@ var require_object_inspect = __commonJS((exports, module2) => {
|
|
|
161065
161622
|
function weakCollectionOf(type) {
|
|
161066
161623
|
return type + " { ? }";
|
|
161067
161624
|
}
|
|
161068
|
-
function collectionOf(type, size,
|
|
161069
|
-
var joinedEntries = indent ? indentedJoin(
|
|
161625
|
+
function collectionOf(type, size, entries2, indent) {
|
|
161626
|
+
var joinedEntries = indent ? indentedJoin(entries2, indent) : $join.call(entries2, ", ");
|
|
161070
161627
|
return type + " (" + size + ") {" + joinedEntries + "}";
|
|
161071
161628
|
}
|
|
161072
161629
|
function singleLineValues(xs) {
|
|
@@ -161148,15 +161705,15 @@ var require_object_inspect = __commonJS((exports, module2) => {
|
|
|
161148
161705
|
var require_side_channel_list = __commonJS((exports, module2) => {
|
|
161149
161706
|
var inspect = require_object_inspect();
|
|
161150
161707
|
var $TypeError = require_type();
|
|
161151
|
-
var listGetNode = function(
|
|
161152
|
-
var prev =
|
|
161708
|
+
var listGetNode = function(list3, key, isDelete) {
|
|
161709
|
+
var prev = list3;
|
|
161153
161710
|
var curr;
|
|
161154
161711
|
for (;(curr = prev.next) != null; prev = curr) {
|
|
161155
161712
|
if (curr.key === key) {
|
|
161156
161713
|
prev.next = curr.next;
|
|
161157
161714
|
if (!isDelete) {
|
|
161158
|
-
curr.next =
|
|
161159
|
-
|
|
161715
|
+
curr.next = list3.next;
|
|
161716
|
+
list3.next = curr;
|
|
161160
161717
|
}
|
|
161161
161718
|
return curr;
|
|
161162
161719
|
}
|
|
@@ -162375,9 +162932,9 @@ var require_stringify3 = __commonJS((exports, module2) => {
|
|
|
162375
162932
|
}
|
|
162376
162933
|
};
|
|
162377
162934
|
var isArray = Array.isArray;
|
|
162378
|
-
var
|
|
162935
|
+
var push2 = Array.prototype.push;
|
|
162379
162936
|
var pushToArray = function(arr, valueOrArray) {
|
|
162380
|
-
|
|
162937
|
+
push2.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
162381
162938
|
};
|
|
162382
162939
|
var toISO = Date.prototype.toISOString;
|
|
162383
162940
|
var defaultFormat = formats["default"];
|
|
@@ -170227,9 +170784,9 @@ var require_caller = __commonJS((exports, module2) => {
|
|
|
170227
170784
|
if (!Array.isArray(stack)) {
|
|
170228
170785
|
return;
|
|
170229
170786
|
}
|
|
170230
|
-
const
|
|
170787
|
+
const entries2 = stack.slice(2);
|
|
170231
170788
|
const fileNames = [];
|
|
170232
|
-
for (const entry of
|
|
170789
|
+
for (const entry of entries2) {
|
|
170233
170790
|
if (!entry) {
|
|
170234
170791
|
continue;
|
|
170235
170792
|
}
|
|
@@ -182143,10 +182700,10 @@ var require_tools2 = __commonJS((exports, module2) => {
|
|
|
182143
182700
|
}
|
|
182144
182701
|
return tools.normalizePath(connection, a) === tools.normalizePath(connection, b2);
|
|
182145
182702
|
},
|
|
182146
|
-
updateCapabilities(
|
|
182703
|
+
updateCapabilities(list3) {
|
|
182147
182704
|
let map3 = new Map;
|
|
182148
|
-
if (
|
|
182149
|
-
|
|
182705
|
+
if (list3 && Array.isArray(list3)) {
|
|
182706
|
+
list3.forEach((val) => {
|
|
182150
182707
|
if (typeof val.value !== "string") {
|
|
182151
182708
|
return false;
|
|
182152
182709
|
}
|
|
@@ -182435,8 +182992,8 @@ var require_tools2 = __commonJS((exports, module2) => {
|
|
|
182435
182992
|
}
|
|
182436
182993
|
return obj.value;
|
|
182437
182994
|
};
|
|
182438
|
-
let processAddresses = function(
|
|
182439
|
-
return [].concat(
|
|
182995
|
+
let processAddresses = function(list3) {
|
|
182996
|
+
return [].concat(list3 || []).map((addr) => {
|
|
182440
182997
|
let address = (getStrValue(addr[2]) || "") + "@" + (getStrValue(addr[3]) || "");
|
|
182441
182998
|
if (address === "@") {
|
|
182442
182999
|
address = "";
|
|
@@ -182705,17 +183262,17 @@ var require_tools2 = __commonJS((exports, module2) => {
|
|
|
182705
183262
|
if (first === second) {
|
|
182706
183263
|
return first;
|
|
182707
183264
|
}
|
|
182708
|
-
let
|
|
183265
|
+
let list3 = [];
|
|
182709
183266
|
if (first < second) {
|
|
182710
183267
|
for (let i2 = first;i2 <= second; i2++) {
|
|
182711
|
-
|
|
183268
|
+
list3.push(i2);
|
|
182712
183269
|
}
|
|
182713
183270
|
} else {
|
|
182714
183271
|
for (let i2 = first;i2 >= second; i2--) {
|
|
182715
|
-
|
|
183272
|
+
list3.push(i2);
|
|
182716
183273
|
}
|
|
182717
183274
|
}
|
|
182718
|
-
return
|
|
183275
|
+
return list3;
|
|
182719
183276
|
});
|
|
182720
183277
|
},
|
|
182721
183278
|
getDecoder(charset) {
|
|
@@ -182725,22 +183282,22 @@ var require_tools2 = __commonJS((exports, module2) => {
|
|
|
182725
183282
|
}
|
|
182726
183283
|
return iconv.decodeStream(charset);
|
|
182727
183284
|
},
|
|
182728
|
-
packMessageRange(
|
|
182729
|
-
if (!Array.isArray(
|
|
182730
|
-
|
|
183285
|
+
packMessageRange(list3) {
|
|
183286
|
+
if (!Array.isArray(list3)) {
|
|
183287
|
+
list3 = [].concat(list3 || []);
|
|
182731
183288
|
}
|
|
182732
|
-
if (!
|
|
183289
|
+
if (!list3.length) {
|
|
182733
183290
|
return "";
|
|
182734
183291
|
}
|
|
182735
|
-
|
|
182736
|
-
let last =
|
|
183292
|
+
list3.sort((a, b2) => a - b2);
|
|
183293
|
+
let last = list3[list3.length - 1];
|
|
182737
183294
|
let result = [[last]];
|
|
182738
|
-
for (let i2 =
|
|
182739
|
-
if (
|
|
182740
|
-
result[0].unshift(
|
|
183295
|
+
for (let i2 = list3.length - 2;i2 >= 0; i2--) {
|
|
183296
|
+
if (list3[i2] === list3[i2 + 1] - 1) {
|
|
183297
|
+
result[0].unshift(list3[i2]);
|
|
182741
183298
|
continue;
|
|
182742
183299
|
}
|
|
182743
|
-
result.unshift([
|
|
183300
|
+
result.unshift([list3[i2]]);
|
|
182744
183301
|
}
|
|
182745
183302
|
result = result.map((item) => {
|
|
182746
183303
|
if (item.length === 1) {
|
|
@@ -183296,7 +183853,7 @@ var require_list = __commonJS((exports, module2) => {
|
|
|
183296
183853
|
let listCommand = connection.capabilities.has("XLIST") && !connection.capabilities.has("SPECIAL-USE") ? "XLIST" : "LIST";
|
|
183297
183854
|
let response;
|
|
183298
183855
|
try {
|
|
183299
|
-
let
|
|
183856
|
+
let entries2 = [];
|
|
183300
183857
|
let statusMap = new Map;
|
|
183301
183858
|
let returnArgs = [];
|
|
183302
183859
|
let statusQueryAttributes = [];
|
|
@@ -183382,7 +183939,7 @@ var require_list = __commonJS((exports, module2) => {
|
|
|
183382
183939
|
if (specialUseFlag) {
|
|
183383
183940
|
addSpecialUseMatch(entry, specialUseFlag, flagSource);
|
|
183384
183941
|
}
|
|
183385
|
-
|
|
183942
|
+
entries2.push(entry);
|
|
183386
183943
|
},
|
|
183387
183944
|
STATUS: async (untagged) => {
|
|
183388
183945
|
let statusPath = normalizePath(connection, decodePath(connection, untagged.attributes[0] && untagged.attributes[0].value || ""));
|
|
@@ -183427,13 +183984,13 @@ var require_list = __commonJS((exports, module2) => {
|
|
|
183427
183984
|
let normalizedReference = normalizePath(connection, reference || "");
|
|
183428
183985
|
await runList(normalizedReference, normalizePath(connection, mailbox || "", true));
|
|
183429
183986
|
if (options.listOnly) {
|
|
183430
|
-
return
|
|
183987
|
+
return entries2;
|
|
183431
183988
|
}
|
|
183432
183989
|
if (normalizedReference && !specialUseMatches["\\Inbox"]) {
|
|
183433
183990
|
await runList("", "INBOX");
|
|
183434
183991
|
}
|
|
183435
183992
|
if (options.statusQuery) {
|
|
183436
|
-
for (let entry of
|
|
183993
|
+
for (let entry of entries2) {
|
|
183437
183994
|
if (!entry.flags.has("\\Noselect") && !entry.flags.has("\\NonExistent")) {
|
|
183438
183995
|
if (statusMap.has(entry.path)) {
|
|
183439
183996
|
entry.status = statusMap.get(entry.path);
|
|
@@ -183469,7 +184026,7 @@ var require_list = __commonJS((exports, module2) => {
|
|
|
183469
184026
|
entry.parentPath = entry.delimiter && entry.path ? entry.path.substr(0, entry.path.lastIndexOf(entry.delimiter)) : "";
|
|
183470
184027
|
entry.parent = entry.delimiter ? entry.path.split(entry.delimiter) : [entry.path];
|
|
183471
184028
|
entry.name = entry.parent.pop();
|
|
183472
|
-
let existing =
|
|
184029
|
+
let existing = entries2.find((existing2) => existing2.path === entry.path);
|
|
183473
184030
|
if (existing) {
|
|
183474
184031
|
existing.subscribed = true;
|
|
183475
184032
|
entry.flags.forEach((flag) => existing.flags.add(flag));
|
|
@@ -183492,11 +184049,11 @@ var require_list = __commonJS((exports, module2) => {
|
|
|
183492
184049
|
sortedEntries[0].entry.specialUseSource = sortedEntries[0].source;
|
|
183493
184050
|
}
|
|
183494
184051
|
}
|
|
183495
|
-
let inboxEntry =
|
|
184052
|
+
let inboxEntry = entries2.find((entry) => entry.specialUse === "\\Inbox");
|
|
183496
184053
|
if (inboxEntry && !inboxEntry.subscribed) {
|
|
183497
184054
|
inboxEntry.subscribed = true;
|
|
183498
184055
|
}
|
|
183499
|
-
return
|
|
184056
|
+
return entries2.sort((a, b2) => {
|
|
183500
184057
|
if (a.specialUse && !b2.specialUse) {
|
|
183501
184058
|
return -1;
|
|
183502
184059
|
}
|
|
@@ -184346,10 +184903,10 @@ var require_search_compiler = __commonJS((exports, module2) => {
|
|
|
184346
184903
|
}
|
|
184347
184904
|
break;
|
|
184348
184905
|
}
|
|
184349
|
-
let genOrTree = (
|
|
184906
|
+
let genOrTree = (list3) => {
|
|
184350
184907
|
let group = false;
|
|
184351
184908
|
let groups = [];
|
|
184352
|
-
|
|
184909
|
+
list3.forEach((entry, i2) => {
|
|
184353
184910
|
if (i2 % 2 === 0) {
|
|
184354
184911
|
group = [entry];
|
|
184355
184912
|
} else {
|
|
@@ -184573,9 +185130,9 @@ var require_append = __commonJS((exports, module2) => {
|
|
|
184573
185130
|
}
|
|
184574
185131
|
}
|
|
184575
185132
|
if (map3.seq && !map3.uid) {
|
|
184576
|
-
let
|
|
184577
|
-
if (
|
|
184578
|
-
map3.uid =
|
|
185133
|
+
let list3 = await connection.search({ seq: map3.seq }, { uid: true });
|
|
185134
|
+
if (list3 && list3.length) {
|
|
185135
|
+
map3.uid = list3[0];
|
|
184579
185136
|
}
|
|
184580
185137
|
}
|
|
184581
185138
|
return map3;
|
|
@@ -184628,8 +185185,8 @@ var require_status2 = __commonJS((exports, module2) => {
|
|
|
184628
185185
|
untagged: {
|
|
184629
185186
|
STATUS: async (untagged) => {
|
|
184630
185187
|
let updateCurrent = connection.state === connection.states.SELECTED && path6 === connection.mailbox.path;
|
|
184631
|
-
let
|
|
184632
|
-
if (!
|
|
185188
|
+
let list3 = untagged.attributes && Array.isArray(untagged.attributes[1]) ? untagged.attributes[1] : false;
|
|
185189
|
+
if (!list3) {
|
|
184633
185190
|
return;
|
|
184634
185191
|
}
|
|
184635
185192
|
const STATUS_FIELD_MAP = {
|
|
@@ -184663,7 +185220,7 @@ var require_status2 = __commonJS((exports, module2) => {
|
|
|
184663
185220
|
}
|
|
184664
185221
|
};
|
|
184665
185222
|
let key;
|
|
184666
|
-
|
|
185223
|
+
list3.forEach((entry, i2) => {
|
|
184667
185224
|
if (i2 % 2 === 0) {
|
|
184668
185225
|
key = entry && typeof entry.value === "string" ? entry.value : false;
|
|
184669
185226
|
return;
|
|
@@ -186612,7 +187169,7 @@ var init_imap_flow = __esm(() => {
|
|
|
186612
187169
|
return false;
|
|
186613
187170
|
}
|
|
186614
187171
|
let finished = false;
|
|
186615
|
-
let
|
|
187172
|
+
let push2 = false;
|
|
186616
187173
|
let rowQueue = [];
|
|
186617
187174
|
let getNext = () => new Promise((resolve4, reject) => {
|
|
186618
187175
|
let check2 = () => {
|
|
@@ -186627,8 +187184,8 @@ var init_imap_flow = __esm(() => {
|
|
|
186627
187184
|
if (finished) {
|
|
186628
187185
|
return resolve4(null);
|
|
186629
187186
|
}
|
|
186630
|
-
|
|
186631
|
-
|
|
187187
|
+
push2 = () => {
|
|
187188
|
+
push2 = false;
|
|
186632
187189
|
check2();
|
|
186633
187190
|
};
|
|
186634
187191
|
};
|
|
@@ -186645,19 +187202,19 @@ var init_imap_flow = __esm(() => {
|
|
|
186645
187202
|
next
|
|
186646
187203
|
}
|
|
186647
187204
|
});
|
|
186648
|
-
if (typeof
|
|
186649
|
-
|
|
187205
|
+
if (typeof push2 === "function") {
|
|
187206
|
+
push2();
|
|
186650
187207
|
}
|
|
186651
187208
|
}
|
|
186652
187209
|
}).then(() => {
|
|
186653
187210
|
finished = true;
|
|
186654
|
-
if (typeof
|
|
186655
|
-
|
|
187211
|
+
if (typeof push2 === "function") {
|
|
187212
|
+
push2();
|
|
186656
187213
|
}
|
|
186657
187214
|
}).catch((err) => {
|
|
186658
187215
|
rowQueue.push({ err });
|
|
186659
|
-
if (typeof
|
|
186660
|
-
|
|
187216
|
+
if (typeof push2 === "function") {
|
|
187217
|
+
push2();
|
|
186661
187218
|
}
|
|
186662
187219
|
});
|
|
186663
187220
|
let res;
|
|
@@ -188182,6 +188739,9 @@ function createAllTools(ctx4) {
|
|
|
188182
188739
|
spawn_pentest_swarm: spawnPentestSwarm(ctx4),
|
|
188183
188740
|
spawn_coding_agent: spawnCodingAgent(ctx4),
|
|
188184
188741
|
provide_comparison_results: provideComparisonResults(ctx4),
|
|
188742
|
+
add_memory: addMemory2(ctx4),
|
|
188743
|
+
list_memories: listMemories2(ctx4),
|
|
188744
|
+
get_memory: getMemory2(ctx4),
|
|
188185
188745
|
...createEmailToolset(ctx4),
|
|
188186
188746
|
email_list_inboxes: emailListInboxes(ctx4),
|
|
188187
188747
|
email_list_messages: emailListMessages(ctx4),
|
|
@@ -188217,6 +188777,9 @@ var init_tools = __esm(() => {
|
|
|
188217
188777
|
init_spawnPentestSwarm();
|
|
188218
188778
|
init_spawnCodingAgent();
|
|
188219
188779
|
init_provideComparisonResults();
|
|
188780
|
+
init_addMemory();
|
|
188781
|
+
init_listMemories();
|
|
188782
|
+
init_getMemory();
|
|
188220
188783
|
init_email();
|
|
188221
188784
|
init_browserTools();
|
|
188222
188785
|
init_executeCommand();
|
|
@@ -188243,6 +188806,9 @@ var init_tools = __esm(() => {
|
|
|
188243
188806
|
init_spawnPentestSwarm();
|
|
188244
188807
|
init_spawnCodingAgent();
|
|
188245
188808
|
init_provideComparisonResults();
|
|
188809
|
+
init_addMemory();
|
|
188810
|
+
init_listMemories();
|
|
188811
|
+
init_getMemory();
|
|
188246
188812
|
init_email();
|
|
188247
188813
|
init_listInboxes();
|
|
188248
188814
|
init_listMessages();
|
|
@@ -188276,6 +188842,9 @@ var init_tools = __esm(() => {
|
|
|
188276
188842
|
"spawn_pentest_swarm",
|
|
188277
188843
|
"spawn_coding_agent",
|
|
188278
188844
|
"provide_comparison_results",
|
|
188845
|
+
"add_memory",
|
|
188846
|
+
"list_memories",
|
|
188847
|
+
"get_memory",
|
|
188279
188848
|
"email_list_inboxes",
|
|
188280
188849
|
"email_list_messages",
|
|
188281
188850
|
"email_get_message",
|
|
@@ -191049,13 +191618,13 @@ https://github.com/highlightjs/highlight.js/issues/2277`);
|
|
|
191049
191618
|
return origin.returnEnd ? 0 : lexeme.length;
|
|
191050
191619
|
}
|
|
191051
191620
|
function processContinuations() {
|
|
191052
|
-
const
|
|
191621
|
+
const list3 = [];
|
|
191053
191622
|
for (let current = top;current !== language; current = current.parent) {
|
|
191054
191623
|
if (current.scope) {
|
|
191055
|
-
|
|
191624
|
+
list3.unshift(current.scope);
|
|
191056
191625
|
}
|
|
191057
191626
|
}
|
|
191058
|
-
|
|
191627
|
+
list3.forEach((item) => emitter.openNode(item));
|
|
191059
191628
|
}
|
|
191060
191629
|
let lastMatch = {};
|
|
191061
191630
|
function processLexeme(textBeforeMatch, match) {
|
|
@@ -196627,7 +197196,7 @@ var require_coffeescript = __commonJS((exports, module2) => {
|
|
|
196627
197196
|
"function",
|
|
196628
197197
|
"static"
|
|
196629
197198
|
];
|
|
196630
|
-
const excluding = (
|
|
197199
|
+
const excluding = (list3) => (kw) => !list3.includes(kw);
|
|
196631
197200
|
const KEYWORDS$1 = {
|
|
196632
197201
|
keyword: KEYWORDS.concat(COFFEE_KEYWORDS).filter(excluding(NOT_VALID_KEYWORDS)),
|
|
196633
197202
|
literal: LITERALS.concat(COFFEE_LITERALS),
|
|
@@ -210081,8 +210650,8 @@ var require_javascript = __commonJS((exports, module2) => {
|
|
|
210081
210650
|
match: /\b[A-Z][A-Z_0-9]+\b/,
|
|
210082
210651
|
className: "variable.constant"
|
|
210083
210652
|
};
|
|
210084
|
-
function noneOf(
|
|
210085
|
-
return regex.concat("(?!",
|
|
210653
|
+
function noneOf(list3) {
|
|
210654
|
+
return regex.concat("(?!", list3.join("|"), ")");
|
|
210086
210655
|
}
|
|
210087
210656
|
const FUNCTION_CALL = {
|
|
210088
210657
|
match: regex.concat(/\b/, noneOf([
|
|
@@ -232685,8 +233254,8 @@ var require_sql = __commonJS((exports, module2) => {
|
|
|
232685
233254
|
relevance: 0,
|
|
232686
233255
|
keywords: { built_in: FUNCTIONS }
|
|
232687
233256
|
};
|
|
232688
|
-
function kws_to_regex(
|
|
232689
|
-
return regex.concat(/\b/, regex.either(...
|
|
233257
|
+
function kws_to_regex(list3) {
|
|
233258
|
+
return regex.concat(/\b/, regex.either(...list3.map((kw) => {
|
|
232690
233259
|
return kw.replace(/\s+/, "\\s+");
|
|
232691
233260
|
})), /\b/);
|
|
232692
233261
|
}
|
|
@@ -232695,13 +233264,13 @@ var require_sql = __commonJS((exports, module2) => {
|
|
|
232695
233264
|
match: kws_to_regex(COMBOS),
|
|
232696
233265
|
relevance: 0
|
|
232697
233266
|
};
|
|
232698
|
-
function reduceRelevancy(
|
|
233267
|
+
function reduceRelevancy(list3, {
|
|
232699
233268
|
exceptions,
|
|
232700
233269
|
when
|
|
232701
233270
|
} = {}) {
|
|
232702
233271
|
const qualifyFn = when;
|
|
232703
233272
|
exceptions = exceptions || [];
|
|
232704
|
-
return
|
|
233273
|
+
return list3.map((item) => {
|
|
232705
233274
|
if (item.match(/\|\d+$/) || exceptions.includes(item)) {
|
|
232706
233275
|
return item;
|
|
232707
233276
|
} else if (qualifyFn(item)) {
|
|
@@ -236386,8 +236955,8 @@ var require_typescript = __commonJS((exports, module2) => {
|
|
|
236386
236955
|
match: /\b[A-Z][A-Z_0-9]+\b/,
|
|
236387
236956
|
className: "variable.constant"
|
|
236388
236957
|
};
|
|
236389
|
-
function noneOf(
|
|
236390
|
-
return regex.concat("(?!",
|
|
236958
|
+
function noneOf(list3) {
|
|
236959
|
+
return regex.concat("(?!", list3.join("|"), ")");
|
|
236391
236960
|
}
|
|
236392
236961
|
const FUNCTION_CALL = {
|
|
236393
236962
|
match: regex.concat(/\b/, noneOf([
|
|
@@ -266766,239 +267335,7 @@ function create(prefix, descending2, timestamp) {
|
|
|
266766
267335
|
|
|
266767
267336
|
// src/core/session/index.ts
|
|
266768
267337
|
init_installation();
|
|
266769
|
-
|
|
266770
|
-
// src/core/storage/index.ts
|
|
266771
|
-
import os3 from "os";
|
|
266772
|
-
import path3 from "path";
|
|
266773
|
-
import fs3 from "fs/promises";
|
|
266774
|
-
init_zod();
|
|
266775
|
-
|
|
266776
|
-
// src/util/errors.ts
|
|
266777
|
-
init_zod();
|
|
266778
|
-
|
|
266779
|
-
class NamedError extends Error {
|
|
266780
|
-
static create(name, data) {
|
|
266781
|
-
const schema2 = zod_default.object({
|
|
266782
|
-
name: zod_default.literal(name),
|
|
266783
|
-
data
|
|
266784
|
-
});
|
|
266785
|
-
const result = class extends NamedError {
|
|
266786
|
-
data;
|
|
266787
|
-
static Schema = schema2;
|
|
266788
|
-
name = name;
|
|
266789
|
-
constructor(data2, options) {
|
|
266790
|
-
super(name, options);
|
|
266791
|
-
this.data = data2;
|
|
266792
|
-
this.name = name;
|
|
266793
|
-
}
|
|
266794
|
-
static isInstance(input) {
|
|
266795
|
-
return typeof input === "object" && input !== null && "name" in input && input.name === name;
|
|
266796
|
-
}
|
|
266797
|
-
schema() {
|
|
266798
|
-
return schema2;
|
|
266799
|
-
}
|
|
266800
|
-
toObject() {
|
|
266801
|
-
return {
|
|
266802
|
-
name,
|
|
266803
|
-
data: this.data
|
|
266804
|
-
};
|
|
266805
|
-
}
|
|
266806
|
-
};
|
|
266807
|
-
Object.defineProperty(result, "name", { value: name });
|
|
266808
|
-
return result;
|
|
266809
|
-
}
|
|
266810
|
-
static Unknown = NamedError.create("UnknownError", zod_default.object({
|
|
266811
|
-
message: zod_default.string()
|
|
266812
|
-
}));
|
|
266813
|
-
}
|
|
266814
|
-
|
|
266815
|
-
// src/util/lock.ts
|
|
266816
|
-
var locks = new Map;
|
|
266817
|
-
function getLock(key) {
|
|
266818
|
-
if (!locks.has(key)) {
|
|
266819
|
-
locks.set(key, {
|
|
266820
|
-
readers: 0,
|
|
266821
|
-
writer: false,
|
|
266822
|
-
waitingReaders: [],
|
|
266823
|
-
waitingWriters: []
|
|
266824
|
-
});
|
|
266825
|
-
}
|
|
266826
|
-
return locks.get(key);
|
|
266827
|
-
}
|
|
266828
|
-
function processQueue(key) {
|
|
266829
|
-
const lock = locks.get(key);
|
|
266830
|
-
if (!lock || lock.writer || lock.readers > 0)
|
|
266831
|
-
return;
|
|
266832
|
-
if (lock.waitingWriters.length > 0) {
|
|
266833
|
-
const nextWriter = lock.waitingWriters.shift();
|
|
266834
|
-
nextWriter();
|
|
266835
|
-
return;
|
|
266836
|
-
}
|
|
266837
|
-
while (lock.waitingReaders.length > 0) {
|
|
266838
|
-
const nextReader = lock.waitingReaders.shift();
|
|
266839
|
-
nextReader();
|
|
266840
|
-
}
|
|
266841
|
-
if (lock.readers === 0 && !lock.writer && lock.waitingReaders.length === 0 && lock.waitingWriters.length === 0) {
|
|
266842
|
-
locks.delete(key);
|
|
266843
|
-
}
|
|
266844
|
-
}
|
|
266845
|
-
async function read(key) {
|
|
266846
|
-
const lock = getLock(key);
|
|
266847
|
-
return new Promise((resolve3) => {
|
|
266848
|
-
if (!lock.writer && lock.waitingWriters.length === 0) {
|
|
266849
|
-
lock.readers++;
|
|
266850
|
-
resolve3({
|
|
266851
|
-
[Symbol.dispose]: () => {
|
|
266852
|
-
lock.readers--;
|
|
266853
|
-
processQueue(key);
|
|
266854
|
-
}
|
|
266855
|
-
});
|
|
266856
|
-
} else {
|
|
266857
|
-
lock.waitingReaders.push(() => {
|
|
266858
|
-
lock.readers++;
|
|
266859
|
-
resolve3({
|
|
266860
|
-
[Symbol.dispose]: () => {
|
|
266861
|
-
lock.readers--;
|
|
266862
|
-
processQueue(key);
|
|
266863
|
-
}
|
|
266864
|
-
});
|
|
266865
|
-
});
|
|
266866
|
-
}
|
|
266867
|
-
});
|
|
266868
|
-
}
|
|
266869
|
-
async function write(key) {
|
|
266870
|
-
const lock = getLock(key);
|
|
266871
|
-
return new Promise((resolve3) => {
|
|
266872
|
-
if (!lock.writer && lock.readers === 0) {
|
|
266873
|
-
lock.writer = true;
|
|
266874
|
-
resolve3({
|
|
266875
|
-
[Symbol.dispose]: () => {
|
|
266876
|
-
lock.writer = false;
|
|
266877
|
-
processQueue(key);
|
|
266878
|
-
}
|
|
266879
|
-
});
|
|
266880
|
-
} else {
|
|
266881
|
-
lock.waitingWriters.push(() => {
|
|
266882
|
-
lock.writer = true;
|
|
266883
|
-
resolve3({
|
|
266884
|
-
[Symbol.dispose]: () => {
|
|
266885
|
-
lock.writer = false;
|
|
266886
|
-
processQueue(key);
|
|
266887
|
-
}
|
|
266888
|
-
});
|
|
266889
|
-
});
|
|
266890
|
-
}
|
|
266891
|
-
});
|
|
266892
|
-
}
|
|
266893
|
-
|
|
266894
|
-
// src/core/storage/index.ts
|
|
266895
|
-
var NotFoundError = NamedError.create("NotFoundError", zod_default.object({
|
|
266896
|
-
message: zod_default.string()
|
|
266897
|
-
}));
|
|
266898
|
-
async function remove(key) {
|
|
266899
|
-
const dir = path3.join(os3.homedir(), ".pensar");
|
|
266900
|
-
const target = path3.join(dir, ...key) + ".json";
|
|
266901
|
-
return withErrorHandling(async () => {
|
|
266902
|
-
await fs3.unlink(target).catch(() => {});
|
|
266903
|
-
});
|
|
266904
|
-
}
|
|
266905
|
-
async function write2(key, content, ext) {
|
|
266906
|
-
const dir = path3.join(os3.homedir(), ".pensar");
|
|
266907
|
-
const target = path3.join(dir, ...key) + (ext ? ext : ".json");
|
|
266908
|
-
return withErrorHandling(async () => {
|
|
266909
|
-
let __stack = [];
|
|
266910
|
-
try {
|
|
266911
|
-
const _2 = __using(__stack, await write(target), 0);
|
|
266912
|
-
await fs3.mkdir(path3.dirname(target), { recursive: true });
|
|
266913
|
-
await fs3.writeFile(target, JSON.stringify(content, null, 2), "utf-8");
|
|
266914
|
-
} catch (_catch) {
|
|
266915
|
-
var _err = _catch, _hasErr = 1;
|
|
266916
|
-
} finally {
|
|
266917
|
-
__callDispose(__stack, _err, _hasErr);
|
|
266918
|
-
}
|
|
266919
|
-
});
|
|
266920
|
-
}
|
|
266921
|
-
async function createDir(key) {
|
|
266922
|
-
const dir = path3.join(os3.homedir(), ".pensar");
|
|
266923
|
-
const target = path3.join(dir, ...key);
|
|
266924
|
-
return withErrorHandling(async () => {
|
|
266925
|
-
let __stack = [];
|
|
266926
|
-
try {
|
|
266927
|
-
const _2 = __using(__stack, await write(target), 0);
|
|
266928
|
-
await fs3.mkdir(target, { recursive: true });
|
|
266929
|
-
} catch (_catch) {
|
|
266930
|
-
var _err = _catch, _hasErr = 1;
|
|
266931
|
-
} finally {
|
|
266932
|
-
__callDispose(__stack, _err, _hasErr);
|
|
266933
|
-
}
|
|
266934
|
-
});
|
|
266935
|
-
}
|
|
266936
|
-
async function writeRaw(key, content) {
|
|
266937
|
-
const dir = path3.join(os3.homedir(), ".pensar");
|
|
266938
|
-
const target = path3.join(dir, ...key);
|
|
266939
|
-
return withErrorHandling(async () => {
|
|
266940
|
-
let __stack = [];
|
|
266941
|
-
try {
|
|
266942
|
-
const _2 = __using(__stack, await write(target), 0);
|
|
266943
|
-
const parentDir = path3.dirname(target);
|
|
266944
|
-
await fs3.mkdir(parentDir, { recursive: true });
|
|
266945
|
-
await fs3.writeFile(target, content, "utf-8");
|
|
266946
|
-
} catch (_catch) {
|
|
266947
|
-
var _err = _catch, _hasErr = 1;
|
|
266948
|
-
} finally {
|
|
266949
|
-
__callDispose(__stack, _err, _hasErr);
|
|
266950
|
-
}
|
|
266951
|
-
});
|
|
266952
|
-
}
|
|
266953
|
-
async function read2(key, ext) {
|
|
266954
|
-
const dir = path3.join(os3.homedir(), ".pensar");
|
|
266955
|
-
const target = path3.join(dir, ...key) + (ext ? ext : ".json");
|
|
266956
|
-
return withErrorHandling(async () => {
|
|
266957
|
-
let __stack = [];
|
|
266958
|
-
try {
|
|
266959
|
-
const _2 = __using(__stack, await read(target), 0);
|
|
266960
|
-
const text = await fs3.readFile(target, "utf-8");
|
|
266961
|
-
const result = ext ? text : JSON.parse(text);
|
|
266962
|
-
return result;
|
|
266963
|
-
} catch (_catch) {
|
|
266964
|
-
var _err = _catch, _hasErr = 1;
|
|
266965
|
-
} finally {
|
|
266966
|
-
__callDispose(__stack, _err, _hasErr);
|
|
266967
|
-
}
|
|
266968
|
-
});
|
|
266969
|
-
}
|
|
266970
|
-
async function update2(key, fn, ext) {
|
|
266971
|
-
const dir = path3.join(os3.homedir(), ".pensar");
|
|
266972
|
-
const target = path3.join(dir, ...key) + (ext ? ext : ".json");
|
|
266973
|
-
return withErrorHandling(async () => {
|
|
266974
|
-
let __stack = [];
|
|
266975
|
-
try {
|
|
266976
|
-
const _2 = __using(__stack, await write(target), 0);
|
|
266977
|
-
const text = await fs3.readFile(target, "utf-8");
|
|
266978
|
-
const content = ext ? text : JSON.parse(text);
|
|
266979
|
-
fn(content);
|
|
266980
|
-
await fs3.writeFile(target, JSON.stringify(content, null, 2), "utf-8");
|
|
266981
|
-
return content;
|
|
266982
|
-
} catch (_catch) {
|
|
266983
|
-
var _err = _catch, _hasErr = 1;
|
|
266984
|
-
} finally {
|
|
266985
|
-
__callDispose(__stack, _err, _hasErr);
|
|
266986
|
-
}
|
|
266987
|
-
});
|
|
266988
|
-
}
|
|
266989
|
-
async function withErrorHandling(body) {
|
|
266990
|
-
return body().catch((e) => {
|
|
266991
|
-
if (!(e instanceof Error))
|
|
266992
|
-
throw e;
|
|
266993
|
-
const errnoExcpetion = e;
|
|
266994
|
-
if (errnoExcpetion.code === "ENOENT") {
|
|
266995
|
-
throw new NotFoundError({
|
|
266996
|
-
message: `Resource not found: ${errnoExcpetion.path}`
|
|
266997
|
-
});
|
|
266998
|
-
}
|
|
266999
|
-
throw e;
|
|
267000
|
-
});
|
|
267001
|
-
}
|
|
267338
|
+
init_storage();
|
|
267002
267339
|
|
|
267003
267340
|
// src/core/services/rateLimiter/index.ts
|
|
267004
267341
|
function sleep(ms) {
|
|
@@ -267293,7 +267630,7 @@ async function update3(id, editor) {
|
|
|
267293
267630
|
console.info("updated session", result);
|
|
267294
267631
|
return result;
|
|
267295
267632
|
}
|
|
267296
|
-
async function*
|
|
267633
|
+
async function* list2() {
|
|
267297
267634
|
const sessionsDir = getSessionsDir();
|
|
267298
267635
|
let entries;
|
|
267299
267636
|
try {
|
|
@@ -267428,7 +267765,7 @@ var sessions = {
|
|
|
267428
267765
|
create: create2,
|
|
267429
267766
|
get: get2,
|
|
267430
267767
|
update: update3,
|
|
267431
|
-
list,
|
|
267768
|
+
list: list2,
|
|
267432
267769
|
remove: remove2,
|
|
267433
267770
|
updateMessage,
|
|
267434
267771
|
removeMessage,
|
|
@@ -267557,9 +267894,9 @@ function AgentProvider({ children }) {
|
|
|
267557
267894
|
}
|
|
267558
267895
|
const byProvider = new Map;
|
|
267559
267896
|
for (const m2 of available) {
|
|
267560
|
-
const
|
|
267561
|
-
|
|
267562
|
-
byProvider.set(m2.provider,
|
|
267897
|
+
const list3 = byProvider.get(m2.provider) || [];
|
|
267898
|
+
list3.push(m2);
|
|
267899
|
+
byProvider.set(m2.provider, list3);
|
|
267563
267900
|
}
|
|
267564
267901
|
let selectedModel = null;
|
|
267565
267902
|
for (const provider of PROVIDER_PREFERENCE) {
|
|
@@ -269044,10 +269381,10 @@ function useDialog() {
|
|
|
269044
269381
|
}
|
|
269045
269382
|
|
|
269046
269383
|
// src/tui/utils/scroll.ts
|
|
269047
|
-
function scrollToIndex(scrollBox, index,
|
|
269048
|
-
if (!scrollBox ||
|
|
269384
|
+
function scrollToIndex(scrollBox, index, list3, getId) {
|
|
269385
|
+
if (!scrollBox || list3.length === 0)
|
|
269049
269386
|
return;
|
|
269050
|
-
const item =
|
|
269387
|
+
const item = list3[index];
|
|
269051
269388
|
if (!item)
|
|
269052
269389
|
return;
|
|
269053
269390
|
const target = findChildById(scrollBox, getId(item));
|
|
@@ -269057,7 +269394,7 @@ function scrollToIndex(scrollBox, index, list2, getId) {
|
|
|
269057
269394
|
scrollBox.scrollTo(0);
|
|
269058
269395
|
return;
|
|
269059
269396
|
}
|
|
269060
|
-
if (index ===
|
|
269397
|
+
if (index === list3.length - 1) {
|
|
269061
269398
|
scrollBox.scrollTo(Infinity);
|
|
269062
269399
|
return;
|
|
269063
269400
|
}
|
|
@@ -269903,6 +270240,7 @@ var PromptInput = import_react30.forwardRef(function PromptInput2({
|
|
|
269903
270240
|
maxSuggestions = 10,
|
|
269904
270241
|
enableCommands = false,
|
|
269905
270242
|
onCommandExecute,
|
|
270243
|
+
commandHistory = [],
|
|
269906
270244
|
showPromptIndicator = false
|
|
269907
270245
|
}, ref) {
|
|
269908
270246
|
const { colors: colors2 } = useTheme();
|
|
@@ -269910,6 +270248,11 @@ var PromptInput = import_react30.forwardRef(function PromptInput2({
|
|
|
269910
270248
|
const { registerPromptRef } = useFocus();
|
|
269911
270249
|
const textareaRef = import_react30.useRef(null);
|
|
269912
270250
|
const [selectedSuggestionIndex, setSelectedSuggestionIndex] = import_react30.useState(-1);
|
|
270251
|
+
const [historyIndex, setHistoryIndex] = import_react30.useState(-1);
|
|
270252
|
+
const savedInputRef = import_react30.useRef("");
|
|
270253
|
+
const historyRef = import_react30.useRef(commandHistory);
|
|
270254
|
+
historyRef.current = commandHistory;
|
|
270255
|
+
const isNavigatingHistoryRef = import_react30.useRef(false);
|
|
269913
270256
|
const selectedIndexRef = import_react30.useRef(selectedSuggestionIndex);
|
|
269914
270257
|
const suggestionsRef = import_react30.useRef([]);
|
|
269915
270258
|
const onCommandExecuteRef = import_react30.useRef(onCommandExecute);
|
|
@@ -269957,28 +270300,76 @@ var PromptInput = import_react30.forwardRef(function PromptInput2({
|
|
|
269957
270300
|
return () => registerPromptRef(null);
|
|
269958
270301
|
}, [registerPromptRef]);
|
|
269959
270302
|
useKeyboard((key) => {
|
|
269960
|
-
if (!focused
|
|
270303
|
+
if (!focused)
|
|
269961
270304
|
return;
|
|
269962
|
-
if (
|
|
269963
|
-
|
|
270305
|
+
if (suggestions.length > 0) {
|
|
270306
|
+
if (key.name === "up") {
|
|
270307
|
+
setSelectedSuggestionIndex((prev) => prev <= 0 ? suggestions.length - 1 : prev - 1);
|
|
270308
|
+
return;
|
|
270309
|
+
}
|
|
270310
|
+
if (key.name === "down") {
|
|
270311
|
+
setSelectedSuggestionIndex((prev) => prev >= suggestions.length - 1 ? 0 : prev + 1);
|
|
270312
|
+
return;
|
|
270313
|
+
}
|
|
270314
|
+
if (key.name === "tab") {
|
|
270315
|
+
key.preventDefault?.();
|
|
270316
|
+
const currentSelectedIndex = selectedIndexRef.current;
|
|
270317
|
+
if (currentSelectedIndex >= 0 && currentSelectedIndex < suggestions.length) {
|
|
270318
|
+
const selected = suggestions[currentSelectedIndex];
|
|
270319
|
+
if (selected) {
|
|
270320
|
+
textareaRef.current?.setText(selected.value);
|
|
270321
|
+
setInputValue(selected.value);
|
|
270322
|
+
setSelectedSuggestionIndex(-1);
|
|
270323
|
+
textareaRef.current?.gotoLineEnd();
|
|
270324
|
+
}
|
|
270325
|
+
}
|
|
270326
|
+
return;
|
|
270327
|
+
}
|
|
269964
270328
|
return;
|
|
269965
270329
|
}
|
|
269966
|
-
|
|
269967
|
-
|
|
270330
|
+
const history = historyRef.current;
|
|
270331
|
+
if (history.length === 0)
|
|
270332
|
+
return;
|
|
270333
|
+
if (key.name === "up") {
|
|
270334
|
+
setHistoryIndex((prev) => {
|
|
270335
|
+
if (prev === -1) {
|
|
270336
|
+
savedInputRef.current = textareaRef.current?.plainText ?? "";
|
|
270337
|
+
}
|
|
270338
|
+
const next = Math.min(prev + 1, history.length - 1);
|
|
270339
|
+
const entry = history[history.length - 1 - next];
|
|
270340
|
+
if (entry !== undefined) {
|
|
270341
|
+
isNavigatingHistoryRef.current = true;
|
|
270342
|
+
textareaRef.current?.setText(entry);
|
|
270343
|
+
setInputValue(entry);
|
|
270344
|
+
isNavigatingHistoryRef.current = false;
|
|
270345
|
+
setTimeout(() => textareaRef.current?.gotoLineEnd(), 0);
|
|
270346
|
+
}
|
|
270347
|
+
return next;
|
|
270348
|
+
});
|
|
269968
270349
|
return;
|
|
269969
270350
|
}
|
|
269970
|
-
if (key.name === "
|
|
269971
|
-
|
|
269972
|
-
|
|
269973
|
-
|
|
269974
|
-
|
|
269975
|
-
|
|
269976
|
-
|
|
269977
|
-
|
|
269978
|
-
|
|
269979
|
-
|
|
270351
|
+
if (key.name === "down") {
|
|
270352
|
+
setHistoryIndex((prev) => {
|
|
270353
|
+
if (prev <= 0) {
|
|
270354
|
+
const saved = savedInputRef.current;
|
|
270355
|
+
isNavigatingHistoryRef.current = true;
|
|
270356
|
+
textareaRef.current?.setText(saved);
|
|
270357
|
+
setInputValue(saved);
|
|
270358
|
+
isNavigatingHistoryRef.current = false;
|
|
270359
|
+
setTimeout(() => textareaRef.current?.gotoLineEnd(), 0);
|
|
270360
|
+
return -1;
|
|
269980
270361
|
}
|
|
269981
|
-
|
|
270362
|
+
const next = prev - 1;
|
|
270363
|
+
const entry = history[history.length - 1 - next];
|
|
270364
|
+
if (entry !== undefined) {
|
|
270365
|
+
isNavigatingHistoryRef.current = true;
|
|
270366
|
+
textareaRef.current?.setText(entry);
|
|
270367
|
+
setInputValue(entry);
|
|
270368
|
+
isNavigatingHistoryRef.current = false;
|
|
270369
|
+
setTimeout(() => textareaRef.current?.gotoLineEnd(), 0);
|
|
270370
|
+
}
|
|
270371
|
+
return next;
|
|
270372
|
+
});
|
|
269982
270373
|
return;
|
|
269983
270374
|
}
|
|
269984
270375
|
});
|
|
@@ -270004,13 +270395,18 @@ var PromptInput = import_react30.forwardRef(function PromptInput2({
|
|
|
270004
270395
|
setInputValue("");
|
|
270005
270396
|
textareaRef.current?.setText("");
|
|
270006
270397
|
setSelectedSuggestionIndex(-1);
|
|
270398
|
+
setHistoryIndex(-1);
|
|
270007
270399
|
return;
|
|
270008
270400
|
}
|
|
270401
|
+
setHistoryIndex(-1);
|
|
270009
270402
|
onSubmitRef.current?.(valueToSubmit);
|
|
270010
270403
|
};
|
|
270011
270404
|
const handleContentChange = () => {
|
|
270012
270405
|
const text = textareaRef.current?.plainText ?? "";
|
|
270013
270406
|
setInputValue(text);
|
|
270407
|
+
if (historyIndex !== -1 && !isNavigatingHistoryRef.current) {
|
|
270408
|
+
setHistoryIndex(-1);
|
|
270409
|
+
}
|
|
270014
270410
|
};
|
|
270015
270411
|
return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
|
|
270016
270412
|
flexDirection: "column",
|
|
@@ -270092,6 +270488,45 @@ var PromptInput = import_react30.forwardRef(function PromptInput2({
|
|
|
270092
270488
|
}, undefined, true, undefined, this);
|
|
270093
270489
|
});
|
|
270094
270490
|
|
|
270491
|
+
// src/core/history.ts
|
|
270492
|
+
init_storage();
|
|
270493
|
+
var STORAGE_KEY = ["command-history"];
|
|
270494
|
+
var MAX_ENTRIES = 500;
|
|
270495
|
+
var entries = null;
|
|
270496
|
+
var loadPromise = null;
|
|
270497
|
+
async function ensureLoaded() {
|
|
270498
|
+
if (entries !== null)
|
|
270499
|
+
return entries;
|
|
270500
|
+
if (!loadPromise) {
|
|
270501
|
+
loadPromise = (async () => {
|
|
270502
|
+
try {
|
|
270503
|
+
const data = await read2(STORAGE_KEY);
|
|
270504
|
+
entries = Array.isArray(data) ? data : [];
|
|
270505
|
+
} catch {
|
|
270506
|
+
entries = [];
|
|
270507
|
+
}
|
|
270508
|
+
})();
|
|
270509
|
+
}
|
|
270510
|
+
await loadPromise;
|
|
270511
|
+
return entries;
|
|
270512
|
+
}
|
|
270513
|
+
async function load() {
|
|
270514
|
+
return ensureLoaded();
|
|
270515
|
+
}
|
|
270516
|
+
async function push(entry) {
|
|
270517
|
+
const history = await ensureLoaded();
|
|
270518
|
+
if (history[history.length - 1] === entry)
|
|
270519
|
+
return;
|
|
270520
|
+
history.push(entry);
|
|
270521
|
+
if (history.length > MAX_ENTRIES) {
|
|
270522
|
+
history.splice(0, history.length - MAX_ENTRIES);
|
|
270523
|
+
}
|
|
270524
|
+
write2(STORAGE_KEY, history).catch(() => {});
|
|
270525
|
+
}
|
|
270526
|
+
function getEntries() {
|
|
270527
|
+
return entries ?? [];
|
|
270528
|
+
}
|
|
270529
|
+
|
|
270095
270530
|
// src/tui/components/chat/home-view.tsx
|
|
270096
270531
|
function HomeView({ onNavigate, onStartSession }) {
|
|
270097
270532
|
const { colors: colors2 } = useTheme();
|
|
@@ -270102,6 +270537,10 @@ function HomeView({ onNavigate, onStartSession }) {
|
|
|
270102
270537
|
const { setInputValue } = useInput();
|
|
270103
270538
|
const { promptRef } = useFocus();
|
|
270104
270539
|
const [hintMessage, setHintMessage] = import_react32.useState(null);
|
|
270540
|
+
const [commandHistory, setCommandHistory] = import_react32.useState(getEntries);
|
|
270541
|
+
import_react32.useEffect(() => {
|
|
270542
|
+
load().then(setCommandHistory);
|
|
270543
|
+
}, []);
|
|
270105
270544
|
const launchOperator = import_react32.useCallback((message, options) => {
|
|
270106
270545
|
route.navigate({
|
|
270107
270546
|
type: "operator",
|
|
@@ -270109,11 +270548,15 @@ function HomeView({ onNavigate, onStartSession }) {
|
|
|
270109
270548
|
initialConfig: { requireApproval: options?.requireApproval ?? true }
|
|
270110
270549
|
});
|
|
270111
270550
|
}, [route]);
|
|
270551
|
+
const pushHistory = import_react32.useCallback((entry) => {
|
|
270552
|
+
push(entry).then(() => setCommandHistory([...getEntries()]));
|
|
270553
|
+
}, []);
|
|
270112
270554
|
const handleSubmit = import_react32.useCallback((value) => {
|
|
270113
270555
|
if (!value.trim())
|
|
270114
270556
|
return;
|
|
270557
|
+
pushHistory(value.trim());
|
|
270115
270558
|
launchOperator(value.trim());
|
|
270116
|
-
}, [launchOperator]);
|
|
270559
|
+
}, [launchOperator, pushHistory]);
|
|
270117
270560
|
import_react32.useEffect(() => {
|
|
270118
270561
|
if (!hintMessage)
|
|
270119
270562
|
return;
|
|
@@ -270121,7 +270564,9 @@ function HomeView({ onNavigate, onStartSession }) {
|
|
|
270121
270564
|
return () => clearTimeout(timer);
|
|
270122
270565
|
}, [hintMessage]);
|
|
270123
270566
|
const handleCommandExecute = import_react32.useCallback(async (command) => {
|
|
270124
|
-
const
|
|
270567
|
+
const trimmed = command.trim();
|
|
270568
|
+
pushHistory(trimmed);
|
|
270569
|
+
const parts = trimmed.replace(/^\/+/, "").split(/\s+/);
|
|
270125
270570
|
const slug = parts[0]?.toLowerCase() ?? "";
|
|
270126
270571
|
const args = parts.slice(1);
|
|
270127
270572
|
const autopilot = args.includes("--autopilot");
|
|
@@ -270131,7 +270576,7 @@ function HomeView({ onNavigate, onStartSession }) {
|
|
|
270131
270576
|
return;
|
|
270132
270577
|
}
|
|
270133
270578
|
await executeCommand(command);
|
|
270134
|
-
}, [resolveSkillContent, launchOperator, executeCommand]);
|
|
270579
|
+
}, [resolveSkillContent, launchOperator, executeCommand, pushHistory]);
|
|
270135
270580
|
const skillItems = skills.slice(0, 5).map((s) => ({
|
|
270136
270581
|
cmd: `/${slugify(s.name)}`,
|
|
270137
270582
|
desc: s.description || "skill"
|
|
@@ -270272,6 +270717,7 @@ function HomeView({ onNavigate, onStartSession }) {
|
|
|
270272
270717
|
autocompleteOptions,
|
|
270273
270718
|
enableCommands: true,
|
|
270274
270719
|
onCommandExecute: handleCommandExecute,
|
|
270720
|
+
commandHistory,
|
|
270275
270721
|
showPromptIndicator: true
|
|
270276
270722
|
}, undefined, false, undefined, this),
|
|
270277
270723
|
hintMessage && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
|
|
@@ -275044,7 +275490,6 @@ function KeybindingProvider({
|
|
|
275044
275490
|
deps
|
|
275045
275491
|
}) {
|
|
275046
275492
|
const { promptRef, refocusPrompt } = useFocus();
|
|
275047
|
-
const { isInputEmpty } = useInput();
|
|
275048
275493
|
const { setExternalDialogOpen } = useDialog();
|
|
275049
275494
|
const registry = createKeybindings({
|
|
275050
275495
|
...deps,
|
|
@@ -275060,7 +275505,9 @@ function KeybindingProvider({
|
|
|
275060
275505
|
if (binding.combo.toLowerCase().startsWith("shift") || binding.combo.toLowerCase() === "?") {
|
|
275061
275506
|
const textareaRef = promptRef.current?.getTextareaRef();
|
|
275062
275507
|
const isInputFocused = textareaRef && !textareaRef.isDestroyed && textareaRef.focused;
|
|
275063
|
-
|
|
275508
|
+
const actualValue = promptRef.current?.getValue() ?? "";
|
|
275509
|
+
const isPromptEmpty = actualValue.trim().length === 0;
|
|
275510
|
+
if (!isInputFocused || !isPromptEmpty) {
|
|
275064
275511
|
continue;
|
|
275065
275512
|
}
|
|
275066
275513
|
}
|
|
@@ -276620,7 +277067,11 @@ var TOOL_SUMMARY_MAP = {
|
|
|
276620
277067
|
return `${method} ${url2}`;
|
|
276621
277068
|
},
|
|
276622
277069
|
crawl: (args) => `crawl ${args.url || args.target || ""}`,
|
|
276623
|
-
execute_command: (args) =>
|
|
277070
|
+
execute_command: (args) => {
|
|
277071
|
+
const cmd = String(args.command || "").split(`
|
|
277072
|
+
`)[0];
|
|
277073
|
+
return cmd.length > 80 ? `$ ${cmd.slice(0, 80)}…` : `$ ${cmd}`;
|
|
277074
|
+
},
|
|
276624
277075
|
read_file: (args) => `read ${args.path || ""}`,
|
|
276625
277076
|
Read: (args) => `read ${args.path || args.file_path || ""}`,
|
|
276626
277077
|
write_file: (args) => `write ${args.path || ""}`,
|
|
@@ -276656,6 +277107,7 @@ var TOOL_SUMMARY_MAP = {
|
|
|
276656
277107
|
const targets = args.targets;
|
|
276657
277108
|
return `pentest swarm ×${targets?.length ?? "?"}`;
|
|
276658
277109
|
},
|
|
277110
|
+
delegate_to_auth_subagent: (args) => `auth ${args.target || ""} — ${args.reason || ""}`,
|
|
276659
277111
|
scratchpad: () => "note"
|
|
276660
277112
|
};
|
|
276661
277113
|
function getToolSummary(toolName, args) {
|
|
@@ -277367,7 +277819,8 @@ var TOOLS_WITH_LOG_WINDOW = new Set([
|
|
|
277367
277819
|
"execute_command",
|
|
277368
277820
|
"run_attack_surface",
|
|
277369
277821
|
"spawn_coding_agent",
|
|
277370
|
-
"spawn_pentest_swarm"
|
|
277822
|
+
"spawn_pentest_swarm",
|
|
277823
|
+
"delegate_to_auth_subagent"
|
|
277371
277824
|
]);
|
|
277372
277825
|
var ToolRenderer = import_react68.memo(function ToolRenderer2({
|
|
277373
277826
|
message,
|
|
@@ -277997,7 +278450,7 @@ function Pentest({ sessionId }) {
|
|
|
277997
278450
|
const gridAvailableWidth = showOrchestratorPanel ? Math.floor((termWidth - 4) / 2) - 2 : termWidth - ORCHESTRATOR_PANEL_WIDTH - GRID_OUTER_PADDING;
|
|
277998
278451
|
const gridColumns = Math.max(1, Math.floor((gridAvailableWidth + GRID_GAP) / (CARD_MIN_WIDTH + GRID_GAP)));
|
|
277999
278452
|
import_react75.useEffect(() => {
|
|
278000
|
-
async function
|
|
278453
|
+
async function load2() {
|
|
278001
278454
|
try {
|
|
278002
278455
|
const s2 = await sessions.get(sessionId);
|
|
278003
278456
|
if (!s2) {
|
|
@@ -278041,7 +278494,7 @@ function Pentest({ sessionId }) {
|
|
|
278041
278494
|
setPhase("error");
|
|
278042
278495
|
}
|
|
278043
278496
|
}
|
|
278044
|
-
|
|
278497
|
+
load2();
|
|
278045
278498
|
}, [sessionId]);
|
|
278046
278499
|
import_react75.useEffect(() => {
|
|
278047
278500
|
if (!session)
|
|
@@ -279640,7 +280093,8 @@ function NormalInputAreaInner({
|
|
|
279640
280093
|
enableAutocomplete = false,
|
|
279641
280094
|
autocompleteOptions = [],
|
|
279642
280095
|
enableCommands = false,
|
|
279643
|
-
onCommandExecute
|
|
280096
|
+
onCommandExecute,
|
|
280097
|
+
commandHistory = []
|
|
279644
280098
|
}) {
|
|
279645
280099
|
const { colors: colors2 } = useTheme();
|
|
279646
280100
|
const { inputValue, setInputValue } = useInput();
|
|
@@ -279698,7 +280152,8 @@ function NormalInputAreaInner({
|
|
|
279698
280152
|
enableAutocomplete,
|
|
279699
280153
|
autocompleteOptions,
|
|
279700
280154
|
enableCommands,
|
|
279701
|
-
onCommandExecute
|
|
280155
|
+
onCommandExecute,
|
|
280156
|
+
commandHistory
|
|
279702
280157
|
}, undefined, false, undefined, this)
|
|
279703
280158
|
]
|
|
279704
280159
|
}, undefined, true, undefined, this),
|
|
@@ -279784,6 +280239,7 @@ function InputArea(props) {
|
|
|
279784
280239
|
autocompleteOptions,
|
|
279785
280240
|
enableCommands,
|
|
279786
280241
|
onCommandExecute,
|
|
280242
|
+
commandHistory,
|
|
279787
280243
|
...normalProps
|
|
279788
280244
|
} = props;
|
|
279789
280245
|
if (pendingApproval) {
|
|
@@ -279806,6 +280262,7 @@ function InputArea(props) {
|
|
|
279806
280262
|
autocompleteOptions,
|
|
279807
280263
|
enableCommands,
|
|
279808
280264
|
onCommandExecute,
|
|
280265
|
+
commandHistory,
|
|
279809
280266
|
...normalProps
|
|
279810
280267
|
}, undefined, false, undefined, this)
|
|
279811
280268
|
}, undefined, false, undefined, this);
|
|
@@ -279991,6 +280448,10 @@ function OperatorDashboard({
|
|
|
279991
280448
|
const textRef = import_react80.useRef("");
|
|
279992
280449
|
const conversationRef = import_react80.useRef([]);
|
|
279993
280450
|
const [inputValue, setInputValue] = import_react80.useState("");
|
|
280451
|
+
const [commandHistory, setCommandHistory] = import_react80.useState(getEntries);
|
|
280452
|
+
import_react80.useEffect(() => {
|
|
280453
|
+
load().then(setCommandHistory);
|
|
280454
|
+
}, []);
|
|
279994
280455
|
const [operatorState, setOperatorState] = import_react80.useState(() => createInitialOperatorState("manual", true));
|
|
279995
280456
|
const approvalGateRef = import_react80.useRef(new ApprovalGate({ requireApproval: true }));
|
|
279996
280457
|
const [pendingApprovals, setPendingApprovals] = import_react80.useState([]);
|
|
@@ -280365,8 +280826,10 @@ function OperatorDashboard({
|
|
|
280365
280826
|
}
|
|
280366
280827
|
if (status === "running")
|
|
280367
280828
|
return;
|
|
280829
|
+
const trimmed = value.trim();
|
|
280830
|
+
push(trimmed).then(() => setCommandHistory([...getEntries()]));
|
|
280368
280831
|
setInputValue("");
|
|
280369
|
-
runAgent(
|
|
280832
|
+
runAgent(trimmed);
|
|
280370
280833
|
}, [status, runAgent]);
|
|
280371
280834
|
const initialMessageSentRef = import_react80.useRef(false);
|
|
280372
280835
|
const runAgentRef = import_react80.useRef(runAgent);
|
|
@@ -280686,7 +281149,8 @@ function OperatorDashboard({
|
|
|
280686
281149
|
enableAutocomplete: true,
|
|
280687
281150
|
autocompleteOptions,
|
|
280688
281151
|
enableCommands: true,
|
|
280689
|
-
onCommandExecute: handleCommandExecute
|
|
281152
|
+
onCommandExecute: handleCommandExecute,
|
|
281153
|
+
commandHistory
|
|
280690
281154
|
}, undefined, false, undefined, this)
|
|
280691
281155
|
]
|
|
280692
281156
|
}, undefined, true, undefined, this);
|