2020117-agent 0.6.2 → 0.6.3
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 +17 -2
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -22,6 +22,8 @@ for (const arg of process.argv.slice(2)) {
|
|
|
22
22
|
if (eq === -1) {
|
|
23
23
|
// Bare flags (no value)
|
|
24
24
|
if (arg === '--sovereign') { } // legacy flag, all agents are now Nostr-native
|
|
25
|
+
if (arg === '--p2p-only')
|
|
26
|
+
process.env.P2P_ONLY = 'true';
|
|
25
27
|
continue;
|
|
26
28
|
}
|
|
27
29
|
const key = arg.slice(0, eq);
|
|
@@ -72,6 +74,9 @@ for (const arg of process.argv.slice(2)) {
|
|
|
72
74
|
case '--relays':
|
|
73
75
|
process.env.NOSTR_RELAYS = val;
|
|
74
76
|
break;
|
|
77
|
+
case '--p2p-only':
|
|
78
|
+
process.env.P2P_ONLY = val;
|
|
79
|
+
break;
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
import { randomBytes } from 'crypto';
|
|
@@ -88,6 +93,7 @@ if (!globalThis.WebSocket)
|
|
|
88
93
|
// --- Config from env ---
|
|
89
94
|
const KIND = Number(process.env.DVM_KIND) || 5100;
|
|
90
95
|
const MAX_CONCURRENT = Number(process.env.MAX_JOBS) || 3;
|
|
96
|
+
const P2P_ONLY = process.env.P2P_ONLY === 'true' || process.env.P2P_ONLY === '1';
|
|
91
97
|
const SATS_PER_CHUNK = Number(process.env.SATS_PER_CHUNK) || 1;
|
|
92
98
|
const CHUNKS_PER_PAYMENT = Number(process.env.CHUNKS_PER_PAYMENT) || 10;
|
|
93
99
|
// --- Lightning payment config ---
|
|
@@ -246,11 +252,13 @@ async function setupNostr(label) {
|
|
|
246
252
|
await publishProfile(label);
|
|
247
253
|
// 5. Publish ai.info (Kind 31340) — NIP-XX capability advertisement
|
|
248
254
|
await publishAiInfo(label);
|
|
249
|
-
// 6. Publish handler info (Kind 31990) — NIP-89 DVM capability
|
|
255
|
+
// 6. Publish handler info (Kind 31990) — NIP-89 DVM capability (always, even P2P-only)
|
|
250
256
|
await publishHandlerInfo(label);
|
|
251
257
|
// 7. Subscribe to NIP-XX prompts (Kind 25802)
|
|
252
258
|
subscribeNipXX(label);
|
|
253
|
-
// 8. Subscribe to DVM requests (Kind 5xxx)
|
|
259
|
+
// 8. Subscribe to DVM requests (Kind 5xxx)
|
|
260
|
+
// P2P-only: still subscribes but handleDvmRequest will ignore broadcast jobs,
|
|
261
|
+
// only responding to direct requests (p tag = our pubkey)
|
|
254
262
|
subscribeDvmRequests(label);
|
|
255
263
|
subscribeDvmResults(label);
|
|
256
264
|
// 9. Start heartbeat (Kind 30333 to relay)
|
|
@@ -277,6 +285,7 @@ async function setupNostr(label) {
|
|
|
277
285
|
console.log(` Lightning: ${LIGHTNING_ADDRESS || '(not set)'}`);
|
|
278
286
|
console.log(` NWC wallet: ${state.nwcParsed ? 'connected' : '(not set)'}`);
|
|
279
287
|
console.log(` Processor: ${state.processor?.name || 'none'}`);
|
|
288
|
+
console.log(` Mode: ${P2P_ONLY ? 'P2P-only (DVM disabled)' : 'DVM + P2P'}`);
|
|
280
289
|
console.log(`═══════════════════════════════════════════════`);
|
|
281
290
|
console.log('');
|
|
282
291
|
}
|
|
@@ -542,6 +551,12 @@ async function handleDvmRequest(label, event) {
|
|
|
542
551
|
// Skip own events
|
|
543
552
|
if (event.pubkey === state.sovereignKeys.pubkey)
|
|
544
553
|
return;
|
|
554
|
+
// P2P-only mode: only handle direct requests (p tag pointing to us)
|
|
555
|
+
if (P2P_ONLY) {
|
|
556
|
+
const isDirected = event.tags.some(t => t[0] === 'p' && t[1] === state.sovereignKeys.pubkey);
|
|
557
|
+
if (!isDirected)
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
545
560
|
// Dedup: skip already-seen events
|
|
546
561
|
if (!markSeen(event.id))
|
|
547
562
|
return;
|