@agents-uni/zhenhuan 0.1.5 → 0.1.7
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 +144 -46
- package/README.md +146 -48
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
<a href="#palace-system">Palace System</a> •
|
|
24
24
|
<a href="#group-chat-with-agents-unichat">Group Chat</a> •
|
|
25
25
|
<a href="#rest-api">API</a> •
|
|
26
|
+
<a href="#ecosystem">Ecosystem</a> •
|
|
26
27
|
<a href="./DESIGN.md">Design Doc</a>
|
|
27
28
|
</p>
|
|
28
29
|
|
|
@@ -75,36 +76,35 @@ Built on [@agents-uni/core](https://github.com/agents-uni/core), it models a com
|
|
|
75
76
|
|
|
76
77
|
## Quick Start
|
|
77
78
|
|
|
78
|
-
###
|
|
79
|
+
### Zero-config Experience
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
# Use as a dependency
|
|
82
|
-
npm install @agents-uni/zhenhuan
|
|
83
|
-
|
|
84
|
-
# Or clone the repo for local development
|
|
85
|
-
git clone https://github.com/agents-uni/zhenhuan.git
|
|
86
|
-
cd zhenhuan
|
|
87
|
-
npm install
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Start the server
|
|
81
|
+
Install and launch immediately — the package ships with a complete palace configuration (7 concubine agents):
|
|
91
82
|
|
|
92
83
|
```bash
|
|
93
|
-
# Global install, then use from any directory
|
|
94
84
|
npm install -g @agents-uni/zhenhuan
|
|
95
85
|
zhenhuan serve
|
|
96
86
|
|
|
97
|
-
# Or in the project directory
|
|
98
|
-
npm start
|
|
99
|
-
|
|
100
87
|
# Or with npx (no global install needed)
|
|
101
88
|
npx @agents-uni/zhenhuan serve
|
|
102
|
-
|
|
103
|
-
# Use a custom spec file
|
|
104
|
-
zhenhuan serve --spec /path/to/my-universe.yaml
|
|
105
89
|
```
|
|
106
90
|
|
|
107
|
-
> 💡
|
|
91
|
+
> 💡 `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`.
|
|
92
|
+
|
|
93
|
+
### Custom Project
|
|
94
|
+
|
|
95
|
+
If you want to modify concubine configurations, add new agents, or use group chat with `@agents-uni/chat`, create a local project:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Initialize a project (generates universe.yaml in current directory)
|
|
99
|
+
mkdir my-palace && cd my-palace
|
|
100
|
+
npx uni init my-palace --uni zhenhuan
|
|
101
|
+
|
|
102
|
+
# Edit universe.yaml to customize concubines...
|
|
103
|
+
|
|
104
|
+
# Deploy to OpenClaw and start
|
|
105
|
+
npx uni deploy
|
|
106
|
+
zhenhuan serve
|
|
107
|
+
```
|
|
108
108
|
|
|
109
109
|
On startup, it prints the access URLs:
|
|
110
110
|
|
|
@@ -417,15 +417,19 @@ universe.yaml
|
|
|
417
417
|
|
|
418
418
|
### Deploy Agents to OpenClaw
|
|
419
419
|
|
|
420
|
+
> 💡 `zhenhuan serve` auto-registers agents on startup — manual deployment is only needed when using OpenClaw workspaces without the server.
|
|
421
|
+
|
|
422
|
+
If you have a local project directory (created via `uni init` or cloned from the repo), run in that directory:
|
|
423
|
+
|
|
420
424
|
```bash
|
|
421
|
-
#
|
|
422
|
-
npx uni deploy
|
|
425
|
+
# Auto-detects universe.yaml in current directory
|
|
426
|
+
npx uni deploy
|
|
423
427
|
|
|
424
|
-
# Custom directory
|
|
425
|
-
npx uni deploy
|
|
428
|
+
# Custom OpenClaw directory
|
|
429
|
+
npx uni deploy --dir ~/.openclaw
|
|
426
430
|
|
|
427
431
|
# Dry run (preview only)
|
|
428
|
-
npx uni deploy
|
|
432
|
+
npx uni deploy --dry-run
|
|
429
433
|
```
|
|
430
434
|
|
|
431
435
|
Or use pre-built SOUL.md files (hand-tuned with richer personality descriptions):
|
|
@@ -459,38 +463,52 @@ const { dispatch, race } = await orchestrator.dispatchAndRace(
|
|
|
459
463
|
// POST /api/race/dispatch
|
|
460
464
|
```
|
|
461
465
|
|
|
462
|
-
> 📖
|
|
466
|
+
> 📖 Design philosophy and architecture decisions: [DESIGN.md](./DESIGN.md)
|
|
463
467
|
|
|
464
468
|
## Group Chat (with @agents-uni/chat)
|
|
465
469
|
|
|
466
|
-
Horse racing is the "arena"; group chat is "daily life".
|
|
470
|
+
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.
|
|
467
471
|
|
|
468
472
|
### Quick Start
|
|
469
473
|
|
|
474
|
+
`agents-chat` needs to read `universe.yaml` to know which concubines exist and their relationships. You need a local project directory:
|
|
475
|
+
|
|
470
476
|
```bash
|
|
471
|
-
#
|
|
472
|
-
|
|
477
|
+
# 1. Initialize a palace project (generates universe.yaml)
|
|
478
|
+
mkdir my-palace && cd my-palace
|
|
479
|
+
npx uni init my-palace --uni zhenhuan
|
|
473
480
|
|
|
474
|
-
# Deploy agents
|
|
475
|
-
uni deploy
|
|
481
|
+
# 2. Deploy agents to OpenClaw workspaces (generates SOUL.md etc.)
|
|
482
|
+
npx uni deploy
|
|
476
483
|
|
|
477
|
-
# Start group chat in
|
|
478
|
-
agents-chat serve
|
|
479
|
-
# Or specify the config file
|
|
480
|
-
agents-chat serve --spec /path/to/universe.yaml
|
|
484
|
+
# 3. Start group chat (auto-detects universe.yaml in current directory)
|
|
485
|
+
npx agents-chat serve
|
|
481
486
|
```
|
|
482
487
|
|
|
483
488
|
Open `http://localhost:3000` in your browser. You are the Emperor — concubines respond automatically based on the topic.
|
|
484
489
|
|
|
490
|
+
> 💡 If you don't want to initialize a project, you can point directly to the bundled config:
|
|
491
|
+
> ```bash
|
|
492
|
+
> agents-chat serve --spec node_modules/@agents-uni/zhenhuan/universe.yaml
|
|
493
|
+
> ```
|
|
494
|
+
|
|
485
495
|
### Racing + Chat Combined
|
|
486
496
|
|
|
487
|
-
Both share the same `universe.yaml` and OpenClaw workspaces
|
|
497
|
+
Both share the same `universe.yaml` and OpenClaw workspaces. Run them side by side from the same project directory:
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
# Terminal 1: Horse racing (port 8089)
|
|
501
|
+
zhenhuan serve
|
|
488
502
|
|
|
489
|
-
|
|
490
|
-
|
|
503
|
+
# Terminal 2: Group chat (port 3000)
|
|
504
|
+
agents-chat serve
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
| Scenario | Which to use | Notes |
|
|
508
|
+
|----------|-------------|-------|
|
|
491
509
|
| Concubines compete on the same task, ELO ranking | `zhenhuan serve` | Horse race |
|
|
492
510
|
| Concubines chat freely, observe interactions | `agents-chat serve` | Group chat |
|
|
493
|
-
| Discuss approaches first, then compete on execution | Both
|
|
511
|
+
| Discuss approaches first, then compete on execution | Both together | Chat then race |
|
|
494
512
|
|
|
495
513
|
### Relationship Evolution in Chat
|
|
496
514
|
|
|
@@ -509,12 +527,14 @@ These changes are reflected in real time on the chat UI's relationship graph. Co
|
|
|
509
527
|
import { PalaceOrchestrator } from '@agents-uni/zhenhuan';
|
|
510
528
|
import { ChatEngine } from '@agents-uni/chat';
|
|
511
529
|
|
|
512
|
-
//
|
|
513
|
-
|
|
530
|
+
const specPath = 'universe.yaml'; // same config file
|
|
531
|
+
|
|
532
|
+
// Horse racing engine
|
|
533
|
+
const orchestrator = await PalaceOrchestrator.fromSpec(specPath);
|
|
514
534
|
|
|
515
|
-
//
|
|
535
|
+
// Group chat engine
|
|
516
536
|
const chat = new ChatEngine({
|
|
517
|
-
specPath
|
|
537
|
+
specPath,
|
|
518
538
|
maxRespondents: 3,
|
|
519
539
|
contextWindow: 20,
|
|
520
540
|
});
|
|
@@ -631,10 +651,88 @@ npm run dev
|
|
|
631
651
|
npm run build
|
|
632
652
|
```
|
|
633
653
|
|
|
634
|
-
##
|
|
654
|
+
## Ecosystem
|
|
655
|
+
|
|
656
|
+
zhenhuan-uni is the flagship application of the agents-uni ecosystem, demonstrating how to build a complete agent competition system on top of the protocol layer.
|
|
657
|
+
|
|
658
|
+
```
|
|
659
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
660
|
+
│ agents-uni Ecosystem Overview │
|
|
661
|
+
│ │
|
|
662
|
+
│ @agents-uni/core Protocol layer │
|
|
663
|
+
│ ├── Universe Spec (universe.yaml parsing/validation│
|
|
664
|
+
│ ├── Agent Registry (registration, discovery, lifecycle│
|
|
665
|
+
│ ├── Relationship Graph(graph modeling, BFS factions) │
|
|
666
|
+
│ ├── State Machine (protocol state machines) │
|
|
667
|
+
│ ├── EventBus (event-driven communication) │
|
|
668
|
+
│ ├── TaskDispatcher (TASK.md → SUBMISSION.md dispatch)│
|
|
669
|
+
│ ├── Dashboard (Web UI + extension mechanism) │
|
|
670
|
+
│ └── CLI: uni (init/deploy/validate/inspect) │
|
|
671
|
+
│ │
|
|
672
|
+
│ @agents-uni/zhenhuan ←── Competition layer (this project) │
|
|
673
|
+
│ ├── ELO Arena (ELO scoring, K-factor, floor) │
|
|
674
|
+
│ ├── Horse Race Engine (multi-agent same-task competition│
|
|
675
|
+
│ ├── Palace System (ranks, resources, factions, exile│
|
|
676
|
+
│ ├── Season System (seasons, court assemblies) │
|
|
677
|
+
│ └── CLI: zhenhuan (serve/status/leaderboard/court) │
|
|
678
|
+
│ │
|
|
679
|
+
│ @agents-uni/chat Social layer │
|
|
680
|
+
│ ├── Multi-agent Chat (topic-driven, auto-respond) │
|
|
681
|
+
│ ├── Relationship Engine(infer trust/rivalry from chat) │
|
|
682
|
+
│ └── Live Relationship Graph (browser visualization) │
|
|
683
|
+
│ │
|
|
684
|
+
│ @agents-uni/rel Relationship layer │
|
|
685
|
+
│ └── Multi-dim Relations(trust, rivalry, affinity, etc.) │
|
|
686
|
+
│ │
|
|
687
|
+
│ @agents-uni/unis Template layer │
|
|
688
|
+
│ └── Arena/Corp/Military/Flat... (universe.yaml templates│
|
|
689
|
+
│ │
|
|
690
|
+
│ OpenClaw Runtime layer │
|
|
691
|
+
│ └── File Protocol (SOUL.md / TASK.md / SUBMISSION.md│
|
|
692
|
+
└─────────────────────────────────────────────────────────────┘
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
### Package Relationships
|
|
696
|
+
|
|
697
|
+
| Package | Role | How zhenhuan uses it |
|
|
698
|
+
|---|---|---|
|
|
699
|
+
| [@agents-uni/core](https://github.com/agents-uni/core) | Protocol foundation | Universe parsing, Agent registry, TaskDispatcher, Dashboard, CLI (`uni`) |
|
|
700
|
+
| [@agents-uni/chat](https://github.com/agents-uni/chat) | Chat engine | Shares `universe.yaml`, concubines chat freely, relationships evolve in real time |
|
|
701
|
+
| [@agents-uni/rel](https://github.com/agents-uni/rel) | Relationship modeling | Multi-dimensional relations (trust/rivalry/affinity/synergy), used internally by core and chat |
|
|
702
|
+
| [@agents-uni/unis](https://github.com/agents-uni/unis) | Org templates | `uni init --uni zhenhuan` pulls palace config from the template library |
|
|
703
|
+
| [OpenClaw](https://github.com/anthropics/openclaw) | Agent runtime | File protocol: SOUL.md (identity) → TASK.md (task) → SUBMISSION.md (output) |
|
|
704
|
+
|
|
705
|
+
### End-to-End Workflow
|
|
706
|
+
|
|
707
|
+
```bash
|
|
708
|
+
# 1. Initialize — pull a universe.yaml template from @agents-uni/unis
|
|
709
|
+
npx uni init my-palace --uni zhenhuan
|
|
710
|
+
|
|
711
|
+
# 2. Deploy — core CLI compiles universe.yaml into SOUL.md files in OpenClaw
|
|
712
|
+
npx uni deploy
|
|
713
|
+
|
|
714
|
+
# 3. Start racing — zhenhuan's competition engine begins dispatching
|
|
715
|
+
zhenhuan serve # port 8089
|
|
716
|
+
|
|
717
|
+
# 4. Start group chat (optional) — chat reads the same universe.yaml
|
|
718
|
+
npx agents-chat serve # port 3000
|
|
719
|
+
|
|
720
|
+
# 5. Validate / inspect / visualize — core CLI tools
|
|
721
|
+
npx uni validate # validate universe.yaml
|
|
722
|
+
npx uni inspect # view agent details
|
|
723
|
+
npx uni visualize # visualize relationship graph
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
### Building Your Own Uni on Core
|
|
727
|
+
|
|
728
|
+
zhenhuan-uni itself is the best reference implementation. Key steps:
|
|
729
|
+
|
|
730
|
+
1. **Define `universe.yaml`** — refer to [core's spec docs](https://github.com/agents-uni/core#universe-spec) or zhenhuan's `universe.yaml` as a template
|
|
731
|
+
2. **Implement competition/collaboration logic** — using core's `TaskDispatcher`, `PerformanceTracker`, `EventBus` primitives
|
|
732
|
+
3. **Deploy to OpenClaw** — `uni deploy` auto-generates SOUL.md and registers agents
|
|
733
|
+
4. **Extend the Dashboard** — inject custom panels via the `DashboardExtension` interface
|
|
635
734
|
|
|
636
|
-
|
|
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))
|
|
735
|
+
For detailed architecture and design decisions, see [DESIGN.md](./DESIGN.md).
|
|
638
736
|
|
|
639
737
|
## License
|
|
640
738
|
|
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
<a href="#后宫体系">后宫体系</a> •
|
|
24
24
|
<a href="#群聊模式配合-agents-unichat">群聊模式</a> •
|
|
25
25
|
<a href="#rest-api">API</a> •
|
|
26
|
+
<a href="#生态系统">生态系统</a> •
|
|
26
27
|
<a href="./DESIGN.md">设计文档</a>
|
|
27
28
|
</p>
|
|
28
29
|
|
|
@@ -75,36 +76,35 @@
|
|
|
75
76
|
|
|
76
77
|
## 快速开始
|
|
77
78
|
|
|
78
|
-
###
|
|
79
|
+
### 零配置体验
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
# 作为依赖使用
|
|
82
|
-
npm install @agents-uni/zhenhuan
|
|
83
|
-
|
|
84
|
-
# 或克隆仓库本地开发
|
|
85
|
-
git clone https://github.com/agents-uni/zhenhuan.git
|
|
86
|
-
cd zhenhuan
|
|
87
|
-
npm install
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### 启动服务器
|
|
81
|
+
安装后直接启动,包自带完整的甄嬛后宫配置(7 个嫔妃 Agent):
|
|
91
82
|
|
|
92
83
|
```bash
|
|
93
|
-
# 全局安装后,在任意目录直接使用
|
|
94
84
|
npm install -g @agents-uni/zhenhuan
|
|
95
85
|
zhenhuan serve
|
|
96
86
|
|
|
97
|
-
# 或在项目目录中
|
|
98
|
-
npm start
|
|
99
|
-
|
|
100
87
|
# 或用 npx(无需全局安装)
|
|
101
88
|
npx @agents-uni/zhenhuan serve
|
|
102
|
-
|
|
103
|
-
# 使用自定义规范文件
|
|
104
|
-
zhenhuan serve --spec /path/to/my-universe.yaml
|
|
105
89
|
```
|
|
106
90
|
|
|
107
|
-
> 💡
|
|
91
|
+
> 💡 `zhenhuan` CLI 的路径解析逻辑:优先使用当前目录的 `universe.yaml`,找不到时自动回退到包自带的默认后宫配置。你也可以通过 `--spec` 显式指定。
|
|
92
|
+
|
|
93
|
+
### 自定义项目
|
|
94
|
+
|
|
95
|
+
如果你想修改嫔妃配置、添加新 Agent,或配合 `@agents-uni/chat` 群聊使用,需要在本地建一个项目:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# 初始化项目(生成 universe.yaml 到当前目录)
|
|
99
|
+
mkdir my-palace && cd my-palace
|
|
100
|
+
npx uni init my-palace --uni zhenhuan
|
|
101
|
+
|
|
102
|
+
# 编辑 universe.yaml 自定义嫔妃...
|
|
103
|
+
|
|
104
|
+
# 部署到 OpenClaw 并启动
|
|
105
|
+
npx uni deploy
|
|
106
|
+
zhenhuan serve
|
|
107
|
+
```
|
|
108
108
|
|
|
109
109
|
启动后会打印访问链接:
|
|
110
110
|
|
|
@@ -417,15 +417,19 @@ universe.yaml
|
|
|
417
417
|
|
|
418
418
|
### 部署 Agent 到 OpenClaw
|
|
419
419
|
|
|
420
|
+
> 💡 `zhenhuan serve` 会自动注册 Agent,无需手动部署。只有在你想单独使用 OpenClaw 工作区(不启动服务器)时才需要手动部署。
|
|
421
|
+
|
|
422
|
+
如果你有本地项目目录(通过 `uni init` 创建,或克隆仓库),在该目录下运行:
|
|
423
|
+
|
|
420
424
|
```bash
|
|
421
|
-
#
|
|
422
|
-
npx uni deploy
|
|
425
|
+
# 自动读取当前目录的 universe.yaml
|
|
426
|
+
npx uni deploy
|
|
423
427
|
|
|
424
|
-
#
|
|
425
|
-
npx uni deploy
|
|
428
|
+
# 指定 OpenClaw 目录
|
|
429
|
+
npx uni deploy --dir ~/.openclaw
|
|
426
430
|
|
|
427
431
|
# 预览(不实际写入)
|
|
428
|
-
npx uni deploy
|
|
432
|
+
npx uni deploy --dry-run
|
|
429
433
|
```
|
|
430
434
|
|
|
431
435
|
或使用预置 SOUL.md(手工调优版,包含更丰富的性格描写):
|
|
@@ -459,49 +463,63 @@ const { dispatch, race } = await orchestrator.dispatchAndRace(
|
|
|
459
463
|
// POST /api/race/dispatch
|
|
460
464
|
```
|
|
461
465
|
|
|
462
|
-
> 📖
|
|
466
|
+
> 📖 设计理念和架构决策详见 [DESIGN.md](./DESIGN.md)
|
|
463
467
|
|
|
464
468
|
## 群聊模式(配合 @agents-uni/chat)
|
|
465
469
|
|
|
466
|
-
赛马竞技是"比武",群聊是"日常"
|
|
470
|
+
赛马竞技是"比武",群聊是"日常"。[@agents-uni/chat](https://github.com/agents-uni/chat) 让后宫嫔妃们在同一个聊天室自由对话——结盟、争吵、密谋都会自然发生,关系随对话内容实时演化。
|
|
467
471
|
|
|
468
472
|
### 快速启动
|
|
469
473
|
|
|
474
|
+
`agents-chat` 需要读取 `universe.yaml` 来了解有哪些嫔妃以及她们之间的关系。你需要先在本地建一个项目目录:
|
|
475
|
+
|
|
470
476
|
```bash
|
|
471
|
-
#
|
|
472
|
-
|
|
477
|
+
# 1. 初始化后宫项目(会生成 universe.yaml 到当前目录)
|
|
478
|
+
mkdir my-palace && cd my-palace
|
|
479
|
+
npx uni init my-palace --uni zhenhuan
|
|
473
480
|
|
|
474
|
-
#
|
|
475
|
-
uni deploy
|
|
481
|
+
# 2. 部署 Agent 到 OpenClaw 工作区(生成 SOUL.md 等文件)
|
|
482
|
+
npx uni deploy
|
|
476
483
|
|
|
477
|
-
#
|
|
478
|
-
agents-chat serve
|
|
479
|
-
# 或指定配置文件
|
|
480
|
-
agents-chat serve --spec /path/to/universe.yaml
|
|
484
|
+
# 3. 启动群聊(自动读取当前目录的 universe.yaml)
|
|
485
|
+
npx agents-chat serve
|
|
481
486
|
```
|
|
482
487
|
|
|
483
|
-
浏览器打开 `http://localhost:3000
|
|
488
|
+
浏览器打开 `http://localhost:3000`,你就是皇帝,嫔妃们根据话题自动应答。
|
|
489
|
+
|
|
490
|
+
> 💡 如果不想初始化项目,也可以用 `--spec` 直接指向包自带的配置:
|
|
491
|
+
> ```bash
|
|
492
|
+
> agents-chat serve --spec node_modules/@agents-uni/zhenhuan/universe.yaml
|
|
493
|
+
> ```
|
|
484
494
|
|
|
485
495
|
### 赛马 + 群聊 配合使用
|
|
486
496
|
|
|
487
|
-
两者共享同一个 `universe.yaml` 和 OpenClaw
|
|
497
|
+
两者共享同一个 `universe.yaml` 和 OpenClaw 工作区,在同一个项目目录下交替使用:
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
# 终端 1:赛马竞技(端口 8089)
|
|
501
|
+
zhenhuan serve
|
|
488
502
|
|
|
489
|
-
|
|
503
|
+
# 终端 2:群聊模式(端口 3000)
|
|
504
|
+
agents-chat serve
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
| 场景 | 用哪个 | 说明 |
|
|
490
508
|
|------|--------|------|
|
|
491
509
|
| 让嫔妃们竞争同一任务、ELO 排名 | `zhenhuan serve` | 赛马竞技 |
|
|
492
510
|
| 让嫔妃们自由对话、观察互动 | `agents-chat serve` | 群聊模式 |
|
|
493
|
-
| 先群聊讨论方案,再赛马比拼执行 |
|
|
511
|
+
| 先群聊讨论方案,再赛马比拼执行 | 两者同时 | 先聊后赛 |
|
|
494
512
|
|
|
495
513
|
### 群聊中的关系演化
|
|
496
514
|
|
|
497
|
-
`@agents-uni/chat`
|
|
515
|
+
`@agents-uni/chat` 内置关系推理引擎,从对话中自动检测:
|
|
498
516
|
|
|
499
517
|
- **赞同** — 信任度 +0.05,亲密度 +0.03
|
|
500
518
|
- **反对** — 竞争度 +0.03
|
|
501
519
|
- **协作** — 协同度 +0.05
|
|
502
520
|
- **共识** — 信任度 +0.02,协同度 +0.02
|
|
503
521
|
|
|
504
|
-
|
|
522
|
+
这些变化实时反映在聊天界面的关系图谱中。配合赛马的 ELO 排名,你可以全方位观察嫔妃们的能力和社交动态。
|
|
505
523
|
|
|
506
524
|
### 编程式集成
|
|
507
525
|
|
|
@@ -509,12 +527,14 @@ agents-chat serve --spec /path/to/universe.yaml
|
|
|
509
527
|
import { PalaceOrchestrator } from '@agents-uni/zhenhuan';
|
|
510
528
|
import { ChatEngine } from '@agents-uni/chat';
|
|
511
529
|
|
|
512
|
-
//
|
|
513
|
-
|
|
530
|
+
const specPath = 'universe.yaml'; // 同一份配置文件
|
|
531
|
+
|
|
532
|
+
// 赛马引擎
|
|
533
|
+
const orchestrator = await PalaceOrchestrator.fromSpec(specPath);
|
|
514
534
|
|
|
515
|
-
//
|
|
535
|
+
// 群聊引擎
|
|
516
536
|
const chat = new ChatEngine({
|
|
517
|
-
specPath
|
|
537
|
+
specPath,
|
|
518
538
|
maxRespondents: 3,
|
|
519
539
|
contextWindow: 20,
|
|
520
540
|
});
|
|
@@ -633,10 +653,88 @@ npm run dev
|
|
|
633
653
|
npm run build
|
|
634
654
|
```
|
|
635
655
|
|
|
636
|
-
##
|
|
656
|
+
## 生态系统
|
|
657
|
+
|
|
658
|
+
zhenhuan-uni 是 agents-uni 生态的标杆应用,展示如何基于底层协议构建完整的 Agent 竞争系统。
|
|
659
|
+
|
|
660
|
+
```
|
|
661
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
662
|
+
│ agents-uni 生态全景 │
|
|
663
|
+
│ │
|
|
664
|
+
│ @agents-uni/core 协议层 — 定义 Agent 组织的通用规范 │
|
|
665
|
+
│ ├── Universe 规范 (universe.yaml 解析与校验) │
|
|
666
|
+
│ ├── Agent Registry (注册、发现、生命周期管理) │
|
|
667
|
+
│ ├── Relationship Graph(关系图谱、BFS 派系发现) │
|
|
668
|
+
│ ├── State Machine (协议状态机、流程编排) │
|
|
669
|
+
│ ├── EventBus (事件驱动的松耦合通信) │
|
|
670
|
+
│ ├── TaskDispatcher (TASK.md → SUBMISSION.md 调度) │
|
|
671
|
+
│ ├── Dashboard (Web UI + 扩展机制) │
|
|
672
|
+
│ └── CLI: uni (init/deploy/validate/inspect) │
|
|
673
|
+
│ │
|
|
674
|
+
│ @agents-uni/zhenhuan ←── 竞争层 — 本项目 │
|
|
675
|
+
│ ├── ELO 竞技场 (ELO 评分、K 因子、地板机制) │
|
|
676
|
+
│ ├── 赛马引擎 (多 Agent 同任务竞争) │
|
|
677
|
+
│ ├── 后宫体系 (品级、资源、势力、冷宫) │
|
|
678
|
+
│ ├── 赛季制度 (赛季、朝会、晋升降级) │
|
|
679
|
+
│ └── CLI: zhenhuan (serve/status/leaderboard/court) │
|
|
680
|
+
│ │
|
|
681
|
+
│ @agents-uni/chat 社交层 — Agent 群聊 │
|
|
682
|
+
│ ├── 多 Agent 聊天室 (话题驱动、自动应答) │
|
|
683
|
+
│ ├── 关系推理引擎 (从对话中推断信任/竞争/协同) │
|
|
684
|
+
│ └── 实时关系图谱 (浏览器可视化) │
|
|
685
|
+
│ │
|
|
686
|
+
│ @agents-uni/rel 关系层 — 关系建模基础库 │
|
|
687
|
+
│ └── 多维关系模型 (信任、竞争、亲密、协同等维度) │
|
|
688
|
+
│ │
|
|
689
|
+
│ @agents-uni/unis 模板层 — 预置组织模板 │
|
|
690
|
+
│ └── 竞技场/企业/军事/扁平... (universe.yaml 模板库) │
|
|
691
|
+
│ │
|
|
692
|
+
│ OpenClaw 运行层 — Agent 运行时环境 │
|
|
693
|
+
│ └── 文件协议 (SOUL.md / TASK.md / SUBMISSION.md)│
|
|
694
|
+
└─────────────────────────────────────────────────────────────┘
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
### 包之间的关系
|
|
698
|
+
|
|
699
|
+
| 包 | 角色 | zhenhuan 如何使用它 |
|
|
700
|
+
|---|---|---|
|
|
701
|
+
| [@agents-uni/core](https://github.com/agents-uni/core) | 协议基座 | Universe 解析、Agent 注册、TaskDispatcher、Dashboard、CLI (`uni`) |
|
|
702
|
+
| [@agents-uni/chat](https://github.com/agents-uni/chat) | 群聊引擎 | 共享 `universe.yaml`,嫔妃在聊天室自由对话,关系实时演化 |
|
|
703
|
+
| [@agents-uni/rel](https://github.com/agents-uni/rel) | 关系建模 | 多维关系(信任/竞争/亲密/协同),被 core 和 chat 内部依赖 |
|
|
704
|
+
| [@agents-uni/unis](https://github.com/agents-uni/unis) | 组织模板 | `uni init --uni zhenhuan` 从模板库拉取后宫配置 |
|
|
705
|
+
| [OpenClaw](https://github.com/anthropics/openclaw) | Agent 运行时 | 文件协议:SOUL.md(身份)→ TASK.md(任务)→ SUBMISSION.md(提交) |
|
|
706
|
+
|
|
707
|
+
### 从零到一的完整流程
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
# 1. 初始化项目 — 从 @agents-uni/unis 模板生成 universe.yaml
|
|
711
|
+
npx uni init my-palace --uni zhenhuan
|
|
712
|
+
|
|
713
|
+
# 2. 部署 — core 的 CLI 将 universe.yaml 编译为 SOUL.md 并写入 OpenClaw
|
|
714
|
+
npx uni deploy
|
|
715
|
+
|
|
716
|
+
# 3. 启动赛马 — zhenhuan 的竞争引擎开始调度
|
|
717
|
+
zhenhuan serve # 端口 8089
|
|
718
|
+
|
|
719
|
+
# 4. 启动群聊(可选)— chat 读取同一份 universe.yaml
|
|
720
|
+
npx agents-chat serve # 端口 3000
|
|
721
|
+
|
|
722
|
+
# 5. 验证 / 检查 / 可视化 — core 的 CLI 工具
|
|
723
|
+
npx uni validate # 校验 universe.yaml
|
|
724
|
+
npx uni inspect # 查看 Agent 详情
|
|
725
|
+
npx uni visualize # 可视化关系图谱
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
### 如果你想基于 core 创建自己的 Uni
|
|
729
|
+
|
|
730
|
+
zhenhuan-uni 本身就是最好的参考实现。核心步骤:
|
|
731
|
+
|
|
732
|
+
1. **定义 `universe.yaml`** — 参考 [core 的规范文档](https://github.com/agents-uni/core#universe-规范) 或直接参考 zhenhuan 的 `universe.yaml`
|
|
733
|
+
2. **实现竞争/协作逻辑** — 使用 core 提供的 `TaskDispatcher`、`PerformanceTracker`、`EventBus` 等原语
|
|
734
|
+
3. **部署到 OpenClaw** — `uni deploy` 自动生成 SOUL.md 并注册 Agent
|
|
735
|
+
4. **扩展 Dashboard** — 通过 `DashboardExtension` 接口注入自定义面板
|
|
637
736
|
|
|
638
|
-
|
|
639
|
-
- [**@agents-uni/chat**](https://github.com/agents-uni/chat) — 群聊服务,让 Agent 们在浏览器中自由对话,关系实时演化 ([npm](https://www.npmjs.com/package/@agents-uni/chat))
|
|
737
|
+
详细的架构设计和决策过程见 [DESIGN.md](./DESIGN.md)。
|
|
640
738
|
|
|
641
739
|
## License
|
|
642
740
|
|