opencode-swarm 7.139.3 → 7.139.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 (79) hide show
  1. package/README.md +2 -2
  2. package/dist/cli/{config-doctor-75qky762.js → config-doctor-jgv6h8hd.js} +6 -6
  3. package/dist/cli/{core-nn8ffy5h.js → core-aj5g7an6.js} +4 -4
  4. package/dist/cli/{curation-policy-f46tf3dw.js → curation-policy-9a8xmh4x.js} +7 -7
  5. package/dist/cli/{curator-drift-r52hjskk.js → curator-drift-49p3jnte.js} +6 -6
  6. package/dist/cli/curator-llm-factory-7c5s2cdm.js +61 -0
  7. package/dist/cli/{curator-m6mk2v1n.js → curator-xhzdk0qy.js} +39 -39
  8. package/dist/cli/{dispatch-nbv0hezh.js → dispatch-2s23fbcs.js} +3 -3
  9. package/dist/cli/{evidence-summary-service-sxcq5nrt.js → evidence-summary-service-g82bsjqa.js} +16 -16
  10. package/dist/cli/{gate-evidence-1982qswy.js → gate-evidence-72cgrvs2.js} +6 -5
  11. package/dist/cli/guardrail-explain-vw1kz4k1.js +62 -0
  12. package/dist/cli/{guardrail-log-320grggj.js → guardrail-log-j91e1s6q.js} +8 -8
  13. package/dist/cli/{hive-promoter-v4w7cjvk.js → hive-promoter-5rk01jea.js} +39 -39
  14. package/dist/cli/{index-jqn332jx.js → index-0cyqmr36.js} +2 -2
  15. package/dist/cli/{index-5syvwd8g.js → index-0xkjhgrf.js} +5 -5
  16. package/dist/cli/{index-yh0q21nj.js → index-1kyex7z2.js} +1 -1
  17. package/dist/cli/{index-tkg6rapy.js → index-2ga0zt4s.js} +19404 -19355
  18. package/dist/cli/{index-6mvbjqbt.js → index-33skgk1a.js} +1 -1
  19. package/dist/cli/{index-xsxrhakg.js → index-41hkt36g.js} +1 -1
  20. package/dist/cli/{index-xzzcfwwm.js → index-5z2xps64.js} +2 -2
  21. package/dist/cli/{index-4fr94329.js → index-6nzmp937.js} +53 -108
  22. package/dist/cli/{index-2eet124q.js → index-6r522srn.js} +1 -1
  23. package/dist/cli/{index-4xbyy6aw.js → index-6rxgb5r9.js} +10 -6
  24. package/dist/cli/{index-gen82t10.js → index-6z0a940s.js} +7 -7
  25. package/dist/cli/{index-bcwx1335.js → index-9jr92bff.js} +1 -1
  26. package/dist/cli/{index-z6qe8wft.js → index-9rbwfydj.js} +10 -10
  27. package/dist/cli/{index-mzck763x.js → index-9xczz1yh.js} +2 -2
  28. package/dist/cli/{index-yawwwhmc.js → index-fb11cwqr.js} +6 -6
  29. package/dist/cli/{index-ba5e5e3n.js → index-gee0y2d8.js} +6 -6
  30. package/dist/cli/{index-1yd38ajy.js → index-h2zm446q.js} +4 -4
  31. package/dist/cli/{index-v7g8dnyh.js → index-hhgbbceq.js} +15 -15
  32. package/dist/cli/{index-mv0czd9c.js → index-j77frjq8.js} +6 -6
  33. package/dist/cli/{index-xeyr62x0.js → index-jtg7gtky.js} +5 -5
  34. package/dist/cli/{index-k87hs2ff.js → index-k46me75h.js} +3 -3
  35. package/dist/cli/{index-5hyq2mw6.js → index-ngfw3sd4.js} +43 -43
  36. package/dist/cli/{index-hckq2r5m.js → index-nrx08gcr.js} +6 -2
  37. package/dist/cli/{index-hwnpd4tw.js → index-px7z3r1c.js} +3 -3
  38. package/dist/cli/{index-6axm8q3s.js → index-r2bggfra.js} +7 -7
  39. package/dist/cli/{index-a5eba0t8.js → index-rsrx77fg.js} +6 -6
  40. package/dist/cli/index-s0qc4gj6.js +298 -0
  41. package/dist/cli/{index-ajwmn8gp.js → index-sd657fkp.js} +4 -4
  42. package/dist/cli/{index-0mzz46we.js → index-w9tezcdd.js} +7 -7
  43. package/dist/cli/{index-1jbj7vzv.js → index-wqk50bv0.js} +4 -4
  44. package/dist/cli/{index-05mms0va.js → index-xmhhhjjw.js} +38 -3
  45. package/dist/cli/{index-kyz7259r.js → index-z0tt5j2s.js} +7 -7
  46. package/dist/cli/index.js +41 -41
  47. package/dist/cli/{knowledge-escalator-kkjsjtza.js → knowledge-escalator-rhycg2rh.js} +9 -9
  48. package/dist/cli/{knowledge-events-jbw9j94n.js → knowledge-events-yjkszs87.js} +6 -6
  49. package/dist/cli/{knowledge-link-f6akgbdn.js → knowledge-link-bmbatt8s.js} +5 -5
  50. package/dist/cli/{knowledge-store-m7vnz62z.js → knowledge-store-qe7geq48.js} +7 -7
  51. package/dist/cli/{knowledge-validator-rqj7kech.js → knowledge-validator-rwptbkpz.js} +10 -10
  52. package/dist/cli/{pending-delegations-14544jpr.js → pending-delegations-7ayryxbg.js} +7 -7
  53. package/dist/cli/{pr-subscriptions-qdwfm1a8.js → pr-subscriptions-w5y08ebc.js} +7 -7
  54. package/dist/cli/{runner-mzb3e2s6.js → runner-h7vmgkth.js} +7 -6
  55. package/dist/cli/{scan-cursor-8e6ryhjq.js → scan-cursor-v1zkh6st.js} +8 -8
  56. package/dist/cli/{schema-g7rs20c6.js → schema-9v8wgmxf.js} +3 -3
  57. package/dist/cli/{scope-persistence-wy65zyha.js → scope-persistence-tj6qway9.js} +6 -6
  58. package/dist/cli/{skill-generator-2rv6ftre.js → skill-generator-a91bxwv2.js} +12 -12
  59. package/dist/cli/{telemetry-4tgrfhaz.js → telemetry-62cn5t24.js} +1 -1
  60. package/dist/cli/{worktree-collision-ownership-24s0t62z.js → worktree-collision-ownership-hs5c2qzp.js} +8 -8
  61. package/dist/evidence/manager.d.ts +4 -1
  62. package/dist/index.js +590 -588
  63. package/dist/prm/escalation.d.ts +34 -0
  64. package/dist/prm/index.d.ts +6 -2
  65. package/dist/prm/pattern-detector.d.ts +22 -1
  66. package/dist/prm/types.d.ts +12 -2
  67. package/dist/state.d.ts +49 -0
  68. package/dist/summaries/schema.d.ts +2 -2
  69. package/dist/tools/convene-council.d.ts +1 -1
  70. package/dist/tools/pre-check-batch.d.ts +4 -0
  71. package/dist/tools/resolve-working-directory.d.ts +4 -4
  72. package/dist/tools/submit-phase-council-verdicts.d.ts +1 -1
  73. package/dist/tools/write-final-council-evidence.d.ts +1 -1
  74. package/dist/utils/project-boundary.d.ts +34 -0
  75. package/package.json +1 -1
  76. package/dist/cli/curator-llm-factory-1r9vz0g2.js +0 -61
  77. package/dist/cli/guardrail-explain-y2wg00dp.js +0 -62
  78. package/dist/cli/index-5j6chvj8.js +0 -159
  79. package/dist/cli/{index-z6xqpmqg.js → index-ee3x66a5.js} +3 -3
