@burdenoff/microfe-botmanor 2026.1120.20 → 2026.1120.22

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.
Files changed (50) hide show
  1. package/dist/botlit/components/A2ACardVerificationCard.d.ts +8 -0
  2. package/dist/botlit/components/A2ACardVerificationCard.js +123 -0
  3. package/dist/botlit/components/A2ACardVerificationCard.js.map +1 -0
  4. package/dist/botlit/components/A2ARunCollaborationPanel.d.ts +4 -0
  5. package/dist/botlit/components/A2ARunCollaborationPanel.js +149 -0
  6. package/dist/botlit/components/A2ARunCollaborationPanel.js.map +1 -0
  7. package/dist/botlit/components/A2AVerificationBadge.d.ts +4 -0
  8. package/dist/botlit/components/A2AVerificationBadge.js +37 -0
  9. package/dist/botlit/components/A2AVerificationBadge.js.map +1 -0
  10. package/dist/botlit/components/AgentA2APanel.js +85 -73
  11. package/dist/botlit/components/AgentA2APanel.js.map +1 -1
  12. package/dist/botlit/hooks/index.d.ts +2 -2
  13. package/dist/botlit/hooks/index.js +9 -9
  14. package/dist/botlit/hooks/useA2A.d.ts +36 -0
  15. package/dist/botlit/hooks/useA2A.js +154 -109
  16. package/dist/botlit/hooks/useA2A.js.map +1 -1
  17. package/dist/botlit/hooks/useA2APlan.d.ts +8 -0
  18. package/dist/botlit/hooks/useA2APlan.js +24 -0
  19. package/dist/botlit/hooks/useA2APlan.js.map +1 -0
  20. package/dist/botlit/hooks/usePromptTemplates.d.ts +26 -1
  21. package/dist/botlit/hooks/usePromptTemplates.js +119 -52
  22. package/dist/botlit/hooks/usePromptTemplates.js.map +1 -1
  23. package/dist/botlit/pages/A2AAgentDetailPage.js +384 -342
  24. package/dist/botlit/pages/A2AAgentDetailPage.js.map +1 -1
  25. package/dist/botlit/pages/A2ARegistryPage.js +148 -140
  26. package/dist/botlit/pages/A2ARegistryPage.js.map +1 -1
  27. package/dist/botlit/pages/ExecutionDetailPage.js +172 -170
  28. package/dist/botlit/pages/ExecutionDetailPage.js.map +1 -1
  29. package/dist/botlit/pages/PromptTemplateDetailPage.d.ts +5 -0
  30. package/dist/botlit/pages/PromptTemplateDetailPage.js +837 -670
  31. package/dist/botlit/pages/PromptTemplateDetailPage.js.map +1 -1
  32. package/dist/botlit/pages/PromptTemplatesPage.js +264 -245
  33. package/dist/botlit/pages/PromptTemplatesPage.js.map +1 -1
  34. package/dist/botlit/utils/a2aRunCollaboration.d.ts +37 -0
  35. package/dist/botlit/utils/a2aRunCollaboration.js +42 -0
  36. package/dist/botlit/utils/a2aRunCollaboration.js.map +1 -0
  37. package/dist/botlit/utils/a2aVerificationStatus.d.ts +11 -0
  38. package/dist/botlit/utils/a2aVerificationStatus.js +18 -0
  39. package/dist/botlit/utils/a2aVerificationStatus.js.map +1 -0
  40. package/dist/botlit/utils/leaveGuard.js +13 -12
  41. package/dist/botlit/utils/leaveGuard.js.map +1 -1
  42. package/dist/botlit/utils/promptTemplateForm.d.ts +94 -0
  43. package/dist/botlit/utils/promptTemplateForm.js +108 -0
  44. package/dist/botlit/utils/promptTemplateForm.js.map +1 -0
  45. package/dist/generated/wspace-operations.d.ts +159 -0
  46. package/dist/generated/wspace-operations.js +186 -116
  47. package/dist/generated/wspace-operations.js.map +1 -1
  48. package/dist/generated/wspace-types.d.ts +74 -1
  49. package/dist/generated/wspace-types.js.map +1 -1
  50. package/package.json +1 -1
