@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.
- package/dist/generated/wspace-types.d.ts +68885 -33499
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/labsofscience/LabsOfScienceRoot.d.ts.map +1 -1
- package/dist/labsofscience/LabsOfScienceRoot.js +57 -49
- package/dist/labsofscience/LabsOfScienceRoot.js.map +1 -1
- package/dist/labsofscience/LabsOfScienceRoutes.d.ts.map +1 -1
- package/dist/labsofscience/LabsOfScienceRoutes.js +10 -6
- package/dist/labsofscience/LabsOfScienceRoutes.js.map +1 -1
- package/dist/labsofscience/components/BottomNav.d.ts.map +1 -1
- package/dist/labsofscience/components/BottomNav.js +36 -30
- package/dist/labsofscience/components/BottomNav.js.map +1 -1
- package/dist/labsofscience/components/MetricsCard.d.ts +1 -2
- package/dist/labsofscience/components/MetricsCard.d.ts.map +1 -1
- package/dist/labsofscience/components/MetricsCard.js.map +1 -1
- package/dist/labsofscience/components/StatusBadge.d.ts.map +1 -1
- package/dist/labsofscience/components/StatusBadge.js +10 -1
- package/dist/labsofscience/components/StatusBadge.js.map +1 -1
- package/dist/labsofscience/hooks/index.d.ts +1 -1
- package/dist/labsofscience/hooks/index.d.ts.map +1 -1
- package/dist/labsofscience/hooks/useLabsOfScienceApi.d.ts +82 -1
- package/dist/labsofscience/hooks/useLabsOfScienceApi.d.ts.map +1 -1
- package/dist/labsofscience/hooks/useLabsOfScienceApi.js +326 -199
- package/dist/labsofscience/hooks/useLabsOfScienceApi.js.map +1 -1
- package/dist/labsofscience/pages/ai/AiDialogs.d.ts +20 -0
- package/dist/labsofscience/pages/ai/AiDialogs.d.ts.map +1 -0
- package/dist/labsofscience/pages/ai/AiDialogs.js +566 -0
- package/dist/labsofscience/pages/ai/AiDialogs.js.map +1 -0
- package/dist/labsofscience/pages/ai/AiErrorNotice.d.ts +20 -0
- package/dist/labsofscience/pages/ai/AiErrorNotice.d.ts.map +1 -0
- package/dist/labsofscience/pages/ai/AiErrorNotice.js +67 -0
- package/dist/labsofscience/pages/ai/AiErrorNotice.js.map +1 -0
- package/dist/labsofscience/pages/ai/AiOperationsPage.d.ts +29 -0
- package/dist/labsofscience/pages/ai/AiOperationsPage.d.ts.map +1 -0
- package/dist/labsofscience/pages/ai/AiOperationsPage.js +196 -0
- package/dist/labsofscience/pages/ai/AiOperationsPage.js.map +1 -0
- package/dist/labsofscience/pages/ai/DecisionCard.d.ts +9 -0
- package/dist/labsofscience/pages/ai/DecisionCard.d.ts.map +1 -0
- package/dist/labsofscience/pages/ai/DecisionCard.js +282 -0
- package/dist/labsofscience/pages/ai/DecisionCard.js.map +1 -0
- package/dist/labsofscience/pages/ai/ModelSettings.d.ts +20 -0
- package/dist/labsofscience/pages/ai/ModelSettings.d.ts.map +1 -0
- package/dist/labsofscience/pages/ai/ModelSettings.js +141 -0
- package/dist/labsofscience/pages/ai/ModelSettings.js.map +1 -0
- package/dist/labsofscience/pages/ai/aiReaders.d.ts +82 -0
- package/dist/labsofscience/pages/ai/aiReaders.d.ts.map +1 -0
- package/dist/labsofscience/pages/ai/aiReaders.js +86 -0
- package/dist/labsofscience/pages/ai/aiReaders.js.map +1 -0
- package/dist/labsofscience/pages/experiments/ExperimentDetailPage.js +18 -18
- package/dist/labsofscience/pages/experiments/ExperimentsListPage.js +6 -6
- package/dist/labsofscience/pages/instruments/InstrumentDetailPage.js +14 -14
- package/dist/labsofscience/pages/instruments/InstrumentsListPage.js +6 -6
- package/dist/labsofscience/pages/projects/ProjectDetailPage.js +16 -16
- package/dist/labsofscience/pages/projects/ProjectsListPage.js +6 -6
- package/dist/labsofscience/types/index.d.ts +133 -2
- package/dist/labsofscience/types/index.d.ts.map +1 -1
- package/dist/services/createSandboxAssistantTransport.js +6 -6
- package/dist/services/createSandboxAssistantTransport.js.map +1 -1
- package/dist/utils/pageContext.d.ts +13 -0
- package/dist/utils/pageContext.d.ts.map +1 -1
- package/dist/utils/pageContext.js +89 -26
- package/dist/utils/pageContext.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecisionCard.js","names":[],"sources":["../../../../src/labsofscience/pages/ai/DecisionCard.tsx"],"sourcesContent":["/**\n * One AI decision, rendered with its provenance.\n * @module labsofscience/pages/ai\n *\n * A ledger row is only trustworthy if you can see what went into it, so every\n * card shows three things together: what was decided (`decision`), what it was\n * decided from (`inputRefs`), and which model produced it at what cost. A\n * FAILED row is shown with the same prominence as a successful one — the point\n * of an append-only ledger is that the attempts nobody liked are still there.\n *\n * The override action is the human half of the loop: it appends a new row that\n * supersedes this one rather than editing it.\n */\n\nimport type { FC } from 'react';\nimport { Beaker, Gauge, MessageSquareWarning, Sparkles, UserCheck } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport type { LabAgentRun } from '../../types';\nimport { formatDate, formatRelativeTime, titleCase } from '../../utils/formatters';\nimport { JsonBlock } from '../shared/DetailComponents';\nimport {\n describeDecision,\n experimentIdOfRun,\n formatConfidence,\n readJsonRecord,\n supersededRunIdOfRun,\n} from './aiReaders';\n\n/** Short display for a UUID (the full id stays available via the title attribute). */\nconst shortId = (id: string): string => `${id.slice(0, 8)}…`;\n\n/** Provenance keys rendered as their own chips; the rest go to the JSON block. */\nconst NAMED_PROVENANCE_KEYS = ['experimentId', 'projectId', 'supersedesRunId'] as const;\n\nconst Chip: FC<{ label: string; value: string; mono?: boolean; title?: string }> = ({\n label,\n value,\n mono,\n title,\n}) => (\n <span className=\"inline-flex items-center gap-1.5 rounded-full bg-bg-sunken px-2.5 py-1 text-xs\">\n <span className=\"text-text-tertiary\">{label}</span>\n <span className={mono ? 'font-mono text-text-secondary' : 'text-text-secondary'} title={title}>\n {value}\n </span>\n </span>\n);\n\n/**\n * The `inputRefs` bag, split into the ids a researcher recognises and the rest\n * (run counts, status tallies) which stay as raw JSON rather than being\n * invented into prose the service never promised.\n */\nconst Provenance: FC<{ run: LabAgentRun }> = ({ run }) => {\n const record = readJsonRecord(run.inputRefs);\n const experimentId = experimentIdOfRun(run);\n const projectId = typeof record?.projectId === 'string' ? record.projectId : null;\n const supersedesRunId = supersededRunIdOfRun(run);\n\n const rest = record\n ? Object.fromEntries(\n Object.entries(record).filter(\n ([key]) => !NAMED_PROVENANCE_KEYS.includes(key as (typeof NAMED_PROVENANCE_KEYS)[number])\n )\n )\n : null;\n const hasRest = rest !== null && Object.keys(rest).length > 0;\n\n if (!record) {\n return (\n <p className=\"text-sm text-text-secondary\">No inputs were recorded against this decision.</p>\n );\n }\n\n return (\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap gap-1.5\">\n {experimentId && (\n <Chip label=\"Experiment\" value={shortId(experimentId)} mono title={experimentId} />\n )}\n {projectId && <Chip label=\"Project\" value={shortId(projectId)} mono title={projectId} />}\n {supersedesRunId && (\n <Chip label=\"Supersedes\" value={shortId(supersedesRunId)} mono title={supersedesRunId} />\n )}\n {!experimentId && !projectId && !supersedesRunId && (\n <span className=\"text-xs text-text-tertiary\">No linked project or experiment.</span>\n )}\n </div>\n {hasRest && <JsonBlock value={rest} emptyLabel=\"No further inputs recorded\" />}\n </div>\n );\n};\n\nconst DecisionBody: FC<{ run: LabAgentRun }> = ({ run }) => {\n const decision = describeDecision(run.decision);\n\n switch (decision.kind) {\n case 'recommendation':\n return (\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2\">\n {decision.recommendation ? (\n <StatusBadge status={decision.recommendation} />\n ) : (\n <span className=\"text-sm text-text-secondary\">No classification recorded</span>\n )}\n <span className=\"inline-flex items-center gap-1 text-xs text-text-tertiary\">\n <Gauge className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n Confidence {formatConfidence(decision.confidence)}\n </span>\n </div>\n {decision.rationale && (\n <p className=\"text-sm text-text-secondary\">{decision.rationale}</p>\n )}\n {decision.flags.length > 0 && (\n <div className=\"flex flex-wrap gap-1.5\">\n {decision.flags.map((flag) => (\n <span\n key={flag}\n className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs text-status-warning-text\"\n >\n {flag}\n </span>\n ))}\n </div>\n )}\n {decision.recommendation === 'ADJUST_PARAMETERS' && (\n <div>\n <p className=\"mb-1.5 text-xs font-medium uppercase tracking-wide text-text-tertiary\">\n Suggested parameters\n </p>\n <JsonBlock\n value={decision.suggestedParameters}\n emptyLabel=\"No specific parameter values were proposed\"\n />\n </div>\n )}\n </div>\n );\n\n case 'override':\n return (\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"inline-flex items-center gap-1 text-xs text-text-tertiary\">\n <UserCheck className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n Researcher's call\n </span>\n {decision.recommendation && <StatusBadge status={decision.recommendation} />}\n {decision.proposedRecommendation &&\n decision.proposedRecommendation !== decision.recommendation && (\n <span className=\"text-xs text-text-tertiary\">\n (model proposed {titleCase(decision.proposedRecommendation)})\n </span>\n )}\n </div>\n {decision.note && <p className=\"text-sm text-text-secondary\">{decision.note}</p>}\n </div>\n );\n\n case 'protocol':\n return (\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"font-medium text-text-primary\">\n {decision.protocolName ?? 'Draft protocol'}\n </span>\n <StatusBadge status=\"DRAFT\" />\n </div>\n {decision.summary && <p className=\"text-sm text-text-secondary\">{decision.summary}</p>}\n <div className=\"flex flex-wrap gap-1.5\">\n {decision.stepCount !== null && (\n <Chip label=\"Steps\" value={String(decision.stepCount)} />\n )}\n {decision.estimatedMinutes !== null && (\n <Chip label=\"Est.\" value={`${decision.estimatedMinutes} min`} />\n )}\n {decision.materials.length > 0 && (\n <Chip label=\"Materials\" value={String(decision.materials.length)} />\n )}\n </div>\n {decision.safetyNotes && (\n <p className=\"text-xs text-status-warning-text\">Safety: {decision.safetyNotes}</p>\n )}\n </div>\n );\n\n case 'parse-error':\n return (\n <div className=\"flex items-start gap-2\">\n <MessageSquareWarning\n className=\"mt-0.5 h-4 w-4 shrink-0 text-status-warning-text\"\n aria-hidden=\"true\"\n />\n <p className=\"text-sm text-text-secondary\">\n The provider answered, but not with something this engine could read: {decision.message}\n . The attempt is kept so the cost and latency stay accounted for.\n </p>\n </div>\n );\n\n case 'unrecognised':\n return (\n <div className=\"space-y-1.5\">\n <p className=\"text-sm text-text-secondary\">\n This entry was written in a shape this page does not recognise. Shown verbatim:\n </p>\n <JsonBlock value={decision.raw} />\n </div>\n );\n\n case 'none':\n default:\n return (\n <p className=\"text-sm text-text-secondary\">\n {run.status === 'FAILED'\n ? 'No decision was reached — the attempt failed before the model produced one.'\n : 'No decision payload was recorded for this entry.'}\n </p>\n );\n }\n};\n\n/** Human label for what the row was trying to do, derived from its payload. */\nfunction decisionTitle(run: LabAgentRun): string {\n switch (describeDecision(run.decision).kind) {\n case 'recommendation':\n return 'Next-run recommendation';\n case 'override':\n return 'Researcher override';\n case 'protocol':\n return 'Protocol design';\n case 'parse-error':\n return 'Unreadable model response';\n default:\n return run.status === 'FAILED' ? 'Failed attempt' : 'Decision';\n }\n}\n\nexport const DecisionCard: FC<{\n run: LabAgentRun;\n onOverride: (run: LabAgentRun) => void;\n onOpenExperiment: (experimentId: string) => void;\n}> = ({ run, onOverride, onOpenExperiment }) => {\n const experimentId = experimentIdOfRun(run);\n\n return (\n <article className=\"rounded-xl border border-border-seam bg-bg-surface p-4\">\n <header className=\"flex flex-wrap items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <Sparkles className=\"h-4 w-4 text-text-tertiary\" aria-hidden=\"true\" />\n <h3 className=\"text-sm font-semibold text-text-primary\">{decisionTitle(run)}</h3>\n <StatusBadge status={run.status} />\n <StatusBadge status={run.trigger} />\n </div>\n <p className=\"mt-1 text-xs text-text-tertiary\">\n {run.provider} · {run.model} ·{' '}\n <time dateTime={run.createdAt} title={formatDate(run.createdAt)}>\n {formatRelativeTime(run.createdAt)}\n </time>\n </p>\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n {experimentId && (\n <Button variant=\"ghost\" size=\"sm\" onClick={() => onOpenExperiment(experimentId)}>\n <Beaker className=\"mr-1.5 h-4 w-4\" />\n Experiment\n </Button>\n )}\n <Button variant=\"outline\" size=\"sm\" onClick={() => onOverride(run)}>\n <UserCheck className=\"mr-1.5 h-4 w-4\" />\n Override\n </Button>\n </div>\n </header>\n\n <div className=\"mt-3\">\n <DecisionBody run={run} />\n </div>\n\n {run.error && (\n <p className=\"mt-3 break-words rounded-lg bg-status-error-bg-subtle p-2.5 text-xs text-status-error-text\">\n {run.error}\n </p>\n )}\n\n <div className=\"mt-4 border-t border-border-seam pt-3\">\n <p className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-tertiary\">\n What it was decided from\n </p>\n <Provenance run={run} />\n </div>\n\n {run.promptSummary && (\n <p className=\"mt-3 text-xs text-text-tertiary\">Prompt: {run.promptSummary}</p>\n )}\n </article>\n );\n};\n"],"mappings":";;;;;;;;AA8BA,IAAM,KAAW,MAAuB,GAAG,EAAG,MAAM,GAAG,CAAC,EAAE,IAGpD,IAAwB;CAAC;CAAgB;CAAa;AAAiB,GAEvE,KAA8E,EAClF,UACA,UACA,SACA,eAEA,kBAAC,QAAD;CAAM,WAAU;WAAhB,CACE,kBAAC,QAAD;EAAM,WAAU;YAAsB;CAAY,CAAA,GAClD,kBAAC,QAAD;EAAM,WAAW,IAAO,kCAAkC;EAA8B;YACrF;CACG,CAAA,CACF;IAQF,KAAwC,EAAE,aAAU;CACxD,IAAM,IAAS,EAAe,EAAI,SAAS,GACrC,IAAe,EAAkB,CAAG,GACpC,IAAY,OAAO,GAAQ,aAAc,WAAW,EAAO,YAAY,MACvE,IAAkB,EAAqB,CAAG,GAE1C,IAAO,IACT,OAAO,YACL,OAAO,QAAQ,CAAM,CAAC,CAAC,QACpB,CAAC,OAAS,CAAC,EAAs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A2C,EAAc,CAAG;OAAM,CAAA;OAChF,kBAAC,GAAD,EAAa,QAAQ,EAAI,OAAS,CAAA;OAClC,kBAAC,GAAD,EAAa,QAAQ,EAAI,QAAU,CAAA;MAChC;SACL,kBAAC,KAAD;MAAG,WAAU;gBAAb;OACG,EAAI;OAAS;OAAI,EAAI;OAAM;OAAG;OAC/B,kBAAC,QAAD;QAAM,UAAU,EAAI;QAAW,OAAO,EAAW,EAAI,SAAS;kBAC3D,EAAmB,EAAI,SAAS;OAC7B,CAAA;MACL;OACA;QACL,kBAAC,OAAD;KAAK,WAAU;eAAf,CACG,KACC,kBAAC,GAAD;MAAQ,SAAQ;MAAQ,MAAK;MAAK,eAAe,EAAiB,CAAY;gBAA9E,CACE,kBAAC,GAAD,EAAQ,WAAU,iBAAkB,CAAA,GAAC,YAE/B;SAEV,kBAAC,GAAD;MAAQ,SAAQ;MAAU,MAAK;MAAK,eAAe,EAAW,CAAG;gBAAjE,CACE,kBAAC,GAAD,EAAW,WAAU,iBAAkB,CAAA,GAAC,UAElC;OACL;MACC;;GAER,kBAAC,OAAD;IAAK,WAAU;cACb,kBAAC,GAAD,EAAmB,OAAM,CAAA;GACtB,CAAA;GAEJ,EAAI,SACH,kBAAC,KAAD;IAAG,WAAU;cACV,EAAI;GACJ,CAAA;GAGL,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,KAAD;KAAG,WAAU;eAAsE;IAEhF,CAAA,GACH,kBAAC,GAAD,EAAiB,OAAM,CAAA,CACpB;;GAEJ,EAAI,iBACH,kBAAC,KAAD;IAAG,WAAU;cAAb,CAA+C,YAAS,EAAI,aAAiB;;EAExE;;AAEb"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace AI model picker + autopilot opt-in.
|
|
3
|
+
* @module labsofscience/pages/ai
|
|
4
|
+
*
|
|
5
|
+
* Two settings, one row of the `lab_workspace_ai_configs` table:
|
|
6
|
+
*
|
|
7
|
+
* - the default (provider, model) pair every decision in this workspace uses,
|
|
8
|
+
* saved with `labSetWorkspaceAiModel`;
|
|
9
|
+
* - the workspace's opt-in to the autonomous agent loop, saved with
|
|
10
|
+
* `labSetWorkspaceAutoPilot`.
|
|
11
|
+
*
|
|
12
|
+
* The autopilot copy is deliberately unexciting. The loop only ever PROPOSES a
|
|
13
|
+
* next-run recommendation — it starts no run, changes no experiment design and
|
|
14
|
+
* publishes no protocol — and it is additionally gated per deployment by the
|
|
15
|
+
* `LABSOFSCIENCE_AGENT_LOOP_ENABLED` env switch, which is off in production.
|
|
16
|
+
* Saying so here is the difference between an honest toggle and one that
|
|
17
|
+
* implies the lab is about to start running itself.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ModelSettings(): import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=ModelSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelSettings.d.ts","sourceRoot":"","sources":["../../../../src/labsofscience/pages/ai/ModelSettings.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAmCH,wBAAgB,aAAa,gCA8I5B"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { QueryBoundary as e } from "../../components/QueryStates.js";
|
|
2
|
+
import { useAiModelCatalog as t, useSetWorkspaceAiModel as n, useSetWorkspaceAutoPilot as r, useWorkspaceAiConfig as i } from "../../hooks/useLabsOfScienceApi.js";
|
|
3
|
+
import { formatDate as a, formatRelativeTime as o } from "../../utils/formatters.js";
|
|
4
|
+
import { DetailSection as s } from "../shared/DetailComponents.js";
|
|
5
|
+
import { AiErrorNotice as c } from "./AiErrorNotice.js";
|
|
6
|
+
import { useState as l } from "react";
|
|
7
|
+
import { Bot as u, Save as d } from "lucide-react";
|
|
8
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
9
|
+
import { Button as h, Label as g, Select as _, SelectContent as v, SelectItem as y, SelectTrigger as b, SelectValue as x, Switch as S } from "@burdenoff/fe-libs/ui";
|
|
10
|
+
//#region src/labsofscience/pages/ai/ModelSettings.tsx
|
|
11
|
+
var C = (e) => `${e.provider}::${e.model}`;
|
|
12
|
+
function w(e, t) {
|
|
13
|
+
return t.find((t) => C(t) === e) ?? null;
|
|
14
|
+
}
|
|
15
|
+
function T() {
|
|
16
|
+
let T = t(), E = i(), D = n(), O = r(), [k, A] = l(null), j = T.data ?? [], M = j.find((e) => e.isDefault) ?? j[0] ?? null, N = E.data ? C(E.data) : M ? C(M) : "", P = k ?? N, F = k !== null && k !== N, I = E.data?.autoPilotEnabled ?? !1, L = async () => {
|
|
17
|
+
let e = w(P, j);
|
|
18
|
+
if (e) try {
|
|
19
|
+
await D.mutateAsync({
|
|
20
|
+
provider: e.provider,
|
|
21
|
+
model: e.model
|
|
22
|
+
}), A(null);
|
|
23
|
+
} catch {}
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ p(s, {
|
|
26
|
+
title: "Model & autopilot",
|
|
27
|
+
children: /* @__PURE__ */ p(e, {
|
|
28
|
+
isLoading: T.isLoading || E.isLoading,
|
|
29
|
+
isError: T.isError || E.isError,
|
|
30
|
+
error: T.error ?? E.error,
|
|
31
|
+
onRetry: () => {
|
|
32
|
+
T.refetch(), E.refetch();
|
|
33
|
+
},
|
|
34
|
+
loadingLabel: "Loading AI settings…",
|
|
35
|
+
children: /* @__PURE__ */ m("div", {
|
|
36
|
+
className: "space-y-6",
|
|
37
|
+
children: [/* @__PURE__ */ m("div", {
|
|
38
|
+
className: "space-y-2",
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ m("div", {
|
|
41
|
+
className: "flex flex-col gap-3 sm:flex-row sm:items-end",
|
|
42
|
+
children: [/* @__PURE__ */ m("div", {
|
|
43
|
+
className: "min-w-0 flex-1 space-y-1.5",
|
|
44
|
+
children: [/* @__PURE__ */ p(g, {
|
|
45
|
+
htmlFor: "ai-model",
|
|
46
|
+
children: "Default model"
|
|
47
|
+
}), /* @__PURE__ */ m(_, {
|
|
48
|
+
value: P,
|
|
49
|
+
onValueChange: A,
|
|
50
|
+
children: [/* @__PURE__ */ p(b, {
|
|
51
|
+
id: "ai-model",
|
|
52
|
+
className: "w-full",
|
|
53
|
+
children: /* @__PURE__ */ p(x, { placeholder: "Select a model" })
|
|
54
|
+
}), /* @__PURE__ */ p(v, { children: j.map((e) => /* @__PURE__ */ m(y, {
|
|
55
|
+
value: C(e),
|
|
56
|
+
children: [e.label, e.isDefault ? " (platform default)" : ""]
|
|
57
|
+
}, C(e))) })]
|
|
58
|
+
})]
|
|
59
|
+
}), /* @__PURE__ */ m(h, {
|
|
60
|
+
onClick: () => void L(),
|
|
61
|
+
disabled: !F || D.isPending || j.length === 0,
|
|
62
|
+
children: [/* @__PURE__ */ p(d, { className: "mr-2 h-4 w-4" }), D.isPending ? "Saving…" : "Save model"]
|
|
63
|
+
})]
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ p("p", {
|
|
66
|
+
className: "text-xs text-text-tertiary",
|
|
67
|
+
children: E.data ? `Saved ${o(E.data.updatedAt)}. Every decision in this workspace uses this pair unless a single request asks for another provider.` : "This workspace has not chosen a model, so decisions use the platform default shown above."
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ p(c, {
|
|
70
|
+
error: D.error,
|
|
71
|
+
fallback: "Failed to save the model."
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
}), /* @__PURE__ */ m("div", {
|
|
75
|
+
className: "space-y-3 rounded-lg border border-border-seam bg-bg-sunken p-4",
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ m("div", {
|
|
78
|
+
className: "flex items-start justify-between gap-4",
|
|
79
|
+
children: [/* @__PURE__ */ m("div", {
|
|
80
|
+
className: "min-w-0",
|
|
81
|
+
children: [/* @__PURE__ */ m("div", {
|
|
82
|
+
className: "flex items-center gap-2",
|
|
83
|
+
children: [/* @__PURE__ */ p(u, {
|
|
84
|
+
className: "h-4 w-4 text-text-tertiary",
|
|
85
|
+
"aria-hidden": "true"
|
|
86
|
+
}), /* @__PURE__ */ p("p", {
|
|
87
|
+
className: "text-sm font-medium text-text-primary",
|
|
88
|
+
children: "Autopilot"
|
|
89
|
+
})]
|
|
90
|
+
}), /* @__PURE__ */ p("p", {
|
|
91
|
+
className: "mt-1 text-sm text-text-secondary",
|
|
92
|
+
children: "Periodically ask for a next-run recommendation on experiments that have recent completed runs nobody has assessed lately."
|
|
93
|
+
})]
|
|
94
|
+
}), /* @__PURE__ */ p(S, {
|
|
95
|
+
id: "ai-autopilot",
|
|
96
|
+
checked: I,
|
|
97
|
+
disabled: O.isPending,
|
|
98
|
+
"aria-label": "Enable autopilot for this workspace",
|
|
99
|
+
onCheckedChange: (e) => {
|
|
100
|
+
O.mutate(e);
|
|
101
|
+
}
|
|
102
|
+
})]
|
|
103
|
+
}),
|
|
104
|
+
/* @__PURE__ */ m("p", {
|
|
105
|
+
className: "text-xs text-text-tertiary",
|
|
106
|
+
children: [
|
|
107
|
+
"It only ",
|
|
108
|
+
/* @__PURE__ */ p("strong", {
|
|
109
|
+
className: "text-text-secondary",
|
|
110
|
+
children: "proposes"
|
|
111
|
+
}),
|
|
112
|
+
". Each scheduled decision is recorded in the feed below with a SCHEDULED trigger, exactly like the recommendations you request by hand — it starts no run, changes no experiment design, and publishes no protocol. The loop is also gated per deployment by a server-side switch that is off in production, so turning this on records your opt-in and nothing will run until that switch is enabled."
|
|
113
|
+
]
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ p("p", {
|
|
116
|
+
className: "text-xs text-text-tertiary",
|
|
117
|
+
children: E.data?.autoPilotLastRunAt ? /* @__PURE__ */ m(f, { children: [
|
|
118
|
+
"A scheduled tick last considered this workspace",
|
|
119
|
+
" ",
|
|
120
|
+
/* @__PURE__ */ p("time", {
|
|
121
|
+
dateTime: E.data.autoPilotLastRunAt,
|
|
122
|
+
title: a(E.data.autoPilotLastRunAt),
|
|
123
|
+
children: o(E.data.autoPilotLastRunAt)
|
|
124
|
+
}),
|
|
125
|
+
"."
|
|
126
|
+
] }) : "No scheduled tick has considered this workspace yet."
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ p(c, {
|
|
129
|
+
error: O.error,
|
|
130
|
+
fallback: "Failed to change the autopilot setting."
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
})]
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
export { T as ModelSettings };
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=ModelSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelSettings.js","names":[],"sources":["../../../../src/labsofscience/pages/ai/ModelSettings.tsx"],"sourcesContent":["/**\n * Workspace AI model picker + autopilot opt-in.\n * @module labsofscience/pages/ai\n *\n * Two settings, one row of the `lab_workspace_ai_configs` table:\n *\n * - the default (provider, model) pair every decision in this workspace uses,\n * saved with `labSetWorkspaceAiModel`;\n * - the workspace's opt-in to the autonomous agent loop, saved with\n * `labSetWorkspaceAutoPilot`.\n *\n * The autopilot copy is deliberately unexciting. The loop only ever PROPOSES a\n * next-run recommendation — it starts no run, changes no experiment design and\n * publishes no protocol — and it is additionally gated per deployment by the\n * `LABSOFSCIENCE_AGENT_LOOP_ENABLED` env switch, which is off in production.\n * Saying so here is the difference between an honest toggle and one that\n * implies the lab is about to start running itself.\n */\n\nimport { useState } from 'react';\nimport { Bot, Save } from 'lucide-react';\nimport {\n Button,\n Label,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Switch,\n} from '@burdenoff/fe-libs/ui';\nimport { QueryBoundary } from '../../components/QueryStates';\nimport {\n useAiModelCatalog,\n useSetWorkspaceAiModel,\n useSetWorkspaceAutoPilot,\n useWorkspaceAiConfig,\n} from '../../hooks/useLabsOfScienceApi';\nimport type { LabAiModelInfo } from '../../types';\nimport { formatDate, formatRelativeTime } from '../../utils/formatters';\nimport { DetailSection } from '../shared/DetailComponents';\nimport { AiErrorNotice } from './AiErrorNotice';\n\n/** Select values pair provider and model, which are only unique together. */\nconst modelKey = (entry: { provider: string; model: string }): string =>\n `${entry.provider}::${entry.model}`;\n\n/** Inverse of `modelKey`; returns null for a value not in the catalog. */\nfunction parseModelKey(value: string, catalog: LabAiModelInfo[]): LabAiModelInfo | null {\n return catalog.find((entry) => modelKey(entry) === value) ?? null;\n}\n\nexport function ModelSettings() {\n const catalog = useAiModelCatalog();\n const config = useWorkspaceAiConfig();\n const setModel = useSetWorkspaceAiModel();\n const setAutoPilot = useSetWorkspaceAutoPilot();\n\n /**\n * The user's un-saved pick. Null means \"show what the server has\", which is\n * why this is not seeded from `config` in an effect: the saved value is\n * derived on every render and a pick simply shadows it until it is saved.\n */\n const [pendingKey, setPendingKey] = useState<string | null>(null);\n\n const entries = catalog.data ?? [];\n const catalogDefault = entries.find((entry) => entry.isDefault) ?? entries[0] ?? null;\n const savedKey = config.data\n ? modelKey(config.data)\n : catalogDefault\n ? modelKey(catalogDefault)\n : '';\n const selectedKey = pendingKey ?? savedKey;\n const isDirty = pendingKey !== null && pendingKey !== savedKey;\n const autoPilotEnabled = config.data?.autoPilotEnabled ?? false;\n\n const handleSave = async () => {\n const chosen = parseModelKey(selectedKey, entries);\n if (!chosen) return;\n try {\n await setModel.mutateAsync({ provider: chosen.provider, model: chosen.model });\n setPendingKey(null);\n } catch {\n // Rendered from `setModel.error`.\n }\n };\n\n return (\n <DetailSection title=\"Model & autopilot\">\n <QueryBoundary\n isLoading={catalog.isLoading || config.isLoading}\n isError={catalog.isError || config.isError}\n error={catalog.error ?? config.error}\n onRetry={() => {\n void catalog.refetch();\n void config.refetch();\n }}\n loadingLabel=\"Loading AI settings…\"\n >\n <div className=\"space-y-6\">\n {/* ── Model picker ─────────────────────────────────────────────── */}\n <div className=\"space-y-2\">\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-end\">\n <div className=\"min-w-0 flex-1 space-y-1.5\">\n <Label htmlFor=\"ai-model\">Default model</Label>\n <Select value={selectedKey} onValueChange={setPendingKey}>\n <SelectTrigger id=\"ai-model\" className=\"w-full\">\n <SelectValue placeholder=\"Select a model\" />\n </SelectTrigger>\n <SelectContent>\n {entries.map((entry) => (\n <SelectItem key={modelKey(entry)} value={modelKey(entry)}>\n {entry.label}\n {entry.isDefault ? ' (platform default)' : ''}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <Button\n onClick={() => void handleSave()}\n disabled={!isDirty || setModel.isPending || entries.length === 0}\n >\n <Save className=\"mr-2 h-4 w-4\" />\n {setModel.isPending ? 'Saving…' : 'Save model'}\n </Button>\n </div>\n <p className=\"text-xs text-text-tertiary\">\n {config.data\n ? `Saved ${formatRelativeTime(config.data.updatedAt)}. Every decision in this workspace uses this pair unless a single request asks for another provider.`\n : 'This workspace has not chosen a model, so decisions use the platform default shown above.'}\n </p>\n <AiErrorNotice error={setModel.error} fallback=\"Failed to save the model.\" />\n </div>\n\n {/* ── Autopilot ────────────────────────────────────────────────── */}\n <div className=\"space-y-3 rounded-lg border border-border-seam bg-bg-sunken p-4\">\n <div className=\"flex items-start justify-between gap-4\">\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2\">\n <Bot className=\"h-4 w-4 text-text-tertiary\" aria-hidden=\"true\" />\n <p className=\"text-sm font-medium text-text-primary\">Autopilot</p>\n </div>\n <p className=\"mt-1 text-sm text-text-secondary\">\n Periodically ask for a next-run recommendation on experiments that have recent\n completed runs nobody has assessed lately.\n </p>\n </div>\n <Switch\n id=\"ai-autopilot\"\n checked={autoPilotEnabled}\n disabled={setAutoPilot.isPending}\n aria-label=\"Enable autopilot for this workspace\"\n onCheckedChange={(checked) => {\n setAutoPilot.mutate(checked);\n }}\n />\n </div>\n\n <p className=\"text-xs text-text-tertiary\">\n It only <strong className=\"text-text-secondary\">proposes</strong>. Each scheduled\n decision is recorded in the feed below with a SCHEDULED trigger, exactly like the\n recommendations you request by hand — it starts no run, changes no experiment design,\n and publishes no protocol. The loop is also gated per deployment by a server-side\n switch that is off in production, so turning this on records your opt-in and nothing\n will run until that switch is enabled.\n </p>\n\n <p className=\"text-xs text-text-tertiary\">\n {config.data?.autoPilotLastRunAt ? (\n <>\n A scheduled tick last considered this workspace{' '}\n <time\n dateTime={config.data.autoPilotLastRunAt}\n title={formatDate(config.data.autoPilotLastRunAt)}\n >\n {formatRelativeTime(config.data.autoPilotLastRunAt)}\n </time>\n .\n </>\n ) : (\n 'No scheduled tick has considered this workspace yet.'\n )}\n </p>\n\n <AiErrorNotice\n error={setAutoPilot.error}\n fallback=\"Failed to change the autopilot setting.\"\n />\n </div>\n </div>\n </QueryBoundary>\n </DetailSection>\n );\n}\n"],"mappings":";;;;;;;;;;AA4CA,IAAM,KAAY,MAChB,GAAG,EAAM,SAAS,IAAI,EAAM;AAG9B,SAAS,EAAc,GAAe,GAAkD;CACtF,OAAO,EAAQ,MAAM,MAAU,EAAS,CAAK,MAAM,CAAK,KAAK;AAC/D;AAEA,SAAgB,IAAgB;CAC9B,IAAM,IAAU,EAAkB,GAC5B,IAAS,EAAqB,GAC9B,IAAW,EAAuB,GAClC,IAAe,EAAyB,GAOxC,CAAC,GAAY,KAAiB,EAAwB,IAAI,GAE1D,IAAU,EAAQ,QAAQ,CAAC,GAC3B,IAAiB,EAAQ,MAAM,MAAU,EAAM,SAAS,KAAK,EAAQ,MAAM,MAC3E,IAAW,EAAO,OACpB,EAAS,EAAO,IAAI,IACpB,IACE,EAAS,CAAc,IACvB,IACA,IAAc,KAAc,GAC5B,IAAU,MAAe,QAAQ,MAAe,GAChD,IAAmB,EAAO,MAAM,oBAAoB,IAEpD,IAAa,YAAY;EAC7B,IAAM,IAAS,EAAc,GAAa,CAAO;EAC5C,OACL,IAAI;GAEF,AADA,MAAM,EAAS,YAAY;IAAE,UAAU,EAAO;IAAU,OAAO,EAAO;GAAM,CAAC,GAC7E,EAAc,IAAI;EACpB,QAAQ,CAER;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AAf,CACE,kBAAC,OAAD;SAAK,WAAU;mBAAf,CACE,kBAAC,GAAD;UAAK,WAAU;UAA6B,eAAY;SAAQ,CAAA,GAChE,kBAAC,KAAD;UAAG,WAAU;oBAAwC;SAAY,CAAA,CAC9D;YACL,kBAAC,KAAD;SAAG,WAAU;mBAAmC;QAG7C,CAAA,CACA;WACL,kBAAC,GAAD;QACE,IAAG;QACH,SAAS;QACT,UAAU,EAAa;QACvB,cAAW;QACX,kBAAkB,MAAY;SAC5B,EAAa,OAAO,CAAO;QAC7B;OACD,CAAA,CACE;;MAEL,kBAAC,KAAD;OAAG,WAAU;iBAAb;QAA0C;QAChC,kBAAC,UAAD;SAAQ,WAAU;mBAAsB;QAAgB,CAAA;QAAC;OAMhE;;MAEH,kBAAC,KAAD;OAAG,WAAU;iBACV,EAAO,MAAM,qBACZ,kBAAA,GAAA,EAAA,UAAA;QAAE;QACgD;QAChD,kBAAC,QAAD;SACE,UAAU,EAAO,KAAK;SACtB,OAAO,EAAW,EAAO,KAAK,kBAAkB;mBAE/C,EAAmB,EAAO,KAAK,kBAAkB;QAC9C,CAAA;QAAC;OAEP,EAAA,CAAA,IAEF;MAED,CAAA;MAEH,kBAAC,GAAD;OACE,OAAO,EAAa;OACpB,UAAS;MACV,CAAA;KACE;MACF;;EACQ,CAAA;CACF,CAAA;AAEnB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { LabAgentRun, LabRunRecommendation } from '../../types';
|
|
2
|
+
|
|
3
|
+
/** Narrow an unknown JSON value to a plain object, rejecting arrays and null. */
|
|
4
|
+
export declare function readJsonRecord(value: unknown): Record<string, unknown> | null;
|
|
5
|
+
/** Read a non-empty string property from an unknown JSON bag. */
|
|
6
|
+
export declare function readJsonString(value: unknown, key: string): string | null;
|
|
7
|
+
/** Read a finite number property from an unknown JSON bag. */
|
|
8
|
+
export declare function readJsonNumber(value: unknown, key: string): number | null;
|
|
9
|
+
/** Read a string[] property, dropping non-string members. */
|
|
10
|
+
export declare function readJsonStringArray(value: unknown, key: string): string[];
|
|
11
|
+
/** Narrow an unknown value to one of the four recommendation labels. */
|
|
12
|
+
export declare function readRecommendation(value: unknown): LabRunRecommendation | null;
|
|
13
|
+
/**
|
|
14
|
+
* What one ledger row decided, in the shape the decision card renders.
|
|
15
|
+
*
|
|
16
|
+
* Discriminated rather than a bag of optional fields so a card cannot, for
|
|
17
|
+
* example, show an override's note under a "rationale" heading.
|
|
18
|
+
*/
|
|
19
|
+
export type AgentDecision = {
|
|
20
|
+
kind: 'recommendation';
|
|
21
|
+
recommendation: LabRunRecommendation | null;
|
|
22
|
+
rationale: string | null;
|
|
23
|
+
confidence: number | null;
|
|
24
|
+
flags: string[];
|
|
25
|
+
suggestedParameters: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'override';
|
|
28
|
+
recommendation: LabRunRecommendation | null;
|
|
29
|
+
note: string | null;
|
|
30
|
+
proposedRecommendation: LabRunRecommendation | null;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'protocol';
|
|
33
|
+
protocolName: string | null;
|
|
34
|
+
summary: string | null;
|
|
35
|
+
stepCount: number | null;
|
|
36
|
+
estimatedMinutes: number | null;
|
|
37
|
+
materials: string[];
|
|
38
|
+
safetyNotes: string | null;
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'parse-error';
|
|
41
|
+
message: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'unrecognised';
|
|
44
|
+
raw: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'none';
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Classify a ledger row's `decision` payload.
|
|
50
|
+
*
|
|
51
|
+
* Order matters: an override row carries both `recommendation` and
|
|
52
|
+
* `status: 'OVERRIDDEN'`, so it must be matched before the plain recommendation
|
|
53
|
+
* shape or a researcher's own call would be rendered as the model's.
|
|
54
|
+
*/
|
|
55
|
+
export declare function describeDecision(decision: unknown): AgentDecision;
|
|
56
|
+
/**
|
|
57
|
+
* The experiment a ledger row was filed against, or null for rows that are not
|
|
58
|
+
* about one experiment (a project-scoped protocol suggestion, for instance).
|
|
59
|
+
* Both decision paths record it under `inputRefs.experimentId`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function experimentIdOfRun(run: Pick<LabAgentRun, 'inputRefs'>): string | null;
|
|
62
|
+
/** The prior run this row supersedes, set only on override rows. */
|
|
63
|
+
export declare function supersededRunIdOfRun(run: Pick<LabAgentRun, 'inputRefs'>): string | null;
|
|
64
|
+
/** `0.82` → `"82%"`; null/out-of-range → "—". */
|
|
65
|
+
export declare function formatConfidence(value: number | null): string;
|
|
66
|
+
/** `1840` → `"1.8s"`; sub-second latencies stay in milliseconds. */
|
|
67
|
+
export declare function formatLatency(ms: number | null): string;
|
|
68
|
+
/** `in`/`out` token counts as a single compact cell. */
|
|
69
|
+
export declare function formatTokens(tokensIn: number | null, tokensOut: number | null): string;
|
|
70
|
+
/**
|
|
71
|
+
* The current AI read stored on `LabExperiment.context.lastAiRecommendation`.
|
|
72
|
+
* Returns null when the experiment has never been assessed.
|
|
73
|
+
*/
|
|
74
|
+
export interface ExperimentAiRead {
|
|
75
|
+
recommendation: LabRunRecommendation | null;
|
|
76
|
+
status: string | null;
|
|
77
|
+
rationale: string | null;
|
|
78
|
+
agentRunId: string | null;
|
|
79
|
+
confidence: number | null;
|
|
80
|
+
}
|
|
81
|
+
export declare function readLastAiRecommendation(context: unknown): ExperimentAiRead | null;
|
|
82
|
+
//# sourceMappingURL=aiReaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiReaders.d.ts","sourceRoot":"","sources":["../../../../src/labsofscience/pages/ai/aiReaders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AASrE,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC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
|
|
2
|
+
var e = [
|
|
3
|
+
"REPLICATE",
|
|
4
|
+
"ADJUST_PARAMETERS",
|
|
5
|
+
"ESCALATE_REVIEW",
|
|
6
|
+
"CONCLUDE"
|
|
7
|
+
];
|
|
8
|
+
function t(e) {
|
|
9
|
+
return typeof e != "object" || !e || Array.isArray(e) ? null : e;
|
|
10
|
+
}
|
|
11
|
+
function n(e, n) {
|
|
12
|
+
let r = t(e)?.[n];
|
|
13
|
+
return typeof r == "string" && r.trim() || null;
|
|
14
|
+
}
|
|
15
|
+
function r(e, n) {
|
|
16
|
+
let r = t(e)?.[n];
|
|
17
|
+
return typeof r == "number" && Number.isFinite(r) ? r : null;
|
|
18
|
+
}
|
|
19
|
+
function i(e, n) {
|
|
20
|
+
let r = t(e)?.[n];
|
|
21
|
+
return Array.isArray(r) ? r.filter((e) => typeof e == "string" && e.trim() !== "") : [];
|
|
22
|
+
}
|
|
23
|
+
function a(t) {
|
|
24
|
+
return typeof t == "string" && e.includes(t) ? t : null;
|
|
25
|
+
}
|
|
26
|
+
function o(e) {
|
|
27
|
+
let o = t(e);
|
|
28
|
+
if (!o) return { kind: "none" };
|
|
29
|
+
let s = n(o, "parseError");
|
|
30
|
+
return s ? {
|
|
31
|
+
kind: "parse-error",
|
|
32
|
+
message: s
|
|
33
|
+
} : n(o, "status") === "OVERRIDDEN" ? {
|
|
34
|
+
kind: "override",
|
|
35
|
+
recommendation: a(o.recommendation),
|
|
36
|
+
note: n(o, "note"),
|
|
37
|
+
proposedRecommendation: a(o.proposedRecommendation)
|
|
38
|
+
} : "recommendation" in o || "rationale" in o ? {
|
|
39
|
+
kind: "recommendation",
|
|
40
|
+
recommendation: a(o.recommendation),
|
|
41
|
+
rationale: n(o, "rationale"),
|
|
42
|
+
confidence: r(o, "confidence"),
|
|
43
|
+
flags: i(o, "flags"),
|
|
44
|
+
suggestedParameters: o.suggestedParameters ?? null
|
|
45
|
+
} : "protocolName" in o || "steps" in o ? {
|
|
46
|
+
kind: "protocol",
|
|
47
|
+
protocolName: n(o, "protocolName"),
|
|
48
|
+
summary: n(o, "summary"),
|
|
49
|
+
stepCount: Array.isArray(o.steps) ? o.steps.length : null,
|
|
50
|
+
estimatedMinutes: r(o, "estimatedMinutes"),
|
|
51
|
+
materials: i(o, "materials"),
|
|
52
|
+
safetyNotes: n(o, "safetyNotes")
|
|
53
|
+
} : {
|
|
54
|
+
kind: "unrecognised",
|
|
55
|
+
raw: e
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function s(e) {
|
|
59
|
+
return n(e.inputRefs, "experimentId");
|
|
60
|
+
}
|
|
61
|
+
function c(e) {
|
|
62
|
+
return n(e.inputRefs, "supersedesRunId");
|
|
63
|
+
}
|
|
64
|
+
function l(e) {
|
|
65
|
+
return e === null || !Number.isFinite(e) ? "—" : `${Math.round(Math.min(Math.max(e, 0), 1) * 100)}%`;
|
|
66
|
+
}
|
|
67
|
+
function u(e) {
|
|
68
|
+
return e === null || !Number.isFinite(e) || e < 0 ? "—" : e < 1e3 ? `${Math.round(e)} ms` : `${(e / 1e3).toFixed(1)}s`;
|
|
69
|
+
}
|
|
70
|
+
function d(e, t) {
|
|
71
|
+
return e === null && t === null ? "—" : `${e ?? 0} in · ${t ?? 0} out`;
|
|
72
|
+
}
|
|
73
|
+
function f(e) {
|
|
74
|
+
let i = t(t(e)?.lastAiRecommendation);
|
|
75
|
+
return i ? {
|
|
76
|
+
recommendation: a(i.recommendation),
|
|
77
|
+
status: n(i, "status"),
|
|
78
|
+
rationale: n(i, "rationale"),
|
|
79
|
+
agentRunId: n(i, "agentRunId"),
|
|
80
|
+
confidence: r(i, "confidence")
|
|
81
|
+
} : null;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { o as describeDecision, s as experimentIdOfRun, l as formatConfidence, u as formatLatency, d as formatTokens, r as readJsonNumber, t as readJsonRecord, n as readJsonString, i as readJsonStringArray, f as readLastAiRecommendation, a as readRecommendation, c as supersededRunIdOfRun };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=aiReaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiReaders.js","names":[],"sources":["../../../../src/labsofscience/pages/ai/aiReaders.ts"],"sourcesContent":["/**\n * Readers for the AI decision ledger's free-form JSON columns.\n * @module labsofscience/pages/ai\n *\n * `LabAgentRun.decision` and `LabAgentRun.inputRefs` are `JSON` on the wire:\n * whatever the decision engine wrote at the time the row was appended. The\n * ledger is append-only and rows are never rewritten, so a page rendering it\n * must cope with shapes written by an older engine — including the deliberate\n * `{ parseError }` row the gateway writes when a provider answered with\n * something that was not valid JSON (the call itself still cost money and is\n * still recorded).\n *\n * Every reader here therefore takes `unknown` and narrows defensively rather\n * than casting. A shape the UI does not recognise renders as \"unrecognised\",\n * never as a crash and never as a silently empty card.\n */\n\nimport type { LabAgentRun, LabRunRecommendation } from '../../types';\n\nconst RECOMMENDATION_LABELS: readonly LabRunRecommendation[] = [\n 'REPLICATE',\n 'ADJUST_PARAMETERS',\n 'ESCALATE_REVIEW',\n 'CONCLUDE',\n];\n\n/** Narrow an unknown JSON value to a plain object, rejecting arrays and null. */\nexport function readJsonRecord(value: unknown): Record<string, unknown> | null {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return null;\n return value as Record<string, unknown>;\n}\n\n/** Read a non-empty string property from an unknown JSON bag. */\nexport function readJsonString(value: unknown, key: string): string | null {\n const record = readJsonRecord(value);\n const raw = record?.[key];\n if (typeof raw !== 'string') return null;\n const trimmed = raw.trim();\n return trimmed ? trimmed : null;\n}\n\n/** Read a finite number property from an unknown JSON bag. */\nexport function readJsonNumber(value: unknown, key: string): number | null {\n const record = readJsonRecord(value);\n const raw = record?.[key];\n return typeof raw === 'number' && Number.isFinite(raw) ? raw : null;\n}\n\n/** Read a string[] property, dropping non-string members. */\nexport function readJsonStringArray(value: unknown, key: string): string[] {\n const record = readJsonRecord(value);\n const raw = record?.[key];\n if (!Array.isArray(raw)) return [];\n return raw.filter((entry): entry is string => typeof entry === 'string' && entry.trim() !== '');\n}\n\n/** Narrow an unknown value to one of the four recommendation labels. */\nexport function readRecommendation(value: unknown): LabRunRecommendation | null {\n return typeof value === 'string' && RECOMMENDATION_LABELS.includes(value as LabRunRecommendation)\n ? (value as LabRunRecommendation)\n : null;\n}\n\n/**\n * What one ledger row decided, in the shape the decision card renders.\n *\n * Discriminated rather than a bag of optional fields so a card cannot, for\n * example, show an override's note under a \"rationale\" heading.\n */\nexport type AgentDecision =\n | {\n kind: 'recommendation';\n recommendation: LabRunRecommendation | null;\n rationale: string | null;\n confidence: number | null;\n flags: string[];\n suggestedParameters: unknown;\n }\n | {\n kind: 'override';\n recommendation: LabRunRecommendation | null;\n note: string | null;\n proposedRecommendation: LabRunRecommendation | null;\n }\n | {\n kind: 'protocol';\n protocolName: string | null;\n summary: string | null;\n stepCount: number | null;\n estimatedMinutes: number | null;\n materials: string[];\n safetyNotes: string | null;\n }\n | { kind: 'parse-error'; message: string }\n | { kind: 'unrecognised'; raw: unknown }\n | { kind: 'none' };\n\n/**\n * Classify a ledger row's `decision` payload.\n *\n * Order matters: an override row carries both `recommendation` and\n * `status: 'OVERRIDDEN'`, so it must be matched before the plain recommendation\n * shape or a researcher's own call would be rendered as the model's.\n */\nexport function describeDecision(decision: unknown): AgentDecision {\n const record = readJsonRecord(decision);\n if (!record) return { kind: 'none' };\n\n const parseError = readJsonString(record, 'parseError');\n if (parseError) return { kind: 'parse-error', message: parseError };\n\n if (readJsonString(record, 'status') === 'OVERRIDDEN') {\n return {\n kind: 'override',\n recommendation: readRecommendation(record.recommendation),\n note: readJsonString(record, 'note'),\n proposedRecommendation: readRecommendation(record.proposedRecommendation),\n };\n }\n\n if ('recommendation' in record || 'rationale' in record) {\n return {\n kind: 'recommendation',\n recommendation: readRecommendation(record.recommendation),\n rationale: readJsonString(record, 'rationale'),\n confidence: readJsonNumber(record, 'confidence'),\n flags: readJsonStringArray(record, 'flags'),\n suggestedParameters: record.suggestedParameters ?? null,\n };\n }\n\n if ('protocolName' in record || 'steps' in record) {\n return {\n kind: 'protocol',\n protocolName: readJsonString(record, 'protocolName'),\n summary: readJsonString(record, 'summary'),\n stepCount: Array.isArray(record.steps) ? record.steps.length : null,\n estimatedMinutes: readJsonNumber(record, 'estimatedMinutes'),\n materials: readJsonStringArray(record, 'materials'),\n safetyNotes: readJsonString(record, 'safetyNotes'),\n };\n }\n\n return { kind: 'unrecognised', raw: decision };\n}\n\n/**\n * The experiment a ledger row was filed against, or null for rows that are not\n * about one experiment (a project-scoped protocol suggestion, for instance).\n * Both decision paths record it under `inputRefs.experimentId`.\n */\nexport function experimentIdOfRun(run: Pick<LabAgentRun, 'inputRefs'>): string | null {\n return readJsonString(run.inputRefs, 'experimentId');\n}\n\n/** The prior run this row supersedes, set only on override rows. */\nexport function supersededRunIdOfRun(run: Pick<LabAgentRun, 'inputRefs'>): string | null {\n return readJsonString(run.inputRefs, 'supersedesRunId');\n}\n\n/** `0.82` → `\"82%\"`; null/out-of-range → \"—\". */\nexport function formatConfidence(value: number | null): string {\n if (value === null || !Number.isFinite(value)) return '—';\n const clamped = Math.min(Math.max(value, 0), 1);\n return `${Math.round(clamped * 100)}%`;\n}\n\n/** `1840` → `\"1.8s\"`; sub-second latencies stay in milliseconds. */\nexport function formatLatency(ms: number | null): string {\n if (ms === null || !Number.isFinite(ms) || ms < 0) return '—';\n if (ms < 1000) return `${Math.round(ms)} ms`;\n return `${(ms / 1000).toFixed(1)}s`;\n}\n\n/** `in`/`out` token counts as a single compact cell. */\nexport function formatTokens(tokensIn: number | null, tokensOut: number | null): string {\n if (tokensIn === null && tokensOut === null) return '—';\n return `${tokensIn ?? 0} in · ${tokensOut ?? 0} out`;\n}\n\n/**\n * The current AI read stored on `LabExperiment.context.lastAiRecommendation`.\n * Returns null when the experiment has never been assessed.\n */\nexport interface ExperimentAiRead {\n recommendation: LabRunRecommendation | null;\n status: string | null;\n rationale: string | null;\n agentRunId: string | null;\n confidence: number | null;\n}\n\nexport function readLastAiRecommendation(context: unknown): ExperimentAiRead | null {\n const record = readJsonRecord(context);\n const last = readJsonRecord(record?.lastAiRecommendation);\n if (!last) return null;\n return {\n recommendation: readRecommendation(last.recommendation),\n status: readJsonString(last, 'status'),\n rationale: readJsonString(last, 'rationale'),\n agentRunId: readJsonString(last, 'agentRunId'),\n confidence: readJsonNumber(last, 'confidence'),\n };\n}\n"],"mappings":";AAmBA,IAAM,IAAyD;CAC7D;CACA;CACA;CACA;AACF;AAGA,SAAgB,EAAe,GAAgD;CAE7E,OADI,OAAO,KAAU,aAAY,KAAkB,MAAM,QAAQ,CAAK,IAAU,OACzE;AACT;AAGA,SAAgB,EAAe,GAAgB,GAA4B;CAEzE,IAAM,IADS,EAAe,CAClB,CAAA,GAAS;CAGrB,OAFI,OAAO,KAAQ,YACH,EAAI,KACb,KAF6B;AAGtC;AAGA,SAAgB,EAAe,GAAgB,GAA4B;CAEzE,IAAM,IADS,EAAe,CAClB,CAAA,GAAS;CACrB,OAAO,OAAO,KAAQ,YAAY,OAAO,SAAS,CAAG,IAAI,IAAM;AACjE;AAGA,SAAgB,EAAoB,GAAgB,GAAuB;CAEzE,IAAM,IADS,EAAe,CAClB,CAAA,GAAS;CAErB,OADK,MAAM,QAAQ,CAAG,IACf,EAAI,QAAQ,MAA2B,OAAO,KAAU,YAAY,EAAM,KAAK,MAAM,EAAE,IAD9D,CAAC;AAEnC;AAGA,SAAgB,EAAmB,GAA6C;CAC9E,OAAO,OAAO,KAAU,YAAY,EAAsB,SAAS,CAA6B,IAC3F,IACD;AACN;AA2CA,SAAgB,EAAiB,GAAkC;CACjE,IAAM,IAAS,EAAe,CAAQ;CACtC,IAAI,CAAC,GAAQ,OAAO,EAAE,MAAM,OAAO;CAEnC,IAAM,IAAa,EAAe,GAAQ,YAAY;CAmCtD,OAlCI,IAAmB;EAAE,MAAM;EAAe,SAAS;CAAW,IAE9D,EAAe,GAAQ,QAAQ,MAAM,eAChC;EACL,MAAM;EACN,gBAAgB,E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EAAE,QAAQ,KAAa,EAAE;AACjD;AAcA,SAAgB,EAAyB,GAA2C;CAElF,IAAM,IAAO,EADE,EAAe,CACF,CAAA,EAAQ,oBAAoB;CAExD,OADK,IACE;EACL,gBAAgB,EAAmB,EAAK,cAAc;EACtD,QAAQ,EAAe,GAAM,QAAQ;EACrC,WAAW,EAAe,GAAM,WAAW;EAC3C,YAAY,EAAe,GAAM,YAAY;EAC7C,YAAY,EAAe,GAAM,YAAY;CAC/C,IAPkB;AAQpB"}
|
|
@@ -6,9 +6,9 @@ import { useExperiment as i, useTransitionExperiment as a } from "../../hooks/us
|
|
|
6
6
|
import { formatDate as o, titleCase as s } from "../../utils/formatters.js";
|
|
7
7
|
import { ExperimentFormDialog as c } from "./ExperimentFormDialog.js";
|
|
8
8
|
import { EmptyState as l } from "../../components/EmptyState.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { useLabActorNames as u } from "../../hooks/useLabActorNames.js";
|
|
10
|
+
import { BackLink as d, DetailField as f, DetailSection as p, JsonBlock as m, TagList as h } from "../shared/DetailComponents.js";
|
|
11
|
+
import { DiscussionPanel as g } from "../../components/DiscussionPanel.js";
|
|
12
12
|
import { CompleteRunDialog as _, StartRunDialog as v } from "./RunDialogs.js";
|
|
13
13
|
import { useState as y } from "react";
|
|
14
14
|
import { CheckCircle2 as b, FlaskConical as x, FolderKanban as S, Pencil as C, Play as w } from "lucide-react";
|
|
@@ -28,7 +28,7 @@ var I = [
|
|
|
28
28
|
"CANCELLED"
|
|
29
29
|
]);
|
|
30
30
|
function R() {
|
|
31
|
-
let { id: R } = T(), { navigateTo: z } = e(), B = i(R), V = a(), [H, U] = y(!1), [W, G] = y(!1), [K, q] = y(null), J = B.data, { nameOf: Y } =
|
|
31
|
+
let { id: R } = T(), { navigateTo: z } = e(), B = i(R), V = a(), [H, U] = y(!1), [W, G] = y(!1), [K, q] = y(null), J = B.data, { nameOf: Y } = u([J?.leadResearcherId, ...J?.runs.map((e) => e.performedById) ?? []]), X = [
|
|
32
32
|
{
|
|
33
33
|
key: "runNumber",
|
|
34
34
|
header: "Run",
|
|
@@ -93,7 +93,7 @@ function R() {
|
|
|
93
93
|
}) : void 0,
|
|
94
94
|
children: [/* @__PURE__ */ O("div", {
|
|
95
95
|
className: "space-y-4",
|
|
96
|
-
children: [/* @__PURE__ */ D(
|
|
96
|
+
children: [/* @__PURE__ */ D(d, {
|
|
97
97
|
label: "Experiments",
|
|
98
98
|
onClick: () => z("experiments")
|
|
99
99
|
}), /* @__PURE__ */ D(r, {
|
|
@@ -105,7 +105,7 @@ function R() {
|
|
|
105
105
|
children: J ? /* @__PURE__ */ O("div", {
|
|
106
106
|
className: "space-y-6",
|
|
107
107
|
children: [
|
|
108
|
-
/* @__PURE__ */ D(
|
|
108
|
+
/* @__PURE__ */ D(p, {
|
|
109
109
|
title: "Design",
|
|
110
110
|
action: /* @__PURE__ */ O("div", {
|
|
111
111
|
className: "flex items-center gap-2",
|
|
@@ -129,11 +129,11 @@ function R() {
|
|
|
129
129
|
children: /* @__PURE__ */ O("dl", {
|
|
130
130
|
className: "grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3",
|
|
131
131
|
children: [
|
|
132
|
-
/* @__PURE__ */ D(
|
|
132
|
+
/* @__PURE__ */ D(f, {
|
|
133
133
|
label: "Status",
|
|
134
134
|
children: /* @__PURE__ */ D(n, { status: J.status })
|
|
135
135
|
}),
|
|
136
|
-
/* @__PURE__ */ D(
|
|
136
|
+
/* @__PURE__ */ D(f, {
|
|
137
137
|
label: "Protocol",
|
|
138
138
|
children: J.protocolId ? /* @__PURE__ */ D("button", {
|
|
139
139
|
type: "button",
|
|
@@ -142,7 +142,7 @@ function R() {
|
|
|
142
142
|
children: "View protocol"
|
|
143
143
|
}) : "—"
|
|
144
144
|
}),
|
|
145
|
-
/* @__PURE__ */ D(
|
|
145
|
+
/* @__PURE__ */ D(f, {
|
|
146
146
|
label: "Project",
|
|
147
147
|
children: /* @__PURE__ */ O("button", {
|
|
148
148
|
type: "button",
|
|
@@ -151,37 +151,37 @@ function R() {
|
|
|
151
151
|
children: [/* @__PURE__ */ D(S, { className: "h-3.5 w-3.5" }), J.project?.name ?? "Open project"]
|
|
152
152
|
})
|
|
153
153
|
}),
|
|
154
|
-
/* @__PURE__ */ D(
|
|
154
|
+
/* @__PURE__ */ D(f, {
|
|
155
155
|
label: "Lead researcher",
|
|
156
156
|
children: Y(J.leadResearcherId)
|
|
157
157
|
}),
|
|
158
|
-
/* @__PURE__ */ D(
|
|
158
|
+
/* @__PURE__ */ D(f, {
|
|
159
159
|
label: "Hypothesis",
|
|
160
160
|
className: "sm:col-span-2 lg:col-span-3",
|
|
161
161
|
children: J.hypothesis ?? "—"
|
|
162
162
|
}),
|
|
163
|
-
/* @__PURE__ */ D(
|
|
163
|
+
/* @__PURE__ */ D(f, {
|
|
164
164
|
label: "Description",
|
|
165
165
|
className: "sm:col-span-2 lg:col-span-3",
|
|
166
166
|
children: J.description ?? "—"
|
|
167
167
|
}),
|
|
168
|
-
/* @__PURE__ */ D(
|
|
168
|
+
/* @__PURE__ */ D(f, {
|
|
169
169
|
label: "Variables",
|
|
170
170
|
className: "sm:col-span-2 lg:col-span-3",
|
|
171
|
-
children: /* @__PURE__ */ D(
|
|
171
|
+
children: /* @__PURE__ */ D(m, {
|
|
172
172
|
value: J.variables,
|
|
173
173
|
emptyLabel: "No variables defined"
|
|
174
174
|
})
|
|
175
175
|
}),
|
|
176
|
-
/* @__PURE__ */ D(
|
|
176
|
+
/* @__PURE__ */ D(f, {
|
|
177
177
|
label: "Tags",
|
|
178
178
|
className: "sm:col-span-2 lg:col-span-3",
|
|
179
|
-
children: /* @__PURE__ */ D(
|
|
179
|
+
children: /* @__PURE__ */ D(h, { tags: J.tags })
|
|
180
180
|
})
|
|
181
181
|
]
|
|
182
182
|
})
|
|
183
183
|
}),
|
|
184
|
-
/* @__PURE__ */ D(
|
|
184
|
+
/* @__PURE__ */ D(p, {
|
|
185
185
|
title: `Runs (${J.runs.length})`,
|
|
186
186
|
action: /* @__PURE__ */ O(k, {
|
|
187
187
|
size: "sm",
|
|
@@ -205,7 +205,7 @@ function R() {
|
|
|
205
205
|
})
|
|
206
206
|
})
|
|
207
207
|
}),
|
|
208
|
-
/* @__PURE__ */ D(
|
|
208
|
+
/* @__PURE__ */ D(g, {
|
|
209
209
|
entityType: "lab-experiment",
|
|
210
210
|
entityId: J.id
|
|
211
211
|
})
|
|
@@ -6,9 +6,9 @@ import { useExperiments as i } from "../../hooks/useLabsOfScienceApi.js";
|
|
|
6
6
|
import { formatDateShort as a, titleCase as o } from "../../utils/formatters.js";
|
|
7
7
|
import { ExperimentFormDialog as s } from "./ExperimentFormDialog.js";
|
|
8
8
|
import { EmptyState as c } from "../../components/EmptyState.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { useLabActorNames as l } from "../../hooks/useLabActorNames.js";
|
|
10
|
+
import { ListSearchInput as u } from "../../components/ListSearchInput.js";
|
|
11
|
+
import { useDebouncedValue as d } from "../../utils/useDebouncedValue.js";
|
|
12
12
|
import { useState as f } from "react";
|
|
13
13
|
import { FlaskConical as p, Plus as m } from "lucide-react";
|
|
14
14
|
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
@@ -22,14 +22,14 @@ var E = 20, D = [
|
|
|
22
22
|
"ABANDONED"
|
|
23
23
|
];
|
|
24
24
|
function O() {
|
|
25
|
-
let { navigateTo: O } = e(), [k, A] = f(1), [j, M] = f("ALL"), [N, P] = f(""), [F, I] = f(!1), L =
|
|
25
|
+
let { navigateTo: O } = e(), [k, A] = f(1), [j, M] = f("ALL"), [N, P] = f(""), [F, I] = f(!1), L = d(N.trim()), R = i({
|
|
26
26
|
status: j === "ALL" ? void 0 : j,
|
|
27
27
|
search: L || void 0,
|
|
28
28
|
pagination: {
|
|
29
29
|
limit: E,
|
|
30
30
|
offset: (k - 1) * E
|
|
31
31
|
}
|
|
32
|
-
}), z = R.data?.items ?? [], B = R.data?.pageInfo.hasMore ?? !1, { nameOf: V } =
|
|
32
|
+
}), z = R.data?.items ?? [], B = R.data?.pageInfo.hasMore ?? !1, { nameOf: V } = l(z.map((e) => e.leadResearcherId));
|
|
33
33
|
return /* @__PURE__ */ _(t, {
|
|
34
34
|
title: "Experiments",
|
|
35
35
|
description: "Designed studies that produce reproducible runs.",
|
|
@@ -41,7 +41,7 @@ function O() {
|
|
|
41
41
|
className: "space-y-4",
|
|
42
42
|
children: [/* @__PURE__ */ _("div", {
|
|
43
43
|
className: "flex flex-wrap items-center gap-3",
|
|
44
|
-
children: [/* @__PURE__ */ g(
|
|
44
|
+
children: [/* @__PURE__ */ g(u, {
|
|
45
45
|
value: N,
|
|
46
46
|
ariaLabel: "Search experiments",
|
|
47
47
|
placeholder: "Search experiments…",
|