diff --git a/examples/crewai-x402/.env.example b/examples/crewai-x402/.env.example new file mode 100644 index 0000000..78a7d4f --- /dev/null +++ b/examples/crewai-x402/.env.example @@ -0,0 +1,16 @@ +# Stellar testnet secret key of the PAYER (funded via Friendbot, with a USDC trustline and testnet USDC) +# Generate: https://laboratory.stellar.org/#account-creator?network=test +STELLAR_SECRET_KEY= + +# OpenAI API key for the live crew run (CrewAI uses gpt-4o-mini by default) +OPENAI_API_KEY= +# Optional: another model name supported by CrewAI's LLM() +# CREWAI_MODEL=gpt-4o-mini + +# x402 server settings (server/, your own x402Serve route) +# Testnet public key you own that RECEIVES the payments (not the payer's key) +SELLER_PUBLIC_KEY= +# Free testnet facilitator key: https://channels.openzeppelin.com/testnet/gen +FACILITATOR_API_KEY= +X402_SERVER_PORT=3402 +X402_PRICE=0.02 diff --git a/examples/crewai-x402/.gitignore b/examples/crewai-x402/.gitignore new file mode 100644 index 0000000..2ce3829 --- /dev/null +++ b/examples/crewai-x402/.gitignore @@ -0,0 +1,8 @@ +.env +.venv/ +seller.secret +__pycache__/ +*.pyc +.pytest_cache/ +node_modules/ +*.log diff --git a/examples/crewai-x402/README.md b/examples/crewai-x402/README.md new file mode 100644 index 0000000..f933336 --- /dev/null +++ b/examples/crewai-x402/README.md @@ -0,0 +1,151 @@ +# CrewAI x402 Tool Example + +A **CrewAI** (Python) tool that pays x402 endpoints through the Nirium Python SDK, with a per-payment spend cap, used by a two-agent crew on `stellar:testnet`. + +- **`NiriumX402Tool`** is a CrewAI `BaseTool` that wraps `nirium.Agent.x402_fetch()` with `init_x402(max_amount_per_payment="$1")`. +- **Data scout** (no tools) reads the catalog of paid routes and picks the one that answers the request. +- **Payer** (has the tool) pays that route on your own `x402Serve` server. +- A request above the cap is refused by the SDK **before signing** (`X402SpendCapError`). The tool returns it as `{"status": "refused", "signed": false, ...}`, so the crew finishes normally and explains the refusal instead of crashing. + +Testnet only: no real funds, no mainnet, no custody. Every key stays with whoever owns it. + +## Package Versions Tested + +Python 3.12, from `requirements.txt`: + +``` +nirium==0.12.7 +crewai==1.15.44 +python-dotenv==1.2.2 +pytest==8.3.0 +pytest-asyncio==0.24.0 +``` + +`server/` (Node): `nirium@0.19.6`, `@x402/*@2.32.0`, `express@5.3.0` (locked in `server/package-lock.json`). + +## Files + +- **`nirium_crewai_tool.py`**: the CrewAI `BaseTool` (`NiriumX402Tool`) +- **`agent.py`**: the two-agent crew (Data scout + Payer) with the two test runs +- **`test_crewai_tool.py`**: offline tests of the tool (real Nirium SDK, faked HTTP, spy signer) +- **`test_crew_offline.py`**: offline end-to-end tests of the crew with a scripted LLM +- **`requirements.txt`**, **`pytest.ini`**, **`.env.example`**, **`.gitignore`** +- **`server/`**: your own `x402Serve` route on testnet: `/paid/market-summary` at `X402_PRICE` (default $0.02, below the cap) and `/paid/full-report` at $2 (above the cap) + +## Setup + +```bash +cd examples/crewai-x402 +python3 -m venv .venv && source .venv/bin/activate +pip install -r requirements.txt +cp .env.example .env # then fill it in; never commit it +``` + +In `.env`: + +- `STELLAR_SECRET_KEY`: your **own** testnet payer key (Friendbot), with a USDC trustline and testnet USDC. The facilitator sponsors fees, so the payer needs no XLM for the payment itself. +- `OPENAI_API_KEY`: for the live crew run (`gpt-4o-mini` by default; override with `CREWAI_MODEL`). +- `SELLER_PUBLIC_KEY`: a second testnet account you own (G...) that **receives** the payments. It needs a USDC trustline. +- `FACILITATOR_API_KEY`: a free testnet key from https://channels.openzeppelin.com/testnet/gen + +## Run + +Terminal 1, your own `x402Serve` route (reads `../.env`): + +```bash +cd examples/crewai-x402/server +npm install +npm start # x402Serve on http://localhost:3402 (stellar:testnet) +``` + +Terminal 2, the crew: + +```bash +cd examples/crewai-x402 +source .venv/bin/activate +python agent.py +``` + +- **Test 1** asks for a short market summary. The scout picks `/paid/market-summary`, the payer pays $0.02 and the tool returns the settlement `tx_hash` with its Stellar Expert link. +- **Test 2** asks for the full report. The scout picks `/paid/full-report` ($2), the SDK refuses it before signing because $2 > $1, and the crew reports the refusal. + +At the end, `agent.py` prints the tool's own call log (status, URL, tx hash), which comes from `NiriumX402Tool`, not from the LLM. + +## Tests + +No network, no LLM, no real funds: + +```bash +pytest -v +``` + +`test_crewai_tool.py` runs the real Nirium SDK against a fake `aiohttp` session and a spy in place of the signer: + +- the tool is a CrewAI `BaseTool` and its schema exposes only `url` and `method` (no secret, no cap) +- the cap and network are passed to `init_x402`, and an unknown network is rejected +- below the cap: signed once, paid retry with `PAYMENT-SIGNATURE`, `tx_hash` and Stellar Expert link returned +- above the cap: `X402SpendCapError`, **signer never called**, no paid retry, structured `refused` result +- network mismatch (pubnet offer to a testnet client): refused, signer never called +- sync `_run` inside a running event loop, and async `arun` +- errors are returned (not raised) with secrets and payment headers redacted +- a server error without payment (e.g. a bad facilitator key) is reported as `error`, not as a success + +`test_crew_offline.py` runs the crew from `agent.py` with a scripted LLM: two agents, only the payer holds the tool, the cheap route is paid, and the $2 route is refused while the crew still completes. + +## Testnet Evidence + +**Run against my own `x402Serve` route (`server/`, stellar:testnet, Nov 21 2026):** + +| Step | Value | +|---|---| +| Seller account (`SELLER_PUBLIC_KEY`, receives the payment) | [GDYJA25NGJWWMGTAC73LG4J2X6FCVSTC7CTVJZKT3EZSBUYM5WOKIV5Z](https://stellar.expert/explorer/testnet/account/GDYJA25NGJWWMGTAC73LG4J2X6FCVSTC7CTVJZKT3EZSBUYM5WOKIV5Z) | +| Payer account (`STELLAR_SECRET_KEY`'s public key) | [GBTBTAO3MGBSBQ6ARGHSRRJLPJ7UBI7HCGHP47DO77TJZYWPN7KSRIY5](https://stellar.expert/explorer/testnet/account/GBTBTAO3MGBSBQ6ARGHSRRJLPJ7UBI7HCGHP47DO77TJZYWPN7KSRIY5) | +| Paid call `/paid/market-summary` through the crew's Payer | [632ebebcd63c2c202fe2c7e3ef60c27b6ab99f31f663e3b71730017d58293d8d](https://stellar.expert/explorer/testnet/tx/632ebebcd63c2c202fe2c7e3ef60c27b6ab99f31f663e3b71730017d58293d8d): 0.02 USDC from the payer to the seller above | +| Refused call `/paid/full-report` ($2 > $1 cap) | Refused before signing with `X402SpendCapError`, no transaction. Crew answer: "The payment was refused before signing because it exceeds the $1 cap." Tool message: "Payment refused before signing: the price is above the per-payment cap of $1. Nothing was signed or sent." | + +## How the Spend Cap Works + +1. The server answers `402` with its payment options in the `payment-required` header. +2. The SDK picks the option on the configured network and compares its USDC amount with `max_amount_per_payment`. +3. If it is above the cap, it raises `X402SpendCapError` **before** building or signing anything. +4. The tool returns: + +```json +{ + "status": "refused", + "error": "X402SpendCapError", + "url": "http://localhost:3402/paid/full-report", + "cap": "$1", + "requested_amount_stroops": "20000000", + "asset": "CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA", + "network": "stellar:testnet", + "signed": false, + "message": "Payment refused before signing: the price is above the per-payment cap of $1. Nothing was signed or sent." +} +``` + +## Usage + +```python +from crewai import Agent, Crew, Task +from nirium_crewai_tool import NiriumX402Tool + +tool = NiriumX402Tool( + secret_key="S...", # your own testnet key, from .env + network="stellar:testnet", + max_amount_per_payment="$1", +) +payer = Agent(role="Payer", goal="Fetch paid x402 data", backstory="...", tools=[tool]) +``` + +## Security Checklist + +- Testnet only (no mainnet, no real funds) +- `.env`, `.venv/` and `seller.secret` are in `.gitignore` +- The secret goes only to `init_x402`: not stored on the tool, not in the LLM-visible schema, redacted from errors +- The spend cap is enforced by the SDK before signing +- Own keys only; no custody + +## License + +Apache-2.0 (same as Nirium Protocol) diff --git a/examples/crewai-x402/agent.py b/examples/crewai-x402/agent.py new file mode 100644 index 0000000..d649f3f --- /dev/null +++ b/examples/crewai-x402/agent.py @@ -0,0 +1,124 @@ +"""Two-agent CrewAI crew that pays your own x402Serve route on stellar:testnet. + +- Data scout: reads the catalog of paid routes and picks the one that answers the + request (it has no payment tool). +- Payer: fetches the chosen URL with NiriumX402Tool, capped at $1 per payment. + +Run 1 asks for the market summary ($0.02): paid, tx hash on Stellar Expert. +Run 2 asks for the full report ($2): refused by the cap before signing; the crew +finishes normally and explains the refusal. +""" + +from __future__ import annotations + +import json +import os +import sys +from typing import Any + +# Keep the run quiet and local: no CrewAI telemetry or trace upload prompts. +os.environ.setdefault("CREWAI_TRACING_ENABLED", "false") +os.environ.setdefault("CREWAI_DISABLE_TELEMETRY", "true") +os.environ.setdefault("OTEL_SDK_DISABLED", "true") + +from dotenv import load_dotenv # noqa: E402 + +load_dotenv() + +from crewai import LLM, Agent, Crew, Process, Task # noqa: E402 + +from nirium_crewai_tool import NiriumX402Tool # noqa: E402 + +CAP = "$1" +NETWORK = "stellar:testnet" + + +def catalog(server_url: str) -> str: + return ( + f"- {server_url}/paid/market-summary : short market summary, price " + f"${os.getenv('X402_PRICE', '0.02').lstrip('$')} USDC\n" + f"- {server_url}/paid/full-report : full detailed report, price $2 USDC" + ) + + +def build_crew(tool: NiriumX402Tool, llm: Any, verbose: bool = True) -> Crew: + scout = Agent( + role="Data scout", + goal="Pick the single paid endpoint that answers the request.", + backstory="You know the catalog of x402 routes and their prices. You never pay for anything.", + llm=llm, + allow_delegation=False, + verbose=verbose, + ) + payer = Agent( + role="Payer", + goal="Fetch the endpoint chosen by the scout, paying with the nirium_x402_fetch tool.", + backstory=( + "You pay x402 routes on Stellar testnet with a hard per-payment cap of $1. " + "If the tool says status='refused', you do not retry: you report the refusal." + ), + tools=[tool], + llm=llm, + allow_delegation=False, + max_iter=3, + verbose=verbose, + ) + find = Task( + description=( + "Request: {request}\n\nCatalog of paid routes:\n{catalog}\n\n" + "Choose the one route that answers the request." + ), + expected_output="Only the absolute URL of the chosen route, nothing else.", + agent=scout, + ) + pay = Task( + description=( + "Call nirium_x402_fetch exactly once with the URL chosen by the Data scout. " + "Report what came back." + ), + expected_output=( + "If paid: the data and the tx_hash. If refused: say the payment was refused " + "before signing because it exceeds the $1 cap." + ), + agent=payer, + context=[find], + ) + return Crew(agents=[scout, payer], tasks=[find, pay], process=Process.sequential, verbose=verbose, tracing=False) + + +def main() -> int: + secret = os.getenv("STELLAR_SECRET_KEY") + if not secret: + print("STELLAR_SECRET_KEY is not set in .env (testnet payer key).") + return 1 + if not os.getenv("OPENAI_API_KEY"): + print("OPENAI_API_KEY is not set in .env. Offline tests: pytest -v") + return 1 + + server_url = f"http://localhost:{os.getenv('X402_SERVER_PORT', '3402')}" + tool = NiriumX402Tool(secret, network=NETWORK, max_amount_per_payment=CAP) + llm = LLM(model=os.getenv("CREWAI_MODEL", "gpt-4o-mini"), temperature=0) + print(f"Nirium x402 tool ready (cap {CAP}, {NETWORK}), server {server_url}") + + runs = [ + ("Test 1: market summary (below the $1 cap, must pay)", "I need a short market summary."), + ("Test 2: full report ($2, above the $1 cap, must be refused)", "I need the full detailed report."), + ] + for title, request in runs: + print("\n" + "=" * 70 + f"\n{title}\n" + "=" * 70) + crew = build_crew(tool, llm) # fresh crew per run, same tool and cap + result = crew.kickoff(inputs={"request": request, "catalog": catalog(server_url)}) + print(f"\nCrew answer: {result.raw}") + + print("\n" + "=" * 70 + "\nTool call log (from NiriumX402Tool, not from the LLM)\n" + "=" * 70) + for entry in tool.history: + line = {k: entry.get(k) for k in ("status", "url", "tx_hash", "stellar_expert", "error", "cap", "requested_amount_stroops", "signed") if entry.get(k) is not None} + print(json.dumps(line)) + return 0 + + +if __name__ == "__main__": + try: + sys.exit(main()) + except KeyboardInterrupt: + sys.exit(1) diff --git a/examples/crewai-x402/nirium_crewai_tool.py b/examples/crewai-x402/nirium_crewai_tool.py new file mode 100644 index 0000000..ff7b3cf --- /dev/null +++ b/examples/crewai-x402/nirium_crewai_tool.py @@ -0,0 +1,194 @@ +"""CrewAI tool that pays x402 endpoints through the Nirium Python SDK. + +Wraps ``nirium.Agent.x402_fetch()`` with ``max_amount_per_payment`` (a per-payment +spend cap). The Stellar secret is used only to call ``Agent.init_x402``: it is +never stored on the tool, never part of the schema the LLM sees, and is redacted +from anything the tool returns. + +A payment above the cap is refused by the SDK *before signing* +(``X402SpendCapError``). The tool turns that into a structured result instead of +raising, so the crew keeps running and the agent can explain the refusal. +""" + +from __future__ import annotations + +import asyncio +import concurrent.futures +import json +import re +from typing import Any, Optional, Type +from urllib.parse import urlparse + +from crewai.tools import BaseTool +from pydantic import BaseModel, Field, PrivateAttr + +from nirium import Agent, X402NetworkMismatchError, X402SpendCapError + +DEFAULT_API_URL = "https://nirium-agent.fly.dev" +_ALLOWED_METHODS = {"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"} +_STELLAR_SECRET_RE = re.compile(r"\bS[A-Z2-7]{55}\b") +_PAYMENT_HEADER_RE = re.compile(r"(?i)\b(PAYMENT-SIGNATURE|X-PAYMENT)\s*[:=]\s*\S+") + + +def redact_secrets(value: Any) -> str: + """Strip Stellar secret seeds and payment headers from text shown to the LLM.""" + text = value if isinstance(value, str) else str(value) + text = _STELLAR_SECRET_RE.sub("[REDACTED]", text) + return _PAYMENT_HEADER_RE.sub(r"\1=[REDACTED]", text) + + +def extract_settlement_tx(settlement: Optional[dict[str, Any]]) -> Optional[str]: + """Return the public transaction hash from an x402 settlement payload.""" + if not settlement: + return None + for key in ("transaction", "txHash", "tx_hash", "hash", "transactionHash"): + value = settlement.get(key) + if isinstance(value, str) and value: + return value + if isinstance(value, dict): + nested = extract_settlement_tx(value) + if nested: + return nested + for key in ("settleResponse", "settlement", "receipt", "payload"): + nested = settlement.get(key) + if isinstance(nested, dict): + found = extract_settlement_tx(nested) + if found: + return found + return None + + +def stellar_expert_tx_url(tx_hash: str, network: str = "stellar:testnet") -> str: + net = "testnet" if network == "stellar:testnet" else "public" + return f"https://stellar.expert/explorer/{net}/tx/{tx_hash}" + + +def _run_coro(coro: Any) -> Any: + """Run a coroutine from sync code, even if an event loop is already running.""" + try: + asyncio.get_running_loop() + except RuntimeError: + return asyncio.run(coro) + with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool: + return pool.submit(asyncio.run, coro).result() + + +class NiriumX402Input(BaseModel): + """Arguments the LLM can fill in. No secret, no cap: those stay in code.""" + + url: str = Field(description="Absolute http(s) URL of the x402-protected resource.") + method: str = Field(default="GET", description="HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD).") + + +class NiriumX402Tool(BaseTool): + """CrewAI ``BaseTool`` around ``nirium.Agent.x402_fetch`` with a spend cap.""" + + name: str = "nirium_x402_fetch" + description: str = ( + "Fetch an HTTP resource protected by x402 and pay for it in testnet USDC on " + "Stellar through Nirium. Returns JSON. If the price is above the per-payment " + "cap the payment is refused before signing and the JSON has " + "status='refused' with the reason: report it, do not retry." + ) + args_schema: Type[BaseModel] = NiriumX402Input + + network: str = "stellar:testnet" + max_amount_per_payment: str = "$1" + + _client: Any = PrivateAttr(default=None) + _history: list = PrivateAttr(default_factory=list) + + def __init__( + self, + secret_key: str, + *, + network: str = "stellar:testnet", + max_amount_per_payment: str = "$1", + api_url: str = DEFAULT_API_URL, + client: Any = None, + **kwargs: Any, + ) -> None: + super().__init__(network=network, max_amount_per_payment=max_amount_per_payment, **kwargs) + nirium_client = client if client is not None else Agent(api_url=api_url) + # The secret goes straight to the SDK and is not kept on the tool. + nirium_client.init_x402( + secret_key, + network=network, + max_amount_per_payment=max_amount_per_payment, + ) + self._client = nirium_client + + @property + def history(self) -> list[dict[str, Any]]: + """Every call this tool made: url, status and tx hash (for evidence).""" + return list(self._history) + + def _record(self, entry: dict[str, Any]) -> str: + self._history.append(entry) + return json.dumps(entry, default=str) + + async def _afetch(self, url: str, method: str = "GET") -> str: + method = (method or "GET").upper() + parsed = urlparse(url) + if parsed.scheme not in {"http", "https"} or not parsed.netloc: + return self._record({"status": "error", "url": url, "error": "url must be an absolute http(s) URL"}) + if method not in _ALLOWED_METHODS: + return self._record({"status": "error", "url": url, "error": f"unsupported method {method}"}) + + try: + data = await self._client.x402_fetch(url, method=method) + except X402SpendCapError as e: + return self._record({ + "status": "refused", + "error": "X402SpendCapError", + "url": url, + "cap": e.cap, + "requested_amount_stroops": e.amount, + "asset": e.asset, + "network": e.network, + "signed": False, + "message": redact_secrets( + f"Payment refused before signing: the price is above the per-payment cap of " + f"{e.cap}. Nothing was signed or sent." + ), + }) + except X402NetworkMismatchError as e: + return self._record({ + "status": "refused", + "error": "X402NetworkMismatchError", + "url": url, + "network": e.network, + "offered": e.offered, + "signed": False, + "message": redact_secrets(str(e)), + }) + except Exception as e: # network errors, rejected payment, etc. + return self._record({ + "status": "error", + "error": type(e).__name__, + "url": url, + "message": redact_secrets(e), + }) + + tx_hash = extract_settlement_tx(getattr(self._client, "last_x402_settlement", None)) + if not tx_hash and isinstance(data, dict) and "error" in data: + # The SDK returns non-402 responses as-is (e.g. a 503 from the server). + return self._record({ + "status": "error", + "error": "ServerError", + "url": url, + "signed": False, + "message": redact_secrets(json.dumps(data, default=str)[:500]), + }) + # "paid" when a settlement came back; "free" when the route did not ask for payment. + entry: dict[str, Any] = {"status": "paid" if tx_hash else "free", "url": url, "data": data} + if tx_hash: + entry["tx_hash"] = tx_hash + entry["stellar_expert"] = stellar_expert_tx_url(tx_hash, self.network) + return self._record(entry) + + def _run(self, url: str, method: str = "GET") -> str: + return _run_coro(self._afetch(url, method)) + + async def _arun(self, url: str, method: str = "GET") -> str: + return await self._afetch(url, method) diff --git a/examples/crewai-x402/pytest.ini b/examples/crewai-x402/pytest.ini new file mode 100644 index 0000000..59ac280 --- /dev/null +++ b/examples/crewai-x402/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +asyncio_mode = strict +asyncio_default_fixture_loop_scope = function + +filterwarnings = + ignore::DeprecationWarning + ignore::PendingDeprecationWarning diff --git a/examples/crewai-x402/requirements.txt b/examples/crewai-x402/requirements.txt new file mode 100644 index 0000000..163c026 --- /dev/null +++ b/examples/crewai-x402/requirements.txt @@ -0,0 +1,8 @@ +# Exact versions tested (Python 3.12) +nirium==0.12.7 +crewai==1.15.44 +python-dotenv==1.2.2 + +# Testing +pytest==8.3.0 +pytest-asyncio==0.24.0 diff --git a/examples/crewai-x402/server/package-lock.json b/examples/crewai-x402/server/package-lock.json new file mode 100644 index 0000000..868cf16 --- /dev/null +++ b/examples/crewai-x402/server/package-lock.json @@ -0,0 +1,2130 @@ +{ + "name": "nirium-crewai-x402-server", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "nirium-crewai-x402-server", + "version": "0.1.0", + "dependencies": { + "@x402/core": "2.32.0", + "@x402/express": "2.32.0", + "@x402/extensions": "2.32.0", + "@x402/stellar": "2.32.0", + "dotenv": "^17.4.2", + "express": "5.3.0", + "nirium": "0.19.6" + } + }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.1.tgz", + "integrity": "sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==", + "license": "MIT" + }, + "node_modules/@cfworker/json-schema": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-4.1.6.tgz", + "integrity": "sha512-YzVGTHXf4bzlyAL5KAvHYCdNbbt6zM5cYkAgxqxQPDQM6aZ4ShIIN5yJ+6q7YeonnevxT8k/LmD2tJi/jOiKkg==", + "license": "MIT" + }, + "node_modules/@exodus/bytes": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.16.0.tgz", + "integrity": "sha512-IcpW84uEn3N7ETtNZMlxKhfl6Pec8rUNGOTBtWbK1FKhJxIFAptZyVrvVRVBimAJxJCgc3PxepxkdWWG4DVzfA==", + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@noble/hashes": "^1.8.0 || ^2.0.0" + }, + "peerDependenciesMeta": { + "@noble/hashes": { + "optional": true + } + } + }, + "node_modules/@modelcontextprotocol/server": { + "version": "2.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.0.0-alpha.4.tgz", + "integrity": "sha512-/KEo3ZJ50HlagHp0lz2vPgfBZFtXHu6zTBXT9XqPc+4O9i4+IbBVWKq/a9yAfv/ifp0u3+mRo8SUk5kMKzhN8A==", + "license": "MIT", + "dependencies": { + "zod": "^4.2.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@noble/ciphers": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz", + "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves": { + "version": "1.9.7", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", + "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/ed25519": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-3.2.0.tgz", + "integrity": "sha512-criDgRlnUA09hchYrTy/JUWPIEap5rZxQe6wDWzRx51oWWpDRcUpuNzlgPxDJaOK6AsW9c0wKcj3rKRv6t+bPQ==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scalar/openapi-types": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@scalar/openapi-types/-/openapi-types-0.8.0.tgz", + "integrity": "sha512-WmaxVSfvY5K/TwcG2B2TU1WOe1As1uc2s7myswtP6dBlcjU3hM08SApxv/jmyGaCE8t4gO5BBhmHY4pDUfmr2g==", + "license": "MIT", + "engines": { + "node": ">=22" + } + }, + "node_modules/@scure/base": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", + "integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.7.0.tgz", + "integrity": "sha512-E4FFX/N3f4B80AKWp5dP6ow+flD1LQZo/w8UnLGYZO674jS6YnYeepycOOksv+vLPSpgN35wgKgy+ybfTb2SMw==", + "license": "MIT", + "dependencies": { + "@noble/curves": "~1.9.0", + "@noble/hashes": "~1.8.0", + "@scure/base": "~1.2.5" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.6.0.tgz", + "integrity": "sha512-+lF0BbLiJNwVlev4eKelw1WWLaiKXw7sSl8T6FvBlWkdX+94aGJ4o8XjUdlyhTCjd8c+B3KT3JfS8P0bLRNU6A==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "~1.8.0", + "@scure/base": "~1.2.5" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@signinwithethereum/siwe": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@signinwithethereum/siwe/-/siwe-4.2.1.tgz", + "integrity": "sha512-CQEQhCIgN9blil1YpaGR+wvGPdsBVK6zed5DBu03s1IdbSO3kA/n7Zp+SAkZGiHy3HY6OJm1Su0/Bd33vKK6nQ==", + "license": "Apache-2.0", + "dependencies": { + "@signinwithethereum/siwe-parser": "^4.2.1" + }, + "peerDependencies": { + "ethers": "^5.7.0 || ^6.13.0", + "viem": "^2.7.0" + }, + "peerDependenciesMeta": { + "ethers": { + "optional": true + }, + "viem": { + "optional": true + } + } + }, + "node_modules/@signinwithethereum/siwe-parser": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@signinwithethereum/siwe-parser/-/siwe-parser-4.2.1.tgz", + "integrity": "sha512-GAdwNiBaRpUMTiFfPrbQ3e/RBhPbEhRRN1sZmDMLgLEZuKqKwO7V0ksVzCerE9l8HFKTNw5R/q3kPDCWJRz4zA==", + "license": "Apache-2.0", + "dependencies": { + "@noble/hashes": "^1.7.0", + "apg-js": "^4.4.0" + } + }, + "node_modules/@stellar/js-xdr": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@stellar/js-xdr/-/js-xdr-5.0.0.tgz", + "integrity": "sha512-HBDNKnxr+ecdaEmbZ0mcKkirOF8tXXEbWSw34P3wT40Tn3g+u+cCH17xAWZymzscq8cojHB8340pR8QNVaD32w==", + "license": "Apache-2.0", + "engines": { + "node": ">=22.0.0", + "pnpm": ">=10.0.0" + } + }, + "node_modules/@stellar/stellar-sdk": { + "version": "17.4.0", + "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-17.4.0.tgz", + "integrity": "sha512-IX6gi62yWQ+6Oz56LsVEEeSViSOWJL3BkttftwVmVsu+62nLTWNVsCmTWEzwgNLT/q5HGP25OnlU+hhy2E4wwA==", + "license": "Apache-2.0", + "dependencies": { + "@exodus/bytes": "^1.15.1", + "@noble/ed25519": "^3.1.0", + "@noble/hashes": "^2.2.0", + "@stellar/js-xdr": "^5.0.0", + "@types/json-schema": "^7.0.15", + "axios": "1.20.0", + "bignumber.js": "^11.1.4", + "commander": "^14.0.3", + "eventsource": "^4.1.0", + "feaxios": "^0.0.23", + "smol-toml": "^1.6.1", + "uint8array-extras": "^1.5.0" + }, + "bin": { + "stellar-contract-bindings-typescript": "bin/stellar-contract-bindings-typescript", + "stellar-js": "bin/stellar-js", + "stellar-sdk": "bin/stellar-js" + }, + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/@stellar/stellar-sdk/node_modules/@noble/hashes": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.4.0.tgz", + "integrity": "sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==", + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@toon-format/toon": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@toon-format/toon/-/toon-2.3.1.tgz", + "integrity": "sha512-sWqEMeAJGMda9qRrfPKrX3C4c33CO9SJuvJzzrcBEn5sbDB+k6pSLkDsfN0rVnLQwR97MV3sDgVbcxQNsq8xVw==", + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "license": "MIT" + }, + "node_modules/@x402/core": { + "version": "2.32.0", + "resolved": "https://registry.npmjs.org/@x402/core/-/core-2.32.0.tgz", + "integrity": "sha512-HyS8vbaR3XP79EIATKGMt8eL0Ql46yrfVDrtv1Inmlx4qJl4NU61cJmTh/pSGOCJIeb7ETNhWR/GQ4XsWZcQIA==", + "license": "Apache-2.0", + "dependencies": { + "zod": "^4.6.6" + } + }, + "node_modules/@x402/express": { + "version": "2.32.0", + "resolved": "https://registry.npmjs.org/@x402/express/-/express-2.32.0.tgz", + "integrity": "sha512-aPZDcDsSIAy6dz5YmcuosoBRy4t2VUCwzeZG/S5bxE7xZfxouyRbm3M+mlUNHymAjy4Z/lNqK6jummRe770AGw==", + "license": "Apache-2.0", + "dependencies": { + "@x402/core": "~2.32.0", + "@x402/extensions": "~2.32.0" + }, + "peerDependencies": { + "@x402/paywall": "^2.32.0", + "express": "^4.22.3 || ^5.3.0" + }, + "peerDependenciesMeta": { + "@x402/paywall": { + "optional": true + } + } + }, + "node_modules/@x402/extensions": { + "version": "2.32.0", + "resolved": "https://registry.npmjs.org/@x402/extensions/-/extensions-2.32.0.tgz", + "integrity": "sha512-bvhqNqCjmULkjCpjM1fJvDfoL8tzp1IFcMTXN7QJTwqM22ucNe8B4UefKeQOCpjJ3tuIEbp8k9A0fR0CiYtjrQ==", + "license": "Apache-2.0", + "dependencies": { + "@noble/curves": "^1.9.0", + "@scure/base": "^1.2.6", + "@signinwithethereum/siwe": "^4.1.0", + "@x402/core": "~2.32.0", + "ajv": "^8.18.0", + "jose": "^5.9.6", + "tweetnacl": "^1.0.3", + "viem": "^2.48.11", + "zod": "^4.6.6" + } + }, + "node_modules/@x402/fetch": { + "version": "2.32.0", + "resolved": "https://registry.npmjs.org/@x402/fetch/-/fetch-2.32.0.tgz", + "integrity": "sha512-MxDqmBxQz6I5NWUVu90cQ1XRZayAi8oDpGllDwrwihxfAHloE7eqXkNuFC80IRE3BbMwj8h65aBEaOaiq3EBUQ==", + "license": "Apache-2.0", + "dependencies": { + "@x402/core": "~2.32.0" + } + }, + "node_modules/@x402/stellar": { + "version": "2.32.0", + "resolved": "https://registry.npmjs.org/@x402/stellar/-/stellar-2.32.0.tgz", + "integrity": "sha512-ArexKFv6/Os4toaFP4u5RMN+A6v3WtNjCG5/CenuDQRf8+0Ts99GcNz97lKUgo9CXzJfSqE/QhwUlaZ0oiZc7g==", + "license": "Apache-2.0", + "dependencies": { + "@stellar/stellar-sdk": "^17.4.0", + "@x402/core": "~2.32.0" + }, + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/abitype": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.3.0.tgz", + "integrity": "sha512-fk6Te+bojIFrMvMZrnOO+SxCB+RUksTGOzq/60ZRvs1L+BVzvi2bqt9L3W/17ZLdZsyM1FuYf65P5nlmoiH1Bg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3.22.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/apg-js": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/apg-js/-/apg-js-4.4.0.tgz", + "integrity": "sha512-fefmXFknJmtgtNEXfPwZKYkMFX4Fyeyz+fNF6JWp87biGOPslJbCBVU158zvKRZfHBKnJDy8CMM40oLFGkXT8Q==", + "license": "BSD-2-Clause" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.20.0.tgz", + "integrity": "sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.16.0", + "form-data": "^4.0.6", + "https-proxy-agent": "^5.0.1", + "proxy-from-env": "^2.1.0" + } + }, + "node_modules/base32.js": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base32.js/-/base32.js-0.1.0.tgz", + "integrity": "sha512-n3TkB02ixgBOhTvANakDb4xaMXnYUVkNoRFJjQflcqMQhyEKxEHdj3E6N8t8sUQ0mjH/3/JxzlXuz3ul/J90pQ==", + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/bignumber.js": { + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-11.1.5.tgz", + "integrity": "sha512-6WmzCNtUnfKpbozq+hOgWaZMMzORmYBwF1xZScyoIX3QRYWeKTtxxwDOW5tIz7C9BdjkIYHGTcelCLkXg0mndw==", + "license": "MIT" + }, + "node_modules/body-parser": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz", + "integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^2.1.0", + "debug": "^4.4.3", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.3", + "on-finished": "^2.4.1", + "qs": "^6.16.1", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz", + "integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==", + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/content-disposition": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-2.0.1.tgz", + "integrity": "sha512-e+H0ZXHSWYrENhQzw1LPuP4oF5MzVKmDU6d3hxlvaPEYLLg62MxtQNPRx4SYSuYJSBUgnQIG4HIN2tEtNv7Dog==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dotenv": { + "version": "17.4.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz", + "integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.3.tgz", + "integrity": "sha512-mIteYONiEfc4xWf2F1WXovh1c8npzS00vNeiUPdwFF+QlVJni+gNvpQltLMQhob8rew/bWWc/bGTuUr0EUGt0w==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "license": "MIT" + }, + "node_modules/eventsource": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-4.1.1.tgz", + "integrity": "sha512-D6bTRWh6KahHTK/m4WnjPQyEinNPf9eFLEZSEoj7d6fTibspnAVYfzHvirL7u/aoX5d9YYfIkBVAhmigUELk9w==", + "license": "MIT", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.1.tgz", + "integrity": "sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/express": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.3.0.tgz", + "integrity": "sha512-qCqy1xSoaugxOD4IVHb1ZWdkvCF2W3aE2okKouWj8VwJ+ztskSiXoBnCSJqfKT+cVPJhuJqe9YLbY425+Zh00g==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.3.0", + "content-disposition": "^2.0.1", + "content-type": "^2.0.0", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.8", + "qs": "^6.16.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.1.0", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, + "node_modules/fast-uri": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz", + "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/feaxios": { + "version": "0.0.23", + "resolved": "https://registry.npmjs.org/feaxios/-/feaxios-0.0.23.tgz", + "integrity": "sha512-eghR0A21fvbkcQBgZuMfQhrXxJzC0GNUGC9fXhBge33D+mFDTwl0aJ35zoQQn575BhyjQitRc5N4f+L4cP708g==", + "license": "MIT", + "dependencies": { + "is-retry-allowed": "^3.0.0" + } + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/follow-redirects": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.3.tgz", + "integrity": "sha512-toOSoqN6d51Wjf1aOFJYcoVv1aND9rj/CwjLU0Vz40oDuSpWDayCeKe4JpL5NL0WdFvoOOCI3BRo69HahjbR1A==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/form-data/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/incur": { + "version": "0.4.26", + "resolved": "https://registry.npmjs.org/incur/-/incur-0.4.26.tgz", + "integrity": "sha512-63lwOc8+o1VeFkIW3sWWMrDSP5Dd1NsvucUWyxLUk+DoNRiNl7cj481nlLdlboXkq+tqYPBSlV/7XbylS2S4BA==", + "license": "MIT", + "dependencies": { + "@cfworker/json-schema": "^4.1.1", + "@modelcontextprotocol/server": "2.0.0-alpha.4", + "@scalar/openapi-types": "^0.8.0", + "@toon-format/toon": "^2.1.0", + "tokenx": "^1.3.0", + "yaml": "^2.8.2", + "zod": "^4.3.6" + }, + "bin": { + "incur": "dist/bin.js", + "incur.src": "src/bin.ts" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/is-retry-allowed": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-3.0.0.tgz", + "integrity": "sha512-9xH0xvoggby+u0uGF7cZXdrutWiBiaFG8ZT4YFPXL8NzkyAwX3AKGLeFQLvzDpM430+nDFBZ1LHkie/8ocL06A==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isows": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.7.tgz", + "integrity": "sha512-I1fSfDCZL5P0v33sVqeTDSpcstAg/N+wF5HS033mogOVIp4B+oHC7oOCsA3axAbBSGTJ8QubbNmnIRN/h8U7hg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "peerDependencies": { + "ws": "*" + } + }, + "node_modules/jose": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/jose/-/jose-5.10.0.tgz", + "integrity": "sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz", + "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/mppx": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/mppx/-/mppx-0.21.1.tgz", + "integrity": "sha512-71+y/cOamBOH1+UehF9EgttkGkwCFmlbDGIs2fB/+0WvZqWCqw5zPqY0rKjxhru+jb1nZo9tK4/S3D1aSLCn7w==", + "extraneous": true, + "license": "MIT", + "dependencies": { + "ox": "0.14.65", + "structured-headers": "2.1.0", + "zod": "^4.6.7" + }, + "bin": { + "mppx": "dist/bin.js" + }, + "peerDependencies": { + "@modelcontextprotocol/sdk": ">=1.25.0", + "@stripe/agent-identity": ">=0.3.0", + "@x402/core": ">=2.22.0", + "@x402/evm": ">=2.22.0", + "@x402/express": ">=2.22.0", + "@x402/hono": ">=2.22.0", + "@x402/mcp": ">=2.22.0", + "@x402/next": ">=2.22.0", + "elysia": ">=1.2.0", + "express": ">=5", + "hono": ">=4.12.25", + "next": ">=16.2.6", + "viem": ">=2.57.19" + }, + "peerDependenciesMeta": { + "@modelcontextprotocol/sdk": { + "optional": true + }, + "@stripe/agent-identity": { + "optional": true + }, + "@x402/core": { + "optional": true + }, + "@x402/evm": { + "optional": true + }, + "@x402/express": { + "optional": true + }, + "@x402/hono": { + "optional": true + }, + "@x402/mcp": { + "optional": true + }, + "@x402/next": { + "optional": true + }, + "elysia": { + "optional": true + }, + "express": { + "optional": true + }, + "hono": { + "optional": true + }, + "next": { + "optional": true + } + } + }, + "node_modules/mppx/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "extraneous": true, + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/mppx/node_modules/ox": { + "version": "0.14.65", + "resolved": "https://registry.npmjs.org/ox/-/ox-0.14.65.tgz", + "integrity": "sha512-K7oj+jvEP4Gf78ZOYuWAWzKEX/g5z7p6ukj84gdbFnezmFSt6SpprEp9tH5tymXsywSqRdeqk+8JL4+9o0Schw==", + "extraneous": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "^1.11.0", + "@noble/ciphers": "^1.3.0", + "@noble/curves": "1.9.1", + "@noble/hashes": "^1.8.0", + "@scure/bip32": "^1.7.0", + "@scure/bip39": "^1.6.0", + "abitype": "^1.2.3", + "eventemitter3": "5.0.1" + }, + "peerDependencies": { + "typescript": ">=5.4.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz", + "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", + "license": "MIT", + "dependencies": { + "content-type": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/nirium": { + "version": "0.19.6", + "resolved": "https://registry.npmjs.org/nirium/-/nirium-0.19.6.tgz", + "integrity": "sha512-W2kdqCLNWxfiMQKUC2pPrONFh1y0BMGU1XcGLjgpGFzaZbnITfwwIP5/UzpnFLRrCKbkKs26uXMRPxCR/ghMBQ==", + "license": "Apache-2.0", + "dependencies": { + "@stellar/mpp": "^0.7.1", + "@stellar/stellar-sdk": "^16.3.0", + "@x402/fetch": "^2.28.0", + "@x402/stellar": "^2.28.0", + "mppx": "^0.6.31", + "viem": "^2.55.19", + "ws": "^8.21.3" + }, + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/nirium/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/nirium/node_modules/@noble/curves/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/nirium/node_modules/@noble/hashes": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.4.0.tgz", + "integrity": "sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==", + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/nirium/node_modules/@stellar/js-xdr": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@stellar/js-xdr/-/js-xdr-4.0.0.tgz", + "integrity": "sha512-+NmNa7Tk5BI5XFdy/6xGTqAN4J9a9KgCrCGhj2uEUTCBhLkch0M+QbKzNH8zEnejWe0p8w+0q5hUVX6L3OzoVA==", + "license": "Apache-2.0", + "engines": { + "node": ">=20.0.0", + "pnpm": ">=9.0.0" + } + }, + "node_modules/nirium/node_modules/@stellar/mpp": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@stellar/mpp/-/mpp-0.7.1.tgz", + "integrity": "sha512-L0bwohQU4jKgm3yBFxvrhcYuroRITnUMGmr4N+aJY6q2GYY1bnhenFeTU5Bi0sxXP/5PIRA4ulRHPtqeZ8oTpA==", + "license": "MIT", + "dependencies": { + "zod": "^4.4.3" + }, + "engines": { + "node": ">=22" + }, + "peerDependencies": { + "@stellar/stellar-sdk": "^15.1.0", + "mppx": "^0.6.29" + } + }, + "node_modules/nirium/node_modules/@stellar/stellar-sdk": { + "version": "16.4.1", + "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-16.4.1.tgz", + "integrity": "sha512-0kT+ShOUE6dc0smLEsajuizss1hvlGDsCooM88FqgxNOCKpY8IuQPzCs75RNKMSMITz+dX7KZ5qGhQ2EWGMTTg==", + "license": "Apache-2.0", + "dependencies": { + "@noble/ed25519": "^3.1.0", + "@noble/hashes": "^2.2.0", + "@stellar/js-xdr": "4.0.0", + "axios": "1.20.0", + "base32.js": "^0.1.0", + "bignumber.js": "^11.1.4", + "buffer": "^6.0.3", + "commander": "^14.0.3", + "eventsource": "^4.1.0", + "feaxios": "^0.0.23", + "smol-toml": "^1.6.1", + "uint8array-extras": "^1.5.0" + }, + "bin": { + "stellar-js": "bin/stellar-js" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/nirium/node_modules/mppx": { + "version": "0.6.31", + "resolved": "https://registry.npmjs.org/mppx/-/mppx-0.6.31.tgz", + "integrity": "sha512-euHHDLjNa9DQdPSzpayRBhUb3YVGSNZhVAzoOPmjzqxcEb77ry59uaeSBsWr3IjSxqmpR45cB6aR0uiNSgO6kA==", + "license": "MIT", + "dependencies": { + "incur": "^0.4.8", + "ox": "0.14.27", + "zod": "^4.4.3" + }, + "bin": { + "mppx": "dist/bin.js", + "mppx.src": "src/bin.ts" + }, + "peerDependencies": { + "@modelcontextprotocol/sdk": ">=1.25.0", + "elysia": ">=1", + "express": ">=5", + "hono": ">=4.12.18", + "viem": ">=2.51.0" + }, + "peerDependenciesMeta": { + "@modelcontextprotocol/sdk": { + "optional": true + }, + "elysia": { + "optional": true + }, + "express": { + "optional": true + }, + "hono": { + "optional": true + } + } + }, + "node_modules/nirium/node_modules/ox": { + "version": "0.14.27", + "resolved": "https://registry.npmjs.org/ox/-/ox-0.14.27.tgz", + "integrity": "sha512-+xhLHo/f+f4BH121/1Pomm/1vgBBda1wYiFpTvjSo8o5OcEj76Pf1hGPJiepoYMTQoTm2SKdSBvWkFWk5l07PA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "^1.11.0", + "@noble/ciphers": "^1.3.0", + "@noble/curves": "1.9.1", + "@noble/hashes": "^1.8.0", + "@scure/bip32": "^1.7.0", + "@scure/bip39": "^1.6.0", + "abitype": "^1.2.3", + "eventemitter3": "5.0.1" + }, + "peerDependencies": { + "typescript": ">=5.4.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/nirium/node_modules/ox/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/object-inspect": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.14.0.tgz", + "integrity": "sha512-IVgHNlp/jwQX271+Xzoq9LZNTWXxZK+cEOrGBOBxXNbn7fapnZ+Ts6TVMgNOuAezwG2wdtnMX97tTPK6VEnuOQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz", + "integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/ox": { + "version": "0.14.67", + "resolved": "https://registry.npmjs.org/ox/-/ox-0.14.67.tgz", + "integrity": "sha512-6v6UlwgsmiyTujZp0aVDuN8uIBAtl/QZadBADFRZ2zp1+CM9TqDzd+rPKJ5PYvWPlCvz8JvoO9dTr42+1PhBhA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "^1.11.0", + "@noble/ciphers": "^1.3.0", + "@noble/curves": "1.9.1", + "@noble/hashes": "^1.8.0", + "@scure/bip32": "^1.7.0", + "@scure/bip39": "^1.6.0", + "abitype": "^1.2.3", + "eventemitter3": "5.0.1" + }, + "peerDependencies": { + "typescript": ">=5.4.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/ox/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz", + "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/qs": { + "version": "6.17.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz", + "integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==", + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", + "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/router": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.3.0.tgz", + "integrity": "sha512-bpowRfGjEPe8t9R6fJIzhwmyCGAXwKvxBUsgJm+bJukwdcWmUXbMo7p22w7aYmQBPQTUMNqMV39YX0kMou3z8w==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/smol-toml": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.9.1.tgz", + "integrity": "sha512-j7WyPdf0CJoutMzMoPLF/bVXHtKZIT9Rb4eGeEbWw8X2t5oirjPgpL+OpaENZrILYaXqYwnVH+qgUwVbl+pUJQ==", + "license": "BSD-3-Clause", + "engines": { + "node": ">= 18" + }, + "funding": { + "url": "https://github.com/sponsors/cyyynthia" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/structured-headers": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/structured-headers/-/structured-headers-2.1.0.tgz", + "integrity": "sha512-ClzykN+XQVaSW5UfpOdEWfDplZ1Th7mISdaFvaC2+GjLTeBhGMJw83D/Rw9jPkHOml4oYd3EXaZhbz3gnE5nBQ==", + "extraneous": true, + "license": "MIT", + "engines": { + "node": ">=18", + "npm": ">=6" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tokenx": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/tokenx/-/tokenx-1.6.0.tgz", + "integrity": "sha512-CKTjk345ajvBAUp5xUI9a5KKN0zU0lBueVHQbCskH1Hp6WkUKsPW2qGCYNs0pxNyfzxfo+IIjdt2W4sMbw/qBw==", + "license": "MIT" + }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", + "license": "Unlicense" + }, + "node_modules/type-is": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", + "license": "MIT", + "dependencies": { + "content-type": "^2.0.0", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/uint8array-extras": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/uint8array-extras/-/uint8array-extras-1.6.0.tgz", + "integrity": "sha512-8iAasVS4wUx0gPLjH8Xtz2PeDzTSiy8QiLGu2DT3X5GU+egFEQhpnbtkehbAwjvDcxIERmCYcysiODFmE3Ud0Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/viem": { + "version": "2.58.2", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.58.2.tgz", + "integrity": "sha512-tOdKI6+6oQWbb0NirduHfILojP9uY8YamtYIwallzObzMhhSCxWb2zOVw7SwrkYWTt7JmB1/Of4L3hTokp9GJA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@noble/curves": "1.9.1", + "@noble/hashes": "1.8.0", + "@scure/bip32": "1.7.0", + "@scure/bip39": "1.6.0", + "abitype": "1.2.3", + "isows": "1.0.7", + "ox": "0.14.67", + "ws": "8.21.0" + }, + "peerDependencies": { + "mppx": ">=0.17.0", + "typescript": ">=5.0.4" + }, + "peerDependenciesMeta": { + "mppx": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/viem/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/abitype": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.2.3.tgz", + "integrity": "sha512-Ofer5QUnuUdTFsBRwARMoWKOH1ND5ehwYhJ3OJ/BQO+StkwQjHw0XyVh4vDttzHB7QOFhPHa/o413PJ82gU/Tg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3.22.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, + "node_modules/viem/node_modules/ws": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", + "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, + "node_modules/ws": { + "version": "8.23.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.23.0.tgz", + "integrity": "sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/yaml": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", + "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, + "node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/examples/crewai-x402/server/package.json b/examples/crewai-x402/server/package.json new file mode 100644 index 0000000..9e1073a --- /dev/null +++ b/examples/crewai-x402/server/package.json @@ -0,0 +1,19 @@ +{ + "name": "nirium-crewai-x402-server", + "version": "0.1.0", + "private": true, + "type": "module", + "description": "Testnet x402Serve route for the CrewAI example: one route below the agent's cap, one above.", + "scripts": { + "start": "node server.mjs" + }, + "dependencies": { + "@x402/core": "2.32.0", + "@x402/express": "2.32.0", + "@x402/extensions": "2.32.0", + "@x402/stellar": "2.32.0", + "dotenv": "^17.4.2", + "express": "5.3.0", + "nirium": "0.19.6" + } +} diff --git a/examples/crewai-x402/server/server.mjs b/examples/crewai-x402/server/server.mjs new file mode 100644 index 0000000..9f4b8fe --- /dev/null +++ b/examples/crewai-x402/server/server.mjs @@ -0,0 +1,58 @@ +// A small x402Serve route on stellar:testnet for the CrewAI example. +// +// Two paid routes, so the crew can show both outcomes against a seller you run: +// GET /paid/market-summary costs X402_PRICE (default $0.02), below the agent's $1 cap: paid +// GET /paid/full-report costs $2, above the cap: refused by the agent before signing +// +// Payments go to SELLER_PUBLIC_KEY, a testnet account you own (not the payer's key). +import dotenv from "dotenv"; +import express from "express"; +import { x402Serve } from "nirium"; + +// Same .env as the Python agent, one folder up. +dotenv.config({ path: new URL("../.env", import.meta.url), quiet: true }); + +const payTo = process.env.SELLER_PUBLIC_KEY ?? ""; +const facilitatorApiKey = process.env.FACILITATOR_API_KEY ?? ""; +const port = Number(process.env.X402_SERVER_PORT ?? 3402); +const rawPrice = process.env.X402_PRICE ?? "0.02"; +const cheapPrice = rawPrice.startsWith("$") ? rawPrice : `$${rawPrice}`; + +if (!/^G[A-Z2-7]{55}$/.test(payTo)) { + console.error("SELLER_PUBLIC_KEY must be a testnet public key (G...) that you own. It receives the payments."); + process.exit(1); +} +if (!facilitatorApiKey) { + console.error("FACILITATOR_API_KEY is missing. A free testnet key: https://channels.openzeppelin.com/testnet/gen"); + process.exit(1); +} + +const app = express(); + +app.use( + x402Serve({ + payTo, + network: "stellar:testnet", + facilitatorApiKey, + appName: "Nirium CrewAI x402 example", + routes: { + "GET /paid/market-summary": { price: cheapPrice, description: "Market summary (below the agent's $1 cap)" }, + "GET /paid/full-report": { price: "$2", description: "Full report (above the agent's $1 cap)" }, + }, + }), +); + +// Reached only after x402Serve verified and settled the payment. +app.get("/paid/market-summary", (_req, res) => { + res.json({ ok: true, route: "market-summary", price: cheapPrice, note: "Demo data from your own x402Serve route." }); +}); + +app.get("/paid/full-report", (_req, res) => { + res.json({ ok: true, route: "full-report", price: "$2" }); +}); + +app.listen(port, () => { + console.log(`x402Serve on http://localhost:${port} (stellar:testnet), payTo ${payTo}`); + console.log(` GET /paid/market-summary ${cheapPrice}`); + console.log(" GET /paid/full-report $2"); +}); diff --git a/examples/crewai-x402/test_crew_offline.py b/examples/crewai-x402/test_crew_offline.py new file mode 100644 index 0000000..1849064 --- /dev/null +++ b/examples/crewai-x402/test_crew_offline.py @@ -0,0 +1,94 @@ +"""Offline end-to-end test of the two-agent crew in agent.py. + +A scripted LLM stands in for the model, aiohttp is faked, and the signer is a +spy. The crew, the tool and the Nirium spend cap all run for real. +""" + +from __future__ import annotations + +import os + +os.environ.setdefault("CREWAI_TRACING_ENABLED", "false") +os.environ.setdefault("CREWAI_DISABLE_TELEMETRY", "true") +os.environ.setdefault("OTEL_SDK_DISABLED", "true") + +from typing import Any # noqa: E402 + +import pytest # noqa: E402 +from crewai.llms.base_llm import BaseLLM # noqa: E402 + +import agent as example # noqa: E402 +from test_crewai_tool import CHEAP_URL, EXPENSIVE_URL, TX_HASH, FakeSession, _tool_with # noqa: E402 + +SERVER = "http://localhost:3402" + + +class ScriptedLLM(BaseLLM): + """Scout answers with a URL; payer calls the tool once, then finishes.""" + + def __init__(self, url: str): + super().__init__(model="scripted-offline") + self._url = url + self._payer_turns = 0 + self.prompts: list[str] = [] + + def supports_function_calling(self) -> bool: + return False + + def call(self, messages: Any, tools=None, callbacks=None, available_functions=None, + from_task=None, from_agent=None, response_model=None) -> str: + self.prompts.append(str(messages)) + if getattr(from_agent, "role", "") == "Data scout": + return f"Thought: this route answers the request\nFinal Answer: {self._url}" + self._payer_turns += 1 + if self._payer_turns == 1: + return ( + "Thought: pay the chosen route\nAction: nirium_x402_fetch\n" + f'Action Input: {{"url": "{self._url}"}}' + ) + return "Thought: I have the tool result\nFinal Answer: done, see tool result" + + +@pytest.fixture +def stop_patches(): + started: list = [] + yield started + for p in started: + p.stop() + + +def test_crew_has_two_agents_and_only_payer_has_tool(stop_patches): + tool, _signer, patches = _tool_with(FakeSession(amount="200000")) + stop_patches.extend(patches) + crew = example.build_crew(tool, ScriptedLLM(CHEAP_URL), verbose=False) + scout, payer = crew.agents + assert (scout.role, payer.role) == ("Data scout", "Payer") + assert not scout.tools + assert [t.name for t in payer.tools] == ["nirium_x402_fetch"] + + +def test_crew_pays_cheap_route(stop_patches): + tool, signer, patches = _tool_with(FakeSession(amount="200000")) + stop_patches.extend(patches) + crew = example.build_crew(tool, ScriptedLLM(CHEAP_URL), verbose=False) + + crew.kickoff(inputs={"request": "short market summary", "catalog": example.catalog(SERVER)}) + + assert [h["status"] for h in tool.history] == ["paid"] + assert tool.history[0]["tx_hash"] == TX_HASH + signer.assert_called_once() + + +def test_crew_survives_over_cap_refusal(stop_patches): + session = FakeSession(amount="20000000") # $2 + tool, signer, patches = _tool_with(session) + stop_patches.extend(patches) + crew = example.build_crew(tool, ScriptedLLM(EXPENSIVE_URL), verbose=False) + + result = crew.kickoff(inputs={"request": "full report", "catalog": example.catalog(SERVER)}) + + assert result.raw # crew finished, no exception + assert [h["status"] for h in tool.history] == ["refused"] + assert tool.history[0]["error"] == "X402SpendCapError" + signer.assert_not_called() + assert len(session.requests) == 1 diff --git a/examples/crewai-x402/test_crewai_tool.py b/examples/crewai-x402/test_crewai_tool.py new file mode 100644 index 0000000..ab87eb0 --- /dev/null +++ b/examples/crewai-x402/test_crewai_tool.py @@ -0,0 +1,225 @@ +"""Offline tests for the CrewAI x402 tool. No network, no LLM, no real funds. + +The Nirium SDK runs for real; only aiohttp (the HTTP layer) and the signer are +replaced, so the spend-cap check is the SDK's own code. +""" + +from __future__ import annotations + +import base64 +import json +from typing import Any +from unittest.mock import MagicMock, patch + +import pytest +from crewai.tools import BaseTool +from stellar_sdk import Keypair + +import nirium.client as nirium_client +from nirium import Agent as NiriumAgent +from nirium_crewai_tool import ( + NiriumX402Tool, + extract_settlement_tx, + redact_secrets, + stellar_expert_tx_url, +) + +TESTNET_USDC = "CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA" +PAY_TO = Keypair.random().public_key +TEST_SECRET = Keypair.random().secret # never funded, never leaves this process +CHEAP_URL = "http://localhost:3402/paid/market-summary" +EXPENSIVE_URL = "http://localhost:3402/paid/full-report" +TX_HASH = "ab" * 32 + + +class FakeResponse: + def __init__(self, status: int, headers: dict[str, str] | None = None, body: Any = None): + self.status = status + self.headers = headers or {} + self._body = body + + async def __aenter__(self): + return self + + async def __aexit__(self, *exc): + return False + + async def text(self): + return "" if self._body is None else json.dumps(self._body) + + +class FakeSession: + """Replays a 402 challenge, then (if the client pays) a 200 with a settlement.""" + + def __init__(self, amount: str, network: str = "stellar:testnet"): + accepts = [{ + "scheme": "exact", + "network": network, + "asset": TESTNET_USDC, + "payTo": PAY_TO, + "amount": amount, + "maxTimeoutSeconds": 60, + "extra": {"areFeesSponsored": True}, + }] + challenge = base64.b64encode(json.dumps({"x402Version": 2, "accepts": accepts}).encode()).decode() + settlement = base64.b64encode(json.dumps({"success": True, "transaction": TX_HASH}).encode()).decode() + self.responses = [ + FakeResponse(402, {"payment-required": challenge}), + FakeResponse(200, {"PAYMENT-RESPONSE": settlement}, {"ok": True, "route": "market-summary"}), + ] + self.requests: list[dict[str, Any]] = [] + + async def __aenter__(self): + return self + + async def __aexit__(self, *exc): + return False + + def request(self, method, url, **kwargs): + self.requests.append({"method": method, "url": url, **kwargs}) + return self.responses.pop(0) + + +def _tool_with(session: FakeSession, cap: str = "$1"): + """Real nirium Agent + real tool, fake HTTP, spy signer.""" + signer = MagicMock(return_value="signed-auth-entry-xdr") + patches = [ + patch.object(nirium_client.aiohttp, "ClientSession", return_value=session), + patch.object(NiriumAgent, "_x402_build_transaction", signer), + ] + for p in patches: + p.start() + tool = NiriumX402Tool(TEST_SECRET, network="stellar:testnet", max_amount_per_payment=cap) + return tool, signer, patches + + +@pytest.fixture +def stop_patches(): + started: list = [] + yield started + for p in started: + p.stop() + + +def test_is_crewai_base_tool_and_schema_has_no_secret(): + tool = NiriumX402Tool(TEST_SECRET) + assert isinstance(tool, BaseTool) + assert tool.name == "nirium_x402_fetch" + props = tool.args_schema.model_json_schema()["properties"] + assert set(props) == {"url", "method"} # no secret, no cap exposed to the LLM + dumped = json.dumps(tool.model_dump(mode="json"), default=str) + assert TEST_SECRET not in dumped and TEST_SECRET not in repr(tool) + + +def test_init_passes_cap_and_network_to_sdk(): + client = MagicMock() + NiriumX402Tool(TEST_SECRET, max_amount_per_payment="$0.50", client=client) + client.init_x402.assert_called_once_with(TEST_SECRET, network="stellar:testnet", max_amount_per_payment="$0.50") + + +def test_rejects_mainnet_typo_network(): + with pytest.raises(ValueError): + NiriumX402Tool(TEST_SECRET, network="stellar:moonnet") + + +def test_paid_call_below_cap_signs_and_returns_tx(stop_patches): + session = FakeSession(amount="200000") # 0.02 USDC (7 decimals) + tool, signer, patches = _tool_with(session) + stop_patches.extend(patches) + + result = json.loads(tool.run(url=CHEAP_URL)) + + assert result["status"] == "paid" + assert result["tx_hash"] == TX_HASH + assert result["stellar_expert"] == f"https://stellar.expert/explorer/testnet/tx/{TX_HASH}" + assert result["data"]["ok"] is True + signer.assert_called_once() + assert len(session.requests) == 2 + assert "PAYMENT-SIGNATURE" in session.requests[1]["headers"] + + +def test_over_cap_refused_before_signing(stop_patches): + session = FakeSession(amount="20000000") # $2, above the $1 cap + tool, signer, patches = _tool_with(session) + stop_patches.extend(patches) + + result = json.loads(tool.run(url=EXPENSIVE_URL)) # must not raise + + assert result["status"] == "refused" + assert result["error"] == "X402SpendCapError" + assert result["signed"] is False + assert result["cap"] == "$1" + assert result["requested_amount_stroops"] == "20000000" + signer.assert_not_called() + assert len(session.requests) == 1 # only the challenge; no paid retry + assert tool.history[-1]["status"] == "refused" + + +def test_network_mismatch_refused_before_signing(stop_patches): + session = FakeSession(amount="200000", network="stellar:pubnet") + tool, signer, patches = _tool_with(session) + stop_patches.extend(patches) + + result = json.loads(tool.run(url=CHEAP_URL)) + + assert result["status"] == "refused" + assert result["error"] == "X402NetworkMismatchError" + signer.assert_not_called() + + +@pytest.mark.asyncio +async def test_async_path_inside_running_loop(stop_patches): + session = FakeSession(amount="200000") + tool, _signer, patches = _tool_with(session) + stop_patches.extend(patches) + # _run is also safe when an event loop is already running. + assert json.loads(tool._run(CHEAP_URL))["status"] == "paid" + + +@pytest.mark.asyncio +async def test_arun(stop_patches): + session = FakeSession(amount="20000000") + tool, signer, patches = _tool_with(session) + stop_patches.extend(patches) + assert json.loads(await tool.arun(url=EXPENSIVE_URL))["status"] == "refused" + signer.assert_not_called() + + +def test_errors_are_returned_and_redacted(): + client = MagicMock() + + async def boom(url, method="GET"): + raise RuntimeError(f"bad thing with {TEST_SECRET} PAYMENT-SIGNATURE: abc123") + + client.x402_fetch = boom + tool = NiriumX402Tool(TEST_SECRET, client=client) + out = tool.run(url=CHEAP_URL) + assert TEST_SECRET not in out and "abc123" not in out + assert json.loads(out)["status"] == "error" + + +def test_server_error_without_payment_is_reported(): + client = MagicMock() + client.last_x402_settlement = None + + async def unavailable(url, method="GET"): + return {"error": "x402 payments unavailable", "detail": "facilitator rejected the API key (401)"} + + client.x402_fetch = unavailable + tool = NiriumX402Tool(TEST_SECRET, client=client) + out = json.loads(tool.run(url=CHEAP_URL)) + assert out["status"] == "error" and "facilitator" in out["message"] + + +def test_invalid_url_and_method(): + tool = NiriumX402Tool(TEST_SECRET, client=MagicMock()) + assert json.loads(tool.run(url="not-a-url"))["status"] == "error" + assert json.loads(tool.run(url=CHEAP_URL, method="TRACE"))["status"] == "error" + + +def test_helpers(): + assert extract_settlement_tx({"settleResponse": {"txHash": "h1"}}) == "h1" + assert extract_settlement_tx({"transaction": {"hash": "h2"}}) == "h2" + assert extract_settlement_tx(None) is None + assert redact_secrets(f"key {TEST_SECRET}") == "key [REDACTED]" + assert stellar_expert_tx_url("h").endswith("/testnet/tx/h")