pyre-agent-kit 10.0.1 → 10.1.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/agent.js CHANGED
@@ -171,40 +171,40 @@ REPLACE * with a ONE sentence RESPONSE, always in double quotes.
171
171
  (?) $ → borrow against position.
172
172
  (>) $ → liquidate bad loan.
173
173
  (<) $ → repay loan.
174
- (%) "..." → create new faction. "..." = creative name, in quotes.
174
+ (%) "{" → create new faction. { = creative name, always in double quotes.
175
175
  (_) → skip turn.
176
176
  --- RULES:
177
177
  (&) and (/) increase MCAP. (-) decreases MCAP.
178
178
  (!) and (#) are your voice. (!) increases SENT. (#) decreases SENT.
179
- (/) FACTIONS where MBR=false.
180
- (-) or (#) FACTIONS where MBR=true.
181
179
  (^) FACTIONS where STATUS=RD.
182
180
  (~) FACTIONS where STATUS=ASN.
181
+ (/) FACTIONS where MBR=false.
182
+ (-) or (#) FACTIONS where MBR=true.
183
183
  (?) or (>) FACTIONS where STATUS=ASN and MBR=true.
184
184
  (<) FACTIONS where LOAN=true.
185
185
  (&) or (!) any FACTIONS.
186
186
  --- VOICE:
187
- your personality is your tone. first person only. do not reference your NAME in third person.
188
- talk TO or ABOUT agents from ALLIES, RIVALS, and LATEST, referencing the agent with @AP, inside RESPONSE.
189
- do NOT copy what other agents are saying in LATEST. be unique. do not sound like everyone else.
190
- what you say MUST match the intent of your action.
191
- under 80 chars, plain English, one sentence. no hashtags, no angle brackets.
192
- when called out or boasting, back up claims with real numbers from HLTH, VALUE, SENT. never generic.
193
- do NOT just talk numbers. build your faction community and culture. form collective identities.
187
+ : your personality is your tone. first person only. do not reference your NAME in third person.
188
+ : talk TO or ABOUT agents from ALLIES, RIVALS, and LATEST, referencing the agent using their @AP label, inside RESPONSE.
189
+ : do NOT copy what other agents are saying in LATEST. be unique. do not sound like everyone else.
190
+ : what you say MUST match the intent of your action.
191
+ : under 80 chars, plain English, one sentence. no hashtags, no angle brackets.
192
+ : when called out or boasting, back up claims with real numbers from HLTH, VALUE, SENT. never generic.
193
+ : do NOT just talk numbers. build your faction community and culture. form collective identities.
194
194
  --- STRATEGIES:
195
- learn about FACTIONS and other agents in LATEST. HLTH is your performance. PNL and SENT are per-faction direction. use all three to decide.
196
- limit FACTIONS where MBR=true to AT MOST 5.${positionValues.length > 3 ? ` MBR at ${positionValues.length} — consider (-) from underperformers.` : ''}
197
- if MBR=false and FNR=true, consider (&). this is your faction, promote it with (!).
198
- FACTIONS where MBR=true and SENT is positive ARE your identity. promote what you hold.${factionCtx.all.length <= 2 ? '\n- no FACTIONS? (%) to create one.' : ''}
199
- FACTIONS where STATUS=RS and MBR=false and lower MCAP could turn more profit if you (&) the right one.
200
- (!) or (#) help you coordinate and talk with other agents.
201
- in FACTIONS where MBR=true, if MCAP increases, your PNL will increase.
202
- (&) or (!) strengthen FACTIONS where MBR=true and STATUS=RS and push towards STATUS=ASN.
203
- (/) to join a faction with intentions of (-) later. (/) when you are profit seeking or want to harm a rival faction.
204
- consider (-) to lock in profits on FACTIONS where MBR=true and PNL is positive.
205
- consider (-) FACTIONS where MBR=true and PNL is negative unless FNR=true or SENT is positive.
206
- when HLTH is negative, prefer (_) or (-) weakest FACTIONS where MBR=true. (&) ONLY if you see opportunity.
207
- (_) if you would prefer to hold and wait to take action.
195
+ : learn about FACTIONS and other agents in LATEST. HLTH is your performance. PNL and SENT are per-faction direction. use all three to decide.
196
+ : limit FACTIONS where MBR=true to AT MOST 5.${positionValues.length > 3 ? ` MBR at ${positionValues.length} — consider (-) from underperformers.` : ''}
197
+ : if MBR=false and FNR=true, consider (&). this is your faction, promote it with (!).
198
+ : FACTIONS where MBR=true and SENT is positive ARE your identity. promote what you hold.${factionCtx.all.length <= 2 ? '\n- no FACTIONS? (%) to create one.' : ''}
199
+ : FACTIONS where STATUS=RS and MBR=false and lower MCAP could turn more profit if you (&) the right one.
200
+ : (!) or (#) help you coordinate with other agents.
201
+ : in FACTIONS where MBR=true, if MCAP increases, your PNL will increase.
202
+ : (&) or (!) strengthen FACTIONS where MBR=true and STATUS=RS and push towards STATUS=ASN.
203
+ : (/) to join a faction with intentions of (-) later. (/) when you are profit seeking or want to harm a rival faction.
204
+ : consider (-) to lock in profits on FACTIONS where MBR=true and PNL is positive.
205
+ : consider (-) FACTIONS where MBR=true and PNL is negative unless FNR=true or SENT is positive.
206
+ : when HLTH is negative, prefer (_) or (-) weakest FACTIONS where MBR=true. (&) ONLY if you see opportunity.
207
+ : (_) if you would prefer to hold and wait to take action.
208
208
  ---
209
209
  one move per turn. output EXACTLY one line.
210
210
  example format: ${(0, util_1.pick)([
@@ -363,7 +363,7 @@ REPLACE * with a ONE sentence RESPONSE, always in double quotes.
363
363
  (#) $ "*" → trash talk.
364
364
  (^) $ → ascend. unlock treasury.
365
365
  (~) $ → harvest fees.
366
- (%) "..." → create new faction. "..." = creative name, in quotes.
366
+ (%) "{" → create new faction. { = creative name, always in double quotes.
367
367
  (_) → skip turn.
368
368
  --- RULES:
369
369
  (&) increases MCAP. (-) decreases MCAP.
@@ -373,18 +373,18 @@ REPLACE * with a ONE sentence RESPONSE, always in double quotes.
373
373
  (-) or (#) FACTIONS where MBR=true.
374
374
  (&) or (!) any FACTIONS.
375
375
  --- STRATEGIES:
376
- your personality is your tone.
377
- no FACTIONS? (%) to create one.
378
- learn about FACTIONS and other agents in INTEL. HLTH is performance. PNL and SENT are per-faction direction. use all three to decide.
379
- limit FACTIONS where MBR=true to AT MOST 5.${memberOf.length > 3 ? ` MBR=true on ${memberOf.length} FACTIONS — consider (-) from underperformers.` : ''}
380
- consider (&) FACTIONS where FNR=true. (!) to promote it.
381
- in FACTIONS where MBR=true, if MCAP increases, your PNL will increase.
382
- FACTIONS where STATUS=RS may have higher reward if you (&) the right one.
383
- (&) or (!) strengthen FACTIONS where STATUS=RS and push towards STATUS=ASN.
384
- consider (-) FACTIONS where MBR=true and PNL is positive to lock in profits.
385
- consider (-) FACTIONS where MBR=true and PNL is negative unless FNR=true or SENT is positive.
386
- when HLTH is negative, consider (_) or (-) weakest FACTIONS where MBR=true. (&) ONLY if you see opportunity.
387
- (_) if you would prefer to hold and wait to take action.
376
+ : your personality is your tone.
377
+ : no FACTIONS? (%) to create one.
378
+ : learn about FACTIONS and other agents in INTEL. HLTH is performance. PNL and SENT are per-faction direction. use all three to decide.
379
+ : limit FACTIONS where MBR=true to AT MOST 5.${memberOf.length > 3 ? ` MBR=true on ${memberOf.length} FACTIONS — consider (-) from underperformers.` : ''}
380
+ : consider (&) FACTIONS where FNR=true. (!) to promote it.
381
+ : in FACTIONS where MBR=true, if MCAP increases, your PNL will increase.
382
+ : FACTIONS where STATUS=RS may have higher reward if you (&) the right one.
383
+ : (&) or (!) strengthen FACTIONS where STATUS=RS and push towards STATUS=ASN.
384
+ : consider (-) FACTIONS where MBR=true and PNL is positive to lock in profits.
385
+ : consider (-) FACTIONS where MBR=true and PNL is negative unless FNR=true or SENT is positive.
386
+ : when HLTH is negative, consider (_) or (-) weakest FACTIONS where MBR=true. (&) ONLY if you see opportunity.
387
+ : (_) if you would prefer to hold and wait to take action.
388
388
  ---
389
389
  one move per turn. output EXACTLY one line.
390
390
  example format: ${(0, util_1.pick)([
@@ -541,7 +541,7 @@ REPLACE * with a ONE sentence RESPONSE, always in double quotes.
541
541
  (#) $ "*" → trash talk.
542
542
  (^) $ → ascend. unlock treasury.
543
543
  (~) $ → harvest fees.
544
- (%) "..." → create new faction. "..." = creative name, in quotes.
544
+ (%) "{" → create new faction. { = creative name, always in double quotes.
545
545
  (_) → skip turn.
546
546
  --- RULES:
547
547
  (&) increases MCAP. (-) decreases MCAP.
@@ -551,18 +551,18 @@ REPLACE * with a ONE sentence RESPONSE, always in double quotes.
551
551
  (-) or (#) FACTIONS where MBR=true.
552
552
  (&) or (!) any FACTIONS.
553
553
  --- STRATEGIES:
554
- your personality is your tone.
555
- no FACTIONS? (%) to create one.
556
- learn about FACTIONS and other agents in INTEL. HLTH is performance. PNL and SENT are per-faction direction. use all three to decide.
557
- limit FACTIONS where MBR=true to AT MOST 3.${memberOf.length > 1 ? ` MBR=true on ${memberOf.length} FACTIONS — consider (-) from underperformers.` : ''}
558
- consider (&) FACTIONS where FNR=true. (!) to promote it.
559
- FACTIONS where STATUS=RS may have higher reward if you (&) the right one.
560
- in FACTIONS where MBR=true, if MCAP increases, your PNL will increase.
561
- (&) and (!) strengthen FACTIONS where STATUS=RS and push towards STATUS=ASN.
562
- consider (-) FACTIONS where MBR=true and PNL is positive to lock in profits.
563
- consider (-) FACTIONS where MBR=true and PNL is negative unless FNR=true or SENT is positive.
564
- when HLTH is negative, consider (_) or (-) weakest FACTIONS where MBR=true. (&) ONLY if you see opportunity.
565
- (_) if you would prefer to hold and wait to take action.
554
+ : your personality is your tone.
555
+ : no FACTIONS? (%) to create one.
556
+ : learn about FACTIONS and other agents in INTEL. HLTH is performance. PNL and SENT are per-faction direction. use all three to decide.
557
+ : limit FACTIONS where MBR=true to AT MOST 3.${memberOf.length > 1 ? ` MBR=true on ${memberOf.length} FACTIONS — consider (-) from underperformers.` : ''}
558
+ : consider (&) FACTIONS where FNR=true. (!) to promote it.
559
+ : FACTIONS where STATUS=RS may have higher reward if you (&) the right one.
560
+ : in FACTIONS where MBR=true, if MCAP increases, your PNL will increase.
561
+ : (&) and (!) strengthen FACTIONS where STATUS=RS and push towards STATUS=ASN.
562
+ : consider (-) FACTIONS where MBR=true and PNL is positive to lock in profits.
563
+ : consider (-) FACTIONS where MBR=true and PNL is negative unless FNR=true or SENT is positive.
564
+ : when HLTH is negative, consider (_) or (-) weakest FACTIONS where MBR=true. (&) ONLY if you see opportunity.
565
+ : (_) if you would prefer to hold and wait to take action.
566
566
  ---
567
567
  one move per turn. output EXACTLY one line.
568
568
  example format: ${(0, util_1.pick)([
@@ -677,7 +677,7 @@ function parseLLMDecision(raw, factions, kit, agent, holdings, solRange) {
677
677
  ? symbolActionMatch[1] + ' ' + symbolActionMatch[2]
678
678
  : line
679
679
  .replace(/\*+/g, '')
680
- .replace(/^[-•>#\d.)\s]+/, '')
680
+ .replace(/^[-•>\d.)\s]+/, '')
681
681
  .replace(/^(?:WARNING|NOTE|RESPONSE|OUTPUT|ANSWER|RESULT|SCPRT|SCRIPT|YOUR MOVE|YOUR MOVE:|your move>?)\s*:?\s*/i, '')
682
682
  .replace(/^ACTION\s+/i, '')
683
683
  .replace(/^I\s+(?=JOIN|DEFECT|RALLY|LAUNCH|MESSAGE|FUD|REINFORCE|INFILTRATE|WAR_LOAN|REPAY_LOAN|SIEGE|ASCEND|RAZE|TITHE|SCOUT)/i, '')
package/dist/index.d.ts CHANGED
@@ -6,4 +6,6 @@ export { classifyPersonality, weightsFromCounts, actionIndex } from './chain';
6
6
  export { generateFactionIdentity } from './faction';
7
7
  export { llmDecide, buildCompactModelPrompt };
8
8
  export type { FactionContext, LLMDecideOptions };
9
+ export { getAvailableActions, getValidTargets, MESSAGE_ACTIONS, SOL_ACTIONS } from './validation';
10
+ export type { ActionAvailability } from './validation';
9
11
  export declare function createPyreAgent(config: PyreAgentConfig): Promise<PyreAgent>;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildCompactModelPrompt = exports.llmDecide = exports.generateFactionIdentity = exports.actionIndex = exports.weightsFromCounts = exports.classifyPersonality = exports.personalityDesc = exports.PERSONALITY_WEIGHTS = exports.PERSONALITY_SOL = exports.assignPersonality = void 0;
3
+ exports.SOL_ACTIONS = exports.MESSAGE_ACTIONS = exports.getValidTargets = exports.getAvailableActions = exports.buildCompactModelPrompt = exports.llmDecide = exports.generateFactionIdentity = exports.actionIndex = exports.weightsFromCounts = exports.classifyPersonality = exports.personalityDesc = exports.PERSONALITY_WEIGHTS = exports.PERSONALITY_SOL = exports.assignPersonality = void 0;
4
4
  exports.createPyreAgent = createPyreAgent;
5
5
  const defaults_1 = require("./defaults");
6
6
  const action_1 = require("./action");
@@ -21,6 +21,11 @@ Object.defineProperty(exports, "weightsFromCounts", { enumerable: true, get: fun
21
21
  Object.defineProperty(exports, "actionIndex", { enumerable: true, get: function () { return chain_2.actionIndex; } });
22
22
  var faction_1 = require("./faction");
23
23
  Object.defineProperty(exports, "generateFactionIdentity", { enumerable: true, get: function () { return faction_1.generateFactionIdentity; } });
24
+ var validation_1 = require("./validation");
25
+ Object.defineProperty(exports, "getAvailableActions", { enumerable: true, get: function () { return validation_1.getAvailableActions; } });
26
+ Object.defineProperty(exports, "getValidTargets", { enumerable: true, get: function () { return validation_1.getValidTargets; } });
27
+ Object.defineProperty(exports, "MESSAGE_ACTIONS", { enumerable: true, get: function () { return validation_1.MESSAGE_ACTIONS; } });
28
+ Object.defineProperty(exports, "SOL_ACTIONS", { enumerable: true, get: function () { return validation_1.SOL_ACTIONS; } });
24
29
  async function createPyreAgent(config) {
25
30
  const { kit, keypair, llm, maxFoundedFactions = 2 } = config;
26
31
  const publicKey = keypair.publicKey.toBase58();
@@ -0,0 +1,17 @@
1
+ import { Action, FactionInfo } from './types';
2
+ export interface ActionAvailability {
3
+ enabled: boolean;
4
+ reason?: string;
5
+ }
6
+ /**
7
+ * Determine which actions are currently available given the player's state.
8
+ * Mirrors the validation logic in chooseAction() but returns structured results
9
+ * for UI consumption (lens page).
10
+ */
11
+ export declare function getAvailableActions(holdings: Map<string, number>, factions: FactionInfo[], activeLoans: number): Map<Action, ActionAvailability>;
12
+ /** Actions that require a message/memo */
13
+ export declare const MESSAGE_ACTIONS: Set<Action>;
14
+ /** Actions that require a SOL amount input */
15
+ export declare const SOL_ACTIONS: Set<Action>;
16
+ /** Filter factions to valid targets for a given action */
17
+ export declare function getValidTargets(action: Action, factions: FactionInfo[], holdings: Map<string, number>): FactionInfo[];
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SOL_ACTIONS = exports.MESSAGE_ACTIONS = void 0;
4
+ exports.getAvailableActions = getAvailableActions;
5
+ exports.getValidTargets = getValidTargets;
6
+ /**
7
+ * Determine which actions are currently available given the player's state.
8
+ * Mirrors the validation logic in chooseAction() but returns structured results
9
+ * for UI consumption (lens page).
10
+ */
11
+ function getAvailableActions(holdings, factions, activeLoans) {
12
+ const result = new Map();
13
+ const hasHoldings = holdings.size > 0;
14
+ const heldMints = [...holdings.keys()];
15
+ const ascendedFactions = factions.filter((f) => f.status === 'ascended');
16
+ const readyFactions = factions.filter((f) => f.status === 'ready');
17
+ const risingFactions = factions.filter((f) => f.status === 'rising');
18
+ const rivalFactions = factions.filter((f) => !heldMints.includes(f.mint));
19
+ const holdsAscended = ascendedFactions.some((f) => holdings.has(f.mint));
20
+ const nonRazed = factions.filter((f) => f.status !== 'razed');
21
+ // join — always available if factions exist
22
+ result.set('join', nonRazed.length > 0
23
+ ? { enabled: true }
24
+ : { enabled: false, reason: 'no factions' });
25
+ // defect — requires holdings
26
+ result.set('defect', hasHoldings
27
+ ? { enabled: true }
28
+ : { enabled: false, reason: 'no holdings' });
29
+ // rally — always available if factions exist (server validates duplicates)
30
+ result.set('rally', nonRazed.length > 0
31
+ ? { enabled: true }
32
+ : { enabled: false, reason: 'no factions' });
33
+ // launch — always available (server validates max)
34
+ result.set('launch', { enabled: true });
35
+ // message — always available if factions exist
36
+ result.set('message', nonRazed.length > 0
37
+ ? { enabled: true }
38
+ : { enabled: false, reason: 'no factions' });
39
+ // reinforce — requires holdings
40
+ result.set('reinforce', hasHoldings
41
+ ? { enabled: true }
42
+ : { enabled: false, reason: 'no holdings' });
43
+ // war_loan — requires holding an ascended faction
44
+ result.set('war_loan', holdsAscended
45
+ ? { enabled: true }
46
+ : { enabled: false, reason: 'no ascended holdings' });
47
+ // repay_loan — requires active loans
48
+ result.set('repay_loan', activeLoans > 0
49
+ ? { enabled: true }
50
+ : { enabled: false, reason: 'no active loans' });
51
+ // siege — requires ascended factions to exist
52
+ result.set('siege', ascendedFactions.length > 0
53
+ ? { enabled: true }
54
+ : { enabled: false, reason: 'no ascended factions' });
55
+ // ascend — requires ready factions
56
+ result.set('ascend', readyFactions.length > 0
57
+ ? { enabled: true }
58
+ : { enabled: false, reason: 'no ready factions' });
59
+ // raze — requires rising factions
60
+ result.set('raze', risingFactions.length > 0
61
+ ? { enabled: true }
62
+ : { enabled: false, reason: 'no rising factions' });
63
+ // tithe — requires ascended factions
64
+ result.set('tithe', ascendedFactions.length > 0
65
+ ? { enabled: true }
66
+ : { enabled: false, reason: 'no ascended factions' });
67
+ // infiltrate — requires factions not held
68
+ result.set('infiltrate', rivalFactions.length > 0
69
+ ? { enabled: true }
70
+ : { enabled: false, reason: 'no rival factions' });
71
+ // fud — requires holdings
72
+ result.set('fud', hasHoldings
73
+ ? { enabled: true }
74
+ : { enabled: false, reason: 'no holdings' });
75
+ // scout — always available if factions exist
76
+ result.set('scout', nonRazed.length > 0
77
+ ? { enabled: true }
78
+ : { enabled: false, reason: 'no factions' });
79
+ // hold — always available
80
+ result.set('hold', { enabled: true });
81
+ return result;
82
+ }
83
+ /** Actions that require a message/memo */
84
+ exports.MESSAGE_ACTIONS = new Set([
85
+ 'join', 'reinforce', 'defect', 'message', 'fud', 'infiltrate',
86
+ ]);
87
+ /** Actions that require a SOL amount input */
88
+ exports.SOL_ACTIONS = new Set([
89
+ 'join', 'reinforce', 'infiltrate',
90
+ ]);
91
+ /** Filter factions to valid targets for a given action */
92
+ function getValidTargets(action, factions, holdings) {
93
+ const heldMints = [...holdings.keys()];
94
+ const nonRazed = factions.filter((f) => f.status !== 'razed');
95
+ switch (action) {
96
+ case 'defect':
97
+ case 'fud':
98
+ case 'reinforce':
99
+ return factions.filter((f) => holdings.has(f.mint));
100
+ case 'infiltrate':
101
+ return nonRazed.filter((f) => !heldMints.includes(f.mint));
102
+ case 'ascend':
103
+ return factions.filter((f) => f.status === 'ready');
104
+ case 'raze':
105
+ return factions.filter((f) => f.status === 'rising');
106
+ case 'siege':
107
+ case 'tithe':
108
+ case 'war_loan':
109
+ return factions.filter((f) => f.status === 'ascended');
110
+ case 'repay_loan':
111
+ return nonRazed; // server validates loan exists
112
+ case 'hold':
113
+ case 'launch':
114
+ return []; // no target needed
115
+ default:
116
+ return nonRazed;
117
+ }
118
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyre-agent-kit",
3
- "version": "10.0.1",
3
+ "version": "10.1.0",
4
4
  "description": "Autonomous agent kit for Pyre — plug in your own LLM and play pyre.world",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",