@zkp2p/cash 0.1.2 → 0.1.4
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/AGENTS.md +92 -28
- package/README.md +69 -25
- package/dist/chunk-P3KYZ2FX.js +373 -0
- package/dist/{createCashClient-iHuGgjH_.d.cts → createCashClient-BbkfxILl.d.cts} +37 -8
- package/dist/{createCashClient-iHuGgjH_.d.ts → createCashClient-BbkfxILl.d.ts} +37 -8
- package/dist/index.cjs +1099 -254
- package/dist/index.d.cts +1554 -74
- package/dist/index.d.ts +1554 -74
- package/dist/index.js +886 -248
- package/dist/react.cjs +239 -59
- package/dist/react.d.cts +6 -4
- package/dist/react.d.ts +6 -4
- package/dist/react.js +236 -59
- package/dist/tools.cjs +36 -36
- package/dist/tools.d.cts +282 -3
- package/dist/tools.d.ts +282 -3
- package/dist/tools.js +36 -36
- package/docs/lifecycle-and-recovery.md +278 -0
- package/examples/agent-tool-use.ts +122 -0
- package/examples/node-cashout.ts +79 -0
- package/llms.txt +23 -5
- package/package.json +51 -21
- package/skills/peer-cash-integration/SKILL.md +82 -19
- package/dist/chunk-FKVPZVFH.js +0 -188
- package/dist/chunk-FKVPZVFH.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/react.cjs.map +0 -1
- package/dist/react.js.map +0 -1
- package/dist/tools.cjs.map +0 -1
- package/dist/tools.js.map +0 -1
package/dist/react.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/useEstimate.ts","../src/react/useCashout.ts","../src/react/usePoll.ts","../src/react/useMountedRef.ts","../src/react/useOrder.ts","../src/react/useOrders.ts"],"names":["useState","useCallback","useEffect","useRef"],"mappings":";;;AAuBO,SAAS,WAAA,CAAY;AAAA,EAC1B,MAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,iBAAA,GA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CAAY,MAAM,OAAA,CAAQ,OAAO,CAAA,EAAG,CAAC,WAAA,EAAa,OAAO,CAAC,CAAA;AAE5F,EAAA,MAAM,gBAAgB,MAAA,CAAO,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAU,CAAA,CAAE,MAAA;AAEzD,EAAA,MAAM,cAAA,GAAiB,OAAO,MAAA,CAAO,CAAC,KAAK,CAAA,KAAM,GAAA,GAAM,CAAA,CAAE,YAAA,EAAc,EAAE,CAAA;AAEzE,EAAA,OAAO,EAAE,MAAA,EAAQ,aAAA,EAAe,cAAA,EAAgB,SAAA,EAAW,OAAO,OAAA,EAAQ;AAC5E","file":"react.js","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { CurrencyType } from '../sdk-types';\nimport type { CashClient } from '../client/createCashClient';\nimport type { CashEstimate, EstimateInput } from '../client/estimate';\n\nexport interface UseEstimateOptions {\n client: CashClient | null;\n /** Amount to convert, USDC base units. Estimate is skipped while null/0. */\n amount: bigint | null | undefined;\n currency: CurrencyType | null | undefined;\n /** Optional payout platform for platform-specific ETA sampling. */\n platform?: string | null | undefined;\n /** Optional Relay source. Omit for the Base USDC default path. */\n source?: EstimateInput['source'] | null | undefined;\n /** Re-fetch interval (ms) so the displayed rate tracks the market. 0 = no auto-refresh. */\n refreshIntervalMs?: number;\n}\n\n/**\n * Live market-rate estimate for a screen-1 display. The figure is a `≈`\n * estimate; the binding rate resolves at the Chainlink oracle when a buyer\n * fills - there is no committed quote to show.\n */\nexport function useEstimate({\n client,\n amount,\n currency,\n platform,\n source,\n refreshIntervalMs = 0,\n}: UseEstimateOptions) {\n const [estimate, setEstimate] = useState<CashEstimate | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const mountedRef = useRef(true);\n const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const refresh = useCallback(async () => {\n if (!client || !currency || !amount || amount <= 0n) {\n if (mountedRef.current) setEstimate(null);\n return;\n }\n setIsLoading(true);\n setError(null);\n try {\n const result = await client.estimate({\n amount,\n currency,\n ...(platform ? { platform } : {}),\n ...(source ? { source } : {}),\n });\n if (mountedRef.current) setEstimate(result);\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n if (mountedRef.current) {\n setEstimate(null);\n setError(e);\n }\n } finally {\n if (mountedRef.current) setIsLoading(false);\n }\n }, [client, currency, amount, platform, source]);\n\n useEffect(() => {\n mountedRef.current = true;\n void refresh();\n if (refreshIntervalMs > 0) {\n timerRef.current = setInterval(() => void refresh(), refreshIntervalMs);\n }\n return () => {\n mountedRef.current = false;\n if (timerRef.current) clearInterval(timerRef.current);\n };\n }, [refresh, refreshIntervalMs]);\n\n return { estimate, isLoading, error, refresh };\n}\n","import { useCallback, useMemo, useState } from 'react';\nimport type { WalletClient } from 'viem';\nimport type {\n CashClient,\n CashoutOptions,\n CashoutInput,\n CashoutResult,\n TopUpResult,\n WithdrawResult,\n} from '../client/createCashClient';\n\nexport interface UseCashoutOptions {\n client: CashClient | null;\n /** A viem WalletClient with an account, on Base. */\n signer: WalletClient | null | undefined;\n /** Source-chain signer for Relay source routing. Required when the source chain is not Base. */\n sourceSigner?: WalletClient | null | undefined;\n onSourceProgress?: CashoutOptions['onSourceProgress'];\n onCashout?: (result: CashoutResult) => void;\n onError?: (error: Error) => void;\n}\n\n/**\n * Orchestrate a cash-out end to end on the maker side:\n * - `cashout(input)` → create the market-rate deposit, resolve its composite id.\n * - `topUp(depositId, amount)` → add USDC to a live order.\n * - `withdraw(depositId, amount?)` → the ONE unwind verb; partial with an\n * amount, full close without. The caller never chooses between\n * cancel/recover - expired intents are pruned automatically.\n */\nexport function useCashout({\n client,\n signer,\n sourceSigner,\n onSourceProgress,\n onCashout,\n onError,\n}: UseCashoutOptions) {\n const [pending, setPending] = useState<null | 'cashout' | 'withdraw' | 'topUp'>(null);\n const [result, setResult] = useState<CashoutResult | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n const cashout = useCallback(\n async (input: CashoutInput): Promise<CashoutResult | null> => {\n if (!client || !signer) {\n const err = new Error('Cash client or signer is not ready');\n setError(err);\n onError?.(err);\n return null;\n }\n setPending('cashout');\n setError(null);\n setResult(null);\n try {\n const cashoutResult = await client.cashout(input, {\n signer,\n ...(sourceSigner ? { sourceSigner } : {}),\n ...(onSourceProgress ? { onSourceProgress } : {}),\n });\n setResult(cashoutResult);\n onCashout?.(cashoutResult);\n return cashoutResult;\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setError(e);\n onError?.(e);\n return null;\n } finally {\n setPending(null);\n }\n },\n [client, signer, sourceSigner, onSourceProgress, onCashout, onError],\n );\n\n const withdraw = useCallback(\n async (depositId: string, amount?: bigint): Promise<WithdrawResult | null> => {\n if (!client || !signer) {\n const err = new Error('Cash client or signer is not ready');\n setError(err);\n onError?.(err);\n return null;\n }\n setPending('withdraw');\n setError(null);\n try {\n return await client.withdraw(depositId, {\n signer,\n ...(amount !== undefined ? { amount } : {}),\n });\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setError(e);\n onError?.(e);\n return null;\n } finally {\n setPending(null);\n }\n },\n [client, signer, onError],\n );\n\n const topUp = useCallback(\n async (depositId: string, amount: bigint): Promise<TopUpResult | null> => {\n if (!client || !signer) {\n const err = new Error('Cash client or signer is not ready');\n setError(err);\n onError?.(err);\n return null;\n }\n setPending('topUp');\n setError(null);\n try {\n return await client.topUp(depositId, amount, { signer });\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setError(e);\n onError?.(e);\n return null;\n } finally {\n setPending(null);\n }\n },\n [client, signer, onError],\n );\n\n return useMemo(\n () => ({ cashout, topUp, withdraw, pending, result, error }),\n [cashout, topUp, withdraw, pending, result, error],\n );\n}\n","import { useEffect } from 'react';\n\n/**\n * Shared polling loop for the order hooks: runs `tick` immediately, then every\n * `intervalMs` for as long as `tick` resolves true. Cancels cleanly on unmount\n * or dependency change; `isActive()` lets the tick guard its own setState\n * calls against a stale run. Internal - not exported from the package.\n */\nexport function usePoll(\n enabled: boolean,\n intervalMs: number,\n tick: (isActive: () => boolean) => Promise<boolean>,\n): void {\n useEffect(() => {\n if (!enabled) return;\n\n let cancelled = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n const isActive = () => !cancelled;\n\n const run = async () => {\n const keepPolling = await tick(isActive);\n if (cancelled) return;\n if (keepPolling) timer = setTimeout(run, intervalMs);\n };\n void run();\n\n return () => {\n cancelled = true;\n if (timer) clearTimeout(timer);\n };\n }, [enabled, intervalMs, tick]);\n}\n","import { useEffect, useRef } from 'react';\n\n/**\n * A ref that is `true` while the component is mounted. Used to guard `setState`\n * in the manually-triggered `refresh()` paths (the poll loop guards itself).\n * Internal - not exported from the package.\n */\nexport function useMountedRef(): { readonly current: boolean } {\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n return mounted;\n}\n","import { useCallback, useState } from 'react';\nimport { CASH_ORDER_POLL_INTERVAL_MS } from '../engine/constants';\nimport type { CashOrder } from '../engine/types';\nimport type { CashClient } from '../client/createCashClient';\nimport { isCashError } from '../client/errors';\nimport { usePoll } from './usePoll';\nimport { useMountedRef } from './useMountedRef';\n\nexport interface UseOrderOptions {\n client: CashClient | null;\n /** Composite deposit id (`escrow_onchainId`). The resumable anchor. */\n depositId: string | null | undefined;\n /** Poll cadence while the order is in flight (ms). */\n pollIntervalMs?: number;\n /** Disable automatic polling (manual `refresh()` only). */\n paused?: boolean;\n}\n\n/**\n * Observe a cash-out order's lifecycle, keyed by `depositId`.\n *\n * Fully resumable: the order is reconstructed from on-chain data on every load,\n * so it survives a closed tab, a new device, or a wallet reconnect. Polls while\n * the order is in flight and stops once it reaches a terminal state.\n * `ORDER_NOT_FOUND` right after creation is indexer lag - polling continues.\n */\nexport function useOrder({\n client,\n depositId,\n pollIntervalMs = CASH_ORDER_POLL_INTERVAL_MS,\n paused = false,\n}: UseOrderOptions) {\n const [order, setOrder] = useState<CashOrder | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const mounted = useMountedRef();\n\n const fetchOrder = useCallback(\n async (isActive: () => boolean = () => true): Promise<CashOrder | null> => {\n if (!client || !depositId) return null;\n setIsLoading(true);\n setError(null);\n try {\n const derived = await client.order(depositId);\n if (isActive()) setOrder(derived);\n return derived;\n } catch (err) {\n if (isCashError(err) && err.code === 'ORDER_NOT_FOUND') {\n // Indexer lag right after creation - not an error, keep polling.\n return null;\n }\n const e = err instanceof Error ? err : new Error(String(err));\n if (isActive()) setError(e);\n return null;\n } finally {\n if (isActive()) setIsLoading(false);\n }\n },\n [client, depositId],\n );\n\n usePoll(\n Boolean(client && depositId && !paused),\n pollIntervalMs,\n useCallback(\n async (isActive: () => boolean) => {\n const result = await fetchOrder(isActive);\n // Keep polling while in flight (or while state is still unknown).\n return !result || result.isInFlight;\n },\n [fetchOrder],\n ),\n );\n\n const refresh = useCallback(() => fetchOrder(() => mounted.current), [fetchOrder, mounted]);\n\n return { order, isLoading, error, refresh };\n}\n","import { useCallback, useState } from 'react';\nimport { CASH_ORDER_POLL_INTERVAL_MS } from '../engine/constants';\nimport type { CashOrder } from '../engine/types';\nimport type { CashClient } from '../client/createCashClient';\nimport { usePoll } from './usePoll';\nimport { useMountedRef } from './useMountedRef';\n\nexport interface UseOrdersOptions {\n client: CashClient | null;\n /** The connected user's address (the maker / depositor). */\n owner: string | null | undefined;\n /** Max deposits to scan. */\n limit?: number;\n /** Poll cadence (ms) while any order is in flight. */\n pollIntervalMs?: number;\n paused?: boolean;\n}\n\n/**\n * List the user's cash-out orders (the Transactions-feed pattern). Reads\n * deposits by depositor and derives real amounts + states from the indexer\n * aggregates. Polls while any order is in flight.\n */\nexport function useOrders({\n client,\n owner,\n limit = 100,\n pollIntervalMs = CASH_ORDER_POLL_INTERVAL_MS,\n paused = false,\n}: UseOrdersOptions) {\n const [orders, setOrders] = useState<CashOrder[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const mounted = useMountedRef();\n\n const fetchOrders = useCallback(\n async (isActive: () => boolean = () => true): Promise<CashOrder[]> => {\n if (!client || !owner) return [];\n setIsLoading(true);\n setError(null);\n try {\n const derived = await client.orders(owner, { limit });\n if (isActive()) setOrders(derived);\n return derived;\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n if (isActive()) setError(e);\n return [];\n } finally {\n if (isActive()) setIsLoading(false);\n }\n },\n [client, owner, limit],\n );\n\n usePoll(\n Boolean(client && owner && !paused),\n pollIntervalMs,\n useCallback(\n async (isActive: () => boolean) => {\n const result = await fetchOrders(isActive);\n return result.some((o) => o.isInFlight);\n },\n [fetchOrders],\n ),\n );\n\n const refresh = useCallback(() => fetchOrders(() => mounted.current), [fetchOrders, mounted]);\n\n const inFlightCount = orders.filter((o) => o.isInFlight).length;\n /** Lifetime cashed-out total (USDC base units) across the feed. */\n const totalCashedOut = orders.reduce((sum, o) => sum + o.filledAmount, 0n);\n\n return { orders, inFlightCount, totalCashedOut, isLoading, error, refresh };\n}\n"]}
|
package/dist/tools.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tools/index.ts"],"names":[],"mappings":";;;AAsBA,IAAM,YAAA,GAAe;AAAA,EACnB,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,UAAA;AAAA,EACT,WAAA,EACE;AACJ,CAAA;AAEA,IAAM,SAAA,GAAY;AAAA,EAChB,IAAA,EAAM,QAAA;AAAA,EACN,WAAA,EAAa;AACf,CAAA;AAEO,IAAM,SAAA,GAAkC;AAAA,EAC7C;AAAA,IACE,IAAA,EAAM,mBAAA;AAAA,IACN,WAAA,EACE,6RAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,mBAAA,EAAqB;AAAA,UACnB,IAAA,EAAM,SAAA;AAAA,UACN,WA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;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,eAAA;AAAA,IACN,WAAA,EACE,2dAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,SAAA;AAAA,QACA,MAAA,EAAQ;AAAA,UACN,GAAG,YAAA;AAAA,UACH,WAAA,EACE;AAAA;AACJ,OACF;AAAA,MACA,QAAA,EAAU,CAAC,WAAW,CAAA;AAAA,MACtB,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,YAAA;AAAA,IACN,WAAA,EACE,gQAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY,EAAE,SAAA,EAAW,MAAA,EAAQ,YAAA,EAAa;AAAA,MAC9C,QAAA,EAAU,CAAC,WAAA,EAAa,QAAQ,CAAA;AAAA,MAChC,oBAAA,EAAsB;AAAA;AACxB;AAEJ;AAGO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,IAAA,EAAM,aAAA;AAAA,EACN,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EACE,iQAAA;AAAA,EACF,KAAA,EAAO;AACT","file":"tools.cjs","sourcesContent":["/**\n * `@zkp2p/cash/tools` - JSON-schema tool definitions of the verbs, so\n * agent hosts (peer-cli, zkp2p-mcp, any MCP server or tool-use loop) adopt\n * Peer Cash without re-deriving schemas.\n *\n * Design rules:\n * - Mutating verbs default to the **prepare path**: the tool returns unsigned\n * transactions plus readable step labels; signing stays host-side, where key\n * custody and policy live.\n * - Every input/output is plain JSON (bigints as decimal strings) - see the\n * codecs exported from the package root for lossless (de)serialization.\n * - `watch` is intentionally not a tool: agents poll `cash_order` between\n * other work instead of holding a streaming connection open.\n */\n\nexport interface CashToolDefinition {\n name: string;\n description: string;\n /** JSON Schema (draft-07 compatible) for the tool input. */\n inputSchema: Record<string, unknown>;\n}\n\nconst bigintString = {\n type: 'string',\n pattern: '^[0-9]+$',\n description:\n 'Base units as a decimal string. For the default path this is USDC 6 decimals; with source it is source-token base units.',\n} as const;\n\nconst depositId = {\n type: 'string',\n description: 'Composite deposit id (escrow_onchainId) returned by cash_cashout - the resume key',\n} as const;\n\nexport const cashTools: CashToolDefinition[] = [\n {\n name: 'cash_capabilities',\n description:\n 'Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, Base USDC destination, default Base USDC source, payee handle hints, and amount bounds. Set includeRelaySources=true to fetch live Relay-supported EVM source chains/tokens through the Relay SDK.',\n inputSchema: {\n type: 'object',\n properties: {\n includeRelaySources: {\n type: 'boolean',\n description: 'Fetch live Relay SDK EVM source chain/token metadata.',\n },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'cash_source_quote',\n description:\n 'Quote any Relay-supported EVM source asset into Base USDC through @relayprotocol/relay-sdk. Use this before cash_cashout when the user starts with an asset other than Base USDC.',\n inputSchema: {\n type: 'object',\n properties: {\n user: { type: 'string', description: 'Source wallet submitting the Relay transaction.' },\n amount: bigintString,\n source: {\n type: 'object',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n },\n required: ['chainId', 'currency'],\n additionalProperties: false,\n },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to user.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n description: 'Relay quote trade type. Defaults to EXACT_INPUT.',\n },\n },\n required: ['user', 'amount', 'source'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_estimate',\n description:\n 'Estimate fiat received at the live oracle market rate and include a simple recent-fill ETA. Without source, amount is Base USDC. With source, the SDK first quotes source->Base USDC through Relay SDK, then estimates the cashout.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n currency: {\n type: 'string',\n description: 'Fiat currency code from cash_capabilities, e.g. \"USD\"',\n },\n platform: {\n type: 'string',\n description: 'Optional payout platform for platform-specific ETA sampling.',\n },\n source: {\n type: 'object',\n description: 'Optional Relay EVM source asset. Omit for the Base USDC default path.',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n user: {\n type: 'string',\n description: 'Source wallet submitting the Relay transaction.',\n },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to user.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n },\n },\n required: ['chainId', 'currency', 'user'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'currency'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_cashout',\n description:\n 'Start a cash-out. Default path: Base USDC amount and tool hosts can return UNSIGNED transactions plus same-index steps [approve, createDeposit]. With source: signer-backed clients first execute a Relay SDK EVM route into Base USDC, then register the payee and create the protocol-held cash-out order. Non-Base source chains need a source-chain signer. Custody-separated hosts should use cash_source_quote/cash_source_status first, then Base USDC cash_cashout.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n source: {\n type: 'object',\n description: 'Optional Relay EVM source asset. Omit for the Base USDC default path.',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to signer.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n },\n },\n required: ['chainId', 'currency'],\n additionalProperties: false,\n },\n receive: {\n type: 'object',\n description: 'Where the fiat should arrive',\n properties: {\n platform: {\n type: 'string',\n description: 'Platform id from cash_capabilities, e.g. \"venmo\"',\n },\n currency: { type: 'string', description: 'Fiat currency code, e.g. \"USD\"' },\n payee: {\n type: 'object',\n description: 'Payee handle for the platform',\n properties: {\n offchainId: {\n type: 'string',\n description:\n 'The handle, e.g. \"@andrew\" for Venmo - see payeeHint in cash_capabilities',\n },\n },\n required: ['offchainId'],\n additionalProperties: true,\n },\n },\n required: ['platform', 'currency', 'payee'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'receive'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_order',\n description:\n 'Observe one cash-out order by depositId - fully resumable, no session state. Returns state (awaiting-buyer | matched | delivering | delivered | returned), amounts, fills, and nextActions (wait | withdraw). Errors are typed with retryable + remediation; ORDER_NOT_FOUND right after cashout means indexer lag - retry in a few seconds.',\n inputSchema: {\n type: 'object',\n properties: { depositId },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_orders',\n description:\n 'List all cash-out orders for a wallet address (the chain is the database - a cash order IS a deposit, keyed by depositor). Use inFlight=true for only the orders still needing attention.',\n inputSchema: {\n type: 'object',\n properties: {\n owner: { type: 'string', description: 'The maker wallet address (0x...)' },\n inFlight: {\n type: 'boolean',\n description: 'Only awaiting-buyer / matched / delivering orders',\n },\n limit: { type: 'number', description: 'Max deposits to scan (default 100)' },\n },\n required: ['owner'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_buyer',\n description:\n 'Look up a buyer\\'s protocol track record from their full intent history: lifetime intents, fulfilled vs pruned counts, success rate (bps), first/last seen. Use during the matched state to answer \"who just committed to my order?\".',\n inputSchema: {\n type: 'object',\n properties: {\n address: { type: 'string', description: 'The buyer (taker) wallet address (0x...)' },\n },\n required: ['address'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_source_status',\n description:\n 'Read Relay request status through the Relay SDK request utility using the requestId returned from cash_source_quote or Relay execution progress.',\n inputSchema: {\n type: 'object',\n properties: {\n requestId: { type: 'string', description: 'Relay request id.' },\n },\n required: ['requestId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_withdraw',\n description:\n 'Unwind a cash-out: returns UNSIGNED transaction(s) plus same-index steps (prepare path - signing stays host-side). With amount: partial withdrawal of the unlocked balance (a live buyer intent does not block it). Without amount: closes the order fully, state-aware - when the only live intents have expired it includes a pruneExpiredIntents transaction first; while a live buyer intent locks funds it fails with ACTIVE_INTENT_BLOCKS_WITHDRAWAL (retryable - wait for expiry).',\n inputSchema: {\n type: 'object',\n properties: {\n depositId,\n amount: {\n ...bigintString,\n description:\n 'Optional partial amount (USDC base units, decimal string). Omit to close the order fully.',\n },\n },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_topup',\n description:\n 'Add USDC to a live cash-out order (same payee, same market rate). Returns UNSIGNED transactions plus same-index steps [approve, addFunds] for the host to sign and submit in order. Fails with ORDER_NOT_ACTIVE if the order is already delivered or returned.',\n inputSchema: {\n type: 'object',\n properties: { depositId, amount: bigintString },\n required: ['depositId', 'amount'],\n additionalProperties: false,\n },\n },\n];\n\n/** Manifest wrapper with versioning for host registries. */\nexport const cashToolManifest = {\n name: '@zkp2p/cash',\n version: '0.1.2',\n description:\n 'Peer Cash - offramp-only: route any Relay-supported EVM source asset to Base USDC, then cash out to fiat at the live oracle market rate (0% spread). Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.',\n tools: cashTools,\n} as const;\n\nexport type CashToolName = (typeof cashTools)[number]['name'];\n"]}
|
package/dist/tools.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tools/index.ts"],"names":[],"mappings":";AAsBA,IAAM,YAAA,GAAe;AAAA,EACnB,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,UAAA;AAAA,EACT,WAAA,EACE;AACJ,CAAA;AAEA,IAAM,SAAA,GAAY;AAAA,EAChB,IAAA,EAAM,QAAA;AAAA,EACN,WAAA,EAAa;AACf,CAAA;AAEO,IAAM,SAAA,GAAkC;AAAA,EAC7C;AAAA,IACE,IAAA,EAAM,mBAAA;AAAA,IACN,WAAA,EACE,6RAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAA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,mBAAA;AAAoB,OAChE;AAAA,MACA,QAAA,EAAU,CAAC,WAAW,CAAA;AAAA,MACtB,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,eAAA;AAAA,IACN,WAAA,EACE,2dAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,SAAA;AAAA,QACA,MAAA,EAAQ;AAAA,UACN,GAAG,YAAA;AAAA,UACH,WAAA,EACE;AAAA;AACJ,OACF;AAAA,MACA,QAAA,EAAU,CAAC,WAAW,CAAA;AAAA,MACtB,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,YAAA;AAAA,IACN,WAAA,EACE,gQAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY,EAAE,SAAA,EAAW,MAAA,EAAQ,YAAA,EAAa;AAAA,MAC9C,QAAA,EAAU,CAAC,WAAA,EAAa,QAAQ,CAAA;AAAA,MAChC,oBAAA,EAAsB;AAAA;AACxB;AAEJ;AAGO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,IAAA,EAAM,aAAA;AAAA,EACN,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EACE,iQAAA;AAAA,EACF,KAAA,EAAO;AACT","file":"tools.js","sourcesContent":["/**\n * `@zkp2p/cash/tools` - JSON-schema tool definitions of the verbs, so\n * agent hosts (peer-cli, zkp2p-mcp, any MCP server or tool-use loop) adopt\n * Peer Cash without re-deriving schemas.\n *\n * Design rules:\n * - Mutating verbs default to the **prepare path**: the tool returns unsigned\n * transactions plus readable step labels; signing stays host-side, where key\n * custody and policy live.\n * - Every input/output is plain JSON (bigints as decimal strings) - see the\n * codecs exported from the package root for lossless (de)serialization.\n * - `watch` is intentionally not a tool: agents poll `cash_order` between\n * other work instead of holding a streaming connection open.\n */\n\nexport interface CashToolDefinition {\n name: string;\n description: string;\n /** JSON Schema (draft-07 compatible) for the tool input. */\n inputSchema: Record<string, unknown>;\n}\n\nconst bigintString = {\n type: 'string',\n pattern: '^[0-9]+$',\n description:\n 'Base units as a decimal string. For the default path this is USDC 6 decimals; with source it is source-token base units.',\n} as const;\n\nconst depositId = {\n type: 'string',\n description: 'Composite deposit id (escrow_onchainId) returned by cash_cashout - the resume key',\n} as const;\n\nexport const cashTools: CashToolDefinition[] = [\n {\n name: 'cash_capabilities',\n description:\n 'Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, Base USDC destination, default Base USDC source, payee handle hints, and amount bounds. Set includeRelaySources=true to fetch live Relay-supported EVM source chains/tokens through the Relay SDK.',\n inputSchema: {\n type: 'object',\n properties: {\n includeRelaySources: {\n type: 'boolean',\n description: 'Fetch live Relay SDK EVM source chain/token metadata.',\n },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'cash_source_quote',\n description:\n 'Quote any Relay-supported EVM source asset into Base USDC through @relayprotocol/relay-sdk. Use this before cash_cashout when the user starts with an asset other than Base USDC.',\n inputSchema: {\n type: 'object',\n properties: {\n user: { type: 'string', description: 'Source wallet submitting the Relay transaction.' },\n amount: bigintString,\n source: {\n type: 'object',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n },\n required: ['chainId', 'currency'],\n additionalProperties: false,\n },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to user.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n description: 'Relay quote trade type. Defaults to EXACT_INPUT.',\n },\n },\n required: ['user', 'amount', 'source'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_estimate',\n description:\n 'Estimate fiat received at the live oracle market rate and include a simple recent-fill ETA. Without source, amount is Base USDC. With source, the SDK first quotes source->Base USDC through Relay SDK, then estimates the cashout.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n currency: {\n type: 'string',\n description: 'Fiat currency code from cash_capabilities, e.g. \"USD\"',\n },\n platform: {\n type: 'string',\n description: 'Optional payout platform for platform-specific ETA sampling.',\n },\n source: {\n type: 'object',\n description: 'Optional Relay EVM source asset. Omit for the Base USDC default path.',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n user: {\n type: 'string',\n description: 'Source wallet submitting the Relay transaction.',\n },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to user.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n },\n },\n required: ['chainId', 'currency', 'user'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'currency'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_cashout',\n description:\n 'Start a cash-out. Default path: Base USDC amount and tool hosts can return UNSIGNED transactions plus same-index steps [approve, createDeposit]. With source: signer-backed clients first execute a Relay SDK EVM route into Base USDC, then register the payee and create the protocol-held cash-out order. Non-Base source chains need a source-chain signer. Custody-separated hosts should use cash_source_quote/cash_source_status first, then Base USDC cash_cashout.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n source: {\n type: 'object',\n description: 'Optional Relay EVM source asset. Omit for the Base USDC default path.',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to signer.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n },\n },\n required: ['chainId', 'currency'],\n additionalProperties: false,\n },\n receive: {\n type: 'object',\n description: 'Where the fiat should arrive',\n properties: {\n platform: {\n type: 'string',\n description: 'Platform id from cash_capabilities, e.g. \"venmo\"',\n },\n currency: { type: 'string', description: 'Fiat currency code, e.g. \"USD\"' },\n payee: {\n type: 'object',\n description: 'Payee handle for the platform',\n properties: {\n offchainId: {\n type: 'string',\n description:\n 'The handle, e.g. \"@andrew\" for Venmo - see payeeHint in cash_capabilities',\n },\n },\n required: ['offchainId'],\n additionalProperties: true,\n },\n },\n required: ['platform', 'currency', 'payee'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'receive'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_order',\n description:\n 'Observe one cash-out order by depositId - fully resumable, no session state. Returns state (awaiting-buyer | matched | delivering | delivered | returned), amounts, fills, and nextActions (wait | withdraw). Errors are typed with retryable + remediation; ORDER_NOT_FOUND right after cashout means indexer lag - retry in a few seconds.',\n inputSchema: {\n type: 'object',\n properties: { depositId },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_orders',\n description:\n 'List all cash-out orders for a wallet address (the chain is the database - a cash order IS a deposit, keyed by depositor). Use inFlight=true for only the orders still needing attention.',\n inputSchema: {\n type: 'object',\n properties: {\n owner: { type: 'string', description: 'The maker wallet address (0x...)' },\n inFlight: {\n type: 'boolean',\n description: 'Only awaiting-buyer / matched / delivering orders',\n },\n limit: { type: 'number', description: 'Max deposits to scan (default 100)' },\n },\n required: ['owner'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_buyer',\n description:\n 'Look up a buyer\\'s protocol track record from their full intent history: lifetime intents, fulfilled vs pruned counts, success rate (bps), first/last seen. Use during the matched state to answer \"who just committed to my order?\".',\n inputSchema: {\n type: 'object',\n properties: {\n address: { type: 'string', description: 'The buyer (taker) wallet address (0x...)' },\n },\n required: ['address'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_source_status',\n description:\n 'Read Relay request status through the Relay SDK request utility using the requestId returned from cash_source_quote or Relay execution progress.',\n inputSchema: {\n type: 'object',\n properties: {\n requestId: { type: 'string', description: 'Relay request id.' },\n },\n required: ['requestId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_withdraw',\n description:\n 'Unwind a cash-out: returns UNSIGNED transaction(s) plus same-index steps (prepare path - signing stays host-side). With amount: partial withdrawal of the unlocked balance (a live buyer intent does not block it). Without amount: closes the order fully, state-aware - when the only live intents have expired it includes a pruneExpiredIntents transaction first; while a live buyer intent locks funds it fails with ACTIVE_INTENT_BLOCKS_WITHDRAWAL (retryable - wait for expiry).',\n inputSchema: {\n type: 'object',\n properties: {\n depositId,\n amount: {\n ...bigintString,\n description:\n 'Optional partial amount (USDC base units, decimal string). Omit to close the order fully.',\n },\n },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_topup',\n description:\n 'Add USDC to a live cash-out order (same payee, same market rate). Returns UNSIGNED transactions plus same-index steps [approve, addFunds] for the host to sign and submit in order. Fails with ORDER_NOT_ACTIVE if the order is already delivered or returned.',\n inputSchema: {\n type: 'object',\n properties: { depositId, amount: bigintString },\n required: ['depositId', 'amount'],\n additionalProperties: false,\n },\n },\n];\n\n/** Manifest wrapper with versioning for host registries. */\nexport const cashToolManifest = {\n name: '@zkp2p/cash',\n version: '0.1.2',\n description:\n 'Peer Cash - offramp-only: route any Relay-supported EVM source asset to Base USDC, then cash out to fiat at the live oracle market rate (0% spread). Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.',\n tools: cashTools,\n} as const;\n\nexport type CashToolName = (typeof cashTools)[number]['name'];\n"]}
|