agentcash 0.14.4 → 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 (93) hide show
  1. package/dist/cjs/run-server.cjs +40656 -17083
  2. package/dist/esm/{add-skill-MO4YPAYM.js → add-skill-5HFBHQTQ.js} +10 -10
  3. package/dist/esm/{bridge-Q4YWH4WW.js → bridge-BOLVXKCD.js} +7 -7
  4. package/dist/esm/{check-3GPSLBNI.js → check-FEWY37RD.js} +7 -7
  5. package/dist/esm/{chunk-JKK2XT7N.js → chunk-2C7X7XIG.js} +3 -3
  6. package/dist/esm/{chunk-UCADMHNP.js → chunk-2E4ZDG2M.js} +2 -2
  7. package/dist/esm/{chunk-YUPRVVFP.js → chunk-4MCPQDKM.js} +3 -3
  8. package/dist/esm/{chunk-JX2XE6FD.js → chunk-4TIYIVZF.js} +1 -1
  9. package/dist/esm/chunk-4TIYIVZF.js.map +1 -0
  10. package/dist/esm/{chunk-CUZFVI2X.js → chunk-5MITNOWT.js} +2 -2
  11. package/dist/esm/{chunk-MSNAPI5G.js → chunk-BIO4Y27B.js} +3 -3
  12. package/dist/esm/{chunk-BNFMFAEF.js → chunk-C7B6LEPE.js} +3 -3
  13. package/dist/esm/{chunk-KJCWPVQE.js → chunk-EM6OE6WL.js} +3 -3
  14. package/dist/esm/chunk-FBGNOXFP.js +102 -0
  15. package/dist/esm/chunk-FBGNOXFP.js.map +1 -0
  16. package/dist/esm/{chunk-JVMJVMWB.js → chunk-HNDMHX4B.js} +207 -83
  17. package/dist/esm/chunk-HNDMHX4B.js.map +1 -0
  18. package/dist/esm/{chunk-NPJV7AMV.js → chunk-HTGTKVXB.js} +6 -2
  19. package/dist/esm/chunk-HTGTKVXB.js.map +1 -0
  20. package/dist/esm/{chunk-L4U6AJW3.js → chunk-K3WB4R2P.js} +3 -2
  21. package/dist/esm/{chunk-L4U6AJW3.js.map → chunk-K3WB4R2P.js.map} +1 -1
  22. package/dist/esm/{chunk-2OKYUR7B.js → chunk-MKA2PTOE.js} +5 -7
  23. package/dist/esm/chunk-MKA2PTOE.js.map +1 -0
  24. package/dist/esm/{chunk-ONGJJBKT.js → chunk-MZPHS3IS.js} +4 -4
  25. package/dist/esm/{chunk-2SZ6MZS3.js → chunk-O57QVTLM.js} +2 -2
  26. package/dist/esm/{chunk-BFOYXXLG.js → chunk-RAS5DZPQ.js} +15 -1
  27. package/dist/esm/chunk-RAS5DZPQ.js.map +1 -0
  28. package/dist/esm/{chunk-7KT6UCTT.js → chunk-SLTRGQ7W.js} +8 -3
  29. package/dist/esm/{chunk-7KT6UCTT.js.map → chunk-SLTRGQ7W.js.map} +1 -1
  30. package/dist/esm/chunk-TX7S7QGG.js +146 -0
  31. package/dist/esm/chunk-TX7S7QGG.js.map +1 -0
  32. package/dist/esm/{chunk-QOMU3YLK.js → chunk-ULB5PPKW.js} +2 -2
  33. package/dist/esm/{chunk-WRNDLZ3K.js → chunk-VGKAPM5S.js} +3 -3
  34. package/dist/esm/{chunk-3PYQIEMA.js → chunk-W37JKCLN.js} +41 -3
  35. package/dist/esm/chunk-W37JKCLN.js.map +1 -0
  36. package/dist/esm/{chunk-TTAO2EJK.js → chunk-YPFBBTA2.js} +1 -1
  37. package/dist/esm/chunk-YPFBBTA2.js.map +1 -0
  38. package/dist/esm/{discover-TE2BZJMA.js → discover-TXEJNB5A.js} +5 -5
  39. package/dist/esm/{fetch-ZAECKP5C.js → fetch-QAVIWIRX.js} +12 -11
  40. package/dist/esm/{fetch-ZAECKP5C.js.map → fetch-QAVIWIRX.js.map} +1 -1
  41. package/dist/esm/{fund-HHL4QEU5.js → fund-FCOUEG7T.js} +5 -5
  42. package/dist/esm/index.js +70 -34
  43. package/dist/esm/index.js.map +1 -1
  44. package/dist/esm/{install-EOF353SY.js → install-NJJZYBZU.js} +8 -8
  45. package/dist/esm/{onboard-EMUCEMFN.js → onboard-TYB4QZE4.js} +12 -12
  46. package/dist/esm/{origins-MBWKIWLR.js → origins-EVVF3N4G.js} +6 -6
  47. package/dist/esm/{register-NSQPYCWI.js → register-T6M2US4B.js} +62 -21
  48. package/dist/esm/register-T6M2US4B.js.map +1 -0
  49. package/dist/esm/{report-error-7RCKDM2N.js → report-error-BR7ETMF7.js} +5 -5
  50. package/dist/esm/{search-SYBTWXON.js → search-KIPT62MB.js} +11 -10
  51. package/dist/esm/{search-SYBTWXON.js.map → search-KIPT62MB.js.map} +1 -1
  52. package/dist/esm/{server-NHOKDQHU.js → server-MO3YMDHB.js} +83 -18
  53. package/dist/esm/server-MO3YMDHB.js.map +1 -0
  54. package/dist/esm/{server-ZIKTGUST.js → server-WJH536CN.js} +2 -2
  55. package/dist/esm/sessions-NUOSJC6M.js +74 -0
  56. package/dist/esm/sessions-NUOSJC6M.js.map +1 -0
  57. package/dist/esm/{settings-RLSKK5RM.js → settings-SBL7WIBQ.js} +2 -2
  58. package/dist/esm/{try-MXWZSHRS.js → try-2P5ZRXRT.js} +9 -9
  59. package/dist/esm/{wallet-QOS3FPSF.js → wallet-PY4ZDHNZ.js} +12 -12
  60. package/package.json +8 -8
  61. package/dist/esm/chunk-2OKYUR7B.js.map +0 -1
  62. package/dist/esm/chunk-3PYQIEMA.js.map +0 -1
  63. package/dist/esm/chunk-BFOYXXLG.js.map +0 -1
  64. package/dist/esm/chunk-JVMJVMWB.js.map +0 -1
  65. package/dist/esm/chunk-JX2XE6FD.js.map +0 -1
  66. package/dist/esm/chunk-NPJV7AMV.js.map +0 -1
  67. package/dist/esm/chunk-TTAO2EJK.js.map +0 -1
  68. package/dist/esm/register-NSQPYCWI.js.map +0 -1
  69. package/dist/esm/server-NHOKDQHU.js.map +0 -1
  70. /package/dist/esm/{add-skill-MO4YPAYM.js.map → add-skill-5HFBHQTQ.js.map} +0 -0
  71. /package/dist/esm/{bridge-Q4YWH4WW.js.map → bridge-BOLVXKCD.js.map} +0 -0
  72. /package/dist/esm/{check-3GPSLBNI.js.map → check-FEWY37RD.js.map} +0 -0
  73. /package/dist/esm/{chunk-JKK2XT7N.js.map → chunk-2C7X7XIG.js.map} +0 -0
  74. /package/dist/esm/{chunk-UCADMHNP.js.map → chunk-2E4ZDG2M.js.map} +0 -0
  75. /package/dist/esm/{chunk-YUPRVVFP.js.map → chunk-4MCPQDKM.js.map} +0 -0
  76. /package/dist/esm/{chunk-CUZFVI2X.js.map → chunk-5MITNOWT.js.map} +0 -0
  77. /package/dist/esm/{chunk-MSNAPI5G.js.map → chunk-BIO4Y27B.js.map} +0 -0
  78. /package/dist/esm/{chunk-BNFMFAEF.js.map → chunk-C7B6LEPE.js.map} +0 -0
  79. /package/dist/esm/{chunk-KJCWPVQE.js.map → chunk-EM6OE6WL.js.map} +0 -0
  80. /package/dist/esm/{chunk-ONGJJBKT.js.map → chunk-MZPHS3IS.js.map} +0 -0
  81. /package/dist/esm/{chunk-2SZ6MZS3.js.map → chunk-O57QVTLM.js.map} +0 -0
  82. /package/dist/esm/{chunk-QOMU3YLK.js.map → chunk-ULB5PPKW.js.map} +0 -0
  83. /package/dist/esm/{chunk-WRNDLZ3K.js.map → chunk-VGKAPM5S.js.map} +0 -0
  84. /package/dist/esm/{discover-TE2BZJMA.js.map → discover-TXEJNB5A.js.map} +0 -0
  85. /package/dist/esm/{fund-HHL4QEU5.js.map → fund-FCOUEG7T.js.map} +0 -0
  86. /package/dist/esm/{install-EOF353SY.js.map → install-NJJZYBZU.js.map} +0 -0
  87. /package/dist/esm/{onboard-EMUCEMFN.js.map → onboard-TYB4QZE4.js.map} +0 -0
  88. /package/dist/esm/{origins-MBWKIWLR.js.map → origins-EVVF3N4G.js.map} +0 -0
  89. /package/dist/esm/{report-error-7RCKDM2N.js.map → report-error-BR7ETMF7.js.map} +0 -0
  90. /package/dist/esm/{server-ZIKTGUST.js.map → server-WJH536CN.js.map} +0 -0
  91. /package/dist/esm/{settings-RLSKK5RM.js.map → settings-SBL7WIBQ.js.map} +0 -0
  92. /package/dist/esm/{try-MXWZSHRS.js.map → try-2P5ZRXRT.js.map} +0 -0
  93. /package/dist/esm/{wallet-QOS3FPSF.js.map → wallet-PY4ZDHNZ.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/operations/bridge.ts","../../src/shared/network.ts","../../../../internal/bridge/src/quote.ts","../../../../internal/bridge/src/client.ts","../../../../internal/bridge/src/execute.ts","../../../../internal/bridge/src/relay-svm-wallet-adapter.ts","../../src/shared/neverthrow/bridge/index.ts"],"sourcesContent":["import z from 'zod';\n\nimport { createWalletClient, http } from 'viem';\n\nimport { EVM_CONFIGS, Network, networkSchema } from '@agentcash/networks';\n\nimport { toTypedNetworkAddress } from '@/shared/network';\nimport { TOOL_PARAMS } from '@/shared/descriptions';\nimport {\n safeExecuteQuote,\n safeExecuteSolana,\n safeGetBridgeDepositQuote,\n} from '@/shared/neverthrow/bridge';\nimport { safeFetchJson } from '@/shared/neverthrow/fetch';\nimport { getBaseUrl } from '@/shared/utils';\n\nimport type { Wallets } from '@/wallet';\nimport type { Execute } from '@agentcash/bridge';\nimport type { GlobalFlags } from '@/types';\n\nexport const bridgeSchema = z\n .object({\n from: networkSchema.describe(TOOL_PARAMS.bridge.from),\n to: networkSchema.describe(TOOL_PARAMS.bridge.to),\n amount: z.number().positive().describe(TOOL_PARAMS.bridge.amount),\n })\n .refine(({ from, to }) => from !== to, {\n message: 'From and to networks cannot be the same',\n });\n\nexport type BridgeInput = z.input<typeof bridgeSchema>;\n\nexport const bridge = async (\n args: GlobalFlags<z.infer<typeof bridgeSchema>>,\n wallets: Wallets\n) => {\n const { from, to, amount } = args;\n\n if (from === Network.SOLANA) {\n const request = new Request(`${getBaseUrl(args.dev)}/api/bridge/solana`, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n },\n body: JSON.stringify({\n fromAddress: wallets.svm.address,\n to: toTypedNetworkAddress(to, wallets),\n amount,\n }),\n });\n const response = await safeFetchJson(\n 'bridge',\n request,\n z.object({\n success: z.literal(true),\n partiallySignedTransaction: z.string(),\n quote: z.custom<Execute>(),\n })\n );\n\n if (response.isErr()) {\n return response;\n }\n\n const { partiallySignedTransaction, quote } = response.value;\n\n const executeResult = await safeExecuteSolana('bridge', {\n quote,\n signer: wallets.svm,\n partiallySignedTransaction,\n });\n\n return executeResult.map(\n result => result.data.details ?? { success: true }\n );\n } else {\n const quote = await safeGetBridgeDepositQuote('bridge', {\n from: toTypedNetworkAddress(from, wallets),\n to: toTypedNetworkAddress(to, wallets),\n amount,\n });\n\n if (quote.isErr()) {\n return quote;\n }\n\n const executeResult = await safeExecuteQuote(\n 'bridge',\n quote.value,\n createWalletClient({\n account: wallets.evm,\n chain: EVM_CONFIGS[from].chain,\n transport: http(EVM_CONFIGS[from].rpcUrl),\n })\n );\n\n return executeResult.map(\n result => result.data.details ?? { success: true }\n );\n }\n};\n","import { Network } from '@agentcash/networks';\n\nimport type { TypedNetworkAddress } from '@agentcash/networks';\nimport type { Wallets } from '@/wallet';\n\nexport const toTypedNetworkAddress = (\n network: Network,\n wallets: Wallets\n): TypedNetworkAddress => {\n if (network === Network.SOLANA) {\n return {\n address: wallets.svm.address,\n network: Network.SOLANA,\n };\n }\n return {\n address: wallets.evm.address,\n network: network,\n };\n};\n","import {\n Network,\n solanaAddressSchema,\n typedAddressSchema,\n usdc,\n} from '@agentcash/networks';\nimport z from 'zod';\n\nimport { relayClient, relayChainId } from './client';\n\nexport const getBridgeDepositQuoteSchema = z.object({\n from: typedAddressSchema,\n to: typedAddressSchema,\n amount: z.number(),\n depositFeePayer: solanaAddressSchema.optional(),\n});\n\nexport const getBridgeDepositQuote = async (\n input: z.input<typeof getBridgeDepositQuoteSchema>\n) => {\n const parseResult = getBridgeDepositQuoteSchema.safeParse(input);\n if (!parseResult.success) {\n throw new Error('Invalid input');\n }\n\n const { from, to, amount, depositFeePayer } = parseResult.data;\n\n const fromCurrency = usdc(from.network);\n const toCurrency = usdc(to.network);\n\n return await relayClient.actions.getQuote({\n chainId: relayChainId(from.network),\n toChainId: relayChainId(to.network),\n currency: fromCurrency.address,\n toCurrency: toCurrency.address,\n tradeType: 'EXACT_INPUT',\n user: from.address,\n recipient: to.address,\n amount: (amount * 10 ** fromCurrency.decimals).toString(),\n options: {\n refundTo: from.address,\n depositFeePayer:\n from.network === Network.SOLANA ? depositFeePayer : undefined,\n usePermit: from.network !== Network.SOLANA,\n },\n });\n};\n","import {\n createClient,\n convertViemChainToRelayChain,\n MAINNET_RELAY_API,\n} from '@relayprotocol/relay-sdk';\n\nimport { Network, chainId, EVM_CONFIGS } from '@agentcash/networks';\n\nimport type { RelayChain } from '@relayprotocol/relay-sdk';\n\nexport const SOLANA_RELAY_CHAIN: RelayChain = {\n id: 792703809,\n name: 'solana',\n displayName: 'Solana',\n httpRpcUrl: 'https://api.mainnet-beta.solana.com',\n wsRpcUrl: '',\n explorerUrl: 'https://solscan.io',\n depositEnabled: true,\n tokenSupport: 'All',\n currency: {\n id: 'sol',\n symbol: 'SOL',\n name: 'Solana',\n address: '11111111111111111111111111111111',\n decimals: 9,\n supportsBridging: true,\n },\n featuredTokens: [\n {\n id: 'sol',\n symbol: 'SOL',\n name: 'Solana',\n address: '11111111111111111111111111111111',\n decimals: 9,\n supportsBridging: true,\n metadata: {\n logoURI:\n 'https://upload.wikimedia.org/wikipedia/en/b/b9/Solana_logo.png',\n },\n },\n {\n id: 'usdc',\n symbol: 'USDC',\n name: 'USD Coin',\n address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',\n decimals: 6,\n supportsBridging: true,\n metadata: {\n logoURI:\n 'https://coin-images.coingecko.com/coins/images/6319/large/usdc.png?1696506694',\n },\n },\n {\n id: 'usdt',\n symbol: 'USDT',\n name: 'USDT',\n address: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',\n decimals: 6,\n supportsBridging: true,\n metadata: {\n logoURI:\n 'https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661',\n },\n },\n ],\n erc20Currencies: [\n {\n id: 'pengu',\n symbol: 'PENGU',\n name: 'Pudgy Penguins',\n address: '2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv',\n decimals: 6,\n supportsBridging: true,\n withdrawalFee: 25,\n depositFee: 0,\n surgeEnabled: false,\n },\n {\n id: 'usdc',\n symbol: 'USDC',\n name: 'USD Coin',\n address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',\n decimals: 6,\n supportsBridging: true,\n supportsPermit: true,\n withdrawalFee: 2.25,\n depositFee: 2,\n surgeEnabled: false,\n },\n {\n id: 'usdt',\n symbol: 'USDT',\n name: 'USDT',\n address: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',\n decimals: 6,\n supportsBridging: true,\n withdrawalFee: 5,\n depositFee: 2,\n surgeEnabled: false,\n },\n {\n id: 'cash',\n symbol: 'CASH',\n name: 'CASH',\n address: 'CASHx9KJUStyftLFWGvEVf59SGeG9sh5FfcnZMVPCASH',\n decimals: 6,\n supportsBridging: true,\n withdrawalFee: 25,\n depositFee: 0,\n surgeEnabled: false,\n },\n {\n id: 'pyusd',\n symbol: 'PYUSD',\n name: 'PayPal USD',\n address: '2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo',\n decimals: 6,\n supportsBridging: true,\n withdrawalFee: 25,\n depositFee: 0,\n surgeEnabled: false,\n },\n ],\n solverCurrencies: [\n {\n id: 'pengu',\n symbol: 'PENGU',\n name: 'Pudgy Penguins',\n address: '2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv',\n decimals: 6,\n },\n {\n id: 'usdc',\n symbol: 'USDC',\n name: 'USD Coin',\n address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',\n decimals: 6,\n },\n {\n id: 'usdt',\n symbol: 'USDT',\n name: 'USDT',\n address: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',\n decimals: 6,\n },\n {\n id: 'cash',\n symbol: 'CASH',\n name: 'CASH',\n address: 'CASHx9KJUStyftLFWGvEVf59SGeG9sh5FfcnZMVPCASH',\n decimals: 6,\n },\n {\n id: 'pyusd',\n symbol: 'PYUSD',\n name: 'PayPal USD',\n address: '2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo',\n decimals: 6,\n },\n {\n id: 'sol',\n symbol: 'SOL',\n name: 'Solana',\n address: '11111111111111111111111111111111',\n decimals: 9,\n },\n ],\n iconUrl: 'https://assets.relay.link/icons/792703809/light.png',\n vmType: 'svm',\n baseChainId: 1,\n tags: [],\n protocol: {\n v2: {\n chainId: 'solana',\n depository: '99vQwtBwYtrqqD9YSXbdum3KBdxPAVxYTaQ3cfnJSrN2',\n },\n },\n};\n\nexport const relayChainId = (network: Network) => {\n switch (network) {\n case Network.BASE:\n case Network.TEMPO:\n return chainId(network);\n case Network.SOLANA:\n return SOLANA_RELAY_CHAIN.id;\n }\n};\n\nexport const relayClient = createClient({\n baseApiUrl: MAINNET_RELAY_API,\n source: 'https://agentcash.dev',\n chains: [\n ...Object.values(EVM_CONFIGS).map(config =>\n convertViemChainToRelayChain(config.chain)\n ),\n SOLANA_RELAY_CHAIN,\n ],\n});\n","import { adaptViemWallet } from '@relayprotocol/relay-sdk';\n\nimport { relayClient } from './client';\nimport type { AdaptSolanaKitWalletParams } from './relay-svm-wallet-adapter';\nimport { adaptSolanaKitWallet } from './relay-svm-wallet-adapter';\n\nimport type { WalletClient } from 'viem';\nimport type { Execute } from '@relayprotocol/relay-sdk';\n\nexport const executeQuote = async (quote: Execute, account: WalletClient) => {\n return await relayClient.actions.execute({\n wallet: adaptViemWallet(account),\n quote,\n });\n};\n\nexport interface ExecuteSolanaParams extends AdaptSolanaKitWalletParams {\n quote: Execute;\n}\n\nexport const executeSolana = async ({\n quote,\n ...rest\n}: ExecuteSolanaParams) => {\n return await relayClient.actions.execute({\n wallet: adaptSolanaKitWallet(rest),\n quote,\n });\n};\n","import {\n assertIsSendableTransaction,\n assertIsTransactionWithinSizeLimit,\n createSolanaRpc,\n getBase64EncodedWireTransaction,\n getCompiledTransactionMessageDecoder,\n getSignatureFromTransaction,\n getTransactionDecoder,\n getTransactionLifetimeConstraintFromCompiledTransactionMessage,\n isTransactionModifyingSigner,\n isTransactionPartialSigner,\n isTransactionSendingSigner,\n} from '@solana/kit';\nimport { LogLevel, getClient } from '@relayprotocol/relay-sdk';\n\nimport { SOLANA_RELAY_CHAIN } from './client';\n\nimport type { AdaptedWallet } from '@relayprotocol/relay-sdk';\nimport type {\n ClusterUrl,\n Signature,\n Transaction,\n TransactionSigner,\n TransactionWithLifetime,\n TransactionWithinSizeLimit,\n} from '@solana/kit';\n\nconst BASE58_SIGNATURE_REGEX = /^[1-9A-HJ-NP-Za-km-z]+$/;\nconst DEFAULT_CONFIRM_TIMEOUT_MS = 120_000;\nconst DEFAULT_CONFIRM_POLL_MS = 2_000;\n\nexport interface AdaptSolanaKitWalletParams {\n signer: TransactionSigner;\n partiallySignedTransaction: string;\n rpcUrl?: ClusterUrl;\n}\n\ntype SignableTransaction = Transaction &\n TransactionWithLifetime &\n TransactionWithinSizeLimit;\n\nconst assertBase58TransactionSignature = (signature: string | undefined) => {\n if (\n typeof signature !== 'string' ||\n signature.length === 0 ||\n !BASE58_SIGNATURE_REGEX.test(signature)\n ) {\n throw new Error('Invalid Solana signature: expected base58.');\n }\n};\n\nconst sleep = async (ms: number) =>\n await new Promise(resolve => setTimeout(resolve, ms));\n\nasync function decodePartiallySignedTransaction(\n partiallySignedTransaction: string\n): Promise<SignableTransaction> {\n const decodedTransaction = getTransactionDecoder().decode(\n Uint8Array.from(Buffer.from(partiallySignedTransaction, 'base64'))\n );\n const compiledTransactionMessage =\n getCompiledTransactionMessageDecoder().decode(\n decodedTransaction.messageBytes\n );\n const lifetimeConstraint =\n await getTransactionLifetimeConstraintFromCompiledTransactionMessage(\n compiledTransactionMessage\n );\n const transactionWithLifetime = {\n ...decodedTransaction,\n lifetimeConstraint,\n };\n\n assertIsTransactionWithinSizeLimit(transactionWithLifetime);\n\n return transactionWithLifetime;\n}\n\nasync function signTransactionWithSigner(\n transaction: SignableTransaction,\n signer: TransactionSigner\n): Promise<SignableTransaction> {\n if (isTransactionModifyingSigner(signer)) {\n const [signedTransaction] = await signer.modifyAndSignTransactions([\n transaction,\n ]);\n\n if (!signedTransaction) {\n throw new Error('Modifying signer did not return a signed transaction');\n }\n\n return signedTransaction;\n }\n\n if (isTransactionPartialSigner(signer)) {\n const [signatureDictionary] = await signer.signTransactions([transaction]);\n\n if (!signatureDictionary) {\n throw new Error('Transaction signer did not return signatures');\n }\n\n return {\n ...transaction,\n signatures: Object.freeze({\n ...transaction.signatures,\n ...signatureDictionary,\n }),\n };\n }\n\n if (isTransactionSendingSigner(signer)) {\n throw new Error(\n 'TransactionSendingSigner is not supported by Relay Solana adapter'\n );\n }\n\n throw new Error(\n 'Unsupported Solana transaction signer provided to Relay adapter'\n );\n}\n\nexport const adaptSolanaKitWallet = ({\n rpcUrl = SOLANA_RELAY_CHAIN.httpRpcUrl as ClusterUrl,\n signer,\n partiallySignedTransaction,\n}: AdaptSolanaKitWalletParams): AdaptedWallet => {\n const rpc = createSolanaRpc(rpcUrl);\n return {\n vmType: 'svm',\n getChainId: () => Promise.resolve(SOLANA_RELAY_CHAIN.id),\n address: () => Promise.resolve(signer.address),\n handleSignMessageStep: () => {\n throw new Error('Message signing not implemented for Solana');\n },\n handleSendTransactionStep: async () => {\n const client = getClient();\n const decodedTransaction = await decodePartiallySignedTransaction(\n partiallySignedTransaction\n );\n const signedTransaction = await signTransactionWithSigner(\n decodedTransaction,\n signer\n );\n\n assertIsSendableTransaction(signedTransaction);\n const wireTransaction =\n getBase64EncodedWireTransaction(signedTransaction);\n const signature = getSignatureFromTransaction(signedTransaction);\n\n await rpc\n .sendTransaction(wireTransaction, {\n encoding: 'base64',\n skipPreflight: false,\n preflightCommitment: 'confirmed',\n })\n .send();\n\n assertBase58TransactionSignature(signature);\n\n client.log(\n ['Transaction Signature obtained', { signature }],\n LogLevel.Verbose\n );\n\n return signature;\n },\n handleConfirmTransactionStep: async txHash => {\n assertBase58TransactionSignature(txHash);\n\n const deadline = Date.now() + DEFAULT_CONFIRM_TIMEOUT_MS;\n\n while (Date.now() < deadline) {\n const { value: statuses } = await rpc\n .getSignatureStatuses([txHash as Signature])\n .send();\n\n const status = statuses[0];\n\n if (status) {\n if (status.err) {\n throw new Error(\n `Transaction failed: ${JSON.stringify(status.err)}`\n );\n }\n\n if (\n status.confirmationStatus === 'confirmed' ||\n status.confirmationStatus === 'finalized'\n ) {\n return {\n blockHash: status.slot.toString(),\n blockNumber: Number(status.slot),\n txHash,\n };\n }\n }\n\n await sleep(DEFAULT_CONFIRM_POLL_MS);\n }\n\n throw new Error(\n `Transaction not confirmed within ${DEFAULT_CONFIRM_TIMEOUT_MS}ms: ${txHash}`\n );\n },\n switchChain: () => {\n throw new Error('Switching chains not implemented for Solana');\n },\n };\n};\n","import {\n executeQuote,\n executeSolana,\n getBridgeDepositQuote,\n} from '@agentcash/bridge';\nimport { err, resultFromPromise } from '@agentcash/neverthrow';\n\nimport type { BaseBridgeError } from './types';\n\nconst errorType = 'bridge';\n\nexport const bridgeErr = (surface: string, error: BaseBridgeError) =>\n err(errorType, surface, error);\n\nconst bridgeResultFromPromise = <T>(\n surface: string,\n promise: Promise<T>,\n error: (e: unknown) => BaseBridgeError\n) => resultFromPromise(errorType, surface, promise, error);\n\nconst getErrorMessage = (error: unknown, fallback: string) => {\n if (error instanceof Error && error.message) {\n return error.message;\n }\n\n if (typeof error === 'string' && error.length > 0) {\n return error;\n }\n\n return fallback;\n};\n\nexport const safeGetBridgeDepositQuote = (\n surface: string,\n ...args: Parameters<typeof getBridgeDepositQuote>\n) =>\n bridgeResultFromPromise(surface, getBridgeDepositQuote(...args), error => {\n const errorMessage = getErrorMessage(\n error,\n 'Failed to get bridge deposit quote'\n );\n\n return {\n cause: 'get_bridge_deposit_quote',\n errorMessage,\n message: `Failed to get bridge deposit quote: ${errorMessage}`,\n };\n });\n\nexport const safeExecuteQuote = (\n surface: string,\n ...args: Parameters<typeof executeQuote>\n) =>\n bridgeResultFromPromise(surface, executeQuote(...args), error => {\n const errorMessage = getErrorMessage(error, 'Failed to execute quote');\n\n return {\n cause: 'execute_quote',\n errorMessage,\n message: `Failed to execute quote: ${errorMessage}`,\n };\n });\n\nexport const safeExecuteSolana = (\n surface: string,\n ...args: Parameters<typeof executeSolana>\n) =>\n bridgeResultFromPromise(surface, executeSolana(...args), error => {\n const errorMessage = getErrorMessage(\n error,\n 'Failed to execute Solana bridge transaction'\n );\n\n return {\n cause: 'execute_solana',\n errorMessage,\n message: `Failed to execute Solana bridge transaction: ${errorMessage}`,\n };\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,QAAO;AAEd,SAAS,oBAAoB,YAAY;;;ACGlC,IAAM,wBAAwB,CACnC,SACA,YACwB;AACxB,MAAI,mCAA4B;AAC9B,WAAO;AAAA,MACL,SAAS,QAAQ,IAAI;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL,SAAS,QAAQ,IAAI;AAAA,IACrB;AAAA,EACF;AACF;;;ACbA,OAAO,OAAO;;;ACNd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMA,IAAM,qBAAiC;AAAA,EAC5C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,UAAU;AAAA,IACR,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,UAAU;AAAA,IACV,kBAAkB;AAAA,EACpB;AAAA,EACA,gBAAgB;AAAA,IACd;AAAA,MACE,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;A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AAI;AAAA,QACvB,4BAA4BA,GAAE,OAAO;AAAA,QACrC,OAAOA,GAAE,OAAgB;AAAA,MAC3B,CAAC;AAAA,IACH;AAEA,QAAI,SAAS,MAAM,GAAG;AACpB,aAAO;AAAA,IACT;AAEA,UAAM,EAAE,4BAA4B,MAAM,IAAI,SAAS;AAEvD,UAAM,gBAAgB,MAAM,kBAAkB,UAAU;AAAA,MACtD;AAAA,MACA,QAAQ,QAAQ;AAAA,MAChB;AAAA,IACF,CAAC;AAED,WAAO,cAAc;AAAA,MACnB,YAAU,OAAO,KAAK,WAAW,EAAE,SAAS,KAAK;AAAA,IACnD;AAAA,EACF,OAAO;AACL,UAAM,QAAQ,MAAM,0BAA0B,UAAU;AAAA,MACtD,MAAM,sBAAsB,MAAM,OAAO;AAAA,MACzC,IAAI,sBAAsB,IAAI,OAAO;AAAA,MACrC;AAAA,IACF,CAAC;AAED,QAAI,MAAM,MAAM,GAAG;AACjB,aAAO;AAAA,IACT;AAEA,UAAM,gBAAgB,MAAM;AAAA,MAC1B;AAAA,MACA,MAAM;AAAA,MACN,mBAAmB;AAAA,QACjB,SAAS,QAAQ;AAAA,QACjB,OAAO,YAAY,IAAI,EAAE;AAAA,QACzB,WAAW,KAAK,YAAY,IAAI,EAAE,MAAM;AAAA,MAC1C,CAAC;AAAA,IACH;AAEA,WAAO,cAAc;AAAA,MACnB,YAAU,OAAO,KAAK,WAAW,EAAE,SAAS,KAAK;AAAA,IACnD;AAAA,EACF;AACF;","names":["z","z"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  TOOL_PARAMS
3
- } from "./chunk-3PYQIEMA.js";
3
+ } from "./chunk-W37JKCLN.js";
4
4
  import {
5
5
  executeFetch
6
- } from "./chunk-JVMJVMWB.js";
6
+ } from "./chunk-HNDMHX4B.js";
7
7
  import {
8
8
  safeParseResponse
9
- } from "./chunk-BFOYXXLG.js";
9
+ } from "./chunk-RAS5DZPQ.js";
10
10
  import {
11
11
  log
12
12
  } from "./chunk-QZCSZB7E.js";
