pantheon-opencode 1.6.2-beta.8 → 1.6.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 +121 -3
- package/README.md +34 -60
- package/README.pt-BR.md +10 -12
- package/bin/pantheon-init.mjs +30 -32
- package/package.json +3 -3
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/decision-router.mjs +41 -56
- package/scripts/install/decision-router-config.mjs +67 -1
- package/scripts/install/npx-cache-sweep.mjs +103 -0
- package/scripts/install/opencode.mjs +7 -7
- package/scripts/install/plugin.mjs +4 -3
- package/scripts/install/strings.mjs +4 -0
- package/scripts/release-gates.mjs +6 -82
- package/scripts/sync-tui.mjs +3 -3
- package/src/agents/aphrodite.md +1 -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 +1 -1
- 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 +1 -1
- package/src/agents/themis.md +1 -1
- package/src/agents/zeus.md +5 -2
- package/src/pantheon/jev-decision-tool.ts +366 -114
- package/src/pantheon/jev-decisions.ts +11 -13
- package/src/pantheon/jev-escalation.ts +639 -0
- package/src/pantheon/jev-quality-score.ts +432 -0
- package/src/pantheon/jev-risk-gate.ts +479 -0
- package/src/pantheon/local-decision-prompt.ts +12 -18
- package/src/pantheon/v2-decision-telemetry.ts +14 -4
- package/src/pantheon/v2-native-decisions.ts +1 -1
- package/src/plugin-v2.ts +201 -24
- 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 -789
- package/src/plugins/tui/dist/server-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui-v2.d.ts +12 -331
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +257 -5370
- 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 +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/plugins/tui/src/index-v2.tsx +213 -86
- package/src/plugins/tui/src/server-v2.ts +18 -982
- package/src/plugins/tui/tsconfig.typecheck.json +1 -6
- package/src/plugins/tui/tsdown.config.ts +1 -11
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +0 -749
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +0 -1
- 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-DMmXBhBe.js +0 -684
- package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +0 -1
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +0 -118
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +0 -1
- package/src/plugins/tui/dist/usage-history-worker.js +0 -25
- package/src/plugins/tui/dist/usage-history-worker.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 -373
- package/src/plugins/tui/src/quota-v2-model.ts +0 -1032
- package/src/plugins/tui/src/quota-v2.tsx +0 -1238
- package/src/plugins/tui/src/usage-history-contract.ts +0 -217
- package/src/plugins/tui/src/usage-history-validation.ts +0 -104
- package/src/plugins/tui/src/usage-history-view.tsx +0 -236
- package/src/plugins/tui/src/usage-history-worker.ts +0 -25
- package/src/plugins/tui/src/usage-view-model.ts +0 -272
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { cellWidth } from './sidebar-width'
|
|
2
|
-
import type {
|
|
3
|
-
UsageHistoryRpcAvailable,
|
|
4
|
-
UsageHistoryRpcPeriod,
|
|
5
|
-
UsageHistoryRpcResult,
|
|
6
|
-
} from './usage-history-contract'
|
|
7
|
-
|
|
8
|
-
export type ActiveContextCostResult =
|
|
9
|
-
| {
|
|
10
|
-
status: 'estimated'
|
|
11
|
-
estimatedUsd: number
|
|
12
|
-
billed: false
|
|
13
|
-
basis: 'pre-cache-context-tokens-times-input-price'
|
|
14
|
-
cacheDiscountApplied: false
|
|
15
|
-
}
|
|
16
|
-
| {
|
|
17
|
-
status: 'unavailable'
|
|
18
|
-
billed: false
|
|
19
|
-
basis: 'pre-cache-context-tokens-times-input-price'
|
|
20
|
-
cacheDiscountApplied: false
|
|
21
|
-
reason:
|
|
22
|
-
| 'invalid-context-token-count'
|
|
23
|
-
| 'missing-model-identity'
|
|
24
|
-
| 'no-pricing'
|
|
25
|
-
| 'unknown-model'
|
|
26
|
-
| 'ambiguous-model'
|
|
27
|
-
| 'missing-cache-price'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const HISTORY_PERIODS: readonly UsageHistoryRpcPeriod[] = ['7d', '15d', '30d', 'total']
|
|
31
|
-
export const USAGE_HISTORY_PERIOD_BINDINGS = [
|
|
32
|
-
{ period: '7d', bind: '7', label: '7d' },
|
|
33
|
-
{ period: '15d', bind: '1', label: '15d' },
|
|
34
|
-
{ period: '30d', bind: '3', label: '30d' },
|
|
35
|
-
{ period: 'total', bind: 't', label: 'total' },
|
|
36
|
-
] as const satisfies readonly {
|
|
37
|
-
period: UsageHistoryRpcPeriod
|
|
38
|
-
bind: string
|
|
39
|
-
label: string
|
|
40
|
-
}[]
|
|
41
|
-
|
|
42
|
-
function wrapText(value: string, width: number): string[] {
|
|
43
|
-
const maxWidth = Number.isFinite(width) ? Math.max(1, Math.floor(width)) : 1
|
|
44
|
-
const lines: string[] = []
|
|
45
|
-
const segmenter = new Intl.Segmenter()
|
|
46
|
-
let line = ''
|
|
47
|
-
|
|
48
|
-
for (const word of value.trim().split(/\s+/)) {
|
|
49
|
-
if (!word) continue
|
|
50
|
-
if (line && cellWidth(line) + 1 + cellWidth(word) > maxWidth) {
|
|
51
|
-
lines.push(line)
|
|
52
|
-
line = ''
|
|
53
|
-
}
|
|
54
|
-
if (line) line += ' '
|
|
55
|
-
for (const { segment } of segmenter.segment(word)) {
|
|
56
|
-
if (cellWidth(line) + cellWidth(segment) > maxWidth) {
|
|
57
|
-
if (line) lines.push(line)
|
|
58
|
-
line = ''
|
|
59
|
-
}
|
|
60
|
-
line += segment
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (line) lines.push(line)
|
|
65
|
-
return lines
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function usageHistoryTextLines(value: string, width: number): string[] {
|
|
69
|
-
return wrapText(value, width)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function formatCount(value: number): string {
|
|
73
|
-
return Math.max(0, value).toLocaleString('en-US')
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function formatUsd(value: number): string | undefined {
|
|
77
|
-
if (!Number.isFinite(value) || value < 0) return undefined
|
|
78
|
-
return `$${new Intl.NumberFormat('en-US', {
|
|
79
|
-
minimumFractionDigits: 2,
|
|
80
|
-
maximumFractionDigits: 8,
|
|
81
|
-
}).format(value)}`
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function chartBar(value: number, maxValue: number, width: number): string {
|
|
85
|
-
const cells = Math.max(0, Math.floor(width))
|
|
86
|
-
if (cells === 0 || value <= 0 || maxValue <= 0) return ''
|
|
87
|
-
return '#'.repeat(Math.max(1, Math.min(cells, Math.round((value / maxValue) * cells))))
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function chartValueLine(value: number, maximum: number, width: number): string {
|
|
91
|
-
const count = `${formatCount(value)} tokens`
|
|
92
|
-
const barWidth = Math.max(0, width - cellWidth(count) - 3)
|
|
93
|
-
const bar = chartBar(value, maximum, Math.min(12, barWidth))
|
|
94
|
-
const line = ` ${bar ? `${bar} ` : ''}${count}`
|
|
95
|
-
return wrapText(line, width).join('\n')
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function appendWrapped(target: string[], value: string, width: number): void {
|
|
99
|
-
target.push(...wrapText(value, width))
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function usageHistorySelectorLabel(selected: UsageHistoryRpcPeriod): string {
|
|
103
|
-
return `Período: ${HISTORY_PERIODS.map((period) => {
|
|
104
|
-
const label = period === 'total' ? 'Total' : period
|
|
105
|
-
return period === selected ? `[${label}]` : label
|
|
106
|
-
}).join(' · ')}`
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function usageHistorySelectorLines(
|
|
110
|
-
selected: UsageHistoryRpcPeriod,
|
|
111
|
-
width: number,
|
|
112
|
-
): string[] {
|
|
113
|
-
return wrapText(usageHistorySelectorLabel(selected), width)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function usageHistoryPeriodForKey(key: string): UsageHistoryRpcPeriod | undefined {
|
|
117
|
-
return USAGE_HISTORY_PERIOD_BINDINGS.find((binding) => binding.bind === key)?.period
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function usageHistoryControlsLines(width: number): string[] {
|
|
121
|
-
return wrapText('7 · 7d 1 · 15d 3 · 30d T · total', width)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function usageHistoryCoverageLabel(result: UsageHistoryRpcAvailable): string {
|
|
125
|
-
return result.coverageStart === null
|
|
126
|
-
? 'Início da cobertura indisponível'
|
|
127
|
-
: `Cobertura desde ${result.coverageStart}`
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function usageHistoryPartialWarning(result: UsageHistoryRpcAvailable): string | null {
|
|
131
|
-
if (result.partial && result.truncated) return 'Histórico parcial e truncado pelo limite seguro.'
|
|
132
|
-
if (result.partial) return 'Histórico parcial segundo a consulta.'
|
|
133
|
-
if (result.truncated) return 'Histórico truncado pelo limite seguro.'
|
|
134
|
-
return null
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function usageHistoryPricingLabel(result: UsageHistoryRpcAvailable): string {
|
|
138
|
-
const amount =
|
|
139
|
-
result.pricing.estimatedUsd === undefined ? undefined : formatUsd(result.pricing.estimatedUsd)
|
|
140
|
-
const value = amount ? ` · ${amount}` : ''
|
|
141
|
-
switch (result.pricing.status) {
|
|
142
|
-
case 'complete':
|
|
143
|
-
return `Estimativa pelo catálogo${value} · não cobrada`
|
|
144
|
-
case 'partial':
|
|
145
|
-
return `Estimativa parcial pelo catálogo${value} · não cobrada · ${result.pricing.unpricedModels} modelo(s) sem preço`
|
|
146
|
-
case 'unavailable':
|
|
147
|
-
return 'Estimativa de preço indisponível · nenhum valor cobrado'
|
|
148
|
-
case 'empty':
|
|
149
|
-
return 'Sem dados de preço para estimar · nenhum valor cobrado'
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function usageHistoryUnavailableMessage(result: UsageHistoryRpcResult): string | null {
|
|
154
|
-
if (result.status !== 'unavailable') return null
|
|
155
|
-
switch (result.reason) {
|
|
156
|
-
case 'invalid_period':
|
|
157
|
-
return 'Período de histórico inválido.'
|
|
158
|
-
case 'history_timeout':
|
|
159
|
-
return 'Consulta de histórico excedeu o tempo limite.'
|
|
160
|
-
case 'history_unavailable':
|
|
161
|
-
return 'Histórico indisponível neste momento.'
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function usageHistoryEmptyMessage(): string {
|
|
166
|
-
return 'Sem histórico neste período.'
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function usageHistoryChartLines(result: UsageHistoryRpcAvailable, width: number): string[] {
|
|
170
|
-
const maxWidth = Math.max(1, Math.floor(width))
|
|
171
|
-
if (result.rows === 0 && result.buckets.length === 0 && result.models.length === 0) {
|
|
172
|
-
return wrapText(usageHistoryEmptyMessage(), maxWidth)
|
|
173
|
-
}
|
|
174
|
-
const lines: string[] = []
|
|
175
|
-
appendWrapped(lines, `GERAL · ${formatCount(result.totals.total)} tokens`, maxWidth)
|
|
176
|
-
|
|
177
|
-
if (result.buckets.length > 0) {
|
|
178
|
-
lines.push('Uso diário')
|
|
179
|
-
const maxBucket = Math.max(0, ...result.buckets.map((bucket) => bucket.total))
|
|
180
|
-
for (const bucket of result.buckets) {
|
|
181
|
-
appendWrapped(lines, bucket.date, maxWidth)
|
|
182
|
-
lines.push(...chartValueLine(bucket.total, maxBucket, maxWidth).split('\n'))
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
lines.push('Sem buckets diários neste período.')
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
lines.push('Modelos no período')
|
|
189
|
-
if (result.models.length === 0) {
|
|
190
|
-
lines.push('Sem totais por modelo.')
|
|
191
|
-
return lines.flatMap((line) => wrapText(line, maxWidth))
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const maxModel = Math.max(0, ...result.models.map((model) => model.totals.total))
|
|
195
|
-
for (const model of result.models) {
|
|
196
|
-
appendWrapped(lines, `${model.providerID}/${model.modelID}`, maxWidth)
|
|
197
|
-
lines.push(...chartValueLine(model.totals.total, maxModel, maxWidth).split('\n'))
|
|
198
|
-
}
|
|
199
|
-
return lines.flatMap((line) => wrapText(line, maxWidth))
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function activeModelIdentity(model: {
|
|
203
|
-
providerID: string | null
|
|
204
|
-
modelID: string | null
|
|
205
|
-
label: string
|
|
206
|
-
}): string {
|
|
207
|
-
if (model.providerID && model.modelID) return `${model.providerID}/${model.modelID}`
|
|
208
|
-
if (model.modelID) return model.modelID
|
|
209
|
-
return model.label || 'identidade indisponível'
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export function sessionSpendLabel(cost: number): string | null {
|
|
213
|
-
if (!Number.isFinite(cost) || cost < 0) return null
|
|
214
|
-
return `Gasto da sessão (relatado) · $${cost.toFixed(2)}`
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function unavailableContextReason(
|
|
218
|
-
reason: Extract<ActiveContextCostResult, { status: 'unavailable' }>['reason'],
|
|
219
|
-
): string {
|
|
220
|
-
switch (reason) {
|
|
221
|
-
case 'invalid-context-token-count':
|
|
222
|
-
return 'contagem de tokens de contexto inválida'
|
|
223
|
-
case 'missing-model-identity':
|
|
224
|
-
return 'identidade do modelo indisponível'
|
|
225
|
-
case 'no-pricing':
|
|
226
|
-
case 'missing-cache-price':
|
|
227
|
-
return 'preço de entrada indisponível'
|
|
228
|
-
case 'unknown-model':
|
|
229
|
-
case 'ambiguous-model':
|
|
230
|
-
return 'modelo não identificado na tabela de preços'
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export function activeContextEstimateLines(
|
|
235
|
-
result: ActiveContextCostResult,
|
|
236
|
-
width: number,
|
|
237
|
-
): string[] {
|
|
238
|
-
const maxWidth = Math.max(1, Math.floor(width))
|
|
239
|
-
if (result.status === 'unavailable') {
|
|
240
|
-
return wrapText(
|
|
241
|
-
`Estimativa de contexto (pré-cache) indisponível · ${unavailableContextReason(result.reason)}`,
|
|
242
|
-
maxWidth,
|
|
243
|
-
)
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const amount = formatUsd(result.estimatedUsd)
|
|
247
|
-
if (!amount) {
|
|
248
|
-
return wrapText('Estimativa de contexto (pré-cache) indisponível · valor inválido', maxWidth)
|
|
249
|
-
}
|
|
250
|
-
return [
|
|
251
|
-
...wrapText(`Estimativa de contexto (pré-cache) · ${amount}`, maxWidth),
|
|
252
|
-
...wrapText(
|
|
253
|
-
'Preço de entrada × tokens pré-cache; sem desconto de cache; não é valor cobrado.',
|
|
254
|
-
maxWidth,
|
|
255
|
-
),
|
|
256
|
-
]
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export function activeContextEstimatePendingLines(width: number): string[] {
|
|
260
|
-
return wrapText('Estimativa de contexto (pré-cache) · calculando…', width)
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export function activeContextEstimateMissingLines(width: number): string[] {
|
|
264
|
-
return wrapText(
|
|
265
|
-
'Estimativa de contexto (pré-cache) indisponível · contexto não reportado.',
|
|
266
|
-
width,
|
|
267
|
-
)
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export function activeContextEstimateErrorLines(width: number): string[] {
|
|
271
|
-
return wrapText('Estimativa de contexto (pré-cache) indisponível · falha na consulta.', width)
|
|
272
|
-
}
|