@burdenoff/microfe-labsofscience 2026.801.2 → 2026.820.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/generated/wspace-types.d.ts +68885 -33499
  2. package/dist/generated/wspace-types.d.ts.map +1 -1
  3. package/dist/labsofscience/LabsOfScienceRoot.d.ts.map +1 -1
  4. package/dist/labsofscience/LabsOfScienceRoot.js +57 -49
  5. package/dist/labsofscience/LabsOfScienceRoot.js.map +1 -1
  6. package/dist/labsofscience/LabsOfScienceRoutes.d.ts.map +1 -1
  7. package/dist/labsofscience/LabsOfScienceRoutes.js +10 -6
  8. package/dist/labsofscience/LabsOfScienceRoutes.js.map +1 -1
  9. package/dist/labsofscience/components/BottomNav.d.ts.map +1 -1
  10. package/dist/labsofscience/components/BottomNav.js +36 -30
  11. package/dist/labsofscience/components/BottomNav.js.map +1 -1
  12. package/dist/labsofscience/components/MetricsCard.d.ts +1 -2
  13. package/dist/labsofscience/components/MetricsCard.d.ts.map +1 -1
  14. package/dist/labsofscience/components/MetricsCard.js.map +1 -1
  15. package/dist/labsofscience/components/StatusBadge.d.ts.map +1 -1
  16. package/dist/labsofscience/components/StatusBadge.js +10 -1
  17. package/dist/labsofscience/components/StatusBadge.js.map +1 -1
  18. package/dist/labsofscience/hooks/index.d.ts +1 -1
  19. package/dist/labsofscience/hooks/index.d.ts.map +1 -1
  20. package/dist/labsofscience/hooks/useLabsOfScienceApi.d.ts +82 -1
  21. package/dist/labsofscience/hooks/useLabsOfScienceApi.d.ts.map +1 -1
  22. package/dist/labsofscience/hooks/useLabsOfScienceApi.js +326 -199
  23. package/dist/labsofscience/hooks/useLabsOfScienceApi.js.map +1 -1
  24. package/dist/labsofscience/pages/ai/AiDialogs.d.ts +20 -0
  25. package/dist/labsofscience/pages/ai/AiDialogs.d.ts.map +1 -0
  26. package/dist/labsofscience/pages/ai/AiDialogs.js +566 -0
  27. package/dist/labsofscience/pages/ai/AiDialogs.js.map +1 -0
  28. package/dist/labsofscience/pages/ai/AiErrorNotice.d.ts +20 -0
  29. package/dist/labsofscience/pages/ai/AiErrorNotice.d.ts.map +1 -0
  30. package/dist/labsofscience/pages/ai/AiErrorNotice.js +67 -0
  31. package/dist/labsofscience/pages/ai/AiErrorNotice.js.map +1 -0
  32. package/dist/labsofscience/pages/ai/AiOperationsPage.d.ts +29 -0
  33. package/dist/labsofscience/pages/ai/AiOperationsPage.d.ts.map +1 -0
  34. package/dist/labsofscience/pages/ai/AiOperationsPage.js +196 -0
  35. package/dist/labsofscience/pages/ai/AiOperationsPage.js.map +1 -0
  36. package/dist/labsofscience/pages/ai/DecisionCard.d.ts +9 -0
  37. package/dist/labsofscience/pages/ai/DecisionCard.d.ts.map +1 -0
  38. package/dist/labsofscience/pages/ai/DecisionCard.js +282 -0
  39. package/dist/labsofscience/pages/ai/DecisionCard.js.map +1 -0
  40. package/dist/labsofscience/pages/ai/ModelSettings.d.ts +20 -0
  41. package/dist/labsofscience/pages/ai/ModelSettings.d.ts.map +1 -0
  42. package/dist/labsofscience/pages/ai/ModelSettings.js +141 -0
  43. package/dist/labsofscience/pages/ai/ModelSettings.js.map +1 -0
  44. package/dist/labsofscience/pages/ai/aiReaders.d.ts +82 -0
  45. package/dist/labsofscience/pages/ai/aiReaders.d.ts.map +1 -0
  46. package/dist/labsofscience/pages/ai/aiReaders.js +86 -0
  47. package/dist/labsofscience/pages/ai/aiReaders.js.map +1 -0
  48. package/dist/labsofscience/pages/experiments/ExperimentDetailPage.js +18 -18
  49. package/dist/labsofscience/pages/experiments/ExperimentsListPage.js +6 -6
  50. package/dist/labsofscience/pages/instruments/InstrumentDetailPage.js +14 -14
  51. package/dist/labsofscience/pages/instruments/InstrumentsListPage.js +6 -6
  52. package/dist/labsofscience/pages/projects/ProjectDetailPage.js +16 -16
  53. package/dist/labsofscience/pages/projects/ProjectsListPage.js +6 -6
  54. package/dist/labsofscience/types/index.d.ts +133 -2
  55. package/dist/labsofscience/types/index.d.ts.map +1 -1
  56. package/dist/services/createSandboxAssistantTransport.js +6 -6
  57. package/dist/services/createSandboxAssistantTransport.js.map +1 -1
  58. package/dist/utils/pageContext.d.ts +13 -0
  59. package/dist/utils/pageContext.d.ts.map +1 -1
  60. package/dist/utils/pageContext.js +89 -26
  61. package/dist/utils/pageContext.js.map +1 -1
  62. package/package.json +2 -2
