@suifei/dsh-ai-team 0.4.133 → 0.4.135

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 (54) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +55 -3
  3. package/client.js +104 -11
  4. package/index.js +11 -0
  5. package/lib/domain/avatar.js +47 -0
  6. package/lib/domain/catalog.js +8 -2
  7. package/lib/host/default-roster.js +1 -0
  8. package/lib/host/service.js +19 -3
  9. package/lib/ledger/fold.js +10 -0
  10. package/package.json +2 -1
  11. package/talents/algo-reimplementer/talent.yml +2 -1
  12. package/talents/analyst/talent.yml +2 -1
  13. package/talents/architect/talent.yml +2 -1
  14. package/talents/binary-analyst/talent.yml +2 -1
  15. package/talents/biz-analyst/talent.yml +2 -1
  16. package/talents/code-reviewer/talent.yml +2 -1
  17. package/talents/content-author/talent.yml +2 -1
  18. package/talents/content-strategist/talent.yml +2 -1
  19. package/talents/copywriter/talent.yml +2 -1
  20. package/talents/creative-director/talent.yml +2 -1
  21. package/talents/curriculum-designer/talent.yml +2 -1
  22. package/talents/data-analyst/talent.yml +2 -1
  23. package/talents/deobfuscator/talent.yml +2 -1
  24. package/talents/diagrammer/talent.yml +2 -1
  25. package/talents/dynamic-debugger/talent.yml +2 -1
  26. package/talents/editor/talent.yml +2 -1
  27. package/talents/editorial-lead/talent.yml +2 -1
  28. package/talents/education-lead/talent.yml +2 -1
  29. package/talents/engineer/talent.yml +2 -1
  30. package/talents/executor/talent.yml +2 -1
  31. package/talents/experiment-designer/talent.yml +2 -1
  32. package/talents/fact-checker/talent.yml +2 -1
  33. package/talents/game-artist/talent.yml +2 -1
  34. package/talents/game-designer/talent.yml +2 -1
  35. package/talents/game-director/talent.yml +2 -1
  36. package/talents/game-tester/talent.yml +2 -1
  37. package/talents/gameplay-programmer/talent.yml +2 -1
  38. package/talents/mobile-re/talent.yml +2 -1
  39. package/talents/paper-writer/talent.yml +2 -1
  40. package/talents/peer-reviewer/talent.yml +2 -1
  41. package/talents/pmo-lead/talent.yml +2 -1
  42. package/talents/principal-investigator/talent.yml +2 -1
  43. package/talents/qa-acceptor/talent.yml +2 -1
  44. package/talents/re-lead/talent.yml +2 -1
  45. package/talents/re-verifier/talent.yml +2 -1
  46. package/talents/research-lead/talent.yml +2 -1
  47. package/talents/researcher/talent.yml +2 -1
  48. package/talents/scriptwriter/talent.yml +2 -1
  49. package/talents/security-auditor/talent.yml +2 -1
  50. package/talents/seo-specialist/talent.yml +2 -1
  51. package/talents/storyboard-artist/talent.yml +2 -1
  52. package/talents/tech-writer/talent.yml +2 -1
  53. package/talents/ux-designer/talent.yml +2 -1
  54. package/talents/video-editor/talent.yml +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.135 - 2026-11-18
