@locusgraph/loop 0.1.0 → 0.2.1
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/README.md +2 -0
- package/dist/agent/pulse/gradient-label.js +36 -15
- package/dist/agent/pulse/marks/bars-mark.js +24 -10
- package/dist/agent/pulse/marks/glyph-mark.js +17 -11
- package/dist/agent/pulse/marks/locus-mark.js +39 -28
- package/dist/agent/pulse/marks/orb-mark.js +21 -8
- package/dist/agent/pulse/marks/spinner-mark.js +20 -1
- package/dist/agent/pulse/pulse.js +63 -35
- package/dist/agent/pulse/use-loop-animation.js +14 -16
- package/dist/agent/steps/step-icon.js +40 -24
- package/dist/agent/steps/steps.js +72 -25
- package/dist/agent/thinking/thinking.js +203 -23
- package/dist/agent/thinking/thought-duration.js +7 -9
- package/dist/agent/tool/json-block.js +18 -11
- package/dist/agent/tool/tool-status.js +28 -18
- package/dist/agent/tool/tool.js +184 -6
- package/dist/approval/inbox/inbox-row.d.ts +3 -2
- package/dist/approval/inbox/inbox-row.js +96 -7
- package/dist/approval/inbox/inbox-selection.js +7 -13
- package/dist/approval/inbox/inbox.d.ts +2 -1
- package/dist/approval/inbox/inbox.js +99 -18
- package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
- package/dist/approval/inbox/virtual-inbox-list.js +53 -0
- package/dist/approval/memory/memory-choices.js +27 -22
- package/dist/approval/memory/memory-review.js +108 -17
- package/dist/approval/memory/memory-row.js +80 -19
- package/dist/approval/plan/plan-review.js +129 -28
- package/dist/approval/plan/plan-step-row.js +91 -44
- package/dist/approval/plan/plan-steps.js +24 -23
- package/dist/approval/plan/question-choices.js +73 -40
- package/dist/approval/plan/question.d.ts +1 -1
- package/dist/approval/plan/question.js +108 -27
- package/dist/approval/run/run-bar.js +94 -22
- package/dist/approval/shared/decision-line.js +1 -1
- package/dist/approval/shared/risk-badge.js +32 -16
- package/dist/approval/shared/time.js +5 -8
- package/dist/approval/shared/use-focus-on-mount.js +7 -6
- package/dist/approval/spend/raise-cap-form.js +64 -19
- package/dist/approval/spend/spend-gate.js +124 -21
- package/dist/approval/spend/spend-math.js +7 -8
- package/dist/approval/spend/spend-meter.js +136 -35
- package/dist/approval/tool/approval.js +113 -27
- package/dist/approval/tool/args/args-editor.js +104 -26
- package/dist/approval/tool/args/args-field.js +79 -22
- package/dist/approval/tool/args/args-validation.js +38 -47
- package/dist/approval/tool/deny-form.js +43 -10
- package/dist/approval/tool/tool-inputs.js +62 -38
- 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 +2 -1
- package/dist/chat/chat/chat.js +181 -5
- package/dist/chat/chat/use-stick-to-bottom.js +71 -48
- package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
- package/dist/chat/chat/virtual-chat-items.js +60 -0
- package/dist/chat/composer/composer-actions.js +69 -17
- package/dist/chat/composer/composer.js +330 -32
- package/dist/chat/composer/use-auto-grow.js +9 -9
- package/dist/chat/files/file-meta.js +19 -19
- package/dist/chat/files/files.js +92 -29
- package/dist/chat/reply/fenced-code.js +23 -21
- package/dist/chat/reply/markdown-components.js +137 -17
- package/dist/chat/reply/reply.js +30 -10
- package/dist/chat/turn/group-parts.js +43 -29
- package/dist/chat/turn/turn.js +87 -30
- package/dist/cost/context.js +104 -23
- package/dist/cost/cost-steps.js +67 -14
- package/dist/cost/cost.js +128 -23
- package/dist/cost/model-picker.js +51 -6
- package/dist/cost/shared/context-breakdown.js +83 -10
- package/dist/cost/shared/meter-marks.js +49 -9
- package/dist/cost/shared/model-option-row.js +56 -22
- package/dist/cost/shared/step-cost-row.js +65 -22
- package/dist/cost/shared/usage-totals.js +22 -18
- package/dist/memory/cite.js +62 -12
- package/dist/memory/memorized.js +65 -11
- package/dist/memory/recall.js +101 -17
- package/dist/memory/shared/host-label.js +19 -22
- package/dist/memory/shared/source-mark.js +11 -3
- package/dist/memory/sources.js +78 -14
- package/dist/shared/decision-summary.js +51 -14
- package/dist/shared/panel-empty.js +20 -3
- package/dist/shared/panel.js +69 -13
- package/dist/shared/status-dot.js +16 -8
- package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
- package/dist/shared/virtual/use-list-virtualizer.js +68 -0
- package/dist/thread/actions/action-button.js +22 -3
- package/dist/thread/actions/actions.js +184 -13
- package/dist/thread/actions/branch-switcher.js +28 -5
- package/dist/thread/canvas/canvas.js +205 -5
- package/dist/thread/canvas/version-switcher.js +54 -8
- package/dist/thread/code/code.js +186 -24
- package/dist/thread/code/copy-code-button.js +30 -14
- package/dist/thread/code/highlight.js +30 -29
- 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 +3 -2
- package/dist/thread/history/history.js +174 -5
- package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
- package/dist/thread/history/row/history-row.js +58 -0
- package/dist/thread/history/row/thread-item-menu.js +31 -0
- package/dist/thread/history/row/thread-title-editor.js +38 -0
- package/dist/thread/history/thread-groups.d.ts +1 -1
- package/dist/thread/history/thread-groups.js +40 -34
- package/dist/thread/history/virtual-history-list.d.ts +11 -0
- package/dist/thread/history/virtual-history-list.js +71 -0
- package/dist/thread/index.d.ts +1 -1
- package/dist/thread/starters/starters.js +33 -8
- package/dist/thread/use-copied.js +18 -16
- package/dist/types.js +1 -1
- package/package.json +6 -4
- package/dist/thread/history/history-row.js +0 -17
- package/dist/thread/history/thread-item-menu.js +0 -6
- package/dist/thread/history/thread-title-editor.js +0 -25
- /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
- /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
package/dist/cost/context.js
CHANGED
|
@@ -1,35 +1,116 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { cn, HoverCard, HoverCardContent, HoverCardTrigger } from "@locusgraph/components";
|
|
3
2
|
import { formatCount, nearLimitPercent, quotaPercent } from "@locusgraph/utils";
|
|
4
3
|
import { ContextBreakdown } from "./shared/context-breakdown.js";
|
|
5
4
|
import { MeterBar, MeterRing } from "./shared/meter-marks.js";
|
|
6
5
|
import { formatTokensShort } from "./shared/usage-totals.js";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
7
|
export function contextStatus(usedTokens, limitTokens) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (usedTokens >= limitTokens) return "full";
|
|
9
|
+
const percent = quotaPercent({
|
|
10
|
+
used: usedTokens,
|
|
11
|
+
included: limitTokens
|
|
12
|
+
});
|
|
13
|
+
return percent >= nearLimitPercent ? "near" : "ok";
|
|
12
14
|
}
|
|
13
15
|
const statusTone = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
ok: "text-muted-foreground",
|
|
17
|
+
near: "text-warn",
|
|
18
|
+
full: "text-destructive"
|
|
17
19
|
};
|
|
18
|
-
function RingContent({
|
|
19
|
-
|
|
20
|
+
function RingContent({
|
|
21
|
+
percent,
|
|
22
|
+
status
|
|
23
|
+
}) {
|
|
24
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
25
|
+
children: [/*#__PURE__*/_jsx(MeterRing, {
|
|
26
|
+
percent: percent,
|
|
27
|
+
status: status
|
|
28
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
29
|
+
className: "font-mono text-[11px] tabular-nums",
|
|
30
|
+
children: [percent, "%"]
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
20
33
|
}
|
|
21
|
-
function BarContent({
|
|
22
|
-
|
|
34
|
+
function BarContent({
|
|
35
|
+
label,
|
|
36
|
+
usedTokens,
|
|
37
|
+
limitTokens,
|
|
38
|
+
percent,
|
|
39
|
+
status
|
|
40
|
+
}) {
|
|
41
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
42
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
43
|
+
className: "flex items-baseline justify-between gap-4 font-mono text-[11px] tabular-nums",
|
|
44
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
45
|
+
className: "eyebrow",
|
|
46
|
+
children: label
|
|
47
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
48
|
+
className: cn(status === "ok" && "text-foreground"),
|
|
49
|
+
children: [percent, "% \xB7 ", formatTokensShort(usedTokens), " / ", formatTokensShort(limitTokens)]
|
|
50
|
+
})]
|
|
51
|
+
}), /*#__PURE__*/_jsx(MeterBar, {
|
|
52
|
+
percent: percent,
|
|
53
|
+
status: status
|
|
54
|
+
})]
|
|
55
|
+
});
|
|
23
56
|
}
|
|
24
|
-
export function Context({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
export function Context({
|
|
58
|
+
usedTokens,
|
|
59
|
+
limitTokens,
|
|
60
|
+
breakdown,
|
|
61
|
+
variant = "bar",
|
|
62
|
+
label = "Context",
|
|
63
|
+
className
|
|
64
|
+
}) {
|
|
65
|
+
const percent = quotaPercent({
|
|
66
|
+
used: usedTokens,
|
|
67
|
+
included: limitTokens
|
|
68
|
+
});
|
|
69
|
+
const status = contextStatus(usedTokens, limitTokens);
|
|
70
|
+
const summary = `${formatCount(usedTokens)} of ${formatCount(limitTokens)} tokens`;
|
|
71
|
+
const hasBreakdown = breakdown !== undefined && breakdown.length > 0;
|
|
72
|
+
const meter = /*#__PURE__*/_jsx("div", {
|
|
73
|
+
"data-slot": "context",
|
|
74
|
+
"data-status": status,
|
|
75
|
+
"data-variant": variant,
|
|
76
|
+
role: "meter",
|
|
77
|
+
"aria-label": `${label} window`,
|
|
78
|
+
"aria-valuemin": 0,
|
|
79
|
+
"aria-valuemax": 100,
|
|
80
|
+
"aria-valuenow": percent,
|
|
81
|
+
"aria-valuetext": `${percent}%, ${summary}`,
|
|
82
|
+
tabIndex: hasBreakdown ? 0 : undefined,
|
|
83
|
+
className: cn("outline-none focus-visible:ring-2 focus-visible:ring-ring/70", statusTone[status], 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", variant === "ring" && hasBreakdown && "cursor-default hover:bg-accent", className),
|
|
84
|
+
children: variant === "ring" ? /*#__PURE__*/_jsx(RingContent, {
|
|
85
|
+
percent: percent,
|
|
86
|
+
status: status
|
|
87
|
+
}) : /*#__PURE__*/_jsx(BarContent, {
|
|
88
|
+
label: label,
|
|
89
|
+
usedTokens: usedTokens,
|
|
90
|
+
limitTokens: limitTokens,
|
|
91
|
+
percent: percent,
|
|
92
|
+
status: status
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
if (!hasBreakdown) return meter;
|
|
96
|
+
return /*#__PURE__*/_jsxs(HoverCard, {
|
|
97
|
+
openDelay: 100,
|
|
98
|
+
closeDelay: 100,
|
|
99
|
+
children: [/*#__PURE__*/_jsx(HoverCardTrigger, {
|
|
100
|
+
asChild: true,
|
|
101
|
+
children: meter
|
|
102
|
+
}), /*#__PURE__*/_jsx(HoverCardContent, {
|
|
103
|
+
align: "end",
|
|
104
|
+
sideOffset: 6,
|
|
105
|
+
className: "w-72 rounded-none border-0 bg-popover p-0 shadow-overlay ring-1 ring-border",
|
|
106
|
+
children: /*#__PURE__*/_jsx(ContextBreakdown, {
|
|
107
|
+
label: label,
|
|
108
|
+
usedTokens: usedTokens,
|
|
109
|
+
limitTokens: limitTokens,
|
|
110
|
+
percent: percent,
|
|
111
|
+
status: status,
|
|
112
|
+
breakdown: breakdown
|
|
113
|
+
})
|
|
114
|
+
})]
|
|
115
|
+
});
|
|
35
116
|
}
|
package/dist/cost/cost-steps.js
CHANGED
|
@@ -1,24 +1,77 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { Roadmap as ChartNoAxesGanttIcon } from "@carbon/icons-react";
|
|
3
2
|
import { formatCount, formatMicroUsd, pluralize } from "@locusgraph/utils";
|
|
4
3
|
import { ApprovalPanel, PanelHeader } from "../shared/panel.js";
|
|
5
4
|
import { PanelEmpty } from "../shared/panel-empty.js";
|
|
6
5
|
import { isWastedStep, StepCostRow } from "./shared/step-cost-row.js";
|
|
7
6
|
import { formatDuration, sumUsage } from "./shared/usage-totals.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
8
|
export function stepCostTotals(steps) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const totals = sumUsage(steps.map(step => step.usage));
|
|
10
|
+
const wastedMicroUsd = steps.filter(isWastedStep).reduce((sum, step) => sum + step.usage.costMicroUsd, 0);
|
|
11
|
+
const durationMs = steps.reduce((sum, step) => sum + (step.durationMs ?? 0), 0);
|
|
12
|
+
return {
|
|
13
|
+
...totals,
|
|
14
|
+
wastedMicroUsd,
|
|
15
|
+
durationMs
|
|
16
|
+
};
|
|
15
17
|
}
|
|
16
|
-
function Totals({
|
|
17
|
-
|
|
18
|
+
function Totals({
|
|
19
|
+
totals
|
|
20
|
+
}) {
|
|
21
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
22
|
+
"data-slot": "step-cost-totals",
|
|
23
|
+
className: "flex flex-col gap-1 px-5 pt-2 pb-4",
|
|
24
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
25
|
+
className: "text-2xl font-semibold tracking-tight tabular-nums",
|
|
26
|
+
children: formatMicroUsd(totals.costMicroUsd)
|
|
27
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
28
|
+
className: "flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground tabular-nums",
|
|
29
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
30
|
+
children: [formatCount(totals.inputTokens), " in \xB7 ", formatCount(totals.outputTokens), " out", totals.durationMs > 0 && ` · ${formatDuration(totals.durationMs)}`]
|
|
31
|
+
}), totals.wastedMicroUsd > 0 && /*#__PURE__*/_jsxs("span", {
|
|
32
|
+
className: "text-destructive",
|
|
33
|
+
children: ["Wasted on failures ", formatMicroUsd(totals.wastedMicroUsd)]
|
|
34
|
+
})]
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
18
37
|
}
|
|
19
|
-
export function CostSteps({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
export function CostSteps({
|
|
39
|
+
steps,
|
|
40
|
+
label = "Cost by step",
|
|
41
|
+
emptyText = "No steps have run yet.",
|
|
42
|
+
className
|
|
43
|
+
}) {
|
|
44
|
+
const totals = stepCostTotals(steps);
|
|
45
|
+
const maxCost = Math.max(0, ...steps.map(step => step.usage.costMicroUsd));
|
|
46
|
+
const running = steps.some(step => step.status === "running");
|
|
47
|
+
return /*#__PURE__*/_jsxs(ApprovalPanel, {
|
|
48
|
+
"data-slot": "cost-steps",
|
|
49
|
+
"aria-label": label,
|
|
50
|
+
className: className,
|
|
51
|
+
children: [/*#__PURE__*/_jsx(PanelHeader, {
|
|
52
|
+
icon: /*#__PURE__*/_jsx(ChartNoAxesGanttIcon, {
|
|
53
|
+
"aria-hidden": true
|
|
54
|
+
}),
|
|
55
|
+
eyebrow: label,
|
|
56
|
+
aside: steps.length > 0 ? pluralize(steps.length, "step") : undefined,
|
|
57
|
+
status: running ? "Running" : undefined,
|
|
58
|
+
tone: "running"
|
|
59
|
+
}), steps.length === 0 ? /*#__PURE__*/_jsx(PanelEmpty, {
|
|
60
|
+
icon: /*#__PURE__*/_jsx(ChartNoAxesGanttIcon, {
|
|
61
|
+
"aria-hidden": true
|
|
62
|
+
}),
|
|
63
|
+
title: emptyText
|
|
64
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
65
|
+
children: [/*#__PURE__*/_jsx(Totals, {
|
|
66
|
+
totals: totals
|
|
67
|
+
}), /*#__PURE__*/_jsx("ol", {
|
|
68
|
+
className: "flex flex-col divide-y divide-border border-t border-border",
|
|
69
|
+
children: steps.map(step => /*#__PURE__*/_jsx(StepCostRow, {
|
|
70
|
+
step: step,
|
|
71
|
+
maxCost: maxCost,
|
|
72
|
+
totalCost: totals.costMicroUsd
|
|
73
|
+
}, step.id))
|
|
74
|
+
})]
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
24
77
|
}
|
package/dist/cost/cost.js
CHANGED
|
@@ -1,37 +1,142 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { Money as CoinsIcon } from "@carbon/icons-react";
|
|
3
2
|
import { cn } from "@locusgraph/components";
|
|
4
3
|
import { formatCount, formatMicroUsd, pluralize } from "@locusgraph/utils";
|
|
5
4
|
import { ApprovalPanel, PanelHeader } from "../shared/panel.js";
|
|
6
5
|
import { sumUsage } from "./shared/usage-totals.js";
|
|
6
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
function attemptsOf(usage) {
|
|
8
|
-
|
|
8
|
+
return Array.isArray(usage) ? usage : [usage];
|
|
9
9
|
}
|
|
10
10
|
function modelsOf(attempts) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const models = [...new Set(attempts.map(attempt => attempt.model).filter(Boolean))];
|
|
12
|
+
return models.length > 0 ? models.join(", ") : undefined;
|
|
13
13
|
}
|
|
14
|
-
function WastedNote({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
function WastedNote({
|
|
15
|
+
totals
|
|
16
|
+
}) {
|
|
17
|
+
if (totals.failedAttempts === 0) return null;
|
|
18
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
19
|
+
"data-slot": "cost-wasted",
|
|
20
|
+
className: "text-destructive tabular-nums",
|
|
21
|
+
children: [pluralize(totals.failedAttempts, "failed attempt"), " \xB7 ", formatMicroUsd(totals.wastedMicroUsd), " ", "wasted"]
|
|
22
|
+
});
|
|
18
23
|
}
|
|
19
|
-
function CompactCost({
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
function CompactCost({
|
|
25
|
+
attempts,
|
|
26
|
+
totals,
|
|
27
|
+
className
|
|
28
|
+
}) {
|
|
29
|
+
const model = modelsOf(attempts);
|
|
30
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
31
|
+
"data-slot": "cost",
|
|
32
|
+
"data-variant": "compact",
|
|
33
|
+
"data-failed": totals.failedAttempts > 0 || undefined,
|
|
34
|
+
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),
|
|
35
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
36
|
+
className: "font-medium text-foreground",
|
|
37
|
+
children: formatMicroUsd(totals.costMicroUsd)
|
|
38
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
39
|
+
className: "whitespace-nowrap",
|
|
40
|
+
children: [formatCount(totals.inputTokens), " in \xB7 ", formatCount(totals.outputTokens), " out"]
|
|
41
|
+
}), model && /*#__PURE__*/_jsx("span", {
|
|
42
|
+
children: model
|
|
43
|
+
}), /*#__PURE__*/_jsx(WastedNote, {
|
|
44
|
+
totals: totals
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
22
47
|
}
|
|
23
|
-
function AttemptRow({
|
|
24
|
-
|
|
48
|
+
function AttemptRow({
|
|
49
|
+
attempt,
|
|
50
|
+
position
|
|
51
|
+
}) {
|
|
52
|
+
return /*#__PURE__*/_jsxs("li", {
|
|
53
|
+
"data-slot": "cost-attempt",
|
|
54
|
+
"data-failed": attempt.failed || undefined,
|
|
55
|
+
className: "grid grid-cols-[1fr_auto_4.5rem] items-baseline gap-x-4 px-5 py-2.5 text-sm tabular-nums",
|
|
56
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
57
|
+
className: "flex min-w-0 items-baseline gap-2",
|
|
58
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
59
|
+
className: "eyebrow",
|
|
60
|
+
children: ["#", position + 1]
|
|
61
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
62
|
+
className: cn("truncate", attempt.failed && "text-muted-foreground"),
|
|
63
|
+
children: attempt.model ?? "Attempt"
|
|
64
|
+
}), attempt.failed && /*#__PURE__*/_jsx("span", {
|
|
65
|
+
className: "font-mono text-[11px] tracking-wide text-destructive uppercase",
|
|
66
|
+
children: "Failed"
|
|
67
|
+
})]
|
|
68
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
69
|
+
className: "font-mono text-[11px] text-muted-foreground max-sm:hidden",
|
|
70
|
+
children: [formatCount(attempt.inputTokens), " in \xB7 ", formatCount(attempt.outputTokens), " out"]
|
|
71
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
72
|
+
className: cn("text-right font-mono text-xs", attempt.failed && "text-muted-foreground line-through"),
|
|
73
|
+
children: formatMicroUsd(attempt.costMicroUsd)
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
25
76
|
}
|
|
26
|
-
function DetailedCost({
|
|
27
|
-
|
|
28
|
-
|
|
77
|
+
function DetailedCost({
|
|
78
|
+
attempts,
|
|
79
|
+
totals,
|
|
80
|
+
label,
|
|
81
|
+
className
|
|
82
|
+
}) {
|
|
83
|
+
const failed = totals.failedAttempts > 0;
|
|
84
|
+
return /*#__PURE__*/_jsxs(ApprovalPanel, {
|
|
85
|
+
"data-slot": "cost",
|
|
86
|
+
"data-variant": "detailed",
|
|
87
|
+
"data-failed": failed || undefined,
|
|
88
|
+
"aria-label": label,
|
|
89
|
+
className: className,
|
|
90
|
+
children: [/*#__PURE__*/_jsx(PanelHeader, {
|
|
91
|
+
icon: /*#__PURE__*/_jsx(CoinsIcon, {
|
|
92
|
+
"aria-hidden": true
|
|
93
|
+
}),
|
|
94
|
+
eyebrow: label,
|
|
95
|
+
aside: pluralize(attempts.length, "attempt")
|
|
96
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
97
|
+
className: "flex flex-col gap-1 px-5 pt-2 pb-4",
|
|
98
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
99
|
+
className: "text-2xl font-semibold tracking-tight tabular-nums",
|
|
100
|
+
children: formatMicroUsd(totals.costMicroUsd)
|
|
101
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
102
|
+
className: "flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground tabular-nums",
|
|
103
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
104
|
+
children: [formatCount(totals.inputTokens), " in \xB7 ", formatCount(totals.outputTokens), " out"]
|
|
105
|
+
}), /*#__PURE__*/_jsx(WastedNote, {
|
|
106
|
+
totals: totals
|
|
107
|
+
})]
|
|
108
|
+
})]
|
|
109
|
+
}), /*#__PURE__*/_jsx("ol", {
|
|
110
|
+
className: "flex flex-col divide-y divide-border border-t border-border",
|
|
111
|
+
children: attempts.map((attempt, position) =>
|
|
112
|
+
/*#__PURE__*/
|
|
113
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: attempts carry no id and keep their order
|
|
114
|
+
_jsx(AttemptRow, {
|
|
115
|
+
attempt: attempt,
|
|
116
|
+
position: position
|
|
117
|
+
}, position))
|
|
118
|
+
})]
|
|
119
|
+
});
|
|
29
120
|
}
|
|
30
|
-
export function Cost({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
121
|
+
export function Cost({
|
|
122
|
+
usage,
|
|
123
|
+
variant = "compact",
|
|
124
|
+
label = "Run cost",
|
|
125
|
+
className
|
|
126
|
+
}) {
|
|
127
|
+
const attempts = attemptsOf(usage);
|
|
128
|
+
const totals = sumUsage(attempts);
|
|
129
|
+
if (variant === "detailed") {
|
|
130
|
+
return /*#__PURE__*/_jsx(DetailedCost, {
|
|
131
|
+
attempts: attempts,
|
|
132
|
+
totals: totals,
|
|
133
|
+
label: label,
|
|
134
|
+
className: className
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return /*#__PURE__*/_jsx(CompactCost, {
|
|
138
|
+
attempts: attempts,
|
|
139
|
+
totals: totals,
|
|
140
|
+
className: className
|
|
141
|
+
});
|
|
37
142
|
}
|
|
@@ -1,9 +1,54 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { ChevronDown as ChevronDownIcon } from "@carbon/icons-react";
|
|
3
|
-
import { cn, DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuTrigger
|
|
2
|
+
import { cn, DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuTrigger } from "@locusgraph/components";
|
|
4
3
|
import { ModelOptionRow } from "./shared/model-option-row.js";
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export { modelPriceLabel } from "./shared/model-option-row.js";
|
|
6
|
+
export function ModelPicker({
|
|
7
|
+
models,
|
|
8
|
+
value,
|
|
9
|
+
onChange,
|
|
10
|
+
label = "Model",
|
|
11
|
+
disabled = false,
|
|
12
|
+
className
|
|
13
|
+
}) {
|
|
14
|
+
const selected = models.find(model => model.id === value);
|
|
15
|
+
return /*#__PURE__*/_jsxs(DropdownMenu, {
|
|
16
|
+
children: [/*#__PURE__*/_jsxs(DropdownMenuTrigger, {
|
|
17
|
+
"data-slot": "model-picker",
|
|
18
|
+
"data-value": value,
|
|
19
|
+
disabled: disabled,
|
|
20
|
+
"aria-label": `${label}: ${selected?.name ?? "none selected"}`,
|
|
21
|
+
className: cn("group inline-flex h-7 max-w-full items-center gap-1.5 rounded-full px-2.5 text-xs outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:opacity-50 data-[state=open]:bg-accent motion-reduce:transition-none", className),
|
|
22
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
23
|
+
className: "truncate font-medium",
|
|
24
|
+
children: selected?.name ?? label
|
|
25
|
+
}), selected && /*#__PURE__*/_jsx("span", {
|
|
26
|
+
className: "truncate text-muted-foreground max-sm:hidden",
|
|
27
|
+
children: selected.provider
|
|
28
|
+
}), /*#__PURE__*/_jsx(ChevronDownIcon, {
|
|
29
|
+
"aria-hidden": true,
|
|
30
|
+
className: "size-3 shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180 motion-reduce:transition-none"
|
|
31
|
+
})]
|
|
32
|
+
}), /*#__PURE__*/_jsxs(DropdownMenuContent, {
|
|
33
|
+
align: "start",
|
|
34
|
+
sideOffset: 6,
|
|
35
|
+
className: "w-80 rounded-none border-0 bg-popover p-0 shadow-overlay ring-1 ring-border",
|
|
36
|
+
children: [/*#__PURE__*/_jsxs(DropdownMenuLabel, {
|
|
37
|
+
className: "eyebrow flex justify-between gap-3 border-b border-border px-3 py-2 font-normal",
|
|
38
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
39
|
+
children: label
|
|
40
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
41
|
+
className: "pr-7",
|
|
42
|
+
children: "Per 1M tokens"
|
|
43
|
+
})]
|
|
44
|
+
}), /*#__PURE__*/_jsx(DropdownMenuRadioGroup, {
|
|
45
|
+
value: value,
|
|
46
|
+
onValueChange: onChange,
|
|
47
|
+
className: "flex flex-col divide-y divide-border",
|
|
48
|
+
children: models.map(model => /*#__PURE__*/_jsx(ModelOptionRow, {
|
|
49
|
+
model: model
|
|
50
|
+
}, model.id))
|
|
51
|
+
})]
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
9
54
|
}
|
|
@@ -1,17 +1,90 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { cn } from "@locusgraph/components";
|
|
3
2
|
import { formatCount, quotaPercent } from "@locusgraph/utils";
|
|
4
3
|
import { MeterBar } from "./meter-marks.js";
|
|
5
|
-
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
const statusWord = {
|
|
6
|
+
ok: "Room left",
|
|
7
|
+
near: "Near limit",
|
|
8
|
+
full: "Full"
|
|
9
|
+
};
|
|
6
10
|
const statusDot = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
ok: "bg-good",
|
|
12
|
+
near: "bg-warn",
|
|
13
|
+
full: "bg-destructive"
|
|
10
14
|
};
|
|
11
|
-
function SegmentRow({
|
|
12
|
-
|
|
15
|
+
function SegmentRow({
|
|
16
|
+
label,
|
|
17
|
+
tokens,
|
|
18
|
+
limitTokens,
|
|
19
|
+
muted = false
|
|
20
|
+
}) {
|
|
21
|
+
return /*#__PURE__*/_jsxs("li", {
|
|
22
|
+
className: cn("grid grid-cols-[1fr_auto_3rem] items-baseline gap-x-3 px-4 py-2 text-xs tabular-nums", muted && "text-muted-foreground"),
|
|
23
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
24
|
+
className: "truncate",
|
|
25
|
+
children: label
|
|
26
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
27
|
+
className: "font-mono",
|
|
28
|
+
children: formatCount(tokens)
|
|
29
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
30
|
+
className: "text-right font-mono text-muted-foreground",
|
|
31
|
+
children: [quotaPercent({
|
|
32
|
+
used: tokens,
|
|
33
|
+
included: limitTokens
|
|
34
|
+
}), "%"]
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
13
37
|
}
|
|
14
|
-
export function ContextBreakdown({
|
|
15
|
-
|
|
16
|
-
|
|
38
|
+
export function ContextBreakdown({
|
|
39
|
+
label,
|
|
40
|
+
usedTokens,
|
|
41
|
+
limitTokens,
|
|
42
|
+
percent,
|
|
43
|
+
status,
|
|
44
|
+
breakdown
|
|
45
|
+
}) {
|
|
46
|
+
const freeTokens = Math.max(limitTokens - usedTokens, 0);
|
|
47
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
48
|
+
"data-slot": "context-breakdown",
|
|
49
|
+
className: "flex flex-col",
|
|
50
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
51
|
+
className: "eyebrow flex items-center gap-2 px-4 pt-3",
|
|
52
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
53
|
+
children: label
|
|
54
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
55
|
+
className: "ml-auto flex items-center gap-1.5",
|
|
56
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
57
|
+
"aria-hidden": true,
|
|
58
|
+
className: cn("size-1.5 rounded-full", statusDot[status])
|
|
59
|
+
}), statusWord[status]]
|
|
60
|
+
})]
|
|
61
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
62
|
+
className: "flex flex-col gap-2 px-4 pt-2 pb-3",
|
|
63
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
64
|
+
className: "flex items-baseline gap-1.5 tabular-nums",
|
|
65
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
66
|
+
className: "text-lg font-semibold tracking-tight",
|
|
67
|
+
children: [percent, "%"]
|
|
68
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
69
|
+
className: "text-xs text-muted-foreground",
|
|
70
|
+
children: [formatCount(usedTokens), " of ", formatCount(limitTokens), " tokens"]
|
|
71
|
+
})]
|
|
72
|
+
}), /*#__PURE__*/_jsx(MeterBar, {
|
|
73
|
+
percent: percent,
|
|
74
|
+
status: status
|
|
75
|
+
})]
|
|
76
|
+
}), /*#__PURE__*/_jsxs("ul", {
|
|
77
|
+
className: "flex flex-col divide-y divide-border border-t border-border",
|
|
78
|
+
children: [breakdown.map(segment => /*#__PURE__*/_jsx(SegmentRow, {
|
|
79
|
+
label: segment.label,
|
|
80
|
+
tokens: segment.tokens,
|
|
81
|
+
limitTokens: limitTokens
|
|
82
|
+
}, segment.label)), /*#__PURE__*/_jsx(SegmentRow, {
|
|
83
|
+
label: "Free",
|
|
84
|
+
tokens: freeTokens,
|
|
85
|
+
limitTokens: limitTokens,
|
|
86
|
+
muted: true
|
|
87
|
+
})]
|
|
88
|
+
})]
|
|
89
|
+
});
|
|
17
90
|
}
|
|
@@ -1,16 +1,56 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { cn } from "@locusgraph/components";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
const ringRadius = 7;
|
|
4
4
|
const ringCircumference = 2 * Math.PI * ringRadius;
|
|
5
5
|
const ringStroke = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
ok: "stroke-primary",
|
|
7
|
+
near: "stroke-warn",
|
|
8
|
+
full: "stroke-destructive"
|
|
9
|
+
};
|
|
10
|
+
const barFill = {
|
|
11
|
+
ok: "bg-primary",
|
|
12
|
+
near: "bg-warn",
|
|
13
|
+
full: "bg-destructive"
|
|
9
14
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
export function MeterRing({
|
|
16
|
+
percent,
|
|
17
|
+
status
|
|
18
|
+
}) {
|
|
19
|
+
return /*#__PURE__*/_jsxs("svg", {
|
|
20
|
+
viewBox: "0 0 18 18",
|
|
21
|
+
"aria-hidden": true,
|
|
22
|
+
className: "size-3.5 shrink-0 -rotate-90",
|
|
23
|
+
children: [/*#__PURE__*/_jsx("circle", {
|
|
24
|
+
cx: "9",
|
|
25
|
+
cy: "9",
|
|
26
|
+
r: ringRadius,
|
|
27
|
+
fill: "none",
|
|
28
|
+
strokeWidth: "2.5",
|
|
29
|
+
className: "stroke-muted-foreground/20"
|
|
30
|
+
}), /*#__PURE__*/_jsx("circle", {
|
|
31
|
+
cx: "9",
|
|
32
|
+
cy: "9",
|
|
33
|
+
r: ringRadius,
|
|
34
|
+
fill: "none",
|
|
35
|
+
strokeWidth: "2.5",
|
|
36
|
+
strokeDasharray: ringCircumference,
|
|
37
|
+
strokeDashoffset: ringCircumference * (1 - percent / 100),
|
|
38
|
+
className: cn("transition-[stroke-dashoffset] duration-300 motion-reduce:transition-none", ringStroke[status])
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
13
41
|
}
|
|
14
|
-
export function MeterBar({
|
|
15
|
-
|
|
42
|
+
export function MeterBar({
|
|
43
|
+
percent,
|
|
44
|
+
status
|
|
45
|
+
}) {
|
|
46
|
+
return /*#__PURE__*/_jsx("span", {
|
|
47
|
+
"aria-hidden": true,
|
|
48
|
+
className: "relative block h-1 w-full overflow-hidden bg-muted-foreground/20",
|
|
49
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
50
|
+
className: cn("absolute inset-y-0 left-0 transition-[width] duration-300 motion-reduce:transition-none", barFill[status]),
|
|
51
|
+
style: {
|
|
52
|
+
width: `${percent}%`
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
});
|
|
16
56
|
}
|