@pensar/apex 0.0.114-canary.445a6e7a → 0.0.114-canary.4ff24fd4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/build/agent-pcevnxnv.js +16 -0
  2. package/build/{agent-45w8zb5f.js → agent-rbr4abvd.js} +8 -8
  3. package/build/{auth-b5pzg62w.js → auth-qd1f6065.js} +4 -4
  4. package/build/{authentication-4072yy3c.js → authentication-yvnpc6cq.js} +7 -7
  5. package/build/blackboxAgent-0jtzy98g.js +17 -0
  6. package/build/{blackboxPentest-wzry7w8d.js → blackboxPentest-zk6zdgdy.js} +12 -12
  7. package/build/{cli-pvk8q5mg.js → cli-45ad5yvq.js} +34 -14
  8. package/build/{cli-ykp1xvx6.js → cli-5jmnx7vb.js} +1 -1
  9. package/build/{cli-gs19dhmn.js → cli-640ycgr7.js} +120 -12
  10. package/build/{cli-ewt4jma9.js → cli-6sjq0mpc.js} +16 -4
  11. package/build/{cli-6jcp4fkp.js → cli-9evmet94.js} +5 -13
  12. package/build/{cli-nvmyy13v.js → cli-c9hc1grf.js} +4 -2
  13. package/build/{cli-p6ww5g5c.js → cli-cmv5029e.js} +1 -1
  14. package/build/{cli-d5k4vq3e.js → cli-cphrdpc5.js} +1 -1
  15. package/build/{cli-k4vqtbac.js → cli-egaks5yw.js} +510 -312
  16. package/build/{cli-dnyffzes.js → cli-gwj3x308.js} +1 -1
  17. package/build/{cli-ampzrkgg.js → cli-hkm3ecrm.js} +48 -27
  18. package/build/cli-qfwvwkrm.js +7524 -0
  19. package/build/{cli-v8872wsv.js → cli-vmrd4d7b.js} +1 -1
  20. package/build/{cli-c3c6rmas.js → cli-wjszcaa8.js} +1 -1
  21. package/build/cli.js +66 -20
  22. package/build/{fixes-tvwqxq4r.js → fixes-7n4qa805.js} +4 -4
  23. package/build/{index-v56ms5zm.js → index-0szx19t1.js} +2 -2
  24. package/build/{index-qv3npmy8.js → index-cggwqpe3.js} +1892 -9145
  25. package/build/{index-5tzbmazn.js → index-fx39x0xr.js} +6 -6
  26. package/build/{issues-qw4z2fcz.js → issues-h001c9fy.js} +4 -4
  27. package/build/{logs-08dnqe9v.js → logs-8sfshm57.js} +4 -4
  28. package/build/pentest-mc2skj6r.js +25 -0
  29. package/build/{pentests-sm7ax5a1.js → pentests-ahnqxme7.js} +4 -4
  30. package/build/{projects-kcvphqqf.js → projects-e52czssm.js} +4 -4
  31. package/build/{targetedPentest-z1sg42yb.js → targetedPentest-58kg4t5q.js} +10 -10
  32. package/build/threatModel-1epmre4q.js +59 -0
  33. package/build/{uninstall-aj5jkd7y.js → uninstall-qd2wymhf.js} +1 -1
  34. package/package.json +1 -1
  35. package/build/agent-tb6k0spm.js +0 -16
  36. package/build/blackboxAgent-apycgjc5.js +0 -17
  37. package/build/pentest-f2d7d014.js +0 -25
