@burdenoff/microfe-botmanor 2026.1202.1 → 2026.1203.1

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.
@@ -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 { ExternalLink as x, Sparkles as S, Unlink as C, Workflow as w } from "lucide-react";
16
- import { toast as T } from "sonner";
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 E = "v1", D = "internal:api", O = "1.0.0", k = "onManualTrigger", A = "Trigger Manually", j = "Runs the flow when you click 'Test workflow', or when this bot is invoked.", M = [
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 N() {
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 P(e, t) {
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: E,
38
+ version: O,
37
39
  name: t,
38
40
  nodes: [{
39
- id: N(),
40
- type: D,
41
+ id: F(),
42
+ type: k,
41
43
  position: {
42
44
  x: 160,
43
45
  y: 160
44
46
  },
45
- kind: M,
47
+ kind: P,
46
48
  data: {
47
- operation_name: k,
49
+ operation_name: j,
48
50
  operation_type: "trigger",
49
- version: O,
51
+ version: A,
50
52
  nodeData: {
51
- nodeType: D,
52
- name: A,
53
- description: j,
54
- version: O,
55
- kind: M,
53
+ nodeType: k,
54
+ name: M,
55
+ description: N,
56
+ version: A,
57
+ kind: P,
56
58
  operations: [{
57
- name: k,
59
+ name: j,
58
60
  type: "trigger",
59
61
  role: "trigger",
60
- description: j
62
+ description: N
61
63
  }]
62
64
  },
63
65
  args: {
64
66
  context: { node: {
65
- id: D,
66
- type: D,
67
- kind: M
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: E
85
+ version: O
84
86
  },
85
87
  tags: []
86
88
  };
87
89
  }
88
- var F = ({ botId: D, botName: O, workflowId: k, onWorkflowChanged: A }) => {
89
- let j = e(), { navigateTo: M } = g(), { createWorkflow: F } = r(), [I] = h(), [L, R] = v(!1), { workflow: z, loading: B } = n(void 0, k ?? void 0), V = _((e, t) => {
90
- M(`workflows/workflow/${e}/${t || E}`);
91
- }, [M]), H = _(async () => {
92
- R(!0);
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 = N(), t = `${O} workflow`, n = await F({
96
+ let e = F(), t = `${D} workflow`, n = await N({
95
97
  workflowKey: e,
96
- version: E,
98
+ version: O,
97
99
  name: t,
98
100
  description: j("botlit.botDetail.workflow.createdDescription", "Behaviour designed for this BotManor bot."),
99
- definitionJson: P(e, t)
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 I({
103
- botId: D,
104
+ await P({
105
+ botId: x,
104
106
  input: { workflowId: n.id }
105
- }), await A(), T.success(j("botlit.botDetail.workflow.createSuccess", "Workflow created and bound to this bot")), V(n.workflowKey, n.version);
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
- T.error(t);
110
+ E.error(t);
109
111
  } finally {
110
- R(!1);
112
+ z(!1);
111
113
  }
112
114
  }, [
115
+ x,
113
116
  D,
114
- O,
115
- F,
117
+ N,
116
118
  A,
117
- V,
119
+ H,
118
120
  j,
119
- I
120
- ]), U = _(async () => {
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
- R(!0);
128
+ z(!0);
127
129
  try {
128
- await I({
129
- botId: D,
130
+ await P({
131
+ botId: x,
130
132
  input: { workflowId: null }
131
- }), await A(), T.success(j("botlit.botDetail.workflow.unbindSuccess", "Workflow unbound"));
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
- T.error(t);
136
+ E.error(t);
135
137
  } finally {
136
- R(!1);
138
+ z(!1);
137
139
  }
138
140
  }
139
141
  }, [
140
- D,
142
+ x,
141
143
  A,
142
144
  j,
143
- I
145
+ P
144
146
  ]);
145
- return k ? /* @__PURE__ */ y("div", {
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(w, { size: 18 }), j("botlit.botDetail.workflow.bound.title", "Bound workflow")]
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: [B ? /* @__PURE__ */ y("div", { className: "h-24 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer" }) : z ? /* @__PURE__ */ b("div", {
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: z.name
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: z.workflowKey
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: z.version
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: z.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: [z && /* @__PURE__ */ y(d, {
201
- leftIcon: /* @__PURE__ */ y(x, { size: 16 }),
202
+ children: [B && /* @__PURE__ */ y(d, {
203
+ leftIcon: /* @__PURE__ */ y(S, { size: 16 }),
202
204
  disabled: L,
203
- onClick: () => V(z.workflowKey, z.version),
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(C, { size: 16 }),
211
+ leftIcon: /* @__PURE__ */ y(w, { size: 16 }),
210
212
  isLoading: L,
211
213
  disabled: L,
212
- onClick: () => void U(),
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(S, { size: 16 }),
229
+ leftIcon: /* @__PURE__ */ y(C, { size: 16 }),
228
230
  isLoading: L,
229
231
  disabled: L,
230
- onClick: () => void H(),
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 { F as BotWorkflowTab };
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;KAAE,GAAG;KAAK,GAAG;IAAI;IAC3B,MAAMK;IACN,MAAM;KACJ,gBAAgBH;KAChB,gBAAgB;KAChB,SAASD;KACT,UAAU;MACR,UAAUD;MACV,MAAMG;MACN,aAAaC;MACb,SAASH;MACT,MAAMI;MACN,YAAY,CACV;OACE,MAAMH;OACN,MAAM;OACN,MAAM;OACN,aAAaE;MACf,CACF;KACF;KACA,MAAM;MACJ,SAAS,EACP,MAAM;OACJ,IAAIJ;OACJ,MAAMA;OACN,MAAMK;MACR,EACF;MACA,OAAO,CAAC;MACR,aAAa,CAAC;KAChB;IACF;GAaU,CAAW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AD;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,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;KAAE,GAAG;KAAK,GAAG;IAAI;IAC3B,MAAMK;IACN,MAAM;KACJ,gBAAgBH;KAChB,gBAAgB;KAChB,SAASD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202.1",
3
+ "version": "2026.1203.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Algoshred/microfe-botmanor.git"
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@apollo/client": "^4.3.7",
57
- "@burdenoff/fe-libs": "2026.1126.9",
57
+ "@burdenoff/fe-libs": "2026.1202.21",
58
58
  "@tanstack/react-query": "^5.106.1",
59
59
  "clsx": "^2.1.1",
60
60
  "graphql": "^16.15.0",
@@ -102,7 +102,7 @@
102
102
  },
103
103
  "peerDependencies": {
104
104
  "@apollo/client": "^4.0.11",
105
- "@burdenoff/fe-libs": "2026.1126.9",
105
+ "@burdenoff/fe-libs": ">=2026.1202.21",
106
106
  "@tanstack/react-query": "^5.90.16",
107
107
  "clsx": "^2.1.1",
108
108
  "graphql": "^16.12.0",