@@ -0,0 +1,24 @@
1
+ import { CheckA2APlanQuotaDocument as e } from "../../generated/wspace-operations.js";
2
+ import { useWorkspaceId as t, useWorkspaceQuery as n } from "./internal/workspaceGateway.js";
3
+ import { useMemo as r } from "react";
4
+ // src/botlit/hooks/useA2APlan.ts
5
+ function i(e) {
6
+ return e ? e.allowed || e.noLimit || !e.assignmentId ? "allowed" : "exhausted" : "unknown";
7
+ }
8
+ function a() {
9
+ let a = t(), o = r(() => ({ workspaceId: a ?? "" }), [a]), s = n({
10
+ document: e,
11
+ variables: o,
12
+ select: (e) => i(e?.checkWorkspaceQuota),
13
+ fallback: "unknown",
14
+ enabled: !!a,
15
+ errorMessage: "Failed to check the A2A plan allowance"
16
+ });
17
+ return {
18
+ allowance: s.error ? "unknown" : s.data,
19
+ loading: s.loading
20
+ };
21
+ }
22
+ export { i as readA2APlanAllowance, a as useA2APlanAllowance };
23
+
24
+ //# sourceMappingURL=useA2APlan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useA2APlan.js","names":["readA2APlanAllowance","check","useA2APlanAllowance","workspaceId","useWorkspaceId","variables","useMemo","result","useWorkspaceQuery","CheckA2APlanQuotaDocument","data"],"sources":["../../../src/botlit/hooks/useA2APlan.ts"],"sourcesContent":["/**\n * A2A plan allowance (BOFF-15360)\n * @module botlit/hooks\n *\n * Agent-to-agent orchestration is a plan dimension\n * (`botmanor.a2a.orchestrations.count`). The service refuses a delegation\n * only when the workspace has a quota assignment for it with nothing left;\n * a workspace without an assignment is not metered. This hook reads the same\n * check so the A2A tab can say so before agents are connected.\n */\n\nimport { useMemo } from 'react';\nimport {\n CheckA2APlanQuotaDocument,\n type CheckA2APlanQuotaQuery,\n} from '../../generated/wspace-operations';\nimport { useWorkspaceId, useWorkspaceQuery } from './internal/workspaceGateway';\n\nexport type A2APlanAllowance = 'allowed' | 'exhausted' | 'unknown';\n\n/** Reads the quota check the way the delegation service applies it. */\nexport function readA2APlanAllowance(\n check: CheckA2APlanQuotaQuery['checkWorkspaceQuota'] | null | undefined\n): A2APlanAllowance {\n if (!check) return 'unknown';\n if (check.allowed || check.noLimit || !check.assignmentId) return 'allowed';\n return 'exhausted';\n}\n\nexport function useA2APlanAllowance(): { allowance: A2APlanAllowance; loading: boolean } {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(() => ({ workspaceId: workspaceId ?? '' }), [workspaceId]);\n const result = useWorkspaceQuery<CheckA2APlanQuotaQuery, A2APlanAllowance>({\n document: CheckA2APlanQuotaDocument,\n variables,\n select: (data) => readA2APlanAllowance(data?.checkWorkspaceQuota),\n fallback: 'unknown',\n enabled: Boolean(workspaceId),\n // A failed check is not a refusal: the panel just shows no warning.\n errorMessage: 'Failed to check the A2A plan allowance',\n });\n return { allowance: result.error ? 'unknown' : result.data, loading: result.loading };\n}\n"],"mappings":";;;;AAqBA,SAAgBA,EACd,GACkB;CAGlB,OAFKC,IACDA,EAAM,WAAWA,EAAM,WAAW,CAACA,EAAM,eAAqB,YAC3D,cAFY;AAGrB;AAEA,SAAgBC,IAAyE;CACvF,IAAMC,IAAcC,EAAe,GAC7BC,IAAYC,SAAe,EAAE,aAAaH,KAAe,GAAG,IAAI,CAACA,CAAW,CAAC,GAC7EI,IAASC,EAA4D;EACzE,UAAUC;EACV;EACA,SAAS,MAAST,EAAqBU,GAAM,mBAAmB;EAChE,UAAU;EACV,SAAS,EAAQP;EAEjB,cAAc;CAChB,CAAC;CACD,OAAO;EAAE,WAAWI,EAAO,QAAQ,YAAYA,EAAO;EAAM,SAASA,EAAO;CAAQ;AACtF"}
@@ -1,6 +1,7 @@
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>;
@@ -1,10 +1,11 @@
1
- import { CreatePromptTemplateDocument as e, DeletePromptTemplateDocument as t, GetPromptTemplateDocument as n, ListPromptTemplatesDocument as r, RenderPromptTemplateDocument as i, UpdatePromptTemplateDocument as a } from "../../generated/wspace-operations.js";
2
- import { jsonRecords as o } from "../utils/unions.js";
3
- import { buildMutationInput as s, fieldsOf as c } from "./internal/mutationInput.js";
4
- import { useWorkspaceId as l, useWorkspaceMutation as u, useWorkspaceQuery as d } from "./internal/workspaceGateway.js";
5
- import { useCallback as f, useMemo as p } from "react";
1
+ import { CreatePromptTemplateDocument as e, DeletePromptTemplateDocument as t, DuplicatePromptTemplateDocument as n, GetPromptTemplateDocument as r, ListPromptTemplatesDocument as i, RenderPromptTemplateDocument as a, UpdatePromptTemplateDocument as o } from "../../generated/wspace-operations.js";
2
+ import { jsonRecords as s } from "../utils/unions.js";
3
+ import { buildMutationInput as c, fieldsOf as l } from "./internal/mutationInput.js";
4
+ import { useWorkspaceAllPagesQuery as u, useWorkspaceClient as d, useWorkspaceId as f, useWorkspaceMutation as p, useWorkspacePaginatedQuery as m, useWorkspaceQuery as h } from "./internal/workspaceGateway.js";
5
+ import { useCallback as g, useMemo as _ } from "react";
6
+ import { gql as v } from "@apollo/client";
6
7
  // src/botlit/hooks/usePromptTemplates.ts
