@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
package/dist/cost/cost.js CHANGED
@@ -1,37 +1,531 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { Money as CoinsIcon } from "@carbon/icons-react";
3
3
  import { cn } from "@locusgraph/components";
4
4
  import { formatCount, formatMicroUsd, pluralize } from "@locusgraph/utils";
5
5
  import { ApprovalPanel, PanelHeader } from "../shared/panel.js";
6
6
  import { sumUsage } from "./shared/usage-totals.js";
7
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
7
8
  function attemptsOf(usage) {
8
- return Array.isArray(usage) ? usage : [usage];
9
+ return Array.isArray(usage) ? usage : [usage];
9
10
  }
10
11
  function modelsOf(attempts) {
11
- const models = [...new Set(attempts.map((attempt) => attempt.model).filter(Boolean))];
12
- return models.length > 0 ? models.join(", ") : undefined;
13
- }
14
- function WastedNote({ totals }) {
15
- if (totals.failedAttempts === 0)
16
- return null;
17
- return (_jsxs("span", { "data-slot": "cost-wasted", className: "text-destructive tabular-nums", children: [pluralize(totals.failedAttempts, "failed attempt"), " \u00B7 ", formatMicroUsd(totals.wastedMicroUsd), " ", "wasted"] }));
18
- }
19
- function CompactCost({ attempts, totals, className, }) {
20
- const model = modelsOf(attempts);
21
- return (_jsxs("span", { "data-slot": "cost", "data-variant": "compact", "data-failed": totals.failedAttempts > 0 || undefined, className: cn("inline-flex flex-wrap items-baseline gap-x-3 gap-y-0.5 font-mono text-[11px] text-muted-foreground tabular-nums", className), children: [_jsx("span", { className: "font-medium text-foreground", children: formatMicroUsd(totals.costMicroUsd) }), _jsxs("span", { className: "whitespace-nowrap", children: [formatCount(totals.inputTokens), " in \u00B7 ", formatCount(totals.outputTokens), " out"] }), model && _jsx("span", { children: model }), _jsx(WastedNote, { totals: totals })] }));
22
- }
23
- function AttemptRow({ attempt, position }) {
24
- return (_jsxs("li", { "data-slot": "cost-attempt", "data-failed": attempt.failed || undefined, className: "grid grid-cols-[1fr_auto_4.5rem] items-baseline gap-x-4 px-5 py-2.5 text-sm tabular-nums", children: [_jsxs("span", { className: "flex min-w-0 items-baseline gap-2", children: [_jsxs("span", { className: "eyebrow", children: ["#", position + 1] }), _jsx("span", { className: cn("truncate", attempt.failed && "text-muted-foreground"), children: attempt.model ?? "Attempt" }), attempt.failed && (_jsx("span", { className: "font-mono text-[11px] tracking-wide text-destructive uppercase", children: "Failed" }))] }), _jsxs("span", { className: "font-mono text-[11px] text-muted-foreground max-sm:hidden", children: [formatCount(attempt.inputTokens), " in \u00B7 ", formatCount(attempt.outputTokens), " out"] }), _jsx("span", { className: cn("text-right font-mono text-xs", attempt.failed && "text-muted-foreground line-through"), children: formatMicroUsd(attempt.costMicroUsd) })] }));
25
- }
26
- function DetailedCost({ attempts, totals, label, className, }) {
27
- const failed = totals.failedAttempts > 0;
28
- return (_jsxs(ApprovalPanel, { "data-slot": "cost", "data-variant": "detailed", "data-failed": failed || undefined, "aria-label": label, className: className, children: [_jsx(PanelHeader, { icon: _jsx(CoinsIcon, { "aria-hidden": true }), eyebrow: label, aside: pluralize(attempts.length, "attempt") }), _jsxs("div", { className: "flex flex-col gap-1 px-5 pt-2 pb-4", children: [_jsx("span", { className: "text-2xl font-semibold tracking-tight tabular-nums", children: formatMicroUsd(totals.costMicroUsd) }), _jsxs("span", { className: "flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground tabular-nums", children: [_jsxs("span", { children: [formatCount(totals.inputTokens), " in \u00B7 ", formatCount(totals.outputTokens), " out"] }), _jsx(WastedNote, { totals: totals })] })] }), _jsx("ol", { className: "flex flex-col divide-y divide-border border-t border-border", children: attempts.map((attempt, position) => (_jsx(AttemptRow, { attempt: attempt, position: position }, position))) })] }));
29
- }
30
- export function Cost({ usage, variant = "compact", label = "Run cost", className }) {
31
- const attempts = attemptsOf(usage);
32
- const totals = sumUsage(attempts);
33
- if (variant === "detailed") {
34
- return _jsx(DetailedCost, { attempts: attempts, totals: totals, label: label, className: className });
12
+ const models = [...new Set(attempts.map(attempt => attempt.model).filter(Boolean))];
13
+ return models.length > 0 ? models.join(", ") : undefined;
14
+ }
15
+ function WastedNote(t0) {
16
+ const $ = _c(7);
17
+ const {
18
+ totals
19
+ } = t0;
20
+ if (totals.failedAttempts === 0) {
21
+ return null;
22
+ }
23
+ let t1;
24
+ if ($[0] !== totals.failedAttempts) {
25
+ t1 = pluralize(totals.failedAttempts, "failed attempt");
26
+ $[0] = totals.failedAttempts;
27
+ $[1] = t1;
28
+ } else {
29
+ t1 = $[1];
30
+ }
31
+ let t2;
32
+ if ($[2] !== totals.wastedMicroUsd) {
33
+ t2 = formatMicroUsd(totals.wastedMicroUsd);
34
+ $[2] = totals.wastedMicroUsd;
35
+ $[3] = t2;
36
+ } else {
37
+ t2 = $[3];
38
+ }
39
+ let t3;
40
+ if ($[4] !== t1 || $[5] !== t2) {
41
+ t3 = /*#__PURE__*/_jsxs("span", {
42
+ "data-slot": "cost-wasted",
43
+ className: "text-destructive tabular-nums",
44
+ children: [t1, " \xB7 ", t2, " ", "wasted"]
45
+ });
46
+ $[4] = t1;
47
+ $[5] = t2;
48
+ $[6] = t3;
49
+ } else {
50
+ t3 = $[6];
51
+ }
52
+ return t3;
53
+ }
54
+ function CompactCost(t0) {
55
+ const $ = _c(26);
56
+ const {
57
+ attempts,
58
+ totals,
59
+ className
60
+ } = t0;
61
+ let t1;
62
+ if ($[0] !== attempts) {
63
+ t1 = modelsOf(attempts);
64
+ $[0] = attempts;
65
+ $[1] = t1;
66
+ } else {
67
+ t1 = $[1];
68
+ }
69
+ const model = t1;
70
+ const t2 = totals.failedAttempts > 0 || undefined;
71
+ let t3;
72
+ if ($[2] !== className) {
73
+ t3 = cn("inline-flex flex-wrap items-baseline gap-x-3 gap-y-0.5 font-mono text-[11px] text-muted-foreground tabular-nums", className);
74
+ $[2] = className;
75
+ $[3] = t3;
76
+ } else {
77
+ t3 = $[3];
78
+ }
79
+ let t4;
80
+ if ($[4] !== totals.costMicroUsd) {
81
+ t4 = formatMicroUsd(totals.costMicroUsd);
82
+ $[4] = totals.costMicroUsd;
83
+ $[5] = t4;
84
+ } else {
85
+ t4 = $[5];
86
+ }
87
+ let t5;
88
+ if ($[6] !== t4) {
89
+ t5 = /*#__PURE__*/_jsx("span", {
90
+ className: "font-medium text-foreground",
91
+ children: t4
92
+ });
93
+ $[6] = t4;
94
+ $[7] = t5;
95
+ } else {
96
+ t5 = $[7];
97
+ }
98
+ let t6;
99
+ if ($[8] !== totals.inputTokens) {
100
+ t6 = formatCount(totals.inputTokens);
101
+ $[8] = totals.inputTokens;
102
+ $[9] = t6;
103
+ } else {
104
+ t6 = $[9];
105
+ }
106
+ let t7;
107
+ if ($[10] !== totals.outputTokens) {
108
+ t7 = formatCount(totals.outputTokens);
109
+ $[10] = totals.outputTokens;
110
+ $[11] = t7;
111
+ } else {
112
+ t7 = $[11];
113
+ }
114
+ let t8;
115
+ if ($[12] !== t6 || $[13] !== t7) {
116
+ t8 = /*#__PURE__*/_jsxs("span", {
117
+ className: "whitespace-nowrap",
118
+ children: [t6, " in \xB7 ", t7, " out"]
119
+ });
120
+ $[12] = t6;
121
+ $[13] = t7;
122
+ $[14] = t8;
123
+ } else {
124
+ t8 = $[14];
125
+ }
126
+ let t9;
127
+ if ($[15] !== model) {
128
+ t9 = model && /*#__PURE__*/_jsx("span", {
129
+ children: model
130
+ });
131
+ $[15] = model;
132
+ $[16] = t9;
133
+ } else {
134
+ t9 = $[16];
135
+ }
136
+ let t10;
137
+ if ($[17] !== totals) {
138
+ t10 = /*#__PURE__*/_jsx(WastedNote, {
139
+ totals: totals
140
+ });
141
+ $[17] = totals;
142
+ $[18] = t10;
143
+ } else {
144
+ t10 = $[18];
145
+ }
146
+ let t11;
147
+ if ($[19] !== t10 || $[20] !== t2 || $[21] !== t3 || $[22] !== t5 || $[23] !== t8 || $[24] !== t9) {
148
+ t11 = /*#__PURE__*/_jsxs("span", {
149
+ "data-slot": "cost",
150
+ "data-variant": "compact",
151
+ "data-failed": t2,
152
+ className: t3,
153
+ children: [t5, t8, t9, t10]
154
+ });
155
+ $[19] = t10;
156
+ $[20] = t2;
157
+ $[21] = t3;
158
+ $[22] = t5;
159
+ $[23] = t8;
160
+ $[24] = t9;
161
+ $[25] = t11;
162
+ } else {
163
+ t11 = $[25];
164
+ }
165
+ return t11;
166
+ }
167
+ function AttemptRow(t0) {
168
+ const $ = _c(32);
169
+ const {
170
+ attempt,
171
+ position
172
+ } = t0;
173
+ const t1 = attempt.failed || undefined;
174
+ const t2 = position + 1;
175
+ let t3;
176
+ if ($[0] !== t2) {
177
+ t3 = /*#__PURE__*/_jsxs("span", {
178
+ className: "eyebrow",
179
+ children: ["#", t2]
180
+ });
181
+ $[0] = t2;
182
+ $[1] = t3;
183
+ } else {
184
+ t3 = $[1];
185
+ }
186
+ const t4 = attempt.failed && "text-muted-foreground";
187
+ let t5;
188
+ if ($[2] !== t4) {
189
+ t5 = cn("truncate", t4);
190
+ $[2] = t4;
191
+ $[3] = t5;
192
+ } else {
193
+ t5 = $[3];
194
+ }
195
+ const t6 = attempt.model ?? "Attempt";
196
+ let t7;
197
+ if ($[4] !== t5 || $[5] !== t6) {
198
+ t7 = /*#__PURE__*/_jsx("span", {
199
+ className: t5,
200
+ children: t6
201
+ });
202
+ $[4] = t5;
203
+ $[5] = t6;
204
+ $[6] = t7;
205
+ } else {
206
+ t7 = $[6];
207
+ }
208
+ let t8;
209
+ if ($[7] !== attempt.failed) {
210
+ t8 = attempt.failed && /*#__PURE__*/_jsx("span", {
211
+ className: "font-mono text-[11px] tracking-wide text-destructive uppercase",
212
+ children: "Failed"
213
+ });
214
+ $[7] = attempt.failed;
215
+ $[8] = t8;
216
+ } else {
217
+ t8 = $[8];
218
+ }
219
+ let t9;
220
+ if ($[9] !== t3 || $[10] !== t7 || $[11] !== t8) {
221
+ t9 = /*#__PURE__*/_jsxs("span", {
222
+ className: "flex min-w-0 items-baseline gap-2",
223
+ children: [t3, t7, t8]
224
+ });
225
+ $[9] = t3;
226
+ $[10] = t7;
227
+ $[11] = t8;
228
+ $[12] = t9;
229
+ } else {
230
+ t9 = $[12];
231
+ }
232
+ let t10;
233
+ if ($[13] !== attempt.inputTokens) {
234
+ t10 = formatCount(attempt.inputTokens);
235
+ $[13] = attempt.inputTokens;
236
+ $[14] = t10;
237
+ } else {
238
+ t10 = $[14];
239
+ }
240
+ let t11;
241
+ if ($[15] !== attempt.outputTokens) {
242
+ t11 = formatCount(attempt.outputTokens);
243
+ $[15] = attempt.outputTokens;
244
+ $[16] = t11;
245
+ } else {
246
+ t11 = $[16];
247
+ }
248
+ let t12;
249
+ if ($[17] !== t10 || $[18] !== t11) {
250
+ t12 = /*#__PURE__*/_jsxs("span", {
251
+ className: "font-mono text-[11px] text-muted-foreground max-sm:hidden",
252
+ children: [t10, " in \xB7 ", t11, " out"]
253
+ });
254
+ $[17] = t10;
255
+ $[18] = t11;
256
+ $[19] = t12;
257
+ } else {
258
+ t12 = $[19];
259
+ }
260
+ const t13 = attempt.failed && "text-muted-foreground line-through";
261
+ let t14;
262
+ if ($[20] !== t13) {
263
+ t14 = cn("text-right font-mono text-xs", t13);
264
+ $[20] = t13;
265
+ $[21] = t14;
266
+ } else {
267
+ t14 = $[21];
268
+ }
269
+ let t15;
270
+ if ($[22] !== attempt.costMicroUsd) {
271
+ t15 = formatMicroUsd(attempt.costMicroUsd);
272
+ $[22] = attempt.costMicroUsd;
273
+ $[23] = t15;
274
+ } else {
275
+ t15 = $[23];
276
+ }
277
+ let t16;
278
+ if ($[24] !== t14 || $[25] !== t15) {
279
+ t16 = /*#__PURE__*/_jsx("span", {
280
+ className: t14,
281
+ children: t15
282
+ });
283
+ $[24] = t14;
284
+ $[25] = t15;
285
+ $[26] = t16;
286
+ } else {
287
+ t16 = $[26];
288
+ }
289
+ let t17;
290
+ if ($[27] !== t1 || $[28] !== t12 || $[29] !== t16 || $[30] !== t9) {
291
+ t17 = /*#__PURE__*/_jsxs("li", {
292
+ "data-slot": "cost-attempt",
293
+ "data-failed": t1,
294
+ className: "grid grid-cols-[1fr_auto_4.5rem] items-baseline gap-x-4 px-5 py-2.5 text-sm tabular-nums",
295
+ children: [t9, t12, t16]
296
+ });
297
+ $[27] = t1;
298
+ $[28] = t12;
299
+ $[29] = t16;
300
+ $[30] = t9;
301
+ $[31] = t17;
302
+ } else {
303
+ t17 = $[31];
304
+ }
305
+ return t17;
306
+ }
307
+ function DetailedCost(t0) {
308
+ const $ = _c(36);
309
+ const {
310
+ attempts,
311
+ totals,
312
+ label,
313
+ className
314
+ } = t0;
315
+ const failed = totals.failedAttempts > 0;
316
+ const t1 = failed || undefined;
317
+ let t2;
318
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
319
+ t2 = /*#__PURE__*/_jsx(CoinsIcon, {
320
+ "aria-hidden": true
321
+ });
322
+ $[0] = t2;
323
+ } else {
324
+ t2 = $[0];
325
+ }
326
+ let t3;
327
+ if ($[1] !== attempts.length) {
328
+ t3 = pluralize(attempts.length, "attempt");
329
+ $[1] = attempts.length;
330
+ $[2] = t3;
331
+ } else {
332
+ t3 = $[2];
333
+ }
334
+ let t4;
335
+ if ($[3] !== label || $[4] !== t3) {
336
+ t4 = /*#__PURE__*/_jsx(PanelHeader, {
337
+ icon: t2,
338
+ eyebrow: label,
339
+ aside: t3
340
+ });
341
+ $[3] = label;
342
+ $[4] = t3;
343
+ $[5] = t4;
344
+ } else {
345
+ t4 = $[5];
346
+ }
347
+ let t5;
348
+ if ($[6] !== totals.costMicroUsd) {
349
+ t5 = formatMicroUsd(totals.costMicroUsd);
350
+ $[6] = totals.costMicroUsd;
351
+ $[7] = t5;
352
+ } else {
353
+ t5 = $[7];
354
+ }
355
+ let t6;
356
+ if ($[8] !== t5) {
357
+ t6 = /*#__PURE__*/_jsx("span", {
358
+ className: "text-2xl font-semibold tracking-tight tabular-nums",
359
+ children: t5
360
+ });
361
+ $[8] = t5;
362
+ $[9] = t6;
363
+ } else {
364
+ t6 = $[9];
365
+ }
366
+ let t7;
367
+ if ($[10] !== totals.inputTokens) {
368
+ t7 = formatCount(totals.inputTokens);
369
+ $[10] = totals.inputTokens;
370
+ $[11] = t7;
371
+ } else {
372
+ t7 = $[11];
373
+ }
374
+ let t8;
375
+ if ($[12] !== totals.outputTokens) {
376
+ t8 = formatCount(totals.outputTokens);
377
+ $[12] = totals.outputTokens;
378
+ $[13] = t8;
379
+ } else {
380
+ t8 = $[13];
381
+ }
382
+ let t9;
383
+ if ($[14] !== t7 || $[15] !== t8) {
384
+ t9 = /*#__PURE__*/_jsxs("span", {
385
+ children: [t7, " in \xB7 ", t8, " out"]
386
+ });
387
+ $[14] = t7;
388
+ $[15] = t8;
389
+ $[16] = t9;
390
+ } else {
391
+ t9 = $[16];
392
+ }
393
+ let t10;
394
+ if ($[17] !== totals) {
395
+ t10 = /*#__PURE__*/_jsx(WastedNote, {
396
+ totals: totals
397
+ });
398
+ $[17] = totals;
399
+ $[18] = t10;
400
+ } else {
401
+ t10 = $[18];
402
+ }
403
+ let t11;
404
+ if ($[19] !== t10 || $[20] !== t9) {
405
+ t11 = /*#__PURE__*/_jsxs("span", {
406
+ className: "flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground tabular-nums",
407
+ children: [t9, t10]
408
+ });
409
+ $[19] = t10;
410
+ $[20] = t9;
411
+ $[21] = t11;
412
+ } else {
413
+ t11 = $[21];
414
+ }
415
+ let t12;
416
+ if ($[22] !== t11 || $[23] !== t6) {
417
+ t12 = /*#__PURE__*/_jsxs("div", {
418
+ className: "flex flex-col gap-1 px-5 pt-2 pb-4",
419
+ children: [t6, t11]
420
+ });
421
+ $[22] = t11;
422
+ $[23] = t6;
423
+ $[24] = t12;
424
+ } else {
425
+ t12 = $[24];
426
+ }
427
+ let t13;
428
+ if ($[25] !== attempts) {
429
+ t13 = attempts.map(_temp);
430
+ $[25] = attempts;
431
+ $[26] = t13;
432
+ } else {
433
+ t13 = $[26];
434
+ }
435
+ let t14;
436
+ if ($[27] !== t13) {
437
+ t14 = /*#__PURE__*/_jsx("ol", {
438
+ className: "flex flex-col divide-y divide-border border-t border-border",
439
+ children: t13
440
+ });
441
+ $[27] = t13;
442
+ $[28] = t14;
443
+ } else {
444
+ t14 = $[28];
445
+ }
446
+ let t15;
447
+ if ($[29] !== className || $[30] !== label || $[31] !== t1 || $[32] !== t12 || $[33] !== t14 || $[34] !== t4) {
448
+ t15 = /*#__PURE__*/_jsxs(ApprovalPanel, {
449
+ "data-slot": "cost",
450
+ "data-variant": "detailed",
451
+ "data-failed": t1,
452
+ "aria-label": label,
453
+ className: className,
454
+ children: [t4, t12, t14]
455
+ });
456
+ $[29] = className;
457
+ $[30] = label;
458
+ $[31] = t1;
459
+ $[32] = t12;
460
+ $[33] = t14;
461
+ $[34] = t4;
462
+ $[35] = t15;
463
+ } else {
464
+ t15 = $[35];
465
+ }
466
+ return t15;
467
+ }
468
+ function _temp(attempt, position) {
469
+ return /*#__PURE__*/_jsx(AttemptRow, {
470
+ attempt: attempt,
471
+ position: position
472
+ }, position);
473
+ }
474
+ export function Cost(t0) {
475
+ const $ = _c(12);
476
+ const {
477
+ usage,
478
+ variant: t1,
479
+ label: t2,
480
+ className
481
+ } = t0;
482
+ const variant = t1 === undefined ? "compact" : t1;
483
+ const label = t2 === undefined ? "Run cost" : t2;
484
+ let attempts;
485
+ let t3;
486
+ if ($[0] !== usage) {
487
+ attempts = attemptsOf(usage);
488
+ t3 = sumUsage(attempts);
489
+ $[0] = usage;
490
+ $[1] = attempts;
491
+ $[2] = t3;
492
+ } else {
493
+ attempts = $[1];
494
+ t3 = $[2];
495
+ }
496
+ const totals = t3;
497
+ if (variant === "detailed") {
498
+ let t4;
499
+ if ($[3] !== attempts || $[4] !== className || $[5] !== label || $[6] !== totals) {
500
+ t4 = /*#__PURE__*/_jsx(DetailedCost, {
501
+ attempts: attempts,
502
+ totals: totals,
503
+ label: label,
504
+ className: className
505
+ });
506
+ $[3] = attempts;
507
+ $[4] = className;
508
+ $[5] = label;
509
+ $[6] = totals;
510
+ $[7] = t4;
511
+ } else {
512
+ t4 = $[7];
35
513
  }
36
- return _jsx(CompactCost, { attempts: attempts, totals: totals, className: className });
514
+ return t4;
515
+ }
516
+ let t4;
517
+ if ($[8] !== attempts || $[9] !== className || $[10] !== totals) {
518
+ t4 = /*#__PURE__*/_jsx(CompactCost, {
519
+ attempts: attempts,
520
+ totals: totals,
521
+ className: className
522
+ });
523
+ $[8] = attempts;
524
+ $[9] = className;
525
+ $[10] = totals;
526
+ $[11] = t4;
527
+ } else {
528
+ t4 = $[11];
529
+ }
530
+ return t4;
37
531
  }