@burdenoff/microfe-botmanor 2026.1120.19 → 2026.1120.21

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.
@@ -2,8 +2,8 @@ import { Badge as e } from "./Badge.js";
2
2
  import { Button as t } from "./Button.js";
3
3
  import { Card as n, CardContent as r, CardDescription as ee, CardHeader as te, CardTitle as i } from "./Card.js";
4
4
  import { FormField as a, Input as o, Textarea as s } from "./Input.js";
5
- import { useCreateFromDraft as c, useDraftBot as l } from "../hooks/useBotCopilot.js";
6
- import { useLLMModels as ne, useLLMProviders as re } from "../hooks/useLLMProviders.js";
5
+ import { useCreateFromDraft as c, useDraftBot as ne } from "../hooks/useBotCopilot.js";
6
+ import { useLLMModels as l, useLLMProviders as re } from "../hooks/useLLMProviders.js";
7
7
  import { configuredAnswerModels as ie } from "../utils/embedding-models.js";
8
8
  import "../utils/agentSettings.js";
9
9
  import { useEffect as u, useMemo as d, useState as f } from "react";
@@ -11,10 +11,10 @@ import { ResponsiveDialog as p, ResponsiveDialogContent as m, ResponsiveDialogDe
11
11
  import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
12
12
  import { isQuotaExhaustedError as b } from "@burdenoff/fe-libs/shared/utils";
13
13
  import { Sparkles as x, WandSparkles as se } from "lucide-react";
14
- import { toast as ce } from "sonner";
14
+ import { toast as S } from "sonner";
15
15
  // src/botlit/components/DescribeBotDialog.tsx
16
- var S = 10, C = 1e3, le = "flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm";
17
- function w(e) {
16
+ var C = 10, w = 1e3, ce = "flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm";
17
+ function le(e) {
18
18
  return {
19
19
  app: e.app ? { ...e.app } : null,
20
20
  agents: e.agents.map((e) => ({
@@ -27,7 +27,7 @@ function T(e, t) {
27
27
  return e instanceof Error && e.message ? e.message : t;
28
28
  }
29
29
  var E = ({ scope: E, onCreated: ue, onQuotaExhausted: D }) => {
30
- let O = E === "BOT" ? "bot" : "agent", [de, k] = f(!1), [A, fe] = f(""), [j, M] = f(""), [N, P] = f(null), [F, I] = f(null), [L, R] = f(null), z = ne(), B = re(), V = d(() => ie(z.data ?? [], B.data ?? []), [z.data, B.data]), H = V.some((e) => e.id === j) ? j : V[0]?.id || "", U = l(), [pe, W] = c(E), G = A.trim(), K = G.length > 0 && G.length < S ? `Write at least ${S} characters.` : G.length > C ? `Use at most ${C} characters.` : void 0, q = F?.agents.filter((e) => e.include) ?? [], J = () => {
30
+ let O = E === "BOT" ? "bot" : "agent", [de, k] = f(!1), [A, fe] = f(""), [j, M] = f(""), [N, P] = f(null), [F, I] = f(null), [L, R] = f(null), z = l(), B = re(), V = d(() => ie(z.data ?? [], B.data ?? []), [z.data, B.data]), H = V.some((e) => e.id === j) ? j : "", U = ne(), [pe, W] = c(E), G = A.trim(), K = G.length > 0 && G.length < C ? `Write at least ${C} characters.` : G.length > w ? `Use at most ${w} characters.` : void 0, q = F?.agents.filter((e) => e.include) ?? [], J = () => {
31
31
  U.cancel(), P(null), I(null), R(null);
32
32
  };
33
33
  u(() => {
@@ -40,11 +40,11 @@ var E = ({ scope: E, onCreated: ue, onQuotaExhausted: D }) => {
40
40
  try {
41
41
  let e = await U.draft({
42
42
  description: G,
43
- llmModelId: H,
43
+ llmModelId: H || null,
44
44
  scope: E
45
45
  });
46
46
  if (!e) return;
47
- P(e), I(w(e));
47
+ P(e), I(le(e));
48
48
  } catch (e) {
49
49
  R(b(e) ? "This workspace has no AI credits left for the copilot. The Free plan does not include AI-assisted creation; Pro does." : T(e, `Could not draft the ${O}.`));
50
50
  }
@@ -59,7 +59,7 @@ var E = ({ scope: E, onCreated: ue, onQuotaExhausted: D }) => {
59
59
  agents: e,
60
60
  links: N.links
61
61
  });
62
- ce.success(E === "BOT" ? `Draft bot "${t.app?.name ?? ""}" created with ${t.agents.length} draft agent(s)` : `${t.agents.length} draft agent(s) created`), Z(), ue(t);
62
+ S.success(E === "BOT" ? `Draft bot "${t.app?.name ?? ""}" created with ${t.agents.length} draft agent(s)` : `${t.agents.length} draft agent(s) created`), Z(), ue(t);
63
63
  } catch (e) {
64
64
  if (D && b(e)) {
65
65
  Z(), D();
@@ -117,7 +117,7 @@ var E = ({ scope: E, onCreated: ue, onQuotaExhausted: D }) => {
117
117
  htmlFor: "copilot-description",
118
118
  required: !0,
119
119
  error: K,
120
- description: `${G.length}/${C}`,
120
+ description: `${G.length}/${w}`,
121
121
  children: /* @__PURE__ */ v(s, {
122
122
  id: "copilot-description",
123
123
  rows: 3,
@@ -131,25 +131,32 @@ var E = ({ scope: E, onCreated: ue, onQuotaExhausted: D }) => {
131
131
  label: "Model",
132
132
  htmlFor: "copilot-model",
133
133
  required: !0,
134
- description: "A model registered in this workspace drafts the bot, and the drafted agents use it.",
134
+ description: "Automatic picks a working model of this workspace and tries another if it fails. The drafted agents use the model that drafted.",
135
135
  children: /* @__PURE__ */ y("select", {
136
136
  id: "copilot-model",
137
- className: le,
137
+ className: ce,
138
138
  value: H,
139
139
  disabled: U.loading || z.loading || B.loading,
140
140
  onChange: (e) => M(e.target.value),
141
- children: [V.length === 0 && /* @__PURE__ */ v("option", {
142
- value: "",
143
- children: X ? "Loading models…" : Y ? "Models could not be loaded" : "No model registered yet"
144
- }), V.map((e) => /* @__PURE__ */ y("option", {
145
- value: e.id,
146
- children: [
147
- e.name,
148
- " (",
149
- e.modelId,
150
- ")"
151
- ]
152
- }, e.id))]
141
+ children: [
142
+ V.length > 0 && /* @__PURE__ */ v("option", {
143
+ value: "",
144
+ children: "Automatic (recommended)"
145
+ }),
146
+ V.length === 0 && /* @__PURE__ */ v("option", {
147
+ value: "",
148
+ children: X ? "Loading models…" : Y ? "Models could not be loaded" : "No model registered yet"
149
+ }),
150
+ V.map((e) => /* @__PURE__ */ y("option", {
151
+ value: e.id,
152
+ children: [
153
+ e.name,
154
+ " (",
155
+ e.modelId,
156
+ ")"
157
+ ]
158
+ }, e.id))
159
+ ]
153
160
  })
154
161
  }),
155
162
  Y && !X && /* @__PURE__ */ y("div", {
@@ -186,6 +193,10 @@ var E = ({ scope: E, onCreated: ue, onQuotaExhausted: D }) => {
186
193
  variant: "outline",
187
194
  children: ["Model: ", N.model]
188
195
  }),
196
+ N.fellBack && /* @__PURE__ */ v(e, {
197
+ variant: "outline",
198
+ children: "The first model failed; another model drafted"
199
+ }),
189
200
  /* @__PURE__ */ v(e, {
190
201
  variant: "outline",
191
202
  children: N.aiCredits == null ? "AI credits: not recorded" : `${N.aiCredits} AI credits used`
@@ -341,7 +352,7 @@ var E = ({ scope: E, onCreated: ue, onQuotaExhausted: D }) => {
341
352
  }), /* @__PURE__ */ y(t, {
342
353
  leftIcon: /* @__PURE__ */ v(x, { size: 16 }),
343
354
  isLoading: U.loading,
344
- disabled: U.loading || !H || G.length < S || G.length > C,
355
+ disabled: U.loading || V.length === 0 || G.length < C || G.length > w,
345
356
  onClick: () => void me(),
346
357
  children: ["Draft ", O]
347
358
  })] }) })
@@ -1 +1 @@
1
- {"version":3,"file":"DescribeBotDialog.js","names":["_Fragment","Textarea","Textarea$1","Fragment$1","DESCRIPTION_MIN","DESCRIPTION_MAX","SELECT_CLASS","reviewFrom","draft","agent","errorText","error","fallback","DescribeBotDialog","noun","scope","open","setOpen","useState","description","setDescription","modelId","setModelId","setDraft","review","setReview","setError","models","useLLMModels","providers","useLLMProviders","answerModels","useMemo","configuredAnswerModels","chosenModel","model","drafting","useDraftBot","createDrafts","createState","useCreateFromDraft","trimmed","descriptionError","included","reset","catalogError","catalogLoading","close","runDraft","result","draftError","isQuotaExhaustedError","create","agents","_include","created","toast","onCreated","createError","onQuotaExhausted","updateAgent","current","key","patch","toggleKnowledgeBase","entry","agentKey","on","kbId","id","appName","canCreate","name","Card","CardHeader","CardTitle","WandSparkles","CardDescription","CardContent","Button","Sparkles","ResponsiveDialog","next","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","FormField","event","Badge","Input","link","suggestions","kb","ResponsiveDialogFooter"],"sources":["../../../src/botlit/components/DescribeBotDialog.tsx"],"sourcesContent":["/**\n * Copilot \"Describe your bot\" (BOFF-15360, ABOUT §9, BL-UC-21)\n * @module botlit/components\n *\n * One sentence → a reviewable draft: the bot (on the bot create page), its\n * agents, routing links, the model and knowledge-base suggestions, started\n * from a workspace template when one fits. The draft is shown for review and\n * editing; nothing exists until the person clicks \"Create drafts\", and even\n * then every entity is a DRAFT that goes live only when it is published.\n * Drafting can be cancelled at any time and leaves nothing behind. It is\n * metered as AI credits on the workspace plan.\n */\n\nimport { useEffect, useMemo, useState, type FC } from 'react';\nimport { Sparkles, WandSparkles } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { isQuotaExhaustedError } from '@burdenoff/fe-libs/shared/utils';\nimport {\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n} from '@burdenoff/fe-libs/ui';\n\nimport { Badge } from './Badge';\nimport { Button } from './Button';\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from './Card';\nimport { FormField, Input, Textarea } from './Input';\nimport {\n useCreateFromDraft,\n useDraftBot,\n type BotDraft,\n type BotDraftAgent,\n type BotDraftApp,\n type BotDraftScope,\n type CreatedDraft,\n} from '../hooks/useBotCopilot';\nimport { useLLMModels, useLLMProviders } from '../hooks/useLLMProviders';\nimport { configuredAnswerModels } from '../utils/embedding-models';\nimport { AGENT_NAME_MAX_LENGTH } from '../utils/agentSettings';\nimport { BOT_NAME_MAX_LENGTH } from '../utils/botIdentity';\n\nconst DESCRIPTION_MIN = 10;\nconst DESCRIPTION_MAX = 1000;\nconst SELECT_CLASS =\n 'flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm';\n\ninterface DescribeBotDialogProps {\n scope: BotDraftScope;\n /** Receives what was created (every entity is DRAFT). */\n onCreated: (created: CreatedDraft) => void;\n /** Called instead of an inline message when the plan's bot limit is reached. */\n onQuotaExhausted?: () => void;\n}\n\ninterface ReviewState {\n app: BotDraftApp | null;\n agents: Array<BotDraftAgent & { include: boolean }>;\n}\n\nfunction reviewFrom(draft: BotDraft): ReviewState {\n return {\n app: draft.app ? { ...draft.app } : null,\n agents: draft.agents.map((agent) => ({ ...agent, include: true })),\n };\n}\n\nfunction errorText(error: unknown, fallback: string): string {\n return error instanceof Error && error.message ? error.message : fallback;\n}\n\nexport const DescribeBotDialog: FC<DescribeBotDialogProps> = ({\n scope,\n onCreated,\n onQuotaExhausted,\n}) => {\n const noun = scope === 'BOT' ? 'bot' : 'agent';\n const [open, setOpen] = useState(false);\n const [description, setDescription] = useState('');\n const [modelId, setModelId] = useState('');\n const [draft, setDraft] = useState<BotDraft | null>(null);\n const [review, setReview] = useState<ReviewState | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n const models = useLLMModels();\n const providers = useLLMProviders();\n const answerModels = useMemo(\n () => configuredAnswerModels(models.data ?? [], providers.data ?? []),\n [models.data, providers.data]\n );\n // A selection only counts while it is still one of this workspace's models.\n const chosenModel = answerModels.some((model) => model.id === modelId)\n ? modelId\n : answerModels[0]?.id || '';\n\n const drafting = useDraftBot();\n const [createDrafts, createState] = useCreateFromDraft(scope);\n\n const trimmed = description.trim();\n const descriptionError =\n trimmed.length > 0 && trimmed.length < DESCRIPTION_MIN\n ? `Write at least ${DESCRIPTION_MIN} characters.`\n : trimmed.length > DESCRIPTION_MAX\n ? `Use at most ${DESCRIPTION_MAX} characters.`\n : undefined;\n const included = review?.agents.filter((agent) => agent.include) ?? [];\n\n const reset = () => {\n drafting.cancel();\n setDraft(null);\n setReview(null);\n setError(null);\n };\n\n // A draft from another workspace must never be created in this one.\n useEffect(() => {\n setModelId('');\n setDraft(null);\n setReview(null);\n setError(null);\n }, [drafting.workspaceId]);\n\n const catalogError = models.error ?? providers.error;\n const catalogLoading = models.loading || providers.loading;\n\n const close = () => {\n reset();\n setOpen(false);\n };\n\n const runDraft = async () => {\n setError(null);\n try {\n const result = await drafting.draft({ description: trimmed, llmModelId: chosenModel, scope });\n if (!result) return; // cancelled\n setDraft(result);\n setReview(reviewFrom(result));\n } catch (draftError: unknown) {\n setError(\n isQuotaExhaustedError(draftError)\n ? 'This workspace has no AI credits left for the copilot. The Free plan does not include AI-assisted creation; Pro does.'\n : errorText(draftError, `Could not draft the ${noun}.`)\n );\n }\n };\n\n const create = async () => {\n if (!draft || !review) return;\n setError(null);\n const agents = included.map(({ include: _include, ...agent }) => agent);\n try {\n const created = await createDrafts({ draft, app: review.app, agents, links: draft.links });\n toast.success(\n scope === 'BOT'\n ? `Draft bot \"${created.app?.name ?? ''}\" created with ${created.agents.length} draft agent(s)`\n : `${created.agents.length} draft agent(s) created`\n );\n close();\n onCreated(created);\n } catch (createError: unknown) {\n if (onQuotaExhausted && isQuotaExhaustedError(createError)) {\n close();\n onQuotaExhausted();\n return;\n }\n setError(errorText(createError, `Could not create the draft ${noun}.`));\n }\n };\n\n const updateAgent = (key: string, patch: Partial<BotDraftAgent & { include: boolean }>) =>\n setReview((current) =>\n current\n ? {\n ...current,\n agents: current.agents.map((agent) =>\n agent.key === key ? { ...agent, ...patch } : agent\n ),\n }\n : current\n );\n\n const toggleKnowledgeBase = (agentKey: string, kbId: string, on: boolean) => {\n const agent = review?.agents.find((entry) => entry.key === agentKey);\n if (!agent) return;\n updateAgent(agentKey, {\n knowledgeBaseIds: on\n ? [...new Set([...agent.knowledgeBaseIds, kbId])]\n : agent.knowledgeBaseIds.filter((id) => id !== kbId),\n });\n };\n\n const appName = review?.app?.name.trim() ?? '';\n const canCreate =\n included.length > 0 &&\n included.every((agent) => {\n const name = agent.name.trim();\n return (\n name.length > 0 &&\n name.length <= AGENT_NAME_MAX_LENGTH &&\n agent.systemPrompt.trim().length > 0\n );\n }) &&\n (scope === 'AGENTS' || (appName.length > 0 && appName.length <= BOT_NAME_MAX_LENGTH));\n\n return (\n <>\n <Card className=\"max-w-2xl\">\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <WandSparkles size={18} aria-hidden=\"true\" />\n Describe your {noun}\n </CardTitle>\n <CardDescription>\n Write one sentence and the copilot drafts{' '}\n {scope === 'BOT' ? 'a bot with its agents' : 'agents'} for you to review. Nothing goes\n live until you publish it. Uses AI credits.\n </CardDescription>\n </CardHeader>\n <CardContent>\n <Button leftIcon={<Sparkles size={16} />} onClick={() => setOpen(true)}>\n Describe your {noun}\n </Button>\n </CardContent>\n </Card>\n\n <ResponsiveDialog open={open} onOpenChange={(next) => (next ? setOpen(true) : close())}>\n <ResponsiveDialogContent className=\"max-h-[90vh] overflow-y-auto sm:max-w-3xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>Describe your {noun}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {review\n ? 'Review the draft. Edit or untick anything you do not want. Everything is created as a draft.'\n : 'One sentence is enough, for example: \"A bot that answers HR policy questions from our handbook and escalates payroll to a human.\"'}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n {!review && (\n <div className=\"space-y-4\">\n <FormField\n label=\"Description\"\n htmlFor=\"copilot-description\"\n required\n error={descriptionError}\n description={`${trimmed.length}/${DESCRIPTION_MAX}`}\n >\n <Textarea\n id=\"copilot-description\"\n rows={3}\n value={description}\n disabled={drafting.loading}\n aria-invalid={descriptionError ? true : undefined}\n onChange={(event) => setDescription(event.target.value)}\n />\n </FormField>\n <FormField\n label=\"Model\"\n htmlFor=\"copilot-model\"\n required\n description=\"A model registered in this workspace drafts the bot, and the drafted agents use it.\"\n >\n <select\n id=\"copilot-model\"\n className={SELECT_CLASS}\n value={chosenModel}\n disabled={drafting.loading || models.loading || providers.loading}\n onChange={(event) => setModelId(event.target.value)}\n >\n {answerModels.length === 0 && (\n <option value=\"\">\n {catalogLoading\n ? 'Loading models…'\n : catalogError\n ? 'Models could not be loaded'\n : 'No model registered yet'}\n </option>\n )}\n {answerModels.map((model) => (\n <option key={model.id} value={model.id}>\n {model.name} ({model.modelId})\n </option>\n ))}\n </select>\n </FormField>\n {catalogError && !catalogLoading && (\n <div\n role=\"alert\"\n className=\"flex items-center gap-2 text-sm text-status-error-text\"\n >\n The models in this workspace could not be loaded.\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n void models.refetch();\n void providers.refetch();\n }}\n >\n Retry\n </Button>\n </div>\n )}\n {drafting.loading && (\n <p role=\"status\" className=\"text-sm text-text-secondary\">\n Drafting… this can take up to a minute. Cancel at any time; nothing is created.\n </p>\n )}\n </div>\n )}\n\n {review && draft && (\n <div className=\"space-y-5\">\n <div className=\"flex flex-wrap items-center gap-2 text-xs text-text-secondary\">\n {draft.template && (\n <Badge variant=\"secondary\">Started from template: {draft.template.name}</Badge>\n )}\n <Badge variant=\"outline\">Model: {draft.model}</Badge>\n <Badge variant=\"outline\">\n {draft.aiCredits != null\n ? `${draft.aiCredits} AI credits used`\n : 'AI credits: not recorded'}\n </Badge>\n </div>\n {draft.notes && (\n <p className=\"rounded-md border border-border-subtle p-3 text-sm\">{draft.notes}</p>\n )}\n\n {review.app && (\n <fieldset className=\"space-y-3 rounded-lg border border-border-subtle p-4\">\n <legend className=\"px-1 text-sm font-medium\">Bot (draft)</legend>\n <FormField label=\"Name\" htmlFor=\"copilot-app-name\" required>\n <Input\n id=\"copilot-app-name\"\n maxLength={BOT_NAME_MAX_LENGTH}\n value={review.app.name}\n onChange={(event) =>\n setReview({ ...review, app: { ...review.app!, name: event.target.value } })\n }\n />\n </FormField>\n <FormField label=\"Welcome message\" htmlFor=\"copilot-app-welcome\">\n <Input\n id=\"copilot-app-welcome\"\n value={review.app.welcomeMessage ?? ''}\n onChange={(event) =>\n setReview({\n ...review,\n app: { ...review.app!, welcomeMessage: event.target.value },\n })\n }\n />\n </FormField>\n <p className=\"text-xs text-text-secondary\">\n Routing: {included.length > 1 ? review.app.routingStrategy : 'SINGLE'}\n {review.app.description ? ` · ${review.app.description}` : ''}\n </p>\n </fieldset>\n )}\n\n {review.agents.map((agent) => {\n const link = draft.links.find((entry) => entry.agentKey === agent.key);\n const suggestions = draft.knowledgeBases.filter((kb) =>\n kb.agentKeys.includes(agent.key)\n );\n return (\n <fieldset\n key={agent.key}\n className=\"space-y-3 rounded-lg border border-border-subtle p-4\"\n >\n <legend className=\"px-1 text-sm font-medium\">\n <label className=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n checked={agent.include}\n onChange={(event) =>\n updateAgent(agent.key, { include: event.target.checked })\n }\n />\n Agent (draft): {agent.name}\n </label>\n </legend>\n {agent.include && (\n <>\n <FormField\n label=\"Name\"\n htmlFor={`copilot-agent-${agent.key}-name`}\n required\n >\n <Input\n id={`copilot-agent-${agent.key}-name`}\n maxLength={AGENT_NAME_MAX_LENGTH}\n value={agent.name}\n onChange={(event) =>\n updateAgent(agent.key, { name: event.target.value })\n }\n />\n </FormField>\n <FormField\n label=\"System prompt\"\n htmlFor={`copilot-agent-${agent.key}-prompt`}\n required\n >\n <Textarea\n id={`copilot-agent-${agent.key}-prompt`}\n rows={6}\n value={agent.systemPrompt}\n onChange={(event) =>\n updateAgent(agent.key, { systemPrompt: event.target.value })\n }\n />\n </FormField>\n {suggestions.length > 0 && (\n <div className=\"space-y-1\">\n <p className=\"text-sm font-medium\">Suggested knowledge bases</p>\n {suggestions.map((kb) => (\n <label\n key={kb.knowledgeBaseId}\n className=\"flex items-start gap-2 text-sm\"\n >\n <input\n type=\"checkbox\"\n className=\"mt-1\"\n checked={agent.knowledgeBaseIds.includes(kb.knowledgeBaseId)}\n onChange={(event) =>\n toggleKnowledgeBase(\n agent.key,\n kb.knowledgeBaseId,\n event.target.checked\n )\n }\n />\n <span>\n {kb.name}\n {kb.reason && (\n <span className=\"block text-xs text-text-secondary\">\n {kb.reason}\n </span>\n )}\n </span>\n </label>\n ))}\n </div>\n )}\n {scope === 'BOT' && link && (\n <p className=\"text-xs text-text-secondary\">\n Routing: priority {link.priority}\n {link.isDefault ? ' · default agent' : ''}\n {link.intentPatterns.length > 0\n ? ` · intents: ${link.intentPatterns.join(', ')}`\n : ''}\n {link.triggerKeywords.length > 0\n ? ` · keywords: ${link.triggerKeywords.join(', ')}`\n : ''}\n </p>\n )}\n </>\n )}\n </fieldset>\n );\n })}\n </div>\n )}\n\n {error && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {error}\n </p>\n )}\n\n <ResponsiveDialogFooter>\n {!review ? (\n <>\n <Button variant=\"outline\" onClick={drafting.loading ? drafting.cancel : close}>\n {drafting.loading ? 'Cancel drafting' : 'Close'}\n </Button>\n <Button\n leftIcon={<Sparkles size={16} />}\n isLoading={drafting.loading}\n disabled={\n drafting.loading ||\n !chosenModel ||\n trimmed.length < DESCRIPTION_MIN ||\n trimmed.length > DESCRIPTION_MAX\n }\n onClick={() => void runDraft()}\n >\n Draft {noun}\n </Button>\n </>\n ) : (\n <>\n <Button variant=\"outline\" onClick={reset} disabled={createState.loading}>\n Discard draft\n </Button>\n <Button\n isLoading={createState.loading}\n disabled={!canCreate || createState.loading}\n onClick={() => void create()}\n >\n Create drafts\n </Button>\n </>\n )}\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AA4CA,IAAMI,IAAkB,IAClBC,IAAkB,KAClBC,KACJ;AAeF,SAASC,EAAW,GAA8B;CAChD,OAAO;EACL,KAAKC,EAAM,MAAM,EAAE,GAAGA,EAAM,IAAI,IAAI;EACpC,QAAQA,EAAM,OAAO,KAAK,OAAW;GAAE,GAAGC;GAAO,SAAS;EAAK,EAAE;CACnE;AACF;AAEA,SAASC,EAAU,GAAgB,GAA0B;CAC3D,OAAOC,aAAiB,SAASA,EAAM,UAAUA,EAAM,UAAUC;AACnE;AAEA,IAAaC,KAAiD,EAC5D,UACA,eACA,0BACI;CACJ,IAAMC,IAAOC,MAAU,QAAQ,QAAQ,SACjC,CAACC,IAAMC,KAAWC,EAAS,EAAK,G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AU,kBAACC,GAAD,EAAU,MAAM,GAAK,CAAA;KAC/B,WAAW5C,EAAS;KACpB,UACEA,EAAS,WACT,CAACF,KACDO,EAAQ,SAASrC,KACjBqC,EAAQ,SAASpC;KAEnB,eAAe,KAAK2C,GAAS;KAT/B,UAAA,CAUC,UACQlC,CACD;IACR,CAAA,CAAA,EAAA,CAAA,EAekB,CAAA;GACD;;CACT,CAAA,CAClB,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"DescribeBotDialog.js","names":["_Fragment","Textarea","Textarea$1","Fragment$1","DESCRIPTION_MIN","DESCRIPTION_MAX","SELECT_CLASS","reviewFrom","draft","agent","errorText","error","fallback","DescribeBotDialog","noun","scope","open","setOpen","useState","description","setDescription","modelId","setModelId","setDraft","review","setReview","setError","models","useLLMModels","providers","useLLMProviders","answerModels","useMemo","configuredAnswerModels","chosenModel","model","drafting","useDraftBot","createDrafts","createState","useCreateFromDraft","trimmed","descriptionError","included","reset","catalogError","catalogLoading","close","runDraft","result","draftError","isQuotaExhaustedError","create","agents","_include","created","toast","onCreated","createError","onQuotaExhausted","updateAgent","current","key","patch","toggleKnowledgeBase","entry","agentKey","on","kbId","id","appName","canCreate","name","Card","CardHeader","CardTitle","WandSparkles","CardDescription","CardContent","Button","Sparkles","ResponsiveDialog","next","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","FormField","event","Badge","Input","link","suggestions","kb","ResponsiveDialogFooter"],"sources":["../../../src/botlit/components/DescribeBotDialog.tsx"],"sourcesContent":["/**\n * Copilot \"Describe your bot\" (BOFF-15360, ABOUT §9, BL-UC-21)\n * @module botlit/components\n *\n * One sentence → a reviewable draft: the bot (on the bot create page), its\n * agents, routing links, the model and knowledge-base suggestions, started\n * from a workspace template when one fits. The draft is shown for review and\n * editing; nothing exists until the person clicks \"Create drafts\", and even\n * then every entity is a DRAFT that goes live only when it is published.\n * Drafting can be cancelled at any time and leaves nothing behind. It is\n * metered as AI credits on the workspace plan.\n */\n\nimport { useEffect, useMemo, useState, type FC } from 'react';\nimport { Sparkles, WandSparkles } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { isQuotaExhaustedError } from '@burdenoff/fe-libs/shared/utils';\nimport {\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n} from '@burdenoff/fe-libs/ui';\n\nimport { Badge } from './Badge';\nimport { Button } from './Button';\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from './Card';\nimport { FormField, Input, Textarea } from './Input';\nimport {\n useCreateFromDraft,\n useDraftBot,\n type BotDraft,\n type BotDraftAgent,\n type BotDraftApp,\n type BotDraftScope,\n type CreatedDraft,\n} from '../hooks/useBotCopilot';\nimport { useLLMModels, useLLMProviders } from '../hooks/useLLMProviders';\nimport { configuredAnswerModels } from '../utils/embedding-models';\nimport { AGENT_NAME_MAX_LENGTH } from '../utils/agentSettings';\nimport { BOT_NAME_MAX_LENGTH } from '../utils/botIdentity';\n\nconst DESCRIPTION_MIN = 10;\nconst DESCRIPTION_MAX = 1000;\nconst SELECT_CLASS =\n 'flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm';\n\ninterface DescribeBotDialogProps {\n scope: BotDraftScope;\n /** Receives what was created (every entity is DRAFT). */\n onCreated: (created: CreatedDraft) => void;\n /** Called instead of an inline message when the plan's bot limit is reached. */\n onQuotaExhausted?: () => void;\n}\n\ninterface ReviewState {\n app: BotDraftApp | null;\n agents: Array<BotDraftAgent & { include: boolean }>;\n}\n\nfunction reviewFrom(draft: BotDraft): ReviewState {\n return {\n app: draft.app ? { ...draft.app } : null,\n agents: draft.agents.map((agent) => ({ ...agent, include: true })),\n };\n}\n\nfunction errorText(error: unknown, fallback: string): string {\n return error instanceof Error && error.message ? error.message : fallback;\n}\n\nexport const DescribeBotDialog: FC<DescribeBotDialogProps> = ({\n scope,\n onCreated,\n onQuotaExhausted,\n}) => {\n const noun = scope === 'BOT' ? 'bot' : 'agent';\n const [open, setOpen] = useState(false);\n const [description, setDescription] = useState('');\n const [modelId, setModelId] = useState('');\n const [draft, setDraft] = useState<BotDraft | null>(null);\n const [review, setReview] = useState<ReviewState | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n const models = useLLMModels();\n const providers = useLLMProviders();\n const answerModels = useMemo(\n () => configuredAnswerModels(models.data ?? [], providers.data ?? []),\n [models.data, providers.data]\n );\n // A selection only counts while it is still one of this workspace's models.\n // Empty means \"Automatic\": the service drafts with the best working model\n // and falls back to the next one if it fails (BOFF-15436).\n const chosenModel = answerModels.some((model) => model.id === modelId) ? modelId : '';\n\n const drafting = useDraftBot();\n const [createDrafts, createState] = useCreateFromDraft(scope);\n\n const trimmed = description.trim();\n const descriptionError =\n trimmed.length > 0 && trimmed.length < DESCRIPTION_MIN\n ? `Write at least ${DESCRIPTION_MIN} characters.`\n : trimmed.length > DESCRIPTION_MAX\n ? `Use at most ${DESCRIPTION_MAX} characters.`\n : undefined;\n const included = review?.agents.filter((agent) => agent.include) ?? [];\n\n const reset = () => {\n drafting.cancel();\n setDraft(null);\n setReview(null);\n setError(null);\n };\n\n // A draft from another workspace must never be created in this one.\n useEffect(() => {\n setModelId('');\n setDraft(null);\n setReview(null);\n setError(null);\n }, [drafting.workspaceId]);\n\n const catalogError = models.error ?? providers.error;\n const catalogLoading = models.loading || providers.loading;\n\n const close = () => {\n reset();\n setOpen(false);\n };\n\n const runDraft = async () => {\n setError(null);\n try {\n const result = await drafting.draft({\n description: trimmed,\n llmModelId: chosenModel || null,\n scope,\n });\n if (!result) return; // cancelled\n setDraft(result);\n setReview(reviewFrom(result));\n } catch (draftError: unknown) {\n setError(\n isQuotaExhaustedError(draftError)\n ? 'This workspace has no AI credits left for the copilot. The Free plan does not include AI-assisted creation; Pro does.'\n : errorText(draftError, `Could not draft the ${noun}.`)\n );\n }\n };\n\n const create = async () => {\n if (!draft || !review) return;\n setError(null);\n const agents = included.map(({ include: _include, ...agent }) => agent);\n try {\n const created = await createDrafts({ draft, app: review.app, agents, links: draft.links });\n toast.success(\n scope === 'BOT'\n ? `Draft bot \"${created.app?.name ?? ''}\" created with ${created.agents.length} draft agent(s)`\n : `${created.agents.length} draft agent(s) created`\n );\n close();\n onCreated(created);\n } catch (createError: unknown) {\n if (onQuotaExhausted && isQuotaExhaustedError(createError)) {\n close();\n onQuotaExhausted();\n return;\n }\n setError(errorText(createError, `Could not create the draft ${noun}.`));\n }\n };\n\n const updateAgent = (key: string, patch: Partial<BotDraftAgent & { include: boolean }>) =>\n setReview((current) =>\n current\n ? {\n ...current,\n agents: current.agents.map((agent) =>\n agent.key === key ? { ...agent, ...patch } : agent\n ),\n }\n : current\n );\n\n const toggleKnowledgeBase = (agentKey: string, kbId: string, on: boolean) => {\n const agent = review?.agents.find((entry) => entry.key === agentKey);\n if (!agent) return;\n updateAgent(agentKey, {\n knowledgeBaseIds: on\n ? [...new Set([...agent.knowledgeBaseIds, kbId])]\n : agent.knowledgeBaseIds.filter((id) => id !== kbId),\n });\n };\n\n const appName = review?.app?.name.trim() ?? '';\n const canCreate =\n included.length > 0 &&\n included.every((agent) => {\n const name = agent.name.trim();\n return (\n name.length > 0 &&\n name.length <= AGENT_NAME_MAX_LENGTH &&\n agent.systemPrompt.trim().length > 0\n );\n }) &&\n (scope === 'AGENTS' || (appName.length > 0 && appName.length <= BOT_NAME_MAX_LENGTH));\n\n return (\n <>\n <Card className=\"max-w-2xl\">\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <WandSparkles size={18} aria-hidden=\"true\" />\n Describe your {noun}\n </CardTitle>\n <CardDescription>\n Write one sentence and the copilot drafts{' '}\n {scope === 'BOT' ? 'a bot with its agents' : 'agents'} for you to review. Nothing goes\n live until you publish it. Uses AI credits.\n </CardDescription>\n </CardHeader>\n <CardContent>\n <Button leftIcon={<Sparkles size={16} />} onClick={() => setOpen(true)}>\n Describe your {noun}\n </Button>\n </CardContent>\n </Card>\n\n <ResponsiveDialog open={open} onOpenChange={(next) => (next ? setOpen(true) : close())}>\n <ResponsiveDialogContent className=\"max-h-[90vh] overflow-y-auto sm:max-w-3xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>Describe your {noun}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {review\n ? 'Review the draft. Edit or untick anything you do not want. Everything is created as a draft.'\n : 'One sentence is enough, for example: \"A bot that answers HR policy questions from our handbook and escalates payroll to a human.\"'}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n {!review && (\n <div className=\"space-y-4\">\n <FormField\n label=\"Description\"\n htmlFor=\"copilot-description\"\n required\n error={descriptionError}\n description={`${trimmed.length}/${DESCRIPTION_MAX}`}\n >\n <Textarea\n id=\"copilot-description\"\n rows={3}\n value={description}\n disabled={drafting.loading}\n aria-invalid={descriptionError ? true : undefined}\n onChange={(event) => setDescription(event.target.value)}\n />\n </FormField>\n <FormField\n label=\"Model\"\n htmlFor=\"copilot-model\"\n required\n description=\"Automatic picks a working model of this workspace and tries another if it fails. The drafted agents use the model that drafted.\"\n >\n <select\n id=\"copilot-model\"\n className={SELECT_CLASS}\n value={chosenModel}\n disabled={drafting.loading || models.loading || providers.loading}\n onChange={(event) => setModelId(event.target.value)}\n >\n {answerModels.length > 0 && <option value=\"\">Automatic (recommended)</option>}\n {answerModels.length === 0 && (\n <option value=\"\">\n {catalogLoading\n ? 'Loading models…'\n : catalogError\n ? 'Models could not be loaded'\n : 'No model registered yet'}\n </option>\n )}\n {answerModels.map((model) => (\n <option key={model.id} value={model.id}>\n {model.name} ({model.modelId})\n </option>\n ))}\n </select>\n </FormField>\n {catalogError && !catalogLoading && (\n <div\n role=\"alert\"\n className=\"flex items-center gap-2 text-sm text-status-error-text\"\n >\n The models in this workspace could not be loaded.\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n void models.refetch();\n void providers.refetch();\n }}\n >\n Retry\n </Button>\n </div>\n )}\n {drafting.loading && (\n <p role=\"status\" className=\"text-sm text-text-secondary\">\n Drafting… this can take up to a minute. Cancel at any time; nothing is created.\n </p>\n )}\n </div>\n )}\n\n {review && draft && (\n <div className=\"space-y-5\">\n <div className=\"flex flex-wrap items-center gap-2 text-xs text-text-secondary\">\n {draft.template && (\n <Badge variant=\"secondary\">Started from template: {draft.template.name}</Badge>\n )}\n <Badge variant=\"outline\">Model: {draft.model}</Badge>\n {draft.fellBack && (\n <Badge variant=\"outline\">The first model failed; another model drafted</Badge>\n )}\n <Badge variant=\"outline\">\n {draft.aiCredits != null\n ? `${draft.aiCredits} AI credits used`\n : 'AI credits: not recorded'}\n </Badge>\n </div>\n {draft.notes && (\n <p className=\"rounded-md border border-border-subtle p-3 text-sm\">{draft.notes}</p>\n )}\n\n {review.app && (\n <fieldset className=\"space-y-3 rounded-lg border border-border-subtle p-4\">\n <legend className=\"px-1 text-sm font-medium\">Bot (draft)</legend>\n <FormField label=\"Name\" htmlFor=\"copilot-app-name\" required>\n <Input\n id=\"copilot-app-name\"\n maxLength={BOT_NAME_MAX_LENGTH}\n value={review.app.name}\n onChange={(event) =>\n setReview({ ...review, app: { ...review.app!, name: event.target.value } })\n }\n />\n </FormField>\n <FormField label=\"Welcome message\" htmlFor=\"copilot-app-welcome\">\n <Input\n id=\"copilot-app-welcome\"\n value={review.app.welcomeMessage ?? ''}\n onChange={(event) =>\n setReview({\n ...review,\n app: { ...review.app!, welcomeMessage: event.target.value },\n })\n }\n />\n </FormField>\n <p className=\"text-xs text-text-secondary\">\n Routing: {included.length > 1 ? review.app.routingStrategy : 'SINGLE'}\n {review.app.description ? ` · ${review.app.description}` : ''}\n </p>\n </fieldset>\n )}\n\n {review.agents.map((agent) => {\n const link = draft.links.find((entry) => entry.agentKey === agent.key);\n const suggestions = draft.knowledgeBases.filter((kb) =>\n kb.agentKeys.includes(agent.key)\n );\n return (\n <fieldset\n key={agent.key}\n className=\"space-y-3 rounded-lg border border-border-subtle p-4\"\n >\n <legend className=\"px-1 text-sm font-medium\">\n <label className=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n checked={agent.include}\n onChange={(event) =>\n updateAgent(agent.key, { include: event.target.checked })\n }\n />\n Agent (draft): {agent.name}\n </label>\n </legend>\n {agent.include && (\n <>\n <FormField\n label=\"Name\"\n htmlFor={`copilot-agent-${agent.key}-name`}\n required\n >\n <Input\n id={`copilot-agent-${agent.key}-name`}\n maxLength={AGENT_NAME_MAX_LENGTH}\n value={agent.name}\n onChange={(event) =>\n updateAgent(agent.key, { name: event.target.value })\n }\n />\n </FormField>\n <FormField\n label=\"System prompt\"\n htmlFor={`copilot-agent-${agent.key}-prompt`}\n required\n >\n <Textarea\n id={`copilot-agent-${agent.key}-prompt`}\n rows={6}\n value={agent.systemPrompt}\n onChange={(event) =>\n updateAgent(agent.key, { systemPrompt: event.target.value })\n }\n />\n </FormField>\n {suggestions.length > 0 && (\n <div className=\"space-y-1\">\n <p className=\"text-sm font-medium\">Suggested knowledge bases</p>\n {suggestions.map((kb) => (\n <label\n key={kb.knowledgeBaseId}\n className=\"flex items-start gap-2 text-sm\"\n >\n <input\n type=\"checkbox\"\n className=\"mt-1\"\n checked={agent.knowledgeBaseIds.includes(kb.knowledgeBaseId)}\n onChange={(event) =>\n toggleKnowledgeBase(\n agent.key,\n kb.knowledgeBaseId,\n event.target.checked\n )\n }\n />\n <span>\n {kb.name}\n {kb.reason && (\n <span className=\"block text-xs text-text-secondary\">\n {kb.reason}\n </span>\n )}\n </span>\n </label>\n ))}\n </div>\n )}\n {scope === 'BOT' && link && (\n <p className=\"text-xs text-text-secondary\">\n Routing: priority {link.priority}\n {link.isDefault ? ' · default agent' : ''}\n {link.intentPatterns.length > 0\n ? ` · intents: ${link.intentPatterns.join(', ')}`\n : ''}\n {link.triggerKeywords.length > 0\n ? ` · keywords: ${link.triggerKeywords.join(', ')}`\n : ''}\n </p>\n )}\n </>\n )}\n </fieldset>\n );\n })}\n </div>\n )}\n\n {error && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {error}\n </p>\n )}\n\n <ResponsiveDialogFooter>\n {!review ? (\n <>\n <Button variant=\"outline\" onClick={drafting.loading ? drafting.cancel : close}>\n {drafting.loading ? 'Cancel drafting' : 'Close'}\n </Button>\n <Button\n leftIcon={<Sparkles size={16} />}\n isLoading={drafting.loading}\n disabled={\n drafting.loading ||\n answerModels.length === 0 ||\n trimmed.length < DESCRIPTION_MIN ||\n trimmed.length > DESCRIPTION_MAX\n }\n onClick={() => void runDraft()}\n >\n Draft {noun}\n </Button>\n </>\n ) : (\n <>\n <Button variant=\"outline\" onClick={reset} disabled={createState.loading}>\n Discard draft\n </Button>\n <Button\n isLoading={createState.loading}\n disabled={!canCreate || createState.loading}\n onClick={() => void create()}\n >\n Create drafts\n </Button>\n </>\n )}\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AA4CA,IAAMI,IAAkB,IAClBC,IAAkB,KAClBC,KACJ;AAeF,SAASC,GAAW,GAA8B;CAChD,OAAO;EACL,KAAKC,EAAM,MAAM,EAAE,GAAGA,EAAM,IAAI,IAAI;EACpC,QAAQA,EAAM,OAAO,KAAK,OAAW;GAAE,GAAGC;GAAO,SAAS;EAAK,EAAE;CACnE;AACF;AAEA,SAASC,EAAU,GAAgB,GAA0B;CAC3D,OAAOC,aAAiB,SAASA,EAAM,UAAUA,EAAM,UAAUC;AACnE;AAEA,IAAaC,KAAiD,EAC5D,UACA,eACA,0BACI;CACJ,IAAMC,IAAOC,MAAU,QAAQ,QAAQ,SACjC,CAACC,IAAMC,KAAWC,EAAS,EAAK,GAChC,CAACC,GAAaC,MAAkBF,EAAS,EAAE,GAC3C,CAACG,GAASC,KAAcJ,EAAS,EAAE,GACnC,CAACV,GAAOe,KAAYL,EAA0B,IAAI,GAClD,CAACM,GAAQC,KAAaP,EAA6B,IAAI,GACvD,CAACP,GAAOe,KAAYR,EAAwB,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;KACpB,UACEA,EAAS,WACTL,EAAa,WAAW,KACxBU,EAAQ,SAASrC,KACjBqC,EAAQ,SAASpC;KAEnB,eAAe,KAAK2C,GAAS;KAT/B,UAAA,CAUC,UACQlC,CACD;IACR,CAAA,CAAA,EAAA,CAAA,EAekB,CAAA;GACD;;CACT,CAAA,CAClB,EAAA,CAAA;AAEN"}
@@ -22,7 +22,7 @@ export { useRetentionStatus, useApplyRetention } from './useRetention';
22
22
  export type { RetentionRunRecord, RetentionStatusRecord } from './useRetention';
23
23
  export { useSkills, useSkill, useCreateSkill, useUpdateSkill, useDeleteSkill, skillKeys, } from './useSkills';
24
24
  export type { SkillRecord } from './useSkills';
25
- export { usePromptTemplates, usePromptTemplate, useCreatePromptTemplate, useUpdatePromptTemplate, useDeletePromptTemplate, useRenderPromptTemplate, promptTemplateVariables, promptTemplateKeys, } from './usePromptTemplates';
25
+ export { usePromptTemplates, usePagedPromptTemplates, usePromptTemplate, useDuplicatePromptTemplate, useLoadPromptTemplateUsage, useCreatePromptTemplate, useUpdatePromptTemplate, useDeletePromptTemplate, useRenderPromptTemplate, promptTemplateVariables, promptTemplateKeys, } from './usePromptTemplates';
26
26
  export type { PromptTemplateRecord } from './usePromptTemplates';
27
27
  export { useAgentBindings, useSetAgentBindings, useTestPromptTemplate, useSavePromptTemplateVersion, usePromptTemplateVersions, } from './useAgentBindings';
28
28
  export type { AgentBindingsRecord, PromptTemplateTestRecord, PromptTemplateVersionRecord, } from './useAgentBindings';
@@ -9,13 +9,13 @@ import { PLATFORM_CREDENTIALS as M, connectorPlatform as N, useActiveOrganizatio
9
9
  import { useCreatePolicy as R, useDeletePolicy as z, usePolicies as B, usePolicy as V, useUpdatePolicy as H } from "./usePolicies.js";
10
10
  import { useApplyRetention as U, useRetentionStatus as W } from "./useRetention.js";
11
11
  import { useCreateSkill as G, useDeleteSkill as K, useSkill as q, useSkills as J, useUpdateSkill as Y } from "./useSkills.js";
12
- import { promptTemplateVariables as X, useCreatePromptTemplate as Z, useDeletePromptTemplate as Q, usePromptTemplate as $, usePromptTemplates as ee, useRenderPromptTemplate as te, useUpdatePromptTemplate as ne } from "./usePromptTemplates.js";
13
- import { useAgentBindings as re, usePromptTemplateVersions as ie, useSavePromptTemplateVersion as ae, useSetAgentBindings as oe, useTestPromptTemplate as se } from "./useAgentBindings.js";
14
- import { useExecutionSummary as ce, useExecutions as le } from "./useExecutions.js";
15
- import { buildBucketTree as ue, searchTreeRows as de, useAllBuckets as fe, useBucket as pe, useBucketBranch as me, useBucketContents as he, useBucketCount as ge, useBucketSearch as _e, useBuckets as ve, useChildBuckets as ye, useCreateBucket as be, useDeleteBucket as xe, useUpdateBucket as Se } from "./useBuckets.js";
16
- import { storePackageDescription as Ce, storePackageName as we, useInstallPackage as Te, useInstalledPackageCount as Ee, useInstalledPackages as De, useStorePackage as Oe, useStorePackageCount as ke, useStorePackages as Ae, useUninstallPackage as je, useUpdateInstalledPackage as Me } from "./useStore.js";
12
+ import { promptTemplateVariables as X, useCreatePromptTemplate as Z, useDeletePromptTemplate as Q, useDuplicatePromptTemplate as $, useLoadPromptTemplateUsage as ee, usePagedPromptTemplates as te, usePromptTemplate as ne, usePromptTemplates as re, useRenderPromptTemplate as ie, useUpdatePromptTemplate as ae } from "./usePromptTemplates.js";
13
+ import { useAgentBindings as oe, usePromptTemplateVersions as se, useSavePromptTemplateVersion as ce, useSetAgentBindings as le, useTestPromptTemplate as ue } from "./useAgentBindings.js";
14
+ import { useExecutionSummary as de, useExecutions as fe } from "./useExecutions.js";
15
+ import { buildBucketTree as pe, searchTreeRows as me, useAllBuckets as he, useBucket as ge, useBucketBranch as _e, useBucketContents as ve, useBucketCount as ye, useBucketSearch as be, useBuckets as xe, useChildBuckets as Se, useCreateBucket as Ce, useDeleteBucket as we, useUpdateBucket as Te } from "./useBuckets.js";
16
+ import { storePackageDescription as Ee, storePackageName as De, useInstallPackage as Oe, useInstalledPackageCount as ke, useInstalledPackages as Ae, useStorePackage as je, useStorePackageCount as Me, useStorePackages as Ne, useUninstallPackage as Pe, useUpdateInstalledPackage as Fe } from "./useStore.js";
17
17
  import "./useLLMProviders.js";
18
- import { useGlobalChannels as Ne, useInitiateSlackConnect as Pe, useLinkIntegrationConnection as Fe, useMyUserPlatformConnection as Ie, useRevokeSlackConnection as Le, useToggleSlackNotifications as Re } from "./useUserPlatformConnection.js";
19
- import { useConfigureSupervisor as ze, useRunSupervisorNow as Be, useSupervisorConfig as Ve, useSupervisorRuns as He } from "./useAiOperations.js";
20
- import { isActiveHandoff as Ue, useAcceptHandoff as We, useAssignHandoff as Ge, useHandoffConfig as Ke, useHandoffQueue as qe, useHandoffTranscript as Je, useRejectHandoff as Ye, useReleaseHandoff as Xe, useReplyToHandoff as Ze, useResolveHandoff as Qe, useUpsertHandoffConfig as $e } from "./useHandoffs.js";
21
- export { M as PLATFORM_CREDENTIALS, h as a2aAgentSkillCount, ue as buildBucketTree, N as connectorPlatform, Ue as isActiveHandoff, i as isMCPServerHealthy, a as mcpServerDescription, o as mcpServerEndpoint, X as promptTemplateVariables, _ as routeMetadataString, de as searchTreeRows, Ce as storePackageDescription, we as storePackageName, g as useA2AAgents, We as useAcceptHandoff, P as useActiveOrganizationId, re as useAgentBindings, n as useAgents, e as useAllBots, fe as useAllBuckets, v as useAllChannelConnectors, y as useAllChannelRoutes, U as useApplyRetention, Ge as useAssignHandoff, b as useBotChannelRoutes, t as useBots, pe as useBucket, me as useBucketBranch, he as useBucketContents, ge as useBucketCount, _e as useBucketSearch, ve as useBuckets, x as useChannelConnector, S as useChannelConnectors, C as useChannelOverview, w as useChannelRoutes, ye as useChildBuckets, ze as useConfigureSupervisor, be as useCreateBucket, T as useCreateChannelConnector, E as useCreateChannelRoute, s as useCreateMCPServer, R as useCreatePolicy, Z as useCreatePromptTemplate, G as useCreateSkill, xe as useDeleteBucket, D as useDeleteChannelConnector, O as useDeleteChannelRoute, c as useDeleteMCPServer, z as useDeletePolicy, Q as useDeletePromptTemplate, K as useDeleteSkill, ce as useExecutionSummary, le as useExecutions, k as useFindChannelConnector, Ne as useGlobalChannels, Ke as useHandoffConfig, qe as useHandoffQueue, Je as useHandoffTranscript, F as useInboundChannel, Pe as useInitiateSlackConnect, Te as useInstallPackage, Ee as useInstalledPackageCount, De as useInstalledPackages, Fe as useLinkIntegrationConnection, l as useMCPResources, u as useMCPServer, d as useMCPTools, Ie as useMyUserPlatformConnection, B as usePolicies, V as usePolicy, $ as usePromptTemplate, ie as usePromptTemplateVersions, ee as usePromptTemplates, I as useProvisionChannel, Ye as useRejectHandoff, Xe as useReleaseHandoff, te as useRenderPromptTemplate, Ze as useReplyToHandoff, Qe as useResolveHandoff, W as useRetentionStatus, r as useRetrievalProfiles, Le as useRevokeSlackConnection, Be as useRunSupervisorNow, ae as useSavePromptTemplateVersion, oe as useSetAgentBindings, q as useSkill, J as useSkills, Oe as useStorePackage, ke as useStorePackageCount, Ae as useStorePackages, Ve as useSupervisorConfig, He as useSupervisorRuns, f as useTestMCPConnection, se as useTestPromptTemplate, Re as useToggleSlackNotifications, je as useUninstallPackage, Se as useUpdateBucket, A as useUpdateChannelConnector, j as useUpdateChannelRoute, Me as useUpdateInstalledPackage, p as useUpdateMCPServer, m as useUpdateMCPTool, H as useUpdatePolicy, ne as useUpdatePromptTemplate, Y as useUpdateSkill, $e as useUpsertHandoffConfig, L as validateCredentials };
18
+ import { useGlobalChannels as Ie, useInitiateSlackConnect as Le, useLinkIntegrationConnection as Re, useMyUserPlatformConnection as ze, useRevokeSlackConnection as Be, useToggleSlackNotifications as Ve } from "./useUserPlatformConnection.js";
19
+ import { useConfigureSupervisor as He, useRunSupervisorNow as Ue, useSupervisorConfig as We, useSupervisorRuns as Ge } from "./useAiOperations.js";
20
+ import { isActiveHandoff as Ke, useAcceptHandoff as qe, useAssignHandoff as Je, useHandoffConfig as Ye, useHandoffQueue as Xe, useHandoffTranscript as Ze, useRejectHandoff as Qe, useReleaseHandoff as $e, useReplyToHandoff as et, useResolveHandoff as tt, useUpsertHandoffConfig as nt } from "./useHandoffs.js";
21
+ export { M as PLATFORM_CREDENTIALS, h as a2aAgentSkillCount, pe as buildBucketTree, N as connectorPlatform, Ke as isActiveHandoff, i as isMCPServerHealthy, a as mcpServerDescription, o as mcpServerEndpoint, X as promptTemplateVariables, _ as routeMetadataString, me as searchTreeRows, Ee as storePackageDescription, De as storePackageName, g as useA2AAgents, qe as useAcceptHandoff, P as useActiveOrganizationId, oe as useAgentBindings, n as useAgents, e as useAllBots, he as useAllBuckets, v as useAllChannelConnectors, y as useAllChannelRoutes, U as useApplyRetention, Je as useAssignHandoff, b as useBotChannelRoutes, t as useBots, ge as useBucket, _e as useBucketBranch, ve as useBucketContents, ye as useBucketCount, be as useBucketSearch, xe as useBuckets, x as useChannelConnector, S as useChannelConnectors, C as useChannelOverview, w as useChannelRoutes, Se as useChildBuckets, He as useConfigureSupervisor, Ce as useCreateBucket, T as useCreateChannelConnector, E as useCreateChannelRoute, s as useCreateMCPServer, R as useCreatePolicy, Z as useCreatePromptTemplate, G as useCreateSkill, we as useDeleteBucket, D as useDeleteChannelConnector, O as useDeleteChannelRoute, c as useDeleteMCPServer, z as useDeletePolicy, Q as useDeletePromptTemplate, K as useDeleteSkill, $ as useDuplicatePromptTemplate, de as useExecutionSummary, fe as useExecutions, k as useFindChannelConnector, Ie as useGlobalChannels, Ye as useHandoffConfig, Xe as useHandoffQueue, Ze as useHandoffTranscript, F as useInboundChannel, Le as useInitiateSlackConnect, Oe as useInstallPackage, ke as useInstalledPackageCount, Ae as useInstalledPackages, Re as useLinkIntegrationConnection, ee as useLoadPromptTemplateUsage, l as useMCPResources, u as useMCPServer, d as useMCPTools, ze as useMyUserPlatformConnection, te as usePagedPromptTemplates, B as usePolicies, V as usePolicy, ne as usePromptTemplate, se as usePromptTemplateVersions, re as usePromptTemplates, I as useProvisionChannel, Qe as useRejectHandoff, $e as useReleaseHandoff, ie as useRenderPromptTemplate, et as useReplyToHandoff, tt as useResolveHandoff, W as useRetentionStatus, r as useRetrievalProfiles, Be as useRevokeSlackConnection, Ue as useRunSupervisorNow, ce as useSavePromptTemplateVersion, le as useSetAgentBindings, q as useSkill, J as useSkills, je as useStorePackage, Me as useStorePackageCount, Ne as useStorePackages, We as useSupervisorConfig, Ge as useSupervisorRuns, f as useTestMCPConnection, ue as useTestPromptTemplate, Ve as useToggleSlackNotifications, Pe as useUninstallPackage, Te as useUpdateBucket, A as useUpdateChannelConnector, j as useUpdateChannelRoute, Fe as useUpdateInstalledPackage, p as useUpdateMCPServer, m as useUpdateMCPTool, H as useUpdatePolicy, ae as useUpdatePromptTemplate, Y as useUpdateSkill, nt as useUpsertHandoffConfig, L as validateCredentials };
@@ -49,6 +49,8 @@ export interface BotDraft {
49
49
  description: string;
50
50
  llmModelId: string;
51
51
  model: string;
52
+ /** BOFF-15436 — true when the picked (or first-ranked) model failed and another drafted. */
53
+ fellBack: boolean;
52
54
  template: {
53
55
  id: string;
54
56
  name: string;
@@ -75,7 +77,8 @@ export interface CreatedDraft {
75
77
  }
76
78
  export interface DraftRequest {
77
79
  description: string;
78
- llmModelId: string;
80
+ /** Null lets the service pick the best working model (with fallback). */
81
+ llmModelId: string | null;
79
82
  scope: BotDraftScope;
80
83
  }
81
84
  /** Draft from a sentence. `cancel` aborts the request; nothing was written, so nothing is left behind. */
@@ -10,6 +10,7 @@ var c = s`
10
10
  description
11
11
  llmModelId
12
12
  model
13
+ fellBack
13
14
  template {
14
15
  id
15
16
  name
@@ -1 +1 @@
1
- {"version":3,"file":"useBotCopilot.js","names":["DRAFT_DOCUMENT","CREATE_BOT_DOCUMENT","CREATE_AGENTS_DOCUMENT","errorOf","value","fallback","useDraftBot","client","useWorkspaceClient","workspaceId","useWorkspaceId","controller","useRef","loading","setLoading","useState","cancel","useCallback","useEffect","current","result","request","operationError","data","error","agentInput","agent","useCreateFromDraft","useWorkspaceMutation","scope","base","draft","agents","app","links","link"],"sources":["../../../src/botlit/hooks/useBotCopilot.ts"],"sourcesContent":["/**\n * Copilot \"Describe your bot\" (BOFF-15360, BL-UC-21)\n * @module botlit/hooks\n *\n * `draftBotFromDescription` turns one sentence into a reviewable plan and\n * writes nothing; it is metered as AI credits. `createBotFromDraft` /\n * `createAgentsFromDraft` create only what the person accepted, as DRAFT\n * entities, in one transaction. Drafting is cancellable: the request is\n * aborted and its answer discarded.\n */\n\nimport { gql } from '@apollo/client';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport {\n useWorkspaceClient,\n useWorkspaceId,\n useWorkspaceMutation,\n} from './internal/workspaceGateway';\n\nexport type BotDraftScope = 'BOT' | 'AGENTS';\nexport type DraftAgentType = 'ASSISTANT' | 'AUTOMATION' | 'ANALYST' | 'SPECIALIST';\nexport type DraftRoutingStrategy = 'SINGLE' | 'ROUND_ROBIN' | 'INTELLIGENT';\n\nexport interface BotDraftApp {\n name: string;\n description: string | null;\n type: DraftAgentType;\n routingStrategy: DraftRoutingStrategy;\n welcomeMessage: string | null;\n fallbackMessage: string | null;\n}\n\nexport interface BotDraftAgent {\n key: string;\n name: string;\n description: string | null;\n type: DraftAgentType;\n systemPrompt: string;\n temperature: number | null;\n knowledgeBaseIds: string[];\n templateId: string | null;\n}\n\nexport interface BotDraftLink {\n agentKey: string;\n priority: number;\n isDefault: boolean;\n intentPatterns: string[];\n triggerKeywords: string[];\n fallbackAgentKey: string | null;\n}\n\nexport interface BotDraftKnowledgeBase {\n knowledgeBaseId: string;\n name: string;\n reason: string;\n agentKeys: string[];\n}\n\nexport interface BotDraft {\n draftId: string;\n scope: BotDraftScope;\n description: string;\n llmModelId: string;\n model: string;\n template: { id: string; name: string; kind: string } | null;\n app: BotDraftApp | null;\n agents: BotDraftAgent[];\n links: BotDraftLink[];\n knowledgeBases: BotDraftKnowledgeBase[];\n notes: string | null;\n inputTokens: number;\n outputTokens: number;\n aiCredits: number | null;\n}\n\nexport interface CreatedDraft {\n app: { id: string; name: string } | null;\n agents: Array<{ id: string; name: string }>;\n}\n\nconst DRAFT_DOCUMENT = gql`\n mutation draftBotFromDescription($input: DraftBotFromDescriptionInput!) {\n draftBotFromDescription(input: $input) {\n draftId\n scope\n description\n llmModelId\n model\n template {\n id\n name\n kind\n }\n app {\n name\n description\n type\n routingStrategy\n welcomeMessage\n fallbackMessage\n }\n agents {\n key\n name\n description\n type\n systemPrompt\n temperature\n knowledgeBaseIds\n templateId\n }\n links {\n agentKey\n priority\n isDefault\n intentPatterns\n triggerKeywords\n fallbackAgentKey\n }\n knowledgeBases {\n knowledgeBaseId\n name\n reason\n agentKeys\n }\n notes\n inputTokens\n outputTokens\n aiCredits\n }\n }\n`;\n\nconst CREATE_BOT_DOCUMENT = gql`\n mutation createBotFromDraft($input: CreateBotFromDraftInput!) {\n createBotFromDraft(input: $input) {\n app {\n id\n name\n }\n agents {\n id\n name\n }\n }\n }\n`;\n\nconst CREATE_AGENTS_DOCUMENT = gql`\n mutation createAgentsFromDraft($input: CreateAgentsFromDraftInput!) {\n createAgentsFromDraft(input: $input) {\n app {\n id\n name\n }\n agents {\n id\n name\n }\n }\n }\n`;\n\nexport interface DraftRequest {\n description: string;\n llmModelId: string;\n scope: BotDraftScope;\n}\n\nfunction errorOf(value: unknown, fallback: string): Error {\n if (value instanceof Error) return value;\n return new Error(fallback);\n}\n\n/** Draft from a sentence. `cancel` aborts the request; nothing was written, so nothing is left behind. */\nexport function useDraftBot() {\n const client = useWorkspaceClient();\n const workspaceId = useWorkspaceId();\n const controller = useRef<AbortController | null>(null);\n const [loading, setLoading] = useState(false);\n\n const cancel = useCallback(() => {\n controller.current?.abort();\n controller.current = null;\n setLoading(false);\n }, []);\n\n // A draft belongs to the workspace it was asked in: switching workspace (or\n // unmounting) abandons an in-flight draft instead of letting it land later.\n useEffect(() => cancel, [cancel, workspaceId]);\n\n const draft = useCallback(\n async (request: DraftRequest): Promise<BotDraft | null> => {\n controller.current?.abort();\n const current = new AbortController();\n controller.current = current;\n setLoading(true);\n try {\n const result = await client.mutate<{ draftBotFromDescription?: BotDraft | null }>({\n mutation: DRAFT_DOCUMENT,\n variables: { input: { ...request, workspaceId } },\n context: { fetchOptions: { signal: current.signal } },\n });\n if (current.signal.aborted) return null;\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) throw errorOf(operationError, 'Failed to draft the bot');\n const data = result.data?.draftBotFromDescription;\n if (!data) throw new Error('Failed to draft the bot');\n return data;\n } catch (error: unknown) {\n if (current.signal.aborted) return null;\n throw errorOf(error, 'Failed to draft the bot');\n } finally {\n if (controller.current === current) {\n controller.current = null;\n setLoading(false);\n }\n }\n },\n [client, workspaceId]\n );\n\n return { draft, cancel, loading, workspaceId } as const;\n}\n\nexport interface CreateFromDraftInput {\n draft: BotDraft;\n app: BotDraftApp | null;\n agents: BotDraftAgent[];\n links: BotDraftLink[];\n}\n\nconst agentInput = (agent: BotDraftAgent) => ({\n key: agent.key,\n name: agent.name.trim(),\n description: agent.description?.trim() || null,\n type: agent.type,\n systemPrompt: agent.systemPrompt.trim(),\n temperature: agent.temperature,\n knowledgeBaseIds: agent.knowledgeBaseIds,\n templateId: agent.templateId,\n});\n\n/** Create the reviewed draft as DRAFT entities. */\nexport function useCreateFromDraft(scope: BotDraftScope) {\n const workspaceId = useWorkspaceId();\n return useWorkspaceMutation<\n {\n createBotFromDraft?: CreatedDraft | null;\n createAgentsFromDraft?: CreatedDraft | null;\n },\n CreateFromDraftInput,\n CreatedDraft\n >({\n document: scope === 'BOT' ? CREATE_BOT_DOCUMENT : CREATE_AGENTS_DOCUMENT,\n variables: ({ draft, app, agents, links }) => {\n const base = {\n workspaceId,\n draftId: draft.draftId,\n description: draft.description,\n llmModelId: draft.llmModelId,\n templateId: draft.template?.id ?? null,\n agents: agents.map(agentInput),\n };\n return {\n input:\n scope === 'BOT' && app\n ? {\n ...base,\n app: {\n name: app.name.trim(),\n description: app.description?.trim() || null,\n type: app.type,\n routingStrategy: agents.length > 1 ? app.routingStrategy : 'SINGLE',\n welcomeMessage: app.welcomeMessage?.trim() || null,\n fallbackMessage: app.fallbackMessage?.trim() || null,\n },\n links: links\n .filter((link) => agents.some((agent) => agent.key === link.agentKey))\n .map((link) => ({\n ...link,\n fallbackAgentKey:\n link.fallbackAgentKey &&\n agents.some((agent) => agent.key === link.fallbackAgentKey)\n ? link.fallbackAgentKey\n : null,\n })),\n }\n : base,\n };\n },\n select: (data) =>\n (scope === 'BOT' ? data?.createBotFromDraft : data?.createAgentsFromDraft) ?? undefined,\n errorMessage:\n scope === 'BOT' ? 'Failed to create the draft bot' : 'Failed to create the draft agents',\n });\n}\n"],"mappings":";;;;AAkFA,IAAMA,IAAiB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDpBC,IAAsB,CAAG;;;;;;;;;;;;;GAezBC,IAAyB,CAAG;;;;;;;;;;;;;;AAqBlC,SAASC,EAAQ,GAAgB,GAAyB;CAExD,OADIC,aAAiB,QAAcA,IACxB,MAAMC,CAAQ;AAC3B;AAGA,SAAgBC,IAAc;CAC5B,IAAMC,IAASC,EAAmB,GAC5BC,IAAcC,EAAe,GAC7BC,IAAaC,EAA+B,IAAI,GAChD,CAACC,GAASC,KAAcC,EAAS,EAAK,GAEtCC,IAASC,QAAkB;EAG/B,AAFAN,EAAW,SAAS,MAAM,GAC1B,EAAW,UAAU,MACrBG,EAAW,EAAK;CAClB,GAAG,CAAC,CAAC;CAqCL,OAjCAI,QAAgBF,GAAQ,CAACA,GAAQP,CAAW,CAAC,GAiCtC;EAAE,OA/BKQ,EACZ,OAAO,MAAoD;GACzD,EAAW,SAAS,MAAM;GAC1B,IAAME,IAAU,IAAI,gBAAgB;GAEpC,AADA,EAAW,UAAUA,GACrBL,EAAW,EAAI;GACf,IAAI;IACF,IAAMM,IAAS,MAAMb,EAAO,OAAsD;KAChF,UAAUP;KACV,WAAW,EAAE,OAAO;MAAE,GAAGqB;MAAS;KAAY,EAAE;KAChD,SAAS,EAAE,cAAc,EAAE,QAAQF,EAAQ,OAAO,EAAE;IACtD,CAAC;IACD,IAAIA,EAAQ,OAA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A,EAAI,iBAAiB,KAAK,KAAK;IAClD;IACA,OAAOC,EACJ,QAAQ,MAASF,EAAO,MAAM,MAAUN,EAAM,QAAQS,EAAK,QAAQ,CAAC,CAAC,CACrE,KAAK,OAAU;KACd,GAAGA;KACH,kBACEA,EAAK,oBACLH,EAAO,MAAM,MAAUN,EAAM,QAAQS,EAAK,gBAAgB,IACtDA,EAAK,mBACL;IACR,EAAE;GACN,IACAL,EACR;EACF;EACA,SAAS,OACND,MAAU,QAAQN,GAAM,qBAAqBA,GAAM,0BAA0B,KAAA;EAChF,cACEM,MAAU,QAAQ,mCAAmC;CACzD,CAAC;AACH"}
1
+ {"version":3,"file":"useBotCopilot.js","names":["DRAFT_DOCUMENT","CREATE_BOT_DOCUMENT","CREATE_AGENTS_DOCUMENT","errorOf","value","fallback","useDraftBot","client","useWorkspaceClient","workspaceId","useWorkspaceId","controller","useRef","loading","setLoading","useState","cancel","useCallback","useEffect","current","result","request","operationError","data","error","agentInput","agent","useCreateFromDraft","useWorkspaceMutation","scope","base","draft","agents","app","links","link"],"sources":["../../../src/botlit/hooks/useBotCopilot.ts"],"sourcesContent":["/**\n * Copilot \"Describe your bot\" (BOFF-15360, BL-UC-21)\n * @module botlit/hooks\n *\n * `draftBotFromDescription` turns one sentence into a reviewable plan and\n * writes nothing; it is metered as AI credits. `createBotFromDraft` /\n * `createAgentsFromDraft` create only what the person accepted, as DRAFT\n * entities, in one transaction. Drafting is cancellable: the request is\n * aborted and its answer discarded.\n */\n\nimport { gql } from '@apollo/client';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport {\n useWorkspaceClient,\n useWorkspaceId,\n useWorkspaceMutation,\n} from './internal/workspaceGateway';\n\nexport type BotDraftScope = 'BOT' | 'AGENTS';\nexport type DraftAgentType = 'ASSISTANT' | 'AUTOMATION' | 'ANALYST' | 'SPECIALIST';\nexport type DraftRoutingStrategy = 'SINGLE' | 'ROUND_ROBIN' | 'INTELLIGENT';\n\nexport interface BotDraftApp {\n name: string;\n description: string | null;\n type: DraftAgentType;\n routingStrategy: DraftRoutingStrategy;\n welcomeMessage: string | null;\n fallbackMessage: string | null;\n}\n\nexport interface BotDraftAgent {\n key: string;\n name: string;\n description: string | null;\n type: DraftAgentType;\n systemPrompt: string;\n temperature: number | null;\n knowledgeBaseIds: string[];\n templateId: string | null;\n}\n\nexport interface BotDraftLink {\n agentKey: string;\n priority: number;\n isDefault: boolean;\n intentPatterns: string[];\n triggerKeywords: string[];\n fallbackAgentKey: string | null;\n}\n\nexport interface BotDraftKnowledgeBase {\n knowledgeBaseId: string;\n name: string;\n reason: string;\n agentKeys: string[];\n}\n\nexport interface BotDraft {\n draftId: string;\n scope: BotDraftScope;\n description: string;\n llmModelId: string;\n model: string;\n /** BOFF-15436 — true when the picked (or first-ranked) model failed and another drafted. */\n fellBack: boolean;\n template: { id: string; name: string; kind: string } | null;\n app: BotDraftApp | null;\n agents: BotDraftAgent[];\n links: BotDraftLink[];\n knowledgeBases: BotDraftKnowledgeBase[];\n notes: string | null;\n inputTokens: number;\n outputTokens: number;\n aiCredits: number | null;\n}\n\nexport interface CreatedDraft {\n app: { id: string; name: string } | null;\n agents: Array<{ id: string; name: string }>;\n}\n\nconst DRAFT_DOCUMENT = gql`\n mutation draftBotFromDescription($input: DraftBotFromDescriptionInput!) {\n draftBotFromDescription(input: $input) {\n draftId\n scope\n description\n llmModelId\n model\n fellBack\n template {\n id\n name\n kind\n }\n app {\n name\n description\n type\n routingStrategy\n welcomeMessage\n fallbackMessage\n }\n agents {\n key\n name\n description\n type\n systemPrompt\n temperature\n knowledgeBaseIds\n templateId\n }\n links {\n agentKey\n priority\n isDefault\n intentPatterns\n triggerKeywords\n fallbackAgentKey\n }\n knowledgeBases {\n knowledgeBaseId\n name\n reason\n agentKeys\n }\n notes\n inputTokens\n outputTokens\n aiCredits\n }\n }\n`;\n\nconst CREATE_BOT_DOCUMENT = gql`\n mutation createBotFromDraft($input: CreateBotFromDraftInput!) {\n createBotFromDraft(input: $input) {\n app {\n id\n name\n }\n agents {\n id\n name\n }\n }\n }\n`;\n\nconst CREATE_AGENTS_DOCUMENT = gql`\n mutation createAgentsFromDraft($input: CreateAgentsFromDraftInput!) {\n createAgentsFromDraft(input: $input) {\n app {\n id\n name\n }\n agents {\n id\n name\n }\n }\n }\n`;\n\nexport interface DraftRequest {\n description: string;\n /** Null lets the service pick the best working model (with fallback). */\n llmModelId: string | null;\n scope: BotDraftScope;\n}\n\nfunction errorOf(value: unknown, fallback: string): Error {\n if (value instanceof Error) return value;\n return new Error(fallback);\n}\n\n/** Draft from a sentence. `cancel` aborts the request; nothing was written, so nothing is left behind. */\nexport function useDraftBot() {\n const client = useWorkspaceClient();\n const workspaceId = useWorkspaceId();\n const controller = useRef<AbortController | null>(null);\n const [loading, setLoading] = useState(false);\n\n const cancel = useCallback(() => {\n controller.current?.abort();\n controller.current = null;\n setLoading(false);\n }, []);\n\n // A draft belongs to the workspace it was asked in: switching workspace (or\n // unmounting) abandons an in-flight draft instead of letting it land later.\n useEffect(() => cancel, [cancel, workspaceId]);\n\n const draft = useCallback(\n async (request: DraftRequest): Promise<BotDraft | null> => {\n controller.current?.abort();\n const current = new AbortController();\n controller.current = current;\n setLoading(true);\n try {\n const result = await client.mutate<{ draftBotFromDescription?: BotDraft | null }>({\n mutation: DRAFT_DOCUMENT,\n variables: { input: { ...request, workspaceId } },\n context: { fetchOptions: { signal: current.signal } },\n });\n if (current.signal.aborted) return null;\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) throw errorOf(operationError, 'Failed to draft the bot');\n const data = result.data?.draftBotFromDescription;\n if (!data) throw new Error('Failed to draft the bot');\n return data;\n } catch (error: unknown) {\n if (current.signal.aborted) return null;\n throw errorOf(error, 'Failed to draft the bot');\n } finally {\n if (controller.current === current) {\n controller.current = null;\n setLoading(false);\n }\n }\n },\n [client, workspaceId]\n );\n\n return { draft, cancel, loading, workspaceId } as const;\n}\n\nexport interface CreateFromDraftInput {\n draft: BotDraft;\n app: BotDraftApp | null;\n agents: BotDraftAgent[];\n links: BotDraftLink[];\n}\n\nconst agentInput = (agent: BotDraftAgent) => ({\n key: agent.key,\n name: agent.name.trim(),\n description: agent.description?.trim() || null,\n type: agent.type,\n systemPrompt: agent.systemPrompt.trim(),\n temperature: agent.temperature,\n knowledgeBaseIds: agent.knowledgeBaseIds,\n templateId: agent.templateId,\n});\n\n/** Create the reviewed draft as DRAFT entities. */\nexport function useCreateFromDraft(scope: BotDraftScope) {\n const workspaceId = useWorkspaceId();\n return useWorkspaceMutation<\n {\n createBotFromDraft?: CreatedDraft | null;\n createAgentsFromDraft?: CreatedDraft | null;\n },\n CreateFromDraftInput,\n CreatedDraft\n >({\n document: scope === 'BOT' ? CREATE_BOT_DOCUMENT : CREATE_AGENTS_DOCUMENT,\n variables: ({ draft, app, agents, links }) => {\n const base = {\n workspaceId,\n draftId: draft.draftId,\n description: draft.description,\n llmModelId: draft.llmModelId,\n templateId: draft.template?.id ?? null,\n agents: agents.map(agentInput),\n };\n return {\n input:\n scope === 'BOT' && app\n ? {\n ...base,\n app: {\n name: app.name.trim(),\n description: app.description?.trim() || null,\n type: app.type,\n routingStrategy: agents.length > 1 ? app.routingStrategy : 'SINGLE',\n welcomeMessage: app.welcomeMessage?.trim() || null,\n fallbackMessage: app.fallbackMessage?.trim() || null,\n },\n links: links\n .filter((link) => agents.some((agent) => agent.key === link.agentKey))\n .map((link) => ({\n ...link,\n fallbackAgentKey:\n link.fallbackAgentKey &&\n agents.some((agent) => agent.key === link.fallbackAgentKey)\n ? link.fallbackAgentKey\n : null,\n })),\n }\n : base,\n };\n },\n select: (data) =>\n (scope === 'BOT' ? data?.createBotFromDraft : data?.createAgentsFromDraft) ?? undefined,\n errorMessage:\n scope === 'BOT' ? 'Failed to create the draft bot' : 'Failed to create the draft agents',\n });\n}\n"],"mappings":";;;;AAoFA,IAAMA,IAAiB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDpBC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
1
1
  import { CreatePromptTemplateInput, UpdatePromptTemplateInput } from '../../generated/wspace-types';
2
+ import { PromptTemplateUsage } from '../utils/promptTemplateForm';
2
3
  import { GraphQLInput } from './internal/mutationInput';
3
- import { QueryResult } from './internal/workspaceGateway';
4
+ import { PaginatedQueryResult, QueryResult } from './internal/workspaceGateway';
4
5
  export interface PromptTemplateRecord {
5
6
  id: string;
6
7
  name: string;
@@ -64,7 +65,16 @@ export declare const promptTemplateKeys: {
64
65
  details: () => readonly ["promptTemplates", "detail"];
65
66
  detail: (id: string) => readonly ["promptTemplates", "detail", string];
66
67
  };
68
+ /**
69
+ * Every template matching the filter, all pages: pickers (skills, agent
70
+ * bindings, Prompt Studio) must see the whole workspace, not the first 100.
71
+ */
67
72
  export declare function usePromptTemplates(filter?: PromptTemplateFilterVariables): QueryResult<PromptTemplateRecord[]>;
73
+ /**
74
+ * The Prompt Templates list page: server-side search and filters, one page at
75
+ * a time with `loadMore` (BOFF-12545). Pickers keep `usePromptTemplates`.
76
+ */
77
+ export declare function usePagedPromptTemplates(filter?: PromptTemplateFilterVariables): PaginatedQueryResult<PromptTemplateRecord[]>;
68
78
  export declare function usePromptTemplate(templateId: string | undefined): QueryResult<PromptTemplateRecord | null>;
69
79
  export declare function useCreatePromptTemplate(): {
70
80
  create: (input: CreatePromptTemplateVariables) => Promise<PromptTemplateRecord>;
@@ -86,3 +96,18 @@ export declare function useRenderPromptTemplate(): {
86
96
  loading: boolean;
87
97
  error: Error | undefined;
88
98
  };
99
+ export interface DuplicatePromptTemplateVariables {
100
+ templateId: string;
101
+ name: string;
102
+ }
103
+ /** Copies a template under a new name; the copy starts as a DRAFT at version 1.0.0 (BOFF-12547). */
104
+ export declare function useDuplicatePromptTemplate(): {
105
+ duplicate: (input: DuplicatePromptTemplateVariables) => Promise<PromptTemplateRecord>;
106
+ loading: boolean;
107
+ error: Error | undefined;
108
+ };
109
+ /**
110
+ * Returns a function that reads which agents and skills use a template, fresh
111
+ * each time: a delete confirmation is about to rely on it (BOFF-12547).
112
+ */
113
+ export declare function useLoadPromptTemplateUsage(): (templateId: string) => Promise<PromptTemplateUsage>;