@@ -0,0 +1,16 @@
1
+ import {
2
+ CodeAgent
3
+ } from "./cli-c9hc1grf.js";
4
+ import"./cli-egaks5yw.js";
5
+ import"./cli-9evmet94.js";
6
+ import"./cli-640ycgr7.js";
7
+ import"./cli-gwj3x308.js";
8
+ import"./cli-cphrdpc5.js";
9
+ import"./cli-cmv5029e.js";
10
+ import"./cli-vmrd4d7b.js";
11
+ import"./cli-5gh0m3xb.js";
12
+ import"./cli-7ckctq7a.js";
13
+ import"./cli-8rxa073f.js";
14
+ export {
15
+ CodeAgent
16
+ };
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  WhiteboxAttackSurfaceResultSchema
3
- } from "./cli-ykp1xvx6.js";
3
+ } from "./cli-5jmnx7vb.js";
4
4
  import {
5
5
  OffensiveSecurityAgent
6
- } from "./cli-k4vqtbac.js";
7
- import"./cli-6jcp4fkp.js";
6
+ } from "./cli-egaks5yw.js";
7
+ import"./cli-9evmet94.js";
8
8
  import {
9
9
  hasToolCall,
10
10
  tool
11
- } from "./cli-gs19dhmn.js";
12
- import"./cli-dnyffzes.js";
13
- import"./cli-d5k4vq3e.js";
14
- import"./cli-p6ww5g5c.js";
15
- import"./cli-v8872wsv.js";
11
+ } from "./cli-640ycgr7.js";
12
+ import"./cli-gwj3x308.js";
13
+ import"./cli-cphrdpc5.js";
14
+ import"./cli-cmv5029e.js";
15
+ import"./cli-vmrd4d7b.js";
16
16
  import"./cli-5gh0m3xb.js";
17
17
  import"./cli-7ckctq7a.js";
18
18
  import"./cli-8rxa073f.js";
@@ -8,14 +8,14 @@ import {
8
8
  pollWorkOSToken,
9
9
  selectWorkspace,
10
10
  startDeviceFlow
11
- } from "./cli-dnyffzes.js";
11
+ } from "./cli-gwj3x308.js";
12
12
  import {
13
13
  config,
14
14
  getPensarApiUrl,
15
15
  getPensarConsoleUrl
16
- } from "./cli-d5k4vq3e.js";
17
- import"./cli-p6ww5g5c.js";
18
- import"./cli-v8872wsv.js";
16
+ } from "./cli-cphrdpc5.js";
17
+ import"./cli-cmv5029e.js";
18
+ import"./cli-vmrd4d7b.js";
19
19
  import {
20
20
  __require
21
21
  } from "./cli-8rxa073f.js";
@@ -3,15 +3,15 @@ import {
3
3
  } from "./cli-6gtnyaqf.js";
4
4
  import {
5
5
  OffensiveSecurityAgent
6
- } from "./cli-k4vqtbac.js";
7
- import"./cli-6jcp4fkp.js";
6
+ } from "./cli-egaks5yw.js";
7
+ import"./cli-9evmet94.js";
8
8
  import {
9
9
  hasToolCall
10
- } from "./cli-gs19dhmn.js";
11
- import"./cli-dnyffzes.js";
12
- import"./cli-d5k4vq3e.js";
13
- import"./cli-p6ww5g5c.js";
14
- import"./cli-v8872wsv.js";
10
+ } from "./cli-640ycgr7.js";
11
+ import"./cli-gwj3x308.js";
12
+ import"./cli-cphrdpc5.js";
13
+ import"./cli-cmv5029e.js";
14
+ import"./cli-vmrd4d7b.js";
15
15
  import"./cli-5gh0m3xb.js";
16
16
  import"./cli-7ckctq7a.js";
17
17
  import"./cli-8rxa073f.js";
@@ -0,0 +1,17 @@
1
+ import {
2
+ BlackboxAttackSurfaceAgent
3
+ } from "./cli-6sjq0mpc.js";
4
+ import"./cli-6gtnyaqf.js";
5
+ import"./cli-egaks5yw.js";
6
+ import"./cli-9evmet94.js";
7
+ import"./cli-640ycgr7.js";
8
+ import"./cli-gwj3x308.js";
9
+ import"./cli-cphrdpc5.js";
10
+ import"./cli-cmv5029e.js";
11
+ import"./cli-vmrd4d7b.js";
12
+ import"./cli-5gh0m3xb.js";
13
+ import"./cli-7ckctq7a.js";
14
+ import"./cli-8rxa073f.js";
15
+ export {
16
+ BlackboxAttackSurfaceAgent
17
+ };
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  runPentestWorkflow
3
- } from "./cli-pvk8q5mg.js";
4
- import"./cli-ampzrkgg.js";
5
- import"./cli-nvmyy13v.js";
6
- import"./cli-ykp1xvx6.js";
7
- import"./cli-ewt4jma9.js";
3
+ } from "./cli-45ad5yvq.js";
4
+ import"./cli-hkm3ecrm.js";
5
+ import"./cli-c9hc1grf.js";
6
+ import"./cli-5jmnx7vb.js";
7
+ import"./cli-6sjq0mpc.js";
8
8
  import"./cli-6gtnyaqf.js";
