@suifei/dsh-ai-team 0.4.134 → 0.4.136

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 (55) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +54 -4
  3. package/client.js +166 -11
  4. package/index.js +21 -0
  5. package/lib/domain/avatar.js +258 -0
  6. package/lib/domain/catalog-sync.js +2 -2
  7. package/lib/domain/catalog.js +8 -2
  8. package/lib/host/default-roster.js +1 -0
  9. package/lib/host/service.js +19 -3
  10. package/lib/ledger/fold.js +12 -0
  11. package/package.json +1 -1
  12. package/talents/algo-reimplementer/talent.yml +2 -1
  13. package/talents/analyst/talent.yml +2 -1
  14. package/talents/architect/talent.yml +2 -1
  15. package/talents/binary-analyst/talent.yml +2 -1
  16. package/talents/biz-analyst/talent.yml +2 -1
  17. package/talents/code-reviewer/talent.yml +2 -1
  18. package/talents/content-author/talent.yml +2 -1
  19. package/talents/content-strategist/talent.yml +2 -1
  20. package/talents/copywriter/talent.yml +2 -1
  21. package/talents/creative-director/talent.yml +2 -1
  22. package/talents/curriculum-designer/talent.yml +2 -1
  23. package/talents/data-analyst/talent.yml +2 -1
  24. package/talents/deobfuscator/talent.yml +2 -1
  25. package/talents/diagrammer/talent.yml +2 -1
  26. package/talents/dynamic-debugger/talent.yml +2 -1
  27. package/talents/editor/talent.yml +2 -1
  28. package/talents/editorial-lead/talent.yml +2 -1
  29. package/talents/education-lead/talent.yml +2 -1
  30. package/talents/engineer/talent.yml +2 -1
  31. package/talents/executor/talent.yml +2 -1
  32. package/talents/experiment-designer/talent.yml +2 -1
  33. package/talents/fact-checker/talent.yml +2 -1
  34. package/talents/game-artist/talent.yml +2 -1
  35. package/talents/game-designer/talent.yml +2 -1
  36. package/talents/game-director/talent.yml +2 -1
  37. package/talents/game-tester/talent.yml +2 -1
  38. package/talents/gameplay-programmer/talent.yml +2 -1
  39. package/talents/mobile-re/talent.yml +2 -1
  40. package/talents/paper-writer/talent.yml +2 -1
  41. package/talents/peer-reviewer/talent.yml +2 -1
  42. package/talents/pmo-lead/talent.yml +2 -1
  43. package/talents/principal-investigator/talent.yml +2 -1
  44. package/talents/qa-acceptor/talent.yml +2 -1
  45. package/talents/re-lead/talent.yml +2 -1
  46. package/talents/re-verifier/talent.yml +2 -1
  47. package/talents/research-lead/talent.yml +2 -1
  48. package/talents/researcher/talent.yml +2 -1
  49. package/talents/scriptwriter/talent.yml +2 -1
  50. package/talents/security-auditor/talent.yml +2 -1
  51. package/talents/seo-specialist/talent.yml +2 -1
  52. package/talents/storyboard-artist/talent.yml +2 -1
  53. package/talents/tech-writer/talent.yml +2 -1
  54. package/talents/ux-designer/talent.yml +2 -1
  55. package/talents/video-editor/talent.yml +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.136 - 2026-11-19
