@locusgraph/loop 0.1.0 → 0.2.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 (115) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/pulse/gradient-label.js +86 -15
  3. package/dist/agent/pulse/marks/bars-mark.js +46 -10
  4. package/dist/agent/pulse/marks/glyph-mark.js +56 -11
  5. package/dist/agent/pulse/marks/locus-mark.js +63 -28
  6. package/dist/agent/pulse/marks/orb-mark.js +31 -8
  7. package/dist/agent/pulse/marks/spinner-mark.js +29 -1
  8. package/dist/agent/pulse/pulse.js +150 -35
  9. package/dist/agent/pulse/use-loop-animation.js +36 -17
  10. package/dist/agent/steps/step-icon.js +110 -24
  11. package/dist/agent/steps/steps.js +235 -25
  12. package/dist/agent/thinking/thinking.js +203 -23
  13. package/dist/agent/thinking/thought-duration.js +7 -9
  14. package/dist/agent/tool/json-block.js +38 -11
  15. package/dist/agent/tool/tool-status.js +51 -18
  16. package/dist/agent/tool/tool.js +184 -6
  17. package/dist/approval/inbox/inbox-row.d.ts +3 -2
  18. package/dist/approval/inbox/inbox-row.js +321 -7
  19. package/dist/approval/inbox/inbox-selection.js +7 -13
  20. package/dist/approval/inbox/inbox.d.ts +2 -1
  21. package/dist/approval/inbox/inbox.js +250 -18
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  23. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  24. package/dist/approval/memory/memory-choices.js +27 -22
  25. package/dist/approval/memory/memory-review.js +242 -17
  26. package/dist/approval/memory/memory-row.js +215 -19
  27. package/dist/approval/plan/plan-review.js +279 -28
  28. package/dist/approval/plan/plan-step-row.js +194 -43
  29. package/dist/approval/plan/plan-steps.js +24 -23
  30. package/dist/approval/plan/question-choices.js +158 -39
  31. package/dist/approval/plan/question.d.ts +1 -1
  32. package/dist/approval/plan/question.js +223 -26
  33. package/dist/approval/run/run-bar.js +178 -22
  34. package/dist/approval/shared/decision-line.js +1 -1
  35. package/dist/approval/shared/risk-badge.js +47 -16
  36. package/dist/approval/shared/time.js +5 -8
  37. package/dist/approval/shared/use-focus-on-mount.js +23 -6
  38. package/dist/approval/spend/raise-cap-form.js +235 -17
  39. package/dist/approval/spend/spend-gate.js +239 -21
  40. package/dist/approval/spend/spend-math.js +7 -8
  41. package/dist/approval/spend/spend-meter.js +362 -34
  42. package/dist/approval/tool/approval.js +272 -27
  43. package/dist/approval/tool/args/args-editor.js +262 -26
  44. package/dist/approval/tool/args/args-field.js +259 -19
  45. package/dist/approval/tool/args/args-validation.js +38 -47
  46. package/dist/approval/tool/deny-form.js +130 -10
  47. package/dist/approval/tool/tool-inputs.js +127 -38
  48. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  49. package/dist/chat/chat/chat-item-spacing.js +19 -0
  50. package/dist/chat/chat/chat.d.ts +2 -1
  51. package/dist/chat/chat/chat.js +181 -5
  52. package/dist/chat/chat/use-stick-to-bottom.js +123 -47
  53. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  54. package/dist/chat/chat/virtual-chat-items.js +153 -0
  55. package/dist/chat/composer/composer-actions.js +151 -16
  56. package/dist/chat/composer/composer.js +330 -32
  57. package/dist/chat/composer/use-auto-grow.js +24 -9
  58. package/dist/chat/files/file-meta.js +19 -19
  59. package/dist/chat/files/files.js +316 -28
  60. package/dist/chat/reply/fenced-code.js +45 -21
  61. package/dist/chat/reply/markdown-components.js +137 -17
  62. package/dist/chat/reply/reply.js +105 -10
  63. package/dist/chat/turn/group-parts.js +43 -29
  64. package/dist/chat/turn/turn.js +238 -30
  65. package/dist/cost/context.js +321 -23
  66. package/dist/cost/cost-steps.js +220 -14
  67. package/dist/cost/cost.js +521 -27
  68. package/dist/cost/model-picker.js +181 -6
  69. package/dist/cost/shared/context-breakdown.js +299 -10
  70. package/dist/cost/shared/meter-marks.js +107 -9
  71. package/dist/cost/shared/model-option-row.js +178 -21
  72. package/dist/cost/shared/step-cost-row.js +248 -20
  73. package/dist/cost/shared/usage-totals.js +22 -18
  74. package/dist/memory/cite.js +182 -11
  75. package/dist/memory/memorized.js +217 -11
  76. package/dist/memory/recall.js +296 -17
  77. package/dist/memory/shared/host-label.js +19 -22
  78. package/dist/memory/shared/source-mark.js +39 -3
  79. package/dist/memory/sources.js +255 -13
  80. package/dist/shared/decision-summary.js +133 -14
  81. package/dist/shared/panel-empty.js +78 -3
  82. package/dist/shared/panel.js +243 -13
  83. package/dist/shared/status-dot.js +38 -8
  84. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  85. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  86. package/dist/thread/actions/action-button.js +65 -3
  87. package/dist/thread/actions/actions.js +184 -13
  88. package/dist/thread/actions/branch-switcher.js +102 -5
  89. package/dist/thread/canvas/canvas.js +205 -5
  90. package/dist/thread/canvas/version-switcher.js +149 -8
  91. package/dist/thread/code/code.js +186 -24
  92. package/dist/thread/code/copy-code-button.js +61 -13
  93. package/dist/thread/code/highlight.js +30 -29
  94. package/dist/thread/history/history-rows.d.ts +16 -0
  95. package/dist/thread/history/history-rows.js +23 -0
  96. package/dist/thread/history/history.d.ts +3 -2
  97. package/dist/thread/history/history.js +174 -5
  98. package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
  99. package/dist/thread/history/row/history-row.js +137 -0
  100. package/dist/thread/history/row/thread-item-menu.js +84 -0
  101. package/dist/thread/history/row/thread-title-editor.js +81 -0
  102. package/dist/thread/history/thread-groups.d.ts +1 -1
  103. package/dist/thread/history/thread-groups.js +40 -34
  104. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  105. package/dist/thread/history/virtual-history-list.js +107 -0
  106. package/dist/thread/index.d.ts +1 -1
  107. package/dist/thread/starters/starters.js +92 -7
  108. package/dist/thread/use-copied.js +45 -15
  109. package/dist/types.js +1 -1
  110. package/package.json +6 -4
  111. package/dist/thread/history/history-row.js +0 -17
  112. package/dist/thread/history/thread-item-menu.js +0 -6
  113. package/dist/thread/history/thread-title-editor.js +0 -25
  114. /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
  115. /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
