dsh-cohub 0.13.7 → 0.13.9
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 +1 -1
- package/lib/client.js +197 -215
- package/lib/index.js +112 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-cohub
|
|
2
2
|
|
|
3
|
-
> 本文对应 **v0.13.
|
|
3
|
+
> 本文对应 **v0.13.9**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
4
4
|
|
|
5
5
|
DeepSeek Harness 版(对照 [OpenCode 版](../oh-my-opencode-cohub/)):中文智能体编排插件。
|
|
6
6
|
把「纯调度模式 + 内置技能(代理编排体系 + co-cordis 组合创作 + 写作组)+ 多模型共识 + 运行期调度韧性」移植到 DSH 原生能力之上。
|
package/lib/client.js
CHANGED
|
@@ -7,7 +7,7 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
|
|
8
8
|
// BEGIN ROLE_CATALOG (generated by scripts/generate-role-catalog.ts; build-client.js 会替换为真实数据)
|
|
9
9
|
const ROLE_CATALOG = {
|
|
10
|
-
"generatedAt": "2026-11-
|
|
10
|
+
"generatedAt": "2026-11-26T03:57:13.809Z",
|
|
11
11
|
"tiers": {
|
|
12
12
|
"ro": {
|
|
13
13
|
"preset": "cohub-subagent-readonly",
|
|
@@ -408,14 +408,49 @@ window.__ModuleLoader__.load({
|
|
|
408
408
|
"brief": "你是 Outliner,中文内容创作的前置角色:把模糊需求收敛成可写的选题(读者/核心主张/差异点),输出写作提纲(2-4 个一级节 + 每节论证任务)、素材清单与待查清单、需作者确认项(≤3)。不写成稿、不代查外部资料(列入 <to-research> 交 librarian)、不拍板不可逆决策。输出 <summary>/<outline>/<materials>/<to-research>/<open-questions>。全中文。",
|
|
409
409
|
"content": "你是 Outliner——中文内容创作的前置角色:选题、调研提纲、结构设计、素材清单。\n\n**角色**: 在动笔之前把「写什么、给谁写、按什么顺序写、需要哪些素材」定清楚,产出可直接交给 writer 的写作提纲。\n\n**能力**:\n- **选题收敛**:把模糊需求收敛成一个可写的题目——目标读者、核心主张(一句话)、与读者既有认知的差异点\n- **调研提纲**:列出「必须查清的事实」清单(谁、何时、多少、依据出处),标出哪些是硬事实、哪些是观点\n- **结构设计**:给出层级目录(2-4 个一级节,每节 2-4 个要点),说明每节的论证任务(立论 / 举证 / 反驳 / 收束)\n- **素材清单**:每节需要什么类型的素材(数据、案例、引文、对比、图示),标注来源候选与缺失项\n\n## 职责边界(硬性)\n\n- **不写成稿**。你产出提纲与清单,不产出正文段落;示例句最多一句,用来锁定口吻。\n- **不代查外部资料**。需要联网核实的事实列成「待查清单」交 librarian / 主代理;你只做结构设计与需求拆解。\n- **不拍板不可逆决策**。涉及立场、敏感表述、对外署名口径的,写成「需作者确认项」,不代替作者决定。\n- **不重复已定事实**。任务书已给定的读者/篇幅/口吻直接沿用,不重新质疑。\n\n## 输入契约\n\n先确认四项,缺项可给「默认值 + 一句说明」继续推进,但必须在输出里标出用的是默认值:\n1. 主题与大致方向(一句话即可)\n2. 目标读者与发布渠道\n3. 期望篇幅与体裁\n4. 硬约束(发布时间、必须覆盖的点、必须回避的点)\n\n## 输出规范\n\n```\n<summary> 选题一句话 + 目标读者 + 核心主张 + 建议篇幅 </summary>\n\n<outline>\n## 1. <节标题>(本节任务:立论 / 举证 / 对比 / 收束)\n- 要点 1\n- 要点 2\n## 2. ...\n</outline>\n\n<materials> 素材清单(按节分组)\n- 第 1 节:需 <数据类型>,来源候选 <X>,是否已具备:是/待查\n\n<to-research> 待查清单(交给 librarian / 主代理)\n- <具体要查什么> —— 为什么需要(支撑哪一节哪个论点)\n\n<open-questions> 需作者确认(≤3 条,超出说明需求过大建议拆分)\n</open-questions>\n```\n\n- 提纲层级不超过三层;一级节 2-4 个,单节要点 2-4 条\n- 每个要点是一句「可写的断言」或「必须回答的问题」,不写空标签(如「背景介绍」「总结」要说明介绍什么、总结什么)\n- 核心主张必须是一句可被反驳的话;写不出可被反驳的主张说明选题还没收敛\n- 待查清单每条都要能直接作为检索词,不写「查一些资料」这种无法执行的任务\n\n## 禁止事项\n\n- 禁输出成稿正文(>2 句的连续段落即违规)\n- 禁把待查事实直接写成结论(不确定就进 `<to-research>`)\n- 禁给出超过 4 个一级节的结构——需求过大时明确建议拆分为多篇,而不是堆一张巨型提纲\n- 禁使用「深入探讨」「全面分析」这类无信息量的节标题\n- 禁在素材清单里填编造的数据、案例或链接\n\n**语言要求**: 始终使用中文思考与回复。提纲与要点一律中文;专有名词与术语可保留原文。\n"
|
|
410
410
|
}
|
|
411
|
-
}
|
|
411
|
+
},
|
|
412
|
+
"builtinTeams": [
|
|
413
|
+
{
|
|
414
|
+
"id": "dev",
|
|
415
|
+
"name": "开发团队",
|
|
416
|
+
"description": "通用软件开发团队:调度 + 12 个专职子代理",
|
|
417
|
+
"members": [
|
|
418
|
+
"co-fixer",
|
|
419
|
+
"co-designer",
|
|
420
|
+
"co-explorer",
|
|
421
|
+
"co-oracle",
|
|
422
|
+
"co-planner",
|
|
423
|
+
"co-librarian",
|
|
424
|
+
"co-observer",
|
|
425
|
+
"co-council",
|
|
426
|
+
"co-rule-user",
|
|
427
|
+
"co-rule-project",
|
|
428
|
+
"co-rule-app",
|
|
429
|
+
"co-cordis"
|
|
430
|
+
],
|
|
431
|
+
"lead": "co-orchestrator",
|
|
432
|
+
"builtin": true
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"id": "writing",
|
|
436
|
+
"name": "写作团队",
|
|
437
|
+
"description": "中文内容创作团队:选题、成稿、审校",
|
|
438
|
+
"members": [
|
|
439
|
+
"co-writer",
|
|
440
|
+
"co-editor",
|
|
441
|
+
"co-outliner"
|
|
442
|
+
],
|
|
443
|
+
"lead": "co-orchestrator",
|
|
444
|
+
"builtin": true
|
|
445
|
+
}
|
|
446
|
+
]
|
|
412
447
|
};
|
|
413
448
|
// END ROLE_CATALOG
|
|
414
449
|
|
|
415
450
|
var React = require("react");
|
|
416
451
|
|
|
417
452
|
/* ────────────────────────────────────────────────────────────────
|
|
418
|
-
* CoHub
|
|
453
|
+
* CoHub 代理设置页(DSH 0.2.1)
|
|
419
454
|
*
|
|
420
455
|
* 历史纠正(旧注释是错的,别再抄回去):
|
|
421
456
|
* ❌「0.2 官方设置页会自动按 volatile 字段生成表单,无需客户端」
|
|
@@ -498,14 +533,8 @@ window.__ModuleLoader__.load({
|
|
|
498
533
|
|
|
499
534
|
var zh = {
|
|
500
535
|
nav: "CoHub 代理",
|
|
501
|
-
title: "CoHub
|
|
502
|
-
description: "
|
|
503
|
-
provider: "供应商",
|
|
504
|
-
model: "模型",
|
|
505
|
-
configured: "显式配置",
|
|
506
|
-
inherited: "继承父模型",
|
|
507
|
-
providerInherit: "(不配置,继承父模型)",
|
|
508
|
-
modelInherit: "(继承父模型)",
|
|
536
|
+
title: "CoHub 代理",
|
|
537
|
+
description: "团队 → 角色库。每个角色的提示词、绑定工具与运行模型(供应商 / 模型 / 推理强度 / 最大输出)统一在「角色库」里配置。",
|
|
509
538
|
loading: "加载中…",
|
|
510
539
|
unavailable: "当前设置不可用(宿主未提供 cohub 配置命名空间)。",
|
|
511
540
|
readOnly: "当前连接只读,无法修改设置。",
|
|
@@ -517,17 +546,8 @@ window.__ModuleLoader__.load({
|
|
|
517
546
|
saving: "保存中…",
|
|
518
547
|
saved: "已保存。",
|
|
519
548
|
discard: "放弃修改",
|
|
520
|
-
reset: "重置",
|
|
521
|
-
customModel: "输入模型 ID",
|
|
522
|
-
selectProviderFirst: "请先选择供应商",
|
|
523
549
|
loadProvidersFailed: "模型供应商列表加载失败",
|
|
524
550
|
emptyModel: "该供应商未提供模型目录",
|
|
525
|
-
unavailableOption: "{value}(不可用)",
|
|
526
|
-
reasoningEffort: "推理强度",
|
|
527
|
-
effortInherit: "(继承父会话)",
|
|
528
|
-
effortSelectModelFirst: "请先选择模型",
|
|
529
|
-
effortUnsupported: "该模型不支持",
|
|
530
|
-
effortUnsupportedOption: "{value}(当前模型不支持)",
|
|
531
551
|
"skill.co-orchestrator": "调度编排",
|
|
532
552
|
"skill.co-planner": "方案制定",
|
|
533
553
|
"skill.co-oracle": "架构/代码审查",
|
|
@@ -545,7 +565,10 @@ window.__ModuleLoader__.load({
|
|
|
545
565
|
rolesDescription: "先在这里建角色,再到上面的「团队」里勾选为成员。保存后运行时注册器约 1 秒内热加载,无需重启。",
|
|
546
566
|
teamsTitle: "团队",
|
|
547
567
|
teamsDescription: "把角色编成团队:每个团队会自动注册为一个 Agent 预设,在 DSH 的「Agent 预设」里选它即可开局。",
|
|
548
|
-
|
|
568
|
+
teamBuiltinNote: "内置团队随插件提供,可复制后修改。",
|
|
569
|
+
teamBuiltinBadge: "内置",
|
|
570
|
+
teamBuiltinCopy: "复制为我的团队",
|
|
571
|
+
teamEmpty: "还没有自定义团队。点「新建团队」开始。",
|
|
549
572
|
teamAdd: "新建团队",
|
|
550
573
|
teamRemove: "删除",
|
|
551
574
|
teamPresetUnknown: "当前会话预设:未知(在 Agent 预设里选择后此处会显示)",
|
|
@@ -692,14 +715,8 @@ window.__ModuleLoader__.load({
|
|
|
692
715
|
|
|
693
716
|
var en = {
|
|
694
717
|
nav: "CoHub agents",
|
|
695
|
-
title: "CoHub
|
|
696
|
-
description: "
|
|
697
|
-
provider: "Provider",
|
|
698
|
-
model: "Model",
|
|
699
|
-
configured: "Explicit",
|
|
700
|
-
inherited: "Inherited",
|
|
701
|
-
providerInherit: "(not set — inherit parent model)",
|
|
702
|
-
modelInherit: "(inherit parent model)",
|
|
718
|
+
title: "CoHub agents",
|
|
719
|
+
description: "Teams → Roles. Each role's prompt, bound tools and runtime model (provider / model / reasoning effort / max output) are configured in the role library.",
|
|
703
720
|
loading: "Loading…",
|
|
704
721
|
unavailable: "This setting is unavailable (the Host does not serve the cohub configuration namespace).",
|
|
705
722
|
readOnly: "This connection is read-only; settings cannot be changed.",
|
|
@@ -711,17 +728,8 @@ window.__ModuleLoader__.load({
|
|
|
711
728
|
saving: "Saving…",
|
|
712
729
|
saved: "Saved.",
|
|
713
730
|
discard: "Discard",
|
|
714
|
-
reset: "Reset",
|
|
715
|
-
customModel: "Enter model ID",
|
|
716
|
-
selectProviderFirst: "Select a provider first",
|
|
717
731
|
loadProvidersFailed: "Failed to load the provider catalog",
|
|
718
732
|
emptyModel: "This provider publishes no model catalog",
|
|
719
|
-
unavailableOption: "{value} (unavailable)",
|
|
720
|
-
reasoningEffort: "Reasoning effort",
|
|
721
|
-
effortInherit: "(inherit from parent session)",
|
|
722
|
-
effortSelectModelFirst: "Select a model first",
|
|
723
|
-
effortUnsupported: "Not supported by this model",
|
|
724
|
-
effortUnsupportedOption: "{value} (unsupported by this model)",
|
|
725
733
|
"skill.co-orchestrator": "Orchestrator",
|
|
726
734
|
"skill.co-planner": "Planner",
|
|
727
735
|
"skill.co-oracle": "Architecture/code review",
|
|
@@ -739,7 +747,10 @@ window.__ModuleLoader__.load({
|
|
|
739
747
|
rolesDescription: "Create roles here first, then tick them as members under \"Teams\" above. The runtime registrar picks changes up in about 1 second — no restart needed.",
|
|
740
748
|
teamsTitle: "Teams",
|
|
741
749
|
teamsDescription: "Group roles into teams: every team is registered as an Agent preset — pick it in DSH's \"Agent presets\" to start a session.",
|
|
742
|
-
|
|
750
|
+
teamBuiltinNote: "Built-in teams ship with the plugin; duplicate one to customise it.",
|
|
751
|
+
teamBuiltinBadge: "Built-in",
|
|
752
|
+
teamBuiltinCopy: "Duplicate as my team",
|
|
753
|
+
teamEmpty: "No custom teams yet. Click \"New team\" to start.",
|
|
743
754
|
teamAdd: "New team",
|
|
744
755
|
teamRemove: "Remove",
|
|
745
756
|
teamPresetUnknown: "Current session preset: unknown (pick one under Agent presets and it will show here)",
|
|
@@ -1422,6 +1433,35 @@ window.__ModuleLoader__.load({
|
|
|
1422
1433
|
return rows;
|
|
1423
1434
|
}
|
|
1424
1435
|
|
|
1436
|
+
/**
|
|
1437
|
+
* 内置团队(构建期由 scripts/generate-role-catalog.ts 从 src/builtin-teams.ts 写进
|
|
1438
|
+
* ROLE_CATALOG.builtinTeams)。它们**不是用户配置**:不进 Config.teams,页面只读展示 +
|
|
1439
|
+
* 提供「复制为我的团队」。缺字段 / 形状不对的条目直接跳过,绝不抛错。
|
|
1440
|
+
*/
|
|
1441
|
+
function builtinTeamsOf(catalog) {
|
|
1442
|
+
var source = catalog && Array.isArray(catalog.builtinTeams) ? catalog.builtinTeams : [];
|
|
1443
|
+
var out = [];
|
|
1444
|
+
for (var i = 0; i < source.length; i += 1) {
|
|
1445
|
+
var team = source[i];
|
|
1446
|
+
if (!team || typeof team !== "object") continue;
|
|
1447
|
+
if (typeof team.id !== "string" || team.id.trim() === "") continue;
|
|
1448
|
+
var members = [];
|
|
1449
|
+
var list = Array.isArray(team.members) ? team.members : [];
|
|
1450
|
+
for (var m = 0; m < list.length; m += 1) {
|
|
1451
|
+
if (typeof list[m] === "string" && list[m] !== "") members.push(list[m]);
|
|
1452
|
+
}
|
|
1453
|
+
out.push({
|
|
1454
|
+
id: team.id.trim(),
|
|
1455
|
+
name: typeof team.name === "string" && team.name.trim() !== "" ? team.name : team.id.trim(),
|
|
1456
|
+
description: typeof team.description === "string" ? team.description : "",
|
|
1457
|
+
members: members,
|
|
1458
|
+
lead: typeof team.lead === "string" ? team.lead : "",
|
|
1459
|
+
builtin: true
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
return out;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1425
1465
|
/** 编辑行 → 待写入的 teams 数组(只写受控字段,草稿标记不外泄)。 */
|
|
1426
1466
|
function teamsToConfig(rows) {
|
|
1427
1467
|
var out = [];
|
|
@@ -2569,6 +2609,48 @@ window.__ModuleLoader__.load({
|
|
|
2569
2609
|
pushTeamsRows(next);
|
|
2570
2610
|
}
|
|
2571
2611
|
|
|
2612
|
+
/**
|
|
2613
|
+
* 「复制为我的团队」:拿内置团队当模板,追加一条**普通用户团队**草稿行。
|
|
2614
|
+
* · 名称加「-副本」后缀;id 走 uniqueTeamId 消歧(基准 `<内置 id>-copy`,
|
|
2615
|
+
* 并把内置 id 一并算作已占用——预设 id 不能和内置团队撞车);
|
|
2616
|
+
* · 复制完直接展开该行(可改成员 / 队长 / 预设 id),之后可保存、可删除。
|
|
2617
|
+
* @param builtinId - ROLE_CATALOG.builtinTeams[].id
|
|
2618
|
+
*/
|
|
2619
|
+
function copyBuiltinTeam(builtinId) {
|
|
2620
|
+
if (!canEdit()) return;
|
|
2621
|
+
var specs = builtinTeamsOf(ROLE_CATALOG);
|
|
2622
|
+
var template = null;
|
|
2623
|
+
for (var s = 0; s < specs.length; s += 1) {
|
|
2624
|
+
if (specs[s].id === builtinId) template = specs[s];
|
|
2625
|
+
}
|
|
2626
|
+
if (template === null) return;
|
|
2627
|
+
var current = beginTeamsDraft();
|
|
2628
|
+
var next = [];
|
|
2629
|
+
for (var i = 0; i < current.rows.length; i += 1) {
|
|
2630
|
+
var copy = copyTeam(current.rows[i]);
|
|
2631
|
+
copy.isNew = current.rows[i].isNew === true;
|
|
2632
|
+
next.push(copy);
|
|
2633
|
+
}
|
|
2634
|
+
var taken = takenIdsExcept(next, -1);
|
|
2635
|
+
for (var t2 = 0; t2 < specs.length; t2 += 1) {
|
|
2636
|
+
if (taken.indexOf(specs[t2].id) < 0) taken.push(specs[t2].id);
|
|
2637
|
+
}
|
|
2638
|
+
var name = template.name + "-副本";
|
|
2639
|
+
var row = copyTeam({
|
|
2640
|
+
id: uniqueTeamId(template.id + "-copy", taken),
|
|
2641
|
+
name: name,
|
|
2642
|
+
description: template.description,
|
|
2643
|
+
members: template.members.slice(),
|
|
2644
|
+
lead: template.lead
|
|
2645
|
+
});
|
|
2646
|
+
row.isNew = true;
|
|
2647
|
+
row.slugEdited = false;
|
|
2648
|
+
row.slug = row.id;
|
|
2649
|
+
next.push(row);
|
|
2650
|
+
expandedTeam = next.length - 1;
|
|
2651
|
+
pushTeamsRows(next);
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2572
2654
|
/** 单 path 写配置:异常与 rejected promise 都归一为 false(不抛给 UI)。 */
|
|
2573
2655
|
function mutatePath(path, value, expected) {
|
|
2574
2656
|
if (disposed || !scope || typeof scope.mutate !== "function") return Promise.resolve(false);
|
|
@@ -2803,6 +2885,7 @@ window.__ModuleLoader__.load({
|
|
|
2803
2885
|
toggleTeamMember: toggleTeamMember,
|
|
2804
2886
|
setTeamLead: setTeamLead,
|
|
2805
2887
|
addTeam: addTeam,
|
|
2888
|
+
copyBuiltinTeam: copyBuiltinTeam,
|
|
2806
2889
|
removeTeam: removeTeam,
|
|
2807
2890
|
discardTeams: discardTeams,
|
|
2808
2891
|
saveTeams: saveTeams
|
|
@@ -2839,10 +2922,6 @@ window.__ModuleLoader__.load({
|
|
|
2839
2922
|
".cohub-row-id{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;}",
|
|
2840
2923
|
".cohub-badge{margin-left:auto;border-radius:999px;padding:1px 8px;font-size:11px;line-height:17px;white-space:nowrap;border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);}",
|
|
2841
2924
|
".cohub-badge-explicit{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary);}",
|
|
2842
|
-
// 四列:供应商 / 模型 / 推理强度 / 重置。三列下拉都等分剩余宽度,重置按钮自适应。
|
|
2843
|
-
".cohub-fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) auto;gap:8px;margin-top:8px;align-items:end;}",
|
|
2844
|
-
// 窄容器下 4 列会把下拉压到不可读:退成两列(前三个字段各占一行两列,按钮贴右下)。
|
|
2845
|
-
"@media (max-width:560px){.cohub-fields{grid-template-columns:minmax(0,1fr) minmax(0,1fr);}}",
|
|
2846
2925
|
".cohub-field{display:flex;flex-direction:column;gap:4px;min-width:0;}",
|
|
2847
2926
|
".cohub-label{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;}",
|
|
2848
2927
|
".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;}",
|
|
@@ -2862,7 +2941,7 @@ window.__ModuleLoader__.load({
|
|
|
2862
2941
|
".cohub-button-ghost{color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid var(--dsw-alias-border-l2);}",
|
|
2863
2942
|
".cohub-button-ghost:hover:not(:disabled){color:var(--dsw-alias-label-primary);}",
|
|
2864
2943
|
".cohub-button:disabled{opacity:.45;cursor:default;}",
|
|
2865
|
-
// ──
|
|
2944
|
+
// ── 自定义团队区块(各自独立的草稿与保存按钮) ──
|
|
2866
2945
|
".cohub-roles{display:flex;flex-direction:column;gap:12px;margin-top:8px;padding-top:16px;border-top:1px solid var(--dsw-alias-border-l2);}",
|
|
2867
2946
|
".cohub-subtitle{margin:0;font-size:14px;font-weight:600;line-height:22px;}",
|
|
2868
2947
|
".cohub-role-summary{flex:1 1 140px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;}",
|
|
@@ -2933,7 +3012,7 @@ window.__ModuleLoader__.load({
|
|
|
2933
3012
|
/**
|
|
2934
3013
|
* settings.section 页面。
|
|
2935
3014
|
* @param props - 注入面:hooks.cohubSkills→useCohubSkills、动作、locale 提供的 t。
|
|
2936
|
-
* @returns
|
|
3015
|
+
* @returns 页面结构:团队 → 角色库(角色的提示词 / 绑定工具 / 运行模型),底部是 Config.skills 的保存动作条。
|
|
2937
3016
|
*/
|
|
2938
3017
|
function CohubSection(props) {
|
|
2939
3018
|
var t = typeof props.t === "function" ? props.t : fallbackTranslate;
|
|
@@ -2955,171 +3034,8 @@ window.__ModuleLoader__.load({
|
|
|
2955
3034
|
|
|
2956
3035
|
var locked = !state.writable || state.saving || state.conflicted;
|
|
2957
3036
|
var providers = state.providers || [];
|
|
2958
|
-
var modelsByProvider = state.modelsByProvider || {};
|
|
2959
3037
|
var rows = state.rows || [];
|
|
2960
3038
|
|
|
2961
|
-
function renderRow(row) {
|
|
2962
|
-
var known = SKILL_NAMES.indexOf(row.name) >= 0;
|
|
2963
|
-
var label = known ? t("skill." + row.name) : row.name;
|
|
2964
|
-
var providerIds = [];
|
|
2965
|
-
var providerOptions = [
|
|
2966
|
-
React.createElement("option", { key: "__inherit", value: "" }, t("providerInherit"))
|
|
2967
|
-
];
|
|
2968
|
-
for (var i = 0; i < providers.length; i += 1) {
|
|
2969
|
-
providerIds.push(providers[i].id);
|
|
2970
|
-
providerOptions.push(React.createElement("option", { key: providers[i].id, value: providers[i].id }, providers[i].label));
|
|
2971
|
-
}
|
|
2972
|
-
if (row.provider !== "" && providerIds.indexOf(row.provider) < 0) {
|
|
2973
|
-
// 已存但当前目录里没有:给一个不可选回显项,避免下拉显示成第一项造成误读。
|
|
2974
|
-
providerOptions.push(React.createElement("option", {
|
|
2975
|
-
key: "__missing-provider",
|
|
2976
|
-
value: row.provider,
|
|
2977
|
-
disabled: true
|
|
2978
|
-
}, state.catalogStatus === "ready" ? t("unavailableOption", { value: row.provider }) : row.provider));
|
|
2979
|
-
}
|
|
2980
|
-
|
|
2981
|
-
var models = modelsByProvider[row.provider] || [];
|
|
2982
|
-
var modelControl;
|
|
2983
|
-
if (row.provider === "") {
|
|
2984
|
-
modelControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
2985
|
-
React.createElement("option", { value: "" }, t("selectProviderFirst")));
|
|
2986
|
-
} else if (state.catalogStatus === "loading") {
|
|
2987
|
-
modelControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
2988
|
-
React.createElement("option", { value: "" }, t("loading")));
|
|
2989
|
-
} else if (models.length > 0) {
|
|
2990
|
-
// 未保存 model 时必须插入 value="" 的占位项。否则 <select value=""> 会被浏览器
|
|
2991
|
-
// 渲染成列表第一项,用户以为已选、实际存的仍是空 → 子代理拿不到模型(UNKNOWN_MODEL)。
|
|
2992
|
-
var modelOptions = [React.createElement("option", { key: "__inherit", value: "" }, t("modelInherit"))];
|
|
2993
|
-
var modelIds = [];
|
|
2994
|
-
for (var m = 0; m < models.length; m += 1) {
|
|
2995
|
-
modelIds.push(models[m].id);
|
|
2996
|
-
modelOptions.push(React.createElement("option", { key: models[m].id, value: models[m].id }, models[m].label));
|
|
2997
|
-
}
|
|
2998
|
-
if (row.model !== "" && modelIds.indexOf(row.model) < 0) {
|
|
2999
|
-
modelOptions.push(React.createElement("option", {
|
|
3000
|
-
key: "__missing-model",
|
|
3001
|
-
value: row.model,
|
|
3002
|
-
disabled: true
|
|
3003
|
-
}, t("unavailableOption", { value: row.model })));
|
|
3004
|
-
}
|
|
3005
|
-
modelControl = React.createElement("select", {
|
|
3006
|
-
className: "cohub-select",
|
|
3007
|
-
value: row.model === "" ? "" : row.model,
|
|
3008
|
-
disabled: locked,
|
|
3009
|
-
"aria-label": label + " · " + t("model"),
|
|
3010
|
-
onChange: function (event) {
|
|
3011
|
-
props.editRow(row.name, "model", event.target.value);
|
|
3012
|
-
}
|
|
3013
|
-
}, modelOptions);
|
|
3014
|
-
} else {
|
|
3015
|
-
// 该供应商没有可用模型目录(或目录加载失败)→ 降级为手填 model id。
|
|
3016
|
-
modelControl = React.createElement("input", {
|
|
3017
|
-
className: "cohub-input",
|
|
3018
|
-
type: "text",
|
|
3019
|
-
value: row.model,
|
|
3020
|
-
disabled: locked,
|
|
3021
|
-
"aria-label": label + " · " + t("model"),
|
|
3022
|
-
placeholder: state.catalogStatus === "ready" ? t("emptyModel") + " / " + t("customModel") : t("customModel"),
|
|
3023
|
-
onChange: function (event) {
|
|
3024
|
-
props.editRow(row.name, "model", event.target.value);
|
|
3025
|
-
}
|
|
3026
|
-
});
|
|
3027
|
-
}
|
|
3028
|
-
|
|
3029
|
-
var configured = row.provider !== "" || row.model !== "" || effortOf(row) !== "";
|
|
3030
|
-
|
|
3031
|
-
// 第三个下拉:推理强度。档位来自模型目录(models[].reasoning.efforts),
|
|
3032
|
-
// 按「供应商 + 模型」这一对查表;不支持的模型整个 reasoning 字段缺失 → 禁用并提示。
|
|
3033
|
-
var currentEffort = effortOf(row);
|
|
3034
|
-
var efforts = [];
|
|
3035
|
-
if (row.provider !== "" && row.model !== "") {
|
|
3036
|
-
var byModel = state.effortsByModel && state.effortsByModel[row.provider];
|
|
3037
|
-
var list = byModel ? byModel[row.model] : undefined;
|
|
3038
|
-
if (Array.isArray(list)) efforts = list;
|
|
3039
|
-
}
|
|
3040
|
-
var effortControl;
|
|
3041
|
-
if (row.provider === "") {
|
|
3042
|
-
effortControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3043
|
-
React.createElement("option", { value: "" }, t("selectProviderFirst")));
|
|
3044
|
-
} else if (state.catalogStatus === "loading") {
|
|
3045
|
-
effortControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3046
|
-
React.createElement("option", { value: "" }, t("loading")));
|
|
3047
|
-
} else if (row.model === "") {
|
|
3048
|
-
effortControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3049
|
-
React.createElement("option", { value: "" }, t("effortSelectModelFirst")));
|
|
3050
|
-
} else if (efforts.length === 0) {
|
|
3051
|
-
// 模型目录里没有该模型的 reasoning 信息(或手填了不在目录里的 model id)→ 不支持。
|
|
3052
|
-
effortControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3053
|
-
React.createElement("option", { value: "" }, t("effortUnsupported")));
|
|
3054
|
-
} else {
|
|
3055
|
-
// 与模型下拉同理:value="" 的继承占位项必须在首位,否则浏览器把第一档显示成已选,
|
|
3056
|
-
// 而实际存的是空串(用户以为配了 high,其实继承父会话)。
|
|
3057
|
-
var effortOptions = [React.createElement("option", { key: "__inherit", value: "" }, t("effortInherit"))];
|
|
3058
|
-
var effortIds = [];
|
|
3059
|
-
for (var e = 0; e < efforts.length; e += 1) {
|
|
3060
|
-
effortIds.push(efforts[e].id);
|
|
3061
|
-
effortOptions.push(React.createElement("option", { key: efforts[e].id, value: efforts[e].id }, efforts[e].label));
|
|
3062
|
-
}
|
|
3063
|
-
if (currentEffort !== "" && effortIds.indexOf(currentEffort) < 0) {
|
|
3064
|
-
// 已配强度不在当前模型档位里(手改过 YAML / 换过模型)→ 给不可选回显项,别静默改成第一档。
|
|
3065
|
-
effortOptions.push(React.createElement("option", {
|
|
3066
|
-
key: "__missing-effort",
|
|
3067
|
-
value: currentEffort,
|
|
3068
|
-
disabled: true
|
|
3069
|
-
}, t("effortUnsupportedOption", { value: currentEffort })));
|
|
3070
|
-
}
|
|
3071
|
-
effortControl = React.createElement("select", {
|
|
3072
|
-
className: "cohub-select",
|
|
3073
|
-
value: currentEffort,
|
|
3074
|
-
disabled: locked,
|
|
3075
|
-
"aria-label": label + " · " + t("reasoningEffort"),
|
|
3076
|
-
onChange: function (event) {
|
|
3077
|
-
props.editRow(row.name, "reasoningEffort", event.target.value);
|
|
3078
|
-
}
|
|
3079
|
-
}, effortOptions);
|
|
3080
|
-
}
|
|
3081
|
-
|
|
3082
|
-
return React.createElement("li", { key: row.name, className: "cohub-row" },
|
|
3083
|
-
React.createElement("div", { className: "cohub-row-head" },
|
|
3084
|
-
React.createElement("span", { className: "cohub-row-name" }, label),
|
|
3085
|
-
React.createElement("span", { className: "cohub-row-id" }, row.name),
|
|
3086
|
-
React.createElement("span", {
|
|
3087
|
-
className: configured ? "cohub-badge cohub-badge-explicit" : "cohub-badge"
|
|
3088
|
-
}, configured ? t("configured") : t("inherited"))
|
|
3089
|
-
),
|
|
3090
|
-
React.createElement("div", { className: "cohub-fields" },
|
|
3091
|
-
React.createElement("div", { className: "cohub-field" },
|
|
3092
|
-
React.createElement("label", { className: "cohub-label" }, t("provider")),
|
|
3093
|
-
React.createElement("select", {
|
|
3094
|
-
className: "cohub-select",
|
|
3095
|
-
value: row.provider,
|
|
3096
|
-
disabled: locked,
|
|
3097
|
-
"aria-label": label + " · " + t("provider"),
|
|
3098
|
-
onChange: function (event) {
|
|
3099
|
-
props.editRow(row.name, "provider", event.target.value);
|
|
3100
|
-
}
|
|
3101
|
-
}, providerOptions)
|
|
3102
|
-
),
|
|
3103
|
-
React.createElement("div", { className: "cohub-field" },
|
|
3104
|
-
React.createElement("label", { className: "cohub-label" }, t("model")),
|
|
3105
|
-
modelControl
|
|
3106
|
-
),
|
|
3107
|
-
React.createElement("div", { className: "cohub-field" },
|
|
3108
|
-
React.createElement("label", { className: "cohub-label" }, t("reasoningEffort")),
|
|
3109
|
-
effortControl
|
|
3110
|
-
),
|
|
3111
|
-
React.createElement("button", {
|
|
3112
|
-
type: "button",
|
|
3113
|
-
className: "cohub-row-reset",
|
|
3114
|
-
disabled: locked || !configured,
|
|
3115
|
-
onClick: function () {
|
|
3116
|
-
props.resetRow(row.name);
|
|
3117
|
-
}
|
|
3118
|
-
}, t("reset"))
|
|
3119
|
-
)
|
|
3120
|
-
);
|
|
3121
|
-
}
|
|
3122
|
-
|
|
3123
3039
|
/* ── 自定义团队:增删改 Config.customRoles ─────────────────── */
|
|
3124
3040
|
|
|
3125
3041
|
var roles = state.roles || [];
|
|
@@ -3925,6 +3841,65 @@ window.__ModuleLoader__.load({
|
|
|
3925
3841
|
);
|
|
3926
3842
|
}
|
|
3927
3843
|
|
|
3844
|
+
/**
|
|
3845
|
+
* 内置团队卡片:**只读**——没有展开编辑区、没有删除按钮(它们不在 Config.teams 里,
|
|
3846
|
+
* 删/改都无意义),只显示团队名、`内置` 徽标、成员数、队长、档位分布与预设 id。
|
|
3847
|
+
* 唯一动作是「复制为我的团队」:生成一条普通用户团队草稿行(可改可删)。
|
|
3848
|
+
*/
|
|
3849
|
+
function renderBuiltinTeam(team) {
|
|
3850
|
+
var distribution = tierDistributionOf(team.members, roles);
|
|
3851
|
+
var distributionParts = [];
|
|
3852
|
+
for (var d = 0; d < distribution.length; d += 1) {
|
|
3853
|
+
distributionParts.push(roleTierLabel(distribution[d]) + " ×" + distribution[d].count);
|
|
3854
|
+
}
|
|
3855
|
+
var leadName = effectiveTeamLead(team);
|
|
3856
|
+
var memberNames = [];
|
|
3857
|
+
for (var i = 0; i < team.members.length; i += 1) memberNames.push(skillLabel(team.members[i]));
|
|
3858
|
+
return React.createElement("li", {
|
|
3859
|
+
key: "builtin-team-" + team.id,
|
|
3860
|
+
className: "cohub-row cohub-row-catalog"
|
|
3861
|
+
},
|
|
3862
|
+
React.createElement("div", { className: "cohub-row-head" },
|
|
3863
|
+
React.createElement("span", { className: "cohub-row-name" }, team.name),
|
|
3864
|
+
React.createElement("span", { className: "cohub-badge" }, t("teamBuiltinBadge")),
|
|
3865
|
+
React.createElement("span", { className: "cohub-badge" },
|
|
3866
|
+
t("teamMemberCount", { count: team.members.length })),
|
|
3867
|
+
leadName !== "" ? React.createElement("span", { className: "cohub-badge cohub-badge-lead" },
|
|
3868
|
+
t("teamLeadBadge", { name: skillLabel(leadName) })) : null,
|
|
3869
|
+
// 内置团队的预设 id 恒为 `cohub-team-<内置 id>`(见 src/team-presets.ts)。
|
|
3870
|
+
React.createElement("span", { className: "cohub-row-id cohub-mono" },
|
|
3871
|
+
t("teamPresetIdBadge", { id: TEAM_PRESET_PREFIX + team.id })),
|
|
3872
|
+
distributionParts.length > 0
|
|
3873
|
+
? React.createElement("span", { className: "cohub-tier-dist" },
|
|
3874
|
+
t("teamTierDistribution") + " · " + distributionParts.join(t("listSeparator")))
|
|
3875
|
+
: null,
|
|
3876
|
+
React.createElement("button", {
|
|
3877
|
+
type: "button",
|
|
3878
|
+
className: "cohub-row-reset",
|
|
3879
|
+
disabled: locked,
|
|
3880
|
+
"aria-label": t("teamBuiltinCopy") + " " + team.name,
|
|
3881
|
+
onClick: function (builtinId) {
|
|
3882
|
+
return function () {
|
|
3883
|
+
props.copyBuiltinTeam(builtinId);
|
|
3884
|
+
};
|
|
3885
|
+
}(team.id)
|
|
3886
|
+
}, t("teamBuiltinCopy"))
|
|
3887
|
+
),
|
|
3888
|
+
team.description !== "" ? React.createElement("p", { className: "cohub-desc" }, team.description) : null,
|
|
3889
|
+
memberNames.length > 0
|
|
3890
|
+
? React.createElement("p", { className: "cohub-desc cohub-mono" },
|
|
3891
|
+
memberNames.join(t("listSeparator")))
|
|
3892
|
+
: null
|
|
3893
|
+
);
|
|
3894
|
+
}
|
|
3895
|
+
|
|
3896
|
+
// 内置团队先渲染(只读卡片 + 「复制为我的团队」),用户团队紧随其后。
|
|
3897
|
+
var builtinTeamSpecs = builtinTeamsOf(ROLE_CATALOG);
|
|
3898
|
+
var builtinTeamItems = [];
|
|
3899
|
+
for (var bti = 0; bti < builtinTeamSpecs.length; bti += 1) {
|
|
3900
|
+
builtinTeamItems.push(renderBuiltinTeam(builtinTeamSpecs[bti]));
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3928
3903
|
var teamItems = [];
|
|
3929
3904
|
for (var ti = 0; ti < teams.length; ti += 1) teamItems.push(renderTeam(teams[ti], ti));
|
|
3930
3905
|
|
|
@@ -3956,6 +3931,11 @@ window.__ModuleLoader__.load({
|
|
|
3956
3931
|
React.createElement("p", { className: "cohub-notice cohub-mono" }, t("teamPresetUnknown")),
|
|
3957
3932
|
React.createElement("p", { className: "cohub-desc" }, t("teamPresetSwitchHint")),
|
|
3958
3933
|
React.createElement("p", { className: "cohub-desc" }, t("teamsDescription")),
|
|
3934
|
+
// 内置团队随包发布(不在 Config.teams 里):先渲染它们,再渲染用户团队。
|
|
3935
|
+
React.createElement("p", { className: "cohub-desc" }, t("teamBuiltinNote")),
|
|
3936
|
+
builtinTeamItems.length > 0
|
|
3937
|
+
? React.createElement("ul", { className: "cohub-rows" }, builtinTeamItems)
|
|
3938
|
+
: null,
|
|
3959
3939
|
teams.length === 0
|
|
3960
3940
|
? React.createElement("p", { className: "cohub-notice" }, t("teamEmpty"))
|
|
3961
3941
|
: React.createElement("ul", { className: "cohub-rows" }, teamItems),
|
|
@@ -4065,9 +4045,6 @@ window.__ModuleLoader__.load({
|
|
|
4065
4045
|
)
|
|
4066
4046
|
);
|
|
4067
4047
|
|
|
4068
|
-
var items = [];
|
|
4069
|
-
for (var i = 0; i < rows.length; i += 1) items.push(renderRow(rows[i]));
|
|
4070
|
-
|
|
4071
4048
|
var status = null;
|
|
4072
4049
|
var statusClass = "cohub-status";
|
|
4073
4050
|
if (state.conflicted) {
|
|
@@ -4103,7 +4080,10 @@ window.__ModuleLoader__.load({
|
|
|
4103
4080
|
state.conflicted
|
|
4104
4081
|
? React.createElement("p", { className: "cohub-notice cohub-notice-warn" }, t("conflicted"))
|
|
4105
4082
|
: null,
|
|
4106
|
-
|
|
4083
|
+
teamsBlock,
|
|
4084
|
+
rolesBlock,
|
|
4085
|
+
// 角色库 / 角色编辑里的模型区写的是 Config.skills,统一由这条动作条落盘。
|
|
4086
|
+
// 顶部「每个代理一行」的模型区块已移除,这里只剩保存 / 放弃与状态提示。
|
|
4107
4087
|
React.createElement("div", { className: "cohub-actions" },
|
|
4108
4088
|
status !== null ? React.createElement("p", { className: statusClass }, status) : null,
|
|
4109
4089
|
React.createElement("button", {
|
|
@@ -4122,9 +4102,7 @@ window.__ModuleLoader__.load({
|
|
|
4122
4102
|
props.save();
|
|
4123
4103
|
}
|
|
4124
4104
|
}, t(state.saving ? "saving" : "save"))
|
|
4125
|
-
)
|
|
4126
|
-
teamsBlock,
|
|
4127
|
-
rolesBlock
|
|
4105
|
+
)
|
|
4128
4106
|
);
|
|
4129
4107
|
}
|
|
4130
4108
|
|
|
@@ -4206,6 +4184,9 @@ window.__ModuleLoader__.load({
|
|
|
4206
4184
|
addTeam: function () {
|
|
4207
4185
|
controller.addTeam();
|
|
4208
4186
|
},
|
|
4187
|
+
copyBuiltinTeam: function (builtinId) {
|
|
4188
|
+
controller.copyBuiltinTeam(builtinId);
|
|
4189
|
+
},
|
|
4209
4190
|
removeTeam: function (index) {
|
|
4210
4191
|
return controller.removeTeam(index);
|
|
4211
4192
|
},
|
|
@@ -4273,6 +4254,7 @@ window.__ModuleLoader__.load({
|
|
|
4273
4254
|
tierDistributionOf: tierDistributionOf,
|
|
4274
4255
|
teamTitle: teamTitle,
|
|
4275
4256
|
effectiveTeamLead: effectiveTeamLead,
|
|
4257
|
+
builtinTeamsOf: builtinTeamsOf,
|
|
4276
4258
|
isMainAgent: isMainAgent,
|
|
4277
4259
|
roleTierKey: roleTierKey
|
|
4278
4260
|
};
|
package/lib/index.js
CHANGED
|
@@ -804,6 +804,39 @@ function unregisterCohubPresets(ctx, logger) {
|
|
|
804
804
|
return removed;
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
+
// src/builtin-teams.ts
|
|
808
|
+
var BUILTIN_TEAMS = [
|
|
809
|
+
{
|
|
810
|
+
id: "dev",
|
|
811
|
+
name: "开发团队",
|
|
812
|
+
description: "通用软件开发团队:调度 + 12 个专职子代理",
|
|
813
|
+
members: [
|
|
814
|
+
"co-fixer",
|
|
815
|
+
"co-designer",
|
|
816
|
+
"co-explorer",
|
|
817
|
+
"co-oracle",
|
|
818
|
+
"co-planner",
|
|
819
|
+
"co-librarian",
|
|
820
|
+
"co-observer",
|
|
821
|
+
"co-council",
|
|
822
|
+
"co-rule-user",
|
|
823
|
+
"co-rule-project",
|
|
824
|
+
"co-rule-app",
|
|
825
|
+
"co-cordis"
|
|
826
|
+
],
|
|
827
|
+
lead: "co-orchestrator",
|
|
828
|
+
builtin: true
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
id: "writing",
|
|
832
|
+
name: "写作团队",
|
|
833
|
+
description: "中文内容创作团队:选题、成稿、审校",
|
|
834
|
+
members: ["co-writer", "co-editor", "co-outliner"],
|
|
835
|
+
lead: "co-orchestrator",
|
|
836
|
+
builtin: true
|
|
837
|
+
}
|
|
838
|
+
];
|
|
839
|
+
|
|
807
840
|
// src/skills.ts
|
|
808
841
|
var COHUB_SKILLS = [
|
|
809
842
|
{
|
|
@@ -2094,7 +2127,7 @@ function resolveSessionTeam(config, presetId) {
|
|
|
2094
2127
|
const preset = (presetId ?? "").trim();
|
|
2095
2128
|
if (preset.length === 0)
|
|
2096
2129
|
return null;
|
|
2097
|
-
const matched = (config?.teams ?? []).find((team) => teamPresetId(team) === preset);
|
|
2130
|
+
const matched = (config?.teams ?? []).find((team) => teamPresetId(team) === preset) ?? BUILTIN_TEAMS.find((team) => teamPresetId(team) === preset);
|
|
2098
2131
|
if (matched === undefined)
|
|
2099
2132
|
return null;
|
|
2100
2133
|
return buildActiveTeam(matched, (matched.id ?? "").trim());
|
|
@@ -2111,7 +2144,7 @@ function resolveTeamFilter(config, presetId) {
|
|
|
2111
2144
|
}
|
|
2112
2145
|
function resolveTeamLead(team, members) {
|
|
2113
2146
|
const declared = (team.lead ?? "").trim();
|
|
2114
|
-
if (declared.length > 0 && members.includes(declared))
|
|
2147
|
+
if (declared.length > 0 && (members.includes(declared) || declared === PRIMARY_AGENT_ROLE))
|
|
2115
2148
|
return declared;
|
|
2116
2149
|
if (members.includes(PRIMARY_AGENT_ROLE))
|
|
2117
2150
|
return PRIMARY_AGENT_ROLE;
|
|
@@ -2235,6 +2268,7 @@ function resolveSkillSnapshot(config) {
|
|
|
2235
2268
|
|
|
2236
2269
|
// src/team-presets.ts
|
|
2237
2270
|
var TEAM_PRESET_ORDER_BASE = 50;
|
|
2271
|
+
var BUILTIN_TEAM_ORDER_BASE = 40;
|
|
2238
2272
|
var emptyResult = () => ({
|
|
2239
2273
|
registered: [],
|
|
2240
2274
|
updated: [],
|
|
@@ -2257,7 +2291,7 @@ function teamPresetId2(team) {
|
|
|
2257
2291
|
}
|
|
2258
2292
|
function resolveTeamLead2(team, members) {
|
|
2259
2293
|
const declared = typeof team.lead === "string" ? team.lead.trim() : "";
|
|
2260
|
-
if (declared.length > 0 && members.includes(declared))
|
|
2294
|
+
if (declared.length > 0 && (members.includes(declared) || declared === "co-orchestrator"))
|
|
2261
2295
|
return declared;
|
|
2262
2296
|
if (members.includes("co-orchestrator"))
|
|
2263
2297
|
return "co-orchestrator";
|
|
@@ -2313,10 +2347,24 @@ function buildTeamPresetPlugins(persona) {
|
|
|
2313
2347
|
{ id: "skill-filesystem", name: "@deepseek-ai/dsh-skill-filesystem" }
|
|
2314
2348
|
];
|
|
2315
2349
|
}
|
|
2350
|
+
function buildTeamDef(team, order, customRoles) {
|
|
2351
|
+
const teamId = typeof team.id === "string" ? team.id.trim() : "";
|
|
2352
|
+
const members = cleanMembers(team);
|
|
2353
|
+
const lead = resolveTeamLead2(team, members);
|
|
2354
|
+
const name = typeof team.name === "string" && team.name.trim().length > 0 ? team.name.trim() : teamId;
|
|
2355
|
+
const description = `cohub 团队「${name}」:队长 ${lead || "(未指定)"},成员 ${members.length > 0 ? members.join(", ") : "(无)"}`;
|
|
2356
|
+
return {
|
|
2357
|
+
id: teamPresetId2(team),
|
|
2358
|
+
name,
|
|
2359
|
+
description,
|
|
2360
|
+
order,
|
|
2361
|
+
plugins: buildTeamPresetPlugins(buildTeamPersona(team, members, lead, customRoles))
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
2316
2364
|
function buildTeamPresetDefs(config, logger) {
|
|
2317
2365
|
const teams = readList(config?.teams);
|
|
2318
2366
|
const customRoles = readList(config?.customRoles);
|
|
2319
|
-
const
|
|
2367
|
+
const userDefs = [];
|
|
2320
2368
|
const used = new Set;
|
|
2321
2369
|
for (const [index, team] of teams.entries()) {
|
|
2322
2370
|
const teamId = typeof team?.id === "string" ? team.id.trim() : "";
|
|
@@ -2330,19 +2378,18 @@ function buildTeamPresetDefs(config, logger) {
|
|
|
2330
2378
|
continue;
|
|
2331
2379
|
}
|
|
2332
2380
|
used.add(id);
|
|
2333
|
-
|
|
2334
|
-
const lead = resolveTeamLead2(team, members);
|
|
2335
|
-
const name = typeof team.name === "string" && team.name.trim().length > 0 ? team.name.trim() : teamId;
|
|
2336
|
-
const description = `cohub 团队「${name}」:队长 ${lead || "(未指定)"},成员 ${members.length > 0 ? members.join(", ") : "(无)"}`;
|
|
2337
|
-
defs.push({
|
|
2338
|
-
id,
|
|
2339
|
-
name,
|
|
2340
|
-
description,
|
|
2341
|
-
order: TEAM_PRESET_ORDER_BASE + index,
|
|
2342
|
-
plugins: buildTeamPresetPlugins(buildTeamPersona(team, members, lead, customRoles))
|
|
2343
|
-
});
|
|
2381
|
+
userDefs.push(buildTeamDef(team, TEAM_PRESET_ORDER_BASE + index, customRoles));
|
|
2344
2382
|
}
|
|
2345
|
-
|
|
2383
|
+
const builtinDefs = [];
|
|
2384
|
+
for (const [index, team] of BUILTIN_TEAMS.entries()) {
|
|
2385
|
+
const id = teamPresetId2(team);
|
|
2386
|
+
if (used.has(id)) {
|
|
2387
|
+
logger?.info?.(`cohub: 团队 ${team.id} 已被用户配置的同名团队覆盖(预设 id ${id}),跳过内置版本`);
|
|
2388
|
+
continue;
|
|
2389
|
+
}
|
|
2390
|
+
builtinDefs.push(buildTeamDef(team, BUILTIN_TEAM_ORDER_BASE + index, customRoles));
|
|
2391
|
+
}
|
|
2392
|
+
return [...builtinDefs, ...userDefs];
|
|
2346
2393
|
}
|
|
2347
2394
|
var LEDGER_KEY = Symbol.for("cohub.team-presets.ledger.v1");
|
|
2348
2395
|
var stateByRegistry = new WeakMap;
|
|
@@ -2506,8 +2553,9 @@ async function syncTeamPresets(ctx, logger, config) {
|
|
|
2506
2553
|
continue;
|
|
2507
2554
|
sources.set(teamPresetId2(team), team);
|
|
2508
2555
|
}
|
|
2556
|
+
const builtinById = new Map(BUILTIN_TEAMS.map((team) => [teamPresetId2(team), team]));
|
|
2509
2557
|
const membersOf = (id) => {
|
|
2510
|
-
const team = sources.get(id);
|
|
2558
|
+
const team = sources.get(id) ?? builtinById.get(id);
|
|
2511
2559
|
return team === undefined ? 0 : cleanMembers(team).length;
|
|
2512
2560
|
};
|
|
2513
2561
|
for (const [id, entry] of [...state.entries()]) {
|
|
@@ -6052,6 +6100,28 @@ function normalizeArguments(args) {
|
|
|
6052
6100
|
}
|
|
6053
6101
|
return raw.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
6054
6102
|
}
|
|
6103
|
+
function describeFailureDetail(value) {
|
|
6104
|
+
const seen = new Set;
|
|
6105
|
+
let cur = value;
|
|
6106
|
+
let text;
|
|
6107
|
+
while (cur !== null && cur !== undefined && typeof cur === "object" && !seen.has(cur)) {
|
|
6108
|
+
seen.add(cur);
|
|
6109
|
+
const next = cur.error ?? cur.errorMessage ?? cur.failure ?? cur.message ?? cur.cause;
|
|
6110
|
+
if (next === cur || next === null || next === undefined)
|
|
6111
|
+
break;
|
|
6112
|
+
cur = next;
|
|
6113
|
+
}
|
|
6114
|
+
if (typeof cur === "string")
|
|
6115
|
+
text = cur;
|
|
6116
|
+
else if (cur !== null && cur !== undefined && typeof cur !== "object")
|
|
6117
|
+
text = String(cur);
|
|
6118
|
+
if (text === undefined)
|
|
6119
|
+
return;
|
|
6120
|
+
const oneLine = text.replace(/\s+/g, " ").trim();
|
|
6121
|
+
if (oneLine.length === 0)
|
|
6122
|
+
return;
|
|
6123
|
+
return oneLine.length > 200 ? oneLine.slice(0, 200) + "…" : oneLine;
|
|
6124
|
+
}
|
|
6055
6125
|
|
|
6056
6126
|
class StallWatchdog {
|
|
6057
6127
|
cfg;
|
|
@@ -6701,6 +6771,7 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
6701
6771
|
const runAttempts = async (outerSignal) => {
|
|
6702
6772
|
let lastReason = "unknown";
|
|
6703
6773
|
let lastDiagnostic;
|
|
6774
|
+
let lastRunError;
|
|
6704
6775
|
let lastPartial = "";
|
|
6705
6776
|
let lastPartialBudget = "";
|
|
6706
6777
|
const stallState = { last: null };
|
|
@@ -6814,6 +6885,7 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
6814
6885
|
await new Promise((r) => setTimeout(r, retry.retryDelayMs));
|
|
6815
6886
|
continue;
|
|
6816
6887
|
}
|
|
6888
|
+
lastRunError = describeFailureDetail(error) ?? lastRunError;
|
|
6817
6889
|
reportAttempt("", "failed", String(error?.message ?? error));
|
|
6818
6890
|
throw error;
|
|
6819
6891
|
}
|
|
@@ -6850,6 +6922,7 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
6850
6922
|
await safeDispose();
|
|
6851
6923
|
outcome = { stopReason: "aborted", output: [], diagnostic: "raced abort(result 未结算)" };
|
|
6852
6924
|
} else {
|
|
6925
|
+
lastRunError = describeFailureDetail(error) ?? lastRunError;
|
|
6853
6926
|
reportAttempt(String(run?.id ?? ""), "failed", "error");
|
|
6854
6927
|
throw error;
|
|
6855
6928
|
}
|
|
@@ -6899,7 +6972,9 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
6899
6972
|
return budgeted + formatDegradeNotes(degradeNotes) + contractMark;
|
|
6900
6973
|
}
|
|
6901
6974
|
lastReason = String(outcome?.stopReason ?? "unknown");
|
|
6902
|
-
|
|
6975
|
+
const outcomeDiag = typeof outcome?.diagnostic === "string" && outcome.diagnostic.length > 0 ? outcome.diagnostic : undefined;
|
|
6976
|
+
const residualDetail = describeFailureDetail(outcome);
|
|
6977
|
+
lastDiagnostic = outcomeDiag ?? (residualDetail !== undefined ? "subagent error: " + residualDetail : lastRunError === undefined ? undefined : "run error: " + lastRunError);
|
|
6903
6978
|
const partialRaw = contentText(outcome?.output ?? []);
|
|
6904
6979
|
lastPartial = partialRaw.slice(0, 500);
|
|
6905
6980
|
lastPartialBudget = budget.enabled && partialRaw.length > budget.partialMaxChars ? applyResultBudget(partialRaw, {
|
|
@@ -7615,6 +7690,12 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
7615
7690
|
degradeNotes: taskNotes
|
|
7616
7691
|
});
|
|
7617
7692
|
const run = await spawnAgain(promptText, ac.signal);
|
|
7693
|
+
const timing = {};
|
|
7694
|
+
const markSettled = () => {
|
|
7695
|
+
if (timing.endedAt === undefined)
|
|
7696
|
+
timing.endedAt = Date.now();
|
|
7697
|
+
};
|
|
7698
|
+
run.result.then(markSettled, markSettled);
|
|
7618
7699
|
return {
|
|
7619
7700
|
taskId,
|
|
7620
7701
|
skillName: skill.name,
|
|
@@ -7625,6 +7706,7 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
7625
7706
|
ac,
|
|
7626
7707
|
onExecAbort,
|
|
7627
7708
|
startedAt,
|
|
7709
|
+
timing,
|
|
7628
7710
|
startError: undefined,
|
|
7629
7711
|
skillError: undefined,
|
|
7630
7712
|
outputContract,
|
|
@@ -7741,7 +7823,7 @@ ${attribution}`,
|
|
|
7741
7823
|
}, val.startedAt, startErrAt));
|
|
7742
7824
|
continue;
|
|
7743
7825
|
}
|
|
7744
|
-
const { run, taskId, skillName, skillTag, taskNotes, ac, onExecAbort, startedAt, outputContract, buildPrompt, spawnAgain } = val;
|
|
7826
|
+
const { run, taskId, skillName, skillTag, taskNotes, ac, onExecAbort, startedAt, timing, outputContract, buildPrompt, spawnAgain } = val;
|
|
7745
7827
|
const taskEvents = batchEvents[index] ?? [];
|
|
7746
7828
|
let disposed = false;
|
|
7747
7829
|
const safeDispose = () => {
|
|
@@ -7750,11 +7832,11 @@ ${attribution}`,
|
|
|
7750
7832
|
disposed = true;
|
|
7751
7833
|
Promise.resolve().then(() => run.dispose()).catch(() => {});
|
|
7752
7834
|
};
|
|
7753
|
-
runs.push({ run, safeDispose, taskId, skillName, skillTag, taskNotes, ac, onExecAbort, startedAt, taskEvents, outputContract, buildPrompt, spawnAgain });
|
|
7835
|
+
runs.push({ run, safeDispose, taskId, skillName, skillTag, taskNotes, ac, onExecAbort, startedAt, timing, taskEvents, outputContract, buildPrompt, spawnAgain });
|
|
7754
7836
|
perTaskNotes.push({ taskId, notes: taskNotes });
|
|
7755
7837
|
run.result.catch(() => {});
|
|
7756
7838
|
}
|
|
7757
|
-
for (const { run, safeDispose, taskId, skillName, skillTag, taskNotes, ac, startedAt, taskEvents, outputContract, buildPrompt, spawnAgain } of runs) {
|
|
7839
|
+
for (const { run, safeDispose, taskId, skillName, skillTag, taskNotes, ac, startedAt, timing, taskEvents, outputContract, buildPrompt, spawnAgain } of runs) {
|
|
7758
7840
|
let outcome;
|
|
7759
7841
|
let timer = null;
|
|
7760
7842
|
const runId = typeof run?.id === "string" && run.id.length > 0 ? run.id : undefined;
|
|
@@ -7876,7 +7958,7 @@ ${attribution}`,
|
|
|
7876
7958
|
ctx.logger?.warn?.("[cohub contract] " + taskId + " 输出未满足契约(" + outputContract.level + "):" + check.errors.join(";"));
|
|
7877
7959
|
}
|
|
7878
7960
|
}
|
|
7879
|
-
const endedAt = Date.now();
|
|
7961
|
+
const endedAt = timing.endedAt ?? Date.now();
|
|
7880
7962
|
pushBatchEvent(taskEvents, {
|
|
7881
7963
|
taskId,
|
|
7882
7964
|
phase: "completed",
|
|
@@ -7900,8 +7982,9 @@ ${attribution}`,
|
|
|
7900
7982
|
...contractViolated ? { contractViolated: true } : {}
|
|
7901
7983
|
}, startedAt, endedAt, runId));
|
|
7902
7984
|
} else {
|
|
7903
|
-
const endedAt = Date.now();
|
|
7904
|
-
const
|
|
7985
|
+
const endedAt = timing.endedAt ?? Date.now();
|
|
7986
|
+
const residual = describeFailureDetail(outcome);
|
|
7987
|
+
const diag = typeof outcome?.diagnostic === "string" && outcome.diagnostic.length > 0 ? outcome.diagnostic : residual === undefined ? undefined : "subagent error: " + residual;
|
|
7905
7988
|
pushBatchEvent(taskEvents, {
|
|
7906
7989
|
taskId,
|
|
7907
7990
|
phase: "failed",
|
|
@@ -7920,8 +8003,9 @@ ${attribution}`,
|
|
|
7920
8003
|
}, startedAt, endedAt, runId));
|
|
7921
8004
|
}
|
|
7922
8005
|
} catch (e) {
|
|
7923
|
-
const endedAt = Date.now();
|
|
7924
|
-
const
|
|
8006
|
+
const endedAt = timing.endedAt ?? Date.now();
|
|
8007
|
+
const rawMessage = e instanceof Error ? e.message : String(e);
|
|
8008
|
+
const message = describeFailureDetail(rawMessage) ?? rawMessage;
|
|
7925
8009
|
pushBatchEvent(taskEvents, {
|
|
7926
8010
|
taskId,
|
|
7927
8011
|
phase: message.startsWith("超时") ? "timeout" : "failed",
|
|
@@ -10448,6 +10532,8 @@ function apply(ctx, config) {
|
|
|
10448
10532
|
}
|
|
10449
10533
|
}
|
|
10450
10534
|
export {
|
|
10535
|
+
BUILTIN_TEAMS,
|
|
10536
|
+
BUILTIN_TEAM_ORDER_BASE,
|
|
10451
10537
|
COHUB_PRESETS_DIR,
|
|
10452
10538
|
CohubSettingsSchema,
|
|
10453
10539
|
Config,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cohub",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.9",
|
|
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",
|