dsh-model 0.0.1 → 0.15.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.en.md +127 -0
- package/README.md +96 -43
- package/bin/dsh-model.js +8 -0
- package/dist/bridge/aggregate.js +91 -0
- package/dist/bridge/login.js +127 -0
- package/dist/bridge/runtime.js +136 -0
- package/dist/bridge/server.js +183 -0
- package/dist/bridge/workbuddy/_compat.js +52 -0
- package/dist/bridge/workbuddy/app-version.js +141 -0
- package/dist/bridge/workbuddy/auth.js +548 -0
- package/dist/bridge/workbuddy/catalog.js +154 -0
- package/dist/bridge/workbuddy/client-identity.js +234 -0
- package/dist/bridge/workbuddy/desktop-credential-protection.js +992 -0
- package/dist/bridge/workbuddy/loopback.js +52 -0
- package/dist/bridge/workbuddy/probe.js +153 -0
- package/dist/bridge/workbuddy/status-paths.js +49 -0
- package/dist/bridge/workbuddy/upstream.js +1180 -0
- package/dist/bridge/workbuddy/variants.js +101 -0
- package/dist/cli.js +215 -0
- package/dist/commands/bridge.js +68 -0
- package/dist/commands/connect.js +67 -0
- package/dist/commands/engine.js +122 -0
- package/dist/commands/key.js +75 -0
- package/dist/commands/login.js +113 -0
- package/dist/commands/logs.js +19 -0
- package/dist/commands/opencode.js +83 -0
- package/dist/commands/remote.js +129 -0
- package/dist/commands/self.js +116 -0
- package/dist/commands/service.js +72 -0
- package/dist/commands/setup.js +219 -0
- package/dist/commands/sources.js +196 -0
- package/dist/commands/status.js +216 -0
- package/dist/commands/uninstall.js +97 -0
- package/dist/commands/workbuddy.js +117 -0
- package/dist/context.js +86 -0
- package/dist/daemon/client.js +27 -0
- package/dist/daemon/core.js +850 -0
- package/dist/daemon/service.js +33 -0
- package/dist/daemon/stats.js +126 -0
- package/dist/daemon/usage.js +213 -0
- package/dist/dsh/cli.js +90 -0
- package/dist/dsh/connect.js +257 -0
- package/dist/dsh/credentials.js +55 -0
- package/dist/dsh/locate.js +129 -0
- package/dist/dsh/patch.js +106 -0
- package/dist/dsh/pick.js +59 -0
- package/dist/engine/auth.js +40 -0
- package/dist/engine/client.js +104 -0
- package/dist/engine/compat.js +94 -0
- package/dist/engine/config.js +47 -0
- package/dist/engine/install.js +118 -0
- package/dist/engine/mgmt.js +99 -0
- package/dist/engine/sourcemap.js +48 -0
- package/dist/errors.js +14 -0
- package/dist/i18n.js +39 -0
- package/dist/integrations/dshplugin.js +89 -0
- package/dist/integrations/opencode.js +101 -0
- package/dist/integrations/workbuddy.js +114 -0
- package/dist/keys.js +54 -0
- package/dist/ops.js +178 -0
- package/dist/remote/public.js +109 -0
- package/dist/secrets.js +13 -0
- package/dist/service/index.js +48 -0
- package/dist/service/launchd.js +89 -0
- package/dist/service/systemd.js +83 -0
- package/dist/sources.js +36 -0
- package/dist/state.js +90 -0
- package/dist/upstreams.js +23 -0
- package/dist/util/diff.js +30 -0
- package/dist/util/exec.js +42 -0
- package/dist/util/fs.js +107 -0
- package/dist/util/output.js +50 -0
- package/dist/util/pkg.js +13 -0
- package/dist/util/port.js +16 -0
- package/dist/util/prompt.js +40 -0
- package/dist/util/proxy.js +73 -0
- package/dist/util/redact.js +7 -0
- package/engine-manifest.json +28 -0
- package/package.json +77 -7
- package/plugin/client.js +688 -0
- package/plugin/cordis.patch.yml +4 -0
- package/plugin/index.js +231 -0
- package/docs/DESIGN.md +0 -610
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// util/proxy.ts — 出站代理:引擎作为后台服务运行时拿不到终端里的 HTTPS_PROXY,
|
|
2
|
+
// 所以 setup 时把代理写进 engine.yaml 的 requests.proxy-url。
|
|
3
|
+
// 检测顺序:HTTPS_PROXY / ALL_PROXY 环境变量 → macOS 系统代理(scutil --proxy)
|
|
4
|
+
import { connect } from 'node:net';
|
|
5
|
+
import { DshModelError } from '../errors.js';
|
|
6
|
+
import { L } from '../i18n.js';
|
|
7
|
+
import { run } from './exec.js';
|
|
8
|
+
export function normalizeProxyUrl(value) {
|
|
9
|
+
const v = value.trim();
|
|
10
|
+
let u;
|
|
11
|
+
try {
|
|
12
|
+
u = new URL(v);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new DshModelError('invalid_proxy', L(`代理地址不合法:${v}(例:http://127.0.0.1:7890 或 socks5://127.0.0.1:1080)`, `Invalid proxy URL: ${v} (e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:1080)`));
|
|
16
|
+
}
|
|
17
|
+
if (!['http:', 'https:', 'socks5:', 'socks5h:'].includes(u.protocol) || !u.hostname) {
|
|
18
|
+
throw new DshModelError('invalid_proxy', L(`代理只支持 http / https / socks5:${v}`, `Only http / https / socks5 proxies are supported: ${v}`));
|
|
19
|
+
}
|
|
20
|
+
return v.replace(/\/$/, '');
|
|
21
|
+
}
|
|
22
|
+
export async function detectProxy(env = process.env, platform = process.platform) {
|
|
23
|
+
for (const name of ['HTTPS_PROXY', 'https_proxy', 'ALL_PROXY', 'all_proxy']) {
|
|
24
|
+
const v = env[name]?.trim();
|
|
25
|
+
if (v) {
|
|
26
|
+
try {
|
|
27
|
+
return { url: normalizeProxyUrl(v), source: name };
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// 环境变量写错了就继续往下找
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (platform === 'darwin') {
|
|
35
|
+
const r = await run('scutil', ['--proxy']);
|
|
36
|
+
if (r.code === 0) {
|
|
37
|
+
const get = (k) => r.stdout.match(new RegExp(`\\b${k} : (\\S+)`))?.[1];
|
|
38
|
+
if (get('HTTPSEnable') === '1' && get('HTTPSProxy') && get('HTTPSPort'))
|
|
39
|
+
return { url: `http://${get('HTTPSProxy')}:${get('HTTPSPort')}`, source: 'macOS system proxy' };
|
|
40
|
+
if (get('SOCKSEnable') === '1' && get('SOCKSProxy') && get('SOCKSPort'))
|
|
41
|
+
return { url: `socks5://${get('SOCKSProxy')}:${get('SOCKSPort')}`, source: 'macOS system proxy' };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/** 代理端口能不能连上(doctor 用) */
|
|
47
|
+
export function proxyReachable(url, timeoutMs = 2000) {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
let u;
|
|
50
|
+
try {
|
|
51
|
+
u = new URL(url);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
resolve(false);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const port = Number(u.port) || (u.protocol === 'https:' ? 443 : u.protocol.startsWith('socks') ? 1080 : 80);
|
|
58
|
+
const sock = connect({ host: u.hostname, port, timeout: timeoutMs });
|
|
59
|
+
sock.once('connect', () => {
|
|
60
|
+
sock.destroy();
|
|
61
|
+
resolve(true);
|
|
62
|
+
});
|
|
63
|
+
sock.once('timeout', () => {
|
|
64
|
+
sock.destroy();
|
|
65
|
+
resolve(false);
|
|
66
|
+
});
|
|
67
|
+
sock.once('error', () => resolve(false));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/** 显示用:隐去代理里的账号密码 */
|
|
71
|
+
export function redactProxy(url) {
|
|
72
|
+
return url.replace(/\/\/[^@/]*@/, '//***@');
|
|
73
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "CLIProxyAPI",
|
|
3
|
+
"repo": "router-for-me/CLIProxyAPI",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"version": "8.0.13",
|
|
6
|
+
"assets": {
|
|
7
|
+
"darwin-aarch64": {
|
|
8
|
+
"file": "CLIProxyAPI_8.0.13_darwin_aarch64.tar.gz",
|
|
9
|
+
"url": "https://github.com/router-for-me/CLIProxyAPI/releases/download/v8.0.13/CLIProxyAPI_8.0.13_darwin_aarch64.tar.gz",
|
|
10
|
+
"sha256": "652a192e3e38520253e330c4a094fa8916728370c3f213f127dbc56e35be7938"
|
|
11
|
+
},
|
|
12
|
+
"darwin-amd64": {
|
|
13
|
+
"file": "CLIProxyAPI_8.0.13_darwin_amd64.tar.gz",
|
|
14
|
+
"url": "https://github.com/router-for-me/CLIProxyAPI/releases/download/v8.0.13/CLIProxyAPI_8.0.13_darwin_amd64.tar.gz",
|
|
15
|
+
"sha256": "8c47459190b997828be246973d18fbb681799540cebb867c3b7368d189559785"
|
|
16
|
+
},
|
|
17
|
+
"linux-aarch64": {
|
|
18
|
+
"file": "CLIProxyAPI_8.0.13_linux_aarch64.tar.gz",
|
|
19
|
+
"url": "https://github.com/router-for-me/CLIProxyAPI/releases/download/v8.0.13/CLIProxyAPI_8.0.13_linux_aarch64.tar.gz",
|
|
20
|
+
"sha256": "f7ff98a128075ea8437dadd58a88f429a401e452a42ef7119304139185f5344f"
|
|
21
|
+
},
|
|
22
|
+
"linux-amd64": {
|
|
23
|
+
"file": "CLIProxyAPI_8.0.13_linux_amd64.tar.gz",
|
|
24
|
+
"url": "https://github.com/router-for-me/CLIProxyAPI/releases/download/v8.0.13/CLIProxyAPI_8.0.13_linux_amd64.tar.gz",
|
|
25
|
+
"sha256": "50ecffb47fdd81c8c5a9825a73a7a905ab66342337e274f39c4276b92d3533f3"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,92 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-model",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "Many model sources behind one authenticated OpenAI-compatible endpoint for DeepSeek Harness (dsh) and your tools: WorkBuddy, OpenCode Zen and your CLI subscriptions (Codex, Kimi…), with a management page inside dsh. 多家模型汇成一个 OpenAI 兼容地址,dsh 和其他软件都能直接用。",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"dsh-plugin",
|
|
7
|
+
"dsh-plugins",
|
|
6
8
|
"dsh",
|
|
7
9
|
"deepseek-harness",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
+
"deepseek-harness-plugin",
|
|
11
|
+
"deepseek",
|
|
12
|
+
"cordis",
|
|
10
13
|
"model-provider",
|
|
14
|
+
"llm-gateway",
|
|
11
15
|
"openai-compatible",
|
|
12
|
-
"
|
|
16
|
+
"openai-api",
|
|
17
|
+
"cli-subscription",
|
|
18
|
+
"codex",
|
|
19
|
+
"kimi",
|
|
20
|
+
"workbuddy",
|
|
21
|
+
"opencode",
|
|
22
|
+
"cliproxyapi",
|
|
23
|
+
"self-hosted",
|
|
24
|
+
"llm-tools"
|
|
13
25
|
],
|
|
14
26
|
"license": "MIT",
|
|
27
|
+
"type": "module",
|
|
28
|
+
"bin": {
|
|
29
|
+
"dsh-model": "bin/dsh-model.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"bin",
|
|
33
|
+
"dist",
|
|
34
|
+
"plugin",
|
|
35
|
+
"engine-manifest.json",
|
|
36
|
+
"README.md",
|
|
37
|
+
"README.en.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc -p tsconfig.json",
|
|
42
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:contract": "vitest run tests/engine-contract",
|
|
45
|
+
"pin-engine": "node scripts/pin-engine.mjs"
|
|
46
|
+
},
|
|
15
47
|
"repository": {
|
|
16
48
|
"type": "git",
|
|
17
49
|
"url": "git+https://github.com/AIcivilization/dsh-model.git"
|
|
18
50
|
},
|
|
19
51
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
21
|
-
}
|
|
52
|
+
"node": ">=20"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"yaml": "^2.9.1"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/node": "^20.19.43",
|
|
59
|
+
"typescript": "^5.9.3",
|
|
60
|
+
"vitest": "^3.2.7"
|
|
61
|
+
},
|
|
62
|
+
"exports": {
|
|
63
|
+
".": "./plugin/index.js",
|
|
64
|
+
"./client": "./plugin/client.js",
|
|
65
|
+
"./package.json": "./package.json"
|
|
66
|
+
},
|
|
67
|
+
"dsh": {
|
|
68
|
+
"bundle": {
|
|
69
|
+
"patch": "./plugin/cordis.patch.yml"
|
|
70
|
+
},
|
|
71
|
+
"client": {
|
|
72
|
+
"platform": "web"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
77
|
+
"react": ">=18.0.0"
|
|
78
|
+
},
|
|
79
|
+
"peerDependenciesMeta": {
|
|
80
|
+
"@deepseek-ai/cordis": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"react": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"homepage": "https://github.com/AIcivilization/dsh-model#readme",
|
|
88
|
+
"bugs": {
|
|
89
|
+
"url": "https://github.com/AIcivilization/dsh-model/issues"
|
|
90
|
+
},
|
|
91
|
+
"author": "AIcivilization"
|
|
22
92
|
}
|