opencode-visual-cache 1.6.2 → 1.6.4

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.
@@ -1 +1 @@
1
- export declare const PLUGIN_VERSION = "1.6.2";
1
+ export declare const PLUGIN_VERSION = "1.6.4";
package/dist/_version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // auto-generated
2
- export const PLUGIN_VERSION = "1.6.2";
2
+ export const PLUGIN_VERSION = "1.6.4";
@@ -103,8 +103,34 @@ const moonshotProvider = {
103
103
  return [{ currency: "CNY", total: String(balance) }];
104
104
  },
105
105
  };
106
+ const hyperProvider = {
107
+ id: "hyper",
108
+ name: "Charm Hyper",
109
+ keyPlaceholder: "sk-hyper-...",
110
+ async fetchBalance(apiKey, signal) {
111
+ // 官方接口:GET /v1/credits → {"balance": 98}(积分余额)
112
+ const res = await fetch("https://hyper.charm.land/v1/credits", {
113
+ headers: { Authorization: `Bearer ${apiKey}`, Accept: "application/json" },
114
+ signal,
115
+ });
116
+ if (!res.ok) {
117
+ if (res.status === 401)
118
+ throw new BalanceError("401");
119
+ if (res.status === 403)
120
+ throw new BalanceError("403");
121
+ throw new BalanceError(String(res.status));
122
+ }
123
+ const json = await res.json();
124
+ const balance = json.balance;
125
+ if (typeof balance === "undefined" || balance === null)
126
+ throw new BalanceError("EMPTY");
127
+ // hyper 积分换算:100 积分 = $5,即 1 积分 = $0.05
128
+ const usd = (Number(balance) * 0.05).toFixed(2);
129
+ return [{ currency: "USD", total: usd }];
130
+ },
131
+ };
106
132
  /** 已注册的 provider 列表(按需追加新适配器)。 */
107
- export const balanceProviders = [deepseekProvider, siliconflowProvider, openrouterProvider, moonshotProvider];
133
+ export const balanceProviders = [deepseekProvider, siliconflowProvider, openrouterProvider, moonshotProvider, hyperProvider];
108
134
  /** 按 id 取 provider;未知 id 回退到第一个。 */
109
135
  export function getBalanceProvider(id) {
110
136
  return balanceProviders.find((p) => p.id === id) ?? balanceProviders[0] ?? deepseekProvider;
package/dist/index.js CHANGED
@@ -1231,7 +1231,10 @@ const tui = async (api) => {
1231
1231
  order: 55,
1232
1232
  slots: {
1233
1233
  session_prompt(_ctx, input) {
1234
- return (_jsx(api.ui.Prompt, { sessionID: input.session_id, visible: input.visible, disabled: input.disabled, onSubmit: input.on_submit, ref: input.ref, hint: _jsx(BottomStatusBar, { api: api, signals: signals, sessionId: input.session_id }) }));
1234
+ return (_jsx(api.ui.Prompt, { sessionID: input.session_id, visible: input.visible, disabled: input.disabled, onSubmit: input.on_submit, ref: input.ref, hint: _jsx(BottomStatusBar, { api: api, signals: signals, sessionId: input.session_id }),
1235
+ // 接管 session_prompt 后需透传宿主的 session_prompt_right 插槽,
1236
+ // 否则 oc-tps 等依赖该插槽的插件无法显示;无注册时 Slot 为 null。
1237
+ right: _jsx(api.ui.Slot, { name: "session_prompt_right", session_id: input.session_id }) }));
1235
1238
  },
1236
1239
  },
1237
1240
  });
package/dist/tui.js CHANGED
@@ -13,7 +13,7 @@ import { createElement as _$createElement } from "@opentui/solid";
13
13
  import { createMemo, createSignal, createEffect, onMount, onCleanup, Show, For, untrack } from "solid-js";
14
14
 
15
15
  // src/_version.ts
16
- var PLUGIN_VERSION = "1.6.2";
16
+ var PLUGIN_VERSION = "1.6.4";
17
17
 
18
18
  // src/balance-providers.ts
19
19
  var BalanceError = class extends Error {
@@ -101,7 +101,28 @@ var moonshotProvider = {
101
101
  return [{ currency: "CNY", total: String(balance) }];
102
102
  }
103
103
  };
