@owli/agent-sdk 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ratchet.js +20 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owli/agent-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Headless Node.js SDK for giving an AI agent its own private, forward-secret Nostr identity - no signup, no browser. Phase 1 of the ai.owli.chat initiative.",
5
5
  "keywords": [
6
6
  "nostr",
package/src/ratchet.js CHANGED
@@ -378,7 +378,26 @@ export async function trySend(secretKey, myPubkey, contactPubkey, text, expirySe
378
378
  // above (a relay-side NIP-40 hint), and the two would silently collide
379
379
  // on the same inner rumor if this reused it.
380
380
  if (disappearAfterSec) rumorOptions.tags = [[DISAPPEAR_TAG, String(Math.floor(Date.now() / 1000) + disappearAfterSec)]];
381
- const { event } = session.sendEvent(buildTextRumor(text, rumorOptions));
381
+ let event;
382
+ try {
383
+ ({ event } = session.sendEvent(buildTextRumor(text, rumorOptions)));
384
+ } catch (err) {
385
+ // Real, confirmed bug this fixes: a persisted session that loaded but
386
+ // is missing the ratchet key state needed to actually send (nostr-
387
+ // double-ratchet's own Session.sendEvent throws "we are not the
388
+ // initiator, so we can't send the first message" for this exact
389
+ // shape) used to reject straight out of trySend instead of falling
390
+ // back - this function's own doc comment already promised "returns
391
+ // null if no session could be established, callers fall back to
392
+ // nip17.wrapEvent" but the guard above only covered "no session
393
+ // found," never "session found but unusable." Confirmed live: two
394
+ // freshly-created agents CC'ing a brand-new owner relationship hit
395
+ // this on every single attempt, permanently, since nothing ever
396
+ // discarded the broken session to let a real one bootstrap instead.
397
+ sessions.delete(contactPubkey);
398
+ await storage.deleteRatchetSession(contactPubkey);
399
+ return null;
400
+ }
382
401
  await publish(event);
383
402
  await persist(contactPubkey, session);
384
403
  return event;