@chenlongapps/opencode-token-usage 0.4.2 → 0.4.4
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 -5
- package/README.zh-CN.md +16 -5
- package/ROADMAP.md +4 -1
- package/dist/context-capture.d.ts +43 -0
- package/dist/context-capture.js +111 -0
- package/dist/controller.d.ts +4 -0
- package/dist/controller.js +43 -15
- package/dist/index.js +29 -8
- package/dist/performance.d.ts +19 -0
- package/dist/performance.js +112 -36
- package/dist/prices.generated.d.ts +338 -15
- package/dist/prices.generated.js +32 -10
- package/dist/pricing.d.ts +1 -1
- package/dist/source.d.ts +3 -2
- package/dist/source.js +31 -16
- package/dist/tui.js +209 -153
- package/dist/usage.d.ts +22 -2
- package/dist/usage.js +91 -14
- package/docs/pricing.md +1 -0
- package/docs/verification.md +54 -0
- package/package.json +2 -2
package/dist/prices.generated.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const GENERATED_PRICE_SNAPSHOT = {
|
|
2
|
-
verified: "2026-
|
|
2
|
+
verified: "2026-10-02",
|
|
3
3
|
source: "https://models.dev/api.json",
|
|
4
4
|
entries: [
|
|
5
5
|
{ "providerID": "ai21", "id": "jamba-large", "prices": [{ "input": 2, "output": 8 }], "released": "2025-07-01" },
|
|
@@ -40,16 +40,19 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
40
40
|
{ "providerID": "alibaba", "id": "qwen3.5-27b", "prices": [{ "input": 0.3, "output": 2.4 }], "released": "2026-02-23" },
|
|
41
41
|
{ "providerID": "alibaba", "id": "qwen3.5-35b-a3b", "prices": [{ "input": 0.25, "output": 2 }], "released": "2026-02-23" },
|
|
42
42
|
{ "providerID": "alibaba", "id": "qwen3.5-397b-a17b", "prices": [{ "input": 0.6, "output": 3.6 }], "released": "2026-02-15" },
|
|
43
|
+
{ "providerID": "alibaba", "id": "qwen3.5-flash", "prices": [{ "input": 0.1, "output": 0.4, "cache": { "read": 0.01 } }], "released": "2026-02-23" },
|
|
43
44
|
{ "providerID": "alibaba", "id": "qwen3.5-plus", "prices": [{ "input": 0.4, "output": 2.4 }], "released": "2026-02-16" },
|
|
44
45
|
{ "providerID": "alibaba", "id": "qwen3.6-27b", "prices": [{ "input": 0.6, "output": 3.6 }], "released": "2026-04-22" },
|
|
45
46
|
{ "providerID": "alibaba", "id": "qwen3.6-35b-a3b", "prices": [{ "input": 0.248, "output": 1.485 }], "released": "2026-04-17" },
|
|
46
47
|
{ "providerID": "alibaba", "id": "qwen3.6-flash", "prices": [{ "input": 0.1875, "output": 1.125, "cache": {} }], "released": "2026-04-27" },
|
|
47
48
|
{ "providerID": "alibaba", "id": "qwen3.6-max-preview", "prices": [{ "input": 1.3, "output": 7.8, "cache": { "read": 0.13 } }], "released": "2026-04-20" },
|
|
48
49
|
{ "providerID": "alibaba", "id": "qwen3.6-plus", "prices": [{ "input": 0.5, "output": 3, "cache": { "read": 0.05 } }, { "input": 2, "output": 6, "cache": { "read": 0.2 }, "tier": { "type": "context", "size": 256000 } }], "released": "2026-04-02" },
|
|
50
|
+
{ "providerID": "alibaba", "id": "qwen3.7-flash", "prices": [{ "input": 0.03, "output": 0.13, "cache": { "read": 0.003 } }, { "input": 0.1, "output": 0.4, "cache": { "read": 0.01 }, "tier": { "type": "context", "size": 32000 } }, { "input": 0.2, "output": 0.8, "cache": { "read": 0.02 }, "tier": { "type": "context", "size": 256000 } }], "released": "2026-07-15" },
|
|
49
51
|
{ "providerID": "alibaba", "id": "qwen3.7-max", "prices": [{ "input": 2.5, "output": 7.5, "cache": { "read": 0.5 } }], "released": "2026-05-21" },
|
|
50
|
-
{ "providerID": "alibaba", "id": "qwen3.7-plus", "prices": [{ "input": 0.
|
|
52
|
+
{ "providerID": "alibaba", "id": "qwen3.7-plus", "prices": [{ "input": 0.4, "output": 1.6, "cache": { "read": 0.04 } }, { "input": 1.2, "output": 4.8, "cache": { "read": 0.12 }, "tier": { "type": "context", "size": 256000 } }], "released": "2026-06-02" },
|
|
51
53
|
{ "providerID": "alibaba", "id": "qwen3.8-flash", "prices": [{ "input": 0.15, "output": 0.47, "cache": { "read": 0.016 } }], "released": "2026-08-26" },
|
|
52
54
|
{ "providerID": "alibaba", "id": "qwen3.8-max", "prices": [{ "input": 2, "output": 6, "cache": { "read": 0.25 } }], "released": "2026-08-03" },
|
|
55
|
+
{ "providerID": "alibaba", "id": "qwen3.8-omni-flash", "prices": [{ "input": 0.15, "output": 0.47, "cache": { "read": 0.016 } }], "released": "2026-09-17" },
|
|
53
56
|
{ "providerID": "alibaba", "id": "qwq-plus", "prices": [{ "input": 0.8, "output": 2.4 }], "released": "2025-03-05" },
|
|
54
57
|
{ "providerID": "anthropic", "id": "claude-fable-5", "prices": [{ "input": 10, "output": 50, "cache": { "read": 1, "write": 12.5 } }], "released": "2026-06-07" },
|
|
55
58
|
{ "providerID": "anthropic", "id": "claude-fable-5-1", "prices": [{ "input": 10, "output": 50, "cache": { "read": 0.25, "write": 12.5 } }], "released": "2026-09-01" },
|
|
@@ -69,6 +72,7 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
69
72
|
{ "providerID": "anthropic", "id": "claude-sonnet-4-5-20250929", "prices": [{ "input": 3, "output": 15, "cache": { "read": 0.3, "write": 3.75 } }], "released": "2025-09-29" },
|
|
70
73
|
{ "providerID": "anthropic", "id": "claude-sonnet-4-6", "prices": [{ "input": 3, "output": 15, "cache": { "read": 0.3, "write": 3.75 } }], "released": "2026-02-17" },
|
|
71
74
|
{ "providerID": "anthropic", "id": "claude-sonnet-5", "prices": [{ "input": 2, "output": 10, "cache": { "read": 0.2, "write": 2.5 } }], "released": "2026-06-29" },
|
|
75
|
+
{ "providerID": "anthropic", "id": "claude-sonnet-5-5", "prices": [{ "input": 2, "output": 10, "cache": { "read": 0.2, "write": 2.5 } }], "released": "2026-09-28" },
|
|
72
76
|
{ "providerID": "arcee", "id": "trinity-large-thinking", "prices": [{ "input": 0.25, "output": 0.8, "cache": { "read": 0.06 } }], "released": "2026-04-01" },
|
|
73
77
|
{ "providerID": "cohere", "id": "command-a-03-2025", "prices": [{ "input": 2.5, "output": 10 }], "released": "2025-03-13" },
|
|
74
78
|
{ "providerID": "cohere", "id": "command-a-plus-05-2026", "prices": [{ "input": 2.5, "output": 10 }], "released": "2026-05-20" },
|
|
@@ -80,6 +84,7 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
80
84
|
{ "providerID": "cohere", "id": "command-r7b-12-2024", "prices": [{ "input": 0.0375, "output": 0.15 }], "released": "2024-12-02" },
|
|
81
85
|
{ "providerID": "cohere", "id": "command-r7b-arabic-02-2025", "prices": [{ "input": 0.0375, "output": 0.15 }], "released": "2025-02-27" },
|
|
82
86
|
{ "providerID": "cohere", "id": "north-mini-code-1-0", "prices": [{ "input": 0, "output": 0 }], "released": "2026-06-09" },
|
|
87
|
+
{ "providerID": "cohere", "id": "north-small-translate-09-2026", "prices": [{ "input": 0, "output": 0 }], "released": "2026-09-09" },
|
|
83
88
|
{ "providerID": "deepseek", "id": "deepseek-flash", "prices": [{ "input": 0.15, "output": 0.6, "cache": { "read": 0.003 } }], "released": "2026-09-10" },
|
|
84
89
|
{ "providerID": "deepseek", "id": "deepseek-v4-flash", "prices": [{ "input": 0.15, "output": 0.6, "cache": { "read": 0.003 } }], "released": "2026-09-10" },
|
|
85
90
|
{ "providerID": "deepseek", "id": "deepseek-v4-flash-vision-exp", "prices": [{ "input": 0.15, "output": 0.6, "cache": { "read": 0.003 } }], "released": "2026-09-10" },
|
|
@@ -118,7 +123,7 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
118
123
|
{ "providerID": "minimax", "id": "minimax-m2.7", "prices": [{ "input": 0.3, "output": 1.2, "cache": { "read": 0.06, "write": 0.375 } }], "released": "2026-03-18" },
|
|
119
124
|
{ "providerID": "minimax", "id": "minimax-m2.7-highspeed", "prices": [{ "input": 0.6, "output": 2.4, "cache": { "read": 0.06, "write": 0.375 } }], "released": "2026-03-18" },
|
|
120
125
|
{ "providerID": "minimax", "id": "minimax-m3", "prices": [{ "input": 0.3, "output": 1.2, "cache": { "read": 0.06 } }, { "input": 0.6, "output": 2.4, "cache": { "read": 0.12 }, "tier": { "type": "context", "size": 512000 } }], "released": "2026-06-01" },
|
|
121
|
-
{ "providerID": "mistral", "id": "codestral-latest", "prices": [{ "input": 0.3, "output": 0.9 }], "released": "2024-05-29" },
|
|
126
|
+
{ "providerID": "mistral", "id": "codestral-latest", "prices": [{ "input": 0.3, "output": 0.9, "cache": { "read": 0.03 } }], "released": "2024-05-29" },
|
|
122
127
|
{ "providerID": "mistral", "id": "devstral-2512", "prices": [{ "input": 0.4, "output": 2 }], "released": "2025-12-09" },
|
|
123
128
|
{ "providerID": "mistral", "id": "devstral-latest", "prices": [{ "input": 0.4, "output": 2 }], "released": "2025-12-09" },
|
|
124
129
|
{ "providerID": "mistral", "id": "devstral-medium-2507", "prices": [{ "input": 0.4, "output": 2 }], "released": "2025-07-10" },
|
|
@@ -127,20 +132,19 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
127
132
|
{ "providerID": "mistral", "id": "devstral-small-2507", "prices": [{ "input": 0.1, "output": 0.3 }], "released": "2025-07-10" },
|
|
128
133
|
{ "providerID": "mistral", "id": "labs-devstral-small-2512", "prices": [{ "input": 0, "output": 0 }], "released": "2025-12-09" },
|
|
129
134
|
{ "providerID": "mistral", "id": "magistral-medium-latest", "prices": [{ "input": 2, "output": 5 }], "released": "2025-03-17" },
|
|
130
|
-
{ "providerID": "mistral", "id": "magistral-small", "prices": [{ "input": 0.5, "output": 1.5 }], "released": "2025-03-17" },
|
|
131
135
|
{ "providerID": "mistral", "id": "ministral-3b-latest", "prices": [{ "input": 0.04, "output": 0.04 }], "released": "2024-10-01" },
|
|
132
136
|
{ "providerID": "mistral", "id": "ministral-8b-latest", "prices": [{ "input": 0.1, "output": 0.1 }], "released": "2024-10-01" },
|
|
133
137
|
{ "providerID": "mistral", "id": "mistral-large-2411", "prices": [{ "input": 2, "output": 6 }], "released": "2024-11-18" },
|
|
134
|
-
{ "providerID": "mistral", "id": "mistral-large-2512", "prices": [{ "input": 0.5, "output": 1.5 }], "released": "2024-11-01" },
|
|
135
|
-
{ "providerID": "mistral", "id": "mistral-large-latest", "prices": [{ "input": 0.5, "output": 1.5 }], "released": "2024-11-01" },
|
|
138
|
+
{ "providerID": "mistral", "id": "mistral-large-2512", "prices": [{ "input": 0.5, "output": 1.5, "cache": { "read": 0.05 } }], "released": "2024-11-01" },
|
|
139
|
+
{ "providerID": "mistral", "id": "mistral-large-latest", "prices": [{ "input": 0.5, "output": 1.5, "cache": { "read": 0.05 } }], "released": "2024-11-01" },
|
|
136
140
|
{ "providerID": "mistral", "id": "mistral-medium-2505", "prices": [{ "input": 0.4, "output": 2 }], "released": "2025-05-07" },
|
|
137
141
|
{ "providerID": "mistral", "id": "mistral-medium-2508", "prices": [{ "input": 0.4, "output": 2 }], "released": "2025-08-12" },
|
|
138
|
-
{ "providerID": "mistral", "id": "mistral-medium-2604", "prices": [{ "input": 1.5, "output": 7.5 }], "released": "2026-04-29" },
|
|
139
|
-
{ "providerID": "mistral", "id": "mistral-medium-latest", "prices": [{ "input": 1.5, "output": 7.5 }], "released": "2026-04-29" },
|
|
142
|
+
{ "providerID": "mistral", "id": "mistral-medium-2604", "prices": [{ "input": 1.5, "output": 7.5, "cache": { "read": 0.15 } }], "released": "2026-04-29" },
|
|
143
|
+
{ "providerID": "mistral", "id": "mistral-medium-latest", "prices": [{ "input": 1.5, "output": 7.5, "cache": { "read": 0.15 } }], "released": "2026-04-29" },
|
|
140
144
|
{ "providerID": "mistral", "id": "mistral-nemo", "prices": [{ "input": 0.15, "output": 0.15 }], "released": "2024-07-01" },
|
|
141
145
|
{ "providerID": "mistral", "id": "mistral-small-2506", "prices": [{ "input": 0.1, "output": 0.3 }], "released": "2025-06-20" },
|
|
142
|
-
{ "providerID": "mistral", "id": "mistral-small-2603", "prices": [{ "input": 0.15, "output": 0.6 }], "released": "2026-03-16" },
|
|
143
|
-
{ "providerID": "mistral", "id": "mistral-small-latest", "prices": [{ "input": 0.15, "output": 0.6 }], "released": "2026-03-16" },
|
|
146
|
+
{ "providerID": "mistral", "id": "mistral-small-2603", "prices": [{ "input": 0.15, "output": 0.6, "cache": { "read": 0.015 } }], "released": "2026-03-16" },
|
|
147
|
+
{ "providerID": "mistral", "id": "mistral-small-latest", "prices": [{ "input": 0.15, "output": 0.6, "cache": { "read": 0.015 } }], "released": "2026-03-16" },
|
|
144
148
|
{ "providerID": "mistral", "id": "open-mistral-7b", "prices": [{ "input": 0.25, "output": 0.25 }], "released": "2023-09-27" },
|
|
145
149
|
{ "providerID": "mistral", "id": "open-mistral-nemo", "prices": [{ "input": 0.15, "output": 0.15 }], "released": "2024-07-01" },
|
|
146
150
|
{ "providerID": "mistral", "id": "open-mixtral-8x22b", "prices": [{ "input": 2, "output": 6 }], "released": "2024-04-17" },
|
|
@@ -164,6 +168,7 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
164
168
|
{ "providerID": "nvidia", "id": "nvidia/nemotron-3-nano-omni-30b-a3b-reasoning", "prices": [{ "input": 0, "output": 0 }], "released": "2026-04-28" },
|
|
165
169
|
{ "providerID": "nvidia", "id": "nvidia/nemotron-3-super-120b-a12b", "prices": [{ "input": 0.2, "output": 0.8 }], "released": "2026-03-11" },
|
|
166
170
|
{ "providerID": "nvidia", "id": "nvidia/nemotron-3-ultra-550b-a55b", "prices": [{ "input": 0.5, "output": 2.5, "cache": { "read": 0.15 } }], "released": "2026-06-04" },
|
|
171
|
+
{ "providerID": "nvidia", "id": "nvidia/nemotron-3.5-content-safety", "prices": [{ "input": 0, "output": 0 }], "released": "2026-06-04" },
|
|
167
172
|
{ "providerID": "nvidia", "id": "nvidia/nemotron-3.5-lightning-30b-a3b", "prices": [{ "input": 0, "output": 0 }], "released": "2026-08-11" },
|
|
168
173
|
{ "providerID": "nvidia", "id": "nvidia/nemotron-content-safety-reasoning-4b", "prices": [{ "input": 0, "output": 0 }], "released": "2026-01-22" },
|
|
169
174
|
{ "providerID": "nvidia", "id": "nvidia/nemotron-mini-4b-instruct", "prices": [{ "input": 0, "output": 0 }], "released": "2024-08-21" },
|
|
@@ -173,23 +178,34 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
173
178
|
{ "providerID": "openai", "id": "gpt-4", "prices": [{ "input": 30, "output": 60 }], "released": "2023-11-06" },
|
|
174
179
|
{ "providerID": "openai", "id": "gpt-4-turbo", "prices": [{ "input": 10, "output": 30 }], "released": "2023-11-06" },
|
|
175
180
|
{ "providerID": "openai", "id": "gpt-4.1", "prices": [{ "input": 2, "output": 8, "cache": { "read": 0.5 } }], "released": "2025-04-14" },
|
|
181
|
+
{ "providerID": "openai", "id": "gpt-4.1-fast", "providers": ["openai"], "prices": [{ "input": 3.5, "output": 14, "cache": { "read": 0.875 } }], "released": "2025-04-14" },
|
|
176
182
|
{ "providerID": "openai", "id": "gpt-4.1-mini", "prices": [{ "input": 0.4, "output": 1.6, "cache": { "read": 0.1 } }], "released": "2025-04-14" },
|
|
183
|
+
{ "providerID": "openai", "id": "gpt-4.1-mini-fast", "providers": ["openai"], "prices": [{ "input": 0.7, "output": 2.8, "cache": { "read": 0.175 } }], "released": "2025-04-14" },
|
|
177
184
|
{ "providerID": "openai", "id": "gpt-4.1-nano", "prices": [{ "input": 0.1, "output": 0.4, "cache": { "read": 0.025 } }], "released": "2025-04-14" },
|
|
185
|
+
{ "providerID": "openai", "id": "gpt-4.1-nano-fast", "providers": ["openai"], "prices": [{ "input": 0.2, "output": 0.8, "cache": { "read": 0.05 } }], "released": "2025-04-14" },
|
|
178
186
|
{ "providerID": "openai", "id": "gpt-4o", "prices": [{ "input": 2.5, "output": 10, "cache": { "read": 1.25 } }], "released": "2024-05-13" },
|
|
179
187
|
{ "providerID": "openai", "id": "gpt-4o-2024-05-13", "prices": [{ "input": 5, "output": 15 }], "released": "2024-05-13" },
|
|
188
|
+
{ "providerID": "openai", "id": "gpt-4o-2024-05-13-fast", "providers": ["openai"], "prices": [{ "input": 8.75, "output": 26.25 }], "released": "2024-05-13" },
|
|
180
189
|
{ "providerID": "openai", "id": "gpt-4o-2024-08-06", "prices": [{ "input": 2.5, "output": 10, "cache": { "read": 1.25 } }], "released": "2024-08-06" },
|
|
181
190
|
{ "providerID": "openai", "id": "gpt-4o-2024-11-20", "prices": [{ "input": 2.5, "output": 10, "cache": { "read": 1.25 } }], "released": "2024-11-20" },
|
|
191
|
+
{ "providerID": "openai", "id": "gpt-4o-fast", "providers": ["openai"], "prices": [{ "input": 4.25, "output": 17, "cache": { "read": 2.125 } }], "released": "2024-05-13" },
|
|
182
192
|
{ "providerID": "openai", "id": "gpt-4o-mini", "prices": [{ "input": 0.15, "output": 0.6, "cache": { "read": 0.075 } }], "released": "2024-07-18" },
|
|
193
|
+
{ "providerID": "openai", "id": "gpt-4o-mini-fast", "providers": ["openai"], "prices": [{ "input": 0.25, "output": 1, "cache": { "read": 0.125 } }], "released": "2024-07-18" },
|
|
183
194
|
{ "providerID": "openai", "id": "gpt-5", "prices": [{ "input": 1.25, "output": 10, "cache": { "read": 0.125 } }], "released": "2025-08-07" },
|
|
195
|
+
{ "providerID": "openai", "id": "gpt-5-fast", "providers": ["openai"], "prices": [{ "input": 2.5, "output": 20, "cache": { "read": 0.25 } }], "released": "2025-08-07" },
|
|
184
196
|
{ "providerID": "openai", "id": "gpt-5-mini", "prices": [{ "input": 0.25, "output": 2, "cache": { "read": 0.025 } }], "released": "2025-08-07" },
|
|
197
|
+
{ "providerID": "openai", "id": "gpt-5-mini-fast", "providers": ["openai"], "prices": [{ "input": 0.45, "output": 3.6, "cache": { "read": 0.045 } }], "released": "2025-08-07" },
|
|
185
198
|
{ "providerID": "openai", "id": "gpt-5-nano", "prices": [{ "input": 0.05, "output": 0.4, "cache": { "read": 0.005 } }], "released": "2025-08-07" },
|
|
186
199
|
{ "providerID": "openai", "id": "gpt-5-pro", "prices": [{ "input": 15, "output": 120 }], "released": "2025-10-06" },
|
|
187
200
|
{ "providerID": "openai", "id": "gpt-5.1", "prices": [{ "input": 1.25, "output": 10, "cache": { "read": 0.125 } }], "released": "2025-11-13" },
|
|
201
|
+
{ "providerID": "openai", "id": "gpt-5.1-fast", "providers": ["openai"], "prices": [{ "input": 2.5, "output": 20, "cache": { "read": 0.25 } }], "released": "2025-11-13" },
|
|
188
202
|
{ "providerID": "openai", "id": "gpt-5.2", "prices": [{ "input": 1.75, "output": 14, "cache": { "read": 0.175 } }], "released": "2025-12-11" },
|
|
189
203
|
{ "providerID": "openai", "id": "gpt-5.2-chat-latest", "prices": [{ "input": 1.75, "output": 14, "cache": { "read": 0.175 } }], "released": "2025-12-11" },
|
|
204
|
+
{ "providerID": "openai", "id": "gpt-5.2-fast", "providers": ["openai"], "prices": [{ "input": 3.5, "output": 28, "cache": { "read": 0.35 } }], "released": "2025-12-11" },
|
|
190
205
|
{ "providerID": "openai", "id": "gpt-5.2-pro", "prices": [{ "input": 21, "output": 168 }], "released": "2025-12-11" },
|
|
191
206
|
{ "providerID": "openai", "id": "gpt-5.3-chat-latest", "prices": [{ "input": 1.75, "output": 14, "cache": { "read": 0.175 } }], "released": "2026-03-03" },
|
|
192
207
|
{ "providerID": "openai", "id": "gpt-5.3-codex", "prices": [{ "input": 1.75, "output": 14, "cache": { "read": 0.175 } }], "released": "2026-02-05" },
|
|
208
|
+
{ "providerID": "openai", "id": "gpt-5.3-codex-fast", "providers": ["openai"], "prices": [{ "input": 3.5, "output": 28, "cache": { "read": 0.35 } }], "released": "2026-02-05" },
|
|
193
209
|
{ "providerID": "openai", "id": "gpt-5.3-codex-spark", "prices": [{ "input": 1.75, "output": 14, "cache": { "read": 0.175 } }], "released": "2026-02-05" },
|
|
194
210
|
{ "providerID": "openai", "id": "gpt-5.4", "prices": [{ "input": 2.5, "output": 15, "cache": { "read": 0.25 } }, { "input": 5, "output": 22.5, "cache": { "read": 0.5 }, "tier": { "type": "context", "size": 272000 } }], "released": "2026-03-05" },
|
|
195
211
|
{ "providerID": "openai", "id": "gpt-5.4-fast", "providers": ["openai"], "prices": [{ "input": 5, "output": 30, "cache": { "read": 0.5 } }, { "tier": { "type": "context", "size": 272000 } }], "released": "2026-03-05" },
|
|
@@ -214,12 +230,18 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
214
230
|
{ "providerID": "openai", "id": "gpt-6-luna-fast", "providers": ["openai"], "prices": [{ "input": 0.2, "output": 1, "cache": { "read": 0.02, "write": 0.25 } }, { "tier": { "type": "context", "size": 272000 } }], "released": "2026-09-22" },
|
|
215
231
|
{ "providerID": "openai", "id": "gpt-6-sol", "prices": [{ "input": 2, "output": 10, "cache": { "read": 0.2, "write": 2.5 } }, { "input": 4, "output": 15, "cache": { "read": 0.4, "write": 5 }, "tier": { "type": "context", "size": 272000 } }], "released": "2026-09-22" },
|
|
216
232
|
{ "providerID": "openai", "id": "gpt-6-sol-fast", "providers": ["openai"], "prices": [{ "input": 4, "output": 20, "cache": { "read": 0.4, "write": 5 } }, { "tier": { "type": "context", "size": 272000 } }], "released": "2026-09-22" },
|
|
233
|
+
{ "providerID": "openai", "id": "gpt-6.1-sol", "prices": [{ "input": 2, "output": 10, "cache": { "read": 0.1, "write": 2.5 } }, { "input": 4, "output": 15, "cache": { "read": 0.2, "write": 5 }, "tier": { "type": "context", "size": 272000 } }], "released": "2026-09-29" },
|
|
234
|
+
{ "providerID": "openai", "id": "gpt-6.1-sol-fast", "providers": ["openai"], "prices": [{ "input": 4, "output": 20, "cache": { "read": 0.2, "write": 5 } }, { "tier": { "type": "context", "size": 272000 } }], "released": "2026-09-29" },
|
|
235
|
+
{ "providerID": "openai", "id": "gpt-daybreak-blue-latest", "prices": [{ "input": 4, "output": 20, "cache": { "read": 0.4, "write": 5 } }, { "input": 8, "output": 30, "cache": { "read": 0.8, "write": 10 }, "tier": { "type": "context", "size": 272000 } }], "released": "2026-08-07" },
|
|
236
|
+
{ "providerID": "openai", "id": "gpt-daybreak-red-latest", "prices": [{ "input": 12.5, "output": 75, "cache": { "read": 1.25, "write": 15.625 } }], "released": "2026-08-07" },
|
|
217
237
|
{ "providerID": "openai", "id": "o1", "prices": [{ "input": 15, "output": 60, "cache": { "read": 7.5 } }], "released": "2024-12-05" },
|
|
218
238
|
{ "providerID": "openai", "id": "o1-pro", "prices": [{ "input": 150, "output": 600 }], "released": "2025-03-19" },
|
|
219
239
|
{ "providerID": "openai", "id": "o3", "prices": [{ "input": 2, "output": 8, "cache": { "read": 0.5 } }], "released": "2025-04-16" },
|
|
240
|
+
{ "providerID": "openai", "id": "o3-fast", "providers": ["openai"], "prices": [{ "input": 3.5, "output": 14, "cache": { "read": 0.875 } }], "released": "2025-04-16" },
|
|
220
241
|
{ "providerID": "openai", "id": "o3-mini", "prices": [{ "input": 1.1, "output": 4.4, "cache": { "read": 0.55 } }], "released": "2024-12-20" },
|
|
221
242
|
{ "providerID": "openai", "id": "o3-pro", "prices": [{ "input": 20, "output": 80 }], "released": "2025-06-10" },
|
|
222
243
|
{ "providerID": "openai", "id": "o4-mini", "prices": [{ "input": 1.1, "output": 4.4, "cache": { "read": 0.275 } }], "released": "2025-04-16" },
|
|
244
|
+
{ "providerID": "openai", "id": "o4-mini-fast", "providers": ["openai"], "prices": [{ "input": 2, "output": 8, "cache": { "read": 0.5 } }], "released": "2025-04-16" },
|
|
223
245
|
{ "providerID": "perplexity", "id": "sonar", "prices": [{ "input": 1, "output": 1 }], "released": "2024-01-01" },
|
|
224
246
|
{ "providerID": "perplexity", "id": "sonar-deep-research", "prices": [{ "input": 2, "output": 8, "reasoning": 3 }], "released": "2025-02-01" },
|
|
225
247
|
{ "providerID": "perplexity", "id": "sonar-pro", "prices": [{ "input": 3, "output": 15 }], "released": "2024-01-01" },
|
package/dist/pricing.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface OfficialPriceEntry {
|
|
|
14
14
|
/** Checked-in data: updating prices is explicit, not a network request at
|
|
15
15
|
* startup, during a refresh, or during an npm build. */
|
|
16
16
|
export declare const OFFICIAL_PRICE_SNAPSHOT: {
|
|
17
|
-
verified: "2026-
|
|
17
|
+
verified: "2026-10-02";
|
|
18
18
|
source: "https://models.dev/api.json";
|
|
19
19
|
entries: OfficialPriceEntry[];
|
|
20
20
|
};
|
package/dist/source.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OpenCodeClient, SessionInfo } from "@opencode/client";
|
|
2
2
|
import type { ContextSources } from "./context-sources.js";
|
|
3
3
|
import type { PriceCatalog, UsageMessage } from "./usage.js";
|
|
4
|
-
export type Session = Pick<SessionInfo, "id" | "parentID" | "fork" | "model" | "location" | "title">;
|
|
4
|
+
export type Session = Pick<SessionInfo, "id" | "parentID" | "fork" | "model" | "location" | "title" | "revert">;
|
|
5
5
|
export interface Page<T> {
|
|
6
6
|
data: T[];
|
|
7
7
|
cursor: {
|
|
@@ -31,7 +31,8 @@ export interface Snapshot {
|
|
|
31
31
|
messages: Map<string, Map<string, UsageMessage>>;
|
|
32
32
|
model: ActiveModel;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
/** A changed set permits reuse of unchanged histories. Omitting it forces a full read. */
|
|
35
|
+
export declare function loadSnapshot(source: UsageSource, sessionID: string, signal: AbortSignal, previous?: Snapshot, changed?: ReadonlySet<string>): Promise<Snapshot>;
|
|
35
36
|
/** History of the viewed session only, in API order (`order: "asc"`). */
|
|
36
37
|
export declare function viewedMessages(snapshot: Snapshot): readonly UsageMessage[];
|
|
37
38
|
export declare function uniqueMessages(snapshot: Snapshot): Iterable<UsageMessage>;
|
package/dist/source.js
CHANGED
|
@@ -48,7 +48,8 @@ export async function pages(read, signal) {
|
|
|
48
48
|
} while (cursor);
|
|
49
49
|
return result;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
/** A changed set permits reuse of unchanged histories. Omitting it forces a full read. */
|
|
52
|
+
export async function loadSnapshot(source, sessionID, signal, previous, changed) {
|
|
52
53
|
const viewed = await source.session(sessionID, signal);
|
|
53
54
|
let root = viewed;
|
|
54
55
|
const ancestors = new Set();
|
|
@@ -61,26 +62,40 @@ export async function loadSnapshot(source, sessionID, signal) {
|
|
|
61
62
|
}
|
|
62
63
|
const sessions = new Map([[root.id, root]]);
|
|
63
64
|
const messages = new Map();
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
const cache = previous?.rootID === root.id && previous.viewedID === viewed.id && changed
|
|
66
|
+
? previous.messages : undefined;
|
|
67
|
+
// Traverse every branch so additions and removals replace the tree atomically. Each
|
|
68
|
+
// wave reads at most four sessions concurrently; pagination within one stays ordered.
|
|
69
|
+
let frontier = [root];
|
|
70
|
+
while (frontier.length) {
|
|
71
|
+
const next = [];
|
|
72
|
+
for (let offset = 0; offset < frontier.length; offset += 4) {
|
|
73
|
+
signal.throwIfAborted();
|
|
74
|
+
const batch = frontier.slice(offset, offset + 4);
|
|
75
|
+
const results = await Promise.all(batch.map(async (session) => {
|
|
76
|
+
const reused = !changed?.has(session.id) ? cache?.get(session.id) : undefined;
|
|
77
|
+
const children = await pages(cursor => source.children(session.id, cursor, signal), signal);
|
|
78
|
+
const history = reused ?? new Map((await pages(cursor => source.messages(session.id, cursor, signal), signal))
|
|
79
|
+
.map(message => [message.id, message]));
|
|
80
|
+
return { session, children, history };
|
|
81
|
+
}));
|
|
82
|
+
for (const { session, children, history } of results) {
|
|
83
|
+
messages.set(session.id, history);
|
|
84
|
+
for (const child of children) {
|
|
85
|
+
if (child.parentID !== session.id)
|
|
86
|
+
throw new Error("Unexpected child session");
|
|
87
|
+
if (!sessions.has(child.id)) {
|
|
88
|
+
sessions.set(child.id, child);
|
|
89
|
+
next.push(child);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
79
92
|
}
|
|
80
93
|
}
|
|
94
|
+
frontier = next;
|
|
81
95
|
}
|
|
82
96
|
if (!sessions.has(viewed.id))
|
|
83
97
|
throw new Error("Session tree changed during refresh");
|
|
98
|
+
sessions.set(viewed.id, viewed);
|
|
84
99
|
const model = await source.model(viewed, signal);
|
|
85
100
|
signal.throwIfAborted();
|
|
86
101
|
return { rootID: root.id, viewedID: viewed.id, sessions, messages, model };
|