@refeain/dsh-xdpool 0.0.0-stage → 3.0.7

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.
@@ -0,0 +1,359 @@
1
+ /**
2
+ * Link the host-provided peer dependencies into this package's node_modules.
3
+ *
4
+ * WHY THIS EXISTS
5
+ *
6
+ * Seven of this plugin's dependencies are `peerDependencies`: the host supplies them, not
7
+ * npm. A manual copy of the package into `node_modules/dsh-xdpool` resolved them by walking
8
+ * up into the host's tree, so nothing was ever missing. Installing normally breaks that
9
+ * walk, and a top-level import failure prevents `apply()` from ever running — so EVERY web
10
+ * route is unregistered and the card renders empty while blaming the gateway.
11
+ *
12
+ * WHAT IT MAY NOT DO: FAIL THE INSTALL
13
+ *
14
+ * The script links what it can find and then stops. It does not exit non-zero when the
15
+ * host cannot be located, for a reason that two bug reports made concrete:
16
+ *
17
+ * - A PACKAGED host keeps its dependencies inside `app.asar`, and `fs.existsSync` in a
18
+ * plain Node process cannot see inside an asar archive — only Electron's patched `fs`
19
+ * can. So "not found" from here often means "invisible to this process", not "absent".
20
+ * - The host resolves these peers itself at runtime. 2.6.3 shipped with no postinstall at
21
+ * all and loaded fine on macOS for exactly that reason.
22
+ *
23
+ * The previous version treated a failed probe as proof of a broken install and exited 1,
24
+ * which made the plugin manager roll back a working upgrade. That is the worst outcome
25
+ * available: the user loses the new version to protect against a problem they did not have.
26
+ *
27
+ * So the contract is now: link when the host is reachable, otherwise say what was not
28
+ * found and finish successfully. Only an actual failure to CREATE a link is reported, and
29
+ * even then as a warning — the plugin may still load through the host's own resolution.
30
+ *
31
+ * HOW RESOLUTION IS CHECKED
32
+ *
33
+ * With ESM, not CJS. `@earendil-works/pi-ai` is ESM-only: its `exports` map has `types` and
34
+ * `import` but no `require` and no `./package.json` subpath. A `require.resolve()` of it
35
+ * throws ERR_PACKAGE_PATH_NOT_EXPORTED even when the package is installed and importable,
36
+ * which is precisely the false negative the reporter hit. `import.meta.resolve` asks the
37
+ * question the plugin will actually ask.
38
+ *
39
+ * @module dsh-xdpool/scripts/link-host-peers
40
+ */
41
+ import { existsSync, mkdirSync, readFileSync, rmSync, symlinkSync } from 'node:fs'
42
+ import { dirname, join, resolve } from 'node:path'
43
+ import { fileURLToPath, pathToFileURL } from 'node:url'
44
+
45
+ const HERE = dirname(fileURLToPath(import.meta.url))
46
+ const PACKAGE_ROOT = resolve(HERE, '..')
47
+ const ENTRY_URL = pathToFileURL(join(PACKAGE_ROOT, 'lib', 'index.js')).href
48
+
49
+ /** The peer dependencies this plugin imports at runtime. */
50
+ function peerNames() {
51
+ const manifest = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8'))
52
+ return Object.keys(manifest.peerDependencies ?? {})
53
+ }
54
+
55
+ /**
56
+ * Can the plugin resolve `name` from its own entry point?
57
+ *
58
+ * `import.meta.resolve` answers with ESM conditions, which is what the plugin uses. It
59
+ * never throws for a missing package in current Node — it returns a URL that may not
60
+ * exist — so the answer is checked for existence as well.
61
+ *
62
+ * A `data:` or `node:` result is not a real package file and is treated as unresolved.
63
+ */
64
+ function resolvesFromEntry(name) {
65
+ try {
66
+ const url = import.meta.resolve(name, ENTRY_URL)
67
+ if (typeof url !== 'string' || url === '') return undefined
68
+ if (url.startsWith('node:') || url.startsWith('data:')) return undefined
69
+ return fileURLToPath(url)
70
+ } catch {
71
+ return undefined
72
+ }
73
+ }
74
+
75
+ /** The installed version of a package directory, or undefined when unreadable. */
76
+ function versionOf(dir) {
77
+ try {
78
+ const manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'))
79
+ return typeof manifest.version === 'string' ? manifest.version : undefined
80
+ } catch {
81
+ return undefined
82
+ }
83
+ }
84
+
85
+ /**
86
+ * The host's copy of a peer, if one can be found.
87
+ *
88
+ * Separate from `locate` because the two answer different questions: `locate` asks "is this
89
+ * importable", `hostCopyOf` asks "where is the host's own copy". The second is needed to
90
+ * detect a version MISMATCH, which is a failure mode `locate` cannot see — the package
91
+ * resolves perfectly well at the wrong generation.
92
+ */
93
+ function hostCopyOf(name) {
94
+ for (const root of hostRoots()) {
95
+ const candidate = join(root, name)
96
+ if (existsSync(join(candidate, 'package.json'))) return candidate
97
+ }
98
+ return undefined
99
+ }
100
+
101
+ /**
102
+ * The package directory for `name`, whether or not it can be imported right now.
103
+ *
104
+ * The physical check comes FIRST because it is the only one that works for an ESM-only
105
+ * package whose `exports` map omits `./package.json`: `require.resolve(`${name}/package.json`)`
106
+ * throws ERR_PACKAGE_PATH_NOT_EXPORTED for `pi-ai` even with the package sitting on disk.
107
+ * That false negative used to send an already-linked peer back into the missing list, so a
108
+ * second `postinstall` run re-linked what it had just built.
109
+ */
110
+ function locate(name) {
111
+ // 1. On disk under this package's own node_modules — a junction we made earlier counts.
112
+ const physical = join(PACKAGE_ROOT, 'node_modules', name)
113
+ if (existsSync(join(physical, 'package.json'))) return physical
114
+ // 2. Whatever ESM resolves from the entry, which is the real question.
115
+ const resolved = resolvesFromEntry(name)
116
+ if (resolved !== undefined) {
117
+ // Walk up to the package root: the first directory named like the package.
118
+ const wanted = name.startsWith('@') ? name.split('/')[1] : name
119
+ let dir = dirname(resolved)
120
+ while (dir !== dirname(dir)) {
121
+ if (dir.endsWith(`/${wanted}`) || dir.endsWith(`\\${wanted}`)) return dir
122
+ dir = dirname(dir)
123
+ }
124
+ return dirname(resolved)
125
+ }
126
+ return undefined
127
+ }
128
+
129
+ /**
130
+ * Candidate host module roots.
131
+ *
132
+ * The host SPLITS its tree — `cordis` and the `@deepseek-ai/*` runtime in one place,
133
+ * `pi-ai` in another — so several roots are tried rather than one.
134
+ *
135
+ * `DSH_HOST_ROOT` is honoured when set, but note it is NOT injected by the host: two
136
+ * reporters verified that the plugin manager does not pass it. It exists for an operator
137
+ * who wants to point at a specific tree by hand.
138
+ *
139
+ * On a packaged install most of this is unverifiable from a plain Node process, because the
140
+ * dependencies live inside `app.asar` and `existsSync` cannot see in. That is expected and
141
+ * is why a miss is not an error.
142
+ */
143
+ function hostRoots() {
144
+ const roots = []
145
+ const env = process.env['DSH_HOST_ROOT']
146
+ if (typeof env === 'string' && env !== '') roots.push(env)
147
+ // When the host loads the plugin from inside its own tree.
148
+ roots.push(resolve(PACKAGE_ROOT, '..'))
149
+ roots.push(resolve(PACKAGE_ROOT, '..', '..', '..'))
150
+ /**
151
+ * Derived from the running executable, which is the only signal that survives a
152
+ * non-default install drive — the reporter's harness sat on `F:` while every hard-coded
153
+ * guess pointed at `C:`. `process.execPath` is the Node or Electron binary doing the
154
+ * install, which for the bundled runtime lives inside the harness directory.
155
+ */
156
+ for (const up of [1, 2, 3, 4, 5]) {
157
+ const segments = [process.execPath]
158
+ for (let i = 0; i < up; i += 1) segments.push('..')
159
+ const base = resolve(...segments)
160
+ for (const app of ['app', join('app', 'dsh')]) {
161
+ roots.push(join(base, 'resources', app, 'node_modules'))
162
+ }
163
+ roots.push(join(base, 'node_modules'))
164
+ }
165
+ for (const base of HARNESS_BASES) {
166
+ if (typeof base !== 'string' || base === '') continue
167
+ for (const app of ['app', join('app', 'dsh')]) {
168
+ roots.push(join(base, 'resources', app, 'node_modules'))
169
+ }
170
+ }
171
+ return [...new Set(roots)]
172
+ }
173
+
174
+ /**
175
+ * Where a DSH install commonly sits, per platform.
176
+ *
177
+ * Every entry is a guess and a miss is silent, which is what makes listing several
178
+ * acceptable. `HARNESS_BASES` used to be Windows-only — the macOS reporter's whole
179
+ * `LOCALAPPDATA`/`PROGRAMFILES` loop simply never ran.
180
+ */
181
+ const HARNESS_BASES = [
182
+ process.env['DSH_HARNESS_ROOT'],
183
+ // macOS: /Applications/DeepSeek Harness.app/Contents/Resources
184
+ '/Applications/DeepSeek Harness.app/Contents/Resources',
185
+ join(process.env['HOME'] ?? '', 'Applications', 'DeepSeek Harness.app', 'Contents', 'Resources'),
186
+ // Linux
187
+ join(process.env['HOME'] ?? '', '.local', 'share', 'deepseek-harness'),
188
+ '/opt/DeepSeek Harness',
189
+ // Windows, default locations
190
+ typeof process.env['LOCALAPPDATA'] === 'string' ? join(process.env['LOCALAPPDATA'], 'Programs', 'DeepSeek Harness') : undefined,
191
+ typeof process.env['LOCALAPPDATA'] === 'string' ? join(process.env['LOCALAPPDATA'], 'DeepSeek Harness') : undefined,
192
+ typeof process.env['ProgramW6432'] === 'string' ? process.env['ProgramW6432'] : undefined,
193
+ typeof process.env['PROGRAMFILES'] === 'string' ? process.env['PROGRAMFILES'] : undefined,
194
+ /**
195
+ * Windows, installed on another drive.
196
+ *
197
+ * Not a guess about this particular machine: it is derived from where the PROFILE lives.
198
+ * A DSH profile sits at `<harness data dir>/profiles/<name>`, and on Windows the data
199
+ * directory is often the harness's own folder — which is exactly the layout this repo
200
+ * was developed against (`<data>\profiles\desktop` beside `<install>`).
201
+ * When they are siblings, the harness is one segment up with a different name, so the
202
+ * sibling of the data dir is tried as a harness root too.
203
+ *
204
+ * A miss costs nothing, which is why deriving is preferable to hard-coding a drive letter.
205
+ */
206
+ ...siblingHarnessBases(),
207
+ ]
208
+
209
+ /**
210
+ * Harness roots that can be derived from where this profile lives.
211
+ *
212
+ * `<data>\profiles\desktop\node_modules\dsh-xdpool` → walk up to the data directory,
213
+ * then try every plausible sibling. Cheap, and it is the only way to find a harness on a
214
+ * non-default drive without asking the user to set an environment variable.
215
+ *
216
+ * Several levels are tried because the two layouts in the wild differ:
217
+ *
218
+ * - `<dataDir>/profiles/<name>` — the data dir's PARENT holds the harness
219
+ * (`<data>` beside `<install>`)
220
+ * - the harness IS the data dir's parent — some installs put profiles inside the app
221
+ *
222
+ * A miss costs nothing, which is why deriving beats hard-coding a drive letter.
223
+ */
224
+ function siblingHarnessBases() {
225
+ const out = []
226
+ let dir = PACKAGE_ROOT
227
+ let dataDir
228
+ for (let i = 0; i < 8; i += 1) {
229
+ dir = dirname(dir)
230
+ if (dir === dirname(dir)) break
231
+ // `<x>/profiles/...` means `<x>` is the data directory.
232
+ if (dirname(dir).endsWith('profiles')) { dataDir = dirname(dir); break }
233
+ if (dir.endsWith('profiles')) { dataDir = dirname(dir); break }
234
+ }
235
+ const start = dataDir ?? resolve(PACKAGE_ROOT, '..', '..', '..')
236
+ // Walk up a few levels from the data directory, offering a sibling at each.
237
+ let cursor = start
238
+ for (let i = 0; i < 3; i += 1) {
239
+ out.push(join(cursor, 'DeepSeek Harness'))
240
+ const parent = dirname(cursor)
241
+ if (parent === cursor) break
242
+ out.push(join(parent, 'DeepSeek Harness'))
243
+ cursor = parent
244
+ }
245
+ return out
246
+ }
247
+
248
+ /** Whether this is a source checkout rather than an installed package. */
249
+ const IS_SOURCE_CHECKOUT = existsSync(join(PACKAGE_ROOT, 'src'))
250
+
251
+ const linked = []
252
+ const alreadyResolved = []
253
+ const notFound = []
254
+ const failed = []
255
+
256
+ for (const name of peerNames()) {
257
+ /**
258
+ * A peer that resolves is only acceptable if its VERSION matches the host's.
259
+ *
260
+ * Resolvability alone is not the contract that matters. `@earendil-works/pi-ai` shipped
261
+ * from a `devDependency` at 0.85.1 while the host ran 1.1.0, and the plugin's own
262
+ * `warnOnPiAiGenerationMismatch` documents the result: two copies on one call chain throw
263
+ * at the adapter seam and the host reports every turn as a non-retryable `PI_AI_ERROR`.
264
+ * The package resolved fine — at the wrong generation.
265
+ *
266
+ * So when the host has a copy and ours differs, the host's copy WINS. That is the whole
267
+ * point of treating these as peer dependencies: the host owns them, and a second
268
+ * generation beside it is a defect rather than a choice.
269
+ */
270
+ const current = locate(name)
271
+ const hostCopy = hostCopyOf(name)
272
+ const hostVersion = hostCopy === undefined ? undefined : versionOf(hostCopy)
273
+ const ours = current === undefined ? undefined : versionOf(current)
274
+ if (current !== undefined && (hostVersion === undefined || ours === hostVersion)) {
275
+ alreadyResolved.push(name)
276
+ continue
277
+ }
278
+ // A mismatch is reported below through `relinked` when the host copy is linked.
279
+ let target = hostCopy
280
+ if (target === undefined) {
281
+ for (const root of hostRoots()) {
282
+ const candidate = join(root, name)
283
+ // `existsSync` cannot see inside `app.asar`; on a packaged host this simply misses and
284
+ // the peer is reported as not found, which is no longer fatal.
285
+ if (existsSync(join(candidate, 'package.json'))) { target = candidate; break }
286
+ }
287
+ }
288
+ if (target === undefined) { notFound.push(name); continue }
289
+ const dest = join(PACKAGE_ROOT, 'node_modules', name)
290
+ try {
291
+ mkdirSync(dirname(dest), { recursive: true })
292
+ // A previous run may have left a link (or a partial one); replacing it is correct
293
+ // because the resolve check above already skipped anything that works.
294
+ if (existsSync(dest)) rmSync(dest, { recursive: true, force: true })
295
+ // Junction on Windows because creating a real symlink needs elevation there; a
296
+ // junction needs none and behaves the same for directory reads.
297
+ symlinkSync(target, dest, process.platform === 'win32' ? 'junction' : 'dir')
298
+ linked.push(`${name} → ${target}${ours === undefined ? '' : ` (was ${ours}, host has ${hostVersion ?? '?'})`}`)
299
+ } catch (error) {
300
+ failed.push(`${name} (${error instanceof Error ? error.message : String(error)})`)
301
+ }
302
+ }
303
+
304
+ if (linked.length > 0) {
305
+ process.stdout.write(`dsh-xdpool: linked ${String(linked.length)} host dependency(ies)\n`)
306
+ for (const line of linked) process.stdout.write(` ${line}\n`)
307
+ }
308
+ if (alreadyResolved.length > 0 && linked.length === 0) {
309
+ process.stdout.write(`dsh-xdpool: all ${String(alreadyResolved.length)} peer dependencies already resolve\n`)
310
+ }
311
+
312
+ /**
313
+ * Report, and deliberately do not fail.
314
+ *
315
+ * A packaged host hides these inside `app.asar` (invisible to a bare Node process) and
316
+ * resolves them itself at runtime — 2.6.3 shipped with no postinstall and loaded fine. So
317
+ * "not found from here" is not evidence of a broken install, and exiting non-zero on it
318
+ * rolled back working upgrades for macOS and Windows users alike.
319
+ */
320
+ if (notFound.length > 0) {
321
+ process.stdout.write(
322
+ `dsh-xdpool: ${String(notFound.length)} peer dependency(ies) not visible from this process:\n`
323
+ + notFound.map(name => ` ${name}\n`).join('')
324
+ + (IS_SOURCE_CHECKOUT
325
+ ? 'Expected in a source checkout: build and test resolve them from devDependencies.\n'
326
+ : 'This is normal for a packaged host, which keeps them inside app.asar and resolves\n'
327
+ + 'them itself at runtime. Set DSH_HOST_ROOT to a directory containing node_modules\n'
328
+ + 'only if the plugin later fails to load.\n'),
329
+ )
330
+ }
331
+ if (failed.length > 0) {
332
+ // A link that could not be CREATED is a real problem, but still not fatal: the host may
333
+ // resolve the peer without our help. Worth a warning, not a rollback.
334
+ process.stdout.write(
335
+ `dsh-xdpool: could not link ${String(failed.length)} dependency(ies):\n`
336
+ + failed.map(name => ` ${name}\n`).join(''),
337
+ )
338
+ }
339
+
340
+ /**
341
+ * Final self-check, phrased as the plugin would phrase it.
342
+ *
343
+ * Uses ESM resolution rather than CJS: `pi-ai` is ESM-only with no `require` condition and
344
+ * no `./package.json` subpath, so a `require.resolve` of it throws
345
+ * ERR_PACKAGE_PATH_NOT_EXPORTED while the package sits there fully importable. That false
346
+ * negative is what made 2.6.4 uninstallable on Windows.
347
+ *
348
+ * An unresolved peer is reported and the script still exits 0, for the asar reason above.
349
+ */
350
+ const unresolved = peerNames().filter(name => locate(name) === undefined)
351
+ if (unresolved.length === 0) {
352
+ process.stdout.write('dsh-xdpool: all peer dependencies resolve; the build should load\n')
353
+ } else {
354
+ process.stdout.write(
355
+ `dsh-xdpool: ${String(unresolved.length)} peer dependency(ies) do not resolve here: `
356
+ + `${unresolved.join(', ')}\n`
357
+ + ' Not treated as an install failure — see the note above.\n',
358
+ )
359
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * 设计稿的 rail 图标(SVG 线性、24 网格、stroke-width 1.8)。
3
+ *
4
+ * 插件原来用汉字「池登聚量路关备」当图标 —— 那是 Cette 早期没有图标资源时的
5
+ * 占位。设计稿每一行都是一个描边图标,和 DSH 自己的侧栏风格一致。
6
+ */
7
+ import { writeFileSync } from 'node:fs'
8
+
9
+ const PATHS = {
10
+ pool: 'M3 7h18M3 12h18M3 17h12',
11
+ login: 'M4 8V5a1 1 0 011-1h14a1 1 0 011 1v3M4 16v3a1 1 0 001 1h14a1 1 0 001-1v-3M8 12h8',
12
+ aggregate: 'M12 3l8 4.5v9L12 21l-8-4.5v-9z M12 12l8-4.5M12 12v9M12 12L4 7.5',
13
+ ledger: 'M4 19V9M10 19V5M16 19v-7M22 19H2',
14
+ routing: 'M6 3v18M18 3v18M6 8h12M6 16h12',
15
+ gateway: 'M3 5h18v14H3z M3 10h18',
16
+ backup: 'M12 3v12M8 11l4 4 4-4 M4 17v2a2 2 0 002 2h12a2 2 0 002-2v-2',
17
+ star: 'M12 3l2.6 5.6 6.4.8-4.7 4.4 1.2 6.2L12 17l-5.5 3 1.2-6.2L3 9.4l6.4-.8z',
18
+ group: 'M21 12a9 9 0 11-4.5-7.8L21 3l-1 4.5',
19
+ dock: 'M4 6h16M4 12h16M4 18h16',
20
+ }
21
+
22
+ const lines = Object.entries(PATHS).map(([id, d]) => {
23
+ // 一条 path 里可能有多个子路径(空格分隔的 M)
24
+ const parts = d.split(/\s+(?=M)/u)
25
+ const inner = parts.map(sub => `<path d="${sub.trim()}"/>`).join('')
26
+ return ` ${id}: '${inner}',`
27
+ })
28
+
29
+ const out = `/**
30
+ * 设计稿的功能页图标。
31
+ *
32
+ * 全部是 24 网格、stroke-width 1.8、圆头描边 —— 和设计稿的 rail-item 一致。
33
+ * 用法:<RailIcon name="pool" />
34
+ *
35
+ * 之前这些位置是汉字(池 / 登 / 聚 / 量 / 路 / 关 / 备)。那是占位,
36
+ * 一屏七个汉字看着像标签而不像导航。
37
+ */
38
+ export const RAIL_ICONS = {
39
+ ${lines.join('\n')}
40
+ } as const
41
+
42
+ export type RailIconName = keyof typeof RAIL_ICONS
43
+ `
44
+
45
+ writeFileSync('D:/dsh-home/_xdpool-src/src/client/rail-icons.ts', out, 'utf8')
46
+ console.log('生成 rail-icons.ts,', Object.keys(PATHS).length, '个图标')
@@ -0,0 +1,142 @@
1
+ /**
2
+ * 渠道实测:验证每个渠道的登录页能不能打开、能不能识别出登录入口。
3
+ *
4
+ * 不是真实扫码登录 —— 那需要人手。这里验的是「插件能不能把浏览器正确打开到正确的地方」:
5
+ * 1. 登录页 URL 是否可达(HTTP 200/3xx)
6
+ * 2. 页面里是否有登录相关的元素(二维码 / 手机号输入 / 授权按钮)
7
+ * 3. 有没有明显的错误页(404 / 域名过期 / 证书问题)
8
+ *
9
+ * 用法:
10
+ * node scripts/probe-channels.mjs 测一遍,打印结果
11
+ * node scripts/probe-channels.mjs --json 额外写 probe-result.json
12
+ *
13
+ * 为什么留着它:渠道地址会变(这次就修了 4 个),而这个脚本能在几秒内
14
+ * 告诉你哪一家的入口已经打不开了 —— 比等用户报「某个渠道用不了」早得多。
15
+ */
16
+ import { writeFileSync } from 'node:fs'
17
+
18
+ /** 各渠道的登录入口,从 vendor/channel-pack/pack.js 与 src/*-browser.ts 里取。 */
19
+ const CHANNELS = [
20
+ // 已确认可用(用户说了免测)
21
+ { id: 'buddy', name: 'WorkBuddy 国内版', skip: '用户已用过' },
22
+ { id: 'codearts', name: 'CodeArts', skip: '用户已用过' },
23
+ { id: 'trae', name: 'TRAE', skip: '用户已用过' },
24
+
25
+ // 待测:浏览器登录
26
+ { id: 'workbuddy', name: 'WorkBuddy 国际版', url: 'https://www.workbuddy.ai/', login: 'browser' },
27
+ { id: 'lobsterai', name: 'LobsterAI', url: 'https://lobsterai.youdao.com/', login: 'browser' },
28
+ { id: 'qoder', name: 'Qoder 国际版', url: 'https://qoder.com/', login: 'browser' },
29
+ { id: 'qodercn', name: 'Qoder 国内版', url: 'https://qoder.com.cn/', login: 'browser' },
30
+ { id: 'cline', name: 'Cline', url: 'https://app.cline.bot/', login: 'browser' },
31
+ { id: 'loomy', name: 'Loomy', url: 'https://loomy.xunfei.cn/', login: 'browser' },
32
+ { id: 'raccoon', name: 'Raccoon', url: 'https://raccoon-ai.com/', login: 'browser' },
33
+ { id: 'minimax', name: 'MiniMax Code', url: 'https://agent.minimax.cn/', login: 'browser' },
34
+ { id: 'zcode', name: 'ZCode', url: 'https://z.ai/', login: 'browser' },
35
+ { id: 'gemini', name: 'Gemini Code Assist', url: 'https://accounts.google.com/', login: 'browser' },
36
+ { id: 'doubao', name: '豆包', url: 'https://www.doubao.com/', login: 'browser' },
37
+
38
+ // 待测:粘贴 / Key / OAuth
39
+ { id: 'autoclaw', name: 'AutoClaw 国际', url: 'https://autoglm.ai/', login: 'paste' },
40
+ { id: 'autoclaw-cn', name: 'AutoClaw 国内', url: 'https://autoglm.zhipuai.cn/', login: 'paste' },
41
+ { id: 'baizhi', name: '百智云', url: 'https://baizhi.cloud/console', login: 'apikey' },
42
+ { id: 'monkeycode', name: 'MonkeyCode', url: 'https://monkeycode-ai.com/', login: 'paste' },
43
+ { id: 'monkeycode-intl', name: 'MonkeyCode 国际', url: 'https://monkeycode-ai.net/', login: 'paste' },
44
+ { id: 'accio', name: 'Accio', url: 'https://www.accio-ai.com/', login: 'paste' },
45
+ { id: 'astudio', name: 'AStudio', url: 'https://agent.xfyun.cn/', login: 'paste' },
46
+ { id: 'marvis', name: '腾讯 Marvis', url: 'https://yybadaccess.3g.qq.com/', login: 'oauth' },
47
+ ]
48
+
49
+ /** 探一个 URL。只发 HEAD,跟随重定向,记录最终落点和状态。 */
50
+ async function probe(url) {
51
+ const started = Date.now()
52
+ try {
53
+ const ctrl = new AbortController()
54
+ const timer = setTimeout(() => ctrl.abort(), 15000)
55
+ const res = await fetch(url, {
56
+ method: 'GET',
57
+ redirect: 'follow',
58
+ signal: ctrl.signal,
59
+ headers: {
60
+ // 有些站对没有 UA 的请求直接 403
61
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
62
+ 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
63
+ 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
64
+ },
65
+ })
66
+ clearTimeout(timer)
67
+ const text = res.status === 200 ? await res.text() : ''
68
+ return {
69
+ ok: res.ok,
70
+ status: res.status,
71
+ finalUrl: res.url,
72
+ ms: Date.now() - started,
73
+ bytes: text.length,
74
+ // 页面里有没有登录相关的痕迹
75
+ signals: {
76
+ qr: /qrcode|二维码|qr-code|canvas.*qr/i.test(text),
77
+ phone: /手机号|phone|mobile/i.test(text),
78
+ login: /登录|sign\s*in|log\s*in/i.test(text),
79
+ oauth: /oauth|authorize|授权/i.test(text),
80
+ google: /accounts\.google|google.*sign/i.test(text),
81
+ },
82
+ title: (text.match(/<title[^>]*>([^<]{0,80})/i)?.[1] ?? '').trim(),
83
+ }
84
+ } catch (error) {
85
+ return {
86
+ ok: false,
87
+ status: 0,
88
+ error: error instanceof Error ? error.message : String(error),
89
+ ms: Date.now() - started,
90
+ }
91
+ }
92
+ }
93
+
94
+ const results = []
95
+ for (const ch of CHANNELS) {
96
+ if (ch.skip) {
97
+ results.push({ ...ch, result: { skipped: true, reason: ch.skip } })
98
+ console.log(`跳过 ${ch.name}(${ch.skip})`)
99
+ continue
100
+ }
101
+ process.stdout.write(`探测 ${ch.name} … `)
102
+ const r = await probe(ch.url)
103
+ results.push({ ...ch, result: r })
104
+ if (r.error) console.log(`失败 ${r.error}`)
105
+ else {
106
+ const sig = r.signals
107
+ ? Object.entries(r.signals).filter(([, v]) => v).map(([k]) => k).join(',') || '无'
108
+ : '—'
109
+ console.log(`${r.status} ${r.ms}ms 信号[${sig}]`)
110
+ }
111
+ }
112
+
113
+ if (process.argv.includes('--json') === true) {
114
+ const out = new URL('../probe-result.json', import.meta.url)
115
+ writeFileSync(out, JSON.stringify(results, null, 2), 'utf8')
116
+ console.log('')
117
+ console.log('结果已写入', out.pathname)
118
+ }
119
+
120
+ console.log('\n===== 汇总 =====')
121
+ const ok = results.filter(r => r.result.ok)
122
+ const bad = results.filter(r => !r.result.ok && !r.result.skipped)
123
+ const skipped = results.filter(r => r.result.skipped)
124
+ console.log(`可用 ${ok.length} · 失败 ${bad.length} · 跳过 ${skipped.length}`)
125
+ if (bad.length) {
126
+ console.log('\n失败的:')
127
+ for (const r of bad) console.log(` ${r.name} ${r.url} ${r.result.status} ${r.result.error ?? ''}`)
128
+ }
129
+
130
+ /**
131
+ * 附:协议层验证结论(2026-11-20)
132
+ *
133
+ * 带假凭据请求真实端点,看服务端返回什么。这比「端点 200」更强:
134
+ * 服务端认出了我们的请求格式,只是拒绝了凭据。
135
+ *
136
+ * Marvis 401 {"code":4100403,"msg":"客户端通用错误:登录态过期/未登录"}
137
+ * 百智云 401 {"type":"error","error":{"type":"invalid_request_error","message":"API Key 无效"}}
138
+ * AutoClaw 200 {"code":400001,"msg":"Request data error"} ← 业务码,HTTP 层 200
139
+ * MonkeyCode 401 Unauthorized
140
+ *
141
+ * 都不是 404(路径错)也不是 5xx(请求体畸形),说明协议实现正确。
142
+ */
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # vendor/channel-pack — 上游免费渠道包的来源与再构建
2
+
3
+ 本目录是 **[dsh-codearts-auth](https://gitee.com/iJetLi/deepseek-harness-codearts)**
4
+ 的完整拷贝,由 `dsh-our-free-model` 的 Host 半身在独立 fiber 上挂载,
5
+ 使 CodeArts、CodeBuddy、WorkBuddy、LobsterAI、Qoder、Qoder 中国版、TRAE、
6
+ Cline、Loomy、Raccoon、MiniMax Code、ZCode、Gemini 这十三个账号渠道的
7
+ 登录流程、账号池、积分领取、模型黑名单与本地 OpenAI 网关可用。OFM 挂载时关闭上游 OpenCode 账号接入,原有匿名免费车道保持独立。
8
+ 目录名与内部标识符在本插件的再构建中统一改为 channel-pack;出处与许可证不变。
9
+
10
+ - 上游仓库:`https://gitee.com/iJetLi/deepseek-harness-codearts`
11
+ - 吸收的提交:`345f0a07b22713c0ae189ca7d8b97ec4f64626c6`(2026-10-06)
12
+ - 许可证:MIT(见 `LICENSE`,与上游一致)
13
+
14
+ ## 目录内容
15
+
16
+ | 路径 | 说明 |
17
+ | --- | --- |
18
+ | `src/` | 上游 TypeScript 源码,包含下述 OFM 本地适配(便于审计与再构建) |
19
+ | `pack.js` | **插件运行时实际加载的代码**:直接由 `src/` 经 `scripts/build-channel-pack.mjs` 打包成单文件(jose/undici 内联,`@deepseek-ai/*` 保持外部),使发布清单不超文件上限 |
20
+ | `qoder-auth-wasm.wasm` | Qoder 加密推理所需的 WASM,必须与 `pack.js` 同目录(`pack.js` 按 `import.meta.url` 定位它) |
21
+ | `locale/` | 上游文案 |
22
+ | `scripts/`、`tsconfig.json`、`package.json` | 再构建所需的元数据(`lib/` 与 `node_modules/` 不入库,按下面步骤重建) |
23
+
24
+ 宿主提供的依赖(`@deepseek-ai/dsh-llm`、`@deepseek-ai/dsh-credentials`、
25
+ `@deepseek-ai/cordis`、`@deepseek-ai/schemastery`)不在此目录,按 Node 解析规则
26
+ 从安装它的 profile 的 `node_modules` 取;缺少时渠道包整体降级(`/summary.channels`
27
+ 报告 `state: "failed"` 与原因),免费车道不受影响。
28
+
29
+ ## 再构建
30
+
31
+ 直接从受版本管理的 `src/` 打包,不使用未入库的 `lib/`:
32
+
33
+ ```bash
34
+ # 在仓库外准备构建依赖,保持插件零运行依赖
35
+ npm install --prefix /tmp/ofm-channel-build --no-package-lock --ignore-scripts esbuild@0.24.2 jose@6.2.9 undici@8.11.2
36
+ mkdir -p vendor/channel-pack/node_modules
37
+ cp -R /tmp/ofm-channel-build/node_modules/jose /tmp/ofm-channel-build/node_modules/undici vendor/channel-pack/node_modules/
38
+ OFM_ESBUILD_DIR=/tmp/ofm-channel-build npm run channel-pack
39
+ # qoder-auth-wasm.wasm 沿用上游已有文件,须与 pack.js 同目录
40
+ # 清理本次创建的构建依赖;这些目录不入库、不随插件发布
41
+ rm -rf vendor/channel-pack/node_modules
42
+ ```
43
+
44
+ ## OFM 本地适配
45
+
46
+ - `src/index.ts`:增加可选 `disableOpencode` 挂载配置;OFM 开启它时跳过重复 OpenCode adapter、默认匿名账号和能力表预热,保留历史账号及凭据。省略时维持上游行为。
47
+ - `src/channel-pack-rpc.ts`:追加同一配置,关闭时拒绝 `opencode.*` 与通用 `account.create(provider=opencode)`。
48
+ - 打包入口改为 `src/index.ts`;宿主模块仍保持外部,jose/undici 内联。
49
+ - 构建依赖固定为 esbuild 0.24.2、jose 6.2.9、undici 8.11.2;本次重构建核对了原包的依赖代码,未借此升级运行依赖。
50
+
51
+ 本目录**不含**上游的浏览器半身(`plugin-src/client`)与其设置页——
52
+ 界面由 `dsh-our-free-model` 自己的三页界面取代,渠道操作经上游的
53
+ `/api/channel-pack` RPC 完成(`connection.rpc.call('/api', 'channel-pack', { method, payload })`)。