opencode-quota-gui 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -12
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/card-order.d.ts +2 -0
- package/dist/contracts/card-order.js +2 -2
- package/dist/contracts/card-visibility.d.ts +2 -1
- package/dist/contracts/card-visibility.js +2 -1
- package/dist/contracts/dashboard.d.ts +87 -5
- package/dist/contracts/dashboard.js +10 -0
- package/dist/contracts/dto-guards.d.ts +4 -0
- package/dist/contracts/dto-guards.js +29 -7
- package/dist/contracts/guards.js +3 -1
- package/dist/contracts/identity.d.ts +37 -5
- package/dist/contracts/identity.js +43 -0
- package/dist/contracts/provider-auto-resume.d.ts +9 -0
- package/dist/contracts/provider-auto-resume.js +24 -0
- package/dist/contracts/provider-failure.d.ts +22 -0
- package/dist/contracts/provider-failure.js +25 -1
- package/dist/contracts/row-order.d.ts +13 -0
- package/dist/contracts/row-order.js +34 -0
- package/dist/contracts/row-visibility.d.ts +53 -0
- package/dist/contracts/row-visibility.js +130 -0
- package/dist/data/modelsdev-pricing.min.json +1 -1
- package/dist/data/modelsdev-temporal.min.json +3 -634
- package/dist/gui/aggregation.d.ts +29 -1
- package/dist/gui/aggregation.js +157 -4
- package/dist/gui/analytics-bridge.d.ts +8 -9
- package/dist/gui/analytics-bridge.js +197 -54
- package/dist/gui/analytics-engine.d.ts +7 -15
- package/dist/gui/analytics-engine.js +246 -106
- package/dist/gui/analytics-model.d.ts +7 -0
- package/dist/gui/analytics-model.js +75 -9
- package/dist/gui/analytics-pricing-upkeep.d.ts +21 -0
- package/dist/gui/analytics-pricing-upkeep.js +23 -0
- package/dist/gui/analytics-protocol.d.ts +17 -7
- package/dist/gui/analytics-protocol.js +1 -0
- package/dist/gui/analytics-service.d.ts +10 -0
- package/dist/gui/analytics-service.js +30 -9
- package/dist/gui/analytics-state.d.ts +30 -5
- package/dist/gui/analytics-state.js +46 -7
- package/dist/gui/analytics-worker-runtime.d.ts +5 -0
- package/dist/gui/analytics-worker-runtime.js +9 -1
- package/dist/gui/analytics-worker.js +11 -0
- package/dist/gui/config.d.ts +2 -2
- package/dist/gui/config.js +46 -5
- package/dist/gui/identity.d.ts +6 -20
- package/dist/gui/identity.js +6 -54
- package/dist/gui/primary-quota-windows.js +55 -34
- package/dist/gui/provider-cards.d.ts +12 -8
- package/dist/gui/provider-cards.js +12 -53
- package/dist/gui/quota-notification-detector.d.ts +25 -2
- package/dist/gui/quota-notification-detector.js +60 -5
- package/dist/gui/quota-notification-observer.d.ts +1 -1
- package/dist/gui/quota-notification-observer.js +5 -1
- package/dist/gui/quota-observation.d.ts +4 -0
- package/dist/gui/quota-observation.js +18 -0
- package/dist/gui/rpc.js +3 -0
- package/dist/gui/server.js +6 -1
- package/dist/gui/snapshot-service.d.ts +3 -17
- package/dist/gui/snapshot-service.js +159 -9
- package/dist/gui/sources.js +84 -11
- package/dist/gui/temporal-status.d.ts +3 -2
- package/dist/gui/temporal-status.js +10 -6
- package/dist/gui-experimental.cjs +228 -228
- package/dist/lib/accounting-format.d.ts +8 -0
- package/dist/lib/accounting-format.js +12 -2
- package/dist/lib/anthropic-api-auth.d.ts +7 -0
- package/dist/lib/anthropic-api-auth.js +27 -0
- package/dist/lib/anthropic-api-rate-limits.d.ts +47 -0
- package/dist/lib/anthropic-api-rate-limits.js +92 -0
- package/dist/lib/anthropic-oauth-throttle.d.ts +76 -0
- package/dist/lib/anthropic-oauth-throttle.js +379 -0
- package/dist/lib/anthropic.d.ts +22 -4
- package/dist/lib/anthropic.js +498 -180
- package/dist/lib/cache-observer-ingestion.js +27 -0
- package/dist/lib/cache-observer.d.ts +3 -0
- package/dist/lib/cache-observer.js +9 -3
- package/dist/lib/cli-show.d.ts +5 -0
- package/dist/lib/cli-show.js +16 -5
- package/dist/lib/cli-status.js +3 -6
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/config.js +64 -2
- package/dist/lib/dashboard-visibility.d.ts +5 -0
- package/dist/lib/dashboard-visibility.js +11 -10
- package/dist/lib/display-sanitize.js +1 -0
- package/dist/lib/entries.d.ts +10 -1
- package/dist/lib/entries.js +4 -0
- package/dist/lib/grouped-entry-normalization.js +1 -1
- package/dist/lib/maintainer-announcements.js +2 -2
- package/dist/lib/modelsdev-pricing.d.ts +74 -2
- package/dist/lib/modelsdev-pricing.js +457 -63
- package/dist/lib/modelsdev-temporal.d.ts +6 -0
- package/dist/lib/modelsdev-temporal.js +16 -2
- package/dist/lib/opencode-config-providers.js +2 -2
- package/dist/lib/opencode-storage.d.ts +20 -0
- package/dist/lib/opencode-storage.js +89 -2
- package/dist/lib/opencode-version-core.d.ts +7 -0
- package/dist/lib/opencode-version-core.js +10 -0
- package/dist/lib/opencode-warming-refresh.d.ts +19 -0
- package/dist/lib/opencode-warming-refresh.js +95 -0
- package/dist/lib/provider-metadata.d.ts +11 -3
- package/dist/lib/provider-metadata.js +20 -2
- package/dist/lib/provider-registration.d.ts +342 -3
- package/dist/lib/provider-registration.js +409 -27
- package/dist/lib/quota-auto-resume.d.ts +74 -0
- package/dist/lib/quota-auto-resume.js +539 -0
- package/dist/lib/quota-command-format.js +22 -9
- package/dist/lib/quota-identity.d.ts +64 -0
- package/dist/lib/quota-identity.js +111 -0
- package/dist/lib/quota-providers.js +2 -2
- package/dist/lib/quota-render-data.js +2 -2
- package/dist/lib/quota-reset-notifications.js +11 -155
- package/dist/lib/quota-retry-wait.d.ts +106 -5
- package/dist/lib/quota-retry-wait.js +301 -34
- package/dist/lib/quota-runtime-context.js +1 -0
- package/dist/lib/quota-state-codec.d.ts +2 -0
- package/dist/lib/quota-state-codec.js +14 -1
- package/dist/lib/quota-state.d.ts +1 -1
- package/dist/lib/quota-state.js +60 -28
- package/dist/lib/quota-stats.d.ts +26 -0
- package/dist/lib/quota-stats.js +19 -1
- package/dist/lib/quota-surface-data.js +18 -3
- package/dist/lib/quota-telemetry.js +2 -2
- package/dist/lib/resolved-auth-identity.d.ts +19 -0
- package/dist/lib/resolved-auth-identity.js +44 -0
- package/dist/lib/state-file-lock.d.ts +26 -0
- package/dist/lib/state-file-lock.js +205 -0
- package/dist/lib/toast-format-grouped.js +7 -4
- package/dist/lib/tui-compact-format.js +29 -16
- package/dist/lib/types.d.ts +20 -0
- package/dist/lib/types.js +4 -1
- package/dist/plugin.js +67 -1
- package/dist/providers/alibaba-coding-plan.js +21 -3
- package/dist/providers/alibaba-token-plan.js +9 -5
- package/dist/providers/anthropic.d.ts +6 -2
- package/dist/providers/anthropic.js +123 -14
- package/dist/providers/chutes.js +2 -0
- package/dist/providers/claude-agent.js +24 -5
- package/dist/providers/copilot.js +5 -4
- package/dist/providers/glm-coding-plan-provider.js +30 -23
- package/dist/providers/ollama-cloud.js +10 -0
- package/dist/providers/openai.js +24 -23
- package/dist/providers/opencode-go.js +7 -6
- package/dist/providers/opencode-zen.js +1 -1
- package/dist/providers/result-helpers.d.ts +4 -2
- package/dist/providers/result-helpers.js +5 -1
- package/dist/providers/synthetic.js +4 -0
- package/dist/providers/xai.js +9 -8
- package/dist/rpc.d.ts +8 -0
- package/dist/rpc.js +15 -2
- package/dist/ui/assets/{index-BcueIm3Z.css → index-6_g1FHs-.css} +1 -1
- package/dist/ui/assets/index-sZnGUuML.js +10 -0
- package/dist/ui/assets/{popover-4bFSvRZ7.js → popover-C4ZLYe9E.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +3 -3
- package/dist/ui/assets/index-C6qRSoh8.js +0 -10
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Quota, token usage, and analytics inside OpenCode Desktop. OpenCode Quota GUI ad
|
|
|
13
13
|
|
|
14
14
|
## Native OpenCode Desktop
|
|
15
15
|
|
|
16
|
-
The Native panel is the primary experience in **v1.3.
|
|
16
|
+
The Native panel is the primary experience in **v1.3.2**. Open **Quota & Usage** for Quota, Analytics, Models, and their detail pages; OpenCode Settings includes the plugin's **Quota & analytics** page. The session header shows a compact quota slot with a combined preview.
|
|
17
17
|
|
|
18
18
|
The full Native integration ships from **v1.3.0** and requires **OpenCode Desktop 2.2.1 or newer**.
|
|
19
19
|
|
|
@@ -24,9 +24,9 @@ The full Native integration ships from **v1.3.0** and requires **OpenCode Deskto
|
|
|
24
24
|
<table>
|
|
25
25
|
<tr>
|
|
26
26
|
<td width="50%" valign="top">
|
|
27
|
-
<img src="images/opencode-quota-gui_session.png" alt="Session analytics in the native panel
|
|
27
|
+
<img src="images/opencode-quota-gui_session.png" alt="Session analytics in the native panel showing scoped context, cumulative and cache-rate series with user-prompt markers, longest idle and high-reuse gaps, and a session tree listing each session's agent, model, cache rate and tokens" />
|
|
28
28
|
<br />
|
|
29
|
-
<sub><strong>Session analytics</strong>
|
|
29
|
+
<sub><strong>Session analytics</strong> - scoped context, cumulative and cache-rate series with prompt markers, and a session tree with model and cache columns.</sub>
|
|
30
30
|
</td>
|
|
31
31
|
<td width="50%" valign="top">
|
|
32
32
|
<img src="images/opencode-quota-gui_providers.png" alt="Models analytics grouped by provider with a stacked token chart, an API-equivalent cost line, and a cost and token breakdown by provider and model" />
|
|
@@ -46,11 +46,18 @@ The full Native integration ships from **v1.3.0** and requires **OpenCode Deskto
|
|
|
46
46
|
<sub><strong>Header Slot</strong> — at-a-glance quota rings with the combined preview open.</sub>
|
|
47
47
|
</td>
|
|
48
48
|
</tr>
|
|
49
|
+
<tr>
|
|
50
|
+
<td colspan="2" align="center" valign="top">
|
|
51
|
+
<img src="https://raw.githubusercontent.com/PVLPM/opencode-quota-gui/main/images/opencode-quota-gui_composer_pill.png" alt="OpenCode composer cache observation popover showing per-session cache reuse and estimated TTL" width="320" />
|
|
52
|
+
<br />
|
|
53
|
+
<sub><strong>Composer cache observation (v1.3.1)</strong> — measured cache-read share, estimated TTL, and recent session or agent observations. TTL is not a provider-confirmed expiry.</sub>
|
|
54
|
+
</td>
|
|
55
|
+
</tr>
|
|
49
56
|
</table>
|
|
50
57
|
|
|
51
58
|
## What you get
|
|
52
59
|
|
|
53
|
-
The Native panel is the primary surface in v1.3.
|
|
60
|
+
The Native panel is the primary surface in v1.3.2. Every feature below is available there, and the optional browser dashboard mirrors the same views as a fallback.
|
|
54
61
|
|
|
55
62
|
## Features
|
|
56
63
|
|
|
@@ -65,7 +72,7 @@ The Native panel is the primary surface in v1.3.1. Every feature below is availa
|
|
|
65
72
|
- **Session detail:** per-step context and cumulative own-session and whole-tree token charts, compaction markers, and a nested session tree with steps and totals.
|
|
66
73
|
- **API-equivalent estimates:** list-price estimates for recorded tokens, using the peak or off-peak rate that applied when each step completed, shown beside token totals in Analytics, Models, projects, providers, and models. They are estimates, not subscription spend.
|
|
67
74
|
- **Customization:** used or remaining percentages, label style, row detail, provider selection, refresh interval, request timeout, card order, per-card or per-row visibility, and which providers show peak and off-peak status. Custom quota providers and pricing fallbacks live in the canonical config.
|
|
68
|
-
- **Local-first operation:** no cloud account and no hosted sync; the plugin reads OpenCode data on this machine. The optional browser dashboard binds only to `127.0.0.1`. Reset-aware retry can hold a request until the provider's used-up quota window resets; turn it off with `waitForQuotaReset: false`.
|
|
75
|
+
- **Local-first operation:** no cloud account and no hosted sync; the plugin reads OpenCode data on this machine. The optional browser dashboard binds only to `127.0.0.1`. Reset-aware retry can hold a request until the provider's used-up quota window resets; turn it off with `waitForQuotaReset: false`. Opt-in auto-resume can instead send one `continue` after a quota-limited session's window resets.
|
|
69
76
|
|
|
70
77
|
## Quick start
|
|
71
78
|
|
|
@@ -101,7 +108,7 @@ The browser dashboard default follows the OpenCode host version. On supported ho
|
|
|
101
108
|
|
|
102
109
|
`true` forces web access on and `false` keeps it off. Then open <http://localhost:4144/quota>. The first page may show an empty dashboard until OpenCode has loaded the plugin and discovered a provider account. The path and platform overrides are in [Configuration](docs/readme/configuration.md#web-dashboard).
|
|
103
110
|
|
|
104
|
-
Requirements: OpenCode `>= 2.0.16 < 2.
|
|
111
|
+
Requirements: OpenCode `>= 2.0.16 < 2.5.0` and Node.js `22.13+` or `23.4+`. The full Native Desktop integration ships from v1.3.0 and requires OpenCode Desktop 2.2.1+. On supported older hosts, the browser dashboard is the automatic fallback. This package does not support OpenCode 1.
|
|
105
112
|
|
|
106
113
|
## Native panel
|
|
107
114
|
|
|
@@ -117,10 +124,6 @@ The panel follows you between sessions: switching sessions reuses the same share
|
|
|
117
124
|
|
|
118
125
|
The Native composer also shows **Cache observation**, for example `TTL ~4m 30s · Cache 99.70% · Hit`. Its percentage is the cache-read share of the last completed primary call with reliable usage data, not a session average, labelled by how much of the prompt was reused: `Low reuse` (above 0% up to 50%), `Partial reuse` (above 50% to under 90%) and `Hit` (90% or more). These are reuse-efficiency bands, not provider cache-hit semantics, so a small positive cache read is technically a cache hit but shows `Low reuse`. `Miss` is reserved for an independently confirmed zero. `Unknown` means the usage data was missing or invalid, or the share is zero: OpenCode reports a missing cache-read count as zero, so a plain zero is never shown as a confirmed `Miss`. The `~` marks the TTL countdown as an estimate; it is not an authoritative expiry, and no supported OpenCode host exposes one. For Claude Agent, a call whose cache writes are recorded as 1-hour-only with zero cache reads in its session record is estimated at 60 minutes instead of 5; an observed 1-hour write does not prove that earlier cached segments last an hour. See [Cache TTL evidence](docs/readme/cache-ttl-evidence.md) for what is and is not observable per route. Green means cache reuse is likely within an estimated retention window; yellow means the estimate is uncertain or in its final 20%; red means estimated expiry, observed invalidation, or a model change; gray means there is insufficient reliable information. An active session with confirmed prior cache reads may also show yellow when its retention is unknown, without a countdown. Colors estimate future reuse and do not guarantee the next hit or prove what a provider retained. Select a session row to open its Session Analytics in the panel without switching the active chat; its breadcrumbs link back to parent sessions.
|
|
119
126
|
|
|
120
|
-
<p align="center">
|
|
121
|
-
<img src="https://raw.githubusercontent.com/PVLPM/opencode-quota-gui/main/images/opencode-quota-gui_composer_pill.png" alt="Native composer Cache observation popover listing per-session TTL estimates and cache-read percentages above the TTL, Cache and Hit pill" width="320" />
|
|
122
|
-
</p>
|
|
123
|
-
|
|
124
127
|
For eligible quota windows, hover or focus the percentage or progress bar to see a linear runway estimate. It is available only when the provider data supports a reliable window projection; a reset timestamp alone is not enough. In particular, OpenCode Go's rolling five-hour window does not establish a fixed window start.
|
|
125
128
|
|
|
126
129
|
Native notifications cover low quota, exhausted quota, quota reset, and provider or API failures. The low-quota threshold and duplicate cooldown are configurable in Settings. A focused window shows an in-app toast; a background window asks OpenCode to notify you. The model-change toast has its own Settings toggle and does not control cache mismatch detection. Delivery is best effort, not exactly once.
|
|
@@ -165,7 +168,7 @@ Most providers work automatically once you log in through OpenCode. A **Needs se
|
|
|
165
168
|
|
|
166
169
|
| Provider | Auth/setup | Data from | Reports |
|
|
167
170
|
| ------------------ | -------------------------------------------------------------- | ------------------ | ------------------ |
|
|
168
|
-
| Anthropic | [
|
|
171
|
+
| Anthropic | [API key](docs/readme/providers.md#anthropic) | Observed headers | Rate limits |
|
|
169
172
|
| Claude Agent | [Needs setup](docs/readme/providers.md#claude-agent) | Local CLI/OAuth | Quota |
|
|
170
173
|
| Chutes AI | Automatic | Remote API | Quota |
|
|
171
174
|
| Cursor | [Needs setup](docs/readme/providers.md#cursor) | Local estimate | Budget and spend |
|
|
@@ -188,7 +191,7 @@ Most providers work automatically once you log in through OpenCode. A **Needs se
|
|
|
188
191
|
|
|
189
192
|
| Provider | Auth/setup | Data from | Reports |
|
|
190
193
|
| ----------------------- | -------------------------------------------------------------- | ------------------ | ------------------ |
|
|
191
|
-
| Anthropic | [
|
|
194
|
+
| Anthropic | [API key](docs/readme/providers.md#anthropic) | Observed headers | Rate limits |
|
|
192
195
|
| Claude Agent | [Needs setup](docs/readme/providers.md#claude-agent) | Local CLI/OAuth | Quota |
|
|
193
196
|
| Chutes AI | Automatic | Remote API | Quota |
|
|
194
197
|
| Cursor | [Needs setup](docs/readme/providers.md#cursor) | Local estimate | Budget and spend |
|
|
@@ -256,6 +259,7 @@ The plugin reads only the canonical file at runtime:
|
|
|
256
259
|
`$XDG_CONFIG_HOME/opencode` replaces `~/.config/opencode` when `XDG_CONFIG_HOME` is set, and `OPENCODE_CONFIG_DIR` replaces the global OpenCode config folder. The sibling `config.json` is not read, converted, or imported; it is preserved unchanged. Changes made in `Settings` write to this canonical file. Settings values, source labels, the port, and visibility lists come only from the canonical file and defaults, regardless of whether OpenCode uses `opencode.json` or `opencode.jsonc`. Selecting a project install in `init` adds only the project OpenCode plugin entry; behavior settings remain global. Inherited legacy values are available only through the separate import preview.
|
|
257
260
|
|
|
258
261
|
- **Legacy import:** when a global legacy OpenCode Quota source exists, Settings can preview and copy seven compatible keys: `percentDisplayMode`, `percentLabelStyle`, `enabledProviders`, `minIntervalMs`, `requestTimeoutMs`, `accountingDetail`, and `waitForQuotaReset`. The import is read-only for the source; files stay byte-for-byte untouched. Custom provider definitions are not imported, so copy `quotaProviders` into the canonical file yourself.
|
|
262
|
+
- **Auto-resume on quota recovery:** off by default (`autoResumeOnQuotaRecovery`). When on, a session that terminally fails on a provider quota limit gets one `continue` prompt after the failed route's exhausted primary window is observed as reset, following two minutes of inactivity (temporary check failures keep it pending; they never authorize it), and only if the session is still failed, idle and on the same model. It appears as a user message, never replays tool actions, and is dropped if OpenCode or the plugin restarts. One resume is consumed per user-initiated execution; a quota failure after that `continue` waits for a fresh user prompt. Evidence must be bound to one verified identity: an active OpenCode account row, or, for a route whose adapter exposes no account rows, the provider cache identity. Supported: Claude Agent, Copilot, OpenAI, Synthetic, Chutes, Z.ai, Zhipu, NanoGPT, MiniMax Token Plan, MiniMax Token Plan (CN), xAI, OpenCode Go, OpenCode Zen, Ollama Cloud. A route whose provider registration has no auto-resume contract is rejected before the live quota probe and is not polled. Claude Agent's known untyped five-hour and weekly subscription-limit messages are recognized, but only the independent observation of the applicable window exhausted for the same Claude identity can authorize the continuation; native retry is unchanged. The full eligibility matrix and exclusions are in [configuration](docs/readme/configuration.md#auto-resume-on-quota-recovery).
|
|
259
263
|
- **Visibility:** hiding a provider or row is presentation only and never changes polling or provider data. Opaque card and row IDs in `dashboard.hiddenCards` and `dashboard.hiddenRows` are internal identifiers: use **Settings → Visibility** to manage them instead of editing or deriving IDs by hand.
|
|
260
264
|
- **Temporal pricing:** `dashboard.temporalProviderOverrides` stores sparse per-provider on/off choices for the live peak and off-peak status in the Quota header. A provider with a discovered account is shown by default; an explicit choice wins. Hiding a status is presentation only and never changes polling, quota values, or recorded usage.
|
|
261
265
|
- **Web dashboard (optional fallback):** on by default below OpenCode 2.2.1 (including 2.2.0) and off by default at 2.2.1 and newer. An explicit `"dashboard": { "enabled": true }` or `"dashboard": { "enabled": false }` in the canonical file always wins. When enabled, the browser UI is served on `127.0.0.1` at `dashboard.port` (default `4144`), and the server never falls back to another port. Missing/unparseable host versions and malformed or invalid canonical settings fail closed when the switch is absent. Changes apply after an OpenCode restart.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUILD_IDENTITY = Object.freeze({"version":"1.3.
|
|
1
|
+
export const BUILD_IDENTITY = Object.freeze({"version":"1.3.2","build":"c6a0d0f63ee7"});
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* The caller assembles the real cards first, then asks for a display order, so
|
|
8
8
|
* same-provider siblings are ordered independently.
|
|
9
9
|
*/
|
|
10
|
+
export declare function rankByIds(preference: readonly string[] | undefined, knownIds: ReadonlySet<string>): Map<string, number>;
|
|
11
|
+
export declare function stableSortByRank<T>(cards: readonly T[], rankOf: (card: T) => number): T[];
|
|
10
12
|
/**
|
|
11
13
|
* Returns a fresh card array ordered for presentation.
|
|
12
14
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* same-provider siblings are ordered independently.
|
|
9
9
|
*/
|
|
10
10
|
const UNKNOWN_RANK = Number.POSITIVE_INFINITY;
|
|
11
|
-
function rankByIds(preference, knownIds) {
|
|
11
|
+
export function rankByIds(preference, knownIds) {
|
|
12
12
|
const ranks = new Map();
|
|
13
13
|
if (preference === undefined)
|
|
14
14
|
return ranks;
|
|
@@ -19,7 +19,7 @@ function rankByIds(preference, knownIds) {
|
|
|
19
19
|
}
|
|
20
20
|
return ranks;
|
|
21
21
|
}
|
|
22
|
-
function stableSortByRank(cards, rankOf) {
|
|
22
|
+
export function stableSortByRank(cards, rankOf) {
|
|
23
23
|
return cards
|
|
24
24
|
.map((card, index) => ({ card, index, rank: rankOf(card) }))
|
|
25
25
|
.sort((left, right) => left.rank === right.rank ? left.index - right.index : left.rank - right.rank)
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* exact `cardId`, its `providerId`, or its authoritative bare provider-scope
|
|
7
7
|
* hash. Effective server settings normalize legacy full scope ids to
|
|
8
8
|
* `providerId`; every full card id is now an exact hide. Row hiding is a
|
|
9
|
-
* separate
|
|
9
|
+
* separate check in `row-visibility.ts`, which resolves pre-window aggregate
|
|
10
|
+
* row ids against the card's first emitted typed row.
|
|
10
11
|
*/
|
|
11
12
|
export interface ProviderVisibilityIdentity {
|
|
12
13
|
providerId: string;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* exact `cardId`, its `providerId`, or its authoritative bare provider-scope
|
|
7
7
|
* hash. Effective server settings normalize legacy full scope ids to
|
|
8
8
|
* `providerId`; every full card id is now an exact hide. Row hiding is a
|
|
9
|
-
* separate
|
|
9
|
+
* separate check in `row-visibility.ts`, which resolves pre-window aggregate
|
|
10
|
+
* row ids against the card's first emitted typed row.
|
|
10
11
|
*/
|
|
11
12
|
/** Consume normalized settings; never guess old semantics from the current catalog. */
|
|
12
13
|
export function isLegacyProviderHidden(card, hidden) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnalyticsTemporalBreakdown } from "./analytics-temporal.js";
|
|
2
2
|
import type { CardId, RowId } from "./identity.js";
|
|
3
3
|
import type { BankedResetAvailability } from "./openai-quota.js";
|
|
4
|
-
import type { ProviderFailureCategory } from "./provider-failure.js";
|
|
4
|
+
import type { ProviderFailureCategory, QuotaAttemptOutcome } from "./provider-failure.js";
|
|
5
5
|
import type { BucketUnit, RangeKey, RangeWindow } from "./ranges.js";
|
|
6
6
|
import type { TemporalStatusSnapshot } from "./temporal.js";
|
|
7
7
|
/**
|
|
@@ -70,6 +70,16 @@ export interface CostedTokens extends TokenStack {
|
|
|
70
70
|
apiEquivalentCostUsd: number | null;
|
|
71
71
|
unpricedTokens: number;
|
|
72
72
|
unknownTokens: number;
|
|
73
|
+
/**
|
|
74
|
+
* Portion of `apiEquivalentCostUsd` that came from OpenCode's recorded
|
|
75
|
+
* per-message cost because models.dev could not price the route.
|
|
76
|
+
*/
|
|
77
|
+
recordedCostUsd?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Tokens priced by that recorded-cost fallback. They are already included in
|
|
80
|
+
* the priced total and are never counted as unpriced/unknown tokens.
|
|
81
|
+
*/
|
|
82
|
+
recordedCostTokens?: number;
|
|
73
83
|
}
|
|
74
84
|
export interface Bucket {
|
|
75
85
|
startMs: number;
|
|
@@ -314,6 +324,11 @@ export interface ProviderCard {
|
|
|
314
324
|
message: string;
|
|
315
325
|
retryable?: boolean;
|
|
316
326
|
retryAtMs?: number;
|
|
327
|
+
/**
|
|
328
|
+
* Outcome of the attempt behind this error. A `cooldown` skip made no
|
|
329
|
+
* request, so it is displayed as a muted retry notice, never a failure.
|
|
330
|
+
*/
|
|
331
|
+
attemptOutcome?: QuotaAttemptOutcome;
|
|
317
332
|
kind?: "intentional-filter";
|
|
318
333
|
/** Source-assigned safe category; absence means unknown and consumers fail closed. */
|
|
319
334
|
failureCategory?: ProviderFailureCategory;
|
|
@@ -327,11 +342,14 @@ export interface ProviderCard {
|
|
|
327
342
|
/**
|
|
328
343
|
* Persistent optional-row choices (additive): stable ids and labels exist
|
|
329
344
|
* even when runtime values are absent. Never synthetic zero data rows.
|
|
345
|
+
* `rowId` is the stable declared field id; `aliases` lists the emitted row
|
|
346
|
+
* ids that render the same field in another shape.
|
|
330
347
|
*/
|
|
331
348
|
visibilityRows?: {
|
|
332
349
|
rowId: RowId;
|
|
333
350
|
label: string;
|
|
334
351
|
info?: string;
|
|
352
|
+
aliases?: RowId[];
|
|
335
353
|
}[];
|
|
336
354
|
}
|
|
337
355
|
export interface ProjectActivityRow {
|
|
@@ -345,6 +363,13 @@ export interface HomeSnapshot {
|
|
|
345
363
|
generatedAtMs: number;
|
|
346
364
|
range: RangeKey;
|
|
347
365
|
stale: boolean;
|
|
366
|
+
provisional?: true;
|
|
367
|
+
/**
|
|
368
|
+
* Additive: the exact replacement behind a provisional paint failed. The
|
|
369
|
+
* provisional data stays visible; the UI clears its pending ring and offers
|
|
370
|
+
* a retry. Absent while the exact read is pending or after it succeeds.
|
|
371
|
+
*/
|
|
372
|
+
exactError?: string;
|
|
348
373
|
/** `polledAtMs` is a poll time, not a guarantee that every provider succeeded. */
|
|
349
374
|
providers: {
|
|
350
375
|
cards: ProviderCard[];
|
|
@@ -354,6 +379,14 @@ export interface HomeSnapshot {
|
|
|
354
379
|
usage: Usage;
|
|
355
380
|
projects: ProjectActivityRow[];
|
|
356
381
|
}
|
|
382
|
+
/** Positional analytics reads shared by the engine and worker transport. */
|
|
383
|
+
export interface AnalyticsRangeReader {
|
|
384
|
+
home(range: RangeKey, exact?: boolean, background?: boolean): Promise<HomeSnapshot>;
|
|
385
|
+
project(projectId: string, range: RangeKey): Promise<ProjectSnapshot>;
|
|
386
|
+
session(sessionId: string): Promise<SessionSnapshot>;
|
|
387
|
+
groups(query: AnalyticsGroupQuery): Promise<AnalyticsGroupSnapshot>;
|
|
388
|
+
refresh(): Promise<void>;
|
|
389
|
+
}
|
|
357
390
|
/**
|
|
358
391
|
* Independent quota/provider read (transport contract). Analytics never waits
|
|
359
392
|
* on this; a quota viewer never starts the analytics worker.
|
|
@@ -404,20 +437,50 @@ export interface SessionNode {
|
|
|
404
437
|
stepCount: number;
|
|
405
438
|
subtreeNodeCount: number;
|
|
406
439
|
latestActivityAtMs: number;
|
|
440
|
+
/**
|
|
441
|
+
* Distinct provider/model/effort identities this session itself used,
|
|
442
|
+
* deduplicated by the complete identity and ordered by most recent actual
|
|
443
|
+
* use. `models[0]` is the last used identity; empty when none was recorded.
|
|
444
|
+
*/
|
|
445
|
+
models: ModelIdentity[];
|
|
446
|
+
/**
|
|
447
|
+
* Own steps whose stored message lacked a cache-read or cache-write counter.
|
|
448
|
+
* Their 0 is unknown, so the session's cache rate is unknown when this is
|
|
449
|
+
* positive. Omitted when every own step recorded both counters.
|
|
450
|
+
*/
|
|
451
|
+
cacheUnknownSteps?: number;
|
|
452
|
+
}
|
|
453
|
+
/** Provider/model plus the reasoning effort only when OpenCode recorded one. */
|
|
454
|
+
export interface ModelIdentity {
|
|
455
|
+
providerId: string;
|
|
456
|
+
modelId: string;
|
|
457
|
+
effort?: string;
|
|
407
458
|
}
|
|
408
459
|
export interface StepPoint {
|
|
409
460
|
sessionId: string;
|
|
410
461
|
messageId: string;
|
|
462
|
+
/** Completion time of the assistant message (the step's chart position). */
|
|
411
463
|
atMs: number;
|
|
464
|
+
/**
|
|
465
|
+
* OpenCode's stored assistant-message creation time. Not a request-start
|
|
466
|
+
* timestamp; absent when it was not recorded as a positive number.
|
|
467
|
+
*/
|
|
468
|
+
createdAtMs?: number;
|
|
412
469
|
branch: number;
|
|
413
470
|
stack: TokenStack;
|
|
414
471
|
contextTokens: number;
|
|
415
472
|
totalTokens: number;
|
|
416
|
-
model?:
|
|
417
|
-
providerId: string;
|
|
418
|
-
modelId: string;
|
|
419
|
-
};
|
|
473
|
+
model?: ModelIdentity;
|
|
420
474
|
agent?: string;
|
|
475
|
+
/** The message stored no cache-read counter: `stack.cacheRead` 0 is unknown, not observed. */
|
|
476
|
+
cacheReadUnknown?: true;
|
|
477
|
+
/** Same for the cache-write counter. */
|
|
478
|
+
cacheWriteUnknown?: true;
|
|
479
|
+
/**
|
|
480
|
+
* The first assistant step after a user-role message in this step's own
|
|
481
|
+
* session. Position only: the DTO never carries prompt text.
|
|
482
|
+
*/
|
|
483
|
+
inputMarker?: true;
|
|
421
484
|
}
|
|
422
485
|
export interface SessionSnapshot {
|
|
423
486
|
focusSessionId: string;
|
|
@@ -438,6 +501,13 @@ export interface SessionSnapshot {
|
|
|
438
501
|
atMs: number;
|
|
439
502
|
messageId: string;
|
|
440
503
|
}[];
|
|
504
|
+
/**
|
|
505
|
+
* Positions (creation time, else completion time) of the focus session's own
|
|
506
|
+
* completed assistant messages that are NOT in `steps` (zero-token rows,
|
|
507
|
+
* fork copies owned elsewhere). A gap spanning one is never bridged.
|
|
508
|
+
* Omitted when there are none.
|
|
509
|
+
*/
|
|
510
|
+
unobservedAtMs?: number[];
|
|
441
511
|
ownSummary: CostedTokens & {
|
|
442
512
|
stepCount: number;
|
|
443
513
|
};
|
|
@@ -515,6 +585,8 @@ export interface DashboardDataSource {
|
|
|
515
585
|
health(): Promise<DashboardHealth>;
|
|
516
586
|
home(input: {
|
|
517
587
|
range: RangeKey;
|
|
588
|
+
exact?: boolean;
|
|
589
|
+
background?: boolean;
|
|
518
590
|
}): Promise<HomeSnapshot>;
|
|
519
591
|
quota(input?: {
|
|
520
592
|
refresh?: boolean;
|
|
@@ -551,4 +623,14 @@ export interface DashboardDataSource {
|
|
|
551
623
|
}
|
|
552
624
|
/** Read/write config seam for the GUI server (P2 store satisfies this Pick). */
|
|
553
625
|
export type GuiSettingsStore = Pick<DashboardDataSource, "settings" | "saveSettings" | "saveVisibility" | "importPreview" | "importApply" | "openSettingsFile">;
|
|
626
|
+
/**
|
|
627
|
+
* Cold 7d/30d/lifetime analytics catch-up reads the full source store and can
|
|
628
|
+
* legitimately take tens of seconds on a slow local disk; a foreground request
|
|
629
|
+
* queued behind one can add its own scoped read. The old 90 s budget retired
|
|
630
|
+
* healthy workers mid-read on measured sources. Keep a finite budget above the
|
|
631
|
+
* measured worst request (112.9 s on the reported source), so genuinely stuck
|
|
632
|
+
* workers are still retired and recovered on the next request. The Analytics
|
|
633
|
+
* view also stops re-joining a host-timed-out read after this long.
|
|
634
|
+
*/
|
|
635
|
+
export declare const ANALYTICS_DEFAULT_REQUEST_TIMEOUT_MS = 180000;
|
|
554
636
|
//# sourceMappingURL=dashboard.d.ts.map
|
|
@@ -2,4 +2,14 @@
|
|
|
2
2
|
export const DASHBOARD_CONTRACT_VERSION = 2;
|
|
3
3
|
/** Approved maximum number of primary quota-window references per card. */
|
|
4
4
|
export const PRIMARY_QUOTA_WINDOW_LIMIT = 3;
|
|
5
|
+
/**
|
|
6
|
+
* Cold 7d/30d/lifetime analytics catch-up reads the full source store and can
|
|
7
|
+
* legitimately take tens of seconds on a slow local disk; a foreground request
|
|
8
|
+
* queued behind one can add its own scoped read. The old 90 s budget retired
|
|
9
|
+
* healthy workers mid-read on measured sources. Keep a finite budget above the
|
|
10
|
+
* measured worst request (112.9 s on the reported source), so genuinely stuck
|
|
11
|
+
* workers are still retired and recovered on the next request. The Analytics
|
|
12
|
+
* view also stops re-joining a host-timed-out read after this long.
|
|
13
|
+
*/
|
|
14
|
+
export const ANALYTICS_DEFAULT_REQUEST_TIMEOUT_MS = 180_000;
|
|
5
15
|
//# sourceMappingURL=dashboard.js.map
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
* reused rather than re-implemented.
|
|
10
10
|
*/
|
|
11
11
|
import type { AnalyticsGroupQuery, AnalyticsGroupSnapshot, DashboardHealth, HomeSnapshot, ImportPreview, JsonValue, ProjectSnapshot, QuotaSnapshot, SessionSnapshot, SettingsSnapshot, SettingsWriteResult } from "./dashboard.js";
|
|
12
|
+
type RecordValue = Record<string, unknown>;
|
|
13
|
+
export declare function isRecord(value: unknown): value is RecordValue;
|
|
14
|
+
export declare function isText(value: unknown): value is string;
|
|
12
15
|
export declare function isJsonValue(value: unknown, depth?: number): value is JsonValue;
|
|
13
16
|
export declare function isDashboardHealth(value: unknown): value is DashboardHealth;
|
|
14
17
|
export declare function isQuotaSnapshot(value: unknown): value is QuotaSnapshot;
|
|
@@ -21,4 +24,5 @@ export declare function isSessionSnapshot(value: unknown): value is SessionSnaps
|
|
|
21
24
|
export declare function isSettingsSnapshot(value: unknown): value is SettingsSnapshot;
|
|
22
25
|
export declare function isSettingsWriteResult(value: unknown): value is SettingsWriteResult;
|
|
23
26
|
export declare function isImportPreview(value: unknown): value is ImportPreview;
|
|
27
|
+
export {};
|
|
24
28
|
//# sourceMappingURL=dto-guards.d.ts.map
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { PRIMARY_QUOTA_WINDOW_LIMIT } from "./dashboard.js";
|
|
12
12
|
import { isCostedTokens, isTokenStack } from "./guards.js";
|
|
13
|
-
import { isProviderFailureCategory } from "./provider-failure.js";
|
|
13
|
+
import { isProviderFailureCategory, isQuotaAttemptOutcome, } from "./provider-failure.js";
|
|
14
14
|
import { isRangeKey } from "./ranges.js";
|
|
15
15
|
const RESULT_TYPES = [
|
|
16
16
|
"quota",
|
|
@@ -31,10 +31,10 @@ const TEMPORAL_EFFECT_DIRECTIONS = ["peak", "offpeak", "unchanged"];
|
|
|
31
31
|
const TEMPORAL_EFFECT_UNITS = ["api_price", "quota_points"];
|
|
32
32
|
const TEMPORAL_HOLIDAYS = ["CN", "US", "CA"];
|
|
33
33
|
const TEMPORAL_WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
34
|
-
function isRecord(value) {
|
|
34
|
+
export function isRecord(value) {
|
|
35
35
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36
36
|
}
|
|
37
|
-
function isText(value) {
|
|
37
|
+
export function isText(value) {
|
|
38
38
|
return typeof value === "string";
|
|
39
39
|
}
|
|
40
40
|
function isBoolean(value) {
|
|
@@ -201,6 +201,8 @@ function isProviderCard(value) {
|
|
|
201
201
|
return false;
|
|
202
202
|
if (!isOptional(value.accountLabel, isText))
|
|
203
203
|
return false;
|
|
204
|
+
if (!isOptional(value.stale, (stale) => stale === true))
|
|
205
|
+
return false;
|
|
204
206
|
if (!isOptional(value.providerScopeId, isText))
|
|
205
207
|
return false;
|
|
206
208
|
if (!isOptional(value.providerScopeHash, isText))
|
|
@@ -212,6 +214,7 @@ function isProviderCard(value) {
|
|
|
212
214
|
isText(entry.message) &&
|
|
213
215
|
isOptional(entry.retryable, isBoolean) &&
|
|
214
216
|
isOptional(entry.retryAtMs, isFiniteNumber) &&
|
|
217
|
+
isOptional(entry.attemptOutcome, isQuotaAttemptOutcome) &&
|
|
215
218
|
isOptional(entry.kind, (kind) => kind === "intentional-filter") &&
|
|
216
219
|
isOptional(entry.failureCategory, isProviderFailureCategory)))) {
|
|
217
220
|
return false;
|
|
@@ -219,7 +222,11 @@ function isProviderCard(value) {
|
|
|
219
222
|
if (!isOptional(value.details, (details) => isArrayOf(details, (entry) => isRecord(entry) && isText(entry.label) && isText(entry.value)))) {
|
|
220
223
|
return false;
|
|
221
224
|
}
|
|
222
|
-
if (!isOptional(value.visibilityRows, (rows) => isArrayOf(rows, (row) => isRecord(row) &&
|
|
225
|
+
if (!isOptional(value.visibilityRows, (rows) => isArrayOf(rows, (row) => isRecord(row) &&
|
|
226
|
+
isText(row.rowId) &&
|
|
227
|
+
isText(row.label) &&
|
|
228
|
+
isOptional(row.info, isText) &&
|
|
229
|
+
isOptional(row.aliases, (aliases) => isArrayOf(aliases, isText))))) {
|
|
223
230
|
return false;
|
|
224
231
|
}
|
|
225
232
|
const rowsById = new Map(value.rows.map((row) => [row.rowId, row]));
|
|
@@ -390,6 +397,8 @@ export function isHomeSnapshot(value) {
|
|
|
390
397
|
isFiniteNumber(value.generatedAtMs) &&
|
|
391
398
|
isRangeKey(value.range) &&
|
|
392
399
|
isBoolean(value.stale) &&
|
|
400
|
+
isOptional(value.provisional, (provisional) => provisional === true) &&
|
|
401
|
+
isOptional(value.exactError, isText) &&
|
|
393
402
|
isProviders(value.providers) &&
|
|
394
403
|
isUsage(value.usage) &&
|
|
395
404
|
isArrayOf(value.projects, isProjectActivityRow));
|
|
@@ -491,6 +500,12 @@ export function isProjectSnapshot(value) {
|
|
|
491
500
|
function isSessionBreadcrumb(value) {
|
|
492
501
|
return (isRecord(value) && isText(value.sessionId) && isText(value.title) && isBoolean(value.isFocus));
|
|
493
502
|
}
|
|
503
|
+
function isModelIdentity(value) {
|
|
504
|
+
return (isRecord(value) &&
|
|
505
|
+
isText(value.providerId) &&
|
|
506
|
+
isText(value.modelId) &&
|
|
507
|
+
isOptional(value.effort, isText));
|
|
508
|
+
}
|
|
494
509
|
function isSessionNode(value) {
|
|
495
510
|
return (isRecord(value) &&
|
|
496
511
|
isText(value.sessionId) &&
|
|
@@ -504,19 +519,25 @@ function isSessionNode(value) {
|
|
|
504
519
|
isCostedTokens(value.subtreeTokens) &&
|
|
505
520
|
isFiniteNumber(value.stepCount) &&
|
|
506
521
|
isFiniteNumber(value.subtreeNodeCount) &&
|
|
507
|
-
isFiniteNumber(value.latestActivityAtMs)
|
|
522
|
+
isFiniteNumber(value.latestActivityAtMs) &&
|
|
523
|
+
isArrayOf(value.models, isModelIdentity) &&
|
|
524
|
+
isOptional(value.cacheUnknownSteps, isFiniteNumber));
|
|
508
525
|
}
|
|
509
526
|
function isStepPoint(value) {
|
|
510
527
|
return (isRecord(value) &&
|
|
511
528
|
isText(value.sessionId) &&
|
|
512
529
|
isText(value.messageId) &&
|
|
513
530
|
isFiniteNumber(value.atMs) &&
|
|
531
|
+
isOptional(value.createdAtMs, isFiniteNumber) &&
|
|
514
532
|
isFiniteNumber(value.branch) &&
|
|
515
533
|
isTokenStack(value.stack) &&
|
|
516
534
|
isFiniteNumber(value.contextTokens) &&
|
|
517
535
|
isFiniteNumber(value.totalTokens) &&
|
|
518
|
-
isOptional(value.model,
|
|
519
|
-
isOptional(value.agent, isText)
|
|
536
|
+
isOptional(value.model, isModelIdentity) &&
|
|
537
|
+
isOptional(value.agent, isText) &&
|
|
538
|
+
isOptional(value.cacheReadUnknown, (flag) => flag === true) &&
|
|
539
|
+
isOptional(value.cacheWriteUnknown, (flag) => flag === true) &&
|
|
540
|
+
isOptional(value.inputMarker, (flag) => flag === true));
|
|
520
541
|
}
|
|
521
542
|
function isCompactionMarker(value) {
|
|
522
543
|
return (isRecord(value) &&
|
|
@@ -535,6 +556,7 @@ export function isSessionSnapshot(value) {
|
|
|
535
556
|
isArrayOf(value.nodes, isSessionNode) &&
|
|
536
557
|
isArrayOf(value.steps, isStepPoint) &&
|
|
537
558
|
isArrayOf(value.compactionMarkers, isCompactionMarker) &&
|
|
559
|
+
isOptional(value.unobservedAtMs, (list) => isArrayOf(list, isFiniteNumber)) &&
|
|
538
560
|
isCostedTokens(value.ownSummary) &&
|
|
539
561
|
isFiniteNumber(value.ownSummary.stepCount) &&
|
|
540
562
|
isCostedTokens(value.treeTotals) &&
|
package/dist/contracts/guards.js
CHANGED
|
@@ -41,7 +41,9 @@ export function isCostedTokens(value) {
|
|
|
41
41
|
(value.apiEquivalentCostUsd === null ||
|
|
42
42
|
isNonNegativeFiniteNumber(value.apiEquivalentCostUsd)) &&
|
|
43
43
|
isNonNegativeFiniteNumber(value.unpricedTokens) &&
|
|
44
|
-
isNonNegativeFiniteNumber(value.unknownTokens)
|
|
44
|
+
isNonNegativeFiniteNumber(value.unknownTokens) &&
|
|
45
|
+
(value.recordedCostUsd === undefined || isNonNegativeFiniteNumber(value.recordedCostUsd)) &&
|
|
46
|
+
(value.recordedCostTokens === undefined || isNonNegativeFiniteNumber(value.recordedCostTokens)));
|
|
45
47
|
}
|
|
46
48
|
export function isDashboardEvent(value) {
|
|
47
49
|
if (!isRecord(value))
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { AccountingMetric } from "./dashboard.js";
|
|
1
|
+
import type { AccountingMetric, AccountingResultType } from "./dashboard.js";
|
|
2
2
|
/**
|
|
3
3
|
* Identity seam (design spec §5, §8, R20).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* The server-side hash
|
|
7
|
-
*
|
|
8
|
-
* browser
|
|
5
|
+
* Browser-safe contracts: the opaque id types and the stable row-key builder.
|
|
6
|
+
* The server-side card hash and entry-visibility helper live in
|
|
7
|
+
* `./quota-identity.ts` so neither the lib nor the GUI layer imports the other,
|
|
8
|
+
* and the browser bundle never pulls in `node:crypto`.
|
|
9
9
|
*/
|
|
10
10
|
declare const cardIdBrand: unique symbol;
|
|
11
11
|
declare const rowIdBrand: unique symbol;
|
|
@@ -33,9 +33,41 @@ export type RowKeyInput = AccountingMetric | {
|
|
|
33
33
|
};
|
|
34
34
|
/** Stable-`rowKey` builder type (no hashing; the card hash is server-side). */
|
|
35
35
|
export type RowKeyBuilder = (input: RowKeyInput) => RowKey;
|
|
36
|
+
/** The minimal entry identity fields; real `QuotaToastEntry` values are assignable. */
|
|
37
|
+
export interface QuotaRowIdentityEntry {
|
|
38
|
+
readonly semantic?: {
|
|
39
|
+
readonly metric: AccountingMetric;
|
|
40
|
+
readonly prominence: "primary" | "supplementary";
|
|
41
|
+
};
|
|
42
|
+
readonly rowKey?: string;
|
|
43
|
+
readonly kind?: "percent" | "value" | "quantity" | "boolean";
|
|
44
|
+
readonly accounting: {
|
|
45
|
+
readonly resultType: AccountingResultType;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
36
48
|
/** Builds a deterministic row key from a typed semantic key. */
|
|
37
49
|
export declare function buildRowKey(input: RowKeyInput): RowKey;
|
|
38
50
|
/** Composes `rowId = cardId + "#" + rowKey` (R20). */
|
|
39
51
|
export declare function composeRowId(cardId: CardId, rowKey: RowKey): RowId;
|
|
52
|
+
/**
|
|
53
|
+
* Stable typed row key: the entry's semantic metric (window/component/named) or
|
|
54
|
+
* its provider-supplied `rowKey`, plus the `resultType:kind` discriminator so
|
|
55
|
+
* rows that share a metric but mean different things stay distinct. Never a
|
|
56
|
+
* display label or an ordinal, so a rename cannot change a row id.
|
|
57
|
+
*/
|
|
58
|
+
export declare function rowKeyForEntry(entry: QuotaRowIdentityEntry): RowKey;
|
|
59
|
+
/** `rowId = cardId + "#" + rowKey` (R20). */
|
|
60
|
+
export declare function rowIdForEntry(cardId: CardId, entry: QuotaRowIdentityEntry): RowId;
|
|
61
|
+
/**
|
|
62
|
+
* Row id for a declared optional field. `kind` must match the live row's
|
|
63
|
+
* render shape so hiding the Settings eye also hides the emitted row.
|
|
64
|
+
*/
|
|
65
|
+
export declare function optionalRowId(cardId: CardId, rowKey: string, resultType: AccountingResultType, kind?: "percent" | "value" | "quantity" | "boolean"): RowId;
|
|
66
|
+
/**
|
|
67
|
+
* The typed field key inside a row id (`cardId#<field>|<resultType>:<kind>`).
|
|
68
|
+
* Used only to keep one Settings entry per field when a provider emits the same
|
|
69
|
+
* field in a different render shape than its declaration describes.
|
|
70
|
+
*/
|
|
71
|
+
export declare function rowFieldKey(rowId: string): string;
|
|
40
72
|
export {};
|
|
41
73
|
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -24,4 +24,47 @@ export function composeRowId(cardId, rowKey) {
|
|
|
24
24
|
// SAFETY: RowId is the opaque brand of exactly `cardId + "#" + rowKey`.
|
|
25
25
|
return `${cardId}#${rowKey}`;
|
|
26
26
|
}
|
|
27
|
+
function baseRowKeyOf(entry) {
|
|
28
|
+
if (entry.semantic)
|
|
29
|
+
return buildRowKey(entry.semantic.metric);
|
|
30
|
+
if (entry.rowKey)
|
|
31
|
+
return buildRowKey({ kind: "explicit", key: entry.rowKey });
|
|
32
|
+
return buildRowKey({ kind: "aggregate" });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Stable typed row key: the entry's semantic metric (window/component/named) or
|
|
36
|
+
* its provider-supplied `rowKey`, plus the `resultType:kind` discriminator so
|
|
37
|
+
* rows that share a metric but mean different things stay distinct. Never a
|
|
38
|
+
* display label or an ordinal, so a rename cannot change a row id.
|
|
39
|
+
*/
|
|
40
|
+
export function rowKeyForEntry(entry) {
|
|
41
|
+
const base = baseRowKeyOf(entry);
|
|
42
|
+
const kind = entry.kind === undefined || entry.kind === "percent" ? "percent" : entry.kind;
|
|
43
|
+
return buildRowKey({ kind: "explicit", key: `${base}|${entry.accounting.resultType}:${kind}` });
|
|
44
|
+
}
|
|
45
|
+
/** `rowId = cardId + "#" + rowKey` (R20). */
|
|
46
|
+
export function rowIdForEntry(cardId, entry) {
|
|
47
|
+
return composeRowId(cardId, rowKeyForEntry(entry));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Row id for a declared optional field. `kind` must match the live row's
|
|
51
|
+
* render shape so hiding the Settings eye also hides the emitted row.
|
|
52
|
+
*/
|
|
53
|
+
export function optionalRowId(cardId, rowKey, resultType, kind = "value") {
|
|
54
|
+
const entry = kind === "percent"
|
|
55
|
+
? { rowKey, accounting: { resultType } }
|
|
56
|
+
: { rowKey, kind, accounting: { resultType } };
|
|
57
|
+
return rowIdForEntry(cardId, entry);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The typed field key inside a row id (`cardId#<field>|<resultType>:<kind>`).
|
|
61
|
+
* Used only to keep one Settings entry per field when a provider emits the same
|
|
62
|
+
* field in a different render shape than its declaration describes.
|
|
63
|
+
*/
|
|
64
|
+
export function rowFieldKey(rowId) {
|
|
65
|
+
const hash = rowId.indexOf("#");
|
|
66
|
+
const key = hash >= 0 ? rowId.slice(hash + 1) : rowId;
|
|
67
|
+
const discriminator = key.lastIndexOf("|");
|
|
68
|
+
return discriminator >= 0 ? key.slice(0, discriminator) : key;
|
|
69
|
+
}
|
|
27
70
|
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Providers that can supply auto-resume evidence, in provider-registration
|
|
3
|
+
* order. Settings help copy is browser-layer code and must not import the
|
|
4
|
+
* provider metadata module, so the labels are mirrored here for that one
|
|
5
|
+
* string. `tests/lib.provider-metadata.test.ts` fails if this list drifts from
|
|
6
|
+
* the registration metadata's `autoResume` bindings.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AUTO_RESUME_SUPPORTED_PROVIDER_LABELS: readonly ["Claude Agent", "Copilot", "OpenAI", "Synthetic", "Chutes", "Z.ai", "Zhipu", "NanoGPT", "MiniMax Token Plan", "MiniMax Token Plan (CN)", "xAI", "OpenCode Go", "OpenCode Zen", "Ollama Cloud"];
|
|
9
|
+
//# sourceMappingURL=provider-auto-resume.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Providers that can supply auto-resume evidence, in provider-registration
|
|
3
|
+
* order. Settings help copy is browser-layer code and must not import the
|
|
4
|
+
* provider metadata module, so the labels are mirrored here for that one
|
|
5
|
+
* string. `tests/lib.provider-metadata.test.ts` fails if this list drifts from
|
|
6
|
+
* the registration metadata's `autoResume` bindings.
|
|
7
|
+
*/
|
|
8
|
+
export const AUTO_RESUME_SUPPORTED_PROVIDER_LABELS = [
|
|
9
|
+
"Claude Agent",
|
|
10
|
+
"Copilot",
|
|
11
|
+
"OpenAI",
|
|
12
|
+
"Synthetic",
|
|
13
|
+
"Chutes",
|
|
14
|
+
"Z.ai",
|
|
15
|
+
"Zhipu",
|
|
16
|
+
"NanoGPT",
|
|
17
|
+
"MiniMax Token Plan",
|
|
18
|
+
"MiniMax Token Plan (CN)",
|
|
19
|
+
"xAI",
|
|
20
|
+
"OpenCode Go",
|
|
21
|
+
"OpenCode Zen",
|
|
22
|
+
"Ollama Cloud",
|
|
23
|
+
];
|
|
24
|
+
//# sourceMappingURL=provider-auto-resume.js.map
|