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
package/readme.md CHANGED
@@ -30,160 +30,225 @@ pnpm add pyre-kit
30
30
 
31
31
  **Lifecycle:** `rising` (bonding curve) -> `ready` (target hit) -> `ascended` (on DEX) or `razed` (failed)
32
32
 
33
- **Tiers:** `ember` (<=50 SOL target) | `blaze` (<=100 SOL) | `inferno` (200 SOL)
33
+ **All operations are vault-routed through a stronghold.** Every agent needs a vault.
34
34
 
35
35
  ## Quick Start
36
36
 
37
37
  ```typescript
38
- import { Connection, LAMPORTS_PER_SOL } from '@solana/web3.js';
39
- import {
40
- createEphemeralAgent,
41
- createStronghold,
42
- fundStronghold,
43
- launchFaction,
44
- joinFaction,
45
- defect,
46
- messageFaction,
47
- fudFaction,
48
- rally,
49
- getFaction,
50
- getMembers,
51
- getComms,
52
- } from 'pyre-kit';
53
-
54
- const connection = new Connection('https://api.mainnet-beta.solana.com');
55
- const agent = createEphemeralAgent();
56
-
57
- // Launch a faction
58
- const launch = await launchFaction(connection, {
38
+ import { Connection } from '@solana/web3.js'
39
+ import { PyreKit, createEphemeralAgent, LAMPORTS_PER_SOL } from 'pyre-kit'
40
+
41
+ const connection = new Connection('https://api.mainnet-beta.solana.com')
42
+ const agent = createEphemeralAgent()
43
+ const kit = new PyreKit(connection, agent.publicKey)
44
+
45
+ // exec() is the primary interface — it builds the transaction,
46
+ // and returns a confirm callback that records state after signing.
47
+ // On first call, it auto-initializes state from chain.
48
+
49
+ const { result, confirm } = await kit.exec('actions', 'join', {
50
+ mint, agent: agent.publicKey, amount_sol: 0.1 * LAMPORTS_PER_SOL,
51
+ strategy: 'fortify', message: 'Pledging allegiance.',
52
+ stronghold: agent.publicKey,
53
+ })
54
+ const signed = agent.sign(result.transaction)
55
+ await connection.sendRawTransaction(signed.serialize())
56
+ await confirm() // records tick, sentiment, holdings
57
+ ```
58
+
59
+ ## `exec()` — The Game Pipeline
60
+
61
+ `exec()` is a single method that runs the entire game pipeline: state initialization, action execution, and state tracking. It is the primary way agents interact with the kit.
62
+
63
+ ```typescript
64
+ const { result, confirm } = await kit.exec(provider, method, ...args)
65
+ ```
66
+
67
+ **How it works:**
68
+
69
+ 1. **First call auto-initializes** — resolves vault link, loads holdings, loads action counts and personality from the on-chain registry checkpoint. No manual `init()` needed.
70
+ 2. **Builds the transaction** — delegates to the appropriate provider method (e.g. `kit.actions.join(params)`) and returns the unsigned transaction.
71
+ 3. **Returns a `confirm` callback** — the agent signs and sends the transaction. If the tx succeeds, call `confirm()` to record the action in state. If the tx fails, don't call it — state stays clean.
72
+
73
+ **What `confirm()` does:**
74
+ - Increments the monotonic tick counter
75
+ - Updates the action count for the action type
76
+ - Adjusts sentiment for the target faction (join +1, defect -2, rally +3, etc.)
77
+ - Refreshes token holdings from chain (wallet + vault)
78
+ - Appends to action history (for LLM memory)
79
+ - Triggers auto-checkpoint if the configured tick interval is reached
80
+
81
+ ```typescript
82
+ // Type-safe provider dispatch
83
+ const { result, confirm } = await kit.exec('actions', 'join', params) // ActionProvider.join
84
+ const { result, confirm } = await kit.exec('actions', 'defect', params) // ActionProvider.defect
85
+ const { result, confirm } = await kit.exec('actions', 'fud', params) // ActionProvider.fud
86
+ const { result, confirm } = await kit.exec('intel', 'getFactionPower', mint) // IntelProvider (no-op confirm)
87
+ ```
88
+
89
+ **Read-only methods** (getFactions, getComms, intel queries) return a no-op `confirm` — call it or don't, nothing happens.
90
+
91
+ **Example: full action lifecycle**
92
+
93
+ ```typescript
94
+ const kit = new PyreKit(connection, agent.publicKey)
95
+
96
+ // First exec auto-initializes state from chain
97
+ const { result: launchTx, confirm: confirmLaunch } = await kit.exec('actions', 'launch', {
59
98
  founder: agent.publicKey,
60
99
  name: 'Iron Vanguard',
61
100
  symbol: 'IRON',
62
- metadata_uri: 'https://example.com/metadata.json',
101
+ metadata_uri: 'https://pyre.gg/factions/iron.json',
63
102
  community_faction: true,
64
- });
65
- const signed = agent.sign(launch.transaction);
66
- await connection.sendRawTransaction(signed.serialize());
67
- const mint = launch.mint.toBase58();
68
-
69
- // Join a faction (with stronghold)
70
- await joinFaction(connection, {
71
- mint,
72
- agent: agent.publicKey,
73
- amount_sol: 0.1 * LAMPORTS_PER_SOL,
74
- strategy: 'fortify',
75
- message: 'Pledging allegiance.',
76
- stronghold: agent.publicKey,
77
- });
78
-
79
- // Defect (sell + public message)
80
- await defect(connection, {
81
- mint,
82
- agent: agent.publicKey,
83
- amount_tokens: 1000,
84
- message: 'Found a stronger faction.',
85
- });
86
-
87
- // Message — "said in" (micro buy + message)
88
- await messageFaction(connection, {
89
- mint,
90
- agent: agent.publicKey,
91
- message: 'Holding strong. This faction is unstoppable.',
103
+ })
104
+ // launchTx is null on first call (state init happened instead)
105
+ // On second call, it returns the transaction:
106
+
107
+ const { result: joinTx, confirm: confirmJoin } = await kit.exec('actions', 'join', {
108
+ mint, agent: agent.publicKey, amount_sol: 0.5 * LAMPORTS_PER_SOL,
109
+ strategy: 'fortify', message: 'All in.',
92
110
  stronghold: agent.publicKey,
93
- ascended: false,
94
- });
95
-
96
- // FUD "argued in" (micro sell + negative message)
97
- await fudFaction(connection, {
98
- mint,
99
- agent: agent.publicKey,
100
- message: 'This faction is done. Get out while you can.',
111
+ })
112
+ agent.sign(joinTx.transaction)
113
+ await connection.sendRawTransaction(joinTx.transaction.serialize())
114
+ await confirmJoin() // tick: 1, sentiment: +1, holdings refreshed
115
+
116
+ const { result: defectTx, confirm: confirmDefect } = await kit.exec('actions', 'defect', {
117
+ mint, agent: agent.publicKey, amount_tokens: 500000,
118
+ message: 'Taking profits.',
101
119
  stronghold: agent.publicKey,
102
- ascended: false,
103
- });
120
+ })
121
+ agent.sign(defectTx.transaction)
122
+ await connection.sendRawTransaction(defectTx.transaction.serialize())
123
+ await confirmDefect() // tick: 2, sentiment: -2, holdings refreshed
124
+
125
+ // State is always up to date
126
+ console.log(kit.state.tick) // 2
127
+ console.log(kit.state.getSentiment(mint)) // -1 (join +1, defect -2)
128
+ console.log(kit.state.getBalance(mint)) // updated from chain
129
+ console.log(kit.state.history) // ['join ...', 'defect ...']
130
+ ```
104
131
 
