@burdenoff/microfe-botmanor 2026.1101.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.
@@ -1,51 +1,53 @@
1
1
  import { useBotlit as e } from "../../providers/BotlitProvider.js";
2
- import { useCallback as t, useEffect as n, useLayoutEffect as r, useRef as i, useState as a } from "react";
3
- import { useGatewayClient as o } from "@burdenoff/fe-libs/shared/graphql";
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 l(e, t) {
12
- return e instanceof Error ? e : Error(t);
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 u(e) {
15
- let t = i(e);
16
- return r(() => {
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 d(e) {
21
- let { document: r, variables: i, enabled: o, errorMessage: c } = e, d = s(), f = u(e.select), p = u(e.fallback), [m, h] = a(e.fallback), [g, _] = a(!1), [v, y] = a(), b = t(async () => {
22
- if (!o) {
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 d.query({
29
- query: r,
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(l(e, c));
37
+ h(p.current), y(u(e, s));
36
38
  } finally {
37
39
  _(!1);
38
40
  }
39
41
  }, [
40
- d,
41
- r,
42
+ l,
43
+ t,
42
44
  i,
43
- o,
44
- c,
45
+ a,
46
+ s,
45
47
  p,
46
48
  f
47
49
  ]);
48
- return n(() => {
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 f(e) {
58
- let { document: n, errorMessage: r } = e, i = s(), o = u(e.variables), c = u(e.select), [d, f] = a({
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 [t(async (e) => {
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 t = await i.mutate({
71
- mutation: n,
72
- variables: o.current(e)
73
- }), a = c.current(t.data ?? void 0);
74
- if (a === void 0) throw Error(r);
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: a,
78
+ data: o,
77
79
  loading: !1,
78
80
  error: void 0
79
- }), a;
81
+ }), o;
80
82
  } catch (e) {
81
- let t = l(e, r);
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
- n,
92
+ t,
91
93
  r,
92
- c,
93
- o
94
- ]), d];
94
+ s,
95
+ a
96
+ ]), l];
95
97
  }
96
98
  //#endregion
97
- export { s as useWorkspaceClient, c as useWorkspaceId, f as useWorkspaceMutation, d as useWorkspaceQuery };
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":";;;;AAqBA,SAAgB,IAAsC;AACpD,QAAO,EAAiB,YAAY;;AAItC,SAAgB,IAAqC;AACnD,QAAO,GAAW,CAAC;;AAiBrB,SAAS,EAAQ,GAAgB,GAAgC;AAE/D,QADI,aAAiB,QAAc,IACxB,MAAM,EAAgB;;AAInC,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,EA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,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
+ {"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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N;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,18 +1,18 @@
1
1
  import { useBotlit as e } from "../providers/BotlitProvider.js";
2
- import { formatRelativeTime as t } from "../utils/formatters.js";
3
- import { BOTMANOR_PERMISSIONS as n } from "../permissions/botmanorPermissions.js";
4
- import { BotmanorPermissionGate as r } from "../permissions/useBotmanorPermissions.js";
5
- import { PageLayout as i } from "../components/PageLayout.js";
6
- import { Button as a } from "../components/Button.js";
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 o, CardContent as s, CardDescription as c, CardHeader as l, CardTitle as u } from "../components/Card.js";
9
- import { Badge as d } from "../components/Badge.js";
10
- import { EmptyState as f } from "../components/EmptyState.js";
11
- import { FormField as p, Input as m, Textarea as h } from "../components/Input.js";
12
- import { ErrorState as g } from "../components/ErrorState.js";
13
- import { promptTemplateVariables as _, usePromptTemplates as v, useRenderPromptTemplate as y } from "../hooks/usePromptTemplates.js";
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 { graphqlErrorMessage as b } from "../utils/errors.js";
16
16
  import { useEffect as x, useMemo as S, useState as C } from "react";
17
17
  import { GlassCard as w, PagePurpose as T } from "@burdenoff/fe-libs/ui";
18
18
  import { jsx as E, jsxs as D } from "react/jsx-runtime";
@@ -31,10 +31,10 @@ function M(e) {
31
31
  } : null;
32
32
  }
33
33
  function N(e) {
34
- return e ? _(e).map(M).filter((e) => e !== null) : [];
34
+ return e ? v(e).map(M).filter((e) => e !== null) : [];
35
35
  }
36
36
  var P = () => {
37
- let { navigateTo: _ } = e(), { data: M, loading: P, error: F, refetch: I } = v(), { render: L, loading: R } = y(), [z, B] = C(null), [V, H] = C({}), [U, W] = C("");
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
38
  x(() => {
39
39
  !z && M.length > 0 && B(M[0].id);
40
40
  }, [M, z]);
@@ -45,17 +45,17 @@ var P = () => {
45
45
  variables: V
46
46
  }));
47
47
  } catch (e) {
48
- j.error(b(e, "Failed to render prompt"));
48
+ j.error(t(e, "Failed to render prompt"));
49
49
  }
50
50
  };
