@burdenoff/microfe-botmanor 2026.1202.1 → 2026.1203.2
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/botlit/hooks/useAgents.d.ts +5 -0
- package/dist/botlit/hooks/useAgents.js +8 -0
- package/dist/botlit/hooks/useAgents.js.map +1 -1
- package/dist/botlit/pages/AgentBuilderPage.js +508 -460
- package/dist/botlit/pages/AgentBuilderPage.js.map +1 -1
- package/dist/botlit/pages/BotWorkflowTab.js +74 -65
- package/dist/botlit/pages/BotWorkflowTab.js.map +1 -1
- package/dist/botlit/utils/agentSettings.d.ts +4 -1
- package/dist/botlit/utils/agentSettings.js +30 -28
- package/dist/botlit/utils/agentSettings.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +4 -0
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +12 -0
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +3 -3
|
@@ -12,19 +12,21 @@ import { useBotlit as g } from "../providers/BotlitProvider.js";
|
|
|
12
12
|
import "../permissions/index.js";
|
|
13
13
|
import { useCallback as _, useState as v } from "react";
|
|
14
14
|
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { usePermissions as x } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
16
|
+
import { ExternalLink as S, Sparkles as C, Unlink as w, Workflow as T } from "lucide-react";
|
|
17
|
+
import { toast as E } from "sonner";
|
|
18
|
+
import { ProductFailureTriagePanel as D } from "@burdenoff/fe-libs/shared/proactive";
|
|
17
19
|
// src/botlit/pages/BotWorkflowTab.tsx
|
|
18
|
-
var
|
|
20
|
+
var O = "v1", k = "internal:api", A = "1.0.0", j = "onManualTrigger", M = "Trigger Manually", N = "Runs the flow when you click 'Test workflow', or when this bot is invoked.", P = [
|
|
19
21
|
"trigger",
|
|
20
22
|
"manual",
|
|
21
23
|
"entry"
|
|
22
24
|
];
|
|
23
|
-
function
|
|
25
|
+
function F() {
|
|
24
26
|
let e = globalThis.crypto;
|
|
25
27
|
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
26
28
|
}
|
|
27
|
-
function
|
|
29
|
+
function I(e, t) {
|
|
28
30
|
return {
|
|
29
31
|
key: e,
|
|
30
32
|
name: t,
|
|
@@ -33,38 +35,38 @@ function P(e, t) {
|
|
|
33
35
|
data: {
|
|
34
36
|
id: e,
|
|
35
37
|
workflowKey: e,
|
|
36
|
-
version:
|
|
38
|
+
version: O,
|
|
37
39
|
name: t,
|
|
38
40
|
nodes: [{
|
|
39
|
-
id:
|
|
40
|
-
type:
|
|
41
|
+
id: F(),
|
|
42
|
+
type: k,
|
|
41
43
|
position: {
|
|
42
44
|
x: 160,
|
|
43
45
|
y: 160
|
|
44
46
|
},
|
|
45
|
-
kind:
|
|
47
|
+
kind: P,
|
|
46
48
|
data: {
|
|
47
|
-
operation_name:
|
|
49
|
+
operation_name: j,
|
|
48
50
|
operation_type: "trigger",
|
|
49
|
-
version:
|
|
51
|
+
version: A,
|
|
50
52
|
nodeData: {
|
|
51
|
-
nodeType:
|
|
52
|
-
name:
|
|
53
|
-
description:
|
|
54
|
-
version:
|
|
55
|
-
kind:
|
|
53
|
+
nodeType: k,
|
|
54
|
+
name: M,
|
|
55
|
+
description: N,
|
|
56
|
+
version: A,
|
|
57
|
+
kind: P,
|
|
56
58
|
operations: [{
|
|
57
|
-
name:
|
|
59
|
+
name: j,
|
|
58
60
|
type: "trigger",
|
|
59
61
|
role: "trigger",
|
|
60
|
-
description:
|
|
62
|
+
description: N
|
|
61
63
|
}]
|
|
62
64
|
},
|
|
63
65
|
args: {
|
|
64
66
|
context: { node: {
|
|
65
|
-
id:
|
|
66
|
-
type:
|
|
67
|
-
kind:
|
|
67
|
+
id: k,
|
|
68
|
+
type: k,
|
|
69
|
+
kind: P
|
|
68
70
|
} },
|
|
69
71
|
state: {},
|
|
70
72
|
credentials: []
|
|
@@ -80,76 +82,76 @@ function P(e, t) {
|
|
|
80
82
|
},
|
|
81
83
|
meta: {
|
|
82
84
|
creator: "botlit_bot_design",
|
|
83
|
-
version:
|
|
85
|
+
version: O
|
|
84
86
|
},
|
|
85
87
|
tags: []
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
|
-
var
|
|
89
|
-
let j = e(), { navigateTo: M } = g(), { createWorkflow:
|
|
90
|
-
M(`workflows/workflow/${e}/${t ||
|
|
91
|
-
}, [M]),
|
|
92
|
-
|
|
90
|
+
var L = ({ botId: x, botName: D, workflowId: k, onWorkflowChanged: A }) => {
|
|
91
|
+
let j = e(), { navigateTo: M } = g(), { createWorkflow: N } = r(), [P] = h(), [L, z] = v(!1), { workflow: B, loading: V } = n(void 0, k ?? void 0), H = _((e, t) => {
|
|
92
|
+
M(`workflows/workflow/${e}/${t || O}`);
|
|
93
|
+
}, [M]), U = _(async () => {
|
|
94
|
+
z(!0);
|
|
93
95
|
try {
|
|
94
|
-
let e =
|
|
96
|
+
let e = F(), t = `${D} workflow`, n = await N({
|
|
95
97
|
workflowKey: e,
|
|
96
|
-
version:
|
|
98
|
+
version: O,
|
|
97
99
|
name: t,
|
|
98
100
|
description: j("botlit.botDetail.workflow.createdDescription", "Behaviour designed for this BotManor bot."),
|
|
99
|
-
definitionJson:
|
|
101
|
+
definitionJson: I(e, t)
|
|
100
102
|
});
|
|
101
103
|
if (!n) throw Error(j("botlit.botDetail.workflow.createError", "Failed to create the workflow"));
|
|
102
|
-
await
|
|
103
|
-
botId:
|
|
104
|
+
await P({
|
|
105
|
+
botId: x,
|
|
104
106
|
input: { workflowId: n.id }
|
|
105
|
-
}), await A(),
|
|
107
|
+
}), await A(), E.success(j("botlit.botDetail.workflow.createSuccess", "Workflow created and bound to this bot")), H(n.workflowKey, n.version);
|
|
106
108
|
} catch (e) {
|
|
107
109
|
let t = e instanceof Error ? e.message : j("botlit.botDetail.workflow.createError", "Failed to create the workflow");
|
|
108
|
-
|
|
110
|
+
E.error(t);
|
|
109
111
|
} finally {
|
|
110
|
-
|
|
112
|
+
z(!1);
|
|
111
113
|
}
|
|
112
114
|
}, [
|
|
115
|
+
x,
|
|
113
116
|
D,
|
|
114
|
-
|
|
115
|
-
F,
|
|
117
|
+
N,
|
|
116
118
|
A,
|
|
117
|
-
|
|
119
|
+
H,
|
|
118
120
|
j,
|
|
119
|
-
|
|
120
|
-
]),
|
|
121
|
+
P
|
|
122
|
+
]), W = _(async () => {
|
|
121
123
|
if (await t({
|
|
122
124
|
title: j("botlit.botDetail.workflow.unbindConfirm", "Unbind this workflow from the bot? The workflow itself is not deleted."),
|
|
123
125
|
confirmLabel: j("botlit.botDetail.workflow.unbindConfirmAction", "Unbind"),
|
|
124
126
|
cancelLabel: j("botlit.common.cancel", "Cancel")
|
|
125
127
|
})) {
|
|
126
|
-
|
|
128
|
+
z(!0);
|
|
127
129
|
try {
|
|
128
|
-
await
|
|
129
|
-
botId:
|
|
130
|
+
await P({
|
|
131
|
+
botId: x,
|
|
130
132
|
input: { workflowId: null }
|
|
131
|
-
}), await A(),
|
|
133
|
+
}), await A(), E.success(j("botlit.botDetail.workflow.unbindSuccess", "Workflow unbound"));
|
|
132
134
|
} catch (e) {
|
|
133
135
|
let t = e instanceof Error ? e.message : j("botlit.botDetail.workflow.unbindError", "Failed to unbind the workflow");
|
|
134
|
-
|
|
136
|
+
E.error(t);
|
|
135
137
|
} finally {
|
|
136
|
-
|
|
138
|
+
z(!1);
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
}, [
|
|
140
|
-
|
|
142
|
+
x,
|
|
141
143
|
A,
|
|
142
144
|
j,
|
|
143
|
-
|
|
145
|
+
P
|
|
144
146
|
]);
|
|
145
|
-
return k ? /* @__PURE__ */
|
|
147
|
+
return k ? /* @__PURE__ */ b("div", {
|
|
146
148
|
className: "space-y-6",
|
|
147
|
-
children: /* @__PURE__ */ b(o, { children: [/* @__PURE__ */ b(l, { children: [/* @__PURE__ */ b(u, {
|
|
149
|
+
children: [/* @__PURE__ */ b(o, { children: [/* @__PURE__ */ b(l, { children: [/* @__PURE__ */ b(u, {
|
|
148
150
|
className: "flex items-center gap-2",
|
|
149
|
-
children: [/* @__PURE__ */ y(
|
|
151
|
+
children: [/* @__PURE__ */ y(T, { size: 18 }), j("botlit.botDetail.workflow.bound.title", "Bound workflow")]
|
|
150
152
|
}), /* @__PURE__ */ y(c, { children: j("botlit.botDetail.workflow.bound.description", "This workflow defines what the bot does when it is invoked.") })] }), /* @__PURE__ */ b(s, {
|
|
151
153
|
className: "space-y-6",
|
|
152
|
-
children: [
|
|
154
|
+
children: [V ? /* @__PURE__ */ y("div", { className: "h-24 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer" }) : B ? /* @__PURE__ */ b("div", {
|
|
153
155
|
className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
|
|
154
156
|
children: [
|
|
155
157
|
/* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("p", {
|
|
@@ -157,14 +159,14 @@ var F = ({ botId: D, botName: O, workflowId: k, onWorkflowChanged: A }) => {
|
|
|
157
159
|
children: j("botlit.botDetail.workflow.fields.name", "Name")
|
|
158
160
|
}), /* @__PURE__ */ y("p", {
|
|
159
161
|
className: "font-medium text-text-primary",
|
|
160
|
-
children:
|
|
162
|
+
children: B.name
|
|
161
163
|
})] }),
|
|
162
164
|
/* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("p", {
|
|
163
165
|
className: "text-sm text-text-secondary",
|
|
164
166
|
children: j("botlit.botDetail.workflow.fields.key", "Key")
|
|
165
167
|
}), /* @__PURE__ */ y("p", {
|
|
166
168
|
className: "mt-1 break-all font-mono text-sm text-text-primary",
|
|
167
|
-
children:
|
|
169
|
+
children: B.workflowKey
|
|
168
170
|
})] }),
|
|
169
171
|
/* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("p", {
|
|
170
172
|
className: "text-sm text-text-secondary",
|
|
@@ -172,14 +174,14 @@ var F = ({ botId: D, botName: O, workflowId: k, onWorkflowChanged: A }) => {
|
|
|
172
174
|
}), /* @__PURE__ */ y(f, {
|
|
173
175
|
variant: "outline",
|
|
174
176
|
className: "mt-1",
|
|
175
|
-
children:
|
|
177
|
+
children: B.version
|
|
176
178
|
})] }),
|
|
177
179
|
/* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("p", {
|
|
178
180
|
className: "text-sm text-text-secondary",
|
|
179
181
|
children: j("botlit.botDetail.workflow.fields.status", "Status")
|
|
180
182
|
}), /* @__PURE__ */ y("div", {
|
|
181
183
|
className: "mt-1",
|
|
182
|
-
children: /* @__PURE__ */ y(p, { status:
|
|
184
|
+
children: /* @__PURE__ */ y(p, { status: B.status })
|
|
183
185
|
})] })
|
|
184
186
|
]
|
|
185
187
|
}) : /* @__PURE__ */ b("div", { children: [
|
|
@@ -197,24 +199,24 @@ var F = ({ botId: D, botName: O, workflowId: k, onWorkflowChanged: A }) => {
|
|
|
197
199
|
})
|
|
198
200
|
] }), /* @__PURE__ */ b("div", {
|
|
199
201
|
className: "flex flex-wrap gap-2",
|
|
200
|
-
children: [
|
|
201
|
-
leftIcon: /* @__PURE__ */ y(
|
|
202
|
+
children: [B && /* @__PURE__ */ y(d, {
|
|
203
|
+
leftIcon: /* @__PURE__ */ y(S, { size: 16 }),
|
|
202
204
|
disabled: L,
|
|
203
|
-
onClick: () =>
|
|
205
|
+
onClick: () => H(B.workflowKey, B.version),
|
|
204
206
|
children: j("botlit.botDetail.workflow.actions.openBuilder", "Open in builder")
|
|
205
207
|
}), /* @__PURE__ */ y(a, {
|
|
206
208
|
permission: i.APP_UPDATE,
|
|
207
209
|
children: /* @__PURE__ */ y(d, {
|
|
208
210
|
variant: "outline",
|
|
209
|
-
leftIcon: /* @__PURE__ */ y(
|
|
211
|
+
leftIcon: /* @__PURE__ */ y(w, { size: 16 }),
|
|
210
212
|
isLoading: L,
|
|
211
213
|
disabled: L,
|
|
212
|
-
onClick: () => void
|
|
214
|
+
onClick: () => void W(),
|
|
213
215
|
children: j("botlit.botDetail.workflow.actions.unbind", "Unbind")
|
|
214
216
|
})
|
|
215
217
|
})]
|
|
216
218
|
})]
|
|
217
|
-
})] })
|
|
219
|
+
})] }), /* @__PURE__ */ y(R, {})]
|
|
218
220
|
}) : /* @__PURE__ */ y(o, { children: /* @__PURE__ */ y(s, {
|
|
219
221
|
className: "pt-6",
|
|
220
222
|
children: /* @__PURE__ */ y(m, {
|
|
@@ -224,16 +226,23 @@ var F = ({ botId: D, botName: O, workflowId: k, onWorkflowChanged: A }) => {
|
|
|
224
226
|
action: /* @__PURE__ */ y(a, {
|
|
225
227
|
permission: i.APP_UPDATE,
|
|
226
228
|
children: /* @__PURE__ */ y(d, {
|
|
227
|
-
leftIcon: /* @__PURE__ */ y(
|
|
229
|
+
leftIcon: /* @__PURE__ */ y(C, { size: 16 }),
|
|
228
230
|
isLoading: L,
|
|
229
231
|
disabled: L,
|
|
230
|
-
onClick: () => void
|
|
232
|
+
onClick: () => void U(),
|
|
231
233
|
children: j("botlit.botDetail.workflow.empty.action", "Design in workflow builder")
|
|
232
234
|
})
|
|
233
235
|
})
|
|
234
236
|
})
|
|
235
237
|
}) });
|
|
238
|
+
}, R = () => {
|
|
239
|
+
let { hasPermission: e } = x();
|
|
240
|
+
return /* @__PURE__ */ y(D, {
|
|
241
|
+
productId: "botmanor",
|
|
242
|
+
canManage: e(i.APP_UPDATE),
|
|
243
|
+
className: "rounded-xl border border-border-default bg-bg-surface p-4"
|
|
244
|
+
});
|
|
236
245
|
};
|
|
237
|
-
export {
|
|
246
|
+
export { L as BotWorkflowTab };
|
|
238
247
|
|
|
239
248
|
//# sourceMappingURL=BotWorkflowTab.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BotWorkflowTab.js","names":["useCreateWorkflow","useWorkflowDefinition","INITIAL_VERSION","MANUAL_TRIGGER_NODE_TYPE","MANUAL_TRIGGER_NODE_VERSION","MANUAL_TRIGGER_OPERATION","MANUAL_TRIGGER_NAME","MANUAL_TRIGGER_DESCRIPTION","MANUAL_TRIGGER_KIND","generateId","webCrypto","buildSeedDefinition","workflowKey","name","BotWorkflowTab","t","useTr","useBotlit","useCreateBotWorkflow","updateBot","useUpdateBot","busy","setBusy","useState","workflowLoading","useBotWorkflowDefinition","workflowId","openBuilder","useCallback","version","navigateTo","handleDesign","botName","created","createWorkflow","onWorkflowChanged","toast","err","message","botId","handleUnbind","confirmAction","Card","CardHeader","CardTitle","Workflow","CardDescription","CardContent","workflow","Badge","StatusBadge","Button","ExternalLink","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","Unlink","EmptyState","Sparkles"],"sources":["../../../src/botlit/pages/BotWorkflowTab.tsx"],"sourcesContent":["/**\n * BotWorkflowTab\n * @module botlit/pages\n *\n * Shown inside BotDetailPage → \"Workflow\" tab.\n *\n * A bot's behaviour is designed as a FluidGrids workflow. `BotApp.workflowId`\n * holds the binding (validated server-side by `assertWorkflowBindingsResolvable`\n * on wspace-botlit-svc), and the FluidGrids builder is already mounted INSIDE\n * BotManor at `workflows/workflow/:id/:version` — so this tab never leaves the\n * product.\n *\n * Flow:\n * 1. Bound → resolve the definition by id (`useWorkflowDefinition`), show\n * name / key / version / status, \"Open in builder\", \"Unbind\".\n * A binding that no longer resolves falls back to the raw id so\n * the user can still clear it.\n * 2. Not bound → zero state whose primary action creates a seeded workflow\n * definition, binds it via `updateBotApp(workflowId)` and drops\n * the user straight into the embedded builder.\n *\n * IMPORTANT — seed graph shape. `BotlitFluidGridsBridge.extractTriggerNodeIds`\n * reads nodes from `definitionJson.data.nodes` (NOT the top level) and treats a\n * node as a trigger when its `type` is `trigger`/`trigger:*`/`*_trigger`, OR its\n * `kind[]` / `data.nodeData.kind[]` contains `trigger`. The seed below uses the\n * workflow service's own BUILTIN manual trigger (`internal:api`, \"Trigger\n * Manually\") — the node the executor resolves as the entry point — and carries\n * `kind: ['trigger', ...]` in both places, so a freshly designed bot is\n * immediately runnable instead of failing with `WORKFLOW_NO_TRIGGER_NODE`.\n */\n\nimport type { FC } from 'react';\nimport { useCallback, useState } from 'react';\nimport { ExternalLink, Sparkles, Unlink, Workflow } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { confirmAction } from '../utils/confirmAction';\nimport {\n useCreateBotWorkflow as useCreateWorkflow,\n useBotWorkflowDefinition as useWorkflowDefinition,\n} from '../hooks/useBotWorkflow';\nimport { Card, CardHeader, CardTitle, CardContent, CardDescription } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Badge, StatusBadge } from '../components/Badge';\nimport { EmptyState } from '../components/EmptyState';\nimport { useUpdateBot } from '../hooks/useBots';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Seed graph\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** First version minted for a bot's workflow — matches the builder's own default. */\nconst INITIAL_VERSION = 'v1';\n\n/**\n * BUILTIN \"Trigger Manually\" node (`MANUAL_TRIGGER_MANIFEST` in\n * wspace-workflow-svc). The executor resolves this type as a workflow's entry\n * node, and the builder renders it from the seeded node registry.\n */\nconst MANUAL_TRIGGER_NODE_TYPE = 'internal:api';\nconst MANUAL_TRIGGER_NODE_VERSION = '1.0.0';\nconst MANUAL_TRIGGER_OPERATION = 'onManualTrigger';\nconst MANUAL_TRIGGER_NAME = 'Trigger Manually';\nconst MANUAL_TRIGGER_DESCRIPTION =\n \"Runs the flow when you click 'Test workflow', or when this bot is invoked.\";\n\n/** `kind[]` the BotManor bridge scans for when classifying a node as a trigger. */\nconst MANUAL_TRIGGER_KIND = ['trigger', 'manual', 'entry'];\n\n/** Node shape written into `definitionJson.data.nodes`. */\ntype SeedNode = {\n id: string;\n type: string;\n position: { x: number; y: number };\n /** Top-level kind — the bridge's second trigger-detection path. */\n kind: string[];\n data: {\n operation_name: string;\n operation_type: string;\n version: string;\n nodeData: {\n nodeType: string;\n name: string;\n description: string;\n version: string;\n /** The bridge's third trigger-detection path. */\n kind: string[];\n operations: { name: string; type: string; role: string; description: string }[];\n };\n args: {\n context: { node: { id: string; type: string; kind: string[] } };\n state: Record<string, never>;\n credentials: never[];\n };\n };\n};\n\n/**\n * `definitionJson` document. Mirrors what the builder itself persists\n * (`useSaveWorkflow`) so the graph round-trips through the builder unchanged.\n */\ntype SeedDefinition = {\n key: string;\n name: string;\n description: string;\n workflow_type: string;\n data: {\n id: string;\n workflowKey: string;\n version: string;\n name: string;\n nodes: SeedNode[];\n edges: never[];\n sidebar: { active: string; panels: { nodeProperties: { selectedNode: null } } };\n stickyNotes: never[];\n };\n meta: { creator: string; version: string };\n tags: string[];\n};\n\n/**\n * Generate an opaque id. `crypto.randomUUID` is unavailable on insecure origins\n * and in some test environments, so fall back to a time+random token rather than\n * throwing mid-create.\n */\nfunction generateId(): string {\n const webCrypto = globalThis.crypto as Crypto | undefined;\n if (webCrypto && typeof webCrypto.randomUUID === 'function') {\n return webCrypto.randomUUID();\n }\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\n/** Build the starter graph: one manual trigger, nothing else. */\nfunction buildSeedDefinition(workflowKey: string, name: string): SeedDefinition {\n const triggerNode: SeedNode = {\n id: generateId(),\n type: MANUAL_TRIGGER_NODE_TYPE,\n position: { x: 160, y: 160 },\n kind: MANUAL_TRIGGER_KIND,\n data: {\n operation_name: MANUAL_TRIGGER_OPERATION,\n operation_type: 'trigger',\n version: MANUAL_TRIGGER_NODE_VERSION,\n nodeData: {\n nodeType: MANUAL_TRIGGER_NODE_TYPE,\n name: MANUAL_TRIGGER_NAME,\n description: MANUAL_TRIGGER_DESCRIPTION,\n version: MANUAL_TRIGGER_NODE_VERSION,\n kind: MANUAL_TRIGGER_KIND,\n operations: [\n {\n name: MANUAL_TRIGGER_OPERATION,\n type: 'trigger',\n role: 'trigger',\n description: MANUAL_TRIGGER_DESCRIPTION,\n },\n ],\n },\n args: {\n context: {\n node: {\n id: MANUAL_TRIGGER_NODE_TYPE,\n type: MANUAL_TRIGGER_NODE_TYPE,\n kind: MANUAL_TRIGGER_KIND,\n },\n },\n state: {},\n credentials: [],\n },\n },\n };\n\n return {\n key: workflowKey,\n name,\n description: name,\n workflow_type: 'query-conditional',\n data: {\n id: workflowKey,\n workflowKey,\n version: INITIAL_VERSION,\n name,\n nodes: [triggerNode],\n edges: [],\n sidebar: { active: 'store-browse', panels: { nodeProperties: { selectedNode: null } } },\n stickyNotes: [],\n },\n meta: { creator: 'botlit_bot_design', version: INITIAL_VERSION },\n tags: [],\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Component\n// ─────────────────────────────────────────────────────────────────────────────\n\ninterface BotWorkflowTabProps {\n botId: string;\n botName: string;\n /** `BotApp.workflowId` — the bound workflow definition id, if any. */\n workflowId: string | null | undefined;\n /** Refetch the bot so the tab reflects the new binding. */\n onWorkflowChanged: () => Promise<void> | void;\n}\n\nexport const BotWorkflowTab: FC<BotWorkflowTabProps> = ({\n botId,\n botName,\n workflowId,\n onWorkflowChanged,\n}) => {\n const t = useTr();\n const { navigateTo } = useBotlit();\n const { createWorkflow } = useCreateWorkflow();\n const [updateBot] = useUpdateBot();\n const [busy, setBusy] = useState(false);\n\n // Resolve by id — `BotApp.workflowId` stores the definition's opaque id, not\n // its workflowKey (which is what the builder route takes). The hook refetches\n // on its own when the bound id changes, so binding/unbinding only has to\n // refresh the bot.\n const { workflow, loading: workflowLoading } = useWorkflowDefinition(\n undefined,\n workflowId ?? undefined\n );\n\n const openBuilder = useCallback(\n (workflowKey: string, version: string) => {\n navigateTo(`workflows/workflow/${workflowKey}/${version || INITIAL_VERSION}`);\n },\n [navigateTo]\n );\n\n const handleDesign = useCallback(async () => {\n setBusy(true);\n try {\n const workflowKey = generateId();\n const name = `${botName} workflow`;\n const created = await createWorkflow({\n workflowKey,\n version: INITIAL_VERSION,\n name,\n description: t(\n 'botlit.botDetail.workflow.createdDescription',\n 'Behaviour designed for this BotManor bot.'\n ),\n definitionJson: buildSeedDefinition(workflowKey, name),\n });\n\n if (!created) {\n throw new Error(\n t('botlit.botDetail.workflow.createError', 'Failed to create the workflow')\n );\n }\n\n await updateBot({ botId, input: { workflowId: created.id } });\n await onWorkflowChanged();\n toast.success(\n t('botlit.botDetail.workflow.createSuccess', 'Workflow created and bound to this bot')\n );\n openBuilder(created.workflowKey, created.version);\n } catch (err: unknown) {\n const message =\n err instanceof Error\n ? err.message\n : t('botlit.botDetail.workflow.createError', 'Failed to create the workflow');\n toast.error(message);\n } finally {\n setBusy(false);\n }\n }, [botId, botName, createWorkflow, onWorkflowChanged, openBuilder, t, updateBot]);\n\n const handleUnbind = useCallback(async () => {\n const confirmed = await confirmAction({\n title: t(\n 'botlit.botDetail.workflow.unbindConfirm',\n 'Unbind this workflow from the bot? The workflow itself is not deleted.'\n ),\n confirmLabel: t('botlit.botDetail.workflow.unbindConfirmAction', 'Unbind'),\n cancelLabel: t('botlit.common.cancel', 'Cancel'),\n });\n if (!confirmed) return;\n setBusy(true);\n try {\n await updateBot({ botId, input: { workflowId: null } });\n await onWorkflowChanged();\n toast.success(t('botlit.botDetail.workflow.unbindSuccess', 'Workflow unbound'));\n } catch (err: unknown) {\n const message =\n err instanceof Error\n ? err.message\n : t('botlit.botDetail.workflow.unbindError', 'Failed to unbind the workflow');\n toast.error(message);\n } finally {\n setBusy(false);\n }\n }, [botId, onWorkflowChanged, t, updateBot]);\n\n // ── Not bound ─────────────────────────────────────────────────────────────\n if (!workflowId) {\n return (\n <Card>\n <CardContent className=\"pt-6\">\n <EmptyState\n illustration=\"empty-generic\"\n title={t('botlit.botDetail.workflow.empty.title', 'Design this bot as a workflow')}\n description={t(\n 'botlit.botDetail.workflow.empty.description',\n \"A bot's behaviour is designed as a FluidGrids workflow — the visual canvas where you wire triggers, agents, tools and conditions together. Start one and we will create it, bind it to this bot and open the builder for you.\"\n )}\n action={\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_UPDATE}>\n <Button\n leftIcon={<Sparkles size={16} />}\n isLoading={busy}\n disabled={busy}\n onClick={() => void handleDesign()}\n >\n {t('botlit.botDetail.workflow.empty.action', 'Design in workflow builder')}\n </Button>\n </BotmanorPermissionGate>\n }\n />\n </CardContent>\n </Card>\n );\n }\n\n // ── Bound ─────────────────────────────────────────────────────────────────\n return (\n <div className=\"space-y-6\">\n <Card>\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <Workflow size={18} />\n {t('botlit.botDetail.workflow.bound.title', 'Bound workflow')}\n </CardTitle>\n <CardDescription>\n {t(\n 'botlit.botDetail.workflow.bound.description',\n 'This workflow defines what the bot does when it is invoked.'\n )}\n </CardDescription>\n </CardHeader>\n <CardContent className=\"space-y-6\">\n {workflowLoading ? (\n <div className=\"h-24 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer\" />\n ) : workflow ? (\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.name', 'Name')}\n </p>\n <p className=\"font-medium text-text-primary\">{workflow.name}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.key', 'Key')}\n </p>\n <p className=\"mt-1 break-all font-mono text-sm text-text-primary\">\n {workflow.workflowKey}\n </p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.version', 'Version')}\n </p>\n <Badge variant=\"outline\" className=\"mt-1\">\n {workflow.version}\n </Badge>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.status', 'Status')}\n </p>\n <div className=\"mt-1\">\n <StatusBadge status={workflow.status} />\n </div>\n </div>\n </div>\n ) : (\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.workflowId', 'Workflow ID')}\n </p>\n <p className=\"mt-1 break-all font-mono text-sm text-text-primary\">{workflowId}</p>\n <p className=\"mt-2 text-sm text-text-secondary\">\n {t(\n 'botlit.botDetail.workflow.unresolved',\n 'This workflow could not be loaded — it may have been deleted. Unbind it and design a new one.'\n )}\n </p>\n </div>\n )}\n\n <div className=\"flex flex-wrap gap-2\">\n {workflow && (\n <Button\n leftIcon={<ExternalLink size={16} />}\n disabled={busy}\n onClick={() => openBuilder(workflow.workflowKey, workflow.version)}\n >\n {t('botlit.botDetail.workflow.actions.openBuilder', 'Open in builder')}\n </Button>\n )}\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_UPDATE}>\n <Button\n variant=\"outline\"\n leftIcon={<Unlink size={16} />}\n isLoading={busy}\n disabled={busy}\n onClick={() => void handleUnbind()}\n >\n {t('botlit.botDetail.workflow.actions.unbind', 'Unbind')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n </CardContent>\n </Card>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAsDA,IAAME,IAAkB,MAOlBC,IAA2B,gBAC3BC,IAA8B,SAC9BC,IAA2B,mBAC3BC,IAAsB,oBACtBC,IACJ,8EAGIC,IAAsB;CAAC;CAAW;CAAU;AAAO;AA0DzD,SAASC,IAAqB;CAC5B,IAAMC,IAAY,WAAW;CAI7B,OAHIA,KAAa,OAAOA,EAAU,cAAe,aACxCA,EAAU,WAAW,IAEvB,GAAG,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,EAAE;AAC7E;AAGA,SAASC,EAAoB,GAAqB,GAA8B;CAuC9E,OAAO;EACL,KAAKC;EACL;EACA,aAAaC;EACb,eAAe;EACf,MAAM;GACJ,IAAID;GACJ;GACA,SAASV;GACT;GACA,OAAO,CAAC;IA/CV,IAAIO,EAAW;IACf,MAAMN;IACN,UAAU;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;IACjF,kBAAC,KAAD;KAAG,WAAU;KACV,UAAAX,EACC,wCACA,+FACF;IACC,CAAA;GACA,EAAA,CAAA,GAGP,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACGiC,KACC,kBAACG,GAAD;KACE,UAAU,kBAACC,GAAD,EAAc,MAAM,GAAK,CAAA;KACnC,UAAU/B;KACV,eAAeM,EAAYqB,EAAS,aAAaA,EAAS,OAAO;KAEhE,UAAAjC,EAAE,iDAAiD,iBAAiB;IAC/D,CAAA,GAEV,kBAACsC,GAAD;KAAwB,YAAYC,EAAqB;KACvD,UAAA,kBAACH,GAAD;MACE,SAAQ;MACR,UAAU,kBAACI,GAAD,EAAQ,MAAM,GAAK,CAAA;MAC7B,WAAWlC;MACX,UAAUA;MACV,eAAe,KAAKmB,EAAa;MAEhC,UAAAzB,EAAE,4CAA4C,QAAQ;KACjD,CAAA;IACc,CAAA,CACrB;GACM,CAAA,CAAA;EACT,CAAA,CAAA,EAAA,CAAA;CACH,CAAA,IAtHH,kBAAC2B,GAAD,EAAA,UACE,kBAACK,GAAD;EAAa,WAAU;EACrB,UAAA,kBAACS,GAAD;GACE,cAAa;GACb,OAAOzC,EAAE,yCAAyC,+BAA+B;GACjF,aAAaA,EACX,+CACA,+NACF;GACA,QACE,kBAACsC,GAAD;IAAwB,YAAYC,EAAqB;IACvD,UAAA,kBAACH,GAAD;KACE,UAAU,kBAACM,GAAD,EAAU,MAAM,GAAK,CAAA;KAC/B,WAAWpC;KACX,UAAUA;KACV,eAAe,KAAKU,EAAa;KAEhC,UAAAhB,EAAE,0CAA0C,4BAA4B;IACnE,CAAA;GACc,CAAA;EAE3B,CAAA;CACU,CAAA,EACT,CAAA;AAiGZ"}
|
|
1
|
+
{"version":3,"file":"BotWorkflowTab.js","names":["useCreateWorkflow","useWorkflowDefinition","INITIAL_VERSION","MANUAL_TRIGGER_NODE_TYPE","MANUAL_TRIGGER_NODE_VERSION","MANUAL_TRIGGER_OPERATION","MANUAL_TRIGGER_NAME","MANUAL_TRIGGER_DESCRIPTION","MANUAL_TRIGGER_KIND","generateId","webCrypto","buildSeedDefinition","workflowKey","name","BotWorkflowTab","t","useTr","useBotlit","useCreateBotWorkflow","updateBot","useUpdateBot","busy","setBusy","useState","workflowLoading","useBotWorkflowDefinition","workflowId","openBuilder","useCallback","version","navigateTo","handleDesign","botName","created","createWorkflow","onWorkflowChanged","toast","err","message","botId","handleUnbind","confirmAction","Card","CardHeader","CardTitle","Workflow","CardDescription","CardContent","workflow","Badge","StatusBadge","Button","ExternalLink","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","Unlink","BotmanorFailureTriageSection","EmptyState","Sparkles","usePermissions","ProductFailureTriagePanel","hasPermission"],"sources":["../../../src/botlit/pages/BotWorkflowTab.tsx"],"sourcesContent":["/**\n * BotWorkflowTab\n * @module botlit/pages\n *\n * Shown inside BotDetailPage → \"Workflow\" tab.\n *\n * A bot's behaviour is designed as a FluidGrids workflow. `BotApp.workflowId`\n * holds the binding (validated server-side by `assertWorkflowBindingsResolvable`\n * on wspace-botlit-svc), and the FluidGrids builder is already mounted INSIDE\n * BotManor at `workflows/workflow/:id/:version` — so this tab never leaves the\n * product.\n *\n * Flow:\n * 1. Bound → resolve the definition by id (`useWorkflowDefinition`), show\n * name / key / version / status, \"Open in builder\", \"Unbind\".\n * A binding that no longer resolves falls back to the raw id so\n * the user can still clear it.\n * 2. Not bound → zero state whose primary action creates a seeded workflow\n * definition, binds it via `updateBotApp(workflowId)` and drops\n * the user straight into the embedded builder.\n *\n * IMPORTANT — seed graph shape. `BotlitFluidGridsBridge.extractTriggerNodeIds`\n * reads nodes from `definitionJson.data.nodes` (NOT the top level) and treats a\n * node as a trigger when its `type` is `trigger`/`trigger:*`/`*_trigger`, OR its\n * `kind[]` / `data.nodeData.kind[]` contains `trigger`. The seed below uses the\n * workflow service's own BUILTIN manual trigger (`internal:api`, \"Trigger\n * Manually\") — the node the executor resolves as the entry point — and carries\n * `kind: ['trigger', ...]` in both places, so a freshly designed bot is\n * immediately runnable instead of failing with `WORKFLOW_NO_TRIGGER_NODE`.\n */\n\nimport type { FC } from 'react';\nimport { useCallback, useState } from 'react';\nimport { ExternalLink, Sparkles, Unlink, Workflow } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { confirmAction } from '../utils/confirmAction';\nimport {\n useCreateBotWorkflow as useCreateWorkflow,\n useBotWorkflowDefinition as useWorkflowDefinition,\n} from '../hooks/useBotWorkflow';\nimport { Card, CardHeader, CardTitle, CardContent, CardDescription } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Badge, StatusBadge } from '../components/Badge';\nimport { EmptyState } from '../components/EmptyState';\nimport { useUpdateBot } from '../hooks/useBots';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { ProductFailureTriagePanel } from '@burdenoff/fe-libs/shared/proactive';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Seed graph\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** First version minted for a bot's workflow — matches the builder's own default. */\nconst INITIAL_VERSION = 'v1';\n\n/**\n * BUILTIN \"Trigger Manually\" node (`MANUAL_TRIGGER_MANIFEST` in\n * wspace-workflow-svc). The executor resolves this type as a workflow's entry\n * node, and the builder renders it from the seeded node registry.\n */\nconst MANUAL_TRIGGER_NODE_TYPE = 'internal:api';\nconst MANUAL_TRIGGER_NODE_VERSION = '1.0.0';\nconst MANUAL_TRIGGER_OPERATION = 'onManualTrigger';\nconst MANUAL_TRIGGER_NAME = 'Trigger Manually';\nconst MANUAL_TRIGGER_DESCRIPTION =\n \"Runs the flow when you click 'Test workflow', or when this bot is invoked.\";\n\n/** `kind[]` the BotManor bridge scans for when classifying a node as a trigger. */\nconst MANUAL_TRIGGER_KIND = ['trigger', 'manual', 'entry'];\n\n/** Node shape written into `definitionJson.data.nodes`. */\ntype SeedNode = {\n id: string;\n type: string;\n position: { x: number; y: number };\n /** Top-level kind — the bridge's second trigger-detection path. */\n kind: string[];\n data: {\n operation_name: string;\n operation_type: string;\n version: string;\n nodeData: {\n nodeType: string;\n name: string;\n description: string;\n version: string;\n /** The bridge's third trigger-detection path. */\n kind: string[];\n operations: { name: string; type: string; role: string; description: string }[];\n };\n args: {\n context: { node: { id: string; type: string; kind: string[] } };\n state: Record<string, never>;\n credentials: never[];\n };\n };\n};\n\n/**\n * `definitionJson` document. Mirrors what the builder itself persists\n * (`useSaveWorkflow`) so the graph round-trips through the builder unchanged.\n */\ntype SeedDefinition = {\n key: string;\n name: string;\n description: string;\n workflow_type: string;\n data: {\n id: string;\n workflowKey: string;\n version: string;\n name: string;\n nodes: SeedNode[];\n edges: never[];\n sidebar: { active: string; panels: { nodeProperties: { selectedNode: null } } };\n stickyNotes: never[];\n };\n meta: { creator: string; version: string };\n tags: string[];\n};\n\n/**\n * Generate an opaque id. `crypto.randomUUID` is unavailable on insecure origins\n * and in some test environments, so fall back to a time+random token rather than\n * throwing mid-create.\n */\nfunction generateId(): string {\n const webCrypto = globalThis.crypto as Crypto | undefined;\n if (webCrypto && typeof webCrypto.randomUUID === 'function') {\n return webCrypto.randomUUID();\n }\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\n/** Build the starter graph: one manual trigger, nothing else. */\nfunction buildSeedDefinition(workflowKey: string, name: string): SeedDefinition {\n const triggerNode: SeedNode = {\n id: generateId(),\n type: MANUAL_TRIGGER_NODE_TYPE,\n position: { x: 160, y: 160 },\n kind: MANUAL_TRIGGER_KIND,\n data: {\n operation_name: MANUAL_TRIGGER_OPERATION,\n operation_type: 'trigger',\n version: MANUAL_TRIGGER_NODE_VERSION,\n nodeData: {\n nodeType: MANUAL_TRIGGER_NODE_TYPE,\n name: MANUAL_TRIGGER_NAME,\n description: MANUAL_TRIGGER_DESCRIPTION,\n version: MANUAL_TRIGGER_NODE_VERSION,\n kind: MANUAL_TRIGGER_KIND,\n operations: [\n {\n name: MANUAL_TRIGGER_OPERATION,\n type: 'trigger',\n role: 'trigger',\n description: MANUAL_TRIGGER_DESCRIPTION,\n },\n ],\n },\n args: {\n context: {\n node: {\n id: MANUAL_TRIGGER_NODE_TYPE,\n type: MANUAL_TRIGGER_NODE_TYPE,\n kind: MANUAL_TRIGGER_KIND,\n },\n },\n state: {},\n credentials: [],\n },\n },\n };\n\n return {\n key: workflowKey,\n name,\n description: name,\n workflow_type: 'query-conditional',\n data: {\n id: workflowKey,\n workflowKey,\n version: INITIAL_VERSION,\n name,\n nodes: [triggerNode],\n edges: [],\n sidebar: { active: 'store-browse', panels: { nodeProperties: { selectedNode: null } } },\n stickyNotes: [],\n },\n meta: { creator: 'botlit_bot_design', version: INITIAL_VERSION },\n tags: [],\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Component\n// ─────────────────────────────────────────────────────────────────────────────\n\ninterface BotWorkflowTabProps {\n botId: string;\n botName: string;\n /** `BotApp.workflowId` — the bound workflow definition id, if any. */\n workflowId: string | null | undefined;\n /** Refetch the bot so the tab reflects the new binding. */\n onWorkflowChanged: () => Promise<void> | void;\n}\n\nexport const BotWorkflowTab: FC<BotWorkflowTabProps> = ({\n botId,\n botName,\n workflowId,\n onWorkflowChanged,\n}) => {\n const t = useTr();\n const { navigateTo } = useBotlit();\n const { createWorkflow } = useCreateWorkflow();\n const [updateBot] = useUpdateBot();\n const [busy, setBusy] = useState(false);\n\n // Resolve by id — `BotApp.workflowId` stores the definition's opaque id, not\n // its workflowKey (which is what the builder route takes). The hook refetches\n // on its own when the bound id changes, so binding/unbinding only has to\n // refresh the bot.\n const { workflow, loading: workflowLoading } = useWorkflowDefinition(\n undefined,\n workflowId ?? undefined\n );\n\n const openBuilder = useCallback(\n (workflowKey: string, version: string) => {\n navigateTo(`workflows/workflow/${workflowKey}/${version || INITIAL_VERSION}`);\n },\n [navigateTo]\n );\n\n const handleDesign = useCallback(async () => {\n setBusy(true);\n try {\n const workflowKey = generateId();\n const name = `${botName} workflow`;\n const created = await createWorkflow({\n workflowKey,\n version: INITIAL_VERSION,\n name,\n description: t(\n 'botlit.botDetail.workflow.createdDescription',\n 'Behaviour designed for this BotManor bot.'\n ),\n definitionJson: buildSeedDefinition(workflowKey, name),\n });\n\n if (!created) {\n throw new Error(\n t('botlit.botDetail.workflow.createError', 'Failed to create the workflow')\n );\n }\n\n await updateBot({ botId, input: { workflowId: created.id } });\n await onWorkflowChanged();\n toast.success(\n t('botlit.botDetail.workflow.createSuccess', 'Workflow created and bound to this bot')\n );\n openBuilder(created.workflowKey, created.version);\n } catch (err: unknown) {\n const message =\n err instanceof Error\n ? err.message\n : t('botlit.botDetail.workflow.createError', 'Failed to create the workflow');\n toast.error(message);\n } finally {\n setBusy(false);\n }\n }, [botId, botName, createWorkflow, onWorkflowChanged, openBuilder, t, updateBot]);\n\n const handleUnbind = useCallback(async () => {\n const confirmed = await confirmAction({\n title: t(\n 'botlit.botDetail.workflow.unbindConfirm',\n 'Unbind this workflow from the bot? The workflow itself is not deleted.'\n ),\n confirmLabel: t('botlit.botDetail.workflow.unbindConfirmAction', 'Unbind'),\n cancelLabel: t('botlit.common.cancel', 'Cancel'),\n });\n if (!confirmed) return;\n setBusy(true);\n try {\n await updateBot({ botId, input: { workflowId: null } });\n await onWorkflowChanged();\n toast.success(t('botlit.botDetail.workflow.unbindSuccess', 'Workflow unbound'));\n } catch (err: unknown) {\n const message =\n err instanceof Error\n ? err.message\n : t('botlit.botDetail.workflow.unbindError', 'Failed to unbind the workflow');\n toast.error(message);\n } finally {\n setBusy(false);\n }\n }, [botId, onWorkflowChanged, t, updateBot]);\n\n // ── Not bound ─────────────────────────────────────────────────────────────\n if (!workflowId) {\n return (\n <Card>\n <CardContent className=\"pt-6\">\n <EmptyState\n illustration=\"empty-generic\"\n title={t('botlit.botDetail.workflow.empty.title', 'Design this bot as a workflow')}\n description={t(\n 'botlit.botDetail.workflow.empty.description',\n \"A bot's behaviour is designed as a FluidGrids workflow — the visual canvas where you wire triggers, agents, tools and conditions together. Start one and we will create it, bind it to this bot and open the builder for you.\"\n )}\n action={\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_UPDATE}>\n <Button\n leftIcon={<Sparkles size={16} />}\n isLoading={busy}\n disabled={busy}\n onClick={() => void handleDesign()}\n >\n {t('botlit.botDetail.workflow.empty.action', 'Design in workflow builder')}\n </Button>\n </BotmanorPermissionGate>\n }\n />\n </CardContent>\n </Card>\n );\n }\n\n // ── Bound ─────────────────────────────────────────────────────────────────\n return (\n <div className=\"space-y-6\">\n <Card>\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <Workflow size={18} />\n {t('botlit.botDetail.workflow.bound.title', 'Bound workflow')}\n </CardTitle>\n <CardDescription>\n {t(\n 'botlit.botDetail.workflow.bound.description',\n 'This workflow defines what the bot does when it is invoked.'\n )}\n </CardDescription>\n </CardHeader>\n <CardContent className=\"space-y-6\">\n {workflowLoading ? (\n <div className=\"h-24 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer\" />\n ) : workflow ? (\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.name', 'Name')}\n </p>\n <p className=\"font-medium text-text-primary\">{workflow.name}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.key', 'Key')}\n </p>\n <p className=\"mt-1 break-all font-mono text-sm text-text-primary\">\n {workflow.workflowKey}\n </p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.version', 'Version')}\n </p>\n <Badge variant=\"outline\" className=\"mt-1\">\n {workflow.version}\n </Badge>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.status', 'Status')}\n </p>\n <div className=\"mt-1\">\n <StatusBadge status={workflow.status} />\n </div>\n </div>\n </div>\n ) : (\n <div>\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botDetail.workflow.fields.workflowId', 'Workflow ID')}\n </p>\n <p className=\"mt-1 break-all font-mono text-sm text-text-primary\">{workflowId}</p>\n <p className=\"mt-2 text-sm text-text-secondary\">\n {t(\n 'botlit.botDetail.workflow.unresolved',\n 'This workflow could not be loaded — it may have been deleted. Unbind it and design a new one.'\n )}\n </p>\n </div>\n )}\n\n <div className=\"flex flex-wrap gap-2\">\n {workflow && (\n <Button\n leftIcon={<ExternalLink size={16} />}\n disabled={busy}\n onClick={() => openBuilder(workflow.workflowKey, workflow.version)}\n >\n {t('botlit.botDetail.workflow.actions.openBuilder', 'Open in builder')}\n </Button>\n )}\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_UPDATE}>\n <Button\n variant=\"outline\"\n leftIcon={<Unlink size={16} />}\n isLoading={busy}\n disabled={busy}\n onClick={() => void handleUnbind()}\n >\n {t('botlit.botDetail.workflow.actions.unbind', 'Unbind')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n </CardContent>\n </Card>\n <BotmanorFailureTriageSection />\n </div>\n );\n};\n\nconst BotmanorFailureTriageSection: FC = () => {\n const { hasPermission } = usePermissions();\n return (\n <ProductFailureTriagePanel\n productId=\"botmanor\"\n canManage={hasPermission(BOTMANOR_PERMISSIONS.APP_UPDATE)}\n className=\"rounded-xl border border-border-default bg-bg-surface p-4\"\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,IAAME,IAAkB,MAOlBC,IAA2B,gBAC3BC,IAA8B,SAC9BC,IAA2B,mBAC3BC,IAAsB,oBACtBC,IACJ,8EAGIC,IAAsB;CAAC;CAAW;CAAU;AAAO;AA0DzD,SAASC,IAAqB;CAC5B,IAAMC,IAAY,WAAW;CAI7B,OAHIA,KAAa,OAAOA,EAAU,cAAe,aACxCA,EAAU,WAAW,IAEvB,GAAG,KAAK,IAAI,CAAC,CAA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C/B,WAAWrC;KACX,UAAUA;KACV,eAAe,KAAKU,EAAa;KAEhC,UAAAhB,EAAE,0CAA0C,4BAA4B;IACnE,CAAA;GACc,CAAA;EAE3B,CAAA;CACU,CAAA,EACT,CAAA;AAkGZ,GAEMyC,UAAyC;CAC7C,IAAM,EAAE,qBAAkBG,EAAe;CACzC,OACE,kBAACC,GAAD;EACE,WAAU;EACV,WAAWC,EAAcP,EAAqB,UAAU;EACxD,WAAU;CACX,CAAA;AAEL"}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const AGENT_NAME_MAX_LENGTH = 100;
|
|
12
12
|
export declare const AGENT_SLUG_MAX_LENGTH = 64;
|
|
13
|
+
export declare const AI_DISCLOSURE_TEXT_MAX_LENGTH = 500;
|
|
14
|
+
export declare const DEFAULT_AI_DISCLOSURE_TEXT = "You are chatting with an AI assistant.";
|
|
13
15
|
/** Slugs kept for the platform because they collide with agent route names. */
|
|
14
16
|
export declare const RESERVED_AGENT_SLUGS: ReadonlySet<string>;
|
|
15
17
|
/** The one default for each numeric setting (the API applies the same ones). */
|
|
@@ -30,11 +32,12 @@ export declare const AGENT_MAX_CONCURRENT_RANGE: {
|
|
|
30
32
|
readonly min: 1;
|
|
31
33
|
readonly max: 100;
|
|
32
34
|
};
|
|
33
|
-
export type AgentFieldError = 'nameRequired' | 'nameTooLong' | 'slugRequired' | 'slugTooLong' | 'slugInvalid' | 'slugReserved' | 'promptRequired' | 'temperatureRange' | 'maxTokensRange' | 'maxConcurrentRange';
|
|
35
|
+
export type AgentFieldError = 'nameRequired' | 'nameTooLong' | 'slugRequired' | 'slugTooLong' | 'slugInvalid' | 'slugReserved' | 'promptRequired' | 'temperatureRange' | 'maxTokensRange' | 'maxConcurrentRange' | 'aiDisclosureTextTooLong';
|
|
34
36
|
export interface AgentFormValues {
|
|
35
37
|
name: string;
|
|
36
38
|
slug: string;
|
|
37
39
|
systemPrompt: string;
|
|
40
|
+
aiDisclosureText?: string;
|
|
38
41
|
temperature: string;
|
|
39
42
|
maxTokens: string;
|
|
40
43
|
maxConcurrentExecutions: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BOT_SLUG_PATTERN as e, slugify as t } from "./botIdentity.js";
|
|
2
|
-
var n = /* @__PURE__ */ new Set([
|
|
2
|
+
var n = "You are chatting with an AI assistant.", r = /* @__PURE__ */ new Set([
|
|
3
3
|
"new",
|
|
4
4
|
"edit",
|
|
5
5
|
"create",
|
|
@@ -8,20 +8,20 @@ var n = /* @__PURE__ */ new Set([
|
|
|
8
8
|
"bots",
|
|
9
9
|
"approvals",
|
|
10
10
|
"settings"
|
|
11
|
-
]),
|
|
11
|
+
]), i = {
|
|
12
12
|
temperature: .7,
|
|
13
13
|
maxTokens: 2048,
|
|
14
14
|
maxConcurrentExecutions: 10
|
|
15
|
-
},
|
|
15
|
+
}, a = {
|
|
16
16
|
min: 0,
|
|
17
17
|
max: 2
|
|
18
|
-
},
|
|
18
|
+
}, o = {
|
|
19
19
|
min: 1,
|
|
20
20
|
max: 2e5
|
|
21
|
-
},
|
|
21
|
+
}, s = {
|
|
22
22
|
min: 1,
|
|
23
23
|
max: 100
|
|
24
|
-
},
|
|
24
|
+
}, c = {
|
|
25
25
|
nameRequired: "Enter a name for the agent.",
|
|
26
26
|
nameTooLong: "Use at most 100 characters for the name.",
|
|
27
27
|
slugRequired: "Enter a slug using letters, numbers and hyphens.",
|
|
@@ -29,50 +29,52 @@ var n = /* @__PURE__ */ new Set([
|
|
|
29
29
|
slugInvalid: "Use only lowercase letters, numbers and single hyphens, for example support-agent.",
|
|
30
30
|
slugReserved: "This slug is reserved. Choose another one.",
|
|
31
31
|
promptRequired: "Enter the system prompt: the instructions the agent follows.",
|
|
32
|
-
temperatureRange: `Temperature must be a number from ${
|
|
33
|
-
maxTokensRange: `Max tokens must be a whole number from ${
|
|
34
|
-
maxConcurrentRange: `Max concurrent executions must be a whole number from ${
|
|
32
|
+
temperatureRange: `Temperature must be a number from ${a.min} to ${a.max}.`,
|
|
33
|
+
maxTokensRange: `Max tokens must be a whole number from ${o.min} to ${o.max}.`,
|
|
34
|
+
maxConcurrentRange: `Max concurrent executions must be a whole number from ${s.min} to ${s.max}.`,
|
|
35
|
+
aiDisclosureTextTooLong: "Use at most 500 characters for the AI disclosure notice."
|
|
35
36
|
};
|
|
36
|
-
function
|
|
37
|
+
function l(e) {
|
|
37
38
|
let t = e.trim();
|
|
38
39
|
if (t !== "") return Number(t);
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
-
let i =
|
|
41
|
+
function u(e, t, n, r) {
|
|
42
|
+
let i = l(e);
|
|
42
43
|
if (i !== void 0 && (!Number.isFinite(i) || i < t.min || i > t.max || n && !Number.isInteger(i))) return r;
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
let
|
|
46
|
-
c.length === 0 ?
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
let d =
|
|
50
|
-
d && (
|
|
51
|
-
let f =
|
|
52
|
-
f && (
|
|
53
|
-
let p =
|
|
54
|
-
return p && (
|
|
45
|
+
function d(n) {
|
|
46
|
+
let i = {}, c = n.name.trim();
|
|
47
|
+
c.length === 0 ? i.name = "nameRequired" : c.length > 100 && (i.name = "nameTooLong");
|
|
48
|
+
let l = n.slug.trim() === "" ? t(c, 64) : n.slug.trim();
|
|
49
|
+
l === "" ? i.slug = "slugRequired" : l.length > 64 ? i.slug = "slugTooLong" : e.test(l) ? r.has(l) && (i.slug = "slugReserved") : i.slug = "slugInvalid", n.systemPrompt.trim().length === 0 && (i.systemPrompt = "promptRequired"), typeof n.aiDisclosureText == "string" && [...n.aiDisclosureText.trim()].length > 500 && (i.aiDisclosureText = "aiDisclosureTextTooLong");
|
|
50
|
+
let d = u(n.temperature, a, !1, "temperatureRange");
|
|
51
|
+
d && (i.temperature = d);
|
|
52
|
+
let f = u(n.maxTokens, o, !0, "maxTokensRange");
|
|
53
|
+
f && (i.maxTokens = f);
|
|
54
|
+
let p = u(n.maxConcurrentExecutions, s, !0, "maxConcurrentRange");
|
|
55
|
+
return p && (i.maxConcurrentExecutions = p), i;
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
+
function f(e, n) {
|
|
57
58
|
return t(n.trim() === "" ? e : n, 64);
|
|
58
59
|
}
|
|
59
|
-
var
|
|
60
|
+
var p = [
|
|
60
61
|
"MCP_TOOLS",
|
|
61
62
|
"RAG",
|
|
62
63
|
"A2A"
|
|
63
64
|
];
|
|
64
|
-
function
|
|
65
|
+
function m(e) {
|
|
65
66
|
let t = [], n = e.capabilities.includes("MCP_TOOLS"), r = e.capabilities.includes("RAG");
|
|
66
67
|
return n && e.mcpServerCount === 0 && t.push("mcpToolsNeedsServer"), r && e.knowledgeBaseCount === 0 && t.push("ragNeedsKnowledgeBase"), !n && e.mcpServerCount > 0 && t.push("serversNeedMcpTools"), !r && e.knowledgeBaseCount > 0 && t.push("knowledgeBasesNeedRag"), t;
|
|
67
68
|
}
|
|
68
|
-
var
|
|
69
|
+
var h = {
|
|
69
70
|
name: "basics",
|
|
70
71
|
slug: "basics",
|
|
71
72
|
systemPrompt: "prompt",
|
|
73
|
+
aiDisclosureText: "prompt",
|
|
72
74
|
temperature: "prompt",
|
|
73
75
|
maxTokens: "prompt",
|
|
74
76
|
maxConcurrentExecutions: "prompt"
|
|
75
77
|
};
|
|
76
|
-
export {
|
|
78
|
+
export { i as AGENT_DEFAULTS, c as AGENT_FIELD_MESSAGES, h as AGENT_FIELD_TAB, s as AGENT_MAX_CONCURRENT_RANGE, o as AGENT_MAX_TOKENS_RANGE, a as AGENT_TEMPERATURE_RANGE, n as DEFAULT_AI_DISCLOSURE_TEXT, p as OFFERED_CAPABILITIES, r as RESERVED_AGENT_SLUGS, f as agentSlugFor, m as capabilityWarnings, l as parseNumberField, d as validateAgentForm };
|
|
77
79
|
|
|
78
80
|
//# sourceMappingURL=agentSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentSettings.js","names":["RESERVED_AGENT_SLUGS","AGENT_DEFAULTS","AGENT_TEMPERATURE_RANGE","AGENT_MAX_TOKENS_RANGE","AGENT_MAX_CONCURRENT_RANGE","AGENT_FIELD_MESSAGES","parseNumberField","trimmed","text","numberError","value","range","whole","error","validateAgentForm","errors","name","values","slug","slugify","BOT_SLUG_PATTERN","temperature","maxTokens","maxConcurrent","agentSlugFor","OFFERED_CAPABILITIES","capabilityWarnings","warnings","hasTools","input","hasRag","AGENT_FIELD_TAB"],"sources":["../../../src/botlit/utils/agentSettings.ts"],"sourcesContent":["/**\n * Agent form rules (BOFF-12447, BOFF-12449, BOFF-12455)\n * @module botlit/utils\n *\n * What a valid agent name, slug, prompt, temperature, token limit and\n * concurrency limit are, shared by the builder and mirrored in\n * `wspace-botmanor-svc` (`agents/agent-settings.ts`), so the form and the server\n * never disagree. 0 is a real temperature: absent and invalid are different\n * from zero, and are never turned into a default silently.\n */\n\nimport { BOT_SLUG_PATTERN, slugify } from './botIdentity';\n\nexport const AGENT_NAME_MAX_LENGTH = 100;\nexport const AGENT_SLUG_MAX_LENGTH = 64;\n\n/** Slugs kept for the platform because they collide with agent route names. */\nexport const RESERVED_AGENT_SLUGS: ReadonlySet<string> = new Set([\n 'new',\n 'edit',\n 'create',\n 'admin',\n 'api',\n 'bots',\n 'approvals',\n 'settings',\n]);\n\n/** The one default for each numeric setting (the API applies the same ones). */\nexport const AGENT_DEFAULTS = {\n temperature: 0.7,\n maxTokens: 2048,\n maxConcurrentExecutions: 10,\n} as const;\n\nexport const AGENT_TEMPERATURE_RANGE = { min: 0, max: 2 } as const;\nexport const AGENT_MAX_TOKENS_RANGE = { min: 1, max: 200_000 } as const;\nexport const AGENT_MAX_CONCURRENT_RANGE = { min: 1, max: 100 } as const;\n\nexport type AgentFieldError =\n | 'nameRequired'\n | 'nameTooLong'\n | 'slugRequired'\n | 'slugTooLong'\n | 'slugInvalid'\n | 'slugReserved'\n | 'promptRequired'\n | 'temperatureRange'\n | 'maxTokensRange'\n | 'maxConcurrentRange';\n\nexport interface AgentFormValues {\n name: string;\n slug: string;\n systemPrompt: string;\n temperature: string;\n maxTokens: string;\n maxConcurrentExecutions: string;\n}\n\nexport type AgentFormErrors = Partial<Record<keyof AgentFormValues, AgentFieldError>>;\n\n/** English fallbacks, keyed so callers translate through `useTr`. */\nexport const AGENT_FIELD_MESSAGES: Record<AgentFieldError, string> = {\n nameRequired: 'Enter a name for the agent.',\n nameTooLong: `Use at most ${AGENT_NAME_MAX_LENGTH} characters for the name.`,\n slugRequired: 'Enter a slug using letters, numbers and hyphens.',\n slugTooLong: `Use at most ${AGENT_SLUG_MAX_LENGTH} characters for the slug.`,\n slugInvalid: 'Use only lowercase letters, numbers and single hyphens, for example support-agent.',\n slugReserved: 'This slug is reserved. Choose another one.',\n promptRequired: 'Enter the system prompt: the instructions the agent follows.',\n temperatureRange: `Temperature must be a number from ${AGENT_TEMPERATURE_RANGE.min} to ${AGENT_TEMPERATURE_RANGE.max}.`,\n maxTokensRange: `Max tokens must be a whole number from ${AGENT_MAX_TOKENS_RANGE.min} to ${AGENT_MAX_TOKENS_RANGE.max}.`,\n maxConcurrentRange: `Max concurrent executions must be a whole number from ${AGENT_MAX_CONCURRENT_RANGE.min} to ${AGENT_MAX_CONCURRENT_RANGE.max}.`,\n};\n\n/** A blank field means \"use the default\" (undefined); text that is not a finite number is NaN, so it can be refused. */\nexport function parseNumberField(text: string): number | undefined {\n const trimmed = text.trim();\n if (trimmed === '') return undefined;\n return Number(trimmed);\n}\n\nfunction numberError(\n text: string,\n range: { min: number; max: number },\n whole: boolean,\n error: AgentFieldError\n): AgentFieldError | undefined {\n const value = parseNumberField(text);\n if (value === undefined) return undefined;\n if (!Number.isFinite(value) || value < range.min || value > range.max) return error;\n if (whole && !Number.isInteger(value)) return error;\n return undefined;\n}\n\n/**\n * Validates the agent form. An empty slug is fine when one can be derived from\n * the name; it is an error when the name has no usable letters. Blank numeric\n * fields are valid: they mean the default.\n */\nexport function validateAgentForm(values: AgentFormValues): AgentFormErrors {\n const errors: AgentFormErrors = {};\n const name = values.name.trim();\n\n if (name.length === 0) errors.name = 'nameRequired';\n else if (name.length > AGENT_NAME_MAX_LENGTH) errors.name = 'nameTooLong';\n\n const slug =\n values.slug.trim() === '' ? slugify(name, AGENT_SLUG_MAX_LENGTH) : values.slug.trim();\n if (slug === '') errors.slug = 'slugRequired';\n else if (slug.length > AGENT_SLUG_MAX_LENGTH) errors.slug = 'slugTooLong';\n else if (!BOT_SLUG_PATTERN.test(slug)) errors.slug = 'slugInvalid';\n else if (RESERVED_AGENT_SLUGS.has(slug)) errors.slug = 'slugReserved';\n\n if (values.systemPrompt.trim().length === 0) errors.systemPrompt = 'promptRequired';\n\n const temperature = numberError(\n values.temperature,\n AGENT_TEMPERATURE_RANGE,\n false,\n 'temperatureRange'\n );\n if (temperature) errors.temperature = temperature;\n const maxTokens = numberError(values.maxTokens, AGENT_MAX_TOKENS_RANGE, true, 'maxTokensRange');\n if (maxTokens) errors.maxTokens = maxTokens;\n const maxConcurrent = numberError(\n values.maxConcurrentExecutions,\n AGENT_MAX_CONCURRENT_RANGE,\n true,\n 'maxConcurrentRange'\n );\n if (maxConcurrent) errors.maxConcurrentExecutions = maxConcurrent;\n\n return errors;\n}\n\n/** The slug to send: the typed one (normalised), else one made from the name. */\nexport function agentSlugFor(name: string, slug: string): string {\n return slugify(slug.trim() === '' ? name : slug, AGENT_SLUG_MAX_LENGTH);\n}\n\n/**\n * The capabilities the builder offers (BOFF-12450). Only these change what an\n * agent does at runtime: MCP tools (when MCP servers are attached), RAG (when a\n * knowledge base is attached) and agent-to-agent delegation. The others in the\n * schema (REASONING, MULTIMODAL, MEMORY, CODE_EXECUTION, WEB_BROWSING) are not\n * read by the chat or channel runtime, so they are not offered; a value an\n * agent already carries is kept as saved, never dropped silently.\n */\nexport const OFFERED_CAPABILITIES = ['MCP_TOOLS', 'RAG', 'A2A'] as const;\nexport type OfferedCapability = (typeof OFFERED_CAPABILITIES)[number];\n\nexport type CapabilityWarning =\n 'mcpToolsNeedsServer' | 'ragNeedsKnowledgeBase' | 'serversNeedMcpTools' | 'knowledgeBasesNeedRag';\n\n/**\n * Mismatches between the ticked capabilities and what is attached. Each one\n * means something configured has no effect at runtime, which otherwise fails\n * silently.\n */\nexport function capabilityWarnings(input: {\n capabilities: readonly string[];\n mcpServerCount: number;\n knowledgeBaseCount: number;\n}): CapabilityWarning[] {\n const warnings: CapabilityWarning[] = [];\n const hasTools = input.capabilities.includes('MCP_TOOLS');\n const hasRag = input.capabilities.includes('RAG');\n if (hasTools && input.mcpServerCount === 0) warnings.push('mcpToolsNeedsServer');\n if (hasRag && input.knowledgeBaseCount === 0) warnings.push('ragNeedsKnowledgeBase');\n if (!hasTools && input.mcpServerCount > 0) warnings.push('serversNeedMcpTools');\n if (!hasRag && input.knowledgeBaseCount > 0) warnings.push('knowledgeBasesNeedRag');\n return warnings;\n}\n\n/** Which builder tab holds each form field, so a tab can show that it has a problem. */\nexport const AGENT_FIELD_TAB: Record<keyof AgentFormValues, 'basics' | 'prompt'> = {\n name: 'basics',\n slug: 'basics',\n systemPrompt: 'prompt',\n temperature: 'prompt',\n maxTokens: 'prompt',\n maxConcurrentExecutions: 'prompt',\n};\n"],"mappings":";AAiBA,IAAaA,oBAA4C,IAAI,IAAI;CAC/D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,GAGYC,IAAiB;CAC5B,aAAa;CACb,WAAW;CACX,yBAAyB;AAC3B,GAEaC,IAA0B;CAAE,KAAK;CAAG,KAAK;AAAE,GAC3CC,IAAyB;CAAE,KAAK;CAAG,KAAK;AAAQ,GAChDC,IAA6B;CAAE,KAAK;CAAG,KAAK;AAAI,GA0BhDC,IAAwD;CACnE,cAAc;CACd,aAAa;CACb,cAAc;CACd,aAAa;CACb,aAAa;CACb,cAAc;CACd,gBAAgB;CAChB,kBAAkB,qCAAqCH,EAAwB,IAAI,MAAMA,EAAwB,IAAI;CACrH,gBAAgB,0CAA0CC,EA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7CR;AACT;AAGA,SAAgBS,EAAa,GAAc,GAAsB;CAC/D,OAAOL,EAAQD,EAAK,KAAK,MAAM,KAAKF,IAAOE,GAAA,EAA2B;AACxE;AAUA,IAAaO,IAAuB;CAAC;CAAa;CAAO;AAAK;AAW9D,SAAgBC,EAAmB,GAIX;CACtB,IAAMC,IAAgC,CAAC,GACjCC,IAAWC,EAAM,aAAa,SAAS,WAAW,GAClDC,IAASD,EAAM,aAAa,SAAS,KAAK;CAKhD,OAJID,KAAYC,EAAM,mBAAmB,KAAGF,EAAS,KAAK,qBAAqB,GAC3EG,KAAUD,EAAM,uBAAuB,KAAGF,EAAS,KAAK,uBAAuB,GAC/E,CAACC,KAAYC,EAAM,iBAAiB,KAAGF,EAAS,KAAK,qBAAqB,GAC1E,CAACG,KAAUD,EAAM,qBAAqB,KAAGF,EAAS,KAAK,uBAAuB,GAC3EA;AACT;AAGA,IAAaI,IAAsE;CACjF,MAAM;CACN,MAAM;CACN,cAAc;CACd,aAAa;CACb,WAAW;CACX,yBAAyB;AAC3B"}
|
|
1
|
+
{"version":3,"file":"agentSettings.js","names":["DEFAULT_AI_DISCLOSURE_TEXT","RESERVED_AGENT_SLUGS","AGENT_DEFAULTS","AGENT_TEMPERATURE_RANGE","AGENT_MAX_TOKENS_RANGE","AGENT_MAX_CONCURRENT_RANGE","AGENT_FIELD_MESSAGES","parseNumberField","trimmed","text","numberError","value","range","whole","error","validateAgentForm","errors","name","values","slug","slugify","BOT_SLUG_PATTERN","temperature","maxTokens","maxConcurrent","agentSlugFor","OFFERED_CAPABILITIES","capabilityWarnings","warnings","hasTools","input","hasRag","AGENT_FIELD_TAB"],"sources":["../../../src/botlit/utils/agentSettings.ts"],"sourcesContent":["/**\n * Agent form rules (BOFF-12447, BOFF-12449, BOFF-12455)\n * @module botlit/utils\n *\n * What a valid agent name, slug, prompt, temperature, token limit and\n * concurrency limit are, shared by the builder and mirrored in\n * `wspace-botmanor-svc` (`agents/agent-settings.ts`), so the form and the server\n * never disagree. 0 is a real temperature: absent and invalid are different\n * from zero, and are never turned into a default silently.\n */\n\nimport { BOT_SLUG_PATTERN, slugify } from './botIdentity';\n\nexport const AGENT_NAME_MAX_LENGTH = 100;\nexport const AGENT_SLUG_MAX_LENGTH = 64;\nexport const AI_DISCLOSURE_TEXT_MAX_LENGTH = 500;\nexport const DEFAULT_AI_DISCLOSURE_TEXT = 'You are chatting with an AI assistant.';\n\n/** Slugs kept for the platform because they collide with agent route names. */\nexport const RESERVED_AGENT_SLUGS: ReadonlySet<string> = new Set([\n 'new',\n 'edit',\n 'create',\n 'admin',\n 'api',\n 'bots',\n 'approvals',\n 'settings',\n]);\n\n/** The one default for each numeric setting (the API applies the same ones). */\nexport const AGENT_DEFAULTS = {\n temperature: 0.7,\n maxTokens: 2048,\n maxConcurrentExecutions: 10,\n} as const;\n\nexport const AGENT_TEMPERATURE_RANGE = { min: 0, max: 2 } as const;\nexport const AGENT_MAX_TOKENS_RANGE = { min: 1, max: 200_000 } as const;\nexport const AGENT_MAX_CONCURRENT_RANGE = { min: 1, max: 100 } as const;\n\nexport type AgentFieldError =\n | 'nameRequired'\n | 'nameTooLong'\n | 'slugRequired'\n | 'slugTooLong'\n | 'slugInvalid'\n | 'slugReserved'\n | 'promptRequired'\n | 'temperatureRange'\n | 'maxTokensRange'\n | 'maxConcurrentRange'\n | 'aiDisclosureTextTooLong';\n\nexport interface AgentFormValues {\n name: string;\n slug: string;\n systemPrompt: string;\n aiDisclosureText?: string;\n temperature: string;\n maxTokens: string;\n maxConcurrentExecutions: string;\n}\n\nexport type AgentFormErrors = Partial<Record<keyof AgentFormValues, AgentFieldError>>;\n\n/** English fallbacks, keyed so callers translate through `useTr`. */\nexport const AGENT_FIELD_MESSAGES: Record<AgentFieldError, string> = {\n nameRequired: 'Enter a name for the agent.',\n nameTooLong: `Use at most ${AGENT_NAME_MAX_LENGTH} characters for the name.`,\n slugRequired: 'Enter a slug using letters, numbers and hyphens.',\n slugTooLong: `Use at most ${AGENT_SLUG_MAX_LENGTH} characters for the slug.`,\n slugInvalid: 'Use only lowercase letters, numbers and single hyphens, for example support-agent.',\n slugReserved: 'This slug is reserved. Choose another one.',\n promptRequired: 'Enter the system prompt: the instructions the agent follows.',\n temperatureRange: `Temperature must be a number from ${AGENT_TEMPERATURE_RANGE.min} to ${AGENT_TEMPERATURE_RANGE.max}.`,\n maxTokensRange: `Max tokens must be a whole number from ${AGENT_MAX_TOKENS_RANGE.min} to ${AGENT_MAX_TOKENS_RANGE.max}.`,\n maxConcurrentRange: `Max concurrent executions must be a whole number from ${AGENT_MAX_CONCURRENT_RANGE.min} to ${AGENT_MAX_CONCURRENT_RANGE.max}.`,\n aiDisclosureTextTooLong: `Use at most ${AI_DISCLOSURE_TEXT_MAX_LENGTH} characters for the AI disclosure notice.`,\n};\n\n/** A blank field means \"use the default\" (undefined); text that is not a finite number is NaN, so it can be refused. */\nexport function parseNumberField(text: string): number | undefined {\n const trimmed = text.trim();\n if (trimmed === '') return undefined;\n return Number(trimmed);\n}\n\nfunction numberError(\n text: string,\n range: { min: number; max: number },\n whole: boolean,\n error: AgentFieldError\n): AgentFieldError | undefined {\n const value = parseNumberField(text);\n if (value === undefined) return undefined;\n if (!Number.isFinite(value) || value < range.min || value > range.max) return error;\n if (whole && !Number.isInteger(value)) return error;\n return undefined;\n}\n\n/**\n * Validates the agent form. An empty slug is fine when one can be derived from\n * the name; it is an error when the name has no usable letters. Blank numeric\n * fields are valid: they mean the default.\n */\nexport function validateAgentForm(values: AgentFormValues): AgentFormErrors {\n const errors: AgentFormErrors = {};\n const name = values.name.trim();\n\n if (name.length === 0) errors.name = 'nameRequired';\n else if (name.length > AGENT_NAME_MAX_LENGTH) errors.name = 'nameTooLong';\n\n const slug =\n values.slug.trim() === '' ? slugify(name, AGENT_SLUG_MAX_LENGTH) : values.slug.trim();\n if (slug === '') errors.slug = 'slugRequired';\n else if (slug.length > AGENT_SLUG_MAX_LENGTH) errors.slug = 'slugTooLong';\n else if (!BOT_SLUG_PATTERN.test(slug)) errors.slug = 'slugInvalid';\n else if (RESERVED_AGENT_SLUGS.has(slug)) errors.slug = 'slugReserved';\n\n if (values.systemPrompt.trim().length === 0) errors.systemPrompt = 'promptRequired';\n\n if (\n typeof values.aiDisclosureText === 'string' &&\n [...values.aiDisclosureText.trim()].length > AI_DISCLOSURE_TEXT_MAX_LENGTH\n ) {\n errors.aiDisclosureText = 'aiDisclosureTextTooLong';\n }\n\n const temperature = numberError(\n values.temperature,\n AGENT_TEMPERATURE_RANGE,\n false,\n 'temperatureRange'\n );\n if (temperature) errors.temperature = temperature;\n const maxTokens = numberError(values.maxTokens, AGENT_MAX_TOKENS_RANGE, true, 'maxTokensRange');\n if (maxTokens) errors.maxTokens = maxTokens;\n const maxConcurrent = numberError(\n values.maxConcurrentExecutions,\n AGENT_MAX_CONCURRENT_RANGE,\n true,\n 'maxConcurrentRange'\n );\n if (maxConcurrent) errors.maxConcurrentExecutions = maxConcurrent;\n\n return errors;\n}\n\n/** The slug to send: the typed one (normalised), else one made from the name. */\nexport function agentSlugFor(name: string, slug: string): string {\n return slugify(slug.trim() === '' ? name : slug, AGENT_SLUG_MAX_LENGTH);\n}\n\n/**\n * The capabilities the builder offers (BOFF-12450). Only these change what an\n * agent does at runtime: MCP tools (when MCP servers are attached), RAG (when a\n * knowledge base is attached) and agent-to-agent delegation. The others in the\n * schema (REASONING, MULTIMODAL, MEMORY, CODE_EXECUTION, WEB_BROWSING) are not\n * read by the chat or channel runtime, so they are not offered; a value an\n * agent already carries is kept as saved, never dropped silently.\n */\nexport const OFFERED_CAPABILITIES = ['MCP_TOOLS', 'RAG', 'A2A'] as const;\nexport type OfferedCapability = (typeof OFFERED_CAPABILITIES)[number];\n\nexport type CapabilityWarning =\n 'mcpToolsNeedsServer' | 'ragNeedsKnowledgeBase' | 'serversNeedMcpTools' | 'knowledgeBasesNeedRag';\n\n/**\n * Mismatches between the ticked capabilities and what is attached. Each one\n * means something configured has no effect at runtime, which otherwise fails\n * silently.\n */\nexport function capabilityWarnings(input: {\n capabilities: readonly string[];\n mcpServerCount: number;\n knowledgeBaseCount: number;\n}): CapabilityWarning[] {\n const warnings: CapabilityWarning[] = [];\n const hasTools = input.capabilities.includes('MCP_TOOLS');\n const hasRag = input.capabilities.includes('RAG');\n if (hasTools && input.mcpServerCount === 0) warnings.push('mcpToolsNeedsServer');\n if (hasRag && input.knowledgeBaseCount === 0) warnings.push('ragNeedsKnowledgeBase');\n if (!hasTools && input.mcpServerCount > 0) warnings.push('serversNeedMcpTools');\n if (!hasRag && input.knowledgeBaseCount > 0) warnings.push('knowledgeBasesNeedRag');\n return warnings;\n}\n\n/** Which builder tab holds each form field, so a tab can show that it has a problem. */\nexport const AGENT_FIELD_TAB: Record<keyof AgentFormValues, 'basics' | 'prompt'> = {\n name: 'basics',\n slug: 'basics',\n systemPrompt: 'prompt',\n aiDisclosureText: 'prompt',\n temperature: 'prompt',\n maxTokens: 'prompt',\n maxConcurrentExecutions: 'prompt',\n};\n"],"mappings":";AAgBA,IAAaA,IAA6B,0CAG7BC,oBAA4C,IAAI,IAAI;CAC/D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,GAGYC,IAAiB;CAC5B,aAAa;CACb,WAAW;CACX,yBAAyB;AAC3B,GAEaC,IAA0B;CAAE,KAAK;CAAG,KAAK;AAAE,GAC3CC,IAAyB;CAAE,KAAK;CAAG,KAAK;AAAQ,GAChDC,IAA6B;CAAE,KAAK;CAAG,KAAK;AAAI,GA4BhDC,IAAwD;CACnE,cAAc;CACd,aAAa;CACb,cAAc;CACd,aAAa;CACb,aAAa;CACb,cAAc;CACd,gBAAgB;CAChB,kBAAkB,qCAAqCH,EAAwB,IAAI,MAAMA,EAAwB,IAAI;CACrH,gBAAgB,0CAA0CC,EAAuB,IAAI,MAAMA,EAAuB,IAAI;CACtH,oBAAoB,yDAAyDC,EAA2B,IAAI,MAAMA,EAA2B,IAAI;CACjJ,yBAAyB;AAC3B;AAGA,SAAgBE,EAAiB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7CR;AACT;AAGA,SAAgBS,EAAa,GAAc,GAAsB;CAC/D,OAAOL,EAAQD,EAAK,KAAK,MAAM,KAAKF,IAAOE,GAAA,EAA2B;AACxE;AAUA,IAAaO,IAAuB;CAAC;CAAa;CAAO;AAAK;AAW9D,SAAgBC,EAAmB,GAIX;CACtB,IAAMC,IAAgC,CAAC,GACjCC,IAAWC,EAAM,aAAa,SAAS,WAAW,GAClDC,IAASD,EAAM,aAAa,SAAS,KAAK;CAKhD,OAJID,KAAYC,EAAM,mBAAmB,KAAGF,EAAS,KAAK,qBAAqB,GAC3EG,KAAUD,EAAM,uBAAuB,KAAGF,EAAS,KAAK,uBAAuB,GAC/E,CAACC,KAAYC,EAAM,iBAAiB,KAAGF,EAAS,KAAK,qBAAqB,GAC1E,CAACG,KAAUD,EAAM,qBAAqB,KAAGF,EAAS,KAAK,uBAAuB,GAC3EA;AACT;AAGA,IAAaI,IAAsE;CACjF,MAAM;CACN,MAAM;CACN,cAAc;CACd,kBAAkB;CAClB,aAAa;CACb,WAAW;CACX,yBAAyB;AAC3B"}
|
|
@@ -250,6 +250,8 @@ export type CreateBotAppInput = {
|
|
|
250
250
|
workspaceId: string | number;
|
|
251
251
|
};
|
|
252
252
|
export type CreateBotmanorAgentInput = {
|
|
253
|
+
aiDisclosureEnabled?: boolean | null | undefined;
|
|
254
|
+
aiDisclosureText?: string | null | undefined;
|
|
253
255
|
/** Emoji shown for the agent (up to 32 characters). An empty string clears it. */
|
|
254
256
|
avatar?: string | null | undefined;
|
|
255
257
|
bucketId?: string | number | null | undefined;
|
|
@@ -780,6 +782,8 @@ export type UpdateBotAppInput = {
|
|
|
780
782
|
workflowId?: string | number | null | undefined;
|
|
781
783
|
};
|
|
782
784
|
export type UpdateBotmanorAgentInput = {
|
|
785
|
+
aiDisclosureEnabled?: boolean | null | undefined;
|
|
786
|
+
aiDisclosureText?: string | null | undefined;
|
|
783
787
|
/** Emoji shown for the agent (up to 32 characters). An empty string clears it. */
|
|
784
788
|
avatar?: string | null | undefined;
|
|
785
789
|
bucketId?: string | number | null | undefined;
|