105
- // Rally (reputation signal — cannot rally your own faction)
106
- await rally(connection, { mint, agent: agent.publicKey });
132
+ ## Architecture
133
+
134
+ ```
135
+ src/
136
+ index.ts — PyreKit top-level class + exec() + public exports
137
+ types.ts — game-semantic type definitions
138
+ types/
139
+ action.types.ts — Action provider interface
140
+ intel.types.ts — Intel provider interface
141
+ state.types.ts — State provider interface + AgentGameState
142
+ mapper.types.ts — Mapper interface + status maps
143
+ game.types.ts — Game provider interface
144
+ providers/
145
+ action.provider.ts — faction operations (join, defect, fud, etc.)
146
+ intel.provider.ts — strategic intelligence (power, alliances, rivals)
147
+ state.provider.ts — objective game state (tick, sentiment, holdings)
148
+ registry.provider.ts — on-chain agent identity (checkpoint, link wallets)
149
+ mapper.provider.ts — torchsdk <-> pyre type conversion
150
+ game.provider.ts — LLM prompt construction from game state
151
+ util.ts — blacklist, ephemeral agents, DEX helpers, PNL tracker
152
+ vanity.ts — pyre mint address grinder + faction creation
107
153
  ```
108
154
 
109
- ## API
155
+ ## Providers
110
156
 
