dsh-magpie-connect 0.4.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -35,6 +35,12 @@ dsh plugin --profile web add dsh-magpie-connect
35
35
  - **API 地址** — 网关地址,**要带版本号**。默认已填好 `http://127.0.0.1:3425/v1`,网关不在本机时改成实际地址。
36
36
  - **API Key** — 网关凭据,必填。
37
37
 
38
+ > Key 保存后**不会再回显**到页面;输入框留空表示沿用已保存的 Key,只有填入新值才会替换。
39
+ > 「测试连接」和「获取可用模型」同样复用已保存的 Key。设置文件里仍然是原来的 JSON 结构
40
+ > (`baseUrl` / `apiKey` / `enabledModels`),所以降级回旧版本也能直接读取。
41
+ > 插件自有状态目录在 POSIX 系统上为 `0700`、`settings.json` 为 `0600`;旧版本留下的宽权限
42
+ > 会在下次读取时自动收紧(只读文件系统或非 POSIX 平台会跳过,不影响设置读取)。
43
+
38
44
  点「保存」后,可以点「测试连接」确认通不通(会告诉你网关上有多少模型)。两项都齐了才会生效——
39
45
  地址有默认值,Key 没有,所以没填 Key 之前模型选择器是空的。
40
46
 
@@ -46,6 +52,17 @@ dsh plugin --profile web add dsh-magpie-connect
46
52
  点 **获取可用模型**,会弹出网关当前的模型列表:勾选你想要的,再点「应用选择」。
47
53
  弹窗里可以搜索、全选、取消全选。
48
54
 
55
+ 模型选择器、已选模型列表和弹窗统一显示 **`<组名>/<模型名>`**:模型名直接取 API 的
56
+ `display_name`;组名优先取 `magpie_label` 最后一个 ` · ` 右边的部分。若 `magpie_label`
57
+ 缺失或没有可解析的组名,则取 id 第一个 `/` 前的部分,并仅将首字母大写(例如
58
+ `workbuddy-ai/hy4free` → `Workbuddy-ai/Hy4`)。`auto/` 和 `group/` 是特例:组名始终从 id 前缀
59
+ 生成(`Auto`、`Group`),不使用 `magpie_label` 中的通用组名。
60
+ 原始路由 id 只在鼠标悬停时显示,请求、会话历史和白名单里始终是 id,所以改显示名
61
+ 不会影响已保存的选择或历史会话。搜索可以同时按显示名和 id 匹配,列表按显示名排序。
62
+
63
+ > 如果 API 没有返回 `display_name`,显示名回落到原始 id。旧版本留下的本地模型缓存
64
+ > 暂时以 id 显示,等下一次成功读取网关目录后自动换成新标签。
65
+
49
66
  模型列表是**白名单**,和 DSH 自带的「模型」设置语义一致:列表里有什么,选择器就提供
50
67
  什么。不想要的点该行末尾的「删除」,它就从列表和选择器里一起消失;想加回来,点
51
68
  「获取可用模型」,在弹窗里勾上它再「应用选择」。
@@ -90,8 +107,12 @@ Key 无效、网关不通)不会清空本地目录,避免把选择器误清
90
107
  **从旧版本升级,我原来的删除记录还在吗?**
91
108
 
92
109
  在。首次启动会自动把旧的 `hiddenModels`(黑名单)换算成 `enabledModels`(白名单),
93
- 并写回 `~/.dsh-magpie-connect/settings.json`,只执行一次。若升级时网关不可达、
94
- 算不出旧列表,则退回「继承网关目录」,不会误删你能用的模型。
110
+ 只执行一次。若升级时网关不可达、算不出旧列表,则退回「继承网关目录」,不会误删你能用的模型。
111
+
112
+ > 配置文件位置:从 0.5.0 起写在 `$DSH_HOME/storages/magpie-connect/settings.json`
113
+ >(默认 `~/.dsh/storages/magpie-connect/settings.json`)。老版本的
114
+ > `~/.dsh-magpie-connect/settings.json` **不迁移、不删除**,只做只读兼容——升级后不改任何文件;
115
+ > 你第一次在设置页保存(或删除模型触发自动保存)时,新配置才会写入新位置,同时清掉旧文件。
95
116
 
