@pensar/apex 2.6.1 → 2.7.0-canary.21cb83dc

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 (226) hide show
  1. package/build/{agent-yby11zaq.js → agent-68t2wzmc.js} +6 -6
  2. package/build/agent-jhekpern.js +13 -0
  3. package/build/{agent-ayreaj6z.js → agent-qvreg8a4.js} +5 -5
  4. package/build/{agent-runs-g37vkrjr.js → agent-runs-30dvbvmm.js} +18 -18
  5. package/build/agent-vybw255f.js +13 -0
  6. package/build/{apps-xn6km9yn.js → apps-na0y0992.js} +13 -13
  7. package/build/{auth-d105wc64.js → auth-dz2c5thx.js} +13 -13
  8. package/build/{blackboxAgent-s56sgx9b.js → blackboxAgent-2mwvaajb.js} +6 -6
  9. package/build/{blackboxPentest-ps78v3w7.js → blackboxPentest-s2mfze9p.js} +17 -12
  10. package/build/{cli-kb21qhvm.js → cli-1pmfnz1a.js} +4 -3
  11. package/build/{cli-ae8jqxqr.js → cli-563yntrb.js} +2 -2
  12. package/build/{cli-7eea4e2y.js → cli-5ab346kd.js} +6 -6
  13. package/build/{cli-1ve18npr.js → cli-72y76bpg.js} +3 -2
  14. package/build/{cli-fy6vh2a7.js → cli-98wmmphf.js} +1 -1
  15. package/build/{cli-c05y640n.js → cli-9jscnhtg.js} +1 -1
  16. package/build/{cli-3sp6nd8d.js → cli-9kk9tm58.js} +2 -2
  17. package/build/{cli-d37a42dc.js → cli-9pz9wjt2.js} +101 -18
  18. package/build/{cli-dpsw2fe6.js → cli-a6x4jm5a.js} +476 -193
  19. package/build/{cli-az3xq70v.js → cli-cfrdr25z.js} +1 -1
  20. package/build/{cli-ngq9dr8n.js → cli-fdrrbb9p.js} +3 -3
  21. package/build/{cli-k2nwxta0.js → cli-t09zj814.js} +2 -2
  22. package/build/{cli-qgz1q9g5.js → cli-t4q4t4dx.js} +223 -76
  23. package/build/{cli-xtc2t6me.js → cli-vdd1s3x9.js} +103 -39
  24. package/build/{cli-gx71jcke.js → cli-vn4cwac3.js} +1 -1
  25. package/build/{cli-65g6rcat.js → cli-w9nw2a4z.js} +1 -1
  26. package/build/{cli-n2en7j5b.js → cli-z7ysyrr4.js} +1 -1
  27. package/build/{cli-709rvekb.js → cli-zbbtr4sb.js} +4 -2
  28. package/build/cli.js +70 -40
  29. package/build/{config-zpqkd5cz.js → config-nkzm9arw.js} +1 -1
  30. package/build/{fastStrike-mcjdvwez.js → fastStrike-16jw1s61.js} +67 -15
  31. package/build/{fixes-kytx5dmj.js → fixes-6wxk22v5.js} +13 -13
  32. package/build/{index-4vqdgb42.js → index-36p56pcf.js} +1473 -1217
  33. package/build/{index-je6hcsqr.js → index-6nejymsc.js} +1 -1
  34. package/build/{index-fv64eb32.js → index-asm4y7e4.js} +2 -2
  35. package/build/{index-n65z6v7b.js → index-bfmn52za.js} +6 -6
  36. package/build/{index-qv4cc65p.js → index-bt4r13q7.js} +13 -13
  37. package/build/{index-dr3tg1w3.js → index-gfq1rp1q.js} +1 -1
  38. package/build/{index-wqetp6gq.js → index-j9pxgrzd.js} +12 -7
  39. package/build/{index-r9yjkfrv.js → index-n9kapn1x.js} +4 -4
  40. package/build/{index-ns4m4s01.js → index-tr6evhyg.js} +4 -4
  41. package/build/{issues-eb3q9d3a.js → issues-7rmf4ker.js} +13 -13
  42. package/build/{knowledge-fqsvtx0f.js → knowledge-s2sxh8nb.js} +13 -13
  43. package/build/lib/{chunk-1azdancq.js → chunk-0dnx79b1.js} +1 -1
  44. package/build/lib/{chunk-4hwzqthr.js → chunk-161ak2am.js} +3 -2
  45. package/build/lib/{chunk-z137x08b.js → chunk-1rqbhx4b.js} +7 -5
  46. package/build/lib/{chunk-1yct6cra.js → chunk-3hjvdf67.js} +1 -1
  47. package/build/lib/{chunk-r2dkp4tb.js → chunk-5j8pp0xf.js} +1 -1
  48. package/build/lib/{chunk-3c00n0cy.js → chunk-77se1d35.js} +8 -3
  49. package/build/lib/{chunk-yrnrbjes.js → chunk-7tft4b8b.js} +4 -2
  50. package/build/lib/{chunk-w66ce82a.js → chunk-8njjwwcw.js} +4 -2
  51. package/build/lib/{chunk-v3dk9j7k.js → chunk-aq9eyxas.js} +80 -21
  52. package/build/lib/{chunk-9tt2021m.js → chunk-d05cvnv8.js} +9 -9
  53. package/build/lib/{chunk-e8yy2k73.js → chunk-f3sq4896.js} +28 -2
  54. package/build/lib/{chunk-1fy8azee.js → chunk-fasqtjq1.js} +1 -1
  55. package/build/lib/{chunk-1jvwqnem.js → chunk-gm3b9j4y.js} +104 -40
  56. package/build/lib/{chunk-r4j8ybn9.js → chunk-hys7nemr.js} +87 -36
  57. package/build/lib/{chunk-7pwa92rn.js → chunk-j9668h16.js} +1 -1
  58. package/build/lib/{chunk-ba41jh41.js → chunk-kcw4cpr3.js} +418 -133
  59. package/build/lib/{chunk-z96pbjhd.js → chunk-m4swxy5r.js} +13 -6
  60. package/build/lib/{chunk-xhdpgpkm.js → chunk-mbsde9d0.js} +2 -2
  61. package/build/lib/{chunk-9yksqgzr.js → chunk-mpvjfvz0.js} +20 -13
  62. package/build/lib/{chunk-2qsq76xq.js → chunk-qkz5sm0d.js} +128 -34
  63. package/build/lib/{chunk-nhfax4gb.js → chunk-rfyjqybp.js} +1 -1
  64. package/build/lib/{chunk-mg03jdmt.js → chunk-vsnwzne5.js} +1 -1
  65. package/build/lib/{chunk-acgbyf5h.js → chunk-ydxhkgjw.js} +3 -2
  66. package/build/lib/{chunk-bb0ekhkw.js → chunk-z8kej0sp.js} +69 -18
  67. package/build/lib/core/agents/agentRuntime.d.ts +2 -1
  68. package/build/lib/core/agents/defineAgent.d.ts +3 -2
  69. package/build/lib/core/agents/offSecAgent/index.d.ts +3 -1
  70. package/build/lib/core/agents/offSecAgent/index.js +10 -8
  71. package/build/lib/core/agents/offSecAgent/prompt.d.ts +3 -1
  72. package/build/lib/core/agents/offSecAgent/subagentSpawner.d.ts +2 -1
  73. package/build/lib/core/agents/offSecAgent/subagentSpawner.js +5 -5
  74. package/build/lib/core/agents/offSecAgent/tools/index.js +4 -4
  75. package/build/lib/core/agents/offSecAgent/tools/listMemories.d.ts +11 -1
  76. package/build/lib/core/agents/offSecAgent/tools/reportError.d.ts +2 -1
  77. package/build/lib/core/agents/offSecAgent/tools/runPentestWorkflow.d.ts +20 -1
  78. package/build/lib/core/agents/offSecAgent/tools/spawnPentestAgent.d.ts +4 -7
  79. package/build/lib/core/agents/offSecAgent/tools/spawnPentestSwarm.d.ts +7 -1
  80. package/build/lib/core/agents/offSecAgent/tools/types.d.ts +2 -1
  81. package/build/lib/core/agents/offSecAgent/types.d.ts +7 -1
  82. package/build/lib/core/agents/specialized/attackSurface/blackboxAgent.js +9 -9
  83. package/build/lib/core/agents/specialized/attackSurface/schemas.js +9 -9
  84. package/build/lib/core/agents/specialized/authenticationAgent/index.js +10 -10
  85. package/build/lib/core/agents/specialized/codeAgent/agent.js +9 -9
  86. package/build/lib/core/agents/specialized/codeAgent/prompts.d.ts +1 -0
  87. package/build/lib/core/agents/specialized/findingJudge/agent.js +8 -8
  88. package/build/lib/core/agents/specialized/findingJudge/index.js +3 -3
  89. package/build/lib/core/agents/specialized/patching/index.js +10 -10
  90. package/build/lib/core/agents/specialized/pentest/agent.d.ts +18 -4
  91. package/build/lib/core/agents/specialized/pentest/agent.js +11 -9
  92. package/build/lib/core/agents/specialized/whiteboxAttackSurface/index.js +9 -9
  93. package/build/lib/core/ai/ai.d.ts +23 -6
  94. package/build/lib/core/ai/ai.js +2 -2
  95. package/build/lib/core/ai/index.js +2 -2
  96. package/build/lib/core/ai/models/claude-capabilities.d.ts +3 -2
  97. package/build/lib/core/ai/models/concentrate.d.ts +1 -0
  98. package/build/lib/core/ai/models/index.d.ts +1 -1
  99. package/build/lib/core/ai/providers/concentrate.d.ts +1 -0
  100. package/build/lib/core/ai/utils.d.ts +2 -0
  101. package/build/lib/core/ai/utils.js +4 -2
  102. package/build/lib/core/api/index.d.ts +3 -0
  103. package/build/lib/core/api/index.js +22 -19
  104. package/build/lib/core/api/targetedPentest.d.ts +1 -0
  105. package/build/lib/core/api/targetedPentest.js +10 -10
  106. package/build/lib/core/config/config.d.ts +3 -0
  107. package/build/lib/core/config/index.js +1 -1
  108. package/build/lib/core/findings/registry.js +3 -3
  109. package/build/lib/core/session/index.d.ts +12 -0
  110. package/build/lib/core/session/index.js +2 -2
  111. package/build/lib/core/session/persistence.d.ts +7 -0
  112. package/build/lib/core/session/persistence.js +7 -3
  113. package/build/lib/core/workflows/fastStrike.d.ts +3 -1
  114. package/build/lib/core/workflows/pentest.d.ts +8 -1
  115. package/build/lib/core/workflows/pentest.js +15 -15
  116. package/build/lib/core/workflows/seams.js +4 -4
  117. package/build/lib/core/workflows/whiteboxAttackSurface.js +11 -11
  118. package/build/lib/index.js +22 -22
  119. package/build/{logs-x62b7hk1.js → logs-70fyr848.js} +13 -13
  120. package/build/{native-rollout-evidence-c9yhfqcs.js → native-rollout-evidence-ntensvzb.js} +3 -3
  121. package/build/{offesecAgent-5whnpeta.js → offesecAgent-kk62tf60.js} +4 -4
  122. package/build/pentest-4jgznn7h.js +22 -0
  123. package/build/{pentests-e0f32aqx.js → pentests-3e41hj08.js} +13 -13
  124. package/build/recordedRunClient-w34kcch1.js +11 -0
  125. package/build/{targetedPentest-rcbs4nvp.js → targetedPentest-t9snxcj2.js} +18 -11
  126. package/build/{targets-xj9g3q0z.js → targets-1pyf21c7.js} +13 -13
  127. package/build/threatModel-48y5qjze.js +21 -0
  128. package/build/{uninstall-7s784q4a.js → uninstall-fbydd9t6.js} +1 -1
  129. package/build/{upload-4gvhwmvr.js → upload-sbhwe2fq.js} +4 -4
  130. package/build/{utils-cjrz64pc.js → utils-23903gcj.js} +3 -3
  131. package/package.json +1 -1
  132. package/src/cli.ts +48 -14
  133. package/src/core/agents/agentRuntime.test.ts +38 -0
  134. package/src/core/agents/agentRuntime.ts +5 -2
  135. package/src/core/agents/defineAgent.ts +3 -1
  136. package/src/core/agents/offSecAgent/index.ts +3 -0
  137. package/src/core/agents/offSecAgent/offensiveSecurityAgent.test.ts +92 -5
  138. package/src/core/agents/offSecAgent/offensiveSecurityAgent.ts +70 -31
  139. package/src/core/agents/offSecAgent/prompt.test.ts +46 -0
  140. package/src/core/agents/offSecAgent/prompt.ts +52 -8
  141. package/src/core/agents/offSecAgent/selectiveConstruction.publicPath.test.ts +38 -0
  142. package/src/core/agents/offSecAgent/selectiveConstruction.test.ts +64 -0
  143. package/src/core/agents/offSecAgent/subagentSpawner.ts +12 -1
  144. package/src/core/agents/offSecAgent/tools/delegateAuth.ts +1 -0
  145. package/src/core/agents/offSecAgent/tools/listMemories.test.ts +230 -0
  146. package/src/core/agents/offSecAgent/tools/listMemories.ts +73 -6
  147. package/src/core/agents/offSecAgent/tools/reportError.test.ts +6 -0
  148. package/src/core/agents/offSecAgent/tools/reportError.ts +10 -2
  149. package/src/core/agents/offSecAgent/tools/runAttackSurface.ts +2 -0
  150. package/src/core/agents/offSecAgent/tools/runPentestWorkflow.test.ts +57 -0
  151. package/src/core/agents/offSecAgent/tools/runPentestWorkflow.ts +19 -1
  152. package/src/core/agents/offSecAgent/tools/runWhiteboxScan.ts +5 -2
  153. package/src/core/agents/offSecAgent/tools/spawnCodingAgent.ts +1 -0
  154. package/src/core/agents/offSecAgent/tools/spawnPentestAgent.test.ts +72 -2
  155. package/src/core/agents/offSecAgent/tools/spawnPentestAgent.ts +32 -11
  156. package/src/core/agents/offSecAgent/tools/spawnPentestSwarm.ts +25 -5
  157. package/src/core/agents/offSecAgent/tools/threatModelGenerator.ts +1 -0
  158. package/src/core/agents/offSecAgent/tools/types.ts +6 -1
  159. package/src/core/agents/offSecAgent/tools/updateTask.ts +5 -1
  160. package/src/core/agents/offSecAgent/tools/whiteboxCandidates.ts +11 -4
  161. package/src/core/agents/offSecAgent/types.ts +9 -0
  162. package/src/core/agents/specialized/codeAgent/agent.test.ts +7 -0
  163. package/src/core/agents/specialized/codeAgent/agent.ts +9 -2
  164. package/src/core/agents/specialized/codeAgent/prompts.ts +6 -0
  165. package/src/core/agents/specialized/pentest/agent.test.ts +116 -0
  166. package/src/core/agents/specialized/pentest/agent.ts +178 -49
  167. package/src/core/agents/specialized/pentest/results.test.ts +59 -4
  168. package/src/core/agents/specialized/whiteboxAttackSurface/endpointDocumentationAgent.ts +1 -0
  169. package/src/core/ai/ai.operator-context.bench.test.ts +1408 -0
  170. package/src/core/ai/ai.recorded-context.test.ts +74 -0
  171. package/src/core/ai/ai.test.ts +54 -0
  172. package/src/core/ai/ai.ts +312 -82
  173. package/src/core/ai/compactionTelemetry.test.ts +2 -2
  174. package/src/core/ai/models/anthropic.ts +6 -0
  175. package/src/core/ai/models/bedrock.ts +18 -0
  176. package/src/core/ai/models/claude-capabilities.ts +29 -8
  177. package/src/core/ai/models/concentrate.ts +52 -0
  178. package/src/core/ai/models/index.ts +25 -4
  179. package/src/core/ai/models/models.test.ts +154 -0
  180. package/src/core/ai/models/openrouter.ts +43 -1
  181. package/src/core/ai/providers/anthropic-models.test.ts +60 -1
  182. package/src/core/ai/providers/bedrock-models.test.ts +81 -0
  183. package/src/core/ai/providers/concentrate.test.ts +31 -0
  184. package/src/core/ai/providers/concentrate.ts +11 -0
  185. package/src/core/ai/providers/gateway-models.test.ts +16 -6
  186. package/src/core/ai/utils.native-rollout-evidence.test.ts +1 -0
  187. package/src/core/ai/utils.ts +189 -143
  188. package/src/core/api/blackboxPentest.ts +9 -1
  189. package/src/core/api/index.ts +9 -0
  190. package/src/core/api/targetedPentest.ts +19 -5
  191. package/src/core/config/config.test.ts +35 -0
  192. package/src/core/config/config.ts +5 -0
  193. package/src/core/observability/telemetry.test.ts +2 -3
  194. package/src/core/session/index.ts +5 -0
  195. package/src/core/session/persistence.test.ts +62 -0
  196. package/src/core/session/persistence.ts +56 -0
  197. package/src/core/workflows/fastStrike.seams.test.ts +149 -0
  198. package/src/core/workflows/fastStrike.test.ts +18 -1
  199. package/src/core/workflows/fastStrike.ts +103 -11
  200. package/src/core/workflows/pentest.test.ts +104 -0
  201. package/src/core/workflows/pentest.ts +110 -7
  202. package/src/core/workflows/seams.test.ts +13 -0
  203. package/src/core/workflows/seams.ts +5 -1
  204. package/src/core/workflows/whiteboxAttackSurface.ts +1 -0
  205. package/src/tui/components/chat/loading-indicator.tsx +20 -4
  206. package/src/tui/components/chat/message-list.tsx +1 -0
  207. package/src/tui/components/commands/__tests__/advanced-settings-lifecycle.tsx +176 -0
  208. package/src/tui/components/commands/advanced-settings.test.ts +28 -0
  209. package/src/tui/components/commands/advanced-settings.tsx +237 -19
  210. package/src/tui/components/operator-dashboard/index.tsx +46 -9
  211. package/src/tui/components/operator-dashboard/logic.test.ts +106 -0
  212. package/src/tui/components/operator-dashboard/logic.ts +42 -2
  213. package/src/tui/components/operator-dashboard/run-events.test.ts +3 -1
  214. package/src/tui/components/shared/__tests__/tool-renderer-lifecycle.tsx +18 -0
  215. package/src/tui/components/shared/action-label.test.ts +9 -0
  216. package/src/tui/components/shared/compacting-icon.tsx +18 -0
  217. package/src/tui/components/shared/index.ts +1 -0
  218. package/src/tui/components/shared/tool-registry.ts +1 -0
  219. package/src/tui/components/shared/tool-renderer.tsx +21 -7
  220. package/src/tui/context/route.tsx +1 -0
  221. package/src/tui/keybindings/registry.ts +2 -0
  222. package/build/agent-6w7egcf1.js +0 -13
  223. package/build/agent-9zx75feh.js +0 -13
  224. package/build/pentest-e61hc38s.js +0 -22
  225. package/build/recordedRunClient-dp032c32.js +0 -11
  226. package/build/threatModel-jkxfa40s.js +0 -21