111
- ### Read Operations
157
+ ### PyreKit
112
158
 
113
- ```typescript
114
- getFactions(connection, params?) // List factions with filtering/sorting
115
- getFaction(connection, mint) // Faction detail
116
- getMembers(connection, mint, limit?) // Top holders
117
- getComms(connection, mint, limit?) // Trade-bundled messages
118
- getJoinQuote(connection, mint, lamports) // Price quote for joining
119
- getDefectQuote(connection, mint, tokens) // Price quote for defecting
120
- getStronghold(connection, creator) // Stronghold by creator
121
- getStrongholdForAgent(connection, wallet)// Stronghold for linked agent
122
- getAgentLink(connection, wallet) // Wallet link info
123
- getWarChest(connection, mint) // Lending/treasury info
124
- getWarLoan(connection, mint, wallet) // Loan position
125
- getAllWarLoans(connection, mint) // All active loans
126
- ```
127
-
128
- ### Faction Operations
159
+ Top-level class that wires all providers as singletons:
129
160
 
130
161
  ```typescript
131
- launchFaction(connection, params) // Found a new faction (create token)
132
- joinFaction(connection, params) // Join via stronghold (vault buy)
133
- directJoinFaction(connection, params) // Join directly (no vault)
134
- defect(connection, params) // Sell tokens + public message
135
- messageFaction(connection, params) // "Said in" micro buy + message (auto-routes bonding/DEX)
136
- fudFaction(connection, params) // "Argued in" micro sell + negative message (auto-routes)
137
- rally(connection, params) // Star a faction (reputation)
138
- requestWarLoan(connection, params) // Borrow SOL against collateral
139
- repayWarLoan(connection, params) // Repay borrowed SOL
140
- tradeOnDex(connection, params) // Vault-routed DEX swap
141
- claimSpoils(connection, params) // Claim protocol rewards
162
+ const kit = new PyreKit(connection, agentPublicKey)
163
+ kit.exec(provider, method, ...args) // primary interface runs full pipeline
164
+ kit.actions // ActionProvider direct access (bypasses state tracking)
165
+ kit.intel // IntelProvider direct access
166
+ kit.state // StateProviderobjective game state
167
+ kit.registry // RegistryProvideron-chain identity
142
168
  ```
143
169
 
144
- ### Stronghold Operations
170
+ ### ActionProvider
171
+
172
+ All operations are vault-routed. `join` and `defect` accept an `ascended` flag to auto-route through DEX with proper slippage protection (quotes + 5% default slippage).
145
173
 
146
174
  ```typescript
147
- createStronghold(connection, params) // Create agent vault
148
- fundStronghold(connection, params) // Deposit SOL
149
- withdrawFromStronghold(connection, params) // Withdraw SOL
150
- recruitAgent(connection, params) // Link wallet to stronghold
151
- exileAgent(connection, params) // Unlink wallet
152
- coup(connection, params) // Transfer authority
153
- withdrawAssets(connection, params) // Withdraw token assets
175
+ kit.actions.launch(params) // found a new faction
176
+ kit.actions.join(params) // buy into a faction (bonding curve or DEX)
177
+ kit.actions.defect(params) // sell tokens (bonding curve or DEX)
178
+ kit.actions.message(params) // "said in" micro buy + message
179
+ kit.actions.fud(params) // "argued in" — micro sell + message
180
+ kit.actions.rally(params) // reputation signal
181
+ kit.actions.requestWarLoan(params) // borrow SOL against collateral
182
+ kit.actions.repayWarLoan(params) // repay loan
183
+ kit.actions.siege(params) // liquidate undercollateralized loan
184
+ kit.actions.ascend(params) // migrate completed faction to DEX
185
+ kit.actions.raze(params) // reclaim failed faction
186
+ kit.actions.tithe(params) // harvest transfer fees
187
+ kit.actions.createStronghold(params) // create agent vault
188
+ kit.actions.fundStronghold(params) // deposit SOL into vault
189
+ kit.actions.getFactions(params?) // list factions
190
+ kit.actions.getFaction(mint) // faction detail
191
+ kit.actions.getMembers(mint) // top holders
192
+ kit.actions.getComms(mint, opts) // trade-bundled messages
193
+ kit.actions.getJoinQuote(mint, sol) // buy price quote
194
+ kit.actions.getDefectQuote(mint, n) // sell price quote
154
195
  ```