@@ -6,13 +6,13 @@ import {
6
6
  resolveSwarmKnowledgePath,
7
7
  transactKnowledge,
8
8
  wordBigrams
9
- } from "./index-z6qe8wft.js";
9
+ } from "./index-9rbwfydj.js";
10
10
  import {
11
11
  countEntryContradictionsInWindow,
12
12
  countEntryViolationsInWindow,
13
13
  readKnowledgeEvents,
14
14
  recordKnowledgeEvent
15
- } from "./index-hwnpd4tw.js";
15
+ } from "./index-px7z3r1c.js";
16
16
  import {
17
17
  init_knowledge_types,
18
18
  isActiveStatus
@@ -190,11 +190,11 @@ async function maybeQuarantineOnContradiction(directory, entryId, threshold, win
190
190
  alreadyInactive: true
191
191
  };
192
192
  }
193
- const { quarantineEntry } = await import("./knowledge-validator-rqj7kech.js");
193
+ const { quarantineEntry } = await import("./knowledge-validator-rwptbkpz.js");
194
194
  let policyConfig;
195
195
  try {
196
- const { KnowledgeConfigSchema } = await import("./schema-g7rs20c6.js");
197
- const { loadPluginConfigWithMeta } = await import("./index-v7g8dnyh.js");
196
+ const { KnowledgeConfigSchema } = await import("./schema-9v8wgmxf.js");
197
+ const { loadPluginConfigWithMeta } = await import("./index-hhgbbceq.js");
198
198
  const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
199
199
  policyConfig = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
200
200
  } catch {
@@ -1,10 +1,10 @@
1
1
  // @bun
2
+ import {
3
+ SwarmError
4
+ } from "./index-ee3x66a5.js";
2
5
  import {
3
6
  readCachedTextFile
4
7
  } from "./index-ed5ykebp.js";
5
- import {
6
- SwarmError
7
- } from "./index-z6xqpmqg.js";
8
8
  import {
9
9
  bunFile
10
10
  } from "./index-4nt52yr9.js";
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  handleGuardrailExplain
4
- } from "./index-mzck763x.js";
4
+ } from "./index-9xczz1yh.js";
5
5
  import {
6
6
  handleGuardrailLog
7
- } from "./index-bcwx1335.js";
7
+ } from "./index-9jr92bff.js";
8
8
  import {
9
9
  COMMAND_REGISTRY,
10
10
  SWARM_COMMAND_TOOL_ALLOWLIST,
@@ -84,67 +84,67 @@ import {
84
84
  handleWriteRetroCommand,
85
85
  normalizeSwarmCommandInput,
86
86
  resolveCommand
87
- } from "./index-tkg6rapy.js";
88
- import"./index-xsxrhakg.js";
89
- import"./index-ajwmn8gp.js";
90
- import"./index-0mzz46we.js";
91
- import"./index-1yd38ajy.js";
92
- import"./index-4fr94329.js";
93
- import"./index-hckq2r5m.js";
87
+ } from "./index-2ga0zt4s.js";
88
+ import"./index-41hkt36g.js";
89
+ import"./index-sd657fkp.js";
90
+ import"./index-w9tezcdd.js";
91
+ import"./index-h2zm446q.js";
92
+ import"./index-6nzmp937.js";
93
+ import"./index-nrx08gcr.js";
94
94
  import"./index-y8552snf.js";