@@ -1,30 +1,37 @@
1
- import"./cli-fy6vh2a7.js";
2
- import"./cli-c05y640n.js";
3
- import"./cli-qgz1q9g5.js";
1
+ import"./cli-98wmmphf.js";
2
+ import"./cli-9jscnhtg.js";
3
+ import"./cli-t4q4t4dx.js";
4
4
  import {
5
5
  TargetedPentestAgent2
6
- } from "./cli-xtc2t6me.js";
6
+ } from "./cli-vdd1s3x9.js";
7
7
  import {
8
8
  startAgentExecution
9
9
  } from "./cli-g06s7edq.js";
10
- import"./cli-1ve18npr.js";
10
+ import"./cli-72y76bpg.js";
11
11
  import"./cli-qba2x69h.js";
12
- import"./cli-dpsw2fe6.js";
12
+ import"./cli-a6x4jm5a.js";
13
13
  import"./cli-c2k4xxaw.js";
14
14
 
15
15
  // src/core/api/targetedPentest.ts
16
- function normalizeResult(result) {
16
+ function normalizeResult(result, findingPolicy) {
17
17
  const r = result;
18
18
  if (!r || !Array.isArray(r.findings)) {
19
19
  console.error("runTargetedPentestAgent: consume() returned unexpected shape", { keys: result ? Object.keys(result) : null });
20
20
  }
21
21
  const findings = Array.isArray(r?.findings) ? r.findings : [];
22
- console.log(`
22
+ const reportedFindings = Array.isArray(r?.reportedFindings) ? r.reportedFindings : [];
23
+ if (findingPolicy === "external") {
24
+ console.log(`
25
+ Reported ${reportedFindings.length} finding(s) for external evaluation`);
26
+ } else {
27
+ console.log(`
23
28
  Found ${findings.length} vulnerabilities`);
24
- console.log(`Findings: ${r?.findingsPath}`);
25
- console.log(`POCs: ${r?.pocsPath}`);
29
+ console.log(`Findings: ${r?.findingsPath}`);
30
+ console.log(`POCs: ${r?.pocsPath}`);
31
+ }
26
32
  return {
27
33
  findings,
34
+ ...findingPolicy === "external" ? { reportedFindings } : {},
28
35
  findingsPath: r?.findingsPath,
29
36
  pocsPath: r?.pocsPath,
30
37
  objectiveResults: r?.objectiveResults,
@@ -41,7 +48,7 @@ function startTargetedPentestAgent(input) {
41
48
  }
42
49
  const { result, abortAndDrain, drained } = startAgentExecution(agent);
43
50
  return {
44
- result: result.then(normalizeResult),
51
+ result: result.then((value) => normalizeResult(value, input.findingPolicy)),
45
52
  abortAndDrain,
46
53
  drained
47
54
  };
@@ -1,26 +1,26 @@
1
1
  #!/usr/bin/env bun
2
- import"./cli-fy6vh2a7.js";
3
- import"./cli-c05y640n.js";
2
+ import"./cli-t4q4t4dx.js";
3
+ import"./cli-98wmmphf.js";
4
+ import"./cli-9jscnhtg.js";
4
5
  import {
5
6
  listPentestTargets2,
6
7
  listTargetLogs2,
7
8
  searchTargetLogs2
8
- } from "./cli-7eea4e2y.js";
9
- import"./cli-qgz1q9g5.js";
10
- import"./cli-k2nwxta0.js";
11
- import"./cli-kb21qhvm.js";
12
- import"./cli-ngq9dr8n.js";
13
- import"./cli-d37a42dc.js";
14
- import"./cli-3sp6nd8d.js";
15
- import"./cli-xtc2t6me.js";
16
- import"./cli-n2en7j5b.js";
9
+ } from "./cli-5ab346kd.js";
10
+ import"./cli-t09zj814.js";
11
+ import"./cli-1pmfnz1a.js";
12
+ import"./cli-fdrrbb9p.js";
13
+ import"./cli-9pz9wjt2.js";
14
+ import"./cli-9kk9tm58.js";
15
+ import"./cli-vdd1s3x9.js";
16
+ import"./cli-z7ysyrr4.js";
17
17
  import"./cli-xcy2vxj2.js";
18
18
  import {
19
19
  markCommandFailed
20
20
  } from "./cli-z82n3qk1.js";
21
- import"./cli-1ve18npr.js";
21
+ import"./cli-72y76bpg.js";
22
22
  import"./cli-qba2x69h.js";
23
- import"./cli-dpsw2fe6.js";
23
+ import"./cli-a6x4jm5a.js";
24
24
  import"./cli-c2k4xxaw.js";
25
25
 
26
26
  // src/cli/targets.ts
@@ -0,0 +1,21 @@
1
+ import"./cli-t4q4t4dx.js";
2
+ import"./cli-98wmmphf.js";
3
+ import"./cli-9jscnhtg.js";
4
+ import {
5
+ runThreatModelWorkflow2
6
+ } from "./cli-5ab346kd.js";
7
+ import"./cli-t09zj814.js";
8
+ import"./cli-1pmfnz1a.js";
9
+ import"./cli-fdrrbb9p.js";
10
+ import"./cli-9pz9wjt2.js";
11
+ import"./cli-9kk9tm58.js";
12
+ import"./cli-vdd1s3x9.js";
13
+ import"./cli-z7ysyrr4.js";
14
+ import"./cli-xcy2vxj2.js";
15
+ import"./cli-72y76bpg.js";
16
+ import"./cli-qba2x69h.js";
17
+ import"./cli-a6x4jm5a.js";
18
+ import"./cli-c2k4xxaw.js";
19
+ export {
20
+ runThreatModelWorkflow2 as runThreatModelWorkflow
21
+ };
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  detectInstallMethod,
7
7
  init_installation
8
- } from "./cli-65g6rcat.js";
8
+ } from "./cli-w9nw2a4z.js";
9
9
  import {
10
10
  __require
11
11
  } from "./cli-h6y3bt60.js";
@@ -1,10 +1,10 @@
1
- import"./cli-fy6vh2a7.js";
2
- import"./cli-c05y640n.js";
1
+ import"./cli-98wmmphf.js";
2
+ import"./cli-9jscnhtg.js";
3
3
  import {
4
4
  resolveConfig,
5
5
  createWeaveTracer
6
- } from "./cli-az3xq70v.js";
7
- import"./cli-dpsw2fe6.js";
6
+ } from "./cli-cfrdr25z.js";
7
+ import"./cli-a6x4jm5a.js";
8
8
  import"./cli-c2k4xxaw.js";
9
9
 
10
10
  // src/core/integrations/wandb/upload.ts
@@ -1,12 +1,12 @@
1
- import"./cli-fy6vh2a7.js";
2
- import"./cli-c05y640n.js";
1
+ import"./cli-98wmmphf.js";
2
+ import"./cli-9jscnhtg.js";
3
3
  import {
4
4
  init_types
5
5
  } from "./cli-3gt761d2.js";
6
6
  import {
7
7
  AVAILABLE_MODELS,
8
8
  init_ai
9
- } from "./cli-dpsw2fe6.js";
9
+ } from "./cli-a6x4jm5a.js";
10
10
  import"./cli-c2k4xxaw.js";
11
11
 
12
12
  // src/core/providers/utils.ts
package/package.json CHANGED
@@ -344,5 +344,5 @@
344
344
  "tsc": "tsc --noEmit"
345
345
  },
346
346
  "type": "module",
347
- "version": "2.6.1"
347
+ "version": "2.7.0-canary.21cb83dc"
348
348
  }
package/src/cli.ts CHANGED
@@ -301,6 +301,7 @@ pentest options:
301
301
  --task-driven Enable task-driven architecture (experimental)
302
302
  --fast-strike Single-operator fast strike: skip attack-surface/swarm
303
303
  phases, one tight recon→exploit loop against the target
304
+ --external-findings Return findings without Apex's in-run finding judge
304
305
  --prompt <text|@file> Guidance for the pentest agent (inline text or @filepath)
305
306
  --threat-model <text|@file> Threat model to guide the pentest (inline or @filepath)
306
307
  --header "Name: Value" Custom HTTP header (repeatable)
@@ -366,6 +367,7 @@ async function runPentest() {
366
367
  const enableThinking = hasFlag("--extended-thinking");
367
368
  const taskDriven = hasFlag("--task-driven");
368
369
  const fastStrike = hasFlag("--fast-strike");
370
+ const externalFindings = hasFlag("--external-findings");
369
371
  const evidenceOutput = nativeRolloutEvidenceOutput();
370
372
 
371
373
  // Resolve and combine threat model + prompt
@@ -395,7 +397,7 @@ async function runPentest() {
395
397
  PENTEST ORCHESTRATION
396
398
  ${sep}
397
399
  Target: ${target}${cwd ? `\nCwd: ${cwd} (whitebox)` : ""}${exfilMode ? "\nMode: exfil" : ""}
398
- Model: ${model}${enableThinking ? "\nThinking: enabled" : ""}${taskDriven ? "\nTask-driven: enabled" : ""}${fastStrike ? "\nFast strike: enabled" : ""}${headers ? `\nHeaders: ${Object.keys(headers).length} configured` : ""}
400
+ Model: ${model}${enableThinking ? "\nThinking: enabled" : ""}${taskDriven ? "\nTask-driven: enabled" : ""}${fastStrike ? "\nFast strike: enabled" : ""}${externalFindings ? "\nFindings: external evaluation" : ""}${headers ? `\nHeaders: ${Object.keys(headers).length} configured` : ""}
399
401
  `);
400
402
 
401
403
  const session = await sessions.create({
@@ -424,26 +426,58 @@ Model: ${model}${enableThinking ? "\nThinking: enabled" : ""}${taskDriven ? "\
424
426
  const { bus: pentestBus, cleanup: wandbCleanup } =
425
427
  await createInstrumentedBus(session, model);
426
428
  try {
427
- const { findings, findingsPath, pocsPath, reportPath } =
428
- await runPentestAgent({
429
- target,
430
- ...(cwd ? { cwd } : {}),
431
- session,
432
- model,
433
- enableThinking,
434
- ...(fastStrike ? { fastStrike: true } : {}),
435
- surfaceIntegrationEnabled: pensarConfig.surfaceIntegrationEnabled,
436
- authConfig: buildAuthConfig(pensarConfig),
437
- eventBus: pentestBus,
438
- });
429
+ const {
430
+ findings,
431
+ findingsPath,
432
+ pocsPath,
433
+ reportPath,
434
+ reportedFindings,
435
+ objectiveResults,
436
+ submissionJson,
437
+ solved,
438
+ summary,
439
+ } = await runPentestAgent({
440
+ target,
441
+ ...(cwd ? { cwd } : {}),
442
+ session,
443
+ model,
444
+ enableThinking,
445
+ ...(externalFindings ? { findingPolicy: "external" as const } : {}),
446
+ ...(fastStrike ? { fastStrike: true } : {}),
447
+ surfaceIntegrationEnabled: pensarConfig.surfaceIntegrationEnabled,
448
+ authConfig: buildAuthConfig(pensarConfig),
449
+ eventBus: pentestBus,
450
+ });
439
451
 
440
- console.log(`
452
+ if (externalFindings) {
453
+ console.log(`
454
+ ${sep}
455
+ RESULTS
456
+ ${sep}
457
+ Findings: ${reportedFindings?.length ?? 0}
458
+ Evaluation: external`);
459
+ console.log(
460
+ JSON.stringify(
461
+ {
462
+ reportedFindings: reportedFindings ?? [],
463
+ ...(objectiveResults ? { objectiveResults } : {}),
464
+ ...(submissionJson ? { submissionJson } : {}),
465
+ ...(solved === undefined ? {} : { solved }),
466
+ ...(summary === undefined ? {} : { summary }),
467
+ },
468
+ null,
469
+ 2,
470
+ ),
471
+ );
472
+ } else {
473
+ console.log(`
441
474
  ${sep}
442
475
  RESULTS
443
476
  ${sep}
444
477
  Findings: ${findings.length}
445
478
  Path: ${findingsPath}
446
479
  POCs: ${pocsPath}${reportPath ? `\nReport: ${reportPath}` : ""}`);
480
+ }
447
481
  } finally {
448
482
  await wandbCleanup();
449
483
  }
@@ -175,6 +175,42 @@ describe("AgentRuntime — hook forwarding", () => {
175
175
 
176
176
  expect(constructorCalls[0]!.stopWhen).toBe(callerStopWhen);
177
177
  });
178
+
179
+ it("forwards an executed response tool's validated result to the definition resolver", () => {
180
+ constructorCalls.length = 0;
181
+ const opts: FakeOpts = {
182
+ model: "test-model" as AIModel,
183
+ // biome-ignore lint/suspicious/noExplicitAny: minimal SessionInfo stand-in
184
+ session: { rootPath: "/tmp", targets: [] } as any,
185
+ objective: "find a weakness",
186
+ };
187
+ const resolveResult = vi.fn(() => ({ reportedFindings: ["verified"] }));
188
+ const definition = defineAgent<FakeOpts, { reportedFindings: string[] }>({
189
+ name: "test-agent",
190
+ role: "worker",
191
+ prompt: (input) => input.objective,
192
+ activeTools: () => ["response"],
193
+ resolveResult,
194
+ });
195
+
196
+ new AgentRuntime(definition, opts);
197
+
198
+ const streamResult = { response: Promise.resolve({ messages: [] }) };
199
+ const validatedResponse = { reportedFindings: ["verified"] };
200
+ const forwarded = constructorCalls[0]?.resolveResult;
201
+ if (typeof forwarded !== "function") {
202
+ throw new Error("Missing forwarded result resolver");
203
+ }
204
+ expect(forwarded(streamResult, validatedResponse)).toEqual(
205
+ validatedResponse,
206
+ );
207
+ expect(resolveResult).toHaveBeenCalledWith(
208
+ opts,
209
+ undefined,
210
+ streamResult,
211
+ validatedResponse,
212
+ );
213
+ });
178
214
  });
179
215
 
180
216
  describe("assembleAgentHooks — compile-time completeness", () => {
@@ -197,6 +233,7 @@ describe("assembleAgentHooks — compile-time completeness", () => {
197
233
  "abortSignal",
198
234
  "extraTools",
199
235
  "sandbox",
236
+ "findingPolicy",
200
237
  ].sort(),
201
238
  );
202
239
  });
@@ -217,6 +254,7 @@ describe("assembleAgentHooks — compile-time completeness", () => {
217
254
  abortSignal: undefined,
218
255
  extraTools: undefined,
219
256
  sandbox: undefined,
257
+ findingPolicy: undefined,
220
258
  };
221
259
  expectTypeOf(complete).toEqualTypeOf<RequiredAgentHooks>();
222
260
 
@@ -13,7 +13,7 @@ import type { SubagentSpawner } from "./offSecAgent/subagentSpawner";
13
13
  import type { EmailAdapterResolver } from "./offSecAgent/tools/email/adapters";
14
14
  import type { UnifiedSandbox } from "./offSecAgent/tools/sandbox";
15
15
  import type { SmsInbox } from "./offSecAgent/tools/smsInbox";
16
- import type { StreamIdFactory } from "./offSecAgent/types";
16
+ import type { FindingPolicy, StreamIdFactory } from "./offSecAgent/types";
17
17
 
18
18
  /**
19
19
  * {@link AgentHooks} with every key required (value types keep their
@@ -23,6 +23,7 @@ import type { StreamIdFactory } from "./offSecAgent/types";
23
23
  * "dropping a hook is a type error".
24
24
  */
25
25
  export interface RequiredAgentHooks {
26
+ findingPolicy: FindingPolicy | undefined;
26
27
  backends: ToolBackends | undefined;
27
28
  subagentSpawner: SubagentSpawner | undefined;
28
29
  languageModelMiddleware:
@@ -51,6 +52,7 @@ export interface RequiredAgentHooks {
51
52
  */
52
53
  export function assembleAgentHooks(opts: AgentHooks): RequiredAgentHooks {
53
54
  return {
55
+ findingPolicy: opts.findingPolicy,
54
56
  backends: opts.backends,
55
57
  subagentSpawner: opts.subagentSpawner,
56
58
  languageModelMiddleware: opts.languageModelMiddleware,
@@ -101,7 +103,8 @@ export class AgentRuntime<
101
103
  definition.extraTools?.(opts, state),
102
104
  ),
103
105
  resolveResult: resolveResult
104
- ? (streamResult) => resolveResult(opts, state, streamResult)
106
+ ? (streamResult, validatedResponse) =>
107
+ resolveResult(opts, state, streamResult, validatedResponse)
105
108
  : undefined,
106
109
  target: definition.target?.(opts, state) ?? opts.target,
107
110
  grpc: definition.grpc?.(opts, state) ?? opts.grpc,
@@ -63,11 +63,13 @@ export interface AgentDefinition<
63
63
  /** Extra tools this definition injects, merged on top of `opts.extraTools`. */
64
64
  extraTools?: (opts: TOpts, state: TState) => ToolSet | undefined;
65
65
 
66
- /** Produces `consume()`'s typed result from the finished stream. */
66
+ /** Produces `consume()`'s typed result from the finished stream and, when
67
+ * the response tool executes, its schema-validated result. */
67
68
  resolveResult?: (
68
69
  opts: TOpts,
69
70
  state: TState,
70
71
  streamResult: StreamTextResult<ToolSet, never>,
72
+ validatedResponse?: unknown,
71
73
  ) => TResult | Promise<TResult>;
72
74
 
73
75
  /** Target URL/host, when this definition derives one instead of taking it verbatim from `opts`. */
@@ -8,6 +8,8 @@ export type { AgentEventMap } from "../../eventBus";
8
8
  // ---------------------------------------------------------------------------
9
9
  export { AgentEventBus } from "../../eventBus";
10
10
  export { OffensiveSecurityAgent } from "./offensiveSecurityAgent";
11
+ /** Runtime marker for hosts that require Apex's externally graded finding policy. */
12
+ export const EXTERNAL_FINDING_POLICY_CAPABILITY = "v1" as const;
11
13
  // ---------------------------------------------------------------------------
12
14
  // System prompts
13
15
  // ---------------------------------------------------------------------------
@@ -156,6 +158,7 @@ export {
156
158
  type CommandCancelHandle,
157
159
  type CreateAgentInput,
158
160
  type Finding,
161
+ type FindingPolicy,
159
162
  type OffensiveSecurityAgentInput,
160
163
  type SpecializedAgentInput,
161
164
  type SystemPentestScope,
@@ -361,6 +361,86 @@ describe("spawned-agent usage callbacks", () => {
361
361
  });
362
362
 
363
363
  describe("auxiliary model events", () => {
364
+ it("persists prepared context instead of restoring a fitted-away prefix", async () => {
365
+ streamResponseCalls.length = 0;
366
+ const rootPath = mkdtempSync(join(tmpdir(), "apex-fitted-history-"));
367
+ try {
368
+ const agent = new OffensiveSecurityAgent({
369
+ prompt: "test",
370
+ model: "test-model",
371
+ messages: [{ role: "user", content: "old large prefix" }],
372
+ session: { id: "ses_fitted_history", rootPath },
373
+ activeTools: [],
374
+ sandbox: {},
375
+ } as never);
376
+ void agent.streamResult;
377
+ const call = streamResponseCalls[0] as {
378
+ onContextPrepared: (context: {
379
+ messages: Array<{ role: string; content: unknown }>;
380
+ responseMessageOffset: number;
381
+ }) => void;
382
+ onStepFinish: (event: unknown) => Promise<void>;
383
+ };
384
+ const firstStep = [
385
+ { role: "assistant", content: "first call" },
386
+ { role: "tool", content: "full first result" },
387
+ ];
388
+ const cachedSystem = {
389
+ role: "system",
390
+ content: "cached effective system prompt",
391
+ providerOptions: {
392
+ anthropic: { cacheControl: { type: "ephemeral" } },
393
+ },
394
+ };
395
+ const historySystem = {
396
+ role: "system",
397
+ content: "caller-supplied history instruction",
398
+ };
399
+ call.onContextPrepared({
400
+ messages: [
401
+ cachedSystem,
402
+ cachedSystem,
403
+ historySystem,
404
+ { role: "user", content: "fitted prefix" },
405
+ ],
406
+ responseMessageOffset: 0,
407
+ });
408
+ await call.onStepFinish({
409
+ response: { id: "step-1", messages: firstStep },
410
+ usage: { inputTokens: 10, outputTokens: 2 },
411
+ });
412
+
413
+ const compacted = [
414
+ historySystem,
415
+ { role: "user", content: "fitted prefix" },
416
+ { role: "assistant", content: "first call" },
417
+ { role: "tool", content: "short first result" },
418
+ ];
419
+ call.onContextPrepared({
420
+ messages: [cachedSystem, cachedSystem, ...compacted],
421
+ responseMessageOffset: 2,
422
+ });
423
+ const secondStep = [
424
+ { role: "assistant", content: "second call" },
425
+ { role: "tool", content: "second result" },
426
+ ];
427
+ await call.onStepFinish({
428
+ response: {
429
+ id: "step-2",
430
+ messages: [...firstStep, ...secondStep],
431
+ },
432
+ usage: { inputTokens: 10, outputTokens: 2 },
433
+ });
434
+
435
+ const writer = (agent as unknown as { writer: AgentMessageWriter })
436
+ .writer;
437
+ expect(writer.latest).toEqual([...compacted, ...secondStep]);
438
+ writer.cancelTimer();
439
+ } finally {
440
+ rmSync(rootPath, { recursive: true, force: true });
441
+ }
442
+ });
443
+
364
444
  it("keeps the last complete message snapshot while forwarding usage", async () => {
365
445
  streamResponseCalls.length = 0;
366
446
  traceRecordStepCalls.length = 0;
@@ -2806,6 +2886,11 @@ describe("trace identity and root IO", () => {
2806
2886
  describe("contextRecorder integration", () => {
2807
2887
  const streamTextChunk = { type: "text-delta", id: "t1", delta: "hi" };
2808
2888
  const CANONICAL = [
2889
+ {
2890
+ role: "system",
2891
+ content: "cached effective system prompt",
2892
+ providerOptions: { anthropic: { cacheControl: { type: "ephemeral" } } },
2893
+ },
2809
2894
  { role: "user", content: "recorded prompt" },
2810
2895
  { role: "assistant", content: "recorded answer" },
2811
2896
  ] as never[];
@@ -2874,14 +2959,13 @@ describe("contextRecorder integration", () => {
2874
2959
  expect(streamResponseCalls[0]?.inferenceRecorder).toBe(inferenceRecorder);
2875
2960
 
2876
2961
  const stepEvent = {
2877
- response: { id: "resp_1", messages: CANONICAL.slice(1) },
2962
+ response: { id: "resp_1", messages: CANONICAL.slice(2) },
2878
2963
  usage: {},
2879
2964
  };
2880
2965
  await streamOpts.onStepFinish(stepEvent);
2881
2966
 
2882
- // Writer snapshot equals canonical latest() exactly — the step's
2883
- // response.messages are already part of the committed context, so the
2884
- // projection must not re-prepend a base or duplicate them.
2967
+ // The cached system message is transport-only; it must not enter the
2968
+ // transcript reloaded with a fresh system prompt on the next turn.
2885
2969
  const writer = agent["writer" as keyof typeof agent] as unknown as {
2886
2970
  waitForPendingWrites: () => Promise<void>;
2887
2971
  latest: unknown[] | null;
@@ -2894,6 +2978,9 @@ describe("contextRecorder integration", () => {
2894
2978
  await streamOpts.onFinish(finishEvent);
2895
2979
 
2896
2980
  expect(recorder.latest).toHaveBeenCalled();
2897
- expect((captured as unknown[]).length).toBe(CANONICAL.length);
2981
+ expect(captured).toEqual(CANONICAL.slice(1));
2982
+ expect(
2983
+ JSON.parse(readFileSync(join(rootPath, "messages.json"), "utf8")),
2984
+ ).toEqual(CANONICAL.slice(1));
2898
2985
  });
2899
2986
  });