@@ -89,4 +89,4 @@ export {
89
89
  searchSchema,
90
90
  search
91
91
  };
92
- //# sourceMappingURL=chunk-ONGJJBKT.js.map
92
+ //# sourceMappingURL=chunk-MZPHS3IS.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  discoverResources
3
- } from "./chunk-L4U6AJW3.js";
3
+ } from "./chunk-K3WB4R2P.js";
4
4
  import {
5
5
  errorResponse
6
6
  } from "./chunk-7EBJ4BCH.js";
@@ -52,4 +52,4 @@ function resolveDescription(result) {
52
52
  export {
53
53
  resolveOrigin
54
54
  };
55
- //# sourceMappingURL=chunk-2SZ6MZS3.js.map
55
+ //# sourceMappingURL=chunk-O57QVTLM.js.map
@@ -62,6 +62,19 @@ var safeFetchJson = (surface, request, schema, timeout) => {
62
62
  }));
63
63
  }).andThen((data) => safeParse(surface, schema, data));
64
64
  };
65
+ var safeReadResponseText = (surface, response) => {
66
+ return resultFromPromise(
67
+ errorType,
68
+ surface,
69
+ (async () => response.clone().text())(),
70
+ () => ({
71
+ cause: "parse",
72
+ message: "Failed to read response body as text",
73
+ statusCode: response.status,
74
+ contentType: response.headers.get("content-type") ?? "Not specified"
75
+ })
76
+ );
77
+ };
65
78
  var safeParseResponse = (surface, response) => {
66
79
  return resultFromPromise(
67
80
  errorType,
@@ -134,7 +147,8 @@ export {
134
147
  fetchHttpErr,
135
148
  safeFetch,
136
149
  safeFetchJson,
150
+ safeReadResponseText,
137
151
  safeParseResponse,
138
152
  isFetchError
139
153
  };
140
- //# sourceMappingURL=chunk-BFOYXXLG.js.map
154
+ //# sourceMappingURL=chunk-RAS5DZPQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/shared/neverthrow/fetch/index.ts"],"sourcesContent":["import contentType from 'content-type';\nimport { err, ok, resultFromPromise } from '@agentcash/neverthrow';\n\nimport type z from 'zod';\n\nimport type { BaseError, Error } from '@agentcash/neverthrow/types';\nimport type { BaseFetchError, FetchError, ParsedResponse } from './types';\nimport type { JsonObject } from '../json/types';\nimport { safeParse } from '../parse';\n\nconst DEFAULT_USER_FETCH_TIMEOUT = 30_000;\n\nconst IMAGE_TYPES = new Set([\n 'image/png',\n 'image/jpeg',\n 'image/gif',\n 'image/webp',\n 'image/svg+xml',\n 'image/tiff',\n 'image/bmp',\n 'image/ico',\n]);\n\nconst errorType = 'fetch';\n\nexport const fetchErr = (surface: string, error: BaseFetchError) =>\n err(errorType, surface, error);\nexport const fetchOk = <T>(value: T) => ok(value);\n\nexport const fetchHttpErr = (surface: string, response: Response) =>\n fetchErr(surface, {\n cause: 'http' as const,\n statusCode: response.status,\n message: response.statusText,\n response,\n });\n\nexport const safeFetch = (\n surface: string,\n request: Request,\n timeout = DEFAULT_USER_FETCH_TIMEOUT\n) => {\n const signal = AbortSignal.timeout(timeout);\n\n return resultFromPromise(\n errorType,\n surface,\n fetch(request, ...(signal ? [{ signal }] : [])),\n error => {\n if (\n error instanceof DOMException &&\n (error.name === 'TimeoutError' || error.name === 'AbortError')\n ) {\n return {\n cause: 'timeout',\n message: timeout\n ? `Request timed out after ${timeout}ms. You can increase the timeout by passing a larger value in the 'timeout' parameter.`\n : 'Request was aborted',\n } as BaseFetchError;\n }\n\n return {\n cause: 'network',\n message: error instanceof Error ? error.message : 'Network error',\n } as BaseFetchError;\n }\n );\n};\n\nexport const safeFetchJson = <T>(\n surface: string,\n request: Request,\n schema: z.ZodSchema<T>,\n timeout?: number\n) => {\n return safeFetch(surface, request, timeout)\n .andThen(response => {\n if (!response.ok) {\n return fetchHttpErr(surface, response);\n }\n\n return resultFromPromise(errorType, surface, response.json(), () => ({\n cause: 'parse' as const,\n message: 'Could not parse JSON from response',\n statusCode: response.status,\n contentType: response.headers.get('content-type') ?? 'Not specified',\n }));\n })\n .andThen(data => safeParse(surface, schema, data));\n};\n\nexport const safeReadResponseText = (surface: string, response: Response) => {\n // async IIFE so a sync throw from `.clone()` becomes a rejection alongside\n // any `.text()` rejection — `resultFromPromise` captures both.\n return resultFromPromise(\n errorType,\n surface,\n (async () => response.clone().text())(),\n () => ({\n cause: 'parse' as const,\n message: 'Failed to read response body as text',\n statusCode: response.status,\n contentType: response.headers.get('content-type') ?? 'Not specified',\n })\n );\n};\n\nexport const safeParseResponse = (surface: string, response: Response) => {\n return resultFromPromise(\n errorType,\n surface,\n (async (): Promise<ParsedResponse> => {\n const header = response.headers.get('content-type');\n const { type: mimeType } = header\n ? contentType.parse(header)\n : { type: 'application/octet-stream' };\n\n switch (mimeType) {\n case 'application/json':\n return {\n type: 'json' as const,\n data: (await response.json()) as JsonObject,\n };\n case 'application/pdf':\n return {\n type: 'pdf' as const,\n mimeType,\n data: await response.arrayBuffer(),\n };\n case 'application/octet-stream':\n return {\n type: 'octet-stream' as const,\n mimeType,\n data: await response.arrayBuffer(),\n };\n case 'multipart/form-data':\n return { type: 'formData' as const, data: await response.formData() };\n }\n\n if (IMAGE_TYPES.has(mimeType)) {\n return {\n type: 'image' as const,\n mimeType,\n data: await response.arrayBuffer(),\n };\n }\n\n if (mimeType.startsWith('audio/')) {\n return {\n type: 'audio' as const,\n mimeType,\n data: await response.arrayBuffer(),\n };\n }\n\n if (mimeType.startsWith('video/')) {\n return {\n type: 'video' as const,\n mimeType,\n data: await response.arrayBuffer(),\n };\n }\n\n if (mimeType.startsWith('text/')) {\n return { type: 'text' as const, data: await response.text() };\n }\n\n throw new Error(`Unsupported content type: ${header}`);\n })(),\n e => ({\n cause: 'parse' as const,\n message: e instanceof Error ? e.message : 'Could not parse response',\n statusCode: response.status,\n contentType: response.headers.get('content-type') ?? 'Not specified',\n })\n );\n};\n\nexport const isFetchError = (error: Error<BaseError>): error is FetchError => {\n return error.type === errorType;\n};\n"],"mappings":";;;;;;;;;;AAAA,OAAO,iBAAiB;AAUxB,IAAM,6BAA6B;AAEnC,IAAM,cAAc,oBAAI,IAAI;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CA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AY;AAAA,QACnC;AAAA,MACF;AAEA,UAAI,SAAS,WAAW,OAAO,GAAG;AAChC,eAAO,EAAE,MAAM,QAAiB,MAAM,MAAM,SAAS,KAAK,EAAE;AAAA,MAC9D;AAEA,YAAM,IAAI,MAAM,6BAA6B,MAAM,EAAE;AAAA,IACvD,GAAG;AAAA,IACH,QAAM;AAAA,MACJ,OAAO;AAAA,MACP,SAAS,aAAa,QAAQ,EAAE,UAAU;AAAA,MAC1C,YAAY,SAAS;AAAA,MACrB,aAAa,SAAS,QAAQ,IAAI,cAAc,KAAK;AAAA,IACvD;AAAA,EACF;AACF;AAEO,IAAM,eAAe,CAAC,UAAiD;AAC5E,SAAO,MAAM,SAAS;AACxB;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  REQUEST_FETCH_PARAMS,
3
3
  REQUEST_PARAMS
4
- } from "./chunk-3PYQIEMA.js";
4
+ } from "./chunk-W37JKCLN.js";
5
5
  import {
6
6
  RequestMethod
7
7
  } from "./chunk-LNJIXYCU.js";
