@locusgraph/loop 0.0.0-stage → 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 (214) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -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 +94 -0
  7. package/dist/agent/pulse/marks/bars-mark.d.ts +1 -0
  8. package/dist/agent/pulse/marks/bars-mark.js +51 -0
  9. package/dist/agent/pulse/marks/glyph-mark.d.ts +4 -0
  10. package/dist/agent/pulse/marks/glyph-mark.js +62 -0
  11. package/dist/agent/pulse/marks/locus-mark.d.ts +1 -0
  12. package/dist/agent/pulse/marks/locus-mark.js +73 -0
  13. package/dist/agent/pulse/marks/orb-mark.d.ts +1 -0
  14. package/dist/agent/pulse/marks/orb-mark.js +34 -0
  15. package/dist/agent/pulse/marks/spinner-mark.d.ts +1 -0
  16. package/dist/agent/pulse/marks/spinner-mark.js +32 -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 +166 -0
  21. package/dist/agent/pulse/use-loop-animation.d.ts +2 -0
  22. package/dist/agent/pulse/use-loop-animation.js +40 -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 +117 -0
  27. package/dist/agent/steps/steps.d.ts +7 -0
  28. package/dist/agent/steps/steps.js +249 -0
  29. package/dist/agent/thinking/thinking.d.ts +6 -0
  30. package/dist/agent/thinking/thinking.js +211 -0
  31. package/dist/agent/thinking/thought-duration.d.ts +2 -0
  32. package/dist/agent/thinking/thought-duration.js +11 -0
  33. package/dist/agent/tool/json-block.d.ts +5 -0
  34. package/dist/agent/tool/json-block.js +42 -0
  35. package/dist/agent/tool/tool-status.d.ts +6 -0
  36. package/dist/agent/tool/tool-status.js +59 -0
  37. package/dist/agent/tool/tool.d.ts +7 -0
  38. package/dist/agent/tool/tool.js +192 -0
  39. package/dist/approval/inbox/inbox-row.d.ts +12 -0
  40. package/dist/approval/inbox/inbox-row.js +328 -0
  41. package/dist/approval/inbox/inbox-selection.d.ts +6 -0
  42. package/dist/approval/inbox/inbox-selection.js +15 -0
  43. package/dist/approval/inbox/inbox.d.ts +12 -0
  44. package/dist/approval/inbox/inbox.js +258 -0
  45. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  46. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  47. package/dist/approval/index.d.ts +9 -0
  48. package/dist/approval/index.js +8 -0
  49. package/dist/approval/memory/memory-choices.d.ts +10 -0
  50. package/dist/approval/memory/memory-choices.js +35 -0
  51. package/dist/approval/memory/memory-review.d.ts +11 -0
  52. package/dist/approval/memory/memory-review.js +256 -0
  53. package/dist/approval/memory/memory-row.d.ts +9 -0
  54. package/dist/approval/memory/memory-row.js +226 -0
  55. package/dist/approval/plan/plan-review.d.ts +13 -0
  56. package/dist/approval/plan/plan-review.js +289 -0
  57. package/dist/approval/plan/plan-step-row.d.ts +13 -0
  58. package/dist/approval/plan/plan-step-row.js +201 -0
  59. package/dist/approval/plan/plan-steps.d.ts +8 -0
  60. package/dist/approval/plan/plan-steps.js +30 -0
  61. package/dist/approval/plan/question-choices.d.ts +10 -0
  62. package/dist/approval/plan/question-choices.js +166 -0
  63. package/dist/approval/plan/question.d.ts +18 -0
  64. package/dist/approval/plan/question.js +232 -0
  65. package/dist/approval/run/run-bar.d.ts +13 -0
  66. package/dist/approval/run/run-bar.js +189 -0
  67. package/dist/approval/shared/decision-line.d.ts +1 -0
  68. package/dist/approval/shared/decision-line.js +1 -0
  69. package/dist/approval/shared/risk-badge.d.ts +10 -0
  70. package/dist/approval/shared/risk-badge.js +57 -0
  71. package/dist/approval/shared/time.d.ts +3 -0
  72. package/dist/approval/shared/time.js +12 -0
  73. package/dist/approval/shared/use-focus-on-mount.d.ts +2 -0
  74. package/dist/approval/shared/use-focus-on-mount.js +26 -0
  75. package/dist/approval/spend/raise-cap-form.d.ts +8 -0
  76. package/dist/approval/spend/raise-cap-form.js +244 -0
  77. package/dist/approval/spend/spend-gate.d.ts +16 -0
  78. package/dist/approval/spend/spend-gate.js +250 -0
  79. package/dist/approval/spend/spend-math.d.ts +5 -0
  80. package/dist/approval/spend/spend-math.js +17 -0
  81. package/dist/approval/spend/spend-meter.d.ts +10 -0
  82. package/dist/approval/spend/spend-meter.js +377 -0
  83. package/dist/approval/tool/approval.d.ts +14 -0
  84. package/dist/approval/tool/approval.js +290 -0
  85. package/dist/approval/tool/args/args-editor.d.ts +16 -0
  86. package/dist/approval/tool/args/args-editor.js +273 -0
  87. package/dist/approval/tool/args/args-field.d.ts +11 -0
  88. package/dist/approval/tool/args/args-field.js +268 -0
  89. package/dist/approval/tool/args/args-validation.d.ts +8 -0
  90. package/dist/approval/tool/args/args-validation.js +50 -0
  91. package/dist/approval/tool/deny-form.d.ts +6 -0
  92. package/dist/approval/tool/deny-form.js +135 -0
  93. package/dist/approval/tool/tool-inputs.d.ts +6 -0
  94. package/dist/approval/tool/tool-inputs.js +142 -0
  95. package/dist/approval/types.d.ts +59 -0
  96. package/dist/approval/types.js +1 -0
  97. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  98. package/dist/chat/chat/chat-item-spacing.js +19 -0
  99. package/dist/chat/chat/chat.d.ts +8 -0
  100. package/dist/chat/chat/chat.js +187 -0
  101. package/dist/chat/chat/use-stick-to-bottom.d.ts +7 -0
  102. package/dist/chat/chat/use-stick-to-bottom.js +133 -0
  103. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  104. package/dist/chat/chat/virtual-chat-items.js +153 -0
  105. package/dist/chat/composer/composer-actions.d.ts +15 -0
  106. package/dist/chat/composer/composer-actions.js +158 -0
  107. package/dist/chat/composer/composer.d.ts +20 -0
  108. package/dist/chat/composer/composer.js +340 -0
  109. package/dist/chat/composer/use-auto-grow.d.ts +2 -0
  110. package/dist/chat/composer/use-auto-grow.js +29 -0
  111. package/dist/chat/files/file-meta.d.ts +13 -0
  112. package/dist/chat/files/file-meta.js +30 -0
  113. package/dist/chat/files/files.d.ts +9 -0
  114. package/dist/chat/files/files.js +327 -0
  115. package/dist/chat/index.d.ts +7 -0
  116. package/dist/chat/index.js +7 -0
  117. package/dist/chat/reply/fenced-code.d.ts +8 -0
  118. package/dist/chat/reply/fenced-code.js +53 -0
  119. package/dist/chat/reply/markdown-components.d.ts +2 -0
  120. package/dist/chat/reply/markdown-components.js +142 -0
  121. package/dist/chat/reply/reply.d.ts +8 -0
  122. package/dist/chat/reply/reply.js +116 -0
  123. package/dist/chat/turn/group-parts.d.ts +24 -0
  124. package/dist/chat/turn/group-parts.js +49 -0
  125. package/dist/chat/turn/turn.d.ts +11 -0
  126. package/dist/chat/turn/turn.js +253 -0
  127. package/dist/cost/context.d.ts +13 -0
  128. package/dist/cost/context.js +333 -0
  129. package/dist/cost/cost-steps.d.ts +17 -0
  130. package/dist/cost/cost-steps.js +230 -0
  131. package/dist/cost/cost.d.ts +8 -0
  132. package/dist/cost/cost.js +531 -0
  133. package/dist/cost/index.d.ts +4 -0
  134. package/dist/cost/index.js +4 -0
  135. package/dist/cost/model-picker.d.ts +11 -0
  136. package/dist/cost/model-picker.js +184 -0
  137. package/dist/cost/shared/context-breakdown.d.ts +15 -0
  138. package/dist/cost/shared/context-breakdown.js +306 -0
  139. package/dist/cost/shared/meter-marks.d.ts +9 -0
  140. package/dist/cost/shared/meter-marks.js +114 -0
  141. package/dist/cost/shared/model-option-row.d.ts +14 -0
  142. package/dist/cost/shared/model-option-row.js +189 -0
  143. package/dist/cost/shared/step-cost-row.d.ts +15 -0
  144. package/dist/cost/shared/step-cost-row.js +262 -0
  145. package/dist/cost/shared/usage-totals.d.ts +11 -0
  146. package/dist/cost/shared/usage-totals.js +30 -0
  147. package/dist/index.d.ts +7 -0
  148. package/dist/index.js +7 -0
  149. package/dist/memory/cite.d.ts +8 -0
  150. package/dist/memory/cite.js +190 -0
  151. package/dist/memory/index.d.ts +5 -0
  152. package/dist/memory/index.js +4 -0
  153. package/dist/memory/memorized.d.ts +14 -0
  154. package/dist/memory/memorized.js +225 -0
  155. package/dist/memory/recall.d.ts +9 -0
  156. package/dist/memory/recall.js +303 -0
  157. package/dist/memory/shared/disclosure.d.ts +6 -0
  158. package/dist/memory/shared/disclosure.js +6 -0
  159. package/dist/memory/shared/host-label.d.ts +6 -0
  160. package/dist/memory/shared/host-label.js +31 -0
  161. package/dist/memory/shared/source-mark.d.ts +5 -0
  162. package/dist/memory/shared/source-mark.js +42 -0
  163. package/dist/memory/sources.d.ts +9 -0
  164. package/dist/memory/sources.js +264 -0
  165. package/dist/shared/decision-summary.d.ts +18 -0
  166. package/dist/shared/decision-summary.js +144 -0
  167. package/dist/shared/panel-empty.d.ts +8 -0
  168. package/dist/shared/panel-empty.js +80 -0
  169. package/dist/shared/panel.d.ts +19 -0
  170. package/dist/shared/panel.js +251 -0
  171. package/dist/shared/status-dot.d.ts +6 -0
  172. package/dist/shared/status-dot.js +42 -0
  173. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  174. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  175. package/dist/sources.css +1 -0
  176. package/dist/thread/actions/action-button.d.ts +8 -0
  177. package/dist/thread/actions/action-button.js +67 -0
  178. package/dist/thread/actions/actions.d.ts +13 -0
  179. package/dist/thread/actions/actions.js +192 -0
  180. package/dist/thread/actions/branch-switcher.d.ts +10 -0
  181. package/dist/thread/actions/branch-switcher.js +104 -0
  182. package/dist/thread/canvas/canvas.d.ts +14 -0
  183. package/dist/thread/canvas/canvas.js +212 -0
  184. package/dist/thread/canvas/version-switcher.d.ts +12 -0
  185. package/dist/thread/canvas/version-switcher.js +152 -0
  186. package/dist/thread/code/code.d.ts +10 -0
  187. package/dist/thread/code/code.js +195 -0
  188. package/dist/thread/code/copy-code-button.d.ts +6 -0
  189. package/dist/thread/code/copy-code-button.js +66 -0
  190. package/dist/thread/code/highlight.d.ts +1 -0
  191. package/dist/thread/code/highlight.js +40 -0
  192. package/dist/thread/history/history-rows.d.ts +16 -0
  193. package/dist/thread/history/history-rows.js +23 -0
  194. package/dist/thread/history/history.d.ts +16 -0
  195. package/dist/thread/history/history.js +179 -0
  196. package/dist/thread/history/row/history-row.d.ts +15 -0
  197. package/dist/thread/history/row/history-row.js +137 -0
  198. package/dist/thread/history/row/thread-item-menu.d.ts +7 -0
  199. package/dist/thread/history/row/thread-item-menu.js +84 -0
  200. package/dist/thread/history/row/thread-title-editor.d.ts +7 -0
  201. package/dist/thread/history/row/thread-title-editor.js +81 -0
  202. package/dist/thread/history/thread-groups.d.ts +8 -0
  203. package/dist/thread/history/thread-groups.js +52 -0
  204. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  205. package/dist/thread/history/virtual-history-list.js +107 -0
  206. package/dist/thread/index.d.ts +8 -0
  207. package/dist/thread/index.js +5 -0
  208. package/dist/thread/starters/starters.d.ts +12 -0
  209. package/dist/thread/starters/starters.js +100 -0
  210. package/dist/thread/use-copied.d.ts +5 -0
  211. package/dist/thread/use-copied.js +52 -0
  212. package/dist/types.d.ts +70 -0
  213. package/dist/types.js +3 -0
  214. package/package.json +59 -3
