2020117-agent 0.6.21 → 0.6.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/agent.js CHANGED
@@ -571,8 +571,16 @@ async function handleDvmRequest(label, event) {
571
571
  // Dedup: skip already-seen events
572
572
  if (!markSeen(event.id))
573
573
  return;
574
- if (!acquireSlot())
574
+ if (!acquireSlot()) {
575
+ console.warn(`[${label}] DVM request ${event.id.slice(0, 8)} dropped — agent at capacity (${state.activeJobs}/${MAX_CONCURRENT})`);
576
+ const errorEvent = signEvent({
577
+ kind: 7000,
578
+ tags: [['p', event.pubkey], ['e', event.id], ['status', 'error']],
579
+ content: 'Agent at capacity, please retry later',
580
+ }, state.sovereignKeys.privkey);
581
+ await state.relayPool.publish(errorEvent).catch(() => { });
575
582
  return;
583
+ }
576
584
  try {
577
585
  // Step 1: p-tag filter — if request is directed (has p tags) but not to us, skip
578
586
  const pTags = event.tags.filter(t => t[0] === 'p').map(t => t[1]);
package/dist/nostr.js CHANGED
@@ -203,17 +203,22 @@ export class NostrRelay {
203
203
  async reconnect() {
204
204
  try {
205
205
  await this.connect();
206
- // Re-subscribe after reconnect
207
- for (const [id, handler] of this.subs) {
208
- // Can't re-send original filters, but the subscription handler is preserved
209
- // Caller should re-subscribe if needed
206
+ // Re-send all active subscriptions to the relay
207
+ for (const [id, { filters }] of this.subs) {
208
+ this.ws.send(JSON.stringify(['REQ', id, filters]));
209
+ }
210
+ if (this.subs.size > 0) {
211
+ console.log(`[NostrRelay] Reconnected to ${this.url}, restored ${this.subs.size} subscription(s)`);
210
212
  }
211
213
  }
212
- catch { }
214
+ catch (e) {
215
+ console.error(`[NostrRelay] Reconnect failed for ${this.url}: ${e.message}`);
216
+ }
213
217
  }
214
218
  handleMessage(msg) {
215
219
  if (msg[0] === 'EVENT') {
216
- const handler = this.subs.get(msg[1]);
220
+ const sub = this.subs.get(msg[1]);
221
+ const handler = sub?.handler;
217
222
  if (handler)
218
223
  handler(msg[2]);
219
224
  }
@@ -249,7 +254,7 @@ export class NostrRelay {
249
254
  if (!this.ws || !this._connected)
250
255
  throw new Error('Not connected');
251
256
  const id = randomBytes(4).toString('hex');
252
- this.subs.set(id, handler);
257
+ this.subs.set(id, { filters, handler });
253
258
  if (onEose)
254
259
  this.eoseCallbacks.set(id, onEose);
255
260
  this.ws.send(JSON.stringify(['REQ', id, filters]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "2020117-agent",
3
- "version": "0.6.21",
3
+ "version": "0.6.22",
4
4
  "description": "2020117 agent runtime — Nostr-native relay subscription + Hyperswarm P2P + Lightning payments",
5
5
  "type": "module",
6
6
  "bin": {