@burdenoff/microfe-botmanor 2026.1118.6 → 2026.1118.7

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.
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ export declare const AgentBindingsPanel: FC<{
3
+ agentId: string;
4
+ }>;
@@ -0,0 +1,305 @@
1
+ import { Card as e, CardContent as t, CardDescription as n, CardHeader as r, CardTitle as i } from "./Card.js";
2
+ import { BOTMANOR_PERMISSIONS as a } from "../permissions/botmanorPermissions.js";
3
+ import { useBotmanorCan as o } from "../permissions/useBotmanorPermissions.js";
4
+ import { Button as s } from "./Button.js";
5
+ import { Input as ee } from "./Input.js";
6
+ import { Badge as c } from "./Badge.js";
7
+ import "../hooks/index.js";
8
+ import { graphqlErrorMessage as l } from "../utils/errors.js";
9
+ import { useRetrievalProfiles as u } from "../hooks/useRetrievalProfiles.js";
10
+ import { useSkills as d } from "../hooks/useSkills.js";
11
+ import { promptTemplateVariables as f, usePromptTemplate as p, usePromptTemplates as m } from "../hooks/usePromptTemplates.js";
12
+ import { useAgentBindings as h, useSetAgentBindings as g } from "../hooks/useAgentBindings.js";
13
+ import { typedVariableValue as _ } from "../utils/promptVariables.js";
14
+ import "../permissions/index.js";
15
+ import { useEffect as v, useMemo as y, useState as b } from "react";
16
+ import { jsx as x, jsxs as S } from "react/jsx-runtime";
17
+ import { ArrowDown as C, ArrowUp as te, Layers as w } from "lucide-react";
18
+ import { toast as T } from "sonner";
19
+ // src/botlit/components/AgentBindingsPanel.tsx
20
+ var E = "h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 text-sm";
21
+ function D(e) {
22
+ let t = e?.promptTemplate?.variables;
23
+ return t && typeof t == "object" && !Array.isArray(t) ? t : {};
24
+ }
25
+ function O(e) {
26
+ let t = {};
27
+ for (let [n, r] of Object.entries(D(e))) t[n] = typeof r == "string" ? r : JSON.stringify(r);
28
+ return {
29
+ promptTemplateId: e?.promptTemplate?.promptTemplateId ?? "",
30
+ variables: t,
31
+ edited: [],
32
+ skillIds: [...e?.skills ?? []].sort((e, t) => e.position - t.position).map((e) => e.skillId),
33
+ retrievalProfileId: e?.retrievalProfile?.retrievalProfileId ?? ""
34
+ };
35
+ }
36
+ var k = (e) => e !== "ARCHIVED", A = ({ agentId: A }) => {
37
+ let j = o(), [M, N] = b(!1), P = j(a.AGENT_UPDATE), F = h(A), I = P && !M && !!F.data && !F.loading, L = m(), R = d(), z = u(), { save: B } = g(A), [V, H] = b(() => O(null)), U = p(V.promptTemplateId || void 0), W = U.data && U.data.id === V.promptTemplateId ? U.data : null, G = !!V.promptTemplateId && !U.loading && !!U.data && U.data?.id !== V.promptTemplateId, { refetch: K } = U;
38
+ v(() => {
39
+ G && K();
40
+ }, [G, K]);
41
+ let q = !!F.data && (!V.promptTemplateId || W !== null && !U.loading) && !F.loading && !F.error && !L.loading && !L.error && !R.loading && !R.error && !z.loading && !z.error;
42
+ v(() => {
43
+ H(O(F.data));
44
+ }, [F.data]);
45
+ let J = y(() => W ? f(W) : [], [W]), Y = F.data?.retrievalProfile, X = V.retrievalProfileId ? z.data.find((e) => e.id === V.retrievalProfileId) ?? (Y?.retrievalProfileId === V.retrievalProfileId ? Y : null) : null, Z = y(() => new Map(R.data.map((e) => [e.id, e])), [R.data]), Q = R.data.filter((e) => k(e.status) && !V.skillIds.includes(e.id)), $ = (e, t) => {
46
+ let n = [...V.skillIds], r = e + t;
47
+ r < 0 || r >= n.length || ([n[e], n[r]] = [n[r], n[e]], H({
48
+ ...V,
49
+ skillIds: n
50
+ }));
51
+ }, ne = async () => {
52
+ let e = F.data?.promptTemplate?.promptTemplateId ?? "", t = V.promptTemplateId !== e, n = t ? {} : D(F.data), r = {};
53
+ for (let e of J) {
54
+ let t = V.variables[e.name] ?? "";
55
+ !V.edited.includes(e.name) && e.name in n ? r[e.name] = n[e.name] : t !== "" && (r[e.name] = _(e.type, t));
56
+ }
57
+ let i = !!V.promptTemplateId && (t || V.edited.length > 0);
58
+ N(!0);
59
+ try {
60
+ await B({
61
+ promptTemplateId: V.promptTemplateId || null,
62
+ ...i ? { promptVariables: r } : {},
63
+ skillIds: V.skillIds,
64
+ retrievalProfileId: V.retrievalProfileId || null
65
+ }), T.success("Agent bindings saved"), await F.refetch();
66
+ } catch (e) {
67
+ T.error(l(e, "Failed to save the agent bindings"));
68
+ } finally {
69
+ N(!1);
70
+ }
71
+ };
72
+ return /* @__PURE__ */ S(e, { children: [/* @__PURE__ */ S(r, { children: [/* @__PURE__ */ S(i, {
73
+ className: "flex items-center gap-2",
74
+ children: [/* @__PURE__ */ x(w, { size: 18 }), "Prompt template, skills & retrieval"]
75
+ }), /* @__PURE__ */ x(n, { children: "Every run of this agent starts from the bound prompt template, adds the agent's own system prompt and the skills below, and searches its knowledge with the retrieval profile." })] }), /* @__PURE__ */ S(t, {
76
+ className: "space-y-6",
77
+ children: [
78
+ F.error && /* @__PURE__ */ x("p", {
79
+ role: "alert",
80
+ className: "text-sm text-status-error-text",
81
+ children: l(F.error, "Failed to load the agent bindings")
82
+ }),
83
+ /* @__PURE__ */ S("section", {
84
+ className: "space-y-3",
85
+ children: [/* @__PURE__ */ S("label", {
86
+ className: "grid gap-2 text-sm font-medium",
87
+ children: ["Prompt template", /* @__PURE__ */ S("select", {
88
+ "aria-label": "Prompt template",
89
+ className: E,
90
+ value: V.promptTemplateId,
91
+ disabled: !I,
92
+ onChange: (e) => H({
93
+ ...V,
94
+ promptTemplateId: e.target.value,
95
+ variables: {},
96
+ edited: []
97
+ }),
98
+ children: [
99
+ /* @__PURE__ */ x("option", {
100
+ value: "",
101
+ children: "No prompt template"
102
+ }),
103
+ W && !L.data.some((e) => e.id === W.id) && /* @__PURE__ */ S("option", {
104
+ value: W.id,
105
+ children: [
106
+ W.name,
107
+ " · v",
108
+ W.version
109
+ ]
110
+ }),
111
+ L.data.filter((e) => k(e.status) || e.id === V.promptTemplateId).map((e) => /* @__PURE__ */ S("option", {
112
+ value: e.id,
113
+ children: [
114
+ e.name,
115
+ " · v",
116
+ e.version
117
+ ]
118
+ }, e.id))
119
+ ]
120
+ })]
121
+ }), J.length > 0 && /* @__PURE__ */ x("div", {
122
+ className: "grid gap-3 sm:grid-cols-2",
123
+ children: J.map((e) => /* @__PURE__ */ S("label", {
124
+ className: "grid gap-1 text-sm",
125
+ children: [/* @__PURE__ */ S("span", { children: [`{{${e.name}}}`, e.required && /* @__PURE__ */ x("span", {
126
+ className: "ml-1 text-status-error-text",
127
+ children: "*"
128
+ })] }), /* @__PURE__ */ x(ee, {
129
+ "aria-label": `Variable ${e.name}`,
130
+ disabled: !I,
131
+ placeholder: typeof e.defaultValue == "string" ? `Default: ${e.defaultValue}` : e.description ?? e.type,
132
+ value: V.variables[e.name] ?? "",
133
+ onChange: (t) => H({
134
+ ...V,
135
+ variables: {
136
+ ...V.variables,
137
+ [e.name]: t.target.value
138
+ },
139
+ edited: V.edited.includes(e.name) ? V.edited : [...V.edited, e.name]
140
+ })
141
+ })]
142
+ }, e.name))
143
+ })]
144
+ }),
145
+ /* @__PURE__ */ S("section", {
146
+ className: "space-y-3",
147
+ children: [
148
+ /* @__PURE__ */ x("p", {
149
+ className: "text-sm font-medium",
150
+ children: "Skills"
151
+ }),
152
+ V.skillIds.length === 0 ? /* @__PURE__ */ x("p", {
153
+ className: "text-sm text-text-secondary",
154
+ children: "No skills attached."
155
+ }) : /* @__PURE__ */ x("ol", {
156
+ className: "space-y-2",
157
+ children: V.skillIds.map((e, t) => {
158
+ let n = Z.get(e);
159
+ return /* @__PURE__ */ S("li", {
160
+ className: "flex items-center gap-3 rounded-lg border border-border-subtle p-3",
161
+ children: [
162
+ /* @__PURE__ */ S(c, {
163
+ variant: "outline",
164
+ children: ["#", t + 1]
165
+ }),
166
+ /* @__PURE__ */ S("div", {
167
+ className: "min-w-0 flex-1",
168
+ children: [/* @__PURE__ */ x("p", {
169
+ className: "truncate text-sm font-medium",
170
+ children: n?.name ?? F.data?.skills.find((t) => t.skillId === e)?.name ?? e
171
+ }), n?.description && /* @__PURE__ */ x("p", {
172
+ className: "truncate text-xs text-text-secondary",
173
+ children: n.description
174
+ })]
175
+ }),
176
+ I && /* @__PURE__ */ S("div", {
177
+ className: "flex items-center gap-1",
178
+ children: [
179
+ /* @__PURE__ */ x(s, {
180
+ size: "sm",
181
+ variant: "ghost",
182
+ "aria-label": "Move skill up",
183
+ onClick: () => $(t, -1),
184
+ children: /* @__PURE__ */ x(te, { size: 14 })
185
+ }),
186
+ /* @__PURE__ */ x(s, {
187
+ size: "sm",
188
+ variant: "ghost",
189
+ "aria-label": "Move skill down",
190
+ onClick: () => $(t, 1),
191
+ children: /* @__PURE__ */ x(C, { size: 14 })
192
+ }),
193
+ /* @__PURE__ */ x(s, {
194
+ size: "sm",
195
+ variant: "outline",
196
+ onClick: () => H({
197
+ ...V,
198
+ skillIds: V.skillIds.filter((t) => t !== e)
199
+ }),
200
+ children: "Remove"
201
+ })
202
+ ]
203
+ })
204
+ ]
205
+ }, e);
206
+ })
207
+ }),
208
+ I && Q.length > 0 && /* @__PURE__ */ S("select", {
209
+ "aria-label": "Add skill",
210
+ className: E,
211
+ value: "",
212
+ onChange: (e) => e.target.value && H({
213
+ ...V,
214
+ skillIds: [...V.skillIds, e.target.value]
215
+ }),
216
+ children: [/* @__PURE__ */ x("option", {
217
+ value: "",
218
+ children: "Add a skill…"
219
+ }), Q.map((e) => /* @__PURE__ */ x("option", {
220
+ value: e.id,
221
+ children: e.name
222
+ }, e.id))]
223
+ })
224
+ ]
225
+ }),
226
+ /* @__PURE__ */ S("section", {
227
+ className: "space-y-2",
228
+ children: [/* @__PURE__ */ S("label", {
229
+ className: "grid gap-2 text-sm font-medium",
230
+ children: ["Retrieval profile", /* @__PURE__ */ S("select", {
231
+ "aria-label": "Retrieval profile",
232
+ className: E,
233
+ value: V.retrievalProfileId,
234
+ disabled: !I,
235
+ onChange: (e) => H({
236
+ ...V,
237
+ retrievalProfileId: e.target.value
238
+ }),
239
+ children: [
240
+ /* @__PURE__ */ x("option", {
241
+ value: "",
242
+ children: "Default retrieval (vector, top 5)"
243
+ }),
244
+ F.data?.retrievalProfile && !z.data.some((e) => e.id === F.data?.retrievalProfile?.retrievalProfileId) && /* @__PURE__ */ S("option", {
245
+ value: F.data.retrievalProfile.retrievalProfileId,
246
+ children: [
247
+ F.data.retrievalProfile.name,
248
+ " ·",
249
+ " ",
250
+ F.data.retrievalProfile.strategyMode,
251
+ " · top",
252
+ " ",
253
+ F.data.retrievalProfile.topK
254
+ ]
255
+ }),
256
+ z.data.filter((e) => k(e.status) || e.id === V.retrievalProfileId).map((e) => /* @__PURE__ */ S("option", {
257
+ value: e.id,
258
+ children: [
259
+ e.name,
260
+ " · ",
261
+ e.strategyMode,
262
+ " · top ",
263
+ e.topK
264
+ ]
265
+ }, e.id))
266
+ ]
267
+ })]
268
+ }), X && /* @__PURE__ */ S("p", {
269
+ className: "text-xs text-text-secondary",
270
+ children: [
271
+ X.strategyMode,
272
+ " search, top ",
273
+ X.topK,
274
+ X.minRelevanceScore != null && `, minimum relevance ${X.minRelevanceScore}`,
275
+ X.noAnswerIfBelowThreshold && ", abstains when nothing clears the threshold",
276
+ "."
277
+ ]
278
+ })]
279
+ }),
280
+ P && /* @__PURE__ */ x("div", {
281
+ className: "flex justify-end",
282
+ children: /* @__PURE__ */ x(s, {
283
+ onClick: () => void ne(),
284
+ isLoading: M,
285
+ disabled: !q || M,
286
+ children: "Save bindings"
287
+ })
288
+ }),
289
+ F.data && /* @__PURE__ */ S("section", {
290
+ className: "space-y-2",
291
+ children: [/* @__PURE__ */ x("p", {
292
+ className: "text-sm font-medium",
293
+ children: "Effective system prompt"
294
+ }), /* @__PURE__ */ x("pre", {
295
+ "data-testid": "effective-system-prompt",
296
+ className: "max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-bg-sunken p-4 font-mono text-sm",
297
+ children: F.data.effectiveSystemPrompt
298
+ })]
299
+ })
300
+ ]
301
+ })] });
302
+ };
303
+ export { A as AgentBindingsPanel };
304
+
305
+ //# sourceMappingURL=AgentBindingsPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentBindingsPanel.js","names":["SELECT_CLASS","storedVariables","stored","bindings","draftFrom","variables","key","value","a","b","skill","isLive","status","AgentBindingsPanel","can","useBotmanorCan","busy","setBusy","useState","canUpdate","BOTMANOR_PERMISSIONS","useAgentBindings","agentId","editable","templates","usePromptTemplates","skills","useSkills","profiles","useRetrievalProfiles","useSetAgentBindings","draft","setDraft","selectedTemplate","usePromptTemplate","boundTemplate","staleTemplate","refetchTemplate","ready","declared","useMemo","promptTemplateVariables","boundProfile","selectedProfile","row","skillsById","availableSkills","moveSkill","next","target","index","delta","handleSave","boundTemplateId","templateChanged","promptVariables","variable","text","typedVariableValue","sendVariables","save","toast","error","graphqlErrorMessage","Card","CardHeader","CardTitle","Layers","CardDescription","CardContent","event","Input","skillId","Badge","bound","Button","ArrowUp","ArrowDown","id"],"sources":["../../../src/botlit/components/AgentBindingsPanel.tsx"],"sourcesContent":["/**\n * Agent Bindings Panel (BOFF-15360)\n * @module botlit/components\n *\n * Attach a prompt template (with its variable values), skills and a retrieval\n * profile to an agent. Every run of the agent — test chat, website assistant,\n * channels, A2A — composes its system prompt from them and retrieves\n * knowledge with the profile. Saved through `setAgentBindings`.\n */\nimport type { FC } from 'react';\nimport { useEffect, useMemo, useState } from 'react';\nimport { ArrowDown, ArrowUp, Layers } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from './Card';\nimport { Button } from './Button';\nimport { Input } from './Input';\nimport { Badge } from './Badge';\nimport {\n promptTemplateVariables,\n usePromptTemplate,\n useAgentBindings,\n usePromptTemplates,\n useRetrievalProfiles,\n useSetAgentBindings,\n useSkills,\n type AgentBindingsRecord,\n} from '../hooks';\nimport { graphqlErrorMessage } from '../utils/errors';\nimport { typedVariableValue } from '../utils/promptVariables';\nimport { BOTMANOR_PERMISSIONS, useBotmanorCan } from '../permissions';\n\nconst SELECT_CLASS =\n 'h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 text-sm';\n\ninterface Draft {\n promptTemplateId: string;\n /** Text shown in each variable field. */\n variables: Record<string, string>;\n /** Names whose field was edited since the bindings loaded. */\n edited: string[];\n skillIds: string[];\n retrievalProfileId: string;\n}\n\nfunction storedVariables(bindings: AgentBindingsRecord | null): Record<string, unknown> {\n const stored = bindings?.promptTemplate?.variables;\n return stored && typeof stored === 'object' && !Array.isArray(stored)\n ? (stored as Record<string, unknown>)\n : {};\n}\n\nfunction draftFrom(bindings: AgentBindingsRecord | null): Draft {\n const variables: Record<string, string> = {};\n for (const [key, value] of Object.entries(storedVariables(bindings))) {\n variables[key] = typeof value === 'string' ? value : JSON.stringify(value);\n }\n return {\n promptTemplateId: bindings?.promptTemplate?.promptTemplateId ?? '',\n variables,\n edited: [],\n skillIds: [...(bindings?.skills ?? [])]\n .sort((a, b) => a.position - b.position)\n .map((skill) => skill.skillId),\n retrievalProfileId: bindings?.retrievalProfile?.retrievalProfileId ?? '',\n };\n}\n\nconst isLive = (status: string) => status !== 'ARCHIVED';\n\nexport const AgentBindingsPanel: FC<{ agentId: string }> = ({ agentId }) => {\n const can = useBotmanorCan();\n // Controls lock from Save until the saved bindings have been read back, so\n // an edit made meanwhile cannot be replaced by the refetched snapshot.\n const [busy, setBusy] = useState(false);\n const canUpdate = can(BOTMANOR_PERMISSIONS.AGENT_UPDATE);\n const bindings = useAgentBindings(agentId);\n // Nothing is editable before the stored bindings arrive: they would\n // replace any edit made meanwhile.\n const editable = canUpdate && !busy && Boolean(bindings.data) && !bindings.loading;\n const templates = usePromptTemplates();\n const skills = useSkills();\n const profiles = useRetrievalProfiles();\n const { save } = useSetAgentBindings(agentId);\n // Saving sends the complete binding set, so it waits until the stored\n // bindings and every catalog have loaded: an early click must never detach\n // what it has not seen yet.\n const [draft, setDraft] = useState<Draft>(() => draftFrom(null));\n // The selected template is read on its own: the catalog list is paged and\n // may not include it.\n const selectedTemplate = usePromptTemplate(draft.promptTemplateId || undefined);\n // A detail response for a template that is no longer selected is ignored.\n const boundTemplate =\n selectedTemplate.data && selectedTemplate.data.id === draft.promptTemplateId\n ? selectedTemplate.data\n : null;\n // A detail response for an earlier selection that landed last is replaced\n // by a fresh read of the selected template.\n const staleTemplate =\n Boolean(draft.promptTemplateId) &&\n !selectedTemplate.loading &&\n Boolean(selectedTemplate.data) &&\n selectedTemplate.data?.id !== draft.promptTemplateId;\n const { refetch: refetchTemplate } = selectedTemplate;\n useEffect(() => {\n if (staleTemplate) void refetchTemplate();\n }, [staleTemplate, refetchTemplate]);\n const ready =\n Boolean(bindings.data) &&\n (!draft.promptTemplateId || (boundTemplate !== null && !selectedTemplate.loading)) &&\n !bindings.loading &&\n !bindings.error &&\n !templates.loading &&\n !templates.error &&\n !skills.loading &&\n !skills.error &&\n !profiles.loading &&\n !profiles.error;\n\n useEffect(() => {\n setDraft(draftFrom(bindings.data));\n }, [bindings.data]);\n\n const declared = useMemo(\n () => (boundTemplate ? promptTemplateVariables(boundTemplate) : []),\n [boundTemplate]\n );\n // The details shown are those of the profile Save will attach.\n const boundProfile = bindings.data?.retrievalProfile;\n const selectedProfile = draft.retrievalProfileId\n ? (profiles.data.find((row) => row.id === draft.retrievalProfileId) ??\n (boundProfile?.retrievalProfileId === draft.retrievalProfileId ? boundProfile : null))\n : null;\n const skillsById = useMemo(() => new Map(skills.data.map((row) => [row.id, row])), [skills.data]);\n const availableSkills = skills.data.filter(\n (row) => isLive(row.status) && !draft.skillIds.includes(row.id)\n );\n\n const moveSkill = (index: number, delta: number) => {\n const next = [...draft.skillIds];\n const target = index + delta;\n if (target < 0 || target >= next.length) return;\n [next[index], next[target]] = [next[target], next[index]];\n setDraft({ ...draft, skillIds: next });\n };\n\n const handleSave = async () => {\n const boundTemplateId = bindings.data?.promptTemplate?.promptTemplateId ?? '';\n const templateChanged = draft.promptTemplateId !== boundTemplateId;\n // Unedited stored values are sent back exactly as stored (typed); an\n // edited field is converted for its declared type; empty fields are left\n // out so defaults apply.\n const stored = templateChanged ? {} : storedVariables(bindings.data);\n const promptVariables: Record<string, unknown> = {};\n for (const variable of declared) {\n const text = draft.variables[variable.name] ?? '';\n if (!draft.edited.includes(variable.name) && variable.name in stored) {\n promptVariables[variable.name] = stored[variable.name];\n } else if (text !== '') {\n promptVariables[variable.name] = typedVariableValue(variable.type, text);\n }\n }\n const sendVariables =\n Boolean(draft.promptTemplateId) && (templateChanged || draft.edited.length > 0);\n setBusy(true);\n try {\n await save({\n promptTemplateId: draft.promptTemplateId || null,\n // Variables are only sent when the template or a value changed, so a\n // skill or profile edit never rewrites the stored values.\n ...(sendVariables ? { promptVariables } : {}),\n skillIds: draft.skillIds,\n retrievalProfileId: draft.retrievalProfileId || null,\n });\n toast.success('Agent bindings saved');\n await bindings.refetch();\n } catch (error) {\n toast.error(graphqlErrorMessage(error, 'Failed to save the agent bindings'));\n } finally {\n setBusy(false);\n }\n };\n\n return (\n <Card>\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <Layers size={18} />\n Prompt template, skills &amp; retrieval\n </CardTitle>\n <CardDescription>\n Every run of this agent starts from the bound prompt template, adds the agent&apos;s own\n system prompt and the skills below, and searches its knowledge with the retrieval profile.\n </CardDescription>\n </CardHeader>\n <CardContent className=\"space-y-6\">\n {bindings.error && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {graphqlErrorMessage(bindings.error, 'Failed to load the agent bindings')}\n </p>\n )}\n\n <section className=\"space-y-3\">\n <label className=\"grid gap-2 text-sm font-medium\">\n Prompt template\n <select\n aria-label=\"Prompt template\"\n className={SELECT_CLASS}\n value={draft.promptTemplateId}\n disabled={!editable}\n onChange={(event) =>\n setDraft({\n ...draft,\n promptTemplateId: event.target.value,\n variables: {},\n edited: [],\n })\n }\n >\n <option value=\"\">No prompt template</option>\n {boundTemplate && !templates.data.some((row) => row.id === boundTemplate.id) && (\n <option value={boundTemplate.id}>\n {boundTemplate.name} · v{boundTemplate.version}\n </option>\n )}\n {templates.data\n .filter((row) => isLive(row.status) || row.id === draft.promptTemplateId)\n .map((row) => (\n <option key={row.id} value={row.id}>\n {row.name} · v{row.version}\n </option>\n ))}\n </select>\n </label>\n {declared.length > 0 && (\n <div className=\"grid gap-3 sm:grid-cols-2\">\n {declared.map((variable) => (\n <label key={variable.name} className=\"grid gap-1 text-sm\">\n <span>\n {`{{${variable.name}}}`}\n {variable.required && <span className=\"ml-1 text-status-error-text\">*</span>}\n </span>\n <Input\n aria-label={`Variable ${variable.name}`}\n disabled={!editable}\n placeholder={\n typeof variable.defaultValue === 'string'\n ? `Default: ${variable.defaultValue}`\n : (variable.description ?? variable.type)\n }\n value={draft.variables[variable.name] ?? ''}\n onChange={(event) =>\n setDraft({\n ...draft,\n variables: { ...draft.variables, [variable.name]: event.target.value },\n edited: draft.edited.includes(variable.name)\n ? draft.edited\n : [...draft.edited, variable.name],\n })\n }\n />\n </label>\n ))}\n </div>\n )}\n </section>\n\n <section className=\"space-y-3\">\n <p className=\"text-sm font-medium\">Skills</p>\n {draft.skillIds.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">No skills attached.</p>\n ) : (\n <ol className=\"space-y-2\">\n {draft.skillIds.map((skillId, index) => {\n const skill = skillsById.get(skillId);\n return (\n <li\n key={skillId}\n className=\"flex items-center gap-3 rounded-lg border border-border-subtle p-3\"\n >\n <Badge variant=\"outline\">#{index + 1}</Badge>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium\">\n {skill?.name ??\n bindings.data?.skills.find((bound) => bound.skillId === skillId)?.name ??\n skillId}\n </p>\n {skill?.description && (\n <p className=\"truncate text-xs text-text-secondary\">{skill.description}</p>\n )}\n </div>\n {editable && (\n <div className=\"flex items-center gap-1\">\n <Button\n size=\"sm\"\n variant=\"ghost\"\n aria-label=\"Move skill up\"\n onClick={() => moveSkill(index, -1)}\n >\n <ArrowUp size={14} />\n </Button>\n <Button\n size=\"sm\"\n variant=\"ghost\"\n aria-label=\"Move skill down\"\n onClick={() => moveSkill(index, 1)}\n >\n <ArrowDown size={14} />\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() =>\n setDraft({\n ...draft,\n skillIds: draft.skillIds.filter((id) => id !== skillId),\n })\n }\n >\n Remove\n </Button>\n </div>\n )}\n </li>\n );\n })}\n </ol>\n )}\n {editable && availableSkills.length > 0 && (\n <select\n aria-label=\"Add skill\"\n className={SELECT_CLASS}\n value=\"\"\n onChange={(event) =>\n event.target.value &&\n setDraft({ ...draft, skillIds: [...draft.skillIds, event.target.value] })\n }\n >\n <option value=\"\">Add a skill…</option>\n {availableSkills.map((row) => (\n <option key={row.id} value={row.id}>\n {row.name}\n </option>\n ))}\n </select>\n )}\n </section>\n\n <section className=\"space-y-2\">\n <label className=\"grid gap-2 text-sm font-medium\">\n Retrieval profile\n <select\n aria-label=\"Retrieval profile\"\n className={SELECT_CLASS}\n value={draft.retrievalProfileId}\n disabled={!editable}\n onChange={(event) => setDraft({ ...draft, retrievalProfileId: event.target.value })}\n >\n <option value=\"\">Default retrieval (vector, top 5)</option>\n {bindings.data?.retrievalProfile &&\n !profiles.data.some(\n (row) => row.id === bindings.data?.retrievalProfile?.retrievalProfileId\n ) && (\n <option value={bindings.data.retrievalProfile.retrievalProfileId}>\n {bindings.data.retrievalProfile.name} ·{' '}\n {bindings.data.retrievalProfile.strategyMode} · top{' '}\n {bindings.data.retrievalProfile.topK}\n </option>\n )}\n {profiles.data\n .filter((row) => isLive(row.status) || row.id === draft.retrievalProfileId)\n .map((row) => (\n <option key={row.id} value={row.id}>\n {row.name} · {row.strategyMode} · top {row.topK}\n </option>\n ))}\n </select>\n </label>\n {selectedProfile && (\n <p className=\"text-xs text-text-secondary\">\n {selectedProfile.strategyMode} search, top {selectedProfile.topK}\n {selectedProfile.minRelevanceScore != null &&\n `, minimum relevance ${selectedProfile.minRelevanceScore}`}\n {selectedProfile.noAnswerIfBelowThreshold &&\n ', abstains when nothing clears the threshold'}\n .\n </p>\n )}\n </section>\n\n {canUpdate && (\n <div className=\"flex justify-end\">\n <Button onClick={() => void handleSave()} isLoading={busy} disabled={!ready || busy}>\n Save bindings\n </Button>\n </div>\n )}\n\n {bindings.data && (\n <section className=\"space-y-2\">\n <p className=\"text-sm font-medium\">Effective system prompt</p>\n <pre\n data-testid=\"effective-system-prompt\"\n className=\"max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-bg-sunken p-4 font-mono text-sm\"\n >\n {bindings.data.effectiveSystemPrompt}\n </pre>\n </section>\n )}\n </CardContent>\n </Card>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,IAAMA,IACJ;AAYF,SAASC,EAAgB,GAA+D;CACtF,IAAMC,IAASC,GAAU,gBAAgB;CACzC,OAAOD,KAAU,OAAOA,KAAW,YAAY,CAAC,MAAM,QAAQA,CAAM,IAC/DA,IACD,CAAC;AACP;AAEA,SAASE,EAAU,GAA6C;CAC9D,IAAMC,IAAoC,CAAC;CAC3C,KAAK,IAAM,CAACC,GAAKC,MAAU,OAAO,QAAQN,EAAgBE,CAAQ,CAAC,GACjE,EAAUG,KAAO,OAAOC,KAAU,WAAWA,IAAQ,KAAK,UAAUA,CAAK;CAE3E,OAAO;EACL,kBAAkBJ,GAAU,gBAAgB,oBAAoB;EAChE;EACA,QAAQ,CAAC;EACT,UAAU,CAAC,GAAIA,GAAU,UAAU,CAAC,CAAE,CAAC,CACpC,MAAM,GAAG,MAAMK,EAAE,WAAWC,EAAE,QAAQ,CAAC,CACvC,KAAK,MAAUC,EAAM,OAAO;EAC/B,oBAAoBP,GAAU,kBAAkB,sBAAsB;CACxE;AACF;AAEA,IAAMQ,KAAU,MAAmBC,MAAW,YAEjCC,KAA+C,EAAE,iBAAc;CAC1E,IAAMC,IAAMC,EAAe,GAGrB,CAACC,GAAMC,KAAWC,EAAS,EAAK,GAChCC,IAAYL,EAAIM,EAAqB,YAAY,GACjDjB,IAAWkB,EAAiBC,CAAO,GAGnCC,IAAWJ,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,KAAD;KAAG,WAAU;KAAsB,UAAA;IAA0B,CAAA,GAC7D,kBAAC,OAAD;KACE,eAAY;KACZ,WAAU;KAET,UAAAA,EAAS,KAAK;IACZ,CAAA,CACE;;EAEA;CACT,CAAA,CAAA,EAAA,CAAA;AAEV"}
@@ -24,6 +24,8 @@ export { useSkills, useSkill, useCreateSkill, useUpdateSkill, useDeleteSkill, sk
24
24
  export type { SkillRecord } from './useSkills';
25
25
  export { usePromptTemplates, usePromptTemplate, useCreatePromptTemplate, useUpdatePromptTemplate, useDeletePromptTemplate, useRenderPromptTemplate, promptTemplateVariables, promptTemplateKeys, } from './usePromptTemplates';
26
26
  export type { PromptTemplateRecord } from './usePromptTemplates';
27
+ export { useAgentBindings, useSetAgentBindings, useTestPromptTemplate, useSavePromptTemplateVersion, usePromptTemplateVersions, } from './useAgentBindings';
28
+ export type { AgentBindingsRecord, PromptTemplateTestRecord, PromptTemplateVersionRecord, } from './useAgentBindings';
27
29
  export { useExecutions, useExecution, useCreateExecution, useUpdateExecutionStatus, useExecutionMetrics, summariseExecutions, executionKeys, } from './useExecutions';
28
30
  export type { ExecutionRecord, ExecutionRollup } from './useExecutions';
29
31
  export { useBuckets, useBucketTree, useBucket, useChildBuckets, useCreateBucket, useUpdateBucket, useDeleteBucket, buildBucketTree, bucketKeys, } from './useBuckets';
@@ -10,11 +10,12 @@ import { useCreatePolicy as N, useDeletePolicy as P, usePolicies as F, usePolicy
10
10
  import { useApplyRetention as R, useRetentionStatus as z } from "./useRetention.js";
11
11
  import { useCreateSkill as B, useDeleteSkill as V, useSkill as H, useSkills as U, useUpdateSkill as W } from "./useSkills.js";
12
12
  import { promptTemplateVariables as G, useCreatePromptTemplate as K, useDeletePromptTemplate as q, usePromptTemplate as J, usePromptTemplates as Y, useRenderPromptTemplate as X, useUpdatePromptTemplate as Z } from "./usePromptTemplates.js";
13
- import { summariseExecutions as Q, useExecutions as $ } from "./useExecutions.js";
14
- import { useBucket as ee, useBucketTree as te, useBuckets as ne, useChildBuckets as re, useCreateBucket as ie, useDeleteBucket as ae, useUpdateBucket as oe } from "./useBuckets.js";
15
- import { storePackageDescription as se, storePackageName as ce, useInstallPackage as le, useInstalledPackages as ue, usePinPackageVersion as de, useStorePackage as fe, useStorePackages as pe, useUninstallPackage as me, useUpdateInstalledPackage as he } from "./useStore.js";
13
+ import { useAgentBindings as Q, usePromptTemplateVersions as $, useSavePromptTemplateVersion as ee, useSetAgentBindings as te, useTestPromptTemplate as ne } from "./useAgentBindings.js";
14
+ import { summariseExecutions as re, useExecutions as ie } from "./useExecutions.js";
15
+ import { useBucket as ae, useBucketTree as oe, useBuckets as se, useChildBuckets as ce, useCreateBucket as le, useDeleteBucket as ue, useUpdateBucket as de } from "./useBuckets.js";
16
+ import { storePackageDescription as fe, storePackageName as pe, useInstallPackage as me, useInstalledPackages as he, usePinPackageVersion as ge, useStorePackage as _e, useStorePackages as ve, useUninstallPackage as ye, useUpdateInstalledPackage as be } from "./useStore.js";
16
17
  import "./useLLMProviders.js";
17
- import { useGlobalChannels as ge, useInitiateSlackConnect as _e, useLinkIntegrationConnection as ve, useMyUserPlatformConnection as ye, useRevokeSlackConnection as be, useToggleSlackNotifications as xe } from "./useUserPlatformConnection.js";
18
- import { useConfigureSupervisor as Se, useRunSupervisorNow as Ce, useSupervisorConfig as we, useSupervisorRuns as Te } from "./useAiOperations.js";
19
- import { useAcceptHandoff as Ee, useHandoffConfig as De, useHandoffQueue as Oe, useRejectHandoff as ke, useReleaseHandoff as Ae, useResolveHandoff as je, useUpsertHandoffConfig as Me } from "./useHandoffs.js";
20
- export { D as PLATFORM_CREDENTIALS, m as a2aAgentSkillCount, O as connectorPlatform, r as isMCPServerHealthy, i as mcpServerDescription, a as mcpServerEndpoint, G as promptTemplateVariables, g as routeMetadataString, se as storePackageDescription, ce as storePackageName, Q as summariseExecutions, h as useA2AAgents, Ee as useAcceptHandoff, k as useActiveOrganizationId, t as useAgents, R as useApplyRetention, _ as useBotChannelRoutes, e as useBots, ee as useBucket, te as useBucketTree, ne as useBuckets, v as useChannelConnector, y as useChannelConnectors, b as useChannelRoutes, re as useChildBuckets, Se as useConfigureSupervisor, ie as useCreateBucket, x as useCreateChannelConnector, S as useCreateChannelRoute, o as useCreateMCPServer, N as useCreatePolicy, K as useCreatePromptTemplate, B as useCreateSkill, ae as useDeleteBucket, C as useDeleteChannelConnector, w as useDeleteChannelRoute, s as useDeleteMCPServer, P as useDeletePolicy, q as useDeletePromptTemplate, V as useDeleteSkill, $ as useExecutions, T as useFindChannelConnector, ge as useGlobalChannels, De as useHandoffConfig, Oe as useHandoffQueue, A as useInboundChannel, _e as useInitiateSlackConnect, le as useInstallPackage, ue as useInstalledPackages, ve as useLinkIntegrationConnection, c as useMCPResources, l as useMCPServer, u as useMCPTools, ye as useMyUserPlatformConnection, de as usePinPackageVersion, F as usePolicies, I as usePolicy, J as usePromptTemplate, Y as usePromptTemplates, j as useProvisionChannel, ke as useRejectHandoff, Ae as useReleaseHandoff, X as useRenderPromptTemplate, je as useResolveHandoff, z as useRetentionStatus, n as useRetrievalProfiles, be as useRevokeSlackConnection, Ce as useRunSupervisorNow, H as useSkill, U as useSkills, fe as useStorePackage, pe as useStorePackages, we as useSupervisorConfig, Te as useSupervisorRuns, d as useTestMCPConnection, xe as useToggleSlackNotifications, me as useUninstallPackage, oe as useUpdateBucket, E as useUpdateChannelConnector, he as useUpdateInstalledPackage, f as useUpdateMCPServer, p as useUpdateMCPTool, L as useUpdatePolicy, Z as useUpdatePromptTemplate, W as useUpdateSkill, Me as useUpsertHandoffConfig, M as validateCredentials };
18
+ import { useGlobalChannels as xe, useInitiateSlackConnect as Se, useLinkIntegrationConnection as Ce, useMyUserPlatformConnection as we, useRevokeSlackConnection as Te, useToggleSlackNotifications as Ee } from "./useUserPlatformConnection.js";
19
+ import { useConfigureSupervisor as De, useRunSupervisorNow as Oe, useSupervisorConfig as ke, useSupervisorRuns as Ae } from "./useAiOperations.js";
20
+ import { useAcceptHandoff as je, useHandoffConfig as Me, useHandoffQueue as Ne, useRejectHandoff as Pe, useReleaseHandoff as Fe, useResolveHandoff as Ie, useUpsertHandoffConfig as Le } from "./useHandoffs.js";
21
+ export { D as PLATFORM_CREDENTIALS, m as a2aAgentSkillCount, O as connectorPlatform, r as isMCPServerHealthy, i as mcpServerDescription, a as mcpServerEndpoint, G as promptTemplateVariables, g as routeMetadataString, fe as storePackageDescription, pe as storePackageName, re as summariseExecutions, h as useA2AAgents, je as useAcceptHandoff, k as useActiveOrganizationId, Q as useAgentBindings, t as useAgents, R as useApplyRetention, _ as useBotChannelRoutes, e as useBots, ae as useBucket, oe as useBucketTree, se as useBuckets, v as useChannelConnector, y as useChannelConnectors, b as useChannelRoutes, ce as useChildBuckets, De as useConfigureSupervisor, le as useCreateBucket, x as useCreateChannelConnector, S as useCreateChannelRoute, o as useCreateMCPServer, N as useCreatePolicy, K as useCreatePromptTemplate, B as useCreateSkill, ue as useDeleteBucket, C as useDeleteChannelConnector, w as useDeleteChannelRoute, s as useDeleteMCPServer, P as useDeletePolicy, q as useDeletePromptTemplate, V as useDeleteSkill, ie as useExecutions, T as useFindChannelConnector, xe as useGlobalChannels, Me as useHandoffConfig, Ne as useHandoffQueue, A as useInboundChannel, Se as useInitiateSlackConnect, me as useInstallPackage, he as useInstalledPackages, Ce as useLinkIntegrationConnection, c as useMCPResources, l as useMCPServer, u as useMCPTools, we as useMyUserPlatformConnection, ge as usePinPackageVersion, F as usePolicies, I as usePolicy, J as usePromptTemplate, $ as usePromptTemplateVersions, Y as usePromptTemplates, j as useProvisionChannel, Pe as useRejectHandoff, Fe as useReleaseHandoff, X as useRenderPromptTemplate, Ie as useResolveHandoff, z as useRetentionStatus, n as useRetrievalProfiles, Te as useRevokeSlackConnection, Oe as useRunSupervisorNow, ee as useSavePromptTemplateVersion, te as useSetAgentBindings, H as useSkill, U as useSkills, _e as useStorePackage, ve as useStorePackages, ke as useSupervisorConfig, Ae as useSupervisorRuns, d as useTestMCPConnection, ne as useTestPromptTemplate, Ee as useToggleSlackNotifications, ye as useUninstallPackage, de as useUpdateBucket, E as useUpdateChannelConnector, be as useUpdateInstalledPackage, f as useUpdateMCPServer, p as useUpdateMCPTool, L as useUpdatePolicy, Z as useUpdatePromptTemplate, W as useUpdateSkill, Le as useUpsertHandoffConfig, M as validateCredentials };
@@ -0,0 +1,58 @@
1
+ import { AgentBindingsFieldsFragment, GetPromptTemplateVersionsQuery, TestPromptTemplateMutation } from '../../generated/wspace-operations';
2
+ import { SavePromptTemplateVersionInput, SetAgentBindingsInput, TestPromptTemplateInput } from '../../generated/wspace-types';
3
+ import { QueryResult } from './internal/workspaceGateway';
4
+ export type AgentBindingsRecord = AgentBindingsFieldsFragment;
5
+ export type PromptTemplateTestRecord = TestPromptTemplateMutation['testPromptTemplate'];
6
+ export type PromptTemplateVersionRecord = NonNullable<GetPromptTemplateVersionsQuery['getPromptTemplate']>['versionHistory'][number];
7
+ export declare function useAgentBindings(agentId: string | undefined): QueryResult<AgentBindingsRecord | null>;
8
+ export declare function useSetAgentBindings(agentId: string): {
9
+ save: (input: SetAgentBindingsInput) => Promise<AgentBindingsFieldsFragment>;
10
+ loading: boolean;
11
+ error: Error | undefined;
12
+ };
13
+ export interface TestPromptTemplateVariables {
14
+ templateId: string;
15
+ input: TestPromptTemplateInput;
16
+ }
17
+ export declare function useTestPromptTemplate(): {
18
+ run: (input: TestPromptTemplateVariables) => Promise<{
19
+ renderedPrompt: string;
20
+ output: string;
21
+ model: string;
22
+ tokensUsed: number;
23
+ inputTokens: number | null;
24
+ outputTokens: number | null;
25
+ latencyMs: number;
26
+ }>;
27
+ loading: boolean;
28
+ };
29
+ export interface SavePromptTemplateVersionVariables {
30
+ templateId: string;
31
+ input: SavePromptTemplateVersionInput;
32
+ }
33
+ export declare function useSavePromptTemplateVersion(): {
34
+ save: (input: SavePromptTemplateVersionVariables) => Promise<{
35
+ id: string;
36
+ version: string;
37
+ revision: number;
38
+ templateText: string;
39
+ variables: Record<string, unknown>;
40
+ updatedAt: string;
41
+ versionHistory: Array<{
42
+ version: string;
43
+ revision: number;
44
+ templateText: string;
45
+ variables: Record<string, unknown>;
46
+ changelog: string | null;
47
+ savedAt: string;
48
+ savedById: string;
49
+ }>;
50
+ }>;
51
+ loading: boolean;
52
+ };
53
+ /**
54
+ * Earlier versions of one template. A response for a template that is no
55
+ * longer the requested one (the selection changed mid-flight) is discarded,
56
+ * so one prompt's history can never be shown, loaded or saved into another.
57
+ */
58
+ export declare function usePromptTemplateVersions(templateId: string | undefined): QueryResult<PromptTemplateVersionRecord[]>;
@@ -0,0 +1,87 @@
1
+ import { GetAgentBindingsDocument as e, GetPromptTemplateVersionsDocument as t, SavePromptTemplateVersionDocument as n, SetAgentBindingsDocument as r, TestPromptTemplateDocument as i } from "../../generated/wspace-operations.js";
2
+ import { useWorkspaceId as a, useWorkspaceMutation as o, useWorkspaceQuery as s } from "./internal/workspaceGateway.js";
3
+ import { useEffect as c, useMemo as l } from "react";
4
+ // src/botlit/hooks/useAgentBindings.ts
5
+ function u(t) {
6
+ let n = a(), r = l(() => ({ agentId: t ?? "" }), [t]);
7
+ return s({
8
+ document: e,
9
+ variables: r,
10
+ select: (e) => e?.getAgentBindings ?? null,
11
+ fallback: null,
12
+ enabled: !!(n && t),
13
+ errorMessage: "Failed to load the agent bindings"
14
+ });
15
+ }
16
+ function d(e) {
17
+ let [t, n] = o({
18
+ document: r,
19
+ variables: (t) => ({
20
+ agentId: e,
21
+ input: t
22
+ }),
23
+ select: (e) => e?.setAgentBindings,
24
+ errorMessage: "Failed to save the agent bindings"
25
+ });
26
+ return {
27
+ save: t,
28
+ loading: n.loading,
29
+ error: n.error
30
+ };
31
+ }
32
+ function f() {
33
+ let [e, t] = o({
34
+ document: i,
35
+ variables: ({ templateId: e, input: t }) => ({
36
+ id: e,
37
+ input: t
38
+ }),
39
+ select: (e) => e?.testPromptTemplate,
40
+ errorMessage: "Failed to run the prompt against the model"
41
+ });
42
+ return {
43
+ run: e,
44
+ loading: t.loading
45
+ };
46
+ }
47
+ function p() {
48
+ let [e, t] = o({
49
+ document: n,
50
+ variables: ({ templateId: e, input: t }) => ({
51
+ id: e,
52
+ input: t
53
+ }),
54
+ select: (e) => e?.savePromptTemplateVersion,
55
+ errorMessage: "Failed to save the prompt version"
56
+ });
57
+ return {
58
+ save: e,
59
+ loading: t.loading
60
+ };
61
+ }
62
+ var m = [], h = {
63
+ templateId: null,
64
+ versions: m
65
+ };
66
+ function g(e) {
67
+ let n = l(() => ({ id: e ?? "" }), [e]), r = s({
68
+ document: t,
69
+ variables: n,
70
+ select: (e) => e?.getPromptTemplate ? {
71
+ templateId: e.getPromptTemplate.id,
72
+ versions: e.getPromptTemplate.versionHistory
73
+ } : h,
74
+ fallback: h,
75
+ enabled: !!e,
76
+ errorMessage: "Failed to load the prompt versions"
77
+ }), i = !!e && !r.loading && r.data.templateId !== null && r.data.templateId !== e, { refetch: a } = r;
78
+ return c(() => {
79
+ i && a();
80
+ }, [i, a]), {
81
+ ...r,
82
+ data: r.data.templateId === e ? r.data.versions : m
83
+ };
84
+ }
85
+ export { u as useAgentBindings, g as usePromptTemplateVersions, p as useSavePromptTemplateVersion, d as useSetAgentBindings, f as useTestPromptTemplate };
86
+
87
+ //# sourceMappingURL=useAgentBindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAgentBindings.js","names":["useAgentBindings","workspaceId","useWorkspaceId","variables","useMemo","agentId","useWorkspaceQuery","GetAgentBindingsDocument","data","useSetAgentBindings","save","state","useWorkspaceMutation","SetAgentBindingsDocument","useTestPromptTemplate","run","TestPromptTemplateDocument","templateId","useSavePromptTemplateVersion","SavePromptTemplateVersionDocument","NO_VERSIONS","NO_TEMPLATE_VERSIONS","usePromptTemplateVersions","result","GetPromptTemplateVersionsDocument","stale","useEffect","refetch"],"sources":["../../../src/botlit/hooks/useAgentBindings.ts"],"sourcesContent":["/**\n * Agent Builder bindings + Prompt Studio hooks (BOFF-15360)\n * @module botlit/hooks\n *\n * Backed by `getAgentBindings` / `setAgentBindings` (the prompt template,\n * skills and retrieval profile attached to an agent) and the Prompt Studio\n * mutations `testPromptTemplate` / `savePromptTemplateVersion` on\n * wspace-botmanor-svc.\n */\n\nimport { useEffect, useMemo } from 'react';\nimport {\n GetAgentBindingsDocument,\n GetPromptTemplateVersionsDocument,\n SavePromptTemplateVersionDocument,\n SetAgentBindingsDocument,\n TestPromptTemplateDocument,\n type AgentBindingsFieldsFragment,\n type GetAgentBindingsQuery,\n type GetPromptTemplateVersionsQuery,\n type SavePromptTemplateVersionMutation,\n type SetAgentBindingsMutation,\n type TestPromptTemplateMutation,\n} from '../../generated/wspace-operations';\nimport type {\n SavePromptTemplateVersionInput,\n SetAgentBindingsInput,\n TestPromptTemplateInput,\n} from '../../generated/wspace-types';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nexport type AgentBindingsRecord = AgentBindingsFieldsFragment;\nexport type PromptTemplateTestRecord = TestPromptTemplateMutation['testPromptTemplate'];\nexport type PromptTemplateVersionRecord = NonNullable<\n GetPromptTemplateVersionsQuery['getPromptTemplate']\n>['versionHistory'][number];\n\nexport function useAgentBindings(\n agentId: string | undefined\n): QueryResult<AgentBindingsRecord | null> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(() => ({ agentId: agentId ?? '' }), [agentId]);\n return useWorkspaceQuery<GetAgentBindingsQuery, AgentBindingsRecord | null>({\n document: GetAgentBindingsDocument,\n variables,\n select: (data) => data?.getAgentBindings ?? null,\n fallback: null,\n enabled: Boolean(workspaceId && agentId),\n errorMessage: 'Failed to load the agent bindings',\n });\n}\n\nexport function useSetAgentBindings(agentId: string) {\n const [save, state] = useWorkspaceMutation<\n SetAgentBindingsMutation,\n SetAgentBindingsInput,\n AgentBindingsRecord\n >({\n document: SetAgentBindingsDocument,\n variables: (input) => ({ agentId, input }),\n select: (data) => data?.setAgentBindings,\n errorMessage: 'Failed to save the agent bindings',\n });\n return { save, loading: state.loading, error: state.error };\n}\n\nexport interface TestPromptTemplateVariables {\n templateId: string;\n input: TestPromptTemplateInput;\n}\n\nexport function useTestPromptTemplate() {\n const [run, state] = useWorkspaceMutation<\n TestPromptTemplateMutation,\n TestPromptTemplateVariables,\n PromptTemplateTestRecord\n >({\n document: TestPromptTemplateDocument,\n variables: ({ templateId, input }) => ({ id: templateId, input }),\n select: (data) => data?.testPromptTemplate,\n errorMessage: 'Failed to run the prompt against the model',\n });\n return { run, loading: state.loading };\n}\n\nexport interface SavePromptTemplateVersionVariables {\n templateId: string;\n input: SavePromptTemplateVersionInput;\n}\n\nexport function useSavePromptTemplateVersion() {\n const [save, state] = useWorkspaceMutation<\n SavePromptTemplateVersionMutation,\n SavePromptTemplateVersionVariables,\n SavePromptTemplateVersionMutation['savePromptTemplateVersion']\n >({\n document: SavePromptTemplateVersionDocument,\n variables: ({ templateId, input }) => ({ id: templateId, input }),\n select: (data) => data?.savePromptTemplateVersion,\n errorMessage: 'Failed to save the prompt version',\n });\n return { save, loading: state.loading };\n}\n\nconst NO_VERSIONS: PromptTemplateVersionRecord[] = [];\n\ninterface PromptTemplateVersions {\n templateId: string | null;\n versions: PromptTemplateVersionRecord[];\n}\n\nconst NO_TEMPLATE_VERSIONS: PromptTemplateVersions = { templateId: null, versions: NO_VERSIONS };\n\n/**\n * Earlier versions of one template. A response for a template that is no\n * longer the requested one (the selection changed mid-flight) is discarded,\n * so one prompt's history can never be shown, loaded or saved into another.\n */\nexport function usePromptTemplateVersions(\n templateId: string | undefined\n): QueryResult<PromptTemplateVersionRecord[]> {\n const variables = useMemo(() => ({ id: templateId ?? '' }), [templateId]);\n const result = useWorkspaceQuery<GetPromptTemplateVersionsQuery, PromptTemplateVersions>({\n document: GetPromptTemplateVersionsDocument,\n variables,\n select: (data) =>\n data?.getPromptTemplate\n ? { templateId: data.getPromptTemplate.id, versions: data.getPromptTemplate.versionHistory }\n : NO_TEMPLATE_VERSIONS,\n fallback: NO_TEMPLATE_VERSIONS,\n enabled: Boolean(templateId),\n errorMessage: 'Failed to load the prompt versions',\n });\n // A stale response that landed last is replaced by a fresh read of the\n // selected template's history.\n const stale =\n Boolean(templateId) &&\n !result.loading &&\n result.data.templateId !== null &&\n result.data.templateId !== templateId;\n const { refetch } = result;\n useEffect(() => {\n if (stale) void refetch();\n }, [stale, refetch]);\n return {\n ...result,\n data: result.data.templateId === templateId ? result.data.versions : NO_VERSIONS,\n };\n}\n"],"mappings":";;;;AA0CA,SAAgBA,EACd,GACyC;CACzC,IAAMC,IAAcC,EAAe,GAC7BC,IAAYC,SAAe,EAAE,SAASC,KAAW,GAAG,IAAI,CAACA,CAAO,CAAC;CACvE,OAAOC,EAAqE;EAC1E,UAAUC;EACV;EACA,SAAS,MAASC,GAAM,oBAAoB;EAC5C,UAAU;EACV,SAAS,GAAQP,KAAeI;EAChC,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBI,EAAoB,GAAiB;CACnD,IAAM,CAACC,GAAMC,KAASC,EAIpB;EACA,UAAUC;EACV,YAAY,OAAW;GAAE;GAAS;EAAM;EACxC,SAAS,MAASL,GAAM;EACxB,cAAc;CAChB,CAAC;CACD,OAAO;EAAE;EAAM,SAASG,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC5D;AAOA,SAAgBG,IAAwB;CACtC,IAAM,CAACC,GAAKJ,KAASC,EAInB;EACA,UAAUI;EACV,YAAY,EAAE,eAAY,gBAAa;GAAE,IAAIC;GAAY;EAAM;EAC/D,SAAS,MAAST,GAAM;EACxB,cAAc;CAChB,CAAC;CACD,OAAO;EAAE;EAAK,SAASG,EAAM;CAAQ;AACvC;AAOA,SAAgBO,IAA+B;CAC7C,IAAM,CAACR,GAAMC,KAASC,EAIpB;EACA,UAAUO;EACV,YAAY,EAAE,eAAY,gBAAa;GAAE,IAAIF;GAAY;EAAM;EAC/D,SAAS,MAAST,GAAM;EACxB,cAAc;CAChB,CAAC;CACD,OAAO;EAAE;EAAM,SAASG,EAAM;CAAQ;AACxC;AA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