@@ -1,30 +1,226 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { ShieldAlert as ShieldAlertIcon } from "@carbon/icons-react";
3
3
  import { cn, Textarea } from "@locusgraph/components";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
5
  const choiceLabels = {
5
- keep: "Keep",
6
- edit: "Edit",
7
- discard: "Discard",
6
+ keep: "Keep",
7
+ edit: "Edit",
8
+ discard: "Discard"
8
9
  };
9
10
  const choices = ["keep", "edit", "discard"];
10
11
  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)]",
12
+ keep: "text-foreground shadow-[inset_0_-2px_0_var(--color-primary)]",
13
+ edit: "text-foreground shadow-[inset_0_-2px_0_var(--color-primary)]",
14
+ discard: "text-destructive shadow-[inset_0_-2px_0_var(--color-destructive)]"
14
15
  };
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
- })] }));
16
+ function ChoiceSegments(t0) {
17
+ const $ = _c(6);
18
+ const {
19
+ value,
20
+ onChange
21
+ } = t0;
22
+ let t1;
23
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
24
+ t1 = /*#__PURE__*/_jsx("legend", {
25
+ className: "sr-only",
26
+ children: "What to do with this memory"
27
+ });
28
+ $[0] = t1;
29
+ } else {
30
+ t1 = $[0];
31
+ }
32
+ let t2;
33
+ if ($[1] !== onChange || $[2] !== value) {
34
+ t2 = choices.map(choice => {
35
+ const pressed = value === choice;
36
+ return /*#__PURE__*/_jsx("button", {
37
+ type: "button",
38
+ "aria-pressed": pressed,
39
+ onClick: () => onChange(choice),
40
+ 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 ? cn("font-medium", selectedChoiceClass[choice]) : "text-muted-foreground hover:text-foreground"),
41
+ children: choiceLabels[choice]
42
+ }, choice);
43
+ });
44
+ $[1] = onChange;
45
+ $[2] = value;
46
+ $[3] = t2;
47
+ } else {
48
+ t2 = $[3];
49
+ }
50
+ let t3;
51
+ if ($[4] !== t2) {
52
+ t3 = /*#__PURE__*/_jsxs("fieldset", {
53
+ className: "flex shrink-0 gap-1 self-start",
54
+ children: [t1, t2]
55
+ });
56
+ $[4] = t2;
57
+ $[5] = t3;
58
+ } else {
59
+ t3 = $[5];
60
+ }
61
+ return t3;
22
62
  }