96
117
  **为什么我删掉的模型又出现了?**
97
118
 
@@ -144,7 +165,7 @@ Key 无效、网关不通)不会清空本地目录,避免把选择器误清
144
165
  | `displayName` | `Magpie` | 模型选择器里的分组名。 |
145
166
  | `baseUrl` | `http://127.0.0.1:3425/v1` | 带版本号的 API 地址。 |
146
167
  | `apiKey` | `''`(未配置) | 网关凭据。必填,即使网关不校验——地址有默认值,Key 没有。 |
147
- | `dataDir` | `~/.dsh-magpie-connect` | 状态目录(状态快照、设置文件、模型缓存)。 |
168
+ | `dataDir` | `$DSH_HOME/storages/magpie-connect` | 状态目录(状态快照、设置文件、模型缓存)。默认 `~/.dsh/storages/magpie-connect`;显式指定后不会读写旧目录。 |
148
169
  | `refreshSeconds` | `300` | 模型目录刷新间隔(秒)。 |
149
170
  | `maxRetries` | `2` | 遇到 429/5xx 时的连接重试次数。 |
150
171
  | `timeoutMs` | `300000` | 单次请求的总超时(毫秒)。 |
@@ -174,10 +195,13 @@ http://127.0.0.1:3425/v1 ← 按 native_endpoints 选择 chat/completions 或 r
174
195
  (显式档位直通网关);`none` 关闭思考,`ultra` 直通网关,不在本地截断。
175
196
  - **图片** — 带图的请求经 harness 附件服务取字节后上行;文本模型收到图片会直接
176
197
  失败(harness 已按模型声明的输入类型做过门控)。
198
+ - **输出预算** — 模型目录保留网关声明的最大输出能力;每次请求的默认输出预算沿用
199
+ Magpie 的 DSH 策略,为上下文和压缩保留空间。例如 500,000 上下文、393,216 最大
200
+ 输出的模型默认预留 184,464 输出。显式设置的请求输出预算保持原值,读图能力不变。
177
201
  - **容错** — 启动即注册,目录在后台预热;静默挂起会被看门狗快速判为超时;
178
202
  上游截断如实上报,不做自动续写。
179
203
 
180
- 运行状态快照写在 `~/.dsh-magpie-connect/adapter-status.json`,设置与缓存在同一目录。
204
+ 运行状态快照写在 `<dataDir>/adapter-status.json`(默认 `~/.dsh/storages/magpie-connect/adapter-status.json`),设置与缓存在同一目录。
181
205
 
182
206
  ## 开发
183
207
 
package/cordis.patch.yml CHANGED
@@ -8,12 +8,17 @@
8
8
  # (saved to <dataDir>/settings.json, applied without restart) and hides models
9
9
  # from the picker. Page values win per-field; the patch config below stays as
10
10
  # fallback (e.g. headless compositions without the settings page).
11
+ # <dataDir> defaults to $DSH_HOME/storages/magpie-connect
12
+ # (~/.dsh/storages/magpie-connect). The pre-0.5 dir ~/.dsh-magpie-connect is
13
+ # read once as a fallback and removed on the first save; it is never migrated
14
+ # eagerly, so an upgrade that changes nothing touches no file.
11
15
  #
12
16
  # - baseUrl: versioned API root (default http://127.0.0.1:3425/v1). Include the
13
17
  # version segment: the plugin appends only the resource (/models, /responses),
14
18
  # so a gateway on /v2 or /v3 is reached by changing this one string.
15
19
  # - apiKey: gateway credential (required, even if /models needs none).
