@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,377 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ import { formatMicroUsd } from "@locusgraph/utils";
4
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
5
+ function percentOf(value, scale) {
6
+ return scale <= 0 ? 0 : Math.min(100, Math.max(0, value / scale * 100));
7
+ }
8
+ function meterFrame({
9
+ spentMicroUsd,
10
+ estimateMicroUsd,
11
+ capMicroUsd,
12
+ balanceMicroUsd,
13
+ outOfCredits
14
+ }) {
15
+ if (outOfCredits) {
16
+ const limit = Math.max(balanceMicroUsd, 0);
17
+ return {
18
+ base: limit,
19
+ extra: Math.max(estimateMicroUsd - limit, 0),
20
+ scale: Math.max(limit, estimateMicroUsd),
21
+ limit,
22
+ limitLabel: "Credits"
23
+ };
24
+ }
25
+ const scale = Math.max(capMicroUsd, spentMicroUsd + estimateMicroUsd);
26
+ return {
27
+ base: spentMicroUsd,
28
+ extra: estimateMicroUsd,
29
+ scale,
30
+ limit: capMicroUsd,
31
+ limitLabel: "Cap"
32
+ };
33
+ }
34
+ function labelAlignment(position) {
35
+ if (position > 80) return "-translate-x-full";
36
+ if (position < 20) return "";
37
+ return "-translate-x-1/2";
38
+ }
39
+ function Amount(t0) {
40
+ const $ = _c(7);
41
+ const {
42
+ value,
43
+ muted
44
+ } = t0;
45
+ const t1 = !muted && "text-foreground";
46
+ let t2;
47
+ if ($[0] !== t1) {
48
+ t2 = cn("font-medium", t1);
49
+ $[0] = t1;
50
+ $[1] = t2;
51
+ } else {
52
+ t2 = $[1];
53
+ }
54
+ let t3;
55
+ if ($[2] !== value) {
56
+ t3 = formatMicroUsd(value);
57
+ $[2] = value;
58
+ $[3] = t3;
59
+ } else {
60
+ t3 = $[3];
61
+ }
62
+ let t4;
63
+ if ($[4] !== t2 || $[5] !== t3) {
64
+ t4 = /*#__PURE__*/_jsx("span", {
65
+ className: t2,
66
+ children: t3
67
+ });
68
+ $[4] = t2;
69
+ $[5] = t3;
70
+ $[6] = t4;
71
+ } else {
72
+ t4 = $[6];
73
+ }
74
+ return t4;
75
+ }
76
+ function MeterLegend(props) {
77
+ const $ = _c(7);
78
+ const {
79
+ spentMicroUsd,
80
+ estimateMicroUsd,
81
+ capMicroUsd,
82
+ balanceMicroUsd,
83
+ outOfCredits,
84
+ muted
85
+ } = props;
86
+ let t0;
87
+ if ($[0] !== balanceMicroUsd || $[1] !== capMicroUsd || $[2] !== estimateMicroUsd || $[3] !== muted || $[4] !== outOfCredits || $[5] !== spentMicroUsd) {
88
+ t0 = /*#__PURE__*/_jsx("div", {
89
+ className: "flex flex-wrap justify-between gap-x-4 gap-y-1 text-xs text-muted-foreground tabular-nums",
90
+ children: outOfCredits ? /*#__PURE__*/_jsxs(_Fragment, {
91
+ children: [/*#__PURE__*/_jsxs("span", {
92
+ children: ["Next step needs ", /*#__PURE__*/_jsx(Amount, {
93
+ value: estimateMicroUsd,
94
+ muted: muted
95
+ }), ", you have", " ", /*#__PURE__*/_jsx("span", {
96
+ className: cn("font-medium", !muted && "text-destructive"),
97
+ children: formatMicroUsd(balanceMicroUsd)
98
+ }), " ", "in credits"]
99
+ }), /*#__PURE__*/_jsxs("span", {
100
+ children: [formatMicroUsd(spentMicroUsd), " spent this run"]
101
+ })]
102
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
103
+ children: [/*#__PURE__*/_jsxs("span", {
104
+ children: [/*#__PURE__*/_jsx(Amount, {
105
+ value: spentMicroUsd,
106
+ muted: muted
107
+ }), " spent of a", " ", /*#__PURE__*/_jsx(Amount, {
108
+ value: capMicroUsd,
109
+ muted: muted
110
+ }), " cap"]
111
+ }), /*#__PURE__*/_jsxs("span", {
112
+ children: [formatMicroUsd(balanceMicroUsd), " credits left"]
113
+ })]
114
+ })
115
+ });
116
+ $[0] = balanceMicroUsd;
117
+ $[1] = capMicroUsd;
118
+ $[2] = estimateMicroUsd;
119
+ $[3] = muted;
120
+ $[4] = outOfCredits;
121
+ $[5] = spentMicroUsd;
122
+ $[6] = t0;
123
+ } else {
124
+ t0 = $[6];
125
+ }
126
+ return t0;
127
+ }
128
+ export function SpendMeter(props) {
129
+ const $ = _c(58);
130
+ const {
131
+ outOfCredits,
132
+ muted: t0
133
+ } = props;
134
+ const muted = t0 === undefined ? false : t0;
135
+ let baseWidth;
136
+ let estimateWidth;
137
+ let limitPosition;
138
+ let t1;
139
+ let t10;
140
+ let t11;
141
+ let t2;
142
+ let t3;
143
+ let t4;
144
+ let t5;
145
+ let t6;
146
+ let t7;
147
+ let t8;
148
+ let t9;
149
+ if ($[0] !== outOfCredits || $[1] !== props) {
150
+ const {
151
+ base,
152
+ extra,
153
+ scale,
154
+ limit,
155
+ limitLabel
156
+ } = meterFrame(props);
157
+ baseWidth = percentOf(base, scale);
158
+ estimateWidth = percentOf(extra, scale);
159
+ limitPosition = percentOf(limit, scale);
160
+ const projected = base + extra;
161
+ t9 = "spend-meter";
162
+ t10 = "flex flex-col gap-1.5";
163
+ const t12 = `${limitPosition}%`;
164
+ let t13;
165
+ if ($[16] !== t12) {
166
+ t13 = {
167
+ left: t12
168
+ };
169
+ $[16] = t12;
170
+ $[17] = t13;
171
+ } else {
172
+ t13 = $[17];
173
+ }
174
+ t11 = /*#__PURE__*/_jsx("div", {
175
+ "aria-hidden": true,
176
+ className: "relative h-4",
177
+ children: /*#__PURE__*/_jsxs("span", {
178
+ className: cn("eyebrow absolute bottom-0 whitespace-nowrap", labelAlignment(limitPosition)),
179
+ style: t13,
180
+ children: [limitLabel, " ", formatMicroUsd(limit)]
181
+ })
182
+ });
183
+ t4 = "meter";
184
+ t5 = outOfCredits ? "Next step against your credits" : "Run spend against its cap";
185
+ t6 = 0;
186
+ t7 = scale;
187
+ t8 = projected;
188
+ if ($[18] !== projected) {
189
+ t1 = formatMicroUsd(projected);
190
+ $[18] = projected;
191
+ $[19] = t1;
192
+ } else {
193
+ t1 = $[19];
194
+ }
195
+ if ($[20] !== limitLabel) {
196
+ t2 = limitLabel.toLowerCase();
197
+ $[20] = limitLabel;
198
+ $[21] = t2;
199
+ } else {
200
+ t2 = $[21];
201
+ }
202
+ t3 = formatMicroUsd(limit);
203
+ $[0] = outOfCredits;
204
+ $[1] = props;
205
+ $[2] = baseWidth;
206
+ $[3] = estimateWidth;
207
+ $[4] = limitPosition;
208
+ $[5] = t1;
209
+ $[6] = t10;
210
+ $[7] = t11;
211
+ $[8] = t2;
212
+ $[9] = t3;
213
+ $[10] = t4;
214
+ $[11] = t5;
215
+ $[12] = t6;
216
+ $[13] = t7;
217
+ $[14] = t8;
218
+ $[15] = t9;
219
+ } else {
220
+ baseWidth = $[2];
221
+ estimateWidth = $[3];
222
+ limitPosition = $[4];
223
+ t1 = $[5];
224
+ t10 = $[6];
225
+ t11 = $[7];
226
+ t2 = $[8];
227
+ t3 = $[9];
228
+ t4 = $[10];
229
+ t5 = $[11];
230
+ t6 = $[12];
231
+ t7 = $[13];
232
+ t8 = $[14];
233
+ t9 = $[15];
234
+ }
235
+ const t12 = `${t1} after the next step, ${t2} ${t3}`;
236
+ const t13 = muted ? "bg-muted-foreground/40" : "bg-foreground/70";
237
+ let t14;
238
+ if ($[22] !== t13) {
239
+ t14 = cn("absolute inset-y-0 left-0", t13);
240
+ $[22] = t13;
241
+ $[23] = t14;
242
+ } else {
243
+ t14 = $[23];
244
+ }
245
+ const t15 = `${baseWidth}%`;
246
+ let t16;
247
+ if ($[24] !== t15) {
248
+ t16 = {
249
+ width: t15
250
+ };
251
+ $[24] = t15;
252
+ $[25] = t16;
253
+ } else {
254
+ t16 = $[25];
255
+ }
256
+ let t17;
257
+ if ($[26] !== t14 || $[27] !== t16) {
258
+ t17 = /*#__PURE__*/_jsx("span", {
259
+ "aria-hidden": true,
260
+ className: t14,
261
+ style: t16
262
+ });
263
+ $[26] = t14;
264
+ $[27] = t16;
265
+ $[28] = t17;
266
+ } else {
267
+ t17 = $[28];
268
+ }
269
+ const t18 = muted ? "bg-muted-foreground/25" : outOfCredits ? "bg-destructive" : "bg-warn";
270
+ let t19;
271
+ if ($[29] !== t18) {
272
+ t19 = cn("absolute inset-y-0", t18);
273
+ $[29] = t18;
274
+ $[30] = t19;
275
+ } else {
276
+ t19 = $[30];
277
+ }
278
+ const t20 = `${baseWidth}%`;
279
+ const t21 = `${estimateWidth}%`;
280
+ let t22;
281
+ if ($[31] !== t20 || $[32] !== t21) {
282
+ t22 = {
283
+ left: t20,
284
+ width: t21
285
+ };
286
+ $[31] = t20;
287
+ $[32] = t21;
288
+ $[33] = t22;
289
+ } else {
290
+ t22 = $[33];
291
+ }
292
+ let t23;
293
+ if ($[34] !== t19 || $[35] !== t22) {
294
+ t23 = /*#__PURE__*/_jsx("span", {
295
+ "aria-hidden": true,
296
+ className: t19,
297
+ style: t22
298
+ });
299
+ $[34] = t19;
300
+ $[35] = t22;
301
+ $[36] = t23;
302
+ } else {
303
+ t23 = $[36];
304
+ }
305
+ const t24 = `${limitPosition}%`;
306
+ let t25;
307
+ if ($[37] !== t24) {
308
+ t25 = /*#__PURE__*/_jsx("span", {
309
+ "aria-hidden": true,
310
+ className: "absolute -inset-y-1 -ml-px w-px bg-foreground",
311
+ style: {
312
+ left: t24
313
+ }
314
+ });
315
+ $[37] = t24;
316
+ $[38] = t25;
317
+ } else {
318
+ t25 = $[38];
319
+ }
320
+ let t26;
321
+ if ($[39] !== t12 || $[40] !== t17 || $[41] !== t23 || $[42] !== t25 || $[43] !== t4 || $[44] !== t5 || $[45] !== t6 || $[46] !== t7 || $[47] !== t8) {
322
+ t26 = /*#__PURE__*/_jsxs("div", {
323
+ role: t4,
324
+ "aria-label": t5,
325
+ "aria-valuemin": t6,
326
+ "aria-valuemax": t7,
327
+ "aria-valuenow": t8,
328
+ "aria-valuetext": t12,
329
+ className: "relative h-1.5 bg-muted-foreground/20",
330
+ children: [t17, t23, t25]
331
+ });
332
+ $[39] = t12;
333
+ $[40] = t17;
334
+ $[41] = t23;
335
+ $[42] = t25;
336
+ $[43] = t4;
337
+ $[44] = t5;
338
+ $[45] = t6;
339
+ $[46] = t7;
340
+ $[47] = t8;
341
+ $[48] = t26;
342
+ } else {
343
+ t26 = $[48];
344
+ }
345
+ let t27;
346
+ if ($[49] !== muted || $[50] !== props) {
347
+ t27 = /*#__PURE__*/_jsx("div", {
348
+ className: "pt-0.5",
349
+ children: /*#__PURE__*/_jsx(MeterLegend, {
350
+ ...props,
351
+ muted: muted
352
+ })
353
+ });
354
+ $[49] = muted;
355
+ $[50] = props;
356
+ $[51] = t27;
357
+ } else {
358
+ t27 = $[51];
359
+ }
360
+ let t28;
361
+ if ($[52] !== t10 || $[53] !== t11 || $[54] !== t26 || $[55] !== t27 || $[56] !== t9) {
362
+ t28 = /*#__PURE__*/_jsxs("div", {
363
+ "data-slot": t9,
364
+ className: t10,
365
+ children: [t11, t26, t27]
366
+ });
367
+ $[52] = t10;
368
+ $[53] = t11;
369
+ $[54] = t26;
370
+ $[55] = t27;
371
+ $[56] = t9;
372
+ $[57] = t28;
373
+ } else {
374
+ t28 = $[57];
375
+ }
376
+ return t28;
377
+ }
@@ -0,0 +1,14 @@
1
+ import { type RiskLevel, type ToolPart } from "../../types.js";
2
+ import type { ApprovalDecision } from "../types.js";
3
+ export type ApprovalProps = {
4
+ part: ToolPart;
5
+ risk?: RiskLevel;
6
+ actionLabel?: string;
7
+ description?: string;
8
+ decision?: ApprovalDecision;
9
+ onApprove: () => void;
10
+ onDeny: (reason?: string) => void;
11
+ autoFocus?: boolean;
12
+ className?: string;
13
+ };
14
+ export declare function Approval({ part, risk, actionLabel, description, decision, onApprove, onDeny, autoFocus, className, }: ApprovalProps): import("react").JSX.Element;
@@ -0,0 +1,290 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { ShieldAlert as ShieldAlertIcon, Tools as WrenchIcon } from "@carbon/icons-react";
3
+ import { Button, cn } from "@locusgraph/components";
4
+ import { useState } from "react";
5
+ import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle } from "../../shared/panel.js";
6
+ import { toolNameOf } from "../../types.js";
7
+ import { DecisionSummary } from "../shared/decision-line.js";
8
+ import { riskCopy, riskLabels, riskRing } from "../shared/risk-badge.js";
9
+ import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
10
+ import { DenyForm } from "./deny-form.js";
11
+ import { ToolInputs } from "./tool-inputs.js";
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ const settledStateLabels = {
14
+ "approval-responded": "Reply sent. Waiting for the tool to run.",
15
+ "output-available": "Approved and run.",
16
+ "output-error": "Approved, but the tool failed.",
17
+ "output-denied": "Denied. The tool did not run."
18
+ };
19
+ function settledLabel(state) {
20
+ return settledStateLabels[state] ?? "Waiting for the tool inputs.";
21
+ }
22
+ function headerStatus(awaiting, decision) {
23
+ if (decision) {
24
+ return decision.approved ? {
25
+ status: "Approved",
26
+ tone: "done"
27
+ } : {
28
+ status: "Denied",
29
+ tone: "danger"
30
+ };
31
+ }
32
+ return awaiting ? {
33
+ status: "Waiting for you",
34
+ tone: "waiting"
35
+ } : {
36
+ tone: "idle"
37
+ };
38
+ }
39
+ function decidedResult(toolName, state, decision) {
40
+ return settledStateLabels[state] ?? `${toolName} ${decision.approved ? "approved" : "denied"}`;
41
+ }
42
+ export function Approval(t0) {
43
+ const $ = _c(64);
44
+ const {
45
+ part,
46
+ risk: t1,
47
+ actionLabel,
48
+ description,
49
+ decision,
50
+ onApprove,
51
+ onDeny,
52
+ autoFocus: t2,
53
+ className
54
+ } = t0;
55
+ const risk = t1 === undefined ? "write" : t1;
56
+ const autoFocus = t2 === undefined ? true : t2;
57
+ const [denying, setDenying] = useState(false);
58
+ let t3;
59
+ if ($[0] !== part) {
60
+ t3 = toolNameOf(part);
61
+ $[0] = part;
62
+ $[1] = t3;
63
+ } else {
64
+ t3 = $[1];
65
+ }
66
+ const toolName = t3;
67
+ const awaiting = !decision && part.state === "approval-requested";
68
+ const approveRef = useFocusOnMount(autoFocus && awaiting);
69
+ const destructive = risk === "destructive";
70
+ const Icon = destructive ? ShieldAlertIcon : WrenchIcon;
71
+ let t4;
72
+ if ($[2] !== awaiting || $[3] !== decision) {
73
+ t4 = headerStatus(awaiting, decision);
74
+ $[2] = awaiting;
75
+ $[3] = decision;
76
+ $[4] = t4;
77
+ } else {
78
+ t4 = $[4];
79
+ }
80
+ const header = t4;
81
+ const t5 = decision ? decision.approved ? "approved" : "denied" : part.state;
82
+ const t6 = `Approve ${toolName}`;
83
+ const t7 = awaiting && riskRing[risk];
84
+ let t8;
85
+ if ($[5] !== className || $[6] !== t7) {
86
+ t8 = cn(t7, className);
87
+ $[5] = className;
88
+ $[6] = t7;
89
+ $[7] = t8;
90
+ } else {
91
+ t8 = $[7];
92
+ }
93
+ let t9;
94
+ if ($[8] !== Icon) {
95
+ t9 = /*#__PURE__*/_jsx(Icon, {
96
+ "aria-hidden": true
97
+ });
98
+ $[8] = Icon;
99
+ $[9] = t9;
100
+ } else {
101
+ t9 = $[9];
102
+ }
103
+ const t10 = awaiting ? "Approval needed" : "Tool call";
104
+ const t11 = riskLabels[risk];
105
+ let t12;
106
+ if ($[10] !== header.status || $[11] !== header.tone || $[12] !== t10 || $[13] !== t11 || $[14] !== t9) {
107
+ t12 = /*#__PURE__*/_jsx(PanelHeader, {
108
+ icon: t9,
109
+ eyebrow: t10,
110
+ aside: t11,
111
+ status: header.status,
112
+ tone: header.tone
113
+ });
114
+ $[10] = header.status;
115
+ $[11] = header.tone;
116
+ $[12] = t10;
117
+ $[13] = t11;
118
+ $[14] = t9;
119
+ $[15] = t12;
120
+ } else {
121
+ t12 = $[15];
122
+ }
123
+ const t13 = !awaiting && "text-muted-foreground";
124
+ let t14;
125
+ if ($[16] !== t13) {
126
+ t14 = cn("truncate font-mono", t13);
127
+ $[16] = t13;
128
+ $[17] = t14;
129
+ } else {
130
+ t14 = $[17];
131
+ }
132
+ let t15;
133
+ if ($[18] !== t14 || $[19] !== toolName) {
134
+ t15 = /*#__PURE__*/_jsx(PanelTitle, {
135
+ className: t14,
136
+ children: toolName
137
+ });
138
+ $[18] = t14;
139
+ $[19] = toolName;
140
+ $[20] = t15;
141
+ } else {
142
+ t15 = $[20];
143
+ }
144
+ let t16;
145
+ if ($[21] !== awaiting || $[22] !== description || $[23] !== risk || $[24] !== toolName) {
146
+ t16 = awaiting && /*#__PURE__*/_jsx("p", {
147
+ className: "px-5 pt-1 text-sm text-muted-foreground",
148
+ children: description ?? riskCopy[risk](toolName)
149
+ });
150
+ $[21] = awaiting;
151
+ $[22] = description;
152
+ $[23] = risk;
153
+ $[24] = toolName;
154
+ $[25] = t16;
155
+ } else {
156
+ t16 = $[25];
157
+ }
158
+ let t17;
159
+ if ($[26] !== actionLabel || $[27] !== approveRef || $[28] !== awaiting || $[29] !== denying || $[30] !== destructive || $[31] !== onApprove || $[32] !== part || $[33] !== toolName) {
160
+ t17 = awaiting && !denying && /*#__PURE__*/_jsxs(_Fragment, {
161
+ children: [/*#__PURE__*/_jsx(PanelBody, {
162
+ children: /*#__PURE__*/_jsx(ToolInputs, {
163
+ input: part.input
164
+ })
165
+ }), /*#__PURE__*/_jsxs(PanelFooter, {
166
+ className: "justify-between",
167
+ children: [/*#__PURE__*/_jsx("span", {
168
+ className: "hidden font-mono text-[11px] text-muted-foreground sm:inline",
169
+ children: "The run is paused"
170
+ }), /*#__PURE__*/_jsxs("span", {
171
+ className: "flex flex-wrap gap-2",
172
+ children: [/*#__PURE__*/_jsx(Button, {
173
+ type: "button",
174
+ size: "sm",
175
+ variant: "ghost",
176
+ onClick: () => setDenying(true),
177
+ children: "Deny"
178
+ }), /*#__PURE__*/_jsx(Button, {
179
+ ref: approveRef,
180
+ type: "button",
181
+ size: "sm",
182
+ variant: destructive ? "destructive" : "default",
183
+ onClick: onApprove,
184
+ children: actionLabel ?? `Run ${toolName}`
185
+ })]
186
+ })]
187
+ })]
188
+ });
189
+ $[26] = actionLabel;
190
+ $[27] = approveRef;
191
+ $[28] = awaiting;
192
+ $[29] = denying;
193
+ $[30] = destructive;
194
+ $[31] = onApprove;
195
+ $[32] = part;
196
+ $[33] = toolName;
197
+ $[34] = t17;
198
+ } else {
199
+ t17 = $[34];
200
+ }
201
+ let t18;
202
+ if ($[35] !== awaiting || $[36] !== denying || $[37] !== onDeny || $[38] !== part) {
203
+ t18 = awaiting && denying && /*#__PURE__*/_jsxs(_Fragment, {
204
+ children: [/*#__PURE__*/_jsx(PanelBody, {
205
+ className: "pb-4",
206
+ children: /*#__PURE__*/_jsx(ToolInputs, {
207
+ input: part.input,
208
+ muted: true
209
+ })
210
+ }), /*#__PURE__*/_jsx(DenyForm, {
211
+ onDeny: onDeny,
212
+ onBack: () => setDenying(false)
213
+ })]
214
+ });
215
+ $[35] = awaiting;
216
+ $[36] = denying;
217
+ $[37] = onDeny;
218
+ $[38] = part;
219
+ $[39] = t18;
220
+ } else {
221
+ t18 = $[39];
222
+ }
223
+ let t19;
224
+ if ($[40] !== awaiting || $[41] !== decision || $[42] !== part || $[43] !== toolName) {
225
+ t19 = !awaiting && /*#__PURE__*/_jsx(PanelBody, {
226
+ className: "pt-3",
227
+ children: decision ? /*#__PURE__*/_jsx(DecisionSummary, {
228
+ decision: decision,
229
+ result: decidedResult(toolName, part.state, decision)
230
+ }) : /*#__PURE__*/_jsx("p", {
231
+ className: "text-sm text-muted-foreground",
232
+ children: settledLabel(part.state)
233
+ })
234
+ });
235
+ $[40] = awaiting;
236
+ $[41] = decision;
237
+ $[42] = part;
238
+ $[43] = toolName;
239
+ $[44] = t19;
240
+ } else {
241
+ t19 = $[44];
242
+ }
243
+ let t20;
244
+ if ($[45] !== awaiting || $[46] !== decision || $[47] !== part || $[48] !== toolName) {
245
+ t20 = decision ? `${toolName} ${decision.approved ? "approved" : "denied"} by ${decision.by}` : awaiting ? `${toolName} is waiting for your approval` : settledLabel(part.state);
246
+ $[45] = awaiting;
247
+ $[46] = decision;
248
+ $[47] = part;
249
+ $[48] = toolName;
250
+ $[49] = t20;
251
+ } else {
252
+ t20 = $[49];
253
+ }
254
+ let t21;
255
+ if ($[50] !== t20) {
256
+ t21 = /*#__PURE__*/_jsx(LiveStatus, {
257
+ message: t20
258
+ });
259
+ $[50] = t20;
260
+ $[51] = t21;
261
+ } else {
262
+ t21 = $[51];
263
+ }
264
+ let t22;
265
+ if ($[52] !== risk || $[53] !== t12 || $[54] !== t15 || $[55] !== t16 || $[56] !== t17 || $[57] !== t18 || $[58] !== t19 || $[59] !== t21 || $[60] !== t5 || $[61] !== t6 || $[62] !== t8) {
266
+ t22 = /*#__PURE__*/_jsxs(ApprovalPanel, {
267
+ "data-slot": "approval",
268
+ "data-risk": risk,
269
+ "data-state": t5,
270
+ "aria-label": t6,
271
+ className: t8,
272
+ children: [t12, t15, t16, t17, t18, t19, t21]
273
+ });
274
+ $[52] = risk;
275
+ $[53] = t12;
276
+ $[54] = t15;
277
+ $[55] = t16;
278
+ $[56] = t17;
279
+ $[57] = t18;
280
+ $[58] = t19;
281
+ $[59] = t21;
282
+ $[60] = t5;
283
+ $[61] = t6;
284
+ $[62] = t8;
285
+ $[63] = t22;
286
+ } else {
287
+ t22 = $[63];
288
+ }
289
+ return t22;
290
+ }
@@ -0,0 +1,16 @@
1
+ import type { RiskLevel } from "../../../types.js";
2
+ import type { ApprovalDecision, ArgField, ArgValues } from "../../types.js";
3
+ export type ArgsEditorProps = {
4
+ toolName: string;
5
+ fields: ArgField[];
6
+ initialValues?: ArgValues;
7
+ risk?: RiskLevel;
8
+ actionLabel?: string;
9
+ description?: string;
10
+ decision?: ApprovalDecision;
11
+ onApprove: (editedInput: ArgValues) => void;
12
+ onCancel: () => void;
13
+ autoFocus?: boolean;
14
+ className?: string;
15
+ };
16
+ export declare function ArgsEditor({ toolName, fields, initialValues, risk, actionLabel, description, decision, onApprove, onCancel, autoFocus, className, }: ArgsEditorProps): import("react").JSX.Element;