pyre-agent-kit 10.0.2 → 10.1.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.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { PyreAgentConfig, PyreAgent } from './types';
2
- import { llmDecide, buildCompactModelPrompt, FactionContext, LLMDecideOptions } from './agent';
2
+ import { llmDecide, buildAgentPrompt, buildCompactModelPrompt, FactionContext, LLMDecideOptions } from './agent';
3
3
  export type { PyreAgentConfig, PyreAgent, AgentTickResult, SerializedAgentState, LLMAdapter, LLMDecision, FactionInfo, Personality, Action, AgentState, } from './types';
4
4
  export { assignPersonality, PERSONALITY_SOL, PERSONALITY_WEIGHTS, personalityDesc, } from './defaults';
5
5
  export { classifyPersonality, weightsFromCounts, actionIndex } from './chain';
6
6
  export { generateFactionIdentity } from './faction';
7
- export { llmDecide, buildCompactModelPrompt };
7
+ export { llmDecide, buildAgentPrompt, 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,11 +1,12 @@
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.buildAgentPrompt = 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");
7
7
  const agent_1 = require("./agent");
8
8
  Object.defineProperty(exports, "llmDecide", { enumerable: true, get: function () { return agent_1.llmDecide; } });
9
+ Object.defineProperty(exports, "buildAgentPrompt", { enumerable: true, get: function () { return agent_1.buildAgentPrompt; } });
9
10
  Object.defineProperty(exports, "buildCompactModelPrompt", { enumerable: true, get: function () { return agent_1.buildCompactModelPrompt; } });
10
11
  const executor_1 = require("./executor");
11
12
  const chain_1 = require("./chain");
@@ -21,6 +22,11 @@ Object.defineProperty(exports, "weightsFromCounts", { enumerable: true, get: fun
21
22
  Object.defineProperty(exports, "actionIndex", { enumerable: true, get: function () { return chain_2.actionIndex; } });
22
23
  var faction_1 = require("./faction");
23
24
  Object.defineProperty(exports, "generateFactionIdentity", { enumerable: true, get: function () { return faction_1.generateFactionIdentity; } });
25
+ var validation_1 = require("./validation");
26
+ Object.defineProperty(exports, "getAvailableActions", { enumerable: true, get: function () { return validation_1.getAvailableActions; } });
27
+ Object.defineProperty(exports, "getValidTargets", { enumerable: true, get: function () { return validation_1.getValidTargets; } });
28
+ Object.defineProperty(exports, "MESSAGE_ACTIONS", { enumerable: true, get: function () { return validation_1.MESSAGE_ACTIONS; } });
29
+ Object.defineProperty(exports, "SOL_ACTIONS", { enumerable: true, get: function () { return validation_1.SOL_ACTIONS; } });
24
30
  async function createPyreAgent(config) {
25
31
  const { kit, keypair, llm, maxFoundedFactions = 2 } = config;
26
32
  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.2",
3
+ "version": "10.1.1",
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",