@burdenoff/microfe-botmanor 2026.1120.4 → 2026.1120.6

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.
@@ -9,41 +9,38 @@ import { Button as p } from "../components/Button.js";
9
9
  import { Badge as m } from "../components/Badge.js";
10
10
  import { ErrorState as h } from "../components/ErrorState.js";
11
11
  import { ExecutionModelFallback as g } from "../components/ExecutionModelFallback.js";
12
- import { useCreateExecution as _, useExecution as v } from "../hooks/useExecutions.js";
12
+ import { useExecution as _ } from "../hooks/useExecutions.js";
13
+ import { useRerunExecution as v } from "../hooks/useRerunExecution.js";
13
14
  import { formatCurrency as y, formatDuration as b, formatNumber as x, formatRelativeTime as S } from "../utils/formatters.js";
14
- import { toUnion as C } from "../utils/unions.js";
15
- import { ExecutionStatus as w } from "../../generated/wspace-types.js";
15
+ import { ExecutionStatus as C } from "../../generated/wspace-types.js";
16
16
  import "../permissions/index.js";
17
+ import { useEffect as w } from "react";
17
18
  import { PagePurpose as T } from "@burdenoff/fe-libs/ui";
18
19
  import { jsx as E, jsxs as D } from "react/jsx-runtime";
19
20
  import { useParams as O } from "react-router";
20
21
  import { AlertTriangle as k, ArrowLeft as A, CheckCircle as j, Clock as M, Copy as N, DollarSign as P, Hourglass as F, Play as I, RefreshCw as L, XCircle as R, Zap as z } from "lucide-react";
21
22
  import { toast as B } from "sonner";
22
23
  // src/botlit/pages/ExecutionDetailPage.tsx
