pyre-world-kit 2.0.12 → 3.0.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.
Files changed (53) hide show
  1. package/.prettierrc.json +6 -0
  2. package/dist/index.d.ts +46 -4
  3. package/dist/index.js +105 -85
  4. package/dist/providers/action.provider.d.ts +46 -0
  5. package/dist/providers/action.provider.js +331 -0
  6. package/dist/providers/intel.provider.d.ts +29 -0
  7. package/dist/providers/intel.provider.js +363 -0
  8. package/dist/providers/mapper.provider.d.ts +197 -0
  9. package/dist/providers/mapper.provider.js +158 -0
  10. package/dist/providers/registry.provider.d.ts +25 -0
  11. package/dist/providers/registry.provider.js +229 -0
  12. package/dist/providers/state.provider.d.ts +42 -0
  13. package/dist/providers/state.provider.js +348 -0
  14. package/dist/pyre_world.json +34 -229
  15. package/dist/types/action.types.d.ts +41 -0
  16. package/dist/types/action.types.js +2 -0
  17. package/dist/types/intel.types.d.ts +20 -0
  18. package/dist/types/intel.types.js +2 -0
  19. package/dist/types/mapper.types.d.ts +27 -0
  20. package/dist/types/mapper.types.js +22 -0
  21. package/dist/types/registry.types.d.ts +0 -0
  22. package/dist/types/registry.types.js +1 -0
  23. package/dist/types/state.types.d.ts +112 -0
  24. package/dist/types/state.types.js +2 -0
  25. package/dist/types.d.ts +8 -24
  26. package/dist/util.d.ts +29 -0
  27. package/dist/util.js +144 -0
  28. package/dist/vanity.d.ts +3 -3
  29. package/dist/vanity.js +18 -15
  30. package/package.json +4 -2
  31. package/readme.md +184 -142
  32. package/src/index.ts +133 -92
  33. package/src/providers/action.provider.ts +443 -0
  34. package/src/providers/intel.provider.ts +383 -0
  35. package/src/providers/mapper.provider.ts +195 -0
  36. package/src/providers/registry.provider.ts +277 -0
  37. package/src/providers/state.provider.ts +357 -0
  38. package/src/pyre_world.json +35 -230
  39. package/src/types/action.types.ts +76 -0
  40. package/src/types/intel.types.ts +22 -0
  41. package/src/types/mapper.types.ts +84 -0
  42. package/src/types/registry.types.ts +0 -0
  43. package/src/types/state.types.ts +144 -0
  44. package/src/types.ts +329 -333
  45. package/src/util.ts +148 -0
  46. package/src/vanity.ts +27 -14
  47. package/tests/test_e2e.ts +339 -172
  48. package/src/actions.ts +0 -719
  49. package/src/intel.ts +0 -521
  50. package/src/mappers.ts +0 -302
  51. package/src/registry.ts +0 -317
  52. package/tests/test_devnet_e2e.ts +0 -401
  53. package/tests/test_sim.ts +0 -458
