@agent-e/core 1.2.1 → 1.3.1

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
@@ -16,18 +16,26 @@ import { AgentE } from '@agent-e/core';
16
16
  const adapter = {
17
17
  getState: () => ({
18
18
  tick: currentTick,
19
- agentBalances: { /* id → balance */ },
19
+ currencies: ['gold', 'gems'],
20
+ agentBalances: {
21
+ player1: { gold: 100, gems: 50 },
22
+ player2: { gold: 200, gems: 10 },
23
+ },
20
24
  agentRoles: { /* id → role */ },
21
25
  agentInventories: { /* id → { resource → qty } */ },
22
- marketPrices: { /* resource → price */ },
26
+ marketPrices: {
27
+ gold: { sword: 10, potion: 5 },
28
+ gems: { sword: 2, potion: 1 },
29
+ },
23
30
  agentSatisfaction: { /* id → 0-100 */ },
24
- poolSizes: { /* pool amount */ },
25
- roles: ['consumer', 'producer'], // all possible roles
26
- resources: ['goodA', 'goodB'], // all possible resources
27
- currency: 'credits', // currency name
31
+ poolSizes: { rewardPool: { gold: 500, gems: 100 } },
32
+ roles: ['warrior', 'mage'],
33
+ resources: ['sword', 'potion'],
34
+ recentTransactions: [],
28
35
  }),
29
- setParam: async (param, value) => {
30
- // Apply parameter change to your economy
36
+ setParam: async (param, value, currency) => {
37
+ // currency tells you which economy to adjust
38
+ applyToYourEconomy(param, value, currency);
31
39
  },
32
40
  };
33
41
 
@@ -50,6 +58,17 @@ await agent.tick();
50
58
  4. **Planner** — Lag-aware, cooldown-aware planning with rollback conditions
51
59
  5. **Executor** — Applies actions and monitors for rollback triggers
52
60
 
61
+ ## Multi-Currency Support
62
+
63
+ AgentE tracks each currency independently. Every currency gets its own:
64
+ - Supply, net flow, velocity, inflation rate
65
+ - Gini coefficient, median/mean balance, wealth distribution
66
+ - Faucet/sink volumes, pool sizes
67
+ - Price index, arbitrage index
68
+
69
+ When a principle detects an issue, the violation tells you which currency
70
+ is unhealthy and the suggested action is scoped to that currency.
71
+
53
72
  ## Modes
54
73
 
55
74
  | Mode | Behavior |
@@ -81,7 +100,8 @@ const agent = new AgentE({
81
100
 
82
101
  ```typescript
83
102
  // Lock a parameter from automated adjustment
84
- agent.lock('productionCost');
103
+ agent.lock('productionCost'); // lock for ALL currencies
104
+ // Future: agent.lock('productionCost', 'gems'); // lock for specific currency
85
105
  agent.unlock('productionCost');
86
106
 
87
107
  // Constrain a parameter to a range
package/dist/index.d.mts CHANGED
@@ -5,6 +5,7 @@ interface EconomicEvent {
5
5
  actor: string;
6
6
  role?: string;
7
7
  resource?: string;
8
+ currency?: string;
8
9
  amount?: number;
9
10
  price?: number;
10
11
  from?: string;
@@ -15,37 +16,58 @@ type PinchPointStatus = 'optimal' | 'oversupplied' | 'scarce';
15
16
  interface EconomyMetrics {
16
17
  tick: number;
17
18
  timestamp: number;
19
+ currencies: string[];
20
+ totalSupplyByCurrency: Record<string, number>;
21
+ netFlowByCurrency: Record<string, number>;
22
+ velocityByCurrency: Record<string, number>;
23
+ inflationRateByCurrency: Record<string, number>;
24
+ faucetVolumeByCurrency: Record<string, number>;
25
+ sinkVolumeByCurrency: Record<string, number>;
26
+ tapSinkRatioByCurrency: Record<string, number>;
27
+ anchorRatioDriftByCurrency: Record<string, number>;
18
28
  totalSupply: number;
19
29
  netFlow: number;
20
30
  velocity: number;
21
31
  inflationRate: number;
32
+ faucetVolume: number;
33
+ sinkVolume: number;
34
+ tapSinkRatio: number;
35
+ anchorRatioDrift: number;
36
+ giniCoefficientByCurrency: Record<string, number>;
37
+ medianBalanceByCurrency: Record<string, number>;
38
+ meanBalanceByCurrency: Record<string, number>;
39
+ top10PctShareByCurrency: Record<string, number>;
40
+ meanMedianDivergenceByCurrency: Record<string, number>;
41
+ giniCoefficient: number;
42
+ medianBalance: number;
43
+ meanBalance: number;
44
+ top10PctShare: number;
45
+ meanMedianDivergence: number;
22
46
  populationByRole: Record<string, number>;
23
47
  roleShares: Record<string, number>;
24
48
  totalAgents: number;
25
49
  churnRate: number;
26
50
  churnByRole: Record<string, number>;
27
51
  personaDistribution: Record<string, number>;
28
- giniCoefficient: number;
29
- medianBalance: number;
30
- meanBalance: number;
31
- top10PctShare: number;
32
- meanMedianDivergence: number;
52
+ priceIndexByCurrency: Record<string, number>;
53
+ pricesByCurrency: Record<string, Record<string, number>>;
54
+ priceVolatilityByCurrency: Record<string, Record<string, number>>;
33
55
  priceIndex: number;
34
- productionIndex: number;
35
- capacityUsage: number;
36
56
  prices: Record<string, number>;
37
57
  priceVolatility: Record<string, number>;
58
+ productionIndex: number;
59
+ capacityUsage: number;
38
60
  supplyByResource: Record<string, number>;
39
61
  demandSignals: Record<string, number>;
40
62
  pinchPoints: Record<string, PinchPointStatus>;
41
63
  avgSatisfaction: number;
42
64
  blockedAgentCount: number;
43
65
  timeToValue: number;
44
- faucetVolume: number;
45
- sinkVolume: number;
46
- tapSinkRatio: number;
66
+ poolSizesByCurrency: Record<string, Record<string, number>>;
47
67
  poolSizes: Record<string, number>;
48
- anchorRatioDrift: number;
68
+ extractionRatioByCurrency: Record<string, number>;
69
+ newUserDependencyByCurrency: Record<string, number>;
70
+ currencyInsulationByCurrency: Record<string, number>;
49
71
  extractionRatio: number;
50
72
  newUserDependency: number;
51
73
  smokeTestRatio: number;
@@ -53,9 +75,12 @@ interface EconomyMetrics {
53
75
  sharkToothPeaks: number[];
54
76
  sharkToothValleys: number[];
55
77
  eventCompletionRate: number;
78
+ arbitrageIndexByCurrency: Record<string, number>;
56
79
  arbitrageIndex: number;
57
80
  contentDropAge: number;
81
+ giftTradeRatioByCurrency: Record<string, number>;
58
82
  giftTradeRatio: number;
83
+ disposalTradeRatioByCurrency: Record<string, number>;
59
84
  disposalTradeRatio: number;
60
85
  custom: Record<string, number>;
61
86
  }
@@ -85,12 +110,14 @@ interface SuggestedAction {
85
110
  direction: 'increase' | 'decrease' | 'set';
86
111
  magnitude?: number;
87
112
  absoluteValue?: number;
113
+ currency?: string;
88
114
  reasoning: string;
89
115
  }
90
116
  interface ActionPlan {
91
117
  id: string;
92
118
  diagnosis: Diagnosis;
93
119
  parameter: string;
120
+ currency?: string;
94
121
  currentValue: number;
95
122
  targetValue: number;
96
123
  maxChangePercent: number;
@@ -143,21 +170,21 @@ interface EconomyState {
143
170
  tick: number;
144
171
  roles: string[];
145
172
  resources: string[];
146
- currency: string;
147
- agentBalances: Record<string, number>;
173
+ currencies: string[];
174
+ agentBalances: Record<string, Record<string, number>>;
148
175
  agentRoles: Record<string, string>;
149
176
  agentInventories: Record<string, Record<string, number>>;
150
177
  agentSatisfaction?: Record<string, number>;
151
- marketPrices: Record<string, number>;
178
+ marketPrices: Record<string, Record<string, number>>;
152
179
  recentTransactions: EconomicEvent[];
153
- poolSizes?: Record<string, number>;
180
+ poolSizes?: Record<string, Record<string, number>>;
154
181
  customData?: Record<string, unknown>;
155
182
  }
156
183
  interface EconomyAdapter {
157
184
  /** Return current full state snapshot */
158
185
  getState(): EconomyState | Promise<EconomyState>;
159
186
  /** Apply a parameter change to the host system */
160
- setParam(key: string, value: number): void | Promise<void>;
187
+ setParam(key: string, value: number, currency?: string): void | Promise<void>;
161
188
  /** Optional: adapter pushes events as they happen */
162
189
  onEvent?: (handler: (event: EconomicEvent) => void) => void;
163
190
  }
@@ -365,9 +392,9 @@ declare class AgentE {
365
392
 
366
393
  declare class Observer {
367
394
  private previousMetrics;
368
- private previousPrices;
395
+ private previousPricesByCurrency;
369
396
  private customMetricFns;
370
- private anchorBaseline;
397
+ private anchorBaselineByCurrency;
371
398
  private tickConfig;
372
399
  constructor(tickConfig?: Partial<TickConfig>);
373
400
  registerCustomMetric(name: string, fn: (state: EconomyState) => number): void;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ interface EconomicEvent {
5
5
  actor: string;
6
6
  role?: string;
7
7
  resource?: string;
8
+ currency?: string;
8
9
  amount?: number;
9
10
  price?: number;
10
11
  from?: string;
@@ -15,37 +16,58 @@ type PinchPointStatus = 'optimal' | 'oversupplied' | 'scarce';
15
16
  interface EconomyMetrics {
16
17
  tick: number;
17
18
  timestamp: number;
19
+ currencies: string[];
20
+ totalSupplyByCurrency: Record<string, number>;
21
+ netFlowByCurrency: Record<string, number>;
22
+ velocityByCurrency: Record<string, number>;
23
+ inflationRateByCurrency: Record<string, number>;
24
+ faucetVolumeByCurrency: Record<string, number>;
25
+ sinkVolumeByCurrency: Record<string, number>;
26
+ tapSinkRatioByCurrency: Record<string, number>;
27
+ anchorRatioDriftByCurrency: Record<string, number>;
18
28
  totalSupply: number;
19
29
  netFlow: number;
20
30
  velocity: number;
21
31
  inflationRate: number;
32
+ faucetVolume: number;
33
+ sinkVolume: number;
34
+ tapSinkRatio: number;
35
+ anchorRatioDrift: number;
36
+ giniCoefficientByCurrency: Record<string, number>;
37
+ medianBalanceByCurrency: Record<string, number>;
38
+ meanBalanceByCurrency: Record<string, number>;
39
+ top10PctShareByCurrency: Record<string, number>;
40
+ meanMedianDivergenceByCurrency: Record<string, number>;
41
+ giniCoefficient: number;
42
+ medianBalance: number;
43
+ meanBalance: number;
44
+ top10PctShare: number;
45
+ meanMedianDivergence: number;
22
46
  populationByRole: Record<string, number>;
23
47
  roleShares: Record<string, number>;
24
48
  totalAgents: number;
25
49
  churnRate: number;
26
50
  churnByRole: Record<string, number>;
27
51
  personaDistribution: Record<string, number>;
28
- giniCoefficient: number;
29
- medianBalance: number;
30
- meanBalance: number;
31
- top10PctShare: number;
32
- meanMedianDivergence: number;
52
+ priceIndexByCurrency: Record<string, number>;
53
+ pricesByCurrency: Record<string, Record<string, number>>;
54
+ priceVolatilityByCurrency: Record<string, Record<string, number>>;
33
55
  priceIndex: number;
34
- productionIndex: number;
35
- capacityUsage: number;
36
56
  prices: Record<string, number>;
37
57
  priceVolatility: Record<string, number>;
58
+ productionIndex: number;
59
+ capacityUsage: number;
38
60
  supplyByResource: Record<string, number>;
39
61
  demandSignals: Record<string, number>;
40
62
  pinchPoints: Record<string, PinchPointStatus>;
41
63
  avgSatisfaction: number;
42
64
  blockedAgentCount: number;
43
65
  timeToValue: number;
44
- faucetVolume: number;
45
- sinkVolume: number;
46
- tapSinkRatio: number;
66
+ poolSizesByCurrency: Record<string, Record<string, number>>;
47
67
  poolSizes: Record<string, number>;
48
- anchorRatioDrift: number;
68
+ extractionRatioByCurrency: Record<string, number>;
69
+ newUserDependencyByCurrency: Record<string, number>;
70
+ currencyInsulationByCurrency: Record<string, number>;
49
71
  extractionRatio: number;
50
72
  newUserDependency: number;
51
73
  smokeTestRatio: number;
@@ -53,9 +75,12 @@ interface EconomyMetrics {
53
75
  sharkToothPeaks: number[];
54
76
  sharkToothValleys: number[];
55
77
  eventCompletionRate: number;
78
+ arbitrageIndexByCurrency: Record<string, number>;
56
79
  arbitrageIndex: number;
57
80
  contentDropAge: number;
81
+ giftTradeRatioByCurrency: Record<string, number>;
58
82
  giftTradeRatio: number;
83
+ disposalTradeRatioByCurrency: Record<string, number>;
59
84
  disposalTradeRatio: number;
60
85
  custom: Record<string, number>;
61
86
  }
@@ -85,12 +110,14 @@ interface SuggestedAction {
85
110
  direction: 'increase' | 'decrease' | 'set';
86
111
  magnitude?: number;
87
112
  absoluteValue?: number;
113
+ currency?: string;
88
114
  reasoning: string;
89
115
  }
90
116
  interface ActionPlan {
91
117
  id: string;
92
118
  diagnosis: Diagnosis;
93
119
  parameter: string;
120
+ currency?: string;
94
121
  currentValue: number;
95
122
  targetValue: number;
96
123
  maxChangePercent: number;
@@ -143,21 +170,21 @@ interface EconomyState {
143
170
  tick: number;
144
171
  roles: string[];
145
172
  resources: string[];
146
- currency: string;
147
- agentBalances: Record<string, number>;
173
+ currencies: string[];
174
+ agentBalances: Record<string, Record<string, number>>;
148
175
  agentRoles: Record<string, string>;
149
176
  agentInventories: Record<string, Record<string, number>>;
150
177
  agentSatisfaction?: Record<string, number>;
151
- marketPrices: Record<string, number>;
178
+ marketPrices: Record<string, Record<string, number>>;
152
179
  recentTransactions: EconomicEvent[];
153
- poolSizes?: Record<string, number>;
180
+ poolSizes?: Record<string, Record<string, number>>;
154
181
  customData?: Record<string, unknown>;
155
182
  }
156
183
  interface EconomyAdapter {
157
184
  /** Return current full state snapshot */
158
185
  getState(): EconomyState | Promise<EconomyState>;
159
186
  /** Apply a parameter change to the host system */
160
- setParam(key: string, value: number): void | Promise<void>;
187
+ setParam(key: string, value: number, currency?: string): void | Promise<void>;
161
188
  /** Optional: adapter pushes events as they happen */
162
189
  onEvent?: (handler: (event: EconomicEvent) => void) => void;
163
190
  }
@@ -365,9 +392,9 @@ declare class AgentE {
365
392
 
366
393
  declare class Observer {
367
394
  private previousMetrics;
368
- private previousPrices;
395
+ private previousPricesByCurrency;
369
396
  private customMetricFns;
370
- private anchorBaseline;
397
+ private anchorBaselineByCurrency;
371
398
  private tickConfig;
372
399
  constructor(tickConfig?: Partial<TickConfig>);
373
400
  registerCustomMetric(name: string, fn: (state: EconomyState) => number): void;