@agents-uni/zhenhuan 0.1.4 → 0.1.6
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 +111 -25
- package/README.md +111 -25
- package/package.json +2 -1
package/README.en.md
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
<a href="#quick-start">Quick Start</a> •
|
|
22
22
|
<a href="#competition-mechanics">Competition</a> •
|
|
23
23
|
<a href="#palace-system">Palace System</a> •
|
|
24
|
+
<a href="#group-chat-with-agents-unichat">Group Chat</a> •
|
|
24
25
|
<a href="#rest-api">API</a> •
|
|
25
26
|
<a href="./DESIGN.md">Design Doc</a>
|
|
26
27
|
</p>
|
|
@@ -74,36 +75,35 @@ Built on [@agents-uni/core](https://github.com/agents-uni/core), it models a com
|
|
|
74
75
|
|
|
75
76
|
## Quick Start
|
|
76
77
|
|
|
77
|
-
###
|
|
78
|
+
### Zero-config Experience
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
# Use as a dependency
|
|
81
|
-
npm install @agents-uni/zhenhuan
|
|
82
|
-
|
|
83
|
-
# Or clone the repo for local development
|
|
84
|
-
git clone https://github.com/agents-uni/zhenhuan.git
|
|
85
|
-
cd zhenhuan
|
|
86
|
-
npm install
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Start the server
|
|
80
|
+
Install and launch immediately — the package ships with a complete palace configuration (7 concubine agents):
|
|
90
81
|
|
|
91
82
|
```bash
|
|
92
|
-
# Global install, then use from any directory
|
|
93
83
|
npm install -g @agents-uni/zhenhuan
|
|
94
84
|
zhenhuan serve
|
|
95
85
|
|
|
96
|
-
# Or in the project directory
|
|
97
|
-
npm start
|
|
98
|
-
|
|
99
86
|
# Or with npx (no global install needed)
|
|
100
87
|
npx @agents-uni/zhenhuan serve
|
|
101
|
-
|
|
102
|
-
# Use a custom spec file
|
|
103
|
-
zhenhuan serve --spec /path/to/my-universe.yaml
|
|
104
88
|
```
|
|
105
89
|
|
|
106
|
-
> 💡
|
|
90
|
+
> 💡 `zhenhuan` CLI path resolution: first checks for `universe.yaml` in the current directory; if not found, falls back to the built-in palace configuration. You can also specify a custom path with `--spec`.
|
|
91
|
+
|
|
92
|
+
### Custom Project
|
|
93
|
+
|
|
94
|
+
If you want to modify concubine configurations, add new agents, or use group chat with `@agents-uni/chat`, create a local project:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Initialize a project (generates universe.yaml in current directory)
|
|
98
|
+
mkdir my-palace && cd my-palace
|
|
99
|
+
npx uni init my-palace --uni zhenhuan
|
|
100
|
+
|
|
101
|
+
# Edit universe.yaml to customize concubines...
|
|
102
|
+
|
|
103
|
+
# Deploy to OpenClaw and start
|
|
104
|
+
npx uni deploy
|
|
105
|
+
zhenhuan serve
|
|
106
|
+
```
|
|
107
107
|
|
|
108
108
|
On startup, it prints the access URLs:
|
|
109
109
|
|
|
@@ -416,15 +416,19 @@ universe.yaml
|
|
|
416
416
|
|
|
417
417
|
### Deploy Agents to OpenClaw
|
|
418
418
|
|
|
419
|
+
> 💡 `zhenhuan serve` auto-registers agents on startup — manual deployment is only needed when using OpenClaw workspaces without the server.
|
|
420
|
+
|
|
421
|
+
If you have a local project directory (created via `uni init` or cloned from the repo), run in that directory:
|
|
422
|
+
|
|
419
423
|
```bash
|
|
420
|
-
#
|
|
421
|
-
npx uni deploy
|
|
424
|
+
# Auto-detects universe.yaml in current directory
|
|
425
|
+
npx uni deploy
|
|
422
426
|
|
|
423
|
-
# Custom directory
|
|
424
|
-
npx uni deploy
|
|
427
|
+
# Custom OpenClaw directory
|
|
428
|
+
npx uni deploy --dir ~/.openclaw
|
|
425
429
|
|
|
426
430
|
# Dry run (preview only)
|
|
427
|
-
npx uni deploy
|
|
431
|
+
npx uni deploy --dry-run
|
|
428
432
|
```
|
|
429
433
|
|
|
430
434
|
Or use pre-built SOUL.md files (hand-tuned with richer personality descriptions):
|
|
@@ -460,6 +464,87 @@ const { dispatch, race } = await orchestrator.dispatchAndRace(
|
|
|
460
464
|
|
|
461
465
|
> 📖 Full integration tutorial: [OPENCLAW_INTEGRATION_GUIDE.md](https://github.com/agents-uni/zhenhuan/blob/main/OPENCLAW_INTEGRATION_GUIDE.md)
|
|
462
466
|
|
|
467
|
+
## Group Chat (with @agents-uni/chat)
|
|
468
|
+
|
|
469
|
+
Horse racing is the "arena"; group chat is "daily life". [@agents-uni/chat](https://github.com/agents-uni/chat) lets your concubines talk freely in a shared chat room — forming alliances, arguing, scheming — and their relationships evolve in real time based on the conversation.
|
|
470
|
+
|
|
471
|
+
### Quick Start
|
|
472
|
+
|
|
473
|
+
`agents-chat` needs to read `universe.yaml` to know which concubines exist and their relationships. You need a local project directory:
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
# 1. Initialize a palace project (generates universe.yaml)
|
|
477
|
+
mkdir my-palace && cd my-palace
|
|
478
|
+
npx uni init my-palace --uni zhenhuan
|
|
479
|
+
|
|
480
|
+
# 2. Deploy agents to OpenClaw workspaces (generates SOUL.md etc.)
|
|
481
|
+
npx uni deploy
|
|
482
|
+
|
|
483
|
+
# 3. Start group chat (auto-detects universe.yaml in current directory)
|
|
484
|
+
npx agents-chat serve
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Open `http://localhost:3000` in your browser. You are the Emperor — concubines respond automatically based on the topic.
|
|
488
|
+
|
|
489
|
+
> 💡 If you don't want to initialize a project, you can point directly to the bundled config:
|
|
490
|
+
> ```bash
|
|
491
|
+
> agents-chat serve --spec node_modules/@agents-uni/zhenhuan/universe.yaml
|
|
492
|
+
> ```
|
|
493
|
+
|
|
494
|
+
### Racing + Chat Combined
|
|
495
|
+
|
|
496
|
+
Both share the same `universe.yaml` and OpenClaw workspaces. Run them side by side from the same project directory:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
# Terminal 1: Horse racing (port 8089)
|
|
500
|
+
zhenhuan serve
|
|
501
|
+
|
|
502
|
+
# Terminal 2: Group chat (port 3000)
|
|
503
|
+
agents-chat serve
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
| Scenario | Which to use | Notes |
|
|
507
|
+
|----------|-------------|-------|
|
|
508
|
+
| Concubines compete on the same task, ELO ranking | `zhenhuan serve` | Horse race |
|
|
509
|
+
| Concubines chat freely, observe interactions | `agents-chat serve` | Group chat |
|
|
510
|
+
| Discuss approaches first, then compete on execution | Both together | Chat then race |
|
|
511
|
+
|
|
512
|
+
### Relationship Evolution in Chat
|
|
513
|
+
|
|
514
|
+
`@agents-uni/chat` includes a built-in relationship inference engine that detects signals from conversations:
|
|
515
|
+
|
|
516
|
+
- **Agreement** — trust +0.05, affinity +0.03
|
|
517
|
+
- **Disagreement** — rivalry +0.03
|
|
518
|
+
- **Collaboration** — synergy +0.05
|
|
519
|
+
- **Consensus** — trust +0.02, synergy +0.02
|
|
520
|
+
|
|
521
|
+
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.
|
|
522
|
+
|
|
523
|
+
### Programmatic Integration
|
|
524
|
+
|
|
525
|
+
```typescript
|
|
526
|
+
import { PalaceOrchestrator } from '@agents-uni/zhenhuan';
|
|
527
|
+
import { ChatEngine } from '@agents-uni/chat';
|
|
528
|
+
|
|
529
|
+
const specPath = 'universe.yaml'; // same config file
|
|
530
|
+
|
|
531
|
+
// Horse racing engine
|
|
532
|
+
const orchestrator = await PalaceOrchestrator.fromSpec(specPath);
|
|
533
|
+
|
|
534
|
+
// Group chat engine
|
|
535
|
+
const chat = new ChatEngine({
|
|
536
|
+
specPath,
|
|
537
|
+
maxRespondents: 3,
|
|
538
|
+
contextWindow: 20,
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
// Chat: let concubines discuss
|
|
542
|
+
const responses = await chat.processMessage('How should we improve palace cuisine?');
|
|
543
|
+
|
|
544
|
+
// Race: let them compete formally
|
|
545
|
+
const { race } = await orchestrator.dispatchAndRace(task, judge);
|
|
546
|
+
```
|
|
547
|
+
|
|
463
548
|
## Dashboard Integration
|
|
464
549
|
|
|
465
550
|
zhenhuan-uni integrates deeply with the agents-uni-core Dashboard, providing a unified web UI for managing the palace system.
|
|
@@ -568,6 +653,7 @@ npm run build
|
|
|
568
653
|
## Related Projects
|
|
569
654
|
|
|
570
655
|
- [**@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))
|
|
656
|
+
- [**@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))
|
|
571
657
|
|
|
572
658
|
## License
|
|
573
659
|
|
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
<a href="#快速开始">快速开始</a> •
|
|
22
22
|
<a href="#竞争机制">竞争机制</a> •
|
|
23
23
|
<a href="#后宫体系">后宫体系</a> •
|
|
24
|
+
<a href="#群聊模式配合-agents-unichat">群聊模式</a> •
|
|
24
25
|
<a href="#rest-api">API</a> •
|
|
25
26
|
<a href="./DESIGN.md">设计文档</a>
|
|
26
27
|
</p>
|
|
@@ -74,36 +75,35 @@
|
|
|
74
75
|
|
|
75
76
|
## 快速开始
|
|
76
77
|
|
|
77
|
-
###
|
|
78
|
+
### 零配置体验
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
# 作为依赖使用
|
|
81
|
-
npm install @agents-uni/zhenhuan
|
|
82
|
-
|
|
83
|
-
# 或克隆仓库本地开发
|
|
84
|
-
git clone https://github.com/agents-uni/zhenhuan.git
|
|
85
|
-
cd zhenhuan
|
|
86
|
-
npm install
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### 启动服务器
|
|
80
|
+
安装后直接启动,包自带完整的甄嬛后宫配置(7 个嫔妃 Agent):
|
|
90
81
|
|
|
91
82
|
```bash
|
|
92
|
-
# 全局安装后,在任意目录直接使用
|
|
93
83
|
npm install -g @agents-uni/zhenhuan
|
|
94
84
|
zhenhuan serve
|
|
95
85
|
|
|
96
|
-
# 或在项目目录中
|
|
97
|
-
npm start
|
|
98
|
-
|
|
99
86
|
# 或用 npx(无需全局安装)
|
|
100
87
|
npx @agents-uni/zhenhuan serve
|
|
101
|
-
|
|
102
|
-
# 使用自定义规范文件
|
|
103
|
-
zhenhuan serve --spec /path/to/my-universe.yaml
|
|
104
88
|
```
|
|
105
89
|
|
|
106
|
-
> 💡
|
|
90
|
+
> 💡 `zhenhuan` CLI 的路径解析逻辑:优先使用当前目录的 `universe.yaml`,找不到时自动回退到包自带的默认后宫配置。你也可以通过 `--spec` 显式指定。
|
|
91
|
+
|
|
92
|
+
### 自定义项目
|
|
93
|
+
|
|
94
|
+
如果你想修改嫔妃配置、添加新 Agent,或配合 `@agents-uni/chat` 群聊使用,需要在本地建一个项目:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 初始化项目(生成 universe.yaml 到当前目录)
|
|
98
|
+
mkdir my-palace && cd my-palace
|
|
99
|
+
npx uni init my-palace --uni zhenhuan
|
|
100
|
+
|
|
101
|
+
# 编辑 universe.yaml 自定义嫔妃...
|
|
102
|
+
|
|
103
|
+
# 部署到 OpenClaw 并启动
|
|
104
|
+
npx uni deploy
|
|
105
|
+
zhenhuan serve
|
|
106
|
+
```
|
|
107
107
|
|
|
108
108
|
启动后会打印访问链接:
|
|
109
109
|
|
|
@@ -416,15 +416,19 @@ universe.yaml
|
|
|
416
416
|
|
|
417
417
|
### 部署 Agent 到 OpenClaw
|
|
418
418
|
|
|
419
|
+
> 💡 `zhenhuan serve` 会自动注册 Agent,无需手动部署。只有在你想单独使用 OpenClaw 工作区(不启动服务器)时才需要手动部署。
|
|
420
|
+
|
|
421
|
+
如果你有本地项目目录(通过 `uni init` 创建,或克隆仓库),在该目录下运行:
|
|
422
|
+
|
|
419
423
|
```bash
|
|
420
|
-
#
|
|
421
|
-
npx uni deploy
|
|
424
|
+
# 自动读取当前目录的 universe.yaml
|
|
425
|
+
npx uni deploy
|
|
422
426
|
|
|
423
|
-
#
|
|
424
|
-
npx uni deploy
|
|
427
|
+
# 指定 OpenClaw 目录
|
|
428
|
+
npx uni deploy --dir ~/.openclaw
|
|
425
429
|
|
|
426
430
|
# 预览(不实际写入)
|
|
427
|
-
npx uni deploy
|
|
431
|
+
npx uni deploy --dry-run
|
|
428
432
|
```
|
|
429
433
|
|
|
430
434
|
或使用预置 SOUL.md(手工调优版,包含更丰富的性格描写):
|
|
@@ -460,6 +464,87 @@ const { dispatch, race } = await orchestrator.dispatchAndRace(
|
|
|
460
464
|
|
|
461
465
|
> 📖 详细整合教程见 [OPENCLAW_INTEGRATION_GUIDE.md](https://github.com/agents-uni/zhenhuan/blob/main/OPENCLAW_INTEGRATION_GUIDE.md)
|
|
462
466
|
|
|
467
|
+
## 群聊模式(配合 @agents-uni/chat)
|
|
468
|
+
|
|
469
|
+
赛马竞技是"比武",群聊是"日常"。[@agents-uni/chat](https://github.com/agents-uni/chat) 让后宫嫔妃们在同一个聊天室自由对话——结盟、争吵、密谋都会自然发生,关系随对话内容实时演化。
|
|
470
|
+
|
|
471
|
+
### 快速启动
|
|
472
|
+
|
|
473
|
+
`agents-chat` 需要读取 `universe.yaml` 来了解有哪些嫔妃以及她们之间的关系。你需要先在本地建一个项目目录:
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
# 1. 初始化后宫项目(会生成 universe.yaml 到当前目录)
|
|
477
|
+
mkdir my-palace && cd my-palace
|
|
478
|
+
npx uni init my-palace --uni zhenhuan
|
|
479
|
+
|
|
480
|
+
# 2. 部署 Agent 到 OpenClaw 工作区(生成 SOUL.md 等文件)
|
|
481
|
+
npx uni deploy
|
|
482
|
+
|
|
483
|
+
# 3. 启动群聊(自动读取当前目录的 universe.yaml)
|
|
484
|
+
npx agents-chat serve
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
浏览器打开 `http://localhost:3000`,你就是皇帝,嫔妃们根据话题自动应答。
|
|
488
|
+
|
|
489
|
+
> 💡 如果不想初始化项目,也可以用 `--spec` 直接指向包自带的配置:
|
|
490
|
+
> ```bash
|
|
491
|
+
> agents-chat serve --spec node_modules/@agents-uni/zhenhuan/universe.yaml
|
|
492
|
+
> ```
|
|
493
|
+
|
|
494
|
+
### 赛马 + 群聊 配合使用
|
|
495
|
+
|
|
496
|
+
两者共享同一个 `universe.yaml` 和 OpenClaw 工作区,在同一个项目目录下交替使用:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
# 终端 1:赛马竞技(端口 8089)
|
|
500
|
+
zhenhuan serve
|
|
501
|
+
|
|
502
|
+
# 终端 2:群聊模式(端口 3000)
|
|
503
|
+
agents-chat serve
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
| 场景 | 用哪个 | 说明 |
|
|
507
|
+
|------|--------|------|
|
|
508
|
+
| 让嫔妃们竞争同一任务、ELO 排名 | `zhenhuan serve` | 赛马竞技 |
|
|
509
|
+
| 让嫔妃们自由对话、观察互动 | `agents-chat serve` | 群聊模式 |
|
|
510
|
+
| 先群聊讨论方案,再赛马比拼执行 | 两者同时 | 先聊后赛 |
|
|
511
|
+
|
|
512
|
+
### 群聊中的关系演化
|
|
513
|
+
|
|
514
|
+
`@agents-uni/chat` 内置关系推理引擎,从对话中自动检测:
|
|
515
|
+
|
|
516
|
+
- **赞同** — 信任度 +0.05,亲密度 +0.03
|
|
517
|
+
- **反对** — 竞争度 +0.03
|
|
518
|
+
- **协作** — 协同度 +0.05
|
|
519
|
+
- **共识** — 信任度 +0.02,协同度 +0.02
|
|
520
|
+
|
|
521
|
+
这些变化实时反映在聊天界面的关系图谱中。配合赛马的 ELO 排名,你可以全方位观察嫔妃们的能力和社交动态。
|
|
522
|
+
|
|
523
|
+
### 编程式集成
|
|
524
|
+
|
|
525
|
+
```typescript
|
|
526
|
+
import { PalaceOrchestrator } from '@agents-uni/zhenhuan';
|
|
527
|
+
import { ChatEngine } from '@agents-uni/chat';
|
|
528
|
+
|
|
529
|
+
const specPath = 'universe.yaml'; // 同一份配置文件
|
|
530
|
+
|
|
531
|
+
// 赛马引擎
|
|
532
|
+
const orchestrator = await PalaceOrchestrator.fromSpec(specPath);
|
|
533
|
+
|
|
534
|
+
// 群聊引擎
|
|
535
|
+
const chat = new ChatEngine({
|
|
536
|
+
specPath,
|
|
537
|
+
maxRespondents: 3,
|
|
538
|
+
contextWindow: 20,
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
// 群聊:让嫔妃们讨论
|
|
542
|
+
const responses = await chat.processMessage('各位觉得如何提升后宫膳食质量?');
|
|
543
|
+
|
|
544
|
+
// 赛马:让她们正式比拼
|
|
545
|
+
const { race } = await orchestrator.dispatchAndRace(task, judge);
|
|
546
|
+
```
|
|
547
|
+
|
|
463
548
|
## Dashboard 集成
|
|
464
549
|
|
|
465
550
|
zhenhuan-uni 内置了 agents-uni-core 的 Dashboard,启动服务后直接访问首页即可。
|
|
@@ -570,6 +655,7 @@ npm run build
|
|
|
570
655
|
## 相关项目
|
|
571
656
|
|
|
572
657
|
- [**@agents-uni/core**](https://github.com/agents-uni/core) — 本项目底层的通用 Agent 组织协议层 ([npm](https://www.npmjs.com/package/@agents-uni/core))
|
|
658
|
+
- [**@agents-uni/chat**](https://github.com/agents-uni/chat) — 群聊服务,让 Agent 们在浏览器中自由对话,关系实时演化 ([npm](https://www.npmjs.com/package/@agents-uni/chat))
|
|
573
659
|
|
|
574
660
|
## License
|
|
575
661
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agents-uni/zhenhuan",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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",
|