dsh-ollama-usage 0.1.1 → 0.1.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/lib/index.js +22 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -372,14 +372,29 @@ async function handleBridgeRequest(req, res) {
|
|
|
372
372
|
export default {
|
|
373
373
|
inject: ['timer'],
|
|
374
374
|
apply(ctx) {
|
|
375
|
+
// 1) RPC 路由优先注册:即使后续步骤失败,路由也已生效
|
|
375
376
|
const webServer = ctx.get('webServer')
|
|
376
|
-
if (webServer
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
377
|
+
if (webServer === undefined) {
|
|
378
|
+
console.error('[ollama-usage] webServer 服务不可用,跳过 RPC 路由注册')
|
|
379
|
+
} else {
|
|
380
|
+
try {
|
|
381
|
+
ctx.effect(
|
|
382
|
+
() => webServer.register({ kind: 'prefix', path: RPC_CHANNEL, handler: handleBridgeRequest }),
|
|
383
|
+
'ollama-usage: rpc bridge',
|
|
384
|
+
)
|
|
385
|
+
console.log('[ollama-usage] RPC 路由已注册: ' + RPC_CHANNEL)
|
|
386
|
+
} catch (e) {
|
|
387
|
+
console.error('[ollama-usage] 路由注册失败: ' + String((e && e.message) || e))
|
|
388
|
+
}
|
|
381
389
|
}
|
|
382
|
-
|
|
383
|
-
|
|
390
|
+
// 2) 自动刷新:失败不影响插件启动
|
|
391
|
+
try {
|
|
392
|
+
ctx.effect(() => ctx.interval(autoRefresh, AUTO_REFRESH_MS), 'ollama-usage: auto refresh')
|
|
393
|
+
} catch (e) {
|
|
394
|
+
console.error('[ollama-usage] 自动刷新定时器不可用: ' + String((e && e.message) || e))
|
|
395
|
+
}
|
|
396
|
+
autoRefresh().catch((e) => {
|
|
397
|
+
console.error('[ollama-usage] 首次自动刷新失败: ' + String((e && e.message) || e))
|
|
398
|
+
})
|
|
384
399
|
},
|
|
385
400
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ollama-usage",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "DeepSeek Harness 插件:可视化 Ollama Cloud 账号用量余量(每 5 小时会话用量 + 周用量),支持侧边栏双横条、设置页面板、API Key 与用量快照持久化、自动刷新与登录引导。Ollama Pro usage & remaining-quota visualization for DeepSeek Harness: 5-hour session + weekly quota bars in the sidebar footer, a full settings panel, persisted API key and usage snapshots, auto-refresh and login guidance.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|