@pensar/apex 2.4.0 → 2.5.0-canary.22f2eb52

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 (94) hide show
  1. package/build/agent-7qtpem5z.js +12 -0
  2. package/build/agent-9khcyh5t.js +14 -0
  3. package/build/agent-bsyhck0a.js +12 -0
  4. package/build/{agent-5ejt5vpz.js → agent-ywewzc2h.js} +42 -42
  5. package/build/{apps-17wvz1d7.js → apps-11akynyv.js} +74 -43
  6. package/build/{auth-z3h9859n.js → auth-dd6r9mk4.js} +57 -61
  7. package/build/blackboxAgent-hbra4k00.js +12 -0
  8. package/build/blackboxPentest-bn5evs2z.js +61 -0
  9. package/build/{cli-xshasbwe.js → cli-3v9zs5wm.js} +31 -52
  10. package/build/{cli-mavved45.js → cli-4z46kyrk.js} +86 -93
  11. package/build/cli-7vby0hk6.js +12136 -0
  12. package/build/{cli-gq40s5b3.js → cli-8kkaeb70.js} +33 -46
  13. package/build/cli-8w8k4dph.js +15 -0
  14. package/build/cli-ag6jtndp.js +32 -0
  15. package/build/{cli-2cbwdk78.js → cli-ak78mweh.js} +4 -4
  16. package/build/cli-bb02pjt0.js +1485 -0
  17. package/build/{cli-k71t434r.js → cli-ec2hwkv3.js} +34 -76
  18. package/build/{cli-vnynf0js.js → cli-f5rw841m.js} +11 -5
  19. package/build/{cli-k8kc47pq.js → cli-gamfs2yq.js} +118 -115
  20. package/build/{cli-32z0017y.js → cli-gq5sk2j3.js} +36 -60
  21. package/build/{cli-bc05qbss.js → cli-h6y3bt60.js} +13 -21
  22. package/build/{cli-tkc598ey.js → cli-j1916nvj.js} +10035 -7661
  23. package/build/{cli-5k33webc.js → cli-jw1xftqm.js} +355 -332
  24. package/build/{cli-tznv8pf1.js → cli-n4h7ygp5.js} +4 -4
  25. package/build/{cli-b1adytsy.js → cli-q45hcq3f.js} +67 -39
  26. package/build/{cli-repbyhkk.js → cli-qkb3v2nw.js} +26063 -25373
  27. package/build/{cli-j54qa6tm.js → cli-qktcyj48.js} +1 -1
  28. package/build/cli-retw3rw5.js +12 -0
  29. package/build/cli-tjm77pmx.js +12075 -0
  30. package/build/{cli-dm0fc0bm.js → cli-v1sarr4y.js} +5 -9
  31. package/build/{cli-9rhzhgx2.js → cli-v8ph8hy2.js} +5 -5
  32. package/build/{cli-vq52kp7j.js → cli-vkxx4jzv.js} +147 -128
  33. package/build/cli-wfb4gde1.js +22 -0
  34. package/build/{cli-ee3axgts.js → cli-xbhr5khz.js} +1 -1
  35. package/build/cli-z82n3qk1.js +6 -0
  36. package/build/cli.js +689 -132
  37. package/build/{config-f1mj4nhd.js → config-kv5v9ctn.js} +29 -29
  38. package/build/{doctor-ekneewa3.js → doctor-xs4s5km8.js} +4 -9
  39. package/build/{fastStrike-8zka43xs.js → fastStrike-b8t8f916.js} +26 -28
  40. package/build/{fixes-b89s5haw.js → fixes-kcckqx3s.js} +22 -27
  41. package/build/getMachineId-bsd-zr67nd9p.js +36 -0
  42. package/build/getMachineId-darwin-fd1d562d.js +36 -0
  43. package/build/getMachineId-linux-kjmg243j.js +29 -0
  44. package/build/getMachineId-unsupported-n4r58vke.js +19 -0
  45. package/build/getMachineId-win-yzgpfsrb.js +38 -0
  46. package/build/index-3mzr07h0.js +9 -0
  47. package/build/index-63zf8jxx.js +12 -0
  48. package/build/index-a1bg29j1.js +1559 -0
  49. package/build/{index-cbwn03kz.js → index-a2xycbjs.js} +12 -31
  50. package/build/{index-6d22pyxt.js → index-ae81pvwg.js} +2995 -2432
  51. package/build/index-cbajq2xy.js +17 -0
  52. package/build/index-cn4p95gh.js +100 -0
  53. package/build/index-kas88svr.js +36 -0
  54. package/build/index-mr20g8k4.js +22 -0
  55. package/build/{index-psqjpw5m.js → index-nweqptgs.js} +7 -7
  56. package/build/{index-sf16jm0m.js → index-rx5jn1nz.js} +137 -162
  57. package/build/{issues-xx5bs4md.js → issues-jm28k288.js} +81 -35
  58. package/build/{logs-qtxe51w2.js → logs-r02tbz89.js} +20 -25
  59. package/build/{multipart-parser-g2xxkezz.js → multipart-parser-vjjdbpd1.js} +10 -10
  60. package/build/{offesecAgent-b9e2xm6v.js → offesecAgent-mmfejh1j.js} +6 -13
  61. package/build/{parse-rtccymzn.js → parse-cqecqrc5.js} +0 -4
  62. package/build/pentest-13jcm4cy.js +21 -0
  63. package/build/{pentests-6ks3szc4.js → pentests-jyn4zs7n.js} +23 -28
  64. package/build/{targetedPentest-s1ptvq8e.js → targetedPentest-m3qkbpv6.js} +16 -20
  65. package/build/{targets-sxygyj87.js → targets-rqv57as0.js} +22 -27
  66. package/build/threatModel-scmz36xr.js +19 -0
  67. package/build/{token-3bbp59y6.js → token-n0tmq8n5.js} +2 -2
  68. package/build/{token-util-6xjme11b.js → token-util-bv80pj47.js} +1 -2
  69. package/build/{uninstall-tvsh81v8.js → uninstall-bme62bdg.js} +7 -4
  70. package/build/{upload-7wdyyqmr.js → upload-hwpgx1ha.js} +7 -13
  71. package/build/{utils-7fwdkqk6.js → utils-abtz5mmk.js} +7 -29
  72. package/package.json +8 -2
  73. package/build/agent-mvpgvgks.js +0 -19
  74. package/build/agent-nhs1w5w0.js +0 -29
  75. package/build/authentication-3s97cpk4.js +0 -19
  76. package/build/blackboxAgent-gw0a1ca4.js +0 -19
  77. package/build/blackboxPentest-44333zss.js +0 -37
  78. package/build/cli-0n4r54hq.js +0 -414
  79. package/build/cli-72cvcqhg.js +0 -22
  80. package/build/cli-qqt4gj1w.js +0 -53
  81. package/build/cli-swpbx60z.js +0 -24441
  82. package/build/index-4ad3sdwk.js +0 -39
  83. package/build/index-ghwf5z3v.js +0 -12
  84. package/build/index-hqjdg6fg.js +0 -205
  85. package/build/index-mtq7kmxz.js +0 -12856
  86. package/build/index-rbzhk712.js +0 -33
  87. package/build/index-y5w6n3tb.js +0 -19
  88. package/build/main-mmjp338j.js +0 -324
  89. package/build/pentest-xtc1sjdw.js +0 -29
  90. package/build/threatModel-xsm6fwk5.js +0 -27
  91. /package/build/{cli-c8131c4q.js → cli-0wsh8j2t.js} +0 -0
  92. /package/build/{cli-e08r86zk.js → cli-b3dvxjgk.js} +0 -0
  93. /package/build/{cli-fw5r7pfj.js → cli-q126f6ef.js} +0 -0
  94. /package/build/{cli-9fsre5pt.js → cli-qba2x69h.js} +0 -0
@@ -1,59 +1,56 @@
1
1
  import {
2
- BlackboxAttackSurfaceAgent
3
- } from "./cli-gq40s5b3.js";
4
- import {
5
- REPORT_FILENAME_JSON,
6
- REPORT_FILENAME_MD,
7
- buildPentestReport,
8
- renderJson,
9
- renderMarkdown
10
- } from "./cli-b1adytsy.js";
11
- import {
12
- TargetedPentestAgent,
13
- buildPentestSystemPrompt
14
- } from "./cli-mavved45.js";
15
- import {
16
- CodeAgent
17
- } from "./cli-32z0017y.js";
18
- import {
19
- AppsDiscoveryResultSchema,
20
- DiscoverySummarySchema,
21
- EndpointSchema,
22
- WHITEBOX_APPS_DISCOVERY_SYSTEM_PROMPT,
23
- WHITEBOX_DISCOVERY_SYSTEM_PROMPT,
24
- WHITEBOX_ENDPOINT_DOCUMENTATION_SYSTEM_PROMPT
25
- } from "./cli-k8kc47pq.js";
26
- import {
27
- FindingsRegistry,
28
- OffensiveSecurityAgent,
29
- PLAN_MODE_TOOL_NAMES,
2
+ toGrpcPentestContext,
30
3
  grpcAuthorityTarget,
4
+ inProcessSubagentSpawner,
31
5
  pLimit,
32
- runWithBoundedConcurrency,
33
- toGrpcPentestContext
34
- } from "./cli-repbyhkk.js";
35
- import {
36
- createThreatModelPrompt
37
- } from "./cli-fw5r7pfj.js";
6
+ FindingsRegistry,
7
+ PLAN_MODE_TOOL_NAMES,
8
+ OffensiveSecurityAgent
9
+ } from "./cli-qkb3v2nw.js";
38
10
  import {
39
- createLogger,
40
11
  hasToolCall,
41
12
  init_dist,
13
+ newSessionId,
42
14
  init_id,
15
+ scopedLogger,
43
16
  init_lazyLogger,
44
17
  init_session,
45
- init_structured,
46
- newSessionId,
47
- scopedLogger
48
- } from "./cli-tkc598ey.js";
18
+ createLogger,
19
+ init_structured
20
+ } from "./cli-j1916nvj.js";
49
21
  import {
50
- __require
51
- } from "./cli-bc05qbss.js";
22
+ BlackboxAttackSurfaceAgent2
23
+ } from "./cli-8kkaeb70.js";
24
+ import {
25
+ TargetedPentestAgent2,
26
+ buildPentestSystemPrompt2
27
+ } from "./cli-4z46kyrk.js";
28
+ import {
29
+ buildPentestReport,
30
+ renderJson,
31
+ renderMarkdown,
32
+ REPORT_FILENAME_MD,
33
+ REPORT_FILENAME_JSON
34
+ } from "./cli-q45hcq3f.js";
35
+ import {
36
+ CodeAgent2
37
+ } from "./cli-gq5sk2j3.js";
38
+ import {
39
+ WHITEBOX_APPS_DISCOVERY_SYSTEM_PROMPT2,
40
+ WHITEBOX_ENDPOINT_DOCUMENTATION_SYSTEM_PROMPT,
41
+ WHITEBOX_DISCOVERY_SYSTEM_PROMPT2,
42
+ EndpointSchema2,
43
+ AppsDiscoveryResultSchema2,
44
+ DiscoverySummarySchema2
45
+ } from "./cli-gamfs2yq.js";
46
+ import {
47
+ createThreatModelPrompt
48
+ } from "./cli-q126f6ef.js";
52
49
 