9
- import"./cli-k4vqtbac.js";
10
- import"./cli-6jcp4fkp.js";
11
- import"./cli-gs19dhmn.js";
12
- import"./cli-dnyffzes.js";
13
- import"./cli-d5k4vq3e.js";
14
- import"./cli-p6ww5g5c.js";
15
- import"./cli-v8872wsv.js";
9
+ import"./cli-egaks5yw.js";
10
+ import"./cli-9evmet94.js";
11
+ import"./cli-640ycgr7.js";
12
+ import"./cli-gwj3x308.js";
13
+ import"./cli-cphrdpc5.js";
14
+ import"./cli-cmv5029e.js";
15
+ import"./cli-vmrd4d7b.js";
16
16
  import"./cli-5gh0m3xb.js";
17
17
  import"./cli-7ckctq7a.js";
18
18
  import"./cli-8rxa073f.js";
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  TargetedPentestAgent
3
- } from "./cli-ampzrkgg.js";
3
+ } from "./cli-hkm3ecrm.js";
4
4
  import {
5
5
  CodeAgent
6
- } from "./cli-nvmyy13v.js";
6
+ } from "./cli-c9hc1grf.js";
7
7
  import {
8
8
  EndpointSchema
9
- } from "./cli-ykp1xvx6.js";
9
+ } from "./cli-5jmnx7vb.js";
10
10
  import {
11
11
  BlackboxAttackSurfaceAgent
12
- } from "./cli-ewt4jma9.js";
12
+ } from "./cli-6sjq0mpc.js";
13
13
  import {
14
14
  CweEntrySchema,
15
15
  FindingsRegistry
16
- } from "./cli-k4vqtbac.js";
16
+ } from "./cli-egaks5yw.js";
17
17
  import {
18
18
  exports_external,
19
19
  init_zod
20
- } from "./cli-gs19dhmn.js";
20
+ } from "./cli-640ycgr7.js";
21
21
 
22
22
  // src/core/workflows/pentest.ts
23
23
  import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
@@ -922,7 +922,8 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
922
922
  abortSignal,
923
923
  callbacks,
924
924
  attackSurfaceRegistry,
925
- onStepFinish
925
+ onStepFinish,
926
+ onCacheMetrics
926
927
  } = input;
927
928
  const appsAgent = new CodeAgent({
928
929
  codebasePath,
@@ -935,6 +936,7 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
935
936
  attackSurfaceRegistry,
936
937
  callbacks,
937
938
  onStepFinish: (event) => onStepFinish?.(event),
939
+ onCacheMetrics,
938
940
  responseSchema: AppsDiscoveryResultSchema
939
941
  });
940
942
  const appsResult = await appsAgent.consume({
@@ -995,6 +997,7 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
995
997
  attackSurfaceRegistry,
996
998
  callbacks,
997
999
  onStepFinish: (event) => onStepFinish?.(event),
1000
+ onCacheMetrics,
998
1001
  responseSchema: DiscoverySummarySchema
999
1002
  });
