opencode-swarm 7.181.1 → 7.181.3
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/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
- package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
- package/dist/background/stage-b-gates.d.ts +4 -0
- package/dist/cli/{coder-settlement-ee8bmg83.js → coder-settlement-txte2m87.js} +11 -11
- package/dist/cli/{config-doctor-mnmxzg86.js → config-doctor-101n3c1r.js} +3 -3
- package/dist/cli/{core-m9yymv84.js → core-s0yzzpaj.js} +3 -3
- package/dist/cli/{curation-policy-m3x9mkj9.js → curation-policy-r4dkajw9.js} +4 -4
- package/dist/cli/{curator-7nmwpcxy.js → curator-dp49fr0p.js} +38 -38
- package/dist/cli/curator-drift-r7w3cg3m.js +37 -0
- package/dist/cli/curator-llm-factory-tycc9xkw.js +74 -0
- package/dist/cli/{evidence-summary-service-m2b0mxmr.js → evidence-summary-service-r648x5f2.js} +17 -17
- package/dist/cli/{gate-evidence-4y2x85g4.js → gate-evidence-8rh69tsh.js} +6 -6
- package/dist/cli/guardrail-explain-dfyj1g1c.js +75 -0
- package/dist/cli/{guardrail-log-202rfw7b.js → guardrail-log-yr60w7h6.js} +7 -7
- package/dist/cli/{guardrail-reset-7nt7z18b.js → guardrail-reset-eztc62va.js} +38 -38
- package/dist/cli/{hive-promoter-segsykns.js → hive-promoter-g56ba4a4.js} +38 -38
- package/dist/cli/{index-m65tnv4j.js → index-01r2wrwa.js} +1 -1
- package/dist/cli/{index-hxe22tx3.js → index-1ks0rnzn.js} +5 -5
- package/dist/cli/{index-ztph1v9m.js → index-1w1xrk5k.js} +1 -1
- package/dist/cli/{index-12ewkms0.js → index-23mdeh2a.js} +1 -1
- package/dist/cli/{index-a7z6jygf.js → index-2pt5g7zz.js} +3 -3
- package/dist/cli/{index-y4zjbrqs.js → index-2t21pv2v.js} +1 -1
- package/dist/cli/{index-38cfx8g8.js → index-427x3j6p.js} +2 -2
- package/dist/cli/{index-tczqm089.js → index-4ffryqb1.js} +1 -1
- package/dist/cli/{index-pee6ykkg.js → index-4jvt3r77.js} +5 -5
- package/dist/cli/{index-908yea8v.js → index-6ep83w7x.js} +1 -1
- package/dist/cli/{index-r6p6x0pb.js → index-789tdsfv.js} +4 -4
- package/dist/cli/{index-yhx94xpr.js → index-7s6ct0t2.js} +6 -6
- package/dist/cli/{index-9j5jjqks.js → index-8c37kzh6.js} +7 -7
- package/dist/cli/{index-gc6h1fmf.js → index-a2hvmc3a.js} +1 -1
- package/dist/cli/{index-ea9fk6v0.js → index-ap6hs8fj.js} +1 -1
- package/dist/cli/{index-92m05mew.js → index-by9wfeja.js} +1 -1
- package/dist/cli/{index-kjstkfgh.js → index-ckrm4784.js} +7 -7
- package/dist/cli/{index-rxs0rrv1.js → index-dy9mxh0z.js} +40 -40
- package/dist/cli/{index-b2zbak7v.js → index-ekwe81my.js} +2 -2
- package/dist/cli/{index-3qhx9dx0.js → index-h6gxh3an.js} +4946 -1965
- package/dist/cli/{index-basp4sxt.js → index-hcaspktr.js} +1 -1
- package/dist/cli/{index-bdpgfep1.js → index-jrxrjz89.js} +1 -1
- package/dist/cli/{index-q1prchye.js → index-k5rqe97g.js} +27 -13
- package/dist/cli/{index-4h54k8h3.js → index-kexzhwbq.js} +2 -2
- package/dist/cli/{index-516j9vsk.js → index-kkrbybgt.js} +27 -2
- package/dist/cli/{index-cyyvc1cd.js → index-m4e3p8na.js} +2 -2
- package/dist/cli/{index-jqjdejqe.js → index-mdqp0cq2.js} +4 -4
- package/dist/cli/{index-6mwha20t.js → index-mkpdcbye.js} +3 -3
- package/dist/cli/{index-y30y1rkg.js → index-nw3z614g.js} +6 -6
- package/dist/cli/{index-nhxykfyy.js → index-nw8pfcw1.js} +270 -10
- package/dist/cli/{index-na3br902.js → index-qdz43cne.js} +38 -38
- package/dist/cli/{index-g9ax7jyf.js → index-rchygh27.js} +57 -4
- package/dist/cli/{index-6gcxgx84.js → index-s34y6gbh.js} +1 -1
- package/dist/cli/{index-s0zgz4p1.js → index-sf51gh68.js} +1 -1
- package/dist/cli/{index-gydvqmtg.js → index-sr9k8sh7.js} +4 -4
- package/dist/cli/{index-edb3sgxg.js → index-ttgex8ky.js} +6 -6
- package/dist/cli/{index-91dhg3wr.js → index-ved1325w.js} +2 -2
- package/dist/cli/{index-rw0wy2y7.js → index-vgjmahnd.js} +3 -3
- package/dist/cli/{index-bv4b8tpa.js → index-vvgpgcyn.js} +10 -0
- package/dist/cli/{index-vmthakz0.js → index-w1ydvzef.js} +1 -1
- package/dist/cli/{index-gqe4sm73.js → index-xqr076aq.js} +4 -4
- package/dist/cli/{index-g5wjasjn.js → index-yv0q0hp9.js} +140 -9
- package/dist/cli/{index-vs83acgx.js → index-yzapt508.js} +3 -3
- package/dist/cli/index.js +39 -39
- package/dist/cli/{knowledge-escalator-r9chkas8.js → knowledge-escalator-0rcft6q4.js} +12 -12
- package/dist/cli/{knowledge-events-5j2n6age.js → knowledge-events-7jyz3qxs.js} +10 -10
- package/dist/cli/{knowledge-link-s2qs178z.js → knowledge-link-655xa3db.js} +3 -3
- package/dist/cli/{knowledge-store-mybx9bmx.js → knowledge-store-asa26g6p.js} +4 -4
- package/dist/cli/{knowledge-validator-v1sj9tv4.js → knowledge-validator-j3x9ezej.js} +6 -6
- package/dist/cli/{mcp-7yx5230p.js → mcp-70hefjk6.js} +1 -1
- package/dist/cli/model-preflight-szekh1dc.js +359 -0
- package/dist/cli/{pending-delegations-amjfmc7t.js → pending-delegations-rb6bhv5x.js} +10 -10
- package/dist/cli/{pr-subscriptions-rctqs0gk.js → pr-subscriptions-v4ms5pfb.js} +10 -10
- package/dist/cli/{pr-workflow-gate-9he8ys4e.js → pr-workflow-gate-qmfpz6wb.js} +38 -38
- package/dist/cli/{runner-tzgwvvn1.js → runner-b5vt1any.js} +4 -4
- package/dist/cli/{scan-cursor-pxqkphrh.js → scan-cursor-7zn4t1hw.js} +5 -5
- package/dist/cli/{schema-n8pk3f80.js → schema-tx62mfy8.js} +2 -2
- package/dist/cli/{scope-persistence-p992x2yd.js → scope-persistence-f8w12sns.js} +14 -14
- package/dist/cli/{server-ywrd2q6z.js → server-f2vrp2wc.js} +73 -603
- package/dist/cli/{skill-generator-cdppktqx.js → skill-generator-jme09w7n.js} +14 -14
- package/dist/cli/{snapshot-coordination-init-z42ev5g9.js → snapshot-coordination-init-ad83sq6c.js} +38 -38
- package/dist/cli/{speckit-checkoff-6ynv46bn.js → speckit-checkoff-98gfvn3r.js} +4 -4
- package/dist/cli/{telemetry-zhcgfe70.js → telemetry-6k8t2mrw.js} +1 -1
- package/dist/cli/{workspace-snapshot-4m2ex1ey.js → workspace-snapshot-hsssm50w.js} +2 -2
- package/dist/cli/{worktree-collision-ownership-65971p3m.js → worktree-collision-ownership-47kdjtqb.js} +11 -11
- package/dist/cli/{worktree-isolation-xf7dfc46.js → worktree-isolation-etaawcnt.js} +38 -38
- package/dist/commands/registry.d.ts +1 -1
- package/dist/config/agent-model.d.ts +14 -0
- package/dist/config/bundled-skill-dispositions.d.ts +29 -0
- package/dist/db/qa-gate-profile.d.ts +6 -3
- package/dist/db/qa-gate-session-override.d.ts +72 -0
- package/dist/index.js +404 -390
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/instruction-pairing.d.ts +112 -0
- package/dist/services/model-preflight.d.ts +103 -21
- package/dist/session/restart-reconciliation.d.ts +74 -0
- package/dist/state.d.ts +6 -3
- package/dist/tools/get-qa-gate-profile.d.ts +13 -6
- package/package.json +1 -1
- package/dist/cli/curator-drift-q42fr0c9.js +0 -297
- package/dist/cli/curator-llm-factory-s1b2p162.js +0 -74
- package/dist/cli/guardrail-explain-nvmf3y7j.js +0 -75
- package/dist/cli/model-preflight-ckvv1arg.js +0 -170
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
canonicalProjectKey,
|
|
4
|
-
getGlobalEventBus,
|
|
5
|
-
getGroupCommitWriter,
|
|
6
|
-
importLegacyJsonFiles
|
|
7
|
-
} from "./index-nhxykfyy.js";
|
|
8
|
-
import {
|
|
9
|
-
readEffectiveSpecSync
|
|
10
|
-
} from "./index-tczqm089.js";
|
|
11
|
-
import"./index-908yea8v.js";
|
|
12
|
-
import {
|
|
13
|
-
readSwarmFileAsync
|
|
14
|
-
} from "./index-gc6h1fmf.js";
|
|
15
|
-
import"./index-2s7dvzff.js";
|
|
16
|
-
import"./index-0725jpp7.js";
|
|
17
|
-
import {
|
|
18
|
-
DURABILITY_CLASSES,
|
|
19
|
-
getProjectDb,
|
|
20
|
-
projectDbExists
|
|
21
|
-
} from "./index-bv4b8tpa.js";
|
|
22
|
-
import"./index-rdm3px0g.js";
|
|
23
|
-
import"./index-ry16d01s.js";
|
|
24
|
-
import"./index-1xnse449.js";
|
|
25
|
-
import"./index-c1ggtmpm.js";
|
|
26
|
-
import"./index-ejhxgyvm.js";
|
|
27
|
-
import"./index-7g4c7s5r.js";
|
|
28
|
-
import"./index-989v83pb.js";
|
|
29
|
-
import"./index-basp4sxt.js";
|
|
30
|
-
import"./index-zxdawwc7.js";
|
|
31
|
-
import"./index-g9ax7jyf.js";
|
|
32
|
-
import"./index-y4zjbrqs.js";
|
|
33
|
-
import"./index-bk5tah7q.js";
|
|
34
|
-
import"./index-gknz3bv1.js";
|
|
35
|
-
import"./index-zpsr8rpc.js";
|
|
36
|
-
import {
|
|
37
|
-
init_logger,
|
|
38
|
-
warn
|
|
39
|
-
} from "./index-zgwm4ryv.js";
|
|
40
|
-
import"./index-a76rekgs.js";
|
|
41
|
-
|
|
42
|
-
// src/db/phase-report-store.ts
|
|
43
|
-
import { readdirSync } from "fs";
|
|
44
|
-
import { join } from "path";
|
|
45
|
-
var PHASE_REPORT_LEGACY_PREFIXES = {
|
|
46
|
-
curator_drift: "drift-report-phase-",
|
|
47
|
-
design_doc_drift: "doc-drift-phase-"
|
|
48
|
-
};
|
|
49
|
-
var importedRoots = new Set;
|
|
50
|
-
function hasAnyPhaseReportState(directory) {
|
|
51
|
-
if (projectDbExists(directory))
|
|
52
|
-
return true;
|
|
53
|
-
const root = canonicalProjectKey(directory);
|
|
54
|
-
let entries;
|
|
55
|
-
try {
|
|
56
|
-
entries = readdirSync(join(root, ".swarm"));
|
|
57
|
-
} catch {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
for (const prefix of Object.values(PHASE_REPORT_LEGACY_PREFIXES)) {
|
|
61
|
-
if (entries.some((name) => name.startsWith(prefix) && name.endsWith(".json") && !name.includes(".imported"))) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
function kindCount(db, kind) {
|
|
68
|
-
return db.query("SELECT COUNT(*) as count FROM phase_report WHERE kind = ?").get(kind)?.count ?? 0;
|
|
69
|
-
}
|
|
70
|
-
function ensurePhaseReportsImported(directory) {
|
|
71
|
-
const root = canonicalProjectKey(directory);
|
|
72
|
-
if (importedRoots.has(root))
|
|
73
|
-
return;
|
|
74
|
-
for (const kind of Object.keys(PHASE_REPORT_LEGACY_PREFIXES)) {
|
|
75
|
-
importLegacyJsonFiles(directory, {
|
|
76
|
-
filePrefix: PHASE_REPORT_LEGACY_PREFIXES[kind],
|
|
77
|
-
kind,
|
|
78
|
-
kindCount: (db) => kindCount(db, kind),
|
|
79
|
-
upsertRow: (db, phase, payload) => {
|
|
80
|
-
db.run(`INSERT INTO phase_report (kind, phase, payload, updated_at)
|
|
81
|
-
VALUES (?, ?, ?, datetime('now'))
|
|
82
|
-
ON CONFLICT(kind, phase) DO UPDATE SET
|
|
83
|
-
payload = excluded.payload,
|
|
84
|
-
updated_at = datetime('now')`, [kind, phase, payload]);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
importedRoots.add(root);
|
|
89
|
-
}
|
|
90
|
-
async function upsertPhaseReportDb(directory, kind, phase, payload) {
|
|
91
|
-
ensurePhaseReportsImported(directory);
|
|
92
|
-
const writer = getGroupCommitWriter(directory);
|
|
93
|
-
writer.enqueue({
|
|
94
|
-
durability: DURABILITY_CLASSES.phase_report,
|
|
95
|
-
run: (db) => {
|
|
96
|
-
db.run(`INSERT INTO phase_report (kind, phase, payload, updated_at)
|
|
97
|
-
VALUES (?, ?, ?, datetime('now'))
|
|
98
|
-
ON CONFLICT(kind, phase) DO UPDATE SET
|
|
99
|
-
payload = excluded.payload,
|
|
100
|
-
updated_at = datetime('now')`, [kind, phase, payload]);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
await writer.flush();
|
|
104
|
-
}
|
|
105
|
-
function readPhaseReportsDb(directory, kind) {
|
|
106
|
-
if (!hasAnyPhaseReportState(directory))
|
|
107
|
-
return [];
|
|
108
|
-
ensurePhaseReportsImported(directory);
|
|
109
|
-
const db = getProjectDb(directory);
|
|
110
|
-
return db.query("SELECT phase, payload FROM phase_report WHERE kind = ? ORDER BY phase").all(kind).map((row) => ({ phase: row.phase, payload: row.payload }));
|
|
111
|
-
}
|
|
112
|
-
function phaseReportLocator(kind, phase) {
|
|
113
|
-
return `swarm.db:phase_report(${kind},${phase})`;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/hooks/curator-drift.ts
|
|
117
|
-
init_logger();
|
|
118
|
-
async function readPriorDriftReports(directory) {
|
|
119
|
-
const reports = [];
|
|
120
|
-
try {
|
|
121
|
-
for (const row of readPhaseReportsDb(directory, "curator_drift")) {
|
|
122
|
-
try {
|
|
123
|
-
const report = JSON.parse(row.payload);
|
|
124
|
-
if (typeof report.phase !== "number" || typeof report.alignment !== "string" || typeof report.timestamp !== "string" || typeof report.drift_score !== "number" || typeof report.schema_version !== "number" || !Array.isArray(report.compounding_effects)) {
|
|
125
|
-
warn(`[curator-drift] Skipping corrupt drift report: phase ${row.phase}`);
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
reports.push(report);
|
|
129
|
-
} catch {
|
|
130
|
-
warn(`[curator-drift] Skipping unreadable drift report: phase ${row.phase}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
} catch {
|
|
134
|
-
return [];
|
|
135
|
-
}
|
|
136
|
-
reports.sort((a, b) => a.phase - b.phase);
|
|
137
|
-
return reports;
|
|
138
|
-
}
|
|
139
|
-
async function writeDriftReport(directory, report) {
|
|
140
|
-
const locator = phaseReportLocator("curator_drift", report.phase);
|
|
141
|
-
try {
|
|
142
|
-
await upsertPhaseReportDb(directory, "curator_drift", report.phase, JSON.stringify(report, null, 2));
|
|
143
|
-
} catch (err) {
|
|
144
|
-
throw new Error(`[curator-drift] Failed to write drift report to ${locator}: ${String(err)}`);
|
|
145
|
-
}
|
|
146
|
-
return locator;
|
|
147
|
-
}
|
|
148
|
-
var _internals = {
|
|
149
|
-
readPriorDriftReports,
|
|
150
|
-
writeDriftReport,
|
|
151
|
-
runDeterministicDriftCheck,
|
|
152
|
-
buildDriftInjectionText
|
|
153
|
-
};
|
|
154
|
-
function extractRequirementIds(text) {
|
|
155
|
-
const matches = text.match(/(?:[A-Za-z0-9][A-Za-z0-9._-]*\/)?FR-\d{3}/g);
|
|
156
|
-
return matches ? [...new Set(matches)] : [];
|
|
157
|
-
}
|
|
158
|
-
function bareSuffixCovers(specId, refId) {
|
|
159
|
-
return refId === specId || !refId.includes("/") && specId.endsWith(`/${refId}`);
|
|
160
|
-
}
|
|
161
|
-
async function runDeterministicDriftCheck(directory, phase, curatorResult, config, injectAdvisory) {
|
|
162
|
-
try {
|
|
163
|
-
const planMd = await readSwarmFileAsync(directory, "plan.md");
|
|
164
|
-
const specMd = readEffectiveSpecSync(directory)?.content ?? null;
|
|
165
|
-
const priorReports = await _internals.readPriorDriftReports(directory);
|
|
166
|
-
const complianceCount = curatorResult.compliance.length;
|
|
167
|
-
const warningCompliance = curatorResult.compliance.filter((obs) => obs.severity === "warning");
|
|
168
|
-
let alignment = "ALIGNED";
|
|
169
|
-
let driftScore = 0;
|
|
170
|
-
const specRequirements = specMd ? extractRequirementIds(specMd) : [];
|
|
171
|
-
const planRequirements = planMd ? extractRequirementIds(planMd) : [];
|
|
172
|
-
const digestRequirements = extractRequirementIds(JSON.stringify(curatorResult.digest) + JSON.stringify(curatorResult.compliance) + JSON.stringify(curatorResult.knowledge_recommendations ?? []));
|
|
173
|
-
if (!planMd) {
|
|
174
|
-
alignment = "MINOR_DRIFT";
|
|
175
|
-
driftScore = 0.3;
|
|
176
|
-
} else if (specRequirements.length > 0) {
|
|
177
|
-
const coveredInPlan = specRequirements.filter((fr) => planRequirements.some((ref) => bareSuffixCovers(fr, ref)));
|
|
178
|
-
const coveredInDigest = specRequirements.filter((fr) => digestRequirements.some((ref) => bareSuffixCovers(fr, ref)));
|
|
179
|
-
const specCoverageRatio = coveredInPlan.length / specRequirements.length;
|
|
180
|
-
const implementationRatio = coveredInDigest.length / specRequirements.length;
|
|
181
|
-
if (specCoverageRatio < 0.5) {
|
|
182
|
-
alignment = "MAJOR_DRIFT";
|
|
183
|
-
driftScore = Math.min(0.9, 0.6 + (1 - specCoverageRatio) * 0.3);
|
|
184
|
-
} else if (warningCompliance.length >= 3) {
|
|
185
|
-
alignment = "MAJOR_DRIFT";
|
|
186
|
-
driftScore = Math.min(0.9, 0.5 + warningCompliance.length * 0.1);
|
|
187
|
-
} else if (warningCompliance.length >= 1 || complianceCount >= 3) {
|
|
188
|
-
alignment = "MINOR_DRIFT";
|
|
189
|
-
driftScore = Math.min(0.49, 0.2 + complianceCount * 0.05);
|
|
190
|
-
} else if (implementationRatio < 0.5) {
|
|
191
|
-
alignment = "MINOR_DRIFT";
|
|
192
|
-
driftScore = Math.min(0.6, 0.2 + (1 - implementationRatio) * 0.3);
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
if (warningCompliance.length >= 3) {
|
|
196
|
-
alignment = "MAJOR_DRIFT";
|
|
197
|
-
driftScore = Math.min(0.9, 0.5 + warningCompliance.length * 0.1);
|
|
198
|
-
} else if (warningCompliance.length >= 1 || complianceCount >= 3) {
|
|
199
|
-
alignment = "MINOR_DRIFT";
|
|
200
|
-
driftScore = Math.min(0.49, 0.2 + complianceCount * 0.05);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
const keyCorrections = warningCompliance.map((obs) => obs.description);
|
|
204
|
-
const firstDeviation = warningCompliance.length > 0 ? {
|
|
205
|
-
phase,
|
|
206
|
-
task: "unknown",
|
|
207
|
-
description: warningCompliance[0]?.description ?? ""
|
|
208
|
-
} : null;
|
|
209
|
-
const requirementsChecked = curatorResult.digest.tasks_total;
|
|
210
|
-
const requirementsSatisfied = curatorResult.digest.tasks_completed;
|
|
211
|
-
const coverageNote = specRequirements.length > 0 ? ` [${digestRequirements.filter((ref) => specRequirements.some((fr) => bareSuffixCovers(fr, ref))).length}/${specRequirements.length} FRs covered]` : "";
|
|
212
|
-
const injectionSummaryRaw = `Phase ${phase}: ${alignment} (${driftScore.toFixed(2)})${coverageNote} \u2014 ${firstDeviation ? firstDeviation.description : "all requirements on track"}.${keyCorrections.length > 0 ? `Correction: ${keyCorrections[0] ?? ""}.` : ""}`;
|
|
213
|
-
const injectionSummary = injectionSummaryRaw.slice(0, config.drift_inject_max_chars);
|
|
214
|
-
const report = {
|
|
215
|
-
schema_version: 1,
|
|
216
|
-
phase,
|
|
217
|
-
timestamp: new Date().toISOString(),
|
|
218
|
-
alignment,
|
|
219
|
-
drift_score: driftScore,
|
|
220
|
-
first_deviation: firstDeviation,
|
|
221
|
-
compounding_effects: priorReports.filter((r) => r.alignment !== "ALIGNED").map((r) => `Phase ${r.phase}: ${r.alignment}`).slice(0, 5),
|
|
222
|
-
corrections: keyCorrections.slice(0, 5),
|
|
223
|
-
requirements_checked: requirementsChecked,
|
|
224
|
-
requirements_satisfied: requirementsSatisfied,
|
|
225
|
-
scope_additions: [],
|
|
226
|
-
injection_summary: injectionSummary
|
|
227
|
-
};
|
|
228
|
-
const reportPath = await _internals.writeDriftReport(directory, report);
|
|
229
|
-
getGlobalEventBus().publish("curator.drift.completed", {
|
|
230
|
-
phase,
|
|
231
|
-
alignment,
|
|
232
|
-
drift_score: driftScore,
|
|
233
|
-
report_path: reportPath
|
|
234
|
-
});
|
|
235
|
-
if (injectAdvisory && alignment !== "ALIGNED" && driftScore > 0) {
|
|
236
|
-
try {
|
|
237
|
-
const advisoryText = `CURATOR DRIFT DETECTED (phase ${phase}, score ${driftScore.toFixed(2)}): ${injectionSummary.slice(0, 300)}. Review the phase-${phase} drift report stored in .swarm/swarm.db (${phaseReportLocator("curator_drift", phase)}) and address spec alignment before proceeding. Consider running critic_drift_verifier before phase completion to get a proper drift review.`;
|
|
238
|
-
injectAdvisory(advisoryText);
|
|
239
|
-
} catch {}
|
|
240
|
-
}
|
|
241
|
-
const injectionText = injectionSummary;
|
|
242
|
-
return {
|
|
243
|
-
phase,
|
|
244
|
-
report,
|
|
245
|
-
report_path: reportPath,
|
|
246
|
-
injection_text: injectionText
|
|
247
|
-
};
|
|
248
|
-
} catch (err) {
|
|
249
|
-
getGlobalEventBus().publish("curator.error", {
|
|
250
|
-
operation: "drift",
|
|
251
|
-
phase,
|
|
252
|
-
error: String(err)
|
|
253
|
-
});
|
|
254
|
-
const defaultReport = {
|
|
255
|
-
schema_version: 1,
|
|
256
|
-
phase,
|
|
257
|
-
timestamp: new Date().toISOString(),
|
|
258
|
-
alignment: "ALIGNED",
|
|
259
|
-
drift_score: 0,
|
|
260
|
-
first_deviation: null,
|
|
261
|
-
compounding_effects: [],
|
|
262
|
-
corrections: [],
|
|
263
|
-
requirements_checked: 0,
|
|
264
|
-
requirements_satisfied: 0,
|
|
265
|
-
scope_additions: [],
|
|
266
|
-
injection_summary: `Phase ${phase}: drift analysis unavailable (${String(err)})`
|
|
267
|
-
};
|
|
268
|
-
return {
|
|
269
|
-
phase,
|
|
270
|
-
report: defaultReport,
|
|
271
|
-
report_path: "",
|
|
272
|
-
injection_text: ""
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
function buildDriftInjectionText(report, maxChars) {
|
|
277
|
-
if (maxChars <= 0) {
|
|
278
|
-
return "";
|
|
279
|
-
}
|
|
280
|
-
let text;
|
|
281
|
-
if (report.alignment === "ALIGNED" && report.drift_score < 0.1) {
|
|
282
|
-
text = `<drift_report>Phase ${report.phase}: ALIGNED, all requirements on track.</drift_report>`;
|
|
283
|
-
} else {
|
|
284
|
-
const keyFinding = report.first_deviation?.description ?? "no deviation recorded";
|
|
285
|
-
const score = report.drift_score ?? 0;
|
|
286
|
-
const correctionClause = report.corrections?.[0] ? `Correction: ${report.corrections[0]}.` : "";
|
|
287
|
-
text = `<drift_report>Phase ${report.phase}: ${report.alignment} (${score.toFixed(2)}) \u2014 ${keyFinding}. ${correctionClause}</drift_report>`;
|
|
288
|
-
}
|
|
289
|
-
return text.slice(0, maxChars);
|
|
290
|
-
}
|
|
291
|
-
export {
|
|
292
|
-
writeDriftReport,
|
|
293
|
-
runDeterministicDriftCheck,
|
|
294
|
-
readPriorDriftReports,
|
|
295
|
-
buildDriftInjectionText,
|
|
296
|
-
_internals
|
|
297
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
createCuratorLLMDelegate
|
|
4
|
-
} from "./index-3qhx9dx0.js";
|
|
5
|
-
import"./index-jqjdejqe.js";
|
|
6
|
-
import"./index-hamqvzqn.js";
|
|
7
|
-
import"./index-m65tnv4j.js";
|
|
8
|
-
import"./index-nhxykfyy.js";
|
|
9
|
-
import"./index-b2zbak7v.js";
|
|
10
|
-
import"./index-q1prchye.js";
|
|
11
|
-
import"./index-s0zgz4p1.js";
|
|
12
|
-
import"./index-txdagbh7.js";
|
|
13
|
-
import"./index-tczqm089.js";
|
|
14
|
-
import"./index-6b295cas.js";
|
|
15
|
-
import"./index-vs83acgx.js";
|
|
16
|
-
import"./index-hxe22tx3.js";
|
|
17
|
-
import"./index-cyyvc1cd.js";
|
|
18
|
-
import"./index-rdec0y3z.js";
|
|
19
|
-
import"./index-y30y1rkg.js";
|
|
20
|
-
import"./index-cjapb4hy.js";
|
|
21
|
-
import"./index-zsrtt42s.js";
|
|
22
|
-
import"./index-kjstkfgh.js";
|
|
23
|
-
import"./index-bdpgfep1.js";
|
|
24
|
-
import"./index-92m05mew.js";
|
|
25
|
-
import"./index-pt7h91zc.js";
|
|
26
|
-
import"./index-q7sjgr1y.js";
|
|
27
|
-
import"./index-908yea8v.js";
|
|
28
|
-
import"./index-r6p6x0pb.js";
|
|
29
|
-
import"./index-a7z6jygf.js";
|
|
30
|
-
import"./index-9j5jjqks.js";
|
|
31
|
-
import"./index-g5wjasjn.js";
|
|
32
|
-
import"./index-gc6h1fmf.js";
|
|
33
|
-
import"./index-2s7dvzff.js";
|
|
34
|
-
import"./index-gqe4sm73.js";
|
|
35
|
-
import"./index-6gcxgx84.js";
|
|
36
|
-
import"./index-rtry5xyf.js";
|
|
37
|
-
import"./index-rw0wy2y7.js";
|
|
38
|
-
import"./index-frcemc0b.js";
|
|
39
|
-
import"./index-0725jpp7.js";
|
|
40
|
-
import"./index-pee6ykkg.js";
|
|
41
|
-
import"./index-edb3sgxg.js";
|
|
42
|
-
import"./index-38cfx8g8.js";
|
|
43
|
-
import"./index-91dhg3wr.js";
|
|
44
|
-
import"./index-vmthakz0.js";
|
|
45
|
-
import"./index-bv4b8tpa.js";
|
|
46
|
-
import"./index-rdm3px0g.js";
|
|
47
|
-
import"./index-ry16d01s.js";
|
|
48
|
-
import"./index-516j9vsk.js";
|
|
49
|
-
import"./index-yhx94xpr.js";
|
|
50
|
-
import"./index-vzm6zre7.js";
|
|
51
|
-
import"./index-ae75rja9.js";
|
|
52
|
-
import"./index-12ewkms0.js";
|
|
53
|
-
import"./index-ea9fk6v0.js";
|
|
54
|
-
import"./index-6mwha20t.js";
|
|
55
|
-
import"./index-1xnse449.js";
|
|
56
|
-
import"./index-c1ggtmpm.js";
|
|
57
|
-
import"./index-ejhxgyvm.js";
|
|
58
|
-
import"./index-7g4c7s5r.js";
|
|
59
|
-
import"./index-989v83pb.js";
|
|
60
|
-
import"./index-gx2vp8gx.js";
|
|
61
|
-
import"./index-basp4sxt.js";
|
|
62
|
-
import"./index-zxdawwc7.js";
|
|
63
|
-
import"./index-g9ax7jyf.js";
|
|
64
|
-
import"./index-y4zjbrqs.js";
|
|
65
|
-
import"./index-bk5tah7q.js";
|
|
66
|
-
import"./index-gknz3bv1.js";
|
|
67
|
-
import"./index-zpsr8rpc.js";
|
|
68
|
-
import"./index-wvghb3x6.js";
|
|
69
|
-
import"./index-9rwhas09.js";
|
|
70
|
-
import"./index-zgwm4ryv.js";
|
|
71
|
-
import"./index-a76rekgs.js";
|
|
72
|
-
export {
|
|
73
|
-
createCuratorLLMDelegate
|
|
74
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
handleGuardrailExplain
|
|
4
|
-
} from "./index-4h54k8h3.js";
|
|
5
|
-
import"./index-3qhx9dx0.js";
|
|
6
|
-
import"./index-jqjdejqe.js";
|
|
7
|
-
import"./index-hamqvzqn.js";
|
|
8
|
-
import"./index-m65tnv4j.js";
|
|
9
|
-
import"./index-nhxykfyy.js";
|
|
10
|
-
import"./index-b2zbak7v.js";
|
|
11
|
-
import"./index-q1prchye.js";
|
|
12
|
-
import"./index-s0zgz4p1.js";
|
|
13
|
-
import"./index-txdagbh7.js";
|
|
14
|
-
import"./index-tczqm089.js";
|
|
15
|
-
import"./index-6b295cas.js";
|
|
16
|
-
import"./index-vs83acgx.js";
|
|
17
|
-
import"./index-hxe22tx3.js";
|
|
18
|
-
import"./index-cyyvc1cd.js";
|
|
19
|
-
import"./index-rdec0y3z.js";
|
|
20
|
-
import"./index-y30y1rkg.js";
|
|
21
|
-
import"./index-cjapb4hy.js";
|
|
22
|
-
import"./index-zsrtt42s.js";
|
|
23
|
-
import"./index-kjstkfgh.js";
|
|
24
|
-
import"./index-bdpgfep1.js";
|
|
25
|
-
import"./index-92m05mew.js";
|
|
26
|
-
import"./index-pt7h91zc.js";
|
|
27
|
-
import"./index-q7sjgr1y.js";
|
|
28
|
-
import"./index-908yea8v.js";
|
|
29
|
-
import"./index-r6p6x0pb.js";
|
|
30
|
-
import"./index-a7z6jygf.js";
|
|
31
|
-
import"./index-9j5jjqks.js";
|
|
32
|
-
import"./index-g5wjasjn.js";
|
|
33
|
-
import"./index-gc6h1fmf.js";
|
|
34
|
-
import"./index-2s7dvzff.js";
|
|
35
|
-
import"./index-gqe4sm73.js";
|
|
36
|
-
import"./index-6gcxgx84.js";
|
|
37
|
-
import"./index-rtry5xyf.js";
|
|
38
|
-
import"./index-rw0wy2y7.js";
|
|
39
|
-
import"./index-frcemc0b.js";
|
|
40
|
-
import"./index-0725jpp7.js";
|
|
41
|
-
import"./index-pee6ykkg.js";
|
|
42
|
-
import"./index-edb3sgxg.js";
|
|
43
|
-
import"./index-38cfx8g8.js";
|
|
44
|
-
import"./index-91dhg3wr.js";
|
|
45
|
-
import"./index-vmthakz0.js";
|
|
46
|
-
import"./index-bv4b8tpa.js";
|
|
47
|
-
import"./index-rdm3px0g.js";
|
|
48
|
-
import"./index-ry16d01s.js";
|
|
49
|
-
import"./index-516j9vsk.js";
|
|
50
|
-
import"./index-yhx94xpr.js";
|
|
51
|
-
import"./index-vzm6zre7.js";
|
|
52
|
-
import"./index-ae75rja9.js";
|
|
53
|
-
import"./index-12ewkms0.js";
|
|
54
|
-
import"./index-ea9fk6v0.js";
|
|
55
|
-
import"./index-6mwha20t.js";
|
|
56
|
-
import"./index-1xnse449.js";
|
|
57
|
-
import"./index-c1ggtmpm.js";
|
|
58
|
-
import"./index-ejhxgyvm.js";
|
|
59
|
-
import"./index-7g4c7s5r.js";
|
|
60
|
-
import"./index-989v83pb.js";
|
|
61
|
-
import"./index-gx2vp8gx.js";
|
|
62
|
-
import"./index-basp4sxt.js";
|
|
63
|
-
import"./index-zxdawwc7.js";
|
|
64
|
-
import"./index-g9ax7jyf.js";
|
|
65
|
-
import"./index-y4zjbrqs.js";
|
|
66
|
-
import"./index-bk5tah7q.js";
|
|
67
|
-
import"./index-gknz3bv1.js";
|
|
68
|
-
import"./index-zpsr8rpc.js";
|
|
69
|
-
import"./index-wvghb3x6.js";
|
|
70
|
-
import"./index-9rwhas09.js";
|
|
71
|
-
import"./index-zgwm4ryv.js";
|
|
72
|
-
import"./index-a76rekgs.js";
|
|
73
|
-
export {
|
|
74
|
-
handleGuardrailExplain
|
|
75
|
-
};
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_MODELS,
|
|
4
|
-
init_constants
|
|
5
|
-
} from "./index-y4zjbrqs.js";
|
|
6
|
-
import"./index-zpsr8rpc.js";
|
|
7
|
-
import"./index-a76rekgs.js";
|
|
8
|
-
|
|
9
|
-
// src/services/model-preflight.ts
|
|
10
|
-
init_constants();
|
|
11
|
-
var PROVIDER_LIST_TIMEOUT_MS = 2000;
|
|
12
|
-
function splitModelId(model) {
|
|
13
|
-
const separator = model.indexOf("/");
|
|
14
|
-
if (separator <= 0 || separator === model.length - 1)
|
|
15
|
-
return null;
|
|
16
|
-
return {
|
|
17
|
-
provider: model.slice(0, separator),
|
|
18
|
-
model: model.slice(separator + 1)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function collectConfiguredAgentModels(config) {
|
|
22
|
-
const collected = [];
|
|
23
|
-
const overriddenAgents = new Set;
|
|
24
|
-
const overrides = config?.agents ?? {};
|
|
25
|
-
for (const [agent, override] of Object.entries(overrides)) {
|
|
26
|
-
if (typeof override?.model === "string" && override.model.trim()) {
|
|
27
|
-
collected.push({
|
|
28
|
-
agent,
|
|
29
|
-
model: override.model.trim(),
|
|
30
|
-
source: "override"
|
|
31
|
-
});
|
|
32
|
-
overriddenAgents.add(agent);
|
|
33
|
-
}
|
|
34
|
-
for (const fallback of override?.fallback_models ?? []) {
|
|
35
|
-
if (typeof fallback === "string" && fallback.trim()) {
|
|
36
|
-
collected.push({
|
|
37
|
-
agent,
|
|
38
|
-
model: fallback.trim(),
|
|
39
|
-
source: "fallback"
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
for (const [agent, model] of Object.entries(DEFAULT_MODELS)) {
|
|
45
|
-
if (overriddenAgents.has(agent))
|
|
46
|
-
continue;
|
|
47
|
-
collected.push({ agent, model, source: "default" });
|
|
48
|
-
}
|
|
49
|
-
return collected;
|
|
50
|
-
}
|
|
51
|
-
var CATALOG_CACHE_TTL_MS = 30000;
|
|
52
|
-
var catalogCacheByClient = new WeakMap;
|
|
53
|
-
function invalidateProviderCatalogCache() {
|
|
54
|
-
catalogCacheByClient = new WeakMap;
|
|
55
|
-
}
|
|
56
|
-
async function fetchProviderCatalog(client) {
|
|
57
|
-
if (!client)
|
|
58
|
-
return null;
|
|
59
|
-
const cached = catalogCacheByClient.get(client);
|
|
60
|
-
if (cached && Date.now() - cached.fetchedAt < CATALOG_CACHE_TTL_MS) {
|
|
61
|
-
return cached.catalog;
|
|
62
|
-
}
|
|
63
|
-
let response;
|
|
64
|
-
try {
|
|
65
|
-
response = await _internals.providerList(client);
|
|
66
|
-
} catch {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
const all = response?.data?.all;
|
|
70
|
-
if (!Array.isArray(all))
|
|
71
|
-
return null;
|
|
72
|
-
const catalog = new Map;
|
|
73
|
-
for (const provider of all) {
|
|
74
|
-
if (typeof provider?.id !== "string")
|
|
75
|
-
continue;
|
|
76
|
-
const models = new Set;
|
|
77
|
-
if (provider.models && typeof provider.models === "object") {
|
|
78
|
-
for (const modelKey of Object.keys(provider.models)) {
|
|
79
|
-
models.add(modelKey);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catalog.set(provider.id, models);
|
|
83
|
-
}
|
|
84
|
-
catalogCacheByClient.set(client, { fetchedAt: Date.now(), catalog });
|
|
85
|
-
return catalog;
|
|
86
|
-
}
|
|
87
|
-
function resolveAgainstCatalog(models, catalog) {
|
|
88
|
-
if (catalog === null) {
|
|
89
|
-
return {
|
|
90
|
-
catalogAvailable: false,
|
|
91
|
-
resolutions: models.map((entry) => ({
|
|
92
|
-
...entry,
|
|
93
|
-
status: "unknown",
|
|
94
|
-
detail: "provider catalog unavailable; model resolution not checked"
|
|
95
|
-
}))
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
const resolutions = models.map((entry) => {
|
|
99
|
-
const split = splitModelId(entry.model);
|
|
100
|
-
if (!split) {
|
|
101
|
-
return {
|
|
102
|
-
...entry,
|
|
103
|
-
status: "unknown",
|
|
104
|
-
detail: "model id has no provider prefix; resolution not checked against the catalog"
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
const providerModels = catalog.get(split.provider);
|
|
108
|
-
if (providerModels === undefined) {
|
|
109
|
-
return {
|
|
110
|
-
...entry,
|
|
111
|
-
status: "unresolved",
|
|
112
|
-
detail: `provider "${split.provider}" is not present in the provider catalog`
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
if (!providerModels.has(split.model)) {
|
|
116
|
-
return {
|
|
117
|
-
...entry,
|
|
118
|
-
status: "unresolved",
|
|
119
|
-
detail: `provider "${split.provider}" does not list model "${split.model}"`
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return { ...entry, status: "ok" };
|
|
123
|
-
});
|
|
124
|
-
return { catalogAvailable: true, resolutions };
|
|
125
|
-
}
|
|
126
|
-
async function runModelPreflight(config, client) {
|
|
127
|
-
const models = collectConfiguredAgentModels(config);
|
|
128
|
-
const catalog = await fetchProviderCatalog(client);
|
|
129
|
-
return resolveAgainstCatalog(models, catalog);
|
|
130
|
-
}
|
|
131
|
-
async function checkSingleModelResolution(model, client) {
|
|
132
|
-
const catalog = await fetchProviderCatalog(client);
|
|
133
|
-
if (catalog === null)
|
|
134
|
-
return "unknown";
|
|
135
|
-
const split = splitModelId(model);
|
|
136
|
-
if (!split)
|
|
137
|
-
return "unknown";
|
|
138
|
-
const providerModels = catalog.get(split.provider);
|
|
139
|
-
if (providerModels === undefined || !providerModels.has(split.model)) {
|
|
140
|
-
return "unresolved";
|
|
141
|
-
}
|
|
142
|
-
return "ok";
|
|
143
|
-
}
|
|
144
|
-
var _internals = {
|
|
145
|
-
providerList: async (client) => {
|
|
146
|
-
let timer;
|
|
147
|
-
try {
|
|
148
|
-
return await Promise.race([
|
|
149
|
-
client.provider.list(),
|
|
150
|
-
new Promise((_, reject) => {
|
|
151
|
-
timer = setTimeout(() => reject(new Error("provider list timed out")), PROVIDER_LIST_TIMEOUT_MS);
|
|
152
|
-
})
|
|
153
|
-
]);
|
|
154
|
-
} finally {
|
|
155
|
-
if (timer)
|
|
156
|
-
clearTimeout(timer);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
export {
|
|
161
|
-
splitModelId,
|
|
162
|
-
runModelPreflight,
|
|
163
|
-
resolveAgainstCatalog,
|
|
164
|
-
invalidateProviderCatalogCache,
|
|
165
|
-
fetchProviderCatalog,
|
|
166
|
-
collectConfiguredAgentModels,
|
|
167
|
-
checkSingleModelResolution,
|
|
168
|
-
_internals,
|
|
169
|
-
PROVIDER_LIST_TIMEOUT_MS
|
|
170
|
-
};
|