agentcash 0.13.1 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/cjs/run-server.cjs +3912 -5574
- package/dist/esm/{add-skill-3SHARVQA.js → add-skill-W277MI7L.js} +16 -16
- package/dist/esm/{bridge-55J4MKZR.js → bridge-EXVM6MMU.js} +13 -14
- package/dist/esm/{bridge-55J4MKZR.js.map → bridge-EXVM6MMU.js.map} +1 -1
- package/dist/esm/{check-V262JV5M.js → check-LTH3BZYQ.js} +12 -13
- package/dist/esm/{check-V262JV5M.js.map → check-LTH3BZYQ.js.map} +1 -1
- package/dist/esm/{chunk-DFHVSUHX.js → chunk-5CMVFNXO.js} +3 -3
- package/dist/esm/{chunk-23OVF3MX.js → chunk-5JBG33QY.js} +4 -4
- package/dist/esm/{chunk-QOYH6AOG.js → chunk-7AT3NXJ2.js} +2 -2
- package/dist/esm/{chunk-DPKUB6GL.js → chunk-AWFBYDYO.js} +7 -7
- package/dist/esm/{chunk-HFEYSQRZ.js → chunk-F3KGAMIA.js} +34 -19
- package/dist/esm/chunk-F3KGAMIA.js.map +1 -0
- package/dist/esm/{chunk-QLW6AJTF.js → chunk-H3L6DHOH.js} +4 -4
- package/dist/esm/{chunk-EJDPIURX.js → chunk-IL5RGDIX.js} +9 -9
- package/dist/esm/{chunk-Q5SPIJGE.js → chunk-IPBR36VR.js} +48 -29
- package/dist/esm/chunk-IPBR36VR.js.map +1 -0
- package/dist/esm/{chunk-6XGAIMNK.js → chunk-ISF2WVEZ.js} +2 -2
- package/dist/esm/{chunk-4JNU4ZDR.js → chunk-JAA6JEF2.js} +3 -3
- package/dist/esm/{chunk-GYJKIBJJ.js → chunk-JOIAQY6V.js} +5 -5
- package/dist/esm/{chunk-GKYODP7W.js → chunk-JX2XE6FD.js} +2 -2
- package/dist/esm/{chunk-TVSACMMH.js → chunk-KPJJSNZO.js} +7 -7
- package/dist/esm/{chunk-LNQRIXFK.js → chunk-KVSTJRSJ.js} +2 -2
- package/dist/esm/{chunk-DJLERI6R.js → chunk-MYWE3P7R.js} +5 -5
- package/dist/esm/{chunk-RVJ22H4S.js → chunk-NC4UN6IF.js} +2 -2
- package/dist/esm/{chunk-BYLBPP4V.js → chunk-O3OVWMBY.js} +8 -8
- package/dist/esm/{chunk-QZBSRYSW.js → chunk-PBVLTOFS.js} +3 -3
- package/dist/esm/{chunk-Y4VZACTC.js → chunk-QZCSZB7E.js} +6 -8
- package/dist/esm/{chunk-Y4VZACTC.js.map → chunk-QZCSZB7E.js.map} +1 -1
- package/dist/esm/chunk-TTAO2EJK.js +10 -0
- package/dist/esm/chunk-TTAO2EJK.js.map +1 -0
- package/dist/esm/{chunk-E5SPXKCI.js → chunk-UBVHQSSW.js} +9 -9
- package/dist/esm/{chunk-HOGMCHWI.js → chunk-UMYAGSWZ.js} +5 -5
- package/dist/esm/{chunk-BQRFNAMV.js → chunk-VX6PPHSN.js} +5 -5
- package/dist/esm/{chunk-X5AS5G23.js → chunk-WRMSVC2R.js} +2 -2
- package/dist/esm/{chunk-EMQMCXIC.js → chunk-X2JUL4S3.js} +3 -10
- package/dist/esm/chunk-X2JUL4S3.js.map +1 -0
- package/dist/esm/{chunk-TX4UYXJO.js → chunk-YIU364NZ.js} +3 -3
- package/dist/esm/{chunk-WUNL7OYW.js → chunk-YUGBFY4H.js} +3 -3
- package/dist/esm/{chunk-C7KWYVS3.js → chunk-YWNBUUBR.js} +53 -2
- package/dist/esm/chunk-YWNBUUBR.js.map +1 -0
- package/dist/esm/{discover-RV2HPYM3.js → discover-63V73SKH.js} +7 -7
- package/dist/esm/{fetch-5H6NJNO5.js → fetch-G2C4EUTP.js} +17 -18
- package/dist/esm/{fetch-5H6NJNO5.js.map → fetch-G2C4EUTP.js.map} +1 -1
- package/dist/esm/{fund-OTAWWC7N.js → fund-YCUI5KVH.js} +9 -11
- package/dist/esm/{fund-OTAWWC7N.js.map → fund-YCUI5KVH.js.map} +1 -1
- package/dist/esm/index.js +35 -35
- package/dist/esm/{install-BZLMXTQ6.js → install-OK4J2KEU.js} +12 -14
- package/dist/esm/{install-BZLMXTQ6.js.map → install-OK4J2KEU.js.map} +1 -1
- package/dist/esm/{onboard-DBENGNGV.js → onboard-SLU3CNO4.js} +17 -19
- package/dist/esm/{onboard-DBENGNGV.js.map → onboard-SLU3CNO4.js.map} +1 -1
- package/dist/esm/{origins-3AA7U2VW.js → origins-7KBHPH42.js} +10 -10
- package/dist/esm/register-HP4VTPU7.js +150 -0
- package/dist/esm/register-HP4VTPU7.js.map +1 -0
- package/dist/esm/{report-error-F44RFQ54.js → report-error-D3RRKDEC.js} +10 -12
- package/dist/esm/{report-error-F44RFQ54.js.map → report-error-D3RRKDEC.js.map} +1 -1
- package/dist/esm/{search-WTPHS4A3.js → search-G25PLCS2.js} +14 -15
- package/dist/esm/{search-WTPHS4A3.js.map → search-G25PLCS2.js.map} +1 -1
- package/dist/esm/{server-BR4W2YCH.js → server-KWXWCPIO.js} +36 -37
- package/dist/esm/{server-BR4W2YCH.js.map → server-KWXWCPIO.js.map} +1 -1
- package/dist/esm/{server-6V4NB65Q.js → server-QJNQOPBK.js} +2 -2
- package/dist/esm/{settings-SEZ65YUC.js → settings-RLSKK5RM.js} +3 -4
- package/dist/esm/{settings-SEZ65YUC.js.map → settings-RLSKK5RM.js.map} +1 -1
- package/dist/esm/{try-2KUOYSRY.js → try-JK56MOLD.js} +16 -17
- package/dist/esm/{try-2KUOYSRY.js.map → try-JK56MOLD.js.map} +1 -1
- package/dist/esm/{wallet-RZVO77IB.js → wallet-RWNVHHCO.js} +17 -19
- package/dist/esm/{wallet-RZVO77IB.js.map → wallet-RWNVHHCO.js.map} +1 -1
- package/package.json +7 -7
- package/dist/esm/chunk-C7KWYVS3.js.map +0 -1
- package/dist/esm/chunk-EMQMCXIC.js.map +0 -1
- package/dist/esm/chunk-HFEYSQRZ.js.map +0 -1
- package/dist/esm/chunk-NROPRHIC.js +0 -25
- package/dist/esm/chunk-NROPRHIC.js.map +0 -1
- package/dist/esm/chunk-Q5SPIJGE.js.map +0 -1
- package/dist/esm/chunk-VDBUUHJF.js +0 -58
- package/dist/esm/chunk-VDBUUHJF.js.map +0 -1
- package/dist/esm/register-NAPAV4G7.js +0 -64
- package/dist/esm/register-NAPAV4G7.js.map +0 -1
- /package/dist/esm/{add-skill-3SHARVQA.js.map → add-skill-W277MI7L.js.map} +0 -0
- /package/dist/esm/{chunk-DFHVSUHX.js.map → chunk-5CMVFNXO.js.map} +0 -0
- /package/dist/esm/{chunk-23OVF3MX.js.map → chunk-5JBG33QY.js.map} +0 -0
- /package/dist/esm/{chunk-QOYH6AOG.js.map → chunk-7AT3NXJ2.js.map} +0 -0
- /package/dist/esm/{chunk-DPKUB6GL.js.map → chunk-AWFBYDYO.js.map} +0 -0
- /package/dist/esm/{chunk-QLW6AJTF.js.map → chunk-H3L6DHOH.js.map} +0 -0
- /package/dist/esm/{chunk-EJDPIURX.js.map → chunk-IL5RGDIX.js.map} +0 -0
- /package/dist/esm/{chunk-6XGAIMNK.js.map → chunk-ISF2WVEZ.js.map} +0 -0
- /package/dist/esm/{chunk-4JNU4ZDR.js.map → chunk-JAA6JEF2.js.map} +0 -0
- /package/dist/esm/{chunk-GYJKIBJJ.js.map → chunk-JOIAQY6V.js.map} +0 -0
- /package/dist/esm/{chunk-GKYODP7W.js.map → chunk-JX2XE6FD.js.map} +0 -0
- /package/dist/esm/{chunk-TVSACMMH.js.map → chunk-KPJJSNZO.js.map} +0 -0
- /package/dist/esm/{chunk-LNQRIXFK.js.map → chunk-KVSTJRSJ.js.map} +0 -0
- /package/dist/esm/{chunk-DJLERI6R.js.map → chunk-MYWE3P7R.js.map} +0 -0
- /package/dist/esm/{chunk-RVJ22H4S.js.map → chunk-NC4UN6IF.js.map} +0 -0
- /package/dist/esm/{chunk-BYLBPP4V.js.map → chunk-O3OVWMBY.js.map} +0 -0
- /package/dist/esm/{chunk-QZBSRYSW.js.map → chunk-PBVLTOFS.js.map} +0 -0
- /package/dist/esm/{chunk-E5SPXKCI.js.map → chunk-UBVHQSSW.js.map} +0 -0
- /package/dist/esm/{chunk-HOGMCHWI.js.map → chunk-UMYAGSWZ.js.map} +0 -0
- /package/dist/esm/{chunk-BQRFNAMV.js.map → chunk-VX6PPHSN.js.map} +0 -0
- /package/dist/esm/{chunk-X5AS5G23.js.map → chunk-WRMSVC2R.js.map} +0 -0
- /package/dist/esm/{chunk-TX4UYXJO.js.map → chunk-YIU364NZ.js.map} +0 -0
- /package/dist/esm/{chunk-WUNL7OYW.js.map → chunk-YUGBFY4H.js.map} +0 -0
- /package/dist/esm/{discover-RV2HPYM3.js.map → discover-63V73SKH.js.map} +0 -0
- /package/dist/esm/{origins-3AA7U2VW.js.map → origins-7KBHPH42.js.map} +0 -0
- /package/dist/esm/{server-6V4NB65Q.js.map → server-QJNQOPBK.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/operations/fetch/auth.ts","../../src/shared/protocols/x402/index.ts","../../src/shared/protocols/x402/patched-exact-svm-scheme.ts","../../src/shared/protocols/detect.ts","../../src/shared/protocols/mpp/handle-payment.ts","../../src/shared/protocols/mpp/index.ts","../../src/shared/protocols/before-payment.ts","../../src/shared/protocols/pick.ts","../../src/shared/protocols/x402/choose-payment-requirement.ts","../../src/shared/protocols/x402/handle-payment.ts","../../src/operations/fetch/payment.ts","../../src/operations/fetch/index.ts"],"sourcesContent":["import { encodeSIWxHeader } from '@x402/extensions/sign-in-with-x';\n\nimport { fetchOk, safeFetch } from '@/shared/neverthrow/fetch';\nimport {\n getSiwxExtension,\n safeCreateSIWxPayload,\n safeGetPaymentRequired,\n} from '@/shared/protocols/x402';\n\nimport type { ExecuteFetchOptions } from './types';\n\nexport async function attemptSiwxAuth(\n response: Response,\n authRetryRequest: Request,\n paymentRetryRequest: Request,\n options: ExecuteFetchOptions\n) {\n const { surface, wallets } = options;\n const { timeout, paymentNetwork } = options.params;\n\n if (!response.headers.has('payment-required')) {\n return fetchOk({\n response,\n paymentRetryRequest,\n });\n }\n\n const paymentRequiredResult = await safeGetPaymentRequired(surface, response);\n\n if (paymentRequiredResult.isErr()) {\n return paymentRequiredResult;\n }\n\n const siwxExtension = getSiwxExtension(\n paymentRequiredResult.value.extensions,\n paymentNetwork\n );\n\n if (!siwxExtension) {\n return fetchOk({\n response,\n paymentRetryRequest,\n });\n }\n\n const payloadResult = await safeCreateSIWxPayload(\n surface,\n siwxExtension,\n wallets\n );\n\n if (payloadResult.isErr()) {\n return payloadResult;\n }\n\n const siwxHeader = encodeSIWxHeader(payloadResult.value);\n authRetryRequest.headers.set('SIGN-IN-WITH-X', siwxHeader);\n paymentRetryRequest.headers.set('SIGN-IN-WITH-X', siwxHeader);\n\n return (await safeFetch(surface, authRetryRequest, timeout)).andThen(\n authResponse =>\n fetchOk({\n response: authResponse,\n paymentRetryRequest,\n })\n );\n}\n","import {\n err,\n ok,\n resultFromPromise,\n resultFromThrowable,\n} from '@agentcash/neverthrow';\n\nimport type { SelectPaymentRequirements } from '@x402/core/client';\nimport { x402Client, x402HTTPClient } from '@x402/core/client';\n\nimport { toClientEvmSigner } from '@x402/evm';\nimport { toClientSvmSigner } from '@x402/svm';\n\nimport { ExactEvmScheme } from '@x402/evm/exact/client';\nimport { PatchedExactSvmScheme } from './patched-exact-svm-scheme';\n\nimport { createSIWxPayload } from '@x402/extensions/sign-in-with-x';\n\nimport type { BaseX402Error } from './types';\nimport type { PaymentRequired } from '@x402/core/types';\nimport type {\n CompleteSIWxInfo,\n SIWxExtensionInfo,\n SolanaSigner,\n SupportedChain,\n} from '@x402/extensions/sign-in-with-x';\nimport type { Wallets } from '@/wallet';\nimport { Network, networkToCaip2 } from '@agentcash/networks';\nimport type { Network as PaymentNetwork } from '@agentcash/networks';\nimport { createPublicClient, http } from 'viem';\nimport { base } from 'viem/chains';\n\nconst errorType = 'x402';\n\nexport const x402Ok = <T>(value: T) => ok(value);\nexport const x402Err = (cause: string, error: BaseX402Error) =>\n err(errorType, cause, error);\n\nconst x402ResultFromPromise = <T>(\n surface: string,\n promise: Promise<T>,\n error: (e: unknown) => BaseX402Error\n) => resultFromPromise(errorType, surface, promise, error);\n\nconst x402ResultFromThrowable = <T>(\n surface: string,\n fn: () => T,\n error: (e: unknown) => BaseX402Error\n) => resultFromThrowable(errorType, surface, fn, error);\n\nexport const x402ProbeClient = new x402HTTPClient(new x402Client());\n\nexport const safeGetPaymentRequired = (surface: string, response: Response) => {\n return x402ResultFromPromise(\n surface,\n response.json().then(\n json =>\n x402ProbeClient.getPaymentRequiredResponse(\n name => response.headers.get(name),\n json\n ),\n () =>\n x402ProbeClient.getPaymentRequiredResponse(name =>\n response.headers.get(name)\n )\n ),\n error => ({\n cause: 'parse_payment_required',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to parse payment required',\n })\n );\n};\n\nexport const getSiwxExtension = (\n extensions: PaymentRequired['extensions'],\n paymentNetwork?: PaymentNetwork\n): CompleteSIWxInfo | undefined => {\n const siwx = extensions?.['sign-in-with-x'] as\n | { info?: SIWxExtensionInfo; supportedChains?: SupportedChain[] }\n | undefined;\n\n if (!siwx?.info) {\n return undefined;\n }\n\n const chain = siwx.supportedChains?.find(c =>\n paymentNetwork\n ? c.chainId === networkToCaip2(paymentNetwork)\n : c.chainId.startsWith('eip155:')\n );\n\n return {\n ...siwx.info,\n chainId: chain?.chainId ?? 'eip155:8453',\n type: chain?.type ?? 'eip191',\n signatureScheme: chain?.signatureScheme,\n };\n};\n\nexport const safeCreatePaymentPayload = (\n surface: string,\n wallets: Wallets,\n paymentRequired: PaymentRequired,\n paymentRequirementsSelector?: SelectPaymentRequirements\n) => {\n const client = new x402HTTPClient(\n x402Client.fromConfig({\n schemes: [\n {\n network: networkToCaip2(Network.BASE),\n client: new ExactEvmScheme(\n toClientEvmSigner(\n wallets.evm,\n createPublicClient({\n chain: base,\n transport: http(),\n })\n )\n ),\n },\n {\n network: networkToCaip2(Network.SOLANA),\n client: new PatchedExactSvmScheme(toClientSvmSigner(wallets.svm)),\n },\n ],\n paymentRequirementsSelector,\n })\n );\n return x402ResultFromPromise(\n surface,\n client.createPaymentPayload(paymentRequired),\n error => ({\n cause: 'create_payment_payload',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to create payment payload',\n })\n );\n};\n\nexport const safeGetPaymentSettlement = (\n surface: string,\n response: Response\n) => {\n return x402ResultFromThrowable(\n surface,\n () =>\n x402ProbeClient.getPaymentSettleResponse(name =>\n response.headers.get(name)\n ),\n error => ({\n cause: 'get_payment_settlement',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to get payment settlement',\n })\n );\n};\n\nexport const safeCreateSIWxPayload = (\n surface: string,\n serverInfo: CompleteSIWxInfo,\n wallets: Wallets\n) => {\n return x402ResultFromPromise(\n surface,\n createSIWxPayload(\n serverInfo,\n serverInfo.chainId.startsWith('eip155:')\n ? wallets.evm\n : (wallets.svm as unknown as SolanaSigner)\n ),\n error => ({\n cause: 'create_siwx_payload',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to create SIWX payload',\n })\n );\n};\n","import {\n getSetComputeUnitLimitInstruction,\n setTransactionMessageComputeUnitPrice,\n} from '@solana-program/compute-budget';\nimport { TOKEN_PROGRAM_ADDRESS } from '@solana-program/token';\nimport {\n fetchMint,\n findAssociatedTokenPda,\n getTransferCheckedInstruction,\n TOKEN_2022_PROGRAM_ADDRESS,\n} from '@solana-program/token-2022';\nimport {\n appendTransactionMessageInstructions,\n createTransactionMessage,\n getBase64EncodedWireTransaction,\n partiallySignTransactionMessageWithSigners,\n pipe,\n prependTransactionMessageInstruction,\n setTransactionMessageFeePayer,\n setTransactionMessageLifetimeUsingBlockhash,\n type Address,\n} from '@solana/kit';\n\nimport type {\n PaymentPayload,\n PaymentRequirements,\n SchemeNetworkClient,\n} from '@x402/core/types';\nimport {\n DEFAULT_COMPUTE_UNIT_LIMIT,\n DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS,\n createRpcClient,\n type ClientSvmConfig,\n type ClientSvmSigner,\n type ExactSvmPayloadV2,\n} from '@x402/svm';\n\ntype BlockhashLifetime = Parameters<\n typeof setTransactionMessageLifetimeUsingBlockhash\n>[0];\n\ninterface PatchedPaymentExtra {\n feePayer?: Address;\n recentBlockhash?:\n | string\n | Partial<{\n blockhash: string;\n lastValidBlockHeight: bigint | number | string;\n }>;\n lastValidBlockHeight?: bigint | number | string;\n}\n\nfunction parseLastValidBlockHeight(\n value: bigint | number | string | undefined\n): bigint | undefined {\n if (typeof value === 'bigint') {\n return value;\n }\n\n if (typeof value === 'number' && Number.isFinite(value)) {\n return BigInt(value);\n }\n\n if (typeof value === 'string' && value.length > 0) {\n return BigInt(value);\n }\n\n return undefined;\n}\n\nfunction asBlockhash(blockhash: string): BlockhashLifetime['blockhash'] {\n return blockhash as BlockhashLifetime['blockhash'];\n}\n\n/**\n * Local compatibility patch for Coinbase ExactSvmScheme.\n *\n * Changes from upstream:\n * - omits the trailing memo instruction\n * - prefers paymentRequirements.extra.recentBlockhash when provided\n */\nexport class PatchedExactSvmScheme implements SchemeNetworkClient {\n readonly scheme = 'exact';\n\n constructor(\n private readonly signer: ClientSvmSigner,\n private readonly config?: ClientSvmConfig\n ) {}\n\n async createPaymentPayload(\n x402Version: number,\n paymentRequirements: PaymentRequirements\n ): Promise<Pick<PaymentPayload, 'x402Version' | 'payload'>> {\n const rpc = createRpcClient(\n paymentRequirements.network,\n this.config?.rpcUrl\n );\n\n const tokenMint = await fetchMint(\n rpc,\n paymentRequirements.asset as Address\n );\n const tokenProgramAddress = tokenMint.programAddress;\n\n if (\n tokenProgramAddress.toString() !== TOKEN_PROGRAM_ADDRESS.toString() &&\n tokenProgramAddress.toString() !== TOKEN_2022_PROGRAM_ADDRESS.toString()\n ) {\n throw new Error('Asset was not created by a known token program');\n }\n\n const [sourceATA] = await findAssociatedTokenPda({\n mint: paymentRequirements.asset as Address,\n owner: this.signer.address,\n tokenProgram: tokenProgramAddress,\n });\n\n const [destinationATA] = await findAssociatedTokenPda({\n mint: paymentRequirements.asset as Address,\n owner: paymentRequirements.payTo as Address,\n tokenProgram: tokenProgramAddress,\n });\n\n const transferIx = getTransferCheckedInstruction(\n {\n source: sourceATA,\n mint: paymentRequirements.asset as Address,\n destination: destinationATA,\n authority: this.signer,\n amount: BigInt(paymentRequirements.amount),\n decimals: tokenMint.data.decimals,\n },\n { programAddress: tokenProgramAddress }\n );\n\n const extra = paymentRequirements.extra as PatchedPaymentExtra;\n const feePayer = extra.feePayer;\n\n if (!feePayer) {\n throw new Error(\n 'feePayer is required in paymentRequirements.extra for SVM transactions'\n );\n }\n\n const latestBlockhash = await this.resolveBlockhashLifetime(rpc, extra);\n\n const tx = pipe(\n createTransactionMessage({ version: 0 }),\n tx =>\n setTransactionMessageComputeUnitPrice(\n DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS,\n tx\n ),\n tx => setTransactionMessageFeePayer(feePayer, tx),\n tx =>\n prependTransactionMessageInstruction(\n getSetComputeUnitLimitInstruction({\n units: DEFAULT_COMPUTE_UNIT_LIMIT,\n }),\n tx\n ),\n tx => appendTransactionMessageInstructions([transferIx], tx),\n tx => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx)\n );\n\n const signedTransaction =\n await partiallySignTransactionMessageWithSigners(tx);\n const base64EncodedWireTransaction =\n getBase64EncodedWireTransaction(signedTransaction);\n\n const payload: ExactSvmPayloadV2 = {\n transaction: base64EncodedWireTransaction,\n };\n\n return {\n x402Version,\n payload,\n };\n }\n\n private async resolveBlockhashLifetime(\n rpc: ReturnType<typeof createRpcClient>,\n extra: PatchedPaymentExtra\n ): Promise<BlockhashLifetime> {\n const providedLastValidBlockHeight = parseLastValidBlockHeight(\n extra.lastValidBlockHeight\n );\n\n if (typeof extra.recentBlockhash === 'string') {\n if (providedLastValidBlockHeight !== undefined) {\n return {\n blockhash: asBlockhash(extra.recentBlockhash),\n lastValidBlockHeight: providedLastValidBlockHeight,\n };\n }\n\n const { value } = await rpc.getLatestBlockhash().send();\n return {\n blockhash: asBlockhash(extra.recentBlockhash),\n lastValidBlockHeight: value.lastValidBlockHeight,\n };\n }\n\n if (\n extra.recentBlockhash &&\n typeof extra.recentBlockhash === 'object' &&\n typeof extra.recentBlockhash.blockhash === 'string'\n ) {\n const lastValidBlockHeight =\n parseLastValidBlockHeight(extra.recentBlockhash.lastValidBlockHeight) ??\n providedLastValidBlockHeight;\n\n if (lastValidBlockHeight !== undefined) {\n return {\n blockhash: asBlockhash(extra.recentBlockhash.blockhash),\n lastValidBlockHeight,\n };\n }\n\n const { value } = await rpc.getLatestBlockhash().send();\n return {\n blockhash: asBlockhash(extra.recentBlockhash.blockhash),\n lastValidBlockHeight: value.lastValidBlockHeight,\n };\n }\n\n return (await rpc.getLatestBlockhash().send()).value;\n }\n}\n","import { PaymentProtocol } from './types';\n\nexport function detectPaymentProtocols(response: Response): PaymentProtocol[] {\n const protocols: PaymentProtocol[] = [];\n\n const wwwAuth = response.headers.get('WWW-Authenticate');\n if (wwwAuth?.startsWith('Payment')) {\n protocols.push(PaymentProtocol.MPP);\n }\n\n const paymentRequired = response.headers.get('payment-required');\n if (paymentRequired) {\n protocols.push(PaymentProtocol.X402);\n }\n // If we couldn't detect either explicitly, default to x402\n if (protocols.length === 0) {\n protocols.push(PaymentProtocol.X402);\n }\n return protocols;\n}\n","import type { Address } from 'viem';\nimport { formatUnits } from 'viem';\n\nimport { safeFetch } from '@/shared/neverthrow/fetch';\nimport {\n safeGetMppChallenge,\n safeCreateMppCredential,\n safeGetMppReceipt,\n mppErr,\n mppOk,\n} from '@/shared/protocols/mpp';\n\nimport { PaymentProtocol } from '../types';\nimport { Network, EVM_CONFIGS } from '@agentcash/networks';\n\nimport type { ExecuteFetchResult } from '@/operations/fetch/types';\nimport type { HandlePaymentParams } from '@/shared/protocols/types';\nimport { beforePayment } from '../before-payment';\n\nexport async function handleMppPayment({\n response,\n request,\n options,\n}: HandlePaymentParams) {\n const { surface, wallets } = options;\n const { timeout } = options.params;\n\n // Prevent retry loops\n if (request.headers.has('Authorization')) {\n return mppErr(surface, {\n cause: 'mpp_payment_already_attempted',\n message: 'MPP payment already attempted',\n });\n }\n\n // Parse the challenge from the WWW-Authenticate header\n const challengeResult = safeGetMppChallenge(surface, response);\n\n if (challengeResult.isErr()) {\n return challengeResult;\n }\n\n const challenge = challengeResult.value;\n\n // Extract payment info from challenge request\n const amount = Number(formatUnits(BigInt(challenge.request.amount), 6));\n const tokenAddress = challenge.request.currency as Address;\n\n // Check that the requested token matches what agentcash supports on Tempo\n const expectedToken = EVM_CONFIGS[Network.TEMPO].usdcAddress.toLowerCase();\n if (tokenAddress.toLowerCase() !== expectedToken) {\n return mppErr(surface, {\n cause: 'unsupported_token',\n message: `Endpoint requires payment in token ${tokenAddress} on Tempo, but agentcash only supports ${EVM_CONFIGS[Network.TEMPO].usdcAddress}. The endpoint may be configured for a different token (e.g. PathUSD vs USDC).`,\n });\n }\n\n const beforePaymentResult = await beforePayment({\n options,\n balanceInput: {\n address: wallets.evm.address,\n network: Network.TEMPO,\n tokenAddress,\n },\n amount,\n protocol: PaymentProtocol.MPP,\n });\n\n if (beforePaymentResult.isErr()) {\n return beforePaymentResult;\n }\n\n const credentialResult = await safeCreateMppCredential(\n surface,\n wallets,\n response\n );\n\n if (credentialResult.isErr()) {\n return credentialResult;\n }\n\n const credential = credentialResult.value;\n\n // Set Authorization header on cloned request\n request.headers.set('Authorization', credential);\n\n // Retry the fetch with the credential\n const paidFetchResult = await safeFetch(surface, request, timeout);\n if (paidFetchResult.isErr()) {\n return paidFetchResult;\n }\n\n const paidResponse = paidFetchResult.value;\n\n // If the server still returns 402, the payment was rejected\n if (paidResponse.status === 402) {\n const body = await paidResponse\n .clone()\n .text()\n .catch(() => '');\n const detail = body ? `: ${body}` : '';\n return mppErr(surface, {\n cause: 'mpp_payment_rejected',\n message: `MPP payment was rejected by the server (402)${detail}`,\n });\n }\n\n // Parse the receipt for transaction hash\n const receiptResult = safeGetMppReceipt(surface, paidResponse);\n\n return mppOk<ExecuteFetchResult>({\n response: paidResponse,\n paymentInfo: {\n protocol: PaymentProtocol.MPP,\n network: Network.TEMPO,\n price: amount.toLocaleString('en-US', {\n style: 'currency',\n currency: 'USD',\n }),\n payment: receiptResult.isOk()\n ? {\n success: true,\n transactionHash: receiptResult.value.reference,\n }\n : null,\n },\n });\n}\n","import { Challenge, Receipt } from 'mppx';\nimport { Methods } from 'mppx/tempo';\nimport {\n err,\n ok,\n resultFromPromise,\n resultFromThrowable,\n} from '@agentcash/neverthrow';\n\nimport { Mppx, tempo as tempoMethod } from 'mppx/client';\n\nimport { createClient, http } from 'viem';\nimport { tempo } from 'viem/chains';\n\nimport type { BaseMppError } from './types';\nimport type { Wallets } from '@/wallet';\n\nconst errorType = 'mpp';\n\nexport const mppOk = <T>(value: T) => ok(value);\nexport const mppErr = (surface: string, error: BaseMppError) =>\n err(errorType, surface, error);\n\nconst mppResultFromPromise = <T>(\n surface: string,\n promise: Promise<T>,\n error: (e: unknown) => BaseMppError\n) => resultFromPromise(errorType, surface, promise, error);\n\nconst mppResultFromThrowable = <T>(\n surface: string,\n fn: () => T,\n error: (e: unknown) => BaseMppError\n) => resultFromThrowable(errorType, surface, fn, error);\n\nexport const safeGetMppChallenge = (surface: string, response: Response) => {\n return mppResultFromThrowable(\n surface,\n () => Challenge.fromResponse(response, { methods: [Methods.charge] }),\n error => ({\n cause: 'parse_mpp_challenge',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to parse MPP challenge from response',\n })\n );\n};\n\nexport const safeCreateMppCredential = (\n surface: string,\n wallets: Wallets,\n response: Response\n) => {\n const TEMPO_RPC_URL =\n 'https://eng:acard-melody-fashion-finish@rpc.mainnet.tempo.xyz';\n\n const client = Mppx.create({\n polyfill: false,\n methods: [\n tempoMethod({\n account: wallets.evm,\n getClient: () =>\n createClient({\n chain: tempo,\n transport: http(TEMPO_RPC_URL),\n }),\n }),\n ],\n });\n\n return mppResultFromPromise(\n surface,\n client.createCredential(response),\n error => ({\n cause: 'create_mpp_credential',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to create MPP credential',\n })\n );\n};\n\nexport const safeGetMppReceipt = (surface: string, response: Response) => {\n return mppResultFromThrowable(\n surface,\n () => Receipt.fromResponse(response),\n error => ({\n cause: 'parse_mpp_receipt',\n message:\n error instanceof Error\n ? error.message\n : 'Failed to parse MPP receipt from response',\n })\n );\n};\n","import { err, ok } from '@agentcash/neverthrow';\n\nimport { getBalance } from '../balance';\nimport { getDepositLink } from '../utils';\nimport { getSettings } from '../settings';\n\nimport { DEFAULT_MAX_AMOUNT } from '@/operations/fetch/types';\n\nimport type { GetBalanceInput } from '@agentcash/balance';\nimport type { ExecuteFetchOptions } from '@/operations/fetch/types';\nimport type { PaymentProtocol } from './types';\n\ninterface BeforePaymentProps {\n options: ExecuteFetchOptions;\n balanceInput: GetBalanceInput;\n protocol: PaymentProtocol;\n amount: number;\n}\n\nexport const beforePayment = async (props: BeforePaymentProps) => {\n const { options, balanceInput, amount } = props;\n const maxAmount =\n options.params.maxAmount ?? getSettings().maxAmount ?? DEFAULT_MAX_AMOUNT;\n if (amount > maxAmount) {\n return err('before_payment', options.surface, {\n cause: 'amount_exceeds_max_amount' as const,\n message: `Endpoint requested $${amount} which exceeds the maximum allowed amount of $${maxAmount}. Pass a higher maxAmount on this call, or use update_settings to raise the default permanently.`,\n });\n }\n\n const balanceResult = await getBalance(\n options.surface,\n balanceInput,\n options.flags\n );\n\n if (balanceResult.isErr()) {\n return balanceResult;\n }\n\n const balance = balanceResult.value.balance;\n\n if (balance < amount) {\n return err('before_payment', options.surface, {\n cause: 'insufficient_balance' as const,\n message: insufficientBalanceErrorMessage(props, balance),\n });\n }\n\n return ok(true);\n};\n\nconst insufficientBalanceErrorMessage = (\n props: BeforePaymentProps,\n balance: number\n) => {\n const { options, balanceInput, amount } = props;\n return [\n `You are attempting to use an endpoint via ${props.protocol} that costs ${amount} USDC on ${balanceInput.network}.`,\n `Your current balance is ${balance} USDC.`,\n `You can bridge between accounts or deposit at ${getDepositLink(balanceInput.address, options.flags, balanceInput.network)} to top up your balance.`,\n `Before bridging, you can check the users account with npx agentcash@latest accounts or if you are within the MCP, you can use the list_accounts tool.`,\n ].join('\\n');\n};\n","import { safeGetMppChallenge } from '@/shared/protocols/mpp';\n\nimport { log } from '@/shared/log';\nimport { getBalance } from '@/shared/balance';\nimport { Network } from '@agentcash/networks';\n\nimport { PaymentProtocol } from './types';\n\nimport type { ExecuteFetchOptions } from '@/operations/fetch/types';\n\n/**\n * Pick the preferred protocol by comparing wallet balances.\n * Falls back to 'mpp' if both balances fail to fetch.\n */\nexport async function pickByBalance(\n response: Response,\n options: ExecuteFetchOptions\n): Promise<PaymentProtocol> {\n const { surface, wallets, flags } = options;\n\n // Get x402 (USDC on Base and Solana) balances in parallel\n const x402Balances = await Promise.all([\n getBalance(\n surface,\n {\n address: wallets.evm.address,\n network: Network.BASE,\n },\n flags\n ),\n getBalance(\n surface,\n {\n address: wallets.svm.address,\n network: Network.SOLANA,\n },\n flags\n ),\n ]);\n\n const x402Balance = x402Balances.reduce(\n (acc, balance) => acc + (balance.isOk() ? balance.value.balance : 0),\n 0\n );\n\n // Get MPP (Tempo) balance — need token address from the challenge\n let mppBalance = 0;\n const challengeResult = safeGetMppChallenge(surface, response);\n if (challengeResult.isOk()) {\n const currency = challengeResult.value.request.currency;\n if (currency) {\n const tempoResult = await getBalance(\n surface,\n {\n address: wallets.evm.address,\n network: Network.TEMPO,\n },\n flags\n );\n if (tempoResult.isOk()) {\n mppBalance = tempoResult.value.balance ?? 0;\n }\n }\n }\n\n log.info(`Protocol selection — x402: $${x402Balance}, mpp: $${mppBalance}`);\n return x402Balance >= mppBalance ? PaymentProtocol.X402 : PaymentProtocol.MPP;\n}\n","import { getBalance } from '@/shared/balance';\nimport { caip2ToNetwork, Network, networkToCaip2 } from '@agentcash/networks';\n\nimport type { PaymentRequirements } from '@x402/core/types';\nimport type { ExecuteFetchOptions } from '@/operations/fetch/types';\n\ninterface ChoosePaymentRequirementParams {\n paymentRequirements: PaymentRequirements[];\n options: ExecuteFetchOptions;\n}\n\nexport const choosePaymentRequirement = async ({\n paymentRequirements,\n options,\n}: ChoosePaymentRequirementParams) => {\n const { surface, wallets, flags } = options;\n const { paymentNetwork } = options.params;\n if (paymentNetwork) {\n const caip2 = networkToCaip2(paymentNetwork);\n return paymentRequirements.find(pr => pr.network === caip2);\n }\n\n const requirementsWithBalance = await Promise.all(\n paymentRequirements.map(async pr => {\n const network = caip2ToNetwork(pr.network);\n if (network === null) {\n return {\n balance: 0,\n requirement: pr,\n };\n }\n if (network === Network.SOLANA) {\n const balanceResult = await getBalance(\n surface,\n {\n address: wallets.svm.address,\n network,\n },\n flags\n );\n return {\n requirement: pr,\n balance: balanceResult.isOk() ? balanceResult.value.balance : 0,\n };\n } else {\n const balanceResult = await getBalance(\n surface,\n {\n address: wallets.evm.address,\n network,\n },\n flags\n );\n return {\n requirement: pr,\n balance: balanceResult.isOk() ? balanceResult.value.balance : 0,\n };\n }\n })\n );\n return requirementsWithBalance.sort((a, b) => b.balance - a.balance)[0]!\n .requirement;\n};\n","import { caip2ToNetwork, Network } from '@agentcash/networks';\n\nimport { choosePaymentRequirement } from './choose-payment-requirement';\n\nimport { safeFetch } from '@/shared/neverthrow/fetch';\nimport {\n safeCreatePaymentPayload,\n safeGetPaymentRequired,\n safeGetPaymentSettlement,\n x402Err,\n x402Ok,\n x402ProbeClient,\n} from '@/shared/protocols/x402';\nimport { tokenStringToNumber } from '@/shared/utils';\n\nimport { beforePayment } from '../before-payment';\n\nimport { PaymentProtocol } from '../types';\n\nimport type { ExecuteFetchResult } from '@/operations/fetch/types';\nimport type { HandlePaymentParams } from '../types';\n\nexport async function handleX402Payment({\n response,\n request,\n options,\n}: HandlePaymentParams) {\n const { surface, wallets } = options;\n const { timeout } = options.params;\n\n const paymentRequiredResult = await safeGetPaymentRequired(surface, response);\n\n if (paymentRequiredResult.isErr()) {\n return paymentRequiredResult;\n }\n\n const paymentRequired = paymentRequiredResult.value;\n\n if (paymentRequired.x402Version === 1) {\n return x402Err(surface, {\n cause: 'parse_payment_required' as const,\n message:\n 'This endpoint uses the x402 v1 format, which is not supported by agentcash. Only x402 v2 servers (with an `accepts` array in the Payment-Required header) are supported.',\n });\n }\n\n if (!paymentRequired.accepts || !Array.isArray(paymentRequired.accepts)) {\n return x402Err(surface, {\n cause: 'parse_payment_required' as const,\n message:\n 'This endpoint has a missing or malformed accepts array in the Payment-Required header.',\n });\n }\n\n // Check amount against maxAmount before any payment logic\n const accept = await choosePaymentRequirement({\n options,\n paymentRequirements: paymentRequired.accepts,\n });\n\n if (accept) {\n const amount = tokenStringToNumber(accept.amount);\n\n const typedNetwork = caip2ToNetwork(accept.network)!;\n if (!typedNetwork) {\n return x402Err(surface, {\n cause: 'parse_payment_required' as const,\n message: `Invalid network: ${accept.network}`,\n });\n }\n\n const beforePaymentResult = await beforePayment({\n options,\n balanceInput:\n typedNetwork === Network.SOLANA\n ? {\n address: wallets.svm.address,\n network: Network.SOLANA,\n }\n : {\n address: wallets.evm.address,\n network: typedNetwork,\n },\n amount,\n protocol: PaymentProtocol.X402,\n });\n\n if (beforePaymentResult.isErr()) {\n return beforePaymentResult;\n }\n }\n\n const paymentPayloadResult = await safeCreatePaymentPayload(\n surface,\n wallets,\n paymentRequired,\n accept ? () => accept : undefined\n );\n\n if (paymentPayloadResult.isErr()) {\n return paymentPayloadResult;\n }\n\n const paymentPayload = paymentPayloadResult.value;\n\n // Encode payment header\n const paymentHeaders =\n x402ProbeClient.encodePaymentSignatureHeader(paymentPayload);\n\n // Check if this is already a retry to prevent infinite loops\n if (\n request.headers.has('PAYMENT-SIGNATURE') ||\n request.headers.has('X-PAYMENT')\n ) {\n return x402Err(surface, {\n cause: 'payment_already_attempted',\n message: 'Payment already attempted',\n });\n }\n\n // Add payment headers to cloned request\n for (const [key, value] of Object.entries(paymentHeaders)) {\n request.headers.set(key, value);\n }\n request.headers.set(\n 'Access-Control-Expose-Headers',\n 'PAYMENT-RESPONSE,X-PAYMENT-RESPONSE'\n );\n\n // Retry the request with payment\n return await safeFetch(surface, request, timeout).andThen(paidResponse => {\n const settlementResult = safeGetPaymentSettlement(surface, paidResponse);\n\n return x402Ok<ExecuteFetchResult>({\n response: paidResponse,\n paymentInfo: {\n protocol: PaymentProtocol.X402,\n network: caip2ToNetwork(paymentPayload.accepted.network)!,\n price: tokenStringToNumber(\n paymentPayload.accepted.amount\n ).toLocaleString('en-US', {\n style: 'currency',\n currency: 'USD',\n }),\n payment: settlementResult.isOk()\n ? {\n success: settlementResult.value.success,\n transactionHash: settlementResult.value.transaction,\n }\n : null,\n },\n });\n });\n}\n","import { detectPaymentProtocols } from '@/shared/protocols/detect';\nimport { handleMppPayment } from '@/shared/protocols/mpp/handle-payment';\nimport { pickByBalance } from '@/shared/protocols/pick';\nimport { PaymentProtocol } from '@/shared/protocols/types';\nimport { handleX402Payment } from '@/shared/protocols/x402/handle-payment';\n\nimport type { ExecuteFetchOptions } from './types';\n\nexport async function executePayment(\n response: Response,\n request: Request,\n options: ExecuteFetchOptions\n) {\n const { paymentProtocol } = options.params;\n\n const params = {\n response,\n request,\n options,\n };\n\n if (paymentProtocol) {\n return handlerMap[paymentProtocol](params);\n }\n\n const available = detectPaymentProtocols(response);\n const preferred =\n available.length === 1\n ? available[0]!\n : await pickByBalance(response, options);\n const fallback =\n available.length > 1\n ? preferred === PaymentProtocol.MPP\n ? PaymentProtocol.X402\n : PaymentProtocol.MPP\n : null;\n\n const fallbackRetryRequest = fallback ? request.clone() : null;\n const result = await handlerMap[preferred](params);\n\n if (result.isErr() && fallback && fallbackRetryRequest) {\n return handlerMap[fallback]({\n ...params,\n request: fallbackRetryRequest,\n });\n }\n\n return result;\n}\n\nconst handlerMap = {\n [PaymentProtocol.MPP]: handleMppPayment,\n [PaymentProtocol.X402]: handleX402Payment,\n};\n","import { fetchErr, fetchOk, safeFetch } from '@/shared/neverthrow/fetch';\nimport { BLACKLISTED_ORIGINS } from '@/shared/origins';\n\nimport { attemptSiwxAuth } from './auth';\nimport { executePayment } from './payment';\n\nimport type { ExecuteFetchOptions } from './types';\nimport { buildRequest } from '@/shared/request/build';\nimport type { RequestInput } from '@/shared/request/types';\n\n/**\n * Executes a request with automatic SIWX authentication and payment handling.\n *\n * 1. Probe the endpoint\n * 2. If 402 with SIWX challenge, retry with SIGN-IN-WITH-X\n * 3. If still 402, execute payment\n */\nexport async function executeFetch(\n input: RequestInput,\n options: ExecuteFetchOptions\n) {\n const request = buildRequest(input, options);\n\n const { surface } = options;\n const { timeout } = options.params;\n\n const blocked = BLACKLISTED_ORIGINS.find(origin =>\n request.url.startsWith(origin)\n );\n if (blocked) {\n return fetchErr(surface, {\n cause: 'network',\n message: `${blocked} is no longer available. This origin has been deprecated.`,\n });\n }\n\n const authRetryRequest = request.clone();\n const paymentRetryRequest = request.clone();\n\n const probeResult = await safeFetch(surface, request, timeout);\n\n if (probeResult.isErr()) {\n return fetchErr(surface, probeResult.error);\n }\n\n const initialResponse = probeResult.value;\n if (initialResponse.status !== 402) {\n return fetchOk({\n response: initialResponse,\n paymentInfo: null,\n });\n }\n\n const authResult = await attemptSiwxAuth(\n initialResponse,\n authRetryRequest,\n paymentRetryRequest,\n options\n );\n\n if (authResult.isErr()) {\n return authResult;\n }\n\n const latestResponse = authResult.value.response;\n if (latestResponse.status !== 402) {\n return fetchOk({\n response: latestResponse,\n paymentInfo: null,\n });\n }\n\n return executePayment(\n latestResponse,\n authResult.value.paymentRetryRequest,\n options\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,wBAAwB;;;ACQjC,SAAS,YAAY,sBAAsB;AAE3C,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAElC,SAAS,sBAAsB;;;ACb/B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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CAAC;AAAA,EACH;AAEA,QAAM,mBAAmB,QAAQ,MAAM;AACvC,QAAM,sBAAsB,QAAQ,MAAM;AAE1C,QAAM,cAAc,MAAM,UAAU,SAAS,SAAS,OAAO;AAE7D,MAAI,YAAY,MAAM,GAAG;AACvB,WAAO,SAAS,SAAS,YAAY,KAAK;AAAA,EAC5C;AAEA,QAAM,kBAAkB,YAAY;AACpC,MAAI,gBAAgB,WAAW,KAAK;AAClC,WAAO,QAAQ;AAAA,MACb,UAAU;AAAA,MACV,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AAEA,QAAM,aAAa,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,WAAW,MAAM,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,iBAAiB,WAAW,MAAM;AACxC,MAAI,eAAe,WAAW,KAAK;AACjC,WAAO,QAAQ;AAAA,MACb,UAAU;AAAA,MACV,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,IACA,WAAW,MAAM;AAAA,IACjB;AAAA,EACF;AACF;","names":["tx","http","errorType"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
configFile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YWNBUUBR.js";
|
|
4
4
|
|
|
5
5
|
// src/shared/state.ts
|
|
6
6
|
import z from "zod";
|
|
@@ -32,4 +32,4 @@ export {
|
|
|
32
32
|
getState,
|
|
33
33
|
setState
|
|
34
34
|
};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-ISF2WVEZ.js.map
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
safeRmSync,
|
|
10
10
|
safeSymlink,
|
|
11
11
|
safeUnlinkSync
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QZCSZB7E.js";
|
|
13
13
|
import {
|
|
14
14
|
err,
|
|
15
15
|
ok
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YWNBUUBR.js";
|
|
17
17
|
|
|
18
18
|
// src/shared/skills/core/agents.ts
|
|
19
19
|
import * as os from "os";
|
|
@@ -381,4 +381,4 @@ export {
|
|
|
381
381
|
detectAgents,
|
|
382
382
|
installSkills
|
|
383
383
|
};
|
|
384
|
-
//# sourceMappingURL=chunk-
|
|
384
|
+
//# sourceMappingURL=chunk-JAA6JEF2.js.map
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
} from "./chunk-DZNSJ2BA.js";
|
|
4
4
|
import {
|
|
5
5
|
redeemInviteCode
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AWFBYDYO.js";
|
|
7
|
+
import {
|
|
8
|
+
getDepositLink
|
|
9
|
+
} from "./chunk-PBVLTOFS.js";
|
|
7
10
|
import {
|
|
8
11
|
EVM_CONFIGS,
|
|
9
12
|
getTxExplorerUrl
|
|
10
13
|
} from "./chunk-NPJV7AMV.js";
|
|
11
|
-
import {
|
|
12
|
-
getDepositLink
|
|
13
|
-
} from "./chunk-QZBSRYSW.js";
|
|
14
14
|
|
|
15
15
|
// src/cli/lib/deposit.ts
|
|
16
16
|
import chalk from "chalk";
|
|
@@ -106,4 +106,4 @@ var promptDeposit = async (surface, args, wallets) => {
|
|
|
106
106
|
export {
|
|
107
107
|
promptDeposit
|
|
108
108
|
};
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
109
|
+
//# sourceMappingURL=chunk-JOIAQY6V.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
configFile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YWNBUUBR.js";
|
|
4
4
|
|
|
5
5
|
// src/shared/settings.ts
|
|
6
6
|
import z from "zod";
|
|
@@ -34,4 +34,4 @@ export {
|
|
|
34
34
|
setSettings,
|
|
35
35
|
DEFAULT_MAX_AMOUNT
|
|
36
36
|
};
|
|
37
|
-
//# sourceMappingURL=chunk-
|
|
37
|
+
//# sourceMappingURL=chunk-JX2XE6FD.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getState
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ISF2WVEZ.js";
|
|
4
4
|
import {
|
|
5
5
|
getBalance
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
Network
|
|
9
|
-
} from "./chunk-NPJV7AMV.js";
|
|
6
|
+
} from "./chunk-MYWE3P7R.js";
|
|
10
7
|
import {
|
|
11
8
|
getBaseUrl,
|
|
12
9
|
getDepositLink
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PBVLTOFS.js";
|
|
11
|
+
import {
|
|
12
|
+
Network
|
|
13
|
+
} from "./chunk-NPJV7AMV.js";
|
|
14
14
|
|
|
15
15
|
// src/operations/onboarding-cta.ts
|
|
16
16
|
function shouldShowOnboardingCta(totalBalance) {
|
|
@@ -90,4 +90,4 @@ export {
|
|
|
90
90
|
getBalances,
|
|
91
91
|
listAccountsWithBalances
|
|
92
92
|
};
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-KPJJSNZO.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
err,
|
|
3
3
|
resultFromThrowable
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YWNBUUBR.js";
|
|
5
5
|
|
|
6
6
|
// src/shared/neverthrow/json/index.ts
|
|
7
7
|
var type = "json";
|
|
@@ -42,4 +42,4 @@ export {
|
|
|
42
42
|
safeParseJson,
|
|
43
43
|
safeToJsonObject
|
|
44
44
|
};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-KVSTJRSJ.js.map
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getBaseUrl,
|
|
3
|
+
safeFetchJson
|
|
4
|
+
} from "./chunk-PBVLTOFS.js";
|
|
1
5
|
import {
|
|
2
6
|
ALL_NETWORK_CONFIGS,
|
|
3
7
|
EVM_CONFIGS,
|
|
@@ -5,10 +9,6 @@ import {
|
|
|
5
9
|
networkSchema,
|
|
6
10
|
solanaAddressSchema
|
|
7
11
|
} from "./chunk-NPJV7AMV.js";
|
|
8
|
-
import {
|
|
9
|
-
getBaseUrl,
|
|
10
|
-
safeFetchJson
|
|
11
|
-
} from "./chunk-QZBSRYSW.js";
|
|
12
12
|
|
|
13
13
|
// ../../internal/balance/src/index.ts
|
|
14
14
|
import { z } from "zod";
|
|
@@ -57,4 +57,4 @@ var getBalance = async (surface, input, flags) => {
|
|
|
57
57
|
export {
|
|
58
58
|
getBalance
|
|
59
59
|
};
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-MYWE3P7R.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
discoverResources
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UMYAGSWZ.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-
|
|
55
|
+
//# sourceMappingURL=chunk-NC4UN6IF.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
installSkills
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JAA6JEF2.js";
|
|
4
|
+
import {
|
|
5
|
+
safeFetch,
|
|
6
|
+
safeFetchJson
|
|
7
|
+
} from "./chunk-PBVLTOFS.js";
|
|
4
8
|
import {
|
|
5
9
|
safeMkdir,
|
|
6
10
|
safeMkdtemp,
|
|
7
11
|
safeRm,
|
|
8
12
|
safeWriteFile
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
safeFetch,
|
|
12
|
-
safeFetchJson
|
|
13
|
-
} from "./chunk-QZBSRYSW.js";
|
|
13
|
+
} from "./chunk-QZCSZB7E.js";
|
|
14
14
|
import {
|
|
15
15
|
err,
|
|
16
16
|
ok,
|
|
17
17
|
resultFromPromise
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-YWNBUUBR.js";
|
|
19
19
|
|
|
20
20
|
// src/shared/skills/github.ts
|
|
21
21
|
import * as os from "os";
|
|
@@ -163,4 +163,4 @@ async function installGitHubSkill(surface, source, options) {
|
|
|
163
163
|
export {
|
|
164
164
|
installGitHubSkill
|
|
165
165
|
};
|
|
166
|
-
//# sourceMappingURL=chunk-
|
|
166
|
+
//# sourceMappingURL=chunk-O3OVWMBY.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
safeParse
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-F3KGAMIA.js";
|
|
4
4
|
import {
|
|
5
5
|
err,
|
|
6
6
|
ok,
|
|
7
7
|
resultFromPromise
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YWNBUUBR.js";
|
|
9
9
|
|
|
10
10
|
// src/shared/neverthrow/fetch/index.ts
|
|
11
11
|
import contentType from "content-type";
|
|
@@ -152,4 +152,4 @@ export {
|
|
|
152
152
|
getDepositLink,
|
|
153
153
|
tokenStringToNumber
|
|
154
154
|
};
|
|
155
|
-
//# sourceMappingURL=chunk-
|
|
155
|
+
//# sourceMappingURL=chunk-PBVLTOFS.js.map
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
configFile
|
|
3
|
-
} from "./chunk-VDBUUHJF.js";
|
|
4
|
-
import {
|
|
5
|
-
isVerbose
|
|
6
|
-
} from "./chunk-ITCDZXBZ.js";
|
|
7
|
-
import {
|
|
2
|
+
configFile,
|
|
8
3
|
err,
|
|
9
4
|
resultFromPromise,
|
|
10
5
|
resultFromThrowable
|
|
11
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YWNBUUBR.js";
|
|
7
|
+
import {
|
|
8
|
+
isVerbose
|
|
9
|
+
} from "./chunk-ITCDZXBZ.js";
|
|
12
10
|
|
|
13
11
|
// src/shared/neverthrow/fs/index.ts
|
|
14
12
|
import {
|
|
@@ -166,4 +164,4 @@ export {
|
|
|
166
164
|
safeRealpathSync,
|
|
167
165
|
log
|
|
168
166
|
};
|
|
169
|
-
//# sourceMappingURL=chunk-
|
|
167
|
+
//# sourceMappingURL=chunk-QZCSZB7E.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shared/neverthrow/fs/index.ts","../../src/shared/log.ts"],"sourcesContent":["import {\n readFile,\n writeFile,\n appendFile,\n chmod,\n mkdir,\n mkdtemp,\n rm,\n copyFile,\n cp,\n symlink,\n lstat,\n unlink,\n realpath,\n readdir,\n} from 'fs/promises';\nimport {\n existsSync,\n lstatSync,\n realpathSync,\n rmSync,\n unlinkSync,\n} from 'node:fs';\n\nimport {\n err,\n resultFromPromise,\n resultFromThrowable,\n} from '@agentcash/neverthrow';\n\nimport type { BaseFileSystemError } from './types';\n\nconst errorType = 'fs';\n\nexport const fsErr = (surface: string, error: BaseFileSystemError) =>\n err(errorType, surface, error);\n\nconst fsResultFromPromise = <T>(\n surface: string,\n promise: Promise<T>,\n error: (e: unknown) => BaseFileSystemError\n) => resultFromPromise(errorType, surface, promise, error);\n\nconst fsResultFromThrowable = <T>(\n surface: string,\n fn: () => T,\n error: (e: unknown) => BaseFileSystemError\n) => resultFromThrowable(errorType, surface, fn, error);\n\nexport const safeReadFile = (\n surface: string,\n path: Parameters<typeof readFile>[0]\n) =>\n fsResultFromPromise(surface, readFile(path, 'utf-8'), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to read file',\n }));\n\nexport const safeWriteFile = (\n surface: string,\n ...args: Parameters<typeof writeFile>\n) =>\n fsResultFromPromise(surface, writeFile(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to write file',\n }));\n\nexport const safeAppendFile = (\n surface: string,\n ...args: Parameters<typeof appendFile>\n) =>\n fsResultFromPromise(surface, appendFile(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to append file',\n }));\n\nexport const safeChmod = (surface: string, ...args: Parameters<typeof chmod>) =>\n fsResultFromPromise(surface, chmod(...args), () => ({\n cause: 'file_not_chmodable',\n message: 'Failed to chmod file',\n }));\n\nexport const safeMkdir = (surface: string, ...args: Parameters<typeof mkdir>) =>\n fsResultFromPromise(surface, mkdir(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to create directory',\n }));\n\nexport const safeMkdtemp = (\n surface: string,\n ...args: Parameters<typeof mkdtemp>\n) =>\n fsResultFromPromise(surface, mkdtemp(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to create temporary directory',\n }));\n\nexport const safeRm = (surface: string, ...args: Parameters<typeof rm>) =>\n fsResultFromPromise(surface, rm(...args), () => ({\n cause: 'file_not_deletable',\n message: 'Failed to remove file',\n }));\n\nexport const safeCopyFile = (\n surface: string,\n ...args: Parameters<typeof copyFile>\n) =>\n fsResultFromPromise(surface, copyFile(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_copyable',\n message: 'Failed to copy file',\n }));\n\nexport const safeCp = (surface: string, ...args: Parameters<typeof cp>) =>\n fsResultFromPromise(surface, cp(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_copyable',\n message: 'Failed to copy file',\n }));\n\nexport const safeSymlink = (\n surface: string,\n ...args: Parameters<typeof symlink>\n) =>\n fsResultFromPromise(surface, symlink(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to create symlink',\n }));\n\nexport const safeLstat = (surface: string, ...args: Parameters<typeof lstat>) =>\n fsResultFromPromise(surface, lstat(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to stat file',\n }));\n\nexport const safeUnlink = (\n surface: string,\n ...args: Parameters<typeof unlink>\n) =>\n fsResultFromPromise(surface, unlink(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_deletable',\n message: 'Failed to unlink file',\n }));\n\nexport const safeRealpath = (\n surface: string,\n ...args: Parameters<typeof realpath>\n) =>\n fsResultFromPromise(surface, realpath(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to resolve real path',\n }));\n\nexport const safeReaddir = (\n surface: string,\n ...args: Parameters<typeof readdir>\n) =>\n fsResultFromPromise(surface, readdir(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? ('file_not_found' as const)\n : ('file_not_readable' as const),\n message: 'Failed to read directory',\n }));\n\nexport const safeReadDirents = (\n surface: string,\n dirPath: Parameters<typeof readdir>[0]\n) =>\n fsResultFromPromise(\n surface,\n readdir(dirPath, { encoding: 'utf8', withFileTypes: true }),\n error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to read directory',\n })\n );\n\nexport const pathExists = (...args: Parameters<typeof existsSync>) =>\n existsSync(...args);\n\nexport const safeLstatSync = (\n surface: string,\n ...args: Parameters<typeof lstatSync>\n) =>\n fsResultFromThrowable(\n surface,\n () => lstatSync(...args),\n error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to stat file',\n })\n );\n\nexport const safeUnlinkSync = (\n surface: string,\n ...args: Parameters<typeof unlinkSync>\n) =>\n fsResultFromThrowable(\n surface,\n () => unlinkSync(...args),\n error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_deletable',\n message: 'Failed to unlink file',\n })\n );\n\nexport const safeRmSync = (\n surface: string,\n ...args: Parameters<typeof rmSync>\n) =>\n fsResultFromThrowable(\n surface,\n () => rmSync(...args),\n () => ({\n cause: 'file_not_deletable',\n message: 'Failed to remove file',\n })\n );\n\nexport const safeRealpathSync = (\n surface: string,\n ...args: Parameters<typeof realpathSync>\n) =>\n fsResultFromThrowable(\n surface,\n () => realpathSync(...args),\n error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to resolve real path',\n })\n );\n","import { resultFromThrowable } from '@agentcash/neverthrow';\n\nimport { safeAppendFile } from '@/shared/neverthrow/fs';\n\nimport { configFile } from './fs';\nimport { isVerbose } from '@/cli/lib/context';\n\n/**\n * Resolved lazily on first write. `null` means the filesystem is\n * unavailable (e.g. Vercel sandbox) — file logging is skipped.\n */\nlet logFile: string | null | undefined;\n\nfunction getLogFile(): string | null {\n if (logFile === undefined) {\n const result = resultFromThrowable(\n 'log',\n 'log',\n () => configFile('mcp.log'),\n e => ({\n cause: 'log_init' as const,\n message: e instanceof Error ? e.message : String(e),\n })\n );\n logFile = result.isOk() ? result.value : null;\n }\n return logFile;\n}\n\nfunction format(args: unknown[]): string {\n return args\n .map(a =>\n typeof a === 'object' && a !== null ? JSON.stringify(a) : String(a)\n )\n .join(' ');\n}\n\nfunction write(level: string, msg: string, args: unknown[]): void {\n const formatted = args.length ? `${msg} ${format(args)}` : msg;\n const line = `[${new Date().toISOString()}] [${level}] ${formatted}\\n`;\n const file = getLogFile();\n if (file) safeAppendFile('log', file, line);\n if (isVerbose()) {\n console.error(`[agentcash] ${formatted}`);\n }\n}\n\nexport const log = {\n info: (msg: string, ...args: unknown[]) => write('INFO', msg, args),\n error: (msg: string, ...args: unknown[]) => write('ERROR', msg, args),\n debug: (msg: string, ...args: unknown[]) =>\n isVerbose() && write('DEBUG', msg, args),\n get path() {\n return getLogFile();\n },\n};\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP,IAAM,YAAY;AAEX,IAAM,QAAQ,CAAC,SAAiB,UACrC,IAAI,WAAW,SAAS,KAAK;AAE/B,IAAM,sBAAsB,CAC1B,SACA,SACA,UACG,kBAAkB,WAAW,SAAS,SAAS,KAAK;AAEzD,IAAM,wBAAwB,CAC5B,SACA,IACA,UACG,oBAAoB,WAAW,SAAS,IAAI,KAAK;AAE/C,IAAM,eAAe,CAC1B,SACA,SAEA,oBAAoB,SAAS,SAAS,MAAM,OAAO,GAAG,YAAU;AAAA,EAC9D,OACG,MAAgC,SAAS,WACtC,mBACA;AAAA,EACN,SAAS;AACX,EAAE;AAEG,IAAM,gBAAgB,CAC3B,YACG,SAEH,oBAAoB,SAAS,UAAU,GAAG,IAAI,GAAG,OAAO;AAAA,EACtD,OAAO;AAAA,EACP,SAAS;AACX,EAAE;AAEG,IAAM,iBAAiB,CAC5B,YACG,SAEH,oBAAoB,SAAS,WAAW,GAAG,IAAI,GAAG,OAAO;AAAA,EACvD,OAAO;AAAA,EACP,SAAS;AACX,EAAE;AAEG,IAAM,YAAY,CAAC,YAAoB,SAC5C,oBAAoB,SAAS,MAAM,GAAG,IAAI,GAAG,OAAO;AAAA,EAClD,OAAO;AAAA,EACP,SAAS;AACX,EAAE;AAEG,IAAM,YAAY,CAAC,YAAoB,SAC5C,oBAAoB,SAAS,MAAM,GAAG,IAAI,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.ts","../../src/shared/log.ts"],"sourcesContent":["import {\n readFile,\n writeFile,\n appendFile,\n chmod,\n mkdir,\n mkdtemp,\n rm,\n copyFile,\n cp,\n symlink,\n lstat,\n unlink,\n realpath,\n readdir,\n} from 'fs/promises';\nimport {\n existsSync,\n lstatSync,\n realpathSync,\n rmSync,\n unlinkSync,\n} from 'node:fs';\n\nimport {\n err,\n resultFromPromise,\n resultFromThrowable,\n} from '@agentcash/neverthrow';\n\nimport type { BaseFileSystemError } from './types';\n\nconst errorType = 'fs';\n\nexport const fsErr = (surface: string, error: BaseFileSystemError) =>\n err(errorType, surface, error);\n\nconst fsResultFromPromise = <T>(\n surface: string,\n promise: Promise<T>,\n error: (e: unknown) => BaseFileSystemError\n) => resultFromPromise(errorType, surface, promise, error);\n\nconst fsResultFromThrowable = <T>(\n surface: string,\n fn: () => T,\n error: (e: unknown) => BaseFileSystemError\n) => resultFromThrowable(errorType, surface, fn, error);\n\nexport const safeReadFile = (\n surface: string,\n path: Parameters<typeof readFile>[0]\n) =>\n fsResultFromPromise(surface, readFile(path, 'utf-8'), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to read file',\n }));\n\nexport const safeWriteFile = (\n surface: string,\n ...args: Parameters<typeof writeFile>\n) =>\n fsResultFromPromise(surface, writeFile(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to write file',\n }));\n\nexport const safeAppendFile = (\n surface: string,\n ...args: Parameters<typeof appendFile>\n) =>\n fsResultFromPromise(surface, appendFile(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to append file',\n }));\n\nexport const safeChmod = (surface: string, ...args: Parameters<typeof chmod>) =>\n fsResultFromPromise(surface, chmod(...args), () => ({\n cause: 'file_not_chmodable',\n message: 'Failed to chmod file',\n }));\n\nexport const safeMkdir = (surface: string, ...args: Parameters<typeof mkdir>) =>\n fsResultFromPromise(surface, mkdir(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to create directory',\n }));\n\nexport const safeMkdtemp = (\n surface: string,\n ...args: Parameters<typeof mkdtemp>\n) =>\n fsResultFromPromise(surface, mkdtemp(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to create temporary directory',\n }));\n\nexport const safeRm = (surface: string, ...args: Parameters<typeof rm>) =>\n fsResultFromPromise(surface, rm(...args), () => ({\n cause: 'file_not_deletable',\n message: 'Failed to remove file',\n }));\n\nexport const safeCopyFile = (\n surface: string,\n ...args: Parameters<typeof copyFile>\n) =>\n fsResultFromPromise(surface, copyFile(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_copyable',\n message: 'Failed to copy file',\n }));\n\nexport const safeCp = (surface: string, ...args: Parameters<typeof cp>) =>\n fsResultFromPromise(surface, cp(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_copyable',\n message: 'Failed to copy file',\n }));\n\nexport const safeSymlink = (\n surface: string,\n ...args: Parameters<typeof symlink>\n) =>\n fsResultFromPromise(surface, symlink(...args), () => ({\n cause: 'file_not_writable',\n message: 'Failed to create symlink',\n }));\n\nexport const safeLstat = (surface: string, ...args: Parameters<typeof lstat>) =>\n fsResultFromPromise(surface, lstat(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to stat file',\n }));\n\nexport const safeUnlink = (\n surface: string,\n ...args: Parameters<typeof unlink>\n) =>\n fsResultFromPromise(surface, unlink(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_deletable',\n message: 'Failed to unlink file',\n }));\n\nexport const safeRealpath = (\n surface: string,\n ...args: Parameters<typeof realpath>\n) =>\n fsResultFromPromise(surface, realpath(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to resolve real path',\n }));\n\nexport const safeReaddir = (\n surface: string,\n ...args: Parameters<typeof readdir>\n) =>\n fsResultFromPromise(surface, readdir(...args), error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? ('file_not_found' as const)\n : ('file_not_readable' as const),\n message: 'Failed to read directory',\n }));\n\nexport const safeReadDirents = (\n surface: string,\n dirPath: Parameters<typeof readdir>[0]\n) =>\n fsResultFromPromise(\n surface,\n readdir(dirPath, { encoding: 'utf8', withFileTypes: true }),\n error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to read directory',\n })\n );\n\nexport const pathExists = (...args: Parameters<typeof existsSync>) =>\n existsSync(...args);\n\nexport const safeLstatSync = (\n surface: string,\n ...args: Parameters<typeof lstatSync>\n) =>\n fsResultFromThrowable(\n surface,\n () => lstatSync(...args),\n error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to stat file',\n })\n );\n\nexport const safeUnlinkSync = (\n surface: string,\n ...args: Parameters<typeof unlinkSync>\n) =>\n fsResultFromThrowable(\n surface,\n () => unlinkSync(...args),\n error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_deletable',\n message: 'Failed to unlink file',\n })\n );\n\nexport const safeRmSync = (\n surface: string,\n ...args: Parameters<typeof rmSync>\n) =>\n fsResultFromThrowable(\n surface,\n () => rmSync(...args),\n () => ({\n cause: 'file_not_deletable',\n message: 'Failed to remove file',\n })\n );\n\nexport const safeRealpathSync = (\n surface: string,\n ...args: Parameters<typeof realpathSync>\n) =>\n fsResultFromThrowable(\n surface,\n () => realpathSync(...args),\n error => ({\n cause:\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n ? 'file_not_found'\n : 'file_not_readable',\n message: 'Failed to resolve real path',\n })\n );\n","import { resultFromThrowable } from '@agentcash/neverthrow';\n\nimport { safeAppendFile } from '@/shared/neverthrow/fs';\n\nimport { configFile } from './fs';\nimport { isVerbose } from '@/cli/lib/context';\n\n/**\n * Resolved lazily on first write. `null` means the filesystem is\n * unavailable (e.g. Vercel sandbox) — file logging is skipped.\n */\nlet logFile: string | null | undefined;\n\nfunction getLogFile(): string | null {\n if (logFile === undefined) {\n const result = resultFromThrowable(\n 'log',\n 'log',\n () => configFile('mcp.log'),\n e => ({\n cause: 'log_init' as const,\n message: e instanceof Error ? e.message : String(e),\n })\n );\n logFile = result.isOk() ? result.value : null;\n }\n return logFile;\n}\n\nfunction format(args: unknown[]): string {\n return args\n .map(a =>\n typeof a === 'object' && a !== null ? JSON.stringify(a) : String(a)\n )\n .join(' ');\n}\n\nfunction write(level: string, msg: string, args: unknown[]): void {\n const formatted = args.length ? `${msg} ${format(args)}` : msg;\n const line = `[${new Date().toISOString()}] [${level}] ${formatted}\\n`;\n const file = getLogFile();\n if (file) safeAppendFile('log', file, line);\n if (isVerbose()) {\n console.error(`[agentcash] ${formatted}`);\n }\n}\n\nexport const log = {\n info: (msg: string, ...args: unknown[]) => write('INFO', msg, args),\n error: (msg: string, ...args: unknown[]) => write('ERROR', msg, args),\n debug: (msg: string, ...args: unknown[]) =>\n isVerbose() && write('DEBUG', msg, args),\n get path() {\n return getLogFile();\n },\n};\n"],"mappings":";;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP,IAAM,YAAY;AAEX,IAAM,QAAQ,CAAC,SAAiB,UACrC,IAAI,WAAW,SAAS,KAAK;AAE/B,IAAM,sBAAsB,CAC1B,SACA,SACA,UACG,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OAAO,CAAC;AAAA,EACpE,EACC,KAAK,GAAG;AACb;AAEA,SAAS,MAAM,OAAe,KAAa,MAAuB;AAChE,QAAM,YAAY,KAAK,SAAS,GAAG,GAAG,IAAI,OAAO,IAAI,CAAC,KAAK;AAC3D,QAAM,OAAO,KAAI,oBAAI,KAAK,GAAE,YAAY,CAAC,MAAM,KAAK,KAAK,SAAS;AAAA;AAClE,QAAM,OAAO,WAAW;AACxB,MAAI,KAAM,gBAAe,OAAO,MAAM,IAAI;AAC1C,MAAI,UAAU,GAAG;AACf,YAAQ,MAAM,eAAe,SAAS,EAAE;AAAA,EAC1C;AACF;AAEO,IAAM,MAAM;AAAA,EACjB,MAAM,CAAC,QAAgB,SAAoB,MAAM,QAAQ,KAAK,IAAI;AAAA,EAClE,OAAO,CAAC,QAAgB,SAAoB,MAAM,SAAS,KAAK,IAAI;AAAA,EACpE,OAAO,CAAC,QAAgB,SACtB,UAAU,KAAK,MAAM,SAAS,KAAK,IAAI;AAAA,EACzC,IAAI,OAAO;AACT,WAAO,WAAW;AAAA,EACpB;AACF;","names":[]}
|
|
@@ -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 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":";AAoBO,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":[]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
executeFetch
|
|
3
|
-
} from "./chunk-Q5SPIJGE.js";
|
|
4
|
-
import {
|
|
5
|
-
log
|
|
6
|
-
} from "./chunk-Y4VZACTC.js";
|
|
7
1
|
import {
|
|
8
2
|
TOOL_PARAMS
|
|
9
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X2JUL4S3.js";
|
|
4
|
+
import {
|
|
5
|
+
executeFetch
|
|
6
|
+
} from "./chunk-IPBR36VR.js";
|
|
10
7
|
import {
|
|
11
8
|
safeParseResponse
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PBVLTOFS.js";
|
|
10
|
+
import {
|
|
11
|
+
log
|
|
12
|
+
} from "./chunk-QZCSZB7E.js";
|
|
13
13
|
|
|
14
14
|
// src/operations/search.ts
|
|
15
15
|
import z from "zod";
|
|
@@ -81,4 +81,4 @@ export {
|
|
|
81
81
|
searchSchema,
|
|
82
82
|
search
|
|
83
83
|
};
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
84
|
+
//# sourceMappingURL=chunk-UBVHQSSW.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
log
|
|
3
|
-
} from "./chunk-Y4VZACTC.js";
|
|
4
1
|
import {
|
|
5
2
|
TOOL_PARAMS
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X2JUL4S3.js";
|
|
7
4
|
import {
|
|
8
5
|
zodUrl
|
|
9
6
|
} from "./chunk-FB5CMO3J.js";
|
|
7
|
+
import {
|
|
8
|
+
log
|
|
9
|
+
} from "./chunk-QZCSZB7E.js";
|
|
10
10
|
|
|
11
11
|
// src/operations/discover.ts
|
|
12
12
|
import { discoverOriginSchema, GuidanceMode } from "@agentcash/discovery";
|
|
@@ -46,4 +46,4 @@ export {
|
|
|
46
46
|
discoverResourcesSchema,
|
|
47
47
|
discoverResources
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-UMYAGSWZ.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RequestMethod
|
|
3
|
-
} from "./chunk-LNJIXYCU.js";
|
|
4
1
|
import {
|
|
5
2
|
REQUEST_FETCH_PARAMS,
|
|
6
3
|
REQUEST_PARAMS
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-X2JUL4S3.js";
|
|
5
|
+
import {
|
|
6
|
+
RequestMethod
|
|
7
|
+
} from "./chunk-LNJIXYCU.js";
|
|
8
8
|
import {
|
|
9
9
|
zodUrl
|
|
10
10
|
} from "./chunk-FB5CMO3J.js";
|
|
@@ -40,4 +40,4 @@ export {
|
|
|
40
40
|
paymentProtocols,
|
|
41
41
|
fetchShape
|
|
42
42
|
};
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-VX6PPHSN.js.map
|
|
@@ -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.13.
|
|
7
|
+
return "0.13.2";
|
|
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-
|
|
26
|
+
//# sourceMappingURL=chunk-WRMSVC2R.js.map
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// src/shared/origins.ts
|
|
2
|
-
var BLACKLISTED_ORIGINS = [
|
|
3
|
-
"https://twit.sh",
|
|
4
|
-
"https://x402.twit.sh"
|
|
5
|
-
];
|
|
6
|
-
|
|
7
1
|
// src/shared/descriptions.ts
|
|
8
2
|
var ORIGIN_METADATA = {
|
|
9
3
|
["https://stableenrich.dev" /* StableEnrich */]: {
|
|
@@ -123,7 +117,7 @@ ${PRIMARY_ORIGINS.flatMap((o) => ORIGIN_METADATA[o] ? [` ${o} \u2014 ${ORIGIN_M
|
|
|
123
117
|
search: {
|
|
124
118
|
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.
|
|
125
119
|
|
|
126
|
-
|
|
120
|
+
Only 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 \u2192 StableEnrich, image generation \u2192 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.`,
|
|
127
121
|
cli: `Search for paid API services by natural language query. Returns matching origins with endpoints and pricing. Use this to find APIs before calling discover or fetch.`
|
|
128
122
|
},
|
|
129
123
|
reportError: {
|
|
@@ -143,7 +137,7 @@ var WORKFLOW = [
|
|
|
143
137
|
`Workflow:`,
|
|
144
138
|
`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.`,
|
|
145
139
|
`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.`,
|
|
146
|
-
`3. If the task
|
|
140
|
+
`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 \u2014 go straight to step 4.`,
|
|
147
141
|
`4. Call discover_api_endpoints() to get the endpoint index \u2014 a list of available routes with descriptions and auth modes. The auth mode is advisory and tells you what the route may require.`,
|
|
148
142
|
`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.`,
|
|
149
143
|
`6. Call fetch with the correct input schema. It will attempt SIWX first when available and only pay if the route still returns 402.`
|
|
@@ -241,7 +235,6 @@ var TOOL_PARAMS = {
|
|
|
241
235
|
};
|
|
242
236
|
|
|
243
237
|
export {
|
|
244
|
-
BLACKLISTED_ORIGINS,
|
|
245
238
|
ORIGIN_METADATA,
|
|
246
239
|
PRIMARY_ORIGINS,
|
|
247
240
|
DESCRIPTIONS,
|
|
@@ -250,4 +243,4 @@ export {
|
|
|
250
243
|
REQUEST_FETCH_PARAMS,
|
|
251
244
|
TOOL_PARAMS
|
|
252
245
|
};
|
|
253
|
-
//# sourceMappingURL=chunk-
|
|
246
|
+
//# sourceMappingURL=chunk-X2JUL4S3.js.map
|