@@ -0,0 +1,144 @@
1
+ import type { Stronghold } from '../types'
2
+
3
+ /** Action types tracked by the state provider */
4
+ export type TrackedAction =
5
+ | 'join'
6
+ | 'defect'
7
+ | 'rally'
8
+ | 'launch'
9
+ | 'message'
10
+ | 'reinforce'
11
+ | 'war_loan'
12
+ | 'repay_loan'
13
+ | 'siege'
14
+ | 'ascend'
15
+ | 'raze'
16
+ | 'tithe'
17
+ | 'infiltrate'
18
+ | 'fud'
19
+
20
+ /** Snapshot of objective on-chain game state for an agent */
21
+ export interface AgentGameState {
22
+ /** Agent wallet public key */
23
+ publicKey: string
24
+ /** Vault creator key (resolved from on-chain vault link) */
25
+ vaultCreator: string | null
26
+ /** Vault info (null if no vault found) */
27
+ stronghold: Stronghold | null
28
+ /** Monotonic tick counter — increments on each successful action */
29
+ tick: number
30
+ /** Cumulative action counts keyed by action type */
31
+ actionCounts: Record<TrackedAction, number>
32
+ /** Token holdings: mint → balance (wallet + vault combined) */
33
+ holdings: Map<string, number>
34
+ /** Mints with active war loans */
35
+ activeLoans: Set<string>
36
+ /** Mints this agent founded */
37
+ founded: string[]
38
+ /** Mints already rallied (can only rally once) */
39
+ rallied: Set<string>
40
+ /** Mints already voted on (first buy requires strategy vote) */
41
+ voted: Set<string>
42
+ /** Sentiment per faction: mint → score (-10 to +10), derived from actions */
43
+ sentiment: Map<string, number>
44
+ /** Recent action descriptions for LLM context / memory block */
45
+ recentHistory: string[]
46
+ /** Personality summary from on-chain registry checkpoint (null if no profile) */
47
+ personalitySummary: string | null
48
+ /** Total SOL spent (from registry checkpoint, lamports) */
49
+ totalSolSpent: number
50
+ /** Total SOL received (from registry checkpoint, lamports) */
51
+ totalSolReceived: number
52
+ /** Whether state has been initialized from chain */
53
+ initialized: boolean
54
+ }
55
+
56
+ /** Serializable form of AgentGameState for persistence */
57
+ export interface SerializedGameState {
58
+ publicKey: string
59
+ vaultCreator: string | null
60
+ tick: number
61
+ actionCounts: Record<TrackedAction, number>
62
+ holdings: Record<string, number>
63
+ activeLoans: string[]
64
+ founded: string[]
65
+ rallied: string[]
66
+ voted: string[]
67
+ sentiment: Record<string, number>
68
+ recentHistory: string[]
69
+ personalitySummary: string | null
70
+ totalSolSpent: number
71
+ totalSolReceived: number
72
+ }
73
+
74
+ /** Configuration for auto-checkpoint behavior */
75
+ export interface CheckpointConfig {
76
+ /** Checkpoint every N ticks (default: 25) */
77
+ interval: number
78
+ /** Personality summary string provider — called at checkpoint time */
79
+ getPersonalitySummary?: () => string
80
+ /** SOL spent/received provider — called at checkpoint time */
81
+ getSolTotals?: () => { spent: number; received: number }
82
+ }
83
+
84
+ /** State provider interface — objective game state tracking */
85
+ export interface State {
86
+ /** Current game state (null before init) */
87
+ readonly state: AgentGameState | null
88
+
89
+ /** Vault creator key (shorthand for state.vaultCreator) */
90
+ readonly vaultCreator: string | null
91
+
92
+ /** Whether state has been initialized */
93
+ readonly initialized: boolean
94
+
95
+ /** Current tick count */
96
+ readonly tick: number
97
+
98
+ /**
99
+ * Initialize state from chain.
100
+ * Resolves vault link, loads holdings, loads action counts from registry checkpoint.
101
+ * Must be called before any action. Returns the resolved state.
102
+ */
103
+ init(): Promise<AgentGameState>
104
+
105
+ /**
106
+ * Record a successful action — increments tick, updates action counts,
107
+ * updates sentiment, appends to history, refreshes holdings.
108
+ * Called by ActionProvider after tx confirmation.
109
+ */
110
+ record(action: TrackedAction, mint?: string, description?: string): Promise<void>
111
+
112
+ /** Refresh holdings from on-chain (wallet + vault token accounts) */
113
+ refreshHoldings(): Promise<void>
114
+
115
+ /** Get sentiment score for a faction (-10 to +10) */
116
+ getSentiment(mint: string): number
117
+
118
+ /** Get all sentiment entries */
119
+ readonly sentimentMap: ReadonlyMap<string, number>
120
+
121
+ /** Get recent action history (for LLM memory block) */
122
+ readonly history: readonly string[]
123
+
124
+ /** Get token balance for a specific mint */
125
+ getBalance(mint: string): number
126
+
127
+ /** Check if agent has voted on a faction */
128
+ hasVoted(mint: string): boolean
129
+
130
+ /** Check if agent has rallied a faction */
131
+ hasRallied(mint: string): boolean
132
+
133
+ /** Mark a faction as voted */
134
+ markVoted(mint: string): void
135
+
136
+ /** Mark a faction as rallied */
137
+ markRallied(mint: string): void
138
+
139
+ /** Serialize state for persistence */
140
+ serialize(): SerializedGameState
141
+
142
+ /** Hydrate from a previously serialized state (skips chain reconstruction) */
143
+ hydrate(saved: SerializedGameState): void
144
+ }