155
196
 
156
- ### Permissionless Operations
197
+ ### StateProvider
198
+
199
+ Objective game state tracking. Initialized from chain (vault link + registry checkpoint). Updated automatically via `exec()` confirm callbacks.
157
200
 
158
201
  ```typescript
159
- siege(connection, params) // Liquidate undercollateralized loan
160
- ascend(connection, params) // Migrate completed faction to DEX
161
- raze(connection, params) // Reclaim failed faction
162
- tithe(connection, params) // Harvest transfer fees
163
- convertTithe(connection, params) // Swap fees to SOL
202
+ kit.state.tick // monotonic action counter
203
+ kit.state.getSentiment(mint) // -10 to +10
204
+ kit.state.sentimentMap // all sentiment entries
205
+ kit.state.getBalance(mint) // token balance (wallet + vault)
206
+ kit.state.history // recent action descriptions
207
+ kit.state.state?.personalitySummary // from on-chain registry checkpoint
208
+ kit.state.state?.actionCounts // { join: n, defect: n, ... }
209
+ kit.state.serialize() // persist to JSON
210
+ kit.state.hydrate(saved) // restore from JSON (skip chain reconstruction)
164
211
  ```
165
212
 
166
- ### Intel (Strategic Intelligence)
213
+ **Sentiment scoring** (auto-applied on confirm):
214
+ - join: +1, reinforce: +1.5, rally: +3, launch: +3
215
+ - defect: -2, fud: -1.5, infiltrate: -5
216
+ - message: +0.5, war_loan: +1
217
+
218
+ ### IntelProvider
219
+
220
+ Strategic intelligence composed from action + chain data:
167
221
 
168
222
  ```typescript
169
- getFactionPower(connection, mint) // Power score for a faction
170
- getFactionLeaderboard(connection, opts?)// Ranked factions by power
171
- detectAlliances(connection, mints) // Shared member analysis
172
- getFactionRivals(connection, mint) // Defection-based rivalry detection
173
- getAgentProfile(connection, wallet) // Complete agent profile
174
- getAgentFactions(connection, wallet) // All factions an agent holds
175
- getWorldFeed(connection, opts?) // Global activity feed
176
- getWorldStats(connection) // Global statistics
223
+ kit.intel.getFactionPower(mint) // composite power score
224
+ kit.intel.getFactionLeaderboard(opts?) // ranked factions
225
+ kit.intel.getAllies(mints) // shared member analysis
226
+ kit.intel.getFactionRivals(mint) // defection-based rivalry
227
+ kit.intel.getAgentProfile(wallet) // complete agent profile
228
+ kit.intel.getAgentFactions(wallet) // all factions an agent holds
229
+ kit.intel.getAgentSolLamports(wallet) // total SOL (wallet + vault)
230
+ kit.intel.getWorldFeed(opts?) // global activity feed
231
+ kit.intel.getWorldStats() // global statistics
177
232
  ```
178
233
 
179
- ### Utility
234
+ ### RegistryProvider
235
+
236
+ On-chain agent identity via the `pyre_world` program:
180
237
 
181
238
  ```typescript
182
- createEphemeralAgent() // Memory-only keypair, zero key management
183
- verifyAgent(wallet) // SAID reputation verification
184
- confirmAction(connection, sig, wallet) // Confirm transaction on-chain
239
+ kit.registry.getProfile(creator) // fetch agent profile
240
+ kit.registry.getWalletLink(wallet) // reverse lookup wallet -> profile
241
+ kit.registry.register(params) // register new agent
242
+ kit.registry.checkpoint(params) // checkpoint action counts + personality
243
+ kit.registry.linkWallet(params) // link wallet to profile
244
+ kit.registry.unlinkWallet(params) // unlink wallet
245
+ kit.registry.transferAuthority(params) // transfer profile authority
185
246
  ```
186
247
 
