pantheon-opencode 1.6.2-beta.9 → 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 +101 -0
- package/README.md +34 -60
- package/README.pt-BR.md +10 -12
- package/bin/pantheon-init.mjs +22 -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/zeus.md +4 -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,1238 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @opentui/solid */
|
|
2
|
-
// biome-ignore-all lint/a11y/noStaticElementInteractions: OpenTUI has no DOM roles; mouse controls have keyboard equivalents.
|
|
3
|
-
|
|
4
|
-
import type { Context, KeymapCommand, KeymapLayer, PanelInput } from '@opencode/plugin/tui/context'
|
|
5
|
-
import { icon } from '@profullstack/hqtui'
|
|
6
|
-
import { createMemo, createSignal, For, type JSX, onCleanup, onMount, Show } from 'solid-js'
|
|
7
|
-
import {
|
|
8
|
-
contextBar,
|
|
9
|
-
contextUsageTone,
|
|
10
|
-
formatContextWindow,
|
|
11
|
-
formatTokenCount,
|
|
12
|
-
} from './context-gauge'
|
|
13
|
-
import { quotaGoCheckCommand } from './go-key-diagnostic-ui'
|
|
14
|
-
import { MODEL_USAGE_MESSAGE_LIMIT, MODEL_USAGE_SESSION_LIMIT } from './model-usage-limits'
|
|
15
|
-
import {
|
|
16
|
-
collectRecentModelUsageRows,
|
|
17
|
-
compactQuotaMetric,
|
|
18
|
-
formatQuotaCountdown,
|
|
19
|
-
type QuotaMetric,
|
|
20
|
-
type QuotaProviderDetail,
|
|
21
|
-
type QuotaRuntime,
|
|
22
|
-
type QuotaSidebarEntry,
|
|
23
|
-
type QuotaSnapshot,
|
|
24
|
-
quotaClock,
|
|
25
|
-
quotaProgress,
|
|
26
|
-
quotaSidebarEntries,
|
|
27
|
-
quotaSnapshotStatusLabel,
|
|
28
|
-
type RecentModelUsageRow,
|
|
29
|
-
resolveActiveModelRef,
|
|
30
|
-
} from './quota-v2-model'
|
|
31
|
-
import { cellWidth, SIDEBAR_CONTENT_WIDTH } from './sidebar-width'
|
|
32
|
-
import { ActiveContextEstimate, UsageHistorySection } from './usage-history-view'
|
|
33
|
-
import { activeModelIdentity, sessionSpendLabel } from './usage-view-model'
|
|
34
|
-
|
|
35
|
-
export const QUOTA_PANEL_NAME = 'pantheon.quota'
|
|
36
|
-
export const QUOTA_OPEN_COMMAND_ID = 'pantheon.quota.open'
|
|
37
|
-
export type QuotaIconMode = 'nerd' | 'unicode' | 'ascii'
|
|
38
|
-
export type QuotaIconName =
|
|
39
|
-
| 'check'
|
|
40
|
-
| 'close'
|
|
41
|
-
| 'clock'
|
|
42
|
-
| 'gauge'
|
|
43
|
-
| 'plug'
|
|
44
|
-
| 'refresh'
|
|
45
|
-
| 'settings'
|
|
46
|
-
| 'sliders'
|
|
47
|
-
| 'warning'
|
|
48
|
-
|
|
49
|
-
export function quotaIcon(name: QuotaIconName, mode?: QuotaIconMode): string {
|
|
50
|
-
return icon(name, mode ? { mode } : undefined)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function iconInSlot(name: QuotaIconName, width: number, mode?: QuotaIconMode): string {
|
|
54
|
-
const glyph = quotaIcon(name, mode)
|
|
55
|
-
return `${glyph}${' '.repeat(Math.max(0, width - cellWidth(glyph)))}`
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const QUOTA_ICON = quotaIcon('refresh')
|
|
59
|
-
const QUOTA_PANEL_TOAST = 'Abra uma sessão para ver os detalhes da quota.'
|
|
60
|
-
|
|
61
|
-
type QuotaSurfaceProps = { context: Context; runtime: QuotaRuntime }
|
|
62
|
-
|
|
63
|
-
const MODEL_USAGE_REFRESH_EVENTS = [
|
|
64
|
-
'session.created',
|
|
65
|
-
'session.renamed',
|
|
66
|
-
'session.metadata.updated',
|
|
67
|
-
'session.moved',
|
|
68
|
-
'session.idle',
|
|
69
|
-
'session.status',
|
|
70
|
-
'session.deleted',
|
|
71
|
-
] as const satisfies readonly Parameters<Context['data']['on']>[0][]
|
|
72
|
-
|
|
73
|
-
function base(context: Context) {
|
|
74
|
-
return context.theme.text?.base ?? (context.themeMode === 'dark' ? '#ffffff' : '#111111')
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function muted(context: Context) {
|
|
78
|
-
return context.theme.text?.muted ?? base(context)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function quotaUsageTone(usedPercent: number): 'success' | 'warning' | 'error' {
|
|
82
|
-
return usedPercent > 85 ? 'error' : usedPercent >= 60 ? 'warning' : 'success'
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function quotaColor(context: Context, usedPercent: number | undefined): string {
|
|
86
|
-
return usedPercent === undefined ? base(context) : tone(context, quotaUsageTone(usedPercent))
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
type QuotaTone = 'info' | 'success' | 'warning' | 'error'
|
|
90
|
-
|
|
91
|
-
function tone(context: Context, color: QuotaTone): string {
|
|
92
|
-
return context.theme.text?.feedback?.[color]?.base ?? base(context)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function snapshotSummary(snapshot: QuotaSnapshot, display: 'used' | 'remaining'): string {
|
|
96
|
-
if (snapshot.status === 'loading') return 'carregando status'
|
|
97
|
-
if (snapshot.status !== 'ready' && snapshot.status !== 'partial') {
|
|
98
|
-
// Reuse the sidebar label map (fault-aware for `unavailable`) so the footer
|
|
99
|
-
// never contradicts the sidebar; lowercase matches the footer style.
|
|
100
|
-
return quotaSnapshotStatusLabel(snapshot.status, snapshot.error).toLowerCase()
|
|
101
|
-
}
|
|
102
|
-
const metrics = snapshot.providers.flatMap((provider) => provider.metrics)
|
|
103
|
-
const metric = metrics.find((item) => item.kind !== 'provider_status') ?? metrics[0]
|
|
104
|
-
if (metric) {
|
|
105
|
-
const value = compactQuotaMetric(metric, display) ?? 'quota indisponível'
|
|
106
|
-
return snapshot.status === 'partial' ? `quota parcialmente disponível · ${value}` : value
|
|
107
|
-
}
|
|
108
|
-
if (snapshot.status === 'partial') return 'quota parcialmente disponível'
|
|
109
|
-
if (snapshot.providers[0]?.message) return snapshot.providers[0].message
|
|
110
|
-
return 'quota indisponível'
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
type FinanceMetric = Extract<QuotaMetric, { kind: 'balance' | 'estimate' | 'key_usage' }>
|
|
114
|
-
type FinanceEntry = { providerID: string; metric: FinanceMetric }
|
|
115
|
-
|
|
116
|
-
export function sidebarFinanceEntries(snapshot: QuotaSnapshot): FinanceEntry[] {
|
|
117
|
-
return snapshot.providers.flatMap((provider) =>
|
|
118
|
-
provider.metrics.flatMap((metric) =>
|
|
119
|
-
(metric.kind === 'balance' || metric.kind === 'estimate' || metric.kind === 'key_usage') &&
|
|
120
|
-
metricRow(metric)
|
|
121
|
-
? [{ providerID: provider.id, metric }]
|
|
122
|
-
: [],
|
|
123
|
-
),
|
|
124
|
-
)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function QuotaSidebarEntryRow(props: {
|
|
128
|
-
entry: QuotaSidebarEntry
|
|
129
|
-
display: 'used' | 'remaining'
|
|
130
|
-
context: Context
|
|
131
|
-
now: number
|
|
132
|
-
}): JSX.Element {
|
|
133
|
-
return (
|
|
134
|
-
<Show
|
|
135
|
-
when={props.entry.kind === 'quota'}
|
|
136
|
-
fallback={
|
|
137
|
-
<For
|
|
138
|
-
each={
|
|
139
|
-
props.entry.kind === 'status'
|
|
140
|
-
? quotaTextLines(props.entry.message, SIDEBAR_CONTENT_WIDTH, 2)
|
|
141
|
-
: []
|
|
142
|
-
}
|
|
143
|
-
>
|
|
144
|
-
{(line) => <text fg={muted(props.context)}>{line}</text>}
|
|
145
|
-
</For>
|
|
146
|
-
}
|
|
147
|
-
>
|
|
148
|
-
<For
|
|
149
|
-
each={
|
|
150
|
-
props.entry.kind === 'quota'
|
|
151
|
-
? quotaWindowLines(
|
|
152
|
-
props.entry.metric,
|
|
153
|
-
props.display,
|
|
154
|
-
SIDEBAR_CONTENT_WIDTH,
|
|
155
|
-
props.now,
|
|
156
|
-
true,
|
|
157
|
-
)
|
|
158
|
-
: []
|
|
159
|
-
}
|
|
160
|
-
>
|
|
161
|
-
{(line) => (
|
|
162
|
-
<text
|
|
163
|
-
fg={quotaColor(
|
|
164
|
-
props.context,
|
|
165
|
-
props.entry.kind === 'quota' ? props.entry.progress.usedPercent : undefined,
|
|
166
|
-
)}
|
|
167
|
-
>
|
|
168
|
-
{line}
|
|
169
|
-
</text>
|
|
170
|
-
)}
|
|
171
|
-
</For>
|
|
172
|
-
</Show>
|
|
173
|
-
)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function QuotaSidebarSummary(props: QuotaSurfaceProps): JSX.Element {
|
|
177
|
-
const entries = createMemo(() => quotaSidebarEntries(props.runtime.snapshot()))
|
|
178
|
-
const finance = createMemo(() => sidebarFinanceEntries(props.runtime.snapshot()))
|
|
179
|
-
const [now, setNow] = createSignal(Date.now())
|
|
180
|
-
onMount(() => onCleanup(quotaClock.subscribe(setNow)))
|
|
181
|
-
return (
|
|
182
|
-
<Show when={props.runtime.preferences().enabled}>
|
|
183
|
-
<box flexDirection="column" marginTop={1}>
|
|
184
|
-
<text fg={base(props.context)}>{`${QUOTA_ICON} Pantheon quota`}</text>
|
|
185
|
-
<Show when={props.runtime.snapshot().status !== 'ready' || entries().length === 0}>
|
|
186
|
-
<text fg={muted(props.context)}>
|
|
187
|
-
{quotaSnapshotStatusLabel(
|
|
188
|
-
props.runtime.snapshot().status,
|
|
189
|
-
props.runtime.snapshot().error,
|
|
190
|
-
)}
|
|
191
|
-
</text>
|
|
192
|
-
</Show>
|
|
193
|
-
<For each={props.runtime.snapshot().providers}>
|
|
194
|
-
{(provider) => (
|
|
195
|
-
<box flexDirection="column">
|
|
196
|
-
<Show
|
|
197
|
-
when={
|
|
198
|
-
entries().some((entry) => entry.providerID === provider.id) ||
|
|
199
|
-
finance().some((entry) => entry.providerID === provider.id) ||
|
|
200
|
-
provider.metrics.some((metric) => metric.kind === 'provider_status')
|
|
201
|
-
}
|
|
202
|
-
>
|
|
203
|
-
<For each={quotaTextLines(provider.label, SIDEBAR_CONTENT_WIDTH, 0)}>
|
|
204
|
-
{(line) => <text fg={muted(props.context)}>{line}</text>}
|
|
205
|
-
</For>
|
|
206
|
-
</Show>
|
|
207
|
-
<For each={entries().filter((entry) => entry.providerID === provider.id)}>
|
|
208
|
-
{(entry) => (
|
|
209
|
-
<QuotaSidebarEntryRow
|
|
210
|
-
entry={entry}
|
|
211
|
-
display={props.runtime.preferences().display}
|
|
212
|
-
context={props.context}
|
|
213
|
-
now={now()}
|
|
214
|
-
/>
|
|
215
|
-
)}
|
|
216
|
-
</For>
|
|
217
|
-
<For each={provider.metrics.filter((metric) => metric.kind === 'provider_status')}>
|
|
218
|
-
{(metric) => (
|
|
219
|
-
<For each={quotaMetricLines(metric, SIDEBAR_CONTENT_WIDTH)}>
|
|
220
|
-
{(line) => <text fg={muted(props.context)}>{line}</text>}
|
|
221
|
-
</For>
|
|
222
|
-
)}
|
|
223
|
-
</For>
|
|
224
|
-
<For each={finance().filter((entry) => entry.providerID === provider.id)}>
|
|
225
|
-
{(entry) => (
|
|
226
|
-
<For each={financeMetricLines(entry.metric, SIDEBAR_CONTENT_WIDTH)}>
|
|
227
|
-
{(line) => <text fg={base(props.context)}>{line}</text>}
|
|
228
|
-
</For>
|
|
229
|
-
)}
|
|
230
|
-
</For>
|
|
231
|
-
</box>
|
|
232
|
-
)}
|
|
233
|
-
</For>
|
|
234
|
-
</box>
|
|
235
|
-
</Show>
|
|
236
|
-
)
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function QuotaFooterSummary(props: QuotaSurfaceProps) {
|
|
240
|
-
const preferences = () => props.runtime.preferences()
|
|
241
|
-
return (
|
|
242
|
-
<Show when={preferences().enabled}>
|
|
243
|
-
<text fg={muted(props.context)}>
|
|
244
|
-
{`Quota · ${snapshotSummary(props.runtime.snapshot(), preferences().display)}`}
|
|
245
|
-
</text>
|
|
246
|
-
</Show>
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function clipped(value: string, width: number): string {
|
|
251
|
-
const max = Math.max(5, Math.floor(width) - 2)
|
|
252
|
-
return value.length <= max ? value : `${value.slice(0, max - 1)}…`
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
type QuotaWindowMetric = Extract<QuotaMetric, { kind: 'provider_quota' }>
|
|
256
|
-
|
|
257
|
-
function quotaAmount(value: number, unit: string): string | undefined {
|
|
258
|
-
const safeUnit = unit.trim()
|
|
259
|
-
if (!Number.isFinite(value) || !safeUnit) return undefined
|
|
260
|
-
return `${new Intl.NumberFormat('en-US', { maximumFractionDigits: 2 }).format(value)} ${safeUnit}`
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function quotaResetDate(resetsAt: number | undefined, now: number): string | undefined {
|
|
264
|
-
if (resetsAt === undefined || !Number.isFinite(resetsAt) || !Number.isFinite(now))
|
|
265
|
-
return undefined
|
|
266
|
-
const date = new Date(resetsAt)
|
|
267
|
-
if (!Number.isFinite(date.getTime()) || resetsAt <= now) return undefined
|
|
268
|
-
return `Resets on ${date.toISOString().slice(0, 16).replace('T', ' ')} UTC`
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/** Wrap on grapheme boundaries, measuring terminal cells rather than code units. */
|
|
272
|
-
export function quotaTextLines(text: string, width: number, indent: number): string[] {
|
|
273
|
-
const max = Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 0
|
|
274
|
-
if (max < 1) return []
|
|
275
|
-
const padding = ' '.repeat(Math.min(Math.max(0, indent), Math.max(0, max - 2)))
|
|
276
|
-
const lines: string[] = []
|
|
277
|
-
let line = padding
|
|
278
|
-
const segmenter = new Intl.Segmenter()
|
|
279
|
-
for (const word of text.trim().split(/\s+/)) {
|
|
280
|
-
if (!word) continue
|
|
281
|
-
if (line.trim() && cellWidth(line) + 1 + cellWidth(word) > max) {
|
|
282
|
-
lines.push(line.trimEnd())
|
|
283
|
-
line = padding
|
|
284
|
-
}
|
|
285
|
-
if (line.trim()) line += ' '
|
|
286
|
-
for (const { segment } of segmenter.segment(word)) {
|
|
287
|
-
const glyphWidth = cellWidth(segment)
|
|
288
|
-
if (glyphWidth > max) continue
|
|
289
|
-
if (cellWidth(line) + glyphWidth > max) {
|
|
290
|
-
if (line.trim()) lines.push(line.trimEnd())
|
|
291
|
-
line = glyphWidth + cellWidth(padding) <= max ? padding : ''
|
|
292
|
-
}
|
|
293
|
-
line += segment
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
if (line.trim()) lines.push(line.trimEnd())
|
|
297
|
-
return lines
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/** Layout uses only a provider-reported reset; a local clock never refreshes data. */
|
|
301
|
-
export function quotaWindowLines(
|
|
302
|
-
metric: QuotaWindowMetric,
|
|
303
|
-
display: 'used' | 'remaining',
|
|
304
|
-
width: number,
|
|
305
|
-
now: number,
|
|
306
|
-
sidebarPercent = false,
|
|
307
|
-
): string[] {
|
|
308
|
-
const title = metric.period?.trim() || metric.label?.trim() || 'Quota'
|
|
309
|
-
const progress = quotaProgress(metric)
|
|
310
|
-
const amount =
|
|
311
|
-
sidebarPercent && progress
|
|
312
|
-
? `${display === 'remaining' ? progress.remainingPercent : progress.usedPercent}%`
|
|
313
|
-
: quotaAmount(display === 'remaining' ? metric.remaining : metric.used, metric.unit)
|
|
314
|
-
if (!amount) return []
|
|
315
|
-
const value = `${amount} ${display === 'remaining' ? 'rest.' : 'uso'}`
|
|
316
|
-
const countdown = formatQuotaCountdown(metric.resetsAt, now)
|
|
317
|
-
const reset =
|
|
318
|
-
countdown === null ? '(aguardando atualização)' : countdown ? `(${countdown})` : undefined
|
|
319
|
-
const resetDate =
|
|
320
|
-
countdown !== undefined && countdown !== null ? quotaResetDate(metric.resetsAt, now) : undefined
|
|
321
|
-
const resetDateLines = resetDate ? quotaTextLines(resetDate, width, 4) : []
|
|
322
|
-
const padded = ` ${title.padEnd(8)} ${value}`
|
|
323
|
-
const compact = ` ${title} ${value}`
|
|
324
|
-
const prefix = cellWidth(padded) <= width ? padded : compact
|
|
325
|
-
const suffix = reset ? ` ${reset}` : ''
|
|
326
|
-
const secondaryAmount = sidebarPercent
|
|
327
|
-
? undefined
|
|
328
|
-
: quotaAmount(display === 'remaining' ? metric.used : metric.remaining, metric.unit)
|
|
329
|
-
const secondary = secondaryAmount
|
|
330
|
-
? quotaTextLines(
|
|
331
|
-
`${display === 'remaining' ? 'Usado' : 'Restante'} ${secondaryAmount}`,
|
|
332
|
-
width,
|
|
333
|
-
4,
|
|
334
|
-
)
|
|
335
|
-
: []
|
|
336
|
-
if (!sidebarPercent && progress) {
|
|
337
|
-
secondary.push(...quotaTextLines(`${progress.remainingPercent}% restante`, width, 4))
|
|
338
|
-
}
|
|
339
|
-
if (cellWidth(prefix + suffix) <= width)
|
|
340
|
-
return [`${prefix}${suffix}`, ...resetDateLines, ...secondary]
|
|
341
|
-
if (cellWidth(prefix) <= width)
|
|
342
|
-
return reset
|
|
343
|
-
? [prefix, ...quotaTextLines(reset, width, 4), ...resetDateLines, ...secondary]
|
|
344
|
-
: [prefix, ...resetDateLines, ...secondary]
|
|
345
|
-
return [
|
|
346
|
-
...quotaTextLines(title, width, 2),
|
|
347
|
-
...quotaTextLines(value, width, 4),
|
|
348
|
-
...(reset ? quotaTextLines(reset, width, 4) : []),
|
|
349
|
-
...resetDateLines,
|
|
350
|
-
...secondary,
|
|
351
|
-
]
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
function QuotaWindow(props: {
|
|
355
|
-
metric: QuotaWindowMetric
|
|
356
|
-
display: 'used' | 'remaining'
|
|
357
|
-
width: number
|
|
358
|
-
context: Context
|
|
359
|
-
now: number
|
|
360
|
-
}): JSX.Element {
|
|
361
|
-
return (
|
|
362
|
-
<box flexDirection="column">
|
|
363
|
-
<For each={quotaWindowLines(props.metric, props.display, props.width, props.now)}>
|
|
364
|
-
{(line) => (
|
|
365
|
-
<text fg={quotaColor(props.context, quotaProgress(props.metric)?.usedPercent)}>
|
|
366
|
-
{line}
|
|
367
|
-
</text>
|
|
368
|
-
)}
|
|
369
|
-
</For>
|
|
370
|
-
</box>
|
|
371
|
-
)
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
type QuotaMetricRow = { label: string; value: string }
|
|
375
|
-
|
|
376
|
-
function metricRow(
|
|
377
|
-
metric: Exclude<QuotaMetric, { kind: 'provider_quota' }>,
|
|
378
|
-
): QuotaMetricRow | undefined {
|
|
379
|
-
const label = (fallback: string): string => metric.label?.trim() || fallback
|
|
380
|
-
switch (metric.kind) {
|
|
381
|
-
case 'balance': {
|
|
382
|
-
const value = quotaAmount(metric.amount, metric.currency)
|
|
383
|
-
return value
|
|
384
|
-
? {
|
|
385
|
-
label: label('Saldo'),
|
|
386
|
-
value: `${value}${metric.status?.trim() ? ` · ${metric.status.trim()}` : ''}`,
|
|
387
|
-
}
|
|
388
|
-
: undefined
|
|
389
|
-
}
|
|
390
|
-
case 'estimate': {
|
|
391
|
-
const value = quotaAmount(metric.amount, metric.unit)
|
|
392
|
-
return value ? { label: label('Estimativa'), value } : undefined
|
|
393
|
-
}
|
|
394
|
-
case 'key_usage': {
|
|
395
|
-
const value = quotaAmount(metric.amount, metric.currency)
|
|
396
|
-
if (!value) return undefined
|
|
397
|
-
const source = label('Uso da chave selecionada')
|
|
398
|
-
const scopedLabel = /selected\s+key|chave selecionada/i.test(source)
|
|
399
|
-
? source
|
|
400
|
-
: `Chave selecionada · ${source}`
|
|
401
|
-
return {
|
|
402
|
-
label: scopedLabel,
|
|
403
|
-
value: `${value}${metric.period?.trim() ? ` · ${metric.period.trim()}` : ''}`,
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
case 'session_usage': {
|
|
407
|
-
const value = quotaAmount(metric.amount, metric.unit)
|
|
408
|
-
return value ? { label: label('Uso da sessão'), value } : undefined
|
|
409
|
-
}
|
|
410
|
-
case 'provider_status':
|
|
411
|
-
return { label: metric.label, value: metric.status }
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
export function financeMetricLines(metric: FinanceMetric, width: number): string[] {
|
|
416
|
-
return quotaMetricLines(metric, width)
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
export function quotaMetricLines(
|
|
420
|
-
metric: Exclude<QuotaMetric, { kind: 'provider_quota' }>,
|
|
421
|
-
width: number,
|
|
422
|
-
): string[] {
|
|
423
|
-
const row = metricRow(metric)
|
|
424
|
-
if (!row) return []
|
|
425
|
-
const left = ` ${row.label}`
|
|
426
|
-
const spaces = width - cellWidth(left) - cellWidth(row.value)
|
|
427
|
-
if (spaces >= 2) return [`${left}${' '.repeat(spaces)}${row.value}`]
|
|
428
|
-
return [...quotaTextLines(row.label, width, 2), ...quotaTextLines(row.value, width, 4)]
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
function QuotaMetricLine(props: {
|
|
432
|
-
metric: Exclude<QuotaMetric, { kind: 'provider_quota' }>
|
|
433
|
-
width: number
|
|
434
|
-
context: Context
|
|
435
|
-
}) {
|
|
436
|
-
const row = () => metricRow(props.metric)
|
|
437
|
-
return (
|
|
438
|
-
<Show when={row()}>
|
|
439
|
-
<box flexDirection="column">
|
|
440
|
-
<For each={quotaMetricLines(props.metric, props.width)}>
|
|
441
|
-
{(line) => <text fg={base(props.context)}>{line}</text>}
|
|
442
|
-
</For>
|
|
443
|
-
</box>
|
|
444
|
-
</Show>
|
|
445
|
-
)
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
export function providerState(
|
|
449
|
-
provider: QuotaProviderDetail,
|
|
450
|
-
mode?: QuotaIconMode,
|
|
451
|
-
): { label: string; tone: QuotaTone } {
|
|
452
|
-
if (provider.authentication === 'not_connected')
|
|
453
|
-
return { label: `${iconInSlot('settings', 2, mode)} Precisa configurar`, tone: 'warning' }
|
|
454
|
-
if (provider.authentication === 'unavailable')
|
|
455
|
-
return { label: `${iconInSlot('close', 2, mode)} Indisponível`, tone: 'error' }
|
|
456
|
-
return provider.state === 'available'
|
|
457
|
-
? {
|
|
458
|
-
label: `${iconInSlot('check', 2, mode)} Credencial local · há dados`,
|
|
459
|
-
tone: 'success',
|
|
460
|
-
}
|
|
461
|
-
: {
|
|
462
|
-
label: `${iconInSlot('warning', 2, mode)} Credencial local · sem dados`,
|
|
463
|
-
tone: 'warning',
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
function recentModelUsage(context: Context, sessionID: string): RecentModelUsageRow[] {
|
|
468
|
-
if (!sessionID.startsWith('ses')) {
|
|
469
|
-
return collectRecentModelUsageRows({
|
|
470
|
-
activeModel: null,
|
|
471
|
-
activeMessages: [],
|
|
472
|
-
usageMessages: [],
|
|
473
|
-
models: [],
|
|
474
|
-
})
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
let session: ReturnType<Context['data']['session']['get']>
|
|
478
|
-
let activeMessages: unknown[] = []
|
|
479
|
-
try {
|
|
480
|
-
session = context.data.session.get(sessionID)
|
|
481
|
-
} catch {
|
|
482
|
-
session = undefined
|
|
483
|
-
}
|
|
484
|
-
const messagesBySession = new Map<string, unknown[]>()
|
|
485
|
-
try {
|
|
486
|
-
const messages = context.data.session.message.list(sessionID)
|
|
487
|
-
if (Array.isArray(messages)) {
|
|
488
|
-
activeMessages = messages.slice(-MODEL_USAGE_MESSAGE_LIMIT)
|
|
489
|
-
messagesBySession.set(sessionID, activeMessages)
|
|
490
|
-
}
|
|
491
|
-
} catch {
|
|
492
|
-
/* Cached session metadata can still identify the active model. */
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
const sessionIDs = [sessionID]
|
|
496
|
-
try {
|
|
497
|
-
const family = context.data.session.family(sessionID)
|
|
498
|
-
if (Array.isArray(family)) {
|
|
499
|
-
for (const id of family) {
|
|
500
|
-
if (typeof id !== 'string' || !id.startsWith('ses') || sessionIDs.includes(id)) continue
|
|
501
|
-
sessionIDs.push(id)
|
|
502
|
-
if (sessionIDs.length >= MODEL_USAGE_SESSION_LIMIT) break
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
} catch {
|
|
506
|
-
/* The active session still supplies its cached messages when family is absent. */
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
const usageMessages: unknown[] = []
|
|
510
|
-
const usageSessions: Array<{ messages: readonly unknown[]; revertMessageID: string | null }> = []
|
|
511
|
-
for (const id of sessionIDs) {
|
|
512
|
-
let messages = messagesBySession.get(id) ?? []
|
|
513
|
-
if (!messagesBySession.has(id)) {
|
|
514
|
-
try {
|
|
515
|
-
const result = context.data.session.message.list(id)
|
|
516
|
-
if (Array.isArray(result)) messages = result.slice(-MODEL_USAGE_MESSAGE_LIMIT)
|
|
517
|
-
} catch {
|
|
518
|
-
/* One unreadable child must not hide usage from the rest of the family. */
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
messagesBySession.set(id, messages)
|
|
522
|
-
usageMessages.push(...messages)
|
|
523
|
-
let familySession = session
|
|
524
|
-
if (id !== sessionID) {
|
|
525
|
-
try {
|
|
526
|
-
familySession = context.data.session.get(id)
|
|
527
|
-
} catch {
|
|
528
|
-
familySession = undefined
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
const revert = familySession?.revert
|
|
532
|
-
const revertMessageID =
|
|
533
|
-
typeof revert === 'object' && revert !== null && typeof revert.messageID === 'string'
|
|
534
|
-
? revert.messageID
|
|
535
|
-
: null
|
|
536
|
-
usageSessions.push({ messages, revertMessageID })
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
let models: unknown[] = []
|
|
540
|
-
let fallbackModel: unknown = null
|
|
541
|
-
try {
|
|
542
|
-
const location = context.location ?? context.data.location.default()
|
|
543
|
-
const result = context.data.location.model.list(location)
|
|
544
|
-
if (Array.isArray(result)) models = result
|
|
545
|
-
const agentID = session?.agent
|
|
546
|
-
if (typeof agentID === 'string' && agentID !== '') {
|
|
547
|
-
const agents = context.data.location.agent?.list?.(location)
|
|
548
|
-
if (Array.isArray(agents)) {
|
|
549
|
-
fallbackModel = agents.find((agent) => agent?.id === agentID)?.model ?? null
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
} catch {
|
|
553
|
-
/* Unknown model limits suppress only the context bars. */
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
const activeModel = resolveActiveModelRef(session?.model, activeMessages, fallbackModel)
|
|
557
|
-
const revert = session?.revert
|
|
558
|
-
const revertMessageID =
|
|
559
|
-
typeof revert === 'object' && revert !== null && typeof revert.messageID === 'string'
|
|
560
|
-
? revert.messageID
|
|
561
|
-
: null
|
|
562
|
-
|
|
563
|
-
return collectRecentModelUsageRows({
|
|
564
|
-
activeModel,
|
|
565
|
-
activeMessages,
|
|
566
|
-
usageMessages,
|
|
567
|
-
usageSessions,
|
|
568
|
-
models,
|
|
569
|
-
revertMessageID,
|
|
570
|
-
})
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
export function activeQuotaModelLabel(row: RecentModelUsageRow | undefined): string {
|
|
574
|
-
return row ? `Modelo ativo · ${activeModelIdentity(row)}` : 'Modelo ativo indisponível'
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
export function quotaPanelStatusMessage(
|
|
578
|
-
snapshot: Pick<QuotaSnapshot, 'status' | 'error'>,
|
|
579
|
-
): string | undefined {
|
|
580
|
-
if (snapshot.status === 'partial') return 'Dados parciais'
|
|
581
|
-
if (snapshot.status === 'ready') return undefined
|
|
582
|
-
return quotaSnapshotStatusLabel(snapshot.status, snapshot.error)
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
function useRecentModelUsage(context: Context, sessionID: string): () => RecentModelUsageRow[] {
|
|
586
|
-
const [revision, setRevision] = createSignal(0)
|
|
587
|
-
const rows = createMemo(() => {
|
|
588
|
-
revision()
|
|
589
|
-
return recentModelUsage(context, sessionID)
|
|
590
|
-
})
|
|
591
|
-
onMount(() => {
|
|
592
|
-
const unsubscribe: Array<() => void> = []
|
|
593
|
-
for (const event of MODEL_USAGE_REFRESH_EVENTS) {
|
|
594
|
-
try {
|
|
595
|
-
unsubscribe.push(context.data.on(event, () => setRevision((value) => value + 1)))
|
|
596
|
-
} catch {
|
|
597
|
-
/* Cached values stay renderable if a host event is unavailable. */
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
onCleanup(() => {
|
|
601
|
-
for (const dispose of unsubscribe) dispose()
|
|
602
|
-
})
|
|
603
|
-
})
|
|
604
|
-
return rows
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
function ActiveModelHeader(props: {
|
|
608
|
-
context: Context
|
|
609
|
-
sessionID: string
|
|
610
|
-
width: number
|
|
611
|
-
snapshot: QuotaSnapshot
|
|
612
|
-
}): JSX.Element {
|
|
613
|
-
const rows = useRecentModelUsage(props.context, props.sessionID)
|
|
614
|
-
const activeModel = createMemo(() => rows().find((row) => row.active))
|
|
615
|
-
const status = () => props.snapshot.status
|
|
616
|
-
const message = () => quotaPanelStatusMessage(props.snapshot)
|
|
617
|
-
const modelLine = () => activeQuotaModelLabel(activeModel())
|
|
618
|
-
return (
|
|
619
|
-
<box flexDirection="column">
|
|
620
|
-
<For each={quotaTextLines(modelLine(), props.width, 0)}>
|
|
621
|
-
{(line) => <text fg={base(props.context)}>{line}</text>}
|
|
622
|
-
</For>
|
|
623
|
-
<Show when={message()}>
|
|
624
|
-
{(label) => (
|
|
625
|
-
<For each={quotaTextLines(label(), props.width, 0)}>
|
|
626
|
-
{(line) => (
|
|
627
|
-
<text
|
|
628
|
-
fg={
|
|
629
|
-
status() === 'partial'
|
|
630
|
-
? tone(props.context, 'warning')
|
|
631
|
-
: tone(props.context, status() === 'unavailable' ? 'error' : 'info')
|
|
632
|
-
}
|
|
633
|
-
>
|
|
634
|
-
{line}
|
|
635
|
-
</text>
|
|
636
|
-
)}
|
|
637
|
-
</For>
|
|
638
|
-
)}
|
|
639
|
-
</Show>
|
|
640
|
-
</box>
|
|
641
|
-
)
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
function ModelUsageDetails(props: { context: Context; sessionID: string; width: number }) {
|
|
645
|
-
const rows = useRecentModelUsage(props.context, props.sessionID)
|
|
646
|
-
|
|
647
|
-
const contextTone = (percent: number) => tone(props.context, contextUsageTone(percent))
|
|
648
|
-
const contextCells = () => Math.max(4, Math.min(12, Math.floor((props.width - 30) / 2)))
|
|
649
|
-
const modelLabel = (row: RecentModelUsageRow) =>
|
|
650
|
-
`${row.providerID ? `${row.providerID}/` : ''}${row.label}`
|
|
651
|
-
|
|
652
|
-
return (
|
|
653
|
-
<box flexDirection="column" paddingTop={1}>
|
|
654
|
-
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
655
|
-
Modelos em uso
|
|
656
|
-
</text>
|
|
657
|
-
<text fg={muted(props.context)}>Mensagens recentes da sessão ativa e delegações.</text>
|
|
658
|
-
<For each={rows()}>
|
|
659
|
-
{(row, index) => (
|
|
660
|
-
<>
|
|
661
|
-
<Show when={row.active}>
|
|
662
|
-
<For
|
|
663
|
-
each={quotaTextLines(`MODELO ATUAL · ${activeModelIdentity(row)}`, props.width, 0)}
|
|
664
|
-
>
|
|
665
|
-
{(line) => (
|
|
666
|
-
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
667
|
-
{line}
|
|
668
|
-
</text>
|
|
669
|
-
)}
|
|
670
|
-
</For>
|
|
671
|
-
</Show>
|
|
672
|
-
<Show when={!row.active && index() === 1}>
|
|
673
|
-
<text fg={muted(props.context)} attributes={1}>
|
|
674
|
-
MAIS USADOS RECENTEMENTE
|
|
675
|
-
</text>
|
|
676
|
-
</Show>
|
|
677
|
-
<box flexDirection="column" paddingTop={1} paddingLeft={1}>
|
|
678
|
-
<text fg={base(props.context)} attributes={1}>
|
|
679
|
-
{clipped(modelLabel(row), props.width - 2)}
|
|
680
|
-
</text>
|
|
681
|
-
<Show
|
|
682
|
-
when={row.tokens !== null}
|
|
683
|
-
fallback={<text fg={muted(props.context)}>dados indisponíveis</text>}
|
|
684
|
-
>
|
|
685
|
-
<box flexDirection="row" justifyContent="space-between" gap={1}>
|
|
686
|
-
<text fg={muted(props.context)}>Tokens nas mensagens recentes</text>
|
|
687
|
-
<text fg={base(props.context)}>{`${formatTokenCount(row.tokens) ?? '—'}`}</text>
|
|
688
|
-
</box>
|
|
689
|
-
</Show>
|
|
690
|
-
<Show when={row.context}>
|
|
691
|
-
{(usage) => {
|
|
692
|
-
const bar = () => contextBar(usage().percent, contextCells())
|
|
693
|
-
return (
|
|
694
|
-
<box flexDirection="column" paddingTop={1}>
|
|
695
|
-
<box flexDirection="row" justifyContent="space-between" gap={1}>
|
|
696
|
-
<text fg={muted(props.context)}>Último contexto reportado</text>
|
|
697
|
-
<text fg={contextTone(usage().percent)}>
|
|
698
|
-
{`${formatTokenCount(usage().tokens) ?? '—'} tokens`}
|
|
699
|
-
</text>
|
|
700
|
-
</box>
|
|
701
|
-
<box flexDirection="row" gap={1}>
|
|
702
|
-
<Show when={bar()}>
|
|
703
|
-
{(cells) => (
|
|
704
|
-
<>
|
|
705
|
-
<text fg={contextTone(usage().percent)}>{cells().filled}</text>
|
|
706
|
-
<text fg={muted(props.context)}>{cells().empty}</text>
|
|
707
|
-
</>
|
|
708
|
-
)}
|
|
709
|
-
</Show>
|
|
710
|
-
<text fg={contextTone(usage().percent)}>
|
|
711
|
-
{`${usage().percent}% de ${formatContextWindow(usage().limit) ?? '—'}`}
|
|
712
|
-
</text>
|
|
713
|
-
</box>
|
|
714
|
-
</box>
|
|
715
|
-
)
|
|
716
|
-
}}
|
|
717
|
-
</Show>
|
|
718
|
-
<Show when={row.tokens !== null && row.context === null}>
|
|
719
|
-
<text fg={muted(props.context)}>Contexto indisponível</text>
|
|
720
|
-
</Show>
|
|
721
|
-
<Show when={row.active}>
|
|
722
|
-
<ActiveContextEstimate
|
|
723
|
-
context={props.context}
|
|
724
|
-
providerID={row.providerID}
|
|
725
|
-
modelID={row.modelID}
|
|
726
|
-
contextTokens={row.context?.tokens ?? null}
|
|
727
|
-
width={props.width - 2}
|
|
728
|
-
/>
|
|
729
|
-
</Show>
|
|
730
|
-
<Show when={row.cost === null ? null : sessionSpendLabel(row.cost)}>
|
|
731
|
-
{(label) => (
|
|
732
|
-
<For each={quotaTextLines(label(), props.width - 2, 0)}>
|
|
733
|
-
{(line) => <text fg={muted(props.context)}>{line}</text>}
|
|
734
|
-
</For>
|
|
735
|
-
)}
|
|
736
|
-
</Show>
|
|
737
|
-
</box>
|
|
738
|
-
</>
|
|
739
|
-
)}
|
|
740
|
-
</For>
|
|
741
|
-
</box>
|
|
742
|
-
)
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
function QuotaProviderDetails(props: {
|
|
746
|
-
provider: QuotaProviderDetail
|
|
747
|
-
display: 'used' | 'remaining'
|
|
748
|
-
width: number
|
|
749
|
-
context: Context
|
|
750
|
-
}) {
|
|
751
|
-
const [now, setNow] = createSignal(Date.now())
|
|
752
|
-
onMount(() => onCleanup(quotaClock.subscribe(setNow)))
|
|
753
|
-
const state = () => providerState(props.provider)
|
|
754
|
-
const quotaMetrics = () =>
|
|
755
|
-
props.provider.metrics.filter(
|
|
756
|
-
(metric): metric is QuotaWindowMetric => metric.kind === 'provider_quota',
|
|
757
|
-
)
|
|
758
|
-
const financeMetrics = () =>
|
|
759
|
-
props.provider.metrics.filter(
|
|
760
|
-
(metric) =>
|
|
761
|
-
metric.kind === 'balance' || metric.kind === 'estimate' || metric.kind === 'key_usage',
|
|
762
|
-
)
|
|
763
|
-
const otherMetrics = () =>
|
|
764
|
-
props.provider.metrics.filter(
|
|
765
|
-
(metric) => metric.kind === 'provider_status' || metric.kind === 'session_usage',
|
|
766
|
-
)
|
|
767
|
-
const safeError = () => {
|
|
768
|
-
const message = props.provider.message
|
|
769
|
-
return message &&
|
|
770
|
-
message !== 'status indisponível' &&
|
|
771
|
-
message !== 'dados de quota indisponíveis' &&
|
|
772
|
-
message !== 'setup necessário'
|
|
773
|
-
? message
|
|
774
|
-
: undefined
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
return (
|
|
778
|
-
<box flexDirection="column" paddingBottom={1}>
|
|
779
|
-
<For each={quotaTextLines(props.provider.label, props.width, 0)}>
|
|
780
|
-
{(line) => (
|
|
781
|
-
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
782
|
-
{line}
|
|
783
|
-
</text>
|
|
784
|
-
)}
|
|
785
|
-
</For>
|
|
786
|
-
<For each={quotaTextLines(state().label, props.width, 0)}>
|
|
787
|
-
{(line) => <text fg={tone(props.context, state().tone)}>{line}</text>}
|
|
788
|
-
</For>
|
|
789
|
-
<Show when={quotaMetrics().length > 0}>
|
|
790
|
-
<For each={quotaMetrics()}>
|
|
791
|
-
{(metric) => (
|
|
792
|
-
<QuotaWindow
|
|
793
|
-
metric={metric}
|
|
794
|
-
now={now()}
|
|
795
|
-
display={props.display}
|
|
796
|
-
width={props.width}
|
|
797
|
-
context={props.context}
|
|
798
|
-
/>
|
|
799
|
-
)}
|
|
800
|
-
</For>
|
|
801
|
-
</Show>
|
|
802
|
-
<Show when={financeMetrics().length > 0}>
|
|
803
|
-
<text fg={muted(props.context)}>GASTOS & SALDO</text>
|
|
804
|
-
<For each={financeMetrics()}>
|
|
805
|
-
{(metric) => (
|
|
806
|
-
<QuotaMetricLine metric={metric} width={props.width} context={props.context} />
|
|
807
|
-
)}
|
|
808
|
-
</For>
|
|
809
|
-
</Show>
|
|
810
|
-
<Show when={otherMetrics().length > 0}>
|
|
811
|
-
<text fg={muted(props.context)}>OUTRAS MÉTRICAS</text>
|
|
812
|
-
<For each={otherMetrics()}>
|
|
813
|
-
{(metric) => (
|
|
814
|
-
<QuotaMetricLine metric={metric} width={props.width} context={props.context} />
|
|
815
|
-
)}
|
|
816
|
-
</For>
|
|
817
|
-
</Show>
|
|
818
|
-
<Show when={safeError()}>
|
|
819
|
-
{(message) => (
|
|
820
|
-
<text fg={tone(props.context, 'warning')}>
|
|
821
|
-
{clipped(`! ${message()}`, props.width - 2)}
|
|
822
|
-
</text>
|
|
823
|
-
)}
|
|
824
|
-
</Show>
|
|
825
|
-
<text fg={muted(props.context)}>
|
|
826
|
-
{'─'.repeat(Math.max(8, Math.min(32, props.width - 4)))}
|
|
827
|
-
</text>
|
|
828
|
-
</box>
|
|
829
|
-
)
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
export type QuotaPanelAction = 'toggle-enabled' | 'toggle-display' | 'refresh' | 'close'
|
|
833
|
-
|
|
834
|
-
export const QUOTA_TABS = ['usage', 'limits', 'plugin', 'settings'] as const
|
|
835
|
-
export type QuotaTab = (typeof QUOTA_TABS)[number]
|
|
836
|
-
export const DEFAULT_QUOTA_TAB: QuotaTab = 'limits'
|
|
837
|
-
|
|
838
|
-
export function moveQuotaTab(current: QuotaTab, direction: -1 | 1): QuotaTab {
|
|
839
|
-
const currentIndex = QUOTA_TABS.indexOf(current)
|
|
840
|
-
const nextIndex = (currentIndex + direction + QUOTA_TABS.length) % QUOTA_TABS.length
|
|
841
|
-
return QUOTA_TABS[nextIndex] ?? DEFAULT_QUOTA_TAB
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
export const QUOTA_PANEL_COMMANDS: readonly {
|
|
845
|
-
action: QuotaPanelAction
|
|
846
|
-
id: string
|
|
847
|
-
title: string
|
|
848
|
-
bind: string
|
|
849
|
-
}[] = [
|
|
850
|
-
{
|
|
851
|
-
action: 'toggle-enabled',
|
|
852
|
-
id: 'pantheon.quota.toggle-enabled',
|
|
853
|
-
title: 'Quota: ativar/desativar',
|
|
854
|
-
bind: 'e',
|
|
855
|
-
},
|
|
856
|
-
{
|
|
857
|
-
action: 'toggle-display',
|
|
858
|
-
id: 'pantheon.quota.toggle-display',
|
|
859
|
-
title: 'Quota: alternar usado/restante',
|
|
860
|
-
bind: 'm',
|
|
861
|
-
},
|
|
862
|
-
{ action: 'refresh', id: 'pantheon.quota.refresh', title: 'Quota: atualizar', bind: 'r' },
|
|
863
|
-
{ action: 'close', id: 'pantheon.quota.close', title: 'Quota: fechar', bind: 'escape,q' },
|
|
864
|
-
]
|
|
865
|
-
|
|
866
|
-
export function runQuotaPanelCommand(
|
|
867
|
-
action: QuotaPanelAction,
|
|
868
|
-
panel: Pick<PanelInput, 'focused' | 'close'>,
|
|
869
|
-
runtime: QuotaRuntime,
|
|
870
|
-
): false | Promise<void> | undefined {
|
|
871
|
-
if (panel.focused !== true) return false
|
|
872
|
-
switch (action) {
|
|
873
|
-
case 'toggle-enabled':
|
|
874
|
-
return runtime.toggleEnabled()
|
|
875
|
-
case 'toggle-display':
|
|
876
|
-
return runtime.toggleDisplay()
|
|
877
|
-
case 'refresh':
|
|
878
|
-
return runtime.refresh()
|
|
879
|
-
case 'close':
|
|
880
|
-
panel.close()
|
|
881
|
-
return undefined
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
export function quotaPanelKeymapLayer(
|
|
886
|
-
panel: Pick<PanelInput, 'focused' | 'close'>,
|
|
887
|
-
runtime: QuotaRuntime,
|
|
888
|
-
onTabChange?: (direction: -1 | 1) => void,
|
|
889
|
-
): KeymapLayer {
|
|
890
|
-
const focused = () => panel.focused === true
|
|
891
|
-
return {
|
|
892
|
-
mode: 'global',
|
|
893
|
-
enabled: focused,
|
|
894
|
-
commands: [
|
|
895
|
-
...QUOTA_PANEL_COMMANDS.map((command) => ({
|
|
896
|
-
id: command.id,
|
|
897
|
-
title: command.title,
|
|
898
|
-
bind: command.bind,
|
|
899
|
-
run: () => (focused() ? runQuotaPanelCommand(command.action, panel, runtime) : false),
|
|
900
|
-
})),
|
|
901
|
-
{
|
|
902
|
-
id: 'pantheon.quota.next-tab',
|
|
903
|
-
title: 'Quota: próxima aba',
|
|
904
|
-
bind: 'tab',
|
|
905
|
-
run: () => {
|
|
906
|
-
if (!focused()) return false
|
|
907
|
-
onTabChange?.(1)
|
|
908
|
-
return undefined
|
|
909
|
-
},
|
|
910
|
-
},
|
|
911
|
-
{
|
|
912
|
-
id: 'pantheon.quota.previous-tab',
|
|
913
|
-
title: 'Quota: aba anterior',
|
|
914
|
-
bind: 'shift+tab',
|
|
915
|
-
run: () => {
|
|
916
|
-
if (!focused()) return false
|
|
917
|
-
onTabChange?.(-1)
|
|
918
|
-
return undefined
|
|
919
|
-
},
|
|
920
|
-
},
|
|
921
|
-
],
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
export function quotaOpenCommand(context: Pick<Context, 'ui'>): KeymapCommand {
|
|
926
|
-
return {
|
|
927
|
-
id: QUOTA_OPEN_COMMAND_ID,
|
|
928
|
-
title: 'Pantheon: Quota',
|
|
929
|
-
description: 'Painel de quota',
|
|
930
|
-
group: 'Pantheon',
|
|
931
|
-
palette: true,
|
|
932
|
-
slash: { name: 'quota', aliases: ['pantheon-quota'] },
|
|
933
|
-
run: () => {
|
|
934
|
-
openQuotaPanel(context)
|
|
935
|
-
},
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
export function openQuotaPanel(context: Pick<Context, 'ui'>): boolean {
|
|
940
|
-
let opened = false
|
|
941
|
-
try {
|
|
942
|
-
opened = context.ui.panel.open(QUOTA_PANEL_NAME)
|
|
943
|
-
} catch {
|
|
944
|
-
opened = false
|
|
945
|
-
}
|
|
946
|
-
if (opened) return true
|
|
947
|
-
try {
|
|
948
|
-
context.ui.toast.show({ message: QUOTA_PANEL_TOAST, variant: 'warning' })
|
|
949
|
-
} catch {
|
|
950
|
-
/* The details panel remains a no-op if the host also lacks toast support. */
|
|
951
|
-
}
|
|
952
|
-
return false
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
const QUOTA_TAB_LABELS: Record<QuotaTab, string> = {
|
|
956
|
-
usage: 'Usage',
|
|
957
|
-
limits: 'Limits',
|
|
958
|
-
plugin: 'Plugin',
|
|
959
|
-
settings: 'Settings',
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
const QUOTA_TAB_ICONS: Record<QuotaTab, QuotaIconName> = {
|
|
963
|
-
usage: 'clock',
|
|
964
|
-
limits: 'gauge',
|
|
965
|
-
plugin: 'plug',
|
|
966
|
-
settings: 'settings',
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
export function quotaTabLabel(tab: QuotaTab, mode?: QuotaIconMode): string {
|
|
970
|
-
return `${iconInSlot(QUOTA_TAB_ICONS[tab], 3, mode)} ${QUOTA_TAB_LABELS[tab]}`
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
function QuotaTabNavigation(props: {
|
|
974
|
-
context: Context
|
|
975
|
-
selected: QuotaTab
|
|
976
|
-
width: number
|
|
977
|
-
onSelect: (tab: QuotaTab) => void
|
|
978
|
-
}): JSX.Element {
|
|
979
|
-
return (
|
|
980
|
-
<box flexDirection={props.width < 54 ? 'column' : 'row'} gap={1}>
|
|
981
|
-
<For each={QUOTA_TABS}>
|
|
982
|
-
{(tab) => (
|
|
983
|
-
<box onMouseDown={() => props.onSelect(tab)}>
|
|
984
|
-
<text
|
|
985
|
-
fg={props.selected === tab ? tone(props.context, 'info') : muted(props.context)}
|
|
986
|
-
attributes={props.selected === tab ? 1 : 0}
|
|
987
|
-
>
|
|
988
|
-
{`${props.selected === tab ? '› ' : ' '}${quotaTabLabel(tab)}`}
|
|
989
|
-
</text>
|
|
990
|
-
</box>
|
|
991
|
-
)}
|
|
992
|
-
</For>
|
|
993
|
-
</box>
|
|
994
|
-
)
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
function QuotaCloseButton(props: { context: Context; close: () => void }): JSX.Element {
|
|
998
|
-
return (
|
|
999
|
-
<box onMouseDown={props.close}>
|
|
1000
|
-
<text fg={tone(props.context, 'info')}>{`${quotaIcon('close')} Fechar`}</text>
|
|
1001
|
-
</box>
|
|
1002
|
-
)
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
function QuotaPluginDetails(props: { context: Context; snapshot: QuotaSnapshot }): JSX.Element {
|
|
1006
|
-
return (
|
|
1007
|
-
<box flexDirection="column" paddingTop={1}>
|
|
1008
|
-
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
1009
|
-
Plugin
|
|
1010
|
-
</text>
|
|
1011
|
-
<text fg={base(props.context)}>{`Pantheon TUI v${__PANTHEON_VERSION__}`}</text>
|
|
1012
|
-
<text fg={muted(props.context)}>
|
|
1013
|
-
Status de conexão consultado pelo OpenCode; segredos não são exibidos.
|
|
1014
|
-
</text>
|
|
1015
|
-
<text fg={muted(props.context)}>
|
|
1016
|
-
{`Status da quota: ${quotaSnapshotStatusLabel(props.snapshot.status, props.snapshot.error)}`}
|
|
1017
|
-
</text>
|
|
1018
|
-
<Show when={props.snapshot.details.length > 0}>
|
|
1019
|
-
<text fg={muted(props.context)}>PROVEDORES DETECTADOS</text>
|
|
1020
|
-
<For each={props.snapshot.details}>
|
|
1021
|
-
{(provider) => {
|
|
1022
|
-
const state = providerState(provider)
|
|
1023
|
-
return (
|
|
1024
|
-
<text fg={tone(props.context, state.tone)}>
|
|
1025
|
-
{`${provider.label} · ${state.label}`}
|
|
1026
|
-
</text>
|
|
1027
|
-
)
|
|
1028
|
-
}}
|
|
1029
|
-
</For>
|
|
1030
|
-
</Show>
|
|
1031
|
-
<Show when={props.snapshot.details.length === 0}>
|
|
1032
|
-
<text fg={muted(props.context)}>Nenhum provedor elegível foi confirmado nesta sessão.</text>
|
|
1033
|
-
</Show>
|
|
1034
|
-
<text fg={muted(props.context)}>
|
|
1035
|
-
Configure a conexão e credenciais pelo fluxo oficial do OpenCode; o painel não altera
|
|
1036
|
-
configurações.
|
|
1037
|
-
</text>
|
|
1038
|
-
</box>
|
|
1039
|
-
)
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
function QuotaSettings(props: { context: Context; runtime: QuotaRuntime }): JSX.Element {
|
|
1043
|
-
const preferences = () => props.runtime.preferences()
|
|
1044
|
-
return (
|
|
1045
|
-
<box flexDirection="column" paddingTop={1}>
|
|
1046
|
-
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
1047
|
-
Settings
|
|
1048
|
-
</text>
|
|
1049
|
-
<box onMouseDown={() => void props.runtime.toggleEnabled()}>
|
|
1050
|
-
<text fg={base(props.context)}>
|
|
1051
|
-
{`${quotaIcon(preferences().enabled ? 'check' : 'close')} [E] Quota ${preferences().enabled ? 'ativada' : 'desativada'} · clique para alternar`}
|
|
1052
|
-
</text>
|
|
1053
|
-
</box>
|
|
1054
|
-
<box onMouseDown={() => void props.runtime.toggleDisplay()}>
|
|
1055
|
-
<text fg={base(props.context)}>
|
|
1056
|
-
{`${quotaIcon('sliders')} [M] Exibir ${preferences().display === 'remaining' ? 'restante' : 'usado'} · clique para alternar`}
|
|
1057
|
-
</text>
|
|
1058
|
-
</box>
|
|
1059
|
-
<text fg={muted(props.context)}>Tab/Shift+Tab navega pelas abas; Esc fecha o painel.</text>
|
|
1060
|
-
</box>
|
|
1061
|
-
)
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
export function QuotaPanel(props: QuotaSurfaceProps & { panel: PanelInput }): JSX.Element {
|
|
1065
|
-
const [selectedTab, setSelectedTab] = createSignal<QuotaTab>(DEFAULT_QUOTA_TAB)
|
|
1066
|
-
props.context.keymap.layer(() =>
|
|
1067
|
-
quotaPanelKeymapLayer(props.panel, props.runtime, (direction) =>
|
|
1068
|
-
setSelectedTab((tab) => moveQuotaTab(tab, direction)),
|
|
1069
|
-
),
|
|
1070
|
-
)
|
|
1071
|
-
const preferences = () => props.runtime.preferences()
|
|
1072
|
-
const snapshot = () => props.runtime.snapshot()
|
|
1073
|
-
|
|
1074
|
-
return (
|
|
1075
|
-
<box flexDirection="column" width="100%" height="100%" padding={1}>
|
|
1076
|
-
<Show
|
|
1077
|
-
when={props.panel.width >= 54}
|
|
1078
|
-
fallback={
|
|
1079
|
-
<box flexDirection="row" justifyContent="space-between" gap={1}>
|
|
1080
|
-
<text
|
|
1081
|
-
fg={tone(props.context, 'info')}
|
|
1082
|
-
attributes={1}
|
|
1083
|
-
>{`${QUOTA_ICON} Pantheon / Quota`}</text>
|
|
1084
|
-
<QuotaCloseButton context={props.context} close={props.panel.close} />
|
|
1085
|
-
</box>
|
|
1086
|
-
}
|
|
1087
|
-
>
|
|
1088
|
-
<box flexDirection="row" justifyContent="space-between" gap={1}>
|
|
1089
|
-
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
1090
|
-
{`${QUOTA_ICON} Pantheon / Quota`}
|
|
1091
|
-
</text>
|
|
1092
|
-
<QuotaCloseButton context={props.context} close={props.panel.close} />
|
|
1093
|
-
</box>
|
|
1094
|
-
</Show>
|
|
1095
|
-
<ActiveModelHeader
|
|
1096
|
-
context={props.context}
|
|
1097
|
-
sessionID={props.panel.sessionID}
|
|
1098
|
-
width={props.panel.width - 4}
|
|
1099
|
-
snapshot={snapshot()}
|
|
1100
|
-
/>
|
|
1101
|
-
<QuotaTabNavigation
|
|
1102
|
-
context={props.context}
|
|
1103
|
-
selected={selectedTab()}
|
|
1104
|
-
width={props.panel.width}
|
|
1105
|
-
onSelect={setSelectedTab}
|
|
1106
|
-
/>
|
|
1107
|
-
<Show when={snapshot().error !== undefined && snapshot().status !== 'ready'}>
|
|
1108
|
-
<text fg={muted(props.context)}>{`Último erro: ${snapshot().error}`}</text>
|
|
1109
|
-
</Show>
|
|
1110
|
-
<Show when={snapshot().status === 'needs_setup' && snapshot().details.length === 0}>
|
|
1111
|
-
<text fg={muted(props.context)}>
|
|
1112
|
-
Nenhum provedor elegível: verifique conexão ativa e credencial local compatível.
|
|
1113
|
-
</text>
|
|
1114
|
-
</Show>
|
|
1115
|
-
<Show when={snapshot().status === 'unavailable'}>
|
|
1116
|
-
<text fg={muted(props.context)}>Não foi possível verificar o status da quota.</text>
|
|
1117
|
-
</Show>
|
|
1118
|
-
<Show when={snapshot().status === 'stale'}>
|
|
1119
|
-
<text fg={muted(props.context)}>
|
|
1120
|
-
A última resposta continua visível; atualize para tentar novamente.
|
|
1121
|
-
</text>
|
|
1122
|
-
</Show>
|
|
1123
|
-
<scrollbox
|
|
1124
|
-
flexGrow={1}
|
|
1125
|
-
flexShrink={1}
|
|
1126
|
-
flexBasis={0}
|
|
1127
|
-
minHeight={3}
|
|
1128
|
-
width="100%"
|
|
1129
|
-
scrollY
|
|
1130
|
-
focused={props.panel.focused}
|
|
1131
|
-
focusable
|
|
1132
|
-
border
|
|
1133
|
-
borderColor={muted(props.context)}
|
|
1134
|
-
focusedBorderColor={tone(props.context, 'info')}
|
|
1135
|
-
>
|
|
1136
|
-
<box flexDirection="column" paddingX={1} paddingY={1}>
|
|
1137
|
-
<Show when={selectedTab() === 'usage'}>
|
|
1138
|
-
<UsageHistorySection
|
|
1139
|
-
context={props.context}
|
|
1140
|
-
panel={props.panel}
|
|
1141
|
-
width={props.panel.width - 6}
|
|
1142
|
-
/>
|
|
1143
|
-
<ModelUsageDetails
|
|
1144
|
-
context={props.context}
|
|
1145
|
-
sessionID={props.panel.sessionID}
|
|
1146
|
-
width={props.panel.width - 6}
|
|
1147
|
-
/>
|
|
1148
|
-
</Show>
|
|
1149
|
-
<Show when={selectedTab() === 'limits'}>
|
|
1150
|
-
<Show when={snapshot().details.length > 0}>
|
|
1151
|
-
<For each={snapshot().details}>
|
|
1152
|
-
{(provider) => (
|
|
1153
|
-
<QuotaProviderDetails
|
|
1154
|
-
provider={provider}
|
|
1155
|
-
display={preferences().display}
|
|
1156
|
-
width={props.panel.width - 4}
|
|
1157
|
-
context={props.context}
|
|
1158
|
-
/>
|
|
1159
|
-
)}
|
|
1160
|
-
</For>
|
|
1161
|
-
</Show>
|
|
1162
|
-
<Show when={snapshot().details.length === 0}>
|
|
1163
|
-
<text fg={muted(props.context)}>
|
|
1164
|
-
{quotaSnapshotStatusLabel(snapshot().status, snapshot().error)}
|
|
1165
|
-
</text>
|
|
1166
|
-
</Show>
|
|
1167
|
-
</Show>
|
|
1168
|
-
<Show when={selectedTab() === 'plugin'}>
|
|
1169
|
-
<QuotaPluginDetails context={props.context} snapshot={snapshot()} />
|
|
1170
|
-
</Show>
|
|
1171
|
-
<Show when={selectedTab() === 'settings'}>
|
|
1172
|
-
<QuotaSettings context={props.context} runtime={props.runtime} />
|
|
1173
|
-
</Show>
|
|
1174
|
-
</box>
|
|
1175
|
-
</scrollbox>
|
|
1176
|
-
<box flexDirection="column" flexShrink={0}>
|
|
1177
|
-
<text fg={muted(props.context)}>
|
|
1178
|
-
{`Quota ${preferences().enabled ? 'ativada' : 'desativada'} · exibição: ${preferences().display === 'remaining' ? 'restante' : 'usado'}`}
|
|
1179
|
-
</text>
|
|
1180
|
-
<text
|
|
1181
|
-
fg={muted(props.context)}
|
|
1182
|
-
>{`E ${preferences().enabled ? 'desativar' : 'ativar'} · M alternar usado/restante`}</text>
|
|
1183
|
-
<text fg={muted(props.context)}>{`↑/↓ rolar · ${quotaIcon('refresh')} R atualizar`}</text>
|
|
1184
|
-
<text fg={muted(props.context)}>Tab/Shift+Tab abas · Esc/Q fechar</text>
|
|
1185
|
-
</box>
|
|
1186
|
-
</box>
|
|
1187
|
-
)
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
function QuotaCommandLayer(props: QuotaSurfaceProps) {
|
|
1191
|
-
const goCheck = quotaGoCheckCommand(props.context)
|
|
1192
|
-
props.context.keymap.layer(() => ({
|
|
1193
|
-
mode: 'global',
|
|
1194
|
-
commands: [quotaOpenCommand(props.context), goCheck],
|
|
1195
|
-
}))
|
|
1196
|
-
return null
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
/** Register footer/panel controls and own teardown of the shared sidebar runtime. */
|
|
1200
|
-
export function registerQuotaTui(context: Context, runtime: QuotaRuntime): () => void {
|
|
1201
|
-
const unregister: Array<() => void> = []
|
|
1202
|
-
try {
|
|
1203
|
-
unregister.push(
|
|
1204
|
-
context.ui.slot({
|
|
1205
|
-
append: 'prompt.footer',
|
|
1206
|
-
render: () => <QuotaFooterSummary context={context} runtime={runtime} />,
|
|
1207
|
-
}),
|
|
1208
|
-
)
|
|
1209
|
-
unregister.push(
|
|
1210
|
-
context.ui.slot({
|
|
1211
|
-
append: 'session.panel',
|
|
1212
|
-
render: (panel: PanelInput) =>
|
|
1213
|
-
panel.name === QUOTA_PANEL_NAME ? (
|
|
1214
|
-
<QuotaPanel context={context} runtime={runtime} panel={panel} />
|
|
1215
|
-
) : null,
|
|
1216
|
-
}),
|
|
1217
|
-
)
|
|
1218
|
-
unregister.push(
|
|
1219
|
-
context.ui.slot({
|
|
1220
|
-
append: 'app',
|
|
1221
|
-
render: () => <QuotaCommandLayer context={context} runtime={runtime} />,
|
|
1222
|
-
}),
|
|
1223
|
-
)
|
|
1224
|
-
} catch (error) {
|
|
1225
|
-
runtime.dispose()
|
|
1226
|
-
unregister.reverse().forEach((dispose) => {
|
|
1227
|
-
dispose()
|
|
1228
|
-
})
|
|
1229
|
-
throw error
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
return () => {
|
|
1233
|
-
runtime.dispose()
|
|
1234
|
-
unregister.reverse().forEach((dispose) => {
|
|
1235
|
-
dispose()
|
|
1236
|
-
})
|
|
1237
|
-
}
|
|
1238
|
-
}
|