@locusgraph/loop 0.0.0-stage → 0.1.0

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 (202) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -2
  3. package/dist/agent/index.d.ts +5 -0
  4. package/dist/agent/index.js +5 -0
  5. package/dist/agent/pulse/gradient-label.d.ts +7 -0
  6. package/dist/agent/pulse/gradient-label.js +23 -0
  7. package/dist/agent/pulse/marks/bars-mark.d.ts +1 -0
  8. package/dist/agent/pulse/marks/bars-mark.js +15 -0
  9. package/dist/agent/pulse/marks/glyph-mark.d.ts +4 -0
  10. package/dist/agent/pulse/marks/glyph-mark.js +17 -0
  11. package/dist/agent/pulse/marks/locus-mark.d.ts +1 -0
  12. package/dist/agent/pulse/marks/locus-mark.js +38 -0
  13. package/dist/agent/pulse/marks/orb-mark.d.ts +1 -0
  14. package/dist/agent/pulse/marks/orb-mark.js +11 -0
  15. package/dist/agent/pulse/marks/spinner-mark.d.ts +1 -0
  16. package/dist/agent/pulse/marks/spinner-mark.js +4 -0
  17. package/dist/agent/pulse/pulse-tone.d.ts +1 -0
  18. package/dist/agent/pulse/pulse-tone.js +1 -0
  19. package/dist/agent/pulse/pulse.d.ts +12 -0
  20. package/dist/agent/pulse/pulse.js +51 -0
  21. package/dist/agent/pulse/use-loop-animation.d.ts +2 -0
  22. package/dist/agent/pulse/use-loop-animation.js +21 -0
  23. package/dist/agent/shared/status-dot.d.ts +1 -0
  24. package/dist/agent/shared/status-dot.js +1 -0
  25. package/dist/agent/steps/step-icon.d.ts +8 -0
  26. package/dist/agent/steps/step-icon.js +31 -0
  27. package/dist/agent/steps/steps.d.ts +7 -0
  28. package/dist/agent/steps/steps.js +39 -0
  29. package/dist/agent/thinking/thinking.d.ts +6 -0
  30. package/dist/agent/thinking/thinking.js +31 -0
  31. package/dist/agent/thinking/thought-duration.d.ts +2 -0
  32. package/dist/agent/thinking/thought-duration.js +13 -0
  33. package/dist/agent/tool/json-block.d.ts +5 -0
  34. package/dist/agent/tool/json-block.js +15 -0
  35. package/dist/agent/tool/tool-status.d.ts +6 -0
  36. package/dist/agent/tool/tool-status.js +26 -0
  37. package/dist/agent/tool/tool.d.ts +7 -0
  38. package/dist/agent/tool/tool.js +14 -0
  39. package/dist/approval/inbox/inbox-row.d.ts +11 -0
  40. package/dist/approval/inbox/inbox-row.js +14 -0
  41. package/dist/approval/inbox/inbox-selection.d.ts +6 -0
  42. package/dist/approval/inbox/inbox-selection.js +21 -0
  43. package/dist/approval/inbox/inbox.d.ts +11 -0
  44. package/dist/approval/inbox/inbox.js +26 -0
  45. package/dist/approval/index.d.ts +9 -0
  46. package/dist/approval/index.js +8 -0
  47. package/dist/approval/memory/memory-choices.d.ts +10 -0
  48. package/dist/approval/memory/memory-choices.js +30 -0
  49. package/dist/approval/memory/memory-review.d.ts +11 -0
  50. package/dist/approval/memory/memory-review.js +31 -0
  51. package/dist/approval/memory/memory-row.d.ts +9 -0
  52. package/dist/approval/memory/memory-row.js +30 -0
  53. package/dist/approval/plan/plan-review.d.ts +13 -0
  54. package/dist/approval/plan/plan-review.js +38 -0
  55. package/dist/approval/plan/plan-step-row.d.ts +13 -0
  56. package/dist/approval/plan/plan-step-row.js +50 -0
  57. package/dist/approval/plan/plan-steps.d.ts +8 -0
  58. package/dist/approval/plan/plan-steps.js +29 -0
  59. package/dist/approval/plan/question-choices.d.ts +10 -0
  60. package/dist/approval/plan/question-choices.js +47 -0
  61. package/dist/approval/plan/question.d.ts +18 -0
  62. package/dist/approval/plan/question.js +35 -0
  63. package/dist/approval/run/run-bar.d.ts +13 -0
  64. package/dist/approval/run/run-bar.js +33 -0
  65. package/dist/approval/shared/decision-line.d.ts +1 -0
  66. package/dist/approval/shared/decision-line.js +1 -0
  67. package/dist/approval/shared/risk-badge.d.ts +10 -0
  68. package/dist/approval/shared/risk-badge.js +26 -0
  69. package/dist/approval/shared/time.d.ts +3 -0
  70. package/dist/approval/shared/time.js +15 -0
  71. package/dist/approval/shared/use-focus-on-mount.d.ts +2 -0
  72. package/dist/approval/shared/use-focus-on-mount.js +9 -0
  73. package/dist/approval/spend/raise-cap-form.d.ts +8 -0
  74. package/dist/approval/spend/raise-cap-form.js +26 -0
  75. package/dist/approval/spend/spend-gate.d.ts +16 -0
  76. package/dist/approval/spend/spend-gate.js +32 -0
  77. package/dist/approval/spend/spend-math.d.ts +5 -0
  78. package/dist/approval/spend/spend-math.js +18 -0
  79. package/dist/approval/spend/spend-meter.d.ts +10 -0
  80. package/dist/approval/spend/spend-meter.js +49 -0
  81. package/dist/approval/tool/approval.d.ts +14 -0
  82. package/dist/approval/tool/approval.js +45 -0
  83. package/dist/approval/tool/args/args-editor.d.ts +16 -0
  84. package/dist/approval/tool/args/args-editor.js +37 -0
  85. package/dist/approval/tool/args/args-field.d.ts +11 -0
  86. package/dist/approval/tool/args/args-field.js +28 -0
  87. package/dist/approval/tool/args/args-validation.d.ts +8 -0
  88. package/dist/approval/tool/args/args-validation.js +59 -0
  89. package/dist/approval/tool/deny-form.d.ts +6 -0
  90. package/dist/approval/tool/deny-form.js +15 -0
  91. package/dist/approval/tool/tool-inputs.d.ts +6 -0
  92. package/dist/approval/tool/tool-inputs.js +53 -0
  93. package/dist/approval/types.d.ts +59 -0
  94. package/dist/approval/types.js +1 -0
  95. package/dist/chat/chat/chat.d.ts +7 -0
  96. package/dist/chat/chat/chat.js +11 -0
  97. package/dist/chat/chat/use-stick-to-bottom.d.ts +7 -0
  98. package/dist/chat/chat/use-stick-to-bottom.js +57 -0
  99. package/dist/chat/composer/composer-actions.d.ts +15 -0
  100. package/dist/chat/composer/composer-actions.js +23 -0
  101. package/dist/chat/composer/composer.d.ts +20 -0
  102. package/dist/chat/composer/composer.js +42 -0
  103. package/dist/chat/composer/use-auto-grow.d.ts +2 -0
  104. package/dist/chat/composer/use-auto-grow.js +14 -0
  105. package/dist/chat/files/file-meta.d.ts +13 -0
  106. package/dist/chat/files/file-meta.js +30 -0
  107. package/dist/chat/files/files.d.ts +9 -0
  108. package/dist/chat/files/files.js +39 -0
  109. package/dist/chat/index.d.ts +7 -0
  110. package/dist/chat/index.js +7 -0
  111. package/dist/chat/reply/fenced-code.d.ts +8 -0
  112. package/dist/chat/reply/fenced-code.js +29 -0
  113. package/dist/chat/reply/markdown-components.d.ts +2 -0
  114. package/dist/chat/reply/markdown-components.js +22 -0
  115. package/dist/chat/reply/reply.d.ts +8 -0
  116. package/dist/chat/reply/reply.js +21 -0
  117. package/dist/chat/turn/group-parts.d.ts +24 -0
  118. package/dist/chat/turn/group-parts.js +35 -0
  119. package/dist/chat/turn/turn.d.ts +11 -0
  120. package/dist/chat/turn/turn.js +45 -0
  121. package/dist/cost/context.d.ts +13 -0
  122. package/dist/cost/context.js +35 -0
  123. package/dist/cost/cost-steps.d.ts +17 -0
  124. package/dist/cost/cost-steps.js +24 -0
  125. package/dist/cost/cost.d.ts +8 -0
  126. package/dist/cost/cost.js +37 -0
  127. package/dist/cost/index.d.ts +4 -0
  128. package/dist/cost/index.js +4 -0
  129. package/dist/cost/model-picker.d.ts +11 -0
  130. package/dist/cost/model-picker.js +9 -0
  131. package/dist/cost/shared/context-breakdown.d.ts +15 -0
  132. package/dist/cost/shared/context-breakdown.js +17 -0
  133. package/dist/cost/shared/meter-marks.d.ts +9 -0
  134. package/dist/cost/shared/meter-marks.js +16 -0
  135. package/dist/cost/shared/model-option-row.d.ts +14 -0
  136. package/dist/cost/shared/model-option-row.js +32 -0
  137. package/dist/cost/shared/step-cost-row.d.ts +15 -0
  138. package/dist/cost/shared/step-cost-row.js +34 -0
  139. package/dist/cost/shared/usage-totals.d.ts +11 -0
  140. package/dist/cost/shared/usage-totals.js +26 -0
  141. package/dist/index.d.ts +7 -0
  142. package/dist/index.js +7 -0
  143. package/dist/memory/cite.d.ts +8 -0
  144. package/dist/memory/cite.js +19 -0
  145. package/dist/memory/index.d.ts +5 -0
  146. package/dist/memory/index.js +4 -0
  147. package/dist/memory/memorized.d.ts +14 -0
  148. package/dist/memory/memorized.js +19 -0
  149. package/dist/memory/recall.d.ts +9 -0
  150. package/dist/memory/recall.js +24 -0
  151. package/dist/memory/shared/disclosure.d.ts +6 -0
  152. package/dist/memory/shared/disclosure.js +6 -0
  153. package/dist/memory/shared/host-label.d.ts +6 -0
  154. package/dist/memory/shared/host-label.js +34 -0
  155. package/dist/memory/shared/source-mark.d.ts +5 -0
  156. package/dist/memory/shared/source-mark.js +6 -0
  157. package/dist/memory/sources.d.ts +9 -0
  158. package/dist/memory/sources.js +22 -0
  159. package/dist/shared/decision-summary.d.ts +18 -0
  160. package/dist/shared/decision-summary.js +25 -0
  161. package/dist/shared/panel-empty.d.ts +8 -0
  162. package/dist/shared/panel-empty.js +5 -0
  163. package/dist/shared/panel.d.ts +19 -0
  164. package/dist/shared/panel.js +21 -0
  165. package/dist/shared/status-dot.d.ts +6 -0
  166. package/dist/shared/status-dot.js +12 -0
  167. package/dist/sources.css +1 -0
  168. package/dist/thread/actions/action-button.d.ts +8 -0
  169. package/dist/thread/actions/action-button.js +5 -0
  170. package/dist/thread/actions/actions.d.ts +13 -0
  171. package/dist/thread/actions/actions.js +21 -0
  172. package/dist/thread/actions/branch-switcher.d.ts +10 -0
  173. package/dist/thread/actions/branch-switcher.js +7 -0
  174. package/dist/thread/canvas/canvas.d.ts +14 -0
  175. package/dist/thread/canvas/canvas.js +12 -0
  176. package/dist/thread/canvas/version-switcher.d.ts +12 -0
  177. package/dist/thread/canvas/version-switcher.js +11 -0
  178. package/dist/thread/code/code.d.ts +10 -0
  179. package/dist/thread/code/code.js +33 -0
  180. package/dist/thread/code/copy-code-button.d.ts +6 -0
  181. package/dist/thread/code/copy-code-button.js +18 -0
  182. package/dist/thread/code/highlight.d.ts +1 -0
  183. package/dist/thread/code/highlight.js +39 -0
  184. package/dist/thread/history/history-row.d.ts +14 -0
  185. package/dist/thread/history/history-row.js +17 -0
  186. package/dist/thread/history/history.d.ts +15 -0
  187. package/dist/thread/history/history.js +10 -0
  188. package/dist/thread/history/thread-groups.d.ts +8 -0
  189. package/dist/thread/history/thread-groups.js +46 -0
  190. package/dist/thread/history/thread-item-menu.d.ts +7 -0
  191. package/dist/thread/history/thread-item-menu.js +6 -0
  192. package/dist/thread/history/thread-title-editor.d.ts +7 -0
  193. package/dist/thread/history/thread-title-editor.js +25 -0
  194. package/dist/thread/index.d.ts +8 -0
  195. package/dist/thread/index.js +5 -0
  196. package/dist/thread/starters/starters.d.ts +12 -0
  197. package/dist/thread/starters/starters.js +15 -0
  198. package/dist/thread/use-copied.d.ts +5 -0
  199. package/dist/thread/use-copied.js +22 -0
  200. package/dist/types.d.ts +70 -0
  201. package/dist/types.js +3 -0
  202. package/package.json +57 -3
