pyre-agent-kit 2.0.21 → 2.0.22
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/cli.js +60 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -47,6 +47,7 @@ const fs = __importStar(require("fs"));
|
|
|
47
47
|
const path = __importStar(require("path"));
|
|
48
48
|
const web3_js_1 = require("@solana/web3.js");
|
|
49
49
|
const index_1 = require("./index");
|
|
50
|
+
const pyre_world_kit_1 = require("pyre-world-kit");
|
|
50
51
|
// ─── Constants ────────────────────────────────────────────────────
|
|
51
52
|
const CONFIG_PATH = path.join(process.env.HOME ?? '.', '.pyre-agent.json');
|
|
52
53
|
const BANNER = `
|
|
@@ -340,7 +341,29 @@ async function runAgent(config) {
|
|
|
340
341
|
};
|
|
341
342
|
process.on('SIGINT', shutdown);
|
|
342
343
|
process.on('SIGTERM', shutdown);
|
|
343
|
-
//
|
|
344
|
+
// Action tracking for checkpoints
|
|
345
|
+
const CHECKPOINT_EVERY = 20;
|
|
346
|
+
const ALL_ACTIONS = [
|
|
347
|
+
'join', 'defect', 'rally', 'launch', 'message',
|
|
348
|
+
'stronghold', 'war_loan', 'repay_loan', 'siege', 'ascend', 'raze', 'tithe',
|
|
349
|
+
'infiltrate', 'fud',
|
|
350
|
+
];
|
|
351
|
+
const actionCounts = new Array(14).fill(0);
|
|
352
|
+
const recentMemos = [];
|
|
353
|
+
// Seed counts from registry profile if available
|
|
354
|
+
try {
|
|
355
|
+
const reg = await (0, pyre_world_kit_1.getRegistryProfile)(connection, keypair.publicKey.toBase58());
|
|
356
|
+
if (reg) {
|
|
357
|
+
const seed = [
|
|
358
|
+
reg.joins, reg.defects, reg.rallies, reg.launches, reg.messages,
|
|
359
|
+
reg.reinforces, reg.war_loans, reg.repay_loans, reg.sieges,
|
|
360
|
+
reg.ascends, reg.razes, reg.tithes, reg.infiltrates, reg.fuds,
|
|
361
|
+
];
|
|
362
|
+
for (let i = 0; i < seed.length; i++)
|
|
363
|
+
actionCounts[i] = Math.max(actionCounts[i], seed[i]);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
catch { /* no profile yet */ }
|
|
344
367
|
let tickCount = 0;
|
|
345
368
|
while (running) {
|
|
346
369
|
try {
|
|
@@ -350,11 +373,47 @@ async function runAgent(config) {
|
|
|
350
373
|
const msg = result.message ? ` "${result.message}"` : '';
|
|
351
374
|
const brain = result.usedLLM ? 'LLM' : 'RNG';
|
|
352
375
|
console.log(` [${ts()}] #${tickCount} [${brain}] ${result.action.toUpperCase()} ${result.faction ?? ''}${msg} — ${status}`);
|
|
376
|
+
// Track actions for checkpoint
|
|
377
|
+
if (result.success) {
|
|
378
|
+
const idx = ALL_ACTIONS.indexOf(result.action);
|
|
379
|
+
if (idx >= 0)
|
|
380
|
+
actionCounts[idx]++;
|
|
381
|
+
if (result.message?.trim()) {
|
|
382
|
+
recentMemos.push(result.message);
|
|
383
|
+
if (recentMemos.length > 10)
|
|
384
|
+
recentMemos.shift();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
353
387
|
// Auto-save state every 10 ticks
|
|
354
388
|
if (tickCount % 10 === 0) {
|
|
355
389
|
const saved = agent.serialize();
|
|
356
390
|
fs.writeFileSync(statePath, JSON.stringify(saved, null, 2));
|
|
357
391
|
}
|
|
392
|
+
// Checkpoint to pyre_world every N ticks
|
|
393
|
+
if (tickCount % CHECKPOINT_EVERY === 0) {
|
|
394
|
+
try {
|
|
395
|
+
const personality = agent.personality;
|
|
396
|
+
const summary = recentMemos.length > 0
|
|
397
|
+
? `${personality}: ${recentMemos.slice(-5).join('. ')}`.slice(0, 256)
|
|
398
|
+
: personality;
|
|
399
|
+
const pub = keypair.publicKey.toBase58();
|
|
400
|
+
const cpResult = await (0, pyre_world_kit_1.buildCheckpointTransaction)(connection, {
|
|
401
|
+
signer: pub,
|
|
402
|
+
creator: pub,
|
|
403
|
+
joins: actionCounts[0], defects: actionCounts[1], rallies: actionCounts[2],
|
|
404
|
+
launches: actionCounts[3], messages: actionCounts[4], fuds: actionCounts[13],
|
|
405
|
+
infiltrates: actionCounts[12], reinforces: actionCounts[5],
|
|
406
|
+
war_loans: actionCounts[6], repay_loans: actionCounts[7], sieges: actionCounts[8],
|
|
407
|
+
ascends: actionCounts[9], razes: actionCounts[10], tithes: actionCounts[11],
|
|
408
|
+
personality_summary: summary,
|
|
409
|
+
});
|
|
410
|
+
await (0, index_1.sendAndConfirm)(connection, keypair, cpResult);
|
|
411
|
+
console.log(` [${ts()}] Checkpointed to pyre_world (${actionCounts.reduce((a, b) => a + b, 0)} total actions)`);
|
|
412
|
+
}
|
|
413
|
+
catch (e) {
|
|
414
|
+
console.error(` [${ts()}] Checkpoint failed: ${e.message?.slice(0, 60)}`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
358
417
|
}
|
|
359
418
|
catch (e) {
|
|
360
419
|
console.error(` [${ts()}] Tick error: ${e.message}`);
|