@burdenoff/microfe-botmanor 2026.1120.20 → 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.
- package/dist/botlit/hooks/index.d.ts +1 -1
- package/dist/botlit/hooks/index.js +9 -9
- package/dist/botlit/hooks/usePromptTemplates.d.ts +26 -1
- package/dist/botlit/hooks/usePromptTemplates.js +119 -52
- package/dist/botlit/hooks/usePromptTemplates.js.map +1 -1
- package/dist/botlit/pages/PromptTemplateDetailPage.d.ts +5 -0
- package/dist/botlit/pages/PromptTemplateDetailPage.js +837 -670
- package/dist/botlit/pages/PromptTemplateDetailPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplatesPage.js +264 -245
- package/dist/botlit/pages/PromptTemplatesPage.js.map +1 -1
- package/dist/botlit/utils/leaveGuard.js +13 -12
- package/dist/botlit/utils/leaveGuard.js.map +1 -1
- package/dist/botlit/utils/promptTemplateForm.d.ts +94 -0
- package/dist/botlit/utils/promptTemplateForm.js +108 -0
- package/dist/botlit/utils/promptTemplateForm.js.map +1 -0
- package/dist/generated/wspace-operations.js +31 -33
- package/dist/generated/wspace-operations.js.map +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
13
|
-
import { useAgentBindings as
|
|
14
|
-
import { useExecutionSummary as
|
|
15
|
-
import { buildBucketTree as
|
|
16
|
-
import { storePackageDescription as
|
|
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
|
|
19
|
-
import { useConfigureSupervisor as
|
|
20
|
-
import { isActiveHandoff as
|
|
21
|
-
export { M as PLATFORM_CREDENTIALS, h as a2aAgentSkillCount,
|
|
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 };
|
|
@@ -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,
|
|
2
|
-
import { jsonRecords as
|
|
3
|
-
import { buildMutationInput as
|
|
4
|
-
import { useWorkspaceId as
|
|
5
|
-
import { useCallback as
|
|
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
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
35
|
+
}), C = [], w = [
|
|
35
36
|
"string",
|
|
36
37
|
"number",
|
|
37
38
|
"boolean",
|
|
38
39
|
"array",
|
|
39
40
|
"object"
|
|
40
41
|
];
|
|
41
|
-
function
|
|
42
|
-
return
|
|
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:
|
|
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
|
|
51
|
-
return
|
|
51
|
+
function E(e) {
|
|
52
|
+
return s(e.exampleInputs);
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
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
|
|
57
|
-
let t =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
92
|
+
r,
|
|
74
93
|
a,
|
|
75
94
|
o,
|
|
76
95
|
s
|
|
77
96
|
]);
|
|
78
|
-
return
|
|
79
|
-
document:
|
|
97
|
+
return m({
|
|
98
|
+
document: i,
|
|
80
99
|
variables: c,
|
|
81
|
-
|
|
82
|
-
|
|
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
|
|
88
|
-
let t =
|
|
89
|
-
return
|
|
90
|
-
document:
|
|
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
|
|
99
|
-
let t =
|
|
119
|
+
function A() {
|
|
120
|
+
let t = f(), n = g((e) => ({ input: c({
|
|
100
121
|
...e,
|
|
101
122
|
workspaceId: t
|
|
102
|
-
},
|
|
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
|
|
115
|
-
let [e, t] =
|
|
116
|
-
document:
|
|
135
|
+
function j() {
|
|
136
|
+
let [e, t] = p({
|
|
137
|
+
document: o,
|
|
117
138
|
variables: ({ templateId: e, input: t }) => ({
|
|
118
139
|
id: e,
|
|
119
|
-
input:
|
|
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
|
|
131
|
-
let [e, n] =
|
|
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
|
|
144
|
-
let [e, t] =
|
|
145
|
-
document:
|
|
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
|
-
|
|
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,MAAM;CACN,MAAM;CACN,QAAQ;CACR,MAAM;CACN,cAAc;CACd,WAAW;CACX,SAAS;CACT,YAAY;AACd,CAAC,GAOKE,IAAuC,CAAC,GAGxCC,IAAuC;CAAC;CAAU;CAAU;CAAW;CAAS;AAAQ;AAkB9F,SAAgBC,EACd,GAC0B;CAC1B,OAAOC,EAAYC,EAAS,SAAS,CAAC,CAAC,KAAK,GAAU,OAAW;EAC/D,MAAM,OAAOC,EAAS,QAAS,WAAWA,EAAS,OAAO,YAAYC,IAAQ;EAC9E,MACEL,EAAe,MACZ,MAAc,OAAOI,EAAS,QAAS,YAAYE,MAAcF,EAAS,IAC7E,KAAK;EACP,UAAUA,EAAS,a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AAC;CAED,OAAO;EAAE;EAAQ,SAASsB,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D;AAEA,SAAgBG,IAA0B;CACxC,IAAM,CAACC,GAAQJ,KAASC,EAItB;EACA,UAAUI;EACV,YAAY,EAAE,eAAY,gBAAa;GACrC,IAAIZ;GACJ,OAAOI,EAAmBC,GAAO/B,CAAsB;EACzD;EACA,SAAS,MAASW,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAASsB,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D;AAEA,SAAgBM,IAA0B;CACxC,IAAM,CAACC,GAAQP,KAASC,EAAoE;EAC1F,UAAUO;EACV,YAAY,OAAgB,EAAE,IAAIf,EAAW;EAC7C,SAAS,MAASf,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAASsB,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D;AAEA,SAAgBS,IAA0B;CACxC,IAAM,CAACC,GAAQV,KAASC,EAItB;EACA,UAAUU;EACV,YAAY,EAAE,eAAY,oBAAiB;GAAE,IAAIlB;GAAY;EAAU;EACvE,SAAS,MAASf,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAASsB,EAAM;EAAS,OAAOA,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,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,MAAM;CACN,MAAM;CACN,QAAQ;CACR,MAAM;CACN,cAAc;CACd,WAAW;CACX,SAAS;CACT,YAAY;AACd,CAAC,GAOKE,IAAuC,CAAC,GAGxCC,IAAuC;CAAC;CAAU;CAAU;CAAW;CAAS;AAAQ;AAkB9F,SAAgBC,EACd,GAC0B;C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OAAO;EAAE;EAAQ,SAASa,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D;AAEA,SAAgBS,IAA0B;CACxC,IAAM,CAACC,GAAQV,KAASC,EAItB;EACA,UAAUU;EACV,YAAY,EAAE,eAAY,oBAAiB;GAAE,IAAInB;GAAY;EAAU;EACvE,SAAS,MAASL,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAASa,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D;AAQA,SAAgBY,IAA6B;CAC3C,IAAM,CAACC,GAAWb,KAASC,EAIzB;EACA,UAAUa;EACV,YAAY,EAAE,eAAY,eAAY;GAAE,IAAItB;GAAY;EAAK;EAC7D,SAAS,MAASL,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAW,SAASa,EAAM;EAAS,OAAOA,EAAM;CAAM;AACjE;AAEA,IAAMe,IAA4B,CAAG;;;;;;;;;;;;;;AAuBrC,SAAgBC,IAA6B;CAC3C,IAAMC,IAASC,EAAmB;CAElC,OAAOtB,EACL,OAAO,MAAqD;EAC1D,IAAMuB,IAAS,MAAMF,EAAO,MAA+B;GACzD,OAAOF;GACP,WAAW,EAAE,IAAIvB,EAAW;GAC5B,aAAa;EACf,CAAC,GAIK4B,IAAkBD,EAA+B;EACvD,IAAIC,KAAkB,MACpB,MAAMA,aAA0B,QAC5BA,IACA,gBAAI,MAAM,+CAA+C;EAE/D,IAAMC,IAAQF,EAAO,MAAM;EAC3B,OAAO;GAAE,QAAQE,GAAO,UAAU,CAAC;GAAG,QAAQA,GAAO,UAAU,CAAC;EAAE;CACpE,GACA,CAACJ,CAAM,CACT;AACF"}
|
|
@@ -2,5 +2,10 @@ import { FC } from 'react';
|
|
|
2
2
|
interface PromptTemplateDetailPageProps {
|
|
3
3
|
isNew?: boolean;
|
|
4
4
|
}
|
|
5
|
+
/** Template text with its placeholders highlighted, rendered as text (never as HTML). */
|
|
6
|
+
export declare const HighlightedTemplate: FC<{
|
|
7
|
+
text: string;
|
|
8
|
+
emptyText?: string;
|
|
9
|
+
}>;
|
|
5
10
|
export declare const PromptTemplateDetailPage: FC<PromptTemplateDetailPageProps>;
|
|
6
11
|
export {};
|