@agent-e/core 1.2.0 → 1.2.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 +20 -15
- package/dist/index.js +27 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,25 +13,30 @@ npm install @agent-e/core
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { AgentE } from '@agent-e/core';
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
const adapter = {
|
|
17
|
+
getState: () => ({
|
|
18
|
+
tick: currentTick,
|
|
19
|
+
agentBalances: { /* id → balance */ },
|
|
20
|
+
agentRoles: { /* id → role */ },
|
|
21
|
+
agentInventories: { /* id → { resource → qty } */ },
|
|
22
|
+
marketPrices: { /* resource → price */ },
|
|
23
|
+
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
|
|
28
|
+
}),
|
|
29
|
+
setParam: async (param, value) => {
|
|
30
|
+
// Apply parameter change to your economy
|
|
30
31
|
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const agent = new AgentE({
|
|
35
|
+
adapter,
|
|
31
36
|
mode: 'advisor', // or 'autonomous'
|
|
32
37
|
});
|
|
33
38
|
|
|
34
|
-
agent.connect(
|
|
39
|
+
agent.connect(adapter).start();
|
|
35
40
|
|
|
36
41
|
// Call once per tick in your loop:
|
|
37
42
|
await agent.tick();
|
package/dist/index.js
CHANGED
|
@@ -215,6 +215,7 @@ var Observer = class {
|
|
|
215
215
|
const tradeEvents = [];
|
|
216
216
|
const roleChangeEvents = [];
|
|
217
217
|
let churnCount = 0;
|
|
218
|
+
let productionAmount = 0;
|
|
218
219
|
for (const e of recentEvents) {
|
|
219
220
|
switch (e.type) {
|
|
220
221
|
case "mint":
|
|
@@ -225,6 +226,9 @@ var Observer = class {
|
|
|
225
226
|
case "consume":
|
|
226
227
|
sinkVolume += e.amount ?? 0;
|
|
227
228
|
break;
|
|
229
|
+
case "produce":
|
|
230
|
+
productionAmount += e.amount ?? 1;
|
|
231
|
+
break;
|
|
228
232
|
case "trade":
|
|
229
233
|
tradeEvents.push(e);
|
|
230
234
|
break;
|
|
@@ -298,7 +302,7 @@ var Observer = class {
|
|
|
298
302
|
pinchPoints[resource] = "optimal";
|
|
299
303
|
}
|
|
300
304
|
}
|
|
301
|
-
const productionIndex =
|
|
305
|
+
const productionIndex = productionAmount;
|
|
302
306
|
const maxPossibleProduction = productionIndex + sinkVolume;
|
|
303
307
|
const capacityUsage = maxPossibleProduction > 0 ? productionIndex / maxPossibleProduction : 0;
|
|
304
308
|
const satisfactions = Object.values(state.agentSatisfaction ?? {});
|
|
@@ -996,7 +1000,7 @@ var P12_OnePrimaryFaucet = {
|
|
|
996
1000
|
id: "P12",
|
|
997
1001
|
name: "One Primary Faucet",
|
|
998
1002
|
category: "currency",
|
|
999
|
-
description: "Multiple independent currency sources (gathering +
|
|
1003
|
+
description: "Multiple independent currency sources (gathering + production + quests) each creating currency causes uncontrolled inflation. One clear primary faucet makes the economy predictable and auditable.",
|
|
1000
1004
|
check(metrics, thresholds) {
|
|
1001
1005
|
const { netFlow, faucetVolume, sinkVolume } = metrics;
|
|
1002
1006
|
if (netFlow > thresholds.netFlowWarnThreshold) {
|
|
@@ -1008,7 +1012,7 @@ var P12_OnePrimaryFaucet = {
|
|
|
1008
1012
|
parameter: "productionCost",
|
|
1009
1013
|
direction: "increase",
|
|
1010
1014
|
magnitude: 0.15,
|
|
1011
|
-
reasoning: `Net flow +${netFlow.toFixed(1)}
|
|
1015
|
+
reasoning: `Net flow +${netFlow.toFixed(1)}/tick. Inflationary. Increase production cost (primary sink) to balance faucet output.`
|
|
1012
1016
|
},
|
|
1013
1017
|
confidence: 0.8,
|
|
1014
1018
|
estimatedLag: 8
|
|
@@ -1023,7 +1027,7 @@ var P12_OnePrimaryFaucet = {
|
|
|
1023
1027
|
parameter: "productionCost",
|
|
1024
1028
|
direction: "decrease",
|
|
1025
1029
|
magnitude: 0.15,
|
|
1026
|
-
reasoning: `Net flow ${netFlow.toFixed(1)}
|
|
1030
|
+
reasoning: `Net flow ${netFlow.toFixed(1)}/tick. Deflationary. Decrease production cost to ease sink pressure.`
|
|
1027
1031
|
},
|
|
1028
1032
|
confidence: 0.8,
|
|
1029
1033
|
estimatedLag: 8
|
|
@@ -1082,7 +1086,7 @@ var P14_TrackActualInjection = {
|
|
|
1082
1086
|
parameter: "yieldRate",
|
|
1083
1087
|
direction: "decrease",
|
|
1084
1088
|
magnitude: 0.1,
|
|
1085
|
-
reasoning: `Supply growing at ${(supplyGrowthRate * 100).toFixed(1)}%/tick. Verify
|
|
1089
|
+
reasoning: `Supply growing at ${(supplyGrowthRate * 100).toFixed(1)}%/tick. Verify currency injection tracking. Resources should not create currency directly.`
|
|
1086
1090
|
},
|
|
1087
1091
|
confidence: 0.55,
|
|
1088
1092
|
estimatedLag: 5
|
|
@@ -1095,7 +1099,7 @@ var P15_PoolsNeedCapAndDecay = {
|
|
|
1095
1099
|
id: "P15",
|
|
1096
1100
|
name: "Pools Need Cap + Decay",
|
|
1097
1101
|
category: "currency",
|
|
1098
|
-
description: "Any pool (bank, reward pool) without a cap accumulates infinitely.
|
|
1102
|
+
description: "Any pool (bank, reward pool) without a cap accumulates infinitely. A pool at 42% of total supply means 42% of the economy is frozen. Cap at 5%, decay at 2%/tick.",
|
|
1099
1103
|
check(metrics, thresholds) {
|
|
1100
1104
|
const { poolSizes, totalSupply } = metrics;
|
|
1101
1105
|
const { poolCapPercent } = thresholds;
|
|
@@ -1110,7 +1114,7 @@ var P15_PoolsNeedCapAndDecay = {
|
|
|
1110
1114
|
parameter: "transactionFee",
|
|
1111
1115
|
direction: "decrease",
|
|
1112
1116
|
magnitude: 0.1,
|
|
1113
|
-
reasoning: `${pool} pool at ${(shareOfSupply * 100).toFixed(1)}% of supply (cap: ${(poolCapPercent * 100).toFixed(0)}%).
|
|
1117
|
+
reasoning: `${pool} pool at ${(shareOfSupply * 100).toFixed(1)}% of supply (cap: ${(poolCapPercent * 100).toFixed(0)}%). Currency frozen. Lower fees to encourage circulation over accumulation.`
|
|
1114
1118
|
},
|
|
1115
1119
|
confidence: 0.85,
|
|
1116
1120
|
estimatedLag: 5
|
|
@@ -1252,25 +1256,22 @@ var P18_FirstProducerNeedsStartingInventory = {
|
|
|
1252
1256
|
description: "A producer with 0 resources and 0 currency must sell nothing to get currency before they can buy raw materials. This creates a chicken-and-egg freeze. Starting inventory (2 goods + 4 raw materials + 40 currency) breaks the deadlock.",
|
|
1253
1257
|
check(metrics, _thresholds) {
|
|
1254
1258
|
if (metrics.tick > 20) return { violated: false };
|
|
1259
|
+
const hasAgents = metrics.totalAgents > 0;
|
|
1255
1260
|
for (const [resource, supply] of Object.entries(metrics.supplyByResource)) {
|
|
1256
|
-
if (supply === 0) {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
estimatedLag: 2
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1261
|
+
if (supply === 0 && hasAgents) {
|
|
1262
|
+
return {
|
|
1263
|
+
violated: true,
|
|
1264
|
+
severity: 8,
|
|
1265
|
+
evidence: { tick: metrics.tick, resource, supply, totalAgents: metrics.totalAgents },
|
|
1266
|
+
suggestedAction: {
|
|
1267
|
+
parameter: "productionCost",
|
|
1268
|
+
direction: "decrease",
|
|
1269
|
+
magnitude: 0.5,
|
|
1270
|
+
reasoning: `Bootstrap failure: ${resource} supply is 0 at tick ${metrics.tick} with ${metrics.totalAgents} agents. Drastically reduce production cost to allow immediate output.`
|
|
1271
|
+
},
|
|
1272
|
+
confidence: 0.9,
|
|
1273
|
+
estimatedLag: 2
|
|
1274
|
+
};
|
|
1274
1275
|
}
|
|
1275
1276
|
}
|
|
1276
1277
|
return { violated: false };
|
|
@@ -1911,7 +1912,7 @@ var P42_TheMedianPrinciple = {
|
|
|
1911
1912
|
parameter: "transactionFee",
|
|
1912
1913
|
direction: "increase",
|
|
1913
1914
|
magnitude: 0.15,
|
|
1914
|
-
reasoning: `Mean/median divergence ${(meanMedianDivergence * 100).toFixed(0)}% (threshold: ${(thresholds.meanMedianDivergenceMax * 100).toFixed(0)}%). Economy has outliers skewing metrics. Use median for decisions. Raise
|
|
1915
|
+
reasoning: `Mean/median divergence ${(meanMedianDivergence * 100).toFixed(0)}% (threshold: ${(thresholds.meanMedianDivergenceMax * 100).toFixed(0)}%). Economy has outliers skewing metrics. Use median for decisions. Raise transaction fees to redistribute wealth.`
|
|
1915
1916
|
},
|
|
1916
1917
|
confidence: 0.85,
|
|
1917
1918
|
estimatedLag: 15
|