@vapi-network/core 0.14.0 → 0.15.0

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 (53) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-link.d.ts +1 -0
  3. package/dist/agent-link.d.ts.map +1 -1
  4. package/dist/agent-link.js +209 -96
  5. package/dist/agent-link.js.map +3 -3
  6. package/dist/atomic-file.d.ts +4 -0
  7. package/dist/atomic-file.d.ts.map +1 -1
  8. package/dist/backup.d.ts.map +1 -1
  9. package/dist/backup.js +202 -146
  10. package/dist/backup.js.map +3 -3
  11. package/dist/cloud-backup.js +312 -197
  12. package/dist/cloud-backup.js.map +3 -3
  13. package/dist/discovery.d.ts +2 -0
  14. package/dist/discovery.d.ts.map +1 -1
  15. package/dist/http-response.d.ts +7 -0
  16. package/dist/http-response.d.ts.map +1 -0
  17. package/dist/index.d.ts +3 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +3269 -2242
  20. package/dist/index.js.map +3 -3
  21. package/dist/keystore-error.d.ts +4 -0
  22. package/dist/keystore-error.d.ts.map +1 -0
  23. package/dist/keystore.d.ts +1 -4
  24. package/dist/keystore.d.ts.map +1 -1
  25. package/dist/payment-warning.d.ts +12 -0
  26. package/dist/payment-warning.d.ts.map +1 -0
  27. package/dist/receipts.d.ts +5 -0
  28. package/dist/receipts.d.ts.map +1 -1
  29. package/dist/router-client.d.ts +107 -7
  30. package/dist/router-client.d.ts.map +1 -1
  31. package/dist/router-client.js +17442 -16631
  32. package/dist/router-client.js.map +3 -3
  33. package/dist/secrets.js +65 -42
  34. package/dist/secrets.js.map +2 -2
  35. package/dist/spend-policy.d.ts.map +1 -1
  36. package/dist/support-report.d.ts +1 -1
  37. package/dist/svm.d.ts.map +1 -1
  38. package/dist/swarm-capital.d.ts +70 -0
  39. package/dist/swarm-capital.d.ts.map +1 -1
  40. package/dist/swarm-workers.d.ts +4 -0
  41. package/dist/swarm-workers.d.ts.map +1 -0
  42. package/dist/swarm.d.ts +1 -1
  43. package/dist/swarm.d.ts.map +1 -1
  44. package/dist/tasks.js +139 -69
  45. package/dist/tasks.js.map +2 -2
  46. package/dist/transfer.d.ts.map +1 -1
  47. package/dist/wallet-store.d.ts +77 -0
  48. package/dist/wallet-store.d.ts.map +1 -1
  49. package/dist/x402-pay.d.ts +10 -2
  50. package/dist/x402-pay.d.ts.map +1 -1
  51. package/dist/x402.d.ts +10 -6
  52. package/dist/x402.d.ts.map +1 -1
  53. package/package.json +1 -1
