@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.
- package/LICENSE +21 -0
- package/README.md +37 -2
- package/dist/agent/index.d.ts +5 -0
- package/dist/agent/index.js +5 -0
- package/dist/agent/pulse/gradient-label.d.ts +7 -0
- package/dist/agent/pulse/gradient-label.js +94 -0
- package/dist/agent/pulse/marks/bars-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/bars-mark.js +51 -0
- package/dist/agent/pulse/marks/glyph-mark.d.ts +4 -0
- package/dist/agent/pulse/marks/glyph-mark.js +62 -0
- package/dist/agent/pulse/marks/locus-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/locus-mark.js +73 -0
- package/dist/agent/pulse/marks/orb-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/orb-mark.js +34 -0
- package/dist/agent/pulse/marks/spinner-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/spinner-mark.js +32 -0
- package/dist/agent/pulse/pulse-tone.d.ts +1 -0
- package/dist/agent/pulse/pulse-tone.js +1 -0
- package/dist/agent/pulse/pulse.d.ts +12 -0
- package/dist/agent/pulse/pulse.js +166 -0
- package/dist/agent/pulse/use-loop-animation.d.ts +2 -0
- package/dist/agent/pulse/use-loop-animation.js +40 -0
- package/dist/agent/shared/status-dot.d.ts +1 -0
- package/dist/agent/shared/status-dot.js +1 -0
- package/dist/agent/steps/step-icon.d.ts +8 -0
- package/dist/agent/steps/step-icon.js +117 -0
- package/dist/agent/steps/steps.d.ts +7 -0
- package/dist/agent/steps/steps.js +249 -0
- package/dist/agent/thinking/thinking.d.ts +6 -0
- package/dist/agent/thinking/thinking.js +211 -0
- package/dist/agent/thinking/thought-duration.d.ts +2 -0
- package/dist/agent/thinking/thought-duration.js +11 -0
- package/dist/agent/tool/json-block.d.ts +5 -0
- package/dist/agent/tool/json-block.js +42 -0
- package/dist/agent/tool/tool-status.d.ts +6 -0
- package/dist/agent/tool/tool-status.js +59 -0
- package/dist/agent/tool/tool.d.ts +7 -0
- package/dist/agent/tool/tool.js +192 -0
- package/dist/approval/inbox/inbox-row.d.ts +12 -0
- package/dist/approval/inbox/inbox-row.js +328 -0
- package/dist/approval/inbox/inbox-selection.d.ts +6 -0
- package/dist/approval/inbox/inbox-selection.js +15 -0
- package/dist/approval/inbox/inbox.d.ts +12 -0
- package/dist/approval/inbox/inbox.js +258 -0
- package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
- package/dist/approval/inbox/virtual-inbox-list.js +129 -0
- package/dist/approval/index.d.ts +9 -0
- package/dist/approval/index.js +8 -0
- package/dist/approval/memory/memory-choices.d.ts +10 -0
- package/dist/approval/memory/memory-choices.js +35 -0
- package/dist/approval/memory/memory-review.d.ts +11 -0
- package/dist/approval/memory/memory-review.js +256 -0
- package/dist/approval/memory/memory-row.d.ts +9 -0
- package/dist/approval/memory/memory-row.js +226 -0
- package/dist/approval/plan/plan-review.d.ts +13 -0
- package/dist/approval/plan/plan-review.js +289 -0
- package/dist/approval/plan/plan-step-row.d.ts +13 -0
- package/dist/approval/plan/plan-step-row.js +201 -0
- package/dist/approval/plan/plan-steps.d.ts +8 -0
- package/dist/approval/plan/plan-steps.js +30 -0
- package/dist/approval/plan/question-choices.d.ts +10 -0
- package/dist/approval/plan/question-choices.js +166 -0
- package/dist/approval/plan/question.d.ts +18 -0
- package/dist/approval/plan/question.js +232 -0
- package/dist/approval/run/run-bar.d.ts +13 -0
- package/dist/approval/run/run-bar.js +189 -0
- package/dist/approval/shared/decision-line.d.ts +1 -0
- package/dist/approval/shared/decision-line.js +1 -0
- package/dist/approval/shared/risk-badge.d.ts +10 -0
- package/dist/approval/shared/risk-badge.js +57 -0
- package/dist/approval/shared/time.d.ts +3 -0
- package/dist/approval/shared/time.js +12 -0
- package/dist/approval/shared/use-focus-on-mount.d.ts +2 -0
- package/dist/approval/shared/use-focus-on-mount.js +26 -0
- package/dist/approval/spend/raise-cap-form.d.ts +8 -0
- package/dist/approval/spend/raise-cap-form.js +244 -0
- package/dist/approval/spend/spend-gate.d.ts +16 -0
- package/dist/approval/spend/spend-gate.js +250 -0
- package/dist/approval/spend/spend-math.d.ts +5 -0
- package/dist/approval/spend/spend-math.js +17 -0
- package/dist/approval/spend/spend-meter.d.ts +10 -0
- package/dist/approval/spend/spend-meter.js +377 -0
- package/dist/approval/tool/approval.d.ts +14 -0
- package/dist/approval/tool/approval.js +290 -0
- package/dist/approval/tool/args/args-editor.d.ts +16 -0
- package/dist/approval/tool/args/args-editor.js +273 -0
- package/dist/approval/tool/args/args-field.d.ts +11 -0
- package/dist/approval/tool/args/args-field.js +268 -0
- package/dist/approval/tool/args/args-validation.d.ts +8 -0
- package/dist/approval/tool/args/args-validation.js +50 -0
- package/dist/approval/tool/deny-form.d.ts +6 -0
- package/dist/approval/tool/deny-form.js +135 -0
- package/dist/approval/tool/tool-inputs.d.ts +6 -0
- package/dist/approval/tool/tool-inputs.js +142 -0
- package/dist/approval/types.d.ts +59 -0
- package/dist/approval/types.js +1 -0
- package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
- package/dist/chat/chat/chat-item-spacing.js +19 -0
- package/dist/chat/chat/chat.d.ts +8 -0
- package/dist/chat/chat/chat.js +187 -0
- package/dist/chat/chat/use-stick-to-bottom.d.ts +7 -0
- package/dist/chat/chat/use-stick-to-bottom.js +133 -0
- package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
- package/dist/chat/chat/virtual-chat-items.js +153 -0
- package/dist/chat/composer/composer-actions.d.ts +15 -0
- package/dist/chat/composer/composer-actions.js +158 -0
- package/dist/chat/composer/composer.d.ts +20 -0
- package/dist/chat/composer/composer.js +340 -0
- package/dist/chat/composer/use-auto-grow.d.ts +2 -0
- package/dist/chat/composer/use-auto-grow.js +29 -0
- package/dist/chat/files/file-meta.d.ts +13 -0
- package/dist/chat/files/file-meta.js +30 -0
- package/dist/chat/files/files.d.ts +9 -0
- package/dist/chat/files/files.js +327 -0
- package/dist/chat/index.d.ts +7 -0
- package/dist/chat/index.js +7 -0
- package/dist/chat/reply/fenced-code.d.ts +8 -0
- package/dist/chat/reply/fenced-code.js +53 -0
- package/dist/chat/reply/markdown-components.d.ts +2 -0
- package/dist/chat/reply/markdown-components.js +142 -0
- package/dist/chat/reply/reply.d.ts +8 -0
- package/dist/chat/reply/reply.js +116 -0
- package/dist/chat/turn/group-parts.d.ts +24 -0
- package/dist/chat/turn/group-parts.js +49 -0
- package/dist/chat/turn/turn.d.ts +11 -0
- package/dist/chat/turn/turn.js +253 -0
- package/dist/cost/context.d.ts +13 -0
- package/dist/cost/context.js +333 -0
- package/dist/cost/cost-steps.d.ts +17 -0
- package/dist/cost/cost-steps.js +230 -0
- package/dist/cost/cost.d.ts +8 -0
- package/dist/cost/cost.js +531 -0
- package/dist/cost/index.d.ts +4 -0
- package/dist/cost/index.js +4 -0
- package/dist/cost/model-picker.d.ts +11 -0
- package/dist/cost/model-picker.js +184 -0
- package/dist/cost/shared/context-breakdown.d.ts +15 -0
- package/dist/cost/shared/context-breakdown.js +306 -0
- package/dist/cost/shared/meter-marks.d.ts +9 -0
- package/dist/cost/shared/meter-marks.js +114 -0
- package/dist/cost/shared/model-option-row.d.ts +14 -0
- package/dist/cost/shared/model-option-row.js +189 -0
- package/dist/cost/shared/step-cost-row.d.ts +15 -0
- package/dist/cost/shared/step-cost-row.js +262 -0
- package/dist/cost/shared/usage-totals.d.ts +11 -0
- package/dist/cost/shared/usage-totals.js +30 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/memory/cite.d.ts +8 -0
- package/dist/memory/cite.js +190 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.js +4 -0
- package/dist/memory/memorized.d.ts +14 -0
- package/dist/memory/memorized.js +225 -0
- package/dist/memory/recall.d.ts +9 -0
- package/dist/memory/recall.js +303 -0
- package/dist/memory/shared/disclosure.d.ts +6 -0
- package/dist/memory/shared/disclosure.js +6 -0
- package/dist/memory/shared/host-label.d.ts +6 -0
- package/dist/memory/shared/host-label.js +31 -0
- package/dist/memory/shared/source-mark.d.ts +5 -0
- package/dist/memory/shared/source-mark.js +42 -0
- package/dist/memory/sources.d.ts +9 -0
- package/dist/memory/sources.js +264 -0
- package/dist/shared/decision-summary.d.ts +18 -0
- package/dist/shared/decision-summary.js +144 -0
- package/dist/shared/panel-empty.d.ts +8 -0
- package/dist/shared/panel-empty.js +80 -0
- package/dist/shared/panel.d.ts +19 -0
- package/dist/shared/panel.js +251 -0
- package/dist/shared/status-dot.d.ts +6 -0
- package/dist/shared/status-dot.js +42 -0
- package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
- package/dist/shared/virtual/use-list-virtualizer.js +68 -0
- package/dist/sources.css +1 -0
- package/dist/thread/actions/action-button.d.ts +8 -0
- package/dist/thread/actions/action-button.js +67 -0
- package/dist/thread/actions/actions.d.ts +13 -0
- package/dist/thread/actions/actions.js +192 -0
- package/dist/thread/actions/branch-switcher.d.ts +10 -0
- package/dist/thread/actions/branch-switcher.js +104 -0
- package/dist/thread/canvas/canvas.d.ts +14 -0
- package/dist/thread/canvas/canvas.js +212 -0
- package/dist/thread/canvas/version-switcher.d.ts +12 -0
- package/dist/thread/canvas/version-switcher.js +152 -0
- package/dist/thread/code/code.d.ts +10 -0
- package/dist/thread/code/code.js +195 -0
- package/dist/thread/code/copy-code-button.d.ts +6 -0
- package/dist/thread/code/copy-code-button.js +66 -0
- package/dist/thread/code/highlight.d.ts +1 -0
- package/dist/thread/code/highlight.js +40 -0
- package/dist/thread/history/history-rows.d.ts +16 -0
- package/dist/thread/history/history-rows.js +23 -0
- package/dist/thread/history/history.d.ts +16 -0
- package/dist/thread/history/history.js +179 -0
- package/dist/thread/history/row/history-row.d.ts +15 -0
- package/dist/thread/history/row/history-row.js +137 -0
- package/dist/thread/history/row/thread-item-menu.d.ts +7 -0
- package/dist/thread/history/row/thread-item-menu.js +84 -0
- package/dist/thread/history/row/thread-title-editor.d.ts +7 -0
- package/dist/thread/history/row/thread-title-editor.js +81 -0
- package/dist/thread/history/thread-groups.d.ts +8 -0
- package/dist/thread/history/thread-groups.js +52 -0
- package/dist/thread/history/virtual-history-list.d.ts +11 -0
- package/dist/thread/history/virtual-history-list.js +107 -0
- package/dist/thread/index.d.ts +8 -0
- package/dist/thread/index.js +5 -0
- package/dist/thread/starters/starters.d.ts +12 -0
- package/dist/thread/starters/starters.js +100 -0
- package/dist/thread/use-copied.d.ts +5 -0
- package/dist/thread/use-copied.js +52 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +3 -0
- package/package.json +59 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { toDate } from "../../shared/decision-summary.js";
|
|
2
|
+
export { formatDecidedAt, isoOf, toDate } from "../../shared/decision-summary.js";
|
|
3
|
+
const minuteMs = 60_000;
|
|
4
|
+
const hourMs = 60 * minuteMs;
|
|
5
|
+
const dayMs = 24 * hourMs;
|
|
6
|
+
export function formatWaiting(since, now) {
|
|
7
|
+
const waitedMs = Math.max(0, now - toDate(since).getTime());
|
|
8
|
+
if (waitedMs < minuteMs) return "just now";
|
|
9
|
+
if (waitedMs < hourMs) return `${Math.floor(waitedMs / minuteMs)} min`;
|
|
10
|
+
if (waitedMs < dayMs) return `${Math.floor(waitedMs / hourMs)} h`;
|
|
11
|
+
return `${Math.floor(waitedMs / dayMs)} d`;
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
export function useFocusOnMount(enabled) {
|
|
4
|
+
const $ = _c(3);
|
|
5
|
+
const ref = useRef(null);
|
|
6
|
+
let t0;
|
|
7
|
+
let t1;
|
|
8
|
+
if ($[0] !== enabled) {
|
|
9
|
+
t0 = () => {
|
|
10
|
+
if (enabled) {
|
|
11
|
+
ref.current?.focus({
|
|
12
|
+
preventScroll: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
t1 = [enabled];
|
|
17
|
+
$[0] = enabled;
|
|
18
|
+
$[1] = t0;
|
|
19
|
+
$[2] = t1;
|
|
20
|
+
} else {
|
|
21
|
+
t0 = $[1];
|
|
22
|
+
t1 = $[2];
|
|
23
|
+
}
|
|
24
|
+
useEffect(t0, t1);
|
|
25
|
+
return ref;
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type RaiseCapFormProps = {
|
|
2
|
+
capMicroUsd: number;
|
|
3
|
+
suggestedMicroUsd: number;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
onRaiseCap: (newCapMicroUsd: number) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function RaiseCapForm({ capMicroUsd, suggestedMicroUsd, disabled, onRaiseCap, }: RaiseCapFormProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Button, Input, Label } from "@locusgraph/components";
|
|
3
|
+
import { formatMicroUsd } from "@locusgraph/utils";
|
|
4
|
+
import { useId, useState } from "react";
|
|
5
|
+
import { dollarsToMicroUsd, microUsdToDollarsInput } from "./spend-math.js";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
function capError(next, capMicroUsd) {
|
|
8
|
+
if (next === null) return "Enter an amount in dollars.";
|
|
9
|
+
if (next <= capMicroUsd) return `The new cap must be above ${formatMicroUsd(capMicroUsd)}.`;
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
export function RaiseCapForm(t0) {
|
|
13
|
+
const $ = _c(59);
|
|
14
|
+
const {
|
|
15
|
+
capMicroUsd,
|
|
16
|
+
suggestedMicroUsd,
|
|
17
|
+
disabled: t1,
|
|
18
|
+
onRaiseCap
|
|
19
|
+
} = t0;
|
|
20
|
+
const disabled = t1 === undefined ? false : t1;
|
|
21
|
+
const inputId = useId();
|
|
22
|
+
let t2;
|
|
23
|
+
if ($[0] !== suggestedMicroUsd) {
|
|
24
|
+
t2 = () => microUsdToDollarsInput(suggestedMicroUsd);
|
|
25
|
+
$[0] = suggestedMicroUsd;
|
|
26
|
+
$[1] = t2;
|
|
27
|
+
} else {
|
|
28
|
+
t2 = $[1];
|
|
29
|
+
}
|
|
30
|
+
const [dollars, setDollars] = useState(t2);
|
|
31
|
+
const [touched, setTouched] = useState(false);
|
|
32
|
+
let T0;
|
|
33
|
+
let t10;
|
|
34
|
+
let t11;
|
|
35
|
+
let t12;
|
|
36
|
+
let t13;
|
|
37
|
+
let t14;
|
|
38
|
+
let t15;
|
|
39
|
+
let t3;
|
|
40
|
+
let t4;
|
|
41
|
+
let t5;
|
|
42
|
+
let t6;
|
|
43
|
+
let t7;
|
|
44
|
+
let t8;
|
|
45
|
+
let t9;
|
|
46
|
+
let visibleError;
|
|
47
|
+
if ($[2] !== capMicroUsd || $[3] !== disabled || $[4] !== dollars || $[5] !== inputId || $[6] !== onRaiseCap || $[7] !== touched) {
|
|
48
|
+
const next = dollarsToMicroUsd(dollars);
|
|
49
|
+
const error = capError(next, capMicroUsd);
|
|
50
|
+
visibleError = touched ? error : undefined;
|
|
51
|
+
t12 = "raise-cap-form";
|
|
52
|
+
t13 = true;
|
|
53
|
+
t14 = "flex flex-col gap-1.5 border-t pt-4";
|
|
54
|
+
t15 = event => {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
setTouched(true);
|
|
57
|
+
if (next !== null && !error) {
|
|
58
|
+
onRaiseCap(next);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
t10 = "flex flex-wrap items-center justify-between gap-x-4 gap-y-2";
|
|
62
|
+
if ($[23] !== inputId) {
|
|
63
|
+
t11 = /*#__PURE__*/_jsx(Label, {
|
|
64
|
+
htmlFor: inputId,
|
|
65
|
+
className: "text-xs font-normal text-muted-foreground",
|
|
66
|
+
children: "Or raise the cap for this run"
|
|
67
|
+
});
|
|
68
|
+
$[23] = inputId;
|
|
69
|
+
$[24] = t11;
|
|
70
|
+
} else {
|
|
71
|
+
t11 = $[24];
|
|
72
|
+
}
|
|
73
|
+
t8 = "flex flex-wrap items-center gap-2";
|
|
74
|
+
let t16;
|
|
75
|
+
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
76
|
+
t16 = /*#__PURE__*/_jsx("span", {
|
|
77
|
+
"aria-hidden": true,
|
|
78
|
+
className: "pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-sm text-muted-foreground",
|
|
79
|
+
children: "$"
|
|
80
|
+
});
|
|
81
|
+
$[25] = t16;
|
|
82
|
+
} else {
|
|
83
|
+
t16 = $[25];
|
|
84
|
+
}
|
|
85
|
+
const t17 = visibleError ? true : undefined;
|
|
86
|
+
const t18 = visibleError ? `${inputId}-error` : undefined;
|
|
87
|
+
let t19;
|
|
88
|
+
let t20;
|
|
89
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
90
|
+
t19 = event_0 => setDollars(event_0.target.value);
|
|
91
|
+
t20 = () => setTouched(true);
|
|
92
|
+
$[26] = t19;
|
|
93
|
+
$[27] = t20;
|
|
94
|
+
} else {
|
|
95
|
+
t19 = $[26];
|
|
96
|
+
t20 = $[27];
|
|
97
|
+
}
|
|
98
|
+
if ($[28] !== disabled || $[29] !== dollars || $[30] !== inputId || $[31] !== t17 || $[32] !== t18) {
|
|
99
|
+
t9 = /*#__PURE__*/_jsxs("div", {
|
|
100
|
+
className: "relative w-32",
|
|
101
|
+
children: [t16, /*#__PURE__*/_jsx(Input, {
|
|
102
|
+
id: inputId,
|
|
103
|
+
inputMode: "decimal",
|
|
104
|
+
className: "pl-6 tabular-nums",
|
|
105
|
+
value: dollars,
|
|
106
|
+
disabled: disabled,
|
|
107
|
+
"aria-invalid": t17,
|
|
108
|
+
"aria-describedby": t18,
|
|
109
|
+
onChange: t19,
|
|
110
|
+
onBlur: t20
|
|
111
|
+
})]
|
|
112
|
+
});
|
|
113
|
+
$[28] = disabled;
|
|
114
|
+
$[29] = dollars;
|
|
115
|
+
$[30] = inputId;
|
|
116
|
+
$[31] = t17;
|
|
117
|
+
$[32] = t18;
|
|
118
|
+
$[33] = t9;
|
|
119
|
+
} else {
|
|
120
|
+
t9 = $[33];
|
|
121
|
+
}
|
|
122
|
+
T0 = Button;
|
|
123
|
+
t3 = "submit";
|
|
124
|
+
t4 = "sm";
|
|
125
|
+
t5 = "outline";
|
|
126
|
+
t6 = disabled;
|
|
127
|
+
t7 = next !== null && !error ? `Raise cap to ${formatMicroUsd(next)}` : "Raise cap";
|
|
128
|
+
$[2] = capMicroUsd;
|
|
129
|
+
$[3] = disabled;
|
|
130
|
+
$[4] = dollars;
|
|
131
|
+
$[5] = inputId;
|
|
132
|
+
$[6] = onRaiseCap;
|
|
133
|
+
$[7] = touched;
|
|
134
|
+
$[8] = T0;
|
|
135
|
+
$[9] = t10;
|
|
136
|
+
$[10] = t11;
|
|
137
|
+
$[11] = t12;
|
|
138
|
+
$[12] = t13;
|
|
139
|
+
$[13] = t14;
|
|
140
|
+
$[14] = t15;
|
|
141
|
+
$[15] = t3;
|
|
142
|
+
$[16] = t4;
|
|
143
|
+
$[17] = t5;
|
|
144
|
+
$[18] = t6;
|
|
145
|
+
$[19] = t7;
|
|
146
|
+
$[20] = t8;
|
|
147
|
+
$[21] = t9;
|
|
148
|
+
$[22] = visibleError;
|
|
149
|
+
} else {
|
|
150
|
+
T0 = $[8];
|
|
151
|
+
t10 = $[9];
|
|
152
|
+
t11 = $[10];
|
|
153
|
+
t12 = $[11];
|
|
154
|
+
t13 = $[12];
|
|
155
|
+
t14 = $[13];
|
|
156
|
+
t15 = $[14];
|
|
157
|
+
t3 = $[15];
|
|
158
|
+
t4 = $[16];
|
|
159
|
+
t5 = $[17];
|
|
160
|
+
t6 = $[18];
|
|
161
|
+
t7 = $[19];
|
|
162
|
+
t8 = $[20];
|
|
163
|
+
t9 = $[21];
|
|
164
|
+
visibleError = $[22];
|
|
165
|
+
}
|
|
166
|
+
let t16;
|
|
167
|
+
if ($[34] !== T0 || $[35] !== t3 || $[36] !== t4 || $[37] !== t5 || $[38] !== t6 || $[39] !== t7) {
|
|
168
|
+
t16 = /*#__PURE__*/_jsx(T0, {
|
|
169
|
+
type: t3,
|
|
170
|
+
size: t4,
|
|
171
|
+
variant: t5,
|
|
172
|
+
disabled: t6,
|
|
173
|
+
children: t7
|
|
174
|
+
});
|
|
175
|
+
$[34] = T0;
|
|
176
|
+
$[35] = t3;
|
|
177
|
+
$[36] = t4;
|
|
178
|
+
$[37] = t5;
|
|
179
|
+
$[38] = t6;
|
|
180
|
+
$[39] = t7;
|
|
181
|
+
$[40] = t16;
|
|
182
|
+
} else {
|
|
183
|
+
t16 = $[40];
|
|
184
|
+
}
|
|
185
|
+
let t17;
|
|
186
|
+
if ($[41] !== t16 || $[42] !== t8 || $[43] !== t9) {
|
|
187
|
+
t17 = /*#__PURE__*/_jsxs("div", {
|
|
188
|
+
className: t8,
|
|
189
|
+
children: [t9, t16]
|
|
190
|
+
});
|
|
191
|
+
$[41] = t16;
|
|
192
|
+
$[42] = t8;
|
|
193
|
+
$[43] = t9;
|
|
194
|
+
$[44] = t17;
|
|
195
|
+
} else {
|
|
196
|
+
t17 = $[44];
|
|
197
|
+
}
|
|
198
|
+
let t18;
|
|
199
|
+
if ($[45] !== t10 || $[46] !== t11 || $[47] !== t17) {
|
|
200
|
+
t18 = /*#__PURE__*/_jsxs("div", {
|
|
201
|
+
className: t10,
|
|
202
|
+
children: [t11, t17]
|
|
203
|
+
});
|
|
204
|
+
$[45] = t10;
|
|
205
|
+
$[46] = t11;
|
|
206
|
+
$[47] = t17;
|
|
207
|
+
$[48] = t18;
|
|
208
|
+
} else {
|
|
209
|
+
t18 = $[48];
|
|
210
|
+
}
|
|
211
|
+
let t19;
|
|
212
|
+
if ($[49] !== inputId || $[50] !== visibleError) {
|
|
213
|
+
t19 = visibleError && /*#__PURE__*/_jsx("p", {
|
|
214
|
+
id: `${inputId}-error`,
|
|
215
|
+
className: "text-right text-xs text-destructive",
|
|
216
|
+
children: visibleError
|
|
217
|
+
});
|
|
218
|
+
$[49] = inputId;
|
|
219
|
+
$[50] = visibleError;
|
|
220
|
+
$[51] = t19;
|
|
221
|
+
} else {
|
|
222
|
+
t19 = $[51];
|
|
223
|
+
}
|
|
224
|
+
let t20;
|
|
225
|
+
if ($[52] !== t12 || $[53] !== t13 || $[54] !== t14 || $[55] !== t15 || $[56] !== t18 || $[57] !== t19) {
|
|
226
|
+
t20 = /*#__PURE__*/_jsxs("form", {
|
|
227
|
+
"data-slot": t12,
|
|
228
|
+
noValidate: t13,
|
|
229
|
+
className: t14,
|
|
230
|
+
onSubmit: t15,
|
|
231
|
+
children: [t18, t19]
|
|
232
|
+
});
|
|
233
|
+
$[52] = t12;
|
|
234
|
+
$[53] = t13;
|
|
235
|
+
$[54] = t14;
|
|
236
|
+
$[55] = t15;
|
|
237
|
+
$[56] = t18;
|
|
238
|
+
$[57] = t19;
|
|
239
|
+
$[58] = t20;
|
|
240
|
+
} else {
|
|
241
|
+
t20 = $[58];
|
|
242
|
+
}
|
|
243
|
+
return t20;
|
|
244
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ApprovalDecision } from "../types.js";
|
|
2
|
+
export type SpendGateProps = {
|
|
3
|
+
spentMicroUsd: number;
|
|
4
|
+
estimateMicroUsd: number;
|
|
5
|
+
capMicroUsd: number;
|
|
6
|
+
balanceMicroUsd: number;
|
|
7
|
+
runName?: string;
|
|
8
|
+
decision?: ApprovalDecision;
|
|
9
|
+
onAllowOnce: () => void;
|
|
10
|
+
onRaiseCap: (newCapMicroUsd: number) => void;
|
|
11
|
+
onStop: () => void;
|
|
12
|
+
onBuyCredits?: () => void;
|
|
13
|
+
autoFocus?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function SpendGate({ spentMicroUsd, estimateMicroUsd, capMicroUsd, balanceMicroUsd, runName, decision, onAllowOnce, onRaiseCap, onStop, onBuyCredits, autoFocus, className, }: SpendGateProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { CurrencyDollar as CircleDollarSignIcon } from "@carbon/icons-react";
|
|
3
|
+
import { Button, cn } from "@locusgraph/components";
|
|
4
|
+
import { formatMicroUsd } from "@locusgraph/utils";
|
|
5
|
+
import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle } from "../../shared/panel.js";
|
|
6
|
+
import { DecisionSummary } from "../shared/decision-line.js";
|
|
7
|
+
import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
|
|
8
|
+
import { RaiseCapForm } from "./raise-cap-form.js";
|
|
9
|
+
import { spendSituation, suggestedCapMicroUsd } from "./spend-math.js";
|
|
10
|
+
import { SpendMeter } from "./spend-meter.js";
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
const situationCopy = {
|
|
13
|
+
"over-cap": {
|
|
14
|
+
title: "This run would pass its cost cap",
|
|
15
|
+
body: run => `${run} paused before the next step. Allow it once, raise the cap, or stop the run.`
|
|
16
|
+
},
|
|
17
|
+
"out-of-credits": {
|
|
18
|
+
title: "Not enough credits to continue",
|
|
19
|
+
body: run => `${run} paused: the next step costs more than your prepaid balance. Add credits or stop the run.`
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const situationStatus = {
|
|
23
|
+
"over-cap": "Over cap",
|
|
24
|
+
"out-of-credits": "Out of credits"
|
|
25
|
+
};
|
|
26
|
+
export function SpendGate(t0) {
|
|
27
|
+
const $ = _c(45);
|
|
28
|
+
const {
|
|
29
|
+
spentMicroUsd,
|
|
30
|
+
estimateMicroUsd,
|
|
31
|
+
capMicroUsd,
|
|
32
|
+
balanceMicroUsd,
|
|
33
|
+
runName,
|
|
34
|
+
decision,
|
|
35
|
+
onAllowOnce,
|
|
36
|
+
onRaiseCap,
|
|
37
|
+
onStop,
|
|
38
|
+
onBuyCredits,
|
|
39
|
+
autoFocus: t1,
|
|
40
|
+
className
|
|
41
|
+
} = t0;
|
|
42
|
+
const autoFocus = t1 === undefined ? true : t1;
|
|
43
|
+
let t2;
|
|
44
|
+
if ($[0] !== balanceMicroUsd || $[1] !== estimateMicroUsd) {
|
|
45
|
+
t2 = spendSituation(balanceMicroUsd, estimateMicroUsd);
|
|
46
|
+
$[0] = balanceMicroUsd;
|
|
47
|
+
$[1] = estimateMicroUsd;
|
|
48
|
+
$[2] = t2;
|
|
49
|
+
} else {
|
|
50
|
+
t2 = $[2];
|
|
51
|
+
}
|
|
52
|
+
const situation = t2;
|
|
53
|
+
const outOfCredits = situation === "out-of-credits";
|
|
54
|
+
const projected = spentMicroUsd + estimateMicroUsd;
|
|
55
|
+
const copy = situationCopy[situation];
|
|
56
|
+
const primaryRef = useFocusOnMount(autoFocus && !decision);
|
|
57
|
+
let t3;
|
|
58
|
+
if ($[3] !== balanceMicroUsd || $[4] !== capMicroUsd || $[5] !== estimateMicroUsd || $[6] !== outOfCredits || $[7] !== spentMicroUsd) {
|
|
59
|
+
t3 = {
|
|
60
|
+
spentMicroUsd,
|
|
61
|
+
estimateMicroUsd,
|
|
62
|
+
capMicroUsd,
|
|
63
|
+
balanceMicroUsd,
|
|
64
|
+
outOfCredits
|
|
65
|
+
};
|
|
66
|
+
$[3] = balanceMicroUsd;
|
|
67
|
+
$[4] = capMicroUsd;
|
|
68
|
+
$[5] = estimateMicroUsd;
|
|
69
|
+
$[6] = outOfCredits;
|
|
70
|
+
$[7] = spentMicroUsd;
|
|
71
|
+
$[8] = t3;
|
|
72
|
+
} else {
|
|
73
|
+
t3 = $[8];
|
|
74
|
+
}
|
|
75
|
+
const meter = t3;
|
|
76
|
+
const t4 = copy.title;
|
|
77
|
+
const t5 = !decision && outOfCredits && "ring-destructive/60";
|
|
78
|
+
let t6;
|
|
79
|
+
if ($[9] !== className || $[10] !== t5) {
|
|
80
|
+
t6 = cn(t5, className);
|
|
81
|
+
$[9] = className;
|
|
82
|
+
$[10] = t5;
|
|
83
|
+
$[11] = t6;
|
|
84
|
+
} else {
|
|
85
|
+
t6 = $[11];
|
|
86
|
+
}
|
|
87
|
+
let t7;
|
|
88
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
89
|
+
t7 = /*#__PURE__*/_jsx(CircleDollarSignIcon, {
|
|
90
|
+
"aria-hidden": true
|
|
91
|
+
});
|
|
92
|
+
$[12] = t7;
|
|
93
|
+
} else {
|
|
94
|
+
t7 = $[12];
|
|
95
|
+
}
|
|
96
|
+
const t8 = decision ? decision.approved ? "Allowed" : "Stopped" : situationStatus[situation];
|
|
97
|
+
const t9 = decision ? decision.approved ? "done" : "danger" : outOfCredits ? "danger" : "waiting";
|
|
98
|
+
let t10;
|
|
99
|
+
if ($[13] !== t8 || $[14] !== t9) {
|
|
100
|
+
t10 = /*#__PURE__*/_jsx(PanelHeader, {
|
|
101
|
+
icon: t7,
|
|
102
|
+
eyebrow: "Spend approval",
|
|
103
|
+
status: t8,
|
|
104
|
+
tone: t9
|
|
105
|
+
});
|
|
106
|
+
$[13] = t8;
|
|
107
|
+
$[14] = t9;
|
|
108
|
+
$[15] = t10;
|
|
109
|
+
} else {
|
|
110
|
+
t10 = $[15];
|
|
111
|
+
}
|
|
112
|
+
const t11 = decision && "text-muted-foreground";
|
|
113
|
+
let t12;
|
|
114
|
+
if ($[16] !== t11) {
|
|
115
|
+
t12 = cn(t11);
|
|
116
|
+
$[16] = t11;
|
|
117
|
+
$[17] = t12;
|
|
118
|
+
} else {
|
|
119
|
+
t12 = $[17];
|
|
120
|
+
}
|
|
121
|
+
let t13;
|
|
122
|
+
if ($[18] !== copy.title || $[19] !== t12) {
|
|
123
|
+
t13 = /*#__PURE__*/_jsx(PanelTitle, {
|
|
124
|
+
className: t12,
|
|
125
|
+
children: copy.title
|
|
126
|
+
});
|
|
127
|
+
$[18] = copy.title;
|
|
128
|
+
$[19] = t12;
|
|
129
|
+
$[20] = t13;
|
|
130
|
+
} else {
|
|
131
|
+
t13 = $[20];
|
|
132
|
+
}
|
|
133
|
+
let t14;
|
|
134
|
+
if ($[21] !== capMicroUsd || $[22] !== copy || $[23] !== decision || $[24] !== estimateMicroUsd || $[25] !== meter || $[26] !== onAllowOnce || $[27] !== onBuyCredits || $[28] !== onRaiseCap || $[29] !== onStop || $[30] !== outOfCredits || $[31] !== primaryRef || $[32] !== projected || $[33] !== runName) {
|
|
135
|
+
t14 = decision ? /*#__PURE__*/_jsxs(PanelBody, {
|
|
136
|
+
className: "pt-3",
|
|
137
|
+
children: [/*#__PURE__*/_jsx(DecisionSummary, {
|
|
138
|
+
decision: decision,
|
|
139
|
+
approvedVerb: "Allowed",
|
|
140
|
+
deniedVerb: "Stopped",
|
|
141
|
+
result: decision.approved ? `Allowed ${formatMicroUsd(estimateMicroUsd)} once` : `${runName ?? "The run"} stopped`
|
|
142
|
+
}), /*#__PURE__*/_jsx(SpendMeter, {
|
|
143
|
+
...meter,
|
|
144
|
+
muted: true
|
|
145
|
+
})]
|
|
146
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
147
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
148
|
+
className: "px-5 pt-1 text-sm text-muted-foreground",
|
|
149
|
+
children: copy.body(runName ?? "The agent")
|
|
150
|
+
}), /*#__PURE__*/_jsxs(PanelBody, {
|
|
151
|
+
className: "gap-5",
|
|
152
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
153
|
+
className: "flex flex-col gap-0.5",
|
|
154
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
155
|
+
className: "text-2xl font-semibold tracking-tight tabular-nums",
|
|
156
|
+
children: formatMicroUsd(estimateMicroUsd)
|
|
157
|
+
}), /*#__PURE__*/_jsxs("p", {
|
|
158
|
+
className: "text-xs text-muted-foreground",
|
|
159
|
+
children: ["Next step, estimated. The run would reach", " ", /*#__PURE__*/_jsx("span", {
|
|
160
|
+
className: "tabular-nums",
|
|
161
|
+
children: formatMicroUsd(projected)
|
|
162
|
+
}), "."]
|
|
163
|
+
})]
|
|
164
|
+
}), /*#__PURE__*/_jsx(SpendMeter, {
|
|
165
|
+
...meter
|
|
166
|
+
}), !outOfCredits && /*#__PURE__*/_jsx(RaiseCapForm, {
|
|
167
|
+
capMicroUsd: capMicroUsd,
|
|
168
|
+
suggestedMicroUsd: suggestedCapMicroUsd(projected, capMicroUsd),
|
|
169
|
+
onRaiseCap: onRaiseCap
|
|
170
|
+
})]
|
|
171
|
+
}), /*#__PURE__*/_jsxs(PanelFooter, {
|
|
172
|
+
className: "justify-between",
|
|
173
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
174
|
+
className: "hidden font-mono text-[11px] text-muted-foreground sm:inline",
|
|
175
|
+
children: "The run is paused"
|
|
176
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
177
|
+
className: "flex flex-wrap gap-2",
|
|
178
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
179
|
+
ref: outOfCredits && !onBuyCredits ? primaryRef : undefined,
|
|
180
|
+
type: "button",
|
|
181
|
+
size: "sm",
|
|
182
|
+
variant: outOfCredits && !onBuyCredits ? "destructive" : "ghost",
|
|
183
|
+
onClick: onStop,
|
|
184
|
+
children: "Stop the run"
|
|
185
|
+
}), outOfCredits ? onBuyCredits && /*#__PURE__*/_jsx(Button, {
|
|
186
|
+
ref: primaryRef,
|
|
187
|
+
type: "button",
|
|
188
|
+
size: "sm",
|
|
189
|
+
onClick: onBuyCredits,
|
|
190
|
+
children: "Buy credits"
|
|
191
|
+
}) : /*#__PURE__*/_jsxs(Button, {
|
|
192
|
+
ref: primaryRef,
|
|
193
|
+
type: "button",
|
|
194
|
+
size: "sm",
|
|
195
|
+
onClick: onAllowOnce,
|
|
196
|
+
children: ["Allow ", formatMicroUsd(estimateMicroUsd), " once"]
|
|
197
|
+
})]
|
|
198
|
+
})]
|
|
199
|
+
})]
|
|
200
|
+
});
|
|
201
|
+
$[21] = capMicroUsd;
|
|
202
|
+
$[22] = copy;
|
|
203
|
+
$[23] = decision;
|
|
204
|
+
$[24] = estimateMicroUsd;
|
|
205
|
+
$[25] = meter;
|
|
206
|
+
$[26] = onAllowOnce;
|
|
207
|
+
$[27] = onBuyCredits;
|
|
208
|
+
$[28] = onRaiseCap;
|
|
209
|
+
$[29] = onStop;
|
|
210
|
+
$[30] = outOfCredits;
|
|
211
|
+
$[31] = primaryRef;
|
|
212
|
+
$[32] = projected;
|
|
213
|
+
$[33] = runName;
|
|
214
|
+
$[34] = t14;
|
|
215
|
+
} else {
|
|
216
|
+
t14 = $[34];
|
|
217
|
+
}
|
|
218
|
+
const t15 = decision ? decision.approved ? "Spend allowed" : "Run stopped" : copy.title;
|
|
219
|
+
let t16;
|
|
220
|
+
if ($[35] !== t15) {
|
|
221
|
+
t16 = /*#__PURE__*/_jsx(LiveStatus, {
|
|
222
|
+
message: t15
|
|
223
|
+
});
|
|
224
|
+
$[35] = t15;
|
|
225
|
+
$[36] = t16;
|
|
226
|
+
} else {
|
|
227
|
+
t16 = $[36];
|
|
228
|
+
}
|
|
229
|
+
let t17;
|
|
230
|
+
if ($[37] !== copy.title || $[38] !== situation || $[39] !== t10 || $[40] !== t13 || $[41] !== t14 || $[42] !== t16 || $[43] !== t6) {
|
|
231
|
+
t17 = /*#__PURE__*/_jsxs(ApprovalPanel, {
|
|
232
|
+
"data-slot": "spend-gate",
|
|
233
|
+
"data-situation": situation,
|
|
234
|
+
"aria-label": t4,
|
|
235
|
+
className: t6,
|
|
236
|
+
children: [t10, t13, t14, t16]
|
|
237
|
+
});
|
|
238
|
+
$[37] = copy.title;
|
|
239
|
+
$[38] = situation;
|
|
240
|
+
$[39] = t10;
|
|
241
|
+
$[40] = t13;
|
|
242
|
+
$[41] = t14;
|
|
243
|
+
$[42] = t16;
|
|
244
|
+
$[43] = t6;
|
|
245
|
+
$[44] = t17;
|
|
246
|
+
} else {
|
|
247
|
+
t17 = $[44];
|
|
248
|
+
}
|
|
249
|
+
return t17;
|
|
250
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type SpendSituation = "over-cap" | "out-of-credits";
|
|
2
|
+
export declare function spendSituation(balanceMicroUsd: number, estimateMicroUsd: number): SpendSituation;
|
|
3
|
+
export declare function suggestedCapMicroUsd(projectedMicroUsd: number, capMicroUsd: number): number;
|
|
4
|
+
export declare function dollarsToMicroUsd(dollars: string): number | null;
|
|
5
|
+
export declare function microUsdToDollarsInput(microUsd: number): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const microUsdPerDollar = 1_000_000;
|
|
2
|
+
const microUsdPerCent = 10_000;
|
|
3
|
+
export function spendSituation(balanceMicroUsd, estimateMicroUsd) {
|
|
4
|
+
return balanceMicroUsd <= 0 || balanceMicroUsd < estimateMicroUsd ? "out-of-credits" : "over-cap";
|
|
5
|
+
}
|
|
6
|
+
export function suggestedCapMicroUsd(projectedMicroUsd, capMicroUsd) {
|
|
7
|
+
const target = Math.max(projectedMicroUsd, capMicroUsd + microUsdPerCent);
|
|
8
|
+
return Math.ceil(target / microUsdPerDollar) * microUsdPerDollar;
|
|
9
|
+
}
|
|
10
|
+
export function dollarsToMicroUsd(dollars) {
|
|
11
|
+
const value = Number(dollars.trim());
|
|
12
|
+
if (dollars.trim() === "" || !Number.isFinite(value)) return null;
|
|
13
|
+
return Math.round(value * microUsdPerDollar);
|
|
14
|
+
}
|
|
15
|
+
export function microUsdToDollarsInput(microUsd) {
|
|
16
|
+
return (microUsd / microUsdPerDollar).toFixed(2);
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type SpendMeterProps = {
|
|
2
|
+
spentMicroUsd: number;
|
|
3
|
+
estimateMicroUsd: number;
|
|
4
|
+
capMicroUsd: number;
|
|
5
|
+
balanceMicroUsd: number;
|
|
6
|
+
outOfCredits: boolean;
|
|
7
|
+
muted?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function SpendMeter(props: SpendMeterProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|