@@ -0,0 +1,289 @@
1
+ import { c as _c } from "react/compiler-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
+ 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;
37
+ }
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() === "";
289
+ }
@@ -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,201 @@
1
+ import { c as _c } from "react/compiler-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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ export function stepControlId(idPrefix, stepId, action) {
6
+ return `${idPrefix}-${stepId}-${action}`;
7
+ }
8
+ function selectInputById(id) {
9
+ const element = document.getElementById(id);
10
+ if (element instanceof HTMLInputElement) {
11
+ element.focus();
12
+ element.select();
13
+ }
14
+ }
15
+ export function PlanStepRow(t0) {
16
+ const $ = _c(34);
17
+ const {
18
+ idPrefix,
19
+ step,
20
+ position,
21
+ count,
22
+ onRename,
23
+ onAction
24
+ } = t0;
25
+ const number = position + 1;
26
+ let t1;
27
+ let t2;
28
+ let t3;
29
+ let t4;
30
+ let t5;
31
+ let t6;
32
+ if ($[0] !== count || $[1] !== idPrefix || $[2] !== number || $[3] !== onAction || $[4] !== onRename || $[5] !== position || $[6] !== step.detail || $[7] !== step.id || $[8] !== step.title) {
33
+ const titleId = stepControlId(idPrefix, step.id, "title");
34
+ let t7;
35
+ if ($[15] !== step.title) {
36
+ t7 = step.title.trim();
37
+ $[15] = step.title;
38
+ $[16] = t7;
39
+ } else {
40
+ t7 = $[16];
41
+ }
42
+ const blank = t7 === "";
43
+ const controls = [{
44
+ id: `${idPrefix}-${step.id}-edit`,
45
+ label: `Edit step ${number}`,
46
+ icon: PencilIcon,
47
+ disabled: false,
48
+ onClick: () => selectInputById(titleId)
49
+ }, {
50
+ id: stepControlId(idPrefix, step.id, "up"),
51
+ label: `Move step ${number} up`,
52
+ icon: ArrowUpIcon,
53
+ disabled: position === 0,
54
+ onClick: () => onAction("up")
55
+ }, {
56
+ id: stepControlId(idPrefix, step.id, "down"),
57
+ label: `Move step ${number} down`,
58
+ icon: ArrowDownIcon,
59
+ disabled: position === count - 1,
60
+ onClick: () => onAction("down")
61
+ }, {
62
+ id: stepControlId(idPrefix, step.id, "remove"),
63
+ label: `Remove step ${number}`,
64
+ icon: Trash2Icon,
65
+ disabled: count === 1,
66
+ onClick: () => onAction("remove"),
67
+ danger: true
68
+ }];
69
+ t3 = "plan-step";
70
+ t4 = "group flex items-start gap-3 px-5 py-2.5 focus-within:bg-accent/50 hover:bg-accent/50 motion-safe:transition-colors";
71
+ if ($[17] !== number) {
72
+ t5 = /*#__PURE__*/_jsx("span", {
73
+ "aria-hidden": true,
74
+ 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",
75
+ children: number
76
+ });
77
+ $[17] = number;
78
+ $[18] = t5;
79
+ } else {
80
+ t5 = $[18];
81
+ }
82
+ const t8 = step.title;
83
+ let t9;
84
+ if ($[19] !== onRename) {
85
+ t9 = event => onRename(event.target.value);
86
+ $[19] = onRename;
87
+ $[20] = t9;
88
+ } else {
89
+ t9 = $[20];
90
+ }
91
+ const t10 = blank && "ring-1 ring-destructive/70";
92
+ let t11;
93
+ if ($[21] !== t10) {
94
+ t11 = 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", t10);
95
+ $[21] = t10;
96
+ $[22] = t11;
97
+ } else {
98
+ t11 = $[22];
99
+ }
100
+ let t12;
101
+ if ($[23] !== step.detail) {
102
+ t12 = step.detail && /*#__PURE__*/_jsx("p", {
103
+ className: "text-xs text-muted-foreground",
104
+ children: step.detail
105
+ });
106
+ $[23] = step.detail;
107
+ $[24] = t12;
108
+ } else {
109
+ t12 = $[24];
110
+ }
111
+ t6 = /*#__PURE__*/_jsxs("div", {
112
+ className: "flex min-w-0 flex-1 flex-col gap-0.5",
113
+ children: [/*#__PURE__*/_jsx("input", {
114
+ id: titleId,
115
+ "aria-label": `Step ${number} title`,
116
+ value: t8,
117
+ placeholder: "Name this step",
118
+ "aria-invalid": blank || undefined,
119
+ onChange: t9,
120
+ className: t11
121
+ }), t12]
122
+ });
123
+ t1 = "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";
124
+ t2 = controls.map(_temp);
125
+ $[0] = count;
126
+ $[1] = idPrefix;
127
+ $[2] = number;
128
+ $[3] = onAction;
129
+ $[4] = onRename;
130
+ $[5] = position;
131
+ $[6] = step.detail;
132
+ $[7] = step.id;
133
+ $[8] = step.title;
134
+ $[9] = t1;
135
+ $[10] = t2;
136
+ $[11] = t3;
137
+ $[12] = t4;
138
+ $[13] = t5;
139
+ $[14] = t6;
140
+ } else {
141
+ t1 = $[9];
142
+ t2 = $[10];
143
+ t3 = $[11];
144
+ t4 = $[12];
145
+ t5 = $[13];
146
+ t6 = $[14];
147
+ }
148
+ let t7;
149
+ if ($[25] !== t1 || $[26] !== t2) {
150
+ t7 = /*#__PURE__*/_jsx("div", {
151
+ className: t1,
152
+ children: t2
153
+ });
154
+ $[25] = t1;
155
+ $[26] = t2;
156
+ $[27] = t7;
157
+ } else {
158
+ t7 = $[27];
159
+ }
160
+ let t8;
161
+ if ($[28] !== t3 || $[29] !== t4 || $[30] !== t5 || $[31] !== t6 || $[32] !== t7) {
162
+ t8 = /*#__PURE__*/_jsxs("li", {
163
+ "data-slot": t3,
164
+ className: t4,
165
+ children: [t5, t6, t7]
166
+ });
167
+ $[28] = t3;
168
+ $[29] = t4;
169
+ $[30] = t5;
170
+ $[31] = t6;
171
+ $[32] = t7;
172
+ $[33] = t8;
173
+ } else {
174
+ t8 = $[33];
175
+ }
176
+ return t8;
177
+ }
178
+ function _temp(t0) {
179
+ const {
180
+ id,
181
+ label,
182
+ icon: Icon,
183
+ disabled,
184
+ onClick,
185
+ danger
186
+ } = t0;
187
+ return /*#__PURE__*/_jsx(Button, {
188
+ id: id,
189
+ type: "button",
190
+ variant: "ghost",
191
+ size: "icon-xs",
192
+ "aria-label": label,
193
+ title: label,
194
+ disabled: disabled,
195
+ onClick: onClick,
196
+ className: cn("text-muted-foreground hover:text-foreground", danger && "hover:text-destructive"),
197
+ children: /*#__PURE__*/_jsx(Icon, {
198
+ "aria-hidden": true
199
+ })
200
+ }, id);
201
+ }
@@ -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,30 @@
1
+ export function applyStepAction(steps, stepId, action) {
2
+ const index = steps.findIndex(step => step.id === stepId);
3
+ if (index === -1) return steps;
4
+ if (action === "remove") return steps.filter(step => step.id !== stepId);
5
+ const target = action === "up" ? index - 1 : index + 1;
6
+ if (target < 0 || target >= steps.length) return steps;
7
+ const reordered = [...steps];
8
+ const [moved] = reordered.splice(index, 1);
9
+ if (moved) reordered.splice(target, 0, moved);
10
+ return reordered;
11
+ }
12
+ export function focusAfterAction(steps, stepId, action) {
13
+ if (action !== "remove") {
14
+ const index = steps.findIndex(step => step.id === stepId);
15
+ const atEdge = action === "up" ? index === 0 : index === steps.length - 1;
16
+ return {
17
+ stepId,
18
+ control: atEdge ? "title" : action
19
+ };
20
+ }
21
+ const neighbor = steps[0];
22
+ return neighbor ? {
23
+ stepId: neighbor.id,
24
+ control: "title"
25
+ } : null;
26
+ }
27
+ export function describeStepAction(position, action) {
28
+ if (action === "remove") return `Step ${position + 1} removed.`;
29
+ return `Step moved ${action}.`;
30
+ }
@@ -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 {};