23
63
  function SensitiveMarker() {
24
- return (_jsxs("span", { className: "flex items-center gap-1 text-warn", children: [_jsx(ShieldAlertIcon, { "aria-hidden": true, className: "size-3" }), "Sensitive"] }));
64
+ const $ = _c(1);
65
+ let t0;
66
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
67
+ t0 = /*#__PURE__*/_jsxs("span", {
68
+ className: "flex items-center gap-1 text-warn",
69
+ children: [/*#__PURE__*/_jsx(ShieldAlertIcon, {
70
+ "aria-hidden": true,
71
+ className: "size-3"
72
+ }), "Sensitive"]
73
+ });
74
+ $[0] = t0;
75
+ } else {
76
+ t0 = $[0];
77
+ }
78
+ return t0;
25
79
  }
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." }))] }));
80
+ export function MemoryRow(t0) {
81
+ const $ = _c(35);
82
+ const {
83
+ memory,
84
+ draft,
85
+ onChange
86
+ } = t0;
87
+ const discarded = draft.choice === "discard";
88
+ const editing = draft.choice === "edit";
89
+ const t1 = draft.choice;
90
+ const t2 = memory.sensitive || undefined;
91
+ const t3 = editing ? "bg-accent/30" : "hover:bg-accent/30";
92
+ let t4;
93
+ if ($[0] !== t3) {
94
+ t4 = cn("flex flex-col gap-2 px-5 py-2.5 motion-safe:transition-colors", t3);
95
+ $[0] = t3;
96
+ $[1] = t4;
97
+ } else {
98
+ t4 = $[1];
99
+ }
100
+ let t5;
101
+ if ($[2] !== memory.kind || $[3] !== memory.sensitive) {
102
+ t5 = (memory.kind || memory.sensitive) && /*#__PURE__*/_jsxs("span", {
103
+ className: "eyebrow flex items-center gap-2",
104
+ children: [memory.kind && /*#__PURE__*/_jsx("span", {
105
+ children: memory.kind
106
+ }), memory.sensitive && /*#__PURE__*/_jsx(SensitiveMarker, {})]
107
+ });
108
+ $[2] = memory.kind;
109
+ $[3] = memory.sensitive;
110
+ $[4] = t5;
111
+ } else {
112
+ t5 = $[4];
113
+ }
114
+ let t6;
115
+ if ($[5] !== discarded || $[6] !== editing || $[7] !== memory.text) {
116
+ t6 = !editing && /*#__PURE__*/_jsx("p", {
117
+ className: cn("text-sm", discarded && "text-muted-foreground line-through decoration-muted-foreground/60"),
118
+ children: memory.text
119
+ });
120
+ $[5] = discarded;
121
+ $[6] = editing;
122
+ $[7] = memory.text;
123
+ $[8] = t6;
124
+ } else {
125
+ t6 = $[8];
126
+ }
127
+ let t7;
128
+ if ($[9] !== t5 || $[10] !== t6) {
129
+ t7 = /*#__PURE__*/_jsxs("div", {
130
+ className: "flex min-w-0 flex-1 flex-col gap-1",
131
+ children: [t5, t6]
132
+ });
133
+ $[9] = t5;
134
+ $[10] = t6;
135
+ $[11] = t7;
136
+ } else {
137
+ t7 = $[11];
138
+ }
139
+ let t8;
140
+ if ($[12] !== draft || $[13] !== onChange) {
141
+ t8 = choice => onChange({
142
+ ...draft,
143
+ choice
144
+ });
145
+ $[12] = draft;
146
+ $[13] = onChange;
147
+ $[14] = t8;
148
+ } else {
149
+ t8 = $[14];
150
+ }
151
+ let t9;
152
+ if ($[15] !== draft.choice || $[16] !== t8) {
153
+ t9 = /*#__PURE__*/_jsx(ChoiceSegments, {
154
+ value: draft.choice,
155
+ onChange: t8
156
+ });
157
+ $[15] = draft.choice;
158
+ $[16] = t8;
159
+ $[17] = t9;
160
+ } else {
161
+ t9 = $[17];
162
+ }
163
+ let t10;
164
+ if ($[18] !== t7 || $[19] !== t9) {
165
+ t10 = /*#__PURE__*/_jsxs("div", {
166
+ className: "flex items-start gap-3",
167
+ children: [t7, t9]
168
+ });
169
+ $[18] = t7;
170
+ $[19] = t9;
171
+ $[20] = t10;
172
+ } else {
173
+ t10 = $[20];
174
+ }
175
+ let t11;
176
+ if ($[21] !== draft || $[22] !== editing || $[23] !== onChange) {
177
+ t11 = editing && /*#__PURE__*/_jsx(Textarea, {
178
+ "aria-label": "Memory text",
179
+ value: draft.text,
180
+ "aria-invalid": draft.text.trim() === "" || undefined,
181
+ onChange: event => onChange({
182
+ ...draft,
183
+ text: event.target.value
184
+ }),
185
+ className: "min-h-16 text-sm"
186
+ });
187
+ $[21] = draft;
188
+ $[22] = editing;
189
+ $[23] = onChange;
190
+ $[24] = t11;
191
+ } else {
192
+ t11 = $[24];
193
+ }
194
+ let t12;
195
+ if ($[25] !== discarded || $[26] !== memory.sensitive) {
196
+ t12 = memory.sensitive && !discarded && /*#__PURE__*/_jsx("p", {
197
+ className: "text-xs text-warn",
198
+ children: "This looks like personal or secret data. Keep it only if the agent should remember it."
199
+ });
200
+ $[25] = discarded;
201
+ $[26] = memory.sensitive;
202
+ $[27] = t12;
203
+ } else {
204
+ t12 = $[27];
205
+ }
206
+ let t13;
207
+ if ($[28] !== draft.choice || $[29] !== t10 || $[30] !== t11 || $[31] !== t12 || $[32] !== t2 || $[33] !== t4) {
208
+ t13 = /*#__PURE__*/_jsxs("li", {
209
+ "data-slot": "memory-review-item",
210
+ "data-choice": t1,
211
+ "data-sensitive": t2,
212
+ className: t4,
213
+ children: [t10, t11, t12]
214
+ });
215
+ $[28] = draft.choice;
216
+ $[29] = t10;
217
+ $[30] = t11;
218
+ $[31] = t12;
219
+ $[32] = t2;
220
+ $[33] = t4;
221
+ $[34] = t13;
222
+ } else {
223
+ t13 = $[34];
224
+ }
225
+ return t13;
30
226
  }
