@synergenius/flow-weaver-pack-weaver 0.9.199 → 0.9.201

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 (181) hide show
  1. package/dist/ai-chat-provider.js +5 -5
  2. package/dist/ai-chat-provider.js.map +1 -1
  3. package/dist/bot/acceptance-merge.d.ts +21 -0
  4. package/dist/bot/acceptance-merge.d.ts.map +1 -0
  5. package/dist/bot/acceptance-merge.js +46 -0
  6. package/dist/bot/acceptance-merge.js.map +1 -0
  7. package/dist/bot/ai-client.d.ts +14 -2
  8. package/dist/bot/ai-client.d.ts.map +1 -1
  9. package/dist/bot/ai-client.js +71 -24
  10. package/dist/bot/ai-client.js.map +1 -1
  11. package/dist/bot/assistant-tools.js +3 -3
  12. package/dist/bot/assistant-tools.js.map +1 -1
  13. package/dist/bot/audit-logger.d.ts.map +1 -1
  14. package/dist/bot/audit-logger.js +34 -14
  15. package/dist/bot/audit-logger.js.map +1 -1
  16. package/dist/bot/audit-trail.d.ts +67 -0
  17. package/dist/bot/audit-trail.d.ts.map +1 -0
  18. package/dist/bot/audit-trail.js +153 -0
  19. package/dist/bot/audit-trail.js.map +1 -0
  20. package/dist/bot/behavior-defaults.d.ts +1 -1
  21. package/dist/bot/behavior-defaults.d.ts.map +1 -1
  22. package/dist/bot/behavior-defaults.js +7 -3
  23. package/dist/bot/behavior-defaults.js.map +1 -1
  24. package/dist/bot/capability-registry.d.ts +9 -0
  25. package/dist/bot/capability-registry.d.ts.map +1 -1
  26. package/dist/bot/capability-registry.js +81 -27
  27. package/dist/bot/capability-registry.js.map +1 -1
  28. package/dist/bot/capability-types.d.ts +10 -0
  29. package/dist/bot/capability-types.d.ts.map +1 -1
  30. package/dist/bot/cli-provider.d.ts.map +1 -1
  31. package/dist/bot/cli-provider.js +8 -7
  32. package/dist/bot/cli-provider.js.map +1 -1
  33. package/dist/bot/preflight.d.ts +48 -0
  34. package/dist/bot/preflight.d.ts.map +1 -0
  35. package/dist/bot/preflight.js +247 -0
  36. package/dist/bot/preflight.js.map +1 -0
  37. package/dist/bot/provider-shim.d.ts +74 -0
  38. package/dist/bot/provider-shim.d.ts.map +1 -0
  39. package/dist/bot/provider-shim.js +176 -0
  40. package/dist/bot/provider-shim.js.map +1 -0
  41. package/dist/bot/runner.d.ts +2 -0
  42. package/dist/bot/runner.d.ts.map +1 -1
  43. package/dist/bot/runner.js +60 -17
  44. package/dist/bot/runner.js.map +1 -1
  45. package/dist/bot/step-executor.d.ts.map +1 -1
  46. package/dist/bot/step-executor.js +72 -115
  47. package/dist/bot/step-executor.js.map +1 -1
  48. package/dist/bot/swarm-controller.d.ts +2 -0
  49. package/dist/bot/swarm-controller.d.ts.map +1 -1
  50. package/dist/bot/swarm-controller.js +92 -20
  51. package/dist/bot/swarm-controller.js.map +1 -1
  52. package/dist/bot/task-create-handler.d.ts +37 -0
  53. package/dist/bot/task-create-handler.d.ts.map +1 -0
  54. package/dist/bot/task-create-handler.js +124 -0
  55. package/dist/bot/task-create-handler.js.map +1 -0
  56. package/dist/bot/task-store.d.ts +1 -0
  57. package/dist/bot/task-store.d.ts.map +1 -1
  58. package/dist/bot/task-store.js +67 -0
  59. package/dist/bot/task-store.js.map +1 -1
  60. package/dist/bot/types.d.ts +1 -1
  61. package/dist/bot/types.d.ts.map +1 -1
  62. package/dist/bot/weaver-tools.d.ts.map +1 -1
  63. package/dist/bot/weaver-tools.js +7 -39
  64. package/dist/bot/weaver-tools.js.map +1 -1
  65. package/dist/node-types/agent-execute.d.ts +25 -8
  66. package/dist/node-types/agent-execute.d.ts.map +1 -1
  67. package/dist/node-types/agent-execute.js +89 -23
  68. package/dist/node-types/agent-execute.js.map +1 -1
  69. package/dist/node-types/bot-report.d.ts.map +1 -1
  70. package/dist/node-types/bot-report.js +24 -3
  71. package/dist/node-types/bot-report.js.map +1 -1
  72. package/dist/node-types/plan-task.d.ts +8 -17
  73. package/dist/node-types/plan-task.d.ts.map +1 -1
  74. package/dist/node-types/plan-task.js +217 -256
  75. package/dist/node-types/plan-task.js.map +1 -1
  76. package/dist/node-types/review-result.js +8 -6
  77. package/dist/node-types/review-result.js.map +1 -1
  78. package/dist/palindrome.d.ts +9 -0
  79. package/dist/palindrome.d.ts.map +1 -0
  80. package/dist/palindrome.js +14 -0
  81. package/dist/palindrome.js.map +1 -0
  82. package/dist/ui/approval-card.js +91 -82
  83. package/dist/ui/bot-activity.js +73 -56
  84. package/dist/ui/bot-config.js +48 -31
  85. package/dist/ui/bot-dashboard.js +52 -36
  86. package/dist/ui/bot-panel.js +230 -228
  87. package/dist/ui/bot-slot-card.js +100 -90
  88. package/dist/ui/bot-status.js +37 -15
  89. package/dist/ui/budget-bar.js +57 -31
  90. package/dist/ui/capability-editor.js +447 -378
  91. package/dist/ui/chat-task-result.js +78 -71
  92. package/dist/ui/decision-log.js +68 -81
  93. package/dist/ui/genesis-block.js +86 -95
  94. package/dist/ui/instance-stream-view.js +722 -0
  95. package/dist/ui/profile-card.js +96 -221
  96. package/dist/ui/profile-editor.js +532 -575
  97. package/dist/ui/settings-section.js +41 -45
  98. package/dist/ui/swarm-controls.js +212 -135
  99. package/dist/ui/swarm-dashboard.js +3992 -2715
  100. package/dist/ui/task-detail-view.js +415 -521
  101. package/dist/ui/task-editor.js +339 -390
  102. package/dist/ui/task-pool-list.js +60 -55
  103. package/dist/workflows/src/palindrome.d.ts +11 -0
  104. package/dist/workflows/src/palindrome.d.ts.map +1 -0
  105. package/dist/workflows/src/palindrome.js +16 -0
  106. package/dist/workflows/src/palindrome.js.map +1 -0
  107. package/dist/workflows/tests/palindrome.test.d.ts +2 -0
  108. package/dist/workflows/tests/palindrome.test.d.ts.map +1 -0
  109. package/dist/workflows/tests/palindrome.test.js +41 -0
  110. package/dist/workflows/tests/palindrome.test.js.map +1 -0
  111. package/dist/workflows/weaver-bot-batch.js +1 -1
  112. package/dist/workflows/weaver-bot-batch.js.map +1 -1
  113. package/dist/workflows/weaver-bot.js +1 -1
  114. package/dist/workflows/weaver-bot.js.map +1 -1
  115. package/flowweaver.manifest.json +1 -1
  116. package/package.json +8 -2
  117. package/src/ai-chat-provider.ts +5 -5
  118. package/src/bot/acceptance-merge.ts +62 -0
  119. package/src/bot/ai-client.ts +77 -21
  120. package/src/bot/assistant-tools.ts +3 -3
  121. package/src/bot/audit-logger.ts +42 -14
  122. package/src/bot/audit-trail.ts +211 -0
  123. package/src/bot/behavior-defaults.ts +7 -2
  124. package/src/bot/capability-registry.ts +84 -28
  125. package/src/bot/capability-types.ts +11 -0
  126. package/src/bot/cli-provider.ts +8 -7
  127. package/src/bot/preflight.ts +285 -0
  128. package/src/bot/provider-shim.ts +218 -0
  129. package/src/bot/runner.ts +68 -20
  130. package/src/bot/step-executor.ts +69 -127
  131. package/src/bot/swarm-controller.ts +94 -20
  132. package/src/bot/task-create-handler.ts +164 -0
  133. package/src/bot/task-store.ts +83 -0
  134. package/src/bot/types.ts +4 -1
  135. package/src/bot/weaver-tools.ts +7 -45
  136. package/src/node-types/agent-execute.ts +102 -16
  137. package/src/node-types/bot-report.ts +24 -3
  138. package/src/node-types/plan-task.ts +238 -280
  139. package/src/node-types/review-result.ts +8 -6
  140. package/src/palindrome.ts +14 -0
  141. package/src/ui/approval-card.tsx +78 -62
  142. package/src/ui/bot-activity.tsx +12 -10
  143. package/src/ui/bot-config.tsx +12 -10
  144. package/src/ui/bot-dashboard.tsx +13 -11
  145. package/src/ui/bot-panel.tsx +189 -171
  146. package/src/ui/bot-slot-card.tsx +125 -70
  147. package/src/ui/bot-status.tsx +4 -4
  148. package/src/ui/budget-bar.tsx +86 -25
  149. package/src/ui/capability-editor.tsx +392 -257
  150. package/src/ui/chat-task-result.tsx +81 -78
  151. package/src/ui/decision-log.tsx +76 -73
  152. package/src/ui/genesis-block.tsx +91 -61
  153. package/src/ui/instance-stream-view.tsx +861 -0
  154. package/src/ui/profile-card.tsx +195 -168
  155. package/src/ui/profile-editor.tsx +453 -370
  156. package/src/ui/settings-section.tsx +46 -39
  157. package/src/ui/swarm-controls.tsx +252 -123
  158. package/src/ui/swarm-dashboard.tsx +999 -466
  159. package/src/ui/task-detail-view.tsx +485 -428
  160. package/src/ui/task-editor.tsx +329 -271
  161. package/src/ui/task-pool-list.tsx +68 -62
  162. package/src/workflows/src/palindrome.ts +16 -0
  163. package/src/workflows/tests/palindrome.test.ts +49 -0
  164. package/src/workflows/weaver-bot-batch.ts +1 -1
  165. package/src/workflows/weaver-bot.ts +1 -1
  166. package/dist/ui/bot-constants.d.ts +0 -14
  167. package/dist/ui/bot-constants.d.ts.map +0 -1
  168. package/dist/ui/bot-constants.js +0 -189
  169. package/dist/ui/bot-constants.js.map +0 -1
  170. package/dist/ui/steer-api.d.ts +0 -7
  171. package/dist/ui/steer-api.d.ts.map +0 -1
  172. package/dist/ui/steer-api.js +0 -11
  173. package/dist/ui/steer-api.js.map +0 -1
  174. package/dist/ui/trace-to-timeline.d.ts +0 -91
  175. package/dist/ui/trace-to-timeline.d.ts.map +0 -1
  176. package/dist/ui/trace-to-timeline.js +0 -116
  177. package/dist/ui/trace-to-timeline.js.map +0 -1
  178. package/dist/ui/use-stream-timeline.d.ts +0 -50
  179. package/dist/ui/use-stream-timeline.d.ts.map +0 -1
  180. package/dist/ui/use-stream-timeline.js +0 -245
  181. package/dist/ui/use-stream-timeline.js.map +0 -1
