opencode-swarm-plugin 0.31.6 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.turbo/turbo-build.log +10 -9
  2. package/.turbo/turbo-test.log +319 -317
  3. package/CHANGELOG.md +158 -0
  4. package/README.md +7 -4
  5. package/bin/swarm.ts +388 -87
  6. package/dist/compaction-hook.d.ts +1 -1
  7. package/dist/compaction-hook.d.ts.map +1 -1
  8. package/dist/hive.d.ts.map +1 -1
  9. package/dist/index.d.ts +0 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +123 -134
  12. package/dist/memory-tools.d.ts.map +1 -1
  13. package/dist/memory.d.ts +5 -4
  14. package/dist/memory.d.ts.map +1 -1
  15. package/dist/plugin.js +118 -131
  16. package/dist/swarm-orchestrate.d.ts +29 -5
  17. package/dist/swarm-orchestrate.d.ts.map +1 -1
  18. package/dist/swarm-prompts.d.ts +7 -0
  19. package/dist/swarm-prompts.d.ts.map +1 -1
  20. package/dist/swarm.d.ts +0 -2
  21. package/dist/swarm.d.ts.map +1 -1
  22. package/evals/lib/{data-loader.test.ts → data-loader.evalite-test.ts} +7 -6
  23. package/evals/lib/data-loader.ts +1 -1
  24. package/evals/scorers/{outcome-scorers.test.ts → outcome-scorers.evalite-test.ts} +1 -1
  25. package/examples/plugin-wrapper-template.ts +19 -4
  26. package/global-skills/swarm-coordination/SKILL.md +118 -8
  27. package/package.json +2 -2
  28. package/src/compaction-hook.ts +5 -3
  29. package/src/hive.integration.test.ts +83 -1
  30. package/src/hive.ts +37 -12
  31. package/src/mandate-storage.integration.test.ts +601 -0
  32. package/src/memory-tools.ts +6 -4
  33. package/src/memory.integration.test.ts +117 -49
  34. package/src/memory.test.ts +41 -217
  35. package/src/memory.ts +12 -8
  36. package/src/repo-crawl.integration.test.ts +441 -0
  37. package/src/skills.integration.test.ts +1056 -0
  38. package/src/structured.integration.test.ts +817 -0
  39. package/src/swarm-deferred.integration.test.ts +157 -0
  40. package/src/swarm-deferred.test.ts +38 -0
  41. package/src/swarm-mail.integration.test.ts +15 -19
  42. package/src/swarm-orchestrate.integration.test.ts +282 -0
  43. package/src/swarm-orchestrate.ts +96 -201
  44. package/src/swarm-prompts.test.ts +92 -0
  45. package/src/swarm-prompts.ts +69 -0
  46. package/src/swarm-review.integration.test.ts +290 -0
  47. package/src/swarm.integration.test.ts +23 -20
  48. package/src/tool-adapter.integration.test.ts +1221 -0
package/dist/plugin.js CHANGED
@@ -27084,7 +27084,7 @@ import {
27084
27084
  FlushManager,
27085
27085
  importFromJSONL,
27086
27086
  syncMemories,
27087
- getSwarmMail,
27087
+ getSwarmMailLibSQL,
27088
27088
  resolvePartialId
27089
27089
  } from "swarm-mail";
27090
27090
  import { existsSync, readFileSync } from "node:fs";