95
95
  import"./index-4905hd2m.js";
96
96
  import"./index-134d35c1.js";
97
- import"./index-6axm8q3s.js";
98
- import"./index-xeyr62x0.js";
99
- import"./index-ba5e5e3n.js";
97
+ import"./index-r2bggfra.js";
98
+ import"./index-jtg7gtky.js";
99
+ import"./index-gee0y2d8.js";
100
100
  import"./index-6mjf4vr1.js";
101
101
  import"./index-c8s9a3zh.js";
102
102
  import"./index-9ss2m4rs.js";
103
+ import"./index-0xkjhgrf.js";
104
+ import"./index-xmhhhjjw.js";
105
+ import"./index-556ja8an.js";
106
+ import"./index-6rxgb5r9.js";
107
+ import"./index-1kyex7z2.js";
108
+ import"./index-b8zgtz81.js";
109
+ import"./index-6z0a940s.js";
110
+ import"./index-j77frjq8.js";
111
+ import"./index-k46me75h.js";
112
+ import"./index-ee3x66a5.js";
103
113
  import"./index-74hpm6sh.js";
104
- import"./index-xzzcfwwm.js";
105
- import"./index-1jbj7vzv.js";
106
- import"./index-jqn332jx.js";
114
+ import"./index-5z2xps64.js";
115
+ import"./index-8fwhhayc.js";
116
+ import"./index-q1exe2b3.js";
117
+ import"./index-wqk50bv0.js";
118
+ import"./index-0cyqmr36.js";
107
119
  import"./index-rtry5xyf.js";
108
- import"./index-z6qe8wft.js";
109
- import"./index-hwnpd4tw.js";
120
+ import"./index-9rbwfydj.js";
121
+ import"./index-px7z3r1c.js";
110
122
  import"./index-ae75rja9.js";
111
- import"./index-6mvbjqbt.js";
112
- import"./index-2eet124q.js";
113
- import"./index-yawwwhmc.js";
123
+ import"./index-33skgk1a.js";
124
+ import"./index-6r522srn.js";
125
+ import"./index-ed5ykebp.js";
126
+ import"./index-s0qc4gj6.js";
127
+ import"./index-7g4c7s5r.js";
128
+ import"./index-4nt52yr9.js";
129
+ import"./index-fb11cwqr.js";
114
130
  import"./index-gprxjmm7.js";
115
131
  import"./index-n832052r.js";
132
+ import"./index-1kz6da87.js";
133
+ import"./index-4rhhvd1a.js";
134
+ import"./index-zgwm4ryv.js";
116
135
  import {
117
136
  init_schema,
118
137
  stripKnownSwarmPrefix
119
- } from "./index-kyz7259r.js";
120
- import"./index-bk5tah7q.js";
121
- import"./index-8fwhhayc.js";
122
- import"./index-q1exe2b3.js";
123
- import"./index-5syvwd8g.js";
124
- import"./index-05mms0va.js";
125
- import"./index-556ja8an.js";
126
- import"./index-4xbyy6aw.js";
127
- import"./index-1kz6da87.js";
128
- import"./index-yh0q21nj.js";
129
- import"./index-b8zgtz81.js";
130
- import"./index-gen82t10.js";
131
- import"./index-4rhhvd1a.js";
138
+ } from "./index-z0tt5j2s.js";
132
139
  import {
133
140
  AGENT_TOOL_MAP,
134
141
  ORCHESTRATOR_NAME,
135
142
  init_constants
136
143
  } from "./index-4wjk296r.js";