@@ -24,22 +24,22 @@ __export(settings_section_exports, {
24
24
  default: () => settings_section_default
25
25
  });
26
26
  module.exports = __toCommonJS(settings_section_exports);
27
- var React = require("react");
28
- var { useState, useEffect, useCallback } = React;
29
- var { Flex, Typography, Button, CollapsibleSection, KeyValueRow, toast } = require("@fw/plugin-ui-kit");
27
+ var import_react = require("react");
28
+ var import_plugin_ui_kit = require("@fw/plugin-ui-kit");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
30
  function SettingsSection({ callTool, dispatchEvent }) {
31
- const [providers, setProviders] = useState([]);
32
- const [insights, setInsights] = useState(null);
33
- const handleClear = useCallback(() => {
31
+ const [providers, setProviders] = (0, import_react.useState)([]);
32
+ const [insights, setInsights] = (0, import_react.useState)(null);
33
+ const handleClear = (0, import_react.useCallback)(() => {
34
34
  if (!confirm("Clear all bot run history? This action cannot be undone.")) return;
35
35
  callTool("fw_weaver_history", { clear: true }).then(() => {
36
36
  dispatchEvent("fw:refresh-bot-workspace");
37
- toast("Run history cleared", { type: "success" });
37
+ (0, import_plugin_ui_kit.toast)("Run history cleared", { type: "success" });
38
38
  }).catch(() => {
39
- toast("Failed to clear history", { type: "error" });
39
+ (0, import_plugin_ui_kit.toast)("Failed to clear history", { type: "error" });
40
40
  });
41
41
  }, [callTool, dispatchEvent]);
42
- useEffect(() => {
42
+ (0, import_react.useEffect)(() => {
43
43
  Promise.all([
44
44
  callTool("fw_weaver_providers"),
45
45
  callTool("fw_weaver_insights")
@@ -51,54 +51,50 @@ function SettingsSection({ callTool, dispatchEvent }) {
51
51
  const activeProvider = providers.find((p) => p.envVarsSet) ?? providers[0];
52
52
  const trustScore = insights?.trust?.score;
53
53
  const trustDisplay = trustScore != null ? (trustScore <= 1 ? (trustScore * 100).toFixed(0) : Math.round(trustScore)) + "%" : "\u2014";
54
- return React.createElement(
55
- CollapsibleSection,
56
- {
57
- title: "Settings",
58
- variant: "list",
59
- defaultExpanded: false
60
- },
61
- React.createElement(
62
- Flex,
63
- { variant: "column-start-start-nowrap-4", style: { width: "100%" } },
64
- activeProvider && React.createElement(KeyValueRow, {
54
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.CollapsibleSection, { title: "Settings", variant: "list", defaultExpanded: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "column-start-start-nowrap-4", style: { width: "100%" }, children: [
55
+ activeProvider && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
+ import_plugin_ui_kit.KeyValueRow,
57
+ {
65
58
  keyName: "Provider",
66
59
  value: `${activeProvider.name} (${activeProvider.source})`,
67
60
  size: "small"
68
- }),
69
- insights?.trust && React.createElement(KeyValueRow, {
61
+ }
62
+ ),
63
+ insights?.trust && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
+ import_plugin_ui_kit.KeyValueRow,
65
+ {
70
66
  keyName: "Trust",
71
67
  value: `Phase ${insights.trust.phase} \xB7 ${trustDisplay}`,
72
68
  size: "small"
73
- }),
74
- insights?.health && React.createElement(KeyValueRow, {
69
+ }
70
+ ),
71
+ insights?.health && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
72
+ import_plugin_ui_kit.KeyValueRow,
73
+ {
75
74
  keyName: "Health",
76
75
  value: `${insights.health.overall}/100`,
77
76
  size: "small"
78
- }),
79
- insights?.cost && React.createElement(KeyValueRow, {
77
+ }
78
+ ),
79
+ insights?.cost && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
+ import_plugin_ui_kit.KeyValueRow,
81
+ {
80
82
  keyName: "Cost (7d)",
81
83
  value: `$${insights.cost.last7Days?.toFixed(2) ?? "0.00"} \xB7 ${insights.cost.trend ?? "stable"}`,
82
84
  size: "small"
83
- }),
84
- React.createElement(
85
- Flex,
86
- {
87
- variant: "row-center-space-between-nowrap-8",
88
- style: { width: "100%", marginTop: "4px" }
89
- },
90
- React.createElement(Button, {
91
- size: "xs",
92
- variant: "outlined",
93
- color: "danger",
94
- onClick: handleClear
95
- }, "Clear Run History"),
96
- React.createElement(Typography, {
97
- variant: "smallCaption-regular",
98
- color: "color-text-subtle"
99
- }, "Edit settings in .weaver.json")
100
- )
85
+ }
86
+ ),
87
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
88
+ import_plugin_ui_kit.Flex,
89
+ {
90
+ variant: "row-center-space-between-nowrap-8",
91
+ style: { width: "100%", marginTop: "4px" },
92
+ children: [
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Button, { size: "xs", variant: "outlined", color: "danger", onClick: handleClear, children: "Clear Run History" }),
94
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "smallCaption-regular", color: "color-text-subtle", children: "Edit settings in .weaver.json" })
95
+ ]
96
+ }
101
97
  )
102
- );
98
+ ] }) });
103
99
  }
