opencode-swarm 7.139.3 → 7.139.4
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.
- package/README.md +2 -2
- package/dist/cli/{config-doctor-75qky762.js → config-doctor-whxr386t.js} +6 -6
- package/dist/cli/{core-nn8ffy5h.js → core-aj5g7an6.js} +4 -4
- package/dist/cli/{curation-policy-f46tf3dw.js → curation-policy-anym2y3v.js} +7 -7
- package/dist/cli/{curator-drift-r52hjskk.js → curator-drift-49p3jnte.js} +6 -6
- package/dist/cli/{curator-m6mk2v1n.js → curator-e8cvb55d.js} +39 -39
- package/dist/cli/curator-llm-factory-h9xbpgmw.js +61 -0
- package/dist/cli/{dispatch-nbv0hezh.js → dispatch-2s23fbcs.js} +3 -3
- package/dist/cli/{evidence-summary-service-sxcq5nrt.js → evidence-summary-service-g82bsjqa.js} +16 -16
- package/dist/cli/{gate-evidence-1982qswy.js → gate-evidence-72cgrvs2.js} +6 -5
- package/dist/cli/guardrail-explain-0be7msvq.js +62 -0
- package/dist/cli/{guardrail-log-320grggj.js → guardrail-log-9mm5443g.js} +8 -8
- package/dist/cli/{hive-promoter-v4w7cjvk.js → hive-promoter-nnzs5x1r.js} +39 -39
- package/dist/cli/{index-xeyr62x0.js → index-0e95eck5.js} +5 -5
- package/dist/cli/{index-5syvwd8g.js → index-0xkjhgrf.js} +5 -5
- package/dist/cli/{index-yh0q21nj.js → index-1kyex7z2.js} +1 -1
- package/dist/cli/{index-6mvbjqbt.js → index-33skgk1a.js} +1 -1
- package/dist/cli/{index-xsxrhakg.js → index-41hkt36g.js} +1 -1
- package/dist/cli/{index-jqn332jx.js → index-5azdnaty.js} +2 -2
- package/dist/cli/{index-kyz7259r.js → index-5s23pfsy.js} +7 -7
- package/dist/cli/{index-xzzcfwwm.js → index-5z2xps64.js} +2 -2
- package/dist/cli/{index-4fr94329.js → index-6nzmp937.js} +53 -108
- package/dist/cli/{index-2eet124q.js → index-6r522srn.js} +1 -1
- package/dist/cli/{index-4xbyy6aw.js → index-6rxgb5r9.js} +10 -6
- package/dist/cli/{index-z6qe8wft.js → index-6vh6vrnk.js} +10 -10
- package/dist/cli/{index-gen82t10.js → index-6z0a940s.js} +7 -7
- package/dist/cli/{index-ba5e5e3n.js → index-9cdj4020.js} +6 -6
- package/dist/cli/{index-1yd38ajy.js → index-e1k9vpqn.js} +4 -4
- package/dist/cli/{index-0mzz46we.js → index-ejbcpbzp.js} +7 -7
- package/dist/cli/{index-mzck763x.js → index-gfmrw2f5.js} +2 -2
- package/dist/cli/{index-mv0czd9c.js → index-j77frjq8.js} +6 -6
- package/dist/cli/{index-1jbj7vzv.js → index-jnfyxeap.js} +4 -4
- package/dist/cli/{index-hwnpd4tw.js → index-k41dn8me.js} +3 -3
- package/dist/cli/{index-k87hs2ff.js → index-k46me75h.js} +3 -3
- package/dist/cli/{index-hckq2r5m.js → index-nrx08gcr.js} +6 -2
- package/dist/cli/{index-6axm8q3s.js → index-pg84msyc.js} +7 -7
- package/dist/cli/{index-a5eba0t8.js → index-rsrx77fg.js} +6 -6
- package/dist/cli/index-s0qc4gj6.js +298 -0
- package/dist/cli/{index-yawwwhmc.js → index-s58vghgj.js} +6 -6
- package/dist/cli/{index-5hyq2mw6.js → index-sa15nfgg.js} +43 -43
- package/dist/cli/{index-ajwmn8gp.js → index-sd657fkp.js} +4 -4
- package/dist/cli/{index-v7g8dnyh.js → index-vfsqpcz6.js} +15 -15
- package/dist/cli/{index-tkg6rapy.js → index-vyqd1hzm.js} +19404 -19355
- package/dist/cli/{index-bcwx1335.js → index-xb1zq933.js} +1 -1
- package/dist/cli/{index-05mms0va.js → index-xmhhhjjw.js} +38 -3
- package/dist/cli/index.js +41 -41
- package/dist/cli/{knowledge-escalator-kkjsjtza.js → knowledge-escalator-a6z30y9p.js} +9 -9
- package/dist/cli/{knowledge-events-jbw9j94n.js → knowledge-events-deq0ds8e.js} +6 -6
- package/dist/cli/{knowledge-link-f6akgbdn.js → knowledge-link-bmbatt8s.js} +5 -5
- package/dist/cli/{knowledge-store-m7vnz62z.js → knowledge-store-vdr19mnq.js} +7 -7
- package/dist/cli/{knowledge-validator-rqj7kech.js → knowledge-validator-5hgacnrf.js} +10 -10
- package/dist/cli/{pending-delegations-14544jpr.js → pending-delegations-7ayryxbg.js} +7 -7
- package/dist/cli/{pr-subscriptions-qdwfm1a8.js → pr-subscriptions-w5y08ebc.js} +7 -7
- package/dist/cli/{runner-mzb3e2s6.js → runner-h7vmgkth.js} +7 -6
- package/dist/cli/{scan-cursor-8e6ryhjq.js → scan-cursor-d6qcg9hr.js} +8 -8
- package/dist/cli/{schema-g7rs20c6.js → schema-y1zekrag.js} +3 -3
- package/dist/cli/{scope-persistence-wy65zyha.js → scope-persistence-tj6qway9.js} +6 -6
- package/dist/cli/{skill-generator-2rv6ftre.js → skill-generator-bw8xhzzn.js} +12 -12
- package/dist/cli/{telemetry-4tgrfhaz.js → telemetry-62cn5t24.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-24s0t62z.js → worktree-collision-ownership-hs5c2qzp.js} +8 -8
- package/dist/evidence/manager.d.ts +4 -1
- package/dist/index.js +590 -588
- package/dist/prm/escalation.d.ts +34 -0
- package/dist/prm/index.d.ts +6 -2
- package/dist/prm/pattern-detector.d.ts +22 -1
- package/dist/prm/types.d.ts +12 -2
- package/dist/state.d.ts +49 -0
- package/dist/summaries/schema.d.ts +2 -2
- package/dist/tools/convene-council.d.ts +1 -1
- package/dist/tools/pre-check-batch.d.ts +4 -0
- package/dist/tools/resolve-working-directory.d.ts +4 -4
- package/dist/tools/submit-phase-council-verdicts.d.ts +1 -1
- package/dist/tools/write-final-council-evidence.d.ts +1 -1
- package/dist/utils/project-boundary.d.ts +34 -0
- package/package.json +1 -1
- package/dist/cli/curator-llm-factory-1r9vz0g2.js +0 -61
- package/dist/cli/guardrail-explain-y2wg00dp.js +0 -62
- package/dist/cli/index-5j6chvj8.js +0 -159
- package/dist/cli/{index-z6xqpmqg.js → index-ee3x66a5.js} +3 -3
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
} from "./index-y8552snf.js";
|
|
10
10
|
import {
|
|
11
11
|
atomicWriteFile
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-6r522srn.js";
|
|
13
13
|
import {
|
|
14
|
+
assertProjectRoot,
|
|
14
15
|
withEvidenceLock
|
|
15
|
-
} from "./index-
|
|
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) ?? "";
|
|
@@ -2,22 +2,18 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ALLOWED_SKILL_PATH_PREFIXES,
|
|
4
4
|
validateSkillPath
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-jnfyxeap.js";
|
|
6
6
|
import {
|
|
7
7
|
computeOutcomeSignal,
|
|
8
8
|
readKnowledge,
|
|
9
9
|
resolveHiveKnowledgePath,
|
|
10
10
|
resolveSwarmKnowledgePath,
|
|
11
11
|
transactKnowledge
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-6vh6vrnk.js";
|
|
13
13
|
import {
|
|
14
14
|
effectiveRetrievalOutcomes,
|
|
15
15
|
readKnowledgeCounterRollups
|
|
16
|
-
} from "./index-
|
|
17
|
-
import {
|
|
18
|
-
init_knowledge_types,
|
|
19
|
-
isActiveStatus
|
|
20
|
-
} from "./index-bk5tah7q.js";
|
|
16
|
+
} from "./index-k41dn8me.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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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 };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
import {
|
|
3
|
+
advisoryWarn,
|
|
4
|
+
init_warning_buffer
|
|
5
|
+
} from "./index-4rhhvd1a.js";
|
|
2
6
|
import {
|
|
3
7
|
ExternalSkillsConfigSchema,
|
|
4
8
|
GATE_CONFIG_KNOWN_SECTION_KEYS,
|
|
@@ -6,11 +10,7 @@ import {
|
|
|
6
10
|
PluginConfigSchema,
|
|
7
11
|
init_schema,
|
|
8
12
|
resolveExternalSkillsConfig
|
|
9
|
-
} from "./index-
|
|
10
|
-
import {
|
|
11
|
-
advisoryWarn,
|
|
12
|
-
init_warning_buffer
|
|
13
|
-
} from "./index-4rhhvd1a.js";
|
|
13
|
+
} from "./index-5s23pfsy.js";
|
|
14
14
|
import {
|
|
15
15
|
DEFAULT_WORKTREE_ISOLATION_CONFIG,
|
|
16
16
|
init_constants
|
|
@@ -717,4 +717,4 @@ function resolveWorktreeIsolationConfig(config) {
|
|
|
717
717
|
// src/config/index.ts
|
|
718
718
|
var _internals = { loadPluginConfigWithMeta };
|
|
719
719
|
|
|
720
|
-
export {
|
|
720
|
+
export { loadPluginConfig, loadPluginConfigWithMeta, getSafeDefaultConfigLoadResult, loadPluginConfigWithMetaAsync, loadAgentPrompt, exports_loader, init_loader, resolveWorktreeIsolationConfig, _internals };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
handleGuardrailExplain
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-gfmrw2f5.js";
|
|
5
5
|
import {
|
|
6
6
|
handleGuardrailLog
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-xb1zq933.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-
|
|
88
|
-
import"./index-
|
|
89
|
-
import"./index-
|
|
90
|
-
import"./index-
|
|
91
|
-
import"./index-
|
|
92
|
-
import"./index-
|
|
93
|
-
import"./index-
|
|
87
|
+
} from "./index-vyqd1hzm.js";
|
|
88
|
+
import"./index-41hkt36g.js";
|
|
89
|
+
import"./index-sd657fkp.js";
|
|
90
|
+
import"./index-ejbcpbzp.js";
|
|
91
|
+
import"./index-e1k9vpqn.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-
|
|
98
|
-
import"./index-
|
|
99
|
-
import"./index-
|
|
97
|
+
import"./index-pg84msyc.js";
|
|
98
|
+
import"./index-0e95eck5.js";
|
|
99
|
+
import"./index-9cdj4020.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-
|
|
105
|
-
import"./index-
|
|
106
|
-
import"./index-
|
|
114
|
+
import"./index-5z2xps64.js";
|
|
115
|
+
import"./index-8fwhhayc.js";
|
|
116
|
+
import"./index-q1exe2b3.js";
|
|
117
|
+
import"./index-jnfyxeap.js";
|
|
118
|
+
import"./index-5azdnaty.js";
|
|
107
119
|
import"./index-rtry5xyf.js";
|
|
108
|
-
import"./index-
|
|
109
|
-
import"./index-
|
|
120
|
+
import"./index-6vh6vrnk.js";
|
|
121
|
+
import"./index-k41dn8me.js";
|
|
110
122
|
import"./index-ae75rja9.js";
|
|
111
|
-
import"./index-
|
|
112
|
-
import"./index-
|
|
113
|
-
import"./index-
|
|
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-s58vghgj.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-
|
|
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-5s23pfsy.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-
|
|
147
|
-
import"./index-
|
|
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,7 +9,7 @@ import {
|
|
|
9
9
|
readEvaluationRun,
|
|
10
10
|
saveEvaluationRun,
|
|
11
11
|
saveTaskSetSnapshot
|
|
12
|
-
} from "./index-
|
|
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";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
loadPluginConfigWithMeta,
|
|
8
8
|
loadPluginConfigWithMetaAsync,
|
|
9
9
|
resolveWorktreeIsolationConfig
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-s58vghgj.js";
|
|
11
11
|
import {
|
|
12
12
|
ApprovalEvidenceSchema,
|
|
13
13
|
BaseEvidenceSchema,
|
|
@@ -33,6 +33,17 @@ import {
|
|
|
33
33
|
SwarmSpecSchema,
|
|
34
34
|
validateSpecContent
|
|
35
35
|
} from "./index-n832052r.js";
|
|
36
|
+
import {
|
|
37
|
+
MigrationStatusSchema,
|
|
38
|
+
PhaseSchema,
|
|
39
|
+
PhaseStatusSchema,
|
|
40
|
+
PlanSchema,
|
|
41
|
+
TaskSchema,
|
|
42
|
+
TaskSizeSchema,
|
|
43
|
+
TaskStatusSchema
|
|
44
|
+
} from "./index-1kz6da87.js";
|
|
45
|
+
import"./index-4rhhvd1a.js";
|
|
46
|
+
import"./index-zgwm4ryv.js";
|
|
36
47
|
import {
|
|
37
48
|
AUTO_REVIEW_V8_BURN_IN_DECISION,
|
|
38
49
|
AgentOverrideConfigSchema,
|
|
@@ -54,18 +65,7 @@ import {
|
|
|
54
65
|
TurboConfigSchema,
|
|
55
66
|
WorktreeIsolationConfigSchema,
|
|
56
67
|
resolveAutoReviewConfig
|
|
57
|
-
} from "./index-
|
|
58
|
-
import"./index-bk5tah7q.js";
|
|
59
|
-
import {
|
|
60
|
-
MigrationStatusSchema,
|
|
61
|
-
PhaseSchema,
|
|
62
|
-
PhaseStatusSchema,
|
|
63
|
-
PlanSchema,
|
|
64
|
-
TaskSchema,
|
|
65
|
-
TaskSizeSchema,
|
|
66
|
-
TaskStatusSchema
|
|
67
|
-
} from "./index-1kz6da87.js";
|
|
68
|
-
import"./index-4rhhvd1a.js";
|
|
68
|
+
} from "./index-5s23pfsy.js";
|
|
69
69
|
import {
|
|
70
70
|
ALL_AGENT_NAMES,
|
|
71
71
|
ALL_SUBAGENT_NAMES,
|
|
@@ -76,9 +76,9 @@ import {
|
|
|
76
76
|
isQAAgent,
|
|
77
77
|
isSubagent
|
|
78
78
|
} from "./index-4wjk296r.js";
|
|
79
|
-
import"./index-bpmtbmy9.js";
|
|
80
79
|
import"./index-zjygnfay.js";
|
|
81
|
-
import"./index-
|
|
80
|
+
import"./index-bk5tah7q.js";
|
|
81
|
+
import"./index-bpmtbmy9.js";
|
|
82
82
|
import"./index-a76rekgs.js";
|
|
83
83
|
export {
|
|
84
84
|
validateSpecContent,
|