@@ -0,0 +1,21 @@
1
+ export function bulkApprovable(items) {
2
+ return items.filter((item) => item.risk !== "destructive");
3
+ }
4
+ export function selectedIn(items, selected) {
5
+ return bulkApprovable(items)
6
+ .map((item) => item.id)
7
+ .filter((id) => selected.has(id));
8
+ }
9
+ export function selectAllState(selectableCount, selectedCount) {
10
+ if (selectedCount === 0 || selectableCount === 0)
11
+ return false;
12
+ return selectedCount === selectableCount ? true : "indeterminate";
13
+ }
14
+ export function toggled(selected, id, on) {
15
+ const next = new Set(selected);
16
+ if (on)
17
+ next.add(id);
18
+ else
19
+ next.delete(id);
20
+ return next;
21
+ }
@@ -0,0 +1,11 @@
1
+ import type { PendingApproval } from "../types.js";
2
+ export type InboxProps = {
3
+ items: PendingApproval[];
4
+ now?: number;
5
+ title?: string;
6
+ onApprove: (id: string) => void;
7
+ onDeny: (id: string) => void;
8
+ onApproveAll: (ids: string[]) => void;
9
+ className?: string;
10
+ };
11
+ export declare function Inbox({ items, now, title, onApprove, onDeny, onApproveAll, className, }: InboxProps): import("react").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { MailAll as InboxIcon } from "@carbon/icons-react";
3
+ import { Button, Checkbox, Label } from "@locusgraph/components";
4
+ import { pluralize } from "@locusgraph/utils";
5
+ import { useId, useState } from "react";
6
+ import { ApprovalPanel, LiveStatus, PanelFooter, PanelHeader, PanelTitle, } from "../../shared/panel.js";
7
+ import { PanelEmpty } from "../../shared/panel-empty.js";
8
+ import { InboxRow } from "./inbox-row.js";
9
+ import { bulkApprovable, selectAllState, selectedIn, toggled } from "./inbox-selection.js";
10
+ export function Inbox({ items, now = Date.now(), title = "Waiting for approval", onApprove, onDeny, onApproveAll, className, }) {
11
+ const selectAllId = useId();
12
+ const [selected, setSelected] = useState(() => new Set());
13
+ const selectable = bulkApprovable(items);
14
+ const selectedIds = selectedIn(items, selected);
15
+ const allState = selectAllState(selectable.length, selectedIds.length);
16
+ const hasDestructive = selectable.length < items.length;
17
+ const empty = items.length === 0;
18
+ return (_jsxs(ApprovalPanel, { "data-slot": "inbox", "aria-label": title, className: className, children: [_jsx(PanelHeader, { icon: _jsx(InboxIcon, { "aria-hidden": true }), eyebrow: "Approvals", status: empty ? "All clear" : `${items.length} waiting`, tone: empty ? "done" : "waiting" }), _jsx(PanelTitle, { children: title }), empty ? (_jsx(PanelEmpty, { "data-slot": "inbox-empty", icon: _jsx(InboxIcon, { "aria-hidden": true }), title: "Nothing waiting for you", description: "When an agent needs approval to write, pay, send or delete, it shows up here." })) : (_jsxs(_Fragment, { children: [_jsx("ul", { className: "mt-4 flex flex-col divide-y border-t", children: items.map((item) => (_jsx(InboxRow, { item: item, now: now, selected: selected.has(item.id), onSelect: (on) => setSelected((current) => toggled(current, item.id, on)), onApprove: () => onApprove(item.id), onDeny: () => onDeny(item.id) }, item.id))) }), _jsxs(PanelFooter, { className: "justify-between gap-3", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-3", children: [selectable.length > 0 && (_jsx(Checkbox, { id: selectAllId, checked: allState, onCheckedChange: (checked) => setSelected(checked === true ? new Set(selectable.map((item) => item.id)) : new Set()) })), _jsxs(Label, { htmlFor: selectAllId, className: "flex min-w-0 flex-col items-start gap-0 font-normal", children: [_jsxs("span", { className: "text-sm tabular-nums", children: [_jsx("span", { className: "sr-only", children: "Select all that can be approved together. " }), selectedIds.length > 0 ? `${selectedIds.length} selected` : "Select all"] }), hasDestructive && (_jsx("span", { className: "text-xs text-muted-foreground", children: "Destructive requests are approved one at a time." }))] })] }), _jsx(Button, { type: "button", size: "sm", disabled: selectedIds.length === 0, onClick: () => {
19
+ onApproveAll(selectedIds);
20
+ setSelected(new Set());
21
+ }, children: selectedIds.length > 0
22
+ ? `Approve ${selectedIds.length} selected`
23
+ : "Approve selected" })] })] })), _jsx(LiveStatus, { message: empty
24
+ ? "No approvals waiting"
25
+ : `${pluralize(items.length, "approval")} waiting, ${selectedIds.length} selected` })] }));
26
+ }
@@ -0,0 +1,9 @@
1
+ export * from "./inbox/inbox.js";
2
+ export * from "./memory/memory-review.js";
3
+ export * from "./plan/plan-review.js";
4
+ export * from "./plan/question.js";
5
+ export * from "./run/run-bar.js";
6
+ export * from "./spend/spend-gate.js";
7
+ export * from "./tool/approval.js";
8
+ export * from "./tool/args/args-editor.js";
9
+ export type * from "./types.js";
@@ -0,0 +1,8 @@
1
+ export * from "./inbox/inbox.js";
2
+ export * from "./memory/memory-review.js";
3
+ export * from "./plan/plan-review.js";
4
+ export * from "./plan/question.js";
5
+ export * from "./run/run-bar.js";
6
+ export * from "./spend/spend-gate.js";
7
+ export * from "./tool/approval.js";
8
+ export * from "./tool/args/args-editor.js";
@@ -0,0 +1,10 @@
1
+ import type { MemoryReviewResult, ProposedMemory } from "../types.js";
2
+ export type MemoryChoice = "keep" | "edit" | "discard";
3
+ export type MemoryDraft = {
4
+ choice: MemoryChoice;
5
+ text: string;
6
+ };
7
+ export declare function initialDrafts(memories: ProposedMemory[]): Record<string, MemoryDraft>;
8
+ export declare function reviewResult(memories: ProposedMemory[], drafts: Record<string, MemoryDraft>): MemoryReviewResult;
9
+ export declare function hasBlankEdit(drafts: Record<string, MemoryDraft>): boolean;
10
+ export declare function submitLabel(result: MemoryReviewResult): string;
@@ -0,0 +1,30 @@
1
+ export function initialDrafts(memories) {
2
+ return Object.fromEntries(memories.map((memory) => [
3
+ memory.id,
4
+ { choice: memory.sensitive ? "discard" : "keep", text: memory.text },
5
+ ]));
6
+ }
7
+ export function reviewResult(memories, drafts) {
8
+ const result = { kept: [], edited: [], discarded: [] };
9
+ for (const memory of memories) {
10
+ const draft = drafts[memory.id] ?? { choice: "keep", text: memory.text };
11
+ const text = draft.text.trim();
12
+ if (draft.choice === "discard")
13
+ result.discarded.push(memory);
14
+ else if (draft.choice === "edit" && text !== "" && text !== memory.text) {
15
+ result.edited.push({ ...memory, text });
16
+ }
17
+ else
18
+ result.kept.push(memory);
19
+ }
20
+ return result;
21
+ }
22
+ export function hasBlankEdit(drafts) {
23
+ return Object.values(drafts).some((draft) => draft.choice === "edit" && draft.text.trim() === "");
24
+ }
25
+ export function submitLabel(result) {
26
+ const saved = result.kept.length + result.edited.length;
27
+ if (saved === 0)
28
+ return "Discard all";
29
+ return `Save ${saved} ${saved === 1 ? "memory" : "memories"}`;
30
+ }
@@ -0,0 +1,11 @@
1
+ import type { ApprovalDecision, MemoryReviewResult, ProposedMemory } from "../types.js";
2
+ export type MemoryReviewProps = {
3
+ memories: ProposedMemory[];
4
+ title?: string;
5
+ description?: string;
6
+ decision?: ApprovalDecision;
7
+ onSubmit: (result: MemoryReviewResult) => void;
8
+ autoFocus?: boolean;
9
+ className?: string;
10
+ };
11
+ export declare function MemoryReview({ memories, title, description, decision, onSubmit, autoFocus, className, }: MemoryReviewProps): import("react").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Idea as BrainIcon } from "@carbon/icons-react";
3
+ import { Button } from "@locusgraph/components";
4
+ import { pluralize } from "@locusgraph/utils";
5
+ import { useMemo, useState } from "react";
6
+ import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle, } from "../../shared/panel.js";
7
+ import { PanelEmpty } from "../../shared/panel-empty.js";
8
+ import { DecisionSummary } from "../shared/decision-line.js";
9
+ import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
10
+ import { hasBlankEdit, initialDrafts, reviewResult, submitLabel } from "./memory-choices.js";
11
+ import { MemoryRow } from "./memory-row.js";
12
+ function resultSummary(result) {
13
+ return `${result.kept.length} kept, ${result.edited.length} edited, ${result.discarded.length} discarded`;
14
+ }
15
+ function headerStatus(decision, empty) {
16
+ if (decision)
17
+ return { status: "Reviewed", tone: "done" };
18
+ if (empty)
19
+ return { status: "Nothing new", tone: "idle" };
20
+ return { status: "Waiting for you", tone: "waiting" };
21
+ }
22
+ export function MemoryReview({ memories, title = "Review new memories", description = "The agent wants to remember these in LocusGraph. Keep, edit or discard each one.", decision, onSubmit, autoFocus = true, className, }) {
23
+ const [drafts, setDrafts] = useState(() => initialDrafts(memories));
24
+ const result = useMemo(() => reviewResult(memories, drafts), [memories, drafts]);
25
+ const blankEdit = hasBlankEdit(drafts);
26
+ const empty = memories.length === 0;
27
+ const sensitiveCount = memories.filter((memory) => memory.sensitive).length;
28
+ const submitRef = useFocusOnMount(autoFocus && !decision && !empty);
29
+ const { status, tone } = headerStatus(decision, empty);
30
+ return (_jsxs(ApprovalPanel, { "data-slot": "memory-review", "aria-label": title, className: className, children: [_jsx(PanelHeader, { icon: _jsx(BrainIcon, { "aria-hidden": true }), eyebrow: "Memory", status: status, tone: tone, aside: empty ? undefined : pluralize(memories.length, "proposed", "proposed") }), _jsx(PanelTitle, { className: decision ? "text-muted-foreground" : undefined, children: title }), empty ? (_jsx(PanelEmpty, { icon: _jsx(BrainIcon, { "aria-hidden": true }), title: "No new memories to review.", description: "When an agent wants to remember something in LocusGraph, it shows up here." })) : decision ? (_jsx(PanelBody, { children: _jsx(DecisionSummary, { decision: decision, approvedVerb: "Reviewed", deniedVerb: "Discarded", result: decision.approved ? "Memories reviewed" : "All memories discarded" }) })) : (_jsxs(_Fragment, { children: [_jsxs("p", { className: "px-5 pt-1 text-sm text-muted-foreground", children: [description, sensitiveCount > 0 && (_jsxs("span", { className: "text-warn", children: [" ", pluralize(sensitiveCount, "memory", "memories"), " flagged as sensitive, set to discard."] }))] }), _jsx(PanelBody, { className: "pb-0", children: _jsx("ul", { className: "-mx-5 flex flex-col divide-y border-t", children: memories.map((memory) => (_jsx(MemoryRow, { memory: memory, draft: drafts[memory.id] ?? { choice: "keep", text: memory.text }, onChange: (draft) => setDrafts((current) => ({ ...current, [memory.id]: draft })) }, memory.id))) }) }), _jsxs(PanelFooter, { className: "justify-between", children: [blankEdit ? (_jsx("span", { className: "text-xs text-destructive", children: "An edited memory can't be empty." })) : (_jsxs("span", { className: "hidden font-mono text-[11px] text-muted-foreground tabular-nums sm:inline", children: [result.kept.length, " kept \u00B7 ", result.edited.length, " edited \u00B7", " ", result.discarded.length, " discarded"] })), _jsx(Button, { ref: submitRef, type: "button", size: "sm", className: "ml-auto", variant: result.kept.length + result.edited.length === 0 ? "destructive" : "default", disabled: blankEdit, onClick: () => onSubmit(result), children: submitLabel(result) })] })] })), _jsx(LiveStatus, { message: decision ? "Memories reviewed" : resultSummary(result) })] }));
31
+ }
@@ -0,0 +1,9 @@
1
+ import type { ProposedMemory } from "../types.js";
2
+ import type { MemoryDraft } from "./memory-choices.js";
3
+ type MemoryRowProps = {
4
+ memory: ProposedMemory;
5
+ draft: MemoryDraft;
6
+ onChange: (draft: MemoryDraft) => void;
7
+ };
8
+ export declare function MemoryRow({ memory, draft, onChange }: MemoryRowProps): import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ShieldAlert as ShieldAlertIcon } from "@carbon/icons-react";
3
+ import { cn, Textarea } from "@locusgraph/components";
4
+ const choiceLabels = {
5
+ keep: "Keep",
6
+ edit: "Edit",
7
+ discard: "Discard",
8
+ };
9
+ const choices = ["keep", "edit", "discard"];
10
+ const selectedChoiceClass = {
11
+ keep: "text-foreground shadow-[inset_0_-2px_0_var(--color-primary)]",
12
+ edit: "text-foreground shadow-[inset_0_-2px_0_var(--color-primary)]",
13
+ discard: "text-destructive shadow-[inset_0_-2px_0_var(--color-destructive)]",
14
+ };
15
+ function ChoiceSegments({ value, onChange, }) {
16
+ return (_jsxs("fieldset", { className: "flex shrink-0 gap-1 self-start", children: [_jsx("legend", { className: "sr-only", children: "What to do with this memory" }), choices.map((choice) => {
17
+ const pressed = value === choice;
18
+ return (_jsx("button", { type: "button", "aria-pressed": pressed, onClick: () => onChange(choice), className: cn("h-7 px-2 text-xs outline-none motion-safe:transition-colors focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-ring/70", pressed
19
+ ? cn("font-medium", selectedChoiceClass[choice])
20
+ : "text-muted-foreground hover:text-foreground"), children: choiceLabels[choice] }, choice));
21
+ })] }));
22
+ }
23
+ function SensitiveMarker() {
24
+ return (_jsxs("span", { className: "flex items-center gap-1 text-warn", children: [_jsx(ShieldAlertIcon, { "aria-hidden": true, className: "size-3" }), "Sensitive"] }));
25
+ }
26
+ export function MemoryRow({ memory, draft, onChange }) {
27
+ const discarded = draft.choice === "discard";
28
+ const editing = draft.choice === "edit";
29
+ return (_jsxs("li", { "data-slot": "memory-review-item", "data-choice": draft.choice, "data-sensitive": memory.sensitive || undefined, className: cn("flex flex-col gap-2 px-5 py-2.5 motion-safe:transition-colors", editing ? "bg-accent/30" : "hover:bg-accent/30"), children: [_jsxs("div", { className: "flex items-start gap-3", children: [_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [(memory.kind || memory.sensitive) && (_jsxs("span", { className: "eyebrow flex items-center gap-2", children: [memory.kind && _jsx("span", { children: memory.kind }), memory.sensitive && _jsx(SensitiveMarker, {})] })), !editing && (_jsx("p", { className: cn("text-sm", discarded && "text-muted-foreground line-through decoration-muted-foreground/60"), children: memory.text }))] }), _jsx(ChoiceSegments, { value: draft.choice, onChange: (choice) => onChange({ ...draft, choice }) })] }), editing && (_jsx(Textarea, { "aria-label": "Memory text", value: draft.text, "aria-invalid": draft.text.trim() === "" || undefined, onChange: (event) => onChange({ ...draft, text: event.target.value }), className: "min-h-16 text-sm" })), memory.sensitive && !discarded && (_jsx("p", { className: "text-xs text-warn", children: "This looks like personal or secret data. Keep it only if the agent should remember it." }))] }));
30
+ }
@@ -0,0 +1,13 @@
1
+ import type { ApprovalDecision, PlanStepDraft } from "../types.js";
2
+ export type PlanReviewProps = {
3
+ steps: PlanStepDraft[];
4
+ title?: string;
5
+ description?: string;
6
+ actionLabel?: string;
7
+ decision?: ApprovalDecision;
8
+ onApprove: (steps: PlanStepDraft[]) => void;
9
+ onCancel: () => void;
10
+ autoFocus?: boolean;
11
+ className?: string;
12
+ };
13
+ export declare function PlanReview({ steps: initialSteps, title, description, actionLabel, decision, onApprove, onCancel, autoFocus, className, }: PlanReviewProps): import("react").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ArrowRight as ArrowRightIcon, ListChecked as ListChecksIcon } from "@carbon/icons-react";
3
+ import { Button } from "@locusgraph/components";
4
+ import { pluralize } from "@locusgraph/utils";
5
+ import { useEffect, useId, useState } from "react";
6
+ import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle, } from "../../shared/panel.js";
7
+ import { DecisionSummary } from "../shared/decision-line.js";
8
+ import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
9
+ import { PlanStepRow, stepControlId } from "./plan-step-row.js";
10
+ import { applyStepAction, describeStepAction, focusAfterAction } from "./plan-steps.js";
11
+ function DecidedSteps({ steps }) {
12
+ return (_jsx("ol", { className: "flex flex-col gap-1 pl-6.5 text-sm text-muted-foreground", children: steps.map((step, position) => (_jsxs("li", { className: "flex gap-3", children: [_jsx("span", { className: "w-4 shrink-0 font-mono text-xs leading-5 tabular-nums", children: position + 1 }), _jsx("span", { className: "min-w-0", children: step.title })] }, step.id))) }));
13
+ }
14
+ export function PlanReview({ steps: initialSteps, title = "Review the plan", description = "The agent will run these steps in order. Edit, reorder or remove steps before it starts.", actionLabel, decision, onApprove, onCancel, autoFocus = true, className, }) {
15
+ const idPrefix = useId();
16
+ const [steps, setSteps] = useState(initialSteps);
17
+ const [announcement, setAnnouncement] = useState("");
18
+ const [pendingFocus, setPendingFocus] = useState(null);
19
+ const approveRef = useFocusOnMount(autoFocus && !decision);
20
+ const hasBlankTitle = steps.some((step) => step.title.trim() === "");
21
+ useEffect(() => {
22
+ if (pendingFocus)
23
+ document.getElementById(pendingFocus.id)?.focus();
24
+ }, [pendingFocus]);
25
+ function handleAction(stepId, position, action) {
26
+ const next = applyStepAction(steps, stepId, action);
27
+ const focus = focusAfterAction(next, stepId, action);
28
+ setSteps(next);
29
+ setAnnouncement(describeStepAction(position, action));
30
+ setPendingFocus(focus ? { id: stepControlId(idPrefix, focus.stepId, focus.control) } : null);
31
+ }
32
+ function renameStep(stepId, nextTitle) {
33
+ setSteps((current) => current.map((item) => (item.id === stepId ? { ...item, title: nextTitle } : item)));
34
+ }
35
+ return (_jsxs(ApprovalPanel, { "data-slot": "plan-review", "data-decided": decision ? true : undefined, "aria-label": title, className: className, children: [_jsx(PanelHeader, { icon: _jsx(ListChecksIcon, { "aria-hidden": true }), eyebrow: "Plan", status: decision ? (decision.approved ? "Approved" : "Cancelled") : "Waiting for you", tone: decision ? (decision.approved ? "done" : "danger") : "waiting", aside: pluralize(steps.length, "step") }), _jsx(PanelTitle, { className: decision ? "text-muted-foreground" : undefined, children: title }), decision ? (_jsxs(PanelBody, { children: [_jsx(DecisionSummary, { decision: decision, deniedVerb: "Cancelled", result: decision.approved
36
+ ? `${pluralize(initialSteps.length, "step")} approved`
37
+ : "Plan cancelled" }), _jsx(DecidedSteps, { steps: initialSteps })] })) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "px-5 pt-1 text-sm text-muted-foreground", children: description }), _jsx(PanelBody, { className: "pb-0", children: _jsx("ol", { className: "-mx-5 flex flex-col divide-y border-t", children: steps.map((step, position) => (_jsx(PlanStepRow, { idPrefix: idPrefix, step: step, position: position, count: steps.length, onRename: (nextTitle) => renameStep(step.id, nextTitle), onAction: (action) => handleAction(step.id, position, action) }, step.id))) }) }), _jsxs(PanelFooter, { className: "justify-between", children: [hasBlankTitle ? (_jsx("span", { className: "text-xs text-destructive", children: "Every step needs a title." })) : (_jsx("span", { className: "hidden font-mono text-[11px] text-muted-foreground sm:inline", children: "The run starts when you approve" })), _jsxs("span", { className: "ml-auto flex gap-2", children: [_jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: onCancel, children: "Cancel" }), _jsxs(Button, { ref: approveRef, type: "button", size: "sm", disabled: hasBlankTitle || steps.length === 0, onClick: () => onApprove(steps.map((step) => ({ ...step, title: step.title.trim() }))), children: [actionLabel ?? `Run ${pluralize(steps.length, "step")}`, _jsx(ArrowRightIcon, { "aria-hidden": true })] })] })] })] })), _jsx(LiveStatus, { message: decision ? (decision.approved ? "Plan approved" : "Plan cancelled") : announcement })] }));
38
+ }
@@ -0,0 +1,13 @@
1
+ import type { PlanStepDraft } from "../types.js";
2
+ export type StepAction = "up" | "down" | "remove";
3
+ type PlanStepRowProps = {
4
+ idPrefix: string;
5
+ step: PlanStepDraft;
6
+ position: number;
7
+ count: number;
8
+ onRename: (title: string) => void;
9
+ onAction: (action: StepAction) => void;
10
+ };
11
+ export declare function stepControlId(idPrefix: string, stepId: string, action: StepAction | "title"): string;
12
+ export declare function PlanStepRow({ idPrefix, step, position, count, onRename, onAction, }: PlanStepRowProps): import("react").JSX.Element;
13
+ export {};
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ArrowDown as ArrowDownIcon, ArrowUp as ArrowUpIcon, Edit as PencilIcon, TrashCan as Trash2Icon, } from "@carbon/icons-react";
3
+ import { Button, cn } from "@locusgraph/components";
4
+ export function stepControlId(idPrefix, stepId, action) {
5
+ return `${idPrefix}-${stepId}-${action}`;
6
+ }
7
+ function selectInputById(id) {
8
+ const element = document.getElementById(id);
9
+ if (element instanceof HTMLInputElement) {
10
+ element.focus();
11
+ element.select();
12
+ }
13
+ }
14
+ export function PlanStepRow({ idPrefix, step, position, count, onRename, onAction, }) {
15
+ const number = position + 1;
16
+ const titleId = stepControlId(idPrefix, step.id, "title");
17
+ const blank = step.title.trim() === "";
18
+ const controls = [
19
+ {
20
+ id: `${idPrefix}-${step.id}-edit`,
21
+ label: `Edit step ${number}`,
22
+ icon: PencilIcon,
23
+ disabled: false,
24
+ onClick: () => selectInputById(titleId),
25
+ },
26
+ {
27
+ id: stepControlId(idPrefix, step.id, "up"),
28
+ label: `Move step ${number} up`,
29
+ icon: ArrowUpIcon,
30
+ disabled: position === 0,
31
+ onClick: () => onAction("up"),
32
+ },
33
+ {
34
+ id: stepControlId(idPrefix, step.id, "down"),
35
+ label: `Move step ${number} down`,
36
+ icon: ArrowDownIcon,
37
+ disabled: position === count - 1,
38
+ onClick: () => onAction("down"),
39
+ },
40
+ {
41
+ id: stepControlId(idPrefix, step.id, "remove"),
42
+ label: `Remove step ${number}`,
43
+ icon: Trash2Icon,
44
+ disabled: count === 1,
45
+ onClick: () => onAction("remove"),
46
+ danger: true,
47
+ },
48
+ ];
49
+ return (_jsxs("li", { "data-slot": "plan-step", className: "group flex items-start gap-3 px-5 py-2.5 focus-within:bg-accent/50 hover:bg-accent/50 motion-safe:transition-colors", children: [_jsx("span", { "aria-hidden": true, className: "mt-0.5 flex size-5 shrink-0 items-center justify-center font-mono text-[11px] text-muted-foreground tabular-nums ring-1 ring-input", children: number }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [_jsx("input", { id: titleId, "aria-label": `Step ${number} title`, value: step.title, placeholder: "Name this step", "aria-invalid": blank || undefined, onChange: (event) => onRename(event.target.value), className: cn("-mx-1.5 h-6 min-w-0 bg-transparent px-1.5 text-sm font-medium outline-none placeholder:font-normal placeholder:text-muted-foreground focus-visible:bg-background focus-visible:ring-1 focus-visible:ring-ring", blank && "ring-1 ring-destructive/70") }), step.detail && _jsx("p", { className: "text-xs text-muted-foreground", children: step.detail })] }), _jsx("div", { className: "flex shrink-0 gap-0.5 sm:opacity-0 sm:group-focus-within:opacity-100 sm:group-hover:opacity-100 sm:motion-safe:transition-opacity", children: controls.map(({ id, label, icon: Icon, disabled, onClick, danger }) => (_jsx(Button, { id: id, type: "button", variant: "ghost", size: "icon-xs", "aria-label": label, title: label, disabled: disabled, onClick: onClick, className: cn("text-muted-foreground hover:text-foreground", danger && "hover:text-destructive"), children: _jsx(Icon, { "aria-hidden": true }) }, id))) })] }));
50
+ }
@@ -0,0 +1,8 @@
1
+ import type { PlanStepDraft } from "../types.js";
2
+ import type { StepAction } from "./plan-step-row.js";
3
+ export declare function applyStepAction(steps: PlanStepDraft[], stepId: string, action: StepAction): PlanStepDraft[];
4
+ export declare function focusAfterAction(steps: PlanStepDraft[], stepId: string, action: StepAction): {
5
+ stepId: string;
6
+ control: StepAction | "title";
7
+ } | null;
8
+ export declare function describeStepAction(position: number, action: StepAction): string;
@@ -0,0 +1,29 @@
1
+ export function applyStepAction(steps, stepId, action) {
2
+ const index = steps.findIndex((step) => step.id === stepId);
3
+ if (index === -1)
4
+ return steps;
5
+ if (action === "remove")
6
+ return steps.filter((step) => step.id !== stepId);
7
+ const target = action === "up" ? index - 1 : index + 1;
8
+ if (target < 0 || target >= steps.length)
9
+ return steps;
10
+ const reordered = [...steps];
11
+ const [moved] = reordered.splice(index, 1);
12
+ if (moved)
13
+ reordered.splice(target, 0, moved);
14
+ return reordered;
15
+ }
16
+ export function focusAfterAction(steps, stepId, action) {
17
+ if (action !== "remove") {
18
+ const index = steps.findIndex((step) => step.id === stepId);
19
+ const atEdge = action === "up" ? index === 0 : index === steps.length - 1;
20
+ return { stepId, control: atEdge ? "title" : action };
21
+ }
22
+ const neighbor = steps[0];
23
+ return neighbor ? { stepId: neighbor.id, control: "title" } : null;
24
+ }
25
+ export function describeStepAction(position, action) {
26
+ if (action === "remove")
27
+ return `Step ${position + 1} removed.`;
28
+ return `Step moved ${action}.`;
29
+ }
@@ -0,0 +1,10 @@
1
+ import type { QuestionOption } from "../types.js";
2
+ type QuestionChoicesProps = {
3
+ label: string;
4
+ options: QuestionOption[];
5
+ selectedId?: string;
6
+ onSelect: (optionId: string) => void;
7
+ autoFocus?: boolean;
8
+ };
9
+ export declare function QuestionChoices({ label, options, selectedId, onSelect, autoFocus, }: QuestionChoicesProps): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ import { useEffect, useRef } from "react";
4
+ const nextIndexByKey = {
5
+ ArrowRight: (index, count) => (index + 1) % count,
6
+ ArrowDown: (index, count) => (index + 1) % count,
7
+ ArrowLeft: (index, count) => (index - 1 + count) % count,
8
+ ArrowUp: (index, count) => (index - 1 + count) % count,
9
+ Home: () => 0,
10
+ End: (_index, count) => count - 1,
11
+ };
12
+ function indexFromDigitKey(key, count) {
13
+ const digit = Number(key);
14
+ return Number.isInteger(digit) && digit >= 1 && digit <= count ? digit - 1 : undefined;
15
+ }
16
+ export function QuestionChoices({ label, options, selectedId, onSelect, autoFocus = false, }) {
17
+ const buttons = useRef([]);
18
+ useEffect(() => {
19
+ if (autoFocus)
20
+ buttons.current[0]?.focus({ preventScroll: true });
21
+ }, [autoFocus]);
22
+ const selectedIndex = options.findIndex((option) => option.id === selectedId);
23
+ const tabStop = selectedIndex === -1 ? 0 : selectedIndex;
24
+ function selectIndex(next) {
25
+ const option = options[next];
26
+ if (!option)
27
+ return;
28
+ onSelect(option.id);
29
+ buttons.current[next]?.focus();
30
+ }
31
+ function handleKeyDown(event, index) {
32
+ const byDigit = indexFromDigitKey(event.key, options.length);
33
+ const move = nextIndexByKey[event.key];
34
+ if (byDigit === undefined && !move)
35
+ return;
36
+ event.preventDefault();
37
+ selectIndex(byDigit ?? move?.(index, options.length) ?? index);
38
+ }
39
+ return (_jsx("div", { role: "radiogroup", "aria-label": label, "data-slot": "question-choices", className: "-mx-5 flex flex-col divide-y border-y", children: options.map((option, index) => {
40
+ const checked = option.id === selectedId;
41
+ return (_jsxs("button", { ref: (element) => {
42
+ buttons.current[index] = element;
43
+ }, type: "button", role: "radio", "aria-checked": checked, tabIndex: index === tabStop ? 0 : -1, "data-state": checked ? "checked" : "unchecked", onClick: () => onSelect(option.id), onKeyDown: (event) => handleKeyDown(event, index), className: cn("group relative flex items-center gap-3 px-5 py-2.5 text-left text-sm outline-none motion-safe:transition-colors focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-inset", checked ? "bg-accent" : "hover:bg-accent/50"), children: [_jsx("span", { "aria-hidden": true, className: cn("flex size-5 shrink-0 items-center justify-center font-mono text-[11px] ring-1", checked
44
+ ? "bg-primary text-primary-foreground ring-primary"
45
+ : "text-muted-foreground ring-input"), children: index + 1 }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "font-medium", children: option.label }), option.description && (_jsx("span", { className: "text-xs text-muted-foreground", children: option.description }))] })] }, option.id));
46
+ }) }));
47
+ }
@@ -0,0 +1,18 @@
1
+ import type { DecidedAt, QuestionAnswer, QuestionOption } from "../types.js";
2
+ export type AnsweredQuestion = QuestionAnswer & {
3
+ by?: string;
4
+ at?: DecidedAt;
5
+ };
6
+ export type QuestionProps = {
7
+ question: string;
8
+ options?: QuestionOption[];
9
+ allowText?: boolean;
10
+ textLabel?: string;
11
+ textPlaceholder?: string;
12
+ submitLabel?: string;
13
+ answer?: AnsweredQuestion;
14
+ onAnswer: (answer: QuestionAnswer) => void;
15
+ autoFocus?: boolean;
16
+ className?: string;
17
+ };
18
+ export declare function Question({ question, options, allowText, textLabel, textPlaceholder, submitLabel, answer, onAnswer, autoFocus, className, }: QuestionProps): import("react").JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ArrowRight as ArrowRightIcon, Help as MessageCircleQuestionIcon, } from "@carbon/icons-react";
3
+ import { Button, Input, Textarea } from "@locusgraph/components";
4
+ import { useId, useState } from "react";
5
+ import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle, } from "../../shared/panel.js";
6
+ import { DecisionSummary } from "../shared/decision-line.js";
7
+ import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
8
+ import { QuestionChoices } from "./question-choices.js";
9
+ function answerText(answer, options) {
10
+ const option = options.find((item) => item.id === answer.optionId);
11
+ return [option?.label, answer.text].filter(Boolean).join(" · ");
12
+ }
13
+ export function Question({ question, options = [], allowText = options.length === 0, textLabel = options.length > 0 ? "Something else" : "Your answer", textPlaceholder = options.length > 0 ? "Something else…" : "Type an answer for the agent", submitLabel = "Send answer", answer, onAnswer, autoFocus = true, className, }) {
14
+ const textId = useId();
15
+ const [optionId, setOptionId] = useState();
16
+ const [text, setText] = useState("");
17
+ const trimmed = text.trim();
18
+ const canSubmit = optionId !== undefined || trimmed !== "";
19
+ const textOnly = options.length === 0;
20
+ const textRef = useFocusOnMount(autoFocus && !answer && textOnly);
21
+ const changeText = (value) => {
22
+ setText(value);
23
+ if (value.trim() !== "")
24
+ setOptionId(undefined);
25
+ };
26
+ return (_jsxs(ApprovalPanel, { "data-slot": "question", "data-answered": answer ? true : undefined, className: className, children: [_jsx(PanelHeader, { icon: _jsx(MessageCircleQuestionIcon, { "aria-hidden": true }), eyebrow: "Agent question", status: answer ? "Answered" : "Waiting for you", tone: answer ? "done" : "waiting" }), _jsx(PanelTitle, { className: answer ? "text-muted-foreground" : undefined, children: question }), answer ? (_jsx(PanelBody, { children: _jsx(DecisionSummary, { decision: { approved: true, by: answer.by, at: answer.at }, approvedVerb: "Answered", result: answerText(answer, options) || "No answer" }) })) : (_jsxs("form", { onSubmit: (event) => {
27
+ event.preventDefault();
28
+ if (!canSubmit)
29
+ return;
30
+ onAnswer({ optionId, text: trimmed === "" ? undefined : trimmed });
31
+ }, children: [_jsxs(PanelBody, { className: "gap-3", children: [!textOnly && (_jsx(QuestionChoices, { label: question, options: options, selectedId: optionId, onSelect: (id) => {
32
+ setOptionId(id);
33
+ setText("");
34
+ }, autoFocus: autoFocus })), allowText && !textOnly && (_jsx(Input, { id: textId, "aria-label": textLabel, value: text, placeholder: textPlaceholder, onChange: (event) => changeText(event.target.value) })), textOnly && (_jsx(Textarea, { id: textId, ref: textRef, "aria-label": textLabel, value: text, placeholder: textPlaceholder, onChange: (event) => changeText(event.target.value) }))] }), _jsxs(PanelFooter, { className: "justify-between", children: [_jsx("span", { className: "hidden font-mono text-[11px] text-muted-foreground sm:inline", children: textOnly ? "The run is paused" : `Press 1–${options.length} to pick` }), _jsxs(Button, { type: "submit", size: "sm", disabled: !canSubmit, children: [submitLabel, _jsx(ArrowRightIcon, { "aria-hidden": true })] })] })] })), _jsx(LiveStatus, { message: answer ? `Answered: ${answerText(answer, options)}` : `The agent asks: ${question}` })] }));
35
+ }
@@ -0,0 +1,13 @@
1
+ import type { RunBarStatus } from "../types.js";
2
+ export type RunBarProps = {
3
+ status: RunBarStatus;
4
+ runName?: string;
5
+ elapsedMs?: number;
6
+ onPause: () => void;
7
+ onResume: () => void;
8
+ onStop: () => void;
9
+ onStep?: () => void;
10
+ pending?: boolean;
11
+ className?: string;
12
+ };
13
+ export declare function RunBar({ status, runName, elapsedMs, onPause, onResume, onStop, onStep, pending, className, }: RunBarProps): import("react").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pause as PauseIcon, Play as PlayIcon, SkipForward as SkipForwardIcon, StopFilledAlt as SquareIcon, } from "@carbon/icons-react";
3
+ import { Button, cn } from "@locusgraph/components";
4
+ import { StatusDot } from "../../shared/status-dot.js";
5
+ const statusLabels = {
6
+ running: "Running",
7
+ paused: "Paused",
8
+ stopped: "Stopped",
9
+ done: "Done",
10
+ };
11
+ const statusTone = {
12
+ running: "running",
13
+ paused: "waiting",
14
+ stopped: "danger",
15
+ done: "done",
16
+ };
17
+ function twoDigits(value) {
18
+ return String(value).padStart(2, "0");
19
+ }
20
+ function formatElapsed(elapsedMs) {
21
+ const totalSeconds = Math.max(0, Math.floor(elapsedMs / 1000));
22
+ const hours = Math.floor(totalSeconds / 3600);
23
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
24
+ const seconds = totalSeconds % 60;
25
+ if (hours > 0)
26
+ return `${hours}:${twoDigits(minutes)}:${twoDigits(seconds)}`;
27
+ return `${minutes}:${twoDigits(seconds)}`;
28
+ }
29
+ export function RunBar({ status, runName, elapsedMs, onPause, onResume, onStop, onStep, pending = false, className, }) {
30
+ const live = status === "running" || status === "paused";
31
+ const paused = status === "paused";
32
+ return (_jsxs("div", { role: "toolbar", "aria-label": runName ? `Controls for ${runName}` : "Run controls", "data-slot": "run-bar", "data-status": status, className: cn("flex min-h-10 min-w-0 flex-wrap items-center gap-x-3 gap-y-2 bg-card py-2 pr-2 pl-3 text-card-foreground ring-1 ring-border", className), children: [_jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2.5 text-sm", children: [_jsx(StatusDot, { tone: statusTone[status], className: "size-2" }), runName && _jsx("span", { className: "truncate font-medium", children: runName }), _jsx("span", { role: "status", "aria-live": "polite", className: "eyebrow shrink-0", children: statusLabels[status] }), elapsedMs !== undefined && (_jsxs("span", { className: "shrink-0 font-mono text-xs text-muted-foreground tabular-nums", children: [_jsx("span", { className: "sr-only", children: "Elapsed " }), formatElapsed(elapsedMs)] }))] }), live && (_jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-1", children: [_jsxs(Button, { type: "button", size: "xs", variant: paused ? "default" : "outline", disabled: pending, onClick: paused ? onResume : onPause, children: [paused ? _jsx(PlayIcon, { "aria-hidden": true }) : _jsx(PauseIcon, { "aria-hidden": true }), paused ? "Resume" : "Pause"] }), onStep && (_jsxs(Button, { type: "button", size: "xs", variant: "ghost", "aria-label": "Run one step", title: "Run one step", disabled: !paused || pending, onClick: onStep, children: [_jsx(SkipForwardIcon, { "aria-hidden": true }), "Step"] })), _jsxs(Button, { type: "button", size: "xs", variant: "ghost", className: "text-muted-foreground hover:bg-destructive/10 hover:text-destructive dark:hover:bg-destructive/15", disabled: pending, onClick: onStop, children: [_jsx(SquareIcon, { "aria-hidden": true, className: "size-2.5 fill-current" }), "Stop"] })] }))] }));
33
+ }
@@ -0,0 +1 @@
1
+ export { DecisionSummary, type DecisionSummaryProps, } from "../../shared/decision-summary.js";
@@ -0,0 +1 @@
1
+ export { DecisionSummary, } from "../../shared/decision-summary.js";
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from "react";
2
+ import type { PanelTone } from "../../shared/panel.js";
3
+ import type { RiskLevel } from "../../types.js";
4
+ export declare const riskLabels: Record<RiskLevel, string>;
5
+ export declare const riskRing: Record<RiskLevel, string>;
6
+ export declare const riskTone: Record<RiskLevel, PanelTone>;
7
+ export declare const riskCopy: Record<RiskLevel, (tool: string) => ReactNode>;
8
+ export declare function RiskBadge({ risk }: {
9
+ risk: RiskLevel;
10
+ }): import("react").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Badge } from "@locusgraph/components";
3
+ export const riskLabels = {
4
+ read: "Read only",
5
+ write: "Writes data",
6
+ destructive: "Destructive",
7
+ };
8
+ export const riskRing = {
9
+ read: "ring-border",
10
+ write: "ring-border",
11
+ destructive: "ring-destructive/60",
12
+ };
13
+ export const riskTone = {
14
+ read: "idle",
15
+ write: "waiting",
16
+ destructive: "danger",
17
+ };
18
+ export const riskCopy = {
19
+ read: (tool) => `${tool} only reads data. Nothing changes if you approve.`,
20
+ write: (tool) => `${tool} wants to make a change. Check the inputs before you approve.`,
21
+ destructive: (tool) => (_jsxs(_Fragment, { children: [tool, " will permanently delete or overwrite data.", " ", _jsx("span", { className: "font-medium text-destructive", children: "This can't be undone." })] })),
22
+ };
23
+ const riskVariant = { read: "outline", write: "secondary", destructive: "destructive" };
24
+ export function RiskBadge({ risk }) {
25
+ return (_jsx(Badge, { "data-slot": "risk-badge", "data-risk": risk, variant: riskVariant[risk], children: riskLabels[risk] }));
26
+ }
@@ -0,0 +1,3 @@
1
+ import type { DecidedAt } from "../types.js";
2
+ export { formatDecidedAt, isoOf, toDate } from "../../shared/decision-summary.js";
3
+ export declare function formatWaiting(since: DecidedAt, now: number): string;
@@ -0,0 +1,15 @@
1
+ import { toDate } from "../../shared/decision-summary.js";
2
+ export { formatDecidedAt, isoOf, toDate } from "../../shared/decision-summary.js";
3
+ const minuteMs = 60_000;
4
+ const hourMs = 60 * minuteMs;
5
+ const dayMs = 24 * hourMs;
6
+ export function formatWaiting(since, now) {
7
+ const waitedMs = Math.max(0, now - toDate(since).getTime());
8
+ if (waitedMs < minuteMs)
9
+ return "just now";
10
+ if (waitedMs < hourMs)
11
+ return `${Math.floor(waitedMs / minuteMs)} min`;
12
+ if (waitedMs < dayMs)
13
+ return `${Math.floor(waitedMs / hourMs)} h`;
14
+ return `${Math.floor(waitedMs / dayMs)} d`;
15
+ }