16
- # - dataDir: plugin state dir (status snapshot, settings file, catalog cache).
20
+ # - dataDir: plugin state dir (status snapshot, settings file, catalog cache);
21
+ # defaults to $DSH_HOME/storages/magpie-connect.
17
22
  # - displayName: cosmetic label in the model picker (route id stays providerId).
18
23
  # - providerId: RENAME the route id itself (existing sessions pointing at the
19
24
  # old id will orphan — prefer displayName for a cosmetic rename).
package/dsh.plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-magpie-connect",
3
3
  "description": "Magpie gateway models for the DeepSeek Harness web GUI",
4
- "version": "0.4.4",
4
+ "version": "0.6.0",
5
5
  "entry": {
6
6
  "name": "dsh-magpie-connect",
7
7
  "inject": [
package/lib/client.js CHANGED
@@ -44,7 +44,8 @@ var EN = {
44
44
  baseUrlPlaceholder: "http://127.0.0.1:3425/v1",
45
45
  apiKey: "API key",
46
46
  apiKeyPlaceholder: "required",
47
- requiredNote: "API URL and API key are both required. Include the version segment (e.g. /v1) \u2014 the URL is used exactly as written.",
47
+ apiKeySavedPlaceholder: "Saved \u2014 leave blank to keep the existing key",
48
+ requiredNote: "API URL and API key are both required. Once a key is saved, leave the field blank to keep it. Include the version segment (e.g. /v1) \u2014 the URL is used exactly as written.",
48
49
  test: "Test connection",
49
50
  testing: "Testing\u2026",
50
51
  save: "Save",
@@ -97,7 +98,8 @@ var ZH = {
97
98
  baseUrlPlaceholder: "http://127.0.0.1:3425/v1",
98
99
  apiKey: "API Key",
99
100
  apiKeyPlaceholder: "\u5FC5\u586B",
100
- requiredNote: "API \u5730\u5740\u4E0E Key \u5747\u4E3A\u5FC5\u586B\u3002\u5730\u5740\u9700\u5305\u542B\u7248\u672C\u6BB5\uFF08\u5982 /v1\uFF09\uFF0C\u63D2\u4EF6\u6309\u4F60\u586B\u5199\u7684\u539F\u6837\u4F7F\u7528\u3002",
101
+ apiKeySavedPlaceholder: "\u5DF2\u4FDD\u5B58\uFF1B\u7559\u7A7A\u4FDD\u7559\u73B0\u6709 Key",
102
+ requiredNote: "API \u5730\u5740\u4E0E Key \u5747\u4E3A\u5FC5\u586B\u3002Key \u4FDD\u5B58\u540E\u7559\u7A7A\u5373\u53EF\u6CBF\u7528\uFF1B\u5730\u5740\u9700\u5305\u542B\u7248\u672C\u6BB5\uFF08\u5982 /v1\uFF09\uFF0C\u63D2\u4EF6\u6309\u4F60\u586B\u5199\u7684\u539F\u6837\u4F7F\u7528\u3002",
101
103
  test: "\u6D4B\u8BD5\u8FDE\u63A5",
102
104
  testing: "\u6D4B\u8BD5\u4E2D\u2026",
103
105
  save: "\u4FDD\u5B58",
@@ -312,7 +314,9 @@ var css = {
312
314
  item: { display: "flex", alignItems: "center", gap: 10, padding: "8px 10px", borderRadius: 8, background: "transparent" },
313
315
  removeButton: { border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-secondary)", cursor: "pointer", padding: "3px 10px", borderRadius: 6, fontSize: 12, lineHeight: "18px", flex: "none" },
314
316
  itemMain: { display: "flex", flexDirection: "column", gap: 2, minWidth: 0, flex: 1 },
315
- itemId: { fontSize: 13, lineHeight: "20px", fontWeight: 500, color: "var(--dsw-alias-label-primary)", overflowWrap: "anywhere", fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace" },
317
+ // The visible label is `<group>/<name>`; the raw route id is only a hover
318
+ // title, so the list reads cleanly while the allowlist key stays inspectable.
319
+ itemId: { fontSize: 13, lineHeight: "20px", fontWeight: 500, color: "var(--dsw-alias-label-primary)", overflowWrap: "anywhere" },
316
320
  chips: { display: "flex", gap: 6, flexWrap: "wrap" },
317
321
  chip: { fontSize: 11, lineHeight: "18px", padding: "0 7px", borderRadius: 999, border: "1px solid var(--dsw-alias-border-l2)", color: "var(--dsw-alias-label-secondary)", whiteSpace: "nowrap" },
318
322
  // A row the live gateway does not list is informational, not a capability the
@@ -327,7 +331,7 @@ var css = {
327
331
  candidateLabel: { display: "flex", alignItems: "center", gap: 10, padding: "8px 10px", cursor: "pointer" },
328
332
  candidateCheckbox: { width: 15, height: 15, accentColor: "var(--dsw-alias-brand-primary)", flex: "none", cursor: "pointer" },
329
333
  candidateText: { display: "flex", flexDirection: "column", gap: 2, minWidth: 0, flex: 1 },
330
- candidateId: { fontSize: 13, lineHeight: "20px", fontWeight: 500, color: "var(--dsw-alias-label-primary)", overflowWrap: "anywhere", fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace" },
334
+ candidateId: { fontSize: 13, lineHeight: "20px", fontWeight: 500, color: "var(--dsw-alias-label-primary)", overflowWrap: "anywhere" },
331
335
  candidateEmpty: { margin: "24px 0", textAlign: "center", fontSize: 13, lineHeight: "20px", color: "var(--dsw-alias-label-secondary)" }
332
336
  };
333
337
  function formatWindow(value) {
@@ -462,7 +466,7 @@ function ModelListEditor(props) {
462
466
  const source = sourceChip(row);
463
467
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: css.item, children: [
464
468
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: css.itemMain, children: [
465
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: css.itemId, children: row.id }),
469
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: css.itemId, title: row.id, children: row.displayName }),
466
470
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: css.chips, children: [
467
471
  chipsFor(row).map((chip) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: css.chip, children: chip.label }, chip.key)),
468
472
  source === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...css.chip, ...css.chipStale }, children: source.label }, source.key)
@@ -524,7 +528,7 @@ function ModelListEditor(props) {
524
528
  }
525
529
  ),
526
530
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: css.candidateText, children: [
527
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: css.candidateId, title: candidate.id, children: candidate.id }),
531
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: css.candidateId, title: candidate.id, children: candidate.displayName }),
528
532
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: css.chips, children: chipsFor(candidate).map((chip) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: css.chip, children: chip.label }, chip.key)) })
529
533
  ] })
