@agents-uni/zhenhuan 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -2,6 +2,9 @@
2
2
  [![npm version](https://img.shields.io/npm/v/@agents-uni/zhenhuan.svg)](https://www.npmjs.com/package/@agents-uni/zhenhuan)
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
4
 
5
+ <p align="center">
6
+ <img src="assets/logo.png" alt="Agents Uni" width="120" />
7
+ </p>
5
8
  <p align="center">
6
9
  <h1 align="center">zhenhuan-uni</h1>
7
10
  <p align="center">
@@ -18,6 +21,7 @@
18
21
  <a href="#quick-start">Quick Start</a> &bull;
19
22
  <a href="#competition-mechanics">Competition</a> &bull;
20
23
  <a href="#palace-system">Palace System</a> &bull;
24
+ <a href="#group-chat-with-agents-unichat">Group Chat</a> &bull;
21
25
  <a href="#rest-api">API</a> &bull;
22
26
  <a href="./DESIGN.md">Design Doc</a>
23
27
  </p>
@@ -457,6 +461,71 @@ const { dispatch, race } = await orchestrator.dispatchAndRace(
457
461
 
458
462
  > 📖 Full integration tutorial: [OPENCLAW_INTEGRATION_GUIDE.md](https://github.com/agents-uni/zhenhuan/blob/main/OPENCLAW_INTEGRATION_GUIDE.md)
459
463
 
464
+ ## Group Chat (with @agents-uni/chat)
465
+
466
+ Horse racing is the "arena"; group chat is "daily life". With [@agents-uni/chat](https://github.com/agents-uni/chat), your concubines can talk freely in a shared chat room — forming alliances, arguing, scheming — and their relationships evolve in real time based on the conversation.
467
+
468
+ ### Quick Start
469
+
470
+ ```bash
471
+ # Install the chat package
472
+ npm install -g @agents-uni/chat
473
+
474
+ # Deploy agents first (if not already deployed)
475
+ uni deploy
476
+
477
+ # Start group chat in the directory containing universe.yaml
478
+ agents-chat serve
479
+ # Or specify the config file
480
+ agents-chat serve --spec /path/to/universe.yaml
481
+ ```
482
+
483
+ Open `http://localhost:3000` in your browser. You are the Emperor — concubines respond automatically based on the topic.
484
+
485
+ ### Racing + Chat Combined
486
+
487
+ Both share the same `universe.yaml` and OpenClaw workspaces, and can be used simultaneously or alternately:
488
+
489
+ | Scenario | Which to use | Command |
490
+ |----------|-------------|---------|
491
+ | Concubines compete on the same task, ELO ranking | `zhenhuan serve` | Horse race |
492
+ | Concubines chat freely, observe interactions | `agents-chat serve` | Group chat |
493
+ | Discuss approaches first, then compete on execution | Both alternately | Chat then race |
494
+
495
+ ### Relationship Evolution in Chat
496
+
497
+ `@agents-uni/chat` includes a built-in relationship inference engine that detects signals from conversations:
498
+
499
+ - **Agreement** — trust +0.05, affinity +0.03
500
+ - **Disagreement** — rivalry +0.03
501
+ - **Collaboration** — synergy +0.05
502
+ - **Consensus** — trust +0.02, synergy +0.02
503
+
504
+ These changes are reflected in real time on the chat UI's relationship graph. Combined with ELO rankings from horse racing, you get a full picture of each concubine's ability and social dynamics.
505
+
506
+ ### Programmatic Integration
507
+
508
+ ```typescript
509
+ import { PalaceOrchestrator } from '@agents-uni/zhenhuan';
510
+ import { ChatEngine } from '@agents-uni/chat';
511
+
512
+ // Initialize the palace
513
+ const orchestrator = await PalaceOrchestrator.fromSpec('universe.yaml');
514
+
515
+ // Start chat engine with the same config
516
+ const chat = new ChatEngine({
517
+ specPath: 'universe.yaml',
518
+ maxRespondents: 3,
519
+ contextWindow: 20,
520
+ });
521
+
522
+ // Chat: let concubines discuss
523
+ const responses = await chat.processMessage('How should we improve palace cuisine?');
524
+
525
+ // Race: let them compete formally
526
+ const { race } = await orchestrator.dispatchAndRace(task, judge);
527
+ ```
528
+
460
529
  ## Dashboard Integration
461
530
 
462
531
  zhenhuan-uni integrates deeply with the agents-uni-core Dashboard, providing a unified web UI for managing the palace system.
@@ -565,6 +634,7 @@ npm run build
565
634
  ## Related Projects
566
635
 
567
636
  - [**@agents-uni/core**](https://github.com/agents-uni/core) — The universal protocol layer this project is built on ([npm](https://www.npmjs.com/package/@agents-uni/core))
637
+ - [**@agents-uni/chat**](https://github.com/agents-uni/chat) — Group chat service for agent universes with real-time relationship evolution ([npm](https://www.npmjs.com/package/@agents-uni/chat))
568
638
 
569
639
  ## License
570
640
 
package/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
  [![npm version](https://img.shields.io/npm/v/@agents-uni/zhenhuan.svg)](https://www.npmjs.com/package/@agents-uni/zhenhuan)
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
4
 
5
+ <p align="center">
6
+ <img src="assets/logo.png" alt="Agents Uni" width="120" />
7
+ </p>
5
8
  <p align="center">
6
9
  <h1 align="center">zhenhuan-uni</h1>
7
10
  <p align="center">
@@ -18,6 +21,7 @@
18
21
  <a href="#快速开始">快速开始</a> &bull;
19
22
  <a href="#竞争机制">竞争机制</a> &bull;
20
23
  <a href="#后宫体系">后宫体系</a> &bull;
24
+ <a href="#群聊模式配合-agents-unichat">群聊模式</a> &bull;
21
25
  <a href="#rest-api">API</a> &bull;
22
26
  <a href="./DESIGN.md">设计文档</a>
23
27
  </p>
@@ -457,6 +461,71 @@ const { dispatch, race } = await orchestrator.dispatchAndRace(
457
461
 
458
462
  > 📖 详细整合教程见 [OPENCLAW_INTEGRATION_GUIDE.md](https://github.com/agents-uni/zhenhuan/blob/main/OPENCLAW_INTEGRATION_GUIDE.md)
459
463
 
464
+ ## 群聊模式(配合 @agents-uni/chat)
465
+
466
+ 赛马竞技是"比武",群聊是"日常"。通过 [@agents-uni/chat](https://github.com/agents-uni/chat) 可以让后宫嫔妃们在同一个聊天室里自由对话——结盟、争吵、密谋都会自然发生,关系也会随对话内容实时演化。
467
+
468
+ ### 快速启动
469
+
470
+ ```bash
471
+ # 安装 chat 包
472
+ npm install -g @agents-uni/chat
473
+
474
+ # 先部署 Agent(如果还没部署过)
475
+ uni deploy
476
+
477
+ # 在甄嬛后宫的 universe.yaml 目录下启动群聊
478
+ agents-chat serve
479
+ # 或指定配置文件
480
+ agents-chat serve --spec /path/to/universe.yaml
481
+ ```
482
+
483
+ 浏览器打开 `http://localhost:3000`,你就是皇帝,嫔妃们会根据话题自动应答。
484
+
485
+ ### 赛马 + 群聊 配合使用
486
+
487
+ 两者共享同一个 `universe.yaml` 和 OpenClaw 工作区,可以同时或交替使用:
488
+
489
+ | 场景 | 用哪个 | 命令 |
490
+ |------|--------|------|
491
+ | 让嫔妃们竞争同一任务、ELO 排名 | `zhenhuan serve` | 赛马竞技 |
492
+ | 让嫔妃们自由对话、观察互动 | `agents-chat serve` | 群聊模式 |
493
+ | 先群聊讨论方案,再赛马比拼执行 | 两者交替 | 先聊后赛 |
494
+
495
+ ### 群聊中的关系演化
496
+
497
+ `@agents-uni/chat` 内置了关系推理引擎,会从对话中自动检测:
498
+
499
+ - **赞同** — 信任度 +0.05,亲密度 +0.03
500
+ - **反对** — 竞争度 +0.03
501
+ - **协作** — 协同度 +0.05
502
+ - **共识** — 信任度 +0.02,协同度 +0.02
503
+
504
+ 这些关系变化会实时反映在聊天界面的关系图谱中。配合赛马的 ELO 排名,你可以全方位观察嫔妃们的能力和社交动态。
505
+
506
+ ### 编程式集成
507
+
508
+ ```typescript
509
+ import { PalaceOrchestrator } from '@agents-uni/zhenhuan';
510
+ import { ChatEngine } from '@agents-uni/chat';
511
+
512
+ // 先初始化后宫
513
+ const orchestrator = await PalaceOrchestrator.fromSpec('universe.yaml');
514
+
515
+ // 用同一份配置启动群聊引擎
516
+ const chat = new ChatEngine({
517
+ specPath: 'universe.yaml',
518
+ maxRespondents: 3,
519
+ contextWindow: 20,
520
+ });
521
+
522
+ // 群聊:让嫔妃们讨论
523
+ const responses = await chat.processMessage('各位觉得如何提升后宫膳食质量?');
524
+
525
+ // 赛马:让她们正式比拼
526
+ const { race } = await orchestrator.dispatchAndRace(task, judge);
527
+ ```
528
+
460
529
  ## Dashboard 集成
461
530
 
462
531
  zhenhuan-uni 内置了 agents-uni-core 的 Dashboard,启动服务后直接访问首页即可。
@@ -567,6 +636,7 @@ npm run build
567
636
  ## 相关项目
568
637
 
569
638
  - [**@agents-uni/core**](https://github.com/agents-uni/core) — 本项目底层的通用 Agent 组织协议层 ([npm](https://www.npmjs.com/package/@agents-uni/core))
639
+ - [**@agents-uni/chat**](https://github.com/agents-uni/chat) — 群聊服务,让 Agent 们在浏览器中自由对话,关系实时演化 ([npm](https://www.npmjs.com/package/@agents-uni/chat))
570
640
 
571
641
  ## License
572
642
 
package/dist/cli/index.js CHANGED
@@ -7,6 +7,7 @@ import chalk from 'chalk';
7
7
  import { resolve, dirname, join } from 'node:path';
8
8
  import { existsSync } from 'node:fs';
9
9
  import { fileURLToPath } from 'node:url';
10
+ import { createRequire } from 'node:module';
10
11
  import { PalaceOrchestrator } from '../orchestrator/index.js';
11
12
  import { startServer } from '../server/index.js';
12
13
  /**
@@ -14,6 +15,7 @@ import { startServer } from '../server/index.js';
14
15
  * 1. 用户显式指定 --spec → 直接用
15
16
  * 2. CWD 下存在 universe.yaml → 用它
16
17
  * 3. fallback 到包自带的 universe.yaml(全局安装场景)
18
+ * 4. fallback 到 @agents-uni/unis/zhenhuan/universe.yaml(如果安装了)
17
19
  */
18
20
  function resolveSpec(specOpt) {
19
21
  // 用户显式传了绝对路径或非默认值
@@ -32,6 +34,19 @@ function resolveSpec(specOpt) {
32
34
  console.log(chalk.gray(` ℹ 使用内置 universe.yaml (${bundledSpec})`));
33
35
  return bundledSpec;
34
36
  }
37
+ // fallback: @agents-uni/unis 中的 zhenhuan 模板
38
+ try {
39
+ const require = createRequire(import.meta.url);
40
+ const unisPkgPath = require.resolve('@agents-uni/unis/package.json');
41
+ const unisSpec = join(dirname(unisPkgPath), 'zhenhuan', 'universe.yaml');
42
+ if (existsSync(unisSpec)) {
43
+ console.log(chalk.gray(` ℹ 使用 @agents-uni/unis 模板 (${unisSpec})`));
44
+ return unisSpec;
45
+ }
46
+ }
47
+ catch {
48
+ // @agents-uni/unis not installed — skip
49
+ }
35
50
  // 都找不到,返回原始路径(让后续报一个清晰的错误)
36
51
  return cwdSpec;
37
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agents-uni/zhenhuan",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Zhen Huan palace drama themed agent competition system built on @agents-uni/core",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,6 +26,7 @@
26
26
  "scripts": {
27
27
  "build": "tsc",
28
28
  "test": "vitest run",
29
+ "lint": "tsc --noEmit",
29
30
  "dev": "tsx --watch src/cli/index.ts serve",
30
31
  "start": "tsx src/cli/index.ts serve",
31
32
  "serve": "tsx src/cli/index.ts serve",
@@ -52,12 +53,15 @@
52
53
  "url": "https://github.com/agents-uni/zhenhuan/issues"
53
54
  },
54
55
  "dependencies": {
55
- "@agents-uni/core": "^0.2.0",
56
+ "@agents-uni/core": "^0.3.0",
56
57
  "@hono/node-server": "^1.13.0",
57
58
  "chalk": "^5.3.0",
58
59
  "commander": "^12.1.0",
59
60
  "hono": "^4.6.0"
60
61
  },
62
+ "optionalDependencies": {
63
+ "@agents-uni/unis": "^0.1.0"
64
+ },
61
65
  "devDependencies": {
62
66
  "@types/node": "^22.10.0",
63
67
  "tsx": "^4.19.2",