23
- var V = [
24
- "AGENT",
25
- "APP",
26
- "WORKFLOW"
27
- ], H = (e) => {
24
+ var V = 3e3, H = /* @__PURE__ */ new Set(["AGENT", "APP"]), U = (e) => {
28
25
  switch (e) {
29
- case w.Completed: return /* @__PURE__ */ E(j, {
26
+ case C.Completed: return /* @__PURE__ */ E(j, {
30
27
  className: "text-status-success-text",
31
28
  size: 20
32
29
  });
33
- case w.Failed:
34
- case w.Timeout: return /* @__PURE__ */ E(R, {
30
+ case C.Failed:
31
+ case C.Timeout: return /* @__PURE__ */ E(R, {
35
32
  className: "text-status-error-text",
36
33
  size: 20
37
34
  });
38
- case w.Cancelled: return /* @__PURE__ */ E(R, {
35
+ case C.Cancelled: return /* @__PURE__ */ E(R, {
39
36
  className: "text-text-secondary",
40
37
  size: 20
41
38
  });
42
- case w.Running: return /* @__PURE__ */ E(L, {
39
+ case C.Running: return /* @__PURE__ */ E(L, {
43
40
  className: "text-status-info-text motion-safe:animate-spin",
44
41
  size: 20
45
42
  });
46
- case w.Pending: return /* @__PURE__ */ E(F, {
43
+ case C.Pending: return /* @__PURE__ */ E(F, {
47
44
  className: "text-status-warning-text",
48
45
  size: 20
49
46
  });
@@ -52,52 +49,49 @@ var V = [
52
49
  size: 20
53
50
  });
54
51
  }
55
- }, U = (e) => {
52
+ }, W = (e) => {
56
53
  switch (e) {
57
- case w.Completed: return "success";
58
- case w.Failed:
59
- case w.Timeout: return "destructive";
60
- case w.Pending: return "warning";
61
- case w.Running: return "default";
54
+ case C.Completed: return "success";
55
+ case C.Failed:
56
+ case C.Timeout: return "destructive";
57
+ case C.Pending: return "warning";
58
+ case C.Running: return "default";
62
59
  default: return "secondary";
63
60
  }
64
- }, W = () => {
65
- let { executionId: w } = O(), { navigateTo: j } = e(), { data: F, loading: R, error: W, refetch: G } = v(w), [K, q] = _();
66
- if (R) return /* @__PURE__ */ E(o, {
61
+ }, G = () => {
62
+ let { executionId: j } = O(), { navigateTo: F } = e(), { data: R, loading: G, error: K, refetch: q } = _(j), J = v(), Y = R?.status;
63
+ if (w(() => {
64
+ if (Y !== C.Pending && Y !== C.Running) return;
65
+ let e = setInterval(() => void q(), V);
66
+ return () => clearInterval(e);
67
+ }, [Y, q]), G && !R) return /* @__PURE__ */ E(o, {
67
68
  title: "Loading...",
68
69
  children: /* @__PURE__ */ E("div", { className: "h-96 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg" })
69
70
  });
70
- if (W) return /* @__PURE__ */ E(o, {
71
+ if (K) return /* @__PURE__ */ E(o, {
71
72
  title: "Execution",
72
73
  children: /* @__PURE__ */ E(h, {
73
74
  resource: "this execution",
74
- error: W,
75
- onRetry: () => void G()
75
+ error: K,
76
+ onRetry: () => void q()
76
77
  })
77
78
  });
78
- if (!F) return /* @__PURE__ */ E(o, {
79
+ if (!R) return /* @__PURE__ */ E(o, {
79
80
  title: "Execution Not Found",
80
81
  children: /* @__PURE__ */ E(s, {
81
82
  illustration: "empty-search",
82
83
  title: "Execution Not Found",
83
84
  description: "The execution doesn't exist.",
84
85
  action: /* @__PURE__ */ E(p, {
85
- onClick: () => j("executions"),
86
+ onClick: () => F("executions"),
86
87
  children: "Back to Executions"
87
88
  })
88
89
  })
89
90
  });
90
- let J = async () => {
91
+ let X = async () => {
91
92
  try {
92
- let e = await K({ input: {
93
- workspaceId: F.workspaceId,
94
- type: C(F.type, V, "AGENT"),
95
- input: F.input,
96
- appId: F.appId,
97
- agentId: F.agentId,
98
- metadata: { sourceExecutionId: F.id }
99
- } });
100
- B.success("Re-run started"), j(`executions/${e.id}`);
93
+ let e = await J.mutateAsync(R.id);
94
+ B.success("Re-run started"), F(`executions/${e.id}`);
101
95
  } catch (e) {
102
96
  B.error(e instanceof Error ? e.message : "Failed to re-run execution");
103
97
  }
@@ -109,26 +103,26 @@ var V = [
109
103
  /* @__PURE__ */ E(p, {
110
104
  variant: "ghost",
111
105
  size: "icon",
112
- onClick: () => j("executions"),
106
+ onClick: () => F("executions"),
113
107
  children: /* @__PURE__ */ E(A, { size: 20 })
114
108
  }),
115
- H(F.status),
109
+ U(R.status),
116
110
  /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ D("div", {
117
111
  className: "flex items-center gap-2",
118
112
  children: [/* @__PURE__ */ D("span", { children: [
119
113
  "Execution ",
120
- F.id.slice(0, 8),
114
+ R.id.slice(0, 8),
121
115
  "…"
122
116
  ] }), /* @__PURE__ */ E(m, {
123
- variant: U(F.status),
124
- children: F.status
117
+ variant: W(R.status),
118
+ children: R.status
125
119
  })]
126
120
  }), /* @__PURE__ */ D("p", {
127
121
  className: "text-sm font-normal text-text-secondary",
128
122
  children: [
129
- F.appId ?? "—",
123
+ R.appId ?? "—",
130
124
  " / ",
131
- F.agentId ?? "—"
125
+ R.agentId ?? "—"
132
126
  ]
133
127
  })] })
134
128
  ]
@@ -139,15 +133,15 @@ var V = [
139
133
  variant: "outline",
140
134
  leftIcon: /* @__PURE__ */ E(N, { size: 16 }),
141
135
  onClick: () => {
142
- n(F.id), t() && r("Copied");
136
+ n(R.id), t() && r("Copied");
143
137
  },
144
138
  children: "Copy ID"
145
- }), /* @__PURE__ */ E(a, {
139
+ }), H.has(R.type) && /* @__PURE__ */ E(a, {
146
140
  permission: i.EXECUTION_CREATE,
147
141
  children: /* @__PURE__ */ E(p, {
148
142
  leftIcon: /* @__PURE__ */ E(I, { size: 16 }),
149
- onClick: () => void J(),
150
- isLoading: q.loading,
143
+ onClick: () => void X(),
144
+ isLoading: J.isPending,
151
145
  children: "Run again"
152
146
  })
153
147
  })]
@@ -171,7 +165,7 @@ var V = [
171
165
  /* @__PURE__ */ E(M, { className: "h-6 w-6 mx-auto mb-2 text-text-secondary" }),
172
166
  /* @__PURE__ */ E("p", {
173
167
  className: "text-2xl font-bold tabular-nums",
174
- children: F.duration === null || F.duration === void 0 ? "—" : b(F.duration)
168
+ children: R.duration === null || R.duration === void 0 ? "—" : b(R.duration)
175
169
  }),
176
170
  /* @__PURE__ */ E("p", {
177
171
  className: "text-sm text-text-secondary",
@@ -188,7 +182,7 @@ var V = [
188
182
  /* @__PURE__ */ E(z, { className: "h-6 w-6 mx-auto mb-2 text-text-secondary" }),
189
183
  /* @__PURE__ */ E("p", {
190
184
  className: "text-2xl font-bold tabular-nums",
191
- children: x(F.tokensUsed)
185
+ children: x(R.tokensUsed)
192
186
  }),
193
187
  /* @__PURE__ */ E("p", {
194
188
  className: "text-sm text-text-secondary",
@@ -205,7 +199,7 @@ var V = [
205
199
  /* @__PURE__ */ E(P, { className: "h-6 w-6 mx-auto mb-2 text-text-secondary" }),
206
200
  /* @__PURE__ */ E("p", {
207
201
  className: "text-2xl font-bold tabular-nums",
208
- children: y(F.cost)
202
+ children: y(R.cost)
209
203
  }),
210
204
  /* @__PURE__ */ E("p", {
211
205
  className: "text-sm text-text-secondary",
@@ -222,7 +216,7 @@ var V = [
222
216
  /* @__PURE__ */ E(L, { className: "h-6 w-6 mx-auto mb-2 text-text-secondary" }),
223
217
  /* @__PURE__ */ E("p", {
224
218
  className: "text-2xl font-bold capitalize",
225
- children: F.type.toLowerCase()
219
+ children: R.type.toLowerCase()
226
220
  }),
227
221
  /* @__PURE__ */ E("p", {
228
222
  className: "text-sm text-text-secondary",
@@ -233,17 +227,17 @@ var V = [
233
227
  })
234
228
  ]
235
229
  }),
236
- (F.errorMessage || F.errorCode) && /* @__PURE__ */ D(c, { children: [/* @__PURE__ */ D(d, { children: [/* @__PURE__ */ D(f, {
230
+ (R.errorMessage || R.errorCode) && /* @__PURE__ */ D(c, { children: [/* @__PURE__ */ D(d, { children: [/* @__PURE__ */ D(f, {
237
231
  className: "flex items-center gap-2 text-status-error-text",
238
232
  children: [/* @__PURE__ */ E(k, { size: 18 }), "Failure"]
239
- }), F.errorCode && /* @__PURE__ */ E(u, { children: F.errorCode })] }), /* @__PURE__ */ D(l, {
233
+ }), R.errorCode && /* @__PURE__ */ E(u, { children: R.errorCode })] }), /* @__PURE__ */ D(l, {
240
234
  className: "space-y-3",
241
- children: [F.errorMessage && /* @__PURE__ */ E("p", {
235
+ children: [R.errorMessage && /* @__PURE__ */ E("p", {
242
236
  className: "text-sm text-text-primary",
243
- children: F.errorMessage
244
- }), F.errorDetails && /* @__PURE__ */ E("pre", {
237
+ children: R.errorMessage
238
+ }), R.errorDetails && /* @__PURE__ */ E("pre", {
245
239
  className: "max-h-64 overflow-auto rounded-lg bg-bg-sunken p-3 font-mono text-xs",
246
- children: JSON.stringify(F.errorDetails, null, 2)
240
+ children: JSON.stringify(R.errorDetails, null, 2)
247
241
  })]
248
242
  })] }),
249
243
  /* @__PURE__ */ D(c, { children: [/* @__PURE__ */ E(d, { children: /* @__PURE__ */ E(f, { children: "Run Details" }) }), /* @__PURE__ */ E(l, { children: /* @__PURE__ */ D("div", {
@@ -254,42 +248,42 @@ var V = [
254
248
  children: "Execution ID"
255
249
  }), /* @__PURE__ */ E("p", {
256
250
  className: "font-mono text-sm break-all",
257
- children: F.id
251
+ children: R.id
258
252
  })] }),
259
253
  /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
260
254
  className: "text-sm text-text-secondary",
261
255
  children: "Bot"
262
256
  }), /* @__PURE__ */ E("p", {
263
257
  className: "font-mono text-sm break-all",
264
- children: F.appId ?? "—"
258
+ children: R.appId ?? "—"
265
259
  })] }),
266
260
  /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
267
261
  className: "text-sm text-text-secondary",
268
262
  children: "Agent"
269
263
  }), /* @__PURE__ */ E("p", {
270
264
  className: "font-mono text-sm break-all",
271
- children: F.agentId ?? "—"
265
+ children: R.agentId ?? "—"
272
266
  })] }),
273
267
  /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
274
268
  className: "text-sm text-text-secondary",
275
269
  children: "Conversation"
276
270
  }), /* @__PURE__ */ E("p", {
277
271
  className: "font-mono text-sm break-all",
278
- children: F.conversationId ?? "—"
272
+ children: R.conversationId ?? "—"
279
273
  })] }),
280
274
  /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
281
275
  className: "text-sm text-text-secondary",
282
276
  children: "Started"
283
277
  }), /* @__PURE__ */ E("p", {
284
278
  className: "font-medium",
285
- children: S(F.createdAt)
279
+ children: S(R.createdAt)
286
280
  })] }),
287
281
  /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
288
282
  className: "text-sm text-text-secondary",
289
283
  children: "Completed"
290
284
  }), /* @__PURE__ */ E("p", {
291
285
  className: "font-medium",
292
- children: S(F.completedAt)
286
+ children: S(R.completedAt)
293
287
  })] })
294
288
  ]
295
289
  }) })] }),