@@ -1,38 +1,289 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { ArrowRight as ArrowRightIcon, ListChecked as ListChecksIcon } from "@carbon/icons-react";
3
3
  import { Button } from "@locusgraph/components";
4
4
  import { pluralize } from "@locusgraph/utils";
5
5
  import { useEffect, useId, useState } from "react";
6
- import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle, } from "../../shared/panel.js";
6
+ import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle } from "../../shared/panel.js";
7
7
  import { DecisionSummary } from "../shared/decision-line.js";
8
8
  import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
9
9
  import { PlanStepRow, stepControlId } from "./plan-step-row.js";
10
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))) }));
11
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
12
+ function DecidedSteps(t0) {
13
+ const $ = _c(4);
14
+ const {
15
+ steps
16
+ } = t0;
17
+ let t1;
18
+ if ($[0] !== steps) {
19
+ t1 = steps.map(_temp);
20
+ $[0] = steps;
21
+ $[1] = t1;
22
+ } else {
23
+ t1 = $[1];
24
+ }
25
+ let t2;
26
+ if ($[2] !== t1) {
27
+ t2 = /*#__PURE__*/_jsx("ol", {
28
+ className: "flex flex-col gap-1 pl-6.5 text-sm text-muted-foreground",
29
+ children: t1
30
+ });
31
+ $[2] = t1;
32
+ $[3] = t2;
33
+ } else {
34
+ t2 = $[3];
35
+ }
36
+ return t2;
13
37
  }
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
+ function _temp(step, position) {
39
+ return /*#__PURE__*/_jsxs("li", {
40
+ className: "flex gap-3",
41
+ children: [/*#__PURE__*/_jsx("span", {
42
+ className: "w-4 shrink-0 font-mono text-xs leading-5 tabular-nums",
43
+ children: position + 1
44
+ }), /*#__PURE__*/_jsx("span", {
45
+ className: "min-w-0",
46
+ children: step.title
47
+ })]
48
+ }, step.id);
49
+ }
50
+ export function PlanReview(t0) {
51
+ const $ = _c(41);
52
+ const {
53
+ steps: initialSteps,
54
+ title: t1,
55
+ description: t2,
56
+ actionLabel,
57
+ decision,
58
+ onApprove,
59
+ onCancel,
60
+ autoFocus: t3,
61
+ className
62
+ } = t0;
63
+ const title = t1 === undefined ? "Review the plan" : t1;
64
+ const description = t2 === undefined ? "The agent will run these steps in order. Edit, reorder or remove steps before it starts." : t2;
65
+ const autoFocus = t3 === undefined ? true : t3;
66
+ const idPrefix = useId();
67
+ const [steps, setSteps] = useState(initialSteps);
68
+ const [announcement, setAnnouncement] = useState("");
69
+ const [pendingFocus, setPendingFocus] = useState(null);
70
+ const approveRef = useFocusOnMount(autoFocus && !decision);
71
+ let t4;
72
+ if ($[0] !== steps) {
73
+ t4 = steps.some(_temp2);
74
+ $[0] = steps;
75
+ $[1] = t4;
76
+ } else {
77
+ t4 = $[1];
78
+ }
79
+ const hasBlankTitle = t4;
80
+ let t5;
81
+ let t6;
82
+ if ($[2] !== pendingFocus) {
83
+ t5 = () => {
84
+ if (pendingFocus) {
85
+ document.getElementById(pendingFocus.id)?.focus();
86
+ }
87
+ };
88
+ t6 = [pendingFocus];
89
+ $[2] = pendingFocus;
90
+ $[3] = t5;
91
+ $[4] = t6;
92
+ } else {
93
+ t5 = $[3];
94
+ t6 = $[4];
95
+ }
96
+ useEffect(t5, t6);
97
+ let t7;
98
+ if ($[5] !== idPrefix || $[6] !== steps) {
99
+ t7 = function handleAction(stepId, position, action) {
100
+ const next = applyStepAction(steps, stepId, action);
101
+ const focus = focusAfterAction(next, stepId, action);
102
+ setSteps(next);
103
+ setAnnouncement(describeStepAction(position, action));
104
+ setPendingFocus(focus ? {
105
+ id: stepControlId(idPrefix, focus.stepId, focus.control)
106
+ } : null);
107
+ };
108
+ $[5] = idPrefix;
109
+ $[6] = steps;
110
+ $[7] = t7;
111
+ } else {
112
+ t7 = $[7];
113
+ }
114
+ const handleAction = t7;
115
+ let t8;
116
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
117
+ t8 = function renameStep(stepId_0, nextTitle) {
118
+ setSteps(current => current.map(item => item.id === stepId_0 ? {
119
+ ...item,
120
+ title: nextTitle
121
+ } : item));
122
+ };
123
+ $[8] = t8;
124
+ } else {
125
+ t8 = $[8];
126
+ }
127
+ const renameStep = t8;
128
+ const t9 = decision ? true : undefined;
129
+ let t10;
130
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
131
+ t10 = /*#__PURE__*/_jsx(ListChecksIcon, {
132
+ "aria-hidden": true
133
+ });
134
+ $[9] = t10;
135
+ } else {
136
+ t10 = $[9];
137
+ }
138
+ const t11 = decision ? decision.approved ? "Approved" : "Cancelled" : "Waiting for you";
139
+ const t12 = decision ? decision.approved ? "done" : "danger" : "waiting";
140
+ let t13;
141
+ if ($[10] !== steps.length) {
142
+ t13 = pluralize(steps.length, "step");
143
+ $[10] = steps.length;
144
+ $[11] = t13;
145
+ } else {
146
+ t13 = $[11];
147
+ }
148
+ let t14;
149
+ if ($[12] !== t11 || $[13] !== t12 || $[14] !== t13) {
150
+ t14 = /*#__PURE__*/_jsx(PanelHeader, {
151
+ icon: t10,
152
+ eyebrow: "Plan",
153
+ status: t11,
154
+ tone: t12,
155
+ aside: t13
156
+ });
157
+ $[12] = t11;
158
+ $[13] = t12;
159
+ $[14] = t13;
160
+ $[15] = t14;
161
+ } else {
162
+ t14 = $[15];
163
+ }
164
+ const t15 = decision ? "text-muted-foreground" : undefined;
165
+ let t16;
166
+ if ($[16] !== t15 || $[17] !== title) {
167
+ t16 = /*#__PURE__*/_jsx(PanelTitle, {
168
+ className: t15,
169
+ children: title
170
+ });
171
+ $[16] = t15;
172
+ $[17] = title;
173
+ $[18] = t16;
174
+ } else {
175
+ t16 = $[18];
176
+ }
177
+ let t17;
178
+ if ($[19] !== actionLabel || $[20] !== approveRef || $[21] !== decision || $[22] !== description || $[23] !== handleAction || $[24] !== hasBlankTitle || $[25] !== idPrefix || $[26] !== initialSteps || $[27] !== onApprove || $[28] !== onCancel || $[29] !== steps) {
179
+ t17 = decision ? /*#__PURE__*/_jsxs(PanelBody, {
180
+ children: [/*#__PURE__*/_jsx(DecisionSummary, {
181
+ decision: decision,
182
+ deniedVerb: "Cancelled",
183
+ result: decision.approved ? `${pluralize(initialSteps.length, "step")} approved` : "Plan cancelled"
184
+ }), /*#__PURE__*/_jsx(DecidedSteps, {
185
+ steps: initialSteps
186
+ })]
187
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
188
+ children: [/*#__PURE__*/_jsx("p", {
189
+ className: "px-5 pt-1 text-sm text-muted-foreground",
190
+ children: description
191
+ }), /*#__PURE__*/_jsx(PanelBody, {
192
+ className: "pb-0",
193
+ children: /*#__PURE__*/_jsx("ol", {
194
+ className: "-mx-5 flex flex-col divide-y border-t",
195
+ children: steps.map((step_0, position_0) => /*#__PURE__*/_jsx(PlanStepRow, {
196
+ idPrefix: idPrefix,
197
+ step: step_0,
198
+ position: position_0,
199
+ count: steps.length,
200
+ onRename: nextTitle_0 => renameStep(step_0.id, nextTitle_0),
201
+ onAction: action_0 => handleAction(step_0.id, position_0, action_0)
202
+ }, step_0.id))
203
+ })
204
+ }), /*#__PURE__*/_jsxs(PanelFooter, {
205
+ className: "justify-between",
206
+ children: [hasBlankTitle ? /*#__PURE__*/_jsx("span", {
207
+ className: "text-xs text-destructive",
208
+ children: "Every step needs a title."
209
+ }) : /*#__PURE__*/_jsx("span", {
210
+ className: "hidden font-mono text-[11px] text-muted-foreground sm:inline",
211
+ children: "The run starts when you approve"
212
+ }), /*#__PURE__*/_jsxs("span", {
213
+ className: "ml-auto flex gap-2",
214
+ children: [/*#__PURE__*/_jsx(Button, {
215
+ type: "button",
216
+ size: "sm",
217
+ variant: "ghost",
218
+ onClick: onCancel,
219
+ children: "Cancel"
220
+ }), /*#__PURE__*/_jsxs(Button, {
221
+ ref: approveRef,
222
+ type: "button",
223
+ size: "sm",
224
+ disabled: hasBlankTitle || steps.length === 0,
225
+ onClick: () => onApprove(steps.map(_temp3)),
226
+ children: [actionLabel ?? `Run ${pluralize(steps.length, "step")}`, /*#__PURE__*/_jsx(ArrowRightIcon, {
227
+ "aria-hidden": true
228
+ })]
229
+ })]
230
+ })]
231
+ })]
232
+ });
233
+ $[19] = actionLabel;
234
+ $[20] = approveRef;
235
+ $[21] = decision;
236
+ $[22] = description;
237
+ $[23] = handleAction;
238
+ $[24] = hasBlankTitle;
239
+ $[25] = idPrefix;
240
+ $[26] = initialSteps;
241
+ $[27] = onApprove;
242
+ $[28] = onCancel;
243
+ $[29] = steps;
244
+ $[30] = t17;
245
+ } else {
246
+ t17 = $[30];
247
+ }
248
+ const t18 = decision ? decision.approved ? "Plan approved" : "Plan cancelled" : announcement;
249
+ let t19;
250
+ if ($[31] !== t18) {
251
+ t19 = /*#__PURE__*/_jsx(LiveStatus, {
252
+ message: t18
253
+ });
254
+ $[31] = t18;
255
+ $[32] = t19;
256
+ } else {
257
+ t19 = $[32];
258
+ }
259
+ let t20;
260
+ if ($[33] !== className || $[34] !== t14 || $[35] !== t16 || $[36] !== t17 || $[37] !== t19 || $[38] !== t9 || $[39] !== title) {
261
+ t20 = /*#__PURE__*/_jsxs(ApprovalPanel, {
262
+ "data-slot": "plan-review",
263
+ "data-decided": t9,
264
+ "aria-label": title,
265
+ className: className,
266
+ children: [t14, t16, t17, t19]
267
+ });
268
+ $[33] = className;
269
+ $[34] = t14;
270
+ $[35] = t16;
271
+ $[36] = t17;
272
+ $[37] = t19;
273
+ $[38] = t9;
274
+ $[39] = title;
275
+ $[40] = t20;
276
+ } else {
277
+ t20 = $[40];
278
+ }
279
+ return t20;
280
+ }
281
+ function _temp3(step_1) {
282
+ return {
283
+ ...step_1,
284
+ title: step_1.title.trim()
285
+ };
286
+ }
287
+ function _temp2(step) {
288
+ return step.title.trim() === "";
38
289
  }