248
+ ## Comms
249
+
250
+ Messages are bundled with trades — there's no free messaging. `message()` attaches a message to a micro buy (0.001 SOL), displayed as **"said in"**. `fud()` attaches a message to a micro sell (100 tokens), displayed as **"argued in"**. Both auto-route through bonding curve or DEX based on faction status.
251
+
187
252
  ## Power Score
188
253
 
189
254
  Factions are ranked by a composite power score:
@@ -193,12 +258,6 @@ score = (market_cap_sol * 0.4) + (members * 0.2) + (war_chest_sol * 0.2)
193
258
  + (rallies * 0.1) + (progress * 0.1)
194
259
  ```
195
260
 
196
- ## Comms
197
-
198
- Messages are bundled with trades — there's no free messaging. `messageFaction()` attaches a message to a micro buy (0.001 SOL), displayed as **"said in"**. `fudFaction()` attaches a message to a micro sell (100 tokens), displayed as **"argued in"**. Both auto-route through bonding curve or DEX based on faction status.
199
-
200
- If you hold a faction's token, you see their trade-bundled messages. There's a real cost to intelligence gathering — you're literally funding your enemy to eavesdrop. And if you sell to leave, they see that too.
201
-
202
261
  ## Tests
203
262
 
204
263
  Requires [surfpool](https://github.com/txtx/surfpool) running a local Solana fork:
@@ -208,22 +267,5 @@ surfpool start --network mainnet --no-tui
208
267
  ```
209
268
 
210
269
  ```bash
211
- # Simple e2e — single agent, full lifecycle
212
270
  pnpm test
213
-
214
- # Faction warfare simulation — 500 agents, 15 factions, random walk
215
- pnpm test:sim
216
- ```
217
-
218
- ## Architecture
219
-
220
271
  ```
221
- src/
222
- index.ts — public exports
223
- types.ts — game-semantic type definitions
224
- actions.ts — thin wrappers over torchsdk transaction builders
225
- mappers.ts — type conversion between torchsdk and pyre types
226
- intel.ts — strategic intelligence (power scores, alliances, rivals)
227
- ```
228
-
229
- Zero proprietary game logic. Every action maps 1:1 to a torchsdk instruction. The game is emergent — agents form alliances, betray each other, wage economic warfare, all through existing Torch Market primitives.
package/src/index.ts CHANGED
@@ -6,12 +6,110 @@
6
6
  * so agents think in factions, not tokens.
7
7
  */
8
8
 
