@locusgraph/loop 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/pulse/gradient-label.js +6 -5
- package/dist/agent/pulse/marks/bars-mark.js +1 -1
- package/dist/agent/pulse/marks/glyph-mark.js +2 -2
- package/dist/agent/pulse/marks/locus-mark.js +1 -1
- package/dist/agent/pulse/pulse.js +1 -1
- package/dist/agent/pulse/use-loop-animation.d.ts +0 -1
- package/dist/agent/pulse/use-loop-animation.js +1 -3
- package/dist/agent/steps/step-icon.js +20 -13
- package/dist/agent/steps/steps.js +39 -37
- package/dist/agent/thinking/thinking.js +65 -62
- package/dist/agent/tool/json-block.js +10 -7
- package/dist/agent/tool/tool-status.d.ts +2 -0
- package/dist/agent/tool/tool-status.js +16 -13
- package/dist/agent/tool/tool.d.ts +8 -1
- package/dist/agent/tool/tool.js +238 -119
- package/dist/approval/inbox/inbox-row.d.ts +3 -3
- package/dist/approval/inbox/inbox-row.js +135 -200
- package/dist/approval/inbox/inbox.d.ts +3 -3
- package/dist/approval/inbox/inbox.js +180 -139
- package/dist/approval/inbox/virtual-inbox-list.d.ts +3 -3
- package/dist/approval/inbox/virtual-inbox-list.js +20 -21
- package/dist/approval/memory/memory-review.js +155 -154
- package/dist/approval/memory/memory-row.js +86 -87
- package/dist/approval/plan/plan-review.js +110 -129
- package/dist/approval/plan/plan-step-row.js +7 -6
- package/dist/approval/plan/plan-steps.d.ts +1 -1
- package/dist/approval/plan/plan-steps.js +2 -2
- package/dist/approval/plan/question-choices.js +10 -7
- package/dist/approval/plan/question.js +116 -112
- package/dist/approval/run/run-bar.js +43 -40
- package/dist/approval/shared/approval-line.d.ts +27 -0
- package/dist/approval/shared/approval-line.js +85 -0
- package/dist/approval/shared/risk-badge.d.ts +3 -5
- package/dist/approval/shared/risk-badge.js +11 -19
- package/dist/approval/shared/time.d.ts +0 -1
- package/dist/approval/shared/time.js +0 -1
- package/dist/approval/shared/use-focus-when-settled.d.ts +2 -0
- package/dist/approval/shared/use-focus-when-settled.js +18 -0
- package/dist/approval/spend/raise-cap-form.d.ts +2 -2
- package/dist/approval/spend/raise-cap-form.js +134 -126
- package/dist/approval/spend/spend-gate.js +133 -156
- package/dist/approval/spend/spend-math.d.ts +1 -0
- package/dist/approval/spend/spend-math.js +5 -2
- package/dist/approval/spend/spend-meter.js +5 -5
- package/dist/approval/tool/approval.js +114 -214
- package/dist/approval/tool/args/args-editor.js +147 -156
- package/dist/approval/tool/args/args-field.js +197 -109
- package/dist/approval/tool/deny-form.js +59 -66
- package/dist/approval/tool/tool-inputs.js +38 -45
- package/dist/chat/chat/chat.js +5 -4
- package/dist/chat/chat/use-stick-to-bottom.js +1 -3
- package/dist/chat/composer/composer-actions.js +4 -1
- package/dist/chat/composer/composer.js +4 -3
- package/dist/chat/composer/use-auto-grow.js +14 -10
- package/dist/chat/files/files.js +12 -10
- package/dist/chat/reply/fenced-code.js +1 -1
- package/dist/chat/reply/markdown-components.js +9 -116
- package/dist/chat/reply/reply.js +2 -2
- package/dist/chat/turn/group-parts.d.ts +1 -0
- package/dist/chat/turn/group-parts.js +6 -3
- package/dist/chat/turn/turn.js +13 -4
- package/dist/cost/context.js +3 -3
- package/dist/cost/cost-steps.js +31 -30
- package/dist/cost/cost.js +39 -39
- package/dist/cost/model-picker.js +5 -4
- package/dist/cost/shared/context-breakdown.js +10 -11
- package/dist/cost/shared/model-option-row.js +4 -3
- package/dist/cost/shared/step-cost-row.js +11 -12
- package/dist/cost/shared/usage-totals.d.ts +1 -0
- package/dist/cost/shared/usage-totals.js +19 -1
- package/dist/memory/cite.js +55 -47
- package/dist/memory/memorized.js +123 -108
- package/dist/memory/recall.js +136 -146
- package/dist/memory/shared/host-label.d.ts +1 -1
- package/dist/memory/shared/host-label.js +2 -2
- package/dist/memory/shared/source-mark.js +1 -1
- package/dist/memory/sources.d.ts +2 -1
- package/dist/memory/sources.js +135 -100
- package/dist/shared/decision-summary.js +2 -1
- package/dist/shared/line.d.ts +10 -0
- package/dist/shared/line.js +11 -0
- package/dist/shared/live-status.d.ts +3 -0
- package/dist/shared/live-status.js +11 -0
- package/dist/shared/reduced-motion.d.ts +1 -0
- package/dist/shared/reduced-motion.js +3 -0
- package/dist/thread/actions/action-button.js +1 -1
- package/dist/thread/actions/actions.d.ts +3 -1
- package/dist/thread/actions/actions.js +100 -81
- package/dist/thread/actions/branch-switcher.js +67 -37
- package/dist/thread/canvas/canvas-meta.d.ts +9 -0
- package/dist/thread/canvas/canvas-meta.js +35 -0
- package/dist/thread/canvas/canvas.d.ts +1 -1
- package/dist/thread/canvas/canvas.js +64 -74
- package/dist/thread/canvas/version-switcher.d.ts +1 -0
- package/dist/thread/canvas/version-switcher.js +106 -87
- package/dist/thread/code/code.js +4 -6
- package/dist/thread/code/copy-code-button.d.ts +2 -1
- package/dist/thread/code/copy-code-button.js +56 -25
- package/dist/thread/history/history.d.ts +1 -1
- package/dist/thread/history/history.js +104 -104
- package/dist/thread/history/row/history-row.js +8 -5
- package/dist/thread/history/row/thread-item-menu.js +13 -4
- package/dist/thread/history/row/thread-title-editor.js +1 -1
- package/dist/thread/history/virtual-history-list.js +1 -2
- package/dist/thread/index.d.ts +1 -0
- package/dist/thread/index.js +1 -0
- package/dist/thread/starters/starters.js +5 -4
- package/package.json +6 -6
- package/dist/agent/shared/status-dot.d.ts +0 -1
- package/dist/agent/shared/status-dot.js +0 -1
- package/dist/approval/shared/decision-line.d.ts +0 -1
- package/dist/approval/shared/decision-line.js +0 -1
- package/dist/memory/shared/disclosure.d.ts +0 -6
- package/dist/memory/shared/disclosure.js +0 -6
- package/dist/shared/panel.d.ts +0 -19
- package/dist/shared/panel.js +0 -77
- package/dist/shared/status-dot.d.ts +0 -6
- package/dist/shared/status-dot.js +0 -20
package/dist/cost/context.js
CHANGED
|
@@ -26,7 +26,7 @@ function RingContent({
|
|
|
26
26
|
percent: percent,
|
|
27
27
|
status: status
|
|
28
28
|
}), /*#__PURE__*/_jsxs("span", {
|
|
29
|
-
className: "font-mono text-
|
|
29
|
+
className: "font-mono text-2xs tabular-nums",
|
|
30
30
|
children: [percent, "%"]
|
|
31
31
|
})]
|
|
32
32
|
});
|
|
@@ -40,7 +40,7 @@ function BarContent({
|
|
|
40
40
|
}) {
|
|
41
41
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
42
42
|
children: [/*#__PURE__*/_jsxs("span", {
|
|
43
|
-
className: "flex items-baseline justify-between gap-4 font-mono text-
|
|
43
|
+
className: "flex items-baseline justify-between gap-4 font-mono text-2xs tabular-nums",
|
|
44
44
|
children: [/*#__PURE__*/_jsx("span", {
|
|
45
45
|
className: "locus-eyebrow",
|
|
46
46
|
children: label
|
|
@@ -80,7 +80,7 @@ export function Context({
|
|
|
80
80
|
"aria-valuenow": percent,
|
|
81
81
|
"aria-valuetext": `${percent}%, ${summary}`,
|
|
82
82
|
tabIndex: hasBreakdown ? 0 : undefined,
|
|
83
|
-
className: cn("
|
|
83
|
+
className: cn("locus-focus-ring", statusTone[status], variant === "ring" ? "inline-flex h-control-xs 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
84
|
children: variant === "ring" ? /*#__PURE__*/_jsx(RingContent, {
|
|
85
85
|
percent: percent,
|
|
86
86
|
status: status
|
package/dist/cost/cost-steps.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { cn } from "@locusgraph/components";
|
|
2
|
+
import { formatMicroUsd } from "@locusgraph/utils";
|
|
3
|
+
import { ChartBarHorizontal as ChartNoAxesGanttIcon } from "@phosphor-icons/react/ssr";
|
|
4
|
+
import { lineIconClass, lineRowClass } from "../shared/line.js";
|
|
5
5
|
import { isWastedStep, StepCostRow } from "./shared/step-cost-row.js";
|
|
6
|
-
import { formatDuration, sumUsage } from "./shared/usage-totals.js";
|
|
6
|
+
import { formatDuration, formatTokensShort, sumUsage } from "./shared/usage-totals.js";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
8
|
export function stepCostTotals(steps) {
|
|
9
9
|
const totals = sumUsage(steps.map(step => step.usage));
|
|
@@ -20,18 +20,13 @@ function Totals({
|
|
|
20
20
|
}) {
|
|
21
21
|
return /*#__PURE__*/_jsxs("div", {
|
|
22
22
|
"data-slot": "step-cost-totals",
|
|
23
|
-
className: "flex
|
|
23
|
+
className: "flex items-baseline gap-3 pb-2 pl-6 tabular-nums",
|
|
24
24
|
children: [/*#__PURE__*/_jsx("span", {
|
|
25
|
-
className: "text-
|
|
25
|
+
className: "text-xl font-semibold tracking-tight text-foreground",
|
|
26
26
|
children: formatMicroUsd(totals.costMicroUsd)
|
|
27
27
|
}), /*#__PURE__*/_jsxs("span", {
|
|
28
|
-
className: "
|
|
29
|
-
children: [
|
|
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
|
-
})]
|
|
28
|
+
className: "text-xs text-faint",
|
|
29
|
+
children: [formatTokensShort(totals.inputTokens), " in \xB7 ", formatTokensShort(totals.outputTokens), " out", totals.durationMs > 0 && ` · ${formatDuration(totals.durationMs)}`]
|
|
35
30
|
})]
|
|
36
31
|
});
|
|
37
32
|
}
|
|
@@ -44,28 +39,34 @@ export function CostSteps({
|
|
|
44
39
|
const totals = stepCostTotals(steps);
|
|
45
40
|
const maxCost = Math.max(0, ...steps.map(step => step.usage.costMicroUsd));
|
|
46
41
|
const running = steps.some(step => step.status === "running");
|
|
47
|
-
return /*#__PURE__*/_jsxs(
|
|
42
|
+
return /*#__PURE__*/_jsxs("section", {
|
|
48
43
|
"data-slot": "cost-steps",
|
|
49
44
|
"aria-label": label,
|
|
50
|
-
className: className,
|
|
51
|
-
children: [/*#__PURE__*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
className: cn("flex min-w-0 flex-col", className),
|
|
46
|
+
children: [/*#__PURE__*/_jsxs("header", {
|
|
47
|
+
className: lineRowClass,
|
|
48
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
49
|
+
"aria-hidden": true,
|
|
50
|
+
className: lineIconClass,
|
|
51
|
+
children: /*#__PURE__*/_jsx(ChartNoAxesGanttIcon, {
|
|
52
|
+
weight: "bold",
|
|
53
|
+
"aria-hidden": true
|
|
54
|
+
})
|
|
55
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
56
|
+
className: "truncate",
|
|
57
|
+
children: label
|
|
58
|
+
}), running && /*#__PURE__*/_jsx("span", {
|
|
59
|
+
className: "shrink-0 text-warn motion-safe:locus-shimmer",
|
|
60
|
+
children: "Running"
|
|
61
|
+
})]
|
|
62
|
+
}), steps.length === 0 ? /*#__PURE__*/_jsx("p", {
|
|
63
|
+
className: "pl-6 text-sm text-faint",
|
|
64
|
+
children: emptyText
|
|
64
65
|
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
65
66
|
children: [/*#__PURE__*/_jsx(Totals, {
|
|
66
67
|
totals: totals
|
|
67
68
|
}), /*#__PURE__*/_jsx("ol", {
|
|
68
|
-
className: "flex flex-col
|
|
69
|
+
className: "flex flex-col pl-6",
|
|
69
70
|
children: steps.map(step => /*#__PURE__*/_jsx(StepCostRow, {
|
|
70
71
|
step: step,
|
|
71
72
|
maxCost: maxCost,
|
package/dist/cost/cost.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Money as CoinsIcon } from "@carbon/icons-react";
|
|
2
1
|
import { cn } from "@locusgraph/components";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { formatMicroUsd, pluralize } from "@locusgraph/utils";
|
|
3
|
+
import { Coins as CoinsIcon } from "@phosphor-icons/react/ssr";
|
|
4
|
+
import { lineIconClass, lineRowClass } from "../shared/line.js";
|
|
5
|
+
import { formatTokensShort, sumUsage } from "./shared/usage-totals.js";
|
|
6
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];
|
|
@@ -31,13 +31,13 @@ function CompactCost({
|
|
|
31
31
|
"data-slot": "cost",
|
|
32
32
|
"data-variant": "compact",
|
|
33
33
|
"data-failed": totals.failedAttempts > 0 || undefined,
|
|
34
|
-
className: cn("inline-flex flex-wrap items-baseline gap-x-3 gap-y-0.5
|
|
34
|
+
className: cn("inline-flex flex-wrap items-baseline gap-x-3 gap-y-0.5 text-xs text-faint tabular-nums", className),
|
|
35
35
|
children: [/*#__PURE__*/_jsx("span", {
|
|
36
|
-
className: "font-medium text-foreground",
|
|
36
|
+
className: "font-medium text-muted-foreground",
|
|
37
37
|
children: formatMicroUsd(totals.costMicroUsd)
|
|
38
38
|
}), /*#__PURE__*/_jsxs("span", {
|
|
39
39
|
className: "whitespace-nowrap",
|
|
40
|
-
children: [
|
|
40
|
+
children: [formatTokensShort(totals.inputTokens), " in \xB7 ", formatTokensShort(totals.outputTokens), " out"]
|
|
41
41
|
}), model && /*#__PURE__*/_jsx("span", {
|
|
42
42
|
children: model
|
|
43
43
|
}), /*#__PURE__*/_jsx(WastedNote, {
|
|
@@ -46,30 +46,26 @@ function CompactCost({
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
function AttemptRow({
|
|
49
|
-
attempt
|
|
50
|
-
position
|
|
49
|
+
attempt
|
|
51
50
|
}) {
|
|
52
51
|
return /*#__PURE__*/_jsxs("li", {
|
|
53
52
|
"data-slot": "cost-attempt",
|
|
54
53
|
"data-failed": attempt.failed || undefined,
|
|
55
|
-
className: "
|
|
54
|
+
className: "flex items-baseline justify-between gap-4 py-0.5 text-sm tabular-nums",
|
|
56
55
|
children: [/*#__PURE__*/_jsxs("span", {
|
|
57
56
|
className: "flex min-w-0 items-baseline gap-2",
|
|
58
|
-
children: [/*#__PURE__*/
|
|
59
|
-
className: "
|
|
60
|
-
children: ["#", position + 1]
|
|
61
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
62
|
-
className: cn("truncate", attempt.failed && "text-muted-foreground"),
|
|
57
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
58
|
+
className: cn("truncate normal-nums", attempt.failed ? "text-muted-foreground" : "text-foreground"),
|
|
63
59
|
children: attempt.model ?? "Attempt"
|
|
64
60
|
}), attempt.failed && /*#__PURE__*/_jsx("span", {
|
|
65
|
-
className: "
|
|
61
|
+
className: "text-xs font-medium text-destructive",
|
|
66
62
|
children: "Failed"
|
|
67
63
|
})]
|
|
68
64
|
}), /*#__PURE__*/_jsxs("span", {
|
|
69
|
-
className: "
|
|
70
|
-
children: [
|
|
65
|
+
className: "ml-auto text-xs text-faint",
|
|
66
|
+
children: [formatTokensShort(attempt.inputTokens), " in \xB7 ", formatTokensShort(attempt.outputTokens), " out"]
|
|
71
67
|
}), /*#__PURE__*/_jsx("span", {
|
|
72
|
-
className: cn("
|
|
68
|
+
className: cn("shrink-0", attempt.failed ? "text-faint line-through decoration-faint" : "text-foreground"),
|
|
73
69
|
children: formatMicroUsd(attempt.costMicroUsd)
|
|
74
70
|
})]
|
|
75
71
|
});
|
|
@@ -81,39 +77,43 @@ function DetailedCost({
|
|
|
81
77
|
className
|
|
82
78
|
}) {
|
|
83
79
|
const failed = totals.failedAttempts > 0;
|
|
84
|
-
return /*#__PURE__*/_jsxs(
|
|
80
|
+
return /*#__PURE__*/_jsxs("section", {
|
|
85
81
|
"data-slot": "cost",
|
|
86
82
|
"data-variant": "detailed",
|
|
87
83
|
"data-failed": failed || undefined,
|
|
88
84
|
"aria-label": label,
|
|
89
|
-
className: className,
|
|
90
|
-
children: [/*#__PURE__*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
85
|
+
className: cn("flex min-w-0 flex-col", className),
|
|
86
|
+
children: [/*#__PURE__*/_jsxs("header", {
|
|
87
|
+
className: lineRowClass,
|
|
88
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
89
|
+
"aria-hidden": true,
|
|
90
|
+
className: lineIconClass,
|
|
91
|
+
children: /*#__PURE__*/_jsx(CoinsIcon, {
|
|
92
|
+
weight: "bold",
|
|
93
|
+
"aria-hidden": true
|
|
94
|
+
})
|
|
95
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
96
|
+
className: "truncate",
|
|
97
|
+
children: label
|
|
98
|
+
})]
|
|
96
99
|
}), /*#__PURE__*/_jsxs("div", {
|
|
97
|
-
className: "flex flex-
|
|
100
|
+
className: "flex flex-wrap items-baseline gap-x-3 gap-y-0.5 pb-2 pl-6 text-xs tabular-nums",
|
|
98
101
|
children: [/*#__PURE__*/_jsx("span", {
|
|
99
|
-
className: "text-
|
|
102
|
+
className: "text-xl font-semibold tracking-tight text-foreground",
|
|
100
103
|
children: formatMicroUsd(totals.costMicroUsd)
|
|
101
104
|
}), /*#__PURE__*/_jsxs("span", {
|
|
102
|
-
className: "
|
|
103
|
-
children: [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
totals: totals
|
|
107
|
-
})]
|
|
105
|
+
className: "text-faint",
|
|
106
|
+
children: [formatTokensShort(totals.inputTokens), " in \xB7 ", formatTokensShort(totals.outputTokens), " out"]
|
|
107
|
+
}), /*#__PURE__*/_jsx(WastedNote, {
|
|
108
|
+
totals: totals
|
|
108
109
|
})]
|
|
109
|
-
}), /*#__PURE__*/_jsx("ol", {
|
|
110
|
-
className: "flex
|
|
110
|
+
}), attempts.length > 1 && /*#__PURE__*/_jsx("ol", {
|
|
111
|
+
className: "flex max-w-sm flex-col pl-6",
|
|
111
112
|
children: attempts.map((attempt, position) =>
|
|
112
113
|
/*#__PURE__*/
|
|
113
114
|
// biome-ignore lint/suspicious/noArrayIndexKey: attempts carry no id and keep their order
|
|
114
115
|
_jsx(AttemptRow, {
|
|
115
|
-
attempt: attempt
|
|
116
|
-
position: position
|
|
116
|
+
attempt: attempt
|
|
117
117
|
}, position))
|
|
118
118
|
})]
|
|
119
119
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
|
-
import { ChevronDown as ChevronDownIcon } from "@carbon/icons-react";
|
|
5
4
|
import { cn, DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuTrigger } from "@locusgraph/components";
|
|
5
|
+
import { CaretDown as ChevronDownIcon } from "@phosphor-icons/react/ssr";
|
|
6
6
|
import { ModelOptionRow } from "./shared/model-option-row.js";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
export { modelPriceLabel } from "./shared/model-option-row.js";
|
|
@@ -39,7 +39,7 @@ export function ModelPicker(t0) {
|
|
|
39
39
|
const t4 = `${label}: ${selected?.name ?? "none selected"}`;
|
|
40
40
|
let t5;
|
|
41
41
|
if ($[5] !== className) {
|
|
42
|
-
t5 = cn("group inline-flex h-
|
|
42
|
+
t5 = cn("group inline-flex h-control-sm max-w-full items-center gap-1.5 rounded-full px-2.5 text-xs locus-focus-ring transition-colors duration-150 hover:bg-accent disabled:pointer-events-none disabled:opacity-50 data-[state=open]:bg-accent motion-reduce:transition-none", className);
|
|
43
43
|
$[5] = className;
|
|
44
44
|
$[6] = t5;
|
|
45
45
|
} else {
|
|
@@ -71,6 +71,7 @@ export function ModelPicker(t0) {
|
|
|
71
71
|
let t9;
|
|
72
72
|
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
73
73
|
t9 = /*#__PURE__*/_jsx(ChevronDownIcon, {
|
|
74
|
+
weight: "bold",
|
|
74
75
|
"aria-hidden": true,
|
|
75
76
|
className: "size-3 shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180 motion-reduce:transition-none"
|
|
76
77
|
});
|
|
@@ -121,7 +122,7 @@ export function ModelPicker(t0) {
|
|
|
121
122
|
let t13;
|
|
122
123
|
if ($[22] !== t11) {
|
|
123
124
|
t13 = /*#__PURE__*/_jsxs(DropdownMenuLabel, {
|
|
124
|
-
className: "locus-eyebrow flex justify-between gap-3
|
|
125
|
+
className: "locus-eyebrow flex justify-between gap-3 px-3 pt-2.5 pb-1 font-normal",
|
|
125
126
|
children: [t11, t12]
|
|
126
127
|
});
|
|
127
128
|
$[22] = t11;
|
|
@@ -142,7 +143,7 @@ export function ModelPicker(t0) {
|
|
|
142
143
|
t15 = /*#__PURE__*/_jsx(DropdownMenuRadioGroup, {
|
|
143
144
|
value: value,
|
|
144
145
|
onValueChange: onChange,
|
|
145
|
-
className: "flex flex-col
|
|
146
|
+
className: "flex flex-col pb-1",
|
|
146
147
|
children: t14
|
|
147
148
|
});
|
|
148
149
|
$[26] = onChange;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cn } from "@locusgraph/components";
|
|
2
|
-
import { formatCount
|
|
2
|
+
import { formatCount } from "@locusgraph/utils";
|
|
3
3
|
import { MeterBar } from "./meter-marks.js";
|
|
4
|
+
import { wholePercentsOf } from "./usage-totals.js";
|
|
4
5
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
6
|
const statusWord = {
|
|
6
7
|
ok: "Room left",
|
|
@@ -15,11 +16,11 @@ const statusDot = {
|
|
|
15
16
|
function SegmentRow({
|
|
16
17
|
label,
|
|
17
18
|
tokens,
|
|
18
|
-
|
|
19
|
+
percent,
|
|
19
20
|
muted = false
|
|
20
21
|
}) {
|
|
21
22
|
return /*#__PURE__*/_jsxs("li", {
|
|
22
|
-
className: cn("grid grid-cols-[1fr_auto_3rem] items-baseline gap-x-3 px-4 py-
|
|
23
|
+
className: cn("grid grid-cols-[1fr_auto_3rem] items-baseline gap-x-3 px-4 py-1.5 text-xs tabular-nums", muted && "text-muted-foreground"),
|
|
23
24
|
children: [/*#__PURE__*/_jsx("span", {
|
|
24
25
|
className: "truncate",
|
|
25
26
|
children: label
|
|
@@ -28,10 +29,7 @@ function SegmentRow({
|
|
|
28
29
|
children: formatCount(tokens)
|
|
29
30
|
}), /*#__PURE__*/_jsxs("span", {
|
|
30
31
|
className: "text-right font-mono text-muted-foreground",
|
|
31
|
-
children: [
|
|
32
|
-
used: tokens,
|
|
33
|
-
included: limitTokens
|
|
34
|
-
}), "%"]
|
|
32
|
+
children: [percent, "%"]
|
|
35
33
|
})]
|
|
36
34
|
});
|
|
37
35
|
}
|
|
@@ -44,6 +42,7 @@ export function ContextBreakdown({
|
|
|
44
42
|
breakdown
|
|
45
43
|
}) {
|
|
46
44
|
const freeTokens = Math.max(limitTokens - usedTokens, 0);
|
|
45
|
+
const shares = wholePercentsOf([...breakdown.map(segment => segment.tokens), freeTokens], limitTokens);
|
|
47
46
|
return /*#__PURE__*/_jsxs("div", {
|
|
48
47
|
"data-slot": "context-breakdown",
|
|
49
48
|
className: "flex flex-col",
|
|
@@ -74,15 +73,15 @@ export function ContextBreakdown({
|
|
|
74
73
|
status: status
|
|
75
74
|
})]
|
|
76
75
|
}), /*#__PURE__*/_jsxs("ul", {
|
|
77
|
-
className: "flex flex-col
|
|
78
|
-
children: [breakdown.map(segment => /*#__PURE__*/_jsx(SegmentRow, {
|
|
76
|
+
className: "flex flex-col pb-2",
|
|
77
|
+
children: [breakdown.map((segment, index) => /*#__PURE__*/_jsx(SegmentRow, {
|
|
79
78
|
label: segment.label,
|
|
80
79
|
tokens: segment.tokens,
|
|
81
|
-
|
|
80
|
+
percent: shares[index] ?? 0
|
|
82
81
|
}, segment.label)), /*#__PURE__*/_jsx(SegmentRow, {
|
|
83
82
|
label: "Free",
|
|
84
83
|
tokens: freeTokens,
|
|
85
|
-
|
|
84
|
+
percent: shares.at(-1) ?? 0,
|
|
86
85
|
muted: true
|
|
87
86
|
})]
|
|
88
87
|
})]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Checkmark as CheckIcon } from "@carbon/icons-react";
|
|
2
1
|
import { DropdownMenuRadioItem } from "@locusgraph/components";
|
|
3
2
|
import { formatMicroUsd } from "@locusgraph/utils";
|
|
3
|
+
import { Check as CheckIcon } from "@phosphor-icons/react/ssr";
|
|
4
4
|
import { formatTokensShort } from "./usage-totals.js";
|
|
5
5
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
const speedLabel = {
|
|
@@ -25,7 +25,7 @@ function PriceColumn({
|
|
|
25
25
|
const input = model.inputPerMillionMicroUsd;
|
|
26
26
|
const output = model.outputPerMillionMicroUsd;
|
|
27
27
|
return /*#__PURE__*/_jsxs("span", {
|
|
28
|
-
className: "flex flex-col items-end font-mono text-
|
|
28
|
+
className: "flex flex-col items-end font-mono text-2xs text-muted-foreground tabular-nums",
|
|
29
29
|
children: [input !== undefined && /*#__PURE__*/_jsxs("span", {
|
|
30
30
|
children: [formatMicroUsd(input), " in"]
|
|
31
31
|
}), output !== undefined && /*#__PURE__*/_jsxs("span", {
|
|
@@ -53,12 +53,13 @@ export function ModelOptionRow({
|
|
|
53
53
|
children: model.provider
|
|
54
54
|
})]
|
|
55
55
|
}), facts.length > 0 && /*#__PURE__*/_jsx("span", {
|
|
56
|
-
className: "font-mono text-
|
|
56
|
+
className: "font-mono text-2xs text-muted-foreground tabular-nums",
|
|
57
57
|
children: facts.join(" · ")
|
|
58
58
|
})]
|
|
59
59
|
}), /*#__PURE__*/_jsx(PriceColumn, {
|
|
60
60
|
model: model
|
|
61
61
|
}), /*#__PURE__*/_jsx(CheckIcon, {
|
|
62
|
+
weight: "bold",
|
|
62
63
|
"aria-hidden": true,
|
|
63
64
|
className: "size-4 text-foreground opacity-0 group-data-[state=checked]:opacity-100"
|
|
64
65
|
})]
|
|
@@ -7,9 +7,8 @@ export function isWastedStep(step) {
|
|
|
7
7
|
}
|
|
8
8
|
function barTone(step) {
|
|
9
9
|
if (isWastedStep(step)) return "bg-destructive";
|
|
10
|
-
if (step.status === "retried") return "bg-warn/40";
|
|
11
10
|
if (step.status === "running") return "bg-warn/60 motion-safe:animate-pulse";
|
|
12
|
-
return "bg-
|
|
11
|
+
return "bg-muted-foreground/50";
|
|
13
12
|
}
|
|
14
13
|
const statusMark = {
|
|
15
14
|
failed: {
|
|
@@ -22,11 +21,11 @@ const statusMark = {
|
|
|
22
21
|
},
|
|
23
22
|
running: {
|
|
24
23
|
text: "Running",
|
|
25
|
-
className: "text-muted-foreground"
|
|
24
|
+
className: "text-muted-foreground motion-safe:locus-shimmer"
|
|
26
25
|
},
|
|
27
26
|
skipped: {
|
|
28
27
|
text: "Skipped",
|
|
29
|
-
className: "text-
|
|
28
|
+
className: "font-normal text-faint"
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
31
|
function barWidth(cost, maxCost) {
|
|
@@ -47,30 +46,30 @@ export function StepCostRow({
|
|
|
47
46
|
"data-status": step.status,
|
|
48
47
|
"data-wasted": wasted || undefined,
|
|
49
48
|
"aria-label": `${step.title}: ${formatMicroUsd(cost)}, ${share}% of run${mark ? `, ${mark.text.toLowerCase()}` : ""}`,
|
|
50
|
-
className: "grid grid-cols-[minmax(0,11rem)_1fr_3.5rem_4.5rem] items-center gap-x-4 gap-y-1.5
|
|
49
|
+
className: "grid grid-cols-[minmax(0,11rem)_1fr_3.5rem_4.5rem] items-center gap-x-4 gap-y-1.5 py-1 text-sm tabular-nums max-sm:grid-cols-[1fr_auto_auto]",
|
|
51
50
|
children: [/*#__PURE__*/_jsxs("span", {
|
|
52
|
-
className: "flex min-w-0 items-baseline gap-2",
|
|
51
|
+
className: "flex min-w-0 items-baseline gap-x-2 max-sm:flex-wrap",
|
|
53
52
|
children: [/*#__PURE__*/_jsx("span", {
|
|
54
|
-
className: cn("truncate", step.status === "skipped" && "text-
|
|
53
|
+
className: cn("text-foreground normal-nums sm:truncate", step.status === "skipped" && "text-faint"),
|
|
55
54
|
children: step.title
|
|
56
55
|
}), mark && /*#__PURE__*/_jsx("span", {
|
|
57
|
-
className: cn("shrink-0
|
|
56
|
+
className: cn("shrink-0 text-xs font-medium", mark.className),
|
|
58
57
|
children: mark.text
|
|
59
58
|
})]
|
|
60
59
|
}), /*#__PURE__*/_jsx("span", {
|
|
61
60
|
"aria-hidden": true,
|
|
62
|
-
className: "relative h-1
|
|
61
|
+
className: "relative h-1 w-full overflow-hidden rounded-full bg-muted-foreground/10 max-sm:col-span-3 max-sm:row-start-2",
|
|
63
62
|
children: /*#__PURE__*/_jsx("span", {
|
|
64
|
-
className: cn("absolute inset-y-0 left-0 transition-[width] duration-300 motion-reduce:transition-none", barTone(step)),
|
|
63
|
+
className: cn("absolute inset-y-0 left-0 rounded-full transition-[width] duration-300 motion-reduce:transition-none", barTone(step)),
|
|
65
64
|
style: {
|
|
66
65
|
width: `${barWidth(cost, maxCost)}%`
|
|
67
66
|
}
|
|
68
67
|
})
|
|
69
68
|
}), /*#__PURE__*/_jsx("span", {
|
|
70
|
-
className: "text-right
|
|
69
|
+
className: "text-right text-xs text-faint",
|
|
71
70
|
children: step.durationMs !== undefined ? formatDuration(step.durationMs) : ""
|
|
72
71
|
}), /*#__PURE__*/_jsx("span", {
|
|
73
|
-
className: cn("text-right
|
|
72
|
+
className: cn("text-right", wasted ? "text-destructive" : "text-foreground"),
|
|
74
73
|
children: formatMicroUsd(cost)
|
|
75
74
|
})]
|
|
76
75
|
});
|
|
@@ -9,3 +9,4 @@ export type UsageTotals = {
|
|
|
9
9
|
export declare function sumUsage(attempts: RunUsage[]): UsageTotals;
|
|
10
10
|
export declare function formatTokensShort(tokens: number): string;
|
|
11
11
|
export declare function formatDuration(durationMs: number): string;
|
|
12
|
+
export declare function wholePercentsOf(parts: number[], whole: number): number[];
|
|
@@ -18,7 +18,7 @@ const compactCount = new Intl.NumberFormat("en-US", {
|
|
|
18
18
|
maximumFractionDigits: 1
|
|
19
19
|
});
|
|
20
20
|
export function formatTokensShort(tokens) {
|
|
21
|
-
return compactCount.format(tokens);
|
|
21
|
+
return compactCount.format(tokens).replace("K", "k");
|
|
22
22
|
}
|
|
23
23
|
export function formatDuration(durationMs) {
|
|
24
24
|
if (durationMs < 1000) return `${Math.round(durationMs)}ms`;
|
|
@@ -28,3 +28,21 @@ export function formatDuration(durationMs) {
|
|
|
28
28
|
const remainder = Math.round(seconds % 60);
|
|
29
29
|
return `${minutes}m ${String(remainder).padStart(2, "0")}s`;
|
|
30
30
|
}
|
|
31
|
+
export function wholePercentsOf(parts, whole) {
|
|
32
|
+
if (whole <= 0) return parts.map(() => 0);
|
|
33
|
+
const exact = parts.map(part => part / whole * 100);
|
|
34
|
+
const sum = parts.reduce((total, part) => total + part, 0);
|
|
35
|
+
if (sum !== whole) return exact.map(percent => Math.round(percent));
|
|
36
|
+
const floors = exact.map(percent => Math.floor(percent));
|
|
37
|
+
const missing = 100 - floors.reduce((total, percent) => total + percent, 0);
|
|
38
|
+
const byLargestRemainder = exact.map((percent, index) => ({
|
|
39
|
+
index,
|
|
40
|
+
remainder: percent - Math.floor(percent)
|
|
41
|
+
})).sort((first, second) => second.remainder - first.remainder);
|
|
42
|
+
for (const {
|
|
43
|
+
index
|
|
44
|
+
} of byLargestRemainder.slice(0, missing)) {
|
|
45
|
+
floors[index] = (floors[index] ?? 0) + 1;
|
|
46
|
+
}
|
|
47
|
+
return floors;
|
|
48
|
+
}
|