dsh-cohub 0.10.5 → 0.11.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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-cohub
|
|
2
2
|
|
|
3
|
-
> 本文对应 **v0.
|
|
3
|
+
> 本文对应 **v0.11.1**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
4
4
|
|
|
5
5
|
DeepSeek Harness 版(对照 [OpenCode 版](../oh-my-opencode-cohub/)):中文智能体编排插件。
|
|
6
6
|
把「纯调度模式 + 13 个技能(12 个代理编排体系 + co-cordis 组合创作)+ 多模型共识 + 运行期调度韧性」移植到 DSH 原生能力之上。
|
|
@@ -9,7 +9,10 @@ DeepSeek Harness 版(对照 [OpenCode 版](../oh-my-opencode-cohub/)):中
|
|
|
9
9
|
|
|
10
10
|
### 1. 前置条件
|
|
11
11
|
|
|
12
|
-
宿主 DSH ≥ `0.2.0-rc.2
|
|
12
|
+
宿主 DSH ≥ `0.2.2-rc.1`(`@deepseek-ai/dsh-*` peer 依赖声明为 `^0.2.2-rc.1`,等价于 `>=0.2.2-rc.1 <0.3.0-0`;低于此版本时 npm 会因 peer 冲突拒绝安装,属预期行为)。不支持 DSH 0.1,以及 0.2.0 / 0.2.1 系列。
|
|
13
|
+
|
|
14
|
+
- 子代理读写硬隔离(per-child `agentPreset`)自 DSH `0.2.1` 起提供,已被上述下限涵盖,无需单独满足。
|
|
15
|
+
- `0.2.2-rc.1` 是 prerelease,版本走 npm dist-tag `next`(2026-11-04 发布);宿主自身要求 **Node ≥ 24.9.0**(`engines.node`),本地构建/运行前请先对齐 Node 版本。本包不单独声明 `engines.node`,Node 门槛以宿主为准。
|
|
13
16
|
|
|
14
17
|
### 2. 安装
|
|
15
18
|
|
|
@@ -84,7 +87,7 @@ cp presets/co-orchestrator/* ~/.dsh/.agent-presets/co-orchestrator/
|
|
|
84
87
|
> pwsh -File scripts/deploy-preset.ps1 -PresetName co-orchestrator
|
|
85
88
|
> ```
|
|
86
89
|
|
|
87
|
-
在 GUI 的 agent preset 选择器中切换。注意:**DSH 0.2.1 起支持 per-child `agentPreset`**(`SubagentStartRequest.agentPreset` 为一等字段,子代理经 `presets.mount()`
|
|
90
|
+
在 GUI 的 agent preset 选择器中切换。注意:**DSH 0.2.1 起支持 per-child `agentPreset`**(`SubagentStartRequest.agentPreset` 为一等字段,子代理经 `presets.mount()` 独立组装;本包 peer 要求的 `^0.2.2-rc.1` 已涵盖该能力),子代理不再继承父代理的 preset 组合与工具表——cohub 已用两个独立精简 preset(`cohub-subagent-readonly` / `cohub-subagent-write`)对子代理做**硬隔离**,故「绝不亲自操作文件」「只读代理不写文件」由工具面物理保证,不再只靠提示词。`toolFilter` 仍保留作为补充收窄手段(但它对子代理 own 层挂载的工具无效)。主代理侧「绝不亲自操作文件」继续由 co-orchestrator 技能在提示词层约束(与 OpenCode 原版一致)。
|
|
88
91
|
|
|
89
92
|
完整变更历史(含 v0.3.0–v0.8.2 全部条目)见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
90
93
|
|
|
@@ -150,7 +153,7 @@ revision 做冲突栅栏),因此改完保存即生效,无需重启。
|
|
|
150
153
|
留空 = 不覆盖;可填档位见上文
|
|
151
154
|
[按代理配置推理强度](#按代理配置推理强度reasoningeffort)。
|
|
152
155
|
|
|
153
|
-
`npm run test:client`(`test/client-runtime-0.2.ts`,
|
|
156
|
+
`npm run test:client`(`test/client-runtime-0.2.ts`,120 条断言)覆盖该页的渲染契约与写回契约:
|
|
154
157
|
`value=""` 继承占位项、目录加载中/失败降级手填、已存值不可用时 disabled 回显、只读连接、
|
|
155
158
|
revision 冲突拒绝保存、只写显式配置的代理等。
|
|
156
159
|
|
|
@@ -276,14 +279,18 @@ skills:
|
|
|
276
279
|
|
|
277
280
|
## 兼容性
|
|
278
281
|
|
|
279
|
-
宿主版本要求见「快速开始 → 前置条件」。`@deepseek-ai/
|
|
280
|
-
|
|
282
|
+
宿主版本要求见「快速开始 → 前置条件」。`@deepseek-ai/dsh-*` peer 声明为 `^0.2.2-rc.1`;`@deepseek-ai/cordis`
|
|
283
|
+
peer `^4.0.1` / `schemastery` peer `^3.18.4` **保持不变**——这两个区间已覆盖宿主内置的 cordis 4.1.0 与
|
|
284
|
+
schemastery 3.19.0(非 prerelease,无 prerelease 元组匹配问题,故不需要随宿主一起抬)。
|
|
285
|
+
测试 devDependencies **精确固定** `4.1.0` / `3.19.0`(与宿主内置一致;`@deepseek-ai/dsh-*` 侧则精确固定
|
|
286
|
+
`0.2.2-rc.1`,与 peer 下限同版)——lock 解析到最新不代表宿主实测,以宿主为准:
|
|
281
287
|
|
|
282
288
|
- **0.1 的 settings namespace 机制已移除**:`installSettingsSection` / `settingsNamespace` 在
|
|
283
289
|
dsh-settings 0.2 已删除。本插件不再注册 `cohub` namespace,改为 Config 的三个动态字段标
|
|
284
290
|
`.volatile()`(见上节)。`settings.yaml` 的 `cohub.*` 段**不会被自动迁移**(旧 importer 是否
|
|
285
291
|
支持自定义 namespace 未证实,明确不触发),请通过设置页或 `cordis.patch.yml` 重新配置。
|
|
286
292
|
- **不兼容 DSH 0.1**:宿主版本要求见「快速开始 → 前置条件」(0.1 宿主上 npm 会拒绝 peer 冲突,属预期行为)。
|
|
293
|
+
同理,**0.2.0 / 0.2.1 及全部 `0.2.2-*` 早期 rc 也已不在支持范围**——peer 下限是 `0.2.2-rc.1`,低于它一律按 peer 冲突拒绝。
|
|
287
294
|
- **验证入口**:`npm run test:runtime`(`test/runtime-0.2.ts`,真实 schemastery/Volatile/defineTool
|
|
288
295
|
契约 + 真实 cordis 挂载,离线 stub 子代理)、`npm run test:host`(`test/host-integration.ts`,
|
|
289
296
|
真实 Loader + entry.update volatile 提交 + SettingsForms.describe 投影 + 真实 subagents 服务
|
|
@@ -292,6 +299,7 @@ skills:
|
|
|
292
299
|
(`test/types/runtime-0.2.ts`,strict 编译检查公共边界与真实 DSH 0.2 导出)。完整宿主链路
|
|
293
300
|
(真实 spawn/fork transport 的进程内实现、真实 LLM provider、preset 树真实挂载)由宿主集成验证覆盖,
|
|
294
301
|
单测不冒称完全覆盖。
|
|
302
|
+
- **continuable 子代理冷恢复后回到父 preset 全量工具**:`toolFilter` 不进 subagent descriptor,冷恢复(进程重启后接续)时子代理回到父 preset 的完整工具面。因此**工具隔离主要靠 `agentPreset` 承担**(`cohub-subagent-readonly` / `cohub-subagent-write`),不要把 `toolFilter` 当作安全边界。
|
|
295
303
|
|
|
296
304
|
### 环境契约持久化
|
|
297
305
|
|
|
@@ -421,7 +429,7 @@ presets/
|
|
|
421
429
|
cohub-subagent-write/ 子代理可写 preset(工具面硬隔离)
|
|
422
430
|
test/
|
|
423
431
|
unit.ts 基础集成
|
|
424
|
-
client-runtime-0.2.ts 设置页渲染 / 写回契约(
|
|
432
|
+
client-runtime-0.2.ts 设置页渲染 / 写回契约(120 条断言)
|
|
425
433
|
delegate-p1.ts P1 环境契约注入 + 重试 + 模型回退
|
|
426
434
|
stall-p3.ts 停滞检测
|
|
427
435
|
schedule-p3.ts 调度参数
|
package/lib/index.js
CHANGED
|
@@ -304,17 +304,19 @@ var COHUB_SKILLS = [
|
|
|
304
304
|
**第二层 · 代理之间**:可独立执行验收且无实依赖/写冲突的工作单元 → 多个代理并行(单批 ≤ \`schedule.maxParallelBatch\`,缺省 3)。
|
|
305
305
|
|
|
306
306
|
### delegate_batch(批量并行,信息收集类任务首选)
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
**参数形状(硬性,写错直接校验失败)**:
|
|
308
|
+
\`\`\`js
|
|
309
|
+
delegate_batch({ tasks: [
|
|
310
|
+
{ id: "可选", skill: "co-fixer", prompt: "自包含任务书" }, // 只允许这 3 个键
|
|
311
|
+
]})
|
|
312
|
+
\`\`\`
|
|
313
|
+
- 每个 task **只有 3 个键**:\`id\`(可选) / \`skill\`(必填) / \`prompt\`(必填)。多写任何键(如 \`skill_x\`、\`agent\`、\`name\`、\`timeout\`)→ 整批 \`additionalProperties: false\` 拒绝,一个都不会启动。
|
|
314
|
+
- 漏 \`skill\` → \`missing required property "skill"\`,整批拒绝。
|
|
315
|
+
- \`skill\` 必须取 13 个合法值之一:co-oracle / co-explorer / co-librarian / co-designer / co-fixer / co-observer / co-council / co-rule-user / co-rule-project / co-rule-app / co-planner / co-cordis(co-orchestrator 是主代理自己,一般委派用其余 12 个)。填了无效名 → 该 task 单独返回 error(不拖垮同批),但**不会**静默降级,务必用正确名。
|
|
316
|
+
- 想标注用途时写进 \`id\`(如 \`id: "analyze-conflicts"\`),**不要自造字段名**。
|
|
317
|
+
|
|
318
|
+
一次工具调用内部并行派发 N 个无依赖任务(Promise.allSettled 真正并行),避免 agent loop 将多个 tool_use 串行化——实测本环境同消息多 tool_use 很少真正并发。**≥2 个无依赖任务(尤其信息收集/探索)优先用一次 delegate_batch**。**同文件写冲突不能入同一批(需串行);独立只读同文件可并行**。
|
|
309
319
|
- 特性:每 task 独立 AbortController 超时主动中止;只尝试一次(不重试),由墙钟预算兜底;父级中止全部取消;返回 { status: completed/failed/error, result, error }。
|
|
310
|
-
- 示例:
|
|
311
|
-
\`\`\`js
|
|
312
|
-
delegate_batch({ tasks: [
|
|
313
|
-
{ id: "explore-auth", skill: "co-explorer", prompt: "搜索 src/auth/ 下认证相关文件" },
|
|
314
|
-
{ id: "fix-login", skill: "co-fixer", prompt: "修复 src/auth/login.ts 的类型错误" },
|
|
315
|
-
{ id: "review-api", skill: "co-oracle", prompt: "审查 src/api/routes.ts 安全问题" },
|
|
316
|
-
]})
|
|
317
|
-
\`\`\`
|
|
318
320
|
- 与 delegate 对比:单任务 / 需重试 / 需停滞检测 → delegate;批量并行独立任务 → delegate_batch;单个长任务(>3 分钟,中途还要干别的)→ delegate + \`background: true\`。
|
|
319
321
|
|
|
320
322
|
### 并行派发纪律(原则 + 参数,禁止超预算大并行)
|
|
@@ -326,6 +328,12 @@ var COHUB_SKILLS = [
|
|
|
326
328
|
- **批间自适应**:按上批实际观测人工判断本批大小——高错误率/已超时 → 缩到 1-2;运行干净 → 放宽到上限。原 \`cohub.schedule.adaptiveBatch\` 已删除(死参数),勿再引用。
|
|
327
329
|
- **中止处理**:先判原因是否可重试(被中止/超时可重试;审批拒绝等不可);重试时 prompt 末尾注明「上次原因 + 已完成部分,从中断处继续」,不整单重跑。
|
|
328
330
|
|
|
331
|
+
### 通道前置检查(bootstrap 检查)
|
|
332
|
+
**适用条件**:待修对象与执行工具是同一套基础设施(改委派系统 / 改停滞检测器 / 改构建链 / 改技能加载器)。此时 bug 会顺手杀掉用来修它的工具,规划第一步不是拆任务,而是「**测通道 + 先止血**」:
|
|
333
|
+
- **先探针再规划**:先派一个极小探针任务(≤2 步、仅 1 次 read)验证子代理能正常返回,探针通过后再规划正式任务。
|
|
334
|
+
- **停手阈值**:探针失败,或连续 2 次出现基础设施类中止(stalled / timeout / aborted)→ **立即停手**,改走配置层止血或请用户先行修复,不得继续委派。理由:修工具的工具正在故障时,继续委派只会放大损失;且配置层往往能先把通道恢复回来。
|
|
335
|
+
- **诊断 raced abort(result 未结算)时不可假定子代理未执行**:必须用 \`git status\` / \`git diff\` 核对实际落盘副作用——被中止的委派可能已改完文件而仅结果丢失,盲目重派会重复改动或覆盖已完成的工作。
|
|
336
|
+
|
|
329
337
|
### 委派 prompt 信息优先级
|
|
330
338
|
通用环境原则(自包含/先验证再批量/错误可回传) > 事实(绝对路径/锚点/清单/已知约束) > 输出约束(格式/长度/超时) > 边界(只读/禁止/不擅自扩大)。具体环境事实由探测/注入提供。
|
|
331
339
|
|
|
@@ -432,8 +440,8 @@ Orchestrator 禁止使用任何文件/代码操作工具(read、grep、glob、
|
|
|
432
440
|
|
|
433
441
|
**硬约束:配置类文件要标并发风险**(**仅写类子代理适用**;只读类不改文件,本条对它们无意义)——委派改动下列文件时,任务书必须写一句「该文件可能有并发写者(GUI 插件市场 / 其他插件会毫秒级回写),改完必须复查**全量 diff** 而不能只看目标行」,并要求按「并发写与 FS_STALE_VERSION」纪律处理:
|
|
434
442
|
- \`~/.dsh/profiles/*/package.json\`(插件市场回写)
|
|
435
|
-
- \`~/.dsh/profiles/*/cordis.patch.yml
|
|
436
|
-
- \`~/.dsh/.agent-presets
|
|
443
|
+
- \`~/.dsh/profiles/*/cordis.patch.yml\`(patch 层,插件市场与多个插件都可能毫秒级回写)
|
|
444
|
+
- \`~/.dsh/.agent-presets/**\`(目录式 preset 布局,cohub 自身会重装;新版宿主亦支持 \`dsh-agent-preset\` 声明行,动手前先确认该 preset 属于哪种形态)
|
|
437
445
|
- \`.dsh-market/**\`、\`settings.*\` 等状态文件
|
|
438
446
|
|
|
439
447
|
**时间预算纪律(硬性四条):**
|
|
@@ -465,6 +473,8 @@ Orchestrator 禁止使用任何文件/代码操作工具(read、grep、glob、
|
|
|
465
473
|
□ **本轮需要同时发起多个独立操作吗?** → 有 2+ 个无依赖且不冲突任务 → 按拆批规则单条消息 N 个 delegate tool_use 并发(单批 ≤ maxParallelBatch 缺省 3,超预算分批 job 轮询或前台逐批降级),不得逐个串行也不得超预算整批并行;数据依赖/同文件写冲突 → 串行分批;仅 1 个任务(确认无其他可并行)→ 可单个发起
|
|
466
474
|
□ **本轮是否提议新增能力?** → 先过规则 4 三问(低频/重叠/为用而用),任一不过不新增
|
|
467
475
|
□ **本轮 delegate 参数是否完整?** → 每个 delegate 都有 skill(必填)与 prompt(必填,自包含:目标/路径/约束/输出格式),skill 值在可用代理列表中
|
|
476
|
+
□ **delegate_batch 每个 task 是否恰好只有 id/skill/prompt 三个键、且 skill 取自 13 个合法值?** → 多键或拼错会导致整批/该 task 失败
|
|
477
|
+
□ **本轮待修对象是否与执行工具同属一套基础设施?** → 是则先跑通道探针,失败则停手止血,不得继续委派
|
|
468
478
|
</自检清单>
|
|
469
479
|
`
|
|
470
480
|
},
|
|
@@ -1180,7 +1190,7 @@ Orchestrator 会在 prompt 中明确指定:
|
|
|
1180
1190
|
可用:read / glob / grep / edit / write / pwsh(构建、测试、git)。
|
|
1181
1191
|
主战场:
|
|
1182
1192
|
- 插件仓库源码(\`src/\`、\`cordis.patch.yml\`、\`package.json\` 的 \`dsh.bundle.patch\`)
|
|
1183
|
-
- 组合层:profile 的 \`cordis.patch.yml\`(在 bundle patch **之后**应用)、\`~/.dsh/.agent-presets/<id>/agent.cordis.yml\`
|
|
1193
|
+
- 组合层:profile 的 \`cordis.patch.yml\`(在 bundle patch **之后**应用)、\`~/.dsh/.agent-presets/<id>/agent.cordis.yml\`(目录式 preset 布局;新版宿主已改用 \`dsh-agent-preset\` 声明行,动手前先确认目标 preset 属于哪一种形态)
|
|
1184
1194
|
- 运行时产物:\`lib/\` —— **改完源码必须重建(如 \`bun run build\`),否则运行时加载的还是旧产物**
|
|
1185
1195
|
|
|
1186
1196
|
禁止:改动部署自带的 preset 安装目录(升级会覆盖它;要改行为就把组合复制成新 preset 再改副本);扩大范围去改与本任务无关的文件。
|
|
@@ -1871,7 +1881,7 @@ function bindTypertRemote(service, serviceKey, options = {}) {
|
|
|
1871
1881
|
const namespace = options.namespace ?? serviceKey;
|
|
1872
1882
|
validateName("namespace", namespace);
|
|
1873
1883
|
const ctx = Reflect.get(service, "ctx");
|
|
1874
|
-
if (ctx
|
|
1884
|
+
if (Context.is(ctx))
|
|
1875
1885
|
provideInvocationAccessor(ctx);
|
|
1876
1886
|
return Object.freeze({
|
|
1877
1887
|
service,
|
|
@@ -1896,23 +1906,47 @@ function provideInvocationAccessor(ctx) {
|
|
|
1896
1906
|
function Remote(methodExportOrOptions, context) {
|
|
1897
1907
|
if (typeof methodExportOrOptions === "string") {
|
|
1898
1908
|
validateName("Remote export name", methodExportOrOptions);
|
|
1899
|
-
return remoteDecorator({ kind: "direct" },
|
|
1900
|
-
}
|
|
1901
|
-
if (typeof methodExportOrOptions === "object") {
|
|
1902
|
-
if (remoteOptionMode(methodExportOrOptions) !== "stream" || Reflect.ownKeys(methodExportOrOptions).length !== 1)
|
|
1903
|
-
throw new TypeError('typert-protocol: Remote options must contain exactly mode: "stream"');
|
|
1904
|
-
return remoteDecorator({ kind: "direct" }, "stream");
|
|
1909
|
+
return remoteDecorator({ kind: "direct" }, { exportName: methodExportOrOptions });
|
|
1905
1910
|
}
|
|
1911
|
+
if (typeof methodExportOrOptions === "object")
|
|
1912
|
+
return remoteDecorator({ kind: "direct" }, markerOptions(methodExportOrOptions, REMOTE_OPTION_KEYS, 'Remote options require name, mode: "stream", or resources'));
|
|
1906
1913
|
if (context === undefined)
|
|
1907
1914
|
throw new TypeError("typert-protocol: Remote decorator context is missing");
|
|
1908
1915
|
addMarkerInitializer(context, { kind: "direct" });
|
|
1909
1916
|
}
|
|
1910
|
-
|
|
1911
|
-
|
|
1917
|
+
var REMOTE_OPTION_KEYS = new Set([
|
|
1918
|
+
"name",
|
|
1919
|
+
"mode",
|
|
1920
|
+
"resources"
|
|
1921
|
+
]);
|
|
1922
|
+
var REMOTE_SCOPE_OPTION_KEYS = new Set(["name", "resources"]);
|
|
1923
|
+
function markerOptions(options, accepted, requirement) {
|
|
1924
|
+
const keys = Reflect.ownKeys(options);
|
|
1925
|
+
if (keys.length === 0 || keys.some((key) => typeof key !== "string" || !accepted.has(key)) || Object.hasOwn(options, "mode") && options.mode !== "stream")
|
|
1926
|
+
throw new TypeError(`typert-protocol: ${requirement}`);
|
|
1927
|
+
const { mode, name, resources } = options;
|
|
1928
|
+
if (name !== undefined)
|
|
1929
|
+
validateName("Remote export name", name);
|
|
1930
|
+
return {
|
|
1931
|
+
...mode === undefined ? {} : { mode },
|
|
1932
|
+
...name === undefined ? {} : { exportName: name },
|
|
1933
|
+
...resources === undefined ? {} : { resources: resourceReaders(resources) }
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
function resourceReaders(resources) {
|
|
1937
|
+
const readers = {};
|
|
1938
|
+
for (const [kind, reader] of Object.entries(resources)) {
|
|
1939
|
+
if (typeof reader !== "function")
|
|
1940
|
+
throw new TypeError(`typert-protocol: Remote resource reader "${kind}" must be a function`);
|
|
1941
|
+
readers[kind] = reader;
|
|
1942
|
+
}
|
|
1943
|
+
if (Object.keys(readers).length === 0)
|
|
1944
|
+
throw new TypeError("typert-protocol: Remote resources require at least one reader");
|
|
1945
|
+
return Object.freeze(readers);
|
|
1912
1946
|
}
|
|
1913
|
-
function remoteDecorator(invocation,
|
|
1947
|
+
function remoteDecorator(invocation, options = {}) {
|
|
1914
1948
|
return function(_method, context) {
|
|
1915
|
-
addMarkerInitializer(context, invocation,
|
|
1949
|
+
addMarkerInitializer(context, invocation, options);
|
|
1916
1950
|
};
|
|
1917
1951
|
}
|
|
1918
1952
|
function readRemoteMethodDescriptor(prototype) {
|
|
@@ -1930,7 +1964,7 @@ function readRemoteMethodDescriptor(prototype) {
|
|
|
1930
1964
|
throw new TypeError("typert-protocol: Remote method descriptor methods must be an array");
|
|
1931
1965
|
return descriptor;
|
|
1932
1966
|
}
|
|
1933
|
-
function addMarkerInitializer(context, invocation,
|
|
1967
|
+
function addMarkerInitializer(context, invocation, options = {}) {
|
|
1934
1968
|
if (context.private || context.static || typeof context.name !== "string")
|
|
1935
1969
|
throw new TypeError("typert-protocol: Remote decorators require a public instance method with a string name");
|
|
1936
1970
|
const method = context.name;
|
|
@@ -1938,20 +1972,21 @@ function addMarkerInitializer(context, invocation, mode, exportName) {
|
|
|
1938
1972
|
const prototype = Object.getPrototypeOf(this);
|
|
1939
1973
|
if (prototype === null)
|
|
1940
1974
|
throw new TypeError(`typert-protocol: cannot mark Remote method "${method}" on an object without a prototype`);
|
|
1941
|
-
mark(prototype, method, invocation,
|
|
1975
|
+
mark(prototype, method, invocation, options);
|
|
1942
1976
|
});
|
|
1943
1977
|
}
|
|
1944
|
-
function mark(prototype, method, invocation, mode, exportName) {
|
|
1978
|
+
function mark(prototype, method, invocation, { mode, exportName, resources }) {
|
|
1945
1979
|
const descriptor = readRemoteMethodDescriptor(prototype);
|
|
1946
1980
|
const marker = Object.freeze({
|
|
1947
1981
|
method,
|
|
1948
1982
|
...exportName === undefined || exportName === method ? {} : { exportName },
|
|
1949
1983
|
...mode === undefined ? {} : { mode },
|
|
1950
|
-
invocation: Object.freeze(invocation)
|
|
1984
|
+
invocation: Object.freeze(invocation),
|
|
1985
|
+
...resources === undefined ? {} : { resources }
|
|
1951
1986
|
});
|
|
1952
1987
|
const current = descriptor?.methods.find((candidate) => candidate.method === method);
|
|
1953
1988
|
if (current !== undefined) {
|
|
1954
|
-
if (current.exportName === marker.exportName && current.mode === marker.mode && sameInvocation(current.invocation, invocation))
|
|
1989
|
+
if (current.exportName === marker.exportName && current.mode === marker.mode && current.resources === marker.resources && sameInvocation(current.invocation, invocation))
|
|
1955
1990
|
return;
|
|
1956
1991
|
throw new Error(`typert-protocol: Remote method "${method}" has conflicting invocation markers`);
|
|
1957
1992
|
}
|
|
@@ -1976,6 +2011,593 @@ function validateName(subject, value) {
|
|
|
1976
2011
|
}
|
|
1977
2012
|
|
|
1978
2013
|
// node_modules/@deepseek-ai/dsh-util-values/lib/index.js
|
|
2014
|
+
var SIMPLE_ESCAPES = {
|
|
2015
|
+
'"': '"',
|
|
2016
|
+
"\\": "\\",
|
|
2017
|
+
"/": "/",
|
|
2018
|
+
b: "\b",
|
|
2019
|
+
f: "\f",
|
|
2020
|
+
n: `
|
|
2021
|
+
`,
|
|
2022
|
+
r: "\r",
|
|
2023
|
+
t: "\t"
|
|
2024
|
+
};
|
|
2025
|
+
var CONTENT_ESCAPE = /[\\\u0000-\u001f]/u;
|
|
2026
|
+
function isWhitespace(c) {
|
|
2027
|
+
return c === " " || c === `
|
|
2028
|
+
` || c === "\r" || c === "\t";
|
|
2029
|
+
}
|
|
2030
|
+
function isHex(c) {
|
|
2031
|
+
return c >= "0" && c <= "9" || c >= "a" && c <= "f" || c >= "A" && c <= "F";
|
|
2032
|
+
}
|
|
2033
|
+
var PartialArguments = class PartialArguments {
|
|
2034
|
+
static EMPTY = PartialArguments.fromObject({});
|
|
2035
|
+
static fromText(text) {
|
|
2036
|
+
const view = new PartialArguments;
|
|
2037
|
+
view.append(text);
|
|
2038
|
+
view.sealed = true;
|
|
2039
|
+
return view;
|
|
2040
|
+
}
|
|
2041
|
+
static fromObject(value) {
|
|
2042
|
+
const view = new PartialArguments;
|
|
2043
|
+
view.object = typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
2044
|
+
view.sealed = true;
|
|
2045
|
+
return view;
|
|
2046
|
+
}
|
|
2047
|
+
chunks = [];
|
|
2048
|
+
object;
|
|
2049
|
+
sealed = false;
|
|
2050
|
+
#ends = [];
|
|
2051
|
+
#size = 0;
|
|
2052
|
+
#consumed = 0;
|
|
2053
|
+
#mode = "root";
|
|
2054
|
+
#escape = false;
|
|
2055
|
+
#keyStart = 0;
|
|
2056
|
+
#keyEscaped = false;
|
|
2057
|
+
#key = "";
|
|
2058
|
+
#current = null;
|
|
2059
|
+
#nestedEnds = [];
|
|
2060
|
+
#nestedInString = false;
|
|
2061
|
+
#invalidAt;
|
|
2062
|
+
#invalidValue = false;
|
|
2063
|
+
#entries = /* @__PURE__ */ new Map;
|
|
2064
|
+
#order = [];
|
|
2065
|
+
#reads = /* @__PURE__ */ new Map;
|
|
2066
|
+
get isSealed() {
|
|
2067
|
+
return this.sealed;
|
|
2068
|
+
}
|
|
2069
|
+
get invalid() {
|
|
2070
|
+
this.scan();
|
|
2071
|
+
return this.#mode === "invalid" || this.#invalidValue;
|
|
2072
|
+
}
|
|
2073
|
+
append(fragment) {
|
|
2074
|
+
if (this.sealed)
|
|
2075
|
+
throw new Error("PartialArguments: cannot append to a sealed view");
|
|
2076
|
+
if (fragment.length === 0)
|
|
2077
|
+
return;
|
|
2078
|
+
this.chunks.push(fragment);
|
|
2079
|
+
this.#size += fragment.length;
|
|
2080
|
+
this.#ends.push(this.#size);
|
|
2081
|
+
}
|
|
2082
|
+
settle(text) {
|
|
2083
|
+
if (this.object !== undefined || text.length !== this.#size)
|
|
2084
|
+
return PartialArguments.fromText(text);
|
|
2085
|
+
let offset = 0;
|
|
2086
|
+
for (const chunk of this.chunks) {
|
|
2087
|
+
if (!text.startsWith(chunk, offset))
|
|
2088
|
+
return PartialArguments.fromText(text);
|
|
2089
|
+
offset += chunk.length;
|
|
2090
|
+
}
|
|
2091
|
+
this.chunks = text.length === 0 ? [] : [text];
|
|
2092
|
+
this.#ends = text.length === 0 ? [] : [text.length];
|
|
2093
|
+
this.sealed = true;
|
|
2094
|
+
return this;
|
|
2095
|
+
}
|
|
2096
|
+
refresh() {
|
|
2097
|
+
if (this.#reads.size === 0)
|
|
2098
|
+
return false;
|
|
2099
|
+
this.scan();
|
|
2100
|
+
let changed = false;
|
|
2101
|
+
let completions = false;
|
|
2102
|
+
for (const read of this.#reads.values()) {
|
|
2103
|
+
if (read.completion) {
|
|
2104
|
+
completions = true;
|
|
2105
|
+
continue;
|
|
2106
|
+
}
|
|
2107
|
+
changed = this.refreshRead(read) || changed;
|
|
2108
|
+
}
|
|
2109
|
+
if (completions) {
|
|
2110
|
+
for (const read of this.#reads.values())
|
|
2111
|
+
if (read.completion)
|
|
2112
|
+
changed = this.refreshRead(read) || changed;
|
|
2113
|
+
}
|
|
2114
|
+
if (this.sealed)
|
|
2115
|
+
this.#reads.clear();
|
|
2116
|
+
return changed;
|
|
2117
|
+
}
|
|
2118
|
+
refreshRead(read) {
|
|
2119
|
+
const now = read.answer();
|
|
2120
|
+
if (Object.is(now, read.last))
|
|
2121
|
+
return false;
|
|
2122
|
+
read.last = now;
|
|
2123
|
+
return true;
|
|
2124
|
+
}
|
|
2125
|
+
closed() {
|
|
2126
|
+
return this.remember("closed", "", () => this.closedNow());
|
|
2127
|
+
}
|
|
2128
|
+
keys() {
|
|
2129
|
+
return this.remember("keys", "", () => this.keysNow(), (keys) => keys.length);
|
|
2130
|
+
}
|
|
2131
|
+
has(key) {
|
|
2132
|
+
return this.remember("has", key, () => this.hasNow(key));
|
|
2133
|
+
}
|
|
2134
|
+
complete(key) {
|
|
2135
|
+
return this.remember("complete", key, () => this.completeNow(key));
|
|
2136
|
+
}
|
|
2137
|
+
stringLength(key, options) {
|
|
2138
|
+
const step = Math.max(1, Math.floor(options?.step ?? 1));
|
|
2139
|
+
const offset = options?.offset ?? 0;
|
|
2140
|
+
return this.remember(`length:${step}:${offset}`, key, () => this.lengthNow(key), (length) => length === undefined ? undefined : Math.ceil((length + offset) / step));
|
|
2141
|
+
}
|
|
2142
|
+
stringExceeds(key, maxLength) {
|
|
2143
|
+
const limit = Math.max(0, Math.floor(maxLength));
|
|
2144
|
+
return this.remember(`exceeds:${limit}`, key, () => (this.lengthNow(key, limit + 1) ?? 0) > limit);
|
|
2145
|
+
}
|
|
2146
|
+
text(key) {
|
|
2147
|
+
return this.remember("text", key, () => this.textNow(key));
|
|
2148
|
+
}
|
|
2149
|
+
textPrefix(key, maxLength) {
|
|
2150
|
+
const limit = Math.max(1, Math.floor(maxLength));
|
|
2151
|
+
return this.remember(`prefix:${limit}`, key, () => this.textPrefixNow(key, limit));
|
|
2152
|
+
}
|
|
2153
|
+
value(key) {
|
|
2154
|
+
return this.remember("value", key, () => this.valueNow(key));
|
|
2155
|
+
}
|
|
2156
|
+
remember(kind, key, read, comparison) {
|
|
2157
|
+
this.scan();
|
|
2158
|
+
const result = read();
|
|
2159
|
+
if (!this.sealed) {
|
|
2160
|
+
const id = `${kind}/${key}`;
|
|
2161
|
+
if (!this.#reads.has(id))
|
|
2162
|
+
this.#reads.set(id, {
|
|
2163
|
+
completion: kind === "complete",
|
|
2164
|
+
answer: comparison === undefined ? read : () => comparison(read()),
|
|
2165
|
+
last: comparison === undefined ? result : comparison(result)
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
return result;
|
|
2169
|
+
}
|
|
2170
|
+
closedNow() {
|
|
2171
|
+
return this.sealed || this.#mode === "closed" || this.#mode === "invalid";
|
|
2172
|
+
}
|
|
2173
|
+
keysNow() {
|
|
2174
|
+
return this.object === undefined ? this.#order : Object.keys(this.object);
|
|
2175
|
+
}
|
|
2176
|
+
hasNow(key) {
|
|
2177
|
+
return this.object === undefined ? this.#entries.has(key) : Object.hasOwn(this.object, key);
|
|
2178
|
+
}
|
|
2179
|
+
completeNow(key) {
|
|
2180
|
+
if (this.object !== undefined)
|
|
2181
|
+
return Object.hasOwn(this.object, key);
|
|
2182
|
+
const entry = this.#entries.get(key);
|
|
2183
|
+
return entry !== undefined && entry.end >= 0 && (entry.kind === "string" ? entry.invalidAt === undefined : !entry.invalid);
|
|
2184
|
+
}
|
|
2185
|
+
lengthNow(key, limit = Number.POSITIVE_INFINITY) {
|
|
2186
|
+
if (this.object !== undefined) {
|
|
2187
|
+
const field = Object.hasOwn(this.object, key) ? this.object[key] : undefined;
|
|
2188
|
+
return typeof field === "string" ? field.length : undefined;
|
|
2189
|
+
}
|
|
2190
|
+
const entry = this.#entries.get(key);
|
|
2191
|
+
if (entry?.kind !== "string")
|
|
2192
|
+
return;
|
|
2193
|
+
if (entry.text !== undefined && entry.text.at === entry.end)
|
|
2194
|
+
return entry.text.length;
|
|
2195
|
+
const read = entry.length ??= {
|
|
2196
|
+
at: entry.start,
|
|
2197
|
+
length: 0,
|
|
2198
|
+
text: ""
|
|
2199
|
+
};
|
|
2200
|
+
this.readString(entry, read, limit, false);
|
|
2201
|
+
return read.length;
|
|
2202
|
+
}
|
|
2203
|
+
textNow(key) {
|
|
2204
|
+
if (this.object !== undefined) {
|
|
2205
|
+
const field = Object.hasOwn(this.object, key) ? this.object[key] : undefined;
|
|
2206
|
+
return typeof field === "string" ? field : undefined;
|
|
2207
|
+
}
|
|
2208
|
+
const entry = this.#entries.get(key);
|
|
2209
|
+
if (entry?.kind !== "string")
|
|
2210
|
+
return;
|
|
2211
|
+
if (entry.text === undefined && entry.end >= 0 && entry.needsDecoding && entry.invalidAt === undefined) {
|
|
2212
|
+
let text;
|
|
2213
|
+
try {
|
|
2214
|
+
text = JSON.parse(`"${this.slice(entry.start, entry.end)}"`);
|
|
2215
|
+
} catch (_error) {}
|
|
2216
|
+
if (text !== undefined)
|
|
2217
|
+
entry.text = {
|
|
2218
|
+
at: entry.end,
|
|
2219
|
+
length: text.length,
|
|
2220
|
+
text
|
|
2221
|
+
};
|
|
2222
|
+
}
|
|
2223
|
+
const read = entry.text ??= {
|
|
2224
|
+
at: entry.start,
|
|
2225
|
+
length: 0,
|
|
2226
|
+
text: ""
|
|
2227
|
+
};
|
|
2228
|
+
this.readString(entry, read, Number.POSITIVE_INFINITY, true);
|
|
2229
|
+
return read.text;
|
|
2230
|
+
}
|
|
2231
|
+
textPrefixNow(key, maxLength) {
|
|
2232
|
+
if (this.object !== undefined) {
|
|
2233
|
+
const field = Object.hasOwn(this.object, key) ? this.object[key] : undefined;
|
|
2234
|
+
return typeof field === "string" ? field.slice(0, maxLength) : undefined;
|
|
2235
|
+
}
|
|
2236
|
+
const entry = this.#entries.get(key);
|
|
2237
|
+
if (entry?.kind !== "string")
|
|
2238
|
+
return;
|
|
2239
|
+
const prefixes = entry.prefixes ??= /* @__PURE__ */ new Map;
|
|
2240
|
+
let read = prefixes.get(maxLength);
|
|
2241
|
+
if (read === undefined) {
|
|
2242
|
+
read = {
|
|
2243
|
+
at: entry.start,
|
|
2244
|
+
length: 0,
|
|
2245
|
+
text: ""
|
|
2246
|
+
};
|
|
2247
|
+
prefixes.set(maxLength, read);
|
|
2248
|
+
}
|
|
2249
|
+
this.readString(entry, read, maxLength, true);
|
|
2250
|
+
return read.text;
|
|
2251
|
+
}
|
|
2252
|
+
valueNow(key) {
|
|
2253
|
+
if (this.object !== undefined) {
|
|
2254
|
+
if (!Object.hasOwn(this.object, key))
|
|
2255
|
+
return;
|
|
2256
|
+
const field = this.object[key];
|
|
2257
|
+
return typeof field === "string" ? undefined : field;
|
|
2258
|
+
}
|
|
2259
|
+
const entry = this.#entries.get(key);
|
|
2260
|
+
if (entry?.kind !== "value" || entry.end < 0 || entry.invalid)
|
|
2261
|
+
return;
|
|
2262
|
+
if (entry.parsed === undefined)
|
|
2263
|
+
try {
|
|
2264
|
+
entry.parsed = JSON.parse(this.slice(entry.start, entry.end));
|
|
2265
|
+
} catch (_error) {
|
|
2266
|
+
entry.invalid = true;
|
|
2267
|
+
this.#invalidValue = true;
|
|
2268
|
+
}
|
|
2269
|
+
return entry.parsed;
|
|
2270
|
+
}
|
|
2271
|
+
chunkAt(at) {
|
|
2272
|
+
let low = 0;
|
|
2273
|
+
let high = this.#ends.length;
|
|
2274
|
+
while (low < high) {
|
|
2275
|
+
const mid = low + high >>> 1;
|
|
2276
|
+
if (this.#ends[mid] <= at)
|
|
2277
|
+
low = mid + 1;
|
|
2278
|
+
else
|
|
2279
|
+
high = mid;
|
|
2280
|
+
}
|
|
2281
|
+
return low;
|
|
2282
|
+
}
|
|
2283
|
+
slice(start, end) {
|
|
2284
|
+
if (start >= end)
|
|
2285
|
+
return "";
|
|
2286
|
+
const first = this.chunkAt(start);
|
|
2287
|
+
const last = this.chunkAt(end - 1);
|
|
2288
|
+
const base = first === 0 ? 0 : this.#ends[first - 1];
|
|
2289
|
+
if (first === last)
|
|
2290
|
+
return this.chunks[first].slice(start - base, end - base);
|
|
2291
|
+
const parts = [this.chunks[first].slice(start - base)];
|
|
2292
|
+
for (let i = first + 1;i < last; i++)
|
|
2293
|
+
parts.push(this.chunks[i]);
|
|
2294
|
+
parts.push(this.chunks[last].slice(0, end - this.#ends[last - 1]));
|
|
2295
|
+
return parts.join("");
|
|
2296
|
+
}
|
|
2297
|
+
readString(entry, read, limit, materialize) {
|
|
2298
|
+
const end = Math.min(entry.end < 0 ? this.#consumed : entry.end, entry.invalidAt ?? Number.POSITIVE_INFINITY, this.#invalidAt ?? Number.POSITIVE_INFINITY);
|
|
2299
|
+
if (!entry.needsDecoding) {
|
|
2300
|
+
const length = Math.min(end - read.at, limit - read.length);
|
|
2301
|
+
if (length <= 0)
|
|
2302
|
+
return;
|
|
2303
|
+
if (materialize)
|
|
2304
|
+
read.text += this.slice(read.at, read.at + length);
|
|
2305
|
+
read.at += length;
|
|
2306
|
+
read.length += length;
|
|
2307
|
+
return;
|
|
2308
|
+
}
|
|
2309
|
+
let chunkIndex = this.chunkAt(read.at);
|
|
2310
|
+
while (read.at < end && read.length < limit) {
|
|
2311
|
+
const base = chunkIndex === 0 ? 0 : this.#ends[chunkIndex - 1];
|
|
2312
|
+
const chunk = this.chunks[chunkIndex];
|
|
2313
|
+
const remaining = chunk.slice(read.at - base, Math.min(chunk.length, end - base));
|
|
2314
|
+
const boundary = remaining.search(CONTENT_ESCAPE);
|
|
2315
|
+
const length = Math.min(boundary < 0 ? remaining.length : boundary, limit - read.length);
|
|
2316
|
+
if (length > 0) {
|
|
2317
|
+
if (materialize)
|
|
2318
|
+
read.text += remaining.slice(0, length);
|
|
2319
|
+
read.at += length;
|
|
2320
|
+
read.length += length;
|
|
2321
|
+
if (read.at === base + chunk.length)
|
|
2322
|
+
chunkIndex++;
|
|
2323
|
+
continue;
|
|
2324
|
+
}
|
|
2325
|
+
const type = remaining.length > 1 ? remaining[1] : read.at + 1 < end ? this.chunks[chunkIndex + 1][0] : undefined;
|
|
2326
|
+
let decoded;
|
|
2327
|
+
let width = 2;
|
|
2328
|
+
if (remaining[0] === "\\" && type === undefined && entry.end < 0)
|
|
2329
|
+
return;
|
|
2330
|
+
if (remaining[0] === "\\" && type === "u") {
|
|
2331
|
+
const hex = this.slice(read.at + 2, Math.min(end, read.at + 6));
|
|
2332
|
+
let valid = true;
|
|
2333
|
+
for (let i = 0;i < hex.length; i++)
|
|
2334
|
+
if (!isHex(hex[i]))
|
|
2335
|
+
valid = false;
|
|
2336
|
+
if (valid) {
|
|
2337
|
+
if (hex.length < 4 && entry.end < 0)
|
|
2338
|
+
return;
|
|
2339
|
+
if (hex.length === 4)
|
|
2340
|
+
decoded = String.fromCharCode(Number.parseInt(hex, 16));
|
|
2341
|
+
}
|
|
2342
|
+
width = 6;
|
|
2343
|
+
} else if (remaining[0] === "\\" && type !== undefined)
|
|
2344
|
+
decoded = SIMPLE_ESCAPES[type];
|
|
2345
|
+
if (decoded === undefined) {
|
|
2346
|
+
entry.invalidAt = read.at;
|
|
2347
|
+
this.#invalidValue = true;
|
|
2348
|
+
return;
|
|
2349
|
+
}
|
|
2350
|
+
if (materialize)
|
|
2351
|
+
read.text += decoded;
|
|
2352
|
+
read.length++;
|
|
2353
|
+
read.at += width;
|
|
2354
|
+
while (chunkIndex < this.chunks.length && read.at >= this.#ends[chunkIndex])
|
|
2355
|
+
chunkIndex++;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
scan() {
|
|
2359
|
+
if (this.object !== undefined || this.#consumed === this.#size)
|
|
2360
|
+
return;
|
|
2361
|
+
for (let i = this.chunkAt(this.#consumed);i < this.chunks.length && this.#invalidAt === undefined; i++) {
|
|
2362
|
+
const pending = this.chunks[i];
|
|
2363
|
+
const base = i === 0 ? 0 : this.#ends[i - 1];
|
|
2364
|
+
for (let index = this.#consumed - base;index < pending.length && this.#mode !== "invalid"; index++) {
|
|
2365
|
+
if (this.#mode === "string" || this.#mode === "nested" && this.#nestedInString) {
|
|
2366
|
+
const end = this.stringBoundary(pending, index);
|
|
2367
|
+
this.#consumed += end - index;
|
|
2368
|
+
index = end;
|
|
2369
|
+
if (index === pending.length)
|
|
2370
|
+
break;
|
|
2371
|
+
}
|
|
2372
|
+
this.step(pending[index], this.#consumed);
|
|
2373
|
+
this.#consumed++;
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
stringBoundary(fragment, start) {
|
|
2378
|
+
let at = start;
|
|
2379
|
+
while (true) {
|
|
2380
|
+
const quote = fragment.indexOf('"', at);
|
|
2381
|
+
const end = quote < 0 ? fragment.length : quote;
|
|
2382
|
+
if (this.#mode === "string") {
|
|
2383
|
+
const entry = this.#current;
|
|
2384
|
+
if (!entry.needsDecoding && CONTENT_ESCAPE.test(fragment.slice(at, end)))
|
|
2385
|
+
entry.needsDecoding = true;
|
|
2386
|
+
}
|
|
2387
|
+
let slashStart = end;
|
|
2388
|
+
while (slashStart > at && fragment[slashStart - 1] === "\\")
|
|
2389
|
+
slashStart--;
|
|
2390
|
+
const escaped = (end - slashStart) % 2 === 1 !== (slashStart === at && this.#escape);
|
|
2391
|
+
this.#escape = quote < 0 && escaped;
|
|
2392
|
+
if (quote < 0 || !escaped)
|
|
2393
|
+
return end;
|
|
2394
|
+
at = quote + 1;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
step(c, at) {
|
|
2398
|
+
switch (this.#mode) {
|
|
2399
|
+
case "root":
|
|
2400
|
+
if (isWhitespace(c))
|
|
2401
|
+
return;
|
|
2402
|
+
if (c === "{") {
|
|
2403
|
+
this.#mode = "key-or-end";
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
this.fail();
|
|
2407
|
+
return;
|
|
2408
|
+
case "key-or-end":
|
|
2409
|
+
if (isWhitespace(c))
|
|
2410
|
+
return;
|
|
2411
|
+
if (c === "}") {
|
|
2412
|
+
this.#mode = "closed";
|
|
2413
|
+
return;
|
|
2414
|
+
}
|
|
2415
|
+
if (c === '"') {
|
|
2416
|
+
this.beginKey(at);
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2419
|
+
this.fail();
|
|
2420
|
+
return;
|
|
2421
|
+
case "key-only":
|
|
2422
|
+
if (isWhitespace(c))
|
|
2423
|
+
return;
|
|
2424
|
+
if (c === '"') {
|
|
2425
|
+
this.beginKey(at);
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2428
|
+
this.fail();
|
|
2429
|
+
return;
|
|
2430
|
+
case "key":
|
|
2431
|
+
this.stepKey(c, at);
|
|
2432
|
+
return;
|
|
2433
|
+
case "colon":
|
|
2434
|
+
if (isWhitespace(c))
|
|
2435
|
+
return;
|
|
2436
|
+
if (c === ":") {
|
|
2437
|
+
this.#mode = "value";
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
this.fail();
|
|
2441
|
+
return;
|
|
2442
|
+
case "value":
|
|
2443
|
+
this.beginValue(c, at);
|
|
2444
|
+
return;
|
|
2445
|
+
case "string": {
|
|
2446
|
+
const entry = this.#current;
|
|
2447
|
+
entry.end = at;
|
|
2448
|
+
this.#current = null;
|
|
2449
|
+
this.#mode = "comma-or-end";
|
|
2450
|
+
return;
|
|
2451
|
+
}
|
|
2452
|
+
case "scalar":
|
|
2453
|
+
this.stepScalar(c, at);
|
|
2454
|
+
return;
|
|
2455
|
+
case "nested":
|
|
2456
|
+
this.stepNested(c, at);
|
|
2457
|
+
return;
|
|
2458
|
+
case "comma-or-end":
|
|
2459
|
+
if (isWhitespace(c))
|
|
2460
|
+
return;
|
|
2461
|
+
if (c === ",") {
|
|
2462
|
+
this.#mode = "key-only";
|
|
2463
|
+
return;
|
|
2464
|
+
}
|
|
2465
|
+
if (c === "}") {
|
|
2466
|
+
this.#mode = "closed";
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2469
|
+
this.fail();
|
|
2470
|
+
return;
|
|
2471
|
+
case "closed":
|
|
2472
|
+
if (isWhitespace(c))
|
|
2473
|
+
return;
|
|
2474
|
+
this.fail();
|
|
2475
|
+
return;
|
|
2476
|
+
case "invalid":
|
|
2477
|
+
return;
|
|
2478
|
+
default:
|
|
2479
|
+
assertNever(this.#mode);
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
fail() {
|
|
2483
|
+
this.#invalidAt = this.#consumed;
|
|
2484
|
+
this.#mode = "invalid";
|
|
2485
|
+
this.#current = null;
|
|
2486
|
+
}
|
|
2487
|
+
beginKey(at) {
|
|
2488
|
+
this.#mode = "key";
|
|
2489
|
+
this.#keyStart = at + 1;
|
|
2490
|
+
this.#keyEscaped = false;
|
|
2491
|
+
this.#escape = false;
|
|
2492
|
+
}
|
|
2493
|
+
stepKey(c, at) {
|
|
2494
|
+
if (c < " ") {
|
|
2495
|
+
this.fail();
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
if (this.#escape) {
|
|
2499
|
+
this.#escape = false;
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
if (c === "\\") {
|
|
2503
|
+
this.#escape = true;
|
|
2504
|
+
this.#keyEscaped = true;
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
if (c !== '"')
|
|
2508
|
+
return;
|
|
2509
|
+
const raw = this.slice(this.#keyStart, at);
|
|
2510
|
+
if (this.#keyEscaped)
|
|
2511
|
+
try {
|
|
2512
|
+
this.#key = JSON.parse(`"${raw}"`);
|
|
2513
|
+
} catch (_error) {
|
|
2514
|
+
this.fail();
|
|
2515
|
+
return;
|
|
2516
|
+
}
|
|
2517
|
+
else
|
|
2518
|
+
this.#key = raw;
|
|
2519
|
+
this.#mode = "colon";
|
|
2520
|
+
}
|
|
2521
|
+
open(entry) {
|
|
2522
|
+
if (!this.#entries.has(this.#key))
|
|
2523
|
+
this.#order.push(this.#key);
|
|
2524
|
+
this.#entries.set(this.#key, entry);
|
|
2525
|
+
this.#current = entry;
|
|
2526
|
+
}
|
|
2527
|
+
beginValue(c, at) {
|
|
2528
|
+
if (isWhitespace(c))
|
|
2529
|
+
return;
|
|
2530
|
+
if (c === '"') {
|
|
2531
|
+
this.open({
|
|
2532
|
+
kind: "string",
|
|
2533
|
+
start: at + 1,
|
|
2534
|
+
end: -1,
|
|
2535
|
+
needsDecoding: false,
|
|
2536
|
+
invalidAt: undefined,
|
|
2537
|
+
length: undefined,
|
|
2538
|
+
text: undefined,
|
|
2539
|
+
prefixes: undefined
|
|
2540
|
+
});
|
|
2541
|
+
this.#escape = false;
|
|
2542
|
+
this.#mode = "string";
|
|
2543
|
+
return;
|
|
2544
|
+
}
|
|
2545
|
+
if (c === "}" || c === "," || c === ":" || c === "]") {
|
|
2546
|
+
this.fail();
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
this.open({
|
|
2550
|
+
kind: "value",
|
|
2551
|
+
start: at,
|
|
2552
|
+
end: -1,
|
|
2553
|
+
parsed: undefined,
|
|
2554
|
+
invalid: false
|
|
2555
|
+
});
|
|
2556
|
+
if (c === "{" || c === "[") {
|
|
2557
|
+
this.#mode = "nested";
|
|
2558
|
+
this.#nestedEnds = [c === "{" ? "}" : "]"];
|
|
2559
|
+
this.#nestedInString = false;
|
|
2560
|
+
this.#escape = false;
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
this.#mode = "scalar";
|
|
2564
|
+
}
|
|
2565
|
+
stepScalar(c, at) {
|
|
2566
|
+
if (c !== "," && c !== "}" && !isWhitespace(c))
|
|
2567
|
+
return;
|
|
2568
|
+
this.closeValue(at);
|
|
2569
|
+
this.#mode = c === "," ? "key-only" : c === "}" ? "closed" : "comma-or-end";
|
|
2570
|
+
}
|
|
2571
|
+
stepNested(c, at) {
|
|
2572
|
+
if (this.#nestedInString) {
|
|
2573
|
+
this.#nestedInString = false;
|
|
2574
|
+
return;
|
|
2575
|
+
}
|
|
2576
|
+
if (c === '"') {
|
|
2577
|
+
this.#nestedInString = true;
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
if (c === "{" || c === "[") {
|
|
2581
|
+
this.#nestedEnds.push(c === "{" ? "}" : "]");
|
|
2582
|
+
return;
|
|
2583
|
+
}
|
|
2584
|
+
if (c === "}" || c === "]") {
|
|
2585
|
+
if (this.#nestedEnds.pop() !== c) {
|
|
2586
|
+
this.fail();
|
|
2587
|
+
return;
|
|
2588
|
+
}
|
|
2589
|
+
if (this.#nestedEnds.length === 0) {
|
|
2590
|
+
this.closeValue(at + 1);
|
|
2591
|
+
this.#mode = "comma-or-end";
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
closeValue(end) {
|
|
2596
|
+
const entry = this.#current;
|
|
2597
|
+
entry.end = end;
|
|
2598
|
+
this.#current = null;
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
1979
2601
|
function assertNever(value, context) {
|
|
1980
2602
|
const rendered = JSON.stringify(value) ?? String(value);
|
|
1981
2603
|
throw new Error(`unreachable variant${context ? ` in ${context}` : ""}: ${rendered}`);
|
|
@@ -2021,7 +2643,7 @@ function deepFreeze(value) {
|
|
|
2021
2643
|
return value;
|
|
2022
2644
|
}
|
|
2023
2645
|
|
|
2024
|
-
// node_modules/@deepseek-ai/dsh-util-crypto/lib/index.js
|
|
2646
|
+
// node_modules/@deepseek-ai/dsh-llm/node_modules/@deepseek-ai/dsh-util-crypto/lib/index.js
|
|
2025
2647
|
function randomUUID() {
|
|
2026
2648
|
const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16));
|
|
2027
2649
|
const hex = Array.from(bytes, (byte, index) => {
|
|
@@ -2038,7 +2660,7 @@ function brandString(value) {
|
|
|
2038
2660
|
// node_modules/@deepseek-ai/dsh-llm/lib/index.js
|
|
2039
2661
|
import z from "@deepseek-ai/schemastery";
|
|
2040
2662
|
|
|
2041
|
-
// node_modules/@deepseek-ai/dsh-timeout/lib/index.js
|
|
2663
|
+
// node_modules/@deepseek-ai/dsh-llm/node_modules/@deepseek-ai/dsh-timeout/lib/index.js
|
|
2042
2664
|
var MAX_TIMER_DELAY_MS = 2147483647;
|
|
2043
2665
|
|
|
2044
2666
|
// node_modules/@deepseek-ai/dsh-llm/lib/index.js
|
|
@@ -2554,7 +3176,6 @@ var LlmRuntime = (() => {
|
|
|
2554
3176
|
super(ctx, "llm");
|
|
2555
3177
|
}
|
|
2556
3178
|
emitAdaptersUpdated() {
|
|
2557
|
-
let invariantFailure;
|
|
2558
3179
|
for (const listener of this.ctx.events.dispatch("emit", ["llm/adapters-updated"]))
|
|
2559
3180
|
try {
|
|
2560
3181
|
const returned = listener();
|
|
@@ -2563,14 +3184,8 @@ var LlmRuntime = (() => {
|
|
|
2563
3184
|
this.warnAdaptersListenerFailure(error);
|
|
2564
3185
|
});
|
|
2565
3186
|
} catch (error) {
|
|
2566
|
-
if (error?.code === "INVARIANT") {
|
|
2567
|
-
invariantFailure ??= error;
|
|
2568
|
-
continue;
|
|
2569
|
-
}
|
|
2570
3187
|
this.warnAdaptersListenerFailure(error);
|
|
2571
3188
|
}
|
|
2572
|
-
if (invariantFailure !== undefined)
|
|
2573
|
-
throw invariantFailure;
|
|
2574
3189
|
}
|
|
2575
3190
|
warnAdaptersListenerFailure(error) {
|
|
2576
3191
|
this.ctx.logger.warn("llm: an llm/adapters-updated listener failed");
|
|
@@ -2649,10 +3264,7 @@ var LlmRuntime = (() => {
|
|
|
2649
3264
|
throw new LlmError(`configurable provider "${entry.provider}" has an empty settingsPath segment`, "INVALID_DIRECTORY");
|
|
2650
3265
|
if (this.directory.has(entry.provider) && !own.has(entry.provider) || detached.some((seen) => seen.provider === entry.provider))
|
|
2651
3266
|
throw new LlmError(`configurable provider "${entry.provider}" is already declared`, "DUPLICATE_DIRECTORY");
|
|
2652
|
-
detached.push(
|
|
2653
|
-
...entry,
|
|
2654
|
-
settingsPath: [...entry.settingsPath]
|
|
2655
|
-
});
|
|
3267
|
+
detached.push(detachDirectoryEntry(entry));
|
|
2656
3268
|
}
|
|
2657
3269
|
for (const entry of held)
|
|
2658
3270
|
this.directory.delete(entry.provider);
|
|
@@ -2682,10 +3294,7 @@ var LlmRuntime = (() => {
|
|
|
2682
3294
|
return handle;
|
|
2683
3295
|
}
|
|
2684
3296
|
listConfigurableProviders() {
|
|
2685
|
-
return [...this.directory.values()].map(
|
|
2686
|
-
...entry,
|
|
2687
|
-
settingsPath: [...entry.settingsPath]
|
|
2688
|
-
}));
|
|
3297
|
+
return [...this.directory.values()].map(detachDirectoryEntry);
|
|
2689
3298
|
}
|
|
2690
3299
|
registerModelDiscovery(settingsNs, discover) {
|
|
2691
3300
|
const dispose = this.ctx.effect(function* () {
|
|
@@ -2739,6 +3348,9 @@ var LlmRuntime = (() => {
|
|
|
2739
3348
|
imageRequestPricing(provider, model) {
|
|
2740
3349
|
return this.adapters.get(provider)?.adapter.imageRequestPricing(provider, model);
|
|
2741
3350
|
}
|
|
3351
|
+
imageRequestTarget(provider, model, image) {
|
|
3352
|
+
return this.registration(provider).adapter.imageRequestTarget(provider, model, image);
|
|
3353
|
+
}
|
|
2742
3354
|
fileRequestText(ref) {
|
|
2743
3355
|
return fileHandleText(ref, this.fileReadPath(ref));
|
|
2744
3356
|
}
|
|
@@ -2753,12 +3365,17 @@ var LlmRuntime = (() => {
|
|
|
2753
3365
|
throw new LlmError(`adapter returned invalid or duplicate model metadata for provider "${provider}"`, "INVALID_CATALOG");
|
|
2754
3366
|
seen.add(model.id);
|
|
2755
3367
|
const inputModalities = this.detachedModalities(model.inputModalities);
|
|
3368
|
+
const badge = model.badge;
|
|
2756
3369
|
return {
|
|
2757
3370
|
provider: model.provider,
|
|
2758
3371
|
id: model.id,
|
|
2759
3372
|
name: model.name,
|
|
2760
3373
|
...model.description === undefined ? {} : { description: model.description },
|
|
2761
|
-
...inputModalities === undefined ? {} : { inputModalities }
|
|
3374
|
+
...inputModalities === undefined ? {} : { inputModalities },
|
|
3375
|
+
...badge === undefined ? {} : { badge: {
|
|
3376
|
+
text: typeof badge.text === "string" ? badge.text : { ...badge.text },
|
|
3377
|
+
tone: badge.tone
|
|
3378
|
+
} }
|
|
2762
3379
|
};
|
|
2763
3380
|
});
|
|
2764
3381
|
}
|
|
@@ -2859,16 +3476,25 @@ var LlmRuntime = (() => {
|
|
|
2859
3476
|
modelInfo: info
|
|
2860
3477
|
};
|
|
2861
3478
|
}
|
|
2862
|
-
async prepareCall(config, signal) {
|
|
2863
|
-
|
|
2864
|
-
const
|
|
2865
|
-
const
|
|
2866
|
-
const
|
|
3479
|
+
async prepareCall(config, signal, configure) {
|
|
3480
|
+
signal?.throwIfAborted();
|
|
3481
|
+
const { provider, model, ...controls } = config;
|
|
3482
|
+
const registration = this.registration(provider);
|
|
3483
|
+
const adapterCall = await registration.adapter.prepareCall(provider, model, signal);
|
|
3484
|
+
signal?.throwIfAborted();
|
|
3485
|
+
const modelInfo = this.normalizeModelInfo(registration, model, adapterCall.model);
|
|
3486
|
+
const proposed = configure === undefined ? config : {
|
|
3487
|
+
...configure(deepFreeze(structuredClone(controls)), deepFreeze(modelInfo)),
|
|
3488
|
+
provider,
|
|
3489
|
+
model
|
|
3490
|
+
};
|
|
3491
|
+
signal?.throwIfAborted();
|
|
3492
|
+
const resolved = this.resolveCallWithInfo(proposed, modelInfo);
|
|
2867
3493
|
const resolvedConfig = deepFreeze(structuredClone(resolved.config));
|
|
2868
3494
|
const context = resolved.context === undefined ? undefined : deepFreeze(structuredClone(resolved.context));
|
|
2869
3495
|
const adapterDefaults = deepFreeze({
|
|
2870
|
-
...
|
|
2871
|
-
...
|
|
3496
|
+
...proposed.reasoningEffort === undefined && resolvedConfig.reasoningEffort !== undefined ? { reasoningEffort: true } : {},
|
|
3497
|
+
...proposed.maxTokens === undefined && resolvedConfig.maxTokens !== undefined ? { maxTokens: true } : {}
|
|
2872
3498
|
});
|
|
2873
3499
|
let dispatched = false;
|
|
2874
3500
|
return Object.freeze({
|
|
@@ -3036,6 +3662,18 @@ function adapterFailureChunk(error, signal) {
|
|
|
3036
3662
|
}
|
|
3037
3663
|
};
|
|
3038
3664
|
}
|
|
3665
|
+
function detachDirectoryEntry(entry) {
|
|
3666
|
+
const { nativeAuth } = entry;
|
|
3667
|
+
return {
|
|
3668
|
+
...entry,
|
|
3669
|
+
settingsPath: [...entry.settingsPath],
|
|
3670
|
+
...entry.baseURLEnv === undefined ? {} : { baseURLEnv: [...entry.baseURLEnv] },
|
|
3671
|
+
...nativeAuth === undefined ? {} : { nativeAuth: {
|
|
3672
|
+
...nativeAuth,
|
|
3673
|
+
env: [...nativeAuth.env]
|
|
3674
|
+
} }
|
|
3675
|
+
};
|
|
3676
|
+
}
|
|
3039
3677
|
|
|
3040
3678
|
// src/todo-nudge.ts
|
|
3041
3679
|
var NUDGE_TEXT = "委派结果已返回:立刻 todo_write 回写对应项状态(整表覆盖,保留未动项),再继续下一步。";
|
|
@@ -3335,42 +3973,24 @@ async function startSubagentRunOnce(ctx, provider, spec) {
|
|
|
3335
3973
|
if (signal === undefined) {
|
|
3336
3974
|
ctx?.logger?.warn?.("[cohub] startSubagentRun 无可用 signal:子运行不可中止(父轮停止无法回收)");
|
|
3337
3975
|
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
provider,
|
|
3342
|
-
label: spec.label,
|
|
3343
|
-
request: {
|
|
3344
|
-
prompt,
|
|
3345
|
-
parent: spec.parent,
|
|
3346
|
-
...spec.agentPreset !== undefined ? { agentPreset: spec.agentPreset } : {},
|
|
3347
|
-
...spec.agentOptions !== undefined ? { agentOptions: spec.agentOptions } : {},
|
|
3348
|
-
...spec.toolFilter !== undefined ? { toolFilter: spec.toolFilter } : {}
|
|
3349
|
-
},
|
|
3350
|
-
...signal !== undefined ? { signal } : {},
|
|
3351
|
-
delivery: "caller"
|
|
3352
|
-
});
|
|
3353
|
-
applyChildToolFilterDirectly(ctx, receipt.childId, spec.toolFilter, spec.degradeNotes);
|
|
3354
|
-
return {
|
|
3355
|
-
id: receipt.childId,
|
|
3356
|
-
result: receipt.result,
|
|
3357
|
-
dispose: () => receipt.dispose()
|
|
3358
|
-
};
|
|
3359
|
-
}
|
|
3360
|
-
const run = await subagents.start(provider, {
|
|
3976
|
+
const prompt = spec.persona !== undefined ? [{ type: "text", text: spec.persona }, ...spec.prompt] : spec.prompt;
|
|
3977
|
+
const receipt = await subagents.startActivation({
|
|
3978
|
+
provider,
|
|
3361
3979
|
label: spec.label,
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
...signal !== undefined ? { signal } : {}
|
|
3980
|
+
request: {
|
|
3981
|
+
prompt,
|
|
3982
|
+
parent: spec.parent,
|
|
3983
|
+
...spec.agentPreset !== undefined ? { agentPreset: spec.agentPreset } : {},
|
|
3984
|
+
...spec.agentOptions !== undefined ? { agentOptions: spec.agentOptions } : {}
|
|
3985
|
+
},
|
|
3986
|
+
...signal !== undefined ? { signal } : {},
|
|
3987
|
+
delivery: "caller"
|
|
3369
3988
|
});
|
|
3989
|
+
applyChildToolFilterDirectly(ctx, receipt.childId, spec.toolFilter, spec.degradeNotes);
|
|
3370
3990
|
return {
|
|
3371
|
-
id:
|
|
3372
|
-
result:
|
|
3373
|
-
dispose: () =>
|
|
3991
|
+
id: receipt.childId,
|
|
3992
|
+
result: receipt.result,
|
|
3993
|
+
dispose: () => receipt.dispose()
|
|
3374
3994
|
};
|
|
3375
3995
|
}
|
|
3376
3996
|
function createEnvContract(config) {
|
|
@@ -3421,6 +4041,7 @@ class StallWatchdog {
|
|
|
3421
4041
|
lastToolResultAt: 0,
|
|
3422
4042
|
lastSuccessAt: 0,
|
|
3423
4043
|
lastReasoningAt: 0,
|
|
4044
|
+
lastActivityAt: 0,
|
|
3424
4045
|
lastReasoningIndex: -1,
|
|
3425
4046
|
sawReasoningChunks: false,
|
|
3426
4047
|
reasoningStreak: 0,
|
|
@@ -3499,6 +4120,7 @@ class StallWatchdog {
|
|
|
3499
4120
|
const now = Date.now();
|
|
3500
4121
|
if (type === "tool/call") {
|
|
3501
4122
|
this.s.lastToolAt = now;
|
|
4123
|
+
this.s.lastActivityAt = now;
|
|
3502
4124
|
this.s.pendingCall = { key: String(d?.name ?? "") + "|" + normalizeArguments(d?.arguments), callId: d?.callId };
|
|
3503
4125
|
this.s.reasoningStreak = 0;
|
|
3504
4126
|
this.s.lastReasoningIndex = -1;
|
|
@@ -3509,6 +4131,7 @@ class StallWatchdog {
|
|
|
3509
4131
|
this.s.pendingCall = null;
|
|
3510
4132
|
this.s.lastToolAt = now;
|
|
3511
4133
|
this.s.lastToolResultAt = now;
|
|
4134
|
+
this.s.lastActivityAt = now;
|
|
3512
4135
|
if (isError) {
|
|
3513
4136
|
const sig = normalizeErrorSignature(d, { digits: "keep" }) ?? "err:unknown";
|
|
3514
4137
|
this.s.consecutiveErrors = sig === this.s.lastErrorSig ? this.s.consecutiveErrors + 1 : 1;
|
|
@@ -3533,13 +4156,17 @@ class StallWatchdog {
|
|
|
3533
4156
|
if (chunk?.type === "reasoning-delta") {
|
|
3534
4157
|
this.s.sawReasoningChunks = true;
|
|
3535
4158
|
this.s.lastReasoningAt = now;
|
|
4159
|
+
this.s.lastActivityAt = now;
|
|
3536
4160
|
if (chunk.index !== this.s.lastReasoningIndex) {
|
|
3537
4161
|
this.s.reasoningStreak++;
|
|
3538
4162
|
this.s.lastReasoningIndex = chunk.index;
|
|
3539
4163
|
}
|
|
4164
|
+
} else if (chunk?.type === "text-delta") {
|
|
4165
|
+
this.s.lastActivityAt = now;
|
|
3540
4166
|
}
|
|
3541
4167
|
} else if (type === "assistant/message" && !this.s.sawReasoningChunks) {
|
|
3542
4168
|
const blocks = Array.isArray(d?.message?.content) ? d.message.content : [];
|
|
4169
|
+
this.s.lastActivityAt = now;
|
|
3543
4170
|
if (blocks.some((b) => b?.type === "reasoning")) {
|
|
3544
4171
|
this.s.lastReasoningAt = now;
|
|
3545
4172
|
this.s.reasoningStreak++;
|
|
@@ -3554,7 +4181,7 @@ class StallWatchdog {
|
|
|
3554
4181
|
const cfg = this.cfg;
|
|
3555
4182
|
const now = Date.now();
|
|
3556
4183
|
const s1 = s.consecutiveErrors >= cfg.consecutiveErrors;
|
|
3557
|
-
const s2 = s.
|
|
4184
|
+
const s2 = s.lastActivityAt > 0 && now - s.lastActivityAt > cfg.idleMs;
|
|
3558
4185
|
const s3 = s.reasoningStreak >= cfg.reasoningWithoutAction;
|
|
3559
4186
|
const s4 = s.loopStreak >= cfg.loopCount;
|
|
3560
4187
|
const fired = [];
|
|
@@ -3613,8 +4240,6 @@ function skillTierDefaults(skillName) {
|
|
|
3613
4240
|
case "co-librarian":
|
|
3614
4241
|
case "co-observer":
|
|
3615
4242
|
return { reasoningEffort: "low" };
|
|
3616
|
-
case "co-fixer":
|
|
3617
|
-
return { maxTokens: 8192 };
|
|
3618
4243
|
case "co-planner":
|
|
3619
4244
|
return { maxTokens: 4096 };
|
|
3620
4245
|
default:
|
|
@@ -4489,6 +5114,19 @@ function createCouncilTool(config, ctx) {
|
|
|
4489
5114
|
// src/delegate_batch.ts
|
|
4490
5115
|
import { defineTool as defineTool3 } from "@deepseek-ai/dsh-tools";
|
|
4491
5116
|
var BATCH_TASK_ID_ECHO_MAX = 40;
|
|
5117
|
+
var KNOWN_SKILL_NAMES = COHUB_SKILLS.map((s) => s.name);
|
|
5118
|
+
var SKILL_NAMES_TEXT = KNOWN_SKILL_NAMES.join(", ");
|
|
5119
|
+
var SKILL_NAMES_SHORT_TEXT = KNOWN_SKILL_NAMES.join(" / ");
|
|
5120
|
+
function assertKnownSkill(raw) {
|
|
5121
|
+
if (raw.length === 0)
|
|
5122
|
+
return { ok: true };
|
|
5123
|
+
if (KNOWN_SKILL_NAMES.includes(raw))
|
|
5124
|
+
return { ok: true };
|
|
5125
|
+
return {
|
|
5126
|
+
ok: false,
|
|
5127
|
+
error: `skill 名 "${raw}" 无效。合法值:${SKILL_NAMES_SHORT_TEXT}` + `(co-orchestrator 为主代理,通常委派用其余 ${KNOWN_SKILL_NAMES.length - 1} 个)`
|
|
5128
|
+
};
|
|
5129
|
+
}
|
|
4492
5130
|
var MAX_BATCH_SIZE = 20;
|
|
4493
5131
|
function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
4494
5132
|
const envContract = createEnvContract(config);
|
|
@@ -4515,7 +5153,7 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
4515
5153
|
tasks: {
|
|
4516
5154
|
type: "array",
|
|
4517
5155
|
required: true,
|
|
4518
|
-
description: "
|
|
5156
|
+
description: "任务列表(≤maxParallelBatch)。每项仅接受 3 个字段:id(可选) / skill(必填) / prompt(必填);出现其它字段会被参数校验拒绝。",
|
|
4519
5157
|
items: {
|
|
4520
5158
|
type: "object",
|
|
4521
5159
|
additionalProperties: false,
|
|
@@ -4524,7 +5162,7 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
4524
5162
|
skill: {
|
|
4525
5163
|
type: "string",
|
|
4526
5164
|
required: true,
|
|
4527
|
-
description: "
|
|
5165
|
+
description: "必填。合法值(" + KNOWN_SKILL_NAMES.length + " 选 1):" + SKILL_NAMES_TEXT + "。注意 co-orchestrator 为主代理,通常委派用其余 " + (KNOWN_SKILL_NAMES.length - 1) + " 个。"
|
|
4528
5166
|
},
|
|
4529
5167
|
prompt: { type: "string", required: true, description: "必填,给该代理的具体任务(自包含)" }
|
|
4530
5168
|
}
|
|
@@ -4563,6 +5201,23 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
4563
5201
|
});
|
|
4564
5202
|
const starts = await Promise.allSettled(normalized.map(async ({ task, taskId, requestedSkill, skillFallback }) => {
|
|
4565
5203
|
const startedAt = Date.now();
|
|
5204
|
+
const skillCheck = assertKnownSkill(requestedSkill);
|
|
5205
|
+
if (!skillCheck.ok) {
|
|
5206
|
+
ctx.logger?.warn?.('[cohub delegate_batch] task "' + taskId + '" 的 skill 名 "' + requestedSkill + '" 不在合法名单内,已按错误返回(不再静默降级为 ' + DEFAULT_FALLBACK_SKILL + ")");
|
|
5207
|
+
return {
|
|
5208
|
+
taskId,
|
|
5209
|
+
skillName: requestedSkill,
|
|
5210
|
+
skillTag: requestedSkill,
|
|
5211
|
+
task,
|
|
5212
|
+
taskNotes: [],
|
|
5213
|
+
run: undefined,
|
|
5214
|
+
ac: undefined,
|
|
5215
|
+
onExecAbort: null,
|
|
5216
|
+
startedAt,
|
|
5217
|
+
startError: undefined,
|
|
5218
|
+
skillError: skillCheck.error
|
|
5219
|
+
};
|
|
5220
|
+
}
|
|
4566
5221
|
const { skill, route, note: skillNote } = resolveSkillAndRoute(requestedSkill, getRoutes, ctx, ctx.logger);
|
|
4567
5222
|
const taskNotes = [];
|
|
4568
5223
|
if (skillNote !== undefined) {
|
|
@@ -4607,14 +5262,14 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
4607
5262
|
signal: ac.signal,
|
|
4608
5263
|
degradeNotes: taskNotes
|
|
4609
5264
|
});
|
|
4610
|
-
return { taskId, skillName: skill.name, skillTag, task, taskNotes, run, ac, onExecAbort, startedAt, startError: undefined };
|
|
5265
|
+
return { taskId, skillName: skill.name, skillTag, task, taskNotes, run, ac, onExecAbort, startedAt, startError: undefined, skillError: undefined };
|
|
4611
5266
|
} catch (startError) {
|
|
4612
5267
|
if (onExecAbort && exec.signal) {
|
|
4613
5268
|
try {
|
|
4614
5269
|
exec.signal.removeEventListener("abort", onExecAbort);
|
|
4615
5270
|
} catch {}
|
|
4616
5271
|
}
|
|
4617
|
-
return { taskId, skillName: skill.name, skillTag, task, taskNotes, run: undefined, ac, onExecAbort: null, startedAt, startError };
|
|
5272
|
+
return { taskId, skillName: skill.name, skillTag, task, taskNotes, run: undefined, ac, onExecAbort: null, startedAt, startError, skillError: undefined };
|
|
4618
5273
|
}
|
|
4619
5274
|
}));
|
|
4620
5275
|
const results = [];
|
|
@@ -4630,6 +5285,17 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
4630
5285
|
continue;
|
|
4631
5286
|
}
|
|
4632
5287
|
const val = s.value;
|
|
5288
|
+
if (val.skillError) {
|
|
5289
|
+
perTaskNotes.push({ taskId: val.taskId, notes: val.taskNotes ?? [] });
|
|
5290
|
+
results.push({
|
|
5291
|
+
id: val.taskId,
|
|
5292
|
+
skill: val.skillTag,
|
|
5293
|
+
status: "error",
|
|
5294
|
+
error: val.skillError,
|
|
5295
|
+
...degradeField(val.taskNotes ?? [])
|
|
5296
|
+
});
|
|
5297
|
+
continue;
|
|
5298
|
+
}
|
|
4633
5299
|
if (val.startError) {
|
|
4634
5300
|
perTaskNotes.push({ taskId: val.taskId, notes: val.taskNotes ?? [] });
|
|
4635
5301
|
results.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cohub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "DeepSeek Harness 版 CoHub:中文智能体编排——用户可选 2 种工作模式(co-orchestrator 纯调度 / cohub-cordis 创造模式)+ 13 个专职代理技能 + 多模型共识;另由 cohub-subagent-readonly / cohub-subagent-write 两个支撑 preset 实现子代理读写硬隔离(共 4 个 preset)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -43,21 +43,22 @@
|
|
|
43
43
|
"typecheck:0.2": "bunx tsc --noEmit -p test/tsconfig.runtime-0.2.json",
|
|
44
44
|
"typecheck:src": "bunx tsc --noEmit -p tsconfig.typecheck.json",
|
|
45
45
|
"typecheck": "bun run typecheck:src && bun run typecheck:0.2",
|
|
46
|
+
"prepublish-check": "bun run scripts/prepublish-check.ts",
|
|
46
47
|
"prepublishOnly": "npm run build",
|
|
47
48
|
"build:client": "bun run scripts/build-client.js",
|
|
48
49
|
"audit": "node scripts/audit-session.mjs"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"@deepseek-ai/cordis": "^4.0
|
|
52
|
-
"@deepseek-ai/schemastery": "^3.
|
|
53
|
-
"@deepseek-ai/dsh-system-prompt": "^0.2.
|
|
54
|
-
"@deepseek-ai/dsh-skill": "^0.2.
|
|
55
|
-
"@deepseek-ai/dsh-tools": "^0.2.
|
|
56
|
-
"@deepseek-ai/dsh-home-paths": "^0.2.
|
|
57
|
-
"@deepseek-ai/dsh-subagent": "^0.2.
|
|
58
|
-
"@deepseek-ai/dsh-llm": "^0.2.
|
|
59
|
-
"@deepseek-ai/dsh-session-projection": "^0.2.
|
|
60
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.
|
|
52
|
+
"@deepseek-ai/cordis": "^4.1.0",
|
|
53
|
+
"@deepseek-ai/schemastery": "^3.19.0",
|
|
54
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.1",
|
|
55
|
+
"@deepseek-ai/dsh-skill": "^0.2.2-rc.1",
|
|
56
|
+
"@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
|
|
57
|
+
"@deepseek-ai/dsh-home-paths": "^0.2.2-rc.1",
|
|
58
|
+
"@deepseek-ai/dsh-subagent": "^0.2.2-rc.1",
|
|
59
|
+
"@deepseek-ai/dsh-llm": "^0.2.2-rc.1",
|
|
60
|
+
"@deepseek-ai/dsh-session-projection": "^0.2.2-rc.1",
|
|
61
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.1"
|
|
61
62
|
},
|
|
62
63
|
"peerDependenciesMeta": {
|
|
63
64
|
"@deepseek-ai/cordis": {
|
|
@@ -77,20 +78,23 @@
|
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
|
-
"@deepseek-ai/cordis": "4.0
|
|
81
|
-
"@deepseek-ai/schemastery": "3.
|
|
82
|
-
"@deepseek-ai/dsh-system-prompt": "0.2.
|
|
83
|
-
"@deepseek-ai/dsh-skill": "0.2.
|
|
84
|
-
"@deepseek-ai/dsh-tools": "0.2.
|
|
85
|
-
"@deepseek-ai/dsh-home-paths": "0.2.
|
|
86
|
-
"@deepseek-ai/dsh-subagent": "0.2.
|
|
87
|
-
"@deepseek-ai/dsh-settings": "0.2.
|
|
88
|
-
"@deepseek-ai/dsh-session-projection": "0.2.
|
|
89
|
-
"@deepseek-ai/dsh-app-boot": "0.2.
|
|
90
|
-
"@deepseek-ai/dsh-config-editor": "0.2.
|
|
91
|
-
"@deepseek-ai/
|
|
92
|
-
"@deepseek-ai/
|
|
93
|
-
"@deepseek-ai/cordis-plugin-
|
|
81
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
82
|
+
"@deepseek-ai/schemastery": "3.19.0",
|
|
83
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1",
|
|
84
|
+
"@deepseek-ai/dsh-skill": "0.2.2-rc.1",
|
|
85
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.1",
|
|
86
|
+
"@deepseek-ai/dsh-home-paths": "0.2.2-rc.1",
|
|
87
|
+
"@deepseek-ai/dsh-subagent": "0.2.2-rc.1",
|
|
88
|
+
"@deepseek-ai/dsh-settings": "0.2.2-rc.1",
|
|
89
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.1",
|
|
90
|
+
"@deepseek-ai/dsh-app-boot": "0.2.2-rc.1",
|
|
91
|
+
"@deepseek-ai/dsh-config-editor": "0.2.2-rc.1",
|
|
92
|
+
"@deepseek-ai/dsh-fs": "0.2.2-rc.1",
|
|
93
|
+
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.1",
|
|
94
|
+
"@deepseek-ai/cordis-plugin-loader": "1.1.0",
|
|
95
|
+
"@deepseek-ai/cordis-plugin-include": "1.1.0",
|
|
96
|
+
"@deepseek-ai/cordis-plugin-group": "1.1.0",
|
|
97
|
+
"@deepseek-ai/cordis-plugin-timer": "1.2.0",
|
|
94
98
|
"@types/node": "^24.0.0"
|
|
95
99
|
},
|
|
96
100
|
"license": "MIT",
|
|
@@ -88,9 +88,6 @@
|
|
|
88
88
|
- id: tool-subagent-control
|
|
89
89
|
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
90
90
|
|
|
91
|
-
- id: tool-subagent-list-agents
|
|
92
|
-
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
93
|
-
|
|
94
91
|
- id: tool-subagent
|
|
95
92
|
name: '@deepseek-ai/dsh-tool-subagent'
|
|
96
93
|
config:
|
|
@@ -208,9 +208,6 @@
|
|
|
208
208
|
- id: tool-subagent-control
|
|
209
209
|
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
210
210
|
|
|
211
|
-
- id: tool-subagent-list-agents
|
|
212
|
-
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
213
|
-
|
|
214
211
|
- id: tool-subagent
|
|
215
212
|
name: '@deepseek-ai/dsh-tool-subagent'
|
|
216
213
|
config:
|
|
@@ -88,8 +88,8 @@ When a preset genuinely owns a service, wrap the provider **and every consumer t
|
|
|
88
88
|
isolate:
|
|
89
89
|
workflows: true
|
|
90
90
|
config:
|
|
91
|
-
- id: workflow-
|
|
92
|
-
name: '@deepseek-ai/dsh-workflow-
|
|
91
|
+
- id: workflow-ptc
|
|
92
|
+
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
93
93
|
config:
|
|
94
94
|
provider: spawn
|
|
95
95
|
- id: tool-workflow
|