53
50
  // src/core/workflows/pentest.ts
54
51
  init_dist();
55
- import { existsSync as existsSync13, readdirSync as readdirSync12, readFileSync as readFileSync11, writeFileSync as writeFileSync4 } from "node:fs";
56
- import { join as join18 } from "node:path";
52
+ import { existsSync as existsSync12, readdirSync as readdirSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync4 } from "node:fs";
53
+ import { join as join17 } from "node:path";
57
54
 
58
55
  // src/core/agents/specialized/pentest/planPrompt.ts
59
56
  var PLAN_PHASE_SYSTEM_PROMPT = `You are an expert penetration tester performing reconnaissance and planning.
@@ -126,9 +123,23 @@ function normalizeTokenUsage(value) {
126
123
  return {
127
124
  inputTokens,
128
125
  outputTokens,
126
+ cacheReadTokens: toNonNegativeInteger(value?.cacheReadTokens),
127
+ cacheWriteTokens: toNonNegativeInteger(value?.cacheWriteTokens),
129
128
  totalTokens: explicitTotal > 0 ? explicitTotal : derivedTotal
130
129
  };
131
130
  }
131
+ function normalizeContextUsage(value) {
132
+ if (typeof value !== "object" || value === null)
133
+ return;
134
+ const v = value;
135
+ if (typeof v.modelId !== "string" || v.modelId.length === 0)
136
+ return;
137
+ return {
138
+ modelId: v.modelId,
139
+ usedTokens: toNonNegativeInteger(v.usedTokens),
140
+ contextLimit: toNonNegativeInteger(v.contextLimit)
141
+ };
142
+ }
132
143
  function metricsPath(sessionRootPath) {
133
144
  return join(sessionRootPath, EXECUTION_METRICS_FILENAME);
134
145
  }
@@ -143,6 +154,7 @@ function readExecutionMetrics(sessionRootPath) {
143
154
  const parsed = JSON.parse(readFileSync(path, "utf-8"));
144
155
  return {
145
156
  tokenUsage: normalizeTokenUsage(parsed.tokenUsage),
157
+ contextUsage: normalizeContextUsage(parsed.contextUsage),
146
158
  runtime: typeof parsed.runtime === "string" ? parsed.runtime : undefined,
147
159
  elapsedSeconds: toNonNegativeInteger(parsed.elapsedSeconds) || undefined,
148
160
  updatedAt: typeof parsed.updatedAt === "string" ? parsed.updatedAt : new Date().toISOString()
@@ -167,10 +179,13 @@ function writeExecutionMetrics(input) {
167
179
  const nextTokenUsage = input.tokenUsage ? normalizeTokenUsage(input.tokenUsage) : existing?.tokenUsage ?? {
168
180
  inputTokens: 0,
169
181
  outputTokens: 0,
182
+ cacheReadTokens: 0,
183
+ cacheWriteTokens: 0,
170
184
  totalTokens: 0
171
185
  };
172
186
  const next = {
173
187
  tokenUsage: nextTokenUsage,
188
+ contextUsage: input.contextUsage ?? existing?.contextUsage,
174
189
  runtime: input.runtime ?? existing?.runtime,
175
190
  elapsedSeconds: input.elapsedSeconds ?? existing?.elapsedSeconds,
176
191
  updatedAt: new Date().toISOString()
@@ -467,10 +482,10 @@ function loadSubagents(rootPath) {
467
482
  const subagentsPath = join2(rootPath, SUBAGENTS_DIR);
468
483
  const manifestNameById = new Map;
469
484
  {
470
- const manifestPath2 = join2(rootPath, MANIFEST_FILE);
471
- if (existsSync2(manifestPath2)) {
485
+ const manifestPath = join2(rootPath, MANIFEST_FILE);
486
+ if (existsSync2(manifestPath)) {
472
487
  try {
473
- const manifest = JSON.parse(readFileSync2(manifestPath2, "utf-8"));
488
+ const manifest = JSON.parse(readFileSync2(manifestPath, "utf-8"));
474
489
  for (const entry of manifest)
475
490
  manifestNameById.set(entry.id, entry.name);
476
491
  } catch {}
@@ -620,7 +635,7 @@ init_lazyLogger();
620
635
 
621
636
  // src/core/workflows/whiteboxAttackSurface.ts
622
637
  import {
623
- existsSync as existsSync12,
638
+ existsSync as existsSync11,
624
639
  mkdirSync as mkdirSync2,
625
640
  readdirSync as readdirSync10,
626
641
  readFileSync as readFileSync9,
@@ -740,7 +755,7 @@ async function runEndpointDocumentationAgent(opts) {
740
755
  endpoint,
741
756
  frameworks
742
757
  });
743
- const agent = new CodeAgent({
758
+ const agent = new CodeAgent2({
744
759
  codebasePath,
745
760
  objective,
746
761
  system: WHITEBOX_ENDPOINT_DOCUMENTATION_SYSTEM_PROMPT,
@@ -757,7 +772,7 @@ async function runEndpointDocumentationAgent(opts) {
757
772
  openAIReasoningEffort,
758
773
  enableThinking,
759
774
  thinkingEffort,
760
- responseSchema: DiscoverySummarySchema,
775
+ responseSchema: DiscoverySummarySchema2,
761
776
  excludeTools: ["document_app", "list_files", "grep"],
762
777
  projectThreatModel
763
778
  });
@@ -783,12 +798,13 @@ async function runAppEndpointDocumentation(opts) {
783
798
  const { endpoints, ...shared } = opts;
784
799
  if (endpoints.length === 0)
785
800
  return;
801
+ const spawner = opts.subagentSpawner ?? inProcessSubagentSpawner;
786
802
  let anyFailed = false;
787
- await runWithBoundedConcurrency(endpoints, ENDPOINT_DOCUMENTATION_CONCURRENCY, async (endpoint) => {
803
+ await spawner.spawnMany(endpoints, async (endpoint) => {
788
804
  const ok = await runEndpointDocumentationAgent({ ...shared, endpoint });
789
805
  if (!ok)
790
806
  anyFailed = true;
791
- });
807
+ }, { concurrency: ENDPOINT_DOCUMENTATION_CONCURRENCY });
792
808
  if (anyFailed) {
793
809
  throw new Error(`One or more endpoint documentation agents failed for app ${opts.app.name}`);
794
810
  }
@@ -1055,12 +1071,12 @@ function compileMap() {
1055
1071
  fallback: []
1056
1072
  }
1057
1073
  }, index, length;
1058
- function collectType(type2) {
1059
- if (type2.multi) {
1060
- result.multi[type2.kind].push(type2);
1061
- result.multi["fallback"].push(type2);
1074
+ function collectType(type) {
1075
+ if (type.multi) {
1076
+ result.multi[type.kind].push(type);
1077
+ result.multi["fallback"].push(type);
1062
1078
  } else {
1063
- result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
1079
+ result[type.kind][type.tag] = result["fallback"][type.tag] = type;
1064
1080
  }
1065
1081
  }
1066
1082
  for (index = 0, length = arguments.length;index < length; index += 1) {
@@ -1071,7 +1087,7 @@ function compileMap() {
1071
1087
  function Schema$1(definition) {
1072
1088
  return this.extend(definition);
1073
1089
  }
1074
- Schema$1.prototype.extend = function extend2(definition) {
1090
+ Schema$1.prototype.extend = function extend(definition) {
1075
1091
  var implicit = [];
1076
1092
  var explicit = [];
1077
1093
  if (definition instanceof type) {
@@ -1478,9 +1494,9 @@ var BASE64_MAP = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
1478
1494
  function resolveYamlBinary(data) {
1479
1495
  if (data === null)
1480
1496
  return false;
1481
- var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
1497
+ var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
1482
1498
  for (idx = 0;idx < max; idx++) {
1483
- code = map2.indexOf(data.charAt(idx));
1499
+ code = map.indexOf(data.charAt(idx));
1484
1500
  if (code > 64)
1485
1501
  continue;
1486
1502
  if (code < 0)
@@ -1490,14 +1506,14 @@ function resolveYamlBinary(data) {
1490
1506
  return bitlen % 8 === 0;
1491
1507
  }
1492
1508
  function constructYamlBinary(data) {
1493
- var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
1509
+ var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map = BASE64_MAP, bits = 0, result = [];
1494
1510
  for (idx = 0;idx < max; idx++) {
1495
1511
  if (idx % 4 === 0 && idx) {
1496
1512
  result.push(bits >> 16 & 255);
1497
1513
  result.push(bits >> 8 & 255);
1498
1514
  result.push(bits & 255);
1499
1515
  }
1500
- bits = bits << 6 | map2.indexOf(input.charAt(idx));
1516
+ bits = bits << 6 | map.indexOf(input.charAt(idx));
1501
1517
  }
1502
1518
  tailbits = max % 4 * 6;
1503
1519
  if (tailbits === 0) {
@@ -1513,32 +1529,32 @@ function constructYamlBinary(data) {
1513
1529
  return new Uint8Array(result);
1514
1530
  }
1515
1531
  function representYamlBinary(object) {
1516
- var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
1532
+ var result = "", bits = 0, idx, tail, max = object.length, map = BASE64_MAP;
1517
1533
  for (idx = 0;idx < max; idx++) {
1518
1534
  if (idx % 3 === 0 && idx) {
1519
- result += map2[bits >> 18 & 63];
1520
- result += map2[bits >> 12 & 63];
1521
- result += map2[bits >> 6 & 63];
1522
- result += map2[bits & 63];
1535
+ result += map[bits >> 18 & 63];
1536
+ result += map[bits >> 12 & 63];
1537
+ result += map[bits >> 6 & 63];
1538
+ result += map[bits & 63];
1523
1539
  }
1524
1540
  bits = (bits << 8) + object[idx];
1525
1541
  }
1526
1542
  tail = max % 3;
1527
1543
  if (tail === 0) {
1528
- result += map2[bits >> 18 & 63];
1529
- result += map2[bits >> 12 & 63];
1530
- result += map2[bits >> 6 & 63];
1531
- result += map2[bits & 63];
1544
+ result += map[bits >> 18 & 63];
1545
+ result += map[bits >> 12 & 63];
1546
+ result += map[bits >> 6 & 63];
1547
+ result += map[bits & 63];
1532
1548
  } else if (tail === 2) {
1533
- result += map2[bits >> 10 & 63];
1534
- result += map2[bits >> 4 & 63];
1535
- result += map2[bits << 2 & 63];
1536
- result += map2[64];
1549
+ result += map[bits >> 10 & 63];
1550
+ result += map[bits >> 4 & 63];
1551
+ result += map[bits << 2 & 63];
1552
+ result += map[64];
1537
1553
  } else if (tail === 1) {
1538
- result += map2[bits >> 2 & 63];
1539
- result += map2[bits << 4 & 63];
1540
- result += map2[64];
1541
- result += map2[64];
1554
+ result += map[bits >> 2 & 63];
1555
+ result += map[bits << 4 & 63];
1556
+ result += map[64];
1557
+ result += map[64];
1542
1558
  }
1543
1559
  return result;
1544
1560
  }
@@ -1967,7 +1983,7 @@ function writeFoldedLines(state, count) {
1967
1983
  }
1968
1984
  }
1969
1985
  function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1970
- var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1986
+ var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, { kind: _kind, result: _result } = state, ch;
1971
1987
  ch = state.input.charCodeAt(state.position);
1972
1988
  if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
1973
1989
  return false;
@@ -2297,7 +2313,7 @@ function readBlockScalar(state, nodeIndent) {
2297
2313
  return true;
2298
2314
  }
2299
2315
  function readBlockSequence(state, nodeIndent) {
2300
- var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
2316
+ var _line, { tag: _tag, anchor: _anchor } = state, _result = [], following, detected = false, ch;
2301
2317
  if (state.firstTabInLine !== -1)
2302
2318
  return false;
2303
2319
  if (state.anchor !== null) {
@@ -2346,7 +2362,7 @@ function readBlockSequence(state, nodeIndent) {
2346
2362
  return false;
2347
2363
  }
2348
2364
  function readBlockMapping(state, nodeIndent, flowIndent) {
2349
- var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
2365
+ var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, { tag: _tag, anchor: _anchor } = state, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
2350
2366
  if (state.firstTabInLine !== -1)
2351
2367
  return false;
2352
2368
  if (state.anchor !== null) {
@@ -2568,7 +2584,7 @@ function readAlias(state) {
2568
2584
  return true;
2569
2585
  }
2570
2586
  function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2571
- var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
2587
+ var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type, flowIndent, blockIndent;
2572
2588
  if (state.listener !== null) {
2573
2589
  state.listener("open", state);
2574
2590
  }
@@ -2650,10 +2666,10 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
2650
2666
  throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
2651
2667
  }
2652
2668
  for (typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
2653
- type2 = state.implicitTypes[typeIndex];
2654
- if (type2.resolve(state.result)) {
2655
- state.result = type2.construct(state.result);
2656
- state.tag = type2.tag;
2669
+ type = state.implicitTypes[typeIndex];
2670
+ if (type.resolve(state.result)) {
2671
+ state.result = type.construct(state.result);
2672
+ state.tag = type.tag;
2657
2673
  if (state.anchor !== null) {
2658
2674
  state.anchorMap[state.anchor] = state.result;
2659
2675
  }
@@ -2662,27 +2678,27 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
2662
2678
  }
2663
2679
  } else if (state.tag !== "!") {
2664
2680
  if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
2665
- type2 = state.typeMap[state.kind || "fallback"][state.tag];
2681
+ type = state.typeMap[state.kind || "fallback"][state.tag];
2666
2682
  } else {
2667
- type2 = null;
2683
+ type = null;
2668
2684
  typeList = state.typeMap.multi[state.kind || "fallback"];
2669
2685
  for (typeIndex = 0, typeQuantity = typeList.length;typeIndex < typeQuantity; typeIndex += 1) {
2670
2686
  if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
2671
- type2 = typeList[typeIndex];
2687
+ type = typeList[typeIndex];
2672
2688
  break;
2673
2689
  }
2674
2690
  }
2675
2691
  }
2676
- if (!type2) {
2692
+ if (!type) {
2677
2693
  throwError(state, "unknown tag !<" + state.tag + ">");
2678
2694
  }
2679
- if (state.result !== null && type2.kind !== state.kind) {
2680
- throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
2695
+ if (state.result !== null && type.kind !== state.kind) {
2696
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2681
2697
  }
2682
- if (!type2.resolve(state.result, state.tag)) {
2698
+ if (!type.resolve(state.result, state.tag)) {
2683
2699
  throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
2684
2700
  } else {
2685
- state.result = type2.construct(state.result, state.tag);
2701
+ state.result = type.construct(state.result, state.tag);
2686
2702
  if (state.anchor !== null) {
2687
2703
  state.anchorMap[state.anchor] = state.result;
2688
2704
  }
@@ -2886,21 +2902,21 @@ var DEPRECATED_BOOLEANS_SYNTAX = [
2886
2902
  "OFF"
2887
2903
  ];
2888
2904
  var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
2889
- function compileStyleMap(schema2, map2) {
2890
- var result, keys, index, length, tag, style, type2;
2891
- if (map2 === null)
2905
+ function compileStyleMap(schema, map) {
2906
+ var result, keys, index, length, tag, style, type;
2907
+ if (map === null)
2892
2908
  return {};
2893
2909
  result = {};
2894
- keys = Object.keys(map2);
2910
+ keys = Object.keys(map);
2895
2911
  for (index = 0, length = keys.length;index < length; index += 1) {
2896
2912
  tag = keys[index];
2897
- style = String(map2[tag]);
2913
+ style = String(map[tag]);
2898
2914
  if (tag.slice(0, 2) === "!!") {
2899
2915
  tag = "tag:yaml.org,2002:" + tag.slice(2);
2900
2916
  }
2901
- type2 = schema2.compiledTypeMap["fallback"][tag];
2902
- if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
2903
- style = type2.styleAliases[style];
2917
+ type = schema.compiledTypeMap["fallback"][tag];
2918
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) {
2919
+ style = type.styleAliases[style];
2904
2920
  }
2905
2921
  result[tag] = style;
2906
2922
  }
@@ -2970,11 +2986,11 @@ function generateNextLine(state, level) {
2970
2986
  return `
