@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
@@ -12,24 +12,24 @@ import {
12
12
  pLimit,
13
13
  PLAN_MODE_TOOL_NAMES,
14
14
  OffensiveSecurityAgent
15
- } from "./cli-qgz1q9g5.js";
15
+ } from "./cli-t4q4t4dx.js";
16
16
  import {
17
17
  BlackboxAttackSurfaceAgent2
18
- } from "./cli-k2nwxta0.js";
18
+ } from "./cli-t09zj814.js";
19
19
  import {
20
20
  TargetedPentestAgent2,
21
21
  buildPentestSystemPrompt2
22
- } from "./cli-xtc2t6me.js";
22
+ } from "./cli-vdd1s3x9.js";
23
23
  import {
24
24
  buildPentestReport,
25
25
  renderJson,
26
26
  renderMarkdown,
27
27
  REPORT_FILENAME_MD,
28
28
  REPORT_FILENAME_JSON
29
- } from "./cli-n2en7j5b.js";
29
+ } from "./cli-z7ysyrr4.js";
30
30
  import {
31
31
  CodeAgent2
32
- } from "./cli-kb21qhvm.js";
32
+ } from "./cli-1pmfnz1a.js";
33
33
  import {
34
34
  WHITEBOX_APPS_DISCOVERY_SYSTEM_PROMPT2,
35
35
  WHITEBOX_ENDPOINT_DOCUMENTATION_SYSTEM_PROMPT,
@@ -38,7 +38,7 @@ import {
38
38
  AppInfoSchema2,
39
39
  AppsDiscoveryResultSchema2,
40
40
  DiscoverySummarySchema2
41
- } from "./cli-ngq9dr8n.js";
41
+ } from "./cli-fdrrbb9p.js";
42
42
  import {
43
43
  createThreatModelPrompt
44
44
  } from "./cli-q126f6ef.js";
@@ -50,7 +50,7 @@ import {
50
50
  init_session,
51
51
  createLogger,
52
52
  init_structured
53
- } from "./cli-dpsw2fe6.js";
53
+ } from "./cli-a6x4jm5a.js";
54
54
  import {
55
55
  newSessionId,
56
56
  init_id
@@ -262,6 +262,28 @@ function loadSubagentMessages(session, key) {
262
262
  return [];
263
263
  }
264
264
  }
