@vapi-network/core 0.2.3 → 0.5.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 (74) hide show
  1. package/README.md +18 -5
  2. package/dist/accounts.d.ts.map +1 -1
  3. package/dist/agent-guard.d.ts +40 -0
  4. package/dist/agent-guard.d.ts.map +1 -0
  5. package/dist/agent-link.d.ts +98 -0
  6. package/dist/agent-link.d.ts.map +1 -0
  7. package/dist/agent-link.js +1715 -0
  8. package/dist/agent-link.js.map +6 -0
  9. package/dist/agent-profile.d.ts +27 -0
  10. package/dist/agent-profile.d.ts.map +1 -0
  11. package/dist/api-key.d.ts +99 -0
  12. package/dist/api-key.d.ts.map +1 -0
  13. package/dist/api-key.js +20084 -0
  14. package/dist/api-key.js.map +6 -0
  15. package/dist/audit.d.ts +44 -0
  16. package/dist/audit.d.ts.map +1 -0
  17. package/dist/authorization-state.d.ts +58 -0
  18. package/dist/authorization-state.d.ts.map +1 -0
  19. package/dist/call-contracts-wire.d.ts +151 -11
  20. package/dist/call-contracts-wire.d.ts.map +1 -1
  21. package/dist/config.d.ts +10 -1
  22. package/dist/config.d.ts.map +1 -1
  23. package/dist/discovery.d.ts +20 -2
  24. package/dist/discovery.d.ts.map +1 -1
  25. package/dist/hd.d.ts +33 -0
  26. package/dist/hd.d.ts.map +1 -0
  27. package/dist/index.d.ts +14 -2
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +25354 -954
  30. package/dist/index.js.map +3 -3
  31. package/dist/keystore.d.ts +94 -4
  32. package/dist/keystore.d.ts.map +1 -1
  33. package/dist/marketplace-contracts.d.ts +448 -15
  34. package/dist/marketplace-contracts.d.ts.map +1 -1
  35. package/dist/networks.d.ts +16 -2
  36. package/dist/networks.d.ts.map +1 -1
  37. package/dist/onramp.d.ts +12 -28
  38. package/dist/onramp.d.ts.map +1 -1
  39. package/dist/passphrase.d.ts +47 -0
  40. package/dist/passphrase.d.ts.map +1 -0
  41. package/dist/policy.d.ts +6 -0
  42. package/dist/policy.d.ts.map +1 -1
  43. package/dist/receipts.d.ts +40 -4
  44. package/dist/receipts.d.ts.map +1 -1
  45. package/dist/router-client.d.ts +117 -0
  46. package/dist/router-client.d.ts.map +1 -0
  47. package/dist/router-client.js +27421 -0
  48. package/dist/router-client.js.map +6 -0
  49. package/dist/secret-store.d.ts +60 -0
  50. package/dist/secret-store.d.ts.map +1 -0
  51. package/dist/secrets.d.ts +14 -0
  52. package/dist/secrets.d.ts.map +1 -0
  53. package/dist/secrets.js +47238 -0
  54. package/dist/secrets.js.map +6 -0
  55. package/dist/spend-policy.d.ts +13 -1
  56. package/dist/spend-policy.d.ts.map +1 -1
  57. package/dist/stats.d.ts +3 -2
  58. package/dist/stats.d.ts.map +1 -1
  59. package/dist/support-report.d.ts +1 -1
  60. package/dist/sweep.d.ts +4 -0
  61. package/dist/sweep.d.ts.map +1 -1
  62. package/dist/wallet-name.d.ts +18 -0
  63. package/dist/wallet-name.d.ts.map +1 -0
  64. package/dist/wallet-store.d.ts +220 -0
  65. package/dist/wallet-store.d.ts.map +1 -0
  66. package/dist/wallet.d.ts +0 -5
  67. package/dist/wallet.d.ts.map +1 -1
  68. package/dist/x402-networks.d.ts +6 -9
  69. package/dist/x402-networks.d.ts.map +1 -1
  70. package/dist/x402-pay.d.ts +131 -0
  71. package/dist/x402-pay.d.ts.map +1 -0
  72. package/dist/x402.d.ts +20 -1
  73. package/dist/x402.d.ts.map +1 -1
  74. package/package.json +17 -1
