pyre-world-kit 2.0.11 → 3.0.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.
Files changed (54) hide show
  1. package/.prettierrc.json +6 -0
  2. package/dist/actions.js +16 -0
  3. package/dist/index.d.ts +38 -4
  4. package/dist/index.js +100 -85
  5. package/dist/providers/action.provider.d.ts +46 -0
  6. package/dist/providers/action.provider.js +331 -0
  7. package/dist/providers/intel.provider.d.ts +29 -0
  8. package/dist/providers/intel.provider.js +363 -0
  9. package/dist/providers/mapper.provider.d.ts +197 -0
  10. package/dist/providers/mapper.provider.js +158 -0
  11. package/dist/providers/registry.provider.d.ts +25 -0
  12. package/dist/providers/registry.provider.js +229 -0
  13. package/dist/providers/state.provider.d.ts +42 -0
  14. package/dist/providers/state.provider.js +348 -0
  15. package/dist/pyre_world.json +34 -229
  16. package/dist/types/action.types.d.ts +41 -0
  17. package/dist/types/action.types.js +2 -0
  18. package/dist/types/intel.types.d.ts +20 -0
  19. package/dist/types/intel.types.js +2 -0
  20. package/dist/types/mapper.types.d.ts +27 -0
  21. package/dist/types/mapper.types.js +22 -0
  22. package/dist/types/registry.types.d.ts +0 -0
  23. package/dist/types/registry.types.js +1 -0
  24. package/dist/types/state.types.d.ts +112 -0
  25. package/dist/types/state.types.js +2 -0
  26. package/dist/types.d.ts +8 -24
  27. package/dist/util.d.ts +29 -0
  28. package/dist/util.js +144 -0
  29. package/dist/vanity.d.ts +3 -3
  30. package/dist/vanity.js +18 -15
  31. package/package.json +4 -2
  32. package/readme.md +134 -122
  33. package/src/index.ts +127 -92
  34. package/src/providers/action.provider.ts +443 -0
  35. package/src/providers/intel.provider.ts +383 -0
  36. package/src/providers/mapper.provider.ts +195 -0
  37. package/src/providers/registry.provider.ts +277 -0
  38. package/src/providers/state.provider.ts +357 -0
  39. package/src/pyre_world.json +35 -230
  40. package/src/types/action.types.ts +76 -0
  41. package/src/types/intel.types.ts +22 -0
  42. package/src/types/mapper.types.ts +84 -0
  43. package/src/types/registry.types.ts +0 -0
  44. package/src/types/state.types.ts +144 -0
  45. package/src/types.ts +329 -333
  46. package/src/util.ts +148 -0
  47. package/src/vanity.ts +27 -14
  48. package/tests/test_e2e.ts +339 -172
  49. package/src/actions.ts +0 -703
  50. package/src/intel.ts +0 -521
  51. package/src/mappers.ts +0 -302
  52. package/src/registry.ts +0 -317
  53. package/tests/test_devnet_e2e.ts +0 -401
  54. package/tests/test_sim.ts +0 -458
@@ -13,16 +13,7 @@
13
13
  "Update action counters and personality summary.",
14
14
  "Only the linked wallet can call this."
15
15
  ],