@@ -297,24 +291,24 @@ var V = [
297
291
  className: "grid grid-cols-1 gap-6 lg:grid-cols-2",
298
292
  children: [/* @__PURE__ */ D(c, { children: [/* @__PURE__ */ E(d, { children: /* @__PURE__ */ E(f, { children: "Input" }) }), /* @__PURE__ */ E(l, { children: /* @__PURE__ */ E("pre", {
299
293
  className: "max-h-96 overflow-auto whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm",
300
- children: F.input
301
- }) })] }), /* @__PURE__ */ D(c, { children: [/* @__PURE__ */ E(d, { children: /* @__PURE__ */ E(f, { children: "Output" }) }), /* @__PURE__ */ E(l, { children: F.output ? /* @__PURE__ */ E("pre", {
294
+ children: R.input
295
+ }) })] }), /* @__PURE__ */ D(c, { children: [/* @__PURE__ */ E(d, { children: /* @__PURE__ */ E(f, { children: "Output" }) }), /* @__PURE__ */ E(l, { children: R.output ? /* @__PURE__ */ E("pre", {
302
296
  className: "max-h-96 overflow-auto whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm",
303
- children: F.output
297
+ children: R.output
304
298
  }) : /* @__PURE__ */ E("p", {
305
299
  className: "text-sm text-text-secondary",
306
300
  children: "This run has not produced an output yet."
307
301
  }) })] })]
308
302
  }),
