@troed/oc-ls-stats 1.1.5 → 1.3.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.
- package/README.md +18 -2
- package/package.json +6 -2
- package/src/stats.ts +96 -0
- package/tui.tsx +85 -123
package/README.md
CHANGED
|
@@ -47,12 +47,28 @@ The plugin renders a single line in the session prompt right slot:
|
|
|
47
47
|
|
|
48
48
|
### Server Discovery
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
By default the plugin discovers the llama-server URL from OpenCode's resolved provider list (`id` or `name` containing "llama", excluding "ollama"), extracting `baseURL`/`base_url` from the provider options. This covers providers from all sources (config, environment, API). If the provider list is unavailable, it falls back to parsing the OpenCode configuration directly, and finally to `http://localhost:8080`.
|
|
51
|
+
|
|
52
|
+
When several llama-server providers are detected, stats follow the provider used by the current session; until a session has picked a model, every detected server is polled.
|
|
53
|
+
|
|
54
|
+
If your llama-server provider is named differently, configure the endpoint explicitly via the plugin's `server` option in `tui.json`. An explicit server replaces discovery entirely:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"plugin": [
|
|
59
|
+
["@troed/oc-ls-stats@latest", { "server": "http://headless.local:8080" }]
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A `baseURL`-style value ending in `/v1` is also accepted.
|
|
51
65
|
|
|
52
66
|
### Slot Polling
|
|
53
67
|
|
|
54
68
|
Every 500ms, the plugin polls `GET /slots?model=<model>` on each discovered server. The model parameter is required by the `/slots` endpoint. If the model cannot be discovered from the current route's session, the plugin skips polling.
|
|
55
69
|
|
|
70
|
+
When a server returns an error (e.g. HTTP 502) or is unreachable, the plugin backs off with an exponentially increasing delay per server (1s, 2s, 4s, ...) capped at 10s, with a small random jitter to stagger multiple servers. Backoff resets as soon as the server responds successfully again.
|
|
71
|
+
|
|
56
72
|
### State Classification
|
|
57
73
|
|
|
58
74
|
Each processing slot is classified as prefill (PP) or generation (TG) by comparing `n_decoded` and `n_prompt_tokens` against per-slot/per-task baselines. The plugin tracks two baseline maps keyed by slot ID:
|
|
@@ -114,7 +130,7 @@ The following changes to the `/slots` endpoint would improve the plugin's functi
|
|
|
114
130
|
|
|
115
131
|
For known issues, posting new ones, forking or contributing:
|
|
116
132
|
|
|
117
|
-
https://
|
|
133
|
+
https://git.sync.wtf/troed/oc-ls-stats
|
|
118
134
|
|
|
119
135
|
## Debug Logging
|
|
120
136
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@troed/oc-ls-stats",
|
|
4
|
-
"version": "1.1
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"tui.tsx",
|
|
8
|
+
"src"
|
|
9
|
+
],
|
|
6
10
|
"exports": {
|
|
7
11
|
"./tui": {
|
|
8
12
|
"import": "./tui.tsx"
|
|
9
13
|
}
|
|
10
14
|
},
|
|
11
15
|
"scripts": {
|
|
12
|
-
"prepack": "npx -y tsx test-
|
|
16
|
+
"prepack": "npx -y tsx test-backoff.ts"
|
|
13
17
|
},
|
|
14
18
|
"engines": {
|
|
15
19
|
"opencode": ">=1.3.14"
|
package/src/stats.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export function backoffDelayMs(failures: number, baseMs: number = 1000, maxMs: number = 10000): number {
|
|
2
|
+
return Math.min(maxMs, baseMs * 2 ** (failures - 1))
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
export interface SlotState {
|
|
2
6
|
id: number
|
|
3
7
|
is_processing: boolean
|
|
@@ -206,3 +210,95 @@ export function processPoll(
|
|
|
206
210
|
tgEnded,
|
|
207
211
|
}
|
|
208
212
|
}
|
|
213
|
+
|
|
214
|
+
export function stripBaseUrlPath(baseURL: string): string {
|
|
215
|
+
try {
|
|
216
|
+
const url = new URL(baseURL)
|
|
217
|
+
return `${url.origin}`
|
|
218
|
+
} catch {
|
|
219
|
+
return baseURL.replace(/\/v1(\/.*)?$/, "").replace(/\/$/, "") || baseURL
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function extractProviderUrls(config: unknown): string[] {
|
|
224
|
+
if (!config || typeof config !== "object") return []
|
|
225
|
+
const obj = config as Record<string, unknown>
|
|
226
|
+
const provider = obj.provider
|
|
227
|
+
if (!provider || typeof provider !== "object") return []
|
|
228
|
+
|
|
229
|
+
const urls: string[] = []
|
|
230
|
+
for (const [key, val] of Object.entries(provider as Record<string, unknown>)) {
|
|
231
|
+
if (val && typeof val === "object") {
|
|
232
|
+
const opts = (val as Record<string, unknown>).options
|
|
233
|
+
if (opts && typeof opts === "object") {
|
|
234
|
+
const baseURL = (opts as Record<string, unknown>).baseURL || (opts as Record<string, unknown>).base_url
|
|
235
|
+
if (typeof baseURL === "string" && key.toLowerCase().includes("llama") && !key.toLowerCase().includes("ollama")) {
|
|
236
|
+
urls.push(stripBaseUrlPath(baseURL))
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return urls
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function extractProviderUrlsFromList(providers: unknown): string[] {
|
|
245
|
+
if (!Array.isArray(providers)) return []
|
|
246
|
+
const urls: string[] = []
|
|
247
|
+
for (const entry of providers) {
|
|
248
|
+
if (!entry || typeof entry !== "object") continue
|
|
249
|
+
const provider = entry as Record<string, unknown>
|
|
250
|
+
const id = typeof provider.id === "string" ? provider.id.toLowerCase() : ""
|
|
251
|
+
const name = typeof provider.name === "string" ? provider.name.toLowerCase() : ""
|
|
252
|
+
const hay = `${id} ${name}`
|
|
253
|
+
if (!hay.includes("llama") || hay.includes("ollama")) continue
|
|
254
|
+
const opts = provider.options
|
|
255
|
+
if (!opts || typeof opts !== "object") continue
|
|
256
|
+
const baseURL = (opts as Record<string, unknown>).baseURL || (opts as Record<string, unknown>).base_url
|
|
257
|
+
if (typeof baseURL === "string") {
|
|
258
|
+
urls.push(stripBaseUrlPath(baseURL))
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return urls
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function resolveServerUrls(options: unknown, providers: unknown, config: unknown): string[] {
|
|
265
|
+
const opts = options && typeof options === "object" ? (options as Record<string, unknown>) : undefined
|
|
266
|
+
const server = opts?.server
|
|
267
|
+
const explicit = typeof server === "string" && server.trim() !== "" ? stripBaseUrlPath(server) : undefined
|
|
268
|
+
if (explicit && /^https?:\/\//.test(explicit)) {
|
|
269
|
+
return [explicit]
|
|
270
|
+
}
|
|
271
|
+
if (server !== undefined) {
|
|
272
|
+
console.warn("[oc-ls-stats] ignoring invalid 'server' plugin option, falling back to provider detection")
|
|
273
|
+
}
|
|
274
|
+
const detected = [...new Set(extractProviderUrlsFromList(providers))]
|
|
275
|
+
if (detected.length > 0) return detected
|
|
276
|
+
const legacy = [...new Set(extractProviderUrls(config))]
|
|
277
|
+
return legacy.length > 0 ? legacy : ["http://localhost:8080"]
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function selectSessionUrls(
|
|
281
|
+
candidates: string[],
|
|
282
|
+
providers: unknown,
|
|
283
|
+
providerID: string | undefined,
|
|
284
|
+
): string[] {
|
|
285
|
+
if (typeof providerID !== "string" || providerID.trim() === "" || candidates.length === 0)
|
|
286
|
+
return candidates
|
|
287
|
+
if (!Array.isArray(providers) || providers.length === 0) return candidates
|
|
288
|
+
for (const entry of providers) {
|
|
289
|
+
if (!entry || typeof entry !== "object") continue
|
|
290
|
+
const provider = entry as Record<string, unknown>
|
|
291
|
+
if (provider.id !== providerID) continue
|
|
292
|
+
const opts = provider.options
|
|
293
|
+
if (opts && typeof opts === "object") {
|
|
294
|
+
const baseURL =
|
|
295
|
+
(opts as Record<string, unknown>).baseURL || (opts as Record<string, unknown>).base_url
|
|
296
|
+
if (typeof baseURL === "string") {
|
|
297
|
+
const normalized = stripBaseUrlPath(baseURL)
|
|
298
|
+
if (candidates.includes(normalized)) return [normalized]
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return []
|
|
302
|
+
}
|
|
303
|
+
return []
|
|
304
|
+
}
|
package/tui.tsx
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
import type { TextRenderable } from "@opentui/core"
|
|
2
3
|
import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui"
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { processPoll } from "./src/stats.ts"
|
|
6
|
-
|
|
7
|
-
const DEBUG_ENABLED = false
|
|
8
|
-
const DEBUG_LOG = "/tmp/oc-ls-stats-debug.log"
|
|
9
|
-
function debug(...args: unknown[]) {
|
|
10
|
-
if (!DEBUG_ENABLED) return
|
|
11
|
-
try {
|
|
12
|
-
const line = `${args.map(a => typeof a === "object" ? JSON.stringify(a) : String(a)).join(" ")}\n`
|
|
13
|
-
appendFileSync(DEBUG_LOG, line)
|
|
14
|
-
} catch {}
|
|
15
|
-
}
|
|
4
|
+
import { onCleanup } from "solid-js"
|
|
5
|
+
import { backoffDelayMs, processPoll, resolveServerUrls, selectSessionUrls } from "./src/stats.ts"
|
|
16
6
|
|
|
17
7
|
type StreamSample = {
|
|
18
8
|
at: number
|
|
@@ -21,6 +11,8 @@ type StreamSample = {
|
|
|
21
11
|
|
|
22
12
|
const STREAM_WINDOW_MS = 5_000
|
|
23
13
|
const SLOT_POLL_MS = 500
|
|
14
|
+
const BACKOFF_BASE_MS = 1_000
|
|
15
|
+
const BACKOFF_MAX_MS = 10_000
|
|
24
16
|
type MessageTiming = {
|
|
25
17
|
sessionID: string
|
|
26
18
|
requestStartAt: number
|
|
@@ -51,53 +43,6 @@ function estimateStreamTokens(delta: string) {
|
|
|
51
43
|
return Math.max(1, Math.ceil(Buffer.byteLength(delta, "utf8") / 5))
|
|
52
44
|
}
|
|
53
45
|
|
|
54
|
-
function stripBaseUrlPath(baseURL: string): string {
|
|
55
|
-
try {
|
|
56
|
-
const url = new URL(baseURL)
|
|
57
|
-
return `${url.origin}`
|
|
58
|
-
} catch {
|
|
59
|
-
return baseURL.replace(/\/v1(\/.*)?$/, "").replace(/\/$/, "") || baseURL
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function extractProviderUrls(config: unknown): string[] {
|
|
64
|
-
if (!config || typeof config !== "object") { debug("extractProviderUrls: config is null/undefined or not object"); return [] }
|
|
65
|
-
const obj = config as Record<string, unknown>
|
|
66
|
-
const provider = obj.provider
|
|
67
|
-
if (!provider || typeof provider !== "object") { debug("extractProviderUrls: no provider in config"); return [] }
|
|
68
|
-
|
|
69
|
-
const urls: string[] = []
|
|
70
|
-
let total = 0
|
|
71
|
-
let matched = 0
|
|
72
|
-
for (const [key, val] of Object.entries(provider as Record<string, unknown>)) {
|
|
73
|
-
total++
|
|
74
|
-
if (val && typeof val === "object") {
|
|
75
|
-
const opts = (val as Record<string, unknown>).options
|
|
76
|
-
if (opts && typeof opts === "object") {
|
|
77
|
-
const baseURL = (opts as Record<string, unknown>).baseURL || (opts as Record<string, unknown>).base_url
|
|
78
|
-
debug(`extractProviderUrls: provider="${key}" baseURL=${baseURL}`)
|
|
79
|
-
if (typeof baseURL === "string" && key.toLowerCase().includes("llama") && !key.toLowerCase().includes("ollama")) {
|
|
80
|
-
urls.push(stripBaseUrlPath(baseURL))
|
|
81
|
-
matched++
|
|
82
|
-
debug(`extractProviderUrls: MATCH provider="${key}" -> ${urls[urls.length-1]}`)
|
|
83
|
-
} else {
|
|
84
|
-
debug(`extractProviderUrls: SKIP provider="${key}" (llama=${key.toLowerCase().includes("llama")} ollama=${key.toLowerCase().includes("ollama")})`)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
debug(`extractProviderUrls: total=${total} matched=${matched} urls=${JSON.stringify(urls)}`)
|
|
90
|
-
return urls
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function loadConfigUrls(api: Parameters<TuiPlugin>[0]): Promise<string[]> {
|
|
94
|
-
try {
|
|
95
|
-
return extractProviderUrls(api.state.config as unknown)
|
|
96
|
-
} catch (e) {
|
|
97
|
-
return []
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
46
|
async function fetchSlots(baseUrl: string, model?: string): Promise<unknown | null> {
|
|
102
47
|
try {
|
|
103
48
|
const url = model ? `${baseUrl}/slots?model=${encodeURIComponent(model)}` : `${baseUrl}/slots`
|
|
@@ -123,49 +68,49 @@ function SessionPromptRight(props: {
|
|
|
123
68
|
api: Parameters<TuiPlugin>[0]
|
|
124
69
|
sessionID: string
|
|
125
70
|
tracker: TrackerState
|
|
126
|
-
|
|
127
|
-
clock: () => number
|
|
71
|
+
subscribe: (listener: () => void) => () => void
|
|
128
72
|
}) {
|
|
129
|
-
|
|
130
|
-
props.version()
|
|
131
|
-
props.clock()
|
|
132
|
-
const rate = props.tracker.lastGeneratedTps
|
|
133
|
-
if (!Number.isFinite(rate) || rate <= 0) return undefined
|
|
134
|
-
return rate
|
|
135
|
-
})
|
|
73
|
+
let textRef: TextRenderable | undefined
|
|
136
74
|
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return rate
|
|
143
|
-
})
|
|
75
|
+
const sync = () => {
|
|
76
|
+
if (!textRef) return
|
|
77
|
+
textRef.content = getStatusText()
|
|
78
|
+
props.api.renderer.requestRender()
|
|
79
|
+
}
|
|
144
80
|
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
81
|
+
const unsubscribe = props.subscribe(sync)
|
|
82
|
+
onCleanup(unsubscribe)
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<text
|
|
86
|
+
ref={(ref: TextRenderable) => {
|
|
87
|
+
textRef = ref
|
|
88
|
+
sync()
|
|
89
|
+
}}
|
|
90
|
+
fg={props.api.theme.current.textMuted}
|
|
91
|
+
>
|
|
92
|
+
{getStatusText()}
|
|
93
|
+
</text>
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
function getStatusText() {
|
|
97
|
+
const s = props.tracker
|
|
98
|
+
if (s.failure) {
|
|
99
|
+
return s.failure
|
|
154
100
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
101
|
+
const pp = s.isPrefilling && s.lastPrefillRate > 0 ? formatPps(s.lastPrefillRate) : undefined
|
|
102
|
+
const tps = s.isGenerating && s.lastGeneratedTps > 0 ? formatTps(s.lastGeneratedTps) : undefined
|
|
103
|
+
let result = "- tps (TG)"
|
|
104
|
+
if (s.isPrefilling && pp) {
|
|
105
|
+
result = `${pp} tps (PP)`
|
|
106
|
+
} else if (s.isGenerating && tps) {
|
|
107
|
+
result = `${tps} tps (TG)`
|
|
159
108
|
}
|
|
160
|
-
const result = `- tps (TG)`
|
|
161
|
-
debug(`UI_TEXT="${result}" isPrefilling=${props.tracker.isPrefilling} isGenerating=${props.tracker.isGenerating} failure=${props.tracker.failure} pp=${pp} tps=${tps}`)
|
|
162
109
|
return result
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return <>{text() ? <text fg={props.api.theme.current.textMuted}>{text()}</text> : null}</>
|
|
110
|
+
}
|
|
166
111
|
}
|
|
167
112
|
|
|
168
|
-
const tui: TuiPlugin = async (api) => {
|
|
113
|
+
const tui: TuiPlugin = async (api, options) => {
|
|
169
114
|
console.log("[oc-ls-stats] TUI plugin loaded!")
|
|
170
115
|
const tracker: TrackerState = {
|
|
171
116
|
streamSamplesBySession: {},
|
|
@@ -184,10 +129,11 @@ const tui: TuiPlugin = async (api) => {
|
|
|
184
129
|
prevPromptTokensBySlot: {},
|
|
185
130
|
failure: null,
|
|
186
131
|
}
|
|
187
|
-
const
|
|
188
|
-
const [clock, setClock] = createSignal(Date.now())
|
|
132
|
+
const listeners = new Set<() => void>()
|
|
189
133
|
|
|
190
|
-
const bump = () =>
|
|
134
|
+
const bump = () => {
|
|
135
|
+
for (const listener of listeners) listener()
|
|
136
|
+
}
|
|
191
137
|
|
|
192
138
|
const pruneSamples = (now = Date.now()) => {
|
|
193
139
|
let changed = false
|
|
@@ -232,11 +178,13 @@ const tui: TuiPlugin = async (api) => {
|
|
|
232
178
|
|
|
233
179
|
let llamaServerUrls: string[] = []
|
|
234
180
|
let llamaServerModel: string | undefined
|
|
181
|
+
const backoffByUrl = new Map<string, { failures: number; nextRetryAt: number }>()
|
|
235
182
|
|
|
236
183
|
const pollMetrics = async () => {
|
|
237
184
|
if (!llamaServerUrls.length) return
|
|
238
185
|
|
|
239
186
|
let model = llamaServerModel
|
|
187
|
+
let sessionProviderId: string | undefined
|
|
240
188
|
if (!model) {
|
|
241
189
|
const routeSessionID = api.route.current.params?.sessionID
|
|
242
190
|
if (routeSessionID) {
|
|
@@ -244,16 +192,41 @@ const tui: TuiPlugin = async (api) => {
|
|
|
244
192
|
if (session?.model?.id) {
|
|
245
193
|
model = session.model.id
|
|
246
194
|
}
|
|
195
|
+
sessionProviderId = session?.model?.providerID
|
|
247
196
|
}
|
|
248
197
|
}
|
|
249
198
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
199
|
+
const activeUrls = selectSessionUrls(llamaServerUrls, api.state.provider, sessionProviderId)
|
|
200
|
+
if (!activeUrls.length) {
|
|
201
|
+
tracker.failure = "n/a"
|
|
202
|
+
bump()
|
|
203
|
+
return
|
|
204
|
+
}
|
|
205
|
+
for (const baseUrl of activeUrls) {
|
|
206
|
+
const now = Date.now()
|
|
207
|
+
const backoff = backoffByUrl.get(baseUrl)
|
|
208
|
+
if (backoff && now < backoff.nextRetryAt) {
|
|
209
|
+
tracker.failure = "n/a"
|
|
210
|
+
bump()
|
|
211
|
+
continue
|
|
212
|
+
}
|
|
213
|
+
|
|
253
214
|
const slots = await fetchSlots(baseUrl, model)
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
215
|
+
if (slots == null) {
|
|
216
|
+
const failures = (backoff?.failures ?? 0) + 1
|
|
217
|
+
const delay = backoffDelayMs(failures, BACKOFF_BASE_MS, BACKOFF_MAX_MS)
|
|
218
|
+
const jitter = Math.floor(Math.random() * (delay / 4))
|
|
219
|
+
backoffByUrl.set(baseUrl, {
|
|
220
|
+
failures,
|
|
221
|
+
nextRetryAt: Date.now() + Math.min(delay + jitter, BACKOFF_MAX_MS),
|
|
222
|
+
})
|
|
223
|
+
tracker.failure = "n/a"
|
|
224
|
+
bump()
|
|
225
|
+
continue
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
backoffByUrl.delete(baseUrl)
|
|
229
|
+
const slotList = Array.isArray(slots) ? slots : Object.values(slots)
|
|
257
230
|
if (slotList.length === 0) {
|
|
258
231
|
tracker.failure = "n/a"
|
|
259
232
|
bump()
|
|
@@ -264,19 +237,6 @@ const tui: TuiPlugin = async (api) => {
|
|
|
264
237
|
|
|
265
238
|
const result = processPoll(slotList, tracker)
|
|
266
239
|
bump()
|
|
267
|
-
|
|
268
|
-
if (result.isPrefilling) {
|
|
269
|
-
debug(`PP rate=${Math.round(result.lastPrefillRate)} tps`)
|
|
270
|
-
}
|
|
271
|
-
if (result.isGenerating) {
|
|
272
|
-
debug(`TG rate=${Math.round(result.lastGeneratedTps)} tps`)
|
|
273
|
-
}
|
|
274
|
-
if (result.ppEnded) {
|
|
275
|
-
debug(`PP ended rate=${Math.round(result.lastPrefillRate)} tps`)
|
|
276
|
-
}
|
|
277
|
-
if (result.tgEnded) {
|
|
278
|
-
debug(`TG ended rate=${Math.round(result.lastGeneratedTps)} tps`)
|
|
279
|
-
}
|
|
280
240
|
}
|
|
281
241
|
}
|
|
282
242
|
|
|
@@ -337,7 +297,6 @@ const tui: TuiPlugin = async (api) => {
|
|
|
337
297
|
})
|
|
338
298
|
|
|
339
299
|
const timer = setInterval(() => {
|
|
340
|
-
setClock(Date.now())
|
|
341
300
|
pruneSamples()
|
|
342
301
|
}, 1000)
|
|
343
302
|
|
|
@@ -354,18 +313,21 @@ const tui: TuiPlugin = async (api) => {
|
|
|
354
313
|
})
|
|
355
314
|
|
|
356
315
|
try {
|
|
357
|
-
|
|
358
|
-
llamaServerUrls = configUrls.length > 0 ? configUrls : ["http://localhost:8080"]
|
|
316
|
+
llamaServerUrls = resolveServerUrls(options, api.state.provider, api.state.config)
|
|
359
317
|
} catch (e) {
|
|
360
|
-
console.error("[oc-ls-stats]
|
|
318
|
+
console.error("[oc-ls-stats] resolveServerUrls error:", e)
|
|
361
319
|
llamaServerUrls = ["http://localhost:8080"]
|
|
362
320
|
}
|
|
363
321
|
|
|
364
322
|
api.slots.register({
|
|
365
323
|
slots: {
|
|
366
324
|
session_prompt_right(_ctx, value) {
|
|
367
|
-
|
|
368
|
-
|
|
325
|
+
return <SessionPromptRight api={api} sessionID={value.session_id} tracker={tracker} subscribe={(listener) => {
|
|
326
|
+
listeners.add(listener)
|
|
327
|
+
return () => {
|
|
328
|
+
listeners.delete(listener)
|
|
329
|
+
}
|
|
330
|
+
}} />
|
|
369
331
|
},
|
|
370
332
|
},
|
|
371
333
|
})
|