51
- return /* @__PURE__ */ E(i, {
51
+ return /* @__PURE__ */ E(a, {
52
52
  title: "Prompt Studio",
53
53
  description: "Create, test, and manage prompts for your AI agents",
54
- actions: /* @__PURE__ */ E(r, {
55
- permission: n.PROMPT_TEMPLATE_CREATE,
56
- children: /* @__PURE__ */ E(a, {
54
+ actions: /* @__PURE__ */ E(i, {
55
+ permission: r.PROMPT_TEMPLATE_CREATE,
56
+ children: /* @__PURE__ */ E(o, {
57
57
  leftIcon: /* @__PURE__ */ E(k, { size: 16 }),
58
- onClick: () => _("prompt-templates/new"),
58
+ onClick: () => v("prompt-templates/new"),
59
59
  children: "New Prompt"
60
60
  })
61
61
  }),
@@ -69,10 +69,10 @@ var P = () => {
69
69
  children: [
70
70
  /* @__PURE__ */ E("div", {
71
71
  className: "col-span-3",
72
- children: /* @__PURE__ */ D(o, { children: [/* @__PURE__ */ E(l, { children: /* @__PURE__ */ E(u, {
72
+ children: /* @__PURE__ */ D(s, { children: [/* @__PURE__ */ E(u, { children: /* @__PURE__ */ E(d, {
73
73
  className: "text-base",
74
74
  children: "Prompts"
75
- }) }), /* @__PURE__ */ E(s, {
75
+ }) }), /* @__PURE__ */ E(c, {
76
76
  className: "p-0",
77
77
  children: P ? /* @__PURE__ */ E("div", {
78
78
  className: "space-y-2 p-4",
@@ -81,7 +81,7 @@ var P = () => {
81
81
  2,
82
82
  3
83
83
  ].map((e) => /* @__PURE__ */ E("div", { className: "h-14 bg-bg-sunken motion-safe:animate-vc-shimmer rounded" }, e))
84
- }) : F ? /* @__PURE__ */ E(g, {
84
+ }) : F ? /* @__PURE__ */ E(_, {
85
85
  resource: "prompt templates",
86
86
  error: F,
87
87
  onRetry: () => void I(),
@@ -108,7 +108,7 @@ var P = () => {
108
108
  }),
109
109
  /* @__PURE__ */ D("div", {
110
110
  className: "flex items-center gap-2 mt-2",
111
- children: [e.visibility === "PUBLIC" && /* @__PURE__ */ E(d, {
111
+ children: [e.visibility === "PUBLIC" && /* @__PURE__ */ E(f, {
112
112
  variant: "secondary",
113
113
  className: "text-[10px]",
114
114
  children: "Public"
@@ -128,15 +128,15 @@ var P = () => {
128
128
  treatment: "glass",
129
129
  glow: !0,
130
130
  className: "overflow-hidden",
131
- children: [/* @__PURE__ */ D(l, {
131
+ children: [/* @__PURE__ */ D(u, {
132
132
  className: "flex flex-row items-center justify-between",
133
- children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E(u, { children: G.name }), /* @__PURE__ */ E(c, { children: G.description })] }), /* @__PURE__ */ E(a, {
133
+ children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E(d, { children: G.name }), /* @__PURE__ */ E(l, { children: G.description })] }), /* @__PURE__ */ E(o, {
134
134
  size: "sm",
135
135
  variant: "outline",
136
- onClick: () => _(`prompt-templates/${G.id}`),
136
+ onClick: () => v(`prompt-templates/${G.id}`),
137
137
  children: "Open template"
138
138
  })]
139
- }), /* @__PURE__ */ D(s, {
139
+ }), /* @__PURE__ */ D(c, {
140
140
  className: "space-y-4",
141
141
  children: [
142
142
  /* @__PURE__ */ D("div", {
@@ -144,14 +144,14 @@ var P = () => {
144
144
  children: [/* @__PURE__ */ E(A, {
145
145
  size: 14,
146
146
  className: "text-text-secondary"
147
- }), G.tags.map((e) => /* @__PURE__ */ E(d, {
147
+ }), G.tags.map((e) => /* @__PURE__ */ E(f, {
148
148
  variant: "secondary",
149
149
  children: e
150
150
  }, e))]
151
151
  }),
152
- /* @__PURE__ */ E(p, {
152
+ /* @__PURE__ */ E(m, {
153
153
  label: "Prompt Content",
154
- children: /* @__PURE__ */ E(h, {
154
+ children: /* @__PURE__ */ E(g, {
155
155
  value: G.templateText,
156
156
  rows: 15,
157
157
  readOnly: !0,
@@ -177,7 +177,7 @@ var P = () => {
177
177
  className: "text-xs text-text-secondary",
178
178
  children: e.description
179
179
  })]
180
- }), /* @__PURE__ */ E(d, {
180
+ }), /* @__PURE__ */ E(f, {
181
181
  variant: "outline",
182
182
  className: "capitalize",
183
183
  children: e.type
@@ -186,11 +186,11 @@ var P = () => {
186
186
  })] }),
187
187
  /* @__PURE__ */ D("div", {
188
188
  className: "pt-4 text-xs text-text-secondary",
189
- children: ["Updated ", t(G.updatedAt)]
189
+ children: ["Updated ", n(G.updatedAt)]
190
190
  })
191
191
  ]
192
192
  })]
193
- }) : /* @__PURE__ */ E(f, {
193
+ }) : /* @__PURE__ */ E(p, {
194
194
  illustration: "onboarding",
195
195
  title: "Select a prompt",
196
196
  description: "Choose a prompt from the list to view and edit"
@@ -198,15 +198,15 @@ var P = () => {
198
198
  }),
199
199
  /* @__PURE__ */ E("div", {
200
200
  className: "col-span-3",
201
- children: /* @__PURE__ */ D(o, { children: [/* @__PURE__ */ E(l, { children: /* @__PURE__ */ D(u, {
201
+ children: /* @__PURE__ */ D(s, { children: [/* @__PURE__ */ E(u, { children: /* @__PURE__ */ D(d, {
202
202
  className: "text-base flex items-center gap-2",
203
203
  children: [/* @__PURE__ */ E(O, { size: 16 }), "Test Prompt"]
204
- }) }), /* @__PURE__ */ D(s, {
204
+ }) }), /* @__PURE__ */ D(c, {
205
205
  className: "space-y-4",
206
206
  children: [
207
- K.map((e) => /* @__PURE__ */ E(p, {
207
+ K.map((e) => /* @__PURE__ */ E(m, {
208
208
  label: e.name,
209
- children: /* @__PURE__ */ E(m, {
209
+ children: /* @__PURE__ */ E(h, {
210
210
  placeholder: e.description || `Enter ${e.name}`,
211
211
  value: V[e.name] || "",
212
212
  onChange: (t) => H({
@@ -215,9 +215,9 @@ var P = () => {
215
215
  })
216
216
  })
217
217
  }, e.name)),
218
- /* @__PURE__ */ E(r, {
219
- permission: n.PROMPT_TEMPLATE_EXECUTE,
220
- children: /* @__PURE__ */ E(a, {
218
+ /* @__PURE__ */ E(i, {
219
+ permission: r.PROMPT_TEMPLATE_EXECUTE,
220
+ children: /* @__PURE__ */ E(o, {
221
221
  className: "w-full",
222
222
  onClick: () => void q(),
223
223
  isLoading: R,