dsh-cohub 0.13.11 → 0.13.13

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.13.11**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
3
+ > 本文对应 **v0.13.13**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
4
4
 
5
5
  DeepSeek Harness 版(对照 [OpenCode 版](../oh-my-opencode-cohub/)):中文智能体编排插件。
6
6
  把「纯调度模式 + 内置技能(代理编排体系 + co-cordis 组合创作 + 写作组)+ 多模型共识 + 运行期调度韧性」移植到 DSH 原生能力之上。
package/lib/index.js CHANGED
@@ -629,7 +629,13 @@ function materializeJsTags(node, logger, platform = process.platform, path = "pl
629
629
  }
630
630
  return node;
631
631
  }
632
- var TEAM_OWNED_PRESET_IDS = ["co-orchestrator"];
632
+ var TEAM_OWNED_PRESET_IDS = [
633
+ "co-orchestrator",
634
+ "cohub-subagent-readonly",
635
+ "cohub-subagent-readonly-net",
636
+ "cohub-subagent-write",
637
+ "cohub-subagent-write-shell"
638
+ ];
633
639
  function isSafePresetId2(id) {
634
640
  return /^[a-z0-9][a-z0-9._-]*$/i.test(id) && !id.includes("..");
635
641
  }
@@ -2034,13 +2040,6 @@ Orchestrator 会在 prompt 中明确指定:
2034
2040
 
2035
2041
  // src/roles.ts
2036
2042
  var ALL_TIERS = ["ro", "ro-net", "rw", "rw-shell", "cordis"];
