pantheon-opencode 1.6.2-beta.1 → 1.6.2-beta.11
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/CHANGELOG.md +171 -0
- package/README.md +236 -60
- package/README.pt-BR.md +19 -1
- package/bin/pantheon-init.mjs +195 -13
- package/package.json +11 -3
- package/plugin.json +1 -1
- package/prompts/README.md +58 -0
- package/prompts/debug-issue.prompt.md +46 -0
- package/prompts/dynamic/agora-generated.txt +38 -0
- package/prompts/dynamic/orchestrate-generated.txt +51 -0
- package/prompts/focus.prompt.md +42 -0
- package/prompts/implement-feature.prompt.md +39 -0
- package/prompts/optimize-database.prompt.md +58 -0
- package/prompts/orchestrate-with-zeus.prompt.md +441 -0
- package/prompts/plan-architecture.prompt.md +59 -0
- package/prompts/quick-discovery-large-codebase.prompt.md +294 -0
- package/prompts/quick-plan-large-feature.prompt.md +197 -0
- package/prompts/semantic-summarize.md +50 -0
- package/prompts/sketch.prompt.md +91 -0
- package/prompts/subtask.prompt.md +131 -0
- package/pyproject.toml +1 -1
- package/scripts/decision-router-budget.mjs +780 -0
- package/scripts/decision-router-v2-budget.mjs +218 -0
- package/scripts/decision-router-v2-egress.mjs +272 -0
- package/scripts/decision-router.mjs +758 -0
- package/scripts/docs-check-changelog.mjs +5 -3
- package/scripts/install/component-selection.mjs +9 -4
- package/scripts/install/decision-layer-preview.mjs +376 -0
- package/scripts/install/decision-router-config.mjs +560 -0
- package/scripts/install/health-check.mjs +20 -11
- package/scripts/install/interactive.mjs +103 -14
- package/scripts/install/interrupt.mjs +4 -3
- package/scripts/install/migrate.mjs +123 -72
- package/scripts/install/opencode.mjs +178 -122
- package/scripts/install/plan.mjs +8 -1
- package/scripts/install/plugin.mjs +4 -3
- package/scripts/install/state.mjs +12 -0
- package/scripts/install/strings.mjs +22 -0
- package/scripts/install/venv.mjs +34 -17
- package/scripts/mcp_resources.py +11 -9
- package/scripts/release-gates.mjs +6 -82
- package/scripts/release-notes.mjs +30 -7
- package/scripts/restore.mjs +22 -10
- package/scripts/sync-tui.mjs +3 -3
- package/scripts/test-opencode-v2-sandbox.sh +10 -6
- package/scripts/versioning.mjs +41 -5
- package/src/agents/aphrodite.md +6 -1
- package/src/agents/apollo.md +1 -0
- package/src/agents/athena.md +1 -0
- package/src/agents/demeter.md +1 -1
- package/src/agents/gaia.md +1 -0
- package/src/agents/hephaestus.md +1 -1
- package/src/agents/hermes.md +8 -10
- package/src/agents/iris.md +1 -1
- package/src/agents/mnemosyne.md +1 -0
- package/src/agents/nyx.md +1 -1
- package/src/agents/prometheus.md +1 -1
- package/src/agents/talos.md +6 -1
- package/src/agents/themis.md +1 -1
- package/src/agents/zeus.md +52 -62
- package/src/mcp/eval_store.py +11 -4
- package/src/mcp/mcp_resources.py +11 -9
- package/src/mcp/memory_mcp.py +293 -150
- package/src/pantheon/cost-command.ts +30 -133
- package/src/pantheon/jev-decision-tool.ts +359 -0
- package/src/pantheon/jev-decisions.ts +625 -0
- package/src/pantheon/local-decision-agents.ts +170 -0
- package/src/pantheon/local-decision-budget.ts +1046 -0
- package/src/pantheon/local-decision-egress-gate.ts +144 -0
- package/src/pantheon/local-decision-prompt.ts +256 -0
- package/src/pantheon/local-decision-provider-matrix.ts +44 -0
- package/src/pantheon/local-decision-router.ts +225 -0
- package/src/pantheon/local-decision-skills.ts +281 -0
- package/src/pantheon/local-decision-tool.ts +160 -0
- package/src/pantheon/local-decision-turn.ts +101 -0
- package/src/pantheon/local-decision-usage-evidence.internal.ts +168 -0
- package/src/pantheon/local-orchestration.ts +322 -0
- package/src/pantheon/model-pricing.ts +1 -536
- package/src/pantheon/pantheon-decision-catalog.ts +101 -0
- package/src/pantheon/v2-decision-budget.ts +456 -0
- package/src/pantheon/v2-decision-contracts.ts +300 -0
- package/src/pantheon/v2-decision-egress.ts +203 -0
- package/src/pantheon/v2-decision-events.ts +180 -0
- package/src/pantheon/v2-decision-heuristic.ts +121 -0
- package/src/pantheon/v2-decision-points/p1-agent.ts +91 -0
- package/src/pantheon/v2-decision-points/p10-claims.ts +243 -0
- package/src/pantheon/v2-decision-points/p11-catalog.ts +220 -0
- package/src/pantheon/v2-decision-points/p2-skill.ts +83 -0
- package/src/pantheon/v2-decision-points/p3-complexity.ts +108 -0
- package/src/pantheon/v2-decision-points/p4-memory.ts +137 -0
- package/src/pantheon/v2-decision-points/p5-themis-verify.ts +190 -0
- package/src/pantheon/v2-decision-points/p6-council.ts +161 -0
- package/src/pantheon/v2-decision-points/p7-loop.ts +263 -0
- package/src/pantheon/v2-decision-points/p8-guardrail.ts +367 -0
- package/src/pantheon/v2-decision-points/p9-memory-compaction.ts +304 -0
- package/src/pantheon/v2-decision-points.ts +242 -0
- package/src/pantheon/v2-decision-policy.ts +166 -0
- package/src/pantheon/v2-decision-premises.ts +146 -0
- package/src/pantheon/v2-decision-prompt-surface.ts +115 -0
- package/src/pantheon/v2-decision-rank.ts +91 -0
- package/src/pantheon/v2-decision-registry.ts +391 -0
- package/src/pantheon/v2-decision-resource-ids.ts +127 -0
- package/src/pantheon/v2-decision-shadow.ts +123 -0
- package/src/pantheon/v2-decision-telemetry.ts +214 -0
- package/src/pantheon/v2-decision-verify.ts +51 -0
- package/src/pantheon/v2-hook-engine.ts +307 -0
- package/src/pantheon/v2-native-decisions.ts +365 -0
- package/src/pantheon/v2-shell-hooks.ts +66 -2
- package/src/pantheon/v2-tools.ts +38 -15
- package/src/plugin-v2.ts +419 -26
- package/src/plugin.ts +4 -0
- package/src/plugins/tui/THIRD_PARTY_NOTICES.md +24 -0
- package/src/plugins/tui/dist/server-v2.d.ts +19 -11
- package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/server-v2.js +19 -666
- package/src/plugins/tui/dist/server-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui-v2.d.ts +11 -203
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +187 -1917
- package/src/plugins/tui/dist/tui-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/package-lock.json +17 -2
- package/src/plugins/tui/package.json +4 -2
- package/src/plugins/tui/src/cost-data.ts +607 -0
- package/src/plugins/tui/src/index-v2.tsx +213 -54
- package/src/plugins/tui/src/model-pricing.ts +536 -0
- package/src/plugins/tui/src/server-v2.ts +18 -838
- package/src/plugins/tui/tsdown.config.ts +28 -6
- package/src/plugins/tui/dist/quota-adapters.d.ts +0 -89
- package/src/plugins/tui/dist/quota-adapters.d.ts.map +0 -1
- package/src/plugins/tui/dist/quota-adapters.js +0 -1142
- package/src/plugins/tui/dist/quota-adapters.js.map +0 -1
- package/src/plugins/tui/dist/quota-cli.d.ts +0 -17
- package/src/plugins/tui/dist/quota-cli.d.ts.map +0 -1
- package/src/plugins/tui/dist/quota-cli.js +0 -184
- package/src/plugins/tui/dist/quota-cli.js.map +0 -1
- package/src/plugins/tui/dist/quota-rpc-UL2HuFRJ.js +0 -390
- package/src/plugins/tui/dist/quota-rpc-UL2HuFRJ.js.map +0 -1
- package/src/plugins/tui/src/go-key-diagnostic-ui.ts +0 -100
- package/src/plugins/tui/src/go-key-diagnostic.ts +0 -125
- package/src/plugins/tui/src/quota-adapters.ts +0 -1598
- package/src/plugins/tui/src/quota-cli.ts +0 -237
- package/src/plugins/tui/src/quota-rpc.ts +0 -209
- package/src/plugins/tui/src/quota-v2-model.ts +0 -1032
- package/src/plugins/tui/src/quota-v2.tsx +0 -986
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { n as quotaRpc, t as QUOTA_PROVIDER_IDS } from "./quota-rpc-UL2HuFRJ.js";
|
|
2
1
|
import { createComponent, createElement, createTextNode, effect, insert, insertNode, memo, setProp } from "@opentui/solid";
|
|
3
2
|
import { readFile } from "node:fs/promises";
|
|
4
3
|
import { homedir } from "node:os";
|
|
@@ -59,744 +58,6 @@ const MODEL_USAGE_VISIBLE_CEILING = 3;
|
|
|
59
58
|
const MODEL_USAGE_MESSAGE_LIMIT = 400;
|
|
60
59
|
const MODEL_USAGE_SESSION_LIMIT = 8;
|
|
61
60
|
//#endregion
|
|
62
|
-
//#region src/go-key-diagnostic-ui.ts
|
|
63
|
-
const EXPLANATIONS = {
|
|
64
|
-
not_run: "No request was sent. No eligible Go API key was available or the attempt was canceled.",
|
|
65
|
-
already_used: "No request was sent. The one-shot diagnostic was already used in this plugin runtime.",
|
|
66
|
-
success: "HTTP success only; not proof of a stable quota contract or parsed quota correctness.",
|
|
67
|
-
unauthorized: "Request rejected; cause unknown.",
|
|
68
|
-
redirect: "Redirect was not followed.",
|
|
69
|
-
http_error: "HTTP error; cause unknown.",
|
|
70
|
-
timeout: "Request timed out; no retry was made.",
|
|
71
|
-
network_error: "Network error; no retry was made."
|
|
72
|
-
};
|
|
73
|
-
const ERROR_STRUCTURE_EXPLANATIONS = {
|
|
74
|
-
present: "erro estruturado presente",
|
|
75
|
-
absent: "erro estruturado não detectado",
|
|
76
|
-
unavailable: "não foi possível inspecionar"
|
|
77
|
-
};
|
|
78
|
-
/** Treat RPC data as untrusted: only render allowlisted categories and coarse metadata. */
|
|
79
|
-
function resultMessage(value) {
|
|
80
|
-
if (!value || typeof value !== "object" || !("category" in value)) return "Diagnostic result unavailable. Request outcome unknown; no automatic retry.";
|
|
81
|
-
const category = value.category;
|
|
82
|
-
if (typeof category !== "string" || !Object.hasOwn(EXPLANATIONS, category)) return "Diagnostic result unavailable. Request outcome unknown; no automatic retry.";
|
|
83
|
-
return `${category}${"status" in value && typeof value.status === "number" && Number.isInteger(value.status) && value.status >= 100 && value.status <= 599 ? ` · HTTP ${value.status}` : ""}${"content_type" in value && typeof value.content_type === "string" && [
|
|
84
|
-
"application/json",
|
|
85
|
-
"text/plain",
|
|
86
|
-
"text/html",
|
|
87
|
-
"other",
|
|
88
|
-
"missing"
|
|
89
|
-
].includes(value.content_type) ? ` · content type: ${value.content_type}` : ""}${category === "unauthorized" && "status" in value && value.status === 401 && "error_structure" in value && typeof value.error_structure === "string" && Object.hasOwn(ERROR_STRUCTURE_EXPLANATIONS, value.error_structure) ? ` · ${ERROR_STRUCTURE_EXPLANATIONS[value.error_structure]}` : ""}\n${EXPLANATIONS[category]}`;
|
|
90
|
-
}
|
|
91
|
-
/** Native keyboard-accessible dialogs; never invoked by quota refresh or panel mounting. */
|
|
92
|
-
function quotaGoCheckCommand(context) {
|
|
93
|
-
let active = false;
|
|
94
|
-
return {
|
|
95
|
-
id: "pantheon.quota.go-check",
|
|
96
|
-
title: "Pantheon: Go API-key check (one-shot)",
|
|
97
|
-
description: "Manual diagnostic with confirmation; not a quota refresh",
|
|
98
|
-
group: "Pantheon",
|
|
99
|
-
palette: true,
|
|
100
|
-
slash: { name: "quota-go-check" },
|
|
101
|
-
run: async () => {
|
|
102
|
-
if (active) return;
|
|
103
|
-
active = true;
|
|
104
|
-
try {
|
|
105
|
-
if (await context.ui.dialog.confirm({
|
|
106
|
-
title: "Go API-key diagnostic — send once?",
|
|
107
|
-
message: "Send one GET to https://opencode.ai/zen/go/v1/usage using the configured Go API key once? OAuth is not used. No request body, redirects, or retries. Only HTTP 401 bodies are inspected (up to 4096 bytes) for a top-level JSON error property; no error values or response details are shown. Rejection cause remains unknown. 5-second timeout. One attempt per plugin runtime, including failed or unavailable-key attempts. This does not refresh quota.",
|
|
108
|
-
label: {
|
|
109
|
-
confirm: "Send once",
|
|
110
|
-
cancel: "Cancel (no request)"
|
|
111
|
-
}
|
|
112
|
-
}) !== true) return;
|
|
113
|
-
let message;
|
|
114
|
-
try {
|
|
115
|
-
message = resultMessage(await context.client.rpc(quotaRpc).go_key_diagnostic({}, { location: context.location ?? context.data.location.default() }));
|
|
116
|
-
} catch {
|
|
117
|
-
message = "Diagnostic result unavailable. Request outcome unknown; no automatic retry.";
|
|
118
|
-
}
|
|
119
|
-
await context.ui.dialog.alert({
|
|
120
|
-
title: "Go API-key diagnostic",
|
|
121
|
-
message
|
|
122
|
-
});
|
|
123
|
-
} finally {
|
|
124
|
-
active = false;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/quota-v2-model.ts
|
|
131
|
-
const DEFAULT_QUOTA_PREFERENCES = {
|
|
132
|
-
enabled: true,
|
|
133
|
-
display: "remaining"
|
|
134
|
-
};
|
|
135
|
-
const QUOTA_CLOCK_INTERVAL_MS = 6e4;
|
|
136
|
-
/** Create a shared local clock for countdown displays; it never refreshes quota data. */
|
|
137
|
-
function createQuotaClock(options = {}) {
|
|
138
|
-
const now = options.now ?? Date.now;
|
|
139
|
-
const schedule = options.setInterval ?? globalThis.setInterval;
|
|
140
|
-
const cancel = options.clearInterval ?? globalThis.clearInterval;
|
|
141
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
142
|
-
let timer;
|
|
143
|
-
const notify = () => {
|
|
144
|
-
const currentTime = now();
|
|
145
|
-
for (const listener of [...listeners]) listener(currentTime);
|
|
146
|
-
};
|
|
147
|
-
return { subscribe(listener) {
|
|
148
|
-
listeners.add(listener);
|
|
149
|
-
if (timer === void 0) {
|
|
150
|
-
timer = schedule(notify, QUOTA_CLOCK_INTERVAL_MS);
|
|
151
|
-
timer.unref?.();
|
|
152
|
-
}
|
|
153
|
-
listener(now());
|
|
154
|
-
let subscribed = true;
|
|
155
|
-
return () => {
|
|
156
|
-
if (!subscribed) return;
|
|
157
|
-
subscribed = false;
|
|
158
|
-
listeners.delete(listener);
|
|
159
|
-
if (listeners.size === 0 && timer !== void 0) {
|
|
160
|
-
cancel(timer);
|
|
161
|
-
timer = void 0;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
} };
|
|
165
|
-
}
|
|
166
|
-
/** Module-local clock shared by all countdown consumers in the TUI bundle. */
|
|
167
|
-
const quotaClock = createQuotaClock();
|
|
168
|
-
/** Format a provider-reported reset timestamp using the caller's local clock. */
|
|
169
|
-
function formatQuotaCountdown(resetsAt, now) {
|
|
170
|
-
if (resetsAt === void 0 || !Number.isFinite(resetsAt) || !Number.isFinite(now)) return;
|
|
171
|
-
const remainingMs = resetsAt - now;
|
|
172
|
-
if (remainingMs <= 0) return null;
|
|
173
|
-
if (remainingMs < 6e4) return "<1m";
|
|
174
|
-
const remainingMinutes = Math.ceil(remainingMs / 6e4);
|
|
175
|
-
const days = Math.floor(remainingMinutes / 1440);
|
|
176
|
-
if (days > 0) {
|
|
177
|
-
const hours = Math.floor(remainingMinutes % 1440 / 60);
|
|
178
|
-
return hours > 0 ? `${days}d ${hours}h` : `${days}d`;
|
|
179
|
-
}
|
|
180
|
-
const hours = Math.floor(remainingMinutes / 60);
|
|
181
|
-
if (hours > 0) {
|
|
182
|
-
const minutes = remainingMinutes % 60;
|
|
183
|
-
return minutes > 0 ? `${hours}h ${minutes}m` : `${hours}h`;
|
|
184
|
-
}
|
|
185
|
-
return `${remainingMinutes}m`;
|
|
186
|
-
}
|
|
187
|
-
const SETTINGS_KEY = "pantheon.quota.preferences.v1";
|
|
188
|
-
const SNAPSHOT_KEY = "pantheon.quota.live.v1";
|
|
189
|
-
const REFRESH_INTERVAL_MS = 6e4;
|
|
190
|
-
const QUOTA_PROVIDER_ID_SET = new Set(QUOTA_PROVIDER_IDS);
|
|
191
|
-
const INITIAL_SNAPSHOT = {
|
|
192
|
-
status: "loading",
|
|
193
|
-
providers: [],
|
|
194
|
-
details: [],
|
|
195
|
-
updatedAt: null
|
|
196
|
-
};
|
|
197
|
-
function asRecord(value) {
|
|
198
|
-
return typeof value === "object" && value !== null ? value : void 0;
|
|
199
|
-
}
|
|
200
|
-
function modelID(ref) {
|
|
201
|
-
const record = asRecord(ref);
|
|
202
|
-
const id = typeof ref === "string" ? ref : record?.id ?? record?.modelID;
|
|
203
|
-
return typeof id === "string" && id.trim() !== "" ? id : null;
|
|
204
|
-
}
|
|
205
|
-
function messageModelRef(message) {
|
|
206
|
-
return message.model ?? message;
|
|
207
|
-
}
|
|
208
|
-
function modelProvider(ref, models) {
|
|
209
|
-
const direct = asRecord(ref)?.providerID;
|
|
210
|
-
if (typeof direct === "string" && direct.trim() !== "") return direct.trim();
|
|
211
|
-
const id = modelID(ref);
|
|
212
|
-
if (id === null) return null;
|
|
213
|
-
const segment = id.slice(id.lastIndexOf("/") + 1);
|
|
214
|
-
const providers = /* @__PURE__ */ new Set();
|
|
215
|
-
for (const candidate of models) {
|
|
216
|
-
const item = asRecord(candidate);
|
|
217
|
-
if (!item) continue;
|
|
218
|
-
if (item.id !== id && item.modelID !== id && item.id !== segment && item.modelID !== segment) continue;
|
|
219
|
-
if (typeof item.providerID === "string" && item.providerID.trim() !== "") providers.add(item.providerID.trim());
|
|
220
|
-
}
|
|
221
|
-
const explicitProvider = id.includes("/") ? id.slice(0, id.indexOf("/")) : null;
|
|
222
|
-
if (explicitProvider && providers.has(explicitProvider)) return explicitProvider;
|
|
223
|
-
return providers.size === 1 ? [...providers][0] ?? null : null;
|
|
224
|
-
}
|
|
225
|
-
function modelIdentity(ref, models) {
|
|
226
|
-
const id = modelID(ref);
|
|
227
|
-
if (id === null) return null;
|
|
228
|
-
const providerID = modelProvider(ref, models);
|
|
229
|
-
const segment = id.slice(id.lastIndexOf("/") + 1);
|
|
230
|
-
return {
|
|
231
|
-
key: `${providerID ?? ""}\u0000${id}`,
|
|
232
|
-
id,
|
|
233
|
-
providerID,
|
|
234
|
-
label: segment || id
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
function tokenCount(message) {
|
|
238
|
-
const tokens = asRecord(message.tokens);
|
|
239
|
-
if (!tokens) return null;
|
|
240
|
-
const cache = asRecord(tokens.cache);
|
|
241
|
-
const reported = [
|
|
242
|
-
tokens.input,
|
|
243
|
-
tokens.output,
|
|
244
|
-
tokens.reasoning,
|
|
245
|
-
cache?.read,
|
|
246
|
-
cache?.write
|
|
247
|
-
].filter((value) => typeof value === "number" && Number.isFinite(value) && value >= 0);
|
|
248
|
-
return reported.length === 0 ? null : reported.reduce((sum, value) => sum + value, 0);
|
|
249
|
-
}
|
|
250
|
-
function validCost(message) {
|
|
251
|
-
const cost = message.cost;
|
|
252
|
-
return typeof cost === "number" && Number.isFinite(cost) && cost >= 0 ? cost : null;
|
|
253
|
-
}
|
|
254
|
-
function contextLimit(ref, models) {
|
|
255
|
-
const id = modelID(ref);
|
|
256
|
-
if (id === null) return null;
|
|
257
|
-
const providerID = modelProvider(ref, models);
|
|
258
|
-
if (providerID === null) return null;
|
|
259
|
-
const segment = id.slice(id.lastIndexOf("/") + 1);
|
|
260
|
-
const matches = models.filter((value) => {
|
|
261
|
-
const model = asRecord(value);
|
|
262
|
-
if (!model) return false;
|
|
263
|
-
return (model.id === id || model.modelID === id || model.id === segment || model.modelID === segment) && model.providerID === providerID;
|
|
264
|
-
});
|
|
265
|
-
const limits = /* @__PURE__ */ new Set();
|
|
266
|
-
for (const candidate of matches) {
|
|
267
|
-
const limit = asRecord(asRecord(candidate)?.limit)?.context;
|
|
268
|
-
if (typeof limit === "number" && Number.isFinite(limit) && limit > 0) limits.add(limit);
|
|
269
|
-
}
|
|
270
|
-
return limits.size === 1 ? [...limits][0] ?? null : null;
|
|
271
|
-
}
|
|
272
|
-
function liveTranscriptWindow(messages, revertMessageID) {
|
|
273
|
-
let end = messages.length;
|
|
274
|
-
if (revertMessageID) {
|
|
275
|
-
const boundary = messages.findIndex((message) => asRecord(message)?.id === revertMessageID);
|
|
276
|
-
if (boundary >= 0) end = boundary;
|
|
277
|
-
}
|
|
278
|
-
let start = 0;
|
|
279
|
-
for (let index = end - 1; index >= 0; index -= 1) if (asRecord(messages[index])?.type === "compaction") {
|
|
280
|
-
start = index + 1;
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
return {
|
|
284
|
-
start,
|
|
285
|
-
end
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
function latestContext(messages, modelRef, models, revertMessageID) {
|
|
289
|
-
const target = modelIdentity(modelRef, models);
|
|
290
|
-
if (target === null || target.providerID === null) return null;
|
|
291
|
-
const limit = contextLimit(modelRef, models);
|
|
292
|
-
if (limit === null || limit <= 0) return null;
|
|
293
|
-
const { start, end } = liveTranscriptWindow(messages, revertMessageID);
|
|
294
|
-
for (let index = end - 1; index >= start; index -= 1) {
|
|
295
|
-
const message = asRecord(messages[index]);
|
|
296
|
-
if (message?.type !== "assistant") continue;
|
|
297
|
-
const identity = modelIdentity(messageModelRef(message), models);
|
|
298
|
-
if (identity?.id !== target.id || identity.providerID !== target.providerID) continue;
|
|
299
|
-
const tokens = tokenCount(message);
|
|
300
|
-
if (tokens === null || tokens <= 0) continue;
|
|
301
|
-
return {
|
|
302
|
-
tokens,
|
|
303
|
-
percent: Math.round(tokens / limit * 100),
|
|
304
|
-
limit
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
309
|
-
/** Snapshot for one exact model identity in the bounded active transcript. */
|
|
310
|
-
function resolveModelContextSnapshot(messages, modelRef, models, revertMessageID) {
|
|
311
|
-
return latestContext(messages.slice(-400), modelRef, models, revertMessageID);
|
|
312
|
-
}
|
|
313
|
-
/** Select the pinned chat model before transcript or configured-agent fallbacks. */
|
|
314
|
-
function resolveActiveModelRef(sessionModel, activeMessages, fallbackModel = null) {
|
|
315
|
-
if (modelID(sessionModel) !== null) return sessionModel;
|
|
316
|
-
const firstMessage = Math.max(0, activeMessages.length - 400);
|
|
317
|
-
for (let index = activeMessages.length - 1; index >= firstMessage; index -= 1) {
|
|
318
|
-
const message = asRecord(activeMessages[index]);
|
|
319
|
-
if (message?.type !== "assistant") continue;
|
|
320
|
-
const ref = messageModelRef(message);
|
|
321
|
-
if (modelID(ref) !== null) return ref;
|
|
322
|
-
}
|
|
323
|
-
return modelID(fallbackModel) === null ? null : fallbackModel;
|
|
324
|
-
}
|
|
325
|
-
/** Pin the active chat first, then rank two distinct models by summed reported
|
|
326
|
-
* tokens from the already-cached, bounded session-family messages. */
|
|
327
|
-
function collectRecentModelUsageRows(input) {
|
|
328
|
-
const models = Array.isArray(input.models) ? input.models : [];
|
|
329
|
-
const activeMessages = input.activeMessages.slice(-400);
|
|
330
|
-
const contextSessions = input.usageSessions ? input.usageSessions.map((session) => ({
|
|
331
|
-
...session,
|
|
332
|
-
messages: session.messages.slice(-400)
|
|
333
|
-
})) : [{
|
|
334
|
-
messages: input.usageMessages.slice(-400),
|
|
335
|
-
revertMessageID: null
|
|
336
|
-
}];
|
|
337
|
-
const usageMessages = contextSessions.flatMap((session) => session.messages);
|
|
338
|
-
const active = modelIdentity(input.activeModel, models);
|
|
339
|
-
const totals = /* @__PURE__ */ new Map();
|
|
340
|
-
for (const value of usageMessages) {
|
|
341
|
-
const message = asRecord(value);
|
|
342
|
-
if (message?.type !== "assistant") continue;
|
|
343
|
-
const identity = modelIdentity(messageModelRef(message), models);
|
|
344
|
-
if (!identity) continue;
|
|
345
|
-
const current = totals.get(identity.key) ?? {
|
|
346
|
-
identity,
|
|
347
|
-
tokens: null,
|
|
348
|
-
cost: null
|
|
349
|
-
};
|
|
350
|
-
const tokens = tokenCount(message);
|
|
351
|
-
const cost = validCost(message);
|
|
352
|
-
if (tokens !== null) current.tokens = (current.tokens ?? 0) + tokens;
|
|
353
|
-
if (cost !== null) current.cost = (current.cost ?? 0) + cost;
|
|
354
|
-
totals.set(identity.key, current);
|
|
355
|
-
}
|
|
356
|
-
const latestContextMessages = /* @__PURE__ */ new Map();
|
|
357
|
-
let contextIndex = 0;
|
|
358
|
-
for (const session of contextSessions) {
|
|
359
|
-
const messages = session.messages;
|
|
360
|
-
const { start, end } = liveTranscriptWindow(messages, session.revertMessageID);
|
|
361
|
-
for (let index = start; index < end; index += 1) {
|
|
362
|
-
const order = contextIndex;
|
|
363
|
-
contextIndex += 1;
|
|
364
|
-
const message = asRecord(messages[index]);
|
|
365
|
-
if (message?.type !== "assistant" || (tokenCount(message) ?? 0) <= 0) continue;
|
|
366
|
-
const identity = modelIdentity(messageModelRef(message), models);
|
|
367
|
-
if (!identity) continue;
|
|
368
|
-
const time = asRecord(message.time);
|
|
369
|
-
const timestamp = typeof time?.created === "number" && Number.isFinite(time.created) ? time.created : null;
|
|
370
|
-
const current = latestContextMessages.get(identity.key);
|
|
371
|
-
if (current === void 0 || (timestamp !== null && current.timestamp !== null ? timestamp >= current.timestamp : order > current.index)) latestContextMessages.set(identity.key, {
|
|
372
|
-
message,
|
|
373
|
-
timestamp,
|
|
374
|
-
index: order
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
const activeUsage = active === null ? void 0 : totals.get(active.key);
|
|
379
|
-
return [{
|
|
380
|
-
providerID: active?.providerID ?? null,
|
|
381
|
-
modelID: active?.id ?? null,
|
|
382
|
-
label: active?.label ?? "Modelo atual",
|
|
383
|
-
tokens: activeUsage?.tokens ?? null,
|
|
384
|
-
cost: activeUsage?.cost ?? null,
|
|
385
|
-
context: active === null ? null : resolveModelContextSnapshot(activeMessages, input.activeModel, models, input.revertMessageID),
|
|
386
|
-
active: true
|
|
387
|
-
}, ...[...totals.values()].filter((entry) => entry.tokens !== null).filter((entry) => {
|
|
388
|
-
if (!active) return true;
|
|
389
|
-
return !(entry.identity.id === active.id && (entry.identity.providerID === null || active.providerID === null || entry.identity.providerID === active.providerID));
|
|
390
|
-
}).sort((left, right) => (right.tokens ?? 0) - (left.tokens ?? 0) || left.identity.label.localeCompare(right.identity.label) || (left.identity.providerID ?? "").localeCompare(right.identity.providerID ?? "")).slice(0, 2).map((entry) => {
|
|
391
|
-
const latest = latestContextMessages.get(entry.identity.key)?.message;
|
|
392
|
-
const modelRef = latest === void 0 ? void 0 : messageModelRef(latest);
|
|
393
|
-
const context = latest === void 0 ? null : latestContext([latest], modelRef, models);
|
|
394
|
-
return {
|
|
395
|
-
providerID: entry.identity.providerID,
|
|
396
|
-
modelID: entry.identity.id,
|
|
397
|
-
label: entry.identity.label,
|
|
398
|
-
tokens: entry.tokens,
|
|
399
|
-
cost: entry.cost,
|
|
400
|
-
context,
|
|
401
|
-
active: false
|
|
402
|
-
};
|
|
403
|
-
})];
|
|
404
|
-
}
|
|
405
|
-
function normalizeQuotaPreferences(value) {
|
|
406
|
-
const settings = asRecord(value);
|
|
407
|
-
return {
|
|
408
|
-
enabled: typeof settings?.enabled === "boolean" ? settings.enabled : DEFAULT_QUOTA_PREFERENCES.enabled,
|
|
409
|
-
display: settings?.display === "used" ? "used" : "remaining"
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
function providerLabel(id) {
|
|
413
|
-
return id.split(/[._-]+/).filter((part) => part.length > 0).map((part) => `${part.charAt(0).toLocaleUpperCase()}${part.slice(1)}`).join(" ");
|
|
414
|
-
}
|
|
415
|
-
function providerStatus(value) {
|
|
416
|
-
const item = asRecord(value);
|
|
417
|
-
if (typeof item?.provider !== "string" || typeof item.label !== "string" || item.scope !== "account" && item.scope !== "selected_key" && item.scope !== "team" && item.scope !== "session" || item.authentication !== "connected" && item.authentication !== "not_connected" && item.authentication !== "unavailable" || item.state !== "available" && item.state !== "needs_setup" && item.state !== "unavailable" || typeof item.reason !== "string" || item.route_kind !== void 0 && item.route_kind !== "api_key" && item.route_kind !== "console_oauth" && item.route_kind !== "none" && item.route_kind !== "unsupported" || !Array.isArray(item.metrics)) return;
|
|
418
|
-
if (!QUOTA_PROVIDER_ID_SET.has(item.provider)) return void 0;
|
|
419
|
-
return {
|
|
420
|
-
provider: item.provider,
|
|
421
|
-
label: item.label,
|
|
422
|
-
scope: item.scope,
|
|
423
|
-
authentication: item.authentication,
|
|
424
|
-
state: item.state,
|
|
425
|
-
reason: item.reason,
|
|
426
|
-
...item.route_kind === void 0 ? {} : { route_kind: item.route_kind },
|
|
427
|
-
metrics: item.metrics
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
function unavailableMessage(reason, provider) {
|
|
431
|
-
if (provider === "opencode-go" && reason === "unauthorized") return "Pedido recusado; uso indisponível. Verifique o Console oficial.";
|
|
432
|
-
if (provider === "opencode-go" && reason === "not_subscribed") return "sem assinatura OpenCode Go nesta conta";
|
|
433
|
-
switch (reason) {
|
|
434
|
-
case "not_connected": return "setup necessário";
|
|
435
|
-
case "unsupported": return "fonte de credencial não suportada";
|
|
436
|
-
case "private_endpoint": return "endpoint privado não validado";
|
|
437
|
-
case "eligibility_unverified": return "elegibilidade da conta não comprovada";
|
|
438
|
-
case "runtime_accounting_unavailable": return "dados de uso do runtime não disponíveis";
|
|
439
|
-
case "cli_identity_unavailable": return "identidade do CLI não validada";
|
|
440
|
-
case "unsupported_credential_method": return "método de autenticação não suportado";
|
|
441
|
-
case "rate_limited": return "limite de consultas; aguarde";
|
|
442
|
-
case "unauthorized": return "credencial rejeitada; reconecte o provedor";
|
|
443
|
-
case "forbidden": return "acesso negado pelo provedor";
|
|
444
|
-
case "timeout": return "tempo limite da consulta";
|
|
445
|
-
case "network_error": return "falha de rede ao consultar";
|
|
446
|
-
case "invalid_response": return "resposta inválida do provedor";
|
|
447
|
-
case "provider_error": return "provedor temporariamente indisponível";
|
|
448
|
-
default: return;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
function metricIsAvailable(metric) {
|
|
452
|
-
switch (metric.kind) {
|
|
453
|
-
case "provider_quota": return Number.isFinite(metric.used) && Number.isFinite(metric.remaining) && metric.unit.trim().length > 0;
|
|
454
|
-
case "balance":
|
|
455
|
-
case "key_usage": return Number.isFinite(metric.amount) && metric.currency.trim().length > 0;
|
|
456
|
-
case "estimate":
|
|
457
|
-
case "session_usage": return Number.isFinite(metric.amount) && metric.unit.trim().length > 0;
|
|
458
|
-
case "provider_status": return metric.status !== "unavailable";
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
function providerHasAvailableMetrics(provider) {
|
|
462
|
-
return provider.state === "available" && provider.metrics.some(metricIsAvailable);
|
|
463
|
-
}
|
|
464
|
-
function quotaSnapshotStatusLabel(status, error) {
|
|
465
|
-
switch (status) {
|
|
466
|
-
case "loading": return "Buscando status…";
|
|
467
|
-
case "ready": return "Quota disponível";
|
|
468
|
-
case "partial": return "Dados parciais";
|
|
469
|
-
case "connected_unavailable": return "Credencial local · dados indisponíveis";
|
|
470
|
-
case "needs_setup": return "Nenhum provedor elegível";
|
|
471
|
-
case "unavailable": return error !== void 0 ? `Erro: ${error}` : "Status indisponível";
|
|
472
|
-
case "stale": return "Dados desatualizados";
|
|
473
|
-
case "disabled": return "Desativado";
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Short, UI-safe summary of a failed status request. OpenCode rejects plugin RPC calls
|
|
478
|
-
* with a plain `{ type, message }` object (not an `Error`), so both shapes are handled;
|
|
479
|
-
* `rpc.unavailable` means no server side registered the quota RPC in this run — the
|
|
480
|
-
* historical "Status indisponível" blind spot.
|
|
481
|
-
*/
|
|
482
|
-
function quotaRpcFaultMessage(error) {
|
|
483
|
-
const message = error instanceof Error ? error.message : typeof error === "object" && error !== null && "message" in error ? String(error.message) : String(error);
|
|
484
|
-
const type = typeof error === "object" && error !== null ? error.type : void 0;
|
|
485
|
-
const cleaned = message.trim().replace(/^Error:\s*/i, "");
|
|
486
|
-
if (type === "rpc.unavailable" || cleaned === "rpc.unavailable") return "rpc de quota indisponível no servidor";
|
|
487
|
-
if (cleaned.length === 0) return "erro desconhecido na consulta de quota";
|
|
488
|
-
return cleaned.length > 80 ? `${cleaned.slice(0, 79)}…` : cleaned;
|
|
489
|
-
}
|
|
490
|
-
/** Map the current typed RPC status into a provider-neutral, data-only UI model. */
|
|
491
|
-
function quotaSnapshotFromStatus(response, now = Date.now()) {
|
|
492
|
-
const statusResponse = asRecord(response);
|
|
493
|
-
const credentialResolutionFailed = statusResponse?.credential_resolution_failed === true;
|
|
494
|
-
const providersValue = statusResponse?.providers;
|
|
495
|
-
const providerList = Array.isArray(providersValue) ? providersValue : void 0;
|
|
496
|
-
const statuses = providerList ? providerList.map(providerStatus).filter((item) => item !== void 0) : [];
|
|
497
|
-
const connected = statuses.filter((item) => item.authentication === "connected");
|
|
498
|
-
const availableConnected = connected.filter(providerHasAvailableMetrics);
|
|
499
|
-
const status = credentialResolutionFailed ? connected.length > 0 ? availableConnected.length > 0 ? "partial" : "connected_unavailable" : "unavailable" : connected.length > 0 ? availableConnected.length === connected.length ? "ready" : availableConnected.length > 0 ? "partial" : "connected_unavailable" : statuses.length === 0 && providerList?.length !== 0 || statuses.some((item) => item.authentication === "unavailable") ? "unavailable" : "needs_setup";
|
|
500
|
-
const details = statuses.map((item) => {
|
|
501
|
-
const hasMetrics = item.authentication === "connected" && providerHasAvailableMetrics(item);
|
|
502
|
-
const message = unavailableMessage(item.reason, item.provider) ?? (item.authentication === "connected" && !hasMetrics ? "dados de quota indisponíveis" : void 0);
|
|
503
|
-
return {
|
|
504
|
-
id: item.provider,
|
|
505
|
-
label: item.label || providerLabel(item.provider),
|
|
506
|
-
authentication: item.authentication,
|
|
507
|
-
state: item.authentication === "not_connected" ? "needs_setup" : hasMetrics ? "available" : "unavailable",
|
|
508
|
-
...message === void 0 ? {} : { message },
|
|
509
|
-
metrics: item.metrics
|
|
510
|
-
};
|
|
511
|
-
});
|
|
512
|
-
return {
|
|
513
|
-
status,
|
|
514
|
-
providers: connected.map((item) => {
|
|
515
|
-
const hasMetrics = providerHasAvailableMetrics(item);
|
|
516
|
-
const message = unavailableMessage(item.reason, item.provider) ?? (!hasMetrics ? "dados de quota indisponíveis" : void 0);
|
|
517
|
-
return {
|
|
518
|
-
id: item.provider,
|
|
519
|
-
label: item.label || providerLabel(item.provider),
|
|
520
|
-
quotaState: hasMetrics ? "available" : "unavailable",
|
|
521
|
-
...message === void 0 ? {} : { message },
|
|
522
|
-
metrics: item.metrics
|
|
523
|
-
};
|
|
524
|
-
}),
|
|
525
|
-
details,
|
|
526
|
-
...status === "unavailable" && credentialResolutionFailed ? { error: "resolução de credenciais falhou no servidor" } : {},
|
|
527
|
-
updatedAt: now
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
function numeric(value) {
|
|
531
|
-
if (!Number.isFinite(value)) return void 0;
|
|
532
|
-
return new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value);
|
|
533
|
-
}
|
|
534
|
-
function amount(value, unit) {
|
|
535
|
-
const formatted = numeric(value);
|
|
536
|
-
const safeUnit = unit.trim();
|
|
537
|
-
return formatted && safeUnit ? `${formatted} ${safeUnit}` : void 0;
|
|
538
|
-
}
|
|
539
|
-
/** Return complementary whole percentages only when both quota values define a real range. */
|
|
540
|
-
function quotaProgress(metric) {
|
|
541
|
-
if (!Number.isFinite(metric.used) || !Number.isFinite(metric.remaining) || metric.used < 0 || metric.remaining < 0) return;
|
|
542
|
-
const total = metric.used + metric.remaining;
|
|
543
|
-
if (!Number.isFinite(total) || total <= 0) return void 0;
|
|
544
|
-
const usedPercent = Math.round(metric.used / total * 100);
|
|
545
|
-
return {
|
|
546
|
-
usedPercent,
|
|
547
|
-
remainingPercent: 100 - usedPercent
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
/** Connected-provider rows for the compact sidebar; only reported quota windows become gauges. */
|
|
551
|
-
function quotaSidebarEntries(snapshot) {
|
|
552
|
-
const entries = [];
|
|
553
|
-
for (const provider of snapshot.providers) {
|
|
554
|
-
let quotaCount = 0;
|
|
555
|
-
let hasQuotaMetric = false;
|
|
556
|
-
provider.metrics.forEach((metric, index) => {
|
|
557
|
-
if (metric.kind !== "provider_quota") return;
|
|
558
|
-
hasQuotaMetric = true;
|
|
559
|
-
if (metric.unit.trim() === "") return;
|
|
560
|
-
const progress = quotaProgress(metric);
|
|
561
|
-
if (!progress) return;
|
|
562
|
-
quotaCount += 1;
|
|
563
|
-
entries.push({
|
|
564
|
-
kind: "quota",
|
|
565
|
-
key: `${provider.id}:quota:${index}`,
|
|
566
|
-
providerID: provider.id,
|
|
567
|
-
providerLabel: provider.label,
|
|
568
|
-
metric,
|
|
569
|
-
progress
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
if (quotaCount === 0 && (provider.quotaState === "unavailable" || hasQuotaMetric)) entries.push({
|
|
573
|
-
kind: "status",
|
|
574
|
-
key: `${provider.id}:status`,
|
|
575
|
-
providerID: provider.id,
|
|
576
|
-
providerLabel: provider.label,
|
|
577
|
-
message: provider.message ?? "dados de quota indisponíveis"
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
return entries;
|
|
581
|
-
}
|
|
582
|
-
/** Render each measurement with its source/category label; no category is inferred. */
|
|
583
|
-
function formatQuotaMetric(metric, display) {
|
|
584
|
-
switch (metric.kind) {
|
|
585
|
-
case "provider_quota": {
|
|
586
|
-
const used = amount(metric.used, metric.unit);
|
|
587
|
-
const remaining = amount(metric.remaining, metric.unit);
|
|
588
|
-
if (!used || !remaining) return void 0;
|
|
589
|
-
const label = metric.label ?? "Quota do provedor";
|
|
590
|
-
const period = metric.period ? ` · ${metric.period}` : "";
|
|
591
|
-
return display === "remaining" ? `${label} · restante ${remaining} · usado ${used}${period}` : `${label} · usado ${used} · restante ${remaining}${period}`;
|
|
592
|
-
}
|
|
593
|
-
case "balance": {
|
|
594
|
-
const balance = amount(metric.amount, metric.currency);
|
|
595
|
-
if (!balance) return void 0;
|
|
596
|
-
const status = metric.status?.trim();
|
|
597
|
-
return `${metric.label ?? "Saldo"} · ${balance}${status ? ` · ${status}` : ""}`;
|
|
598
|
-
}
|
|
599
|
-
case "estimate": {
|
|
600
|
-
const estimate = amount(metric.amount, metric.unit);
|
|
601
|
-
return estimate ? `${metric.label ?? "Estimativa"} · ${estimate}` : void 0;
|
|
602
|
-
}
|
|
603
|
-
case "key_usage": {
|
|
604
|
-
const usage = amount(metric.amount, metric.currency);
|
|
605
|
-
const period = metric.period ? ` · ${metric.period}` : "";
|
|
606
|
-
return usage ? `${metric.label ?? "Uso da chave"} · ${usage}${period}` : void 0;
|
|
607
|
-
}
|
|
608
|
-
case "provider_status": return `${metric.label} · ${metric.status}`;
|
|
609
|
-
case "session_usage": {
|
|
610
|
-
const usage = amount(metric.amount, metric.unit);
|
|
611
|
-
return usage ? `${metric.label ?? "Uso da sessão"} · ${usage}` : void 0;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
/** Compact one-value summary for the footer; quota display follows the setting. */
|
|
616
|
-
function compactQuotaMetric(metric, display) {
|
|
617
|
-
switch (metric.kind) {
|
|
618
|
-
case "provider_quota": {
|
|
619
|
-
const formatted = amount(display === "remaining" ? metric.remaining : metric.used, metric.unit);
|
|
620
|
-
return formatted ? `${metric.label ?? (display === "remaining" ? "restante" : "usado")} ${formatted}` : void 0;
|
|
621
|
-
}
|
|
622
|
-
case "balance": {
|
|
623
|
-
const formatted = amount(metric.amount, metric.currency);
|
|
624
|
-
return formatted ? `${metric.label ?? "saldo"} ${formatted}` : void 0;
|
|
625
|
-
}
|
|
626
|
-
case "estimate": {
|
|
627
|
-
const formatted = amount(metric.amount, metric.unit);
|
|
628
|
-
return formatted ? `${metric.label ?? "estimativa"} ${formatted}` : void 0;
|
|
629
|
-
}
|
|
630
|
-
case "key_usage": {
|
|
631
|
-
const formatted = amount(metric.amount, metric.currency);
|
|
632
|
-
return formatted ? `${metric.label ?? "uso da chave"} ${formatted}` : void 0;
|
|
633
|
-
}
|
|
634
|
-
case "provider_status": return `${metric.label} ${metric.status}`;
|
|
635
|
-
case "session_usage": {
|
|
636
|
-
const formatted = amount(metric.amount, metric.unit);
|
|
637
|
-
return formatted ? `${metric.label ?? "sessão"} ${formatted}` : void 0;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
/** One storage-backed source of truth for all quota TUI surfaces. */
|
|
642
|
-
function createQuotaRuntime(context) {
|
|
643
|
-
const [settings, persistSettings] = context.storage.store(SETTINGS_KEY, { initial: { ...DEFAULT_QUOTA_PREFERENCES } });
|
|
644
|
-
const [snapshot, setSnapshot] = context.storage.memory(SNAPSHOT_KEY, { initial: {
|
|
645
|
-
...INITIAL_SNAPSHOT,
|
|
646
|
-
providers: []
|
|
647
|
-
} });
|
|
648
|
-
const client = context.client.rpc(quotaRpc);
|
|
649
|
-
let unsubscribeCredentialChanges;
|
|
650
|
-
let requestController;
|
|
651
|
-
let refreshTimer;
|
|
652
|
-
let requestVersion = 0;
|
|
653
|
-
let disposed = false;
|
|
654
|
-
const preferences = () => normalizeQuotaPreferences({
|
|
655
|
-
enabled: settings.enabled,
|
|
656
|
-
display: settings.display
|
|
657
|
-
});
|
|
658
|
-
const currentSnapshot = () => ({
|
|
659
|
-
status: snapshot.status,
|
|
660
|
-
providers: snapshot.providers,
|
|
661
|
-
details: snapshot.details ?? [],
|
|
662
|
-
updatedAt: snapshot.updatedAt,
|
|
663
|
-
error: snapshot.error
|
|
664
|
-
});
|
|
665
|
-
const updateSnapshot = (next) => {
|
|
666
|
-
setSnapshot((draft) => {
|
|
667
|
-
draft.status = next.status;
|
|
668
|
-
draft.providers = next.providers;
|
|
669
|
-
draft.details = next.details;
|
|
670
|
-
draft.updatedAt = next.updatedAt;
|
|
671
|
-
draft.error = next.error;
|
|
672
|
-
});
|
|
673
|
-
};
|
|
674
|
-
const cancelScheduledRefresh = () => {
|
|
675
|
-
if (refreshTimer) clearTimeout(refreshTimer);
|
|
676
|
-
refreshTimer = void 0;
|
|
677
|
-
};
|
|
678
|
-
const scheduleRefresh = () => {
|
|
679
|
-
cancelScheduledRefresh();
|
|
680
|
-
if (disposed || !preferences().enabled) return;
|
|
681
|
-
refreshTimer = setTimeout(() => {
|
|
682
|
-
refresh();
|
|
683
|
-
}, REFRESH_INTERVAL_MS);
|
|
684
|
-
refreshTimer.unref?.();
|
|
685
|
-
};
|
|
686
|
-
const refresh = async () => {
|
|
687
|
-
if (disposed) return;
|
|
688
|
-
if (!preferences().enabled) {
|
|
689
|
-
updateSnapshot({
|
|
690
|
-
status: "disabled",
|
|
691
|
-
providers: [],
|
|
692
|
-
details: [],
|
|
693
|
-
updatedAt: null
|
|
694
|
-
});
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
requestController?.abort();
|
|
698
|
-
const controller = new AbortController();
|
|
699
|
-
requestController = controller;
|
|
700
|
-
const version = ++requestVersion;
|
|
701
|
-
const previous = currentSnapshot();
|
|
702
|
-
updateSnapshot({
|
|
703
|
-
...previous,
|
|
704
|
-
status: previous.updatedAt === null ? "loading" : "stale"
|
|
705
|
-
});
|
|
706
|
-
try {
|
|
707
|
-
const response = await client.status({}, {
|
|
708
|
-
signal: controller.signal,
|
|
709
|
-
location: context.location ?? context.data.location.default()
|
|
710
|
-
});
|
|
711
|
-
if (!disposed && version === requestVersion) updateSnapshot(quotaSnapshotFromStatus(response));
|
|
712
|
-
} catch (error) {
|
|
713
|
-
if (!disposed && version === requestVersion && !controller.signal.aborted) {
|
|
714
|
-
const fault = quotaRpcFaultMessage(error);
|
|
715
|
-
console.warn(`[pantheon-tui quota] status request failed: ${fault}`);
|
|
716
|
-
updateSnapshot({
|
|
717
|
-
...previous,
|
|
718
|
-
status: previous.updatedAt === null ? "unavailable" : "stale",
|
|
719
|
-
error: fault
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
} finally {
|
|
723
|
-
if (requestController === controller) {
|
|
724
|
-
requestController = void 0;
|
|
725
|
-
scheduleRefresh();
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
const runtime = {
|
|
730
|
-
preferences,
|
|
731
|
-
snapshot: currentSnapshot,
|
|
732
|
-
async toggleEnabled() {
|
|
733
|
-
const enabled = !preferences().enabled;
|
|
734
|
-
if (!enabled) {
|
|
735
|
-
requestVersion += 1;
|
|
736
|
-
requestController?.abort();
|
|
737
|
-
requestController = void 0;
|
|
738
|
-
cancelScheduledRefresh();
|
|
739
|
-
}
|
|
740
|
-
await persistSettings((draft) => {
|
|
741
|
-
draft.enabled = enabled;
|
|
742
|
-
});
|
|
743
|
-
if (enabled) {
|
|
744
|
-
updateSnapshot({
|
|
745
|
-
status: "loading",
|
|
746
|
-
providers: [],
|
|
747
|
-
details: [],
|
|
748
|
-
updatedAt: null
|
|
749
|
-
});
|
|
750
|
-
await refresh();
|
|
751
|
-
} else updateSnapshot({
|
|
752
|
-
status: "disabled",
|
|
753
|
-
providers: [],
|
|
754
|
-
details: [],
|
|
755
|
-
updatedAt: null
|
|
756
|
-
});
|
|
757
|
-
},
|
|
758
|
-
async toggleDisplay() {
|
|
759
|
-
const display = preferences().display === "remaining" ? "used" : "remaining";
|
|
760
|
-
await persistSettings((draft) => {
|
|
761
|
-
draft.display = display;
|
|
762
|
-
});
|
|
763
|
-
},
|
|
764
|
-
refresh,
|
|
765
|
-
dispose() {
|
|
766
|
-
disposed = true;
|
|
767
|
-
requestVersion += 1;
|
|
768
|
-
requestController?.abort();
|
|
769
|
-
requestController = void 0;
|
|
770
|
-
cancelScheduledRefresh();
|
|
771
|
-
unsubscribeCredentialChanges?.();
|
|
772
|
-
}
|
|
773
|
-
};
|
|
774
|
-
unsubscribeCredentialChanges = client.events?.on("credentials_changed", () => {
|
|
775
|
-
updateSnapshot({
|
|
776
|
-
status: "loading",
|
|
777
|
-
providers: [],
|
|
778
|
-
details: [],
|
|
779
|
-
updatedAt: null
|
|
780
|
-
});
|
|
781
|
-
refresh();
|
|
782
|
-
});
|
|
783
|
-
if (preferences().enabled) {
|
|
784
|
-
updateSnapshot({
|
|
785
|
-
status: "loading",
|
|
786
|
-
providers: [],
|
|
787
|
-
details: [],
|
|
788
|
-
updatedAt: null
|
|
789
|
-
});
|
|
790
|
-
refresh();
|
|
791
|
-
} else updateSnapshot({
|
|
792
|
-
status: "disabled",
|
|
793
|
-
providers: [],
|
|
794
|
-
details: [],
|
|
795
|
-
updatedAt: null
|
|
796
|
-
});
|
|
797
|
-
return runtime;
|
|
798
|
-
}
|
|
799
|
-
//#endregion
|
|
800
61
|
//#region src/sidebar-width.ts
|
|
801
62
|
const GRAPHEMES = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
802
63
|
/** A grapheme the host draws two cells wide: emoji presentation, an extended
|
|
@@ -886,1171 +147,37 @@ function isZeroWidthCodePoint(code, glyph) {
|
|
|
886
147
|
if (code >= 65024 && code <= 65039) return true;
|
|
887
148
|
if (code >= 65056 && code <= 65071) return true;
|
|
888
149
|
if (code >= 917760 && code <= 917999) return true;
|
|
889
|
-
if (code >= 55296 && code <= 57343) return true;
|
|
890
|
-
return IGNORABLE_GLYPH.test(glyph);
|
|
891
|
-
}
|
|
892
|
-
function isWideCodePoint(code) {
|
|
893
|
-
for (const [low, high] of CELL_WIDE_RANGES) {
|
|
894
|
-
if (code < low) return false;
|
|
895
|
-
if (code <= high) return true;
|
|
896
|
-
}
|
|
897
|
-
return false;
|
|
898
|
-
}
|
|
899
|
-
/** Cells one grapheme occupies. */
|
|
900
|
-
function graphemeWidth(segment) {
|
|
901
|
-
if (EMOJI_GLYPH.test(segment)) return 2;
|
|
902
|
-
if (segment.length > 1 && segment.includes(EMOJI_PRESENTATION_SELECTOR)) return 2;
|
|
903
|
-
let width = 0;
|
|
904
|
-
for (const glyph of segment) {
|
|
905
|
-
const code = glyph.codePointAt(0) ?? 0;
|
|
906
|
-
if (isZeroWidthCodePoint(code, glyph)) continue;
|
|
907
|
-
width += isWideCodePoint(code) ? 2 : 1;
|
|
908
|
-
}
|
|
909
|
-
return width;
|
|
910
|
-
}
|
|
911
|
-
/** Terminal cells `value` occupies — the unit every column in this plugin is
|
|
912
|
-
* measured in. Mirrors the host (that is how `@opentui/core` sizes a text
|
|
913
|
-
* run): emoji count as two cells, East Asian Wide/Fullwidth as two, East
|
|
914
|
-
* Asian Ambiguous as one, combining marks and variation selectors as none.
|
|
915
|
-
* Pure. */
|
|
916
|
-
function cellWidth(value) {
|
|
917
|
-
let width = 0;
|
|
918
|
-
for (const { segment } of GRAPHEMES.segment(value)) width += graphemeWidth(segment);
|
|
919
|
-
return width;
|
|
920
|
-
}
|
|
921
|
-
//#endregion
|
|
922
|
-
//#region src/quota-v2.tsx
|
|
923
|
-
/** @jsxImportSource @opentui/solid */
|
|
924
|
-
const QUOTA_PANEL_NAME = "pantheon.quota";
|
|
925
|
-
const QUOTA_OPEN_COMMAND_ID = "pantheon.quota.open";
|
|
926
|
-
const QUOTA_ICON = "▥";
|
|
927
|
-
const QUOTA_PANEL_TOAST = "Abra uma sessão para ver os detalhes da quota.";
|
|
928
|
-
const MODEL_USAGE_REFRESH_EVENTS = [
|
|
929
|
-
"session.created",
|
|
930
|
-
"session.renamed",
|
|
931
|
-
"session.metadata.updated",
|
|
932
|
-
"session.moved",
|
|
933
|
-
"session.idle",
|
|
934
|
-
"session.status",
|
|
935
|
-
"session.deleted"
|
|
936
|
-
];
|
|
937
|
-
function base(context) {
|
|
938
|
-
return context.theme.text?.base ?? (context.themeMode === "dark" ? "#ffffff" : "#111111");
|
|
939
|
-
}
|
|
940
|
-
function muted(context) {
|
|
941
|
-
return context.theme.text?.muted ?? base(context);
|
|
942
|
-
}
|
|
943
|
-
function quotaUsageTone(usedPercent) {
|
|
944
|
-
return usedPercent > 85 ? "error" : usedPercent >= 60 ? "warning" : "success";
|
|
945
|
-
}
|
|
946
|
-
function quotaColor(context, usedPercent) {
|
|
947
|
-
return usedPercent === void 0 ? base(context) : tone(context, quotaUsageTone(usedPercent));
|
|
948
|
-
}
|
|
949
|
-
function tone(context, color) {
|
|
950
|
-
return context.theme.text?.feedback?.[color]?.base ?? base(context);
|
|
951
|
-
}
|
|
952
|
-
function snapshotSummary(snapshot, display) {
|
|
953
|
-
if (snapshot.status === "loading") return "carregando status";
|
|
954
|
-
if (snapshot.status !== "ready" && snapshot.status !== "partial") return quotaSnapshotStatusLabel(snapshot.status, snapshot.error).toLowerCase();
|
|
955
|
-
const metrics = snapshot.providers.flatMap((provider) => provider.metrics);
|
|
956
|
-
const metric = metrics.find((item) => item.kind !== "provider_status") ?? metrics[0];
|
|
957
|
-
if (metric) {
|
|
958
|
-
const value = compactQuotaMetric(metric, display) ?? "quota indisponível";
|
|
959
|
-
return snapshot.status === "partial" ? `parcial · ${value}` : value;
|
|
960
|
-
}
|
|
961
|
-
if (snapshot.status === "partial") return "dados parciais";
|
|
962
|
-
if (snapshot.providers[0]?.message) return snapshot.providers[0].message;
|
|
963
|
-
return "quota indisponível";
|
|
964
|
-
}
|
|
965
|
-
function sidebarFinanceEntries(snapshot) {
|
|
966
|
-
return snapshot.providers.flatMap((provider) => provider.metrics.flatMap((metric) => (metric.kind === "balance" || metric.kind === "estimate" || metric.kind === "key_usage") && metricRow(metric) ? [{
|
|
967
|
-
providerID: provider.id,
|
|
968
|
-
metric
|
|
969
|
-
}] : []));
|
|
970
|
-
}
|
|
971
|
-
function QuotaSidebarEntryRow(props) {
|
|
972
|
-
return createComponent(Show, {
|
|
973
|
-
get when() {
|
|
974
|
-
return props.entry.kind === "quota";
|
|
975
|
-
},
|
|
976
|
-
get fallback() {
|
|
977
|
-
return createComponent(For, {
|
|
978
|
-
get each() {
|
|
979
|
-
return memo(() => props.entry.kind === "status")() ? quotaTextLines(props.entry.message, 34, 2) : [];
|
|
980
|
-
},
|
|
981
|
-
children: (line) => (() => {
|
|
982
|
-
var _el$ = createElement("text");
|
|
983
|
-
insert(_el$, line);
|
|
984
|
-
effect((_$p) => setProp(_el$, "fg", muted(props.context), _$p));
|
|
985
|
-
return _el$;
|
|
986
|
-
})()
|
|
987
|
-
});
|
|
988
|
-
},
|
|
989
|
-
get children() {
|
|
990
|
-
return createComponent(For, {
|
|
991
|
-
get each() {
|
|
992
|
-
return memo(() => props.entry.kind === "quota")() ? quotaWindowLines(props.entry.metric, props.display, 34, props.now, true) : [];
|
|
993
|
-
},
|
|
994
|
-
children: (line) => (() => {
|
|
995
|
-
var _el$2 = createElement("text");
|
|
996
|
-
insert(_el$2, line);
|
|
997
|
-
effect((_$p) => setProp(_el$2, "fg", quotaColor(props.context, props.entry.kind === "quota" ? props.entry.progress.usedPercent : void 0), _$p));
|
|
998
|
-
return _el$2;
|
|
999
|
-
})()
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
function QuotaSidebarSummary(props) {
|
|
1005
|
-
const entries = createMemo(() => quotaSidebarEntries(props.runtime.snapshot()));
|
|
1006
|
-
const finance = createMemo(() => sidebarFinanceEntries(props.runtime.snapshot()));
|
|
1007
|
-
const [now, setNow] = createSignal(Date.now());
|
|
1008
|
-
onMount(() => onCleanup(quotaClock.subscribe(setNow)));
|
|
1009
|
-
return createComponent(Show, {
|
|
1010
|
-
get when() {
|
|
1011
|
-
return props.runtime.preferences().enabled;
|
|
1012
|
-
},
|
|
1013
|
-
get children() {
|
|
1014
|
-
var _el$3 = createElement("box"), _el$4 = createElement("text");
|
|
1015
|
-
insertNode(_el$3, _el$4);
|
|
1016
|
-
setProp(_el$3, "flexDirection", "column");
|
|
1017
|
-
setProp(_el$3, "marginTop", 1);
|
|
1018
|
-
insertNode(_el$4, createTextNode(`▥ Pantheon quota`));
|
|
1019
|
-
insert(_el$3, createComponent(Show, {
|
|
1020
|
-
get when() {
|
|
1021
|
-
return props.runtime.snapshot().status !== "ready" || entries().length === 0;
|
|
1022
|
-
},
|
|
1023
|
-
get children() {
|
|
1024
|
-
var _el$6 = createElement("text");
|
|
1025
|
-
insert(_el$6, () => quotaSnapshotStatusLabel(props.runtime.snapshot().status, props.runtime.snapshot().error));
|
|
1026
|
-
effect((_$p) => setProp(_el$6, "fg", muted(props.context), _$p));
|
|
1027
|
-
return _el$6;
|
|
1028
|
-
}
|
|
1029
|
-
}), null);
|
|
1030
|
-
insert(_el$3, createComponent(For, {
|
|
1031
|
-
get each() {
|
|
1032
|
-
return props.runtime.snapshot().providers;
|
|
1033
|
-
},
|
|
1034
|
-
children: (provider) => (() => {
|
|
1035
|
-
var _el$7 = createElement("box");
|
|
1036
|
-
setProp(_el$7, "flexDirection", "column");
|
|
1037
|
-
insert(_el$7, createComponent(Show, {
|
|
1038
|
-
get when() {
|
|
1039
|
-
return entries().some((entry) => entry.providerID === provider.id) || finance().some((entry) => entry.providerID === provider.id) || provider.metrics.some((metric) => metric.kind === "provider_status");
|
|
1040
|
-
},
|
|
1041
|
-
get children() {
|
|
1042
|
-
return createComponent(For, {
|
|
1043
|
-
get each() {
|
|
1044
|
-
return quotaTextLines(provider.label, 34, 0);
|
|
1045
|
-
},
|
|
1046
|
-
children: (line) => (() => {
|
|
1047
|
-
var _el$8 = createElement("text");
|
|
1048
|
-
insert(_el$8, line);
|
|
1049
|
-
effect((_$p) => setProp(_el$8, "fg", muted(props.context), _$p));
|
|
1050
|
-
return _el$8;
|
|
1051
|
-
})()
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
}), null);
|
|
1055
|
-
insert(_el$7, createComponent(For, {
|
|
1056
|
-
get each() {
|
|
1057
|
-
return entries().filter((entry) => entry.providerID === provider.id);
|
|
1058
|
-
},
|
|
1059
|
-
children: (entry) => createComponent(QuotaSidebarEntryRow, {
|
|
1060
|
-
entry,
|
|
1061
|
-
get display() {
|
|
1062
|
-
return props.runtime.preferences().display;
|
|
1063
|
-
},
|
|
1064
|
-
get context() {
|
|
1065
|
-
return props.context;
|
|
1066
|
-
},
|
|
1067
|
-
get now() {
|
|
1068
|
-
return now();
|
|
1069
|
-
}
|
|
1070
|
-
})
|
|
1071
|
-
}), null);
|
|
1072
|
-
insert(_el$7, createComponent(For, {
|
|
1073
|
-
get each() {
|
|
1074
|
-
return provider.metrics.filter((metric) => metric.kind === "provider_status");
|
|
1075
|
-
},
|
|
1076
|
-
children: (metric) => createComponent(For, {
|
|
1077
|
-
get each() {
|
|
1078
|
-
return quotaMetricLines(metric, 34);
|
|
1079
|
-
},
|
|
1080
|
-
children: (line) => (() => {
|
|
1081
|
-
var _el$9 = createElement("text");
|
|
1082
|
-
insert(_el$9, line);
|
|
1083
|
-
effect((_$p) => setProp(_el$9, "fg", muted(props.context), _$p));
|
|
1084
|
-
return _el$9;
|
|
1085
|
-
})()
|
|
1086
|
-
})
|
|
1087
|
-
}), null);
|
|
1088
|
-
insert(_el$7, createComponent(For, {
|
|
1089
|
-
get each() {
|
|
1090
|
-
return finance().filter((entry) => entry.providerID === provider.id);
|
|
1091
|
-
},
|
|
1092
|
-
children: (entry) => createComponent(For, {
|
|
1093
|
-
get each() {
|
|
1094
|
-
return financeMetricLines(entry.metric, 34);
|
|
1095
|
-
},
|
|
1096
|
-
children: (line) => (() => {
|
|
1097
|
-
var _el$0 = createElement("text");
|
|
1098
|
-
insert(_el$0, line);
|
|
1099
|
-
effect((_$p) => setProp(_el$0, "fg", base(props.context), _$p));
|
|
1100
|
-
return _el$0;
|
|
1101
|
-
})()
|
|
1102
|
-
})
|
|
1103
|
-
}), null);
|
|
1104
|
-
return _el$7;
|
|
1105
|
-
})()
|
|
1106
|
-
}), null);
|
|
1107
|
-
effect((_$p) => setProp(_el$4, "fg", base(props.context), _$p));
|
|
1108
|
-
return _el$3;
|
|
1109
|
-
}
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
function QuotaFooterSummary(props) {
|
|
1113
|
-
const preferences = () => props.runtime.preferences();
|
|
1114
|
-
return createComponent(Show, {
|
|
1115
|
-
get when() {
|
|
1116
|
-
return preferences().enabled;
|
|
1117
|
-
},
|
|
1118
|
-
get children() {
|
|
1119
|
-
var _el$1 = createElement("text");
|
|
1120
|
-
insert(_el$1, () => `Quota · ${snapshotSummary(props.runtime.snapshot(), preferences().display)}`);
|
|
1121
|
-
effect((_$p) => setProp(_el$1, "fg", muted(props.context), _$p));
|
|
1122
|
-
return _el$1;
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
}
|
|
1126
|
-
function clipped(value, width) {
|
|
1127
|
-
const max = Math.max(5, Math.floor(width) - 2);
|
|
1128
|
-
return value.length <= max ? value : `${value.slice(0, max - 1)}…`;
|
|
1129
|
-
}
|
|
1130
|
-
function quotaAmount(value, unit) {
|
|
1131
|
-
const safeUnit = unit.trim();
|
|
1132
|
-
if (!Number.isFinite(value) || !safeUnit) return void 0;
|
|
1133
|
-
return `${new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value)} ${safeUnit}`;
|
|
1134
|
-
}
|
|
1135
|
-
function quotaResetDate(resetsAt, now) {
|
|
1136
|
-
if (resetsAt === void 0 || !Number.isFinite(resetsAt) || !Number.isFinite(now)) return void 0;
|
|
1137
|
-
const date = new Date(resetsAt);
|
|
1138
|
-
if (!Number.isFinite(date.getTime()) || resetsAt <= now) return void 0;
|
|
1139
|
-
return `Resets on ${date.toISOString().slice(0, 16).replace("T", " ")} UTC`;
|
|
1140
|
-
}
|
|
1141
|
-
/** Wrap on grapheme boundaries, measuring terminal cells rather than code units. */
|
|
1142
|
-
function quotaTextLines(text, width, indent) {
|
|
1143
|
-
const max = Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 0;
|
|
1144
|
-
if (max < 1) return [];
|
|
1145
|
-
const padding = " ".repeat(Math.min(Math.max(0, indent), Math.max(0, max - 2)));
|
|
1146
|
-
const lines = [];
|
|
1147
|
-
let line = padding;
|
|
1148
|
-
const segmenter = new Intl.Segmenter();
|
|
1149
|
-
for (const word of text.trim().split(/\s+/)) {
|
|
1150
|
-
if (!word) continue;
|
|
1151
|
-
if (line.trim() && cellWidth(line) + 1 + cellWidth(word) > max) {
|
|
1152
|
-
lines.push(line.trimEnd());
|
|
1153
|
-
line = padding;
|
|
1154
|
-
}
|
|
1155
|
-
if (line.trim()) line += " ";
|
|
1156
|
-
for (const { segment } of segmenter.segment(word)) {
|
|
1157
|
-
const glyphWidth = cellWidth(segment);
|
|
1158
|
-
if (glyphWidth > max) continue;
|
|
1159
|
-
if (cellWidth(line) + glyphWidth > max) {
|
|
1160
|
-
if (line.trim()) lines.push(line.trimEnd());
|
|
1161
|
-
line = glyphWidth + cellWidth(padding) <= max ? padding : "";
|
|
1162
|
-
}
|
|
1163
|
-
line += segment;
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
if (line.trim()) lines.push(line.trimEnd());
|
|
1167
|
-
return lines;
|
|
1168
|
-
}
|
|
1169
|
-
/** Layout uses only a provider-reported reset; a local clock never refreshes data. */
|
|
1170
|
-
function quotaWindowLines(metric, display, width, now, sidebarPercent = false) {
|
|
1171
|
-
const title = metric.period?.trim() || metric.label?.trim() || "Quota";
|
|
1172
|
-
const progress = quotaProgress(metric);
|
|
1173
|
-
const amount = sidebarPercent && progress ? `${display === "remaining" ? progress.remainingPercent : progress.usedPercent}%` : quotaAmount(display === "remaining" ? metric.remaining : metric.used, metric.unit);
|
|
1174
|
-
if (!amount) return [];
|
|
1175
|
-
const value = `${amount} ${display === "remaining" ? "rest." : "uso"}`;
|
|
1176
|
-
const countdown = formatQuotaCountdown(metric.resetsAt, now);
|
|
1177
|
-
const reset = countdown === null ? "(aguardando atualização)" : countdown ? `(${countdown})` : void 0;
|
|
1178
|
-
const resetDate = countdown !== void 0 && countdown !== null ? quotaResetDate(metric.resetsAt, now) : void 0;
|
|
1179
|
-
const resetDateLines = resetDate ? quotaTextLines(resetDate, width, 4) : [];
|
|
1180
|
-
const padded = ` ${title.padEnd(8)} ${value}`;
|
|
1181
|
-
const compact = ` ${title} ${value}`;
|
|
1182
|
-
const prefix = cellWidth(padded) <= width ? padded : compact;
|
|
1183
|
-
const suffix = reset ? ` ${reset}` : "";
|
|
1184
|
-
const rawBar = progress && (sidebarPercent || metric.unit.trim() === "%") ? contextBar(progress.usedPercent, 4) : void 0;
|
|
1185
|
-
const bar = rawBar ? {
|
|
1186
|
-
...rawBar,
|
|
1187
|
-
empty: "░".repeat(cellWidth(rawBar.empty))
|
|
1188
|
-
} : void 0;
|
|
1189
|
-
const secondaryAmount = sidebarPercent ? void 0 : quotaAmount(display === "remaining" ? metric.used : metric.remaining, metric.unit);
|
|
1190
|
-
const secondary = secondaryAmount ? quotaTextLines(`${display === "remaining" ? "Usado" : "Restante"} ${secondaryAmount}`, width, 4) : [];
|
|
1191
|
-
if (!sidebarPercent && progress) secondary.push(...quotaTextLines(`${progress.remainingPercent}% restante`, width, 4));
|
|
1192
|
-
if (bar && cellWidth(prefix + suffix) + 5 <= width) return [
|
|
1193
|
-
`${prefix} ${bar.filled}${bar.empty}${suffix}`,
|
|
1194
|
-
...resetDateLines,
|
|
1195
|
-
...secondary
|
|
1196
|
-
];
|
|
1197
|
-
if (cellWidth(prefix + suffix) <= width) return [
|
|
1198
|
-
`${prefix}${suffix}`,
|
|
1199
|
-
...resetDateLines,
|
|
1200
|
-
...secondary
|
|
1201
|
-
];
|
|
1202
|
-
if (cellWidth(prefix) <= width) return reset ? [
|
|
1203
|
-
prefix,
|
|
1204
|
-
...quotaTextLines(reset, width, 4),
|
|
1205
|
-
...resetDateLines,
|
|
1206
|
-
...secondary
|
|
1207
|
-
] : [
|
|
1208
|
-
prefix,
|
|
1209
|
-
...resetDateLines,
|
|
1210
|
-
...secondary
|
|
1211
|
-
];
|
|
1212
|
-
return [
|
|
1213
|
-
...quotaTextLines(title, width, 2),
|
|
1214
|
-
...quotaTextLines(value, width, 4),
|
|
1215
|
-
...reset ? quotaTextLines(reset, width, 4) : [],
|
|
1216
|
-
...resetDateLines,
|
|
1217
|
-
...secondary
|
|
1218
|
-
];
|
|
1219
|
-
}
|
|
1220
|
-
function QuotaWindow(props) {
|
|
1221
|
-
return (() => {
|
|
1222
|
-
var _el$10 = createElement("box");
|
|
1223
|
-
setProp(_el$10, "flexDirection", "column");
|
|
1224
|
-
insert(_el$10, createComponent(For, {
|
|
1225
|
-
get each() {
|
|
1226
|
-
return quotaWindowLines(props.metric, props.display, props.width, props.now);
|
|
1227
|
-
},
|
|
1228
|
-
children: (line) => (() => {
|
|
1229
|
-
var _el$11 = createElement("text");
|
|
1230
|
-
insert(_el$11, line);
|
|
1231
|
-
effect((_$p) => setProp(_el$11, "fg", quotaColor(props.context, quotaProgress(props.metric)?.usedPercent), _$p));
|
|
1232
|
-
return _el$11;
|
|
1233
|
-
})()
|
|
1234
|
-
}));
|
|
1235
|
-
return _el$10;
|
|
1236
|
-
})();
|
|
1237
|
-
}
|
|
1238
|
-
function metricRow(metric) {
|
|
1239
|
-
const label = (fallback) => metric.label?.trim() || fallback;
|
|
1240
|
-
switch (metric.kind) {
|
|
1241
|
-
case "balance": {
|
|
1242
|
-
const value = quotaAmount(metric.amount, metric.currency);
|
|
1243
|
-
return value ? {
|
|
1244
|
-
label: label("Saldo"),
|
|
1245
|
-
value: `${value}${metric.status?.trim() ? ` · ${metric.status.trim()}` : ""}`
|
|
1246
|
-
} : void 0;
|
|
1247
|
-
}
|
|
1248
|
-
case "estimate": {
|
|
1249
|
-
const value = quotaAmount(metric.amount, metric.unit);
|
|
1250
|
-
return value ? {
|
|
1251
|
-
label: label("Estimativa"),
|
|
1252
|
-
value
|
|
1253
|
-
} : void 0;
|
|
1254
|
-
}
|
|
1255
|
-
case "key_usage": {
|
|
1256
|
-
const value = quotaAmount(metric.amount, metric.currency);
|
|
1257
|
-
if (!value) return void 0;
|
|
1258
|
-
const source = label("Uso da chave selecionada");
|
|
1259
|
-
return {
|
|
1260
|
-
label: /selected\s+key|chave selecionada/i.test(source) ? source : `Chave selecionada · ${source}`,
|
|
1261
|
-
value: `${value}${metric.period?.trim() ? ` · ${metric.period.trim()}` : ""}`
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
case "session_usage": {
|
|
1265
|
-
const value = quotaAmount(metric.amount, metric.unit);
|
|
1266
|
-
return value ? {
|
|
1267
|
-
label: label("Uso da sessão"),
|
|
1268
|
-
value
|
|
1269
|
-
} : void 0;
|
|
1270
|
-
}
|
|
1271
|
-
case "provider_status": return {
|
|
1272
|
-
label: metric.label,
|
|
1273
|
-
value: metric.status
|
|
1274
|
-
};
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
function financeMetricLines(metric, width) {
|
|
1278
|
-
return quotaMetricLines(metric, width);
|
|
1279
|
-
}
|
|
1280
|
-
function quotaMetricLines(metric, width) {
|
|
1281
|
-
const row = metricRow(metric);
|
|
1282
|
-
if (!row) return [];
|
|
1283
|
-
const left = ` ${row.label}`;
|
|
1284
|
-
const spaces = width - cellWidth(left) - cellWidth(row.value);
|
|
1285
|
-
if (spaces >= 2) return [`${left}${" ".repeat(spaces)}${row.value}`];
|
|
1286
|
-
return [...quotaTextLines(row.label, width, 2), ...quotaTextLines(row.value, width, 4)];
|
|
1287
|
-
}
|
|
1288
|
-
function QuotaMetricLine(props) {
|
|
1289
|
-
const row = () => metricRow(props.metric);
|
|
1290
|
-
return createComponent(Show, {
|
|
1291
|
-
get when() {
|
|
1292
|
-
return row();
|
|
1293
|
-
},
|
|
1294
|
-
get children() {
|
|
1295
|
-
var _el$12 = createElement("box");
|
|
1296
|
-
setProp(_el$12, "flexDirection", "column");
|
|
1297
|
-
insert(_el$12, createComponent(For, {
|
|
1298
|
-
get each() {
|
|
1299
|
-
return quotaMetricLines(props.metric, props.width);
|
|
1300
|
-
},
|
|
1301
|
-
children: (line) => (() => {
|
|
1302
|
-
var _el$13 = createElement("text");
|
|
1303
|
-
insert(_el$13, line);
|
|
1304
|
-
effect((_$p) => setProp(_el$13, "fg", base(props.context), _$p));
|
|
1305
|
-
return _el$13;
|
|
1306
|
-
})()
|
|
1307
|
-
}));
|
|
1308
|
-
return _el$12;
|
|
1309
|
-
}
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
function providerState(provider) {
|
|
1313
|
-
if (provider.authentication === "not_connected") return {
|
|
1314
|
-
label: "○ Precisa configurar",
|
|
1315
|
-
tone: "warning"
|
|
1316
|
-
};
|
|
1317
|
-
if (provider.authentication === "unavailable") return {
|
|
1318
|
-
label: "× Indisponível",
|
|
1319
|
-
tone: "error"
|
|
1320
|
-
};
|
|
1321
|
-
return provider.state === "available" ? {
|
|
1322
|
-
label: "✓ Credencial local · há dados",
|
|
1323
|
-
tone: "success"
|
|
1324
|
-
} : {
|
|
1325
|
-
label: "! Credencial local · sem dados",
|
|
1326
|
-
tone: "warning"
|
|
1327
|
-
};
|
|
1328
|
-
}
|
|
1329
|
-
function recentModelUsage(context, sessionID) {
|
|
1330
|
-
if (!sessionID.startsWith("ses")) return collectRecentModelUsageRows({
|
|
1331
|
-
activeModel: null,
|
|
1332
|
-
activeMessages: [],
|
|
1333
|
-
usageMessages: [],
|
|
1334
|
-
models: []
|
|
1335
|
-
});
|
|
1336
|
-
let session;
|
|
1337
|
-
let activeMessages = [];
|
|
1338
|
-
try {
|
|
1339
|
-
session = context.data.session.get(sessionID);
|
|
1340
|
-
} catch {
|
|
1341
|
-
session = void 0;
|
|
1342
|
-
}
|
|
1343
|
-
const messagesBySession = /* @__PURE__ */ new Map();
|
|
1344
|
-
try {
|
|
1345
|
-
const messages = context.data.session.message.list(sessionID);
|
|
1346
|
-
if (Array.isArray(messages)) {
|
|
1347
|
-
activeMessages = messages.slice(-400);
|
|
1348
|
-
messagesBySession.set(sessionID, activeMessages);
|
|
1349
|
-
}
|
|
1350
|
-
} catch {}
|
|
1351
|
-
const sessionIDs = [sessionID];
|
|
1352
|
-
try {
|
|
1353
|
-
const family = context.data.session.family(sessionID);
|
|
1354
|
-
if (Array.isArray(family)) for (const id of family) {
|
|
1355
|
-
if (typeof id !== "string" || !id.startsWith("ses") || sessionIDs.includes(id)) continue;
|
|
1356
|
-
sessionIDs.push(id);
|
|
1357
|
-
if (sessionIDs.length >= 8) break;
|
|
1358
|
-
}
|
|
1359
|
-
} catch {}
|
|
1360
|
-
const usageMessages = [];
|
|
1361
|
-
const usageSessions = [];
|
|
1362
|
-
for (const id of sessionIDs) {
|
|
1363
|
-
let messages = messagesBySession.get(id) ?? [];
|
|
1364
|
-
if (!messagesBySession.has(id)) try {
|
|
1365
|
-
const result = context.data.session.message.list(id);
|
|
1366
|
-
if (Array.isArray(result)) messages = result.slice(-400);
|
|
1367
|
-
} catch {}
|
|
1368
|
-
messagesBySession.set(id, messages);
|
|
1369
|
-
usageMessages.push(...messages);
|
|
1370
|
-
let familySession = session;
|
|
1371
|
-
if (id !== sessionID) try {
|
|
1372
|
-
familySession = context.data.session.get(id);
|
|
1373
|
-
} catch {
|
|
1374
|
-
familySession = void 0;
|
|
1375
|
-
}
|
|
1376
|
-
const revert = familySession?.revert;
|
|
1377
|
-
const revertMessageID = typeof revert === "object" && revert !== null && typeof revert.messageID === "string" ? revert.messageID : null;
|
|
1378
|
-
usageSessions.push({
|
|
1379
|
-
messages,
|
|
1380
|
-
revertMessageID
|
|
1381
|
-
});
|
|
1382
|
-
}
|
|
1383
|
-
let models = [];
|
|
1384
|
-
let fallbackModel = null;
|
|
1385
|
-
try {
|
|
1386
|
-
const location = context.location ?? context.data.location.default();
|
|
1387
|
-
const result = context.data.location.model.list(location);
|
|
1388
|
-
if (Array.isArray(result)) models = result;
|
|
1389
|
-
const agentID = session?.agent;
|
|
1390
|
-
if (typeof agentID === "string" && agentID !== "") {
|
|
1391
|
-
const agents = context.data.location.agent?.list?.(location);
|
|
1392
|
-
if (Array.isArray(agents)) fallbackModel = agents.find((agent) => agent?.id === agentID)?.model ?? null;
|
|
1393
|
-
}
|
|
1394
|
-
} catch {}
|
|
1395
|
-
const activeModel = resolveActiveModelRef(session?.model, activeMessages, fallbackModel);
|
|
1396
|
-
const revert = session?.revert;
|
|
1397
|
-
const revertMessageID = typeof revert === "object" && revert !== null && typeof revert.messageID === "string" ? revert.messageID : null;
|
|
1398
|
-
return collectRecentModelUsageRows({
|
|
1399
|
-
activeModel,
|
|
1400
|
-
activeMessages,
|
|
1401
|
-
usageMessages,
|
|
1402
|
-
usageSessions,
|
|
1403
|
-
models,
|
|
1404
|
-
revertMessageID
|
|
1405
|
-
});
|
|
1406
|
-
}
|
|
1407
|
-
function ModelUsageDetails(props) {
|
|
1408
|
-
const [revision, setRevision] = createSignal(0);
|
|
1409
|
-
const rows = createMemo(() => {
|
|
1410
|
-
revision();
|
|
1411
|
-
return recentModelUsage(props.context, props.sessionID);
|
|
1412
|
-
});
|
|
1413
|
-
onMount(() => {
|
|
1414
|
-
const unsubscribe = [];
|
|
1415
|
-
for (const event of MODEL_USAGE_REFRESH_EVENTS) try {
|
|
1416
|
-
unsubscribe.push(props.context.data.on(event, () => setRevision((value) => value + 1)));
|
|
1417
|
-
} catch {}
|
|
1418
|
-
onCleanup(() => {
|
|
1419
|
-
for (const dispose of unsubscribe) dispose();
|
|
1420
|
-
});
|
|
1421
|
-
});
|
|
1422
|
-
const contextTone = (percent) => tone(props.context, contextUsageTone(percent));
|
|
1423
|
-
const contextCells = () => Math.max(4, Math.min(12, Math.floor((props.width - 30) / 2)));
|
|
1424
|
-
const modelLabel = (row) => `${row.providerID ? `${row.providerID}/` : ""}${row.label}`;
|
|
1425
|
-
return (() => {
|
|
1426
|
-
var _el$14 = createElement("box"), _el$15 = createElement("text"), _el$17 = createElement("text");
|
|
1427
|
-
insertNode(_el$14, _el$15);
|
|
1428
|
-
insertNode(_el$14, _el$17);
|
|
1429
|
-
setProp(_el$14, "flexDirection", "column");
|
|
1430
|
-
setProp(_el$14, "paddingTop", 1);
|
|
1431
|
-
insertNode(_el$15, createTextNode(`Modelos em uso`));
|
|
1432
|
-
setProp(_el$15, "attributes", 1);
|
|
1433
|
-
insertNode(_el$17, createTextNode(`Mensagens recentes da sessão ativa e delegações.`));
|
|
1434
|
-
insert(_el$14, createComponent(For, {
|
|
1435
|
-
get each() {
|
|
1436
|
-
return rows();
|
|
1437
|
-
},
|
|
1438
|
-
children: (row, index) => [
|
|
1439
|
-
createComponent(Show, {
|
|
1440
|
-
get when() {
|
|
1441
|
-
return row.active;
|
|
1442
|
-
},
|
|
1443
|
-
get children() {
|
|
1444
|
-
var _el$19 = createElement("text");
|
|
1445
|
-
insertNode(_el$19, createTextNode(`MODELO ATUAL`));
|
|
1446
|
-
setProp(_el$19, "attributes", 1);
|
|
1447
|
-
effect((_$p) => setProp(_el$19, "fg", tone(props.context, "info"), _$p));
|
|
1448
|
-
return _el$19;
|
|
1449
|
-
}
|
|
1450
|
-
}),
|
|
1451
|
-
createComponent(Show, {
|
|
1452
|
-
get when() {
|
|
1453
|
-
return memo(() => !!!row.active)() && index() === 1;
|
|
1454
|
-
},
|
|
1455
|
-
get children() {
|
|
1456
|
-
var _el$21 = createElement("text");
|
|
1457
|
-
insertNode(_el$21, createTextNode(`MAIS USADOS RECENTEMENTE`));
|
|
1458
|
-
setProp(_el$21, "attributes", 1);
|
|
1459
|
-
effect((_$p) => setProp(_el$21, "fg", muted(props.context), _$p));
|
|
1460
|
-
return _el$21;
|
|
1461
|
-
}
|
|
1462
|
-
}),
|
|
1463
|
-
(() => {
|
|
1464
|
-
var _el$23 = createElement("box"), _el$24 = createElement("text");
|
|
1465
|
-
insertNode(_el$23, _el$24);
|
|
1466
|
-
setProp(_el$23, "flexDirection", "column");
|
|
1467
|
-
setProp(_el$23, "paddingTop", 1);
|
|
1468
|
-
setProp(_el$23, "paddingLeft", 1);
|
|
1469
|
-
setProp(_el$24, "attributes", 1);
|
|
1470
|
-
insert(_el$24, () => clipped(modelLabel(row), props.width - 2));
|
|
1471
|
-
insert(_el$23, createComponent(Show, {
|
|
1472
|
-
get when() {
|
|
1473
|
-
return row.tokens !== null;
|
|
1474
|
-
},
|
|
1475
|
-
get fallback() {
|
|
1476
|
-
return (() => {
|
|
1477
|
-
var _el$31 = createElement("text");
|
|
1478
|
-
insertNode(_el$31, createTextNode(`dados indisponíveis`));
|
|
1479
|
-
effect((_$p) => setProp(_el$31, "fg", muted(props.context), _$p));
|
|
1480
|
-
return _el$31;
|
|
1481
|
-
})();
|
|
1482
|
-
},
|
|
1483
|
-
get children() {
|
|
1484
|
-
var _el$25 = createElement("box"), _el$26 = createElement("text"), _el$28 = createElement("text");
|
|
1485
|
-
insertNode(_el$25, _el$26);
|
|
1486
|
-
insertNode(_el$25, _el$28);
|
|
1487
|
-
setProp(_el$25, "flexDirection", "row");
|
|
1488
|
-
setProp(_el$25, "justifyContent", "space-between");
|
|
1489
|
-
setProp(_el$25, "gap", 1);
|
|
1490
|
-
insertNode(_el$26, createTextNode(`Tokens nas mensagens recentes`));
|
|
1491
|
-
insert(_el$28, () => `${formatTokenCount(row.tokens) ?? "—"}`);
|
|
1492
|
-
effect((_p$) => {
|
|
1493
|
-
var _v$3 = muted(props.context), _v$4 = base(props.context);
|
|
1494
|
-
_v$3 !== _p$.e && (_p$.e = setProp(_el$26, "fg", _v$3, _p$.e));
|
|
1495
|
-
_v$4 !== _p$.t && (_p$.t = setProp(_el$28, "fg", _v$4, _p$.t));
|
|
1496
|
-
return _p$;
|
|
1497
|
-
}, {
|
|
1498
|
-
e: void 0,
|
|
1499
|
-
t: void 0
|
|
1500
|
-
});
|
|
1501
|
-
return _el$25;
|
|
1502
|
-
}
|
|
1503
|
-
}), null);
|
|
1504
|
-
insert(_el$23, createComponent(Show, {
|
|
1505
|
-
get when() {
|
|
1506
|
-
return row.context;
|
|
1507
|
-
},
|
|
1508
|
-
children: (usage) => {
|
|
1509
|
-
const bar = () => contextBar(usage().percent, contextCells());
|
|
1510
|
-
return (() => {
|
|
1511
|
-
var _el$33 = createElement("box"), _el$34 = createElement("box"), _el$35 = createElement("text"), _el$37 = createElement("text"), _el$38 = createElement("box"), _el$39 = createElement("text");
|
|
1512
|
-
insertNode(_el$33, _el$34);
|
|
1513
|
-
insertNode(_el$33, _el$38);
|
|
1514
|
-
setProp(_el$33, "flexDirection", "column");
|
|
1515
|
-
setProp(_el$33, "paddingTop", 1);
|
|
1516
|
-
insertNode(_el$34, _el$35);
|
|
1517
|
-
insertNode(_el$34, _el$37);
|
|
1518
|
-
setProp(_el$34, "flexDirection", "row");
|
|
1519
|
-
setProp(_el$34, "justifyContent", "space-between");
|
|
1520
|
-
setProp(_el$34, "gap", 1);
|
|
1521
|
-
insertNode(_el$35, createTextNode(`Último contexto reportado`));
|
|
1522
|
-
insert(_el$37, () => `${formatTokenCount(usage().tokens) ?? "—"} tokens`);
|
|
1523
|
-
insertNode(_el$38, _el$39);
|
|
1524
|
-
setProp(_el$38, "flexDirection", "row");
|
|
1525
|
-
setProp(_el$38, "gap", 1);
|
|
1526
|
-
insert(_el$38, createComponent(Show, {
|
|
1527
|
-
get when() {
|
|
1528
|
-
return bar();
|
|
1529
|
-
},
|
|
1530
|
-
children: (cells) => [(() => {
|
|
1531
|
-
var _el$40 = createElement("text");
|
|
1532
|
-
insert(_el$40, () => cells().filled);
|
|
1533
|
-
effect((_$p) => setProp(_el$40, "fg", contextTone(usage().percent), _$p));
|
|
1534
|
-
return _el$40;
|
|
1535
|
-
})(), (() => {
|
|
1536
|
-
var _el$41 = createElement("text");
|
|
1537
|
-
insert(_el$41, () => cells().empty);
|
|
1538
|
-
effect((_$p) => setProp(_el$41, "fg", muted(props.context), _$p));
|
|
1539
|
-
return _el$41;
|
|
1540
|
-
})()]
|
|
1541
|
-
}), _el$39);
|
|
1542
|
-
insert(_el$39, () => `${usage().percent}% de ${formatContextWindow(usage().limit) ?? "—"}`);
|
|
1543
|
-
effect((_p$) => {
|
|
1544
|
-
var _v$5 = muted(props.context), _v$6 = contextTone(usage().percent), _v$7 = contextTone(usage().percent);
|
|
1545
|
-
_v$5 !== _p$.e && (_p$.e = setProp(_el$35, "fg", _v$5, _p$.e));
|
|
1546
|
-
_v$6 !== _p$.t && (_p$.t = setProp(_el$37, "fg", _v$6, _p$.t));
|
|
1547
|
-
_v$7 !== _p$.a && (_p$.a = setProp(_el$39, "fg", _v$7, _p$.a));
|
|
1548
|
-
return _p$;
|
|
1549
|
-
}, {
|
|
1550
|
-
e: void 0,
|
|
1551
|
-
t: void 0,
|
|
1552
|
-
a: void 0
|
|
1553
|
-
});
|
|
1554
|
-
return _el$33;
|
|
1555
|
-
})();
|
|
1556
|
-
}
|
|
1557
|
-
}), null);
|
|
1558
|
-
insert(_el$23, createComponent(Show, {
|
|
1559
|
-
get when() {
|
|
1560
|
-
return row.cost !== null;
|
|
1561
|
-
},
|
|
1562
|
-
get children() {
|
|
1563
|
-
return createComponent(For, {
|
|
1564
|
-
get each() {
|
|
1565
|
-
return quotaTextLines(`Custo reportado · mensagens recentes · ${formatSpent(row.cost) ?? "—"}`, props.width - 2, 0);
|
|
1566
|
-
},
|
|
1567
|
-
children: (line) => (() => {
|
|
1568
|
-
var _el$42 = createElement("text");
|
|
1569
|
-
insert(_el$42, line);
|
|
1570
|
-
effect((_$p) => setProp(_el$42, "fg", muted(props.context), _$p));
|
|
1571
|
-
return _el$42;
|
|
1572
|
-
})()
|
|
1573
|
-
});
|
|
1574
|
-
}
|
|
1575
|
-
}), null);
|
|
1576
|
-
insert(_el$23, createComponent(Show, {
|
|
1577
|
-
get when() {
|
|
1578
|
-
return memo(() => row.tokens !== null)() && row.context === null;
|
|
1579
|
-
},
|
|
1580
|
-
get children() {
|
|
1581
|
-
var _el$29 = createElement("text");
|
|
1582
|
-
insertNode(_el$29, createTextNode(`Contexto indisponível`));
|
|
1583
|
-
effect((_$p) => setProp(_el$29, "fg", muted(props.context), _$p));
|
|
1584
|
-
return _el$29;
|
|
1585
|
-
}
|
|
1586
|
-
}), null);
|
|
1587
|
-
effect((_$p) => setProp(_el$24, "fg", base(props.context), _$p));
|
|
1588
|
-
return _el$23;
|
|
1589
|
-
})()
|
|
1590
|
-
]
|
|
1591
|
-
}), null);
|
|
1592
|
-
effect((_p$) => {
|
|
1593
|
-
var _v$ = tone(props.context, "info"), _v$2 = muted(props.context);
|
|
1594
|
-
_v$ !== _p$.e && (_p$.e = setProp(_el$15, "fg", _v$, _p$.e));
|
|
1595
|
-
_v$2 !== _p$.t && (_p$.t = setProp(_el$17, "fg", _v$2, _p$.t));
|
|
1596
|
-
return _p$;
|
|
1597
|
-
}, {
|
|
1598
|
-
e: void 0,
|
|
1599
|
-
t: void 0
|
|
1600
|
-
});
|
|
1601
|
-
return _el$14;
|
|
1602
|
-
})();
|
|
1603
|
-
}
|
|
1604
|
-
function QuotaProviderDetails(props) {
|
|
1605
|
-
const [now, setNow] = createSignal(Date.now());
|
|
1606
|
-
onMount(() => onCleanup(quotaClock.subscribe(setNow)));
|
|
1607
|
-
const state = () => providerState(props.provider);
|
|
1608
|
-
const quotaMetrics = () => props.provider.metrics.filter((metric) => metric.kind === "provider_quota");
|
|
1609
|
-
const financeMetrics = () => props.provider.metrics.filter((metric) => metric.kind === "balance" || metric.kind === "estimate" || metric.kind === "key_usage");
|
|
1610
|
-
const otherMetrics = () => props.provider.metrics.filter((metric) => metric.kind === "provider_status" || metric.kind === "session_usage");
|
|
1611
|
-
const safeError = () => {
|
|
1612
|
-
const message = props.provider.message;
|
|
1613
|
-
return message && message !== "status indisponível" && message !== "dados de quota indisponíveis" && message !== "setup necessário" ? message : void 0;
|
|
1614
|
-
};
|
|
1615
|
-
return (() => {
|
|
1616
|
-
var _el$43 = createElement("box"), _el$48 = createElement("text");
|
|
1617
|
-
insertNode(_el$43, _el$48);
|
|
1618
|
-
setProp(_el$43, "flexDirection", "column");
|
|
1619
|
-
setProp(_el$43, "paddingBottom", 1);
|
|
1620
|
-
insert(_el$43, createComponent(For, {
|
|
1621
|
-
get each() {
|
|
1622
|
-
return quotaTextLines(props.provider.label, props.width, 0);
|
|
1623
|
-
},
|
|
1624
|
-
children: (line) => (() => {
|
|
1625
|
-
var _el$49 = createElement("text");
|
|
1626
|
-
setProp(_el$49, "attributes", 1);
|
|
1627
|
-
insert(_el$49, line);
|
|
1628
|
-
effect((_$p) => setProp(_el$49, "fg", tone(props.context, "info"), _$p));
|
|
1629
|
-
return _el$49;
|
|
1630
|
-
})()
|
|
1631
|
-
}), _el$48);
|
|
1632
|
-
insert(_el$43, createComponent(For, {
|
|
1633
|
-
get each() {
|
|
1634
|
-
return quotaTextLines(state().label, props.width, 0);
|
|
1635
|
-
},
|
|
1636
|
-
children: (line) => (() => {
|
|
1637
|
-
var _el$50 = createElement("text");
|
|
1638
|
-
insert(_el$50, line);
|
|
1639
|
-
effect((_$p) => setProp(_el$50, "fg", tone(props.context, state().tone), _$p));
|
|
1640
|
-
return _el$50;
|
|
1641
|
-
})()
|
|
1642
|
-
}), _el$48);
|
|
1643
|
-
insert(_el$43, createComponent(Show, {
|
|
1644
|
-
get when() {
|
|
1645
|
-
return quotaMetrics().length > 0;
|
|
1646
|
-
},
|
|
1647
|
-
get children() {
|
|
1648
|
-
return createComponent(For, {
|
|
1649
|
-
get each() {
|
|
1650
|
-
return quotaMetrics();
|
|
1651
|
-
},
|
|
1652
|
-
children: (metric) => createComponent(QuotaWindow, {
|
|
1653
|
-
metric,
|
|
1654
|
-
get now() {
|
|
1655
|
-
return now();
|
|
1656
|
-
},
|
|
1657
|
-
get display() {
|
|
1658
|
-
return props.display;
|
|
1659
|
-
},
|
|
1660
|
-
get width() {
|
|
1661
|
-
return props.width;
|
|
1662
|
-
},
|
|
1663
|
-
get context() {
|
|
1664
|
-
return props.context;
|
|
1665
|
-
}
|
|
1666
|
-
})
|
|
1667
|
-
});
|
|
1668
|
-
}
|
|
1669
|
-
}), _el$48);
|
|
1670
|
-
insert(_el$43, createComponent(Show, {
|
|
1671
|
-
get when() {
|
|
1672
|
-
return financeMetrics().length > 0;
|
|
1673
|
-
},
|
|
1674
|
-
get children() {
|
|
1675
|
-
return [(() => {
|
|
1676
|
-
var _el$44 = createElement("text");
|
|
1677
|
-
insertNode(_el$44, createTextNode(`GASTOS & SALDO`));
|
|
1678
|
-
effect((_$p) => setProp(_el$44, "fg", muted(props.context), _$p));
|
|
1679
|
-
return _el$44;
|
|
1680
|
-
})(), createComponent(For, {
|
|
1681
|
-
get each() {
|
|
1682
|
-
return financeMetrics();
|
|
1683
|
-
},
|
|
1684
|
-
children: (metric) => createComponent(QuotaMetricLine, {
|
|
1685
|
-
metric,
|
|
1686
|
-
get width() {
|
|
1687
|
-
return props.width;
|
|
1688
|
-
},
|
|
1689
|
-
get context() {
|
|
1690
|
-
return props.context;
|
|
1691
|
-
}
|
|
1692
|
-
})
|
|
1693
|
-
})];
|
|
1694
|
-
}
|
|
1695
|
-
}), _el$48);
|
|
1696
|
-
insert(_el$43, createComponent(Show, {
|
|
1697
|
-
get when() {
|
|
1698
|
-
return otherMetrics().length > 0;
|
|
1699
|
-
},
|
|
1700
|
-
get children() {
|
|
1701
|
-
return [(() => {
|
|
1702
|
-
var _el$46 = createElement("text");
|
|
1703
|
-
insertNode(_el$46, createTextNode(`OUTRAS MÉTRICAS`));
|
|
1704
|
-
effect((_$p) => setProp(_el$46, "fg", muted(props.context), _$p));
|
|
1705
|
-
return _el$46;
|
|
1706
|
-
})(), createComponent(For, {
|
|
1707
|
-
get each() {
|
|
1708
|
-
return otherMetrics();
|
|
1709
|
-
},
|
|
1710
|
-
children: (metric) => createComponent(QuotaMetricLine, {
|
|
1711
|
-
metric,
|
|
1712
|
-
get width() {
|
|
1713
|
-
return props.width;
|
|
1714
|
-
},
|
|
1715
|
-
get context() {
|
|
1716
|
-
return props.context;
|
|
1717
|
-
}
|
|
1718
|
-
})
|
|
1719
|
-
})];
|
|
1720
|
-
}
|
|
1721
|
-
}), _el$48);
|
|
1722
|
-
insert(_el$43, createComponent(Show, {
|
|
1723
|
-
get when() {
|
|
1724
|
-
return safeError();
|
|
1725
|
-
},
|
|
1726
|
-
children: (message) => (() => {
|
|
1727
|
-
var _el$51 = createElement("text");
|
|
1728
|
-
insert(_el$51, () => clipped(`! ${message()}`, props.width - 2));
|
|
1729
|
-
effect((_$p) => setProp(_el$51, "fg", tone(props.context, "warning"), _$p));
|
|
1730
|
-
return _el$51;
|
|
1731
|
-
})()
|
|
1732
|
-
}), _el$48);
|
|
1733
|
-
insert(_el$48, () => "─".repeat(Math.max(8, Math.min(32, props.width - 4))));
|
|
1734
|
-
effect((_$p) => setProp(_el$48, "fg", muted(props.context), _$p));
|
|
1735
|
-
return _el$43;
|
|
1736
|
-
})();
|
|
1737
|
-
}
|
|
1738
|
-
const QUOTA_PANEL_COMMANDS = [
|
|
1739
|
-
{
|
|
1740
|
-
action: "toggle-enabled",
|
|
1741
|
-
id: "pantheon.quota.toggle-enabled",
|
|
1742
|
-
title: "Quota: ativar/desativar",
|
|
1743
|
-
bind: "e"
|
|
1744
|
-
},
|
|
1745
|
-
{
|
|
1746
|
-
action: "toggle-display",
|
|
1747
|
-
id: "pantheon.quota.toggle-display",
|
|
1748
|
-
title: "Quota: alternar usado/restante",
|
|
1749
|
-
bind: "m"
|
|
1750
|
-
},
|
|
1751
|
-
{
|
|
1752
|
-
action: "refresh",
|
|
1753
|
-
id: "pantheon.quota.refresh",
|
|
1754
|
-
title: "Quota: atualizar",
|
|
1755
|
-
bind: "r"
|
|
1756
|
-
},
|
|
1757
|
-
{
|
|
1758
|
-
action: "close",
|
|
1759
|
-
id: "pantheon.quota.close",
|
|
1760
|
-
title: "Quota: fechar",
|
|
1761
|
-
bind: "escape,q"
|
|
1762
|
-
}
|
|
1763
|
-
];
|
|
1764
|
-
function runQuotaPanelCommand(action, panel, runtime) {
|
|
1765
|
-
if (panel.focused !== true) return false;
|
|
1766
|
-
switch (action) {
|
|
1767
|
-
case "toggle-enabled": return runtime.toggleEnabled();
|
|
1768
|
-
case "toggle-display": return runtime.toggleDisplay();
|
|
1769
|
-
case "refresh": return runtime.refresh();
|
|
1770
|
-
case "close":
|
|
1771
|
-
panel.close();
|
|
1772
|
-
return;
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
function quotaPanelKeymapLayer(panel, runtime) {
|
|
1776
|
-
const focused = () => panel.focused === true;
|
|
1777
|
-
return {
|
|
1778
|
-
mode: "global",
|
|
1779
|
-
enabled: focused,
|
|
1780
|
-
commands: QUOTA_PANEL_COMMANDS.map((command) => ({
|
|
1781
|
-
id: command.id,
|
|
1782
|
-
title: command.title,
|
|
1783
|
-
bind: command.bind,
|
|
1784
|
-
run: () => focused() ? runQuotaPanelCommand(command.action, panel, runtime) : false
|
|
1785
|
-
}))
|
|
1786
|
-
};
|
|
1787
|
-
}
|
|
1788
|
-
function quotaOpenCommand(context) {
|
|
1789
|
-
return {
|
|
1790
|
-
id: QUOTA_OPEN_COMMAND_ID,
|
|
1791
|
-
title: "Pantheon: Quota",
|
|
1792
|
-
description: "Painel de quota",
|
|
1793
|
-
group: "Pantheon",
|
|
1794
|
-
palette: true,
|
|
1795
|
-
slash: {
|
|
1796
|
-
name: "quota",
|
|
1797
|
-
aliases: ["pantheon-quota"]
|
|
1798
|
-
},
|
|
1799
|
-
run: () => {
|
|
1800
|
-
openQuotaPanel(context);
|
|
1801
|
-
}
|
|
1802
|
-
};
|
|
150
|
+
if (code >= 55296 && code <= 57343) return true;
|
|
151
|
+
return IGNORABLE_GLYPH.test(glyph);
|
|
1803
152
|
}
|
|
1804
|
-
function
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
} catch {
|
|
1809
|
-
opened = false;
|
|
153
|
+
function isWideCodePoint(code) {
|
|
154
|
+
for (const [low, high] of CELL_WIDE_RANGES) {
|
|
155
|
+
if (code < low) return false;
|
|
156
|
+
if (code <= high) return true;
|
|
1810
157
|
}
|
|
1811
|
-
if (opened) return true;
|
|
1812
|
-
try {
|
|
1813
|
-
context.ui.toast.show({
|
|
1814
|
-
message: QUOTA_PANEL_TOAST,
|
|
1815
|
-
variant: "warning"
|
|
1816
|
-
});
|
|
1817
|
-
} catch {}
|
|
1818
158
|
return false;
|
|
1819
159
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
case "needs_setup":
|
|
1830
|
-
case "stale": return "warning";
|
|
1831
|
-
case "unavailable": return "error";
|
|
1832
|
-
case "loading":
|
|
1833
|
-
case "disabled": return "info";
|
|
1834
|
-
}
|
|
1835
|
-
};
|
|
1836
|
-
return (() => {
|
|
1837
|
-
var _el$52 = createElement("box"), _el$64 = createElement("scrollbox"), _el$65 = createElement("box"), _el$66 = createElement("box"), _el$67 = createElement("text"), _el$68 = createElement("text"), _el$69 = createElement("text"), _el$71 = createElement("text");
|
|
1838
|
-
insertNode(_el$52, _el$64);
|
|
1839
|
-
insertNode(_el$52, _el$66);
|
|
1840
|
-
setProp(_el$52, "flexDirection", "column");
|
|
1841
|
-
setProp(_el$52, "width", "100%");
|
|
1842
|
-
setProp(_el$52, "height", "100%");
|
|
1843
|
-
setProp(_el$52, "padding", 1);
|
|
1844
|
-
insert(_el$52, createComponent(Show, {
|
|
1845
|
-
get when() {
|
|
1846
|
-
return props.panel.width >= 54;
|
|
1847
|
-
},
|
|
1848
|
-
get fallback() {
|
|
1849
|
-
return (() => {
|
|
1850
|
-
var _el$73 = createElement("box"), _el$74 = createElement("text"), _el$76 = createElement("text");
|
|
1851
|
-
insertNode(_el$73, _el$74);
|
|
1852
|
-
insertNode(_el$73, _el$76);
|
|
1853
|
-
setProp(_el$73, "flexDirection", "column");
|
|
1854
|
-
insertNode(_el$74, createTextNode(`▥ Pantheon / Quota`));
|
|
1855
|
-
setProp(_el$74, "attributes", 1);
|
|
1856
|
-
insert(_el$76, () => quotaSnapshotStatusLabel(snapshot().status, snapshot().error));
|
|
1857
|
-
effect((_p$) => {
|
|
1858
|
-
var _v$15 = tone(props.context, "info"), _v$16 = tone(props.context, snapshotTone());
|
|
1859
|
-
_v$15 !== _p$.e && (_p$.e = setProp(_el$74, "fg", _v$15, _p$.e));
|
|
1860
|
-
_v$16 !== _p$.t && (_p$.t = setProp(_el$76, "fg", _v$16, _p$.t));
|
|
1861
|
-
return _p$;
|
|
1862
|
-
}, {
|
|
1863
|
-
e: void 0,
|
|
1864
|
-
t: void 0
|
|
1865
|
-
});
|
|
1866
|
-
return _el$73;
|
|
1867
|
-
})();
|
|
1868
|
-
},
|
|
1869
|
-
get children() {
|
|
1870
|
-
var _el$53 = createElement("box"), _el$54 = createElement("text"), _el$56 = createElement("text");
|
|
1871
|
-
insertNode(_el$53, _el$54);
|
|
1872
|
-
insertNode(_el$53, _el$56);
|
|
1873
|
-
setProp(_el$53, "flexDirection", "row");
|
|
1874
|
-
setProp(_el$53, "justifyContent", "space-between");
|
|
1875
|
-
setProp(_el$53, "gap", 1);
|
|
1876
|
-
insertNode(_el$54, createTextNode(`▥ Pantheon / Quota`));
|
|
1877
|
-
setProp(_el$54, "attributes", 1);
|
|
1878
|
-
insert(_el$56, () => quotaSnapshotStatusLabel(snapshot().status, snapshot().error));
|
|
1879
|
-
effect((_p$) => {
|
|
1880
|
-
var _v$8 = tone(props.context, "info"), _v$9 = tone(props.context, snapshotTone());
|
|
1881
|
-
_v$8 !== _p$.e && (_p$.e = setProp(_el$54, "fg", _v$8, _p$.e));
|
|
1882
|
-
_v$9 !== _p$.t && (_p$.t = setProp(_el$56, "fg", _v$9, _p$.t));
|
|
1883
|
-
return _p$;
|
|
1884
|
-
}, {
|
|
1885
|
-
e: void 0,
|
|
1886
|
-
t: void 0
|
|
1887
|
-
});
|
|
1888
|
-
return _el$53;
|
|
1889
|
-
}
|
|
1890
|
-
}), _el$64);
|
|
1891
|
-
insert(_el$52, createComponent(Show, {
|
|
1892
|
-
get when() {
|
|
1893
|
-
return memo(() => snapshot().error !== void 0)() && snapshot().status !== "ready";
|
|
1894
|
-
},
|
|
1895
|
-
get children() {
|
|
1896
|
-
var _el$57 = createElement("text");
|
|
1897
|
-
insert(_el$57, () => `Último erro: ${snapshot().error}`);
|
|
1898
|
-
effect((_$p) => setProp(_el$57, "fg", muted(props.context), _$p));
|
|
1899
|
-
return _el$57;
|
|
1900
|
-
}
|
|
1901
|
-
}), _el$64);
|
|
1902
|
-
insert(_el$52, createComponent(Show, {
|
|
1903
|
-
get when() {
|
|
1904
|
-
return memo(() => snapshot().status === "needs_setup")() && snapshot().details.length === 0;
|
|
1905
|
-
},
|
|
1906
|
-
get children() {
|
|
1907
|
-
var _el$58 = createElement("text");
|
|
1908
|
-
insertNode(_el$58, createTextNode(`Nenhum provedor elegível: verifique conexão ativa e credencial local compatível.`));
|
|
1909
|
-
effect((_$p) => setProp(_el$58, "fg", muted(props.context), _$p));
|
|
1910
|
-
return _el$58;
|
|
1911
|
-
}
|
|
1912
|
-
}), _el$64);
|
|
1913
|
-
insert(_el$52, createComponent(Show, {
|
|
1914
|
-
get when() {
|
|
1915
|
-
return snapshot().status === "unavailable";
|
|
1916
|
-
},
|
|
1917
|
-
get children() {
|
|
1918
|
-
var _el$60 = createElement("text");
|
|
1919
|
-
insertNode(_el$60, createTextNode(`Não foi possível verificar o status da quota.`));
|
|
1920
|
-
effect((_$p) => setProp(_el$60, "fg", muted(props.context), _$p));
|
|
1921
|
-
return _el$60;
|
|
1922
|
-
}
|
|
1923
|
-
}), _el$64);
|
|
1924
|
-
insert(_el$52, createComponent(Show, {
|
|
1925
|
-
get when() {
|
|
1926
|
-
return snapshot().status === "stale";
|
|
1927
|
-
},
|
|
1928
|
-
get children() {
|
|
1929
|
-
var _el$62 = createElement("text");
|
|
1930
|
-
insertNode(_el$62, createTextNode(`A última resposta continua visível; atualize para tentar novamente.`));
|
|
1931
|
-
effect((_$p) => setProp(_el$62, "fg", muted(props.context), _$p));
|
|
1932
|
-
return _el$62;
|
|
1933
|
-
}
|
|
1934
|
-
}), _el$64);
|
|
1935
|
-
insertNode(_el$64, _el$65);
|
|
1936
|
-
setProp(_el$64, "flexGrow", 1);
|
|
1937
|
-
setProp(_el$64, "flexShrink", 1);
|
|
1938
|
-
setProp(_el$64, "flexBasis", 0);
|
|
1939
|
-
setProp(_el$64, "minHeight", 3);
|
|
1940
|
-
setProp(_el$64, "width", "100%");
|
|
1941
|
-
setProp(_el$64, "scrollY", true);
|
|
1942
|
-
setProp(_el$64, "focusable", true);
|
|
1943
|
-
setProp(_el$64, "border", true);
|
|
1944
|
-
setProp(_el$65, "flexDirection", "column");
|
|
1945
|
-
setProp(_el$65, "paddingX", 1);
|
|
1946
|
-
setProp(_el$65, "paddingY", 1);
|
|
1947
|
-
insert(_el$65, createComponent(For, {
|
|
1948
|
-
get each() {
|
|
1949
|
-
return snapshot().details;
|
|
1950
|
-
},
|
|
1951
|
-
children: (provider) => createComponent(QuotaProviderDetails, {
|
|
1952
|
-
provider,
|
|
1953
|
-
get display() {
|
|
1954
|
-
return preferences().display;
|
|
1955
|
-
},
|
|
1956
|
-
get width() {
|
|
1957
|
-
return props.panel.width - 4;
|
|
1958
|
-
},
|
|
1959
|
-
get context() {
|
|
1960
|
-
return props.context;
|
|
1961
|
-
}
|
|
1962
|
-
})
|
|
1963
|
-
}), null);
|
|
1964
|
-
insert(_el$65, createComponent(ModelUsageDetails, {
|
|
1965
|
-
get context() {
|
|
1966
|
-
return props.context;
|
|
1967
|
-
},
|
|
1968
|
-
get sessionID() {
|
|
1969
|
-
return props.panel.sessionID;
|
|
1970
|
-
},
|
|
1971
|
-
get width() {
|
|
1972
|
-
return props.panel.width - 6;
|
|
1973
|
-
}
|
|
1974
|
-
}), null);
|
|
1975
|
-
insertNode(_el$66, _el$67);
|
|
1976
|
-
insertNode(_el$66, _el$68);
|
|
1977
|
-
insertNode(_el$66, _el$69);
|
|
1978
|
-
insertNode(_el$66, _el$71);
|
|
1979
|
-
setProp(_el$66, "flexDirection", "column");
|
|
1980
|
-
setProp(_el$66, "flexShrink", 0);
|
|
1981
|
-
insert(_el$67, () => `Quota ${preferences().enabled ? "ativada" : "desativada"} · exibição: ${preferences().display === "remaining" ? "restante" : "usado"}`);
|
|
1982
|
-
insert(_el$68, () => `E ${preferences().enabled ? "desativar" : "ativar"} · M alternar usado/restante`);
|
|
1983
|
-
insertNode(_el$69, createTextNode(`↑/↓ rolar · R atualizar`));
|
|
1984
|
-
insertNode(_el$71, createTextNode(`Esc/Q fechar`));
|
|
1985
|
-
effect((_p$) => {
|
|
1986
|
-
var _v$0 = props.panel.focused, _v$1 = muted(props.context), _v$10 = tone(props.context, "info"), _v$11 = muted(props.context), _v$12 = muted(props.context), _v$13 = muted(props.context), _v$14 = muted(props.context);
|
|
1987
|
-
_v$0 !== _p$.e && (_p$.e = setProp(_el$64, "focused", _v$0, _p$.e));
|
|
1988
|
-
_v$1 !== _p$.t && (_p$.t = setProp(_el$64, "borderColor", _v$1, _p$.t));
|
|
1989
|
-
_v$10 !== _p$.a && (_p$.a = setProp(_el$64, "focusedBorderColor", _v$10, _p$.a));
|
|
1990
|
-
_v$11 !== _p$.o && (_p$.o = setProp(_el$67, "fg", _v$11, _p$.o));
|
|
1991
|
-
_v$12 !== _p$.i && (_p$.i = setProp(_el$68, "fg", _v$12, _p$.i));
|
|
1992
|
-
_v$13 !== _p$.n && (_p$.n = setProp(_el$69, "fg", _v$13, _p$.n));
|
|
1993
|
-
_v$14 !== _p$.s && (_p$.s = setProp(_el$71, "fg", _v$14, _p$.s));
|
|
1994
|
-
return _p$;
|
|
1995
|
-
}, {
|
|
1996
|
-
e: void 0,
|
|
1997
|
-
t: void 0,
|
|
1998
|
-
a: void 0,
|
|
1999
|
-
o: void 0,
|
|
2000
|
-
i: void 0,
|
|
2001
|
-
n: void 0,
|
|
2002
|
-
s: void 0
|
|
2003
|
-
});
|
|
2004
|
-
return _el$52;
|
|
2005
|
-
})();
|
|
2006
|
-
}
|
|
2007
|
-
function QuotaCommandLayer(props) {
|
|
2008
|
-
const goCheck = quotaGoCheckCommand(props.context);
|
|
2009
|
-
props.context.keymap.layer(() => ({
|
|
2010
|
-
mode: "global",
|
|
2011
|
-
commands: [quotaOpenCommand(props.context), goCheck]
|
|
2012
|
-
}));
|
|
2013
|
-
return null;
|
|
2014
|
-
}
|
|
2015
|
-
/** Register footer/panel controls and own teardown of the shared sidebar runtime. */
|
|
2016
|
-
function registerQuotaTui(context, runtime) {
|
|
2017
|
-
const unregister = [];
|
|
2018
|
-
try {
|
|
2019
|
-
unregister.push(context.ui.slot({
|
|
2020
|
-
append: "prompt.footer",
|
|
2021
|
-
render: () => createComponent(QuotaFooterSummary, {
|
|
2022
|
-
context,
|
|
2023
|
-
runtime
|
|
2024
|
-
})
|
|
2025
|
-
}));
|
|
2026
|
-
unregister.push(context.ui.slot({
|
|
2027
|
-
append: "session.panel",
|
|
2028
|
-
render: (panel) => panel.name === "pantheon.quota" ? createComponent(QuotaPanel, {
|
|
2029
|
-
context,
|
|
2030
|
-
runtime,
|
|
2031
|
-
panel
|
|
2032
|
-
}) : null
|
|
2033
|
-
}));
|
|
2034
|
-
unregister.push(context.ui.slot({
|
|
2035
|
-
append: "app",
|
|
2036
|
-
render: () => createComponent(QuotaCommandLayer, {
|
|
2037
|
-
context,
|
|
2038
|
-
runtime
|
|
2039
|
-
})
|
|
2040
|
-
}));
|
|
2041
|
-
} catch (error) {
|
|
2042
|
-
runtime.dispose();
|
|
2043
|
-
unregister.reverse().forEach((dispose) => {
|
|
2044
|
-
dispose();
|
|
2045
|
-
});
|
|
2046
|
-
throw error;
|
|
160
|
+
/** Cells one grapheme occupies. */
|
|
161
|
+
function graphemeWidth(segment) {
|
|
162
|
+
if (EMOJI_GLYPH.test(segment)) return 2;
|
|
163
|
+
if (segment.length > 1 && segment.includes(EMOJI_PRESENTATION_SELECTOR)) return 2;
|
|
164
|
+
let width = 0;
|
|
165
|
+
for (const glyph of segment) {
|
|
166
|
+
const code = glyph.codePointAt(0) ?? 0;
|
|
167
|
+
if (isZeroWidthCodePoint(code, glyph)) continue;
|
|
168
|
+
width += isWideCodePoint(code) ? 2 : 1;
|
|
2047
169
|
}
|
|
2048
|
-
return
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
170
|
+
return width;
|
|
171
|
+
}
|
|
172
|
+
/** Terminal cells `value` occupies — the unit every column in this plugin is
|
|
173
|
+
* measured in. Mirrors the host (that is how `@opentui/core` sizes a text
|
|
174
|
+
* run): emoji count as two cells, East Asian Wide/Fullwidth as two, East
|
|
175
|
+
* Asian Ambiguous as one, combining marks and variation selectors as none.
|
|
176
|
+
* Pure. */
|
|
177
|
+
function cellWidth(value) {
|
|
178
|
+
let width = 0;
|
|
179
|
+
for (const { segment } of GRAPHEMES.segment(value)) width += graphemeWidth(segment);
|
|
180
|
+
return width;
|
|
2054
181
|
}
|
|
2055
182
|
//#endregion
|
|
2056
183
|
//#region src/index-v2.tsx
|
|
@@ -2259,6 +386,130 @@ function resolveContextLimit(models, ref) {
|
|
|
2259
386
|
}
|
|
2260
387
|
return null;
|
|
2261
388
|
}
|
|
389
|
+
function asRecord(value) {
|
|
390
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
391
|
+
}
|
|
392
|
+
function modelID(ref) {
|
|
393
|
+
const record = asRecord(ref);
|
|
394
|
+
const id = typeof ref === "string" ? ref : record?.id ?? record?.modelID;
|
|
395
|
+
return typeof id === "string" && id.trim() !== "" ? id : null;
|
|
396
|
+
}
|
|
397
|
+
function messageModelRef(message) {
|
|
398
|
+
return message.model ?? message;
|
|
399
|
+
}
|
|
400
|
+
function modelProvider(ref, models) {
|
|
401
|
+
const direct = asRecord(ref)?.providerID;
|
|
402
|
+
if (typeof direct === "string" && direct.trim() !== "") return direct.trim();
|
|
403
|
+
const id = modelID(ref);
|
|
404
|
+
if (id === null) return null;
|
|
405
|
+
const segment = id.slice(id.lastIndexOf("/") + 1);
|
|
406
|
+
const providers = /* @__PURE__ */ new Set();
|
|
407
|
+
for (const candidate of models) {
|
|
408
|
+
const item = asRecord(candidate);
|
|
409
|
+
if (!item) continue;
|
|
410
|
+
if (item.id !== id && item.modelID !== id && item.id !== segment && item.modelID !== segment) continue;
|
|
411
|
+
if (typeof item.providerID === "string" && item.providerID.trim() !== "") providers.add(item.providerID.trim());
|
|
412
|
+
}
|
|
413
|
+
const explicitProvider = id.includes("/") ? id.slice(0, id.indexOf("/")) : null;
|
|
414
|
+
if (explicitProvider && providers.has(explicitProvider)) return explicitProvider;
|
|
415
|
+
return providers.size === 1 ? [...providers][0] ?? null : null;
|
|
416
|
+
}
|
|
417
|
+
function modelIdentity(ref, models) {
|
|
418
|
+
const id = modelID(ref);
|
|
419
|
+
if (id === null) return null;
|
|
420
|
+
const providerID = modelProvider(ref, models);
|
|
421
|
+
const segment = id.slice(id.lastIndexOf("/") + 1);
|
|
422
|
+
return {
|
|
423
|
+
key: `${providerID ?? ""}\u0000${id}`,
|
|
424
|
+
id,
|
|
425
|
+
providerID,
|
|
426
|
+
label: segment || id
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function tokenCount(message) {
|
|
430
|
+
const tokens = asRecord(message.tokens);
|
|
431
|
+
if (!tokens) return null;
|
|
432
|
+
const cache = asRecord(tokens.cache);
|
|
433
|
+
const reported = [
|
|
434
|
+
tokens.input,
|
|
435
|
+
tokens.output,
|
|
436
|
+
tokens.reasoning,
|
|
437
|
+
cache?.read,
|
|
438
|
+
cache?.write
|
|
439
|
+
].filter((value) => typeof value === "number" && Number.isFinite(value) && value >= 0);
|
|
440
|
+
return reported.length === 0 ? null : reported.reduce((sum, value) => sum + value, 0);
|
|
441
|
+
}
|
|
442
|
+
function contextLimit(ref, models) {
|
|
443
|
+
const id = modelID(ref);
|
|
444
|
+
if (id === null) return null;
|
|
445
|
+
const providerID = modelProvider(ref, models);
|
|
446
|
+
if (providerID === null) return null;
|
|
447
|
+
const segment = id.slice(id.lastIndexOf("/") + 1);
|
|
448
|
+
const matches = models.filter((value) => {
|
|
449
|
+
const model = asRecord(value);
|
|
450
|
+
if (!model) return false;
|
|
451
|
+
return (model.id === id || model.modelID === id || model.id === segment || model.modelID === segment) && model.providerID === providerID;
|
|
452
|
+
});
|
|
453
|
+
const limits = /* @__PURE__ */ new Set();
|
|
454
|
+
for (const candidate of matches) {
|
|
455
|
+
const limit = asRecord(asRecord(candidate)?.limit)?.context;
|
|
456
|
+
if (typeof limit === "number" && Number.isFinite(limit) && limit > 0) limits.add(limit);
|
|
457
|
+
}
|
|
458
|
+
return limits.size === 1 ? [...limits][0] ?? null : null;
|
|
459
|
+
}
|
|
460
|
+
function liveTranscriptWindow(messages, revertMessageID) {
|
|
461
|
+
let end = messages.length;
|
|
462
|
+
if (revertMessageID) {
|
|
463
|
+
const boundary = messages.findIndex((message) => asRecord(message)?.id === revertMessageID);
|
|
464
|
+
if (boundary >= 0) end = boundary;
|
|
465
|
+
}
|
|
466
|
+
let start = 0;
|
|
467
|
+
for (let index = end - 1; index >= 0; index -= 1) if (asRecord(messages[index])?.type === "compaction") {
|
|
468
|
+
start = index + 1;
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
start,
|
|
473
|
+
end
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
function latestContext(messages, modelRef, models, revertMessageID) {
|
|
477
|
+
const target = modelIdentity(modelRef, models);
|
|
478
|
+
if (target === null || target.providerID === null) return null;
|
|
479
|
+
const limit = contextLimit(modelRef, models);
|
|
480
|
+
if (limit === null || limit <= 0) return null;
|
|
481
|
+
const { start, end } = liveTranscriptWindow(messages, revertMessageID);
|
|
482
|
+
for (let index = end - 1; index >= start; index -= 1) {
|
|
483
|
+
const message = asRecord(messages[index]);
|
|
484
|
+
if (message?.type !== "assistant") continue;
|
|
485
|
+
const identity = modelIdentity(messageModelRef(message), models);
|
|
486
|
+
if (identity?.id !== target.id || identity.providerID !== target.providerID) continue;
|
|
487
|
+
const tokens = tokenCount(message);
|
|
488
|
+
if (tokens === null || tokens <= 0) continue;
|
|
489
|
+
return {
|
|
490
|
+
tokens,
|
|
491
|
+
percent: Math.round(tokens / limit * 100),
|
|
492
|
+
limit
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
497
|
+
/** Snapshot for one exact model identity in the bounded active transcript. */
|
|
498
|
+
function resolveModelContextSnapshot(messages, modelRef, models, revertMessageID) {
|
|
499
|
+
return latestContext(messages.slice(-400), modelRef, models, revertMessageID);
|
|
500
|
+
}
|
|
501
|
+
/** Select the pinned chat model before transcript or configured-agent fallbacks. */
|
|
502
|
+
function resolveActiveModelRef(sessionModel, activeMessages, fallbackModel = null) {
|
|
503
|
+
if (modelID(sessionModel) !== null) return sessionModel;
|
|
504
|
+
const firstMessage = Math.max(0, activeMessages.length - 400);
|
|
505
|
+
for (let index = activeMessages.length - 1; index >= firstMessage; index -= 1) {
|
|
506
|
+
const message = asRecord(activeMessages[index]);
|
|
507
|
+
if (message?.type !== "assistant") continue;
|
|
508
|
+
const ref = messageModelRef(message);
|
|
509
|
+
if (modelID(ref) !== null) return ref;
|
|
510
|
+
}
|
|
511
|
+
return modelID(fallbackModel) === null ? null : fallbackModel;
|
|
512
|
+
}
|
|
2262
513
|
/** Native token total: input + output + reasoning + cache read + cache write. */
|
|
2263
514
|
function messageTokensTotal(tokens) {
|
|
2264
515
|
const cacheRead = numberOrNull(tokens?.cache?.read) ?? 0;
|
|
@@ -2469,15 +720,15 @@ function collectModelUsage(messages) {
|
|
|
2469
720
|
const model = shortModelID(message.model, 12);
|
|
2470
721
|
if (id === null || model === null) continue;
|
|
2471
722
|
const key = `${typeof message.model?.providerID === "string" ? message.model.providerID : ""}\u0000${id}`;
|
|
2472
|
-
const
|
|
723
|
+
const tokensTotal = message.tokens ? messageTokensTotal(message.tokens) : 0;
|
|
2473
724
|
const cost = numberOrNull(message.cost) ?? 0;
|
|
2474
725
|
const current = totals.get(key);
|
|
2475
726
|
if (current) {
|
|
2476
|
-
current.tokens += Math.max(0,
|
|
727
|
+
current.tokens += Math.max(0, tokensTotal);
|
|
2477
728
|
current.cost += Math.max(0, cost);
|
|
2478
729
|
} else totals.set(key, {
|
|
2479
730
|
model,
|
|
2480
|
-
tokens: Math.max(0,
|
|
731
|
+
tokens: Math.max(0, tokensTotal),
|
|
2481
732
|
cost: Math.max(0, cost)
|
|
2482
733
|
});
|
|
2483
734
|
}
|
|
@@ -2528,9 +779,38 @@ function modelUsageRows(rows) {
|
|
|
2528
779
|
function modelUsageRowText(row) {
|
|
2529
780
|
return `${row.model.padEnd(12)} ${row.tokens.padStart(6)} ${row.cost.padStart(8)}`;
|
|
2530
781
|
}
|
|
782
|
+
/** Wrap on grapheme boundaries, measuring terminal cells rather than code units.
|
|
783
|
+
* (Body moved verbatim from the removed quota module's `quotaTextLines`.) */
|
|
784
|
+
function wrapTextLines(text, width, indent) {
|
|
785
|
+
const max = Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 0;
|
|
786
|
+
if (max < 1) return [];
|
|
787
|
+
const padding = " ".repeat(Math.min(Math.max(0, indent), Math.max(0, max - 2)));
|
|
788
|
+
const lines = [];
|
|
789
|
+
let line = padding;
|
|
790
|
+
const segmenter = new Intl.Segmenter();
|
|
791
|
+
for (const word of text.trim().split(/\s+/)) {
|
|
792
|
+
if (!word) continue;
|
|
793
|
+
if (line.trim() && cellWidth(line) + 1 + cellWidth(word) > max) {
|
|
794
|
+
lines.push(line.trimEnd());
|
|
795
|
+
line = padding;
|
|
796
|
+
}
|
|
797
|
+
if (line.trim()) line += " ";
|
|
798
|
+
for (const { segment } of segmenter.segment(word)) {
|
|
799
|
+
const glyphWidth = cellWidth(segment);
|
|
800
|
+
if (glyphWidth > max) continue;
|
|
801
|
+
if (cellWidth(line) + glyphWidth > max) {
|
|
802
|
+
if (line.trim()) lines.push(line.trimEnd());
|
|
803
|
+
line = glyphWidth + cellWidth(padding) <= max ? padding : "";
|
|
804
|
+
}
|
|
805
|
+
line += segment;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (line.trim()) lines.push(line.trimEnd());
|
|
809
|
+
return lines;
|
|
810
|
+
}
|
|
2531
811
|
/** Wrap sidebar text by terminal cells, preserving the complete values. */
|
|
2532
812
|
function sidebarTextLines(value) {
|
|
2533
|
-
return
|
|
813
|
+
return wrapTextLines(value, 34, 0);
|
|
2534
814
|
}
|
|
2535
815
|
/** Align a monetary value when it fits, otherwise preserve it on a new line. */
|
|
2536
816
|
function sidebarMoneyLines(label, value) {
|
|
@@ -4917,7 +3197,7 @@ function Sidebar(props) {
|
|
|
4917
3197
|
setProp(_el$12, "width", "100%");
|
|
4918
3198
|
setProp(_el$12, "padding", 1);
|
|
4919
3199
|
setProp(_el$13, "attributes", 1);
|
|
4920
|
-
insert(_el$13, `Pantheon v1.6.2-beta.
|
|
3200
|
+
insert(_el$13, `Pantheon v1.6.2-beta.11`);
|
|
4921
3201
|
insert(_el$14, () => presetHeaderLine(model.preset().name ?? "", model.provider()));
|
|
4922
3202
|
insert(_el$12, createComponent(Show, {
|
|
4923
3203
|
get when() {
|
|
@@ -5374,12 +3654,6 @@ function Sidebar(props) {
|
|
|
5374
3654
|
return _el$23;
|
|
5375
3655
|
}
|
|
5376
3656
|
}), null);
|
|
5377
|
-
insert(_el$12, createComponent(QuotaSidebarSummary, {
|
|
5378
|
-
context,
|
|
5379
|
-
get runtime() {
|
|
5380
|
-
return props.quotaRuntime;
|
|
5381
|
-
}
|
|
5382
|
-
}), null);
|
|
5383
3657
|
effect((_p$) => {
|
|
5384
3658
|
var _v$3 = text(), _v$4 = muted();
|
|
5385
3659
|
_v$3 !== _p$.e && (_p$.e = setProp(_el$13, "fg", _v$3, _p$.e));
|
|
@@ -5644,7 +3918,7 @@ function HomeStatus(props) {
|
|
|
5644
3918
|
const muted = () => props.context.theme?.text?.muted ?? props.context.theme?.text?.base;
|
|
5645
3919
|
return (() => {
|
|
5646
3920
|
var _el$72 = createElement("text");
|
|
5647
|
-
insert(_el$72, () => `Pantheon v1.6.2-beta.
|
|
3921
|
+
insert(_el$72, () => `Pantheon v1.6.2-beta.11${preset().name ? ` ▸ ${preset().name}` : ""}`);
|
|
5648
3922
|
effect((_$p) => setProp(_el$72, "fg", muted(), _$p));
|
|
5649
3923
|
return _el$72;
|
|
5650
3924
|
})();
|
|
@@ -5715,14 +3989,11 @@ const plugin = Plugin.define({
|
|
|
5715
3989
|
if (globalState[SINGLETON]) return;
|
|
5716
3990
|
globalState[SINGLETON] = true;
|
|
5717
3991
|
warmUpSidebarData(context, resolveLocation(context));
|
|
5718
|
-
const quotaRuntime = createQuotaRuntime(context);
|
|
5719
|
-
const unregisterQuotaTui = registerQuotaTui(context, quotaRuntime);
|
|
5720
3992
|
const unregisterSidebar = context.ui.slot({
|
|
5721
3993
|
append: "sidebar.content",
|
|
5722
3994
|
render: ({ sessionID }) => createComponent(Sidebar, {
|
|
5723
3995
|
context,
|
|
5724
|
-
sessionID
|
|
5725
|
-
quotaRuntime
|
|
3996
|
+
sessionID
|
|
5726
3997
|
})
|
|
5727
3998
|
});
|
|
5728
3999
|
const unregisterHome = context.ui.slot({
|
|
@@ -5760,12 +4031,11 @@ const plugin = Plugin.define({
|
|
|
5760
4031
|
if (typeof unregisterPromptFooter === "function") unregisterPromptFooter();
|
|
5761
4032
|
if (typeof unregisterPanel === "function") unregisterPanel();
|
|
5762
4033
|
if (typeof unregisterCommands === "function") unregisterCommands();
|
|
5763
|
-
unregisterQuotaTui();
|
|
5764
4034
|
delete globalState[SINGLETON];
|
|
5765
4035
|
};
|
|
5766
4036
|
}
|
|
5767
4037
|
});
|
|
5768
4038
|
//#endregion
|
|
5769
|
-
export { BLOCK_ICONS, CONTEXT_BAR_CELLS, CONTEXT_BAR_EMPTY_CELL, CONTEXT_BAR_FILLED_CELL,
|
|
4039
|
+
export { BLOCK_ICONS, CONTEXT_BAR_CELLS, CONTEXT_BAR_EMPTY_CELL, CONTEXT_BAR_FILLED_CELL, DELEGATION_CHILD_STATUS_GRACE_MS, DISPATCH_AGENT_CEILING, DISPATCH_AGENT_WIDTH, DISPATCH_COST_WIDTH, DISPATCH_COUNT_WIDTH, DISPATCH_DONE_MARKER, DISPATCH_DURATION_WIDTH, DISPATCH_GROUP_COST_WIDTH, DISPATCH_KIND_ORIGIN_LABELS, DISPATCH_MAX_LINES, DISPATCH_MAX_WIDTH, DISPATCH_MIN_AGENT_WIDTH, DISPATCH_MODEL_WIDTH, DISPATCH_PANEL_AGENT_WIDTH, DISPATCH_PANEL_COMMANDS, DISPATCH_PANEL_COST_WIDTH, DISPATCH_PANEL_DASH, DISPATCH_PANEL_DURATION_WIDTH, DISPATCH_PANEL_EMPTY_TEXT, DISPATCH_PANEL_FULLSCREEN_BADGE, DISPATCH_PANEL_HEADER_MARKER, DISPATCH_PANEL_KIND_WIDTH, DISPATCH_PANEL_MIN_AGENT_WIDTH, DISPATCH_PANEL_NAME, DISPATCH_PANEL_PAGE_SIZE, DISPATCH_PANEL_RULE_CHAR, DISPATCH_PANEL_SELECTION_GUTTER, DISPATCH_PANEL_SELECTION_MARKER, DISPATCH_PANEL_TITLE_WIDTH, DISPATCH_PANEL_TOAST, DISPATCH_PANEL_WIDE_MIN_WIDTH, DISPATCH_RUNNING_CEILING, GIT_ARROW_DOWN, GIT_ARROW_UP, GIT_CHANGES_DEBOUNCE_MS, GIT_CLI_DEBOUNCE_MS, GIT_CLI_MAX_BUFFER, GIT_CLI_MIN_INTERVAL_MS, GIT_CLI_TIMEOUT_MS, HEADER_MAX_WIDTH, MODEL_USAGE_COST_WIDTH, MODEL_USAGE_DEBOUNCE_MS, MODEL_USAGE_MESSAGE_LIMIT, MODEL_USAGE_MODEL_WIDTH, MODEL_USAGE_SESSION_LIMIT, MODEL_USAGE_TOKEN_WIDTH, MODEL_USAGE_VISIBLE_CEILING, PRESET_MARKER, SIDEBAR_REFRESH_EVENTS, SIDEBAR_WAITING_LABEL, SPEND_30D_LABEL, SPEND_30D_MS, SPEND_LINE_SEPARATOR, SPEND_PROBE_TOLERANCE_MS, SPEND_PROBE_WINDOW_MS, SPEND_REFRESH_DEBOUNCE_MS, SPEND_TODAY_LABEL, TODO_TEXT_WIDTH, TODO_VISIBLE_CEILING, UNKNOWN_AGENT, agentKey, buildDispatchBlock, cacheHitPercent, ceilingModelUsage, ceilingTodoItems, cellWidth, childAgentRowText, classifyDispatchKind, collectChildAgentUsage, collectDispatch, collectModelUsage, collectSubagentCalls, collectWarmupTargets, completedSummaryText, computeContextUsage, contextBar, contextBarFilled, contextBlockRows, contextPerformanceLine, contextProgressColor, contextSpendLine, contextSpendLines, contextUsageTone, countGitChanges, createDispatchPanelModel, createFooterModel, createSidebarModel, plugin as default, defaultGitExec, delegationStateFromOutcome, delegationStateFromStatus, detectDelegationCompletions, dispatchAgentText, dispatchElapsed, dispatchHeaderSummary, dispatchKindFromAgent, dispatchKindFromPrefix, dispatchKindSuffix, dispatchModelText, dispatchPanelCell, dispatchPanelDetail, dispatchPanelFooter, dispatchPanelHeader, dispatchPanelKeymapLayer, dispatchPanelLayout, dispatchPanelMarker, dispatchPanelRangeText, dispatchPanelRowText, dispatchPanelRows, dispatchPanelRule, dispatchPanelTitle, dispatchPanelWindow, dispatchTokenLine, dispatchTokens, dispatchTotalCost, failedSuffixText, formatContextWindow, formatDispatchCost, formatDispatchDuration, formatGitChanges, formatGitSnapshot, formatSpendUSD, formatSpent, formatTokenCount, formatUsageCost, formatUsageTokens, gitProbeAllowed, hiddenChildAgentsText, hiddenModelUsageText, hiddenTodoText, isTodoStatus, isValidSessionID, lastAssistantWithTokens, latestTodoItems, messageTokensTotal, modelRefID, modelUsageRowLines, modelUsageRowText, modelUsageRows, navigateToSession, openDispatchPanel, orderDispatchEntries, orderTodoItems, padCell, parseGitAheadBehind, parseGitStatusPorcelain, parsePresetOverrides, parseTodoItems, performDispatchPanelAction, presetFromEnv, presetHeaderLine, providerIDFromModels, providerIDFromRef, readGitSnapshot, resetSpendUnit, resolveActiveModelRef, resolveActivePresetForTui, resolveContextLimit, resolveModelContextSnapshot, resolvedSpendUnit, runDispatchPanelCommand, runningChildRowText, shortModelID, shortSessionID, sidebarMoneyLines, sidebarPlaceholder, sidebarTextLines, spendWindows, spinnerFrame, startOfLocalDay, statsCost, statsRangeMatches, toDelegationView, toDispatchEntry, todoRowText, todoTone, transcriptWindow, truncateLabel, turnTokensPerSecond, withBlockSpacers };
|
|
5770
4040
|
|
|
5771
4041
|
//# sourceMappingURL=tui-v2.js.map
|