2971
2987
  ` + common.repeat(" ", state.indent * level);
2972
2988
  }
2973
- function testImplicitResolving(state, str2) {
2974
- var index, length, type2;
2989
+ function testImplicitResolving(state, str) {
2990
+ var index, length, type;
2975
2991
  for (index = 0, length = state.implicitTypes.length;index < length; index += 1) {
2976
- type2 = state.implicitTypes[index];
2977
- if (type2.resolve(str2)) {
2992
+ type = state.implicitTypes[index];
2993
+ if (type.resolve(str)) {
2978
2994
  return true;
2979
2995
  }
2980
2996
  }
@@ -3020,7 +3036,7 @@ var STYLE_LITERAL = 3;
3020
3036
  var STYLE_FOLDED = 4;
3021
3037
  var STYLE_DOUBLE = 5;
3022
3038
  function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
3023
- var i2;
3039
+ var i;
3024
3040
  var char = 0;
3025
3041
  var prevChar = null;
3026
3042
  var hasLineBreak = false;
@@ -3029,8 +3045,8 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
3029
3045
  var previousLineBreak = -1;
3030
3046
  var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
3031
3047
  if (singleLineOnly || forceQuotes) {
3032
- for (i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
3033
- char = codePointAt(string, i2);
3048
+ for (i = 0;i < string.length; char >= 65536 ? i += 2 : i++) {
3049
+ char = codePointAt(string, i);
3034
3050
  if (!isPrintable(char)) {
3035
3051
  return STYLE_DOUBLE;
3036
3052
  }
@@ -3038,13 +3054,13 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
3038
3054
  prevChar = char;
3039
3055
  }
3040
3056
  } else {
3041
- for (i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
3042
- char = codePointAt(string, i2);
3057
+ for (i = 0;i < string.length; char >= 65536 ? i += 2 : i++) {
3058
+ char = codePointAt(string, i);
3043
3059
  if (char === CHAR_LINE_FEED) {
3044
3060
  hasLineBreak = true;
3045
3061
  if (shouldTrackWidth) {
3046
- hasFoldableLine = hasFoldableLine || i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
3047
- previousLineBreak = i2;
3062
+ hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
3063
+ previousLineBreak = i;
3048
3064
  }
3049
3065
  } else if (!isPrintable(char)) {
3050
3066
  return STYLE_DOUBLE;
@@ -3052,7 +3068,7 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
3052
3068
  plain = plain && isPlainSafe(char, prevChar, inblock);
3053
3069
  prevChar = char;
3054
3070
  }
3055
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
3071
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
3056
3072
  }
3057
3073
  if (!hasLineBreak && !hasFoldableLine) {
3058
3074
  if (plain && !forceQuotes && !testAmbiguousType(string)) {
@@ -3081,8 +3097,8 @@ function writeScalar(state, string, level, iskey, inblock) {
3081
3097
  var indent = state.indent * Math.max(1, level);
3082
3098
  var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
3083
3099
  var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
3084
- function testAmbiguity(string2) {
3085
- return testImplicitResolving(state, string2);
3100
+ function testAmbiguity(string) {
3101
+ return testImplicitResolving(state, string);
3086
3102
  }
3087
3103
  switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
3088
3104
  case STYLE_PLAIN:
@@ -3168,13 +3184,13 @@ function escapeString(string) {
3168
3184
  var result = "";
3169
3185
  var char = 0;
3170
3186
  var escapeSeq;
3171
- for (var i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
3172
- char = codePointAt(string, i2);
3187
+ for (var i = 0;i < string.length; char >= 65536 ? i += 2 : i++) {
3188
+ char = codePointAt(string, i);
3173
3189
  escapeSeq = ESCAPE_SEQUENCES[char];
3174
3190
  if (!escapeSeq && isPrintable(char)) {
3175
- result += string[i2];
3191
+ result += string[i];
3176
3192
  if (char >= 65536)
3177
- result += string[i2 + 1];
3193
+ result += string[i + 1];
3178
3194
  } else {
3179
3195
  result += escapeSeq || encodeHex(char);
3180
3196
  }
@@ -3296,28 +3312,28 @@ function writeBlockMapping(state, level, object, compact) {
3296
3312
  state.dump = _result || "{}";
3297
3313
  }
3298
3314
  function detectType(state, object, explicit) {
3299
- var _result, typeList, index, length, type2, style;
3315
+ var _result, typeList, index, length, type, style;
3300
3316
  typeList = explicit ? state.explicitTypes : state.implicitTypes;
3301
3317
  for (index = 0, length = typeList.length;index < length; index += 1) {
3302
- type2 = typeList[index];
3303
- if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
3318
+ type = typeList[index];
3319
+ if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
3304
3320
  if (explicit) {
3305
- if (type2.multi && type2.representName) {
3306
- state.tag = type2.representName(object);
3321
+ if (type.multi && type.representName) {
3322
+ state.tag = type.representName(object);
3307
3323
  } else {
3308
- state.tag = type2.tag;
3324
+ state.tag = type.tag;
3309
3325
  }
3310
3326
  } else {
3311
3327
  state.tag = "?";
3312
3328
  }
3313
- if (type2.represent) {
3314
- style = state.styleMap[type2.tag] || type2.defaultStyle;
3315
- if (_toString.call(type2.represent) === "[object Function]") {
3316
- _result = type2.represent(object, style);
3317
- } else if (_hasOwnProperty.call(type2.represent, style)) {
3318
- _result = type2.represent[style](object, style);
3329
+ if (type.represent) {
3330
+ style = state.styleMap[type.tag] || type.defaultStyle;
3331
+ if (_toString.call(type.represent) === "[object Function]") {
3332
+ _result = type.represent(object, style);
3333
+ } else if (_hasOwnProperty.call(type.represent, style)) {
3334
+ _result = type.represent[style](object, style);
3319
3335
  } else {
3320
- throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
3336
+ throw new exception("!<" + type.tag + '> tag resolver accepts not "' + style + '" style');
3321
3337
  }
3322
3338
  state.dump = _result;
3323
3339
  }
@@ -3332,13 +3348,13 @@ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
3332
3348
  if (!detectType(state, object, false)) {
3333
3349
  detectType(state, object, true);
3334
3350
  }
3335
- var type2 = _toString.call(state.dump);
3351
+ var type = _toString.call(state.dump);
3336
3352
  var inblock = block;
3337
3353
  var tagStr;
3338
3354
  if (block) {
3339
3355
  block = state.flowLevel < 0 || state.flowLevel > level;
3340
3356
  }
3341
- var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
3357
+ var objectOrArray = type === "[object Object]" || type === "[object Array]", duplicateIndex, duplicate;
3342
3358
  if (objectOrArray) {
3343
3359
  duplicateIndex = state.duplicates.indexOf(object);
3344
3360
  duplicate = duplicateIndex !== -1;
@@ -3352,7 +3368,7 @@ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
3352
3368
  if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
3353
3369
  state.usedDuplicates[duplicateIndex] = true;
3354
3370
  }
3355
- if (type2 === "[object Object]") {
3371
+ if (type === "[object Object]") {
3356
3372
  if (block && Object.keys(state.dump).length !== 0) {
3357
3373
  writeBlockMapping(state, level, state.dump, compact);
3358
3374
  if (duplicate) {
@@ -3364,7 +3380,7 @@ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
3364
3380
  state.dump = "&ref_" + duplicateIndex + " " + state.dump;
3365
3381
  }
3366
3382
  }
3367
- } else if (type2 === "[object Array]") {
3383
+ } else if (type === "[object Array]") {
3368
3384
  if (block && state.dump.length !== 0) {
3369
3385
  if (state.noArrayIndent && !isblockseq && level > 0) {
3370
3386
  writeBlockSequence(state, level - 1, state.dump, compact);
@@ -3380,16 +3396,16 @@ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
3380
3396
  state.dump = "&ref_" + duplicateIndex + " " + state.dump;
3381
3397
  }
3382
3398
  }
3383
- } else if (type2 === "[object String]") {
3399
+ } else if (type === "[object String]") {
3384
3400
  if (state.tag !== "?") {
3385
3401
  writeScalar(state, state.dump, level, iskey, inblock);
3386
3402
  }
3387
- } else if (type2 === "[object Undefined]") {
3403
+ } else if (type === "[object Undefined]") {
3388
3404
  return false;
3389
3405
  } else {
3390
3406
  if (state.skipInvalid)
3391
3407
  return false;
3392
- throw new exception("unacceptable kind of an object to dump " + type2);
3408
+ throw new exception("unacceptable kind of an object to dump " + type);
3393
3409
  }
3394
3410
  if (state.tag !== null && state.tag !== "?") {
3395
3411
  tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
@@ -3820,8 +3836,8 @@ function normalizePath(path) {
3820
3836
  }
3821
3837
  function lineNumber(content, offset) {
3822
3838
  let count = 1;
3823
- for (let i2 = 0;i2 < offset && i2 < content.length; i2++) {
3824
- if (content[i2] === `
3839
+ for (let i = 0;i < offset && i < content.length; i++) {
3840
+ if (content[i] === `
3825
3841
  `)
3826
3842
  count++;
3827
3843
  }
