dsh-cohub 0.13.6 → 0.13.7

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/lib/client.js CHANGED
@@ -487,6 +487,12 @@ window.__ModuleLoader__.load({
487
487
  /** Config.customRoles[].tier 的五个合法档位(自定义角色不得越权,取值与 Config schema 一致)。 */
488
488
  var ROLE_TIERS = ["ro", "ro-net", "rw", "rw-shell", "cordis"];
489
489
 
490
+ /**
491
+ * 主代理名。co-orchestrator 是会话主代理,**不在 roles.ts 的 BUILTIN_ROLE_TIERS 档位表里**,
492
+ * 目录里它的 tier 是 null:档位/工具必须给专属文案,不能落进 tierLabel 的「未知档位」降级分支。
493
+ */
494
+ var MAIN_AGENT_NAME = "co-orchestrator";
495
+
490
496
  /** 自定义角色名必须是 kebab-case:运行时把它注册成 skill 名,含空格/大写会污染技能表。 */
491
497
  var ROLE_NAME_PATTERN = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
492
498
 
@@ -538,14 +544,32 @@ window.__ModuleLoader__.load({
538
544
  rolesTitle: "角色库",
539
545
  rolesDescription: "先在这里建角色,再到上面的「团队」里勾选为成员。保存后运行时注册器约 1 秒内热加载,无需重启。",
540
546
  teamsTitle: "团队",
541
- teamsDescription: "把角色编成团队:勾选成员后点「设为当前」,本次会话只用当前团队的成员。",
547
+ teamsDescription: "把角色编成团队:每个团队会自动注册为一个 Agent 预设,在 DSH 的「Agent 预设」里选它即可开局。",
542
548
  teamEmpty: "还没有团队。点「新建团队」开始。",
543
549
  teamAdd: "新建团队",
544
550
  teamRemove: "删除",
545
- teamSetActive: "设为当前",
546
- teamUnsetActive: "取消当前",
547
- teamActiveBadge: "当前",
551
+ teamPresetUnknown: "当前会话预设:未知(在 Agent 预设里选择后此处会显示)",
552
+ teamPresetSwitchHint: "切换请在 设置 → Agent 预设 里选择",
553
+ teamPresetIdBadge: "预设 id:{id}",
554
+ teamPresetSlug: "预设 id(slug,可改)",
555
+ teamPresetIdFinal: "最终预设 id:{id}",
556
+ teamSlugPlaceholder: "例如:writing",
557
+ teamNewPresetHint: "保存后将注册为 Agent 预设,可在 Agent 预设列表中选择。",
558
+ teamSaveRegisterHint: "保存后立即出现在 Agent 预设选择器中,无需重启。",
559
+ teamMemberWarn: "成员警告:{names} 为空或已不在角色库中(不阻止保存)。",
560
+ teamMemberEmpty: "(空成员)",
561
+ teamActiveBadge: "当前会话",
548
562
  teamUnsaved: "未命名团队",
563
+ teamNamePlaceholder: "例如:writing",
564
+ teamLead: "队长",
565
+ teamLeadBadge: "队长:{name}",
566
+ teamLeadEmpty: "先选成员",
567
+ teamLeadHint: "队长是本团队的主责角色,派发时优先使用。",
568
+ teamLeadDangling: "已不在成员中",
569
+ teamErrLeadNotMember: "队长必须是本团队已勾选的成员。",
570
+ "tier.mainAgent": "主代理·纯调度",
571
+ roleToolMainAgent: "主代理 preset(含委派工具)",
572
+ roleDetailMainAgent: "主代理不绑定档位,工具由会话的 agent preset 决定",
549
573
  teamMemberCount: "{count} 个成员",
550
574
  teamName: "团队名",
551
575
  teamDescription: "说明",
@@ -553,8 +577,8 @@ window.__ModuleLoader__.load({
553
577
  teamMembersEmpty: "先到下方「角色库」创建自定义角色。",
554
578
  teamBuiltinGroup: "内置角色",
555
579
  teamCustomGroup: "自定义角色",
556
- teamSavedLabel: "保存团队",
557
- teamSaved: "已保存,约 1 秒后生效,无需重启。",
580
+ teamSavedLabel: "保存并注册预设",
581
+ teamSaved: "已保存并注册为 Agent 预设,约 1 秒后可在 Agent 预设选择器中看到,无需重启。",
558
582
  teamDirty: "有未保存的修改。",
559
583
  teamErrSummary: "有 {count} 处不合法,已标红,未保存。",
560
584
  teamErrNameRequired: "团队名不能为空。",
@@ -604,6 +628,62 @@ window.__ModuleLoader__.load({
604
628
  roleDetailBuiltinHint: "内置,只读",
605
629
  roleDetailCustomHint: "自定义,只读",
606
630
  roleDetailReadOnly: "仅展示:编辑提示词请用角色卡片里的「提示词」字段。",
631
+ // ── 模板新建 / 绑定工具 / 运行模型 ──────────────────────────────
632
+ roleTemplateSection: "选择一个模板开始",
633
+ roleTemplateHint: "选中模板会自动填好名称(加 -copy 后缀防重名)、职责、提示词、档位与绑定工具。",
634
+ roleTemplateBlank: "空白角色",
635
+ roleTemplateBlankDesc: "从零填写名称、职责与提示词。",
636
+ roleTemplateMain: "co-orchestrator · 通用编排主代理",
637
+ roleTemplateMainDesc: "通用编排主代理 · 纯调度 · 不绑定档位",
638
+ roleTemplateBasedOn: "基于模板:{name}",
639
+ roleTemplateReselect: "重新选择模板",
640
+ roleTemplateNone: "未选模板:提示词 / 工具 / 模型区暂不可编辑。",
641
+ roleToolCountSuffix: "{count} 个工具",
642
+ roleToolsTitle: "绑定工具",
643
+ roleToolsCount: "已选 {count} 个工具",
644
+ roleToolsTierHint: "档位快捷组合(点一下批量勾选)",
645
+ roleToolsEmpty: "还没绑定工具:保存后按档位组合兜底。",
646
+ roleToolsShellWarn: "勾了 Shell 但没勾文件读写:子代理无法定位或修改文件,建议同时勾上「文件读写」。",
647
+ roleModelTitle: "运行模型",
648
+ roleModelBuiltinNote: "提示词与工具由插件维护,模型路由可单独配置。",
649
+ roleModelInherit: "继承",
650
+ roleModelProvider: "供应商",
651
+ roleModelModel: "模型",
652
+ roleModelProviderDefault: "继承默认(跟随会话)",
653
+ roleModelPickProvider: "先选供应商",
654
+ roleModelPickModel: "选择模型",
655
+ roleModelReasoning: "推理强度",
656
+ roleModelReasoningHint: "默认 = 跟随会话设置",
657
+ roleModelMaxOutput: "最大输出",
658
+ roleModelMaxOutputPlaceholder: "例如 4000",
659
+ roleModelReset: "恢复默认",
660
+ roleMainBadge: "通用编排主代理 · 纯调度 · 不绑定档位",
661
+ roleMainNew: "以此模板新建",
662
+ roleMainDetail: "查看详情",
663
+ "effort.default": "默认",
664
+ "effort.low": "低",
665
+ "effort.medium": "中",
666
+ "effort.high": "高",
667
+ toolGroupFile: "文件",
668
+ toolGroupNet: "联网",
669
+ toolGroupExec: "执行",
670
+ toolGroupOrch: "编排",
671
+ toolGroupExt: "外部",
672
+ "tool.tool-fs": "文件读写",
673
+ "tool.tool-fs-search": "文件搜索",
674
+ "tool.tool-web": "联网抓取",
675
+ "tool.tool-bash": "Shell(bash)",
676
+ "tool.tool-pwsh": "Shell(pwsh)",
677
+ "tool.tool-skill": "技能",
678
+ "tool.tool-todo": "待办",
679
+ "tool.tool-jobs": "后台任务",
680
+ "tool.tool-goal": "目标",
681
+ "tool.tool-ask-user": "追问用户",
682
+ "tool.tool-delegation": "委派",
683
+ "tool.mcp-github": "GitHub MCP",
684
+ "gate.posix": "仅 POSIX",
685
+ "gate.windows": "仅 Windows",
686
+ "gate.mcp": "需 MCP 授权",
607
687
  builtinRolesTitle: "内置角色",
608
688
  builtinRolesDescription: "内置角色来自插件目录,提示词与绑定工具只读展示,不能在这里删改。",
609
689
  teamTierDistribution: "成员档位分布",
@@ -658,14 +738,32 @@ window.__ModuleLoader__.load({
658
738
  rolesTitle: "Role library",
659
739
  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.",
660
740
  teamsTitle: "Teams",
661
- teamsDescription: "Group roles into teams: tick the members, then click \"Set active\" — only the active team's members stay available in this session.",
741
+ teamsDescription: "Group roles into teams: every team is registered as an Agent preset — pick it in DSH's \"Agent presets\" to start a session.",
662
742
  teamEmpty: "No teams yet. Click \"New team\" to start.",
663
743
  teamAdd: "New team",
664
744
  teamRemove: "Remove",
665
- teamSetActive: "Set active",
666
- teamUnsetActive: "Clear active",
667
- teamActiveBadge: "Active",
745
+ teamPresetUnknown: "Current session preset: unknown (pick one under Agent presets and it will show here)",
746
+ teamPresetSwitchHint: "To switch, use Settings → Agent presets",
747
+ teamPresetIdBadge: "Preset id: {id}",
748
+ teamPresetSlug: "Preset id (slug, editable)",
749
+ teamPresetIdFinal: "Final preset id: {id}",
750
+ teamSlugPlaceholder: "e.g. writing",
751
+ teamNewPresetHint: "Saving registers this team as an Agent preset, selectable in the Agent presets list.",
752
+ teamSaveRegisterHint: "It appears in the Agent presets picker right after saving — no restart needed.",
753
+ teamMemberWarn: "Member warning: {names} is empty or no longer in the role library (saving is still allowed).",
754
+ teamMemberEmpty: "(empty member)",
755
+ teamActiveBadge: "Current session",
668
756
  teamUnsaved: "Unnamed team",
757
+ teamNamePlaceholder: "e.g. writing",
758
+ teamLead: "Lead",
759
+ teamLeadBadge: "Lead: {name}",
760
+ teamLeadEmpty: "Pick members first",
761
+ teamLeadHint: "The lead is the team's primary role, preferred when dispatching.",
762
+ teamLeadDangling: "no longer a member",
763
+ teamErrLeadNotMember: "The lead must be one of the members ticked for this team.",
764
+ "tier.mainAgent": "Main agent · orchestration only",
765
+ roleToolMainAgent: "Main agent preset (delegation tools included)",
766
+ roleDetailMainAgent: "The main agent has no tier; its tools come from the session's agent preset.",
669
767
  teamMemberCount: "{count} member(s)",
670
768
  teamName: "Team name",
671
769
  teamDescription: "Description",
@@ -673,8 +771,8 @@ window.__ModuleLoader__.load({
673
771
  teamMembersEmpty: "Create a custom role in the Role library below first.",
674
772
  teamBuiltinGroup: "Built-in roles",
675
773
  teamCustomGroup: "Custom roles",
676
- teamSavedLabel: "Save teams",
677
- teamSaved: "Saved. Takes effect in about 1 second — no restart needed.",
774
+ teamSavedLabel: "Save & register preset",
775
+ teamSaved: "Saved and registered as an Agent preset — visible in the Agent presets picker in about 1 second, no restart needed.",
678
776
  teamDirty: "Unsaved changes.",
679
777
  teamErrSummary: "{count} invalid field(s), highlighted in red. Nothing was saved.",
680
778
  teamErrNameRequired: "Team name is required.",
@@ -724,6 +822,61 @@ window.__ModuleLoader__.load({
724
822
  roleDetailBuiltinHint: "built-in, read-only",
725
823
  roleDetailCustomHint: "custom, read-only",
726
824
  roleDetailReadOnly: "Read-only view — edit the prompt in the role card's \"Prompt\" field.",
825
+ roleTemplateSection: "Start from a template",
826
+ roleTemplateHint: "Picking a template fills in the name (-copy suffix avoids collisions), description, prompt, tier and bound tools.",
827
+ roleTemplateBlank: "Blank role",
828
+ roleTemplateBlankDesc: "Fill in name, description and prompt from scratch.",
829
+ roleTemplateMain: "co-orchestrator · general orchestrator",
830
+ roleTemplateMainDesc: "General orchestrator · dispatch only · no tier",
831
+ roleTemplateBasedOn: "Based on template: {name}",
832
+ roleTemplateReselect: "Pick another template",
833
+ roleTemplateNone: "No template yet — prompt / tools / model stay disabled until you pick one.",
834
+ roleToolCountSuffix: "{count} tools",
835
+ roleToolsTitle: "Bound tools",
836
+ roleToolsCount: "{count} tools selected",
837
+ roleToolsTierHint: "Tier shortcut (click to check them all)",
838
+ roleToolsEmpty: "No tools bound yet — saving falls back to the tier combination.",
839
+ roleToolsShellWarn: "Shell is checked without file tools: the child agent cannot locate or edit files. Consider adding \"File access\".",
840
+ roleModelTitle: "Model",
841
+ roleModelBuiltinNote: "Prompt and tools are maintained by the plugin; model routing can be configured separately.",
842
+ roleModelInherit: "Inherited",
843
+ roleModelProvider: "Provider",
844
+ roleModelModel: "Model",
845
+ roleModelProviderDefault: "Inherit default (follow session)",
846
+ roleModelPickProvider: "Pick a provider first",
847
+ roleModelPickModel: "Pick a model",
848
+ roleModelReasoning: "Reasoning effort",
849
+ roleModelReasoningHint: "Default follows the session setting",
850
+ roleModelMaxOutput: "Max output",
851
+ roleModelMaxOutputPlaceholder: "e.g. 4000",
852
+ roleModelReset: "Reset",
853
+ roleMainBadge: "General orchestrator · dispatch only · no tier",
854
+ roleMainNew: "New role from this template",
855
+ roleMainDetail: "View details",
856
+ "effort.default": "Default",
857
+ "effort.low": "Low",
858
+ "effort.medium": "Medium",
859
+ "effort.high": "High",
860
+ toolGroupFile: "Files",
861
+ toolGroupNet: "Web",
862
+ toolGroupExec: "Execution",
863
+ toolGroupOrch: "Orchestration",
864
+ toolGroupExt: "External",
865
+ "tool.tool-fs": "File access",
866
+ "tool.tool-fs-search": "File search",
867
+ "tool.tool-web": "Web fetch",
868
+ "tool.tool-bash": "Shell (bash)",
869
+ "tool.tool-pwsh": "Shell (pwsh)",
870
+ "tool.tool-skill": "Skills",
871
+ "tool.tool-todo": "Todo",
872
+ "tool.tool-jobs": "Background jobs",
873
+ "tool.tool-goal": "Goal",
874
+ "tool.tool-ask-user": "Ask user",
875
+ "tool.tool-delegation": "Delegation",
876
+ "tool.mcp-github": "GitHub MCP",
877
+ "gate.posix": "POSIX only",
878
+ "gate.windows": "Windows only",
879
+ "gate.mcp": "Needs MCP auth",
727
880
  builtinRolesTitle: "Built-in roles",
728
881
  builtinRolesDescription: "Built-in roles come from the plugin catalog; their prompts and bound tools are shown read-only and cannot be changed here.",
729
882
  teamTierDistribution: "Member tier mix",
@@ -895,15 +1048,21 @@ window.__ModuleLoader__.load({
895
1048
  /* ── 纯数据层:Config.customRoles ↔ 编辑行 ────────────────────── */
896
1049
 
897
1050
  function emptyRole() {
898
- return { name: "", description: "", prompt: "", tier: "ro" };
1051
+ return { name: "", description: "", prompt: "", tier: "ro", tools: [] };
899
1052
  }
900
1053
 
901
1054
  function copyRole(role) {
1055
+ var tools = [];
1056
+ var list = role && Array.isArray(role.tools) ? role.tools : [];
1057
+ for (var i = 0; i < list.length; i += 1) {
1058
+ if (typeof list[i] === "string" && list[i] !== "" && tools.indexOf(list[i]) < 0) tools.push(list[i]);
1059
+ }
902
1060
  return {
903
1061
  name: typeof role.name === "string" ? role.name : "",
904
1062
  description: typeof role.description === "string" ? role.description : "",
905
1063
  prompt: typeof role.prompt === "string" ? role.prompt : "",
906
- tier: ROLE_TIERS.indexOf(role.tier) >= 0 ? role.tier : "ro"
1064
+ tier: ROLE_TIERS.indexOf(role.tier) >= 0 ? role.tier : "ro",
1065
+ tools: tools
907
1066
  };
908
1067
  }
909
1068
 
@@ -924,7 +1083,7 @@ window.__ModuleLoader__.load({
924
1083
  return rows;
925
1084
  }
926
1085
 
927
- /** 编辑行 → 待写入的 customRoles 数组(只写四个受控字段,tier 越界退回 ro)。 */
1086
+ /** 编辑行 → 待写入的 customRoles 数组(只写受控字段:name/description/prompt/tier/tools)。 */
928
1087
  function rolesToCustomRoles(rows) {
929
1088
  var out = [];
930
1089
  if (!Array.isArray(rows)) return out;
@@ -936,6 +1095,147 @@ window.__ModuleLoader__.load({
936
1095
  return out;
937
1096
  }
938
1097
 
1098
+ /* ── 纯数据层:绑定工具分组 / 角色模板(模板新建用) ───────────── */
1099
+
1100
+ /**
1101
+ * 工具分组:id 就是写进 Config.customRoles[].tools 的插件 id
1102
+ * (与 schema index.ts:152 的 `z.array(z.string().min(1))` 同口径,不做形状校验)。
1103
+ * gate 只是展示用的门控说明(bash 仅 POSIX / pwsh 仅 Windows / mcp 需授权)。
1104
+ */
1105
+ var TOOL_GROUPS = [
1106
+ {
1107
+ id: "file",
1108
+ labelKey: "toolGroupFile",
1109
+ items: [
1110
+ { id: "tool-fs", plugin: "dsh-tool-fs" },
1111
+ { id: "tool-fs-search", plugin: "dsh-tool-fs-search" }
1112
+ ]
1113
+ },
1114
+ {
1115
+ id: "net",
1116
+ labelKey: "toolGroupNet",
1117
+ items: [{ id: "tool-web", plugin: "dsh-tool-web" }]
1118
+ },
1119
+ {
1120
+ id: "exec",
1121
+ labelKey: "toolGroupExec",
1122
+ items: [
1123
+ { id: "tool-bash", plugin: "dsh-tool-bash", gate: "posix" },
1124
+ { id: "tool-pwsh", plugin: "dsh-tool-pwsh", gate: "windows" }
1125
+ ]
1126
+ },
1127
+ {
1128
+ id: "orch",
1129
+ labelKey: "toolGroupOrch",
1130
+ items: [
1131
+ { id: "tool-skill", plugin: "dsh-tool-skill" },
1132
+ { id: "tool-todo", plugin: "dsh-tool-todo" },
1133
+ { id: "tool-jobs", plugin: "dsh-tool-jobs" },
1134
+ { id: "tool-goal", plugin: "dsh-tool-goal" },
1135
+ { id: "tool-ask-user", plugin: "dsh-tool-ask-user" },
1136
+ { id: "tool-delegation", plugin: "dsh-tool-delegation" }
1137
+ ]
1138
+ },
1139
+ {
1140
+ id: "ext",
1141
+ labelKey: "toolGroupExt",
1142
+ items: [{ id: "mcp-github", plugin: "mcp-github", gate: "mcp" }]
1143
+ }
1144
+ ];
1145
+
1146
+ /** 单个工具项在 TOOL_GROUPS 里的登记(找不到返回 null)。 */
1147
+ function toolItemOf(id) {
1148
+ for (var g = 0; g < TOOL_GROUPS.length; g += 1) {
1149
+ var items = TOOL_GROUPS[g].items;
1150
+ for (var i = 0; i < items.length; i += 1) if (items[i].id === id) return items[i];
1151
+ }
1152
+ return null;
1153
+ }
1154
+
1155
+ /**
1156
+ * 角色目录里的插件短名 → 本页工具 id。
1157
+ * pluginShortName 已经剥掉 dsh-tool- 前缀(dsh-tool-fs → fs),所以这里补回 tool-;
1158
+ * dsh-tool-web-search / dsh-tool-web-fetch 都归到 tool-web;mcp-github 原样保留。
1159
+ */
1160
+ function toolIdOfPlugin(plugin) {
1161
+ var short = pluginShortName(plugin);
1162
+ if (short.indexOf("mcp-") === 0) return short;
1163
+ if (short.indexOf("web") === 0) return "tool-web";
1164
+ return "tool-" + short;
1165
+ }
1166
+
1167
+ /** 档位对应的工具 id 列表(点档位快捷按钮时批量勾选它)。 */
1168
+ function tierToolIds(tier) {
1169
+ var list = tierToolsOf(tier);
1170
+ var out = [];
1171
+ for (var i = 0; i < list.length; i += 1) {
1172
+ var id = toolIdOfPlugin(list[i] && list[i].plugin ? list[i].plugin : "");
1173
+ if (id !== "" && out.indexOf(id) < 0) out.push(id);
1174
+ }
1175
+ return out;
1176
+ }
1177
+
1178
+ /** 勾了 Shell 却没勾文件工具 → 回调里没法定位文件,给一条黄色提示。 */
1179
+ function shellWithoutFs(tools) {
1180
+ var list = Array.isArray(tools) ? tools : [];
1181
+ var hasShell = list.indexOf("tool-bash") >= 0 || list.indexOf("tool-pwsh") >= 0;
1182
+ return hasShell && list.indexOf("tool-fs") < 0;
1183
+ }
1184
+
1185
+ /**
1186
+ * 模板清单:co-orchestrator 置顶(突出)→ 16 个内置角色 → 空白角色。
1187
+ * 数据全部来自构建期生成的 ROLE_CATALOG,运行期零 IO。
1188
+ */
1189
+ function roleTemplateList() {
1190
+ var roles = ROLE_CATALOG && ROLE_CATALOG.roles ? ROLE_CATALOG.roles : {};
1191
+ var out = [{
1192
+ id: "co-orchestrator",
1193
+ name: "co-orchestrator",
1194
+ main: true,
1195
+ description: "通用编排主代理 · 纯调度 · 不绑定档位",
1196
+ brief: "你是纯调度主代理:只分析需求、委派子代理、审核产出,不直接改文件。每轮只派发当前最必要的一组任务,说明目标、约束与验收标准;收到结果后核对证据再决定下一步。",
1197
+ tier: "",
1198
+ tools: []
1199
+ }];
1200
+ for (var i = 0; i < BUILTIN_ROLE_NAMES.length; i += 1) {
1201
+ var name = BUILTIN_ROLE_NAMES[i];
1202
+ var entry = roles[name] && typeof roles[name] === "object" ? roles[name] : null;
1203
+ var tier = entry && typeof entry.tier === "string" ? entry.tier : "";
1204
+ var tools = tierToolIds(tier);
1205
+ out.push({
1206
+ id: name,
1207
+ name: name,
1208
+ main: false,
1209
+ description: entry && typeof entry.description === "string" ? entry.description : "",
1210
+ brief: entry && typeof entry.brief === "string" ? entry.brief : "",
1211
+ tier: tier,
1212
+ tools: tools
1213
+ });
1214
+ }
1215
+ out.push({ id: "blank", name: "", blank: true, main: false, description: "", brief: "", tier: "", tools: [] });
1216
+ return out;
1217
+ }
1218
+
1219
+ /** 按 id 取模板(空白角色用 id="")。 */
1220
+ function templateOf(id) {
1221
+ var list = roleTemplateList();
1222
+ for (var i = 0; i < list.length; i += 1) if (list[i].id === id) return list[i];
1223
+ return null;
1224
+ }
1225
+
1226
+ /** 模板新建的默认名:加 -copy 后缀防与内置角色重名,重复时再追加序号。 */
1227
+ function templateRoleName(base, taken) {
1228
+ var raw = typeof base === "string" && base !== "" ? base : "co-role";
1229
+ var used = Array.isArray(taken) ? taken : [];
1230
+ var candidate = raw + "-copy";
1231
+ var n = 2;
1232
+ while (used.indexOf(candidate) >= 0) {
1233
+ candidate = raw + "-copy-" + n;
1234
+ n += 1;
1235
+ }
1236
+ return candidate;
1237
+ }
1238
+
939
1239
  /**
940
1240
  * 提交前的前端校验:违反任一条就不写配置(写进去会污染技能表或让子代理拿错档位)。
941
1241
  * 规则:name 必填 + kebab-case + 不撞内置 SKILL_NAMES + 表内不重名;description / prompt 非空。
@@ -983,9 +1283,50 @@ window.__ModuleLoader__.load({
983
1283
  /** 团队 id 的合法形状,与服务端 Team.id 的 pattern 一致。 */
984
1284
  var TEAM_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
985
1285
 
1286
+ /** 团队预设 id 的固定前缀:注册器把团队落成一个叫 `cohub-team-<slug>` 的 Agent 预设。 */
1287
+ var TEAM_PRESET_PREFIX = "cohub-team-";
1288
+
1289
+ /**
1290
+ * 团队 → Agent 预设 id:与 src/team-presets.ts 的 teamPresetId **同一条规则**:
1291
+ * 显式 presetId 优先,否则按 `cohub-team-<团队 id>` 推导(服务端注册时用的就是它)。
1292
+ * 空串 / 纯空白视为「未配置」。
1293
+ */
1294
+ function teamPresetId(team) {
1295
+ var declared = team && typeof team.presetId === "string" ? team.presetId.trim() : "";
1296
+ if (declared !== "") return declared;
1297
+ return TEAM_PRESET_PREFIX + (team && typeof team.id === "string" ? team.id.trim() : "");
1298
+ }
1299
+
1300
+ /**
1301
+ * 编辑面板里那个 **可改的** slug 输入框的值:
1302
+ * 1. 用户手改过(slugEdited)→ 原样返回他填的(允许暂时不合法,交给 validateTeams 标红);
1303
+ * 2. 否则显式 presetId 剥掉 `cohub-team-` 前缀(配置里手写过 prefix 形式时);
1304
+ * 3. 再退到团队 id —— 中文名折成空串时 id 已被 uniqueTeamId 兜底成 "team",所以这里是 "team"。
1305
+ * 这就是根修点:中文团队名默认 slug 只能是 "team",现在用户可以亲手填成 writing。
1306
+ */
1307
+ function teamSlugOf(team) {
1308
+ if (team && team.slugEdited === true) return typeof team.slug === "string" ? team.slug : "";
1309
+ var declared = team && typeof team.presetId === "string" ? team.presetId.trim() : "";
1310
+ if (declared.indexOf(TEAM_PRESET_PREFIX) === 0 && declared.length > TEAM_PRESET_PREFIX.length) {
1311
+ return declared.slice(TEAM_PRESET_PREFIX.length);
1312
+ }
1313
+ var id = team && typeof team.id === "string" ? team.id.trim() : "";
1314
+ return id !== "" ? id : "team";
1315
+ }
1316
+
1317
+ /**
1318
+ * 卡片徽标与输入框右侧提示共用的「最终预设 id」:
1319
+ * 手改过 → `cohub-team-<手填值>`;否则沿用 teamPresetId(显式 presetId,或 cohub-team-<id>)。
1320
+ * 落库规则见 teamsToConfig —— 三处口径必须一致,否则「提示的 id」和「注册出来的 id」会漂。
1321
+ */
1322
+ function teamPresetIdOf(team) {
1323
+ if (team && team.slugEdited === true) return TEAM_PRESET_PREFIX + teamSlugOf(team);
1324
+ return teamPresetId(team);
1325
+ }
1326
+
986
1327
  /**
987
1328
  * 团队 id 生成:name 转 kebab-case(小写、非字母数字折成单连字符、去首尾连字符)。
988
- * 中文名折完可能为空串 → 返回 "",由 uniqueTeamId 兜底成 "team"。
1329
+ * 中文名折完是空串(ASCII 折叠规则,不做音译)→ 返回 "",由 uniqueTeamId 兜底成 "team"。
989
1330
  */
990
1331
  function kebabIdOf(name) {
991
1332
  var raw = typeof name === "string" ? name.trim().toLowerCase() : "";
@@ -1016,9 +1357,29 @@ window.__ModuleLoader__.load({
1016
1357
  return base + "-" + String(Date.now());
1017
1358
  }
1018
1359
 
1019
- /** 新建团队的草稿行(id 先占位,isNew 让改名时重算 id;保存时不外泄该标记)。 */
1360
+ /**
1361
+ * 团队的有效队长(默认值规则唯一入口,下拉框默认选中与保存写回都用它):
1362
+ * 1. 显式 lead 且确实在 members 里 → 用它;
1363
+ * 2. lead 为空(或悬空)且成员含 co-orchestrator → 选 co-orchestrator(主代理天然是调度者);
1364
+ * 3. 否则取第一个成员;没有成员 → ""。
1365
+ */
1366
+ function effectiveTeamLead(team) {
1367
+ var members = team && Array.isArray(team.members) ? team.members : [];
1368
+ var lead = team && typeof team.lead === "string" ? team.lead : "";
1369
+ if (lead !== "" && members.indexOf(lead) >= 0) return lead;
1370
+ if (members.indexOf(MAIN_AGENT_NAME) >= 0) return MAIN_AGENT_NAME;
1371
+ return members.length > 0 && typeof members[0] === "string" ? members[0] : "";
1372
+ }
1373
+
1374
+ /**
1375
+ * 新建团队的草稿行(id 先占位,isNew 让改名时重算 id;保存时不外泄这些草稿标记)。
1376
+ * slug 初值 = 占位 id(中文名折空后 id 就是 "team");slugEdited=false 表示「还没手改,跟随推导」。
1377
+ */
1020
1378
  function emptyTeam(id) {
1021
- return { id: id, name: "", description: "", members: [], isNew: true };
1379
+ return {
1380
+ id: id, name: "", description: "", members: [], lead: "", presetId: "",
1381
+ slug: typeof id === "string" ? id : "", slugEdited: false, isNew: true
1382
+ };
1022
1383
  }
1023
1384
 
1024
1385
  /** Config.teams 的一项 → 编辑行;members 只保留非空字符串。 */
@@ -1033,6 +1394,15 @@ window.__ModuleLoader__.load({
1033
1394
  name: team && typeof team.name === "string" ? team.name : "",
1034
1395
  description: team && typeof team.description === "string" ? team.description : "",
1035
1396
  members: members,
1397
+ // 显式 presetId 原样保留:它覆盖「cohub-team-<id>」的默认推导,不能让一次保存把它丢掉。
1398
+ presetId: team && typeof team.presetId === "string" ? team.presetId : "",
1399
+ // slug 输入框的值:手改过就原样带着(改名不再覆盖),没改过则跟着 id 重新推导。
1400
+ slug: team && team.slugEdited === true
1401
+ ? (typeof team.slug === "string" ? team.slug : "")
1402
+ : teamSlugOf(team),
1403
+ slugEdited: team && team.slugEdited === true,
1404
+ // lead 悬空(指向已取消勾选的角色)也原样保留:保存时由 validateTeams 拦下并标红。
1405
+ lead: team && typeof team.lead === "string" ? team.lead : "",
1036
1406
  isNew: false
1037
1407
  };
1038
1408
  }
@@ -1052,19 +1422,32 @@ window.__ModuleLoader__.load({
1052
1422
  return rows;
1053
1423
  }
1054
1424
 
1055
- /** 编辑行 → 待写入的 teams 数组(只写 schema 的四个字段,草稿标记不外泄)。 */
1425
+ /** 编辑行 → 待写入的 teams 数组(只写受控字段,草稿标记不外泄)。 */
1056
1426
  function teamsToConfig(rows) {
1057
1427
  var out = [];
1058
1428
  if (!Array.isArray(rows)) return out;
1059
1429
  for (var i = 0; i < rows.length; i += 1) {
1060
1430
  var team = rows[i];
1061
1431
  if (!team || typeof team !== "object") continue;
1062
- out.push({
1432
+ var members = Array.isArray(team.members) ? team.members.slice() : [];
1433
+ var item = {
1063
1434
  id: typeof team.id === "string" ? team.id : "",
1064
1435
  name: typeof team.name === "string" ? team.name : "",
1065
1436
  description: typeof team.description === "string" ? team.description : "",
1066
- members: Array.isArray(team.members) ? team.members.slice() : []
1067
- });
1437
+ members: members,
1438
+ // lead 与 members 同一次 mutate 写入:空 lead 落成默认队长,配置文件里不留空。
1439
+ lead: effectiveTeamLead({ members: members, lead: team.lead })
1440
+ };
1441
+ // 预设 id 落库规则(不新增 schema 字段,全走已有的 presetId):
1442
+ // - 用户手改过 slug → 写显式 presetId = `cohub-team-<手填值>`;
1443
+ // - 没改过 → 沿用原显式 presetId(若有),否则省略,让注册器按 cohub-team-<id> 推导。
1444
+ var presetId = typeof team.presetId === "string" ? team.presetId.trim() : "";
1445
+ if (team.slugEdited === true) {
1446
+ var slug = typeof team.slug === "string" ? team.slug.trim() : "";
1447
+ presetId = slug !== "" ? TEAM_PRESET_PREFIX + slug : "";
1448
+ }
1449
+ if (presetId !== "") item.presetId = presetId;
1450
+ out.push(item);
1068
1451
  }
1069
1452
  return out;
1070
1453
  }
@@ -1073,7 +1456,7 @@ window.__ModuleLoader__.load({
1073
1456
  * 团队校验(对齐服务端 Team schema,另加页面才判得了的 id 重复):
1074
1457
  * - name 去空白后非空;
1075
1458
  * - members 至少 1 个;
1076
- * - id 合法(kebab-case)且表内不重复。
1459
+ * - 预设 id 的 slug 合法(kebab-case)且表内不重复(按最终 slug 判,手改过的也算)。
1077
1460
  * @returns 与 rows 等长的错误数组,空串表示该字段合法。
1078
1461
  */
1079
1462
  function validateTeams(rows) {
@@ -1081,20 +1464,27 @@ window.__ModuleLoader__.load({
1081
1464
  var counts = {};
1082
1465
  var errors = [];
1083
1466
  var i;
1467
+ // 重名按 **最终 slug**(预设 id 的终段)统计:手填的 slug 撞上别人的 id 同样要拦。
1084
1468
  for (i = 0; i < list.length; i += 1) {
1085
- var seeded = list[i] && typeof list[i].id === "string" ? list[i].id : "";
1469
+ var seeded = teamSlugOf(list[i]).trim();
1086
1470
  if (seeded === "") continue;
1087
1471
  counts[seeded] = (counts[seeded] || 0) + 1;
1088
1472
  }
1089
1473
  for (i = 0; i < list.length; i += 1) {
1090
1474
  var team = list[i] || {};
1091
- var error = { name: "", members: "", id: "" };
1475
+ var error = { name: "", members: "", id: "", lead: "" };
1092
1476
  var teamName = typeof team.name === "string" ? team.name.trim() : "";
1093
- var id = typeof team.id === "string" ? team.id : "";
1477
+ // 面板上标红的是 slug 输入框(沿用 error.id 这个键,渲染层与文案不用改)。
1478
+ var slug = teamSlugOf(team).trim();
1094
1479
  if (teamName === "") error.name = "nameRequired";
1095
1480
  if (!Array.isArray(team.members) || team.members.length === 0) error.members = "required";
1096
- if (id === "" || !TEAM_ID_PATTERN.test(id)) error.id = "idFormat";
1097
- else if (counts[id] > 1) error.id = "idDuplicate";
1481
+ if (slug === "" || !TEAM_ID_PATTERN.test(slug)) error.id = "idFormat";
1482
+ else if (counts[slug] > 1) error.id = "idDuplicate";
1483
+ // 队长必须是本团队已勾选的成员;空 lead 合法(保存时按默认规则补成有效值)。
1484
+ var lead = typeof team.lead === "string" ? team.lead : "";
1485
+ if (lead !== "" && (!Array.isArray(team.members) || team.members.indexOf(lead) < 0)) {
1486
+ error.lead = "notMember";
1487
+ }
1098
1488
  errors.push(error);
1099
1489
  }
1100
1490
  return errors;
@@ -1108,10 +1498,35 @@ window.__ModuleLoader__.load({
1108
1498
  if (error.name !== "") count += 1;
1109
1499
  if (error.members !== "") count += 1;
1110
1500
  if (error.id !== "") count += 1;
1501
+ if (error.lead !== "") count += 1;
1111
1502
  }
1112
1503
  return count;
1113
1504
  }
1114
1505
 
1506
+ /**
1507
+ * 团队卡片标题:只认「字符串且去空白后非空」的 name,其余("" / undefined / 纯空格 /
1508
+ * 非字符串)统一回退「未命名团队」。与角色标题同一口径——不能用 name 是否为空来猜,
1509
+ * 也不能把 undefined 直接渲染成空标题。
1510
+ */
1511
+ function teamTitle(team) {
1512
+ var name = team && typeof team.name === "string" ? team.name.trim() : "";
1513
+ return name !== "" ? name : null;
1514
+ }
1515
+
1516
+ /** 角色是否主代理(co-orchestrator):不绑定档位,工具由会话的 agent preset 决定。 */
1517
+ function isMainAgent(name) {
1518
+ return name === MAIN_AGENT_NAME;
1519
+ }
1520
+
1521
+ /**
1522
+ * 档位标签的语义键:主代理走 "main"(专属文案),其余沿用 tier / unknown。
1523
+ * 渲染层拿它翻文案,纯函数层拿它做断言,两处口径不会漂。
1524
+ */
1525
+ function roleTierKey(detail) {
1526
+ if (isMainAgent(detail && detail.name)) return "main";
1527
+ return detail && detail.tierKnown === true ? detail.tier : "unknown";
1528
+ }
1529
+
1115
1530
  /**
1116
1531
  * 成员候选:内置 16 角色 + customRoles(自定义与内置同名时不重复列出)。
1117
1532
  * customRoles 取「角色库」当前的编辑行,因此刚新建但未保存的角色也能先勾上。
@@ -1235,7 +1650,7 @@ window.__ModuleLoader__.load({
1235
1650
  var list = Array.isArray(members) ? members : [];
1236
1651
  for (var i = 0; i < list.length; i += 1) {
1237
1652
  var detail = roleDetailOf(list[i], customRows);
1238
- var key = detail.tierKnown ? detail.tier : "unknown";
1653
+ var key = roleTierKey(detail) === "main" ? "main" : detail.tierKnown ? detail.tier : "unknown";
1239
1654
  counts[key] = Object.prototype.hasOwnProperty.call(counts, key) ? counts[key] + 1 : 1;
1240
1655
  }
1241
1656
  var sorted = [];
@@ -1244,6 +1659,9 @@ window.__ModuleLoader__.load({
1244
1659
  sorted.push({ tier: ROLE_TIERS[t], known: true, count: counts[ROLE_TIERS[t]] });
1245
1660
  }
1246
1661
  }
1662
+ if (Object.prototype.hasOwnProperty.call(counts, "main")) {
1663
+ sorted.unshift({ tier: "main", known: true, count: counts.main });
1664
+ }
1247
1665
  if (Object.prototype.hasOwnProperty.call(counts, "unknown")) {
1248
1666
  sorted.push({ tier: "unknown", known: false, count: counts.unknown });
1249
1667
  }
@@ -1310,8 +1728,7 @@ window.__ModuleLoader__.load({
1310
1728
  teamsNotice: "",
1311
1729
  expandedTeam: -1,
1312
1730
  // 角色详情面板(提示词 + 绑定工具)展开的是哪个角色名;"" = 全收起。
1313
- expandedRole: "",
1314
- activeTeamBusy: false
1731
+ expandedRole: ""
1315
1732
  });
1316
1733
 
1317
1734
  /**
@@ -1351,17 +1768,26 @@ window.__ModuleLoader__.load({
1351
1768
  var rolesSaved = false;
1352
1769
  var rolesFailed = false;
1353
1770
  var roleErrors = [];
1771
+ // 每行「从哪个模板来」:下标与角色行一一对应,"" = 未选/空白角色。
1772
+ // 只存在于本次编辑会话(Config.customRoles 里没有该字段,保存时不写)。
1773
+ var roleTemplates = [];
1774
+ var rolePicker = -1; // 当前展开模板选择器的行下标,-1 = 全收起
1354
1775
 
1355
- // 团队草稿:写 path:["teams"]。「设为当前」/「删除当前团队」走 path:["activeTeam"],
1356
- // 是独立的一次 mutate(不同 path,不能塞进同一次提交)。
1776
+ /** 模板标记数组对齐到角色行数(新增/删除行后补齐或截断)。 */
1777
+ function syncRoleTemplates(size) {
1778
+ var out = [];
1779
+ for (var i = 0; i < size; i += 1) out.push(i < roleTemplates.length ? roleTemplates[i] : "");
1780
+ roleTemplates = out;
1781
+ }
1782
+
1783
+ // 团队草稿:只写 path:["teams"](Config.activeTeam 已废弃,本页不再写入)。
1357
1784
  var teamsDraft = null; // { rows, revision }
1358
1785
  var teamsSaved = false;
1359
1786
  var teamsFailed = false;
1360
1787
  var teamErrors = [];
1361
- var teamsNotice = ""; // "activeCleared" = 删除当前团队后的一次性提示
1788
+ var teamsNotice = ""; // 一次性提示(保留 "activeCleared" 旧词条,本版不再触发)
1362
1789
  var expandedTeam = -1; // 展开编辑的团队行下标,-1 = 全收起
1363
1790
  var expandedRole = ""; // 展开详情的角色名,"" = 全收起(角色库/成员/团队三处共用)
1364
- var activeTeamBusy = false;
1365
1791
 
1366
1792
  function readScope() {
1367
1793
  if (!scope || typeof scope.getSnapshot !== "function") {
@@ -1427,6 +1853,8 @@ window.__ModuleLoader__.load({
1427
1853
  rolesSaved: rolesSaved,
1428
1854
  rolesFailed: rolesFailed,
1429
1855
  roleErrors: roleErrors,
1856
+ roleTemplates: roleTemplates,
1857
+ rolePicker: rolePicker,
1430
1858
  teams: teamsDraft !== null ? teamsDraft.rows : currentTeams(),
1431
1859
  activeTeam: currentActiveTeam(),
1432
1860
  teamsDirty: teamsDraft !== null,
@@ -1435,8 +1863,7 @@ window.__ModuleLoader__.load({
1435
1863
  teamErrors: teamErrors,
1436
1864
  teamsNotice: teamsNotice,
1437
1865
  expandedTeam: expandedTeam,
1438
- expandedRole: expandedRole,
1439
- activeTeamBusy: activeTeamBusy
1866
+ expandedRole: expandedRole
1440
1867
  };
1441
1868
  }
1442
1869
 
@@ -1460,6 +1887,8 @@ window.__ModuleLoader__.load({
1460
1887
  && left.rolesSaved === right.rolesSaved
1461
1888
  && left.rolesFailed === right.rolesFailed
1462
1889
  && left.roleErrors === right.roleErrors
1890
+ && left.roleTemplates === right.roleTemplates
1891
+ && left.rolePicker === right.rolePicker
1463
1892
  && left.teams === right.teams
1464
1893
  && left.activeTeam === right.activeTeam
1465
1894
  && left.teamsDirty === right.teamsDirty
@@ -1468,8 +1897,7 @@ window.__ModuleLoader__.load({
1468
1897
  && left.teamErrors === right.teamErrors
1469
1898
  && left.teamsNotice === right.teamsNotice
1470
1899
  && left.expandedTeam === right.expandedTeam
1471
- && left.expandedRole === right.expandedRole
1472
- && left.activeTeamBusy === right.activeTeamBusy;
1900
+ && left.expandedRole === right.expandedRole;
1473
1901
  }
1474
1902
 
1475
1903
  function publish() {
@@ -1508,6 +1936,7 @@ window.__ModuleLoader__.load({
1508
1936
  var source = currentRoles();
1509
1937
  var rows = [];
1510
1938
  for (var i = 0; i < source.length; i += 1) rows.push(copyRole(source[i]));
1939
+ syncRoleTemplates(rows.length);
1511
1940
  rolesDraft = { rows: rows, revision: snapshot.revision };
1512
1941
  return rolesDraft;
1513
1942
  }
@@ -1693,15 +2122,25 @@ window.__ModuleLoader__.load({
1693
2122
  }
1694
2123
 
1695
2124
  /**
1696
- * 改一行的某个字段(name / description / prompt / tier)。
1697
- * 只写受控四字段,避免把 Config 里别的键带歪;提交过校验后改字段会即时重算标红。
2125
+ * 改一行的某个字段(name / description / prompt / tier / tools)。
2126
+ * 只写受控字段,避免把 Config 里别的键带歪;提交过校验后改字段会即时重算标红。
2127
+ * tools 传整数组(checkbox 勾选结果),一次性替换。
1698
2128
  */
1699
2129
  function editRole(index, field, value) {
1700
- if (field !== "name" && field !== "description" && field !== "prompt" && field !== "tier") return;
2130
+ if (field !== "name" && field !== "description" && field !== "prompt" && field !== "tier" && field !== "tools") return;
1701
2131
  if (!canEdit()) return;
1702
2132
  var current = beginRolesDraft();
1703
2133
  if (index < 0 || index >= current.rows.length) return;
1704
- if (current.rows[index][field] === value) return;
2134
+ if (field === "tools") {
2135
+ var picked = [];
2136
+ var list = Array.isArray(value) ? value : [];
2137
+ for (var t = 0; t < list.length; t += 1) {
2138
+ if (typeof list[t] === "string" && list[t] !== "" && picked.indexOf(list[t]) < 0) picked.push(list[t]);
2139
+ }
2140
+ value = picked;
2141
+ } else if (current.rows[index][field] === value) {
2142
+ return;
2143
+ }
1705
2144
  var next = [];
1706
2145
  for (var i = 0; i < current.rows.length; i += 1) {
1707
2146
  var copy = copyRole(current.rows[i]);
@@ -1715,7 +2154,157 @@ window.__ModuleLoader__.load({
1715
2154
  publish();
1716
2155
  }
1717
2156
 
1718
- /** 追加一个空行(默认 tier=ro,最小权限起步)。 */
2157
+ /**
2158
+ * 用模板填一行:name(加 -copy 防重名)/ description / prompt(brief 全文)/ tier / tools。
2159
+ * 空白角色(id="")只清空字段,名字留给用户自己填。
2160
+ */
2161
+ function chooseTemplate(index, templateId) {
2162
+ if (!canEdit()) return;
2163
+ var template = templateOf(templateId);
2164
+ if (template === null) return;
2165
+ var current = beginRolesDraft();
2166
+ if (index < 0 || index >= current.rows.length) return;
2167
+ var taken = [];
2168
+ for (var i = 0; i < current.rows.length; i += 1) {
2169
+ if (i !== index && current.rows[i].name !== "") taken.push(current.rows[i].name);
2170
+ }
2171
+ for (var b = 0; b < BUILTIN_ROLE_NAMES.length; b += 1) taken.push(BUILTIN_ROLE_NAMES[b]);
2172
+ var next = [];
2173
+ for (var j = 0; j < current.rows.length; j += 1) {
2174
+ var copy = copyRole(current.rows[j]);
2175
+ if (j === index) {
2176
+ if (template.blank) {
2177
+ copy.name = "";
2178
+ copy.description = "";
2179
+ copy.prompt = "";
2180
+ copy.tier = "ro";
2181
+ copy.tools = [];
2182
+ } else {
2183
+ // 「基于模板」的显示名固定用模板 id:选完再改名也不影响这条提示。
2184
+ copy.name = templateRoleName(template.name, taken);
2185
+ copy.description = template.description !== "" ? template.description : template.name;
2186
+ copy.prompt = template.brief !== "" ? template.brief : template.description;
2187
+ copy.tier = ROLE_TIERS.indexOf(template.tier) >= 0 ? template.tier : "ro";
2188
+ copy.tools = template.tools.slice();
2189
+ }
2190
+ }
2191
+ next.push(copy);
2192
+ }
2193
+ var marks = [];
2194
+ for (var k = 0; k < next.length; k += 1) marks.push(k === index ? template.id : roleTemplates[k]);
2195
+ rolesDraft.rows = next;
2196
+ syncRoleTemplates(next.length);
2197
+ roleTemplates = marks;
2198
+ rolePicker = -1;
2199
+ roleErrors = roleErrors.length > 0 ? validateRoles(next) : [];
2200
+ rolesSaved = false;
2201
+ rolesFailed = false;
2202
+ publish();
2203
+ }
2204
+
2205
+ /** 档位退化为快捷组合:点一下按 ROLE_CATALOG.tiers[tier].tools 批量勾选,返回勾上的 id。 */
2206
+ function applyTierTools(index) {
2207
+ if (!canEdit()) return [];
2208
+ var current = beginRolesDraft();
2209
+ if (index < 0 || index >= current.rows.length) return [];
2210
+ var ids = tierToolIds(current.rows[index].tier);
2211
+ editRole(index, "tools", ids);
2212
+ return ids;
2213
+ }
2214
+
2215
+ /**
2216
+ * 角色卡片 / 内置卡片的模型区:按角色名写 Config.skills(**不是 customRoles**)。
2217
+ * 行不存在就先建一行;provider / model / reasoningEffort 与上方代理行同一套语义,
2218
+ * maxTokens(最大输出)落在 extra 里由 rowsToSkills 原样保留。
2219
+ */
2220
+ function editSkillRow(name, field, value) {
2221
+ if (field !== "provider" && field !== "model" && field !== "reasoningEffort" && field !== "maxTokens") return;
2222
+ if (!canEdit() || typeof name !== "string" || name === "") return;
2223
+ var current = beginDraft();
2224
+ var next = [];
2225
+ var found = false;
2226
+ for (var i = 0; i < current.rows.length; i += 1) {
2227
+ var row = current.rows[i];
2228
+ if (row.name !== name) {
2229
+ next.push(row);
2230
+ continue;
2231
+ }
2232
+ found = true;
2233
+ var copy = copyRow(row);
2234
+ applySkillField(copy, field, value);
2235
+ next.push(copy);
2236
+ }
2237
+ if (!found) {
2238
+ var created = emptyRow(name);
2239
+ applySkillField(created, field, value);
2240
+ next.push(created);
2241
+ }
2242
+ draft.rows = next;
2243
+ saved = false;
2244
+ failed = false;
2245
+ publish();
2246
+ }
2247
+
2248
+ /** 单行改字段:换供应商连带清 model/effort(与 editRow 同口径,避免写出失效路由)。 */
2249
+ function applySkillField(row, field, value) {
2250
+ if (field === "provider") {
2251
+ row.provider = value;
2252
+ row.model = "";
2253
+ row.reasoningEffort = "";
2254
+ return;
2255
+ }
2256
+ if (field === "model") {
2257
+ row.model = value;
2258
+ row.reasoningEffort = reconcileEffort(row.provider, value, effortOf(row));
2259
+ return;
2260
+ }
2261
+ if (field === "reasoningEffort") {
2262
+ row.reasoningEffort = value;
2263
+ return;
2264
+ }
2265
+ var raw = value === undefined || value === null ? "" : String(value).trim();
2266
+ if (raw === "") {
2267
+ if (row.extra) delete row.extra.maxTokens;
2268
+ return;
2269
+ }
2270
+ var number = Number(raw);
2271
+ if (!isFinite(number) || number < 1) return;
2272
+ if (!row.extra) row.extra = {};
2273
+ row.extra.maxTokens = Math.round(number);
2274
+ }
2275
+
2276
+ /** 恢复默认:清供应商 / 模型 / 推理强度 / 最大输出四项,其余未知字段保留。 */
2277
+ function resetSkillRow(name) {
2278
+ if (!canEdit() || typeof name !== "string" || name === "") return;
2279
+ var current = beginDraft();
2280
+ var next = [];
2281
+ var changed = false;
2282
+ for (var i = 0; i < current.rows.length; i += 1) {
2283
+ var row = current.rows[i];
2284
+ if (row.name !== name) {
2285
+ next.push(row);
2286
+ continue;
2287
+ }
2288
+ if (row.provider === "" && row.model === "" && effortOf(row) === "" && row.extra.maxTokens === undefined) {
2289
+ next.push(row);
2290
+ continue;
2291
+ }
2292
+ var copy = copyRow(row);
2293
+ copy.provider = "";
2294
+ copy.model = "";
2295
+ copy.reasoningEffort = "";
2296
+ delete copy.extra.maxTokens;
2297
+ next.push(copy);
2298
+ changed = true;
2299
+ }
2300
+ if (!changed) return;
2301
+ draft.rows = next;
2302
+ saved = false;
2303
+ failed = false;
2304
+ publish();
2305
+ }
2306
+
2307
+ /** 添加角色:先展开「选择一个模板开始」,选中模板后自动填字段。 */
1719
2308
  function addRole() {
1720
2309
  if (!canEdit()) return;
1721
2310
  var current = beginRolesDraft();
@@ -1723,6 +2312,8 @@ window.__ModuleLoader__.load({
1723
2312
  for (var i = 0; i < current.rows.length; i += 1) next.push(copyRole(current.rows[i]));
1724
2313
  next.push(emptyRole());
1725
2314
  rolesDraft.rows = next;
2315
+ syncRoleTemplates(next.length);
2316
+ rolePicker = next.length - 1;
1726
2317
  roleErrors = [];
1727
2318
  rolesSaved = false;
1728
2319
  rolesFailed = false;
@@ -1738,6 +2329,12 @@ window.__ModuleLoader__.load({
1738
2329
  for (var i = 0; i < current.rows.length; i += 1) {
1739
2330
  if (i !== index) next.push(current.rows[i]);
1740
2331
  }
2332
+ var marks = [];
2333
+ for (var m = 0; m < roleTemplates.length; m += 1) if (m !== index) marks.push(roleTemplates[m]);
2334
+ roleTemplates = marks;
2335
+ syncRoleTemplates(next.length);
2336
+ if (rolePicker === index) rolePicker = -1;
2337
+ else if (rolePicker > index) rolePicker -= 1;
1741
2338
  rolesDraft.rows = next;
1742
2339
  roleErrors = [];
1743
2340
  rolesSaved = false;
@@ -1748,12 +2345,33 @@ window.__ModuleLoader__.load({
1748
2345
  function discardRoles() {
1749
2346
  if (saving) return;
1750
2347
  rolesDraft = null;
2348
+ roleTemplates = [];
2349
+ rolePicker = -1;
1751
2350
  rolesSaved = false;
1752
2351
  rolesFailed = false;
1753
2352
  roleErrors = [];
1754
2353
  publish();
1755
2354
  }
1756
2355
 
2356
+ /** 展开/收起某行的模板选择器。 */
2357
+ function toggleRolePicker(index) {
2358
+ rolePicker = rolePicker === index ? -1 : index;
2359
+ publish();
2360
+ }
2361
+
2362
+ /** 主代理卡「以此模板新建」:加一行并直接套上 co-orchestrator 模板。 */
2363
+ function newRoleFromMain() {
2364
+ if (!canEdit()) return;
2365
+ var current = beginRolesDraft();
2366
+ var next = [];
2367
+ for (var i = 0; i < current.rows.length; i += 1) next.push(copyRole(current.rows[i]));
2368
+ next.push(emptyRole());
2369
+ rolesDraft.rows = next;
2370
+ syncRoleTemplates(next.length);
2371
+ publish();
2372
+ chooseTemplate(next.length - 1, "co-orchestrator");
2373
+ }
2374
+
1757
2375
  /**
1758
2376
  * 整表写回 Config.customRoles(数组字段整体替换,与 skills 同一 mutate 契约)。
1759
2377
  * 校验不通过只标红、不发请求;成功后运行时注册器约 1 秒内热加载,无需重启。
@@ -1825,12 +2443,14 @@ window.__ModuleLoader__.load({
1825
2443
  return teamsDraft;
1826
2444
  }
1827
2445
 
1828
- /** 除第 index 行以外已被占用的团队 id(id 消歧用)。 */
2446
+ /** 除第 index 行以外已被占用的团队 id / slug(自动消歧用:别人手填的 slug 也算占用)。 */
1829
2447
  function takenIdsExcept(rows, index) {
1830
2448
  var out = [];
1831
2449
  for (var i = 0; i < rows.length; i += 1) {
1832
2450
  if (i === index) continue;
1833
2451
  if (typeof rows[i].id === "string" && rows[i].id !== "") out.push(rows[i].id);
2452
+ var slug = teamSlugOf(rows[i]);
2453
+ if (slug !== "" && out.indexOf(slug) < 0) out.push(slug);
1834
2454
  }
1835
2455
  return out;
1836
2456
  }
@@ -1862,12 +2482,13 @@ window.__ModuleLoader__.load({
1862
2482
  }
1863
2483
 
1864
2484
  /**
1865
- * 改团队字段(name / description)。
2485
+ * 改团队字段(name / description / slug)。
1866
2486
  * name 变更时:**新建行**(isNew)重算 id 并自动消歧;**已存团队保留原 id**,
1867
2487
  * 否则改名会把 Config.activeTeam 指向的 id 弄悬空。
2488
+ * slug 变更 = 用户亲手指定预设 id:打上 slugEdited,此后改名不再覆盖它。
1868
2489
  */
1869
2490
  function editTeam(index, field, value) {
1870
- if (field !== "name" && field !== "description") return;
2491
+ if (field !== "name" && field !== "description" && field !== "slug") return;
1871
2492
  if (!canEdit()) return;
1872
2493
  var current = beginTeamsDraft();
1873
2494
  if (index < 0 || index >= current.rows.length) return;
@@ -1879,8 +2500,11 @@ window.__ModuleLoader__.load({
1879
2500
  copy.isNew = row.isNew === true;
1880
2501
  if (i === index) {
1881
2502
  copy[field] = value;
2503
+ if (field === "slug") copy.slugEdited = true;
1882
2504
  if (field === "name" && copy.isNew === true) {
1883
2505
  copy.id = uniqueTeamId(value, takenIdsExcept(current.rows, index));
2506
+ // 没手改过的行让输入框跟着新 id 走;手改过就保持用户填的值不动。
2507
+ if (copy.slugEdited !== true) copy.slug = copy.id;
1884
2508
  }
1885
2509
  }
1886
2510
  next.push(copy);
@@ -1909,6 +2533,27 @@ window.__ModuleLoader__.load({
1909
2533
  pushTeamsRows(next);
1910
2534
  }
1911
2535
 
2536
+ /**
2537
+ * 指定队长:只接受当前已勾选的成员,其它值一律落成 ""(再由默认规则补)。
2538
+ * 取消勾选原队长后 lead 会悬空 —— 故意不自动改,交给 validateTeams 标红拦截。
2539
+ */
2540
+ function setTeamLead(index, roleName) {
2541
+ if (typeof roleName !== "string") return;
2542
+ if (!canEdit()) return;
2543
+ var current = beginTeamsDraft();
2544
+ if (index < 0 || index >= current.rows.length) return;
2545
+ if (current.rows[index].lead === roleName) return;
2546
+ var next = [];
2547
+ for (var i = 0; i < current.rows.length; i += 1) {
2548
+ var row = current.rows[i];
2549
+ var copy = copyTeam(row);
2550
+ copy.isNew = row.isNew === true;
2551
+ if (i === index) copy.lead = copy.members.indexOf(roleName) >= 0 ? roleName : "";
2552
+ next.push(copy);
2553
+ }
2554
+ pushTeamsRows(next);
2555
+ }
2556
+
1912
2557
  /** 追加一个空团队(id 先按 "team"/"team-2"… 占位,填名后自动重算)。 */
1913
2558
  function addTeam() {
1914
2559
  if (!canEdit()) return;
@@ -1941,39 +2586,13 @@ window.__ModuleLoader__.load({
1941
2586
  }
1942
2587
 
1943
2588
  /**
1944
- * 设为当前团队;对已是当前的团队再点一次 = 取消(写空串 = 不限制)。
1945
- * 立即写 Config.activeTeam,不等「保存团队」。
1946
- */
1947
- function setActiveTeam(id) {
1948
- if (!canEdit()) return Promise.resolve(false);
1949
- var snapshot = readScope();
1950
- if (snapshot.status !== "ready" || snapshot.writable !== true) return Promise.resolve(false);
1951
- var nextValue = id === currentActiveTeam() ? "" : id;
1952
- activeTeamBusy = true;
1953
- teamsFailed = false;
1954
- publish();
1955
- return mutatePath(["activeTeam"], nextValue, snapshot.revision).then(function (ok) {
1956
- activeTeamBusy = false;
1957
- if (ok) {
1958
- teamsNotice = "";
1959
- lastValue = undefined;
1960
- } else {
1961
- teamsFailed = true;
1962
- }
1963
- publish();
1964
- return ok;
1965
- });
1966
- }
1967
-
1968
- /**
1969
- * 删除一个团队行。若删的正是当前团队,顺手把 Config.activeTeam 清空
1970
- * (独立的一次 path:["activeTeam"] 写入),避免「当前」指向不存在的团队。
2589
+ * 删除一个团队行。
2590
+ * 只写 Config.teams:`activeTeam` 已废弃,本页不再写入(会话限制改由 Agent 预设承担)。
1971
2591
  */
1972
2592
  function removeTeam(index) {
1973
2593
  if (!canEdit()) return Promise.resolve(false);
1974
2594
  var current = beginTeamsDraft();
1975
2595
  if (index < 0 || index >= current.rows.length) return Promise.resolve(false);
1976
- var removed = current.rows[index];
1977
2596
  var next = [];
1978
2597
  for (var i = 0; i < current.rows.length; i += 1) {
1979
2598
  if (i === index) continue;
@@ -1983,20 +2602,7 @@ window.__ModuleLoader__.load({
1983
2602
  }
1984
2603
  expandedTeam = -1;
1985
2604
  pushTeamsRows(next);
1986
- var removedId = removed && typeof removed.id === "string" ? removed.id : "";
1987
- if (removedId === "" || removedId !== currentActiveTeam()) return Promise.resolve(true);
1988
- var snapshot = readScope();
1989
- if (snapshot.status !== "ready" || snapshot.writable !== true) return Promise.resolve(false);
1990
- return mutatePath(["activeTeam"], "", snapshot.revision).then(function (ok) {
1991
- if (ok) {
1992
- teamsNotice = "activeCleared";
1993
- lastValue = undefined;
1994
- } else {
1995
- teamsFailed = true;
1996
- }
1997
- publish();
1998
- return ok;
1999
- });
2605
+ return Promise.resolve(true);
2000
2606
  }
2001
2607
 
2002
2608
  function discardTeams() {
@@ -2185,15 +2791,21 @@ window.__ModuleLoader__.load({
2185
2791
  removeRole: removeRole,
2186
2792
  discardRoles: discardRoles,
2187
2793
  saveRoles: saveRoles,
2794
+ chooseTemplate: chooseTemplate,
2795
+ applyTierTools: applyTierTools,
2796
+ toggleRolePicker: toggleRolePicker,
2797
+ newRoleFromMain: newRoleFromMain,
2798
+ editSkillRow: editSkillRow,
2799
+ resetSkillRow: resetSkillRow,
2188
2800
  toggleTeam: toggleTeam,
2189
2801
  toggleRoleDetail: toggleRoleDetail,
2190
2802
  editTeam: editTeam,
2191
2803
  toggleTeamMember: toggleTeamMember,
2804
+ setTeamLead: setTeamLead,
2192
2805
  addTeam: addTeam,
2193
2806
  removeTeam: removeTeam,
2194
2807
  discardTeams: discardTeams,
2195
- saveTeams: saveTeams,
2196
- setActiveTeam: setActiveTeam
2808
+ saveTeams: saveTeams
2197
2809
  };
2198
2810
  }
2199
2811
 
@@ -2210,6 +2822,15 @@ window.__ModuleLoader__.load({
2210
2822
  ".cohub-notice{margin:0;padding:8px 12px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary);}",
2211
2823
  ".cohub-notice-error{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary);}",
2212
2824
  ".cohub-notice-warn{color:var(--dsw-alias-state-warning-primary,#8d6e00);}",
2825
+ ".cohub-badge-muted{opacity:.62;font-weight:400;}",
2826
+ ".cohub-seg-active{background:var(--dsw-alias-bg-active,#233240);border-color:var(--dsw-alias-border-strong,#4b7193);font-weight:650;}",
2827
+ ".cohub-template-head{align-items:center;}",
2828
+ ".cohub-templates .cohub-checks{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));}",
2829
+ ".cohub-template-card{display:flex;flex-direction:column;align-items:flex-start;gap:2px;text-align:left;padding:9px 11px;border:1px solid var(--dsw-alias-border-weak,#35434d);border-radius:6px;background:var(--dsw-alias-bg-raised,#1d2227);}",
2830
+ ".cohub-template-card:hover{border-color:var(--dsw-alias-border-strong,#4b7193);}",
2831
+ ".cohub-template-main{border-color:var(--dsw-alias-state-info-primary,#3f6f9e);background:var(--dsw-alias-bg-info-weak,#1c2c3b);grid-column:1/-1;}",
2832
+ ".cohub-row-main{border-left:2px solid var(--dsw-alias-state-info-primary,#3f6f9e);}",
2833
+ ".cohub-model-block,.cohub-tool-block{margin-top:10px;}",
2213
2834
  ".cohub-notice-ok{color:var(--dsw-alias-state-success-primary);}",
2214
2835
  ".cohub-rows{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:8px;}",
2215
2836
  ".cohub-row{border:1px solid var(--dsw-alias-border-l2);border-radius:10px;padding:10px 12px;background:var(--dsw-alias-bg-layer-2);}",
@@ -2258,7 +2879,13 @@ window.__ModuleLoader__.load({
2258
2879
  // ── 团队区块:卡片头部整块可点展开,成员多选用紧凑网格 ──
2259
2880
  ".cohub-team-toggle{display:flex;align-items:center;gap:8px;flex-wrap:wrap;flex:1 1 auto;min-width:0;background:transparent;border:none;padding:0;margin:0;cursor:pointer;font:inherit;color:inherit;text-align:left;}",
2260
2881
  ".cohub-team-toggle:hover .cohub-row-name{text-decoration:underline;}",
2261
- ".cohub-team-body{margin-top:8px;display:flex;flex-direction:column;gap:8px;}",
2882
+ // 预设 id 用等宽字体(id 里有连字符与数字,等宽才好读),并在卡片头部独占一行(名称下方)。
2883
+ ".cohub-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,\"Liberation Mono\",monospace;}",
2884
+ ".cohub-team-toggle .cohub-row-id{flex-basis:100%;order:9;}",
2885
+ ".cohub-slug-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}",
2886
+ ".cohub-slug-row .cohub-input{flex:1 1 160px;width:auto;min-width:0;}",
2887
+ ".cohub-slug-row .cohub-desc{flex:0 0 auto;}",
2888
+ ".cohub-team-body{margin-top:8px;display:flex;flex-direction:column;gap:8px;}",
2262
2889
  ".cohub-check-group{display:flex;flex-direction:column;gap:4px;}",
2263
2890
  ".cohub-checks{display:flex;flex-wrap:wrap;gap:6px 14px;}",
2264
2891
  ".cohub-check{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);cursor:pointer;}",
@@ -2522,10 +3149,257 @@ window.__ModuleLoader__.load({
2522
3149
  return label === "tier." + tier ? t("tier.unknown") : label;
2523
3150
  }
2524
3151
 
3152
+ /**
3153
+ * 角色档位标签:主代理(co-orchestrator)不在档位表里,走专属文案「主代理·纯调度」,
3154
+ * 不再降级成「未知档位」——它不是重建错的配置,是设计如此。
3155
+ */
3156
+ function roleTierLabel(detail) {
3157
+ if (roleTierKey(detail) === "main") return t("tier.mainAgent");
3158
+ return tierLabel(detail ? detail.tier : "");
3159
+ }
3160
+
3161
+ /** 卡片上的「档位 · N 个工具」摘要:主代理没有档位绑定工具,改说 preset。 */
3162
+ function roleToolSummary(detail) {
3163
+ if (roleTierKey(detail) === "main") return t("tier.mainAgent") + " · " + t("roleToolMainAgent");
3164
+ return tierLabel(detail ? detail.tier : "") + " · " + t("roleToolCount", { count: detail ? detail.toolCount : 0 });
3165
+ }
3166
+
2525
3167
  /**
2526
3168
  * 详情面板的「完整正文」块:内置角色折叠展示技能 content 全文(默认收起,360px 内滚动),
2527
3169
  * 自定义角色没有内置正文,给一行说明;未知角色整块不渲染(避免空壳)。
2528
3170
  */
3171
+ /* ── 角色编辑区:模板新建 / 绑定工具 / 运行模型(对齐定稿原型结构) ── */
3172
+
3173
+ /** skills 编辑行按名查找(找不到返回 null,模型区按「继承」展示)。 */
3174
+ function skillRowOf(name) {
3175
+ for (var i = 0; i < rows.length; i += 1) if (rows[i].name === name) return rows[i];
3176
+ return null;
3177
+ }
3178
+
3179
+ /** 角色卡片上的模型徽标:显式配置显示 model,未配置显示灰色「继承」。 */
3180
+ function modelPill(name) {
3181
+ var row = skillRowOf(name);
3182
+ var provider = row && typeof row.provider === "string" ? row.provider : "";
3183
+ var model = row && typeof row.model === "string" ? row.model : "";
3184
+ if (provider === "") {
3185
+ return React.createElement("span", { className: "cohub-badge cohub-badge-muted" }, t("roleModelInherit"));
3186
+ }
3187
+ return React.createElement("span", { className: "cohub-badge" }, model !== "" ? model : provider);
3188
+ }
3189
+
3190
+ /** 模板标记 → 展示文案("" = 空白角色;未知 id 原样显示)。 */
3191
+ function templateLabelOf(templateId) {
3192
+ if (templateId === "" || templateId === "blank") return t("roleTemplateBlank");
3193
+ if (templateId === "co-orchestrator") return t("roleTemplateMain");
3194
+ return skillLabel(templateId);
3195
+ }
3196
+
3197
+ /**
3198
+ * 模型区:供应商(真实目录,取不到只有「继承默认」)→ 模型联动 →
3199
+ * 推理强度分段按钮(默认/低/中/高 = ""/low/medium/high)→ 最大输出 → 恢复默认。
3200
+ * 写的是 Config.skills(不是 customRoles),内置角色与自定义角色共用同一份渲染。
3201
+ */
3202
+ function renderRoleModel(name, disabled) {
3203
+ var row = skillRowOf(name);
3204
+ var provider = row && typeof row.provider === "string" ? row.provider : "";
3205
+ var model = row && typeof row.model === "string" ? row.model : "";
3206
+ var effort = row ? effortOf(row) : "";
3207
+ var maxTokens = row && row.extra && row.extra.maxTokens !== undefined ? String(row.extra.maxTokens) : "";
3208
+ var providerOptions = [React.createElement("option", { key: "__inherit", value: "" }, t("roleModelProviderDefault"))];
3209
+ for (var p = 0; p < providers.length; p += 1) {
3210
+ providerOptions.push(React.createElement("option", { key: providers[p].id, value: providers[p].id }, providers[p].label));
3211
+ }
3212
+ var models = provider !== "" && state.modelsByProvider ? state.modelsByProvider[provider] : null;
3213
+ var modelOptions = [React.createElement("option", { key: "__pick", value: "" },
3214
+ provider === ""
3215
+ ? t("roleModelPickProvider")
3216
+ : (Array.isArray(models) && models.length > 0 ? t("roleModelPickModel") : t("emptyModel")))];
3217
+ if (Array.isArray(models)) {
3218
+ for (var m = 0; m < models.length; m += 1) {
3219
+ modelOptions.push(React.createElement("option", { key: models[m].id, value: models[m].id }, models[m].label));
3220
+ }
3221
+ }
3222
+ var effortChoices = [["", "effort.default"], ["low", "effort.low"], ["medium", "effort.medium"], ["high", "effort.high"]];
3223
+ var effortButtons = [];
3224
+ for (var e = 0; e < effortChoices.length; e += 1) {
3225
+ var choice = effortChoices[e][0];
3226
+ var active = effort === choice;
3227
+ effortButtons.push(React.createElement("button", {
3228
+ key: choice === "" ? "__default" : choice,
3229
+ type: "button",
3230
+ className: active ? "cohub-tier-chip cohub-seg-active" : "cohub-tier-chip",
3231
+ "aria-pressed": active,
3232
+ disabled: disabled,
3233
+ onClick: function (value) {
3234
+ return function () {
3235
+ props.editSkill(name, "reasoningEffort", value);
3236
+ };
3237
+ }(choice)
3238
+ }, t(effortChoices[e][1])));
3239
+ }
3240
+ return React.createElement("div", { className: "cohub-detail-block cohub-model-block" },
3241
+ React.createElement("p", { className: "cohub-label" }, t("roleModelTitle")),
3242
+ React.createElement("div", { className: "cohub-field" },
3243
+ React.createElement("label", { className: "cohub-label" }, t("roleModelProvider")),
3244
+ React.createElement("select", {
3245
+ className: "cohub-select",
3246
+ value: provider,
3247
+ disabled: disabled,
3248
+ "aria-label": name + " · " + t("roleModelProvider"),
3249
+ onChange: function (event) {
3250
+ props.editSkill(name, "provider", event.target.value);
3251
+ }
3252
+ }, providerOptions)
3253
+ ),
3254
+ React.createElement("div", { className: "cohub-field" },
3255
+ React.createElement("label", { className: "cohub-label" }, t("roleModelModel")),
3256
+ React.createElement("select", {
3257
+ className: "cohub-select",
3258
+ value: model,
3259
+ disabled: disabled || provider === "",
3260
+ "aria-label": name + " · " + t("roleModelModel"),
3261
+ onChange: function (event) {
3262
+ props.editSkill(name, "model", event.target.value);
3263
+ }
3264
+ }, modelOptions)
3265
+ ),
3266
+ React.createElement("div", { className: "cohub-field" },
3267
+ React.createElement("span", { className: "cohub-label" }, t("roleModelReasoning")),
3268
+ React.createElement("div", { className: "cohub-actions" }, effortButtons),
3269
+ React.createElement("small", { className: "cohub-desc" }, t("roleModelReasoningHint"))
3270
+ ),
3271
+ React.createElement("div", { className: "cohub-field" },
3272
+ React.createElement("label", { className: "cohub-label" }, t("roleModelMaxOutput")),
3273
+ React.createElement("input", {
3274
+ className: "cohub-input",
3275
+ type: "number",
3276
+ min: 1,
3277
+ step: 1,
3278
+ value: maxTokens,
3279
+ disabled: disabled || provider === "",
3280
+ placeholder: t("roleModelMaxOutputPlaceholder"),
3281
+ "aria-label": name + " · " + t("roleModelMaxOutput"),
3282
+ onChange: function (event) {
3283
+ props.editSkill(name, "maxTokens", event.target.value);
3284
+ }
3285
+ })
3286
+ ),
3287
+ React.createElement("div", { className: "cohub-actions" },
3288
+ React.createElement("button", {
3289
+ type: "button",
3290
+ className: "cohub-button cohub-button-ghost",
3291
+ disabled: disabled,
3292
+ onClick: function () {
3293
+ props.resetSkill(name);
3294
+ }
3295
+ }, t("roleModelReset"))
3296
+ )
3297
+ );
3298
+ }
3299
+
3300
+ /**
3301
+ * 绑定工具:5 组 checkbox(中文名 + 插件短名 + 门控)+ 档位快捷组合按钮 +
3302
+ * 「已选 N 个工具」实时计数 + Shell 缺文件读写时的黄色提示。
3303
+ */
3304
+ function renderToolPicker(index, role, disabled) {
3305
+ var selected = Array.isArray(role.tools) ? role.tools : [];
3306
+ var groups = [];
3307
+ for (var g = 0; g < TOOL_GROUPS.length; g += 1) {
3308
+ var group = TOOL_GROUPS[g];
3309
+ var boxes = [];
3310
+ for (var i = 0; i < group.items.length; i += 1) {
3311
+ var item = group.items[i];
3312
+ var checked = selected.indexOf(item.id) >= 0;
3313
+ boxes.push(React.createElement("label", { key: item.id, className: "cohub-check" },
3314
+ React.createElement("input", {
3315
+ type: "checkbox",
3316
+ checked: checked,
3317
+ disabled: disabled,
3318
+ "aria-label": t("tool." + item.id),
3319
+ onChange: function (id, isChecked) {
3320
+ return function () {
3321
+ var next = [];
3322
+ for (var s = 0; s < selected.length; s += 1) if (selected[s] !== id) next.push(selected[s]);
3323
+ if (isChecked) next.push(id);
3324
+ props.editRole(index, "tools", next);
3325
+ };
3326
+ }(item.id, !checked)
3327
+ }),
3328
+ React.createElement("span", null, t("tool." + item.id)),
3329
+ React.createElement("span", { className: "cohub-check-id" }, item.plugin),
3330
+ item.gate ? React.createElement("span", { className: "cohub-badge cohub-badge-muted" }, t("gate." + item.gate)) : null
3331
+ ));
3332
+ }
3333
+ groups.push(React.createElement("div", { key: group.id, className: "cohub-check-group" },
3334
+ React.createElement("p", { className: "cohub-label" }, t(group.labelKey)),
3335
+ React.createElement("div", { className: "cohub-checks" }, boxes)
3336
+ ));
3337
+ }
3338
+ var tierButtons = [];
3339
+ for (var k = 0; k < ROLE_TIERS.length; k += 1) {
3340
+ var tier = ROLE_TIERS[k];
3341
+ var active = role.tier === tier;
3342
+ tierButtons.push(React.createElement("button", {
3343
+ key: tier,
3344
+ type: "button",
3345
+ className: active ? "cohub-tier-chip cohub-seg-active" : "cohub-tier-chip",
3346
+ "aria-pressed": active,
3347
+ disabled: disabled,
3348
+ onClick: function () {
3349
+ props.applyTierTools(index);
3350
+ }
3351
+ }, tierLabel(tier)));
3352
+ }
3353
+ return React.createElement("div", { className: "cohub-detail-block cohub-tool-block" },
3354
+ React.createElement("p", { className: "cohub-label" },
3355
+ t("roleToolsTitle") + " · " + t("roleToolsCount", { count: selected.length })),
3356
+ React.createElement("p", { className: "cohub-desc" }, t("roleToolsTierHint")),
3357
+ React.createElement("div", { className: "cohub-actions" }, tierButtons),
3358
+ groups,
3359
+ selected.length === 0 ? React.createElement("p", { className: "cohub-desc" }, t("roleToolsEmpty")) : null,
3360
+ shellWithoutFs(selected)
3361
+ ? React.createElement("p", { className: "cohub-notice cohub-notice-warn" }, t("roleToolsShellWarn"))
3362
+ : null
3363
+ );
3364
+ }
3365
+
3366
+ /** 模板选择器:co-orchestrator 置顶突出 → 16 内置角色(名称/一句职责/档位/工具数)→ 空白角色。 */
3367
+ function renderTemplatePicker(index) {
3368
+ var list = roleTemplateList();
3369
+ var cards = [];
3370
+ for (var i = 0; i < list.length; i += 1) {
3371
+ var item = list[i];
3372
+ var className = "cohub-template-card";
3373
+ if (item.main) className += " cohub-template-main";
3374
+ if (item.blank) className += " cohub-template-blank";
3375
+ cards.push(React.createElement("button", {
3376
+ key: item.id === "" ? "__blank" : item.id,
3377
+ type: "button",
3378
+ className: className,
3379
+ disabled: locked,
3380
+ onClick: function (id) {
3381
+ return function () {
3382
+ props.chooseTemplate(index, id);
3383
+ };
3384
+ }(item.id)
3385
+ },
3386
+ React.createElement("span", { className: "cohub-row-name" },
3387
+ item.main ? t("roleTemplateMain") : (item.blank ? t("roleTemplateBlank") : skillLabel(item.name))),
3388
+ React.createElement("span", { className: "cohub-role-summary" },
3389
+ item.blank ? t("roleTemplateBlankDesc") : item.description),
3390
+ item.blank ? null : React.createElement("span", { className: "cohub-badge" },
3391
+ item.main ? t("tier.mainAgent") : tierLabel(item.tier)),
3392
+ item.blank ? null : React.createElement("span", { className: "cohub-badge cohub-badge-muted" },
3393
+ t("roleToolCountSuffix", { count: item.tools.length }))
3394
+ ));
3395
+ }
3396
+ return React.createElement("div", { className: "cohub-detail-block cohub-templates" },
3397
+ React.createElement("p", { className: "cohub-label" }, t("roleTemplateSection")),
3398
+ React.createElement("p", { className: "cohub-desc" }, t("roleTemplateHint")),
3399
+ React.createElement("div", { className: "cohub-checks" }, cards)
3400
+ );
3401
+ }
3402
+
2529
3403
  function renderContentBlock(detail) {
2530
3404
  if (detail.promptSource === "none") return null;
2531
3405
  var body = detail.content !== ""
@@ -2562,7 +3436,10 @@ window.__ModuleLoader__.load({
2562
3436
  return React.createElement("div", { className: "cohub-role-detail" },
2563
3437
  React.createElement("div", { className: "cohub-detail-line" },
2564
3438
  React.createElement("span", { className: "cohub-label" }, t("roleDetailTier")),
2565
- React.createElement("span", { className: "cohub-badge cohub-badge-tier" }, tierLabel(detail.tier)),
3439
+ React.createElement("span", { className: "cohub-badge cohub-badge-tier" }, roleTierLabel(detail)),
3440
+ roleTierKey(detail) === "main"
3441
+ ? React.createElement("span", { className: "cohub-desc" }, t("roleDetailMainAgent"))
3442
+ : null,
2566
3443
  detail.promptSource === "none"
2567
3444
  ? React.createElement("span", { className: "cohub-desc" }, t("roleDetailUnknownRole"))
2568
3445
  : null
@@ -2576,10 +3453,13 @@ window.__ModuleLoader__.load({
2576
3453
  renderContentBlock(detail),
2577
3454
  React.createElement("div", { className: "cohub-detail-block" },
2578
3455
  React.createElement("p", { className: "cohub-label" },
2579
- t("roleDetailTools") + " · " + t("roleToolCount", { count: detail.toolCount })),
3456
+ roleTierKey(detail) === "main"
3457
+ ? t("roleDetailTools") + " · " + t("roleToolMainAgent")
3458
+ : t("roleDetailTools") + " · " + t("roleToolCount", { count: detail.toolCount })),
2580
3459
  toolItems.length > 0
2581
3460
  ? React.createElement("ul", { className: "cohub-readonly-tools" }, toolItems)
2582
- : React.createElement("p", { className: "cohub-desc" }, t("roleDetailNoTools"))
3461
+ : React.createElement("p", { className: "cohub-desc" },
3462
+ roleTierKey(detail) === "main" ? t("roleDetailMainAgent") : t("roleDetailNoTools"))
2583
3463
  ),
2584
3464
  React.createElement("p", { className: "cohub-desc" }, t("roleDetailReadOnly"))
2585
3465
  );
@@ -2595,7 +3475,9 @@ window.__ModuleLoader__.load({
2595
3475
  React.createElement("span", { className: "cohub-row-name" }, skillLabel(name)),
2596
3476
  React.createElement("span", { className: "cohub-role-summary" },
2597
3477
  detail.description !== "" ? detail.description : name),
2598
- React.createElement("span", { className: "cohub-badge" }, tierLabel(detail.tier)),
3478
+ React.createElement("span", { className: "cohub-badge" }, roleTierLabel(detail)),
3479
+ // 内置角色的模型路由可单独配置(写 Config.skills),卡片上直接展示当前徽标。
3480
+ modelPill(name),
2599
3481
  React.createElement("button", {
2600
3482
  type: "button",
2601
3483
  className: "cohub-row-reset",
@@ -2606,7 +3488,13 @@ window.__ModuleLoader__.load({
2606
3488
  }
2607
3489
  }, expanded ? t("roleDetailCollapse") : t("roleDetailToggle"))
2608
3490
  ),
2609
- expanded ? renderRoleDetail(name) : null
3491
+ expanded
3492
+ ? React.createElement("div", { key: "builtin-detail" },
3493
+ renderRoleDetail(name),
3494
+ React.createElement("p", { className: "cohub-desc" }, t("roleModelBuiltinNote")),
3495
+ renderRoleModel(name, locked)
3496
+ )
3497
+ : null
2610
3498
  );
2611
3499
  }
2612
3500
 
@@ -2622,6 +3510,12 @@ window.__ModuleLoader__.load({
2622
3510
  // 才回退到「未命名角色」。旧写法只比了 "",undefined 会被直接渲染成空标题。
2623
3511
  var roleTitle = typeof role.name === "string" ? role.name.trim() : "";
2624
3512
  var typeLabel = roleTitle !== "" ? role.name : t("roleUnsaved");
3513
+ // 模板标记:"" = 还没选模板(此时提示词 / 工具 / 模型区禁用并提示)。
3514
+ var templateMarks = state.roleTemplates || [];
3515
+ var templateId = index < templateMarks.length ? templateMarks[index] : "";
3516
+ var hasTemplate = templateId !== "";
3517
+ var promptDisabled = locked || !hasTemplate;
3518
+ var pickerOpen = !hasTemplate || state.rolePicker === index;
2625
3519
  return React.createElement("li", {
2626
3520
  key: "role-" + index,
2627
3521
  className: invalid ? "cohub-row cohub-invalid" : "cohub-row"
@@ -2631,6 +3525,7 @@ window.__ModuleLoader__.load({
2631
3525
  React.createElement("span", { className: "cohub-role-summary" },
2632
3526
  role.description !== "" ? role.description : t("roleDescription")),
2633
3527
  React.createElement("span", { className: "cohub-badge" }, tierLabel(role.tier)),
3528
+ roleTitle !== "" ? modelPill(role.name) : null,
2634
3529
  // 未命名的草稿行查不到详情:按钮留着但禁用,避免空键把面板挂到别的角色上。
2635
3530
  React.createElement("button", {
2636
3531
  type: "button",
@@ -2698,7 +3593,7 @@ window.__ModuleLoader__.load({
2698
3593
  React.createElement("textarea", {
2699
3594
  className: error.prompt !== "" ? "cohub-textarea cohub-invalid" : "cohub-textarea",
2700
3595
  value: role.prompt,
2701
- disabled: locked,
3596
+ disabled: promptDisabled,
2702
3597
  rows: 3,
2703
3598
  "aria-label": typeLabel + " · " + t("rolePrompt"),
2704
3599
  onChange: function (event) {
@@ -2707,6 +3602,25 @@ window.__ModuleLoader__.load({
2707
3602
  })
2708
3603
  )
2709
3604
  ),
3605
+ // 模板状态行:已选 → 「基于模板:xxx」+「重新选择模板」;未选 → 禁用提示。
3606
+ React.createElement("div", { className: "cohub-actions cohub-template-head" },
3607
+ hasTemplate
3608
+ ? React.createElement("span", { className: "cohub-badge" },
3609
+ t("roleTemplateBasedOn", { name: templateLabelOf(templateId) }))
3610
+ : React.createElement("span", { className: "cohub-desc" }, t("roleTemplateNone")),
3611
+ React.createElement("button", {
3612
+ type: "button",
3613
+ className: "cohub-row-reset",
3614
+ disabled: locked,
3615
+ "aria-expanded": pickerOpen,
3616
+ onClick: function () {
3617
+ props.toggleRolePicker(index);
3618
+ }
3619
+ }, t("roleTemplateReselect"))
3620
+ ),
3621
+ pickerOpen ? renderTemplatePicker(index) : null,
3622
+ renderToolPicker(index, role, locked || !hasTemplate),
3623
+ roleTitle !== "" ? renderRoleModel(role.name, locked || !hasTemplate) : null,
2710
3624
  message !== "" ? React.createElement("p", { className: "cohub-role-error" }, message) : null,
2711
3625
  roleTitle !== "" && state.expandedRole === role.name ? renderRoleDetail(role.name) : null
2712
3626
  );
@@ -2803,7 +3717,7 @@ window.__ModuleLoader__.load({
2803
3717
  props.toggleRoleDetail(roleName);
2804
3718
  };
2805
3719
  }(name)
2806
- }, tierLabel(memberDetail.tier) + " · " + t("roleToolCount", { count: memberDetail.toolCount })),
3720
+ }, roleToolSummary(memberDetail)),
2807
3721
  state.expandedRole === name ? renderRoleDetail(name) : null
2808
3722
  ));
2809
3723
  }
@@ -2816,26 +3730,86 @@ window.__ModuleLoader__.load({
2816
3730
  return blocks;
2817
3731
  }
2818
3732
 
3733
+ /**
3734
+ * 队长选择器:选项**只来自当前已勾选的成员**(未勾选的角色当不了队长)。
3735
+ * 没勾任何成员 → 禁用并提示「先选成员」;lead 为空时按 effectiveTeamLead 预选默认值;
3736
+ * lead 悬空(原队长被取消勾选)时额外留一个标红选项,让「保存被拦」的原因可见。
3737
+ */
3738
+ function renderLeadPicker(team, index, title) {
3739
+ var members = Array.isArray(team.members) ? team.members : [];
3740
+ var label = title + " · " + t("teamLead");
3741
+ if (members.length === 0) {
3742
+ return React.createElement("div", { className: "cohub-lead-picker" },
3743
+ React.createElement("select", {
3744
+ className: "cohub-input",
3745
+ disabled: true,
3746
+ value: "",
3747
+ "aria-label": label
3748
+ }, React.createElement("option", { value: "" }, t("teamLeadEmpty"))),
3749
+ React.createElement("span", { className: "cohub-desc" }, t("teamLeadEmpty")));
3750
+ }
3751
+ var raw = typeof team.lead === "string" ? team.lead : "";
3752
+ var options = [];
3753
+ if (raw !== "" && members.indexOf(raw) < 0) {
3754
+ options.push(React.createElement("option", { key: "__dangling", value: raw },
3755
+ raw + "(" + t("teamLeadDangling") + ")"));
3756
+ }
3757
+ for (var i = 0; i < members.length; i += 1) {
3758
+ options.push(React.createElement("option", { key: members[i], value: members[i] }, members[i]));
3759
+ }
3760
+ return React.createElement("div", { className: "cohub-lead-picker" },
3761
+ React.createElement("select", {
3762
+ className: "cohub-input",
3763
+ disabled: locked,
3764
+ value: raw !== "" ? raw : effectiveTeamLead(team),
3765
+ "aria-label": label,
3766
+ onChange: function (event) {
3767
+ props.setTeamLead(index, event.target.value);
3768
+ }
3769
+ }, options),
3770
+ React.createElement("span", { className: "cohub-desc" }, t("teamLeadHint")));
3771
+ }
3772
+
2819
3773
  function renderTeam(team, index) {
2820
3774
  var error = teamErrorsState[index] && typeof teamErrorsState[index] === "object" ? teamErrorsState[index] : {};
2821
3775
  var invalid = error.name !== "" || error.members !== "" || error.id !== "";
2822
3776
  var isActive = team.id !== "" && team.id === state.activeTeam;
2823
3777
  var expanded = state.expandedTeam === index;
2824
- var title = typeof team.name === "string" && team.name.trim() !== "" ? team.name : t("teamUnsaved");
3778
+ // 标题只读 name;teamTitle 返回 null 才回退——空名字段的 "writing" 只是占位符,不是值。
3779
+ var named = teamTitle(team);
3780
+ var title = named !== null ? named : t("teamUnsaved");
3781
+ var leadName = effectiveTeamLead(team);
2825
3782
  var knownMembers = [];
2826
3783
  for (var m = 0; m < team.members.length; m += 1) knownMembers.push(team.members[m]);
2827
3784
  for (var c = 0; c < candidates.custom.length; c += 1) knownMembers.push(candidates.custom[c].name);
2828
3785
  for (var bi = 0; bi < candidates.builtin.length; bi += 1) knownMembers.push(candidates.builtin[bi]);
2829
3786
  var message = teamMessage(error);
3787
+ // 「角色库里有这个名字吗」——注意不能用 knownMembers(它含 team.members 自身,
3788
+ // 那样任何悬空成员都会被判为已知,警告永远不触发)。
3789
+ var libraryNames = candidates.builtin.slice();
3790
+ for (var ln = 0; ln < candidates.custom.length; ln += 1) libraryNames.push(candidates.custom[ln].name);
3791
+ // 成员异常(空成员 / 角色已不在角色库):卡片上黄字提示,**不阻止保存**——
3792
+ // 团队可能有意先保留占位成员,真正的落库校验只有 validateTeams 那几条。
3793
+ var badMembers = [];
3794
+ for (var bm = 0; bm < team.members.length; bm += 1) {
3795
+ var memberName = typeof team.members[bm] === "string" ? team.members[bm].trim() : "";
3796
+ if (memberName === "" || libraryNames.indexOf(memberName) < 0) {
3797
+ badMembers.push(memberName === "" ? t("teamMemberEmpty") : memberName);
3798
+ }
3799
+ }
3800
+ var memberWarning = badMembers.length > 0 ? badMembers.join(t("listSeparator")) : "";
2830
3801
  // 成员档位分布:一眼看出这组权限构成(未知档位/查不到的角色并入「未知档位」)。
2831
3802
  var distribution = tierDistributionOf(team.members, roles);
2832
3803
  var distributionParts = [];
2833
3804
  for (var d = 0; d < distribution.length; d += 1) {
2834
- distributionParts.push(tierLabel(distribution[d].tier) + " ×" + distribution[d].count);
3805
+ distributionParts.push(roleTierLabel(distribution[d]) + " ×" + distribution[d].count);
2835
3806
  }
2836
3807
 
2837
3808
  var body = expanded
2838
3809
  ? React.createElement("div", { className: "cohub-team-body" },
3810
+ team.isNew === true
3811
+ ? React.createElement("p", { className: "cohub-notice" }, t("teamNewPresetHint"))
3812
+ : null,
2839
3813
  React.createElement("div", { className: "cohub-role-fields" },
2840
3814
  React.createElement("div", { className: "cohub-field" },
2841
3815
  React.createElement("label", { className: "cohub-label" }, t("teamName")),
@@ -2844,13 +3818,34 @@ window.__ModuleLoader__.load({
2844
3818
  type: "text",
2845
3819
  value: team.name,
2846
3820
  disabled: locked,
2847
- placeholder: "writing",
3821
+ placeholder: t("teamNamePlaceholder"),
2848
3822
  "aria-label": title + " · " + t("teamName"),
2849
3823
  onChange: function (event) {
2850
3824
  props.editTeam(index, "name", event.target.value);
2851
3825
  }
2852
3826
  })
2853
3827
  ),
3828
+ // 预设 id 终段(slug):可改。初值 = 推导结果(中文名折空 → "team"),手改后不再被改名覆盖。
3829
+ React.createElement("div", { className: "cohub-field" },
3830
+ React.createElement("label", {
3831
+ className: error.id !== "" ? "cohub-label cohub-invalid-label" : "cohub-label"
3832
+ }, t("teamPresetSlug")),
3833
+ React.createElement("div", { className: "cohub-slug-row" },
3834
+ React.createElement("input", {
3835
+ className: error.id !== "" ? "cohub-input cohub-mono cohub-invalid" : "cohub-input cohub-mono",
3836
+ type: "text",
3837
+ value: teamSlugOf(team),
3838
+ disabled: locked,
3839
+ placeholder: t("teamSlugPlaceholder"),
3840
+ "aria-label": title + " · " + t("teamPresetSlug"),
3841
+ onChange: function (event) {
3842
+ props.editTeam(index, "slug", event.target.value);
3843
+ }
3844
+ }),
3845
+ React.createElement("span", { className: "cohub-desc cohub-mono" },
3846
+ t("teamPresetIdFinal", { id: teamPresetIdOf(team) }))
3847
+ )
3848
+ ),
2854
3849
  React.createElement("div", { className: "cohub-field" },
2855
3850
  React.createElement("label", { className: "cohub-label" }, t("teamDescription")),
2856
3851
  React.createElement("input", {
@@ -2864,6 +3859,13 @@ window.__ModuleLoader__.load({
2864
3859
  }
2865
3860
  })
2866
3861
  ),
3862
+ React.createElement("div", { className: "cohub-field" },
3863
+ React.createElement("label", {
3864
+ className: error.lead !== "" ? "cohub-label cohub-invalid-label" : "cohub-label"
3865
+ }, t("teamLead")),
3866
+ renderLeadPicker(team, index, title),
3867
+ error.lead !== "" ? React.createElement("p", { className: "cohub-desc" }, t("teamErrLeadNotMember")) : null
3868
+ ),
2867
3869
  React.createElement("div", { className: "cohub-field cohub-field-wide" },
2868
3870
  React.createElement("label", {
2869
3871
  className: error.members !== "" ? "cohub-label cohub-invalid-label" : "cohub-label"
@@ -2892,23 +3894,19 @@ window.__ModuleLoader__.load({
2892
3894
  }
2893
3895
  },
2894
3896
  React.createElement("span", { className: "cohub-row-name" }, title),
2895
- React.createElement("span", { className: "cohub-row-id" }, team.id),
3897
+ // 名称下方一行的等宽小字:团队注册成 Agent 预设时用的真实 id。
3898
+ React.createElement("span", { className: "cohub-row-id cohub-mono" },
3899
+ t("teamPresetIdBadge", { id: teamPresetIdOf(team) })),
2896
3900
  React.createElement("span", { className: "cohub-badge" },
2897
- t("teamMemberCount", { count: team.members.length }))
3901
+ t("teamMemberCount", { count: team.members.length })),
3902
+ leadName !== "" ? React.createElement("span", { className: "cohub-badge cohub-badge-lead" },
3903
+ t("teamLeadBadge", { name: leadName })) : null
2898
3904
  ),
2899
3905
  distributionParts.length > 0
2900
3906
  ? React.createElement("span", { className: "cohub-tier-dist" },
2901
3907
  t("teamTierDistribution") + " · " + distributionParts.join(t("listSeparator")))
2902
3908
  : null,
2903
3909
  isActive ? React.createElement("span", { className: "cohub-badge cohub-badge-explicit" }, t("teamActiveBadge")) : null,
2904
- React.createElement("button", {
2905
- type: "button",
2906
- className: "cohub-row-reset",
2907
- disabled: locked || state.activeTeamBusy || team.id === "",
2908
- onClick: function () {
2909
- props.setActiveTeam(team.id);
2910
- }
2911
- }, isActive ? t("teamUnsetActive") : t("teamSetActive")),
2912
3910
  React.createElement("button", {
2913
3911
  type: "button",
2914
3912
  className: "cohub-row-reset",
@@ -2919,6 +3917,10 @@ window.__ModuleLoader__.load({
2919
3917
  }
2920
3918
  }, t("teamRemove"))
2921
3919
  ),
3920
+ memberWarning !== ""
3921
+ ? React.createElement("p", { className: "cohub-desc cohub-status-warn" },
3922
+ t("teamMemberWarn", { names: memberWarning }))
3923
+ : null,
2922
3924
  body
2923
3925
  );
2924
3926
  }
@@ -2949,6 +3951,10 @@ window.__ModuleLoader__.load({
2949
3951
 
2950
3952
  var teamsBlock = React.createElement("div", { className: "cohub-roles" },
2951
3953
  React.createElement("h3", { className: "cohub-subtitle" }, t("teamsTitle")),
3954
+ // 只读一行:当前会话预设(客户端拿不到会话的预设 → 稳定的降级文案)+ 切换入口提示。
3955
+ // 旧的「设为当前」下拉/按钮已删除:切换统一走 设置 → Agent 预设(Config.activeTeam 已废弃)。
3956
+ React.createElement("p", { className: "cohub-notice cohub-mono" }, t("teamPresetUnknown")),
3957
+ React.createElement("p", { className: "cohub-desc" }, t("teamPresetSwitchHint")),
2952
3958
  React.createElement("p", { className: "cohub-desc" }, t("teamsDescription")),
2953
3959
  teams.length === 0
2954
3960
  ? React.createElement("p", { className: "cohub-notice" }, t("teamEmpty"))
@@ -2978,13 +3984,49 @@ window.__ModuleLoader__.load({
2978
3984
  onClick: function () {
2979
3985
  props.saveTeams();
2980
3986
  }
2981
- }, t(state.saving ? "saving" : "teamSavedLabel"))
3987
+ }, t(state.saving ? "saving" : "teamSavedLabel")),
3988
+ React.createElement("p", { className: "cohub-desc" }, t("teamSaveRegisterHint"))
3989
+ )
3990
+ );
3991
+
3992
+ // 角色库顶部固定一张主代理卡:标注纯调度 / 不绑定档位,可直接「以此模板新建」。
3993
+ var mainRoleCard = React.createElement("ul", { className: "cohub-rows" },
3994
+ React.createElement("li", { className: "cohub-row cohub-row-catalog cohub-row-main" },
3995
+ React.createElement("div", { className: "cohub-row-head" },
3996
+ React.createElement("span", { className: "cohub-row-name" }, MAIN_AGENT_NAME),
3997
+ React.createElement("span", { className: "cohub-role-summary" }, t("roleMainBadge")),
3998
+ modelPill(MAIN_AGENT_NAME),
3999
+ React.createElement("button", {
4000
+ type: "button",
4001
+ className: "cohub-row-reset",
4002
+ disabled: locked,
4003
+ "aria-expanded": state.expandedRole === MAIN_AGENT_NAME,
4004
+ onClick: function () {
4005
+ props.toggleRoleDetail(MAIN_AGENT_NAME);
4006
+ }
4007
+ }, state.expandedRole === MAIN_AGENT_NAME ? t("roleDetailCollapse") : t("roleMainDetail")),
4008
+ React.createElement("button", {
4009
+ type: "button",
4010
+ className: "cohub-row-reset",
4011
+ disabled: locked,
4012
+ onClick: function () {
4013
+ props.newRoleFromMain();
4014
+ }
4015
+ }, t("roleMainNew"))
4016
+ ),
4017
+ state.expandedRole === MAIN_AGENT_NAME
4018
+ ? React.createElement("div", { key: "main-detail" },
4019
+ renderRoleDetail(MAIN_AGENT_NAME),
4020
+ React.createElement("p", { className: "cohub-desc" }, t("roleModelBuiltinNote")),
4021
+ renderRoleModel(MAIN_AGENT_NAME, locked))
4022
+ : null
2982
4023
  )
2983
4024
  );
2984
4025
 
2985
4026
  var rolesBlock = React.createElement("div", { className: "cohub-roles" },
2986
4027
  React.createElement("h3", { className: "cohub-subtitle" }, t("rolesTitle")),
2987
4028
  React.createElement("p", { className: "cohub-desc" }, t("rolesDescription")),
4029
+ mainRoleCard,
2988
4030
  // 内置角色:只读卡片,与下面的自定义角色共用同一份详情面板。
2989
4031
  React.createElement("div", { className: "cohub-roles" },
2990
4032
  React.createElement("p", { className: "cohub-sublabel" }, t("builtinRolesTitle")),
@@ -3131,6 +4173,24 @@ window.__ModuleLoader__.load({
3131
4173
  editRole: function (index, field, value) {
3132
4174
  controller.editRole(index, field, value);
3133
4175
  },
4176
+ chooseTemplate: function (index, templateId) {
4177
+ controller.chooseTemplate(index, templateId);
4178
+ },
4179
+ applyTierTools: function (index) {
4180
+ return controller.applyTierTools(index);
4181
+ },
4182
+ toggleRolePicker: function (index) {
4183
+ controller.toggleRolePicker(index);
4184
+ },
4185
+ newRoleFromMain: function () {
4186
+ controller.newRoleFromMain();
4187
+ },
4188
+ editSkill: function (name, field, value) {
4189
+ controller.editSkillRow(name, field, value);
4190
+ },
4191
+ resetSkill: function (name) {
4192
+ controller.resetSkillRow(name);
4193
+ },
3134
4194
  addRole: function () {
3135
4195
  controller.addRole();
3136
4196
  },
@@ -3161,14 +4221,14 @@ window.__ModuleLoader__.load({
3161
4221
  toggleTeamMember: function (index, name) {
3162
4222
  controller.toggleTeamMember(index, name);
3163
4223
  },
4224
+ setTeamLead: function (index, name) {
4225
+ controller.setTeamLead(index, name);
4226
+ },
3164
4227
  discardTeams: function () {
3165
4228
  controller.discardTeams();
3166
4229
  },
3167
4230
  saveTeams: function () {
3168
4231
  return controller.saveTeams();
3169
- },
3170
- setActiveTeam: function (id) {
3171
- return controller.setActiveTeam(id);
3172
4232
  }
3173
4233
  };
3174
4234
  };
@@ -3199,6 +4259,9 @@ window.__ModuleLoader__.load({
3199
4259
  reasoningEffortsOf: reasoningEffortsOf,
3200
4260
  kebabIdOf: kebabIdOf,
3201
4261
  uniqueTeamId: uniqueTeamId,
4262
+ teamPresetId: teamPresetId,
4263
+ teamSlugOf: teamSlugOf,
4264
+ teamPresetIdOf: teamPresetIdOf,
3202
4265
  validateTeams: validateTeams,
3203
4266
  countTeamErrors: countTeamErrors,
3204
4267
  teamsToConfig: teamsToConfig,
@@ -3207,7 +4270,11 @@ window.__ModuleLoader__.load({
3207
4270
  tierKnown: tierKnown,
3208
4271
  tierToolsOf: tierToolsOf,
3209
4272
  roleDetailOf: roleDetailOf,
3210
- tierDistributionOf: tierDistributionOf
4273
+ tierDistributionOf: tierDistributionOf,
4274
+ teamTitle: teamTitle,
4275
+ effectiveTeamLead: effectiveTeamLead,
4276
+ isMainAgent: isMainAgent,
4277
+ roleTierKey: roleTierKey
3211
4278
  };
3212
4279
  return module.exports;
3213
4280
  }