@fish-under-sea/dsh-agent-teams-fish 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/NOTICE.md +13 -7
  2. package/README.en.md +20 -12
  3. package/README.md +20 -12
  4. package/compatibility.json +82 -46
  5. package/icon.png +0 -0
  6. package/lib/artifacts.js +148 -25
  7. package/lib/client/ActivityPanel.js +26 -5
  8. package/lib/client/WorkspaceActivity.js +6 -4
  9. package/lib/client/activity-monitor.js +113 -41
  10. package/lib/client/locales.js +14 -0
  11. package/lib/client.js +433 -199
  12. package/lib/client.js.map +1 -1
  13. package/lib/command.js +7 -4
  14. package/lib/git-artifact-stamp.json +2 -2
  15. package/lib/harness-compat.js +120 -62
  16. package/lib/index.js +7 -10
  17. package/lib/mailbox.js +15 -5
  18. package/lib/members.js +221 -154
  19. package/lib/snapshot.js +15 -10
  20. package/lib/state.js +41 -8
  21. package/lib/tools.js +123 -64
  22. package/lib/types/artifacts.d.ts +6 -3
  23. package/lib/types/client/activity-monitor.d.ts +13 -4
  24. package/lib/types/client/locales.d.ts +14 -0
  25. package/lib/types/harness-compat.d.ts +63 -16
  26. package/lib/types/mailbox.d.ts +2 -0
  27. package/lib/types/members.d.ts +5 -17
  28. package/lib/types/snapshot.d.ts +12 -7
  29. package/lib/types/state.d.ts +10 -3
  30. package/lib/types/types.d.ts +5 -0
  31. package/lib/types/web-routes.d.ts +2 -0
  32. package/lib/types/workspace-audit-service.d.ts +35 -0
  33. package/lib/types/workspace-audit-worker.d.ts +1 -0
  34. package/lib/web-routes.js +31 -0
  35. package/lib/workspace-audit-service.js +165 -0
  36. package/lib/workspace-audit-worker.js +11 -0
  37. package/lib/workspace-audit.js +6 -5
  38. package/locale/en.json +6 -0
  39. package/locale/zh.json +6 -0
  40. package/package.json +69 -64
  41. package/pnpm-workspace.yaml +306 -273
  42. package/release-notes/v0.1.25.md +16 -0
  43. package/release-notes/v0.1.26.md +19 -0
  44. package/release-notes/v0.1.27.md +42 -0
  45. package/release-notes/v0.1.28.md +45 -0
  46. package/release-notes/v0.1.29.md +23 -0
  47. package/release-notes/v1.1.0.md +42 -0
  48. package/release-notes/v2.0.0.md +17 -0
  49. package/scripts/artwork-role-match.test.mjs +517 -0
  50. package/scripts/capabilities.test.mjs +301 -0
  51. package/scripts/check-install-channel.mjs +55 -0
  52. package/scripts/check-install-channel.test.mjs +39 -0
  53. package/scripts/clean-build.mjs +14 -0
  54. package/scripts/client-harness-migration.test.mjs +46 -0
  55. package/scripts/compatibility.mjs +20 -0
  56. package/scripts/compatibility.test.mjs +187 -0
  57. package/scripts/corrupt-teamjson.test.mjs +180 -0
  58. package/scripts/custom-artwork.test.mjs +273 -0
  59. package/scripts/fallback-tdd.mjs +61 -0
  60. package/scripts/fixtures/harness-benchmark-scope.mjs +16 -0
  61. package/scripts/fixtures/harness-benchmark-scope.test.mjs +18 -0
  62. package/scripts/fixtures/harness-complex-case.mjs +201 -0
  63. package/scripts/fixtures/harness-complex-case.test.mjs +21 -0
  64. package/scripts/fixtures/harness-complex-oracle.mjs +63 -0
  65. package/scripts/fixtures/harness-issue-case.mjs +51 -0
  66. package/scripts/fixtures/harness-issue159-case.mjs +28 -0
  67. package/scripts/fixtures/harness-model-case.mjs +127 -0
  68. package/scripts/fixtures/harness-model-case.test.mjs +37 -0
  69. package/scripts/fixtures/harness-model-driver.mjs +100 -0
  70. package/scripts/fixtures/harness-runtime-credentials.mjs +23 -0
  71. package/scripts/fixtures/harness-runtime-entry.mjs +171 -0
  72. package/scripts/fixtures/harness-runtime-idle.mjs +42 -0
  73. package/scripts/fixtures/harness-runtime-llm.mjs +193 -0
  74. package/scripts/fixtures/harness-runtime-protocol.mjs +187 -0
  75. package/scripts/fixtures/harness-runtime-resume.mjs +24 -0
  76. package/scripts/fixtures/harness-runtime-stability.mjs +282 -0
  77. package/scripts/fixtures/harness-runtime-tools.mjs +13 -0
  78. package/scripts/fixtures/harness-runtime-web-approval.mjs +341 -0
  79. package/scripts/fixtures/issue-336-audit-worker.mjs +18 -0
  80. package/scripts/git-artifacts.mjs +64 -0
  81. package/scripts/git-artifacts.test.mjs +32 -0
  82. package/scripts/harness-compat-tdd.mjs +492 -0
  83. package/scripts/harness-issue-verify.mjs +26 -0
  84. package/scripts/harness-model-benchmark.mjs +163 -0
  85. package/scripts/harness-runtime-platform.test.mjs +31 -0
  86. package/scripts/harness-runtime-scenarios.mjs +297 -0
  87. package/scripts/harness-runtime-verify.mjs +169 -0
  88. package/scripts/harness-source-verify.mjs +211 -0
  89. package/scripts/harness-source-verify.test.mjs +97 -0
  90. package/scripts/harness-validation.mjs +68 -0
  91. package/scripts/harness-validation.test.mjs +95 -0
  92. package/scripts/http-body.test.mjs +72 -0
  93. package/scripts/import-vendor-artwork.mjs +78 -0
  94. package/scripts/inline-plan-blank-optional-tdd.mjs +121 -0
  95. package/scripts/issue-159.test.mjs +78 -0
  96. package/scripts/issue-188.test.mjs +148 -0
  97. package/scripts/issue-189.test.mjs +100 -0
  98. package/scripts/issue-203-card.test.mjs +181 -0
  99. package/scripts/issue-205.test.mjs +163 -0
  100. package/scripts/issue-234.test.mjs +424 -0
  101. package/scripts/issue-236-stale-module.test.mjs +63 -0
  102. package/scripts/issue-236.test.mjs +59 -0
  103. package/scripts/issue-262.test.mjs +98 -0
  104. package/scripts/issue-336.test.mjs +404 -0
  105. package/scripts/legacy-session-source-repair.test.mjs +201 -0
  106. package/scripts/lifecycle-verify.mjs +1573 -0
  107. package/scripts/lineage-identity.test.mjs +77 -0
  108. package/scripts/member-failure-tdd.mjs +451 -0
  109. package/scripts/member-spawn-recovery.test.mjs +92 -0
  110. package/scripts/quality-gates-amend.test.mjs +161 -0
  111. package/scripts/quality-gates-content-bound.test.mjs +572 -0
  112. package/scripts/quality-gates-cross-binding.test.mjs +184 -0
  113. package/scripts/quality-gates-excluded-scope.test.mjs +163 -0
  114. package/scripts/quality-gates-repair-scope.test.mjs +143 -0
  115. package/scripts/quality-gates-repair-wiring.test.mjs +189 -0
  116. package/scripts/quality-gates-tdd.mjs +1238 -0
  117. package/scripts/quality-gates-work-order.test.mjs +494 -0
  118. package/scripts/readme-version.mjs +89 -0
  119. package/scripts/readme-version.test.mjs +77 -0
  120. package/scripts/release-metadata.mjs +45 -0
  121. package/scripts/release-metadata.test.mjs +66 -0
  122. package/scripts/scoped-release.test.mjs +52 -0
  123. package/scripts/stability-tdd.mjs +144 -0
  124. package/scripts/stress-verify.mjs +548 -0
  125. package/scripts/symlink-support.mjs +46 -0
  126. package/scripts/sync-skill.mjs +103 -0
  127. package/scripts/tool-policies.test.mjs +280 -0
  128. package/scripts/update-skills.mjs +105 -0
  129. package/scripts/update-skills.test.mjs +79 -0
  130. package/scripts/upgrade-status.mjs +66 -0
  131. package/scripts/upgrade-status.test.mjs +83 -0
  132. package/scripts/verify-package.mjs +73 -0
  133. package/scripts/verify.mjs +2199 -0
  134. package/scripts/web-routes-verify.mjs +142 -0
  135. package/scripts/workspace-activity.test.mjs +346 -0
  136. package/scripts/workspace-summary.test.mjs +49 -0
  137. package/src/artifacts.ts +487 -0
  138. package/src/artwork-source.ts +262 -0
  139. package/src/capabilities.ts +113 -0
  140. package/src/client/ActivityPanel.module.css +2390 -0
  141. package/src/client/ActivityPanel.tsx +1507 -0
  142. package/src/client/AgentTeamsCard.module.css +148 -0
  143. package/src/client/AgentTeamsCard.tsx +155 -0
  144. package/src/client/StagingPlanEditor.tsx +829 -0
  145. package/src/client/TeamChatEntry.tsx +27 -0
  146. package/src/client/WorkspaceActivity.module.css +41 -0
  147. package/src/client/WorkspaceActivity.tsx +137 -0
  148. package/src/client/activity-model.ts +372 -0
  149. package/src/client/activity-monitor.ts +440 -0
  150. package/src/client/agent-teams-card-definition.ts +250 -0
  151. package/src/client/artwork.ts +374 -0
  152. package/src/client/icons.tsx +17 -0
  153. package/src/client/index.tsx +140 -0
  154. package/src/client/locales.ts +481 -0
  155. package/src/client/panel-geometry.ts +194 -0
  156. package/src/client/session-navigation.ts +73 -0
  157. package/src/client/workspace-state.ts +52 -0
  158. package/src/command.ts +145 -0
  159. package/src/css-modules.d.ts +4 -0
  160. package/src/event-types.ts +177 -0
  161. package/src/events.ts +78 -0
  162. package/src/harness-compat.ts +570 -0
  163. package/src/index.ts +599 -0
  164. package/src/lineage.ts +248 -0
  165. package/src/mailbox.ts +185 -0
  166. package/src/members.ts +1230 -0
  167. package/src/profiles.ts +765 -0
  168. package/src/quality-gates.ts +2124 -0
  169. package/src/scheduler.ts +554 -0
  170. package/src/snapshot.ts +333 -0
  171. package/src/state.ts +1317 -0
  172. package/src/tool-names.ts +14 -0
  173. package/src/tool-policies.ts +219 -0
  174. package/src/tools.ts +2939 -0
  175. package/src/types.ts +414 -0
  176. package/src/web-routes.ts +128 -0
  177. package/src/workspace-audit-service.ts +182 -0
  178. package/src/workspace-audit-worker.ts +12 -0
  179. package/src/workspace-audit.ts +57 -0