package/dist/secrets.js CHANGED
@@ -46574,38 +46574,43 @@ async function withFileLock(lockPath, fn, options = {}) {
46574
46574
  const owner = JSON.stringify(ownerRecord);
46575
46575
  const releasedOwner = JSON.stringify({ ...ownerRecord, released: true });
46576
46576
  let handle;
46577
- while (handle === void 0) {
46578
- await atomicFileTestHooks?.beforeLockAttempt?.(lockPath);
46579
- try {
46580
- const candidate = await open2(lockPath, "wx", 384);
46577
+ try {
46578
+ while (handle === void 0) {
46579
+ await atomicFileTestHooks?.beforeLockAttempt?.(lockPath);
46581
46580
  try {
46582
- await candidate.writeFile(owner, "utf8");
46583
- await candidate.sync();
46584
- await atomicFileTestHooks?.afterLockCreate?.(lockPath);
46585
- if (await lockTakeoverInProgress(lockPath)) {
46586
- await candidate.close();
46587
- await removeOwnedLock(lockPath, [owner]);
46588
- await removeAbandonedLockTombs(lockPath);
46589
- if (Date.now() >= deadline) {
46590
- throw new FileLockedError(options.lockedMessage);
46581
+ const candidate = await open2(lockPath, "wx", 384);
46582
+ try {
46583
+ await candidate.writeFile(owner, "utf8");
46584
+ await candidate.sync();
46585
+ await atomicFileTestHooks?.afterLockCreate?.(lockPath);
46586
+ if (await lockTakeoverInProgress(lockPath)) {
46587
+ await candidate.close();
46588
+ await removeOwnedLock(lockPath, [owner]);
46589
+ await removeAbandonedLockTombs(lockPath);
46590
+ if (Date.now() >= deadline) {
46591
+ throw new FileLockedError(options.lockedMessage);
46592
+ }
46593
+ await new Promise((resolve) => setTimeout(resolve, LOCK_RETRY_MS));
46594
+ continue;
46591
46595
  }
46592
- await new Promise((resolve) => setTimeout(resolve, LOCK_RETRY_MS));
46593
- continue;
46596
+ handle = candidate;
46597
+ } catch (error61) {
46598
+ await candidate.close().catch(() => void 0);
46599
+ await removeOwnedLock(lockPath, [owner]).catch(() => void 0);
46600
+ throw error61;
46594
46601
  }
46595
- handle = candidate;
46596
46602
  } catch (error61) {
46597
- await candidate.close().catch(() => void 0);
46598
- await removeOwnedLock(lockPath, [owner]).catch(() => void 0);
46599
- throw error61;
46600
- }
46601
- } catch (error61) {
46602
- if (!hasCode(error61, "EEXIST")) throw error61;
46603
- await removeStaleLock(lockPath);
46604
- if (Date.now() >= deadline) {
46605
- throw new FileLockedError(options.lockedMessage);
46603
+ if (!hasCode(error61, "EEXIST")) throw error61;
46604
+ await removeStaleLock(lockPath);
46605
+ if (Date.now() >= deadline) {
46606
+ throw new FileLockedError(options.lockedMessage);
46607
+ }
46608
+ await new Promise((resolve) => setTimeout(resolve, LOCK_RETRY_MS));
46606
46609
  }
46607
- await new Promise((resolve) => setTimeout(resolve, LOCK_RETRY_MS));
46608
46610
  }
46611
+ } catch (error61) {
46612
+ await removeOwnedTombs(lockPath, [owner]).catch(() => void 0);
46613
+ throw error61;
46609
46614
  }
46610
46615
  const ownedHandle = handle;
46611
46616
  const heartbeat = setInterval(() => {
@@ -46618,13 +46623,18 @@ async function withFileLock(lockPath, fn, options = {}) {
46618
46623
  } finally {
46619
46624
  clearInterval(heartbeat);
46620
46625
  try {
46621
- await markLockReleased(ownedHandle, releasedOwner);
46622
- } finally {
46623
46626
  try {
46624
- await ownedHandle.close();
46627
+ await atomicFileTestHooks?.beforeLockRelease?.(lockPath);
46628
+ await markLockReleased(ownedHandle, releasedOwner);
46625
46629
  } finally {
46626
- await removeOwnedLock(lockPath, [owner, releasedOwner]);
46630
+ try {
46631
+ await ownedHandle.close();
46632
+ await atomicFileTestHooks?.afterLockHandleClose?.(lockPath);
46633
+ } finally {
46634
+ await removeOwnedLock(lockPath, [owner, releasedOwner]);
46635
+ }
46627
46636
  }
46637
+ } catch {
46628
46638
  }
46629
46639
  }
46630
46640
  }
@@ -46661,8 +46671,9 @@ async function removeOwnedLock(path, owners) {
46661
46671
  throw error61;
46662
46672
  }
46663
46673
  let pendingError;
46674
+ let renamedOwner;
46664
46675
  try {
46665
- const renamedOwner = await readFile(tombPath, "utf8");
46676
+ renamedOwner = await readFile(tombPath, "utf8");
46666
46677
  if (!owners.includes(renamedOwner) && !lockOwnerReleased(renamedOwner)) {
46667
46678
  await atomicFileTestHooks?.afterMismatchedLockRename?.(path);
46668
46679
  const currentOwner = await readFile(tombPath, "utf8");
@@ -46673,9 +46684,13 @@ async function removeOwnedLock(path, owners) {
46673
46684
  pendingError = error61;
46674
46685
  }
46675
46686
  try {
46687
+ await atomicFileTestHooks?.beforeTombUnlink?.(tombPath);
46676
46688
  await unlink(tombPath);
46677
46689
  } catch (error61) {
46678
- if (!hasCode(error61, "ENOENT") && pendingError === void 0) {
46690
+ if (!tombUnlinkTolerated(
46691
+ error61,
46692
+ renamedOwner !== void 0 && lockOwnerReleased(renamedOwner) && owners.includes(renamedOwner)
46693
+ ) && pendingError === void 0) {
46679
46694
  pendingError = error61;
46680
46695
  }
46681
46696
  }
@@ -46700,7 +46715,7 @@ async function removeAbandonedLockTombs(path) {
46700
46715
  const abandoned = lockOwnerReleased(owner) || Date.now() - metadata.mtimeMs > LOCK_STALE_AFTER_MS && (pid === void 0 || !processIsAlive(pid));
46701
46716
  if (!abandoned) continue;
46702
46717
  await unlink(tombPath).catch((error61) => {
46703
- if (!hasCode(error61, "ENOENT")) throw error61;
46718
+ if (!tombUnlinkTolerated(error61, true)) throw error61;
46704
46719
  });
46705
46720
  }
46706
46721
  }
@@ -46712,9 +46727,12 @@ async function removeOwnedTombs(path, owners) {
46712
46727
  const tombPath = join2(directory, entry);
46713
46728
  const owner = await readFile(tombPath, "utf8").catch(() => void 0);
46714
46729
  if (owner === void 0 || !owners.includes(owner)) continue;
46715
- await unlink(tombPath).catch((error61) => {
46716
- if (!hasCode(error61, "ENOENT")) throw error61;
46717
- });
46730
+ try {
46731
+ await atomicFileTestHooks?.beforeTombUnlink?.(tombPath);
46732
+ await unlink(tombPath);
46733
+ } catch (error61) {
46734
+ if (!tombUnlinkTolerated(error61, lockOwnerReleased(owner))) throw error61;
46735
+ }
46718
46736
  }
46719
46737
  }
46720
46738
  async function restoreRenamedLock(path, tombPath) {
@@ -46764,6 +46782,9 @@ function processIsAlive(pid) {
46764
46782
  return hasCode(error61, "EPERM");
46765
46783
  }
46766
46784
  }
46785
+ function tombUnlinkTolerated(error61, reapable) {
46786
+ return hasCode(error61, "ENOENT") || reapable && process.platform === "win32" && (hasCode(error61, "EPERM") || hasCode(error61, "EBUSY"));
46787
+ }
46767
46788
  function hasCode(error61, code) {
46768
46789
  return error61 instanceof Error && "code" in error61 && error61.code === code;
46769
46790
  }
@@ -47237,6 +47258,14 @@ function isAlreadyExists(error61) {
47237
47258
  return error61 instanceof Error && "code" in error61 && error61.code === "EEXIST";
47238
47259
  }
47239
47260
 
47261
+ // src/keystore-error.ts
47262
+ var KeystoreError = class extends Error {
47263
+ constructor(message, options) {
47264
+ super(message, options);
47265
+ this.name = "KeystoreError";
47266
+ }
47267
+ };
47268
+
47240
47269
  // src/hd.ts
47241
47270
  import { createHmac } from "node:crypto";
47242
47271
  var EVM_DERIVATION_PATH = "m/44'/60'/0'/0/0";
@@ -47384,12 +47413,6 @@ var encryptedKeysSchema = external_exports.object({
47384
47413
  })
47385
47414
  });
47386
47415
  var encryptedEntropySchema = external_exports.object({ entropy: external_exports.string() });
47387
- var KeystoreError = class extends Error {
47388
- constructor(message, options) {
47389
- super(message, options);
47390
- this.name = "KeystoreError";
47391
- }
47392
- };
47393
47416
  function encryptWithKey(key, plaintext) {
47394
47417
  if (key.byteLength !== KEY_LENGTH) {
47395
47418
  throw new Error(`Expected a ${KEY_LENGTH}-byte AES-256-GCM key.`);