309
- /* @__PURE__ */ E(g, { metadata: F.metadata }),
310
- F.metadata && Object.keys(F.metadata).length > 0 && /* @__PURE__ */ D(c, { children: [/* @__PURE__ */ E(d, { children: /* @__PURE__ */ E(f, { children: "Metadata" }) }), /* @__PURE__ */ E(l, { children: /* @__PURE__ */ E("pre", {
303
+ /* @__PURE__ */ E(g, { metadata: R.metadata }),
304
+ R.metadata && Object.keys(R.metadata).length > 0 && /* @__PURE__ */ D(c, { children: [/* @__PURE__ */ E(d, { children: /* @__PURE__ */ E(f, { children: "Metadata" }) }), /* @__PURE__ */ E(l, { children: /* @__PURE__ */ E("pre", {
311
305
  className: "max-h-64 overflow-auto rounded-lg bg-bg-sunken p-3 font-mono text-xs",
312
- children: JSON.stringify(F.metadata, null, 2)
306
+ children: JSON.stringify(R.metadata, null, 2)
313
307
  }) })] })
314
308
  ]
315
309
  })
316
310
  });
317
311
  };
318
- export { W as ExecutionDetailPage };
312
+ export { G as ExecutionDetailPage };
319
313
 
320
314
  //# sourceMappingURL=ExecutionDetailPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExecutionDetailPage.js","names":["GqlExecutionStatus","EXECUTION_TYPES","getStatusIcon","status","ExecutionStatus","CheckCircle","XCircle","RefreshCw","Hourglass","AlertTriangle","getStatusBadgeVariant","ExecutionDetailPage","useParams","useBotlit","execution","useExecution","executionId","createExecution","createExecutionState","useCreateExecution","loading","PageLayout","error","ErrorState","refetch","EmptyState","Button","navigateTo","handleReplay","created","toUnion","toast","err","ArrowLeft","Badge","Copy","nativeCopyText","isNative","nativeToast","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","Play","PagePurpose","Clock","Card","CardContent","formatDuration","Zap","formatNumber","DollarSign","formatCurrency","CardHeader","CardTitle","CardDescription","formatRelativeTime","ExecutionModelFallback"],"sources":["../../../src/botlit/pages/ExecutionDetailPage.tsx"],"sourcesContent":["/**\n * Execution Detail Page\n * @module botlit/pages\n */\n\nimport type { FC } from 'react';\nimport { useParams } from 'react-router';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { isNative, nativeCopyText, nativeToast } from '../../utils/nativeBridge';\nimport {\n ArrowLeft,\n Play,\n Clock,\n DollarSign,\n Zap,\n AlertTriangle,\n CheckCircle,\n XCircle,\n RefreshCw,\n Hourglass,\n Copy,\n} from 'lucide-react';\nimport { toast } from 'sonner';\nimport { PageLayout } from '../components/PageLayout';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { EmptyState } from '../components/EmptyState';\nimport { Card, CardHeader, CardTitle, CardContent, CardDescription } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Badge } from '../components/Badge';\nimport { ErrorState } from '../components/ErrorState';\nimport { ExecutionModelFallback } from '../components/ExecutionModelFallback';\nimport { useExecution, useCreateExecution } from '../hooks/useExecutions';\nimport {\n formatNumber,\n formatCurrency,\n formatDuration,\n formatRelativeTime,\n MISSING_VALUE,\n} from '../utils/formatters';\nimport { toUnion } from '../utils/unions';\n\n/** Execution kinds `CreateExecutionInput.type` accepts. */\nconst EXECUTION_TYPES = ['AGENT', 'APP', 'WORKFLOW'] as const;\nimport { ExecutionStatus as GqlExecutionStatus } from '../../generated/wspace-types';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\nconst getStatusIcon = (status: string) => {\n switch (status) {\n case GqlExecutionStatus.Completed:\n return <CheckCircle className=\"text-status-success-text\" size={20} />;\n case GqlExecutionStatus.Failed:\n case GqlExecutionStatus.Timeout:\n return <XCircle className=\"text-status-error-text\" size={20} />;\n case GqlExecutionStatus.Cancelled:\n return <XCircle className=\"text-text-secondary\" size={20} />;\n case GqlExecutionStatus.Running:\n return <RefreshCw className=\"text-status-info-text motion-safe:animate-spin\" size={20} />;\n case GqlExecutionStatus.Pending:\n return <Hourglass className=\"text-status-warning-text\" size={20} />;\n default:\n return <AlertTriangle className=\"text-text-secondary\" size={20} />;\n }\n};\n\nconst getStatusBadgeVariant = (\n status: string\n): 'success' | 'destructive' | 'warning' | 'secondary' | 'default' => {\n switch (status) {\n case GqlExecutionStatus.Completed:\n return 'success';\n case GqlExecutionStatus.Failed:\n case GqlExecutionStatus.Timeout:\n return 'destructive';\n case GqlExecutionStatus.Pending:\n return 'warning';\n case GqlExecutionStatus.Running:\n return 'default';\n default:\n return 'secondary';\n }\n};\n\nexport const ExecutionDetailPage: FC = () => {\n const { executionId } = useParams();\n const { navigateTo } = useBotlit();\n const { data: execution, loading, error, refetch } = useExecution(executionId);\n const [createExecution, createExecutionState] = useCreateExecution();\n\n if (loading) {\n return (\n <PageLayout title=\"Loading...\">\n <div className=\"h-96 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n </PageLayout>\n );\n }\n\n if (error) {\n return (\n <PageLayout title=\"Execution\">\n <ErrorState resource=\"this execution\" error={error} onRetry={() => void refetch()} />\n </PageLayout>\n );\n }\n\n if (!execution) {\n return (\n <PageLayout title=\"Execution Not Found\">\n <EmptyState\n illustration=\"empty-search\"\n title=\"Execution Not Found\"\n description=\"The execution doesn't exist.\"\n action={<Button onClick={() => navigateTo('executions')}>Back to Executions</Button>}\n />\n </PageLayout>\n );\n }\n\n /**\n * Re-runs this execution's input. The service has no dedicated replay\n * operation, so this creates a fresh execution with the same input and a\n * pointer back to the run it came from.\n */\n const handleReplay = async () => {\n try {\n const created = await createExecution({\n input: {\n workspaceId: execution.workspaceId,\n type: toUnion(execution.type, EXECUTION_TYPES, 'AGENT'),\n input: execution.input,\n appId: execution.appId,\n agentId: execution.agentId,\n metadata: { sourceExecutionId: execution.id },\n },\n });\n toast.success('Re-run started');\n navigateTo(`executions/${created.id}`);\n } catch (err) {\n toast.error(err instanceof Error ? err.message : 'Failed to re-run execution');\n }\n };\n\n return (\n <PageLayout\n title={\n <div className=\"flex items-center gap-3\">\n <Button variant=\"ghost\" size=\"icon\" onClick={() => navigateTo('executions')}>\n <ArrowLeft size={20} />\n </Button>\n {getStatusIcon(execution.status)}\n <div>\n <div className=\"flex items-center gap-2\">\n <span>Execution {execution.id.slice(0, 8)}…</span>\n <Badge variant={getStatusBadgeVariant(execution.status)}>{execution.status}</Badge>\n </div>\n <p className=\"text-sm font-normal text-text-secondary\">\n {execution.appId ?? MISSING_VALUE} / {execution.agentId ?? MISSING_VALUE}\n </p>\n </div>\n </div>\n }\n actions={\n <div className=\"flex gap-2\">\n <Button\n variant=\"outline\"\n leftIcon={<Copy size={16} />}\n onClick={() => {\n void nativeCopyText(execution.id);\n if (isNative()) void nativeToast('Copied');\n }}\n >\n Copy ID\n </Button>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.EXECUTION_CREATE}>\n <Button\n leftIcon={<Play size={16} />}\n onClick={() => void handleReplay()}\n isLoading={createExecutionState.loading}\n >\n Run again\n </Button>\n </BotmanorPermissionGate>\n </div>\n }\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<Clock size={18} />}>\n This is the record of one agent run — its status, how long it took, the tokens and cost it\n consumed, and the input and output that produced the result. Use it to debug a failure,\n understand an unexpected answer, or audit exactly what the agent did on a given request.\n </PagePurpose>\n\n {/* Metrics Summary */}\n <div className=\"grid grid-cols-2 md:grid-cols-4 gap-4\">\n <Card treatment=\"glass\" glow>\n <CardContent className=\"pt-6 text-center\">\n <Clock className=\"h-6 w-6 mx-auto mb-2 text-text-secondary\" />\n <p className=\"text-2xl font-bold tabular-nums\">\n {execution.duration === null || execution.duration === undefined\n ? MISSING_VALUE\n : formatDuration(execution.duration)}\n </p>\n <p className=\"text-sm text-text-secondary\">Duration</p>\n </CardContent>\n </Card>\n <Card treatment=\"metric\">\n <CardContent className=\"pt-6 text-center\">\n <Zap className=\"h-6 w-6 mx-auto mb-2 text-text-secondary\" />\n <p className=\"text-2xl font-bold tabular-nums\">\n {formatNumber(execution.tokensUsed)}\n </p>\n <p className=\"text-sm text-text-secondary\">Tokens</p>\n </CardContent>\n </Card>\n <Card treatment=\"metric\">\n <CardContent className=\"pt-6 text-center\">\n <DollarSign className=\"h-6 w-6 mx-auto mb-2 text-text-secondary\" />\n <p className=\"text-2xl font-bold tabular-nums\">{formatCurrency(execution.cost)}</p>\n <p className=\"text-sm text-text-secondary\">Cost</p>\n </CardContent>\n </Card>\n <Card treatment=\"metric\">\n <CardContent className=\"pt-6 text-center\">\n <RefreshCw className=\"h-6 w-6 mx-auto mb-2 text-text-secondary\" />\n <p className=\"text-2xl font-bold capitalize\">{execution.type.toLowerCase()}</p>\n <p className=\"text-sm text-text-secondary\">Type</p>\n </CardContent>\n </Card>\n </div>\n\n {/* Failure details */}\n {(execution.errorMessage || execution.errorCode) && (\n <Card>\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2 text-status-error-text\">\n <AlertTriangle size={18} />\n Failure\n </CardTitle>\n {execution.errorCode && <CardDescription>{execution.errorCode}</CardDescription>}\n </CardHeader>\n <CardContent className=\"space-y-3\">\n {execution.errorMessage && (\n <p className=\"text-sm text-text-primary\">{execution.errorMessage}</p>\n )}\n {execution.errorDetails && (\n <pre className=\"max-h-64 overflow-auto rounded-lg bg-bg-sunken p-3 font-mono text-xs\">\n {JSON.stringify(execution.errorDetails, null, 2)}\n </pre>\n )}\n </CardContent>\n </Card>\n )}\n\n {/* Identity & timings */}\n <Card>\n <CardHeader>\n <CardTitle>Run Details</CardTitle>\n </CardHeader>\n <CardContent>\n <div className=\"grid grid-cols-1 gap-6 md:grid-cols-3\">\n <div>\n <p className=\"text-sm text-text-secondary\">Execution ID</p>\n <p className=\"font-mono text-sm break-all\">{execution.id}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Bot</p>\n <p className=\"font-mono text-sm break-all\">{execution.appId ?? MISSING_VALUE}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Agent</p>\n <p className=\"font-mono text-sm break-all\">{execution.agentId ?? MISSING_VALUE}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Conversation</p>\n <p className=\"font-mono text-sm break-all\">\n {execution.conversationId ?? MISSING_VALUE}\n </p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Started</p>\n <p className=\"font-medium\">{formatRelativeTime(execution.createdAt)}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Completed</p>\n <p className=\"font-medium\">{formatRelativeTime(execution.completedAt)}</p>\n </div>\n </div>\n </CardContent>\n </Card>\n\n {/* Input / Output */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-2\">\n <Card>\n <CardHeader>\n <CardTitle>Input</CardTitle>\n </CardHeader>\n <CardContent>\n <pre className=\"max-h-96 overflow-auto whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm\">\n {execution.input}\n </pre>\n </CardContent>\n </Card>\n <Card>\n <CardHeader>\n <CardTitle>Output</CardTitle>\n </CardHeader>\n <CardContent>\n {execution.output ? (\n <pre className=\"max-h-96 overflow-auto whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm\">\n {execution.output}\n </pre>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n This run has not produced an output yet.\n </p>\n )}\n </CardContent>\n </Card>\n </div>\n\n {/* BOFF-15360 — which model served the run, and what it fell back from */}\n <ExecutionModelFallback metadata={execution.metadata} />\n\n {/* Metadata */}\n {execution.metadata && Object.keys(execution.metadata).length > 0 && (\n <Card>\n <CardHeader>\n <CardTitle>Metadata</CardTitle>\n </CardHeader>\n <CardContent>\n <pre className=\"max-h-64 overflow-auto rounded-lg bg-bg-sunken p-3 font-mono text-xs\">\n {JSON.stringify(execution.metadata, null, 2)}\n </pre>\n </CardContent>\n </Card>\n )}\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAMC,IAAkB;CAAC;CAAS;CAAO;AAAU,GAI7CC,KAAiB,MAAmB;CACxC,QAAQC,GAAR;EACE,KAAKH,EAAmB,WACtB,OAAO,kBAACK,GAAD;GAAa,WAAU;GAA2B,MAAM;EAAK,CAAA;EACtE,KAAKL,EAAmB;EACxB,KAAKA,EAAmB,SACtB,OAAO,kBAACM,GAAD;GAAS,WAAU;GAAyB,MAAM;EAAK,CAAA;EAChE,KAAKN,EAAmB,WACtB,OAAO,kBAACM,GAAD;GAAS,WAAU;GAAsB,MAAM;EAAK,CAAA;EAC7D,KAAKN,EAAmB,SACtB,OAAO,kBAACO,GAAD;GAAW,WAAU;GAAiD,MAAM;EAAK,CAAA;EAC1F,KAAKP,EAAmB,SACtB,OAAO,kBAACQ,GAAD;GAAW,WAAU;GAA2B,MAAM;EAAK,CAAA;EACpE,SACE,OAAO,kBAACC,GAAD;GAAe,WAAU;GAAsB,MAAM;EAAK,CAAA;CACrE;AACF,GAEMC,KACJ,MACoE;CACpE,QAAQP,GAAR;EACE,KAAKH,EAAmB,WACtB,OAAO;EACT,KAAKA,EAAmB;EACxB,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,kBAAC8B,GAAD,EAAA,UAAA,CACE,kBAACO,GAAD,EAAA,UACE,kBAACC,GAAD,EAAA,UAAW,WAAmB,CAAA,EACpB,CAAA,GACZ,kBAACP,GAAD,EAAA,UACE,kBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,KAAK,UAAU/B,EAAU,UAAU,MAAM,CAAC;IACxC,CAAA,EACM,CAAA,CACT,EAAA,CAAA;GAEL;;CACK,CAAA;AAEhB"}
1
+ {"version":3,"file":"ExecutionDetailPage.js","names":["GqlExecutionStatus","ACTIVE_RUN_POLL_MS","RERUNNABLE_TYPES","getStatusIcon","status","ExecutionStatus","CheckCircle","XCircle","RefreshCw","Hourglass","AlertTriangle","getStatusBadgeVariant","ExecutionDetailPage","useParams","useBotlit","execution","useExecution","executionId","rerun","useRerunExecution","useEffect","timer","refetch","loading","PageLayout","error","ErrorState","EmptyState","Button","navigateTo","handleReplay","created","toast","err","ArrowLeft","Badge","Copy","nativeCopyText","isNative","nativeToast","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","Play","PagePurpose","Clock","Card","CardContent","formatDuration","Zap","formatNumber","DollarSign","formatCurrency","CardHeader","CardTitle","CardDescription","formatRelativeTime","ExecutionModelFallback"],"sources":["../../../src/botlit/pages/ExecutionDetailPage.tsx"],"sourcesContent":["/**\n * Execution Detail Page\n * @module botlit/pages\n */\n\nimport { useEffect } from 'react';\nimport type { FC } from 'react';\nimport { useParams } from 'react-router';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { isNative, nativeCopyText, nativeToast } from '../../utils/nativeBridge';\nimport {\n ArrowLeft,\n Play,\n Clock,\n DollarSign,\n Zap,\n AlertTriangle,\n CheckCircle,\n XCircle,\n RefreshCw,\n Hourglass,\n Copy,\n} from 'lucide-react';\nimport { toast } from 'sonner';\nimport { PageLayout } from '../components/PageLayout';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { EmptyState } from '../components/EmptyState';\nimport { Card, CardHeader, CardTitle, CardContent, CardDescription } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Badge } from '../components/Badge';\nimport { ErrorState } from '../components/ErrorState';\nimport { ExecutionModelFallback } from '../components/ExecutionModelFallback';\nimport { useExecution } from '../hooks/useExecutions';\nimport { useRerunExecution } from '../hooks/useRerunExecution';\nimport {\n formatNumber,\n formatCurrency,\n formatDuration,\n formatRelativeTime,\n MISSING_VALUE,\n} from '../utils/formatters';\n\nimport { ExecutionStatus as GqlExecutionStatus } from '../../generated/wspace-types';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\n/** How often an unfinished run is re-read so its outcome shows without a reload. */\nconst ACTIVE_RUN_POLL_MS = 3000;\n\n/** Execution kinds `rerunExecution` accepts; workflow runs are re-run from FluidGrids. */\nconst RERUNNABLE_TYPES: ReadonlySet<string> = new Set(['AGENT', 'APP']);\n\nconst getStatusIcon = (status: string) => {\n switch (status) {\n case GqlExecutionStatus.Completed:\n return <CheckCircle className=\"text-status-success-text\" size={20} />;\n case GqlExecutionStatus.Failed:\n case GqlExecutionStatus.Timeout:\n return <XCircle className=\"text-status-error-text\" size={20} />;\n case GqlExecutionStatus.Cancelled:\n return <XCircle className=\"text-text-secondary\" size={20} />;\n case GqlExecutionStatus.Running:\n return <RefreshCw className=\"text-status-info-text motion-safe:animate-spin\" size={20} />;\n case GqlExecutionStatus.Pending:\n return <Hourglass className=\"text-status-warning-text\" size={20} />;\n default:\n return <AlertTriangle className=\"text-text-secondary\" size={20} />;\n }\n};\n\nconst getStatusBadgeVariant = (\n status: string\n): 'success' | 'destructive' | 'warning' | 'secondary' | 'default' => {\n switch (status) {\n case GqlExecutionStatus.Completed:\n return 'success';\n case GqlExecutionStatus.Failed:\n case GqlExecutionStatus.Timeout:\n return 'destructive';\n case GqlExecutionStatus.Pending:\n return 'warning';\n case GqlExecutionStatus.Running:\n return 'default';\n default:\n return 'secondary';\n }\n};\n\nexport const ExecutionDetailPage: FC = () => {\n const { executionId } = useParams();\n const { navigateTo } = useBotlit();\n const { data: execution, loading, error, refetch } = useExecution(executionId);\n const rerun = useRerunExecution();\n const status = execution?.status;\n\n // A PENDING or RUNNING run (for example one just started with \"Run again\")\n // is re-read until it finishes, so the page shows its outcome.\n useEffect(() => {\n if (status !== GqlExecutionStatus.Pending && status !== GqlExecutionStatus.Running) return;\n const timer = setInterval(() => void refetch(), ACTIVE_RUN_POLL_MS);\n return () => clearInterval(timer);\n }, [status, refetch]);\n\n // Keep showing the run while it is re-read; only the first load shows the placeholder.\n if (loading && !execution) {\n return (\n <PageLayout title=\"Loading...\">\n <div className=\"h-96 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n </PageLayout>\n );\n }\n\n if (error) {\n return (\n <PageLayout title=\"Execution\">\n <ErrorState resource=\"this execution\" error={error} onRetry={() => void refetch()} />\n </PageLayout>\n );\n }\n\n if (!execution) {\n return (\n <PageLayout title=\"Execution Not Found\">\n <EmptyState\n illustration=\"empty-search\"\n title=\"Execution Not Found\"\n description=\"The execution doesn't exist.\"\n action={<Button onClick={() => navigateTo('executions')}>Back to Executions</Button>}\n />\n </PageLayout>\n );\n }\n\n /**\n * Runs this execution again. `rerunExecution` creates a new run with the same\n * input, agent and bot (pointing back to this one) and starts it in the\n * background; the new run's page follows it until it finishes.\n */\n const handleReplay = async () => {\n try {\n const created = await rerun.mutateAsync(execution.id);\n toast.success('Re-run started');\n navigateTo(`executions/${created.id}`);\n } catch (err) {\n toast.error(err instanceof Error ? err.message : 'Failed to re-run execution');\n }\n };\n\n return (\n <PageLayout\n title={\n <div className=\"flex items-center gap-3\">\n <Button variant=\"ghost\" size=\"icon\" onClick={() => navigateTo('executions')}>\n <ArrowLeft size={20} />\n </Button>\n {getStatusIcon(execution.status)}\n <div>\n <div className=\"flex items-center gap-2\">\n <span>Execution {execution.id.slice(0, 8)}…</span>\n <Badge variant={getStatusBadgeVariant(execution.status)}>{execution.status}</Badge>\n </div>\n <p className=\"text-sm font-normal text-text-secondary\">\n {execution.appId ?? MISSING_VALUE} / {execution.agentId ?? MISSING_VALUE}\n </p>\n </div>\n </div>\n }\n actions={\n <div className=\"flex gap-2\">\n <Button\n variant=\"outline\"\n leftIcon={<Copy size={16} />}\n onClick={() => {\n void nativeCopyText(execution.id);\n if (isNative()) void nativeToast('Copied');\n }}\n >\n Copy ID\n </Button>\n {RERUNNABLE_TYPES.has(execution.type) && (\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.EXECUTION_CREATE}>\n <Button\n leftIcon={<Play size={16} />}\n onClick={() => void handleReplay()}\n isLoading={rerun.isPending}\n >\n Run again\n </Button>\n </BotmanorPermissionGate>\n )}\n </div>\n }\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<Clock size={18} />}>\n This is the record of one agent run — its status, how long it took, the tokens and cost it\n consumed, and the input and output that produced the result. Use it to debug a failure,\n understand an unexpected answer, or audit exactly what the agent did on a given request.\n </PagePurpose>\n\n {/* Metrics Summary */}\n <div className=\"grid grid-cols-2 md:grid-cols-4 gap-4\">\n <Card treatment=\"glass\" glow>\n <CardContent className=\"pt-6 text-center\">\n <Clock className=\"h-6 w-6 mx-auto mb-2 text-text-secondary\" />\n <p className=\"text-2xl font-bold tabular-nums\">\n {execution.duration === null || execution.duration === undefined\n ? MISSING_VALUE\n : formatDuration(execution.duration)}\n </p>\n <p className=\"text-sm text-text-secondary\">Duration</p>\n </CardContent>\n </Card>\n <Card treatment=\"metric\">\n <CardContent className=\"pt-6 text-center\">\n <Zap className=\"h-6 w-6 mx-auto mb-2 text-text-secondary\" />\n <p className=\"text-2xl font-bold tabular-nums\">\n {formatNumber(execution.tokensUsed)}\n </p>\n <p className=\"text-sm text-text-secondary\">Tokens</p>\n </CardContent>\n </Card>\n <Card treatment=\"metric\">\n <CardContent className=\"pt-6 text-center\">\n <DollarSign className=\"h-6 w-6 mx-auto mb-2 text-text-secondary\" />\n <p className=\"text-2xl font-bold tabular-nums\">{formatCurrency(execution.cost)}</p>\n <p className=\"text-sm text-text-secondary\">Cost</p>\n </CardContent>\n </Card>\n <Card treatment=\"metric\">\n <CardContent className=\"pt-6 text-center\">\n <RefreshCw className=\"h-6 w-6 mx-auto mb-2 text-text-secondary\" />\n <p className=\"text-2xl font-bold capitalize\">{execution.type.toLowerCase()}</p>\n <p className=\"text-sm text-text-secondary\">Type</p>\n </CardContent>\n </Card>\n </div>\n\n {/* Failure details */}\n {(execution.errorMessage || execution.errorCode) && (\n <Card>\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2 text-status-error-text\">\n <AlertTriangle size={18} />\n Failure\n </CardTitle>\n {execution.errorCode && <CardDescription>{execution.errorCode}</CardDescription>}\n </CardHeader>\n <CardContent className=\"space-y-3\">\n {execution.errorMessage && (\n <p className=\"text-sm text-text-primary\">{execution.errorMessage}</p>\n )}\n {execution.errorDetails && (\n <pre className=\"max-h-64 overflow-auto rounded-lg bg-bg-sunken p-3 font-mono text-xs\">\n {JSON.stringify(execution.errorDetails, null, 2)}\n </pre>\n )}\n </CardContent>\n </Card>\n )}\n\n {/* Identity & timings */}\n <Card>\n <CardHeader>\n <CardTitle>Run Details</CardTitle>\n </CardHeader>\n <CardContent>\n <div className=\"grid grid-cols-1 gap-6 md:grid-cols-3\">\n <div>\n <p className=\"text-sm text-text-secondary\">Execution ID</p>\n <p className=\"font-mono text-sm break-all\">{execution.id}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Bot</p>\n <p className=\"font-mono text-sm break-all\">{execution.appId ?? MISSING_VALUE}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Agent</p>\n <p className=\"font-mono text-sm break-all\">{execution.agentId ?? MISSING_VALUE}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Conversation</p>\n <p className=\"font-mono text-sm break-all\">\n {execution.conversationId ?? MISSING_VALUE}\n </p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Started</p>\n <p className=\"font-medium\">{formatRelativeTime(execution.createdAt)}</p>\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Completed</p>\n <p className=\"font-medium\">{formatRelativeTime(execution.completedAt)}</p>\n </div>\n </div>\n </CardContent>\n </Card>\n\n {/* Input / Output */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-2\">\n <Card>\n <CardHeader>\n <CardTitle>Input</CardTitle>\n </CardHeader>\n <CardContent>\n <pre className=\"max-h-96 overflow-auto whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm\">\n {execution.input}\n </pre>\n </CardContent>\n </Card>\n <Card>\n <CardHeader>\n <CardTitle>Output</CardTitle>\n </CardHeader>\n <CardContent>\n {execution.output ? (\n <pre className=\"max-h-96 overflow-auto whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm\">\n {execution.output}\n </pre>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n This run has not produced an output yet.\n </p>\n )}\n </CardContent>\n </Card>\n </div>\n\n {/* BOFF-15360 — which model served the run, and what it fell back from */}\n <ExecutionModelFallback metadata={execution.metadata} />\n\n {/* Metadata */}\n {execution.metadata && Object.keys(execution.metadata).length > 0 && (\n <Card>\n <CardHeader>\n <CardTitle>Metadata</CardTitle>\n </CardHeader>\n <CardContent>\n <pre className=\"max-h-64 overflow-auto rounded-lg bg-bg-sunken p-3 font-mono text-xs\">\n {JSON.stringify(execution.metadata, null, 2)}\n </pre>\n </CardContent>\n </Card>\n )}\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAMC,IAAqB,KAGrBC,oBAAwC,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC,GAEhEC,KAAiB,MAAmB;CACxC,QAAQC,GAAR;EACE,KAAKJ,EAAmB,WACtB,OAAO,kBAACM,GAAD;GAAa,WAAU;GAA2B,MAAM;EAAK,CAAA;EACtE,KAAKN,EAAmB;EACxB,KAAKA,EAAmB,SACtB,OAAO,kBAACO,GAAD;GAAS,WAAU;GAAyB,MAAM;EAAK,CAAA;EAChE,KAAKP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;MAAK,WAAU;MACZ,UAAA/B,EAAU;KACR,CAAA,EACM,CAAA,CACT,EAAA,CAAA,GACN,kBAAC8B,GAAD,EAAA,UAAA,CACE,kBAACO,GAAD,EAAA,UACE,kBAACC,GAAD,EAAA,UAAW,SAAiB,CAAA,EAClB,CAAA,GACZ,kBAACP,GAAD,EAAA,UACG/B,EAAU,SACT,kBAAC,OAAD;MAAK,WAAU;MACZ,UAAAA,EAAU;KACR,CAAA,IAEL,kBAAC,KAAD;MAAG,WAAU;MAA8B,UAAA;KAExC,CAAA,EAEM,CAAA,CACT,EAAA,CAAA,CACH;;IAGL,kBAACyC,GAAD,EAAwB,UAAUzC,EAAU,SAAW,CAAA;IAGtDA,EAAU,YAAY,OAAO,KAAKA,EAAU,QAAQ,CAAC,CAAC,SAAS,KAC9D,kBAAC8B,GAAD,EAAA,UAAA,CACE,kBAACO,GAAD,EAAA,UACE,kBAACC,GAAD,EAAA,UAAW,WAAmB,CAAA,EACpB,CAAA,GACZ,kBAACP,GAAD,EAAA,UACE,kBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,KAAK,UAAU/B,EAAU,UAAU,MAAM,CAAC;IACxC,CAAA,EACM,CAAA,CACT,EAAA,CAAA;GAEL;;CACK,CAAA;AAEhB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Which agents a saved AI Chat can use (BOFF-12696).
3
+ *
4
+ * A saved chat runs on the private generation path of wspace-botmanor-svc,
5
+ * through the agent's managed workflow when Assistant setup configured one and
6
+ * with direct inference otherwise; a workspace member's turn runs the agent's
7
+ * tools (BOFF-15360). That path refuses an agent that is not ACTIVE or has no
8
+ * model, and keeps a course tutor (`metadata.knowledgeAccess`) to its course
9
+ * chat. The rules below mirror those server checks so the page can say why an
10
+ * agent cannot be used before a turn fails.
11
+ */
12
+ export type AssistantUnavailableReason = 'inactive' | 'noModel' | 'courseTutor';
13
+ export interface AssistantCandidate {
14
+ status?: string | null;
15
+ llmModelId?: string | null;
16
+ capabilities?: readonly string[] | null;
17
+ knowledgeBaseIds?: readonly string[] | null;
18
+ metadata?: unknown;
19
+ }
20
+ export type AssistantAvailability = {
21
+ available: true;
22
+ } | {
23
+ available: false;
24
+ reason: AssistantUnavailableReason;
25
+ };
26
+ /** True when the agent is a private course tutor, which answers only in its course chat. */
27
+ export declare function isCourseTutor(metadata: unknown): boolean;
28
+ /**
29
+ * True when the agent's answers are held to its knowledge: it has knowledge
30
+ * attached and the RAG capability, the same rule the server uses to answer
31
+ * with the no-match message instead of the model (BOFF-12698).
32
+ */
33
+ export declare function searchesKnowledge(agent: AssistantCandidate): boolean;
34
+ export declare function assistantAvailability(agent: AssistantCandidate): AssistantAvailability;
@@ -0,0 +1,24 @@
1
+ // src/botlit/utils/assistantAvailability.ts
2
+ function e(e) {
3
+ if (!e || typeof e != "object" || Array.isArray(e)) return !1;
4
+ let t = e.knowledgeAccess;
5
+ return !!(t && typeof t == "object");
6
+ }
7
+ function t(e) {
8
+ return (e.knowledgeBaseIds?.length ?? 0) > 0 && (e.capabilities ?? []).includes("RAG");
9
+ }
10
+ function n(t) {
11
+ return t.status === "ACTIVE" ? e(t.metadata) ? {
12
+ available: !1,
13
+ reason: "courseTutor"
14
+ } : t.llmModelId ? { available: !0 } : {
15
+ available: !1,
16
+ reason: "noModel"
17
+ } : {
18
+ available: !1,
19
+ reason: "inactive"
20
+ };
21
+ }
22
+ export { n as assistantAvailability, e as isCourseTutor, t as searchesKnowledge };
23
+
24
+ //# sourceMappingURL=assistantAvailability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assistantAvailability.js","names":["isCourseTutor","metadata","access","searchesKnowledge","agent","assistantAvailability"],"sources":["../../../src/botlit/utils/assistantAvailability.ts"],"sourcesContent":["/**\n * Which agents a saved AI Chat can use (BOFF-12696).\n *\n * A saved chat runs on the private generation path of wspace-botmanor-svc,\n * through the agent's managed workflow when Assistant setup configured one and\n * with direct inference otherwise; a workspace member's turn runs the agent's\n * tools (BOFF-15360). That path refuses an agent that is not ACTIVE or has no\n * model, and keeps a course tutor (`metadata.knowledgeAccess`) to its course\n * chat. The rules below mirror those server checks so the page can say why an\n * agent cannot be used before a turn fails.\n */\n\nexport type AssistantUnavailableReason = 'inactive' | 'noModel' | 'courseTutor';\n\nexport interface AssistantCandidate {\n status?: string | null;\n llmModelId?: string | null;\n capabilities?: readonly string[] | null;\n knowledgeBaseIds?: readonly string[] | null;\n metadata?: unknown;\n}\n\nexport type AssistantAvailability =\n { available: true } | { available: false; reason: AssistantUnavailableReason };\n\n/** True when the agent is a private course tutor, which answers only in its course chat. */\nexport function isCourseTutor(metadata: unknown): boolean {\n if (!metadata || typeof metadata !== 'object' || Array.isArray(metadata)) return false;\n const access = (metadata as Record<string, unknown>).knowledgeAccess;\n return Boolean(access && typeof access === 'object');\n}\n\n/**\n * True when the agent's answers are held to its knowledge: it has knowledge\n * attached and the RAG capability, the same rule the server uses to answer\n * with the no-match message instead of the model (BOFF-12698).\n */\nexport function searchesKnowledge(agent: AssistantCandidate): boolean {\n return (agent.knowledgeBaseIds?.length ?? 0) > 0 && (agent.capabilities ?? []).includes('RAG');\n}\n\nexport function assistantAvailability(agent: AssistantCandidate): AssistantAvailability {\n if (agent.status !== 'ACTIVE') return { available: false, reason: 'inactive' };\n if (isCourseTutor(agent.metadata)) return { available: false, reason: 'courseTutor' };\n if (!agent.llmModelId) return { available: false, reason: 'noModel' };\n return { available: true };\n}\n"],"mappings":";AA0BA,SAAgBA,EAAc,GAA4B;CACxD,IAAI,CAACC,KAAY,OAAOA,KAAa,YAAY,MAAM,QAAQA,CAAQ,GAAG,OAAO;CACjF,IAAMC,IAAUD,EAAqC;CACrD,OAAO,GAAQC,KAAU,OAAOA,KAAW;AAC7C;AAOA,SAAgBC,EAAkB,GAAoC;CACpE,QAAQC,EAAM,kBAAkB,UAAU,KAAK,MAAMA,EAAM,gBAAgB,CAAC,EAAA,CAAG,SAAS,KAAK;AAC/F;AAEA,SAAgBC,EAAsB,GAAkD;CAItF,OAHID,EAAM,WAAW,WACjBJ,EAAcI,EAAM,QAAQ,IAAU;EAAE,WAAW;EAAO,QAAQ;CAAc,IAC/EA,EAAM,aACJ,EAAE,WAAW,GAAK,IADK;EAAE,WAAW;EAAO,QAAQ;CAAU,IAF9B;EAAE,WAAW;EAAO,QAAQ;CAAW;AAI/E"}