heybash-xdpool 1.0.3 → 1.0.4
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/CHANGELOG.md +5 -0
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/lib/client.js +1 -1
- package/lib/index.js +3 -3
- package/package.json +4 -2
- package/tools/sync-npmmirror.mjs +132 -0
- package/vendor/channel-pack/pack.js +8 -1
- package/vendor/channel-pack/pool-model-dedupe.js +16 -0
package/CHANGELOG.md
CHANGED
package/README.en.md
CHANGED
|
@@ -112,7 +112,7 @@ After editing source, rebuild and update the installed plugin, then fully quit a
|
|
|
112
112
|
|
|
113
113
|
The package does not run a dependency-linking script during installation. DeepSeek Harness normally supplies the shared dependencies; if a particular environment cannot resolve them, run `node scripts/link-host-peers.mjs` manually from the installed package to troubleshoot.
|
|
114
114
|
|
|
115
|
-
The account pools appear as **
|
|
115
|
+
The account pools appear as **WorkBuddy 国内版** and **WorkBuddy 国际版**; the optional free-model group is **Heybash · 免费模型**. Channel models already offered by the same regional pool are shown once; existing channel routes remain available to saved conversations.
|
|
116
116
|
|
|
117
117
|
## Upgrading from an older version
|
|
118
118
|
|
package/README.md
CHANGED
|
@@ -115,7 +115,7 @@ dsh plugin --profile desktop add "file:/你的项目路径/dsh-xdpool-fork"
|
|
|
115
115
|
|
|
116
116
|
安装包不自动执行依赖链接脚本。通常由 DeepSeek Harness 提供插件所需的共享依赖;如特殊环境出现依赖无法解析,可手动运行安装目录下的 `node scripts/link-host-peers.mjs` 进行排查。
|
|
117
117
|
|
|
118
|
-
模型选择器中的账号池分别显示为 **
|
|
118
|
+
模型选择器中的账号池分别显示为 **WorkBuddy 国内版**、**WorkBuddy 国际版**,免费模型分组显示为 **Heybash · 免费模型**。同一区域中与账号池重复的渠道模型只展示一次,原有渠道标识仍可用于已有会话。
|
|
119
119
|
|
|
120
120
|
## 从旧版升级
|
|
121
121
|
|
package/lib/client.js
CHANGED
|
@@ -13294,7 +13294,7 @@ window.__ModuleLoader__.load({
|
|
|
13294
13294
|
}
|
|
13295
13295
|
// src/version.ts
|
|
13296
13296
|
/** Version embedded in the browser bundle at build time from the package manifest. */
|
|
13297
|
-
const POOL_VERSION = "1.0.
|
|
13297
|
+
const POOL_VERSION = "1.0.4";
|
|
13298
13298
|
// src/client/PoolCard.tsx
|
|
13299
13299
|
/**
|
|
13300
13300
|
* Heybash card contributed to DSH Plugin configuration.
|
package/lib/index.js
CHANGED
|
@@ -13232,14 +13232,14 @@ const POOL_PROVIDER_BY_REGION = {
|
|
|
13232
13232
|
/**
|
|
13233
13233
|
* Display name each region registers under, so the picker can group them.
|
|
13234
13234
|
*
|
|
13235
|
-
* The regional suffix distinguishes the two
|
|
13235
|
+
* The regional suffix distinguishes the two WorkBuddy account pools.
|
|
13236
13236
|
*
|
|
13237
13237
|
* Display name only. The provider ids above are what the host matches on when it
|
|
13238
13238
|
* persists a selection, so renaming a group must never touch them.
|
|
13239
13239
|
*/
|
|
13240
13240
|
const POOL_NAME_BY_REGION = {
|
|
13241
|
-
cn: "
|
|
13242
|
-
global: "
|
|
13241
|
+
cn: "WorkBuddy 国内版",
|
|
13242
|
+
global: "WorkBuddy 国际版"
|
|
13243
13243
|
};
|
|
13244
13244
|
/** Provider idle ceiling while one stream read is outstanding. */
|
|
13245
13245
|
const WORKBUDDY_STREAM_IDLE_TIMEOUT_MS = 3e5;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "heybash-xdpool",
|
|
3
3
|
"displayName": "Heybash",
|
|
4
4
|
"description": "Heybash model pool for DeepSeek Harness: account rotation, provider aggregation, routing chains, usage insights and a local OpenAI-compatible gateway.",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.4",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Heybash",
|
|
8
8
|
"contributors": [
|
|
@@ -55,11 +55,13 @@
|
|
|
55
55
|
"README.en.md",
|
|
56
56
|
"CHANGELOG.md",
|
|
57
57
|
"LICENSE",
|
|
58
|
-
"scripts"
|
|
58
|
+
"scripts",
|
|
59
|
+
"tools/sync-npmmirror.mjs"
|
|
59
60
|
],
|
|
60
61
|
"scripts": {
|
|
61
62
|
"build": "tsdown",
|
|
62
63
|
"prepublishOnly": "tsdown",
|
|
64
|
+
"postpublish": "node tools/sync-npmmirror.mjs --published",
|
|
63
65
|
"test": "vitest run",
|
|
64
66
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
65
67
|
"typecheck:client": "tsc -p tsconfig.client.json --noEmit"
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Synchronize the public package after npm has made the requested version available. */
|
|
3
|
+
import { pathToFileURL } from 'node:url'
|
|
4
|
+
import { createHash } from 'node:crypto'
|
|
5
|
+
|
|
6
|
+
const NAME = 'heybash-xdpool'
|
|
7
|
+
const NPM = `https://registry.npmjs.org/${NAME}`
|
|
8
|
+
const MIRROR = `https://registry.npmmirror.com/${NAME}`
|
|
9
|
+
const SYNC = `https://registry.npmmirror.com/-/package/${NAME}/syncs`
|
|
10
|
+
const VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u
|
|
11
|
+
const TASK_ID = /^[0-9A-Za-z_-]+$/u
|
|
12
|
+
const MAX_TARBALL_BYTES = 64 * 1024 * 1024
|
|
13
|
+
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms))
|
|
14
|
+
|
|
15
|
+
async function request(fetchImpl, url, init = {}) {
|
|
16
|
+
const response = await fetchImpl(url, {
|
|
17
|
+
...init,
|
|
18
|
+
signal: AbortSignal.timeout(15_000),
|
|
19
|
+
})
|
|
20
|
+
if (!response.ok) throw new Error(`${init.method ?? 'GET'} ${new URL(url).hostname}: HTTP ${response.status}`)
|
|
21
|
+
return response
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function retry(label, action, { attempts, intervalMs, sleep, log }) {
|
|
25
|
+
let lastError
|
|
26
|
+
for (let i = 0; i < attempts; i++) {
|
|
27
|
+
try { return await action() } catch (error) {
|
|
28
|
+
lastError = error
|
|
29
|
+
log(`${label} (${i + 1}/${attempts}): ${error instanceof Error ? error.message : String(error)}`)
|
|
30
|
+
if (error?.terminal === true) throw error
|
|
31
|
+
if (i + 1 < attempts) await sleep(intervalMs)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
throw new Error(`${label} failed after ${attempts} attempts: ${lastError instanceof Error ? lastError.message : String(lastError)}`)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Poll the real public registry endpoints without credentials. A matching
|
|
39
|
+
* version, checksum, latest tag and reachable tarball are all required before
|
|
40
|
+
* reporting success. `version` absent means the current official latest.
|
|
41
|
+
*/
|
|
42
|
+
export async function syncMirror({
|
|
43
|
+
version, fetchImpl = fetch, sleep = delay, log = console.log,
|
|
44
|
+
attempts = 24, intervalMs = 10_000, syncAttempts = 3,
|
|
45
|
+
} = {}) {
|
|
46
|
+
if (version !== undefined && !VERSION.test(version)) throw new Error('Invalid target version')
|
|
47
|
+
const options = { attempts, intervalMs, sleep, log }
|
|
48
|
+
const read = async (url) => (await request(fetchImpl, url)).json()
|
|
49
|
+
const official = await retry('Waiting for npm', async () => {
|
|
50
|
+
const data = await read(NPM)
|
|
51
|
+
const target = version ?? data['dist-tags']?.latest
|
|
52
|
+
if (typeof target !== 'string' || !VERSION.test(target)) throw new Error('npm has no valid target version')
|
|
53
|
+
const checksum = data.versions?.[target]?.dist?.shasum
|
|
54
|
+
if (typeof checksum !== 'string' || !/^[a-f0-9]{40}$/u.test(checksum)) throw new Error(`npm ${target} is not yet available with a checksum`)
|
|
55
|
+
return { target, checksum, latest: data['dist-tags']?.latest }
|
|
56
|
+
}, options)
|
|
57
|
+
log(`npm target ${official.target}; latest ${official.latest}`)
|
|
58
|
+
|
|
59
|
+
const verify = async (download = false) => {
|
|
60
|
+
const mirror = await read(MIRROR)
|
|
61
|
+
if (mirror.versions?.[official.target]?.dist?.shasum !== official.checksum) throw new Error(`mirror ${official.target} is missing or has a different checksum`)
|
|
62
|
+
if (official.latest === official.target && mirror['dist-tags']?.latest !== official.target) throw new Error(`mirror latest is not ${official.target}`)
|
|
63
|
+
const tarball = mirror.versions[official.target].dist.tarball
|
|
64
|
+
const expected = `https://registry.npmmirror.com/${NAME}/-/${NAME}-${official.target}.tgz`
|
|
65
|
+
if (tarball !== expected) throw new Error('mirror returned an unexpected tarball URL')
|
|
66
|
+
const artifact = await request(fetchImpl, tarball, { method: download ? 'GET' : 'HEAD' })
|
|
67
|
+
if (download) {
|
|
68
|
+
if (artifact.body === null) throw new Error('mirror tarball has no body')
|
|
69
|
+
const digest = createHash('sha1')
|
|
70
|
+
let bytes = 0
|
|
71
|
+
for await (const chunk of artifact.body) {
|
|
72
|
+
bytes += chunk.length
|
|
73
|
+
if (bytes > MAX_TARBALL_BYTES) throw new Error('mirror tarball exceeds size limit')
|
|
74
|
+
digest.update(chunk)
|
|
75
|
+
}
|
|
76
|
+
if (digest.digest('hex') !== official.checksum) throw new Error('mirror tarball checksum does not match npm')
|
|
77
|
+
}
|
|
78
|
+
return official.target
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const target = await verify()
|
|
83
|
+
log(`Mirror already serves ${target} with the correct checksum`)
|
|
84
|
+
return { version: target, synced: false }
|
|
85
|
+
} catch (error) {
|
|
86
|
+
log(`Mirror needs synchronization: ${error instanceof Error ? error.message : String(error)}`)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let lastError
|
|
90
|
+
for (let attempt = 0; attempt < syncAttempts; attempt++) {
|
|
91
|
+
try {
|
|
92
|
+
const task = await (await request(fetchImpl, SYNC, {
|
|
93
|
+
method: 'PUT', headers: { 'content-type': 'application/json' },
|
|
94
|
+
body: JSON.stringify({ skipDependencies: true }),
|
|
95
|
+
})).json()
|
|
96
|
+
if (task.ok !== true || typeof task.id !== 'string' || !TASK_ID.test(task.id)) throw new Error('mirror did not return a valid sync task')
|
|
97
|
+
log(`Mirror synchronization task ${task.id}`)
|
|
98
|
+
await retry('Waiting for mirror synchronization', async () => {
|
|
99
|
+
const status = await read(`${SYNC}/${task.id}`)
|
|
100
|
+
if (status.state === 'success') return
|
|
101
|
+
if (status.state === 'failed' || status.state === 'fail') {
|
|
102
|
+
throw Object.assign(new Error(`sync task ${status.state}`), { terminal: true })
|
|
103
|
+
}
|
|
104
|
+
throw new Error(`sync task ${String(status.state)}`)
|
|
105
|
+
}, options)
|
|
106
|
+
const target = await retry('Waiting for mirror availability', () => verify(true), options)
|
|
107
|
+
log(`Mirror serves ${target} with the correct checksum`)
|
|
108
|
+
return { version: target, synced: true }
|
|
109
|
+
} catch (error) {
|
|
110
|
+
lastError = error
|
|
111
|
+
log(`Mirror synchronization attempt ${attempt + 1}/${syncAttempts} failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
112
|
+
if (attempt + 1 < syncAttempts) await sleep(intervalMs)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
throw new Error(`Mirror synchronization failed: ${lastError instanceof Error ? lastError.message : String(lastError)}`)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
119
|
+
const args = process.argv.slice(2)
|
|
120
|
+
const published = args.length === 1 && args[0] === '--published'
|
|
121
|
+
const publishedVersion = published ? process.env.npm_package_version : undefined
|
|
122
|
+
if ((published && (publishedVersion === undefined || !VERSION.test(publishedVersion)))
|
|
123
|
+
|| (!published && args.length !== 0 && (args.length !== 2 || args[0] !== '--version'))) {
|
|
124
|
+
console.error('Usage: node tools/sync-npmmirror.mjs [--version X.Y.Z | --published (npm lifecycle only)]')
|
|
125
|
+
process.exitCode = 2
|
|
126
|
+
} else {
|
|
127
|
+
syncMirror(published ? { version: publishedVersion } : args.length === 2 ? { version: args[1] } : {}).catch(error => {
|
|
128
|
+
console.error(error instanceof Error ? error.message : String(error))
|
|
129
|
+
process.exitCode = 1
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// Generated by scripts/build-channel-pack.mjs —
|
|
1
|
+
// Generated by scripts/build-channel-pack.mjs — local compatibility patches are marked below.
|
|
2
|
+
import { withoutPoolDuplicates } from './pool-model-dedupe.js';
|
|
2
3
|
// Source: vendor/channel-pack/src (the absorbed free-channel pack; see NOTICE.md).
|
|
3
4
|
import { createRequire as __ofmCreateRequire } from 'node:module'
|
|
4
5
|
const require = __ofmCreateRequire(import.meta.url)
|
|
@@ -36226,6 +36227,12 @@ function positiveMaxTokens(value) {
|
|
|
36226
36227
|
function registerBuddyLlm(ctx, options) {
|
|
36227
36228
|
const product = options.product ?? CODEBUDDY;
|
|
36228
36229
|
const adapter = new BuddyAdapter(options);
|
|
36230
|
+
// [patch:workbuddy-picker-dedupe] Keep the historical provider callable while
|
|
36231
|
+
// hiding entries already listed by this region's WorkBuddy pool in the picker.
|
|
36232
|
+
const listChannelModels = adapter.listModels.bind(adapter);
|
|
36233
|
+
adapter.listModels = async (provider) => withoutPoolDuplicates(
|
|
36234
|
+
await listChannelModels(provider), product.id, (poolProvider) => ctx.llm.listModels(poolProvider)
|
|
36235
|
+
);
|
|
36229
36236
|
registerAdapterIdempotent(ctx.llm, [product.id], adapter);
|
|
36230
36237
|
return adapter;
|
|
36231
36238
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Hide only model IDs also offered by the corresponding WorkBuddy pool.
|
|
2
|
+
* The channel adapter itself stays registered so previously saved routes work.
|
|
3
|
+
* If the pool is unavailable, keep the original channel catalog intact.
|
|
4
|
+
*/
|
|
5
|
+
export async function withoutPoolDuplicates(rows, provider, listModels) {
|
|
6
|
+
const poolProvider = provider === 'buddy' ? 'xdpool'
|
|
7
|
+
: provider === 'workbuddy' ? 'xdpool-global' : undefined
|
|
8
|
+
if (poolProvider === undefined) return rows
|
|
9
|
+
try {
|
|
10
|
+
const poolRows = await listModels(poolProvider)
|
|
11
|
+
const ids = new Set(poolRows.map(row => row.id))
|
|
12
|
+
return rows.filter(row => !ids.has(row.id))
|
|
13
|
+
} catch {
|
|
14
|
+
return rows
|
|
15
|
+
}
|
|
16
|
+
}
|