@@ -0,0 +1,20 @@
1
+ import { FC } from 'react';
2
+
3
+ /** Server-side error code for an unconfigured / unreachable model provider. */
4
+ export declare const AI_PROVIDER_UNAVAILABLE = "AI_PROVIDER_UNAVAILABLE";
5
+ export interface AiFailure {
6
+ code: string | null;
7
+ message: string;
8
+ /** The FAILED ledger row this attempt was recorded as, when the server sent one. */
9
+ agentRunId: string | null;
10
+ isProviderUnavailable: boolean;
11
+ }
12
+ /** Normalise any thrown value into something renderable, never throwing itself. */
13
+ export declare function describeAiFailure(error: unknown, fallback: string): AiFailure;
14
+ export declare const AiErrorNotice: FC<{
15
+ error: unknown;
16
+ /** Used when the thrown value carries no message of its own. */
17
+ fallback: string;
18
+ className?: string;
19
+ }>;
20
+ //# sourceMappingURL=AiErrorNotice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiErrorNotice.d.ts","sourceRoot":"","sources":["../../../../src/labsofscience/pages/ai/AiErrorNotice.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKhC,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAe7E;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAyCA,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { cn as e } from "../../utils/cn.js";
2
+ import { LabApiError as t } from "../../hooks/useLabsOfScienceApi.js";
3
+ import { AlertTriangle as n, PlugZap as r } from "lucide-react";
4
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
+ //#region src/labsofscience/pages/ai/AiErrorNotice.tsx
6
+ var o = "AI_PROVIDER_UNAVAILABLE";
7
+ function s(e, n) {
8
+ return e instanceof t ? {
9
+ code: e.code,
10
+ message: e.message || n,
11
+ agentRunId: e.agentRunId,
12
+ isProviderUnavailable: e.code === o
13
+ } : {
14
+ code: null,
15
+ message: e instanceof Error && e.message ? e.message : n,
16
+ agentRunId: null,
17
+ isProviderUnavailable: !1
18
+ };
19
+ }
20
+ var c = ({ error: t, fallback: o, className: c }) => {
21
+ if (t == null) return null;
22
+ let l = s(t, o);
23
+ return /* @__PURE__ */ i("div", {
24
+ role: "alert",
25
+ className: e("rounded-lg border border-border-seam bg-status-error-bg-subtle p-3 text-sm", c),
26
+ children: /* @__PURE__ */ a("div", {
27
+ className: "flex items-start gap-2",
28
+ children: [/* @__PURE__ */ i("span", {
29
+ className: "mt-0.5 shrink-0 text-status-error-text",
30
+ "aria-hidden": "true",
31
+ children: l.isProviderUnavailable ? /* @__PURE__ */ i(r, { className: "h-4 w-4" }) : /* @__PURE__ */ i(n, { className: "h-4 w-4" })
32
+ }), /* @__PURE__ */ a("div", {
33
+ className: "min-w-0 space-y-1",
34
+ children: [
35
+ /* @__PURE__ */ i("p", {
36
+ className: "font-medium text-status-error-text",
37
+ children: l.isProviderUnavailable ? "AI provider unavailable" : "That decision failed"
38
+ }),
39
+ /* @__PURE__ */ i("p", {
40
+ className: "break-words text-text-secondary",
41
+ children: l.message
42
+ }),
43
+ l.isProviderUnavailable && /* @__PURE__ */ i("p", {
44
+ className: "text-text-tertiary",
45
+ children: "No provider key is configured for this deployment, or every configured provider refused the call. Nothing was written to your protocols or experiments."
46
+ }),
47
+ l.agentRunId && /* @__PURE__ */ a("p", {
48
+ className: "text-xs text-text-tertiary",
49
+ children: [
50
+ "Recorded in the decision feed as",
51
+ " ",
52
+ /* @__PURE__ */ i("span", {
53
+ className: "break-all font-mono",
54
+ children: l.agentRunId
55
+ }),
56
+ "."
57
+ ]
58
+ })
59
+ ]
60
+ })]
61
+ })
62
+ });
63
+ };
64
+ //#endregion
65
+ export { o as AI_PROVIDER_UNAVAILABLE, c as AiErrorNotice, s as describeAiFailure };
66
+
67
+ //# sourceMappingURL=AiErrorNotice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiErrorNotice.js","names":[],"sources":["../../../../src/labsofscience/pages/ai/AiErrorNotice.tsx"],"sourcesContent":["/**\n * Failure surface for AI decision actions.\n * @module labsofscience/pages/ai\n *\n * `wspace-labsofscience-svc` distinguishes \"the model provider is not\n * configured or is unreachable\" (`AI_PROVIDER_UNAVAILABLE`) from every other\n * failure, and pays for that distinction by writing a FAILED row to the\n * decision ledger before throwing — the error carries that row's id in\n * `extensions.agentRunId`. Rendering it as a generic \"something went wrong\"\n * would throw away the one identifier that lets a researcher (or an operator\n * reading over their shoulder) find what actually happened in the feed below.\n */\n\nimport type { FC } from 'react';\nimport { AlertTriangle, PlugZap } from 'lucide-react';\nimport { LabApiError } from '../../hooks/useLabsOfScienceApi';\nimport { cn } from '../../utils/cn';\n\n/** Server-side error code for an unconfigured / unreachable model provider. */\nexport const AI_PROVIDER_UNAVAILABLE = 'AI_PROVIDER_UNAVAILABLE';\n\nexport interface AiFailure {\n code: string | null;\n message: string;\n /** The FAILED ledger row this attempt was recorded as, when the server sent one. */\n agentRunId: string | null;\n isProviderUnavailable: boolean;\n}\n\n/** Normalise any thrown value into something renderable, never throwing itself. */\nexport function describeAiFailure(error: unknown, fallback: string): AiFailure {\n if (error instanceof LabApiError) {\n return {\n code: error.code,\n message: error.message || fallback,\n agentRunId: error.agentRunId,\n isProviderUnavailable: error.code === AI_PROVIDER_UNAVAILABLE,\n };\n }\n return {\n code: null,\n message: error instanceof Error && error.message ? error.message : fallback,\n agentRunId: null,\n isProviderUnavailable: false,\n };\n}\n\nexport const AiErrorNotice: FC<{\n error: unknown;\n /** Used when the thrown value carries no message of its own. */\n fallback: string;\n className?: string;\n}> = ({ error, fallback, className }) => {\n if (error === null || error === undefined) return null;\n const failure = describeAiFailure(error, fallback);\n\n return (\n <div\n role=\"alert\"\n className={cn(\n 'rounded-lg border border-border-seam bg-status-error-bg-subtle p-3 text-sm',\n className\n )}\n >\n <div className=\"flex items-start gap-2\">\n <span className=\"mt-0.5 shrink-0 text-status-error-text\" aria-hidden=\"true\">\n {failure.isProviderUnavailable ? (\n <PlugZap className=\"h-4 w-4\" />\n ) : (\n <AlertTriangle className=\"h-4 w-4\" />\n )}\n </span>\n <div className=\"min-w-0 space-y-1\">\n <p className=\"font-medium text-status-error-text\">\n {failure.isProviderUnavailable ? 'AI provider unavailable' : 'That decision failed'}\n </p>\n <p className=\"break-words text-text-secondary\">{failure.message}</p>\n {failure.isProviderUnavailable && (\n <p className=\"text-text-tertiary\">\n No provider key is configured for this deployment, or every configured provider\n refused the call. Nothing was written to your protocols or experiments.\n </p>\n )}\n {failure.agentRunId && (\n <p className=\"text-xs text-text-tertiary\">\n Recorded in the decision feed as{' '}\n <span className=\"break-all font-mono\">{failure.agentRunId}</span>.\n </p>\n )}\n </div>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;AAmBA,IAAa,IAA0B;AAWvC,SAAgB,EAAkB,GAAgB,GAA6B;CAS7E,OARI,aAAiB,IACZ;EACL,MAAM,EAAM;EACZ,SAAS,EAAM,WAAW;EAC1B,YAAY,EAAM;EAClB,uBAAuB,EAAM,SAAS;CACxC,IAEK;EACL,MAAM;EACN,SAAS,aAAiB,SAAS,EAAM,UAAU,EAAM,UAAU;EACnE,YAAY;EACZ,uBAAuB;CACzB;AACF;AAEA,IAAa,KAKP,EAAE,UAAO,aAAU,mBAAgB;CACvC,IAAI,KAAU,MAA6B,OAAO;CAClD,IAAM,IAAU,EAAkB,GAAO,CAAQ;CAEjD,OACE,kBAAC,OAAD;EACE,MAAK;EACL,WAAW,EACT,8EACA,CACF;YAEA,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,QAAD;IAAM,WAAU;IAAyC,eAAY;cAClE,EAAQ,wBACP,kBAAC,GAAD,EAAS,WAAU,UAAW,CAAA,IAE9B,kBAAC,GAAD,EAAe,WAAU,UAAW,CAAA;GAElC,CAAA,GACN,kBAAC,OAAD;IAAK,WAAU;cAAf;KACE,kBAAC,KAAD;MAAG,WAAU;gBACV,EAAQ,wBAAwB,4BAA4B;KAC5D,CAAA;KACH,kBAAC,KAAD;MAAG,WAAU;gBAAmC,EAAQ;KAAW,CAAA;KAClE,EAAQ,yBACP,kBAAC,KAAD;MAAG,WAAU;gBAAqB;KAG/B,CAAA;KAEJ,EAAQ,cACP,kBAAC,KAAD;MAAG,WAAU;gBAAb;OAA0C;OACP;OACjC,kBAAC,QAAD;QAAM,WAAU;kBAAuB,EAAQ;OAAiB,CAAA;OAAC;MAChE;;IAEF;KACF;;CACF,CAAA;AAET"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * AI Operations (BOFF-3586)
3
+ * @module labsofscience/pages/ai
4
+ *
5
+ * The researcher-facing surface of the AI decision engine, in three parts:
6
+ *
7
+ * 1. **Model & autopilot** — the workspace's default (provider, model) pair and
8
+ * its opt-in to the autonomous loop (`ModelSettings`).
9
+ * 2. **Decision feed** — `labAgentRuns`, newest first, offset-paginated. The
10
+ * ledger is append-only and records failures too, so the table shows the
11
+ * `error` text for FAILED rows rather than hiding them.
12
+ * 3. **Decisions** — the same page of rows rendered as cards with their
13
+ * `decision` payload and `inputRefs` provenance, each with the researcher
14
+ * override wired to `labOverrideAgentRun`.
15
+ *
16
+ * The feed and the cards are one query, not two: they are two readings of the
17
+ * same page of the ledger, and fetching it twice would let them disagree.
18
+ *
19
+ * Paging is offset-based. The composed workspace supergraph's `PaginationInput`
20
+ * has no `cursor` field (Federation intersects input types and two other
21
+ * subgraphs declare a narrower one), so `pageInfo.cursor` is informational only.
22
+ *
23
+ * `labAgentRuns` is legitimately empty until a decision actually runs — in
24
+ * production it will be, because the AI actions are opt-in and the loop is off.
25
+ * That state renders as "No decisions yet" with the actions that would create
26
+ * one, never as an error and never as a spinner that never resolves.
27
+ */
28
+ export declare function AiOperationsPage(): import("react").JSX.Element;
29
+ //# sourceMappingURL=AiOperationsPage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiOperationsPage.d.ts","sourceRoot":"","sources":["../../../../src/labsofscience/pages/ai/AiOperationsPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA2BH,wBAAgB,gBAAgB,gCA6M/B"}
@@ -0,0 +1,196 @@
1
+ import { useLabsOfScience as e } from "../../context/LabsOfScienceContext.js";
2
+ import { PageLayout as t } from "../../components/PageLayout.js";
3
+ import { StatusBadge as n } from "../../components/StatusBadge.js";
4
+ import { QueryBoundary as r } from "../../components/QueryStates.js";
5
+ import { useAgentRuns as i } from "../../hooks/useLabsOfScienceApi.js";
6
+ import { formatDate as a, formatRelativeTime as o, titleCase as s } from "../../utils/formatters.js";
7
+ import { EmptyState as c } from "../../components/EmptyState.js";
8
+ import { useLabActorNames as l } from "../../hooks/useLabActorNames.js";
9
+ import { DetailSection as u } from "../shared/DetailComponents.js";
10
+ import { describeDecision as d, formatLatency as f, formatTokens as p } from "./aiReaders.js";
11
+ import { OverrideDecisionDialog as m, RecommendNextRunDialog as h, SuggestProtocolDialog as g } from "./AiDialogs.js";
12
+ import { DecisionCard as _ } from "./DecisionCard.js";
13
+ import { ModelSettings as v } from "./ModelSettings.js";
14
+ import { useState as y } from "react";
15
+ import { History as b, Sparkles as x, Wand2 as S } from "lucide-react";
16
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
17
+ import { Button as E, Pagination as D, ResponsiveTable as O } from "@burdenoff/fe-libs/ui";
18
+ //#region src/labsofscience/pages/ai/AiOperationsPage.tsx
19
+ var k = 20;
20
+ function A() {
21
+ let { navigateTo: A } = e(), [j, M] = y(1), [N, P] = y(!1), [F, I] = y(!1), [L, R] = y(null), z = i({ pagination: {
22
+ limit: k,
23
+ offset: (j - 1) * k
24
+ } }), B = z.data?.items ?? [], V = z.data?.pageInfo.hasMore ?? !1, { nameOf: H } = l(B.map((e) => e.actorType === "user" ? e.actorId : null)), U = B.filter((e) => d(e.decision).kind !== "none");
25
+ return /* @__PURE__ */ T(t, {
26
+ title: "AI Operations",
27
+ description: "The model this workspace uses, every decision it has taken, and your call on each one.",
28
+ actions: /* @__PURE__ */ T("div", {
29
+ className: "flex flex-wrap items-center gap-2",
30
+ children: [/* @__PURE__ */ T(E, {
31
+ variant: "outline",
32
+ onClick: () => P(!0),
33
+ children: [/* @__PURE__ */ w(S, { className: "mr-2 h-4 w-4" }), "Suggest protocol"]
34
+ }), /* @__PURE__ */ T(E, {
35
+ onClick: () => I(!0),
36
+ children: [/* @__PURE__ */ w(x, { className: "mr-2 h-4 w-4" }), "Recommend next run"]
37
+ })]
38
+ }),
39
+ children: [
40
+ /* @__PURE__ */ T("div", {
41
+ className: "space-y-6",
42
+ children: [
43
+ /* @__PURE__ */ w(v, {}),
44
+ /* @__PURE__ */ w(u, {
45
+ title: "Decision feed",
46
+ children: /* @__PURE__ */ w(r, {
47
+ isLoading: z.isLoading,
48
+ isError: z.isError,
49
+ error: z.error,
50
+ onRetry: () => void z.refetch(),
51
+ loadingLabel: "Loading decisions…",
52
+ children: B.length === 0 ? /* @__PURE__ */ w(c, {
53
+ icon: /* @__PURE__ */ w(b, { className: "h-10 w-10" }),
54
+ title: "No decisions yet",
55
+ description: "Nothing has been asked of the AI in this workspace. Every attempt — including the ones that fail — is recorded here, newest first.",
56
+ action: /* @__PURE__ */ T("div", {
57
+ className: "flex flex-wrap items-center justify-center gap-2",
58
+ children: [/* @__PURE__ */ T(E, {
59
+ variant: "outline",
60
+ onClick: () => P(!0),
61
+ children: [/* @__PURE__ */ w(S, { className: "mr-2 h-4 w-4" }), "Suggest protocol"]
62
+ }), /* @__PURE__ */ T(E, {
63
+ onClick: () => I(!0),
64
+ children: [/* @__PURE__ */ w(x, { className: "mr-2 h-4 w-4" }), "Recommend next run"]
65
+ })]
66
+ })
67
+ }) : /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(O, {
68
+ columns: [
69
+ {
70
+ key: "when",
71
+ header: "When",
72
+ priority: "primary",
73
+ cell: (e) => /* @__PURE__ */ w("time", {
74
+ dateTime: e.createdAt,
75
+ title: a(e.createdAt),
76
+ className: "text-text-secondary",
77
+ children: o(e.createdAt)
78
+ })
79
+ },
80
+ {
81
+ key: "status",
82
+ header: "Status",
83
+ priority: "primary",
84
+ cell: (e) => /* @__PURE__ */ w(n, { status: e.status })
85
+ },
86
+ {
87
+ key: "trigger",
88
+ header: "Trigger",
89
+ cell: (e) => /* @__PURE__ */ w(n, { status: e.trigger })
90
+ },
91
+ {
92
+ key: "model",
93
+ header: "Model",
94
+ priority: "hidden-on-mobile",
95
+ cell: (e) => /* @__PURE__ */ T("div", {
96
+ className: "min-w-0",
97
+ children: [/* @__PURE__ */ w("p", {
98
+ className: "truncate text-text-primary",
99
+ children: e.model
100
+ }), /* @__PURE__ */ w("p", {
101
+ className: "truncate text-xs text-text-tertiary",
102
+ children: e.provider
103
+ })]
104
+ })
105
+ },
106
+ {
107
+ key: "actor",
108
+ header: "Requested by",
109
+ priority: "hidden-on-mobile",
110
+ cell: (e) => /* @__PURE__ */ w("span", {
111
+ className: "text-text-secondary",
112
+ children: e.actorType === "user" ? H(e.actorId) : s(e.actorType)
113
+ })
114
+ },
115
+ {
116
+ key: "latency",
117
+ header: "Latency",
118
+ priority: "hidden-on-mobile",
119
+ cell: (e) => /* @__PURE__ */ w("span", {
120
+ className: "tabular-nums text-text-secondary",
121
+ children: f(e.latencyMs)
122
+ })
123
+ },
124
+ {
125
+ key: "tokens",
126
+ header: "Tokens",
127
+ priority: "hidden-on-mobile",
128
+ cell: (e) => /* @__PURE__ */ w("span", {
129
+ className: "tabular-nums text-text-secondary",
130
+ children: p(e.tokensIn, e.tokensOut)
131
+ })
132
+ },
133
+ {
134
+ key: "detail",
135
+ header: "Detail",
136
+ cell: (e) => e.error ? /* @__PURE__ */ w("span", {
137
+ className: "break-words text-xs text-status-error-text",
138
+ children: e.error
139
+ }) : /* @__PURE__ */ w("span", {
140
+ className: "line-clamp-2 text-xs text-text-tertiary",
141
+ children: e.promptSummary
142
+ })
143
+ }
144
+ ],
145
+ data: B,
146
+ rowKey: (e) => e.id
147
+ }), /* @__PURE__ */ w(D, {
148
+ page: j,
149
+ pageSize: k,
150
+ hasNextPage: V,
151
+ hasPreviousPage: j > 1,
152
+ loading: z.isFetching,
153
+ onPageChange: M,
154
+ className: "mt-4"
155
+ })] })
156
+ })
157
+ }),
158
+ B.length > 0 && /* @__PURE__ */ w(u, {
159
+ title: `Decisions on this page (${U.length})`,
160
+ children: U.length === 0 ? /* @__PURE__ */ w("p", {
161
+ className: "py-6 text-center text-sm text-text-secondary",
162
+ children: "None of the entries on this page reached a decision."
163
+ }) : /* @__PURE__ */ w("div", {
164
+ className: "space-y-4",
165
+ children: U.map((e) => /* @__PURE__ */ w(_, {
166
+ run: e,
167
+ onOverride: R,
168
+ onOpenExperiment: (e) => A(`experiments/${e}`)
169
+ }, e.id))
170
+ })
171
+ })
172
+ ]
173
+ }),
174
+ /* @__PURE__ */ w(g, {
175
+ open: N,
176
+ onOpenChange: P,
177
+ onViewProtocol: (e) => A(`protocols/${e}`)
178
+ }),
179
+ /* @__PURE__ */ w(h, {
180
+ open: F,
181
+ onOpenChange: I,
182
+ onViewExperiment: (e) => A(`experiments/${e}`)
183
+ }),
184
+ /* @__PURE__ */ w(m, {
185
+ run: L,
186
+ onOpenChange: (e) => {
187
+ e || R(null);
188
+ }
189
+ })
190
+ ]
191
+ });
192
+ }
193
+ //#endregion
194
+ export { A as AiOperationsPage };
195
+
196
+ //# sourceMappingURL=AiOperationsPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiOperationsPage.js","names":[],"sources":["../../../../src/labsofscience/pages/ai/AiOperationsPage.tsx"],"sourcesContent":["/**\n * AI Operations (BOFF-3586)\n * @module labsofscience/pages/ai\n *\n * The researcher-facing surface of the AI decision engine, in three parts:\n *\n * 1. **Model & autopilot** — the workspace's default (provider, model) pair and\n * its opt-in to the autonomous loop (`ModelSettings`).\n * 2. **Decision feed** — `labAgentRuns`, newest first, offset-paginated. The\n * ledger is append-only and records failures too, so the table shows the\n * `error` text for FAILED rows rather than hiding them.\n * 3. **Decisions** — the same page of rows rendered as cards with their\n * `decision` payload and `inputRefs` provenance, each with the researcher\n * override wired to `labOverrideAgentRun`.\n *\n * The feed and the cards are one query, not two: they are two readings of the\n * same page of the ledger, and fetching it twice would let them disagree.\n *\n * Paging is offset-based. The composed workspace supergraph's `PaginationInput`\n * has no `cursor` field (Federation intersects input types and two other\n * subgraphs declare a narrower one), so `pageInfo.cursor` is informational only.\n *\n * `labAgentRuns` is legitimately empty until a decision actually runs — in\n * production it will be, because the AI actions are opt-in and the loop is off.\n * That state renders as \"No decisions yet\" with the actions that would create\n * one, never as an error and never as a spinner that never resolves.\n */\n\nimport { useState } from 'react';\nimport { History, Sparkles, Wand2 } from 'lucide-react';\nimport {\n Button,\n Pagination,\n ResponsiveTable,\n type ResponsiveTableColumn,\n} from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { EmptyState } from '../../components/EmptyState';\nimport { QueryBoundary } from '../../components/QueryStates';\nimport { useLabsOfScience } from '../../context/LabsOfScienceContext';\nimport { useAgentRuns } from '../../hooks/useLabsOfScienceApi';\nimport { useLabActorNames } from '../../hooks/useLabActorNames';\nimport type { LabAgentRun } from '../../types';\nimport { formatDate, formatRelativeTime, titleCase } from '../../utils/formatters';\nimport { DetailSection } from '../shared/DetailComponents';\nimport { OverrideDecisionDialog, RecommendNextRunDialog, SuggestProtocolDialog } from './AiDialogs';\nimport { DecisionCard } from './DecisionCard';\nimport { ModelSettings } from './ModelSettings';\nimport { describeDecision, formatLatency, formatTokens } from './aiReaders';\n\nconst PAGE_SIZE = 20;\n\nexport function AiOperationsPage() {\n const { navigateTo } = useLabsOfScience();\n const [page, setPage] = useState(1);\n const [suggestOpen, setSuggestOpen] = useState(false);\n const [recommendOpen, setRecommendOpen] = useState(false);\n const [overrideRun, setOverrideRun] = useState<LabAgentRun | null>(null);\n\n const runs = useAgentRuns({\n pagination: { limit: PAGE_SIZE, offset: (page - 1) * PAGE_SIZE },\n });\n\n const items = runs.data?.items ?? [];\n const hasMore = runs.data?.pageInfo.hasMore ?? false;\n\n // Scheduled decisions are taken by the service actor, not a person; only user\n // actors are worth resolving to a display name.\n const { nameOf } = useLabActorNames(\n items.map((run) => (run.actorType === 'user' ? run.actorId : null))\n );\n\n // Cards only exist for rows that actually carry a payload. A FAILED row with\n // no decision is still in the feed above with its error text — it just has\n // nothing to render as a card.\n const decided = items.filter((run) => describeDecision(run.decision).kind !== 'none');\n\n const columns: ResponsiveTableColumn<LabAgentRun>[] = [\n {\n key: 'when',\n header: 'When',\n priority: 'primary',\n cell: (row) => (\n <time\n dateTime={row.createdAt}\n title={formatDate(row.createdAt)}\n className=\"text-text-secondary\"\n >\n {formatRelativeTime(row.createdAt)}\n </time>\n ),\n },\n {\n key: 'status',\n header: 'Status',\n priority: 'primary',\n cell: (row) => <StatusBadge status={row.status} />,\n },\n {\n key: 'trigger',\n header: 'Trigger',\n cell: (row) => <StatusBadge status={row.trigger} />,\n },\n {\n key: 'model',\n header: 'Model',\n priority: 'hidden-on-mobile',\n cell: (row) => (\n <div className=\"min-w-0\">\n <p className=\"truncate text-text-primary\">{row.model}</p>\n <p className=\"truncate text-xs text-text-tertiary\">{row.provider}</p>\n </div>\n ),\n },\n {\n key: 'actor',\n header: 'Requested by',\n priority: 'hidden-on-mobile',\n cell: (row) => (\n <span className=\"text-text-secondary\">\n {row.actorType === 'user' ? nameOf(row.actorId) : titleCase(row.actorType)}\n </span>\n ),\n },\n {\n key: 'latency',\n header: 'Latency',\n priority: 'hidden-on-mobile',\n cell: (row) => (\n <span className=\"tabular-nums text-text-secondary\">{formatLatency(row.latencyMs)}</span>\n ),\n },\n {\n key: 'tokens',\n header: 'Tokens',\n priority: 'hidden-on-mobile',\n cell: (row) => (\n <span className=\"tabular-nums text-text-secondary\">\n {formatTokens(row.tokensIn, row.tokensOut)}\n </span>\n ),\n },\n {\n key: 'detail',\n header: 'Detail',\n cell: (row) =>\n row.error ? (\n <span className=\"break-words text-xs text-status-error-text\">{row.error}</span>\n ) : (\n <span className=\"line-clamp-2 text-xs text-text-tertiary\">{row.promptSummary}</span>\n ),\n },\n ];\n\n return (\n <PageLayout\n title=\"AI Operations\"\n description=\"The model this workspace uses, every decision it has taken, and your call on each one.\"\n actions={\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button variant=\"outline\" onClick={() => setSuggestOpen(true)}>\n <Wand2 className=\"mr-2 h-4 w-4\" />\n Suggest protocol\n </Button>\n <Button onClick={() => setRecommendOpen(true)}>\n <Sparkles className=\"mr-2 h-4 w-4\" />\n Recommend next run\n </Button>\n </div>\n }\n >\n <div className=\"space-y-6\">\n <ModelSettings />\n\n <DetailSection title=\"Decision feed\">\n <QueryBoundary\n isLoading={runs.isLoading}\n isError={runs.isError}\n error={runs.error}\n onRetry={() => void runs.refetch()}\n loadingLabel=\"Loading decisions…\"\n >\n {items.length === 0 ? (\n <EmptyState\n icon={<History className=\"h-10 w-10\" />}\n title=\"No decisions yet\"\n description=\"Nothing has been asked of the AI in this workspace. Every attempt — including the ones that fail — is recorded here, newest first.\"\n action={\n <div className=\"flex flex-wrap items-center justify-center gap-2\">\n <Button variant=\"outline\" onClick={() => setSuggestOpen(true)}>\n <Wand2 className=\"mr-2 h-4 w-4\" />\n Suggest protocol\n </Button>\n <Button onClick={() => setRecommendOpen(true)}>\n <Sparkles className=\"mr-2 h-4 w-4\" />\n Recommend next run\n </Button>\n </div>\n }\n />\n ) : (\n <>\n <ResponsiveTable columns={columns} data={items} rowKey={(row) => row.id} />\n <Pagination\n page={page}\n pageSize={PAGE_SIZE}\n hasNextPage={hasMore}\n hasPreviousPage={page > 1}\n loading={runs.isFetching}\n onPageChange={setPage}\n className=\"mt-4\"\n />\n </>\n )}\n </QueryBoundary>\n </DetailSection>\n\n {items.length > 0 && (\n <DetailSection title={`Decisions on this page (${decided.length})`}>\n {decided.length === 0 ? (\n <p className=\"py-6 text-center text-sm text-text-secondary\">\n None of the entries on this page reached a decision.\n </p>\n ) : (\n <div className=\"space-y-4\">\n {decided.map((run) => (\n <DecisionCard\n key={run.id}\n run={run}\n onOverride={setOverrideRun}\n onOpenExperiment={(experimentId) => navigateTo(`experiments/${experimentId}`)}\n />\n ))}\n </div>\n )}\n </DetailSection>\n )}\n </div>\n\n <SuggestProtocolDialog\n open={suggestOpen}\n onOpenChange={setSuggestOpen}\n onViewProtocol={(protocolId) => navigateTo(`protocols/${protocolId}`)}\n />\n <RecommendNextRunDialog\n open={recommendOpen}\n onOpenChange={setRecommendOpen}\n onViewExperiment={(experimentId) => navigateTo(`experiments/${experimentId}`)}\n />\n <OverrideDecisionDialog\n run={overrideRun}\n onOpenChange={(open) => {\n if (!open) setOverrideRun(null);\n }}\n />\n </PageLayout>\n );\n}\n"],"mappings":"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"}
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { LabAgentRun } from '../../types';
3
+
4
+ export declare const DecisionCard: FC<{
5
+ run: LabAgentRun;
6
+ onOverride: (run: LabAgentRun) => void;
7
+ onOpenExperiment: (experimentId: string) => void;
8
+ }>;
9
+ //# sourceMappingURL=DecisionCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DecisionCard.d.ts","sourceRoot":"","sources":["../../../../src/labsofscience/pages/ai/DecisionCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA8N/C,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC;IAC5B,GAAG,EAAE,WAAW,CAAC;IACjB,UAAU,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,gBAAgB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD,CAwDA,CAAC"}
@@ -0,0 +1,282 @@
1
+ import { StatusBadge as e } from "../../components/StatusBadge.js";
2
+ import { formatDate as t, formatRelativeTime as n, titleCase as r } from "../../utils/formatters.js";
3
+ import { JsonBlock as i } from "../shared/DetailComponents.js";
4
+ import { describeDecision as a, experimentIdOfRun as o, formatConfidence as s, readJsonRecord as c, supersededRunIdOfRun as l } from "./aiReaders.js";
5
+ import { Beaker as u, Gauge as d, MessageSquareWarning as f, Sparkles as p, UserCheck as m } from "lucide-react";
6
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
7
+ import { Button as _ } from "@burdenoff/fe-libs/ui";
8
+ //#region src/labsofscience/pages/ai/DecisionCard.tsx
9
+ var v = (e) => `${e.slice(0, 8)}…`, y = [
10
+ "experimentId",
11
+ "projectId",
12
+ "supersedesRunId"
13
+ ], b = ({ label: e, value: t, mono: n, title: r }) => /* @__PURE__ */ g("span", {
14
+ className: "inline-flex items-center gap-1.5 rounded-full bg-bg-sunken px-2.5 py-1 text-xs",
15
+ children: [/* @__PURE__ */ h("span", {
16
+ className: "text-text-tertiary",
17
+ children: e
18
+ }), /* @__PURE__ */ h("span", {
19
+ className: n ? "font-mono text-text-secondary" : "text-text-secondary",
20
+ title: r,
21
+ children: t
22
+ })]
23
+ }), x = ({ run: e }) => {
24
+ let t = c(e.inputRefs), n = o(e), r = typeof t?.projectId == "string" ? t.projectId : null, a = l(e), s = t ? Object.fromEntries(Object.entries(t).filter(([e]) => !y.includes(e))) : null, u = s !== null && Object.keys(s).length > 0;
25
+ return t ? /* @__PURE__ */ g("div", {
26
+ className: "space-y-2",
27
+ children: [/* @__PURE__ */ g("div", {
28
+ className: "flex flex-wrap gap-1.5",
29
+ children: [
30
+ n && /* @__PURE__ */ h(b, {
31
+ label: "Experiment",
32
+ value: v(n),
33
+ mono: !0,
34
+ title: n
35
+ }),
36
+ r && /* @__PURE__ */ h(b, {
37
+ label: "Project",
38
+ value: v(r),
39
+ mono: !0,
40
+ title: r
41
+ }),
42
+ a && /* @__PURE__ */ h(b, {
43
+ label: "Supersedes",
44
+ value: v(a),
45
+ mono: !0,
46
+ title: a
47
+ }),
48
+ !n && !r && !a && /* @__PURE__ */ h("span", {
49
+ className: "text-xs text-text-tertiary",
50
+ children: "No linked project or experiment."
51
+ })
52
+ ]
53
+ }), u && /* @__PURE__ */ h(i, {
54
+ value: s,
55
+ emptyLabel: "No further inputs recorded"
56
+ })]
57
+ }) : /* @__PURE__ */ h("p", {
58
+ className: "text-sm text-text-secondary",
59
+ children: "No inputs were recorded against this decision."
60
+ });
61
+ }, S = ({ run: t }) => {
62
+ let n = a(t.decision);
63
+ switch (n.kind) {
64
+ case "recommendation": return /* @__PURE__ */ g("div", {
65
+ className: "space-y-2",
66
+ children: [
67
+ /* @__PURE__ */ g("div", {
68
+ className: "flex flex-wrap items-center gap-2",
69
+ children: [n.recommendation ? /* @__PURE__ */ h(e, { status: n.recommendation }) : /* @__PURE__ */ h("span", {
70
+ className: "text-sm text-text-secondary",
71
+ children: "No classification recorded"
72
+ }), /* @__PURE__ */ g("span", {
73
+ className: "inline-flex items-center gap-1 text-xs text-text-tertiary",
74
+ children: [
75
+ /* @__PURE__ */ h(d, {
76
+ className: "h-3.5 w-3.5",
77
+ "aria-hidden": "true"
78
+ }),
79
+ "Confidence ",
80
+ s(n.confidence)
81
+ ]
82
+ })]
83
+ }),
84
+ n.rationale && /* @__PURE__ */ h("p", {
85
+ className: "text-sm text-text-secondary",
86
+ children: n.rationale
87
+ }),
88
+ n.flags.length > 0 && /* @__PURE__ */ h("div", {
89
+ className: "flex flex-wrap gap-1.5",
90
+ children: n.flags.map((e) => /* @__PURE__ */ h("span", {
91
+ className: "rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs text-status-warning-text",
92
+ children: e
93
+ }, e))
94
+ }),
95
+ n.recommendation === "ADJUST_PARAMETERS" && /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("p", {
96
+ className: "mb-1.5 text-xs font-medium uppercase tracking-wide text-text-tertiary",
97
+ children: "Suggested parameters"
98
+ }), /* @__PURE__ */ h(i, {
99
+ value: n.suggestedParameters,
100
+ emptyLabel: "No specific parameter values were proposed"
101
+ })] })
102
+ ]
103
+ });
104
+ case "override": return /* @__PURE__ */ g("div", {
105
+ className: "space-y-2",
106
+ children: [/* @__PURE__ */ g("div", {
107
+ className: "flex flex-wrap items-center gap-2",
108
+ children: [
109
+ /* @__PURE__ */ g("span", {
110
+ className: "inline-flex items-center gap-1 text-xs text-text-tertiary",
111
+ children: [/* @__PURE__ */ h(m, {
112
+ className: "h-3.5 w-3.5",
113
+ "aria-hidden": "true"
114
+ }), "Researcher's call"]
115
+ }),
116
+ n.recommendation && /* @__PURE__ */ h(e, { status: n.recommendation }),
117
+ n.proposedRecommendation && n.proposedRecommendation !== n.recommendation && /* @__PURE__ */ g("span", {
118
+ className: "text-xs text-text-tertiary",
119
+ children: [
120
+ "(model proposed ",
121
+ r(n.proposedRecommendation),
122
+ ")"
123
+ ]
124
+ })
125
+ ]
126
+ }), n.note && /* @__PURE__ */ h("p", {
127
+ className: "text-sm text-text-secondary",
128
+ children: n.note
129
+ })]
130
+ });
131
+ case "protocol": return /* @__PURE__ */ g("div", {
132
+ className: "space-y-2",
133
+ children: [
134
+ /* @__PURE__ */ g("div", {
135
+ className: "flex flex-wrap items-center gap-2",
136
+ children: [/* @__PURE__ */ h("span", {
137
+ className: "font-medium text-text-primary",
138
+ children: n.protocolName ?? "Draft protocol"
139
+ }), /* @__PURE__ */ h(e, { status: "DRAFT" })]
140
+ }),
141
+ n.summary && /* @__PURE__ */ h("p", {
142
+ className: "text-sm text-text-secondary",
143
+ children: n.summary
144
+ }),
145
+ /* @__PURE__ */ g("div", {
146
+ className: "flex flex-wrap gap-1.5",
147
+ children: [
148
+ n.stepCount !== null && /* @__PURE__ */ h(b, {
149
+ label: "Steps",
150
+ value: String(n.stepCount)
151
+ }),
152
+ n.estimatedMinutes !== null && /* @__PURE__ */ h(b, {
153
+ label: "Est.",
154
+ value: `${n.estimatedMinutes} min`
155
+ }),
156
+ n.materials.length > 0 && /* @__PURE__ */ h(b, {
157
+ label: "Materials",
158
+ value: String(n.materials.length)
159
+ })
160
+ ]
161
+ }),
162
+ n.safetyNotes && /* @__PURE__ */ g("p", {
163
+ className: "text-xs text-status-warning-text",
164
+ children: ["Safety: ", n.safetyNotes]
165
+ })
166
+ ]
167
+ });
168
+ case "parse-error": return /* @__PURE__ */ g("div", {
169
+ className: "flex items-start gap-2",
170
+ children: [/* @__PURE__ */ h(f, {
171
+ className: "mt-0.5 h-4 w-4 shrink-0 text-status-warning-text",
172
+ "aria-hidden": "true"
173
+ }), /* @__PURE__ */ g("p", {
174
+ className: "text-sm text-text-secondary",
175
+ children: [
176
+ "The provider answered, but not with something this engine could read: ",
177
+ n.message,
178
+ ". The attempt is kept so the cost and latency stay accounted for."
179
+ ]
180
+ })]
181
+ });
182
+ case "unrecognised": return /* @__PURE__ */ g("div", {
183
+ className: "space-y-1.5",
184
+ children: [/* @__PURE__ */ h("p", {
185
+ className: "text-sm text-text-secondary",
186
+ children: "This entry was written in a shape this page does not recognise. Shown verbatim:"
187
+ }), /* @__PURE__ */ h(i, { value: n.raw })]
188
+ });
189
+ default: return /* @__PURE__ */ h("p", {
190
+ className: "text-sm text-text-secondary",
191
+ children: t.status === "FAILED" ? "No decision was reached — the attempt failed before the model produced one." : "No decision payload was recorded for this entry."
192
+ });
193
+ }
194
+ };
195
+ function C(e) {
196
+ switch (a(e.decision).kind) {
197
+ case "recommendation": return "Next-run recommendation";
198
+ case "override": return "Researcher override";
199
+ case "protocol": return "Protocol design";
200
+ case "parse-error": return "Unreadable model response";
201
+ default: return e.status === "FAILED" ? "Failed attempt" : "Decision";
202
+ }
203
+ }
204
+ var w = ({ run: r, onOverride: i, onOpenExperiment: a }) => {
205
+ let s = o(r);
206
+ return /* @__PURE__ */ g("article", {
207
+ className: "rounded-xl border border-border-seam bg-bg-surface p-4",
208
+ children: [
209
+ /* @__PURE__ */ g("header", {
210
+ className: "flex flex-wrap items-start justify-between gap-3",
211
+ children: [/* @__PURE__ */ g("div", {
212
+ className: "min-w-0",
213
+ children: [/* @__PURE__ */ g("div", {
214
+ className: "flex flex-wrap items-center gap-2",
215
+ children: [
216
+ /* @__PURE__ */ h(p, {
217
+ className: "h-4 w-4 text-text-tertiary",
218
+ "aria-hidden": "true"
219
+ }),
220
+ /* @__PURE__ */ h("h3", {
221
+ className: "text-sm font-semibold text-text-primary",
222
+ children: C(r)
223
+ }),
224
+ /* @__PURE__ */ h(e, { status: r.status }),
225
+ /* @__PURE__ */ h(e, { status: r.trigger })
226
+ ]
227
+ }), /* @__PURE__ */ g("p", {
228
+ className: "mt-1 text-xs text-text-tertiary",
229
+ children: [
230
+ r.provider,
231
+ " · ",
232
+ r.model,
233
+ " ·",
234
+ " ",
235
+ /* @__PURE__ */ h("time", {
236
+ dateTime: r.createdAt,
237
+ title: t(r.createdAt),
238
+ children: n(r.createdAt)
239
+ })
240
+ ]
241
+ })]
242
+ }), /* @__PURE__ */ g("div", {
243
+ className: "flex flex-wrap items-center gap-2",
244
+ children: [s && /* @__PURE__ */ g(_, {
245
+ variant: "ghost",
246
+ size: "sm",
247
+ onClick: () => a(s),
248
+ children: [/* @__PURE__ */ h(u, { className: "mr-1.5 h-4 w-4" }), "Experiment"]
249
+ }), /* @__PURE__ */ g(_, {
250
+ variant: "outline",
251
+ size: "sm",
252
+ onClick: () => i(r),
253
+ children: [/* @__PURE__ */ h(m, { className: "mr-1.5 h-4 w-4" }), "Override"]
254
+ })]
255
+ })]
256
+ }),
257
+ /* @__PURE__ */ h("div", {
258
+ className: "mt-3",
259
+ children: /* @__PURE__ */ h(S, { run: r })
260
+ }),
261
+ r.error && /* @__PURE__ */ h("p", {
262
+ className: "mt-3 break-words rounded-lg bg-status-error-bg-subtle p-2.5 text-xs text-status-error-text",
263
+ children: r.error
264
+ }),
265
+ /* @__PURE__ */ g("div", {
266
+ className: "mt-4 border-t border-border-seam pt-3",
267
+ children: [/* @__PURE__ */ h("p", {
268
+ className: "mb-2 text-xs font-medium uppercase tracking-wide text-text-tertiary",
269
+ children: "What it was decided from"
270
+ }), /* @__PURE__ */ h(x, { run: r })]
271
+ }),
272
+ r.promptSummary && /* @__PURE__ */ g("p", {
273
+ className: "mt-3 text-xs text-text-tertiary",
274
+ children: ["Prompt: ", r.promptSummary]
275
+ })
276
+ ]
277
+ });
278
+ };
279
+ //#endregion
280
+ export { w as DecisionCard };
281
+
282
+ //# sourceMappingURL=DecisionCard.js.map