@@ -0,0 +1,374 @@
1
+ /**
2
+ * Shared character artwork lookup for the activity panel and the conversation
3
+ * card: role keywords pick the role, and a member's model vendor picks which
4
+ * character wears it. The captain always uses the lead artwork.
5
+ *
6
+ * Only the most specific slug is requested here. The host degrades a missing
7
+ * combination along `vendor+role → role → vendor → packaged whale`, so a
8
+ * vendor this list does not know still gets the role artwork instead of a
9
+ * broken image.
10
+ * @module dsh-agent-teams/client/artwork
11
+ */
12
+
13
+ /** Artwork route prefix served by the plugin host half. */
14
+ export const ART_BASE = '/plugins/dsh-agent-teams/assets/'
15
+
16
+ /** Role token per role keyword, in match order.
17
+ *
18
+ * 优先级说明(越靠前越先匹配):
19
+ * 1. data / researcher 前置,因为它们的关键词(埋点/统计/报表/指标、调研/资料/情报)
20
+ * 容易与 engineer 等岗位重叠,先排可避免被 engineer 的“开发/代码”等广义词吞掉。
21
+ * data 桶补充了“连击/计分/得分/评分/分数”——这些词只出现在战局/计分等量化场景,
22
+ * 不会与 QA/合规 语境的“判定”等宽泛词混淆,因此放在最前也不会误抢。
23
+ * 2. qa 在 security 之前,这样“代码质量审查”会先命中 qa;否则“审查”会被 security 抢走。
24
+ * 3. security 在 designer 之后,避免“设计安全”类复合词被 security 抢先。
25
+ * 4. engineer 范围较广,放在 qa/security 之后,避免把“质量/审计”类词误吞。
26
+ */
27
+ const ROLE_ART: ReadonlyArray<readonly [RegExp, string]> = [
28
+ // audio / video 是最窄的桶,必须前置:否则「视频渲染」会被 engineer 的「渲染/实现」吞掉。
29
+ [/\baudio\b|sound|\bvoice\b|music|\btts\b|音频|语音|音效|音乐|配音/, 'audio'],
30
+ [/\bvideo\b|\bfilm\b|movie|animat|\bclip\b|视频|影片|剪辑|动画|字幕/, 'video'],
31
+ [/data|analys|metric|performance|埋点|统计|报表|指标|数据|分析|性能|连击|计分|得分|评分|分数/, 'data'],
32
+ [/resear|investig|explor|study|调研|研究|调查|探索|资料|情报/, 'researcher'],
33
+ // Match compound QA titles (for example "QA Engineer") before the broad
34
+ // engineer bucket, otherwise an eight-role roster repeats the engineer art.
35
+ // 注意:这里刻意**不**匹配成员名里的 "reviewer"——qa 排在 security 之前,
36
+ // 名称规则会把 "Security Reviewer" 这类身份抢成 qa,使 member-security 图不可达
37
+ // (仓库自检 scripts/verify.mjs 的 packaging contract 会当场抓住)。审查类成员
38
+ // 由角色文字里的「质量/验证」命中 qa,纯「审查/审计」则落 security,语义更准。
39
+ [/\bqa\b|test|verif|quality|校验|核验|体检|回归|冒烟|测试|质量|验证/, 'qa'],
40
+ [/engineer|dev\b|server|backend|\bapi\b|runtime|watcher|contract|架构|模块|接口|运行时|装配|工程|后端|服务|开发|代码|编程|实现/, 'engineer'],
41
+ [/design|\bui\b|\bux\b|front|theme|accessib|视觉|界面|样式|皮肤|动效|设计|前端|主题|无障碍|美术|插画|立绘|出图|绘制|美工|交互/, 'designer'],
42
+ [/secur|audit|risk|threat|review|合规|风控|权限|审计|安全|审查|风险/, 'security'],
43
+ [/docs|writer|author|edit|readme|product|spec|说明|手册|教程|文案|撰写|写作|作者|写手|文档|规范/, 'docs'],
44
+ [/release|\bbuild\b|deploy|\bops\b|\bci\b|ship|coordin|部署|发布|上线|流水线|调度|编排|构建|运维|协调/, 'operator'],
45
+ ]
46
+
47
+ /**
48
+ * Vendor token per provider/model id, in match order. The model id is the
49
+ * reliable half: one provider (`bailian`) serves several vendors.
50
+ *
51
+ * These tokens must stay identical to `ARTWORK_VENDORS` in the host half
52
+ * (`../artwork-source.ts`); a token the host rejects would 404 the image.
53
+ */
54
+ const VENDOR_ART: ReadonlyArray<readonly [RegExp, string]> = [
55
+ // 两类系统性病根(2026-10-08 修复,不是「少写一个别名」而已):
56
+ //
57
+ // 1. 尾随 \b 卡住「名字 + 数字」的 id:`\bhunyuan\b` 匹配不了 `hunyuan3` ——
58
+ // `3` 是词字符,两者之间没有边界。同类还有 `\brwkv\b` 之于 `rwkv7`、
59
+ // `\bseed\b` 之于 `seed1.6`、`\babab\b` 之于 `abab6.5s`、`\bchatglm\b`
60
+ // 之于 `chatglm3-6b`。所以厂商主名一律用 `[\w.-]*` 吸收后缀,不再要求尾部边界。
61
+ // 2. `\b` 对 CJK **永远不成立**:JS 的 `\w` 只含 ASCII,`\b混元\b` 两侧都是非词
62
+ // 字符,不存在边界 —— 中文别名此前全是死分支。中文一律不写 `\b`。
63
+ //
64
+ // 混元额外补 `hy` 家族(用户口径:混元多用 hy):`hy3` / `hy-3` / `hy_1.5` /
65
+ // `hy-mt2-pro` 都认;但**不**放宽成裸 `\bhy`,否则 `hypothesis` / `hybrid-1` /
66
+ // `hyperbolic`(真实存在的推理服务商)都会被吞成混元。
67
+ [/\bdeepseek[\w.-]*/, 'deepseek'],
68
+ // 阿里系:模型家族(qwen / qwq / tongyi)之外补两个**平台名** ——
69
+ // `dashscope`(官方 SDK 与平台名)与 `aliyun`。中转站常把 provider 段写成它们。
70
+ [/\bqwen[\w.-]*|\bqwq[\w.-]*|\btongyi\b|\bdashscope\b|\baliyun\b|通义/, 'qwen'],
71
+ // 智谱:GLM 主名之外,官方还有一批**非 GLM 命名**的模型家族,此前整片漏命中 ——
72
+ // `charglm`(角色扮演)、`codegeex`(代码)、`cogview`(文生图)、`cogvideo`(文生视频)。
73
+ // `bigmodel`(bigmodel.cn)是智谱开放平台的官方平台名。
74
+ [/\bglm[\w.-]*|\bchatglm[\w.-]*|\bcharglm[\w.-]*|\bcodegeex[\w.-]*|\bcogview[\w.-]*|\bcogvideo[\w.-]*|\bzai\b|\bz\.ai\b|\bzhipu\b|\bbigmodel\b|智谱/, 'glm'],
75
+ [/\bkimi[\w.-]*|\bmoonshot[\w.-]*/, 'kimi'],
76
+ [/\bclaude[\w.-]*|\banthropic\b/, 'claude'],
77
+ // Google:gemini / gemma 之外,`palm-<数字>`(PaLM 2 家族)与 `bison` / `gecko`
78
+ // (其规模档位)是官方历史模型名;`vertex`(Vertex AI)是官方托管平台名。
79
+ // `palm` 刻意写成 `\bpalm[-_.]?\d` 而不是 `\bpalm[\w.-]*`:后者会把
80
+ // `palmyra-x5`(Writer 的模型家族)吞成 Google —— palm 后面跟字母时不算 Google。
81
+ [/\bgemini[\w.-]*|\bgemma[\w.-]*|\bpalm[-_.]?\d[\w.-]*|\bbison[\w.-]*|\bgecko[\w.-]*|\bgoogle\b|\bvertex\b/, 'gemini'],
82
+ [/\bgrok[\w.-]*|\bxai[\w.-]*|\bx\.ai\b/, 'grok'],
83
+ [/\bgpt[\w.-]*|\bchatgpt[\w.-]*|\bopenai\b|\bcodex[\w.-]*|\bo[1-9]\b/, 'gpt'],
84
+ [/\bhunyuan[\w.-]*|\bhy[-_.]?\d[\w.-]*|\bhy-[\w.-]+|\btencent\b|混元|腾讯/, 'hunyuan'],
85
+ // 2026-10-08:第二轮素材新增的 6 个厂商。追加在表尾,确保既有 token 的命中优先级不变。
86
+ // MiniMax 的语音(`speech-*`)与视频(`video-*`)模型没有厂商前缀,靠 provider 段命中;
87
+ // 这里补它们的模型家族名,避免中转站把 provider 段写成平台名时整队掉兜底。
88
+ [/\bminimax[\w.-]*|\bmini-max[\w.-]*|\babab[\w.-]*|\bhailuo[\w.-]*|\bspeech[-_.]\d[\w.-]*/, 'minimax'],
89
+ [/\bmeta\b|\bllama[\w.-]*/, 'meta'],
90
+ // mistral 家族逐个列名,不用 `\w*stral` 这类宽形态 —— 那会把 orchestral 之类吞进来。
91
+ [/\bmistral[\w.-]*|\bmixtral[\w.-]*|\bmagistral[\w.-]*|\bministral[\w.-]*|\bcodestral[\w.-]*|\bdevstral[\w.-]*|\bpixtral[\w.-]*|\bvoxtral[\w.-]*/, 'mistral'],
92
+ [/\brwkv[\w.-]*/, 'rwkv'],
93
+ // 字节:`byteplus`(BytePlus 海外站)与 `skylark`(火山方舟的早期模型名)是官方口径,
94
+ // 此前只认 bytedance / volcengine / volces,走这两条 provider 段会掉兜底。
95
+ [/\bseed[\w.-]*|\bdoubao[\w.-]*|\bbytedance\b|\bbyteplus\b|\bvolcengine\b|\bvolces\b|\bskylark[\w.-]*|豆包/, 'seed'],
96
+ // 百度:家族真实 ID 一律以 `ernie` 开头(`ernie-4.5-turbo` / `ernie-x1-turbo`),
97
+ // 所以前缀收紧到 `ernie` —— 旧的 `\bern` 会把 `ernest-1` / `ernestine` 判成文心一言。
98
+ [/\bernie[\w.-]*|\bwenxin[\w.-]*|\bbaidu\b|\bqianfan\b|文心|千帆/, 'ernie'],
99
+ // 2026-10-11:第三轮素材新增的 2 个厂商。追加在表尾,既有 token 的命中优先级不变。
100
+ //
101
+ // stepfun(阶跃星辰)必须认四种口径,缺一都会掉兜底:
102
+ // 1. provider 名 `stepfun`;
103
+ // 2. 数字家族 `step-<数字>` / `step_<数字>` / `step<数字>` —— 本机三条路由
104
+ // (cn-f/cline/cline-free/step-5-preview 等)的 provider 段里根本没有
105
+ // stepfun 字样,只靠第 1 条会整队掉兜底;
106
+ // 3. **字母家族** `step-<字母>`(`step-asr` / `step-tts-mini` / `step-r1-v-mini` /
107
+ // `step-video-t2v`)与 `stepaudio-*`(`stepaudio-3-realtime`)。这些官方
108
+ // ID 在 #2 的「step 后必须跟数字」口径下全部漏命中 —— 2026-10-11 第二轮补齐;
109
+ // 4. 中文「阶跃」。
110
+ // 刻意**不**写成裸 `\bstep[\w.-]*`:那会把 `stepper` / `steps` / `stepstone`
111
+ // 一类普通英文词吞成阶跃。`step` 后面必须跟分隔符(第 2、3 条)或直接跟数字。
112
+ [/\bstepfun[\w.-]*|\bstep[-_.]?\d[\w.-]*|\bstep[-_.][a-z][\w.-]*|\bstepaudio[\w.-]*|阶跃/, 'stepfun'],
113
+ // jev(TypeSafe 的 System One 模型)同理认 provider 段与模型名两处:
114
+ // `en-f/cline/typesafe` + `jev-router` 是本机真实路由,任一侧命中即可。
115
+ // `type-safe` 变体一并收进,避免中间带连字符时漏命中。
116
+ // `jev` 保留尾部边界:否则 `jevons` / `jevenile` 这类词会被误吞。
117
+ [/\bjev\b|\btypesafe\b|\btype-safe\b/, 'jev'],
118
+ // MiMo 允许分隔符或数字后缀,避免把 mimosa 等普通词当厂商。
119
+ [/\bmimo\b|\bmimo(?=[\d_.-])[\w.-]*|\bxiaomi\b|小米/, 'mimo'],
120
+ ]
121
+
122
+ /** Chinese label map for role tokens.
123
+ * Used by tests and as a reference lookup; the UI itself uses `labelKey` + `t()` for i18n.
124
+ */
125
+ export const ROLE_LABELS: Readonly<Record<string, string>> = {
126
+ engineer: '工程师',
127
+ qa: '测试与质量',
128
+ security: '安全与审计',
129
+ researcher: '调研',
130
+ designer: '设计与前端',
131
+ docs: '文档与文案',
132
+ data: '数据与分析',
133
+ operator: '运维与发布',
134
+ audio: '音频与语音',
135
+ video: '视频与动画',
136
+ 'team-lead': '队长',
137
+ }
138
+
139
+ type AgentTeamsLocaleKey = import('./locales.ts').AgentTeamsLocaleKey
140
+
141
+ /** Resolved artwork for one member. */
142
+ export interface ResolvedMemberArtwork {
143
+ /** Avatar URL, or null when neither role nor vendor is known. */
144
+ url: string | null
145
+ /** Large preview URL, or null when neither role nor vendor is known. */
146
+ full: string | null
147
+ /** Matched role token, or null when no role matched. */
148
+ role: string | null
149
+ /** Locale key for the role's Chinese label, or null when no role matched. */
150
+ labelKey: AgentTeamsLocaleKey | null
151
+ /** True when the image is the vendor-generic fallback because no role matched. */
152
+ isFallback: boolean
153
+ }
154
+
155
+ /**
156
+ * Captain artwork. The vendor-specific name is requested first, and a custom
157
+ * `team-lead-v2.png` still answers it through the host's degradation chain, so
158
+ * the captain can be themed per vendor while one plain override keeps working.
159
+ *
160
+ * It deliberately avoids the packaged slug: that URL existed before any custom
161
+ * directory did and had been served with a 24h cache, so a browser that already
162
+ * held it kept replaying the packaged whale instead of asking for the override.
163
+ * A name the browser has never seen cannot be shadowed by stale bytes.
164
+ */
165
+ export const LEAD_ART = `${ART_BASE}team-lead-deepseek-v2.png`
166
+
167
+ /** Large-preview artwork for the captain; degrades to {@link LEAD_ART}. */
168
+ export const LEAD_FULL_ART = `${ART_BASE}team-lead-deepseek-full-v2.png`
169
+
170
+ /**
171
+ * Vendor tokens that carry their own captain artwork.
172
+ *
173
+ * Derived from {@link VENDOR_ART} rather than restated, so a vendor added to
174
+ * the member table can never be requested for the captain while the host
175
+ * rejects the slug: `artworkCandidates` only serves tokens listed in the host
176
+ * half's `ARTWORK_VENDORS`, and a mismatch would 404 the captain image.
177
+ */
178
+ const KNOWN_VENDORS: ReadonlySet<string> = new Set(VENDOR_ART.map(([, vendor]) => vendor))
179
+
180
+ /** A vendor token the host will actually serve, or undefined to fall back. */
181
+ function servableVendor(vendor: string | undefined): string | undefined {
182
+ const token = vendor?.trim() ?? ''
183
+ return KNOWN_VENDORS.has(token) ? token : undefined
184
+ }
185
+
186
+ /**
187
+ * Captain artwork for a model vendor.
188
+ *
189
+ * The captain is the session's own model, so its vendor comes from the team
190
+ * snapshot's captain route rather than from a member. An unknown or missing
191
+ * vendor falls back to the packaged `team-lead-deepseek-v2.png`, which the
192
+ * host still answers — the same degradation the member artwork uses.
193
+ * @param vendor - vendor token for the captain's route, when known.
194
+ * @returns the captain avatar URL.
195
+ */
196
+ export function leadArtUrl(vendor: string | undefined): string {
197
+ const token = servableVendor(vendor)
198
+ return token === undefined ? LEAD_ART : `${ART_BASE}team-lead-${token}-v2.png`
199
+ }
200
+
201
+ /**
202
+ * Large-preview captain artwork for a model vendor.
203
+ * @param vendor - vendor token for the captain's route, when known.
204
+ * @returns the captain HD preview URL; degrades to the avatar art when absent.
205
+ */
206
+ export function leadFullArtUrl(vendor: string | undefined): string {
207
+ const token = servableVendor(vendor)
208
+ return token === undefined ? LEAD_FULL_ART : `${ART_BASE}team-lead-${token}-full-v2.png`
209
+ }
210
+
211
+ /** Status action artwork per member activity. */
212
+ export const ACTION_ART: Record<'working' | 'idle' | 'unknown', string> = {
213
+ working: `${ART_BASE}action-working-v2.png`,
214
+ idle: `${ART_BASE}action-sleeping-v2.png`,
215
+ unknown: `${ART_BASE}action-thinking-v2.png`,
216
+ }
217
+
218
+ /**
219
+ * Vendor token behind a member's model route, when this build knows it.
220
+ * @param member - a snapshot member carrying its `provider`/`model` route.
221
+ * @returns the vendor token, or undefined to keep the role artwork.
222
+ */
223
+ export function vendorSlug(
224
+ member: { readonly provider?: string; readonly model?: string } | undefined,
225
+ ): string | undefined {
226
+ if (member === undefined) return undefined
227
+ const route = `${member.provider ?? ''} ${member.model ?? ''}`.toLowerCase().trim()
228
+ if (route === '') return undefined
229
+ for (const [pattern, vendor] of VENDOR_ART) {
230
+ if (pattern.test(route)) return vendor
231
+ }
232
+ return undefined
233
+ }
234
+
235
+ /**
236
+ * Strip directory-like and file-like tokens from role text.
237
+ * Directory names (e.g. `team-site-test/`) contain `/` or `\`; file names
238
+ * (e.g. `verify.ps1`, `curl.exe`, `HTML/CSS/JS`) contain a dot-extension.
239
+ * These tokens are artifacts of the member's prompt / workspace, not role
240
+ * nouns, and must not participate in role matching.
241
+ */
242
+ function stripPathTokens(text: string): string {
243
+ return text
244
+ .split(/\s+/)
245
+ .filter((token) => !/[\/\\]/.test(token) && !/\.\w{1,6}$/.test(token))
246
+ .join(' ')
247
+ }
248
+
249
+ /**
250
+ * Role token for a member identity, or null when no role matches.
251
+ * @param name - the member's display name.
252
+ * @param role - the member's role text.
253
+ */
254
+ export function memberRoleSlug(name: string, role: string): string | null {
255
+ // Match only against the member's name and the cleaned role description;
256
+ // path/file tokens in the role text are intentionally ignored so that
257
+ // directory names and filenames do not pollute role matching.
258
+ const identity = `${name} ${stripPathTokens(role)}`.toLowerCase()
259
+ for (const [pattern, art] of ROLE_ART) {
260
+ if (pattern.test(identity)) return art
261
+ }
262
+ return null
263
+ }
264
+
265
+ /**
266
+ * Unified artwork resolver. Implements the client-side degradation chain:
267
+ * role+vendor → role → vendor → initial-letter fallback.
268
+ *
269
+ * - If a role matches, request `member-<vendor>-<role>-v2.png` (or the generic
270
+ * role image when the vendor is unknown).
271
+ * - If no role matches but the vendor is known, request the vendor-generic
272
+ * `member-<vendor>-v2.png` and mark it as a fallback.
273
+ * - If neither role nor vendor is known, return null so the caller can fall back
274
+ * to the initial-letter badge.
275
+ * @param options - member display name, role text, and optional vendor token.
276
+ */
277
+ export function resolveMemberArtwork({
278
+ name: _name,
279
+ role,
280
+ vendor,
281
+ }: {
282
+ name: string
283
+ role: string
284
+ vendor?: string
285
+ }): ResolvedMemberArtwork {
286
+ const slug = memberRoleSlug(_name, role)
287
+ if (slug !== null) {
288
+ return {
289
+ url: vendor === undefined
290
+ ? `${ART_BASE}member-${slug}-v2.png`
291
+ : `${ART_BASE}member-${vendor}-${slug}-v2.png`,
292
+ full: vendor === undefined
293
+ ? `${ART_BASE}member-${slug}-full-v2.png`
294
+ : `${ART_BASE}member-${vendor}-${slug}-full-v2.png`,
295
+ role: slug,
296
+ labelKey: `member.role.${slug}` as AgentTeamsLocaleKey,
297
+ isFallback: false,
298
+ }
299
+ }
300
+ if (vendor !== undefined) {
301
+ return {
302
+ url: `${ART_BASE}member-${vendor}-v2.png`,
303
+ full: `${ART_BASE}member-${vendor}-full-v2.png`,
304
+ role: null,
305
+ labelKey: null,
306
+ isFallback: true,
307
+ }
308
+ }
309
+ return {
310
+ url: null,
311
+ full: null,
312
+ role: null,
313
+ labelKey: null,
314
+ isFallback: false,
315
+ }
316
+ }
317
+
318
+ /** Format the caption under the enlarged member/leader artwork preview. */
319
+ export function formatArtPreviewCaption({
320
+ name,
321
+ labelKey,
322
+ kind,
323
+ t,
324
+ }: {
325
+ name: string
326
+ labelKey: AgentTeamsLocaleKey | null
327
+ kind: 'captain' | 'member'
328
+ t: import('./locales.ts').AgentTeamsTranslate
329
+ }): string {
330
+ if (kind === 'captain') return name
331
+ if (labelKey !== null) return `${name} · ${t('member.art.rolePrefix')}${t(labelKey)}`
332
+ return `${name} · ${t('member.art.fallbackLabel')}`
333
+ }
334
+
335
+ /**
336
+ * Member artwork URL, or null when no role matches (initial-letter fallback).
337
+ * @param name - the member's display name.
338
+ * @param role - the member's role text.
339
+ * @param vendor - optional vendor token from {@link vendorSlug}.
340
+ * @returns the artwork URL, or null when unmatched.
341
+ */
342
+ export function memberArtUrl(name: string, role: string, vendor?: string): string | null {
343
+ const slug = memberRoleSlug(name, role)
344
+ if (slug === null) return null
345
+ return vendor === undefined
346
+ ? `${ART_BASE}member-${slug}-v2.png`
347
+ : `${ART_BASE}member-${vendor}-${slug}-v2.png`
348
+ }
349
+
350
+ /**
351
+ * Vendor brand mark URL for the state badge, or null when the vendor is
352
+ * unknown (the badge then keeps the packaged activity art). A missing file is
353
+ * not fatal: the caller falls back on the image's error event.
354
+ * @param vendor - vendor token from {@link vendorSlug}.
355
+ */
356
+ export function brandArtUrl(vendor: string | undefined): string | null {
357
+ return vendor === undefined ? null : `${ART_BASE}brand-${vendor}.svg`
358
+ }
359
+
360
+ /**
361
+ * Large-preview artwork URL for the same member. Safe to request even when no
362
+ * `-full` file exists: the host degrades to the avatar art.
363
+ * @param name - the member's display name.
364
+ * @param role - the member's role text.
365
+ * @param vendor - optional vendor token from {@link vendorSlug}.
366
+ * @returns the large-preview URL, or null when no role matched.
367
+ */
368
+ export function memberFullArtUrl(name: string, role: string, vendor?: string): string | null {
369
+ const slug = memberRoleSlug(name, role)
370
+ if (slug === null) return null
371
+ return vendor === undefined
372
+ ? `${ART_BASE}member-${slug}-full-v2.png`
373
+ : `${ART_BASE}member-${vendor}-${slug}-full-v2.png`
374
+ }
@@ -0,0 +1,17 @@
1
+ /** Plugin-owned icons avoid depending on the host's generated design-export names. */
2
+ const stroke = { fill: 'none', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round' as const, strokeLinejoin: 'round' as const }
3
+ export function IconBranchOutline16() {
4
+ return <svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" {...stroke}><circle cx="4" cy="3" r="1.5" /><circle cx="12" cy="4" r="1.5" /><circle cx="4" cy="13" r="1.5" /><path d="M4 4.5v7M4 9h3a5 5 0 0 0 5-3.5" /></svg>
5
+ }
6
+ export function IconChevronDownOutline14() {
7
+ return <svg width="14" height="14" viewBox="0 0 14 14" aria-hidden="true" {...stroke}><path d="m3 5 4 4 4-4" /></svg>
8
+ }
9
+ export function IconPanelLeftOutline16() {
10
+ return <svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" {...stroke}><rect x="2" y="2.5" width="12" height="11" rx="2" /><path d="M6 2.5v11" /></svg>
11
+ }
12
+ export function IconStopFill16() {
13
+ return <svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><rect x="4" y="4" width="8" height="8" rx="1" fill="currentColor" /></svg>
14
+ }
15
+ export function IconWarningOutline16() {
16
+ return <svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" {...stroke}><path d="m7 2-5.5 10a1 1 0 0 0 1 1.5h11a1 1 0 0 0 1-1.5L9 2a1.1 1.1 0 0 0-2 0Z" /><path d="M8 6v3m0 2v.1" /></svg>
17
+ }
@@ -0,0 +1,140 @@
1
+ /** Browser plugin for the AgentTeams activity floater and conversation card. */
2
+
3
+ import type { Context as ClientContext } from '@deepseek-ai/cordis'
4
+ import type { SessionId } from '@deepseek-ai/dsh-session/types'
5
+ import type {} from '@deepseek-ai/dsh-api-session-controller/client'
6
+ import type {} from '@deepseek-ai/dsh-client-ui-session/client'
7
+ import type {} from '@deepseek-ai/dsh-client-ui-chat/client'
8
+ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
9
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
10
+ // Type-only: pulls the official browser locale service into ClientContext.
11
+ import type {} from '@deepseek-ai/dsh-client-locale/client'
12
+ // Conversation folding is target-neutral; keyed Chat rendering is owned by
13
+ // ui-chat, whose declaration is loaded above.
14
+ import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
15
+ // The frame-level overlay is declared by ui-layout. This import is type-only;
16
+ // ctx.slots.inject below owns the runtime wait for the declaration.
17
+ import type { UsePanelInfo } from '@deepseek-ai/dsh-client-ui-layout/client'
18
+ // Official model catalog/directory service. The staged roster reads its
19
+ // provider/model/effort metadata without mutating the captain's own selection.
20
+ import type {} from '@deepseek-ai/dsh-client-ui-model-selection/client'
21
+ import type {} from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
22
+ import { ActivitySurface, WorkspaceActivity, createWorkspaceBridge, TEAM_TAB_ID, TEAM_TAB_KIND } from './WorkspaceActivity.tsx'
23
+ import { TeamChatEntry, TeamTurnCard } from './TeamChatEntry.tsx'
24
+ import { createWorkspaceState } from './workspace-state.ts'
25
+ import { AgentTeamsCard, type AgentTeamsCardInjected } from './AgentTeamsCard.tsx'
26
+ import { agentTeamsCardDefinition } from './agent-teams-card-definition.ts'
27
+ import {
28
+ AGENT_TEAMS_LOCALE_NAMESPACE, en, zh, type AgentTeamsLocaleKey,
29
+ } from './locales.ts'
30
+ import { openAgentTeamMember, type AgentTeamsLayoutNavigator, type AgentTeamsWorkspaceNavigator } from './session-navigation.ts'
31
+
32
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
33
+ interface LocaleNamespaceMap {
34
+ /** AgentTeams conversation card and activity monitor copy. */
35
+ agentTeams: AgentTeamsLocaleKey
36
+ }
37
+ }
38
+
39
+ /** Required services: conversation nodes, slots, sessions navigation, and locale. */
40
+ export const inject = ['uiConversation', 'slots', 'sessions', 'locale', 'modelDirectories', 'layout']
41
+
42
+ /** The host supplies this hook for the lifetime of a 0.1.5 root slot. */
43
+ interface PanelNavigationProps {
44
+ usePanelInfo?: UsePanelInfo
45
+ }
46
+ const useLegacyPanelInfo: UsePanelInfo = select => select({ activePanelId: null })
47
+
48
+ /** The replayed user message is the canonical transcript entry. */
49
+ function HiddenAgentTeamsCommand(): null {
50
+ return null
51
+ }
52
+
53
+ /**
54
+ * Register the activity monitor in the shell's additive overlay and the
55
+ * in-conversation team card. The card's activity button re-opens a folded
56
+ * monitor via a window event — the recovery path for an old session.
57
+ */
58
+ export function apply(ctx: ClientContext): void {
59
+ const bridge = createWorkspaceBridge()
60
+ const state = createWorkspaceState()
61
+ ctx.effect(
62
+ () => ctx.locale.register(AGENT_TEAMS_LOCALE_NAMESPACE, { zh, en }),
63
+ 'agent-teams: dictionaries',
64
+ )
65
+
66
+ const openMember = (parentId: SessionId, childId: SessionId): void => {
67
+ void openAgentTeamMember(ctx.sessions, parentId, childId, ctx.layout as AgentTeamsLayoutNavigator, ctx.get('uiWorkspace') as AgentTeamsWorkspaceNavigator | undefined).catch((error: unknown) => {
68
+ console.warn(`agent-teams: failed to open member transcript ${childId}: ${String(error)}`)
69
+ })
70
+ }
71
+ const Panel = ({ t, usePanelInfo }: PropsLocale<'agentTeams'> & PanelNavigationProps) => {
72
+ // A host's standard hook set is fixed for this mounted plugin instance.
73
+ const usePanel = usePanelInfo ?? useLegacyPanelInfo
74
+ const conversationVisible = usePanel(panel => panel.activePanelId === null)
75
+ return (
76
+ <ActivitySurface
77
+ bridge={bridge}
78
+ state={state}
79
+ conversationVisible={conversationVisible}
80
+ sessionsList={ctx.sessions.list}
81
+ modelDirectories={ctx.modelDirectories}
82
+ openMember={openMember}
83
+ t={t}
84
+ />
85
+ )
86
+ }
87
+ // Optional service scope keeps legacy hosts working and removes every native
88
+ // contribution when the host provider disappears (including HMR).
89
+ ctx.inject(['sidebarRight', 'sidebarRightTabs'], (native) => {
90
+ const t = native.locale.bind(AGENT_TEAMS_LOCALE_NAMESPACE)
91
+ native.effect(() => native.sidebarRightTabs.register({
92
+ id: TEAM_TAB_ID, kind: TEAM_TAB_KIND,
93
+ title: () => t('workspace.title'),
94
+ }))
95
+ native.slots.inject('conversation.session.header.actions', () => native.slots.register({
96
+ name: 'conversation.session.header.actions', id: 'agent-teams-entry', order: 50,
97
+ locale: AGENT_TEAMS_LOCALE_NAMESPACE,
98
+ }, TeamChatEntry))
99
+ native.slots.inject('conversation.chat.turnTail', () => native.slots.register({
100
+ name: 'conversation.chat.turnTail', id: 'agent-teams-summary', order: 50,
101
+ locale: AGENT_TEAMS_LOCALE_NAMESPACE,
102
+ inject: () => ({ openMember }),
103
+ }, TeamTurnCard))
104
+ native.slots.inject('sidebar.right.pane.tab', () => {
105
+ const dispose = native.slots.register({
106
+ name: 'sidebar.right.pane.tab', key: TEAM_TAB_ID,
107
+ locale: AGENT_TEAMS_LOCALE_NAMESPACE,
108
+ inject: () => ({ state, modelDirectories: native.modelDirectories, openMember }),
109
+ }, WorkspaceActivity)
110
+ bridge.set(native.sidebarRight)
111
+ return () => { bridge.set(undefined); dispose() }
112
+ })
113
+ })
114
+
115
+ ctx.slots.inject('shell.overlay', () => ctx.slots.register({
116
+ name: 'shell.overlay',
117
+ id: 'agent-teams-activity',
118
+ order: 80,
119
+ label: 'AgentTeams activity',
120
+ locale: AGENT_TEAMS_LOCALE_NAMESPACE,
121
+ }, Panel))
122
+
123
+ // The host command is only the slash-menu/admission surface. Its input is
124
+ // replayed as the visible user message, so the generic result row would be
125
+ // a duplicate placed before that message by command lifecycle ordering.
126
+ ctx.slots.inject('conversation.chat.commandview', () => ctx.slots.register({
127
+ name: 'conversation.chat.commandview',
128
+ key: 'agent-teams',
129
+ }, HiddenAgentTeamsCommand))
130
+
131
+ ctx.uiConversation.events.register(agentTeamsCardDefinition)
132
+ ctx.slots.inject('conversation.chat.node', () => ctx.slots.register({
133
+ name: 'conversation.chat.node',
134
+ key: 'agent-teams',
135
+ locale: AGENT_TEAMS_LOCALE_NAMESPACE,
136
+ inject: (): AgentTeamsCardInjected => ({
137
+ openMember, workspaceBridge: bridge,
138
+ }),
139
+ }, AgentTeamsCard))
140
+ }