@agent-e/core 1.4.4 → 1.5.0

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 CHANGED
@@ -1,4 +1,63 @@
1
- type EconomicEventType = 'trade' | 'mint' | 'burn' | 'transfer' | 'produce' | 'consume' | 'role_change' | 'spawn' | 'churn';
1
+ /** High-level parameter categories (what it IS, not what it's called) */
2
+ type ParameterType = 'cost' | 'fee' | 'reward' | 'yield' | 'rate' | 'cap' | 'penalty' | 'multiplier' | string;
3
+ /** How a parameter change affects net currency flow */
4
+ type FlowImpact = 'sink' | 'faucet' | 'neutral' | 'mixed';
5
+ /** Scope narrows which concrete parameter a type resolves to */
6
+ interface ParameterScope {
7
+ system?: string;
8
+ currency?: string;
9
+ tags?: string[];
10
+ }
11
+ /** A registered parameter in the economy */
12
+ interface RegisteredParameter {
13
+ /** Concrete key used by the adapter (e.g. 'craftingCost', 'stakingYield') */
14
+ key: string;
15
+ /** What type of parameter this is */
16
+ type: ParameterType;
17
+ /** How changing this affects net flow */
18
+ flowImpact: FlowImpact;
19
+ /** Scope constraints — narrows resolution */
20
+ scope?: Partial<ParameterScope>;
21
+ /** Current value (updated after each apply) */
22
+ currentValue?: number;
23
+ /** Human-readable description */
24
+ description?: string;
25
+ }
26
+ declare class ParameterRegistry {
27
+ private parameters;
28
+ /** Register a parameter. Overwrites if key already exists. */
29
+ register(param: RegisteredParameter): void;
30
+ /** Register multiple parameters at once. */
31
+ registerAll(params: RegisteredParameter[]): void;
32
+ /**
33
+ * Resolve a parameterType + scope to a concrete RegisteredParameter.
34
+ * Returns the best match, or undefined if no match.
35
+ *
36
+ * Matching rules (in priority order):
37
+ * 1. Exact type match + all scope fields match
38
+ * 2. Exact type match + partial scope match (tags overlap)
39
+ * 3. Exact type match + no scope constraints
40
+ * 4. undefined (no match)
41
+ */
42
+ resolve(type: ParameterType, scope?: Partial<ParameterScope>): RegisteredParameter | undefined;
43
+ /** Find all parameters of a given type. */
44
+ findByType(type: ParameterType): RegisteredParameter[];
45
+ /** Find all parameters belonging to a given system. */
46
+ findBySystem(system: string): RegisteredParameter[];
47
+ /** Get a parameter by its concrete key. */
48
+ get(key: string): RegisteredParameter | undefined;
49
+ /** Get the flow impact of a parameter by its concrete key. */
50
+ getFlowImpact(key: string): FlowImpact | undefined;
51
+ /** Update the current value of a registered parameter. */
52
+ updateValue(key: string, value: number): void;
53
+ /** Get all registered parameters. */
54
+ getAll(): RegisteredParameter[];
55
+ /** Number of registered parameters. */
56
+ get size(): number;
57
+ private scopeMatchScore;
58
+ }
59
+
60
+ type EconomicEventType = 'trade' | 'mint' | 'burn' | 'transfer' | 'produce' | 'consume' | 'role_change' | 'enter' | 'churn';
2
61
  interface EconomicEvent {
3
62
  type: EconomicEventType;
4
63
  timestamp: number;
@@ -10,6 +69,8 @@ interface EconomicEvent {
10
69
  price?: number;
11
70
  from?: string;
12
71
  to?: string;
72
+ system?: string;
73
+ sourceOrSink?: string;
13
74
  metadata?: Record<string, unknown>;
14
75
  }
15
76
  type PinchPointStatus = 'optimal' | 'oversupplied' | 'scarce';
@@ -82,10 +143,17 @@ interface EconomyMetrics {
82
143
  giftTradeRatio: number;
83
144
  disposalTradeRatioByCurrency: Record<string, number>;
84
145
  disposalTradeRatio: number;
146
+ flowBySystem: Record<string, number>;
147
+ activityBySystem: Record<string, number>;
148
+ participantsBySystem: Record<string, number>;
149
+ flowBySource: Record<string, number>;
150
+ flowBySink: Record<string, number>;
151
+ sourceShare: Record<string, number>;
152
+ sinkShare: Record<string, number>;
85
153
  custom: Record<string, number>;
86
154
  }
87
155
  declare function emptyMetrics(tick?: number): EconomyMetrics;
88
- type PrincipleCategory = 'supply_chain' | 'incentive' | 'population' | 'currency' | 'bootstrap' | 'feedback' | 'regulator' | 'market_dynamics' | 'measurement' | 'wealth_distribution' | 'resource' | 'system_design' | 'player_experience' | 'statistical' | 'system_dynamics' | 'open_economy' | 'liveops';
156
+ type PrincipleCategory = 'supply_chain' | 'incentive' | 'population' | 'currency' | 'bootstrap' | 'feedback' | 'regulator' | 'market_dynamics' | 'measurement' | 'wealth_distribution' | 'resource' | 'system_design' | 'participant_experience' | 'statistical' | 'system_dynamics' | 'open_economy' | 'operations';
89
157
  interface PrincipleViolation {
90
158
  violated: true;
91
159
  severity: number;
@@ -106,18 +174,19 @@ interface Principle {
106
174
  check: (metrics: EconomyMetrics, thresholds: Thresholds) => PrincipleResult;
107
175
  }
108
176
  interface SuggestedAction {
109
- parameter: string;
177
+ parameterType: ParameterType;
110
178
  direction: 'increase' | 'decrease' | 'set';
111
179
  magnitude?: number;
112
180
  absoluteValue?: number;
113
- currency?: string;
181
+ scope?: Partial<ParameterScope>;
182
+ resolvedParameter?: string;
114
183
  reasoning: string;
115
184
  }
116
185
  interface ActionPlan {
117
186
  id: string;
118
187
  diagnosis: Diagnosis;
119
188
  parameter: string;
120
- currency?: string;
189
+ scope?: ParameterScope;
121
190
  currentValue: number;
122
191
  targetValue: number;
123
192
  maxChangePercent: number;
@@ -178,13 +247,16 @@ interface EconomyState {
178
247
  marketPrices: Record<string, Record<string, number>>;
179
248
  recentTransactions: EconomicEvent[];
180
249
  poolSizes?: Record<string, Record<string, number>>;
250
+ systems?: string[];
251
+ sources?: string[];
252
+ sinks?: string[];
181
253
  customData?: Record<string, unknown>;
182
254
  }
183
255
  interface EconomyAdapter {
184
256
  /** Return current full state snapshot */
185
257
  getState(): EconomyState | Promise<EconomyState>;
186
258
  /** Apply a parameter change to the host system */
187
- setParam(key: string, value: number, currency?: string): void | Promise<void>;
259
+ setParam(key: string, value: number, scope?: ParameterScope): void | Promise<void>;
188
260
  /** Optional: adapter pushes events as they happen */
189
261
  onEvent?: (handler: (event: EconomicEvent) => void) => void;
190
262
  }
@@ -247,6 +319,7 @@ interface AgentEConfig {
247
319
  mode?: AgentEMode;
248
320
  dominantRoles?: string[];
249
321
  idealDistribution?: Record<string, number>;
322
+ parameters?: RegisteredParameter[];
250
323
  tickConfig?: Partial<TickConfig>;
251
324
  gracePeriod?: number;
252
325
  checkInterval?: number;
@@ -257,7 +330,7 @@ interface AgentEConfig {
257
330
  onAlert?: (diagnosis: Diagnosis) => void;
258
331
  onRollback?: (plan: ActionPlan, reason: string) => void;
259
332
  }
260
- type PersonaType = 'Active' | 'Trader' | 'Collector' | 'Speculator' | 'Earner' | 'Builder' | 'Social' | 'Whale' | 'Influencer';
333
+ type PersonaType = 'Active' | 'Trader' | 'Collector' | 'Speculator' | 'Earner' | 'Builder' | 'Social' | 'HighValue' | 'Influencer' | string;
261
334
  interface PersonaProfile {
262
335
  type: PersonaType;
263
336
  share: number;
@@ -347,6 +420,7 @@ declare class AgentE {
347
420
  private simulator;
348
421
  private planner;
349
422
  private executor;
423
+ private registry;
350
424
  readonly log: DecisionLog;
351
425
  readonly store: MetricStore;
352
426
  private personaTracker;
@@ -375,6 +449,8 @@ declare class AgentE {
375
449
  setMode(mode: AgentEMode): void;
376
450
  getMode(): AgentEMode;
377
451
  removePrinciple(id: string): void;
452
+ registerParameter(param: RegisteredParameter): void;
453
+ getRegistry(): ParameterRegistry;
378
454
  registerCustomMetric(name: string, fn: (state: EconomyState) => number): void;
379
455
  getDecisions(filter?: Parameters<DecisionLog['query']>[0]): DecisionEntry[];
380
456
  getPrinciples(): Principle[];
@@ -405,6 +481,8 @@ declare class Observer {
405
481
 
406
482
  declare class Simulator {
407
483
  private diagnoser;
484
+ private registry;
485
+ constructor(registry?: ParameterRegistry);
408
486
  private beforeViolationsCache;
409
487
  /**
410
488
  * Simulate the effect of applying `action` to the current economy forward `forwardTicks`.
@@ -422,6 +500,8 @@ declare class Simulator {
422
500
  private runForward;
423
501
  private actionMultiplier;
424
502
  private flowEffect;
503
+ /** Infer flow impact from parameter type when registry is unavailable */
504
+ private inferFlowImpact;
425
505
  private checkImprovement;
426
506
  private averageMetrics;
427
507
  }
@@ -445,10 +525,12 @@ declare class Planner {
445
525
  * - parameter is still in cooldown
446
526
  * - simulation result failed
447
527
  * - complexity budget exceeded
528
+ * - no matching parameter in registry
448
529
  */
449
- plan(diagnosis: Diagnosis, metrics: EconomyMetrics, simulationResult: SimulationResult, currentParams: Record<string, number>, thresholds: Thresholds): ActionPlan | null;
530
+ plan(diagnosis: Diagnosis, metrics: EconomyMetrics, simulationResult: SimulationResult, currentParams: Record<string, number>, thresholds: Thresholds, registry?: ParameterRegistry): ActionPlan | null;
450
531
  recordApplied(plan: ActionPlan, tick: number): void;
451
532
  recordRolledBack(_plan: ActionPlan): void;
533
+ recordSettled(_plan: ActionPlan): void;
452
534
  isOnCooldown(param: string, currentTick: number, cooldownTicks: number): boolean;
453
535
  /** Reset all cooldowns (useful for testing) */
454
536
  resetCooldowns(): void;
@@ -459,10 +541,12 @@ declare class Executor {
459
541
  apply(plan: ActionPlan, adapter: EconomyAdapter, currentParams: Record<string, number>): Promise<void>;
460
542
  /**
461
543
  * Check all active plans for rollback conditions.
462
- * Called every tick after metrics are computed.
463
- * Returns list of plans that were rolled back.
544
+ * Returns { rolledBack, settled } plans that were undone and plans that passed their window.
464
545
  */
465
- checkRollbacks(metrics: EconomyMetrics, adapter: EconomyAdapter): Promise<ActionPlan[]>;
546
+ checkRollbacks(metrics: EconomyMetrics, adapter: EconomyAdapter): Promise<{
547
+ rolledBack: ActionPlan[];
548
+ settled: ActionPlan[];
549
+ }>;
466
550
  private getMetricValue;
467
551
  getActivePlans(): ActionPlan[];
468
552
  }
@@ -575,7 +659,7 @@ declare const P36_MechanicFrictionDetector: Principle;
575
659
  declare const P37_LatecommerProblem: Principle;
576
660
  declare const P45_TimeBudget: Principle;
577
661
  declare const P50_PayPowerRatio: Principle;
578
- declare const PLAYER_EXPERIENCE_PRINCIPLES: Principle[];
662
+ declare const PARTICIPANT_EXPERIENCE_PRINCIPLES: Principle[];
579
663
 
580
664
  declare const P34_ExtractionRatio: Principle;
581
665
  declare const P47_SmokeTest: Principle;
@@ -587,9 +671,9 @@ declare const P52_EndowmentEffect: Principle;
587
671
  declare const P53_EventCompletionRate: Principle;
588
672
  declare const P54_LiveOpsCadence: Principle;
589
673
  declare const P56_ContentDropShock: Principle;
590
- declare const LIVEOPS_PRINCIPLES: Principle[];
674
+ declare const OPERATIONS_PRINCIPLES: Principle[];
591
675
 
592
- /** All 60 built-in principles in priority order (supply chain → liveops) */
676
+ /** All 60 built-in principles in priority order (supply chain → operations) */
593
677
  declare const ALL_PRINCIPLES: Principle[];
594
678
 
595
- export { ALL_PRINCIPLES, type ActionPlan, AgentE, type AgentEConfig, type AgentEMode, BOOTSTRAP_PRINCIPLES, CURRENCY_FLOW_PRINCIPLES, DEFAULT_THRESHOLDS, type DecisionEntry, DecisionLog, type DecisionResult, Diagnoser, type Diagnosis, type EconomicEvent, type EconomicEventType, type EconomyAdapter, type EconomyMetrics, type EconomyState, Executor, FEEDBACK_LOOP_PRINCIPLES, INCENTIVE_PRINCIPLES, LIVEOPS_PRINCIPLES, MARKET_DYNAMICS_PRINCIPLES, MEASUREMENT_PRINCIPLES, type MetricQuery, type MetricQueryResult, type MetricResolution, MetricStore, OPEN_ECONOMY_PRINCIPLES, Observer, P10_SpawnWeightingUsesInversePopulation, P11_TwoTierPressure, P12_OnePrimaryFaucet, P13_PotsAreZeroSumAndSelfRegulate, P14_TrackActualInjection, P15_PoolsNeedCapAndDecay, P16_WithdrawalPenaltyScales, P17_GracePeriodBeforeIntervention, P18_FirstProducerNeedsStartingInventory, P19_StartingSupplyExceedsDemand, P1_ProductionMatchesConsumption, P20_DecayPreventsAccumulation, P21_PriceFromGlobalSupply, P22_MarketAwarenessPreventsSurplus, P23_ProfitabilityFactorsFeasibility, P24_BlockedAgentsDecayFaster, P25_CorrectLeversForCorrectProblems, P26_ContinuousPressureBeatsThresholdCuts, P27_AdjustmentsNeedCooldowns, P28_StructuralDominanceIsNotPathological, P29_PinchPoint, P2_ClosedLoopsNeedDirectHandoff, P30_MovingPinchPoint, P31_AnchorValueTracking, P32_VelocityAboveSupply, P33_FairNotEqual, P34_ExtractionRatio, P35_DestructionCreatesValue, P36_MechanicFrictionDetector, P37_LatecommerProblem, P38_CommunicationPreventsRevolt, P39_TheLagPrinciple, P3_BootstrapCapitalCoversFirstTransaction, P40_ReplacementRate, P41_MultiResolutionMonitoring, P42_TheMedianPrinciple, P43_SimulationMinimum, P44_ComplexityBudget, P45_TimeBudget, P46_PersonaDiversity, P47_SmokeTest, P48_CurrencyInsulation, P49_IdleAssetTax, P4_MaterialsFlowFasterThanCooldown, P50_PayPowerRatio, P51_SharkTooth, P52_EndowmentEffect, P53_EventCompletionRate, P54_LiveOpsCadence, P55_ArbitrageThermometer, P56_ContentDropShock, P57_CombinatorialPriceSpace, P58_NoNaturalNumeraire, P59_GiftEconomyNoise, P5_ProfitabilityIsCompetitive, P60_SurplusDisposalAsymmetry, P6_CrowdingMultiplierOnAllRoles, P7_NonSpecialistsSubsidiseSpecialists, P8_RegulatorCannotFightDesign, P9_RoleSwitchingNeedsFriction, PERSONA_HEALTHY_RANGES, PLAYER_EXPERIENCE_PRINCIPLES, POPULATION_PRINCIPLES, type PersonaProfile, PersonaTracker, type PersonaType, type PinchPointStatus, Planner, type Principle, type PrincipleCategory, type PrincipleOk, type PrincipleResult, type PrincipleViolation, REGULATOR_PRINCIPLES, RESOURCE_MGMT_PRINCIPLES, type RollbackCondition, STATISTICAL_PRINCIPLES, SUPPLY_CHAIN_PRINCIPLES, SYSTEM_DYNAMICS_PRINCIPLES, type SimulationOutcome, type SimulationResult, Simulator, type SuggestedAction, type Thresholds, type TickConfig, type ValidationError, type ValidationResult, type ValidationWarning, emptyMetrics, validateEconomyState };
679
+ export { ALL_PRINCIPLES, type ActionPlan, AgentE, type AgentEConfig, type AgentEMode, BOOTSTRAP_PRINCIPLES, CURRENCY_FLOW_PRINCIPLES, DEFAULT_THRESHOLDS, type DecisionEntry, DecisionLog, type DecisionResult, Diagnoser, type Diagnosis, type EconomicEvent, type EconomicEventType, type EconomyAdapter, type EconomyMetrics, type EconomyState, Executor, FEEDBACK_LOOP_PRINCIPLES, type FlowImpact, INCENTIVE_PRINCIPLES, MARKET_DYNAMICS_PRINCIPLES, MEASUREMENT_PRINCIPLES, type MetricQuery, type MetricQueryResult, type MetricResolution, MetricStore, OPEN_ECONOMY_PRINCIPLES, OPERATIONS_PRINCIPLES, Observer, P10_SpawnWeightingUsesInversePopulation, P11_TwoTierPressure, P12_OnePrimaryFaucet, P13_PotsAreZeroSumAndSelfRegulate, P14_TrackActualInjection, P15_PoolsNeedCapAndDecay, P16_WithdrawalPenaltyScales, P17_GracePeriodBeforeIntervention, P18_FirstProducerNeedsStartingInventory, P19_StartingSupplyExceedsDemand, P1_ProductionMatchesConsumption, P20_DecayPreventsAccumulation, P21_PriceFromGlobalSupply, P22_MarketAwarenessPreventsSurplus, P23_ProfitabilityFactorsFeasibility, P24_BlockedAgentsDecayFaster, P25_CorrectLeversForCorrectProblems, P26_ContinuousPressureBeatsThresholdCuts, P27_AdjustmentsNeedCooldowns, P28_StructuralDominanceIsNotPathological, P29_PinchPoint, P2_ClosedLoopsNeedDirectHandoff, P30_MovingPinchPoint, P31_AnchorValueTracking, P32_VelocityAboveSupply, P33_FairNotEqual, P34_ExtractionRatio, P35_DestructionCreatesValue, P36_MechanicFrictionDetector, P37_LatecommerProblem, P38_CommunicationPreventsRevolt, P39_TheLagPrinciple, P3_BootstrapCapitalCoversFirstTransaction, P40_ReplacementRate, P41_MultiResolutionMonitoring, P42_TheMedianPrinciple, P43_SimulationMinimum, P44_ComplexityBudget, P45_TimeBudget, P46_PersonaDiversity, P47_SmokeTest, P48_CurrencyInsulation, P49_IdleAssetTax, P4_MaterialsFlowFasterThanCooldown, P50_PayPowerRatio, P51_SharkTooth, P52_EndowmentEffect, P53_EventCompletionRate, P54_LiveOpsCadence, P55_ArbitrageThermometer, P56_ContentDropShock, P57_CombinatorialPriceSpace, P58_NoNaturalNumeraire, P59_GiftEconomyNoise, P5_ProfitabilityIsCompetitive, P60_SurplusDisposalAsymmetry, P6_CrowdingMultiplierOnAllRoles, P7_NonSpecialistsSubsidiseSpecialists, P8_RegulatorCannotFightDesign, P9_RoleSwitchingNeedsFriction, PARTICIPANT_EXPERIENCE_PRINCIPLES, PERSONA_HEALTHY_RANGES, POPULATION_PRINCIPLES, ParameterRegistry, type ParameterScope, type ParameterType, type PersonaProfile, PersonaTracker, type PersonaType, type PinchPointStatus, Planner, type Principle, type PrincipleCategory, type PrincipleOk, type PrincipleResult, type PrincipleViolation, REGULATOR_PRINCIPLES, RESOURCE_MGMT_PRINCIPLES, type RegisteredParameter, type RollbackCondition, STATISTICAL_PRINCIPLES, SUPPLY_CHAIN_PRINCIPLES, SYSTEM_DYNAMICS_PRINCIPLES, type SimulationOutcome, type SimulationResult, Simulator, type SuggestedAction, type Thresholds, type TickConfig, type ValidationError, type ValidationResult, type ValidationWarning, emptyMetrics, validateEconomyState };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,63 @@
1
- type EconomicEventType = 'trade' | 'mint' | 'burn' | 'transfer' | 'produce' | 'consume' | 'role_change' | 'spawn' | 'churn';
1
+ /** High-level parameter categories (what it IS, not what it's called) */
2
+ type ParameterType = 'cost' | 'fee' | 'reward' | 'yield' | 'rate' | 'cap' | 'penalty' | 'multiplier' | string;
3
+ /** How a parameter change affects net currency flow */
4
+ type FlowImpact = 'sink' | 'faucet' | 'neutral' | 'mixed';
5
+ /** Scope narrows which concrete parameter a type resolves to */
6
+ interface ParameterScope {
7
+ system?: string;
8
+ currency?: string;
9
+ tags?: string[];
10
+ }
11
+ /** A registered parameter in the economy */
12
+ interface RegisteredParameter {
13
+ /** Concrete key used by the adapter (e.g. 'craftingCost', 'stakingYield') */
14
+ key: string;
15
+ /** What type of parameter this is */
16
+ type: ParameterType;
17
+ /** How changing this affects net flow */
18
+ flowImpact: FlowImpact;
19
+ /** Scope constraints — narrows resolution */
20
+ scope?: Partial<ParameterScope>;
21
+ /** Current value (updated after each apply) */
22
+ currentValue?: number;
23
+ /** Human-readable description */
24
+ description?: string;
25
+ }
26
+ declare class ParameterRegistry {
27
+ private parameters;
28
+ /** Register a parameter. Overwrites if key already exists. */
29
+ register(param: RegisteredParameter): void;
30
+ /** Register multiple parameters at once. */
31
+ registerAll(params: RegisteredParameter[]): void;
32
+ /**
33
+ * Resolve a parameterType + scope to a concrete RegisteredParameter.
34
+ * Returns the best match, or undefined if no match.
35
+ *
36
+ * Matching rules (in priority order):
37
+ * 1. Exact type match + all scope fields match
38
+ * 2. Exact type match + partial scope match (tags overlap)
39
+ * 3. Exact type match + no scope constraints
40
+ * 4. undefined (no match)
41
+ */
42
+ resolve(type: ParameterType, scope?: Partial<ParameterScope>): RegisteredParameter | undefined;
43
+ /** Find all parameters of a given type. */
44
+ findByType(type: ParameterType): RegisteredParameter[];
45
+ /** Find all parameters belonging to a given system. */
46
+ findBySystem(system: string): RegisteredParameter[];
47
+ /** Get a parameter by its concrete key. */
48
+ get(key: string): RegisteredParameter | undefined;
49
+ /** Get the flow impact of a parameter by its concrete key. */
50
+ getFlowImpact(key: string): FlowImpact | undefined;
51
+ /** Update the current value of a registered parameter. */
52
+ updateValue(key: string, value: number): void;
53
+ /** Get all registered parameters. */
54
+ getAll(): RegisteredParameter[];
55
+ /** Number of registered parameters. */
56
+ get size(): number;
57
+ private scopeMatchScore;
58
+ }
59
+
60
+ type EconomicEventType = 'trade' | 'mint' | 'burn' | 'transfer' | 'produce' | 'consume' | 'role_change' | 'enter' | 'churn';
2
61
  interface EconomicEvent {
3
62
  type: EconomicEventType;
4
63
  timestamp: number;
@@ -10,6 +69,8 @@ interface EconomicEvent {
10
69
  price?: number;
11
70
  from?: string;
12
71
  to?: string;
72
+ system?: string;
73
+ sourceOrSink?: string;
13
74
  metadata?: Record<string, unknown>;
14
75
  }
15
76
  type PinchPointStatus = 'optimal' | 'oversupplied' | 'scarce';
@@ -82,10 +143,17 @@ interface EconomyMetrics {
82
143
  giftTradeRatio: number;
83
144
  disposalTradeRatioByCurrency: Record<string, number>;
84
145
  disposalTradeRatio: number;
146
+ flowBySystem: Record<string, number>;
147
+ activityBySystem: Record<string, number>;
148
+ participantsBySystem: Record<string, number>;
149
+ flowBySource: Record<string, number>;
150
+ flowBySink: Record<string, number>;
151
+ sourceShare: Record<string, number>;
152
+ sinkShare: Record<string, number>;
85
153
  custom: Record<string, number>;
86
154
  }
87
155
  declare function emptyMetrics(tick?: number): EconomyMetrics;
88
- type PrincipleCategory = 'supply_chain' | 'incentive' | 'population' | 'currency' | 'bootstrap' | 'feedback' | 'regulator' | 'market_dynamics' | 'measurement' | 'wealth_distribution' | 'resource' | 'system_design' | 'player_experience' | 'statistical' | 'system_dynamics' | 'open_economy' | 'liveops';
156
+ type PrincipleCategory = 'supply_chain' | 'incentive' | 'population' | 'currency' | 'bootstrap' | 'feedback' | 'regulator' | 'market_dynamics' | 'measurement' | 'wealth_distribution' | 'resource' | 'system_design' | 'participant_experience' | 'statistical' | 'system_dynamics' | 'open_economy' | 'operations';
89
157
  interface PrincipleViolation {
90
158
  violated: true;
91
159
  severity: number;
@@ -106,18 +174,19 @@ interface Principle {
106
174
  check: (metrics: EconomyMetrics, thresholds: Thresholds) => PrincipleResult;
107
175
  }
108
176
  interface SuggestedAction {
109
- parameter: string;
177
+ parameterType: ParameterType;
110
178
  direction: 'increase' | 'decrease' | 'set';
111
179
  magnitude?: number;
112
180
  absoluteValue?: number;
113
- currency?: string;
181
+ scope?: Partial<ParameterScope>;
182
+ resolvedParameter?: string;
114
183
  reasoning: string;
115
184
  }
116
185
  interface ActionPlan {
117
186
  id: string;
118
187
  diagnosis: Diagnosis;
119
188
  parameter: string;
120
- currency?: string;
189
+ scope?: ParameterScope;
121
190
  currentValue: number;
122
191
  targetValue: number;
123
192
  maxChangePercent: number;
@@ -178,13 +247,16 @@ interface EconomyState {
178
247
  marketPrices: Record<string, Record<string, number>>;
179
248
  recentTransactions: EconomicEvent[];
180
249
  poolSizes?: Record<string, Record<string, number>>;
250
+ systems?: string[];
251
+ sources?: string[];
252
+ sinks?: string[];
181
253
  customData?: Record<string, unknown>;
182
254
  }
183
255
  interface EconomyAdapter {
184
256
  /** Return current full state snapshot */
185
257
  getState(): EconomyState | Promise<EconomyState>;
186
258
  /** Apply a parameter change to the host system */
187
- setParam(key: string, value: number, currency?: string): void | Promise<void>;
259
+ setParam(key: string, value: number, scope?: ParameterScope): void | Promise<void>;
188
260
  /** Optional: adapter pushes events as they happen */
189
261
  onEvent?: (handler: (event: EconomicEvent) => void) => void;
190
262
  }
@@ -247,6 +319,7 @@ interface AgentEConfig {
247
319
  mode?: AgentEMode;
248
320
  dominantRoles?: string[];
249
321
  idealDistribution?: Record<string, number>;
322
+ parameters?: RegisteredParameter[];
250
323
  tickConfig?: Partial<TickConfig>;
251
324
  gracePeriod?: number;
252
325
  checkInterval?: number;
@@ -257,7 +330,7 @@ interface AgentEConfig {
257
330
  onAlert?: (diagnosis: Diagnosis) => void;
258
331
  onRollback?: (plan: ActionPlan, reason: string) => void;
259
332
  }
260
- type PersonaType = 'Active' | 'Trader' | 'Collector' | 'Speculator' | 'Earner' | 'Builder' | 'Social' | 'Whale' | 'Influencer';
333
+ type PersonaType = 'Active' | 'Trader' | 'Collector' | 'Speculator' | 'Earner' | 'Builder' | 'Social' | 'HighValue' | 'Influencer' | string;
261
334
  interface PersonaProfile {
262
335
  type: PersonaType;
263
336
  share: number;
@@ -347,6 +420,7 @@ declare class AgentE {
347
420
  private simulator;
348
421
  private planner;
349
422
  private executor;
423
+ private registry;
350
424
  readonly log: DecisionLog;
351
425
  readonly store: MetricStore;
352
426
  private personaTracker;
@@ -375,6 +449,8 @@ declare class AgentE {
375
449
  setMode(mode: AgentEMode): void;
376
450
  getMode(): AgentEMode;
377
451
  removePrinciple(id: string): void;
452
+ registerParameter(param: RegisteredParameter): void;
453
+ getRegistry(): ParameterRegistry;
378
454
  registerCustomMetric(name: string, fn: (state: EconomyState) => number): void;
379
455
  getDecisions(filter?: Parameters<DecisionLog['query']>[0]): DecisionEntry[];
380
456
  getPrinciples(): Principle[];
@@ -405,6 +481,8 @@ declare class Observer {
405
481
 
406
482
  declare class Simulator {
407
483
  private diagnoser;
484
+ private registry;
485
+ constructor(registry?: ParameterRegistry);
408
486
  private beforeViolationsCache;
409
487
  /**
410
488
  * Simulate the effect of applying `action` to the current economy forward `forwardTicks`.
@@ -422,6 +500,8 @@ declare class Simulator {
422
500
  private runForward;
423
501
  private actionMultiplier;
424
502
  private flowEffect;
503
+ /** Infer flow impact from parameter type when registry is unavailable */
504
+ private inferFlowImpact;
425
505
  private checkImprovement;
426
506
  private averageMetrics;
427
507
  }
@@ -445,10 +525,12 @@ declare class Planner {
445
525
  * - parameter is still in cooldown
446
526
  * - simulation result failed
447
527
  * - complexity budget exceeded
528
+ * - no matching parameter in registry
448
529
  */
449
- plan(diagnosis: Diagnosis, metrics: EconomyMetrics, simulationResult: SimulationResult, currentParams: Record<string, number>, thresholds: Thresholds): ActionPlan | null;
530
+ plan(diagnosis: Diagnosis, metrics: EconomyMetrics, simulationResult: SimulationResult, currentParams: Record<string, number>, thresholds: Thresholds, registry?: ParameterRegistry): ActionPlan | null;
450
531
  recordApplied(plan: ActionPlan, tick: number): void;
451
532
  recordRolledBack(_plan: ActionPlan): void;
533
+ recordSettled(_plan: ActionPlan): void;
452
534
  isOnCooldown(param: string, currentTick: number, cooldownTicks: number): boolean;
453
535
  /** Reset all cooldowns (useful for testing) */
454
536
  resetCooldowns(): void;
@@ -459,10 +541,12 @@ declare class Executor {
459
541
  apply(plan: ActionPlan, adapter: EconomyAdapter, currentParams: Record<string, number>): Promise<void>;
460
542
  /**
461
543
  * Check all active plans for rollback conditions.
462
- * Called every tick after metrics are computed.
463
- * Returns list of plans that were rolled back.
544
+ * Returns { rolledBack, settled } plans that were undone and plans that passed their window.
464
545
  */
465
- checkRollbacks(metrics: EconomyMetrics, adapter: EconomyAdapter): Promise<ActionPlan[]>;
546
+ checkRollbacks(metrics: EconomyMetrics, adapter: EconomyAdapter): Promise<{
547
+ rolledBack: ActionPlan[];
548
+ settled: ActionPlan[];
549
+ }>;
466
550
  private getMetricValue;
467
551
  getActivePlans(): ActionPlan[];
468
552
  }
@@ -575,7 +659,7 @@ declare const P36_MechanicFrictionDetector: Principle;
575
659
  declare const P37_LatecommerProblem: Principle;
576
660
  declare const P45_TimeBudget: Principle;
577
661
  declare const P50_PayPowerRatio: Principle;
578
- declare const PLAYER_EXPERIENCE_PRINCIPLES: Principle[];
662
+ declare const PARTICIPANT_EXPERIENCE_PRINCIPLES: Principle[];
579
663
 
580
664
  declare const P34_ExtractionRatio: Principle;
581
665
  declare const P47_SmokeTest: Principle;
@@ -587,9 +671,9 @@ declare const P52_EndowmentEffect: Principle;
587
671
  declare const P53_EventCompletionRate: Principle;
588
672
  declare const P54_LiveOpsCadence: Principle;
589
673
  declare const P56_ContentDropShock: Principle;
590
- declare const LIVEOPS_PRINCIPLES: Principle[];
674
+ declare const OPERATIONS_PRINCIPLES: Principle[];
591
675
 
592
- /** All 60 built-in principles in priority order (supply chain → liveops) */
676
+ /** All 60 built-in principles in priority order (supply chain → operations) */
593
677
  declare const ALL_PRINCIPLES: Principle[];
594
678
 
595
- export { ALL_PRINCIPLES, type ActionPlan, AgentE, type AgentEConfig, type AgentEMode, BOOTSTRAP_PRINCIPLES, CURRENCY_FLOW_PRINCIPLES, DEFAULT_THRESHOLDS, type DecisionEntry, DecisionLog, type DecisionResult, Diagnoser, type Diagnosis, type EconomicEvent, type EconomicEventType, type EconomyAdapter, type EconomyMetrics, type EconomyState, Executor, FEEDBACK_LOOP_PRINCIPLES, INCENTIVE_PRINCIPLES, LIVEOPS_PRINCIPLES, MARKET_DYNAMICS_PRINCIPLES, MEASUREMENT_PRINCIPLES, type MetricQuery, type MetricQueryResult, type MetricResolution, MetricStore, OPEN_ECONOMY_PRINCIPLES, Observer, P10_SpawnWeightingUsesInversePopulation, P11_TwoTierPressure, P12_OnePrimaryFaucet, P13_PotsAreZeroSumAndSelfRegulate, P14_TrackActualInjection, P15_PoolsNeedCapAndDecay, P16_WithdrawalPenaltyScales, P17_GracePeriodBeforeIntervention, P18_FirstProducerNeedsStartingInventory, P19_StartingSupplyExceedsDemand, P1_ProductionMatchesConsumption, P20_DecayPreventsAccumulation, P21_PriceFromGlobalSupply, P22_MarketAwarenessPreventsSurplus, P23_ProfitabilityFactorsFeasibility, P24_BlockedAgentsDecayFaster, P25_CorrectLeversForCorrectProblems, P26_ContinuousPressureBeatsThresholdCuts, P27_AdjustmentsNeedCooldowns, P28_StructuralDominanceIsNotPathological, P29_PinchPoint, P2_ClosedLoopsNeedDirectHandoff, P30_MovingPinchPoint, P31_AnchorValueTracking, P32_VelocityAboveSupply, P33_FairNotEqual, P34_ExtractionRatio, P35_DestructionCreatesValue, P36_MechanicFrictionDetector, P37_LatecommerProblem, P38_CommunicationPreventsRevolt, P39_TheLagPrinciple, P3_BootstrapCapitalCoversFirstTransaction, P40_ReplacementRate, P41_MultiResolutionMonitoring, P42_TheMedianPrinciple, P43_SimulationMinimum, P44_ComplexityBudget, P45_TimeBudget, P46_PersonaDiversity, P47_SmokeTest, P48_CurrencyInsulation, P49_IdleAssetTax, P4_MaterialsFlowFasterThanCooldown, P50_PayPowerRatio, P51_SharkTooth, P52_EndowmentEffect, P53_EventCompletionRate, P54_LiveOpsCadence, P55_ArbitrageThermometer, P56_ContentDropShock, P57_CombinatorialPriceSpace, P58_NoNaturalNumeraire, P59_GiftEconomyNoise, P5_ProfitabilityIsCompetitive, P60_SurplusDisposalAsymmetry, P6_CrowdingMultiplierOnAllRoles, P7_NonSpecialistsSubsidiseSpecialists, P8_RegulatorCannotFightDesign, P9_RoleSwitchingNeedsFriction, PERSONA_HEALTHY_RANGES, PLAYER_EXPERIENCE_PRINCIPLES, POPULATION_PRINCIPLES, type PersonaProfile, PersonaTracker, type PersonaType, type PinchPointStatus, Planner, type Principle, type PrincipleCategory, type PrincipleOk, type PrincipleResult, type PrincipleViolation, REGULATOR_PRINCIPLES, RESOURCE_MGMT_PRINCIPLES, type RollbackCondition, STATISTICAL_PRINCIPLES, SUPPLY_CHAIN_PRINCIPLES, SYSTEM_DYNAMICS_PRINCIPLES, type SimulationOutcome, type SimulationResult, Simulator, type SuggestedAction, type Thresholds, type TickConfig, type ValidationError, type ValidationResult, type ValidationWarning, emptyMetrics, validateEconomyState };
679
+ export { ALL_PRINCIPLES, type ActionPlan, AgentE, type AgentEConfig, type AgentEMode, BOOTSTRAP_PRINCIPLES, CURRENCY_FLOW_PRINCIPLES, DEFAULT_THRESHOLDS, type DecisionEntry, DecisionLog, type DecisionResult, Diagnoser, type Diagnosis, type EconomicEvent, type EconomicEventType, type EconomyAdapter, type EconomyMetrics, type EconomyState, Executor, FEEDBACK_LOOP_PRINCIPLES, type FlowImpact, INCENTIVE_PRINCIPLES, MARKET_DYNAMICS_PRINCIPLES, MEASUREMENT_PRINCIPLES, type MetricQuery, type MetricQueryResult, type MetricResolution, MetricStore, OPEN_ECONOMY_PRINCIPLES, OPERATIONS_PRINCIPLES, Observer, P10_SpawnWeightingUsesInversePopulation, P11_TwoTierPressure, P12_OnePrimaryFaucet, P13_PotsAreZeroSumAndSelfRegulate, P14_TrackActualInjection, P15_PoolsNeedCapAndDecay, P16_WithdrawalPenaltyScales, P17_GracePeriodBeforeIntervention, P18_FirstProducerNeedsStartingInventory, P19_StartingSupplyExceedsDemand, P1_ProductionMatchesConsumption, P20_DecayPreventsAccumulation, P21_PriceFromGlobalSupply, P22_MarketAwarenessPreventsSurplus, P23_ProfitabilityFactorsFeasibility, P24_BlockedAgentsDecayFaster, P25_CorrectLeversForCorrectProblems, P26_ContinuousPressureBeatsThresholdCuts, P27_AdjustmentsNeedCooldowns, P28_StructuralDominanceIsNotPathological, P29_PinchPoint, P2_ClosedLoopsNeedDirectHandoff, P30_MovingPinchPoint, P31_AnchorValueTracking, P32_VelocityAboveSupply, P33_FairNotEqual, P34_ExtractionRatio, P35_DestructionCreatesValue, P36_MechanicFrictionDetector, P37_LatecommerProblem, P38_CommunicationPreventsRevolt, P39_TheLagPrinciple, P3_BootstrapCapitalCoversFirstTransaction, P40_ReplacementRate, P41_MultiResolutionMonitoring, P42_TheMedianPrinciple, P43_SimulationMinimum, P44_ComplexityBudget, P45_TimeBudget, P46_PersonaDiversity, P47_SmokeTest, P48_CurrencyInsulation, P49_IdleAssetTax, P4_MaterialsFlowFasterThanCooldown, P50_PayPowerRatio, P51_SharkTooth, P52_EndowmentEffect, P53_EventCompletionRate, P54_LiveOpsCadence, P55_ArbitrageThermometer, P56_ContentDropShock, P57_CombinatorialPriceSpace, P58_NoNaturalNumeraire, P59_GiftEconomyNoise, P5_ProfitabilityIsCompetitive, P60_SurplusDisposalAsymmetry, P6_CrowdingMultiplierOnAllRoles, P7_NonSpecialistsSubsidiseSpecialists, P8_RegulatorCannotFightDesign, P9_RoleSwitchingNeedsFriction, PARTICIPANT_EXPERIENCE_PRINCIPLES, PERSONA_HEALTHY_RANGES, POPULATION_PRINCIPLES, ParameterRegistry, type ParameterScope, type ParameterType, type PersonaProfile, PersonaTracker, type PersonaType, type PinchPointStatus, Planner, type Principle, type PrincipleCategory, type PrincipleOk, type PrincipleResult, type PrincipleViolation, REGULATOR_PRINCIPLES, RESOURCE_MGMT_PRINCIPLES, type RegisteredParameter, type RollbackCondition, STATISTICAL_PRINCIPLES, SUPPLY_CHAIN_PRINCIPLES, SYSTEM_DYNAMICS_PRINCIPLES, type SimulationOutcome, type SimulationResult, Simulator, type SuggestedAction, type Thresholds, type TickConfig, type ValidationError, type ValidationResult, type ValidationWarning, emptyMetrics, validateEconomyState };