dsh-mobile-plugin 0.5.132 → 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.
- package/config/agent-presets/standard/skills/dsh-mobile-kb/references/cloudflare.md +1 -1
- package/config/agent-presets/standard/skills/dsh-mobile-kb/references/frp.md +1 -1
- package/config/agent-presets/standard/skills/dsh-mobile-kb/references/selfhost-common.md +1 -1
- package/lib/ai-diagnosis.js +24 -2
- package/lib/mobile/git.js +10 -2
- package/lib/relay/lan-network.cjs +36 -7
- package/package.json +15 -15
|
@@ -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
|
|
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
|
|
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.
|
|
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
|
|
package/lib/ai-diagnosis.js
CHANGED
|
@@ -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
|
-
|
|
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/lib/mobile/git.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// 本次改动:给手机上会显示的中文错误补稳定机器码(JSON 请求体单独成码),中文只做日志兜底。
|
|
2
|
+
// 本次改动:仓库摘要一并回传宿主已识别的仓库清单,手机端据此切换仓库。
|
|
2
3
|
'use strict';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -151,7 +152,7 @@ async function resolveTarget(ctx, params) {
|
|
|
151
152
|
if (!marker.repos.some((repo) => repo.root === repoRoot)) {
|
|
152
153
|
throw fail('FORBIDDEN', '这个仓库不在该项目的识别结果里');
|
|
153
154
|
}
|
|
154
|
-
return { projectPath, repoRoot };
|
|
155
|
+
return { projectPath, repoRoot, marker };
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
/** HEAD 是否存在:空仓库(还没有第一个提交)时很多命令的行为不一样。 */
|
|
@@ -205,7 +206,14 @@ async function handleGitRepo(ctx, req, res) {
|
|
|
205
206
|
workspaceId: params.get('workspaceId'),
|
|
206
207
|
repo: params.get('repo'),
|
|
207
208
|
});
|
|
208
|
-
|
|
209
|
+
// 仓库清单是识别层已经算好的(同一份也用来校验 repo 参数):跟着摘要一起回,
|
|
210
|
+
// 手机端才有得切。工作区清单继续保持精简,不为每个条目都带这份数组。
|
|
211
|
+
sendJson(res, 200, {
|
|
212
|
+
ok: true,
|
|
213
|
+
...(await read.repoOf(target.repoRoot)),
|
|
214
|
+
repos: target.marker.repos,
|
|
215
|
+
truncated: target.marker.truncated,
|
|
216
|
+
});
|
|
209
217
|
}
|
|
210
218
|
|
|
211
219
|
/** GET git/status:四个分组,带每个文件的增删与二进制标记。 */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 反馈 1569:插件跑在容器里时容器内网 eth0 不进局域网候选(按容器标记判,不按 172 地址段)。
|
|
1
2
|
// 反馈 1012:172.17/16 是真实 Wi-Fi 可用的私网段,容器 / 虚拟网卡改由网卡名黑名单挡。
|
|
2
3
|
// 反馈 1562:节点小宝 NodeBabyLink 是第三方穿透 VPN 虚拟网卡,按网卡名挡,不进局域网候选。
|
|
3
4
|
// 没有已监听端口时不产出可连接候选。
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
*/
|
|
13
14
|
'use strict'
|
|
14
15
|
|
|
16
|
+
const fsSync = require('node:fs')
|
|
15
17
|
const os = require('node:os')
|
|
16
18
|
// 私有地址判断搬到 shared/private-address.js:内核也要用它,不能反过来让内核依赖这个会频繁变的文件。
|
|
17
19
|
const { isPrivateLanAddress } = require('../shared/private-address.js')
|
|
@@ -148,14 +150,19 @@ function toCandidates(list, port, family = 'IPv4') {
|
|
|
148
150
|
// Structured view of the usable LAN endpoints. The app's `candidateUrls()` accepts
|
|
149
151
|
// this shape, so callers that want interface metadata (for diagnostics or smarter
|
|
150
152
|
// ordering) should prefer it.
|
|
151
|
-
|
|
153
|
+
// `opts.inContainer` 只给测试注入容器现场;生产走 isContainerRuntime() 的只读探测。
|
|
154
|
+
function lanInterfaces(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
155
|
+
const inContainer = typeof opts.inContainer === 'boolean' ? opts.inContainer : isContainerRuntime()
|
|
156
|
+
// 容器里那块 eth0 是容器内网、手机拨不进来;整条私网清单不产出,二维码与 /connection-info
|
|
157
|
+
// 转而走公网候选 + 手填地址。不动 isLanCandidateAddress 的地址段判据(172.x 真实 Wi-Fi 照旧)。
|
|
158
|
+
if (inContainer) return []
|
|
152
159
|
return toCandidates(collectEndpoints(interfaces, isLanCandidateAddress), port)
|
|
153
160
|
}
|
|
154
|
-
function lanUrls(port, interfaces = os.networkInterfaces()) {
|
|
155
|
-
return lanInterfaces(port, interfaces).map((candidate) => candidate.url)
|
|
161
|
+
function lanUrls(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
162
|
+
return lanInterfaces(port, interfaces, opts).map((candidate) => candidate.url)
|
|
156
163
|
}
|
|
157
|
-
function lanCandidates(port, interfaces = os.networkInterfaces()) {
|
|
158
|
-
return lanInterfaces(port, interfaces)
|
|
164
|
+
function lanCandidates(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
165
|
+
return lanInterfaces(port, interfaces, opts)
|
|
159
166
|
}
|
|
160
167
|
|
|
161
168
|
/**
|
|
@@ -307,6 +314,27 @@ function ipv6Candidates(port, interfaces = os.networkInterfaces()) {
|
|
|
307
314
|
}
|
|
308
315
|
}
|
|
309
316
|
|
|
317
|
+
// 反馈 1569:插件自己跑在容器里时,os.networkInterfaces() 只有 lo + eth0(容器内网地址),
|
|
318
|
+
// 手机永远拨不进来。这里按「进程是不是在容器里」判,而不是按地址段 —— 172.x 可能是真实
|
|
319
|
+
// Wi-Fi(反馈 1012 已拍板),不能因为地址落在私网段就排除。容器标记都是只读文件,读不到
|
|
320
|
+
// 一律当不在容器;结果按进程缓存,容器身份在进程生命周期内不会变。
|
|
321
|
+
let containerHint
|
|
322
|
+
function isContainerRuntime() {
|
|
323
|
+
if (containerHint !== undefined) return containerHint
|
|
324
|
+
let hit = false
|
|
325
|
+
try {
|
|
326
|
+
for (const marker of ['/.dockerenv', '/run/.containerenv']) {
|
|
327
|
+
if (fsSync.existsSync(marker)) { hit = true; break }
|
|
328
|
+
}
|
|
329
|
+
if (!hit) {
|
|
330
|
+
const cgroup = fsSync.readFileSync('/proc/1/cgroup', 'utf8')
|
|
331
|
+
hit = /(?:docker|containerd|kubepods|lxc[/])/.test(cgroup)
|
|
332
|
+
}
|
|
333
|
+
} catch { /* 非 Linux / 读不到标记:当不在容器 */ }
|
|
334
|
+
containerHint = hit
|
|
335
|
+
return hit
|
|
336
|
+
}
|
|
337
|
+
|
|
310
338
|
/**
|
|
311
339
|
* 对外公布的候选地址:**先私网,一个都没有时才退到公网**。
|
|
312
340
|
*
|
|
@@ -317,9 +345,9 @@ function ipv6Candidates(port, interfaces = os.networkInterfaces()) {
|
|
|
317
345
|
* 取不到网卡(异常)时回空清单、绝不抛:它喂的是二维码与移动端的连接信息,
|
|
318
346
|
* 让它把整条控制面拖下水不值得。
|
|
319
347
|
*/
|
|
320
|
-
function advertisedCandidates(port, interfaces = os.networkInterfaces()) {
|
|
348
|
+
function advertisedCandidates(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
321
349
|
try {
|
|
322
|
-
const lan = lanCandidates(port, interfaces)
|
|
350
|
+
const lan = lanCandidates(port, interfaces, opts)
|
|
323
351
|
if (lan.length > 0) return lan
|
|
324
352
|
return publicCandidates(port, interfaces)
|
|
325
353
|
} catch {
|
|
@@ -508,6 +536,7 @@ module.exports = {
|
|
|
508
536
|
isVpnInterface,
|
|
509
537
|
isVirtualInterface,
|
|
510
538
|
interfaceRank,
|
|
539
|
+
isContainerRuntime,
|
|
511
540
|
lanInterfaces,
|
|
512
541
|
lanUrls,
|
|
513
542
|
lanCandidates,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
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": "
|
|
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,22 +117,22 @@
|
|
|
117
117
|
"yaml": "2.9.1"
|
|
118
118
|
},
|
|
119
119
|
"dshMobileReleaseNotes": {
|
|
120
|
-
"version": "0.5.
|
|
120
|
+
"version": "0.5.134",
|
|
121
121
|
"kinds": [
|
|
122
122
|
"fix"
|
|
123
123
|
],
|
|
124
124
|
"notes": {
|
|
125
|
-
"zh-Hans": "-
|
|
126
|
-
"zh-Hant": "-
|
|
127
|
-
"en": "-
|
|
128
|
-
"ja": "-
|
|
129
|
-
"ko": "-
|
|
130
|
-
"de": "-
|
|
131
|
-
"es": "-
|
|
132
|
-
"fr": "-
|
|
133
|
-
"pt": "-
|
|
134
|
-
"ru": "-
|
|
135
|
-
"tr": "-
|
|
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."
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|