265
+ function loadSubagentReportedFindings(session, key) {
266
+ const snapshotPath = join2(session.rootPath, SUBAGENTS_DIR, `${key}.json`);
267
+ if (!existsSync2(snapshotPath))
268
+ return null;
269
+ try {
270
+ const data = JSON.parse(readFileSync2(snapshotPath, "utf-8"));
271
+ return data.status === "completed" && Array.isArray(data.reportedFindings) && data.reportedFindings.every((finding) => typeof finding === "string") ? data.reportedFindings : null;
272
+ } catch {
273
+ return null;
274
+ }
275
+ }
276
+ function loadSubagentObjectiveResults(session, key) {
277
+ const snapshotPath = join2(session.rootPath, SUBAGENTS_DIR, `${key}.json`);
278
+ if (!existsSync2(snapshotPath))
279
+ return null;
280
+ try {
281
+ const data = JSON.parse(readFileSync2(snapshotPath, "utf-8"));
282
+ return data.status === "completed" && Array.isArray(data.objectiveResults) && data.objectiveResults.every((result) => result !== null && typeof result === "object" && typeof result.objective === "string" && typeof result.completed === "boolean" && (result.result === undefined || typeof result.result === "string")) ? data.objectiveResults : null;
283
+ } catch {
284
+ return null;
285
+ }
286
+ }
265
287
  function saveSubagentData(session, data) {
266
288
  const subagentsDir = join2(session.rootPath, SUBAGENTS_DIR);
267
289
  mkdirSync(subagentsDir, { recursive: true });
@@ -287,6 +309,8 @@ function saveSubagentData(session, data) {
287
309
  toolCallCount,
288
310
  stepCount,
289
311
  findingsCount: data.findingsCount ?? 0,
312
+ reportedFindings: data.reportedFindings,
313
+ objectiveResults: data.objectiveResults,
290
314
  status: data.status,
291
315
  error: data.error,
292
316
  messages: data.messages,
@@ -780,6 +804,7 @@ async function runEndpointDocumentationAgent(opts) {
780
804
  attackSurfaceRegistry
781
805
  },
782
806
  runtime: {
807
+ findingPolicy: hooks?.findingPolicy,
783
808
  model,
784
809
  session,
785
810
  authConfig,
@@ -7079,6 +7104,7 @@ async function runWhiteboxAttackSurfaceApp(app, appIndex, input) {
7079
7104
  attackSurfaceRegistry
7080
7105
  },
7081
7106
  runtime: {
7107
+ findingPolicy: hooksForApp.findingPolicy,
7082
7108
  model,
7083
7109
  session,
7084
7110
  authConfig,
@@ -7937,8 +7963,22 @@ async function runPentestSwarmTarget(target, index, input) {
7937
7963
  const entry = manifestEntries[index];
7938
7964
  const subagentId = entry.id;
7939
7965
  const subagentName = target.name ?? entry.name;
7940
- if (completedIds.has(subagentId))
7941
- return null;
7966
+ if (completedIds.has(subagentId)) {
7967
+ if (sharedHooks.findingPolicy !== "external")
7968
+ return null;
7969
+ const reportedFindings = loadSubagentReportedFindings(session, subagentId);
7970
+ const objectiveResults = loadSubagentObjectiveResults(session, subagentId);
7971
+ if (!reportedFindings || !objectiveResults) {
7972
+ throw new Error(`Cannot resume externally graded pentest: findings or objective results for completed agent ${subagentId} are unavailable`);
7973
+ }
7974
+ return {
7975
+ findings: [],
7976
+ reportedFindings,
7977
+ objectiveResults,
7978
+ findingsPath: session.findingsPath,
7979
+ pocsPath: session.pocsPath
7980
+ };
7981
+ }
7942
7982
  const itemHooks = resolveItemHooks(sharedHooks, seams, target, index);
7943
7983
  const childSignal = abortSignal && itemHooks.abortSignal ? AbortSignal.any([abortSignal, itemHooks.abortSignal]) : abortSignal ?? itemHooks.abortSignal;
7944
7984
  const previousMessages = loadSubagentMessages(session, subagentId);
@@ -8035,14 +8075,21 @@ async function runPentestSwarmTarget(target, index, input) {
8035
8075
  abortSignal: childSignal
8036
8076
  });
8037
8077
  const result = await agent.consume();
8078
+ if (itemHooks.findingPolicy === "external" && (!Array.isArray(result.reportedFindings) || !Array.isArray(result.objectiveResults))) {
8079
+ throw new Error(`Externally graded pentest worker ${subagentId} ended without structured findings and objective results`);
8080
+ }
8038
8081
  saveSubagentData(session, {
8039
8082
  agentName: subagentId,
8040
8083
  target: target.target,
8041
8084
  objective: objectiveStr,
8042
8085
  status: "completed",
8043
- findingsCount: result.findings.length,
8086
+ findingsCount: result.reportedFindings?.length ?? result.findings.length,
8087
+ ...itemHooks.findingPolicy === "external" ? {
8088
+ reportedFindings: result.reportedFindings,
8089
+ objectiveResults: result.objectiveResults
8090
+ } : {},
8044
8091
  messages: [...previousMessages, ...lastMessages],
8045
- systemPrompt: buildPentestSystemPrompt2(session),
8092
+ systemPrompt: buildPentestSystemPrompt2(session, "orchestrator", "default", undefined, undefined, itemHooks.findingPolicy),
8046
8093
  userPrompt: agent.userPrompt
8047
8094
  });
8048
8095
  updateManifestEntryStatus(session, subagentId, "completed");
@@ -8060,7 +8107,7 @@ async function runPentestSwarmTarget(target, index, input) {
8060
8107
  status: "failed",
8061
8108
  error: error instanceof Error ? error.message : String(error),
8062
8109
  messages: [...previousMessages, ...lastMessages],
8063
- systemPrompt: buildPentestSystemPrompt2(session),
8110
+ systemPrompt: buildPentestSystemPrompt2(session, "orchestrator", "default", undefined, undefined, itemHooks.findingPolicy),
8064
8111
  userPrompt: agent?.userPrompt ?? ""
8065
8112
  });
8066
8113
  updateManifestEntryStatus(session, subagentId, "failed");
@@ -8106,7 +8153,8 @@ async function runPentestSwarm2(input) {
8106
8153
  languageModelMiddleware,
8107
8154
  usageRecorder,
8108
8155
  streamIdFactory,
8109
- ...hooks
8156
+ ...hooks,
8157
+ findingPolicy: hooks?.findingPolicy ?? input.findingPolicy
8110
8158
  };
8111
8159
  const findingsRegistry = withFindingPersistedHook(rawFindingsRegistry, seams.hooks.onFindingPersisted);
8112
8160
  const completedIds = getCompletedAgentIds(session);
@@ -8135,11 +8183,14 @@ async function runPentestSwarm2(input) {
8135
8183
  };
8136
8184
  const results = await seams.fanOut.spawnMany(targets, (target, index) => runPentestSwarmTarget(target, index, targetInput), { concurrency, abortSignal });
8137
8185
  finalizeManifest(session, manifestEntries, results);
8186
+ if (sharedHooks.findingPolicy === "external" && results.some((result) => result === null)) {
8187
+ throw new Error("Externally graded pentest has an incomplete swarm target; findings cannot be aggregated");
8188
+ }
8138
8189
  return results;
8139
8190
  }
8140
8191
  async function runPentestWorkflow2(input) {
8141
8192
  if (input.fastStrike) {
8142
- const { runFastStrike } = await import("./fastStrike-mcjdvwez.js");
8193
+ const { runFastStrike } = await import("./fastStrike-16jw1s61.js");
8143
8194
  return runFastStrike(input);
8144
8195
  }
8145
8196
  const {
@@ -8159,6 +8210,7 @@ async function runPentestWorkflow2(input) {
8159
8210
  threatModel,
8160
8211
  surfaceIntegrationEnabled
8161
8212
  } = input;
8213
+ const findingPolicy = input.hooks?.findingPolicy ?? input.findingPolicy;
8162
8214
  const seams = input.seams ?? inProcessSeams({
8163
8215
  fanOut: input.hooks?.subagentSpawner ?? input.subagentSpawner,
8164
8216
  registries: {
@@ -8234,7 +8286,8 @@ ${combined}` : combined;
8234
8286
  languageModelMiddleware: input.languageModelMiddleware,
8235
8287
  usageRecorder: input.usageRecorder,
8236
8288
  streamIdFactory: input.streamIdFactory,
8237
- ...input.hooks
8289
+ ...input.hooks,
8290
+ findingPolicy
8238
8291
  },
8239
8292
  seams
8240
8293
  });
@@ -8254,7 +8307,8 @@ ${combined}` : combined;
8254
8307
  languageModelMiddleware: input.languageModelMiddleware,
8255
8308
  usageRecorder: input.usageRecorder,
8256
8309
  streamIdFactory: input.streamIdFactory,
8257
- ...input.hooks
8310
+ ...input.hooks,
8311
+ findingPolicy
8258
8312
  }
8259
8313
  });
8260
8314
  }
@@ -8270,6 +8324,16 @@ ${combined}` : combined;
8270
8324
  throw new DOMException("Pentest aborted by user", "AbortError");
8271
8325
  }
8272
8326
  if (swarmTargets.length === 0) {
8327
+ if (findingPolicy === "external") {
8328
+ return {
8329
+ findings: [],
8330
+ reportedFindings: [],
8331
+ objectiveResults: [],
8332
+ findingsPath: session.findingsPath,
8333
+ pocsPath: session.pocsPath,
8334
+ reportPath: null
8335
+ };
8336
+ }
8273
8337
  const report = buildPentestReport([], {
8274
8338
  target,
8275
8339
  model,
@@ -8293,9 +8357,12 @@ ${combined}` : combined;
8293
8357
  });
8294
8358
  const findingsRegistry = seams.registries.findings();
8295
8359
  const completedCount = getCompletedAgentIds(session).size;
8296
- if (completedCount < swarmTargets.length) {
8297
- await runPentestSwarm2({
8360
+ let externalReportedFindings = [];
8361
+ let externalObjectiveResults = [];
8362
+ if (findingPolicy === "external" || completedCount < swarmTargets.length) {
8363
+ const swarmResults = await runPentestSwarm2({
8298
8364
  targets: swarmTargets,
8365
+ findingPolicy,
8299
8366
  model,
8300
8367
  session,
8301
8368
  authConfig,
@@ -8314,10 +8381,26 @@ ${combined}` : combined;
8314
8381
  hooks: input.hooks,
8315
8382
  seams
8316
8383
  });
8384
+ externalReportedFindings = swarmResults.flatMap((result) => result?.reportedFindings ?? []);
8385
+ externalObjectiveResults = swarmResults.flatMap((result) => result?.objectiveResults ?? []);
8317
8386
  }
8318
8387
  if (abortSignal?.aborted) {
8319
8388
  throw new DOMException("Pentest aborted by user", "AbortError");
8320
8389
  }
8390
+ if (findingPolicy === "external") {
8391
+ eventBus?.emit("workflow-phase-complete", {
8392
+ phase: "pentesting",
8393
+ summary: { findingsCount: externalReportedFindings.length }
8394
+ });
8395
+ return {
8396
+ findings: [],
8397
+ reportedFindings: externalReportedFindings,
8398
+ objectiveResults: externalObjectiveResults,
8399
+ findingsPath: session.findingsPath,
8400
+ pocsPath: session.pocsPath,
8401
+ reportPath: null
8402
+ };
8403
+ }
8321
8404
  eventBus?.emit("workflow-phase-start", {
8322
8405
  phase: "reporting",
8323
8406
  label: "Report Generation"