opencode-swarm 7.83.0 → 7.84.0
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 +3 -1
- package/dist/cli/capability-probe-jevmgwmf.js +18 -0
- package/dist/cli/config-doctor-4tcdd9vt.js +35 -0
- package/dist/cli/dispatch-k86d928w.js +477 -0
- package/dist/cli/evidence-summary-service-g2znnd33.js +320 -0
- package/dist/cli/explorer-gz70sm9b.js +16 -0
- package/dist/cli/gate-evidence-y8zn7fe2.js +29 -0
- package/dist/cli/guardrail-explain-tcamcdfy.js +30 -0
- package/dist/cli/guardrail-log-fd14n96q.js +15 -0
- package/dist/cli/index-293f68mj.js +13538 -0
- package/dist/cli/index-8ra2qpk8.js +29027 -0
- package/dist/cli/index-a76rekgs.js +67 -0
- package/dist/cli/index-a82d6d87.js +1241 -0
- package/dist/cli/index-b9v501fr.js +371 -0
- package/dist/cli/index-bcp79s17.js +1673 -0
- package/dist/cli/index-ckntc5gf.js +91 -0
- package/dist/cli/index-d9fbxaqd.js +2314 -0
- package/dist/cli/index-e7h9bb6v.js +233 -0
- package/dist/cli/index-e8pk68cc.js +540 -0
- package/dist/cli/index-eb85wtx9.js +242 -0
- package/dist/cli/index-f8r50m3h.js +14505 -0
- package/dist/cli/index-fjwwrwr5.js +37 -0
- package/dist/cli/index-hz59hg4h.js +452 -0
- package/dist/cli/index-j710h2ge.js +412 -0
- package/dist/cli/index-jfgr5gye.js +110 -0
- package/dist/cli/index-jtqkh8jf.js +119 -0
- package/dist/cli/index-p0arc26j.js +28 -0
- package/dist/cli/index-p0ye10nd.js +222 -0
- package/dist/cli/index-pv2xmc9k.js +2391 -0
- package/dist/cli/index-red8fm8p.js +2914 -0
- package/dist/cli/index-wg3r6acj.js +2042 -0
- package/dist/cli/index-xw0bcy0v.js +583 -0
- package/dist/cli/index-yhsmmv2z.js +339 -0
- package/dist/cli/index-yx44zd0p.js +40 -0
- package/dist/cli/index-zfsbaaqh.js +29 -0
- package/dist/cli/index.js +73 -69708
- package/dist/cli/knowledge-store-n4x6zyk7.js +73 -0
- package/dist/cli/pending-delegations-pz61mrsz.js +255 -0
- package/dist/cli/pr-subscriptions-y1nn36e5.js +33 -0
- package/dist/cli/schema-c2dbzhm8.js +168 -0
- package/dist/cli/skill-generator-a5ehggyg.js +55 -0
- package/dist/cli/task-envelope-qn0qtnh0.js +90 -0
- package/dist/cli/telemetry-9bbyxrvn.js +20 -0
- package/dist/cli/workspace-snapshot-w58jr2ga.js +90 -0
- package/dist/commands/guardrail-explain.d.ts +1 -0
- package/dist/commands/guardrail-log.d.ts +1 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/registry.d.ts +14 -0
- package/dist/hooks/guardrails/audit-log.d.ts +114 -0
- package/dist/index.js +3569 -2366
- package/dist/services/diagnose-service.d.ts +5 -0
- package/dist/services/guardrail-explain-service.d.ts +42 -0
- package/dist/services/guardrail-log-service.d.ts +10 -0
- package/package.json +2 -2
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
readCachedTextFile
|
|
4
|
+
} from "./index-jtqkh8jf.js";
|
|
5
|
+
import {
|
|
6
|
+
SwarmError
|
|
7
|
+
} from "./index-zfsbaaqh.js";
|
|
8
|
+
import {
|
|
9
|
+
warn
|
|
10
|
+
} from "./index-yx44zd0p.js";
|
|
11
|
+
import {
|
|
12
|
+
bunFile
|
|
13
|
+
} from "./index-b9v501fr.js";
|
|
14
|
+
|
|
15
|
+
// src/hooks/utils.ts
|
|
16
|
+
import * as path from "path";
|
|
17
|
+
var _internals = { safeHook, composeHandlers, validateSwarmPath, readSwarmFileAsync };
|
|
18
|
+
function safeHook(fn) {
|
|
19
|
+
return async (input, output) => {
|
|
20
|
+
try {
|
|
21
|
+
await fn(input, output);
|
|
22
|
+
} catch (_error) {
|
|
23
|
+
const functionName = fn.name || "unknown";
|
|
24
|
+
if (_error instanceof SwarmError) {
|
|
25
|
+
warn(`Hook '${functionName}' failed: ${_error.message}
|
|
26
|
+
\u2192 ${_error.guidance}`);
|
|
27
|
+
} else {
|
|
28
|
+
warn(`Hook function '${functionName}' failed:`, _error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function composeHandlers(...fns) {
|
|
34
|
+
if (fns.length === 0) {
|
|
35
|
+
return async () => {};
|
|
36
|
+
}
|
|
37
|
+
return async (input, output) => {
|
|
38
|
+
for (const fn of fns) {
|
|
39
|
+
const safeFn = _internals.safeHook(fn);
|
|
40
|
+
await safeFn(input, output);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function validateSwarmPath(directory, filename) {
|
|
45
|
+
if (/[\0]/.test(filename)) {
|
|
46
|
+
throw new Error("Invalid filename: contains null bytes");
|
|
47
|
+
}
|
|
48
|
+
if (/\.\.[/\\]/.test(filename)) {
|
|
49
|
+
throw new Error("Invalid filename: path traversal detected");
|
|
50
|
+
}
|
|
51
|
+
if (/^[A-Za-z]:[\\/]/.test(filename)) {
|
|
52
|
+
throw new Error("Invalid filename: path escapes .swarm directory");
|
|
53
|
+
}
|
|
54
|
+
if (filename.startsWith("/")) {
|
|
55
|
+
throw new Error("Invalid filename: path escapes .swarm directory");
|
|
56
|
+
}
|
|
57
|
+
const baseDir = path.normalize(path.resolve(directory, ".swarm"));
|
|
58
|
+
const resolved = path.normalize(path.resolve(baseDir, filename));
|
|
59
|
+
if (process.platform === "win32") {
|
|
60
|
+
if (!resolved.toLowerCase().startsWith((baseDir + path.sep).toLowerCase())) {
|
|
61
|
+
throw new Error("Invalid filename: path escapes .swarm directory");
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
if (!resolved.startsWith(baseDir + path.sep)) {
|
|
65
|
+
throw new Error("Invalid filename: path escapes .swarm directory");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return resolved;
|
|
69
|
+
}
|
|
70
|
+
async function readSwarmFileAsync(directory, filename) {
|
|
71
|
+
const maxAttempts = 5;
|
|
72
|
+
const retryDelayMs = 10;
|
|
73
|
+
for (let attempt = 0;attempt < maxAttempts; attempt++) {
|
|
74
|
+
try {
|
|
75
|
+
const resolvedPath = _internals.validateSwarmPath(directory, filename);
|
|
76
|
+
return await readCachedTextFile(resolvedPath, async () => {
|
|
77
|
+
const file = bunFile(resolvedPath);
|
|
78
|
+
return await file.text();
|
|
79
|
+
});
|
|
80
|
+
} catch (err) {
|
|
81
|
+
const isNotFound = err?.code === "ENOENT";
|
|
82
|
+
if (!isNotFound || attempt === maxAttempts - 1) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
await new Promise((resolve2) => setTimeout(resolve2, retryDelayMs));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { safeHook, validateSwarmPath, readSwarmFileAsync };
|