dsh-hku-llm 1.6.0 → 1.6.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/DEVELOPMENT.md CHANGED
@@ -17,7 +17,7 @@ nothing else.
17
17
  | **Language** | ESM only (`"type": "module"`); the browser half is loaded as-is |
18
18
  | **Dependencies** | `@deepseek-ai/schemastery` at runtime; `@deepseek-ai/dsh-llm` and `@deepseek-ai/dsh-tools` from the Host |
19
19
  | **Entry points** | `index.js` (Host), `client.js` (Web settings page) |
20
- | **Offline tests** | five suites, no network, no Host install |
20
+ | **Offline tests** | eleven suites, no network, no Host install |
21
21
  | **Live tests** | one smoke script, needs a Developer Portal key |
22
22
 
23
23
  ## Contents
@@ -48,21 +48,24 @@ cd dsh-hku-llm
48
48
 
49
49
  pnpm install # the one runtime dependency (@deepseek-ai/schemastery)
50
50
  npm run stubs # link the dev copies of the Host packages into node_modules
51
- npm run check # run all five offline suites
51
+ npm run check # run every offline suite
52
52
  ```
53
53
 
54
- Expected output ends with:
54
+ Expected output ends with a Vitest summary:
55
55
 
56
56
  ```
57
57
  capacity-defaults are current (25)
58
58
  route-defaults are current (3)
59
- plugin check passed
60
- all 39 checks passed
61
- client check passed
62
- pool check passed
63
- gemini check passed
59
+
60
+ ✓ test/adapter.test.js (…)
61
+ ✓ test/chunks.test.js (…)
62
+ …
63
+ Test Files 12 passed (12)
64
+ Tests … passed (…)
64
65
  ```
65
66
 
67
+ Every suite passes without a network, a credential or a DeepSeek Harness install.
68
+
66
69
  ### Why `npm run stubs` is needed
67
70
 
68
71
  `@deepseek-ai/dsh-llm` and `@deepseek-ai/dsh-tools` are **peer dependencies**: at runtime
@@ -149,7 +152,7 @@ What "done" means for a change:
149
152
  - the adapter streams text, reasoning, tool calls and usage for every protocol it serves;
150
153
  - credentials are resolved per request and never written to configuration;
151
154
  - the settings page round-trips through the settings Remote without a Host restart;
152
- - the five offline suites pass, and `smoke` passes with a real key when the wire changed.
155
+ - the offline suites pass, and `smoke` passes with a real key when the wire changed.
153
156
 
154
157
  ---
155
158
 
@@ -178,15 +181,27 @@ lib/
178
181
  gemini.js Gemini Chat Completions: build body, parse JSON/SSE replies
179
182
 
180
183
  scripts/
181
- plugin-check.mjs apply() against a stub ctx: registrations, tool, teardown
182
- check-errors.mjs failure mapping and config normalization (39 assertions)
183
- client-check.mjs loader, slot, controller diffing, guarded-service trap
184
- check-pool.mjs stubbed gateway: rotation, failover, disabled model, no key
185
- check-gemini.mjs Gemini protocol: body shape, reply envelopes, refusals
186
184
  smoke.mjs live wire matrix, needs HKU_TEST_KEY
187
185
  link-stubs.mjs mounts dev/host-stubs into node_modules
188
186
  sync-client-defaults.mjs mirrors capacities and route defaults into client.js (--check)
189
187
 
188
+ test/ the offline proof, run by Vitest
189
+ package.test.js manifest, exports, files, locale parity, module graph, CI wiring
190
+ plugin.test.js apply() against a stub ctx: registrations, tool, teardown
191
+ errors.test.js failure mapping and config normalization
192
+ sse.test.js event framing: CRLF, multi-line data, split reads, cancellation
193
+ chunks.test.js StreamChunk contract: indices, block lifecycle, tool calls
194
+ convert.test.js history translation for all three protocols; refusal of images
195
+ wire-chat.test.js Chat Completions body and reply parser
196
+ wire-responses.test.js Responses body and reply parser
197
+ wire-gemini.test.js Gemini protocol: body shape, reply envelopes, refusals
198
+ adapter.test.js gates, non-auth statuses, redaction, headers, aborts, rotation
199
+ pool.test.js stubbed gateway: rotation, failover, disabled model, no key
200
+ client.test.js loader, slot, controller diffing, guarded-service trap
201
+ helpers/ fixtures shared by more than one suite
202
+
203
+ vitest.config.js node environment, worker threads, test/**/*.test.js
204
+
190
205
  dev/host-stubs/ local stand-ins for the two peer packages (dev only)
191
206
  docs/assets/ banner, logo, architecture and flow diagrams
192
207
  locale/ plugin metadata for the locale service (en, zh)
@@ -435,7 +450,10 @@ plugin down. Rules, in order:
435
450
  route down;
436
451
  3. trailing slashes are trimmed from `baseURL`;
437
452
  4. an `api` outside `API_KINDS` (`openai-responses`, `openai-completions`,
438
- `gemini-completions`) falls back to `openai-responses`;
453
+ `gemini-completions`) falls back to `openai-responses`. `providerSchema.api` deliberately
454
+ carries **no** schema default: the schema runs before this function, so a default there
455
+ would overwrite the protocol a shipped route declares in rule 2 and send `hku-gemini` to
456
+ `/responses`. Keep the fallback here, not in the schema.
439
457
  5. models require a non-empty `id`; `contextWindow`/`maxTokens` fall back to 128000/16000
440
458
  when not positive; `input` defaults to `['text']`;
441
459
  6. `reasoningEfforts` accepts `{ level: wire }`, `['level']` or `false` and normalizes to a
@@ -610,7 +628,7 @@ remote.credentials.unset(ref)
610
628
  ```
611
629
 
612
630
  Never read `ctx.remote` as a property: Cordis throws
613
- `cannot get property "remote" without inject`, and `scripts/client-check.mjs` deliberately
631
+ `cannot get property "remote" without inject`, and `test/client.test.js` deliberately
614
632
  defines a throwing getter to catch a regression.
615
633
 
616
634
  Remote results are either `{ ok, value }`, `{ ok: false, error }` or a plain value;
@@ -777,43 +795,82 @@ plugin surfaces. Adding a language means adding both: a copy table and a locale
777
795
 
778
796
  ## 10. Testing
779
797
 
780
- Everything runs outside DSH and needs no credential except `smoke`.
798
+ Everything runs outside DSH and needs no credential except `smoke`. The suites are plain
799
+ Vitest files under `test/`, so a failure names the file, the test, and the expected value.
781
800
 
782
801
  | Suite | Proves | Cannot prove |
783
802
  |---|---|---|
784
- | `plugin-check.mjs` | module graph loads; schema produces the three routes; adapter and directory registrations receive the expected arguments; status tool answers; teardown releases everything; no error logs | real seam behavior |
785
- | `check-errors.mjs` | 39 assertions over failure mapping (401/404/429/5xx/plain-text/nested bodies), oversize vs quota heuristics, config normalization, partial-route repair, key-pool normalization | a real gateway |
786
- | `client-check.mjs` | loader contract, slot registration and order, controller load/diff/save, catalogue add/remove/edit operations, documented-capacity defaults and their restore action, checkbox auto-save, endpoint lock/unlock, partial-route hydration and repair, credential writes, guarded-service trap, initial render | a real browser |
787
- | `check-pool.mjs` | stubbed gateway: failover order, rotation cursor, disabled-model refusal, missing-credential refusal | network behavior |
788
- | `check-gemini.mjs` | Gemini protocol: the body carries only documented fields, every reply envelope parses, refusals are classified, one request dispatches through the real adapter | a live gateway |
803
+ | `package.test.js` | the published artefact: every `exports` and `files` target exists, `lib/` is wholly shipped, the browser half has no top-level import, the locales share their keys, every module is reachable from `index.js`, README links resolve, and every suite is documented and wired into `npm test` and CI | that `npm pack` selects the right files |
804
+ | `plugin.test.js` | module graph loads; schema produces the three routes; adapter and directory registrations receive the expected arguments; status tool answers; teardown releases everything; no error logs; `BUILD` matches the manifest version | real seam behavior |
805
+ | `errors.test.js` | failure mapping (401/404/429/5xx/plain-text/nested bodies), oversize vs quota heuristics, config normalization, partial-route repair, key-pool normalization | a real gateway |
806
+ | `sse.test.js` | event framing: one payload per blank line, multi-line data, CRLF, comments, frames split across reads, byte-split UTF-8, an unterminated tail, and reader cancellation | gateway framing quirks |
807
+ | `chunks.test.js` | the `StreamChunk` contract: sequential block indices, one open text or reasoning block, the tool-call lifecycle, a forced close on finish, the `{}` arguments default | how the seam consumes the sequence |
808
+ | `convert.test.js` | history translation for all three protocols, tool calls and results, Gemini folding and adjacent merging, tool filtering, and the image/file refusal | how the harness assembles history |
809
+ | `wire-chat.test.js` | the Chat Completions request body and reply parser: finish mapping, usage detail, in-band errors | a live gateway |
810
+ | `wire-responses.test.js` | the Responses request body and reply parser: `response.*` events, truncation, failure events | a live gateway |
811
+ | `wire-gemini.test.js` | Gemini protocol: the body carries only documented fields, every reply envelope parses, refusals are classified, one request dispatches through the real adapter | a live gateway |
812
+ | `adapter.test.js` | route and model gates, non-auth statuses are not retried, a 401 body that echoes the key is redacted, header precedence, fetch and mid-stream abort, empty answers, rotation order and TTLs | a broken network |
813
+ | `pool.test.js` | stubbed gateway: failover order, rotation cursor, disabled-model refusal, missing-credential refusal | network behavior |
814
+ | `client.test.js` | loader contract, slot registration and order, controller load/diff/save, catalogue add/remove/edit operations, documented-capacity defaults and their restore action, checkbox auto-save, endpoint lock/unlock, partial-route hydration and repair, credential writes, guarded-service trap, initial render | a real browser |
789
815
  | `smoke.mjs` | live text, reasoning, tool call, multi-turn tool history, unknown-model guard; the Responses and Gemini routes with `--all` | failure paths that need a broken gateway |