1000
1003
  try {
@@ -1415,15 +1418,28 @@ async function runPentestSwarm(input) {
1415
1418
  return results;
1416
1419
  }
1417
1420
  async function runPentestWorkflow(input) {
1418
- const { target, cwd, model, session, authConfig, abortSignal, callbacks } = input;
1421
+ const {
1422
+ target,
1423
+ cwd,
1424
+ model,
1425
+ session,
1426
+ authConfig,
1427
+ abortSignal,
1428
+ callbacks,
1429
+ onStepFinish,
1430
+ onCacheMetrics
1431
+ } = input;
1419
1432
  const startedAt = Date.now();
1420
1433
  const tokenUsageTotals = {
1421
1434
  inputTokens: 0,
1422
1435
  outputTokens: 0,
1423
1436
  totalTokens: 0
1424
1437
  };
1425
- const onStepFinish = (event) => {
1438
+ const wrappedOnStepFinish = (event) => {
1426
1439
  addUsageTotals(tokenUsageTotals, event.usage);
1440
+ if (onStepFinish) {
1441
+ onStepFinish(event);
1442
+ }
1427
1443
  };
1428
1444
  try {
1429
1445
  const mode = cwd ? "whitebox" : "blackbox";
@@ -1443,7 +1459,8 @@ async function runPentestWorkflow(input) {
1443
1459
  authConfig,
1444
1460
  abortSignal,
1445
1461
  callbacks,
1446
- onStepFinish
1462
+ onStepFinish: wrappedOnStepFinish,
1463
+ onCacheMetrics
1447
1464
  });
1448
1465
  } else {
1449
1466
  swarmTargets = await runBlackboxPhase({
@@ -1453,7 +1470,8 @@ async function runPentestWorkflow(input) {
1453
1470
  authConfig,
1454
1471
  abortSignal,
1455
1472
  callbacks,
1456
- onStepFinish
1473
+ onStepFinish: wrappedOnStepFinish,
1474
+ onCacheMetrics
1457
1475
  });
1458
1476
  }
1459
1477
  if (abortSignal?.aborted) {
@@ -1493,7 +1511,7 @@ async function runPentestWorkflow(input) {
1493
1511
  findingsRegistry,
1494
1512
  subagentCallbacks: callbacks?.subagentCallbacks,
1495
1513
  onError: (e) => callbacks?.onError?.(e),
1496
- onStepFinish
1514
+ onStepFinish: wrappedOnStepFinish
1497
1515
  });
1498
1516
  }
1499
1517
  if (abortSignal?.aborted) {
@@ -1533,7 +1551,8 @@ async function runWhiteboxPhase(opts) {
1533
1551
  authConfig: opts.authConfig,
1534
1552
  abortSignal: opts.abortSignal,
1535
1553
  callbacks: opts.callbacks,
1536
- onStepFinish: opts.onStepFinish
1554
+ onStepFinish: opts.onStepFinish,
1555
+ onCacheMetrics: opts.onCacheMetrics
1537
1556
  };
1538
1557
  const result = await runWhiteboxAttackSurfaceWorkflow(workflowInput);
1539
1558
  return result.apps.flatMap((app) => [...app.pages, ...app.apiEndpoints].map((ep) => ({
@@ -1555,7 +1574,8 @@ async function runBlackboxPhase(opts) {
1555
1574
  lastMessages = e.response.messages;
1556
1575
  }
1557
1576
  opts.onStepFinish?.(e);
1558
- }
1577
+ },
1578
+ onCacheMetrics: opts.onCacheMetrics
1559
1579
  };
1560
1580
  const agent = new BlackboxAttackSurfaceAgent(agentInput);
1561
1581
  try {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  exports_external,
3
3
  init_zod
4
- } from "./cli-gs19dhmn.js";
4
+ } from "./cli-640ycgr7.js";
5
5
 
6
6
  // src/core/agents/specialized/whiteboxAttackSurface/types.ts
7
7
  init_zod();
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  signGatewayRequest
3
- } from "./cli-dnyffzes.js";
3
+ } from "./cli-gwj3x308.js";
4
4
  import {
5
5
  config,
6
6
  ensureValidToken,
7
7
  getPensarGatewayUrl
8
- } from "./cli-d5k4vq3e.js";
8
+ } from "./cli-cphrdpc5.js";
9
9
  import {
10
10
  getModelInfo
11
11
  } from "./cli-5gh0m3xb.js";
@@ -55857,22 +55857,39 @@ function getDefaultMaxOutputTokens(modelId) {
55857
55857
  }
55858
55858
  return 4096;
55859
55859
  }
