opencode-swarm 7.148.3 → 7.148.5

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 (65) hide show
  1. package/dist/background/delegation-health.d.ts +100 -0
  2. package/dist/background/pending-delegations.d.ts +97 -0
  3. package/dist/background/queue.d.ts +45 -7
  4. package/dist/background/worker.d.ts +24 -3
  5. package/dist/cli/{config-doctor-q3fw9744.js → config-doctor-6z7x0jnz.js} +2 -2
  6. package/dist/cli/{core-y72nw57z.js → core-0ph6pb2y.js} +1 -1
  7. package/dist/cli/{curation-policy-hkdghd3a.js → curation-policy-fbvctttr.js} +5 -5
  8. package/dist/cli/{curator-llm-factory-sdxsn88r.js → curator-llm-factory-mbsn281q.js} +26 -26
  9. package/dist/cli/{curator-bsr0xx05.js → curator-pffqw3br.js} +26 -26
  10. package/dist/cli/{evidence-summary-service-rk5exnrk.js → evidence-summary-service-9ajw5tpc.js} +10 -10
  11. package/dist/cli/{gate-evidence-cn0dvw8m.js → gate-evidence-wc8wzwaw.js} +5 -5
  12. package/dist/cli/{guardrail-explain-fnnka0vt.js → guardrail-explain-a8706sq1.js} +27 -27
  13. package/dist/cli/{guardrail-log-gsx9kj51.js → guardrail-log-wx43bj32.js} +3 -3
  14. package/dist/cli/{guardrail-reset-kk1rdmm0.js → guardrail-reset-sy0vztrd.js} +26 -26
  15. package/dist/cli/{hive-promoter-w7cr6qym.js → hive-promoter-jvyzykgx.js} +26 -26
  16. package/dist/cli/{index-4aqnb12y.js → index-0yzt06r5.js} +2 -2
  17. package/dist/cli/{index-3vescfdb.js → index-1w5nnyew.js} +6 -6
  18. package/dist/cli/{index-7a41ca8k.js → index-3aev3a0c.js} +1311 -99
  19. package/dist/cli/{index-b0703hjg.js → index-579qg534.js} +1 -1
  20. package/dist/cli/{index-08d3pb9a.js → index-59wqcatm.js} +1 -1
  21. package/dist/cli/{index-fp9d0e6f.js → index-5r2mcgpa.js} +1 -1
  22. package/dist/cli/{index-y8kppv1z.js → index-5zq3892p.js} +1 -1
  23. package/dist/cli/{index-x4kgn37c.js → index-8djgxw2w.js} +2 -2
  24. package/dist/cli/{index-kn36sxj0.js → index-ag9bv589.js} +28 -28
  25. package/dist/cli/{index-et35gcph.js → index-arjq717j.js} +1 -1
  26. package/dist/cli/{index-dh85aep3.js → index-c6jqkx9d.js} +2 -2
  27. package/dist/cli/{index-2d582j6q.js → index-haf092ak.js} +3 -3
  28. package/dist/cli/{index-ebt47fnp.js → index-j382eh60.js} +1 -1
  29. package/dist/cli/{index-xq8eydnk.js → index-jzz52as5.js} +4 -4
  30. package/dist/cli/{index-m5z2fgs4.js → index-k1s8gxjh.js} +1 -1
  31. package/dist/cli/{index-zpn3wqvp.js → index-kg4knw6r.js} +2 -2
  32. package/dist/cli/{index-8w63kj4x.js → index-kj6m9ry3.js} +4 -4
  33. package/dist/cli/{index-dmbvep3q.js → index-ne45ew6z.js} +6 -6
  34. package/dist/cli/{index-r9g7ymv2.js → index-nq4tkfpc.js} +1 -1
  35. package/dist/cli/{index-harsx832.js → index-q7ke7kwd.js} +4 -4
  36. package/dist/cli/{index-hwfs0ze1.js → index-qbsc2btq.js} +3 -3
  37. package/dist/cli/{index-2n9rwvcc.js → index-qwmrt51t.js} +1 -1
  38. package/dist/cli/{index-092deqxs.js → index-t25evmna.js} +400 -12
  39. package/dist/cli/{index-2zz8b0rb.js → index-vhefvcta.js} +2 -2
  40. package/dist/cli/{index-rsn4jm90.js → index-vrp2zva8.js} +1 -1
  41. package/dist/cli/{index-afwwz4py.js → index-vyg5b8ee.js} +5 -5
  42. package/dist/cli/{index-8sz9t8s2.js → index-x3d9asnz.js} +2 -2
  43. package/dist/cli/{index-65jw48eb.js → index-yezd5ks6.js} +1 -1
  44. package/dist/cli/{index-8y79znpe.js → index-zf2vwa7y.js} +2 -2
  45. package/dist/cli/{index-c9xfy8yj.js → index-zhn0q7nf.js} +5 -5
  46. package/dist/cli/index.js +26 -26
  47. package/dist/cli/{knowledge-escalator-jxpz0mv5.js → knowledge-escalator-bvrtfdyb.js} +10 -10
  48. package/dist/cli/{knowledge-events-kjwmc21q.js → knowledge-events-rpvkevbm.js} +8 -8
  49. package/dist/cli/{knowledge-link-5dctq0ax.js → knowledge-link-spw879rs.js} +4 -4
  50. package/dist/cli/{knowledge-store-j9bzs7zx.js → knowledge-store-wjy2kshh.js} +5 -5
  51. package/dist/cli/{knowledge-validator-56w52rwr.js → knowledge-validator-cq2cgfcx.js} +7 -7
  52. package/dist/cli/{pending-delegations-h4gr264y.js → pending-delegations-f4wvyzbf.js} +10 -2
  53. package/dist/cli/{pr-subscriptions-9mg6mwc0.js → pr-subscriptions-f4xw1rxy.js} +2 -2
  54. package/dist/cli/{runner-9g2pcg10.js → runner-rk26nk58.js} +5 -5
  55. package/dist/cli/{scan-cursor-7xbrxm2c.js → scan-cursor-7n0zs72g.js} +6 -6
  56. package/dist/cli/{schema-gcjdpfr9.js → schema-e59spg93.js} +1 -1
  57. package/dist/cli/{scope-persistence-2n9nk833.js → scope-persistence-d75p900m.js} +6 -6
  58. package/dist/cli/{skill-generator-z70bhhx9.js → skill-generator-c65y1h6a.js} +12 -12
  59. package/dist/cli/{worktree-collision-ownership-e0p490vw.js → worktree-collision-ownership-wqy7mgb3.js} +2 -2
  60. package/dist/cli/{worktree-isolation-vg6g00mq.js → worktree-isolation-ay9d58w4.js} +26 -26
  61. package/dist/hooks/delegation-gate.d.ts +1 -0
  62. package/dist/index.js +23 -19
  63. package/dist/sast/rules/javascript-call-classifier.d.ts +4 -0
  64. package/dist/services/status-service.d.ts +55 -3
  65. package/package.json +1 -1
@@ -6,17 +6,17 @@ import {
6
6
  resolveExecutableFromPath,
7
7
  runEvaluation,
8
8
  runExternalTool
9
- } from "./index-ebt47fnp.js";
9
+ } from "./index-j382eh60.js";
10
10
  import {
11
11
  normalizeToolNameLowerCase,
12
12
  stableCanonicalStringify
13
- } from "./index-et35gcph.js";
13
+ } from "./index-arjq717j.js";
14
14
  import {
15
15
  detectStraySwarmDirs,
16
16
  readDoctorArtifact,
17
17
  removeStraySwarmDir,
18
18
  runConfigDoctor
19
- } from "./index-fp9d0e6f.js";
19
+ } from "./index-5r2mcgpa.js";
20
20
  import {
21
21
  MAX_TRANSIENT_RETRIES,
22
22
  archiveEvidence,
@@ -62,7 +62,7 @@ import {
62
62
  updateTaskStatus,
63
63
  validateProjectRoot,
64
64
  validateSymlinkBoundary
65
- } from "./index-c9xfy8yj.js";
65
+ } from "./index-zhn0q7nf.js";
66
66
  import {
67
67
  EvaluationTaskV1Schema,
68
68
  GateAuditManifestV1Schema,
@@ -79,7 +79,7 @@ import {
79
79
  saveGateAuditResult,
80
80
  savePromotionDecision,
81
81
  saveTaskSetSnapshot
82
- } from "./index-x4kgn37c.js";
82
+ } from "./index-8djgxw2w.js";
83
83
  import {
84
84
  loadDatabaseCtor
85
85
  } from "./index-134d35c1.js";
@@ -105,12 +105,12 @@ import {
105
105
  } from "./index-y8552snf.js";
106
106
  import {
107
107
  readRecentEscalations
108
- } from "./index-afwwz4py.js";
108
+ } from "./index-vyg5b8ee.js";
109
109
  import {
110
110
  alreadyCuratedThisGeneration,
111
111
  claimNextScanBatch,
112
112
  resolveCohortId
113
- } from "./index-8y79znpe.js";
113
+ } from "./index-zf2vwa7y.js";
114
114
  import {
115
115
  CURATOR_INIT_PROMPT,
116
116
  CURATOR_PHASE_PROMPT,
@@ -159,7 +159,7 @@ import {
159
159
  listActive,
160
160
  subscribe,
161
161
  unsubscribe
162
- } from "./index-2n9rwvcc.js";
162
+ } from "./index-qwmrt51t.js";
163
163
  import {
164
164
  BUNDLED_PROJECT_SKILL_ROOT,
165
165
  DEFAULT_SKILL_MIN_CONFIDENCE,
@@ -180,7 +180,7 @@ import {
180
180
  retireSkill,
181
181
  selectCandidateEntries,
182
182
  syncBundledProjectSkillsIfMissingAsync
183
- } from "./index-xq8eydnk.js";
183
+ } from "./index-jzz52as5.js";
184
184
  import {
185
185
  appendUnactionable,
186
186
  quarantineEntry,
@@ -191,11 +191,11 @@ import {
191
191
  validateActionableFields,
192
192
  validateLesson,
193
193
  validateSkillPath
194
- } from "./index-8w63kj4x.js";
194
+ } from "./index-kj6m9ry3.js";
195
195
  import {
196
196
  authorizeCuration,
197
197
  buildConfigFingerprintInput
198
- } from "./index-r9g7ymv2.js";
198
+ } from "./index-nq4tkfpc.js";
199
199
  import {
200
200
  cohortConfigFingerprint
201
201
  } from "./index-rtry5xyf.js";
@@ -213,9 +213,13 @@ import {
213
213
  MAX_RECOVERY_LEDGER_BYTES,
214
214
  collectDelegationLedgerHealth,
215
215
  findByBatchId,
216
+ maintainBackgroundDelegations,
217
+ readDelegationHealthArtifact,
216
218
  readDelegations,
219
+ scanBackgroundCoderReservationsForAdmission,
220
+ scanDelegationsForRecovery,
217
221
  sweepStaleDelegations
218
- } from "./index-092deqxs.js";
222
+ } from "./index-t25evmna.js";
219
223
  import {
220
224
  WORKTREE_LIFECYCLE_LOCK_FILE,
221
225
  recordWorktreeProvisioningOwner,
@@ -248,18 +252,18 @@ import {
248
252
  transitionTaskWorkflowEvidence,
249
253
  withTaskEvidenceTransaction,
250
254
  writeWorkflowWalFile
251
- } from "./index-2d582j6q.js";
255
+ } from "./index-haf092ak.js";
252
256
  import {
253
257
  provisionWorktree,
254
258
  removeWorktree
255
- } from "./index-y8kppv1z.js";
259
+ } from "./index-5zq3892p.js";
256
260
  import {
257
261
  MAX_PENDING_SCOPE_BINDINGS,
258
262
  canonicalWorkspaceIdentity,
259
263
  clearAllScopes,
260
264
  clearScopeBindingFromDisk,
261
265
  clearScopeBindings
262
- } from "./index-harsx832.js";
266
+ } from "./index-q7ke7kwd.js";
263
267
  import {
264
268
  appendLedgerEvent,
265
269
  computePlanHash,
@@ -274,7 +278,7 @@ import {
274
278
  readPlanEpochIdentity,
275
279
  replayFromLedgerWithStatus,
276
280
  takeSnapshotEvent
277
- } from "./index-8sz9t8s2.js";
281
+ } from "./index-x3d9asnz.js";
278
282
  import {
279
283
  isPathWithinDeclaredScope,
280
284
  sanitizeDiagnosticText
@@ -326,7 +330,7 @@ import {
326
330
  transactFile,
327
331
  transactKnowledge,
328
332
  wordBigrams
329
- } from "./index-3vescfdb.js";
333
+ } from "./index-1w5nnyew.js";
330
334
  import {
331
335
  MAX_EVENT_LOG_ENTRIES,
332
336
  _internals as _internals2,
@@ -340,10 +344,10 @@ import {
340
344
  recordKnowledgeEvent,
341
345
  recordPhaseCloseIntent,
342
346
  resolveKnowledgeEventsPath
343
- } from "./index-dmbvep3q.js";
347
+ } from "./index-ne45ew6z.js";
344
348
  import {
345
349
  resolveWorktreeIsolationConfig
346
- } from "./index-dh85aep3.js";
350
+ } from "./index-c6jqkx9d.js";
347
351
  import {
348
352
  RetrospectiveEvidenceSchema
349
353
  } from "./index-gprxjmm7.js";
