pantheon-opencode 1.6.2-beta.9 → 1.6.3-beta.1

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +34 -60
  3. package/README.pt-BR.md +10 -12
  4. package/bin/pantheon-init.mjs +23 -33
  5. package/package.json +3 -3
  6. package/plugin.json +1 -1
  7. package/pyproject.toml +1 -1
  8. package/scripts/decision-router-budget.mjs +4 -1
  9. package/scripts/decision-router-v2-egress.mjs +11 -2
  10. package/scripts/decision-router.mjs +64 -56
  11. package/scripts/install/decision-router-config.mjs +110 -1
  12. package/scripts/install/npx-cache-sweep.mjs +103 -0
  13. package/scripts/install/opencode.mjs +7 -7
  14. package/scripts/install/plugin.mjs +4 -3
  15. package/scripts/install/strings.mjs +4 -0
  16. package/scripts/release-gates.mjs +6 -82
  17. package/scripts/secret-scan.mjs +1 -1
  18. package/scripts/sync-tui.mjs +3 -3
  19. package/src/agents/zeus.md +4 -2
  20. package/src/pantheon/jev-decision-tool.ts +455 -117
  21. package/src/pantheon/jev-decisions.ts +72 -25
  22. package/src/pantheon/jev-escalation.ts +639 -0
  23. package/src/pantheon/jev-quality-score.ts +432 -0
  24. package/src/pantheon/jev-risk-gate.ts +479 -0
  25. package/src/pantheon/local-decision-budget.ts +11 -1
  26. package/src/pantheon/local-decision-prompt.ts +12 -18
  27. package/src/pantheon/local-decision-provider-matrix.ts +3 -0
  28. package/src/pantheon/v2-decision-telemetry.ts +14 -4
  29. package/src/pantheon/v2-native-decisions.ts +1 -1
  30. package/src/plugin-v2.ts +204 -24
  31. package/src/plugins/tui/dist/server-v2.d.ts +19 -11
  32. package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
  33. package/src/plugins/tui/dist/server-v2.js +19 -789
  34. package/src/plugins/tui/dist/server-v2.js.map +1 -1
  35. package/src/plugins/tui/dist/tui-v2.d.ts +12 -331
  36. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  37. package/src/plugins/tui/dist/tui-v2.js +257 -5370
  38. package/src/plugins/tui/dist/tui-v2.js.map +1 -1
  39. package/src/plugins/tui/dist/tui.js +1 -1
  40. package/src/plugins/tui/package-lock.json +2 -2
  41. package/src/plugins/tui/package.json +1 -1
  42. package/src/plugins/tui/src/index-v2.tsx +213 -86
  43. package/src/plugins/tui/src/server-v2.ts +18 -982
  44. package/src/plugins/tui/tsconfig.typecheck.json +1 -6
  45. package/src/plugins/tui/tsdown.config.ts +1 -11
  46. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +0 -749
  47. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +0 -1
  48. package/src/plugins/tui/dist/quota-adapters.d.ts +0 -89
  49. package/src/plugins/tui/dist/quota-adapters.d.ts.map +0 -1
  50. package/src/plugins/tui/dist/quota-adapters.js +0 -1142
  51. package/src/plugins/tui/dist/quota-adapters.js.map +0 -1
  52. package/src/plugins/tui/dist/quota-cli.d.ts +0 -17
  53. package/src/plugins/tui/dist/quota-cli.d.ts.map +0 -1
  54. package/src/plugins/tui/dist/quota-cli.js +0 -184
  55. package/src/plugins/tui/dist/quota-cli.js.map +0 -1
  56. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js +0 -684
  57. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +0 -1
  58. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +0 -118
  59. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +0 -1
  60. package/src/plugins/tui/dist/usage-history-worker.js +0 -25
  61. package/src/plugins/tui/dist/usage-history-worker.js.map +0 -1
  62. package/src/plugins/tui/src/go-key-diagnostic-ui.ts +0 -100
  63. package/src/plugins/tui/src/go-key-diagnostic.ts +0 -125
  64. package/src/plugins/tui/src/quota-adapters.ts +0 -1598
  65. package/src/plugins/tui/src/quota-cli.ts +0 -237
  66. package/src/plugins/tui/src/quota-rpc.ts +0 -373
  67. package/src/plugins/tui/src/quota-v2-model.ts +0 -1032
  68. package/src/plugins/tui/src/quota-v2.tsx +0 -1238
  69. package/src/plugins/tui/src/usage-history-contract.ts +0 -217
  70. package/src/plugins/tui/src/usage-history-validation.ts +0 -104
  71. package/src/plugins/tui/src/usage-history-view.tsx +0 -236
  72. package/src/plugins/tui/src/usage-history-worker.ts +0 -25
  73. 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
- }