16
- "discriminator": [
17
- 213,
18
- 200,
19
- 19,
20
- 204,
21
- 240,
22
- 143,
23
- 184,
24
- 252
25
- ],
16
+ "discriminator": [213, 200, 19, 204, 240, 143, 184, 252],
26
17
  "accounts": [
27
18
  {
28
19
  "name": "signer",
@@ -59,24 +50,13 @@
59
50
  "Link a new wallet to the profile. Authority only.",
60
51
  "Must unlink existing wallet first."
61
52
  ],
62
- "discriminator": [
63
- 86,
64
- 92,
65
- 31,
66
- 146,
67
- 228,
68
- 51,
69
- 209,
70
- 230
71
- ],
53
+ "discriminator": [86, 92, 31, 146, 228, 51, 209, 230],
72
54
  "accounts": [
73
55
  {
74
56
  "name": "authority",
75
57
  "writable": true,
76
58
  "signer": true,
77
- "relations": [
78
- "profile"
79
- ]
59
+ "relations": ["profile"]
80
60
  },
81
61
  {
82
62
  "name": "profile",
@@ -85,18 +65,7 @@
85
65
  "seeds": [
86
66
  {
87
67
  "kind": "const",
88
- "value": [
89
- 112,
90
- 121,
91
- 114,
92
- 101,
93
- 95,
94
- 97,
95
- 103,
96
- 101,
97
- 110,
98
- 116
99
- ]
68
+ "value": [112, 121, 114, 101, 95, 97, 103, 101, 110, 116]
100
69
  },
101
70
  {
102
71
  "kind": "account",
@@ -117,23 +86,7 @@
117
86
  {
118
87
  "kind": "const",
119
88
  "value": [
120
- 112,
121
- 121,
122
- 114,
123
- 101,
124
- 95,
125
- 97,
126
- 103,
127
- 101,
128
- 110,
129
- 116,
130
- 95,
131
- 119,
132
- 97,
133
- 108,
134
- 108,
135
- 101,
136
- 116
89
+ 112, 121, 114, 101, 95, 97, 103, 101, 110, 116, 95, 119, 97, 108, 108, 101, 116
137
90
  ]
138
91
  },
139
92
  {
@@ -152,19 +105,8 @@
152
105
  },
153
106
  {
154
107
  "name": "register",
155
- "docs": [
156
- "Register a new agent profile and auto-link the creator's wallet."
157
- ],
158
- "discriminator": [
159
- 211,
160
- 124,
161
- 67,
162
- 15,
163
- 211,
164
- 194,
165
- 178,
166
- 240
167
- ],
108
+ "docs": ["Register a new agent profile and auto-link the creator's wallet."],
109
+ "discriminator": [211, 124, 67, 15, 211, 194, 178, 240],
168
110
  "accounts": [
169
111
  {
170
112
  "name": "creator",
@@ -178,18 +120,7 @@
178
120
  "seeds": [
179
121
  {
180
122
  "kind": "const",
181
- "value": [
182
- 112,
183
- 121,
184
- 114,
185
- 101,
186
- 95,
187
- 97,
188
- 103,
189
- 101,
190
- 110,
191
- 116
192
- ]
123
+ "value": [112, 121, 114, 101, 95, 97, 103, 101, 110, 116]
193
124
  },
194
125
  {
195
126
  "kind": "account",
@@ -200,32 +131,14 @@
200
131
  },
201
132
  {
202
133
  "name": "wallet_link",
203
- "docs": [
204
- "Auto-created wallet link for the creator"
205
- ],
134
+ "docs": ["Auto-created wallet link for the creator"],
206
135
  "writable": true,
207
136
  "pda": {
208
137
  "seeds": [
209
138
  {
210
139
  "kind": "const",
211
140
  "value": [
212
- 112,
213
- 121,
214
- 114,
215
- 101,
216
- 95,
217
- 97,
218
- 103,
219
- 101,
220
- 110,
221
- 116,
222
- 95,
223
- 119,
224
- 97,
225
- 108,
226
- 108,
227
- 101,
228
- 116
141
+ 112, 121, 114, 101, 95, 97, 103, 101, 110, 116, 95, 119, 97, 108, 108, 101, 116
229
142
  ]
230
143
  },
231
144
  {
@@ -244,26 +157,13 @@
244
157
  },
245
158
  {
246
159
  "name": "transfer_authority",
247
- "docs": [
248
- "Transfer profile authority to a new wallet."
249
- ],
250
- "discriminator": [
251
- 48,
252
- 169,
253
- 76,
254
- 72,
255
- 229,
256
- 180,
257
- 55,
258
- 161
259
- ],
160
+ "docs": ["Transfer profile authority to a new wallet."],
161
+ "discriminator": [48, 169, 76, 72, 229, 180, 55, 161],
260
162
  "accounts": [
261
163
  {
262
164
  "name": "authority",
263
165
  "signer": true,
264
- "relations": [
265
- "profile"
266
- ]
166
+ "relations": ["profile"]
267
167
  },
268
168
  {
269
169
  "name": "profile",
@@ -272,18 +172,7 @@
272
172
  "seeds": [
273
173
  {
274
174
  "kind": "const",
275
- "value": [
276
- 112,
277
- 121,
278
- 114,
279
- 101,
280
- 95,
281
- 97,
282
- 103,
283
- 101,
284
- 110,
285
- 116
286
- ]
175
+ "value": [112, 121, 114, 101, 95, 97, 103, 101, 110, 116]
287
176
  },
288
177
  {
289
178
  "kind": "account",
@@ -301,27 +190,14 @@
301
190
  },
302
191
  {
303
192
  "name": "unlink_wallet",
304
- "docs": [
305
- "Unlink the current wallet. Authority only."
306
- ],
307
- "discriminator": [
308
- 220,
309
- 121,
310
- 97,
311
- 13,
312
- 193,
313
- 137,
314
- 209,
315
- 159
316
- ],
193
+ "docs": ["Unlink the current wallet. Authority only."],
194
+ "discriminator": [220, 121, 97, 13, 193, 137, 209, 159],
317
195
  "accounts": [
318
196
  {
319
197
  "name": "authority",
320
198
  "writable": true,
321
199
  "signer": true,
322
- "relations": [
323
- "profile"
324
- ]
200
+ "relations": ["profile"]
325
201
  },
326
202
  {
327
203
  "name": "profile",
@@ -330,18 +206,7 @@
330
206
  "seeds": [
331
207
  {
332
208
  "kind": "const",
333
- "value": [
334
- 112,
335
- 121,
336
- 114,
337
- 101,
338
- 95,
339
- 97,
340
- 103,
341
- 101,
342
- 110,
343
- 116
344
- ]
209
+ "value": [112, 121, 114, 101, 95, 97, 103, 101, 110, 116]
345
210
  },
346
211
  {
347
212
  "kind": "account",
@@ -362,23 +227,7 @@
362
227
  {
363
228
  "kind": "const",
364
229
  "value": [
365
- 112,
366
- 121,
367
- 114,
368
- 101,
369
- 95,
370
- 97,
371
- 103,
372
- 101,
373
- 110,
374
- 116,
375
- 95,
376
- 119,
377
- 97,
378
- 108,
379
- 108,
380
- 101,
381
- 116
230
+ 112, 121, 114, 101, 95, 97, 103, 101, 110, 116, 95, 119, 97, 108, 108, 101, 116
382
231
  ]
383
232
  },
384
233
  {
@@ -399,29 +248,11 @@
399
248
  "accounts": [
400
249
  {
401
250
  "name": "AgentProfile",
402
- "discriminator": [
403
- 60,
404
- 227,
405
- 42,
406
- 24,
407
- 0,
408
- 87,
409
- 86,
410
- 205
411
- ]
251
+ "discriminator": [60, 227, 42, 24, 0, 87, 86, 205]
412
252
  },
413
253
  {
414
254
  "name": "AgentWalletLink",
415
- "discriminator": [
416
- 253,
417
- 251,
418
- 63,
419
- 168,
420
- 140,
421
- 233,
422
- 129,
423
- 156
424
- ]
255
+ "discriminator": [253, 251, 63, 168, 140, 233, 129, 156]
425
256
  }
426
257
  ],
427
258
  "errors": [
@@ -467,37 +298,27 @@
467
298
  "fields": [
468
299
  {
469
300
  "name": "creator",
470
- "docs": [
471
- "Immutable creator wallet — PDA seed (never changes)"
472
- ],
301
+ "docs": ["Immutable creator wallet — PDA seed (never changes)"],
473
302
  "type": "pubkey"
474
303
  },
475
304
  {
476
305
  "name": "authority",
477
- "docs": [
478
- "Current authority — controls link/unlink/transfer (transferable)"
479
- ],
306
+ "docs": ["Current authority — controls link/unlink/transfer (transferable)"],
480
307
  "type": "pubkey"
481
308
  },
482
309
  {
483
310
  "name": "linked_wallet",
484
- "docs": [
485
- "Current active wallet that can write checkpoints"
486
- ],
311
+ "docs": ["Current active wallet that can write checkpoints"],
487
312
  "type": "pubkey"
488
313
  },
489
314
  {
490
315
  "name": "personality_summary",
491
- "docs": [
492
- "LLM-compressed personality paragraph (max 256 chars)"
493
- ],
316
+ "docs": ["LLM-compressed personality paragraph (max 256 chars)"],
494
317
  "type": "string"
495
318
  },
496
319
  {
497
320
  "name": "last_checkpoint",
498
- "docs": [
499
- "Unix timestamp of last checkpoint"
500
- ],
321
+ "docs": ["Unix timestamp of last checkpoint"],
501
322
  "type": "i64"
502
323
  },
503
324
  {
@@ -558,30 +379,22 @@
558
379
  },
559
380
  {
560
381
  "name": "created_at",
561
- "docs": [
562
- "Registration timestamp"
563
- ],
382
+ "docs": ["Registration timestamp"],
564
383
  "type": "i64"
565
384
  },
566
385
  {
567
386
  "name": "bump",
568
- "docs": [
569
- "PDA bump"
570
- ],
387
+ "docs": ["PDA bump"],
571
388
  "type": "u8"
572
389
  },
573
390
  {
574
391
  "name": "total_sol_spent",
575
- "docs": [
576
- "Cumulative SOL spent on joins/buys/infiltrates (lamports)"
577
- ],
392
+ "docs": ["Cumulative SOL spent on joins/buys/infiltrates (lamports)"],
578
393
  "type": "u64"
579
394
  },
580
395
  {
581
396
  "name": "total_sol_received",
582
- "docs": [
583
- "Cumulative SOL received from defects/sells (lamports)"
584
- ],
397
+ "docs": ["Cumulative SOL received from defects/sells (lamports)"],
585
398
  "type": "u64"
586
399
  }
587
400
  ]
@@ -600,30 +413,22 @@
600
413
  "fields": [
601
414
  {
602
415
  "name": "profile",
603
- "docs": [
604
- "The AgentProfile this wallet belongs to"
605
- ],
416
+ "docs": ["The AgentProfile this wallet belongs to"],
606
417
  "type": "pubkey"
607
418
  },
608
419
  {
609
420
  "name": "wallet",
610
- "docs": [
611
- "The linked wallet"
612
- ],
421
+ "docs": ["The linked wallet"],
613
422
  "type": "pubkey"
614
423
  },
615
424
  {
616
425
  "name": "linked_at",
617
- "docs": [
618
- "When this link was created"
619
- ],
426
+ "docs": ["When this link was created"],
620
427
  "type": "i64"
621
428
  },
622
429
  {
623
430
  "name": "bump",
624
- "docs": [
625
- "PDA bump"
626
- ],
431
+ "docs": ["PDA bump"],
627
432
  "type": "u8"
628
433
  }
629
434
  ]
@@ -0,0 +1,41 @@
1
+ import { BuyQuoteResult, SellQuoteResult, TransactionResult } from 'torchsdk';
2
+ import { AgentLink, AllWarLoansResult, AscendParams, ClaimSpoilsParams, CommsResult, CoupParams, CreateStrongholdParams, DefectParams, ExileAgentParams, FactionDetail, FactionListParams, FactionListResult, FactionStatus, FudFactionParams, FundStrongholdParams, JoinFactionParams, JoinFactionResult, LaunchFactionParams, LaunchFactionResult, MembersResult, MessageFactionParams, RallyParams, RazeParams, RecruitAgentParams, RepayWarLoanParams, RequestWarLoanParams, SiegeParams, Stronghold, TitheParams, WarChest, WarLoan, WarLoanQuote, WithdrawAssetsParams, WithdrawFromStrongholdParams } from '../types';
3
+ export interface Action {
4
+ createStronghold(params: CreateStrongholdParams): Promise<TransactionResult>;
5
+ coup(params: CoupParams): Promise<TransactionResult>;
6
+ exileAgent(params: ExileAgentParams): Promise<TransactionResult>;
7
+ fundStronghold(params: FundStrongholdParams): Promise<TransactionResult>;
8
+ recruitAgent(params: RecruitAgentParams): Promise<TransactionResult>;
9
+ withdrawAssets(params: WithdrawAssetsParams): Promise<TransactionResult>;
10
+ withdrawFromStronghold(params: WithdrawFromStrongholdParams): Promise<TransactionResult>;
11
+ getAgentLink(wallet: string): Promise<AgentLink | undefined>;
12
+ getComms(mint: string, params: {
13
+ limit?: number;
14
+ status?: FactionStatus;
15
+ }): Promise<CommsResult>;
16
+ getDefectQuote(mint: string, amountTokens: number): Promise<SellQuoteResult>;
17
+ getJoinQuote(mint: string, amountSolLamports: number): Promise<BuyQuoteResult>;
18
+ getFaction(mint: string): Promise<FactionDetail>;
19
+ getFactions(params?: FactionListParams): Promise<FactionListResult>;
20
+ getLinkedAgents(vaultAddress: string): Promise<AgentLink[]>;
21
+ getMembers(mint: string, limit?: number): Promise<MembersResult>;
22
+ getStronghold(creator: string): Promise<Stronghold | undefined>;
23
+ getStrongholdForAgent(wallet: string): Promise<Stronghold | undefined>;
24
+ getWarChest(mint: string): Promise<WarChest>;
25
+ getWarLoan(mint: string, wallet: string): Promise<WarLoan>;
26
+ getWarLoanQuote(mint: string, collateralAmount: number): Promise<WarLoanQuote>;
27
+ getWarLoansForFaction(mint: string): Promise<AllWarLoansResult>;
28
+ ascend(params: AscendParams): Promise<TransactionResult>;
29
+ claimSpoils(params: ClaimSpoilsParams): Promise<TransactionResult>;
30
+ defect(params: DefectParams): Promise<TransactionResult>;
31
+ fud(params: FudFactionParams): Promise<TransactionResult>;
32
+ join(params: JoinFactionParams): Promise<JoinFactionResult>;
33
+ launch(params: LaunchFactionParams): Promise<LaunchFactionResult>;
34
+ message(params: MessageFactionParams): Promise<TransactionResult>;
35
+ rally(params: RallyParams): Promise<TransactionResult>;
36
+ raze(params: RazeParams): Promise<TransactionResult>;
37
+ repayWarLoan(params: RepayWarLoanParams): Promise<TransactionResult>;
38
+ requestWarLoan(params: RequestWarLoanParams): Promise<TransactionResult>;
39
+ siege(params: SiegeParams): Promise<TransactionResult>;
40
+ tithe(params: TitheParams): Promise<TransactionResult>;
41
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,20 @@
1
+ import { AgentFactionPosition, AgentProfile, AllianceCluster, FactionPower, FactionStatus, RivalFaction, WorldEvent, WorldStats } from '../types';
2
+ export interface Intel {
3
+ getAgentFactions(wallet: string, factionLimit?: number): Promise<AgentFactionPosition[]>;
4
+ getAgentProfile(wallet: string): Promise<AgentProfile>;
5
+ getAgentSolLamports(wallet: string): Promise<number>;
6
+ getAllies(mints: string[], holderLimit?: number): Promise<AllianceCluster[]>;
7
+ getFactionPower(mint: string): Promise<FactionPower>;
8
+ getFactionLeaderboard(opts?: {
9
+ status?: FactionStatus;
10
+ limit?: number;
11
+ }): Promise<FactionPower[]>;
12
+ getFactionRivals(mint: string, opts?: {
13
+ limit?: number;
14
+ }): Promise<RivalFaction[]>;
15
+ getWorldFeed(opts?: {
16
+ limit?: number;
17
+ factionLimit?: number;
18
+ }): Promise<WorldEvent[]>;
19
+ getWorldStats(): Promise<WorldStats>;
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,27 @@
1
+ import { AllLoanPositionsResult, BuyTransactionResult, CreateTokenResult, Holder, HoldersResult, LendingInfo, LoanPositionInfo, LoanPositionWithKey, MessagesResult, TokenDetail, TokenListResult, TokenMessage, TokenStatus, TokenStatusFilter, TokenSummary, VaultInfo, VaultWalletLinkInfo } from 'torchsdk';
2
+ import { AgentLink, AllWarLoansResult, Comms, CommsResult, FactionDetail, FactionListResult, FactionStatus, FactionStatusFilter, FactionSummary, JoinFactionResult, LaunchFactionResult, Member, MembersResult, Strategy, Stronghold, WarChest, WarLoan, WarLoanWithAgent } from '../types';
3
+ export interface Mapper {
4
+ allLoansResult(r: AllLoanPositionsResult): AllWarLoansResult;
5
+ buyResult(r: BuyTransactionResult): JoinFactionResult;
6
+ createResult(r: CreateTokenResult): LaunchFactionResult;
7
+ factionStatus(status: TokenStatus): FactionStatus;
8
+ holdersResult(r: HoldersResult): MembersResult;
9
+ holderToMember(h: Holder): Member;
10
+ lendingToWarChest(l: LendingInfo): WarChest;
11
+ loanToWarLoan(l: LoanPositionInfo): WarLoan;
12
+ loanWithKeyToWarLoan(l: LoanPositionWithKey): WarLoanWithAgent;
13
+ messagesResult(r: MessagesResult): CommsResult;
14
+ strategy(vote: 'burn' | 'return'): Strategy;
15
+ tokenDetailToFaction(t: TokenDetail): FactionDetail;
16
+ tokenListResult(r: TokenListResult): FactionListResult;
17
+ tokenMessageToComms(m: TokenMessage): Comms;
18
+ tokenStatus(status: FactionStatus): TokenStatus;
19
+ tokenStatusFilter(status: FactionStatusFilter): TokenStatusFilter;
20
+ tokenSummaryToFaction(t: TokenSummary): FactionSummary;
21
+ vote(strategy: Strategy): 'burn' | 'return';
22
+ vaultToStronghold(v: VaultInfo): Stronghold;
23
+ walletLinkToAgentLink(l: VaultWalletLinkInfo): AgentLink;
24
+ }
25
+ export declare const STATUS_MAP: Record<TokenStatus, FactionStatus>;
26
+ export declare const STATUS_REVERSE: Record<FactionStatus, TokenStatus>;
27
+ export declare const STATUS_FILTER_REVERSE: Record<FactionStatusFilter, TokenStatusFilter>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STATUS_FILTER_REVERSE = exports.STATUS_REVERSE = exports.STATUS_MAP = void 0;
4
+ exports.STATUS_MAP = {
5
+ bonding: 'rising',
6
+ complete: 'ready',
7
+ migrated: 'ascended',
8
+ reclaimed: 'razed',
9
+ };
10
+ exports.STATUS_REVERSE = {
11
+ rising: 'bonding',
12
+ ready: 'complete',
13
+ ascended: 'migrated',
14
+ razed: 'reclaimed',
15
+ };
16
+ exports.STATUS_FILTER_REVERSE = {
17
+ rising: 'bonding',
18
+ ready: 'complete',
19
+ ascended: 'migrated',
20
+ razed: 'reclaimed',
21
+ all: 'all',
22
+ };
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,112 @@
1
+ import type { Stronghold } from '../types';
2
+ /** Action types tracked by the state provider */
3
+ export type TrackedAction = 'join' | 'defect' | 'rally' | 'launch' | 'message' | 'reinforce' | 'war_loan' | 'repay_loan' | 'siege' | 'ascend' | 'raze' | 'tithe' | 'infiltrate' | 'fud';
4
+ /** Snapshot of objective on-chain game state for an agent */
5
+ export interface AgentGameState {
6
+ /** Agent wallet public key */
7
+ publicKey: string;
8
+ /** Vault creator key (resolved from on-chain vault link) */
9
+ vaultCreator: string | null;
10
+ /** Vault info (null if no vault found) */
11
+ stronghold: Stronghold | null;
12
+ /** Monotonic tick counter — increments on each successful action */
13
+ tick: number;
14
+ /** Cumulative action counts keyed by action type */
15
+ actionCounts: Record<TrackedAction, number>;
16
+ /** Token holdings: mint → balance (wallet + vault combined) */
17
+ holdings: Map<string, number>;
18
+ /** Mints with active war loans */
19
+ activeLoans: Set<string>;
20
+ /** Mints this agent founded */
21
+ founded: string[];
22
+ /** Mints already rallied (can only rally once) */
23
+ rallied: Set<string>;
24
+ /** Mints already voted on (first buy requires strategy vote) */
25
+ voted: Set<string>;
26
+ /** Sentiment per faction: mint → score (-10 to +10), derived from actions */
27
+ sentiment: Map<string, number>;
28
+ /** Recent action descriptions for LLM context / memory block */
29
+ recentHistory: string[];
30
+ /** Personality summary from on-chain registry checkpoint (null if no profile) */
31
+ personalitySummary: string | null;
32
+ /** Total SOL spent (from registry checkpoint, lamports) */
33
+ totalSolSpent: number;
34
+ /** Total SOL received (from registry checkpoint, lamports) */
35
+ totalSolReceived: number;
36
+ /** Whether state has been initialized from chain */
37
+ initialized: boolean;
38
+ }
39
+ /** Serializable form of AgentGameState for persistence */
40
+ export interface SerializedGameState {
41
+ publicKey: string;
42
+ vaultCreator: string | null;
43
+ tick: number;
44
+ actionCounts: Record<TrackedAction, number>;
45
+ holdings: Record<string, number>;
46
+ activeLoans: string[];
47
+ founded: string[];
48
+ rallied: string[];
49
+ voted: string[];
50
+ sentiment: Record<string, number>;
51
+ recentHistory: string[];
52
+ personalitySummary: string | null;
53
+ totalSolSpent: number;
54
+ totalSolReceived: number;
55
+ }
56
+ /** Configuration for auto-checkpoint behavior */
57
+ export interface CheckpointConfig {
58
+ /** Checkpoint every N ticks (default: 25) */
59
+ interval: number;
60
+ /** Personality summary string provider — called at checkpoint time */
61
+ getPersonalitySummary?: () => string;
62
+ /** SOL spent/received provider — called at checkpoint time */
63
+ getSolTotals?: () => {
64
+ spent: number;
65
+ received: number;
66
+ };
67
+ }
68
+ /** State provider interface — objective game state tracking */
69
+ export interface State {
70
+ /** Current game state (null before init) */
71
+ readonly state: AgentGameState | null;
72
+ /** Vault creator key (shorthand for state.vaultCreator) */
73
+ readonly vaultCreator: string | null;
74
+ /** Whether state has been initialized */
75
+ readonly initialized: boolean;
76
+ /** Current tick count */
77
+ readonly tick: number;
78
+ /**
79
+ * Initialize state from chain.
80
+ * Resolves vault link, loads holdings, loads action counts from registry checkpoint.
81
+ * Must be called before any action. Returns the resolved state.
82
+ */
83
+ init(): Promise<AgentGameState>;
84
+ /**
85
+ * Record a successful action — increments tick, updates action counts,
86
+ * updates sentiment, appends to history, refreshes holdings.
87
+ * Called by ActionProvider after tx confirmation.
88
+ */
89
+ record(action: TrackedAction, mint?: string, description?: string): Promise<void>;
90
+ /** Refresh holdings from on-chain (wallet + vault token accounts) */
91
+ refreshHoldings(): Promise<void>;
92
+ /** Get sentiment score for a faction (-10 to +10) */
93
+ getSentiment(mint: string): number;
94
+ /** Get all sentiment entries */
95
+ readonly sentimentMap: ReadonlyMap<string, number>;
96
+ /** Get recent action history (for LLM memory block) */
97
+ readonly history: readonly string[];
98
+ /** Get token balance for a specific mint */
99
+ getBalance(mint: string): number;
100
+ /** Check if agent has voted on a faction */
101
+ hasVoted(mint: string): boolean;
102
+ /** Check if agent has rallied a faction */
103
+ hasRallied(mint: string): boolean;
104
+ /** Mark a faction as voted */
105
+ markVoted(mint: string): void;
106
+ /** Mark a faction as rallied */
107
+ markRallied(mint: string): void;
108
+ /** Serialize state for persistence */
109
+ serialize(): SerializedGameState;
110
+ /** Hydrate from a previously serialized state (skips chain reconstruction) */
111
+ hydrate(saved: SerializedGameState): void;
112
+ }