@agent-e/core 1.5.0 → 1.5.2
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 +70 -70
- package/dist/index.d.mts +78 -18
- package/dist/index.d.ts +78 -18
- package/dist/index.js +265 -130
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -123
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** High-level parameter categories (what it IS, not what it's called) */
|
|
2
2
|
type ParameterType = 'cost' | 'fee' | 'reward' | 'yield' | 'rate' | 'cap' | 'penalty' | 'multiplier' | string;
|
|
3
3
|
/** How a parameter change affects net currency flow */
|
|
4
|
-
type FlowImpact = 'sink' | 'faucet' | 'neutral' | 'mixed';
|
|
4
|
+
type FlowImpact = 'sink' | 'faucet' | 'neutral' | 'mixed' | 'friction' | 'redistribution';
|
|
5
5
|
/** Scope narrows which concrete parameter a type resolves to */
|
|
6
6
|
interface ParameterScope {
|
|
7
7
|
system?: string;
|
|
@@ -22,6 +22,16 @@ interface RegisteredParameter {
|
|
|
22
22
|
currentValue?: number;
|
|
23
23
|
/** Human-readable description */
|
|
24
24
|
description?: string;
|
|
25
|
+
/** Priority tiebreaker — higher wins when specificity scores are equal */
|
|
26
|
+
priority?: number;
|
|
27
|
+
/** Human-readable label for UIs and logs */
|
|
28
|
+
label?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Result of registry.validate() */
|
|
31
|
+
interface RegistryValidationResult {
|
|
32
|
+
valid: boolean;
|
|
33
|
+
warnings: string[];
|
|
34
|
+
errors: string[];
|
|
25
35
|
}
|
|
26
36
|
declare class ParameterRegistry {
|
|
27
37
|
private parameters;
|
|
@@ -33,11 +43,12 @@ declare class ParameterRegistry {
|
|
|
33
43
|
* Resolve a parameterType + scope to a concrete RegisteredParameter.
|
|
34
44
|
* Returns the best match, or undefined if no match.
|
|
35
45
|
*
|
|
36
|
-
* Matching rules
|
|
37
|
-
* 1.
|
|
38
|
-
* 2.
|
|
39
|
-
* 3.
|
|
40
|
-
* 4.
|
|
46
|
+
* Matching rules:
|
|
47
|
+
* 1. Filter candidates by type
|
|
48
|
+
* 2. Score each by scope specificity (system +10, currency +5, tags +3 each)
|
|
49
|
+
* 3. Mismatched scope fields disqualify (score = -Infinity)
|
|
50
|
+
* 4. Ties broken by `priority` (higher wins), then registration order
|
|
51
|
+
* 5. All disqualified → undefined
|
|
41
52
|
*/
|
|
42
53
|
resolve(type: ParameterType, scope?: Partial<ParameterScope>): RegisteredParameter | undefined;
|
|
43
54
|
/** Find all parameters of a given type. */
|
|
@@ -54,7 +65,12 @@ declare class ParameterRegistry {
|
|
|
54
65
|
getAll(): RegisteredParameter[];
|
|
55
66
|
/** Number of registered parameters. */
|
|
56
67
|
get size(): number;
|
|
57
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Validate the registry for common misconfigurations.
|
|
70
|
+
* Returns warnings (non-fatal) and errors (likely broken).
|
|
71
|
+
*/
|
|
72
|
+
validate(): RegistryValidationResult;
|
|
73
|
+
private scopeSpecificity;
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
type EconomicEventType = 'trade' | 'mint' | 'burn' | 'transfer' | 'produce' | 'consume' | 'role_change' | 'enter' | 'churn';
|
|
@@ -143,6 +159,9 @@ interface EconomyMetrics {
|
|
|
143
159
|
giftTradeRatio: number;
|
|
144
160
|
disposalTradeRatioByCurrency: Record<string, number>;
|
|
145
161
|
disposalTradeRatio: number;
|
|
162
|
+
systems: string[];
|
|
163
|
+
sources: string[];
|
|
164
|
+
sinks: string[];
|
|
146
165
|
flowBySystem: Record<string, number>;
|
|
147
166
|
activityBySystem: Record<string, number>;
|
|
148
167
|
participantsBySystem: Record<string, number>;
|
|
@@ -284,7 +303,7 @@ interface Thresholds {
|
|
|
284
303
|
maxAdjustmentPercent: number;
|
|
285
304
|
cooldownTicks: number;
|
|
286
305
|
poolWinRate: number;
|
|
287
|
-
|
|
306
|
+
poolOperatorShare: number;
|
|
288
307
|
roleSwitchFrictionMax: number;
|
|
289
308
|
poolCapPercent: number;
|
|
290
309
|
poolDecayRate: number;
|
|
@@ -313,6 +332,16 @@ interface TickConfig {
|
|
|
313
332
|
/** Coarse-resolution metric window in ticks. Default: 100 */
|
|
314
333
|
coarseWindow?: number;
|
|
315
334
|
}
|
|
335
|
+
interface SimulationConfig {
|
|
336
|
+
sinkMultiplier?: number;
|
|
337
|
+
faucetMultiplier?: number;
|
|
338
|
+
frictionMultiplier?: number;
|
|
339
|
+
frictionVelocityScale?: number;
|
|
340
|
+
redistributionMultiplier?: number;
|
|
341
|
+
neutralMultiplier?: number;
|
|
342
|
+
minIterations?: number;
|
|
343
|
+
maxProjectionTicks?: number;
|
|
344
|
+
}
|
|
316
345
|
type AgentEMode = 'autonomous' | 'advisor';
|
|
317
346
|
interface AgentEConfig {
|
|
318
347
|
adapter: EconomyAdapter;
|
|
@@ -320,11 +349,15 @@ interface AgentEConfig {
|
|
|
320
349
|
dominantRoles?: string[];
|
|
321
350
|
idealDistribution?: Record<string, number>;
|
|
322
351
|
parameters?: RegisteredParameter[];
|
|
352
|
+
/** Run registry.validate() on startup and log warnings/errors (default: true) */
|
|
353
|
+
validateRegistry?: boolean;
|
|
323
354
|
tickConfig?: Partial<TickConfig>;
|
|
324
355
|
gracePeriod?: number;
|
|
325
356
|
checkInterval?: number;
|
|
326
357
|
maxAdjustmentPercent?: number;
|
|
327
358
|
cooldownTicks?: number;
|
|
359
|
+
simulation?: SimulationConfig;
|
|
360
|
+
settlementWindowTicks?: number;
|
|
328
361
|
thresholds?: Partial<Thresholds>;
|
|
329
362
|
onDecision?: (entry: DecisionEntry) => void;
|
|
330
363
|
onAlert?: (diagnosis: Diagnosis) => void;
|
|
@@ -482,8 +515,10 @@ declare class Observer {
|
|
|
482
515
|
declare class Simulator {
|
|
483
516
|
private diagnoser;
|
|
484
517
|
private registry;
|
|
485
|
-
|
|
486
|
-
|
|
518
|
+
private simConfig;
|
|
519
|
+
constructor(registry?: ParameterRegistry, simConfig?: SimulationConfig);
|
|
520
|
+
private cachedViolationsTick;
|
|
521
|
+
private cachedViolations;
|
|
487
522
|
/**
|
|
488
523
|
* Simulate the effect of applying `action` to the current economy forward `forwardTicks`.
|
|
489
524
|
* Runs `iterations` Monte Carlo trials and returns the outcome distribution.
|
|
@@ -514,6 +549,7 @@ declare class Planner {
|
|
|
514
549
|
private lockedParams;
|
|
515
550
|
private constraints;
|
|
516
551
|
private cooldowns;
|
|
552
|
+
private typeCooldowns;
|
|
517
553
|
private activePlanCount;
|
|
518
554
|
lock(param: string): void;
|
|
519
555
|
unlock(param: string): void;
|
|
@@ -534,10 +570,19 @@ declare class Planner {
|
|
|
534
570
|
isOnCooldown(param: string, currentTick: number, cooldownTicks: number): boolean;
|
|
535
571
|
/** Reset all cooldowns (useful for testing) */
|
|
536
572
|
resetCooldowns(): void;
|
|
573
|
+
/** V1.5.2: Reset active plan count (e.g., on system restart) */
|
|
574
|
+
resetActivePlans(): void;
|
|
575
|
+
/** V1.5.2: Current active plan count (for diagnostics) */
|
|
576
|
+
getActivePlanCount(): number;
|
|
577
|
+
private typeCooldownKey;
|
|
578
|
+
private isTypeCooldown;
|
|
537
579
|
}
|
|
538
580
|
|
|
581
|
+
type ExecutionResult = 'applied' | 'rolled_back' | 'rollback_skipped';
|
|
539
582
|
declare class Executor {
|
|
540
583
|
private activePlans;
|
|
584
|
+
private maxActiveTicks;
|
|
585
|
+
constructor(settlementWindowTicks?: number);
|
|
541
586
|
apply(plan: ActionPlan, adapter: EconomyAdapter, currentParams: Record<string, number>): Promise<void>;
|
|
542
587
|
/**
|
|
543
588
|
* Check all active plans for rollback conditions.
|
|
@@ -553,6 +598,7 @@ declare class Executor {
|
|
|
553
598
|
|
|
554
599
|
declare class PersonaTracker {
|
|
555
600
|
private agentHistory;
|
|
601
|
+
private lastSeen;
|
|
556
602
|
/** Ingest a state snapshot and update agent signal history */
|
|
557
603
|
update(state: EconomyState): void;
|
|
558
604
|
/** Classify all agents and return persona distribution */
|
|
@@ -560,6 +606,20 @@ declare class PersonaTracker {
|
|
|
560
606
|
private classify;
|
|
561
607
|
}
|
|
562
608
|
|
|
609
|
+
/**
|
|
610
|
+
* Find the system with the worst metric value.
|
|
611
|
+
* Works with flat Record<string, number> maps like flowBySystem.
|
|
612
|
+
*
|
|
613
|
+
* @param metrics - Current economy metrics snapshot
|
|
614
|
+
* @param check - Function that returns a numeric "badness" score per system (higher = worse)
|
|
615
|
+
* @param tolerancePercent - Only flag if the worst system exceeds the average by this % (default 0)
|
|
616
|
+
* @returns The system name and its score, or undefined if no systems or none exceeds tolerance
|
|
617
|
+
*/
|
|
618
|
+
declare function findWorstSystem(metrics: EconomyMetrics, check: (systemName: string, metrics: EconomyMetrics) => number, tolerancePercent?: number): {
|
|
619
|
+
system: string;
|
|
620
|
+
score: number;
|
|
621
|
+
} | undefined;
|
|
622
|
+
|
|
563
623
|
interface ValidationError {
|
|
564
624
|
path: string;
|
|
565
625
|
expected: string;
|
|
@@ -590,14 +650,14 @@ declare const P4_MaterialsFlowFasterThanCooldown: Principle;
|
|
|
590
650
|
declare const P60_SurplusDisposalAsymmetry: Principle;
|
|
591
651
|
declare const SUPPLY_CHAIN_PRINCIPLES: Principle[];
|
|
592
652
|
|
|
593
|
-
declare const
|
|
653
|
+
declare const P5_ProfitabilityIsRelative: Principle;
|
|
594
654
|
declare const P6_CrowdingMultiplierOnAllRoles: Principle;
|
|
595
655
|
declare const P7_NonSpecialistsSubsidiseSpecialists: Principle;
|
|
596
656
|
declare const P8_RegulatorCannotFightDesign: Principle;
|
|
597
657
|
declare const INCENTIVE_PRINCIPLES: Principle[];
|
|
598
658
|
|
|
599
659
|
declare const P9_RoleSwitchingNeedsFriction: Principle;
|
|
600
|
-
declare const
|
|
660
|
+
declare const P10_EntryWeightingUsesInversePopulation: Principle;
|
|
601
661
|
declare const P11_TwoTierPressure: Principle;
|
|
602
662
|
declare const P46_PersonaDiversity: Principle;
|
|
603
663
|
declare const POPULATION_PRINCIPLES: Principle[];
|
|
@@ -630,8 +690,8 @@ declare const P28_StructuralDominanceIsNotPathological: Principle;
|
|
|
630
690
|
declare const P38_CommunicationPreventsRevolt: Principle;
|
|
631
691
|
declare const REGULATOR_PRINCIPLES: Principle[];
|
|
632
692
|
|
|
633
|
-
declare const
|
|
634
|
-
declare const
|
|
693
|
+
declare const P29_BottleneckDetection: Principle;
|
|
694
|
+
declare const P30_DynamicBottleneckRotation: Principle;
|
|
635
695
|
declare const P57_CombinatorialPriceSpace: Principle;
|
|
636
696
|
declare const MARKET_DYNAMICS_PRINCIPLES: Principle[];
|
|
637
697
|
|
|
@@ -666,14 +726,14 @@ declare const P47_SmokeTest: Principle;
|
|
|
666
726
|
declare const P48_CurrencyInsulation: Principle;
|
|
667
727
|
declare const OPEN_ECONOMY_PRINCIPLES: Principle[];
|
|
668
728
|
|
|
669
|
-
declare const
|
|
729
|
+
declare const P51_CyclicalEngagement: Principle;
|
|
670
730
|
declare const P52_EndowmentEffect: Principle;
|
|
671
731
|
declare const P53_EventCompletionRate: Principle;
|
|
672
|
-
declare const
|
|
673
|
-
declare const
|
|
732
|
+
declare const P54_OperationalCadence: Principle;
|
|
733
|
+
declare const P56_SupplyShockAbsorption: Principle;
|
|
674
734
|
declare const OPERATIONS_PRINCIPLES: Principle[];
|
|
675
735
|
|
|
676
736
|
/** All 60 built-in principles in priority order (supply chain → operations) */
|
|
677
737
|
declare const ALL_PRINCIPLES: Principle[];
|
|
678
738
|
|
|
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,
|
|
739
|
+
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, type ExecutionResult, 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_EntryWeightingUsesInversePopulation, 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_BottleneckDetection, P2_ClosedLoopsNeedDirectHandoff, P30_DynamicBottleneckRotation, 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_CyclicalEngagement, P52_EndowmentEffect, P53_EventCompletionRate, P54_OperationalCadence, P55_ArbitrageThermometer, P56_SupplyShockAbsorption, P57_CombinatorialPriceSpace, P58_NoNaturalNumeraire, P59_GiftEconomyNoise, P5_ProfitabilityIsRelative, 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 RegistryValidationResult, type RollbackCondition, STATISTICAL_PRINCIPLES, SUPPLY_CHAIN_PRINCIPLES, SYSTEM_DYNAMICS_PRINCIPLES, type SimulationConfig, type SimulationOutcome, type SimulationResult, Simulator, type SuggestedAction, type Thresholds, type TickConfig, type ValidationError, type ValidationResult, type ValidationWarning, emptyMetrics, findWorstSystem, validateEconomyState };
|