pyre-agent-kit 2.0.20 → 2.0.21
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/registry.js +15 -4
- package/package.json +1 -1
package/dist/registry.js
CHANGED
|
@@ -9,23 +9,34 @@ const tx_1 = require("./tx");
|
|
|
9
9
|
*/
|
|
10
10
|
async function ensureRegistryProfile(connection, agent, log) {
|
|
11
11
|
const short = agent.publicKey.slice(0, 8);
|
|
12
|
+
// Try to fetch existing profile
|
|
12
13
|
try {
|
|
13
14
|
const existing = await (0, pyre_world_kit_1.getRegistryProfile)(connection, agent.publicKey);
|
|
14
15
|
if (existing) {
|
|
15
16
|
log(`[${short}] registry profile found (${existing.address.slice(0, 8)}), last checkpoint: ${existing.last_checkpoint > 0 ? new Date(existing.last_checkpoint * 1000).toISOString().slice(0, 10) : 'never'}`);
|
|
16
17
|
return existing;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Fetch failed — profile may or may not exist, try to register below
|
|
22
|
+
}
|
|
23
|
+
// Try to create — if it already exists, init will fail, that's fine
|
|
24
|
+
try {
|
|
19
25
|
const result = await (0, pyre_world_kit_1.buildRegisterAgentTransaction)(connection, {
|
|
20
26
|
creator: agent.publicKey,
|
|
21
27
|
});
|
|
22
28
|
await (0, tx_1.sendAndConfirm)(connection, agent.keypair, result);
|
|
23
29
|
log(`[${short}] created registry profile`);
|
|
24
|
-
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Already exists or insufficient funds — either way, try to fetch
|
|
33
|
+
}
|
|
34
|
+
// Final fetch attempt
|
|
35
|
+
try {
|
|
25
36
|
return await (0, pyre_world_kit_1.getRegistryProfile)(connection, agent.publicKey);
|
|
26
37
|
}
|
|
27
|
-
catch
|
|
28
|
-
log(`[${short}] registry profile
|
|
38
|
+
catch {
|
|
39
|
+
log(`[${short}] registry profile unavailable`);
|
|
29
40
|
return null;
|
|
30
41
|
}
|
|
31
42
|
}
|