137
- import"./index-mv0czd9c.js";
138
- import"./index-k87hs2ff.js";
139
- import"./index-ed5ykebp.js";
140
- import"./index-5j6chvj8.js";
141
- import"./index-7g4c7s5r.js";
142
- import"./index-a5eba0t8.js";
143
- import"./index-bpmtbmy9.js";
144
- import"./index-z6xqpmqg.js";
145
144
  import"./index-zjygnfay.js";
146
- import"./index-4nt52yr9.js";
147
- import"./index-zgwm4ryv.js";
145
+ import"./index-bk5tah7q.js";
146
+ import"./index-rsrx77fg.js";
147
+ import"./index-bpmtbmy9.js";
148
148
  import"./index-a76rekgs.js";
149
149
 
150
150
  // src/commands/index.ts
@@ -9,10 +9,11 @@ import {
9
9
  } from "./index-y8552snf.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-2eet124q.js";
12
+ } from "./index-6r522srn.js";
13
13
  import {
14
+ assertProjectRoot,
14
15
  withEvidenceLock
15
- } from "./index-5j6chvj8.js";
16
+ } from "./index-s0qc4gj6.js";
16
17
  import {
17
18
  exports_external,
18
19
  init_zod
@@ -407,6 +408,7 @@ async function readOptionalFile(filePath) {
407
408
  }
408
409
  }