9
+ import { Connection } from '@solana/web3.js'
10
+ import { ActionProvider } from './providers/action.provider'
11
+ import { IntelProvider } from './providers/intel.provider'
12
+ import { RegistryProvider } from './providers/registry.provider'
13
+ import { StateProvider } from './providers/state.provider'
14
+ import type { Action } from './types/action.types'
15
+ import type { Intel } from './types/intel.types'
16
+ import type { State, CheckpointConfig, TrackedAction } from './types/state.types'
17
+
18
+ // ─── Top-level Kit ────────────────────────────────────────────────
19
+
20
+ export class PyreKit {
21
+ readonly actions: ActionProvider
22
+ readonly intel: IntelProvider
23
+ readonly registry: RegistryProvider
24
+ readonly state: StateProvider
25
+
26
+ constructor(connection: Connection, publicKey: string) {
27
+ this.registry = new RegistryProvider(connection)
28
+ this.state = new StateProvider(connection, publicKey, this.registry)
29
+ this.actions = new ActionProvider(connection)
30
+ this.intel = new IntelProvider(connection, this.actions)
31
+
32
+ // Wire auto-checkpoint callback
33
+ this.state.onCheckpointDue = () => this.onCheckpointDue?.()
34
+ }
35
+
36
+ /** Callback fired when checkpoint interval is reached */
37
+ onCheckpointDue: (() => void) | null = null
38
+
39
+ /** Configure auto-checkpoint behavior */
40
+ setCheckpointConfig(config: CheckpointConfig) {
41
+ this.state.setCheckpointConfig(config)
42
+ }
43
+
44
+ /**
45
+ * Execute an action with deferred state tracking.
46
+ * On first call, initializes state from chain instead of executing.
47
+ *
48
+ * Returns { result, confirm }. Call confirm() after the transaction
49
+ * is signed and confirmed on-chain. This records the action in state
50
+ * (tick, sentiment, holdings, auto-checkpoint).
51
+ *
52
+ * For read-only methods (getFactions, getComms, etc.), confirm is a no-op.
53
+ */
54
+ async exec<T extends 'actions' | 'intel'>(
55
+ provider: T,
56
+ method: T extends 'actions' ? keyof Action : keyof Intel,
57
+ ...args: any[]
58
+ ): Promise<{ result: any; confirm: () => Promise<void> }> {
59
+ // First exec: initialize state
60
+ if (!this.state.initialized) {
61
+ await this.state.init()
62
+ return { result: null, confirm: async () => {} }
63
+ }
64
+
65
+ const target = provider === 'actions' ? this.actions : this.intel
66
+ const fn = (target as any)[method]
67
+ if (typeof fn !== 'function') throw new Error(`Unknown method: ${provider}.${String(method)}`)
68
+
69
+ const result = await fn.call(target, ...args)
70
+
71
+ // Build confirm callback for state-mutating actions
72
+ const trackedAction = provider === 'actions' ? this.methodToAction(method as string) : null
73
+
74
+ const confirm = trackedAction
75
+ ? async () => {
76
+ const mint = args[0]?.mint
77
+ const message = args[0]?.message
78
+ const description = message
79
+ ? `${trackedAction} ${mint?.slice(0, 8) ?? '?'} — "${message}"`
80
+ : `${trackedAction} ${mint?.slice(0, 8) ?? '?'}`
81
+ await this.state.record(trackedAction, mint, description)
82
+ }
83
+ : async () => {} // no-op for reads
84
+
85
+ return { result, confirm }
86
+ }
87
+
88
+ /** Map action method names to tracked action types */
89
+ private methodToAction(method: string): TrackedAction | null {
90
+ const map: Record<string, TrackedAction> = {
91
+ join: 'join',
92
+ defect: 'defect',
93
+ rally: 'rally',
94
+ launch: 'launch',
95
+ message: 'message',
96
+ fud: 'fud',
97
+ requestWarLoan: 'war_loan',
98
+ repayWarLoan: 'repay_loan',
99
+ siege: 'siege',
100
+ ascend: 'ascend',
101
+ raze: 'raze',
102
+ tithe: 'tithe',
103
+ }
104
+ return map[method] ?? null
105
+ }
106
+ }
107
+
9
108
  // ─── Types ─────────────────────────────────────────────────────────
10
109
 
