Raxol.Payments.Actions.Payments.ExecuteXochiIntent (Raxol Payments v0.2.0)

Copy Markdown View Source

Agent Action that runs a cross-chain (and optionally stealth) Xochi intent.

Quotes the intent, authorizes the spend through SpendGate before any signature is released, signs and submits via the wallet, and returns the intent id and initial status. Poll for the terminal status with Raxol.Payments.Actions.Payments.PollXochiStatus.

The spend is gated on the human-decimal amount; the atomic from_amount sent to Xochi is derived from the token's decimals. If execution fails after the gate reserved budget, the reservation is released.

Idempotent recovery

When a :checkpoint store is supplied, the intent is checkpointed by a stable idempotency key before it is submitted. If the process crashes mid-settlement and the Action runs again for the same logical payment, it finds the checkpoint and returns the in-flight intent for the caller to poll, rather than re-quoting and signing a second time. The spend is reserved and the signature released exactly once across the crash.

Without a checkpoint store the settlement proceeds unchecked and emits [:raxol, :payments, :xochi, :unchecked_settlement] telemetry, so a crash between signing and confirming would re-quote and sign a second time. A fund-moving deployment closes that window by injecting a durable :checkpoint store (see Raxol.Payments.Checkpoint.ContextStore) and setting require_checkpoint: true in context (or config :raxol_payments, :require_checkpoint, true), which fails the Action closed with {:error, {:checkpoint_required, _}} before any signature when no store is present.

Context keys

  • :wallet -- wallet module signing the EIP-712 intent.
  • :xochi_config -- %{base_url:, auth:} for Xochi.Client (e.g. auth: {:mandate, agent_wallet}; see Xochi.Client for all auth modes).
  • :policy, :ledger, :agent_id, :on_confirm -- see SpendGate.
  • :checkpoint -- optional {module, handle} Raxol.Payments.Checkpoint store for idempotent recovery (nil disables it).
  • :require_checkpoint -- when true, the Action fails closed with {:error, {:checkpoint_required, _}} unless a :checkpoint store is present (default false; falls back to config :raxol_payments, :require_checkpoint).
  • :idempotency_key -- optional explicit key; derived from the payment when absent.

Summary

Functions

Validate input, run the action, validate output.

Generate an LLM tool definition for this action.

Functions

call(params, context \\ %{})

Validate input, run the action, validate output.

Returns {:ok, result}, {:ok, result, commands}, or {:error, reason}.

to_tool_definition()

Generate an LLM tool definition for this action.