@@ -1,7 +1,7 @@
1
- import { ARC_MAINNET_CAIP2_PLACEHOLDER, ARC_TESTNET_CAIP2, BASE_MAINNET_CAIP2, SOLANA_MAINNET_CAIP2, SOLANA_MAINNET_USDC, X402_SOLANA_MAINNET_CAIP2 } from "./x402-networks.js";
1
+ import { ARC_MAINNET_CAIP2, ARC_TESTNET_CAIP2, BASE_MAINNET_CAIP2, SOLANA_MAINNET_CAIP2, SOLANA_MAINNET_USDC, X402_SOLANA_MAINNET_CAIP2 } from "./x402-networks.js";
2
2
  import { type Chain, type HttpTransport, type PublicClient } from "viem";
3
3
  import { type LookupFn } from "./net-guard.js";
4
- export { ARC_MAINNET_CAIP2_PLACEHOLDER, ARC_TESTNET_CAIP2, BASE_MAINNET_CAIP2, SOLANA_MAINNET_CAIP2, SOLANA_MAINNET_USDC, X402_SOLANA_MAINNET_CAIP2, };
4
+ export { ARC_MAINNET_CAIP2, ARC_TESTNET_CAIP2, BASE_MAINNET_CAIP2, SOLANA_MAINNET_CAIP2, SOLANA_MAINNET_USDC, X402_SOLANA_MAINNET_CAIP2, };
5
5
  export declare const USDC_DECIMALS = 6;
6
6
  export declare const DEFAULT_ARC_GAS_HEADROOM_ATOMIC = 50000n;
