@locusgraph/loop 0.3.0 → 0.4.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.
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/pulse/gradient-label.js +70 -17
- package/dist/agent/pulse/marks/bars-mark.js +39 -15
- package/dist/agent/pulse/marks/glyph-mark.js +57 -16
- package/dist/agent/pulse/marks/locus-mark.js +39 -13
- package/dist/agent/pulse/marks/orb-mark.js +21 -9
- package/dist/agent/pulse/pulse.js +1 -1
- package/dist/agent/pulse/use-loop-animation.d.ts +0 -1
- package/dist/agent/pulse/use-loop-animation.js +36 -15
- package/dist/agent/steps/step-icon.js +20 -13
- package/dist/agent/steps/steps.js +39 -37
- package/dist/agent/thinking/thinking.js +65 -62
- package/dist/agent/tool/json-block.js +10 -7
- package/dist/agent/tool/tool-status.d.ts +2 -0
- package/dist/agent/tool/tool-status.js +16 -13
- package/dist/agent/tool/tool.d.ts +8 -1
- package/dist/agent/tool/tool.js +238 -119
- package/dist/approval/inbox/inbox-row.d.ts +3 -3
- package/dist/approval/inbox/inbox-row.js +248 -86
- package/dist/approval/inbox/inbox.d.ts +3 -3
- package/dist/approval/inbox/inbox.js +251 -57
- package/dist/approval/inbox/virtual-inbox-list.d.ts +3 -3
- package/dist/approval/inbox/virtual-inbox-list.js +107 -30
- package/dist/approval/memory/memory-review.js +228 -91
- package/dist/approval/memory/memory-row.js +192 -56
- package/dist/approval/plan/plan-review.js +241 -108
- package/dist/approval/plan/plan-step-row.js +184 -77
- package/dist/approval/plan/plan-steps.d.ts +1 -1
- package/dist/approval/plan/plan-steps.js +2 -2
- package/dist/approval/plan/question-choices.js +139 -48
- package/dist/approval/plan/question.js +189 -67
- package/dist/approval/run/run-bar.js +138 -49
- package/dist/approval/shared/approval-line.d.ts +27 -0
- package/dist/approval/shared/approval-line.js +85 -0
- package/dist/approval/shared/risk-badge.d.ts +3 -5
- package/dist/approval/shared/risk-badge.js +11 -19
- package/dist/approval/shared/time.d.ts +0 -1
- package/dist/approval/shared/time.js +0 -1
- package/dist/approval/shared/use-focus-on-mount.js +23 -5
- package/dist/approval/shared/use-focus-when-settled.d.ts +2 -0
- package/dist/approval/shared/use-focus-when-settled.js +18 -0
- package/dist/approval/spend/raise-cap-form.d.ts +2 -2
- package/dist/approval/spend/raise-cap-form.js +235 -52
- package/dist/approval/spend/spend-gate.js +200 -106
- package/dist/approval/spend/spend-math.d.ts +1 -0
- package/dist/approval/spend/spend-math.js +5 -2
- package/dist/approval/spend/spend-meter.js +5 -5
- package/dist/approval/tool/approval.js +157 -96
- package/dist/approval/tool/args/args-editor.js +232 -81
- package/dist/approval/tool/args/args-field.js +333 -60
- package/dist/approval/tool/deny-form.js +114 -32
- package/dist/approval/tool/tool-inputs.js +93 -33
- package/dist/chat/chat/chat.js +5 -4
- package/dist/chat/chat/use-stick-to-bottom.js +116 -63
- package/dist/chat/chat/virtual-chat-items.js +129 -34
- package/dist/chat/composer/composer-actions.d.ts +1 -2
- package/dist/chat/composer/composer-actions.js +136 -50
- package/dist/chat/composer/composer-status.d.ts +2 -0
- package/dist/chat/composer/composer-status.js +3 -0
- package/dist/chat/composer/composer.d.ts +1 -1
- package/dist/chat/composer/composer.js +6 -4
- package/dist/chat/composer/use-auto-grow.js +29 -8
- package/dist/chat/files/files.js +296 -67
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/chat/reply/fenced-code.js +1 -1
- package/dist/chat/reply/markdown-components.js +9 -116
- package/dist/chat/reply/reply.js +2 -2
- package/dist/chat/turn/group-parts.d.ts +1 -0
- package/dist/chat/turn/group-parts.js +6 -3
- package/dist/chat/turn/turn.js +13 -4
- package/dist/cost/context.js +3 -3
- package/dist/cost/cost-steps.js +31 -30
- package/dist/cost/cost.js +39 -39
- package/dist/cost/model-picker.js +176 -43
- package/dist/cost/shared/context-breakdown.js +10 -11
- package/dist/cost/shared/model-option-row.js +4 -3
- package/dist/cost/shared/step-cost-row.js +11 -12
- package/dist/cost/shared/usage-totals.d.ts +1 -0
- package/dist/cost/shared/usage-totals.js +19 -1
- package/dist/memory/cite.js +190 -59
- package/dist/memory/memorized.js +231 -62
- package/dist/memory/recall.js +272 -85
- package/dist/memory/shared/host-label.d.ts +1 -1
- package/dist/memory/shared/host-label.js +2 -2
- package/dist/memory/shared/source-mark.js +1 -1
- package/dist/memory/sources.d.ts +2 -1
- package/dist/memory/sources.js +277 -62
- package/dist/shared/decision-summary.js +2 -1
- package/dist/shared/line.d.ts +10 -0
- package/dist/shared/line.js +11 -0
- package/dist/shared/live-status.d.ts +3 -0
- package/dist/shared/live-status.js +11 -0
- package/dist/shared/reduced-motion.d.ts +1 -0
- package/dist/shared/reduced-motion.js +3 -0
- package/dist/shared/virtual/use-list-virtualizer.js +2 -0
- package/dist/thread/actions/action-button.js +1 -1
- package/dist/thread/actions/actions.d.ts +3 -1
- package/dist/thread/actions/actions.js +100 -81
- package/dist/thread/actions/branch-switcher.js +129 -23
- package/dist/thread/canvas/canvas-meta.d.ts +9 -0
- package/dist/thread/canvas/canvas-meta.js +35 -0
- package/dist/thread/canvas/canvas.d.ts +1 -1
- package/dist/thread/canvas/canvas.js +64 -74
- package/dist/thread/canvas/version-switcher.d.ts +1 -0
- package/dist/thread/canvas/version-switcher.js +161 -45
- package/dist/thread/code/code.js +4 -6
- package/dist/thread/code/copy-code-button.d.ts +2 -1
- package/dist/thread/code/copy-code-button.js +91 -26
- package/dist/thread/history/history.d.ts +1 -1
- package/dist/thread/history/history.js +104 -104
- package/dist/thread/history/row/history-row.js +106 -22
- package/dist/thread/history/row/thread-item-menu.js +84 -20
- package/dist/thread/history/row/thread-title-editor.js +74 -29
- package/dist/thread/history/virtual-history-list.js +83 -46
- package/dist/thread/index.d.ts +1 -0
- package/dist/thread/index.js +1 -0
- package/dist/thread/starters/starters.js +91 -28
- package/dist/thread/use-copied.js +40 -10
- package/package.json +6 -6
- package/dist/agent/shared/status-dot.d.ts +0 -1
- package/dist/agent/shared/status-dot.js +0 -1
- package/dist/approval/shared/decision-line.d.ts +0 -1
- package/dist/approval/shared/decision-line.js +0 -1
- package/dist/memory/shared/disclosure.d.ts +0 -6
- package/dist/memory/shared/disclosure.js +0 -6
- package/dist/shared/panel.d.ts +0 -19
- package/dist/shared/panel.js +0 -77
- package/dist/shared/status-dot.d.ts +0 -6
- package/dist/shared/status-dot.js +0 -20
|
@@ -1,71 +1,254 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
1
4
|
import { Button, Input, Label } from "@locusgraph/components";
|
|
2
5
|
import { formatMicroUsd } from "@locusgraph/utils";
|
|
3
6
|
import { useId, useState } from "react";
|
|
4
7
|
import { dollarsToMicroUsd, microUsdToDollarsInput } from "./spend-math.js";
|
|
5
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
function capError(next,
|
|
9
|
+
function capError(next, minimumMicroUsd) {
|
|
7
10
|
if (next === null) return "Enter an amount in dollars.";
|
|
8
|
-
if (next
|
|
11
|
+
if (next < minimumMicroUsd) {
|
|
12
|
+
return `The new cap must be at least ${formatMicroUsd(minimumMicroUsd)} to cover the next step.`;
|
|
13
|
+
}
|
|
9
14
|
return undefined;
|
|
10
15
|
}
|
|
11
|
-
export function RaiseCapForm({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
export function RaiseCapForm(t0) {
|
|
17
|
+
const $ = _c(61);
|
|
18
|
+
const {
|
|
19
|
+
minimumMicroUsd,
|
|
20
|
+
suggestedMicroUsd,
|
|
21
|
+
disabled: t1,
|
|
22
|
+
onRaiseCap
|
|
23
|
+
} = t0;
|
|
24
|
+
const disabled = t1 === undefined ? false : t1;
|
|
17
25
|
const inputId = useId();
|
|
18
|
-
|
|
26
|
+
let t2;
|
|
27
|
+
if ($[0] !== suggestedMicroUsd) {
|
|
28
|
+
t2 = () => microUsdToDollarsInput(suggestedMicroUsd);
|
|
29
|
+
$[0] = suggestedMicroUsd;
|
|
30
|
+
$[1] = t2;
|
|
31
|
+
} else {
|
|
32
|
+
t2 = $[1];
|
|
33
|
+
}
|
|
34
|
+
const [dollars, setDollars] = useState(t2);
|
|
19
35
|
const [touched, setTouched] = useState(false);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
let T0;
|
|
37
|
+
let t10;
|
|
38
|
+
let t11;
|
|
39
|
+
let t12;
|
|
40
|
+
let t13;
|
|
41
|
+
let t14;
|
|
42
|
+
let t15;
|
|
43
|
+
let t16;
|
|
44
|
+
let t3;
|
|
45
|
+
let t4;
|
|
46
|
+
let t5;
|
|
47
|
+
let t6;
|
|
48
|
+
let t7;
|
|
49
|
+
let t8;
|
|
50
|
+
let t9;
|
|
51
|
+
let visibleError;
|
|
52
|
+
if ($[2] !== disabled || $[3] !== dollars || $[4] !== inputId || $[5] !== minimumMicroUsd || $[6] !== onRaiseCap || $[7] !== touched) {
|
|
53
|
+
const next = dollarsToMicroUsd(dollars);
|
|
54
|
+
const error = capError(next, minimumMicroUsd);
|
|
55
|
+
visibleError = touched ? error : undefined;
|
|
56
|
+
t13 = "raise-cap-form";
|
|
57
|
+
t14 = true;
|
|
58
|
+
t15 = "flex flex-col gap-1.5";
|
|
59
|
+
t16 = event => {
|
|
28
60
|
event.preventDefault();
|
|
29
61
|
setTouched(true);
|
|
30
|
-
if (next !== null && !error)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
62
|
+
if (next !== null && !error) {
|
|
63
|
+
onRaiseCap(next);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
t11 = "flex flex-wrap items-center gap-x-3 gap-y-2";
|
|
67
|
+
if ($[24] !== inputId) {
|
|
68
|
+
t12 = /*#__PURE__*/_jsx(Label, {
|
|
35
69
|
htmlFor: inputId,
|
|
36
|
-
className: "text-
|
|
70
|
+
className: "text-sm font-normal text-muted-foreground",
|
|
37
71
|
children: "Or raise the cap for this run"
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
72
|
+
});
|
|
73
|
+
$[24] = inputId;
|
|
74
|
+
$[25] = t12;
|
|
75
|
+
} else {
|
|
76
|
+
t12 = $[25];
|
|
77
|
+
}
|
|
78
|
+
t9 = "flex flex-wrap items-center gap-2";
|
|
79
|
+
let t17;
|
|
80
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
81
|
+
t17 = /*#__PURE__*/_jsx("span", {
|
|
82
|
+
"aria-hidden": true,
|
|
83
|
+
className: "pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-sm text-faint",
|
|
84
|
+
children: "$"
|
|
85
|
+
});
|
|
86
|
+
$[26] = t17;
|
|
87
|
+
} else {
|
|
88
|
+
t17 = $[26];
|
|
89
|
+
}
|
|
90
|
+
const t18 = visibleError ? true : undefined;
|
|
91
|
+
const t19 = visibleError ? `${inputId}-error` : undefined;
|
|
92
|
+
let t20;
|
|
93
|
+
let t21;
|
|
94
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
95
|
+
t20 = event_0 => setDollars(event_0.target.value);
|
|
96
|
+
t21 = () => setTouched(true);
|
|
97
|
+
$[27] = t20;
|
|
98
|
+
$[28] = t21;
|
|
99
|
+
} else {
|
|
100
|
+
t20 = $[27];
|
|
101
|
+
t21 = $[28];
|
|
102
|
+
}
|
|
103
|
+
if ($[29] !== disabled || $[30] !== dollars || $[31] !== inputId || $[32] !== t18 || $[33] !== t19) {
|
|
104
|
+
t10 = /*#__PURE__*/_jsxs("div", {
|
|
105
|
+
className: "relative w-32",
|
|
106
|
+
children: [t17, /*#__PURE__*/_jsx(Input, {
|
|
107
|
+
id: inputId,
|
|
108
|
+
inputMode: "decimal",
|
|
109
|
+
className: "h-control-sm border-transparent bg-muted pl-6 tabular-nums shadow-none dark:bg-muted",
|
|
110
|
+
value: dollars,
|
|
61
111
|
disabled: disabled,
|
|
62
|
-
|
|
112
|
+
"aria-invalid": t18,
|
|
113
|
+
"aria-describedby": t19,
|
|
114
|
+
onChange: t20,
|
|
115
|
+
onBlur: t21
|
|
63
116
|
})]
|
|
64
|
-
})
|
|
65
|
-
|
|
117
|
+
});
|
|
118
|
+
$[29] = disabled;
|
|
119
|
+
$[30] = dollars;
|
|
120
|
+
$[31] = inputId;
|
|
121
|
+
$[32] = t18;
|
|
122
|
+
$[33] = t19;
|
|
123
|
+
$[34] = t10;
|
|
124
|
+
} else {
|
|
125
|
+
t10 = $[34];
|
|
126
|
+
}
|
|
127
|
+
T0 = Button;
|
|
128
|
+
t3 = "submit";
|
|
129
|
+
t4 = "sm";
|
|
130
|
+
t5 = "ghost";
|
|
131
|
+
t6 = "text-muted-foreground hover:bg-transparent hover:text-interactive";
|
|
132
|
+
t7 = disabled;
|
|
133
|
+
t8 = next !== null && !error ? `Raise cap to ${formatMicroUsd(next)}` : "Raise cap";
|
|
134
|
+
$[2] = disabled;
|
|
135
|
+
$[3] = dollars;
|
|
136
|
+
$[4] = inputId;
|
|
137
|
+
$[5] = minimumMicroUsd;
|
|
138
|
+
$[6] = onRaiseCap;
|
|
139
|
+
$[7] = touched;
|
|
140
|
+
$[8] = T0;
|
|
141
|
+
$[9] = t10;
|
|
142
|
+
$[10] = t11;
|
|
143
|
+
$[11] = t12;
|
|
144
|
+
$[12] = t13;
|
|
145
|
+
$[13] = t14;
|
|
146
|
+
$[14] = t15;
|
|
147
|
+
$[15] = t16;
|
|
148
|
+
$[16] = t3;
|
|
149
|
+
$[17] = t4;
|
|
150
|
+
$[18] = t5;
|
|
151
|
+
$[19] = t6;
|
|
152
|
+
$[20] = t7;
|
|
153
|
+
$[21] = t8;
|
|
154
|
+
$[22] = t9;
|
|
155
|
+
$[23] = visibleError;
|
|
156
|
+
} else {
|
|
157
|
+
T0 = $[8];
|
|
158
|
+
t10 = $[9];
|
|
159
|
+
t11 = $[10];
|
|
160
|
+
t12 = $[11];
|
|
161
|
+
t13 = $[12];
|
|
162
|
+
t14 = $[13];
|
|
163
|
+
t15 = $[14];
|
|
164
|
+
t16 = $[15];
|
|
165
|
+
t3 = $[16];
|
|
166
|
+
t4 = $[17];
|
|
167
|
+
t5 = $[18];
|
|
168
|
+
t6 = $[19];
|
|
169
|
+
t7 = $[20];
|
|
170
|
+
t8 = $[21];
|
|
171
|
+
t9 = $[22];
|
|
172
|
+
visibleError = $[23];
|
|
173
|
+
}
|
|
174
|
+
let t17;
|
|
175
|
+
if ($[35] !== T0 || $[36] !== t3 || $[37] !== t4 || $[38] !== t5 || $[39] !== t6 || $[40] !== t7 || $[41] !== t8) {
|
|
176
|
+
t17 = /*#__PURE__*/_jsx(T0, {
|
|
177
|
+
type: t3,
|
|
178
|
+
size: t4,
|
|
179
|
+
variant: t5,
|
|
180
|
+
className: t6,
|
|
181
|
+
disabled: t7,
|
|
182
|
+
children: t8
|
|
183
|
+
});
|
|
184
|
+
$[35] = T0;
|
|
185
|
+
$[36] = t3;
|
|
186
|
+
$[37] = t4;
|
|
187
|
+
$[38] = t5;
|
|
188
|
+
$[39] = t6;
|
|
189
|
+
$[40] = t7;
|
|
190
|
+
$[41] = t8;
|
|
191
|
+
$[42] = t17;
|
|
192
|
+
} else {
|
|
193
|
+
t17 = $[42];
|
|
194
|
+
}
|
|
195
|
+
let t18;
|
|
196
|
+
if ($[43] !== t10 || $[44] !== t17 || $[45] !== t9) {
|
|
197
|
+
t18 = /*#__PURE__*/_jsxs("div", {
|
|
198
|
+
className: t9,
|
|
199
|
+
children: [t10, t17]
|
|
200
|
+
});
|
|
201
|
+
$[43] = t10;
|
|
202
|
+
$[44] = t17;
|
|
203
|
+
$[45] = t9;
|
|
204
|
+
$[46] = t18;
|
|
205
|
+
} else {
|
|
206
|
+
t18 = $[46];
|
|
207
|
+
}
|
|
208
|
+
let t19;
|
|
209
|
+
if ($[47] !== t11 || $[48] !== t12 || $[49] !== t18) {
|
|
210
|
+
t19 = /*#__PURE__*/_jsxs("div", {
|
|
211
|
+
className: t11,
|
|
212
|
+
children: [t12, t18]
|
|
213
|
+
});
|
|
214
|
+
$[47] = t11;
|
|
215
|
+
$[48] = t12;
|
|
216
|
+
$[49] = t18;
|
|
217
|
+
$[50] = t19;
|
|
218
|
+
} else {
|
|
219
|
+
t19 = $[50];
|
|
220
|
+
}
|
|
221
|
+
let t20;
|
|
222
|
+
if ($[51] !== inputId || $[52] !== visibleError) {
|
|
223
|
+
t20 = visibleError && /*#__PURE__*/_jsx("p", {
|
|
66
224
|
id: `${inputId}-error`,
|
|
67
|
-
className: "text-
|
|
225
|
+
className: "text-xs text-destructive",
|
|
68
226
|
children: visibleError
|
|
69
|
-
})
|
|
70
|
-
|
|
227
|
+
});
|
|
228
|
+
$[51] = inputId;
|
|
229
|
+
$[52] = visibleError;
|
|
230
|
+
$[53] = t20;
|
|
231
|
+
} else {
|
|
232
|
+
t20 = $[53];
|
|
233
|
+
}
|
|
234
|
+
let t21;
|
|
235
|
+
if ($[54] !== t13 || $[55] !== t14 || $[56] !== t15 || $[57] !== t16 || $[58] !== t19 || $[59] !== t20) {
|
|
236
|
+
t21 = /*#__PURE__*/_jsxs("form", {
|
|
237
|
+
"data-slot": t13,
|
|
238
|
+
noValidate: t14,
|
|
239
|
+
className: t15,
|
|
240
|
+
onSubmit: t16,
|
|
241
|
+
children: [t19, t20]
|
|
242
|
+
});
|
|
243
|
+
$[54] = t13;
|
|
244
|
+
$[55] = t14;
|
|
245
|
+
$[56] = t15;
|
|
246
|
+
$[57] = t16;
|
|
247
|
+
$[58] = t19;
|
|
248
|
+
$[59] = t20;
|
|
249
|
+
$[60] = t21;
|
|
250
|
+
} else {
|
|
251
|
+
t21 = $[60];
|
|
252
|
+
}
|
|
253
|
+
return t21;
|
|
71
254
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
4
|
import { Button, cn } from "@locusgraph/components";
|
|
3
5
|
import { formatMicroUsd } from "@locusgraph/utils";
|
|
4
|
-
import {
|
|
5
|
-
import { DecisionSummary } from "
|
|
6
|
+
import { CurrencyCircleDollar as CircleDollarSignIcon } from "@phosphor-icons/react/ssr";
|
|
7
|
+
import { DecisionSummary } from "../../shared/decision-summary.js";
|
|
8
|
+
import { lineObjectClass } from "../../shared/line.js";
|
|
9
|
+
import { LiveStatus } from "../../shared/live-status.js";
|
|
10
|
+
import { PendingLine, SettledLine } from "../shared/approval-line.js";
|
|
6
11
|
import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
|
|
12
|
+
import { useFocusWhenSettled } from "../shared/use-focus-when-settled.js";
|
|
7
13
|
import { RaiseCapForm } from "./raise-cap-form.js";
|
|
8
|
-
import { spendSituation, suggestedCapMicroUsd } from "./spend-math.js";
|
|
14
|
+
import { minimumCapMicroUsd, spendSituation, suggestedCapMicroUsd } from "./spend-math.js";
|
|
9
15
|
import { SpendMeter } from "./spend-meter.js";
|
|
10
16
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
17
|
const situationCopy = {
|
|
@@ -22,114 +28,202 @@ const situationStatus = {
|
|
|
22
28
|
"over-cap": "Over cap",
|
|
23
29
|
"out-of-credits": "Out of credits"
|
|
24
30
|
};
|
|
25
|
-
export function SpendGate({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
capMicroUsd,
|
|
29
|
-
balanceMicroUsd,
|
|
30
|
-
runName,
|
|
31
|
-
decision,
|
|
32
|
-
onAllowOnce,
|
|
33
|
-
onRaiseCap,
|
|
34
|
-
onStop,
|
|
35
|
-
onBuyCredits,
|
|
36
|
-
autoFocus = true,
|
|
37
|
-
className
|
|
38
|
-
}) {
|
|
39
|
-
const situation = spendSituation(balanceMicroUsd, estimateMicroUsd);
|
|
40
|
-
const outOfCredits = situation === "out-of-credits";
|
|
41
|
-
const projected = spentMicroUsd + estimateMicroUsd;
|
|
42
|
-
const copy = situationCopy[situation];
|
|
43
|
-
const primaryRef = useFocusOnMount(autoFocus && !decision);
|
|
44
|
-
const meter = {
|
|
31
|
+
export function SpendGate(t0) {
|
|
32
|
+
const $ = _c(39);
|
|
33
|
+
const {
|
|
45
34
|
spentMicroUsd,
|
|
46
35
|
estimateMicroUsd,
|
|
47
36
|
capMicroUsd,
|
|
48
37
|
balanceMicroUsd,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
38
|
+
runName,
|
|
39
|
+
decision,
|
|
40
|
+
onAllowOnce,
|
|
41
|
+
onRaiseCap,
|
|
42
|
+
onStop,
|
|
43
|
+
onBuyCredits,
|
|
44
|
+
autoFocus: t1,
|
|
45
|
+
className
|
|
46
|
+
} = t0;
|
|
47
|
+
const autoFocus = t1 === undefined ? true : t1;
|
|
48
|
+
let t2;
|
|
49
|
+
if ($[0] !== balanceMicroUsd || $[1] !== estimateMicroUsd) {
|
|
50
|
+
t2 = spendSituation(balanceMicroUsd, estimateMicroUsd);
|
|
51
|
+
$[0] = balanceMicroUsd;
|
|
52
|
+
$[1] = estimateMicroUsd;
|
|
53
|
+
$[2] = t2;
|
|
54
|
+
} else {
|
|
55
|
+
t2 = $[2];
|
|
56
|
+
}
|
|
57
|
+
const situation = t2;
|
|
58
|
+
const outOfCredits = situation === "out-of-credits";
|
|
59
|
+
const projected = spentMicroUsd + estimateMicroUsd;
|
|
60
|
+
const copy = situationCopy[situation];
|
|
61
|
+
const primaryRef = useFocusOnMount(autoFocus && !decision);
|
|
62
|
+
const settleRef = useFocusWhenSettled(!decision);
|
|
63
|
+
let t3;
|
|
64
|
+
if ($[3] !== balanceMicroUsd || $[4] !== capMicroUsd || $[5] !== estimateMicroUsd || $[6] !== outOfCredits || $[7] !== spentMicroUsd) {
|
|
65
|
+
t3 = {
|
|
66
|
+
spentMicroUsd,
|
|
67
|
+
estimateMicroUsd,
|
|
68
|
+
capMicroUsd,
|
|
69
|
+
balanceMicroUsd,
|
|
70
|
+
outOfCredits
|
|
71
|
+
};
|
|
72
|
+
$[3] = balanceMicroUsd;
|
|
73
|
+
$[4] = capMicroUsd;
|
|
74
|
+
$[5] = estimateMicroUsd;
|
|
75
|
+
$[6] = outOfCredits;
|
|
76
|
+
$[7] = spentMicroUsd;
|
|
77
|
+
$[8] = t3;
|
|
78
|
+
} else {
|
|
79
|
+
t3 = $[8];
|
|
80
|
+
}
|
|
81
|
+
const meter = t3;
|
|
82
|
+
let t4;
|
|
83
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
84
|
+
t4 = /*#__PURE__*/_jsx(CircleDollarSignIcon, {
|
|
85
|
+
weight: "bold",
|
|
86
|
+
"aria-hidden": true
|
|
87
|
+
});
|
|
88
|
+
$[9] = t4;
|
|
89
|
+
} else {
|
|
90
|
+
t4 = $[9];
|
|
91
|
+
}
|
|
92
|
+
const icon = t4;
|
|
93
|
+
let t5;
|
|
94
|
+
if ($[10] !== estimateMicroUsd) {
|
|
95
|
+
t5 = formatMicroUsd(estimateMicroUsd);
|
|
96
|
+
$[10] = estimateMicroUsd;
|
|
97
|
+
$[11] = t5;
|
|
98
|
+
} else {
|
|
99
|
+
t5 = $[11];
|
|
100
|
+
}
|
|
101
|
+
const estimate = t5;
|
|
102
|
+
const t6 = copy.title;
|
|
103
|
+
const t7 = !decision && "gap-3";
|
|
104
|
+
let t8;
|
|
105
|
+
if ($[12] !== className || $[13] !== t7) {
|
|
106
|
+
t8 = cn("flex min-w-0 flex-col outline-none", t7, className);
|
|
107
|
+
$[12] = className;
|
|
108
|
+
$[13] = t7;
|
|
109
|
+
$[14] = t8;
|
|
110
|
+
} else {
|
|
111
|
+
t8 = $[14];
|
|
112
|
+
}
|
|
113
|
+
let t9;
|
|
114
|
+
if ($[15] !== capMicroUsd || $[16] !== copy || $[17] !== decision || $[18] !== estimate || $[19] !== meter || $[20] !== onAllowOnce || $[21] !== onBuyCredits || $[22] !== onRaiseCap || $[23] !== onStop || $[24] !== outOfCredits || $[25] !== primaryRef || $[26] !== projected || $[27] !== runName || $[28] !== situation) {
|
|
115
|
+
t9 = decision ? /*#__PURE__*/_jsx(SettledLine, {
|
|
116
|
+
name: estimate,
|
|
117
|
+
verb: "Asked to spend",
|
|
118
|
+
icon: icon,
|
|
119
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
120
|
+
className: "flex flex-col gap-3",
|
|
121
|
+
children: [/*#__PURE__*/_jsx(DecisionSummary, {
|
|
122
|
+
decision: decision,
|
|
123
|
+
approvedVerb: "Allowed",
|
|
124
|
+
deniedVerb: "Stopped",
|
|
125
|
+
result: decision.approved ? `Allowed ${estimate} once` : `${runName ?? "The run"} stopped`
|
|
95
126
|
}), /*#__PURE__*/_jsx(SpendMeter, {
|
|
96
|
-
...meter
|
|
97
|
-
|
|
98
|
-
capMicroUsd: capMicroUsd,
|
|
99
|
-
suggestedMicroUsd: suggestedCapMicroUsd(projected, capMicroUsd),
|
|
100
|
-
onRaiseCap: onRaiseCap
|
|
127
|
+
...meter,
|
|
128
|
+
muted: true
|
|
101
129
|
})]
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
size: "sm",
|
|
113
|
-
variant: outOfCredits && !onBuyCredits ? "destructive" : "ghost",
|
|
114
|
-
onClick: onStop,
|
|
115
|
-
children: "Stop the run"
|
|
116
|
-
}), outOfCredits ? onBuyCredits && /*#__PURE__*/_jsx(Button, {
|
|
117
|
-
ref: primaryRef,
|
|
118
|
-
type: "button",
|
|
119
|
-
size: "sm",
|
|
120
|
-
onClick: onBuyCredits,
|
|
121
|
-
children: "Buy credits"
|
|
122
|
-
}) : /*#__PURE__*/_jsxs(Button, {
|
|
123
|
-
ref: primaryRef,
|
|
124
|
-
type: "button",
|
|
125
|
-
size: "sm",
|
|
126
|
-
onClick: onAllowOnce,
|
|
127
|
-
children: ["Allow ", formatMicroUsd(estimateMicroUsd), " once"]
|
|
128
|
-
})]
|
|
130
|
+
})
|
|
131
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
132
|
+
children: [/*#__PURE__*/_jsxs(PendingLine, {
|
|
133
|
+
icon: icon,
|
|
134
|
+
status: situationStatus[situation],
|
|
135
|
+
tone: outOfCredits ? "destructive" : "warn",
|
|
136
|
+
iconClassName: outOfCredits ? "text-destructive" : undefined,
|
|
137
|
+
children: ["\xB7 next step costs ", /*#__PURE__*/_jsx("span", {
|
|
138
|
+
className: lineObjectClass,
|
|
139
|
+
children: estimate
|
|
129
140
|
})]
|
|
141
|
+
}), /*#__PURE__*/_jsxs("p", {
|
|
142
|
+
className: "-mt-2 text-sm text-faint",
|
|
143
|
+
children: [copy.body(runName ?? "The agent"), " The run would reach", " ", /*#__PURE__*/_jsx("span", {
|
|
144
|
+
className: "tabular-nums",
|
|
145
|
+
children: formatMicroUsd(projected)
|
|
146
|
+
}), "."]
|
|
147
|
+
}), /*#__PURE__*/_jsx(SpendMeter, {
|
|
148
|
+
...meter
|
|
149
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
150
|
+
className: "flex flex-wrap items-center gap-2 pt-1",
|
|
151
|
+
children: [outOfCredits ? onBuyCredits && /*#__PURE__*/_jsx(Button, {
|
|
152
|
+
ref: primaryRef,
|
|
153
|
+
type: "button",
|
|
154
|
+
size: "sm",
|
|
155
|
+
onClick: onBuyCredits,
|
|
156
|
+
children: "Buy credits"
|
|
157
|
+
}) : /*#__PURE__*/_jsxs(Button, {
|
|
158
|
+
ref: primaryRef,
|
|
159
|
+
type: "button",
|
|
160
|
+
size: "sm",
|
|
161
|
+
onClick: onAllowOnce,
|
|
162
|
+
children: ["Allow ", estimate, " once"]
|
|
163
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
164
|
+
ref: outOfCredits && !onBuyCredits ? primaryRef : undefined,
|
|
165
|
+
type: "button",
|
|
166
|
+
size: "sm",
|
|
167
|
+
variant: outOfCredits && !onBuyCredits ? "destructive" : "ghost",
|
|
168
|
+
className: outOfCredits && !onBuyCredits ? undefined : "hover:bg-transparent hover:text-destructive",
|
|
169
|
+
onClick: onStop,
|
|
170
|
+
children: "Stop the run"
|
|
171
|
+
})]
|
|
172
|
+
}), !outOfCredits && /*#__PURE__*/_jsx(RaiseCapForm, {
|
|
173
|
+
minimumMicroUsd: minimumCapMicroUsd(projected, capMicroUsd),
|
|
174
|
+
suggestedMicroUsd: suggestedCapMicroUsd(projected, capMicroUsd),
|
|
175
|
+
onRaiseCap: onRaiseCap
|
|
130
176
|
})]
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
177
|
+
});
|
|
178
|
+
$[15] = capMicroUsd;
|
|
179
|
+
$[16] = copy;
|
|
180
|
+
$[17] = decision;
|
|
181
|
+
$[18] = estimate;
|
|
182
|
+
$[19] = meter;
|
|
183
|
+
$[20] = onAllowOnce;
|
|
184
|
+
$[21] = onBuyCredits;
|
|
185
|
+
$[22] = onRaiseCap;
|
|
186
|
+
$[23] = onStop;
|
|
187
|
+
$[24] = outOfCredits;
|
|
188
|
+
$[25] = primaryRef;
|
|
189
|
+
$[26] = projected;
|
|
190
|
+
$[27] = runName;
|
|
191
|
+
$[28] = situation;
|
|
192
|
+
$[29] = t9;
|
|
193
|
+
} else {
|
|
194
|
+
t9 = $[29];
|
|
195
|
+
}
|
|
196
|
+
const t10 = decision ? decision.approved ? "Spend allowed" : "Run stopped" : copy.title;
|
|
197
|
+
let t11;
|
|
198
|
+
if ($[30] !== t10) {
|
|
199
|
+
t11 = /*#__PURE__*/_jsx(LiveStatus, {
|
|
200
|
+
message: t10
|
|
201
|
+
});
|
|
202
|
+
$[30] = t10;
|
|
203
|
+
$[31] = t11;
|
|
204
|
+
} else {
|
|
205
|
+
t11 = $[31];
|
|
206
|
+
}
|
|
207
|
+
let t12;
|
|
208
|
+
if ($[32] !== copy.title || $[33] !== settleRef || $[34] !== situation || $[35] !== t11 || $[36] !== t8 || $[37] !== t9) {
|
|
209
|
+
t12 = /*#__PURE__*/_jsxs("section", {
|
|
210
|
+
ref: settleRef,
|
|
211
|
+
tabIndex: -1,
|
|
212
|
+
"data-slot": "spend-gate",
|
|
213
|
+
"data-situation": situation,
|
|
214
|
+
"aria-label": t6,
|
|
215
|
+
className: t8,
|
|
216
|
+
children: [t9, t11]
|
|
217
|
+
});
|
|
218
|
+
$[32] = copy.title;
|
|
219
|
+
$[33] = settleRef;
|
|
220
|
+
$[34] = situation;
|
|
221
|
+
$[35] = t11;
|
|
222
|
+
$[36] = t8;
|
|
223
|
+
$[37] = t9;
|
|
224
|
+
$[38] = t12;
|
|
225
|
+
} else {
|
|
226
|
+
t12 = $[38];
|
|
227
|
+
}
|
|
228
|
+
return t12;
|
|
135
229
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type SpendSituation = "over-cap" | "out-of-credits";
|
|
2
2
|
export declare function spendSituation(balanceMicroUsd: number, estimateMicroUsd: number): SpendSituation;
|
|
3
|
+
export declare function minimumCapMicroUsd(projectedMicroUsd: number, capMicroUsd: number): number;
|
|
3
4
|
export declare function suggestedCapMicroUsd(projectedMicroUsd: number, capMicroUsd: number): number;
|
|
4
5
|
export declare function dollarsToMicroUsd(dollars: string): number | null;
|
|
5
6
|
export declare function microUsdToDollarsInput(microUsd: number): string;
|
|
@@ -3,9 +3,12 @@ const microUsdPerCent = 10_000;
|
|
|
3
3
|
export function spendSituation(balanceMicroUsd, estimateMicroUsd) {
|
|
4
4
|
return balanceMicroUsd <= 0 || balanceMicroUsd < estimateMicroUsd ? "out-of-credits" : "over-cap";
|
|
5
5
|
}
|
|
6
|
+
export function minimumCapMicroUsd(projectedMicroUsd, capMicroUsd) {
|
|
7
|
+
return Math.max(projectedMicroUsd, capMicroUsd + microUsdPerCent);
|
|
8
|
+
}
|
|
6
9
|
export function suggestedCapMicroUsd(projectedMicroUsd, capMicroUsd) {
|
|
7
|
-
const
|
|
8
|
-
return Math.ceil(
|
|
10
|
+
const minimum = minimumCapMicroUsd(projectedMicroUsd, capMicroUsd);
|
|
11
|
+
return Math.ceil(minimum / microUsdPerDollar) * microUsdPerDollar;
|
|
9
12
|
}
|
|
10
13
|
export function dollarsToMicroUsd(dollars) {
|
|
11
14
|
const value = Number(dollars.trim());
|