dsh-cohub 0.4.11 → 0.5.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.md +52 -14
- package/cordis.patch.yml +2 -1
- package/lib/client.js +7 -771
- package/lib/index.js +20 -30
- package/package.json +30 -28
package/README.md
CHANGED
|
@@ -45,8 +45,7 @@ npm run build
|
|
|
45
45
|
# bun build src/index.ts --outdir lib --target node --format esm \
|
|
46
46
|
# --external @deepseek-ai/cordis --external @deepseek-ai/schemastery \
|
|
47
47
|
# --external @deepseek-ai/dsh-tools --external @deepseek-ai/dsh-system-prompt \
|
|
48
|
-
# --external @deepseek-ai/dsh-skill --external @deepseek-ai/dsh-home-paths
|
|
49
|
-
# --external @deepseek-ai/dsh-settings
|
|
48
|
+
# --external @deepseek-ai/dsh-skill --external @deepseek-ai/dsh-home-paths
|
|
50
49
|
# bun build src/co-cordis-plugin.ts --outdir lib --target node --format esm \
|
|
51
50
|
# --external @deepseek-ai/dsh-tools # co-cordis 专用插件(第 13 个技能)
|
|
52
51
|
# bun run scripts/build-client.js # src/client/index.js → lib/client.js
|
|
@@ -83,7 +82,7 @@ dsh plugin --profile web add <monorepo>/packages/dsh-cohub
|
|
|
83
82
|
config:
|
|
84
83
|
councillors: [] # 为空则不注册 council_session 工具
|
|
85
84
|
councilTimeoutMs: 180000
|
|
86
|
-
skills: [] # delegate
|
|
85
|
+
skills: [] # delegate 委派路由(DSH 0.2 起由设置页按 profile entry id 投影此 volatile 字段,实时生效)
|
|
87
86
|
```
|
|
88
87
|
|
|
89
88
|
**M4 启用 council**(councillors 非空时自动注册 council_session 工具):
|
|
@@ -144,15 +143,41 @@ dsh plugin --profile web add <monorepo>/packages/dsh-cohub
|
|
|
144
143
|
|
|
145
144
|
### settings 卡片
|
|
146
145
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
146
|
+
**DSH 0.2 起**:本插件不再注入自定义设置卡片——官方 0.2 移除了 `settingsScope` 服务与
|
|
147
|
+
`settings.plugin.item` slot,客户端模块(`src/client/index.js`)仅保留 locale 设置字典注册
|
|
148
|
+
(`npm run build:client` 产物经 `npm run test:client` 验证只声明/访问 locale 服务)。
|
|
149
|
+
官方设置页按活动 profile entry id 自动投影 Config 的 **volatile 字段**
|
|
150
|
+
(`SettingsForms.describe()` 从真实 Loader entry 的 `fiber.runtime.Config` 投影),
|
|
151
|
+
生成「CoHub」表单:12 个 skill 行 + 调度参数 + 委派重试(含停滞检测)+ 环境契约持久化——
|
|
152
|
+
即原自定义卡片覆盖的全部字段,由官方表单实时提交。本包 0.5.0 仅面向 DSH 0.2,
|
|
153
|
+
不支持 0.1,无旧卡片兼容分支。
|
|
154
|
+
|
|
155
|
+
官方表单提交后无需重启即生效:Config 的 `skills` / `schedule` / `delegateRetry` 是 `.volatile()` 字段,
|
|
156
|
+
官方设置页按**活动 profile entry id** 投影这些字段,改动经 `entry.update({config})` 写入 profile patch 后,
|
|
157
|
+
由 Loader 以 `loader/volatile-update` 提交到运行中的同一 Volatile 引用(无需重挂载);
|
|
158
|
+
插件每次 delegate 工具 execute 时 `get()` 当前快照,因此下一次工具调用即见更新,正在执行的一次使用起始快照。
|
|
159
|
+
`test/host-integration.ts` 用真实 Loader + `SettingsForms.describe()` 验证了这条链路(含提交后 describe 的 value 与 `config.get()` 一致)。
|
|
160
|
+
|
|
161
|
+
## DSH 0.2 兼容说明
|
|
162
|
+
|
|
163
|
+
本包自计划版本 0.5.0 起面向 **DSH 0.2.0-rc.2**(peer/dev 依赖已升 `0.2.0-rc.2`;`@deepseek-ai/cordis`
|
|
164
|
+
peer `^4.0.1` / `schemastery` peer `^3.18.1` 保持合法 range,测试 devDependencies **精确固定**
|
|
165
|
+
宿主实测 `4.0.4` / `3.18.4`——lock 解析到最新不代表宿主实测,以宿主为准):
|
|
166
|
+
|
|
167
|
+
- **0.1 的 settings namespace 机制已移除**:`installSettingsSection` / `settingsNamespace` 在
|
|
168
|
+
dsh-settings 0.2 已删除。本插件不再注册 `cohub` namespace,改为 Config 的三个动态字段标
|
|
169
|
+
`.volatile()`(见上节)。`settings.yaml` 的 `cohub.*` 段**不会被自动迁移**(旧 importer 是否
|
|
170
|
+
支持自定义 namespace 未证实,明确不触发),请通过设置页或 `cordis.patch.yml` 重新配置。
|
|
171
|
+
- **不兼容 DSH 0.1**:peer 依赖锁定 `^0.2.0-rc.2`,在 0.1 宿主上无法安装(npm 会拒绝 peer 冲突),
|
|
172
|
+
属预期行为。
|
|
173
|
+
- **验证入口**:`npm run test:runtime`(`test/runtime-0.2.ts`,真实 schemastery/Volatile/defineTool
|
|
174
|
+
契约 + 真实 cordis 挂载,离线 stub 子代理)、`npm run test:host`(`test/host-integration.ts`,
|
|
175
|
+
真实 Loader + entry.update volatile 提交 + SettingsForms.describe 投影 + 真实 subagents 服务
|
|
176
|
+
(正常/失败/capability/pre-aborted/运行中取消 + delegate 取消链) +
|
|
177
|
+
app-boot preflight 官方 helper)、`npm run typecheck:0.2`
|
|
178
|
+
(`test/types/runtime-0.2.ts`,strict 编译检查公共边界与真实 DSH 0.2 导出)。完整宿主链路
|
|
179
|
+
(真实 spawn/fork transport 的进程内实现、真实 LLM provider、preset 树真实挂载)由宿主集成验证覆盖,
|
|
180
|
+
单测不冒称完全覆盖。
|
|
156
181
|
|
|
157
182
|
### 环境契约持久化
|
|
158
183
|
|
|
@@ -262,6 +287,17 @@ cp presets/co-orchestrator/* ~/.dsh/.agent-presets/co-orchestrator/
|
|
|
262
287
|
|
|
263
288
|
**v0.4.11 变更(orchestrator 技能瘦身,2026-10-17)**:`skills/orchestrator.md` 20587 → 15532 bytes(约 -24.6%)。主代理保持纯调度,两层并行/聚合、brief 300、planner 237、批次上限 3 均不变;不伪造 runtime 200K,不自动压缩/硬裁 delegate。规格细节见 [skills/orchestrator.md](skills/orchestrator.md)。
|
|
264
289
|
|
|
290
|
+
**v0.5.0 变更(正式面向 DSH 0.2.0-rc.2,2026-10-17)**:本包正式锁定 DSH 0.2 契约(peer/dev 依赖升至 `0.2.0-rc.2`;`@deepseek-ai/cordis` peer `^4.0.1` / `schemastery` peer `^3.18.1` 保持合法 range),**不再支持 DSH 0.1**(0.1 宿主因 peer 冲突被 npm 拒绝安装,属预期)。设置改为 Config 的 `.volatile()` 动态字段,由官方设置页按活动 profile entry id 原生投影(`.volatile()` 取代并删除 0.1 的 `installSettingsSection` / `settingsNamespace` 自定义卡片机制);**不自动迁移**旧 `cohub` settings namespace 与用户 preset(旧配置请经设置页或 `cordis.patch.yml` 重配;preset 由安装台账按「用户是否改过」逐文件保护)。`test/host-integration.ts` 新增运行中取消门禁:真实 SubagentRuntime + in-memory provider 验证 start 已发布后 mid-flight abort 的 result 停止/失败传播(signal 驱动受控 result settle 为 `stopReason=aborted`,非仅断言 `signal.aborted`)与 dispose 资源清理,并验证 delegate 工具 execution 的取消链(父 `exec.signal` → run.result 停止 → 结构化 cause)。
|
|
291
|
+
**v0.5.0 收尾(客户端收敛 + session-projection peer)**:`src/client/index.js` 删除 0.1 `settingsScope` /
|
|
292
|
+
`settings.plugin.item` 兼容死分支与不可达的自定义设置卡片(约 800 行,0.2 下该分支永不执行),
|
|
293
|
+
仅保留 locale 设置字典注册;`dsh.client.inject` 收敛为仅 `@deepseek-ai/dsh-client-locale`,
|
|
294
|
+
peer 移除不再使用的 `react` / `dsh-client-connection` / `dsh-client-ui-settings` /
|
|
295
|
+
`dsh-client-ui-slots` / `dsh-api-remotes`;新增 peer `@deepseek-ai/dsh-session-projection ^0.2.0-rc.2`
|
|
296
|
+
(required,tokenMeter 真实调用 `ctx.sessionProjections.snapshot`)。新增 `npm run test:client`
|
|
297
|
+
(`test/client-runtime-0.2.ts`):执行真实构建产物 `lib/client.js` 的 ModuleLoader 注册,断言
|
|
298
|
+
module id / inject 仅 locale、apply 只访问声明服务、不触碰旧 settingsScope/slot/未声明 remote
|
|
299
|
+
(locale 与 window 为内存 stub,非 React 真实浏览器 UI,浏览器实测留给宿主)。
|
|
300
|
+
|
|
265
301
|
> **`cohub-cordis` 因此不含 `cordis_*` 工具**(`cordis_define` / `cordis_run` / `cordis_mount` / `cordis_inspect_*`)。需要 Cordis 自指能力时,请用官方**创造模式**会话;本 preset 用于"标准能力 + cohub 委派纪律"的日常开发。
|
|
266
302
|
>
|
|
267
303
|
> 也**不要**在 profile 的 `cordis.patch.yml` 里 insert 同 id —— 那会重新制造同一个故障。
|
|
@@ -308,6 +344,8 @@ node test/delegate-p1.ts # P1:环境契约注入 + 重试
|
|
|
308
344
|
node test/stall-p3.ts # P3-1 N2 停滞检测(35 用例)
|
|
309
345
|
node test/schedule-p3.ts # P3-3 N3 调度参数(24 用例)
|
|
310
346
|
node test/env-sig-p3.ts # P3-2 N1 环境契约持久化(50 用例)
|
|
347
|
+
npm run test:runtime # DSH 0.2 运行期契约(真实 schemastery/Volatile/defineTool + cordis 挂载)
|
|
348
|
+
npm run test:host # DSH 0.2 宿主集成门禁(真实 Loader/SettingsForms/subagents/app-boot preflight)
|
|
311
349
|
```
|
|
312
350
|
|
|
313
351
|
基线说明(2026-09-03 实测,`node` 直跑):`unit` 全 PASS + `delegate-p1` 41 + `stall-p3` 35 + `schedule-p3` 24 + `env-sig-p3` 50 + `preset-copy` 13 + `preset-install` 35 + `preset-schema` 28 —— **8/8 全绿,全部 PASS**(node >= 24)。无需 LLM,单测纯本地模拟。
|
|
@@ -328,7 +366,7 @@ src/
|
|
|
328
366
|
env-contract.ts 注入子代理的执行器环境契约文本(含「工具批处理」通用原则)
|
|
329
367
|
env-signatures.ts P3-2 环境契约持久化(EnvSignatureLearner + 缓存)
|
|
330
368
|
skills.ts generate-skills.ts 生成物(禁止手编)
|
|
331
|
-
client/index.js
|
|
369
|
+
client/index.js 客户端模块(仅 locale 设置字典注册,无 UI 卡片)
|
|
332
370
|
presets/co-orchestrator/ 内置 agent preset(Phase 2,纯调度模式 + 委派工具面补全 + compaction)
|
|
333
371
|
presets/cohub-cordis/ 内置 agent preset(Phase 5,创造模式 + 中文身份 + 自包含组合创作技能,v0.4.7 新增)
|
|
334
372
|
test/
|
|
@@ -343,4 +381,4 @@ test/
|
|
|
343
381
|
cordis.patch.yml bundle patch(含 P1/P3 全部 profile 字段示例)
|
|
344
382
|
```
|
|
345
383
|
|
|
346
|
-
> DSH
|
|
384
|
+
> DSH 0.2(0.2.0-rc.2)阶段,本包 peerDependencies 锁定 0.2.0-rc.2;0.1 支持情况见上文「DSH 0.2 兼容说明」(0.5.0 起明确不支持 0.1)。
|
package/cordis.patch.yml
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
councillors: []
|
|
11
11
|
councilTimeoutMs: 180000
|
|
12
12
|
# skills: delegate 委派路由,按 skill 名覆盖子代理的 provider/model/maxTokens。
|
|
13
|
-
#
|
|
13
|
+
# DSH 0.2 起本字段是 volatile:设置页按 profile entry id(cohub)投影并实时提交
|
|
14
|
+
# (loader/volatile-update),无需重启;此处为组合层初始值。未配置则继承父模型。示例:
|
|
14
15
|
# skills:
|
|
15
16
|
# - { name: co-fixer, provider: deepseek-official, model: deepseek-v4-flash }
|
|
16
17
|
# - { name: co-explorer, provider: deepseek-official, model: deepseek-v4-flash }
|
package/lib/client.js
CHANGED
|
@@ -4,26 +4,15 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
-
var React = require("react");
|
|
8
7
|
|
|
9
8
|
var NS = "cohub";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{ name: "co-librarian", label: "资料研究" },
|
|
18
|
-
{ name: "co-observer", label: "视觉分析" },
|
|
19
|
-
{ name: "co-fixer", label: "代码修改方案" },
|
|
20
|
-
{ name: "co-designer", label: "UI/UX 设计" },
|
|
21
|
-
{ name: "co-council", label: "多模型共识" },
|
|
22
|
-
{ name: "co-rule-user", label: "用户规则" },
|
|
23
|
-
{ name: "co-rule-project", label: "项目规则" },
|
|
24
|
-
{ name: "co-rule-app", label: "应用规则" },
|
|
25
|
-
|
|
26
|
-
];
|
|
9
|
+
// DSH 0.2 客户端服务收敛:本插件客户端仅使用 locale(设置字典注册)。
|
|
10
|
+
// 0.2 官方设置页按活动 profile entry id 投影 Config 的 volatile 字段
|
|
11
|
+
// (SettingsForms.describe() 从真实 Loader entry 的 fiber.runtime.Config 投影),
|
|
12
|
+
// skills / schedule / delegateRetry 由官方自动生成表单并实时提交——不再需要自定义
|
|
13
|
+
// settings 卡片。旧 settingsScope 服务与 settings.plugin.item slot 已在 0.2 移除,
|
|
14
|
+
// 本包 0.5.0 不支持 DSH 0.1,不声明也不保留该兼容分支。
|
|
15
|
+
var inject = ["locale"];
|
|
27
16
|
|
|
28
17
|
var zh = {
|
|
29
18
|
title: "CoHub 代理模型",
|
|
@@ -120,761 +109,10 @@ window.__ModuleLoader__.load({
|
|
|
120
109
|
modelPlaceholder: "Select model (leave blank for provider default)"
|
|
121
110
|
};
|
|
122
111
|
|
|
123
|
-
function emptyDraft() {
|
|
124
|
-
var draft = {};
|
|
125
|
-
for (var i = 0; i < SKILL_ROWS.length; i += 1) {
|
|
126
|
-
draft[SKILL_ROWS[i].name] = { provider: "", model: "", maxTokens: undefined };
|
|
127
|
-
}
|
|
128
|
-
return draft;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function rowFromSkill(skill) {
|
|
132
|
-
return {
|
|
133
|
-
provider: typeof skill.provider === "string" ? skill.provider : "",
|
|
134
|
-
model: typeof skill.model === "string" ? skill.model : "",
|
|
135
|
-
maxTokens: typeof skill.maxTokens === "number" ? skill.maxTokens : undefined
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function buildDraft(skills) {
|
|
140
|
-
var draft = emptyDraft();
|
|
141
|
-
if (Array.isArray(skills)) {
|
|
142
|
-
for (var i = 0; i < skills.length; i += 1) {
|
|
143
|
-
var skill = skills[i];
|
|
144
|
-
if (!skill || typeof skill.name !== "string") continue;
|
|
145
|
-
if (!Object.prototype.hasOwnProperty.call(draft, skill.name)) {
|
|
146
|
-
draft[skill.name] = { provider: "", model: "", maxTokens: undefined };
|
|
147
|
-
}
|
|
148
|
-
draft[skill.name] = rowFromSkill(skill);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return draft;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function isConfigured(row) {
|
|
155
|
-
return row.provider !== "" || row.model !== "" || row.maxTokens !== undefined;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function nameSet(skills) {
|
|
159
|
-
var set = new Set();
|
|
160
|
-
if (Array.isArray(skills)) {
|
|
161
|
-
for (var i = 0; i < skills.length; i += 1) {
|
|
162
|
-
var skill = skills[i];
|
|
163
|
-
if (skill && typeof skill.name === "string") set.add(skill.name);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return set;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function useLlmTopology(api, remote) {
|
|
170
|
-
var [state, setState] = React.useState({ providers: [], modelsByProvider: {}, loading: true, error: null });
|
|
171
|
-
|
|
172
|
-
var load = React.useCallback(function () {
|
|
173
|
-
var generation = 0;
|
|
174
|
-
return async function () {
|
|
175
|
-
generation += 1;
|
|
176
|
-
var providers = [];
|
|
177
|
-
var modelsByProvider = {};
|
|
178
|
-
try {
|
|
179
|
-
var responses = await Promise.all([
|
|
180
|
-
api.llm.listConfigurableProviders(),
|
|
181
|
-
api.session.modelCatalog()
|
|
182
|
-
]);
|
|
183
|
-
var providersResponse = responses[0];
|
|
184
|
-
var modelsResponse = responses[1];
|
|
185
|
-
if (!providersResponse || !providersResponse.ok) {
|
|
186
|
-
throw new Error(providersResponse && providersResponse.error ? providersResponse.error.message : "llm.listConfigurableProviders failed");
|
|
187
|
-
}
|
|
188
|
-
if (!modelsResponse || !modelsResponse.ok) {
|
|
189
|
-
throw new Error(modelsResponse && modelsResponse.error ? modelsResponse.error.message : "session.modelCatalog failed");
|
|
190
|
-
}
|
|
191
|
-
var configurable = providersResponse.value || [];
|
|
192
|
-
for (var i = 0; i < configurable.length; i += 1) {
|
|
193
|
-
var item = configurable[i];
|
|
194
|
-
if (item.declared === false) continue;
|
|
195
|
-
providers.push({
|
|
196
|
-
id: item.provider,
|
|
197
|
-
label: item.displayName && item.displayName !== item.provider ? item.displayName + " (" + item.provider + ")" : item.provider,
|
|
198
|
-
active: item.declared !== false
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
var groups = (modelsResponse.value && modelsResponse.value.groups) || [];
|
|
202
|
-
for (var j = 0; j < groups.length; j += 1) {
|
|
203
|
-
var group = groups[j];
|
|
204
|
-
if (!group || typeof group.id !== "string") continue;
|
|
205
|
-
var models = (group.models || []).map(function (model) {
|
|
206
|
-
return {
|
|
207
|
-
id: model.id,
|
|
208
|
-
label: model.name && model.name !== model.id ? model.name + " (" + model.id + ")" : model.id
|
|
209
|
-
};
|
|
210
|
-
});
|
|
211
|
-
modelsByProvider[group.id] = models;
|
|
212
|
-
var known = providers.some(function (provider) { return provider.id === group.id; });
|
|
213
|
-
if (!known) {
|
|
214
|
-
providers.push({
|
|
215
|
-
id: group.id,
|
|
216
|
-
label: group.name && group.name !== group.id ? group.name + " (" + group.id + ")" : group.id,
|
|
217
|
-
active: true
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
providers.sort(function (left, right) { return left.id.localeCompare(right.id); });
|
|
222
|
-
setState({ providers: providers, modelsByProvider: modelsByProvider, loading: false, error: null });
|
|
223
|
-
} catch (error) {
|
|
224
|
-
setState({ providers: providers, modelsByProvider: modelsByProvider, loading: false, error: error && error.message ? error.message : String(error) });
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
}, [api]);
|
|
228
|
-
|
|
229
|
-
React.useEffect(function () {
|
|
230
|
-
var run = load();
|
|
231
|
-
run();
|
|
232
|
-
var off = remote && remote.$on ? remote.$on("llm/adapters-updated", function () { run(); }) : undefined;
|
|
233
|
-
return function () {
|
|
234
|
-
if (typeof off === "function") off();
|
|
235
|
-
};
|
|
236
|
-
}, [load, remote]);
|
|
237
|
-
|
|
238
|
-
return {
|
|
239
|
-
providers: state.providers,
|
|
240
|
-
modelsByProvider: state.modelsByProvider,
|
|
241
|
-
loading: state.loading,
|
|
242
|
-
error: state.error
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function installCss() {
|
|
247
|
-
var tagId = "dsh-cohub/cohub-card.css";
|
|
248
|
-
if (typeof document === "undefined") return;
|
|
249
|
-
if (document.querySelector('style[data-plugin-css="' + tagId + '"]') !== null) return;
|
|
250
|
-
var css = [
|
|
251
|
-
".cohub-card{max-width:760px;color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);border-radius:12px;padding:14px 16px;background:var(--dsw-alias-bg-layer-3);}",
|
|
252
|
-
".cohub-title{margin:0;font-size:15px;font-weight:600;line-height:22px;}",
|
|
253
|
-
".cohub-desc{color:var(--dsw-alias-label-tertiary);margin:4px 0 0;font-size:13px;line-height:20px;}",
|
|
254
|
-
".cohub-status{margin:8px 0 0;font-size:12px;line-height:18px;}",
|
|
255
|
-
".cohub-rows{margin:14px 0 0;padding:0;list-style:none;display:flex;flex-direction:column;gap:8px;}",
|
|
256
|
-
".cohub-row{border:1px solid var(--dsw-alias-border-l2);border-radius:10px;padding:10px 12px;background:var(--dsw-alias-bg-layer-2);}",
|
|
257
|
-
".cohub-row-head{display:flex;align-items:center;gap:8px;}",
|
|
258
|
-
".cohub-row-name{font-size:13px;font-weight:600;line-height:20px;}",
|
|
259
|
-
".cohub-row-id{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;}",
|
|
260
|
-
".cohub-badge{margin-left:auto;border-radius:999px;padding:1px 8px;font-size:11px;line-height:17px;white-space:nowrap;}",
|
|
261
|
-
".cohub-badge-explicit{color:var(--dsw-alias-state-success-primary);border:1px solid var(--dsw-alias-state-success-primary);}",
|
|
262
|
-
".cohub-badge-inherited{color:var(--dsw-alias-label-tertiary);border:1px solid var(--dsw-alias-border-l2);}",
|
|
263
|
-
".cohub-fields{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:8px;}",
|
|
264
|
-
".cohub-field{display:flex;flex-direction:column;gap:4px;}",
|
|
265
|
-
".cohub-label{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;}",
|
|
266
|
-
".cohub-select,.cohub-input{box-sizing:border-box;width:100%;height:32px;font:inherit;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-3);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:0 10px;font-size:13px;line-height:20px;}",
|
|
267
|
-
".cohub-select:focus-visible,.cohub-input:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none;}",
|
|
268
|
-
".cohub-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px;}",
|
|
269
|
-
".cohub-button{height:32px;font:inherit;cursor:pointer;border-radius:8px;padding:0 12px;font-size:13px;line-height:20px;}",
|
|
270
|
-
".cohub-button-primary{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-primary-fill);border:none;}",
|
|
271
|
-
".cohub-button-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover);}",
|
|
272
|
-
".cohub-button-ghost{color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid var(--dsw-alias-border-l2);}",
|
|
273
|
-
".cohub-button-ghost:hover:not(:disabled){color:var(--dsw-alias-label-primary);}",
|
|
274
|
-
".cohub-button:disabled{opacity:.45;cursor:default;}",
|
|
275
|
-
".cohub-error{color:var(--dsw-alias-state-error-primary);}",
|
|
276
|
-
".cohub-saved{color:var(--dsw-alias-state-success-primary);}",
|
|
277
|
-
".cohub-subtitle{margin:16px 0 0;font-size:13px;font-weight:600;line-height:20px;}",
|
|
278
|
-
".cohub-schedule{border:1px solid var(--dsw-alias-border-l2);border-radius:10px;padding:10px 12px;margin-top:10px;background:var(--dsw-alias-bg-layer-2);}",
|
|
279
|
-
".cohub-schedule-fields{display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:8px;margin-top:8px;}",
|
|
280
|
-
".cohub-retry-fields{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:8px;}",
|
|
281
|
-
".cohub-field-row{display:flex;flex-direction:column;gap:4px;margin-top:10px;}",
|
|
282
|
-
".cohub-stall-fields{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin-top:8px;}",
|
|
283
|
-
".cohub-envsig-fields{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin-top:8px;}",
|
|
284
|
-
".cohub-checkbox-row{display:flex;align-items:center;gap:6px;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:20px;cursor:pointer;}",
|
|
285
|
-
".cohub-notice{background:var(--dsw-alias-state-warning-bg,#fff8e1);color:var(--dsw-alias-state-warning-primary,#8d6e00);border:1px solid var(--dsw-alias-state-warning-border,#ffc107);border-radius:8px;padding:8px 12px;margin-bottom:8px;font-size:13px;line-height:20px;}",
|
|
286
|
-
".cohub-clear-btn{background:none;border:none;color:var(--dsw-alias-label-tertiary);cursor:pointer;font-size:16px;line-height:1;padding:0 4px;margin-left:4px;}.cohub-clear-btn:hover{color:var(--dsw-alias-label-primary);}"
|
|
287
|
-
].join("\n");
|
|
288
|
-
var tag = document.createElement("style");
|
|
289
|
-
tag.dataset.plugin = "dsh-cohub";
|
|
290
|
-
tag.dataset.pluginCss = tagId;
|
|
291
|
-
tag.textContent = css;
|
|
292
|
-
document.head.appendChild(tag);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function CohubSettingsCard(props) {
|
|
296
|
-
var scope = props.scope;
|
|
297
|
-
var api = props.api;
|
|
298
|
-
var remote = props.remote;
|
|
299
|
-
var t = typeof props.t === "function" ? props.t : function (key) { return zh[key] || key; };
|
|
300
|
-
|
|
301
|
-
if (!scope || !api) return null;
|
|
302
|
-
|
|
303
|
-
var subscribe = React.useCallback(function (listener) { return scope.subscribe(listener); }, [scope]);
|
|
304
|
-
var getSnapshot = React.useCallback(function () { return scope.getSnapshot(); }, [scope]);
|
|
305
|
-
var snapshot = React.useSyncExternalStore(subscribe, getSnapshot);
|
|
306
|
-
|
|
307
|
-
var [draft, setDraft] = React.useState(function () {
|
|
308
|
-
return buildDraft(Array.isArray(snapshot.value && snapshot.value.skills) ? snapshot.value.skills : []);
|
|
309
|
-
}, { key: "cohub" });
|
|
310
|
-
var [dirty, setDirty] = React.useState(false);
|
|
311
|
-
var [touched, setTouched] = React.useState(function () { return new Set(); });
|
|
312
|
-
var [saving, setSaving] = React.useState(false);
|
|
313
|
-
var [saved, setSaved] = React.useState(false);
|
|
314
|
-
var [error, setError] = React.useState("");
|
|
315
|
-
var [invalidNotice, setInvalidNotice] = React.useState(null);
|
|
316
|
-
|
|
317
|
-
var [scheduleDraft, setScheduleDraft] = React.useState(function () {
|
|
318
|
-
var s = snapshot.value && snapshot.value.schedule;
|
|
319
|
-
return {
|
|
320
|
-
maxParallelBatch: s && typeof s.maxParallelBatch === "number" ? s.maxParallelBatch : 3,
|
|
321
|
-
wallClockBudgetMs: s && typeof s.wallClockBudgetMs === "number" ? s.wallClockBudgetMs : 600000
|
|
322
|
-
};
|
|
323
|
-
});
|
|
324
|
-
var [retryDraft, setRetryDraft] = React.useState(function () {
|
|
325
|
-
var r = snapshot.value && snapshot.value.delegateRetry;
|
|
326
|
-
return {
|
|
327
|
-
maxRetries: r && typeof r.maxRetries === "number" ? r.maxRetries : 0,
|
|
328
|
-
retryDelayMs: r && typeof r.retryDelayMs === "number" ? r.retryDelayMs : 1000,
|
|
329
|
-
retryableReasons: Array.isArray(r && r.retryableReasons) ? r.retryableReasons : ["aborted"]
|
|
330
|
-
};
|
|
331
|
-
});
|
|
332
|
-
var [stallDraft, setStallDraft] = React.useState(function () {
|
|
333
|
-
var s = snapshot.value && snapshot.value.delegateRetry && snapshot.value.delegateRetry.stall;
|
|
334
|
-
return {
|
|
335
|
-
enabled: !!(s && s.enabled),
|
|
336
|
-
consecutiveErrors: s && typeof s.consecutiveErrors === "number" ? s.consecutiveErrors : 3,
|
|
337
|
-
idleMs: s && typeof s.idleMs === "number" ? s.idleMs : 180000,
|
|
338
|
-
reasoningWithoutAction: s && typeof s.reasoningWithoutAction === "number" ? s.reasoningWithoutAction : 50,
|
|
339
|
-
loopCount: s && typeof s.loopCount === "number" ? s.loopCount : 3,
|
|
340
|
-
graceMs: s && typeof s.graceMs === "number" ? s.graceMs : 30000,
|
|
341
|
-
recoverable: s && typeof s.recoverable === "boolean" ? s.recoverable : true
|
|
342
|
-
};
|
|
343
|
-
});
|
|
344
|
-
var [envSigDraft, setEnvSigDraft] = React.useState(function () {
|
|
345
|
-
var e = snapshot.value && snapshot.value.envSignatures;
|
|
346
|
-
return {
|
|
347
|
-
use: e && typeof e.use === "string" ? e.use : "auto",
|
|
348
|
-
ttlMs: e && typeof e.ttlMs === "number" ? e.ttlMs : 604800000,
|
|
349
|
-
confirmCount: e && typeof e.confirmCount === "number" ? e.confirmCount : 2
|
|
350
|
-
};
|
|
351
|
-
});
|
|
352
|
-
var [scheduleTouched, setScheduleTouched] = React.useState(false);
|
|
353
|
-
var [retryTouched, setRetryTouched] = React.useState(false);
|
|
354
|
-
var [stallTouched, setStallTouched] = React.useState(false);
|
|
355
|
-
var [envSigTouched, setEnvSigTouched] = React.useState(false);
|
|
356
|
-
|
|
357
|
-
var topology = useLlmTopology(api, remote);
|
|
358
|
-
|
|
359
|
-
React.useEffect(function () {
|
|
360
|
-
if (!dirty) {
|
|
361
|
-
setDraft(buildDraft(Array.isArray(snapshot.value && snapshot.value.skills) ? snapshot.value.skills : []));
|
|
362
|
-
setTouched(new Set());
|
|
363
|
-
var s = snapshot.value && snapshot.value.schedule;
|
|
364
|
-
setScheduleDraft({
|
|
365
|
-
maxParallelBatch: s && typeof s.maxParallelBatch === "number" ? s.maxParallelBatch : 3,
|
|
366
|
-
wallClockBudgetMs: s && typeof s.wallClockBudgetMs === "number" ? s.wallClockBudgetMs : 600000
|
|
367
|
-
});
|
|
368
|
-
var r = snapshot.value && snapshot.value.delegateRetry;
|
|
369
|
-
setRetryDraft({
|
|
370
|
-
maxRetries: r && typeof r.maxRetries === "number" ? r.maxRetries : 0,
|
|
371
|
-
retryDelayMs: r && typeof r.retryDelayMs === "number" ? r.retryDelayMs : 1000,
|
|
372
|
-
retryableReasons: Array.isArray(r && r.retryableReasons) ? r.retryableReasons : ["aborted"]
|
|
373
|
-
});
|
|
374
|
-
var st = snapshot.value && snapshot.value.delegateRetry && snapshot.value.delegateRetry.stall;
|
|
375
|
-
setStallDraft({
|
|
376
|
-
enabled: !!(st && st.enabled),
|
|
377
|
-
consecutiveErrors: st && typeof st.consecutiveErrors === "number" ? st.consecutiveErrors : 3,
|
|
378
|
-
idleMs: st && typeof st.idleMs === "number" ? st.idleMs : 180000,
|
|
379
|
-
reasoningWithoutAction: st && typeof st.reasoningWithoutAction === "number" ? st.reasoningWithoutAction : 50,
|
|
380
|
-
loopCount: st && typeof st.loopCount === "number" ? st.loopCount : 3,
|
|
381
|
-
graceMs: st && typeof st.graceMs === "number" ? st.graceMs : 30000,
|
|
382
|
-
recoverable: st && typeof st.recoverable === "boolean" ? st.recoverable : true
|
|
383
|
-
});
|
|
384
|
-
var e = snapshot.value && snapshot.value.envSignatures;
|
|
385
|
-
setEnvSigDraft({
|
|
386
|
-
use: e && typeof e.use === "string" ? e.use : "auto",
|
|
387
|
-
ttlMs: e && typeof e.ttlMs === "number" ? e.ttlMs : 604800000,
|
|
388
|
-
confirmCount: e && typeof e.confirmCount === "number" ? e.confirmCount : 2
|
|
389
|
-
});
|
|
390
|
-
setScheduleTouched(false);
|
|
391
|
-
setRetryTouched(false);
|
|
392
|
-
setStallTouched(false);
|
|
393
|
-
setEnvSigTouched(false);
|
|
394
|
-
}
|
|
395
|
-
}, [snapshot, dirty]);
|
|
396
|
-
|
|
397
|
-
var prevTopologyRef = React.useRef(topology.loading);
|
|
398
|
-
React.useEffect(function () {
|
|
399
|
-
var wasLoading = prevTopologyRef.current;
|
|
400
|
-
prevTopologyRef.current = topology.loading;
|
|
401
|
-
if (topology.loading) return;
|
|
402
|
-
if (!wasLoading) return;
|
|
403
|
-
|
|
404
|
-
var providerIds = new Set(topology.providers.map(function (p) { return p.id; }));
|
|
405
|
-
var cleared = [];
|
|
406
|
-
setDraft(function (prev) {
|
|
407
|
-
var next = {};
|
|
408
|
-
var changed = false;
|
|
409
|
-
for (var key in prev) {
|
|
410
|
-
var row = prev[key];
|
|
411
|
-
var newRow = { provider: row.provider, model: row.model, maxTokens: row.maxTokens };
|
|
412
|
-
if (row.provider && !providerIds.has(row.provider)) {
|
|
413
|
-
newRow.provider = "";
|
|
414
|
-
newRow.model = "";
|
|
415
|
-
changed = true;
|
|
416
|
-
cleared.push(key);
|
|
417
|
-
} else if (row.provider && row.model) {
|
|
418
|
-
var models = topology.modelsByProvider[row.provider] || [];
|
|
419
|
-
var modelIds = new Set(models.map(function (m) { return m.id; }));
|
|
420
|
-
if (!modelIds.has(row.model)) {
|
|
421
|
-
newRow.model = "";
|
|
422
|
-
changed = true;
|
|
423
|
-
cleared.push(key);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
next[key] = newRow;
|
|
427
|
-
}
|
|
428
|
-
return changed ? next : prev;
|
|
429
|
-
});
|
|
430
|
-
if (cleared.length > 0) {
|
|
431
|
-
var skillLabels = cleared.map(function (name) {
|
|
432
|
-
var found = SKILL_ROWS.find(function (s) { return s.name === name; });
|
|
433
|
-
return found ? found.label : name;
|
|
434
|
-
});
|
|
435
|
-
setInvalidNotice(
|
|
436
|
-
t("invalidCleared").replace("{count}", String(cleared.length)) + " " +
|
|
437
|
-
t("invalidClearedList").replace("{list}", skillLabels.join("、"))
|
|
438
|
-
);
|
|
439
|
-
setDirty(true);
|
|
440
|
-
setSaved(false);
|
|
441
|
-
}
|
|
442
|
-
}, [topology.loading, topology.providers, topology.modelsByProvider]);
|
|
443
|
-
|
|
444
|
-
var effectiveSkills = Array.isArray(snapshot.value && snapshot.value.skills) ? snapshot.value.skills : [];
|
|
445
|
-
var baseNames = nameSet(snapshot.base && snapshot.base.skills);
|
|
446
|
-
var userNames = nameSet(snapshot.user && snapshot.user.skills);
|
|
447
|
-
var ready = snapshot.status === "ready";
|
|
448
|
-
var writable = ready && snapshot.writable === true;
|
|
449
|
-
|
|
450
|
-
function update(name, field, value) {
|
|
451
|
-
setDraft(function (prev) {
|
|
452
|
-
var next = {};
|
|
453
|
-
for (var key in prev) next[key] = prev[key];
|
|
454
|
-
next[name] = { provider: prev[name].provider, model: prev[name].model, maxTokens: prev[name].maxTokens };
|
|
455
|
-
next[name][field] = value;
|
|
456
|
-
return next;
|
|
457
|
-
});
|
|
458
|
-
setTouched(function (prev) {
|
|
459
|
-
var next = new Set(prev);
|
|
460
|
-
next.add(name);
|
|
461
|
-
return next;
|
|
462
|
-
});
|
|
463
|
-
setDirty(true);
|
|
464
|
-
setSaved(false);
|
|
465
|
-
setError("");
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
function updateSchedule(field, value) {
|
|
469
|
-
setScheduleDraft(function (prev) {
|
|
470
|
-
var next = {};
|
|
471
|
-
for (var key in prev) next[key] = prev[key];
|
|
472
|
-
next[field] = value;
|
|
473
|
-
return next;
|
|
474
|
-
});
|
|
475
|
-
setScheduleTouched(true);
|
|
476
|
-
setDirty(true);
|
|
477
|
-
setSaved(false);
|
|
478
|
-
setError("");
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
function updateRetry(field, value) {
|
|
482
|
-
setRetryDraft(function (prev) {
|
|
483
|
-
var next = {};
|
|
484
|
-
for (var key in prev) next[key] = prev[key];
|
|
485
|
-
next[field] = value;
|
|
486
|
-
return next;
|
|
487
|
-
});
|
|
488
|
-
setRetryTouched(true);
|
|
489
|
-
setDirty(true);
|
|
490
|
-
setSaved(false);
|
|
491
|
-
setError("");
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function updateStall(field, value) {
|
|
495
|
-
setStallDraft(function (prev) {
|
|
496
|
-
var next = {};
|
|
497
|
-
for (var key in prev) next[key] = prev[key];
|
|
498
|
-
next[field] = value;
|
|
499
|
-
return next;
|
|
500
|
-
});
|
|
501
|
-
setStallTouched(true);
|
|
502
|
-
setDirty(true);
|
|
503
|
-
setSaved(false);
|
|
504
|
-
setError("");
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
function updateEnvSig(field, value) {
|
|
508
|
-
setEnvSigDraft(function (prev) {
|
|
509
|
-
var next = {};
|
|
510
|
-
for (var key in prev) next[key] = prev[key];
|
|
511
|
-
next[field] = value;
|
|
512
|
-
return next;
|
|
513
|
-
});
|
|
514
|
-
setEnvSigTouched(true);
|
|
515
|
-
setDirty(true);
|
|
516
|
-
setSaved(false);
|
|
517
|
-
setError("");
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
function discard() {
|
|
521
|
-
setDraft(buildDraft(effectiveSkills));
|
|
522
|
-
setTouched(new Set());
|
|
523
|
-
var s = snapshot.value && snapshot.value.schedule;
|
|
524
|
-
setScheduleDraft({
|
|
525
|
-
maxParallelBatch: s && typeof s.maxParallelBatch === "number" ? s.maxParallelBatch : 3,
|
|
526
|
-
wallClockBudgetMs: s && typeof s.wallClockBudgetMs === "number" ? s.wallClockBudgetMs : 600000
|
|
527
|
-
});
|
|
528
|
-
var r = snapshot.value && snapshot.value.delegateRetry;
|
|
529
|
-
setRetryDraft({
|
|
530
|
-
maxRetries: r && typeof r.maxRetries === "number" ? r.maxRetries : 0,
|
|
531
|
-
retryDelayMs: r && typeof r.retryDelayMs === "number" ? r.retryDelayMs : 1000,
|
|
532
|
-
retryableReasons: Array.isArray(r && r.retryableReasons) ? r.retryableReasons : ["aborted"]
|
|
533
|
-
});
|
|
534
|
-
var st = snapshot.value && snapshot.value.delegateRetry && snapshot.value.delegateRetry.stall;
|
|
535
|
-
setStallDraft({
|
|
536
|
-
enabled: !!(st && st.enabled),
|
|
537
|
-
consecutiveErrors: st && typeof st.consecutiveErrors === "number" ? st.consecutiveErrors : 3,
|
|
538
|
-
idleMs: st && typeof st.idleMs === "number" ? st.idleMs : 180000,
|
|
539
|
-
reasoningWithoutAction: st && typeof st.reasoningWithoutAction === "number" ? st.reasoningWithoutAction : 50,
|
|
540
|
-
loopCount: st && typeof st.loopCount === "number" ? st.loopCount : 3,
|
|
541
|
-
graceMs: st && typeof st.graceMs === "number" ? st.graceMs : 30000,
|
|
542
|
-
recoverable: st && typeof st.recoverable === "boolean" ? st.recoverable : true
|
|
543
|
-
});
|
|
544
|
-
var e = snapshot.value && snapshot.value.envSignatures;
|
|
545
|
-
setEnvSigDraft({
|
|
546
|
-
use: e && typeof e.use === "string" ? e.use : "auto",
|
|
547
|
-
ttlMs: e && typeof e.ttlMs === "number" ? e.ttlMs : 604800000,
|
|
548
|
-
confirmCount: e && typeof e.confirmCount === "number" ? e.confirmCount : 2
|
|
549
|
-
});
|
|
550
|
-
setScheduleTouched(false);
|
|
551
|
-
setRetryTouched(false);
|
|
552
|
-
setStallTouched(false);
|
|
553
|
-
setEnvSigTouched(false);
|
|
554
|
-
setDirty(false);
|
|
555
|
-
setSaved(false);
|
|
556
|
-
setError("");
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
async function save() {
|
|
560
|
-
if (!dirty || saving || !writable) return;
|
|
561
|
-
setSaving(true);
|
|
562
|
-
setSaved(false);
|
|
563
|
-
setError("");
|
|
564
|
-
var next = [];
|
|
565
|
-
for (var name in draft) {
|
|
566
|
-
var row = draft[name];
|
|
567
|
-
var item = { name: name };
|
|
568
|
-
if (row.provider) item.provider = row.provider;
|
|
569
|
-
if (row.model) item.model = row.model;
|
|
570
|
-
if (row.maxTokens !== undefined) item.maxTokens = row.maxTokens;
|
|
571
|
-
if (item.provider || item.model || item.maxTokens !== undefined) next.push(item);
|
|
572
|
-
}
|
|
573
|
-
try {
|
|
574
|
-
if (next.length === 0) await scope.unset("skills");
|
|
575
|
-
else await scope.set("skills", next);
|
|
576
|
-
if (scheduleTouched) {
|
|
577
|
-
var batch = parseInt(scheduleDraft.maxParallelBatch, 10);
|
|
578
|
-
var wall = parseInt(scheduleDraft.wallClockBudgetMs, 10);
|
|
579
|
-
if (!Number.isFinite(batch) || batch < 1) batch = 3;
|
|
580
|
-
if (!Number.isFinite(wall) || wall < 0) wall = 600000;
|
|
581
|
-
await scope.set("schedule", {
|
|
582
|
-
maxParallelBatch: batch,
|
|
583
|
-
wallClockBudgetMs: wall
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
if (retryTouched || stallTouched) {
|
|
587
|
-
var retries = parseInt(retryDraft.maxRetries, 10);
|
|
588
|
-
var delay = parseInt(retryDraft.retryDelayMs, 10);
|
|
589
|
-
if (!Number.isFinite(retries) || retries < 0) retries = 0;
|
|
590
|
-
if (!Number.isFinite(delay) || delay < 0) delay = 1000;
|
|
591
|
-
var reasons = String(retryDraft.retryableReasons || "")
|
|
592
|
-
.split(/[\s,]+/)
|
|
593
|
-
.filter(function (s) { return s && s.length > 0; });
|
|
594
|
-
if (reasons.length === 0) reasons = ["aborted"];
|
|
595
|
-
var retryPayload = {
|
|
596
|
-
maxRetries: retries,
|
|
597
|
-
retryDelayMs: delay,
|
|
598
|
-
retryableReasons: reasons
|
|
599
|
-
};
|
|
600
|
-
if (stallTouched) {
|
|
601
|
-
var ce = parseInt(stallDraft.consecutiveErrors, 10);
|
|
602
|
-
var idle = parseInt(stallDraft.idleMs, 10);
|
|
603
|
-
var rwa = parseInt(stallDraft.reasoningWithoutAction, 10);
|
|
604
|
-
var loop = parseInt(stallDraft.loopCount, 10);
|
|
605
|
-
var grace = parseInt(stallDraft.graceMs, 10);
|
|
606
|
-
if (!Number.isFinite(ce) || ce < 1) ce = 3;
|
|
607
|
-
if (!Number.isFinite(idle) || idle < 0) idle = 180000;
|
|
608
|
-
if (!Number.isFinite(rwa) || rwa < 1) rwa = 50;
|
|
609
|
-
if (!Number.isFinite(loop) || loop < 1) loop = 3;
|
|
610
|
-
if (!Number.isFinite(grace) || grace < 0) grace = 30000;
|
|
611
|
-
retryPayload.stall = {
|
|
612
|
-
enabled: !!stallDraft.enabled,
|
|
613
|
-
consecutiveErrors: ce,
|
|
614
|
-
idleMs: idle,
|
|
615
|
-
reasoningWithoutAction: rwa,
|
|
616
|
-
loopCount: loop,
|
|
617
|
-
graceMs: grace,
|
|
618
|
-
recoverable: !!stallDraft.recoverable
|
|
619
|
-
};
|
|
620
|
-
} else {
|
|
621
|
-
var cur = snapshot.value && snapshot.value.delegateRetry;
|
|
622
|
-
if (cur && cur.stall) retryPayload.stall = cur.stall;
|
|
623
|
-
}
|
|
624
|
-
await scope.set("delegateRetry", retryPayload);
|
|
625
|
-
}
|
|
626
|
-
if (envSigTouched) {
|
|
627
|
-
var ttl = parseInt(envSigDraft.ttlMs, 10);
|
|
628
|
-
var cc = parseInt(envSigDraft.confirmCount, 10);
|
|
629
|
-
if (!Number.isFinite(ttl) || ttl < 0) ttl = 604800000;
|
|
630
|
-
if (!Number.isFinite(cc) || cc < 1) cc = 2;
|
|
631
|
-
await scope.set("envSignatures", {
|
|
632
|
-
use: envSigDraft.use || "auto",
|
|
633
|
-
ttlMs: ttl,
|
|
634
|
-
confirmCount: cc
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
setDirty(false);
|
|
638
|
-
setTouched(new Set());
|
|
639
|
-
setScheduleTouched(false);
|
|
640
|
-
setRetryTouched(false);
|
|
641
|
-
setStallTouched(false);
|
|
642
|
-
setEnvSigTouched(false);
|
|
643
|
-
setSaved(true);
|
|
644
|
-
} catch (err) {
|
|
645
|
-
setError(err && err.message ? err.message : String(err));
|
|
646
|
-
} finally {
|
|
647
|
-
setSaving(false);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
if (!ready) {
|
|
652
|
-
return React.createElement("div", { className: "cohub-card" },
|
|
653
|
-
React.createElement("h3", { className: "cohub-title" }, t("title")),
|
|
654
|
-
React.createElement("p", { className: "cohub-desc" }, t("description")),
|
|
655
|
-
React.createElement("p", { className: "cohub-status" }, t(snapshot.status === "unavailable" ? "unavailable" : "loading"))
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
var rows = SKILL_ROWS.map(function (skill) {
|
|
660
|
-
var row = draft[skill.name] || { provider: "", model: "", maxTokens: undefined };
|
|
661
|
-
var models = topology.modelsByProvider[row.provider] || [];
|
|
662
|
-
var modelOptions = models.map(function (model) {
|
|
663
|
-
return React.createElement("option", { key: model.id, value: model.id }, model.label);
|
|
664
|
-
});
|
|
665
|
-
if (row.model && !models.some(function (m) { return m.id === row.model; })) {
|
|
666
|
-
modelOptions.unshift(
|
|
667
|
-
React.createElement("option", { key: "__current", value: row.model, disabled: true }, row.model + " (已失效)")
|
|
668
|
-
);
|
|
669
|
-
}
|
|
670
|
-
var providerOptions;
|
|
671
|
-
if (topology.loading) {
|
|
672
|
-
providerOptions = [React.createElement("option", { key: "__loading", value: "", disabled: true }, t("loading"))];
|
|
673
|
-
} else if (topology.error) {
|
|
674
|
-
providerOptions = [React.createElement("option", { key: "__error", value: "", disabled: true }, t("loadProvidersFailed"))];
|
|
675
|
-
} else if (topology.providers.length === 0) {
|
|
676
|
-
providerOptions = [React.createElement("option", { key: "__empty", value: "", disabled: true }, t("loadProvidersFailed"))];
|
|
677
|
-
} else {
|
|
678
|
-
providerOptions = topology.providers.map(function (provider) {
|
|
679
|
-
return React.createElement("option", { key: provider.id, value: provider.id }, provider.label);
|
|
680
|
-
});
|
|
681
|
-
if (row.provider && !topology.providers.some(function (p) { return p.id === row.provider; })) {
|
|
682
|
-
providerOptions.unshift(
|
|
683
|
-
React.createElement("option", { key: "__current-provider", value: row.provider, disabled: true }, row.provider + " (已失效)")
|
|
684
|
-
);
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
var modelControl;
|
|
689
|
-
if (!row.provider) {
|
|
690
|
-
modelControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
691
|
-
React.createElement("option", { value: "" }, t("selectProviderFirst"))
|
|
692
|
-
);
|
|
693
|
-
} else if (topology.loading) {
|
|
694
|
-
modelControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
695
|
-
React.createElement("option", { value: "" }, t("loading"))
|
|
696
|
-
);
|
|
697
|
-
} else if (models.length > 0) {
|
|
698
|
-
// 未保存 model 时插入一个 value="" 的占位项。否则 <select value=""> 会被浏览器
|
|
699
|
-
// 渲染成列表第一项,让人误以为「已经选好了模型」,而实际保存值仍是空 —— 服务端随后
|
|
700
|
-
// 只能继承父会话模型并可能以 UNKNOWN_MODEL 失败。
|
|
701
|
-
var modelSelectOptions = [React.createElement("option", { key: "__inherit", value: "" }, t("modelPlaceholder"))].concat(modelOptions);
|
|
702
|
-
modelControl = React.createElement("select", {
|
|
703
|
-
className: "cohub-select",
|
|
704
|
-
value: row.model || "",
|
|
705
|
-
disabled: !writable,
|
|
706
|
-
onChange: function (event) { update(skill.name, "model", event.target.value); }
|
|
707
|
-
}, modelSelectOptions);
|
|
708
|
-
} else {
|
|
709
|
-
modelControl = React.createElement("input", {
|
|
710
|
-
className: "cohub-input",
|
|
711
|
-
value: row.model,
|
|
712
|
-
disabled: !writable,
|
|
713
|
-
placeholder: t("customModel"),
|
|
714
|
-
onChange: function (event) { update(skill.name, "model", event.target.value); }
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
var badgeClass = userNames.has(skill.name) || touched.has(skill.name) ? "cohub-badge cohub-badge-explicit" : baseNames.has(skill.name) ? "cohub-badge cohub-badge-inherited" : "cohub-badge cohub-badge-inherited";
|
|
719
|
-
var badgeText = userNames.has(skill.name) || touched.has(skill.name) ? t("configured") : t("inherited");
|
|
720
|
-
|
|
721
|
-
return React.createElement("li", { key: skill.name, className: "cohub-row" },
|
|
722
|
-
React.createElement("div", { className: "cohub-row-head" },
|
|
723
|
-
React.createElement("span", { className: "cohub-row-name" }, skill.label),
|
|
724
|
-
React.createElement("span", { className: "cohub-row-id" }, skill.name),
|
|
725
|
-
React.createElement("span", { className: badgeClass }, badgeText)
|
|
726
|
-
),
|
|
727
|
-
React.createElement("div", { className: "cohub-fields" },
|
|
728
|
-
React.createElement("div", { className: "cohub-field" },
|
|
729
|
-
React.createElement("label", { className: "cohub-label" }, t("provider")),
|
|
730
|
-
React.createElement("select", {
|
|
731
|
-
className: "cohub-select",
|
|
732
|
-
value: row.provider,
|
|
733
|
-
disabled: !writable,
|
|
734
|
-
onChange: function (event) { update(skill.name, "provider", event.target.value); }
|
|
735
|
-
}, providerOptions),
|
|
736
|
-
row.provider && writable ?
|
|
737
|
-
React.createElement("button", { type: "button", className: "cohub-clear-btn", onClick: function () { update(skill.name, "provider", ""); update(skill.name, "model", ""); }, title: "清除" }, "\u00D7") :
|
|
738
|
-
null
|
|
739
|
-
),
|
|
740
|
-
React.createElement("div", { className: "cohub-field" },
|
|
741
|
-
React.createElement("label", { className: "cohub-label" }, t("model")),
|
|
742
|
-
modelControl,
|
|
743
|
-
row.model && writable && row.provider ?
|
|
744
|
-
React.createElement("button", { type: "button", className: "cohub-clear-btn", onClick: function () { update(skill.name, "model", ""); }, title: "清除" }, "\u00D7") :
|
|
745
|
-
null
|
|
746
|
-
)
|
|
747
|
-
)
|
|
748
|
-
);
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
return React.createElement("div", { className: "cohub-card" },
|
|
752
|
-
React.createElement("h3", { className: "cohub-title" }, t("title")),
|
|
753
|
-
React.createElement("p", { className: "cohub-desc" }, t("description")),
|
|
754
|
-
topology.error ? React.createElement("p", { className: "cohub-status cohub-error" }, t("loadProvidersFailed") + ": " + topology.error) : null,
|
|
755
|
-
invalidNotice ? React.createElement("div", { className: "cohub-notice" },
|
|
756
|
-
React.createElement("span", null, invalidNotice)
|
|
757
|
-
) : null,
|
|
758
|
-
React.createElement("ul", { className: "cohub-rows" }, rows),
|
|
759
|
-
React.createElement("div", { className: "cohub-schedule" },
|
|
760
|
-
React.createElement("h4", { className: "cohub-subtitle" }, t("scheduleTitle")),
|
|
761
|
-
React.createElement("p", { className: "cohub-desc" }, t("scheduleDesc")),
|
|
762
|
-
React.createElement("div", { className: "cohub-schedule-fields" },
|
|
763
|
-
React.createElement("div", { className: "cohub-field" },
|
|
764
|
-
React.createElement("label", { className: "cohub-label" }, t("batchSize")),
|
|
765
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 1, step: 1, value: scheduleDraft.maxParallelBatch, disabled: !writable, onChange: function (event) { updateSchedule("maxParallelBatch", event.target.value); } })
|
|
766
|
-
),
|
|
767
|
-
React.createElement("div", { className: "cohub-field" },
|
|
768
|
-
React.createElement("label", { className: "cohub-label" }, t("wallClock")),
|
|
769
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 0, step: 1000, value: scheduleDraft.wallClockBudgetMs, disabled: !writable, onChange: function (event) { updateSchedule("wallClockBudgetMs", event.target.value); } })
|
|
770
|
-
)
|
|
771
|
-
)
|
|
772
|
-
),
|
|
773
|
-
React.createElement("div", { className: "cohub-retry" },
|
|
774
|
-
React.createElement("h4", { className: "cohub-subtitle" }, t("maxRetries") + " / " + t("retryDelayMs")),
|
|
775
|
-
React.createElement("div", { className: "cohub-retry-fields" },
|
|
776
|
-
React.createElement("div", { className: "cohub-field" },
|
|
777
|
-
React.createElement("label", { className: "cohub-label" }, t("maxRetries")),
|
|
778
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 0, step: 1, value: retryDraft.maxRetries, disabled: !writable, onChange: function (event) { updateRetry("maxRetries", event.target.value); } })
|
|
779
|
-
),
|
|
780
|
-
React.createElement("div", { className: "cohub-field" },
|
|
781
|
-
React.createElement("label", { className: "cohub-label" }, t("retryDelayMs")),
|
|
782
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 0, step: 100, value: retryDraft.retryDelayMs, disabled: !writable, onChange: function (event) { updateRetry("retryDelayMs", event.target.value); } })
|
|
783
|
-
)
|
|
784
|
-
),
|
|
785
|
-
React.createElement("div", { className: "cohub-field-row" },
|
|
786
|
-
React.createElement("label", { className: "cohub-label" }, t("retryableReasons")),
|
|
787
|
-
React.createElement("input", { className: "cohub-input", type: "text", value: (Array.isArray(retryDraft.retryableReasons) ? retryDraft.retryableReasons : []).join(", "), disabled: !writable, placeholder: "aborted, error", onChange: function (event) { updateRetry("retryableReasons", event.target.value); } }),
|
|
788
|
-
React.createElement("p", { className: "cohub-desc" }, t("retryableReasonsHint"))
|
|
789
|
-
)
|
|
790
|
-
),
|
|
791
|
-
React.createElement("div", { className: "cohub-stall" },
|
|
792
|
-
React.createElement("h4", { className: "cohub-subtitle" }, t("stallTitle")),
|
|
793
|
-
React.createElement("p", { className: "cohub-desc" }, t("stallDesc")),
|
|
794
|
-
React.createElement("label", { className: "cohub-checkbox-row" },
|
|
795
|
-
React.createElement("input", { type: "checkbox", checked: !!stallDraft.enabled, disabled: !writable, onChange: function (event) { updateStall("enabled", event.target.checked); } }),
|
|
796
|
-
" " + t("stallEnabled")
|
|
797
|
-
),
|
|
798
|
-
React.createElement("div", { className: "cohub-stall-fields" },
|
|
799
|
-
React.createElement("div", { className: "cohub-field" },
|
|
800
|
-
React.createElement("label", { className: "cohub-label" }, t("consecutiveErrors")),
|
|
801
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 1, step: 1, value: stallDraft.consecutiveErrors, disabled: !writable || !stallDraft.enabled, onChange: function (event) { updateStall("consecutiveErrors", event.target.value); } })
|
|
802
|
-
),
|
|
803
|
-
React.createElement("div", { className: "cohub-field" },
|
|
804
|
-
React.createElement("label", { className: "cohub-label" }, t("idleMs")),
|
|
805
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 0, step: 1000, value: stallDraft.idleMs, disabled: !writable || !stallDraft.enabled, onChange: function (event) { updateStall("idleMs", event.target.value); } })
|
|
806
|
-
),
|
|
807
|
-
React.createElement("div", { className: "cohub-field" },
|
|
808
|
-
React.createElement("label", { className: "cohub-label" }, t("reasoningWithoutAction")),
|
|
809
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 1, step: 1, value: stallDraft.reasoningWithoutAction, disabled: !writable || !stallDraft.enabled, onChange: function (event) { updateStall("reasoningWithoutAction", event.target.value); } })
|
|
810
|
-
),
|
|
811
|
-
React.createElement("div", { className: "cohub-field" },
|
|
812
|
-
React.createElement("label", { className: "cohub-label" }, t("loopCount")),
|
|
813
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 1, step: 1, value: stallDraft.loopCount, disabled: !writable || !stallDraft.enabled, onChange: function (event) { updateStall("loopCount", event.target.value); } })
|
|
814
|
-
),
|
|
815
|
-
React.createElement("div", { className: "cohub-field" },
|
|
816
|
-
React.createElement("label", { className: "cohub-label" }, t("graceMs")),
|
|
817
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 0, step: 1000, value: stallDraft.graceMs, disabled: !writable || !stallDraft.enabled, onChange: function (event) { updateStall("graceMs", event.target.value); } })
|
|
818
|
-
)
|
|
819
|
-
),
|
|
820
|
-
React.createElement("label", { className: "cohub-checkbox-row" },
|
|
821
|
-
React.createElement("input", { type: "checkbox", checked: !!stallDraft.recoverable, disabled: !writable || !stallDraft.enabled, onChange: function (event) { updateStall("recoverable", event.target.checked); } }),
|
|
822
|
-
" " + t("recoverable")
|
|
823
|
-
)
|
|
824
|
-
),
|
|
825
|
-
React.createElement("div", { className: "cohub-envsig" },
|
|
826
|
-
React.createElement("h4", { className: "cohub-subtitle" }, t("envSigTitle")),
|
|
827
|
-
React.createElement("p", { className: "cohub-desc" }, t("envSigDesc")),
|
|
828
|
-
React.createElement("div", { className: "cohub-envsig-fields" },
|
|
829
|
-
React.createElement("div", { className: "cohub-field" },
|
|
830
|
-
React.createElement("label", { className: "cohub-label" }, t("envSigUse")),
|
|
831
|
-
React.createElement("select", { className: "cohub-select", value: envSigDraft.use, disabled: !writable, onChange: function (event) { updateEnvSig("use", event.target.value); } },
|
|
832
|
-
React.createElement("option", { value: "auto" }, t("envSigUseAuto")),
|
|
833
|
-
React.createElement("option", { value: "off" }, t("envSigUseOff")),
|
|
834
|
-
React.createElement("option", { value: "manual" }, t("envSigUseManual"))
|
|
835
|
-
)
|
|
836
|
-
),
|
|
837
|
-
React.createElement("div", { className: "cohub-field" },
|
|
838
|
-
React.createElement("label", { className: "cohub-label" }, t("envSigTtl")),
|
|
839
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 0, step: 86400000, value: envSigDraft.ttlMs, disabled: !writable, onChange: function (event) { updateEnvSig("ttlMs", event.target.value); } })
|
|
840
|
-
),
|
|
841
|
-
React.createElement("div", { className: "cohub-field" },
|
|
842
|
-
React.createElement("label", { className: "cohub-label" }, t("envSigConfirmCount")),
|
|
843
|
-
React.createElement("input", { className: "cohub-input", type: "number", min: 1, step: 1, value: envSigDraft.confirmCount, disabled: !writable, onChange: function (event) { updateEnvSig("confirmCount", event.target.value); } })
|
|
844
|
-
)
|
|
845
|
-
)
|
|
846
|
-
),
|
|
847
|
-
error ? React.createElement("p", { className: "cohub-status cohub-error" }, t("failed") + error) : null,
|
|
848
|
-
saved ? React.createElement("p", { className: "cohub-status cohub-saved" }, t("saved")) : null,
|
|
849
|
-
React.createElement("div", { className: "cohub-actions" },
|
|
850
|
-
React.createElement("button", { type: "button", className: "cohub-button cohub-button-ghost", disabled: !dirty || saving, onClick: discard }, t("discard")),
|
|
851
|
-
React.createElement("button", { type: "button", className: "cohub-button cohub-button-primary", disabled: !dirty || saving || !writable, onClick: save }, t(saving ? "saving" : "save"))
|
|
852
|
-
)
|
|
853
|
-
);
|
|
854
|
-
}
|
|
855
|
-
|
|
856
112
|
function apply(ctx) {
|
|
857
|
-
installCss();
|
|
858
113
|
ctx.effect(function () {
|
|
859
114
|
return ctx.locale.register(NS, { zh: zh, en: en });
|
|
860
115
|
}, "cohub: settings dictionaries");
|
|
861
|
-
|
|
862
|
-
var scope = ctx.settingsScope.bind({ namespace: NS });
|
|
863
|
-
var remote = ctx.remote;
|
|
864
|
-
|
|
865
|
-
// alpha.2 后 settings.plugin.item slot 改成 keyed 类型(key = settings namespace);
|
|
866
|
-
// 按 .agents/notes/implemented/architecture/2026-08-12-plugin-owned-settings-surface.md,
|
|
867
|
-
// 用 key/locale 注册,不再声明 id/order,也不需要 slots.inject 第三参数。
|
|
868
|
-
ctx.slots.inject("settings.plugin.item", function () {
|
|
869
|
-
return ctx.slots.register({
|
|
870
|
-
name: "settings.plugin.item",
|
|
871
|
-
key: NS,
|
|
872
|
-
locale: NS,
|
|
873
|
-
inject: function () {
|
|
874
|
-
return { scope: scope, api: remote, t: ctx.locale.bind(NS), remote: remote };
|
|
875
|
-
}
|
|
876
|
-
}, CohubSettingsCard);
|
|
877
|
-
});
|
|
878
116
|
}
|
|
879
117
|
|
|
880
118
|
exports.apply = apply;
|
|
@@ -882,5 +120,3 @@ window.__ModuleLoader__.load({
|
|
|
882
120
|
return module.exports;
|
|
883
121
|
}
|
|
884
122
|
});
|
|
885
|
-
|
|
886
|
-
|
package/lib/index.js
CHANGED
|
@@ -1757,10 +1757,10 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
1757
1757
|
const contractText = contractResult.text;
|
|
1758
1758
|
let lastReason = "unknown";
|
|
1759
1759
|
let lastPartial = "";
|
|
1760
|
-
|
|
1760
|
+
const stallState = { last: null };
|
|
1761
1761
|
let retries = 0;
|
|
1762
1762
|
for (let attempt = 0;attempt <= retry.maxRetries; attempt++) {
|
|
1763
|
-
const stallNote =
|
|
1763
|
+
const stallNote = stallState.last ? ";停滞诊断:" + stallState.last.diagnostics : "";
|
|
1764
1764
|
const retryNote = attempt > 0 ? `
|
|
1765
1765
|
|
|
1766
1766
|
[重试 #` + attempt + "] 上一次执行中止,原因:" + lastReason + ";已完成部分:" + (lastPartial || "(无)") + stallNote + "。请从中断处继续,不要重复已完成步骤。" : "";
|
|
@@ -1829,7 +1829,7 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
1829
1829
|
if (ac?.signal.aborted) {
|
|
1830
1830
|
lastReason = "aborted";
|
|
1831
1831
|
lastPartial = "";
|
|
1832
|
-
|
|
1832
|
+
stallState.last = stallInfo;
|
|
1833
1833
|
if (!RETRYABLE.has(lastReason) || attempt >= retry.maxRetries)
|
|
1834
1834
|
break;
|
|
1835
1835
|
retries++;
|
|
@@ -1865,7 +1865,7 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
1865
1865
|
return contentText(outcome.output);
|
|
1866
1866
|
lastReason = String(outcome?.stopReason ?? "unknown");
|
|
1867
1867
|
lastPartial = contentText(outcome?.output ?? []).slice(0, 500);
|
|
1868
|
-
|
|
1868
|
+
stallState.last = stallInfo;
|
|
1869
1869
|
if (stallInfo && !stall.recoverable)
|
|
1870
1870
|
break;
|
|
1871
1871
|
if (!RETRYABLE.has(lastReason) || attempt >= retry.maxRetries)
|
|
@@ -1873,13 +1873,13 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
1873
1873
|
retries++;
|
|
1874
1874
|
await new Promise((r) => setTimeout(r, retry.retryDelayMs));
|
|
1875
1875
|
}
|
|
1876
|
-
const err = new Error('delegate: subagent stopped with reason "' + lastReason + '" after ' + retries + " retry(ies)" + (
|
|
1876
|
+
const err = new Error('delegate: subagent stopped with reason "' + lastReason + '" after ' + retries + " retry(ies)" + (stallState.last ? "; stalled: " + stallState.last.diagnostics : "") + "; partial: " + lastPartial);
|
|
1877
1877
|
err.cause = {
|
|
1878
1878
|
stopReason: lastReason,
|
|
1879
1879
|
partial: lastPartial,
|
|
1880
1880
|
skill: args.skill,
|
|
1881
1881
|
retries,
|
|
1882
|
-
...
|
|
1882
|
+
...stallState.last ? { stall: stallState.last } : {}
|
|
1883
1883
|
};
|
|
1884
1884
|
throw err;
|
|
1885
1885
|
}
|
|
@@ -2325,22 +2325,21 @@ ${r.result}
|
|
|
2325
2325
|
}
|
|
2326
2326
|
|
|
2327
2327
|
// src/index.ts
|
|
2328
|
-
import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
|
|
2329
2328
|
var Councillor = z.object({
|
|
2330
2329
|
name: z.string(),
|
|
2331
2330
|
provider: z.string(),
|
|
2332
2331
|
model: z.string(),
|
|
2333
|
-
prompt: z.string()
|
|
2332
|
+
prompt: z.string()
|
|
2334
2333
|
});
|
|
2335
2334
|
var SkillRoute = z.object({
|
|
2336
2335
|
name: z.string(),
|
|
2337
|
-
provider: z.string()
|
|
2338
|
-
model: z.string()
|
|
2339
|
-
maxTokens: z.number()
|
|
2336
|
+
provider: z.string(),
|
|
2337
|
+
model: z.string(),
|
|
2338
|
+
maxTokens: z.number()
|
|
2340
2339
|
});
|
|
2341
2340
|
var EnvContractConfig = z.object({
|
|
2342
2341
|
enabled: z.boolean().default(true),
|
|
2343
|
-
text: z.string()
|
|
2342
|
+
text: z.string()
|
|
2344
2343
|
}).default({});
|
|
2345
2344
|
var StallDetector = z.object({
|
|
2346
2345
|
enabled: z.boolean().default(false),
|
|
@@ -2362,7 +2361,7 @@ var EnvContractFacts = z.object({
|
|
|
2362
2361
|
topLevelAwait: z.boolean().default(true),
|
|
2363
2362
|
wallClockLimitMs: z.number().default(600000),
|
|
2364
2363
|
hasJobTracking: z.boolean().default(false)
|
|
2365
|
-
})
|
|
2364
|
+
});
|
|
2366
2365
|
var EnvSignatures = z.object({
|
|
2367
2366
|
use: z.union(["auto", "off", "manual"]).default("auto"),
|
|
2368
2367
|
ttlMs: z.number().default(604800000),
|
|
@@ -2380,14 +2379,13 @@ var Config = z.object({
|
|
|
2380
2379
|
councillors: z.array(Councillor).default([]),
|
|
2381
2380
|
councilTimeoutMs: z.number().default(COUNCIL_TIMEOUT_MS),
|
|
2382
2381
|
councilProvider: z.string().default("spawn"),
|
|
2383
|
-
skills: z.array(SkillRoute).default([]),
|
|
2382
|
+
skills: z.array(SkillRoute).default([]).volatile(),
|
|
2384
2383
|
delegateEnvContract: EnvContractConfig,
|
|
2385
|
-
delegateRetry: DelegateRetry,
|
|
2384
|
+
delegateRetry: DelegateRetry.volatile(),
|
|
2386
2385
|
envSignatures: EnvSignatures,
|
|
2387
|
-
schedule: ScheduleConfig,
|
|
2386
|
+
schedule: ScheduleConfig.volatile(),
|
|
2388
2387
|
installPresets: z.boolean().default(true)
|
|
2389
2388
|
});
|
|
2390
|
-
var COHUB_NS = settingsNamespace("cohub");
|
|
2391
2389
|
var CohubSettingsSchema = z.object({
|
|
2392
2390
|
skills: z.array(SkillRoute).default([]),
|
|
2393
2391
|
schedule: ScheduleConfig,
|
|
@@ -2424,20 +2422,12 @@ function apply(ctx, config) {
|
|
|
2424
2422
|
ctx.logger?.warn?.("cohub: agent preset 安装失败(忽略)", error);
|
|
2425
2423
|
}
|
|
2426
2424
|
}
|
|
2427
|
-
const
|
|
2428
|
-
skills: config.skills
|
|
2429
|
-
schedule: config.schedule,
|
|
2430
|
-
delegateRetry: config.delegateRetry
|
|
2431
|
-
};
|
|
2432
|
-
let currentSettings = () => entry;
|
|
2433
|
-
let currentSkills = () => entry.skills;
|
|
2434
|
-
installSettingsSection(ctx, COHUB_NS, CohubSettingsSchema, entry, {
|
|
2435
|
-
setSource: (src) => {
|
|
2436
|
-
currentSettings = () => src() ?? {};
|
|
2437
|
-
currentSkills = () => (src() ?? {}).skills ?? [];
|
|
2438
|
-
},
|
|
2439
|
-
onChange: () => {}
|
|
2425
|
+
const currentSettings = () => ({
|
|
2426
|
+
skills: config.skills.get(),
|
|
2427
|
+
schedule: config.schedule.get(),
|
|
2428
|
+
delegateRetry: config.delegateRetry.get()
|
|
2440
2429
|
});
|
|
2430
|
+
const currentSkills = () => config.skills.get();
|
|
2441
2431
|
const subagentsService = ctx.reflect?.get?.("subagents", false);
|
|
2442
2432
|
if (!subagentsService) {
|
|
2443
2433
|
throw new Error("cohub: delegate tool requires the subagents service (@deepseek-ai/dsh-subagent)");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cohub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "DeepSeek Harness 版 CoHub:中文智能体编排——双 preset 模式(co-orchestrator 纯调度 + cohub-cordis 创造模式)/ 12 技能(11 专职代理 + orchestrator)/ 多模型共识",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
},
|
|
28
28
|
"client": {
|
|
29
29
|
"inject": [
|
|
30
|
-
"@deepseek-ai/dsh-client-
|
|
31
|
-
"@deepseek-ai/dsh-client-locale",
|
|
32
|
-
"@deepseek-ai/dsh-client-runtime",
|
|
33
|
-
"@deepseek-ai/dsh-client-ui-settings",
|
|
34
|
-
"@deepseek-ai/dsh-api-remotes"
|
|
30
|
+
"@deepseek-ai/dsh-client-locale"
|
|
35
31
|
],
|
|
36
32
|
"platform": "web"
|
|
37
33
|
}
|
|
38
34
|
},
|
|
39
35
|
"scripts": {
|
|
40
|
-
"build": "bun run scripts/generate-skills.ts && bun run scripts/guard-schema.ts && bun build src/index.ts --outdir lib --target node --format esm --external @deepseek-ai/cordis --external @deepseek-ai/schemastery --external @deepseek-ai/dsh-tools --external @deepseek-ai/dsh-system-prompt --external @deepseek-ai/dsh-skill --external @deepseek-ai/dsh-home-paths
|
|
36
|
+
"build": "bun run scripts/generate-skills.ts && bun run scripts/guard-schema.ts && bun build src/index.ts --outdir lib --target node --format esm --external @deepseek-ai/cordis --external @deepseek-ai/schemastery --external @deepseek-ai/dsh-tools --external @deepseek-ai/dsh-system-prompt --external @deepseek-ai/dsh-skill --external @deepseek-ai/dsh-home-paths && bun build src/co-cordis-plugin.ts --outdir lib --target node --format esm --external @deepseek-ai/dsh-tools && bun run scripts/build-client.js",
|
|
41
37
|
"lint:schema": "bun run scripts/guard-schema.ts",
|
|
38
|
+
"test:runtime": "node test/runtime-0.2.ts",
|
|
39
|
+
"test:host": "node test/host-integration.ts",
|
|
40
|
+
"test:client": "node test/client-runtime-0.2.ts",
|
|
41
|
+
"typecheck:0.2": "bunx tsc --noEmit -p test/tsconfig.runtime-0.2.json",
|
|
42
42
|
"prepublishOnly": "npm run build",
|
|
43
43
|
"build:client": "bun run scripts/build-client.js",
|
|
44
44
|
"audit": "node scripts/audit-session.mjs"
|
|
@@ -46,20 +46,14 @@
|
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
48
48
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
49
|
-
"@deepseek-ai/dsh-system-prompt": "^0.
|
|
50
|
-
"@deepseek-ai/dsh-skill": "^0.
|
|
51
|
-
"@deepseek-ai/dsh-tools": "^0.
|
|
52
|
-
"@deepseek-ai/dsh-home-paths": "^0.
|
|
53
|
-
"@deepseek-ai/dsh-subagent": "^0.
|
|
54
|
-
"@deepseek-ai/dsh-
|
|
55
|
-
"@deepseek-ai/dsh-
|
|
56
|
-
"
|
|
57
|
-
"@deepseek-ai/dsh-api-remotes": "^0.1.0-rc.6",
|
|
58
|
-
"@deepseek-ai/dsh-client-connection": "^0.1.0-rc.6",
|
|
59
|
-
"@deepseek-ai/dsh-client-locale": "^0.1.0-rc.6",
|
|
60
|
-
"@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.6",
|
|
61
|
-
"@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.6",
|
|
62
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.6"
|
|
49
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.2",
|
|
50
|
+
"@deepseek-ai/dsh-skill": "^0.2.0-rc.2",
|
|
51
|
+
"@deepseek-ai/dsh-tools": "^0.2.0-rc.2",
|
|
52
|
+
"@deepseek-ai/dsh-home-paths": "^0.2.0-rc.2",
|
|
53
|
+
"@deepseek-ai/dsh-subagent": "^0.2.0-rc.2",
|
|
54
|
+
"@deepseek-ai/dsh-llm": "^0.2.0-rc.2",
|
|
55
|
+
"@deepseek-ai/dsh-session-projection": "^0.2.0-rc.2",
|
|
56
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.0-rc.2"
|
|
63
57
|
},
|
|
64
58
|
"peerDependenciesMeta": {
|
|
65
59
|
"@deepseek-ai/cordis": {
|
|
@@ -82,13 +76,21 @@
|
|
|
82
76
|
}
|
|
83
77
|
},
|
|
84
78
|
"devDependencies": {
|
|
85
|
-
"@deepseek-ai/cordis": "
|
|
86
|
-
"@deepseek-ai/schemastery": "
|
|
87
|
-
"@deepseek-ai/dsh-system-prompt": "
|
|
88
|
-
"@deepseek-ai/dsh-skill": "
|
|
89
|
-
"@deepseek-ai/dsh-tools": "
|
|
90
|
-
"@deepseek-ai/dsh-home-paths": "
|
|
91
|
-
"@deepseek-ai/dsh-
|
|
79
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
80
|
+
"@deepseek-ai/schemastery": "3.18.4",
|
|
81
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
|
|
82
|
+
"@deepseek-ai/dsh-skill": "0.2.0-rc.2",
|
|
83
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
84
|
+
"@deepseek-ai/dsh-home-paths": "0.2.0-rc.2",
|
|
85
|
+
"@deepseek-ai/dsh-subagent": "0.2.0-rc.2",
|
|
86
|
+
"@deepseek-ai/dsh-settings": "0.2.0-rc.2",
|
|
87
|
+
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
|
|
88
|
+
"@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",
|
|
89
|
+
"@deepseek-ai/dsh-config-editor": "0.2.0-rc.2",
|
|
90
|
+
"@deepseek-ai/cordis-plugin-loader": "1.0.5",
|
|
91
|
+
"@deepseek-ai/cordis-plugin-include": "1.0.9",
|
|
92
|
+
"@deepseek-ai/cordis-plugin-group": "1.0.4",
|
|
93
|
+
"@types/node": "^24.0.0"
|
|
92
94
|
},
|
|
93
95
|
"license": "MIT",
|
|
94
96
|
"keywords": [
|