@synergenius/flow-weaver-pack-weaver 0.9.59 → 0.9.77

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 (217) hide show
  1. package/dist/ai-chat-provider.d.ts +12 -0
  2. package/dist/ai-chat-provider.d.ts.map +1 -1
  3. package/dist/ai-chat-provider.js +351 -335
  4. package/dist/ai-chat-provider.js.map +1 -1
  5. package/dist/bot/agent-loop.d.ts +20 -0
  6. package/dist/bot/agent-loop.d.ts.map +1 -0
  7. package/dist/bot/agent-loop.js +331 -0
  8. package/dist/bot/agent-loop.js.map +1 -0
  9. package/dist/bot/ai-router.d.ts +19 -0
  10. package/dist/bot/ai-router.d.ts.map +1 -0
  11. package/dist/bot/ai-router.js +104 -0
  12. package/dist/bot/ai-router.js.map +1 -0
  13. package/dist/bot/assistant-tools.d.ts.map +1 -1
  14. package/dist/bot/assistant-tools.js +49 -33
  15. package/dist/bot/assistant-tools.js.map +1 -1
  16. package/dist/bot/async-mutex.d.ts +13 -0
  17. package/dist/bot/async-mutex.d.ts.map +1 -0
  18. package/dist/bot/async-mutex.js +37 -0
  19. package/dist/bot/async-mutex.js.map +1 -0
  20. package/dist/bot/bot-manager.d.ts +2 -2
  21. package/dist/bot/bot-manager.d.ts.map +1 -1
  22. package/dist/bot/bot-manager.js +3 -3
  23. package/dist/bot/bot-manager.js.map +1 -1
  24. package/dist/bot/bot-registry.js +2 -2
  25. package/dist/bot/bot-registry.js.map +1 -1
  26. package/dist/bot/conversation-store.d.ts +1 -0
  27. package/dist/bot/conversation-store.d.ts.map +1 -1
  28. package/dist/bot/conversation-store.js.map +1 -1
  29. package/dist/bot/dashboard.d.ts.map +1 -1
  30. package/dist/bot/dashboard.js +17 -8
  31. package/dist/bot/dashboard.js.map +1 -1
  32. package/dist/bot/improve-loop.js.map +1 -1
  33. package/dist/bot/index.d.ts +2 -4
  34. package/dist/bot/index.d.ts.map +1 -1
  35. package/dist/bot/index.js +1 -2
  36. package/dist/bot/index.js.map +1 -1
  37. package/dist/bot/instance-manager.d.ts +31 -0
  38. package/dist/bot/instance-manager.d.ts.map +1 -0
  39. package/dist/bot/instance-manager.js +115 -0
  40. package/dist/bot/instance-manager.js.map +1 -0
  41. package/dist/bot/orchestrator.d.ts +36 -0
  42. package/dist/bot/orchestrator.d.ts.map +1 -0
  43. package/dist/bot/orchestrator.js +176 -0
  44. package/dist/bot/orchestrator.js.map +1 -0
  45. package/dist/bot/profile-store.d.ts +36 -0
  46. package/dist/bot/profile-store.d.ts.map +1 -0
  47. package/dist/bot/profile-store.js +208 -0
  48. package/dist/bot/profile-store.js.map +1 -0
  49. package/dist/bot/profile-types.d.ts +126 -0
  50. package/dist/bot/profile-types.d.ts.map +1 -0
  51. package/dist/bot/profile-types.js +7 -0
  52. package/dist/bot/profile-types.js.map +1 -0
  53. package/dist/bot/run-store.d.ts.map +1 -1
  54. package/dist/bot/run-store.js +8 -0
  55. package/dist/bot/run-store.js.map +1 -1
  56. package/dist/bot/runner.d.ts +4 -0
  57. package/dist/bot/runner.d.ts.map +1 -1
  58. package/dist/bot/runner.js +5 -1
  59. package/dist/bot/runner.js.map +1 -1
  60. package/dist/bot/swarm-controller.d.ts +109 -0
  61. package/dist/bot/swarm-controller.d.ts.map +1 -0
  62. package/dist/bot/swarm-controller.js +640 -0
  63. package/dist/bot/swarm-controller.js.map +1 -0
  64. package/dist/bot/swarm-event-log.d.ts +28 -0
  65. package/dist/bot/swarm-event-log.d.ts.map +1 -0
  66. package/dist/bot/swarm-event-log.js +54 -0
  67. package/dist/bot/swarm-event-log.js.map +1 -0
  68. package/dist/bot/task-prompt-builder.d.ts +22 -0
  69. package/dist/bot/task-prompt-builder.d.ts.map +1 -0
  70. package/dist/bot/task-prompt-builder.js +240 -0
  71. package/dist/bot/task-prompt-builder.js.map +1 -0
  72. package/dist/bot/task-store.d.ts +21 -0
  73. package/dist/bot/task-store.d.ts.map +1 -0
  74. package/dist/bot/task-store.js +364 -0
  75. package/dist/bot/task-store.js.map +1 -0
  76. package/dist/bot/task-types.d.ts +79 -0
  77. package/dist/bot/task-types.d.ts.map +1 -0
  78. package/dist/bot/task-types.js +6 -0
  79. package/dist/bot/task-types.js.map +1 -0
  80. package/dist/bot/types.d.ts +8 -0
  81. package/dist/bot/types.d.ts.map +1 -1
  82. package/dist/cli-handlers.d.ts.map +1 -1
  83. package/dist/cli-handlers.js +79 -54
  84. package/dist/cli-handlers.js.map +1 -1
  85. package/dist/cli.d.ts +3 -0
  86. package/dist/cli.d.ts.map +1 -0
  87. package/dist/cli.js +749 -0
  88. package/dist/cli.js.map +1 -0
  89. package/dist/docs/docs/weaver-bot-usage.md +35 -18
  90. package/dist/docs/docs/weaver-config.md +20 -0
  91. package/dist/docs/docs/weaver-task-queue.md +31 -19
  92. package/dist/docs/weaver-config.md +15 -9
  93. package/dist/index.d.ts +2 -2
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.js +1 -1
  96. package/dist/index.js.map +1 -1
  97. package/dist/mcp-tools.d.ts +17 -0
  98. package/dist/mcp-tools.d.ts.map +1 -1
  99. package/dist/mcp-tools.js +98 -279
  100. package/dist/mcp-tools.js.map +1 -1
  101. package/dist/node-types/bot-report.d.ts.map +1 -1
  102. package/dist/node-types/bot-report.js +6 -24
  103. package/dist/node-types/bot-report.js.map +1 -1
  104. package/dist/node-types/orchestrator-dispatch.d.ts +17 -0
  105. package/dist/node-types/orchestrator-dispatch.d.ts.map +1 -0
  106. package/dist/node-types/orchestrator-dispatch.js +63 -0
  107. package/dist/node-types/orchestrator-dispatch.js.map +1 -0
  108. package/dist/node-types/orchestrator-load-state.d.ts +16 -0
  109. package/dist/node-types/orchestrator-load-state.d.ts.map +1 -0
  110. package/dist/node-types/orchestrator-load-state.js +60 -0
  111. package/dist/node-types/orchestrator-load-state.js.map +1 -0
  112. package/dist/node-types/orchestrator-route.d.ts +16 -0
  113. package/dist/node-types/orchestrator-route.d.ts.map +1 -0
  114. package/dist/node-types/orchestrator-route.js +28 -0
  115. package/dist/node-types/orchestrator-route.js.map +1 -0
  116. package/dist/node-types/receive-task.d.ts +2 -3
  117. package/dist/node-types/receive-task.d.ts.map +1 -1
  118. package/dist/node-types/receive-task.js +3 -48
  119. package/dist/node-types/receive-task.js.map +1 -1
  120. package/dist/templates/weaver-template.d.ts +11 -0
  121. package/dist/templates/weaver-template.d.ts.map +1 -0
  122. package/dist/templates/weaver-template.js +53 -0
  123. package/dist/templates/weaver-template.js.map +1 -0
  124. package/dist/ui/bot-activity.js +2 -2
  125. package/dist/ui/bot-constants.d.ts +14 -0
  126. package/dist/ui/bot-constants.d.ts.map +1 -0
  127. package/dist/ui/bot-constants.js +189 -0
  128. package/dist/ui/bot-constants.js.map +1 -0
  129. package/dist/ui/bot-panel.js +207 -245
  130. package/dist/ui/bot-slot-card.js +141 -0
  131. package/dist/ui/budget-bar.js +59 -0
  132. package/dist/ui/chat-task-result.js +178 -0
  133. package/dist/ui/decision-log.js +136 -0
  134. package/dist/ui/profile-card.js +158 -0
  135. package/dist/ui/profile-editor.js +597 -0
  136. package/dist/ui/swarm-controls.js +245 -0
  137. package/dist/ui/swarm-dashboard.js +3012 -0
  138. package/dist/ui/task-create-form.js +98 -0
  139. package/dist/ui/task-detail-view.js +1044 -0
  140. package/dist/ui/task-pool-list.js +156 -0
  141. package/dist/workflows/orchestrator.d.ts +21 -0
  142. package/dist/workflows/orchestrator.d.ts.map +1 -0
  143. package/dist/workflows/orchestrator.js +281 -0
  144. package/dist/workflows/orchestrator.js.map +1 -0
  145. package/dist/workflows/weaver-bot-session.d.ts +65 -0
  146. package/dist/workflows/weaver-bot-session.d.ts.map +1 -0
  147. package/dist/workflows/weaver-bot-session.js +68 -0
  148. package/dist/workflows/weaver-bot-session.js.map +1 -0
  149. package/dist/workflows/weaver.d.ts +24 -0
  150. package/dist/workflows/weaver.d.ts.map +1 -0
  151. package/dist/workflows/weaver.js +28 -0
  152. package/dist/workflows/weaver.js.map +1 -0
  153. package/flowweaver.manifest.json +547 -133
  154. package/package.json +1 -1
  155. package/src/ai-chat-provider.ts +378 -371
  156. package/src/bot/ai-router.ts +132 -0
  157. package/src/bot/assistant-tools.ts +47 -29
  158. package/src/bot/async-mutex.ts +37 -0
  159. package/src/bot/bot-manager.ts +3 -3
  160. package/src/bot/bot-registry.ts +2 -2
  161. package/src/bot/conversation-store.ts +2 -1
  162. package/src/bot/dashboard.ts +17 -8
  163. package/src/bot/improve-loop.ts +6 -6
  164. package/src/bot/index.ts +2 -4
  165. package/src/bot/instance-manager.ts +128 -0
  166. package/src/bot/orchestrator.ts +244 -0
  167. package/src/bot/profile-store.ts +225 -0
  168. package/src/bot/profile-types.ts +141 -0
  169. package/src/bot/run-store.ts +8 -0
  170. package/src/bot/runner.ts +9 -1
  171. package/src/bot/swarm-controller.ts +780 -0
  172. package/src/bot/swarm-event-log.ts +57 -0
  173. package/src/bot/task-prompt-builder.ts +309 -0
  174. package/src/bot/task-store.ts +407 -0
  175. package/src/bot/task-types.ts +100 -0
  176. package/src/bot/types.ts +8 -0
  177. package/src/cli-handlers.ts +78 -53
  178. package/src/docs/weaver-bot-usage.md +35 -18
  179. package/src/docs/weaver-config.md +20 -0
  180. package/src/docs/weaver-task-queue.md +31 -19
  181. package/src/index.ts +5 -4
  182. package/src/mcp-tools.ts +129 -372
  183. package/src/node-types/bot-report.ts +6 -24
  184. package/src/node-types/orchestrator-dispatch.ts +71 -0
  185. package/src/node-types/orchestrator-load-state.ts +66 -0
  186. package/src/node-types/orchestrator-route.ts +33 -0
  187. package/src/node-types/receive-task.ts +3 -57
  188. package/src/ui/bot-activity.tsx +2 -2
  189. package/src/ui/bot-constants.ts +192 -0
  190. package/src/ui/bot-panel.tsx +213 -247
  191. package/src/ui/bot-slot-card.tsx +139 -0
  192. package/src/ui/budget-bar.tsx +30 -0
  193. package/src/ui/chat-task-result.tsx +236 -0
  194. package/src/ui/decision-log.tsx +148 -0
  195. package/src/ui/profile-card.tsx +157 -0
  196. package/src/ui/profile-editor.tsx +384 -0
  197. package/src/ui/swarm-controls.tsx +260 -0
  198. package/src/ui/swarm-dashboard.tsx +647 -0
  199. package/src/ui/task-create-form.tsx +87 -0
  200. package/src/ui/task-detail-view.tsx +841 -0
  201. package/src/ui/task-pool-list.tsx +187 -0
  202. package/src/workflows/orchestrator.ts +302 -0
  203. package/dist/docs/weaver-bot-usage.md +0 -34
  204. package/dist/docs/weaver-genesis.md +0 -32
  205. package/dist/docs/weaver-task-queue.md +0 -34
  206. package/dist/ui/bot-workspace.js +0 -1015
  207. package/dist/ui/chat-bot-result.js +0 -71
  208. package/dist/ui/queue-input.js +0 -82
  209. package/dist/ui/session-bar.js +0 -174
  210. package/src/bot/error-guide.ts +0 -4
  211. package/src/bot/retry-utils.ts +0 -4
  212. package/src/bot/session-state.ts +0 -116
  213. package/src/bot/task-queue.ts +0 -262
  214. package/src/ui/bot-workspace.tsx +0 -442
  215. package/src/ui/chat-bot-result.tsx +0 -81
  216. package/src/ui/queue-input.tsx +0 -56
  217. package/src/ui/session-bar.tsx +0 -157