@@ -353,7 +357,7 @@ import {
353
357
  init_loader,
354
358
  loadPluginConfig,
355
359
  loadPluginConfigWithMeta
356
- } from "./index-08d3pb9a.js";
360
+ } from "./index-59wqcatm.js";
357
361
  import {
358
362
  DEFAULT_SKILL_OPT_CONFIG,
359
363
  FALLBACK_MODELS_MAX,
@@ -367,7 +371,7 @@ import {
367
371
  package_default,
368
372
  resolveAutoReviewConfig,
369
373
  stripKnownSwarmPrefix
370
- } from "./index-65jw48eb.js";
374
+ } from "./index-yezd5ks6.js";
371
375
  import {
372
376
  AGENT_TOOL_MAP,
373
377
  ALL_AGENT_NAMES,
@@ -419,10 +423,10 @@ import {
419
423
  resolveLinkDir,
420
424
  sanitizeLinkId,
421
425
  writeLinkPointer
422
- } from "./index-m5z2fgs4.js";
426
+ } from "./index-k1s8gxjh.js";
423
427
  import {
424
428
  atomicWriteFile
425
- } from "./index-2zz8b0rb.js";
429
+ } from "./index-vhefvcta.js";
426
430
  import {
427
431
  KNOWLEDGE_SCHEMA_VERSION,
428
432
  OUTCOME_BLOCK_THRESHOLD,
@@ -434,7 +438,7 @@ import {
434
438
  atomicWriteSwarmFileSync,
435
439
  matchTempGrammar,
436
440
  parseTargetBasename
437
- } from "./index-zpn3wqvp.js";
441
+ } from "./index-kg4knw6r.js";
438
442
  import {
439
443
  assertProjectRoot,
440
444
  hasExplicitProjectBoundary,
@@ -442,7 +446,7 @@ import {
442
446
  listActiveLocks,
443
447
  tryAcquireLock,
444
448
  withEvidenceLock
445
- } from "./index-rsn4jm90.js";
449
+ } from "./index-vrp2zva8.js";
446
450
  import {
447
451
  emit,
448
452
  getLastHeartbeat,
@@ -5604,7 +5608,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
5604
5608
  awaitingMergeByCallID,
5605
5609
  cleanupStandardWorktreeForCallId,
5606
5610
  standardWorktreeByCallID
5607
- } = await import("./worktree-isolation-vg6g00mq.js");
5611
+ } = await import("./worktree-isolation-ay9d58w4.js");
5608
5612
  standardWorktreeByCallID.delete(descriptor.callID);
5609
5613
  if (hasResidue)
5610
5614
  awaitingMergeByCallID.set(descriptor.callID, {
@@ -5706,7 +5710,7 @@ async function recoverCoderSettlement(directory, taskId) {
5706
5710
  awaitingMergeByCallID,
5707
5711
  finishStandardWorktreeDispatch,
5708
5712
  standardWorktreeByCallID
5709
- } = await import("./worktree-isolation-vg6g00mq.js");
5713
+ } = await import("./worktree-isolation-ay9d58w4.js");
5710
5714
  const descriptor = wal.worktree;
5711
5715
  const reconstructedDispatch = {
5712
5716
  callID: descriptor.callID,
@@ -18382,7 +18386,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
18382
18386
  };
18383
18387
  }
18384
18388
  async function sweepActiveNearDuplicates(directory, options = {}) {
18385
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-hwfs0ze1.js");
18389
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-qbsc2btq.js");
18386
18390
  const { config } = loadPluginConfigWithMeta2(directory);
18387
18391
  const sweepConfig = config.learning?.dedup_sweep;
18388
18392
  if (sweepConfig?.enabled === false)
@@ -19500,7 +19504,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
19500
19504
  }
19501
19505
  if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
19502
19506
  try {
19503
- const skillModule = await import("./skill-generator-z70bhhx9.js");
19507
+ const skillModule = await import("./skill-generator-c65y1h6a.js");
19504
19508
  for (const cand of skillCandidates) {
19505
19509
  if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
19506
19510
  continue;
@@ -19972,7 +19976,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
19972
19976
  } catch {}
19973
19977
  }
19974
19978
  if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
