@qthinker/opencode-deepseek-search 0.2.1 → 0.3.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 CHANGED
@@ -3,6 +3,51 @@
3
3
  All notable changes to this package. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
4
4
  and the version numbers follow [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [0.3.2] - 2026-11-04
7
+
8
+ ### Added
9
+
10
+ - **Account balance in both sidebars**: the server probes `GET /user/balance`
11
+ (<https://api-docs.deepseek.com/zh-cn/api/get-user-balance>) with the same API key and serves a
12
+ cached snapshot through the `status` RPC as an optional `balance` field — 60s TTL, at most one upstream request
13
+ per minute, failures keep the last snapshot, and the balance is absent until the first successful probe. The TUI
14
+ card closes its body with the balance (warning-colored when the account cannot pay, dropped below ~12 columns
15
+ instead of squeezed, shown only in the two states that point at the account); the desktop panel shows an account
16
+ block below the usage table with the granted/topped-up split on hover (shown only when both components are
17
+ non-zero). Manual refresh (the desktop refresh
18
+ button, the TUI dialog's *Refresh*, both retry paths) forces a re-probe; the 10-second polls never do.
19
+ - **Sidebar display overhaul**: the usage ladders now put money before words (the cost survives to much narrower
20
+ widths in every language, and the old words-only rungs that outranked a cheaper money row are gone), below the
21
+ numeric floor the three usage rows collapse into one digit-carrying row instead of bare labels, the TUI body
22
+ gained three text tiers plus a 2-column indent on wider sidebars, the state word goes bold when the glyph is
23
+ dropped, and the desktop panel tightens its table typography (10px chunk gaps, trailing separators removed,
24
+ letter-spacing on Latin labels only, a 12px glyph cell, money chunks that never wrap away from their digits).
25
+
26
+ ### Removed
27
+
28
+ - `tools/switch-mode.ps1`, the terminal helper that rewrote `options.mode` in `opencode.jsonc`. The switch has lived in
29
+ plugin storage (`mode/v1`) since the first release and `deepseek_mode` covers the terminal case, so the script only
30
+ duplicated it — and on Windows PowerShell 5.1 its `Set-Content -Encoding UTF8` wrote a BOM, after which
31
+ `opencode plugin add/update/remove` rejected the whole config as invalid.
32
+
33
+ ## [0.3.0] - 2026-11-02
34
+
35
+ ### Added
36
+
37
+ - **UI languages `en` / `ja` / `zh-CN`**: the server resolves the language once (`options.language` > `LC_ALL`/`LANG` >
38
+ English) and carries it to both sidebars over RPC, so tool output, the TUI card, the desktop panel, commands, menus
39
+ and dialogs always speak the same language. Every language owns its narrow-width ladder; the Japanese copy is new and
40
+ the Chinese copy keeps the previous wording.
41
+ - `options.language` (`"en" | "ja" | "zh-CN"`, unset = auto). An unknown value logs a warning and falls back to
42
+ auto-detection instead of blocking the plugin.
43
+
44
+ ### Changed
45
+
46
+ - **The default UI language is now English.** To keep the previous Chinese interface, set `"language": "zh-CN"` in the
47
+ plugin options; the sidebars pick it up on their next status read (a restart always works).
48
+ - Console diagnostics are English in every language, and the `deepseek_fetch` Markdown header follows the UI language
49
+ instead of a hardcoded Chinese `来源:`.
50
+
6
51
  ## [0.2.1] - 2026-11-02
7
52
 
8
53
  ### Changed
package/README.md CHANGED
@@ -6,18 +6,18 @@
6
6
  [![opencode](https://img.shields.io/badge/opencode-%E2%89%A52.2.5-black)](https://opencode.ai)
7
7
 
8
8
  DeepSeek Search & Fetch as an OpenCode V2 plugin: **the built-in `websearch` tool routes to DeepSeek**, plus a clean
9
- Markdown fetch tool, local usage/cost stats, a **persisted** backend switch, and **TUI + desktop sidebars** that show
10
- the state and the numbers and flip the takeover with one click.
9
+ Markdown fetch tool, local usage/cost stats, your **live account balance**, a **persisted** backend switch, and
10
+ **TUI + desktop sidebars** that show the state, the numbers and the balance, and flip the takeover with one click.
11
11
 
12
- Ways back to native search: the sidebar switch, the `mode` option, a `deepseek_mode` call, or
13
- `tools/switch-mode.ps1` from the repo.
12
+ Ways back to native search: the sidebar switch, the `mode` option, or a `deepseek_mode` call.
14
13
  中文说明见 [docs/README.zh-CN.md](https://github.com/QThinkerJR/opencode-deepseek-search/blob/main/docs/README.zh-CN.md)。
15
14
 
16
15
  Differs from the existing same-named V1 package: this one targets the **V2 plugin API**, switches backends **at
17
16
  runtime**, and reports **local usage and estimated cost**.
18
17
 
19
18
  > Verified against `opencode 2.2.5` with `@opencode/plugin@2.2.5` on Windows. Search/Fetch API facts come from
20
- > <https://api-docs.deepseek.com/zh-cn/guides/search>.
19
+ > <https://api-docs.deepseek.com/zh-cn/guides/search>; the balance endpoint from
20
+ > <https://api-docs.deepseek.com/zh-cn/api/get-user-balance>.
21
21
 
22
22
  ## Requirements
23
23
 
@@ -45,7 +45,11 @@ Then add the plugin to `opencode.jsonc`:
45
45
  }
46
46
  ```
47
47
 
48
- > **Which file loads which half.** The server plugin and the desktop panel are read from `opencode.json(c)` — the desktop app reads only that file, and a **global** `~/.config/opencode/opencode.jsonc` entry is what makes the panel appear in every window. The TUI half is read from `cli.json` (`"plugins": [...]`). So a plugin is enabled per half: list it in each file whose half you want, whether it comes from npm (by package name) or from a local directory (by path).
48
+ > **One entry is enough.** A plugin listed in `opencode.json(c)` is enabled for the server **and** for both sidebars:
49
+ > the TUI and the desktop load the corresponding half of every active plugin that ships one. Verified: with the plugin
50
+ > listed only in the global `~/.config/opencode/opencode.jsonc`, both the TUI card and the desktop panel appear.
51
+ > `cli.json` (`"plugins": [...]`) is only for **TUI-only** plugins — packages without a server half, such as
52
+ > `opencode-go-usage-tui`. Keep the entry in the **global** `opencode.jsonc` so the desktop shows it in every window.
49
53
 
50
54
  With options (recommended — this is where `mode` and friends live):
51
55
 
@@ -56,6 +60,8 @@ With options (recommended — this is where `mode` and friends live):
56
60
  "package": "@qthinker/opencode-deepseek-search",
57
61
  "options": {
58
62
  "mode": "deepseek",
63
+ // "en" | "ja" | "zh-CN"; omit it to follow LC_ALL/LANG, then English
64
+ "language": "en",
59
65
  "count": 5,
60
66
  "apiKey": "{env:DEEPSEEK_API_KEY}"
61
67
  }
@@ -86,11 +92,21 @@ The other two halves are clients: restart the **TUI**, and reload the **desktop
86
92
  | Option | Type | Default | Meaning |
87
93
  |---|---|---|---|
88
94
  | `mode` | `"deepseek" \| "native"` | `deepseek` | Default backend for `websearch`; a persisted `deepseek_mode` switch overrides it |
95
+ | `language` | `"en" \| "ja" \| "zh-CN"` | auto | UI language for the sidebars, the desktop panel, `deepseek_*` tool output and errors. Auto reads `LC_ALL`, then `LANG`, then English |
89
96
  | `apiKey` | string | `DEEPSEEK_API_KEY` | Usually `"{env:DEEPSEEK_API_KEY}"`; unset env becomes `""` |
90
97
  | `count` | 1–50 | `5` | Results per search (does not change the price) |
91
98
  | `fetchMaxChars` | 500–200000 | `30000` | Truncation limit for `deepseek_fetch`, with an explicit notice |
92
99
  | `pricePerThousand` | 0–10000 | `5` | CNY per 1000 requests (integer), used only for the local cost estimate |
93
100
 
101
+ **UI languages.** The plugin ships `en`, `ja` and `zh-CN`; English is the default and the fallback. The server resolves
102
+ the language once — `options.language`, else the `LC_ALL`/`LANG` prefix (`ja*` → `ja`, `zh*` → `zh-CN`), else English —
103
+ and the same value drives the tool output and both sidebars, so they can never disagree. An unknown value logs a
104
+ warning and falls back to auto-detection instead of failing. The change reaches the sidebars with their next status
105
+ read (saving the config re-runs the server half; a restart always works). Model-facing text stays English in every
106
+ language — tool descriptions, the `## [title](url)` result format, `Published:` and the empty-result notice — so the
107
+ rerouted `websearch` keeps the built-in tool's shape. Docs stay English and Chinese: the Japanese UI does not add a
108
+ Japanese README.
109
+
94
110
  ## Tools
95
111
 
96
112
  | Tool | What it does |
@@ -110,10 +126,9 @@ and `need_content` is never requested.
110
126
 
111
127
  | Way | How | Persisted | Use it for |
112
128
  |---|---|---|---|
113
- | Sidebar | Click the action on the TUI card (`[停用]` / `[启用]`), or the panel's button | Yes (plugin storage `mode/v1`) | While you are working |
129
+ | Sidebar | Click the action on the TUI card (English UI: `[Disable]` / `[Enable]`; Chinese UI: `[停用]` / `[启用]`), or the panel's button | Yes (plugin storage `mode/v1`) | While you are working |
114
130
  | Config | Edit `options.mode`; applies on save | Yes (in the config file) | The long-term default |
115
131
  | Tool | Ask the model to call `deepseek_mode`, or call it yourself | Yes (plugin storage `mode/v1`) | Switching mid-session without touching files |
116
- | Script | `.\tools\switch-mode.ps1 native` | Yes (the script edits the config) | Quick switch from a terminal, no editor |
117
132
 
118
133
  `deepseek_mode` actions:
119
134
 
@@ -155,8 +170,8 @@ The plugin also shows up where you work, and can be switched without the model o
155
170
 
156
171
  | Surface | What you get | How to switch |
157
172
  |---|---|---|
158
- | TUI | A DeepSeek block appended to the session sidebar: state, then 今日 / 本月 / 累计 rows (`Search` · `Fetch` · `¥` estimate); it degrades to abbreviations and then to fewer columns as the sidebar narrows | Click the action at the right of the title, or run the `/deepseek` slash command for a menu |
159
- | Desktop | A **DeepSeek** tab in a session's side region, listed in the side region's *New tab* page and its `+` menu, and openable with the `DeepSeek: 打开统计面板` command | The panel's button, plus a refresh control |
173
+ | TUI | A DeepSeek block appended to the session sidebar: state, then Today / Month / Total rows (`Search` · `Fetch` · `¥` estimate) in the resolved UI language; it degrades to abbreviations and then to fewer columns as the sidebar narrows | Click the action at the right of the title, or run the `/deepseek` slash command for a menu |
174
+ | Desktop | A **DeepSeek** tab in a session's side region, listed in the side region's *New tab* page and its `+` menu, and openable with the `DeepSeek: Open usage panel` command (localized) | The panel's button, plus a refresh control |
160
175
 
161
176
  - Both surfaces read the same ledger and the same stored switch as `deepseek_usage` / `deepseek_mode`: a single
162
177
  server-side source, reached over the plugin's own RPC, so the numbers never diverge between TUI and desktop.
@@ -164,10 +179,22 @@ The plugin also shows up where you work, and can be switched without the model o
164
179
  It is not an uninstall: `deepseek_fetch`, `deepseek_usage` and `deepseek_mode` stay registered, and the state is
165
180
  persisted in `mode/v1` like any other switch.
166
181
  - The action row always says what a click does. When no API key is configured there is no action to take, so it shows
167
- the fix instead (`DEEPSEEK_API_KEY`); when the built-in tool could not be patched it reports 未接管 rather than
168
- pretending to be enabled.
182
+ the fix instead (`DEEPSEEK_API_KEY`); when the built-in tool could not be patched it reports *not taken over* rather
183
+ than pretending to be enabled.
169
184
  - Stats refresh on a `changed` event emitted after every tally and every switch, with a 10-second reread as a
170
185
  fallback in both surfaces.
186
+ - The body closes with your **account balance**, read from `GET /user/balance` with the same API key
187
+ (<https://api-docs.deepseek.com/zh-cn/api/get-user-balance>) — the usage rows read as the receipt and the account
188
+ truth lands under them. It shows in the two states where the card
189
+ actually points at the account (takeover enabled, or native mode); an unavailable balance gets a warning-colored
190
+ amount, and below ~12 columns the row is dropped rather than squeezed. The server serves a snapshot cached for
191
+ 60 seconds — at most one upstream request per minute, failures keep the last value — and only a manual refresh
192
+ (the desktop refresh button, the TUI menu's *Refresh*, both retry paths) forces a re-probe; the 10-second polls
193
+ never do. The desktop panel shows it as an account block below the usage table, with the granted/topped-up
194
+ split on hover (when the split is meaningful).
195
+ - The usage ladder puts **money before words**: as the sidebar narrows, the cost survives longer than the wordy
196
+ labels, and below the numeric floor the three usage rows collapse into one row that still carries a number
197
+ instead of three bare labels.
171
198
 
172
199
  The desktop half ships as a prebuilt CommonJS bundle (`gui-experimental.cjs`). Published packages include it; if you
173
200
  run the plugin from a clone, build it once — the TUI half needs no build and loads from TypeScript like the server half:
@@ -212,15 +239,15 @@ contain text that tries to steer the model.
212
239
  |---|---|
213
240
  | Unsure which backend search uses | Call `deepseek_mode` — it reports the backend **and** its source |
214
241
  | Config edit seems ignored | A persisted switch is present (the source says so); clear it with `deepseek_mode({"mode": "config"})` |
215
- | `未配置 DeepSeek API Key` (missing key) | Set `DEEPSEEK_API_KEY`, restart the OpenCode service once so the new process inherits it |
242
+ | `未配置 DeepSeek API Key` (zh-CN UI; `API key missing` elsewhere) | Set `DEEPSEEK_API_KEY`, restart the OpenCode service once so the new process inherits it |
216
243
  | `401` invalid key | Check the key and that `apiKey`/env points at it |
217
244
  | `402` insufficient balance | Top up; failed requests are not billed |
218
245
  | `429` rate limited | Backed off once already; retry later |
219
246
  | `403` / `404` on fetch | The site blocks extraction or the page has no readable text; try the built-in `webfetch` |
220
247
  | Search still hits the native backend | `mode` or the persisted switch is `native`; if both are `deepseek`, the built-in `websearch` tool was not found — use config `"websearch": { "provider": "deepseek" }` |
221
- | TUI sidebar has no DeepSeek card | The TUI half is enabled in `cli.json` (`"plugins": [...]`), not in `opencode.jsonc`; add the path/package there and restart the TUI |
248
+ | TUI sidebar has no DeepSeek card | Check `opencode plugin list`: the card comes from the **active server plugin**, so `opencode.json(c)` is what matters — `cli.json` does not need it. Restart the TUI after installing |
222
249
  | Desktop has no DeepSeek entry in the *New tab* list | The desktop reads plugins from the **global** `opencode.jsonc`, and its bundle must exist — run `npm run build:gui` when working from a clone, then reload the window |
223
- | Sidebar says `读取失败` | The half cannot reach the RPC: check `opencode plugin list` reports `deepseek-search` as active, then look for `/api/rpc/deepseek-search/status` in `~/.local/share/opencode/log/opencode.log`. A `400 rpc.invalid_input` means a half and the server disagree on the contract — reload that client |
250
+ | Sidebar says `读取失败` (zh-CN UI; `Read failed` elsewhere) | The half cannot reach the RPC: check `opencode plugin list` reports `deepseek-search` as active, then look for `/api/rpc/deepseek-search/status` in `~/.local/share/opencode/log/opencode.log`. A `400 rpc.invalid_input` means a half and the server disagree on the contract — reload that client |
224
251
 
225
252
  ## Local development
226
253
 
@@ -235,33 +262,13 @@ npm run smoke # real API smoke; skipped without DEEPSEEK_API_KEY
235
262
  npm pack --dry-run # audit the publish artifacts — run build:gui first, `pack` does not build the bundle
236
263
  ```
237
264
 
238
- One-command switch (repo-only helper; edits `options.mode` in `opencode.jsonc`, backing it up to `opencode.jsonc.bak-switch`):
239
-
240
- ```powershell
241
- .\tools\switch-mode.ps1 status
242
- .\tools\switch-mode.ps1 native
243
- .\tools\switch-mode.ps1 deepseek
244
- ```
245
-
246
- If ExecutionPolicy blocks it:
247
-
248
- ```powershell
249
- powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\switch-mode.ps1 native
250
- ```
251
-
252
- Shorter, via an alias in `$PROFILE`:
253
-
254
- ```powershell
255
- function dsmode { & "D:\repos\opencode-deepseek-search\tools\switch-mode.ps1" @args }
256
- ```
257
-
258
265
  Layout:
259
266
 
260
267
  ```
261
268
  index.ts # directory-plugin entry, re-exports src/index.ts
262
269
  tui.ts # TUI entry, re-exports src/tui/main.ts
263
270
  src/index.ts # plugin: options, registration, websearch patch, three tools
264
- src/deepseek.ts # HTTP core: timeout/cancel, single backoff retry, Chinese errors, mapping
271
+ src/deepseek.ts # HTTP core: timeout/cancel, single backoff retry, localized errors, mapping
265
272
  src/usage.ts # pure ledger: micro-CNY pricing, 60-day prune, defensive parse, formatting
266
273
  src/rpc.ts # RPC contract shared by the server, TUI and desktop halves
267
274
  src/status-view.ts # pure view model both sidebars derive their copy from
@@ -271,7 +278,6 @@ vite.config.ts # builds src/gui into the root gui-experimental.cjs bundle
271
278
  test/*.test.ts # pure-function tests
272
279
  scripts/smoke.ts # real-API smoke (5 steps)
273
280
  scripts/check-gui-bundle.ts # bundle shape check, run in CI after build:gui
274
- tools/switch-mode.ps1 # terminal backend switch
275
281
  .github/workflows/ # ci (build + typecheck + test + bundle check) / release
276
282
  ```
277
283
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("solid-js/web"),_=require("@opencode/plugin/gui"),y=require("solid-js"),Y="deepseek-search",k={type:"object",properties:{search:{type:"integer"},fetch:{type:"integer"},empty:{type:"integer"},failed:{type:"integer"},costMicro:{type:"integer"}},required:["search","fetch","empty","failed","costMicro"],additionalProperties:!1},j={id:Y,methods:{status:{input:{type:"object",properties:{},additionalProperties:!1},output:{type:"object",properties:{mode:{type:"string",enum:["deepseek","native"]},source:{type:"string",enum:["override","config"]},patched:{type:"boolean"},hasKey:{type:"boolean"},pricePerThousand:{type:"number"},today:{type:"string"},month:{type:"string"},total:{type:"string"},counts:{type:"object",properties:{today:k,month:k,total:k},required:["today","month","total"],additionalProperties:!1}},required:["mode","source","patched","hasKey","pricePerThousand","today","month","total"],additionalProperties:!1}},setMode:{input:{type:"object",properties:{mode:{type:"string",enum:["deepseek","native","config"]}},required:["mode"],additionalProperties:!1},output:{type:"object",properties:{ok:{type:"boolean"},mode:{type:"string"},message:{type:"string"}},required:["ok","mode","message"],additionalProperties:!1}}},events:{changed:{schema:{type:"object",properties:{}}}}};function E(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function z(t){return t==="deepseek"||t==="native"}function x(t){if(!E(t))return;const{search:e,fetch:r,empty:n,failed:i,costMicro:s}=t;for(const d of[e,r,n,i])if(typeof d!="number"||!Number.isInteger(d)||d<0)return;if(!(typeof s!="number"||!Number.isFinite(s)||s<0))return{search:e,fetch:r,empty:n,failed:i,costMicro:s}}function B(t){if(!E(t))return;const{mode:e,source:r,patched:n,hasKey:i,pricePerThousand:s,today:d,month:u,total:p,counts:a}=t;if(!z(e)||r!=="override"&&r!=="config"||typeof n!="boolean"||typeof i!="boolean"||typeof s!="number"||!Number.isFinite(s)||typeof d!="string"||typeof u!="string"||typeof p!="string")return;const c={mode:e,source:r,patched:n,hasKey:i,pricePerThousand:s,today:d,month:u,total:p};if(E(a)){const f=x(a.today),m=x(a.month),h=x(a.total);f&&m&&h&&(c.counts={today:f,month:m,total:h})}return c}function q(t){if(!E(t))return;const{ok:e,mode:r,message:n}=t;if(!(typeof e!="boolean"||typeof r!="string"||typeof n!="string"))return{ok:e,mode:r,message:n}}const U="DeepSeek search/fetch",D="DeepSeek",H=2,V=1,W=24,N=["today","month","total"],O={today:"今日",month:"本月",total:"累计"};function R(t){const e=t.codePointAt(0)??0;return e===0?0:e>=4352&&e<=4447||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=129791||e>=131072&&e<=262141?2:1}function b(t){let e=0;for(const r of t)e+=R(r);return e}function S(t,e){if(e<1)return"";if(b(t)<=e)return t;let r="",n=0;for(const i of t){const s=R(i);if(n+s>e-1)return`${r}…`;r+=i,n+=s}return r}function G(t,e){const r=t.replace(/\s+/g," ").trim();return S(r||"读取失败",e)}function L(t){let r=(Number.isFinite(t)&&t>0?t/1e6:0).toFixed(3);for(;r.endsWith("0")&&r.length>4;)r=r.slice(0,-1);return`¥${r}`}function J(t){const e=N.map(r=>t[r]);return{search:Math.max(...e.map(r=>String(r.search).length)),fetch:Math.max(...e.map(r=>String(r.fetch).length)),cost:Math.max(...e.map(r=>L(r.costMicro).length))}}function X(t,e,r,n){const i=O[t],s=String(e.search).padStart(r.search," "),d=String(e.fetch).padStart(r.fetch," "),u=L(e.costMicro).padStart(r.cost," "),p=[`${i} Search ${s} Fetch ${d} ${u}`,`${i} Search ${s} Fetch ${d} ${u}`,`${i} Search ${s} Fetch ${d}`,`${i} Search ${s} Fetch ${d}`,`${i} ${s}S ${d}F ${u}`,`${i} ${s}S ${d}F`,`${i} ${s}S`];for(const a of p)if(b(a)<=n)return a;return b(i)<=n?i:S(i,n)}function Q(t,e,r){const n=O[t],i=`${n} ${e}`;if(b(i)<=r)return i;const s=e.split(" · ").filter(u=>!u.startsWith("¥")&&!u.startsWith("空/失")),d=[`${n} ${s.join(" ")}`.trimEnd(),`${n} ${s[0]??""}`.trimEnd(),n];for(const u of d)if(b(u)<=r)return u;return S(n,r)}function Z(t,e){if(e===Number.POSITIVE_INFINITY)return[`今日 ${t.today}`,`本月 ${t.month}`,`累计 ${t.total}`];const r=t.counts;if(r){const n=J(r);return N.map(i=>X(i,r[i],n,e))}return N.map(n=>Q(n,t[n],e))}function ee(t,e){const r=`[${t}]`;if(e===Number.POSITIVE_INFINITY||b(r)<=e)return r;const n=e-2;return n>=1?`[${S(t,n)}]`:S(r,e)}function C(t,e,r,n){const i=(p,a)=>{if(r===Number.POSITIVE_INFINITY)return Number.POSITIVE_INFINITY;const c=p?H:0,f=n===void 0||a?0:n+V;return Math.max(0,r-c-f)},s=[`${U} · ${t}`,`${D} · ${t}`,`${D} · ${e}`,t,e],d=n===void 0?[!1]:[!1,!0];for(const p of s)for(const a of d)for(const c of[!0,!1])if(b(p)<=i(c,a))return{title:p,glyph:c,actionBelow:a};const u=n!==void 0;return{title:S(e,i(!1,u)),glyph:!1,actionBelow:u}}function te(t){const e=["设置 DEEPSEEK_API_KEY 后重启","设置 API KEY 后重启","设置 API KEY","设置 KEY"];if(t===Number.POSITIVE_INFINITY)return e[0];for(const r of e)if(b(r)<=t)return r;return S(e[e.length-1],t)}function P(t,e,r,n){const i=ee(r,n);return{...C(t,e,n,b(i)),action:i}}function re(t){const{status:e,error:r}=t,n=t.maxColumns??W,i=e===void 0?[]:Z(e,n);if(e===void 0)return r===void 0||r.trim()===""?{...P("正在读取…","正在读取…","重试",n),hint:void 0,clickable:!0,lines:i,tone:"idle"}:{...P("读取失败","读取失败","重试",n),hint:void 0,clickable:!0,lines:[G(r,n)],tone:"error"};if(e.patched&&e.hasKey)return{...P("已启用","已启用","停用",n),hint:void 0,clickable:!0,lines:i,tone:"on"};if(!e.patched&&e.mode==="deepseek")return{...P("未接管内置 websearch","未接管","交还",n),hint:void 0,clickable:!0,lines:i,tone:"warn"};if(e.mode==="native")return{...P("已停用","已停用","启用",n),hint:void 0,clickable:!0,lines:i,tone:"off"};const s=te(n);return{...C("未配置 API Key","缺 API Key",n,void 0),action:s,hint:s,clickable:!1,lines:i,tone:"error"}}var F=o.template("<span>"),ne=o.template("<span style=opacity:0.6;font-weight:400>"),oe=o.template("<span style=opacity:0.3;font-weight:400> · "),ie=o.template("<code style=font-size:0.94em>DEEPSEEK_API_KEY"),se=o.template('<p style="margin:16px 0 0;font-size:12px;line-height:1.6;opacity:0.68;overflow-wrap:anywhere">'),ae=o.template("<div style=margin-top:18px>"),le=o.template('<div style="display:flex;flex-direction:column;height:100%;min-width:0;box-sizing:border-box;padding:16px 16px 24px;overflow-y:auto;overflow-x:hidden"><header style=display:flex;align-items:flex-start;gap:8px><span aria-hidden=true style=flex-shrink:0;font-size:10px;line-height:20px;font-weight:700></span><h2 aria-live=polite style=flex:1;min-width:0;margin:0;font-size:13px;font-weight:600;line-height:20px;overflow-wrap:anywhere>'),ce=o.template('<p style="margin:14px 0 0;font-size:12px;line-height:1.6;opacity:0.7;overflow-wrap:anywhere">'),de=o.template("<div style=display:flex;align-items:center;gap:8px;margin-top:14px;opacity:0.7><span style=font-size:12px>正在读取用量…"),ue=o.template('<dl style="margin:16px 0 0">'),fe=o.template('<div style="display:flex;align-items:baseline;gap:12px;padding:10px 0"><dt style=flex-shrink:0;font-size:11px;letter-spacing:0.08em;line-height:1.9;opacity:0.62></dt><dd style=margin:0;margin-left:auto;min-width:0;display:flex;flex-wrap:wrap;justify-content:flex-end;column-gap:6px;row-gap:2px;font-size:13px;line-height:1.55;font-variant-numeric:tabular-nums;text-align:right>'),pe=o.template("<span style=min-width:0;overflow-wrap:anywhere>");const he={on:"●",off:"○",warn:"◐",error:"!",idle:"…"},ye={dark:{on:"#63d19a",warn:"#e0ad4f",error:"#ee7b74",off:"#8b9198",idle:"#8b9198",rule:"rgba(255,255,255,0.14)"},light:{on:"#1e7a4c",warn:"#8a5f08",error:"#b03931",off:"#6b7076",idle:"#6b7076",rule:"rgba(0,0,0,0.13)"}},me={on:"停用(交还原生搜索)",off:"启用(由 DeepSeek 接管)",warn:"交还原生搜索",error:"重试",idle:"重试"},ge={on:"arrow-undo-down",off:"globe",warn:"arrow-undo-down",error:"refresh",idle:"refresh"};function ve(t,e){const r=t.indexOf(" · ");return r<0?(()=>{var n=F();return o.setStyleProperty(n,"color",e),o.insert(n,t),n})():[(()=>{var n=ne();return o.insert(n,()=>t.slice(0,r)),n})(),oe(),(()=>{var n=F();return o.setStyleProperty(n,"color",e),o.insert(n,()=>t.slice(r+3)),n})()]}function be(t){const e=t.indexOf(" ");return e<0?{label:t,chunks:[]}:{label:t.slice(0,e),chunks:t.slice(e+1).split(" · ")}}function $e(t,e){const r="DEEPSEEK_API_KEY",n=t.indexOf(r);return n<0?t:[o.memo(()=>t.slice(0,n)),(()=>{var i=ie();return o.setStyleProperty(i,"font-family",e),i})(),o.memo(()=>t.slice(n+r.length))]}function Se(t){const e=_.usePlugin(),r=y.createMemo(()=>re({status:t.status,error:t.error,maxColumns:1/0})),n=y.createMemo(()=>ye[e.appearance.mode()]),i=()=>e.appearance.font("mono");return y.onMount(()=>{const s=setInterval(()=>t.onRefresh(),1e4);y.onCleanup(()=>clearInterval(s))}),(()=>{var s=le(),d=s.firstChild,u=d.firstChild,p=u.nextSibling;return o.insert(u,()=>he[r().tone]),o.insert(p,()=>ve(r().title,n()[r().tone])),o.insert(d,o.createComponent(e.ui.Tooltip,{value:"刷新用量",placement:"bottom",get children(){return o.createComponent(e.ui.IconButton,{icon:"refresh",label:"刷新用量",size:"small",get onClick(){return t.onRefresh}})}}),null),o.insert(s,(()=>{var a=o.memo(()=>t.status===void 0);return()=>a()?o.memo(()=>r().lines.length>0)()?(()=>{var c=ce();return o.insert(c,()=>r().lines[0]),c})():(()=>{var c=de(),f=c.firstChild;return o.insert(c,o.createComponent(e.ui.Loader,{size:"small"}),f),c})():(()=>{var c=ue();return o.insert(c,o.createComponent(y.For,{get each(){return r().lines},children:(f,m)=>{const h=be(f);return(()=>{var l=fe(),g=l.firstChild,T=g.nextSibling;return o.insert(g,()=>h.label),o.insert(T,o.createComponent(y.For,{get each(){return h.chunks},children:(v,I)=>(()=>{var $=pe();return o.insert($,v,null),o.insert($,()=>I()<h.chunks.length-1?" ·":"",null),o.effect(w=>{var M=v.startsWith("¥")?500:400,A=v.startsWith("¥")?1:.8;return M!==w.e&&o.setStyleProperty($,"font-weight",w.e=M),A!==w.t&&o.setStyleProperty($,"opacity",w.t=A),w},{e:void 0,t:void 0}),$})()})),o.effect(v=>{var I=m()>0?`1px solid ${n().rule}`:void 0,$=i();return I!==v.e&&o.setStyleProperty(l,"border-top",v.e=I),$!==v.t&&o.setStyleProperty(T,"font-family",v.t=$),v},{e:void 0,t:void 0}),l})()}})),o.effect(f=>{var m=`1px solid ${n().rule}`,h=`1px solid ${n().rule}`;return m!==f.e&&o.setStyleProperty(c,"border-top",f.e=m),h!==f.t&&o.setStyleProperty(c,"border-bottom",f.t=h),f},{e:void 0,t:void 0}),c})()})(),null),o.insert(s,o.createComponent(y.Show,{get when(){return!r().clickable},get children(){var a=se();return o.insert(a,()=>$e(r().action,i())),a}}),null),o.insert(s,o.createComponent(y.Show,{get when(){return o.memo(()=>!!r().clickable)()&&r().tone!=="idle"},get children(){var a=ae();return o.insert(a,o.createComponent(e.ui.Button,{get variant(){return r().tone==="off"||r().tone==="error"?"contrast":"neutral"},get icon(){return ge[r().tone]},get disabled(){return t.busy},get busy(){return t.busy},get onClick(){return t.onToggle},get children(){return me[r().tone]}})),a}}),null),o.effect(a=>{var c=t.busy||void 0,f=n()[r().tone];return c!==a.e&&o.setAttribute(s,"aria-busy",a.e=c),f!==a.t&&o.setStyleProperty(u,"color",a.t=f),a},{e:void 0,t:void 0}),s})()}const K={id:"main",title:"DeepSeek"},we=80,Pe=_.Plugin.define({setup(t){const e=t.client.rpc(j),[r,n]=y.createSignal(),[i,s]=y.createSignal(),[d,u]=y.createSignal(!1),p=l=>(l instanceof Error?l.message:String(l)).slice(0,we);async function a(){try{const l=B(await e.status({}));l?(n(l),s(void 0)):s("状态数据格式不符")}catch(l){s(p(l))}}async function c(l){u(!0);try{const g=q(await e.setMode({mode:l}));g?g.ok||t.toast.show({title:"DeepSeek",description:g.message,variant:"error"}):t.toast.show({title:"DeepSeek",description:"模式切换结果格式不符",variant:"error"})}catch(g){t.toast.show({title:"DeepSeek",description:p(g),variant:"error"})}finally{await a(),u(!1)}}function f(){const l=r();if(!l||i()){a();return}c(l.mode==="deepseek"?"native":"deepseek")}t.add(_.Panel,{id:"main",region:"side",mobile:{title:"DeepSeek",order:50,kind:"menu",icon:"globe"},list:l=>l.open.includes(K.id)?[K]:[],render:()=>o.createComponent(Se,{get status(){return r()},get error(){return i()},get busy(){return d()},onToggle:f,onRefresh:()=>{a()}})});const m=()=>{const l=t.sessions.current();if(!l){t.toast.show({title:"DeepSeek",description:"请先打开一个会话"});return}t.layout.open(`${t.id}:main`,l)};t.add(_.Command,{id:"open",title:"DeepSeek: 打开统计面板",section:"session",run:m}),t.add(_.MenuItem,()=>{const l=t.sessions.current();return{menu:"session.panel",id:"open",title:"DeepSeek",description:"搜索用量与接管开关",icon:"globe",order:60,opened:l!==void 0&&t.layout.stored(l).includes("main"),run:m}});const h=e.events.on("changed",()=>{a()});return a(),h}});exports.default=Pe;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("solid-js/web"),I=require("@opencode/plugin/gui"),k=require("solid-js"),z="deepseek-search";function j(e){return e==="en"||e==="ja"||e==="zh-CN"}const $={type:"object",properties:{search:{type:"integer"},fetch:{type:"integer"},empty:{type:"integer"},failed:{type:"integer"},costMicro:{type:"integer"}},required:["search","fetch","empty","failed","costMicro"],additionalProperties:!1},Q={type:"object",properties:{isAvailable:{type:"boolean"},currency:{type:"string"},totalBalance:{type:"string"},grantedBalance:{type:"string"},toppedUpBalance:{type:"string"},fetchedAt:{type:"number"}},required:["isAvailable","currency","totalBalance","grantedBalance","toppedUpBalance","fetchedAt"],additionalProperties:!1},V={id:z,methods:{status:{input:{type:"object",properties:{force:{type:"boolean"}},additionalProperties:!1},output:{type:"object",properties:{mode:{type:"string",enum:["deepseek","native"]},source:{type:"string",enum:["override","config"]},patched:{type:"boolean"},hasKey:{type:"boolean"},pricePerThousand:{type:"number"},today:{type:"string"},month:{type:"string"},total:{type:"string"},language:{type:"string",enum:["en","ja","zh-CN"]},counts:{type:"object",properties:{today:$,month:$,total:$},required:["today","month","total"],additionalProperties:!1},balance:Q},required:["mode","source","patched","hasKey","pricePerThousand","today","month","total"],additionalProperties:!1}},setMode:{input:{type:"object",properties:{mode:{type:"string",enum:["deepseek","native","config"]}},required:["mode"],additionalProperties:!1},output:{type:"object",properties:{ok:{type:"boolean"},mode:{type:"string"},message:{type:"string"}},required:["ok","mode","message"],additionalProperties:!1}}},events:{changed:{schema:{type:"object",properties:{}}}}};function K(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function G(e){return e==="deepseek"||e==="native"}function A(e){if(!K(e))return;const{search:t,fetch:o,empty:r,failed:n,costMicro:s}=e;for(const l of[t,o,r,n])if(typeof l!="number"||!Number.isInteger(l)||l<0)return;if(!(typeof s!="number"||!Number.isFinite(s)||s<0))return{search:t,fetch:o,empty:r,failed:n,costMicro:s}}function W(e){if(!K(e))return;const{isAvailable:t,currency:o,totalBalance:r,grantedBalance:n,toppedUpBalance:s,fetchedAt:l}=e;if(typeof t=="boolean"&&!(o!=="CNY"&&o!=="USD")){for(const i of[r,n,s])if(typeof i!="string"||i.length===0)return;if(!(typeof l!="number"||!Number.isFinite(l)||l<0))return{isAvailable:t,currency:o,totalBalance:r,grantedBalance:n,toppedUpBalance:s,fetchedAt:l}}}function J(e){if(!K(e))return;const{mode:t,source:o,patched:r,hasKey:n,pricePerThousand:s,today:l,month:i,total:u,language:b,counts:m,balance:f}=e;if(!G(t)||o!=="override"&&o!=="config"||typeof r!="boolean"||typeof n!="boolean"||typeof s!="number"||!Number.isFinite(s)||typeof l!="string"||typeof i!="string"||typeof u!="string")return;const h={mode:t,source:o,patched:r,hasKey:n,pricePerThousand:s,today:l,month:i,total:u,language:j(b)?b:"en"};if(K(m)){const S=A(m.today),d=A(m.month),g=A(m.total);S&&d&&g&&(h.counts={today:S,month:d,total:g})}const p=W(f);return p&&(h.balance=p),h}function X(e){if(!K(e))return;const{ok:t,mode:o,message:r}=e;if(!(typeof t!="boolean"||typeof o!="string"||typeof r!="string"))return{ok:t,mode:o,message:r}}const Z={"state.loading":"Loading…","state.loadingShort":"Loading…","state.failed":"Read failed","state.failedShort":"Failed","state.enabled":"Enabled","state.enabledShort":"On","state.disabled":"Disabled","state.disabledShort":"Off","state.unpatched":"websearch not taken over","state.unpatchedShort":"Not taken over","state.missingKey":"API key missing","state.missingKeyShort":"No API key","action.disable":"Disable","action.enable":"Enable","action.release":"Release","action.retry":"Retry","panel.tooltip.refresh":"Refresh usage","panel.loading":"Reading usage…","panel.label.on":"Disable (release to native search)","panel.label.off":"Enable (take over with DeepSeek)","panel.label.warn":"Release to native search","panel.label.error":"Retry","panel.label.idle":"Retry","command.open":"DeepSeek: Open usage panel","command.toggle":"DeepSeek: Enable/disable search takeover","menu.description":"Search usage and the takeover switch","toast.openSessionFirst":"Open a session first","toast.statusMalformed":"Status payload has the wrong shape","toast.modeMalformed":"Mode switch result has the wrong shape","dialog.title":"DeepSeek search","dialog.enable":"Enable","dialog.enableDesc":"Take over the built-in websearch","dialog.disable":"Disable","dialog.disableDesc":"Return the built-in websearch to the host","dialog.refresh":"Refresh","dialog.refreshDesc":"Re-read status and usage","mode.report":"Current search backend: {mode} (source: {source}){suffix}","mode.source.override":"deepseek_mode switch, persisted","mode.source.config":"config file options.mode","mode.suffix.patched":" · built-in websearch is served by DeepSeek","mode.suffix.notPatched":" · built-in websearch was not found, so nothing is taken over","mode.suffix.native":" · built-in websearch stays native","mode.notFound":'Built-in {tool} tool not found; it cannot be switched at runtime. Set options.mode to "{mode}" in the config file instead.',"mode.configCleared":"Persisted switch cleared; back to the config file ({mode}).","mode.persisted":'Persisted: still {mode} after restarting OpenCode. To return to the config file, call deepseek_mode with mode: "config".',"mode.statusOnly":"status only reports the current mode; it does not switch.","mode.invalid":"mode must be status / deepseek / native / config, got: {raw}","progress.fetch":"DeepSeek Fetch: fetching {url}","fetch.source":"Source: {url}","usage.reset":"Local stats cleared.","usage.report.title":"DeepSeek usage (local counts, estimated per successful request; current mode {mode}; ¥{price}/1000 requests)","usage.report.line":"{label}: searches {search} · fetches {fetch} · empty/failed {skipped} (empty {empty} / failed {failed}) · est. {cost}","usage.report.note":"Note: empty and failed requests are not billed; DeepSeek's account-side bill is authoritative, and these counts exclude other machines or tools.","usage.label.today":"Today","usage.label.month":"Month","usage.label.total":"Total","usage.summary.line":"Search {search} · Fetch {fetch} · empty/failed {skipped} · {cost}","balance.label":"Balance","balance.breakdown":"Granted {granted} · Topped up {topped}","error.missingKey":'DeepSeek API key is not configured. Set the DEEPSEEK_API_KEY environment variable (PowerShell: [Environment]::SetEnvironmentVariable("DEEPSEEK_API_KEY","sk-...","User")), or write "apiKey": "{env:DEEPSEEK_API_KEY}" in the plugin options, then restart opencode.',"error.http.400":"Invalid DeepSeek request parameters (400){upstream}. Queries must be 1–128 characters; Fetch URLs must be valid absolute http(s) URLs.","error.http.401":"Invalid DeepSeek API key (401){upstream}. Check the DEEPSEEK_API_KEY environment variable or options.apiKey.","error.http.402":"Insufficient DeepSeek account balance (402); failed requests are not billed. Top up and try again.","error.http.403":"DeepSeek Fetch was blocked by the target site's security policy (403){upstream}.{hint}","error.http.404":"DeepSeek could not extract the page body (404){upstream}. Check that the link is reachable.{hint}","error.http.408":"DeepSeek request timed out (408); one backoff retry also failed. Try again later.","error.http.413":"DeepSeek request body too large (413). Shorten the input.","error.http.429":"DeepSeek rate limit hit (429; account limits: Search 100 QPS / Fetch 25 QPS); one backoff retry also failed. Try again later.","error.http.5xx":'DeepSeek server error ({status}); one backoff retry also failed. You can set options.mode to "native" to use native search for now.',"error.http.other":"DeepSeek request failed (HTTP {status}){upstream}","error.http.fetchHint":" You can use the built-in webfetch tool for this page.","error.parse":"DeepSeek returned an unparseable response (HTTP {status}). Try again later.","error.aborted":"DeepSeek request cancelled.","error.timeout":"DeepSeek request timed out ({seconds}s). Try again.","error.network":"Cannot reach {base} (network error: {message}). Check your network or proxy settings.","error.validate.queryEmpty":"Empty query: DeepSeek Search needs a non-empty query (1–128 characters).","error.validate.queryLong":"Query too long ({length} characters, limit {max}); shorten it and retry.","error.validate.urlScheme":'Invalid URL: "{url}". DeepSeek Fetch only supports absolute http/https URLs.',"error.validate.urlLong":"URL too long ({length} > {max} characters).","error.validate.urlHost":'URL has no host: "{url}".',"error.validate.urlUserinfo":"URL must not contain a username/password (userinfo).","error.validate.urlParse":'Cannot parse URL: "{url}".',"error.fetch.truncated":"[DeepSeek Fetch truncated] The page is {raw} characters; the limit is {max}, so only the first {max} characters are kept."},ee=["{label} Search {search} Fetch {fetch} {cost}","{label} Search {search} Fetch {fetch} {cost}","{label} {search}S {fetch}F {cost}","{label} {search}S {fetch}F","{label} {search}S"],te=["Balance {amount}","Bal. {amount}"],re=["Set DEEPSEEK_API_KEY and restart","Set DEEPSEEK_API_KEY","Set API KEY","Set KEY"],oe={"state.loading":"読み込み中…","state.loadingShort":"読み込み中…","state.failed":"読み込み失敗","state.failedShort":"失敗","state.enabled":"有効","state.enabledShort":"有効","state.disabled":"無効","state.disabledShort":"無効","state.unpatched":"websearch 未引き継ぎ","state.unpatchedShort":"未引き継ぎ","state.missingKey":"APIキー未設定","state.missingKeyShort":"キー未設定","action.disable":"停止","action.enable":"有効化","action.release":"返上","action.retry":"再試行","panel.tooltip.refresh":"使用量を更新","panel.loading":"使用量を読み込み中…","panel.label.on":"停止(ネイティブ検索に返上)","panel.label.off":"有効化(DeepSeek が引き継ぐ)","panel.label.warn":"ネイティブ検索に返上","panel.label.error":"再試行","panel.label.idle":"再試行","command.open":"DeepSeek: 使用量パネルを開く","command.toggle":"DeepSeek: 検索の引き継ぎを切り替え","menu.description":"検索使用量と引き継ぎスイッチ","toast.openSessionFirst":"先にセッションを開いてください","toast.statusMalformed":"状態データの形式が不正です","toast.modeMalformed":"モード切り替え結果の形式が不正です","dialog.title":"DeepSeek 検索","dialog.enable":"有効化","dialog.enableDesc":"組み込み websearch を引き継ぐ","dialog.disable":"停止","dialog.disableDesc":"組み込み websearch をホストに返上","dialog.refresh":"更新","dialog.refreshDesc":"状態と使用量を再読み込み","mode.report":"現在の検索バックエンド: {mode}(ソース: {source}){suffix}","mode.source.override":"deepseek_mode スイッチ(永続化済み)","mode.source.config":"設定ファイルの options.mode","mode.suffix.patched":" · 組み込み websearch は DeepSeek が処理","mode.suffix.notPatched":" · 組み込み websearch が見つからず、引き継げませんでした","mode.suffix.native":" · 組み込み websearch はネイティブのまま","mode.notFound":"組み込み {tool} ツールが見つからないため、実行中は切り替えできません。設定ファイルで options.mode を「{mode}」にしてください。","mode.configCleared":"永続化スイッチを削除し、設定ファイルの値({mode})に戻しました。","mode.persisted":'永続化しました: OpenCode を再起動しても {mode} のままです。設定ファイルの値に戻すには、deepseek_mode に mode: "config" を渡してください。',"mode.statusOnly":"status は現在のモードを読むだけで、切り替えは行いません。","mode.invalid":"mode は status / deepseek / native / config のいずれかです。受信値: {raw}","progress.fetch":"DeepSeek Fetch 取得中: {url}","fetch.source":"出典: {url}","usage.reset":"ローカル統計をクリアしました。","usage.report.title":"DeepSeek 使用量(ローカル集計・成功リクエストで概算。現在のモード {mode}、単価 ¥{price}/1000回)","usage.report.line":"{label}: 検索 {search} · 取得 {fetch} · 空/失敗 {skipped}(空結果 {empty} / 失敗 {failed})· 推定 {cost}","usage.report.note":"注: 空結果と失敗は課金されません。請求は DeepSeek のアカウント側が正で、この集計は他のマシンや他ツールの呼び出しを含みません。","usage.label.today":"今日","usage.label.month":"今月","usage.label.total":"合計","usage.summary.line":"検索 {search} · 取得 {fetch} · 空/失敗 {skipped} · {cost}","balance.label":"残高","balance.breakdown":"付与 {granted} · チャージ {topped}","error.missingKey":'DeepSeek APIキーが未設定です。環境変数 DEEPSEEK_API_KEY を設定してください(PowerShell: [Environment]::SetEnvironmentVariable("DEEPSEEK_API_KEY","sk-...","User"))。またはプラグイン options に "apiKey": "{env:DEEPSEEK_API_KEY}" を書き、opencode を再起動してください。',"error.http.400":"DeepSeek のリクエストパラメータが不正です(400){upstream}。検索語は 1〜128 文字、Fetch の URL は有効な http(s) 絶対 URL が必要です。","error.http.401":"DeepSeek APIキーが無効です(401){upstream}。DEEPSEEK_API_KEY 環境変数か options.apiKey を確認してください。","error.http.402":"DeepSeek アカウントの残高が不足しています(402)。失敗したリクエストは課金されません。チャージ後に再試行してください。","error.http.403":"DeepSeek Fetch は対象サイトのセキュリティポリシーに拒否されました(403){upstream}。{hint}","error.http.404":"DeepSeek はこのリンクの本文を抽出できませんでした(404){upstream}。リンクにアクセスできるか確認してください。{hint}","error.http.408":"DeepSeek リクエストがタイムアウトしました(408)。バックオフ再試行も失敗しました。しばらくしてから再試行してください。","error.http.413":"DeepSeek リクエストの本文が大きすぎます(413)。入力を短くしてください。","error.http.429":"DeepSeek のレート制限に達しました(429。アカウント上限: Search 100 QPS / Fetch 25 QPS)。バックオフ再試行も失敗しました。しばらくしてから再試行してください。","error.http.5xx":'DeepSeek のサーバーエラーです({status})。バックオフ再試行も失敗しました。一時的に options.mode を "native" にするとネイティブ検索を使えます。',"error.http.other":"DeepSeek リクエストが失敗しました(HTTP {status}){upstream}","error.http.fetchHint":" このページには組み込み webfetch ツールを使えます。","error.parse":"DeepSeek が解析できないレスポンスを返しました(HTTP {status})。しばらくしてから再試行してください。","error.aborted":"DeepSeek リクエストはキャンセルされました。","error.timeout":"DeepSeek リクエストがタイムアウトしました({seconds} 秒)。再試行してください。","error.network":"{base} に接続できません(ネットワークエラー: {message})。ネットワークかプロキシの設定を確認してください。","error.validate.queryEmpty":"検索語が空です。DeepSeek Search には空でない query(1〜128 文字)が必要です。","error.validate.queryLong":"検索語が長すぎます({length} 文字、上限 {max})。短くして再試行してください。","error.validate.urlScheme":"無効な URL:「{url}」。DeepSeek Fetch は http/https の絶対 URL のみ対応します。","error.validate.urlLong":"URL が長すぎます({length} > {max} 文字)。","error.validate.urlHost":"URL にホスト名がありません:「{url}」。","error.validate.urlUserinfo":"URL にユーザー名/パスワード(userinfo)を含められません。","error.validate.urlParse":"URL を解析できません:「{url}」。","error.fetch.truncated":"[DeepSeek Fetch 切り詰め] 元の本文は {raw} 文字で、上限 {max} 文字を超えています。先頭 {max} 文字のみ保持しました。"},ae=["{label} Search {search} Fetch {fetch} {cost}","{label} Search {search} Fetch {fetch} {cost}","{label} {search}S {fetch}F {cost}","{label} {search}S {fetch}F","{label} {search}S"],ne=["残高 {amount}"],se=["DEEPSEEK_API_KEY を設定して再起動","DEEPSEEK_API_KEY を設定","API KEY を設定","KEY 設定"],ie={"state.loading":"正在读取…","state.loadingShort":"正在读取…","state.failed":"读取失败","state.failedShort":"读取失败","state.enabled":"已启用","state.enabledShort":"已启用","state.disabled":"已停用","state.disabledShort":"已停用","state.unpatched":"未接管内置 websearch","state.unpatchedShort":"未接管","state.missingKey":"未配置 API Key","state.missingKeyShort":"缺 API Key","action.disable":"停用","action.enable":"启用","action.release":"交还","action.retry":"重试","panel.tooltip.refresh":"刷新用量","panel.loading":"正在读取用量…","panel.label.on":"停用(交还原生搜索)","panel.label.off":"启用(由 DeepSeek 接管)","panel.label.warn":"交还原生搜索","panel.label.error":"重试","panel.label.idle":"重试","command.open":"DeepSeek: 打开统计面板","command.toggle":"DeepSeek: 启用/停用搜索接管","menu.description":"搜索用量与接管开关","toast.openSessionFirst":"请先打开一个会话","toast.statusMalformed":"状态数据格式不符","toast.modeMalformed":"模式切换结果格式不符","dialog.title":"DeepSeek 搜索","dialog.enable":"启用","dialog.enableDesc":"接管内置 websearch","dialog.disable":"停用","dialog.disableDesc":"把内置 websearch 交还宿主","dialog.refresh":"刷新","dialog.refreshDesc":"重新读取状态与统计","mode.report":"当前搜索后端: {mode}(来源: {source}){suffix}","mode.source.override":"deepseek_mode 开关,已持久化","mode.source.config":"配置文件 options.mode","mode.suffix.patched":" · 内置 websearch 已由 DeepSeek 接管","mode.suffix.notPatched":" · 未找到内置 websearch 工具,实际未能接管","mode.suffix.native":" · 内置 websearch 保持原生","mode.notFound":'未找到内置 {tool} 工具,无法在运行时切换。请改用配置文件把 options.mode 设为 "{mode}"。',"mode.configCleared":"已清除持久化开关,回到配置文件设置({mode})。","mode.persisted":'已持久化:重启 OpenCode 后仍为 {mode}。要恢复配置文件设置,调用 deepseek_mode 并传 mode: "config"。',"mode.statusOnly":"status 只读取当前模式,不做切换。","mode.invalid":"mode 只能是 status / deepseek / native / config,收到:{raw}","progress.fetch":"DeepSeek Fetch 抓取中: {url}","fetch.source":"来源: {url}","usage.reset":"已清零本地统计。","usage.report.title":"DeepSeek 用量(本地统计,按成功请求估算;当前模式 {mode};单价 ¥{price}/1000 次)","usage.report.line":"{label}: 搜索 {search} · 抓取 {fetch} · 空/失 {skipped}(空结果 {empty} / 失败 {failed})· 估算 {cost}","usage.report.note":"说明:空结果与失败请求不计费;DeepSeek 以账号侧账单为准,本统计不含其他机器或其他工具的调用。","usage.label.today":"今日","usage.label.month":"本月","usage.label.total":"累计","usage.summary.line":"搜索 {search} · 抓取 {fetch} · 空/失 {skipped} · {cost}","balance.label":"余额","balance.breakdown":"赠金 {granted} · 充值 {topped}","error.missingKey":'未配置 DeepSeek API Key:请设置环境变量 DEEPSEEK_API_KEY(PowerShell: [Environment]::SetEnvironmentVariable("DEEPSEEK_API_KEY","sk-...","User")),或在插件 options 中写 "apiKey": "{env:DEEPSEEK_API_KEY}",然后重启 opencode。',"error.http.400":"DeepSeek 请求参数无效(400){upstream}。搜索词需 1~128 字符;Fetch 的 URL 需为合法的 http(s) 绝对地址。","error.http.401":"DeepSeek API Key 无效(401){upstream}。请检查 DEEPSEEK_API_KEY 环境变量或 options.apiKey。","error.http.402":"DeepSeek 账户余额不足(402),失败请求不计费。请充值后重试。","error.http.403":"DeepSeek Fetch 被目标站点安全策略拒绝(403){upstream}。{hint}","error.http.404":"DeepSeek 无法提取该链接的正文(404){upstream}。请确认链接可访问。{hint}","error.http.408":"DeepSeek 请求超时(408),已退避重试一次仍失败。请稍后重试。","error.http.413":"DeepSeek 请求体过大(413)。请缩短输入。","error.http.429":"DeepSeek 触发限速(429,账号级 Search 100 QPS / Fetch 25 QPS),已退避重试一次仍失败。请稍后再试。","error.http.5xx":'DeepSeek 服务端错误({status}),已退避重试一次仍失败。可把插件 options.mode 改为 "native" 暂用原生搜索。',"error.http.other":"DeepSeek 请求失败(HTTP {status}){upstream}","error.http.fetchHint":" 可改用内置 webfetch 工具抓取该页面。","error.parse":"DeepSeek 返回了无法解析的响应(HTTP {status})。请稍后重试。","error.aborted":"DeepSeek 请求已取消。","error.timeout":"DeepSeek 请求超时({seconds} 秒),请重试。","error.network":"无法连接 {base}(网络错误:{message})。请检查网络或代理设置。","error.validate.queryEmpty":"搜索词为空:DeepSeek Search 需要非空 query(1~128 字符)。","error.validate.queryLong":"搜索词过长({length} 字符,上限 {max}),请精简后重试。","error.validate.urlScheme":"无效 URL:「{url}」。DeepSeek Fetch 仅支持 http/https 绝对地址。","error.validate.urlLong":"URL 过长({length} > {max} 字符)。","error.validate.urlHost":"URL 缺少主机名:「{url}」。","error.validate.urlUserinfo":"URL 不能包含用户名/密码(userinfo)。","error.validate.urlParse":"无法解析 URL:「{url}」。","error.fetch.truncated":"[DeepSeek Fetch 截断提示] 原文共 {raw} 字符,超出上限 {max},此处仅保留前 {max} 字符。"},le=["{label} Search {search} Fetch {fetch} {cost}","{label} Search {search} Fetch {fetch} {cost}","{label} {search}S {fetch}F {cost}","{label} {search}S {fetch}F","{label} {search}S"],ce=["余额 {amount}"],de=["设置 DEEPSEEK_API_KEY 后重启","设置 API KEY 后重启","设置 API KEY","设置 KEY"],B={en:{messages:Z,usageForms:ee,hintForms:re,balanceForms:te},ja:{messages:oe,usageForms:ae,hintForms:se,balanceForms:ne},"zh-CN":{messages:ie,usageForms:le,hintForms:de,balanceForms:ce}};function T(e){return B[e]}function pe(e){return B[e].messages}function F(e,t={}){return e.replace(/\{(\w+)\}/g,(o,r)=>r in t?String(t[r]):o)}function c(e,t,o){const n=pe(e)[t];return n===void 0?t:F(n,o)}const ue="DeepSeek search/fetch",N="DeepSeek",he=2,fe=1,me=24,R=["today","month","total"],U={today:"usage.label.today",month:"usage.label.month",total:"usage.label.total"};function q(e){const t=e.codePointAt(0)??0;return t===0?0:t>=4352&&t<=4447||t>=11904&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=127744&&t<=129791||t>=131072&&t<=262141?2:1}function w(e){let t=0;for(const o of e)t+=q(o);return t}function _(e,t){if(t<1)return"";if(w(e)<=t)return e;let o="",r=0;for(const n of e){const s=q(n);if(r+s>t-1)return`${o}…`;o+=n,r+=s}return o}function ge(e,t,o){const r=e.replace(/\s+/g," ").trim();return _(r||c(o,"state.failed"),t)}function L(e){let o=(Number.isFinite(e)&&e>0?e/1e6:0).toFixed(3);for(;o.endsWith("0")&&o.length>4;)o=o.slice(0,-1);return`¥${o}`}function be(e){const t=R.map(o=>e[o]);return{search:Math.max(...t.map(o=>String(o.search).length)),fetch:Math.max(...t.map(o=>String(o.fetch).length)),cost:Math.max(...t.map(o=>L(o.costMicro).length))}}function ye(e,t,o,r,n){const s=c(n,U[e]),l=String(t.search).padStart(o.search," "),i=String(t.fetch).padStart(o.fetch," "),u=L(t.costMicro).padStart(o.cost," "),b={label:s,search:l,fetch:i,cost:u},m=T(n).usageForms;for(const p of m.slice(0,-1)){const S=F(p,b);if(w(S)<=r)return S}const f=`${s} ${u}`;if(w(f)<=r)return f;const h=m[m.length-1];if(h!==void 0){const p=F(h,b);if(w(p)<=r)return p}}function Se(e,t,o,r){const n=c(r,U.total),s=L(e.costMicro),l=[`${n} ${s.padStart(t.cost," ")}`,`${n} ${String(e.search).padStart(t.search," ")}S`,s];for(const i of l)if(w(i)<=o)return i;return _(s,o)}function ve(e,t,o){if(t===Number.POSITIVE_INFINITY)return[`${c(o,"usage.label.today")} ${e.today}`,`${c(o,"usage.label.month")} ${e.month}`,`${c(o,"usage.label.total")} ${e.total}`];const r=e.counts;if(r){const n=be(r),s=[];for(const l of R){const i=ye(l,r[l],n,t,o);if(i===void 0)return[Se(r.total,n,t,o)];s.push(i)}return s}return R.map(n=>Ee(n,e[n],t,o))}const O={CNY:"¥",USD:"$"};function ke(e,t,o){const r=e.isAvailable?"":"!",n=`${O[e.currency]??""}${e.totalBalance}`;for(const s of T(o).balanceForms){const l=`${r}${F(s,{amount:n})}`;if(w(l)<=t)return l}}function Ee(e,t,o,r){const n=c(r,U[e]),s=`${n} ${t}`;if(w(s)<=o)return s;const l=t.split(" · ").filter(u=>!u.startsWith("¥")&&!u.startsWith("空/失")),i=[`${n} ${l.join(" ")}`.trimEnd(),`${n} ${l[0]??""}`.trimEnd(),n];for(const u of i)if(w(u)<=o)return u;return _(n,o)}function we(e,t){const o=`[${e}]`;if(t===Number.POSITIVE_INFINITY||w(o)<=t)return o;const r=t-2;return r>=1?`[${_(e,r)}]`:_(o,t)}function H(e,t,o,r,n=!0){const s=(b,m)=>{if(o===Number.POSITIVE_INFINITY)return Number.POSITIVE_INFINITY;const f=b?he:0,h=r===void 0||m?0:r+fe;return Math.max(0,o-f-h)},l=[`${ue} · ${e}`,`${N} · ${e}`,`${N} · ${t}`,e,t],i=r===void 0||!n?[!1]:[!1,!0];for(const b of l)for(const m of i)for(const f of[!0,!1])if(w(b)<=s(f,m))return{title:b,glyph:f,actionBelow:m};const u=n&&r!==void 0;return{title:_(t,s(!1,u)),glyph:!1,actionBelow:u}}function De(e,t){const o=T(t).hintForms;if(e===Number.POSITIVE_INFINITY)return o[0]??"";for(const r of o)if(w(r)<=e)return r;return _(o[o.length-1]??"",e)}function x(e,t,o,r,n=!0){const s=we(o,r);return{...H(e,t,r,w(s),n),action:s}}function Pe(e){const{status:t,error:o,language:r}=e,n=e.maxColumns??me,s=t===void 0?[]:ve(t,n,r),l=t!==void 0&&(t.patched&&t.hasKey||t.mode==="native")&&t.balance!==void 0?ke(t.balance,n,r):void 0,i=l===void 0?s:[...s,l],u=l===void 0;if(t===void 0){const m=c(r,"action.retry");return o===void 0||o.trim()===""?{...x(c(r,"state.loading"),c(r,"state.loadingShort"),m,n),hint:void 0,clickable:!0,lines:i,tone:"idle"}:{...x(c(r,"state.failed"),c(r,"state.failedShort"),m,n),hint:void 0,clickable:!0,lines:[ge(o,n,r)],tone:"error"}}if(t.patched&&t.hasKey)return{...x(c(r,"state.enabled"),c(r,"state.enabledShort"),c(r,"action.disable"),n,u),hint:void 0,clickable:!0,lines:i,tone:"on"};if(!t.patched&&t.mode==="deepseek")return{...x(c(r,"state.unpatched"),c(r,"state.unpatchedShort"),c(r,"action.release"),n,u),hint:void 0,clickable:!0,lines:i,tone:"warn"};if(t.mode==="native")return{...x(c(r,"state.disabled"),c(r,"state.disabledShort"),c(r,"action.enable"),n,u),hint:void 0,clickable:!0,lines:i,tone:"off"};const b=De(n,r);return{...H(c(r,"state.missingKey"),c(r,"state.missingKeyShort"),n,void 0),action:b,hint:b,clickable:!1,lines:i,tone:"error"}}var M=a.template("<span>"),_e=a.template("<span style=opacity:0.6;font-weight:400>"),xe=a.template("<span style=opacity:0.3;font-weight:400> · "),Ie=a.template("<code style=font-size:0.94em>DEEPSEEK_API_KEY"),Ke=a.template('<p style="margin:16px 0 0;font-size:12px;line-height:1.6;opacity:0.68;overflow-wrap:anywhere">'),Fe=a.template("<div style=margin-top:18px>"),$e=a.template('<div style="display:flex;flex-direction:column;height:100%;min-width:0;box-sizing:border-box;padding:16px 16px 24px;overflow-y:auto;overflow-x:hidden"><header style=display:flex;align-items:flex-start;gap:8px><span aria-hidden=true style=flex-shrink:0;font-size:12px;line-height:20px;width:12px;text-align:center;font-weight:700></span><h2 aria-live=polite style=flex:1;min-width:0;margin:0;font-size:13px;font-weight:600;line-height:20px;overflow-wrap:anywhere>'),Ae=a.template('<p style="margin:14px 0 0;font-size:12px;line-height:1.6;opacity:0.7;overflow-wrap:anywhere">'),Re=a.template("<div style=display:flex;align-items:center;gap:8px;margin-top:14px;opacity:0.7><span style=font-size:12px>"),Te=a.template('<dl style="margin:16px 0 0">'),Ue=a.template('<div style="display:flex;align-items:baseline;gap:12px;padding:10px 0"><dt style=flex-shrink:0;font-size:11px;line-height:1.9;opacity:0.62></dt><dd style=margin:0;margin-left:auto;min-width:0;display:flex;flex-wrap:wrap;justify-content:flex-end;column-gap:10px;row-gap:2px;font-size:13px;line-height:1.55;font-variant-numeric:tabular-nums;text-align:right>'),Le=a.template("<span style=min-width:0;overflow-wrap:anywhere>"),Ye=a.template("<dd style=margin:0;margin-left:auto;font-size:14px;line-height:1.55;font-variant-numeric:tabular-nums;text-align:right;font-weight:500;flex-shrink:0>"),Ne=a.template('<div style="display:flex;align-items:baseline;gap:12px;padding:10px 0 4px"><dt style=flex-shrink:0;font-size:11px;line-height:1.9;opacity:0.62>');const Me={on:"●",off:"○",warn:"◐",error:"!",idle:"…"},Ce={dark:{on:"#63d19a",warn:"#e0ad4f",error:"#ee7b74",off:"#8b9198",idle:"#8b9198",rule:"rgba(255,255,255,0.14)"},light:{on:"#1e7a4c",warn:"#8a5f08",error:"#b03931",off:"#6b7076",idle:"#6b7076",rule:"rgba(0,0,0,0.13)"}},Be={on:"panel.label.on",off:"panel.label.off",warn:"panel.label.warn",error:"panel.label.error",idle:"panel.label.idle"},qe={on:"arrow-undo-down",off:"globe",warn:"arrow-undo-down",error:"refresh",idle:"refresh"};function Oe(e,t){const o=e.indexOf(" · ");return o<0?(()=>{var r=M();return a.setStyleProperty(r,"color",t),a.insert(r,e),r})():[(()=>{var r=_e();return a.insert(r,()=>e.slice(0,o)),r})(),xe(),(()=>{var r=M();return a.setStyleProperty(r,"color",t),a.insert(r,()=>e.slice(o+3)),r})()]}function He(e){const t=e.indexOf(" ");return t<0?{label:e,chunks:[]}:{label:e.slice(0,t),chunks:e.slice(t+1).split(" · ")}}function ze(e,t){const o="DEEPSEEK_API_KEY",r=e.indexOf(o);return r<0?e:[a.memo(()=>e.slice(0,r)),(()=>{var n=Ie();return a.setStyleProperty(n,"font-family",t),n})(),a.memo(()=>e.slice(r+o.length))]}function je(e,t){const o=Number.parseFloat(e.grantedBalance)>0,r=Number.parseFloat(e.toppedUpBalance)>0;if(!o||!r)return;const n=c(t,"balance.breakdown",{granted:e.grantedBalance,topped:e.toppedUpBalance});return e.currency==="USD"?`${n} (USD)`:n}function Qe(e){const t=I.usePlugin(),o=()=>e.status?.language??"en",r=k.createMemo(()=>Pe({status:e.status,error:e.error,maxColumns:1/0,language:o()})),n=k.createMemo(()=>Ce[t.appearance.mode()]),s=()=>t.appearance.font("mono"),l=k.createMemo(()=>{const i=e.status?.balance;if(!(i===void 0||r().tone!=="on"&&r().tone!=="off"))return i});return k.onMount(()=>{const i=setInterval(()=>e.onRefresh(),1e4);k.onCleanup(()=>clearInterval(i))}),(()=>{var i=$e(),u=i.firstChild,b=u.firstChild,m=b.nextSibling;return a.insert(b,()=>Me[r().tone]),a.insert(m,()=>Oe(r().title,n()[r().tone])),a.insert(u,a.createComponent(t.ui.Tooltip,{get value(){return c(o(),"panel.tooltip.refresh")},placement:"bottom",get children(){return a.createComponent(t.ui.IconButton,{icon:"refresh",get label(){return c(o(),"panel.tooltip.refresh")},size:"small",onClick:()=>e.onRefresh(!0)})}}),null),a.insert(i,(()=>{var f=a.memo(()=>e.status===void 0);return()=>f()?a.memo(()=>r().lines.length>0)()?(()=>{var h=Ae();return a.insert(h,()=>r().lines[0]),h})():(()=>{var h=Re(),p=h.firstChild;return a.insert(h,a.createComponent(t.ui.Loader,{size:"small"}),p),a.insert(p,()=>c(o(),"panel.loading")),h})():(()=>{var h=Te();return a.insert(h,a.createComponent(k.For,{get each(){return a.memo(()=>l()!==void 0)()?r().lines.slice(0,-1):r().lines},children:(p,S)=>{const d=He(p);return(()=>{var g=Ue(),v=g.firstChild,D=v.nextSibling;return a.insert(v,()=>d.label),a.insert(D,a.createComponent(k.For,{get each(){return d.chunks},children:y=>{const E=/^[¥$]/.test(y);return(()=>{var P=Le();return a.setStyleProperty(P,"font-weight",E?500:400),a.setStyleProperty(P,"opacity",E?1:.8),a.setStyleProperty(P,"flex-shrink",E?0:void 0),a.insert(P,y),P})()}})),a.effect(y=>{var E=S()>0?`1px solid ${n().rule}`:void 0,P=/^[\x20-\x7E]+$/.test(d.label)?"0.08em":void 0,Y=s();return E!==y.e&&a.setStyleProperty(g,"border-top",y.e=E),P!==y.t&&a.setStyleProperty(v,"letter-spacing",y.t=P),Y!==y.a&&a.setStyleProperty(D,"font-family",y.a=Y),y},{e:void 0,t:void 0,a:void 0}),g})()}}),null),a.insert(h,a.createComponent(k.Show,{get when(){return l()},keyed:!0,children:p=>{const S=c(o(),"balance.label"),d=je(p,o()),g=(()=>{var v=Ye();return a.insert(v,()=>O[p.currency]??"",null),a.insert(v,()=>p.totalBalance,null),a.effect(D=>{var y=s(),E=p.isAvailable?void 0:n().warn;return y!==D.e&&a.setStyleProperty(v,"font-family",D.e=y),E!==D.t&&a.setStyleProperty(v,"color",D.t=E),D},{e:void 0,t:void 0}),v})();return(()=>{var v=Ne(),D=v.firstChild;return a.insert(D,S),a.insert(v,d!==void 0?a.createComponent(t.ui.Tooltip,{value:d,placement:"bottom",children:g}):g,null),a.effect(y=>{var E=`1px solid ${n().rule}`,P=/^[\x20-\x7E]+$/.test(S)?"0.08em":void 0;return E!==y.e&&a.setStyleProperty(v,"border-top",y.e=E),P!==y.t&&a.setStyleProperty(D,"letter-spacing",y.t=P),y},{e:void 0,t:void 0}),v})()}}),null),a.effect(p=>{var S=`1px solid ${n().rule}`,d=`1px solid ${n().rule}`;return S!==p.e&&a.setStyleProperty(h,"border-top",p.e=S),d!==p.t&&a.setStyleProperty(h,"border-bottom",p.t=d),p},{e:void 0,t:void 0}),h})()})(),null),a.insert(i,a.createComponent(k.Show,{get when(){return!r().clickable},get children(){var f=Ke();return a.insert(f,()=>ze(r().action,s())),f}}),null),a.insert(i,a.createComponent(k.Show,{get when(){return a.memo(()=>!!r().clickable)()&&r().tone!=="idle"},get children(){var f=Fe();return a.insert(f,a.createComponent(t.ui.Button,{get variant(){return r().tone==="off"||r().tone==="error"?"contrast":"neutral"},get icon(){return qe[r().tone]},get disabled(){return e.busy},get busy(){return e.busy},get onClick(){return e.onToggle},get children(){return c(o(),Be[r().tone])}})),f}}),null),a.effect(f=>{var h=e.busy||void 0,p=n()[r().tone];return h!==f.e&&a.setAttribute(i,"aria-busy",f.e=h),p!==f.t&&a.setStyleProperty(b,"color",f.t=p),f},{e:void 0,t:void 0}),i})()}const C={id:"main",title:"DeepSeek"},Ve=80,Ge=I.Plugin.define({setup(e){const t=e.client.rpc(V),[o,r]=k.createSignal(),[n,s]=k.createSignal(),[l,i]=k.createSignal(!1),u=()=>o()?.language??"en",b=d=>(d instanceof Error?d.message:String(d)).slice(0,Ve);async function m(d=!1){try{const g=J(await t.status(d?{force:!0}:{}));g?(r(g),s(void 0)):s(c(u(),"toast.statusMalformed"))}catch(g){s(b(g))}}async function f(d){i(!0);try{const g=X(await t.setMode({mode:d}));g?g.ok||e.toast.show({title:"DeepSeek",description:g.message,variant:"error"}):e.toast.show({title:"DeepSeek",description:c(u(),"toast.modeMalformed"),variant:"error"})}catch(g){e.toast.show({title:"DeepSeek",description:b(g),variant:"error"})}finally{await m(),i(!1)}}function h(){const d=o();if(!d||n()){m(!0);return}f(d.mode==="deepseek"?"native":"deepseek")}e.add(I.Panel,{id:"main",region:"side",mobile:{title:"DeepSeek",order:50,kind:"menu",icon:"globe"},list:d=>d.open.includes(C.id)?[C]:[],render:()=>a.createComponent(Qe,{get status(){return o()},get error(){return n()},get busy(){return l()},onToggle:h,onRefresh:d=>{m(d)}})});const p=()=>{const d=e.sessions.current();if(!d){e.toast.show({title:"DeepSeek",description:c(u(),"toast.openSessionFirst")});return}e.layout.open(`${e.id}:main`,d)};e.add(I.Command,()=>({id:"open",title:c(u(),"command.open"),section:"session",run:p})),e.add(I.MenuItem,()=>{const d=e.sessions.current(),g=d!==void 0&&e.layout.stored(d).includes("main");return{menu:"session.panel",id:"open",title:"DeepSeek",description:c(u(),"menu.description"),icon:"globe",order:60,opened:g,run:p}});const S=t.events.on("changed",()=>{m()});return m(),S}});exports.default=Ge;
package/package.json CHANGED
@@ -1,87 +1,88 @@
1
1
  {
2
- "name": "@qthinker/opencode-deepseek-search",
3
- "version": "0.2.1",
4
- "description": "DeepSeek Search \u0026 Fetch for OpenCode V2: a switchable websearch backend, clean Markdown fetch, local usage/cost stats, and TUI + desktop sidebars",
5
- "type": "module",
6
- "license": "MIT",
7
- "author": "QThinker",
8
- "homepage": "https://github.com/QThinkerJR/opencode-deepseek-search#readme",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/QThinkerJR/opencode-deepseek-search.git"
12
- },
13
- "bugs": {
14
- "url": "https://github.com/QThinkerJR/opencode-deepseek-search/issues"
15
- },
16
- "keywords": [
17
- "opencode",
18
- "opencode-plugin",
19
- "deepseek",
20
- "websearch",
21
- "search",
22
- "fetch",
23
- "usage",
24
- "cost",
25
- "tui",
26
- "desktop",
27
- "sidebar"
28
- ],
29
- "files": [
30
- "index.ts",
31
- "tui.ts",
32
- "gui-experimental.cjs",
33
- "src",
34
- "README.md",
35
- "CHANGELOG.md",
36
- "LICENSE"
37
- ],
38
- "engines": {
39
- "node": "\u003e=22.18"
40
- },
41
- "scripts": {
42
- "typecheck": "tsc --noEmit \u0026\u0026 tsc --noEmit -p tsconfig.gui.json",
43
- "test": "node --test test/*.test.ts",
44
- "build:gui": "vite build",
45
- "smoke": "node --experimental-strip-types scripts/smoke.ts",
46
- "prepublishOnly": "npm run typecheck \u0026\u0026 npm test \u0026\u0026 npm run build:gui"
47
- },
48
- "peerDependencies": {
49
- "@opencode/plugin": "\u003e=2.2.5",
50
- "@opencode/theme": "\u003e=2.2.5",
51
- "@opentui/core": "\u003e=0.8.0",
52
- "@opentui/solid": "\u003e=0.8.0",
53
- "solid-js": "\u003e=1.9.0"
54
- },
55
- "peerDependenciesMeta": {
56
- "@opencode/plugin": {
57
- "optional": true
58
- },
59
- "@opencode/theme": {
60
- "optional": true
61
- },
62
- "@opentui/core": {
63
- "optional": true
64
- },
65
- "@opentui/solid": {
66
- "optional": true
67
- },
68
- "solid-js": {
69
- "optional": true
70
- }
71
- },
72
- "devDependencies": {
73
- "@opencode/plugin": "2.2.5",
74
- "@opencode/theme": "2.2.5",
75
- "@opentui/core": "^0.8.0",
76
- "@opentui/solid": "^0.8.0",
77
- "@types/node": "^24.0.0",
78
- "solid-js": "^1.9.0",
79
- "typescript": "^5.9.0",
80
- "vite": "^7.3.7",
81
- "vite-plugin-solid": "^2.11.10"
82
- },
83
- "main": "./index.ts",
84
- "publishConfig": {
85
- "access": "public"
86
- }
2
+ "name": "@qthinker/opencode-deepseek-search",
3
+ "version": "0.3.2",
4
+ "description": "DeepSeek Search & Fetch for OpenCode V2: a switchable websearch backend, clean Markdown fetch, local usage/cost stats, and TUI + desktop sidebars",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "QThinker",
8
+ "homepage": "https://github.com/QThinkerJR/opencode-deepseek-search#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/QThinkerJR/opencode-deepseek-search.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/QThinkerJR/opencode-deepseek-search/issues"
15
+ },
16
+ "keywords": [
17
+ "opencode",
18
+ "opencode-plugin",
19
+ "deepseek",
20
+ "websearch",
21
+ "search",
22
+ "fetch",
23
+ "usage",
24
+ "cost",
25
+ "tui",
26
+ "desktop",
27
+ "sidebar",
28
+ "i18n"
29
+ ],
30
+ "files": [
31
+ "index.ts",
32
+ "tui.ts",
33
+ "gui-experimental.cjs",
34
+ "src",
35
+ "README.md",
36
+ "CHANGELOG.md",
37
+ "LICENSE"
38
+ ],
39
+ "engines": {
40
+ "node": ">=22.18"
41
+ },
42
+ "scripts": {
43
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.gui.json",
44
+ "test": "node --test test/*.test.ts",
45
+ "build:gui": "vite build",
46
+ "smoke": "node --experimental-strip-types scripts/smoke.ts",
47
+ "prepublishOnly": "npm run typecheck && npm test && npm run build:gui"
48
+ },
49
+ "peerDependencies": {
50
+ "@opencode/plugin": ">=2.2.5",
51
+ "@opencode/theme": ">=2.2.5",
52
+ "@opentui/core": ">=0.8.0",
53
+ "@opentui/solid": ">=0.8.0",
54
+ "solid-js": ">=1.9.0"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "@opencode/plugin": {
58
+ "optional": true
59
+ },
60
+ "@opencode/theme": {
61
+ "optional": true
62
+ },
63
+ "@opentui/core": {
64
+ "optional": true
65
+ },
66
+ "@opentui/solid": {
67
+ "optional": true
68
+ },
69
+ "solid-js": {
70
+ "optional": true
71
+ }
72
+ },
73
+ "devDependencies": {
74
+ "@opencode/plugin": "2.2.5",
75
+ "@opencode/theme": "2.2.5",
76
+ "@opentui/core": "^0.8.0",
77
+ "@opentui/solid": "^0.8.0",
78
+ "@types/node": "^24.0.0",
79
+ "solid-js": "^1.9.0",
80
+ "typescript": "^5.9.0",
81
+ "vite": "^7.3.7",
82
+ "vite-plugin-solid": "^2.11.10"
83
+ },
84
+ "main": "./index.ts",
85
+ "publishConfig": {
86
+ "access": "public"
87
+ }
87
88
  }