7
- var m = 100, h = c({
8
+ var y = 100, b = 24, x = l({
8
9
  bucketId: !0,
9
10
  description: !0,
10
11
  exampleInputs: !0,
@@ -18,7 +19,7 @@ var m = 100, h = c({
18
19
  version: !0,
19
20
  visibility: !0,
20
21
  workspaceId: !0
21
- }), g = c({
22
+ }), S = l({
22
23
  bucketId: !0,
23
24
  description: !0,
24
25
  exampleInputs: !0,
@@ -31,63 +32,83 @@ var m = 100, h = c({
31
32
  variables: !0,
32
33
  version: !0,
33
34
  visibility: !0
34
- }), _ = [], v = [
35
+ }), C = [], w = [
35
36
  "string",
36
37
  "number",
37
38
  "boolean",
38
39
  "array",
39
40
  "object"
40
41
  ];
41
- function y(e) {
42
- return o(e.variables).map((e, t) => ({
42
+ function T(e) {
43
+ return s(e.variables).map((e, t) => ({
43
44
  name: typeof e.name == "string" ? e.name : `variable_${t + 1}`,
44
- type: v.find((t) => typeof e.type == "string" && t === e.type) ?? "string",
45
+ type: w.find((t) => typeof e.type == "string" && t === e.type) ?? "string",
45
46
  required: e.required === !0,
46
47
  description: typeof e.description == "string" ? e.description : void 0,
47
48
  defaultValue: e.defaultValue
48
49
  }));
49
50
  }
50
- function b(e) {
51
- return o(e.exampleInputs);
51
+ function E(e) {
52
+ return s(e.exampleInputs);
52
53
  }
53
- function x(e) {
54
- return e?.listPromptTemplates ?? _;
54
+ function D(e) {
55
+ let t = f(), { search: n, status: r, visibility: a, bucketId: o } = e ?? {}, s = e?.tags?.join(",") ?? "", c = _(() => ({ filters: {
56
+ workspaceId: t,
57
+ search: n || void 0,
58
+ status: r,
59
+ visibility: a,
60
+ bucketId: o,
61
+ tags: s ? s.split(",") : void 0
62
+ } }), [
63
+ t,
64
+ n,
65
+ r,
66
+ a,
67
+ o,
68
+ s
69
+ ]);
70
+ return u({
71
+ document: i,
72
+ variables: c,
73
+ pageSize: y,
74
+ extractRows: (e) => e?.listPromptTemplates,
75
+ select: (e) => e,
76
+ fallback: C,
77
+ enabled: !!t,
78
+ errorMessage: "Failed to load prompt templates"
79
+ });
55
80
  }
56
- function S(e) {
57
- let t = l(), { search: n, status: i, visibility: a, bucketId: o } = e ?? {}, s = e?.tags?.join(",") ?? "", c = p(() => ({
58
- filters: {
59
- workspaceId: t,
60
- search: n || void 0,
61
- status: i,
62
- visibility: a,
63
- bucketId: o,
64
- tags: s ? s.split(",") : void 0
65
- },
66
- pagination: {
67
- limit: m,
68
- offset: 0
69
- }
70
- }), [
81
+ function O(e) {
82
+ let t = f(), { search: n, status: r, visibility: a, bucketId: o } = e ?? {}, s = e?.tags?.join(",") ?? "", c = _(() => ({ filters: {
83
+ workspaceId: t,
84
+ search: n || void 0,
85
+ status: r || void 0,
86
+ visibility: a || void 0,
87
+ bucketId: o,
88
+ tags: s ? s.split(",") : void 0
89
+ } }), [
71
90
  t,
72
91
  n,
73
- i,
92
+ r,
74
93
  a,
75
94
  o,
76
95
  s
77
96
  ]);
78
- return d({
79
- document: r,
97
+ return m({
98
+ document: i,
80
99
  variables: c,
81
- select: x,
82
- fallback: _,
100
+ pageSize: b,
101
+ extractRows: (e) => e?.listPromptTemplates,
102
+ select: (e) => e,
103
+ fallback: C,
83
104
  enabled: !!t,
84
105
  errorMessage: "Failed to load prompt templates"
85
106
  });
86
107
  }
87
- function C(e) {
88
- let t = p(() => ({ id: e ?? "" }), [e]);
89
- return d({
90
- document: n,
108
+ function k(e) {
109
+ let t = _(() => ({ id: e ?? "" }), [e]);
110
+ return h({
111
+ document: r,
91
112
  variables: t,
92
113
  select: (e) => e?.getPromptTemplate ?? null,
93
114
  fallback: null,
@@ -95,11 +116,11 @@ function C(e) {
95
116
  errorMessage: "Failed to load prompt template"
96
117
  });
97
118
  }
98
- function w() {
99
- let t = l(), n = f((e) => ({ input: s({
119
+ function A() {
120
+ let t = f(), n = g((e) => ({ input: c({
100
121
  ...e,
101
122
  workspaceId: t
102
- }, h) }), [t]), [r, i] = u({
123
+ }, x) }), [t]), [r, i] = p({
103
124
  document: e,
104
125
  variables: n,
105
126
  select: (e) => e?.createPromptTemplate,
@@ -111,12 +132,12 @@ function w() {
111
132
  error: i.error
112
133
  };
113
134
  }
114
- function T() {
115
- let [e, t] = u({
116
- document: a,
135
+ function j() {
136
+ let [e, t] = p({
137
+ document: o,
117
138
  variables: ({ templateId: e, input: t }) => ({
118
139
  id: e,
119
- input: s(t, g)
140
+ input: c(t, S)
120
141
  }),
121
142
  select: (e) => e?.updatePromptTemplate,
122
143
  errorMessage: "Failed to update prompt template"
@@ -127,8 +148,8 @@ function T() {
127
148
  error: t.error
128
149
  };
129
150
  }
130
- function E() {
131
- let [e, n] = u({
151
+ function M() {
152
+ let [e, n] = p({
132
153
  document: t,
133
154
  variables: (e) => ({ id: e }),
134
155
  select: (e) => e?.deletePromptTemplate,
@@ -140,9 +161,9 @@ function E() {
140
161
  error: n.error
141
162
  };
142
163
  }
143
- function D() {
144
- let [e, t] = u({
145
- document: i,
164
+ function N() {
165
+ let [e, t] = p({
166
+ document: a,
146
167
  variables: ({ templateId: e, variables: t }) => ({
147
168
  id: e,
148
169
  variables: t
@@ -156,6 +177,52 @@ function D() {
156
177
  error: t.error
157
178
  };
158
179
  }
159
- export { b as promptTemplateExamples, y as promptTemplateVariables, w as useCreatePromptTemplate, E as useDeletePromptTemplate, C as usePromptTemplate, S as usePromptTemplates, D as useRenderPromptTemplate, T as useUpdatePromptTemplate };
180
+ function P() {
181
+ let [e, t] = p({
182
+ document: n,
183
+ variables: ({ templateId: e, name: t }) => ({
184
+ id: e,
185
+ name: t
186
+ }),
187
+ select: (e) => e?.duplicatePromptTemplate,
188
+ errorMessage: "Failed to duplicate prompt template"
189
+ });
190
+ return {
191
+ duplicate: e,
192
+ loading: t.loading,
193
+ error: t.error
194
+ };
195
+ }
196
+ var F = v`
197
+ query GetPromptTemplateUsage($id: ID!) {
198
+ getPromptTemplateUsage(id: $id) {
199
+ agents {
200
+ id
201
+ name
202
+ }
203
+ skills {
204
+ id
205
+ name
206
+ }
207
+ }
208
+ }
209
+ `;
210
+ function I() {
211
+ let e = d();
212
+ return g(async (t) => {
213
+ let n = await e.query({
214
+ query: F,
215
+ variables: { id: t },
216
+ fetchPolicy: "network-only"
217
+ }), r = n.error;
218
+ if (r != null) throw r instanceof Error ? r : /* @__PURE__ */ Error("Failed to load what uses this prompt template");
219
+ let i = n.data?.getPromptTemplateUsage;
220
+ return {
221
+ agents: i?.agents ?? [],
222
+ skills: i?.skills ?? []
223
+ };
224
+ }, [e]);
225
+ }
226
+ export { E as promptTemplateExamples, T as promptTemplateVariables, A as useCreatePromptTemplate, M as useDeletePromptTemplate, P as useDuplicatePromptTemplate, I as useLoadPromptTemplateUsage, O as usePagedPromptTemplates, k as usePromptTemplate, D as usePromptTemplates, N as useRenderPromptTemplate, j as useUpdatePromptTemplate };
160
227
 
161
228
  //# sourceMappingURL=usePromptTemplates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePromptTemplates.js","names":["LIST_LIMIT","CREATE_TEMPLATE_FIELDS","fieldsOf","UPDATE_TEMPLATE_FIELDS","NO_TEMPLATES","VARIABLE_TYPES","promptTemplateVariables","jsonRecords","template","variable","index","candidate","promptTemplateExamples","selectTemplates","data","usePromptTemplates","workspaceId","useWorkspaceId","filter","tagsKey","variables","useMemo","search","status","visibility","bucketId","useWorkspaceQuery","ListPromptTemplatesDocument","usePromptTemplate","templateId","GetPromptTemplateDocument","useCreatePromptTemplate","useCallback","buildMutationInput","input","create","state","useWorkspaceMutation","CreatePromptTemplateDocument","useUpdatePromptTemplate","update","UpdatePromptTemplateDocument","useDeletePromptTemplate","remove","DeletePromptTemplateDocument","useRenderPromptTemplate","render","RenderPromptTemplateDocument"],"sources":["../../../src/botlit/hooks/usePromptTemplates.ts"],"sourcesContent":["/**\n * Prompt Templates Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listPromptTemplates` / `getPromptTemplate` operations and\n * the create/update/delete/render mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreatePromptTemplateDocument,\n DeletePromptTemplateDocument,\n GetPromptTemplateDocument,\n ListPromptTemplatesDocument,\n RenderPromptTemplateDocument,\n UpdatePromptTemplateDocument,\n type CreatePromptTemplateMutation,\n type DeletePromptTemplateMutation,\n type GetPromptTemplateQuery,\n type ListPromptTemplatesQuery,\n type RenderPromptTemplateMutation,\n type UpdatePromptTemplateMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreatePromptTemplateInput,\n UpdatePromptTemplateInput,\n} from '../../generated/wspace-types';\nimport { jsonRecords } from '../utils/unions';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface PromptTemplateRecord {\n id: string;\n name: string;\n slug: string;\n version: string;\n templateText: string;\n status: string;\n visibility: string;\n description?: string | null;\n bucketId?: string | null;\n /** Free-form JSON — the UI stores an array of `PromptVariable` here. */\n variables: Record<string, unknown> | unknown[];\n exampleInputs: Record<string, unknown> | unknown[];\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface PromptTemplateFilterVariables {\n search?: string;\n status?: string;\n visibility?: string;\n bucketId?: string;\n tags?: string[];\n}\n\n/** `CreatePromptTemplateInput` minus the `workspaceId` the hook supplies. */\nexport type CreatePromptTemplateVariables = Omit<\n GraphQLInput<CreatePromptTemplateInput>,\n 'workspaceId'\n>;\n\nexport interface UpdatePromptTemplateVariables {\n templateId: string;\n input: GraphQLInput<UpdatePromptTemplateInput>;\n}\n\nconst CREATE_TEMPLATE_FIELDS = fieldsOf<CreatePromptTemplateInput>({\n bucketId: true,\n description: true,\n exampleInputs: true,\n metadata: true,\n name: true,\n slug: true,\n status: true,\n tags: true,\n templateText: true,\n variables: true,\n version: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_TEMPLATE_FIELDS = fieldsOf<UpdatePromptTemplateInput>({\n bucketId: true,\n description: true,\n exampleInputs: true,\n metadata: true,\n name: true,\n slug: true,\n status: true,\n tags: true,\n templateText: true,\n variables: true,\n version: true,\n visibility: true,\n});\n\nexport interface RenderPromptTemplateVariables {\n templateId: string;\n variables?: Record<string, unknown>;\n}\n\nconst NO_TEMPLATES: PromptTemplateRecord[] = [];\n\n/** The variable types the editor offers; anything else falls back to `string`. */\nconst VARIABLE_TYPES: PromptVariableType[] = ['string', 'number', 'boolean', 'array', 'object'];\n\nexport type PromptVariableType = 'string' | 'number' | 'boolean' | 'array' | 'object';\n\n/**\n * One declared template variable. `variables` is a free-form `JSON` column, so\n * a template whose variables were written by another client (or stored as an\n * object rather than an array) must still render.\n */\nexport interface PromptTemplateVariable {\n name: string;\n type: PromptVariableType;\n required: boolean;\n description?: string;\n defaultValue?: unknown;\n}\n\n/** The template's declared variables, normalised for rendering. */\nexport function promptTemplateVariables(\n template: Pick<PromptTemplateRecord, 'variables'>\n): PromptTemplateVariable[] {\n return jsonRecords(template.variables).map((variable, index) => ({\n name: typeof variable.name === 'string' ? variable.name : `variable_${index + 1}`,\n type:\n VARIABLE_TYPES.find(\n (candidate) => typeof variable.type === 'string' && candidate === variable.type\n ) ?? 'string',\n required: variable.required === true,\n description: typeof variable.description === 'string' ? variable.description : undefined,\n defaultValue: variable.defaultValue,\n }));\n}\n\n/** The template's example input sets, normalised for rendering. */\nexport function promptTemplateExamples(\n template: Pick<PromptTemplateRecord, 'exampleInputs'>\n): Record<string, unknown>[] {\n return jsonRecords(template.exampleInputs);\n}\n\nfunction selectTemplates(data: ListPromptTemplatesQuery | undefined): PromptTemplateRecord[] {\n return data?.listPromptTemplates ?? NO_TEMPLATES;\n}\n\nexport const promptTemplateKeys = {\n all: ['promptTemplates'] as const,\n lists: () => [...promptTemplateKeys.all, 'list'] as const,\n list: (filter?: PromptTemplateFilterVariables) =>\n [...promptTemplateKeys.lists(), filter] as const,\n details: () => [...promptTemplateKeys.all, 'detail'] as const,\n detail: (id: string) => [...promptTemplateKeys.details(), id] as const,\n};\n\nexport function usePromptTemplates(\n filter?: PromptTemplateFilterVariables\n): QueryResult<PromptTemplateRecord[]> {\n const workspaceId = useWorkspaceId();\n const { search, status, visibility, bucketId } = filter ?? {};\n const tagsKey = filter?.tags?.join(',') ?? '';\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status,\n visibility,\n bucketId,\n tags: tagsKey ? tagsKey.split(',') : undefined,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search, status, visibility, bucketId, tagsKey]\n );\n\n return useWorkspaceQuery<ListPromptTemplatesQuery, PromptTemplateRecord[]>({\n document: ListPromptTemplatesDocument,\n variables,\n select: selectTemplates,\n fallback: NO_TEMPLATES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load prompt templates',\n });\n}\n\nexport function usePromptTemplate(\n templateId: string | undefined\n): QueryResult<PromptTemplateRecord | null> {\n const variables = useMemo(() => ({ id: templateId ?? '' }), [templateId]);\n\n return useWorkspaceQuery<GetPromptTemplateQuery, PromptTemplateRecord | null>({\n document: GetPromptTemplateDocument,\n variables,\n select: (data) => data?.getPromptTemplate ?? null,\n fallback: null,\n enabled: Boolean(templateId),\n errorMessage: 'Failed to load prompt template',\n });\n}\n\nexport function useCreatePromptTemplate() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreatePromptTemplateVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_TEMPLATE_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreatePromptTemplateMutation,\n CreatePromptTemplateVariables,\n PromptTemplateRecord\n >({\n document: CreatePromptTemplateDocument,\n variables,\n select: (data) => data?.createPromptTemplate,\n errorMessage: 'Failed to create prompt template',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdatePromptTemplate() {\n const [update, state] = useWorkspaceMutation<\n UpdatePromptTemplateMutation,\n UpdatePromptTemplateVariables,\n PromptTemplateRecord\n >({\n document: UpdatePromptTemplateDocument,\n variables: ({ templateId, input }) => ({\n id: templateId,\n input: buildMutationInput(input, UPDATE_TEMPLATE_FIELDS),\n }),\n select: (data) => data?.updatePromptTemplate,\n errorMessage: 'Failed to update prompt template',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeletePromptTemplate() {\n const [remove, state] = useWorkspaceMutation<DeletePromptTemplateMutation, string, boolean>({\n document: DeletePromptTemplateDocument,\n variables: (templateId) => ({ id: templateId }),\n select: (data) => data?.deletePromptTemplate,\n errorMessage: 'Failed to delete prompt template',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n\nexport function useRenderPromptTemplate() {\n const [render, state] = useWorkspaceMutation<\n RenderPromptTemplateMutation,\n RenderPromptTemplateVariables,\n string\n >({\n document: RenderPromptTemplateDocument,\n variables: ({ templateId, variables }) => ({ id: templateId, variables }),\n select: (data) => data?.renderPromptTemplate,\n errorMessage: 'Failed to render prompt template',\n });\n\n return { render, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;;AAoCA,IAAMA,IAAa,KA4CbC,IAAyBC,EAAoC;CACjE,UAAU;CACV,aAAa;CACb,eAAe;CACf,UAAU;CACV,MAAM;CACN,MAAM;CACN,QAAQ;CACR,MAAM;CACN,cAAc;CACd,WAAW;CACX,SAAS;CACT,YAAY;CACZ,aAAa;AACf,CAAC,GAEKC,IAAyBD,EAAoC;CACjE,UAAU;CACV,aAAa;CACb,eAAe;CACf,UAAU;CACV,MAA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OA,EAAM;CAAM;AAC9D"}
1
+ {"version":3,"file":"usePromptTemplates.js","names":["LIST_LIMIT","PAGE_SIZE","CREATE_TEMPLATE_FIELDS","fieldsOf","UPDATE_TEMPLATE_FIELDS","NO_TEMPLATES","VARIABLE_TYPES","promptTemplateVariables","jsonRecords","template","variable","index","candidate","promptTemplateExamples","usePromptTemplates","workspaceId","useWorkspaceId","filter","tagsKey","variables","useMemo","search","status","visibility","bucketId","useWorkspaceAllPagesQuery","ListPromptTemplatesDocument","data","rows","usePagedPromptTemplates","useWorkspacePaginatedQuery","usePromptTemplate","templateId","useWorkspaceQuery","GetPromptTemplateDocument","useCreatePromptTemplate","useCallback","buildMutationInput","input","create","state","useWorkspaceMutation","CreatePromptTemplateDocument","useUpdatePromptTemplate","update","UpdatePromptTemplateDocument","useDeletePromptTemplate","remove","DeletePromptTemplateDocument","useRenderPromptTemplate","render","RenderPromptTemplateDocument","useDuplicatePromptTemplate","duplicate","DuplicatePromptTemplateDocument","GET_PROMPT_TEMPLATE_USAGE","useLoadPromptTemplateUsage","client","useWorkspaceClient","result","operationError","usage"],"sources":["../../../src/botlit/hooks/usePromptTemplates.ts"],"sourcesContent":["/**\n * Prompt Templates Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listPromptTemplates` / `getPromptTemplate` operations and\n * the create/update/delete/render mutations on wspace-botlit-svc.\n */\n\nimport { gql } from '@apollo/client';\nimport { useCallback, useMemo } from 'react';\nimport {\n CreatePromptTemplateDocument,\n DeletePromptTemplateDocument,\n DuplicatePromptTemplateDocument,\n GetPromptTemplateDocument,\n ListPromptTemplatesDocument,\n RenderPromptTemplateDocument,\n UpdatePromptTemplateDocument,\n type CreatePromptTemplateMutation,\n type DeletePromptTemplateMutation,\n type DuplicatePromptTemplateMutation,\n type GetPromptTemplateQuery,\n type ListPromptTemplatesQuery,\n type RenderPromptTemplateMutation,\n type UpdatePromptTemplateMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreatePromptTemplateInput,\n UpdatePromptTemplateInput,\n} from '../../generated/wspace-types';\nimport type { PromptTemplateUsage } from '../utils/promptTemplateForm';\nimport { jsonRecords } from '../utils/unions';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceClient,\n useWorkspaceAllPagesQuery,\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n/** Page size of the Prompt Templates list page; more pages load on request (BOFF-12545). */\nconst PAGE_SIZE = 24;\n\nexport interface PromptTemplateRecord {\n id: string;\n name: string;\n slug: string;\n version: string;\n templateText: string;\n status: string;\n visibility: string;\n description?: string | null;\n bucketId?: string | null;\n /** Free-form JSON — the UI stores an array of `PromptVariable` here. */\n variables: Record<string, unknown> | unknown[];\n exampleInputs: Record<string, unknown> | unknown[];\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface PromptTemplateFilterVariables {\n search?: string;\n status?: string;\n visibility?: string;\n bucketId?: string;\n tags?: string[];\n}\n\n/** `CreatePromptTemplateInput` minus the `workspaceId` the hook supplies. */\nexport type CreatePromptTemplateVariables = Omit<\n GraphQLInput<CreatePromptTemplateInput>,\n 'workspaceId'\n>;\n\nexport interface UpdatePromptTemplateVariables {\n templateId: string;\n input: GraphQLInput<UpdatePromptTemplateInput>;\n}\n\nconst CREATE_TEMPLATE_FIELDS = fieldsOf<CreatePromptTemplateInput>({\n bucketId: true,\n description: true,\n exampleInputs: true,\n metadata: true,\n name: true,\n slug: true,\n status: true,\n tags: true,\n templateText: true,\n variables: true,\n version: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_TEMPLATE_FIELDS = fieldsOf<UpdatePromptTemplateInput>({\n bucketId: true,\n description: true,\n exampleInputs: true,\n metadata: true,\n name: true,\n slug: true,\n status: true,\n tags: true,\n templateText: true,\n variables: true,\n version: true,\n visibility: true,\n});\n\nexport interface RenderPromptTemplateVariables {\n templateId: string;\n variables?: Record<string, unknown>;\n}\n\nconst NO_TEMPLATES: PromptTemplateRecord[] = [];\n\n/** The variable types the editor offers; anything else falls back to `string`. */\nconst VARIABLE_TYPES: PromptVariableType[] = ['string', 'number', 'boolean', 'array', 'object'];\n\nexport type PromptVariableType = 'string' | 'number' | 'boolean' | 'array' | 'object';\n\n/**\n * One declared template variable. `variables` is a free-form `JSON` column, so\n * a template whose variables were written by another client (or stored as an\n * object rather than an array) must still render.\n */\nexport interface PromptTemplateVariable {\n name: string;\n type: PromptVariableType;\n required: boolean;\n description?: string;\n defaultValue?: unknown;\n}\n\n/** The template's declared variables, normalised for rendering. */\nexport function promptTemplateVariables(\n template: Pick<PromptTemplateRecord, 'variables'>\n): PromptTemplateVariable[] {\n return jsonRecords(template.variables).map((variable, index) => ({\n name: typeof variable.name === 'string' ? variable.name : `variable_${index + 1}`,\n type:\n VARIABLE_TYPES.find(\n (candidate) => typeof variable.type === 'string' && candidate === variable.type\n ) ?? 'string',\n required: variable.required === true,\n description: typeof variable.description === 'string' ? variable.description : undefined,\n defaultValue: variable.defaultValue,\n }));\n}\n\n/** The template's example input sets, normalised for rendering. */\nexport function promptTemplateExamples(\n template: Pick<PromptTemplateRecord, 'exampleInputs'>\n): Record<string, unknown>[] {\n return jsonRecords(template.exampleInputs);\n}\n\nexport const promptTemplateKeys = {\n all: ['promptTemplates'] as const,\n lists: () => [...promptTemplateKeys.all, 'list'] as const,\n list: (filter?: PromptTemplateFilterVariables) =>\n [...promptTemplateKeys.lists(), filter] as const,\n details: () => [...promptTemplateKeys.all, 'detail'] as const,\n detail: (id: string) => [...promptTemplateKeys.details(), id] as const,\n};\n\n/**\n * Every template matching the filter, all pages: pickers (skills, agent\n * bindings, Prompt Studio) must see the whole workspace, not the first 100.\n */\nexport function usePromptTemplates(\n filter?: PromptTemplateFilterVariables\n): QueryResult<PromptTemplateRecord[]> {\n const workspaceId = useWorkspaceId();\n const { search, status, visibility, bucketId } = filter ?? {};\n const tagsKey = filter?.tags?.join(',') ?? '';\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status,\n visibility,\n bucketId,\n tags: tagsKey ? tagsKey.split(',') : undefined,\n },\n }),\n [workspaceId, search, status, visibility, bucketId, tagsKey]\n );\n\n return useWorkspaceAllPagesQuery<\n ListPromptTemplatesQuery,\n PromptTemplateRecord,\n PromptTemplateRecord[]\n >({\n document: ListPromptTemplatesDocument,\n variables,\n pageSize: LIST_LIMIT,\n extractRows: (data) => data?.listPromptTemplates,\n select: (rows) => rows,\n fallback: NO_TEMPLATES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load prompt templates',\n });\n}\n\n/**\n * The Prompt Templates list page: server-side search and filters, one page at\n * a time with `loadMore` (BOFF-12545). Pickers keep `usePromptTemplates`.\n */\nexport function usePagedPromptTemplates(\n filter?: PromptTemplateFilterVariables\n): PaginatedQueryResult<PromptTemplateRecord[]> {\n const workspaceId = useWorkspaceId();\n const { search, status, visibility, bucketId } = filter ?? {};\n const tagsKey = filter?.tags?.join(',') ?? '';\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status: status || undefined,\n visibility: visibility || undefined,\n bucketId,\n tags: tagsKey ? tagsKey.split(',') : undefined,\n },\n }),\n [workspaceId, search, status, visibility, bucketId, tagsKey]\n );\n\n return useWorkspacePaginatedQuery<\n ListPromptTemplatesQuery,\n PromptTemplateRecord,\n PromptTemplateRecord[]\n >({\n document: ListPromptTemplatesDocument,\n variables,\n pageSize: PAGE_SIZE,\n extractRows: (data) => data?.listPromptTemplates,\n select: (rows) => rows,\n fallback: NO_TEMPLATES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load prompt templates',\n });\n}\n\nexport function usePromptTemplate(\n templateId: string | undefined\n): QueryResult<PromptTemplateRecord | null> {\n const variables = useMemo(() => ({ id: templateId ?? '' }), [templateId]);\n\n return useWorkspaceQuery<GetPromptTemplateQuery, PromptTemplateRecord | null>({\n document: GetPromptTemplateDocument,\n variables,\n select: (data) => data?.getPromptTemplate ?? null,\n fallback: null,\n enabled: Boolean(templateId),\n errorMessage: 'Failed to load prompt template',\n });\n}\n\nexport function useCreatePromptTemplate() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreatePromptTemplateVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_TEMPLATE_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreatePromptTemplateMutation,\n CreatePromptTemplateVariables,\n PromptTemplateRecord\n >({\n document: CreatePromptTemplateDocument,\n variables,\n select: (data) => data?.createPromptTemplate,\n errorMessage: 'Failed to create prompt template',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdatePromptTemplate() {\n const [update, state] = useWorkspaceMutation<\n UpdatePromptTemplateMutation,\n UpdatePromptTemplateVariables,\n PromptTemplateRecord\n >({\n document: UpdatePromptTemplateDocument,\n variables: ({ templateId, input }) => ({\n id: templateId,\n input: buildMutationInput(input, UPDATE_TEMPLATE_FIELDS),\n }),\n select: (data) => data?.updatePromptTemplate,\n errorMessage: 'Failed to update prompt template',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeletePromptTemplate() {\n const [remove, state] = useWorkspaceMutation<DeletePromptTemplateMutation, string, boolean>({\n document: DeletePromptTemplateDocument,\n variables: (templateId) => ({ id: templateId }),\n select: (data) => data?.deletePromptTemplate,\n errorMessage: 'Failed to delete prompt template',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n\nexport function useRenderPromptTemplate() {\n const [render, state] = useWorkspaceMutation<\n RenderPromptTemplateMutation,\n RenderPromptTemplateVariables,\n string\n >({\n document: RenderPromptTemplateDocument,\n variables: ({ templateId, variables }) => ({ id: templateId, variables }),\n select: (data) => data?.renderPromptTemplate,\n errorMessage: 'Failed to render prompt template',\n });\n\n return { render, loading: state.loading, error: state.error };\n}\n\nexport interface DuplicatePromptTemplateVariables {\n templateId: string;\n name: string;\n}\n\n/** Copies a template under a new name; the copy starts as a DRAFT at version 1.0.0 (BOFF-12547). */\nexport function useDuplicatePromptTemplate() {\n const [duplicate, state] = useWorkspaceMutation<\n DuplicatePromptTemplateMutation,\n DuplicatePromptTemplateVariables,\n PromptTemplateRecord\n >({\n document: DuplicatePromptTemplateDocument,\n variables: ({ templateId, name }) => ({ id: templateId, name }),\n select: (data) => data?.duplicatePromptTemplate,\n errorMessage: 'Failed to duplicate prompt template',\n });\n\n return { duplicate, loading: state.loading, error: state.error };\n}\n\nconst GET_PROMPT_TEMPLATE_USAGE = gql`\n query GetPromptTemplateUsage($id: ID!) {\n getPromptTemplateUsage(id: $id) {\n agents {\n id\n name\n }\n skills {\n id\n name\n }\n }\n }\n`;\n\ninterface PromptTemplateUsageData {\n getPromptTemplateUsage?: PromptTemplateUsage | null;\n}\n\n/**\n * Returns a function that reads which agents and skills use a template, fresh\n * each time: a delete confirmation is about to rely on it (BOFF-12547).\n */\nexport function useLoadPromptTemplateUsage() {\n const client = useWorkspaceClient();\n\n return useCallback(\n async (templateId: string): Promise<PromptTemplateUsage> => {\n const result = await client.query<PromptTemplateUsageData>({\n query: GET_PROMPT_TEMPLATE_USAGE,\n variables: { id: templateId },\n fetchPolicy: 'network-only',\n });\n // The usage query is an inline document (not in the generated operations), so\n // the result is typed loosely here; a failed read surfaces on `result.error`\n // when the client does not throw, and must not pass as \"nothing uses it\".\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error\n ? operationError\n : new Error('Failed to load what uses this prompt template');\n }\n const usage = result.data?.getPromptTemplateUsage;\n return { agents: usage?.agents ?? [], skills: usage?.skills ?? [] };\n },\n [client]\n );\n}\n"],"mappings":";;;;;;;AA4CA,IAAMA,IAAa,KAEbC,IAAY,IA4CZC,IAAyBC,EAAoC;CACjE,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