@@ -27734,7 +27734,7 @@ async function getHiveAdapter(projectKey) {
27734
27734
  if (adapterCache.has(projectKey)) {
27735
27735
  return adapterCache.get(projectKey);
27736
27736
  }
27737
- const swarmMail = await getSwarmMail(projectKey);
27737
+ const swarmMail = await getSwarmMailLibSQL(projectKey);
27738
27738
  const db = await swarmMail.getDatabase();
27739
27739
  const adapter = createHiveAdapter(db, projectKey);
27740
27740
  await adapter.runMigrations();
@@ -28101,7 +28101,7 @@ var hive_sync = tool({
28101
28101
  outputPath: `${projectKey}/.hive/issues.jsonl`
28102
28102
  });
28103
28103
  const flushResult = await withTimeout(flushManager.flush(), TIMEOUT_MS, "flush hive");
28104
- const swarmMail = await getSwarmMail(projectKey);
28104
+ const swarmMail = await getSwarmMailLibSQL(projectKey);
28105
28105
  const db = await swarmMail.getDatabase();
28106
28106
  const hivePath = join(projectKey, ".hive");
28107
28107
  let memoriesSynced = 0;
@@ -28134,9 +28134,27 @@ var hive_sync = tool({
28134
28134
  const remoteCheckResult2 = await runGitCommand(["remote"]);
28135
28135
  const hasRemote2 = remoteCheckResult2.stdout.trim() !== "";
28136
28136
  if (hasRemote2) {
28137
- const pullResult = await withTimeout(runGitCommand(["pull", "--rebase"]), TIMEOUT_MS, "git pull --rebase");
28138
- if (pullResult.exitCode !== 0) {
28139
- throw new HiveError(`Failed to pull: ${pullResult.stderr}`, "git pull --rebase", pullResult.exitCode);
28137
+ const statusResult = await runGitCommand(["status", "--porcelain"]);
28138
+ const hasUnstagedChanges = statusResult.stdout.trim() !== "";
28139
+ let didStash = false;
28140
+ if (hasUnstagedChanges) {
28141
+ const stashResult = await runGitCommand(["stash", "push", "-u", "-m", "hive_sync: auto-stash before pull"]);
28142
+ if (stashResult.exitCode === 0) {
28143
+ didStash = true;
28144
+ }
28145
+ }
28146
+ try {
28147
+ const pullResult = await withTimeout(runGitCommand(["pull", "--rebase"]), TIMEOUT_MS, "git pull --rebase");
28148
+ if (pullResult.exitCode !== 0) {
28149
+ throw new HiveError(`Failed to pull: ${pullResult.stderr}`, "git pull --rebase", pullResult.exitCode);
28150
+ }
28151
+ } finally {
28152
+ if (didStash) {
28153
+ const popResult = await runGitCommand(["stash", "pop"]);
28154
+ if (popResult.exitCode !== 0) {
28155
+ console.warn(`[hive_sync] Warning: stash pop failed. Your changes are in 'git stash list'. Error: ${popResult.stderr}`);
28156
+ }
28157
+ }
28140
28158
  }
28141
28159
  }
28142
28160
  }
@@ -32535,7 +32553,8 @@ import {
32535
32553
  sendSwarmMessage as sendSwarmMessage3,
32536
32554
  getAgent,
32537
32555
  createEvent as createEvent2,
32538
- appendEvent as appendEvent2
32556
+ appendEvent as appendEvent2,
32557
+ getSwarmMailLibSQL as getSwarmMailLibSQL2
32539
32558
  } from "swarm-mail";
32540
32559
  init_skills();
32541
32560
 
@@ -33339,60 +33358,6 @@ ${progress.blockers.map((b) => `- ${b}`).join(`
33339
33358
 
33340
33359
  `);
33341
33360
  }
33342
- async function runUbsScan(files) {
33343
- if (files.length === 0) {
33344
- return null;
33345
- }
33346
- const ubsAvailable = await isToolAvailable("ubs");
33347
- if (!ubsAvailable) {
33348
- warnMissingTool("ubs");
33349
- return null;
33350
- }
33351
- try {
33352
- const result = await Bun.$`ubs scan ${files.join(" ")} --json`.quiet().nothrow();
33353
- const output = result.stdout.toString();
33354
- if (!output.trim()) {
33355
- return {
33356
- exitCode: result.exitCode,
33357
- bugs: [],
33358
- summary: { total: 0, critical: 0, high: 0, medium: 0, low: 0 }
33359
- };
33360
- }
33361
- try {
33362
- const parsed = JSON.parse(output);
33363
- if (typeof parsed !== "object" || parsed === null) {
33364
- throw new Error("UBS output is not an object");
33365
- }
33366
- if (!Array.isArray(parsed.bugs)) {
33367
- console.warn("[swarm] UBS output missing bugs array, using empty");
33368
- }
33369
- if (typeof parsed.summary !== "object" || parsed.summary === null) {
33370
- console.warn("[swarm] UBS output missing summary object, using empty");
33371
- }
33372
- return {
33373
- exitCode: result.exitCode,
33374
- bugs: Array.isArray(parsed.bugs) ? parsed.bugs : [],
33375
- summary: parsed.summary || {
33376
- total: 0,
33377
- critical: 0,
33378
- high: 0,
33379
- medium: 0,
33380
- low: 0
33381
- }
33382
- };
33383
- } catch (error45) {
33384
- console.error(`[swarm] CRITICAL: UBS scan failed to parse JSON output because output is malformed:`, error45);
33385
- console.error(`[swarm] Raw output: ${output}. Try: Run 'ubs doctor' to check installation, verify UBS version with 'ubs --version' (need v1.0.0+), or check if UBS supports --json flag.`);
33386
- return {
33387
- exitCode: result.exitCode,
33388
- bugs: [],
33389
- summary: { total: 0, critical: 0, high: 0, medium: 0, low: 0 }
33390
- };
33391
- }
33392
- } catch {
33393
- return null;
33394
- }
33395
- }
33396
33361
  async function runTypecheckVerification() {
33397
33362
  const step = {
33398
33363
  name: "typecheck",
@@ -33477,34 +33442,9 @@ async function runTestVerification(filesTouched) {
33477
33442
  }
33478
33443
  return step;
33479
33444
  }
33480
- async function runVerificationGate(filesTouched, skipUbs = false) {
33445
+ async function runVerificationGate(filesTouched, _skipUbs = false) {
33481
33446
  const steps = [];
33482
33447
  const blockers = [];
33483
- if (!skipUbs && filesTouched.length > 0) {
33484
- const ubsResult = await runUbsScan(filesTouched);
33485
- if (ubsResult) {
33486
- const ubsStep = {
33487
- name: "ubs_scan",
33488
- command: `ubs scan ${filesTouched.join(" ")}`,
33489
- passed: ubsResult.summary.critical === 0,
33490
- exitCode: ubsResult.exitCode
33491
- };
33492
- if (!ubsStep.passed) {
33493
- ubsStep.error = `Found ${ubsResult.summary.critical} critical bugs`;
33494
- blockers.push(`UBS found ${ubsResult.summary.critical} critical bug(s). Try: Run 'ubs scan ${filesTouched.join(" ")}' to see details, fix critical bugs in reported files, or use skip_ubs_scan=true to bypass (not recommended).`);
33495
- }
33496
- steps.push(ubsStep);
33497
- } else {
33498
- steps.push({
33499
- name: "ubs_scan",
33500
- command: "ubs scan",
33501
- passed: true,
33502
- exitCode: 0,
33503
- skipped: true,
33504
- skipReason: "UBS not available"
33505
- });
33506
- }
33507
- }
33508
33448
  const typecheckStep = await runTypecheckVerification();
33509
33449
  steps.push(typecheckStep);
33510
33450
  if (!typecheckStep.passed && !typecheckStep.skipped) {
@@ -33827,16 +33767,15 @@ ${args.files_affected.map((f) => `- \`${f}\``).join(`
33827
33767
  }
33828
33768
  });
33829
33769
  var swarm_complete = tool({
33830
- description: "Mark subtask complete with Verification Gate. Runs UBS scan, typecheck, and tests before allowing completion.",
33770
+ description: "Mark subtask complete with Verification Gate. Runs typecheck and tests before allowing completion.",
33831
33771
  args: {
33832
33772
  project_key: tool.schema.string().describe("Project path"),
33833
33773
  agent_name: tool.schema.string().describe("Your Agent Mail name"),
33834
33774
  bead_id: tool.schema.string().describe("Subtask bead ID"),
33835
33775
  summary: tool.schema.string().describe("Brief summary of work done"),
33836
33776
  evaluation: tool.schema.string().optional().describe("Self-evaluation JSON (Evaluation schema)"),
33837
- files_touched: tool.schema.array(tool.schema.string()).optional().describe("Files modified - will be verified (UBS, typecheck, tests)"),
33838
- skip_ubs_scan: tool.schema.boolean().optional().describe("Skip UBS bug scan (default: false)"),
33839
- skip_verification: tool.schema.boolean().optional().describe("Skip ALL verification (UBS, typecheck, tests). Use sparingly! (default: false)"),
33777
+ files_touched: tool.schema.array(tool.schema.string()).optional().describe("Files modified - will be verified (typecheck, tests)"),
33778
+ skip_verification: tool.schema.boolean().optional().describe("Skip ALL verification (typecheck, tests). Use sparingly! (default: false)"),
33840
33779
  planned_files: tool.schema.array(tool.schema.string()).optional().describe("Files that were originally planned to be modified"),
33841
33780
  start_time: tool.schema.number().optional().describe("Task start timestamp (Unix ms) for duration calculation"),
33842
33781
  error_count: tool.schema.number().optional().describe("Number of errors encountered during task"),
@@ -33919,7 +33858,7 @@ Continuing with completion, but this should be fixed for future subtasks.`;
33919
33858
  }
33920
33859
  let verificationResult = null;
33921
33860
  if (!args.skip_verification && args.files_touched?.length) {
33922
- verificationResult = await runVerificationGate(args.files_touched, args.skip_ubs_scan ?? false);
33861
+ verificationResult = await runVerificationGate(args.files_touched, false);
33923
33862
  if (!verificationResult.passed) {
33924
33863
  return JSON.stringify({
33925
33864
  success: false,
@@ -33941,21 +33880,6 @@ Continuing with completion, but this should be fixed for future subtasks.`;
33941
33880
  }, null, 2);
33942
33881
  }
33943
33882
  }
33944
- let ubsResult = null;
33945
- if (!args.skip_verification && !verificationResult && args.files_touched?.length && !args.skip_ubs_scan) {
33946
- ubsResult = await runUbsScan(args.files_touched);
33947
- if (ubsResult && ubsResult.summary.critical > 0) {
33948
- return JSON.stringify({
33949
- success: false,
33950
- error: `UBS found ${ubsResult.summary.critical} critical bug(s) that must be fixed before completing`,
33951
- ubs_scan: {
33952
- critical_count: ubsResult.summary.critical,
33953
- bugs: ubsResult.bugs.filter((b) => b.severity === "critical")
33954
- },
33955
- hint: `Fix these critical bugs: ${ubsResult.bugs.filter((b) => b.severity === "critical").map((b) => `${b.file}:${b.line} - ${b.message}`).slice(0, 3).join("; ")}. Try: Run 'ubs scan ${args.files_touched?.join(" ") || "."} --json' for full report, fix reported issues, or use skip_ubs_scan=true to bypass (not recommended).`
33956
- }, null, 2);
33957
- }
33958
- }
33959
33883
  let contractValidation = null;
33960
33884
  let contractWarning;
33961
33885
  if (args.files_touched && args.files_touched.length > 0) {
@@ -34025,6 +33949,23 @@ This will be recorded as a negative learning signal.`;
34025
33949
  }
34026
33950
  }, null, 2);
34027
33951
  }
33952
+ let deferredResolved = false;
33953
+ let deferredError;
33954
+ try {
33955
+ const swarmMail = await getSwarmMailLibSQL2(args.project_key);
33956
+ const db = await swarmMail.getDatabase();
33957
+ const deferredUrl = `deferred:${args.bead_id}`;
33958
+ const checkResult = await db.query(`SELECT url, resolved FROM deferred WHERE url = ? AND resolved = 0`, [deferredUrl]);
33959
+ if (checkResult.rows.length > 0) {
33960
+ await db.query(`UPDATE deferred SET resolved = 1, value = ? WHERE url = ? AND resolved = 0`, [JSON.stringify({ completed: true, summary: args.summary }), deferredUrl]);
33961
+ deferredResolved = true;
33962
+ } else {
33963
+ console.info(`[swarm_complete] No deferred found for ${args.bead_id} - task may not be part of active swarm`);
33964
+ }
33965
+ } catch (error45) {
33966
+ deferredError = error45 instanceof Error ? error45.message : String(error45);
33967
+ console.warn(`[swarm_complete] Failed to resolve deferred (non-fatal): ${deferredError}`);
33968
+ }
34028
33969
  let syncSuccess = false;
34029
33970
  let syncError;
34030
33971
  try {
@@ -34129,6 +34070,8 @@ This will be recorded as a negative learning signal.`;
34129
34070
  sync_error: syncError,
34130
34071
  message_sent: messageSent,
34131
34072
  message_error: messageError,
34073
+ deferred_resolved: deferredResolved,
34074
+ deferred_error: deferredError,
34132
34075
  agent_registration: {
34133
34076
  verified: agentRegistered,
34134
34077
  warning: registrationWarning || undefined
@@ -34143,15 +34086,6 @@ This will be recorded as a negative learning signal.`;
34143
34086
  skipReason: s.skipReason
34144
34087
  }))
34145
34088
  } : args.skip_verification ? { skipped: true, reason: "skip_verification=true" } : { skipped: true, reason: "no files_touched provided" },
34146
- ubs_scan: ubsResult ? {
34147
- ran: true,
34148
- bugs_found: ubsResult.summary.total,
34149
- summary: ubsResult.summary,
34150
- warnings: ubsResult.bugs.filter((b) => b.severity !== "critical")
34151
- } : verificationResult ? { ran: true, included_in_verification_gate: true } : {
34152
- ran: false,
34153
- reason: args.skip_ubs_scan ? "skipped" : "no files or ubs unavailable"
34154
- },
34155
34089
  learning_prompt: `## Reflection
34156
34090
 
34157
34091
  Did you learn anything reusable during this subtask? Consider:
@@ -34189,9 +34123,7 @@ Files touched: ${args.files_touched?.join(", ") || "none recorded"}`,
34189
34123
  const errorStack = error45 instanceof Error ? error45.stack : undefined;
34190
34124
  let failedStep = "unknown";
34191
34125
  if (errorMessage.includes("verification")) {
34192
- failedStep = "Verification Gate (UBS/typecheck/tests)";
34193
- } else if (errorMessage.includes("UBS") || errorMessage.includes("ubs")) {
34194
- failedStep = "UBS scan";
34126
+ failedStep = "Verification Gate (typecheck/tests)";
34195
34127
  } else if (errorMessage.includes("evaluation")) {
34196
34128
  failedStep = "Self-evaluation parsing";
34197
34129
  } else if (errorMessage.includes("bead") || errorMessage.includes("close")) {
@@ -34223,7 +34155,6 @@ ${errorStack.slice(0, 1000)}
34223
34155
  `### Context`,
34224
34156
  `- **Summary**: ${args.summary}`,
34225
34157
  `- **Files touched**: ${args.files_touched?.length ? args.files_touched.join(", ") : "none"}`,
34226
- `- **Skip UBS**: ${args.skip_ubs_scan ?? false}`,
34227
34158
  `- **Skip verification**: ${args.skip_verification ?? false}`,
34228
34159
  "",
34229
34160
  `### Recovery Actions`,
@@ -34261,7 +34192,6 @@ ${errorStack.slice(0, 1000)}
34261
34192
  context: {
34262
34193
  summary: args.summary,
34263
34194
  files_touched: args.files_touched || [],
34264
- skip_ubs_scan: args.skip_ubs_scan ?? false,
34265
34195
  skip_verification: args.skip_verification ?? false
34266
34196
  },
34267
34197
  recovery: {
@@ -34273,7 +34203,6 @@ ${errorStack.slice(0, 1000)}
34273
34203
  ],
34274
34204
  common_fixes: {
34275
34205
  "Verification Gate": "Use skip_verification=true to bypass (not recommended)",
34276
- "UBS scan": "Use skip_ubs_scan=true to bypass",
34277
34206
  "Cell close": "Check cell status with hive_query(), may need hive_update() first",
34278
34207
  "Self-evaluation": "Check evaluation JSON format matches EvaluationSchema"
34279
34208
  }
@@ -34579,8 +34508,9 @@ var swarm_recover = tool({
34579
34508
  },
34580
34509
  async execute(args) {
34581
34510
  try {
34582
- const { getDatabase } = await import("swarm-mail");
34583
- const db = await getDatabase(args.project_key);
34511
+ const { getSwarmMailLibSQL: getSwarmMailLibSQL3 } = await import("swarm-mail");
34512
+ const swarmMail = await getSwarmMailLibSQL3(args.project_key);
34513
+ const db = await swarmMail.getDatabase();
34584
34514
  const result = await db.query(`SELECT * FROM swarm_contexts
34585
34515
  WHERE epic_id = $1
34586
34516
  ORDER BY updated_at DESC
@@ -35214,6 +35144,58 @@ Other cell operations:
35214
35144
  **Memory is the swarm's collective intelligence. Query it. Feed it.**
35215
35145
 
35216
35146
  Begin now.`;
35147
+ var COORDINATOR_POST_WORKER_CHECKLIST = `
35148
+ ## ⚠️ MANDATORY: Post-Worker Review (DO THIS IMMEDIATELY)
35149
+
35150
+ **A worker just returned. Before doing ANYTHING else, complete this checklist:**
35151
+
35152
+ ### Step 1: Check Swarm Mail
35153
+ \`\`\`
35154
+ swarmmail_inbox()
35155
+ swarmmail_read_message(message_id=N) // Read any messages from the worker
35156
+ \`\`\`
35157
+
35158
+ ### Step 2: Review the Work
35159
+ \`\`\`
35160
+ swarm_review(
35161
+ project_key="{project_key}",
35162
+ epic_id="{epic_id}",
35163
+ task_id="{task_id}",
35164
+ files_touched=[{files_touched}]
35165
+ )
35166
+ \`\`\`
35167
+
35168
+ This generates a review prompt with:
35169
+ - Epic context (what we're trying to achieve)
35170
+ - Subtask requirements
35171
+ - Git diff of changes
35172
+ - Dependency status
35173
+
35174
+ ### Step 3: Evaluate Against Criteria
35175
+ - Does the work fulfill the subtask requirements?
35176
+ - Does it serve the overall epic goal?
35177
+ - Does it enable downstream tasks?
35178
+ - Type safety, no obvious bugs?
35179
+
35180
+ ### Step 4: Send Feedback
35181
+ \`\`\`
35182
+ swarm_review_feedback(
35183
+ project_key="{project_key}",
35184
+ task_id="{task_id}",
35185
+ worker_id="{worker_id}",
35186
+ status="approved", // or "needs_changes"
35187
+ summary="<brief summary>",
35188
+ issues="[]" // or "[{file, line, issue, suggestion}]"
35189
+ )
35190
+ \`\`\`
35191
+
35192
+ ### Step 5: ONLY THEN Continue
35193
+ - If approved: Close the cell, spawn next worker
35194
+ - If needs_changes: Worker gets feedback, retries (max 3 attempts)
35195
+ - If 3 failures: Mark blocked, escalate to human
35196
+
35197
+ **⚠️ DO NOT spawn the next worker until review is complete.**
35198
+ `;
35217
35199
  var EVALUATION_PROMPT = `Evaluate the work completed for this subtask.
35218
35200
 
35219
35201
  ## Subtask
@@ -35385,6 +35367,8 @@ var swarm_spawn_subtask = tool({
35385
35367
  liteModel: "anthropic/claude-haiku-4-5"
35386
35368
  };
35387
35369
  const selectedModel = selectWorkerModel2(subtask, config2);
35370
+ const filesJoined = args.files.map((f) => `"${f}"`).join(", ");
35371
+ const postCompletionInstructions = COORDINATOR_POST_WORKER_CHECKLIST.replace(/{project_key}/g, args.project_path || "$PWD").replace(/{epic_id}/g, args.epic_id).replace(/{task_id}/g, args.bead_id).replace(/{files_touched}/g, filesJoined).replace(/{worker_id}/g, "worker");
35388
35372
  return JSON.stringify({
35389
35373
  prompt,
35390
35374
  bead_id: args.bead_id,
@@ -35392,7 +35376,8 @@ var swarm_spawn_subtask = tool({
35392
35376
  files: args.files,
35393
35377
  project_path: args.project_path,
35394
35378
  recovery_context: args.recovery_context,
35395
- recommended_model: selectedModel
35379
+ recommended_model: selectedModel,
35380
+ post_completion_instructions: postCompletionInstructions
35396
35381
  }, null, 2);
35397
35382
  }
35398
35383
  });
@@ -36559,7 +36544,7 @@ var mandateTools = {
36559
36544
 
36560
36545
  // src/memory-tools.ts
36561
36546
  init_dist();
36562
- import { getSwarmMail as getSwarmMail2 } from "swarm-mail";
36547
+ import { getSwarmMailLibSQL as getSwarmMailLibSQL3 } from "swarm-mail";
36563
36548
 
36564
36549
  // ../../node_modules/.bun/effect@3.19.12/node_modules/effect/dist/esm/Function.js
36565
36550
  var isFunction = (input) => typeof input === "function";
@@ -49980,7 +49965,8 @@ import {
49980
49965
  makeOllamaLive,
49981
49966
  Ollama,
49982
49967
  legacyDatabaseExists,
49983
- migrateLegacyMemories
49968
+ migrateLegacyMemories,
49969
+ toSwarmDb
49984
49970
  } from "swarm-mail";
49985
49971
  var migrationChecked = false;
49986
49972
  async function maybeAutoMigrate(db) {
@@ -50014,7 +50000,8 @@ async function createMemoryAdapter(db) {
50014
50000
  migrationChecked = true;
50015
50001
  await maybeAutoMigrate(db);
50016
50002
  }
50017
- const store = createMemoryStore(db);
50003
+ const drizzleDb = toSwarmDb(db);
50004
+ const store = createMemoryStore(drizzleDb);
50018
50005
  const config2 = getDefaultConfig();
50019
50006
  const ollamaLayer = makeOllamaLive(config2);
50020
50007
  const generateId = () => {
@@ -50159,9 +50146,9 @@ async function getMemoryAdapter(projectPath) {
50159
50146
  if (cachedAdapter && cachedProjectPath === path2) {
50160
50147
  return cachedAdapter;
50161
50148
  }
50162
- const swarmMail = await getSwarmMail2(path2);
50163
- const db = await swarmMail.getDatabase();
50164
- cachedAdapter = await createMemoryAdapter(db);
50149
+ const swarmMail = await getSwarmMailLibSQL3(path2);
50150
+ const dbAdapter = await swarmMail.getDatabase();
50151
+ cachedAdapter = await createMemoryAdapter(dbAdapter);
50165
50152
  cachedProjectPath = path2;
50166
50153
  return cachedAdapter;
50167
50154
  }
@@ -183,7 +183,35 @@ export declare const swarm_broadcast: {
183
183
  * 4. VERIFY: All checks must pass
184
184
  * 5. ONLY THEN: Close the cell
185
185
  *
186
- * Closes cell, releases reservations, notifies coordinator.
186
+ * Closes cell, releases reservations, notifies coordinator, and resolves
187
+ * a DurableDeferred keyed by bead_id for cross-agent task completion signaling.
188
+ *
189
+ * ## DurableDeferred Integration
190
+ *
191
+ * When a coordinator spawns workers, it can create a deferred BEFORE spawning:
192
+ *
193
+ * ```typescript
194
+ * const swarmMail = await getSwarmMailLibSQL(projectPath);
195
+ * const db = await swarmMail.getDatabase();
196
+ *
197
+ * // Create deferred keyed by bead_id
198
+ * const deferredUrl = `deferred:${beadId}`;
199
+ * await db.query(
200
+ * `INSERT INTO deferred (url, resolved, expires_at, created_at) VALUES (?, 0, ?, ?)`,
201
+ * [deferredUrl, Date.now() + 3600000, Date.now()]
202
+ * );
203
+ *
204
+ * // Spawn worker (swarm_spawn_subtask...)
205
+ *
206
+ * // Await completion
207
+ * const result = await db.query<{ value: string }>(
208
+ * `SELECT value FROM deferred WHERE url = ? AND resolved = 1`,
209
+ * [deferredUrl]
210
+ * );
211
+ * ```
212
+ *
213
+ * When the worker calls swarm_complete, it resolves the deferred automatically.
214
+ * Coordinator can await without polling.
187
215
  */
188
216
  export declare const swarm_complete: {
189
217
  description: string;
@@ -194,7 +222,6 @@ export declare const swarm_complete: {
194
222
  summary: z.ZodString;
195
223
  evaluation: z.ZodOptional<z.ZodString>;
196
224
  files_touched: z.ZodOptional<z.ZodArray<z.ZodString>>;
197
- skip_ubs_scan: z.ZodOptional<z.ZodBoolean>;
198
225
  skip_verification: z.ZodOptional<z.ZodBoolean>;
199
226
  planned_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
200
227
  start_time: z.ZodOptional<z.ZodNumber>;
@@ -209,7 +236,6 @@ export declare const swarm_complete: {
209
236
  summary: string;
210
237
  evaluation?: string | undefined;
211
238
  files_touched?: string[] | undefined;
212
- skip_ubs_scan?: boolean | undefined;
213
239
  skip_verification?: boolean | undefined;
214
240
  planned_files?: string[] | undefined;
215
241
  start_time?: number | undefined;
@@ -564,7 +590,6 @@ export declare const orchestrateTools: {
564
590
  summary: z.ZodString;
565
591
  evaluation: z.ZodOptional<z.ZodString>;
566
592
  files_touched: z.ZodOptional<z.ZodArray<z.ZodString>>;
567
- skip_ubs_scan: z.ZodOptional<z.ZodBoolean>;
568
593
  skip_verification: z.ZodOptional<z.ZodBoolean>;
569
594
  planned_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
570
595
  start_time: z.ZodOptional<z.ZodNumber>;
@@ -579,7 +604,6 @@ export declare const orchestrateTools: {
579
604
  summary: string;
580
605
  evaluation?: string | undefined;
581
606
  files_touched?: string[] | undefined;
582
- skip_ubs_scan?: boolean | undefined;
583
607
  skip_verification?: boolean | undefined;
584
608
  planned_files?: string[] | undefined;
585
609
  start_time?: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"swarm-orchestrate.d.ts","sourceRoot":"","sources":["../src/swarm-orchestrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAmDlC;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,aAAa,CA4BhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,MAAM,EAAE,EACvB,WAAW,EAAE,MAAM,EAAE,GACpB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAqC1C;AA8hBD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;CA8JrB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;CAoFvB,CAAC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CAc5B,CAAC"}
@@ -38,6 +38,13 @@ export declare const SUBTASK_PROMPT = "You are a swarm agent working on a subtas
38
38
  * Supports {error_context} placeholder for retry prompts.
39
39
  */
40
40
  export declare const SUBTASK_PROMPT_V2 = "You are a swarm agent working on: **{subtask_title}**\n\n## [IDENTITY]\nAgent: (assigned at spawn)\nCell: {bead_id}\nEpic: {epic_id}\n\n## [TASK]\n{subtask_description}\n\n## [FILES]\nReserved (exclusive):\n{file_list}\n\nOnly modify these files. Need others? Message the coordinator.\n\n## [CONTEXT]\n{shared_context}\n\n{compressed_context}\n\n{error_context}\n\n## [MANDATORY SURVIVAL CHECKLIST]\n\n**CRITICAL: Follow this checklist IN ORDER. Each step builds on the previous.**\n\n### Step 1: Initialize Coordination (REQUIRED - DO THIS FIRST)\n```\nswarmmail_init(project_path=\"{project_path}\", task_description=\"{bead_id}: {subtask_title}\")\n```\n\n**This registers you with the coordination system and enables:**\n- File reservation tracking\n- Inter-agent communication\n- Progress monitoring\n- Conflict detection\n\n**If you skip this step, your work will not be tracked and swarm_complete will fail.**\n\n### Step 2: \uD83E\uDDE0 Query Past Learnings (MANDATORY - BEFORE starting work)\n\n**\u26A0\uFE0F CRITICAL: ALWAYS query semantic memory BEFORE writing ANY code.**\n\n```\nsemantic-memory_find(query=\"<keywords from your task>\", limit=5, expand=true)\n```\n\n**Why this is MANDATORY:**\n- Past agents may have already solved your exact problem\n- Avoids repeating mistakes that wasted 30+ minutes before\n- Discovers project-specific patterns and gotchas\n- Finds known workarounds for tool/library quirks\n\n**Search Query Examples by Task Type:**\n\n- **Bug fix**: Use exact error message or \"<symptom> <component>\"\n- **New feature**: Search \"<domain concept> implementation pattern\"\n- **Refactor**: Query \"<pattern name> migration approach\"\n- **Integration**: Look for \"<library name> gotchas configuration\"\n- **Testing**: Find \"testing <component type> characterization tests\"\n- **Performance**: Search \"<technology> performance optimization\"\n\n**BEFORE you start coding:**\n1. Run semantic-memory_find with keywords from your task\n2. Read the results with expand=true for full content\n3. Check if any memory solves your problem or warns of pitfalls\n4. Adjust your approach based on past learnings\n\n**If you skip this step, you WILL waste time solving already-solved problems.**\n\n### Step 3: Load Relevant Skills (if available)\n```\nskills_list() # See what skills exist\nskills_use(name=\"<relevant-skill>\", context=\"<your task>\") # Load skill\n```\n\n**Common skill triggers:**\n- Writing tests? \u2192 `skills_use(name=\"testing-patterns\")`\n- Breaking dependencies? \u2192 `skills_use(name=\"testing-patterns\")`\n- Multi-agent coordination? \u2192 `skills_use(name=\"swarm-coordination\")`\n- Building a CLI? \u2192 `skills_use(name=\"cli-builder\")`\n\n### Step 4: Reserve Your Files (YOU reserve, not coordinator)\n```\nswarmmail_reserve(\n paths=[{file_list}],\n reason=\"{bead_id}: {subtask_title}\",\n exclusive=true\n)\n```\n\n**Workers reserve their own files.** This prevents edit conflicts with other agents.\n\n### Step 5: Do the Work (TDD MANDATORY)\n\n**Follow RED \u2192 GREEN \u2192 REFACTOR. No exceptions.**\n\n1. **RED**: Write a failing test that describes the expected behavior\n - Test MUST fail before you write implementation\n - If test passes immediately, your test is wrong\n \n2. **GREEN**: Write minimal code to make the test pass\n - Don't over-engineer - just make it green\n - Hardcode if needed, refactor later\n \n3. **REFACTOR**: Clean up while tests stay green\n - Run tests after every change\n - If tests break, undo and try again\n\n```bash\n# Run tests continuously\nbun test <your-test-file> --watch\n```\n\n**Why TDD?**\n- Catches bugs before they exist\n- Documents expected behavior\n- Enables fearless refactoring\n- Proves your code works\n\n### Step 6: Report Progress at Milestones\n```\nswarm_progress(\n project_key=\"{project_path}\",\n agent_name=\"<your-agent-name>\",\n bead_id=\"{bead_id}\",\n status=\"in_progress\",\n progress_percent=25, # or 50, 75\n message=\"<what you just completed>\"\n)\n```\n\n**Report at 25%, 50%, 75% completion.** This:\n- Triggers auto-checkpoint (saves context)\n- Keeps coordinator informed\n- Prevents silent failures\n\n### Step 7: Manual Checkpoint BEFORE Risky Operations\n```\nswarm_checkpoint(\n project_key=\"{project_path}\",\n agent_name=\"<your-agent-name>\",\n bead_id=\"{bead_id}\"\n)\n```\n\n**Call BEFORE:**\n- Large refactors\n- File deletions\n- Breaking API changes\n- Anything that might fail catastrophically\n\n**Checkpoints preserve context so you can recover if things go wrong.**\n\n### Step 8: \uD83D\uDCBE STORE YOUR LEARNINGS (if you discovered something)\n\n**If you learned it the hard way, STORE IT so the next agent doesn't have to.**\n\n```\nsemantic-memory_store(\n information=\"<what you learned, WHY it matters, how to apply it>\",\n tags=\"<domain, tech-stack, pattern-type>\"\n)\n```\n\n**MANDATORY Storage Triggers - Store when you:**\n- \uD83D\uDC1B **Solved a tricky bug** (>15min debugging) - include root cause + solution\n- \uD83D\uDCA1 **Discovered a project-specific pattern** - domain rules, business logic quirks\n- \u26A0\uFE0F **Found a tool/library gotcha** - API quirks, version-specific bugs, workarounds\n- \uD83D\uDEAB **Tried an approach that failed** - anti-patterns to avoid, why it didn't work\n- \uD83C\uDFD7\uFE0F **Made an architectural decision** - reasoning, alternatives considered, tradeoffs\n\n**What Makes a GOOD Memory:**\n\n\u2705 **GOOD** (actionable, explains WHY):\n```\n\"OAuth refresh tokens need 5min buffer before expiry to avoid race conditions.\nWithout buffer, token refresh can fail mid-request if expiry happens between\ncheck and use. Implemented with: if (expiresAt - Date.now() < 300000) refresh()\"\n```\n\n\u274C **BAD** (generic, no context):\n```\n\"Fixed the auth bug by adding a null check\"\n```\n\n**What NOT to Store:**\n- Generic knowledge that's in official documentation\n- Implementation details that change frequently\n- Vague descriptions without context (\"fixed the thing\")\n\n**The WHY matters more than the WHAT.** Future agents need context to apply your learning.\n\n### Step 9: Complete (REQUIRED - releases reservations)\n```\nswarm_complete(\n project_key=\"{project_path}\",\n agent_name=\"<your-agent-name>\",\n bead_id=\"{bead_id}\",\n summary=\"<what you accomplished>\",\n files_touched=[\"list\", \"of\", \"files\"]\n)\n```\n\n**This automatically:**\n- Runs UBS bug scan\n- Releases file reservations\n- Records learning signals\n- Notifies coordinator\n\n**DO NOT manually close the cell with hive_close.** Use swarm_complete.\n\n## [SWARM MAIL COMMUNICATION]\n\n### Check Inbox Regularly\n```\nswarmmail_inbox() # Check for coordinator messages\nswarmmail_read_message(message_id=N) # Read specific message\n```\n\n### When Blocked\n```\nswarmmail_send(\n to=[\"coordinator\"],\n subject=\"BLOCKED: {bead_id}\",\n body=\"<blocker description, what you need>\",\n importance=\"high\",\n thread_id=\"{epic_id}\"\n)\nhive_update(id=\"{bead_id}\", status=\"blocked\")\n```\n\n### Report Issues to Other Agents\n```\nswarmmail_send(\n to=[\"OtherAgent\", \"coordinator\"],\n subject=\"Issue in {bead_id}\",\n body=\"<describe problem, don't fix their code>\",\n thread_id=\"{epic_id}\"\n)\n```\n\n### Manual Release (if needed)\n```\nswarmmail_release() # Manually release reservations\n```\n\n**Note:** `swarm_complete` automatically releases reservations. Only use manual release if aborting work.\n\n## [OTHER TOOLS]\n### Hive - You Have Autonomy to File Issues\nYou can create new cells against this epic when you discover:\n- **Bugs**: Found a bug while working? File it.\n- **Tech debt**: Spotted something that needs cleanup? File it.\n- **Follow-up work**: Task needs more work than scoped? File a follow-up.\n- **Dependencies**: Need something from another agent? File and link it.\n\n```\nhive_create(\n title=\"<descriptive title>\",\n type=\"bug\", # or \"task\", \"chore\"\n priority=2,\n parent_id=\"{epic_id}\", # Links to this epic\n description=\"Found while working on {bead_id}: <details>\"\n)\n```\n\n**Don't silently ignore issues.** File them so they get tracked and addressed.\n\nOther cell operations:\n- hive_update(id, status) - Mark blocked if stuck\n- hive_query(status=\"open\") - See what else needs work\n\n### Skills\n- skills_list() - Discover available skills\n- skills_use(name) - Activate skill for specialized guidance\n- skills_create(name) - Create new skill (if you found a reusable pattern)\n\n## [CRITICAL REQUIREMENTS]\n\n**NON-NEGOTIABLE:**\n1. Step 1 (swarmmail_init) MUST be first - do it before anything else\n2. \uD83E\uDDE0 Step 2 (semantic-memory_find) MUST happen BEFORE starting work - query first, code second\n3. Step 4 (swarmmail_reserve) - YOU reserve files, not coordinator\n4. Step 6 (swarm_progress) - Report at milestones, don't work silently\n5. \uD83D\uDCBE Step 8 (semantic-memory_store) - If you learned something hard, STORE IT\n6. Step 9 (swarm_complete) - Use this to close, NOT hive_close\n\n**If you skip these steps:**\n- Your work won't be tracked (swarm_complete will fail)\n- \uD83D\uDD04 You'll waste time repeating already-solved problems (no semantic memory query)\n- Edit conflicts with other agents (no file reservation)\n- Lost work if you crash (no checkpoints)\n- \uD83D\uDD04 Future agents repeat YOUR mistakes (no learnings stored)\n\n**Memory is the swarm's collective intelligence. Query it. Feed it.**\n\nBegin now.";
41
+ /**
42
+ * Coordinator post-worker checklist - MANDATORY review loop
43
+ *
44
+ * This checklist is returned to coordinators after spawning a worker.
45
+ * It ensures coordinators REVIEW worker output before spawning the next worker.
46
+ */
47
+ export declare const COORDINATOR_POST_WORKER_CHECKLIST = "\n## \u26A0\uFE0F MANDATORY: Post-Worker Review (DO THIS IMMEDIATELY)\n\n**A worker just returned. Before doing ANYTHING else, complete this checklist:**\n\n### Step 1: Check Swarm Mail\n```\nswarmmail_inbox()\nswarmmail_read_message(message_id=N) // Read any messages from the worker\n```\n\n### Step 2: Review the Work\n```\nswarm_review(\n project_key=\"{project_key}\",\n epic_id=\"{epic_id}\",\n task_id=\"{task_id}\",\n files_touched=[{files_touched}]\n)\n```\n\nThis generates a review prompt with:\n- Epic context (what we're trying to achieve)\n- Subtask requirements\n- Git diff of changes\n- Dependency status\n\n### Step 3: Evaluate Against Criteria\n- Does the work fulfill the subtask requirements?\n- Does it serve the overall epic goal?\n- Does it enable downstream tasks?\n- Type safety, no obvious bugs?\n\n### Step 4: Send Feedback\n```\nswarm_review_feedback(\n project_key=\"{project_key}\",\n task_id=\"{task_id}\",\n worker_id=\"{worker_id}\",\n status=\"approved\", // or \"needs_changes\"\n summary=\"<brief summary>\",\n issues=\"[]\" // or \"[{file, line, issue, suggestion}]\"\n)\n```\n\n### Step 5: ONLY THEN Continue\n- If approved: Close the cell, spawn next worker\n- If needs_changes: Worker gets feedback, retries (max 3 attempts)\n- If 3 failures: Mark blocked, escalate to human\n\n**\u26A0\uFE0F DO NOT spawn the next worker until review is complete.**\n";
41
48
  /**
42
49
  * Prompt for self-evaluation before completing a subtask.
43
50
  *
@@ -1 +1 @@
1
- {"version":3,"file":"swarm-prompts.d.ts","sourceRoot":"","sources":["../src/swarm-prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,s6EAkET,CAAC;AAEzB;;GAEG;AACH,eAAO,MAAM,6BAA6B,mxDAyDlB,CAAC;AAEzB;;;;;GAKG;AACH,eAAO,MAAM,cAAc,mkFAgFK,CAAC;AAEjC;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,mzSA0SnB,CAAC;AAEZ;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,8jCAmCU,CAAC;AAMzC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH,GAAG,MAAM,CA2ET;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAA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uBAAuB;;;;;;;;;;;;CAoClC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;CAwI5B,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKvB,CAAC"}
package/dist/swarm.d.ts CHANGED
@@ -102,7 +102,6 @@ export declare const swarmTools: {
102
102
  summary: import("zod").ZodString;
103
103
  evaluation: import("zod").ZodOptional<import("zod").ZodString>;
104
104
  files_touched: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
105
- skip_ubs_scan: import("zod").ZodOptional<import("zod").ZodBoolean>;
106
105
  skip_verification: import("zod").ZodOptional<import("zod").ZodBoolean>;
107
106
  planned_files: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
108
107
  start_time: import("zod").ZodOptional<import("zod").ZodNumber>;
@@ -117,7 +116,6 @@ export declare const swarmTools: {
117
116
  summary: string;
118
117
  evaluation?: string | undefined;
119
118
  files_touched?: string[] | undefined;
120
- skip_ubs_scan?: boolean | undefined;
121
119
  skip_verification?: boolean | undefined;
122
120
  planned_files?: string[] | undefined;
123
121
  start_time?: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../src/swarm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AAQpC;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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tB,CAAC"}
@@ -10,12 +10,13 @@ import {
10
10
  hasRealEvalData,
11
11
  getEvalDataSummary,
12
12
  } from "./data-loader.js";
13
- import { appendEvent } from "../../src/streams/store.js";
14
- import { getDatabase, closeDatabase } from "../../src/streams/index.js";
15
- import type {
16
- DecompositionGeneratedEvent,
17
- SubtaskOutcomeEvent,
18
- } from "../../src/streams/events.js";
13
+ import {
14
+ appendEvent,
15
+ getDatabase,
16
+ closeDatabase,
17
+ type DecompositionGeneratedEvent,
18
+ type SubtaskOutcomeEvent,
19
+ } from "swarm-mail";
19
20
  import * as fs from "node:fs";
20
21
  import * as path from "node:path";
21
22
  import * as os from "node:os";
@@ -8,7 +8,7 @@ import {
8
8
  getEvalRecords,
9
9
  getEvalStats,
10
10
  type EvalRecord,
11
- } from "../../src/streams/projections.js";
11
+ } from "swarm-mail";
12
12
 
13
13
  export interface EvalCase {
14
14
  input: { task: string; context?: string };
@@ -4,7 +4,7 @@
4
4
  * Tests the 5 new outcome-based scorers by verifying their exports.
5
5
  * Full functional testing happens via Evalite integration.
6
6
  */
7
- import { describe, it, expect } from "vitest";
7
+ import { describe, it, expect } from "bun:test";
8
8
 
9
9
  describe("Outcome Scorers", () => {
10
10
  it("exports all 5 outcome scorers from outcome-scorers.ts", async () => {