dsh-mobile-plugin 0.5.133 → 0.5.134

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.
@@ -33,7 +33,7 @@
33
33
 
34
34
  ## 上手机前验收
35
35
 
36
- 按 `references/selfhost-common.md` 四条过一遍:体检口 `curl https://xxx.trycloudflare.com/api/mobile/v1/health` 回带 service 和版本的 JSON;不带 token 访问 `/status` 回 401 JSON;手机断 Wi-Fi 走流量实测 SSE 流式(聊天能否一段段出来)和 WebSocket(内置浏览器能否打开);传个稍大文件看有没有被 100MB 上限截断。WSS/SSE 是能穿的,流式卡住先查应用层心跳和总控,而不是先怀疑地址。
36
+ 按 `references/selfhost-common.md` 四条过一遍:体检口 `curl https://xxx.trycloudflare.com/api/mobile/v1/health` 回带 service 和版本的 JSON;不带任何凭据访问 `/status` 回 404 `{"ok":false}`、带无效凭据才回 401(见共用篇,别只看 health 就说鉴权没问题);手机断 Wi-Fi 走流量实测 SSE 流式(聊天能否一段段出来)和 WebSocket(内置浏览器能否打开);传个稍大文件看有没有被 100MB 上限截断。WSS/SSE 是能穿的,流式卡住先查应用层心跳和总控,而不是先怀疑地址。
37
37
 
38
38
  ## 已知限制
39
39
 
@@ -49,7 +49,7 @@
49
49
 
50
50
  ## 上手机前验收
51
51
 
52
- 按 `references/selfhost-common.md` 四条过一遍:体检口 `curl https://域名/api/mobile/v1/health` 回带 service 和版本的 JSON;不带 token 访问 `/status` 回 401;手机流量下实测 SSE 流式和大文件上传。frp 的 tcp 一般不缓冲,反而比 web 隧道稳;卡住就查服务器到主机这段。
52
+ 按 `references/selfhost-common.md` 四条过一遍:体检口 `curl https://域名/api/mobile/v1/health` 回带 service 和版本的 JSON;不带任何凭据访问 `/status` 回 404 `{"ok":false}`、带无效凭据才回 401(见共用篇);手机流量下实测 SSE 流式和大文件上传。frp 的 tcp 一般不缓冲,反而比 web 隧道稳;卡住就查服务器到主机这段。
53
53
 
54
54
  ## 几个坑
55
55
 
@@ -33,7 +33,7 @@ DSH 部署在 NAS 或家庭服务器上、前面已有 Nginx/Caddy 时,可以
33
33
  ## 上手机前的验收(每种方案都过一遍)
34
34
 
35
35
  1. **地址通不通**:电脑上 `curl https://域名/api/mobile/v1/health`(或 `http://IP:端口/...`),应回带 `service` 和版本的 JSON。这是体检口,不带 token 也能回。
36
- 2. **鉴权有没有生效**:不带 token 访问别的路径(如 `.../api/mobile/v1/status`),应回 401 JSON。若直接回数据,说明暴露面不对,先别用。
36
+ 2. **鉴权有没有生效**:不带任何凭据访问别的路径(如 `.../api/mobile/v1/status`),应回 404 `{"ok":false}`——入口刻意不告诉外人这里跑的是什么;带一枚无效凭据才回 401 说明原因。回的若是数据,说明暴露面不对,先别用。体检口 `/api/mobile/v1/health` 本身免 token,单看它不能判断鉴权。
37
37
  3. **流式能不能穿**:SSE 长连接和 WebSocket 用配对好的手机实测——聊天能否一段段出来、内置浏览器能否打开。被缓冲就回去调反代或换隧道类型。
38
38
  4. **大文件上传**:传个稍大的文件走一遍,确认没被截断。
39
39
 
@@ -1,4 +1,5 @@
1
1
  // 2026-11-24:本机面板全局悬浮 AI 问诊按钮的取选项与建会话发首句,只走 localOnly 控制面。