55860
+ var EPHEMERAL_CACHE_CONTROL = { type: "ephemeral" };
55861
+ function hasCacheControl(part) {
55862
+ const opts = part.providerOptions;
55863
+ return !!opts?.anthropic?.cacheControl;
55864
+ }
55860
55865
  function convertToAnthropicFormat(modelId, options) {
55861
55866
  const messages = [];
55862
55867
  let systemPrompt;
55868
+ let systemHasCacheControl = false;
55863
55869
  if (options.prompt) {
55864
55870
  for (const part of options.prompt) {
55865
55871
  if (part.role === "system") {
55866
55872
  systemPrompt = part.content;
55873
+ systemHasCacheControl = hasCacheControl(part);
55867
55874
  } else if (part.role === "user") {
55868
- const content = part.content.map((c) => {
55875
+ const partHasCache = hasCacheControl(part);
55876
+ const text2 = part.content.map((c) => {
55869
55877
  if (c.type === "text")
55870
55878
  return c.text;
55871
55879
  if (c.type === "file")
55872
55880
  return "[file]";
55873
55881
  return "";
55874
55882
  }).join("");
55875
- messages.push({ role: "user", content });
55883
+ if (partHasCache) {
55884
+ messages.push({
55885
+ role: "user",
55886
+ content: [
55887
+ { type: "text", text: text2, cache_control: EPHEMERAL_CACHE_CONTROL }
55888
+ ]
55889
+ });
55890
+ } else {
55891
+ messages.push({ role: "user", content: text2 });
55892
+ }
55876
55893
  } else if (part.role === "assistant") {
55877
55894
  const assistantContent = part.content;
55878
55895
  const hasToolCalls = assistantContent.some((c) => c.type === "tool-call");
@@ -55933,7 +55950,13 @@ You MUST respond with ONLY valid JSON (no markdown, no explanation, no code fenc
55933
55950
  max_tokens: options.maxOutputTokens ?? getDefaultMaxOutputTokens(modelId)
55934
55951
  };
55935
55952
  if (systemPrompt) {
55936
- body.system = systemPrompt;
55953
+ body.system = systemHasCacheControl ? [
55954
+ {
55955
+ type: "text",
55956
+ text: systemPrompt,
55957
+ cache_control: EPHEMERAL_CACHE_CONTROL
55958
+ }
55959
+ ] : systemPrompt;
55937
55960
  }
55938
55961
  if (options.temperature != null) {
55939
55962
  body.temperature = options.temperature;
@@ -56207,6 +56230,8 @@ function createPensarModel(bedrockModelId, config3) {
56207
56230
  async start(controller) {
56208
56231
  let inputTokens = 0;
56209
56232
  let outputTokens = 0;
56233
+ let cacheReadTokens = 0;
56234
+ let cacheCreationTokens = 0;
56210
56235
  let finishReasonUnified = "other";
56211
56236
  let finishReasonRaw;
56212
56237
  let startEmitted = false;
@@ -56263,6 +56288,12 @@ function createPensarModel(bedrockModelId, config3) {
56263
56288
  if (usage?.input_tokens) {
56264
56289
  inputTokens = usage.input_tokens;
56265
56290
  }
56291
+ if (usage?.cache_read_input_tokens) {
56292
+ cacheReadTokens = usage.cache_read_input_tokens;
56293
+ }
56294
+ if (usage?.cache_creation_input_tokens) {
56295
+ cacheCreationTokens = usage.cache_creation_input_tokens;
56296
+ }
56266
56297
  break;
56267
56298
  }
56268
56299
  case "content_block_start": {
@@ -56350,7 +56381,7 @@ function createPensarModel(bedrockModelId, config3) {
56350
56381
  }
56351
56382
  }
56352
56383
  }
56353
- logInfo(` stream complete: ${finishReasonUnified}, ${inputTokens}in/${outputTokens}out (${Date.now() - startTime}ms)`);
56384
+ logInfo(` stream complete: ${finishReasonUnified}, ${inputTokens}in/${outputTokens}out, cacheRead=${cacheReadTokens}, cacheWrite=${cacheCreationTokens} (${Date.now() - startTime}ms)`);
56354
56385
  controller.enqueue({
56355
56386
  type: "finish",
56356
56387
  finishReason: {
@@ -56361,8 +56392,8 @@ function createPensarModel(bedrockModelId, config3) {
56361
56392
  inputTokens: {
56362
56393
  total: inputTokens,
56363
56394
  noCache: undefined,
56364
- cacheRead: undefined,
56365
- cacheWrite: undefined
56395
+ cacheRead: cacheReadTokens || undefined,
56396
+ cacheWrite: cacheCreationTokens || undefined
56366
56397
  },
56367
56398
  outputTokens: {
56368
56399
  total: outputTokens,
@@ -56402,6 +56433,37 @@ function mapStopReason(reason) {
56402
56433
  }
56403
56434
  }
56404
56435
 
56436
+ // src/core/ai/caching.ts
56437
+ var ANTHROPIC_CACHE_CONTROL = {
56438
+ anthropic: { cacheControl: { type: "ephemeral" } }
56439
+ };
56440
+ function withCachedSystemPrompt(system, messages) {
56441
+ return [
56442
+ {
56443
+ role: "system",
56444
+ content: system,
56445
+ providerOptions: ANTHROPIC_CACHE_CONTROL
56446
+ },
56447
+ ...messages
56448
+ ];
56449
+ }
56450
+ function withCachedLastMessage(messages) {
56451
+ if (messages.length === 0)
56452
+ return messages;
56453
+ return messages.map((msg, i) => {
56454
+ if (i === messages.length - 1) {
56455
+ return {
56456
+ ...msg,
56457
+ providerOptions: {
56458
+ ...msg.providerOptions,
56459
+ ...ANTHROPIC_CACHE_CONTROL
56460
+ }
56461
+ };
56462
+ }
56463
+ return msg;
56464
+ });
56465
+ }
56466
+
56405
56467
  // src/core/ai/ai.ts
56406
56468
  var _usageCallback = null;
56407
56469
  function checkIfRateLimitError(error40) {
@@ -56494,7 +56556,8 @@ function streamResponse(opts) {
56494
56556
  activeTools,
56495
56557
  silent,
56496
56558
  authConfig,
56497
- onFinish
56559
+ onFinish,
56560
+ onCacheMetrics
56498
56561
  } = opts;
56499
56562
  const onStepFinish = async (step) => {
56500
56563
  await userOnStepFinish?.(step);
@@ -56507,20 +56570,61 @@ function streamResponse(opts) {
56507
56570
  };
56508
56571
  const messagesContainer = { current: messages || [] };
56509
56572
  const providerModel = getProviderModel(model, authConfig);
56573
+ const useAnthropicCaching = isAnthropicProvider(model);
56574
+ let effectiveSystem = system;
56575
+ let effectiveMessages = messages;
56576
+ if (useAnthropicCaching && system) {
56577
+ const baseMessages = messages ?? [
56578
+ { role: "user", content: prompt }
56579
+ ];
56580
+ effectiveMessages = withCachedSystemPrompt(system, baseMessages);
56581
+ effectiveSystem = undefined;
56582
+ }
56583
+ let rateLimitRetryCount = 0;
56510
56584
  try {
56511
56585
  const response = streamText({
56512
56586
  model: providerModel,
56513
- system,
56514
- ...messages ? { messages } : { prompt },
56587
+ system: effectiveSystem,
56588
+ ...effectiveMessages ? { messages: effectiveMessages } : { prompt },
56515
56589
  stopWhen,
56516
56590
  toolChoice,
56517
56591
  tools,
56518
56592
  maxRetries: 3,
56519
56593
  prepareStep: (opts2) => {
56520
56594
  messagesContainer.current = opts2.messages;
56595
+ if (useAnthropicCaching) {
56596
+ return { messages: withCachedLastMessage(opts2.messages) };
56597
+ }
56521
56598
  return;
56522
56599
  },
56523
- onStepFinish,
56600
+ onError: async ({ error: error40 }) => {
56601
+ const errorMessage = error40 instanceof Error ? error40.message : String(error40);
56602
+ if (errorMessage.toLowerCase().includes("too many tokens") || errorMessage.toLowerCase().includes("overloaded")) {
56603
+ rateLimitRetryCount++;
56604
+ await new Promise((resolve3) => setTimeout(resolve3, 1000 * rateLimitRetryCount));
56605
+ if (rateLimitRetryCount < 20) {
56606
+ return;
56607
+ }
56608
+ }
56609
+ throw error40;
56610
+ },
56611
+ onStepFinish: onCacheMetrics ? (stepResult) => {
56612
+ const meta = stepResult.providerMetadata?.anthropic;
56613
+ let cacheRead = meta?.cacheReadInputTokens ?? 0;
56614
+ let cacheCreation = meta?.cacheCreationInputTokens ?? 0;
56615
+ if (cacheRead === 0 && cacheCreation === 0) {
56616
+ const usage = stepResult.usage;
56617
+ cacheRead = usage?.inputTokens?.cacheRead ?? 0;
56618
+ cacheCreation = usage?.inputTokens?.cacheWrite ?? 0;
56619
+ }
56620
+ if (cacheRead > 0 || cacheCreation > 0) {
56621
+ onCacheMetrics({
56622
+ cacheReadInputTokens: cacheRead,
56623
+ cacheCreationInputTokens: cacheCreation
56624
+ });
56625
+ }
56626
+ onStepFinish?.(stepResult);
56627
+ } : onStepFinish,
56524
56628
  abortSignal,
56525
56629
  activeTools,
56526
56630
  experimental_repairToolCall: async ({
@@ -56682,6 +56786,10 @@ class ContextLengthError extends Error {
56682
56786
  }
56683
56787
 
56684
56788
  // src/core/ai/utils.ts
56789
+ function isAnthropicProvider(model) {
56790
+ const { provider } = getModelInfo(model);
56791
+ return provider === "anthropic" || provider === "bedrock" || provider === "pensar";
56792
+ }
56685
56793
  function buildAuthConfig(cfg) {
56686
56794
  return {
56687
56795
  anthropicAPIKey: cfg.anthropicAPIKey ?? undefined,
@@ -3,15 +3,15 @@ import {
3
3
  } from "./cli-6gtnyaqf.js";
4
4
  import {
5
5
  OffensiveSecurityAgent
6
- } from "./cli-k4vqtbac.js";
6
+ } from "./cli-egaks5yw.js";
7
7
  import {
8
8
  hasToolCall,
9
9
  stepCountIs
10
- } from "./cli-gs19dhmn.js";
10
+ } from "./cli-640ycgr7.js";
11
11
 
12
12
  // src/core/agents/specialized/attackSurface/blackboxAgent.ts
13
13
  import { join } from "path";
14
- import { existsSync } from "fs";
14
+ import { existsSync, mkdirSync, writeFileSync } from "fs";
15
15
 
16
16
  // src/core/agents/specialized/attackSurface/prompts.ts
17
17
  var SYSTEM = `You are an autonomous attack surface analysis agent. Your mission is to comprehensively map the attack surface of a target and produce a structured report of all discovered assets and pentest objectives.
@@ -393,12 +393,17 @@ class BlackboxAttackSurfaceAgent extends OffensiveSecurityAgent {
393
393
  session,
394
394
  authConfig,
395
395
  onStepFinish,
396
+ onCacheMetrics,
396
397
  abortSignal,
397
398
  attackSurfaceRegistry
398
399
  } = opts;
399
400
  const target = opts.target ?? opts.cwd;
400
401
  const resultsPath = join(session.rootPath, "attack-surface-results.json");
401
402
  const assetsPath = join(session.rootPath, "assets");
403
+ const subagentFolder = join(session.rootPath, "subagents", "attack-surface-agent");
404
+ if (!existsSync(subagentFolder)) {
405
+ mkdirSync(subagentFolder, { recursive: true });
406
+ }
402
407
  super({
403
408
  system: detectOSAndEnhancePrompt(SYSTEM),
404
409
  prompt: buildPrompt(target, session),
@@ -406,7 +411,14 @@ class BlackboxAttackSurfaceAgent extends OffensiveSecurityAgent {
406
411
  session,
407
412
  target,
408
413
  authConfig,
409
- onStepFinish,
414
+ onStepFinish: (e) => {
415
+ onStepFinish?.(e);
416
+ const messages = e.response.messages;
417
+ if (messages !== undefined) {
418
+ writeFileSync(join(subagentFolder, "attack-surface-agent.log"), JSON.stringify(messages, null, 2));
419
+ }
420
+ },
421
+ onCacheMetrics,
410
422
  abortSignal,
411
423
  attackSurfaceRegistry,
412
424
  messages: opts.messages,
@@ -3,7 +3,7 @@ import {
3
3
  generateObjectResponse,
4
4
  init_zod,
5
5
  zod_default
6
- } from "./cli-gs19dhmn.js";
6
+ } from "./cli-640ycgr7.js";
7
7
  import {
8
8
  __callDispose,
9
9
  __esm,
@@ -168,14 +168,6 @@ var init_toolset = __esm(() => {
168
168
  category: "exploitation",
169
169
  defaultEnabled: true
170
170
  },
171
- {
172
- id: "create_poc",
173
- name: "Create POC",
174
- description: "Build & run exploits",
175
- detail: "Create and execute proof-of-concept scripts in Bash, Python, or JavaScript. Automatically validates exploitation success and captures evidence.",
176
- category: "exploitation",
177
- defaultEnabled: true
178
- },
179
171
  {
180
172
  id: "browser_navigate",
181
173
  name: "Browser Navigate",
@@ -225,8 +217,8 @@ var init_toolset = __esm(() => {
225
217
  defaultEnabled: true
226
218
  },
227
219
  {
228
- id: "document_finding",
229
- name: "Document Finding",
220
+ id: "document_vulnerability",
221
+ name: "Document Vulnerability",
230
222
  description: "Record vuln finding",
231
223
  detail: "Document a confirmed vulnerability with title, description, severity, POC path, and evidence. Calculates CVSS score automatically.",
232
224
  category: "reporting",
@@ -391,9 +383,9 @@ var init_toolset = __esm(() => {
391
383
  "browser_navigate",
392
384
  "browser_screenshot",
393
385
  "browser_console",
394
- "document_finding",
395
386
  "generate_report",
396
387
  "record_test_result",
388
+ "document_vulnerability",
397
389
  "update_attack_surface",
398
390
  "update_endpoint_status",
399
391
  "scratchpad",
@@ -411,7 +403,7 @@ var init_toolset = __esm(() => {
411
403
  "http_request",
412
404
  "execute_command",
413
405
  "scratchpad",
414
- "document_finding"
406
+ "document_vulnerability"
415
407
  ]
416
408
  }
417
409
  ];
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  OffensiveSecurityAgent
3
- } from "./cli-k4vqtbac.js";
3
+ } from "./cli-egaks5yw.js";
4
4
  import {
5
5
  stepCountIs
6
- } from "./cli-gs19dhmn.js";
6
+ } from "./cli-640ycgr7.js";
7
7
 
8
8
  // src/core/agents/specialized/codeAgent/prompts.ts
9
9
  var CODE_AGENT_SYSTEM_PROMPT = `You are an expert coding agent with direct filesystem access. You will be given a specific objective — focus exclusively on completing it.
@@ -54,6 +54,7 @@ class CodeAgent extends OffensiveSecurityAgent {
54
54
  session,
55
55
  authConfig,
56
56
  onStepFinish,
57
+ onCacheMetrics,
57
58
  abortSignal,
58
59
  callbacks,
59
60
  stopWhen,
@@ -80,6 +81,7 @@ class CodeAgent extends OffensiveSecurityAgent {
80
81
  session,
81
82
  authConfig,
82
83
  onStepFinish,
84
+ onCacheMetrics,
83
85
  abortSignal,
84
86
  attackSurfaceRegistry,
85
87
  callbacks,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getCurrentVersion
3
- } from "./cli-v8872wsv.js";
3
+ } from "./cli-vmrd4d7b.js";
4
4
 
5
5
  // src/core/config/config.ts
6
6
  import os from "os";
@@ -2,7 +2,7 @@ import {
2
2
  get,
3
3
  init,
4
4
  update
5
- } from "./cli-p6ww5g5c.js";
5
+ } from "./cli-cmv5029e.js";
6
6
 
7
7
  // src/core/api/constants.ts
8
8
  var PENSAR_API_BASE_URL = "https://api.pensar.dev";