@agents-uni/core 0.1.0
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/DESIGN.md +283 -0
- package/LICENSE +21 -0
- package/README.en.md +589 -0
- package/README.md +589 -0
- package/dist/bridge/config-sync.d.ts +24 -0
- package/dist/bridge/config-sync.d.ts.map +1 -0
- package/dist/bridge/config-sync.js +39 -0
- package/dist/bridge/config-sync.js.map +1 -0
- package/dist/bridge/index.d.ts +7 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +7 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge/openclaw-adapter.d.ts +49 -0
- package/dist/bridge/openclaw-adapter.d.ts.map +1 -0
- package/dist/bridge/openclaw-adapter.js +151 -0
- package/dist/bridge/openclaw-adapter.js.map +1 -0
- package/dist/bridge/soul-generator.d.ts +34 -0
- package/dist/bridge/soul-generator.d.ts.map +1 -0
- package/dist/bridge/soul-generator.js +149 -0
- package/dist/bridge/soul-generator.js.map +1 -0
- package/dist/bridge/task-dispatcher.d.ts +107 -0
- package/dist/bridge/task-dispatcher.d.ts.map +1 -0
- package/dist/bridge/task-dispatcher.js +217 -0
- package/dist/bridge/task-dispatcher.js.map +1 -0
- package/dist/bridge/uni-registry.d.ts +82 -0
- package/dist/bridge/uni-registry.d.ts.map +1 -0
- package/dist/bridge/uni-registry.js +261 -0
- package/dist/bridge/uni-registry.js.map +1 -0
- package/dist/bridge/workspace-io.d.ts +64 -0
- package/dist/bridge/workspace-io.d.ts.map +1 -0
- package/dist/bridge/workspace-io.js +99 -0
- package/dist/bridge/workspace-io.js.map +1 -0
- package/dist/cli/commands/deploy.d.ts +6 -0
- package/dist/cli/commands/deploy.d.ts.map +1 -0
- package/dist/cli/commands/deploy.js +48 -0
- package/dist/cli/commands/deploy.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +137 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/inspect.d.ts +4 -0
- package/dist/cli/commands/inspect.d.ts.map +1 -0
- package/dist/cli/commands/inspect.js +77 -0
- package/dist/cli/commands/inspect.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +2 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +30 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/commands/visualize.d.ts +2 -0
- package/dist/cli/commands/visualize.d.ts.map +1 -0
- package/dist/cli/commands/visualize.js +69 -0
- package/dist/cli/commands/visualize.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +132 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/agent-registry.d.ts +37 -0
- package/dist/core/agent-registry.d.ts.map +1 -0
- package/dist/core/agent-registry.js +97 -0
- package/dist/core/agent-registry.js.map +1 -0
- package/dist/core/event-bus.d.ts +34 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +96 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +8 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/permission-matrix.d.ts +35 -0
- package/dist/core/permission-matrix.d.ts.map +1 -0
- package/dist/core/permission-matrix.js +95 -0
- package/dist/core/permission-matrix.js.map +1 -0
- package/dist/core/relationship-graph.d.ts +50 -0
- package/dist/core/relationship-graph.d.ts.map +1 -0
- package/dist/core/relationship-graph.js +150 -0
- package/dist/core/relationship-graph.js.map +1 -0
- package/dist/core/resource-pool.d.ts +48 -0
- package/dist/core/resource-pool.d.ts.map +1 -0
- package/dist/core/resource-pool.js +205 -0
- package/dist/core/resource-pool.js.map +1 -0
- package/dist/core/state-machine.d.ts +47 -0
- package/dist/core/state-machine.d.ts.map +1 -0
- package/dist/core/state-machine.js +110 -0
- package/dist/core/state-machine.js.map +1 -0
- package/dist/core/universe.d.ts +38 -0
- package/dist/core/universe.d.ts.map +1 -0
- package/dist/core/universe.js +101 -0
- package/dist/core/universe.js.map +1 -0
- package/dist/dashboard/api.d.ts +10 -0
- package/dist/dashboard/api.d.ts.map +1 -0
- package/dist/dashboard/api.js +237 -0
- package/dist/dashboard/api.js.map +1 -0
- package/dist/dashboard/index.d.ts +3 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +3 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/dashboard/server.d.ts +31 -0
- package/dist/dashboard/server.d.ts.map +1 -0
- package/dist/dashboard/server.js +44 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/dashboard/templates.d.ts +47 -0
- package/dist/dashboard/templates.d.ts.map +1 -0
- package/dist/dashboard/templates.js +1481 -0
- package/dist/dashboard/templates.js.map +1 -0
- package/dist/evolution/index.d.ts +5 -0
- package/dist/evolution/index.d.ts.map +1 -0
- package/dist/evolution/index.js +5 -0
- package/dist/evolution/index.js.map +1 -0
- package/dist/evolution/memory-consolidator.d.ts +28 -0
- package/dist/evolution/memory-consolidator.d.ts.map +1 -0
- package/dist/evolution/memory-consolidator.js +84 -0
- package/dist/evolution/memory-consolidator.js.map +1 -0
- package/dist/evolution/performance-tracker.d.ts +29 -0
- package/dist/evolution/performance-tracker.d.ts.map +1 -0
- package/dist/evolution/performance-tracker.js +90 -0
- package/dist/evolution/performance-tracker.js.map +1 -0
- package/dist/evolution/promotion-engine.d.ts +32 -0
- package/dist/evolution/promotion-engine.d.ts.map +1 -0
- package/dist/evolution/promotion-engine.js +117 -0
- package/dist/evolution/promotion-engine.js.map +1 -0
- package/dist/evolution/relationship-evolver.d.ts +40 -0
- package/dist/evolution/relationship-evolver.d.ts.map +1 -0
- package/dist/evolution/relationship-evolver.js +105 -0
- package/dist/evolution/relationship-evolver.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/schema/index.d.ts +13 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +18 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/universe.schema.json +214 -0
- package/dist/spec/compiler.d.ts +16 -0
- package/dist/spec/compiler.d.ts.map +1 -0
- package/dist/spec/compiler.js +26 -0
- package/dist/spec/compiler.js.map +1 -0
- package/dist/spec/index.d.ts +4 -0
- package/dist/spec/index.d.ts.map +1 -0
- package/dist/spec/index.js +4 -0
- package/dist/spec/index.js.map +1 -0
- package/dist/spec/parser.d.ts +11 -0
- package/dist/spec/parser.d.ts.map +1 -0
- package/dist/spec/parser.js +89 -0
- package/dist/spec/parser.js.map +1 -0
- package/dist/spec/validator.d.ts +9 -0
- package/dist/spec/validator.d.ts.map +1 -0
- package/dist/spec/validator.js +105 -0
- package/dist/spec/validator.js.map +1 -0
- package/dist/types/agent.d.ts +56 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +8 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/event.d.ts +34 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +11 -0
- package/dist/types/event.js.map +1 -0
- package/dist/types/governance.d.ts +48 -0
- package/dist/types/governance.d.ts.map +1 -0
- package/dist/types/governance.js +9 -0
- package/dist/types/governance.js.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/memory.d.ts +73 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/memory.js +9 -0
- package/dist/types/memory.js.map +1 -0
- package/dist/types/protocol.d.ts +48 -0
- package/dist/types/protocol.d.ts.map +1 -0
- package/dist/types/protocol.js +9 -0
- package/dist/types/protocol.js.map +1 -0
- package/dist/types/relationship.d.ts +40 -0
- package/dist/types/relationship.d.ts.map +1 -0
- package/dist/types/relationship.js +9 -0
- package/dist/types/relationship.js.map +1 -0
- package/dist/types/resource.d.ts +52 -0
- package/dist/types/resource.d.ts.map +1 -0
- package/dist/types/resource.js +9 -0
- package/dist/types/resource.js.map +1 -0
- package/dist/types/universe.d.ts +71 -0
- package/dist/types/universe.d.ts.map +1 -0
- package/dist/types/universe.js +9 -0
- package/dist/types/universe.js.map +1 -0
- package/package.json +68 -0
package/README.en.md
ADDED
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">agents-uni-core</h1>
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>Universal protocol layer for agent organizations</strong>
|
|
5
|
+
</p>
|
|
6
|
+
<p align="center">
|
|
7
|
+
Define how agents organize, collaborate, compete, and evolve — not just what they do.
|
|
8
|
+
</p>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="./README.md">中文</a> •
|
|
13
|
+
<a href="#quick-start">Quick Start</a> •
|
|
14
|
+
<a href="#core-concepts">Core Concepts</a> •
|
|
15
|
+
<a href="#templates">Templates</a> •
|
|
16
|
+
<a href="#cli">CLI</a> •
|
|
17
|
+
<a href="#openclaw-bridge">OpenClaw Bridge</a> •
|
|
18
|
+
<a href="#dashboard">Dashboard</a> •
|
|
19
|
+
<a href="#multi-uni-management">Multi-Uni</a> •
|
|
20
|
+
<a href="./DESIGN.md">Design Doc</a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Why?
|
|
26
|
+
|
|
27
|
+
Current multi-agent frameworks solve **productivity** — how to make agents complete tasks. They ignore **production relationships** — how agents should organize, govern, and evolve together.
|
|
28
|
+
|
|
29
|
+
Human societies spent millennia developing organizational forms: bureaucracies, corporations, militaries, cooperatives. These weren't random — they evolved as optimal structures under specific constraints.
|
|
30
|
+
|
|
31
|
+
**agents-uni-core** brings this thinking to AI agents:
|
|
32
|
+
|
|
33
|
+
> While improving productivity, what we truly need is better production relationships.
|
|
34
|
+
|
|
35
|
+
### The User Is the Center
|
|
36
|
+
|
|
37
|
+
In the OpenClaw ecosystem, **the user is at the center of every relationship network**. Agents don't exist in isolation — they form social structures around the user, building relationships that help the user accomplish tasks and fulfill emotional needs. agents-uni-core provides not just a cold task-execution pipeline, but a warm, user-centric social framework for AI agents.
|
|
38
|
+
|
|
39
|
+
Each agent's SOUL.md defines not only its personality and capabilities, but its **relationship with the user** — what unique value it provides, how it understands the user's needs, and how its personality makes the user feel genuinely accompanied and helped.
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
### Scaffold a new project
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx create-uni my-universe
|
|
47
|
+
# or with a specific template
|
|
48
|
+
npx create-uni my-universe --template competitive
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Use as a library
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install @agents-uni/core
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { compileUniverse, parseSpecFile } from '@agents-uni/core';
|
|
59
|
+
|
|
60
|
+
// Load and compile a universe spec
|
|
61
|
+
const config = parseSpecFile('universe.yaml');
|
|
62
|
+
const universe = await compileUniverse(config, { autoInit: true });
|
|
63
|
+
|
|
64
|
+
// Access the organizational infrastructure
|
|
65
|
+
const agents = universe.agents.getAll();
|
|
66
|
+
const leaderboard = universe.resources.getLeaderboard('rating');
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Write a Universe Spec
|
|
70
|
+
|
|
71
|
+
```yaml
|
|
72
|
+
name: my-team
|
|
73
|
+
type: corporation
|
|
74
|
+
description: A small agile development team
|
|
75
|
+
|
|
76
|
+
agents:
|
|
77
|
+
- id: tech-lead
|
|
78
|
+
name: Tech Lead
|
|
79
|
+
role:
|
|
80
|
+
title: Technical Lead
|
|
81
|
+
duties: [architecture, code-review, mentoring]
|
|
82
|
+
rank: 80
|
|
83
|
+
|
|
84
|
+
- id: dev-alpha
|
|
85
|
+
name: Developer Alpha
|
|
86
|
+
role:
|
|
87
|
+
title: Software Engineer
|
|
88
|
+
duties: [implementation, testing, documentation]
|
|
89
|
+
rank: 50
|
|
90
|
+
traits: { creativity: 0.8, speed: 0.7 }
|
|
91
|
+
|
|
92
|
+
relationships:
|
|
93
|
+
- { from: tech-lead, to: dev-alpha, type: supervises }
|
|
94
|
+
|
|
95
|
+
governance:
|
|
96
|
+
decisionModel: autocratic
|
|
97
|
+
permissionMatrix:
|
|
98
|
+
- { role: Technical Lead, action: execute, target: "*" }
|
|
99
|
+
reviewPolicy:
|
|
100
|
+
mandatory: true
|
|
101
|
+
reviewers: [tech-lead]
|
|
102
|
+
|
|
103
|
+
resources:
|
|
104
|
+
- name: compute
|
|
105
|
+
type: renewable
|
|
106
|
+
total: 1000
|
|
107
|
+
distribution: merit
|
|
108
|
+
|
|
109
|
+
evolution:
|
|
110
|
+
performanceWindow: 20
|
|
111
|
+
promotionThreshold: 80
|
|
112
|
+
demotionThreshold: 30
|
|
113
|
+
memoryRetention: 500
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Core Concepts
|
|
117
|
+
|
|
118
|
+
### Universe
|
|
119
|
+
|
|
120
|
+
A self-contained agent society with its own rules, roles, relationships, and evolution logic. Think of it as a "world" where agents live and operate.
|
|
121
|
+
|
|
122
|
+
### Agent & Role
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
Agent = a concrete actor ("Alice")
|
|
126
|
+
Role = an abstract position ("Lead Engineer")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Agents occupy Roles. Roles define permissions and duties. The same Role can have multiple Agents; the same Agent can migrate between Roles through promotion/demotion.
|
|
130
|
+
|
|
131
|
+
### Relationship Graph
|
|
132
|
+
|
|
133
|
+
Relationships are a **weighted directed graph**, not just org-chart lines:
|
|
134
|
+
|
|
135
|
+
| Type | Description |
|
|
136
|
+
|------|-------------|
|
|
137
|
+
| `supervises` | Management relationship |
|
|
138
|
+
| `collaborates` | Peer cooperation |
|
|
139
|
+
| `competes` | Competitive relationship |
|
|
140
|
+
| `advises` | Advisory role |
|
|
141
|
+
| `audits` | Oversight / supervision |
|
|
142
|
+
|
|
143
|
+
Each edge has a `weight` (0-1) that evolves with interaction history, making trust a quantifiable, evolvable organizational property.
|
|
144
|
+
|
|
145
|
+
### Permission Matrix
|
|
146
|
+
|
|
147
|
+
A three-dimensional access control system: **Who** (agentId / roleId) x **Action** (execute / review / delegate / veto / allocate) x **Target** (agentId / \*).
|
|
148
|
+
|
|
149
|
+
### State Machine (Protocol Engine)
|
|
150
|
+
|
|
151
|
+
Workflows are defined as finite state machines with role-gated transitions and guard expressions:
|
|
152
|
+
|
|
153
|
+
```yaml
|
|
154
|
+
protocols:
|
|
155
|
+
- name: code-review
|
|
156
|
+
states:
|
|
157
|
+
- id: submitted
|
|
158
|
+
type: initial
|
|
159
|
+
- id: reviewing
|
|
160
|
+
transitions:
|
|
161
|
+
- to: approved
|
|
162
|
+
requiredRole: senior-dev
|
|
163
|
+
- to: rejected
|
|
164
|
+
guard: "score < 0.6"
|
|
165
|
+
- id: approved
|
|
166
|
+
type: terminal
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Resource Pool
|
|
170
|
+
|
|
171
|
+
Resources shape incentive structures:
|
|
172
|
+
|
|
173
|
+
| Distribution | Best For |
|
|
174
|
+
|-------------|----------|
|
|
175
|
+
| `equal` | Collaborative teams |
|
|
176
|
+
| `hierarchy` | Bureaucratic orgs |
|
|
177
|
+
| `merit` | Performance-driven orgs |
|
|
178
|
+
| `competitive` | Market-like arenas |
|
|
179
|
+
|
|
180
|
+
Resources can have `decayRate` — unused power fades, forcing agents to stay active.
|
|
181
|
+
|
|
182
|
+
### Evolution Engine
|
|
183
|
+
|
|
184
|
+
Four built-in modules enable organizational self-optimization:
|
|
185
|
+
|
|
186
|
+
| Module | Purpose |
|
|
187
|
+
|--------|---------|
|
|
188
|
+
| **PerformanceTracker** | Multi-dimensional performance recording |
|
|
189
|
+
| **PromotionEngine** | Threshold-based promote / demote / suspend |
|
|
190
|
+
| **RelationshipEvolver** | Auto-adjusts relationship weights from events |
|
|
191
|
+
| **MemoryConsolidator** | Extracts organizational lessons, forms collective memory |
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
Performance Data --> Tracking --> Promotion Decision --> Role Change
|
|
195
|
+
^ |
|
|
196
|
+
+----- Relationship Evolution <-- Events <-- Memory --+
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Templates
|
|
200
|
+
|
|
201
|
+
Five ready-to-use organizational templates:
|
|
202
|
+
|
|
203
|
+
| Template | Model | Governance | Use Case |
|
|
204
|
+
|----------|-------|-----------|----------|
|
|
205
|
+
| `competitive` | Arena with judge + contestants | Meritocratic | Model comparison, creative contests |
|
|
206
|
+
| `government` | Multi-department hierarchy | Checks & balances | Approval workflows, policy making |
|
|
207
|
+
| `corporation` | Manager + engineers | Autocratic | Sprint-based development |
|
|
208
|
+
| `flat` | Peer team | Democratic | Open-source collaboration |
|
|
209
|
+
| `military` | Commander + executors | Single chain of command | Mission-critical execution |
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
npx create-uni my-project --template competitive
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## CLI
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Validate a universe spec
|
|
219
|
+
uni validate universe.yaml
|
|
220
|
+
|
|
221
|
+
# ASCII visualization of the organization
|
|
222
|
+
uni visualize universe.yaml
|
|
223
|
+
|
|
224
|
+
# Detailed inspection (or specific agent)
|
|
225
|
+
uni inspect universe.yaml
|
|
226
|
+
uni inspect universe.yaml --agent dev-alpha
|
|
227
|
+
|
|
228
|
+
# Deploy to OpenClaw workspaces
|
|
229
|
+
uni deploy universe.yaml --dir ./workspaces --lang zh
|
|
230
|
+
|
|
231
|
+
# Interactive project initialization
|
|
232
|
+
uni init
|
|
233
|
+
|
|
234
|
+
# 🆕 Start the Dashboard web UI
|
|
235
|
+
uni dashboard [--port 8089]
|
|
236
|
+
|
|
237
|
+
# 🆕 List all registered universes
|
|
238
|
+
uni list
|
|
239
|
+
|
|
240
|
+
# 🆕 Overview of deployed unis and agents
|
|
241
|
+
uni status
|
|
242
|
+
|
|
243
|
+
# 🆕 Remove a universe and all its files
|
|
244
|
+
uni cleanup <id>
|
|
245
|
+
|
|
246
|
+
# 🆕 Reset runtime data, keep configuration
|
|
247
|
+
uni reset <id>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
| Command | Description |
|
|
251
|
+
|---------|-------------|
|
|
252
|
+
| `uni validate` | Validate a universe spec |
|
|
253
|
+
| `uni visualize` | ASCII visualization of the organization |
|
|
254
|
+
| `uni inspect` | Detailed agent inspection |
|
|
255
|
+
| `uni deploy` | Deploy to OpenClaw workspaces |
|
|
256
|
+
| `uni init` | Interactive project initialization |
|
|
257
|
+
| `uni dashboard` | Start Dashboard web UI |
|
|
258
|
+
| `uni list` | List all registered universes |
|
|
259
|
+
| `uni status` | Overview of deployed unis and agents |
|
|
260
|
+
| `uni cleanup <id>` | Remove a universe and all its files |
|
|
261
|
+
| `uni reset <id>` | Reset runtime data, keep SOUL.md config |
|
|
262
|
+
|
|
263
|
+
## OpenClaw Bridge
|
|
264
|
+
|
|
265
|
+
agents-uni-core integrates with [OpenClaw](https://github.com/anthropics/openclaw) via a **file-based protocol**. Three core capabilities:
|
|
266
|
+
|
|
267
|
+
**1. SOUL.md Deployment** — generate agent persona files from universe specs and create agent runtime directories (`agents/{id}/agent/` + `agents/{id}/sessions/`)
|
|
268
|
+
**2. One-Click Registration** — auto-register agents in `openclaw.json` (with both `workspace` and `agentDir` fields) during deployment
|
|
269
|
+
**3. Task Dispatch** — communicate with agents via `TASK.md` / `SUBMISSION.md` file protocol
|
|
270
|
+
**4. Workspace Management** — check and sync OpenClaw workspace state
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
Universe Spec (YAML)
|
|
274
|
+
| uni deploy
|
|
275
|
+
SOUL.md × N → OpenClaw workspaces
|
|
276
|
+
|
|
|
277
|
+
TaskDispatcher.run()
|
|
278
|
+
|
|
|
279
|
+
├─ Write TASK.md to each agent's workspace
|
|
280
|
+
├─ Agent reads → executes → writes SUBMISSION.md
|
|
281
|
+
├─ Poll & collect SUBMISSION.md
|
|
282
|
+
└─ Return all submissions
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
import {
|
|
287
|
+
deployToOpenClaw,
|
|
288
|
+
TaskDispatcher,
|
|
289
|
+
FileWorkspaceIO,
|
|
290
|
+
} from '@agents-uni/core';
|
|
291
|
+
|
|
292
|
+
// 1. Deploy SOUL.md + agent runtime dirs to OpenClaw + auto-register in openclaw.json
|
|
293
|
+
const result = deployToOpenClaw(config, { openclawDir: '~/.openclaw' });
|
|
294
|
+
// result.registered → newly registered agent IDs in openclaw.json
|
|
295
|
+
// result.agentDirs → created agent runtime directories (~/.openclaw/agents/{id}/agent/)
|
|
296
|
+
//
|
|
297
|
+
// Directory structure after deploy:
|
|
298
|
+
// ~/.openclaw/
|
|
299
|
+
// ├── openclaw.json ← agent registry (workspace + agentDir)
|
|
300
|
+
// ├── agents/
|
|
301
|
+
// │ └── {id}/
|
|
302
|
+
// │ ├── agent/ ← runtime config (auth-profiles.json etc.)
|
|
303
|
+
// │ └── sessions/ ← session history
|
|
304
|
+
// └── workspace-{id}/
|
|
305
|
+
// └── SOUL.md ← agent persona
|
|
306
|
+
|
|
307
|
+
// Or register standalone (without deploying SOUL.md)
|
|
308
|
+
import { registerAgentsInOpenClaw } from '@agents-uni/core';
|
|
309
|
+
registerAgentsInOpenClaw(config, '~/.openclaw');
|
|
310
|
+
// Writes both workspace and agentDir to openclaw.json
|
|
311
|
+
|
|
312
|
+
// 2. Dispatch task and collect submissions
|
|
313
|
+
const dispatcher = new TaskDispatcher(new FileWorkspaceIO());
|
|
314
|
+
const result = await dispatcher.run({
|
|
315
|
+
id: 'task-001',
|
|
316
|
+
title: 'Strategy Essay',
|
|
317
|
+
description: 'Write a 500-word essay',
|
|
318
|
+
criteria: [{ name: 'quality', weight: 1, description: 'Content depth' }],
|
|
319
|
+
timeoutMs: 60000,
|
|
320
|
+
participants: ['agent-a', 'agent-b'],
|
|
321
|
+
});
|
|
322
|
+
// result.submissions → collected agent outputs
|
|
323
|
+
// result.timedOut → agents that missed the deadline
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Dashboard
|
|
327
|
+
|
|
328
|
+
agents-uni-core includes a built-in Hono-based web Dashboard for browsing and managing all deployed universes.
|
|
329
|
+
|
|
330
|
+
### Start
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
# Default port 8089
|
|
334
|
+
uni dashboard
|
|
335
|
+
|
|
336
|
+
# Custom port
|
|
337
|
+
uni dashboard --port 8080
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Pages
|
|
341
|
+
|
|
342
|
+
| Page | Path | Description |
|
|
343
|
+
|------|------|-------------|
|
|
344
|
+
| Home | `/` | Project intro + all registered universes overview + architecture |
|
|
345
|
+
| User Guide | `/guide` | Complete usage guide: concepts, workflow, CLI reference, file protocol, multi-uni management |
|
|
346
|
+
| Uni Detail | `/uni/:id` | Agent list, relationship graph, resource status |
|
|
347
|
+
| Agent Detail | `/uni/:id/agent/:agentId` | Rank, ELO, session history, SOUL.md content |
|
|
348
|
+
| Manage | `/manage` | Batch reset / cleanup / update operations |
|
|
349
|
+
|
|
350
|
+
### API Endpoints
|
|
351
|
+
|
|
352
|
+
```
|
|
353
|
+
GET /api/unis # List all registered universes
|
|
354
|
+
GET /api/unis/:id # Get universe details
|
|
355
|
+
GET /api/unis/:id/agents/:agentId # Get agent details
|
|
356
|
+
GET /api/unis/:id/relationships # Get relationship graph
|
|
357
|
+
POST /api/unis/:id/reset # Reset universe runtime data
|
|
358
|
+
POST /api/unis/:id/cleanup # Remove universe and all files
|
|
359
|
+
GET /api/health # Health check
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Extension System
|
|
363
|
+
|
|
364
|
+
The Dashboard provides a `DashboardExtension` interface, allowing specific unis (e.g., zhenhuan-uni) to inject custom API routes and homepage panels:
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
import { Hono } from 'hono';
|
|
368
|
+
import { startDashboard } from '@agents-uni/core';
|
|
369
|
+
import type { DashboardExtension, PanelDefinition } from '@agents-uni/core';
|
|
370
|
+
|
|
371
|
+
// 1. Create extension routes (Hono instance)
|
|
372
|
+
const extRoutes = new Hono();
|
|
373
|
+
extRoutes.get('/leaderboard', (c) => c.json(getLeaderboard()));
|
|
374
|
+
extRoutes.get('/factions', (c) => c.json(getFactions()));
|
|
375
|
+
|
|
376
|
+
// 2. Define homepage panels
|
|
377
|
+
const panels: PanelDefinition[] = [
|
|
378
|
+
{
|
|
379
|
+
title: 'ELO Leaderboard',
|
|
380
|
+
renderHtml: () => '<table>...</table>', // Return HTML fragment
|
|
381
|
+
},
|
|
382
|
+
];
|
|
383
|
+
|
|
384
|
+
// 3. Assemble extension
|
|
385
|
+
const extension: DashboardExtension = {
|
|
386
|
+
uniId: 'zhenhuan-palace', // Uni this extension belongs to
|
|
387
|
+
routes: extRoutes, // Mounted at /ext/zhenhuan-palace/
|
|
388
|
+
panels, // Displayed on homepage
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
// 4. Start Dashboard
|
|
392
|
+
await startDashboard({ port: 8089, extensions: [extension] });
|
|
393
|
+
// Extension API: GET /ext/zhenhuan-palace/leaderboard
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
The UI uses server-side rendered HTML with Tailwind CDN, dark theme, no frontend build required.
|
|
397
|
+
|
|
398
|
+
## Multi-Uni Management
|
|
399
|
+
|
|
400
|
+
When multiple universes are deployed on the same machine, a registry tracks them all.
|
|
401
|
+
|
|
402
|
+
### Uni Registry
|
|
403
|
+
|
|
404
|
+
Registry data is stored at `~/.openclaw/uni-registry.json`. Each universe is auto-registered during `deployToOpenClaw()` when the `specPath` option is provided.
|
|
405
|
+
|
|
406
|
+
```
|
|
407
|
+
~/.openclaw/
|
|
408
|
+
├── openclaw.json ← agent config
|
|
409
|
+
├── uni-registry.json ← 🆕 multi-uni registry
|
|
410
|
+
├── agents/{id}/agent/ ← agent runtime
|
|
411
|
+
├── agents/{id}/sessions/ ← session history
|
|
412
|
+
└── workspace-{id}/SOUL.md ← agent persona
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### Registry API
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
import {
|
|
419
|
+
registerUni, // Register a universe
|
|
420
|
+
listUnis, // List all registered universes
|
|
421
|
+
getUni, // Get a single universe's info
|
|
422
|
+
unregisterUni, // Remove from registry
|
|
423
|
+
cleanupUni, // Delete workspace dirs + agent dirs + openclaw.json entries + registry
|
|
424
|
+
resetUni, // Clear sessions, TASK.md, SUBMISSION.md; keep SOUL.md
|
|
425
|
+
updateUni, // Re-deploy SOUL.md, handle added/removed agents
|
|
426
|
+
} from '@agents-uni/core';
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Lifecycle Management
|
|
430
|
+
|
|
431
|
+
| Operation | CLI | Description |
|
|
432
|
+
|-----------|-----|-------------|
|
|
433
|
+
| Register | `uni deploy` (auto) | Auto-registered on deploy via specPath |
|
|
434
|
+
| List | `uni list` | List all registered universes |
|
|
435
|
+
| Status | `uni status` | View agent counts, deploy times, etc. |
|
|
436
|
+
| Reset | `uni reset <id>` | Clear sessions & TASK.md/SUBMISSION.md, keep SOUL.md |
|
|
437
|
+
| Update | `updateUni()` | Re-deploy SOUL.md, handle added/removed agents |
|
|
438
|
+
| Cleanup | `uni cleanup <id>` | Delete workspace + agent dirs + remove from openclaw.json + registry |
|
|
439
|
+
|
|
440
|
+
## Architecture
|
|
441
|
+
|
|
442
|
+
```
|
|
443
|
+
+-----------------------------------------------------+
|
|
444
|
+
| Universe (Container) |
|
|
445
|
+
| |
|
|
446
|
+
| +----------+ +--------------+ +----------------+ |
|
|
447
|
+
| | Agent | | Relationship | | Permission | |
|
|
448
|
+
| | Registry |<>| Graph |<>| Matrix | |
|
|
449
|
+
| +----+-----+ +------+-------+ +-------+--------+ |
|
|
450
|
+
| | | | |
|
|
451
|
+
| +----+-----+ +------+-------+ +-------+--------+ |
|
|
452
|
+
| | State | | Resource | | Event | |
|
|
453
|
+
| | Machine | | Pool | | Bus | |
|
|
454
|
+
| +----------+ +--------------+ +----------------+ |
|
|
455
|
+
| |
|
|
456
|
+
| +-------------- Evolution Engine ----------------+ |
|
|
457
|
+
| | Performance -> Promotion -> Memory -> Relations | |
|
|
458
|
+
| +------------------------------------------------+ |
|
|
459
|
+
+--------------------------+----------------------------+
|
|
460
|
+
|
|
|
461
|
+
+---------+---------+
|
|
462
|
+
| |
|
|
463
|
+
+-----+-----+ +-----+-----+
|
|
464
|
+
| Spec YAML | | OpenClaw |
|
|
465
|
+
| -> Universe | | Bridge |
|
|
466
|
+
+------------+ +-----------+
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## API Reference
|
|
470
|
+
|
|
471
|
+
### Core
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
import {
|
|
475
|
+
Universe, // The container for everything
|
|
476
|
+
AgentRegistry, // Agent lifecycle management
|
|
477
|
+
RelationshipGraph, // Weighted directed relationship graph
|
|
478
|
+
StateMachine, // Workflow orchestration
|
|
479
|
+
PermissionMatrix, // Access control
|
|
480
|
+
ResourcePool, // Resource allocation & decay
|
|
481
|
+
EventBus, // Pub/sub event system
|
|
482
|
+
} from '@agents-uni/core';
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### Evolution
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
import {
|
|
489
|
+
PerformanceTracker, // Record & analyze agent performance
|
|
490
|
+
PromotionEngine, // Auto promote/demote/suspend
|
|
491
|
+
MemoryConsolidator, // Organizational learning
|
|
492
|
+
RelationshipEvolver, // Dynamic relationship adjustment
|
|
493
|
+
} from '@agents-uni/core';
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### Spec Processing
|
|
497
|
+
|
|
498
|
+
```typescript
|
|
499
|
+
import {
|
|
500
|
+
parseSpecFile, // YAML file -> UniverseConfig
|
|
501
|
+
parseSpecString, // YAML string -> UniverseConfig
|
|
502
|
+
validateSpec, // Two-level validation
|
|
503
|
+
compileUniverse, // UniverseConfig -> live Universe
|
|
504
|
+
} from '@agents-uni/core';
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
### Bridge
|
|
508
|
+
|
|
509
|
+
```typescript
|
|
510
|
+
import {
|
|
511
|
+
// SOUL.md generation & deployment
|
|
512
|
+
generateSoul, // Generate SOUL.md for one agent
|
|
513
|
+
generateAllSouls, // Generate SOUL.md for all agents
|
|
514
|
+
deployToOpenClaw, // Deploy to OpenClaw workspaces + create agent runtime dirs + auto-register
|
|
515
|
+
registerAgentsInOpenClaw, // Register agents in openclaw.json (with workspace + agentDir)
|
|
516
|
+
checkWorkspaces, // Check existing workspace status
|
|
517
|
+
|
|
518
|
+
// 🆕 Multi-Uni Registry
|
|
519
|
+
registerUni, // Register universe in uni-registry.json
|
|
520
|
+
listUnis, // List all registered universes
|
|
521
|
+
getUni, // Get a single universe's info
|
|
522
|
+
unregisterUni, // Remove from registry
|
|
523
|
+
cleanupUni, // Delete workspace + agent dirs + registry entry
|
|
524
|
+
resetUni, // Clear runtime data, keep SOUL.md
|
|
525
|
+
updateUni, // Re-deploy, handle added/removed agents
|
|
526
|
+
|
|
527
|
+
// Task dispatch (file protocol)
|
|
528
|
+
TaskDispatcher, // Dispatch TASK.md → collect SUBMISSION.md
|
|
529
|
+
FileWorkspaceIO, // File-system I/O backend
|
|
530
|
+
MemoryWorkspaceIO, // In-memory I/O backend (for testing)
|
|
531
|
+
} from '@agents-uni/core';
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### Dashboard
|
|
535
|
+
|
|
536
|
+
```typescript
|
|
537
|
+
import {
|
|
538
|
+
createDashboardServer, // Create Dashboard Hono server
|
|
539
|
+
} from '@agents-uni/core';
|
|
540
|
+
|
|
541
|
+
import type {
|
|
542
|
+
DashboardExtension, // Dashboard extension interface
|
|
543
|
+
} from '@agents-uni/core';
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
## Project Structure
|
|
547
|
+
|
|
548
|
+
```
|
|
549
|
+
agents-uni-core/
|
|
550
|
+
src/
|
|
551
|
+
types/ # Complete type system (Agent, Relationship, Governance, ...)
|
|
552
|
+
core/ # Runtime engine (Universe, Registry, Graph, StateMachine, ...)
|
|
553
|
+
evolution/ # Self-optimization (Performance, Promotion, Memory, ...)
|
|
554
|
+
spec/ # YAML parsing, validation, compilation
|
|
555
|
+
bridge/ # OpenClaw bridge (SOUL.md, task dispatch, workspace I/O, uni registry)
|
|
556
|
+
dashboard/ # 🆕 Dashboard (Hono server, HTML templates, API routes, extension system)
|
|
557
|
+
schema/ # JSON Schema for spec validation
|
|
558
|
+
templates/ # 5 built-in organizational templates
|
|
559
|
+
cli/ # Command-line interface (10 commands)
|
|
560
|
+
create-uni/ # npx create-uni scaffolding tool
|
|
561
|
+
tests/ # Unit tests (41 tests, 7 suites)
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
## Development
|
|
565
|
+
|
|
566
|
+
```bash
|
|
567
|
+
# Install dependencies
|
|
568
|
+
npm install
|
|
569
|
+
|
|
570
|
+
# Run tests (41 tests)
|
|
571
|
+
npm test
|
|
572
|
+
|
|
573
|
+
# Type check
|
|
574
|
+
npm run lint
|
|
575
|
+
|
|
576
|
+
# Build
|
|
577
|
+
npm run build
|
|
578
|
+
|
|
579
|
+
# Watch mode
|
|
580
|
+
npm run dev
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
## Related Projects
|
|
584
|
+
|
|
585
|
+
- [**@agents-uni/zhenhuan**](https://github.com/agents-uni/zhenhuan) — Palace drama themed agent competition system built on agents-uni-core
|
|
586
|
+
|
|
587
|
+
## License
|
|
588
|
+
|
|
589
|
+
MIT
|