104
100
  var settings_section_default = SettingsSection;
@@ -24,17 +24,9 @@ __export(swarm_controls_exports, {
24
24
  default: () => swarm_controls_default
25
25
  });
26
26
  module.exports = __toCommonJS(swarm_controls_exports);
27
- var React = require("react");
28
- var { useState, useCallback } = React;
29
- var {
30
- Flex,
31
- Button,
32
- Typography,
33
- IconButton,
34
- StatusIcon,
35
- toast,
36
- usePackWorkspace
37
- } = require("@fw/plugin-ui-kit");
27
+ var import_react = require("react");
28
+ var import_plugin_ui_kit = require("@fw/plugin-ui-kit");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
38
30
  function swarmStatusToIconStatus(status) {
39
31
  switch (status) {
40
32
  case "running":
@@ -67,10 +59,16 @@ function countActiveInstances(instances) {
67
59
  return { active, total: entries.length };
68
60
  }
69
61
  function SwarmControls({ swarmStatus, onRefresh }) {
70
- const ctx = usePackWorkspace();
71
- const [starting, setStarting] = useState(false);
72
- const [pausing, setPausing] = useState(false);
73
- const [stopping, setStopping] = useState(false);
62
+ const ctx = (0, import_plugin_ui_kit.usePackWorkspace)();
63
+ const [starting, setStarting] = (0, import_react.useState)(false);
64
+ const [pausing, setPausing] = (0, import_react.useState)(false);
65
+ const [stopping, setStopping] = (0, import_react.useState)(false);
66
+ const [showStartConfig, setShowStartConfig] = (0, import_react.useState)(false);
67
+ const [maxConcurrent, setMaxConcurrent] = (0, import_react.useState)(5);
68
+ const [sessionTokenBudget, setSessionTokenBudget] = (0, import_react.useState)("");
69
+ const [sessionCostBudget, setSessionCostBudget] = (0, import_react.useState)("");
70
+ const [editingConcurrency, setEditingConcurrency] = (0, import_react.useState)(false);
71
+ const [liveConcurrency, setLiveConcurrency] = (0, import_react.useState)("");
74
72
  const status = swarmStatus?.status ?? "idle";
75
73
  const instances = swarmStatus?.instances ?? {};
76
74
  const { active, total } = countActiveInstances(instances);
@@ -78,58 +76,52 @@ function SwarmControls({ swarmStatus, onRefresh }) {
78
76
  const isRunning = status === "running";
79
77
  const isPaused = status === "paused";
80
78
  const isStopping = status === "stopping";
81
- const handleStart = useCallback(async () => {
79
+ const handleStartWithConfig = (0, import_react.useCallback)(async () => {
82
80
  setStarting(true);
83
81
  try {
84
- const result = await ctx.callTool("fw_weaver_swarm_start", {});
82
+ const args = {};
83
+ if (maxConcurrent > 0) args.maxConcurrent = maxConcurrent;
84
+ const st = parseInt(sessionTokenBudget, 10);
85
+ if (st > 0) args.sessionBudgetTokens = st;
86
+ const sc = parseFloat(sessionCostBudget);
87
+ if (sc > 0) args.sessionBudgetCost = sc;
88
+ const result = await ctx.callTool("fw_weaver_swarm_start", args);
85
89
  const data = result;
86
90
  if (data?.error) {
87
- toast(String(data.error), { type: "error" });
91
+ (0, import_plugin_ui_kit.toast)(String(data.error), { type: "error" });
88
92
  } else {
89
- toast("Swarm started", { type: "success" });
93
+ (0, import_plugin_ui_kit.toast)("Swarm started", { type: "success" });
94
+ setShowStartConfig(false);
90
95
  }
91
96
  onRefresh();
92
97
  } catch (err) {
93
- const msg = err instanceof Error ? err.message : "Failed to start swarm";
94
- toast(msg, { type: "error" });
98
+ (0, import_plugin_ui_kit.toast)(err instanceof Error ? err.message : "Failed to start swarm", { type: "error" });
95
99
  }
96
100
  setStarting(false);
97
- }, [ctx, onRefresh]);
98
- const handlePause = useCallback(async () => {
101
+ }, [ctx, onRefresh, maxConcurrent, sessionTokenBudget, sessionCostBudget]);
102
+ const handlePause = (0, import_react.useCallback)(async () => {
99
103
  setPausing(true);
100
104
  try {
101
- const result = await ctx.callTool("fw_weaver_swarm_pause", {});
102
- const data = result;
103
- if (data?.error) {
104
- toast(String(data.error), { type: "error" });
105
- } else {
106
- toast("Swarm paused", { type: "info" });
107
- }
105
+ await ctx.callTool("fw_weaver_swarm_pause", {});
106
+ (0, import_plugin_ui_kit.toast)("Swarm paused", { type: "info" });
108
107
  onRefresh();
109
108
  } catch (err) {
110
- const msg = err instanceof Error ? err.message : "Failed to pause swarm";
111
- toast(msg, { type: "error" });
109
+ (0, import_plugin_ui_kit.toast)(err instanceof Error ? err.message : "Failed to pause", { type: "error" });
112
110
  }
113
111
  setPausing(false);
114
112
  }, [ctx, onRefresh]);
115
- const handleResume = useCallback(async () => {
113
+ const handleResume = (0, import_react.useCallback)(async () => {
116
114
  setStarting(true);
117
115
  try {
118
- const result = await ctx.callTool("fw_weaver_swarm_start", {});
119
- const data = result;
120
- if (data?.error) {
121
- toast(String(data.error), { type: "error" });
122
- } else {
123
- toast("Swarm resumed", { type: "success" });
124
- }
116
+ await ctx.callTool("fw_weaver_swarm_start", {});
117
+ (0, import_plugin_ui_kit.toast)("Swarm resumed", { type: "success" });
125
118
  onRefresh();
126
119
  } catch (err) {
127
- const msg = err instanceof Error ? err.message : "Failed to resume swarm";
128
- toast(msg, { type: "error" });
120
+ (0, import_plugin_ui_kit.toast)(err instanceof Error ? err.message : "Failed to resume", { type: "error" });
129
121
  }
130
122
  setStarting(false);
131
123
  }, [ctx, onRefresh]);
132
- const handleStop = useCallback(async () => {
124
+ const handleStop = (0, import_react.useCallback)(async () => {
133
125
  setStopping(true);
134
126
  const ok = await ctx.confirm("This will stop all running instances and abort active tasks.", {
135
127
  title: "Stop Swarm",
@@ -141,105 +133,190 @@ function SwarmControls({ swarmStatus, onRefresh }) {
141
133
  return;
142
134
  }
143
135
  try {
144
- const result = await ctx.callTool("fw_weaver_swarm_stop", {});
145
- const data = result;
146
- if (data?.error) {
147
- toast(String(data.error), { type: "error" });
148
- } else {
149
- toast("Swarm stopped", { type: "info" });
150
- }
136
+ await ctx.callTool("fw_weaver_swarm_stop", {});
137
+ (0, import_plugin_ui_kit.toast)("Swarm stopped", { type: "info" });
151
138
  onRefresh();
152
139
  } catch (err) {
153
- const msg = err instanceof Error ? err.message : "Failed to stop swarm";
154
- toast(msg, { type: "error" });
140
+ (0, import_plugin_ui_kit.toast)(err instanceof Error ? err.message : "Failed to stop", { type: "error" });
155
141
  }
156
142
  setStopping(false);
157
143
  }, [ctx, onRefresh]);
144
+ const handleConcurrencyChange = (0, import_react.useCallback)(async () => {
145
+ const mc = parseInt(liveConcurrency, 10);
146
+ if (!mc || mc < 1) {
147
+ setEditingConcurrency(false);
148
+ return;
149
+ }
150
+ try {
151
+ await ctx.callTool("fw_weaver_swarm_config", { maxConcurrent: mc });
152
+ (0, import_plugin_ui_kit.toast)(`Max concurrency set to ${mc}`, { type: "success" });
153
+ onRefresh();
154
+ } catch (err) {
155
+ (0, import_plugin_ui_kit.toast)(err instanceof Error ? err.message : "Failed to update config", { type: "error" });
156
+ }
157
+ setEditingConcurrency(false);
158
+ }, [ctx, onRefresh, liveConcurrency]);
158
159
  const anyLoading = starting || pausing || stopping;
159
- return React.createElement(
160
- Flex,
161
- {
162
- variant: "row-center-space-between-nowrap-10",
163
- style: {
164
- padding: "8px 16px",
165
- borderBottom: "1px solid var(--color-border-default)",
166
- flexShrink: 0,
167
- backgroundColor: isRunning ? "var(--color-brand-main-alpha-10)" : isPaused ? "var(--color-status-caution-alpha-10)" : "transparent"
168
- }
169
- },
170
- // Left: status icon + label
171
- React.createElement(
172
- Flex,
173
- { variant: "row-center-start-nowrap-8", style: { flexShrink: 0 } },
174
- React.createElement(StatusIcon, {
175
- status: swarmStatusToIconStatus(status),
176
- size: "sm"
177
- }),
178
- React.createElement(Typography, {
179
- variant: "caption-bold"
180
- }, statusLabel(status))
181
- ),
182
- // Center: bot count + stats
183
- React.createElement(
184
- Flex,
160
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "column-stretch-start-nowrap-0", children: [
161
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
162
+ import_plugin_ui_kit.Section,
185
163
  {
186
- variant: "row-center-start-nowrap-12",
187
- style: { flex: 1 }
188
- },
189
- total > 0 && React.createElement(Typography, {
190
- variant: "caption-regular",
191
- color: "color-text-medium"
192
- }, `${active}/${total} bots active`),
193
- swarmStatus && swarmStatus.tasksCompleted > 0 && React.createElement(Typography, {
194
- variant: "caption-regular",
195
- color: "color-text-subtle"
196
- }, `${swarmStatus.tasksCompleted} done`),
197
- swarmStatus && swarmStatus.runsIncomplete > 0 && React.createElement(Typography, {
198
- variant: "caption-regular",
199
- color: "color-status-negative"
200
- }, `${swarmStatus.runsIncomplete} incomplete`)
164
+ padding: "compact",
165
+ border: "bottom",
166
+ shrink: true,
167
+ background: isRunning ? "none" : isPaused ? "none" : "none",
168
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "row-center-space-between-nowrap-10", children: [
169
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "row-center-start-nowrap-8", children: [
170
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
171
+ import_plugin_ui_kit.StatusIcon,
172
+ {
173
+ status: swarmStatusToIconStatus(status),
174
+ size: "sm"
175
+ }
176
+ ),
177
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-bold", children: statusLabel(status) })
178
+ ] }),
179
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "row-center-start-nowrap-12", children: [
180
+ total > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-regular", color: "color-text-medium", children: `${active}/${total} bots active` }),
181
+ (isRunning || isPaused) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-regular", color: "color-text-subtle", children: `max ${swarmStatus?.maxConcurrent ?? "?"}` }),
182
+ swarmStatus && swarmStatus.tasksCompleted > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-regular", color: "color-text-subtle", children: `${swarmStatus.tasksCompleted} done` }),
183
+ swarmStatus && swarmStatus.runsIncomplete > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-regular", color: "color-status-negative", children: `${swarmStatus.runsIncomplete} incomplete` })
184
+ ] }),
185
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "row-center-start-nowrap-4", children: [
186
+ isIdle && !showStartConfig && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
187
+ import_plugin_ui_kit.Button,
188
+ {
189
+ size: "xs",
190
+ variant: "outlined",
191
+ color: "primary",
192
+ onClick: () => setShowStartConfig(true),
193
+ disabled: anyLoading,
194
+ children: "Start"
195
+ }
196
+ ),
197
+ isPaused && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
198
+ import_plugin_ui_kit.Button,
199
+ {
200
+ size: "xs",
201
+ variant: "outlined",
202
+ color: "primary",
203
+ onClick: handleResume,
204
+ loading: starting,
205
+ disabled: anyLoading,
206
+ children: "Resume"
207
+ }
208
+ ),
209
+ isRunning && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
210
+ import_plugin_ui_kit.Button,
211
+ {
212
+ size: "xs",
213
+ variant: "outlined",
214
+ color: "warning",
215
+ onClick: handlePause,
216
+ loading: pausing,
217
+ disabled: anyLoading,
218
+ children: "Pause"
219
+ }
220
+ ),
221
+ (isRunning || isPaused) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
222
+ import_plugin_ui_kit.Button,
223
+ {
224
+ size: "xs",
225
+ variant: "outlined",
226
+ color: "danger",
227
+ onClick: handleStop,
228
+ loading: stopping,
229
+ disabled: anyLoading || isStopping,
230
+ children: "Stop"
231
+ }
232
+ ),
233
+ isIdle && showStartConfig && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
234
+ import_plugin_ui_kit.IconButton,
235
+ {
236
+ icon: "close",
237
+ size: "xs",
238
+ variant: "clear",
239
+ onClick: () => setShowStartConfig(false)
240
+ }
241
+ ),
242
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
243
+ import_plugin_ui_kit.IconButton,
244
+ {
245
+ icon: "reset",
246
+ size: "xs",
247
+ variant: "outlined",
248
+ onClick: onRefresh,
249
+ disabled: anyLoading
250
+ }
251
+ )
252
+ ] })
253
+ ] })
254
+ }
201
255
  ),