790
816
 
791
817
  Run them directly or through the manifest:
792
818
 
793
819
  ```bash
794
- node scripts/plugin-check.mjs
795
- node scripts/check-errors.mjs
796
- node scripts/client-check.mjs
797
- node scripts/check-pool.mjs
798
- node scripts/check-gemini.mjs
820
+ npx vitest run # every suite, once
821
+ npx vitest run test/sse.test.js # one suite
822
+ npx vitest # watch mode
799
823
  npm run defaults # refresh client.js after editing lib/models.js
800
- npm run check # stubs + capacity sync + all five
824
+ npm run check # stubs + capacity sync + every suite (what CI runs)
801
825
  ```
802
826
 
827
+ `npm test` mounts the Host stubs first through `pretest`; a directly invoked `npx vitest` needs
828
+ `npm run stubs` once in a bare checkout. Vitest 5 itself needs Node 22.12 or newer, which is a
829
+ development-only constraint — the published plugin runs on any Node 22, because Vitest is not a
830
+ runtime dependency.
831
+
803
832
  ### How the fake gateway works
804
833
 
805
- `check-pool.mjs` replaces `globalThis.fetch` with a function that inspects the `api-key`
834
+ `pool.test.js` replaces `globalThis.fetch` with a function that inspects the `api-key`
806
835
  header. The first key answers `401` with the gateway's real body, the second answers a
807
836
  minimal SSE stream. That is enough to assert attempt order, cursor advance, and that the
808
- stream text survived. Copy that shape for any new failover rule.
837
+ stream text survived. Copy that shape for any new failover rule; restore the global in
838
+ `afterEach`, or the next test answers from the previous gateway.
809
839
 
810
840
  ### How the Client is exercised
811
841
 
812
- `client-check.mjs` sets `globalThis.window.__ModuleLoader__.load` to capture the module
842
+ `client.test.js` sets `globalThis.window.__ModuleLoader__.load` to capture the module
813
843
  spec, calls the factory with a React stub, then drives the controller against a fake
814
844
  Remote. The React stub only implements what one render needs — do not grow it into a
815
845
  renderer; assert on the controller and on the tree instead.
816
846
 
847
+ ### Continuous integration
848
+
849
+ `.github/workflows/ci.yml` runs the same suites on every push to `main` and on every pull
850
+ request, so a green local `npm run check` and a green CI run mean the same thing.
851
+
852
+ | Job | Runner | What it runs |
853
+ |---|---|---|
854
+ | `offline` | Ubuntu with Node 22 and 24; Windows with Node 22 | `npm install`, then `npm run check`; the Ubuntu/Node 22 run also does `npm pack --dry-run` and reads the file list |
855
+
856
+ Only `@deepseek-ai/schemastery` and Vitest are installed: the two Host peers stay optional and
857
+ the suites mount `dev/host-stubs` themselves, so CI needs no DeepSeek Harness install and no
858
+ credential. The Windows job is deliberate — `scripts/link-stubs.mjs` takes a different path
859
+ there (a junction, with a plain copy as fallback), every suite loads `lib/` with native
860
+ path separators, and Vitest runs on worker threads rather than forked processes.
861
+
862
+ CI proves the plugin works, not that the gateway answers: it holds no `HKU_TEST_KEY` and never
863
+ calls HKU, so a pull request from a fork runs the same thing as a push to `main`. The live wire
864
+ matrix is a manual, local step before a release, run with your own key:
865
+
866
+ ```bash
867
+ HKU_TEST_KEY=… node scripts/smoke.mjs --all # PowerShell: $env:HKU_TEST_KEY = '…'
868
+ ```
869
+
870
+ If you add a suite, name it `test/<name>.test.js`: the `include` glob in `vitest.config.js`
871
+ picks it up, CI runs it through `npm run check`, and `package.test.js` fails while
872
+ `DEVELOPMENT.md` does not list it.
873
+
817
874
  ---
818
875
 
819
876
  ## 11. Recipes
@@ -835,7 +892,7 @@ remains the default for a fresh profile.
835
892
  3. If it should be on by default, do nothing — `enabled` defaults to true. Otherwise set
836
893
  `enabled: false` so it ships hidden behind a toggle.
837
894
  4. Update the catalogue tables in `README.md`.
838
- 5. `node scripts/check-pool.mjs` (it asserts a few ids), then `smoke` with the model.
895
+ 5. `npx vitest run test/pool.test.js` (it asserts a few ids), then `smoke` with the model.
839
896
 
840
897
  ### Add a vendor route
841
898
 
@@ -853,7 +910,7 @@ from section 7. Then four touch points:
853
910
  2. the `api` union in `lib/config.js` **and** the `API_KINDS` set in `normalizeRoutes`
854
911
  (a value missing from the set silently falls back to `openai-responses`);
855
912
  3. the `API_LABEL` map in `client.js`, so the route card shows a readable chip;
856
- 4. a suite in `scripts/` and a live case in `smoke.mjs`.
913
+ 4. a suite under `test/` and a live case in `smoke.mjs`.
857
914
 
858
915
  If the gateway can stream, send `accept: text/event-stream`; otherwise ask for the document
859
916
  you actually want and let the parser sniff. Never send a field the published schema lacks:
@@ -863,21 +920,25 @@ an undocumented field risks failing the whole route for no gain.
863
920
  ### Change the rotation or rejection policy
864
921
 
865
922
  All of it lives in `lib/adapter.js`: `cursorOf`, `orderKeys`, `markRejected`, `clearRejected`.
866
- The offline proof is `check-pool.mjs` — extend it before changing behavior, and keep the
923
+ The offline proof is `test/pool.test.js` — extend it before changing behavior, and keep the
867
924
  "fail over only before output" property.
868
925
 
869
926
  ### Add a settings field
870
927
 
871
- 1. `lib/config.js`: add the field to `modelSchema` or `providerSchema` with a default.
928
+ 1. `lib/config.js`: add the field to `modelSchema` or `providerSchema` with a default —
929
+ except for a field the catalogue in `lib/models.js` already declares per route
930
+ (`api`, `baseURL`, `displayName`). A schema default is applied before `normalizeRoutes`
931
+ runs, so it silently wins over the catalogue value; leave those three without one and let
932
+ `normalizeRoutes` supply the fallback.
872
933
  2. `normalizeRoutes()`: validate and default it for the runtime table.
873
934
  3. `client.js`: read it in `load()`, render it in `HkuSection`, include it in `desired()`.
874
935
  4. `controller.save()`: append one diff operation when it changed.
875
- 5. `scripts/client-check.mjs`: assert the operation; `scripts/plugin-check.mjs` if the
936
+ 5. `test/client.test.js`: assert the operation; `test/plugin.test.js` if the
876
937
  registration shape changed.
877
938
 
878
939
  ### Add an error mapping
879
940
 
880
- `lib/errors.js` first (status map or a heuristic), then `check-errors.mjs` with the exact
941
+ `lib/errors.js` first (status map or a heuristic), then `test/errors.test.js` with the exact
881
942
  body and size that reproduces it. Keep the message actionable: what happened, and the one
882
943
  thing the reader can do.
883
944
 
@@ -890,13 +951,13 @@ thing the reader can do.
890
951
  | Field | Value | Why it matters |
891
952
  |---|---|---|
892
953
  | `name` | `dsh-hku-llm` | package name; also the `name` in `cordis.patch.yml` |
893
- | `version` | `1.6.0` | must match `BUILD` in `client.js` |
954
+ | `version` | `1.6.1` | must match `BUILD` in `client.js`; `test/plugin.test.js` enforces it |
894
955
  | `private` | absent | the package is published; a stray `true` blocks `npm publish` |
895
956
  | `type` | `module` | everything is ESM |
896
957
  | `license`, `author`, `homepage`, `repository`, `bugs` | MIT, contributors, the GitHub URL | what the npm listing links to; relative README images resolve against `repository` |
897
958
  | `publishConfig.access` | `public` | explicit for the first publish |
898
959
  | `exports` | `.`, `./client`, `./locale/*.json`, `./icon`, `./package.json` | how the Host and the browser find each half |
899
- | `files` | `index.js`, `client.js`, `lib/**`, `cordis.patch.yml`, `locale`, `icon.svg`, `LICENSE`, all three READMEs, `DEVELOPMENT.md`, `docs/**/*.svg` | what a pack ships; `dev/` and `scripts/` stay out |
960
+ | `files` | `index.js`, `client.js`, `lib/**`, `cordis.patch.yml`, `locale`, `icon.svg`, `LICENSE`, `README.md`, `README-zh-CN.md`, `README-zh-TW.md`, `DEVELOPMENT.md`, `docs/**/*.svg` | what a pack ships; `dev/`, `scripts/` and `test/` stay out |
900
961
  | `peerDependencies` | `@deepseek-ai/dsh-llm`, `@deepseek-ai/dsh-tools` (≥ 0.2.0) | provided by the Host |
901
962
  | `peerDependenciesMeta` | both `optional: true` | no package manager installs them, and a plain `npm install` of this package never resolves the Host's prerelease versions |
902
963
  | `dependencies` | `@deepseek-ai/schemastery` | the only package the plugin resolves itself |
@@ -916,6 +977,15 @@ thing the reader can do.
916
977
  `id` must equal `export const name` — it is the settings namespace the page writes to. If
917
978
  the two drift, the page renders "not active in this profile" while the Host half runs.
918
979
 
