@burdenoff/microfe-botmanor 2026.1031.1 → 2026.1101.2
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/internal/workspaceGateway.js +39 -37
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
- package/dist/botlit/pages/PromptStudioPage.js +102 -101
- package/dist/botlit/pages/PromptStudioPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplateDetailPage.js +142 -141
- package/dist/botlit/pages/PromptTemplateDetailPage.js.map +1 -1
- package/dist/botlit/utils/errors.js +29 -0
- package/dist/botlit/utils/errors.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
import { useBotlit as e } from "../../providers/BotlitProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { extractGraphqlFailureMessage as t } from "../../utils/errors.js";
|
|
3
|
+
import { useCallback as n, useEffect as r, useLayoutEffect as i, useRef as a, useState as o } from "react";
|
|
4
|
+
import { useGatewayClient as s } from "@burdenoff/fe-libs/shared/graphql";
|
|
4
5
|
//#region src/botlit/hooks/internal/workspaceGateway.ts
|
|
5
|
-
function s() {
|
|
6
|
-
return o("workspace");
|
|
7
|
-
}
|
|
8
6
|
function c() {
|
|
7
|
+
return s("workspace");
|
|
8
|
+
}
|
|
9
|
+
function l() {
|
|
9
10
|
return e().workspaceId;
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
12
|
+
function u(e, n) {
|
|
13
|
+
let r = t(e);
|
|
14
|
+
return r ? Error(r, { cause: e }) : e instanceof Error ? e : Error(n, { cause: e });
|
|
13
15
|
}
|
|
14
|
-
function
|
|
15
|
-
let t =
|
|
16
|
-
return
|
|
16
|
+
function d(e) {
|
|
17
|
+
let t = a(e);
|
|
18
|
+
return i(() => {
|
|
17
19
|
t.current = e;
|
|
18
20
|
}, [e]), t;
|
|
19
21
|
}
|
|
20
|
-
function
|
|
21
|
-
let { document:
|
|
22
|
-
if (!
|
|
22
|
+
function f(e) {
|
|
23
|
+
let { document: t, variables: i, enabled: a, errorMessage: s } = e, l = c(), f = d(e.select), p = d(e.fallback), [m, h] = o(e.fallback), [g, _] = o(!1), [v, y] = o(), b = n(async () => {
|
|
24
|
+
if (!a) {
|
|
23
25
|
h(p.current), y(void 0);
|
|
24
26
|
return;
|
|
25
27
|
}
|
|
26
28
|
_(!0), y(void 0);
|
|
27
29
|
try {
|
|
28
|
-
let e = await
|
|
29
|
-
query:
|
|
30
|
+
let e = await l.query({
|
|
31
|
+
query: t,
|
|
30
32
|
variables: i,
|
|
31
33
|
fetchPolicy: "network-only"
|
|
32
34
|
});
|
|
33
35
|
h(f.current(e.data ?? void 0));
|
|
34
36
|
} catch (e) {
|
|
35
|
-
h(p.current), y(
|
|
37
|
+
h(p.current), y(u(e, s));
|
|
36
38
|
} finally {
|
|
37
39
|
_(!1);
|
|
38
40
|
}
|
|
39
41
|
}, [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
l,
|
|
43
|
+
t,
|
|
42
44
|
i,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
a,
|
|
46
|
+
s,
|
|
45
47
|
p,
|
|
46
48
|
f
|
|
47
49
|
]);
|
|
48
|
-
return
|
|
50
|
+
return r(() => {
|
|
49
51
|
b();
|
|
50
52
|
}, [b]), {
|
|
51
53
|
data: m,
|
|
@@ -54,31 +56,31 @@ function d(e) {
|
|
|
54
56
|
refetch: b
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
|
-
function
|
|
58
|
-
let { document:
|
|
59
|
+
function p(e) {
|
|
60
|
+
let { document: t, errorMessage: r } = e, i = c(), a = d(e.variables), s = d(e.select), [l, f] = o({
|
|
59
61
|
data: void 0,
|
|
60
62
|
loading: !1,
|
|
61
63
|
error: void 0
|
|
62
64
|
});
|
|
63
|
-
return [
|
|
65
|
+
return [n(async (e) => {
|
|
64
66
|
f({
|
|
65
67
|
data: void 0,
|
|
66
68
|
loading: !0,
|
|
67
69
|
error: void 0
|
|
68
70
|
});
|
|
69
71
|
try {
|
|
70
|
-
let
|
|
71
|
-
mutation:
|
|
72
|
-
variables:
|
|
73
|
-
}),
|
|
74
|
-
if (
|
|
72
|
+
let n = await i.mutate({
|
|
73
|
+
mutation: t,
|
|
74
|
+
variables: a.current(e)
|
|
75
|
+
}), o = s.current(n.data ?? void 0);
|
|
76
|
+
if (o === void 0) throw Error(r);
|
|
75
77
|
return f({
|
|
76
|
-
data:
|
|
78
|
+
data: o,
|
|
77
79
|
loading: !1,
|
|
78
80
|
error: void 0
|
|
79
|
-
}),
|
|
81
|
+
}), o;
|
|
80
82
|
} catch (e) {
|
|
81
|
-
let t =
|
|
83
|
+
let t = u(e, r);
|
|
82
84
|
throw f({
|
|
83
85
|
data: void 0,
|
|
84
86
|
loading: !1,
|
|
@@ -87,13 +89,13 @@ function f(e) {
|
|
|
87
89
|
}
|
|
88
90
|
}, [
|
|
89
91
|
i,
|
|
90
|
-
|
|
92
|
+
t,
|
|
91
93
|
r,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
]),
|
|
94
|
+
s,
|
|
95
|
+
a
|
|
96
|
+
]), l];
|
|
95
97
|
}
|
|
96
98
|
//#endregion
|
|
97
|
-
export {
|
|
99
|
+
export { c as useWorkspaceClient, l as useWorkspaceId, p as useWorkspaceMutation, f as useWorkspaceQuery };
|
|
98
100
|
|
|
99
101
|
//# sourceMappingURL=workspaceGateway.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspaceGateway.js","names":[],"sources":["../../../../src/botlit/hooks/internal/workspaceGateway.ts"],"sourcesContent":["/**\n * Workspace gateway hook primitives\n * @module botlit/hooks/internal\n *\n * Every BotManor hook talks to the workspace public gateway through the Apollo\n * client the shell installs (`useGatewayClient('workspace')`) — never through a\n * client of its own. These primitives capture the exact shape used by the\n * reference hooks (`useAgents`, `useBots`): `network-only` reads, an explicit\n * `Error` in state rather than a thrown promise, and a `refetch` the caller can\n * run after a mutation.\n */\n\nimport type { ApolloClient, DocumentNode } from '@apollo/client';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../../providers/BotlitProvider';\n\nexport type WorkspaceClient = ApolloClient;\n\n/** Apollo client for the workspace gateway, provided by the host shell. */\nexport function useWorkspaceClient(): WorkspaceClient {\n return useGatewayClient('workspace');\n}\n\n/** Current workspace id from the BotManor context (undefined until the shell resolves it). */\nexport function useWorkspaceId(): string | undefined {\n return useBotlit().workspaceId;\n}\n\nexport interface QueryResult<T> {\n data: T;\n loading: boolean;\n /** Set only when the request FAILED. An empty `data` with no `error` means \"no records yet\". */\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\nexport interface MutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\nfunction toError(cause: unknown, fallbackMessage: string): Error {\n if (cause instanceof Error) return cause;\n return new Error(fallbackMessage);\n}\n\n/** Keeps a mutable ref pointing at the latest value without re-running effects. */\nfunction useLatest<T>(value: T): { readonly current: T } {\n const ref = useRef(value);\n useLayoutEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n\nexport interface WorkspaceQueryOptions<TData, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Must be referentially stable — memoize at the call site. */\n variables: Record<string, unknown> | undefined;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id / no entity id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Reads from the workspace gateway and keeps `{ data, loading, error, refetch }`\n * in sync. `error` is reserved for real failures so callers can tell an empty\n * collection apart from a failed request.\n */\nexport function useWorkspaceQuery<TData, TResult>(\n options: WorkspaceQueryOptions<TData, TResult>\n): QueryResult<TResult> {\n const { document, variables, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const fallbackRef = useLatest(options.fallback);\n\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n setData(fallbackRef.current);\n setError(undefined);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables,\n fetchPolicy: 'network-only',\n });\n setData(selectRef.current(result.data ?? undefined));\n } catch (queryError) {\n setData(fallbackRef.current);\n setError(toError(queryError, errorMessage));\n } finally {\n setLoading(false);\n }\n // fallbackRef/selectRef are stable refs by construction\n }, [client, document, variables, enabled, errorMessage, fallbackRef, selectRef]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport interface WorkspaceMutationOptions<TData, TInput, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Maps the caller's input onto GraphQL variables. */\n variables: (input: TInput) => Record<string, unknown>;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult | undefined;\n /** Thrown (and stored) when the payload is missing or the request fails. */\n errorMessage: string;\n}\n\n/**\n * Writes to the workspace gateway. Returns the `[mutate, state]` tuple used by\n * the reference hooks. `mutate` REJECTS on failure so callers cannot mistake a\n * failed write for a successful one.\n */\nexport function useWorkspaceMutation<TData, TInput, TResult>(\n options: WorkspaceMutationOptions<TData, TInput, TResult>\n): readonly [(input: TInput) => Promise<TResult>, MutationState<TResult>] {\n const { document, errorMessage } = options;\n const client = useWorkspaceClient();\n const variablesRef = useLatest(options.variables);\n const selectRef = useLatest(options.select);\n\n const [state, setState] = useState<MutationState<TResult>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const mutate = useCallback(\n async (input: TInput): Promise<TResult> => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<TData>({\n mutation: document,\n variables: variablesRef.current(input),\n });\n const selected = selectRef.current(result.data ?? undefined);\n if (selected === undefined) {\n throw new Error(errorMessage);\n }\n setState({ data: selected, loading: false, error: undefined });\n return selected;\n } catch (mutationError) {\n const failure = toError(mutationError, errorMessage);\n setState({ data: undefined, loading: false, error: failure });\n throw failure;\n }\n },\n [client, document, errorMessage, selectRef, variablesRef]\n );\n\n return [mutate, state] as const;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"workspaceGateway.js","names":[],"sources":["../../../../src/botlit/hooks/internal/workspaceGateway.ts"],"sourcesContent":["/**\n * Workspace gateway hook primitives\n * @module botlit/hooks/internal\n *\n * Every BotManor hook talks to the workspace public gateway through the Apollo\n * client the shell installs (`useGatewayClient('workspace')`) — never through a\n * client of its own. These primitives capture the exact shape used by the\n * reference hooks (`useAgents`, `useBots`): `network-only` reads, an explicit\n * `Error` in state rather than a thrown promise, and a `refetch` the caller can\n * run after a mutation.\n */\n\nimport type { ApolloClient, DocumentNode } from '@apollo/client';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../../providers/BotlitProvider';\nimport { extractGraphqlFailureMessage } from '../../utils/errors';\n\nexport type WorkspaceClient = ApolloClient;\n\n/** Apollo client for the workspace gateway, provided by the host shell. */\nexport function useWorkspaceClient(): WorkspaceClient {\n return useGatewayClient('workspace');\n}\n\n/** Current workspace id from the BotManor context (undefined until the shell resolves it). */\nexport function useWorkspaceId(): string | undefined {\n return useBotlit().workspaceId;\n}\n\nexport interface QueryResult<T> {\n data: T;\n loading: boolean;\n /** Set only when the request FAILED. An empty `data` with no `error` means \"no records yet\". */\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\nexport interface MutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\n/**\n * Normalises any mutation failure to an Error with the server's\n * user-actionable message where one exists.\n *\n * Apollo Client v4 does not reject with a plain Error: failures arrive as\n * `{ networkError }` / `{ graphQLErrors }` objects, and the batched fetch\n * layer attaches the structured GraphQL errors as `.errors` on the\n * networkError. `extractGraphqlFailureMessage` unwraps all of those; only\n * when nothing user-actionable is present do we fall back to the hook's\n * generic `errorMessage`.\n */\nfunction toError(cause: unknown, fallbackMessage: string): Error {\n const message = extractGraphqlFailureMessage(cause);\n if (message) {\n // Preserve the original rejection on the chain so error monitoring can\n // still reach the structured GraphQL errors (extensions.code, requestId…).\n return new Error(message, { cause });\n }\n if (cause instanceof Error) return cause;\n return new Error(fallbackMessage, { cause });\n}\n\n/** Keeps a mutable ref pointing at the latest value without re-running effects. */\nfunction useLatest<T>(value: T): { readonly current: T } {\n const ref = useRef(value);\n useLayoutEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n\nexport interface WorkspaceQueryOptions<TData, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Must be referentially stable — memoize at the call site. */\n variables: Record<string, unknown> | undefined;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id / no entity id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Reads from the workspace gateway and keeps `{ data, loading, error, refetch }`\n * in sync. `error` is reserved for real failures so callers can tell an empty\n * collection apart from a failed request.\n */\nexport function useWorkspaceQuery<TData, TResult>(\n options: WorkspaceQueryOptions<TData, TResult>\n): QueryResult<TResult> {\n const { document, variables, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const fallbackRef = useLatest(options.fallback);\n\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n setData(fallbackRef.current);\n setError(undefined);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables,\n fetchPolicy: 'network-only',\n });\n setData(selectRef.current(result.data ?? undefined));\n } catch (queryError) {\n setData(fallbackRef.current);\n setError(toError(queryError, errorMessage));\n } finally {\n setLoading(false);\n }\n // fallbackRef/selectRef are stable refs by construction\n }, [client, document, variables, enabled, errorMessage, fallbackRef, selectRef]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport interface WorkspaceMutationOptions<TData, TInput, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Maps the caller's input onto GraphQL variables. */\n variables: (input: TInput) => Record<string, unknown>;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult | undefined;\n /** Thrown (and stored) when the payload is missing or the request fails. */\n errorMessage: string;\n}\n\n/**\n * Writes to the workspace gateway. Returns the `[mutate, state]` tuple used by\n * the reference hooks. `mutate` REJECTS on failure so callers cannot mistake a\n * failed write for a successful one.\n */\nexport function useWorkspaceMutation<TData, TInput, TResult>(\n options: WorkspaceMutationOptions<TData, TInput, TResult>\n): readonly [(input: TInput) => Promise<TResult>, MutationState<TResult>] {\n const { document, errorMessage } = options;\n const client = useWorkspaceClient();\n const variablesRef = useLatest(options.variables);\n const selectRef = useLatest(options.select);\n\n const [state, setState] = useState<MutationState<TResult>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const mutate = useCallback(\n async (input: TInput): Promise<TResult> => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<TData>({\n mutation: document,\n variables: variablesRef.current(input),\n });\n const selected = selectRef.current(result.data ?? undefined);\n if (selected === undefined) {\n throw new Error(errorMessage);\n }\n setState({ data: selected, loading: false, error: undefined });\n return selected;\n } catch (mutationError) {\n const failure = toError(mutationError, errorMessage);\n setState({ data: undefined, loading: false, error: failure });\n throw failure;\n }\n },\n [client, document, errorMessage, selectRef, variablesRef]\n );\n\n return [mutate, state] as const;\n}\n"],"mappings":";;;;;AAsBA,SAAgB,IAAsC;AACpD,QAAO,EAAiB,YAAY;;AAItC,SAAgB,IAAqC;AACnD,QAAO,GAAW,CAAC;;AA4BrB,SAAS,EAAQ,GAAgB,GAAgC;CAC/D,IAAM,IAAU,EAA6B,EAAM;AAOnD,QANI,IAGS,MAAM,GAAS,EAAE,UAAO,CAAC,GAElC,aAAiB,QAAc,IACxB,MAAM,GAAiB,EAAE,UAAO,CAAC;;AAI9C,SAAS,EAAa,GAAmC;CACvD,IAAM,IAAM,EAAO,EAAM;AAIzB,QAHA,QAAsB;AACpB,IAAI,UAAU;IACb,CAAC,EAAM,CAAC,EACJ;;AAuBT,SAAgB,EACd,GACsB;CACtB,IAAM,EAAE,aAAU,cAAW,YAAS,oBAAiB,GACjD,IAAS,GAAoB,EAC7B,IAAY,EAAU,EAAQ,OAAO,EACrC,IAAc,EAAU,EAAQ,SAAS,EAEzC,CAAC,GAAM,KAAW,EAAkB,EAAQ,SAAS,EACrD,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,CAAC,GAAO,KAAY,GAA6B,EAEjD,IAAU,EAAY,YAAY;AACtC,MAAI,CAAC,GAAS;AAEZ,GADA,EAAQ,EAAY,QAAQ,EAC5B,EAAS,KAAA,EAAU;AACnB;;AAIF,EADA,EAAW,GAAK,EAChB,EAAS,KAAA,EAAU;AACnB,MAAI;GACF,IAAM,IAAS,MAAM,EAAO,MAAa;IACvC,OAAO;IACP;IACA,aAAa;IACd,CAAC;AACF,KAAQ,EAAU,QAAQ,EAAO,QAAQ,KAAA,EAAU,CAAC;WAC7C,GAAY;AAEnB,GADA,EAAQ,EAAY,QAAQ,EAC5B,EAAS,EAAQ,GAAY,EAAa,CAAC;YACnC;AACR,KAAW,GAAM;;IAGlB;EAAC;EAAQ;EAAU;EAAW;EAAS;EAAc;EAAa;EAAU,CAAC;AAMhF,QAJA,QAAgB;AACT,KAAS;IACb,CAAC,EAAQ,CAAC,EAEN;EAAE;EAAM;EAAS;EAAO;EAAS;;AAmB1C,SAAgB,EACd,GACwE;CACxE,IAAM,EAAE,aAAU,oBAAiB,GAC7B,IAAS,GAAoB,EAC7B,IAAe,EAAU,EAAQ,UAAU,EAC3C,IAAY,EAAU,EAAQ,OAAO,EAErC,CAAC,GAAO,KAAY,EAAiC;EACzD,MAAM,KAAA;EACN,SAAS;EACT,OAAO,KAAA;EACR,CAAC;AAyBF,QAAO,CAvBQ,EACb,OAAO,MAAoC;AACzC,IAAS;GAAE,MAAM,KAAA;GAAW,SAAS;GAAM,OAAO,KAAA;GAAW,CAAC;AAC9D,MAAI;GACF,IAAM,IAAS,MAAM,EAAO,OAAc;IACxC,UAAU;IACV,WAAW,EAAa,QAAQ,EAAM;IACvC,CAAC,EACI,IAAW,EAAU,QAAQ,EAAO,QAAQ,KAAA,EAAU;AAC5D,OAAI,MAAa,KAAA,EACf,OAAU,MAAM,EAAa;AAG/B,UADA,EAAS;IAAE,MAAM;IAAU,SAAS;IAAO,OAAO,KAAA;IAAW,CAAC,EACvD;WACA,GAAe;GACtB,IAAM,IAAU,EAAQ,GAAe,EAAa;AAEpD,SADA,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO,OAAO;IAAS,CAAC,EACvD;;IAGV;EAAC;EAAQ;EAAU;EAAc;EAAW;EAAa,CAC1D,EAEe,EAAM"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { useBotlit as e } from "../providers/BotlitProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { graphqlErrorMessage as t } from "../utils/errors.js";
|
|
3
|
+
import { formatRelativeTime as n } from "../utils/formatters.js";
|
|
4
|
+
import { BOTMANOR_PERMISSIONS as r } from "../permissions/botmanorPermissions.js";
|
|
5
|
+
import { BotmanorPermissionGate as i } from "../permissions/useBotmanorPermissions.js";
|
|
6
|
+
import { PageLayout as a } from "../components/PageLayout.js";
|
|
7
|
+
import { Button as o } from "../components/Button.js";
|
|
7
8
|
import "../permissions/index.js";
|
|
8
|
-
import { Card as
|
|
9
|
-
import { Badge as
|
|
10
|
-
import { EmptyState as
|
|
11
|
-
import { FormField as
|
|
12
|
-
import { ErrorState as
|
|
13
|
-
import { promptTemplateVariables as
|
|
9
|
+
import { Card as s, CardContent as c, CardDescription as l, CardHeader as u, CardTitle as d } from "../components/Card.js";
|
|
10
|
+
import { Badge as f } from "../components/Badge.js";
|
|
11
|
+
import { EmptyState as p } from "../components/EmptyState.js";
|
|
12
|
+
import { FormField as m, Input as h, Textarea as g } from "../components/Input.js";
|
|
13
|
+
import { ErrorState as _ } from "../components/ErrorState.js";
|
|
14
|
+
import { promptTemplateVariables as v, usePromptTemplates as y, useRenderPromptTemplate as b } from "../hooks/usePromptTemplates.js";
|
|
14
15
|
import "../hooks/index.js";
|
|
15
|
-
import { useEffect as
|
|
16
|
-
import { GlassCard as
|
|
17
|
-
import { jsx as
|
|
18
|
-
import { Play as
|
|
19
|
-
import { toast as
|
|
16
|
+
import { useEffect as x, useMemo as S, useState as C } from "react";
|
|
17
|
+
import { GlassCard as w, PagePurpose as T } from "@burdenoff/fe-libs/ui";
|
|
18
|
+
import { jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
19
|
+
import { Play as O, Plus as k, Tag as A } from "lucide-react";
|
|
20
|
+
import { toast as j } from "sonner";
|
|
20
21
|
//#region src/botlit/pages/PromptStudioPage.tsx
|
|
21
|
-
function
|
|
22
|
+
function M(e) {
|
|
22
23
|
if (!e || typeof e != "object" || Array.isArray(e)) return null;
|
|
23
24
|
let t = e, n = typeof t.name == "string" ? t.name : void 0;
|
|
24
25
|
return n ? {
|
|
@@ -29,91 +30,91 @@ function j(e) {
|
|
|
29
30
|
defaultValue: t.defaultValue
|
|
30
31
|
} : null;
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
return e ?
|
|
33
|
+
function N(e) {
|
|
34
|
+
return e ? v(e).map(M).filter((e) => e !== null) : [];
|
|
34
35
|
}
|
|
35
|
-
var
|
|
36
|
-
let { navigateTo:
|
|
37
|
-
|
|
38
|
-
!
|
|
39
|
-
}, [
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
templateId:
|
|
44
|
-
variables:
|
|
36
|
+
var P = () => {
|
|
37
|
+
let { navigateTo: v } = e(), { data: M, loading: P, error: F, refetch: I } = y(), { render: L, loading: R } = b(), [z, B] = C(null), [V, H] = C({}), [U, W] = C("");
|
|
38
|
+
x(() => {
|
|
39
|
+
!z && M.length > 0 && B(M[0].id);
|
|
40
|
+
}, [M, z]);
|
|
41
|
+
let G = S(() => M.find((e) => e.id === z), [M, z]), K = S(() => N(G), [G]), q = async () => {
|
|
42
|
+
if (G) try {
|
|
43
|
+
W(await L({
|
|
44
|
+
templateId: G.id,
|
|
45
|
+
variables: V
|
|
45
46
|
}));
|
|
46
47
|
} catch (e) {
|
|
47
|
-
|
|
48
|
+
j.error(t(e, "Failed to render prompt"));
|
|
48
49
|
}
|
|
49
50
|
};
|
|
50
|
-
return /* @__PURE__ */
|
|
51
|
+
return /* @__PURE__ */ E(a, {
|
|
51
52
|
title: "Prompt Studio",
|
|
52
53
|
description: "Create, test, and manage prompts for your AI agents",
|
|
53
|
-
actions: /* @__PURE__ */
|
|
54
|
-
permission:
|
|
55
|
-
children: /* @__PURE__ */
|
|
56
|
-
leftIcon: /* @__PURE__ */
|
|
57
|
-
onClick: () =>
|
|
54
|
+
actions: /* @__PURE__ */ E(i, {
|
|
55
|
+
permission: r.PROMPT_TEMPLATE_CREATE,
|
|
56
|
+
children: /* @__PURE__ */ E(o, {
|
|
57
|
+
leftIcon: /* @__PURE__ */ E(k, { size: 16 }),
|
|
58
|
+
onClick: () => v("prompt-templates/new"),
|
|
58
59
|
children: "New Prompt"
|
|
59
60
|
})
|
|
60
61
|
}),
|
|
61
|
-
children: /* @__PURE__ */
|
|
62
|
+
children: /* @__PURE__ */ D("div", {
|
|
62
63
|
className: "space-y-6",
|
|
63
|
-
children: [/* @__PURE__ */ T
|
|
64
|
-
icon: /* @__PURE__ */
|
|
64
|
+
children: [/* @__PURE__ */ E(T, {
|
|
65
|
+
icon: /* @__PURE__ */ E(O, { size: 18 }),
|
|
65
66
|
children: "Prompt Studio is your interactive workbench for writing and testing prompts before they go live. Pick a prompt, edit its text and variables on the left, then fill in sample values and hit Run Test to preview exactly what the agent will receive — so you can iterate on wording and catch mistakes here instead of in production."
|
|
66
|
-
}), /* @__PURE__ */
|
|
67
|
+
}), /* @__PURE__ */ D("div", {
|
|
67
68
|
className: "grid grid-cols-12 gap-6",
|
|
68
69
|
children: [
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ E("div", {
|
|
70
71
|
className: "col-span-3",
|
|
71
|
-
children: /* @__PURE__ */
|
|
72
|
+
children: /* @__PURE__ */ D(s, { children: [/* @__PURE__ */ E(u, { children: /* @__PURE__ */ E(d, {
|
|
72
73
|
className: "text-base",
|
|
73
74
|
children: "Prompts"
|
|
74
|
-
}) }), /* @__PURE__ */
|
|
75
|
+
}) }), /* @__PURE__ */ E(c, {
|
|
75
76
|
className: "p-0",
|
|
76
|
-
children:
|
|
77
|
+
children: P ? /* @__PURE__ */ E("div", {
|
|
77
78
|
className: "space-y-2 p-4",
|
|
78
79
|
children: [
|
|
79
80
|
1,
|
|
80
81
|
2,
|
|
81
82
|
3
|
|
82
|
-
].map((e) => /* @__PURE__ */
|
|
83
|
-
}) :
|
|
83
|
+
].map((e) => /* @__PURE__ */ E("div", { className: "h-14 bg-bg-sunken motion-safe:animate-vc-shimmer rounded" }, e))
|
|
84
|
+
}) : F ? /* @__PURE__ */ E(_, {
|
|
84
85
|
resource: "prompt templates",
|
|
85
|
-
error:
|
|
86
|
-
onRetry: () => void
|
|
86
|
+
error: F,
|
|
87
|
+
onRetry: () => void I(),
|
|
87
88
|
className: "m-4"
|
|
88
|
-
}) :
|
|
89
|
+
}) : M.length === 0 ? /* @__PURE__ */ E("p", {
|
|
89
90
|
className: "p-4 text-sm text-text-secondary",
|
|
90
91
|
children: "No prompt templates yet. Create one to start iterating."
|
|
91
|
-
}) : /* @__PURE__ */
|
|
92
|
+
}) : /* @__PURE__ */ E("div", {
|
|
92
93
|
className: "divide-y divide-border-subtle",
|
|
93
|
-
children:
|
|
94
|
+
children: M.map((e) => /* @__PURE__ */ D("button", {
|
|
94
95
|
type: "button",
|
|
95
|
-
className: `w-full text-left p-4 hover:bg-accent transition-colors ${
|
|
96
|
+
className: `w-full text-left p-4 hover:bg-accent transition-colors ${G?.id === e.id ? "bg-accent" : ""}`,
|
|
96
97
|
onClick: () => {
|
|
97
|
-
|
|
98
|
+
B(e.id), H({}), W("");
|
|
98
99
|
},
|
|
99
100
|
children: [
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ E("p", {
|
|
101
102
|
className: "font-medium truncate",
|
|
102
103
|
children: e.name
|
|
103
104
|
}),
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ D("p", {
|
|
105
106
|
className: "text-xs text-text-secondary mt-1 truncate",
|
|
106
107
|
children: ["v", e.version]
|
|
107
108
|
}),
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ D("div", {
|
|
109
110
|
className: "flex items-center gap-2 mt-2",
|
|
110
|
-
children: [e.visibility === "PUBLIC" && /* @__PURE__ */
|
|
111
|
+
children: [e.visibility === "PUBLIC" && /* @__PURE__ */ E(f, {
|
|
111
112
|
variant: "secondary",
|
|
112
113
|
className: "text-[10px]",
|
|
113
114
|
children: "Public"
|
|
114
|
-
}), /* @__PURE__ */
|
|
115
|
+
}), /* @__PURE__ */ D("span", {
|
|
115
116
|
className: "text-xs text-text-secondary",
|
|
116
|
-
children: [
|
|
117
|
+
children: [N(e).length, " vars"]
|
|
117
118
|
})]
|
|
118
119
|
})
|
|
119
120
|
]
|
|
@@ -121,115 +122,115 @@ var N = () => {
|
|
|
121
122
|
})
|
|
122
123
|
})] })
|
|
123
124
|
}),
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ E("div", {
|
|
125
126
|
className: "col-span-6",
|
|
126
|
-
children:
|
|
127
|
+
children: G ? /* @__PURE__ */ D(w, {
|
|
127
128
|
treatment: "glass",
|
|
128
129
|
glow: !0,
|
|
129
130
|
className: "overflow-hidden",
|
|
130
|
-
children: [/* @__PURE__ */
|
|
131
|
+
children: [/* @__PURE__ */ D(u, {
|
|
131
132
|
className: "flex flex-row items-center justify-between",
|
|
132
|
-
children: [/* @__PURE__ */
|
|
133
|
+
children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E(d, { children: G.name }), /* @__PURE__ */ E(l, { children: G.description })] }), /* @__PURE__ */ E(o, {
|
|
133
134
|
size: "sm",
|
|
134
135
|
variant: "outline",
|
|
135
|
-
onClick: () =>
|
|
136
|
+
onClick: () => v(`prompt-templates/${G.id}`),
|
|
136
137
|
children: "Open template"
|
|
137
138
|
})]
|
|
138
|
-
}), /* @__PURE__ */
|
|
139
|
+
}), /* @__PURE__ */ D(c, {
|
|
139
140
|
className: "space-y-4",
|
|
140
141
|
children: [
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
+
/* @__PURE__ */ D("div", {
|
|
142
143
|
className: "flex items-center gap-2",
|
|
143
|
-
children: [/* @__PURE__ */
|
|
144
|
+
children: [/* @__PURE__ */ E(A, {
|
|
144
145
|
size: 14,
|
|
145
146
|
className: "text-text-secondary"
|
|
146
|
-
}),
|
|
147
|
+
}), G.tags.map((e) => /* @__PURE__ */ E(f, {
|
|
147
148
|
variant: "secondary",
|
|
148
149
|
children: e
|
|
149
150
|
}, e))]
|
|
150
151
|
}),
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
+
/* @__PURE__ */ E(m, {
|
|
152
153
|
label: "Prompt Content",
|
|
153
|
-
children: /* @__PURE__ */
|
|
154
|
-
value:
|
|
154
|
+
children: /* @__PURE__ */ E(g, {
|
|
155
|
+
value: G.templateText,
|
|
155
156
|
rows: 15,
|
|
156
157
|
readOnly: !0,
|
|
157
158
|
className: "font-mono text-sm"
|
|
158
159
|
})
|
|
159
160
|
}),
|
|
160
|
-
|
|
161
|
+
K.length > 0 && /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
|
|
161
162
|
className: "text-sm font-medium mb-2",
|
|
162
163
|
children: "Variables"
|
|
163
|
-
}), /* @__PURE__ */
|
|
164
|
+
}), /* @__PURE__ */ E("div", {
|
|
164
165
|
className: "space-y-2",
|
|
165
|
-
children:
|
|
166
|
+
children: K.map((e) => /* @__PURE__ */ D("div", {
|
|
166
167
|
className: "flex items-center gap-4 p-3 bg-bg-sunken rounded-lg",
|
|
167
|
-
children: [/* @__PURE__ */
|
|
168
|
+
children: [/* @__PURE__ */ D("div", {
|
|
168
169
|
className: "flex-1",
|
|
169
|
-
children: [/* @__PURE__ */
|
|
170
|
+
children: [/* @__PURE__ */ D("p", {
|
|
170
171
|
className: "font-medium text-sm",
|
|
171
|
-
children: [`{{${e.name}}}`, e.required && /* @__PURE__ */
|
|
172
|
+
children: [`{{${e.name}}}`, e.required && /* @__PURE__ */ E("span", {
|
|
172
173
|
className: "text-status-error-text ml-1",
|
|
173
174
|
children: "*"
|
|
174
175
|
})]
|
|
175
|
-
}), e.description && /* @__PURE__ */
|
|
176
|
+
}), e.description && /* @__PURE__ */ E("p", {
|
|
176
177
|
className: "text-xs text-text-secondary",
|
|
177
178
|
children: e.description
|
|
178
179
|
})]
|
|
179
|
-
}), /* @__PURE__ */
|
|
180
|
+
}), /* @__PURE__ */ E(f, {
|
|
180
181
|
variant: "outline",
|
|
181
182
|
className: "capitalize",
|
|
182
183
|
children: e.type
|
|
183
184
|
})]
|
|
184
185
|
}, e.name))
|
|
185
186
|
})] }),
|
|
186
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ D("div", {
|
|
187
188
|
className: "pt-4 text-xs text-text-secondary",
|
|
188
|
-
children: ["Updated ",
|
|
189
|
+
children: ["Updated ", n(G.updatedAt)]
|
|
189
190
|
})
|
|
190
191
|
]
|
|
191
192
|
})]
|
|
192
|
-
}) : /* @__PURE__ */
|
|
193
|
+
}) : /* @__PURE__ */ E(p, {
|
|
193
194
|
illustration: "onboarding",
|
|
194
195
|
title: "Select a prompt",
|
|
195
196
|
description: "Choose a prompt from the list to view and edit"
|
|
196
197
|
})
|
|
197
198
|
}),
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ E("div", {
|
|
199
200
|
className: "col-span-3",
|
|
200
|
-
children: /* @__PURE__ */
|
|
201
|
+
children: /* @__PURE__ */ D(s, { children: [/* @__PURE__ */ E(u, { children: /* @__PURE__ */ D(d, {
|
|
201
202
|
className: "text-base flex items-center gap-2",
|
|
202
|
-
children: [/* @__PURE__ */
|
|
203
|
-
}) }), /* @__PURE__ */
|
|
203
|
+
children: [/* @__PURE__ */ E(O, { size: 16 }), "Test Prompt"]
|
|
204
|
+
}) }), /* @__PURE__ */ D(c, {
|
|
204
205
|
className: "space-y-4",
|
|
205
206
|
children: [
|
|
206
|
-
|
|
207
|
+
K.map((e) => /* @__PURE__ */ E(m, {
|
|
207
208
|
label: e.name,
|
|
208
|
-
children: /* @__PURE__ */
|
|
209
|
+
children: /* @__PURE__ */ E(h, {
|
|
209
210
|
placeholder: e.description || `Enter ${e.name}`,
|
|
210
|
-
value:
|
|
211
|
-
onChange: (t) =>
|
|
212
|
-
...
|
|
211
|
+
value: V[e.name] || "",
|
|
212
|
+
onChange: (t) => H({
|
|
213
|
+
...V,
|
|
213
214
|
[e.name]: t.target.value
|
|
214
215
|
})
|
|
215
216
|
})
|
|
216
217
|
}, e.name)),
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
permission:
|
|
219
|
-
children: /* @__PURE__ */
|
|
218
|
+
/* @__PURE__ */ E(i, {
|
|
219
|
+
permission: r.PROMPT_TEMPLATE_EXECUTE,
|
|
220
|
+
children: /* @__PURE__ */ E(o, {
|
|
220
221
|
className: "w-full",
|
|
221
|
-
onClick: () => void
|
|
222
|
-
isLoading:
|
|
223
|
-
disabled: !
|
|
222
|
+
onClick: () => void q(),
|
|
223
|
+
isLoading: R,
|
|
224
|
+
disabled: !G,
|
|
224
225
|
children: "Run Test"
|
|
225
226
|
})
|
|
226
227
|
}),
|
|
227
|
-
|
|
228
|
+
U && /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
|
|
228
229
|
className: "text-sm font-medium mb-2",
|
|
229
230
|
children: "Output"
|
|
230
|
-
}), /* @__PURE__ */
|
|
231
|
+
}), /* @__PURE__ */ E("div", {
|
|
231
232
|
className: "p-3 bg-bg-sunken rounded-lg text-sm whitespace-pre-wrap font-mono max-h-64 overflow-auto",
|
|
232
|
-
children:
|
|
233
|
+
children: U
|
|
233
234
|
})] })
|
|
234
235
|
]
|
|
235
236
|
})] })
|
|
@@ -240,6 +241,6 @@ var N = () => {
|
|
|
240
241
|
});
|
|
241
242
|
};
|
|
242
243
|
//#endregion
|
|
243
|
-
export {
|
|
244
|
+
export { P as PromptStudioPage };
|
|
244
245
|
|
|
245
246
|
//# sourceMappingURL=PromptStudioPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptStudioPage.js","names":[],"sources":["../../../src/botlit/pages/PromptStudioPage.tsx"],"sourcesContent":["/**\n * Prompt Studio Page\n * @module botlit/pages\n */\n\nimport type { FC } from 'react';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Plus, Play, Tag } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { PagePurpose, GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../components/PageLayout';\nimport { Card, CardHeader, CardTitle, CardContent, CardDescription } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Input, Textarea, FormField } from '../components/Input';\nimport { Badge } from '../components/Badge';\nimport { EmptyState } from '../components/EmptyState';\nimport { ErrorState } from '../components/ErrorState';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport {\n usePromptTemplates,\n useRenderPromptTemplate,\n promptTemplateVariables,\n type PromptTemplateRecord,\n} from '../hooks';\nimport { formatRelativeTime } from '../utils/formatters';\nimport type { PromptVariable } from '../types';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\n/** Normalises one entry of a template's free-form `variables` JSON. */\nfunction toPromptVariable(value: unknown): PromptVariable | null {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return null;\n const record = value as Record<string, unknown>;\n const name = typeof record.name === 'string' ? record.name : undefined;\n if (!name) return null;\n const type = typeof record.type === 'string' ? record.type : 'string';\n return {\n name,\n type: type as PromptVariable['type'],\n description: typeof record.description === 'string' ? record.description : undefined,\n required: record.required === true,\n defaultValue: record.defaultValue,\n };\n}\n\nfunction templateVariables(template: PromptTemplateRecord | undefined): PromptVariable[] {\n if (!template) return [];\n return promptTemplateVariables(template)\n .map(toPromptVariable)\n .filter((variable): variable is PromptVariable => variable !== null);\n}\n\nexport const PromptStudioPage: FC = () => {\n const { navigateTo } = useBotlit();\n const { data: templates, loading, error, refetch } = usePromptTemplates();\n const { render, loading: isRunning } = useRenderPromptTemplate();\n\n const [selectedPromptId, setSelectedPromptId] = useState<string | null>(null);\n const [testVariables, setTestVariables] = useState<Record<string, string>>({});\n const [testOutput, setTestOutput] = useState('');\n\n // Select the first template once the list arrives.\n useEffect(() => {\n if (!selectedPromptId && templates.length > 0) {\n setSelectedPromptId(templates[0].id);\n }\n }, [templates, selectedPromptId]);\n\n const selectedPrompt = useMemo(\n () => templates.find((template) => template.id === selectedPromptId),\n [templates, selectedPromptId]\n );\n\n const selectedVariables = useMemo(() => templateVariables(selectedPrompt), [selectedPrompt]);\n\n const handleTest = async () => {\n if (!selectedPrompt) return;\n try {\n // Rendered by wspace-botlit-svc so the preview matches what the agent\n // actually receives — never a client-side string substitution.\n const output = await render({\n templateId: selectedPrompt.id,\n variables: testVariables,\n });\n setTestOutput(output);\n } catch (err) {\n toast.error(err instanceof Error ? err.message : 'Failed to render prompt');\n }\n };\n\n return (\n <PageLayout\n title=\"Prompt Studio\"\n description=\"Create, test, and manage prompts for your AI agents\"\n actions={\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.PROMPT_TEMPLATE_CREATE}>\n <Button leftIcon={<Plus size={16} />} onClick={() => navigateTo('prompt-templates/new')}>\n New Prompt\n </Button>\n </BotmanorPermissionGate>\n }\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<Play size={18} />}>\n Prompt Studio is your interactive workbench for writing and testing prompts before they go\n live. Pick a prompt, edit its text and variables on the left, then fill in sample values\n and hit Run Test to preview exactly what the agent will receive — so you can iterate on\n wording and catch mistakes here instead of in production.\n </PagePurpose>\n\n <div className=\"grid grid-cols-12 gap-6\">\n {/* Prompt List */}\n <div className=\"col-span-3\">\n <Card>\n <CardHeader>\n <CardTitle className=\"text-base\">Prompts</CardTitle>\n </CardHeader>\n <CardContent className=\"p-0\">\n {loading ? (\n <div className=\"space-y-2 p-4\">\n {[1, 2, 3].map((i) => (\n <div\n key={i}\n className=\"h-14 bg-bg-sunken motion-safe:animate-vc-shimmer rounded\"\n />\n ))}\n </div>\n ) : error ? (\n <ErrorState\n resource=\"prompt templates\"\n error={error}\n onRetry={() => void refetch()}\n className=\"m-4\"\n />\n ) : templates.length === 0 ? (\n <p className=\"p-4 text-sm text-text-secondary\">\n No prompt templates yet. Create one to start iterating.\n </p>\n ) : (\n <div className=\"divide-y divide-border-subtle\">\n {templates.map((prompt: PromptTemplateRecord) => (\n <button\n key={prompt.id}\n type=\"button\"\n className={`w-full text-left p-4 hover:bg-accent transition-colors ${\n selectedPrompt?.id === prompt.id ? 'bg-accent' : ''\n }`}\n onClick={() => {\n setSelectedPromptId(prompt.id);\n setTestVariables({});\n setTestOutput('');\n }}\n >\n <p className=\"font-medium truncate\">{prompt.name}</p>\n <p className=\"text-xs text-text-secondary mt-1 truncate\">\n v{prompt.version}\n </p>\n <div className=\"flex items-center gap-2 mt-2\">\n {prompt.visibility === 'PUBLIC' && (\n <Badge variant=\"secondary\" className=\"text-[10px]\">\n Public\n </Badge>\n )}\n <span className=\"text-xs text-text-secondary\">\n {templateVariables(prompt).length} vars\n </span>\n </div>\n </button>\n ))}\n </div>\n )}\n </CardContent>\n </Card>\n </div>\n\n {/* Editor */}\n <div className=\"col-span-6\">\n {selectedPrompt ? (\n <GlassCard treatment=\"glass\" glow className=\"overflow-hidden\">\n <CardHeader className=\"flex flex-row items-center justify-between\">\n <div>\n <CardTitle>{selectedPrompt.name}</CardTitle>\n <CardDescription>{selectedPrompt.description}</CardDescription>\n </div>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => navigateTo(`prompt-templates/${selectedPrompt.id}`)}\n >\n Open template\n </Button>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {/* Tags */}\n <div className=\"flex items-center gap-2\">\n <Tag size={14} className=\"text-text-secondary\" />\n {selectedPrompt.tags.map((tag) => (\n <Badge key={tag} variant=\"secondary\">\n {tag}\n </Badge>\n ))}\n </div>\n\n {/* Content */}\n <FormField label=\"Prompt Content\">\n <Textarea\n value={selectedPrompt.templateText}\n rows={15}\n readOnly\n className=\"font-mono text-sm\"\n />\n </FormField>\n\n {/* Variables */}\n {selectedVariables.length > 0 && (\n <div>\n <p className=\"text-sm font-medium mb-2\">Variables</p>\n <div className=\"space-y-2\">\n {selectedVariables.map((variable: PromptVariable) => (\n <div\n key={variable.name}\n className=\"flex items-center gap-4 p-3 bg-bg-sunken rounded-lg\"\n >\n <div className=\"flex-1\">\n <p className=\"font-medium text-sm\">\n {`{{${variable.name}}}`}\n {variable.required && (\n <span className=\"text-status-error-text ml-1\">*</span>\n )}\n </p>\n {variable.description && (\n <p className=\"text-xs text-text-secondary\">\n {variable.description}\n </p>\n )}\n </div>\n <Badge variant=\"outline\" className=\"capitalize\">\n {variable.type}\n </Badge>\n </div>\n ))}\n </div>\n </div>\n )}\n\n <div className=\"pt-4 text-xs text-text-secondary\">\n Updated {formatRelativeTime(selectedPrompt.updatedAt)}\n </div>\n </CardContent>\n </GlassCard>\n ) : (\n <EmptyState\n illustration=\"onboarding\"\n title=\"Select a prompt\"\n description=\"Choose a prompt from the list to view and edit\"\n />\n )}\n </div>\n\n {/* Test Panel */}\n <div className=\"col-span-3\">\n <Card>\n <CardHeader>\n <CardTitle className=\"text-base flex items-center gap-2\">\n <Play size={16} />\n Test Prompt\n </CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {selectedVariables.map((variable: PromptVariable) => (\n <FormField key={variable.name} label={variable.name}>\n <Input\n placeholder={variable.description || `Enter ${variable.name}`}\n value={testVariables[variable.name] || ''}\n onChange={(e) =>\n setTestVariables({ ...testVariables, [variable.name]: e.target.value })\n }\n />\n </FormField>\n ))}\n\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.PROMPT_TEMPLATE_EXECUTE}>\n <Button\n className=\"w-full\"\n onClick={() => void handleTest()}\n isLoading={isRunning}\n disabled={!selectedPrompt}\n >\n Run Test\n </Button>\n </BotmanorPermissionGate>\n\n {testOutput && (\n <div>\n <p className=\"text-sm font-medium mb-2\">Output</p>\n <div className=\"p-3 bg-bg-sunken rounded-lg text-sm whitespace-pre-wrap font-mono max-h-64 overflow-auto\">\n {testOutput}\n </div>\n </div>\n )}\n </CardContent>\n </Card>\n </div>\n </div>\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA,SAAS,EAAiB,GAAuC;AAC/D,KAAI,CAAC,KAAS,OAAO,KAAU,YAAY,MAAM,QAAQ,EAAM,CAAE,QAAO;CACxE,IAAM,IAAS,GACT,IAAO,OAAO,EAAO,QAAS,WAAW,EAAO,OAAO,KAAA;AAG7D,QAFK,IAEE;EACL;EACM,MAHK,OAAO,EAAO,QAAS,WAAW,EAAO,OAAO;E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,EAAS,KAmBV,CACN;UACE,CAAA,CACF,EAAA,CAAA;SAGR,kBAAC,OAAD;UAAK,WAAU;oBAAf,CAAkD,YACvC,EAAmB,EAAe,UAAU,CACjD;;SACM;UACJ;WAEZ,kBAAC,GAAD;OACE,cAAa;OACb,OAAM;OACN,aAAY;OACZ,CAAA;MAEA,CAAA;KAGN,kBAAC,OAAD;MAAK,WAAU;gBACb,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;OAAW,WAAU;iBAArB,CACE,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA,EAAA,cAER;UACD,CAAA,EACb,kBAAC,GAAD;OAAa,WAAU;iBAAvB;QACG,EAAkB,KAAK,MACtB,kBAAC,GAAD;SAA+B,OAAO,EAAS;mBAC7C,kBAAC,GAAD;UACE,aAAa,EAAS,eAAe,SAAS,EAAS;UACvD,OAAO,EAAc,EAAS,SAAS;UACvC,WAAW,MACT,EAAiB;WAAE,GAAG;YAAgB,EAAS,OAAO,EAAE,OAAO;WAAO,CAAC;UAEzE,CAAA;SACQ,EARI,EAAS,KAQb,CACZ;QAEF,kBAAC,GAAD;SAAwB,YAAY,EAAqB;mBACvD,kBAAC,GAAD;UACE,WAAU;UACV,eAAe,KAAK,GAAY;UAChC,WAAW;UACX,UAAU,CAAC;oBACZ;UAEQ,CAAA;SACc,CAAA;QAExB,KACC,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,KAAD;SAAG,WAAU;mBAA2B;SAAU,CAAA,EAClD,kBAAC,OAAD;SAAK,WAAU;mBACZ;SACG,CAAA,CACF,EAAA,CAAA;QAEI;SACT,EAAA,CAAA;MACH,CAAA;KACF;MACF;;EACK,CAAA"}
|
|
1
|
+
{"version":3,"file":"PromptStudioPage.js","names":[],"sources":["../../../src/botlit/pages/PromptStudioPage.tsx"],"sourcesContent":["/**\n * Prompt Studio Page\n * @module botlit/pages\n */\n\nimport type { FC } from 'react';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Plus, Play, Tag } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { PagePurpose, GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../components/PageLayout';\nimport { Card, CardHeader, CardTitle, CardContent, CardDescription } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Input, Textarea, FormField } from '../components/Input';\nimport { Badge } from '../components/Badge';\nimport { EmptyState } from '../components/EmptyState';\nimport { ErrorState } from '../components/ErrorState';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport {\n usePromptTemplates,\n useRenderPromptTemplate,\n promptTemplateVariables,\n type PromptTemplateRecord,\n} from '../hooks';\nimport { graphqlErrorMessage } from '../utils/errors';\nimport { formatRelativeTime } from '../utils/formatters';\nimport type { PromptVariable } from '../types';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\n/** Normalises one entry of a template's free-form `variables` JSON. */\nfunction toPromptVariable(value: unknown): PromptVariable | null {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return null;\n const record = value as Record<string, unknown>;\n const name = typeof record.name === 'string' ? record.name : undefined;\n if (!name) return null;\n const type = typeof record.type === 'string' ? record.type : 'string';\n return {\n name,\n type: type as PromptVariable['type'],\n description: typeof record.description === 'string' ? record.description : undefined,\n required: record.required === true,\n defaultValue: record.defaultValue,\n };\n}\n\nfunction templateVariables(template: PromptTemplateRecord | undefined): PromptVariable[] {\n if (!template) return [];\n return promptTemplateVariables(template)\n .map(toPromptVariable)\n .filter((variable): variable is PromptVariable => variable !== null);\n}\n\nexport const PromptStudioPage: FC = () => {\n const { navigateTo } = useBotlit();\n const { data: templates, loading, error, refetch } = usePromptTemplates();\n const { render, loading: isRunning } = useRenderPromptTemplate();\n\n const [selectedPromptId, setSelectedPromptId] = useState<string | null>(null);\n const [testVariables, setTestVariables] = useState<Record<string, string>>({});\n const [testOutput, setTestOutput] = useState('');\n\n // Select the first template once the list arrives.\n useEffect(() => {\n if (!selectedPromptId && templates.length > 0) {\n setSelectedPromptId(templates[0].id);\n }\n }, [templates, selectedPromptId]);\n\n const selectedPrompt = useMemo(\n () => templates.find((template) => template.id === selectedPromptId),\n [templates, selectedPromptId]\n );\n\n const selectedVariables = useMemo(() => templateVariables(selectedPrompt), [selectedPrompt]);\n\n const handleTest = async () => {\n if (!selectedPrompt) return;\n try {\n // Rendered by wspace-botlit-svc so the preview matches what the agent\n // actually receives — never a client-side string substitution.\n const output = await render({\n templateId: selectedPrompt.id,\n variables: testVariables,\n });\n setTestOutput(output);\n } catch (err) {\n toast.error(graphqlErrorMessage(err, 'Failed to render prompt'));\n }\n };\n\n return (\n <PageLayout\n title=\"Prompt Studio\"\n description=\"Create, test, and manage prompts for your AI agents\"\n actions={\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.PROMPT_TEMPLATE_CREATE}>\n <Button leftIcon={<Plus size={16} />} onClick={() => navigateTo('prompt-templates/new')}>\n New Prompt\n </Button>\n </BotmanorPermissionGate>\n }\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<Play size={18} />}>\n Prompt Studio is your interactive workbench for writing and testing prompts before they go\n live. Pick a prompt, edit its text and variables on the left, then fill in sample values\n and hit Run Test to preview exactly what the agent will receive — so you can iterate on\n wording and catch mistakes here instead of in production.\n </PagePurpose>\n\n <div className=\"grid grid-cols-12 gap-6\">\n {/* Prompt List */}\n <div className=\"col-span-3\">\n <Card>\n <CardHeader>\n <CardTitle className=\"text-base\">Prompts</CardTitle>\n </CardHeader>\n <CardContent className=\"p-0\">\n {loading ? (\n <div className=\"space-y-2 p-4\">\n {[1, 2, 3].map((i) => (\n <div\n key={i}\n className=\"h-14 bg-bg-sunken motion-safe:animate-vc-shimmer rounded\"\n />\n ))}\n </div>\n ) : error ? (\n <ErrorState\n resource=\"prompt templates\"\n error={error}\n onRetry={() => void refetch()}\n className=\"m-4\"\n />\n ) : templates.length === 0 ? (\n <p className=\"p-4 text-sm text-text-secondary\">\n No prompt templates yet. Create one to start iterating.\n </p>\n ) : (\n <div className=\"divide-y divide-border-subtle\">\n {templates.map((prompt: PromptTemplateRecord) => (\n <button\n key={prompt.id}\n type=\"button\"\n className={`w-full text-left p-4 hover:bg-accent transition-colors ${\n selectedPrompt?.id === prompt.id ? 'bg-accent' : ''\n }`}\n onClick={() => {\n setSelectedPromptId(prompt.id);\n setTestVariables({});\n setTestOutput('');\n }}\n >\n <p className=\"font-medium truncate\">{prompt.name}</p>\n <p className=\"text-xs text-text-secondary mt-1 truncate\">\n v{prompt.version}\n </p>\n <div className=\"flex items-center gap-2 mt-2\">\n {prompt.visibility === 'PUBLIC' && (\n <Badge variant=\"secondary\" className=\"text-[10px]\">\n Public\n </Badge>\n )}\n <span className=\"text-xs text-text-secondary\">\n {templateVariables(prompt).length} vars\n </span>\n </div>\n </button>\n ))}\n </div>\n )}\n </CardContent>\n </Card>\n </div>\n\n {/* Editor */}\n <div className=\"col-span-6\">\n {selectedPrompt ? (\n <GlassCard treatment=\"glass\" glow className=\"overflow-hidden\">\n <CardHeader className=\"flex flex-row items-center justify-between\">\n <div>\n <CardTitle>{selectedPrompt.name}</CardTitle>\n <CardDescription>{selectedPrompt.description}</CardDescription>\n </div>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => navigateTo(`prompt-templates/${selectedPrompt.id}`)}\n >\n Open template\n </Button>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {/* Tags */}\n <div className=\"flex items-center gap-2\">\n <Tag size={14} className=\"text-text-secondary\" />\n {selectedPrompt.tags.map((tag) => (\n <Badge key={tag} variant=\"secondary\">\n {tag}\n </Badge>\n ))}\n </div>\n\n {/* Content */}\n <FormField label=\"Prompt Content\">\n <Textarea\n value={selectedPrompt.templateText}\n rows={15}\n readOnly\n className=\"font-mono text-sm\"\n />\n </FormField>\n\n {/* Variables */}\n {selectedVariables.length > 0 && (\n <div>\n <p className=\"text-sm font-medium mb-2\">Variables</p>\n <div className=\"space-y-2\">\n {selectedVariables.map((variable: PromptVariable) => (\n <div\n key={variable.name}\n className=\"flex items-center gap-4 p-3 bg-bg-sunken rounded-lg\"\n >\n <div className=\"flex-1\">\n <p className=\"font-medium text-sm\">\n {`{{${variable.name}}}`}\n {variable.required && (\n <span className=\"text-status-error-text ml-1\">*</span>\n )}\n </p>\n {variable.description && (\n <p className=\"text-xs text-text-secondary\">\n {variable.description}\n </p>\n )}\n </div>\n <Badge variant=\"outline\" className=\"capitalize\">\n {variable.type}\n </Badge>\n </div>\n ))}\n </div>\n </div>\n )}\n\n <div className=\"pt-4 text-xs text-text-secondary\">\n Updated {formatRelativeTime(selectedPrompt.updatedAt)}\n </div>\n </CardContent>\n </GlassCard>\n ) : (\n <EmptyState\n illustration=\"onboarding\"\n title=\"Select a prompt\"\n description=\"Choose a prompt from the list to view and edit\"\n />\n )}\n </div>\n\n {/* Test Panel */}\n <div className=\"col-span-3\">\n <Card>\n <CardHeader>\n <CardTitle className=\"text-base flex items-center gap-2\">\n <Play size={16} />\n Test Prompt\n </CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {selectedVariables.map((variable: PromptVariable) => (\n <FormField key={variable.name} label={variable.name}>\n <Input\n placeholder={variable.description || `Enter ${variable.name}`}\n value={testVariables[variable.name] || ''}\n onChange={(e) =>\n setTestVariables({ ...testVariables, [variable.name]: e.target.value })\n }\n />\n </FormField>\n ))}\n\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.PROMPT_TEMPLATE_EXECUTE}>\n <Button\n className=\"w-full\"\n onClick={() => void handleTest()}\n isLoading={isRunning}\n disabled={!selectedPrompt}\n >\n Run Test\n </Button>\n </BotmanorPermissionGate>\n\n {testOutput && (\n <div>\n <p className=\"text-sm font-medium mb-2\">Output</p>\n <div className=\"p-3 bg-bg-sunken rounded-lg text-sm whitespace-pre-wrap font-mono max-h-64 overflow-auto\">\n {testOutput}\n </div>\n </div>\n )}\n </CardContent>\n </Card>\n </div>\n </div>\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;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