530
534
  ] }) }, candidate.id)) })
@@ -592,7 +596,7 @@ function shouldRetryPending(snapshot2, attempts, limit = PENDING_RETRY_LIMIT) {
592
596
 
593
597
  // src/client/page.tsx
594
598
  var import_jsx_runtime3 = require("react/jsx-runtime");
595
- var PLUGIN_VERSION = "0.4.4";
599
+ var PLUGIN_VERSION = "0.6.0";
596
600
  var REPO_URL = "https://github.com/bitxeno/dsh-magpie-connect";
597
601
  var css2 = {
598
602
  section: { display: "flex", flexDirection: "column", gap: 16, maxWidth: 780, paddingBottom: 32 },
@@ -667,6 +671,7 @@ function MagpieSettings() {
667
671
  useLocaleRevision();
668
672
  const [baseUrl, setBaseUrl] = (0, import_react3.useState)("");
669
673
  const [apiKey, setApiKey] = (0, import_react3.useState)("");
674
+ const [hasApiKey, setHasApiKey] = (0, import_react3.useState)(false);
670
675
  const [enabled, setEnabled] = (0, import_react3.useState)(void 0);
671
676
  const [models, setModels] = (0, import_react3.useState)([]);
672
677
  const [busy, setBusy] = (0, import_react3.useState)("idle");
@@ -710,10 +715,8 @@ function MagpieSettings() {
710
715
  const settings = settingsValue;
711
716
  const listed = modelsValue.models ?? [];
712
717
  const snapshot2 = modelsValue.snapshot;
713
- if (!credentialsDirty.current) {
714
- setBaseUrl(settings.baseUrl ?? "");
715
- setApiKey(settings.apiKey ?? "");
716
- }
718
+ if (!credentialsDirty.current) setBaseUrl(settings.baseUrl ?? "");
719
+ setHasApiKey(settings.hasApiKey === true);
717
720
  setEnabled(settings.enabledModels);
718
721
  setModels(listed);
719
722
  setLoaded(true);
@@ -734,7 +737,7 @@ function MagpieSettings() {
734
737
  };
735
738
  }, []);
736
739
  const fetchCandidates = async () => {
737
- const result = await request("/api/magpie-discover", "POST", { baseUrl, apiKey });
740
+ const result = await request("/api/magpie-discover", "POST", { baseUrl, ...apiKey.trim() === "" ? {} : { apiKey } });
738
741
  return result.models ?? [];
739
742
  };
740
743
  const refreshModels = async () => {
@@ -755,11 +758,12 @@ function MagpieSettings() {
755
758
  try {
756
759
  const saved = await request("/api/magpie-settings", "POST", {
757
760
  baseUrl,
758
- apiKey,
761
+ ...apiKey.trim() === "" ? {} : { apiKey },
759
762
  ...enabled === void 0 ? {} : { enabledModels: enabled }
760
763
  });
761
764
  setBaseUrl(saved.baseUrl);
762
- setApiKey(saved.apiKey);
765
+ setHasApiKey(saved.hasApiKey);
766
+ setApiKey("");
763
767
  setEnabled(saved.enabledModels);
764
768
  await refreshModels();
765
769
  setNotice(text("saved"));
@@ -774,7 +778,7 @@ function MagpieSettings() {
774
778
  setError(void 0);
775
779
  setNotice(void 0);
776
780
  try {
777
- const result = await request("/api/magpie-test", "POST", { baseUrl, apiKey });
781
+ const result = await request("/api/magpie-test", "POST", { baseUrl, ...apiKey.trim() === "" ? {} : { apiKey } });
778
782
  setNotice(text("testOk", { count: result.count }));
779
783
  } catch (cause) {
780
784
  setError(cause instanceof Error ? cause.message : String(cause));
@@ -783,7 +787,7 @@ function MagpieSettings() {
783
787
  }
784
788
  };
785
789
  const working = busy !== "idle";
786
- const incomplete = baseUrl.trim() === "" || apiKey.trim() === "";
790
+ const incomplete = baseUrl.trim() === "" || !hasApiKey && apiKey.trim() === "";
787
791
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { style: css2.section, children: [
788
792
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("header", { style: css2.header, children: [
789
793
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: css2.brand, children: [
@@ -821,7 +825,7 @@ function MagpieSettings() {
821
825
  ] }),
822
826
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: css2.field, children: [
823
827
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: css2.label, children: text("apiKey") }),
824
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives2.Input, { type: "password", value: apiKey, placeholder: text("apiKeyPlaceholder"), disabled: working, onChange: (event) => {
828
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives2.Input, { type: "password", value: apiKey, placeholder: text(hasApiKey ? "apiKeySavedPlaceholder" : "apiKeyPlaceholder"), disabled: working, onChange: (event) => {
825
829
  credentialsDirty.current = true;
826
830
  setApiKey(event.currentTarget.value);
827
831
  } })