@blackbelt-technology/pi-dashboard-sim-plugin 0.0.0-stage → 0.12.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/README.md CHANGED
@@ -1,3 +1,20 @@
1
- # Temporary Holding Version
1
+ # pi-dashboard-sim-plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Dashboard surfaces for Self-Improvement Memory (`pi-dashboard-sim-extension`).
4
+
5
+ - **Folder page** `/folder/:encodedCwd/sim` — Project / Global toggle; Problems
6
+ (list with hit rate, attempt timeline with model/project chips, predictions with
7
+ effective outcome and source — automatic outcomes are labelled *local
8
+ evidence*; mark, revert, approve, merge), Review (unlinked edit drafts → link or
9
+ dismiss, withheld attempts → approve, pending evidence), Settings (extra project
10
+ harness globs, `.pi/sim/config.json`).
11
+ - **Sidebar row** — `<n> problems · <m> pending · <k> unlinked`, hidden when the
12
+ folder has no records or drafts.
13
+ - **Settings section** — global globs, delivery budget, window N, hourly
14
+ auto-observe, web tool list (`<agent-dir>/sim/config.json`).
15
+ - **Observation job** — `runObservation` in a worker thread, hourly when
16
+ auto-observe is on, or `POST /api/sim/observe`.
17
+
18
+ Routes: `GET /api/sim/problems|problems/:id|unlinked|config` (observe tier),
19
+ `POST /api/sim/events|unlinked/:id/link|observe`, `DELETE /api/sim/unlinked/:id`,
20
+ `PUT /api/sim/config` (operate tier). Every `cwd` is admitted like kb-plugin.
package/package.json CHANGED
@@ -1,6 +1,88 @@
1
1
  {
2
2
  "name": "@blackbelt-technology/pi-dashboard-sim-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.12.1",
4
+ "description": "Dashboard plugin for Self-Improvement Memory (SIM): browse harness problems and attempts at project and global scope, review unlinked edits and withheld attempts, mark outcomes, revert, merge, and run the outcome observer.",
5
+ "keywords": [
6
+ "pi-dashboard-plugin"
7
+ ],
8
+ "license": "MIT",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "type": "module",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/BlackBeltTechnology/pi-agent-dashboard",
16
+ "directory": "packages/sim-plugin"
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "types": "./src/client/index.tsx",
21
+ "default": "./src/client/index.tsx"
22
+ },
23
+ "./client": {
24
+ "types": "./src/client/index.tsx",
25
+ "default": "./src/client/index.tsx"
26
+ },
27
+ "./server": {
28
+ "types": "./src/server/index.ts",
29
+ "default": "./src/server/index.ts"
30
+ }
31
+ },
32
+ "files": [
33
+ "src/",
34
+ "!**/AGENTS.md",
35
+ "!**/*.AGENTS.md",
36
+ "!**/__tests__",
37
+ "!**/*.test.ts",
38
+ "!**/*.test.tsx"
39
+ ],
40
+ "pi-dashboard-plugin": {
41
+ "id": "sim",
42
+ "displayName": "Self-Improvement Memory",
43
+ "i18nCatalog": "catalog",
44
+ "priority": 110,
45
+ "client": "./src/client/index.tsx",
46
+ "server": "./src/server/index.ts",
47
+ "claims": [
48
+ {
49
+ "slot": "sidebar-folder-section",
50
+ "component": "FolderSimSection"
51
+ },
52
+ {
53
+ "slot": "settings-section",
54
+ "component": "SimGlobalSettings",
55
+ "module": "./src/client/SimGlobalSettings.tsx"
56
+ },
57
+ {
58
+ "slot": "shell-overlay-route",
59
+ "component": "SimOverlayClaim",
60
+ "module": "./src/client/SimOverlayClaim.tsx",
61
+ "path": "/folder/:encodedCwd/sim",
62
+ "depth": 2,
63
+ "parentPath": "/folder/:encodedCwd"
64
+ }
65
+ ]
66
+ },
67
+ "peerDependencies": {
68
+ "fastify": "^5.0.0",
69
+ "react": ">=18.0.0",
70
+ "react-dom": ">=18.0.0",
71
+ "wouter": ">=3.0.0"
72
+ },
73
+ "dependencies": {
74
+ "@blackbelt-technology/dashboard-plugin-runtime": "^0.12.1",
75
+ "@blackbelt-technology/pi-dashboard-shared": "^0.12.1",
76
+ "@blackbelt-technology/pi-dashboard-sim-extension": "^0.12.1",
77
+ "@mdi/js": "^7.4.47",
78
+ "@mdi/react": "^1.6.1"
79
+ },
80
+ "devDependencies": {
81
+ "@types/react": "^19.0.0",
82
+ "@types/react-dom": "^19.0.0",
83
+ "fastify": "^5.0.0",
84
+ "react": "^19.0.0",
85
+ "react-dom": "^19.0.0",
86
+ "wouter": "^3.9.0"
87
+ }
88
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * FolderSimSection — `sidebar-folder-section` slot: `<n> problems · <m>
3
+ * pending · <k> unlinked`; hidden when the folder has no records or drafts.
4
+ * The pill opens the folder's SIM page. See change: add-self-improvement-memory.
5
+ */
6
+ import { SlotPill, useT } from "@blackbelt-technology/dashboard-plugin-runtime";
7
+ import type { FolderDescriptor } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/slot-props.js";
8
+ import { mdiHistory } from "@mdi/js";
9
+ import type React from "react";
10
+ import { useLocation } from "wouter";
11
+ import { simPageUrl } from "./sim-api.js";
12
+ import { useSimProblems } from "./useSimData.js";
13
+
14
+ export function FolderSimSection({ folder }: { folder: FolderDescriptor }): React.ReactElement | null {
15
+ const t = useT();
16
+ const cwd = folder?.cwd ?? "";
17
+ const [, navigate] = useLocation();
18
+ const { data } = useSimProblems("project", cwd);
19
+ const s = data?.summary;
20
+ if (!cwd || !s || (s.problems === 0 && s.unlinked === 0)) return null;
21
+ return (
22
+ <div data-testid="folder-sim-section" onClick={(e) => e.stopPropagation()}>
23
+ <SlotPill
24
+ glyph={mdiHistory}
25
+ accent="purple"
26
+ label={t("slotLabel", undefined, "Harness memory")}
27
+ activateTestId="folder-sim-open"
28
+ activateTitle={t("openSim", undefined, "Open self-improvement memory")}
29
+ onActivate={() => navigate(simPageUrl(cwd))}
30
+ >
31
+ <span className="tabular-nums text-[12px]" data-testid="folder-sim-count">
32
+ {t("slotCounts", { p: s.problems, m: s.pending, k: s.unlinked }, `${s.problems} problems · ${s.pending} pending · ${s.unlinked} unlinked`)}
33
+ </span>
34
+ </SlotPill>
35
+ </div>
36
+ );
37
+ }
@@ -0,0 +1,36 @@
1
+ /** Editable glob list (project Settings tab and global settings section). */
2
+ import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
3
+ import type React from "react";
4
+ import { useState } from "react";
5
+ import { BUTTON, INPUT } from "./chips.js";
6
+
7
+ export function GlobsEditor({ globs, onChange, testId }: { globs: string[]; onChange: (next: string[]) => void; testId: string }): React.ReactElement {
8
+ const t = useT();
9
+ const [draft, setDraft] = useState("");
10
+ return (
11
+ <div className="grid gap-1" data-testid={testId}>
12
+ {globs.map((g) => (
13
+ <div key={g} className="flex items-center gap-2">
14
+ <code className="text-[12px] text-[var(--text-secondary)] flex-1 break-all">{g}</code>
15
+ <button type="button" className={BUTTON} onClick={() => onChange(globs.filter((x) => x !== g))}>
16
+ {t("remove", undefined, "Remove")}
17
+ </button>
18
+ </div>
19
+ ))}
20
+ <form
21
+ className="flex gap-2"
22
+ onSubmit={(e) => {
23
+ e.preventDefault();
24
+ const v = draft.trim();
25
+ if (v && !globs.includes(v)) onChange([...globs, v]);
26
+ setDraft("");
27
+ }}
28
+ >
29
+ <input className={`${INPUT} flex-1 font-mono`} value={draft} onChange={(e) => setDraft(e.target.value)} placeholder=".pi/tools/**" aria-label={t("addGlob", undefined, "Add glob")} />
30
+ <button type="submit" className={BUTTON} disabled={!draft.trim()}>
31
+ {t("add", undefined, "Add")}
32
+ </button>
33
+ </form>
34
+ </div>
35
+ );
36
+ }
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Problem detail: header, merge control and the attempt timeline (edit,
3
+ * predictions with effective outcome + source + counts, status, provenance
4
+ * chips). Automatic outcomes are labelled "local evidence".
5
+ */
6
+ import { SelectField, useT } from "@blackbelt-technology/dashboard-plugin-runtime";
7
+ import type React from "react";
8
+ import { useState } from "react";
9
+ import type { OutcomeResult, SimAttempt, SimPrediction, SimProblemDetail, SimProblemSummary } from "../shared/types.js";
10
+ import { BUTTON, Chip, resultTone } from "./chips.js";
11
+ import { formatHitRate } from "./sim-api.js";
12
+
13
+ export interface TimelineActions {
14
+ mark: (attempt: string, prediction: number, result: OutcomeResult) => void;
15
+ revert: (attempt: string) => void;
16
+ approve: (attempt: string) => void;
17
+ merge: (from: string, into: string) => void;
18
+ }
19
+
20
+ const RESULTS: OutcomeResult[] = ["fixed", "reduced", "missed", "inconclusive"];
21
+
22
+ function PredictionRow({ attempt, p, i, actions }: { attempt: SimAttempt; p: SimPrediction; i: number; actions: TimelineActions }): React.ReactElement {
23
+ const t = useT();
24
+ const source =
25
+ p.source === "manual"
26
+ ? t("sourceManual", undefined, "manual")
27
+ : p.localEvidence
28
+ ? t("sourceLocal", { source: p.source }, `${p.source} · local evidence`)
29
+ : t("sourceNone", undefined, "no evidence yet");
30
+ return (
31
+ <li className="flex flex-wrap items-center gap-1.5 py-1" data-testid="sim-prediction">
32
+ <code className="text-[11px] text-[var(--text-secondary)] break-all">{p.value}</code>
33
+ <span className="text-[var(--text-tertiary)]" aria-hidden>
34
+ →
35
+ </span>
36
+ <Chip tone={resultTone(p.result)} testId="sim-prediction-result">
37
+ {p.result}
38
+ </Chip>
39
+ <span className="text-[11px] text-[var(--text-tertiary)]" data-testid="sim-outcome-source">
40
+ {source}
41
+ </span>
42
+ {p.counts && (
43
+ <span className="text-[11px] tabular-nums text-[var(--text-tertiary)]" title={t("countsTip", undefined, "sessions with the failure before → after")}>
44
+ {p.counts.cb}/{p.counts.nb} → {p.counts.ca}/{p.counts.na}
45
+ </span>
46
+ )}
47
+ {p.autoResult && p.autoResult !== p.result && (
48
+ <span className="text-[11px] text-[var(--text-tertiary)]">{t("autoWas", { result: p.autoResult }, `(local evidence: ${p.autoResult})`)}</span>
49
+ )}
50
+ {attempt.status !== "reverted" && (
51
+ <span className="ml-auto">
52
+ <SelectField
53
+ label={t("markOutcome", undefined, "Mark outcome")}
54
+ hint={null}
55
+ value=""
56
+ options={[{ value: "", label: "—" }, ...RESULTS.map((r) => ({ value: r, label: r }))]}
57
+ onChange={(v) => v && actions.mark(attempt.id, i, v as OutcomeResult)}
58
+ testIds={{ control: "sim-mark-select" }}
59
+ />
60
+ </span>
61
+ )}
62
+ </li>
63
+ );
64
+ }
65
+
66
+ function AttemptCard({ attempt, actions }: { attempt: SimAttempt; actions: TimelineActions }): React.ReactElement {
67
+ const t = useT();
68
+ const statusTone = attempt.status === "reverted" ? "warning" : attempt.status === "observed" ? "success" : "neutral";
69
+ return (
70
+ <li
71
+ className="relative pl-4 border-l border-[var(--border-secondary)] pb-4 last:pb-0"
72
+ data-testid="sim-attempt"
73
+ data-attempt-id={attempt.id}
74
+ data-status={attempt.status}
75
+ >
76
+ <span className="absolute -left-[5px] top-1.5 h-2 w-2 rounded-full bg-[var(--border-strong)]" aria-hidden />
77
+ <div className="flex flex-wrap items-center gap-1.5">
78
+ <time className="text-[11px] tabular-nums text-[var(--text-tertiary)]" dateTime={attempt.at}>
79
+ {attempt.at.slice(0, 16).replace("T", " ")}
80
+ </time>
81
+ <Chip tone={statusTone} testId="sim-attempt-status">
82
+ {attempt.status}
83
+ </Chip>
84
+ {attempt.provenance.model && (
85
+ <Chip testId="sim-model-chip" title={attempt.provenance.provider}>
86
+ {attempt.provenance.model}
87
+ </Chip>
88
+ )}
89
+ <Chip testId="sim-project-chip">{attempt.provenance.projectName}</Chip>
90
+ {attempt.trust !== "agent" && (
91
+ <Chip tone={attempt.trust === "web-derived" && !attempt.reviewed ? "warning" : "info"} testId="sim-trust-chip">
92
+ {attempt.trust === "web-derived"
93
+ ? attempt.reviewed
94
+ ? t("trustWebApproved", undefined, "web-derived · approved")
95
+ : t("trustWeb", undefined, "web-derived")
96
+ : t("trustUser", undefined, "linked by user")}
97
+ </Chip>
98
+ )}
99
+ {!attempt.deliverable && attempt.withheldReason && (
100
+ <Chip tone="warning" testId="sim-withheld-chip">
101
+ {t("withheldReason", { reason: attempt.withheldReason }, `withheld: ${attempt.withheldReason}`)}
102
+ </Chip>
103
+ )}
104
+ </div>
105
+ <p className="mt-1 text-[13px] text-[var(--text-primary)]">{attempt.what}</p>
106
+ <p className="mt-0.5 text-[12px] text-[var(--text-secondary)]">
107
+ <span className="text-[var(--text-tertiary)]">{t("rootCause", undefined, "Root cause:")} </span>
108
+ {attempt.rationale}
109
+ </p>
110
+ <p className="mt-0.5 text-[11px] text-[var(--text-tertiary)] break-all">{attempt.files.join(", ")}</p>
111
+ <ul className="mt-1">
112
+ {attempt.predictions.map((p, i) => (
113
+ <PredictionRow key={`${attempt.id}-${i}`} attempt={attempt} p={p} i={i} actions={actions} />
114
+ ))}
115
+ </ul>
116
+ <div className="mt-1 flex gap-2">
117
+ {attempt.trust === "web-derived" && !attempt.reviewed && (
118
+ <button type="button" className={BUTTON} data-testid="sim-approve" onClick={() => actions.approve(attempt.id)}>
119
+ {t("approve", undefined, "Approve")}
120
+ </button>
121
+ )}
122
+ {attempt.status !== "reverted" && (
123
+ <button type="button" className={BUTTON} data-testid="sim-revert" onClick={() => actions.revert(attempt.id)}>
124
+ {t("revert", undefined, "Mark reverted")}
125
+ </button>
126
+ )}
127
+ </div>
128
+ </li>
129
+ );
130
+ }
131
+
132
+ export function ProblemDetailView({
133
+ problem,
134
+ others,
135
+ actions,
136
+ }: {
137
+ problem: SimProblemDetail;
138
+ others: SimProblemSummary[];
139
+ actions: TimelineActions;
140
+ }): React.ReactElement {
141
+ const t = useT();
142
+ const [into, setInto] = useState("");
143
+ const targets = others.filter((o) => o.id !== problem.id);
144
+ return (
145
+ <section className="flex flex-col gap-3" data-testid="sim-problem-detail" data-problem-id={problem.id}>
146
+ <header>
147
+ <h2 className="text-[15px] font-semibold text-[var(--text-primary)]">
148
+ {problem.withheld ? t("withheldProblem", undefined, "(withheld problem)") : problem.name}
149
+ </h2>
150
+ {problem.description && <p className="text-[12px] text-[var(--text-secondary)]">{problem.description}</p>}
151
+ <p className="mt-1 text-[11px] text-[var(--text-tertiary)] tabular-nums">
152
+ {t("detailCounts", { n: problem.attempts, rate: formatHitRate(problem.hitRate) }, `${problem.attempts} attempts · hit rate ${formatHitRate(problem.hitRate)}`)}
153
+ <code className="ml-2 text-[var(--text-tertiary)]">{problem.id}</code>
154
+ </p>
155
+ </header>
156
+ {targets.length > 0 && (
157
+ <div className="flex flex-wrap items-end gap-2">
158
+ <SelectField
159
+ label={t("mergeInto", undefined, "Merge into")}
160
+ hint={null}
161
+ value={into}
162
+ options={[{ value: "", label: t("chooseProblem", undefined, "Choose a problem…") }, ...targets.map((o) => ({ value: o.id, label: o.name }))]}
163
+ onChange={setInto}
164
+ testIds={{ control: "sim-merge-select" }}
165
+ />
166
+ <button type="button" className={BUTTON} data-testid="sim-merge-apply" disabled={!into} onClick={() => actions.merge(problem.id, into)}>
167
+ {t("merge", undefined, "Merge")}
168
+ </button>
169
+ </div>
170
+ )}
171
+ <ol className="ml-1" data-testid="sim-timeline">
172
+ {problem.timeline.map((a) => (
173
+ <AttemptCard key={a.id} attempt={a} actions={actions} />
174
+ ))}
175
+ </ol>
176
+ </section>
177
+ );
178
+ }
@@ -0,0 +1,150 @@
1
+ /** Review tab: pending observations, unlinked edit drafts (link / dismiss), withheld attempts (approve). */
2
+ import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
3
+ import type React from "react";
4
+ import { useState } from "react";
5
+ import type { SimDraft, SimProblemsResponse, SimProblemSummary } from "../shared/types.js";
6
+ import { BUTTON, BUTTON_PRIMARY, Chip, HEADING, INPUT } from "./chips.js";
7
+ import { type LinkBody, parsePredictionSpec } from "./sim-api.js";
8
+
9
+ export interface ReviewActions {
10
+ link: (draft: string, body: LinkBody) => Promise<void>;
11
+ dismiss: (draft: string) => void;
12
+ approve: (attempt: string) => void;
13
+ open: (problemId: string) => void;
14
+ }
15
+
16
+ function LinkForm({ draft, problems, onLink, onCancel }: { draft: SimDraft; problems: SimProblemSummary[]; onLink: (b: LinkBody) => Promise<void>; onCancel: () => void }): React.ReactElement {
17
+ const t = useT();
18
+ const [problem, setProblem] = useState("");
19
+ const [rationale, setRationale] = useState("");
20
+ const [predict, setPredict] = useState("");
21
+ const [error, setError] = useState<string>();
22
+ const existing = problems.find((p) => p.name === problem.trim());
23
+ const ready = problem.trim() && rationale.trim() && predict.trim();
24
+ return (
25
+ <form
26
+ className="mt-2 grid gap-2"
27
+ data-testid="sim-link-form"
28
+ onSubmit={(e) => {
29
+ e.preventDefault();
30
+ if (!ready) return;
31
+ const predicted = predict.split("\n").map((s) => s.trim()).filter(Boolean).map(parsePredictionSpec);
32
+ onLink({ problem: existing ? { id: existing.id } : { name: problem.trim() }, rationale: rationale.trim(), predicted }).catch((err: unknown) =>
33
+ setError(err instanceof Error ? err.message : String(err)),
34
+ );
35
+ }}
36
+ >
37
+ <label className="grid gap-0.5 text-[11px] text-[var(--text-tertiary)]">
38
+ {t("problemField", undefined, "Problem (existing name or a new one)")}
39
+ <input className={INPUT} list={`sim-problems-${draft.id}`} value={problem} onChange={(e) => setProblem(e.target.value)} data-testid="sim-link-problem" />
40
+ <datalist id={`sim-problems-${draft.id}`}>
41
+ {problems.map((p) => (
42
+ <option key={p.id} value={p.name} />
43
+ ))}
44
+ </datalist>
45
+ </label>
46
+ <label className="grid gap-0.5 text-[11px] text-[var(--text-tertiary)]">
47
+ {t("rationaleField", undefined, "Root cause the edit addresses")}
48
+ <textarea className={INPUT} rows={2} value={rationale} onChange={(e) => setRationale(e.target.value)} data-testid="sim-link-rationale" />
49
+ </label>
50
+ <label className="grid gap-0.5 text-[11px] text-[var(--text-tertiary)]">
51
+ {t("predictField", undefined, "Predictions, one per line (err:<tool>:<class> or an oracle command)")}
52
+ <textarea className={`${INPUT} font-mono`} rows={2} value={predict} onChange={(e) => setPredict(e.target.value)} data-testid="sim-link-predict" />
53
+ </label>
54
+ {error && (
55
+ <p role="alert" className="text-[12px] text-[var(--severity-error-fg)]" data-testid="sim-link-error">
56
+ {error}
57
+ </p>
58
+ )}
59
+ <div className="flex gap-2">
60
+ <button type="submit" className={BUTTON_PRIMARY} disabled={!ready} data-testid="sim-link-submit">
61
+ {t("linkSubmit", undefined, "Record attempt")}
62
+ </button>
63
+ <button type="button" className={BUTTON} onClick={onCancel}>
64
+ {t("cancel", undefined, "Cancel")}
65
+ </button>
66
+ </div>
67
+ </form>
68
+ );
69
+ }
70
+
71
+ export function ReviewQueues({ data, drafts, actions }: { data: SimProblemsResponse; drafts: SimDraft[]; actions: ReviewActions }): React.ReactElement {
72
+ const t = useT();
73
+ const [linking, setLinking] = useState<string>();
74
+ const scoped = drafts.filter((d) => d.scope === data.scope);
75
+ return (
76
+ <div className="grid gap-5">
77
+ <section data-testid="sim-unlinked-queue">
78
+ <h3 className={HEADING}>{t("unlinkedHeading", { n: scoped.length }, `Unlinked harness edits (${scoped.length})`)}</h3>
79
+ {scoped.length === 0 && <p className="mt-1 text-[12px] text-[var(--text-tertiary)]">{t("noUnlinked", undefined, "Every harness edit has a record.")}</p>}
80
+ <ul className="mt-1 grid gap-2">
81
+ {scoped.map((d) => (
82
+ <li key={d.id} className="rounded border border-[var(--border-subtle)] bg-[var(--bg-secondary)] p-2" data-testid="sim-draft-row" data-draft-id={d.id}>
83
+ <div className="flex flex-wrap items-center gap-2">
84
+ <code className="text-[12px] text-[var(--text-primary)] break-all">{d.path}</code>
85
+ <Chip>{d.tool}</Chip>
86
+ {d.model && <Chip testId="sim-model-chip">{d.model}</Chip>}
87
+ <time className="text-[11px] text-[var(--text-tertiary)] tabular-nums" dateTime={d.at}>
88
+ {d.at.slice(0, 16).replace("T", " ")}
89
+ </time>
90
+ <span className="ml-auto flex gap-2">
91
+ <button type="button" className={BUTTON} data-testid="sim-draft-link" onClick={() => setLinking(linking === d.id ? undefined : d.id)}>
92
+ {t("link", undefined, "Link…")}
93
+ </button>
94
+ <button type="button" className={BUTTON} data-testid="sim-draft-dismiss" onClick={() => actions.dismiss(d.id)}>
95
+ {t("dismiss", undefined, "Dismiss")}
96
+ </button>
97
+ </span>
98
+ </div>
99
+ {linking === d.id && (
100
+ <LinkForm
101
+ draft={d}
102
+ problems={data.problems}
103
+ onCancel={() => setLinking(undefined)}
104
+ onLink={async (b) => {
105
+ await actions.link(d.id, b);
106
+ setLinking(undefined);
107
+ }}
108
+ />
109
+ )}
110
+ </li>
111
+ ))}
112
+ </ul>
113
+ </section>
114
+ <section data-testid="sim-withheld-queue">
115
+ <h3 className={HEADING}>{t("withheldHeading", { n: data.withheldQueue.length }, `Withheld from agents (${data.withheldQueue.length})`)}</h3>
116
+ {data.withheldQueue.length === 0 && <p className="mt-1 text-[12px] text-[var(--text-tertiary)]">{t("noWithheld", undefined, "Nothing withheld.")}</p>}
117
+ <ul className="mt-1 grid gap-1">
118
+ {data.withheldQueue.map((w) => (
119
+ <li key={w.attempt} className="flex flex-wrap items-center gap-2 text-[12px]" data-testid="sim-withheld-row" data-attempt-id={w.attempt}>
120
+ <button type="button" className="text-[var(--accent-text)] hover:underline" onClick={() => actions.open(w.problemId)}>
121
+ <code>{w.attempt}</code>
122
+ </button>
123
+ <Chip tone="warning">{w.reason}</Chip>
124
+ {w.trust === "web-derived" && w.reason.includes("web-derived") && (
125
+ <button type="button" className={`${BUTTON} ml-auto`} data-testid="sim-approve" onClick={() => actions.approve(w.attempt)}>
126
+ {t("approve", undefined, "Approve")}
127
+ </button>
128
+ )}
129
+ </li>
130
+ ))}
131
+ </ul>
132
+ </section>
133
+ <section data-testid="sim-pending-queue">
134
+ <h3 className={HEADING}>{t("pendingHeading", { n: data.pendingQueue.length }, `Waiting for evidence (${data.pendingQueue.length})`)}</h3>
135
+ <ul className="mt-1 grid gap-1">
136
+ {data.pendingQueue.map((p) => (
137
+ <li key={p.attempt} className="flex items-center gap-2 text-[12px]" data-testid="sim-pending-row">
138
+ <button type="button" className="text-[var(--accent-text)] hover:underline truncate" onClick={() => actions.open(p.problemId)}>
139
+ {p.what}
140
+ </button>
141
+ <time className="ml-auto text-[11px] text-[var(--text-tertiary)] tabular-nums" dateTime={p.at}>
142
+ {p.at.slice(0, 10)}
143
+ </time>
144
+ </li>
145
+ ))}
146
+ </ul>
147
+ </section>
148
+ </div>
149
+ );
150
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * SimGlobalSettings — `settings-section` slot: global SIM settings
3
+ * (`<agent-dir>/sim/config.json`): global harness globs, delivery budget,
4
+ * window N, auto-observe, web tool list. See change: add-self-improvement-memory.
5
+ */
6
+ import { ToggleField, useT } from "@blackbelt-technology/dashboard-plugin-runtime";
7
+ import type React from "react";
8
+ import { useEffect, useState } from "react";
9
+ import type { SimGlobalConfig } from "../shared/types.js";
10
+ import { BUTTON_PRIMARY, HEADING, INPUT } from "./chips.js";
11
+ import { GlobsEditor } from "./GlobsEditor.js";
12
+ import { fetchGlobalConfig, saveGlobalConfig } from "./sim-api.js";
13
+
14
+ export function SimGlobalSettings(): React.ReactElement {
15
+ const t = useT();
16
+ const [cfg, setCfg] = useState<SimGlobalConfig>();
17
+ const [error, setError] = useState<string>();
18
+ const [saved, setSaved] = useState(false);
19
+ useEffect(() => {
20
+ fetchGlobalConfig().then(setCfg, (e: unknown) => setError(e instanceof Error ? e.message : String(e)));
21
+ }, []);
22
+ if (!cfg) return <div className="text-[12px] text-[var(--text-tertiary)]">{error ?? t("loading", undefined, "Loading…")}</div>;
23
+ const set = (patch: Partial<SimGlobalConfig>) => {
24
+ setSaved(false);
25
+ setCfg({ ...cfg, ...patch });
26
+ };
27
+ return (
28
+ <form
29
+ className="grid gap-3 max-w-2xl"
30
+ data-testid="sim-global-settings"
31
+ onSubmit={(e) => {
32
+ e.preventDefault();
33
+ const { invalid: _i, defaults: _d, ...patch } = cfg;
34
+ saveGlobalConfig(patch).then(
35
+ () => {
36
+ setError(undefined);
37
+ setSaved(true);
38
+ },
39
+ (err: unknown) => setError(err instanceof Error ? err.message : String(err)),
40
+ );
41
+ }}
42
+ >
43
+ <h3 className={HEADING}>{t("globalGlobs", undefined, "Global harness paths (relative to the agent dir)")}</h3>
44
+ <GlobsEditor globs={cfg.harnessGlobs} onChange={(harnessGlobs) => set({ harnessGlobs })} testId="sim-global-globs" />
45
+ <label className="grid gap-0.5 text-[12px] text-[var(--text-secondary)]">
46
+ {t("budget", undefined, "Delivery budget per scope (bytes)")}
47
+ <input type="number" min={1024} className={INPUT} value={cfg.deliveryBudget} onChange={(e) => set({ deliveryBudget: Number(e.target.value) })} />
48
+ </label>
49
+ <label className="grid gap-0.5 text-[12px] text-[var(--text-secondary)]">
50
+ {t("windowN", undefined, "Observation window (sessions before / after)")}
51
+ <input type="number" min={1} className={INPUT} value={cfg.windowN} onChange={(e) => set({ windowN: Number(e.target.value) })} />
52
+ </label>
53
+ <ToggleField
54
+ label={t("autoObserve", undefined, "Observe outcomes every hour")}
55
+ hint={null}
56
+ value={cfg.autoObserve}
57
+ onChange={(autoObserve) => set({ autoObserve })}
58
+ testIds={{ control: "sim-auto-observe" }}
59
+ />
60
+ <label className="grid gap-0.5 text-[12px] text-[var(--text-secondary)]">
61
+ {t("webTools", undefined, "Web tools (records after these are withheld until reviewed), comma separated")}
62
+ <input className={`${INPUT} font-mono`} value={cfg.webTools.join(", ")} onChange={(e) => set({ webTools: e.target.value.split(",").map((s) => s.trim()).filter(Boolean) })} />
63
+ </label>
64
+ {error && (
65
+ <p role="alert" className="text-[12px] text-[var(--severity-error-fg)]">
66
+ {error}
67
+ </p>
68
+ )}
69
+ <div className="flex items-center gap-2">
70
+ <button type="submit" className={BUTTON_PRIMARY}>
71
+ {t("save", undefined, "Save")}
72
+ </button>
73
+ {saved && <span className="text-[12px] text-[var(--severity-success-fg)]">{t("saved", undefined, "Saved")}</span>}
74
+ </div>
75
+ </form>
76
+ );
77
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * SimOverlayClaim — `shell-overlay-route` claim for `/folder/:encodedCwd/sim`.
3
+ * The host decodes the folder path into `cwd`. See change: add-self-improvement-memory.
4
+ */
5
+ import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
6
+ import type React from "react";
7
+ import { SimPage } from "./SimPage.js";
8
+
9
+ interface Props {
10
+ params: Record<string, string>;
11
+ cwd?: string;
12
+ onBack: () => void;
13
+ }
14
+
15
+ export function SimOverlayClaim({ cwd, onBack }: Props): React.ReactElement {
16
+ const t = useT();
17
+ if (!cwd) {
18
+ return (
19
+ <div className="p-4 text-xs text-[var(--severity-error-fg)]" data-testid="sim-bad-cwd">
20
+ {t("invalidFolderPath", undefined, "Invalid folder path.")}
21
+ </div>
22
+ );
23
+ }
24
+ return <SimPage cwd={cwd} onBack={onBack} />;
25
+ }
26
+