104
- var balanceProviders = [deepseekProvider, siliconflowProvider, openrouterProvider, moonshotProvider];
104
+ var hyperProvider = {
105
+ id: "hyper",
106
+ name: "Charm Hyper",
107
+ keyPlaceholder: "sk-hyper-...",
108
+ async fetchBalance(apiKey, signal) {
109
+ const res = await fetch("https://hyper.charm.land/v1/credits", {
110
+ headers: { Authorization: `Bearer ${apiKey}`, Accept: "application/json" },
111
+ signal
112
+ });
113
+ if (!res.ok) {
114
+ if (res.status === 401) throw new BalanceError("401");
115
+ if (res.status === 403) throw new BalanceError("403");
116
+ throw new BalanceError(String(res.status));
117
+ }
118
+ const json = await res.json();
119
+ const balance = json.balance;
120
+ if (typeof balance === "undefined" || balance === null) throw new BalanceError("EMPTY");
121
+ const usd = (Number(balance) * 0.05).toFixed(2);
122
+ return [{ currency: "USD", total: usd }];
123
+ }
124
+ };
125
+ var balanceProviders = [deepseekProvider, siliconflowProvider, openrouterProvider, moonshotProvider, hyperProvider];
105
126
  function getBalanceProvider(id) {
106
127
  return balanceProviders.find((p) => p.id === id) ?? balanceProviders[0] ?? deepseekProvider;
107
128
  }
@@ -2401,6 +2422,14 @@ var tui = async (api) => {
2401
2422
  return input.session_id;
2402
2423
  }
2403
2424
  });
2425
+ },
2426
+ get right() {
2427
+ return _$createComponent(api.ui.Slot, {
2428
+ name: "session_prompt_right",
2429
+ get session_id() {
2430
+ return input.session_id;
2431
+ }
2432
+ });
2404
2433
  }
2405
2434
  });
2406
2435
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-visual-cache",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "OpenCode TUI plugin displaying real-time token cache hit rate in the sidebar",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",
package/src/_version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // auto-generated
2
- export const PLUGIN_VERSION="1.6.2";
2
+ export const PLUGIN_VERSION="1.6.4";
@@ -125,8 +125,32 @@ const moonshotProvider: BalanceProvider = {
125
125
  },
126
126
  }
127
127
 
128
+ const hyperProvider: BalanceProvider = {
129
+ id: "hyper",
130
+ name: "Charm Hyper",
131
+ keyPlaceholder: "sk-hyper-...",
132
+ async fetchBalance(apiKey, signal) {
133
+ // 官方接口:GET /v1/credits → {"balance": 98}(积分余额)
134
+ const res = await fetch("https://hyper.charm.land/v1/credits", {
135
+ headers: { Authorization: `Bearer ${apiKey}`, Accept: "application/json" },
136
+ signal,
137
+ })
138
+ if (!res.ok) {
139
+ if (res.status === 401) throw new BalanceError("401")
140
+ if (res.status === 403) throw new BalanceError("403")
141
+ throw new BalanceError(String(res.status))
142
+ }
143
+ const json = await res.json() as { balance?: string | number }
144
+ const balance = json.balance
145
+ if (typeof balance === "undefined" || balance === null) throw new BalanceError("EMPTY")
146
+ // hyper 积分换算:100 积分 = $5,即 1 积分 = $0.05
147
+ const usd = (Number(balance) * 0.05).toFixed(2)
148
+ return [{ currency: "USD", total: usd }]
149
+ },
150
+ }
151
+
128
152
  /** 已注册的 provider 列表(按需追加新适配器)。 */
129
- export const balanceProviders: BalanceProvider[] = [deepseekProvider, siliconflowProvider, openrouterProvider, moonshotProvider]
153
+ export const balanceProviders: BalanceProvider[] = [deepseekProvider, siliconflowProvider, openrouterProvider, moonshotProvider, hyperProvider]
130
154
 
131
155
  /** 按 id 取 provider;未知 id 回退到第一个。 */
132
156
  export function getBalanceProvider(id: string): BalanceProvider {
package/src/index.tsx CHANGED
@@ -1578,6 +1578,9 @@ const tui: TuiPlugin = async (api: TuiPluginApi) => {
1578
1578
  onSubmit={input.on_submit}
1579
1579
  ref={input.ref}
1580
1580
  hint={<BottomStatusBar api={api} signals={signals} sessionId={input.session_id} />}
1581
+ // 接管 session_prompt 后需透传宿主的 session_prompt_right 插槽,
1582
+ // 否则 oc-tps 等依赖该插槽的插件无法显示;无注册时 Slot 为 null。
1583
+ right={<api.ui.Slot name="session_prompt_right" session_id={input.session_id} />}
1581
1584
  />
1582
1585
  )
1583
1586
  },