980
+ ### Which README npm publishes
981
+
982
+ npm builds the package page from a `{README,README.*}` glob and takes the **first** match, and
983
+ that glob returns those names in reverse alphabetical order. A `README.zh-TW.md` would
984
+ therefore win over `README.md`, and the npm page would open in Traditional Chinese. The
985
+ translations are named with a hyphen (`README-zh-CN.md`, `README-zh-TW.md`) because that
986
+ pattern does not match `README.*`. Keep that shape: renaming them back silently changes which
987
+ document the package page shows.
988
+
919
989
  ### Bumping the version
920
990
 
921
991
  Two files, one commit:
@@ -928,12 +998,13 @@ build is actually loaded. A stale `BUILD` makes bug reports ambiguous.
928
998
 
929
999
  ### Release checklist
930
1000
 
931
- 1. `npm run check` — five suites green. `prepublishOnly` runs the same command, so a red
1001
+ 1. `npm run check` — every suite green. `prepublishOnly` runs the same command, so a red
932
1002
  tree cannot be published.
933
1003
  2. `HKU_TEST_KEY=… node scripts/smoke.mjs --all` — every protocol, including the
934
1004
  multi-turn tool history case and the Gemini text cases.
935
- 3. Bump `version` and `BUILD`; update the catalogue tables if models changed, and the
936
- version badge in each README.
1005
+ 3. Bump `version` and `BUILD` (the plugin check fails when they disagree); update the
1006
+ catalogue tables if models changed. The npm badge reads the published version, so no
1007
+ README edit is needed for a version bump.
937
1008
  4. `npm pack --dry-run` — read the file list: two halves, `lib/**`, the patch, locale, icon,
938
1009
  the docs, and nothing from `dev/`, `scripts/` or `node_modules/`.
939
1010
  5. `npm publish` (add `--dry-run` first if you want the full report without uploading), then
@@ -977,7 +1048,7 @@ build is actually loaded. A stale `BUILD` makes bug reports ambiguous.
977
1048
 
978
1049
  ### Reproduce a failure without HKU
979
1050
 
980
- Stub `globalThis.fetch` exactly as `check-pool.mjs` does: return a `Response` with the
1051
+ Stub `globalThis.fetch` exactly as `test/pool.test.js` does: return a `Response` with the
981
1052
  gateway's body and status. That covers 401, 404, 429, 5xx, the oversize 400 and the quota
982
1053
  400 without touching the network.
983
1054
 
@@ -1,4 +1,4 @@
1
- **语言:** [English](README.md) · **简体中文** · [繁體中文](README.zh-TW.md)
1
+ **语言:** [English](README.md) · **简体中文** · [繁體中文](README-zh-TW.md)
2
2
 
3
3
  # dsh-hku-llm
4
4
 
@@ -7,7 +7,7 @@
7
7
  </div>
8
8
 
9
9
  <div align="center">
10
- <img src="https://img.shields.io/badge/version-1.6.0-0f7a6a?style=flat-square" alt="版本 1.6.0">
10
+ <a href="https://www.npmjs.com/package/dsh-hku-llm"><img src="https://img.shields.io/npm/v/dsh-hku-llm?style=flat-square&color=cb3837" alt="npm 上的 dsh-hku-llm"></a>
11
11
  <img src="https://img.shields.io/badge/models-25%20in%203%20routes-0d2b4b?style=flat-square" alt="3 条路由中共 25 个模型">
12
12
  <img src="https://img.shields.io/badge/DeepSeek%20Harness-%E2%89%A5%200.2.0-0f7a6a?style=flat-square" alt="DeepSeek Harness 0.2.0 或更高版本">
13
13
  <img src="https://img.shields.io/badge/license-MIT-555555?style=flat-square" alt="MIT 许可证">
@@ -38,122 +38,48 @@
38
38
 
39
39
  ## 为什么需要这个插件
40
40
 
41
- HKU 网关使用 **`api-key` 请求头**进行认证,而不是 `Authorization: Bearer`。DSH 中每个
42
- 通用提供方路由发送的都是 bearer 认证,这就是为什么在“设置 → 模型”下手工声明的
43
- `hku-openai` 路由只会得到:
41
+ HKU 网关使用 **`api-key` 请求头**认证,而不是 `Authorization: Bearer`。DSH 中每个通用
42
+ 提供方路由发送的都是 bearer 认证,所以在 **设置 → 模型** 下手工声明的路由只会得到:
44
43
 
45
44
  ```
46
45
  401 Access denied due to missing subscription key.
47
46
  ```
48
47
 
49
- 本插件针对网关实际提供的协议注册了自己的适配器,因此请求头是正确的,模型的行为
50
- 也与任何其他 DSH 模型一样:流式传输、工具调用、推理、用量统计。
48
+ 本插件为网关提供的三种协议注册了自己的适配器,因此请求头正确,模型的表现与任何其他
49
+ DSH 模型一样。
51
50
 