202
- // Right: action buttons
203
- React.createElement(
204
- Flex,
205
- { variant: "row-center-start-nowrap-4", style: { flexShrink: 0 } },
206
- // Start / Resume button
207
- (isIdle || isPaused) && React.createElement(Button, {
208
- size: "xs",
209
- variant: "outlined",
210
- color: "primary",
211
- onClick: isPaused ? handleResume : handleStart,
212
- loading: starting,
213
- disabled: anyLoading
214
- }, isPaused ? "Resume" : "Start"),
215
- // Pause button (only when running)
216
- isRunning && React.createElement(Button, {
217
- size: "xs",
218
- variant: "outlined",
219
- color: "warning",
220
- onClick: handlePause,
221
- loading: pausing,
222
- disabled: anyLoading
223
- }, "Pause"),
224
- // Stop button (when running or paused)
225
- (isRunning || isPaused) && React.createElement(Button, {
226
- size: "xs",
227
- variant: "outlined",
228
- color: "danger",
229
- onClick: handleStop,
230
- loading: stopping,
231
- disabled: anyLoading || isStopping
232
- }, "Stop"),
233
- // Refresh button (always available)
234
- React.createElement(IconButton, {
235
- icon: "reset",
236
- size: "xs",
237
- variant: "outlined",
238
- onClick: onRefresh,
239
- disabled: anyLoading
240
- })
241
- )
242
- );
256
+ isIdle && showStartConfig && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Section, { padding: "default", border: "bottom", shrink: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "column-stretch-start-nowrap-8", children: [
257
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-thick", color: "color-text-high", children: "Start Configuration" }),
258
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "row-center-start-nowrap-12", children: [
259
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "row-center-start-nowrap-8", children: [
260
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "smallCaption-regular", color: "color-text-subtle", children: "Max" }),
261
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
262
+ import_plugin_ui_kit.Slider,
263
+ {
264
+ value: maxConcurrent,
265
+ min: 1,
266
+ max: 20,
267
+ step: 1,
268
+ onChange: (val) => setMaxConcurrent(val)
269
+ }
270
+ ),
271
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-thick", color: "color-text-high", children: maxConcurrent })
272
+ ] }),
273
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Field, { label: "Token Budget", labelWidth: 100, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
274
+ import_plugin_ui_kit.Input,
275
+ {
276
+ value: sessionTokenBudget,
277
+ onChange: (value) => setSessionTokenBudget(value),
278
+ type: "number",
279
+ size: "small",
280
+ placeholder: "No limit"
281
+ }
282
+ ) }),
283
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Field, { label: "Cost Budget ($)", labelWidth: 100, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
284
+ import_plugin_ui_kit.Input,
285
+ {
286
+ value: sessionCostBudget,
287
+ onChange: (value) => setSessionCostBudget(value),
288
+ type: "number",
289
+ size: "small",
290
+ placeholder: "No limit"
291
+ }
292
+ ) })
293
+ ] }),
294
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "row-center-start-nowrap-8", children: [
295
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
296
+ import_plugin_ui_kit.Button,
297
+ {
298
+ size: "xs",
299
+ variant: "fill",
300
+ color: "primary",
301
+ onClick: handleStartWithConfig,
302
+ loading: starting,
303
+ disabled: anyLoading,
304
+ leftIcon: "playArrow",
305
+ children: "Start Swarm"
306
+ }
307
+ ),
308
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
309
+ import_plugin_ui_kit.Button,
310
+ {
311
+ size: "xs",
312
+ variant: "clear",
313
+ color: "secondary",
314
+ onClick: () => setShowStartConfig(false),
315
+ children: "Cancel"
316
+ }
317
+ )
318
+ ] })
319
+ ] }) })
320
+ ] });
243
321
  }
244
322
  var swarm_controls_default = SwarmControls;
245
- module.exports = SwarmControls;