opencode-swarm 7.159.0 → 7.159.1
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/dist/cli/{coder-settlement-66mqw0xt.js → coder-settlement-d89tqam8.js} +9 -9
- package/dist/cli/{config-doctor-nkx61b9e.js → config-doctor-8zawz3qh.js} +2 -2
- package/dist/cli/{core-b3db7gf6.js → core-pp64ys5v.js} +1 -1
- package/dist/cli/{curation-policy-vn3m5nq2.js → curation-policy-2gq8307w.js} +6 -6
- package/dist/cli/{curator-llm-factory-c4y1mrr5.js → curator-llm-factory-m3yw6sn5.js} +30 -30
- package/dist/cli/{curator-w4ntvkz5.js → curator-mpqpbr0r.js} +30 -30
- package/dist/cli/{evidence-summary-service-vadgnzk6.js → evidence-summary-service-qaq1eba9.js} +12 -12
- package/dist/cli/{gate-evidence-0chatz5e.js → gate-evidence-r0c71n04.js} +6 -6
- package/dist/cli/{guardrail-explain-ax2qmsp4.js → guardrail-explain-5z64w3ah.js} +31 -31
- package/dist/cli/{guardrail-log-t3c9g8tc.js → guardrail-log-f9nf687y.js} +5 -5
- package/dist/cli/{guardrail-reset-wvdb5sv5.js → guardrail-reset-yjwk20rb.js} +30 -30
- package/dist/cli/{hive-promoter-mfq3ee0n.js → hive-promoter-zjtgbh4w.js} +30 -30
- package/dist/cli/{index-nwkr6tvv.js → index-0zerbq1v.js} +1 -1
- package/dist/cli/{index-mc9qgkwd.js → index-1qpagg2t.js} +3 -3
- package/dist/cli/{index-fcp41snp.js → index-29wav1x0.js} +4 -4
- package/dist/cli/{index-ghjs1n7k.js → index-2z00wqvb.js} +3 -3
- package/dist/cli/{index-8kfbdrxa.js → index-36sgq7n9.js} +32 -32
- package/dist/cli/{index-9vt2hknx.js → index-3rcqxbwt.js} +1 -1
- package/dist/cli/{index-hte1e31d.js → index-3scbg6n2.js} +2 -2
- package/dist/cli/{index-e2s08v0q.js → index-4k9pqbxw.js} +2 -2
- package/dist/cli/{index-xmz69g65.js → index-4nc9npx5.js} +2 -2
- package/dist/cli/{index-pfnj5pvs.js → index-54pkyasv.js} +1 -1
- package/dist/cli/{index-6e6qxf5q.js → index-60mzwj91.js} +1 -1
- package/dist/cli/{index-8fqb0ynp.js → index-6z53bew2.js} +1 -1
- package/dist/cli/{index-tcbjjppb.js → index-7yg4ypyg.js} +1 -1
- package/dist/cli/{index-3e8600a7.js → index-86dvzyac.js} +703 -222
- package/dist/cli/{index-vywbn766.js → index-8819vcke.js} +4 -4
- package/dist/cli/{index-04yrxg0z.js → index-9fphcxes.js} +2 -2
- package/dist/cli/{index-1sdb57jv.js → index-9yxyc1gb.js} +6 -6
- package/dist/cli/{index-zcmwwp1x.js → index-a5w29k1t.js} +1 -1
- package/dist/cli/{index-xagq35tf.js → index-av3gnekk.js} +1 -1
- package/dist/cli/{index-erdsawqz.js → index-bea260ta.js} +6 -6
- package/dist/cli/{index-ynjy98vv.js → index-bz7ayg01.js} +5 -5
- package/dist/cli/{index-k4arrwrz.js → index-f3yphmk6.js} +7 -7
- package/dist/cli/{index-5zgf140g.js → index-g6d8xam2.js} +1 -1
- package/dist/cli/{index-k48kgm6z.js → index-gkw7kq6z.js} +5 -5
- package/dist/cli/{index-b82tq895.js → index-k6y6btb6.js} +3 -3
- package/dist/cli/{index-h1g8w4v0.js → index-prknc0xn.js} +129 -44
- package/dist/cli/{index-z54qw70y.js → index-tvz43tea.js} +1 -1
- package/dist/cli/{index-h52hs4e9.js → index-v3jy0tc6.js} +2 -2
- package/dist/cli/{index-pvzaryhr.js → index-ve3v09kq.js} +1 -1
- package/dist/cli/{index-b1tenv2s.js → index-wae55z9w.js} +7 -1
- package/dist/cli/{index-8jnzp5ct.js → index-wttqayp1.js} +2 -2
- package/dist/cli/{index-35grv4jg.js → index-yw26j0q7.js} +7 -7
- package/dist/cli/{index-we3nf5as.js → index-zmc8mm7v.js} +4 -4
- package/dist/cli/{index-7s1hmrfh.js → index-zxkv8x5n.js} +2 -2
- package/dist/cli/index.js +30 -30
- package/dist/cli/{knowledge-escalator-x85t1e66.js → knowledge-escalator-585m4927.js} +11 -11
- package/dist/cli/{knowledge-events-bwx99mxc.js → knowledge-events-ssegqfmy.js} +9 -9
- package/dist/cli/{knowledge-link-cj2abbae.js → knowledge-link-a9fafeb3.js} +5 -5
- package/dist/cli/{knowledge-store-21m81zsa.js → knowledge-store-nznky6cv.js} +6 -6
- package/dist/cli/{knowledge-validator-yxcadg1p.js → knowledge-validator-3byea8gp.js} +8 -8
- package/dist/cli/{pending-delegations-b8qka5nf.js → pending-delegations-qrjq3s29.js} +3 -3
- package/dist/cli/{pr-review-reentry-authorization-wv3ck5kh.js → pr-review-reentry-authorization-w8ja0m2p.js} +30 -30
- package/dist/cli/{pr-subscriptions-j9j70bmd.js → pr-subscriptions-fvmey1x6.js} +4 -4
- package/dist/cli/{runner-sj5sf36c.js → runner-atbehryj.js} +6 -6
- package/dist/cli/{scan-cursor-m3w0tapb.js → scan-cursor-kv9scb2v.js} +7 -7
- package/dist/cli/{schema-0b0dqn28.js → schema-a7f88yc3.js} +1 -1
- package/dist/cli/{scope-persistence-199f7yqc.js → scope-persistence-x6de46s4.js} +8 -8
- package/dist/cli/{skill-generator-a2ekcbe2.js → skill-generator-vwcrfrw3.js} +13 -13
- package/dist/cli/{telemetry-r8e8zey7.js → telemetry-3rh94wv3.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-5qaab3q7.js → worktree-collision-ownership-7kf9mm5z.js} +5 -5
- package/dist/cli/{worktree-isolation-esesc842.js → worktree-isolation-6zh5bxrd.js} +30 -30
- package/dist/config/schema.d.ts +20 -0
- package/dist/evaluation/contracts.d.ts +5 -5
- package/dist/evaluation/ephemeral-agent-dispatcher.d.ts +2 -0
- package/dist/evaluation/model-dispatcher.d.ts +2 -2
- package/dist/index.js +189 -189
- package/dist/observability/catalog.d.ts +5 -3
- package/dist/review/contracts.d.ts +2 -1
- package/dist/review/evidence.d.ts +12 -0
- package/dist/services/cost-accounting.d.ts +100 -0
- package/dist/services/status-service.d.ts +12 -0
- package/dist/telemetry.d.ts +1 -1
- package/opencode-swarm.schema.json +40 -0
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
resolveExecutableFromPath,
|
|
7
7
|
runEvaluation,
|
|
8
8
|
runExternalTool
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-tvz43tea.js";
|
|
10
10
|
import {
|
|
11
11
|
finalizeShellAuditForClose,
|
|
12
12
|
isPolicyProtectedPath,
|
|
@@ -15,13 +15,13 @@ import {
|
|
|
15
15
|
protectedRoots,
|
|
16
16
|
redactDecisionLineForArchive,
|
|
17
17
|
stableCanonicalStringify
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-9fphcxes.js";
|
|
19
19
|
import {
|
|
20
20
|
detectStraySwarmDirs,
|
|
21
21
|
readDoctorArtifact,
|
|
22
22
|
removeStraySwarmDir,
|
|
23
23
|
runConfigDoctor
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-60mzwj91.js";
|
|
25
25
|
import {
|
|
26
26
|
MAX_TRANSIENT_RETRIES,
|
|
27
27
|
archiveEvidence,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
validateProjectRoot,
|
|
69
69
|
validateSymlinkBoundary,
|
|
70
70
|
validateTargetWithinRoot
|
|
71
|
-
} from "./index-
|
|
71
|
+
} from "./index-f3yphmk6.js";
|
|
72
72
|
import {
|
|
73
73
|
EvaluationTaskV1Schema,
|
|
74
74
|
GateAuditManifestV1Schema,
|
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
saveGateAuditResult,
|
|
86
86
|
savePromotionDecision,
|
|
87
87
|
saveTaskSetSnapshot
|
|
88
|
-
} from "./index-
|
|
88
|
+
} from "./index-zxkv8x5n.js";
|
|
89
89
|
import {
|
|
90
90
|
canonicalHash,
|
|
91
91
|
canonicalJson,
|
|
@@ -129,15 +129,15 @@ import {
|
|
|
129
129
|
retireSkill,
|
|
130
130
|
selectCandidateEntries,
|
|
131
131
|
syncBundledProjectSkillsIfMissingAsync
|
|
132
|
-
} from "./index-
|
|
132
|
+
} from "./index-29wav1x0.js";
|
|
133
133
|
import {
|
|
134
134
|
readRecentEscalations
|
|
135
|
-
} from "./index-
|
|
135
|
+
} from "./index-gkw7kq6z.js";
|
|
136
136
|
import {
|
|
137
137
|
alreadyCuratedThisGeneration,
|
|
138
138
|
claimNextScanBatch,
|
|
139
139
|
resolveCohortId
|
|
140
|
-
} from "./index-
|
|
140
|
+
} from "./index-4nc9npx5.js";
|
|
141
141
|
import {
|
|
142
142
|
CURATOR_INIT_PROMPT,
|
|
143
143
|
CURATOR_PHASE_PROMPT,
|
|
@@ -161,7 +161,7 @@ import {
|
|
|
161
161
|
listActive,
|
|
162
162
|
subscribe,
|
|
163
163
|
unsubscribe
|
|
164
|
-
} from "./index-
|
|
164
|
+
} from "./index-1qpagg2t.js";
|
|
165
165
|
import {
|
|
166
166
|
clearWorktreeMergeStatus,
|
|
167
167
|
getAllWorktreeMergeFailures,
|
|
@@ -173,7 +173,7 @@ import {
|
|
|
173
173
|
listCoderSettlementWalStates,
|
|
174
174
|
recoverCoderSettlement,
|
|
175
175
|
recoverStaleCoderSettlements
|
|
176
|
-
} from "./index-
|
|
176
|
+
} from "./index-9yxyc1gb.js";
|
|
177
177
|
import {
|
|
178
178
|
parsePorcelainV2Snapshot,
|
|
179
179
|
resolveCommitCountSince,
|
|
@@ -206,7 +206,7 @@ import {
|
|
|
206
206
|
WORKTREE_LIFECYCLE_LOCK_FILE,
|
|
207
207
|
recordWorktreeProvisioningOwner,
|
|
208
208
|
removeWorktreeProvisioningOwner
|
|
209
|
-
} from "./index-
|
|
209
|
+
} from "./index-6z53bew2.js";
|
|
210
210
|
import {
|
|
211
211
|
appendUnactionable,
|
|
212
212
|
quarantineEntry,
|
|
@@ -217,11 +217,11 @@ import {
|
|
|
217
217
|
validateActionableFields,
|
|
218
218
|
validateLesson,
|
|
219
219
|
validateSkillPath
|
|
220
|
-
} from "./index-
|
|
220
|
+
} from "./index-8819vcke.js";
|
|
221
221
|
import {
|
|
222
222
|
authorizeCuration,
|
|
223
223
|
buildConfigFingerprintInput
|
|
224
|
-
} from "./index-
|
|
224
|
+
} from "./index-54pkyasv.js";
|
|
225
225
|
import {
|
|
226
226
|
cohortConfigFingerprint
|
|
227
227
|
} from "./index-rtry5xyf.js";
|
|
@@ -252,12 +252,12 @@ import {
|
|
|
252
252
|
transitionTaskWorkflowEvidence,
|
|
253
253
|
withTaskEvidenceTransaction,
|
|
254
254
|
writeWorkflowWalFile
|
|
255
|
-
} from "./index-
|
|
255
|
+
} from "./index-zmc8mm7v.js";
|
|
256
256
|
import {
|
|
257
257
|
makeWorktreeBranchName,
|
|
258
258
|
provisionWorktree,
|
|
259
259
|
removeWorktree
|
|
260
|
-
} from "./index-
|
|
260
|
+
} from "./index-ve3v09kq.js";
|
|
261
261
|
import {
|
|
262
262
|
DEFAULT_STALE_DELEGATION_TIMEOUT_MS,
|
|
263
263
|
DELEGATION_COMPACTION_HIGH_WATER_BYTES,
|
|
@@ -272,7 +272,7 @@ import {
|
|
|
272
272
|
scanBackgroundCoderReservationsForAdmission,
|
|
273
273
|
scanDelegationsForRecovery,
|
|
274
274
|
sweepStaleDelegations
|
|
275
|
-
} from "./index-
|
|
275
|
+
} from "./index-4k9pqbxw.js";
|
|
276
276
|
import {
|
|
277
277
|
compositeSessionKey,
|
|
278
278
|
sessionKeySuffix
|
|
@@ -283,7 +283,7 @@ import {
|
|
|
283
283
|
clearAllScopes,
|
|
284
284
|
clearScopeBindingFromDisk,
|
|
285
285
|
clearScopeBindings
|
|
286
|
-
} from "./index-
|
|
286
|
+
} from "./index-bz7ayg01.js";
|
|
287
287
|
import {
|
|
288
288
|
appendLedgerEvent,
|
|
289
289
|
computePlanHash,
|
|
@@ -298,7 +298,7 @@ import {
|
|
|
298
298
|
readPlanEpochIdentity,
|
|
299
299
|
replayFromLedgerWithStatus,
|
|
300
300
|
takeSnapshotEvent
|
|
301
|
-
} from "./index-
|
|
301
|
+
} from "./index-k6y6btb6.js";
|
|
302
302
|
import {
|
|
303
303
|
CORE_EVENT_LOCKED,
|
|
304
304
|
appendCoreEventSync,
|
|
@@ -308,7 +308,7 @@ import {
|
|
|
308
308
|
hasSpecDriftAuditEvent,
|
|
309
309
|
hasTaskRepairAuditEvent,
|
|
310
310
|
readCoreEvents
|
|
311
|
-
} from "./index-
|
|
311
|
+
} from "./index-0zerbq1v.js";
|
|
312
312
|
import {
|
|
313
313
|
sanitizeDiagnosticText
|
|
314
314
|
} from "./index-556ja8an.js";
|
|
@@ -357,7 +357,7 @@ import {
|
|
|
357
357
|
transactFile,
|
|
358
358
|
transactKnowledge,
|
|
359
359
|
wordBigrams
|
|
360
|
-
} from "./index-
|
|
360
|
+
} from "./index-bea260ta.js";
|
|
361
361
|
import {
|
|
362
362
|
MAX_EVENT_LOG_ENTRIES,
|
|
363
363
|
_internals as _internals2,
|
|
@@ -373,10 +373,10 @@ import {
|
|
|
373
373
|
recordKnowledgeEvent,
|
|
374
374
|
recordPhaseCloseIntent,
|
|
375
375
|
resolveKnowledgeEventsPath
|
|
376
|
-
} from "./index-
|
|
376
|
+
} from "./index-yw26j0q7.js";
|
|
377
377
|
import {
|
|
378
378
|
resolveWorktreeIsolationConfig
|
|
379
|
-
} from "./index-
|
|
379
|
+
} from "./index-3scbg6n2.js";
|
|
380
380
|
import {
|
|
381
381
|
RetrospectiveEvidenceSchema
|
|
382
382
|
} from "./index-gprxjmm7.js";
|
|
@@ -399,7 +399,7 @@ import {
|
|
|
399
399
|
init_loader,
|
|
400
400
|
loadPluginConfig,
|
|
401
401
|
loadPluginConfigWithMeta
|
|
402
|
-
} from "./index-
|
|
402
|
+
} from "./index-7yg4ypyg.js";
|
|
403
403
|
import {
|
|
404
404
|
DEFAULT_HARNESS_EVOLUTION_CONFIG,
|
|
405
405
|
DEFAULT_PR_REVIEW_RESILIENCE_CONFIG,
|
|
@@ -415,7 +415,7 @@ import {
|
|
|
415
415
|
package_default,
|
|
416
416
|
resolveAutoReviewConfig,
|
|
417
417
|
stripKnownSwarmPrefix
|
|
418
|
-
} from "./index-
|
|
418
|
+
} from "./index-wae55z9w.js";
|
|
419
419
|
import {
|
|
420
420
|
init_git_executable,
|
|
421
421
|
resolveGitExecutable,
|
|
@@ -455,10 +455,10 @@ import {
|
|
|
455
455
|
resolveLinkDir,
|
|
456
456
|
sanitizeLinkId,
|
|
457
457
|
writeLinkPointer
|
|
458
|
-
} from "./index-
|
|
458
|
+
} from "./index-g6d8xam2.js";
|
|
459
459
|
import {
|
|
460
460
|
atomicWriteFile
|
|
461
|
-
} from "./index-
|
|
461
|
+
} from "./index-v3jy0tc6.js";
|
|
462
462
|
import {
|
|
463
463
|
KNOWLEDGE_SCHEMA_VERSION,
|
|
464
464
|
OUTCOME_BLOCK_THRESHOLD,
|
|
@@ -470,7 +470,7 @@ import {
|
|
|
470
470
|
atomicWriteSwarmFileSync,
|
|
471
471
|
matchTempGrammar,
|
|
472
472
|
parseTargetBasename
|
|
473
|
-
} from "./index-
|
|
473
|
+
} from "./index-a5w29k1t.js";
|
|
474
474
|
import {
|
|
475
475
|
assertProjectRoot,
|
|
476
476
|
hasExplicitProjectBoundary,
|
|
@@ -478,7 +478,7 @@ import {
|
|
|
478
478
|
listActiveLocks,
|
|
479
479
|
tryAcquireLock,
|
|
480
480
|
withEvidenceLock
|
|
481
|
-
} from "./index-
|
|
481
|
+
} from "./index-av3gnekk.js";
|
|
482
482
|
import {
|
|
483
483
|
invalidateCachedArtifact,
|
|
484
484
|
resetSwarmArtifactCache
|
|
@@ -487,7 +487,7 @@ import {
|
|
|
487
487
|
emit,
|
|
488
488
|
getLastHeartbeat,
|
|
489
489
|
telemetry
|
|
490
|
-
} from "./index-
|
|
490
|
+
} from "./index-prknc0xn.js";
|
|
491
491
|
import {
|
|
492
492
|
require_proper_lockfile
|
|
493
493
|
} from "./index-7g4c7s5r.js";
|
|
@@ -15777,38 +15777,339 @@ async function computeGateStatistics(directory, minSamples = 6, runId) {
|
|
|
15777
15777
|
}
|
|
15778
15778
|
|
|
15779
15779
|
// src/services/cost-accounting.ts
|
|
15780
|
-
init_logger();
|
|
15781
15780
|
import * as fs8 from "fs";
|
|
15781
|
+
init_logger();
|
|
15782
15782
|
import * as os from "os";
|
|
15783
15783
|
import * as path16 from "path";
|
|
15784
|
+
var ZERO_USAGE = {
|
|
15785
|
+
tokens_input: 0,
|
|
15786
|
+
tokens_output: 0,
|
|
15787
|
+
tokens_reasoning: 0,
|
|
15788
|
+
tokens_cache: 0
|
|
15789
|
+
};
|
|
15790
|
+
var MAX_EVIDENCE_ITEMS = 8;
|
|
15791
|
+
var MAX_COST_STRING_LENGTH = 128;
|
|
15792
|
+
var MAX_PROVIDER_REPORTED_COST_USD = 1e9;
|
|
15793
|
+
var MAX_TELEMETRY_FILE_BYTES = 4 * 1024 * 1024;
|
|
15794
|
+
function projectCostEvidence(evidence2) {
|
|
15795
|
+
const reports = evidence2.filter((item) => item.kind === "provider_reported" && item.reason !== "missing_cost");
|
|
15796
|
+
const compatibleReports = reports.filter((item) => item.amount_usd !== null && item.amount_usd <= MAX_PROVIDER_REPORTED_COST_USD && item.currency === "USD");
|
|
15797
|
+
const incompatibleReport = reports.some((item) => item.amount_usd !== null && item.amount_usd <= MAX_PROVIDER_REPORTED_COST_USD && (item.currency !== "USD" || item.reason !== "authoritative"));
|
|
15798
|
+
const reportConflict = hasReportConflict(reports);
|
|
15799
|
+
if (!reportConflict && !incompatibleReport && compatibleReports.length > 0) {
|
|
15800
|
+
return {
|
|
15801
|
+
cost_usd: roundUsd(compatibleReports[0].amount_usd ?? 0),
|
|
15802
|
+
cost_source: "reported",
|
|
15803
|
+
evidence_status: "complete",
|
|
15804
|
+
reason: "authoritative",
|
|
15805
|
+
currency: "USD"
|
|
15806
|
+
};
|
|
15807
|
+
}
|
|
15808
|
+
const estimate = evidence2.find((item) => item.kind === "normalized_estimate" && item.amount_usd !== null && item.currency === "USD" && item.reason === "authoritative");
|
|
15809
|
+
const hasHardIncompatibleReport = reports.some((item) => item.amount_usd !== null && item.amount_usd <= MAX_PROVIDER_REPORTED_COST_USD && (item.currency !== "USD" || item.reason === "unsupported_currency"));
|
|
15810
|
+
if (!reportConflict && !hasHardIncompatibleReport && estimate) {
|
|
15811
|
+
return {
|
|
15812
|
+
cost_usd: roundUsd(estimate.amount_usd ?? 0),
|
|
15813
|
+
cost_source: "estimated",
|
|
15814
|
+
evidence_status: "complete",
|
|
15815
|
+
reason: "authoritative",
|
|
15816
|
+
currency: "USD"
|
|
15817
|
+
};
|
|
15818
|
+
}
|
|
15819
|
+
return {
|
|
15820
|
+
cost_usd: null,
|
|
15821
|
+
cost_source: "unavailable",
|
|
15822
|
+
evidence_status: "inconclusive",
|
|
15823
|
+
reason: reportConflict ? "conflict" : incompatibleReport ? reports[0]?.reason ?? "unsupported_currency" : "missing_cost",
|
|
15824
|
+
currency: reports[0]?.currency ?? "unknown"
|
|
15825
|
+
};
|
|
15826
|
+
}
|
|
15784
15827
|
function summarizeTelemetryCosts(directory) {
|
|
15785
15828
|
const summary = createEmptySummary();
|
|
15786
|
-
|
|
15829
|
+
const folded = foldTelemetryEvents(readTelemetryEvents(directory));
|
|
15830
|
+
summary.conflict_count = folded.stats.conflict_count;
|
|
15831
|
+
summary.join_miss_count = folded.stats.join_miss_count;
|
|
15832
|
+
summary.telemetry_error_count = folded.stats.telemetry_error_count;
|
|
15833
|
+
if (folded.stats.join_miss_count > 0 || folded.stats.telemetry_error_count > 0) {
|
|
15834
|
+
summary.evidence_status = "inconclusive";
|
|
15835
|
+
}
|
|
15836
|
+
if (folded.stats.rejected_corrections > 0 || folded.stats.conflict_count > 0) {
|
|
15837
|
+
summary.evidence_status = "inconclusive";
|
|
15838
|
+
}
|
|
15839
|
+
summary.accepted_corrections = folded.stats.accepted_corrections;
|
|
15840
|
+
summary.rejected_corrections = folded.stats.rejected_corrections;
|
|
15841
|
+
summary.duplicate_corrections = folded.stats.duplicate_corrections;
|
|
15842
|
+
for (const event of folded.events) {
|
|
15787
15843
|
if (event.event !== "delegation_end")
|
|
15788
15844
|
continue;
|
|
15789
15845
|
addDelegationEvent(summary, event);
|
|
15790
15846
|
}
|
|
15791
15847
|
return finalizeSummary(summary);
|
|
15792
15848
|
}
|
|
15849
|
+
function foldTelemetryEvents(events) {
|
|
15850
|
+
const stats = {
|
|
15851
|
+
conflict_count: 0,
|
|
15852
|
+
join_miss_count: 0,
|
|
15853
|
+
telemetry_error_count: 0,
|
|
15854
|
+
accepted_corrections: 0,
|
|
15855
|
+
rejected_corrections: 0,
|
|
15856
|
+
duplicate_corrections: 0
|
|
15857
|
+
};
|
|
15858
|
+
const rows = new Map;
|
|
15859
|
+
const states = new Map;
|
|
15860
|
+
const legacy = [];
|
|
15861
|
+
const corrections = [];
|
|
15862
|
+
for (const event of events) {
|
|
15863
|
+
const eventKind = event.event;
|
|
15864
|
+
if (eventKind === "delegation_cost_join" && event.reason === "join_miss") {
|
|
15865
|
+
stats.join_miss_count++;
|
|
15866
|
+
continue;
|
|
15867
|
+
}
|
|
15868
|
+
if (eventKind === "delegation_cost_join" && (event.reason === "unreadable" || event.reason === "malformed")) {
|
|
15869
|
+
stats.telemetry_error_count++;
|
|
15870
|
+
continue;
|
|
15871
|
+
}
|
|
15872
|
+
if (eventKind !== "delegation_end" && eventKind !== "delegation_cost_correction")
|
|
15873
|
+
continue;
|
|
15874
|
+
if (eventKind === "delegation_end") {
|
|
15875
|
+
const recordId = boundedId(event.record_id ?? event.recordId);
|
|
15876
|
+
if (!recordId) {
|
|
15877
|
+
legacy.push(event);
|
|
15878
|
+
continue;
|
|
15879
|
+
}
|
|
15880
|
+
const fingerprint = boundedDigest(event.identity_fingerprint);
|
|
15881
|
+
const initialVersion = validVersion(event.version);
|
|
15882
|
+
if (!fingerprint || initialVersion !== 1) {
|
|
15883
|
+
legacy.push(event);
|
|
15884
|
+
stats.rejected_corrections++;
|
|
15885
|
+
continue;
|
|
15886
|
+
}
|
|
15887
|
+
const snapshot = { ...event, record_id: recordId };
|
|
15888
|
+
const digest2 = boundedDigest(event.digest) ?? costSnapshotDigest(snapshot);
|
|
15889
|
+
if (rows.has(recordId)) {
|
|
15890
|
+
stats.rejected_corrections++;
|
|
15891
|
+
continue;
|
|
15892
|
+
}
|
|
15893
|
+
rows.set(recordId, snapshot);
|
|
15894
|
+
states.set(recordId, {
|
|
15895
|
+
version: initialVersion,
|
|
15896
|
+
digest: digest2,
|
|
15897
|
+
fingerprint
|
|
15898
|
+
});
|
|
15899
|
+
if (parseCostSource(event.cost_source) === "unavailable") {
|
|
15900
|
+
const evidence2 = readEventEvidence(event);
|
|
15901
|
+
if (evidence2.some((item) => item.reason === "conflict"))
|
|
15902
|
+
stats.conflict_count++;
|
|
15903
|
+
}
|
|
15904
|
+
continue;
|
|
15905
|
+
}
|
|
15906
|
+
corrections.push(event);
|
|
15907
|
+
}
|
|
15908
|
+
corrections.sort((left, right) => {
|
|
15909
|
+
const leftRecord = boundedId(left.record_id ?? left.recordId) ?? "";
|
|
15910
|
+
const rightRecord = boundedId(right.record_id ?? right.recordId) ?? "";
|
|
15911
|
+
if (leftRecord !== rightRecord)
|
|
15912
|
+
return leftRecord.localeCompare(rightRecord);
|
|
15913
|
+
return (validVersion(left.version) ?? Number.MAX_SAFE_INTEGER) - (validVersion(right.version) ?? Number.MAX_SAFE_INTEGER);
|
|
15914
|
+
});
|
|
15915
|
+
for (const event of corrections) {
|
|
15916
|
+
const recordId = boundedId(event.record_id ?? event.recordId);
|
|
15917
|
+
const state = recordId ? states.get(recordId) : undefined;
|
|
15918
|
+
const current = recordId ? rows.get(recordId) : undefined;
|
|
15919
|
+
if (!recordId || !state || !current) {
|
|
15920
|
+
stats.rejected_corrections++;
|
|
15921
|
+
continue;
|
|
15922
|
+
}
|
|
15923
|
+
const fingerprint = boundedDigest(event.identity_fingerprint);
|
|
15924
|
+
if (!fingerprint || fingerprint !== state.fingerprint) {
|
|
15925
|
+
stats.rejected_corrections++;
|
|
15926
|
+
continue;
|
|
15927
|
+
}
|
|
15928
|
+
const nextVersion = validVersion(event.version);
|
|
15929
|
+
if (nextVersion === null || nextVersion !== state.version + 1) {
|
|
15930
|
+
stats.rejected_corrections++;
|
|
15931
|
+
continue;
|
|
15932
|
+
}
|
|
15933
|
+
const replacement = {
|
|
15934
|
+
...current,
|
|
15935
|
+
event: "delegation_end",
|
|
15936
|
+
record_id: recordId,
|
|
15937
|
+
version: event.version,
|
|
15938
|
+
digest: event.digest,
|
|
15939
|
+
cost_evidence: event.cost_evidence,
|
|
15940
|
+
evidence_status: event.evidence_status,
|
|
15941
|
+
evidence_reason: event.evidence_reason,
|
|
15942
|
+
currency: event.currency,
|
|
15943
|
+
cost_usd: event.cost_usd,
|
|
15944
|
+
cost_source: event.cost_source,
|
|
15945
|
+
tokens_input: event.tokens_input,
|
|
15946
|
+
tokens_output: event.tokens_output,
|
|
15947
|
+
tokens_reasoning: event.tokens_reasoning,
|
|
15948
|
+
tokens_cache: event.tokens_cache
|
|
15949
|
+
};
|
|
15950
|
+
const digest2 = boundedDigest(event.digest) ?? costSnapshotDigest(replacement);
|
|
15951
|
+
if (digest2 === state.digest) {
|
|
15952
|
+
stats.duplicate_corrections++;
|
|
15953
|
+
states.set(recordId, {
|
|
15954
|
+
version: nextVersion,
|
|
15955
|
+
digest: state.digest,
|
|
15956
|
+
fingerprint: state.fingerprint
|
|
15957
|
+
});
|
|
15958
|
+
continue;
|
|
15959
|
+
}
|
|
15960
|
+
const currentEvidence = readEventEvidence(current);
|
|
15961
|
+
const nextEvidence = readEventEvidence(replacement);
|
|
15962
|
+
if (hasReportConflict(nextEvidence)) {
|
|
15963
|
+
stats.conflict_count++;
|
|
15964
|
+
stats.rejected_corrections++;
|
|
15965
|
+
continue;
|
|
15966
|
+
}
|
|
15967
|
+
if (!isCostUpgrade(currentEvidence, nextEvidence)) {
|
|
15968
|
+
stats.rejected_corrections++;
|
|
15969
|
+
continue;
|
|
15970
|
+
}
|
|
15971
|
+
rows.set(recordId, replacement);
|
|
15972
|
+
states.set(recordId, {
|
|
15973
|
+
version: nextVersion,
|
|
15974
|
+
digest: digest2,
|
|
15975
|
+
fingerprint: state.fingerprint
|
|
15976
|
+
});
|
|
15977
|
+
stats.accepted_corrections++;
|
|
15978
|
+
}
|
|
15979
|
+
return {
|
|
15980
|
+
events: [...legacy, ...rows.values()],
|
|
15981
|
+
stats,
|
|
15982
|
+
versions: Object.fromEntries([...states].map(([recordId, state]) => [recordId, state.version]))
|
|
15983
|
+
};
|
|
15984
|
+
}
|
|
15985
|
+
function boundedId(value) {
|
|
15986
|
+
return typeof value === "string" && /^[A-Za-z0-9_-]{1,32}$/.test(value) ? value : null;
|
|
15987
|
+
}
|
|
15988
|
+
function boundedDigest(value) {
|
|
15989
|
+
return typeof value === "string" && /^[a-f0-9]{32,64}$/.test(value) ? value : undefined;
|
|
15990
|
+
}
|
|
15991
|
+
function validVersion(value) {
|
|
15992
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 1e5 ? value : null;
|
|
15993
|
+
}
|
|
15994
|
+
function readEventEvidence(event) {
|
|
15995
|
+
const value = event.cost_evidence ?? event.evidence;
|
|
15996
|
+
if (!Array.isArray(value))
|
|
15997
|
+
return legacyEventEvidence(event);
|
|
15998
|
+
return value.slice(0, MAX_EVIDENCE_ITEMS).flatMap((item) => {
|
|
15999
|
+
if (!isRecord(item))
|
|
16000
|
+
return [];
|
|
16001
|
+
const kind = item.kind === "provider_reported" || item.kind === "normalized_estimate" ? item.kind : null;
|
|
16002
|
+
const sourcePath = isCostSourcePath(item.source_path) ? item.source_path : null;
|
|
16003
|
+
const amount = readBoundedReportedCost(item.amount_usd);
|
|
16004
|
+
const usage = isRecord(item.usage) ? readPinnedTokens(item.usage) : { ...ZERO_USAGE };
|
|
16005
|
+
if (!kind || !sourcePath)
|
|
16006
|
+
return [];
|
|
16007
|
+
return [
|
|
16008
|
+
{
|
|
16009
|
+
kind,
|
|
16010
|
+
amount_usd: amount,
|
|
16011
|
+
currency: normalizeCurrency(item.currency),
|
|
16012
|
+
source_path: sourcePath,
|
|
16013
|
+
reason: isCostEvidenceReason(item.reason) ? item.reason : amount === null ? "missing_cost" : "authoritative",
|
|
16014
|
+
usage,
|
|
16015
|
+
model: typeof item.model === "string" ? item.model.slice(0, MAX_COST_STRING_LENGTH) : undefined,
|
|
16016
|
+
digest: boundedDigest(item.digest)
|
|
16017
|
+
}
|
|
16018
|
+
];
|
|
16019
|
+
});
|
|
16020
|
+
}
|
|
16021
|
+
function legacyEventEvidence(event) {
|
|
16022
|
+
const amount = readBoundedReportedCost(event.cost_usd);
|
|
16023
|
+
return [
|
|
16024
|
+
{
|
|
16025
|
+
kind: parseCostSource(event.cost_source) === "estimated" ? "normalized_estimate" : "provider_reported",
|
|
16026
|
+
amount_usd: amount,
|
|
16027
|
+
currency: "USD",
|
|
16028
|
+
source_path: "legacy.cost",
|
|
16029
|
+
reason: amount === null ? "legacy" : "authoritative",
|
|
16030
|
+
usage: {
|
|
16031
|
+
tokens_input: readFiniteNonNegative(event.tokens_input) ?? 0,
|
|
16032
|
+
tokens_output: readFiniteNonNegative(event.tokens_output) ?? 0,
|
|
16033
|
+
tokens_reasoning: readFiniteNonNegative(event.tokens_reasoning) ?? 0,
|
|
16034
|
+
tokens_cache: readFiniteNonNegative(event.tokens_cache) ?? 0
|
|
16035
|
+
}
|
|
16036
|
+
}
|
|
16037
|
+
];
|
|
16038
|
+
}
|
|
16039
|
+
function isCostSourcePath(value) {
|
|
16040
|
+
return value === "assistant.cost" || value === "step-finish.cost" || value === "response.info.cost" || value === "response.cost" || value === "legacy.cost" || value === "pricing.model";
|
|
16041
|
+
}
|
|
16042
|
+
function isCostEvidenceReason(value) {
|
|
16043
|
+
return value === "authoritative" || value === "missing_cost" || value === "invalid_number" || value === "pricing_missing" || value === "unsupported_currency" || value === "conflict" || value === "unbilled" || value === "join_miss" || value === "legacy" || value === "unreadable" || value === "partial";
|
|
16044
|
+
}
|
|
16045
|
+
function costSnapshotDigest(event) {
|
|
16046
|
+
const canonical = JSON.stringify({
|
|
16047
|
+
cost_usd: event.cost_usd ?? null,
|
|
16048
|
+
cost_source: parseCostSource(event.cost_source),
|
|
16049
|
+
tokens_input: readFiniteNonNegative(event.tokens_input) ?? 0,
|
|
16050
|
+
tokens_output: readFiniteNonNegative(event.tokens_output) ?? 0,
|
|
16051
|
+
tokens_reasoning: readFiniteNonNegative(event.tokens_reasoning) ?? 0,
|
|
16052
|
+
tokens_cache: readFiniteNonNegative(event.tokens_cache) ?? 0,
|
|
16053
|
+
cost_evidence: Array.isArray(event.cost_evidence) ? event.cost_evidence.slice(0, MAX_EVIDENCE_ITEMS) : undefined
|
|
16054
|
+
});
|
|
16055
|
+
let hash = 2166136261;
|
|
16056
|
+
for (let i = 0;i < canonical.length; i++)
|
|
16057
|
+
hash = Math.imul(hash ^ canonical.charCodeAt(i), 16777619);
|
|
16058
|
+
return `${(hash >>> 0).toString(16).padStart(8, "0")}${canonical.length.toString(16).padStart(8, "0")}`.slice(0, 32);
|
|
16059
|
+
}
|
|
16060
|
+
function evidenceAuthority(evidence2) {
|
|
16061
|
+
const projection = projectCostEvidence(evidence2);
|
|
16062
|
+
return projection.cost_source === "reported" ? 2 : projection.cost_source === "estimated" ? 1 : 0;
|
|
16063
|
+
}
|
|
16064
|
+
function isCostUpgrade(current, next) {
|
|
16065
|
+
const currentProjection = projectCostEvidence(current);
|
|
16066
|
+
const nextProjection = projectCostEvidence(next);
|
|
16067
|
+
const currentAuthority = evidenceAuthority(current);
|
|
16068
|
+
const nextAuthority = evidenceAuthority(next);
|
|
16069
|
+
if (nextAuthority > currentAuthority)
|
|
16070
|
+
return true;
|
|
16071
|
+
if (nextAuthority < currentAuthority)
|
|
16072
|
+
return false;
|
|
16073
|
+
if (currentProjection.cost_usd !== nextProjection.cost_usd)
|
|
16074
|
+
return true;
|
|
16075
|
+
const currentUsage = current.reduce(mergeUsage, { ...ZERO_USAGE });
|
|
16076
|
+
const nextUsage = next.reduce(mergeUsage, { ...ZERO_USAGE });
|
|
16077
|
+
return Object.keys(currentUsage).some((key) => nextUsage[key] > currentUsage[key]);
|
|
16078
|
+
}
|
|
15793
16079
|
function readTelemetryEvents(directory) {
|
|
15794
16080
|
const swarmDir = path16.join(directory, ".swarm");
|
|
15795
16081
|
const files = [
|
|
15796
16082
|
path16.join(swarmDir, "telemetry.jsonl.1"),
|
|
15797
16083
|
path16.join(swarmDir, "telemetry.jsonl")
|
|
15798
16084
|
];
|
|
15799
|
-
|
|
16085
|
+
let tmpDir;
|
|
16086
|
+
try {
|
|
16087
|
+
tmpDir = fs8.mkdtempSync(path16.join(os.tmpdir(), "telemetry-snapshot-"));
|
|
16088
|
+
} catch {
|
|
16089
|
+
return [{ event: "delegation_cost_join", reason: "unreadable" }];
|
|
16090
|
+
}
|
|
15800
16091
|
const snapshotFiles = [];
|
|
16092
|
+
let telemetryErrors = 0;
|
|
15801
16093
|
try {
|
|
15802
16094
|
for (const file of files) {
|
|
15803
16095
|
if (!fs8.existsSync(file))
|
|
15804
16096
|
continue;
|
|
15805
16097
|
const snap = path16.join(tmpDir, path16.basename(file));
|
|
15806
16098
|
try {
|
|
16099
|
+
const stat3 = fs8.statSync(file);
|
|
16100
|
+
if (!stat3.isFile() || stat3.size > MAX_TELEMETRY_FILE_BYTES) {
|
|
16101
|
+
telemetryErrors++;
|
|
16102
|
+
continue;
|
|
16103
|
+
}
|
|
15807
16104
|
fs8.copyFileSync(file, snap);
|
|
15808
16105
|
snapshotFiles.push(snap);
|
|
15809
|
-
} catch {
|
|
16106
|
+
} catch {
|
|
16107
|
+
telemetryErrors++;
|
|
16108
|
+
}
|
|
15810
16109
|
}
|
|
15811
|
-
} catch {
|
|
16110
|
+
} catch {
|
|
16111
|
+
telemetryErrors++;
|
|
16112
|
+
}
|
|
15812
16113
|
const events = [];
|
|
15813
16114
|
let unreadableSnapshots = 0;
|
|
15814
16115
|
let firstUnreadableReason = "";
|
|
@@ -15831,10 +16132,13 @@ function readTelemetryEvents(directory) {
|
|
|
15831
16132
|
const parsed = JSON.parse(trimmed);
|
|
15832
16133
|
if (isRecord(parsed))
|
|
15833
16134
|
events.push(parsed);
|
|
15834
|
-
} catch {
|
|
16135
|
+
} catch {
|
|
16136
|
+
telemetryErrors++;
|
|
16137
|
+
}
|
|
15835
16138
|
}
|
|
15836
16139
|
}
|
|
15837
16140
|
if (unreadableSnapshots > 0) {
|
|
16141
|
+
telemetryErrors += unreadableSnapshots;
|
|
15838
16142
|
warn(`[cost-accounting] ${unreadableSnapshots} of ${snapshotFiles.length} snapshot file(s) were unreadable; cost totals undercount. First reason: ${firstUnreadableReason}`);
|
|
15839
16143
|
}
|
|
15840
16144
|
try {
|
|
@@ -15845,8 +16149,59 @@ function readTelemetryEvents(directory) {
|
|
|
15845
16149
|
}
|
|
15846
16150
|
fs8.rmdirSync(tmpDir);
|
|
15847
16151
|
} catch {}
|
|
16152
|
+
if (telemetryErrors > 0) {
|
|
16153
|
+
events.push({ event: "delegation_cost_join", reason: "unreadable" });
|
|
16154
|
+
}
|
|
15848
16155
|
return events;
|
|
15849
16156
|
}
|
|
16157
|
+
function readPinnedTokens(record) {
|
|
16158
|
+
const tokens = isRecord(record.tokens) ? record.tokens : isRecord(record.usage) ? record.usage : record;
|
|
16159
|
+
return {
|
|
16160
|
+
tokens_input: readFiniteNonNegative(tokens.tokens_input ?? tokens.input ?? tokens.input_tokens ?? tokens.prompt_tokens) ?? 0,
|
|
16161
|
+
tokens_output: readFiniteNonNegative(tokens.tokens_output ?? tokens.output ?? tokens.output_tokens ?? tokens.completion_tokens) ?? 0,
|
|
16162
|
+
tokens_reasoning: readFiniteNonNegative(tokens.tokens_reasoning ?? tokens.reasoning ?? tokens.reasoning_tokens) ?? 0,
|
|
16163
|
+
tokens_cache: readFiniteNonNegative(tokens.tokens_cache) ?? readCacheTokens(tokens) ?? 0
|
|
16164
|
+
};
|
|
16165
|
+
}
|
|
16166
|
+
function mergeUsage(total, next) {
|
|
16167
|
+
const usage = "usage" in next && next.usage ? next.usage : next;
|
|
16168
|
+
return {
|
|
16169
|
+
tokens_input: Math.max(total.tokens_input, usage.tokens_input),
|
|
16170
|
+
tokens_output: Math.max(total.tokens_output, usage.tokens_output),
|
|
16171
|
+
tokens_reasoning: Math.max(total.tokens_reasoning, usage.tokens_reasoning),
|
|
16172
|
+
tokens_cache: Math.max(total.tokens_cache, usage.tokens_cache)
|
|
16173
|
+
};
|
|
16174
|
+
}
|
|
16175
|
+
function readFiniteNonNegative(value) {
|
|
16176
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
|
|
16177
|
+
}
|
|
16178
|
+
function readBoundedReportedCost(value) {
|
|
16179
|
+
const amount = readFiniteNonNegative(value);
|
|
16180
|
+
return amount !== null && amount <= MAX_PROVIDER_REPORTED_COST_USD ? amount : null;
|
|
16181
|
+
}
|
|
16182
|
+
function normalizeCurrency(value) {
|
|
16183
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
16184
|
+
return "unknown";
|
|
16185
|
+
const currency = value.trim().slice(0, MAX_COST_STRING_LENGTH).toUpperCase();
|
|
16186
|
+
return currency || "unknown";
|
|
16187
|
+
}
|
|
16188
|
+
function hasReportConflict(reports) {
|
|
16189
|
+
const monetary = reports.filter((item) => item.kind === "provider_reported" && item.amount_usd !== null);
|
|
16190
|
+
for (let i = 0;i < monetary.length; i++) {
|
|
16191
|
+
for (let j = i + 1;j < monetary.length; j++) {
|
|
16192
|
+
const left = monetary[i];
|
|
16193
|
+
const right = monetary[j];
|
|
16194
|
+
if (left.currency !== right.currency)
|
|
16195
|
+
return true;
|
|
16196
|
+
if (left.currency === "USD" && !withinCostTolerance(left.amount_usd ?? 0, right.amount_usd ?? 0))
|
|
16197
|
+
return true;
|
|
16198
|
+
}
|
|
16199
|
+
}
|
|
16200
|
+
return false;
|
|
16201
|
+
}
|
|
16202
|
+
function withinCostTolerance(left, right) {
|
|
16203
|
+
return Math.abs(left - right) <= Math.max(0.000000001, Math.max(Math.abs(left), Math.abs(right)) * 0.000001);
|
|
16204
|
+
}
|
|
15850
16205
|
function readNumber(record, keys) {
|
|
15851
16206
|
for (const key of keys) {
|
|
15852
16207
|
const value = record[key];
|
|
@@ -15860,6 +16215,22 @@ function readNumber(record, keys) {
|
|
|
15860
16215
|
}
|
|
15861
16216
|
return null;
|
|
15862
16217
|
}
|
|
16218
|
+
function readCacheTokens(record) {
|
|
16219
|
+
const cacheRecord = isRecord(record.cache) ? record.cache : record;
|
|
16220
|
+
const read = readNumber(cacheRecord, [
|
|
16221
|
+
"read",
|
|
16222
|
+
"cache_read_input_tokens",
|
|
16223
|
+
"cached_input_tokens"
|
|
16224
|
+
]);
|
|
16225
|
+
const write = readNumber(cacheRecord, [
|
|
16226
|
+
"write",
|
|
16227
|
+
"cache_write_input_tokens",
|
|
16228
|
+
"write_input_tokens"
|
|
16229
|
+
]);
|
|
16230
|
+
if (read === null && write === null)
|
|
16231
|
+
return null;
|
|
16232
|
+
return (read ?? 0) + (write ?? 0);
|
|
16233
|
+
}
|
|
15863
16234
|
function isRecord(value) {
|
|
15864
16235
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15865
16236
|
}
|
|
@@ -15882,18 +16253,51 @@ function createEmptySummary() {
|
|
|
15882
16253
|
reported: { delegations: 0, cost_usd: 0 },
|
|
15883
16254
|
estimated: { delegations: 0, cost_usd: 0 },
|
|
15884
16255
|
unavailable: { delegations: 0, cost_usd: 0 }
|
|
15885
|
-
}
|
|
16256
|
+
},
|
|
16257
|
+
total_legacy_usd: 0,
|
|
16258
|
+
conflict_count: 0,
|
|
16259
|
+
legacy_count: 0,
|
|
16260
|
+
join_miss_count: 0,
|
|
16261
|
+
telemetry_error_count: 0,
|
|
16262
|
+
accepted_corrections: 0,
|
|
16263
|
+
rejected_corrections: 0,
|
|
16264
|
+
duplicate_corrections: 0,
|
|
16265
|
+
evidence_status: "complete",
|
|
16266
|
+
currencies: []
|
|
15886
16267
|
};
|
|
15887
16268
|
}
|
|
15888
16269
|
function addDelegationEvent(summary, event) {
|
|
15889
|
-
const
|
|
15890
|
-
const
|
|
15891
|
-
const
|
|
16270
|
+
const legacyCostSource = parseCostSource(event.cost_source);
|
|
16271
|
+
const legacyCost = readNumber(event, ["cost_usd"]) ?? 0;
|
|
16272
|
+
const hasRecord = boundedId(event.record_id ?? event.recordId) !== null;
|
|
16273
|
+
const evidence2 = readEventEvidence(event);
|
|
16274
|
+
const projection = projectCostEvidence(evidence2);
|
|
16275
|
+
const costSource = hasRecord ? projection.cost_source : legacyCostSource;
|
|
16276
|
+
const cost = hasRecord ? projection.cost_usd ?? 0 : legacyCost;
|
|
16277
|
+
if (!hasRecord) {
|
|
16278
|
+
summary.legacy_count++;
|
|
16279
|
+
summary.total_legacy_usd += legacyCost;
|
|
16280
|
+
summary.evidence_status = "inconclusive";
|
|
16281
|
+
}
|
|
16282
|
+
if (projection.evidence_status === "inconclusive")
|
|
16283
|
+
summary.evidence_status = "inconclusive";
|
|
16284
|
+
for (const item of evidence2) {
|
|
16285
|
+
if (item.currency !== "unknown" && !summary.currencies.includes(item.currency))
|
|
16286
|
+
summary.currencies.push(item.currency);
|
|
16287
|
+
}
|
|
16288
|
+
const legacyUsage = {
|
|
15892
16289
|
tokens_input: readNumber(event, ["tokens_input"]) ?? 0,
|
|
15893
16290
|
tokens_output: readNumber(event, ["tokens_output"]) ?? 0,
|
|
15894
16291
|
tokens_reasoning: readNumber(event, ["tokens_reasoning"]) ?? 0,
|
|
15895
16292
|
tokens_cache: readNumber(event, ["tokens_cache"]) ?? 0
|
|
15896
16293
|
};
|
|
16294
|
+
const evidenceUsage = evidence2.reduce((acc, item) => ({
|
|
16295
|
+
tokens_input: Math.max(acc.tokens_input, item.usage.tokens_input),
|
|
16296
|
+
tokens_output: Math.max(acc.tokens_output, item.usage.tokens_output),
|
|
16297
|
+
tokens_reasoning: Math.max(acc.tokens_reasoning, item.usage.tokens_reasoning),
|
|
16298
|
+
tokens_cache: Math.max(acc.tokens_cache, item.usage.tokens_cache)
|
|
16299
|
+
}), { ...ZERO_USAGE });
|
|
16300
|
+
const usage = hasRecord ? evidenceUsage : legacyUsage;
|
|
15897
16301
|
summary.delegations++;
|
|
15898
16302
|
summary.total_cost_usd += cost;
|
|
15899
16303
|
summary.total_input_tokens += usage.tokens_input;
|
|
@@ -15957,6 +16361,7 @@ function finalizeSummary(summary) {
|
|
|
15957
16361
|
summary.total_cost_usd = roundUsd(summary.total_cost_usd);
|
|
15958
16362
|
summary.total_reported_usd = roundUsd(summary.total_reported_usd);
|
|
15959
16363
|
summary.total_estimated_usd = roundUsd(summary.total_estimated_usd);
|
|
16364
|
+
summary.total_legacy_usd = roundUsd(summary.total_legacy_usd);
|
|
15960
16365
|
for (const source of Object.values(summary.by_source)) {
|
|
15961
16366
|
source.cost_usd = roundUsd(source.cost_usd);
|
|
15962
16367
|
}
|
|
@@ -16217,12 +16622,15 @@ async function handleBenchmarkCommand(directory, args) {
|
|
|
16217
16622
|
}
|
|
16218
16623
|
];
|
|
16219
16624
|
if (maxCostUsd !== null) {
|
|
16625
|
+
const costEvidenceComplete = costSummary !== undefined && costSummary.delegations > 0 && costSummary.evidence_status === "complete";
|
|
16220
16626
|
checks.push({
|
|
16221
16627
|
name: "Total cost",
|
|
16222
16628
|
value: costSummary?.total_cost_usd ?? 0,
|
|
16223
16629
|
threshold: maxCostUsd,
|
|
16224
16630
|
operator: "<=",
|
|
16225
|
-
passed: (costSummary?.total_cost_usd ?? 0) <= maxCostUsd
|
|
16631
|
+
passed: costEvidenceComplete && (costSummary?.total_cost_usd ?? 0) <= maxCostUsd,
|
|
16632
|
+
evidence_status: costEvidenceComplete ? "complete" : "inconclusive",
|
|
16633
|
+
reason: costEvidenceComplete ? (costSummary?.total_cost_usd ?? 0) <= maxCostUsd ? undefined : "thresholdExceeded" : "budgetInconclusive"
|
|
16226
16634
|
});
|
|
16227
16635
|
}
|
|
16228
16636
|
if (gateAudit && gateAuditSummary) {
|
|
@@ -16315,6 +16723,10 @@ async function handleBenchmarkCommand(directory, args) {
|
|
|
16315
16723
|
if (ciGate) {
|
|
16316
16724
|
lines.push("### CI Gate", ciGate.passed ? "\u2705 PASSED" : "\u274C FAILED");
|
|
16317
16725
|
for (const c of ciGate.checks) {
|
|
16726
|
+
if (c.name === "Total cost" && c.evidence_status === "inconclusive") {
|
|
16727
|
+
lines.push(`- Total cost: inconclusive (budget evidence unavailable) <= $${c.threshold.toFixed(6)} \u274C`);
|
|
16728
|
+
continue;
|
|
16729
|
+
}
|
|
16318
16730
|
let valueStr;
|
|
16319
16731
|
if (c.name === "Complexity Delta" || c.name === "Public API Delta") {
|
|
16320
16732
|
valueStr = `${c.value}`;
|
|
@@ -16403,7 +16815,9 @@ async function handleBenchmarkCommand(directory, args) {
|
|
|
16403
16815
|
value: c.value,
|
|
16404
16816
|
threshold: c.threshold,
|
|
16405
16817
|
operator: c.operator,
|
|
16406
|
-
passed: c.passed
|
|
16818
|
+
passed: c.passed,
|
|
16819
|
+
...c.evidence_status ? { evidence_status: c.evidence_status } : {},
|
|
16820
|
+
...c.reason ? { reason: c.reason } : {}
|
|
16407
16821
|
}))
|
|
16408
16822
|
};
|
|
16409
16823
|
lines.push("[BENCHMARK_JSON]", JSON.stringify(json, null, 2), "[/BENCHMARK_JSON]");
|
|
@@ -21040,7 +21454,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
|
|
|
21040
21454
|
};
|
|
21041
21455
|
}
|
|
21042
21456
|
async function sweepActiveNearDuplicates(directory, options = {}) {
|
|
21043
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
21457
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-2z00wqvb.js");
|
|
21044
21458
|
const { config } = loadPluginConfigWithMeta2(directory);
|
|
21045
21459
|
const sweepConfig = config.learning?.dedup_sweep;
|
|
21046
21460
|
if (sweepConfig?.enabled === false)
|
|
@@ -22170,7 +22584,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
22170
22584
|
}
|
|
22171
22585
|
if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
|
|
22172
22586
|
try {
|
|
22173
|
-
const skillModule = await import("./skill-generator-
|
|
22587
|
+
const skillModule = await import("./skill-generator-vwcrfrw3.js");
|
|
22174
22588
|
for (const cand of skillCandidates) {
|
|
22175
22589
|
if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
|
|
22176
22590
|
continue;
|
|
@@ -22642,7 +23056,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
22642
23056
|
} catch {}
|
|
22643
23057
|
}
|
|
22644
23058
|
if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
|
|
22645
|
-
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-
|
|
23059
|
+
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-585m4927.js");
|
|
22646
23060
|
for (const { id } of contradictedEntries) {
|
|
22647
23061
|
try {
|
|
22648
23062
|
await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
|
|
@@ -23461,7 +23875,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
23461
23875
|
warnings.push("Failed to collect knowledge summary.");
|
|
23462
23876
|
}
|
|
23463
23877
|
try {
|
|
23464
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
23878
|
+
const { getScanStatus } = await import("./scan-cursor-kv9scb2v.js");
|
|
23465
23879
|
const scanStatus = await getScanStatus(directory);
|
|
23466
23880
|
if (scanStatus.remaining_estimate > 0) {
|
|
23467
23881
|
warnings.push(`Fair scan: reviewed ${knowledgeSummary.length} entries this sweep (generation ${scanStatus.generation}); ${scanStatus.remaining_estimate} more eligible entries will be visited in future curation sweeps.`);
|
|
@@ -23633,9 +24047,9 @@ var _internals27 = {
|
|
|
23633
24047
|
verifyPostMortemKnowledgeActions,
|
|
23634
24048
|
repairPostMortemActions,
|
|
23635
24049
|
loadDefaultKnowledgeConfig: async (directory) => {
|
|
23636
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
24050
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-a7f88yc3.js");
|
|
23637
24051
|
try {
|
|
23638
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
24052
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-2z00wqvb.js");
|
|
23639
24053
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
23640
24054
|
return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
23641
24055
|
} catch {
|
|
@@ -23643,11 +24057,11 @@ var _internals27 = {
|
|
|
23643
24057
|
}
|
|
23644
24058
|
},
|
|
23645
24059
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
23646
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
24060
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-mpqpbr0r.js");
|
|
23647
24061
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
23648
24062
|
},
|
|
23649
24063
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
23650
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
24064
|
+
const { checkHivePromotions } = await import("./hive-promoter-zjtgbh4w.js");
|
|
23651
24065
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
23652
24066
|
},
|
|
23653
24067
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -23656,7 +24070,7 @@ var _internals27 = {
|
|
|
23656
24070
|
activateProposal,
|
|
23657
24071
|
listSkills: listSkills2,
|
|
23658
24072
|
sanitizeSlug
|
|
23659
|
-
} = await import("./skill-generator-
|
|
24073
|
+
} = await import("./skill-generator-vwcrfrw3.js");
|
|
23660
24074
|
const result = {
|
|
23661
24075
|
approved: [],
|
|
23662
24076
|
rejected: [],
|
|
@@ -24986,9 +25400,9 @@ function hashContent(content) {
|
|
|
24986
25400
|
return createHash13("sha1").update(content).digest("hex");
|
|
24987
25401
|
}
|
|
24988
25402
|
async function loadConfigForPolicyCurator(directory) {
|
|
24989
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
25403
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-a7f88yc3.js");
|
|
24990
25404
|
try {
|
|
24991
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
25405
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-2z00wqvb.js");
|
|
24992
25406
|
const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
|
|
24993
25407
|
return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
|
|
24994
25408
|
} catch {
|
|
@@ -29042,7 +29456,7 @@ import {
|
|
|
29042
29456
|
existsSync as existsSync19,
|
|
29043
29457
|
mkdirSync as mkdirSync11,
|
|
29044
29458
|
readFileSync as readFileSync16,
|
|
29045
|
-
statSync as
|
|
29459
|
+
statSync as statSync11,
|
|
29046
29460
|
writeFileSync as writeFileSync9
|
|
29047
29461
|
} from "fs";
|
|
29048
29462
|
import { createRequire as createRequire3 } from "module";
|
|
@@ -30726,13 +31140,13 @@ class SQLiteMemoryProvider {
|
|
|
30726
31140
|
}
|
|
30727
31141
|
try {
|
|
30728
31142
|
const wal = `${dbPath}-wal`;
|
|
30729
|
-
const st =
|
|
31143
|
+
const st = statSync11(wal);
|
|
30730
31144
|
if (st.size > 0)
|
|
30731
31145
|
walPath = wal;
|
|
30732
31146
|
} catch {}
|
|
30733
31147
|
try {
|
|
30734
31148
|
const shm = `${dbPath}-shm`;
|
|
30735
|
-
const st =
|
|
31149
|
+
const st = statSync11(shm);
|
|
30736
31150
|
if (st.size > 0)
|
|
30737
31151
|
shmPath = shm;
|
|
30738
31152
|
} catch {}
|
|
@@ -32203,7 +32617,7 @@ init_logger();
|
|
|
32203
32617
|
import * as path39 from "path";
|
|
32204
32618
|
|
|
32205
32619
|
// src/memory/memory-link.ts
|
|
32206
|
-
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync17, rmSync as rmSync2, statSync as
|
|
32620
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync17, rmSync as rmSync2, statSync as statSync12 } from "fs";
|
|
32207
32621
|
import * as path38 from "path";
|
|
32208
32622
|
init_logger();
|
|
32209
32623
|
var MEMORY_LINK_POINTER_FILENAME = "memory-link.json";
|
|
@@ -32263,7 +32677,7 @@ var _resolutionCache = new Map;
|
|
|
32263
32677
|
function pointerStatFingerprint(directory) {
|
|
32264
32678
|
const pointerPath = resolveMemoryLinkPointerPath(directory);
|
|
32265
32679
|
try {
|
|
32266
|
-
const st =
|
|
32680
|
+
const st = statSync12(pointerPath);
|
|
32267
32681
|
return `${st.mtimeMs}:${st.ctimeMs}:${st.size}`;
|
|
32268
32682
|
} catch {
|
|
32269
32683
|
return null;
|
|
@@ -37241,7 +37655,7 @@ async function runFinalizeStage(ctx) {
|
|
|
37241
37655
|
}
|
|
37242
37656
|
}
|
|
37243
37657
|
try {
|
|
37244
|
-
const { CuratorConfigSchema: CCS } = await import("./schema-
|
|
37658
|
+
const { CuratorConfigSchema: CCS } = await import("./schema-a7f88yc3.js");
|
|
37245
37659
|
const { config: pmLoadedConfig } = _internals41.loadPluginConfigWithMeta(ctx.directory);
|
|
37246
37660
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
37247
37661
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
@@ -38127,7 +38541,7 @@ var _internals41 = {
|
|
|
38127
38541
|
closePlanTerminalState: reconcileCloseTerminalStateForPlan,
|
|
38128
38542
|
endAgentSession,
|
|
38129
38543
|
flushAndDrainTelemetry: async () => {
|
|
38130
|
-
const { flushAndDrainTelemetry } = await import("./telemetry-
|
|
38544
|
+
const { flushAndDrainTelemetry } = await import("./telemetry-3rh94wv3.js");
|
|
38131
38545
|
return flushAndDrainTelemetry();
|
|
38132
38546
|
},
|
|
38133
38547
|
finalizeContextTelemetry: (directory) => {
|
|
@@ -38647,6 +39061,7 @@ function renderCostSummary(summary) {
|
|
|
38647
39061
|
`Delegations: ${summary.delegations}`,
|
|
38648
39062
|
`Tokens: input ${summary.total_input_tokens.toLocaleString()}, output ${summary.total_output_tokens.toLocaleString()}, reasoning ${summary.total_reasoning_tokens.toLocaleString()}, cache ${summary.total_cache_tokens.toLocaleString()}`,
|
|
38649
39063
|
`Cost source: reported ${formatUsd(summary.total_reported_usd)}, estimated ${formatUsd(summary.total_estimated_usd)}, unavailable ${summary.unavailable_delegations}`,
|
|
39064
|
+
`Evidence: ${summary.evidence_status}; joins missed ${summary.join_miss_count}; telemetry errors ${summary.telemetry_error_count}; corrections accepted ${summary.accepted_corrections}, rejected ${summary.rejected_corrections}, duplicate ${summary.duplicate_corrections}`,
|
|
38650
39065
|
"",
|
|
38651
39066
|
"### By Agent"
|
|
38652
39067
|
];
|
|
@@ -39464,9 +39879,9 @@ var _internals45 = {
|
|
|
39464
39879
|
loadPluginConfigWithMeta,
|
|
39465
39880
|
loadCuratorDeps: async () => {
|
|
39466
39881
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
39467
|
-
import("./schema-
|
|
39468
|
-
import("./curator-
|
|
39469
|
-
import("./curator-llm-factory-
|
|
39882
|
+
import("./schema-a7f88yc3.js"),
|
|
39883
|
+
import("./curator-mpqpbr0r.js"),
|
|
39884
|
+
import("./curator-llm-factory-m3yw6sn5.js")
|
|
39470
39885
|
]);
|
|
39471
39886
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
39472
39887
|
}
|
|
@@ -39966,7 +40381,7 @@ ${USAGE9}`;
|
|
|
39966
40381
|
// src/services/diagnose-service.ts
|
|
39967
40382
|
init_package();
|
|
39968
40383
|
import * as child_process5 from "child_process";
|
|
39969
|
-
import { existsSync as existsSync32, readdirSync as readdirSync6, readFileSync as readFileSync23, statSync as
|
|
40384
|
+
import { existsSync as existsSync32, readdirSync as readdirSync6, readFileSync as readFileSync23, statSync as statSync14 } from "fs";
|
|
39970
40385
|
import * as path54 from "path";
|
|
39971
40386
|
import { fileURLToPath } from "url";
|
|
39972
40387
|
|
|
@@ -40475,7 +40890,7 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
40475
40890
|
let scanCompleted = false;
|
|
40476
40891
|
let scanRemaining = 0;
|
|
40477
40892
|
try {
|
|
40478
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
40893
|
+
const { getScanStatus } = await import("./scan-cursor-kv9scb2v.js");
|
|
40479
40894
|
const status = await getScanStatus(directory);
|
|
40480
40895
|
scanGeneration = status.generation;
|
|
40481
40896
|
scanCompleted = status.completed;
|
|
@@ -40483,19 +40898,19 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
40483
40898
|
} catch {}
|
|
40484
40899
|
let configMatch = null;
|
|
40485
40900
|
try {
|
|
40486
|
-
const { isLinked: isLinked2 } = await import("./knowledge-link-
|
|
40901
|
+
const { isLinked: isLinked2 } = await import("./knowledge-link-a9fafeb3.js");
|
|
40487
40902
|
if (isLinked2(directory)) {
|
|
40488
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
40903
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-a7f88yc3.js");
|
|
40489
40904
|
let config;
|
|
40490
40905
|
try {
|
|
40491
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
40906
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-2z00wqvb.js");
|
|
40492
40907
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
40493
40908
|
config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
40494
40909
|
} catch {
|
|
40495
40910
|
config = KnowledgeConfigSchema2.parse({});
|
|
40496
40911
|
}
|
|
40497
40912
|
const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
|
|
40498
|
-
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-
|
|
40913
|
+
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-2gq8307w.js");
|
|
40499
40914
|
const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
|
|
40500
40915
|
const cohortFp = await readCohortConfigFingerprint(directory);
|
|
40501
40916
|
configMatch = cohortFp === null ? null : currentFp === cohortFp;
|
|
@@ -40902,7 +41317,7 @@ async function checkConfigBackups(directory) {
|
|
|
40902
41317
|
}
|
|
40903
41318
|
async function checkGitRepository(directory) {
|
|
40904
41319
|
try {
|
|
40905
|
-
if (!existsSync32(directory) || !
|
|
41320
|
+
if (!existsSync32(directory) || !statSync14(directory).isDirectory()) {
|
|
40906
41321
|
return {
|
|
40907
41322
|
name: "Git Repository",
|
|
40908
41323
|
status: "\u274C",
|
|
@@ -41808,7 +42223,7 @@ async function handleDoctorCommand(directory, args) {
|
|
|
41808
42223
|
const result = runConfigDoctor(config, directory);
|
|
41809
42224
|
let output;
|
|
41810
42225
|
if (enableAutoFix && result.hasAutoFixableIssues) {
|
|
41811
|
-
const { runConfigDoctorWithFixes } = await import("./config-doctor-
|
|
42226
|
+
const { runConfigDoctorWithFixes } = await import("./config-doctor-8zawz3qh.js");
|
|
41812
42227
|
const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
|
|
41813
42228
|
applyLossy: true
|
|
41814
42229
|
});
|
|
@@ -42748,7 +43163,7 @@ async function handleEvidenceCommand(directory, args) {
|
|
|
42748
43163
|
return formatTaskEvidenceMarkdown(evidenceData);
|
|
42749
43164
|
}
|
|
42750
43165
|
async function handleEvidenceSummaryCommand(directory) {
|
|
42751
|
-
const { buildEvidenceSummary } = await import("./evidence-summary-service-
|
|
43166
|
+
const { buildEvidenceSummary } = await import("./evidence-summary-service-qaq1eba9.js");
|
|
42752
43167
|
const artifact = await buildEvidenceSummary(directory);
|
|
42753
43168
|
if (!artifact) {
|
|
42754
43169
|
return "No plan found. Run `/swarm plan` to check plan status.";
|
|
@@ -50488,7 +50903,7 @@ import {
|
|
|
50488
50903
|
readFileSync as readFileSync32,
|
|
50489
50904
|
renameSync as renameSync12,
|
|
50490
50905
|
rmSync as rmSync7,
|
|
50491
|
-
statSync as
|
|
50906
|
+
statSync as statSync18,
|
|
50492
50907
|
unlinkSync as unlinkSync12,
|
|
50493
50908
|
writeSync
|
|
50494
50909
|
} from "fs";
|
|
@@ -56094,7 +56509,7 @@ var MIN_MAX_CYCLES = 1;
|
|
|
56094
56509
|
var MAX_MAX_CYCLES = 5;
|
|
56095
56510
|
async function readLatestLoopState(directory) {
|
|
56096
56511
|
try {
|
|
56097
|
-
const { readdirSync: readdirSync9, statSync:
|
|
56512
|
+
const { readdirSync: readdirSync9, statSync: statSync20, readFileSync: readFileSync38 } = await import("fs");
|
|
56098
56513
|
const loopDir = `${directory}/.swarm/loop`;
|
|
56099
56514
|
let latestMtime = 0;
|
|
56100
56515
|
let latestPath = null;
|
|
@@ -56105,7 +56520,7 @@ async function readLatestLoopState(directory) {
|
|
|
56105
56520
|
continue;
|
|
56106
56521
|
const statePath = `${loopDir}/${entry.name}/state.json`;
|
|
56107
56522
|
try {
|
|
56108
|
-
const mtime =
|
|
56523
|
+
const mtime = statSync20(statePath).mtimeMs;
|
|
56109
56524
|
if (mtime > latestMtime) {
|
|
56110
56525
|
latestMtime = mtime;
|
|
56111
56526
|
latestPath = statePath;
|
|
@@ -56743,7 +57158,7 @@ import {
|
|
|
56743
57158
|
openSync as openSync13,
|
|
56744
57159
|
readSync as readSync7,
|
|
56745
57160
|
realpathSync as realpathSync8,
|
|
56746
|
-
statSync as
|
|
57161
|
+
statSync as statSync21
|
|
56747
57162
|
} from "fs";
|
|
56748
57163
|
var import_proper_lockfile9 = __toESM(require_proper_lockfile(), 1);
|
|
56749
57164
|
|
|
@@ -74182,12 +74597,16 @@ function autoReviewEvidenceRelativePath(trigger, scopeHash, phase) {
|
|
|
74182
74597
|
}
|
|
74183
74598
|
return path99.join("evidence", "auto-review", `${trigger}-${scopeHash.slice(0, 64)}.json`);
|
|
74184
74599
|
}
|
|
74600
|
+
var _internals89 = {
|
|
74601
|
+
bunWrite,
|
|
74602
|
+
renameSync: fs46.renameSync
|
|
74603
|
+
};
|
|
74185
74604
|
async function persistAutoReviewEvidence(directory, evidence2, options = {}) {
|
|
74186
74605
|
const target = validateSwarmPath(directory, autoReviewEvidenceRelativePath(evidence2.trigger, evidence2.scope.hash, evidence2.phase));
|
|
74187
74606
|
fs46.mkdirSync(path99.dirname(target), { recursive: true });
|
|
74188
74607
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
74189
74608
|
try {
|
|
74190
|
-
await bunWrite(tempPath, `${JSON.stringify(evidence2, null, 2)}
|
|
74609
|
+
await _internals89.bunWrite(tempPath, `${JSON.stringify(evidence2, null, 2)}
|
|
74191
74610
|
`);
|
|
74192
74611
|
const safeTemp = validateSwarmPath(directory, path99.relative(path99.join(directory, ".swarm"), tempPath));
|
|
74193
74612
|
const tempStat = fs46.lstatSync(safeTemp);
|
|
@@ -74203,7 +74622,7 @@ async function persistAutoReviewEvidence(directory, evidence2, options = {}) {
|
|
|
74203
74622
|
if (!revalidatedStat.isFile() || revalidatedStat.isSymbolicLink()) {
|
|
74204
74623
|
throw new Error("auto-review evidence temp path changed before commit");
|
|
74205
74624
|
}
|
|
74206
|
-
|
|
74625
|
+
_internals89.renameSync(revalidatedTemp, safeTarget);
|
|
74207
74626
|
invalidateCachedArtifact(safeTarget);
|
|
74208
74627
|
return safeTarget;
|
|
74209
74628
|
} finally {
|
|
@@ -74450,7 +74869,7 @@ function scopeFreshnessMismatches(reviewed, current) {
|
|
|
74450
74869
|
}
|
|
74451
74870
|
function createScopeVerifier(input, reviewed, maxBytes) {
|
|
74452
74871
|
return async () => {
|
|
74453
|
-
const current = await
|
|
74872
|
+
const current = await _internals90.collectReviewDiff({
|
|
74454
74873
|
directory: input.directory,
|
|
74455
74874
|
selector: input.selector,
|
|
74456
74875
|
maxBytes
|
|
@@ -74459,7 +74878,7 @@ function createScopeVerifier(input, reviewed, maxBytes) {
|
|
|
74459
74878
|
};
|
|
74460
74879
|
}
|
|
74461
74880
|
async function stalePersistenceResult(input, maxBytes, message, modelCalls) {
|
|
74462
|
-
const current = await
|
|
74881
|
+
const current = await _internals90.collectReviewDiff({
|
|
74463
74882
|
directory: input.directory,
|
|
74464
74883
|
selector: input.selector,
|
|
74465
74884
|
maxBytes
|
|
@@ -74746,10 +75165,20 @@ async function dispatchReviewerWithFallback(input, prompt, timeoutMs, promptByte
|
|
|
74746
75165
|
return { result: attempts[0], attempts };
|
|
74747
75166
|
}
|
|
74748
75167
|
function addCost(evidence2, dispatches) {
|
|
75168
|
+
const MAX_REVIEW_COST_EVIDENCE = 32;
|
|
74749
75169
|
evidence2.cost.model_calls = dispatches.length;
|
|
74750
75170
|
evidence2.cost.prompt_bytes = dispatches.reduce((sum, dispatch) => sum + dispatch.promptBytes, 0);
|
|
74751
75171
|
for (const dispatch of dispatches) {
|
|
74752
75172
|
const fields = dispatch.costFields;
|
|
75173
|
+
for (const item of fields?.cost_evidence ?? []) {
|
|
75174
|
+
if (evidence2.cost.cost_evidence.length >= MAX_REVIEW_COST_EVIDENCE)
|
|
75175
|
+
break;
|
|
75176
|
+
evidence2.cost.cost_evidence.push(item);
|
|
75177
|
+
}
|
|
75178
|
+
if (fields?.evidence_status !== "complete") {
|
|
75179
|
+
evidence2.cost.evidence_status = "inconclusive";
|
|
75180
|
+
evidence2.cost.evidence_reason = fields?.evidence_reason ?? "missing_cost";
|
|
75181
|
+
}
|
|
74753
75182
|
evidence2.cost.tokens_input += fields?.tokens_input ?? 0;
|
|
74754
75183
|
evidence2.cost.tokens_output += fields?.tokens_output ?? 0;
|
|
74755
75184
|
evidence2.cost.tokens_reasoning += fields?.tokens_reasoning ?? 0;
|
|
@@ -74798,7 +75227,9 @@ function baseEvidence(input, diff, status) {
|
|
|
74798
75227
|
tokens_reasoning: 0,
|
|
74799
75228
|
tokens_cache: 0,
|
|
74800
75229
|
cost_usd: null,
|
|
74801
|
-
cost_source: "unavailable"
|
|
75230
|
+
cost_source: "unavailable",
|
|
75231
|
+
cost_evidence: [],
|
|
75232
|
+
evidence_status: "complete"
|
|
74802
75233
|
}
|
|
74803
75234
|
};
|
|
74804
75235
|
}
|
|
@@ -74847,7 +75278,7 @@ async function persistErrorResult(input, diff, result, error2, dispatches, promp
|
|
|
74847
75278
|
evidence2.review.error = error2;
|
|
74848
75279
|
addCost(evidence2, dispatches);
|
|
74849
75280
|
try {
|
|
74850
|
-
result.evidencePath = await
|
|
75281
|
+
result.evidencePath = await _internals90.persistEvidence(input.directory, evidence2);
|
|
74851
75282
|
} catch {
|
|
74852
75283
|
if (input.config.final_review.mode === "gate") {
|
|
74853
75284
|
result.blocked = true;
|
|
@@ -74864,7 +75295,7 @@ async function runReviewEngine(input) {
|
|
|
74864
75295
|
const gateMode = input.config.final_review.mode === "gate";
|
|
74865
75296
|
const maxBytes = input.trigger === "task_completion" ? input.config.max_diff_kb * 1024 : input.config.final_review.max_diff_bytes;
|
|
74866
75297
|
const timeoutMs = input.trigger === "task_completion" ? input.config.timeout_ms : input.config.final_review.timeout_ms;
|
|
74867
|
-
const diff = await
|
|
75298
|
+
const diff = await _internals90.collectReviewDiff({
|
|
74868
75299
|
directory: input.directory,
|
|
74869
75300
|
selector: input.selector,
|
|
74870
75301
|
maxBytes
|
|
@@ -74880,7 +75311,7 @@ async function runReviewEngine(input) {
|
|
|
74880
75311
|
evidence3.policy.digest = evidence3.scope.manifest.review_policy_digest;
|
|
74881
75312
|
let evidencePath2;
|
|
74882
75313
|
try {
|
|
74883
|
-
evidencePath2 = await
|
|
75314
|
+
evidencePath2 = await _internals90.persistEvidence(input.directory, evidence3, { verifyCurrent: createScopeVerifier(input, diff, maxBytes) });
|
|
74884
75315
|
} catch (error2) {
|
|
74885
75316
|
if (error2 instanceof ReviewScopeStaleError) {
|
|
74886
75317
|
return stalePersistenceResult(input, maxBytes, "Review scope changed before clean evidence could be committed.", 0);
|
|
@@ -74904,7 +75335,7 @@ async function runReviewEngine(input) {
|
|
|
74904
75335
|
});
|
|
74905
75336
|
const reviewManifest = await materializeAutoReviewManifest(input.directory, diff.manifest, input.config);
|
|
74906
75337
|
if (input.phase !== undefined && (input.trigger === "phase_completion" || input.trigger === "plan_completion")) {
|
|
74907
|
-
const existing =
|
|
75338
|
+
const existing = _internals90.readPhaseEvidence(input.directory, input.phase);
|
|
74908
75339
|
const integrity = existing ? validateAutoReviewEvidenceIntegrity(input.directory, existing, {
|
|
74909
75340
|
scopeHash: diff.scopeHash,
|
|
74910
75341
|
phase: input.phase,
|
|
@@ -75032,7 +75463,7 @@ async function runReviewEngine(input) {
|
|
|
75032
75463
|
validation: byId.get(finding.finding_id)
|
|
75033
75464
|
}));
|
|
75034
75465
|
}
|
|
75035
|
-
const currentScope = await
|
|
75466
|
+
const currentScope = await _internals90.collectReviewDiff({
|
|
75036
75467
|
directory: input.directory,
|
|
75037
75468
|
selector: input.selector,
|
|
75038
75469
|
maxBytes
|
|
@@ -75113,7 +75544,7 @@ async function runReviewEngine(input) {
|
|
|
75113
75544
|
findingValidations: findings.map((finding) => finding.validation).filter((item) => Boolean(item))
|
|
75114
75545
|
});
|
|
75115
75546
|
receiptId = receipt.id;
|
|
75116
|
-
receiptPath = await
|
|
75547
|
+
receiptPath = await _internals90.persistReceipt(input.directory, receipt, {
|
|
75117
75548
|
verifyCurrent: createScopeVerifier(input, diff, maxBytes)
|
|
75118
75549
|
});
|
|
75119
75550
|
evidence2.receipt_path = receiptPath;
|
|
@@ -75143,7 +75574,7 @@ async function runReviewEngine(input) {
|
|
|
75143
75574
|
}
|
|
75144
75575
|
let evidencePath;
|
|
75145
75576
|
try {
|
|
75146
|
-
evidencePath = await
|
|
75577
|
+
evidencePath = await _internals90.persistEvidence(input.directory, evidence2, {
|
|
75147
75578
|
verifyCurrent: createScopeVerifier(input, diff, maxBytes)
|
|
75148
75579
|
});
|
|
75149
75580
|
} catch (error2) {
|
|
@@ -75181,7 +75612,7 @@ async function runReviewEngine(input) {
|
|
|
75181
75612
|
input.injectAdvisory?.(input.sessionID, advisoryMessage(input, result));
|
|
75182
75613
|
return result;
|
|
75183
75614
|
}
|
|
75184
|
-
var
|
|
75615
|
+
var _internals90 = {
|
|
75185
75616
|
collectReviewDiff,
|
|
75186
75617
|
persistEvidence: persistAutoReviewEvidence,
|
|
75187
75618
|
persistReceipt: persistReviewReceipt,
|
|
@@ -75452,7 +75883,7 @@ async function handleReviewCommand(ctx) {
|
|
|
75452
75883
|
} catch (error2) {
|
|
75453
75884
|
return `Review configuration error: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
75454
75885
|
}
|
|
75455
|
-
const result = await
|
|
75886
|
+
const result = await _internals91.runReviewEngine({
|
|
75456
75887
|
directory: ctx.directory,
|
|
75457
75888
|
sessionID: ctx.sessionID,
|
|
75458
75889
|
trigger: "manual",
|
|
@@ -75466,10 +75897,10 @@ async function handleReviewCommand(ctx) {
|
|
|
75466
75897
|
validatorModel,
|
|
75467
75898
|
validatorFallbackModels
|
|
75468
75899
|
});
|
|
75469
|
-
const evidence2 =
|
|
75900
|
+
const evidence2 = _internals91.readEvidence(result.evidencePath, ctx.directory);
|
|
75470
75901
|
return parsed.json ? renderJson(result, evidence2, parsed.selector) : renderHuman(result, evidence2, parsed.selector);
|
|
75471
75902
|
}
|
|
75472
|
-
var
|
|
75903
|
+
var _internals91 = {
|
|
75473
75904
|
runReviewEngine,
|
|
75474
75905
|
readEvidence
|
|
75475
75906
|
};
|
|
@@ -75711,7 +76142,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
75711
76142
|
// src/commands/sdd.ts
|
|
75712
76143
|
import * as fs50 from "fs";
|
|
75713
76144
|
import * as path103 from "path";
|
|
75714
|
-
var
|
|
76145
|
+
var _internals92 = {
|
|
75715
76146
|
writeProjectedSpecSync
|
|
75716
76147
|
};
|
|
75717
76148
|
var SWARM_SPEC_REL = path103.join(".swarm", "spec.md");
|
|
@@ -76111,7 +76542,7 @@ ${USAGE14}`;
|
|
|
76111
76542
|
|
|
76112
76543
|
${USAGE14}`;
|
|
76113
76544
|
}
|
|
76114
|
-
const result2 =
|
|
76545
|
+
const result2 = _internals92.writeProjectedSpecSync(directory, {
|
|
76115
76546
|
source: "speckit",
|
|
76116
76547
|
feature: resolution.feature,
|
|
76117
76548
|
dryRun: parsed.dryRun,
|
|
@@ -76169,7 +76600,7 @@ ${formatList(result2.projection.warnings)}` : ""
|
|
|
76169
76600
|
].join(`
|
|
76170
76601
|
`);
|
|
76171
76602
|
}
|
|
76172
|
-
const result =
|
|
76603
|
+
const result = _internals92.writeProjectedSpecSync(directory, {
|
|
76173
76604
|
changeId: parsed.changeId,
|
|
76174
76605
|
dryRun: parsed.dryRun,
|
|
76175
76606
|
overwrite: parsed.overwrite
|
|
@@ -76314,7 +76745,7 @@ import {
|
|
|
76314
76745
|
openSync as openSync20,
|
|
76315
76746
|
readFileSync as readFileSync46,
|
|
76316
76747
|
renameSync as renameSync16,
|
|
76317
|
-
statSync as
|
|
76748
|
+
statSync as statSync25,
|
|
76318
76749
|
unlinkSync as unlinkSync22,
|
|
76319
76750
|
writeFileSync as writeFileSync18,
|
|
76320
76751
|
writeFileSync as writeFileSyncAsync
|
|
@@ -76396,7 +76827,7 @@ function writeFileFsyncedThenRename(tempPath, targetPath, data) {
|
|
|
76396
76827
|
throw err;
|
|
76397
76828
|
}
|
|
76398
76829
|
}
|
|
76399
|
-
var
|
|
76830
|
+
var _internals93 = {
|
|
76400
76831
|
withEvidenceLock,
|
|
76401
76832
|
writeFileFsyncedThenRename,
|
|
76402
76833
|
writeFileSync: writeFileSyncAsync,
|
|
@@ -76404,7 +76835,7 @@ var _internals92 = {
|
|
|
76404
76835
|
renameSync: renameSync16,
|
|
76405
76836
|
unlinkSync: unlinkSync22,
|
|
76406
76837
|
existsSync: existsSync57,
|
|
76407
|
-
statSync:
|
|
76838
|
+
statSync: statSync25
|
|
76408
76839
|
};
|
|
76409
76840
|
async function appendEvent2(directory, eventInput) {
|
|
76410
76841
|
assertProjectRoot(directory);
|
|
@@ -76415,7 +76846,7 @@ async function appendEvent2(directory, eventInput) {
|
|
|
76415
76846
|
throw new Error(`invalid candidate id: ${eventInput.candidateId}`);
|
|
76416
76847
|
}
|
|
76417
76848
|
const filePath = ledgerPath2(directory, eventInput.skillSlug, eventInput.candidateId);
|
|
76418
|
-
return
|
|
76849
|
+
return _internals93.withEvidenceLock(directory, path104.join(".swarm", "evolution", "skills", eventInput.skillSlug, eventInput.candidateId, "lifecycle.jsonl"), "skill-opt-ledger", "append-skill-opt-event", async () => {
|
|
76419
76850
|
ensureCandidateDir(directory, eventInput.skillSlug, eventInput.candidateId);
|
|
76420
76851
|
const existing = existsSync57(filePath) ? readFileSync46(filePath, "utf8") : "";
|
|
76421
76852
|
const events = parseEventsFromText(existing);
|
|
@@ -76447,8 +76878,8 @@ async function appendEvent2(directory, eventInput) {
|
|
|
76447
76878
|
const validContent = events.map((e) => JSON.stringify(e)).join(`
|
|
76448
76879
|
`) + (events.length > 0 ? `
|
|
76449
76880
|
` : "");
|
|
76450
|
-
|
|
76451
|
-
const verify = parseEventsFromText(
|
|
76881
|
+
_internals93.writeFileFsyncedThenRename(tempPath, filePath, validContent + line);
|
|
76882
|
+
const verify = parseEventsFromText(_internals93.readFileSync(filePath, "utf8"));
|
|
76452
76883
|
const last = verify.length > 0 ? verify[verify.length - 1] : null;
|
|
76453
76884
|
if (!last || last.seq !== event.seq || last.hashAfter !== event.hashAfter) {
|
|
76454
76885
|
throw new Error(`skill-opt ledger append verification failed for candidate ${event.candidateId} seq ${event.seq}`);
|
|
@@ -76552,7 +76983,7 @@ function writeStateProjection(directory, skillSlug, candidateId2, replay) {
|
|
|
76552
76983
|
updatedAt: new Date().toISOString()
|
|
76553
76984
|
};
|
|
76554
76985
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
76555
|
-
|
|
76986
|
+
_internals93.writeFileFsyncedThenRename(tempPath, target, `${JSON.stringify(projection, null, 2)}
|
|
76556
76987
|
`);
|
|
76557
76988
|
}
|
|
76558
76989
|
function writeArtifact(directory, skillSlug, candidateId2, fileName, content) {
|
|
@@ -76560,7 +76991,7 @@ function writeArtifact(directory, skillSlug, candidateId2, fileName, content) {
|
|
|
76560
76991
|
const dir = ensureCandidateDir(directory, skillSlug, candidateId2);
|
|
76561
76992
|
const target = path104.join(dir, fileName);
|
|
76562
76993
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
76563
|
-
|
|
76994
|
+
_internals93.writeFileFsyncedThenRename(tempPath, target, content);
|
|
76564
76995
|
return target;
|
|
76565
76996
|
}
|
|
76566
76997
|
function readArtifact(directory, skillSlug, candidateId2, fileName) {
|
|
@@ -76653,16 +77084,16 @@ function currentCandidateState(directory, skillSlug, candidateId2) {
|
|
|
76653
77084
|
function writeSkillFileAtomic(targetPath, content) {
|
|
76654
77085
|
const tempPath = `${targetPath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
76655
77086
|
try {
|
|
76656
|
-
|
|
76657
|
-
|
|
77087
|
+
_internals94.writeFileSync(tempPath, content, "utf8");
|
|
77088
|
+
_internals94.renameSync(tempPath, targetPath);
|
|
76658
77089
|
} finally {
|
|
76659
77090
|
try {
|
|
76660
77091
|
if (existsSync58(tempPath))
|
|
76661
|
-
|
|
77092
|
+
_internals94.unlinkSync(tempPath);
|
|
76662
77093
|
} catch {}
|
|
76663
77094
|
}
|
|
76664
77095
|
}
|
|
76665
|
-
var
|
|
77096
|
+
var _internals94 = {
|
|
76666
77097
|
writeFileSync: writeFileSync19,
|
|
76667
77098
|
renameSync: renameSync17,
|
|
76668
77099
|
unlinkSync: unlinkSync23
|
|
@@ -77244,7 +77675,7 @@ function buildGeneratorInputs(args) {
|
|
|
77244
77675
|
}
|
|
77245
77676
|
};
|
|
77246
77677
|
}
|
|
77247
|
-
var
|
|
77678
|
+
var _internals95 = {
|
|
77248
77679
|
draftDeterministic: defaultDeterministicDraft
|
|
77249
77680
|
};
|
|
77250
77681
|
function defaultDeterministicDraft(inputs) {
|
|
@@ -77314,7 +77745,7 @@ function countChangedLines(a, b) {
|
|
|
77314
77745
|
return changed;
|
|
77315
77746
|
}
|
|
77316
77747
|
function draftCandidate(inputs) {
|
|
77317
|
-
const candidate2 =
|
|
77748
|
+
const candidate2 = _internals95.draftDeterministic(inputs);
|
|
77318
77749
|
enforceTrustRegion(candidate2, inputs.budget);
|
|
77319
77750
|
return candidate2;
|
|
77320
77751
|
}
|
|
@@ -77357,7 +77788,7 @@ import * as path108 from "path";
|
|
|
77357
77788
|
// src/hooks/spawn-helper.ts
|
|
77358
77789
|
import * as child_process7 from "child_process";
|
|
77359
77790
|
var WIN32_CMD_BINARIES = new Set(["npm", "npx", "pnpm", "yarn"]);
|
|
77360
|
-
var
|
|
77791
|
+
var _internals96 = {
|
|
77361
77792
|
spawn: child_process7.spawn
|
|
77362
77793
|
};
|
|
77363
77794
|
function spawnAsync(command, cwd, timeoutMs) {
|
|
@@ -77365,7 +77796,7 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
77365
77796
|
try {
|
|
77366
77797
|
const [rawCmd, ...args] = command;
|
|
77367
77798
|
const cmd = process.platform === "win32" && WIN32_CMD_BINARIES.has(rawCmd) && !rawCmd.includes(".") ? `${rawCmd}.cmd` : rawCmd;
|
|
77368
|
-
const proc =
|
|
77799
|
+
const proc = _internals96.spawn(cmd, args, {
|
|
77369
77800
|
cwd,
|
|
77370
77801
|
stdio: ["ignore", "pipe", "pipe"]
|
|
77371
77802
|
});
|
|
@@ -77431,7 +77862,7 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
77431
77862
|
}
|
|
77432
77863
|
|
|
77433
77864
|
// src/services/skill-optimizer/smoke.ts
|
|
77434
|
-
var
|
|
77865
|
+
var _internals97 = {
|
|
77435
77866
|
validateSkillPath,
|
|
77436
77867
|
isSymbolicLink: (p) => {
|
|
77437
77868
|
try {
|
|
@@ -77452,7 +77883,7 @@ var _internals96 = {
|
|
|
77452
77883
|
async function validateSkillSmoke(input) {
|
|
77453
77884
|
const notes = [];
|
|
77454
77885
|
const repoRel = path108.join(".opencode", "skills", "generated", input.skillSlug, "SKILL.md");
|
|
77455
|
-
if (!
|
|
77886
|
+
if (!_internals97.validateSkillPath(repoRel)) {
|
|
77456
77887
|
return {
|
|
77457
77888
|
ok: false,
|
|
77458
77889
|
verdict: "VIOLATED",
|
|
@@ -77461,16 +77892,16 @@ async function validateSkillSmoke(input) {
|
|
|
77461
77892
|
}
|
|
77462
77893
|
const skillRoot = path108.join(input.directory, ".opencode", "skills", "generated", input.skillSlug);
|
|
77463
77894
|
if (existsSync59(skillRoot)) {
|
|
77464
|
-
if (
|
|
77895
|
+
if (_internals97.isSymbolicLink(skillRoot)) {
|
|
77465
77896
|
return {
|
|
77466
77897
|
ok: false,
|
|
77467
77898
|
verdict: "VIOLATED",
|
|
77468
77899
|
notes: ["skill root is a symlink (reparse denied)"]
|
|
77469
77900
|
};
|
|
77470
77901
|
}
|
|
77471
|
-
const realRoot =
|
|
77472
|
-
const realProjectDir =
|
|
77473
|
-
if (
|
|
77902
|
+
const realRoot = _internals97.realpath(skillRoot);
|
|
77903
|
+
const realProjectDir = _internals97.realpath(input.directory);
|
|
77904
|
+
if (_internals97.escapedRoot(realProjectDir, realRoot)) {
|
|
77474
77905
|
return {
|
|
77475
77906
|
ok: false,
|
|
77476
77907
|
verdict: "VIOLATED",
|
|
@@ -77488,7 +77919,7 @@ async function validateSkillSmoke(input) {
|
|
|
77488
77919
|
notes: [`frontmatter: ${fmError}`]
|
|
77489
77920
|
};
|
|
77490
77921
|
}
|
|
77491
|
-
const rejected = await
|
|
77922
|
+
const rejected = await _internals97.isRejectedSkillContent(input.directory, input.skillSlug, input.candidateContent);
|
|
77492
77923
|
if (rejected) {
|
|
77493
77924
|
return {
|
|
77494
77925
|
ok: false,
|
|
@@ -77498,7 +77929,7 @@ async function validateSkillSmoke(input) {
|
|
|
77498
77929
|
]
|
|
77499
77930
|
};
|
|
77500
77931
|
}
|
|
77501
|
-
const evalResult = await
|
|
77932
|
+
const evalResult = await _internals97.evaluateSkillChange({
|
|
77502
77933
|
directory: input.directory,
|
|
77503
77934
|
slug: input.skillSlug,
|
|
77504
77935
|
candidateContent: input.candidateContent,
|
|
@@ -77517,7 +77948,7 @@ async function validateSkillSmoke(input) {
|
|
|
77517
77948
|
notes.push(`phrase-eval passed (score ${evalResult.candidateScore.toFixed(2)})`);
|
|
77518
77949
|
}
|
|
77519
77950
|
if (input.checkCommand && input.checkCommand.length > 0) {
|
|
77520
|
-
const cmdResult = await
|
|
77951
|
+
const cmdResult = await _internals97.spawnAsync(input.checkCommand, input.directory, input.checkTimeoutMs ?? 60000);
|
|
77521
77952
|
if (!cmdResult || cmdResult.exitCode !== 0) {
|
|
77522
77953
|
return {
|
|
77523
77954
|
ok: false,
|
|
@@ -77587,7 +78018,7 @@ async function prepareCandidatePayloads(inputRoot, candidateId2, skillSlug, base
|
|
|
77587
78018
|
candidate2.contentHash = await computeCandidateInputContentHash2(inputRoot, candidate2);
|
|
77588
78019
|
return { baseline, candidate: candidate2 };
|
|
77589
78020
|
}
|
|
77590
|
-
var
|
|
78021
|
+
var _internals98 = {
|
|
77591
78022
|
tryAcquireLock,
|
|
77592
78023
|
emitTelemetry: emit,
|
|
77593
78024
|
evaluateCandidateV1,
|
|
@@ -77595,7 +78026,7 @@ var _internals97 = {
|
|
|
77595
78026
|
};
|
|
77596
78027
|
async function acquireProjectLock(directory) {
|
|
77597
78028
|
assertProjectRoot(directory);
|
|
77598
|
-
const result = await
|
|
78029
|
+
const result = await _internals98.tryAcquireLock(directory, PROJECT_LOCK_PATH, "skill-opt-controller", "project-run");
|
|
77599
78030
|
if (!result.acquired)
|
|
77600
78031
|
return null;
|
|
77601
78032
|
return async () => {
|
|
@@ -77609,7 +78040,7 @@ async function acquireProjectLock(directory) {
|
|
|
77609
78040
|
async function acquireSkillLock(directory, skillSlug) {
|
|
77610
78041
|
assertProjectRoot(directory);
|
|
77611
78042
|
const lockPath = path109.join(".swarm", "evolution", "skills", skillSlug, ".skill.lock");
|
|
77612
|
-
const result = await
|
|
78043
|
+
const result = await _internals98.tryAcquireLock(directory, lockPath, "skill-opt-controller", `skill-${skillSlug}`);
|
|
77613
78044
|
if (!result.acquired)
|
|
77614
78045
|
return null;
|
|
77615
78046
|
return async () => {
|
|
@@ -77806,13 +78237,13 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
77806
78237
|
while (true) {
|
|
77807
78238
|
try {
|
|
77808
78239
|
const evalInputRoot = input.inputRoot ?? input.directory;
|
|
77809
|
-
const { baseline, candidate: candidate2 } = await
|
|
78240
|
+
const { baseline, candidate: candidate2 } = await _internals98.prepareCandidatePayloads(evalInputRoot, candidateId2, input.skillSlug, input.baselineModel, input.candidateModel, baselineContent, candidateContent);
|
|
77810
78241
|
if (!input.dispatcher) {
|
|
77811
78242
|
throw new Error("no evaluation dispatcher available (cannot run validation)");
|
|
77812
78243
|
}
|
|
77813
|
-
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-
|
|
78244
|
+
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-atbehryj.js");
|
|
77814
78245
|
const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
|
|
77815
|
-
const result = await withProtectedSetIntegrity([evalInputRoot, ...protectedRoots(input.directory)], () =>
|
|
78246
|
+
const result = await withProtectedSetIntegrity([evalInputRoot, ...protectedRoots(input.directory)], () => _internals98.evaluateCandidateV1({
|
|
77816
78247
|
projectRoot: input.directory,
|
|
77817
78248
|
inputRoot: input.inputRoot ?? input.directory,
|
|
77818
78249
|
tasks: input.validationTasks,
|
|
@@ -77870,7 +78301,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
77870
78301
|
deadband: input.config.deadband
|
|
77871
78302
|
};
|
|
77872
78303
|
}
|
|
77873
|
-
|
|
78304
|
+
_internals98.emitTelemetry?.("loop_detected", {
|
|
77874
78305
|
skillSlug: input.skillSlug,
|
|
77875
78306
|
reason: message.slice(0, 160),
|
|
77876
78307
|
source: "skill-opt-controller"
|
|
@@ -78725,13 +79156,46 @@ function getCompactionMetrics(sessionId) {
|
|
|
78725
79156
|
}
|
|
78726
79157
|
|
|
78727
79158
|
// src/services/status-service.ts
|
|
78728
|
-
var
|
|
79159
|
+
var _internals99 = {
|
|
78729
79160
|
loadLeanTurboRunState,
|
|
78730
79161
|
hasActiveLeanTurbo,
|
|
78731
79162
|
hasActiveFullAuto,
|
|
78732
79163
|
getActiveFullAutoSessionID,
|
|
78733
|
-
loadFullAutoRunState
|
|
79164
|
+
loadFullAutoRunState,
|
|
79165
|
+
summarizeTelemetryCosts
|
|
78734
79166
|
};
|
|
79167
|
+
var MAX_TRACKED_TELEMETRY_COST_SUMMARIES = 32;
|
|
79168
|
+
var telemetryCostSummaryCache = new Map;
|
|
79169
|
+
function getTelemetryCostSummary(directory) {
|
|
79170
|
+
const stamp = readTelemetryCostStamp(directory);
|
|
79171
|
+
const cached = telemetryCostSummaryCache.get(directory);
|
|
79172
|
+
if (cached && cached.stamp === stamp)
|
|
79173
|
+
return cached.summary;
|
|
79174
|
+
const summary = _internals99.summarizeTelemetryCosts(directory);
|
|
79175
|
+
telemetryCostSummaryCache.set(directory, { stamp, summary });
|
|
79176
|
+
while (telemetryCostSummaryCache.size > MAX_TRACKED_TELEMETRY_COST_SUMMARIES) {
|
|
79177
|
+
const oldest = telemetryCostSummaryCache.keys().next().value;
|
|
79178
|
+
if (oldest === undefined)
|
|
79179
|
+
break;
|
|
79180
|
+
telemetryCostSummaryCache.delete(oldest);
|
|
79181
|
+
}
|
|
79182
|
+
return summary;
|
|
79183
|
+
}
|
|
79184
|
+
function readTelemetryCostStamp(directory) {
|
|
79185
|
+
const swarmDir = path114.join(directory, ".swarm");
|
|
79186
|
+
const files = [
|
|
79187
|
+
path114.join(swarmDir, "telemetry.jsonl.1"),
|
|
79188
|
+
path114.join(swarmDir, "telemetry.jsonl")
|
|
79189
|
+
];
|
|
79190
|
+
return files.map((file) => {
|
|
79191
|
+
try {
|
|
79192
|
+
const stat9 = fsSync4.statSync(file);
|
|
79193
|
+
return stat9.isFile() ? `${stat9.mtimeMs}:${stat9.ctimeMs}:${stat9.size}` : "missing";
|
|
79194
|
+
} catch {
|
|
79195
|
+
return "missing";
|
|
79196
|
+
}
|
|
79197
|
+
}).join("|");
|
|
79198
|
+
}
|
|
78735
79199
|
async function collectBackgroundWorkStatus(directory) {
|
|
78736
79200
|
try {
|
|
78737
79201
|
await maintainBackgroundDelegations(directory, {
|
|
@@ -78999,11 +79463,11 @@ async function getStatusData(directory, agents, sessionId, options) {
|
|
|
78999
79463
|
} catch {
|
|
79000
79464
|
status.memoryCohort = { linked: false };
|
|
79001
79465
|
}
|
|
79002
|
-
status.fullAutoActive =
|
|
79466
|
+
status.fullAutoActive = _internals99.hasActiveFullAuto();
|
|
79003
79467
|
if (status.fullAutoActive) {
|
|
79004
|
-
const sid =
|
|
79468
|
+
const sid = _internals99.getActiveFullAutoSessionID();
|
|
79005
79469
|
if (sid) {
|
|
79006
|
-
const runState =
|
|
79470
|
+
const runState = _internals99.loadFullAutoRunState(directory, sid);
|
|
79007
79471
|
if (runState?.lastEscalation) {
|
|
79008
79472
|
status.fullAutoEscalation = {
|
|
79009
79473
|
reason: runState.lastEscalation.reason,
|
|
@@ -79033,11 +79497,24 @@ async function getStatusData(directory, agents, sessionId, options) {
|
|
|
79033
79497
|
};
|
|
79034
79498
|
}
|
|
79035
79499
|
}
|
|
79036
|
-
|
|
79500
|
+
status = enrichWithLeanTurbo(status, directory);
|
|
79501
|
+
try {
|
|
79502
|
+
const costs = getTelemetryCostSummary(directory);
|
|
79503
|
+
status.costs = {
|
|
79504
|
+
totalCostUsd: costs.total_cost_usd,
|
|
79505
|
+
delegations: costs.delegations,
|
|
79506
|
+
unavailableDelegations: costs.unavailable_delegations,
|
|
79507
|
+
evidenceStatus: costs.evidence_status,
|
|
79508
|
+
conflictCount: costs.conflict_count,
|
|
79509
|
+
joinMissCount: costs.join_miss_count,
|
|
79510
|
+
telemetryErrorCount: costs.telemetry_error_count
|
|
79511
|
+
};
|
|
79512
|
+
} catch {}
|
|
79513
|
+
return status;
|
|
79037
79514
|
}
|
|
79038
79515
|
function enrichWithLeanTurbo(status, directory) {
|
|
79039
79516
|
const turboMode = hasActiveTurboMode();
|
|
79040
|
-
const leanActive =
|
|
79517
|
+
const leanActive = _internals99.hasActiveLeanTurbo();
|
|
79041
79518
|
let turboStrategy = "off";
|
|
79042
79519
|
if (leanActive) {
|
|
79043
79520
|
turboStrategy = "lean";
|
|
@@ -79068,7 +79545,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
79068
79545
|
}
|
|
79069
79546
|
}
|
|
79070
79547
|
if (leanSessionID) {
|
|
79071
|
-
const runState =
|
|
79548
|
+
const runState = _internals99.loadLeanTurboRunState(directory, leanSessionID);
|
|
79072
79549
|
if (runState) {
|
|
79073
79550
|
status.leanTurboPhase = runState.phase;
|
|
79074
79551
|
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
@@ -79110,6 +79587,10 @@ function formatStatusMarkdown(status) {
|
|
|
79110
79587
|
`**Tasks**: ${status.completedTasks}/${status.totalTasks} complete`,
|
|
79111
79588
|
`**Agents**: ${status.agentCount} registered`
|
|
79112
79589
|
];
|
|
79590
|
+
if (status.costs && status.costs.delegations > 0) {
|
|
79591
|
+
const evidence2 = status.costs.evidenceStatus === "complete" ? "complete evidence" : `inconclusive evidence (${status.costs.unavailableDelegations} unavailable, ${status.costs.conflictCount} conflicts, ${status.costs.joinMissCount} join misses, ${status.costs.telemetryErrorCount} telemetry errors)`;
|
|
79592
|
+
lines.push("", `**Cost**: $${status.costs.totalCostUsd.toFixed(6)} across ${status.costs.delegations} delegations \u2014 ${evidence2}`);
|
|
79593
|
+
}
|
|
79113
79594
|
if (status.lastActivity) {
|
|
79114
79595
|
const label = status.lastActivity.agoLabel;
|
|
79115
79596
|
const annotation = status.lastActivity.agoLabel !== "never" && status.lastActivity.agoMs !== null && status.lastActivity.agoMs > 120 * 1000 ? " \u26A0\uFE0F possibly stalled" : "";
|
|
@@ -79432,7 +79913,7 @@ init_logger();
|
|
|
79432
79913
|
var TURBO_BYPASS_DISCLOSURE = "Bypassed: Stage B (reviewer + test_engineer) for Tier 0-2 tasks; phase_complete Gates 1-5 " + "(completion-verify, drift-verifier, hallucination-guard, mutation-gate, phase-council). " + "Still enforced: Stage A (lint, imports, pre_check_batch); Tier 3 Stage B; Gate 5b " + "(architecture-supervisor); Gate 6 (final-council); Gate 7 (full-auto).";
|
|
79433
79914
|
|
|
79434
79915
|
// src/commands/turbo.ts
|
|
79435
|
-
var
|
|
79916
|
+
var _internals100 = {
|
|
79436
79917
|
loadPluginConfigWithMeta
|
|
79437
79918
|
};
|
|
79438
79919
|
async function handleTurboCommand(directory, args, sessionID) {
|
|
@@ -79492,7 +79973,7 @@ async function handleTurboCommand(directory, args, sessionID) {
|
|
|
79492
79973
|
if (arg0 === "on") {
|
|
79493
79974
|
let strategy = "standard";
|
|
79494
79975
|
try {
|
|
79495
|
-
const { config } =
|
|
79976
|
+
const { config } = _internals100.loadPluginConfigWithMeta(directory);
|
|
79496
79977
|
if (config.turbo?.strategy === "lean") {
|
|
79497
79978
|
strategy = "lean";
|
|
79498
79979
|
}
|
|
@@ -79589,7 +80070,7 @@ function enableLeanTurbo(session, directory, sessionID) {
|
|
|
79589
80070
|
let maxParallelCoders = 4;
|
|
79590
80071
|
let conflictPolicy = "serialize";
|
|
79591
80072
|
try {
|
|
79592
|
-
const { config } =
|
|
80073
|
+
const { config } = _internals100.loadPluginConfigWithMeta(directory);
|
|
79593
80074
|
const leanConfig = config.turbo?.lean;
|
|
79594
80075
|
if (leanConfig) {
|
|
79595
80076
|
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
@@ -79797,7 +80278,7 @@ function findSimilarCommands(query) {
|
|
|
79797
80278
|
}
|
|
79798
80279
|
const scored = VALID_COMMANDS.map((cmd) => {
|
|
79799
80280
|
const cmdLower = cmd.toLowerCase();
|
|
79800
|
-
const fullScore =
|
|
80281
|
+
const fullScore = _internals101.levenshteinDistance(q, cmdLower);
|
|
79801
80282
|
let tokenScore = Infinity;
|
|
79802
80283
|
if (cmd.includes(" ") || cmd.includes("-")) {
|
|
79803
80284
|
const qTokens = q.split(/[\s-]+/);
|
|
@@ -79810,7 +80291,7 @@ function findSimilarCommands(query) {
|
|
|
79810
80291
|
for (const ct of cmdTokens) {
|
|
79811
80292
|
if (ct.length === 0)
|
|
79812
80293
|
continue;
|
|
79813
|
-
const dist =
|
|
80294
|
+
const dist = _internals101.levenshteinDistance(qt, ct);
|
|
79814
80295
|
if (dist < minDist)
|
|
79815
80296
|
minDist = dist;
|
|
79816
80297
|
}
|
|
@@ -79820,7 +80301,7 @@ function findSimilarCommands(query) {
|
|
|
79820
80301
|
}
|
|
79821
80302
|
const dashStrippedQ = q.replace(/-/g, "");
|
|
79822
80303
|
const dashStrippedCmd = cmdLower.replace(/-/g, "");
|
|
79823
|
-
const dashScore =
|
|
80304
|
+
const dashScore = _internals101.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
|
|
79824
80305
|
const score = Math.min(fullScore, tokenScore, dashScore);
|
|
79825
80306
|
return { cmd, score };
|
|
79826
80307
|
});
|
|
@@ -79855,16 +80336,16 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
79855
80336
|
async function handleHelpCommand(ctx) {
|
|
79856
80337
|
const targetCommand = ctx.args.join(" ");
|
|
79857
80338
|
if (!targetCommand) {
|
|
79858
|
-
const { buildHelpText } = await import("./index-
|
|
80339
|
+
const { buildHelpText } = await import("./index-36sgq7n9.js");
|
|
79859
80340
|
return buildHelpText();
|
|
79860
80341
|
}
|
|
79861
80342
|
const tokens = targetCommand.split(/\s+/);
|
|
79862
|
-
const resolved =
|
|
80343
|
+
const resolved = _internals101.resolveCommand(tokens);
|
|
79863
80344
|
if (resolved) {
|
|
79864
|
-
return
|
|
80345
|
+
return _internals101.buildDetailedHelp(resolved.key, resolved.entry);
|
|
79865
80346
|
}
|
|
79866
|
-
const similar =
|
|
79867
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
80347
|
+
const similar = _internals101.findSimilarCommands(targetCommand);
|
|
80348
|
+
const { buildHelpText: fullHelp } = await import("./index-36sgq7n9.js");
|
|
79868
80349
|
if (similar.length > 0) {
|
|
79869
80350
|
return `Command '/swarm ${targetCommand}' not found.
|
|
79870
80351
|
|
|
@@ -80126,7 +80607,7 @@ var COMMAND_REGISTRY = {
|
|
|
80126
80607
|
toolNoArgs: true
|
|
80127
80608
|
},
|
|
80128
80609
|
help: {
|
|
80129
|
-
handler: (ctx) =>
|
|
80610
|
+
handler: (ctx) => _internals101.handleHelpCommand(ctx),
|
|
80130
80611
|
description: "Show help for swarm commands",
|
|
80131
80612
|
category: "core",
|
|
80132
80613
|
args: "[command]",
|
|
@@ -80195,7 +80676,7 @@ var COMMAND_REGISTRY = {
|
|
|
80195
80676
|
},
|
|
80196
80677
|
"guardrail explain": {
|
|
80197
80678
|
handler: async (ctx) => {
|
|
80198
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
80679
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-5z64w3ah.js");
|
|
80199
80680
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
80200
80681
|
},
|
|
80201
80682
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -80205,7 +80686,7 @@ var COMMAND_REGISTRY = {
|
|
|
80205
80686
|
},
|
|
80206
80687
|
"guardrail reset": {
|
|
80207
80688
|
handler: async (ctx) => {
|
|
80208
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
80689
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-yjwk20rb.js");
|
|
80209
80690
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
80210
80691
|
},
|
|
80211
80692
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -80214,7 +80695,7 @@ var COMMAND_REGISTRY = {
|
|
|
80214
80695
|
},
|
|
80215
80696
|
"guardrail-explain": {
|
|
80216
80697
|
handler: async (ctx) => {
|
|
80217
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
80698
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-5z64w3ah.js");
|
|
80218
80699
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
80219
80700
|
},
|
|
80220
80701
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -80224,7 +80705,7 @@ var COMMAND_REGISTRY = {
|
|
|
80224
80705
|
},
|
|
80225
80706
|
"guardrail-reset": {
|
|
80226
80707
|
handler: async (ctx) => {
|
|
80227
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
80708
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-yjwk20rb.js");
|
|
80228
80709
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
80229
80710
|
},
|
|
80230
80711
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -80234,7 +80715,7 @@ var COMMAND_REGISTRY = {
|
|
|
80234
80715
|
},
|
|
80235
80716
|
"guardrail-log": {
|
|
80236
80717
|
handler: async (ctx) => {
|
|
80237
|
-
const { handleGuardrailLog } = await import("./guardrail-log-
|
|
80718
|
+
const { handleGuardrailLog } = await import("./guardrail-log-f9nf687y.js");
|
|
80238
80719
|
return handleGuardrailLog(ctx.directory, ctx.args);
|
|
80239
80720
|
},
|
|
80240
80721
|
description: "Read the guardrail decision log (use --blocks-only for blocks)",
|
|
@@ -81240,7 +81721,7 @@ function validateToolPolicy() {
|
|
|
81240
81721
|
}
|
|
81241
81722
|
return { valid: warnings.length === 0, warnings };
|
|
81242
81723
|
}
|
|
81243
|
-
var
|
|
81724
|
+
var _internals101 = {
|
|
81244
81725
|
handleHelpCommand,
|
|
81245
81726
|
validateAliases,
|
|
81246
81727
|
validateToolPolicy,
|
|
@@ -81250,16 +81731,16 @@ var _internals100 = {
|
|
|
81250
81731
|
findSimilarCommands,
|
|
81251
81732
|
buildDetailedHelp
|
|
81252
81733
|
};
|
|
81253
|
-
var validation =
|
|
81734
|
+
var validation = _internals101.validateAliases();
|
|
81254
81735
|
if (!validation.valid) {
|
|
81255
81736
|
throw new Error(`COMMAND_REGISTRY alias validation failed:
|
|
81256
81737
|
${validation.errors.join(`
|
|
81257
81738
|
`)}`);
|
|
81258
81739
|
}
|
|
81259
|
-
|
|
81740
|
+
_internals101.emitValidationWarnings("COMMAND_REGISTRY alias warnings", validation.warnings);
|
|
81260
81741
|
try {
|
|
81261
|
-
const toolPolicyValidation =
|
|
81262
|
-
|
|
81742
|
+
const toolPolicyValidation = _internals101.validateToolPolicy();
|
|
81743
|
+
_internals101.emitValidationWarnings("COMMAND_REGISTRY toolPolicy warnings", toolPolicyValidation.warnings);
|
|
81263
81744
|
} catch (e) {
|
|
81264
81745
|
warn(`COMMAND_REGISTRY toolPolicy validation failed (non-fatal): ${e.message}`);
|
|
81265
81746
|
}
|
|
@@ -83191,7 +83672,7 @@ function formatCommandNotFound(tokens) {
|
|
|
83191
83672
|
const attemptedCommand = tokens[0] || "";
|
|
83192
83673
|
const MAX_DISPLAY = 100;
|
|
83193
83674
|
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
83194
|
-
const similar =
|
|
83675
|
+
const similar = _internals101.findSimilarCommands(attemptedCommand);
|
|
83195
83676
|
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
83196
83677
|
const suggestions = similar.length > 0 ? `Did you mean:
|
|
83197
83678
|
${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
|
|
@@ -86227,7 +86708,7 @@ function getDisplayFinalPromptPressure() {
|
|
|
86227
86708
|
async function rehydratePrSubscriptions(sessionID, directory) {
|
|
86228
86709
|
const map = new Map;
|
|
86229
86710
|
try {
|
|
86230
|
-
const { listActive: listActive2 } = await import("./pr-subscriptions-
|
|
86711
|
+
const { listActive: listActive2 } = await import("./pr-subscriptions-fvmey1x6.js");
|
|
86231
86712
|
const records = await listActive2(directory);
|
|
86232
86713
|
for (const record of records) {
|
|
86233
86714
|
if (record.sessionID !== sessionID)
|
|
@@ -86432,7 +86913,7 @@ async function createSessionWithinBudget(promise, label, onLateResolve) {
|
|
|
86432
86913
|
}
|
|
86433
86914
|
}, () => {});
|
|
86434
86915
|
try {
|
|
86435
|
-
return await withTimeout(promise,
|
|
86916
|
+
return await withTimeout(promise, _internals103.worktreeSessionCreateTimeoutMs, new Error(`${label} deadline expired after ${_internals103.worktreeSessionCreateTimeoutMs}ms`));
|
|
86436
86917
|
} catch (error2) {
|
|
86437
86918
|
timedOut = true;
|
|
86438
86919
|
throw error2;
|
|
@@ -86570,8 +87051,8 @@ var WORKTREE_LIST_TIMEOUT_MS = 15000;
|
|
|
86570
87051
|
async function preProvisionCollisionCheck(taskId, directory, _sessionId) {
|
|
86571
87052
|
let proc;
|
|
86572
87053
|
try {
|
|
86573
|
-
proc =
|
|
86574
|
-
|
|
87054
|
+
proc = _internals103.bunSpawn([
|
|
87055
|
+
_internals103.resolveGitExecutable(),
|
|
86575
87056
|
"-C",
|
|
86576
87057
|
directory,
|
|
86577
87058
|
"worktree",
|
|
@@ -86673,13 +87154,13 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
|
|
|
86673
87154
|
return extracted === expectedSessionId;
|
|
86674
87155
|
}
|
|
86675
87156
|
async function inspectStandardWorktreeCollisionOwnership(identity) {
|
|
86676
|
-
const collisionOwnership = await import("./worktree-collision-ownership-
|
|
87157
|
+
const collisionOwnership = await import("./worktree-collision-ownership-7kf9mm5z.js");
|
|
86677
87158
|
return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
|
|
86678
87159
|
}
|
|
86679
87160
|
async function runRecoveryGit(directory, args, timeoutMs = 15000) {
|
|
86680
87161
|
let proc;
|
|
86681
87162
|
try {
|
|
86682
|
-
proc =
|
|
87163
|
+
proc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", directory, ...args], {
|
|
86683
87164
|
stdin: "ignore",
|
|
86684
87165
|
stdout: "pipe",
|
|
86685
87166
|
stderr: "pipe",
|
|
@@ -86742,7 +87223,7 @@ async function publishRecoveryAuthorityForSettlement(input) {
|
|
|
86742
87223
|
if (input.dispatch.recoveryClaim || !input.provenance) {
|
|
86743
87224
|
return { ok: true };
|
|
86744
87225
|
}
|
|
86745
|
-
const identity = await
|
|
87226
|
+
const identity = await _internals103.buildWorktreeRecoveryPublishIdentity({
|
|
86746
87227
|
directory: input.directory,
|
|
86747
87228
|
dispatch: input.dispatch,
|
|
86748
87229
|
taskId: input.taskId,
|
|
@@ -86756,7 +87237,7 @@ async function publishRecoveryAuthorityForSettlement(input) {
|
|
|
86756
87237
|
reason: "worktree recovery publish identity could not be derived from the merge provenance"
|
|
86757
87238
|
};
|
|
86758
87239
|
}
|
|
86759
|
-
const published =
|
|
87240
|
+
const published = _internals103.publishWorktreeRecoveryAuthority(input.directory, identity);
|
|
86760
87241
|
return published.ok ? { ok: true } : { ok: false, code: published.code, reason: published.reason };
|
|
86761
87242
|
}
|
|
86762
87243
|
function isExactRecoveryClaimantStillActive(authority) {
|
|
@@ -86818,12 +87299,12 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86818
87299
|
})
|
|
86819
87300
|
};
|
|
86820
87301
|
let recoveryLaunch;
|
|
86821
|
-
const lifecycleLock = await
|
|
87302
|
+
const lifecycleLock = await _internals103.tryAcquireWorktreeLifecycleLock(args.directory, WORKTREE_LIFECYCLE_LOCK_FILE, "worktree-provisioning", args.taskId);
|
|
86822
87303
|
if (!lifecycleLock.acquired) {
|
|
86823
87304
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, "STANDARD_WORKTREE_LIFECYCLE_BUSY: init orphan recovery is active; retry this coder dispatch after recovery completes.");
|
|
86824
87305
|
}
|
|
86825
87306
|
try {
|
|
86826
|
-
const collision = await
|
|
87307
|
+
const collision = await _internals103.preProvisionCollisionCheck(args.taskId, args.directory, args.parentSessionID);
|
|
86827
87308
|
if (collision.uncertainty) {
|
|
86828
87309
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_SCAN_UNCERTAIN: ${collision.uncertainty}. Destructive cleanup and provisioning were blocked.`);
|
|
86829
87310
|
}
|
|
@@ -86832,17 +87313,17 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86832
87313
|
const ownerInfo = collision.ownerSessionId ? ` owned by session ${collision.ownerSessionId}` : " with uncertain ownership";
|
|
86833
87314
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `PREPROVISION_COLLISION: task ${args.taskId} already has a lane on branch ${collision.existingBranch ?? "unknown"}${ownerInfo}; cleanup and provisioning were blocked.`);
|
|
86834
87315
|
}
|
|
86835
|
-
for (const dispatch of
|
|
87316
|
+
for (const dispatch of _internals103.standardWorktreeByCallID.values()) {
|
|
86836
87317
|
if (dispatch.handle.branchName === collision.existingBranch) {
|
|
86837
87318
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `PREPROVISION_COLLISION_ACTIVE: branch ${collision.existingBranch} is still tracked by an active standard-worktree dispatch.`);
|
|
86838
87319
|
}
|
|
86839
87320
|
}
|
|
86840
|
-
for (const record of
|
|
87321
|
+
for (const record of _internals103.awaitingMergeByCallID.values()) {
|
|
86841
87322
|
if (record.branch === collision.existingBranch) {
|
|
86842
87323
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `PREPROVISION_COLLISION_AWAITING_MERGE: branch ${collision.existingBranch} is still awaiting merge-back.`);
|
|
86843
87324
|
}
|
|
86844
87325
|
}
|
|
86845
|
-
const recoveryCandidate = maybeSelectRecoverableAuthority(
|
|
87326
|
+
const recoveryCandidate = maybeSelectRecoverableAuthority(_internals103.lookupWorktreeRecoveryAuthoritiesByTask(args.directory, {
|
|
86846
87327
|
parentSessionId: args.parentSessionID,
|
|
86847
87328
|
taskId: resolveRecoveryTaskId(args)
|
|
86848
87329
|
}), collision);
|
|
@@ -86853,7 +87334,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86853
87334
|
let recoveredChildSessionId = "";
|
|
86854
87335
|
let claimed;
|
|
86855
87336
|
try {
|
|
86856
|
-
claimed = await
|
|
87337
|
+
claimed = await _internals103.claimWorktreeRecoveryAuthority(args.directory, {
|
|
86857
87338
|
authorityDigest: recoveryCandidate.authority.authorityDigest,
|
|
86858
87339
|
claimantCallID: args.callID,
|
|
86859
87340
|
claimantSessionId: args.parentSessionID,
|
|
@@ -86913,7 +87394,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86913
87394
|
}
|
|
86914
87395
|
});
|
|
86915
87396
|
} catch (error2) {
|
|
86916
|
-
|
|
87397
|
+
_internals103.replayWorktreeRecoveryClaimJournal(args.directory);
|
|
86917
87398
|
if (recoveredChildSessionId) {
|
|
86918
87399
|
await teardownEphemeralSession(client.session, recoveredChildSessionId);
|
|
86919
87400
|
}
|
|
@@ -86950,7 +87431,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86950
87431
|
};
|
|
86951
87432
|
}
|
|
86952
87433
|
if (!recoveryLaunch) {
|
|
86953
|
-
const ownership = await
|
|
87434
|
+
const ownership = await _internals103.inspectStandardWorktreeCollisionOwnership({
|
|
86954
87435
|
directory: args.directory,
|
|
86955
87436
|
parentSessionId: args.parentSessionID,
|
|
86956
87437
|
taskId: args.taskId,
|
|
@@ -86975,31 +87456,31 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86975
87456
|
}
|
|
86976
87457
|
}
|
|
86977
87458
|
if (collisionPathExists) {
|
|
86978
|
-
const preserveResult = await
|
|
87459
|
+
const preserveResult = await _internals103.preserveDirtyWorktreeAtPath(collision.worktreePath, collision.existingBranch, "denied", args.directory, worktreeConfig.worktree_dir);
|
|
86979
87460
|
if (preserveResult.outcome === "preserve-failed") {
|
|
86980
87461
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_PRESERVATION_FAILED_ABORT_CLEANUP: pre-provision collision for task ${args.taskId} could not be preserved (${preserveResult.error}). Cleanup and provisioning were blocked.`);
|
|
86981
87462
|
}
|
|
86982
|
-
const removeResult = await
|
|
87463
|
+
const removeResult = await _internals103.removeWorktree(collision.worktreePath, args.directory, { force: true, worktreeDir: worktreeConfig.worktree_dir });
|
|
86983
87464
|
if ("error" in removeResult) {
|
|
86984
87465
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_REMOVE_FAILED: ${removeResult.error}. Provisioning was blocked.`);
|
|
86985
87466
|
}
|
|
86986
|
-
const cleanupResult = await
|
|
87467
|
+
const cleanupResult = await _internals103.postMergeCleanup(args.directory, collision.existingBranch);
|
|
86987
87468
|
if ("error" in cleanupResult) {
|
|
86988
87469
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_BRANCH_CLEANUP_FAILED: ${cleanupResult.error}. Provisioning was blocked.`);
|
|
86989
87470
|
}
|
|
86990
87471
|
} else {
|
|
86991
|
-
const pruneResult = await
|
|
87472
|
+
const pruneResult = await _internals103.pruneStaleWorktreeMetadata(args.directory);
|
|
86992
87473
|
if ("error" in pruneResult) {
|
|
86993
87474
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_PRUNE_FAILED: ${pruneResult.error}. Provisioning was blocked without deleting the lane branch.`);
|
|
86994
87475
|
}
|
|
86995
87476
|
}
|
|
86996
|
-
const verification = await
|
|
87477
|
+
const verification = await _internals103.preProvisionCollisionCheck(args.taskId, args.directory, args.parentSessionID);
|
|
86997
87478
|
if (verification.uncertainty || verification.collision) {
|
|
86998
87479
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_CLEANUP_UNVERIFIED: ${verification.uncertainty ?? "git still reports the colliding lane after cleanup"}. Provisioning was blocked.`);
|
|
86999
87480
|
}
|
|
87000
87481
|
}
|
|
87001
87482
|
}
|
|
87002
|
-
|
|
87483
|
+
_internals103.recordWorktreeProvisioningOwner(args.directory, {
|
|
87003
87484
|
callID: args.callID,
|
|
87004
87485
|
parentSessionId: args.parentSessionID,
|
|
87005
87486
|
worktreeSessionId: args.parentSessionID,
|
|
@@ -87046,7 +87527,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
87046
87527
|
canonicalPath2 = args.directory;
|
|
87047
87528
|
let provisionResult;
|
|
87048
87529
|
try {
|
|
87049
|
-
provisionResult = await
|
|
87530
|
+
provisionResult = await _internals103.provisionWorktree(args.directory, args.taskId, args.parentSessionID, {
|
|
87050
87531
|
purpose: "lane",
|
|
87051
87532
|
worktreeDir: worktreeConfig.worktree_dir,
|
|
87052
87533
|
mergeStrategy: worktreeConfig.merge_strategy,
|
|
@@ -87054,11 +87535,11 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
87054
87535
|
scope: args.scope
|
|
87055
87536
|
});
|
|
87056
87537
|
} catch (error2) {
|
|
87057
|
-
|
|
87538
|
+
_internals103.removeWorktreeProvisioningOwner(args.directory, args.callID, provisioningOwnerIdentity);
|
|
87058
87539
|
throw error2;
|
|
87059
87540
|
}
|
|
87060
87541
|
if ("error" in provisionResult) {
|
|
87061
|
-
|
|
87542
|
+
_internals103.removeWorktreeProvisioningOwner(args.directory, args.callID, provisioningOwnerIdentity);
|
|
87062
87543
|
const message = `STANDARD_WORKTREE_PROVISION_FAILED: ${provisionResult.error}.`;
|
|
87063
87544
|
handleStandardWorktreeFailure(args.parentSessionID, worktreeConfig.policy, message);
|
|
87064
87545
|
return;
|
|
@@ -87082,7 +87563,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
87082
87563
|
const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, handle.worktreePath);
|
|
87083
87564
|
if (laneProfile) {
|
|
87084
87565
|
try {
|
|
87085
|
-
const { writeLaneProfileToDiskReal } = await import("./core-
|
|
87566
|
+
const { writeLaneProfileToDiskReal } = await import("./core-pp64ys5v.js");
|
|
87086
87567
|
await writeLaneProfileToDiskReal(handle.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
|
|
87087
87568
|
} catch {}
|
|
87088
87569
|
}
|
|
@@ -87111,26 +87592,26 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
87111
87592
|
}
|
|
87112
87593
|
});
|
|
87113
87594
|
} catch (error2) {
|
|
87114
|
-
await
|
|
87595
|
+
await _internals103.removeWorktree(handle.worktreePath, args.directory, {
|
|
87115
87596
|
force: true,
|
|
87116
87597
|
worktreeDir: worktreeConfig.worktree_dir
|
|
87117
87598
|
}).catch((cleanupError) => {
|
|
87118
87599
|
log(`[worktree-isolation] session-create failure cleanup could not remove lane ${handle.worktreePath}: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
|
|
87119
87600
|
});
|
|
87120
|
-
|
|
87601
|
+
_internals103.removeWorktreeProvisioningOwner(args.directory, args.callID, provisioningOwnerIdentity);
|
|
87121
87602
|
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
87122
87603
|
const message = `STANDARD_WORKTREE_SESSION_CREATE_FAILED: ${detail}.`;
|
|
87123
87604
|
handleStandardWorktreeFailure(args.parentSessionID, worktreeConfig.policy, message);
|
|
87124
87605
|
return;
|
|
87125
87606
|
}
|
|
87126
87607
|
if (!createResult?.data?.id) {
|
|
87127
|
-
await
|
|
87608
|
+
await _internals103.removeWorktree(handle.worktreePath, args.directory, {
|
|
87128
87609
|
force: true,
|
|
87129
87610
|
worktreeDir: worktreeConfig.worktree_dir
|
|
87130
87611
|
}).catch((cleanupError) => {
|
|
87131
87612
|
log(`[worktree-isolation] session-create failure cleanup could not remove lane ${handle.worktreePath}: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
|
|
87132
87613
|
});
|
|
87133
|
-
|
|
87614
|
+
_internals103.removeWorktreeProvisioningOwner(args.directory, args.callID, provisioningOwnerIdentity);
|
|
87134
87615
|
const createError = createResult.error;
|
|
87135
87616
|
const detail = typeof createError === "string" ? createError : JSON.stringify(createError ?? "missing session id");
|
|
87136
87617
|
const message = `STANDARD_WORKTREE_SESSION_CREATE_FAILED: ${detail}.`;
|
|
@@ -87169,8 +87650,8 @@ async function preserveBackgroundWorktreeOwnershipForCallId(callID) {
|
|
|
87169
87650
|
return { outcome: "not-found" };
|
|
87170
87651
|
let refProc;
|
|
87171
87652
|
try {
|
|
87172
|
-
refProc =
|
|
87173
|
-
|
|
87653
|
+
refProc = _internals103.bunSpawn([
|
|
87654
|
+
_internals103.resolveGitExecutable(),
|
|
87174
87655
|
"-C",
|
|
87175
87656
|
dispatch.handle.worktreePath,
|
|
87176
87657
|
"rev-parse",
|
|
@@ -87214,8 +87695,8 @@ async function preserveBackgroundWorktreeOwnershipForCallId(callID) {
|
|
|
87214
87695
|
const tag = `swarm-preserved-owner/${session}/${lane}/${callDigest}`;
|
|
87215
87696
|
let tagProc;
|
|
87216
87697
|
try {
|
|
87217
|
-
tagProc =
|
|
87218
|
-
|
|
87698
|
+
tagProc = _internals103.bunSpawn([
|
|
87699
|
+
_internals103.resolveGitExecutable(),
|
|
87219
87700
|
"-C",
|
|
87220
87701
|
dispatch.handle.worktreePath,
|
|
87221
87702
|
"tag",
|
|
@@ -87265,8 +87746,8 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87265
87746
|
}
|
|
87266
87747
|
let statusProc;
|
|
87267
87748
|
try {
|
|
87268
|
-
statusProc =
|
|
87269
|
-
|
|
87749
|
+
statusProc = _internals103.bunSpawn([
|
|
87750
|
+
_internals103.resolveGitExecutable(),
|
|
87270
87751
|
"-C",
|
|
87271
87752
|
worktreePath,
|
|
87272
87753
|
"status",
|
|
@@ -87308,7 +87789,7 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87308
87789
|
}
|
|
87309
87790
|
let addProc;
|
|
87310
87791
|
try {
|
|
87311
|
-
addProc =
|
|
87792
|
+
addProc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", worktreePath, "add", "-A"], {
|
|
87312
87793
|
stdin: "ignore",
|
|
87313
87794
|
stdout: "pipe",
|
|
87314
87795
|
stderr: "pipe",
|
|
@@ -87342,8 +87823,8 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87342
87823
|
const commitMessage = `swarm-preserved: ${reason} for callID ${sanitizedCallID} at ${isoDate}`;
|
|
87343
87824
|
let commitProc;
|
|
87344
87825
|
try {
|
|
87345
|
-
commitProc =
|
|
87346
|
-
|
|
87826
|
+
commitProc = _internals103.bunSpawn([
|
|
87827
|
+
_internals103.resolveGitExecutable(),
|
|
87347
87828
|
"-C",
|
|
87348
87829
|
worktreePath,
|
|
87349
87830
|
"commit",
|
|
@@ -87381,8 +87862,8 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87381
87862
|
}
|
|
87382
87863
|
let hashProc;
|
|
87383
87864
|
try {
|
|
87384
|
-
hashProc =
|
|
87385
|
-
|
|
87865
|
+
hashProc = _internals103.bunSpawn([
|
|
87866
|
+
_internals103.resolveGitExecutable(),
|
|
87386
87867
|
"-C",
|
|
87387
87868
|
worktreePath,
|
|
87388
87869
|
"rev-parse",
|
|
@@ -87428,7 +87909,7 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87428
87909
|
const tagName = `swarm-preserved-${sanitizedCallID}-${shortHash}`;
|
|
87429
87910
|
let tagProc;
|
|
87430
87911
|
try {
|
|
87431
|
-
tagProc =
|
|
87912
|
+
tagProc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", worktreePath, "tag", tagName], {
|
|
87432
87913
|
stdin: "ignore",
|
|
87433
87914
|
stdout: "pipe",
|
|
87434
87915
|
stderr: "pipe",
|
|
@@ -87464,8 +87945,8 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87464
87945
|
async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _directory, _worktree_dir) {
|
|
87465
87946
|
let statusProc;
|
|
87466
87947
|
try {
|
|
87467
|
-
statusProc =
|
|
87468
|
-
|
|
87948
|
+
statusProc = _internals103.bunSpawn([
|
|
87949
|
+
_internals103.resolveGitExecutable(),
|
|
87469
87950
|
"-C",
|
|
87470
87951
|
worktreePath,
|
|
87471
87952
|
"status",
|
|
@@ -87507,7 +87988,7 @@ async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _di
|
|
|
87507
87988
|
}
|
|
87508
87989
|
let addProc;
|
|
87509
87990
|
try {
|
|
87510
|
-
addProc =
|
|
87991
|
+
addProc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", worktreePath, "add", "-A"], {
|
|
87511
87992
|
stdin: "ignore",
|
|
87512
87993
|
stdout: "pipe",
|
|
87513
87994
|
stderr: "pipe",
|
|
@@ -87542,8 +88023,8 @@ async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _di
|
|
|
87542
88023
|
const commitMessage = `swarm-preserved: ${reason} for worktree ${sanitizedPath} at ${isoDate}`;
|
|
87543
88024
|
let commitProc;
|
|
87544
88025
|
try {
|
|
87545
|
-
commitProc =
|
|
87546
|
-
|
|
88026
|
+
commitProc = _internals103.bunSpawn([
|
|
88027
|
+
_internals103.resolveGitExecutable(),
|
|
87547
88028
|
"-C",
|
|
87548
88029
|
worktreePath,
|
|
87549
88030
|
"commit",
|
|
@@ -87581,8 +88062,8 @@ async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _di
|
|
|
87581
88062
|
}
|
|
87582
88063
|
let hashProc;
|
|
87583
88064
|
try {
|
|
87584
|
-
hashProc =
|
|
87585
|
-
|
|
88065
|
+
hashProc = _internals103.bunSpawn([
|
|
88066
|
+
_internals103.resolveGitExecutable(),
|
|
87586
88067
|
"-C",
|
|
87587
88068
|
worktreePath,
|
|
87588
88069
|
"rev-parse",
|
|
@@ -87628,7 +88109,7 @@ async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _di
|
|
|
87628
88109
|
const tagName = `swarm-preserved-worktree-${sanitizedBranch}-${shortHash}`;
|
|
87629
88110
|
let tagProc;
|
|
87630
88111
|
try {
|
|
87631
|
-
tagProc =
|
|
88112
|
+
tagProc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", worktreePath, "tag", tagName], {
|
|
87632
88113
|
stdin: "ignore",
|
|
87633
88114
|
stdout: "pipe",
|
|
87634
88115
|
stderr: "pipe",
|
|
@@ -87682,7 +88163,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87682
88163
|
parentSessionID = awaiting.parentSessionID;
|
|
87683
88164
|
}
|
|
87684
88165
|
if (dispatch?.recoveryClaim && (reason === "denied" || reason === "cancelled")) {
|
|
87685
|
-
const renewResult =
|
|
88166
|
+
const renewResult = _internals103.renewWorktreeRecoveryClaim(directory, {
|
|
87686
88167
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
87687
88168
|
claimantCallID: callID,
|
|
87688
88169
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -87699,7 +88180,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87699
88180
|
pushAdvisory(session3, message);
|
|
87700
88181
|
throw new Error(message);
|
|
87701
88182
|
}
|
|
87702
|
-
const releaseResult =
|
|
88183
|
+
const releaseResult = _internals103.releaseWorktreeRecoveryClaim(directory, {
|
|
87703
88184
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
87704
88185
|
claimantCallID: callID,
|
|
87705
88186
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -87728,7 +88209,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87728
88209
|
let preserveResult;
|
|
87729
88210
|
if (reason === "denied" || reason === "cancelled") {
|
|
87730
88211
|
try {
|
|
87731
|
-
preserveResult = await
|
|
88212
|
+
preserveResult = await _internals103.preserveDirtyWorktreeForCallId(callID, reason, directory, worktree_dir);
|
|
87732
88213
|
} catch (err) {
|
|
87733
88214
|
log(`[swarm] cleanupStandardWorktreeForCallId: preserveDirtyWorktreeForCallId threw for ${callID}: ${err}`);
|
|
87734
88215
|
preserveResult = {
|
|
@@ -87739,7 +88220,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87739
88220
|
}
|
|
87740
88221
|
if (preserveResult.outcome === "clean") {
|
|
87741
88222
|
try {
|
|
87742
|
-
preserveResult = await
|
|
88223
|
+
preserveResult = await _internals103.preserveDirtyWorktreeForCallId(callID, reason, directory, worktree_dir);
|
|
87743
88224
|
} catch (err) {
|
|
87744
88225
|
log(`[swarm] cleanupStandardWorktreeForCallId: final preservation check threw for ${callID}: ${err}`);
|
|
87745
88226
|
preserveResult = {
|
|
@@ -87763,7 +88244,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87763
88244
|
}
|
|
87764
88245
|
let removedWorktree = false;
|
|
87765
88246
|
try {
|
|
87766
|
-
const result = await
|
|
88247
|
+
const result = await _internals103.removeWorktree(worktreePath, directory, {
|
|
87767
88248
|
force: true,
|
|
87768
88249
|
worktreeDir: worktree_dir
|
|
87769
88250
|
});
|
|
@@ -87773,7 +88254,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87773
88254
|
}
|
|
87774
88255
|
let cleanedBranch = false;
|
|
87775
88256
|
try {
|
|
87776
|
-
const result = await
|
|
88257
|
+
const result = await _internals103.postMergeCleanup(directory, branchName);
|
|
87777
88258
|
cleanedBranch = !("error" in result);
|
|
87778
88259
|
} catch (err) {
|
|
87779
88260
|
log(`[swarm] cleanupStandardWorktreeForCallId: postMergeCleanup failed for ${callID}: ${err}`);
|
|
@@ -87823,7 +88304,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87823
88304
|
const renewRecoveryClaimLease = (phase, provenance) => {
|
|
87824
88305
|
if (!dispatch.recoveryClaim)
|
|
87825
88306
|
return;
|
|
87826
|
-
const renewed =
|
|
88307
|
+
const renewed = _internals103.renewWorktreeRecoveryClaim(directory, {
|
|
87827
88308
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
87828
88309
|
claimantCallID: resolvedCallID,
|
|
87829
88310
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -87841,7 +88322,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87841
88322
|
const releaseRecoveryClaim = (provenance) => {
|
|
87842
88323
|
if (!dispatch.recoveryClaim)
|
|
87843
88324
|
return;
|
|
87844
|
-
const released =
|
|
88325
|
+
const released = _internals103.releaseWorktreeRecoveryClaim(directory, {
|
|
87845
88326
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
87846
88327
|
claimantCallID: resolvedCallID,
|
|
87847
88328
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -87877,7 +88358,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87877
88358
|
}
|
|
87878
88359
|
const mergeResult = await (async () => {
|
|
87879
88360
|
if (!dispatch.recoveryClaim) {
|
|
87880
|
-
return
|
|
88361
|
+
return _internals103.attemptMergeBackFromDirty(dispatch.handle.worktreePath, dispatch.handle.branchName, directory, getMergeStrategy({ merge_strategy: dispatch.mergeStrategy }), {
|
|
87881
88362
|
operationId: settlement.operationId,
|
|
87882
88363
|
resume: settlement.resume,
|
|
87883
88364
|
onBeforeMerge: settlement.onBeforeMerge
|
|
@@ -87901,7 +88382,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87901
88382
|
if (settlement.onBeforeMerge) {
|
|
87902
88383
|
await settlement.onBeforeMerge(provenance);
|
|
87903
88384
|
}
|
|
87904
|
-
const recovered = await
|
|
88385
|
+
const recovered = await _internals103.recoverMergeBackFromImmutableCoordinates(directory, coordinates);
|
|
87905
88386
|
if ("merged" in recovered && recovered.merged) {
|
|
87906
88387
|
if (recovered.sourceCommitOrder && recovered.rewrittenCommitOrder) {
|
|
87907
88388
|
dispatch.recoveryClaim.settlement = {
|
|
@@ -87990,7 +88471,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87990
88471
|
settlement: dispatch.recoveryClaim.settlement
|
|
87991
88472
|
};
|
|
87992
88473
|
if (cleanupResult.removedWorktree && cleanupResult.cleanedBranch) {
|
|
87993
|
-
const finalized =
|
|
88474
|
+
const finalized = _internals103.finalizeWorktreeRecoveryAuthority(directory, request);
|
|
87994
88475
|
if (!finalized.ok) {
|
|
87995
88476
|
return failRecoverySettlement("recovery-claim-finalize", `The merged recovery lane was cleaned up but could not finalize its exact claim; ${describeRecoveryMutationFailure({
|
|
87996
88477
|
action: "finalize",
|
|
@@ -88007,7 +88488,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
88007
88488
|
}
|
|
88008
88489
|
clearWorktreeMergeStatus(statusKey);
|
|
88009
88490
|
try {
|
|
88010
|
-
const { removeLaneProfileFromDiskReal } = await import("./core-
|
|
88491
|
+
const { removeLaneProfileFromDiskReal } = await import("./core-pp64ys5v.js");
|
|
88011
88492
|
await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
|
|
88012
88493
|
} catch {}
|
|
88013
88494
|
const state = serializationStateBySessionID.get(dispatch.parentSessionID);
|
|
@@ -88111,7 +88592,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
88111
88592
|
awaitingMergeByCallID.delete(resolvedCallID);
|
|
88112
88593
|
if (dispatch.recoveryClaim) {
|
|
88113
88594
|
try {
|
|
88114
|
-
|
|
88595
|
+
_internals103.releaseWorktreeRecoveryClaim(directory, {
|
|
88115
88596
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
88116
88597
|
claimantCallID: resolvedCallID,
|
|
88117
88598
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -88172,7 +88653,7 @@ async function readLaneEnvFileFromDisk(worktreePath, laneIndex) {
|
|
|
88172
88653
|
}
|
|
88173
88654
|
return result;
|
|
88174
88655
|
}
|
|
88175
|
-
var
|
|
88656
|
+
var _internals103 = {
|
|
88176
88657
|
provisionWorktree,
|
|
88177
88658
|
removeWorktree,
|
|
88178
88659
|
attemptMergeBackFromDirty,
|
|
@@ -88210,4 +88691,4 @@ var _internals102 = {
|
|
|
88210
88691
|
resolveGitExecutable
|
|
88211
88692
|
};
|
|
88212
88693
|
|
|
88213
|
-
export { PrReviewRunIdSchema, resetActionCircuitExternally, getBlockingActionCircuit, dcNormalizeCommand, dcUnwrapWrappers, dcSplitSegments, dcExtractRecursiveRmTargets, dcEvaluateRecursiveDeleteTargets, dcCheckJunctionCreation, dcExtractWindowsCmdTargets, dcExtractPowerShellTargets, getSharedClassifierGuardrailBlock, classifyCommand, normalizeSwarmCommandInput, canonicalCommandKey, formatCommandNotFound, executeSwarmCommand, SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, classifySwarmCommandToolUse, classifySwarmCommandChatFallbackUse, detectPosixWrites, detectWindowsWrites, resolveWriteTargets, getAgentSession, parseLeanLaneIndex, computeLaneRuntimeProfile, MAX_TRACKED_STANDARD_WORKTREE_CALLS, awaitingMergeByCallID, standardWorktreeByCallID, standardWorktreeSerializationSessions, getStandardWorktreeDegradationReason, resetStandardWorktreeIsolationState, checkStandardWorktreeSerializationRelease, sanitizeWorktreeTaskId, preProvisionCollisionCheck, isLaneOwnedByCurrentSession, precreateStandardWorktreeSession, preserveBackgroundWorktreeOwnershipForCallId, preserveDirtyWorktreeForCallId, preserveDirtyWorktreeAtPath, cleanupStandardWorktreeForCallId, abortStandardWorktreeDispatch, finishStandardWorktreeDispatch, readLaneEnvFileFromDisk,
|
|
88694
|
+
export { PrReviewRunIdSchema, resetActionCircuitExternally, getBlockingActionCircuit, dcNormalizeCommand, dcUnwrapWrappers, dcSplitSegments, dcExtractRecursiveRmTargets, dcEvaluateRecursiveDeleteTargets, dcCheckJunctionCreation, dcExtractWindowsCmdTargets, dcExtractPowerShellTargets, getSharedClassifierGuardrailBlock, classifyCommand, normalizeSwarmCommandInput, canonicalCommandKey, formatCommandNotFound, executeSwarmCommand, SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, classifySwarmCommandToolUse, classifySwarmCommandChatFallbackUse, detectPosixWrites, detectWindowsWrites, resolveWriteTargets, getAgentSession, parseLeanLaneIndex, computeLaneRuntimeProfile, MAX_TRACKED_STANDARD_WORKTREE_CALLS, awaitingMergeByCallID, standardWorktreeByCallID, standardWorktreeSerializationSessions, getStandardWorktreeDegradationReason, resetStandardWorktreeIsolationState, checkStandardWorktreeSerializationRelease, sanitizeWorktreeTaskId, preProvisionCollisionCheck, isLaneOwnedByCurrentSession, precreateStandardWorktreeSession, preserveBackgroundWorktreeOwnershipForCallId, preserveDirtyWorktreeForCallId, preserveDirtyWorktreeAtPath, cleanupStandardWorktreeForCallId, abortStandardWorktreeDispatch, finishStandardWorktreeDispatch, readLaneEnvFileFromDisk, _internals103 as _internals, readPrReviewReentryBindingContext, prWorkflowSessionFileStem, handleAcknowledgeSpecDriftCommand, handleAgentsCommand, handleAnalyzeCommand, handleApproveWriteCommand, handleArchiveCommand, handleAutoProceedCommand, handleBenchmarkCommand, handleBrainstormCommand, handleCheckpointCommand, handleCiSimulateCommand, handleClarifyCommand, createCuratorLLMDelegate, _internals26 as _internals1, normalizeRecommendationEntryIdToken, parseKnowledgeRecommendations, parseKnowledgeRecommendationsWithDiagnostics, parseStructuredCuratorBlocks, readCuratorSummary, writeCuratorSummary, appendCuratorRecommendation, mergeCuratorPhaseSummary, filterPhaseEvents, checkPhaseCompliance, runCuratorInit, runCuratorPhase, applyCuratorKnowledgeUpdates, isHiveEligible, countDistinctProjects, checkHivePromotions, _internals30 as _internals2, createHivePromoterHook, promoteToHive, promoteFromSwarm, safeRealpathSync, handleCloseCommand, handleCodebaseReviewCommand, handleConcurrencyCommand, handleConfigCommand, handleConsolidateCommand, handleCostsCommand, handleCouncilCommand, handleCurateCommand, handleDarkMatterCommand, handleDeepDiveCommand, handleDeepResearchCommand, getPluginConfigDir, getPluginCachePaths, getPluginLockFilePaths, VERSION_PINNED_LEAF, discoverVersionPinnedCachePaths, readCachePackageVersion, handleDiagnoseCommand, handleDoctorCommand, handleEvidenceCommand, handleEvidenceSummaryCommand, handleExportCommand, handleFullAutoCommand, handleGateAuditCommand, handleGateStatsCommand, handleHandoffCommand, handleBlueprintValidateCommand, handleBlueprintCurrentCommand, handleBlueprintHistoryCommand, handleBlueprintDiffCommand, handleBlueprintExportCommand, handleHarnessCandidateValidateCommand, handleHarnessCandidateShowCommand, handleHarnessCandidateDiffCommand, handleHistoryCommand, handleKnowledgeQuarantineCommand, handleKnowledgeRestoreCommand, handleKnowledgeMigrateCommand, handleKnowledgeListCommand, handleKnowledgeUnactionableCommand, handleKnowledgeRetryHardeningCommand, handleLearningCommand, handleLinkCommand, handleMemoryCommand, handleMemoryStatusCommand, handleMemoryValueLogCommand, handleMemoryMigrateCommand, handleMemoryImportCommand, handleMemoryExportCommand, handlePlanCommand, handlePreflightCommand, handlePromoteCommand, handleQaGatesCommand, handleRecoverCommand, handleResetCommand, handleResetSessionCommand, handleRetrieveCommand, handleReviewCommand, handleRollbackCommand, handleSddStatusCommand, handleSddValidateCommand, handleSddProjectCommand, handleSddCommand, handleSimulateCommand, handleSpecifyCommand, handleStatusCommand, handleSyncPlanCommand, handleTurboCommand, handleUnlinkCommand, handleWriteRetroCommand, handleHelpCommand, COMMAND_REGISTRY, VALID_COMMANDS, _internals101 as _internals3, resolveCommand };
|