@agent-e/core 1.5.2 → 1.5.4

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 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 — games, DeFi, marketplaces, token systems, social platforms.
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: ['credits', 'tokens'],
21
- systems: ['exchange', 'rewards'],
20
+ currencies: ['currency_a', 'currency_b'],
21
+ systems: ['system_1', 'system_2'],
22
22
  agentBalances: {
23
- user_a: { credits: 500, tokens: 20 },
24
- user_b: { credits: 300, tokens: 80 },
23
+ agent_001: { currency_a: 500, currency_b: 20 },
24
+ agent_002: { currency_a: 120, currency_b: 80 },
25
25
  },
26
- agentRoles: { user_a: 'provider', user_b: 'consumer' },
26
+ agentRoles: { agent_001: 'role_a', agent_002: 'role_b' },
27
27
  marketPrices: {
28
- credits: { service_a: 10, service_b: 25 },
28
+ currency_a: { resource_x: 10, resource_y: 25 },
29
29
  },
30
- agentSatisfaction: { user_a: 72, user_b: 85 },
31
- poolSizes: { rewardPool: { credits: 5000 } },
32
- roles: ['provider', 'consumer'],
33
- resources: ['service_a', 'service_b'],
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: 'exchangeFee', type: 'fee', flowImpact: 'friction', scope: { system: 'exchange' } },
42
- { key: 'dailyReward', type: 'reward', flowImpact: 'faucet', scope: { system: 'rewards' } },
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 economy's parameters with semantic types and flow impacts:
63
+ Register your parameters with semantic types and flow impacts:
62
64
 
63
65
  ```typescript
64
66
  parameters: [
65
- { key: 'tradeFee', type: 'fee', flowImpact: 'friction', scope: { system: 'trading' } },
66
- { key: 'mintReward', type: 'reward', flowImpact: 'faucet', scope: { system: 'minting' } },
67
- { key: 'burnRate', type: 'rate', flowImpact: 'sink', scope: { system: 'burning' } },
68
- { key: 'lpYield', type: 'yield', flowImpact: 'faucet', scope: { system: 'liquidity', currency: 'tokens' } },
69
- { key: 'platformCut', type: 'fee', flowImpact: 'sink', scope: { system: 'marketplace', tags: ['operator'] } },
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 target types (e.g., "decrease `fee` in `trading`"), and the registry resolves to your concrete parameter name.
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 a parameter from automated adjustment
94
- agent.lock('exchangeFee');
95
- agent.unlock('exchangeFee');
124
+ // Lock AgentE will never adjust this parameter
125
+ agent.lock('your_param_name');
126
+ agent.unlock('your_param_name');
96
127
 
97
- // Constrain a parameter to a range
98
- agent.constrain('dailyReward', { min: 1, max: 100 });
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 Floor',
159
+ name: 'Minimum Provider Population',
129
160
  category: 'population',
130
- description: 'Provider role share below 5% is a crisis',
161
+ description: 'Triggers when a critical role drops below 5% of population',
131
162
  check(metrics, thresholds) {
132
- const share = metrics.roleShares['provider'] ?? 0;
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: ['provider'] },
171
+ scope: { tags: ['role_a'] },
141
172
  direction: 'increase',
142
173
  magnitude: 0.25,
143
- reasoning: 'Provider population critically low.',
174
+ reasoning: 'Critical role population below 5%.',
144
175
  },
145
176
  confidence: 0.90,
146
177
  estimatedLag: 10,
package/dist/index.js CHANGED
@@ -494,7 +494,7 @@ var Observer = class {
494
494
  custom[name] = fn(state);
495
495
  } catch (err) {
496
496
  console.warn(`[AgentE] Custom metric '${name}' threw an error:`, err);
497
- custom[name] = NaN;
497
+ custom[name] = 0;
498
498
  }
499
499
  }
500
500
  const metrics = {