2020117-agent 0.4.6 → 0.4.8
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 +40 -5
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -285,15 +285,30 @@ async function setupSovereign(label) {
|
|
|
285
285
|
state.relayPool = new RelayPool(relayUrls);
|
|
286
286
|
await state.relayPool.connect();
|
|
287
287
|
console.log(`[${label}] Connected to ${state.relayPool.connectedCount} relay(s)`);
|
|
288
|
-
// 4. Publish
|
|
288
|
+
// 4. Publish profile (Kind 0) — name, about, lud16
|
|
289
|
+
await publishProfile(label);
|
|
290
|
+
// 5. Publish ai.info (Kind 31340) — NIP-XX capability advertisement
|
|
289
291
|
await publishAiInfo(label);
|
|
290
|
-
//
|
|
292
|
+
// 6. Publish handler info (Kind 31990) — NIP-89 DVM capability
|
|
291
293
|
await publishHandlerInfo(label);
|
|
292
|
-
//
|
|
294
|
+
// 7. Subscribe to NIP-XX prompts (Kind 25802)
|
|
293
295
|
subscribeNipXX(label);
|
|
294
|
-
//
|
|
296
|
+
// 8. Subscribe to DVM requests (Kind 5xxx) directly from relay
|
|
295
297
|
subscribeDvmRequests(label);
|
|
296
|
-
//
|
|
298
|
+
// 9. Print startup summary
|
|
299
|
+
const relays = (keys.relays || RELAYS).join(', ');
|
|
300
|
+
console.log('');
|
|
301
|
+
console.log(`═══════════════════════════════════════════════`);
|
|
302
|
+
console.log(` Agent ready: ${agentName}`);
|
|
303
|
+
console.log(` Pubkey: ${keys.pubkey}`);
|
|
304
|
+
console.log(` Kind: ${KIND}`);
|
|
305
|
+
console.log(` Relays: ${relays}`);
|
|
306
|
+
console.log(` Lightning: ${LIGHTNING_ADDRESS || '(not set)'}`);
|
|
307
|
+
console.log(` NWC wallet: ${state.nwcParsed ? 'connected' : '(not set)'}`);
|
|
308
|
+
console.log(` Processor: ${state.processor?.name || 'none'}`);
|
|
309
|
+
console.log(`═══════════════════════════════════════════════`);
|
|
310
|
+
console.log('');
|
|
311
|
+
// 10. Start sovereign heartbeat (Kind 30333 to relay)
|
|
297
312
|
startSovereignHeartbeat(label);
|
|
298
313
|
}
|
|
299
314
|
async function publishAiInfo(label) {
|
|
@@ -324,6 +339,26 @@ async function publishAiInfo(label) {
|
|
|
324
339
|
const ok = await state.relayPool.publish(event);
|
|
325
340
|
console.log(`[${label}] Published ai.info (Kind 31340): ${ok ? 'ok' : 'failed'}`);
|
|
326
341
|
}
|
|
342
|
+
async function publishProfile(label) {
|
|
343
|
+
if (!state.sovereignKeys || !state.relayPool)
|
|
344
|
+
return;
|
|
345
|
+
const agentName = state.agentName || 'sovereign-agent';
|
|
346
|
+
const content = {
|
|
347
|
+
name: agentName,
|
|
348
|
+
about: state.skill?.description || `DVM agent (kind ${KIND})`,
|
|
349
|
+
picture: `https://robohash.org/${encodeURIComponent(agentName)}`,
|
|
350
|
+
};
|
|
351
|
+
if (LIGHTNING_ADDRESS) {
|
|
352
|
+
content.lud16 = LIGHTNING_ADDRESS;
|
|
353
|
+
}
|
|
354
|
+
const event = signEvent({
|
|
355
|
+
kind: 0,
|
|
356
|
+
tags: [],
|
|
357
|
+
content: JSON.stringify(content),
|
|
358
|
+
}, state.sovereignKeys.privkey);
|
|
359
|
+
const ok = await state.relayPool.publish(event);
|
|
360
|
+
console.log(`[${label}] Published profile (Kind 0): ${ok ? 'ok' : 'failed'}`);
|
|
361
|
+
}
|
|
327
362
|
async function publishHandlerInfo(label) {
|
|
328
363
|
if (!state.sovereignKeys || !state.relayPool)
|
|
329
364
|
return;
|