opencode-swarm 7.140.3 → 7.140.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.
- package/.opencode/skills/brainstorm/SKILL.md +1 -1
- package/.opencode/skills/ci-failure-batching/SKILL.md +11 -1
- package/.opencode/skills/ci-fix-monitor/SKILL.md +6 -4
- package/.opencode/skills/discover/SKILL.md +1 -1
- package/.opencode/skills/durable-session-state/SKILL.md +82 -0
- package/.opencode/skills/engineering-conventions/SKILL.md +1 -1
- package/.opencode/skills/issue-ingest/SKILL.md +13 -7
- package/.opencode/skills/issue-tracer/SKILL.md +1 -1
- package/.opencode/skills/orchestrating-subagents/SKILL.md +113 -0
- package/.opencode/skills/parallel-work-check/SKILL.md +1 -1
- package/.opencode/skills/plan/SKILL.md +40 -12
- package/.opencode/skills/swarm-ci-monitor/SKILL.md +5 -3
- package/.opencode/skills/swarm-pr-feedback/SKILL.md +30 -4
- package/.opencode/skills/writing-tests/SKILL.md +1 -1
- package/dist/agents/architect.d.ts +2 -1
- package/dist/agents/reviewer-directive-compliance.d.ts +19 -5
- package/dist/background/pending-delegations.d.ts +5 -0
- package/dist/cli/{config-doctor-fnmfd35x.js → config-doctor-5vzpq4qa.js} +3 -3
- package/dist/cli/{core-p5cyej3r.js → core-xjzdc56e.js} +2 -2
- package/dist/cli/{curation-policy-d52h4g8t.js → curation-policy-avvb56x2.js} +6 -8
- package/dist/cli/{curator-3zpdqt9r.js → curator-5nytvg7p.js} +38 -38
- package/dist/cli/curator-llm-factory-rds75zhj.js +61 -0
- package/dist/cli/{evidence-summary-service-nfdc1ht9.js → evidence-summary-service-zq4gyx6g.js} +15 -12
- package/dist/cli/gate-evidence-smn2wqft.js +51 -0
- package/dist/cli/guardrail-explain-an7jvam1.js +62 -0
- package/dist/cli/{guardrail-log-82da8y5a.js → guardrail-log-0hnd2k9v.js} +4 -4
- package/dist/cli/{hive-promoter-af5yaxvt.js → hive-promoter-qe8pqg79.js} +38 -38
- package/dist/cli/{index-qksjaxpd.js → index-01ggt2mj.js} +49 -18
- package/dist/cli/{index-j1xmren9.js → index-0r2m0vbq.js} +12 -10
- package/dist/cli/{index-pg7n141e.js → index-0rx9t9w8.js} +1 -1
- package/dist/cli/{index-brh827g0.js → index-2bg901qt.js} +73 -32
- package/dist/cli/{index-8n4c3vec.js → index-386ts4tm.js} +4 -4
- package/dist/cli/{index-898f16j9.js → index-8rp1y4ab.js} +2 -2
- package/dist/cli/{index-hfvxhk4z.js → index-912qz4y0.js} +88 -88
- package/dist/cli/index-affh1gtg.js +2554 -0
- package/dist/cli/{index-1m1ksyqt.js → index-c432knmy.js} +1 -1
- package/dist/cli/{index-jvk119ck.js → index-e0mpz2j3.js} +54 -19
- package/dist/cli/{index-ry0hgg3m.js → index-epvhf50h.js} +37 -3
- package/dist/cli/{index-95bj4kaw.js → index-ex7r16gc.js} +2 -2
- package/dist/cli/{index-7d5jseea.js → index-jm4cpp4n.js} +5 -2
- package/dist/cli/{index-n408rw7n.js → index-jqsfsqbx.js} +27 -2
- package/dist/cli/{index-7kdd75se.js → index-kb5q9v34.js} +11 -9
- package/dist/cli/{index-jfjnn408.js → index-m9xrdjn0.js} +1 -1
- package/dist/cli/{index-pj9h75cc.js → index-mm2egvdt.js} +40 -40
- package/dist/cli/{index-8bnzzv3b.js → index-nwrwy8eb.js} +70 -34
- package/dist/cli/index-nyjtzmsj.js +43 -0
- package/dist/cli/{index-h2waehqq.js → index-p8kk34am.js} +3 -3
- package/dist/cli/{index-wf35ka4z.js → index-ptn13xjn.js} +3 -3
- package/dist/cli/{index-1kyex7z2.js → index-qwm6vdyv.js} +32 -1
- package/dist/cli/{index-p9dsb0tw.js → index-qy1nq52t.js} +2 -19
- package/dist/cli/{index-b9rd29ge.js → index-s1v0wza5.js} +6 -2
- package/dist/cli/{index-yyyk63kk.js → index-t5pytnca.js} +2 -2
- package/dist/cli/index-tjqzr3jc.js +623 -0
- package/dist/cli/{index-rs1f1bh0.js → index-vh05t3w5.js} +1 -1
- package/dist/cli/{index-adyxbmt5.js → index-wkt9fj06.js} +4 -4
- package/dist/cli/{index-kbfsp07d.js → index-wrb0gykj.js} +217 -15
- package/dist/cli/{index-xz8f1n1a.js → index-z7h37d63.js} +2 -2
- package/dist/cli/{index-q1q8b85k.js → index-z90nvqj3.js} +49315 -47331
- package/dist/cli/{index-b8zgtz81.js → index-zsrtt42s.js} +34 -1
- package/dist/cli/{index-gtbmabws.js → index-ztgn70jz.js} +2 -2
- package/dist/cli/index.js +37 -37
- package/dist/cli/{knowledge-escalator-7q59skqg.js → knowledge-escalator-4pfrc902.js} +20 -8
- package/dist/cli/{knowledge-events-3nwfdpq7.js → knowledge-events-3zkfnksk.js} +19 -6
- package/dist/cli/{knowledge-link-q46k9adx.js → knowledge-link-m9p80f4r.js} +5 -5
- package/dist/cli/{knowledge-store-0d83rhh3.js → knowledge-store-dpqgvvjt.js} +6 -6
- package/dist/cli/{knowledge-validator-6mfx91a2.js → knowledge-validator-2c7w87dk.js} +8 -9
- package/dist/cli/{pending-delegations-qzrx38y9.js → pending-delegations-cxx9tezp.js} +4 -4
- package/dist/cli/{pr-subscriptions-5s59h4dd.js → pr-subscriptions-2sfnb599.js} +4 -4
- package/dist/cli/{runner-y78d7ryb.js → runner-mky3vvht.js} +6 -6
- package/dist/cli/{scan-cursor-rc8q12ss.js → scan-cursor-1z60gwrw.js} +7 -7
- package/dist/cli/{schema-n9eaxp3a.js → schema-vpnkwvez.js} +2 -2
- package/dist/cli/{scope-persistence-dr1msqxw.js → scope-persistence-p9dmprry.js} +10 -5
- package/dist/cli/{skill-generator-q7c6vadg.js → skill-generator-yx7ka1cj.js} +19 -10
- package/dist/cli/{telemetry-sc57xtb0.js → telemetry-0x6kszvk.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-7a8e6gr9.js → worktree-collision-ownership-wm5pse49.js} +8 -8
- package/dist/cli/worktree-isolation-bwc6ra8e.js +102 -0
- package/dist/cli/worktree-provisioning-owner-sjh7te1h.js +22 -0
- package/dist/commands/acknowledge-spec-drift.d.ts +4 -5
- package/dist/commands/ci-simulate.d.ts +7 -3
- package/dist/commands/close.d.ts +8 -0
- package/dist/commands/registry.d.ts +2 -2
- package/dist/commands/sdd.d.ts +15 -0
- package/dist/config/bundled-skills.d.ts +1 -1
- package/dist/config/evidence-schema.d.ts +3 -3
- package/dist/config/index.d.ts +2 -2
- package/dist/config/plan-schema.d.ts +8 -0
- package/dist/config/schema.d.ts +4 -2
- package/dist/council/council-evidence-writer.d.ts +1 -1
- package/dist/gate-evidence.d.ts +117 -4
- package/dist/git/branch.d.ts +1 -1
- package/dist/hooks/delegate-ack-collector.d.ts +5 -0
- package/dist/hooks/delegation-gate.d.ts +21 -0
- package/dist/hooks/hive-promoter.d.ts +4 -4
- package/dist/hooks/issue-trace-reducer.d.ts +7 -1
- package/dist/hooks/issue-trace-state.d.ts +18 -0
- package/dist/hooks/issue-trace.d.ts +3 -1
- package/dist/hooks/knowledge-application-gate.d.ts +8 -3
- package/dist/hooks/knowledge-application.d.ts +8 -5
- package/dist/hooks/knowledge-escalator.d.ts +9 -5
- package/dist/hooks/knowledge-events.d.ts +21 -8
- package/dist/hooks/knowledge-injector.d.ts +9 -0
- package/dist/hooks/knowledge-receipt-ledger-storage.d.ts +49 -0
- package/dist/hooks/knowledge-receipt-ledger.d.ts +305 -0
- package/dist/hooks/knowledge-receipt-observability.d.ts +28 -0
- package/dist/hooks/knowledge-receipt-validator.d.ts +13 -50
- package/dist/hooks/knowledge-store.d.ts +6 -1
- package/dist/hooks/knowledge-types.d.ts +12 -0
- package/dist/hooks/phase-complete-directive-gate.d.ts +3 -1
- package/dist/hooks/phase-directives.d.ts +4 -4
- package/dist/hooks/pr-workflow-gate.d.ts +34 -1
- package/dist/hooks/promotion-evidence-store.d.ts +14 -8
- package/dist/hooks/reviewer-verdict-parser.d.ts +34 -10
- package/dist/index.js +823 -779
- package/dist/knowledge/curation-policy.d.ts +0 -2
- package/dist/observability/catalog.d.ts +5 -3
- package/dist/observability/legacy.d.ts +4 -3
- package/dist/plan/ledger.d.ts +55 -0
- package/dist/plan/manager.d.ts +9 -0
- package/dist/plan/planning-profile.d.ts +27 -0
- package/dist/services/spec-drift-recovery.d.ts +84 -0
- package/dist/session/snapshot-writer.d.ts +3 -1
- package/dist/state.d.ts +19 -17
- package/dist/summaries/schema.d.ts +2 -2
- package/dist/telemetry.d.ts +1 -1
- package/dist/tools/convene-council.d.ts +6 -6
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/manifest.d.ts +3 -0
- package/dist/tools/phase-complete.d.ts +9 -0
- package/dist/tools/rebind-pr-feedback-head.d.ts +17 -0
- package/dist/tools/record-implementation-review.d.ts +19 -0
- package/dist/tools/record-recurrence-sweep.d.ts +17 -0
- package/dist/tools/run-pr-feedback-stage-a.d.ts +8 -0
- package/dist/tools/save-plan.d.ts +8 -0
- package/dist/tools/submit-phase-council-verdicts.d.ts +6 -6
- package/dist/tools/tool-metadata.d.ts +40 -28
- package/dist/tools/update-task-status.d.ts +13 -0
- package/dist/tools/write-final-council-evidence.d.ts +6 -6
- package/dist/types/events.d.ts +29 -1
- package/dist/workflow/coder-settlement.d.ts +62 -0
- package/dist/workflow/task-repair.d.ts +30 -0
- package/dist/workflow/task-terminal.d.ts +52 -0
- package/package.json +3 -1
- package/dist/cli/curator-llm-factory-2h0xb62t.js +0 -61
- package/dist/cli/gate-evidence-46qeyfc1.js +0 -32
- package/dist/cli/guardrail-explain-yktan15c.js +0 -62
- package/dist/cli/index-d181x9zr.js +0 -71
- package/dist/cli/index-n0pja0qs.js +0 -239
- package/dist/cli/index-n8jncheh.js +0 -666
|
@@ -8,16 +8,89 @@ import {
|
|
|
8
8
|
} from "./index-zgwm4ryv.js";
|
|
9
9
|
import {
|
|
10
10
|
emit
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-epvhf50h.js";
|
|
12
12
|
import {
|
|
13
13
|
__toESM
|
|
14
14
|
} from "./index-a76rekgs.js";
|
|
15
15
|
|
|
16
|
+
// src/parallel/file-locks.ts
|
|
17
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
18
|
+
import * as crypto from "crypto";
|
|
19
|
+
import * as fs from "fs";
|
|
20
|
+
import * as path from "path";
|
|
21
|
+
var LOCKS_DIR = ".swarm/locks";
|
|
22
|
+
var LOCK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
23
|
+
var _internals = {
|
|
24
|
+
tryAcquireLock,
|
|
25
|
+
writeFile: fs.promises.writeFile
|
|
26
|
+
};
|
|
27
|
+
function getLockFilePath(directory, filePath) {
|
|
28
|
+
const normalized = path.resolve(directory, filePath);
|
|
29
|
+
const baseDir = path.resolve(directory) + path.sep;
|
|
30
|
+
const pathOk = process.platform === "win32" ? normalized.toLowerCase().startsWith(baseDir.toLowerCase()) : normalized.startsWith(baseDir);
|
|
31
|
+
if (!pathOk) {
|
|
32
|
+
throw new Error("Invalid file path: path traversal not allowed");
|
|
33
|
+
}
|
|
34
|
+
const pathForHash = process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
35
|
+
const hash = crypto.createHash("sha256").update(pathForHash).digest("hex");
|
|
36
|
+
const lockPath = path.join(directory, LOCKS_DIR, `${hash}.lock`);
|
|
37
|
+
const legacyPaths = [pathForHash];
|
|
38
|
+
if (process.platform === "win32" && normalized !== pathForHash) {
|
|
39
|
+
legacyPaths.push(normalized);
|
|
40
|
+
}
|
|
41
|
+
for (const legacyPath of legacyPaths) {
|
|
42
|
+
const oldHash = Buffer.from(legacyPath).toString("base64").replace(/[/+=]/g, "_");
|
|
43
|
+
const oldLockPath = path.join(directory, LOCKS_DIR, `${oldHash}.lock`);
|
|
44
|
+
if (fs.existsSync(oldLockPath)) {
|
|
45
|
+
return oldLockPath;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return lockPath;
|
|
49
|
+
}
|
|
50
|
+
async function tryAcquireLock(directory, filePath, agent, taskId) {
|
|
51
|
+
const lockPath = getLockFilePath(directory, filePath);
|
|
52
|
+
const locksDir = path.dirname(lockPath);
|
|
53
|
+
if (!fs.existsSync(locksDir)) {
|
|
54
|
+
fs.mkdirSync(locksDir, { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
if (!fs.existsSync(lockPath)) {
|
|
57
|
+
fs.writeFileSync(lockPath, "", "utf-8");
|
|
58
|
+
}
|
|
59
|
+
let release;
|
|
60
|
+
try {
|
|
61
|
+
release = await import_proper_lockfile.default.lock(lockPath, {
|
|
62
|
+
stale: LOCK_TIMEOUT_MS,
|
|
63
|
+
retries: {
|
|
64
|
+
retries: 5,
|
|
65
|
+
minTimeout: 10,
|
|
66
|
+
maxTimeout: 500,
|
|
67
|
+
factor: 2
|
|
68
|
+
},
|
|
69
|
+
realpath: false
|
|
70
|
+
});
|
|
71
|
+
} catch (err) {
|
|
72
|
+
const code = err.code;
|
|
73
|
+
if (code === "ELOCKED" || code === "EEXIST") {
|
|
74
|
+
return { acquired: false };
|
|
75
|
+
}
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
78
|
+
const lock = {
|
|
79
|
+
filePath,
|
|
80
|
+
agent,
|
|
81
|
+
taskId,
|
|
82
|
+
timestamp: new Date().toISOString(),
|
|
83
|
+
expiresAt: Date.now() + LOCK_TIMEOUT_MS,
|
|
84
|
+
_release: release
|
|
85
|
+
};
|
|
86
|
+
return { acquired: true, lock };
|
|
87
|
+
}
|
|
88
|
+
|
|
16
89
|
// src/utils/project-boundary.ts
|
|
17
90
|
init_logger();
|
|
18
|
-
import * as
|
|
91
|
+
import * as fs2 from "fs";
|
|
19
92
|
import * as os from "os";
|
|
20
|
-
import * as
|
|
93
|
+
import * as path2 from "path";
|
|
21
94
|
var MAX_PROJECT_ROOT_DEPTH = 20;
|
|
22
95
|
var PROJECT_ROOT_INDICATORS = [
|
|
23
96
|
"package.json",
|
|
@@ -40,14 +113,14 @@ var PROJECT_BOUNDARY_MARKERS = [
|
|
|
40
113
|
{ name: ".opencode", accepts: (stat) => stat.isDirectory() }
|
|
41
114
|
];
|
|
42
115
|
function isAbsoluteDirectoryInput(value) {
|
|
43
|
-
return typeof value === "string" && value.trim().length > 0 &&
|
|
116
|
+
return typeof value === "string" && value.trim().length > 0 && path2.isAbsolute(value);
|
|
44
117
|
}
|
|
45
118
|
function hasExplicitProjectBoundary(directory) {
|
|
46
119
|
if (!isAbsoluteDirectoryInput(directory))
|
|
47
120
|
return false;
|
|
48
121
|
for (const marker of PROJECT_BOUNDARY_MARKERS) {
|
|
49
122
|
try {
|
|
50
|
-
const stat =
|
|
123
|
+
const stat = _internals2.lstatSync(path2.join(directory, marker.name));
|
|
51
124
|
if (!stat.isSymbolicLink() && marker.accepts(stat))
|
|
52
125
|
return true;
|
|
53
126
|
} catch {}
|
|
@@ -58,8 +131,8 @@ function isStrictPathDescendant(candidate, root) {
|
|
|
58
131
|
if (!isAbsoluteDirectoryInput(candidate) || !isAbsoluteDirectoryInput(root)) {
|
|
59
132
|
return false;
|
|
60
133
|
}
|
|
61
|
-
const relative2 =
|
|
62
|
-
return relative2 !== "" && relative2 !== ".." && !relative2.startsWith(`..${
|
|
134
|
+
const relative2 = path2.relative(root, candidate);
|
|
135
|
+
return relative2 !== "" && relative2 !== ".." && !relative2.startsWith(`..${path2.sep}`) && !path2.isAbsolute(relative2);
|
|
63
136
|
}
|
|
64
137
|
function isMissingPathError(error) {
|
|
65
138
|
const code = error?.code;
|
|
@@ -70,8 +143,8 @@ function isWeakConfigContainerRoot(directory, dependencies) {
|
|
|
70
143
|
const resolved = dependencies.realpathSync(directory);
|
|
71
144
|
return resolved === dependencies.realpathSync(os.tmpdir()) || resolved === dependencies.realpathSync(os.homedir());
|
|
72
145
|
} catch {
|
|
73
|
-
const resolved =
|
|
74
|
-
return resolved ===
|
|
146
|
+
const resolved = path2.resolve(directory);
|
|
147
|
+
return resolved === path2.resolve(os.tmpdir()) || resolved === path2.resolve(os.homedir());
|
|
75
148
|
}
|
|
76
149
|
}
|
|
77
150
|
function projectIndicatorState(directory, dependencies, options = {}) {
|
|
@@ -80,7 +153,7 @@ function projectIndicatorState(directory, dependencies, options = {}) {
|
|
|
80
153
|
if (!allowConfigOnly && indicator === ".opencode")
|
|
81
154
|
continue;
|
|
82
155
|
try {
|
|
83
|
-
const indicatorStat = dependencies.statSync(
|
|
156
|
+
const indicatorStat = dependencies.statSync(path2.join(directory, indicator));
|
|
84
157
|
if (indicatorStat.isFile() || indicatorStat.isDirectory())
|
|
85
158
|
return "present";
|
|
86
159
|
} catch (error) {
|
|
@@ -90,7 +163,7 @@ function projectIndicatorState(directory, dependencies, options = {}) {
|
|
|
90
163
|
}
|
|
91
164
|
return "absent";
|
|
92
165
|
}
|
|
93
|
-
function assertProjectRoot(directory, dependencies =
|
|
166
|
+
function assertProjectRoot(directory, dependencies = fs2, artifactLabel = "runtime state") {
|
|
94
167
|
let resolved;
|
|
95
168
|
try {
|
|
96
169
|
resolved = dependencies.realpathSync(directory);
|
|
@@ -108,14 +181,14 @@ function assertProjectRoot(directory, dependencies = fs, artifactLabel = "runtim
|
|
|
108
181
|
throw new Error(`Cannot verify project root for "${resolved}" \u2014 ancestor search exceeded ${MAX_PROJECT_ROOT_DEPTH} levels`);
|
|
109
182
|
}
|
|
110
183
|
depth++;
|
|
111
|
-
const parent =
|
|
184
|
+
const parent = path2.dirname(current);
|
|
112
185
|
if (parent === current)
|
|
113
186
|
break;
|
|
114
|
-
if (
|
|
187
|
+
if (path2.dirname(parent) === parent) {
|
|
115
188
|
current = parent;
|
|
116
189
|
continue;
|
|
117
190
|
}
|
|
118
|
-
const parentSwarm =
|
|
191
|
+
const parentSwarm = path2.join(parent, ".swarm");
|
|
119
192
|
let parentSwarmStat;
|
|
120
193
|
try {
|
|
121
194
|
parentSwarmStat = dependencies.statSync(parentSwarm);
|
|
@@ -143,82 +216,9 @@ function assertProjectRoot(directory, dependencies = fs, artifactLabel = "runtim
|
|
|
143
216
|
current = parent;
|
|
144
217
|
}
|
|
145
218
|
}
|
|
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
219
|
var _internals2 = {
|
|
158
|
-
|
|
159
|
-
writeFile: fs2.promises.writeFile
|
|
220
|
+
lstatSync: fs2.lstatSync
|
|
160
221
|
};
|
|
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
222
|
|
|
223
223
|
// src/evidence/lock.ts
|
|
224
224
|
class EvidenceLockTimeoutError extends Error {
|