4
+
5
+ **头像库运行时从 npm 取最新版,不再随插件打包**
6
+
7
+ - `@suifei/hash-avatar` 从插件依赖里去掉。插件运行时从 npm 取 latest:只走 registry 型镜像(npmmirror → npmjs),整包核对 registry 给的 sha512 integrity,取出 `src/hash-avatar.js` 先试画一张再换上;缓存在 `~/.dsh/ai-team/vendor/hash-avatar/<版本>/`,只留当前版本。下载与解包复用在线人才库同步的同一套实现。库更新了插件不用重发。
8
+ - 什么时候查新版:启动只装本机缓存,不联网;界面第一次取头像时才查,之后每 6 小时最多查一次。首次使用会等库下载完(最多 15 秒);离线又没有缓存时头像接口回 503,界面退回首字母,60 秒内不重试。
9
+ - 可选值以当前加载的库为准:新增 `GET /ai-team/api/avatar/meta`(库版本、性别 / 年龄 / 种族 / 画风、种族分组)。挑选界面的种族改成按分组的下拉(人类、奇幻与神话、动物、科幻与奇物,没归组的进「其它」),新增画风下拉;1.3.0 的 88 个种族、10 种画风都配了中文名,库以后新增的取值先显示原 id。校验(talent.yml、成员资料)同样按库的取值,写错仍拒绝;头像参数可带可选的 `art`。
10
+ - 图片地址带库版本(`v=`),同版本可长缓存,换版本自动刷新;显示不到 64px 时去掉外圈指纹和动效。
11
+ - 诊断日志:`avatar.lib.load` / `avatar.lib.missing` / `avatar.lib.update` / `avatar.lib.current` / `avatar.lib.sync.fail`。
12
+ - README:加 Star 徽章、欢迎 Star 与「参与贡献」一节。
13
+ - 测试:`test/avatar.test.js` 新增运行时取库(假 registry:首次下载、同版本不动、换新版、integrity 不符 / 缺文件 / 不是头像库都拒绝且不动旧版、重启读缓存不联网)、节流与离线、`avatar/meta` 与 `avatar.svg` 路由、界面地址与挑选;测试打 tar 包的函数挪到 `test/tar-helper.js` 共用。全量 439。实机:隔离宿主从 npmmirror 取到 1.3.0(88 个种族、10 种画风),人才市场与挑选界面截图核对(`.ptc/rounds/r57-steps.json`,`shots-r57/`)。
14
+
15
+ ## 0.4.135 - 2026-11-18
16
+
17
+ **头像:人才市场、团队、成员卡片都有头像(@suifei/hash-avatar,本机生成)**
18
+
19
+ - 头像由插件依赖 [`@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 时去掉外圈指纹。图片加载失败时退回首字母。
20
+ - **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 的旧副本。
21
+ - **出现头像的地方**:人才市场卡片、新建项目的团队成员卡片、组队的人才列表与已选成员、左栏成员、消息、人员池卡片、批量配置模型、成员资料标题。
22
+ - **自定义可选**:添加成员 · 自定义、新建人才、成员资料 · 资料页有头像挑选(性别 / 年龄 / 人种,左边实时预览)。招聘时带上人才的头像,复制成员带上原成员的,存为人才带上成员的。
23
+ - 账本:`project/member-added`、`member/profile-updated` 可带 `avatar`;`member.profile.update` 允许只改头像,写错的值返回 `E_INVALID_ARGUMENT`。没设过头像的老成员按来源人才的参数画。
24
+ - 测试:`test/avatar.test.js`(参数校验、内置人才全带头像、自建人才 / 存为人才、账本、服务层命令、本机渲染与 `avatar.svg` 路由);全量 435。实机截图核对(`.ptc/rounds/r54-steps.json`,`shots-r54/`),宿主页面里头像图片实际加载成功。
25
+
3
26
  ## 0.4.134 - 2026-11-18
4
27
 
5
28
  **README:最近更新**
package/README.md CHANGED
@@ -12,10 +12,13 @@
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-428%20passing-2ea043">
15
+ <img alt="tests" src="https://img.shields.io/badge/tests-439%20passing-2ea043">
16
16
  <img alt="dsh" src="https://img.shields.io/badge/DeepSeek%20Harness-plugin-6f42c1">
17
+ <a href="https://github.com/suifei/dsh-ai-team/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/suifei/dsh-ai-team?style=social"></a>
17
18
  </p>
18
19
 
20
+ <p align="center">觉得有用?点右上角 ⭐ <a href="https://github.com/suifei/dsh-ai-team">Star</a> 支持一下,也欢迎 <a href="https://github.com/suifei/dsh-ai-team/issues">提 issue</a> 和 <a href="https://github.com/suifei/dsh-ai-team/pulls">发 PR</a>。</p>
21
+
19
22
  > 文渊阁,藏修、校勘、纂辑之地。
20
23
  > 在这里,Human 不在环里逐条调度,而是在环上定方向、守信任、做最后那一步。
21
24
 
@@ -30,6 +33,7 @@
30
33
  - **人才市场**(0.4.124–0.4.129):9 个内置团队、44 位内置人才,各自带看家技能。可以招聘、复制为可编辑、自建人才并装技能,也能把项目成员「存为人才」;新建项目时选团队,或从人才里挑人组新团队。
31
34
  - **主理人只调度交付**(0.4.128):主理人不看产出,只问负责人做全没有;内容由验收人把关。
32
35
  - **在线人才库**(0.4.130–0.4.131):「同步在线库」从 [`@suifei/dsh-ai-team-catalog`](https://www.npmjs.com/package/@suifei/dsh-ai-team-catalog) 拉取最新的人才与团队。国内走 npmmirror 整包下载,约 1 秒同步完;逐个文件核对 sha256,失败不影响旧版本,可一键退回内置。
36
+ - **头像**(0.4.135–0.4.136):人才市场、团队、成员卡片都有头像,由 [`@suifei/hash-avatar`](https://www.npmjs.com/package/@suifei/hash-avatar) 在本机按名字生成。这个库**不随插件打包**:插件运行时从 npm 取最新版并缓存在本机,库更新了插件不用重发,新增的种族、画风直接出现在挑选界面里。内置人才预置了参数(默认亚洲人),自定义成员和人才可以选性别、年龄、种族(人类 / 奇幻 / 动物 / 科幻共 88 种)和画风(扁平、像素、水墨等 10 种)。
33
37
  - **弹窗与人员池**(0.4.132–0.4.133):
34
38
  - 弹窗占主页面的 90%,功能按钮固定在右上角。
35
39
  - 成员资料按「资料 / 模型 / 技能 / 协作」分页签。
@@ -37,8 +41,18 @@
37
41
  - 人员池是成员卡片,可以一次给多位成员批量配置模型。
38
42
 
39
43
  <p align="center">
40
- <img src="https://github.com/suifei/dsh-ai-team/releases/download/v0.4.133/talent-market-online.png" width="860" alt="人才市场:同步在线库后按分类筛选" /><br/>
41
- <sub>人才市场:同步在线库后按分类挑人</sub>
44
+ <img src="https://github.com/suifei/dsh-ai-team/releases/download/v0.4.135/talent-market-avatars.png" width="860" alt="人才市场:每位人才都有头像,同步在线库后按分类挑人" /><br/>
45
+ <sub>人才市场:每位人才都有自己的头像,同步在线库后按分类挑人</sub>
46
+ </p>
47
+
48
+ <p align="center">
49
+ <img src="https://github.com/suifei/dsh-ai-team/releases/download/v0.4.135/project-members-avatars.png" width="860" alt="项目主对话:左栏成员与消息都带头像" /><br/>
50
+ <sub>项目里:左栏成员和对话消息都带头像</sub>
51
+ </p>
52
+
53
+ <p align="center">
54
+ <img src="https://github.com/suifei/dsh-ai-team/releases/download/v0.4.135/member-profile-avatar.png" width="860" alt="成员资料:挑选头像的性别、年龄、人种" /><br/>
55
+ <sub>成员资料:头像可选性别、年龄、人种,左侧实时预览</sub>
42
56
  </p>
43
57
 
44
58
  <p align="center">
@@ -48,9 +62,36 @@
48
62
 
49
63
  完整记录见 [CHANGELOG](./CHANGELOG.md)。
50
64
 
65
+ ### 顺带做了个头像库:hash-avatar
66
+
67
+ 为了让人才市场里的每位人才都有一张自己的脸,我们另做了一个开源库 **[`@suifei/hash-avatar`](https://www.npmjs.com/package/@suifei/hash-avatar)**([GitHub](https://github.com/suifei/hash-avatar))<a href="https://github.com/suifei/hash-avatar/stargazers"><img alt="hash-avatar stars" src="https://img.shields.io/github/stars/suifei/hash-avatar?style=social" align="absmiddle"></a>,同样欢迎 Star。文渊阁的头像就是它在本机生成的。
68
+
69
+ <p align="center">
70
+ <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="墨渊" />
71
+ <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="青岚" />
72
+ <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="白砚" />
73
+ <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="玄策" />
74
+ <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="知微" />
75
+ <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="观澜" />
76
+ </p>
77
+
78
+ - **由名字或 email 确定**:输入经 SHA-256 决定五官、发型和配色;同一个名字永远是同一张脸。外圈 128 个刻度画出哈希的前 128 位,两个不同输入撞上同一张图的概率低于 UUIDv4 撞车。
79
+ - **性别、年龄、种族、画风只是渲染参数**,不进哈希,所以换参数后还是认得出同一个人:`gender=male|female|neutral`、`age=baby|teen|youth|middle|old`;`race` 有人类、奇幻与神话、动物、科幻与奇物四组共 88 种(如 `asian`、`elf`、`fox`、`robot`);`art` 有 `flat`、`pixel`、`ink`、`comic`、`watercolor` 等 10 种画风。
80
+ - **零依赖、同步、浏览器和 Node 都能用**,一张约 0.1 ms、约 6 KB 的 SVG;Apache-2.0。
81
+ - **不写代码也能用**:`https://avatar.onrpc.com/<名字>.svg?gender=female&age=youth&race=asian` 直接当图片地址。
82
+
83
+ ```sh
84
+ npm i @suifei/hash-avatar
85
+ ```
86
+
87
+ ```js
88
+ const HashAvatar = require('@suifei/hash-avatar');
89
+ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asian', size: 128 });
90
+ ```
91
+
51
92
  **人才市场**:成员来自可复用的「人才」,团队从人才里挑人组队。
52
93
 
53
- - 人才 `talents/<人才>/talent.yml`:名字、岗位、`duty`(职责:`lead` 主理人 / `qa` 验收 / `executor` 执行,决定拿哪份岗位规程)、性格、分类与标签、推荐模型,以及自带技能(`talents/<人才>/skills/<技能>/SKILL.md`)。内置 10 位:默认团队的 6 位,外加架构、评审、技术文档、安全审计。
94
+ - 人才 `talents/<人才>/talent.yml`:名字、岗位、`duty`(职责:`lead` 主理人 / `qa` 验收 / `executor` 执行,决定拿哪份岗位规程)、头像参数 `avatar: { gender, age, race }`、性格、分类与标签、推荐模型,以及自带技能(`talents/<人才>/skills/<技能>/SKILL.md`)。内置 10 位:默认团队的 6 位,外加架构、评审、技术文档、安全审计。
54
95
  - 团队 `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 位人才可在人才市场挑选、组合或自建。
55
96
  - 「人员 → 添加成员」先打开人才市场:按分类、关键词挑一位,点「招聘」预填表单,改名、换模型后创建;也可以切到「自定义」从零填写。
56
97
  - 自建:人才放 `~/.dsh/ai-team/catalog/user/talents/<人才>/`,团队放 `~/.dsh/ai-team/catalog/user/teams/<团队>/`,同名覆盖内置;插件设置 `teamPreset` 选新项目用哪个团队。
@@ -269,6 +310,15 @@ round-19 DeepSeek + Zhipu 双 provider
269
310
  - distilly / darwin 不内置,有则用、无则不用;`huashu-nuwa` 已被 Team 技能目录排除。
270
311
  - desktop profile 由插件 patch 固定为 `danger-full-access / never`,只应在可信机器使用。
271
312
 
313
+ ## 参与贡献
314
+
315
+ 欢迎 ⭐ [Star](https://github.com/suifei/dsh-ai-team),这是对我们最直接的鼓励。
316
+
317
+ - **用着有问题、有想法**:到 [Issues](https://github.com/suifei/dsh-ai-team/issues) 说一声,附上截图或诊断日志最好。
318
+ - **想动手改**:Fork 后开分支提 [PR](https://github.com/suifei/dsh-ai-team/pulls),改行为的代码请配测试,`node --test` 全绿再提交。
319
+ - **贡献人才和团队**:新的人才(`talents/<人才>/talent.yml`)和团队(`teams/<团队>/team.yml`)都欢迎,合并后会随在线人才库发给所有用户。
320
+ - **头像库**:[hash-avatar](https://github.com/suifei/hash-avatar) 同样欢迎 Star 和贡献新的种族、画风。
321
+
272
322
  ---
273
323
 
274
324
  ## License
package/client.js CHANGED
@@ -308,6 +308,9 @@ window.__ModuleLoader__.load({
308
308
  talentLoadFailed: '人才市场读取失败:{error}',
309
309
  talentSkills: '技能:{skills}',
310
310
  talentUser: '自建',
311
+ avatarTitle: '头像', avatarGender: '性别', avatarAge: '年龄', avatarRace: '种族', avatarArt: '画风', avatarHint: '头像按名字在本机生成(hash-avatar,自动更新到 npm 最新版);改名会换一张脸,参数不变。',
312
+ avatar_southasian: '南亚人', avatar_seasian: '东南亚人', avatar_mideast: '中东人', avatar_latino: '拉丁裔', avatar_indigenous: '原住民', avatar_pacific: '太平洋岛民', avatar_elf: '精灵', avatar_orc: '兽人', avatar_goblin: '哥布林', avatar_troll: '巨魔', avatar_vampire: '吸血鬼', avatar_zombie: '僵尸', avatar_mummy: '木乃伊', avatar_oni: '鬼', avatar_tengu: '天狗', avatar_demon: '恶魔', avatar_angel: '天使', avatar_fairy: '仙子', avatar_mermaid: '人鱼', avatar_jinn: '灯神', avatar_dragon: '龙', avatar_kitsune: '九尾狐', avatar_qilin: '麒麟', avatar_phoenix: '凤凰', avatar_unicorn: '独角兽', avatar_nian: '年兽', avatar_tanuki: '狸猫', avatar_yeti: '雪怪', avatar_werewolf: '狼人', avatar_golem: '魔像', avatar_ghost: '幽灵', avatar_skeleton: '骷髅', avatar_slime: '史莱姆', avatar_cat: '猫', avatar_dog: '狗', avatar_fox: '狐狸', avatar_wolf: '狼', avatar_tiger: '老虎', avatar_lion: '狮子', avatar_leopard: '豹', avatar_panda: '熊猫', avatar_redpanda: '小熊猫', avatar_bear: '熊', avatar_koala: '考拉', avatar_raccoon: '浣熊', avatar_rabbit: '兔子', avatar_mouse: '老鼠', avatar_hamster: '仓鼠', avatar_hedgehog: '刺猬', avatar_capybara: '水豚', avatar_monkey: '猴子', avatar_ox: '牛', avatar_horse: '马', avatar_zebra: '斑马', avatar_giraffe: '长颈鹿', avatar_deer: '鹿', avatar_goat: '山羊', avatar_sheep: '绵羊', avatar_pig: '猪', avatar_elephant: '大象', avatar_snake: '蛇', avatar_frog: '青蛙', avatar_octopus: '章鱼', avatar_owl: '猫头鹰', avatar_penguin: '企鹅', avatar_rooster: '公鸡', avatar_chick: '小鸡', avatar_duck: '鸭子', avatar_parrot: '鹦鹉', avatar_bee: '蜜蜂', avatar_cyborg: '赛博格', avatar_android: '仿生人', avatar_hologram: '全息影像', avatar_robot: '机器人', avatar_ai: 'AI', avatar_alien: '外星人', avatar_insectoid: '虫族', avatar_mushroom: '蘑菇', avatar_pumpkin: '南瓜', avatar_snowman: '雪人', avatar_cactus: '仙人掌', avatar_star: '星星', avatar_any: '随机', avatar_art_flat: '扁平', avatar_art_pixel: '像素', avatar_art_ink: '水墨', avatar_art_comic: '漫画', avatar_art_sketch: '素描', avatar_art_neon: '霓虹', avatar_art_pop: '波普', avatar_art_mood: '心情', avatar_art_watercolor: '水彩', avatar_art_glitch: '故障', avatar_group_human: '人类', avatar_group_fantasy: '奇幻与神话', avatar_group_animal: '动物', avatar_group_scifi: '科幻与奇物', avatar_group_other: '其它',
313
+ 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
314
  profileTabBasic: '资料', profileTabModel: '模型', profileTabSkills: '技能', profileTabCollab: '协作', profileNotes: '备忘', profileNotesEmpty: '还没有备忘。', profileSkillsEmpty: '还没装技能;在下面填技能名加一个,或到人才市场招已带技能的人才。',
312
315
  teamPickDetail: '人才简介', teamPickDetailEmpty: '在左边点一位人才,这里看简介;点「加入」放进右边的团队。', teamLeadMark: '负责人', projectTeamMembers: '团队成员 · {n} 位',
313
316
  peopleModelBatch: '批量配置模型', peopleModelTitle: '配置模型', peopleModelHint: '选中的成员在其所在的全部项目里改用这个模型;之后仍可在成员资料里单独改。', peopleModelPick: '应用到 {n} 位', peopleModelAll: '全选', peopleModelNone: '全不选', peopleModelApply: '应用', peopleModelNeed: '先选模型', peopleModelDone: '已为 {people} 位成员配置 {model}(成功 {done} 处,失败 {failed} 处)。',
@@ -762,6 +765,9 @@ window.__ModuleLoader__.load({
762
765
  talentLoadFailed: 'Could not load the talent market: {error}',
763
766
  talentSkills: 'Skills: {skills}',
764
767
  talentUser: 'Custom',
768
+ avatarTitle: 'Avatar', avatarGender: 'Gender', avatarAge: 'Age', avatarRace: 'Kind', avatarArt: 'Style', avatarHint: 'Drawn locally from the name (hash-avatar, kept at the latest npm release); renaming gives a new face with the same settings.',
769
+ avatar_art_flat: 'Flat', avatar_art_pixel: 'Pixel', avatar_art_ink: 'Ink', avatar_art_comic: 'Comic', avatar_art_sketch: 'Sketch', avatar_art_neon: 'Neon', avatar_art_pop: 'Pop', avatar_art_mood: 'Mood', avatar_art_watercolor: 'Watercolor', avatar_art_glitch: 'Glitch', avatar_group_human: 'Human', avatar_group_fantasy: 'Fantasy', avatar_group_animal: 'Animal', avatar_group_scifi: 'Sci-fi', avatar_group_other: 'Other',
770
+ 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
771
  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
772
  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
773
  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 +1203,15 @@ window.__ModuleLoader__.load({
1197
1203
  .at-streamjump:hover { color: var(--dsw-alias-label-primary); }
1198
1204
  .at-msg { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
1199
1205
  .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; }
1206
+ .at-avatar.at-avatar-img { overflow: hidden; border-color: transparent; background: transparent; padding: 0; }
1207
+ .at-avatar.at-avatar-img img { display: block; width: 100%; height: 100%; border-radius: 999px; }
1208
+ .at-talenttop { display: flex; align-items: center; gap: 10px; min-width: 0; }
1209
+ .at-talenttop > .at-talenthead { flex: 1 1 auto; min-width: 0; }
1210
+ .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); }
1211
+ .at-avatarpickrows { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
1212
+ .at-avatarpickrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
1213
+ .at-avatarpickrow > .at-panetitle { width: 36px; flex: none; }
1214
+ .at-avatarselect { height: 30px; min-width: 120px; padding: 0 8px; border: 1px solid var(--dsw-alias-border-l1); border-radius: 8px; background: var(--dsw-alias-bg-layer-1); color: inherit; font: inherit; }
1200
1215
  .at-avatar-human { border-color: transparent; background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-inverted); }
1201
1216
  .at-msgb { min-width: 0; flex: 1; }
1202
1217
  .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 +1471,7 @@ window.__ModuleLoader__.load({
1456
1471
  .at-tcpick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
1457
1472
  .at-tcpanel { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
1458
1473
  .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; }
1474
+ .at-teamrow { display: grid; grid-template-columns: 24px minmax(0, 1fr) 76px auto auto; gap: 8px; align-items: center; }
1460
1475
  .at-teamrow > .at-modalmeta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1461
1476
  .at-teamlead { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
1462
1477
  .at-teampick { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
@@ -1641,8 +1656,53 @@ window.__ModuleLoader__.load({
1641
1656
  h('span', null, label));
1642
1657
  }
1643
1658
 
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));
1659
+ /**
1660
+ * 头像:成员 / 人才按名字由插件本机画(/ai-team/api/avatar.svg,参数见 lib/domain/avatar.js),Human 用首字母。
1661
+ * 只给名字时按当前项目成员表(AVATAR_INDEX)找参数;图片加载失败时退回首字母。
1662
+ */
1663
+ function Avatar({ name, human, avatar, seed, size = 24 }) {
1664
+ const [brokenUrl, setBrokenUrl] = React.useState('');
1665
+ const label = String(name ?? '?');
1666
+ const style = size === 24 ? undefined : { width: size + 'px', height: size + 'px', fontSize: Math.round(size * 0.45) + 'px' };
1667
+ const known = human ? null : AVATAR_INDEX.get(label);
1668
+ const url = human ? '' : avatarUrl(seed ?? known?.seed ?? avatarSeed(label), avatar ?? known?.avatar ?? AVATAR_FALLBACK, size);
1669
+ if (human || url === brokenUrl) return h('span', { className: cx('at-avatar', human && 'at-avatar-human'), style, 'aria-hidden': 'true' }, label.slice(0, 1));
1670
+ return h('span', { className: 'at-avatar at-avatar-img', style, 'aria-hidden': 'true' },
1671
+ h('img', { src: url, alt: '', loading: 'lazy', decoding: 'async', referrerPolicy: 'no-referrer', onError: () => setBrokenUrl(url) }));
1672
+ }
1673
+ /**
1674
+ * 头像参数挑选,左边实时预览。性别、年龄是分段按钮;种族按库的 GROUPS 分组下拉,画风下拉——
1675
+ * 取值来自当前加载的 hash-avatar(/ai-team/api/avatar/meta),库新增的取值没配中文名时显示原 id。
1676
+ * 人才新建、自定义成员、成员资料共用。
1677
+ */
1678
+ function AvatarPicker({ t, value, seed, onChange }) {
1679
+ const current = { ...AVATAR_PICK_DEFAULT, ...(value || {}) };
1680
+ const options = AVATAR_META.options;
1681
+ const set = (key, option) => onChange(avatarPickNext(current, key, option));
1682
+ const segmented = (key, label) => h('div', { key, className: 'at-avatarpickrow' },
1683
+ h('span', { className: 'at-panetitle' }, t(label)),
1684
+ h('div', { className: 'at-mode at-addtabs', role: 'group', 'aria-label': t(label) }, (key === 'gender' ? options.genders : options.ages).map((option) => h('button', {
1685
+ key: option,
1686
+ type: 'button',
1687
+ 'aria-pressed': current[key] === option ? 'true' : 'false',
1688
+ onClick: () => set(key, option),
1689
+ }, avatarLabel(t, option)))));
1690
+ const groups = Object.entries(options.groups);
1691
+ return h('div', { className: 'at-avatarpick' },
1692
+ h(Avatar, { name: seed, seed, avatar: current, size: 72 }),
1693
+ h('div', { className: 'at-avatarpickrows' },
1694
+ segmented('gender', 'avatarGender'),
1695
+ segmented('age', 'avatarAge'),
1696
+ h('div', { className: 'at-avatarpickrow' },
1697
+ h('span', { className: 'at-panetitle' }, t('avatarRace')),
1698
+ h('select', { className: 'at-avatarselect', 'aria-label': t('avatarRace'), value: current.race, onChange: (event) => set('race', event.target.value) },
1699
+ groups.length > 1
1700
+ ? groups.map(([group, list]) => h('optgroup', { key: group, label: avatarLabel(t, group, 'avatar_group_') }, list.map((race) => h('option', { key: race, value: race }, avatarLabel(t, race)))))
1701
+ : options.races.map((race) => h('option', { key: race, value: race }, avatarLabel(t, race)))),
1702
+ options.arts.length > 1 ? h('span', { className: 'at-panetitle' }, t('avatarArt')) : null,
1703
+ options.arts.length > 1 ? h('select', { className: 'at-avatarselect', 'aria-label': t('avatarArt'), value: current.art || options.arts[0], onChange: (event) => set('art', event.target.value) },
1704
+ options.arts.map((art) => h('option', { key: art, value: art }, avatarLabel(t, art, 'avatar_art_')))) : null),
1705
+ h('div', { className: 'at-modalmeta' }, t('avatarHint'))));
1646
1706
  }
1647
1707
 
1648
1708
  function FollowToggle({ t, taskNo: no, following, onToggle, compact }) {
@@ -2029,6 +2089,7 @@ window.__ModuleLoader__.load({
2029
2089
  const failure = agent.status === 'failed' ? (agent.lastFailure ?? null) : null;
2030
2090
  return h('div', { className: 'at-agent', role: 'listitem' },
2031
2091
  h('span', { className: 'at-dot at-dot-' + (agent.status ?? 'idle'), 'aria-hidden': 'true' }),
2092
+ h(Avatar, { name: agent.name, size: 30 }),
2032
2093
  h('div', { className: 'at-agentmeta' },
2033
2094
  h('button', { className: 'at-agentname', type: 'button', onClick: () => onAgent(agent), title: agent.name }, agent.name),
2034
2095
  h('div', { className: 'at-agentrole', title: agent.role ?? '' },
@@ -2172,7 +2233,7 @@ window.__ModuleLoader__.load({
2172
2233
  h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: () => setPicked(new Set()) }, t('peopleModelNone'))),
2173
2234
  h('div', { className: 'at-peoplecheck' }, people.map((person) => h('label', { key: person.name, className: 'at-checkcard' },
2174
2235
  h('input', { type: 'checkbox', checked: picked.has(person.name), onChange: () => toggle(person.name) }),
2175
- h(Avatar, { name: person.name, human: false }),
2236
+ h(Avatar, { name: person.name, human: false, size: 32 }),
2176
2237
  h('span', null, h('b', null, person.name + (person.role ? ' · ' + person.role : '')),
2177
2238
  h('small', null, (person.projects ?? []).map((row) => row.projectName).join('、')))))))));
2178
2239
  }
@@ -2218,7 +2279,7 @@ window.__ModuleLoader__.load({
2218
2279
  const localHere = localNames.has(person.name);
2219
2280
  return h('div', { key: person.name, className: cx('at-pcard', person.failures > 0 && 'at-people-failed') },
2220
2281
  h('div', { className: 'at-pcardhead' },
2221
- h(Avatar, { name: person.name, human: false }),
2282
+ h(Avatar, { name: person.name, human: false, size: 40 }),
2222
2283
  h('span', { className: 'at-peoplename' }, person.name),
2223
2284
  person.role ? h('span', { className: 'at-people-role' }, person.role) : null),
2224
2285
  h('div', { className: 'at-peoplebadges' }, badges.join(' · ')),
@@ -2836,12 +2897,14 @@ window.__ModuleLoader__.load({
2836
2897
  : talent.source === 'user' ? withIco('user', t('talentUser'), 10)
2837
2898
  : talent.source === 'official' ? withIco('cloud', t('talentOfficial'), 10) : null;
2838
2899
  return [
2839
- h('div', { key: 'head', className: 'at-talenthead' },
2900
+ h('div', { key: 'head', className: 'at-talenttop' },
2901
+ h(Avatar, { name: talent.name, seed: avatarSeed(talent.name), avatar: talent.avatar ?? AVATAR_FALLBACK, size: 40 }),
2902
+ h('div', { className: 'at-talenthead' },
2840
2903
  h('span', { className: 'at-talentname' }, talent.name),
2841
2904
  talent.role ? h('span', { className: 'at-talentrole' }, talent.role) : null,
2842
2905
  talent.duty ? h('span', { className: 'at-talentduty' }, t(DUTY_LABEL[talent.duty])) : null,
2843
2906
  lead ? h('span', { className: 'at-talentduty' }, withIco('check', t('teamLeadMark'), 10)) : null,
2844
- badge ? h('span', { className: 'at-talentduty' }, badge) : null),
2907
+ badge ? h('span', { className: 'at-talentduty' }, badge) : null)),
2845
2908
  talent.description ? h('div', { key: 'desc', className: 'at-talentdesc' }, talent.description) : null,
2846
2909
  full && talent.personality ? h('div', { key: 'pers', className: 'at-modalmeta' }, talent.personality) : null,
2847
2910
  talent.skills?.length ? h('div', { key: 'skills', className: 'at-modalmeta' }, tf(t, 'talentSkills', { skills: talent.skills.join('、') })) : null,
@@ -2956,6 +3019,8 @@ window.__ModuleLoader__.load({
2956
3019
  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
3020
  h('label', { className: 'at-field' }, h('span', null, t('tcCategory')), h('input', { value: form.category, onChange: set('category') })),
2958
3021
  h('label', { className: 'at-field' }, h('span', null, t('tcTags')), h('input', { value: form.tags, onChange: set('tags'), placeholder: t('tcTagsHint') }))),
3022
+ h('div', { className: 'at-field' }, h('span', null, t('avatarTitle')),
3023
+ h(AvatarPicker, { t, value: form.avatar, seed: avatarSeed(form.name), onChange: (avatar) => setForm((prev) => ({ ...prev, avatar })) })),
2959
3024
  h('label', { className: 'at-field' }, h('span', null, t('tcPersonality')), h('textarea', { value: form.personality, onChange: set('personality'), placeholder: t('tcPersonalityHint') })),
2960
3025
  h('div', { className: 'at-field' }, h('span', null, t('tcSkills')),
2961
3026
  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 +3084,7 @@ window.__ModuleLoader__.load({
3019
3084
  'aria-selected': focused && focused.id === talent.id ? 'true' : 'false',
3020
3085
  onClick: () => setFocus(talent.id),
3021
3086
  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)))),
3087
+ }, 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
3088
  h('div', { className: 'at-pane' },
3024
3089
  h('div', { className: 'at-panetitle' }, t('teamPickDetail')),
3025
3090
  focused ? h('div', { className: 'at-talent' },
@@ -3033,6 +3098,7 @@ window.__ModuleLoader__.load({
3033
3098
  draft.members.length === 0 ? h('div', { className: 'at-modalmeta' }, t('teamEmptyPick')) : h('div', { className: 'at-teamrows' }, draft.members.map((m, i) => {
3034
3099
  const talent = byId(m.talent) || { name: m.talent, role: '' };
3035
3100
  return h('div', { key: i, className: 'at-teamrow' },
3101
+ h(Avatar, { name: m.name || talent.name, seed: avatarSeed(m.name || talent.name), avatar: talent.avatar, size: 24 }),
3036
3102
  h('input', { value: m.name, placeholder: talent.name, 'aria-label': t('teamName'), onChange: (e) => rename(i, e.target.value), onFocus: () => setFocus(m.talent) }),
3037
3103
  h('span', { className: 'at-modalmeta' }, talent.role),
3038
3104
  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 +3299,63 @@ window.__ModuleLoader__.load({
3233
3299
  }
3234
3300
 
3235
3301
  // <member-copy>
3302
+ // 头像:插件本机按名字画(@suifei/hash-avatar 运行时从 npm 取 latest),人才与按原名招来的成员是同一张脸。
3303
+ const AVATAR_ROUTE = '/ai-team/api/avatar.svg';
3304
+ /** 库还没报上来之前认的取值(与 lib/domain/avatar.js 的 BASE_OPTIONS 同)。 */
3305
+ const AVATAR_BASE_OPTIONS = { genders: ['male', 'female', 'neutral'], ages: ['baby', 'teen', 'youth', 'middle', 'old'], races: ['asian', 'white', 'black', 'brown', 'auto'], groups: { human: ['asian', 'white', 'black', 'brown', 'auto'] }, arts: ['flat'] };
3306
+ /** 当前头像库:版本进图片地址(换版本即换地址,旧缓存不挡新图),可选值给挑选界面。由 /ai-team/api/avatar/meta 填。 */
3307
+ const AVATAR_META = { version: '', options: AVATAR_BASE_OPTIONS };
3308
+ function setAvatarMeta(body) {
3309
+ const o = body && body.options;
3310
+ const list = (value, fallback) => (Array.isArray(value) && value.length > 0 ? value.filter((x) => typeof x === 'string') : fallback);
3311
+ const groups = o && o.groups && typeof o.groups === 'object' ? Object.fromEntries(Object.entries(o.groups).filter(([, v]) => Array.isArray(v) && v.length > 0)) : {};
3312
+ AVATAR_META.version = body && typeof body.version === 'string' ? body.version : '';
3313
+ AVATAR_META.options = o ? { genders: list(o.genders, AVATAR_BASE_OPTIONS.genders), ages: list(o.ages, AVATAR_BASE_OPTIONS.ages), races: list(o.races, AVATAR_BASE_OPTIONS.races), groups: Object.keys(groups).length > 0 ? groups : AVATAR_BASE_OPTIONS.groups, arts: list(o.arts, AVATAR_BASE_OPTIONS.arts) } : AVATAR_BASE_OPTIONS;
3314
+ return AVATAR_META;
3315
+ }
3316
+ /** 选项的显示名:有翻译用翻译,库新增、还没配名字的显示原 id。 */
3317
+ function avatarLabel(t, key, prefix = 'avatar_') {
3318
+ const text = typeof t === 'function' ? t(prefix + key) : '';
3319
+ return typeof text === 'string' && text !== '' && !text.endsWith(prefix + key) ? text : key;
3320
+ }
3321
+ /** 挑选后的新参数;画风选回库的第一个(默认 flat)就不写进参数。 */
3322
+ function avatarPickNext(current, key, option) {
3323
+ const next = { ...current, [key]: option };
3324
+ if (key === 'art' && option === AVATAR_META.options.arts[0]) delete next.art;
3325
+ return next;
3326
+ }
3327
+ /** 没设过头像、也查不到来源人才的成员:亚洲人、青年、性别不指定。 */
3328
+ const AVATAR_FALLBACK = { gender: 'neutral', age: 'youth', race: 'asian' };
3329
+ /** 自建时的初始选项:亚洲人、青年、男。 */
3330
+ const AVATAR_PICK_DEFAULT = { gender: 'male', age: 'youth', race: 'asian' };
3331
+ /** 当前项目成员名 → { seed, avatar },给只拿到名字的地方(消息、人员池)用。 */
3332
+ const AVATAR_INDEX = new Map();
3333
+ /** 画像种子就是名字:人才和按原名招来的成员同一张脸;改名换脸,参数不变。 */
3334
+ function avatarSeed(name) {
3335
+ return String(name ?? '').trim() || '?';
3336
+ }
3337
+ function avatarUrl(seed, avatar, size) {
3338
+ const o = AVATAR_META.options;
3339
+ const lists = { gender: o.genders, age: o.ages, race: o.races };
3340
+ const pick = (key) => (lists[key].includes(avatar && avatar[key]) ? avatar[key] : AVATAR_FALLBACK[key]);
3341
+ const px = Math.max(16, Math.min(1024, Math.round((Number(size) || 24) * 2)));
3342
+ const art = avatar && o.arts.includes(avatar.art) && avatar.art !== o.arts[0] ? '&art=' + avatar.art : '';
3343
+ const version = AVATAR_META.version ? '&v=' + encodeURIComponent(AVATAR_META.version) : '';
3344
+ return AVATAR_ROUTE + '?name=' + encodeURIComponent(String(seed ?? '')) + '&gender=' + pick('gender') + '&age=' + pick('age') + '&race=' + pick('race') + art + '&size=' + px + version;
3345
+ }
3346
+ /** 成员的头像参数:自己设过的 > 来源人才的 > 默认(负责人按中年)。 */
3347
+ function memberAvatarOf(agent, talents) {
3348
+ if (agent && agent.avatar) return agent.avatar;
3349
+ const talent = (Array.isArray(talents) ? talents : []).find((x) => x && x.id === (agent && agent.talent));
3350
+ if (talent && talent.avatar) return talent.avatar;
3351
+ return { ...AVATAR_FALLBACK, age: agent && agent.duty === 'lead' ? 'middle' : AVATAR_FALLBACK.age };
3352
+ }
3353
+ function rememberAvatars(agents, talents) {
3354
+ AVATAR_INDEX.clear();
3355
+ for (const agent of Array.isArray(agents) ? agents : []) {
3356
+ if (agent && agent.kind !== 'human' && agent.name) AVATAR_INDEX.set(agent.name, { seed: avatarSeed(agent.name), avatar: memberAvatarOf(agent, talents) });
3357
+ }
3358
+ }
3236
3359
  /**
3237
3360
  * 复制成员(#65:想要两个「玄策」一起写代码,只能手工重填一遍)。
3238
3361
  * 沿用角色、人格、运行配方、模型、输出上限与技能;不带笔记、会话与任务(那是原成员自己的经历)。
@@ -3256,6 +3379,7 @@ window.__ModuleLoader__.load({
3256
3379
  maxTokens: Number.isSafeInteger(maxTokens) && maxTokens > 0 ? maxTokens : null,
3257
3380
  skills: (Array.isArray(source?.skills) ? source.skills : []).filter((skill) => typeof skill === 'string' && skill.trim() !== ''),
3258
3381
  sourceName: String(source?.name ?? ''),
3382
+ avatar: source?.avatar ?? null,
3259
3383
  };
3260
3384
  }
3261
3385
  /**
@@ -3281,6 +3405,7 @@ window.__ModuleLoader__.load({
3281
3405
  sourceName: base,
3282
3406
  talent: { id: String(talent?.id ?? ''), version: String(talent?.version ?? '') },
3283
3407
  duty: ['lead', 'qa', 'executor'].includes(talent?.duty) ? talent.duty : null,
3408
+ avatar: talent?.avatar ?? null,
3284
3409
  };
3285
3410
  }
3286
3411
  /** 人才市场筛选:分类精确匹配;关键词在名字、岗位、分类、标签、说明、技能里找(不分大小写)。 */
@@ -3294,7 +3419,7 @@ window.__ModuleLoader__.load({
3294
3419
  });
3295
3420
  }
3296
3421
  function blankTalentForm() {
3297
- return { name: '', role: '', duty: 'executor', category: '', tags: '', personality: '' };
3422
+ return { name: '', role: '', duty: 'executor', category: '', tags: '', personality: '', avatar: { ...AVATAR_PICK_DEFAULT } };
3298
3423
  }
3299
3424
  /** 新建人才表单 → POST /api/talents 的请求体:标签按逗号/顿号/空白拆开,职责只认三种。 */
3300
3425
  function talentFormToBody(form) {
@@ -3306,6 +3431,7 @@ window.__ModuleLoader__.load({
3306
3431
  category: String((form && form.category) || '').trim(),
3307
3432
  tags,
3308
3433
  personality: String((form && form.personality) || '').trim(),
3434
+ ...(form && form.avatar ? { avatar: form.avatar } : {}),
3309
3435
  };
3310
3436
  }
3311
3437
  /**
@@ -3315,7 +3441,7 @@ window.__ModuleLoader__.load({
3315
3441
  const draft = (initial && initial.draft) || {};
3316
3442
  const skills = Array.isArray(draft.skills) ? draft.skills : [];
3317
3443
  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 || '') },
3444
+ 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
3445
  pending: skills.filter((x) => x && x.found).map((x) => ({ name: x.name, kind: 'member', fromProject: initial.projectId, fromMember: initial.memberId })),
3320
3446
  missing: skills.filter((x) => x && !x.found).map((x) => x.name),
3321
3447
  model: draft.model && (draft.model.provider || draft.model.model) ? draft.model : null,
@@ -3459,6 +3585,8 @@ window.__ModuleLoader__.load({
3459
3585
  // 人才市场(「添加成员」弹窗第一页):可招聘的人才、筛选条件与当前页。
3460
3586
  const [mTab, setMTab] = React.useState('market');
3461
3587
  const [talents, setTalents] = React.useState(null);
3588
+ // 头像库 meta 到了就重画一遍(图片地址带上库版本、挑选界面换成库的可选值)。
3589
+ const [, setAvatarRev] = React.useState(0);
3462
3590
  const [talentError, setTalentError] = React.useState('');
3463
3591
  const [catalogInfo, setCatalogInfo] = React.useState(null);
3464
3592
  const [catalogBusy, setCatalogBusy] = React.useState(false);
@@ -3469,6 +3597,7 @@ window.__ModuleLoader__.load({
3469
3597
  const [talentInit, setTalentInit] = React.useState(null);
3470
3598
  const [mName, setMName] = React.useState('');
3471
3599
  const [mRole, setMRole] = React.useState('');
3600
+ const [mAvatar, setMAvatar] = React.useState(null);
3472
3601
  const [mPrompt, setMPrompt] = React.useState('');
3473
3602
  const [mProvider, setMProvider] = React.useState('');
3474
3603
  const [mEffort, setMEffort] = React.useState('');
@@ -3481,6 +3610,7 @@ window.__ModuleLoader__.load({
3481
3610
  const [profileAgent, setProfileAgent] = React.useState(null);
3482
3611
  const [pName, setPName] = React.useState('');
3483
3612
  const [pRole, setPRole] = React.useState('');
3613
+ const [pAvatar, setPAvatar] = React.useState(null);
3484
3614
  const [pPersonality, setPPersonality] = React.useState('');
3485
3615
  const [pPreset, setPPreset] = React.useState('standard');
3486
3616
  const [pProvider, setPProvider] = React.useState('');
@@ -3642,6 +3772,10 @@ window.__ModuleLoader__.load({
3642
3772
  let alive = true;
3643
3773
  const controller = typeof AbortController === 'function' ? new AbortController() : null;
3644
3774
  // The package is @suifei/dsh-ai-team; the Host prefix is /ai-team.
3775
+ // 头像要按成员的来源人才取参数:进工作台(切项目)时顺带取人才列表(没设过头像的老成员靠它)。
3776
+ void loadTalents();
3777
+ // 头像库版本与可选值(首次启动时服务端会等库下载完,最多 15 秒)。
3778
+ void loadAvatarMeta();
3645
3779
  const query = projectId ? '?project=' + encodeURIComponent(projectId) : '';
3646
3780
  async function load() {
3647
3781
  const seq = ++loadSeqRef.current;
@@ -4306,6 +4440,7 @@ window.__ModuleLoader__.load({
4306
4440
  setMModel(defaults.model ?? '');
4307
4441
  setMEffort(defaults.reasoningEffort ?? '');
4308
4442
  setMOwner((data?.agents ?? []).length === 0);
4443
+ setMAvatar({ ...AVATAR_PICK_DEFAULT });
4309
4444
  setMCopy(null);
4310
4445
  setMError('');
4311
4446
  setMTab('market');
@@ -4318,6 +4453,17 @@ window.__ModuleLoader__.load({
4318
4453
  loadCatalogInfo();
4319
4454
  }
4320
4455
  /** 每次打开弹窗现取:用户刚改了 talent.yml 也能立刻看到。 */
4456
+ async function loadAvatarMeta() {
4457
+ try {
4458
+ const response = await fetch('/ai-team/api/avatar/meta?wait=15000', { headers: { accept: 'application/json' } });
4459
+ const body = await response.json().catch(() => null);
4460
+ if (!response.ok || !body) return;
4461
+ setAvatarMeta(body);
4462
+ setAvatarRev((n) => n + 1);
4463
+ } catch {
4464
+ // 取不到就用默认可选值;图片照样按名字取,失败退回首字母。
4465
+ }
4466
+ }
4321
4467
  async function loadTalents() {
4322
4468
  setTalentError('');
4323
4469
  try {
@@ -4413,6 +4559,7 @@ window.__ModuleLoader__.load({
4413
4559
  setMProvider(draft.provider || defaults.provider || '');
4414
4560
  setMModel(draft.model || defaults.model || '');
4415
4561
  setMEffort(draft.reasoningEffort || defaults.reasoningEffort || '');
4562
+ setMAvatar(draft.avatar ? { ...draft.avatar } : { ...AVATAR_PICK_DEFAULT });
4416
4563
  setMCopy(draft);
4417
4564
  setMError('');
4418
4565
  setMTab('custom');
@@ -4427,6 +4574,7 @@ window.__ModuleLoader__.load({
4427
4574
  setMModel(draft.model);
4428
4575
  setMEffort(draft.reasoningEffort);
4429
4576
  setMOwner(false);
4577
+ setMAvatar({ ...memberAvatarOf(source, talents) });
4430
4578
  setMCopy(draft);
4431
4579
  setMError('');
4432
4580
  setAddOpen(true);
@@ -4459,6 +4607,7 @@ window.__ModuleLoader__.load({
4459
4607
  ...(mCopy?.personality ? { personality: mCopy.personality } : {}),
4460
4608
  ...(mCopy?.talent?.id ? { talent: mCopy.talent.id, talentVersion: mCopy.talent.version } : {}),
4461
4609
  ...(mCopy?.duty ? { duty: mCopy.duty } : {}),
4610
+ ...(mAvatar ? { avatar: mAvatar } : {}),
4462
4611
  });
4463
4612
  const memberId = added.member.id;
4464
4613
  const patch = {
@@ -4552,6 +4701,7 @@ window.__ModuleLoader__.load({
4552
4701
  setPTab('basic');
4553
4702
  setPName(agent.name ?? '');
4554
4703
  setPRole(agent.role ?? '');
4704
+ setPAvatar({ ...memberAvatarOf(agent, talents) });
4555
4705
  setPPersonality(agent.personality ?? '');
4556
4706
  setPPreset(agent.preset ?? agent.config?.preset ?? 'standard');
4557
4707
  setPProvider(agent.config?.provider ?? '');
@@ -4575,6 +4725,7 @@ window.__ModuleLoader__.load({
4575
4725
  name: pName.trim(),
4576
4726
  role: pRole.trim(),
4577
4727
  personality: pPersonality,
4728
+ ...(pAvatar ? { avatar: pAvatar } : {}),
4578
4729
  reason: 'workbench profile',
4579
4730
  });
4580
4731
  const config = profileAgent.config ?? {};
@@ -5059,6 +5210,8 @@ window.__ModuleLoader__.load({
5059
5210
  const memberViewAgent = data.agents.find((agent) => agent.id === memberViewId) ?? null;
5060
5211
  const memberViewTasks = memberViewAgent === null ? [] : tasks.filter((task) => task.ownerId === memberViewAgent.id || task.assigneeId === memberViewAgent.id);
5061
5212
  const headerTitle = inPeople ? t('peopleTitle') : inInbox ? t('inboxTitle') : project ? '# ' + project.name : t('noProject');
5213
+ // 只拿到名字的地方(消息、人员池、批量配置)按这张表找成员的头像参数。
5214
+ rememberAvatars(data?.agents, talents);
5062
5215
  const headerGoal = inPeople ? t('peopleGoal') : inInbox ? t('inboxGoal') : (project?.goal ?? '');
5063
5216
  const unread = inboxUnread > 99 ? '99+' : inboxUnread;
5064
5217
 
@@ -5438,6 +5591,7 @@ window.__ModuleLoader__.load({
5438
5591
  h('input', { value: mName, onChange: (event) => setMName(event.target.value), autoFocus: true })),
5439
5592
  h('label', { className: 'at-field' }, h('span', null, t('memberRole')),
5440
5593
  h('input', { value: mRole, onChange: (event) => setMRole(event.target.value) }))),
5594
+ h(AvatarPicker, { key: 'av', t, value: mAvatar, seed: avatarSeed(mName), onChange: setMAvatar }),
5441
5595
  h('label', { key: 'prompt', className: 'at-field' }, h('span', null, t('memberPrompt')),
5442
5596
  h('textarea', {
5443
5597
  value: mPrompt,
@@ -5471,7 +5625,7 @@ window.__ModuleLoader__.load({
5471
5625
  'aria-label': t('memberProfileTitle'),
5472
5626
  onSubmit: (event) => { event.preventDefault(); saveProfile(); },
5473
5627
  },
5474
- h('h2', { className: 'at-modaltitle' }, withIco('user', tf(t, 'memberProfileTitleName', { name: profileAgent.name }), 16)),
5628
+ h('h2', { className: 'at-modaltitle' }, h(Avatar, { name: profileAgent.name, size: 28 }), tf(t, 'memberProfileTitleName', { name: profileAgent.name })),
5475
5629
  // 右上角按钮按用途分组:去看(任务 / 对话)· 复用(复制 / 存为人才)· 会话维护(重试 / 重置 / 重新蒸馏,黄)· 离开(红)· 取消 / 保存。
5476
5630
  h('div', { className: 'at-modalactions' },
5477
5631
  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 +5662,7 @@ window.__ModuleLoader__.load({
5508
5662
  onClick: () => setPTab(id),
5509
5663
  }, withIco(icon, t(key), 12)))),
5510
5664
  pTab === 'basic' ? [
5665
+ h(AvatarPicker, { key: 'av', t, value: pAvatar, seed: avatarSeed(pName.trim() || profileAgent.name), onChange: setPAvatar }),
5511
5666
  h('div', { key: 'nr', className: 'at-fieldrow' },
5512
5667
  h('label', { className: 'at-field' }, h('span', null, t('memberName')),
5513
5668
  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 { AVATAR_PACKAGE, avatarOptions, renderAvatarSvg, startAvatarLib } 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';
@@ -388,6 +389,8 @@ export function apply(ctx, config = {}) {
388
389
  ctx.effect(() => {
389
390
  const webServer = serviceOf(ctx, 'webServer');
390
391
  if (webServer === undefined) return () => {};
392
+ // 头像库不随插件打包:先用本机缓存,后台从 npm 取 latest(lib/domain/avatar.js)。
393
+ const avatarLib = startAvatarLib({ dshHome: dshHome(), diag });
391
394
 
392
395
  let booted = null;
393
396
  let bootError = null;
@@ -2384,6 +2387,23 @@ export function apply(ctx, config = {}) {
2384
2387
  return send(res, { talents: listTalents(talentCatalog(diag)) });
2385
2388
  }
2386
2389
  // 第 3 步:官方在线人才库。状态 / 同步(npmmirror → jsDelivr,逐文件 sha256 校验后整体替换)/ 清除(退回内置)。
2390
+ // 头像:运行时从 npm 取来的 @suifei/hash-avatar 在本机出 SVG。界面地址带库版本(v=),
2391
+ // 同版本同参同图,可长缓存;库换版本地址就变。库还没就绪回 503,界面退回首字母。
2392
+ if (req.method === 'GET' && url.pathname === '/ai-team/api/avatar/meta') {
2393
+ const lib = await avatarLib.ready(Number(url.searchParams.get('wait') ?? 0) || 0);
2394
+ return send(res, { package: AVATAR_PACKAGE, version: lib?.version ?? null, contract: lib?.contract ?? null, syncedAt: lib?.syncedAt ?? null, ready: lib !== null, options: avatarOptions(lib) });
2395
+ }
2396
+ if (req.method === 'GET' && url.pathname === '/ai-team/api/avatar.svg') {
2397
+ await avatarLib.ready();
2398
+ const q = url.searchParams;
2399
+ const svg = renderAvatarSvg(q.get('name') ?? '', { gender: q.get('gender'), age: q.get('age'), race: q.get('race'), art: q.get('art'), size: q.get('size') });
2400
+ if (svg === null) return send(res, { error: { code: 'E_UNAVAILABLE', message: `${AVATAR_PACKAGE} 还没取到(离线或镜像不可达)` } }, 503);
2401
+ res.statusCode = 200;
2402
+ res.setHeader('content-type', 'image/svg+xml; charset=utf-8');
2403
+ res.setHeader('cache-control', q.get('v') ? 'private, max-age=31536000, immutable' : 'private, max-age=3600');
2404
+ res.setHeader('x-content-type-options', 'nosniff');
2405
+ return res.end(svg);
2406
+ }
2387
2407
  if (req.method === 'GET' && url.pathname === '/ai-team/api/catalog') {
2388
2408
  return send(res, { package: CATALOG_PACKAGE, official: publicOfficial(officialStatus(dshHome())) });
2389
2409
  }
@@ -3258,6 +3278,7 @@ export function apply(ctx, config = {}) {
3258
3278
  // composition: a racing parent-agent dispose left the previous
3259
3279
  // session-controller graph half-disposed and broke plugin toggles.
3260
3280
  disposed = true;
3281
+ try { avatarLib.dispose(); } catch { /* already disposed */ }
3261
3282
  try { removeDiagSink(); } catch { /* sink already replaced */ }
3262
3283
  try { disposeShellGuard(); } catch { /* already disposed */ }
3263
3284
  try { disposeStopGuard(); } catch { /* already disposed */ }