@@ -1374,9 +1374,15 @@ export async function handleSession(opts: ParsedArgs): Promise<void> {
1374
1374
 
1375
1375
  // Crash recovery
1376
1376
  if (continuous) {
1377
- const { TaskQueue } = await import('./bot/task-queue.js');
1378
- const recoveryQueue = new TaskQueue();
1379
- const recovered = await recoveryQueue.recoverOrphans();
1377
+ const { TaskStore } = await import('./bot/task-store.js');
1378
+ const recoveryStore = new TaskStore(projectDir);
1379
+ // Recover orphaned in-progress tasks back to pending
1380
+ const inProgressTasks = await recoveryStore.list({ status: 'in-progress' });
1381
+ let recovered = 0;
1382
+ for (const t of inProgressTasks) {
1383
+ await recoveryStore.update(t.id, { status: 'pending' });
1384
+ recovered++;
1385
+ }
1380
1386
  if (recovered > 0) renderer.info(`Recovered ${recovered} orphaned task(s)`);
1381
1387
  }
1382
1388
 
@@ -1419,9 +1425,9 @@ export async function handleSession(opts: ParsedArgs): Promise<void> {
1419
1425
  }
1420
1426
 
1421
1427
  // Continuous mode: loop until deadline/maxTasks/interrupt
1422
- const { TaskQueue } = await import('./bot/task-queue.js');
1428
+ const { TaskStore } = await import('./bot/task-store.js');
1423
1429
  const { isTransientError, getErrorGuidance } = await import('./bot/error-classifier.js');
1424
- const queue = new TaskQueue();
1430
+ const taskStore = new TaskStore(projectDir);
1425
1431
  let taskCount = 0;
1426
1432
  let interrupted = false;
1427
1433
  let consecutiveErrors = 0;
@@ -1440,10 +1446,11 @@ export async function handleSession(opts: ParsedArgs): Promise<void> {
1440
1446
  const running = new Map<string, Promise<void>>();
1441
1447
  const filesInUse = new Set<string>();
1442
1448
 
1443
- const processTask = async (task: { id: string; instruction?: string; targets?: string[] }) => {
1449
+ const processTask = async (task: { id: string; title: string; description: string; context: { files: string[] } }) => {
1450
+ const taskPayload = { id: task.id, instruction: task.title, description: task.description, targets: task.context.files };
1444
1451
  try {
1445
1452
  const result = await runWorkflow(workflowPath, {
1446
- params: { projectDir, taskJson: JSON.stringify(task) },
1453
+ params: { projectDir, taskJson: JSON.stringify(taskPayload) },
1447
1454
  verbose: opts.verbose,
1448
1455
  dryRun: opts.dryRun,
1449
1456
  config,
@@ -1460,17 +1467,17 @@ export async function handleSession(opts: ParsedArgs): Promise<void> {
1460
1467
  );
1461
1468
 
1462
1469
  if (isNoOp) {
1463
- await queue.markNoOp(task.id);
1470
+ await taskStore.update(task.id, { status: 'done' });
1464
1471
  sessionNoOp++;
1465
1472
  consecutiveNoOps++;
1466
1473
  consecutiveErrors = 0;
1467
1474
  } else if (result.success) {
1468
- await queue.markComplete(task.id);
1475
+ await taskStore.update(task.id, { status: 'done' });
1469
1476
  sessionCompleted++;
1470
1477
  consecutiveErrors = 0;
1471
1478
  consecutiveNoOps = 0;
1472
1479
  } else {
1473
- await queue.markFailed(task.id, result.summary || result.outcome || 'unknown error');
1480
+ await taskStore.update(task.id, { status: 'failed' });
1474
1481
  sessionFailed++;
1475
1482
  consecutiveErrors++;
1476
1483
  consecutiveNoOps = 0;
@@ -1487,13 +1494,13 @@ export async function handleSession(opts: ParsedArgs): Promise<void> {
1487
1494
  const msg = err instanceof Error ? err.message : String(err);
1488
1495
  const guidance = getErrorGuidance(msg);
1489
1496
  renderer.error(`Task ${task.id.slice(0, 8)} error`, guidance ? `${msg}\n Hint: ${guidance}` : msg);
1490
- await queue.markFailed(task.id, msg);
1497
+ await taskStore.update(task.id, { status: 'failed' });
1491
1498
  sessionFailed++;
1492
1499
  if (!isTransientError(err)) {
1493
1500
  consecutiveErrors++;
1494
1501
  }
1495
1502
  } finally {
1496
- for (const f of task.targets ?? []) filesInUse.delete(f);
1503
+ for (const f of task.context.files) filesInUse.delete(f);
1497
1504
  running.delete(task.id);
1498
1505
  }
1499
1506
  };
@@ -1522,7 +1529,8 @@ export async function handleSession(opts: ParsedArgs): Promise<void> {
1522
1529
  continue;
1523
1530
  }
1524
1531
 
1525
- const task = await queue.next();
1532
+ const pendingTasks = await taskStore.list({ status: 'pending', limit: 1 });
1533
+ const task = pendingTasks[0] ?? null;
1526
1534
  if (!task) {
1527
1535
  if (running.size > 0) {
1528
1536
  // Tasks still running — wait for one to finish
@@ -1536,22 +1544,26 @@ export async function handleSession(opts: ParsedArgs): Promise<void> {
1536
1544
 
1537
1545
  // Auto-decompose broad tasks into per-file tasks
1538
1546
  const { decomposeTask } = await import('./bot/task-decomposer.js');
1539
- const { decomposed, tasks: subtasks } = decomposeTask(task, projectDir);
1547
+ const decomposable = { id: task.id, instruction: task.title, targets: task.context.files, priority: task.priority };
1548
+ const { decomposed, tasks: subtasks } = decomposeTask(decomposable, projectDir);
1540
1549
  if (decomposed && subtasks.length > 1) {
1541
1550
  // Replace the broad task with per-file tasks
1542
- await queue.markComplete(task.id);
1543
- let decomposedCount = 0;
1551
+ await taskStore.update(task.id, { status: 'done' });
1544
1552
  for (const st of subtasks) {
1545
- const { duplicate } = await queue.add({ instruction: st.instruction, mode: st.mode as 'modify', targets: st.targets, priority: st.priority ?? 0 });
1546
- if (!duplicate) decomposedCount++;
1553
+ await taskStore.create({
1554
+ title: st.instruction,
1555
+ description: st.instruction,
1556
+ priority: st.priority ?? 0,
1557
+ createdBy: 'ai',
1558
+ });
1547
1559
  }
1548
1560
  renderer.info(`Decomposed into ${subtasks.length} per-file tasks`);
1549
1561
  continue;
1550
1562
  }
1551
1563
 
1552
1564
  // File conflict check: if task targets overlap with files in use, wait
1553
- const taskTargets = task.targets ?? [];
1554
- const hasConflict = taskTargets.some(f => filesInUse.has(f));
1565
+ const taskTargets = task.context.files;
1566
+ const hasConflict = taskTargets.some((f: string) => filesInUse.has(f));
1555
1567
  if (hasConflict && running.size > 0) {
1556
1568
  await Promise.race(running.values());
1557
1569
  continue;
@@ -1559,9 +1571,9 @@ export async function handleSession(opts: ParsedArgs): Promise<void> {
1559
1571
 
1560
1572
  taskCount++;
1561
1573
  if (opts.verbose) process.env.WEAVER_VERBOSE = '1';
1562
- renderer.taskStart(taskCount, task.instruction ?? task.id);
1574
+ renderer.taskStart(taskCount, task.title ?? task.id);
1563
1575
 
1564
- await queue.markRunning(task.id);
1576
+ await taskStore.update(task.id, { status: 'in-progress' });
1565
1577
  // Reserve files
1566
1578
  for (const f of taskTargets) filesInUse.add(f);
1567
1579
 
@@ -1784,8 +1796,9 @@ export async function handleSteer(opts: ParsedArgs): Promise<void> {
1784
1796
  }
1785
1797
 
1786
1798
  export async function handleQueue(opts: ParsedArgs): Promise<void> {
1787
- const { TaskQueue } = await import('./bot/task-queue.js');
1788
- const queue = new TaskQueue();
1799
+ const { TaskStore } = await import('./bot/task-store.js');
1800
+ const projectDir = process.env.WEAVER_PROJECT_DIR ?? process.cwd();
1801
+ const store = new TaskStore(projectDir);
1789
1802
 
1790
1803
  const action = opts.botTask;
1791
1804
  if (!action || !['add', 'list', 'clear', 'remove', 'retry'].includes(action)) {
@@ -1800,30 +1813,31 @@ export async function handleQueue(opts: ParsedArgs): Promise<void> {
1800
1813
  console.error('[weaver] Usage: flow-weaver weaver queue add "task instruction"');
1801
1814
  process.exit(1);
1802
1815
  }
1803
- const { id, duplicate } = await queue.add({ instruction, priority: 0 });
1804
- if (duplicate) {
1805
- console.log(`[weaver] Task already queued (${id}).`);
1806
- } else {
1807
- console.log(`[weaver] Task added: ${id}`);
1808
- }
1816
+ const task = await store.create({ title: instruction, description: instruction, priority: 0, createdBy: 'user' });
1817
+ console.log(`[weaver] Task added: ${task.id}`);
1809
1818
  break;
1810
1819
  }
1811
1820
  case 'list': {
1812
- const tasks = await queue.list();
1821
+ const tasks = await store.list();
1813
1822
  if (opts.historyJson) {
1814
1823
  console.log(JSON.stringify(tasks, null, 2));
1815
1824
  } else if (tasks.length === 0) {
1816
1825
  console.log('No tasks in queue.');
1817
1826
  } else {
1818
- console.log('ID'.padEnd(10) + 'STATUS'.padEnd(12) + 'PRIORITY'.padEnd(10) + 'INSTRUCTION');
1827
+ console.log('ID'.padEnd(10) + 'STATUS'.padEnd(14) + 'PRIORITY'.padEnd(10) + 'TITLE');
1819
1828
  for (const t of tasks) {
1820
- console.log(t.id.padEnd(10) + t.status.padEnd(12) + String(t.priority).padEnd(10) + t.instruction.slice(0, 60));
1829
+ console.log(t.id.padEnd(10) + t.status.padEnd(14) + String(t.priority).padEnd(10) + t.title.slice(0, 60));
1821
1830
  }
1822
1831
  }
1823
1832
  break;
1824
1833
  }
1825
1834
  case 'clear': {
1826
- const count = await queue.clear();
1835
+ const tasks = await store.list();
1836
+ let count = 0;
1837
+ for (const t of tasks) {
1838
+ await store.update(t.id, { status: 'cancelled' });
1839
+ count++;
1840
+ }
1827
1841
  console.log(`Cleared ${count} task(s).`);
1828
1842
  break;
1829
1843
  }
@@ -1833,19 +1847,30 @@ export async function handleQueue(opts: ParsedArgs): Promise<void> {
1833
1847
  console.error('[weaver] Usage: flow-weaver weaver queue remove <id>');
1834
1848
  process.exit(1);
1835
1849
  }
1836
- const removed = await queue.remove(id);
1837
- console.log(removed ? `Removed task ${id}.` : `No task found with id "${id}".`);
1850
+ try {
1851
+ await store.update(id, { status: 'cancelled' });
1852
+ console.log(`Cancelled task ${id}.`);
1853
+ } catch {
1854
+ console.log(`No task found with id "${id}".`);
1855
+ }
1838
1856
  break;
1839
1857
  }
1840
1858
  case 'retry': {
1841
1859
  const id = opts.botFile;
1842
1860
  if (id) {
1843
- // Retry a specific task
1844
- const retried = await queue.retry(id);
1845
- console.log(retried ? `Task ${id} reset to pending.` : `No failed/running task found with id "${id}".`);
1861
+ try {
1862
+ await store.update(id, { status: 'pending' });
1863
+ console.log(`Task ${id} reset to pending.`);
1864
+ } catch {
1865
+ console.log(`No task found with id "${id}".`);
1866
+ }
1846
1867
  } else {
1847
- // Retry all failed tasks
1848
- const count = await queue.retryAll();
1868
+ const failed = await store.list({ status: 'failed' });
1869
+ let count = 0;
1870
+ for (const t of failed) {
1871
+ await store.update(t.id, { status: 'pending' });
1872
+ count++;
1873
+ }
1849
1874
  console.log(`Reset ${count} failed task(s) to pending.`);
1850
1875
  }
1851
1876
  break;
@@ -1855,15 +1880,16 @@ export async function handleQueue(opts: ParsedArgs): Promise<void> {
1855
1880
 
1856
1881
  export async function handleStatus(opts: ParsedArgs): Promise<void> {
1857
1882
  const store = new RunStore();
1858
- const { TaskQueue } = await import('./bot/task-queue.js');
1859
- const queue = new TaskQueue();
1883
+ const { TaskStore } = await import('./bot/task-store.js');
1884
+ const projectDir = process.env.WEAVER_PROJECT_DIR ?? process.cwd();
1885
+ const taskStore = new TaskStore(projectDir);
1860
1886
 
1861
1887
  const orphans = store.checkOrphans();
1862
1888
  const recentRuns = store.list({ limit: 5 });
1863
- const tasks = await queue.list();
1889
+ const tasks = await taskStore.list();
1864
1890
  const pending = tasks.filter(t => t.status === 'pending').length;
1865
- const running = tasks.filter(t => t.status === 'running').length;
1866
- const completed = tasks.filter(t => t.status === 'completed').length;
1891
+ const running = tasks.filter(t => t.status === 'in-progress').length;
1892
+ const completed = tasks.filter(t => t.status === 'done').length;
1867
1893
  const failed = tasks.filter(t => t.status === 'failed').length;
1868
1894
 
1869
1895
  if (opts.historyJson) {
@@ -2367,15 +2393,14 @@ export async function handleDoctor(opts: ParsedArgs): Promise<void> {
2367
2393
 
2368
2394
  // Queue status
2369
2395
  try {
2370
- const { TaskQueue } = await import('./bot/task-queue.js');
2371
- process.env.WEAVER_PROJECT_DIR = dir;
2372
- const queue = new TaskQueue();
2373
- const tasks = await queue.list();
2396
+ const { TaskStore } = await import('./bot/task-store.js');
2397
+ const taskStore = new TaskStore(dir);
2398
+ const tasks = await taskStore.list();
2374
2399
  const pending = tasks.filter(t => t.status === 'pending').length;
2375
- const running = tasks.filter(t => t.status === 'running').length;
2376
- checks.push({ label: 'Queue', status: 'ok', detail: `${pending} pending, ${running} running` });
2400
+ const inProgress = tasks.filter(t => t.status === 'in-progress').length;
2401
+ checks.push({ label: 'Queue', status: 'ok', detail: `${pending} pending, ${inProgress} in-progress` });
2377
2402
  } catch {
2378
- checks.push({ label: 'Queue', status: 'ok', detail: 'Empty (no queue file)' });
2403
+ checks.push({ label: 'Queue', status: 'ok', detail: 'Empty (no tasks file)' });
2379
2404
  }
2380
2405
 
2381
2406
  // Plan file
@@ -1,34 +1,51 @@
1
- ## Weaver Bot
1
+ ## Weaver Bot (Swarm)
2
2
 
3
- The Weaver bot is an autonomous AI agent that creates and modifies Flow Weaver workflows from natural language instructions.
3
+ The Weaver bot is an autonomous AI agent that creates and modifies Flow Weaver workflows. Tasks are executed via the swarm orchestrator, which routes work to the best available bot profile.
4
4
 
5
- ### Running the bot
5
+ ### Running tasks
6
6
 
7
- Use `fw_weaver_bot` with a task description:
8
- - `task`: Natural language instruction (required)
9
- - `mode`: `create` (new workflow), `modify` (edit existing), `read` (analyze), `batch` (multiple tasks)
10
- - `targets`: File paths for modify/read mode
11
- - `autoApprove`: Skip the approval gate (default: true in studio)
7
+ Use `fw_weaver_task_create` to submit work:
8
+ - `title`: Short task title (required)
9
+ - `description`: Detailed instructions
10
+ - `assignedProfile`: Target a specific bot profile
11
+ - `complexity`: trivial, simple, moderate, complex
12
+ - `subtasks`: Inline subtask definitions with dependency chaining
13
+
14
+ Then start the swarm with `fw_weaver_swarm_start` to begin execution.
12
15
 
13
16
  ### Execution flow
14
17
 
15
- 1. **Receive task** — parses instruction and determines mode
16
- 2. **Build context** — gathers project state, templates, and relevant files
17
- 3. **Plan** — AI generates a step-by-step execution plan
18
- 4. **Approval gate** — plan shown for review (skipped if autoApprove)
19
- 5. **Execute + validate + retry** — runs steps, validates output, retries on errors (up to 3 attempts)
18
+ 1. **Create task** — `fw_weaver_task_create` adds task to the pool
19
+ 2. **Orchestrator routes** — matches task to best bot profile via fast-path cascade (exact-match, capability-match, single-eligible, ai-routed, round-robin)
20
+ 3. **Build context** — gathers project state, templates, and relevant files
21
+ 4. **Plan** — AI generates a step-by-step execution plan
22
+ 5. **Execute + validate + retry** — runs steps, validates output, retries on errors (up to maxAttempts)
20
23
  6. **Git ops** — commits changes if successful
21
- 7. **Report** — returns summary with outcome
24
+ 7. **Report** — task marked done/failed with run summary
22
25
 
23
26
  ### Steering a running bot
24
27
 
25
- Use `fw_weaver_steer` to control execution:
28
+ Use `fw_weaver_steer` with a `botId` to control execution:
26
29
  - `pause` — pause at next safe point
27
30
  - `resume` — continue after pause
28
31
  - `cancel` — abort execution
29
- - `redirect` — change task mid-execution
30
- - `queue` — add a follow-up task
31
32
 
32
33
  ### Checking status
33
34
 
34
- Use `fw_weaver_status` to see the current bot session state, active task, and completion count.
35
+ - `fw_weaver_status` quick swarm summary (active bots, tasks completed, budget)
36
+ - `fw_weaver_swarm_status` — full swarm state with per-instance details
37
+ - `fw_weaver_swarm_events` — live event stream
38
+ - `fw_weaver_orchestrator_status` — routing decisions, stats, active instances
39
+
40
+ ### Profiles
41
+
42
+ Use `fw_weaver_profile_create` to create specialized bot profiles. Each profile defines:
43
+
44
+ - **capabilities** — free-form list of `{ name, description }` objects describing what the profile can do. Names are arbitrary strings (e.g. `code-generation`, `testing`, `deployment`). The orchestrator uses the description text to match tasks to profiles.
45
+ - **preferences** — intent-based settings that control profile behavior:
46
+ - `costStrategy` — `"economy"` (minimize cost), `"balanced"` (default), or `"quality"` (maximize quality regardless of cost)
47
+ - `requireApproval` — whether tasks routed to this profile need human approval before execution
48
+ - `instructions` — optional free-text instructions appended to the bot's system prompt
49
+ - **scaling** — `minInstances` and `maxInstances` control how many concurrent bots can run this profile
50
+
51
+ The orchestrator routes tasks to profiles based on `assignedProfile` or by matching task intent against profile capabilities.
@@ -4,6 +4,17 @@ The weaver bot runs workflows, executes tasks from natural language, and evolves
4
4
 
5
5
  The bot has deep knowledge of the full flow-weaver ecosystem: annotation grammar, CLI tools, node patterns, error diagnosis, and the genesis protocol (loaded dynamically from `@synergenius/flow-weaver/doc-metadata`).
6
6
 
7
+ ## Execution models
8
+
9
+ Weaver supports two execution models:
10
+
11
+ - **Single-run mode** — execute one workflow or natural-language task end-to-end via `flow-weaver weaver run` or `flow-weaver weaver bot`. Good for one-off tasks, CI pipelines, and simple automations.
12
+ - **Swarm/task model** — create tasks, define bot profiles with capabilities, and let the orchestrator route work to the best available bot instance. Multiple bots can run concurrently with budget controls and automatic retries.
13
+
14
+ The `.weaver.json` config applies to both models. Provider settings, approval gates, and notifications are shared. Swarm-specific settings (profiles, budgets, concurrency) are managed through the swarm control tools or the Studio UI.
15
+
16
+ > See [weaver-bot-usage.md](weaver-bot-usage.md) for full swarm documentation including profiles, orchestrator routing, and multi-bot workflows.
17
+
7
18
  ## Getting started
8
19
 
9
20
  Run the bot directly via CLI:
@@ -16,6 +27,15 @@ flow-weaver weaver session
16
27
 
17
28
  Or scaffold a project via `flow-weaver init` and select the "AI Workflow Runner" use case.
18
29
 
30
+ ## Profiles and .weaver.json
31
+
32
+ Bot profiles define specialized bot types with free-form capabilities, intent-based preferences, and scaling limits. Profiles are created via `fw_weaver_profile_create` and stored in the `.weaver/` directory. The `.weaver.json` config provides the base provider and approval settings that profiles inherit unless overridden.
33
+
34
+ Each profile specifies:
35
+ - **capabilities** — an array of `{ name, description }` objects. Names are free-form strings (e.g. `code-generation`, `testing`, `deployment`). The orchestrator uses descriptions to match tasks to profiles.
36
+ - **preferences** — intent-based settings: `costStrategy` (`economy`, `balanced`, `quality`), `requireApproval` (boolean), and optional `instructions` (free-text appended to the bot system prompt).
37
+ - **scaling** — `minInstances` / `maxInstances` for concurrency control.
38
+
19
39
  ## .weaver.json
20
40
 
21
41
  Place a `.weaver.json` in your project root to configure the weaver workflow:
@@ -1,34 +1,46 @@
1
- ## Task Queue & Steering
1
+ ## Task Management & Steering
2
2
 
3
- Weaver supports queuing tasks for background processing and steering running bots in real-time.
3
+ Weaver uses a swarm-based task system for background processing and real-time bot control.
4
4
 
5
- ### Task queue
5
+ ### Creating tasks
6
6
 
7
- Use `fw_weaver_queue` to manage tasks:
8
- - `add` — add a task to the queue (requires `task` instruction)
9
- - `list` — show all queued tasks
10
- - `clear` — remove all pending tasks
11
- - `remove` — remove a specific task by ID
7
+ Use `fw_weaver_task_create` to create tasks:
8
+ - `title` — short task title (required)
9
+ - `description` — detailed instructions
10
+ - `priority` — higher number = picked first (default 0)
11
+ - `assignedProfile` — route to a specific bot profile
12
+ - `complexity` — trivial, simple, moderate, complex
13
+ - `subtasks` — inline subtask definitions with `^prev` dependency shorthand
14
+ - `budgetTokens` / `budgetCost` — per-task budget limits
12
15
 
13
- Tasks are stored in NDJSON format and processed sequentially by the bot session.
16
+ ### Listing and managing tasks
17
+
18
+ - `fw_weaver_task_list` — list tasks (filter by status, parentId, botId)
19
+ - `fw_weaver_task_get` — get task details including subtasks
20
+ - `fw_weaver_task_update` — update task fields
21
+ - `fw_weaver_task_cancel` — cancel a pending or running task
22
+ - `fw_weaver_task_retry` — reset a failed task back to pending
14
23
 
15
24
  ### Steering commands
16
25
 
17
- Use `fw_weaver_steer` to control a running bot:
26
+ Use `fw_weaver_steer` to control a running bot instance:
18
27
  - `pause` — pause execution at the next safe point
19
28
  - `resume` — continue after a pause
20
29
  - `cancel` — abort the current task
21
- - `redirect` — change the task instruction mid-execution (requires `payload` with new instruction)
22
- - `queue` — add a follow-up task without interrupting the current one
23
30
 
24
- ### Batch mode
31
+ ### Swarm control
25
32
 
26
- For multiple related tasks, use `fw_weaver_bot` with `mode: "batch"` to process them in sequence through the same bot session, sharing context between tasks.
33
+ - `fw_weaver_swarm_start` start the swarm (spawns bot loops that claim and execute tasks)
34
+ - `fw_weaver_swarm_pause` — pause all bot loops
35
+ - `fw_weaver_swarm_stop` — stop the swarm gracefully
36
+ - `fw_weaver_swarm_status` — full swarm state with per-bot details
37
+ - `fw_weaver_swarm_config` — configure max concurrency, budgets, auto-retry
38
+ - `fw_weaver_swarm_events` — stream swarm-level events for live updates
27
39
 
28
40
  ### Monitoring
29
41
 
30
- Use `fw_weaver_status` to check the current session state:
31
- - Session phase (idle, planning, executing, validating)
32
- - Current task instruction
33
- - Completed task count
34
- - Error state if any
42
+ Use `fw_weaver_status` to check the current swarm state:
43
+ - Swarm phase (idle, running, paused, stopping)
44
+ - Active/total bot instances
45
+ - Tasks completed/failed
46
+ - Budget usage
package/src/index.ts CHANGED
@@ -104,14 +104,15 @@ export { WebApprovalHandler } from './bot/index.js';
104
104
  // Bot infrastructure
105
105
  export {
106
106
  SteeringController,
107
- TaskQueue,
108
- SessionStore,
107
+ TaskStore,
109
108
  buildBotSystemPrompt,
110
109
  } from './bot/index.js';
111
110
  export type {
112
111
  SteeringCommand,
113
- QueuedTask,
114
- SessionState,
112
+ Task,
113
+ TaskFilter,
114
+ CreateTaskInput,
115
+ TaskStatus,
115
116
  BotTask,
116
117
  BotPlan,
117
118
  BotPlanStep,