@agent-e/core 1.5.2 → 1.5.3
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.md +61 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @agent-e/core
|
|
2
2
|
|
|
3
|
-
Autonomous economic balancer SDK. 60 built-in principles, 5-stage pipeline, zero dependencies. Works with any digital economy
|
|
3
|
+
Autonomous economic balancer SDK. 60 built-in principles, 5-stage pipeline, zero dependencies. Works with any digital economy.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -17,20 +17,20 @@ const agent = new AgentE({
|
|
|
17
17
|
adapter: {
|
|
18
18
|
getState: () => ({
|
|
19
19
|
tick: currentTick,
|
|
20
|
-
currencies: ['
|
|
21
|
-
systems: ['
|
|
20
|
+
currencies: ['currency_a', 'currency_b'],
|
|
21
|
+
systems: ['system_1', 'system_2'],
|
|
22
22
|
agentBalances: {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
agent_001: { currency_a: 500, currency_b: 20 },
|
|
24
|
+
agent_002: { currency_a: 120, currency_b: 80 },
|
|
25
25
|
},
|
|
26
|
-
agentRoles: {
|
|
26
|
+
agentRoles: { agent_001: 'role_a', agent_002: 'role_b' },
|
|
27
27
|
marketPrices: {
|
|
28
|
-
|
|
28
|
+
currency_a: { resource_x: 10, resource_y: 25 },
|
|
29
29
|
},
|
|
30
|
-
agentSatisfaction: {
|
|
31
|
-
poolSizes: {
|
|
32
|
-
roles: ['
|
|
33
|
-
resources: ['
|
|
30
|
+
agentSatisfaction: { agent_001: 72, agent_002: 85 },
|
|
31
|
+
poolSizes: { main_pool: { currency_a: 5000 } },
|
|
32
|
+
roles: ['role_a', 'role_b'],
|
|
33
|
+
resources: ['resource_x', 'resource_y'],
|
|
34
34
|
recentTransactions: [],
|
|
35
35
|
}),
|
|
36
36
|
setParam: async (param, value, scope) => {
|
|
@@ -38,8 +38,8 @@ const agent = new AgentE({
|
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
parameters: [
|
|
41
|
-
{ key: '
|
|
42
|
-
{ key: '
|
|
41
|
+
{ key: 'your_fee_param', type: 'fee', flowImpact: 'friction', scope: { system: 'system_1' } },
|
|
42
|
+
{ key: 'your_reward_param', type: 'reward', flowImpact: 'faucet', scope: { system: 'system_2' } },
|
|
43
43
|
],
|
|
44
44
|
mode: 'advisor',
|
|
45
45
|
});
|
|
@@ -48,6 +48,8 @@ agent.start();
|
|
|
48
48
|
await agent.tick();
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
**Replace the placeholder names with YOUR economy's actual names.** See the root README for real-world examples (game, DeFi, marketplace).
|
|
52
|
+
|
|
51
53
|
## The 5-Stage Pipeline
|
|
52
54
|
|
|
53
55
|
1. **Observer** — Translates raw state into 40+ metrics at 3 resolutions (fine/medium/coarse)
|
|
@@ -58,19 +60,48 @@ await agent.tick();
|
|
|
58
60
|
|
|
59
61
|
## Parameter Registry
|
|
60
62
|
|
|
61
|
-
Register your
|
|
63
|
+
Register your parameters with semantic types and flow impacts:
|
|
62
64
|
|
|
63
65
|
```typescript
|
|
64
66
|
parameters: [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
// key: whatever YOU call it
|
|
68
|
+
// type: what kind of lever is it?
|
|
69
|
+
// flowImpact: what does it do to currency flow?
|
|
70
|
+
// scope: where in your economy does it live?
|
|
71
|
+
|
|
72
|
+
{ key: 'my_fee', type: 'fee', flowImpact: 'friction', scope: { system: 'trading' } },
|
|
73
|
+
{ key: 'my_reward', type: 'reward', flowImpact: 'faucet', scope: { system: 'engagement' } },
|
|
74
|
+
{ key: 'my_rate', type: 'rate', flowImpact: 'sink', scope: { system: 'burning' } },
|
|
75
|
+
{ key: 'my_yield', type: 'yield', flowImpact: 'faucet', scope: { system: 'staking', currency: 'currency_b' } },
|
|
76
|
+
{ key: 'my_cut', type: 'fee', flowImpact: 'sink', scope: { system: 'platform', tags: ['operator'] } },
|
|
70
77
|
]
|
|
71
78
|
```
|
|
72
79
|
|
|
73
|
-
Principles
|
|
80
|
+
Principles say "decrease `fee` in `trading`" — the registry resolves to `my_fee`. Your names stay yours.
|
|
81
|
+
|
|
82
|
+
### Semantic Types
|
|
83
|
+
|
|
84
|
+
| Type | What it means |
|
|
85
|
+
|------|--------------|
|
|
86
|
+
| `cost` | Something participants pay to do an action |
|
|
87
|
+
| `fee` | A percentage or flat charge on transactions |
|
|
88
|
+
| `reward` | Something participants receive for an action |
|
|
89
|
+
| `yield` | Passive income from holding or staking |
|
|
90
|
+
| `rate` | A speed or frequency multiplier |
|
|
91
|
+
| `multiplier` | A scaling factor |
|
|
92
|
+
| `threshold` | A boundary value that triggers behavior |
|
|
93
|
+
| `weight` | A relative importance factor |
|
|
94
|
+
| `custom` | Anything else |
|
|
95
|
+
|
|
96
|
+
### Flow Impacts
|
|
97
|
+
|
|
98
|
+
| Impact | What it does to currency flow |
|
|
99
|
+
|--------|------------------------------|
|
|
100
|
+
| `sink` | Removes currency from circulation |
|
|
101
|
+
| `faucet` | Adds currency to circulation |
|
|
102
|
+
| `friction` | Slows velocity without removing currency |
|
|
103
|
+
| `redistribution` | Moves currency between participants |
|
|
104
|
+
| `neutral` | No direct effect on flow |
|
|
74
105
|
|
|
75
106
|
## Multi-System, Multi-Currency
|
|
76
107
|
|
|
@@ -90,12 +121,12 @@ AgentE tracks each system and currency independently:
|
|
|
90
121
|
## Developer API
|
|
91
122
|
|
|
92
123
|
```typescript
|
|
93
|
-
// Lock
|
|
94
|
-
agent.lock('
|
|
95
|
-
agent.unlock('
|
|
124
|
+
// Lock — AgentE will never adjust this parameter
|
|
125
|
+
agent.lock('your_param_name');
|
|
126
|
+
agent.unlock('your_param_name');
|
|
96
127
|
|
|
97
|
-
// Constrain
|
|
98
|
-
agent.constrain('
|
|
128
|
+
// Constrain — AgentE can adjust, but only within this range
|
|
129
|
+
agent.constrain('another_param', { min: 0.01, max: 0.50 });
|
|
99
130
|
|
|
100
131
|
// Add a custom principle
|
|
101
132
|
agent.addPrinciple(myPrinciple);
|
|
@@ -125,11 +156,11 @@ import type { Principle } from '@agent-e/core';
|
|
|
125
156
|
|
|
126
157
|
const myRule: Principle = {
|
|
127
158
|
id: 'MY_01',
|
|
128
|
-
name: 'Provider Population
|
|
159
|
+
name: 'Minimum Provider Population',
|
|
129
160
|
category: 'population',
|
|
130
|
-
description: '
|
|
161
|
+
description: 'Triggers when a critical role drops below 5% of population',
|
|
131
162
|
check(metrics, thresholds) {
|
|
132
|
-
const share = metrics.roleShares['
|
|
163
|
+
const share = metrics.roleShares['role_a'] ?? 0;
|
|
133
164
|
if (share < 0.05) {
|
|
134
165
|
return {
|
|
135
166
|
violated: true,
|
|
@@ -137,10 +168,10 @@ const myRule: Principle = {
|
|
|
137
168
|
evidence: { share },
|
|
138
169
|
suggestedAction: {
|
|
139
170
|
parameterType: 'reward',
|
|
140
|
-
scope: { tags: ['
|
|
171
|
+
scope: { tags: ['role_a'] },
|
|
141
172
|
direction: 'increase',
|
|
142
173
|
magnitude: 0.25,
|
|
143
|
-
reasoning: '
|
|
174
|
+
reasoning: 'Critical role population below 5%.',
|
|
144
175
|
},
|
|
145
176
|
confidence: 0.90,
|
|
146
177
|
estimatedLag: 10,
|