@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,333 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { cn, HoverCard, HoverCardContent, HoverCardTrigger } from "@locusgraph/components";
|
|
3
|
+
import { formatCount, nearLimitPercent, quotaPercent } from "@locusgraph/utils";
|
|
4
|
+
import { ContextBreakdown } from "./shared/context-breakdown.js";
|
|
5
|
+
import { MeterBar, MeterRing } from "./shared/meter-marks.js";
|
|
6
|
+
import { formatTokensShort } from "./shared/usage-totals.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
+
export function contextStatus(usedTokens, limitTokens) {
|
|
9
|
+
if (usedTokens >= limitTokens) return "full";
|
|
10
|
+
const percent = quotaPercent({
|
|
11
|
+
used: usedTokens,
|
|
12
|
+
included: limitTokens
|
|
13
|
+
});
|
|
14
|
+
return percent >= nearLimitPercent ? "near" : "ok";
|
|
15
|
+
}
|
|
16
|
+
const statusTone = {
|
|
17
|
+
ok: "text-muted-foreground",
|
|
18
|
+
near: "text-warn",
|
|
19
|
+
full: "text-destructive"
|
|
20
|
+
};
|
|
21
|
+
function RingContent(t0) {
|
|
22
|
+
const $ = _c(8);
|
|
23
|
+
const {
|
|
24
|
+
percent,
|
|
25
|
+
status
|
|
26
|
+
} = t0;
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[0] !== percent || $[1] !== status) {
|
|
29
|
+
t1 = /*#__PURE__*/_jsx(MeterRing, {
|
|
30
|
+
percent: percent,
|
|
31
|
+
status: status
|
|
32
|
+
});
|
|
33
|
+
$[0] = percent;
|
|
34
|
+
$[1] = status;
|
|
35
|
+
$[2] = t1;
|
|
36
|
+
} else {
|
|
37
|
+
t1 = $[2];
|
|
38
|
+
}
|
|
39
|
+
let t2;
|
|
40
|
+
if ($[3] !== percent) {
|
|
41
|
+
t2 = /*#__PURE__*/_jsxs("span", {
|
|
42
|
+
className: "font-mono text-[11px] tabular-nums",
|
|
43
|
+
children: [percent, "%"]
|
|
44
|
+
});
|
|
45
|
+
$[3] = percent;
|
|
46
|
+
$[4] = t2;
|
|
47
|
+
} else {
|
|
48
|
+
t2 = $[4];
|
|
49
|
+
}
|
|
50
|
+
let t3;
|
|
51
|
+
if ($[5] !== t1 || $[6] !== t2) {
|
|
52
|
+
t3 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
53
|
+
children: [t1, t2]
|
|
54
|
+
});
|
|
55
|
+
$[5] = t1;
|
|
56
|
+
$[6] = t2;
|
|
57
|
+
$[7] = t3;
|
|
58
|
+
} else {
|
|
59
|
+
t3 = $[7];
|
|
60
|
+
}
|
|
61
|
+
return t3;
|
|
62
|
+
}
|
|
63
|
+
function BarContent(t0) {
|
|
64
|
+
const $ = _c(22);
|
|
65
|
+
const {
|
|
66
|
+
label,
|
|
67
|
+
usedTokens,
|
|
68
|
+
limitTokens,
|
|
69
|
+
percent,
|
|
70
|
+
status
|
|
71
|
+
} = t0;
|
|
72
|
+
let t1;
|
|
73
|
+
if ($[0] !== label) {
|
|
74
|
+
t1 = /*#__PURE__*/_jsx("span", {
|
|
75
|
+
className: "eyebrow",
|
|
76
|
+
children: label
|
|
77
|
+
});
|
|
78
|
+
$[0] = label;
|
|
79
|
+
$[1] = t1;
|
|
80
|
+
} else {
|
|
81
|
+
t1 = $[1];
|
|
82
|
+
}
|
|
83
|
+
const t2 = status === "ok" && "text-foreground";
|
|
84
|
+
let t3;
|
|
85
|
+
if ($[2] !== t2) {
|
|
86
|
+
t3 = cn(t2);
|
|
87
|
+
$[2] = t2;
|
|
88
|
+
$[3] = t3;
|
|
89
|
+
} else {
|
|
90
|
+
t3 = $[3];
|
|
91
|
+
}
|
|
92
|
+
let t4;
|
|
93
|
+
if ($[4] !== usedTokens) {
|
|
94
|
+
t4 = formatTokensShort(usedTokens);
|
|
95
|
+
$[4] = usedTokens;
|
|
96
|
+
$[5] = t4;
|
|
97
|
+
} else {
|
|
98
|
+
t4 = $[5];
|
|
99
|
+
}
|
|
100
|
+
let t5;
|
|
101
|
+
if ($[6] !== limitTokens) {
|
|
102
|
+
t5 = formatTokensShort(limitTokens);
|
|
103
|
+
$[6] = limitTokens;
|
|
104
|
+
$[7] = t5;
|
|
105
|
+
} else {
|
|
106
|
+
t5 = $[7];
|
|
107
|
+
}
|
|
108
|
+
let t6;
|
|
109
|
+
if ($[8] !== percent || $[9] !== t3 || $[10] !== t4 || $[11] !== t5) {
|
|
110
|
+
t6 = /*#__PURE__*/_jsxs("span", {
|
|
111
|
+
className: t3,
|
|
112
|
+
children: [percent, "% \xB7 ", t4, " / ", t5]
|
|
113
|
+
});
|
|
114
|
+
$[8] = percent;
|
|
115
|
+
$[9] = t3;
|
|
116
|
+
$[10] = t4;
|
|
117
|
+
$[11] = t5;
|
|
118
|
+
$[12] = t6;
|
|
119
|
+
} else {
|
|
120
|
+
t6 = $[12];
|
|
121
|
+
}
|
|
122
|
+
let t7;
|
|
123
|
+
if ($[13] !== t1 || $[14] !== t6) {
|
|
124
|
+
t7 = /*#__PURE__*/_jsxs("span", {
|
|
125
|
+
className: "flex items-baseline justify-between gap-4 font-mono text-[11px] tabular-nums",
|
|
126
|
+
children: [t1, t6]
|
|
127
|
+
});
|
|
128
|
+
$[13] = t1;
|
|
129
|
+
$[14] = t6;
|
|
130
|
+
$[15] = t7;
|
|
131
|
+
} else {
|
|
132
|
+
t7 = $[15];
|
|
133
|
+
}
|
|
134
|
+
let t8;
|
|
135
|
+
if ($[16] !== percent || $[17] !== status) {
|
|
136
|
+
t8 = /*#__PURE__*/_jsx(MeterBar, {
|
|
137
|
+
percent: percent,
|
|
138
|
+
status: status
|
|
139
|
+
});
|
|
140
|
+
$[16] = percent;
|
|
141
|
+
$[17] = status;
|
|
142
|
+
$[18] = t8;
|
|
143
|
+
} else {
|
|
144
|
+
t8 = $[18];
|
|
145
|
+
}
|
|
146
|
+
let t9;
|
|
147
|
+
if ($[19] !== t7 || $[20] !== t8) {
|
|
148
|
+
t9 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
149
|
+
children: [t7, t8]
|
|
150
|
+
});
|
|
151
|
+
$[19] = t7;
|
|
152
|
+
$[20] = t8;
|
|
153
|
+
$[21] = t9;
|
|
154
|
+
} else {
|
|
155
|
+
t9 = $[21];
|
|
156
|
+
}
|
|
157
|
+
return t9;
|
|
158
|
+
}
|
|
159
|
+
export function Context(t0) {
|
|
160
|
+
const $ = _c(43);
|
|
161
|
+
const {
|
|
162
|
+
usedTokens,
|
|
163
|
+
limitTokens,
|
|
164
|
+
breakdown,
|
|
165
|
+
variant: t1,
|
|
166
|
+
label: t2,
|
|
167
|
+
className
|
|
168
|
+
} = t0;
|
|
169
|
+
const variant = t1 === undefined ? "bar" : t1;
|
|
170
|
+
const label = t2 === undefined ? "Context" : t2;
|
|
171
|
+
let t3;
|
|
172
|
+
if ($[0] !== limitTokens || $[1] !== usedTokens) {
|
|
173
|
+
t3 = quotaPercent({
|
|
174
|
+
used: usedTokens,
|
|
175
|
+
included: limitTokens
|
|
176
|
+
});
|
|
177
|
+
$[0] = limitTokens;
|
|
178
|
+
$[1] = usedTokens;
|
|
179
|
+
$[2] = t3;
|
|
180
|
+
} else {
|
|
181
|
+
t3 = $[2];
|
|
182
|
+
}
|
|
183
|
+
const percent = t3;
|
|
184
|
+
let t4;
|
|
185
|
+
if ($[3] !== limitTokens || $[4] !== usedTokens) {
|
|
186
|
+
t4 = contextStatus(usedTokens, limitTokens);
|
|
187
|
+
$[3] = limitTokens;
|
|
188
|
+
$[4] = usedTokens;
|
|
189
|
+
$[5] = t4;
|
|
190
|
+
} else {
|
|
191
|
+
t4 = $[5];
|
|
192
|
+
}
|
|
193
|
+
const status = t4;
|
|
194
|
+
let t5;
|
|
195
|
+
if ($[6] !== usedTokens) {
|
|
196
|
+
t5 = formatCount(usedTokens);
|
|
197
|
+
$[6] = usedTokens;
|
|
198
|
+
$[7] = t5;
|
|
199
|
+
} else {
|
|
200
|
+
t5 = $[7];
|
|
201
|
+
}
|
|
202
|
+
let t6;
|
|
203
|
+
if ($[8] !== limitTokens) {
|
|
204
|
+
t6 = formatCount(limitTokens);
|
|
205
|
+
$[8] = limitTokens;
|
|
206
|
+
$[9] = t6;
|
|
207
|
+
} else {
|
|
208
|
+
t6 = $[9];
|
|
209
|
+
}
|
|
210
|
+
const summary = `${t5} of ${t6} tokens`;
|
|
211
|
+
const hasBreakdown = breakdown !== undefined && breakdown.length > 0;
|
|
212
|
+
const t7 = `${label} window`;
|
|
213
|
+
const t8 = `${percent}%, ${summary}`;
|
|
214
|
+
const t9 = hasBreakdown ? 0 : undefined;
|
|
215
|
+
const t10 = statusTone[status];
|
|
216
|
+
const t11 = variant === "ring" ? "inline-flex h-6 items-center gap-1.5 rounded-full px-2 transition-colors duration-150 motion-reduce:transition-none" : "flex w-full flex-col gap-2";
|
|
217
|
+
const t12 = variant === "ring" && hasBreakdown && "cursor-default hover:bg-accent";
|
|
218
|
+
let t13;
|
|
219
|
+
if ($[10] !== className || $[11] !== t10 || $[12] !== t11 || $[13] !== t12) {
|
|
220
|
+
t13 = cn("outline-none focus-visible:ring-2 focus-visible:ring-ring/70", t10, t11, t12, className);
|
|
221
|
+
$[10] = className;
|
|
222
|
+
$[11] = t10;
|
|
223
|
+
$[12] = t11;
|
|
224
|
+
$[13] = t12;
|
|
225
|
+
$[14] = t13;
|
|
226
|
+
} else {
|
|
227
|
+
t13 = $[14];
|
|
228
|
+
}
|
|
229
|
+
let t14;
|
|
230
|
+
if ($[15] !== label || $[16] !== limitTokens || $[17] !== percent || $[18] !== status || $[19] !== usedTokens || $[20] !== variant) {
|
|
231
|
+
t14 = variant === "ring" ? /*#__PURE__*/_jsx(RingContent, {
|
|
232
|
+
percent: percent,
|
|
233
|
+
status: status
|
|
234
|
+
}) : /*#__PURE__*/_jsx(BarContent, {
|
|
235
|
+
label: label,
|
|
236
|
+
usedTokens: usedTokens,
|
|
237
|
+
limitTokens: limitTokens,
|
|
238
|
+
percent: percent,
|
|
239
|
+
status: status
|
|
240
|
+
});
|
|
241
|
+
$[15] = label;
|
|
242
|
+
$[16] = limitTokens;
|
|
243
|
+
$[17] = percent;
|
|
244
|
+
$[18] = status;
|
|
245
|
+
$[19] = usedTokens;
|
|
246
|
+
$[20] = variant;
|
|
247
|
+
$[21] = t14;
|
|
248
|
+
} else {
|
|
249
|
+
t14 = $[21];
|
|
250
|
+
}
|
|
251
|
+
let t15;
|
|
252
|
+
if ($[22] !== percent || $[23] !== status || $[24] !== t13 || $[25] !== t14 || $[26] !== t7 || $[27] !== t8 || $[28] !== t9 || $[29] !== variant) {
|
|
253
|
+
t15 = /*#__PURE__*/_jsx("div", {
|
|
254
|
+
"data-slot": "context",
|
|
255
|
+
"data-status": status,
|
|
256
|
+
"data-variant": variant,
|
|
257
|
+
role: "meter",
|
|
258
|
+
"aria-label": t7,
|
|
259
|
+
"aria-valuemin": 0,
|
|
260
|
+
"aria-valuemax": 100,
|
|
261
|
+
"aria-valuenow": percent,
|
|
262
|
+
"aria-valuetext": t8,
|
|
263
|
+
tabIndex: t9,
|
|
264
|
+
className: t13,
|
|
265
|
+
children: t14
|
|
266
|
+
});
|
|
267
|
+
$[22] = percent;
|
|
268
|
+
$[23] = status;
|
|
269
|
+
$[24] = t13;
|
|
270
|
+
$[25] = t14;
|
|
271
|
+
$[26] = t7;
|
|
272
|
+
$[27] = t8;
|
|
273
|
+
$[28] = t9;
|
|
274
|
+
$[29] = variant;
|
|
275
|
+
$[30] = t15;
|
|
276
|
+
} else {
|
|
277
|
+
t15 = $[30];
|
|
278
|
+
}
|
|
279
|
+
const meter = t15;
|
|
280
|
+
if (!hasBreakdown) {
|
|
281
|
+
return meter;
|
|
282
|
+
}
|
|
283
|
+
let t16;
|
|
284
|
+
if ($[31] !== meter) {
|
|
285
|
+
t16 = /*#__PURE__*/_jsx(HoverCardTrigger, {
|
|
286
|
+
asChild: true,
|
|
287
|
+
children: meter
|
|
288
|
+
});
|
|
289
|
+
$[31] = meter;
|
|
290
|
+
$[32] = t16;
|
|
291
|
+
} else {
|
|
292
|
+
t16 = $[32];
|
|
293
|
+
}
|
|
294
|
+
let t17;
|
|
295
|
+
if ($[33] !== breakdown || $[34] !== label || $[35] !== limitTokens || $[36] !== percent || $[37] !== status || $[38] !== usedTokens) {
|
|
296
|
+
t17 = /*#__PURE__*/_jsx(HoverCardContent, {
|
|
297
|
+
align: "end",
|
|
298
|
+
sideOffset: 6,
|
|
299
|
+
className: "w-72 rounded-none border-0 bg-popover p-0 shadow-overlay ring-1 ring-border",
|
|
300
|
+
children: /*#__PURE__*/_jsx(ContextBreakdown, {
|
|
301
|
+
label: label,
|
|
302
|
+
usedTokens: usedTokens,
|
|
303
|
+
limitTokens: limitTokens,
|
|
304
|
+
percent: percent,
|
|
305
|
+
status: status,
|
|
306
|
+
breakdown: breakdown
|
|
307
|
+
})
|
|
308
|
+
});
|
|
309
|
+
$[33] = breakdown;
|
|
310
|
+
$[34] = label;
|
|
311
|
+
$[35] = limitTokens;
|
|
312
|
+
$[36] = percent;
|
|
313
|
+
$[37] = status;
|
|
314
|
+
$[38] = usedTokens;
|
|
315
|
+
$[39] = t17;
|
|
316
|
+
} else {
|
|
317
|
+
t17 = $[39];
|
|
318
|
+
}
|
|
319
|
+
let t18;
|
|
320
|
+
if ($[40] !== t16 || $[41] !== t17) {
|
|
321
|
+
t18 = /*#__PURE__*/_jsxs(HoverCard, {
|
|
322
|
+
openDelay: 100,
|
|
323
|
+
closeDelay: 100,
|
|
324
|
+
children: [t16, t17]
|
|
325
|
+
});
|
|
326
|
+
$[40] = t16;
|
|
327
|
+
$[41] = t17;
|
|
328
|
+
$[42] = t18;
|
|
329
|
+
} else {
|
|
330
|
+
t18 = $[42];
|
|
331
|
+
}
|
|
332
|
+
return t18;
|
|
333
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CostStep } from "./shared/step-cost-row.js";
|
|
2
|
+
export type { CostStep, CostStepStatus } from "./shared/step-cost-row.js";
|
|
3
|
+
export type CostStepsProps = {
|
|
4
|
+
steps: CostStep[];
|
|
5
|
+
label?: string;
|
|
6
|
+
emptyText?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function stepCostTotals(steps: CostStep[]): {
|
|
10
|
+
inputTokens: number;
|
|
11
|
+
outputTokens: number;
|
|
12
|
+
costMicroUsd: number;
|
|
13
|
+
failedAttempts: number;
|
|
14
|
+
wastedMicroUsd: number;
|
|
15
|
+
durationMs: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function CostSteps({ steps, label, emptyText, className, }: CostStepsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Roadmap as ChartNoAxesGanttIcon } from "@carbon/icons-react";
|
|
3
|
+
import { formatCount, formatMicroUsd, pluralize } from "@locusgraph/utils";
|
|
4
|
+
import { ApprovalPanel, PanelHeader } from "../shared/panel.js";
|
|
5
|
+
import { PanelEmpty } from "../shared/panel-empty.js";
|
|
6
|
+
import { isWastedStep, StepCostRow } from "./shared/step-cost-row.js";
|
|
7
|
+
import { formatDuration, sumUsage } from "./shared/usage-totals.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
export function stepCostTotals(steps) {
|
|
10
|
+
const totals = sumUsage(steps.map(step => step.usage));
|
|
11
|
+
const wastedMicroUsd = steps.filter(isWastedStep).reduce((sum, step) => sum + step.usage.costMicroUsd, 0);
|
|
12
|
+
const durationMs = steps.reduce((sum, step) => sum + (step.durationMs ?? 0), 0);
|
|
13
|
+
return {
|
|
14
|
+
...totals,
|
|
15
|
+
wastedMicroUsd,
|
|
16
|
+
durationMs
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function Totals(t0) {
|
|
20
|
+
const $ = _c(22);
|
|
21
|
+
const {
|
|
22
|
+
totals
|
|
23
|
+
} = t0;
|
|
24
|
+
let t1;
|
|
25
|
+
if ($[0] !== totals.costMicroUsd) {
|
|
26
|
+
t1 = formatMicroUsd(totals.costMicroUsd);
|
|
27
|
+
$[0] = totals.costMicroUsd;
|
|
28
|
+
$[1] = t1;
|
|
29
|
+
} else {
|
|
30
|
+
t1 = $[1];
|
|
31
|
+
}
|
|
32
|
+
let t2;
|
|
33
|
+
if ($[2] !== t1) {
|
|
34
|
+
t2 = /*#__PURE__*/_jsx("span", {
|
|
35
|
+
className: "text-2xl font-semibold tracking-tight tabular-nums",
|
|
36
|
+
children: t1
|
|
37
|
+
});
|
|
38
|
+
$[2] = t1;
|
|
39
|
+
$[3] = t2;
|
|
40
|
+
} else {
|
|
41
|
+
t2 = $[3];
|
|
42
|
+
}
|
|
43
|
+
let t3;
|
|
44
|
+
if ($[4] !== totals.inputTokens) {
|
|
45
|
+
t3 = formatCount(totals.inputTokens);
|
|
46
|
+
$[4] = totals.inputTokens;
|
|
47
|
+
$[5] = t3;
|
|
48
|
+
} else {
|
|
49
|
+
t3 = $[5];
|
|
50
|
+
}
|
|
51
|
+
let t4;
|
|
52
|
+
if ($[6] !== totals.outputTokens) {
|
|
53
|
+
t4 = formatCount(totals.outputTokens);
|
|
54
|
+
$[6] = totals.outputTokens;
|
|
55
|
+
$[7] = t4;
|
|
56
|
+
} else {
|
|
57
|
+
t4 = $[7];
|
|
58
|
+
}
|
|
59
|
+
let t5;
|
|
60
|
+
if ($[8] !== totals.durationMs) {
|
|
61
|
+
t5 = totals.durationMs > 0 && ` · ${formatDuration(totals.durationMs)}`;
|
|
62
|
+
$[8] = totals.durationMs;
|
|
63
|
+
$[9] = t5;
|
|
64
|
+
} else {
|
|
65
|
+
t5 = $[9];
|
|
66
|
+
}
|
|
67
|
+
let t6;
|
|
68
|
+
if ($[10] !== t3 || $[11] !== t4 || $[12] !== t5) {
|
|
69
|
+
t6 = /*#__PURE__*/_jsxs("span", {
|
|
70
|
+
children: [t3, " in \xB7 ", t4, " out", t5]
|
|
71
|
+
});
|
|
72
|
+
$[10] = t3;
|
|
73
|
+
$[11] = t4;
|
|
74
|
+
$[12] = t5;
|
|
75
|
+
$[13] = t6;
|
|
76
|
+
} else {
|
|
77
|
+
t6 = $[13];
|
|
78
|
+
}
|
|
79
|
+
let t7;
|
|
80
|
+
if ($[14] !== totals.wastedMicroUsd) {
|
|
81
|
+
t7 = totals.wastedMicroUsd > 0 && /*#__PURE__*/_jsxs("span", {
|
|
82
|
+
className: "text-destructive",
|
|
83
|
+
children: ["Wasted on failures ", formatMicroUsd(totals.wastedMicroUsd)]
|
|
84
|
+
});
|
|
85
|
+
$[14] = totals.wastedMicroUsd;
|
|
86
|
+
$[15] = t7;
|
|
87
|
+
} else {
|
|
88
|
+
t7 = $[15];
|
|
89
|
+
}
|
|
90
|
+
let t8;
|
|
91
|
+
if ($[16] !== t6 || $[17] !== t7) {
|
|
92
|
+
t8 = /*#__PURE__*/_jsxs("span", {
|
|
93
|
+
className: "flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground tabular-nums",
|
|
94
|
+
children: [t6, t7]
|
|
95
|
+
});
|
|
96
|
+
$[16] = t6;
|
|
97
|
+
$[17] = t7;
|
|
98
|
+
$[18] = t8;
|
|
99
|
+
} else {
|
|
100
|
+
t8 = $[18];
|
|
101
|
+
}
|
|
102
|
+
let t9;
|
|
103
|
+
if ($[19] !== t2 || $[20] !== t8) {
|
|
104
|
+
t9 = /*#__PURE__*/_jsxs("div", {
|
|
105
|
+
"data-slot": "step-cost-totals",
|
|
106
|
+
className: "flex flex-col gap-1 px-5 pt-2 pb-4",
|
|
107
|
+
children: [t2, t8]
|
|
108
|
+
});
|
|
109
|
+
$[19] = t2;
|
|
110
|
+
$[20] = t8;
|
|
111
|
+
$[21] = t9;
|
|
112
|
+
} else {
|
|
113
|
+
t9 = $[21];
|
|
114
|
+
}
|
|
115
|
+
return t9;
|
|
116
|
+
}
|
|
117
|
+
export function CostSteps(t0) {
|
|
118
|
+
const $ = _c(21);
|
|
119
|
+
const {
|
|
120
|
+
steps,
|
|
121
|
+
label: t1,
|
|
122
|
+
emptyText: t2,
|
|
123
|
+
className
|
|
124
|
+
} = t0;
|
|
125
|
+
const label = t1 === undefined ? "Cost by step" : t1;
|
|
126
|
+
const emptyText = t2 === undefined ? "No steps have run yet." : t2;
|
|
127
|
+
let t3;
|
|
128
|
+
if ($[0] !== steps) {
|
|
129
|
+
t3 = stepCostTotals(steps);
|
|
130
|
+
$[0] = steps;
|
|
131
|
+
$[1] = t3;
|
|
132
|
+
} else {
|
|
133
|
+
t3 = $[1];
|
|
134
|
+
}
|
|
135
|
+
const totals = t3;
|
|
136
|
+
let t4;
|
|
137
|
+
if ($[2] !== steps) {
|
|
138
|
+
t4 = Math.max(0, ...steps.map(_temp));
|
|
139
|
+
$[2] = steps;
|
|
140
|
+
$[3] = t4;
|
|
141
|
+
} else {
|
|
142
|
+
t4 = $[3];
|
|
143
|
+
}
|
|
144
|
+
const maxCost = t4;
|
|
145
|
+
const running = steps.some(_temp2);
|
|
146
|
+
let t5;
|
|
147
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
148
|
+
t5 = /*#__PURE__*/_jsx(ChartNoAxesGanttIcon, {
|
|
149
|
+
"aria-hidden": true
|
|
150
|
+
});
|
|
151
|
+
$[4] = t5;
|
|
152
|
+
} else {
|
|
153
|
+
t5 = $[4];
|
|
154
|
+
}
|
|
155
|
+
let t6;
|
|
156
|
+
if ($[5] !== steps.length) {
|
|
157
|
+
t6 = steps.length > 0 ? pluralize(steps.length, "step") : undefined;
|
|
158
|
+
$[5] = steps.length;
|
|
159
|
+
$[6] = t6;
|
|
160
|
+
} else {
|
|
161
|
+
t6 = $[6];
|
|
162
|
+
}
|
|
163
|
+
const t7 = running ? "Running" : undefined;
|
|
164
|
+
let t8;
|
|
165
|
+
if ($[7] !== label || $[8] !== t6 || $[9] !== t7) {
|
|
166
|
+
t8 = /*#__PURE__*/_jsx(PanelHeader, {
|
|
167
|
+
icon: t5,
|
|
168
|
+
eyebrow: label,
|
|
169
|
+
aside: t6,
|
|
170
|
+
status: t7,
|
|
171
|
+
tone: "running"
|
|
172
|
+
});
|
|
173
|
+
$[7] = label;
|
|
174
|
+
$[8] = t6;
|
|
175
|
+
$[9] = t7;
|
|
176
|
+
$[10] = t8;
|
|
177
|
+
} else {
|
|
178
|
+
t8 = $[10];
|
|
179
|
+
}
|
|
180
|
+
let t9;
|
|
181
|
+
if ($[11] !== emptyText || $[12] !== maxCost || $[13] !== steps || $[14] !== totals) {
|
|
182
|
+
t9 = steps.length === 0 ? /*#__PURE__*/_jsx(PanelEmpty, {
|
|
183
|
+
icon: /*#__PURE__*/_jsx(ChartNoAxesGanttIcon, {
|
|
184
|
+
"aria-hidden": true
|
|
185
|
+
}),
|
|
186
|
+
title: emptyText
|
|
187
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
188
|
+
children: [/*#__PURE__*/_jsx(Totals, {
|
|
189
|
+
totals: totals
|
|
190
|
+
}), /*#__PURE__*/_jsx("ol", {
|
|
191
|
+
className: "flex flex-col divide-y divide-border border-t border-border",
|
|
192
|
+
children: steps.map(step_1 => /*#__PURE__*/_jsx(StepCostRow, {
|
|
193
|
+
step: step_1,
|
|
194
|
+
maxCost: maxCost,
|
|
195
|
+
totalCost: totals.costMicroUsd
|
|
196
|
+
}, step_1.id))
|
|
197
|
+
})]
|
|
198
|
+
});
|
|
199
|
+
$[11] = emptyText;
|
|
200
|
+
$[12] = maxCost;
|
|
201
|
+
$[13] = steps;
|
|
202
|
+
$[14] = totals;
|
|
203
|
+
$[15] = t9;
|
|
204
|
+
} else {
|
|
205
|
+
t9 = $[15];
|
|
206
|
+
}
|
|
207
|
+
let t10;
|
|
208
|
+
if ($[16] !== className || $[17] !== label || $[18] !== t8 || $[19] !== t9) {
|
|
209
|
+
t10 = /*#__PURE__*/_jsxs(ApprovalPanel, {
|
|
210
|
+
"data-slot": "cost-steps",
|
|
211
|
+
"aria-label": label,
|
|
212
|
+
className: className,
|
|
213
|
+
children: [t8, t9]
|
|
214
|
+
});
|
|
215
|
+
$[16] = className;
|
|
216
|
+
$[17] = label;
|
|
217
|
+
$[18] = t8;
|
|
218
|
+
$[19] = t9;
|
|
219
|
+
$[20] = t10;
|
|
220
|
+
} else {
|
|
221
|
+
t10 = $[20];
|
|
222
|
+
}
|
|
223
|
+
return t10;
|
|
224
|
+
}
|
|
225
|
+
function _temp2(step_0) {
|
|
226
|
+
return step_0.status === "running";
|
|
227
|
+
}
|
|
228
|
+
function _temp(step) {
|
|
229
|
+
return step.usage.costMicroUsd;
|
|
230
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RunUsage } from "../types.js";
|
|
2
|
+
export type CostProps = {
|
|
3
|
+
usage: RunUsage | RunUsage[];
|
|
4
|
+
variant?: "compact" | "detailed";
|
|
5
|
+
label?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function Cost({ usage, variant, label, className }: CostProps): import("react").JSX.Element;
|