@yanglaofish/dsh-proxy-pro 2.0.1 → 2.0.3
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 +19 -1
- package/docs/ACCEPTANCE.md +11 -1
- package/docs/LESSONS.md +1251 -1217
- package/lib/client.js +5 -3
- package/lib/index.js +909 -902
- package/lib/proxy-core.js +17 -2
- package/lib/tool-schemas.js +13 -1
- package/package.json +3 -3
package/lib/proxy-core.js
CHANGED
|
@@ -110,6 +110,21 @@ export function normalizeProxyUrl(value) {
|
|
|
110
110
|
return url.toString().replace(/\/+$/, '')
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/** 仅用于状态展示;传输层和可编辑配置继续使用完整的原始地址。 */
|
|
114
|
+
export function redactProxyUrl(value) {
|
|
115
|
+
if (typeof value !== 'string' || value === '') return ''
|
|
116
|
+
try {
|
|
117
|
+
const url = new URL(value)
|
|
118
|
+
if (!url.username && !url.password) return value
|
|
119
|
+
url.username = ''
|
|
120
|
+
url.password = ''
|
|
121
|
+
return url.toString().replace(/\/+$/, '')
|
|
122
|
+
} catch {
|
|
123
|
+
// 无效地址也不能把 user:password 原样带入错误提示。
|
|
124
|
+
return value.replace(/(https?:\/\/)[^\s/?#]*@/gi, '$1[redacted]@')
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
113
128
|
/**
|
|
114
129
|
* Parse a Windows `ProxyServer` string: single `host:port` (both protocols)
|
|
115
130
|
* or `http=...;https=...` form; `socks=` ignored (undici speaks HTTP CONNECT).
|
|
@@ -324,7 +339,7 @@ export function summarize(snapshot) {
|
|
|
324
339
|
active: effective?.active === true,
|
|
325
340
|
enabled: config?.enabled === true,
|
|
326
341
|
mode: config?.mode ?? 'none',
|
|
327
|
-
url: effective?.url ?? '',
|
|
342
|
+
url: redactProxyUrl(effective?.url ?? ''),
|
|
328
343
|
noProxy: effective?.noProxy ?? composeNoProxy(config?.noProxy),
|
|
329
344
|
reason: effective?.reason ?? 'unknown',
|
|
330
345
|
source: config?.mode === 'system' ? 'system' : config?.mode === 'custom' ? 'custom' : 'none',
|
|
@@ -342,7 +357,7 @@ export function summarize(snapshot) {
|
|
|
342
357
|
export function keepaliveHint(message = '', proxyUrl = '') {
|
|
343
358
|
const text = typeof message === 'string' ? message : ''
|
|
344
359
|
if (!/407|NTLM|proxy authentication|authentication required/i.test(text)) return ''
|
|
345
|
-
const example = typeof proxyUrl === 'string' && proxyUrl !== '' ? proxyUrl : 'http://localhost:7890'
|
|
360
|
+
const example = typeof proxyUrl === 'string' && proxyUrl !== '' ? redactProxyUrl(proxyUrl) : 'http://localhost:7890'
|
|
346
361
|
return `该代理要求 NTLM 认证,undici 无法自行协商。最近一次 curl/浏览器到同一代理的连接会保持一段已认证窗口——先执行一次 \`curl -x ${example} -I https://github.com\`,然后重试。`
|
|
347
362
|
}
|
|
348
363
|
|
package/lib/tool-schemas.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-proxy-pro — tool schema specs (pure data, no imports).
|
|
3
3
|
*
|
|
4
|
-
* These are the author-facing dsh-tools value-schema specs for the
|
|
4
|
+
* These are the author-facing dsh-tools value-schema specs for the four agent
|
|
5
5
|
* tools. They live in their own module for ONE reason: `test/tool-schema.test.mjs`
|
|
6
6
|
* compiles them with the real `@deepseek-ai/dsh-tools` compiler before the app
|
|
7
7
|
* ever boots, so a schema-DSL violation can no longer surface only as a
|
|
@@ -72,6 +72,16 @@ const PROBE_RESULT_SCHEMA = {
|
|
|
72
72
|
},
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// 通道徽标由双通道诊断产生;无效 URL 提前返回时可省略整个徽标。
|
|
76
|
+
const PROBE_BADGE_SCHEMA = {
|
|
77
|
+
type: 'object',
|
|
78
|
+
additionalProperties: false,
|
|
79
|
+
properties: {
|
|
80
|
+
text: { type: 'string', required: true },
|
|
81
|
+
tone: { type: 'string', enum: ['ok', 'warn', 'bad'], required: true },
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
|
|
75
85
|
/** Output schema of `proxy_test`. Dual-channel: forces both legs in parallel
|
|
76
86
|
* (走代理 / 直连), then combines them into one human verdict + recommendation
|
|
77
87
|
* (2026-09-18: single-side probes cannot tell WHO answered, so a strategy
|
|
@@ -90,6 +100,8 @@ export const PROXY_TEST_SCHEMA = {
|
|
|
90
100
|
short: { type: 'string', required: true },
|
|
91
101
|
why: { type: 'string', required: true },
|
|
92
102
|
fix: { type: 'string', required: true },
|
|
103
|
+
proxyBadge: PROBE_BADGE_SCHEMA,
|
|
104
|
+
directBadge: PROBE_BADGE_SCHEMA,
|
|
93
105
|
hint: { type: 'string' },
|
|
94
106
|
},
|
|
95
107
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanglaofish/dsh-proxy-pro",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
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",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"client": {
|
|
54
54
|
"platform": "web",
|
|
55
55
|
"inject": [
|
|
56
|
-
"@deepseek-ai/dsh-client-
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
57
57
|
"@deepseek-ai/dsh-client-ui-settings",
|
|
58
58
|
"@deepseek-ai/dsh-client-ui-conversation"
|
|
59
59
|
]
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
}
|
|
62
|
+
}
|