@@ -30,7 +30,12 @@ var fetchShape = {
30
30
  paymentNetwork: z.enum(paymentNetworks).optional().describe(REQUEST_FETCH_PARAMS.paymentNetwork),
31
31
  paymentProtocol: z.enum(paymentProtocols).optional().describe(REQUEST_FETCH_PARAMS.paymentProtocol),
32
32
  maxAmount: z.number().positive().optional().describe(REQUEST_FETCH_PARAMS.maxAmount),
33
- timeout: z.number().int().positive().optional().describe(REQUEST_PARAMS.timeout)
33
+ timeout: z.number().int().positive().optional().describe(REQUEST_PARAMS.timeout),
34
+ stream: z.boolean().optional().describe(REQUEST_FETCH_PARAMS.stream),
35
+ channelId: z.string().regex(
36
+ /^0x[0-9a-fA-F]{64}$/,
37
+ "channelId must be a 0x-prefixed 32-byte hex string"
38
+ ).optional().describe(REQUEST_FETCH_PARAMS.channelId)
34
39
  };
35
40
 
36
41
  export {
@@ -40,4 +45,4 @@ export {
40
45
  paymentProtocols,
41
46
  fetchShape
42
47
  };
43
- //# sourceMappingURL=chunk-7KT6UCTT.js.map
48
+ //# sourceMappingURL=chunk-SLTRGQ7W.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shared/request/schemas/core.ts"],"sourcesContent":["import z from 'zod';\n\nimport { REQUEST_PARAMS, REQUEST_FETCH_PARAMS } from '@/shared/descriptions';\nimport { PaymentProtocol } from '@/shared/protocols/types';\nimport { Network } from '@agentcash/networks';\nimport { zodUrl } from '@/shared/url';\n\nimport { RequestMethod } from '../types';\n\nexport const requestMethodValues: readonly RequestMethod[] =\n Object.values(RequestMethod);\n\nconst methodSchema = z\n .enum(RequestMethod)\n .optional()\n .default(RequestMethod.GET)\n .describe(REQUEST_PARAMS.method);\n\nexport const coreRequestSchema = z.object({\n url: zodUrl.describe(REQUEST_PARAMS.url),\n method: methodSchema,\n});\n\nexport const paymentNetworks: Network[] = [\n Network.BASE,\n Network.SOLANA,\n Network.TEMPO,\n];\n\nexport const paymentProtocols: PaymentProtocol[] = [\n PaymentProtocol.X402,\n PaymentProtocol.MPP,\n];\n\nexport const fetchShape = {\n paymentNetwork: z\n .enum(paymentNetworks)\n .optional()\n .describe(REQUEST_FETCH_PARAMS.paymentNetwork),\n paymentProtocol: z\n .enum(paymentProtocols)\n .optional()\n .describe(REQUEST_FETCH_PARAMS.paymentProtocol),\n maxAmount: z\n .number()\n .positive()\n .optional()\n .describe(REQUEST_FETCH_PARAMS.maxAmount),\n timeout: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(REQUEST_PARAMS.timeout),\n};\n"],"mappings":";;;;;;;;;;;;AAAA,OAAO,OAAO;AASP,IAAM,sBACX,OAAO,OAAO,aAAa;AAE7B,IAAM,eAAe,EAClB,KAAK,aAAa,EAClB,SAAS,EACT,uBAAyB,EACzB,SAAS,eAAe,MAAM;AAE1B,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,KAAK,OAAO,SAAS,eAAe,GAAG;AAAA,EACvC,QAAQ;AACV,CAAC;AAEM,IAAM,kBAA6B;AAAA;AAAA;AAAA;AAI1C;AAEO,IAAM,mBAAsC;AAAA;AAAA;AAGnD;AAEO,IAAM,aAAa;AAAA,EACxB,gBAAgB,EACb,KAAK,eAAe,EACpB,SAAS,EACT,SAAS,qBAAqB,cAAc;AAAA,EAC/C,iBAAiB,EACd,KAAK,gBAAgB,EACrB,SAAS,EACT,SAAS,qBAAqB,eAAe;AAAA,EAChD,WAAW,EACR,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,qBAAqB,SAAS;AAAA,EAC1C,SAAS,EACN,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,EACT,SAAS,eAAe,OAAO;AACpC;","names":[]}
1
+ {"version":3,"sources":["../../src/shared/request/schemas/core.ts"],"sourcesContent":["import z from 'zod';\n\nimport { REQUEST_PARAMS, REQUEST_FETCH_PARAMS } from '@/shared/descriptions';\nimport { PaymentProtocol } from '@/shared/protocols/types';\nimport { Network } from '@agentcash/networks';\nimport { zodUrl } from '@/shared/url';\n\nimport { RequestMethod } from '../types';\n\nexport const requestMethodValues: readonly RequestMethod[] =\n Object.values(RequestMethod);\n\nconst methodSchema = z\n .enum(RequestMethod)\n .optional()\n .default(RequestMethod.GET)\n .describe(REQUEST_PARAMS.method);\n\nexport const coreRequestSchema = z.object({\n url: zodUrl.describe(REQUEST_PARAMS.url),\n method: methodSchema,\n});\n\nexport const paymentNetworks: Network[] = [\n Network.BASE,\n Network.SOLANA,\n Network.TEMPO,\n];\n\nexport const paymentProtocols: PaymentProtocol[] = [\n PaymentProtocol.X402,\n PaymentProtocol.MPP,\n];\n\nexport const fetchShape = {\n paymentNetwork: z\n .enum(paymentNetworks)\n .optional()\n .describe(REQUEST_FETCH_PARAMS.paymentNetwork),\n paymentProtocol: z\n .enum(paymentProtocols)\n .optional()\n .describe(REQUEST_FETCH_PARAMS.paymentProtocol),\n maxAmount: z\n .number()\n .positive()\n .optional()\n .describe(REQUEST_FETCH_PARAMS.maxAmount),\n timeout: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(REQUEST_PARAMS.timeout),\n stream: z.boolean().optional().describe(REQUEST_FETCH_PARAMS.stream),\n channelId: z\n .string()\n .regex(\n /^0x[0-9a-fA-F]{64}$/,\n 'channelId must be a 0x-prefixed 32-byte hex string'\n )\n .optional()\n .describe(REQUEST_FETCH_PARAMS.channelId),\n};\n"],"mappings":";;;;;;;;;;;;AAAA,OAAO,OAAO;AASP,IAAM,sBACX,OAAO,OAAO,aAAa;AAE7B,IAAM,eAAe,EAClB,KAAK,aAAa,EAClB,SAAS,EACT,uBAAyB,EACzB,SAAS,eAAe,MAAM;AAE1B,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,KAAK,OAAO,SAAS,eAAe,GAAG;AAAA,EACvC,QAAQ;AACV,CAAC;AAEM,IAAM,kBAA6B;AAAA;AAAA;AAAA;AAI1C;AAEO,IAAM,mBAAsC;AAAA;AAAA;AAGnD;AAEO,IAAM,aAAa;AAAA,EACxB,gBAAgB,EACb,KAAK,eAAe,EACpB,SAAS,EACT,SAAS,qBAAqB,cAAc;AAAA,EAC/C,iBAAiB,EACd,KAAK,gBAAgB,EACrB,SAAS,EACT,SAAS,qBAAqB,eAAe;AAAA,EAChD,WAAW,EACR,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,qBAAqB,SAAS;AAAA,EAC1C,SAAS,EACN,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,EACT,SAAS,eAAe,OAAO;AAAA,EAClC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,qBAAqB,MAAM;AAAA,EACnE,WAAW,EACR,OAAO,EACP;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,SAAS,EACT,SAAS,qBAAqB,SAAS;AAC5C;","names":[]}
@@ -0,0 +1,146 @@
1
+ import {
2
+ createTempoClient,
3
+ mppErr,
4
+ mppOk,
5
+ mppResultFromPromise,
6
+ mppResultFromThrowable,
7
+ safeGetMppChallenge,
8
+ sessionCloseFailedErr
9
+ } from "./chunk-FBGNOXFP.js";
10
+ import {
11
+ safeFetch,
12
+ safeReadResponseText
13
+ } from "./chunk-RAS5DZPQ.js";
14
+
15
+ // src/operations/sessions/close.ts
16
+ import { Mppx, tempo as tempoMethod } from "mppx/client";
17
+ import { Session } from "mppx/tempo";
18
+ var DEFAULT_ESCROW_CONTRACT = "0x33b901018174DDabE4841042ab76ba85D4e24f25";
19
+ async function closeMppSession(input, options) {
20
+ const { surface, wallets } = options;
21
+ const { channelId, url, cumulativeAmountRaw } = input;
22
+ const probeResult = await safeFetch(
23
+ surface,
24
+ new Request(url, { method: "POST" })
25
+ );
26
+ if (probeResult.isErr()) {
27
+ return mppErr(
28
+ surface,
29
+ sessionCloseFailedErr(
30
+ probeResult.error.message,
31
+ `Failed to probe ${url} for a session challenge`
32
+ )
33
+ );
34
+ }
35
+ const probeResponse = probeResult.value;
36
+ if (probeResponse.status !== 402) {
37
+ return mppErr(surface, {
38
+ cause: "mpp_session_close_no_challenge",
39
+ message: `Expected a 402 session challenge from ${url}, received ${probeResponse.status} ${probeResponse.statusText}. The endpoint may not be MPP-protected or the channel has already been closed.`
40
+ });
41
+ }
42
+ const challengeResult = safeGetMppChallenge(surface, probeResponse);
43
+ if (challengeResult.isErr()) {
44
+ return challengeResult;
45
+ }
46
+ const challenge = challengeResult.value;
47
+ if (challenge.intent !== "session") {
48
+ return mppErr(surface, {
49
+ cause: "mpp_session_close_no_challenge",
50
+ message: `${url} returned a ${challenge.method}:${challenge.intent} challenge, not a session challenge.`
51
+ });
52
+ }
53
+ const methodDetails = challenge.request.methodDetails;
54
+ const escrowContract = methodDetails?.escrowContract ?? DEFAULT_ESCROW_CONTRACT;
55
+ const cumulativeResult = await resolveCloseCumulative({
56
+ surface,
57
+ channelId,
58
+ escrowContract,
59
+ cumulativeAmountRaw
60
+ });
61
+ if (cumulativeResult.isErr()) {
62
+ return cumulativeResult;
63
+ }
64
+ const cumulativeRaw = cumulativeResult.value;
65
+ const mppx = Mppx.create({
66
+ polyfill: false,
67
+ methods: [
68
+ tempoMethod({ account: wallets.evm, getClient: createTempoClient })
69
+ ]
70
+ });
71
+ const credentialResult = await mppResultFromPromise(
72
+ surface,
73
+ mppx.createCredential(probeResponse, {
74
+ action: "close",
75
+ channelId,
76
+ cumulativeAmountRaw: cumulativeRaw
77
+ }),
78
+ (e) => sessionCloseFailedErr(e, "Failed to sign close credential")
79
+ );
80
+ if (credentialResult.isErr()) {
81
+ return credentialResult;
82
+ }
83
+ const closeResult = await safeFetch(
84
+ surface,
85
+ new Request(url, {
86
+ method: "POST",
87
+ headers: { Authorization: credentialResult.value }
88
+ })
89
+ );
90
+ if (closeResult.isErr()) {
91
+ return mppErr(
92
+ surface,
93
+ sessionCloseFailedErr(
94
+ closeResult.error.message,
95
+ `Close POST to ${url} failed`
96
+ )
97
+ );
98
+ }
99
+ const closeResponse = closeResult.value;
100
+ if (!closeResponse.ok) {
101
+ const body = await safeReadResponseText(surface, closeResponse).unwrapOr(
102
+ ""
103
+ );
104
+ const detail = body ? `: ${body}` : "";
105
+ return mppErr(
106
+ surface,
107
+ sessionCloseFailedErr(
108
+ `Server rejected close credential with ${closeResponse.status} ${closeResponse.statusText}${detail}. The cumulative-amount may be below the server's voucher state \u2014 retry with --cumulative-amount-raw set to the server's expected value.`
109
+ )
110
+ );
111
+ }
112
+ const receiptHeader = closeResponse.headers.get("Payment-Receipt");
113
+ const receipt = receiptHeader ? Session.Receipt.deserializeSessionReceipt(receiptHeader) : null;
114
+ return mppOk({
115
+ channelId,
116
+ cumulativeAmount: receipt?.spent ?? cumulativeRaw,
117
+ ...receipt?.txHash ? { transactionHash: receipt.txHash } : {}
118
+ });
119
+ }
120
+ async function resolveCloseCumulative(args) {
121
+ const { surface, channelId, escrowContract, cumulativeAmountRaw } = args;
122
+ if (cumulativeAmountRaw !== void 0) {
123
+ return mppResultFromThrowable(
124
+ surface,
125
+ () => BigInt(cumulativeAmountRaw).toString(),
126
+ (e) => sessionCloseFailedErr(e, "Invalid cumulativeAmountRaw")
127
+ );
128
+ }
129
+ return mppResultFromPromise(
130
+ surface,
131
+ Session.Chain.getOnChainChannel(
132
+ createTempoClient(),
133
+ escrowContract,
134
+ channelId
135
+ ).then((onChain) => onChain.settled.toString()),
136
+ (e) => sessionCloseFailedErr(
137
+ e,
138
+ `Failed to read on-chain channel state for ${channelId}`
139
+ )
140
+ );
141
+ }
142
+
143
+ export {
144
+ closeMppSession
145
+ };
146
+ //# sourceMappingURL=chunk-TX7S7QGG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/operations/sessions/close.ts"],"sourcesContent":["import type { Address, Hex } from 'viem';\n\nimport { Mppx, tempo as tempoMethod } from 'mppx/client';\nimport { Session } from 'mppx/tempo';\n\nimport { safeFetch, safeReadResponseText } from '@/shared/neverthrow/fetch';\nimport {\n createTempoClient,\n mppErr,\n mppOk,\n mppResultFromPromise,\n mppResultFromThrowable,\n safeGetMppChallenge,\n sessionCloseFailedErr,\n} from '@/shared/protocols/mpp';\n\nimport type { GlobalFlags } from '@/types';\nimport type { Wallets } from '@/wallet';\n\nconst DEFAULT_ESCROW_CONTRACT: Address =\n '0x33b901018174DDabE4841042ab76ba85D4e24f25';\n\nexport interface CloseSessionInput {\n channelId: Hex;\n url: string;\n cumulativeAmountRaw?: string;\n}\n\nexport interface CloseSessionOptions {\n surface: string;\n wallets: Wallets;\n flags: GlobalFlags;\n}\n\nexport interface CloseSessionResult {\n channelId: Hex;\n cumulativeAmount: string;\n transactionHash?: string;\n}\n\nexport async function closeMppSession(\n input: CloseSessionInput,\n options: CloseSessionOptions\n) {\n const { surface, wallets } = options;\n const { channelId, url, cumulativeAmountRaw } = input;\n\n const probeResult = await safeFetch(\n surface,\n new Request(url, { method: 'POST' })\n );\n if (probeResult.isErr()) {\n return mppErr(\n surface,\n sessionCloseFailedErr(\n probeResult.error.message,\n `Failed to probe ${url} for a session challenge`\n )\n );\n }\n const probeResponse = probeResult.value;\n\n if (probeResponse.status !== 402) {\n return mppErr(surface, {\n cause: 'mpp_session_close_no_challenge',\n message: `Expected a 402 session challenge from ${url}, received ${probeResponse.status} ${probeResponse.statusText}. The endpoint may not be MPP-protected or the channel has already been closed.`,\n });\n }\n\n const challengeResult = safeGetMppChallenge(surface, probeResponse);\n if (challengeResult.isErr()) {\n return challengeResult;\n }\n const challenge = challengeResult.value;\n\n if (challenge.intent !== 'session') {\n return mppErr(surface, {\n cause: 'mpp_session_close_no_challenge',\n message: `${url} returned a ${challenge.method}:${challenge.intent} challenge, not a session challenge.`,\n });\n }\n\n const methodDetails = challenge.request.methodDetails as\n | { escrowContract?: string }\n | undefined;\n const escrowContract = (methodDetails?.escrowContract ??\n DEFAULT_ESCROW_CONTRACT) as Address;\n\n const cumulativeResult = await resolveCloseCumulative({\n surface,\n channelId,\n escrowContract,\n cumulativeAmountRaw,\n });\n if (cumulativeResult.isErr()) {\n return cumulativeResult;\n }\n const cumulativeRaw = cumulativeResult.value;\n\n const mppx = Mppx.create({\n polyfill: false,\n methods: [\n tempoMethod({ account: wallets.evm, getClient: createTempoClient }),\n ],\n });\n\n const credentialResult = await mppResultFromPromise(\n surface,\n mppx.createCredential(probeResponse, {\n action: 'close',\n channelId,\n cumulativeAmountRaw: cumulativeRaw,\n }),\n e => sessionCloseFailedErr(e, 'Failed to sign close credential')\n );\n if (credentialResult.isErr()) {\n return credentialResult;\n }\n\n const closeResult = await safeFetch(\n surface,\n new Request(url, {\n method: 'POST',\n headers: { Authorization: credentialResult.value },\n })\n );\n if (closeResult.isErr()) {\n return mppErr(\n surface,\n sessionCloseFailedErr(\n closeResult.error.message,\n `Close POST to ${url} failed`\n )\n );\n }\n const closeResponse = closeResult.value;\n\n if (!closeResponse.ok) {\n const body = await safeReadResponseText(surface, closeResponse).unwrapOr(\n ''\n );\n const detail = body ? `: ${body}` : '';\n return mppErr(\n surface,\n sessionCloseFailedErr(\n `Server rejected close credential with ${closeResponse.status} ${closeResponse.statusText}${detail}. The cumulative-amount may be below the server's voucher state — retry with --cumulative-amount-raw set to the server's expected value.`\n )\n );\n }\n\n const receiptHeader = closeResponse.headers.get('Payment-Receipt');\n const receipt = receiptHeader\n ? Session.Receipt.deserializeSessionReceipt(receiptHeader)\n : null;\n\n return mppOk<CloseSessionResult>({\n channelId,\n cumulativeAmount: receipt?.spent ?? cumulativeRaw,\n ...(receipt?.txHash ? { transactionHash: receipt.txHash } : {}),\n });\n}\n\nasync function resolveCloseCumulative(args: {\n surface: string;\n channelId: Hex;\n escrowContract: Address;\n cumulativeAmountRaw: string | undefined;\n}) {\n const { surface, channelId, escrowContract, cumulativeAmountRaw } = args;\n\n if (cumulativeAmountRaw !== undefined) {\n return mppResultFromThrowable(\n surface,\n () => BigInt(cumulativeAmountRaw).toString(),\n e => sessionCloseFailedErr(e, 'Invalid cumulativeAmountRaw')\n );\n }\n\n return mppResultFromPromise(\n surface,\n Session.Chain.getOnChainChannel(\n createTempoClient(),\n escrowContract,\n channelId\n ).then(onChain => onChain.settled.toString()),\n e =>\n sessionCloseFailedErr(\n e,\n `Failed to read on-chain channel state for ${channelId}`\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA,SAAS,MAAM,SAAS,mBAAmB;AAC3C,SAAS,eAAe;AAgBxB,IAAM,0BACJ;AAoBF,eAAsB,gBACpB,OACA,SACA;AACA,QAAM,EAAE,SAAS,QAAQ,IAAI;AAC7B,QAAM,EAAE,WAAW,KAAK,oBAAoB,IAAI;AAEhD,QAAM,cAAc,MAAM;AAAA,IACxB;AAAA,IACA,IAAI,QAAQ,KAAK,EAAE,QAAQ,OAAO,CAAC;AAAA,EACrC;AACA,MAAI,YAAY,MAAM,GAAG;AACvB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,YAAY,MAAM;AAAA,QAClB,mBAAmB,GAAG;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACA,QAAM,gBAAgB,YAAY;AAElC,MAAI,cAAc,WAAW,KAAK;AAChC,WAAO,OAAO,SAAS;AAAA,MACrB,OAAO;AA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AA,MACL;AAAA,MACA;AAAA,QACE,YAAY,MAAM;AAAA,QAClB,iBAAiB,GAAG;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACA,QAAM,gBAAgB,YAAY;AAElC,MAAI,CAAC,cAAc,IAAI;AACrB,UAAM,OAAO,MAAM,qBAAqB,SAAS,aAAa,EAAE;AAAA,MAC9D;AAAA,IACF;AACA,UAAM,SAAS,OAAO,KAAK,IAAI,KAAK;AACpC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,yCAAyC,cAAc,MAAM,IAAI,cAAc,UAAU,GAAG,MAAM;AAAA,MACpG;AAAA,IACF;AAAA,EACF;AAEA,QAAM,gBAAgB,cAAc,QAAQ,IAAI,iBAAiB;AACjE,QAAM,UAAU,gBACZ,QAAQ,QAAQ,0BAA0B,aAAa,IACvD;AAEJ,SAAO,MAA0B;AAAA,IAC/B;AAAA,IACA,kBAAkB,SAAS,SAAS;AAAA,IACpC,GAAI,SAAS,SAAS,EAAE,iBAAiB,QAAQ,OAAO,IAAI,CAAC;AAAA,EAC/D,CAAC;AACH;AAEA,eAAe,uBAAuB,MAKnC;AACD,QAAM,EAAE,SAAS,WAAW,gBAAgB,oBAAoB,IAAI;AAEpE,MAAI,wBAAwB,QAAW;AACrC,WAAO;AAAA,MACL;AAAA,MACA,MAAM,OAAO,mBAAmB,EAAE,SAAS;AAAA,MAC3C,OAAK,sBAAsB,GAAG,6BAA6B;AAAA,IAC7D;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,MAAM;AAAA,MACZ,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,IACF,EAAE,KAAK,aAAW,QAAQ,QAAQ,SAAS,CAAC;AAAA,IAC5C,OACE;AAAA,MACE;AAAA,MACA,6CAA6C,SAAS;AAAA,IACxD;AAAA,EACJ;AACF;","names":[]}
@@ -4,7 +4,7 @@ import { dirname, join } from "path";
4
4
  import { fileURLToPath } from "url";
5
5
  function getVersion() {
6
6
  if (true) {
7
- return "0.14.4";
7
+ return "0.15.0";
8
8
  }
9
9
  const __dirname2 = dirname(fileURLToPath(import.meta.url));
10
10
  const pkg = JSON.parse(
@@ -23,4 +23,4 @@ export {
23
23
  MCP_VERSION,
24
24
  INSTALL_PACKAGE_SPECIFIER
25
25
  };
26
- //# sourceMappingURL=chunk-QOMU3YLK.js.map
26
+ //# sourceMappingURL=chunk-ULB5PPKW.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  MCP_VERSION
3
- } from "./chunk-QOMU3YLK.js";
3
+ } from "./chunk-ULB5PPKW.js";
4
4
  import {
5
5
  safeFetchJson
6
- } from "./chunk-BFOYXXLG.js";
6
+ } from "./chunk-RAS5DZPQ.js";
7
7
  import {
8
8
  getBaseUrl
9
9
  } from "./chunk-U6FRXL3X.js";