409
410
  async function writeImmutableArtifact(options) {
411
+ assertProjectRoot(options.directory);
410
412
  await mkdir(path.dirname(options.filePath), { recursive: true });
411
413
  return withEvidenceLock(options.directory, options.relativeLockPath, options.agent, options.taskId, async () => {
412
414
  const desired = options.serialize(options.value);
@@ -530,6 +532,7 @@ async function admitEvaluationTask(directory, input, inputRoot = directory) {
530
532
  const relative2 = path2.join("evolution", "tasks", task.split, `${task.id}.json`);
531
533
  const admissionLock = TASK_SPLIT_REGISTRY_RELATIVE;
532
534
  const filePath = swarmPath(directory, relative2);
535
+ assertProjectRoot(directory);
533
536
  await mkdir2(path2.dirname(filePath), { recursive: true });
534
537
  return withEvidenceLock(directory, admissionLock, AGENT, task.id, async () => {
535
538
  const registryPath = swarmPath(directory, TASK_SPLIT_REGISTRY_RELATIVE);
@@ -737,6 +740,7 @@ function parseTestLedger(content) {
737
740
  async function claimHeldOutTest(directory, input) {
738
741
  const claim = TestConsumptionClaimV1Schema.parse(input);
739
742
  const filePath = swarmPath(directory, TEST_LEDGER_RELATIVE);
743
+ assertProjectRoot(directory);
740
744
  await mkdir2(path2.dirname(filePath), { recursive: true });
741
745
  return withEvidenceLock(directory, TEST_LEDGER_RELATIVE, AGENT, claim.runId, async () => {
742
746
  const content = await readOptionalFile(filePath) ?? "";
@@ -4,10 +4,10 @@ import {
4
4
  } from "./index-ae75rja9.js";
5
5
  import {
6
6
  resolveKnowledgeStoreDir
7
- } from "./index-6mvbjqbt.js";
7
+ } from "./index-33skgk1a.js";
8
8
  import {
9
9
  atomicWriteFile
10
- } from "./index-2eet124q.js";
10
+ } from "./index-6r522srn.js";
11
11
  import {
12
12
  require_proper_lockfile
13
13
  } from "./index-7g4c7s5r.js";
@@ -628,7 +628,7 @@ async function applyKnowledgeVerdictFeedback(directory, options) {
628
628
  deltas.push({ id, delta });
629
629
  }
630
630
  if (deltas.length > 0) {
631
- const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-m7vnz62z.js");
631
+ const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-qe7geq48.js");
632
632
  await bumpKnowledgeConfidenceBatch(directory, deltas, options?.floorOptions);
633
633
  }
634
634
  return {
@@ -2,22 +2,18 @@
2
2
  import {
3
3
  ALLOWED_SKILL_PATH_PREFIXES,
4
4
  validateSkillPath
5
- } from "./index-1jbj7vzv.js";
5
+ } from "./index-wqk50bv0.js";
6
6
  import {
7
7
  computeOutcomeSignal,
8
8
  readKnowledge,
9
9
  resolveHiveKnowledgePath,
10
10
  resolveSwarmKnowledgePath,
11
11
  transactKnowledge
12
- } from "./index-z6qe8wft.js";
12
+ } from "./index-9rbwfydj.js";
13
13
  import {
14
14
  effectiveRetrievalOutcomes,
15
15
  readKnowledgeCounterRollups
16
- } from "./index-hwnpd4tw.js";
17
- import {
18
- init_knowledge_types,
19
- isActiveStatus
20
- } from "./index-bk5tah7q.js";
16
+ } from "./index-px7z3r1c.js";
21
17
  import {
22
18
  advisoryWarn,
23
19
  init_warning_buffer
@@ -27,6 +23,10 @@ import {
27
23
  log,
28
24
  warn
29
25
  } from "./index-zgwm4ryv.js";
26
+ import {
27
+ init_knowledge_types,
28
+ isActiveStatus
29
+ } from "./index-bk5tah7q.js";
30
30
  import {
31
31
  __require
32
32
  } from "./index-a76rekgs.js";
@@ -490,7 +490,7 @@ var CATALOG_SOURCE = [
490
490
  category: "evidence",
491
491
  severity: "info",
492
492
  privacyClass: "sensitive",
493
- producer: "src/evidence/lock.ts:94",
493
+ producer: "src/evidence/lock.ts:99",
494
494
  consumers: NO_CONSUMERS,
495
495
  futureOwnerIssue: ISSUE_SINK,
496
496
  retentionOwnerIssue: ISSUE_PLAN_EVIDENCE_RETENTION,
@@ -504,7 +504,7 @@ var CATALOG_SOURCE = [
504
504
  category: "evidence",
505
505
  severity: "notice",
506
506
  privacyClass: "sensitive",
507
- producer: "src/evidence/lock.ts:129",
507
+ producer: "src/evidence/lock.ts:134",
508
508
  consumers: NO_CONSUMERS,
509
509
  futureOwnerIssue: ISSUE_SINK,
510
510
  retentionOwnerIssue: ISSUE_PLAN_EVIDENCE_RETENTION,
@@ -518,7 +518,7 @@ var CATALOG_SOURCE = [
518
518
  category: "evidence",
519
519
  severity: "notice",
520
520
  privacyClass: "sensitive",
521
- producer: "src/evidence/lock.ts:86",
521
+ producer: "src/evidence/lock.ts:91",
522
522
  consumers: NO_CONSUMERS,
523
523
  futureOwnerIssue: ISSUE_SINK,
524
524
  retentionOwnerIssue: ISSUE_PLAN_EVIDENCE_RETENTION,
@@ -532,7 +532,7 @@ var CATALOG_SOURCE = [
532
532
  category: "plan",
533
533
  severity: "notice",
534
534
  privacyClass: "operational",
535
- producer: "src/plan/manager.ts:335",
535
+ producer: "src/plan/manager.ts:336",
536
536
  consumers: NO_CONSUMERS,
537
537
  futureOwnerIssue: ISSUE_SINK,
538
538
  retentionOwnerIssue: ISSUE_PLAN_EVIDENCE_RETENTION,
@@ -545,7 +545,7 @@ var CATALOG_SOURCE = [
545
545
  category: "plan",
546
546
  severity: "warning",
547
547
  privacyClass: "sensitive",
548
- producer: "src/plan/manager.ts:1724",
548
+ producer: "src/plan/manager.ts:1732",
549
549
  consumers: NO_CONSUMERS,
550
550
  futureOwnerIssue: ISSUE_SINK,
551
551
  retentionOwnerIssue: ISSUE_PLAN_EVIDENCE_RETENTION,
@@ -558,7 +558,7 @@ var CATALOG_SOURCE = [
558
558
  category: "plan",
559
559
  severity: "error",
560
560
  privacyClass: "sensitive",
561
- producer: "src/plan/ledger.ts:681",
561
+ producer: "src/plan/ledger.ts:684",
562
562
  consumers: NO_CONSUMERS,
563
563
  futureOwnerIssue: ISSUE_SINK,
564
564
  retentionOwnerIssue: ISSUE_PLAN_EVIDENCE_RETENTION,
@@ -0,0 +1,298 @@
1
+ // @bun
2
+ import {
3
+ require_proper_lockfile
4
+ } from "./index-7g4c7s5r.js";
5
+ import {
6
+ init_logger,
7
+ warn
8
+ } from "./index-zgwm4ryv.js";
9
+ import {
10
+ emit
11
+ } from "./index-rsrx77fg.js";
12
+ import {
13
+ __toESM
14
+ } from "./index-a76rekgs.js";
15
+
16
+ // src/utils/project-boundary.ts
17
+ init_logger();
18
+ import * as fs from "fs";
19
+ import * as os from "os";
20
+ import * as path from "path";
21
+ var MAX_PROJECT_ROOT_DEPTH = 20;
22
+ var PROJECT_ROOT_INDICATORS = [
23
+ "package.json",
24
+ ".git",
25
+ ".opencode",
26
+ "Cargo.toml",
27
+ "go.mod",
28
+ "pyproject.toml",
29
+ "Gemfile",
30
+ "composer.json",
31
+ "pom.xml",
32
+ "build.gradle",
33
+ "CMakeLists.txt"
34
+ ];
35
+ var PROJECT_BOUNDARY_MARKERS = [
36
+ {
37
+ name: ".git",
38
+ accepts: (stat) => stat.isFile() || stat.isDirectory()
39
+ },
40
+ { name: ".opencode", accepts: (stat) => stat.isDirectory() }
41
+ ];
42
+ function isAbsoluteDirectoryInput(value) {
43
+ return typeof value === "string" && value.trim().length > 0 && path.isAbsolute(value);
44
+ }
45
+ function hasExplicitProjectBoundary(directory) {
46
+ if (!isAbsoluteDirectoryInput(directory))
47
+ return false;
48
+ for (const marker of PROJECT_BOUNDARY_MARKERS) {
49
+ try {
50
+ const stat = _internals.lstatSync(path.join(directory, marker.name));
51
+ if (!stat.isSymbolicLink() && marker.accepts(stat))
52
+ return true;
53
+ } catch {}
54
+ }
55
+ return false;
56
+ }
57
+ function isStrictPathDescendant(candidate, root) {
58
+ if (!isAbsoluteDirectoryInput(candidate) || !isAbsoluteDirectoryInput(root)) {
59
+ return false;
60
+ }
61
+ const relative2 = path.relative(root, candidate);
62
+ return relative2 !== "" && relative2 !== ".." && !relative2.startsWith(`..${path.sep}`) && !path.isAbsolute(relative2);
63
+ }
64
+ function isMissingPathError(error) {
65
+ const code = error?.code;
66
+ return code === "ENOENT" || code === "ENOTDIR";
67
+ }
68
+ function isWeakConfigContainerRoot(directory, dependencies) {
69
+ try {
70
+ const resolved = dependencies.realpathSync(directory);
71
+ return resolved === dependencies.realpathSync(os.tmpdir()) || resolved === dependencies.realpathSync(os.homedir());
72
+ } catch {
73
+ const resolved = path.resolve(directory);
74
+ return resolved === path.resolve(os.tmpdir()) || resolved === path.resolve(os.homedir());
75
+ }
76
+ }
77
+ function projectIndicatorState(directory, dependencies, options = {}) {
78
+ const allowConfigOnly = options.allowConfigOnly ?? true;
79
+ for (const indicator of PROJECT_ROOT_INDICATORS) {
80
+ if (!allowConfigOnly && indicator === ".opencode")
81
+ continue;
82
+ try {
83
+ const indicatorStat = dependencies.statSync(path.join(directory, indicator));
84
+ if (indicatorStat.isFile() || indicatorStat.isDirectory())
85
+ return "present";
86
+ } catch (error) {
87
+ if (!isMissingPathError(error))
88
+ return "inaccessible";
89
+ }
90
+ }
91
+ return "absent";
92
+ }
93
+ function assertProjectRoot(directory, dependencies = fs, artifactLabel = "runtime state") {
94
+ let resolved;
95
+ try {
96
+ resolved = dependencies.realpathSync(directory);
97
+ } catch {
98
+ warn(`[project-boundary] Cannot canonicalize directory "${directory}" \u2014 failing closed`);
99
+ throw new Error(`Cannot verify project root for "${directory}" \u2014 directory may not exist or is inaccessible`);
100
+ }
101
+ if (hasExplicitProjectBoundary(resolved))
102
+ return;
103
+ let current = resolved;
104
+ let depth = 0;
105
+ while (true) {
106
+ if (depth >= MAX_PROJECT_ROOT_DEPTH) {
107
+ warn(`[project-boundary] Ancestor search exceeded ${MAX_PROJECT_ROOT_DEPTH} levels for "${resolved}" \u2014 failing closed`);
108
+ throw new Error(`Cannot verify project root for "${resolved}" \u2014 ancestor search exceeded ${MAX_PROJECT_ROOT_DEPTH} levels`);
109
+ }
110
+ depth++;
111
+ const parent = path.dirname(current);
112
+ if (parent === current)
113
+ break;
114
+ if (path.dirname(parent) === parent) {
115
+ current = parent;
116
+ continue;
117
+ }
118
+ const parentSwarm = path.join(parent, ".swarm");
119
+ let parentSwarmStat;
120
+ try {
121
+ parentSwarmStat = dependencies.statSync(parentSwarm);
122
+ } catch (error) {
123
+ if (isMissingPathError(error)) {
124
+ current = parent;
125
+ continue;
126
+ }
127
+ warn(`[project-boundary] Cannot inspect ancestor state "${parentSwarm}" \u2014 failing closed`);
128
+ throw new Error(`Cannot verify project root for "${resolved}" \u2014 ancestor state "${parentSwarm}" is inaccessible`);
129
+ }
130
+ if (parentSwarmStat.isDirectory()) {
131
+ const indicatorState = projectIndicatorState(parent, dependencies, {
132
+ allowConfigOnly: !isWeakConfigContainerRoot(parent, dependencies)
133
+ });
134
+ if (indicatorState === "inaccessible") {
135
+ warn(`[project-boundary] Cannot inspect project indicators in ancestor "${parent}" \u2014 failing closed`);
136
+ throw new Error(`Cannot verify project root for "${resolved}" \u2014 project indicators in ancestor "${parent}" are inaccessible`);
137
+ }
138
+ if (indicatorState === "present") {
139
+ warn(`[project-boundary] Rejecting write to subdirectory "${resolved}" \u2014 parent "${parent}" already contains .swarm/`);
140
+ throw new Error(`Cannot write ${artifactLabel} in "${resolved}" \u2014 parent directory "${parent}" already contains a .swarm/ folder. Runtime state must be written to the project root.`);
141
+ }
142
+ }
143
+ current = parent;
144
+ }
145
+ }
146
+ var _internals = {
147
+ lstatSync: fs.lstatSync
148
+ };
149
+
150
+ // src/parallel/file-locks.ts
151
+ var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
152
+ import * as crypto from "crypto";
153
+ import * as fs2 from "fs";
154
+ import * as path2 from "path";
155
+ var LOCKS_DIR = ".swarm/locks";
156
+ var LOCK_TIMEOUT_MS = 5 * 60 * 1000;
157
+ var _internals2 = {
158
+ tryAcquireLock,
159
+ writeFile: fs2.promises.writeFile
160
+ };
161
+ function getLockFilePath(directory, filePath) {
162
+ const normalized = path2.resolve(directory, filePath);
163
+ const baseDir = path2.resolve(directory) + path2.sep;
164
+ const pathOk = process.platform === "win32" ? normalized.toLowerCase().startsWith(baseDir.toLowerCase()) : normalized.startsWith(baseDir);
165
+ if (!pathOk) {
166
+ throw new Error("Invalid file path: path traversal not allowed");
167
+ }
168
+ const pathForHash = process.platform === "win32" ? normalized.toLowerCase() : normalized;
169
+ const hash = crypto.createHash("sha256").update(pathForHash).digest("hex");
170
+ const lockPath = path2.join(directory, LOCKS_DIR, `${hash}.lock`);
171
+ const legacyPaths = [pathForHash];
172
+ if (process.platform === "win32" && normalized !== pathForHash) {
173
+ legacyPaths.push(normalized);
174
+ }
175
+ for (const legacyPath of legacyPaths) {
176
+ const oldHash = Buffer.from(legacyPath).toString("base64").replace(/[/+=]/g, "_");
177
+ const oldLockPath = path2.join(directory, LOCKS_DIR, `${oldHash}.lock`);
178
+ if (fs2.existsSync(oldLockPath)) {
179
+ return oldLockPath;
180
+ }
181
+ }
182
+ return lockPath;
183
+ }
184
+ async function tryAcquireLock(directory, filePath, agent, taskId) {
185
+ const lockPath = getLockFilePath(directory, filePath);
186
+ const locksDir = path2.dirname(lockPath);
187
+ if (!fs2.existsSync(locksDir)) {
188
+ fs2.mkdirSync(locksDir, { recursive: true });
189
+ }
190
+ if (!fs2.existsSync(lockPath)) {
191
+ fs2.writeFileSync(lockPath, "", "utf-8");
192
+ }
193
+ let release;
194
+ try {
195
+ release = await import_proper_lockfile.default.lock(lockPath, {
196
+ stale: LOCK_TIMEOUT_MS,
197
+ retries: {
198
+ retries: 5,
199
+ minTimeout: 10,
200
+ maxTimeout: 500,
201
+ factor: 2
202
+ },
203
+ realpath: false
204
+ });
205
+ } catch (err) {
206
+ const code = err.code;
207
+ if (code === "ELOCKED" || code === "EEXIST") {
208
+ return { acquired: false };
209
+ }
210
+ throw err;
211
+ }
212
+ const lock = {
213
+ filePath,
214
+ agent,
215
+ taskId,
216
+ timestamp: new Date().toISOString(),
217
+ expiresAt: Date.now() + LOCK_TIMEOUT_MS,
218
+ _release: release
219
+ };
220
+ return { acquired: true, lock };
221
+ }
222
+
223
+ // src/evidence/lock.ts
224
+ class EvidenceLockTimeoutError extends Error {
225
+ directory;
226
+ evidencePath;
227
+ agent;
228
+ taskId;
229
+ constructor(directory, evidencePath, agent, taskId, timeoutMs) {
230
+ super(`Evidence lock timeout after ${timeoutMs}ms for ${evidencePath} (agent=${agent}, task=${taskId})`);
231
+ this.name = "EvidenceLockTimeoutError";
232
+ this.directory = directory;
233
+ this.evidencePath = evidencePath;
234
+ this.agent = agent;
235
+ this.taskId = taskId;
236
+ }
237
+ }
238
+ var BACKOFF_START_MS = 50;
239
+ var BACKOFF_MAX_MS = 2000;
240
+ var BACKOFF_JITTER_RATIO = 0.25;
241
+ function backoffMs(attempt) {
242
+ const base = Math.min(BACKOFF_START_MS * 2 ** attempt, BACKOFF_MAX_MS);
243
+ const jitter = base * BACKOFF_JITTER_RATIO * (Math.random() * 2 - 1);
244
+ return Math.max(1, Math.round(base + jitter));
245
+ }
246
+ async function withEvidenceLock(directory, evidencePath, agent, taskId, fn, timeoutMs = 60000) {
247
+ assertProjectRoot(directory);
248
+ const deadline = Date.now() + timeoutMs;
249
+ let attempt = 0;
250
+ while (true) {
251
+ const result = await tryAcquireLock(directory, evidencePath, agent, taskId);
252
+ if (result.acquired) {
253
+ const lock = result.lock;
254
+ if (attempt > 0) {
255
+ emit("evidence_lock_stale_recovered", {
256
+ directory,
257
+ evidencePath,
258
+ agent,
259
+ taskId,
260
+ attempt
261
+ });
262
+ }
263
+ emit("evidence_lock_acquired", {
264
+ directory,
265
+ evidencePath,
266
+ agent,
267
+ taskId,
268
+ attempt
269
+ });
270
+ try {
271
+ return await fn();
272
+ } finally {
273
+ if (lock._release) {
274
+ try {
275
+ await lock._release();
276
+ } catch {}
277
+ }
278
+ }
279
+ }
280
+ if (Date.now() >= deadline) {
281
+ throw new EvidenceLockTimeoutError(directory, evidencePath, agent, taskId, timeoutMs);
282
+ }
283
+ emit("evidence_lock_contended", {
284
+ directory,
285
+ evidencePath,
286
+ agent,
287
+ taskId,
288
+ attempt
289
+ });
290
+ const delay = Math.min(backoffMs(attempt), deadline - Date.now());
291
+ if (delay > 0) {
292
+ await new Promise((resolve3) => setTimeout(resolve3, delay));
293
+ }
294
+ attempt++;
295
+ }
296
+ }
297
+
298
+ export { tryAcquireLock, hasExplicitProjectBoundary, isStrictPathDescendant, assertProjectRoot, withEvidenceLock };
@@ -9,7 +9,7 @@ import {
9
9
  readEvaluationRun,
10
10
  saveEvaluationRun,
11
11
  saveTaskSetSnapshot
12
- } from "./index-hckq2r5m.js";
12
+ } from "./index-nrx08gcr.js";
13
13
  import {
14
14
  canonicalHash,
15
15
  computeCandidateInputContentHash,
@@ -18,13 +18,13 @@ import {
18
18
  computeTaskSetContentHash,
19
19
  resolveContainedExistingPath
20
20
  } from "./index-y8552snf.js";
21
+ import {
22
+ bunSpawn
23
+ } from "./index-4nt52yr9.js";
21
24
  import {
22
25
  exports_external,
23
26
  init_zod
24
27
  } from "./index-bpmtbmy9.js";
25
- import {
26
- bunSpawn
27
- } from "./index-4nt52yr9.js";
28
28
 
29
29
  // src/evaluation/runner.ts
30
30
  import * as fs3 from "fs";
@@ -1,8 +1,4 @@
1
1
  // @bun
2
- import {
3
- init_schema,
4
- stripKnownSwarmPrefix
5
- } from "./index-kyz7259r.js";
6
2
  import {
7
3
  getPathFlavor,
8
4
  isOnDifferentPathRoot,
@@ -12,13 +8,17 @@ import {
12
8
  sanitizeDiagnosticText,
13
9
  unsafePathTextReason
14
10
  } from "./index-556ja8an.js";
15
- import {
16
- init_constants
17
- } from "./index-4wjk296r.js";
18
11
  import {
19
12
  init_logger,
20
13
  warn
21
14
  } from "./index-zgwm4ryv.js";
15
+ import {
16
+ init_schema,
17
+ stripKnownSwarmPrefix
18
+ } from "./index-z0tt5j2s.js";
19
+ import {
20
+ init_constants
21
+ } from "./index-4wjk296r.js";
22
22
  import {
23
23
  __commonJS,
24
24
  __toESM