pantheon-opencode 1.6.2-beta.1 → 1.6.2-beta.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/CHANGELOG.md +13 -0
- package/README.md +23 -14
- package/README.pt-BR.md +12 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/src/pantheon/cost-command.ts +30 -133
- package/src/pantheon/model-pricing.ts +1 -536
- package/src/plugins/tui/THIRD_PARTY_NOTICES.md +24 -0
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +749 -0
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +1 -0
- package/src/plugins/tui/dist/quota-adapters.d.ts.map +1 -1
- package/src/plugins/tui/dist/quota-adapters.js +1 -1
- package/src/plugins/tui/dist/{quota-rpc-UL2HuFRJ.js → quota-rpc-DMmXBhBe.js} +295 -1
- package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +1 -0
- package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/server-v2.js +135 -12
- package/src/plugins/tui/dist/server-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui-v2.d.ts +132 -5
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +3720 -337
- package/src/plugins/tui/dist/tui-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +118 -0
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +1 -0
- package/src/plugins/tui/dist/usage-history-worker.js +25 -0
- package/src/plugins/tui/dist/usage-history-worker.js.map +1 -0
- 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 +32 -0
- package/src/plugins/tui/src/model-pricing.ts +536 -0
- package/src/plugins/tui/src/quota-rpc.ts +164 -0
- package/src/plugins/tui/src/quota-v2-model.ts +2 -2
- package/src/plugins/tui/src/quota-v2.tsx +338 -86
- package/src/plugins/tui/src/server-v2.ts +159 -15
- package/src/plugins/tui/src/usage-history-contract.ts +217 -0
- package/src/plugins/tui/src/usage-history-validation.ts +104 -0
- package/src/plugins/tui/src/usage-history-view.tsx +236 -0
- package/src/plugins/tui/src/usage-history-worker.ts +25 -0
- package/src/plugins/tui/src/usage-view-model.ts +272 -0
- package/src/plugins/tui/tsconfig.typecheck.json +6 -1
- package/src/plugins/tui/tsdown.config.ts +36 -4
- package/src/plugins/tui/dist/quota-rpc-UL2HuFRJ.js.map +0 -1
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Rpc } from '@opencode/plugin/promise/index'
|
|
2
|
+
import {
|
|
3
|
+
MAX_HISTORY_BUCKETS,
|
|
4
|
+
MAX_HISTORY_MODELS,
|
|
5
|
+
USAGE_HISTORY_PERIODS,
|
|
6
|
+
} from './usage-history-contract'
|
|
2
7
|
|
|
3
8
|
/** Full provider matrix approved for the V2 quota surface. */
|
|
4
9
|
export const QUOTA_PROVIDER_IDS = [
|
|
@@ -152,6 +157,150 @@ const providerStatusSchema = {
|
|
|
152
157
|
additionalProperties: false,
|
|
153
158
|
} as const
|
|
154
159
|
|
|
160
|
+
const usageHistoryTotalsSchema = {
|
|
161
|
+
type: 'object',
|
|
162
|
+
properties: {
|
|
163
|
+
input: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
164
|
+
output: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
165
|
+
cacheRead: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
166
|
+
cacheWrite: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
167
|
+
total: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
168
|
+
},
|
|
169
|
+
required: ['input', 'output', 'cacheRead', 'cacheWrite', 'total'],
|
|
170
|
+
additionalProperties: false,
|
|
171
|
+
} as const
|
|
172
|
+
|
|
173
|
+
const usageHistoryBucketSchema = {
|
|
174
|
+
type: 'object',
|
|
175
|
+
properties: {
|
|
176
|
+
date: { type: 'string', pattern: '^\\d{4}-\\d{2}-\\d{2}$' },
|
|
177
|
+
input: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
178
|
+
output: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
179
|
+
cacheRead: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
180
|
+
cacheWrite: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
181
|
+
total: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
182
|
+
estimatedUsd: { type: 'number', minimum: 0 },
|
|
183
|
+
pricingComplete: { type: 'boolean' },
|
|
184
|
+
},
|
|
185
|
+
required: ['date', 'input', 'output', 'cacheRead', 'cacheWrite', 'total', 'pricingComplete'],
|
|
186
|
+
additionalProperties: false,
|
|
187
|
+
} as const
|
|
188
|
+
|
|
189
|
+
const usageHistoryAvailableSchema = {
|
|
190
|
+
type: 'object',
|
|
191
|
+
properties: {
|
|
192
|
+
status: { type: 'string', enum: ['available', 'partial'] },
|
|
193
|
+
period: { type: 'string', enum: USAGE_HISTORY_PERIODS },
|
|
194
|
+
coverageStart: { type: ['string', 'null'], pattern: '^\\d{4}-\\d{2}-\\d{2}$' },
|
|
195
|
+
partial: { type: 'boolean' },
|
|
196
|
+
truncated: { type: 'boolean' },
|
|
197
|
+
rows: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
198
|
+
buckets: { type: 'array', items: usageHistoryBucketSchema, maxItems: MAX_HISTORY_BUCKETS },
|
|
199
|
+
totals: usageHistoryTotalsSchema,
|
|
200
|
+
models: {
|
|
201
|
+
type: 'array',
|
|
202
|
+
maxItems: MAX_HISTORY_MODELS,
|
|
203
|
+
items: {
|
|
204
|
+
type: 'object',
|
|
205
|
+
properties: {
|
|
206
|
+
providerID: { type: 'string', minLength: 1, maxLength: 128 },
|
|
207
|
+
modelID: { type: 'string', minLength: 1, maxLength: 128 },
|
|
208
|
+
totals: usageHistoryTotalsSchema,
|
|
209
|
+
estimatedUsd: { type: 'number', minimum: 0 },
|
|
210
|
+
pricingComplete: { type: 'boolean' },
|
|
211
|
+
},
|
|
212
|
+
required: ['providerID', 'modelID', 'totals', 'pricingComplete'],
|
|
213
|
+
additionalProperties: false,
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
pricing: {
|
|
217
|
+
type: 'object',
|
|
218
|
+
properties: {
|
|
219
|
+
status: { type: 'string', enum: ['empty', 'unavailable', 'partial', 'complete'] },
|
|
220
|
+
complete: { type: 'boolean' },
|
|
221
|
+
billed: { const: false },
|
|
222
|
+
estimatedUsd: { type: 'number', minimum: 0 },
|
|
223
|
+
unpricedModels: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
224
|
+
},
|
|
225
|
+
required: ['status', 'complete', 'billed', 'unpricedModels'],
|
|
226
|
+
additionalProperties: false,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
required: [
|
|
230
|
+
'status',
|
|
231
|
+
'period',
|
|
232
|
+
'coverageStart',
|
|
233
|
+
'partial',
|
|
234
|
+
'truncated',
|
|
235
|
+
'rows',
|
|
236
|
+
'buckets',
|
|
237
|
+
'totals',
|
|
238
|
+
'models',
|
|
239
|
+
'pricing',
|
|
240
|
+
],
|
|
241
|
+
additionalProperties: false,
|
|
242
|
+
} as const
|
|
243
|
+
|
|
244
|
+
const usageHistoryUnavailableSchema = {
|
|
245
|
+
type: 'object',
|
|
246
|
+
properties: {
|
|
247
|
+
status: { const: 'unavailable' },
|
|
248
|
+
reason: { type: 'string', enum: ['invalid_period', 'history_unavailable', 'history_timeout'] },
|
|
249
|
+
},
|
|
250
|
+
required: ['status', 'reason'],
|
|
251
|
+
additionalProperties: false,
|
|
252
|
+
} as const
|
|
253
|
+
|
|
254
|
+
const activeContextCostInputSchema = {
|
|
255
|
+
type: 'object',
|
|
256
|
+
properties: {
|
|
257
|
+
providerID: { type: ['string', 'null'], minLength: 1, maxLength: 128 },
|
|
258
|
+
modelID: { type: ['string', 'null'], minLength: 1, maxLength: 128 },
|
|
259
|
+
contextTokens: { type: ['number', 'null'] },
|
|
260
|
+
},
|
|
261
|
+
required: ['providerID', 'modelID', 'contextTokens'],
|
|
262
|
+
additionalProperties: false,
|
|
263
|
+
} as const
|
|
264
|
+
|
|
265
|
+
const activeContextCostSchema = {
|
|
266
|
+
oneOf: [
|
|
267
|
+
{
|
|
268
|
+
type: 'object',
|
|
269
|
+
properties: {
|
|
270
|
+
status: { const: 'estimated' },
|
|
271
|
+
estimatedUsd: { type: 'number', minimum: 0 },
|
|
272
|
+
billed: { const: false },
|
|
273
|
+
basis: { const: 'pre-cache-context-tokens-times-input-price' },
|
|
274
|
+
cacheDiscountApplied: { const: false },
|
|
275
|
+
},
|
|
276
|
+
required: ['status', 'estimatedUsd', 'billed', 'basis', 'cacheDiscountApplied'],
|
|
277
|
+
additionalProperties: false,
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
type: 'object',
|
|
281
|
+
properties: {
|
|
282
|
+
status: { const: 'unavailable' },
|
|
283
|
+
billed: { const: false },
|
|
284
|
+
basis: { const: 'pre-cache-context-tokens-times-input-price' },
|
|
285
|
+
cacheDiscountApplied: { const: false },
|
|
286
|
+
reason: {
|
|
287
|
+
type: 'string',
|
|
288
|
+
enum: [
|
|
289
|
+
'invalid-context-token-count',
|
|
290
|
+
'missing-model-identity',
|
|
291
|
+
'no-pricing',
|
|
292
|
+
'unknown-model',
|
|
293
|
+
'ambiguous-model',
|
|
294
|
+
'missing-cache-price',
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
required: ['status', 'billed', 'basis', 'cacheDiscountApplied', 'reason'],
|
|
299
|
+
additionalProperties: false,
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
} as const
|
|
303
|
+
|
|
155
304
|
/** Shared definition keeps the TUI RPC client aligned with the server contract. */
|
|
156
305
|
export const quotaRpc = Rpc.define({
|
|
157
306
|
id: 'pantheon.quota',
|
|
@@ -200,6 +349,21 @@ export const quotaRpc = Rpc.define({
|
|
|
200
349
|
additionalProperties: false,
|
|
201
350
|
},
|
|
202
351
|
},
|
|
352
|
+
usage_history: {
|
|
353
|
+
input: {
|
|
354
|
+
type: 'object',
|
|
355
|
+
properties: { period: { type: 'string', enum: USAGE_HISTORY_PERIODS } },
|
|
356
|
+
required: ['period'],
|
|
357
|
+
additionalProperties: false,
|
|
358
|
+
},
|
|
359
|
+
output: {
|
|
360
|
+
oneOf: [usageHistoryAvailableSchema, usageHistoryUnavailableSchema],
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
active_context_cost: {
|
|
364
|
+
input: activeContextCostInputSchema,
|
|
365
|
+
output: activeContextCostSchema,
|
|
366
|
+
},
|
|
203
367
|
},
|
|
204
368
|
events: {
|
|
205
369
|
credentials_changed: {
|
|
@@ -622,7 +622,7 @@ export function quotaSnapshotStatusLabel(
|
|
|
622
622
|
case 'ready':
|
|
623
623
|
return 'Quota disponível'
|
|
624
624
|
case 'partial':
|
|
625
|
-
return '
|
|
625
|
+
return 'Quota parcialmente disponível'
|
|
626
626
|
case 'connected_unavailable':
|
|
627
627
|
return 'Credencial local · dados indisponíveis'
|
|
628
628
|
case 'needs_setup':
|
|
@@ -765,7 +765,7 @@ export function quotaProgress(
|
|
|
765
765
|
return { usedPercent, remainingPercent: 100 - usedPercent }
|
|
766
766
|
}
|
|
767
767
|
|
|
768
|
-
/** Connected-provider rows for the compact sidebar; only reported quota windows
|
|
768
|
+
/** Connected-provider rows for the compact sidebar; only reported quota windows are shown. */
|
|
769
769
|
export function quotaSidebarEntries(snapshot: QuotaSnapshot): QuotaSidebarEntry[] {
|
|
770
770
|
const entries: QuotaSidebarEntry[] = []
|
|
771
771
|
for (const provider of snapshot.providers) {
|