2
+ // 2026-11-28:首句带上包内 dsh-mobile-kb 正文;桌面预设没登记这份技能,模型调不到。
2
3
  'use strict';
3
4
 
4
5
  /**
@@ -9,12 +10,17 @@
9
10
  * 收敛成小对象,任一路 RPC 失败或回执形状异常都回 { ok:false, error },不把异常抛给路由层。
10
11
  */
11
12
 
13
+ import fs from 'node:fs';
14
+ import path from 'node:path';
12
15
  import { createRequire } from 'node:module';
16
+ import { fileURLToPath } from 'node:url';
13
17
 
14
18
  const require = createRequire(import.meta.url);
15
19
  const { unwrap } = require('./mobile/envelope.js');
16
20
  const { callSessions } = require('./mobile/rpc.js');
17
21
 
22
+ const KB_DIR = path.join(path.dirname(path.dirname(fileURLToPath(import.meta.url))), 'config', 'agent-presets', 'standard', 'skills', 'dsh-mobile-kb');
23
+
18
24
  const MAX_WORKSPACES = 100;
19
25
  const MAX_MODEL_GROUPS = 16;
20
26
  const MAX_MODELS_PER_GROUP = 40;
@@ -151,6 +157,21 @@ async function archiveQuietly(ctx, sessionId) {
151
157
  } catch { /* 原始失败才是要报给面板的那一个 */ }
152
158
  }
153
159
 
160
+ /**
161
+ * 桌面 standard 预设没登记 dsh-mobile-kb,模型在问诊会话里调它会得到 unknown。
162
+ * 把包里同一份正文随首句带进去,references 仍读同一个目录,不留第二份副本;
163
+ * 文件读不到时退回原首句,不让问诊整体失败。
164
+ */
165
+ function withKnowledgeBase(prompt, kbDir = KB_DIR) {
166
+ let body;
167
+ try {
168
+ body = fs.readFileSync(path.join(kbDir, 'SKILL.md'), 'utf8');
169
+ } catch {
170
+ return prompt;
171
+ }
172
+ return `${prompt}\n\n下面是 dsh-mobile-kb 技能的正文(这条会话里技能工具调不到它,直接照这份做)。正文里 references/xxx 指 ${path.join(kbDir, 'references')}/xxx,需要时用读文件工具打开;按里面的分类和顺序排查,不要再说这项技能没装。\n\n${body}`;
173
+ }
174
+
154
175
  /** POST 建会话 + 带模型发送第一句;成功回 sessionId,失败回错误且不抛。 */