4
+
5
+ **头像:人才市场、团队、成员卡片都有头像(@suifei/hash-avatar,本机生成)**
6
+
7
+ - 头像由插件依赖 [`@suifei/hash-avatar`](https://www.npmjs.com/package/@suifei/hash-avatar)(契约 v1)在本机按名字画,经 `GET /ai-team/api/avatar.svg` 出 SVG,不连外网;与 [avatar.onrpc.com](https://avatar.onrpc.com/) 同参同图(实测逐字节一致)。参数是性别 / 年龄 / 人种。人才和按原名招来的成员是同一张脸;改名换脸,参数不变。显示不到 64px 时去掉外圈指纹。图片加载失败时退回首字母。
8
+ - **44 位内置人才都预置了头像参数**,默认亚洲人;负责人多为中年,执行、验收多为青年,性别按名字分配。`talent.yml` 新增可选字段 `avatar: { gender, age, race }`,取值 `male|female|neutral`、`baby|teen|youth|middle|old`、`asian|white|black|brown|auto`;写错的人才文件按 `catalog.load.fail` 跳过。内置人才版本各升一个小版本,盖过在线库 1.0.0 的旧副本。
9
+ - **出现头像的地方**:人才市场卡片、新建项目的团队成员卡片、组队的人才列表与已选成员、左栏成员、消息、人员池卡片、批量配置模型、成员资料标题。
10
+ - **自定义可选**:添加成员 · 自定义、新建人才、成员资料 · 资料页有头像挑选(性别 / 年龄 / 人种,左边实时预览)。招聘时带上人才的头像,复制成员带上原成员的,存为人才带上成员的。
11
+ - 账本:`project/member-added`、`member/profile-updated` 可带 `avatar`;`member.profile.update` 允许只改头像,写错的值返回 `E_INVALID_ARGUMENT`。没设过头像的老成员按来源人才的参数画。
12
+ - 测试:`test/avatar.test.js`(参数校验、内置人才全带头像、自建人才 / 存为人才、账本、服务层命令、本机渲染与 `avatar.svg` 路由);全量 435。实机截图核对(`.ptc/rounds/r54-steps.json`,`shots-r54/`),宿主页面里头像图片实际加载成功。
13
+
14
+ ## 0.4.134 - 2026-11-18
15
+
16
+ **README:最近更新**
17
+
18
+ - README 增加「最近更新」:人才市场、主理人只调度交付、在线人才库、弹窗与人员池,配人才市场与新建项目截图;补成员资料页签、人员池批量配置模型的说明。npm 页面同步显示。代码无改动。
19
+
3
20
  ## 0.4.133 - 2026-11-18
4
21
 
5
22
  **弹窗排版补丁:页签不再被文字盖住、自定义 / 资料 / 组队 / 批量配置模型排版**
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  <a href="https://www.npmjs.com/package/@suifei/dsh-ai-team"><img alt="npm" src="https://img.shields.io/npm/v/@suifei/dsh-ai-team?color=2f6feb&label=npm"></a>
13
13
  <a href="https://github.com/suifei/dsh-ai-team/releases"><img alt="release" src="https://img.shields.io/github/v/release/suifei/dsh-ai-team?color=2f6feb"></a>
14
14
  <a href="./LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-2f6feb"></a>
15
- <img alt="tests" src="https://img.shields.io/badge/tests-82%20passing-2ea043">
15
+ <img alt="tests" src="https://img.shields.io/badge/tests-435%20passing-2ea043">
16
16
  <img alt="dsh" src="https://img.shields.io/badge/DeepSeek%20Harness-plugin-6f42c1">
17
17
  </p>
18
18
 
@@ -25,9 +25,60 @@
25
25
 
26
26
  主理人只调度交付:产出只交给对应角色,主理人不看、不核对成果内容,只问负责人做全没有——没做全催继续,做全了交给下一位;内容对不对由验收人把关,主理人不能验收或退回别人的产出。
27
27
 
28
+ ## 最近更新
29
+
30
+ - **人才市场**(0.4.124–0.4.129):9 个内置团队、44 位内置人才,各自带看家技能。可以招聘、复制为可编辑、自建人才并装技能,也能把项目成员「存为人才」;新建项目时选团队,或从人才里挑人组新团队。
31
+ - **主理人只调度交付**(0.4.128):主理人不看产出,只问负责人做全没有;内容由验收人把关。
32
+ - **在线人才库**(0.4.130–0.4.131):「同步在线库」从 [`@suifei/dsh-ai-team-catalog`](https://www.npmjs.com/package/@suifei/dsh-ai-team-catalog) 拉取最新的人才与团队。国内走 npmmirror 整包下载,约 1 秒同步完;逐个文件核对 sha256,失败不影响旧版本,可一键退回内置。
33
+ - **头像**(0.4.135):人才市场、团队、成员卡片都有头像,由 [`@suifei/hash-avatar`](https://www.npmjs.com/package/@suifei/hash-avatar) 在本机按名字生成(与 [avatar.onrpc.com](https://avatar.onrpc.com/) 同图,不连外网);内置人才预置了参数(默认亚洲人),自定义成员和人才可以选性别、年龄、人种。
34
+ - **弹窗与人员池**(0.4.132–0.4.133):
35
+ - 弹窗占主页面的 90%,功能按钮固定在右上角。
36
+ - 成员资料按「资料 / 模型 / 技能 / 协作」分页签。
37
+ - 新建项目时展示团队成员卡片;组队是三栏:人才列表 → 简介 → 已选成员。
38
+ - 人员池是成员卡片,可以一次给多位成员批量配置模型。
39
+
40
+ <p align="center">
41
+ <img src="https://github.com/suifei/dsh-ai-team/releases/download/v0.4.133/talent-market-online.png" width="860" alt="人才市场:同步在线库后按分类筛选" /><br/>
42
+ <sub>人才市场:同步在线库后按分类挑人</sub>
43
+ </p>
44
+
45
+ <p align="center">
46
+ <img src="https://github.com/suifei/dsh-ai-team/releases/download/v0.4.133/new-project-team-cards.png" width="860" alt="新建项目:选团队后展示成员卡片" /><br/>
47
+ <sub>新建项目:选团队后右侧展示每位成员的卡片</sub>
48
+ </p>
49
+
50
+ 完整记录见 [CHANGELOG](./CHANGELOG.md)。
51
+
52
+ ### 顺带做了个头像库:hash-avatar
53
+
54
+ 为了让人才市场里的每位人才都有一张自己的脸,我们另做了一个开源库 **[`@suifei/hash-avatar`](https://www.npmjs.com/package/@suifei/hash-avatar)**([GitHub](https://github.com/suifei/hash-avatar))。文渊阁的头像就是它在本机生成的。
55
+
56
+ <p align="center">
57
+ <img src="https://avatar.onrpc.com/v1/%E5%A2%A8%E6%B8%8A.svg?gender=male&age=middle&race=asian&size=96" width="72" alt="墨渊" />
58
+ <img src="https://avatar.onrpc.com/v1/%E9%9D%92%E5%B2%9A.svg?gender=female&age=youth&race=asian&size=96" width="72" alt="青岚" />
59
+ <img src="https://avatar.onrpc.com/v1/%E7%99%BD%E7%A0%9A.svg?gender=female&age=youth&race=asian&size=96" width="72" alt="白砚" />
60
+ <img src="https://avatar.onrpc.com/v1/%E7%8E%84%E7%AD%96.svg?gender=male&age=youth&race=asian&size=96" width="72" alt="玄策" />
61
+ <img src="https://avatar.onrpc.com/v1/%E7%9F%A5%E5%BE%AE.svg?gender=female&age=youth&race=asian&size=96" width="72" alt="知微" />
62
+ <img src="https://avatar.onrpc.com/v1/%E8%A7%82%E6%BE%9C.svg?gender=female&age=youth&race=asian&size=96" width="72" alt="观澜" />
63
+ </p>
64
+
65
+ - **由名字或 email 确定**:输入经 SHA-256 决定五官、发型和配色;同一个名字永远是同一张脸。外圈 128 个刻度画出哈希的前 128 位,两个不同输入撞上同一张图的概率低于 UUIDv4 撞车。
66
+ - **性别、年龄、人种只是渲染参数**,不进哈希,所以换参数后还是认得出同一个人:`gender=male|female|neutral`、`age=baby|teen|youth|middle|old`、`race=asian|white|black|brown|auto`。
67
+ - **零依赖、同步、浏览器和 Node 都能用**,一张约 0.1 ms、约 6 KB 的 SVG;Apache-2.0。
68
+ - **不写代码也能用**:`https://avatar.onrpc.com/<名字>.svg?gender=female&age=youth&race=asian` 直接当图片地址。
69
+
70
+ ```sh
71
+ npm i @suifei/hash-avatar
72
+ ```
73
+
74
+ ```js
75
+ const HashAvatar = require('@suifei/hash-avatar');
76
+ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asian', size: 128 });
77
+ ```
78
+
28
79
  **人才市场**:成员来自可复用的「人才」,团队从人才里挑人组队。
29
80
 
30
- - 人才 `talents/<人才>/talent.yml`:名字、岗位、`duty`(职责:`lead` 主理人 / `qa` 验收 / `executor` 执行,决定拿哪份岗位规程)、性格、分类与标签、推荐模型,以及自带技能(`talents/<人才>/skills/<技能>/SKILL.md`)。内置 10 位:默认团队的 6 位,外加架构、评审、技术文档、安全审计。
81
+ - 人才 `talents/<人才>/talent.yml`:名字、岗位、`duty`(职责:`lead` 主理人 / `qa` 验收 / `executor` 执行,决定拿哪份岗位规程)、头像参数 `avatar: { gender, age, race }`、性格、分类与标签、推荐模型,以及自带技能(`talents/<人才>/skills/<技能>/SKILL.md`)。内置 10 位:默认团队的 6 位,外加架构、评审、技术文档、安全审计。
31
82
  - 团队 `teams/<团队>/team.yml`:只引用人才(可覆盖名字、岗位、性格,追加技能),`skills/` 放这个团队的三份岗位规程(`ai-team-core` / `ai-team-qa` / `ai-team-executor`),`procedures` 可换成自己的规程。内置默认团队见 [`teams/default/`](teams/default/)。还预置了**逆向工程队** [`teams/reverse/`](teams/reverse/):静态分析、动态调试、OLLVM 去混淆、移动端逆向、算法复刻与行为对账(`teamPreset: reverse` 启用)。此外预置了文档(`docs`)、视频(`video`)、游戏(`game`)、自媒体写作(`content`)、深度研究(`research`)、科学研究(`science`)、中小学教育软件(`education`)等团队,共 44 位人才可在人才市场挑选、组合或自建。
32
83
  - 「人员 → 添加成员」先打开人才市场:按分类、关键词挑一位,点「招聘」预填表单,改名、换模型后创建;也可以切到「自定义」从零填写。
33
84
  - 自建:人才放 `~/.dsh/ai-team/catalog/user/talents/<人才>/`,团队放 `~/.dsh/ai-team/catalog/user/teams/<团队>/`,同名覆盖内置;插件设置 `teamPreset` 选新项目用哪个团队。
@@ -106,7 +157,8 @@ dsh --profile ai-team --no-open --port 33271
106
157
  - **收件箱**:跨 Project 聚合;顶部「待你处理 · N」一键进入;只放真正需要 Human 的决策/失败,Agent 的进度汇报留在 Thread/动态,不制造“打开 Task 后无事可做”。
107
158
  - **直接对话**:点击成员名字直接打开该 Agent 的 DSH 原生 Session;没有 session 会先激活;打不开时落到成员资料,资料里有「直接对话」按钮。
108
159
  - **成员任务**:成员资料里点「他的任务」,查看他 owner/assignee 的 Task。
109
- - **成员资料**:点「⋯」改名、职责、personality、provider/model、运行配方、notes、skills、re-distill、离队/人才库。
160
+ - **成员资料**:点「⋯」打开,按「资料 / 模型 / 技能 / 协作」分页签:改名、职责、个性、备忘;运行配方、提供商 / 模型 / 推理等级;技能与「进化」;交接人与私信。右上角是他的任务、直接对话、复制成员、存为人才、重置会话、重新蒸馏、离开团队。
161
+ - **人员池**:按人汇总各项目里的成员卡片(负载、所在项目、跳转);「批量配置模型」一次给勾选的成员在其所在的全部项目设同一模型,卡片上的「配置模型」只改这一位。
110
162
 
111
163
  ---
112
164
 
package/client.js CHANGED
@@ -308,6 +308,8 @@ window.__ModuleLoader__.load({
308
308
  talentLoadFailed: '人才市场读取失败:{error}',
309
309
  talentSkills: '技能:{skills}',
310
310
  talentUser: '自建',
311
+ avatarTitle: '头像', avatarGender: '性别', avatarAge: '年龄', avatarRace: '人种', avatarHint: '头像按名字在本机生成(hash-avatar);改名会换一张脸,参数不变。',
312
+ avatar_male: '男', avatar_female: '女', avatar_neutral: '中性', avatar_baby: '婴儿', avatar_teen: '少年', avatar_youth: '青年', avatar_middle: '中年', avatar_old: '老年', avatar_asian: '黄种人', avatar_white: '白人', avatar_black: '黑人', avatar_brown: '棕色人种', avatar_auto: '不指定',
311
313
  profileTabBasic: '资料', profileTabModel: '模型', profileTabSkills: '技能', profileTabCollab: '协作', profileNotes: '备忘', profileNotesEmpty: '还没有备忘。', profileSkillsEmpty: '还没装技能;在下面填技能名加一个,或到人才市场招已带技能的人才。',
312
314
  teamPickDetail: '人才简介', teamPickDetailEmpty: '在左边点一位人才,这里看简介;点「加入」放进右边的团队。', teamLeadMark: '负责人', projectTeamMembers: '团队成员 · {n} 位',
313
315
  peopleModelBatch: '批量配置模型', peopleModelTitle: '配置模型', peopleModelHint: '选中的成员在其所在的全部项目里改用这个模型;之后仍可在成员资料里单独改。', peopleModelPick: '应用到 {n} 位', peopleModelAll: '全选', peopleModelNone: '全不选', peopleModelApply: '应用', peopleModelNeed: '先选模型', peopleModelDone: '已为 {people} 位成员配置 {model}(成功 {done} 处,失败 {failed} 处)。',
@@ -762,6 +764,8 @@ window.__ModuleLoader__.load({
762
764
  talentLoadFailed: 'Could not load the talent market: {error}',
763
765
  talentSkills: 'Skills: {skills}',
764
766
  talentUser: 'Custom',
767
+ avatarTitle: 'Avatar', avatarGender: 'Gender', avatarAge: 'Age', avatarRace: 'Ethnicity', avatarHint: 'Drawn locally from the name (hash-avatar); renaming gives a new face with the same settings.',
768
+ avatar_male: 'Male', avatar_female: 'Female', avatar_neutral: 'Neutral', avatar_baby: 'Baby', avatar_teen: 'Teen', avatar_youth: 'Young', avatar_middle: 'Middle-aged', avatar_old: 'Senior', avatar_asian: 'Asian', avatar_white: 'White', avatar_black: 'Black', avatar_brown: 'Brown', avatar_auto: 'Any',
765
769
  profileTabBasic: 'Profile', profileTabModel: 'Model', profileTabSkills: 'Skills', profileTabCollab: 'Collaboration', profileNotes: 'Notes', profileNotesEmpty: 'No notes yet.', profileSkillsEmpty: 'No skills yet; add one by name below, or hire a talent that comes with skills.',
766
770
  teamPickDetail: 'Talent details', teamPickDetailEmpty: 'Pick a talent on the left to see its details; “Add” puts it into the team on the right.', teamLeadMark: 'Lead', projectTeamMembers: 'Team members · {n}',
767
771
  peopleModelBatch: 'Set model for many', peopleModelTitle: 'Set model', peopleModelHint: 'The selected members switch to this model in every project they are in; each can still be changed in its profile.', peopleModelPick: 'Apply to {n}', peopleModelAll: 'All', peopleModelNone: 'None', peopleModelApply: 'Apply', peopleModelNeed: 'Pick a model first', peopleModelDone: 'Set {model} for {people} members ({done} ok, {failed} failed).',
@@ -1197,6 +1201,14 @@ window.__ModuleLoader__.load({
1197
1201
  .at-streamjump:hover { color: var(--dsw-alias-label-primary); }
1198
1202
  .at-msg { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
1199
1203
  .at-avatar { flex: 0 0 auto; width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--dsw-alias-border-l2); border-radius: 999px; background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-secondary); font-size: 10px; font-weight: 500; }
1204
+ .at-avatar.at-avatar-img { overflow: hidden; border-color: transparent; background: transparent; padding: 0; }
1205
+ .at-avatar.at-avatar-img img { display: block; width: 100%; height: 100%; border-radius: 999px; }
1206
+ .at-talenttop { display: flex; align-items: center; gap: 10px; min-width: 0; }
1207
+ .at-talenttop > .at-talenthead { flex: 1 1 auto; min-width: 0; }
1208
+ .at-avatarpick { display: flex; align-items: center; gap: 16px; padding: 10px 12px; border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; background: var(--dsw-alias-bg-layer-1); }
1209
+ .at-avatarpickrows { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
1210
+ .at-avatarpickrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
1211
+ .at-avatarpickrow > .at-panetitle { width: 36px; flex: none; }
1200
1212
  .at-avatar-human { border-color: transparent; background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-inverted); }
1201
1213
  .at-msgb { min-width: 0; flex: 1; }
1202
1214
  .at-msgh { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }
@@ -1456,7 +1468,7 @@ window.__ModuleLoader__.load({
1456
1468
  .at-tcpick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
1457
1469
  .at-tcpanel { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
1458
1470
  .at-teamrows { display: flex; flex-direction: column; gap: 6px; }
1459
- .at-teamrow { display: grid; grid-template-columns: minmax(0, 1fr) 76px auto auto; gap: 8px; align-items: center; }
1471
+ .at-teamrow { display: grid; grid-template-columns: 24px minmax(0, 1fr) 76px auto auto; gap: 8px; align-items: center; }
1460
1472
  .at-teamrow > .at-modalmeta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1461
1473
  .at-teamlead { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
1462
1474
  .at-teampick { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
@@ -1641,8 +1653,35 @@ window.__ModuleLoader__.load({
1641
1653
  h('span', null, label));
1642
1654
  }
1643
1655
 
1644
- function Avatar({ name, human }) {
1645
- return h('span', { className: cx('at-avatar', human && 'at-avatar-human'), 'aria-hidden': 'true' }, String(name ?? '?').slice(0, 1));
1656
+ /**
1657
+ * 头像:成员 / 人才按名字由插件本机画(/ai-team/api/avatar.svg,参数见 lib/domain/avatar.js),Human 用首字母。
1658
+ * 只给名字时按当前项目成员表(AVATAR_INDEX)找参数;图片加载失败时退回首字母。
1659
+ */
1660
+ function Avatar({ name, human, avatar, seed, size = 24 }) {
1661
+ const [brokenUrl, setBrokenUrl] = React.useState('');
1662
+ const label = String(name ?? '?');
1663
+ const style = size === 24 ? undefined : { width: size + 'px', height: size + 'px', fontSize: Math.round(size * 0.45) + 'px' };
1664
+ const known = human ? null : AVATAR_INDEX.get(label);
1665
+ const url = human ? '' : avatarUrl(seed ?? known?.seed ?? avatarSeed(label), avatar ?? known?.avatar ?? AVATAR_FALLBACK, size);
1666
+ if (human || url === brokenUrl) return h('span', { className: cx('at-avatar', human && 'at-avatar-human'), style, 'aria-hidden': 'true' }, label.slice(0, 1));
1667
+ return h('span', { className: 'at-avatar at-avatar-img', style, 'aria-hidden': 'true' },
1668
+ h('img', { src: url, alt: '', loading: 'lazy', decoding: 'async', referrerPolicy: 'no-referrer', onError: () => setBrokenUrl(url) }));
1669
+ }
1670
+ /** 头像参数挑选(性别 / 年龄 / 人种),左边实时预览。人才新建、自定义成员、成员资料共用。 */
1671
+ function AvatarPicker({ t, value, seed, onChange }) {
1672
+ const current = { ...AVATAR_PICK_DEFAULT, ...(value || {}) };
1673
+ return h('div', { className: 'at-avatarpick' },
1674
+ h(Avatar, { name: seed, seed, avatar: current, size: 72 }),
1675
+ h('div', { className: 'at-avatarpickrows' },
1676
+ [['gender', 'avatarGender'], ['age', 'avatarAge'], ['race', 'avatarRace']].map(([key, label]) => h('div', { key, className: 'at-avatarpickrow' },
1677
+ h('span', { className: 'at-panetitle' }, t(label)),
1678
+ h('div', { className: 'at-mode at-addtabs', role: 'group', 'aria-label': t(label) }, AVATAR_CHOICES[key].map((option) => h('button', {
1679
+ key: option,
1680
+ type: 'button',
1681
+ 'aria-pressed': current[key] === option ? 'true' : 'false',
1682
+ onClick: () => onChange({ ...current, [key]: option }),
1683
+ }, t('avatar_' + option)))))),
1684
+ h('div', { className: 'at-modalmeta' }, t('avatarHint'))));
1646
1685
  }
1647
1686
 
1648
1687
  function FollowToggle({ t, taskNo: no, following, onToggle, compact }) {
@@ -2029,6 +2068,7 @@ window.__ModuleLoader__.load({
2029
2068
  const failure = agent.status === 'failed' ? (agent.lastFailure ?? null) : null;
2030
2069
  return h('div', { className: 'at-agent', role: 'listitem' },
2031
2070
  h('span', { className: 'at-dot at-dot-' + (agent.status ?? 'idle'), 'aria-hidden': 'true' }),
2071
+ h(Avatar, { name: agent.name, size: 30 }),
2032
2072
  h('div', { className: 'at-agentmeta' },
2033
2073
  h('button', { className: 'at-agentname', type: 'button', onClick: () => onAgent(agent), title: agent.name }, agent.name),
2034
2074
  h('div', { className: 'at-agentrole', title: agent.role ?? '' },
@@ -2172,7 +2212,7 @@ window.__ModuleLoader__.load({
2172
2212
  h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: () => setPicked(new Set()) }, t('peopleModelNone'))),
2173
2213
  h('div', { className: 'at-peoplecheck' }, people.map((person) => h('label', { key: person.name, className: 'at-checkcard' },
2174
2214
  h('input', { type: 'checkbox', checked: picked.has(person.name), onChange: () => toggle(person.name) }),
2175
- h(Avatar, { name: person.name, human: false }),
2215
+ h(Avatar, { name: person.name, human: false, size: 32 }),
2176
2216
  h('span', null, h('b', null, person.name + (person.role ? ' · ' + person.role : '')),
2177
2217
  h('small', null, (person.projects ?? []).map((row) => row.projectName).join('、')))))))));
2178
2218
  }
@@ -2218,7 +2258,7 @@ window.__ModuleLoader__.load({
2218
2258
  const localHere = localNames.has(person.name);
2219
2259
  return h('div', { key: person.name, className: cx('at-pcard', person.failures > 0 && 'at-people-failed') },
2220
2260
  h('div', { className: 'at-pcardhead' },
2221
- h(Avatar, { name: person.name, human: false }),
2261
+ h(Avatar, { name: person.name, human: false, size: 40 }),
2222
2262
  h('span', { className: 'at-peoplename' }, person.name),
2223
2263
  person.role ? h('span', { className: 'at-people-role' }, person.role) : null),
2224
2264
  h('div', { className: 'at-peoplebadges' }, badges.join(' · ')),
@@ -2836,12 +2876,14 @@ window.__ModuleLoader__.load({
2836
2876
  : talent.source === 'user' ? withIco('user', t('talentUser'), 10)
2837
2877
  : talent.source === 'official' ? withIco('cloud', t('talentOfficial'), 10) : null;
2838
2878
  return [
2839
- h('div', { key: 'head', className: 'at-talenthead' },
2879
+ h('div', { key: 'head', className: 'at-talenttop' },
2880
+ h(Avatar, { name: talent.name, seed: avatarSeed(talent.name), avatar: talent.avatar ?? AVATAR_FALLBACK, size: 40 }),
2881
+ h('div', { className: 'at-talenthead' },
2840
2882
  h('span', { className: 'at-talentname' }, talent.name),
2841
2883
  talent.role ? h('span', { className: 'at-talentrole' }, talent.role) : null,
2842
2884
  talent.duty ? h('span', { className: 'at-talentduty' }, t(DUTY_LABEL[talent.duty])) : null,
2843
2885
  lead ? h('span', { className: 'at-talentduty' }, withIco('check', t('teamLeadMark'), 10)) : null,
2844
- badge ? h('span', { className: 'at-talentduty' }, badge) : null),
2886
+ badge ? h('span', { className: 'at-talentduty' }, badge) : null)),
2845
2887
  talent.description ? h('div', { key: 'desc', className: 'at-talentdesc' }, talent.description) : null,
2846
2888
  full && talent.personality ? h('div', { key: 'pers', className: 'at-modalmeta' }, talent.personality) : null,
2847
2889
  talent.skills?.length ? h('div', { key: 'skills', className: 'at-modalmeta' }, tf(t, 'talentSkills', { skills: talent.skills.join('、') })) : null,
@@ -2956,6 +2998,8 @@ window.__ModuleLoader__.load({
2956
2998
  h('label', { className: 'at-field' }, h('span', null, t('tcDuty')), h('select', { value: form.duty, onChange: set('duty') }, ['executor', 'qa', 'lead'].map((d) => h('option', { key: d, value: d }, t(DUTY_LABEL[d]))))),
2957
2999
  h('label', { className: 'at-field' }, h('span', null, t('tcCategory')), h('input', { value: form.category, onChange: set('category') })),
2958
3000
  h('label', { className: 'at-field' }, h('span', null, t('tcTags')), h('input', { value: form.tags, onChange: set('tags'), placeholder: t('tcTagsHint') }))),
3001
+ h('div', { className: 'at-field' }, h('span', null, t('avatarTitle')),
3002
+ h(AvatarPicker, { t, value: form.avatar, seed: avatarSeed(form.name), onChange: (avatar) => setForm((prev) => ({ ...prev, avatar })) })),
2959
3003
  h('label', { className: 'at-field' }, h('span', null, t('tcPersonality')), h('textarea', { value: form.personality, onChange: set('personality'), placeholder: t('tcPersonalityHint') })),
2960
3004
  h('div', { className: 'at-field' }, h('span', null, t('tcSkills')),
2961
3005
  pending.length === 0 ? h('div', { className: 'at-modalmeta' }, t('tcEmpty')) : h('div', { className: 'at-tcskills' }, pending.map((sk) => h('span', { key: sk.name, className: 'at-tcskill' }, sk.name, h('button', { type: 'button', 'aria-label': t('tcRemove'), onClick: () => setPending((pp) => pp.filter((x) => x.name !== sk.name)) }, '×')))),
@@ -3019,7 +3063,7 @@ window.__ModuleLoader__.load({
3019
3063
  'aria-selected': focused && focused.id === talent.id ? 'true' : 'false',
3020
3064
  onClick: () => setFocus(talent.id),
3021
3065
  onDoubleClick: () => add(talent),
3022
- }, h('span', null, talent.name, ' ', h('span', { className: 'at-pickrole' }, talent.role)), talent.duty ? h('span', { className: 'at-pickrole' }, t(DUTY_LABEL[talent.duty])) : null)))),
3066
+ }, h('span', { className: 'at-talenttop' }, h(Avatar, { name: talent.name, seed: avatarSeed(talent.name), avatar: talent.avatar, size: 22 }), h('span', null, talent.name, ' ', h('span', { className: 'at-pickrole' }, talent.role))), talent.duty ? h('span', { className: 'at-pickrole' }, t(DUTY_LABEL[talent.duty])) : null)))),
3023
3067
  h('div', { className: 'at-pane' },
3024
3068
  h('div', { className: 'at-panetitle' }, t('teamPickDetail')),
3025
3069
  focused ? h('div', { className: 'at-talent' },
@@ -3033,6 +3077,7 @@ window.__ModuleLoader__.load({
3033
3077
  draft.members.length === 0 ? h('div', { className: 'at-modalmeta' }, t('teamEmptyPick')) : h('div', { className: 'at-teamrows' }, draft.members.map((m, i) => {
3034
3078
  const talent = byId(m.talent) || { name: m.talent, role: '' };
3035
3079
  return h('div', { key: i, className: 'at-teamrow' },
3080
+ h(Avatar, { name: m.name || talent.name, seed: avatarSeed(m.name || talent.name), avatar: talent.avatar, size: 24 }),
3036
3081
  h('input', { value: m.name, placeholder: talent.name, 'aria-label': t('teamName'), onChange: (e) => rename(i, e.target.value), onFocus: () => setFocus(m.talent) }),
3037
3082
  h('span', { className: 'at-modalmeta' }, talent.role),
3038
3083
  h('label', { className: 'at-teamlead' }, h('input', { type: 'radio', name: 'team-lead', checked: draft.lead === i, onChange: () => setDraft({ ...draft, lead: i }) }), t('teamLead')),
@@ -3233,6 +3278,37 @@ window.__ModuleLoader__.load({
3233
3278
  }
3234
3279
 
3235
3280
  // <member-copy>
3281
+ // 头像:插件本机按名字画(@suifei/hash-avatar 契约 v1,与 avatar.onrpc.com 同图),人才与按原名招来的成员是同一张脸。
3282
+ const AVATAR_ROUTE = '/ai-team/api/avatar.svg';
3283
+ const AVATAR_CHOICES = { gender: ['male', 'female', 'neutral'], age: ['baby', 'teen', 'youth', 'middle', 'old'], race: ['asian', 'white', 'black', 'brown', 'auto'] };
3284
+ /** 没设过头像、也查不到来源人才的成员:亚洲人、青年、性别不指定。 */
3285
+ const AVATAR_FALLBACK = { gender: 'neutral', age: 'youth', race: 'asian' };
3286
+ /** 自建时的初始选项:亚洲人、青年、男。 */
3287
+ const AVATAR_PICK_DEFAULT = { gender: 'male', age: 'youth', race: 'asian' };
3288
+ /** 当前项目成员名 → { seed, avatar },给只拿到名字的地方(消息、人员池)用。 */
3289
+ const AVATAR_INDEX = new Map();
3290
+ /** 画像种子就是名字:人才和按原名招来的成员同一张脸;改名换脸,参数不变。 */
3291
+ function avatarSeed(name) {
3292
+ return String(name ?? '').trim() || '?';
3293
+ }
3294
+ function avatarUrl(seed, avatar, size) {
3295
+ const pick = (key) => (AVATAR_CHOICES[key].includes(avatar && avatar[key]) ? avatar[key] : AVATAR_FALLBACK[key]);
3296
+ const px = Math.max(16, Math.min(1024, Math.round((Number(size) || 24) * 2)));
3297
+ return AVATAR_ROUTE + '?name=' + encodeURIComponent(String(seed ?? '')) + '&gender=' + pick('gender') + '&age=' + pick('age') + '&race=' + pick('race') + '&size=' + px;
3298
+ }
3299
+ /** 成员的头像参数:自己设过的 > 来源人才的 > 默认(负责人按中年)。 */
3300
+ function memberAvatarOf(agent, talents) {
3301
+ if (agent && agent.avatar) return agent.avatar;
3302
+ const talent = (Array.isArray(talents) ? talents : []).find((x) => x && x.id === (agent && agent.talent));
3303
+ if (talent && talent.avatar) return talent.avatar;
3304
+ return { ...AVATAR_FALLBACK, age: agent && agent.duty === 'lead' ? 'middle' : AVATAR_FALLBACK.age };
3305
+ }
3306
+ function rememberAvatars(agents, talents) {
3307
+ AVATAR_INDEX.clear();
3308
+ for (const agent of Array.isArray(agents) ? agents : []) {
3309
+ if (agent && agent.kind !== 'human' && agent.name) AVATAR_INDEX.set(agent.name, { seed: avatarSeed(agent.name), avatar: memberAvatarOf(agent, talents) });
3310
+ }
3311
+ }
3236
3312
  /**
3237
3313
  * 复制成员(#65:想要两个「玄策」一起写代码,只能手工重填一遍)。
3238
3314
  * 沿用角色、人格、运行配方、模型、输出上限与技能;不带笔记、会话与任务(那是原成员自己的经历)。
@@ -3256,6 +3332,7 @@ window.__ModuleLoader__.load({
3256
3332
  maxTokens: Number.isSafeInteger(maxTokens) && maxTokens > 0 ? maxTokens : null,
3257
3333
  skills: (Array.isArray(source?.skills) ? source.skills : []).filter((skill) => typeof skill === 'string' && skill.trim() !== ''),
3258
3334
  sourceName: String(source?.name ?? ''),
3335
+ avatar: source?.avatar ?? null,
3259
3336
  };
3260
3337
  }
3261
3338
  /**
@@ -3281,6 +3358,7 @@ window.__ModuleLoader__.load({
3281
3358
  sourceName: base,
3282
3359
  talent: { id: String(talent?.id ?? ''), version: String(talent?.version ?? '') },
3283
3360
  duty: ['lead', 'qa', 'executor'].includes(talent?.duty) ? talent.duty : null,
3361
+ avatar: talent?.avatar ?? null,
3284
3362
  };
3285
3363
  }
3286
3364
  /** 人才市场筛选:分类精确匹配;关键词在名字、岗位、分类、标签、说明、技能里找(不分大小写)。 */
@@ -3294,7 +3372,7 @@ window.__ModuleLoader__.load({
3294
3372
  });
3295
3373
  }
3296
3374
  function blankTalentForm() {
3297
- return { name: '', role: '', duty: 'executor', category: '', tags: '', personality: '' };
3375
+ return { name: '', role: '', duty: 'executor', category: '', tags: '', personality: '', avatar: { ...AVATAR_PICK_DEFAULT } };
3298
3376
  }
3299
3377
  /** 新建人才表单 → POST /api/talents 的请求体:标签按逗号/顿号/空白拆开,职责只认三种。 */
3300
3378
  function talentFormToBody(form) {
@@ -3306,6 +3384,7 @@ window.__ModuleLoader__.load({
3306
3384
  category: String((form && form.category) || '').trim(),
3307
3385
  tags,
3308
3386
  personality: String((form && form.personality) || '').trim(),
3387
+ ...(form && form.avatar ? { avatar: form.avatar } : {}),
3309
3388
  };
3310
3389
  }
3311
3390
  /**
@@ -3315,7 +3394,7 @@ window.__ModuleLoader__.load({
3315
3394
  const draft = (initial && initial.draft) || {};
3316
3395
  const skills = Array.isArray(draft.skills) ? draft.skills : [];
3317
3396
  return {
3318
- form: { name: String(draft.name || ''), role: String(draft.role || ''), duty: ['lead', 'qa', 'executor'].includes(draft.duty) ? draft.duty : 'executor', category: String(draft.category || ''), tags: (Array.isArray(draft.tags) ? draft.tags : []).join(', '), personality: String(draft.personality || '') },
3397
+ form: { name: String(draft.name || ''), role: String(draft.role || ''), duty: ['lead', 'qa', 'executor'].includes(draft.duty) ? draft.duty : 'executor', category: String(draft.category || ''), tags: (Array.isArray(draft.tags) ? draft.tags : []).join(', '), personality: String(draft.personality || ''), avatar: draft.avatar ? { ...draft.avatar } : { ...AVATAR_PICK_DEFAULT } },
3319
3398
  pending: skills.filter((x) => x && x.found).map((x) => ({ name: x.name, kind: 'member', fromProject: initial.projectId, fromMember: initial.memberId })),
3320
3399
  missing: skills.filter((x) => x && !x.found).map((x) => x.name),
3321
3400
  model: draft.model && (draft.model.provider || draft.model.model) ? draft.model : null,
@@ -3469,6 +3548,7 @@ window.__ModuleLoader__.load({
3469
3548
  const [talentInit, setTalentInit] = React.useState(null);
3470
3549
  const [mName, setMName] = React.useState('');
3471
3550
  const [mRole, setMRole] = React.useState('');
3551
+ const [mAvatar, setMAvatar] = React.useState(null);
3472
3552
  const [mPrompt, setMPrompt] = React.useState('');
3473
3553
  const [mProvider, setMProvider] = React.useState('');
3474
3554
  const [mEffort, setMEffort] = React.useState('');
@@ -3481,6 +3561,7 @@ window.__ModuleLoader__.load({
3481
3561
  const [profileAgent, setProfileAgent] = React.useState(null);
3482
3562
  const [pName, setPName] = React.useState('');
3483
3563
  const [pRole, setPRole] = React.useState('');
3564
+ const [pAvatar, setPAvatar] = React.useState(null);
3484
3565
  const [pPersonality, setPPersonality] = React.useState('');
3485
3566
  const [pPreset, setPPreset] = React.useState('standard');
3486
3567
  const [pProvider, setPProvider] = React.useState('');
@@ -3642,6 +3723,8 @@ window.__ModuleLoader__.load({
3642
3723
  let alive = true;
3643
3724
  const controller = typeof AbortController === 'function' ? new AbortController() : null;
3644
3725
  // The package is @suifei/dsh-ai-team; the Host prefix is /ai-team.
3726
+ // 头像要按成员的来源人才取参数:进工作台(切项目)时顺带取人才列表(没设过头像的老成员靠它)。
3727
+ void loadTalents();
3645
3728
  const query = projectId ? '?project=' + encodeURIComponent(projectId) : '';
3646
3729
  async function load() {
3647
3730
  const seq = ++loadSeqRef.current;
@@ -4306,6 +4389,7 @@ window.__ModuleLoader__.load({
4306
4389
  setMModel(defaults.model ?? '');
4307
4390
  setMEffort(defaults.reasoningEffort ?? '');
4308
4391
  setMOwner((data?.agents ?? []).length === 0);
4392
+ setMAvatar({ ...AVATAR_PICK_DEFAULT });
4309
4393
  setMCopy(null);
4310
4394
  setMError('');
4311
4395
  setMTab('market');
@@ -4413,6 +4497,7 @@ window.__ModuleLoader__.load({
4413
4497
  setMProvider(draft.provider || defaults.provider || '');
4414
4498
  setMModel(draft.model || defaults.model || '');
4415
4499
  setMEffort(draft.reasoningEffort || defaults.reasoningEffort || '');
4500
+ setMAvatar(draft.avatar ? { ...draft.avatar } : { ...AVATAR_PICK_DEFAULT });
4416
4501
  setMCopy(draft);
4417
4502
  setMError('');
4418
4503
  setMTab('custom');
@@ -4427,6 +4512,7 @@ window.__ModuleLoader__.load({
4427
4512
  setMModel(draft.model);
4428
4513
  setMEffort(draft.reasoningEffort);
4429
4514
  setMOwner(false);
4515
+ setMAvatar({ ...memberAvatarOf(source, talents) });
4430
4516
  setMCopy(draft);
4431
4517
  setMError('');
4432
4518
  setAddOpen(true);
@@ -4459,6 +4545,7 @@ window.__ModuleLoader__.load({
4459
4545
  ...(mCopy?.personality ? { personality: mCopy.personality } : {}),
4460
4546
  ...(mCopy?.talent?.id ? { talent: mCopy.talent.id, talentVersion: mCopy.talent.version } : {}),
4461
4547
  ...(mCopy?.duty ? { duty: mCopy.duty } : {}),
4548
+ ...(mAvatar ? { avatar: mAvatar } : {}),
4462
4549
  });
4463
4550
  const memberId = added.member.id;
4464
4551
  const patch = {
@@ -4552,6 +4639,7 @@ window.__ModuleLoader__.load({
4552
4639
  setPTab('basic');
4553
4640
  setPName(agent.name ?? '');
4554
4641
  setPRole(agent.role ?? '');
4642
+ setPAvatar({ ...memberAvatarOf(agent, talents) });
4555
4643
  setPPersonality(agent.personality ?? '');
4556
4644
  setPPreset(agent.preset ?? agent.config?.preset ?? 'standard');
4557
4645
  setPProvider(agent.config?.provider ?? '');
@@ -4575,6 +4663,7 @@ window.__ModuleLoader__.load({
4575
4663
  name: pName.trim(),
4576
4664
  role: pRole.trim(),
4577
4665
  personality: pPersonality,
4666
+ ...(pAvatar ? { avatar: pAvatar } : {}),
4578
4667
  reason: 'workbench profile',
4579
4668
  });
4580
4669
  const config = profileAgent.config ?? {};
@@ -5059,6 +5148,8 @@ window.__ModuleLoader__.load({
5059
5148
  const memberViewAgent = data.agents.find((agent) => agent.id === memberViewId) ?? null;
5060
5149
  const memberViewTasks = memberViewAgent === null ? [] : tasks.filter((task) => task.ownerId === memberViewAgent.id || task.assigneeId === memberViewAgent.id);
5061
5150
  const headerTitle = inPeople ? t('peopleTitle') : inInbox ? t('inboxTitle') : project ? '# ' + project.name : t('noProject');
5151
+ // 只拿到名字的地方(消息、人员池、批量配置)按这张表找成员的头像参数。
5152
+ rememberAvatars(data?.agents, talents);
5062
5153
  const headerGoal = inPeople ? t('peopleGoal') : inInbox ? t('inboxGoal') : (project?.goal ?? '');
5063
5154
  const unread = inboxUnread > 99 ? '99+' : inboxUnread;
5064
5155
 
@@ -5438,6 +5529,7 @@ window.__ModuleLoader__.load({
5438
5529
  h('input', { value: mName, onChange: (event) => setMName(event.target.value), autoFocus: true })),
5439
5530
  h('label', { className: 'at-field' }, h('span', null, t('memberRole')),
5440
5531
  h('input', { value: mRole, onChange: (event) => setMRole(event.target.value) }))),
5532
+ h(AvatarPicker, { key: 'av', t, value: mAvatar, seed: avatarSeed(mName), onChange: setMAvatar }),
5441
5533
  h('label', { key: 'prompt', className: 'at-field' }, h('span', null, t('memberPrompt')),
5442
5534
  h('textarea', {
5443
5535
  value: mPrompt,
@@ -5471,7 +5563,7 @@ window.__ModuleLoader__.load({
5471
5563
  'aria-label': t('memberProfileTitle'),
5472
5564
  onSubmit: (event) => { event.preventDefault(); saveProfile(); },
5473
5565
  },
5474
- h('h2', { className: 'at-modaltitle' }, withIco('user', tf(t, 'memberProfileTitleName', { name: profileAgent.name }), 16)),
5566
+ h('h2', { className: 'at-modaltitle' }, h(Avatar, { name: profileAgent.name, size: 28 }), tf(t, 'memberProfileTitleName', { name: profileAgent.name })),
5475
5567
  // 右上角按钮按用途分组:去看(任务 / 对话)· 复用(复制 / 存为人才)· 会话维护(重试 / 重置 / 重新蒸馏,黄)· 离开(红)· 取消 / 保存。
5476
5568
  h('div', { className: 'at-modalactions' },
5477
5569
  h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: () => { const target = profileAgent; setProfileAgent(null); openMemberView(target); } }, withIco('board', t('memberTasks'), 12)),
@@ -5508,6 +5600,7 @@ window.__ModuleLoader__.load({
5508
5600
  onClick: () => setPTab(id),
5509
5601
  }, withIco(icon, t(key), 12)))),
5510
5602
  pTab === 'basic' ? [
5603
+ h(AvatarPicker, { key: 'av', t, value: pAvatar, seed: avatarSeed(pName.trim() || profileAgent.name), onChange: setPAvatar }),
5511
5604
  h('div', { key: 'nr', className: 'at-fieldrow' },
5512
5605
  h('label', { className: 'at-field' }, h('span', null, t('memberName')),
5513
5606
  h('input', { value: pName, onChange: (event) => setPName(event.target.value), autoFocus: true })),
package/index.js CHANGED
@@ -73,6 +73,7 @@ import { messageContent, normalizeAttachments } from './lib/domain/rich-message.
73
73
  import { readAttachment, uploadAttachment } from './lib/host/attachment-routes.js';
74
74
  import { createDiagLogger, defaultDiagDir, installDiagSink } from './lib/diaglog.js';
75
75
  import { CATALOG_PACKAGE, clearOfficialCatalog, officialStatus, syncOfficialCatalog } from './lib/domain/catalog-sync.js';
76
+ import { renderAvatarSvg } from './lib/domain/avatar.js';
76
77
  import { DEFAULT_TEAM, catalogRoots, deleteTalent, deleteTeam, forkTalent, installSkill, listInstallableSkills, listTalents, listTeams, loadCatalog, readSkillText, resolveTeam, talentFromMember, talentIdFrom, uniqueTalentId, uniqueTeamId, userCatalogDir, writeTalent, writeTeam } from './lib/domain/catalog.js';
77
78
 
78
79
  export const name = 'ai-team';
@@ -2384,6 +2385,16 @@ export function apply(ctx, config = {}) {
2384
2385
  return send(res, { talents: listTalents(talentCatalog(diag)) });
2385
2386
  }
2386
2387
  // 第 3 步:官方在线人才库。状态 / 同步(npmmirror → jsDelivr,逐文件 sha256 校验后整体替换)/ 清除(退回内置)。
2388
+ // 头像:@suifei/hash-avatar 本机出 SVG(与 avatar.onrpc.com 契约 v1 同图);同参同图,可长缓存。
2389
+ if (req.method === 'GET' && url.pathname === '/ai-team/api/avatar.svg') {
2390
+ const q = url.searchParams;
2391
+ const svg = renderAvatarSvg(q.get('name') ?? '', { gender: q.get('gender'), age: q.get('age'), race: q.get('race'), size: q.get('size') });
2392
+ res.statusCode = 200;
2393
+ res.setHeader('content-type', 'image/svg+xml; charset=utf-8');
2394
+ res.setHeader('cache-control', 'private, max-age=31536000, immutable');
2395
+ res.setHeader('x-content-type-options', 'nosniff');
2396
+ return res.end(svg);
2397
+ }
2387
2398
  if (req.method === 'GET' && url.pathname === '/ai-team/api/catalog') {
2388
2399
  return send(res, { package: CATALOG_PACKAGE, official: publicOfficial(officialStatus(dshHome())) });
2389
2400
  }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 头像参数(人才 talent.yml 的 `avatar`、成员资料的 `avatar`)与本机画图。
3
+ * 画图用 @suifei/hash-avatar(契约 v1,与 avatar.onrpc.com 同一张图),插件自己出 SVG,不连外网。
4
+ * 人才市场、团队、成员共用这一份校验与渲染。
5
+ */
6
+ import { createRequire } from 'node:module';
7
+
8
+ const HashAvatar = createRequire(import.meta.url)('@suifei/hash-avatar');
9
+
10
+ export const AVATAR_GENDERS = Object.freeze(['male', 'female', 'neutral']);
11
+ export const AVATAR_AGES = Object.freeze(['baby', 'teen', 'youth', 'middle', 'old']);
12
+ export const AVATAR_RACES = Object.freeze(['asian', 'white', 'black', 'brown', 'auto']);
13
+
14
+ /** 默认:亚洲人、青年、性别不指定。 */
15
+ export const DEFAULT_AVATAR = Object.freeze({ gender: 'neutral', age: 'youth', race: 'asian' });
16
+
17
+ /**
18
+ * 校验头像参数。缺省(undefined / null)返回 null;字段可只给一部分,缺的按 DEFAULT_AVATAR 补。
19
+ * 写错的值抛错并说明哪一项,不静默改成别的。
20
+ * @param {unknown} value
21
+ * @param {string} [label]
22
+ * @returns {{ gender: string, age: string, race: string } | null}
23
+ */
24
+ export function parseAvatar(value, label = 'avatar') {
25
+ if (value === undefined || value === null) return null;
26
+ if (typeof value !== 'object' || Array.isArray(value)) throw new Error(`${label} 必须是对象(gender / age / race)`);
27
+ const pick = (key, allowed) => {
28
+ const raw = value[key];
29
+ if (raw === undefined || raw === null || raw === '') return DEFAULT_AVATAR[key];
30
+ if (typeof raw !== 'string' || !allowed.includes(raw)) throw new Error(`${label}.${key} 只认 ${allowed.join(' / ')}`);
31
+ return raw;
32
+ };
33
+ return { gender: pick('gender', AVATAR_GENDERS), age: pick('age', AVATAR_AGES), race: pick('race', AVATAR_RACES) };
34
+ }
35
+
36
+ /**
37
+ * 画一张头像 SVG。参数宽松:写错或缺省的按 DEFAULT_AVATAR;尺寸夹到 16..1024;
38
+ * 小于 128px(客户端按 2 倍像素取图,即显示不到 64px)时去掉外圈指纹:太密看不清(见 hash-avatar README)。
39
+ * @param {string} name
40
+ * @param {{ gender?: string, age?: string, race?: string, size?: number|string }} [options]
41
+ */
42
+ export function renderAvatarSvg(name, options = {}) {
43
+ const pick = (key, allowed) => (allowed.includes(options[key]) ? options[key] : DEFAULT_AVATAR[key]);
44
+ const size = Math.max(16, Math.min(1024, Math.round(Number(options.size) || 64)));
45
+ const input = String(name ?? '').trim().slice(0, 200) || '?';
46
+ return HashAvatar.svg(input, { gender: pick('gender', AVATAR_GENDERS), age: pick('age', AVATAR_AGES), race: pick('race', AVATAR_RACES), size, fingerprint: size >= 128 });
47
+ }
@@ -16,6 +16,7 @@ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, write
16
16
  import { join } from 'node:path';
17
17
  import { fileURLToPath } from 'node:url';
18
18
  import { parse, stringify } from 'yaml';
19
+ import { parseAvatar } from './avatar.js';
19
20
  import { compareVersions, officialRoot } from './catalog-sync.js';
20
21
 
21
22
  /** 插件内置目录(包根,下有 talents/ 与 teams/)。 */
@@ -94,6 +95,7 @@ export function parseTalent(source, label = 'talent') {
94
95
  personality: text(doc.personality, 2000),
95
96
  skills: skillList(doc.skills, `${label}: skills`),
96
97
  model,
98
+ avatar: parseAvatar(doc.avatar, `${label}: avatar`),
97
99
  };
98
100
  }
99
101
 
@@ -197,7 +199,7 @@ export function loadCatalog({ roots = catalogRoots(), diag } = {}) {
197
199
  /** 人才市场列表(给「添加成员」弹窗):按分类、名字排序。 */
198
200
  export function listTalents(catalog) {
199
201
  return [...catalog.talents.values()]
200
- .map(({ id, source, version, name, role, duty: d, category, tags, description, personality, skills, model, shadows }) => ({ id, source, version, name, role, duty: d, category, tags, description, personality, skills, model, forked: source === 'user' && shadows !== undefined }))
202
+ .map(({ id, source, version, name, role, duty: d, category, tags, description, personality, skills, model, avatar, shadows }) => ({ id, source, version, name, role, duty: d, category, tags, description, personality, skills, model, avatar: avatar ?? null, forked: source === 'user' && shadows !== undefined }))
201
203
  .sort((a, b) => a.category.localeCompare(b.category, 'zh') || a.name.localeCompare(b.name, 'zh'));
202
204
  }
203
205
 
@@ -224,6 +226,7 @@ export function resolveTeam(catalog, name = DEFAULT_TEAM, { diag } = {}) {
224
226
  skills: [...new Set([...talent.skills, ...member.skills])],
225
227
  talent: { id: talent.id, version: talent.version, source: talent.source },
226
228
  model: talent.model,
229
+ avatar: talent.avatar ?? null,
227
230
  };
228
231
  });
229
232
  return { id: wanted, source: entry.source, dir: entry.dir, team: { name: entry.name || wanted, description: entry.description, lead: entry.lead, procedures: entry.procedures, members } };
@@ -269,6 +272,8 @@ function talentDoc(input) {
269
272
  if (skills.length) doc.skills = skills;
270
273
  const m = input?.model;
271
274
  if (m && (text(m.provider, 80) || text(m.model, 160))) doc.model = { provider: text(m.provider, 80), model: text(m.model, 160), reasoningEffort: text(m.reasoningEffort, 20) };
275
+ const avatar = parseAvatar(input?.avatar);
276
+ if (avatar) doc.avatar = avatar;
272
277
  return doc;
273
278
  }
274
279
 
@@ -355,7 +360,7 @@ export function listTeams(catalog) {
355
360
  .map((entry) => {
356
361
  const members = entry.members.map((m) => {
357
362
  const t = catalog.talents.get(m.talent);
358
- return { id: m.id, talent: m.talent, name: m.name || t?.name || m.talent, role: m.role || t?.role || '', duty: m.duty ?? t?.duty ?? null, description: t?.description ?? '', category: t?.category ?? '', skills: [...new Set([...(t?.skills ?? []), ...(m.skills ?? [])])], missing: t === undefined };
363
+ return { id: m.id, talent: m.talent, name: m.name || t?.name || m.talent, role: m.role || t?.role || '', duty: m.duty ?? t?.duty ?? null, description: t?.description ?? '', category: t?.category ?? '', skills: [...new Set([...(t?.skills ?? []), ...(m.skills ?? [])])], avatar: t?.avatar ?? null, missing: t === undefined };
359
364
  });
360
365
  return { id: entry.id, source: entry.source, name: entry.name || entry.id, description: entry.description, lead: entry.lead, members, broken: members.some((m) => m.missing) };
361
366
  })
@@ -417,6 +422,7 @@ export function talentFromMember(member, duty) {
417
422
  tags: [],
418
423
  personality: text(member?.personality, 2000),
419
424
  model: provider || model ? { provider, model, reasoningEffort: text(config.reasoningEffort, 20) } : null,
425
+ avatar: member?.avatar ?? null,
420
426
  skills: (Array.isArray(member?.skills) ? member.skills : []).map((s) => text(String(s), 64)).filter((s) => SKILL_NAME.test(s)),
421
427
  };
422
428
  }
@@ -27,6 +27,7 @@ function teamFields(preset, member) {
27
27
  talentVersion: member.talent.version,
28
28
  ...(member.duty ? { duty: member.duty } : {}),
29
29
  ...(member.skills?.length > 0 ? { skills: member.skills } : {}),
30
+ ...(member.avatar ? { avatar: member.avatar } : {}),
30
31
  };
31
32
  }
32
33