@@ -3829,10 +3845,10 @@ function lineNumber(content, offset) {
3829
3845
  }
3830
3846
  function buildLineIndex(content) {
3831
3847
  const offsets = [0];
3832
- for (let i2 = 0;i2 < content.length; i2++) {
3833
- if (content[i2] === `
3848
+ for (let i = 0;i < content.length; i++) {
3849
+ if (content[i] === `
3834
3850
  `)
3835
- offsets.push(i2 + 1);
3851
+ offsets.push(i + 1);
3836
3852
  }
3837
3853
  return {
3838
3854
  lineAt(offset) {
@@ -4047,8 +4063,8 @@ var django = {
4047
4063
  const pyFiles = ctx.iterFiles(PY_EXTS3);
4048
4064
  const dirOf2 = (f) => {
4049
4065
  const norm = f.replace(/\\/g, "/");
4050
- const i2 = norm.lastIndexOf("/");
4051
- return i2 < 0 ? "" : norm.slice(0, i2);
4066
+ const i = norm.lastIndexOf("/");
4067
+ return i < 0 ? "" : norm.slice(0, i);
4052
4068
  };
4053
4069
  const classesByDir = /* @__PURE__ */ new Map;
4054
4070
  const funcsByDir = /* @__PURE__ */ new Map;
@@ -4242,67 +4258,67 @@ var PAGE_RENDER_RE = /\bres\s*\.\s*render\s*\(/;
4242
4258
  var PAGE_SENDFILE_RE = /\bres\s*\.\s*sendFile\s*\(/;
4243
4259
  function findMatchingParen(content, start) {
4244
4260
  let depth = 0;
4245
- let i2 = start;
4261
+ let i = start;
4246
4262
  const len = content.length;
4247
- while (i2 < len) {
4248
- const ch = content[i2];
4249
- if (ch === "/" && content[i2 + 1] === "/") {
4263
+ while (i < len) {
4264
+ const ch = content[i];
4265
+ if (ch === "/" && content[i + 1] === "/") {
4250
4266
  const nl = content.indexOf(`
4251
- `, i2);
4267
+ `, i);
4252
4268
  if (nl === -1)
4253
4269
  return -1;
4254
- i2 = nl + 1;
4270
+ i = nl + 1;
4255
4271
  continue;
4256
4272
  }
4257
- if (ch === "/" && content[i2 + 1] === "*") {
4258
- const end = content.indexOf("*/", i2 + 2);
4273
+ if (ch === "/" && content[i + 1] === "*") {
4274
+ const end = content.indexOf("*/", i + 2);
4259
4275
  if (end === -1)
4260
4276
  return -1;
4261
- i2 = end + 2;
4277
+ i = end + 2;
4262
4278
  continue;
4263
4279
  }
4264
4280
  if (ch === "'" || ch === '"') {
4265
- i2++;
4266
- while (i2 < len) {
4267
- const c = content[i2];
4281
+ i++;
4282
+ while (i < len) {
4283
+ const c = content[i];
4268
4284
  if (c === "\\") {
4269
- i2 += 2;
4285
+ i += 2;
4270
4286
  continue;
4271
4287
  }
4272
4288
  if (c === ch) {
4273
- i2++;
4289
+ i++;
4274
4290
  break;
4275
4291
  }
4276
- i2++;
4292
+ i++;
4277
4293
  }
4278
4294
  continue;
4279
4295
  }
4280
4296
  if (ch === "`") {
4281
- i2++;
4282
- while (i2 < len) {
4283
- const c = content[i2];
4297
+ i++;
4298
+ while (i < len) {
4299
+ const c = content[i];
4284
4300
  if (c === "\\") {
4285
- i2 += 2;
4301
+ i += 2;
4286
4302
  continue;
4287
4303
  }
4288
4304
  if (c === "`") {
4289
- i2++;
4305
+ i++;
4290
4306
  break;
4291
4307
  }
4292
- if (c === "$" && content[i2 + 1] === "{") {
4293
- i2 += 2;
4308
+ if (c === "$" && content[i + 1] === "{") {
4309
+ i += 2;
4294
4310
  let d = 1;
4295
- while (i2 < len && d > 0) {
4296
- const cc = content[i2];
4311
+ while (i < len && d > 0) {
4312
+ const cc = content[i];
4297
4313
  if (cc === "{")
4298
4314
  d++;
4299
4315
  else if (cc === "}")
4300
4316
  d--;
4301
- i2++;
4317
+ i++;
4302
4318
  }
4303
4319
  continue;
4304
4320
  }
4305
- i2++;
4321
+ i++;
4306
4322
  }
4307
4323
  continue;
4308
4324
  }
@@ -4311,9 +4327,9 @@ function findMatchingParen(content, start) {
4311
4327
  else if (ch === ")" || ch === "]" || ch === "}") {
4312
4328
  depth--;
4313
4329
  if (depth === 0 && ch === ")")
4314
- return i2;
4330
+ return i;
4315
4331
  }
4316
- i2++;
4332
+ i++;
4317
4333
  }
4318
4334
  return -1;
4319
4335
  }
@@ -4474,47 +4490,47 @@ var express = {
4474
4490
  };
4475
4491
  function maskComments(src) {
4476
4492
  let out = "";
4477
- let i2 = 0;
4493
+ let i = 0;
4478
4494
  const n = src.length;
4479
- while (i2 < n) {
4480
- const c = src[i2];
4495
+ while (i < n) {
4496
+ const c = src[i];
4481
4497
  if (c === '"' || c === "'" || c === "`") {
4482
4498
  out += c;
4483
- i2++;
4484
- while (i2 < n) {
4485
- if (src[i2] === "\\" && i2 + 1 < n) {
4486
- out += src[i2] + src[i2 + 1];
4487
- i2 += 2;
4499
+ i++;
4500
+ while (i < n) {
4501
+ if (src[i] === "\\" && i + 1 < n) {
4502
+ out += src[i] + src[i + 1];
4503
+ i += 2;
4488
4504
  continue;
4489
4505
  }
4490
- out += src[i2];
4491
- const done = src[i2] === c;
4492
- i2++;
4506
+ out += src[i];
4507
+ const done = src[i] === c;
4508
+ i++;
4493
4509
  if (done)
4494
4510
  break;
4495
4511
  }
4496
- } else if (c === "/" && src[i2 + 1] === "/") {
4497
- while (i2 < n && src[i2] !== `
4512
+ } else if (c === "/" && src[i + 1] === "/") {
4513
+ while (i < n && src[i] !== `
4498
4514
  `) {
4499
4515
  out += " ";
4500
- i2++;
4516
+ i++;
4501
4517
  }
4502
- } else if (c === "/" && src[i2 + 1] === "*") {
4518
+ } else if (c === "/" && src[i + 1] === "*") {
4503
4519
  out += " ";
4504
- i2 += 2;
4505
- while (i2 < n && !(src[i2] === "*" && src[i2 + 1] === "/")) {
4506
- out += src[i2] === `
4520
+ i += 2;
4521
+ while (i < n && !(src[i] === "*" && src[i + 1] === "/")) {
4522
+ out += src[i] === `
4507
4523
  ` ? `
4508
4524
  ` : " ";
4509
- i2++;
4525
+ i++;
4510
4526
  }
4511
- if (i2 < n) {
4527
+ if (i < n) {
4512
4528
  out += " ";
4513
- i2 += 2;
4529
+ i += 2;
4514
4530
  }
4515
4531
  } else {
4516
4532
  out += c;
4517
- i2++;
4533
+ i++;
4518
4534
  }
4519
4535
  }
4520
4536
  return out;
@@ -4977,8 +4993,8 @@ var GO_EXTS = [".go"];
4977
4993
  var GO_GROUP_RE = /(\w+)\s*[:=]+\s*(\w+)\.Group\s*\(\s*['"]([^'"]+)['"]/g;
4978
4994
  var dirOf = (f) => {
4979
4995
  const norm = f.replace(/\\/g, "/");
4980
- const i2 = norm.lastIndexOf("/");
4981
- return i2 < 0 ? "" : norm.slice(0, i2);
4996
+ const i = norm.lastIndexOf("/");
4997
+ return i < 0 ? "" : norm.slice(0, i);
4982
4998
  };
4983
4999
  var GORILLA_WS_IMPORT_RE = /["']github\.com\/gorilla\/websocket["']/;
4984
5000
  var UPGRADE_CALL_RE = /\.\s*Upgrade\s*\(/;
@@ -4992,26 +5008,26 @@ function findWebsocketHandlers(ctx, goFiles) {
4992
5008
  if (!GORILLA_WS_IMPORT_RE.test(content))
4993
5009
  continue;
4994
5010
  const dir = dirOf(f);
4995
- const set2 = byDir.get(dir) ?? /* @__PURE__ */ new Set;
5011
+ const set = byDir.get(dir) ?? /* @__PURE__ */ new Set;
4996
5012
  for (const m of content.matchAll(funcRe)) {
4997
5013
  const name = m[1];
4998
5014
  const bodyStart = m.index + m[0].length;
4999
5015
  let depth = 1;
5000
- let i2 = bodyStart;
5016
+ let i = bodyStart;
5001
5017
  const len = content.length;
5002
- while (i2 < len && depth > 0) {
5003
- const ch = content[i2];
5018
+ while (i < len && depth > 0) {
5019
+ const ch = content[i];
5004
5020
  if (ch === "{")
5005
5021
  depth++;
5006
5022
  else if (ch === "}")
5007
5023
  depth--;
5008
- i2++;
5024
+ i++;
5009
5025
  }
5010
- const body = content.slice(bodyStart, i2 - 1);
5026
+ const body = content.slice(bodyStart, i - 1);
5011
5027
  if (UPGRADE_CALL_RE.test(body))
5012
- set2.add(name);
5028
+ set.add(name);
5013
5029
  }
5014
- byDir.set(dir, set2);
5030
+ byDir.set(dir, set);
5015
5031
  }
5016
5032
  return byDir;
5017
5033
  }
@@ -5392,8 +5408,8 @@ var rails = {
5392
5408
  const nsStack = [];
5393
5409
  let depth = 0;
5394
5410
  const prefixAtLine = new Array(sourceLines.length + 1).fill("");
5395
- for (let i2 = 0;i2 < sourceLines.length; i2++) {
5396
- const line = sourceLines[i2];
5411
+ for (let i = 0;i < sourceLines.length; i++) {
5412
+ const line = sourceLines[i];
5397
5413
  const code = line.replace(/#.*$/, "");
5398
5414
  const nsM = namespaceLineRe.exec(code);
5399
5415
  if (nsM) {
@@ -5410,7 +5426,7 @@ var rails = {
5410
5426
  if (doMatches)
5411
5427
  depth++;
5412
5428
  const prefix = nsStack.length ? "/" + nsStack.map((n) => n.name).join("/") : "";
5413
- prefixAtLine[i2 + 1] = prefix;
5429
+ prefixAtLine[i + 1] = prefix;
5414
5430
  }
5415
5431
  const prefixAt = (offset) => {
5416
5432
  const ln = lines.lineAt(offset);
@@ -5678,15 +5694,15 @@ function splitTopLevel(s) {
5678
5694
  const parts = [];
5679
5695
  let depth = 0;
5680
5696
  let start = 0;
5681
- for (let i2 = 0;i2 < s.length; i2++) {
5682
- const c = s[i2];
5697
+ for (let i = 0;i < s.length; i++) {
5698
+ const c = s[i];
5683
5699
  if (c === "<" || c === "{" || c === "[" || c === "(")
5684
5700
  depth++;
5685
5701
  else if (c === ">" || c === "}" || c === "]" || c === ")")
5686
5702
  depth--;
5687
5703
  else if (c === "," && depth === 0) {
5688
- parts.push(s.slice(start, i2));
5689
- start = i2 + 1;
5704
+ parts.push(s.slice(start, i));
5705
+ start = i + 1;
5690
5706
  }
5691
5707
  }
5692
5708
  parts.push(s.slice(start));
@@ -5694,14 +5710,14 @@ function splitTopLevel(s) {
5694
5710
  }
5695
5711
  function findTopLevelChar(s, targets) {
5696
5712
  let depth = 0;
5697
- for (let i2 = 0;i2 < s.length; i2++) {
5698
- const c = s[i2];
5713
+ for (let i = 0;i < s.length; i++) {
5714
+ const c = s[i];
5699
5715
  if (c === "<" || c === "{" || c === "[" || c === "(")
5700
5716
  depth++;
5701
5717
  else if (c === ">" || c === "}" || c === "]" || c === ")")
5702
5718
  depth--;
5703
5719
  else if (depth === 0 && targets.includes(c))
5704
- return i2;
5720
+ return i;
5705
5721
  }
5706
5722
  return -1;
5707
5723
  }
@@ -5725,14 +5741,14 @@ function parseParams(funcParams) {
5725
5741
  if (trimmed.startsWith("{")) {
5726
5742
  let depth = 0;
5727
5743
  let close = -1;
5728
- for (let i2 = 0;i2 < trimmed.length; i2++) {
5729
- const c = trimmed[i2];
5744
+ for (let i = 0;i < trimmed.length; i++) {
5745
+ const c = trimmed[i];
5730
5746
  if (c === "{")
5731
5747
  depth++;
5732
5748
  else if (c === "}") {
5733
5749
  depth--;
5734
5750
  if (depth === 0) {
5735
- close = i2;
5751
+ close = i;
5736
5752
  break;
5737
5753
  }
5738
5754
  }
@@ -5864,11 +5880,11 @@ var openapi = {
5864
5880
  for (const p of allParams) {
5865
5881
  if (!p || typeof p !== "object")
5866
5882
  continue;
5867
- const schema2 = p.schema;
5883
+ const schema = p.schema;
5868
5884
  params.push({
5869
5885
  name: p.name ?? "?",
5870
5886
  location: p.in ?? "query",
5871
- type: schema2?.type,
5887
+ type: schema?.type,
5872
5888
  required: p.required ?? false
5873
5889
  });
5874
5890
  }
@@ -5937,46 +5953,46 @@ function makeConnectResolver(ctx) {
5937
5953
  }
5938
5954
  function stripComments(src) {
5939
5955
  let out = "";
5940
- for (let i2 = 0;i2 < src.length; ) {
5941
- const c = src[i2];
5956
+ for (let i = 0;i < src.length; ) {
5957
+ const c = src[i];
5942
5958
  if (c === '"' || c === "'") {
5943
5959
  out += c;
5944
- i2++;
5945
- while (i2 < src.length && src[i2] !== c) {
5946
- if (src[i2] === "\\" && i2 + 1 < src.length) {
5947
- out += src[i2] + src[i2 + 1];
5948
- i2 += 2;
5960
+ i++;
5961
+ while (i < src.length && src[i] !== c) {
5962
+ if (src[i] === "\\" && i + 1 < src.length) {
5963
+ out += src[i] + src[i + 1];
5964
+ i += 2;
5949
5965
  } else {
5950
- out += src[i2];
5951
- i2++;
5966
+ out += src[i];
5967
+ i++;
5952
5968
  }
5953
5969
  }
5954
- if (i2 < src.length) {
5955
- out += src[i2];
5956
- i2++;
5970
+ if (i < src.length) {
5971
+ out += src[i];
5972
+ i++;
5957
5973
  }
5958
- } else if (c === "/" && src[i2 + 1] === "/") {
5959
- while (i2 < src.length && src[i2] !== `
5974
+ } else if (c === "/" && src[i + 1] === "/") {
5975
+ while (i < src.length && src[i] !== `
5960
5976
  `) {
5961
5977
  out += " ";
5962
- i2++;
5978
+ i++;
5963
5979
  }
5964
- } else if (c === "/" && src[i2 + 1] === "*") {
5980
+ } else if (c === "/" && src[i + 1] === "*") {
5965
5981
  out += " ";
5966
- i2 += 2;
5967
- while (i2 < src.length && !(src[i2] === "*" && src[i2 + 1] === "/")) {
5968
- out += src[i2] === `
5982
+ i += 2;
5983
+ while (i < src.length && !(src[i] === "*" && src[i + 1] === "/")) {
5984
+ out += src[i] === `
5969
5985
  ` ? `
5970
5986
  ` : " ";
5971
- i2++;
5987
+ i++;
5972
5988
  }
5973
- if (i2 < src.length) {
5989
+ if (i < src.length) {
5974
5990
  out += " ";
5975
- i2 += 2;
5991
+ i += 2;
5976
5992
  }
5977
5993
  } else {
5978
5994
  out += c;
5979
- i2++;
5995
+ i++;
5980
5996
  }
5981
5997
  }
5982
5998
  return out;
@@ -6105,33 +6121,33 @@ function inferServiceType(absDir) {
6105
6121
  try {
6106
6122
  const content = readFileSync42(join10(absDir, "package.json"), "utf-8");
6107
6123
  const lower = content.toLowerCase();
6108
- for (const [dep, type2] of PKG_DEP_TO_TYPE) {
6124
+ for (const [dep, type] of PKG_DEP_TO_TYPE) {
6109
6125
  if (lower.includes(`"${dep}"`))
6110
- return type2;
6126
+ return type;
6111
6127
  }
6112
6128
  return "generic";
6113
6129
  } catch {}
6114
6130
  try {
6115
6131
  const content = readFileSync42(join10(absDir, "go.mod"), "utf-8");
6116
- for (const [dep, type2] of GO_DEP_TO_TYPE) {
6132
+ for (const [dep, type] of GO_DEP_TO_TYPE) {
6117
6133
  if (content.includes(dep))
6118
- return type2;
6134
+ return type;
6119
6135
  }
6120
6136
  return "generic";
6121
6137
  } catch {}
6122
6138
  try {
6123
6139
  const content = readFileSync42(join10(absDir, "Cargo.toml"), "utf-8");
6124
- for (const [dep, type2] of CARGO_DEP_TO_TYPE) {
6140
+ for (const [dep, type] of CARGO_DEP_TO_TYPE) {
6125
6141
  if (content.includes(dep))
6126
- return type2;
6142
+ return type;
6127
6143
  }
6128
6144
  return "generic";
6129
6145
  } catch {}
6130
6146
  try {
6131
6147
  const content = readFileSync42(join10(absDir, "requirements.txt"), "utf-8");
6132
- for (const [dep, type2] of PY_DEP_TO_TYPE) {
6148
+ for (const [dep, type] of PY_DEP_TO_TYPE) {
6133
6149
  if (content.includes(dep))
6134
- return type2;
6150
+ return type;
6135
6151
  }
6136
6152
  return "generic";
6137
6153
  } catch {}
@@ -6947,10 +6963,10 @@ function mapAppWithSurface(appPath, repoRoot, options) {
6947
6963
  }
6948
6964
  const narrow = map2(absApp, { includeInternal: false });
6949
6965
  if (narrow.frameworks.length > 0 && narrow.endpoints.all.length > 0) {
6950
- const rebased2 = rebaseFileToRepoRoot(narrow.endpoints.all, absApp, absRoot);
6966
+ const rebased = rebaseFileToRepoRoot(narrow.endpoints.all, absApp, absRoot);
6951
6967
  return {
6952
6968
  mode: "surface",
6953
- endpoints: consolidateBySameRoute(rebased2),
6969
+ endpoints: consolidateBySameRoute(rebased),
6954
6970
  frameworks: narrow.frameworks
6955
6971
  };
6956
6972
  }
@@ -7018,15 +7034,17 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
7018
7034
  projectThreatModel,
7019
7035
  environments,
7020
7036
  surfaceIntegrationEnabled = true,
7021
- maxConcurrentAgents = MAX_CONCURRENT_AGENTS
7037
+ maxConcurrentAgents = MAX_CONCURRENT_AGENTS,
7038
+ subagentSpawner
7022
7039
  } = input;
7040
+ const spawner = subagentSpawner ?? inProcessSubagentSpawner;
7023
7041
  const agentSlots = pLimit(Math.max(1, maxConcurrentAgents));
7024
7042
  const agentLimiter = (fn) => agentSlots(fn);
7025
7043
  const WORKFLOW_UMBRELLA_ID = newSessionId();
7026
- const appsAgent = new CodeAgent({
7044
+ const appsAgent = new CodeAgent2({
7027
7045
  codebasePath,
7028
7046
  objective: buildAppsDiscoveryObjective(codebasePath, domains, environments),
7029
- system: WHITEBOX_APPS_DISCOVERY_SYSTEM_PROMPT,
7047
+ system: WHITEBOX_APPS_DISCOVERY_SYSTEM_PROMPT2,
7030
7048
  model,
7031
7049
  session,
7032
7050
  authConfig,
@@ -7040,7 +7058,7 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
7040
7058
  openAIReasoningEffort,
7041
7059
  enableThinking,
7042
7060
  thinkingEffort,
7043
- responseSchema: AppsDiscoveryResultSchema,
7061
+ responseSchema: AppsDiscoveryResultSchema2,
7044
7062
  projectThreatModel,
7045
7063
  excludeTools: ["document_endpoint"]
7046
7064
  });
@@ -7104,20 +7122,20 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
7104
7122
  parentSubagentId: WORKFLOW_UMBRELLA_ID
7105
7123
  });
7106
7124
  }
7107
- const spawnDiscoveryAgent = async (app, type2, objective) => {
7125
+ const spawnDiscoveryAgent = async (app, type, objective) => {
7108
7126
  const subagentId = newSessionId();
7109
7127
  const appNodeId = appNodeIdFor(app.name);
7110
- log4.debug(`Phase 2: spawning agent id="${subagentId}" parent="${appNodeId}" (app="${app.name}", type=${type2}, appType=${app.type})`);
7128
+ log4.debug(`Phase 2: spawning agent id="${subagentId}" parent="${appNodeId}" (app="${app.name}", type=${type}, appType=${app.type})`);
7111
7129
  eventBus?.emit("subagent-spawn", {
7112
7130
  subagentId,
7113
- name: TASK_TYPE_LABELS[type2],
7114
- input: { app: app.name, type: type2 },
7131
+ name: TASK_TYPE_LABELS[type],
7132
+ input: { app: app.name, type },
7115
7133
  parentSubagentId: appNodeId
7116
7134
  });
7117
- const agent = new CodeAgent({
7135
+ const agent = new CodeAgent2({
7118
7136
  codebasePath,
7119
7137
  objective,
7120
- system: WHITEBOX_DISCOVERY_SYSTEM_PROMPT,
7138
+ system: WHITEBOX_DISCOVERY_SYSTEM_PROMPT2,
7121
7139
  model,
7122
7140
  session,
7123
7141
  authConfig,
@@ -7125,13 +7143,13 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
7125
7143
  attackSurfaceRegistry,
7126
7144
  eventBus,
7127
7145
  subagentId,
7128
- subagentName: TASK_TYPE_LABELS[type2],
7146
+ subagentName: TASK_TYPE_LABELS[type],
7129
7147
  onStepFinish: (event) => onStepFinish?.(event),
7130
7148
  onCacheMetrics,
7131
7149
  openAIReasoningEffort,
7132
7150
  enableThinking,
7133
7151
  thinkingEffort,
7134
- responseSchema: DiscoverySummarySchema,
7152
+ responseSchema: DiscoverySummarySchema2,
7135
7153
  excludeTools: ["document_app"],
7136
7154
  projectThreatModel
7137
7155
  });
@@ -7156,7 +7174,7 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
7156
7174
  const spawnPagesAgent = (app) => spawnDiscoveryAgent(app, "pages", buildPagesDiscoveryObjective(codebasePath, app));
7157
7175
  const spawnApiEndpointsAgent = (app) => spawnDiscoveryAgent(app, "apiEndpoints", buildApiEndpointsDiscoveryObjective(codebasePath, app));
7158
7176
  const spawnCloudResourceAgent = (app) => spawnDiscoveryAgent(app, "cloudResourceEndpoints", buildCloudResourceEndpointsObjective(codebasePath, app, environments));
7159
- await runWithBoundedConcurrency(appsResult.apps, DEFAULT_CONCURRENCY, async (app) => {
7177
+ await spawner.spawnMany(appsResult.apps, async (app) => {
7160
7178
  const appNodeId = appNodeIdFor(app.name);
7161
7179
  try {
7162
7180
  if (NON_SERVICE_TYPES.includes(app.type)) {
@@ -7189,7 +7207,8 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
7189
7207
  thinkingEffort,
7190
7208
  projectThreatModel,
7191
7209
  parentSubagentId: appNodeId,
7192
- agentLimiter
7210
+ agentLimiter,
7211
+ subagentSpawner
7193
7212
  });
7194
7213
  } else {
7195
7214
  log4.debug(`${app.name}: fallback (${surfaceResult.reason})`);
@@ -7215,7 +7234,7 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
7215
7234
  appName: app.name
7216
7235
  });
7217
7236
  }
7218
- });
7237
+ }, { concurrency: DEFAULT_CONCURRENCY });
7219
7238
  eventBus?.emit("subagent-complete", {
7220
7239
  subagentId: WORKFLOW_UMBRELLA_ID,
7221
7240
  status: "completed"
@@ -7248,7 +7267,7 @@ async function runWhiteboxAttackSurfaceWorkflow(input) {
7248
7267
  function readAppsFromAssetsDirectory(assetsPath, appsDiscovery) {
7249
7268
  const repoType = appsDiscovery?.repoType ?? "unknown";
7250
7269
  const packageManager = appsDiscovery?.packageManager ?? "unknown";
7251
- if (!existsSync12(assetsPath)) {
7270
+ if (!existsSync11(assetsPath)) {
7252
7271
  log4.debug(`readAssets: assets directory does not exist: ${assetsPath}`);
7253
7272
  return { apps: [], repoType, packageManager };
7254
7273
  }
@@ -7263,7 +7282,7 @@ function readAppsFromAssetsDirectory(assetsPath, appsDiscovery) {
7263
7282
  }
7264
7283
  const appJsonPath = join16(entryPath, "app.json");
7265
7284
  let metadata;
7266
- if (existsSync12(appJsonPath)) {
7285
+ if (existsSync11(appJsonPath)) {
7267
7286
  try {
7268
7287
  metadata = JSON.parse(readFileSync9(appJsonPath, "utf-8"));
7269
7288
  } catch {
@@ -7283,16 +7302,16 @@ function readAppsFromAssetsDirectory(assetsPath, appsDiscovery) {
7283
7302
  try {
7284
7303
  const raw = readFileSync9(join16(entryPath, file), "utf-8");
7285
7304
  const data = JSON.parse(raw);
7286
- const endpoint2 = assetRecordToEndpoint(data);
7287
- if (!endpoint2) {
7305
+ const endpoint = assetRecordToEndpoint(data);
7306
+ if (!endpoint) {
7288
7307
  log4.debug(`readAssets: ${file}: failed schema validation (assetRecordToEndpoint returned null)`);
7289
7308
  parseFailed++;
7290
7309
  continue;
7291
7310
  }
7292
7311
  if (isPageEndpoint(data)) {
7293
- pages.push(endpoint2);
7312
+ pages.push(endpoint);
7294
7313
  } else {
7295
- apiEndpoints.push(endpoint2);
7314
+ apiEndpoints.push(endpoint);
7296
7315
  }
7297
7316
  } catch {
7298
7317
  log4.warn(`readAssets: skipping unreadable asset file: ${entry}/${file}`);
@@ -7317,7 +7336,7 @@ function assetRecordToEndpoint(record) {
7317
7336
  const method = Array.isArray(rawMethod) ? rawMethod.join(", ") : rawMethod ?? "UNKNOWN";
7318
7337
  const path = record.routePath;
7319
7338
  const file = record.file ?? "";
7320
- const parsed = EndpointSchema.safeParse({
7339
+ const parsed = EndpointSchema2.safeParse({
7321
7340
  method,
7322
7341
  path,
7323
7342
  handler: record.handler,
@@ -7639,17 +7658,7 @@ When finished, call \`response\` with a summary of how many entry points you doc
7639
7658
  // src/core/workflows/pentest.ts
7640
7659
  var log5 = scopedLogger(() => createLogger("pentest-swarm"));
7641
7660
  var DEFAULT_CONCURRENCY2 = 10;
7642
- function addUsageTotals(totals, usage) {
7643
- if (!usage)
7644
- return;
7645
- const inputTokens = usage.inputTokens ?? 0;
7646
- const outputTokens = usage.outputTokens ?? 0;
7647
- const totalTokens = usage.totalTokens ?? inputTokens + outputTokens;
7648
- totals.inputTokens += inputTokens;
7649
- totals.outputTokens += outputTokens;
7650
- totals.totalTokens += totalTokens;
7651
- }
7652
- async function runPentestSwarm(input) {
7661
+ async function runPentestSwarm2(input) {
7653
7662
  const {
7654
7663
  targets,
7655
7664
  model,
@@ -7661,17 +7670,23 @@ async function runPentestSwarm(input) {
7661
7670
  onError,
7662
7671
  concurrency = DEFAULT_CONCURRENCY2,
7663
7672
  onStepFinish,
7673
+ onCacheMetrics,
7664
7674
  enableThinking,
7665
7675
  thinkingEffort,
7666
7676
  openAIReasoningEffort,
7667
- display
7677
+ display,
7678
+ subagentSpawner,
7679
+ languageModelMiddleware,
7680
+ usageRecorder,
7681
+ streamIdFactory
7668
7682
  } = input;
7683
+ const spawner = subagentSpawner ?? inProcessSubagentSpawner;
7669
7684
  const completedIds = getCompletedAgentIds(session);
7670
7685
  const existingManifest = readAgentManifest(session);
7671
7686
  const freshEntries = buildManifestEntries(targets);
7672
7687
  const manifestEntries = reconcileManifestOnResume(existingManifest, freshEntries);
7673
7688
  writeAgentManifest(session, manifestEntries);
7674
- const results = await runWithBoundedConcurrency(targets, concurrency, async (target, index) => {
7689
+ const results = await spawner.spawnMany(targets, async (target, index) => {
7675
7690
  const entry = manifestEntries[index];
7676
7691
  const subagentId = entry.id;
7677
7692
  const subagentName = target.name ?? entry.name;
@@ -7698,7 +7713,7 @@ async function runPentestSwarm(input) {
7698
7713
  input: { target: target.target, objectives: target.objectives },
7699
7714
  parentSubagentId: subagentId
7700
7715
  });
7701
- const executionTasksDir = join18(session.rootPath, "subagents", `${subagentId}-tasks`);
7716
+ const executionTasksDir = join17(session.rootPath, "subagents", `${subagentId}-tasks`);
7702
7717
  const planAgent = new OffensiveSecurityAgent({
7703
7718
  system: PLAN_PHASE_SYSTEM_PROMPT,
7704
7719
  prompt: buildPlanPrompt(target.target, target.objectives, target.grpc),
@@ -7717,10 +7732,16 @@ async function runPentestSwarm(input) {
7717
7732
  tasksDir: executionTasksDir,
7718
7733
  planSubagentId: subagentId,
7719
7734
  eventBus,
7735
+ onStepFinish,
7736
+ onCacheMetrics,
7720
7737
  enableThinking,
7721
7738
  thinkingEffort,
7722
7739
  openAIReasoningEffort,
7723
- display
7740
+ display,
7741
+ subagentSpawner: spawner,
7742
+ languageModelMiddleware,
7743
+ usageRecorder,
7744
+ streamIdFactory
7724
7745
  });
7725
7746
  await planAgent.consume();
7726
7747
  eventBus?.emit("subagent-complete", {
@@ -7740,7 +7761,7 @@ async function runPentestSwarm(input) {
7740
7761
  const objectiveStr = target.objectives.join("; ");
7741
7762
  let agent;
7742
7763
  try {
7743
- agent = new TargetedPentestAgent({
7764
+ agent = new TargetedPentestAgent2({
7744
7765
  target: target.target,
7745
7766
  grpc: target.grpc,
7746
7767
  objectives: target.objectives,
@@ -7750,6 +7771,8 @@ async function runPentestSwarm(input) {
7750
7771
  abortSignal,
7751
7772
  findingsRegistry,
7752
7773
  onStepFinish: handleStepFinish,
7774
+ onCacheMetrics,
7775
+ forwardUsageCallbacksToSpawnedAgents: true,
7753
7776
  messages: previousMessages.length > 0 ? previousMessages : undefined,
7754
7777
  eventBus,
7755
7778
  subagentId,
@@ -7757,7 +7780,11 @@ async function runPentestSwarm(input) {
7757
7780
  enableThinking,
7758
7781
  thinkingEffort,
7759
7782
  openAIReasoningEffort,
7760
- display
7783
+ display,
7784
+ subagentSpawner: spawner,
7785
+ languageModelMiddleware,
7786
+ usageRecorder,
7787
+ streamIdFactory
7761
7788
  });
7762
7789
  const result = await agent.consume();
7763
7790
  saveSubagentData(session, {
@@ -7767,7 +7794,7 @@ async function runPentestSwarm(input) {
7767
7794
  status: "completed",
7768
7795
  findingsCount: result.findings.length,
7769
7796
  messages: [...previousMessages, ...lastMessages],
7770
- systemPrompt: buildPentestSystemPrompt(session),
7797
+ systemPrompt: buildPentestSystemPrompt2(session),
7771
7798
  userPrompt: agent.userPrompt
7772
7799
  });
7773
7800
  updateManifestEntryStatus(session, subagentId, "completed");
@@ -7784,7 +7811,7 @@ async function runPentestSwarm(input) {
7784
7811
  status: "failed",
7785
7812
  error: error instanceof Error ? error.message : String(error),
7786
7813
  messages: [...previousMessages, ...lastMessages],
7787
- systemPrompt: buildPentestSystemPrompt(session),
7814
+ systemPrompt: buildPentestSystemPrompt2(session),
7788
7815
  userPrompt: agent?.userPrompt ?? ""
7789
7816
  });
7790
7817
  updateManifestEntryStatus(session, subagentId, "failed");
@@ -7796,13 +7823,13 @@ async function runPentestSwarm(input) {
7796
7823
  onError?.(error);
7797
7824
  throw error;
7798
7825
  }
7799
- }, abortSignal);
7826
+ }, { concurrency, abortSignal });
7800
7827
  finalizeManifest(session, manifestEntries, results);
7801
7828
  return results;
7802
7829
  }
7803
- async function runPentestWorkflow(input) {
7830
+ async function runPentestWorkflow2(input) {
7804
7831
  if (input.fastStrike) {
7805
- const { runFastStrike } = await import("./fastStrike-8zka43xs.js");
7832
+ const { runFastStrike } = await import("./fastStrike-b8t8f916.js");
7806
7833
  return runFastStrike(input);
7807
7834
  }
7808
7835
  const {
@@ -7839,17 +7866,6 @@ async function runPentestWorkflow(input) {
7839
7866
  ${combined}` : combined;
7840
7867
  }
7841
7868
  const startedAt = Date.now();
7842
- const tokenUsageTotals = {
7843
- inputTokens: 0,
7844
- outputTokens: 0,
7845
- totalTokens: 0
7846
- };
7847
- const wrappedOnStepFinish = (event) => {
7848
- addUsageTotals(tokenUsageTotals, event.usage);
7849
- if (onStepFinish) {
7850
- onStepFinish(event);
7851
- }
7852
- };
7853
7869
  try {
7854
7870
  const mode = cwd ? "whitebox" : "blackbox";
7855
7871
  let swarmTargets;
@@ -7886,10 +7902,11 @@ ${combined}` : combined;
7886
7902
  authConfig,
7887
7903
  abortSignal,
7888
7904
  eventBus,
7889
- onStepFinish: wrappedOnStepFinish,
7905
+ onStepFinish,
7890
7906
  onCacheMetrics,
7891
7907
  openAIReasoningEffort,
7892
- surfaceIntegrationEnabled
7908
+ surfaceIntegrationEnabled,
7909
+ subagentSpawner: input.subagentSpawner
7893
7910
  });
7894
7911
  } else {
7895
7912
  swarmTargets = await runBlackboxPhase({
@@ -7899,7 +7916,7 @@ ${combined}` : combined;
7899
7916
  authConfig,
7900
7917
  abortSignal,
7901
7918
  eventBus,
7902
- onStepFinish: wrappedOnStepFinish,
7919
+ onStepFinish,
7903
7920
  onCacheMetrics,
7904
7921
  openAIReasoningEffort
7905
7922
  });
@@ -7916,21 +7933,21 @@ ${combined}` : combined;
7916
7933
  throw new DOMException("Pentest aborted by user", "AbortError");
7917
7934
  }
7918
7935
  if (swarmTargets.length === 0) {
7919
- const report2 = buildPentestReport([], {
7936
+ const report = buildPentestReport([], {
7920
7937
  target,
7921
7938
  model,
7922
7939
  sessionId: session.id,
7923
7940
  mode
7924
7941
  });
7925
- const mdPath2 = join18(session.rootPath, REPORT_FILENAME_MD);
7926
- const jsonPath2 = join18(session.rootPath, REPORT_FILENAME_JSON);
7927
- writeFileSync4(mdPath2, renderMarkdown(report2));
7928
- writeFileSync4(jsonPath2, renderJson(report2));
7942
+ const mdPath = join17(session.rootPath, REPORT_FILENAME_MD);
7943
+ const jsonPath = join17(session.rootPath, REPORT_FILENAME_JSON);
7944
+ writeFileSync4(mdPath, renderMarkdown(report));
7945
+ writeFileSync4(jsonPath, renderJson(report));
7929
7946
  return {
7930
7947
  findings: [],
7931
7948
  findingsPath: session.findingsPath,
7932
7949
  pocsPath: session.pocsPath,
7933
- reportPath: mdPath2
7950
+ reportPath: mdPath
7934
7951
  };
7935
7952
  }
7936
7953
  eventBus?.emit("workflow-phase-start", {
@@ -7940,11 +7957,12 @@ ${combined}` : combined;
7940
7957
  const findingsRegistry = FindingsRegistry.fromDirectory(session.findingsPath, {
7941
7958
  model,
7942
7959
  authConfig,
7943
- abortSignal
7960
+ abortSignal,
7961
+ sessionId: session.id
7944
7962
  });
7945
7963
  const completedCount = getCompletedAgentIds(session).size;
7946
7964
  if (completedCount < swarmTargets.length) {
7947
- await runPentestSwarm({
7965
+ await runPentestSwarm2({
7948
7966
  targets: swarmTargets,
7949
7967
  model,
7950
7968
  session,
@@ -7952,10 +7970,15 @@ ${combined}` : combined;
7952
7970
  abortSignal,
7953
7971
  findingsRegistry,
7954
7972
  eventBus,
7955
- onStepFinish: wrappedOnStepFinish,
7973
+ onStepFinish,
7974
+ onCacheMetrics,
7956
7975
  enableThinking,
7957
7976
  thinkingEffort,
7958
- openAIReasoningEffort
7977
+ openAIReasoningEffort,
7978
+ subagentSpawner: input.subagentSpawner,
7979
+ languageModelMiddleware: input.languageModelMiddleware,
7980
+ usageRecorder: input.usageRecorder,
7981
+ streamIdFactory: input.streamIdFactory
7959
7982
  });
7960
7983
  }
7961
7984
  if (abortSignal?.aborted) {
@@ -7973,8 +7996,8 @@ ${combined}` : combined;
7973
7996
  sessionId: session.id,
7974
7997
  mode
7975
7998
  });
7976
- const mdPath = join18(session.rootPath, REPORT_FILENAME_MD);
7977
- const jsonPath = join18(session.rootPath, REPORT_FILENAME_JSON);
7999
+ const mdPath = join17(session.rootPath, REPORT_FILENAME_MD);
8000
+ const jsonPath = join17(session.rootPath, REPORT_FILENAME_JSON);
7978
8001
  writeFileSync4(mdPath, renderMarkdown(report));
7979
8002
  writeFileSync4(jsonPath, renderJson(report));
7980
8003
  const severityCounts = {};
@@ -8000,7 +8023,6 @@ ${combined}` : combined;
8000
8023
  const runtime = formatDurationHmsFromMs(Date.now() - startedAt);
8001
8024
  writeExecutionMetrics({
8002
8025
  sessionRootPath: session.rootPath,
8003
- tokenUsage: tokenUsageTotals,
8004
8026
  runtime
8005
8027
  });
8006
8028
  }
@@ -8016,15 +8038,16 @@ async function runWhiteboxPhase(opts) {
8016
8038
  onStepFinish: opts.onStepFinish,
8017
8039
  onCacheMetrics: opts.onCacheMetrics,
8018
8040
  openAIReasoningEffort: opts.openAIReasoningEffort,
8019
- surfaceIntegrationEnabled: opts.surfaceIntegrationEnabled
8041
+ surfaceIntegrationEnabled: opts.surfaceIntegrationEnabled,
8042
+ subagentSpawner: opts.subagentSpawner
8020
8043
  };
8021
8044
  const result = await runWhiteboxAttackSurfaceWorkflow(workflowInput);
8022
8045
  return result.apps.flatMap((app) => [...app.pages, ...app.apiEndpoints].map((ep) => {
8023
- const grpc2 = toGrpcPentestContext(ep.transport, ep.grpc, ep.path);
8046
+ const grpc = toGrpcPentestContext(ep.transport, ep.grpc, ep.path);
8024
8047
  return {
8025
- target: grpcAuthorityTarget(grpc2, ep.path) ?? (ep.path.startsWith("http") ? ep.path : `${opts.baseTarget}${ep.path}`),
8048
+ target: grpcAuthorityTarget(grpc, ep.path) ?? (ep.path.startsWith("http") ? ep.path : `${opts.baseTarget}${ep.path}`),
8026
8049
  objectives: ep.pentestObjectives,
8027
- grpc: grpc2
8050
+ grpc
8028
8051
  };
8029
8052
  }));
8030
8053
  }
@@ -8047,7 +8070,7 @@ async function runBlackboxPhase(opts) {
8047
8070
  onCacheMetrics: opts.onCacheMetrics,
8048
8071
  openAIReasoningEffort: opts.openAIReasoningEffort
8049
8072
  };
8050
- const agent = new BlackboxAttackSurfaceAgent(agentInput);
8073
+ const agent = new BlackboxAttackSurfaceAgent2(agentInput);
8051
8074
  opts.eventBus?.emit("subagent-spawn", {
8052
8075
  subagentId: "attack-surface-agent",
8053
8076
  name: "Attack Surface Discovery",
@@ -8084,4 +8107,4 @@ async function runBlackboxPhase(opts) {
8084
8107
  throw e;
8085
8108
  }
8086
8109
  }
8087
- export { readExecutionMetrics, writeExecutionMetrics, convertModelMessagesToUI, loadSubagents, DEFAULT_CONCURRENCY2 as DEFAULT_CONCURRENCY, runPentestSwarm, runPentestWorkflow };
8110
+ export { readExecutionMetrics, writeExecutionMetrics, convertModelMessagesToUI, loadSubagents, DEFAULT_CONCURRENCY2, runPentestSwarm2, runPentestWorkflow2 };