opencode-swarm 7.77.0 → 7.77.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/skills/swarm-pr-review/SKILL.md +6 -8
- package/dist/cli/index.js +54 -2
- package/dist/commands/registry.d.ts +1 -1
- package/dist/index.js +761 -278
- package/dist/test-impact/failure-classifier.d.ts +1 -1
- package/dist/tools/dispatch-lanes.d.ts +107 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/manifest.d.ts +1 -0
- package/dist/tools/tool-metadata.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ var package_default;
|
|
|
69
69
|
var init_package = __esm(() => {
|
|
70
70
|
package_default = {
|
|
71
71
|
name: "opencode-swarm",
|
|
72
|
-
version: "7.77.
|
|
72
|
+
version: "7.77.2",
|
|
73
73
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
74
74
|
main: "dist/index.js",
|
|
75
75
|
types: "dist/index.d.ts",
|
|
@@ -682,6 +682,10 @@ var init_tool_metadata = __esm(() => {
|
|
|
682
682
|
"test_engineer"
|
|
683
683
|
]
|
|
684
684
|
},
|
|
685
|
+
dispatch_lanes: {
|
|
686
|
+
description: "dispatch multiple read-only exploration/review lanes concurrently and return a structured join result",
|
|
687
|
+
agents: ["architect"]
|
|
688
|
+
},
|
|
685
689
|
summarize_work: {
|
|
686
690
|
description: "emit a short structured summary of completed work (key decisions, assumptions, risks, constraints) at task completion; rolls up per phase for architecture-supervisor review. Advisory, never blocks.",
|
|
687
691
|
agents: [
|
|
@@ -85407,10 +85411,37 @@ function stringHash(str) {
|
|
|
85407
85411
|
h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
85408
85412
|
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16);
|
|
85409
85413
|
}
|
|
85414
|
+
function buildErrnoPatternPair(errno, contextPattern) {
|
|
85415
|
+
return [
|
|
85416
|
+
new RegExp(`(?:^|\\n)\\s*${errno}\\b`, "i"),
|
|
85417
|
+
new RegExp(`\\b(?:${contextPattern})\\b[^\\n]{0,${MAX_INFRA_CONTEXT_CHARS}}\\b${errno}\\b`, "i")
|
|
85418
|
+
];
|
|
85419
|
+
}
|
|
85420
|
+
function isInfrastructureFailure(currentResult) {
|
|
85421
|
+
const errorMessage = currentResult.errorMessage || "";
|
|
85422
|
+
const stackPrefix = currentResult.stackPrefix || "";
|
|
85423
|
+
if (/\bassertionerror\b/i.test(errorMessage)) {
|
|
85424
|
+
return false;
|
|
85425
|
+
}
|
|
85426
|
+
const combinedText = `${errorMessage}
|
|
85427
|
+
${stackPrefix}`;
|
|
85428
|
+
return INFRASTRUCTURE_FAILURE_PATTERNS.some((pattern) => pattern.test(combinedText));
|
|
85429
|
+
}
|
|
85410
85430
|
function classifyFailure(currentResult, history) {
|
|
85411
85431
|
const normalizedFile = currentResult.testFile.toLowerCase();
|
|
85412
85432
|
const normalizedName = currentResult.testName.toLowerCase();
|
|
85413
85433
|
const testHistory = history.filter((r) => r.testFile.toLowerCase() === normalizedFile && r.testName.toLowerCase() === normalizedName).sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
85434
|
+
if (isInfrastructureFailure(currentResult)) {
|
|
85435
|
+
return {
|
|
85436
|
+
testFile: currentResult.testFile,
|
|
85437
|
+
testName: currentResult.testName,
|
|
85438
|
+
classification: "infrastructure_failure",
|
|
85439
|
+
errorMessage: currentResult.errorMessage,
|
|
85440
|
+
stackPrefix: currentResult.stackPrefix,
|
|
85441
|
+
durationMs: currentResult.durationMs,
|
|
85442
|
+
confidence: computeConfidence2(testHistory.length)
|
|
85443
|
+
};
|
|
85444
|
+
}
|
|
85414
85445
|
const lastThree = testHistory.slice(0, 3);
|
|
85415
85446
|
const lastTen = testHistory.slice(0, 10);
|
|
85416
85447
|
const normalizedTestFile = currentResult.testFile.toLowerCase();
|
|
@@ -85510,6 +85541,26 @@ function classifyAndCluster(testResults, history) {
|
|
|
85510
85541
|
const clusters = clusterFailures(classified);
|
|
85511
85542
|
return { classified, clusters };
|
|
85512
85543
|
}
|
|
85544
|
+
var MAX_INFRA_CONTEXT_CHARS = 80, INFRASTRUCTURE_FAILURE_PATTERNS;
|
|
85545
|
+
var init_failure_classifier = __esm(() => {
|
|
85546
|
+
INFRASTRUCTURE_FAILURE_PATTERNS = [
|
|
85547
|
+
/\boutofmemoryerror\b/i,
|
|
85548
|
+
/\ballocation failed - javascript heap out of memory\b/i,
|
|
85549
|
+
/\bcannot allocate memory\b/i,
|
|
85550
|
+
/\bout of memory:\s*killed process\b/i,
|
|
85551
|
+
/\boom-kill\b/i,
|
|
85552
|
+
/(?:^|\n|\bcommand failed:\s*)\s*killed(?:\s*(?:[-:]\s*)?(?:by signal|signal|sigkill).*)?\s*(?:\n|$)/i,
|
|
85553
|
+
...buildErrnoPatternPair("ETIMEDOUT", "connect|connection|request|socket|network"),
|
|
85554
|
+
...buildErrnoPatternPair("ECONNREFUSED", "connect|connection|socket"),
|
|
85555
|
+
...buildErrnoPatternPair("ENOTFOUND", "getaddrinfo|dns|lookup"),
|
|
85556
|
+
...buildErrnoPatternPair("ECONNRESET", "connect|connection|request|socket|network|stream|read"),
|
|
85557
|
+
...buildErrnoPatternPair("EPIPE", "pipe|stream|write|socket|stdout|stderr"),
|
|
85558
|
+
/\bbroken pipe\b/i,
|
|
85559
|
+
/\bexit(?:ed)?(?:\s+with)?(?:\s+code)?\s*[:=]?\s*137\b/i,
|
|
85560
|
+
/\bsig(?:segv|abrt|bus)\b/i,
|
|
85561
|
+
/\bsegmentation fault(?:\s*\(core dumped\))?\b/i
|
|
85562
|
+
];
|
|
85563
|
+
});
|
|
85513
85564
|
|
|
85514
85565
|
// src/test-impact/flaky-detector.ts
|
|
85515
85566
|
function computeCombinedFlakyScore(recent) {
|
|
@@ -87720,6 +87771,7 @@ var init_test_runner = __esm(() => {
|
|
|
87720
87771
|
init_zod();
|
|
87721
87772
|
init_discovery();
|
|
87722
87773
|
init_analyzer();
|
|
87774
|
+
init_failure_classifier();
|
|
87723
87775
|
init_history_store();
|
|
87724
87776
|
init_bun_compat();
|
|
87725
87777
|
init_path_security();
|
|
@@ -92631,7 +92683,7 @@ Subcommands:
|
|
|
92631
92683
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handlePrReviewCommand),
|
|
92632
92684
|
description: "Launch deep PR review with multi-lane analysis [url] [--council]",
|
|
92633
92685
|
args: "<pr-url|owner/repo#N|N> [--council]",
|
|
92634
|
-
details: "Launches a structured PR review: reconstructs PR intent via obligation extraction cascade, runs 6 parallel explorer lanes (correctness, security, dependencies, docs-intent-vs-actual, tests, performance-architecture), validates findings through independent reviewer confirmation, applies critic challenge to HIGH/CRITICAL findings, synthesizes structured report. --council variant fires adversarial multi-model review. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolves against origin remote).",
|
|
92686
|
+
details: "Launches a structured PR review: reconstructs PR intent via obligation extraction cascade, runs 6 parallel explorer lanes through the deterministic dispatch_lanes join barrier (correctness, security, dependencies, docs-intent-vs-actual, tests, performance-architecture), validates findings through independent reviewer confirmation, applies critic challenge to HIGH/CRITICAL findings, synthesizes structured report. --council variant fires adversarial multi-model review. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolves against origin remote).",
|
|
92635
92687
|
category: "agent"
|
|
92636
92688
|
},
|
|
92637
92689
|
"pr-feedback": {
|
|
@@ -103386,7 +103438,7 @@ var init_curator_drift = __esm(() => {
|
|
|
103386
103438
|
var exports_design_doc_drift = {};
|
|
103387
103439
|
__export(exports_design_doc_drift, {
|
|
103388
103440
|
runDesignDocDriftCheck: () => runDesignDocDriftCheck,
|
|
103389
|
-
_internals: () =>
|
|
103441
|
+
_internals: () => _internals94
|
|
103390
103442
|
});
|
|
103391
103443
|
import * as fs109 from "node:fs";
|
|
103392
103444
|
import * as path164 from "node:path";
|
|
@@ -103519,7 +103571,7 @@ async function runDesignDocDriftCheck(directory, phase, outDir) {
|
|
|
103519
103571
|
return null;
|
|
103520
103572
|
}
|
|
103521
103573
|
}
|
|
103522
|
-
var DOC_DRIFT_REPORT_PREFIX = "doc-drift-phase-", MAX_TRACEABILITY_BYTES, DESIGN_DOC_FILES, TRACEABILITY_REL,
|
|
103574
|
+
var DOC_DRIFT_REPORT_PREFIX = "doc-drift-phase-", MAX_TRACEABILITY_BYTES, DESIGN_DOC_FILES, TRACEABILITY_REL, _internals94;
|
|
103523
103575
|
var init_design_doc_drift = __esm(() => {
|
|
103524
103576
|
init_event_bus();
|
|
103525
103577
|
init_effective_spec();
|
|
@@ -103534,7 +103586,7 @@ var init_design_doc_drift = __esm(() => {
|
|
|
103534
103586
|
"idiom-notes": path164.join("reference", "idiom-notes.md")
|
|
103535
103587
|
};
|
|
103536
103588
|
TRACEABILITY_REL = path164.join("reference", "traceability.json");
|
|
103537
|
-
|
|
103589
|
+
_internals94 = {
|
|
103538
103590
|
mtimeMsOrNull,
|
|
103539
103591
|
resolveAnchorWithin,
|
|
103540
103592
|
DESIGN_DOC_FILES
|
|
@@ -103545,7 +103597,7 @@ var init_design_doc_drift = __esm(() => {
|
|
|
103545
103597
|
var exports_project_context = {};
|
|
103546
103598
|
__export(exports_project_context, {
|
|
103547
103599
|
buildProjectContext: () => buildProjectContext,
|
|
103548
|
-
_internals: () =>
|
|
103600
|
+
_internals: () => _internals107,
|
|
103549
103601
|
LANG_BACKEND_DETECTION_TIMEOUT_MS: () => LANG_BACKEND_DETECTION_TIMEOUT_MS
|
|
103550
103602
|
});
|
|
103551
103603
|
import * as fs133 from "node:fs";
|
|
@@ -103629,7 +103681,7 @@ function selectLintCommand(backend, directory) {
|
|
|
103629
103681
|
return null;
|
|
103630
103682
|
}
|
|
103631
103683
|
async function buildProjectContext(directory) {
|
|
103632
|
-
const backend = await
|
|
103684
|
+
const backend = await _internals107.pickBackend(directory);
|
|
103633
103685
|
if (!backend)
|
|
103634
103686
|
return null;
|
|
103635
103687
|
const ctx = emptyProjectContext();
|
|
@@ -103668,17 +103720,17 @@ async function buildProjectContext(directory) {
|
|
|
103668
103720
|
if (backend.prompts.reviewerChecklist.length > 0) {
|
|
103669
103721
|
ctx.REVIEWER_CHECKLIST = bulletList(backend.prompts.reviewerChecklist);
|
|
103670
103722
|
}
|
|
103671
|
-
const profiles =
|
|
103723
|
+
const profiles = _internals107.pickedProfiles(directory);
|
|
103672
103724
|
if (profiles.length > 1) {
|
|
103673
103725
|
ctx.PROJECT_CONTEXT_SECONDARY_LANGUAGES = profiles.slice(1).map((p) => p.id).join(", ");
|
|
103674
103726
|
}
|
|
103675
103727
|
return ctx;
|
|
103676
103728
|
}
|
|
103677
|
-
var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300,
|
|
103729
|
+
var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals107;
|
|
103678
103730
|
var init_project_context = __esm(() => {
|
|
103679
103731
|
init_dispatch();
|
|
103680
103732
|
init_framework_detector();
|
|
103681
|
-
|
|
103733
|
+
_internals107 = {
|
|
103682
103734
|
pickBackend,
|
|
103683
103735
|
pickedProfiles
|
|
103684
103736
|
};
|
|
@@ -124398,6 +124450,594 @@ var diff_summary = createSwarmTool({
|
|
|
124398
124450
|
}
|
|
124399
124451
|
});
|
|
124400
124452
|
|
|
124453
|
+
// node_modules/yocto-queue/index.js
|
|
124454
|
+
class Node2 {
|
|
124455
|
+
value;
|
|
124456
|
+
next;
|
|
124457
|
+
constructor(value) {
|
|
124458
|
+
this.value = value;
|
|
124459
|
+
}
|
|
124460
|
+
}
|
|
124461
|
+
|
|
124462
|
+
class Queue {
|
|
124463
|
+
#head;
|
|
124464
|
+
#tail;
|
|
124465
|
+
#size;
|
|
124466
|
+
constructor() {
|
|
124467
|
+
this.clear();
|
|
124468
|
+
}
|
|
124469
|
+
enqueue(value) {
|
|
124470
|
+
const node = new Node2(value);
|
|
124471
|
+
if (this.#head) {
|
|
124472
|
+
this.#tail.next = node;
|
|
124473
|
+
this.#tail = node;
|
|
124474
|
+
} else {
|
|
124475
|
+
this.#head = node;
|
|
124476
|
+
this.#tail = node;
|
|
124477
|
+
}
|
|
124478
|
+
this.#size++;
|
|
124479
|
+
}
|
|
124480
|
+
dequeue() {
|
|
124481
|
+
const current = this.#head;
|
|
124482
|
+
if (!current) {
|
|
124483
|
+
return;
|
|
124484
|
+
}
|
|
124485
|
+
this.#head = this.#head.next;
|
|
124486
|
+
this.#size--;
|
|
124487
|
+
if (!this.#head) {
|
|
124488
|
+
this.#tail = undefined;
|
|
124489
|
+
}
|
|
124490
|
+
return current.value;
|
|
124491
|
+
}
|
|
124492
|
+
peek() {
|
|
124493
|
+
if (!this.#head) {
|
|
124494
|
+
return;
|
|
124495
|
+
}
|
|
124496
|
+
return this.#head.value;
|
|
124497
|
+
}
|
|
124498
|
+
clear() {
|
|
124499
|
+
this.#head = undefined;
|
|
124500
|
+
this.#tail = undefined;
|
|
124501
|
+
this.#size = 0;
|
|
124502
|
+
}
|
|
124503
|
+
get size() {
|
|
124504
|
+
return this.#size;
|
|
124505
|
+
}
|
|
124506
|
+
*[Symbol.iterator]() {
|
|
124507
|
+
let current = this.#head;
|
|
124508
|
+
while (current) {
|
|
124509
|
+
yield current.value;
|
|
124510
|
+
current = current.next;
|
|
124511
|
+
}
|
|
124512
|
+
}
|
|
124513
|
+
*drain() {
|
|
124514
|
+
while (this.#head) {
|
|
124515
|
+
yield this.dequeue();
|
|
124516
|
+
}
|
|
124517
|
+
}
|
|
124518
|
+
}
|
|
124519
|
+
|
|
124520
|
+
// node_modules/p-limit/index.js
|
|
124521
|
+
function pLimit(concurrency) {
|
|
124522
|
+
let rejectOnClear = false;
|
|
124523
|
+
if (typeof concurrency === "object") {
|
|
124524
|
+
({ concurrency, rejectOnClear = false } = concurrency);
|
|
124525
|
+
}
|
|
124526
|
+
validateConcurrency(concurrency);
|
|
124527
|
+
if (typeof rejectOnClear !== "boolean") {
|
|
124528
|
+
throw new TypeError("Expected `rejectOnClear` to be a boolean");
|
|
124529
|
+
}
|
|
124530
|
+
const queue = new Queue;
|
|
124531
|
+
let activeCount = 0;
|
|
124532
|
+
const resumeNext = () => {
|
|
124533
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
124534
|
+
activeCount++;
|
|
124535
|
+
queue.dequeue().run();
|
|
124536
|
+
}
|
|
124537
|
+
};
|
|
124538
|
+
const next = () => {
|
|
124539
|
+
activeCount--;
|
|
124540
|
+
resumeNext();
|
|
124541
|
+
};
|
|
124542
|
+
const run2 = async (function_, resolve55, arguments_2) => {
|
|
124543
|
+
const result = (async () => function_(...arguments_2))();
|
|
124544
|
+
resolve55(result);
|
|
124545
|
+
try {
|
|
124546
|
+
await result;
|
|
124547
|
+
} catch {}
|
|
124548
|
+
next();
|
|
124549
|
+
};
|
|
124550
|
+
const enqueue = (function_, resolve55, reject, arguments_2) => {
|
|
124551
|
+
const queueItem = { reject };
|
|
124552
|
+
new Promise((internalResolve) => {
|
|
124553
|
+
queueItem.run = internalResolve;
|
|
124554
|
+
queue.enqueue(queueItem);
|
|
124555
|
+
}).then(run2.bind(undefined, function_, resolve55, arguments_2));
|
|
124556
|
+
if (activeCount < concurrency) {
|
|
124557
|
+
resumeNext();
|
|
124558
|
+
}
|
|
124559
|
+
};
|
|
124560
|
+
const generator = (function_, ...arguments_2) => new Promise((resolve55, reject) => {
|
|
124561
|
+
enqueue(function_, resolve55, reject, arguments_2);
|
|
124562
|
+
});
|
|
124563
|
+
Object.defineProperties(generator, {
|
|
124564
|
+
activeCount: {
|
|
124565
|
+
get: () => activeCount
|
|
124566
|
+
},
|
|
124567
|
+
pendingCount: {
|
|
124568
|
+
get: () => queue.size
|
|
124569
|
+
},
|
|
124570
|
+
clearQueue: {
|
|
124571
|
+
value() {
|
|
124572
|
+
if (!rejectOnClear) {
|
|
124573
|
+
queue.clear();
|
|
124574
|
+
return;
|
|
124575
|
+
}
|
|
124576
|
+
const abortError = AbortSignal.abort().reason;
|
|
124577
|
+
while (queue.size > 0) {
|
|
124578
|
+
queue.dequeue().reject(abortError);
|
|
124579
|
+
}
|
|
124580
|
+
}
|
|
124581
|
+
},
|
|
124582
|
+
concurrency: {
|
|
124583
|
+
get: () => concurrency,
|
|
124584
|
+
set(newConcurrency) {
|
|
124585
|
+
validateConcurrency(newConcurrency);
|
|
124586
|
+
concurrency = newConcurrency;
|
|
124587
|
+
queueMicrotask(() => {
|
|
124588
|
+
while (activeCount < concurrency && queue.size > 0) {
|
|
124589
|
+
resumeNext();
|
|
124590
|
+
}
|
|
124591
|
+
});
|
|
124592
|
+
}
|
|
124593
|
+
},
|
|
124594
|
+
map: {
|
|
124595
|
+
async value(iterable, function_) {
|
|
124596
|
+
const promises10 = Array.from(iterable, (value, index) => this(function_, value, index));
|
|
124597
|
+
return Promise.all(promises10);
|
|
124598
|
+
}
|
|
124599
|
+
}
|
|
124600
|
+
});
|
|
124601
|
+
return generator;
|
|
124602
|
+
}
|
|
124603
|
+
function validateConcurrency(concurrency) {
|
|
124604
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
124605
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
124606
|
+
}
|
|
124607
|
+
}
|
|
124608
|
+
|
|
124609
|
+
// src/tools/dispatch-lanes.ts
|
|
124610
|
+
init_zod();
|
|
124611
|
+
init_constants();
|
|
124612
|
+
init_schema();
|
|
124613
|
+
|
|
124614
|
+
// src/parallel/dispatcher/parallel-dispatcher.ts
|
|
124615
|
+
function createParallelDispatcher(config3) {
|
|
124616
|
+
const limit = pLimit(config3.maxConcurrentTasks);
|
|
124617
|
+
const activeSlots = new Map;
|
|
124618
|
+
let slotCounter = 0;
|
|
124619
|
+
let shutdownCalled = false;
|
|
124620
|
+
return {
|
|
124621
|
+
config: config3,
|
|
124622
|
+
dispatch(taskId) {
|
|
124623
|
+
if (!config3.enabled) {
|
|
124624
|
+
return { action: "reject", reason: "dispatcher_disabled" };
|
|
124625
|
+
}
|
|
124626
|
+
if (shutdownCalled) {
|
|
124627
|
+
return { action: "reject", reason: "dispatcher_shutdown" };
|
|
124628
|
+
}
|
|
124629
|
+
if (activeSlots.size >= config3.maxConcurrentTasks) {
|
|
124630
|
+
return { action: "defer", reason: "max_concurrent_tasks_reached" };
|
|
124631
|
+
}
|
|
124632
|
+
const slotId = `slot-${++slotCounter}`;
|
|
124633
|
+
const runId = `run-${taskId}-${slotId}`;
|
|
124634
|
+
const slot = {
|
|
124635
|
+
slotId,
|
|
124636
|
+
taskId,
|
|
124637
|
+
runId,
|
|
124638
|
+
startedAt: Date.now()
|
|
124639
|
+
};
|
|
124640
|
+
activeSlots.set(slotId, slot);
|
|
124641
|
+
limit(async () => {});
|
|
124642
|
+
return { action: "dispatch", reason: "slot_available", slot };
|
|
124643
|
+
},
|
|
124644
|
+
handles() {
|
|
124645
|
+
return [...activeSlots.values()].map((slot) => ({
|
|
124646
|
+
slotId: slot.slotId,
|
|
124647
|
+
taskId: slot.taskId,
|
|
124648
|
+
runId: slot.runId,
|
|
124649
|
+
cancel: () => {
|
|
124650
|
+
activeSlots.delete(slot.slotId);
|
|
124651
|
+
}
|
|
124652
|
+
}));
|
|
124653
|
+
},
|
|
124654
|
+
releaseSlot(slotId) {
|
|
124655
|
+
activeSlots.delete(slotId);
|
|
124656
|
+
},
|
|
124657
|
+
shutdown() {
|
|
124658
|
+
shutdownCalled = true;
|
|
124659
|
+
activeSlots.clear();
|
|
124660
|
+
limit.clearQueue();
|
|
124661
|
+
}
|
|
124662
|
+
};
|
|
124663
|
+
}
|
|
124664
|
+
|
|
124665
|
+
// src/tools/dispatch-lanes.ts
|
|
124666
|
+
init_state();
|
|
124667
|
+
init_create_tool();
|
|
124668
|
+
var MAX_LANES = 8;
|
|
124669
|
+
var MAX_PROMPT_CHARS = 80000;
|
|
124670
|
+
var DEFAULT_TIMEOUT_MS3 = 300000;
|
|
124671
|
+
var MAX_TIMEOUT_MS2 = 1800000;
|
|
124672
|
+
var MAX_LANE_OUTPUT_CHARS = 20000;
|
|
124673
|
+
var MAX_ERROR_CHARS = 200;
|
|
124674
|
+
var ERROR_TRUNCATION_SUFFIX = "...";
|
|
124675
|
+
var AGENT_NAME_SEPARATORS = ["_", "-", " "];
|
|
124676
|
+
var READ_ONLY_LANE_ROLES = new Set([
|
|
124677
|
+
"explorer",
|
|
124678
|
+
"reviewer",
|
|
124679
|
+
"critic",
|
|
124680
|
+
"critic_oversight",
|
|
124681
|
+
"critic_sounding_board",
|
|
124682
|
+
"critic_drift_verifier",
|
|
124683
|
+
"critic_hallucination_verifier",
|
|
124684
|
+
"critic_architecture_supervisor",
|
|
124685
|
+
"sme",
|
|
124686
|
+
"researcher",
|
|
124687
|
+
"council_generalist",
|
|
124688
|
+
"council_skeptic",
|
|
124689
|
+
"council_domain_expert"
|
|
124690
|
+
]);
|
|
124691
|
+
var READ_ONLY_TOOL_DENYLIST = [
|
|
124692
|
+
...new Set([
|
|
124693
|
+
...WRITE_TOOL_NAMES,
|
|
124694
|
+
"extract_code_blocks",
|
|
124695
|
+
"multiedit",
|
|
124696
|
+
"multi_edit",
|
|
124697
|
+
"todo_write",
|
|
124698
|
+
"save_plan",
|
|
124699
|
+
"update_task_status",
|
|
124700
|
+
"phase_complete",
|
|
124701
|
+
"declare_scope",
|
|
124702
|
+
"declare_council_criteria",
|
|
124703
|
+
"submit_council_verdicts",
|
|
124704
|
+
"submit_phase_council_verdicts",
|
|
124705
|
+
"set_qa_gates",
|
|
124706
|
+
"write_retro",
|
|
124707
|
+
"write_drift_evidence",
|
|
124708
|
+
"write_hallucination_evidence",
|
|
124709
|
+
"write_mutation_evidence",
|
|
124710
|
+
"knowledge_add",
|
|
124711
|
+
"knowledge_remove",
|
|
124712
|
+
"summarize_work",
|
|
124713
|
+
"doc_scan"
|
|
124714
|
+
])
|
|
124715
|
+
];
|
|
124716
|
+
var LaneSchema = exports_external.object({
|
|
124717
|
+
id: exports_external.string().min(1).max(80).regex(/^[A-Za-z0-9][A-Za-z0-9_.-]*$/).describe("Stable lane identifier, unique within this dispatch batch"),
|
|
124718
|
+
agent: exports_external.string().min(1).max(120).describe("Read-only swarm agent name, including any generated swarm prefix"),
|
|
124719
|
+
prompt: exports_external.string().min(1).max(MAX_PROMPT_CHARS).describe("Full lane prompt to send to the requested agent")
|
|
124720
|
+
});
|
|
124721
|
+
var DispatchLanesArgsSchema = exports_external.object({
|
|
124722
|
+
lanes: exports_external.array(LaneSchema).min(1).max(MAX_LANES).describe("Read-only lane specs to dispatch concurrently"),
|
|
124723
|
+
max_concurrent: exports_external.number().int().min(1).max(MAX_LANES).optional().describe("Maximum lanes in flight at once; defaults to lane count"),
|
|
124724
|
+
timeout_ms: exports_external.number().int().min(10).max(MAX_TIMEOUT_MS2).optional().describe("Per-lane session create/prompt timeout in milliseconds")
|
|
124725
|
+
});
|
|
124726
|
+
var _internals79 = {
|
|
124727
|
+
getSessionOps: () => swarmState.opencodeClient?.session ?? null,
|
|
124728
|
+
getGeneratedAgentNames: () => swarmState.generatedAgentNames,
|
|
124729
|
+
createParallelDispatcher,
|
|
124730
|
+
now: () => Date.now()
|
|
124731
|
+
};
|
|
124732
|
+
async function executeDispatchLanes(args2, directory, context = {}) {
|
|
124733
|
+
const parsed = DispatchLanesArgsSchema.safeParse(args2);
|
|
124734
|
+
if (!parsed.success) {
|
|
124735
|
+
return failureResult({
|
|
124736
|
+
failure_class: "invalid_args",
|
|
124737
|
+
message: "Invalid dispatch_lanes arguments",
|
|
124738
|
+
errors: parsed.error.issues.map((issue3) => `${issue3.path.join(".")}: ${issue3.message}`)
|
|
124739
|
+
});
|
|
124740
|
+
}
|
|
124741
|
+
const duplicateLaneIds = findDuplicateLaneIds(parsed.data.lanes);
|
|
124742
|
+
if (duplicateLaneIds.length > 0) {
|
|
124743
|
+
return failureResult({
|
|
124744
|
+
failure_class: "invalid_args",
|
|
124745
|
+
message: "Lane IDs must be unique within one dispatch_lanes batch",
|
|
124746
|
+
errors: duplicateLaneIds.map((id) => `Duplicate lane id: ${id}`)
|
|
124747
|
+
});
|
|
124748
|
+
}
|
|
124749
|
+
const session = _internals79.getSessionOps();
|
|
124750
|
+
if (!session) {
|
|
124751
|
+
return failureResult({
|
|
124752
|
+
failure_class: "no_client",
|
|
124753
|
+
message: "OpenCode session client is not available"
|
|
124754
|
+
});
|
|
124755
|
+
}
|
|
124756
|
+
const lanes = parsed.data.lanes;
|
|
124757
|
+
const maxConcurrent = Math.min(parsed.data.max_concurrent ?? lanes.length, lanes.length, MAX_LANES);
|
|
124758
|
+
const timeoutMs = parsed.data.timeout_ms ?? DEFAULT_TIMEOUT_MS3;
|
|
124759
|
+
const dispatcher = _internals79.createParallelDispatcher({
|
|
124760
|
+
enabled: true,
|
|
124761
|
+
maxConcurrentTasks: maxConcurrent,
|
|
124762
|
+
evidenceLockTimeoutMs: 0
|
|
124763
|
+
});
|
|
124764
|
+
const limit = pLimit(maxConcurrent);
|
|
124765
|
+
try {
|
|
124766
|
+
const laneResults = await Promise.all(lanes.map((lane) => limit(() => runLane(session, dispatcher, lane, directory, timeoutMs, context))));
|
|
124767
|
+
return buildResult(laneResults, maxConcurrent, timeoutMs);
|
|
124768
|
+
} finally {
|
|
124769
|
+
dispatcher.shutdown();
|
|
124770
|
+
}
|
|
124771
|
+
}
|
|
124772
|
+
async function runLane(session, dispatcher, lane, directory, timeoutMs, context) {
|
|
124773
|
+
const validation2 = validateLaneAgent(lane.agent, context);
|
|
124774
|
+
const role = validation2.role;
|
|
124775
|
+
const startedAt = isoNow();
|
|
124776
|
+
if (!validation2.ok) {
|
|
124777
|
+
return {
|
|
124778
|
+
id: lane.id,
|
|
124779
|
+
agent: lane.agent,
|
|
124780
|
+
role,
|
|
124781
|
+
status: "rejected",
|
|
124782
|
+
started_at: startedAt,
|
|
124783
|
+
completed_at: isoNow(),
|
|
124784
|
+
error: validation2.error
|
|
124785
|
+
};
|
|
124786
|
+
}
|
|
124787
|
+
const decision = dispatcher.dispatch(lane.id);
|
|
124788
|
+
if (decision.action !== "dispatch") {
|
|
124789
|
+
return {
|
|
124790
|
+
id: lane.id,
|
|
124791
|
+
agent: lane.agent,
|
|
124792
|
+
role,
|
|
124793
|
+
status: "failed",
|
|
124794
|
+
started_at: startedAt,
|
|
124795
|
+
completed_at: isoNow(),
|
|
124796
|
+
error: `dispatcher ${decision.action}: ${decision.reason}`
|
|
124797
|
+
};
|
|
124798
|
+
}
|
|
124799
|
+
let sessionId;
|
|
124800
|
+
try {
|
|
124801
|
+
const createTimeoutMessage = `Lane "${lane.id}" session.create timed out after ${timeoutMs}ms`;
|
|
124802
|
+
const createPromise = session.create({ query: { directory } });
|
|
124803
|
+
let createTimedOut = false;
|
|
124804
|
+
createPromise.then((createResult2) => {
|
|
124805
|
+
if (createTimedOut && createResult2.data?.id) {
|
|
124806
|
+
scheduleSessionCleanup(session, createResult2.data.id);
|
|
124807
|
+
}
|
|
124808
|
+
}).catch(() => {
|
|
124809
|
+
return;
|
|
124810
|
+
});
|
|
124811
|
+
const createResult = await withTimeout2(createPromise, timeoutMs, createTimeoutMessage).catch((error93) => {
|
|
124812
|
+
if (formatError3(error93) === createTimeoutMessage) {
|
|
124813
|
+
createTimedOut = true;
|
|
124814
|
+
}
|
|
124815
|
+
throw error93;
|
|
124816
|
+
});
|
|
124817
|
+
if (!createResult.data?.id) {
|
|
124818
|
+
return failedLane(lane, role, startedAt, `session.create failed: ${formatError3(createResult.error)}`, decision.slot.slotId, decision.slot.runId);
|
|
124819
|
+
}
|
|
124820
|
+
sessionId = createResult.data.id;
|
|
124821
|
+
const promptResult = await withTimeout2(session.prompt({
|
|
124822
|
+
path: { id: sessionId },
|
|
124823
|
+
body: {
|
|
124824
|
+
agent: lane.agent,
|
|
124825
|
+
tools: buildReadOnlyTools(),
|
|
124826
|
+
parts: [{ type: "text", text: lane.prompt }]
|
|
124827
|
+
}
|
|
124828
|
+
}), timeoutMs, `Lane "${lane.id}" session.prompt timed out after ${timeoutMs}ms`);
|
|
124829
|
+
if (!promptResult.data) {
|
|
124830
|
+
return failedLane(lane, role, startedAt, `session.prompt failed: ${formatError3(promptResult.error)}`, decision.slot.slotId, decision.slot.runId, sessionId);
|
|
124831
|
+
}
|
|
124832
|
+
const boundedOutput = boundLaneOutput(extractText3(promptResult.data.parts));
|
|
124833
|
+
return {
|
|
124834
|
+
id: lane.id,
|
|
124835
|
+
agent: lane.agent,
|
|
124836
|
+
role,
|
|
124837
|
+
status: "completed",
|
|
124838
|
+
session_id: sessionId,
|
|
124839
|
+
slot_id: decision.slot.slotId,
|
|
124840
|
+
run_id: decision.slot.runId,
|
|
124841
|
+
started_at: startedAt,
|
|
124842
|
+
completed_at: isoNow(),
|
|
124843
|
+
...boundedOutput
|
|
124844
|
+
};
|
|
124845
|
+
} catch (error93) {
|
|
124846
|
+
return failedLane(lane, role, startedAt, formatError3(error93), decision.slot.slotId, decision.slot.runId, sessionId);
|
|
124847
|
+
} finally {
|
|
124848
|
+
dispatcher.releaseSlot(decision.slot.slotId);
|
|
124849
|
+
if (sessionId) {
|
|
124850
|
+
scheduleSessionCleanup(session, sessionId);
|
|
124851
|
+
}
|
|
124852
|
+
}
|
|
124853
|
+
}
|
|
124854
|
+
function buildResult(laneResults, maxConcurrent, timeoutMs) {
|
|
124855
|
+
const completed = laneResults.filter((lane) => lane.status === "completed");
|
|
124856
|
+
const failed = laneResults.filter((lane) => lane.status === "failed");
|
|
124857
|
+
const rejected = laneResults.filter((lane) => lane.status === "rejected");
|
|
124858
|
+
return {
|
|
124859
|
+
success: failed.length === 0 && rejected.length === 0,
|
|
124860
|
+
dispatched: laneResults.length,
|
|
124861
|
+
completed: completed.length,
|
|
124862
|
+
failed: failed.length,
|
|
124863
|
+
rejected: rejected.length,
|
|
124864
|
+
max_concurrent: maxConcurrent,
|
|
124865
|
+
timeout_ms: timeoutMs,
|
|
124866
|
+
lane_results: laneResults
|
|
124867
|
+
};
|
|
124868
|
+
}
|
|
124869
|
+
function failedLane(lane, role, startedAt, error93, slotId, runId, sessionId) {
|
|
124870
|
+
return {
|
|
124871
|
+
id: lane.id,
|
|
124872
|
+
agent: lane.agent,
|
|
124873
|
+
role,
|
|
124874
|
+
status: "failed",
|
|
124875
|
+
session_id: sessionId,
|
|
124876
|
+
slot_id: slotId,
|
|
124877
|
+
run_id: runId,
|
|
124878
|
+
started_at: startedAt,
|
|
124879
|
+
completed_at: isoNow(),
|
|
124880
|
+
error: error93
|
|
124881
|
+
};
|
|
124882
|
+
}
|
|
124883
|
+
function validateLaneAgent(agent, context) {
|
|
124884
|
+
const generatedAgentNames = _internals79.getGeneratedAgentNames();
|
|
124885
|
+
const role = resolveGeneratedAgentRole(agent, generatedAgentNames);
|
|
124886
|
+
if (!isKnownCanonicalRole(role)) {
|
|
124887
|
+
return {
|
|
124888
|
+
ok: false,
|
|
124889
|
+
role,
|
|
124890
|
+
error: `Agent "${agent}" is not registered as a generated swarm agent or canonical role`
|
|
124891
|
+
};
|
|
124892
|
+
}
|
|
124893
|
+
if (!READ_ONLY_LANE_ROLES.has(role)) {
|
|
124894
|
+
return {
|
|
124895
|
+
ok: false,
|
|
124896
|
+
role,
|
|
124897
|
+
error: `Agent role "${role}" is not allowed for read-only lane dispatch`
|
|
124898
|
+
};
|
|
124899
|
+
}
|
|
124900
|
+
const callerPrefix = context.callerAgent ? getGeneratedAgentPrefix(context.callerAgent, generatedAgentNames) : null;
|
|
124901
|
+
if (callerPrefix) {
|
|
124902
|
+
const lanePrefix = getGeneratedAgentPrefix(agent, generatedAgentNames);
|
|
124903
|
+
if (lanePrefix !== callerPrefix) {
|
|
124904
|
+
return {
|
|
124905
|
+
ok: false,
|
|
124906
|
+
role,
|
|
124907
|
+
error: `Agent "${agent}" does not match caller swarm prefix "${callerPrefix}"`
|
|
124908
|
+
};
|
|
124909
|
+
}
|
|
124910
|
+
}
|
|
124911
|
+
return { ok: true, role };
|
|
124912
|
+
}
|
|
124913
|
+
function getGeneratedAgentPrefix(agent, generatedAgentNames) {
|
|
124914
|
+
const role = resolveGeneratedAgentRole(agent, generatedAgentNames);
|
|
124915
|
+
if (!isKnownCanonicalRole(role))
|
|
124916
|
+
return null;
|
|
124917
|
+
const normalized = agent.toLowerCase();
|
|
124918
|
+
if (normalized === role)
|
|
124919
|
+
return null;
|
|
124920
|
+
for (const separator of AGENT_NAME_SEPARATORS) {
|
|
124921
|
+
const suffix = `${separator}${role}`;
|
|
124922
|
+
if (normalized.endsWith(suffix)) {
|
|
124923
|
+
return normalized.slice(0, -suffix.length);
|
|
124924
|
+
}
|
|
124925
|
+
}
|
|
124926
|
+
return null;
|
|
124927
|
+
}
|
|
124928
|
+
function buildReadOnlyTools() {
|
|
124929
|
+
const tools = {};
|
|
124930
|
+
for (const toolName of READ_ONLY_TOOL_DENYLIST) {
|
|
124931
|
+
tools[toolName] = false;
|
|
124932
|
+
}
|
|
124933
|
+
tools.write = false;
|
|
124934
|
+
tools.edit = false;
|
|
124935
|
+
tools.patch = false;
|
|
124936
|
+
return tools;
|
|
124937
|
+
}
|
|
124938
|
+
function boundLaneOutput(output) {
|
|
124939
|
+
if (output.length <= MAX_LANE_OUTPUT_CHARS) {
|
|
124940
|
+
return {
|
|
124941
|
+
output,
|
|
124942
|
+
output_chars: output.length,
|
|
124943
|
+
output_truncated: false
|
|
124944
|
+
};
|
|
124945
|
+
}
|
|
124946
|
+
const omitted = output.length - MAX_LANE_OUTPUT_CHARS;
|
|
124947
|
+
const suffix = `
|
|
124948
|
+
[... ${omitted} chars truncated by dispatch_lanes ...]`;
|
|
124949
|
+
const maxContent = Math.max(0, MAX_LANE_OUTPUT_CHARS - suffix.length);
|
|
124950
|
+
return {
|
|
124951
|
+
output: `${output.slice(0, maxContent)}${suffix}`,
|
|
124952
|
+
output_chars: output.length,
|
|
124953
|
+
output_truncated: true
|
|
124954
|
+
};
|
|
124955
|
+
}
|
|
124956
|
+
function failureResult(args2) {
|
|
124957
|
+
return {
|
|
124958
|
+
success: false,
|
|
124959
|
+
failure_class: args2.failure_class,
|
|
124960
|
+
message: args2.message,
|
|
124961
|
+
dispatched: 0,
|
|
124962
|
+
completed: 0,
|
|
124963
|
+
failed: 0,
|
|
124964
|
+
rejected: 0,
|
|
124965
|
+
max_concurrent: 0,
|
|
124966
|
+
timeout_ms: 0,
|
|
124967
|
+
lane_results: [],
|
|
124968
|
+
errors: args2.errors
|
|
124969
|
+
};
|
|
124970
|
+
}
|
|
124971
|
+
function findDuplicateLaneIds(lanes) {
|
|
124972
|
+
const seen = new Set;
|
|
124973
|
+
const duplicates = new Set;
|
|
124974
|
+
for (const lane of lanes) {
|
|
124975
|
+
if (seen.has(lane.id))
|
|
124976
|
+
duplicates.add(lane.id);
|
|
124977
|
+
seen.add(lane.id);
|
|
124978
|
+
}
|
|
124979
|
+
return [...duplicates];
|
|
124980
|
+
}
|
|
124981
|
+
function scheduleSessionCleanup(session, sessionId) {
|
|
124982
|
+
session.delete({ path: { id: sessionId } }).catch(() => {
|
|
124983
|
+
return;
|
|
124984
|
+
});
|
|
124985
|
+
}
|
|
124986
|
+
async function withTimeout2(promise3, timeoutMs, message) {
|
|
124987
|
+
let timeout;
|
|
124988
|
+
try {
|
|
124989
|
+
return await Promise.race([
|
|
124990
|
+
promise3,
|
|
124991
|
+
new Promise((_, reject) => {
|
|
124992
|
+
timeout = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
124993
|
+
})
|
|
124994
|
+
]);
|
|
124995
|
+
} finally {
|
|
124996
|
+
if (timeout)
|
|
124997
|
+
clearTimeout(timeout);
|
|
124998
|
+
}
|
|
124999
|
+
}
|
|
125000
|
+
function extractText3(parts2) {
|
|
125001
|
+
if (!Array.isArray(parts2))
|
|
125002
|
+
return "";
|
|
125003
|
+
return parts2.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
|
|
125004
|
+
`);
|
|
125005
|
+
}
|
|
125006
|
+
function formatError3(error93) {
|
|
125007
|
+
if (error93 instanceof Error)
|
|
125008
|
+
return error93.message;
|
|
125009
|
+
const text = typeof error93 === "string" ? error93 : String(error93);
|
|
125010
|
+
return boundErrorString(text);
|
|
125011
|
+
}
|
|
125012
|
+
function boundErrorString(text) {
|
|
125013
|
+
if (text.length <= MAX_ERROR_CHARS)
|
|
125014
|
+
return text;
|
|
125015
|
+
return `${text.slice(0, MAX_ERROR_CHARS)}${ERROR_TRUNCATION_SUFFIX}`;
|
|
125016
|
+
}
|
|
125017
|
+
function isoNow() {
|
|
125018
|
+
return new Date(_internals79.now()).toISOString();
|
|
125019
|
+
}
|
|
125020
|
+
var dispatch_lanes = createSwarmTool({
|
|
125021
|
+
description: "Dispatch multiple read-only exploration/review lanes concurrently through OpenCode sessions and return a structured join result.",
|
|
125022
|
+
args: {
|
|
125023
|
+
lanes: DispatchLanesArgsSchema.shape.lanes,
|
|
125024
|
+
max_concurrent: DispatchLanesArgsSchema.shape.max_concurrent,
|
|
125025
|
+
timeout_ms: DispatchLanesArgsSchema.shape.timeout_ms
|
|
125026
|
+
},
|
|
125027
|
+
execute: async (args2, directory, ctx) => {
|
|
125028
|
+
const result = await executeDispatchLanes(args2, directory, {
|
|
125029
|
+
callerAgent: getContextAgent(ctx)
|
|
125030
|
+
});
|
|
125031
|
+
return JSON.stringify(result, null, 2);
|
|
125032
|
+
}
|
|
125033
|
+
});
|
|
125034
|
+
function getContextAgent(ctx) {
|
|
125035
|
+
if (!ctx || typeof ctx !== "object")
|
|
125036
|
+
return;
|
|
125037
|
+
const value = ctx.agent;
|
|
125038
|
+
return typeof value === "string" ? value : undefined;
|
|
125039
|
+
}
|
|
125040
|
+
|
|
124401
125041
|
// src/tools/manifest.ts
|
|
124402
125042
|
init_doc_scan();
|
|
124403
125043
|
|
|
@@ -124838,7 +125478,7 @@ function candidateFilePath(storePath3, id) {
|
|
|
124838
125478
|
}
|
|
124839
125479
|
return path146.join(storePath3, `${id}.json`);
|
|
124840
125480
|
}
|
|
124841
|
-
var
|
|
125481
|
+
var _internals80 = {
|
|
124842
125482
|
randomUUID: crypto11.randomUUID.bind(crypto11),
|
|
124843
125483
|
fs: {
|
|
124844
125484
|
mkdir: fs93.mkdir,
|
|
@@ -124851,11 +125491,11 @@ var _internals79 = {
|
|
|
124851
125491
|
function createExternalSkillStore(directory, config3) {
|
|
124852
125492
|
const storePath3 = path146.join(directory, ".swarm", "skills", "candidates");
|
|
124853
125493
|
async function add2(candidate) {
|
|
124854
|
-
const id =
|
|
125494
|
+
const id = _internals80.randomUUID();
|
|
124855
125495
|
const full = { ...candidate, id };
|
|
124856
125496
|
const filePath = path146.join(storePath3, `${id}.json`);
|
|
124857
|
-
await
|
|
124858
|
-
await
|
|
125497
|
+
await _internals80.fs.mkdir(storePath3, { recursive: true });
|
|
125498
|
+
await _internals80.atomicWriteFile(filePath, JSON.stringify(full, null, "\t"));
|
|
124859
125499
|
return full;
|
|
124860
125500
|
}
|
|
124861
125501
|
async function get2(id) {
|
|
@@ -124865,7 +125505,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
124865
125505
|
}
|
|
124866
125506
|
let raw;
|
|
124867
125507
|
try {
|
|
124868
|
-
raw = await
|
|
125508
|
+
raw = await _internals80.fs.readFile(filePath, "utf-8");
|
|
124869
125509
|
} catch (err2) {
|
|
124870
125510
|
if (err2.code === "ENOENT") {
|
|
124871
125511
|
return null;
|
|
@@ -124881,7 +125521,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
124881
125521
|
async function list(filter) {
|
|
124882
125522
|
let entries;
|
|
124883
125523
|
try {
|
|
124884
|
-
entries = await
|
|
125524
|
+
entries = await _internals80.fs.readdir(storePath3);
|
|
124885
125525
|
} catch (err2) {
|
|
124886
125526
|
if (err2.code === "ENOENT") {
|
|
124887
125527
|
return [];
|
|
@@ -124896,7 +125536,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
124896
125536
|
const filePath = path146.join(storePath3, entry);
|
|
124897
125537
|
let raw;
|
|
124898
125538
|
try {
|
|
124899
|
-
raw = await
|
|
125539
|
+
raw = await _internals80.fs.readFile(filePath, "utf-8");
|
|
124900
125540
|
} catch {
|
|
124901
125541
|
continue;
|
|
124902
125542
|
}
|
|
@@ -124963,7 +125603,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
124963
125603
|
...patch.evaluation_history
|
|
124964
125604
|
];
|
|
124965
125605
|
}
|
|
124966
|
-
await
|
|
125606
|
+
await _internals80.atomicWriteFile(filePath, JSON.stringify(updated, null, "\t"));
|
|
124967
125607
|
return updated;
|
|
124968
125608
|
}
|
|
124969
125609
|
async function deleteCandidate(id) {
|
|
@@ -124972,7 +125612,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
124972
125612
|
return false;
|
|
124973
125613
|
}
|
|
124974
125614
|
try {
|
|
124975
|
-
await
|
|
125615
|
+
await _internals80.fs.unlink(filePath);
|
|
124976
125616
|
return true;
|
|
124977
125617
|
} catch (err2) {
|
|
124978
125618
|
if (err2.code === "ENOENT") {
|
|
@@ -125010,7 +125650,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
125010
125650
|
|
|
125011
125651
|
// src/tools/external-skill-delete.ts
|
|
125012
125652
|
init_create_tool();
|
|
125013
|
-
var
|
|
125653
|
+
var _internals81 = {
|
|
125014
125654
|
loadConfig: (directory) => {
|
|
125015
125655
|
const pluginConfig = loadPluginConfig(directory);
|
|
125016
125656
|
return pluginConfig.external_skills;
|
|
@@ -125032,7 +125672,7 @@ var external_skill_delete = createSwarmTool({
|
|
|
125032
125672
|
} catch {}
|
|
125033
125673
|
let config3;
|
|
125034
125674
|
try {
|
|
125035
|
-
config3 =
|
|
125675
|
+
config3 = _internals81.loadConfig(directory);
|
|
125036
125676
|
} catch {
|
|
125037
125677
|
return JSON.stringify({
|
|
125038
125678
|
success: false,
|
|
@@ -125500,7 +126140,7 @@ function scanProvenanceIntegrity(candidate, trustLevel = "low", ttlDays) {
|
|
|
125500
126140
|
});
|
|
125501
126141
|
}
|
|
125502
126142
|
fieldsScanned.push("fetched_at");
|
|
125503
|
-
const now = new Date(
|
|
126143
|
+
const now = new Date(_internals82.getTimestamp()).getTime();
|
|
125504
126144
|
const fetchedAtMs = new Date(candidate.fetched_at).getTime();
|
|
125505
126145
|
if (Number.isNaN(fetchedAtMs)) {
|
|
125506
126146
|
findings.push({
|
|
@@ -125564,7 +126204,7 @@ function scanProvenanceIntegrity(candidate, trustLevel = "low", ttlDays) {
|
|
|
125564
126204
|
});
|
|
125565
126205
|
}
|
|
125566
126206
|
fieldsScanned.push("skill_body");
|
|
125567
|
-
const computedHash =
|
|
126207
|
+
const computedHash = _internals82.computeSha256(candidate.skill_body);
|
|
125568
126208
|
if (computedHash !== candidate.sha256) {
|
|
125569
126209
|
findings.push({
|
|
125570
126210
|
pattern: "content_hash_mismatch",
|
|
@@ -125614,7 +126254,7 @@ function evaluateCandidate(candidate, options) {
|
|
|
125614
126254
|
risk_flags: riskFlags
|
|
125615
126255
|
};
|
|
125616
126256
|
}
|
|
125617
|
-
var
|
|
126257
|
+
var _internals82 = {
|
|
125618
126258
|
getTimestamp: () => new Date().toISOString(),
|
|
125619
126259
|
computeSha256: (content) => createHash14("sha256").update(content).digest("hex"),
|
|
125620
126260
|
stripMarkdownCodeForUnsafeScan
|
|
@@ -125622,7 +126262,7 @@ var _internals81 = {
|
|
|
125622
126262
|
|
|
125623
126263
|
// src/tools/external-skill-discover.ts
|
|
125624
126264
|
init_create_tool();
|
|
125625
|
-
var
|
|
126265
|
+
var _internals83 = {
|
|
125626
126266
|
fetchContent: async (_url3, _timeoutMs) => {
|
|
125627
126267
|
const parsed = new URL(_url3);
|
|
125628
126268
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
@@ -125783,7 +126423,7 @@ var external_skill_discover = createSwarmTool({
|
|
|
125783
126423
|
resolvedContent = content;
|
|
125784
126424
|
} else {
|
|
125785
126425
|
try {
|
|
125786
|
-
const fetched = await
|
|
126426
|
+
const fetched = await _internals83.fetchContent(resolvedUrl, config3.fetch_timeout_ms);
|
|
125787
126427
|
if (fetched.finalUrl !== resolvedUrl && matchedSource && !isSubpathUrl(fetched.finalUrl, matchedSource.location)) {
|
|
125788
126428
|
return JSON.stringify({
|
|
125789
126429
|
success: false,
|
|
@@ -125805,14 +126445,14 @@ var external_skill_discover = createSwarmTool({
|
|
|
125805
126445
|
error: `Content too large: ${resolvedContent.length} bytes exceeds max_bytes_per_candidate (${config3.max_bytes_per_candidate})`
|
|
125806
126446
|
});
|
|
125807
126447
|
}
|
|
125808
|
-
const sha256 =
|
|
126448
|
+
const sha256 = _internals83.computeSha256(resolvedContent);
|
|
125809
126449
|
const candidate = {
|
|
125810
|
-
id:
|
|
126450
|
+
id: _internals83.uuid(),
|
|
125811
126451
|
source_url: resolvedUrl,
|
|
125812
126452
|
source_type: sourceType,
|
|
125813
126453
|
publisher,
|
|
125814
126454
|
sha256,
|
|
125815
|
-
fetched_at:
|
|
126455
|
+
fetched_at: _internals83.getTimestamp(),
|
|
125816
126456
|
skill_name: typeof skillName === "string" ? skillName : undefined,
|
|
125817
126457
|
skill_description: typeof skillDescription === "string" ? skillDescription : undefined,
|
|
125818
126458
|
skill_body: resolvedContent,
|
|
@@ -125830,7 +126470,7 @@ var external_skill_discover = createSwarmTool({
|
|
|
125830
126470
|
candidate.evaluation_history = [
|
|
125831
126471
|
{
|
|
125832
126472
|
verdict: result.overall_verdict,
|
|
125833
|
-
timestamp:
|
|
126473
|
+
timestamp: _internals83.getTimestamp(),
|
|
125834
126474
|
actor: "system",
|
|
125835
126475
|
reason: `Validation: ${result.gate_results.length} gates, ${result.all_findings.length} findings`,
|
|
125836
126476
|
gate_results: result.gate_results.map((gr) => ({
|
|
@@ -125875,7 +126515,7 @@ var external_skill_discover = createSwarmTool({
|
|
|
125875
126515
|
init_zod();
|
|
125876
126516
|
init_loader();
|
|
125877
126517
|
init_create_tool();
|
|
125878
|
-
var
|
|
126518
|
+
var _internals84 = {
|
|
125879
126519
|
loadConfig: (directory) => {
|
|
125880
126520
|
const pluginConfig = loadPluginConfig(directory);
|
|
125881
126521
|
return pluginConfig.external_skills;
|
|
@@ -125897,7 +126537,7 @@ var external_skill_inspect = createSwarmTool({
|
|
|
125897
126537
|
} catch {}
|
|
125898
126538
|
let config3;
|
|
125899
126539
|
try {
|
|
125900
|
-
config3 =
|
|
126540
|
+
config3 = _internals84.loadConfig(directory);
|
|
125901
126541
|
} catch {
|
|
125902
126542
|
return JSON.stringify({
|
|
125903
126543
|
success: false,
|
|
@@ -125939,7 +126579,7 @@ var external_skill_inspect = createSwarmTool({
|
|
|
125939
126579
|
init_zod();
|
|
125940
126580
|
init_loader();
|
|
125941
126581
|
init_create_tool();
|
|
125942
|
-
var
|
|
126582
|
+
var _internals85 = {
|
|
125943
126583
|
loadConfig: (directory) => {
|
|
125944
126584
|
const pluginConfig = loadPluginConfig(directory);
|
|
125945
126585
|
return pluginConfig.external_skills;
|
|
@@ -125975,7 +126615,7 @@ var external_skill_list = createSwarmTool({
|
|
|
125975
126615
|
} catch {}
|
|
125976
126616
|
let config3;
|
|
125977
126617
|
try {
|
|
125978
|
-
config3 =
|
|
126618
|
+
config3 = _internals85.loadConfig(directory);
|
|
125979
126619
|
} catch {
|
|
125980
126620
|
return JSON.stringify({
|
|
125981
126621
|
success: false,
|
|
@@ -126028,7 +126668,7 @@ import { createHash as createHash16 } from "node:crypto";
|
|
|
126028
126668
|
import * as fs94 from "node:fs/promises";
|
|
126029
126669
|
import * as path147 from "node:path";
|
|
126030
126670
|
init_create_tool();
|
|
126031
|
-
var
|
|
126671
|
+
var _internals86 = {
|
|
126032
126672
|
loadConfig: (directory) => {
|
|
126033
126673
|
const pluginConfig = loadPluginConfig(directory);
|
|
126034
126674
|
return pluginConfig.external_skills;
|
|
@@ -126098,7 +126738,7 @@ var external_skill_promote = createSwarmTool({
|
|
|
126098
126738
|
} catch {}
|
|
126099
126739
|
let config3;
|
|
126100
126740
|
try {
|
|
126101
|
-
config3 =
|
|
126741
|
+
config3 = _internals86.loadConfig(directory);
|
|
126102
126742
|
} catch {
|
|
126103
126743
|
return JSON.stringify({
|
|
126104
126744
|
success: false,
|
|
@@ -126168,8 +126808,8 @@ var external_skill_promote = createSwarmTool({
|
|
|
126168
126808
|
}
|
|
126169
126809
|
const targetDir = path147.join(directory, ".opencode", "skills", "generated", sanitizedSlug);
|
|
126170
126810
|
const targetPath = path147.join(targetDir, "SKILL.md");
|
|
126171
|
-
const timestamp =
|
|
126172
|
-
const alreadyExists = await
|
|
126811
|
+
const timestamp = _internals86.getTimestamp();
|
|
126812
|
+
const alreadyExists = await _internals86.fileExists(targetPath);
|
|
126173
126813
|
if (alreadyExists) {
|
|
126174
126814
|
return JSON.stringify({
|
|
126175
126815
|
success: false,
|
|
@@ -126178,7 +126818,7 @@ var external_skill_promote = createSwarmTool({
|
|
|
126178
126818
|
}
|
|
126179
126819
|
const skillMarkdown = buildSkillMarkdown(candidate, sanitizedSlug, timestamp);
|
|
126180
126820
|
try {
|
|
126181
|
-
await
|
|
126821
|
+
await _internals86.writeSkillFile(targetPath, skillMarkdown);
|
|
126182
126822
|
} catch (writeErr) {
|
|
126183
126823
|
const writeError = writeErr;
|
|
126184
126824
|
if (writeError?.code === "EEXIST") {
|
|
@@ -126255,7 +126895,7 @@ var external_skill_promote = createSwarmTool({
|
|
|
126255
126895
|
init_zod();
|
|
126256
126896
|
init_loader();
|
|
126257
126897
|
init_create_tool();
|
|
126258
|
-
var
|
|
126898
|
+
var _internals87 = {
|
|
126259
126899
|
loadConfig: (directory) => {
|
|
126260
126900
|
const pluginConfig = loadPluginConfig(directory);
|
|
126261
126901
|
return pluginConfig.external_skills;
|
|
@@ -126280,7 +126920,7 @@ var external_skill_reject = createSwarmTool({
|
|
|
126280
126920
|
} catch {}
|
|
126281
126921
|
let config3;
|
|
126282
126922
|
try {
|
|
126283
|
-
config3 =
|
|
126923
|
+
config3 = _internals87.loadConfig(directory);
|
|
126284
126924
|
} catch {
|
|
126285
126925
|
return JSON.stringify({
|
|
126286
126926
|
success: false,
|
|
@@ -126343,7 +126983,7 @@ init_zod();
|
|
|
126343
126983
|
init_loader();
|
|
126344
126984
|
import * as path148 from "node:path";
|
|
126345
126985
|
init_create_tool();
|
|
126346
|
-
var
|
|
126986
|
+
var _internals88 = {
|
|
126347
126987
|
loadConfig: (directory) => {
|
|
126348
126988
|
const pluginConfig = loadPluginConfig(directory);
|
|
126349
126989
|
return pluginConfig.external_skills;
|
|
@@ -126394,7 +127034,7 @@ var external_skill_revoke = createSwarmTool({
|
|
|
126394
127034
|
} catch {}
|
|
126395
127035
|
let config3;
|
|
126396
127036
|
try {
|
|
126397
|
-
config3 =
|
|
127037
|
+
config3 = _internals88.loadConfig(directory);
|
|
126398
127038
|
} catch {
|
|
126399
127039
|
return JSON.stringify({
|
|
126400
127040
|
success: false,
|
|
@@ -126441,8 +127081,8 @@ var external_skill_revoke = createSwarmTool({
|
|
|
126441
127081
|
});
|
|
126442
127082
|
}
|
|
126443
127083
|
const skillPath = path148.join(directory, ".opencode", "skills", "generated", slug, "SKILL.md");
|
|
126444
|
-
const skillFileRemoved = await
|
|
126445
|
-
const timestamp =
|
|
127084
|
+
const skillFileRemoved = await _internals88.retireSkillFile(skillPath);
|
|
127085
|
+
const timestamp = _internals88.getTimestamp();
|
|
126446
127086
|
const historyEntry = {
|
|
126447
127087
|
verdict: "revoked",
|
|
126448
127088
|
timestamp,
|
|
@@ -130011,7 +130651,7 @@ ${fileList}
|
|
|
130011
130651
|
async _withStateLock(fn2) {
|
|
130012
130652
|
const timeoutMs = 1e4;
|
|
130013
130653
|
let timeoutId;
|
|
130014
|
-
const
|
|
130654
|
+
const withTimeout3 = new Promise((_resolve, reject) => {
|
|
130015
130655
|
timeoutId = setTimeout(() => {
|
|
130016
130656
|
reject(new Error(`_withStateLock timed out after ${timeoutMs}ms — state update will not block subsequent operations`));
|
|
130017
130657
|
}, timeoutMs);
|
|
@@ -130020,7 +130660,7 @@ ${fileList}
|
|
|
130020
130660
|
if (timeoutId)
|
|
130021
130661
|
clearTimeout(timeoutId);
|
|
130022
130662
|
});
|
|
130023
|
-
const promise3 = Promise.race([chain,
|
|
130663
|
+
const promise3 = Promise.race([chain, withTimeout3]).finally(() => {
|
|
130024
130664
|
if (timeoutId)
|
|
130025
130665
|
clearTimeout(timeoutId);
|
|
130026
130666
|
});
|
|
@@ -130100,7 +130740,7 @@ ${fileList}
|
|
|
130100
130740
|
|
|
130101
130741
|
// src/tools/lean-turbo-run-phase.ts
|
|
130102
130742
|
init_create_tool();
|
|
130103
|
-
var
|
|
130743
|
+
var _internals89 = {
|
|
130104
130744
|
LeanTurboRunner,
|
|
130105
130745
|
loadPluginConfigWithMeta
|
|
130106
130746
|
};
|
|
@@ -130110,9 +130750,9 @@ async function executeLeanTurboRunPhase(args2) {
|
|
|
130110
130750
|
let runError = null;
|
|
130111
130751
|
let runner = null;
|
|
130112
130752
|
try {
|
|
130113
|
-
const { config: config3 } =
|
|
130753
|
+
const { config: config3 } = _internals89.loadPluginConfigWithMeta(directory);
|
|
130114
130754
|
const leanConfig = config3.turbo?.strategy === "lean" ? config3.turbo.lean : undefined;
|
|
130115
|
-
runner = new
|
|
130755
|
+
runner = new _internals89.LeanTurboRunner({
|
|
130116
130756
|
directory,
|
|
130117
130757
|
sessionID,
|
|
130118
130758
|
opencodeClient: swarmState.opencodeClient ?? null,
|
|
@@ -130448,7 +131088,7 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
|
130448
131088
|
const strippedMutated = stripCode(mutatedCode);
|
|
130449
131089
|
return strippedOriginal === strippedMutated;
|
|
130450
131090
|
}
|
|
130451
|
-
var
|
|
131091
|
+
var _internals90 = {
|
|
130452
131092
|
isStaticallyEquivalent,
|
|
130453
131093
|
checkEquivalence,
|
|
130454
131094
|
batchCheckEquivalence
|
|
@@ -130488,7 +131128,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
|
|
|
130488
131128
|
const results = [];
|
|
130489
131129
|
for (const { patch, originalCode, mutatedCode } of patches) {
|
|
130490
131130
|
try {
|
|
130491
|
-
const result = await
|
|
131131
|
+
const result = await _internals90.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
|
|
130492
131132
|
results.push(result);
|
|
130493
131133
|
} catch (err2) {
|
|
130494
131134
|
results.push({
|
|
@@ -130548,7 +131188,7 @@ function validateTestCommand(testCommand) {
|
|
|
130548
131188
|
var MUTATION_TIMEOUT_MS = 30000;
|
|
130549
131189
|
var TOTAL_BUDGET_MS = 300000;
|
|
130550
131190
|
var GIT_APPLY_TIMEOUT_MS = 5000;
|
|
130551
|
-
var
|
|
131191
|
+
var _internals91 = {
|
|
130552
131192
|
executeMutation,
|
|
130553
131193
|
computeReport,
|
|
130554
131194
|
executeMutationSuite,
|
|
@@ -130580,7 +131220,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
130580
131220
|
};
|
|
130581
131221
|
}
|
|
130582
131222
|
try {
|
|
130583
|
-
const applyResult =
|
|
131223
|
+
const applyResult = _internals91.spawnSync("git", ["apply", "--", patchFile], {
|
|
130584
131224
|
cwd: workingDir,
|
|
130585
131225
|
timeout: GIT_APPLY_TIMEOUT_MS,
|
|
130586
131226
|
stdio: "pipe"
|
|
@@ -130611,7 +131251,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
130611
131251
|
try {
|
|
130612
131252
|
const safeTestFiles = testFiles.filter((f) => !f.startsWith("-"));
|
|
130613
131253
|
const testArgs = safeTestFiles.length > 0 ? [...testCommand.slice(1), ...safeTestFiles] : testCommand.slice(1);
|
|
130614
|
-
const spawnResult =
|
|
131254
|
+
const spawnResult = _internals91.spawnSync(testCommand[0], testArgs, {
|
|
130615
131255
|
cwd: workingDir,
|
|
130616
131256
|
timeout: MUTATION_TIMEOUT_MS,
|
|
130617
131257
|
stdio: "pipe"
|
|
@@ -130644,7 +131284,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
130644
131284
|
} finally {
|
|
130645
131285
|
if (patchFile) {
|
|
130646
131286
|
try {
|
|
130647
|
-
const revertResult =
|
|
131287
|
+
const revertResult = _internals91.spawnSync("git", ["apply", "-R", "--", patchFile], {
|
|
130648
131288
|
cwd: workingDir,
|
|
130649
131289
|
timeout: GIT_APPLY_TIMEOUT_MS,
|
|
130650
131290
|
stdio: "pipe"
|
|
@@ -130841,7 +131481,7 @@ async function executeMutationSuite(patches, testCommand, testFiles, workingDir,
|
|
|
130841
131481
|
}
|
|
130842
131482
|
|
|
130843
131483
|
// src/mutation/gate.ts
|
|
130844
|
-
var
|
|
131484
|
+
var _internals92 = {
|
|
130845
131485
|
evaluateMutationGate,
|
|
130846
131486
|
buildTestImprovementPrompt,
|
|
130847
131487
|
buildMessage
|
|
@@ -130862,8 +131502,8 @@ function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThresh
|
|
|
130862
131502
|
} else {
|
|
130863
131503
|
verdict = "fail";
|
|
130864
131504
|
}
|
|
130865
|
-
const testImprovementPrompt =
|
|
130866
|
-
const message =
|
|
131505
|
+
const testImprovementPrompt = _internals92.buildTestImprovementPrompt(report, passThreshold, verdict);
|
|
131506
|
+
const message = _internals92.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
|
|
130867
131507
|
return {
|
|
130868
131508
|
verdict,
|
|
130869
131509
|
killRate: report.killRate,
|
|
@@ -131380,7 +132020,7 @@ function listLaneEvidenceSync(directory, phase) {
|
|
|
131380
132020
|
}
|
|
131381
132021
|
return laneIds;
|
|
131382
132022
|
}
|
|
131383
|
-
var
|
|
132023
|
+
var _internals93 = {
|
|
131384
132024
|
listActiveLocks,
|
|
131385
132025
|
readPersisted: readPersisted2,
|
|
131386
132026
|
readPlanJson: defaultReadPlanJson,
|
|
@@ -131441,7 +132081,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
131441
132081
|
reason: "Lean Turbo state unreadable or missing"
|
|
131442
132082
|
};
|
|
131443
132083
|
}
|
|
131444
|
-
const persisted =
|
|
132084
|
+
const persisted = _internals93.readPersisted(directory);
|
|
131445
132085
|
if (!persisted) {
|
|
131446
132086
|
return {
|
|
131447
132087
|
ok: false,
|
|
@@ -131505,7 +132145,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
131505
132145
|
}
|
|
131506
132146
|
}
|
|
131507
132147
|
if (runState.lanes.length > 0) {
|
|
131508
|
-
const evidenceLaneIds = new Set(
|
|
132148
|
+
const evidenceLaneIds = new Set(_internals93.listLaneEvidenceSync(directory, phase));
|
|
131509
132149
|
for (const lane of runState.lanes) {
|
|
131510
132150
|
if ((lane.status === "completed" || lane.status === "failed") && !evidenceLaneIds.has(lane.laneId)) {
|
|
131511
132151
|
return {
|
|
@@ -131515,7 +132155,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
131515
132155
|
}
|
|
131516
132156
|
}
|
|
131517
132157
|
}
|
|
131518
|
-
const activeLocks =
|
|
132158
|
+
const activeLocks = _internals93.listActiveLocks(directory);
|
|
131519
132159
|
const phaseLaneIds = new Set(laneIds);
|
|
131520
132160
|
for (const lock of activeLocks) {
|
|
131521
132161
|
if (lock.laneId && phaseLaneIds.has(lock.laneId)) {
|
|
@@ -131535,7 +132175,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
131535
132175
|
}
|
|
131536
132176
|
const serialDegradedTasks = runState.degradedTasks.filter((dt) => !laneTaskIds.has(dt.taskId));
|
|
131537
132177
|
if (serialDegradedTasks.length > 0) {
|
|
131538
|
-
const plan =
|
|
132178
|
+
const plan = _internals93.readPlanJson(directory);
|
|
131539
132179
|
if (!plan) {
|
|
131540
132180
|
return {
|
|
131541
132181
|
ok: false,
|
|
@@ -131579,7 +132219,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
131579
132219
|
}
|
|
131580
132220
|
const serializedTasks = runState.serializedTasks;
|
|
131581
132221
|
if (Array.isArray(serializedTasks) && serializedTasks.length > 0) {
|
|
131582
|
-
const plan =
|
|
132222
|
+
const plan = _internals93.readPlanJson(directory);
|
|
131583
132223
|
if (!plan) {
|
|
131584
132224
|
return {
|
|
131585
132225
|
ok: false,
|
|
@@ -131638,7 +132278,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
131638
132278
|
}
|
|
131639
132279
|
let reviewerVerdict = runState.lastReviewerVerdict;
|
|
131640
132280
|
if (!reviewerVerdict) {
|
|
131641
|
-
const evidence =
|
|
132281
|
+
const evidence = _internals93.readReviewerEvidence(directory, phase);
|
|
131642
132282
|
reviewerVerdict = evidence?.verdict ?? undefined;
|
|
131643
132283
|
}
|
|
131644
132284
|
if (mergedConfig.phase_reviewer) {
|
|
@@ -131651,7 +132291,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
131651
132291
|
}
|
|
131652
132292
|
let criticVerdict = runState.lastCriticVerdict;
|
|
131653
132293
|
if (!criticVerdict) {
|
|
131654
|
-
const evidence =
|
|
132294
|
+
const evidence = _internals93.readCriticEvidence(directory, phase);
|
|
131655
132295
|
criticVerdict = evidence?.verdict ?? undefined;
|
|
131656
132296
|
}
|
|
131657
132297
|
if (mergedConfig.phase_critic) {
|
|
@@ -132808,7 +133448,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
132808
133448
|
phase_critic: leanConfig.phase_critic,
|
|
132809
133449
|
integrated_diff_required: leanConfig.integrated_diff_required
|
|
132810
133450
|
} : undefined;
|
|
132811
|
-
const leanCheck =
|
|
133451
|
+
const leanCheck = _internals93.verifyLeanTurboPhaseReady(dir, phase, sessionID, leanPhaseReadyConfig);
|
|
132812
133452
|
if (!leanCheck.ok) {
|
|
132813
133453
|
return JSON.stringify({
|
|
132814
133454
|
success: false,
|
|
@@ -135033,164 +135673,6 @@ var placeholder_scan = createSwarmTool({
|
|
|
135033
135673
|
// src/tools/pre-check-batch.ts
|
|
135034
135674
|
import * as fs116 from "node:fs";
|
|
135035
135675
|
import * as path171 from "node:path";
|
|
135036
|
-
|
|
135037
|
-
// node_modules/yocto-queue/index.js
|
|
135038
|
-
class Node2 {
|
|
135039
|
-
value;
|
|
135040
|
-
next;
|
|
135041
|
-
constructor(value) {
|
|
135042
|
-
this.value = value;
|
|
135043
|
-
}
|
|
135044
|
-
}
|
|
135045
|
-
|
|
135046
|
-
class Queue {
|
|
135047
|
-
#head;
|
|
135048
|
-
#tail;
|
|
135049
|
-
#size;
|
|
135050
|
-
constructor() {
|
|
135051
|
-
this.clear();
|
|
135052
|
-
}
|
|
135053
|
-
enqueue(value) {
|
|
135054
|
-
const node = new Node2(value);
|
|
135055
|
-
if (this.#head) {
|
|
135056
|
-
this.#tail.next = node;
|
|
135057
|
-
this.#tail = node;
|
|
135058
|
-
} else {
|
|
135059
|
-
this.#head = node;
|
|
135060
|
-
this.#tail = node;
|
|
135061
|
-
}
|
|
135062
|
-
this.#size++;
|
|
135063
|
-
}
|
|
135064
|
-
dequeue() {
|
|
135065
|
-
const current = this.#head;
|
|
135066
|
-
if (!current) {
|
|
135067
|
-
return;
|
|
135068
|
-
}
|
|
135069
|
-
this.#head = this.#head.next;
|
|
135070
|
-
this.#size--;
|
|
135071
|
-
if (!this.#head) {
|
|
135072
|
-
this.#tail = undefined;
|
|
135073
|
-
}
|
|
135074
|
-
return current.value;
|
|
135075
|
-
}
|
|
135076
|
-
peek() {
|
|
135077
|
-
if (!this.#head) {
|
|
135078
|
-
return;
|
|
135079
|
-
}
|
|
135080
|
-
return this.#head.value;
|
|
135081
|
-
}
|
|
135082
|
-
clear() {
|
|
135083
|
-
this.#head = undefined;
|
|
135084
|
-
this.#tail = undefined;
|
|
135085
|
-
this.#size = 0;
|
|
135086
|
-
}
|
|
135087
|
-
get size() {
|
|
135088
|
-
return this.#size;
|
|
135089
|
-
}
|
|
135090
|
-
*[Symbol.iterator]() {
|
|
135091
|
-
let current = this.#head;
|
|
135092
|
-
while (current) {
|
|
135093
|
-
yield current.value;
|
|
135094
|
-
current = current.next;
|
|
135095
|
-
}
|
|
135096
|
-
}
|
|
135097
|
-
*drain() {
|
|
135098
|
-
while (this.#head) {
|
|
135099
|
-
yield this.dequeue();
|
|
135100
|
-
}
|
|
135101
|
-
}
|
|
135102
|
-
}
|
|
135103
|
-
|
|
135104
|
-
// node_modules/p-limit/index.js
|
|
135105
|
-
function pLimit(concurrency) {
|
|
135106
|
-
let rejectOnClear = false;
|
|
135107
|
-
if (typeof concurrency === "object") {
|
|
135108
|
-
({ concurrency, rejectOnClear = false } = concurrency);
|
|
135109
|
-
}
|
|
135110
|
-
validateConcurrency(concurrency);
|
|
135111
|
-
if (typeof rejectOnClear !== "boolean") {
|
|
135112
|
-
throw new TypeError("Expected `rejectOnClear` to be a boolean");
|
|
135113
|
-
}
|
|
135114
|
-
const queue = new Queue;
|
|
135115
|
-
let activeCount = 0;
|
|
135116
|
-
const resumeNext = () => {
|
|
135117
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
135118
|
-
activeCount++;
|
|
135119
|
-
queue.dequeue().run();
|
|
135120
|
-
}
|
|
135121
|
-
};
|
|
135122
|
-
const next = () => {
|
|
135123
|
-
activeCount--;
|
|
135124
|
-
resumeNext();
|
|
135125
|
-
};
|
|
135126
|
-
const run2 = async (function_, resolve61, arguments_2) => {
|
|
135127
|
-
const result = (async () => function_(...arguments_2))();
|
|
135128
|
-
resolve61(result);
|
|
135129
|
-
try {
|
|
135130
|
-
await result;
|
|
135131
|
-
} catch {}
|
|
135132
|
-
next();
|
|
135133
|
-
};
|
|
135134
|
-
const enqueue = (function_, resolve61, reject, arguments_2) => {
|
|
135135
|
-
const queueItem = { reject };
|
|
135136
|
-
new Promise((internalResolve) => {
|
|
135137
|
-
queueItem.run = internalResolve;
|
|
135138
|
-
queue.enqueue(queueItem);
|
|
135139
|
-
}).then(run2.bind(undefined, function_, resolve61, arguments_2));
|
|
135140
|
-
if (activeCount < concurrency) {
|
|
135141
|
-
resumeNext();
|
|
135142
|
-
}
|
|
135143
|
-
};
|
|
135144
|
-
const generator = (function_, ...arguments_2) => new Promise((resolve61, reject) => {
|
|
135145
|
-
enqueue(function_, resolve61, reject, arguments_2);
|
|
135146
|
-
});
|
|
135147
|
-
Object.defineProperties(generator, {
|
|
135148
|
-
activeCount: {
|
|
135149
|
-
get: () => activeCount
|
|
135150
|
-
},
|
|
135151
|
-
pendingCount: {
|
|
135152
|
-
get: () => queue.size
|
|
135153
|
-
},
|
|
135154
|
-
clearQueue: {
|
|
135155
|
-
value() {
|
|
135156
|
-
if (!rejectOnClear) {
|
|
135157
|
-
queue.clear();
|
|
135158
|
-
return;
|
|
135159
|
-
}
|
|
135160
|
-
const abortError = AbortSignal.abort().reason;
|
|
135161
|
-
while (queue.size > 0) {
|
|
135162
|
-
queue.dequeue().reject(abortError);
|
|
135163
|
-
}
|
|
135164
|
-
}
|
|
135165
|
-
},
|
|
135166
|
-
concurrency: {
|
|
135167
|
-
get: () => concurrency,
|
|
135168
|
-
set(newConcurrency) {
|
|
135169
|
-
validateConcurrency(newConcurrency);
|
|
135170
|
-
concurrency = newConcurrency;
|
|
135171
|
-
queueMicrotask(() => {
|
|
135172
|
-
while (activeCount < concurrency && queue.size > 0) {
|
|
135173
|
-
resumeNext();
|
|
135174
|
-
}
|
|
135175
|
-
});
|
|
135176
|
-
}
|
|
135177
|
-
},
|
|
135178
|
-
map: {
|
|
135179
|
-
async value(iterable, function_) {
|
|
135180
|
-
const promises11 = Array.from(iterable, (value, index) => this(function_, value, index));
|
|
135181
|
-
return Promise.all(promises11);
|
|
135182
|
-
}
|
|
135183
|
-
}
|
|
135184
|
-
});
|
|
135185
|
-
return generator;
|
|
135186
|
-
}
|
|
135187
|
-
function validateConcurrency(concurrency) {
|
|
135188
|
-
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
135189
|
-
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
135190
|
-
}
|
|
135191
|
-
}
|
|
135192
|
-
|
|
135193
|
-
// src/tools/pre-check-batch.ts
|
|
135194
135676
|
init_zod();
|
|
135195
135677
|
init_manager2();
|
|
135196
135678
|
init_utils();
|
|
@@ -135318,11 +135800,11 @@ var quality_budget = createSwarmTool({
|
|
|
135318
135800
|
}).optional().describe("Quality budget thresholds")
|
|
135319
135801
|
},
|
|
135320
135802
|
async execute(args2, directory) {
|
|
135321
|
-
const result = await
|
|
135803
|
+
const result = await _internals95.qualityBudget(args2, directory);
|
|
135322
135804
|
return JSON.stringify(result);
|
|
135323
135805
|
}
|
|
135324
135806
|
});
|
|
135325
|
-
var
|
|
135807
|
+
var _internals95 = {
|
|
135326
135808
|
qualityBudget
|
|
135327
135809
|
};
|
|
135328
135810
|
|
|
@@ -136044,10 +136526,10 @@ import * as fs113 from "node:fs";
|
|
|
136044
136526
|
import * as path168 from "node:path";
|
|
136045
136527
|
var semgrepAvailableCache = null;
|
|
136046
136528
|
var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
136047
|
-
var
|
|
136529
|
+
var DEFAULT_TIMEOUT_MS4 = 30000;
|
|
136048
136530
|
var MAX_OUTPUT_BYTES8 = 10 * 1024 * 1024;
|
|
136049
136531
|
var KILL_GRACE_MS = 2000;
|
|
136050
|
-
var
|
|
136532
|
+
var _internals96 = {
|
|
136051
136533
|
isSemgrepAvailable,
|
|
136052
136534
|
checkSemgrepAvailable,
|
|
136053
136535
|
resetSemgrepCache,
|
|
@@ -136073,7 +136555,7 @@ function isSemgrepAvailable() {
|
|
|
136073
136555
|
}
|
|
136074
136556
|
}
|
|
136075
136557
|
async function checkSemgrepAvailable() {
|
|
136076
|
-
return
|
|
136558
|
+
return _internals96.isSemgrepAvailable();
|
|
136077
136559
|
}
|
|
136078
136560
|
function resetSemgrepCache() {
|
|
136079
136561
|
semgrepAvailableCache = null;
|
|
@@ -136227,15 +136709,15 @@ async function executeWithTimeout(command, args2, options) {
|
|
|
136227
136709
|
async function runSemgrep(options) {
|
|
136228
136710
|
const files = options.files || [];
|
|
136229
136711
|
const rulesDir = options.rulesDir || DEFAULT_RULES_DIR;
|
|
136230
|
-
const timeoutMs = options.timeoutMs ||
|
|
136712
|
+
const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS4;
|
|
136231
136713
|
if (files.length === 0) {
|
|
136232
136714
|
return {
|
|
136233
|
-
available:
|
|
136715
|
+
available: _internals96.isSemgrepAvailable(),
|
|
136234
136716
|
findings: [],
|
|
136235
136717
|
engine: "tier_a"
|
|
136236
136718
|
};
|
|
136237
136719
|
}
|
|
136238
|
-
if (!
|
|
136720
|
+
if (!_internals96.isSemgrepAvailable()) {
|
|
136239
136721
|
return {
|
|
136240
136722
|
available: false,
|
|
136241
136723
|
findings: [],
|
|
@@ -136402,7 +136884,7 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
136402
136884
|
}
|
|
136403
136885
|
const occIdx = countMap.get(baseKey) ?? 0;
|
|
136404
136886
|
countMap.set(baseKey, occIdx + 1);
|
|
136405
|
-
const fp =
|
|
136887
|
+
const fp = _internals97.fingerprintFinding(finding, directory, occIdx);
|
|
136406
136888
|
return {
|
|
136407
136889
|
finding,
|
|
136408
136890
|
index: occIdx,
|
|
@@ -136471,7 +136953,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
136471
136953
|
}
|
|
136472
136954
|
} catch {}
|
|
136473
136955
|
const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
|
|
136474
|
-
const indexed =
|
|
136956
|
+
const indexed = _internals97.assignOccurrenceIndices(findings, directory);
|
|
136475
136957
|
if (existing && !opts?.force) {
|
|
136476
136958
|
const prunedFingerprints = existing.fingerprints.filter((fp) => {
|
|
136477
136959
|
const relFile = fp.slice(0, fp.indexOf("|"));
|
|
@@ -136611,7 +137093,7 @@ function loadBaseline(directory, phase) {
|
|
|
136611
137093
|
};
|
|
136612
137094
|
}
|
|
136613
137095
|
}
|
|
136614
|
-
var
|
|
137096
|
+
var _internals97 = {
|
|
136615
137097
|
fingerprintFinding,
|
|
136616
137098
|
assignOccurrenceIndices,
|
|
136617
137099
|
captureOrMergeBaseline,
|
|
@@ -137021,11 +137503,11 @@ var sast_scan = createSwarmTool({
|
|
|
137021
137503
|
capture_baseline: safeArgs.capture_baseline,
|
|
137022
137504
|
phase: safeArgs.phase
|
|
137023
137505
|
};
|
|
137024
|
-
const result = await
|
|
137506
|
+
const result = await _internals98.sastScan(input, directory);
|
|
137025
137507
|
return JSON.stringify(result, null, 2);
|
|
137026
137508
|
}
|
|
137027
137509
|
});
|
|
137028
|
-
var
|
|
137510
|
+
var _internals98 = {
|
|
137029
137511
|
sastScan,
|
|
137030
137512
|
sast_scan
|
|
137031
137513
|
};
|
|
@@ -141899,7 +142381,7 @@ init_schema3();
|
|
|
141899
142381
|
init_store();
|
|
141900
142382
|
init_create_tool();
|
|
141901
142383
|
init_resolve_working_directory();
|
|
141902
|
-
function
|
|
142384
|
+
function getContextAgent2(ctx) {
|
|
141903
142385
|
if (!ctx || typeof ctx !== "object")
|
|
141904
142386
|
return;
|
|
141905
142387
|
const value = ctx.agent;
|
|
@@ -141954,7 +142436,7 @@ var summarize_work = createSwarmTool({
|
|
|
141954
142436
|
}
|
|
141955
142437
|
const workingDir = dirResult.directory;
|
|
141956
142438
|
const sessionId = ctx?.sessionID ?? "unknown-session";
|
|
141957
|
-
const agent =
|
|
142439
|
+
const agent = getContextAgent2(ctx) ?? "unknown-agent";
|
|
141958
142440
|
let maxWords = MAX_AGENT_SUMMARY_WORDS;
|
|
141959
142441
|
try {
|
|
141960
142442
|
const config3 = loadPluginConfig(workingDir);
|
|
@@ -142060,7 +142542,7 @@ var swarm_memory_propose = createSwarmTool({
|
|
|
142060
142542
|
evidenceRefs: exports_external.array(exports_external.string().min(1).max(500)).max(20).optional().describe("Evidence refs such as files, commits, test outputs, or URLs")
|
|
142061
142543
|
},
|
|
142062
142544
|
execute: async (args2, directory, ctx) => {
|
|
142063
|
-
const { config: config3 } =
|
|
142545
|
+
const { config: config3 } = _internals99.loadPluginConfigWithMeta(directory);
|
|
142064
142546
|
if (config3.memory?.enabled !== true) {
|
|
142065
142547
|
return JSON.stringify({
|
|
142066
142548
|
success: false,
|
|
@@ -142075,8 +142557,8 @@ var swarm_memory_propose = createSwarmTool({
|
|
|
142075
142557
|
error: parsed.error.issues.map((issue3) => issue3.message).join("; ")
|
|
142076
142558
|
});
|
|
142077
142559
|
}
|
|
142078
|
-
const agent =
|
|
142079
|
-
const gateway =
|
|
142560
|
+
const agent = getContextAgent3(ctx);
|
|
142561
|
+
const gateway = _internals99.createMemoryGateway({
|
|
142080
142562
|
directory,
|
|
142081
142563
|
sessionID: ctx?.sessionID,
|
|
142082
142564
|
agentRole: agent,
|
|
@@ -142101,11 +142583,11 @@ var swarm_memory_propose = createSwarmTool({
|
|
|
142101
142583
|
}
|
|
142102
142584
|
}
|
|
142103
142585
|
});
|
|
142104
|
-
var
|
|
142586
|
+
var _internals99 = {
|
|
142105
142587
|
loadPluginConfigWithMeta,
|
|
142106
142588
|
createMemoryGateway
|
|
142107
142589
|
};
|
|
142108
|
-
function
|
|
142590
|
+
function getContextAgent3(ctx) {
|
|
142109
142591
|
if (!ctx || typeof ctx !== "object")
|
|
142110
142592
|
return;
|
|
142111
142593
|
const value = ctx.agent;
|
|
@@ -142139,7 +142621,7 @@ var swarm_memory_recall = createSwarmTool({
|
|
|
142139
142621
|
maxItems: exports_external.number().int().min(1).max(20).optional().describe("Maximum memories to return")
|
|
142140
142622
|
},
|
|
142141
142623
|
execute: async (args2, directory, ctx) => {
|
|
142142
|
-
const { config: config3 } =
|
|
142624
|
+
const { config: config3 } = _internals100.loadPluginConfigWithMeta(directory);
|
|
142143
142625
|
if (config3.memory?.enabled !== true) {
|
|
142144
142626
|
return JSON.stringify({
|
|
142145
142627
|
success: false,
|
|
@@ -142154,8 +142636,8 @@ var swarm_memory_recall = createSwarmTool({
|
|
|
142154
142636
|
error: parsed.error.issues.map((issue3) => issue3.message).join("; ")
|
|
142155
142637
|
});
|
|
142156
142638
|
}
|
|
142157
|
-
const agent =
|
|
142158
|
-
const gateway =
|
|
142639
|
+
const agent = getContextAgent4(ctx);
|
|
142640
|
+
const gateway = _internals100.createMemoryGateway({
|
|
142159
142641
|
directory,
|
|
142160
142642
|
sessionID: ctx?.sessionID,
|
|
142161
142643
|
agentRole: agent,
|
|
@@ -142188,11 +142670,11 @@ var RecallArgsSchema = exports_external.object({
|
|
|
142188
142670
|
kinds: exports_external.array(exports_external.enum(MEMORY_KINDS2)).optional(),
|
|
142189
142671
|
maxItems: exports_external.number().int().min(1).max(20).optional()
|
|
142190
142672
|
});
|
|
142191
|
-
var
|
|
142673
|
+
var _internals100 = {
|
|
142192
142674
|
loadPluginConfigWithMeta,
|
|
142193
142675
|
createMemoryGateway
|
|
142194
142676
|
};
|
|
142195
|
-
function
|
|
142677
|
+
function getContextAgent4(ctx) {
|
|
142196
142678
|
if (!ctx || typeof ctx !== "object")
|
|
142197
142679
|
return;
|
|
142198
142680
|
const value = ctx.agent;
|
|
@@ -142714,7 +143196,7 @@ import * as path184 from "node:path";
|
|
|
142714
143196
|
init_bun_compat();
|
|
142715
143197
|
import * as fs125 from "node:fs";
|
|
142716
143198
|
import * as path183 from "node:path";
|
|
142717
|
-
var
|
|
143199
|
+
var _internals101 = { bunSpawn };
|
|
142718
143200
|
var _swarmGitExcludedChecked = false;
|
|
142719
143201
|
function fileCoversSwarm(content) {
|
|
142720
143202
|
for (const rawLine of content.split(`
|
|
@@ -142747,7 +143229,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
142747
143229
|
checkIgnoreExitCode
|
|
142748
143230
|
] = await Promise.all([
|
|
142749
143231
|
(async () => {
|
|
142750
|
-
const proc =
|
|
143232
|
+
const proc = _internals101.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
|
|
142751
143233
|
try {
|
|
142752
143234
|
return await Promise.all([proc.exited, proc.stdout.text()]);
|
|
142753
143235
|
} finally {
|
|
@@ -142757,7 +143239,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
142757
143239
|
}
|
|
142758
143240
|
})(),
|
|
142759
143241
|
(async () => {
|
|
142760
|
-
const proc =
|
|
143242
|
+
const proc = _internals101.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
|
|
142761
143243
|
try {
|
|
142762
143244
|
return await Promise.all([proc.exited, proc.stdout.text()]);
|
|
142763
143245
|
} finally {
|
|
@@ -142767,7 +143249,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
142767
143249
|
}
|
|
142768
143250
|
})(),
|
|
142769
143251
|
(async () => {
|
|
142770
|
-
const proc =
|
|
143252
|
+
const proc = _internals101.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
|
|
142771
143253
|
try {
|
|
142772
143254
|
return await proc.exited;
|
|
142773
143255
|
} finally {
|
|
@@ -142806,7 +143288,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
142806
143288
|
}
|
|
142807
143289
|
} catch {}
|
|
142808
143290
|
}
|
|
142809
|
-
const trackedProc =
|
|
143291
|
+
const trackedProc = _internals101.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
|
|
142810
143292
|
let trackedExitCode;
|
|
142811
143293
|
let trackedOutput;
|
|
142812
143294
|
try {
|
|
@@ -142831,7 +143313,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
142831
143313
|
}
|
|
142832
143314
|
|
|
142833
143315
|
// src/hooks/diff-scope.ts
|
|
142834
|
-
var
|
|
143316
|
+
var _internals102 = { bunSpawn };
|
|
142835
143317
|
function getDeclaredScope(taskId, directory) {
|
|
142836
143318
|
try {
|
|
142837
143319
|
const planPath = path184.join(directory, ".swarm", "plan.json");
|
|
@@ -142866,7 +143348,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
|
|
|
142866
143348
|
};
|
|
142867
143349
|
async function getChangedFiles2(directory) {
|
|
142868
143350
|
try {
|
|
142869
|
-
const proc =
|
|
143351
|
+
const proc = _internals102.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
|
|
142870
143352
|
cwd: directory,
|
|
142871
143353
|
...GIT_DIFF_SPAWN_OPTIONS
|
|
142872
143354
|
});
|
|
@@ -142883,7 +143365,7 @@ async function getChangedFiles2(directory) {
|
|
|
142883
143365
|
return stdout.trim().split(`
|
|
142884
143366
|
`).map((f) => f.trim()).filter((f) => f.length > 0);
|
|
142885
143367
|
}
|
|
142886
|
-
const proc2 =
|
|
143368
|
+
const proc2 = _internals102.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
|
|
142887
143369
|
cwd: directory,
|
|
142888
143370
|
...GIT_DIFF_SPAWN_OPTIONS
|
|
142889
143371
|
});
|
|
@@ -142941,7 +143423,7 @@ init_telemetry();
|
|
|
142941
143423
|
init_file_locks();
|
|
142942
143424
|
import * as fs127 from "node:fs";
|
|
142943
143425
|
import * as path185 from "node:path";
|
|
142944
|
-
var
|
|
143426
|
+
var _internals103 = {
|
|
142945
143427
|
listActiveLocks,
|
|
142946
143428
|
verifyLeanTurboTaskCompletion
|
|
142947
143429
|
};
|
|
@@ -143083,7 +143565,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
143083
143565
|
}
|
|
143084
143566
|
};
|
|
143085
143567
|
}
|
|
143086
|
-
const activeLocks =
|
|
143568
|
+
const activeLocks = _internals103.listActiveLocks(directory);
|
|
143087
143569
|
const laneLocks = activeLocks.filter((lock) => lock.laneId === lane.laneId);
|
|
143088
143570
|
if (laneLocks.length > 0) {
|
|
143089
143571
|
return {
|
|
@@ -143150,7 +143632,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
143150
143632
|
init_task_id();
|
|
143151
143633
|
init_create_tool();
|
|
143152
143634
|
init_resolve_working_directory();
|
|
143153
|
-
var
|
|
143635
|
+
var _internals104 = {
|
|
143154
143636
|
tryAcquireLock,
|
|
143155
143637
|
updateTaskStatus,
|
|
143156
143638
|
resolveWorkingDirectory
|
|
@@ -143247,7 +143729,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
143247
143729
|
}
|
|
143248
143730
|
let resolvedDir;
|
|
143249
143731
|
if (fallbackDir) {
|
|
143250
|
-
const resolveResult =
|
|
143732
|
+
const resolveResult = _internals104.resolveWorkingDirectory(workingDirectory, fallbackDir);
|
|
143251
143733
|
if (resolveResult.success) {
|
|
143252
143734
|
resolvedDir = resolveResult.directory;
|
|
143253
143735
|
} else {
|
|
@@ -143594,7 +144076,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
143594
144076
|
}
|
|
143595
144077
|
}
|
|
143596
144078
|
let directory;
|
|
143597
|
-
const resolveResult =
|
|
144079
|
+
const resolveResult = _internals104.resolveWorkingDirectory(args2.working_directory, fallbackDir);
|
|
143598
144080
|
if (!resolveResult.success) {
|
|
143599
144081
|
return {
|
|
143600
144082
|
success: false,
|
|
@@ -143687,7 +144169,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
143687
144169
|
}
|
|
143688
144170
|
let lockResult;
|
|
143689
144171
|
try {
|
|
143690
|
-
lockResult = await
|
|
144172
|
+
lockResult = await _internals104.tryAcquireLock(directory, planFilePath, agentName, lockTaskId);
|
|
143691
144173
|
} catch (error93) {
|
|
143692
144174
|
return {
|
|
143693
144175
|
success: false,
|
|
@@ -143706,7 +144188,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
143706
144188
|
};
|
|
143707
144189
|
}
|
|
143708
144190
|
try {
|
|
143709
|
-
const updatedPlan = await
|
|
144191
|
+
const updatedPlan = await _internals104.updateTaskStatus(directory, args2.task_id, args2.status);
|
|
143710
144192
|
if (args2.status === "completed") {
|
|
143711
144193
|
for (const [_sessionId, session] of swarmState.agentSessions) {
|
|
143712
144194
|
if (!(session.taskWorkflowStates instanceof Map)) {
|
|
@@ -143847,14 +144329,14 @@ init_create_tool();
|
|
|
143847
144329
|
init_resolve_working_directory();
|
|
143848
144330
|
var DEFAULT_MAX_BYTES = 1e6;
|
|
143849
144331
|
var MAX_BYTES_HARD_CAP = 5000000;
|
|
143850
|
-
var
|
|
143851
|
-
var
|
|
144332
|
+
var DEFAULT_TIMEOUT_MS5 = 15000;
|
|
144333
|
+
var MAX_TIMEOUT_MS3 = 30000;
|
|
143852
144334
|
var MAX_REDIRECTS = 5;
|
|
143853
144335
|
var MAX_TEXT_LENGTH2 = 50000;
|
|
143854
144336
|
var ArgsSchema6 = exports_external.object({
|
|
143855
144337
|
url: exports_external.string().min(1).max(2048),
|
|
143856
144338
|
max_bytes: exports_external.number().int().min(1024).max(MAX_BYTES_HARD_CAP).optional(),
|
|
143857
|
-
timeout_ms: exports_external.number().int().min(1000).max(
|
|
144339
|
+
timeout_ms: exports_external.number().int().min(1000).max(MAX_TIMEOUT_MS3).optional(),
|
|
143858
144340
|
working_directory: exports_external.string().optional()
|
|
143859
144341
|
});
|
|
143860
144342
|
function isBlockedAddress(address) {
|
|
@@ -144339,7 +144821,7 @@ var web_fetch = createSwarmTool({
|
|
|
144339
144821
|
args: {
|
|
144340
144822
|
url: exports_external.string().min(1).max(2048).describe("Absolute http(s) URL to fetch (1–2048 chars)."),
|
|
144341
144823
|
max_bytes: exports_external.number().int().min(1024).max(MAX_BYTES_HARD_CAP).optional().describe(`Max decoded response bytes to read (1024..${MAX_BYTES_HARD_CAP}, default ${DEFAULT_MAX_BYTES}).`),
|
|
144342
|
-
timeout_ms: exports_external.number().int().min(1000).max(
|
|
144824
|
+
timeout_ms: exports_external.number().int().min(1000).max(MAX_TIMEOUT_MS3).optional().describe(`Request timeout in ms (1000..${MAX_TIMEOUT_MS3}, default ${DEFAULT_TIMEOUT_MS5}).`),
|
|
144343
144825
|
working_directory: exports_external.string().optional().describe("Project root for config resolution and evidence storage. Optional.")
|
|
144344
144826
|
},
|
|
144345
144827
|
execute: async (args2, directory) => {
|
|
@@ -144361,7 +144843,7 @@ var web_fetch = createSwarmTool({
|
|
|
144361
144843
|
};
|
|
144362
144844
|
return JSON.stringify(fail, null, 2);
|
|
144363
144845
|
}
|
|
144364
|
-
const config3 =
|
|
144846
|
+
const config3 = _internals105.loadPluginConfig(dirResult.directory);
|
|
144365
144847
|
const generalConfig = config3.council?.general;
|
|
144366
144848
|
if (!generalConfig || generalConfig.enabled !== true) {
|
|
144367
144849
|
const fail = {
|
|
@@ -144371,7 +144853,7 @@ var web_fetch = createSwarmTool({
|
|
|
144371
144853
|
};
|
|
144372
144854
|
return JSON.stringify(fail, null, 2);
|
|
144373
144855
|
}
|
|
144374
|
-
const validated = await validateFetchUrl(parsed.data.url,
|
|
144856
|
+
const validated = await validateFetchUrl(parsed.data.url, _internals105.dnsLookup);
|
|
144375
144857
|
if (!validated.ok) {
|
|
144376
144858
|
const fail = {
|
|
144377
144859
|
success: false,
|
|
@@ -144381,8 +144863,8 @@ var web_fetch = createSwarmTool({
|
|
|
144381
144863
|
return JSON.stringify(fail, null, 2);
|
|
144382
144864
|
}
|
|
144383
144865
|
const maxBytes = parsed.data.max_bytes ?? DEFAULT_MAX_BYTES;
|
|
144384
|
-
const timeoutMs = parsed.data.timeout_ms ??
|
|
144385
|
-
const result = await boundedFetch({ url: validated.url, address: validated.address }, maxBytes, timeoutMs,
|
|
144866
|
+
const timeoutMs = parsed.data.timeout_ms ?? DEFAULT_TIMEOUT_MS5;
|
|
144867
|
+
const result = await boundedFetch({ url: validated.url, address: validated.address }, maxBytes, timeoutMs, _internals105);
|
|
144386
144868
|
if (!result.ok) {
|
|
144387
144869
|
const fail = {
|
|
144388
144870
|
success: false,
|
|
@@ -144417,7 +144899,7 @@ var web_fetch = createSwarmTool({
|
|
|
144417
144899
|
});
|
|
144418
144900
|
async function captureFetchEvidence(directory, url3, title, text) {
|
|
144419
144901
|
try {
|
|
144420
|
-
const written = await
|
|
144902
|
+
const written = await _internals105.writeEvidenceDocuments(directory, [
|
|
144421
144903
|
{
|
|
144422
144904
|
sourceType: "crawl",
|
|
144423
144905
|
url: url3,
|
|
@@ -144438,7 +144920,7 @@ async function captureFetchEvidence(directory, url3, title, text) {
|
|
|
144438
144920
|
};
|
|
144439
144921
|
}
|
|
144440
144922
|
}
|
|
144441
|
-
var
|
|
144923
|
+
var _internals105 = {
|
|
144442
144924
|
httpRequest: performHttpRequest,
|
|
144443
144925
|
dnsLookup: lookup,
|
|
144444
144926
|
loadPluginConfig,
|
|
@@ -144752,7 +145234,7 @@ var web_search = createSwarmTool({
|
|
|
144752
145234
|
});
|
|
144753
145235
|
async function captureSearchEvidence(directory, query, results) {
|
|
144754
145236
|
try {
|
|
144755
|
-
const written = await
|
|
145237
|
+
const written = await _internals106.writeEvidenceDocuments(directory, results.map((result) => ({
|
|
144756
145238
|
sourceType: "web_search",
|
|
144757
145239
|
query,
|
|
144758
145240
|
title: result.title,
|
|
@@ -144780,7 +145262,7 @@ async function captureSearchEvidence(directory, query, results) {
|
|
|
144780
145262
|
};
|
|
144781
145263
|
}
|
|
144782
145264
|
}
|
|
144783
|
-
var
|
|
145265
|
+
var _internals106 = {
|
|
144784
145266
|
writeEvidenceDocuments
|
|
144785
145267
|
};
|
|
144786
145268
|
|
|
@@ -145600,6 +146082,7 @@ var TOOL_MANIFEST = defineHandlers({
|
|
|
145600
146082
|
swarm_memory_recall: () => swarm_memory_recall,
|
|
145601
146083
|
swarm_memory_propose: () => swarm_memory_propose,
|
|
145602
146084
|
swarm_command: () => swarm_command,
|
|
146085
|
+
dispatch_lanes: () => dispatch_lanes,
|
|
145603
146086
|
summarize_work: () => summarize_work,
|
|
145604
146087
|
write_architecture_supervisor_evidence: () => write_architecture_supervisor_evidence,
|
|
145605
146088
|
lean_turbo_plan_lanes: () => lean_turbo_plan_lanes,
|