19975
- const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-jxpz0mv5.js");
19979
+ const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-bvrtfdyb.js");
19976
19980
  for (const { id } of contradictedEntries) {
19977
19981
  try {
19978
19982
  await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
@@ -20791,7 +20795,7 @@ async function runCuratorPostMortem(directory, options = {}) {
20791
20795
  warnings.push("Failed to collect knowledge summary.");
20792
20796
  }
20793
20797
  try {
20794
- const { getScanStatus } = await import("./scan-cursor-7xbrxm2c.js");
20798
+ const { getScanStatus } = await import("./scan-cursor-7n0zs72g.js");
20795
20799
  const scanStatus = await getScanStatus(directory);
20796
20800
  if (scanStatus.remaining_estimate > 0) {
20797
20801
  warnings.push(`Fair scan: reviewed ${knowledgeSummary.length} entries this sweep (generation ${scanStatus.generation}); ${scanStatus.remaining_estimate} more eligible entries will be visited in future curation sweeps.`);
@@ -20963,9 +20967,9 @@ var _internals26 = {
20963
20967
  verifyPostMortemKnowledgeActions,
20964
20968
  repairPostMortemActions,
20965
20969
  loadDefaultKnowledgeConfig: async (directory) => {
20966
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-gcjdpfr9.js");
20970
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-e59spg93.js");
20967
20971
  try {
20968
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-hwfs0ze1.js");
20972
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-qbsc2btq.js");
20969
20973
  const loaded = loadPluginConfigWithMeta2(directory);
20970
20974
  return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
20971
20975
  } catch {
@@ -20973,11 +20977,11 @@ var _internals26 = {
20973
20977
  }
20974
20978
  },
20975
20979
  applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
20976
- const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-bsr0xx05.js");
20980
+ const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-pffqw3br.js");
20977
20981
  return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
20978
20982
  },
20979
20983
  checkHivePromotions: async (entries, knowledgeConfig, directory) => {
20980
- const { checkHivePromotions } = await import("./hive-promoter-w7cr6qym.js");
20984
+ const { checkHivePromotions } = await import("./hive-promoter-jvyzykgx.js");
20981
20985
  return checkHivePromotions(entries, knowledgeConfig, directory);
20982
20986
  },
20983
20987
  applyProposalTriage: async (directory, triage) => {
@@ -20986,7 +20990,7 @@ var _internals26 = {
20986
20990
  activateProposal,
20987
20991
  listSkills: listSkills2,
20988
20992
  sanitizeSlug
20989
- } = await import("./skill-generator-z70bhhx9.js");
20993
+ } = await import("./skill-generator-c65y1h6a.js");
20990
20994
  const result = {
20991
20995
  approved: [],
20992
20996
  rejected: [],
@@ -22322,9 +22326,9 @@ function hashContent(content) {
22322
22326
  return createHash10("sha1").update(content).digest("hex");
22323
22327
  }
22324
22328
  async function loadConfigForPolicyCurator(directory) {
22325
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-gcjdpfr9.js");
22329
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-e59spg93.js");
22326
22330
  try {
22327
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-hwfs0ze1.js");
22331
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-qbsc2btq.js");
22328
22332
  const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
22329
22333
  return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
22330
22334
  } catch {
@@ -33520,7 +33524,7 @@ async function runFinalizeStage(ctx) {
33520
33524
  }
33521
33525
  }
33522
33526
  try {
33523
- const { CuratorConfigSchema: CCS } = await import("./schema-gcjdpfr9.js");
33527
+ const { CuratorConfigSchema: CCS } = await import("./schema-e59spg93.js");
33524
33528
  const { config: pmLoadedConfig } = _internals41.loadPluginConfigWithMeta(ctx.directory);
33525
33529
  const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
33526
33530
  if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
@@ -35713,9 +35717,9 @@ var _internals45 = {
35713
35717
  loadPluginConfigWithMeta,
35714
35718
  loadCuratorDeps: async () => {
35715
35719
  const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
35716
- import("./schema-gcjdpfr9.js"),
35717
- import("./curator-bsr0xx05.js"),
35718
- import("./curator-llm-factory-sdxsn88r.js")
35720
+ import("./schema-e59spg93.js"),
35721
+ import("./curator-pffqw3br.js"),
35722
+ import("./curator-llm-factory-mbsn281q.js")
35719
35723
  ]);
35720
35724
  return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
35721
35725
  }
@@ -36705,7 +36709,7 @@ async function computeCurationDiagnostics(directory, entries) {
36705
36709
  let scanCompleted = false;
36706
36710
  let scanRemaining = 0;
36707
36711
  try {
36708
- const { getScanStatus } = await import("./scan-cursor-7xbrxm2c.js");
36712
+ const { getScanStatus } = await import("./scan-cursor-7n0zs72g.js");
36709
36713
  const status = await getScanStatus(directory);
36710
36714
  scanGeneration = status.generation;
36711
36715
  scanCompleted = status.completed;
@@ -36713,19 +36717,19 @@ async function computeCurationDiagnostics(directory, entries) {
36713
36717
  } catch {}
36714
36718
  let configMatch = null;
36715
36719
  try {
36716
- const { isLinked: isLinked2 } = await import("./knowledge-link-5dctq0ax.js");
36720
+ const { isLinked: isLinked2 } = await import("./knowledge-link-spw879rs.js");
36717
36721
  if (isLinked2(directory)) {
36718
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-gcjdpfr9.js");
36722
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-e59spg93.js");
36719
36723
  let config;
36720
36724
  try {
36721
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-hwfs0ze1.js");
36725
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-qbsc2btq.js");
36722
36726
  const loaded = loadPluginConfigWithMeta2(directory);
36723
36727
  config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
36724
36728
  } catch {
36725
36729
  config = KnowledgeConfigSchema2.parse({});
36726
36730
  }
36727
36731
  const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
36728
- const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-hkdghd3a.js");
36732
+ const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-fbvctttr.js");
36729
36733
  const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
36730
36734
  const cohortFp = await readCohortConfigFingerprint(directory);
36731
36735
  configMatch = cohortFp === null ? null : currentFp === cohortFp;
@@ -38029,7 +38033,7 @@ async function handleDoctorCommand(directory, args) {
38029
38033
  const result = runConfigDoctor(config, directory);
38030
38034
  let output;
38031
38035
  if (enableAutoFix && result.hasAutoFixableIssues) {
38032
- const { runConfigDoctorWithFixes } = await import("./config-doctor-q3fw9744.js");
38036
+ const { runConfigDoctorWithFixes } = await import("./config-doctor-6z7x0jnz.js");
38033
38037
  const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
38034
38038
  applyLossy: true
38035
38039
  });
@@ -38969,7 +38973,7 @@ async function handleEvidenceCommand(directory, args) {
38969
38973
  return formatTaskEvidenceMarkdown(evidenceData);
38970
38974
  }
38971
38975
  async function handleEvidenceSummaryCommand(directory) {
38972
- const { buildEvidenceSummary } = await import("./evidence-summary-service-rk5exnrk.js");
38976
+ const { buildEvidenceSummary } = await import("./evidence-summary-service-9ajw5tpc.js");
38973
38977
  const artifact = await buildEvidenceSummary(directory);
38974
38978
  if (!artifact) {
38975
38979
  return "No plan found. Run `/swarm plan` to check plan status.";
@@ -41958,7 +41962,974 @@ var javaRules = [
41958
41962
  }
41959
41963
  ];
41960
41964
 
41965
+ // src/sast/rules/javascript-call-classifier.ts
41966
+ var MAX_ANALYSIS_BYTES = 512 * 1024;
41967
+ var CHILD_PROCESS_MODULES = new Set(["child_process", "node:child_process"]);
41968
+ var analysisByContext = new WeakMap;
41969
+ var dispositionByContext = new WeakMap;
41970
+ var tokenPairsByList = new WeakMap;
41971
+ var ASSIGNMENTS = new Set([
41972
+ "=",
41973
+ "+=",
41974
+ "-=",
41975
+ "*=",
41976
+ "/=",
41977
+ "%=",
41978
+ "&&=",
41979
+ "||=",
41980
+ "??="
41981
+ ]);
41982
+ var DECLARATION_KEYWORDS = new Set(["const", "let", "var"]);
41983
+ function isIdentifierStart(char) {
41984
+ return /[A-Za-z_$]/.test(char);
41985
+ }
41986
+ function isIdentifierPart(char) {
41987
+ return /[A-Za-z0-9_$]/.test(char);
41988
+ }
41989
+ function canStartRegex(previous) {
41990
+ if (!previous)
41991
+ return true;
41992
+ if (previous.kind === "identifier") {
41993
+ return [
41994
+ "return",
41995
+ "throw",
41996
+ "case",
41997
+ "delete",
41998
+ "typeof",
41999
+ "void",
42000
+ "yield",
42001
+ "await"
42002
+ ].includes(previous.value);
42003
+ }
42004
+ return previous.kind === "punctuator" && [
42005
+ "(",
42006
+ "[",
42007
+ "{",
42008
+ "=",
42009
+ ":",
42010
+ ",",
42011
+ ";",
42012
+ "!",
42013
+ "?",
42014
+ "=>",
42015
+ "&&",
42016
+ "||",
42017
+ "??"
42018
+ ].includes(previous.value);
42019
+ }
42020
+ function tokenize2(content) {
42021
+ const tokens = [];
42022
+ let malformed = false;
42023
+ let index = 0;
42024
+ while (index < content.length) {
42025
+ const char = content[index];
42026
+ const next = content[index + 1];
42027
+ if (/\s/.test(char)) {
42028
+ index++;
42029
+ continue;
42030
+ }
42031
+ if (char === "/" && next === "/") {
42032
+ index += 2;
42033
+ while (index < content.length && content[index] !== `
42034
+ `)
42035
+ index++;
42036
+ continue;
42037
+ }
42038
+ if (char === "/" && next === "*") {
42039
+ const start = index;
42040
+ index += 2;
42041
+ while (index < content.length && !(content[index] === "*" && content[index + 1] === "/")) {
42042
+ index++;
42043
+ }
42044
+ if (index >= content.length) {
42045
+ malformed = true;
42046
+ break;
42047
+ }
42048
+ index += 2;
42049
+ if (index <= start)
42050
+ malformed = true;
42051
+ continue;
42052
+ }
42053
+ if (char === '"' || char === "'") {
42054
+ const quote = char;
42055
+ const start = index++;
42056
+ let value2 = "";
42057
+ let closed = false;
42058
+ while (index < content.length) {
42059
+ const current = content[index];
42060
+ if (current === "\\") {
42061
+ value2 += current;
42062
+ if (index + 1 < content.length)
42063
+ value2 += content[index + 1];
42064
+ index += 2;
42065
+ continue;
42066
+ }
42067
+ if (current === quote) {
42068
+ index++;
42069
+ closed = true;
42070
+ break;
42071
+ }
42072
+ value2 += current;
42073
+ index++;
42074
+ }
42075
+ if (!closed)
42076
+ malformed = true;
42077
+ tokens.push({ kind: "string", value: value2, start, end: index });
42078
+ continue;
42079
+ }
42080
+ if (char === "`") {
42081
+ const start = index++;
42082
+ tokens.push({ kind: "template", value: "", start, end: start + 1 });
42083
+ let closed = false;
42084
+ while (index < content.length) {
42085
+ if (content[index] === "\\") {
42086
+ index += 2;
42087
+ continue;
42088
+ }
42089
+ if (content[index] === "$" && content[index + 1] === "{") {
42090
+ const expressionStart = index + 2;
42091
+ let cursor = expressionStart;
42092
+ let depth = 1;
42093
+ let quote = null;
42094
+ while (cursor < content.length && depth > 0) {
42095
+ const current = content[cursor];
42096
+ if (quote) {
42097
+ if (current === "\\")
42098
+ cursor++;
42099
+ else if (current === quote)
42100
+ quote = null;
42101
+ } else if (current === '"' || current === "'")
42102
+ quote = current;
42103
+ else if (current === "{")
42104
+ depth++;
42105
+ else if (current === "}")
42106
+ depth--;
42107
+ cursor++;
42108
+ }
42109
+ if (depth !== 0) {
42110
+ malformed = true;
42111
+ index = cursor;
42112
+ break;
42113
+ }
42114
+ const nested = tokenize2(content.slice(expressionStart, cursor - 1));
42115
+ for (const token of nested.tokens) {
42116
+ tokens.push({
42117
+ ...token,
42118
+ start: token.start + expressionStart,
42119
+ end: token.end + expressionStart
42120
+ });
42121
+ }
42122
+ malformed ||= nested.malformed;
42123
+ index = cursor;
42124
+ continue;
42125
+ }
42126
+ if (content[index] === "`") {
42127
+ index++;
42128
+ closed = true;
42129
+ break;
42130
+ }
42131
+ index++;
42132
+ }
42133
+ if (!closed)
42134
+ malformed = true;
42135
+ continue;
42136
+ }
42137
+ if (char === "/" && canStartRegex(tokens.at(-1))) {
42138
+ const start = index++;
42139
+ let inClass = false;
42140
+ let closed = false;
42141
+ while (index < content.length) {
42142
+ const current = content[index];
42143
+ if (current === "\\") {
42144
+ index += 2;
42145
+ continue;
42146
+ }
42147
+ if (current === "[")
42148
+ inClass = true;
42149
+ if (current === "]")
42150
+ inClass = false;
42151
+ if (current === "/" && !inClass) {
42152
+ index++;
42153
+ while (index < content.length && /[A-Za-z]/.test(content[index]))
42154
+ index++;
42155
+ closed = true;
42156
+ break;
42157
+ }
42158
+ if (current === `
42159
+ `)
42160
+ break;
42161
+ index++;
42162
+ }
42163
+ if (!closed)
42164
+ malformed = true;
42165
+ tokens.push({
42166
+ kind: "regex",
42167
+ value: content.slice(start, index),
42168
+ start,
42169
+ end: index
42170
+ });
42171
+ continue;
42172
+ }
42173
+ if (isIdentifierStart(char)) {
42174
+ const start = index++;
42175
+ while (index < content.length && isIdentifierPart(content[index]))
42176
+ index++;
42177
+ tokens.push({
42178
+ kind: "identifier",
42179
+ value: content.slice(start, index),
42180
+ start,
42181
+ end: index
42182
+ });
42183
+ continue;
42184
+ }
42185
+ if (/\d/.test(char)) {
42186
+ const start = index++;
42187
+ while (index < content.length && /[\w.]/.test(content[index]))
42188
+ index++;
42189
+ tokens.push({
42190
+ kind: "number",
42191
+ value: content.slice(start, index),
42192
+ start,
42193
+ end: index
42194
+ });
42195
+ continue;
42196
+ }
42197
+ const punctuator = [
42198
+ "?.",
42199
+ "=>",
42200
+ "===",
42201
+ "!==",
42202
+ "==",
42203
+ "!=",
42204
+ "++",
42205
+ "--",
42206
+ "+=",
42207
+ "-=",
42208
+ "*=",
42209
+ "/=",
42210
+ "%=",
42211
+ "&&=",
42212
+ "||=",
42213
+ "??=",
42214
+ "&&",
42215
+ "||",
42216
+ "??",
42217
+ "..."
42218
+ ].find((candidate) => content.startsWith(candidate, index));
42219
+ const value = punctuator ?? char;
42220
+ tokens.push({
42221
+ kind: "punctuator",
42222
+ value,
42223
+ start: index,
42224
+ end: index + value.length
42225
+ });
42226
+ index += value.length;
42227
+ }
42228
+ return { tokens, malformed };
42229
+ }
42230
+ function addDeclaration(analysis, name) {
42231
+ analysis.declarations.set(name, (analysis.declarations.get(name) ?? 0) + 1);
42232
+ }
42233
+ function addFact(analysis, name, fact, tokenIndex) {
42234
+ const facts = analysis.facts.get(name) ?? new Set;
42235
+ facts.add(fact);
42236
+ analysis.facts.set(name, facts);
42237
+ const scope = declarationScope(analysis, tokenIndex);
42238
+ const scopedFacts = analysis.factScopes.get(name) ?? new Map;
42239
+ const factsAtScope = scopedFacts.get(scope) ?? new Set;
42240
+ factsAtScope.add(fact);
42241
+ scopedFacts.set(scope, factsAtScope);
42242
+ analysis.factScopes.set(name, scopedFacts);
42243
+ }
42244
+ function addScopedMarker(store, name, scope) {
42245
+ const scopes = store.get(name) ?? new Set;
42246
+ scopes.add(scope);
42247
+ store.set(name, scopes);
42248
+ }
42249
+ function hasScopedMarker(store, name, scope) {
42250
+ return scope !== null && (store.get(name)?.has(scope) ?? false);
42251
+ }
42252
+ function visibleScopeAt(analysis, name, callIndex) {
42253
+ return visibleDeclarationScope(analysis, name, callIndex) ?? analysis.scopeAtToken[callIndex] ?? 0;
42254
+ }
42255
+ function hasVisibleMarker(analysis, store, name, callIndex) {
42256
+ let scope = visibleScopeAt(analysis, name, callIndex);
42257
+ while (scope >= 0) {
42258
+ if (store.get(name)?.has(scope))
42259
+ return true;
42260
+ scope = analysis.scopeParents[scope] ?? -1;
42261
+ }
42262
+ return false;
42263
+ }
42264
+ function factsAtVisibleScope(analysis, name, callIndex) {
42265
+ const scope = visibleDeclarationScope(analysis, name, callIndex);
42266
+ return scope === null ? undefined : analysis.factScopes.get(name)?.get(scope);
42267
+ }
42268
+ function tokenPairs(tokens) {
42269
+ const cached = tokenPairsByList.get(tokens);
42270
+ if (cached)
42271
+ return cached;
42272
+ const pairs = new Map;
42273
+ const stack = [];
42274
+ const matching = { ")": "(", "]": "[", "}": "{" };
42275
+ for (let index = 0;index < tokens.length; index++) {
42276
+ const value = tokens[index]?.value;
42277
+ if (value === "(" || value === "[" || value === "{") {
42278
+ stack.push({ value, index });
42279
+ continue;
42280
+ }
42281
+ const open2 = matching[value ?? ""];
42282
+ if (!open2)
42283
+ continue;
42284
+ const top = stack.at(-1);
42285
+ if (!top || top.value !== open2)
42286
+ continue;
42287
+ stack.pop();
42288
+ pairs.set(top.index, index);
42289
+ pairs.set(index, top.index);
42290
+ }
42291
+ tokenPairsByList.set(tokens, pairs);
42292
+ return pairs;
42293
+ }
42294
+ function pairedToken(tokens, index) {
42295
+ return tokenPairs(tokens).get(index) ?? -1;
42296
+ }
42297
+ function buildScopes(tokens) {
42298
+ const scopeAtToken = [];
42299
+ const scopeParents = [-1];
42300
+ const scopeIsFunction = [true];
42301
+ const stack = [0];
42302
+ const braceCreatesScope = [];
42303
+ for (let index = 0;index < tokens.length; index++) {
42304
+ scopeAtToken[index] = stack.at(-1);
42305
+ if (tokens[index]?.value === "{") {
42306
+ const previous = tokens[index - 1];
42307
+ let cursor = index - 1;
42308
+ let importClause = false;
42309
+ while (cursor >= 0 && ![";", "{", "}"].includes(tokens[cursor].value)) {
42310
+ if (tokens[cursor]?.value === "import")
42311
+ importClause = true;
42312
+ cursor--;
42313
+ }
42314
+ const createsScope = !importClause && !DECLARATION_KEYWORDS.has(previous?.value ?? "") && !["=", "(", "[", ",", ":", "return"].includes(previous?.value ?? "");
42315
+ braceCreatesScope.push(createsScope);
42316
+ if (createsScope) {
42317
+ const child = scopeParents.length;
42318
+ scopeParents.push(stack.at(-1));
42319
+ const previousValue = previous?.value;
42320
+ let functionBody = previousValue === "=>";
42321
+ if (previousValue === ")") {
42322
+ const open2 = pairedToken(tokens, index - 1);
42323
+ for (let cursor2 = open2 - 1;cursor2 >= 0; cursor2--) {
42324
+ const value = tokens[cursor2]?.value;
42325
+ if (value === "function") {
42326
+ functionBody = true;
42327
+ break;
42328
+ }
42329
+ if (value === ";" || value === "{" || value === "}")
42330
+ break;
42331
+ }
42332
+ }
42333
+ scopeIsFunction.push(functionBody);
42334
+ stack.push(child);
42335
+ }
42336
+ } else if (tokens[index]?.value === "}") {
42337
+ if (braceCreatesScope.pop() && stack.length > 1)
42338
+ stack.pop();
42339
+ }
42340
+ }
42341
+ return { scopeAtToken, scopeParents, scopeIsFunction };
42342
+ }
42343
+ function declarationScope(analysis, tokenIndex) {
42344
+ if (analysis.varDeclarationIndexes.has(tokenIndex)) {
42345
+ let scope = analysis.scopeAtToken[tokenIndex] ?? 0;
42346
+ while (scope > 0 && !analysis.scopeIsFunction[scope]) {
42347
+ scope = analysis.scopeParents[scope] ?? 0;
42348
+ }
42349
+ return scope;
42350
+ }
42351
+ const parameterScope = analysis.parameterScopes.get(tokenIndex);
42352
+ if (parameterScope !== undefined)
42353
+ return parameterScope;
42354
+ return analysis.scopeAtToken[tokenIndex] ?? 0;
42355
+ }
42356
+ function visibleDeclarationScope(analysis, name, callIndex) {
42357
+ const scopes = analysis.declarationScopes.get(name);
42358
+ if (!scopes)
42359
+ return null;
42360
+ let scope = analysis.scopeAtToken[callIndex] ?? 0;
42361
+ while (scope >= 0) {
42362
+ if (scopes.has(scope))
42363
+ return scope;
42364
+ scope = analysis.scopeParents[scope] ?? -1;
42365
+ }
42366
+ return null;
42367
+ }
42368
+ function matchingToken(tokens, start, open2, close) {
42369
+ if (tokens[start]?.value !== open2)
42370
+ return -1;
42371
+ const match = pairedToken(tokens, start);
42372
+ return tokens[match]?.value === close ? match : -1;
42373
+ }
42374
+ function moduleAtCall(tokens, start, callee) {
42375
+ if (tokens[start]?.value !== callee || tokens[start + 1]?.value !== "(" || tokens[start + 2]?.kind !== "string" || tokens[start + 3]?.value !== ")") {
42376
+ return null;
42377
+ }
42378
+ return tokens[start + 2].value;
42379
+ }
42380
+ function declarationNames(tokens, start, end) {
42381
+ const names = [];
42382
+ if (tokens[start]?.value === "{") {
42383
+ for (let index = start + 1;index < end; index++) {
42384
+ const token = tokens[index];
42385
+ if (token?.kind !== "identifier")
42386
+ continue;
42387
+ if (tokens[index + 1]?.value === ":") {
42388
+ const local = tokens[index + 2];
42389
+ if (local?.kind === "identifier")
42390
+ names.push({ name: local.value, index: index + 2 });
42391
+ index += 2;
42392
+ } else if (tokens[index - 1]?.value !== ":") {
42393
+ names.push({ name: token.value, index });
42394
+ }
42395
+ }
42396
+ } else if (tokens[start]?.kind === "identifier") {
42397
+ names.push({ name: tokens[start].value, index: start });
42398
+ }
42399
+ return names;
42400
+ }
42401
+ function nextFunctionOpen(tokens, start) {
42402
+ for (let index = start + 1;index < tokens.length; index++) {
42403
+ const value = tokens[index]?.value;
42404
+ if (value === "(")
42405
+ return index;
42406
+ if (value === "{" || value === ";" || value === "=>")
42407
+ return -1;
42408
+ }
42409
+ return -1;
42410
+ }
42411
+ function nextFunctionBody(tokens, start) {
42412
+ for (let index = start;index < tokens.length; index++) {
42413
+ const value = tokens[index]?.value;
42414
+ if (value === "{")
42415
+ return index;
42416
+ if (value === ";" || value === "=>")
42417
+ return -1;
42418
+ }
42419
+ return -1;
42420
+ }
42421
+ function collectDeclarations(analysis) {
42422
+ const { tokens } = analysis;
42423
+ const declarationTokenIndexes = new Set;
42424
+ for (let index = 0;index < tokens.length; index++) {
42425
+ const token = tokens[index];
42426
+ if (!token)
42427
+ continue;
42428
+ if (token.value === "import") {
42429
+ if (tokens[index + 1]?.value === "type")
42430
+ continue;
42431
+ if (tokens[index + 1]?.value === "{") {
42432
+ const close = matchingToken(tokens, index + 1, "{", "}");
42433
+ for (let cursor = index + 2;cursor > 0 && cursor < close; cursor++) {
42434
+ const imported = tokens[cursor];
42435
+ if (imported?.kind !== "identifier")
42436
+ continue;
42437
+ if (imported.value === "type") {
42438
+ while (cursor < close && tokens[cursor]?.value !== ",")
42439
+ cursor++;
42440
+ continue;
42441
+ }
42442
+ const local = tokens[cursor + 1]?.value === "as" ? tokens[cursor + 2] : imported;
42443
+ if (local?.kind === "identifier") {
42444
+ addDeclaration(analysis, local.value);
42445
+ declarationTokenIndexes.add(tokens[cursor + 1]?.value === "as" ? cursor + 2 : cursor);
42446
+ }
42447
+ while (cursor < close && tokens[cursor]?.value !== ",")
42448
+ cursor++;
42449
+ }
42450
+ } else if (tokens[index + 1]?.value === "*" && tokens[index + 2]?.value === "as") {
42451
+ const local = tokens[index + 3];
42452
+ if (local?.kind === "identifier") {
42453
+ addDeclaration(analysis, local.value);
42454
+ declarationTokenIndexes.add(index + 3);
42455
+ }
42456
+ } else if (tokens[index + 1]?.kind === "identifier") {
42457
+ addDeclaration(analysis, tokens[index + 1].value);
42458
+ declarationTokenIndexes.add(index + 1);
42459
+ }
42460
+ }
42461
+ if (DECLARATION_KEYWORDS.has(token.value)) {
42462
+ const start = index + 1;
42463
+ const close = tokens[start]?.value === "{" ? matchingToken(tokens, start, "{", "}") : start + 1;
42464
+ for (const item of declarationNames(tokens, start, close)) {
42465
+ addDeclaration(analysis, item.name);
42466
+ declarationTokenIndexes.add(item.index);
42467
+ if (token.value === "var")
42468
+ analysis.varDeclarationIndexes.add(item.index);
42469
+ }
42470
+ }
42471
+ if ((token.value === "function" || token.value === "class") && tokens[index + 1]?.kind === "identifier") {
42472
+ addDeclaration(analysis, tokens[index + 1].value);
42473
+ declarationTokenIndexes.add(index + 1);
42474
+ }
42475
+ if (token.value === "function") {
42476
+ const open2 = nextFunctionOpen(tokens, index);
42477
+ if (open2 > index) {
42478
+ const close = matchingToken(tokens, open2, "(", ")");
42479
+ const body = close >= 0 ? nextFunctionBody(tokens, close + 1) : -1;
42480
+ const bodyScope = body >= 0 ? analysis.scopeAtToken[body + 1] ?? analysis.scopeAtToken[body] : undefined;
42481
+ for (let cursor = open2 + 1;cursor < close; cursor++) {
42482
+ if (tokens[cursor]?.kind === "identifier" && tokens[cursor - 1]?.value !== ".") {
42483
+ addDeclaration(analysis, tokens[cursor].value);
42484
+ declarationTokenIndexes.add(cursor);
42485
+ if (bodyScope !== undefined)
42486
+ analysis.parameterScopes.set(cursor, bodyScope);
42487
+ while (cursor < close && tokens[cursor]?.value !== ",")
42488
+ cursor++;
42489
+ }
42490
+ }
42491
+ }
42492
+ }
42493
+ if (token.value === "catch" && tokens[index + 1]?.value === "(" && tokens[index + 2]?.kind === "identifier") {
42494
+ addDeclaration(analysis, tokens[index + 2].value);
42495
+ declarationTokenIndexes.add(index + 2);
42496
+ }
42497
+ if (token.kind === "identifier" && tokens[index + 1]?.value === "=>") {
42498
+ addDeclaration(analysis, token.value);
42499
+ declarationTokenIndexes.add(index);
42500
+ const body = nextFunctionBody(tokens, index + 2);
42501
+ if (body >= 0)
42502
+ analysis.parameterScopes.set(index, analysis.scopeAtToken[body + 1] ?? analysis.scopeAtToken[body]);
42503
+ }
42504
+ if (token.value === "=>") {
42505
+ let close = index - 1;
42506
+ while (close >= 0 && tokens[close]?.value !== ")")
42507
+ close--;
42508
+ let cursor = close - 1;
42509
+ let depth = 1;
42510
+ while (cursor >= 0 && depth > 0) {
42511
+ if (tokens[cursor]?.value === ")")
42512
+ depth++;
42513
+ else if (tokens[cursor]?.value === "(")
42514
+ depth--;
42515
+ cursor--;
42516
+ }
42517
+ const body = nextFunctionBody(tokens, index + 1);
42518
+ const bodyScope = body >= 0 ? analysis.scopeAtToken[body + 1] ?? analysis.scopeAtToken[body] : undefined;
42519
+ for (cursor += 2;cursor < close; cursor++) {
42520
+ if (tokens[cursor]?.kind === "identifier") {
42521
+ addDeclaration(analysis, tokens[cursor].value);
42522
+ declarationTokenIndexes.add(cursor);
42523
+ if (bodyScope !== undefined)
42524
+ analysis.parameterScopes.set(cursor, bodyScope);
42525
+ while (cursor < close && tokens[cursor]?.value !== ",")
42526
+ cursor++;
42527
+ }
42528
+ }
42529
+ }
42530
+ }
42531
+ return declarationTokenIndexes;
42532
+ }
42533
+ function collectFacts(analysis) {
42534
+ const { tokens } = analysis;
42535
+ for (let index = 0;index < tokens.length; index++) {
42536
+ if (tokens[index]?.value === "import" && tokens[index + 1]?.value !== "type") {
42537
+ if (tokens[index + 1]?.value === "{") {
42538
+ const close = matchingToken(tokens, index + 1, "{", "}");
42539
+ const module2 = tokens[close + 1]?.value === "from" ? tokens[close + 2]?.value : null;
42540
+ for (let cursor = index + 2;cursor > 0 && cursor < close; cursor++) {
42541
+ const imported = tokens[cursor];
42542
+ if (imported?.kind !== "identifier")
42543
+ continue;
42544
+ if (imported.value === "type") {
42545
+ while (cursor < close && tokens[cursor]?.value !== ",")
42546
+ cursor++;
42547
+ continue;
42548
+ }
42549
+ const local2 = tokens[cursor + 1]?.value === "as" ? tokens[cursor + 2] : imported;
42550
+ if (local2?.kind === "identifier") {
42551
+ if (CHILD_PROCESS_MODULES.has(module2 ?? "") && imported.value === "exec") {
42552
+ addFact(analysis, local2.value, "child-direct", tokens[cursor + 1]?.value === "as" ? cursor + 2 : cursor);
42553
+ } else if (module2)
42554
+ addFact(analysis, local2.value, "other-import", tokens[cursor + 1]?.value === "as" ? cursor + 2 : cursor);
42555
+ }
42556
+ while (cursor < close && tokens[cursor]?.value !== ",")
42557
+ cursor++;
42558
+ }
42559
+ } else if (tokens[index + 1]?.value === "*" && tokens[index + 2]?.value === "as") {
42560
+ const local2 = tokens[index + 3];
42561
+ const module2 = tokens[index + 4]?.value === "from" ? tokens[index + 5]?.value : null;
42562
+ if (local2?.kind === "identifier" && module2) {
42563
+ addFact(analysis, local2.value, CHILD_PROCESS_MODULES.has(module2) ? "child-namespace" : "other-import", index + 3);
42564
+ analysis.requireDerived.add(local2.value);
42565
+ addScopedMarker(analysis.requireDerivedScopes, local2.value, declarationScope(analysis, index + 3));
42566
+ }
42567
+ } else if (tokens[index + 1]?.kind === "identifier" && tokens[index + 2]?.value === "=" && tokens[index + 3]?.value === "require") {
42568
+ const module2 = moduleAtCall(tokens, index + 3, "require");
42569
+ if (module2)
42570
+ addFact(analysis, tokens[index + 1].value, CHILD_PROCESS_MODULES.has(module2) ? "child-namespace" : "other-import", index + 1);
42571
+ } else if (tokens[index + 1]?.kind === "identifier" && tokens[index + 2]?.value === "from" && tokens[index + 3]?.kind === "string") {
42572
+ const local2 = tokens[index + 1];
42573
+ addFact(analysis, local2.value, CHILD_PROCESS_MODULES.has(tokens[index + 3].value) ? "child-namespace" : "other-import", index + 1);
42574
+ }
42575
+ }
42576
+ if (!DECLARATION_KEYWORDS.has(tokens[index]?.value ?? ""))
42577
+ continue;
42578
+ const start = index + 1;
42579
+ if (tokens[start]?.value === "{") {
42580
+ const close = matchingToken(tokens, start, "{", "}");
42581
+ const rhs2 = close + 1;
42582
+ const module2 = tokens[rhs2]?.value === "=" ? moduleAtCall(tokens, rhs2 + 1, "require") : null;
42583
+ const namespace = tokens[rhs2]?.value === "=" && tokens[rhs2 + 1]?.kind === "identifier" ? tokens[rhs2 + 1].value : null;
42584
+ for (let cursor = start + 1;cursor < close; cursor++) {
42585
+ const imported = tokens[cursor];
42586
+ if (imported?.kind !== "identifier")
42587
+ continue;
42588
+ const local2 = tokens[cursor + 1]?.value === ":" ? tokens[cursor + 2] : imported;
42589
+ if (local2?.kind === "identifier" && imported.value === "exec") {
42590
+ if (module2 && CHILD_PROCESS_MODULES.has(module2)) {
42591
+ addFact(analysis, local2.value, "child-direct", tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor);
42592
+ analysis.requireDerived.add(local2.value);
42593
+ addScopedMarker(analysis.requireDerivedScopes, local2.value, declarationScope(analysis, tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor));
42594
+ } else if (namespace && hasUniqueFact(analysis, namespace, rhs2 + 1, "child-namespace")) {
42595
+ addFact(analysis, local2.value, "child-direct", tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor);
42596
+ if (hasScopedMarker(analysis.requireDerivedScopes, namespace, visibleDeclarationScope(analysis, namespace, rhs2 + 1))) {
42597
+ analysis.requireDerived.add(local2.value);
42598
+ addScopedMarker(analysis.requireDerivedScopes, local2.value, declarationScope(analysis, tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor));
42599
+ }
42600
+ }
42601
+ }
42602
+ while (cursor < close && tokens[cursor]?.value !== ",")
42603
+ cursor++;
42604
+ }
42605
+ continue;
42606
+ }
42607
+ const local = tokens[start];
42608
+ if (local?.kind !== "identifier" || tokens[start + 1]?.value !== "=")
42609
+ continue;
42610
+ const rhs = start + 2;
42611
+ const module = moduleAtCall(tokens, rhs, "require");
42612
+ if (module) {
42613
+ addFact(analysis, local.value, CHILD_PROCESS_MODULES.has(module) ? "child-namespace" : "other-import", start);
42614
+ analysis.requireDerived.add(local.value);
42615
+ addScopedMarker(analysis.requireDerivedScopes, local.value, declarationScope(analysis, start));
42616
+ } else if (tokens[rhs]?.value === "import" || tokens[rhs]?.value === "await" && tokens[rhs + 1]?.value === "import") {
42617
+ const importIndex = tokens[rhs]?.value === "await" ? rhs + 1 : rhs;
42618
+ const importedModule = moduleAtCall(tokens, importIndex, "import");
42619
+ if (importedModule) {
42620
+ addFact(analysis, local.value, CHILD_PROCESS_MODULES.has(importedModule) ? "child-namespace" : "other-import", start);
42621
+ }
42622
+ } else if (tokens[rhs]?.kind === "regex" || tokens[rhs]?.value === "new" && tokens[rhs + 1]?.value === "RegExp") {
42623
+ addFact(analysis, local.value, "regex", start);
42624
+ } else if (tokens[rhs]?.kind === "identifier" && (tokens[rhs + 1]?.value === "." || tokens[rhs + 1]?.value === "?.") && tokens[rhs + 2]?.value === "exec" && hasUniqueFact(analysis, tokens[rhs].value, rhs, "child-namespace")) {
42625
+ addFact(analysis, local.value, "child-direct", start);
42626
+ if (hasScopedMarker(analysis.requireDerivedScopes, tokens[rhs].value, visibleDeclarationScope(analysis, tokens[rhs].value, rhs))) {
42627
+ analysis.requireDerived.add(local.value);
42628
+ addScopedMarker(analysis.requireDerivedScopes, local.value, declarationScope(analysis, start));
42629
+ }
42630
+ }
42631
+ }
42632
+ }
42633
+ function hasUniqueFact(analysis, name, callIndex, fact) {
42634
+ const scope = visibleDeclarationScope(analysis, name, callIndex);
42635
+ const facts = scope === null ? undefined : analysis.factScopes.get(name)?.get(scope);
42636
+ return scope !== null && analysis.declarationScopes.get(name)?.get(scope) === 1 && !hasScopedMarker(analysis.reassignedScopes, name, scope) && facts?.size === 1 && facts.has(fact);
42637
+ }
42638
+ function buildAnalysis(context) {
42639
+ const lineStarts = [0];
42640
+ for (let index = 0;index < context.content.length; index++) {
42641
+ if (context.content[index] === `
42642
+ `)
42643
+ lineStarts.push(index + 1);
42644
+ }
42645
+ if (context.content.length > MAX_ANALYSIS_BYTES) {
42646
+ return {
42647
+ tokens: [],
42648
+ lineStarts,
42649
+ scopeAtToken: [],
42650
+ scopeParents: [-1],
42651
+ scopeIsFunction: [true],
42652
+ declarations: new Map,
42653
+ declarationScopes: new Map,
42654
+ facts: new Map,
42655
+ factScopes: new Map,
42656
+ reassigned: new Set,
42657
+ reassignedScopes: new Map,
42658
+ mutatedMembers: new Set,
42659
+ mutatedMemberScopes: new Map,
42660
+ requireDerived: new Set,
42661
+ requireDerivedScopes: new Map,
42662
+ parameterScopes: new Map,
42663
+ varDeclarationIndexes: new Set,
42664
+ oversizedOrMalformed: true
42665
+ };
42666
+ }
42667
+ const tokenized = tokenize2(context.content);
42668
+ const scopes = buildScopes(tokenized.tokens);
42669
+ const analysis = {
42670
+ tokens: tokenized.tokens,
42671
+ lineStarts,
42672
+ scopeAtToken: scopes.scopeAtToken,
42673
+ scopeParents: scopes.scopeParents,
42674
+ scopeIsFunction: scopes.scopeIsFunction,
42675
+ declarations: new Map,
42676
+ declarationScopes: new Map,
42677
+ facts: new Map,
42678
+ factScopes: new Map,
42679
+ reassigned: new Set,
42680
+ reassignedScopes: new Map,
42681
+ mutatedMembers: new Set,
42682
+ mutatedMemberScopes: new Map,
42683
+ requireDerived: new Set,
42684
+ requireDerivedScopes: new Map,
42685
+ parameterScopes: new Map,
42686
+ varDeclarationIndexes: new Set,
42687
+ oversizedOrMalformed: tokenized.malformed
42688
+ };
42689
+ const declarationIndexes = collectDeclarations(analysis);
42690
+ for (const index of declarationIndexes) {
42691
+ const name = analysis.tokens[index]?.value;
42692
+ if (!name)
42693
+ continue;
42694
+ const scope = declarationScope(analysis, index);
42695
+ const counts = analysis.declarationScopes.get(name) ?? new Map;
42696
+ counts.set(scope, (counts.get(scope) ?? 0) + 1);
42697
+ analysis.declarationScopes.set(name, counts);
42698
+ }
42699
+ collectFacts(analysis);
42700
+ for (let index = 0;index < analysis.tokens.length; index++) {
42701
+ const token = analysis.tokens[index];
42702
+ if (token?.kind !== "identifier" || declarationIndexes.has(index))
42703
+ continue;
42704
+ const previous = analysis.tokens[index - 1]?.value;
42705
+ if (previous === "." || previous === "?.") {
42706
+ if (token.value === "exec" && (ASSIGNMENTS.has(analysis.tokens[index + 1]?.value ?? "") || analysis.tokens[index - 3]?.value === "delete")) {
42707
+ const receiver = analysis.tokens[index - 2];
42708
+ if (receiver?.kind === "identifier") {
42709
+ analysis.mutatedMembers.add(receiver.value);
42710
+ addScopedMarker(analysis.mutatedMemberScopes, receiver.value, visibleDeclarationScope(analysis, receiver.value, index - 2) ?? analysis.scopeAtToken[index - 2] ?? 0);
42711
+ }
42712
+ }
42713
+ continue;
42714
+ }
42715
+ if (ASSIGNMENTS.has(analysis.tokens[index + 1]?.value ?? "") || previous === "++" || previous === "--" || analysis.tokens[index + 1]?.value === "++" || analysis.tokens[index + 1]?.value === "--") {
42716
+ analysis.reassigned.add(token.value);
42717
+ addScopedMarker(analysis.reassignedScopes, token.value, visibleDeclarationScope(analysis, token.value, index) ?? analysis.scopeAtToken[index] ?? 0);
42718
+ }
42719
+ }
42720
+ return analysis;
42721
+ }
42722
+ function getAnalysis(context) {
42723
+ let analysis = analysisByContext.get(context);
42724
+ if (!analysis) {
42725
+ analysis = buildAnalysis(context);
42726
+ analysisByContext.set(context, analysis);
42727
+ }
42728
+ return analysis;
42729
+ }
42730
+ function tokenIndexAtOffset(tokens, offset) {
42731
+ let low = 0;
42732
+ let high = tokens.length - 1;
42733
+ while (low <= high) {
42734
+ const mid = low + high >>> 1;
42735
+ const token = tokens[mid];
42736
+ if (offset < token.start)
42737
+ high = mid - 1;
42738
+ else if (offset >= token.end)
42739
+ low = mid + 1;
42740
+ else
42741
+ return mid;
42742
+ }
42743
+ return -1;
42744
+ }
42745
+ function directRequireBefore(tokens, dotIndex) {
42746
+ if (tokens[dotIndex - 1]?.value !== ")")
42747
+ return false;
42748
+ for (let start = dotIndex - 2;start >= 0 && start >= dotIndex - 5; start--) {
42749
+ const module = moduleAtCall(tokens, start, "require");
42750
+ if (module && start + 4 === dotIndex)
42751
+ return CHILD_PROCESS_MODULES.has(module);
42752
+ }
42753
+ return false;
42754
+ }
42755
+ function isTransparentWrapperCall(tokens, openIndex) {
42756
+ return tokens[openIndex - 1]?.kind === "identifier" ? tokens[openIndex - 1].value === "promisify" : false;
42757
+ }
42758
+ function shouldSkipTrailingClose(tokens, nameIndex, closeIndex) {
42759
+ const openIndex = pairedToken(tokens, closeIndex);
42760
+ if (openIndex < 0 || openIndex > nameIndex)
42761
+ return false;
42762
+ const beforeOpen = tokens[openIndex - 1];
42763
+ if (!beforeOpen || beforeOpen.kind !== "identifier" && beforeOpen.kind !== "string" && beforeOpen.kind !== "regex" && beforeOpen.value !== ")" && beforeOpen.value !== "]") {
42764
+ return true;
42765
+ }
42766
+ return isTransparentWrapperCall(tokens, openIndex);
42767
+ }
42768
+ function parseCallee(tokens, nameIndex) {
42769
+ const nameToken = tokens[nameIndex];
42770
+ if (!nameToken)
42771
+ return null;
42772
+ let cursor = nameIndex + 1;
42773
+ if (nameToken.kind === "string") {
42774
+ if (tokens[nameIndex - 1]?.value !== "[" || tokens[nameIndex + 1]?.value !== "]")
42775
+ return null;
42776
+ cursor = nameIndex + 2;
42777
+ }
42778
+ while (tokens[cursor]?.value === ")" && shouldSkipTrailingClose(tokens, nameIndex, cursor)) {
42779
+ cursor++;
42780
+ }
42781
+ if (tokens[cursor]?.value === "?.")
42782
+ cursor++;
42783
+ if (tokens[cursor]?.value !== "(")
42784
+ return null;
42785
+ const callee = { name: nameToken.value, openParen: cursor };
42786
+ const accessIndex = nameToken.kind === "string" ? nameIndex - 1 : nameIndex - 1;
42787
+ if (nameToken.kind === "string") {
42788
+ const receiver = tokens[nameIndex - 2];
42789
+ if (receiver?.kind === "identifier") {
42790
+ callee.receiver = receiver.value;
42791
+ callee.receiverKind = "identifier";
42792
+ } else if (receiver?.kind === "regex")
42793
+ callee.receiverKind = "regex";
42794
+ return callee;
42795
+ }
42796
+ if (tokens[accessIndex]?.value === "." || tokens[accessIndex]?.value === "?.") {
42797
+ const receiver = tokens[accessIndex - 1];
42798
+ if (receiver?.kind === "identifier") {
42799
+ callee.receiver = receiver.value;
42800
+ callee.receiverKind = "identifier";
42801
+ } else if (receiver?.kind === "regex")
42802
+ callee.receiverKind = "regex";
42803
+ else if (directRequireBefore(tokens, accessIndex))
42804
+ callee.receiverKind = "direct-child-require";
42805
+ }
42806
+ return callee;
42807
+ }
42808
+ function bindingDisposition(analysis, name, confirmedFact, callIndex) {
42809
+ const visibleScope = visibleDeclarationScope(analysis, name, callIndex);
42810
+ if (visibleScope === null)
42811
+ return "ambiguous";
42812
+ const declarationCount = analysis.declarationScopes.get(name)?.get(visibleScope) ?? 0;
42813
+ const facts = analysis.factScopes.get(name)?.get(visibleScope);
42814
+ if (hasScopedMarker(analysis.requireDerivedScopes, name, visibleScope) && globalDisposition(analysis, "require", callIndex) !== "confirmed") {
42815
+ return "ambiguous";
42816
+ }
42817
+ if (declarationCount !== 1 || hasScopedMarker(analysis.reassignedScopes, name, visibleScope) || !facts || facts.size !== 1) {
42818
+ return "ambiguous";
42819
+ }
42820
+ if (facts.has(confirmedFact))
42821
+ return "confirmed";
42822
+ if (facts.has("other-import") || facts.has("regex"))
42823
+ return "safe";
42824
+ return "ambiguous";
42825
+ }
42826
+ function globalDisposition(analysis, name, callIndex) {
42827
+ const visibleScope = visibleDeclarationScope(analysis, name, callIndex);
42828
+ if (visibleScope === null && !hasVisibleMarker(analysis, analysis.reassignedScopes, name, callIndex)) {
42829
+ return "confirmed";
42830
+ }
42831
+ const facts = visibleScope === null ? undefined : analysis.factScopes.get(name)?.get(visibleScope);
42832
+ if (facts?.size === 1 && facts.has("other-import") && visibleScope !== null && analysis.declarationScopes.get(name)?.get(visibleScope) === 1 && !hasScopedMarker(analysis.reassignedScopes, name, visibleScope)) {
42833
+ return "safe";
42834
+ }
42835
+ return "ambiguous";
42836
+ }
42837
+ function firstArgument(tokens, openParen) {
42838
+ return tokens[openParen + 1];
42839
+ }
42840
+ function oversizedCandidate(match, family) {
42841
+ const expected = family === "exec" ? ["exec"] : family === "eval" ? ["eval"] : family === "function-constructor" ? ["Function"] : family === "timer-string" ? ["setTimeout", "setInterval"] : family === "document-write" ? ["write"] : ["addEventListener"];
42842
+ return expected.includes(match.text) ? "ambiguous" : "none";
42843
+ }
42844
+ function classifyJavascriptCallUncached(match, context, family) {
42845
+ const analysis = getAnalysis(context);
42846
+ if (analysis.oversizedOrMalformed)
42847
+ return oversizedCandidate(match, family);
42848
+ const offset = (analysis.lineStarts[match.line - 1] ?? 0) + match.column - 1;
42849
+ const tokenIndex = tokenIndexAtOffset(analysis.tokens, offset);
42850
+ if (tokenIndex < 0)
42851
+ return "none";
42852
+ const callee = parseCallee(analysis.tokens, tokenIndex);
42853
+ if (!callee)
42854
+ return "none";
42855
+ const argument = firstArgument(analysis.tokens, callee.openParen);
42856
+ switch (family) {
42857
+ case "exec":
42858
+ if (!argument || argument.value === ")")
42859
+ return "none";
42860
+ if (callee.receiverKind === "regex")
42861
+ return "safe";
42862
+ if (callee.receiverKind === "direct-child-require") {
42863
+ if (callee.name !== "exec")
42864
+ return "none";
42865
+ return globalDisposition(analysis, "require", tokenIndex) === "confirmed" ? "confirmed" : "ambiguous";
42866
+ }
42867
+ if (callee.receiver) {
42868
+ if (callee.name !== "exec")
42869
+ return "none";
42870
+ if (hasScopedMarker(analysis.mutatedMemberScopes, callee.receiver, visibleDeclarationScope(analysis, callee.receiver, tokenIndex))) {
42871
+ return "ambiguous";
42872
+ }
42873
+ return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex);
42874
+ }
42875
+ if (callee.name === "exec" || factsAtVisibleScope(analysis, callee.name, tokenIndex)?.has("child-direct")) {
42876
+ return bindingDisposition(analysis, callee.name, "child-direct", tokenIndex);
42877
+ }
42878
+ return "none";
42879
+ case "eval":
42880
+ if (callee.name !== "eval")
42881
+ return "none";
42882
+ if (callee.receiver) {
42883
+ if (["globalThis", "window", "self"].includes(callee.receiver)) {
42884
+ return globalDisposition(analysis, callee.receiver, tokenIndex);
42885
+ }
42886
+ return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex) === "safe" ? "safe" : "ambiguous";
42887
+ }
42888
+ return globalDisposition(analysis, "eval", tokenIndex);
42889
+ case "function-constructor":
42890
+ if (callee.name !== "Function" || analysis.tokens[tokenIndex - 1]?.value !== "new")
42891
+ return "none";
42892
+ return globalDisposition(analysis, "Function", tokenIndex);
42893
+ case "timer-string":
42894
+ if (!["setTimeout", "setInterval"].includes(callee.name) || !argument || !["string", "template"].includes(argument.kind))
42895
+ return "none";
42896
+ if (callee.receiver) {
42897
+ if (["globalThis", "window", "self"].includes(callee.receiver))
42898
+ return globalDisposition(analysis, callee.receiver, tokenIndex);
42899
+ return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex) === "safe" ? "safe" : "ambiguous";
42900
+ }
42901
+ return globalDisposition(analysis, callee.name, tokenIndex);
42902
+ case "document-write":
42903
+ if (callee.name !== "write" || callee.receiver !== "document")
42904
+ return "none";
42905
+ return globalDisposition(analysis, "document", tokenIndex) === "confirmed" ? "confirmed" : "ambiguous";
42906
+ case "postmessage":
42907
+ if (callee.name !== "addEventListener" || argument?.kind !== "string" || argument.value !== "message")
42908
+ return "none";
42909
+ if (callee.receiver) {
42910
+ if (["globalThis", "window", "self"].includes(callee.receiver))
42911
+ return globalDisposition(analysis, callee.receiver, tokenIndex);
42912
+ return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex) === "safe" ? "safe" : "ambiguous";
42913
+ }
42914
+ return globalDisposition(analysis, "addEventListener", tokenIndex);
42915
+ }
42916
+ }
42917
+ function classifyJavascriptCall(match, context, family) {
42918
+ const key = `${family}:${match.line}:${match.column}:${match.text}`;
42919
+ const cache2 = dispositionByContext.get(context) ?? new Map;
42920
+ const cached = cache2.get(key);
42921
+ if (cached !== undefined)
42922
+ return cached;
42923
+ const disposition = classifyJavascriptCallUncached(match, context, family);
42924
+ cache2.set(key, disposition);
42925
+ dispositionByContext.set(context, cache2);
42926
+ return disposition;
42927
+ }
42928
+
41961
42929
  // src/sast/rules/javascript.ts
42930
+ function hasDisposition(family, disposition) {
42931
+ return (match, context) => classifyJavascriptCall(match, context, family) === disposition;
42932
+ }
41962
42933
  var javascriptRules = [
41963
42934
  {
41964
42935
  id: "sast/js-eval",
@@ -41967,7 +42938,18 @@ var javascriptRules = [
41967
42938
  languages: ["javascript", "typescript"],
41968
42939
  description: "Dangerous use of eval() detected - allows arbitrary code execution",
41969
42940
  remediation: "Avoid using eval(). If you must parse dynamic content, use JSON.parse() or a proper parser instead.",
41970
- pattern: /\beval\s*\(/
42941
+ pattern: /\beval\b/,
42942
+ validate: hasDisposition("eval", "confirmed")
42943
+ },
42944
+ {
42945
+ id: "sast/js-eval-review",
42946
+ name: "Unresolved eval-like call",
42947
+ severity: "low",
42948
+ languages: ["javascript", "typescript"],
42949
+ description: "Unresolved eval-like call requires manual review",
42950
+ remediation: "Verify the callee binding and avoid dynamic code evaluation.",
42951
+ pattern: /\beval\b/,
42952
+ validate: hasDisposition("eval", "ambiguous")
41971
42953
  },
41972
42954
  {
41973
42955
  id: "sast/js-dangerous-function",
@@ -41976,7 +42958,18 @@ var javascriptRules = [
41976
42958
  languages: ["javascript", "typescript"],
41977
42959
  description: "Dangerous use of new Function() detected - allows arbitrary code execution",
41978
42960
  remediation: "Avoid using new Function(). Use a safer alternative like JSON.parse() or a proper expression parser.",
41979
- pattern: /\bnew\s+Function\s*\(/
42961
+ pattern: /\bFunction\b/,
42962
+ validate: hasDisposition("function-constructor", "confirmed")
42963
+ },
42964
+ {
42965
+ id: "sast/js-function-constructor-review",
42966
+ name: "Unresolved Function-like constructor",
42967
+ severity: "low",
42968
+ languages: ["javascript", "typescript"],
42969
+ description: "Unresolved Function-like constructor requires manual review",
42970
+ remediation: "Verify the constructor binding and avoid dynamic code construction.",
42971
+ pattern: /\bFunction\b/,
42972
+ validate: hasDisposition("function-constructor", "ambiguous")
41980
42973
  },
41981
42974
  {
41982
42975
  id: "sast/js-command-injection",
@@ -41985,10 +42978,18 @@ var javascriptRules = [
41985
42978
  languages: ["javascript", "typescript"],
41986
42979
  description: "Potential command injection via child_process.exec() with unsanitized input",
41987
42980
  remediation: "Never pass user input directly to exec(). Use execFile() with arguments array or sanitize input thoroughly.",
41988
- pattern: /exec\s*\(\s*(?:[`'"]|\w)/,
41989
- validate: (_match, _context) => {
41990
- return true;
41991
- }
42981
+ pattern: /[A-Za-z_$][\w$]*/,
42982
+ validate: hasDisposition("exec", "confirmed")
42983
+ },
42984
+ {
42985
+ id: "sast/js-command-exec-review",
42986
+ name: "Unresolved exec-like call",
42987
+ severity: "low",
42988
+ languages: ["javascript", "typescript"],
42989
+ description: "Unresolved exec-like call requires manual review",
42990
+ remediation: "Verify whether the callee reaches child_process; prefer execFile() with an arguments array.",
42991
+ pattern: /[A-Za-z_$][\w$]*/,
42992
+ validate: hasDisposition("exec", "ambiguous")
41992
42993
  },
41993
42994
  {
41994
42995
  id: "sast/js-set-timeout-string",
@@ -41997,7 +42998,18 @@ var javascriptRules = [
41997
42998
  languages: ["javascript", "typescript"],
41998
42999
  description: "setTimeout/setInterval called with string argument - similar to eval()",
41999
43000
  remediation: 'Use function references instead of strings: setTimeout(() => ..., 1000) instead of setTimeout("...", 1000)',
42000
- pattern: /(?:setTimeout|setInterval)\s*\(\s*['"`]/
43001
+ pattern: /\b(?:setTimeout|setInterval)\b/,
43002
+ validate: hasDisposition("timer-string", "confirmed")
43003
+ },
43004
+ {
43005
+ id: "sast/js-timer-string-review",
43006
+ name: "Unresolved string timer call",
43007
+ severity: "low",
43008
+ languages: ["javascript", "typescript"],
43009
+ description: "Unresolved string timer call requires manual review",
43010
+ remediation: "Verify the timer binding and replace string callbacks with functions.",
43011
+ pattern: /\b(?:setTimeout|setInterval)\b/,
43012
+ validate: hasDisposition("timer-string", "ambiguous")
42001
43013
  },
42002
43014
  {
42003
43015
  id: "sast/js-innerhtml",
@@ -42015,7 +43027,18 @@ var javascriptRules = [
42015
43027
  languages: ["javascript", "typescript"],
42016
43028
  description: "document.write() can introduce XSS vulnerabilities",
42017
43029
  remediation: "Use DOM manipulation methods (createElement, appendChild, textContent) instead.",
42018
- pattern: /document\.write\s*\(/
43030
+ pattern: /\bwrite\b/,
43031
+ validate: hasDisposition("document-write", "confirmed")
43032
+ },
43033
+ {
43034
+ id: "sast/js-document-write-review",
43035
+ name: "Unresolved document.write-like call",
43036
+ severity: "low",
43037
+ languages: ["javascript", "typescript"],
43038
+ description: "Unresolved document.write-like call requires manual review",
43039
+ remediation: "Verify the document binding and use safe DOM construction.",
43040
+ pattern: /\bwrite\b/,
43041
+ validate: hasDisposition("document-write", "ambiguous")
42019
43042
  },
42020
43043
  {
42021
43044
  id: "sast/js-postmessage",
@@ -42024,7 +43047,18 @@ var javascriptRules = [
42024
43047
  languages: ["javascript", "typescript"],
42025
43048
  description: "postMessage event listener without origin validation",
42026
43049
  remediation: "Always validate the origin in postMessage event handlers: event.origin === expectedOrigin",
42027
- pattern: /addEventListener\s*\(\s*['"]message['"]/
43050
+ pattern: /\baddEventListener\b/,
43051
+ validate: hasDisposition("postmessage", "confirmed")
43052
+ },
43053
+ {
43054
+ id: "sast/js-postmessage-review",
43055
+ name: "Unresolved message-listener call",
43056
+ severity: "low",
43057
+ languages: ["javascript", "typescript"],
43058
+ description: "Unresolved message-listener call requires manual review",
43059
+ remediation: "Verify the event target and validate message origins where applicable.",
43060
+ pattern: /\baddEventListener\b/,
43061
+ validate: hasDisposition("postmessage", "ambiguous")
42028
43062
  },
42029
43063
  {
42030
43064
  id: "sast/js-hardcoded-secret",
@@ -42334,23 +43368,23 @@ function executeRulesSync(filePath, content, language) {
42334
43368
  const findings = [];
42335
43369
  const normalizedLang = language.toLowerCase();
42336
43370
  const rules = getRulesForLanguage(normalizedLang);
43371
+ const lines = content.split(`
43372
+ `);
43373
+ const context = {
43374
+ filePath,
43375
+ content,
43376
+ language: normalizedLang
43377
+ };
42337
43378
  for (const rule of rules) {
42338
43379
  if (!rule.pattern)
42339
43380
  continue;
42340
43381
  const matches = findPatternMatches(content, rule.pattern);
42341
43382
  for (const match of matches) {
42342
43383
  if (rule.validate) {
42343
- const context = {
42344
- filePath,
42345
- content,
42346
- language: normalizedLang
42347
- };
42348
43384
  if (!rule.validate(match, context)) {
42349
43385
  continue;
42350
43386
  }
42351
43387
  }
42352
- const lines = content.split(`
42353
- `);
42354
43388
  const excerpt = lines[match.line - 1]?.trim() || "";
42355
43389
  findings.push({
42356
43390
  rule_id: rule.id,
@@ -61096,9 +62130,12 @@ function comparePriority(a, b) {
61096
62130
  return priorityDiff;
61097
62131
  return a.createdAt - b.createdAt;
61098
62132
  }
62133
+ var MAX_TERMINAL_IDS = 2048;
61099
62134
 
61100
62135
  class AutomationQueue {
61101
62136
  items = [];
62137
+ inflight = new Map;
62138
+ terminalIds = new Map;
61102
62139
  maxSize;
61103
62140
  defaultMaxRetries;
61104
62141
  defaultBackoffMs;
@@ -61153,49 +62190,86 @@ class AutomationQueue {
61153
62190
  return item.id;
61154
62191
  }
61155
62192
  dequeue() {
61156
- const item = this.items.shift();
61157
- if (item) {
61158
- this.eventBus.publish("queue.item.dequeued", { itemId: item.id });
61159
- }
62193
+ if (this.inflight.size >= this.maxSize)
62194
+ return;
62195
+ const now2 = Date.now();
62196
+ const index = this.items.findIndex((item2) => item2.retry?.nextAttemptAt === undefined || item2.retry.nextAttemptAt <= now2);
62197
+ if (index === -1)
62198
+ return;
62199
+ const [item] = this.items.splice(index, 1);
62200
+ if (!item)
62201
+ return;
62202
+ this.inflight.set(item.id, item);
62203
+ this.eventBus.publish("queue.item.dequeued", { itemId: item.id });
61160
62204
  return item;
61161
62205
  }
61162
62206
  peek() {
61163
62207
  return this.items[0];
61164
62208
  }
61165
62209
  get(id) {
61166
- return this.items.find((item) => item.id === id);
62210
+ return this.items.find((item) => item.id === id) ?? this.inflight.get(id);
61167
62211
  }
61168
- remove(id) {
61169
- const index = this.items.findIndex((item) => item.id === id);
61170
- if (index !== -1) {
61171
- this.items.splice(index, 1);
61172
- return true;
62212
+ inflightSize() {
62213
+ return this.inflight.size;
62214
+ }
62215
+ removeQueuedOrInflight(id) {
62216
+ const queuedIndex = this.items.findIndex((item) => item.id === id);
62217
+ if (queuedIndex !== -1) {
62218
+ const [removed] = this.items.splice(queuedIndex, 1);
62219
+ return removed;
61173
62220
  }
61174
- return false;
62221
+ const inflightItem = this.inflight.get(id);
62222
+ if (inflightItem)
62223
+ this.inflight.delete(id);
62224
+ return inflightItem;
61175
62225
  }
61176
- complete(id) {
61177
- const removed = this.remove(id);
61178
- if (removed) {
61179
- this.eventBus.publish("queue.item.completed", { itemId: id });
62226
+ markTerminal(id, at) {
62227
+ this.terminalIds.set(id, at);
62228
+ if (this.terminalIds.size > MAX_TERMINAL_IDS) {
62229
+ const oldest = this.terminalIds.keys().next().value;
62230
+ if (oldest !== undefined)
62231
+ this.terminalIds.delete(oldest);
61180
62232
  }
61181
- return removed;
62233
+ }
62234
+ remove(id) {
62235
+ if (this.terminalIds.has(id))
62236
+ return false;
62237
+ return this.removeQueuedOrInflight(id) !== undefined;
62238
+ }
62239
+ complete(id) {
62240
+ if (this.terminalIds.has(id))
62241
+ return false;
62242
+ const removed = this.removeQueuedOrInflight(id);
62243
+ if (!removed)
62244
+ return false;
62245
+ this.markTerminal(id, Date.now());
62246
+ this.eventBus.publish("queue.item.completed", { itemId: id });
62247
+ return true;
61182
62248
  }
61183
62249
  retry(id, _error) {
62250
+ if (this.terminalIds.has(id))
62251
+ return false;
61184
62252
  const item = this.get(id);
61185
62253
  if (!item || !item.retry)
61186
62254
  return false;
61187
62255
  item.retry.attempts++;
61188
62256
  item.retry.lastAttempt = Date.now();
61189
62257
  if (item.retry.attempts >= item.retry.maxAttempts) {
62258
+ this.removeQueuedOrInflight(id);
62259
+ this.markTerminal(id, Date.now());
61190
62260
  this.eventBus.publish("queue.item.failed", {
61191
62261
  itemId: id,
61192
62262
  attempts: item.retry.attempts
61193
62263
  });
61194
- this.remove(id);
61195
62264
  return false;
61196
62265
  }
61197
62266
  const backoff = Math.min(item.retry.backoffMs * 2 ** (item.retry.attempts - 1), item.retry.maxBackoffMs);
61198
62267
  item.retry.nextAttemptAt = Date.now() + backoff;
62268
+ this.inflight.delete(id);
62269
+ if (!this.items.some((queued) => queued.id === id)) {
62270
+ this.items.push(item);
62271
+ this.items.sort(comparePriority);
62272
+ }
61199
62273
  this.eventBus.publish("queue.item.retry scheduled", {
61200
62274
  itemId: id,
61201
62275
  attempt: item.retry.attempts,
@@ -61218,7 +62292,14 @@ class AutomationQueue {
61218
62292
  return this.items.length >= this.maxSize;
61219
62293
  }
61220
62294
  clear() {
62295
+ for (const item of this.items) {
62296
+ this.eventBus.publish("queue.item.evicted", { itemId: item.id });
62297
+ }
61221
62298
  this.items = [];
62299
+ for (const item of this.inflight.values()) {
62300
+ this.eventBus.publish("queue.item.evicted", { itemId: item.id });
62301
+ }
62302
+ this.inflight.clear();
61222
62303
  }
61223
62304
  getAll() {
61224
62305
  return [...this.items];
@@ -61236,7 +62317,8 @@ class AutomationQueue {
61236
62317
  normal: this.items.filter((i) => i.priority === "normal").length,
61237
62318
  low: this.items.filter((i) => i.priority === "low").length
61238
62319
  },
61239
- retryable: this.getRetryableItems().length
62320
+ retryable: this.getRetryableItems().length,
62321
+ inflight: this.inflight.size
61240
62322
  };
61241
62323
  }
61242
62324
  }
@@ -61390,7 +62472,8 @@ class WorkerManager {
61390
62472
  processedCount: worker.processedCount,
61391
62473
  errorCount: worker.errorCount,
61392
62474
  lastError: worker.lastError,
61393
- queueSize: worker.queue.size()
62475
+ queueSize: worker.queue.size(),
62476
+ queueInflight: worker.queue.inflightSize()
61394
62477
  };
61395
62478
  }
61396
62479
  getWorkerNames() {
@@ -68321,7 +69404,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
68321
69404
  if (!input.dispatcher) {
68322
69405
  throw new Error("no evaluation dispatcher available (cannot run validation)");
68323
69406
  }
68324
- const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-9g2pcg10.js");
69407
+ const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-rk26nk58.js");
68325
69408
  const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
68326
69409
  const result = await _internals95.evaluateCandidateV1({
68327
69410
  projectRoot: input.directory,
@@ -69237,6 +70320,73 @@ var _internals96 = {
69237
70320
  getActiveFullAutoSessionID,
69238
70321
  loadFullAutoRunState
69239
70322
  };
70323
+ async function collectBackgroundWorkStatus(directory) {
70324
+ try {
70325
+ await maintainBackgroundDelegations(directory, {
70326
+ lockTimeoutMs: 2000,
70327
+ reason: "status"
70328
+ });
70329
+ } catch {}
70330
+ const counts = {
70331
+ pending: 0,
70332
+ running: 0,
70333
+ completed: 0,
70334
+ consumed: 0,
70335
+ stale: 0,
70336
+ cancelled: 0,
70337
+ error: 0,
70338
+ ingestion_error: 0
70339
+ };
70340
+ const maintenance = readDelegationHealthArtifact(directory)?.maintenance ?? null;
70341
+ const empty = {
70342
+ counts,
70343
+ reservations: [],
70344
+ maintenance,
70345
+ source: "uncertain"
70346
+ };
70347
+ let scan;
70348
+ try {
70349
+ scan = scanDelegationsForRecovery(directory);
70350
+ } catch (error2) {
70351
+ return {
70352
+ ...empty,
70353
+ uncertainty: `delegation recovery scan failed: ${error2 instanceof Error ? error2.message : String(error2)}`
70354
+ };
70355
+ }
70356
+ if (scan.status === "uncertain") {
70357
+ return {
70358
+ ...empty,
70359
+ uncertainty: `delegation ledger over its recovery bound or corrupt: ${scan.reason}`
70360
+ };
70361
+ }
70362
+ const reservationScan = scanBackgroundCoderReservationsForAdmission(directory);
70363
+ if (reservationScan.status === "uncertain") {
70364
+ return {
70365
+ ...empty,
70366
+ uncertainty: `coder reservation store unreadable: ${reservationScan.reason}`
70367
+ };
70368
+ }
70369
+ for (const record of scan.owners) {
70370
+ if (record.status in counts) {
70371
+ counts[record.status] += 1;
70372
+ }
70373
+ }
70374
+ const now2 = Date.now();
70375
+ const reservations = reservationScan.reservations.map((reservation) => ({
70376
+ reservationId: reservation.reservationId,
70377
+ planTaskId: reservation.planTaskId,
70378
+ generation: reservation.generation ?? 1,
70379
+ state: reservation.state,
70380
+ leaseState: reservation.leaseExpiresAt === undefined ? "protected-legacy" : reservation.leaseExpiresAt > now2 ? "active" : "expired",
70381
+ ...reservation.leaseExpiresAt !== undefined ? { leaseExpiresAt: reservation.leaseExpiresAt } : {}
70382
+ }));
70383
+ return {
70384
+ counts,
70385
+ reservations,
70386
+ maintenance,
70387
+ source: "validated-recovery"
70388
+ };
70389
+ }
69240
70390
  function formatLedgerBytes(bytes) {
69241
70391
  if (bytes >= 1024 * 1024) {
69242
70392
  return `${Math.round(bytes / (1024 * 1024) * 10) / 10} MiB`;
@@ -69276,7 +70426,7 @@ function formatAgo(ms) {
69276
70426
  const days = Math.floor(hours / 24);
69277
70427
  return `${days}d ago`;
69278
70428
  }
69279
- async function getStatusData(directory, agents, sessionId) {
70429
+ async function getStatusData(directory, agents, sessionId, options) {
69280
70430
  const plan = await loadPlan(directory);
69281
70431
  let status;
69282
70432
  if (plan && plan.migration_status !== "migration_failed") {
@@ -69372,6 +70522,16 @@ async function getStatusData(directory, agents, sessionId) {
69372
70522
  } catch {
69373
70523
  status.delegationLedgerHealth = undefined;
69374
70524
  }
70525
+ const backgroundSubagentsEnabled = options?.backgroundSubagents ?? (() => {
70526
+ try {
70527
+ return loadPluginConfig(directory)?.hooks?.background_subagents === true;
70528
+ } catch {
70529
+ return false;
70530
+ }
70531
+ })();
70532
+ if (backgroundSubagentsEnabled) {
70533
+ status.backgroundWork = await collectBackgroundWorkStatus(directory);
70534
+ }
69375
70535
  try {
69376
70536
  const pointer = readLinkPointer(directory);
69377
70537
  if (pointer) {
@@ -69696,12 +70856,64 @@ function formatStatusMarkdown(status) {
69696
70856
  lines.push(` - Live set: ${counts.activeOwners} active owners, ${counts.pendingAdvisories} pending advisories, ${counts.lateTerminals} late terminals, ${counts.orphanWorktreeOwners} unsettled worktree owners`);
69697
70857
  }
69698
70858
  }
70859
+ const backgroundWork = status.backgroundWork;
70860
+ if (backgroundWork) {
70861
+ lines.push(...renderBackgroundWorkLines(backgroundWork));
70862
+ }
69699
70863
  return lines.join(`
69700
70864
  `);
69701
70865
  }
69702
- async function handleStatusCommand(directory, agents, sessionId) {
69703
- const statusData = await getStatusData(directory, agents, sessionId);
70866
+ function renderBackgroundWorkLines(backgroundWork) {
70867
+ const lines = ["", "**Background Work** (opt-in):"];
70868
+ if (backgroundWork.source === "uncertain") {
70869
+ lines.push(` - \u26A0 State uncertain: ${backgroundWork.uncertainty ?? "unknown reason"} \u2014 counts and reservations are not shown rather than partially trusted`);
70870
+ } else {
70871
+ const counts = backgroundWork.counts;
70872
+ lines.push(` - Delegations: ${counts.pending} pending, ${counts.running} running, ${counts.completed} completed (unconsumed), ${counts.consumed} consumed, ${counts.stale} stale, ${counts.cancelled} cancelled, ${counts.error} error, ${counts.ingestion_error} ingestion_error`);
70873
+ if (backgroundWork.reservations.length > 0) {
70874
+ lines.push(` - Reservations (${backgroundWork.reservations.length} active):`);
70875
+ for (const reservation of backgroundWork.reservations) {
70876
+ const lease = reservation.leaseState === "active" && reservation.leaseExpiresAt ? `active until ${new Date(reservation.leaseExpiresAt).toISOString()}` : reservation.leaseState;
70877
+ lines.push(` - ${reservation.reservationId.slice(0, 12)}\u2026 ${reservation.state} gen ${reservation.generation} task ${reservation.planTaskId ?? "(call-scoped)"} \u2014 lease ${lease}`);
70878
+ }
70879
+ } else {
70880
+ lines.push(" - Reservations: none");
70881
+ }
70882
+ lines.push(" - Source: validated recovery (bounded scan)");
70883
+ }
70884
+ const maintenance = backgroundWork.maintenance;
70885
+ if (maintenance) {
70886
+ if (maintenance.lastOkAt !== null) {
70887
+ const summary = maintenance.lastSummary;
70888
+ lines.push(` - Maintenance: last ok ${new Date(maintenance.lastOkAt).toISOString()} (swept ${summary.sweptStale}, released ${summary.released}, renewed ${summary.renewed}, retained ${summary.retained})`);
70889
+ } else {
70890
+ lines.push(" - Maintenance: no successful run recorded");
70891
+ }
70892
+ if (maintenance.lastFailure) {
70893
+ lines.push(` - \u26A0 Last maintenance failure (${new Date(maintenance.lastFailure.at).toISOString()}): ${maintenance.lastFailure.reason}`);
70894
+ }
70895
+ if (maintenance.lastContentionAt !== null) {
70896
+ lines.push(` - \u26A0 Last maintenance lock contention: ${new Date(maintenance.lastContentionAt).toISOString()}`);
70897
+ }
70898
+ if (maintenance.facts.length > 0) {
70899
+ lines.push(` - Recent maintenance facts (${maintenance.facts.length}):`);
70900
+ for (const fact of maintenance.facts.slice(-5).reverse()) {
70901
+ const target = fact.reservationId ? ` ${fact.reservationId.slice(0, 12)}\u2026` : fact.correlationId ? ` ${fact.correlationId.slice(0, 12)}\u2026` : "";
70902
+ lines.push(` - ${new Date(fact.at).toISOString()} ${fact.kind}${target} \u2014 ${fact.reason}`);
70903
+ }
70904
+ }
70905
+ }
70906
+ return lines;
70907
+ }
70908
+ async function handleStatusCommand(directory, agents, sessionId, options) {
70909
+ const statusData = await getStatusData(directory, agents, sessionId, options);
69704
70910
  if (!statusData.hasPlan) {
70911
+ if (statusData.backgroundWork) {
70912
+ const lines = ["No active swarm plan found."];
70913
+ lines.push(...renderBackgroundWorkLines(statusData.backgroundWork));
70914
+ return lines.join(`
70915
+ `);
70916
+ }
69705
70917
  if (statusData.specStale) {
69706
70918
  const reason = statusData.specStaleReason ?? "spec.md changed since plan saved";
69707
70919
  const stored = statusData.specStaleStoredHash ?? "unknown";
@@ -70227,7 +71439,7 @@ function buildDetailedHelp(commandName, entry) {
70227
71439
  async function handleHelpCommand(ctx) {
70228
71440
  const targetCommand = ctx.args.join(" ");
70229
71441
  if (!targetCommand) {
70230
- const { buildHelpText } = await import("./index-kn36sxj0.js");
71442
+ const { buildHelpText } = await import("./index-ag9bv589.js");
70231
71443
  return buildHelpText();
70232
71444
  }
70233
71445
  const tokens = targetCommand.split(/\s+/);
@@ -70236,7 +71448,7 @@ async function handleHelpCommand(ctx) {
70236
71448
  return _internals98.buildDetailedHelp(resolved.key, resolved.entry);
70237
71449
  }
70238
71450
  const similar = _internals98.findSimilarCommands(targetCommand);
70239
- const { buildHelpText: fullHelp } = await import("./index-kn36sxj0.js");
71451
+ const { buildHelpText: fullHelp } = await import("./index-ag9bv589.js");
70240
71452
  if (similar.length > 0) {
70241
71453
  return `Command '/swarm ${targetCommand}' not found.
70242
71454
 
@@ -70416,7 +71628,7 @@ var COMMAND_REGISTRY = {
70416
71628
  },
70417
71629
  "guardrail explain": {
70418
71630
  handler: async (ctx) => {
70419
- const { handleGuardrailExplain } = await import("./guardrail-explain-fnnka0vt.js");
71631
+ const { handleGuardrailExplain } = await import("./guardrail-explain-a8706sq1.js");
70420
71632
  return handleGuardrailExplain(ctx.directory, ctx.args);
70421
71633
  },
70422
71634
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -70426,7 +71638,7 @@ var COMMAND_REGISTRY = {
70426
71638
  },
70427
71639
  "guardrail reset": {
70428
71640
  handler: async (ctx) => {
70429
- const { handleGuardrailReset } = await import("./guardrail-reset-kk1rdmm0.js");
71641
+ const { handleGuardrailReset } = await import("./guardrail-reset-sy0vztrd.js");
70430
71642
  return handleGuardrailReset(ctx.args, ctx.sessionID);
70431
71643
  },
70432
71644
  description: "Reset one exact active invocation/action circuit after repair",
@@ -70435,7 +71647,7 @@ var COMMAND_REGISTRY = {
70435
71647
  },
70436
71648
  "guardrail-explain": {
70437
71649
  handler: async (ctx) => {
70438
- const { handleGuardrailExplain } = await import("./guardrail-explain-fnnka0vt.js");
71650
+ const { handleGuardrailExplain } = await import("./guardrail-explain-a8706sq1.js");
70439
71651
  return handleGuardrailExplain(ctx.directory, ctx.args);
70440
71652
  },
70441
71653
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -70445,7 +71657,7 @@ var COMMAND_REGISTRY = {
70445
71657
  },
70446
71658
  "guardrail-reset": {
70447
71659
  handler: async (ctx) => {
70448
- const { handleGuardrailReset } = await import("./guardrail-reset-kk1rdmm0.js");
71660
+ const { handleGuardrailReset } = await import("./guardrail-reset-sy0vztrd.js");
70449
71661
  return handleGuardrailReset(ctx.args, ctx.sessionID);
70450
71662
  },
70451
71663
  description: "Reset one exact active invocation/action circuit after repair",
@@ -70455,7 +71667,7 @@ var COMMAND_REGISTRY = {
70455
71667
  },
70456
71668
  "guardrail-log": {
70457
71669
  handler: async (ctx) => {
70458
- const { handleGuardrailLog } = await import("./guardrail-log-gsx9kj51.js");
71670
+ const { handleGuardrailLog } = await import("./guardrail-log-wx43bj32.js");
70459
71671
  return handleGuardrailLog(ctx.directory, ctx.args);
70460
71672
  },
70461
71673
  description: "Read the guardrail decision log (use --blocks-only for blocks)",
@@ -76882,7 +78094,7 @@ function getDisplayBudget() {
76882
78094
  async function rehydratePrSubscriptions(sessionID, directory) {
76883
78095
  const map = new Map;
76884
78096
  try {
76885
- const { listActive: listActive2 } = await import("./pr-subscriptions-9mg6mwc0.js");
78097
+ const { listActive: listActive2 } = await import("./pr-subscriptions-f4xw1rxy.js");
76886
78098
  const records = await listActive2(directory);
76887
78099
  for (const record of records) {
76888
78100
  if (record.sessionID !== sessionID)
@@ -77298,7 +78510,7 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
77298
78510
  return extracted === expectedSessionId;
77299
78511
  }
77300
78512
  async function inspectStandardWorktreeCollisionOwnership(identity) {
77301
- const collisionOwnership = await import("./worktree-collision-ownership-e0p490vw.js");
78513
+ const collisionOwnership = await import("./worktree-collision-ownership-wqy7mgb3.js");
77302
78514
  return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
77303
78515
  }
77304
78516
  async function precreateStandardWorktreeSession(args) {
@@ -77446,7 +78658,7 @@ async function precreateStandardWorktreeSession(args) {
77446
78658
  const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, provisionResult.worktreePath);
77447
78659
  if (laneProfile) {
77448
78660
  try {
77449
- const { writeLaneProfileToDiskReal } = await import("./core-y72nw57z.js");
78661
+ const { writeLaneProfileToDiskReal } = await import("./core-0ph6pb2y.js");
77450
78662
  await writeLaneProfileToDiskReal(provisionResult.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
77451
78663
  } catch {}
77452
78664
  }
@@ -78104,7 +79316,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
78104
79316
  }
78105
79317
  clearWorktreeMergeStatus(statusKey);
78106
79318
  try {
78107
- const { removeLaneProfileFromDiskReal } = await import("./core-y72nw57z.js");
79319
+ const { removeLaneProfileFromDiskReal } = await import("./core-0ph6pb2y.js");
78108
79320
  await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
78109
79321
  } catch {}
78110
79322
  const state = serializationStateBySessionID.get(dispatch.parentSessionID);