@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
@@ -0,0 +1,260 @@
1
+ /**
2
+ * SwarmControls — control bar for the swarm: start/pause/stop, status badge, active bots count.
3
+ * Runs in the pack sandbox — uses CommonJS require, React.createElement throughout.
4
+ */
5
+ const React = require('react');
6
+ const { useState, useCallback } = React;
7
+ const {
8
+ Flex, Button, Typography, IconButton, StatusIcon, toast, usePackWorkspace,
9
+ } = require('@fw/plugin-ui-kit');
10
+
11
+ // ---------------------------------------------------------------------------
12
+ // Types
13
+ // ---------------------------------------------------------------------------
14
+
15
+ interface InstanceInfo {
16
+ instanceId: string;
17
+ profileId: string;
18
+ status: 'idle' | 'executing' | 'paused' | 'stopped';
19
+ currentTaskId?: string;
20
+ }
21
+
22
+ interface SwarmStatus {
23
+ status: 'idle' | 'running' | 'paused' | 'stopping';
24
+ instances: Record<string, InstanceInfo>;
25
+ maxConcurrent: number;
26
+ tasksCompleted: number;
27
+ tasksFailed: number;
28
+ totalTokensUsed: number;
29
+ totalCost: number;
30
+ startedAt?: string;
31
+ }
32
+
33
+ interface SwarmControlsProps {
34
+ swarmStatus: SwarmStatus | null;
35
+ onRefresh: () => void;
36
+ }
37
+
38
+ // ---------------------------------------------------------------------------
39
+ // Helpers
40
+ // ---------------------------------------------------------------------------
41
+
42
+ function swarmStatusToIconStatus(status: string): 'pending' | 'running' | 'completed' | 'failed' {
43
+ switch (status) {
44
+ case 'running': return 'running';
45
+ case 'paused': return 'pending';
46
+ case 'stopping': return 'failed';
47
+ case 'idle':
48
+ default: return 'completed';
49
+ }
50
+ }
51
+
52
+ function statusLabel(status: string): string {
53
+ switch (status) {
54
+ case 'running': return 'Running';
55
+ case 'paused': return 'Paused';
56
+ case 'stopping': return 'Stopping';
57
+ case 'idle':
58
+ default: return 'Idle';
59
+ }
60
+ }
61
+
62
+ function countActiveInstances(instances: Record<string, InstanceInfo>): { active: number; total: number } {
63
+ const entries = Object.values(instances);
64
+ const active = entries.filter(i => i.status === 'executing').length;
65
+ return { active, total: entries.length };
66
+ }
67
+
68
+ // ---------------------------------------------------------------------------
69
+ // Component
70
+ // ---------------------------------------------------------------------------
71
+
72
+ function SwarmControls({ swarmStatus, onRefresh }: SwarmControlsProps) {
73
+ const ctx = usePackWorkspace();
74
+ const [starting, setStarting] = useState(false);
75
+ const [pausing, setPausing] = useState(false);
76
+ const [stopping, setStopping] = useState(false);
77
+
78
+ const status = swarmStatus?.status ?? 'idle';
79
+ const instances = swarmStatus?.instances ?? {};
80
+ const { active, total } = countActiveInstances(instances);
81
+
82
+ const isIdle = status === 'idle';
83
+ const isRunning = status === 'running';
84
+ const isPaused = status === 'paused';
85
+ const isStopping = status === 'stopping';
86
+
87
+ // --- Actions ---
88
+
89
+ const handleStart = useCallback(async () => {
90
+ setStarting(true);
91
+ try {
92
+ const result = await ctx.callTool('fw_weaver_swarm_start', {});
93
+ const data = result as Record<string, unknown> | null;
94
+ if (data?.error) {
95
+ toast(String(data.error), { type: 'error' });
96
+ } else {
97
+ toast('Swarm started', { type: 'success' });
98
+ }
99
+ onRefresh();
100
+ } catch (err: unknown) {
101
+ const msg = err instanceof Error ? err.message : 'Failed to start swarm';
102
+ toast(msg, { type: 'error' });
103
+ }
104
+ setStarting(false);
105
+ }, [ctx, onRefresh]);
106
+
107
+ const handlePause = useCallback(async () => {
108
+ setPausing(true);
109
+ try {
110
+ const result = await ctx.callTool('fw_weaver_swarm_pause', {});
111
+ const data = result as Record<string, unknown> | null;
112
+ if (data?.error) {
113
+ toast(String(data.error), { type: 'error' });
114
+ } else {
115
+ toast('Swarm paused', { type: 'info' });
116
+ }
117
+ onRefresh();
118
+ } catch (err: unknown) {
119
+ const msg = err instanceof Error ? err.message : 'Failed to pause swarm';
120
+ toast(msg, { type: 'error' });
121
+ }
122
+ setPausing(false);
123
+ }, [ctx, onRefresh]);
124
+
125
+ const handleResume = useCallback(async () => {
126
+ setStarting(true);
127
+ try {
128
+ const result = await ctx.callTool('fw_weaver_swarm_start', {});
129
+ const data = result as Record<string, unknown> | null;
130
+ if (data?.error) {
131
+ toast(String(data.error), { type: 'error' });
132
+ } else {
133
+ toast('Swarm resumed', { type: 'success' });
134
+ }
135
+ onRefresh();
136
+ } catch (err: unknown) {
137
+ const msg = err instanceof Error ? err.message : 'Failed to resume swarm';
138
+ toast(msg, { type: 'error' });
139
+ }
140
+ setStarting(false);
141
+ }, [ctx, onRefresh]);
142
+
143
+ const handleStop = useCallback(async () => {
144
+ setStopping(true);
145
+ const ok = await ctx.confirm('This will stop all running instances and abort active tasks.', {
146
+ title: 'Stop Swarm',
147
+ confirmLabel: 'Stop',
148
+ state: 'danger',
149
+ });
150
+ if (!ok) { setStopping(false); return; }
151
+ try {
152
+ const result = await ctx.callTool('fw_weaver_swarm_stop', {});
153
+ const data = result as Record<string, unknown> | null;
154
+ if (data?.error) {
155
+ toast(String(data.error), { type: 'error' });
156
+ } else {
157
+ toast('Swarm stopped', { type: 'info' });
158
+ }
159
+ onRefresh();
160
+ } catch (err: unknown) {
161
+ const msg = err instanceof Error ? err.message : 'Failed to stop swarm';
162
+ toast(msg, { type: 'error' });
163
+ }
164
+ setStopping(false);
165
+ }, [ctx, onRefresh]);
166
+
167
+ // --- Render ---
168
+
169
+ const anyLoading = starting || pausing || stopping;
170
+
171
+ return React.createElement(Flex, {
172
+ variant: 'row-center-space-between-nowrap-10',
173
+ style: {
174
+ padding: '8px 16px',
175
+ borderBottom: '1px solid var(--color-border-default)',
176
+ flexShrink: 0,
177
+ backgroundColor: isRunning
178
+ ? 'var(--color-brand-main-alpha-10)'
179
+ : isPaused
180
+ ? 'var(--color-status-caution-alpha-10)'
181
+ : 'transparent',
182
+ },
183
+ },
184
+ // Left: status icon + label
185
+ React.createElement(Flex, { variant: 'row-center-start-nowrap-8', style: { flexShrink: 0 } },
186
+ React.createElement(StatusIcon, {
187
+ status: swarmStatusToIconStatus(status),
188
+ size: 'sm',
189
+ }),
190
+ React.createElement(Typography, {
191
+ variant: 'caption-bold',
192
+ }, statusLabel(status)),
193
+ ),
194
+
195
+ // Center: bot count + stats
196
+ React.createElement(Flex, {
197
+ variant: 'row-center-start-nowrap-12',
198
+ style: { flex: 1 },
199
+ },
200
+ total > 0 && React.createElement(Typography, {
201
+ variant: 'caption-regular',
202
+ color: 'color-text-medium',
203
+ }, `${active}/${total} bots active`),
204
+ swarmStatus && swarmStatus.tasksCompleted > 0 && React.createElement(Typography, {
205
+ variant: 'caption-regular',
206
+ color: 'color-text-subtle',
207
+ }, `${swarmStatus.tasksCompleted} done`),
208
+ swarmStatus && swarmStatus.tasksFailed > 0 && React.createElement(Typography, {
209
+ variant: 'caption-regular',
210
+ color: 'color-status-negative',
211
+ }, `${swarmStatus.tasksFailed} failed`),
212
+ ),
213
+
214
+ // Right: action buttons
215
+ React.createElement(Flex, { variant: 'row-center-start-nowrap-4', style: { flexShrink: 0 } },
216
+ // Start / Resume button
217
+ (isIdle || isPaused) && React.createElement(Button, {
218
+ size: 'xs',
219
+ variant: 'outlined',
220
+ color: 'primary',
221
+ onClick: isPaused ? handleResume : handleStart,
222
+ loading: starting,
223
+ disabled: anyLoading,
224
+ }, isPaused ? 'Resume' : 'Start'),
225
+
226
+ // Pause button (only when running)
227
+ isRunning && React.createElement(Button, {
228
+ size: 'xs',
229
+ variant: 'outlined',
230
+ color: 'warning',
231
+ onClick: handlePause,
232
+ loading: pausing,
233
+ disabled: anyLoading,
234
+ }, 'Pause'),
235
+
236
+ // Stop button (when running or paused)
237
+ (isRunning || isPaused) && React.createElement(Button, {
238
+ size: 'xs',
239
+ variant: 'outlined',
240
+ color: 'danger',
241
+ onClick: handleStop,
242
+ loading: stopping,
243
+ disabled: anyLoading || isStopping,
244
+ }, 'Stop'),
245
+
246
+ // Refresh button (always available)
247
+ React.createElement(IconButton, {
248
+ icon: 'reset',
249
+ size: 'xs',
250
+ variant: 'outlined',
251
+ onClick: onRefresh,
252
+ disabled: anyLoading,
253
+ }),
254
+ ),
255
+ );
256
+ }
257
+
258
+ export { SwarmControls };
259
+ export default SwarmControls;
260
+ module.exports = SwarmControls;