opencode-tally 0.0.0-stage → 1.0.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 +46 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +269 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/analyzer.d.ts +36 -0
- package/dist/lib/analyzer.d.ts.map +1 -0
- package/dist/lib/analyzer.js +308 -0
- package/dist/lib/analyzer.js.map +1 -0
- package/dist/lib/config.d.ts +28 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +289 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/context.d.ts +69 -0
- package/dist/lib/context.d.ts.map +1 -0
- package/dist/lib/context.js +337 -0
- package/dist/lib/context.js.map +1 -0
- package/dist/lib/cost.d.ts +24 -0
- package/dist/lib/cost.d.ts.map +1 -0
- package/dist/lib/cost.js +222 -0
- package/dist/lib/cost.js.map +1 -0
- package/dist/lib/formatter-cost-sections.d.ts +17 -0
- package/dist/lib/formatter-cost-sections.d.ts.map +1 -0
- package/dist/lib/formatter-cost-sections.js +75 -0
- package/dist/lib/formatter-cost-sections.js.map +1 -0
- package/dist/lib/formatter-helpers.d.ts +37 -0
- package/dist/lib/formatter-helpers.d.ts.map +1 -0
- package/dist/lib/formatter-helpers.js +108 -0
- package/dist/lib/formatter-helpers.js.map +1 -0
- package/dist/lib/formatter-insight-sections.d.ts +11 -0
- package/dist/lib/formatter-insight-sections.d.ts.map +1 -0
- package/dist/lib/formatter-insight-sections.js +310 -0
- package/dist/lib/formatter-insight-sections.js.map +1 -0
- package/dist/lib/formatter.d.ts +12 -0
- package/dist/lib/formatter.d.ts.map +1 -0
- package/dist/lib/formatter.js +347 -0
- package/dist/lib/formatter.js.map +1 -0
- package/dist/lib/jsonc.d.ts +2 -0
- package/dist/lib/jsonc.d.ts.map +1 -0
- package/dist/lib/jsonc.js +85 -0
- package/dist/lib/jsonc.js.map +1 -0
- package/dist/lib/metadata.d.ts +20 -0
- package/dist/lib/metadata.d.ts.map +1 -0
- package/dist/lib/metadata.js +130 -0
- package/dist/lib/metadata.js.map +1 -0
- package/dist/lib/opencode.d.ts +41 -0
- package/dist/lib/opencode.d.ts.map +1 -0
- package/dist/lib/opencode.js +180 -0
- package/dist/lib/opencode.js.map +1 -0
- package/dist/lib/quota/auth.d.ts +80 -0
- package/dist/lib/quota/auth.d.ts.map +1 -0
- package/dist/lib/quota/auth.js +337 -0
- package/dist/lib/quota/auth.js.map +1 -0
- package/dist/lib/quota/command.d.ts +14 -0
- package/dist/lib/quota/command.d.ts.map +1 -0
- package/dist/lib/quota/command.js +87 -0
- package/dist/lib/quota/command.js.map +1 -0
- package/dist/lib/quota/errors.d.ts +18 -0
- package/dist/lib/quota/errors.d.ts.map +1 -0
- package/dist/lib/quota/errors.js +18 -0
- package/dist/lib/quota/errors.js.map +1 -0
- package/dist/lib/quota/format.d.ts +25 -0
- package/dist/lib/quota/format.d.ts.map +1 -0
- package/dist/lib/quota/format.js +143 -0
- package/dist/lib/quota/format.js.map +1 -0
- package/dist/lib/quota/http.d.ts +14 -0
- package/dist/lib/quota/http.d.ts.map +1 -0
- package/dist/lib/quota/http.js +133 -0
- package/dist/lib/quota/http.js.map +1 -0
- package/dist/lib/quota/providers/alibaba-token-plan.d.ts +9 -0
- package/dist/lib/quota/providers/alibaba-token-plan.d.ts.map +1 -0
- package/dist/lib/quota/providers/alibaba-token-plan.js +176 -0
- package/dist/lib/quota/providers/alibaba-token-plan.js.map +1 -0
- package/dist/lib/quota/providers/claude-code.d.ts +7 -0
- package/dist/lib/quota/providers/claude-code.d.ts.map +1 -0
- package/dist/lib/quota/providers/claude-code.js +250 -0
- package/dist/lib/quota/providers/claude-code.js.map +1 -0
- package/dist/lib/quota/providers/codex.d.ts +8 -0
- package/dist/lib/quota/providers/codex.d.ts.map +1 -0
- package/dist/lib/quota/providers/codex.js +207 -0
- package/dist/lib/quota/providers/codex.js.map +1 -0
- package/dist/lib/quota/providers/commandcode.d.ts +8 -0
- package/dist/lib/quota/providers/commandcode.d.ts.map +1 -0
- package/dist/lib/quota/providers/commandcode.js +220 -0
- package/dist/lib/quota/providers/commandcode.js.map +1 -0
- package/dist/lib/quota/providers/deepseek.d.ts +8 -0
- package/dist/lib/quota/providers/deepseek.d.ts.map +1 -0
- package/dist/lib/quota/providers/deepseek.js +116 -0
- package/dist/lib/quota/providers/deepseek.js.map +1 -0
- package/dist/lib/quota/providers/minimax.d.ts +8 -0
- package/dist/lib/quota/providers/minimax.d.ts.map +1 -0
- package/dist/lib/quota/providers/minimax.js +149 -0
- package/dist/lib/quota/providers/minimax.js.map +1 -0
- package/dist/lib/quota/providers/moonshotai.d.ts +14 -0
- package/dist/lib/quota/providers/moonshotai.d.ts.map +1 -0
- package/dist/lib/quota/providers/moonshotai.js +114 -0
- package/dist/lib/quota/providers/moonshotai.js.map +1 -0
- package/dist/lib/quota/providers/novita-ai.d.ts +8 -0
- package/dist/lib/quota/providers/novita-ai.d.ts.map +1 -0
- package/dist/lib/quota/providers/novita-ai.js +98 -0
- package/dist/lib/quota/providers/novita-ai.js.map +1 -0
- package/dist/lib/quota/providers/opencode-go.d.ts +8 -0
- package/dist/lib/quota/providers/opencode-go.d.ts.map +1 -0
- package/dist/lib/quota/providers/opencode-go.js +94 -0
- package/dist/lib/quota/providers/opencode-go.js.map +1 -0
- package/dist/lib/quota/providers/openrouter.d.ts +8 -0
- package/dist/lib/quota/providers/openrouter.d.ts.map +1 -0
- package/dist/lib/quota/providers/openrouter.js +147 -0
- package/dist/lib/quota/providers/openrouter.js.map +1 -0
- package/dist/lib/quota/providers/qwen.d.ts +9 -0
- package/dist/lib/quota/providers/qwen.d.ts.map +1 -0
- package/dist/lib/quota/providers/qwen.js +165 -0
- package/dist/lib/quota/providers/qwen.js.map +1 -0
- package/dist/lib/quota/providers/synthetic.d.ts +8 -0
- package/dist/lib/quota/providers/synthetic.d.ts.map +1 -0
- package/dist/lib/quota/providers/synthetic.js +214 -0
- package/dist/lib/quota/providers/synthetic.js.map +1 -0
- package/dist/lib/quota/providers/zai-coding-plan.d.ts +8 -0
- package/dist/lib/quota/providers/zai-coding-plan.d.ts.map +1 -0
- package/dist/lib/quota/providers/zai-coding-plan.js +234 -0
- package/dist/lib/quota/providers/zai-coding-plan.js.map +1 -0
- package/dist/lib/quota/registry.d.ts +34 -0
- package/dist/lib/quota/registry.d.ts.map +1 -0
- package/dist/lib/quota/registry.js +84 -0
- package/dist/lib/quota/registry.js.map +1 -0
- package/dist/lib/quota/rpc.d.ts +5 -0
- package/dist/lib/quota/rpc.d.ts.map +1 -0
- package/dist/lib/quota/rpc.js +7 -0
- package/dist/lib/quota/rpc.js.map +1 -0
- package/dist/lib/quota/snapshot.d.ts +23 -0
- package/dist/lib/quota/snapshot.d.ts.map +1 -0
- package/dist/lib/quota/snapshot.js +197 -0
- package/dist/lib/quota/snapshot.js.map +1 -0
- package/dist/lib/quota/types.d.ts +195 -0
- package/dist/lib/quota/types.d.ts.map +1 -0
- package/dist/lib/quota/types.js +4 -0
- package/dist/lib/quota/types.js.map +1 -0
- package/dist/lib/quota/url.d.ts +7 -0
- package/dist/lib/quota/url.d.ts.map +1 -0
- package/dist/lib/quota/url.js +31 -0
- package/dist/lib/quota/url.js.map +1 -0
- package/dist/lib/quota/usage.d.ts +18 -0
- package/dist/lib/quota/usage.d.ts.map +1 -0
- package/dist/lib/quota/usage.js +78 -0
- package/dist/lib/quota/usage.js.map +1 -0
- package/dist/lib/report.d.ts +7 -0
- package/dist/lib/report.d.ts.map +1 -0
- package/dist/lib/report.js +102 -0
- package/dist/lib/report.js.map +1 -0
- package/dist/lib/rpc.d.ts +118 -0
- package/dist/lib/rpc.d.ts.map +1 -0
- package/dist/lib/rpc.js +46 -0
- package/dist/lib/rpc.js.map +1 -0
- package/dist/lib/session-workflow.d.ts +34 -0
- package/dist/lib/session-workflow.d.ts.map +1 -0
- package/dist/lib/session-workflow.js +102 -0
- package/dist/lib/session-workflow.js.map +1 -0
- package/dist/lib/skill.d.ts +40 -0
- package/dist/lib/skill.d.ts.map +1 -0
- package/dist/lib/skill.js +222 -0
- package/dist/lib/skill.js.map +1 -0
- package/dist/lib/subagent.d.ts +14 -0
- package/dist/lib/subagent.d.ts.map +1 -0
- package/dist/lib/subagent.js +152 -0
- package/dist/lib/subagent.js.map +1 -0
- package/dist/lib/telemetry.d.ts +34 -0
- package/dist/lib/telemetry.d.ts.map +1 -0
- package/dist/lib/telemetry.js +139 -0
- package/dist/lib/telemetry.js.map +1 -0
- package/dist/lib/tokenizer.d.ts +23 -0
- package/dist/lib/tokenizer.d.ts.map +1 -0
- package/dist/lib/tokenizer.js +213 -0
- package/dist/lib/tokenizer.js.map +1 -0
- package/dist/lib/types.d.ts +338 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/view.d.ts +5 -0
- package/dist/lib/view.d.ts.map +1 -0
- package/dist/lib/view.js +225 -0
- package/dist/lib/view.js.map +1 -0
- package/dist/lib/warnings.d.ts +8 -0
- package/dist/lib/warnings.d.ts.map +1 -0
- package/dist/lib/warnings.js +31 -0
- package/dist/lib/warnings.js.map +1 -0
- package/dist/tui.js +2062 -0
- package/models.json +31004 -0
- package/package.json +73 -4
- package/tally-config.json +25 -0
- package/tally-config.schema.json +216 -0
package/dist/tui.js
ADDED
|
@@ -0,0 +1,2062 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/tui.tsx
|
|
3
|
+
import { createComponent as _$createComponent5 } from "@opentui/solid";
|
|
4
|
+
import { Plugin } from "@opencode/plugin/tui";
|
|
5
|
+
import { Show as Show2 } from "solid-js";
|
|
6
|
+
|
|
7
|
+
// src/panel/ReportPanel.tsx
|
|
8
|
+
import { use as _$use } from "@opentui/solid";
|
|
9
|
+
import { createTextNode as _$createTextNode2 } from "@opentui/solid";
|
|
10
|
+
import { effect as _$effect3 } from "@opentui/solid";
|
|
11
|
+
import { insertNode as _$insertNode3 } from "@opentui/solid";
|
|
12
|
+
import { insert as _$insert3 } from "@opentui/solid";
|
|
13
|
+
import { setProp as _$setProp3 } from "@opentui/solid";
|
|
14
|
+
import { createElement as _$createElement3 } from "@opentui/solid";
|
|
15
|
+
import { memo as _$memo3 } from "@opentui/solid";
|
|
16
|
+
import { createComponent as _$createComponent3 } from "@opentui/solid";
|
|
17
|
+
import { TextAttributes as TextAttributes3 } from "@opentui/core";
|
|
18
|
+
import { createEffect, createMemo, createResource, For as For3, on } from "solid-js";
|
|
19
|
+
|
|
20
|
+
// src/lib/rpc.ts
|
|
21
|
+
function toError(failure) {
|
|
22
|
+
if (failure instanceof Error)
|
|
23
|
+
return failure;
|
|
24
|
+
if (failure && typeof failure === "object" && "message" in failure && typeof failure.message === "string") {
|
|
25
|
+
return new Error("type" in failure && failure.type === "rpc.unavailable" ? `${failure.message}. The Tally server plugin is not loaded for this session's project.` : failure.message, { cause: failure });
|
|
26
|
+
}
|
|
27
|
+
return new Error(String(failure), { cause: failure });
|
|
28
|
+
}
|
|
29
|
+
var TallyRpc = {
|
|
30
|
+
id: "tally",
|
|
31
|
+
methods: {
|
|
32
|
+
report: {
|
|
33
|
+
input: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
sessionID: { type: "string" },
|
|
37
|
+
limitMessages: { type: "integer", minimum: 1, maximum: 10 },
|
|
38
|
+
includeSubagents: { type: "boolean" }
|
|
39
|
+
},
|
|
40
|
+
required: ["sessionID"],
|
|
41
|
+
additionalProperties: false
|
|
42
|
+
},
|
|
43
|
+
output: { type: "object" },
|
|
44
|
+
errors: {
|
|
45
|
+
empty_session: { type: "object", additionalProperties: false },
|
|
46
|
+
analysis_failed: { type: "object", additionalProperties: false }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
quota: {
|
|
50
|
+
input: { type: "object", properties: {}, additionalProperties: false },
|
|
51
|
+
output: { type: "object" }
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
events: {}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/lib/quota/usage.ts
|
|
58
|
+
function quotaUsedPercent(quota) {
|
|
59
|
+
return quota._tag === "Percentage" || quota._tag === "Count" ? quota.usedPercent : null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/lib/quota/format.ts
|
|
63
|
+
function formatDuration(ms, now) {
|
|
64
|
+
if (!Number.isFinite(ms) || ms <= 0) {
|
|
65
|
+
return "now";
|
|
66
|
+
}
|
|
67
|
+
const minutes = Math.ceil(ms / 60000);
|
|
68
|
+
if (minutes < 60) {
|
|
69
|
+
return `${minutes}m`;
|
|
70
|
+
}
|
|
71
|
+
const hours = Math.floor(minutes / 60);
|
|
72
|
+
const remainder = minutes % 60;
|
|
73
|
+
if (hours < 24) {
|
|
74
|
+
if (remainder === 0) {
|
|
75
|
+
return `${hours}h`;
|
|
76
|
+
}
|
|
77
|
+
if (remainder === 30) {
|
|
78
|
+
return `${hours}.5h`;
|
|
79
|
+
}
|
|
80
|
+
return `${hours}h ${remainder}m`;
|
|
81
|
+
}
|
|
82
|
+
const days = Math.floor(hours / 24);
|
|
83
|
+
const hourRemainder = hours % 24;
|
|
84
|
+
return hourRemainder === 0 ? `${days}d` : `${days}d ${hourRemainder}h`;
|
|
85
|
+
}
|
|
86
|
+
var formatPercent = (value) => value === null ? "?" : `${Math.round(value)}%`;
|
|
87
|
+
var CURRENCY_SYMBOLS = new Map([
|
|
88
|
+
["CNY", "\xA5"],
|
|
89
|
+
["EUR", "\u20AC"],
|
|
90
|
+
["GBP", "\xA3"],
|
|
91
|
+
["JPY", "\xA5"],
|
|
92
|
+
["KRW", "\u20A9"],
|
|
93
|
+
["USD", "$"]
|
|
94
|
+
]);
|
|
95
|
+
var formatBalance = (quota) => {
|
|
96
|
+
const symbol = CURRENCY_SYMBOLS.get(quota.unit.toUpperCase());
|
|
97
|
+
const sign = quota.remaining < 0 ? "-" : "";
|
|
98
|
+
const rounded = symbol ? Math.abs(quota.remaining).toFixed(2) : "";
|
|
99
|
+
const displayAmount = symbol && quota.remaining !== 0 && Number(rounded) === 0 ? "<0.01" : rounded;
|
|
100
|
+
const amount = symbol ? `${sign}${symbol}${displayAmount}` : `${quota.remaining} ${quota.unit}`;
|
|
101
|
+
return `${amount} remaining`;
|
|
102
|
+
};
|
|
103
|
+
var formatCountQuota = (quota) => {
|
|
104
|
+
const symbol = CURRENCY_SYMBOLS.get(quota.unit?.toUpperCase() ?? "");
|
|
105
|
+
const amount = (value) => {
|
|
106
|
+
if (symbol)
|
|
107
|
+
return `${symbol}${value.toFixed(2)}`;
|
|
108
|
+
return quota.unit ? `${value} ${quota.unit}` : `${value}`;
|
|
109
|
+
};
|
|
110
|
+
return `${amount(quota.current)} / ${amount(quota.total)} used`;
|
|
111
|
+
};
|
|
112
|
+
function formatQuotaText(quota, usedSuffix = false) {
|
|
113
|
+
if (quota._tag === "Balance") {
|
|
114
|
+
return formatBalance(quota);
|
|
115
|
+
}
|
|
116
|
+
if (quota._tag === "Count") {
|
|
117
|
+
return formatCountQuota(quota);
|
|
118
|
+
}
|
|
119
|
+
const text = formatPercent(quotaUsedPercent(quota));
|
|
120
|
+
return usedSuffix ? `${text} used` : text;
|
|
121
|
+
}
|
|
122
|
+
function scaledCountText(scaled) {
|
|
123
|
+
const text = scaled.toFixed(1);
|
|
124
|
+
return text.endsWith(".0") ? text.slice(0, -2) : text;
|
|
125
|
+
}
|
|
126
|
+
function formatTokenCount(value) {
|
|
127
|
+
if (value < 1000) {
|
|
128
|
+
return value.toString();
|
|
129
|
+
}
|
|
130
|
+
if (value < 1e6) {
|
|
131
|
+
return `${scaledCountText(value / 1000)}K`;
|
|
132
|
+
}
|
|
133
|
+
return `${scaledCountText(value / 1e6)}M`;
|
|
134
|
+
}
|
|
135
|
+
function formatTimestamp(ms) {
|
|
136
|
+
const date = new Date(ms);
|
|
137
|
+
const h = date.getHours().toString().padStart(2, "0");
|
|
138
|
+
const m = date.getMinutes().toString().padStart(2, "0");
|
|
139
|
+
return `${h}:${m}`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/ui/format.ts
|
|
143
|
+
var integer = new Intl.NumberFormat("en-US");
|
|
144
|
+
function formatTokens(value, compact) {
|
|
145
|
+
return compact ? formatTokenCount(value).toLowerCase() : integer.format(value);
|
|
146
|
+
}
|
|
147
|
+
function formatPercent2(part, whole) {
|
|
148
|
+
return whole > 0 ? `${(part / whole * 100).toFixed(1)}%` : "";
|
|
149
|
+
}
|
|
150
|
+
function formatUsd(value) {
|
|
151
|
+
return `$${value.toFixed(value !== 0 && Math.abs(value) < 0.01 ? 4 : 2)}`;
|
|
152
|
+
}
|
|
153
|
+
function barCells(percent, width) {
|
|
154
|
+
if (!Number.isFinite(percent) || percent <= 0) {
|
|
155
|
+
return { filled: 0, empty: width };
|
|
156
|
+
}
|
|
157
|
+
const filled = Math.max(1, Math.min(width, Math.round(percent / 100 * width)));
|
|
158
|
+
return { filled, empty: width - filled };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// src/ui/primitives.tsx
|
|
162
|
+
import { createTextNode as _$createTextNode } from "@opentui/solid";
|
|
163
|
+
import { createComponent as _$createComponent } from "@opentui/solid";
|
|
164
|
+
import { memo as _$memo } from "@opentui/solid";
|
|
165
|
+
import { effect as _$effect } from "@opentui/solid";
|
|
166
|
+
import { insertNode as _$insertNode } from "@opentui/solid";
|
|
167
|
+
import { insert as _$insert } from "@opentui/solid";
|
|
168
|
+
import { setProp as _$setProp } from "@opentui/solid";
|
|
169
|
+
import { createElement as _$createElement } from "@opentui/solid";
|
|
170
|
+
import { TextAttributes } from "@opentui/core";
|
|
171
|
+
import { For } from "solid-js";
|
|
172
|
+
function accent(theme) {
|
|
173
|
+
return theme.categorical[0]?.[200] ?? theme.text.base;
|
|
174
|
+
}
|
|
175
|
+
function Bar(props) {
|
|
176
|
+
return (() => {
|
|
177
|
+
var _el$ = _$createElement("box"), _el$2 = _$createElement("text"), _el$3 = _$createElement("text");
|
|
178
|
+
_$insertNode(_el$, _el$2);
|
|
179
|
+
_$insertNode(_el$, _el$3);
|
|
180
|
+
_$setProp(_el$, "flexDirection", "row");
|
|
181
|
+
_$setProp(_el$2, "selectable", false);
|
|
182
|
+
_$insert(_el$2, () => "\u2588".repeat(props.cells.filled));
|
|
183
|
+
_$setProp(_el$3, "selectable", false);
|
|
184
|
+
_$insert(_el$3, () => "\u2591".repeat(props.cells.empty));
|
|
185
|
+
_$effect((_p$) => {
|
|
186
|
+
var _v$ = props.width, _v$2 = props.fg ?? accent(props.theme), _v$3 = props.theme.text.faint;
|
|
187
|
+
_v$ !== _p$.e && (_p$.e = _$setProp(_el$, "width", _v$, _p$.e));
|
|
188
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp(_el$2, "fg", _v$2, _p$.t));
|
|
189
|
+
_v$3 !== _p$.a && (_p$.a = _$setProp(_el$3, "fg", _v$3, _p$.a));
|
|
190
|
+
return _p$;
|
|
191
|
+
}, {
|
|
192
|
+
e: undefined,
|
|
193
|
+
t: undefined,
|
|
194
|
+
a: undefined
|
|
195
|
+
});
|
|
196
|
+
return _el$;
|
|
197
|
+
})();
|
|
198
|
+
}
|
|
199
|
+
function Row(props) {
|
|
200
|
+
const value = () => {
|
|
201
|
+
const text = props.value ?? "";
|
|
202
|
+
const width = props.valueWidth ?? 10;
|
|
203
|
+
return text.length < width ? text.padStart(width) : text;
|
|
204
|
+
};
|
|
205
|
+
return (() => {
|
|
206
|
+
var _el$4 = _$createElement("box"), _el$5 = _$createElement("box"), _el$6 = _$createElement("text"), _el$7 = _$createElement("text");
|
|
207
|
+
_$insertNode(_el$4, _el$5);
|
|
208
|
+
_$setProp(_el$4, "flexDirection", "column");
|
|
209
|
+
_$setProp(_el$4, "flexShrink", 0);
|
|
210
|
+
_$insertNode(_el$5, _el$6);
|
|
211
|
+
_$insertNode(_el$5, _el$7);
|
|
212
|
+
_$setProp(_el$5, "flexDirection", "row");
|
|
213
|
+
_$setProp(_el$5, "gap", 1);
|
|
214
|
+
_$setProp(_el$5, "height", 1);
|
|
215
|
+
_$setProp(_el$6, "wrapMode", "none");
|
|
216
|
+
_$setProp(_el$6, "truncate", true);
|
|
217
|
+
_$insert(_el$6, () => props.label);
|
|
218
|
+
_$insert(_el$5, (() => {
|
|
219
|
+
var _c$ = _$memo(() => !!(props.cells && props.barWidth !== undefined));
|
|
220
|
+
return () => _c$() ? (() => {
|
|
221
|
+
var _el$8 = _$createElement("box");
|
|
222
|
+
_$setProp(_el$8, "flexDirection", "row");
|
|
223
|
+
_$setProp(_el$8, "flexShrink", 0);
|
|
224
|
+
_$insert(_el$8, (() => {
|
|
225
|
+
var _c$3 = _$memo(() => !!props.brackets);
|
|
226
|
+
return () => _c$3() ? (() => {
|
|
227
|
+
var _el$9 = _$createElement("text");
|
|
228
|
+
_$insertNode(_el$9, _$createTextNode(`[`));
|
|
229
|
+
_$setProp(_el$9, "selectable", false);
|
|
230
|
+
_$effect((_$p) => _$setProp(_el$9, "fg", props.theme.text.faint, _$p));
|
|
231
|
+
return _el$9;
|
|
232
|
+
})() : null;
|
|
233
|
+
})(), null);
|
|
234
|
+
_$insert(_el$8, _$createComponent(Bar, {
|
|
235
|
+
get theme() {
|
|
236
|
+
return props.theme;
|
|
237
|
+
},
|
|
238
|
+
get cells() {
|
|
239
|
+
return props.cells;
|
|
240
|
+
},
|
|
241
|
+
get width() {
|
|
242
|
+
return props.barWidth;
|
|
243
|
+
},
|
|
244
|
+
get fg() {
|
|
245
|
+
return props.fg;
|
|
246
|
+
}
|
|
247
|
+
}), null);
|
|
248
|
+
_$insert(_el$8, (() => {
|
|
249
|
+
var _c$4 = _$memo(() => !!props.brackets);
|
|
250
|
+
return () => _c$4() ? (() => {
|
|
251
|
+
var _el$1 = _$createElement("text");
|
|
252
|
+
_$insertNode(_el$1, _$createTextNode(`]`));
|
|
253
|
+
_$setProp(_el$1, "selectable", false);
|
|
254
|
+
_$effect((_$p) => _$setProp(_el$1, "fg", props.theme.text.faint, _$p));
|
|
255
|
+
return _el$1;
|
|
256
|
+
})() : null;
|
|
257
|
+
})(), null);
|
|
258
|
+
return _el$8;
|
|
259
|
+
})() : null;
|
|
260
|
+
})(), _el$7);
|
|
261
|
+
_$insert(_el$5, (() => {
|
|
262
|
+
var _c$2 = _$memo(() => !!(props.suffix ?? props.percent));
|
|
263
|
+
return () => _c$2() ? (() => {
|
|
264
|
+
var _el$11 = _$createElement("text");
|
|
265
|
+
_$setProp(_el$11, "width", 7);
|
|
266
|
+
_$setProp(_el$11, "wrapMode", "none");
|
|
267
|
+
_$insert(_el$11, () => (props.suffix ?? props.percent).padStart(6));
|
|
268
|
+
_$effect((_$p) => _$setProp(_el$11, "fg", props.theme.text.muted, _$p));
|
|
269
|
+
return _el$11;
|
|
270
|
+
})() : null;
|
|
271
|
+
})(), _el$7);
|
|
272
|
+
_$setProp(_el$7, "wrapMode", "none");
|
|
273
|
+
_$insert(_el$7, value);
|
|
274
|
+
_$insert(_el$4, _$createComponent(For, {
|
|
275
|
+
get each() {
|
|
276
|
+
return props.detail ?? [];
|
|
277
|
+
},
|
|
278
|
+
children: (line) => (() => {
|
|
279
|
+
var _el$12 = _$createElement("text");
|
|
280
|
+
_$setProp(_el$12, "wrapMode", "none");
|
|
281
|
+
_$setProp(_el$12, "truncate", true);
|
|
282
|
+
_$insert(_el$12, ` \u2192 ${line}`);
|
|
283
|
+
_$effect((_$p) => _$setProp(_el$12, "fg", props.theme.text.faint, _$p));
|
|
284
|
+
return _el$12;
|
|
285
|
+
})()
|
|
286
|
+
}), null);
|
|
287
|
+
_$effect((_p$) => {
|
|
288
|
+
var _v$4 = props.theme.text.muted, _v$5 = props.labelWidth ?? 24, _v$6 = props.theme.text.base, _v$7 = props.strong ? TextAttributes.BOLD : TextAttributes.NONE, _v$8 = props.valueWidth;
|
|
289
|
+
_v$4 !== _p$.e && (_p$.e = _$setProp(_el$6, "fg", _v$4, _p$.e));
|
|
290
|
+
_v$5 !== _p$.t && (_p$.t = _$setProp(_el$6, "width", _v$5, _p$.t));
|
|
291
|
+
_v$6 !== _p$.a && (_p$.a = _$setProp(_el$7, "fg", _v$6, _p$.a));
|
|
292
|
+
_v$7 !== _p$.o && (_p$.o = _$setProp(_el$7, "attributes", _v$7, _p$.o));
|
|
293
|
+
_v$8 !== _p$.i && (_p$.i = _$setProp(_el$7, "width", _v$8, _p$.i));
|
|
294
|
+
return _p$;
|
|
295
|
+
}, {
|
|
296
|
+
e: undefined,
|
|
297
|
+
t: undefined,
|
|
298
|
+
a: undefined,
|
|
299
|
+
o: undefined,
|
|
300
|
+
i: undefined
|
|
301
|
+
});
|
|
302
|
+
return _el$4;
|
|
303
|
+
})();
|
|
304
|
+
}
|
|
305
|
+
function Line(props) {
|
|
306
|
+
return (() => {
|
|
307
|
+
var _el$13 = _$createElement("box"), _el$14 = _$createElement("text"), _el$15 = _$createElement("text");
|
|
308
|
+
_$insertNode(_el$13, _el$14);
|
|
309
|
+
_$insertNode(_el$13, _el$15);
|
|
310
|
+
_$setProp(_el$13, "flexDirection", "row");
|
|
311
|
+
_$setProp(_el$13, "gap", 1);
|
|
312
|
+
_$setProp(_el$13, "height", 1);
|
|
313
|
+
_$setProp(_el$14, "wrapMode", "none");
|
|
314
|
+
_$setProp(_el$14, "truncate", true);
|
|
315
|
+
_$insert(_el$14, () => props.label);
|
|
316
|
+
_$setProp(_el$15, "wrapMode", "none");
|
|
317
|
+
_$insert(_el$15, () => props.value);
|
|
318
|
+
_$effect((_p$) => {
|
|
319
|
+
var _v$9 = props.theme.text.muted, _v$0 = props.labelWidth ?? 24, _v$1 = props.theme.text.base, _v$10 = props.strong ? TextAttributes.BOLD : TextAttributes.NONE;
|
|
320
|
+
_v$9 !== _p$.e && (_p$.e = _$setProp(_el$14, "fg", _v$9, _p$.e));
|
|
321
|
+
_v$0 !== _p$.t && (_p$.t = _$setProp(_el$14, "width", _v$0, _p$.t));
|
|
322
|
+
_v$1 !== _p$.a && (_p$.a = _$setProp(_el$15, "fg", _v$1, _p$.a));
|
|
323
|
+
_v$10 !== _p$.o && (_p$.o = _$setProp(_el$15, "attributes", _v$10, _p$.o));
|
|
324
|
+
return _p$;
|
|
325
|
+
}, {
|
|
326
|
+
e: undefined,
|
|
327
|
+
t: undefined,
|
|
328
|
+
a: undefined,
|
|
329
|
+
o: undefined
|
|
330
|
+
});
|
|
331
|
+
return _el$13;
|
|
332
|
+
})();
|
|
333
|
+
}
|
|
334
|
+
function Section(props) {
|
|
335
|
+
return (() => {
|
|
336
|
+
var _el$16 = _$createElement("box"), _el$17 = _$createElement("box"), _el$18 = _$createElement("text");
|
|
337
|
+
_$insertNode(_el$16, _el$17);
|
|
338
|
+
_$setProp(_el$16, "flexDirection", "column");
|
|
339
|
+
_$setProp(_el$16, "flexShrink", 0);
|
|
340
|
+
_$insertNode(_el$17, _el$18);
|
|
341
|
+
_$setProp(_el$17, "flexDirection", "row");
|
|
342
|
+
_$setProp(_el$17, "gap", 1);
|
|
343
|
+
_$setProp(_el$18, "wrapMode", "none");
|
|
344
|
+
_$insert(_el$18, () => props.title);
|
|
345
|
+
_$insert(_el$17, (() => {
|
|
346
|
+
var _c$5 = _$memo(() => !!props.note);
|
|
347
|
+
return () => _c$5() ? (() => {
|
|
348
|
+
var _el$19 = _$createElement("text");
|
|
349
|
+
_$setProp(_el$19, "wrapMode", "none");
|
|
350
|
+
_$insert(_el$19, () => props.note);
|
|
351
|
+
_$effect((_$p) => _$setProp(_el$19, "fg", props.theme.text.faint, _$p));
|
|
352
|
+
return _el$19;
|
|
353
|
+
})() : null;
|
|
354
|
+
})(), null);
|
|
355
|
+
_$insert(_el$16, () => props.children, null);
|
|
356
|
+
_$effect((_p$) => {
|
|
357
|
+
var _v$11 = props.theme.text.base, _v$12 = TextAttributes.BOLD;
|
|
358
|
+
_v$11 !== _p$.e && (_p$.e = _$setProp(_el$18, "fg", _v$11, _p$.e));
|
|
359
|
+
_v$12 !== _p$.t && (_p$.t = _$setProp(_el$18, "attributes", _v$12, _p$.t));
|
|
360
|
+
return _p$;
|
|
361
|
+
}, {
|
|
362
|
+
e: undefined,
|
|
363
|
+
t: undefined
|
|
364
|
+
});
|
|
365
|
+
return _el$16;
|
|
366
|
+
})();
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// src/ui/quota.tsx
|
|
370
|
+
import { effect as _$effect2 } from "@opentui/solid";
|
|
371
|
+
import { insertNode as _$insertNode2 } from "@opentui/solid";
|
|
372
|
+
import { insert as _$insert2 } from "@opentui/solid";
|
|
373
|
+
import { setProp as _$setProp2 } from "@opentui/solid";
|
|
374
|
+
import { createElement as _$createElement2 } from "@opentui/solid";
|
|
375
|
+
import { memo as _$memo2 } from "@opentui/solid";
|
|
376
|
+
import { createComponent as _$createComponent2 } from "@opentui/solid";
|
|
377
|
+
import { TextAttributes as TextAttributes2 } from "@opentui/core";
|
|
378
|
+
import { For as For2 } from "solid-js";
|
|
379
|
+
var QUOTA_ERROR_MAX_LENGTH = 100;
|
|
380
|
+
function shortQuotaError(message) {
|
|
381
|
+
return message.length > QUOTA_ERROR_MAX_LENGTH ? `${message.slice(0, QUOTA_ERROR_MAX_LENGTH - 1)}\u2026` : message;
|
|
382
|
+
}
|
|
383
|
+
function matchesSidebarWindow(window, selected) {
|
|
384
|
+
if (selected === "all")
|
|
385
|
+
return true;
|
|
386
|
+
if (selected === "rolling")
|
|
387
|
+
return window.kind === "rolling" || window.label === "5h";
|
|
388
|
+
return window.kind === selected;
|
|
389
|
+
}
|
|
390
|
+
function stateWindows(state) {
|
|
391
|
+
if (state.status === "ready")
|
|
392
|
+
return state.data.windows;
|
|
393
|
+
if (state.status === "error")
|
|
394
|
+
return state.previous?.windows ?? [];
|
|
395
|
+
return [];
|
|
396
|
+
}
|
|
397
|
+
function isLineQuota(quota) {
|
|
398
|
+
return quota._tag === "Balance" || quota._tag === "Unknown" || quota._tag === "Count" && !!quota.unit;
|
|
399
|
+
}
|
|
400
|
+
function quotaColor(theme, used) {
|
|
401
|
+
if (used === null)
|
|
402
|
+
return;
|
|
403
|
+
if (used >= 90)
|
|
404
|
+
return theme.text.feedback.error.base;
|
|
405
|
+
if (used >= 70)
|
|
406
|
+
return theme.text.feedback.warning.base;
|
|
407
|
+
return theme.text.feedback.success.base;
|
|
408
|
+
}
|
|
409
|
+
function WindowRow(props) {
|
|
410
|
+
const used = () => quotaUsedPercent(props.window.quota);
|
|
411
|
+
const resetValue = () => {
|
|
412
|
+
if (props.window.resetsAt === null)
|
|
413
|
+
return "";
|
|
414
|
+
const countdown = formatDuration(props.window.resetsAt - props.now, props.now);
|
|
415
|
+
return props.showResetTime ? `${formatTimestamp(props.window.resetsAt)} \xB7 ${countdown}` : countdown;
|
|
416
|
+
};
|
|
417
|
+
return isLineQuota(props.window.quota) ? _$createComponent2(Line, {
|
|
418
|
+
get theme() {
|
|
419
|
+
return props.theme;
|
|
420
|
+
},
|
|
421
|
+
get label() {
|
|
422
|
+
return props.window.label;
|
|
423
|
+
},
|
|
424
|
+
get labelWidth() {
|
|
425
|
+
return props.labelWidth;
|
|
426
|
+
},
|
|
427
|
+
get value() {
|
|
428
|
+
return formatQuotaText(props.window.quota);
|
|
429
|
+
}
|
|
430
|
+
}) : _$createComponent2(Row, {
|
|
431
|
+
get theme() {
|
|
432
|
+
return props.theme;
|
|
433
|
+
},
|
|
434
|
+
get label() {
|
|
435
|
+
return props.window.label;
|
|
436
|
+
},
|
|
437
|
+
get labelWidth() {
|
|
438
|
+
return props.labelWidth;
|
|
439
|
+
},
|
|
440
|
+
get cells() {
|
|
441
|
+
return _$memo2(() => !!props.showBar)() ? barCells(used() ?? 0, props.barWidth) : undefined;
|
|
442
|
+
},
|
|
443
|
+
get barWidth() {
|
|
444
|
+
return _$memo2(() => !!props.showBar)() ? props.barWidth : undefined;
|
|
445
|
+
},
|
|
446
|
+
get brackets() {
|
|
447
|
+
return props.showBar;
|
|
448
|
+
},
|
|
449
|
+
get percent() {
|
|
450
|
+
return _$memo2(() => !!props.showPercent)() ? _$memo2(() => used() === null)() ? "?" : `${Math.round(used())}%` : undefined;
|
|
451
|
+
},
|
|
452
|
+
get value() {
|
|
453
|
+
return resetValue();
|
|
454
|
+
},
|
|
455
|
+
get fg() {
|
|
456
|
+
return quotaColor(props.theme, used());
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
function ProviderBlock(props) {
|
|
461
|
+
const data = () => props.state.status === "ready" ? props.state.data : props.state.status === "error" ? props.state.previous : undefined;
|
|
462
|
+
const title = () => `${props.state.label}${props.state.status === "loading" ? " loading..." : ""}${props.state.status === "ready" && props.state.stale ? " (stale)" : ""}${props.state.status === "error" && data() ? " cached" : ""}`;
|
|
463
|
+
const errorState = () => props.state.status === "error" ? props.state : undefined;
|
|
464
|
+
const showError = () => errorState() !== undefined && props.view.showErrors;
|
|
465
|
+
const errorMessage = () => errorState()?.message ?? "";
|
|
466
|
+
return (() => {
|
|
467
|
+
var _el$ = _$createElement2("box"), _el$2 = _$createElement2("text");
|
|
468
|
+
_$insertNode2(_el$, _el$2);
|
|
469
|
+
_$setProp2(_el$, "flexDirection", "column");
|
|
470
|
+
_$setProp2(_el$, "flexShrink", 0);
|
|
471
|
+
_$setProp2(_el$2, "wrapMode", "none");
|
|
472
|
+
_$insert2(_el$2, title);
|
|
473
|
+
_$insert2(_el$, (() => {
|
|
474
|
+
var _c$ = _$memo2(() => !!showError());
|
|
475
|
+
return () => _c$() ? (() => {
|
|
476
|
+
var _el$3 = _$createElement2("text");
|
|
477
|
+
_$setProp2(_el$3, "wrapMode", "none");
|
|
478
|
+
_$insert2(_el$3, () => `! ${shortQuotaError(errorMessage())}`);
|
|
479
|
+
_$effect2((_$p) => _$setProp2(_el$3, "fg", props.theme.text.feedback.error.base, _$p));
|
|
480
|
+
return _el$3;
|
|
481
|
+
})() : null;
|
|
482
|
+
})(), null);
|
|
483
|
+
_$insert2(_el$, _$createComponent2(For2, {
|
|
484
|
+
get each() {
|
|
485
|
+
return props.windows;
|
|
486
|
+
},
|
|
487
|
+
children: (window) => _$createComponent2(WindowRow, {
|
|
488
|
+
window,
|
|
489
|
+
get theme() {
|
|
490
|
+
return props.theme;
|
|
491
|
+
},
|
|
492
|
+
get barWidth() {
|
|
493
|
+
return props.barWidth;
|
|
494
|
+
},
|
|
495
|
+
get compact() {
|
|
496
|
+
return props.compact;
|
|
497
|
+
},
|
|
498
|
+
get showResetTime() {
|
|
499
|
+
return props.showResetTime;
|
|
500
|
+
},
|
|
501
|
+
get labelWidth() {
|
|
502
|
+
return props.labelWidth;
|
|
503
|
+
},
|
|
504
|
+
get now() {
|
|
505
|
+
return props.now;
|
|
506
|
+
},
|
|
507
|
+
get showBar() {
|
|
508
|
+
return props.showBar;
|
|
509
|
+
},
|
|
510
|
+
get showPercent() {
|
|
511
|
+
return props.showPercent;
|
|
512
|
+
}
|
|
513
|
+
})
|
|
514
|
+
}), null);
|
|
515
|
+
_$effect2((_p$) => {
|
|
516
|
+
var _v$ = props.theme.text.base, _v$2 = TextAttributes2.BOLD;
|
|
517
|
+
_v$ !== _p$.e && (_p$.e = _$setProp2(_el$2, "fg", _v$, _p$.e));
|
|
518
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp2(_el$2, "attributes", _v$2, _p$.t));
|
|
519
|
+
return _p$;
|
|
520
|
+
}, {
|
|
521
|
+
e: undefined,
|
|
522
|
+
t: undefined
|
|
523
|
+
});
|
|
524
|
+
return _el$;
|
|
525
|
+
})();
|
|
526
|
+
}
|
|
527
|
+
function QuotaSection(props) {
|
|
528
|
+
const now = props.view.updatedAt ?? Date.now();
|
|
529
|
+
const labelWidth = () => props.labelWidth ?? (props.compact ? 12 : 24);
|
|
530
|
+
const windowsFor = (state) => {
|
|
531
|
+
const all = stateWindows(state);
|
|
532
|
+
if (props.windowScope !== "sidebar")
|
|
533
|
+
return all;
|
|
534
|
+
const selected = props.providerDisplays?.[state.id]?.sidebarWindow ?? "all";
|
|
535
|
+
return all.filter((window) => matchesSidebarWindow(window, selected));
|
|
536
|
+
};
|
|
537
|
+
const visible = () => props.view.states.filter((state) => {
|
|
538
|
+
if (state.status === "disabled")
|
|
539
|
+
return false;
|
|
540
|
+
if (state.status !== "error")
|
|
541
|
+
return true;
|
|
542
|
+
if (state.previous)
|
|
543
|
+
return true;
|
|
544
|
+
return props.view.showErrors && state.errorKind !== "missing_credentials";
|
|
545
|
+
}).filter((state) => {
|
|
546
|
+
if (props.windowScope !== "sidebar")
|
|
547
|
+
return true;
|
|
548
|
+
return stateWindows(state).length === 0 || windowsFor(state).length > 0;
|
|
549
|
+
});
|
|
550
|
+
return _$createComponent2(Section, {
|
|
551
|
+
get theme() {
|
|
552
|
+
return props.theme;
|
|
553
|
+
},
|
|
554
|
+
title: "Quota",
|
|
555
|
+
get children() {
|
|
556
|
+
return [_$createComponent2(For2, {
|
|
557
|
+
get each() {
|
|
558
|
+
return visible();
|
|
559
|
+
},
|
|
560
|
+
children: (state) => _$createComponent2(ProviderBlock, {
|
|
561
|
+
state,
|
|
562
|
+
get windows() {
|
|
563
|
+
return windowsFor(state);
|
|
564
|
+
},
|
|
565
|
+
get view() {
|
|
566
|
+
return props.view;
|
|
567
|
+
},
|
|
568
|
+
get theme() {
|
|
569
|
+
return props.theme;
|
|
570
|
+
},
|
|
571
|
+
get barWidth() {
|
|
572
|
+
return props.barWidth;
|
|
573
|
+
},
|
|
574
|
+
get compact() {
|
|
575
|
+
return props.compact;
|
|
576
|
+
},
|
|
577
|
+
get showResetTime() {
|
|
578
|
+
return props.showResetTime;
|
|
579
|
+
},
|
|
580
|
+
get labelWidth() {
|
|
581
|
+
return labelWidth();
|
|
582
|
+
},
|
|
583
|
+
now,
|
|
584
|
+
get showBar() {
|
|
585
|
+
return _$memo2(() => !!(props.showBar ?? true))() && (props.windowScope !== "sidebar" || props.providerDisplays?.[state.id]?.showSidebarBar !== false);
|
|
586
|
+
},
|
|
587
|
+
get showPercent() {
|
|
588
|
+
return props.showPercent ?? true;
|
|
589
|
+
}
|
|
590
|
+
})
|
|
591
|
+
}), _$memo2(() => _$memo2(() => !!props.view.showErrors)() ? _$createComponent2(For2, {
|
|
592
|
+
get each() {
|
|
593
|
+
return props.view.diagnostics;
|
|
594
|
+
},
|
|
595
|
+
children: (diagnostic) => (() => {
|
|
596
|
+
var _el$4 = _$createElement2("text");
|
|
597
|
+
_$setProp2(_el$4, "wrapMode", "none");
|
|
598
|
+
_$insert2(_el$4, `! ${diagnostic}`);
|
|
599
|
+
_$effect2((_$p) => _$setProp2(_el$4, "fg", props.theme.text.feedback.warning.base, _$p));
|
|
600
|
+
return _el$4;
|
|
601
|
+
})()
|
|
602
|
+
}) : null)];
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/panel/ReportPanel.tsx
|
|
608
|
+
var PANEL_NAME = "tally.report";
|
|
609
|
+
var LABEL_WIDTH = 24;
|
|
610
|
+
var VALUE_WIDTH = 10;
|
|
611
|
+
var PERCENT_WIDTH = 7;
|
|
612
|
+
var MIN_BAR_WIDTH = 6;
|
|
613
|
+
var MAX_BAR_WIDTH = 40;
|
|
614
|
+
var SCROLL_STEP = 3;
|
|
615
|
+
var SCROLL_PAGE = 20;
|
|
616
|
+
var COST_BASIS_NOTE = {
|
|
617
|
+
recorded: "",
|
|
618
|
+
estimated: " (estimate)",
|
|
619
|
+
mixed: " (partly estimated)"
|
|
620
|
+
};
|
|
621
|
+
function usageRows(usage) {
|
|
622
|
+
return [{
|
|
623
|
+
label: "Input (fresh)",
|
|
624
|
+
tokens: usage.input
|
|
625
|
+
}, {
|
|
626
|
+
label: "Cache read",
|
|
627
|
+
tokens: usage.cacheRead
|
|
628
|
+
}, {
|
|
629
|
+
label: "Cache write",
|
|
630
|
+
tokens: usage.cacheWrite
|
|
631
|
+
}, {
|
|
632
|
+
label: "Output",
|
|
633
|
+
tokens: usage.output
|
|
634
|
+
}, {
|
|
635
|
+
label: "Reasoning",
|
|
636
|
+
tokens: usage.reasoning
|
|
637
|
+
}].filter((row) => row.tokens > 0);
|
|
638
|
+
}
|
|
639
|
+
function usageTotal(usage) {
|
|
640
|
+
return usage.input + usage.cacheRead + usage.cacheWrite + usage.output + usage.reasoning;
|
|
641
|
+
}
|
|
642
|
+
function rawPercent(part, whole) {
|
|
643
|
+
return whole > 0 ? part / whole * 100 : 0;
|
|
644
|
+
}
|
|
645
|
+
function BarRows(props) {
|
|
646
|
+
return _$createComponent3(For3, {
|
|
647
|
+
get each() {
|
|
648
|
+
return props.rows.filter((row) => row.tokens > 0);
|
|
649
|
+
},
|
|
650
|
+
children: (row) => _$createComponent3(Row, {
|
|
651
|
+
get theme() {
|
|
652
|
+
return props.theme;
|
|
653
|
+
},
|
|
654
|
+
get label() {
|
|
655
|
+
return row.label;
|
|
656
|
+
},
|
|
657
|
+
labelWidth: LABEL_WIDTH,
|
|
658
|
+
valueWidth: VALUE_WIDTH,
|
|
659
|
+
get cells() {
|
|
660
|
+
return barCells(rawPercent(row.tokens, props.total), props.barWidth);
|
|
661
|
+
},
|
|
662
|
+
get barWidth() {
|
|
663
|
+
return props.barWidth;
|
|
664
|
+
},
|
|
665
|
+
get percent() {
|
|
666
|
+
return _$memo3(() => !!props.suffix)() ? props.suffix(row) : formatPercent2(row.tokens, props.total);
|
|
667
|
+
},
|
|
668
|
+
get value() {
|
|
669
|
+
return formatTokens(row.tokens, false);
|
|
670
|
+
},
|
|
671
|
+
get detail() {
|
|
672
|
+
return row.detail;
|
|
673
|
+
}
|
|
674
|
+
})
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
function ReportData(props) {
|
|
678
|
+
const data = () => props.report;
|
|
679
|
+
const toolTotal = () => data().tools.reduce((sum, tool) => sum + tool.tokens, 0);
|
|
680
|
+
const calls = () => new Map(data().tools.map((tool) => [tool.name, tool.calls]));
|
|
681
|
+
const limit = () => data().contextLimit;
|
|
682
|
+
return (() => {
|
|
683
|
+
var _el$ = _$createElement3("box"), _el$2 = _$createElement3("box"), _el$3 = _$createElement3("text"), _el$4 = _$createElement3("text");
|
|
684
|
+
_$insertNode3(_el$, _el$2);
|
|
685
|
+
_$setProp3(_el$, "flexDirection", "column");
|
|
686
|
+
_$setProp3(_el$, "gap", 1);
|
|
687
|
+
_$insertNode3(_el$2, _el$3);
|
|
688
|
+
_$insertNode3(_el$2, _el$4);
|
|
689
|
+
_$setProp3(_el$2, "flexDirection", "column");
|
|
690
|
+
_$setProp3(_el$2, "flexShrink", 0);
|
|
691
|
+
_$setProp3(_el$3, "wrapMode", "none");
|
|
692
|
+
_$setProp3(_el$3, "truncate", true);
|
|
693
|
+
_$insert3(_el$3, () => `${data().model} \xB7 ${data().steps} steps \xB7 ${data().tokenizer} tokenizer`);
|
|
694
|
+
_$setProp3(_el$4, "wrapMode", "none");
|
|
695
|
+
_$insert3(_el$4, () => `${formatUsd(data().total.cost)}${COST_BASIS_NOTE[data().total.costBasis]} \xB7 ${formatTokens(data().total.tokens, false)} tokens`);
|
|
696
|
+
_$insert3(_el$, (() => {
|
|
697
|
+
var _c$ = _$memo3(() => data().warnings.length > 0);
|
|
698
|
+
return () => _c$() ? (() => {
|
|
699
|
+
var _el$5 = _$createElement3("box");
|
|
700
|
+
_$setProp3(_el$5, "flexDirection", "column");
|
|
701
|
+
_$setProp3(_el$5, "flexShrink", 0);
|
|
702
|
+
_$insert3(_el$5, _$createComponent3(For3, {
|
|
703
|
+
get each() {
|
|
704
|
+
return data().warnings;
|
|
705
|
+
},
|
|
706
|
+
children: (warning) => (() => {
|
|
707
|
+
var _el$6 = _$createElement3("text");
|
|
708
|
+
_$insert3(_el$6, `! ${warning}`);
|
|
709
|
+
_$effect3((_$p) => _$setProp3(_el$6, "fg", props.theme.text.feedback.warning.base, _$p));
|
|
710
|
+
return _el$6;
|
|
711
|
+
})()
|
|
712
|
+
}));
|
|
713
|
+
return _el$5;
|
|
714
|
+
})() : null;
|
|
715
|
+
})(), null);
|
|
716
|
+
_$insert3(_el$, (() => {
|
|
717
|
+
var _c$2 = _$memo3(() => !!props.quotaError);
|
|
718
|
+
return () => _c$2() ? (() => {
|
|
719
|
+
var _el$7 = _$createElement3("text");
|
|
720
|
+
_$setProp3(_el$7, "wrapMode", "none");
|
|
721
|
+
_$insert3(_el$7, () => `Quota unavailable: ${props.quotaError?.message ?? ""}`);
|
|
722
|
+
_$effect3((_$p) => _$setProp3(_el$7, "fg", props.theme.text.feedback.error.base, _$p));
|
|
723
|
+
return _el$7;
|
|
724
|
+
})() : null;
|
|
725
|
+
})(), null);
|
|
726
|
+
_$insert3(_el$, (() => {
|
|
727
|
+
var _c$3 = _$memo3(() => !!props.quota);
|
|
728
|
+
return () => _c$3() ? _$createComponent3(QuotaSection, {
|
|
729
|
+
get view() {
|
|
730
|
+
return props.quota;
|
|
731
|
+
},
|
|
732
|
+
get theme() {
|
|
733
|
+
return props.theme;
|
|
734
|
+
},
|
|
735
|
+
get barWidth() {
|
|
736
|
+
return props.barWidth;
|
|
737
|
+
},
|
|
738
|
+
compact: false,
|
|
739
|
+
showResetTime: true
|
|
740
|
+
}) : null;
|
|
741
|
+
})(), null);
|
|
742
|
+
_$insert3(_el$, _$createComponent3(Section, {
|
|
743
|
+
get theme() {
|
|
744
|
+
return props.theme;
|
|
745
|
+
},
|
|
746
|
+
title: "Context",
|
|
747
|
+
get note() {
|
|
748
|
+
return data().content.scale === undefined ? "local estimate" : undefined;
|
|
749
|
+
},
|
|
750
|
+
get children() {
|
|
751
|
+
return _$memo3(() => limit() !== undefined)() ? _$createComponent3(Row, {
|
|
752
|
+
get theme() {
|
|
753
|
+
return props.theme;
|
|
754
|
+
},
|
|
755
|
+
label: "Tokens",
|
|
756
|
+
labelWidth: LABEL_WIDTH,
|
|
757
|
+
valueWidth: 20,
|
|
758
|
+
get cells() {
|
|
759
|
+
return barCells(rawPercent(data().content.total, limit()), props.barWidth);
|
|
760
|
+
},
|
|
761
|
+
get barWidth() {
|
|
762
|
+
return props.barWidth;
|
|
763
|
+
},
|
|
764
|
+
get percent() {
|
|
765
|
+
return formatPercent2(data().content.total, limit());
|
|
766
|
+
},
|
|
767
|
+
get value() {
|
|
768
|
+
return `${formatTokens(data().content.total, false)} / ${formatTokens(limit(), false)}`;
|
|
769
|
+
},
|
|
770
|
+
strong: true
|
|
771
|
+
}) : _$createComponent3(Line, {
|
|
772
|
+
get theme() {
|
|
773
|
+
return props.theme;
|
|
774
|
+
},
|
|
775
|
+
label: "Tokens",
|
|
776
|
+
get value() {
|
|
777
|
+
return `${formatTokens(data().content.total, false)} tokens`;
|
|
778
|
+
},
|
|
779
|
+
labelWidth: LABEL_WIDTH,
|
|
780
|
+
strong: true
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
}), null);
|
|
784
|
+
_$insert3(_el$, _$createComponent3(Section, {
|
|
785
|
+
get theme() {
|
|
786
|
+
return props.theme;
|
|
787
|
+
},
|
|
788
|
+
title: "Recorded usage",
|
|
789
|
+
get note() {
|
|
790
|
+
return `${data().steps} completed steps`;
|
|
791
|
+
},
|
|
792
|
+
get children() {
|
|
793
|
+
return [_$createComponent3(BarRows, {
|
|
794
|
+
get rows() {
|
|
795
|
+
return usageRows(data().recorded);
|
|
796
|
+
},
|
|
797
|
+
get total() {
|
|
798
|
+
return usageTotal(data().recorded);
|
|
799
|
+
},
|
|
800
|
+
get theme() {
|
|
801
|
+
return props.theme;
|
|
802
|
+
},
|
|
803
|
+
get barWidth() {
|
|
804
|
+
return props.barWidth;
|
|
805
|
+
}
|
|
806
|
+
}), _$createComponent3(Line, {
|
|
807
|
+
get theme() {
|
|
808
|
+
return props.theme;
|
|
809
|
+
},
|
|
810
|
+
label: "Total",
|
|
811
|
+
labelWidth: LABEL_WIDTH,
|
|
812
|
+
get value() {
|
|
813
|
+
return `${formatTokens(usageTotal(data().recorded), false)} tokens`;
|
|
814
|
+
},
|
|
815
|
+
strong: true
|
|
816
|
+
}), _$createComponent3(Line, {
|
|
817
|
+
get theme() {
|
|
818
|
+
return props.theme;
|
|
819
|
+
},
|
|
820
|
+
get label() {
|
|
821
|
+
return data().costBasis === "estimated" ? "Cost (API-rate estimate)" : "Cost (recorded)";
|
|
822
|
+
},
|
|
823
|
+
labelWidth: LABEL_WIDTH,
|
|
824
|
+
get value() {
|
|
825
|
+
return formatUsd(data().cost);
|
|
826
|
+
},
|
|
827
|
+
strong: true
|
|
828
|
+
}), _$memo3(() => _$memo3(() => !!data().cache)() ? _$createComponent3(Line, {
|
|
829
|
+
get theme() {
|
|
830
|
+
return props.theme;
|
|
831
|
+
},
|
|
832
|
+
label: "Cache hit rate",
|
|
833
|
+
labelWidth: LABEL_WIDTH,
|
|
834
|
+
get value() {
|
|
835
|
+
return `${data().cache.hitRate.toFixed(1)}% \xB7 saved ${formatUsd(data().cache.savings)} (${data().cache.savingsPercent.toFixed(1)}%)`;
|
|
836
|
+
}
|
|
837
|
+
}) : null)];
|
|
838
|
+
}
|
|
839
|
+
}), null);
|
|
840
|
+
_$insert3(_el$, _$createComponent3(Section, {
|
|
841
|
+
get theme() {
|
|
842
|
+
return props.theme;
|
|
843
|
+
},
|
|
844
|
+
title: "Context window",
|
|
845
|
+
get note() {
|
|
846
|
+
return _$memo3(() => data().content.scale === undefined)() ? "local estimate" : `recorded total, local split scaled \xD7${data().content.scale.toFixed(2)}`;
|
|
847
|
+
},
|
|
848
|
+
get children() {
|
|
849
|
+
return [_$createComponent3(BarRows, {
|
|
850
|
+
get rows() {
|
|
851
|
+
return data().content.rows;
|
|
852
|
+
},
|
|
853
|
+
get total() {
|
|
854
|
+
return data().content.total;
|
|
855
|
+
},
|
|
856
|
+
get theme() {
|
|
857
|
+
return props.theme;
|
|
858
|
+
},
|
|
859
|
+
get barWidth() {
|
|
860
|
+
return props.barWidth;
|
|
861
|
+
}
|
|
862
|
+
}), _$createComponent3(Line, {
|
|
863
|
+
get theme() {
|
|
864
|
+
return props.theme;
|
|
865
|
+
},
|
|
866
|
+
label: "Total",
|
|
867
|
+
labelWidth: LABEL_WIDTH,
|
|
868
|
+
get value() {
|
|
869
|
+
return `${formatTokens(data().content.total, false)} tokens`;
|
|
870
|
+
},
|
|
871
|
+
strong: true
|
|
872
|
+
})];
|
|
873
|
+
}
|
|
874
|
+
}), null);
|
|
875
|
+
_$insert3(_el$, (() => {
|
|
876
|
+
var _c$4 = _$memo3(() => data().steps > 0);
|
|
877
|
+
return () => _c$4() ? _$createComponent3(Section, {
|
|
878
|
+
get theme() {
|
|
879
|
+
return props.theme;
|
|
880
|
+
},
|
|
881
|
+
title: "Last request",
|
|
882
|
+
note: "recorded by OpenCode",
|
|
883
|
+
get children() {
|
|
884
|
+
return [_$createComponent3(BarRows, {
|
|
885
|
+
get rows() {
|
|
886
|
+
return usageRows(data().lastStep);
|
|
887
|
+
},
|
|
888
|
+
get total() {
|
|
889
|
+
return usageTotal(data().lastStep);
|
|
890
|
+
},
|
|
891
|
+
get theme() {
|
|
892
|
+
return props.theme;
|
|
893
|
+
},
|
|
894
|
+
get barWidth() {
|
|
895
|
+
return props.barWidth;
|
|
896
|
+
}
|
|
897
|
+
}), _$createComponent3(Line, {
|
|
898
|
+
get theme() {
|
|
899
|
+
return props.theme;
|
|
900
|
+
},
|
|
901
|
+
label: "Total",
|
|
902
|
+
labelWidth: LABEL_WIDTH,
|
|
903
|
+
get value() {
|
|
904
|
+
return `${formatTokens(usageTotal(data().lastStep), false)} tokens`;
|
|
905
|
+
},
|
|
906
|
+
strong: true
|
|
907
|
+
})];
|
|
908
|
+
}
|
|
909
|
+
}) : null;
|
|
910
|
+
})(), null);
|
|
911
|
+
_$insert3(_el$, (() => {
|
|
912
|
+
var _c$5 = _$memo3(() => !!data().context);
|
|
913
|
+
return () => _c$5() ? _$createComponent3(Section, {
|
|
914
|
+
get theme() {
|
|
915
|
+
return props.theme;
|
|
916
|
+
},
|
|
917
|
+
title: "Always-sent context",
|
|
918
|
+
get note() {
|
|
919
|
+
return data().context.measured ? "measured from the latest request" : "estimated from the first cache write";
|
|
920
|
+
},
|
|
921
|
+
get children() {
|
|
922
|
+
return [_$createComponent3(BarRows, {
|
|
923
|
+
get rows() {
|
|
924
|
+
return data().context.components;
|
|
925
|
+
},
|
|
926
|
+
get total() {
|
|
927
|
+
return data().context.total;
|
|
928
|
+
},
|
|
929
|
+
get theme() {
|
|
930
|
+
return props.theme;
|
|
931
|
+
},
|
|
932
|
+
get barWidth() {
|
|
933
|
+
return props.barWidth;
|
|
934
|
+
}
|
|
935
|
+
}), _$createComponent3(Line, {
|
|
936
|
+
get theme() {
|
|
937
|
+
return props.theme;
|
|
938
|
+
},
|
|
939
|
+
label: "Total",
|
|
940
|
+
labelWidth: LABEL_WIDTH,
|
|
941
|
+
get value() {
|
|
942
|
+
return `${data().context.measured ? "~" : ""}${formatTokens(data().context.total, false)} tokens`;
|
|
943
|
+
},
|
|
944
|
+
strong: true
|
|
945
|
+
})];
|
|
946
|
+
}
|
|
947
|
+
}) : null;
|
|
948
|
+
})(), null);
|
|
949
|
+
_$insert3(_el$, (() => {
|
|
950
|
+
var _c$6 = _$memo3(() => data().tools.length > 0);
|
|
951
|
+
return () => _c$6() ? _$createComponent3(Section, {
|
|
952
|
+
get theme() {
|
|
953
|
+
return props.theme;
|
|
954
|
+
},
|
|
955
|
+
title: "Tool output",
|
|
956
|
+
get children() {
|
|
957
|
+
return _$createComponent3(BarRows, {
|
|
958
|
+
get rows() {
|
|
959
|
+
return data().tools.filter((tool) => tool.tokens > 0).map((tool) => ({
|
|
960
|
+
label: tool.name,
|
|
961
|
+
tokens: tool.tokens
|
|
962
|
+
}));
|
|
963
|
+
},
|
|
964
|
+
get total() {
|
|
965
|
+
return toolTotal();
|
|
966
|
+
},
|
|
967
|
+
get theme() {
|
|
968
|
+
return props.theme;
|
|
969
|
+
},
|
|
970
|
+
get barWidth() {
|
|
971
|
+
return props.barWidth;
|
|
972
|
+
},
|
|
973
|
+
suffix: (row) => `${calls().get(row.label) ?? 0}x`.padStart(PERCENT_WIDTH - 1)
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
}) : null;
|
|
977
|
+
})(), null);
|
|
978
|
+
_$insert3(_el$, (() => {
|
|
979
|
+
var _c$7 = _$memo3(() => data().topContributors.length > 0);
|
|
980
|
+
return () => _c$7() ? _$createComponent3(Section, {
|
|
981
|
+
get theme() {
|
|
982
|
+
return props.theme;
|
|
983
|
+
},
|
|
984
|
+
title: "Top contributors",
|
|
985
|
+
get children() {
|
|
986
|
+
return _$createComponent3(BarRows, {
|
|
987
|
+
get rows() {
|
|
988
|
+
return data().topContributors;
|
|
989
|
+
},
|
|
990
|
+
get total() {
|
|
991
|
+
return data().content.total;
|
|
992
|
+
},
|
|
993
|
+
get theme() {
|
|
994
|
+
return props.theme;
|
|
995
|
+
},
|
|
996
|
+
get barWidth() {
|
|
997
|
+
return props.barWidth;
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
}) : null;
|
|
1002
|
+
})(), null);
|
|
1003
|
+
_$insert3(_el$, (() => {
|
|
1004
|
+
var _c$8 = _$memo3(() => !!data().subagents);
|
|
1005
|
+
return () => _c$8() ? _$createComponent3(Section, {
|
|
1006
|
+
get theme() {
|
|
1007
|
+
return props.theme;
|
|
1008
|
+
},
|
|
1009
|
+
title: "Subagents",
|
|
1010
|
+
get note() {
|
|
1011
|
+
return `${data().subagents.sessions.length} child ${data().subagents.sessions.length === 1 ? "session" : "sessions"}`;
|
|
1012
|
+
},
|
|
1013
|
+
get children() {
|
|
1014
|
+
return [_$createComponent3(For3, {
|
|
1015
|
+
get each() {
|
|
1016
|
+
return data().subagents.sessions;
|
|
1017
|
+
},
|
|
1018
|
+
children: (session) => _$createComponent3(Line, {
|
|
1019
|
+
get theme() {
|
|
1020
|
+
return props.theme;
|
|
1021
|
+
},
|
|
1022
|
+
get label() {
|
|
1023
|
+
return session.agent;
|
|
1024
|
+
},
|
|
1025
|
+
labelWidth: LABEL_WIDTH,
|
|
1026
|
+
get value() {
|
|
1027
|
+
return `${formatUsd(session.cost)}${COST_BASIS_NOTE[session.costBasis]} \xB7 ${formatTokens(session.tokens, false)} tokens \xB7 ${session.steps} steps`;
|
|
1028
|
+
}
|
|
1029
|
+
})
|
|
1030
|
+
}), _$createComponent3(Line, {
|
|
1031
|
+
get theme() {
|
|
1032
|
+
return props.theme;
|
|
1033
|
+
},
|
|
1034
|
+
label: "Session + subagents",
|
|
1035
|
+
labelWidth: LABEL_WIDTH,
|
|
1036
|
+
get value() {
|
|
1037
|
+
return `${formatUsd(data().total.cost)}${COST_BASIS_NOTE[data().total.costBasis]} \xB7 ${formatTokens(data().total.tokens, false)} tokens \xB7 ${data().total.steps} steps`;
|
|
1038
|
+
},
|
|
1039
|
+
strong: true
|
|
1040
|
+
})];
|
|
1041
|
+
}
|
|
1042
|
+
}) : null;
|
|
1043
|
+
})(), null);
|
|
1044
|
+
_$effect3((_p$) => {
|
|
1045
|
+
var _v$ = props.theme.text.muted, _v$2 = props.theme.text.base, _v$3 = TextAttributes3.BOLD;
|
|
1046
|
+
_v$ !== _p$.e && (_p$.e = _$setProp3(_el$3, "fg", _v$, _p$.e));
|
|
1047
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp3(_el$4, "fg", _v$2, _p$.t));
|
|
1048
|
+
_v$3 !== _p$.a && (_p$.a = _$setProp3(_el$4, "attributes", _v$3, _p$.a));
|
|
1049
|
+
return _p$;
|
|
1050
|
+
}, {
|
|
1051
|
+
e: undefined,
|
|
1052
|
+
t: undefined,
|
|
1053
|
+
a: undefined
|
|
1054
|
+
});
|
|
1055
|
+
return _el$;
|
|
1056
|
+
})();
|
|
1057
|
+
}
|
|
1058
|
+
function ReportPanelView(props) {
|
|
1059
|
+
const barWidth = createMemo(() => Math.max(MIN_BAR_WIDTH, Math.min(MAX_BAR_WIDTH, props.width - 4 - LABEL_WIDTH - VALUE_WIDTH - PERCENT_WIDTH - 3)));
|
|
1060
|
+
return (() => {
|
|
1061
|
+
var _el$8 = _$createElement3("box"), _el$9 = _$createElement3("box"), _el$0 = _$createElement3("text"), _el$10 = _$createElement3("text"), _el$12 = _$createElement3("scrollbox");
|
|
1062
|
+
_$insertNode3(_el$8, _el$9);
|
|
1063
|
+
_$insertNode3(_el$8, _el$12);
|
|
1064
|
+
_$setProp3(_el$8, "width", "100%");
|
|
1065
|
+
_$setProp3(_el$8, "height", "100%");
|
|
1066
|
+
_$setProp3(_el$8, "flexDirection", "column");
|
|
1067
|
+
_$setProp3(_el$8, "paddingLeft", 2);
|
|
1068
|
+
_$setProp3(_el$8, "paddingRight", 2);
|
|
1069
|
+
_$setProp3(_el$8, "paddingTop", 1);
|
|
1070
|
+
_$insertNode3(_el$9, _el$0);
|
|
1071
|
+
_$insertNode3(_el$9, _el$10);
|
|
1072
|
+
_$setProp3(_el$9, "flexDirection", "row");
|
|
1073
|
+
_$setProp3(_el$9, "justifyContent", "space-between");
|
|
1074
|
+
_$setProp3(_el$9, "height", 2);
|
|
1075
|
+
_$setProp3(_el$9, "flexShrink", 0);
|
|
1076
|
+
_$insertNode3(_el$0, _$createTextNode2(`Tally`));
|
|
1077
|
+
_$setProp3(_el$0, "wrapMode", "none");
|
|
1078
|
+
_$insertNode3(_el$10, _$createTextNode2(`r refresh \xB7 f full screen \xB7 esc close`));
|
|
1079
|
+
_$setProp3(_el$10, "wrapMode", "none");
|
|
1080
|
+
_$use((element) => props.scrollRef?.(element), _el$12);
|
|
1081
|
+
_$setProp3(_el$12, "flexGrow", 1);
|
|
1082
|
+
_$setProp3(_el$12, "minHeight", 0);
|
|
1083
|
+
_$setProp3(_el$12, "verticalScrollbarOptions", {
|
|
1084
|
+
visible: false
|
|
1085
|
+
});
|
|
1086
|
+
_$setProp3(_el$12, "horizontalScrollbarOptions", {
|
|
1087
|
+
visible: false
|
|
1088
|
+
});
|
|
1089
|
+
_$insert3(_el$12, (() => {
|
|
1090
|
+
var _c$9 = _$memo3(() => !!props.error);
|
|
1091
|
+
return () => _c$9() ? (() => {
|
|
1092
|
+
var _el$13 = _$createElement3("text");
|
|
1093
|
+
_$insert3(_el$13, () => `Could not load the report: ${props.error?.message ?? ""}`);
|
|
1094
|
+
_$effect3((_$p) => _$setProp3(_el$13, "fg", props.theme.text.feedback.error.base, _$p));
|
|
1095
|
+
return _el$13;
|
|
1096
|
+
})() : _$memo3(() => !!props.report)() ? _$createComponent3(ReportData, {
|
|
1097
|
+
get report() {
|
|
1098
|
+
return props.report;
|
|
1099
|
+
},
|
|
1100
|
+
get quota() {
|
|
1101
|
+
return props.quota;
|
|
1102
|
+
},
|
|
1103
|
+
get theme() {
|
|
1104
|
+
return props.theme;
|
|
1105
|
+
},
|
|
1106
|
+
get barWidth() {
|
|
1107
|
+
return barWidth();
|
|
1108
|
+
},
|
|
1109
|
+
get quotaError() {
|
|
1110
|
+
return props.quotaError;
|
|
1111
|
+
}
|
|
1112
|
+
}) : _$memo3(() => !!props.loading)() ? (() => {
|
|
1113
|
+
var _el$14 = _$createElement3("text");
|
|
1114
|
+
_$insertNode3(_el$14, _$createTextNode2(`Analyzing session\u2026`));
|
|
1115
|
+
_$effect3((_$p) => _$setProp3(_el$14, "fg", props.theme.text.muted, _$p));
|
|
1116
|
+
return _el$14;
|
|
1117
|
+
})() : null;
|
|
1118
|
+
})());
|
|
1119
|
+
_$effect3((_p$) => {
|
|
1120
|
+
var _v$4 = props.theme.text.base, _v$5 = TextAttributes3.BOLD, _v$6 = props.theme.text.faint;
|
|
1121
|
+
_v$4 !== _p$.e && (_p$.e = _$setProp3(_el$0, "fg", _v$4, _p$.e));
|
|
1122
|
+
_v$5 !== _p$.t && (_p$.t = _$setProp3(_el$0, "attributes", _v$5, _p$.t));
|
|
1123
|
+
_v$6 !== _p$.a && (_p$.a = _$setProp3(_el$10, "fg", _v$6, _p$.a));
|
|
1124
|
+
return _p$;
|
|
1125
|
+
}, {
|
|
1126
|
+
e: undefined,
|
|
1127
|
+
t: undefined,
|
|
1128
|
+
a: undefined
|
|
1129
|
+
});
|
|
1130
|
+
return _el$8;
|
|
1131
|
+
})();
|
|
1132
|
+
}
|
|
1133
|
+
function ReportPanel(props) {
|
|
1134
|
+
const theme = props.context.theme;
|
|
1135
|
+
let scroll;
|
|
1136
|
+
const [report, {
|
|
1137
|
+
refetch: refetchReport
|
|
1138
|
+
}] = createResource(() => props.panel.sessionID, async (sessionID) => {
|
|
1139
|
+
const directory = props.context.data.session.get(sessionID)?.location.directory;
|
|
1140
|
+
try {
|
|
1141
|
+
const output = await props.context.client.rpc(TallyRpc).report({
|
|
1142
|
+
sessionID
|
|
1143
|
+
}, directory ? {
|
|
1144
|
+
location: {
|
|
1145
|
+
directory
|
|
1146
|
+
}
|
|
1147
|
+
} : undefined);
|
|
1148
|
+
return output;
|
|
1149
|
+
} catch (failure) {
|
|
1150
|
+
throw toError(failure);
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
const [quota, {
|
|
1154
|
+
refetch: refetchQuota
|
|
1155
|
+
}] = createResource(async () => {
|
|
1156
|
+
try {
|
|
1157
|
+
const output = await props.context.client.rpc(TallyRpc).quota({});
|
|
1158
|
+
return output;
|
|
1159
|
+
} catch (failure) {
|
|
1160
|
+
throw toError(failure);
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
const refresh = () => {
|
|
1164
|
+
refetchReport();
|
|
1165
|
+
refetchQuota();
|
|
1166
|
+
};
|
|
1167
|
+
const status = createMemo(() => props.context.data.session.status(props.panel.sessionID));
|
|
1168
|
+
createEffect(on(status, (current, previous) => {
|
|
1169
|
+
if (previous === "running" && current === "idle")
|
|
1170
|
+
refresh();
|
|
1171
|
+
}, {
|
|
1172
|
+
defer: true
|
|
1173
|
+
}));
|
|
1174
|
+
props.context.keymap.layer(() => ({
|
|
1175
|
+
commands: [{
|
|
1176
|
+
bind: "escape",
|
|
1177
|
+
title: "close",
|
|
1178
|
+
run: () => props.panel.close()
|
|
1179
|
+
}, {
|
|
1180
|
+
bind: "r",
|
|
1181
|
+
title: "refresh",
|
|
1182
|
+
run: refresh
|
|
1183
|
+
}, {
|
|
1184
|
+
bind: "f",
|
|
1185
|
+
title: "full screen",
|
|
1186
|
+
run: () => props.panel.toggleFullscreen()
|
|
1187
|
+
}, {
|
|
1188
|
+
bind: "down",
|
|
1189
|
+
run: () => scroll?.scrollBy(SCROLL_STEP)
|
|
1190
|
+
}, {
|
|
1191
|
+
bind: "up",
|
|
1192
|
+
run: () => scroll?.scrollBy(-SCROLL_STEP)
|
|
1193
|
+
}, {
|
|
1194
|
+
bind: "pagedown",
|
|
1195
|
+
run: () => scroll?.scrollBy(SCROLL_PAGE)
|
|
1196
|
+
}, {
|
|
1197
|
+
bind: "pageup",
|
|
1198
|
+
run: () => scroll?.scrollBy(-SCROLL_PAGE)
|
|
1199
|
+
}]
|
|
1200
|
+
}));
|
|
1201
|
+
return _$createComponent3(ReportPanelView, {
|
|
1202
|
+
get report() {
|
|
1203
|
+
return report();
|
|
1204
|
+
},
|
|
1205
|
+
get quota() {
|
|
1206
|
+
return quota();
|
|
1207
|
+
},
|
|
1208
|
+
theme,
|
|
1209
|
+
get width() {
|
|
1210
|
+
return props.panel.width;
|
|
1211
|
+
},
|
|
1212
|
+
get loading() {
|
|
1213
|
+
return report.loading;
|
|
1214
|
+
},
|
|
1215
|
+
get error() {
|
|
1216
|
+
return report.error;
|
|
1217
|
+
},
|
|
1218
|
+
get quotaError() {
|
|
1219
|
+
return quota.error;
|
|
1220
|
+
},
|
|
1221
|
+
scrollRef: (element) => scroll = element
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// src/sidebar/Sidebar.tsx
|
|
1226
|
+
import { createTextNode as _$createTextNode3 } from "@opentui/solid";
|
|
1227
|
+
import { insertNode as _$insertNode4 } from "@opentui/solid";
|
|
1228
|
+
import { effect as _$effect4 } from "@opentui/solid";
|
|
1229
|
+
import { insert as _$insert4 } from "@opentui/solid";
|
|
1230
|
+
import { setProp as _$setProp4 } from "@opentui/solid";
|
|
1231
|
+
import { createElement as _$createElement4 } from "@opentui/solid";
|
|
1232
|
+
import { memo as _$memo4 } from "@opentui/solid";
|
|
1233
|
+
import { createComponent as _$createComponent4 } from "@opentui/solid";
|
|
1234
|
+
import { TextAttributes as TextAttributes4 } from "@opentui/core";
|
|
1235
|
+
import { createEffect as createEffect2, createMemo as createMemo2, createResource as createResource2, createSignal, For as For4, on as on2, onCleanup, Show } from "solid-js";
|
|
1236
|
+
|
|
1237
|
+
// src/lib/config.ts
|
|
1238
|
+
import path from "path";
|
|
1239
|
+
import fs from "fs/promises";
|
|
1240
|
+
import { homedir } from "os";
|
|
1241
|
+
import { fileURLToPath } from "url";
|
|
1242
|
+
|
|
1243
|
+
// src/lib/jsonc.ts
|
|
1244
|
+
function stripComments(text) {
|
|
1245
|
+
let output = "";
|
|
1246
|
+
let inString = false;
|
|
1247
|
+
let escaped = false;
|
|
1248
|
+
for (let i = 0;i < text.length; i++) {
|
|
1249
|
+
const char = text[i];
|
|
1250
|
+
if (inString) {
|
|
1251
|
+
output += char;
|
|
1252
|
+
if (escaped)
|
|
1253
|
+
escaped = false;
|
|
1254
|
+
else if (char === "\\")
|
|
1255
|
+
escaped = true;
|
|
1256
|
+
else if (char === '"')
|
|
1257
|
+
inString = false;
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
if (char === '"') {
|
|
1261
|
+
inString = true;
|
|
1262
|
+
output += char;
|
|
1263
|
+
continue;
|
|
1264
|
+
}
|
|
1265
|
+
if (char === "/" && text[i + 1] === "/") {
|
|
1266
|
+
i += 2;
|
|
1267
|
+
while (i < text.length && text[i] !== `
|
|
1268
|
+
` && text[i] !== "\r")
|
|
1269
|
+
i++;
|
|
1270
|
+
i--;
|
|
1271
|
+
continue;
|
|
1272
|
+
}
|
|
1273
|
+
if (char === "/" && text[i + 1] === "*") {
|
|
1274
|
+
i += 2;
|
|
1275
|
+
let closed = false;
|
|
1276
|
+
while (i < text.length) {
|
|
1277
|
+
if (text[i] === "*" && text[i + 1] === "/") {
|
|
1278
|
+
i++;
|
|
1279
|
+
closed = true;
|
|
1280
|
+
break;
|
|
1281
|
+
}
|
|
1282
|
+
i++;
|
|
1283
|
+
}
|
|
1284
|
+
if (!closed)
|
|
1285
|
+
throw new SyntaxError("Unterminated block comment in JSONC");
|
|
1286
|
+
continue;
|
|
1287
|
+
}
|
|
1288
|
+
output += char;
|
|
1289
|
+
}
|
|
1290
|
+
return output;
|
|
1291
|
+
}
|
|
1292
|
+
function stripTrailingCommas(text) {
|
|
1293
|
+
let output = "";
|
|
1294
|
+
let inString = false;
|
|
1295
|
+
let escaped = false;
|
|
1296
|
+
for (let i = 0;i < text.length; i++) {
|
|
1297
|
+
const char = text[i];
|
|
1298
|
+
if (inString) {
|
|
1299
|
+
output += char;
|
|
1300
|
+
if (escaped)
|
|
1301
|
+
escaped = false;
|
|
1302
|
+
else if (char === "\\")
|
|
1303
|
+
escaped = true;
|
|
1304
|
+
else if (char === '"')
|
|
1305
|
+
inString = false;
|
|
1306
|
+
continue;
|
|
1307
|
+
}
|
|
1308
|
+
if (char === '"') {
|
|
1309
|
+
inString = true;
|
|
1310
|
+
output += char;
|
|
1311
|
+
continue;
|
|
1312
|
+
}
|
|
1313
|
+
if (char === ",") {
|
|
1314
|
+
let next = i + 1;
|
|
1315
|
+
while (next < text.length && /\s/.test(text[next]))
|
|
1316
|
+
next++;
|
|
1317
|
+
if (text[next] === "}" || text[next] === "]")
|
|
1318
|
+
continue;
|
|
1319
|
+
}
|
|
1320
|
+
output += char;
|
|
1321
|
+
}
|
|
1322
|
+
return output;
|
|
1323
|
+
}
|
|
1324
|
+
function parseJsonc(text) {
|
|
1325
|
+
return JSON.parse(stripTrailingCommas(stripComments(text)));
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
// src/lib/config.ts
|
|
1329
|
+
var MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
1330
|
+
var USER_TALLY_CONFIG_PATH = path.join(homedir(), ".config", "opencode", "tally-config.json");
|
|
1331
|
+
var BUNDLED_ASSET_PATH_CACHE = new Map;
|
|
1332
|
+
async function resolveBundledAssetPath(filename, moduleDir = MODULE_DIR) {
|
|
1333
|
+
const cacheKey = `${moduleDir}:${filename}`;
|
|
1334
|
+
const cached = BUNDLED_ASSET_PATH_CACHE.get(cacheKey);
|
|
1335
|
+
if (cached)
|
|
1336
|
+
return cached;
|
|
1337
|
+
const candidates = [path.join(moduleDir, "../..", filename)];
|
|
1338
|
+
for (const candidate of candidates) {
|
|
1339
|
+
try {
|
|
1340
|
+
await fs.access(candidate);
|
|
1341
|
+
BUNDLED_ASSET_PATH_CACHE.set(cacheKey, candidate);
|
|
1342
|
+
return candidate;
|
|
1343
|
+
} catch {}
|
|
1344
|
+
}
|
|
1345
|
+
const fallback = candidates[0];
|
|
1346
|
+
BUNDLED_ASSET_PATH_CACHE.set(cacheKey, fallback);
|
|
1347
|
+
return fallback;
|
|
1348
|
+
}
|
|
1349
|
+
var DEFAULT_SIDEBAR_CONFIG = {
|
|
1350
|
+
enabled: true,
|
|
1351
|
+
refreshSeconds: 60,
|
|
1352
|
+
sections: ["quota", "context", "recorded", "contextWindow"],
|
|
1353
|
+
showBars: true,
|
|
1354
|
+
showPercentages: true,
|
|
1355
|
+
showWarnings: true,
|
|
1356
|
+
showUpdated: true
|
|
1357
|
+
};
|
|
1358
|
+
var SIDEBAR_SECTION_IDS = ["quota", "context", "recorded", "contextWindow"];
|
|
1359
|
+
var TALLY_FILE_CONFIG_CACHE = new Map;
|
|
1360
|
+
var SIDEBAR_LAST_VALID = new Map;
|
|
1361
|
+
var QUOTA_LAST_VALID = new Map;
|
|
1362
|
+
var BUNDLED_CONFIG_CACHE = null;
|
|
1363
|
+
function isRecord(value) {
|
|
1364
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1365
|
+
}
|
|
1366
|
+
function asSection(value) {
|
|
1367
|
+
return isRecord(value) ? value : {};
|
|
1368
|
+
}
|
|
1369
|
+
async function readConfigFile(configPath) {
|
|
1370
|
+
let text;
|
|
1371
|
+
try {
|
|
1372
|
+
text = await fs.readFile(configPath, "utf8");
|
|
1373
|
+
} catch {
|
|
1374
|
+
return { data: null };
|
|
1375
|
+
}
|
|
1376
|
+
try {
|
|
1377
|
+
const parsed = parseJsonc(text);
|
|
1378
|
+
if (!isRecord(parsed))
|
|
1379
|
+
return { data: null, diagnostic: `Config ${configPath} must contain a JSON object` };
|
|
1380
|
+
return { data: parsed };
|
|
1381
|
+
} catch {
|
|
1382
|
+
return { data: null, diagnostic: `Could not parse ${configPath}; check the JSON syntax.` };
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
async function loadBundledConfig() {
|
|
1386
|
+
if (BUNDLED_CONFIG_CACHE)
|
|
1387
|
+
return BUNDLED_CONFIG_CACHE;
|
|
1388
|
+
const bundledConfigPath = await resolveBundledAssetPath("tally-config.json");
|
|
1389
|
+
const { data } = await readConfigFile(bundledConfigPath);
|
|
1390
|
+
BUNDLED_CONFIG_CACHE = data ?? {};
|
|
1391
|
+
return BUNDLED_CONFIG_CACHE;
|
|
1392
|
+
}
|
|
1393
|
+
function readBoolean(raw, key, defaultValue, previousValue, diagnostics, label) {
|
|
1394
|
+
const value = raw[key];
|
|
1395
|
+
if (value === undefined)
|
|
1396
|
+
return defaultValue;
|
|
1397
|
+
if (typeof value === "boolean")
|
|
1398
|
+
return value;
|
|
1399
|
+
diagnostics.push(`Invalid ${label}.${key}: expected a boolean. Keeping previous value.`);
|
|
1400
|
+
return previousValue;
|
|
1401
|
+
}
|
|
1402
|
+
function readBoundedNumber(raw, key, min, requireInteger, defaultValue, previousValue, diagnostics, label) {
|
|
1403
|
+
const value = raw[key];
|
|
1404
|
+
if (value === undefined)
|
|
1405
|
+
return defaultValue;
|
|
1406
|
+
const valid = typeof value === "number" && Number.isFinite(value) && value >= min && (!requireInteger || Number.isInteger(value));
|
|
1407
|
+
if (valid)
|
|
1408
|
+
return value;
|
|
1409
|
+
diagnostics.push(`Invalid ${label}.${key}: ${String(value)}; must be ${requireInteger ? "an integer " : ""}>= ${min}. Keeping previous value.`);
|
|
1410
|
+
return previousValue;
|
|
1411
|
+
}
|
|
1412
|
+
function readSections(raw, defaultValue, previousValue, diagnostics) {
|
|
1413
|
+
const value = raw.sections;
|
|
1414
|
+
if (value === undefined)
|
|
1415
|
+
return [...defaultValue];
|
|
1416
|
+
if (!Array.isArray(value)) {
|
|
1417
|
+
diagnostics.push("Invalid sidebar.sections: expected an array. Keeping previous value.");
|
|
1418
|
+
return [...previousValue];
|
|
1419
|
+
}
|
|
1420
|
+
const sections = [];
|
|
1421
|
+
for (const entry of value) {
|
|
1422
|
+
if (typeof entry === "string" && SIDEBAR_SECTION_IDS.includes(entry))
|
|
1423
|
+
sections.push(entry);
|
|
1424
|
+
else
|
|
1425
|
+
diagnostics.push(`Unknown sidebar section: ${String(entry)}`);
|
|
1426
|
+
}
|
|
1427
|
+
return sections.length > 0 ? sections : [...DEFAULT_SIDEBAR_CONFIG.sections];
|
|
1428
|
+
}
|
|
1429
|
+
async function loadSidebarConfig(configPath = USER_TALLY_CONFIG_PATH) {
|
|
1430
|
+
const { data, diagnostic } = await readConfigFile(configPath);
|
|
1431
|
+
const previous = SIDEBAR_LAST_VALID.get(configPath) ?? DEFAULT_SIDEBAR_CONFIG;
|
|
1432
|
+
if (diagnostic)
|
|
1433
|
+
return { value: { ...previous }, diagnostics: [diagnostic] };
|
|
1434
|
+
const bundled = await loadBundledConfig();
|
|
1435
|
+
const raw = { ...asSection(bundled.sidebar), ...asSection(data?.sidebar) };
|
|
1436
|
+
const diagnostics = [];
|
|
1437
|
+
const defaults = DEFAULT_SIDEBAR_CONFIG;
|
|
1438
|
+
const value = {
|
|
1439
|
+
enabled: readBoolean(raw, "enabled", defaults.enabled, previous.enabled, diagnostics, "sidebar"),
|
|
1440
|
+
refreshSeconds: readBoundedNumber(raw, "refreshSeconds", 15, true, defaults.refreshSeconds, previous.refreshSeconds, diagnostics, "sidebar"),
|
|
1441
|
+
sections: readSections(raw, defaults.sections, previous.sections, diagnostics),
|
|
1442
|
+
showBars: readBoolean(raw, "showBars", defaults.showBars, previous.showBars, diagnostics, "sidebar"),
|
|
1443
|
+
showPercentages: readBoolean(raw, "showPercentages", defaults.showPercentages, previous.showPercentages, diagnostics, "sidebar"),
|
|
1444
|
+
showWarnings: readBoolean(raw, "showWarnings", defaults.showWarnings, previous.showWarnings, diagnostics, "sidebar"),
|
|
1445
|
+
showUpdated: readBoolean(raw, "showUpdated", defaults.showUpdated, previous.showUpdated, diagnostics, "sidebar")
|
|
1446
|
+
};
|
|
1447
|
+
SIDEBAR_LAST_VALID.set(configPath, value);
|
|
1448
|
+
return { value, diagnostics };
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
// src/sidebar/config.ts
|
|
1452
|
+
function loadSidebarConfig2() {
|
|
1453
|
+
return loadSidebarConfig();
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// src/sidebar/sections.ts
|
|
1457
|
+
function resolveSections(config) {
|
|
1458
|
+
const known = new Set(DEFAULT_SIDEBAR_CONFIG.sections);
|
|
1459
|
+
const sections = Array.isArray(config?.sections) ? config.sections.filter((section) => known.has(section)) : [];
|
|
1460
|
+
return sections.length > 0 ? sections : [...DEFAULT_SIDEBAR_CONFIG.sections];
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
// src/sidebar/Sidebar.tsx
|
|
1464
|
+
var LABEL_WIDTH2 = 6;
|
|
1465
|
+
var NARROW_LABEL_WIDTH = 5;
|
|
1466
|
+
var VALUE_WIDTH2 = 6;
|
|
1467
|
+
var QUOTA_BAR_WIDTH = 12;
|
|
1468
|
+
var LOCAL_BAR_WIDTH = 8;
|
|
1469
|
+
var TARGET_WIDTH = 34;
|
|
1470
|
+
function usageTotal2(usage) {
|
|
1471
|
+
return usage.input + usage.cacheRead + usage.cacheWrite + usage.output + usage.reasoning;
|
|
1472
|
+
}
|
|
1473
|
+
function recordedRows(usage) {
|
|
1474
|
+
return [{
|
|
1475
|
+
label: "input",
|
|
1476
|
+
tokens: usage.input
|
|
1477
|
+
}, {
|
|
1478
|
+
label: "cache read",
|
|
1479
|
+
tokens: usage.cacheRead
|
|
1480
|
+
}, ...usage.cacheWrite > 0 ? [{
|
|
1481
|
+
label: "cache write",
|
|
1482
|
+
tokens: usage.cacheWrite
|
|
1483
|
+
}] : [], {
|
|
1484
|
+
label: "output",
|
|
1485
|
+
tokens: usage.output
|
|
1486
|
+
}, ...usage.reasoning > 0 ? [{
|
|
1487
|
+
label: "reasoning",
|
|
1488
|
+
tokens: usage.reasoning
|
|
1489
|
+
}] : []];
|
|
1490
|
+
}
|
|
1491
|
+
function recordedDerived(report) {
|
|
1492
|
+
const usage = () => report()?.recorded;
|
|
1493
|
+
return {
|
|
1494
|
+
total: () => {
|
|
1495
|
+
const value = usage();
|
|
1496
|
+
return value ? usageTotal2(value) : 0;
|
|
1497
|
+
},
|
|
1498
|
+
rows: () => {
|
|
1499
|
+
const value = usage();
|
|
1500
|
+
return value ? recordedRows(value) : [];
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
function contextDerived(report) {
|
|
1505
|
+
return {
|
|
1506
|
+
limit: () => report()?.contextLimit,
|
|
1507
|
+
total: () => report()?.content.total ?? 0
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
function contextValueText(total, limit) {
|
|
1511
|
+
const tokens = formatTokens(total, true);
|
|
1512
|
+
return limit === undefined ? `${tokens} tokens` : `${tokens} / ${formatTokens(limit, true)}`;
|
|
1513
|
+
}
|
|
1514
|
+
function LocalRows(props) {
|
|
1515
|
+
return _$createComponent4(For4, {
|
|
1516
|
+
get each() {
|
|
1517
|
+
return props.rows.filter((row) => row.tokens > 0);
|
|
1518
|
+
},
|
|
1519
|
+
children: (row) => _$createComponent4(Row, {
|
|
1520
|
+
get theme() {
|
|
1521
|
+
return props.theme;
|
|
1522
|
+
},
|
|
1523
|
+
get label() {
|
|
1524
|
+
return row.label;
|
|
1525
|
+
},
|
|
1526
|
+
get labelWidth() {
|
|
1527
|
+
return props.labelWidth;
|
|
1528
|
+
},
|
|
1529
|
+
valueWidth: VALUE_WIDTH2,
|
|
1530
|
+
get cells() {
|
|
1531
|
+
return _$memo4(() => !!props.showBars)() ? barCells(props.total > 0 ? row.tokens / props.total * 100 : 0, LOCAL_BAR_WIDTH) : undefined;
|
|
1532
|
+
},
|
|
1533
|
+
get barWidth() {
|
|
1534
|
+
return props.showBars ? LOCAL_BAR_WIDTH : undefined;
|
|
1535
|
+
},
|
|
1536
|
+
get brackets() {
|
|
1537
|
+
return props.showBars;
|
|
1538
|
+
},
|
|
1539
|
+
get percent() {
|
|
1540
|
+
return _$memo4(() => !!props.showPercentages)() ? formatPercent2(row.tokens, props.total) : undefined;
|
|
1541
|
+
},
|
|
1542
|
+
get value() {
|
|
1543
|
+
return formatTokens(row.tokens, true);
|
|
1544
|
+
}
|
|
1545
|
+
})
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
function SidebarView(props) {
|
|
1549
|
+
const labelWidth = () => props.width < 32 ? NARROW_LABEL_WIDTH : LABEL_WIDTH2;
|
|
1550
|
+
const report = () => props.report;
|
|
1551
|
+
const recorded = recordedDerived(report);
|
|
1552
|
+
const context = contextDerived(report);
|
|
1553
|
+
const sections = () => resolveSections(props.config);
|
|
1554
|
+
const renderSection = (section) => {
|
|
1555
|
+
switch (section) {
|
|
1556
|
+
case "quota":
|
|
1557
|
+
return (() => {
|
|
1558
|
+
var _el$ = _$createElement4("box");
|
|
1559
|
+
_$setProp4(_el$, "flexDirection", "column");
|
|
1560
|
+
_$setProp4(_el$, "flexShrink", 0);
|
|
1561
|
+
_$insert4(_el$, (() => {
|
|
1562
|
+
var _c$ = _$memo4(() => !!props.quotaError);
|
|
1563
|
+
return () => _c$() ? (() => {
|
|
1564
|
+
var _el$2 = _$createElement4("text");
|
|
1565
|
+
_$setProp4(_el$2, "wrapMode", "none");
|
|
1566
|
+
_$insert4(_el$2, () => `Quota unavailable: ${props.quotaError?.message ?? ""}`);
|
|
1567
|
+
_$effect4((_$p) => _$setProp4(_el$2, "fg", props.theme.text.feedback.error.base, _$p));
|
|
1568
|
+
return _el$2;
|
|
1569
|
+
})() : null;
|
|
1570
|
+
})(), null);
|
|
1571
|
+
_$insert4(_el$, (() => {
|
|
1572
|
+
var _c$2 = _$memo4(() => !!props.quota);
|
|
1573
|
+
return () => _c$2() ? _$createComponent4(QuotaSection, {
|
|
1574
|
+
get view() {
|
|
1575
|
+
return props.quota;
|
|
1576
|
+
},
|
|
1577
|
+
get theme() {
|
|
1578
|
+
return props.theme;
|
|
1579
|
+
},
|
|
1580
|
+
barWidth: QUOTA_BAR_WIDTH,
|
|
1581
|
+
compact: true,
|
|
1582
|
+
showResetTime: false,
|
|
1583
|
+
get labelWidth() {
|
|
1584
|
+
return labelWidth();
|
|
1585
|
+
},
|
|
1586
|
+
get showBar() {
|
|
1587
|
+
return props.config.showBars;
|
|
1588
|
+
},
|
|
1589
|
+
get showPercent() {
|
|
1590
|
+
return props.config.showPercentages;
|
|
1591
|
+
},
|
|
1592
|
+
get providerDisplays() {
|
|
1593
|
+
return props.quota.providerDisplays;
|
|
1594
|
+
},
|
|
1595
|
+
windowScope: "sidebar"
|
|
1596
|
+
}) : null;
|
|
1597
|
+
})(), null);
|
|
1598
|
+
return _el$;
|
|
1599
|
+
})();
|
|
1600
|
+
case "context":
|
|
1601
|
+
return _$createComponent4(Section, {
|
|
1602
|
+
get theme() {
|
|
1603
|
+
return props.theme;
|
|
1604
|
+
},
|
|
1605
|
+
title: "Context",
|
|
1606
|
+
get children() {
|
|
1607
|
+
return _$createComponent4(Show, {
|
|
1608
|
+
get when() {
|
|
1609
|
+
return report();
|
|
1610
|
+
},
|
|
1611
|
+
children: (_current) => _$createComponent4(Show, {
|
|
1612
|
+
get when() {
|
|
1613
|
+
return context.limit();
|
|
1614
|
+
},
|
|
1615
|
+
keyed: true,
|
|
1616
|
+
get fallback() {
|
|
1617
|
+
return _$createComponent4(Line, {
|
|
1618
|
+
get theme() {
|
|
1619
|
+
return props.theme;
|
|
1620
|
+
},
|
|
1621
|
+
label: "Tokens",
|
|
1622
|
+
get labelWidth() {
|
|
1623
|
+
return labelWidth();
|
|
1624
|
+
},
|
|
1625
|
+
get value() {
|
|
1626
|
+
return contextValueText(context.total(), undefined);
|
|
1627
|
+
},
|
|
1628
|
+
strong: true
|
|
1629
|
+
});
|
|
1630
|
+
},
|
|
1631
|
+
children: (limit) => _$createComponent4(Row, {
|
|
1632
|
+
get theme() {
|
|
1633
|
+
return props.theme;
|
|
1634
|
+
},
|
|
1635
|
+
label: "Tokens",
|
|
1636
|
+
get labelWidth() {
|
|
1637
|
+
return labelWidth();
|
|
1638
|
+
},
|
|
1639
|
+
valueWidth: VALUE_WIDTH2,
|
|
1640
|
+
get cells() {
|
|
1641
|
+
return _$memo4(() => !!props.config.showBars)() ? barCells(context.total() / limit * 100, LOCAL_BAR_WIDTH) : undefined;
|
|
1642
|
+
},
|
|
1643
|
+
get barWidth() {
|
|
1644
|
+
return props.config.showBars ? LOCAL_BAR_WIDTH : undefined;
|
|
1645
|
+
},
|
|
1646
|
+
get brackets() {
|
|
1647
|
+
return props.config.showBars;
|
|
1648
|
+
},
|
|
1649
|
+
get percent() {
|
|
1650
|
+
return _$memo4(() => !!props.config.showPercentages)() ? formatPercent2(context.total(), limit) : undefined;
|
|
1651
|
+
},
|
|
1652
|
+
get value() {
|
|
1653
|
+
return contextValueText(context.total(), limit);
|
|
1654
|
+
},
|
|
1655
|
+
strong: true
|
|
1656
|
+
})
|
|
1657
|
+
})
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
});
|
|
1661
|
+
case "recorded":
|
|
1662
|
+
return _$createComponent4(Section, {
|
|
1663
|
+
get theme() {
|
|
1664
|
+
return props.theme;
|
|
1665
|
+
},
|
|
1666
|
+
title: "Recorded usage",
|
|
1667
|
+
get children() {
|
|
1668
|
+
return _$createComponent4(Show, {
|
|
1669
|
+
get when() {
|
|
1670
|
+
return report();
|
|
1671
|
+
},
|
|
1672
|
+
children: (current) => [_$createComponent4(LocalRows, {
|
|
1673
|
+
get rows() {
|
|
1674
|
+
return recorded.rows();
|
|
1675
|
+
},
|
|
1676
|
+
get total() {
|
|
1677
|
+
return recorded.total();
|
|
1678
|
+
},
|
|
1679
|
+
get theme() {
|
|
1680
|
+
return props.theme;
|
|
1681
|
+
},
|
|
1682
|
+
get labelWidth() {
|
|
1683
|
+
return labelWidth();
|
|
1684
|
+
},
|
|
1685
|
+
get showBars() {
|
|
1686
|
+
return props.config.showBars;
|
|
1687
|
+
},
|
|
1688
|
+
get showPercentages() {
|
|
1689
|
+
return props.config.showPercentages;
|
|
1690
|
+
}
|
|
1691
|
+
}), _$createComponent4(Line, {
|
|
1692
|
+
get theme() {
|
|
1693
|
+
return props.theme;
|
|
1694
|
+
},
|
|
1695
|
+
label: "total",
|
|
1696
|
+
get labelWidth() {
|
|
1697
|
+
return labelWidth();
|
|
1698
|
+
},
|
|
1699
|
+
get value() {
|
|
1700
|
+
return `${formatTokens(recorded.total(), true)} tokens`;
|
|
1701
|
+
},
|
|
1702
|
+
strong: true
|
|
1703
|
+
}), _$createComponent4(Line, {
|
|
1704
|
+
get theme() {
|
|
1705
|
+
return props.theme;
|
|
1706
|
+
},
|
|
1707
|
+
get label() {
|
|
1708
|
+
return current().costBasis === "estimated" ? "cost est" : "cost";
|
|
1709
|
+
},
|
|
1710
|
+
get labelWidth() {
|
|
1711
|
+
return labelWidth();
|
|
1712
|
+
},
|
|
1713
|
+
get value() {
|
|
1714
|
+
return formatUsd(current().cost);
|
|
1715
|
+
},
|
|
1716
|
+
strong: true
|
|
1717
|
+
}), _$createComponent4(Show, {
|
|
1718
|
+
get when() {
|
|
1719
|
+
return current().cache;
|
|
1720
|
+
},
|
|
1721
|
+
children: (cache) => _$createComponent4(Line, {
|
|
1722
|
+
get theme() {
|
|
1723
|
+
return props.theme;
|
|
1724
|
+
},
|
|
1725
|
+
label: "cache hit",
|
|
1726
|
+
get labelWidth() {
|
|
1727
|
+
return labelWidth();
|
|
1728
|
+
},
|
|
1729
|
+
get value() {
|
|
1730
|
+
return `${cache().hitRate.toFixed(1)}% \xB7 saved ${formatUsd(cache().savings)}`;
|
|
1731
|
+
}
|
|
1732
|
+
})
|
|
1733
|
+
})]
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
});
|
|
1737
|
+
case "contextWindow":
|
|
1738
|
+
return _$createComponent4(Section, {
|
|
1739
|
+
get theme() {
|
|
1740
|
+
return props.theme;
|
|
1741
|
+
},
|
|
1742
|
+
title: "Context window",
|
|
1743
|
+
get children() {
|
|
1744
|
+
return _$createComponent4(Show, {
|
|
1745
|
+
get when() {
|
|
1746
|
+
return report();
|
|
1747
|
+
},
|
|
1748
|
+
children: (current) => [_$createComponent4(LocalRows, {
|
|
1749
|
+
get rows() {
|
|
1750
|
+
return current().content.rows;
|
|
1751
|
+
},
|
|
1752
|
+
get total() {
|
|
1753
|
+
return current().content.total;
|
|
1754
|
+
},
|
|
1755
|
+
get theme() {
|
|
1756
|
+
return props.theme;
|
|
1757
|
+
},
|
|
1758
|
+
get labelWidth() {
|
|
1759
|
+
return labelWidth();
|
|
1760
|
+
},
|
|
1761
|
+
get showBars() {
|
|
1762
|
+
return props.config.showBars;
|
|
1763
|
+
},
|
|
1764
|
+
get showPercentages() {
|
|
1765
|
+
return props.config.showPercentages;
|
|
1766
|
+
}
|
|
1767
|
+
}), _$createComponent4(Line, {
|
|
1768
|
+
get theme() {
|
|
1769
|
+
return props.theme;
|
|
1770
|
+
},
|
|
1771
|
+
label: "total",
|
|
1772
|
+
get labelWidth() {
|
|
1773
|
+
return labelWidth();
|
|
1774
|
+
},
|
|
1775
|
+
get value() {
|
|
1776
|
+
return `${formatTokens(current().content.total, true)} tokens`;
|
|
1777
|
+
},
|
|
1778
|
+
strong: true
|
|
1779
|
+
})]
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
return (() => {
|
|
1786
|
+
var _el$3 = _$createElement4("box"), _el$4 = _$createElement4("text");
|
|
1787
|
+
_$insertNode4(_el$3, _el$4);
|
|
1788
|
+
_$setProp4(_el$3, "width", "100%");
|
|
1789
|
+
_$setProp4(_el$3, "flexDirection", "column");
|
|
1790
|
+
_$setProp4(_el$3, "flexShrink", 0);
|
|
1791
|
+
_$setProp4(_el$3, "gap", 1);
|
|
1792
|
+
_$insertNode4(_el$4, _$createTextNode3(`Tally`));
|
|
1793
|
+
_$setProp4(_el$4, "wrapMode", "none");
|
|
1794
|
+
_$insert4(_el$3, _$createComponent4(For4, {
|
|
1795
|
+
get each() {
|
|
1796
|
+
return props.configDiagnostics ?? [];
|
|
1797
|
+
},
|
|
1798
|
+
children: (diagnostic) => (() => {
|
|
1799
|
+
var _el$6 = _$createElement4("text");
|
|
1800
|
+
_$setProp4(_el$6, "wrapMode", "none");
|
|
1801
|
+
_$insert4(_el$6, diagnostic);
|
|
1802
|
+
_$effect4((_$p) => _$setProp4(_el$6, "fg", props.theme.text.feedback.warning.base, _$p));
|
|
1803
|
+
return _el$6;
|
|
1804
|
+
})()
|
|
1805
|
+
}), null);
|
|
1806
|
+
_$insert4(_el$3, (() => {
|
|
1807
|
+
var _c$3 = _$memo4(() => !!props.error);
|
|
1808
|
+
return () => _c$3() ? (() => {
|
|
1809
|
+
var _el$7 = _$createElement4("text");
|
|
1810
|
+
_$setProp4(_el$7, "wrapMode", "none");
|
|
1811
|
+
_$insert4(_el$7, () => `Report unavailable: ${props.error?.message ?? ""}`);
|
|
1812
|
+
_$effect4((_$p) => _$setProp4(_el$7, "fg", props.theme.text.feedback.error.base, _$p));
|
|
1813
|
+
return _el$7;
|
|
1814
|
+
})() : null;
|
|
1815
|
+
})(), null);
|
|
1816
|
+
_$insert4(_el$3, (() => {
|
|
1817
|
+
var _c$4 = _$memo4(() => !!(!props.report && props.loading));
|
|
1818
|
+
return () => _c$4() ? (() => {
|
|
1819
|
+
var _el$8 = _$createElement4("text");
|
|
1820
|
+
_$insertNode4(_el$8, _$createTextNode3(`Analyzing session\u2026`));
|
|
1821
|
+
_$setProp4(_el$8, "wrapMode", "none");
|
|
1822
|
+
_$effect4((_$p) => _$setProp4(_el$8, "fg", props.theme.text.muted, _$p));
|
|
1823
|
+
return _el$8;
|
|
1824
|
+
})() : null;
|
|
1825
|
+
})(), null);
|
|
1826
|
+
_$insert4(_el$3, _$createComponent4(For4, {
|
|
1827
|
+
get each() {
|
|
1828
|
+
return sections();
|
|
1829
|
+
},
|
|
1830
|
+
children: (section) => renderSection(section)
|
|
1831
|
+
}), null);
|
|
1832
|
+
_$insert4(_el$3, _$createComponent4(Show, {
|
|
1833
|
+
get when() {
|
|
1834
|
+
return report();
|
|
1835
|
+
},
|
|
1836
|
+
children: (current) => [_$memo4(() => _$memo4(() => !!(props.config.showWarnings && current().warnings.length > 0))() ? (() => {
|
|
1837
|
+
var _el$0 = _$createElement4("text");
|
|
1838
|
+
_$setProp4(_el$0, "wrapMode", "none");
|
|
1839
|
+
_$insert4(_el$0, () => `! ${current().warnings.length} warnings`);
|
|
1840
|
+
_$effect4((_$p) => _$setProp4(_el$0, "fg", props.theme.text.feedback.warning.base, _$p));
|
|
1841
|
+
return _el$0;
|
|
1842
|
+
})() : null), _$memo4(() => _$memo4(() => !!props.config.showUpdated)() ? (() => {
|
|
1843
|
+
var _el$1 = _$createElement4("text");
|
|
1844
|
+
_$setProp4(_el$1, "wrapMode", "none");
|
|
1845
|
+
_$insert4(_el$1, () => `Updated ${formatTimestamp(props.refreshedAt ?? current().generatedAt)}`);
|
|
1846
|
+
_$effect4((_$p) => _$setProp4(_el$1, "fg", props.theme.text.faint, _$p));
|
|
1847
|
+
return _el$1;
|
|
1848
|
+
})() : null)]
|
|
1849
|
+
}), null);
|
|
1850
|
+
_$effect4((_p$) => {
|
|
1851
|
+
var _v$ = props.theme.text.base, _v$2 = TextAttributes4.BOLD;
|
|
1852
|
+
_v$ !== _p$.e && (_p$.e = _$setProp4(_el$4, "fg", _v$, _p$.e));
|
|
1853
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp4(_el$4, "attributes", _v$2, _p$.t));
|
|
1854
|
+
return _p$;
|
|
1855
|
+
}, {
|
|
1856
|
+
e: undefined,
|
|
1857
|
+
t: undefined
|
|
1858
|
+
});
|
|
1859
|
+
return _el$3;
|
|
1860
|
+
})();
|
|
1861
|
+
}
|
|
1862
|
+
async function loadSidebarData(input) {
|
|
1863
|
+
let config;
|
|
1864
|
+
let configError;
|
|
1865
|
+
let configDiagnostics = [];
|
|
1866
|
+
try {
|
|
1867
|
+
const loaded = await input.loadConfig();
|
|
1868
|
+
config = loaded.value;
|
|
1869
|
+
configDiagnostics = loaded.diagnostics;
|
|
1870
|
+
} catch (failure) {
|
|
1871
|
+
configError = toError(failure);
|
|
1872
|
+
config = DEFAULT_SIDEBAR_CONFIG;
|
|
1873
|
+
}
|
|
1874
|
+
if (!config.enabled)
|
|
1875
|
+
return {
|
|
1876
|
+
config,
|
|
1877
|
+
configError,
|
|
1878
|
+
configDiagnostics
|
|
1879
|
+
};
|
|
1880
|
+
const directory = input.context.data.session.get(input.sessionID)?.location.directory;
|
|
1881
|
+
const [reportResult, quotaResult] = await Promise.allSettled([input.context.client.rpc(TallyRpc).report({
|
|
1882
|
+
sessionID: input.sessionID
|
|
1883
|
+
}, directory ? {
|
|
1884
|
+
location: {
|
|
1885
|
+
directory
|
|
1886
|
+
}
|
|
1887
|
+
} : undefined), input.context.client.rpc(TallyRpc).quota({})]);
|
|
1888
|
+
return {
|
|
1889
|
+
config,
|
|
1890
|
+
configError,
|
|
1891
|
+
configDiagnostics,
|
|
1892
|
+
report: reportResult.status === "fulfilled" ? reportResult.value : undefined,
|
|
1893
|
+
reportError: reportResult.status === "rejected" ? toError(reportResult.reason) : undefined,
|
|
1894
|
+
quota: quotaResult.status === "fulfilled" ? quotaResult.value : undefined,
|
|
1895
|
+
quotaError: quotaResult.status === "rejected" ? toError(quotaResult.reason) : undefined
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
function Sidebar(props) {
|
|
1899
|
+
const theme = props.context.theme;
|
|
1900
|
+
let timer;
|
|
1901
|
+
let disposed = false;
|
|
1902
|
+
const [refreshedAt, setRefreshedAt] = createSignal();
|
|
1903
|
+
const [data, {
|
|
1904
|
+
refetch
|
|
1905
|
+
}] = createResource2(() => props.sessionID, async (sessionID) => {
|
|
1906
|
+
const loaded = await loadSidebarData({
|
|
1907
|
+
context: props.context,
|
|
1908
|
+
sessionID,
|
|
1909
|
+
loadConfig: loadSidebarConfig2
|
|
1910
|
+
});
|
|
1911
|
+
setRefreshedAt(Date.now());
|
|
1912
|
+
return loaded;
|
|
1913
|
+
});
|
|
1914
|
+
const schedule = () => {
|
|
1915
|
+
if (disposed)
|
|
1916
|
+
return;
|
|
1917
|
+
if (timer !== undefined)
|
|
1918
|
+
clearTimeout(timer);
|
|
1919
|
+
const seconds = data()?.config.refreshSeconds ?? DEFAULT_SIDEBAR_CONFIG.refreshSeconds;
|
|
1920
|
+
timer = setTimeout(() => {
|
|
1921
|
+
if (!disposed)
|
|
1922
|
+
refetch();
|
|
1923
|
+
}, seconds * 1000);
|
|
1924
|
+
};
|
|
1925
|
+
createEffect2(() => {
|
|
1926
|
+
if (data())
|
|
1927
|
+
schedule();
|
|
1928
|
+
});
|
|
1929
|
+
onCleanup(() => {
|
|
1930
|
+
disposed = true;
|
|
1931
|
+
if (timer !== undefined)
|
|
1932
|
+
clearTimeout(timer);
|
|
1933
|
+
});
|
|
1934
|
+
const status = createMemo2(() => props.context.data.session.status(props.sessionID));
|
|
1935
|
+
createEffect2(on2(status, (current, previous) => {
|
|
1936
|
+
if (previous === "running" && current === "idle")
|
|
1937
|
+
refetch();
|
|
1938
|
+
}, {
|
|
1939
|
+
defer: true
|
|
1940
|
+
}));
|
|
1941
|
+
const current = () => data();
|
|
1942
|
+
return (() => {
|
|
1943
|
+
var _el$10 = _$createElement4("box");
|
|
1944
|
+
_$setProp4(_el$10, "flexDirection", "column");
|
|
1945
|
+
_$setProp4(_el$10, "flexShrink", 0);
|
|
1946
|
+
_$insert4(_el$10, _$createComponent4(Show, {
|
|
1947
|
+
get when() {
|
|
1948
|
+
return current()?.configError;
|
|
1949
|
+
},
|
|
1950
|
+
children: (error) => (() => {
|
|
1951
|
+
var _el$11 = _$createElement4("text");
|
|
1952
|
+
_$setProp4(_el$11, "wrapMode", "none");
|
|
1953
|
+
_$insert4(_el$11, () => `Config error: ${error().message}`);
|
|
1954
|
+
_$effect4((_$p) => _$setProp4(_el$11, "fg", theme.text.feedback.warning.base, _$p));
|
|
1955
|
+
return _el$11;
|
|
1956
|
+
})()
|
|
1957
|
+
}), null);
|
|
1958
|
+
_$insert4(_el$10, _$createComponent4(Show, {
|
|
1959
|
+
get when() {
|
|
1960
|
+
return current()?.config.enabled ?? true;
|
|
1961
|
+
},
|
|
1962
|
+
get children() {
|
|
1963
|
+
return _$createComponent4(SidebarView, {
|
|
1964
|
+
get report() {
|
|
1965
|
+
return current()?.report;
|
|
1966
|
+
},
|
|
1967
|
+
get quota() {
|
|
1968
|
+
return current()?.quota;
|
|
1969
|
+
},
|
|
1970
|
+
theme,
|
|
1971
|
+
get config() {
|
|
1972
|
+
return current()?.config ?? DEFAULT_SIDEBAR_CONFIG;
|
|
1973
|
+
},
|
|
1974
|
+
width: TARGET_WIDTH,
|
|
1975
|
+
get loading() {
|
|
1976
|
+
return data.loading;
|
|
1977
|
+
},
|
|
1978
|
+
get configDiagnostics() {
|
|
1979
|
+
return current()?.configDiagnostics;
|
|
1980
|
+
},
|
|
1981
|
+
get error() {
|
|
1982
|
+
return current()?.reportError ?? (data.error ? toError(data.error) : undefined);
|
|
1983
|
+
},
|
|
1984
|
+
get quotaError() {
|
|
1985
|
+
return current()?.quotaError;
|
|
1986
|
+
},
|
|
1987
|
+
get refreshedAt() {
|
|
1988
|
+
return refreshedAt();
|
|
1989
|
+
}
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
}), null);
|
|
1993
|
+
return _el$10;
|
|
1994
|
+
})();
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
// src/tui.tsx
|
|
1998
|
+
var tui_default = Plugin.define({
|
|
1999
|
+
id: "tally.tui",
|
|
2000
|
+
setup(context) {
|
|
2001
|
+
context.ui.slot({
|
|
2002
|
+
append: "session.panel",
|
|
2003
|
+
render: (panel) => _$createComponent5(Show2, {
|
|
2004
|
+
get when() {
|
|
2005
|
+
return panel.name === PANEL_NAME;
|
|
2006
|
+
},
|
|
2007
|
+
get children() {
|
|
2008
|
+
return _$createComponent5(ReportPanel, {
|
|
2009
|
+
context,
|
|
2010
|
+
panel
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
})
|
|
2014
|
+
});
|
|
2015
|
+
context.ui.slot({
|
|
2016
|
+
append: "sidebar.content",
|
|
2017
|
+
render: (sidebar) => _$createComponent5(Sidebar, {
|
|
2018
|
+
context,
|
|
2019
|
+
get sessionID() {
|
|
2020
|
+
return sidebar.sessionID;
|
|
2021
|
+
}
|
|
2022
|
+
})
|
|
2023
|
+
});
|
|
2024
|
+
context.ui.slot({
|
|
2025
|
+
append: "app",
|
|
2026
|
+
render: () => {
|
|
2027
|
+
context.keymap.layer(() => ({
|
|
2028
|
+
mode: "global",
|
|
2029
|
+
commands: [{
|
|
2030
|
+
id: "tally.open",
|
|
2031
|
+
title: "Token usage report",
|
|
2032
|
+
description: "Show token usage for this session",
|
|
2033
|
+
group: "Session",
|
|
2034
|
+
slash: {
|
|
2035
|
+
name: "tally"
|
|
2036
|
+
},
|
|
2037
|
+
palette: true,
|
|
2038
|
+
run: () => {
|
|
2039
|
+
context.ui.dialog.clear();
|
|
2040
|
+
const route = context.ui.router.current();
|
|
2041
|
+
const current = context.ui.panel.current();
|
|
2042
|
+
if (route.type === "session" && current?.name === PANEL_NAME && current.sessionID === route.sessionID) {
|
|
2043
|
+
context.ui.panel.close();
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
if (!context.ui.panel.open(PANEL_NAME)) {
|
|
2047
|
+
context.ui.toast.show({
|
|
2048
|
+
message: "Open a session to see its token usage.",
|
|
2049
|
+
variant: "info"
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
}]
|
|
2054
|
+
}));
|
|
2055
|
+
return null;
|
|
2056
|
+
}
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
});
|
|
2060
|
+
export {
|
|
2061
|
+
tui_default as default
|
|
2062
|
+
};
|