@synergenius/flow-weaver-pack-weaver 0.9.62 → 0.9.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-chat-provider.d.ts +12 -0
- package/dist/ai-chat-provider.d.ts.map +1 -1
- package/dist/ai-chat-provider.js +173 -19
- package/dist/ai-chat-provider.js.map +1 -1
- package/dist/bot/agent-loop.d.ts +20 -0
- package/dist/bot/agent-loop.d.ts.map +1 -0
- package/dist/bot/agent-loop.js +331 -0
- package/dist/bot/agent-loop.js.map +1 -0
- package/dist/bot/ai-router.d.ts +19 -0
- package/dist/bot/ai-router.d.ts.map +1 -0
- package/dist/bot/ai-router.js +104 -0
- package/dist/bot/ai-router.js.map +1 -0
- package/dist/bot/bot-registry.js +2 -2
- package/dist/bot/bot-registry.js.map +1 -1
- package/dist/bot/conversation-store.d.ts +1 -0
- package/dist/bot/conversation-store.d.ts.map +1 -1
- package/dist/bot/conversation-store.js.map +1 -1
- package/dist/bot/improve-loop.js.map +1 -1
- package/dist/bot/instance-manager.d.ts +31 -0
- package/dist/bot/instance-manager.d.ts.map +1 -0
- package/dist/bot/instance-manager.js +115 -0
- package/dist/bot/instance-manager.js.map +1 -0
- package/dist/bot/orchestrator.d.ts +36 -0
- package/dist/bot/orchestrator.d.ts.map +1 -0
- package/dist/bot/orchestrator.js +176 -0
- package/dist/bot/orchestrator.js.map +1 -0
- package/dist/bot/profile-store.d.ts +36 -0
- package/dist/bot/profile-store.d.ts.map +1 -0
- package/dist/bot/profile-store.js +208 -0
- package/dist/bot/profile-store.js.map +1 -0
- package/dist/bot/profile-types.d.ts +126 -0
- package/dist/bot/profile-types.d.ts.map +1 -0
- package/dist/bot/profile-types.js +7 -0
- package/dist/bot/profile-types.js.map +1 -0
- package/dist/bot/session-state.d.ts +25 -0
- package/dist/bot/session-state.d.ts.map +1 -0
- package/dist/bot/session-state.js +110 -0
- package/dist/bot/session-state.js.map +1 -0
- package/dist/bot/swarm-controller.d.ts +37 -21
- package/dist/bot/swarm-controller.d.ts.map +1 -1
- package/dist/bot/swarm-controller.js +344 -163
- package/dist/bot/swarm-controller.js.map +1 -1
- package/dist/bot/task-prompt-builder.d.ts +2 -1
- package/dist/bot/task-prompt-builder.d.ts.map +1 -1
- package/dist/bot/task-prompt-builder.js +33 -10
- package/dist/bot/task-prompt-builder.js.map +1 -1
- package/dist/bot/task-queue.d.ts +46 -0
- package/dist/bot/task-queue.d.ts.map +1 -0
- package/dist/bot/task-queue.js +237 -0
- package/dist/bot/task-queue.js.map +1 -0
- package/dist/bot/task-store.d.ts +1 -6
- package/dist/bot/task-store.d.ts.map +1 -1
- package/dist/bot/task-store.js +27 -78
- package/dist/bot/task-store.js.map +1 -1
- package/dist/bot/task-types.d.ts +8 -4
- package/dist/bot/task-types.d.ts.map +1 -1
- package/dist/cli-handlers.d.ts.map +1 -1
- package/dist/cli-handlers.js +2 -3
- package/dist/cli-handlers.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +749 -0
- package/dist/cli.js.map +1 -0
- package/dist/docs/docs/weaver-bot-usage.md +35 -18
- package/dist/docs/docs/weaver-config.md +20 -0
- package/dist/docs/docs/weaver-task-queue.md +31 -19
- package/dist/docs/weaver-config.md +15 -9
- package/dist/mcp-tools.d.ts +17 -0
- package/dist/mcp-tools.d.ts.map +1 -1
- package/dist/mcp-tools.js +98 -232
- package/dist/mcp-tools.js.map +1 -1
- package/dist/node-types/orchestrator-dispatch.d.ts +17 -0
- package/dist/node-types/orchestrator-dispatch.d.ts.map +1 -0
- package/dist/node-types/orchestrator-dispatch.js +63 -0
- package/dist/node-types/orchestrator-dispatch.js.map +1 -0
- package/dist/node-types/orchestrator-load-state.d.ts +16 -0
- package/dist/node-types/orchestrator-load-state.d.ts.map +1 -0
- package/dist/node-types/orchestrator-load-state.js +60 -0
- package/dist/node-types/orchestrator-load-state.js.map +1 -0
- package/dist/node-types/orchestrator-route.d.ts +16 -0
- package/dist/node-types/orchestrator-route.d.ts.map +1 -0
- package/dist/node-types/orchestrator-route.js +28 -0
- package/dist/node-types/orchestrator-route.js.map +1 -0
- package/dist/node-types/receive-task.d.ts +2 -3
- package/dist/node-types/receive-task.d.ts.map +1 -1
- package/dist/node-types/receive-task.js +3 -28
- package/dist/node-types/receive-task.js.map +1 -1
- package/dist/templates/weaver-template.d.ts +11 -0
- package/dist/templates/weaver-template.d.ts.map +1 -0
- package/dist/templates/weaver-template.js +53 -0
- package/dist/templates/weaver-template.js.map +1 -0
- package/dist/ui/bot-constants.d.ts +14 -0
- package/dist/ui/bot-constants.d.ts.map +1 -0
- package/dist/ui/bot-constants.js +189 -0
- package/dist/ui/bot-constants.js.map +1 -0
- package/dist/ui/bot-panel.js +51 -90
- package/dist/ui/bot-slot-card.js +87 -122
- package/dist/ui/budget-bar.js +5 -3
- package/dist/ui/chat-task-result.js +4 -7
- package/dist/ui/decision-log.js +136 -0
- package/dist/ui/profile-card.js +158 -0
- package/dist/ui/profile-editor.js +597 -0
- package/dist/ui/swarm-controls.js +36 -27
- package/dist/ui/swarm-dashboard.js +2034 -736
- package/dist/ui/task-create-form.js +39 -116
- package/dist/ui/task-detail-view.js +490 -239
- package/dist/ui/task-pool-list.js +69 -94
- package/dist/workflows/orchestrator.d.ts +21 -0
- package/dist/workflows/orchestrator.d.ts.map +1 -0
- package/dist/workflows/orchestrator.js +281 -0
- package/dist/workflows/orchestrator.js.map +1 -0
- package/dist/workflows/weaver-bot-session.d.ts +65 -0
- package/dist/workflows/weaver-bot-session.d.ts.map +1 -0
- package/dist/workflows/weaver-bot-session.js +68 -0
- package/dist/workflows/weaver-bot-session.js.map +1 -0
- package/dist/workflows/weaver.d.ts +24 -0
- package/dist/workflows/weaver.d.ts.map +1 -0
- package/dist/workflows/weaver.js +28 -0
- package/dist/workflows/weaver.js.map +1 -0
- package/flowweaver.manifest.json +253 -66
- package/package.json +1 -1
- package/src/ai-chat-provider.ts +184 -18
- package/src/bot/ai-router.ts +132 -0
- package/src/bot/bot-registry.ts +2 -2
- package/src/bot/conversation-store.ts +2 -1
- package/src/bot/improve-loop.ts +6 -6
- package/src/bot/instance-manager.ts +128 -0
- package/src/bot/orchestrator.ts +244 -0
- package/src/bot/profile-store.ts +225 -0
- package/src/bot/profile-types.ts +141 -0
- package/src/bot/swarm-controller.ts +385 -186
- package/src/bot/task-prompt-builder.ts +37 -6
- package/src/bot/task-store.ts +28 -89
- package/src/bot/task-types.ts +10 -4
- package/src/cli-handlers.ts +2 -3
- package/src/docs/weaver-bot-usage.md +35 -18
- package/src/docs/weaver-config.md +20 -0
- package/src/docs/weaver-task-queue.md +31 -19
- package/src/mcp-tools.ts +129 -320
- package/src/node-types/orchestrator-dispatch.ts +71 -0
- package/src/node-types/orchestrator-load-state.ts +66 -0
- package/src/node-types/orchestrator-route.ts +33 -0
- package/src/node-types/receive-task.ts +3 -26
- package/src/ui/bot-constants.ts +192 -0
- package/src/ui/bot-panel.tsx +55 -79
- package/src/ui/bot-slot-card.tsx +69 -117
- package/src/ui/budget-bar.tsx +5 -3
- package/src/ui/chat-task-result.tsx +6 -9
- package/src/ui/decision-log.tsx +148 -0
- package/src/ui/profile-card.tsx +157 -0
- package/src/ui/profile-editor.tsx +384 -0
- package/src/ui/swarm-controls.tsx +35 -31
- package/src/ui/swarm-dashboard.tsx +409 -80
- package/src/ui/task-create-form.tsx +29 -119
- package/src/ui/task-detail-view.tsx +461 -215
- package/src/ui/task-pool-list.tsx +74 -95
- package/src/workflows/orchestrator.ts +302 -0
- package/dist/docs/weaver-bot-usage.md +0 -34
- package/dist/docs/weaver-genesis.md +0 -32
- package/dist/docs/weaver-task-queue.md +0 -34
- package/src/bot/error-guide.ts +0 -4
- package/src/bot/retry-utils.ts +0 -4
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/ui/profile-editor.tsx
|
|
21
|
+
var profile_editor_exports = {};
|
|
22
|
+
__export(profile_editor_exports, {
|
|
23
|
+
ProfileEditor: () => ProfileEditor,
|
|
24
|
+
default: () => profile_editor_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(profile_editor_exports);
|
|
27
|
+
|
|
28
|
+
// src/ui/bot-constants.ts
|
|
29
|
+
var ICON_CATALOG = [
|
|
30
|
+
{
|
|
31
|
+
category: "Actions",
|
|
32
|
+
icons: [
|
|
33
|
+
"playArrow",
|
|
34
|
+
"stop",
|
|
35
|
+
"pause",
|
|
36
|
+
"restart",
|
|
37
|
+
"send",
|
|
38
|
+
"check",
|
|
39
|
+
"edit",
|
|
40
|
+
"copy",
|
|
41
|
+
"add",
|
|
42
|
+
"reset",
|
|
43
|
+
"resume"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
category: "AI & Science",
|
|
48
|
+
icons: ["smartToy", "psychology", "autoAwesome", "modelTraining", "biotech", "science", "ai"]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
category: "Data & Storage",
|
|
52
|
+
icons: ["database", "dataObject", "dataArray", "tableChart", "token", "dns", "cloudStorage"]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
category: "Logic & Flow",
|
|
56
|
+
icons: [
|
|
57
|
+
"altRoute",
|
|
58
|
+
"callSplit",
|
|
59
|
+
"callMerge",
|
|
60
|
+
"rule",
|
|
61
|
+
"filterAlt",
|
|
62
|
+
"sort",
|
|
63
|
+
"loop",
|
|
64
|
+
"repeat",
|
|
65
|
+
"compareArrows",
|
|
66
|
+
"swapHoriz",
|
|
67
|
+
"syncAlt",
|
|
68
|
+
"changeCircle",
|
|
69
|
+
"allInclusive"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
category: "Cloud & Network",
|
|
74
|
+
icons: [
|
|
75
|
+
"cloudSync",
|
|
76
|
+
"cloudUpload",
|
|
77
|
+
"cloudDownload",
|
|
78
|
+
"cloudDone",
|
|
79
|
+
"api",
|
|
80
|
+
"webhook",
|
|
81
|
+
"public",
|
|
82
|
+
"router"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
category: "Communication",
|
|
87
|
+
icons: ["email", "chat", "forum", "notifications", "campaign", "rssFeed", "sms"]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
category: "Security",
|
|
91
|
+
icons: [
|
|
92
|
+
"key",
|
|
93
|
+
"shield",
|
|
94
|
+
"security",
|
|
95
|
+
"vpnKey",
|
|
96
|
+
"adminPanel",
|
|
97
|
+
"policy",
|
|
98
|
+
"verified",
|
|
99
|
+
"lockClosed",
|
|
100
|
+
"lockOpened"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
category: "Time",
|
|
105
|
+
icons: [
|
|
106
|
+
"timer",
|
|
107
|
+
"alarm",
|
|
108
|
+
"hourglassEmpty",
|
|
109
|
+
"pendingActions",
|
|
110
|
+
"update",
|
|
111
|
+
"watchLater",
|
|
112
|
+
"scheduled"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
category: "Tasks & Workflow",
|
|
117
|
+
icons: [
|
|
118
|
+
"task",
|
|
119
|
+
"taskAlt",
|
|
120
|
+
"checklist",
|
|
121
|
+
"assignment",
|
|
122
|
+
"publish",
|
|
123
|
+
"build",
|
|
124
|
+
"construction",
|
|
125
|
+
"engineering"
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
category: "Analytics",
|
|
130
|
+
icons: [
|
|
131
|
+
"analytics",
|
|
132
|
+
"insights",
|
|
133
|
+
"barChart",
|
|
134
|
+
"pieChart",
|
|
135
|
+
"trendingUp",
|
|
136
|
+
"showChart",
|
|
137
|
+
"leaderboard",
|
|
138
|
+
"monitoring"
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
category: "Flow Nodes",
|
|
143
|
+
icons: [
|
|
144
|
+
"schema",
|
|
145
|
+
"hub",
|
|
146
|
+
"deviceHub",
|
|
147
|
+
"source",
|
|
148
|
+
"trigger",
|
|
149
|
+
"pulse",
|
|
150
|
+
"step",
|
|
151
|
+
"event",
|
|
152
|
+
"outlinedFlow"
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
category: "Files & Documents",
|
|
157
|
+
icons: [
|
|
158
|
+
"file",
|
|
159
|
+
"filePresent",
|
|
160
|
+
"fileCopy",
|
|
161
|
+
"textSnippet",
|
|
162
|
+
"attachFile",
|
|
163
|
+
"uploadFile",
|
|
164
|
+
"save",
|
|
165
|
+
"upload",
|
|
166
|
+
"download"
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
category: "General",
|
|
171
|
+
icons: [
|
|
172
|
+
"rocketLaunch",
|
|
173
|
+
"code",
|
|
174
|
+
"terminal",
|
|
175
|
+
"logs",
|
|
176
|
+
"info",
|
|
177
|
+
"help",
|
|
178
|
+
"list",
|
|
179
|
+
"category",
|
|
180
|
+
"hash",
|
|
181
|
+
"calendar",
|
|
182
|
+
"history",
|
|
183
|
+
"integration",
|
|
184
|
+
"layers",
|
|
185
|
+
"link",
|
|
186
|
+
"search",
|
|
187
|
+
"outlinedSettings",
|
|
188
|
+
"outlinedBug",
|
|
189
|
+
"collaboration",
|
|
190
|
+
"person",
|
|
191
|
+
"people",
|
|
192
|
+
"backup",
|
|
193
|
+
"healthAndSafety"
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
var BOT_COLORS = [
|
|
198
|
+
{ label: "Blue", token: "color-node-blue-icon" },
|
|
199
|
+
{ label: "Purple", token: "color-node-purple-icon" },
|
|
200
|
+
{ label: "Cyan", token: "color-node-cyan-icon" },
|
|
201
|
+
{ label: "Orange", token: "color-node-orange-icon" },
|
|
202
|
+
{ label: "Pink", token: "color-node-pink-icon" },
|
|
203
|
+
{ label: "Green", token: "color-node-green-icon" },
|
|
204
|
+
{ label: "Brand", token: "color-brand-main" },
|
|
205
|
+
{ label: "Accent", token: "color-brand-alt" },
|
|
206
|
+
{ label: "Positive", token: "color-status-positive" },
|
|
207
|
+
{ label: "Info", token: "color-status-info" }
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
// src/ui/profile-editor.tsx
|
|
211
|
+
var React = require("react");
|
|
212
|
+
var { useState, useEffect, useCallback } = React;
|
|
213
|
+
var {
|
|
214
|
+
Flex,
|
|
215
|
+
Typography,
|
|
216
|
+
Input,
|
|
217
|
+
Button,
|
|
218
|
+
IconButton,
|
|
219
|
+
Icon,
|
|
220
|
+
SectionTitle,
|
|
221
|
+
Checkbox,
|
|
222
|
+
Field,
|
|
223
|
+
IconPicker,
|
|
224
|
+
ColorPicker,
|
|
225
|
+
toast,
|
|
226
|
+
usePackWorkspace
|
|
227
|
+
} = require("@fw/plugin-ui-kit");
|
|
228
|
+
function ProfileEditor({ mode, profileId, bots, onSave, onCancel, onDelete }) {
|
|
229
|
+
const ctx = usePackWorkspace();
|
|
230
|
+
const { callTool } = ctx;
|
|
231
|
+
const [name, setName] = useState("");
|
|
232
|
+
const [description, setDescription] = useState("");
|
|
233
|
+
const [botId, setBotId] = useState(mode === "create" && bots.length > 0 ? bots[0].id : "");
|
|
234
|
+
const [icon, setIcon] = useState("smartToy");
|
|
235
|
+
const [color, setColor] = useState("color-node-blue-icon");
|
|
236
|
+
const [costStrategy, setCostStrategy] = useState("balanced");
|
|
237
|
+
const [capabilities, setCapabilities] = useState([]);
|
|
238
|
+
const [capName, setCapName] = useState("");
|
|
239
|
+
const [capDescription, setCapDescription] = useState("");
|
|
240
|
+
const [instructions, setInstructions] = useState("");
|
|
241
|
+
const [requireApproval, setRequireApproval] = useState(false);
|
|
242
|
+
const [loading, setLoading] = useState(mode === "edit");
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
if (mode !== "edit" || !profileId) return;
|
|
245
|
+
let cancelled = false;
|
|
246
|
+
(async () => {
|
|
247
|
+
try {
|
|
248
|
+
const raw = await callTool("fw_weaver_profile_list", {});
|
|
249
|
+
if (cancelled) return;
|
|
250
|
+
const data = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
251
|
+
const list = Array.isArray(data) ? data : [];
|
|
252
|
+
const profile = list.find((p) => p.id === profileId);
|
|
253
|
+
if (!profile) {
|
|
254
|
+
toast("Profile not found", { type: "error" });
|
|
255
|
+
onCancel();
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
setName(profile.name || "");
|
|
259
|
+
setDescription(profile.description || "");
|
|
260
|
+
setBotId(profile.botId || "");
|
|
261
|
+
setIcon(profile.icon || "smartToy");
|
|
262
|
+
setColor(profile.color || "color-node-blue-icon");
|
|
263
|
+
const prefs = profile.preferences || {};
|
|
264
|
+
setCostStrategy(prefs.costStrategy || "balanced");
|
|
265
|
+
setCapabilities(
|
|
266
|
+
Array.isArray(profile.capabilities) ? profile.capabilities : []
|
|
267
|
+
);
|
|
268
|
+
setInstructions(prefs.instructions || "");
|
|
269
|
+
setRequireApproval(!!prefs.requireApproval);
|
|
270
|
+
} catch {
|
|
271
|
+
toast("Failed to load profile", { type: "error" });
|
|
272
|
+
onCancel();
|
|
273
|
+
} finally {
|
|
274
|
+
if (!cancelled) setLoading(false);
|
|
275
|
+
}
|
|
276
|
+
})();
|
|
277
|
+
return () => {
|
|
278
|
+
cancelled = true;
|
|
279
|
+
};
|
|
280
|
+
}, [mode, profileId, callTool, onCancel]);
|
|
281
|
+
const handleAddCapability = useCallback(() => {
|
|
282
|
+
const trimName = capName.trim();
|
|
283
|
+
const trimDesc = capDescription.trim();
|
|
284
|
+
if (!trimName || !trimDesc) return;
|
|
285
|
+
setCapabilities((prev) => [...prev, { name: trimName, description: trimDesc }]);
|
|
286
|
+
setCapName("");
|
|
287
|
+
setCapDescription("");
|
|
288
|
+
}, [capName, capDescription]);
|
|
289
|
+
const handleRemoveCapability = useCallback((index) => {
|
|
290
|
+
setCapabilities((prev) => prev.filter((_, i) => i !== index));
|
|
291
|
+
}, []);
|
|
292
|
+
const handleSave = useCallback(async () => {
|
|
293
|
+
if (!name.trim()) {
|
|
294
|
+
toast("Profile name is required", { type: "error" });
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (!botId) {
|
|
298
|
+
toast("Select a bot workflow", { type: "error" });
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (capabilities.length === 0) {
|
|
302
|
+
toast("Add at least one capability", { type: "error" });
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
if (mode === "create") {
|
|
307
|
+
await callTool("fw_weaver_profile_create", {
|
|
308
|
+
name: name.trim(),
|
|
309
|
+
description: description.trim(),
|
|
310
|
+
botId,
|
|
311
|
+
icon,
|
|
312
|
+
color,
|
|
313
|
+
capabilities,
|
|
314
|
+
costStrategy,
|
|
315
|
+
instructions: instructions.trim() || void 0,
|
|
316
|
+
requireApproval
|
|
317
|
+
});
|
|
318
|
+
toast("Profile created", { type: "success" });
|
|
319
|
+
} else {
|
|
320
|
+
await callTool("fw_weaver_profile_update", {
|
|
321
|
+
id: profileId,
|
|
322
|
+
name: name.trim(),
|
|
323
|
+
description: description.trim(),
|
|
324
|
+
icon,
|
|
325
|
+
color,
|
|
326
|
+
capabilities,
|
|
327
|
+
costStrategy,
|
|
328
|
+
instructions: instructions.trim() || void 0,
|
|
329
|
+
requireApproval
|
|
330
|
+
});
|
|
331
|
+
toast("Profile updated", { type: "success" });
|
|
332
|
+
}
|
|
333
|
+
onSave();
|
|
334
|
+
} catch (err) {
|
|
335
|
+
toast(err instanceof Error ? err.message : `Failed to ${mode} profile`, { type: "error" });
|
|
336
|
+
}
|
|
337
|
+
}, [mode, profileId, name, description, botId, icon, color, costStrategy, capabilities, instructions, requireApproval, callTool, onSave]);
|
|
338
|
+
const handleDelete = useCallback(async () => {
|
|
339
|
+
if (!profileId) return;
|
|
340
|
+
const ok = await ctx.confirm("Are you sure you want to delete this profile?", {
|
|
341
|
+
title: "Delete Profile",
|
|
342
|
+
confirmLabel: "Delete",
|
|
343
|
+
state: "danger"
|
|
344
|
+
});
|
|
345
|
+
if (!ok) return;
|
|
346
|
+
try {
|
|
347
|
+
await callTool("fw_weaver_profile_delete", { id: profileId });
|
|
348
|
+
toast("Profile deleted", { type: "success" });
|
|
349
|
+
if (onDelete) onDelete();
|
|
350
|
+
} catch (err) {
|
|
351
|
+
toast(err instanceof Error ? err.message : "Failed to delete profile", { type: "error" });
|
|
352
|
+
}
|
|
353
|
+
}, [profileId, callTool, onDelete, ctx]);
|
|
354
|
+
if (loading) {
|
|
355
|
+
return React.createElement(
|
|
356
|
+
Flex,
|
|
357
|
+
{
|
|
358
|
+
variant: "column-center-center-nowrap-12",
|
|
359
|
+
style: { padding: "24px 16px" }
|
|
360
|
+
},
|
|
361
|
+
React.createElement(Typography, { variant: "caption-regular", color: "color-text-subtle" }, "Loading profile...")
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
return React.createElement(
|
|
365
|
+
Flex,
|
|
366
|
+
{
|
|
367
|
+
variant: "column-stretch-start-nowrap-0",
|
|
368
|
+
style: { width: "100%", height: "100%", overflow: "hidden" }
|
|
369
|
+
},
|
|
370
|
+
// ── Header bar ──
|
|
371
|
+
React.createElement(
|
|
372
|
+
Flex,
|
|
373
|
+
{
|
|
374
|
+
variant: "row-center-space-between-nowrap-8",
|
|
375
|
+
style: { padding: "8px 16px", flexShrink: 0, borderBottom: "1px solid var(--color-border-default)" }
|
|
376
|
+
},
|
|
377
|
+
React.createElement(
|
|
378
|
+
Flex,
|
|
379
|
+
{ variant: "row-center-start-nowrap-8" },
|
|
380
|
+
React.createElement(IconButton, {
|
|
381
|
+
icon: "back",
|
|
382
|
+
size: "xs",
|
|
383
|
+
variant: "clear",
|
|
384
|
+
onClick: onCancel,
|
|
385
|
+
title: "Back"
|
|
386
|
+
}),
|
|
387
|
+
React.createElement(Typography, { variant: "caption-thick", color: "color-text-high" }, mode === "create" ? "Create Profile" : "Edit Profile")
|
|
388
|
+
),
|
|
389
|
+
mode === "edit" && onDelete && React.createElement(IconButton, {
|
|
390
|
+
icon: "outlinedDelete",
|
|
391
|
+
size: "sm",
|
|
392
|
+
variant: "clear",
|
|
393
|
+
color: "danger",
|
|
394
|
+
onClick: handleDelete,
|
|
395
|
+
title: "Delete profile"
|
|
396
|
+
})
|
|
397
|
+
),
|
|
398
|
+
// ── Scrollable form body ──
|
|
399
|
+
React.createElement(
|
|
400
|
+
Flex,
|
|
401
|
+
{
|
|
402
|
+
variant: "column-stretch-start-nowrap-10",
|
|
403
|
+
style: { flex: 1, minHeight: 0, overflow: "auto", padding: "12px 16px" }
|
|
404
|
+
},
|
|
405
|
+
// ── Name ──
|
|
406
|
+
React.createElement(
|
|
407
|
+
Field,
|
|
408
|
+
{ label: "Name" },
|
|
409
|
+
React.createElement(Input, {
|
|
410
|
+
type: "text",
|
|
411
|
+
size: "small",
|
|
412
|
+
placeholder: "Profile name",
|
|
413
|
+
value: name,
|
|
414
|
+
onChange: (v) => setName(v),
|
|
415
|
+
defaultBoxStyle: { flex: 1, minWidth: 0 },
|
|
416
|
+
inputBoxStyle: { maxWidth: "none" }
|
|
417
|
+
})
|
|
418
|
+
),
|
|
419
|
+
// ── Description ──
|
|
420
|
+
React.createElement(
|
|
421
|
+
Field,
|
|
422
|
+
{ label: "Description" },
|
|
423
|
+
React.createElement(Input, {
|
|
424
|
+
type: "text",
|
|
425
|
+
size: "small",
|
|
426
|
+
placeholder: "What does this profile do?",
|
|
427
|
+
value: description,
|
|
428
|
+
onChange: (v) => setDescription(v),
|
|
429
|
+
defaultBoxStyle: { flex: 1, minWidth: 0 },
|
|
430
|
+
inputBoxStyle: { maxWidth: "none" }
|
|
431
|
+
})
|
|
432
|
+
),
|
|
433
|
+
// ── Bot ──
|
|
434
|
+
React.createElement(
|
|
435
|
+
Field,
|
|
436
|
+
{ label: "Bot" },
|
|
437
|
+
React.createElement(Input, {
|
|
438
|
+
type: "select",
|
|
439
|
+
size: "small",
|
|
440
|
+
options: bots.map((b) => ({ id: b.id, label: b.name, icon: b.icon || "smartToy" })),
|
|
441
|
+
optionId: botId,
|
|
442
|
+
onChange: (id) => setBotId(id),
|
|
443
|
+
disabled: mode === "edit",
|
|
444
|
+
placeholder: "Select bot",
|
|
445
|
+
defaultBoxStyle: { flex: 1, minWidth: 0 }
|
|
446
|
+
})
|
|
447
|
+
),
|
|
448
|
+
// ── Icon ──
|
|
449
|
+
React.createElement(
|
|
450
|
+
Field,
|
|
451
|
+
{ label: "Icon", align: "start" },
|
|
452
|
+
React.createElement(IconPicker, {
|
|
453
|
+
catalog: ICON_CATALOG,
|
|
454
|
+
value: icon,
|
|
455
|
+
onChange: (v) => setIcon(v),
|
|
456
|
+
accentColor: color,
|
|
457
|
+
variant: "inline"
|
|
458
|
+
})
|
|
459
|
+
),
|
|
460
|
+
// ── Color ──
|
|
461
|
+
React.createElement(
|
|
462
|
+
Field,
|
|
463
|
+
{ label: "Color", align: "start" },
|
|
464
|
+
React.createElement(ColorPicker, {
|
|
465
|
+
colors: BOT_COLORS,
|
|
466
|
+
value: color,
|
|
467
|
+
onChange: (v) => setColor(v),
|
|
468
|
+
variant: "inline"
|
|
469
|
+
})
|
|
470
|
+
),
|
|
471
|
+
// ── Cost Strategy ──
|
|
472
|
+
React.createElement(
|
|
473
|
+
Field,
|
|
474
|
+
{ label: "Cost Strategy" },
|
|
475
|
+
React.createElement(Input, {
|
|
476
|
+
type: "select",
|
|
477
|
+
size: "small",
|
|
478
|
+
options: [
|
|
479
|
+
{ id: "frugal", label: "Frugal", icon: "timer" },
|
|
480
|
+
{ id: "balanced", label: "Balanced", icon: "syncAlt" },
|
|
481
|
+
{ id: "performance", label: "Performance", icon: "rocketLaunch" }
|
|
482
|
+
],
|
|
483
|
+
optionId: costStrategy,
|
|
484
|
+
onChange: (id) => setCostStrategy(id),
|
|
485
|
+
defaultBoxStyle: { flex: 1, minWidth: 0 }
|
|
486
|
+
})
|
|
487
|
+
),
|
|
488
|
+
// ── Capabilities ──
|
|
489
|
+
React.createElement(
|
|
490
|
+
Field,
|
|
491
|
+
{ label: "Capabilities", align: "start" },
|
|
492
|
+
React.createElement(
|
|
493
|
+
Flex,
|
|
494
|
+
{ variant: "column-stretch-start-nowrap-6" },
|
|
495
|
+
// Add capability row
|
|
496
|
+
React.createElement(
|
|
497
|
+
Flex,
|
|
498
|
+
{ variant: "row-center-start-nowrap-4", style: { overflow: "hidden" } },
|
|
499
|
+
React.createElement(Input, {
|
|
500
|
+
type: "text",
|
|
501
|
+
size: "small",
|
|
502
|
+
placeholder: "Name",
|
|
503
|
+
value: capName,
|
|
504
|
+
onChange: (v) => setCapName(v),
|
|
505
|
+
defaultBoxStyle: { flex: 1, minWidth: 0 },
|
|
506
|
+
inputBoxStyle: { maxWidth: "none" }
|
|
507
|
+
}),
|
|
508
|
+
React.createElement(Input, {
|
|
509
|
+
type: "text",
|
|
510
|
+
size: "small",
|
|
511
|
+
placeholder: "Description",
|
|
512
|
+
value: capDescription,
|
|
513
|
+
onChange: (v) => setCapDescription(v),
|
|
514
|
+
onEnter: handleAddCapability,
|
|
515
|
+
defaultBoxStyle: { flex: 2, minWidth: 0 },
|
|
516
|
+
inputBoxStyle: { maxWidth: "none" }
|
|
517
|
+
}),
|
|
518
|
+
React.createElement(IconButton, {
|
|
519
|
+
icon: "add",
|
|
520
|
+
size: "sm",
|
|
521
|
+
variant: "outlined",
|
|
522
|
+
color: "primary",
|
|
523
|
+
onClick: handleAddCapability,
|
|
524
|
+
disabled: !capName.trim() || !capDescription.trim()
|
|
525
|
+
})
|
|
526
|
+
),
|
|
527
|
+
...capabilities.map(
|
|
528
|
+
(cap, idx) => React.createElement(
|
|
529
|
+
Flex,
|
|
530
|
+
{
|
|
531
|
+
key: `${cap.name}-${idx}`,
|
|
532
|
+
variant: "row-center-start-nowrap-6",
|
|
533
|
+
style: { paddingLeft: "4px" }
|
|
534
|
+
},
|
|
535
|
+
React.createElement(Typography, {
|
|
536
|
+
variant: "smallCaption-regular",
|
|
537
|
+
color: "color-text-high",
|
|
538
|
+
style: { flexShrink: 0 }
|
|
539
|
+
}, `\u2022 ${cap.name}:`),
|
|
540
|
+
React.createElement(Typography, {
|
|
541
|
+
variant: "smallCaption-regular",
|
|
542
|
+
color: "color-text-medium",
|
|
543
|
+
style: { flex: 1, minWidth: 0 }
|
|
544
|
+
}, cap.description),
|
|
545
|
+
React.createElement(IconButton, {
|
|
546
|
+
icon: "close",
|
|
547
|
+
size: "xs",
|
|
548
|
+
variant: "clear",
|
|
549
|
+
color: "danger",
|
|
550
|
+
onClick: () => handleRemoveCapability(idx)
|
|
551
|
+
})
|
|
552
|
+
)
|
|
553
|
+
)
|
|
554
|
+
)
|
|
555
|
+
),
|
|
556
|
+
// ── Instructions ──
|
|
557
|
+
React.createElement(
|
|
558
|
+
Field,
|
|
559
|
+
{ label: "Instructions" },
|
|
560
|
+
React.createElement(Input, {
|
|
561
|
+
type: "text",
|
|
562
|
+
size: "small",
|
|
563
|
+
placeholder: "Optional instructions for the bot",
|
|
564
|
+
value: instructions,
|
|
565
|
+
onChange: (v) => setInstructions(v),
|
|
566
|
+
defaultBoxStyle: { flex: 1, minWidth: 0 },
|
|
567
|
+
inputBoxStyle: { maxWidth: "none" }
|
|
568
|
+
})
|
|
569
|
+
),
|
|
570
|
+
// ── Require Approval ──
|
|
571
|
+
React.createElement(
|
|
572
|
+
Field,
|
|
573
|
+
{ label: "" },
|
|
574
|
+
React.createElement(Checkbox, {
|
|
575
|
+
checked: requireApproval,
|
|
576
|
+
onChange: (v) => setRequireApproval(v),
|
|
577
|
+
label: "Require approval",
|
|
578
|
+
size: "sm"
|
|
579
|
+
})
|
|
580
|
+
),
|
|
581
|
+
// ── Save button ──
|
|
582
|
+
React.createElement(
|
|
583
|
+
Flex,
|
|
584
|
+
{ variant: "row-center-end-nowrap-8" },
|
|
585
|
+
React.createElement(Button, {
|
|
586
|
+
size: "xs",
|
|
587
|
+
variant: "fill",
|
|
588
|
+
color: "primary",
|
|
589
|
+
onClick: handleSave,
|
|
590
|
+
disabled: !name.trim() || !botId || capabilities.length === 0
|
|
591
|
+
}, mode === "create" ? "Create" : "Save")
|
|
592
|
+
)
|
|
593
|
+
)
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
var profile_editor_default = ProfileEditor;
|
|
597
|
+
module.exports = ProfileEditor;
|