155
176
  async function launchAiDiagnosis(ctx, body) {
156
177
  try {
@@ -174,7 +195,8 @@ async function launchAiDiagnosis(ctx, body) {
174
195
 
175
196
  const payload = {
176
197
  sessionId,
177
- content: [{ type: 'text', text: prompt }],
198
+ // 知识库是包内自带的内容,不是面板入参;20k 的入口上限只管上面校验过的 prompt。
199
+ content: [{ type: 'text', text: withKnowledgeBase(prompt) }],
178
200
  // 宿主 session.prompt 支持本次发送直接带模型,省掉「先建再 select」两步。
179
201
  ...(provider && model ? { modelSelection: { provider, model } } : {}),
180
202
  };
@@ -195,4 +217,4 @@ async function launchAiDiagnosis(ctx, body) {
195
217
  }
196
218
  }
197
219
 
198
- export { buildAiDiagnosisOptions, launchAiDiagnosis };
220
+ export { buildAiDiagnosisOptions, launchAiDiagnosis, withKnowledgeBase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mobile-plugin",
3
- "version": "0.5.133",
3
+ "version": "0.5.134",
4
4
  "description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (dsh 0.2.x, peers resolved by the host)",
5
5
  "license": "MIT",
6
6
  "icon": "./icon.png",
@@ -91,11 +91,11 @@
91
91
  "dsh-mobile-tailcat-win32-arm64": "1.1.7"
92
92
  },
93
93
  "peerDependencies": {
94
- "@deepseek-ai/cordis": ">=4.0.1",
94
+ "@deepseek-ai/cordis": ">=4.0.1 || >=4.0.1-rc.1 <4.0.2-0 || >=4.0.5-alpha.1 <4.0.6-0 || >=4.0.6-alpha.1 <4.0.7-0 || >=4.2.0-alpha.1 <4.2.1-0",
95
95
  "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2 || ^0.2.0-rc.1 || ^0.2.1-rc.2 || ^0.2.2-rc.1 || ^0.2.3-alpha.1",
96
96
  "@deepseek-ai/dsh-settings": "^0.1.1-rc.2 || ^0.2.0-rc.1 || ^0.2.1-rc.2 || ^0.2.2-rc.1 || ^0.2.3-alpha.1",
97
97
  "@deepseek-ai/dsh-tools": "^0.1.1-rc.2 || ^0.2.0-rc.1 || ^0.2.1-rc.2 || ^0.2.2-rc.1 || ^0.2.3-alpha.1",
98
- "@deepseek-ai/schemastery": "^3.18.1"
98
+ "@deepseek-ai/schemastery": ">=3.18.1 || >=3.18.1-rc.1 <3.18.2-0 || >=3.18.5-alpha.1 <3.18.6-0 || >=3.18.6-alpha.1 <3.18.7-0 || >=3.20.0-alpha.1 <3.20.1-0"
99
99
  },
100
100
  "dsh": {
101
101
  "bundle": {
@@ -117,23 +117,22 @@
117
117
  "yaml": "2.9.1"
118
118
  },
119
119
  "dshMobileReleaseNotes": {
120
- "version": "0.5.133",
120
+ "version": "0.5.134",
121
121
  "kinds": [
122
- "fix",
123
- "feature"
122
+ "fix"
124
123
  ],
125
124
  "notes": {
126
- "zh-Hans": "- 插件跑在容器里时,配对二维码不再给出拨不通的容器内网地址,改用公网候选或手填地址。\n- 仓库摘要现在带出项目里的全部仓库根,手机上可以切换到并列仓库、子模块和工作树。",
127
- "zh-Hant": "- 外掛在容器裡執行時,配對二維碼不再給出連不上的容器內網位址,改採公網候選或手填位址。\n- 倉庫摘要現在帶出專案裡的全部倉庫根,手機上可以切換到並列倉庫、子模組與工作樹。",
128
- "en": "- When the plugin runs inside a container, the pairing QR code no longer leads with an unreachable container-internal address; it falls back to public candidates or a manually entered address.\n- The repository summary now includes every repository root in the project, so you can switch to sibling repositories, submodules, and worktrees on your phone.",
129
- "ja": "- プラグインがコンテナ内で動いている場合、ペアリング用QRコードに接続できないコンテナ内網アドレスが表示されなくなり、公開アドレス候補または手入力アドレスに切り替わります。\n- リポジトリの概要にプロジェクト内のすべてのリポジトリルートが含まれるようになり、スマートフォンで並列リポジトリ、サブモジュール、ワークツリーに切り替えられます。",
130
- "ko": "- 플러그인이 컨테이너 안에서 실행될 때, 페어링 QR 코드에 연결할 수 없는 컨테이너 내부 주소가 더 이상 표시되지 않고 공개 후보 주소나 직접 입력한 주소를 사용합니다.\n- 저장소 요약에 프로젝트의 모든 저장소 루트가 포함되어, 휴대폰에서 나란한 저장소, 서브모듈, 워크트리로 전환할 수 있습니다.",
131
- "de": "- Wenn das Plugin in einem Container läuft, zeigt der Pairing-QR-Code keine nicht erreichbaren Container-internen Adressen mehr an, sondern greift auf öffentliche Kandidaten oder eine manuell eingegebene Adresse zurück.\n- Die Repository-Übersicht enthält jetzt alle Repository-Wurzeln im Projekt, damit Sie auf dem Telefon zu parallelen Repositories, Submodulen und Worktrees wechseln können.",
132
- "es": "- Cuando el plugin se ejecuta dentro de un contenedor, el código QR de emparejamiento ya no muestra direcciones internas del contenedor a las que no se puede conectar; usa candidatos públicos o una dirección introducida manualmente.\n- El resumen del repositorio ahora incluye todas las raíces de repositorios del proyecto, para que puedas cambiar a repositorios paralelos, submódulos y worktrees desde el teléfono.",
133
- "fr": "- Lorsque le plugin s'exécute dans un conteneur, le code QR d'appariement n'affiche plus d'adresses internes du conteneur inaccessibles ; il repasse sur les candidats publics ou une adresse saisie manuellement.\n- Le résumé du dépôt inclut désormais toutes les racines de dépôts du projet, afin de pouvoir basculer vers les dépôts parallèles, les sous-modules et les worktrees depuis le téléphone.",
134
- "pt": "- Quando o plugin corre dentro de um contentor, o código QR de emparelhamento deixa de mostrar endereços internos do contentor inacessíveis e passa a usar candidatos públicos ou um endereço introduzido manualmente.\n- O resumo do repositório agora inclui todas as raízes de repositórios do projeto, para que possa mudar para repositórios paralelos, submódulos e worktrees no telemóvel.",
135
- "ru": "- Когда плагин работает внутри контейнера, QR-код сопряжения больше не показывает недоступные внутренние адреса контейнера и использует публичные кандидаты или введённый вручную адрес.\n- Сводка репозитория теперь включает все корни репозиториев проекта, чтобы на телефоне можно было переключаться на параллельные репозитории, подмодули и рабочие копии.",
136
- "tr": "- Eklenti bir konteyner içinde çalıştığında, eşleştirme QR kodu artık erişilemeyen konteyner içi adresleri göstermiyor; genel adaylara veya elle girilen bir adrese geçiyor.\n- Depo özeti artık projedeki tüm depo köklerini içeriyor; böylece telefondan yan depolara, alt modüllere ve worktree'lere geçebilirsiniz."
125
+ "zh-Hans": "- 使用 DSH 预发布版时,插件安装和更新不再因依赖范围过窄而报冲突。",
126
+ "zh-Hant": "- 使用 DSH 預發布版時,外掛安裝與更新不再因相依範圍過窄而回報衝突。",
127
+ "en": "- Installing or updating the plugin on prerelease builds of DSH no longer fails on a dependency range conflict.",
128
+ "ja": "- DSH のプレリリース版でも、依存範囲が狭すぎることでプラグインのインストールや更新が失敗しなくなりました。",
129
+ "ko": "- DSH 사전 릴리스 버전에서 의존성 범위가 좁아 플러그인 설치·업데이트가 실패하던 문제를 해결했습니다.",
130
+ "de": "- Unter Vorabversionen von DSH lassen sich Installation und Update des Plugins nicht mehr durch einen zu engen Abhängigkeitsbereich blockieren.",
131
+ "es": "- En las versiones preliminares de DSH, instalar o actualizar el plugin ya no falla por un rango de dependencias demasiado estrecho.",
132
+ "fr": "- Sur les versions préliminaires de DSH, l'installation et la mise à jour du plugin ne sont plus bloquées par une plage de dépendances trop restrictive.",
133
+ "pt": "- Em versões de pré-lançamento do DSH, instalar ou atualizar o plugin não falha mais por um intervalo de dependências restrito demais.",
134
+ "ru": "- В предварительных сборках DSH установка и обновление плагина больше не завершаются ошибкой из-за слишком узкого диапазона зависимостей.",
135
+ "tr": "- DSH'nin yayın öncesi sürümlerinde, çok dar bir bağımlılık aralığı nedeniyle eklentinin kurulumu ve güncellenmesi artık başarısız olmuyor."
137
136
  }
138
137
  }
139
138
  }