52
- | 路由 | 协议 | 端点 | 模型 |
53
- |---|---|---|---|
54
- | `hku-chat` | Chat Completions | `https://api.hku.hk/deepseek/models` → `/chat/completions` | DeepSeek V3.2、V4 Flash、V4.1 Flash (1017)、V4 Pro、Kimi K3.1 Pro |
55
- | `hku-responses` | Responses | `https://api.hku.hk/openai/v1` → `/responses` | GPT-4.1 系列、o4-mini、GPT-5 系列、GPT-6 系列 |
56
- | `hku-gemini` | Gemini Chat Completions | `https://api.hku.hk/vertexai-gemini` → `/chat/completions` | Gemini 2.5 Flash、3 Flash (preview)、3.1 Pro (preview)、3.5 Flash、4 Carbon、4 Hydrogen |
57
-
58
- OpenAI 模型清单就是 HKU 开发者手册中公布的模型目录。你的订阅不包含的模型,网关会返回
59
- `500` 而不是 `404`,所以请在设置页面把用不到的模型保持关闭。
60
-
61
- OpenAI 前缀**只提供 Responses** —— 在本网关上 `/openai/v1/chat/completions` 返回 404,
62
- 因此把“自定义模型 API”指向该路径无法工作。
63
-
64
- Gemini 服务则是其中能力最窄的一个:它的 Chat Completions 操作只接受一个模型 id 和一份
65
- `content` 为字符串的消息列表,只返回一份 JSON 文档,并且不提供函数调用 —— 除它自带的
66
- `url_context` 之外,网关会拒绝任何工具。详见[已知限制](#已知限制)。
67
-
68
- ## 你能得到什么
69
-
70
- | | |
71
- |---|---|
72
- | **三种协议,一个选择器** | 每个 HKU 前缀都会变成普通的 DSH 提供方:同一个输入框、同一个选择器、同一个设置页。工具调用与流式输出仍取决于具体线路。 |
73
- | **可故障转移的密钥池** | 请求会在所有已配置的密钥之间轮换;被网关拒绝的密钥会在第一个数据块到来之前就被跳过,因此故障转移绝不会重复输出答案。 |
74
- | **按模型开关** | 目录中的任何模型都可以从选择器中隐藏并拒绝请求,无需编辑文件。目录本身永远不会被破坏。 |
75
- | **属于你的模型目录** | 重命名模型、修改网关 id、调整上下文窗口或输出上限、声明推理等级、添加内置目录中缺少的模型,或删除从不使用的模型 —— 全部在设置页面上完成。 |
76
- | **一个设置页面** | 启用路由、重命名路由、编辑端点、管理模型目录、切换模型、添加或移除密钥槽位 —— 全部在“设置 → HKU 生成式 AI”中。 |
77
- | **一个健康检查工具** | `hku_llm_status` 报告路由、凭据和模型,并可以发起一次小型的实时调用。 |
78
- | **会告诉你该做什么的错误** | `401`、`404`、`429`、`5xx`、2 MiB 边缘限制以及空账户,每一种都会映射到具名错误码,并附带可操作的提示。 |
79
-
80
- ## 设置页面
81
-
82
- <img src="docs/assets/settings-page.svg" width="760" alt="HKU 生成式 AI 设置页面:启用开关、密钥槽位,以及一张带名称、端点和可编辑模型行的路由卡片">
83
-
84
- <p align="center"><sub>设置 → HKU 生成式 AI 的示意图。真实页面会跟随你的 DSH 主题,并显示你自己的密钥槽位。</sub></p>
85
-
86
- 这个页面是完成以下事项的唯一入口:
51
+ | 路由 | 协议 | 端点 |
52
+ |---|---|---|
53
+ | `hku-chat` | Chat Completions | `https://api.hku.hk/deepseek/models` |
54
+ | `hku-responses` | Responses | `https://api.hku.hk/openai/v1` |
55
+ | `hku-gemini` | Gemini Chat Completions | `https://api.hku.hk/vertexai-gemini` |
87
56
 
88
- - 开启或关闭每条路由;
89
- - 重命名路由并编辑其端点;
90
- - **管理模型目录** —— 打开某个模型的参数,修改它的网关 id、标签、上下文窗口、
91
- 输出上限、输入类型或推理等级;**添加模型** 会追加内置目录中缺少的条目,
92
- **移除** 会删除从不使用的模型;
93
- - **逐个切换模型** —— 未勾选的模型会离开选择器并拒绝请求,直到重新勾选为止,
94
- 而条目本身仍保留在目录中;
95
- - **维护开发者门户密钥池** —— `添加密钥` 追加一个槽位,`移除` 删除一个槽位,
96
- 请求会在所有已配置的密钥之间轮换;
97
- - 保存或清除密钥值(只写,经由凭据存储)。
57
+ OpenAI 前缀只提供 Responses,而 Gemini 除自带的 `url_context` 外会拒绝任何工具 —— 详见
58
+ [已知限制](#已知限制)。订阅之外的模型返回 `500` 而不是 `404`,所以用不到的就关掉。
98
59
 
99
60
  ## 安装
100
61
 
101
- ### 准备工作
102
-
103
- - **DeepSeek Harness 0.2.0 或更高版本**,桌面应用,或你自行启动的 Web 构建。
104
- - **插件包本身**,可从 npm 获取(已发布的包名为 `dsh-hku-llm`),或从
105
- [github.com/r48n34/dsh-hku-llm](https://github.com/r48n34/dsh-hku-llm) 获取。只有 GitHub
106
- 方式需要 **PATH 中有 Git**(安装前 DSH 会用 `git ls-remote` 检查仓库,pnpm 也会用 Git
107
- 拉取仓库)以及 **仓库必须公开**(该检查会禁用凭据助手和交互提示)。
108
- - **一个 HKU GenAI 开发者门户密钥。** 在 [genai.hku.hk](https://genai.hku.hk) 创建。
109
- 该密钥的调用会计入你的 AI 额度。
110
- - **仅支持文本模型。** 所有内置模型都是纯文本模型;图片会被替换为占位符,而不是让
111
- 该轮对话失败。
112
-
113
- ### 1. 安装插件包
114
-
115
- DSH 可以从包标识安装插件包 —— npm 包名或 Git 地址:无需手动克隆,也无需单独运行
116
- `pnpm install`。DSH 会把该包解析进你的 profile,安装插件唯一的运行时依赖,并选中该
117
- 插件包。
118
-
119
- **从 npm 安装(推荐)。** 已发布的包名为 `dsh-hku-llm`。
120
-
121
- 1. 在 DSH 侧边栏中选择 **插件**。
122
- 2. 选择 **添加插件** —— 或打开其箭头菜单,选择 **安装第三方插件**。
123
- 3. 将包名粘贴到包/地址输入框:`dsh-hku-llm`。
124
- 4. 确认信任提示,然后选择 **安装**。DSH 会从注册表解析该包,并显示找到的包名和版本。
125
- 5. 完成后选择 **立即启用**。如果你改为关闭该对话框,插件包仍会保持已安装但处于关闭
126
- 状态;此时请在 **已安装插件** 下打开它的 **HKU 生成式 AI 模型** 卡片。
127
- 6. 完全退出并重新打开 DSH。安装会在启动时生效:Host 部分(适配器、凭据查询、状态
128
- 工具)被加载,**设置 → HKU 生成式 AI** 出现在导航中。之所以必须重启,是因为 Web
129
- 客户端在启动时构建其模块图。
62
+ `dsh-hku-llm` 已[发布到 npm](https://www.npmjs.com/package/dsh-hku-llm)。通过你的 DSH profile 安装:
130
63
 
131
- **从 GitHub 安装。** 改为把 `https://github.com/r48n34/dsh-hku-llm` 粘贴到包/地址输入
132
- 框,其余步骤相同。该方式需要 PATH 中有 Git 且仓库公开,并跟随仓库的默认分支。
133
-
134
- > **以后更新。** 移除插件包后重新安装即可获取新版本 —— npm 方式会解析最新发布版本,
135
- > GitHub 方式则跟随默认分支。DSH 没有为第三方插件包提供单独的更新操作。
136
-
137
- ### 2. 添加密钥
64
+ ```bash
65
+ dsh plugin --profile web add dsh-hku-llm
66
+ ```
138
67
 
139
- 打开 **设置 → HKU 生成式 AI**(它位于 Agent 预设与插件市场之间)。粘贴开发者门户密钥,
140
- 然后选择 **保存密钥**。
68
+ 也可以直接从本仓库安装 —— 当你需要 npm 上还没有的提交,或 npm 不可达时使用 GitHub 形式(需要 PATH 中有 Git,且仓库公开):
141
69
 
142
- 该值会写入 DSH 凭据存储,绝不会写入 profile 文件。更想用环境变量?
143
- `HKU_OPENAI_API_KEY` 同样有效 —— 参见 [凭据](#凭据)。
70
+ ```bash
71
+ dsh plugin --profile web add github:r48n34/dsh-hku-llm
72
+ ```
144
73
 
145
- ### 3. 选择模型
74
+ 如果你的 DSH 使用桌面(Desktop)profile,请改用 **设置 → 插件** 中显示的 profile 名称(桌面应用通常为 `desktop`):
146
75
 
147
- 仍在同一页面上:取消勾选你的订阅不包含的模型,在某个模型上按 **编辑** 以调整它的 id、
148
- 标签或容量,对目录中缺少的模型使用 **添加模型**,最后按 **保存更改**。任何未勾选的
149
- 条目都会从选择器中消失,并在任何网络 I/O 之前以 `UNKNOWN_MODEL` 被拒绝。被移除的
150
- 模型会从目录中消失;如果改变主意,可用 **添加模型** 加回来。
76
+ ```bash
77
+ dsh plugin --profile desktop add dsh-hku-llm
78
+ ```
151
79
 
152
- ### 4. 选一个模型开始使用
80
+ 安装完成后重启一次 DSH,然后打开 **设置 → HKU 生成式 AI**,粘贴[开发者门户密钥](https://genai.hku.hk)并选择 **保存密钥**。取消勾选你的订阅未包含的模型,其余模型会出现在输入框中。这需要 DeepSeek Harness 0.2.0 或更高版本,且所有内置模型仅支持文本。
153
81
 
154
- 在输入框中选择一个 HKU 模型。`hku-chat` 是稳定的路由,建议从这里开始;当上游健康时,
155
- `hku-responses` 可提供 GPT 与 o 系列模型;`hku-gemini` 则带来 Gemini 系列部署,它们拥有
156
- 1M token 的上下文,但只返回文本答案。
82
+ 更新或卸载:在 DSH 中使用 **设置 → 插件** 并重新安装,或执行 `dsh plugin --profile <name> remove dsh-hku-llm`。
157
83
 
158
84
  ## 验证安装
159
85
 
@@ -210,6 +136,37 @@ DSH 可以从包标识安装插件包 —— npm 包名或 Git 地址:无需
210
136
  失败时返回的是映射后的错误码和信息,而不是 `ok`,所以这也是区分坏密钥和坏端点最快的
211
137
  办法。
212
138
 
139
+ ## 你能得到什么
140
+
141
+ | | |
142
+ |---|---|
143
+ | **三种协议,一个选择器** | 每个 HKU 前缀都会变成普通的 DSH 提供方:同一个输入框、同一个选择器、同一个设置页。工具调用与流式输出仍取决于具体线路。 |
144
+ | **可故障转移的密钥池** | 请求会在所有已配置的密钥之间轮换;被网关拒绝的密钥会在第一个数据块到来之前就被跳过,因此故障转移绝不会重复输出答案。 |
145
+ | **按模型开关** | 目录中的任何模型都可以从选择器中隐藏并拒绝请求,无需编辑文件。目录本身永远不会被破坏。 |
146
+ | **属于你的模型目录** | 重命名模型、修改网关 id、调整上下文窗口或输出上限、声明推理等级、添加内置目录中缺少的模型,或删除从不使用的模型 —— 全部在设置页面上完成。 |
147
+ | **一个设置页面** | 启用路由、重命名路由、编辑端点、管理模型目录、切换模型、添加或移除密钥槽位 —— 全部在“设置 → HKU 生成式 AI”中。 |
148
+ | **一个健康检查工具** | `hku_llm_status` 报告路由、凭据和模型,并可以发起一次小型的实时调用。 |
149
+ | **会告诉你该做什么的错误** | `401`、`404`、`429`、`5xx`、2 MiB 边缘限制以及空账户,每一种都会映射到具名错误码,并附带可操作的提示。 |
150
+
151
+ ## 设置页面
152
+
153
+ <img src="docs/assets/settings-page.svg" width="760" alt="HKU 生成式 AI 设置页面:启用开关、密钥槽位,以及一张带名称、端点和可编辑模型行的路由卡片">
154
+
155
+ <p align="center"><sub>设置 → HKU 生成式 AI 的示意图。真实页面会跟随你的 DSH 主题,并显示你自己的密钥槽位。</sub></p>
156
+
157
+ 这个页面是完成以下事项的唯一入口:
158
+
159
+ - 开启或关闭每条路由;
160
+ - 重命名路由并编辑其端点;
161
+ - **管理模型目录** —— 打开某个模型的参数,修改它的网关 id、标签、上下文窗口、
162
+ 输出上限、输入类型或推理等级;**添加模型** 会追加内置目录中缺少的条目,
163
+ **移除** 会删除从不使用的模型;
164
+ - **逐个切换模型** —— 未勾选的模型会离开选择器并拒绝请求,直到重新勾选为止,
165
+ 而条目本身仍保留在目录中;
166
+ - **维护开发者门户密钥池** —— `添加密钥` 追加一个槽位,`移除` 删除一个槽位,
167
+ 请求会在所有已配置的密钥之间轮换;
168
+ - 保存或清除密钥值(只写,经由凭据存储)。
169
+
213
170
  ## 模型目录
214
171
 
215
172
  上下文窗口转录自 GenAI 应用的 **Model Information** 面板(*Model Information → Text
@@ -552,10 +509,10 @@ DeepSeek 和 Kimi 模型用 `hku-chat`,它也是稳定的默认选择。GPT
552
509
  ## 开发
553
510
 
554
511
  ```bash
555
- pnpm install # 每个克隆一次:唯一的运行时依赖
512
+ pnpm install # 每个克隆一次:运行时依赖与 Vitest
556
513
  node scripts/link-stubs.mjs # 挂载 Host 包的开发副本
557
- npm run check # 五个离线测试套件
558
- HKU_TEST_KEY=... node scripts/smoke.mjs --all # 实时协议测试,覆盖每种协议
514
+ npm test # 全部离线测试套件(Vitest,无需网络)
515
+ HKU_TEST_KEY=... node scripts/smoke.mjs --all # 可选的实时检查(CI 不会运行)
559
516
  node scripts/link-stubs.mjs --unlink # 在安装插件包之前运行
560
517
  ```
561
518
 
@@ -565,6 +522,9 @@ node scripts/link-stubs.mjs --unlink # 在安装插件包之前运行
565
522
  的已安装副本也会解析到它们**,因此在 `install_bundle` 之前要 unlink,需要再次运行测试
566
523
  套件时再重新链接。该脚本从不覆盖不是它创建的包。
567
524
 
525
+ 与本地完全相同,[`.github/workflows/ci.yml`](.github/workflows/ci.yml) 会在每次推送到
526
+ `main` 时运行全部离线测试套件。
527
+
568
528
  完整的开发者指南 —— 架构、接缝契约、请求生命周期、测试策略、配方、打包与发布检查清单
569
529
  —— 见 [DEVELOPMENT.md](DEVELOPMENT.md)。
570
530
 
@@ -1,4 +1,4 @@
1
- **語言:** [English](README.md) · [简体中文](README.zh-CN.md) · **繁體中文**
1
+ **語言:** [English](README.md) · [简体中文](README-zh-CN.md) · **繁體中文**
2
2
 
3
3
  # dsh-hku-llm
4
4
 
@@ -7,7 +7,7 @@
7
7
  </div>
8
8
 
9
9
  <div align="center">
10
- <img src="https://img.shields.io/badge/version-1.6.0-0f7a6a?style=flat-square" alt="版本 1.6.0">
10
+ <a href="https://www.npmjs.com/package/dsh-hku-llm"><img src="https://img.shields.io/npm/v/dsh-hku-llm?style=flat-square&color=cb3837" alt="npm 上的 dsh-hku-llm"></a>
11
11
  <img src="https://img.shields.io/badge/models-25%20in%203%20routes-0d2b4b?style=flat-square" alt="3 個路由共 25 個模型">
12
12
  <img src="https://img.shields.io/badge/DeepSeek%20Harness-%E2%89%A5%200.2.0-0f7a6a?style=flat-square" alt="DeepSeek Harness 0.2.0 或更新版本">
13
13
  <img src="https://img.shields.io/badge/license-MIT-555555?style=flat-square" alt="MIT 授權">
@@ -38,119 +38,48 @@
38
38
 
39
39
  ## 為何需要這個插件
40
40
 
41
- HKU 閘道使用 **`api-key` 標頭**驗證,而不是 `Authorization: Bearer`。DSH 中每一個通用提供方
42
- 路由都送出 bearer 驗證,這就是為什麼在「設定 → 模型」下手動宣告的 `hku-openai` 路由會得到:
41
+ HKU 閘道使用 **`api-key` 標頭**驗證,而不是 `Authorization: Bearer`。DSH 中每個通用提供方
42
+ 路由送出的都是 bearer 驗證,所以在 **設定 → 模型** 下手動宣告的路由只會得到:
43
43
 
44
44
  ```
45
45
  401 Access denied due to missing subscription key.
46
46
  ```
47
47
 
48
- 本插件為閘道實際提供的協定註冊自己的適配器,因此標頭正確,模型的行為也與任何其他 DSH
49
- 模型相同:串流、工具呼叫、推理、用量。
48
+ 本插件為閘道提供的三種協定註冊自己的適配器,因此標頭正確,模型的行為也與任何其他 DSH
49
+ 模型相同。
50
50
 
51
- | 路由 | 協定 | 端點 | 模型 |
52
- |---|---|---|---|
53
- | `hku-chat` | Chat Completions | `https://api.hku.hk/deepseek/models` → `/chat/completions` | DeepSeek V3.2、V4 Flash、V4.1 Flash (1017)、V4 Pro、Kimi K3.1 Pro |
54
- | `hku-responses` | Responses | `https://api.hku.hk/openai/v1` → `/responses` | GPT-4.1 系列、o4-mini、GPT-5 系列、GPT-6 系列 |
55
- | `hku-gemini` | Gemini Chat Completions | `https://api.hku.hk/vertexai-gemini` → `/chat/completions` | Gemini 2.5 Flash、3 Flash (preview)、3.1 Pro (preview)、3.5 Flash、4 Carbon、4 Hydrogen |
56
-
57
- OpenAI 清單是 HKU 開發者手冊所公布的目錄。你的訂閱未包含的模型,閘道會回 `500` 而不是
58
- `404`,因此請在設定頁面上把用不到的模型保持關閉。
59
-
60
- OpenAI 前綴**只提供 Responses** —— `/openai/v1/chat/completions` 在此閘道上回傳 404,因此
61
- 指向該路徑的「自訂模型 API」項目無法運作。
62
-
63
- Gemini 服務則是其中範圍最窄的一個:它的 Chat Completions 操作只接受一個模型 id 與一份
64
- `content` 為字串的訊息清單,只回傳一份 JSON 文件,而且不提供函式呼叫 —— 除了它自帶的
65
- `url_context`,閘道會拒絕任何工具。詳見[已知限制](#已知限制)。
66
-
67
- ## 你會得到什麼
68
-
69
- | | |
70
- |---|---|
71
- | **三種協定,一個選擇器** | 每個 HKU 前綴都成為一般的 DSH 提供方:同一個輸入區、同一個選擇器、同一個設定頁。工具呼叫與串流輸出仍取決於具體路由。 |
72
- | **可容錯切換的金鑰池** | 請求會在所有已設定的金鑰之間輪替;被閘道拒絕的金鑰會在送出第一個區塊之前就被跳過,因此容錯切換不會重複送出答案。 |
73
- | **個別模型開關** | 目錄中的任何模型都能從選擇器隱藏並拒絕請求,不必編輯檔案。目錄本身永遠不會被破壞。 |
74
- | **由你掌握的模型目錄** | 重新命名模型、變更閘道 id、重新調整上下文視窗或輸出上限、宣告推理等級、新增隨附目錄沒有的模型,或刪除你從未使用的模型 —— 全都在設定頁面上完成。 |
75
- | **單一設定頁面** | 啟用路由、重新命名、編輯端點、管理模型目錄、切換模型、新增或移除金鑰插槽 —— 全都在「設定 → HKU 生成式 AI」中完成。 |
76
- | **健康檢查工具** | `hku_llm_status` 回報路由、憑證與模型,並可發出一次小型即時呼叫。 |
77
- | **告訴你該怎麼做的錯誤** | `401`、`404`、`429`、`5xx`、2 MiB 邊緣限制以及帳戶額度用盡,各自對應到一個具名代碼與可據以行動的訊息。 |
78
-
79
- ## 設定頁面
80
-
81
- <img src="docs/assets/settings-page.svg" width="760" alt="HKU 生成式 AI 設定頁面:啟用開關、金鑰插槽,以及一張含名稱、端點與可編輯模型列的路由卡片">
51
+ | 路由 | 協定 | 端點 |
52
+ |---|---|---|
53
+ | `hku-chat` | Chat Completions | `https://api.hku.hk/deepseek/models` |
54
+ | `hku-responses` | Responses | `https://api.hku.hk/openai/v1` |
55
+ | `hku-gemini` | Gemini Chat Completions | `https://api.hku.hk/vertexai-gemini` |
82
56
 
83
- <p align="center"><sub>「設定 → HKU 生成式 AI」示意圖。實際頁面會依你的 DSH 主題呈現,並顯示你自己的金鑰插槽。</sub></p>
84
-
85
- 那個頁面是唯一能完成這些事的地方:
86
-
87
- - 開啟或關閉每個路由;
88
- - 重新命名路由並編輯其端點;
89
- - **管理模型目錄** —— 開啟模型的參數以變更其閘道 id、標籤、上下文視窗、輸出上限、輸入
90
- 類型或推理等級;**新增模型** 會附加隨附目錄沒有的項目,**移除** 則刪除你從未使用的項目;
91
- - **切換個別模型** —— 未勾選的模型會離開選擇器並拒絕請求,直到再次勾選為止,而該項目本身
92
- 仍留在目錄中;
93
- - **維護 Developer Portal 金鑰池** —— `新增金鑰` 會附加一個插槽、`移除` 會刪除一個,請求
94
- 會在所有已設定的金鑰之間輪替;
95
- - 儲存或清除金鑰值(唯寫,透過憑證儲存)。
57
+ OpenAI 前綴只提供 Responses,而 Gemini 除自帶的 `url_context` 外會拒絕任何工具 —— 詳見
58
+ [已知限制](#已知限制)。訂閱之外的模型回傳 `500` 而不是 `404`,所以用不到的就關掉。
96
59
 
97
60
  ## 安裝
98
61
 
99
- ### 開始之前
100
-
101
- - **DeepSeek Harness 0.2.0 或更新版本**,桌面應用程式,或由你自己啟動的 Web 版本。
102
- - **插件包本身**,可從 npm 取得(已發佈的套件名稱為 `dsh-hku-llm`),或從
103
- [github.com/r48n34/dsh-hku-llm](https://github.com/r48n34/dsh-hku-llm) 取得。只有 GitHub
104
- 方式需要 **PATH 中有 Git**(安裝前 DSH 會用 `git ls-remote` 檢查儲存庫,pnpm 也會用 Git
105
- 取得儲存庫)以及 **儲存庫必須公開**(該檢查會停用憑證輔助程式與互動提示)。
106
- - **一組 HKU GenAI Developer Portal 金鑰。** 在 [genai.hku.hk](https://genai.hku.hk) 建立。
107
- 金鑰的用量會從你的 AI 額度(AI credits)扣抵。
108
- - **僅支援文字模型。** 所有隨附模型都只支援文字;圖片會被替換為佔位符,而不是讓該回合失敗。
109
-
110
- ### 1. 安裝插件包
111
-
112
- DSH 可以從套件規格安裝插件包 —— npm 套件名稱或 Git 位址:不必手動複製儲存庫,也不必另外
113
- 執行 `pnpm install`。DSH 會把該套件解析進你的 profile、安裝插件唯一的執行期相依套件,並
114
- 選取該插件包。
115
-
116
- **從 npm 安裝(建議)。** 已發佈的套件名稱為 `dsh-hku-llm`。
117
-
118
- 1. 在 DSH 側邊欄選擇 **插件**。
119
- 2. 選擇 **新增插件** —— 或開啟其箭頭選單並選擇 **安裝第三方插件**。
120
- 3. 把套件名稱貼到套件/位址欄位:`dsh-hku-llm`。
121
- 4. 確認信任提示,然後選擇 **安裝**。DSH 會從註冊表解析該套件,並顯示找到的套件與版本。
122
- 5. 完成後選擇 **立即啟用**。如果你改成關閉對話框,插件包仍會保持安裝但處於停用狀態;請在
123
- **已安裝插件** 中開啟它的 **HKU 生成式 AI 模型** 卡片。
124
- 6. 完全結束並重新開啟 DSH。安裝會在啟動時生效:Host 部分(適配器、憑證查詢、狀態工具)
125
- 會載入,**設定 → HKU 生成式 AI** 也會出現在導覽中。之所以必須重新啟動,是因為 Web
126
- 客戶端在啟動時才會組合其模組圖。
62
+ `dsh-hku-llm` 已[發佈到 npm](https://www.npmjs.com/package/dsh-hku-llm)。透過你的 DSH profile 安裝:
127
63
 
128
- **從 GitHub 安裝。** 改為把 `https://github.com/r48n34/dsh-hku-llm` 貼到套件/位址欄位,
129
- 其餘步驟相同。該方式需要 PATH 中有 Git 且儲存庫公開,並會跟隨儲存庫的預設分支。
130
-
131
- > **日後更新。** 移除插件包後重新安裝即可取得新版本 —— npm 方式會解析最新已發佈版本,
132
- > GitHub 方式則跟隨預設分支。DSH 沒有為第三方插件包提供個別的更新操作。
133
-
134
- ### 2. 新增你的金鑰
64
+ ```bash
65
+ dsh plugin --profile web add dsh-hku-llm
66
+ ```
135
67
 
136
- 開啟 **設定 → HKU 生成式 AI**(它位於 Agent 預設集與插件市場之間)。貼上 Developer Portal
137
- 金鑰並選擇 **儲存金鑰**。
68
+ 也可以直接從本儲存庫安裝 —— 當你需要 npm 上還沒有的提交,或 npm 不可達時使用 GitHub 形式(需要 PATH 中有 Git,且儲存庫公開):
138
69
 
139
- 金鑰值會寫入 DSH 憑證儲存,絕不會進入 profile 檔案。偏好使用環境變數?
140
- `HKU_OPENAI_API_KEY` 也可以 —— 請見 [憑證](#憑證)。
70
+ ```bash
71
+ dsh plugin --profile web add github:r48n34/dsh-hku-llm
72
+ ```
141
73
 
142
- ### 3. 選擇你的模型
74
+ 如果你的 DSH 使用桌面(Desktop)profile,請改用 **設定 → 插件** 中顯示的 profile 名稱(桌面應用程式通常為 `desktop`):
143
75
 
144
- 仍在同一個頁面:取消勾選你的訂閱未包含的模型,在模型上按 **編輯** 以調整其 id、標籤或容量,
145
- 對目錄缺少的模型使用 **新增模型**,然後按 **儲存變更**。任何未勾選的項目都會從選擇器消失,
146
- 並在任何網路 I/O 之前以 `UNKNOWN_MODEL` 拒絕。已移除的模型會從目錄中消失;如果改變主意,
147
- 可用 **新增模型** 加回來。
76
+ ```bash
77
+ dsh plugin --profile desktop add dsh-hku-llm
78
+ ```
148
79
 
149
- ### 4. 選擇模型並開始
80
+ 安裝完成後重新啟動一次 DSH,然後開啟 **設定 → HKU 生成式 AI**,貼上[Developer Portal 金鑰](https://genai.hku.hk)並選擇 **儲存金鑰**。取消勾選你的訂閱未包含的模型,其餘模型會出現在輸入區。這需要 DeepSeek Harness 0.2.0 或更新版本,且所有隨附模型僅支援文字。
150
81
 
151
- 在輸入區選擇一個 HKU 模型。`hku-chat` 是穩定的路由,建議從它開始;當上游狀況良好時,
152
- `hku-responses` 可讓你使用 GPT 與 o 系列模型;`hku-gemini` 則加入 Gemini 系列部署,它們
153
- 具備 1M token 的上下文,但只回傳文字答案。
82
+ 更新或解除安裝:在 DSH 中使用 **設定 → 插件** 並重新安裝,或執行 `dsh plugin --profile <name> remove dsh-hku-llm`。
154
83
 
155
84
  ## 驗證安裝
156
85
 
@@ -206,6 +135,36 @@ DSH 可以從套件規格安裝插件包 —— npm 套件名稱或 Git 位址
206
135
  失敗時會回傳對應的代碼與訊息,而不是 `ok`,因此這也是分辨「金鑰有問題」與「端點有問題」
207
136
  最快的方法。
208
137
 
138
+ ## 你會得到什麼
139
+
140
+ | | |
141
+ |---|---|
142
+ | **三種協定,一個選擇器** | 每個 HKU 前綴都成為一般的 DSH 提供方:同一個輸入區、同一個選擇器、同一個設定頁。工具呼叫與串流輸出仍取決於具體路由。 |
143
+ | **可容錯切換的金鑰池** | 請求會在所有已設定的金鑰之間輪替;被閘道拒絕的金鑰會在送出第一個區塊之前就被跳過,因此容錯切換不會重複送出答案。 |
144
+ | **個別模型開關** | 目錄中的任何模型都能從選擇器隱藏並拒絕請求,不必編輯檔案。目錄本身永遠不會被破壞。 |
145
+ | **由你掌握的模型目錄** | 重新命名模型、變更閘道 id、重新調整上下文視窗或輸出上限、宣告推理等級、新增隨附目錄沒有的模型,或刪除你從未使用的模型 —— 全都在設定頁面上完成。 |
146
+ | **單一設定頁面** | 啟用路由、重新命名、編輯端點、管理模型目錄、切換模型、新增或移除金鑰插槽 —— 全都在「設定 → HKU 生成式 AI」中完成。 |
147
+ | **健康檢查工具** | `hku_llm_status` 回報路由、憑證與模型,並可發出一次小型即時呼叫。 |
148
+ | **告訴你該怎麼做的錯誤** | `401`、`404`、`429`、`5xx`、2 MiB 邊緣限制以及帳戶額度用盡,各自對應到一個具名代碼與可據以行動的訊息。 |
149
+
150
+ ## 設定頁面
151
+
152
+ <img src="docs/assets/settings-page.svg" width="760" alt="HKU 生成式 AI 設定頁面:啟用開關、金鑰插槽,以及一張含名稱、端點與可編輯模型列的路由卡片">
153
+
154
+ <p align="center"><sub>「設定 → HKU 生成式 AI」示意圖。實際頁面會依你的 DSH 主題呈現,並顯示你自己的金鑰插槽。</sub></p>
155
+
156
+ 那個頁面是唯一能完成這些事的地方:
157
+
158
+ - 開啟或關閉每個路由;
159
+ - 重新命名路由並編輯其端點;
160
+ - **管理模型目錄** —— 開啟模型的參數以變更其閘道 id、標籤、上下文視窗、輸出上限、輸入
161
+ 類型或推理等級;**新增模型** 會附加隨附目錄沒有的項目,**移除** 則刪除你從未使用的項目;
162
+ - **切換個別模型** —— 未勾選的模型會離開選擇器並拒絕請求,直到再次勾選為止,而該項目本身
163
+ 仍留在目錄中;
164
+ - **維護 Developer Portal 金鑰池** —— `新增金鑰` 會附加一個插槽、`移除` 會刪除一個,請求
165
+ 會在所有已設定的金鑰之間輪替;
166
+ - 儲存或清除金鑰值(唯寫,透過憑證儲存)。
167
+
209
168
  ## 模型目錄
210
169
 
211
170
  上下文視窗轉錄自 GenAI 應用程式的 **Model Information** 面板(*Model Information → Text
@@ -548,10 +507,10 @@ DeepSeek 與 Kimi 模型請用 `hku-chat`,它也是穩定的預設值。GPT
548
507
  ## 開發
549
508
 
550
509
  ```bash
551
- pnpm install # 每個複製一次:唯一的執行期相依套件
510
+ pnpm install # 每個複製一次:執行期相依套件與 Vitest
552
511
  node scripts/link-stubs.mjs # 掛載 Host 套件的開發副本
553
- npm run check # 五套離線測試套件
554
- HKU_TEST_KEY=... node scripts/smoke.mjs --all # 即時連線測試,涵蓋每種協定
512
+ npm test # 全部離線測試套件(Vitest,無需網路)
513
+ HKU_TEST_KEY=... node scripts/smoke.mjs --all # 可選的即時檢查(CI 不會執行)
555
514
  node scripts/link-stubs.mjs --unlink # 安裝插件包之前執行
556
515
  ```
557
516
 
@@ -561,6 +520,9 @@ node scripts/link-stubs.mjs --unlink # 安裝插件包之前執行
561
520
  這個目錄的已安裝副本也會解析到它們**,因此在 `install_bundle` 之前請先解除連結,需要再跑
562
521
  測試套件時再重新連結。此腳本絕不會覆寫不是由它建立的套件。
563
522
 
523
+ 與本機相同,[`.github/workflows/ci.yml`](.github/workflows/ci.yml) 會在每次推送到 `main`
524
+ 時執行全部離線測試套件。
525
+
564
526
  完整的開發者指南 —— 架構、接縫契約、請求生命週期、測試策略、操作範例、封裝與發佈檢查
565
527
  清單 —— 位於 [DEVELOPMENT.md](DEVELOPMENT.md)。
566
528
 
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- **Language:** **English** · [简体中文](README.zh-CN.md) · [繁體中文](README.zh-TW.md)
1
+ **Language:** **English** · [简体中文](README-zh-CN.md) · [繁體中文](README-zh-TW.md)
2
2
 
3
3
  # dsh-hku-llm
4
4
 
@@ -7,7 +7,7 @@
7
7
  </div>
8
8
 
9
9
  <div align="center">
10
- <img src="https://img.shields.io/badge/version-1.6.0-0f7a6a?style=flat-square" alt="Version 1.6.0">
10
+ <a href="https://www.npmjs.com/package/dsh-hku-llm"><img src="https://img.shields.io/npm/v/dsh-hku-llm?style=flat-square&color=cb3837" alt="dsh-hku-llm on npm"></a>
11
11
  <img src="https://img.shields.io/badge/models-25%20in%203%20routes-0d2b4b?style=flat-square" alt="25 models in 3 routes">
12
12
  <img src="https://img.shields.io/badge/DeepSeek%20Harness-%E2%89%A5%200.2.0-0f7a6a?style=flat-square" alt="DeepSeek Harness 0.2.0 or newer">
13
13
  <img src="https://img.shields.io/badge/license-MIT-555555?style=flat-square" alt="MIT license">
@@ -41,132 +41,49 @@
41
41
  ## Why this plugin exists
42
42
 
43
43
  The HKU gateway authenticates with an **`api-key` header**, not `Authorization: Bearer`.
44
- Every generic provider route in DSH sends bearer auth, which is why a hand-declared
45
- `hku-openai` route under Settings → Models answers:
44
+ Every generic provider route in DSH sends bearer auth, so a hand-declared route under
45
+ **Settings → Models** answers:
46
46
 
47
47
  ```
48
48
  401 Access denied due to missing subscription key.
49
49
  ```
50
50
 
51
- This plugin registers its own adapter for the protocols the gateway actually serves, so the
52
- header is correct and the models behave like any other DSH model: streaming, tool calls,
53
- reasoning, usage.
51
+ This plugin registers its own adapter for the three protocols the gateway serves, so the
52
+ header is right and the models behave like any other DSH model.
54
53
 
55
- | Route | Protocol | Endpoint | Models |
56
- |---|---|---|---|
57
- | `hku-chat` | Chat Completions | `https://api.hku.hk/deepseek/models` → `/chat/completions` | DeepSeek V3.2, V4 Flash, V4.1 Flash (1017), V4 Pro, Kimi K3.1 Pro |
58
- | `hku-responses` | Responses | `https://api.hku.hk/openai/v1` → `/responses` | GPT-4.1 family, o4-mini, GPT-5 family, GPT-6 family |
59
- | `hku-gemini` | Gemini Chat Completions | `https://api.hku.hk/vertexai-gemini` → `/chat/completions` | Gemini 2.5 Flash, 3 Flash (preview), 3.1 Pro (preview), 3.5 Flash, 4 Carbon, 4 Hydrogen |
60
-
61
- The OpenAI list is the catalogue published in the HKU developer playbook. A model your
62
- subscription does not include answers `500` from the gateway rather than a `404`, so leave
63
- the ones you do not use switched off on the settings page.
64
-
65
- The OpenAI prefix serves **Responses only** — `/openai/v1/chat/completions` returns 404 on
66
- this gateway, so a "custom model API" entry pointed at that path cannot work.
67
-
68
- The Gemini service is the narrow one: its Chat Completions operation takes a model id and a
69
- string-`content` message list, answers one JSON document, and offers no function calling —
70
- the gateway refuses every tool but its own `url_context`. See
71
- [Known limits](#known-limits).
72
-
73
- ## What you get
74
-
75
- | | |
76
- |---|---|
77
- | **Three protocols, one picker** | Every HKU prefix becomes an ordinary DSH provider: one composer, one picker, one settings page. Tool calls and token streaming still depend on the route. |
78
- | **A key pool that fails over** | Requests rotate across every configured key; a key the gateway rejects is skipped before the first chunk, so a failover never duplicates an answer. |
79
- | **Per-model switches** | Any catalogue model can be hidden from the picker and refused, without editing files. The catalogue itself is never destroyed. |
80
- | **A catalogue you own** | Rename a model, change the gateway id, retune its context window or output cap, declare reasoning levels, add a model the shipped catalogue lacks, or delete one you never use — all on the settings page. |
81
- | **One settings page** | Enable the routes, rename them, edit endpoints, manage the model catalogue, toggle models, add or remove key slots — all in Settings → HKU GenAI. |
82
- | **A health check tool** | `hku_llm_status` reports routes, credentials and models, and can make one small live call. |
83
- | **Errors that say what to do** | `401`, `404`, `429`, `5xx`, the 2 MiB edge limit and an empty account each map to a named code with an actionable message. |
84
-
85
- ## The settings page
86
-
87
- <img src="docs/assets/settings-page.svg" width="760" alt="The HKU GenAI settings page: enable switch, key slots, and a route card with its name, endpoint and editable model rows">
88
-
89
- <p align="center"><sub>Illustration of Settings → HKU GenAI. The real page follows your DSH theme and shows your own key slots.</sub></p>
90
-
91
- That page is the one place to:
54
+ | Route | Protocol | Endpoint |
55
+ |---|---|---|
56
+ | `hku-chat` | Chat Completions | `https://api.hku.hk/deepseek/models` |
57
+ | `hku-responses` | Responses | `https://api.hku.hk/openai/v1` |
58
+ | `hku-gemini` | Gemini Chat Completions | `https://api.hku.hk/vertexai-gemini` |
92
59
 
93
- - switch every route on or off;
94
- - rename a route and edit its endpoint;
95
- - **manage the model catalogue** — open a model's parameters to change its gateway
96
- id, label, context window, output cap, input types or reasoning levels; **Add model**
97
- appends an entry the shipped catalogue lacks, **Remove** deletes one you never use;
98
- - **toggle individual models** — an unchecked model leaves the picker and refuses
99
- requests until it is checked again, while the entry itself stays in the catalogue;
100
- - **keep a pool of Developer Portal keys** — `Add key` appends a slot, `Remove` deletes
101
- one, and requests rotate across every configured key;
102
- - store or clear a key value (write-only, through the credential store).
60
+ The OpenAI prefix serves Responses only, and Gemini refuses every tool but its own
61
+ `url_context` — see [Known limits](#known-limits). A model outside your subscription answers
62
+ `500` rather than `404`, so switch off what you do not use.
103
63
 
104
64
  ## Install
105
65
 
106
- ### Before you start
107
-
108
- - **DeepSeek Harness 0.2.0 or newer**, desktop app or a Web build you launch yourself.
109
- - **The bundle itself**, from npm (the published package is `dsh-hku-llm`) or from
110
- [github.com/r48n34/dsh-hku-llm](https://github.com/r48n34/dsh-hku-llm). Only the GitHub
111
- route needs **Git on your PATH** — DSH checks a repository with `git ls-remote` before
112
- installing, and pnpm fetches it with Git — and a **public repository**, because that
113
- check runs with credential helpers and prompts disabled.
114
- - **An HKU GenAI Developer Portal key.** Create one at
115
- [genai.hku.hk](https://genai.hku.hk). The key is charged against your AI credits.
116
- - **Text models only.** Every shipped model is text-only; images are replaced with
117
- placeholders instead of failing the turn.
118
-
119
- ### 1. Install the bundle
120
-
121
- DSH installs a plugin bundle from a package spec — an npm name or a Git address. There is no
122
- manual clone and no separate `pnpm install`: DSH resolves the package into your profile,
123
- installs its one runtime dependency, and selects the bundle.
124
-
125
- **From npm (recommended).** The package is published as `dsh-hku-llm`.
126
-
127
- 1. Select **Plugins** in the DSH sidebar.
128
- 2. Select **Add plugin** — or open its arrow menu and choose **Install a third-party
129
- plugin**.
130
- 3. Paste the package name into the package field: `dsh-hku-llm`.
131
- 4. Acknowledge the trust notice, then select **Install**. DSH resolves the package from
132
- the registry and shows the package and version it found.
133
- 5. When the install finishes, select **Enable now**. If you close the dialog instead, the
134
- bundle stays installed but off; switch on its **HKU GenAI Models** card under
135
- **Installed plugins**.
136
- 6. Fully quit and reopen DSH. The install takes effect at startup: the Host half (adapter,
137
- credential lookup, status tool) loads, and **Settings → HKU GenAI** appears in the
138
- navigation. That restart is required because the Web client composes its module graph
139
- at boot.
66
+ `dsh-hku-llm` is [published on npm](https://www.npmjs.com/package/dsh-hku-llm). Install it through your DSH profile:
140
67
 
141
- **From GitHub.** Paste `https://github.com/r48n34/dsh-hku-llm` into the package field
142
- instead; the remaining steps are the same. That route needs Git on your PATH and a public
143
- repository, and it follows the repository's default branch.
144
-
145
- > **Updating later.** Remove the bundle and install it again to pick up a newer release —
146
- > from npm, DSH resolves the newest published version; from GitHub, the default branch.
147
- > DSH has no separate update action for third-party bundles.
148
-
149
- ### 2. Add your key
68
+ ```bash
69
+ dsh plugin --profile web add dsh-hku-llm
70
+ ```
150
71
 
151
- Open **Settings → HKU GenAI** (it sits between Agent presets and Plugin Market). Paste the
152
- Developer Portal key and choose **Save key**.
72
+ The same plugin can also be installed straight from this repository — use the GitHub form when you need a commit that is not on npm yet, or when npm is unreachable (it needs Git on your PATH and a public repository):
153
73
 
154
- The value goes to the DSH credential store, never into the profile file. Prefer the
155
- environment? `HKU_OPENAI_API_KEY` works too — see [Credential](#credential).
74
+ ```bash
75
+ dsh plugin --profile web add github:r48n34/dsh-hku-llm
76
+ ```
156
77
 
157
- ### 3. Choose your models
78
+ If your DSH runs the Desktop profile, use the profile name shown in **Settings → Plugins** (for the Desktop app this is usually `desktop`):
158
79
 
159
- Still on the page: uncheck the models your subscription does not include, press **Edit**
160
- on a model to retune its id, label or capacities, use **Add model** for one the catalogue
161
- lacks, and press **Save changes**. Anything unchecked disappears from the picker and is
162
- refused with `UNKNOWN_MODEL` before any network I/O. A removed model is gone from the
163
- catalogue; add it back with **Add model** if you change your mind.
80
+ ```bash
81
+ dsh plugin --profile desktop add dsh-hku-llm
82
+ ```
164
83
 
165
- ### 4. Pick a model and go
84
+ After installing, restart DSH once, then open **Settings → HKU GenAI**, paste your [Developer Portal key](https://genai.hku.hk) and choose **Save key**. Uncheck the models your subscription does not include; the composer offers the rest. This needs DeepSeek Harness 0.2.0 or newer, and every shipped model is text-only.
166
85
 
167
- Choose an HKU model in the composer. `hku-chat` is the stable route and the one to start
168
- with; `hku-responses` gives you the GPT and o-series models when that upstream is healthy;
169
- `hku-gemini` adds the Gemini deployments with their 1M-token context, text answers only.
86
+ To update or remove it, use **Settings → Plugins** in DSH and install again, or `dsh plugin --profile <name> remove dsh-hku-llm`.
170
87
 
171
88
  ## Verify the install
172
89
 
@@ -223,6 +140,37 @@ To prove the key actually works, make one small live call:
223
140
  A failure comes back with the mapped code and message instead of `ok`, so this is also the
224
141
  fastest way to tell a bad key from a bad endpoint.
225
142
 
143
+ ## What you get
144
+
145
+ | | |
146
+ |---|---|
147
+ | **Three protocols, one picker** | Every HKU prefix becomes an ordinary DSH provider: one composer, one picker, one settings page. Tool calls and token streaming still depend on the route. |
148
+ | **A key pool that fails over** | Requests rotate across every configured key; a key the gateway rejects is skipped before the first chunk, so a failover never duplicates an answer. |
149
+ | **Per-model switches** | Any catalogue model can be hidden from the picker and refused, without editing files. The catalogue itself is never destroyed. |
150
+ | **A catalogue you own** | Rename a model, change the gateway id, retune its context window or output cap, declare reasoning levels, add a model the shipped catalogue lacks, or delete one you never use — all on the settings page. |
151
+ | **One settings page** | Enable the routes, rename them, edit endpoints, manage the model catalogue, toggle models, add or remove key slots — all in Settings → HKU GenAI. |
152
+ | **A health check tool** | `hku_llm_status` reports routes, credentials and models, and can make one small live call. |
153
+ | **Errors that say what to do** | `401`, `404`, `429`, `5xx`, the 2 MiB edge limit and an empty account each map to a named code with an actionable message. |
154
+
155
+ ## The settings page
156
+
157
+ <img src="docs/assets/settings-page.svg" width="760" alt="The HKU GenAI settings page: enable switch, key slots, and a route card with its name, endpoint and editable model rows">
158
+
159
+ <p align="center"><sub>Illustration of Settings → HKU GenAI. The real page follows your DSH theme and shows your own key slots.</sub></p>
160
+
161
+ That page is the one place to:
162
+
163
+ - switch every route on or off;
164
+ - rename a route and edit its endpoint;
165
+ - **manage the model catalogue** — open a model's parameters to change its gateway
166
+ id, label, context window, output cap, input types or reasoning levels; **Add model**
167
+ appends an entry the shipped catalogue lacks, **Remove** deletes one you never use;
168
+ - **toggle individual models** — an unchecked model leaves the picker and refuses
169
+ requests until it is checked again, while the entry itself stays in the catalogue;
170
+ - **keep a pool of Developer Portal keys** — `Add key` appends a slot, `Remove` deletes
171
+ one, and requests rotate across every configured key;
172
+ - store or clear a key value (write-only, through the credential store).
173
+
226
174
  ## Model catalogue
227
175
 
228
176
  Capacities are transcribed from the **Model Information** panel of the GenAI app
@@ -605,10 +553,10 @@ rather than failing the turn.
605
553
  ## Development
606
554
 
607
555
  ```bash
608
- pnpm install # once per clone: the one runtime dependency
556
+ pnpm install # once per clone: the runtime dependency and Vitest
609
557
  node scripts/link-stubs.mjs # mount dev copies of the Host packages
610
- npm run check # the five offline suites
611
- HKU_TEST_KEY=... node scripts/smoke.mjs --all # live wire tests, every protocol
558
+ npm test # every offline suite (Vitest, no network)
559
+ HKU_TEST_KEY=... node scripts/smoke.mjs --all # optional live check (CI never runs it)
612
560
  node scripts/link-stubs.mjs --unlink # before installing the bundle
613
561
  ```
614
562
 
@@ -619,6 +567,10 @@ In PowerShell, set the key first: `$env:HKU_TEST_KEY = '...'`.
619
567
  unlink before `install_bundle` and relink when you want the suites again. The script never
620
568
  overwrites a package it did not create.
621
569
 
570
+ The same suites run on every push to `main` through
571
+ [`.github/workflows/ci.yml`](.github/workflows/ci.yml), so a green local run and a green CI
572
+ run mean the same thing.
573
+
622
574
  The full developer guide — architecture, seam contracts, request lifecycle, testing
623
575
  strategy, recipes, packaging and the release checklist — is in
624
576
  [DEVELOPMENT.md](DEVELOPMENT.md).
package/client.js CHANGED
@@ -25,7 +25,7 @@ window.__ModuleLoader__.load({
25
25
  const h = React.createElement
26
26
 
27
27
  const NS = 'hku-llm'
28
- const BUILD = '1.6.0'
28
+ const BUILD = '1.6.1'
29
29
  const KEY_STEM = 'HKU_OPENAI_API_KEY'
30
30
  const DEFAULT_CONTEXT_WINDOW = 128000
31
31
  const DEFAULT_MAX_TOKENS = 16000
package/lib/config.js CHANGED
@@ -28,13 +28,16 @@ const modelSchema = Schema.object({
28
28
 
29
29
  const providerSchema = Schema.object({
30
30
  displayName: Schema.string(),
31
+ // Deliberately no `.default()`: a default here is applied by the schema before
32
+ // `normalizeRoutes` sees the object, which would overwrite the protocol a
33
+ // shipped route declares in the catalogue and send, say, `hku-gemini` to
34
+ // `/responses`. An absent `api` must stay absent so the catalogue can supply
35
+ // it; `normalizeRoutes` still falls back to Responses for an unknown id.
31
36
  api: Schema.union([
32
37
  Schema.const('openai-responses'),
33
38
  Schema.const('openai-completions'),
34
39
  Schema.const('gemini-completions'),
35
- ])
36
- .description('Wire protocol spoken by this route.')
37
- .default('openai-responses'),
40
+ ]).description('Wire protocol spoken by this route.'),
38
41
  baseURL: Schema.string().description('Endpoint prefix; the protocol path is appended by the adapter.'),
39
42
  apiKeyEnv: Schema.string()
40
43
  .role('credential-ref')
@@ -104,7 +104,9 @@ export async function* parseResponsesStream(body) {
104
104
  const item = event.item
105
105
  if (item?.type === 'function_call') {
106
106
  const key = String(item.id ?? item.call_id ?? '')
107
- toolKeys.add(key)
107
+ // The block is closed here, so the trailing sweep below must not close
108
+ // it a second time; only a call that never got a done event needs that.
109
+ toolKeys.delete(key)
108
110
  yield { kind: 'tool-end', key }
109
111
  }
110
112
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-hku-llm",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "type": "module",
5
5
  "description": "HKU GenAI Developer Portal model routes for DeepSeek Harness: api-key authentication, OpenAI Responses and Chat Completions, Gemini Chat Completions, an editable model catalogue and a rotating key pool.",
6
6
  "license": "MIT",
@@ -45,8 +45,8 @@
45
45
  "icon.svg",
46
46
  "LICENSE",
47
47
  "README.md",
48
- "README.zh-CN.md",
49
- "README.zh-TW.md",
48
+ "README-zh-CN.md",
49
+ "README-zh-TW.md",
50
50
  "DEVELOPMENT.md",
51
51
  "docs/**/*.svg"
52
52
  ],
@@ -54,7 +54,10 @@
54
54
  "stubs": "node scripts/link-stubs.mjs",
55
55
  "unlink": "node scripts/link-stubs.mjs --unlink",
56
56
  "defaults": "node scripts/sync-client-defaults.mjs",
57
- "check": "node scripts/link-stubs.mjs --quiet && node scripts/sync-client-defaults.mjs --check && node scripts/plugin-check.mjs && node scripts/check-errors.mjs && node scripts/client-check.mjs && node scripts/check-pool.mjs && node scripts/check-gemini.mjs",
57
+ "pretest": "node scripts/link-stubs.mjs --quiet",
58
+ "test": "vitest run",
59
+ "test:watch": "vitest",
60
+ "check": "node scripts/link-stubs.mjs --quiet && node scripts/sync-client-defaults.mjs --check && vitest run",
58
61
  "smoke": "node scripts/smoke.mjs",
59
62
  "prepublishOnly": "npm run check"
60
63
  },
@@ -86,5 +89,8 @@
86
89
  "@deepseek-ai/dsh-api-remotes"
87
90
  ]
88
91
  }
92
+ },
93
+ "devDependencies": {
94
+ "vitest": "^5.1.2"
89
95
  }
90
96
  }