dsh-volcengine-provider 0.2.0 → 0.2.1
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/changelog.md +7 -0
- package/docs/development.md +1 -1
- package/docs/validation.md +11 -3
- package/lib/catalog.mjs +18 -5
- package/lib/client.js +2 -2
- package/lib/manager.mjs +1 -1
- package/lib/state.mjs +12 -4
- package/package.json +2 -2
package/docs/changelog.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
[返回主页](../README.md)
|
|
4
4
|
|
|
5
|
+
## 0.2.1
|
|
6
|
+
|
|
7
|
+
- 修复前端工厂导出协议不兼容导致 DSH 启动失败的问题。
|
|
8
|
+
- 测试与浏览器验证使用宿主真实的单参数加载方式;构建在测试之前执行,构建产物验证不再跳过。
|
|
9
|
+
- 损坏的模型目录行显示为缓存错误,设置页仍可打开并刷新修复。
|
|
10
|
+
- 取消登录会中止尚未提交的账号绑定写入,并清理临时文件。
|
|
11
|
+
|
|
5
12
|
## 0.2.0
|
|
6
13
|
|
|
7
14
|
- 插件显示名、设置页与文档标题采用「火山方舟 Provider」,保留技术包名 `dsh-volcengine-provider` 和内部标识。
|
package/docs/development.md
CHANGED
|
@@ -8,9 +8,9 @@ Node.js >=22.19.0;打包使用 Python >=3.9 标准库。
|
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
node scripts/check.mjs
|
|
11
|
+
node scripts/build.mjs
|
|
11
12
|
node --test test/*.test.mjs
|
|
12
13
|
python -m unittest discover -s test -p 'test_*.py'
|
|
13
|
-
node scripts/build.mjs
|
|
14
14
|
python scripts/pack.py --output-dir test-output/local-package
|
|
15
15
|
python scripts/verify-package.py test-output/local-package
|
|
16
16
|
```
|
package/docs/validation.md
CHANGED
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
node scripts/check.mjs
|
|
15
|
-
node --test test/*.test.mjs
|
|
16
15
|
node scripts/build.mjs
|
|
16
|
+
node --test test/*.test.mjs
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
- JavaScript 语法、manifest 基本字段和前后端依赖边界检查。
|
|
20
20
|
- 账号、双订阅隔离、revision 冲突、目录字段/能力、缓存、签名向量、额度错误/单位、OAuth 生命周期、设置页交互及授权 URL 白名单。
|
|
21
21
|
- HMAC 签名测试使用独立 OpenSSL 推导的固定向量,不只比较实现自身的两次输出。
|
|
22
|
-
- 构建生成 Host
|
|
22
|
+
- 构建生成 Host 模块与返回导出对象的惰性 Client 工厂;不新增安装构建依赖。
|
|
23
23
|
|
|
24
|
-
当前结果:**
|
|
24
|
+
当前结果:**210 项 JavaScript 单元测试、7 项归档测试全部通过**,31 个 JavaScript 源文件语法/边界检查通过,构建生成 12 个运行产物。模型管理测试覆盖旧状态迁移、套餐/模型开关、逐模型参数、请求默认值及适配器生命周期;发布测试覆盖 OIDC 身份、版本与渠道、归档校验、registry 错误分类及发布后完整性检查。
|
|
25
25
|
|
|
26
26
|
### 实际 Core 隔离加载
|
|
27
27
|
|
|
@@ -73,3 +73,11 @@ node scripts/build.mjs
|
|
|
73
73
|
4. 实际 OAuth 页面与回调地址由官方 CLI 生成,随 CLI 版本而定。
|
|
74
74
|
|
|
75
75
|
具体命令依据见[接口文档](arkcli-contract.md)。
|
|
76
|
+
|
|
77
|
+
## 0.2.1 修复验证
|
|
78
|
+
|
|
79
|
+
- 单参数 factory(require) 加载实际构建产物,未提供虚假的 CommonJS 参数。
|
|
80
|
+
- 覆盖空模型行、非法/重复 ID 和保留名称;坏缓存返回 invalid-cache,正常套餐不受影响。
|
|
81
|
+
- 取消排队中的状态写入与登录绑定后,元数据未落盘、模型路由未更新,后续保存仍可执行。
|
|
82
|
+
- 临时写入接受 AbortSignal,并在原子替换前再次检查取消状态;已完成的原子提交不会因后续取消而回滚。
|
|
83
|
+
- 本机 DSH Desktop 0.2.1-rc.3 已在安装入口修复后实际启动到主界面。
|
package/lib/catalog.mjs
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { assertPlan, LABELS, ROUTES } from './state.mjs';
|
|
2
|
+
import { assertModelId, assertPlan, LABELS, ROUTES } from './state.mjs';
|
|
3
3
|
export const snapshot = JSON.parse(await readFile(new URL('./catalog-snapshot.json', import.meta.url), 'utf8'));
|
|
4
4
|
const modelId = /^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$/;
|
|
5
|
+
function validateModelRows(rows) {
|
|
6
|
+
if (!Array.isArray(rows) || rows.length > 1000) throw new Error('本地模型缓存格式错误');
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
for (const row of rows) {
|
|
9
|
+
if (!row || typeof row !== 'object' || Array.isArray(row)) throw new Error('本地模型缓存格式错误');
|
|
10
|
+
try { assertModelId(row.id); } catch { throw new Error('本地模型缓存包含非法 ID'); }
|
|
11
|
+
if (seen.has(row.id)) throw new Error('本地模型缓存包含重复 ID');
|
|
12
|
+
seen.add(row.id);
|
|
13
|
+
}
|
|
14
|
+
return rows;
|
|
15
|
+
}
|
|
5
16
|
export function normalizeCatalog(plan, response) {
|
|
6
17
|
assertPlan(plan);
|
|
7
18
|
if (response?.plan !== plan || !Array.isArray(response.models)) throw new Error('模型目录响应与所选订阅不匹配');
|
|
8
19
|
if (response.models.length > 1000) throw new Error('模型目录过大');
|
|
9
20
|
const seen = new Set();
|
|
10
21
|
const models = response.models.map(row => {
|
|
22
|
+
if (!row || typeof row !== 'object' || Array.isArray(row)) throw new Error('模型目录包含非法或重复 ID');
|
|
11
23
|
const id = row.output_name || row.model_id;
|
|
12
24
|
if (typeof id !== 'string' || !modelId.test(id) || seen.has(id)) throw new Error('模型目录包含非法或重复 ID');
|
|
25
|
+
try { assertModelId(id); } catch { throw new Error('模型目录包含非法或重复 ID'); }
|
|
13
26
|
seen.add(id);
|
|
14
27
|
const known = snapshot[plan].models.find(m => m.id === id || m.id === row.model_id);
|
|
15
28
|
return {
|
|
@@ -21,10 +34,9 @@ export function normalizeCatalog(plan, response) {
|
|
|
21
34
|
return { models, source: 'arkcli', updatedAt: new Date().toISOString() };
|
|
22
35
|
}
|
|
23
36
|
export function usableModels(catalog, plan) {
|
|
37
|
+
assertPlan(plan);
|
|
24
38
|
const rows = catalog === undefined || catalog === null ? snapshot[plan].models : catalog.models;
|
|
25
|
-
|
|
26
|
-
return rows.map(row => {
|
|
27
|
-
if (!modelId.test(row.id)) throw new Error('本地模型缓存包含非法 ID');
|
|
39
|
+
return validateModelRows(rows).map(row => {
|
|
28
40
|
const { capabilityUnverified: _unverified, ...model } = row;
|
|
29
41
|
return model;
|
|
30
42
|
});
|
|
@@ -83,7 +95,8 @@ export function catalogStatus(state, accountId, plan) {
|
|
|
83
95
|
if (cached === undefined || cached === null) {
|
|
84
96
|
return { rows: snapshot[plan].models.map(model => structuredClone(model)), count: snapshot[plan].models.length, source: 'local-snapshot' };
|
|
85
97
|
}
|
|
86
|
-
|
|
98
|
+
try { validateModelRows(cached.models); }
|
|
99
|
+
catch { return { rows: [], count: 0, source: 'invalid-cache', broken: true }; }
|
|
87
100
|
return { rows: cached.models.map(model => structuredClone(model)), count: cached.models.length, source: cached.source ?? 'arkcli', ...(cached.updatedAt ? { updatedAt: cached.updatedAt } : {}) };
|
|
88
101
|
}
|
|
89
102
|
|
package/lib/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:'dsh-volcengine-provider',factory:(require
|
|
1
|
+
window.__ModuleLoader__.load({id:'dsh-volcengine-provider',factory:(require)=>{
|
|
2
2
|
'use strict';
|
|
3
3
|
const PLUGIN_NAME = 'dsh-volcengine-provider';
|
|
4
4
|
function wireCodec(type, parse) {
|
|
@@ -1556,5 +1556,5 @@ function apply(ctx) {
|
|
|
1556
1556
|
const name = 'dsh-volcengine-provider';
|
|
1557
1557
|
const inject = ['slots', 'remote'];
|
|
1558
1558
|
|
|
1559
|
-
|
|
1559
|
+
return {name,inject,apply};
|
|
1560
1560
|
}});
|
package/lib/manager.mjs
CHANGED
|
@@ -112,7 +112,7 @@ export class ArkController {
|
|
|
112
112
|
if (identity?.logged_in !== true) throw new Error('CLI 未确认 OAuth 登录身份');
|
|
113
113
|
const profiles = planProfiles(await cli.status(signal));
|
|
114
114
|
if (signal.aborted || this.disposed) throw new Error('登录已取消');
|
|
115
|
-
await this.store.mutate(rev, next => { next.oauth[id] = { profiles, loggedAt: new Date().toISOString() }; return next; });
|
|
115
|
+
await this.store.mutate(rev, next => { next.oauth[id] = { profiles, loggedAt: new Date().toISOString() }; return next; }, { signal });
|
|
116
116
|
this.clearCaches();
|
|
117
117
|
await this.onChange();
|
|
118
118
|
}
|
package/lib/state.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { mkdir, readFile, writeFile, rename } from 'node:fs/promises';
|
|
2
|
+
import { mkdir, readFile, writeFile, rename, rm } from 'node:fs/promises';
|
|
3
3
|
import { dirname } from 'node:path';
|
|
4
4
|
|
|
5
5
|
export const STATE_VERSION = 2;
|
|
@@ -208,14 +208,22 @@ export class StateStore {
|
|
|
208
208
|
catch (error) { if (error.code !== 'ENOENT') throw new Error('无法读取方舟账号状态;原文件未被覆盖'); this.current = initialState(); }
|
|
209
209
|
return this.current;
|
|
210
210
|
}
|
|
211
|
-
mutate(expectedRevision, change) {
|
|
211
|
+
mutate(expectedRevision, change, { signal } = {}) {
|
|
212
212
|
const operation = this.queue.then(async () => {
|
|
213
|
+
signal?.throwIfAborted();
|
|
213
214
|
if (expectedRevision !== revision(this.current)) throw new Error('设置已改变,请刷新后重试');
|
|
214
215
|
const next = validateState(change(structuredClone(this.current)));
|
|
215
216
|
await mkdir(dirname(this.path), { recursive: true });
|
|
217
|
+
signal?.throwIfAborted();
|
|
216
218
|
const temp = `${this.path}.${process.pid}.tmp`;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
try {
|
|
220
|
+
await writeFile(temp, JSON.stringify(next, null, 2) + '\n', { mode: 0o600, signal });
|
|
221
|
+
signal?.throwIfAborted();
|
|
222
|
+
await rename(temp, this.path);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
await rm(temp, { force: true }).catch(() => {});
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
219
227
|
this.current = next;
|
|
220
228
|
return next;
|
|
221
229
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-volcengine-provider",
|
|
3
3
|
"displayName": "火山方舟 Provider",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"description": "火山方舟 Agent Plan 与 Coding Plan:OAuth 登录、账号、模型与额度管理。",
|
|
6
6
|
"repository": {"type": "git", "url": "git+https://github.com/KouzakiUmi/dsh-volcengine-provider.git"},
|
|
7
7
|
"homepage": "https://github.com/KouzakiUmi/dsh-volcengine-provider#readme",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"publishConfig": {"access": "public", "registry": "https://registry.npmjs.org/"},
|
|
16
16
|
"engines": {"node": ">=22.19.0"},
|
|
17
|
-
"scripts": {"build": "node scripts/build.mjs", "test": "node --test test/*.test.mjs", "check": "node scripts/check.mjs && node
|
|
17
|
+
"scripts": {"build": "node scripts/build.mjs", "test": "node scripts/build.mjs && node --test test/*.test.mjs", "check": "node scripts/check.mjs && node scripts/build.mjs && node --test test/*.test.mjs"},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@deepseek-ai/cordis": "^4.0.5",
|
|
20
20
|
"@deepseek-ai/schemastery": "^3.18.4",
|