2037
- var TIER_TO_PRESET = {
2038
- ro: "cohub-subagent-readonly",
2039
- "ro-net": "cohub-subagent-readonly-net",
2040
- rw: "cohub-subagent-write",
2041
- "rw-shell": "cohub-subagent-write-shell",
2042
- cordis: "cohub-cordis"
2043
- };
2044
2043
  var BUILTIN_ROLE_TIERS = {
2045
2044
  "co-explorer": "ro",
2046
2045
  "co-oracle": "ro",
@@ -2106,10 +2105,6 @@ function resolveTier(roleName, customRoles) {
2106
2105
  const builtin = BUILTIN_ROLE_TIERS[key];
2107
2106
  return builtin ?? null;
2108
2107
  }
2109
- function presetForTier(tier) {
2110
- const preset = TIER_TO_PRESET[tier];
2111
- return typeof preset === "string" && preset.length > 0 ? preset : TIER_TO_PRESET["rw-shell"];
2112
- }
2113
2108
  var PRIMARY_AGENT_ROLE = "co-orchestrator";
2114
2109
  function resolveActiveTeam(config) {
2115
2110
  const id = (config?.activeTeam ?? "").trim();
@@ -5791,9 +5786,6 @@ var UNIVERSAL_DENY2 = [
5791
5786
  "weather",
5792
5787
  "video_search"
5793
5788
  ];
5794
- function fallbackPresetForTier(tier) {
5795
- return tier === "rw" || tier === "rw-shell" || tier === "cordis" ? SUBAGENT_WRITE_PRESET : SUBAGENT_READONLY_PRESET;
5796
- }
5797
5789
  var DEFAULT_FALLBACK_SKILL = "co-fixer";
5798
5790
  function resolveSkillToolFilter(skillName, enabled = true, logger, customRoles) {
5799
5791
  if (!enabled)
@@ -5811,24 +5803,14 @@ function resolveSkillToolFilter(skillName, enabled = true, logger, customRoles)
5811
5803
  return;
5812
5804
  }
5813
5805
  }
5814
- var SUBAGENT_READONLY_PRESET = "cohub-subagent-readonly";
5815
- var SUBAGENT_WRITE_PRESET = "cohub-subagent-write";
5816
- function resolveSkillAgentPreset(skillName, enabled = true, customRoles, logger) {
5806
+ var CORDIS_PRESET = "cohub-cordis";
5807
+ function resolveSkillAgentPreset(skillName, enabled = true, customRoles, _logger) {
5817
5808
  if (!enabled)
5818
5809
  return;
5819
5810
  const key = (skillName ?? "").trim();
5820
5811
  if (key === "co-orchestrator")
5821
5812
  return;
5822
- const tier = resolveTier(key, customRoles);
5823
- if (tier === null)
5824
- return SUBAGENT_WRITE_PRESET;
5825
- const mapped = TIER_TO_PRESET[tier];
5826
- if (typeof mapped !== "string" || mapped.length === 0) {
5827
- const fallback = fallbackPresetForTier(tier);
5828
- logger?.warn?.('[cohub preset] 档位 "' + tier + '"(skill=' + key + ")没有对应的子代理 preset," + "已降级为 " + fallback + "(不扩大权限)");
5829
- return fallback;
5830
- }
5831
- return presetForTier(tier);
5813
+ return resolveTier(key, customRoles) === "cordis" ? CORDIS_PRESET : undefined;
5832
5814
  }
5833
5815
  function intersectWithRestrictable(filter, restrictableNames) {
5834
5816
  if (!filter || !restrictableNames)
@@ -5955,6 +5937,8 @@ async function spawnWithToolFilterFallout(ctx, provider, spec) {
5955
5937
  }
5956
5938
  return handle;
5957
5939
  } catch (error) {
5940
+ if (isToolFilterEnforced(error))
5941
+ throw error;
5958
5942
  const message = error instanceof Error ? error.message : String(error);
5959
5943
  const aborted = spec.signal?.aborted === true || /abort/i.test(message);
5960
5944
  if (filter === undefined || wanted === undefined || aborted || !TOOL_FILTER_REJECTED.test(message)) {
@@ -5989,6 +5973,19 @@ function resolveAgentsService(ctx) {
5989
5973
  return viaReflect;
5990
5974
  return pick(() => ctx?.agents);
5991
5975
  }
5976
+
5977
+ class ToolFilterEnforcedError extends Error {
5978
+ code = TOOL_FILTER_ENFORCED_CODE;
5979
+ constructor(message) {
5980
+ super(message);
5981
+ this.name = "ToolFilterEnforcedError";
5982
+ }
5983
+ }
5984
+ var TOOL_FILTER_ENFORCED_CODE = "cohub/toolfilter-enforced";
5985
+ function isToolFilterEnforced(error) {
5986
+ const code = error?.code;
5987
+ return code === TOOL_FILTER_ENFORCED_CODE;
5988
+ }
5992
5989
  function applyChildToolFilterDirectly(ctx, childId, filter, degradeNotes) {
5993
5990
  if (filter === undefined)
5994
5991
  return;
@@ -6032,12 +6029,11 @@ function applyChildToolFilterDirectly(ctx, childId, filter, degradeNotes) {
6032
6029
  tools.restrict(next);
6033
6030
  return;
6034
6031
  } catch (retryError) {
6035
- noteFailure(describeDegradeReason(retryError));
6036
- return;
6032
+ throw new ToolFilterEnforcedError("cohub: 子代理工具裁剪未能施加(restrict 被拒),已 fail-closed 终止本次派发:" + describeDegradeReason(retryError));
6037
6033
  }
6038
6034
  }
6039
6035
  }
6040
- noteFailure(describeDegradeReason(error));
6036
+ throw new ToolFilterEnforcedError("cohub: 子代理工具裁剪未能施加(restrict 被拒),已 fail-closed 终止本次派发:" + describeDegradeReason(error));
6041
6037
  }
6042
6038
  }
6043
6039
  async function startSubagentRunOnce(ctx, provider, spec) {
@@ -6080,7 +6076,14 @@ ${attribution}`);
6080
6076
  wrapped.stack = err.stack;
6081
6077
  throw wrapped;
6082
6078
  }
6083
- applyChildToolFilterDirectly(ctx, receipt.childId, spec.toolFilter, spec.degradeNotes);
6079
+ try {
6080
+ applyChildToolFilterDirectly(ctx, receipt.childId, spec.toolFilter, spec.degradeNotes);
6081
+ } catch (error) {
6082
+ try {
6083
+ receipt?.dispose?.();
6084
+ } catch {}
6085
+ throw error;
6086
+ }
6084
6087
  return {
6085
6088
  id: receipt.childId,
6086
6089
  result: receipt.result,
@@ -6400,10 +6403,10 @@ function resolveSkillAndRoute(requestedSkill, getRoutes, ctx, logger, snapshot)
6400
6403
  tier: resolveTier(DEFAULT_FALLBACK_SKILL),
6401
6404
  builtin: true
6402
6405
  };
6403
- note = reason === "disabled" ? '传入的 skill 名 "' + echoName + '" 存在但已被禁用(config.disabledSkills),已兜底为 ' + DEFAULT_FALLBACK_SKILL + ",子代理 preset 同步回退为实施类 " + SUBAGENT_WRITE_PRESET + ";如需使用请从禁用清单中移除,而不是改名" : '传入的 skill 名 "' + echoName + '" 未匹配任何角色(内置角色 + config.customRoles),已兜底为 ' + DEFAULT_FALLBACK_SKILL + ",子代理 preset 同步回退为实施类 " + SUBAGENT_WRITE_PRESET;
6406
+ note = reason === "disabled" ? '传入的 skill 名 "' + echoName + '" 存在但已被禁用(config.disabledSkills),已兜底为 ' + DEFAULT_FALLBACK_SKILL + ",子代理档位同步回退为 rw-shell(继承父组合 + restrict 裁剪)" + ";如需使用请从禁用清单中移除,而不是改名" : '传入的 skill 名 "' + echoName + '" 未匹配任何角色(内置角色 + config.customRoles),已兜底为 ' + DEFAULT_FALLBACK_SKILL + ",子代理档位同步回退为 rw-shell(继承父组合 + restrict 裁剪)";
6404
6407
  } else if (fallback) {
6405
6408
  (logger ?? ctx.logger)?.warn?.("delegate: skill 未提供(缺字段/空串/纯空白),已兜底为 " + DEFAULT_FALLBACK_SKILL + ";schema 已要求必填,出现本告警说明调用绕过了参数校验");
6406
- note = "skill 未提供(缺字段/空串/纯空白),已兜底为 " + DEFAULT_FALLBACK_SKILL + ",子代理 preset 回退为实施类 " + SUBAGENT_WRITE_PRESET;
6409
+ note = "skill 未提供(缺字段/空串/纯空白),已兜底为 " + DEFAULT_FALLBACK_SKILL + ",子代理档位回退为 rw-shell(继承父组合 + restrict 裁剪)";
6407
6410
  }
6408
6411
  const route = (getRoutes() ?? []).find((s) => s.name === requested);
6409
6412
  return { skill: role.skill, role, route, fallback, ...note === undefined ? {} : { note } };
@@ -10432,26 +10435,7 @@ function readPackageVersion() {
10432
10435
  }
10433
10436
  }
10434
10437
  function installAgentPresets(logger) {
10435
- const r = installShippedPresets(SHIPPED_PRESETS_DIR, dshHomePath5(".agent-presets"), readPackageVersion(), logger);
10436
- try {
10437
- const patchPath = resolveProfilePatchPath(dshHomePath5());
10438
- if (patchPath === null) {
10439
- logger?.info?.("cohub: 无法判定活动 profile($DSH_PROFILE 未设置且 profiles 下不止一个),跳过 preset 声明写入");
10440
- } else {
10441
- const p = applyPresetPatchDeclarations(SHIPPED_PRESETS_DIR, patchPath, logger);
10442
- if (p.appended.length > 0) {
10443
- logger?.info?.(`cohub: 已向 ${patchPath} 追加 ${p.appended.length} 条 preset 声明(${p.appended.join(", ")})${p.backup ? `,原文件已备份为 ${p.backup}` : ""}`);
10444
- }
10445
- if (p.conflicts.length > 0) {
10446
- logger?.info?.(`cohub: ${p.conflicts.length} 条 preset 声明保留你的版本:${p.conflicts.join(", ")}`);
10447
- }
10448
- if (p.degraded !== undefined)
10449
- logger?.info?.(`cohub: preset 声明写入已跳过(${p.degraded})`);
10450
- }
10451
- } catch (error) {
10452
- logger?.warn?.("cohub: 写入 profile patch 的 preset 声明失败(不影响插件启动)", error);
10453
- }
10454
- return r;
10438
+ return installShippedPresets(SHIPPED_PRESETS_DIR, dshHomePath5(".agent-presets"), readPackageVersion(), logger);
10455
10439
  }
10456
10440
  function readVolatile(value) {
10457
10441
  const holder = value;
@@ -10623,6 +10607,7 @@ export {
10623
10607
  DelegateBackgroundConfig,
10624
10608
  ResultBudgetConfig,
10625
10609
  ScheduleConfig,
10610
+ TEAM_OWNED_PRESET_IDS,
10626
10611
  TEAM_PRESET_ORDER_BASE,
10627
10612
  Team,
10628
10613
  apply,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cohub",
3
- "version": "0.13.11",
3
+ "version": "0.13.13",
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",
@@ -1,179 +1,17 @@
1
- # cohub 子代理 preset 的 **profile patch 声明片段**(供 profile 的 cordis.patch.yml 使用)
1
+ # ⚠️ 已废弃(deprecated)——本文件不再被任何代码读取,仅作为迁移说明保留。
2
2
  #
3
- # 为什么需要这个文件:新版宿主(0.2.1-rc.5 实测)对 profile 里的 agent preset 采用
4
- # `@deepseek-ai/dsh-agent-preset` **声明行**注册,而不是扫描 ~/.dsh/.agent-presets/ 目录。
5
- # 因此只把 presets/<id>/ 复制进用户目录不够 —— 还必须在 profile 的 cordis.patch.yml
6
- # 里以 `- insert: { id: preset-<id>, ... }` 的形式声明,否则 delegate 传
7
- # agentPreset: '<id>' 时 presets.mount 找不到,cohub 会 fail-soft 降级为继承父 preset。
3
+ # 历史:0.13.6 之前,cohub 生成 profile patch 声明(`- insert: { id: preset-<id>, name:
4
+ # '@deepseek-ai/dsh-agent-preset', ... }`)追加到 profile 的 cordis.patch.yml,靠宿主启动时
5
+ # 加载声明来注册 agent preset。本文件是那段声明的模板/片段留存。
8
6
  #
9
- # 用法:把下面的 `- insert:` 段原样追加到目标 profile 的 cordis.patch.yml 顶层
10
- # (与既有的 preset-co-orchestrator / preset-cohub-cordis /
11
- # preset-cohub-subagent-readonly / preset-cohub-subagent-write 同级)。
12
- # 本文件本身不被 installShippedPresets 安装(它只复制 presets/ 下的**目录**)。
7
+ # 现在(0.13.6 起 → 0.13.12 彻底停用):preset 的唯一正源是**运行时注册**
8
+ # `ctx.agentPresets.register()`(见 packages/dsh-cohub/src/index.ts 的 ②c / ②d)。
9
+ # 声明写入已从 installAgentPresets() 中移除,原因:
10
+ # · profile patch 声明先于插件 apply 被宿主加载 → 旧的 preset id/内容胜出;
11
+ # · 运行时注册随后覆盖不掉已由声明挂载的 preset,实例里一度残留 6 条旧名声明。
13
12
  #
14
- # 源文件(plugins 段与之一一对应,改一处必须同时改另一处):
15
- # packages/dsh-cohub/presets/cohub-subagent-readonly-net/agent.cordis.yml
16
- # packages/dsh-cohub/presets/cohub-subagent-write-shell/agent.cordis.yml
17
- # 与既有两条声明的差异仅在 tool-web 的 fetch 开关,其余工具行逐行照抄。
18
- - insert:
19
- - id: preset-cohub-subagent-readonly-net
20
- name: '@deepseek-ai/dsh-agent-preset'
21
- config:
22
- id: cohub-subagent-readonly-net
23
- name: "CoHub 子代理·只读+联网(cohub-subagent-readonly-net)"
24
- description: "cohub 编排体系的联网只读子代理专用 preset:co-librarian / co-observer
25
- / co-planner / co-council 使用;在 readonly 基础上接通外网抓取(web 检索类工具可用),
26
- 仍无写盘、无 Shell、无委派类工具。"
27
- order: 12
28
- plugins:
29
- # ── 身份(精简:子代理不需要调度纪律,技能指令已由任务书 brief 注入)──
30
- - id: persona
31
- name: '@deepseek-ai/dsh-persona'
32
- config:
33
- # 字段名必须是 prefix(required)/ suffix;旧版 text 字段会让整行挂载失败。
34
- prefix: |-
35
- 你是 cohub 编排体系的专职子代理——只负责完成当前这一件具体任务。
36
- 不要试图调度、委派或拆分给其他代理;你的技能指令已由任务书注入,不要调用 skill 工具加载 co-orchestrator。
37
- 事实与证据优先:结论前置,证据用 path:line 形式。
38
-
39
- # ── 技能 ────────────────────────────────────────────────────────────
40
- - id: tool-skill
41
- name: '@deepseek-ai/dsh-tool-skill'
42
-
43
- # ── 任务面板 ────────────────────────────────────────────────────────
44
- - id: tool-todo
45
- name: '@deepseek-ai/dsh-tool-todo'
46
- config:
47
- allowParallelInProgress: true
48
-
49
- # ── 文件(只读)/ 搜索 / 外网(联网)────────────────────────────────
50
- # write / edit 显式关掉 —— 与 readonly 版一致,只读保证的硬边界。
51
- - id: tool-fs
52
- name: '@deepseek-ai/dsh-tool-fs'
53
- config:
54
- write: false
55
- edit: false
56
-
57
- - id: tool-fs-search
58
- name: '@deepseek-ai/dsh-tool-fs-search'
59
- config:
60
- sampleOverCapGlobResults: false
61
-
62
- # ★ 与 readonly 的唯一差异:fetch 打开(readonly 为 false)。
63
- - id: tool-web
64
- name: '@deepseek-ai/dsh-tool-web'
65
- config:
66
- fetch: true
67
-
68
- - id: skill-filesystem
69
- name: '@deepseek-ai/dsh-skill-filesystem'
70
-
71
- # 不挂:delegation / delegation-subagents / tool-subagent* / tool-workflow /
72
- # tool-goal / tool-ask-user / tool-jobs / tool-cordis / mcp-github。
73
- # 不挂 shell:联网代理不需要执行命令(真正的只读保证)。
74
-
75
- # ── 上下文压缩(参数照 co-orchestrator 现有值)─────────────────────
76
- - id: compaction
77
- name: cordis:group
78
- group: true
79
- isolate:
80
- compaction: true
81
- toolResultPruner: true
82
- config:
83
- - id: compaction-basic
84
- name: '@deepseek-ai/dsh-compaction-basic'
85
- config:
86
- thresholdRatio: 0.5
87
-
88
- - id: command-compact
89
- name: '@deepseek-ai/dsh-command-compact'
90
-
91
- - id: tool-result-pruner
92
- name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
93
- config:
94
- thresholdChars: 8192
95
- headChars: 4096
96
- tailChars: 1024
97
-
98
- - insert:
99
- - id: preset-cohub-subagent-write-shell
100
- name: '@deepseek-ai/dsh-agent-preset'
101
- config:
102
- id: cohub-subagent-write-shell
103
- name: "CoHub 子代理·读写+Shell(cohub-subagent-write-shell)"
104
- description: "cohub 编排体系的全能实施类子代理专用 preset:co-fixer / co-designer
105
- / co-cordis 使用;文件读写 + Shell + 外网抓取,但不含任何委派类工具。"
106
- order: 13
107
- plugins:
108
- # ── 身份(精简)─────────────────────────────────────────────────────
109
- - id: persona
110
- name: '@deepseek-ai/dsh-persona'
111
- config:
112
- # 字段名必须是 prefix(required)/ suffix;旧版 text 字段会让整行挂载失败。
113
- prefix: |-
114
- 你是 cohub 编排体系的专职子代理——只负责完成当前这一件具体任务。
115
- 不要试图调度、委派或拆分给其他代理;你的技能指令已由任务书注入,不要调用 skill 工具加载 co-orchestrator。
116
- 事实与证据优先:结论前置,证据用 path:line 形式。
117
-
118
- # ── 技能 ────────────────────────────────────────────────────────────
119
- - id: tool-skill
120
- name: '@deepseek-ai/dsh-tool-skill'
121
-
122
- # ── 任务面板 ────────────────────────────────────────────────────────
123
- - id: tool-todo
124
- name: '@deepseek-ai/dsh-tool-todo'
125
- config:
126
- allowParallelInProgress: true
127
-
128
- # ── 文件(读写)/ 搜索 / 外网(联网)────────────────────────────────
129
- - id: tool-fs
130
- name: '@deepseek-ai/dsh-tool-fs'
131
-
132
- - id: tool-fs-search
133
- name: '@deepseek-ai/dsh-tool-fs-search'
134
- config:
135
- sampleOverCapGlobResults: false
136
-
137
- # ★ 相对 cohub-subagent-write 的唯一差异:fetch 打开(write 为 false)。
138
- - id: tool-web
139
- name: '@deepseek-ai/dsh-tool-web'
140
- config:
141
- fetch: true
142
-
143
- - id: skill-filesystem
144
- name: '@deepseek-ai/dsh-skill-filesystem'
145
-
146
- # ── Shell(平台互斥,写法照 co-orchestrator)────────────────────────
147
- - id: tool-bash
148
- name: '@deepseek-ai/dsh-tool-bash'
149
- disabled: !!js process.platform === 'win32'
150
-
151
- - id: tool-pwsh
152
- name: '@deepseek-ai/dsh-tool-pwsh'
153
- disabled: !!js process.platform !== 'win32'
154
-
155
- # 不挂(见文件头):delegation / delegation-subagents / tool-subagent* /
156
- # tool-workflow / tool-goal / tool-ask-user / tool-jobs / tool-cordis / mcp-github。
157
-
158
- # ── 上下文压缩(参数照 co-orchestrator 现有值)─────────────────────
159
- - id: compaction
160
- name: cordis:group
161
- group: true
162
- isolate:
163
- compaction: true
164
- toolResultPruner: true
165
- config:
166
- - id: compaction-basic
167
- name: '@deepseek-ai/dsh-compaction-basic'
168
- config:
169
- thresholdRatio: 0.5
170
-
171
- - id: command-compact
172
- name: '@deepseek-ai/dsh-command-compact'
173
-
174
- - id: tool-result-pruner
175
- name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
176
- config:
177
- thresholdChars: 8192
178
- headChars: 4096
179
- tailChars: 1024
13
+ # 迁移:若某个 profile 的 cordis.patch.yml 里仍残留 `- insert:` 的
14
+ # `@deepseek-ai/dsh-agent-preset` 声明块,请直接删除这些块(保留
15
+ # `@deepseek-ai/dsh-agent-preset-registry` 那一行,它是 registry 配置而非 preset 声明)。
16
+ # 声明写入的实现(applyPresetPatchDeclarations / buildPresetPatchDeclarations)仍保留在
17
+ # packages/dsh-cohub/src/preset-install.ts 中,供外部脚本显式调用,插件启动路径不再触发。