@yanglaofish/dsh-proxy-pro 1.0.4 → 1.0.5
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/docs/LESSONS.md +28 -1
- package/docs/SPEC.md +4 -2
- package/lib/index.js +20 -12
- package/package.json +1 -1
package/docs/LESSONS.md
CHANGED
|
@@ -723,4 +723,31 @@ forced-proxy = 新建 ProxyAgent,全部由 `und.fetch` 发起。
|
|
|
723
723
|
行动;`proxy_test` 工具输出同步中文(模型照读)。教训:给用户看的文案别用英文"图省事",
|
|
724
724
|
判定结论必须能直接用。
|
|
725
725
|
|
|
726
|
-
**测试**:断言随中文文案同步翻新(/混用/、/超时/、/上游|超时/、/ECONNREFUSED/)。
|
|
726
|
+
**测试**:断言随中文文案同步翻新(/混用/、/超时/、/上游|超时/、/ECONNREFUSED/)。
|
|
727
|
+
|
|
728
|
+
---
|
|
729
|
+
|
|
730
|
+
## 26. 不 import 会被移除的库导出:settings 走服务(2026-09-18)
|
|
731
|
+
|
|
732
|
+
**症状**:升级 test profile 后,dsh CLI 启动时整棵树崩溃:
|
|
733
|
+
`SyntaxError: The requested module '@deepseek-ai/dsh-settings' does not provide an export named 'installSettingsSection'`,
|
|
734
|
+
插件行加载失败 → 整个启动终止。
|
|
735
|
+
|
|
736
|
+
**根因**:dsh-settings 同时存在两个版本——桌面版(resources/app/node_modules)**保留**了
|
|
737
|
+
`installSettingsSection`/`settingsNamespace` 兼容导出;全局 dsh CLI(AppData/Roaming/npm 的
|
|
738
|
+
`@deepseek-ai/dsh` 自带依赖树)是**新版,已移除这两个导出**。插件在模块顶层
|
|
739
|
+
`import { installSettingsSection } from '@deepseek-ai/dsh-settings'` → ESM 求值阶段就抛
|
|
740
|
+
SyntaxError,不是运行期错误——profile 插件树加载失败,启动直接终止。
|
|
741
|
+
|
|
742
|
+
**改法**(1.0.5):彻底不 import dsh-settings 的任何导出,配置注册改走 **settings 服务**:
|
|
743
|
+
```js
|
|
744
|
+
const scope = ctx.settings.register(PROXY_NS, Config, { base: config })
|
|
745
|
+
source = () => scope.get() // update() 重算 registration.resolved,get() 始终新鲜
|
|
746
|
+
scope.watch(() => { void requestSync().catch(() => {}) })
|
|
747
|
+
```
|
|
748
|
+
`register`/`watch`/`update`/`replace` 在两端(旧桌面版 SettingsProvider 与新 CLI 版)都存在;
|
|
749
|
+
命名空间直接写字面量 `'proxy'`(旧 `settingsNamespace()` 也只是 parse + 校验)。
|
|
750
|
+
|
|
751
|
+
**教训**:① ESM 顶层 import 命中断言是**加载期**错误——一次错误的 import 能杀死整个进程,所以
|
|
752
|
+
对外部包的导出要查运行环境的实际版本,而不是凭记忆;② 能从服务拿到的(settings 是 inject 服务)
|
|
753
|
+
就不要 import 包;③ 「桌面版」与「全局 CLI 版」是两套依赖树,一个功能必须两端都能加载。
|
package/docs/SPEC.md
CHANGED
|
@@ -105,7 +105,7 @@ profile 内安装(pnpm nodeLinker: hoisted;本地=file: 软链,发布=regi
|
|
|
105
105
|
|
|
106
106
|
```
|
|
107
107
|
[浏览器 client.js] [host index.js (NodeService 链)]
|
|
108
|
-
│ inject settings.section │
|
|
108
|
+
│ inject settings.section │ ctx.settings.register('proxy') + watch
|
|
109
109
|
│ inject header.utilities │ sync(): resolve → applyEffective(env+dispatcher)
|
|
110
110
|
│ fetch /dsh-proxy-pro/api/* ◄──────┤ → installProxyFromEnvironment(policy)
|
|
111
111
|
│ │ ↓ 让 web_fetch 的 proxyRouteFor 判 PROXIED
|
|
@@ -140,7 +140,9 @@ function apply(ctx, config) { … } // 导出 { Config, apply, inject, name }
|
|
|
140
140
|
- **没有 savedEnv / EnvHttpProxyAgent / 手写 dispatcher**:传输完全委托
|
|
141
141
|
`installProxyFromEnvironment`(env + 全局 dispatcher + 模块级策略一体,
|
|
142
142
|
LESSONS §12.4:单一通道,杜绝 undici 错版)。
|
|
143
|
-
- `
|
|
143
|
+
- `ctx.settings.register(PROXY_NS, Config, { base: config })` 拿 owner scope,
|
|
144
|
+
`source = () => scope.get()`,`scope.watch(onChange)` —— 新版 dsh-settings 已移除
|
|
145
|
+
`installSettingsSection` 导出(LESSONS §26),必须走 settings 服务;
|
|
144
146
|
onChange → `requestSync()`(合并去重,`syncing` 单飞)。
|
|
145
147
|
- teardown(`ctx.effect`):清 pollTimer → `await httpProxyPolicy?.()`(卸载=恢复
|
|
146
148
|
env/dispatcher/策略)。
|
package/lib/index.js
CHANGED
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import z from '@deepseek-ai/schemastery'
|
|
28
28
|
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
29
|
-
import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings'
|
|
30
29
|
import { installProxyFromEnvironment, proxyRouteFor } from '@deepseek-ai/dsh-http-proxy'
|
|
31
30
|
import { execFile } from 'node:child_process'
|
|
32
31
|
import { promisify } from 'node:util'
|
|
@@ -56,8 +55,11 @@ const name = 'dsh-proxy-pro'
|
|
|
56
55
|
/** Services this plugin must resolve before it applies. */
|
|
57
56
|
const inject = ['tools', 'systemPrompt', 'settings']
|
|
58
57
|
|
|
59
|
-
/** Settings namespace owning the proxy configuration (shared with stock
|
|
60
|
-
|
|
58
|
+
/** Settings namespace owning the proxy configuration (shared with stock
|
|
59
|
+
* tooling). Plain literal: the legacy settingsNamespace() helper was removed
|
|
60
|
+
* from newer dsh-settings, and 'proxy' is already a valid lowercase-hyphenated
|
|
61
|
+
* namespace identifier. */
|
|
62
|
+
const PROXY_NS = 'proxy'
|
|
61
63
|
|
|
62
64
|
/** Ordered placement of the proxy status section in the system prompt. */
|
|
63
65
|
const SECTION_ORDER = 55
|
|
@@ -442,16 +444,22 @@ function apply(ctx, config) {
|
|
|
442
444
|
}
|
|
443
445
|
|
|
444
446
|
// Configuration source: the `proxy` settings namespace layered over the
|
|
445
|
-
// composition entry; every committed change re-syncs live.
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
447
|
+
// composition entry; every committed change re-syncs live. Registration goes
|
|
448
|
+
// through the settings SERVICE — newer dsh-settings removed the
|
|
449
|
+
// `installSettingsSection` export entirely, so importing it throws a
|
|
450
|
+
// SyntaxError at boot and kills the whole profile (LESSONS §26).
|
|
451
|
+
// register() + scope.get()/watch() exist on every version we target, and
|
|
452
|
+
// update() recomputes registration.resolved, so scope.get() stays fresh.
|
|
453
|
+
const settingsService = ctx.get('settings')
|
|
454
|
+
if (settingsService !== undefined && typeof settingsService.register === 'function') {
|
|
455
|
+
const proxyScope = settingsService.register(PROXY_NS, Config, { base: config })
|
|
456
|
+
source = () => proxyScope.get()
|
|
457
|
+
proxyScope.watch(() => {
|
|
449
458
|
void requestSync().catch(() => {})
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
})
|
|
459
|
+
})
|
|
460
|
+
}
|
|
461
|
+
// Without a settings service in this composition, `source` keeps the
|
|
462
|
+
// composition default (initialized above) and the plugin still runs, read-only.
|
|
455
463
|
|
|
456
464
|
// ---------- Agent tools ----------
|
|
457
465
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanglaofish/dsh-proxy-pro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "DSH proxy manager: route model requests, web fetches and spawned tools through the Windows system proxy or a custom address; per-URL route diagnosis, one-click toggle from the conversation header, a dedicated Settings page, and keepalive-aware 407 hints.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|