@agent-e/core 1.1.0 → 1.1.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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +42 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -5
package/dist/index.mjs
CHANGED
|
@@ -90,14 +90,38 @@ var Observer = class {
|
|
|
90
90
|
const balances = Object.values(state.agentBalances);
|
|
91
91
|
const roles = Object.values(state.agentRoles);
|
|
92
92
|
const totalAgents = balances.length;
|
|
93
|
+
let faucetVolume = 0;
|
|
94
|
+
let sinkVolume = 0;
|
|
95
|
+
const tradeEvents = [];
|
|
96
|
+
const roleChangeEvents = [];
|
|
97
|
+
let churnCount = 0;
|
|
98
|
+
for (const e of recentEvents) {
|
|
99
|
+
switch (e.type) {
|
|
100
|
+
case "mint":
|
|
101
|
+
case "spawn":
|
|
102
|
+
faucetVolume += e.amount ?? 0;
|
|
103
|
+
break;
|
|
104
|
+
case "burn":
|
|
105
|
+
case "consume":
|
|
106
|
+
sinkVolume += e.amount ?? 0;
|
|
107
|
+
break;
|
|
108
|
+
case "trade":
|
|
109
|
+
tradeEvents.push(e);
|
|
110
|
+
break;
|
|
111
|
+
case "churn":
|
|
112
|
+
churnCount++;
|
|
113
|
+
roleChangeEvents.push(e);
|
|
114
|
+
break;
|
|
115
|
+
case "role_change":
|
|
116
|
+
roleChangeEvents.push(e);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
93
120
|
const totalSupply = balances.reduce((s, b) => s + b, 0);
|
|
94
|
-
const faucetVolume = recentEvents.filter((e) => e.type === "mint" || e.type === "spawn").reduce((s, e) => s + (e.amount ?? 0), 0);
|
|
95
|
-
const sinkVolume = recentEvents.filter((e) => e.type === "burn" || e.type === "consume").reduce((s, e) => s + (e.amount ?? 0), 0);
|
|
96
121
|
const netFlow = faucetVolume - sinkVolume;
|
|
97
122
|
const tapSinkRatio = sinkVolume > 0 ? faucetVolume / sinkVolume : faucetVolume > 0 ? Infinity : 1;
|
|
98
123
|
const prevSupply = this.previousMetrics?.totalSupply ?? totalSupply;
|
|
99
124
|
const inflationRate = prevSupply > 0 ? (totalSupply - prevSupply) / prevSupply : 0;
|
|
100
|
-
const tradeEvents = recentEvents.filter((e) => e.type === "trade");
|
|
101
125
|
const velocity = totalSupply > 0 ? tradeEvents.length / totalSupply : 0;
|
|
102
126
|
const sortedBalances = [...balances].sort((a, b) => a - b);
|
|
103
127
|
const meanBalance = totalAgents > 0 ? totalSupply / totalAgents : 0;
|
|
@@ -116,12 +140,10 @@ var Observer = class {
|
|
|
116
140
|
roleShares[role] = count / Math.max(1, totalAgents);
|
|
117
141
|
}
|
|
118
142
|
const churnByRole = {};
|
|
119
|
-
|
|
120
|
-
for (const e of roleChanges) {
|
|
143
|
+
for (const e of roleChangeEvents) {
|
|
121
144
|
const role = e.role ?? "unknown";
|
|
122
145
|
churnByRole[role] = (churnByRole[role] ?? 0) + 1;
|
|
123
146
|
}
|
|
124
|
-
const churnCount = recentEvents.filter((e) => e.type === "churn").length;
|
|
125
147
|
const churnRate = churnCount / Math.max(1, totalAgents);
|
|
126
148
|
const prices = { ...state.marketPrices };
|
|
127
149
|
const priceVolatility = {};
|
|
@@ -184,7 +206,8 @@ var Observer = class {
|
|
|
184
206
|
for (let j = i + 1; j < priceKeys.length; j++) {
|
|
185
207
|
const pA = prices[priceKeys[i]];
|
|
186
208
|
const pB = prices[priceKeys[j]];
|
|
187
|
-
|
|
209
|
+
let ratio = pA / pB;
|
|
210
|
+
ratio = Math.max(1e-3, Math.min(1e3, ratio));
|
|
188
211
|
totalDivergence += Math.abs(Math.log(ratio));
|
|
189
212
|
pairCount++;
|
|
190
213
|
}
|
|
@@ -1553,7 +1576,7 @@ var P57_CombinatorialPriceSpace = {
|
|
|
1553
1576
|
magnitude: 0.1,
|
|
1554
1577
|
reasoning: `Only ${(convergenceRate * 100).toFixed(0)}% of ${relativePriceCount} relative prices have converged (target: ${(thresholds.relativePriceConvergenceTarget * 100).toFixed(0)}%). Price space too complex for distributed discovery. Lower friction to help.`
|
|
1555
1578
|
},
|
|
1556
|
-
confidence: 0.
|
|
1579
|
+
confidence: 0.55,
|
|
1557
1580
|
estimatedLag: thresholds.priceDiscoveryWindowTicks
|
|
1558
1581
|
};
|
|
1559
1582
|
}
|
|
@@ -1639,7 +1662,7 @@ var P55_ArbitrageThermometer = {
|
|
|
1639
1662
|
magnitude: 0.15,
|
|
1640
1663
|
reasoning: `Arbitrage index ${arbitrageIndex.toFixed(2)} exceeds critical threshold (${thresholds.arbitrageIndexCritical}). Relative prices are diverging \u2014 economy destabilizing. Lower trading friction to accelerate price convergence.`
|
|
1641
1664
|
},
|
|
1642
|
-
confidence: 0.
|
|
1665
|
+
confidence: 0.75,
|
|
1643
1666
|
estimatedLag: 8
|
|
1644
1667
|
};
|
|
1645
1668
|
}
|
|
@@ -2386,7 +2409,7 @@ var P56_ContentDropShock = {
|
|
|
2386
2409
|
magnitude: 0.1,
|
|
2387
2410
|
reasoning: `Content drop ${contentDropAge} ticks ago \u2014 arbitrage at ${arbitrageIndex.toFixed(2)} exceeds post-drop max (${thresholds.postDropArbitrageMax}). Price discovery struggling. Lower trading friction temporarily.`
|
|
2388
2411
|
},
|
|
2389
|
-
confidence: 0.
|
|
2412
|
+
confidence: 0.6,
|
|
2390
2413
|
estimatedLag: 5
|
|
2391
2414
|
};
|
|
2392
2415
|
}
|
|
@@ -2440,6 +2463,7 @@ var ALL_PRINCIPLES = [
|
|
|
2440
2463
|
var Simulator = class {
|
|
2441
2464
|
constructor() {
|
|
2442
2465
|
this.diagnoser = new Diagnoser(ALL_PRINCIPLES);
|
|
2466
|
+
this.beforeViolationsCache = /* @__PURE__ */ new Map();
|
|
2443
2467
|
}
|
|
2444
2468
|
/**
|
|
2445
2469
|
* Simulate the effect of applying `action` to the current economy forward `forwardTicks`.
|
|
@@ -2462,9 +2486,14 @@ var Simulator = class {
|
|
|
2462
2486
|
const p90 = sorted[Math.floor(actualIterations * 0.9)] ?? emptyMetrics();
|
|
2463
2487
|
const mean = this.averageMetrics(outcomes);
|
|
2464
2488
|
const netImprovement = this.checkImprovement(currentMetrics, p50, action);
|
|
2465
|
-
const
|
|
2466
|
-
|
|
2467
|
-
)
|
|
2489
|
+
const tick = currentMetrics.tick;
|
|
2490
|
+
let beforeViolations = this.beforeViolationsCache.get(tick);
|
|
2491
|
+
if (!beforeViolations) {
|
|
2492
|
+
beforeViolations = new Set(
|
|
2493
|
+
this.diagnoser.diagnose(currentMetrics, thresholds).map((d) => d.principle.id)
|
|
2494
|
+
);
|
|
2495
|
+
this.beforeViolationsCache.set(tick, beforeViolations);
|
|
2496
|
+
}
|
|
2468
2497
|
const afterViolations = new Set(
|
|
2469
2498
|
this.diagnoser.diagnose(p50, thresholds).map((d) => d.principle.id)
|
|
2470
2499
|
);
|