7
7
  export type NetworkDefinition = {
@@ -12,6 +12,7 @@ export type NetworkDefinition = {
12
12
  gasToken: "ETH" | "USDC" | "SOL";
13
13
  rpcEnv: string;
14
14
  publicRpcUrl?: string;
15
+ explorerUrl?: string;
15
16
  };
16
17
  export type ConfiguredNetwork = {
17
18
  rpcUrl: string;
@@ -32,6 +33,16 @@ export declare const NETWORKS: {
32
33
  readonly rpcEnv: "BASE_RPC_URL";
33
34
  readonly publicRpcUrl: "https://mainnet.base.org";
34
35
  };
36
+ readonly "eip155:5042": {
37
+ readonly family: "evm";
38
+ readonly chainId: 5042;
39
+ readonly name: "Arc mainnet";
40
+ readonly usdc: `0x${string}`;
41
+ readonly gasToken: "USDC";
42
+ readonly rpcEnv: "ARC_RPC_URL";
43
+ readonly publicRpcUrl: "https://rpc.mainnet.arc.io";
44
+ readonly explorerUrl: "https://explorer.arc.io";
45
+ };
35
46
  readonly "eip155:5042002": {
36
47
  readonly family: "evm";
37
48
  readonly chainId: 5042002;
@@ -59,6 +70,9 @@ export declare const NETWORKS: {
59
70
  };
60
71
  export declare function parseEip155ChainId(network: string): number;
61
72
  export declare function isSolanaNetwork(network: string): boolean;
73
+ export declare function usesUsdcGas(network: string): boolean;
74
+ export declare function explorerTransactionUrl(network: string, hash: string): string | undefined;
75
+ export declare function explorerAddressUrl(network: string, address: string): string | undefined;
62
76
  export declare function areSamePaymentNetwork(left: string, right: string): boolean;
63
77
  export declare function isSupportedPaymentNetwork(network: string): boolean;
64
78
  export declare function configuredNetworkFor(networks: Readonly<Record<string, ConfiguredNetwork>>, network: string): ConfiguredNetwork | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../src/networks.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,iBAAiB,EACjB,kBAAkB,EAElB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAML,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAEd,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EACL,6BAA6B,EAC7B,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,GAC1B,CAAC;AACF,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,+BAA+B,SAAU,CAAC;AAEvD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAC;I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,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAMpD;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOxF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOvF;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAQlE;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,EACrD,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,SAAS,CAM/B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAcvE;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAapF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAuBlE;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,iBAAiB,EAC7B,OAAO,GAAE,uBAA4B,GACpC,YAAY,CAMd;AAED,uFAAuF;AACvF,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,uBAA4B,GACpC,aAAa,CAQf;AAED,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEvD"}
package/dist/onramp.d.ts CHANGED
@@ -1,36 +1,20 @@
1
- import { type LookupFn } from "./net-guard.js";
2
1
  /** Onramp deposits land on Base, the only network the hosted onramp settles to. */
3
2
  export declare const ONRAMP_NETWORK = "base";
4
- export declare const ONRAMP_ASSET = "USDC";
5
- /** Printed whenever the hosted onramp cannot be used; funding stays possible. */
3
+ /** Printed alongside the funding page, so funding never depends on a browser. */
6
4
  export declare const ONRAMP_FALLBACK_INSTRUCTIONS = "Send USDC on Base (eip155:8453) to this address; add a little ETH for gas if you plan to sweep.";
7
- export type CreateOnrampSessionOptions = {
8
- address: string;
9
- /** Requested fiat amount in USD. Omitted when the caller has no preference. */
10
- fiatAmount?: number;
11
- registryUrl?: string;
12
- env?: NodeJS.ProcessEnv;
13
- fetchImpl?: typeof fetch;
14
- allowPrivateNetwork?: boolean;
15
- lookup?: LookupFn;
16
- };
17
- export type OnrampSession = {
18
- status: "ready";
19
- address: string;
20
- url: string;
21
- } | {
22
- status: "unavailable";
23
- address: string;
24
- reason: string;
25
- instructions: string;
5
+ export type FundingPageOptions = {
6
+ /** Fiat amount in USD to prefill on the page. Omitted when the caller has no preference. */
7
+ amount?: number;
26
8
  };
9
+ /** The registry this install talks to: the env override first, then the shipped default. */
10
+ export declare function resolveRegistryUrl(env?: NodeJS.ProcessEnv): string;
27
11
  /**
28
- * Ask the registry for a hosted onramp session for one local address.
12
+ * Build the URL of the hosted funding page for one local address.
29
13
  *
30
- * vAPI never holds funds: the session is created by the registry with the
31
- * onramp provider, and the user pays the provider directly. Every failure mode
32
- * degrades to direct-transfer instructions instead of throwing, so funding
33
- * advice is always available.
14
+ * The page is public — no sign-in — and mints the card-payment session at click
15
+ * time, so the link never goes stale in a terminal scrollback or an agent
16
+ * transcript. It also offers a wallet transfer and a bridge, which is why this
17
+ * is the only funding link the client hands out. Pure: no network, no clock.
34
18
  */
35
- export declare function createOnrampSession(options: CreateOnrampSessionOptions): Promise<OnrampSession>;
19
+ export declare function fundingPageUrl(registryUrl: string, address: string, options?: FundingPageOptions): string;
36
20
  //# sourceMappingURL=onramp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"onramp.d.ts","sourceRo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AC5F,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAE/E;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CAWR"}
@@ -0,0 +1,47 @@
1
+ import { type SecretStore } from "./secret-store.js";
2
+ /**
3
+ * Where the passphrase of a wallet comes from, in one place.
4
+ *
5
+ * The order is `VAPI_KEYSTORE_PASSWORD`, then the OS secret store, then a
6
+ * prompt on a real terminal. The environment variable stays first so CI keeps
7
+ * working; the secret store is what lets an editor's MCP configuration hold no
8
+ * secret at all; the prompt is for a person, and a run with no terminal says
9
+ * how to arrange one of the other two instead.
10
+ */
11
+ export declare const PASSPHRASE_ENVIRONMENT_VARIABLE = "VAPI_KEYSTORE_PASSWORD";
12
+ /** Which of the three routes actually produced the passphrase. */
13
+ export type PassphraseSource = "environment" | "secret-store" | "prompt";
14
+ export type ResolvedPassphrase = {
15
+ passphrase: string;
16
+ source: PassphraseSource;
17
+ };
18
+ export type ResolvePassphraseOptions = {
19
+ /** The environment to read `VAPI_KEYSTORE_PASSWORD` from. */
20
+ env?: NodeJS.ProcessEnv | undefined;
21
+ /** The OS secret store to consult. Defaults to this platform's. */
22
+ store?: SecretStore | undefined;
23
+ /** Reads one line without echoing it. Defaults to the terminal prompt. */
24
+ prompt?: ((prompt: string, noTerminalHint?: string) => Promise<string>) | undefined;
25
+ /** False when nobody is watching, so the prompt is refused before it starts. */
26
+ interactive?: boolean | undefined;
27
+ /**
28
+ * Ask twice. A passphrase that is being set rather than used never comes
29
+ * from the secret store, so this also skips it.
30
+ */
31
+ confirm?: boolean | undefined;
32
+ };
33
+ /** The two ways out of a run that cannot prompt, named for the wallet at hand. */
34
+ export declare function noPassphraseHint(walletName: string): string;
35
+ /**
36
+ * The message for a stored passphrase that no longer opens its wallet — the
37
+ * shape of a passphrase changed on one machine while another kept the old one.
38
+ */
39
+ export declare function staleStoredPassphraseMessage(walletName: string, store: SecretStore): string;
40
+ /**
41
+ * The passphrase for one wallet: environment, then secret store, then prompt.
42
+ * A secret store that cannot be reached — no keyring installed, a locked
43
+ * session — is not fatal here; the prompt, or the error that names both other
44
+ * routes, is the better answer than a failure a person cannot act on.
45
+ */
46
+ export declare function resolvePassphrase(walletName: string, options?: ResolvePassphraseOptions): Promise<ResolvedPassphrase>;
47
+ //# sourceMappingURL=passphrase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passphrase.d.ts","sourceRoot":"","sources":["../src/passphrase.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElE;;;;;;;;GAQG;AAEH,eAAO,MAAM,+BAA+B,2BAA2B,CAAC;AAExE,kEAAkE;AAClE,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,cAAc,GAAG,QAAQ,CAAC;AAEzE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;IACpC,mEAAmE;IACnE,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC,0EAA0E;IAC1E,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IACpF,gFAAgF;IAChF,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAK3F;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,kBAAkB,CAAC,CA+B7B"}
package/dist/policy.d.ts CHANGED
@@ -11,12 +11,18 @@ export type PaymentIntent = Readonly<{
11
11
  export interface Policy {
12
12
  authorize(intent: PaymentIntent): Promise<void>;
13
13
  }
14
+ /**
15
+ * Caps one wallet's spending. The caps belong to the wallet, not to the
16
+ * machine: pass the wallet's name so today's total is counted against that
17
+ * wallet alone.
18
+ */
14
19
  export declare class SpendPolicy implements Policy {
15
20
  readonly caps: SpendCaps;
16
21
  private readonly options;
17
22
  constructor(caps: SpendCaps, options?: {
18
23
  ledgerPath?: string;
19
24
  now?: () => Date;
25
+ wallet?: string;
20
26
  });
21
27
  authorize(intent: PaymentIntent): Promise<void>;
22
28
  reserve(amountAtomic: bigint): Promise<SpendLedger>;
@@ -1 +1 @@
1
- {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,WAAW,MAAM;IACrB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC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AAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAO1D"}
@@ -1,8 +1,11 @@
1
1
  import type { ListingProvenance } from "./discovery.js";
2
+ import { type WalletName } from "./wallet-name.js";
2
3
  import type { X402SettlementOutcome } from "./x402.js";
3
4
  export interface Receipt {
4
5
  readonly id: string;
5
6
  readonly timestamp: string;
7
+ /** The wallet that paid. Absent on receipts written before named wallets, which belong to `main`. */
8
+ readonly wallet?: string;
6
9
  readonly resourceUrl: string;
7
10
  readonly method?: string;
8
11
  /** Primary discovery source retained for compatibility with early receipt writers. */
@@ -15,9 +18,27 @@ export interface Receipt {
15
18
  payTo?: string;
16
19
  }>;
17
20
  readonly payer?: string;
21
+ /**
22
+ * The x402 payment-identifier id sent with this payment. Absent on receipts
23
+ * written before it and when the server did not advertise payment-identifier.
24
+ */
25
+ readonly paymentId?: string;
26
+ /**
27
+ * The EIP-3009 authorization this call signed, kept so a payment whose
28
+ * response was lost can be settled against the chain later with
29
+ * `vapi pay --resume`. The token and the network are the quote's `asset` and
30
+ * `network`. Absent on receipts written before 0.4.0, on Solana payments,
31
+ * and on calls that signed no payment.
32
+ */
33
+ readonly authorization?: Readonly<{
34
+ from: string;
35
+ nonce: string;
36
+ validBefore: string;
37
+ }>;
18
38
  readonly settlement?: Readonly<{
19
39
  outcome: X402SettlementOutcome;
20
40
  transaction?: string;
41
+ explorerUrl?: string;
21
42
  evidence?: unknown;
22
43
  }>;
23
44
  readonly latencyMs?: number;
@@ -50,11 +71,26 @@ export interface Receipt {
50
71
  readonly outcome?: "paid" | "signed_in" | "declined_policy" | "failed_request" | "settlement_rejected" | "settlement_unknown";
51
72
  }
52
73
  export declare function parseReceipt(value: unknown): Receipt;
53
- /** Append exactly one receipt as one JSONL record. Existing records are never rewritten. */
54
- export declare function appendReceipt(receipt: Receipt, path?: string): Promise<Receipt>;
74
+ /**
75
+ * Append exactly one receipt as one JSONL record. Existing records are never
76
+ * rewritten. `options.wallet` names the wallet that paid when the receipt does
77
+ * not already carry one.
78
+ */
79
+ export declare function appendReceipt(receipt: Receipt, path?: string, options?: {
80
+ wallet?: string;
81
+ }): Promise<Receipt>;
55
82
  export declare function readReceipts(path?: string, options?: {
56
83
  limit?: number;
84
+ wallet?: string;
57
85
  }): Promise<Receipt[]>;
58
- /** Compatibility alias used by early CLI code. */
59
- export declare const listReceipts: typeof readReceipts;
86
+ /** The wallet a receipt belongs to; rows written before named wallets are `main`. */
87
+ export declare function receiptWallet(receipt: Receipt): WalletName;
88
+ /** Keeps the receipts of one wallet, counting rows without a wallet as `main`. */
89
+ export declare function filterReceiptsByWallet(receipts: readonly Receipt[], name: WalletName): Receipt[];
90
+ /**
91
+ * Rewrites the wallet field of every matching row after a wallet is renamed.
92
+ * Rows of other wallets keep their exact bytes, and the file is replaced in one
93
+ * atomic rename. Returns how many rows changed.
94
+ */
95
+ export declare function renameReceiptWallet(from: WalletName, to: WalletName, path?: string): Promise<number>;
60
96
  //# sourceMappingURL=receipts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"receipts.d.ts","sourceRoot":"","sources":["../src/receipts.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,sFAAsF;IACtF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACnD,QAAQ,CAAC,KAAK,CA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AAmB,CACvC,IAAI,EAAE,UAAU,EAChB,EAAE,EAAE,UAAU,EACd,IAAI,SAA0B,GAC7B,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
@@ -0,0 +1,117 @@
1
+ import type { SpendCaps, VapiConfig } from "./config.js";
2
+ import type { VapiPaymentAccount } from "./keystore.js";
3
+ import type { Receipt } from "./receipts.js";
4
+ import type { SecretStore } from "./secret-store.js";
5
+ import { type RouterTopupTier, type WalletName, type WalletStore } from "./wallet-store.js";
6
+ export { ROUTER_TOPUP_TIERS, type RouterRefill, type RouterTopupTier } from "./wallet-store.js";
7
+ export type RouterModel = {
8
+ id: string;
9
+ [k: string]: unknown;
10
+ };
11
+ export type ChatMessage = {
12
+ role: "system" | "user" | "assistant" | "tool";
13
+ content: string;
14
+ name?: string;
15
+ tool_call_id?: string;
16
+ tool_calls?: Array<{
17
+ id: string;
18
+ type: "function";
19
+ function: {
20
+ name: string;
21
+ arguments: string;
22
+ };
23
+ }>;
24
+ };
25
+ export type ChatRequest = {
26
+ model: string;
27
+ messages: ChatMessage[];
28
+ max_tokens?: number;
29
+ temperature?: number;
30
+ tools?: unknown[];
31
+ tool_choice?: unknown;
32
+ };
33
+ export type ChatResult = {
34
+ content: string | null;
35
+ toolCalls: Array<{
36
+ id: string;
37
+ name: string;
38
+ arguments: string;
39
+ }>;
40
+ usage?: {
41
+ prompt_tokens: number;
42
+ completion_tokens: number;
43
+ total_tokens: number;
44
+ };
45
+ model: string;
46
+ keyUsed: "stake" | "balance";
47
+ };
48
+ export type AgentRouterUsage = {
49
+ compute: {
50
+ allowanceUsd: number;
51
+ spentTodayUsd: number;
52
+ remainingTodayUsd: number;
53
+ resetsAt: string;
54
+ ownerLimitUsd: number;
55
+ ownerSpentUsd: number;
56
+ };
57
+ balance: {
58
+ purchasedUsd: number;
59
+ spentUsd: number;
60
+ remainingUsd: number;
61
+ } | null;
62
+ };
63
+ export declare class RouterClientError extends Error {
64
+ readonly code: "not_linked" | "no_router_key" | "budget_exhausted" | "http";
65
+ readonly status?: number | undefined;
66
+ constructor(code: "not_linked" | "no_router_key" | "budget_exhausted" | "http", message: string, status?: number | undefined);
67
+ }
68
+ export declare const ROUTER_KEY_REVOKED_MESSAGE = "The Router key was revoked. Run vapi login to link again, or vapi router key --rotate if the link is still active.";
69
+ export type RouterClientDeps = {
70
+ secrets: SecretStore;
71
+ wallets: WalletStore;
72
+ wallet: WalletName;
73
+ fetchImpl?: typeof fetch;
74
+ refill?: {
75
+ account: VapiPaymentAccount | (() => Promise<VapiPaymentAccount>);
76
+ config: VapiConfig;
77
+ caps: SpendCaps | (() => Promise<SpendCaps>);
78
+ paths?: {
79
+ ledgerPath?: string;
80
+ receiptsPath?: string;
81
+ };
82
+ now?: Date;
83
+ };
84
+ };
85
+ export declare const DEFAULT_ROUTER_BASE_URL = "https://router.vapinetwork.ai";
86
+ export declare function listRouterModels(deps: {
87
+ apiBase: string;
88
+ fetchImpl?: typeof fetch;
89
+ }): Promise<RouterModel[]>;
90
+ export declare function routerUsage(deps: RouterClientDeps): Promise<AgentRouterUsage>;
91
+ export declare function buyRouterBalance(deps: RouterClientDeps & {
92
+ account: VapiPaymentAccount;
93
+ config: VapiConfig;
94
+ caps: SpendCaps;
95
+ paths?: {
96
+ ledgerPath?: string;
97
+ receiptsPath?: string;
98
+ };
99
+ now?: Date;
100
+ }, tierUsd: RouterTopupTier): Promise<{
101
+ receipt: Receipt;
102
+ balance: AgentRouterUsage["balance"];
103
+ }>;
104
+ export declare function routerChat(deps: RouterClientDeps, request: ChatRequest): Promise<ChatResult>;
105
+ export declare function rotateRouterKey(deps: RouterClientDeps): Promise<void>;
106
+ export declare function ownerStake(deps: RouterClientDeps): Promise<{
107
+ owner: string;
108
+ stake: string;
109
+ computeTodayUsd: number;
110
+ stakeUrl: string;
111
+ }>;
112
+ /** For the SDK (plan 029): base URL + key for OpenAI-compatible frameworks. Never exposed via MCP. */
113
+ export declare function routerCredentials(deps: RouterClientDeps): Promise<{
114
+ baseURL: string;
115
+ apiKey: string;
116
+ }>;
117
+ //# sourceMappingURL=router-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-client.d.ts","sourceRoot":"","sources":["../src/router-client.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEhG,MAAM,MAAM,WAAW,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE/D,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,UAAU,CAAC;QACjB,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/C,CAAC,CAAC;CACJ,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC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