@@ -51,4 +51,4 @@ async function submitErrorReport(surface, input, address, dev) {
51
51
  export {
52
52
  submitErrorReport
53
53
  };
54
- //# sourceMappingURL=chunk-WRNDLZ3K.js.map
54
+ //# sourceMappingURL=chunk-VGKAPM5S.js.map
@@ -39,6 +39,22 @@ var ORIGIN_METADATA = {
39
39
  ["https://stablemerch.dev" /* StableMerch */]: {
40
40
  title: "StableMerch",
41
41
  description: "Create shirts and mugs with custom images and have them shipped to your address."
42
+ },
43
+ ["https://stablevoice.dev" /* StableVoice */]: {
44
+ title: "StableVoice",
45
+ description: "Text-to-speech with 20+ bundled voices, custom voice cloning, multi-language support (23 languages), mp3/wav output"
46
+ },
47
+ ["https://stabletube.dev" /* StableTube */]: {
48
+ title: "StableTube",
49
+ description: "YouTube video downloads \u2014 POST a URL, get a direct CDN download link (expires ~6h)"
50
+ },
51
+ ["https://stablekey.dev" /* StableKey */]: {
52
+ title: "StableKey",
53
+ description: "VFX-grade neural green-screen unmixing (CorridorKey) \u2014 submit a green-screen plate, get alpha + foreground + RGBA outputs"
54
+ },
55
+ ["https://stablememes.dev" /* StableMemes */]: {
56
+ title: "StableMemes",
57
+ description: "Generate memes \u2014 caption templates, search 1M+ memes, auto-caption, AI meme generation"
42
58
  }
43
59
  };
44
60
  var PRIMARY_ORIGINS = [
@@ -47,7 +63,11 @@ var PRIMARY_ORIGINS = [
47
63
  "https://stablestudio.dev" /* StableStudio */,
48
64
  "https://stableupload.dev" /* StableUpload */,
49
65
  "https://stableemail.dev" /* StableEmail */,
50
- "https://stablemerch.dev" /* StableMerch */
66
+ "https://stablemerch.dev" /* StableMerch */,
67
+ "https://stablevoice.dev" /* StableVoice */,
68
+ "https://stabletube.dev" /* StableTube */,
69
+ "https://stablekey.dev" /* StableKey */,
70
+ "https://stablememes.dev" /* StableMemes */
51
71
  ];
52
72
  var DESCRIPTIONS = {
53
73
  bridge: {
@@ -133,6 +153,12 @@ Set broad=true to widen the search to include newer, unvetted tools that may not
133
153
  getSettings: {
134
154
  mcp: `Get current user settings. Returns persisted values from ~/.agentcash/settings.json with defaults applied.`,
135
155
  cli: `Get current user settings from ~/.agentcash/settings.json, with defaults applied.`
156
+ },
157
+ closeSession: {
158
+ mcp: `Close an MPP \`tempo:session\` payment channel. Pass the channelId surfaced in a prior fetch's paymentInfo together with the same URL you originally fetched. Signs a close credential with the on-chain settled cumulative amount and POSTs it to the server, returning the on-chain settlement transaction hash when available. Use this when you want to finalize a channel rather than leaving it open for the server to settle on its own schedule.`,
159
+ cli: `Close an MPP session payment channel. Provide the channelId (printed in a prior fetch's paymentInfo) and the endpoint URL the channel was opened against. Reads on-chain channel state for the cumulative settled amount, signs a close credential, and POSTs it to the server.`,
160
+ epilogue: `agentcash sessions close 0xabc... --url https://example.dev/api/stream
161
+ Pass --cumulative-amount-raw <atomic-units> only when the server reports vouchers above the on-chain cumulative.`
136
162
  }
137
163
  };
138
164
  var WORKFLOW = [
@@ -173,7 +199,9 @@ var REQUEST_FETCH_PARAMS = {
173
199
  ...REQUEST_PARAMS,
174
200
  paymentProtocol: "Payment protocol to use when payment is required. If not specified, the payment protocol will be auto-detected.",
175
201
  paymentNetwork: "Chain to use for SIWX and payment when applicable. If not specified, the network will be auto-detected.",
176
- maxAmount: "Maximum amount (in USD) to pay per request. Aborts if the endpoint requests more. Defaults to $5. Pass a higher value for known-expensive endpoints."
202
+ maxAmount: "Maximum amount (in USD) to pay per request. Aborts if the endpoint requests more. Defaults to $5. Pass a higher value for known-expensive endpoints.",
203
+ stream: "Escape hatch for streaming MPP session endpoints. Typically unnecessary \u2014 a correctly configured server advertises `streaming: true` in its 402 challenge and the signer handles it automatically. Only pass this when the response is actually a stream AND the server fails to advertise it; otherwise long streams may stall once the initial deposit is exhausted.",
204
+ channelId: "Reuse an existing MPP `tempo:session` payment channel instead of opening a new one. Pass the `channelId` surfaced in a prior fetch's paymentInfo. The channel must still have positive on-chain deposit and not be finalized; if it cannot be recovered, the request fails fast rather than silently opening a new channel. 0x-prefixed 32-byte hex string. Ignored by x402 (non-session) endpoints."
177
205
  };
178
206
  var TOOL_PARAMS = {
179
207
  bridge: {
@@ -225,6 +253,16 @@ var TOOL_PARAMS = {
225
253
  url: "The origin URL to discover endpoints on (e.g. https://stableenrich.dev)",
226
254
  includeGuidance: "Request the origin's usage guidance. true=always include, false=never include, omit=auto (included when compact). Guidance explains how to compose multiple endpoints and covers edge cases."
227
255
  },
256
+ closeSession: {
257
+ channelId: "The payment-channel id to close (the `channelId` field from a prior fetch's paymentInfo).",
258
+ url: "The endpoint URL the channel was opened against (the same URL passed to the original fetch).",
259
+ cumulativeAmountRaw: 'Optional override for the cumulative amount the close credential attests to, in raw atomic units (e.g. "12345" = 0.012345 USDC at 6 decimals). Defaults to the on-chain settled amount. Provide this only when the server has accepted vouchers above the on-chain cumulative.',
260
+ output: {
261
+ channelId: "The closed channel id",
262
+ cumulativeAmount: "The cumulative amount (raw atomic units) the channel was settled at",
263
+ transactionHash: "Settlement transaction hash, when the server returns one in the Payment-Receipt header"
264
+ }
265
+ },
228
266
  reportError: {
229
267
  tool: "MCP tool name",
230
268
  resource: "Resource URL",
@@ -248,4 +286,4 @@ export {
248
286
  REQUEST_FETCH_PARAMS,
249
287
  TOOL_PARAMS
250
288
  };
251
- //# sourceMappingURL=chunk-3PYQIEMA.js.map
289
+ //# sourceMappingURL=chunk-W37JKCLN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/shared/descriptions.ts"],"sourcesContent":["/**\n * Single source of truth for all LLM-facing text in the MCP package.\n *\n * `DESCRIPTIONS` covers every tool with both an `mcp` variant (detailed,\n * AI-audience) and a `cli` variant (concise, human-readable for --help).\n * `serverInstructions` is shared across both surfaces.\n *\n * Additional exports cover parameter/output schema descriptions, origin\n * metadata, and prompt content — all LLM-facing text in one place.\n */\n\nimport type { UserOrigin } from './user-origins';\nimport { Origin } from './origins';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Origin metadata (used for MCP resource registration descriptions)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const ORIGIN_METADATA: Record<\n string,\n { title: string; description: string }\n> = {\n [Origin.StableEnrich]: {\n title: 'StableEnrich',\n description:\n 'People/org search, Google Maps, Exa web search, LinkedIn data, Firecrawl scrape, WhitePages, email enrichment',\n },\n [Origin.StableSocial]: {\n title: 'StableSocial',\n description: 'Social media data for TikTok, Instagram, Facebook, Reddit',\n },\n [Origin.StableStudio]: {\n title: 'StableStudio',\n description: 'Generate and edit images and videos',\n },\n [Origin.StableUpload]: {\n title: 'StableUpload',\n description: 'Pay to upload files, get a permanent download URL.',\n },\n [Origin.StableEmail]: {\n title: 'StableEmail',\n description: 'Send emails',\n },\n [Origin.X402Scan]: {\n title: 'X402 Scan',\n description: 'x402 protocol explorer',\n },\n [Origin.Shirt]: {\n title: 'Shirt',\n description: 'Shirt.sh',\n },\n [Origin.X402Puppet]: {\n title: 'X402 Puppet',\n description: 'Browser automation',\n },\n [Origin.X402Facilitator]: {\n title: 'X402 Facilitator',\n description: 'Payment facilitation',\n },\n [Origin.StableMerch]: {\n title: 'StableMerch',\n description:\n 'Create shirts and mugs with custom images and have them shipped to your address.',\n },\n [Origin.StableVoice]: {\n title: 'StableVoice',\n description:\n 'Text-to-speech with 20+ bundled voices, custom voice cloning, multi-language support (23 languages), mp3/wav output',\n },\n [Origin.StableTube]: {\n title: 'StableTube',\n description:\n 'YouTube video downloads — POST a URL, get a direct CDN download link (expires ~6h)',\n },\n [Origin.StableKey]: {\n title: 'StableKey',\n description:\n 'VFX-grade neural green-screen unmixing (CorridorKey) — submit a green-screen plate, get alpha + foreground + RGBA outputs',\n },\n [Origin.StableMemes]: {\n title: 'StableMemes',\n description:\n 'Generate memes — caption templates, search 1M+ memes, auto-caption, AI meme generation',\n },\n};\n\nexport const PRIMARY_ORIGINS = [\n Origin.StableEnrich,\n Origin.StableSocial,\n Origin.StableStudio,\n Origin.StableUpload,\n Origin.StableEmail,\n Origin.StableMerch,\n Origin.StableVoice,\n Origin.StableTube,\n Origin.StableKey,\n Origin.StableMemes,\n] as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Tool descriptions — { mcp, cli } per tool + shared serverInstructions\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const DESCRIPTIONS = {\n bridge: {\n toolNames: {\n cli: 'bridge',\n mcp: 'bridge',\n },\n title: 'Bridge Between Networks',\n mcp: `Bridge USDC between supported networks using the current wallet. Requires a source network, destination network, and amount. Use this when funds are on one supported network and the user needs them moved to another. Bridging is subject to fees.`,\n cli: `Bridge USDC between supported networks using the current wallet. Requires --from, --to, and --amount. Bridging is subject to fees.`,\n },\n\n getBalance: {\n mcp: `Get your total USDC balance across all supported networks. Auto-creates the wallet on first use (~/.agentcash/wallet.json). Use this before paid API calls to confirm you have funds available.`,\n cli: `Get your total USDC balance across all supported networks. Creates the wallet on first use (~/.agentcash/wallet.json). Use this before paid API calls to confirm you have funds available.`,\n },\n\n fetch: {\n mcp: `HTTP fetch with automatic authentication and payment handling. Makes the request, retries with SIGN-IN-WITH-X when the route exposes a SIWX challenge, and only pays if the route still returns 402. Returns response data along with payment details (price, tx hash) if a payment was made.\\n\\nFor endpoints you haven't called before in this session, you MUST call check_endpoint_schema first to confirm the request body schema. Skipping this causes 400 errors from wrong field names.`,\n cli: `HTTP fetch with automatic authentication and payment handling. If the endpoint returns 402, agentcash attempts authentication first and only falls back to payment if the route still requires it. Run 'check <url>' first to confirm the request body schema; skipping this causes 400 errors from wrong field names.`,\n epilogue: `Workflow: check <url> → fetch <url> -m POST -b '{\"field\":\"value\"}'\\nAuth mode is advisory only; fetch handles both SIWX and paid routes.`,\n },\n\n fetchWithAuth: {\n mcp: `Deprecated alias for fetch. Uses the same unified flow: probe the route, attempt SIWX when available, and only pay if the route still returns 402.\\n\\nFor new integrations, prefer fetch.`,\n cli: `Deprecated alias for fetch. Uses the same unified auth-and-payment flow, but new integrations should call 'fetch' directly.`,\n epilogue: `Deprecated: use agentcash fetch <url>. This alias is kept for compatibility.`,\n },\n\n listAccounts: {\n mcp: `List wallet accounts for each supported network. Returns the network, address, balance, and deposit link for every supported network so you can see where to fund the wallet. Auto-creates the wallet on first use (~/.agentcash/wallet.json). If onboardingCta is present, show its message to the user — it means they haven't onboarded yet and need to either visit the onboard link or deposit directly.`,\n cli: `List wallet accounts for each supported network, including network, address, balance, and deposit link. Creates the wallet on first use (~/.agentcash/wallet.json). Use this when you need the per-network funding addresses and deposit links.`,\n },\n\n getWalletInfo: {\n mcp: `Legacy combined wallet view. Returns both the total balance and the per-network account list. Prefer calling get_balance for available funds and list_accounts when you need network-specific addresses or deposit links.`,\n cli: `Legacy combined wallet view. Returns both the total balance and the per-network account list. Prefer 'balance' for available funds and 'accounts' for network-specific addresses or deposit links.`,\n },\n\n checkEndpointSchema: {\n mcp: [\n `Get the input/output schema and auth mode (paid or SIWX) for a single endpoint.`,\n `Call this to see exactly what fields the request body expects and what the response contains.`,\n `Returns the schema from the origin's OpenAPI spec. Optionally pass sample_input_body to probe the endpoint live (without payment) for an exact price quote — do this when pricing is dynamic (range-based or variable), or when you're unsure about the input schema. Treat auth mode as advisory: fetch handles both SIWX and paid routes.`,\n ].join('\\n\\n'),\n cli: `Get the input/output schema and auth mode (paid or SIWX) for an endpoint. Returns exact field names from the OpenAPI spec — call this before 'fetch' to avoid 400 errors. Pass --body to probe the endpoint live for an exact price quote when pricing is dynamic or unclear.`,\n epilogue: `Auth mode is advisory:\\n paid → agentcash fetch <url>\\n SIWX → agentcash fetch <url>`,\n },\n\n discoverApiEndpoints: {\n mcp: [\n `List available endpoints at an API origin. Returns endpoint URLs with descriptions of what each does and the auth mode for each (paid or SIWX). Works with any origin, not just the registered ones.`,\n `Call this when you need to see what routes are available at an origin — whether it's one of the registered origins or any other origin you've identified as useful. Treat the auth mode as guidance for what the route may require; fetch handles both SIWX and payment.`,\n `The response always indicates whether guidance is available. Guidance is documentation published by the API provider explaining how endpoints work together, edge cases, and usage tips. compact guidance is included automatically; set include_guidance=true to force-include full usage documentation when you need to compose two or more endpoints or need clarification on how the origin works.`,\n ].join('\\n\\n'),\n cli: `List available endpoints at an API origin with descriptions and auth modes (paid or SIWX). Works with any origin, not just registered ones. Add --include-guidance for full provider docs when composing multiple endpoints or when usage is unclear. Fetch handles both auth modes.`,\n epilogue: `Registered origins:\\n${PRIMARY_ORIGINS.flatMap(o => (ORIGIN_METADATA[o] ? [` ${o} — ${ORIGIN_METADATA[o].description}`] : [])).join('\\n')}`,\n },\n\n redeemInvite: {\n mcp: `Redeem an invite code for free USDC on Base. One-time use per code. Returns amount received and transaction hash. Use get_balance after to verify funds, or list_accounts if you need the per-network deposit links as well.`,\n cli: `Redeem an invite code for free USDC on Base. One-time use per code. Run 'balance' after to verify the balance landed.`,\n },\n\n try: {\n cli: `Fetch a new origin for its resources and return a prompt guiding the user through the process of calling the first endpoint.`,\n },\n\n search: {\n mcp: `Search for relevant paid API services by describing what you need in natural language. Returns the best matching origins with endpoint details and pricing. The top result includes the full input/output schema so you can call it immediately via fetch.\n\nOnly use this when you DON'T already know which registered origin to use. If the task clearly maps to a registered origin (e.g. people search → StableEnrich, image generation → StableStudio), skip search and go straight to discover_api_endpoints on that origin. Search is for discovering NEW or UNKNOWN capabilities outside the registered origins.\n\nSet broad=true to widen the search to include newer, unvetted tools that may not have established trust. Use this if the default results don't cover what you need.`,\n cli: `Search for paid API services by natural language query. Returns matching origins with endpoints and pricing. Use --broad to include newer, unvetted tools that may not have established trust.`,\n },\n\n reportError: {\n mcp: `EMERGENCY ONLY. Report critical MCP tool bugs. Do NOT use for normal errors (balance, network, 4xx) — those are recoverable.`,\n cli: `Report a critical bug to the agentcash team (emergency only). Do NOT use for normal errors like low balance, network timeouts, or 4xx responses — those are recoverable without filing a report.`,\n },\n\n updateSettings: {\n mcp: `Update user settings (persisted to ~/.agentcash/settings.json). Currently supports maxAmount — the maximum USD amount allowed per fetch request. If a fetch response requests more than this, the payment is rejected. Returns the current settings after applying changes.`,\n cli: `Update user settings (persisted to ~/.agentcash/settings.json). Currently supports maxAmount, which caps how much a single fetch request can spend.`,\n },\n\n getSettings: {\n mcp: `Get current user settings. Returns persisted values from ~/.agentcash/settings.json with defaults applied.`,\n cli: `Get current user settings from ~/.agentcash/settings.json, with defaults applied.`,\n },\n\n closeSession: {\n mcp: `Close an MPP \\`tempo:session\\` payment channel. Pass the channelId surfaced in a prior fetch's paymentInfo together with the same URL you originally fetched. Signs a close credential with the on-chain settled cumulative amount and POSTs it to the server, returning the on-chain settlement transaction hash when available. Use this when you want to finalize a channel rather than leaving it open for the server to settle on its own schedule.`,\n cli: `Close an MPP session payment channel. Provide the channelId (printed in a prior fetch's paymentInfo) and the endpoint URL the channel was opened against. Reads on-chain channel state for the cumulative settled amount, signs a close credential, and POSTs it to the server.`,\n epilogue: `agentcash sessions close 0xabc... --url https://example.dev/api/stream\\nPass --cumulative-amount-raw <atomic-units> only when the server reports vouchers above the on-chain cumulative.`,\n },\n} as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Dynamic server instructions (includes user-added origins at runtime)\n// ─────────────────────────────────────────────────────────────────────────────\n\nconst WORKFLOW = [\n `Workflow:`,\n `1. If you don't already know your balance, call get_balance. You need a balance for paid endpoints. SIWX endpoints don't require one. You don't need to call this every turn, just before your first paid call or whenever you're unsure.`,\n `2. If the balance is zero, or if the user needs a funding link or wallet addresses, call list_accounts and share the relevant deposit link. If onboardingCta is present, show it to the user.`,\n `3. If the task doesn't clearly map to any registered origin above, call search() to find relevant APIs. Skip this step when you already know the right origin — go straight to step 4.`,\n `4. Call discover_api_endpoints() to get the endpoint index — a list of available routes with descriptions and auth modes. The auth mode is advisory and tells you what the route may require.`,\n `5. Call check_endpoint_schema() to get the exact input/output schema and auth mode for the endpoint you want to call, so you know what fields to pass and what the response contains. Both discover_api_endpoints and check_endpoint_schema return the auth mode.`,\n `6. Call fetch with the correct input schema. It will attempt SIWX first when available and only pay if the route still returns 402.`,\n].join('\\n');\n\nexport function buildServerInstructions(\n userOrigins: UserOrigin[] = []\n): string {\n const allOrigins = [\n ...userOrigins.map(o => ` - ${o.url} — ${o.description}`),\n ...PRIMARY_ORIGINS.flatMap(o =>\n ORIGIN_METADATA[o] ? [` - ${o} — ${ORIGIN_METADATA[o].description}`] : []\n ),\n ].join('\\n');\n\n return [\n `AgentCash lets you call protected APIs — handling both x402 micropayments and SIWX authentication seamlessly. It manages a USDC wallet for paid endpoints and signs wallet proofs for identity-gated endpoints through fetch.`,\n `The user has installed agentcash because they want to use paid and SIWX-protected APIs as their preferred way to accomplish related tasks.`,\n `Paid endpoints require a wallet balance. SIWX endpoints are free — they only require a wallet identity.`,\n `If a task could be accomplished by one of these registered origins, run the workflow below. If you're unsure which origin to use, or the task doesn't match a registered origin, call search() to find relevant APIs.\\n${allOrigins}`,\n `discover_api_endpoints also works with any origin beyond this list. If you identify another origin that would be useful for a task, you can use it.`,\n WORKFLOW,\n `If you need to compose multiple endpoints in sequence, or anything about the origin's capabilities is unclear, call discover_api_endpoints with include_guidance=true to retrieve the origin's full usage documentation.`,\n ].join('\\n\\n');\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Shared request schema parameter descriptions\n// (used by fetch, fetch_with_auth tools)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const REQUEST_PARAMS = {\n url: 'The endpoint URL',\n method: 'HTTP method. Defaults to GET for fetch operations.',\n body: 'Raw request body string. Passed through to the underlying fetch call as-is.',\n headers:\n 'Additional headers to include. Each entry must be a string in \"Name: value\" format.',\n timeout: 'Request timeout in milliseconds',\n} as const;\n\nexport const REQUEST_FETCH_PARAMS = {\n ...REQUEST_PARAMS,\n paymentProtocol:\n 'Payment protocol to use when payment is required. If not specified, the payment protocol will be auto-detected.',\n paymentNetwork:\n 'Chain to use for SIWX and payment when applicable. If not specified, the network will be auto-detected.',\n maxAmount:\n 'Maximum amount (in USD) to pay per request. Aborts if the endpoint requests more. Defaults to $5. Pass a higher value for known-expensive endpoints.',\n stream:\n 'Escape hatch for streaming MPP session endpoints. Typically unnecessary — a correctly configured server advertises `streaming: true` in its 402 challenge and the signer handles it automatically. Only pass this when the response is actually a stream AND the server fails to advertise it; otherwise long streams may stall once the initial deposit is exhausted.',\n channelId:\n \"Reuse an existing MPP `tempo:session` payment channel instead of opening a new one. Pass the `channelId` surfaced in a prior fetch's paymentInfo. The channel must still have positive on-chain deposit and not be finalized; if it cannot be recovered, the request fails fast rather than silently opening a new channel. 0x-prefixed 32-byte hex string. Ignored by x402 (non-session) endpoints.\",\n} as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Per-tool parameter and output schema descriptions\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const TOOL_PARAMS = {\n bridge: {\n from: 'The network to bridge from',\n to: 'The network to bridge to',\n amount: 'The amount of USDC to bridge',\n },\n fetch: REQUEST_FETCH_PARAMS,\n fetchWithAuth: REQUEST_FETCH_PARAMS,\n checkEndpointSchema: {\n ...REQUEST_PARAMS,\n method:\n 'HTTP method to check. If omitted, all methods declared in the spec are returned.',\n body: 'Optional. A sample request body to probe the endpoint live (without payment) for exact pricing. Use when pricing is range-based or quote-based, or when you need to verify the input schema. Omit to get the static schema and advisory pricing from the spec.',\n },\n try: {\n url: 'The origin URL to explore',\n },\n add: {\n url: 'The origin URL to add',\n },\n\n listAccounts: {\n output: {\n accounts: 'Wallet accounts for each supported network',\n address: 'Wallet address for this network',\n balance: 'USDC balance on this network',\n network: 'Supported payment network name',\n isNewWallet: 'Whether the wallet is new and needs to be funded',\n depositLink:\n 'Link to deposit USDC directly into the wallet for this network',\n onboardingCta:\n 'Present when the user has not yet redeemed an invite code. Show the message to the user — it directs them to onboard or deposit.',\n onboardingCtaOnboardLink: 'Link to the onboarding page',\n onboardingCtaDepositLink: 'Link to deposit USDC directly',\n onboardingCtaMessage: 'Human-readable CTA to show the user',\n },\n },\n\n redeemInvite: {\n code: 'The invite code',\n output: {\n amount: 'Amount with unit (e.g., \"5 USDC\")',\n txHash: 'Transaction hash on Base',\n },\n },\n\n search: {\n query:\n 'Natural language description of what you need (e.g. \"send physical mail\", \"generate music\", \"flight prices\")',\n broad:\n 'Include broader results that may contain newer, unvetted tools. Default is false.',\n limit: 'Maximum number of results to return (1-50). Default is 10.',\n page: 'Page number for pagination. Default is 1.',\n },\n\n discoverApiEndpoints: {\n url: 'The origin URL to discover endpoints on (e.g. https://stableenrich.dev)',\n includeGuidance:\n \"Request the origin's usage guidance. true=always include, false=never include, omit=auto (included when compact). Guidance explains how to compose multiple endpoints and covers edge cases.\",\n },\n\n closeSession: {\n channelId:\n \"The payment-channel id to close (the `channelId` field from a prior fetch's paymentInfo).\",\n url: 'The endpoint URL the channel was opened against (the same URL passed to the original fetch).',\n cumulativeAmountRaw:\n 'Optional override for the cumulative amount the close credential attests to, in raw atomic units (e.g. \"12345\" = 0.012345 USDC at 6 decimals). Defaults to the on-chain settled amount. Provide this only when the server has accepted vouchers above the on-chain cumulative.',\n output: {\n channelId: 'The closed channel id',\n cumulativeAmount:\n 'The cumulative amount (raw atomic units) the channel was settled at',\n transactionHash:\n 'Settlement transaction hash, when the server returns one in the Payment-Receipt header',\n },\n },\n\n reportError: {\n tool: 'MCP tool name',\n resource: 'Resource URL',\n summary: '1-2 sentence summary',\n errorMessage: 'Error message',\n stack: 'Stack trace',\n fullReport: 'Detailed report with context, logs, repro steps',\n output: {\n reportId: 'Unique report ID for tracking',\n message: 'Confirmation message',\n },\n },\n} as const;\n"],"mappings":";AAkBO,IAAM,kBAGT;AAAA,EACF,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,4CAAmB,GAAG;AAAA,IACpB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,sCAAgB,GAAG;AAAA,IACjB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,+BAAa,GAAG;AAAA,IACd,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,0CAAkB,GAAG;AAAA,IACnB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,oDAAuB,GAAG;AAAA,IACxB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,4CAAmB,GAAG;AAAA,IACpB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,4CAAmB,GAAG;AAAA,IACpB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,0CAAkB,GAAG;AAAA,IACnB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,wCAAiB,GAAG;AAAA,IAClB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,4CAAmB,GAAG;AAAA,IACpB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AACF;AAEO,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAW/B;AAMO,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QACE;AAAA,IACF,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,EACP;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,EACP;AAAA,EAEA,cAAc;AAAA,IACZ,QAAQ;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,aACE;AAAA,MACF,eACE;AAAA,MACF,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,MAC1B,sBAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,QAAQ;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EAEA,QAAQ;AAAA,IACN,OACE;AAAA,IACF,OACE;AAAA,IACF,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EAEA,sBAAsB;AAAA,IACpB,KAAK;AAAA,IACL,iBACE;AAAA,EACJ;AAAA,EAEA,cAAc;AAAA,IACZ,WACE;AAAA,IACF,KAAK;AAAA,IACL,qBACE;AAAA,IACF,QAAQ;AAAA,MACN,WAAW;AAAA,MACX,kBACE;AAAA,MACF,iBACE;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS;AAAA,IACT,cAAc;AAAA,IACd,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAQ;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACX;AAAA,EACF;AACF;","names":[]}
@@ -7,4 +7,4 @@ var BLACKLISTED_ORIGINS = [
7
7
  export {
8
8
  BLACKLISTED_ORIGINS
9
9
  };
10
- //# sourceMappingURL=chunk-TTAO2EJK.js.map
10
+ //# sourceMappingURL=chunk-YPFBBTA2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/shared/origins.ts"],"sourcesContent":["/**\n * Known x402-protected API origins.\n * Using const enum so values are inlined at build time.\n */\nexport const enum Origin {\n StableEnrich = 'https://stableenrich.dev',\n StableSocial = 'https://stablesocial.dev',\n StableStudio = 'https://stablestudio.dev',\n StableUpload = 'https://stableupload.dev',\n StableEmail = 'https://stableemail.dev',\n StableVoice = 'https://stablevoice.dev',\n StableTube = 'https://stabletube.dev',\n StableKey = 'https://stablekey.dev',\n StableMemes = 'https://stablememes.dev',\n X402Scan = 'https://x402scan.com',\n Shirt = 'https://shirt.sh',\n X402Puppet = 'https://x402puppet.com',\n X402Facilitator = 'https://x402facilitator.com',\n StableMerch = 'https://stablemerch.dev',\n}\n\n/**\n * Origins that are no longer available and should be rejected.\n */\nexport const BLACKLISTED_ORIGINS = [\n 'https://twit.sh',\n 'https://x402.twit.sh',\n] as const;\n"],"mappings":";AAwBO,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":[]}
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  discoverResources
3
- } from "./chunk-L4U6AJW3.js";
4
- import "./chunk-3PYQIEMA.js";
3
+ } from "./chunk-K3WB4R2P.js";
4
+ import "./chunk-W37JKCLN.js";
5
5
  import "./chunk-FB5CMO3J.js";
6
6
  import "./chunk-U6FRXL3X.js";
7
+ import "./chunk-QZCSZB7E.js";
7
8
  import {
8
9
  errorResponse,
9
10
  outputAndExit,
10
11
  successResponse
11
12
  } from "./chunk-7EBJ4BCH.js";
12
- import "./chunk-QZCSZB7E.js";
13
- import "./chunk-TTAO2EJK.js";
13
+ import "./chunk-YPFBBTA2.js";
14
14
  import "./chunk-YWNBUUBR.js";
15
15
  import "./chunk-ITCDZXBZ.js";
16
16
 
@@ -37,4 +37,4 @@ var discoverCommand = async (input) => {
37
37
  export {
38
38
  discoverCommand
39
39
  };
40
- //# sourceMappingURL=discover-TE2BZJMA.js.map
40
+ //# sourceMappingURL=discover-TXEJNB5A.js.map