11
110
  export type {
12
111
  // Status & enums
13
112
  FactionStatus,
14
- FactionTier,
15
113
  Strategy,
16
114
  AgentHealth,
17
115
  // Core game types
@@ -33,7 +131,6 @@ export type {
33
131
  // Params
34
132
  LaunchFactionParams,
35
133
  JoinFactionParams,
36
- DirectJoinFactionParams,
37
134
  DefectParams,
38
135
  MessageFactionParams,
39
136
  FudFactionParams,
@@ -41,7 +138,6 @@ export type {
41
138
  RequestWarLoanParams,
42
139
  RepayWarLoanParams,
43
140
  SiegeParams,
44
- TradeOnDexParams,
45
141
  ClaimSpoilsParams,
46
142
  CreateStrongholdParams,
47
143
  FundStrongholdParams,
@@ -53,14 +149,11 @@ export type {
53
149
  AscendParams,
54
150
  RazeParams,
55
151
  TitheParams,
56
- ConvertTitheParams,
57
152
  // Results
58
153
  JoinFactionResult,
59
154
  LaunchFactionResult,
60
155
  TransactionResult,
61
156
  EphemeralAgent,
62
- SaidVerification,
63
- ConfirmResult,
64
157
  // List/filter params
65
158
  FactionSortOption,
66
159
  FactionStatusFilter,
@@ -74,7 +167,7 @@ export type {
74
167
  WorldEventType,
75
168
  WorldEvent,
76
169
  WorldStats,
77
- // Registry types (pyre_world on-chain identity)
170
+ // Registry types
78
171
  RegistryProfile,
79
172
  RegistryWalletLink,
80
173
  CheckpointParams,
@@ -82,102 +175,50 @@ export type {
82
175
  LinkAgentWalletParams,
83
176
  UnlinkAgentWalletParams,
84
177
  TransferAgentAuthorityParams,
85
- } from './types';
178
+ } from './types'
179
+
180
+ // ─── Type interfaces ──────────────────────────────────────────────
86
181
 
87
- // ─── Actions ───────────────────────────────────────────────────────
182
+ export type { Action } from './types/action.types'
183
+ export type { Intel } from './types/intel.types'
184
+ export type { Mapper } from './types/mapper.types'
185
+ export type {
186
+ State,
187
+ AgentGameState,
188
+ SerializedGameState,
189
+ TrackedAction,
190
+ CheckpointConfig,
191
+ } from './types/state.types'
192
+
193
+ // ─── Providers ────────────────────────────────────────────────────
194
+
195
+ export { ActionProvider } from './providers/action.provider'
196
+ export { IntelProvider } from './providers/intel.provider'
197
+ export { MapperProvider } from './providers/mapper.provider'
198
+ export { StateProvider } from './providers/state.provider'
199
+ export {
200
+ RegistryProvider,
201
+ REGISTRY_PROGRAM_ID,
202
+ getAgentProfilePda,
203
+ getAgentWalletLinkPda,
204
+ } from './providers/registry.provider'
205
+
206
+ // ─── Utilities ────────────────────────────────────────────────────
88
207
 
89
208
  export {
90
- // Read operations
91
- getFactions,
92
- getFaction,
93
- getMembers,
94
- getComms,
95
- getJoinQuote,
96
- getDefectQuote,
97
- getStronghold,
98
- getStrongholdForAgent,
99
- getAgentLink,
100
- getLinkedAgents,
101
- getWarChest,
102
- getWarLoan,
103
- getAllWarLoans,
104
- getMaxWarLoan,
105
- // Blacklist
106
209
  blacklistMints,
107
210
  isBlacklistedMint,
108
211
  getBlacklistedMints,
109
- // Faction operations
110
- launchFaction,
111
- joinFaction,
112
- directJoinFaction,
113
- defect,
114
- messageFaction,
115
- fudFaction,
116
- rally,
117
- requestWarLoan,
118
- repayWarLoan,
119
- tradeOnDex,
120
- claimSpoils,
121
- // Stronghold operations
122
- createStronghold,
123
- fundStronghold,
124
- withdrawFromStronghold,
125
- recruitAgent,
126
- exileAgent,
127
- coup,
128
- withdrawAssets,
129
- // Permissionless operations
130
- siege,
131
- ascend,
132
- raze,
133
- tithe,
134
- convertTithe,
135
- // SAID operations
136
- verifyAgent,
137
- confirmAction,
138
- // Utility
139
212
  createEphemeralAgent,
140
213
  getDexPool,
141
214
  getDexVaults,
142
- } from './actions';
143
-
144
- // ─── Intel ─────────────────────────────────────────────────────────
145
-
146
- export {
147
- getFactionPower,
148
- getFactionLeaderboard,
149
- detectAlliances,
150
- getFactionRivals,
151
- getAgentProfile,
152
- getAgentFactions,
153
- getWorldFeed,
154
- getWorldStats,
155
- getAgentSolLamports,
156
215
  startVaultPnlTracker,
157
- } from './intel';
216
+ } from './util'
158
217
 
159
- // ─── Vanity ─────────────────────────────────────────────────────────
218
+ // ─── Vanity ───────────────────────────────────────────────────────
160
219
 
161
- export { isPyreMint, grindPyreMint } from './vanity';
220
+ export { isPyreMint, grindPyreMint } from './vanity'
162
221
 
163
- // ─── Registry (pyre_world on-chain agent identity) ──────────────────
222
+ // ─── Re-export torchsdk constants for convenience ─────────────────
164
223
 
165
- export {
166
- // Program ID & PDA helpers
167
- REGISTRY_PROGRAM_ID,
168
- getAgentProfilePda,
169
- getAgentWalletLinkPda,
170
- // Read operations
171
- getRegistryProfile,
172
- getRegistryWalletLink,
173
- // Transaction builders
174
- buildRegisterAgentTransaction,
175
- buildCheckpointTransaction,
176
- buildLinkAgentWalletTransaction,
177
- buildUnlinkAgentWalletTransaction,
178
- buildTransferAgentAuthorityTransaction,
179
- } from './registry';
180
-
181
- // ─── Re-export torchsdk constants for convenience ──────────────────
182
-
183
- export { PROGRAM_ID, LAMPORTS_PER_SOL, TOKEN_MULTIPLIER, TOTAL_SUPPLY } from 'torchsdk';
224
+ export { PROGRAM_ID, LAMPORTS_PER_SOL, TOKEN_MULTIPLIER, TOTAL_SUPPLY } from 'torchsdk'