@piprail/sdk 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +16 -3
- package/dist/index.cjs +42 -0
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +42 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ All notable changes to `@piprail/sdk` are documented here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
|
|
5
5
|
versions follow [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [1.8.0] — 2026-06-06
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **Agent tool annotations.** Each of the five `paymentTools(client)` descriptors now carries an
|
|
11
|
+
advisory `annotations` object (MCP-style `ToolAnnotations`: `title`, `readOnlyHint`,
|
|
12
|
+
`destructiveHint`, `idempotentHint`, `openWorldHint`), so an MCP client or agent can reason about a
|
|
13
|
+
tool's nature and render the right consent. The three reads (`piprail_discover` / `quote` / `plan`)
|
|
14
|
+
are flagged **read-only**; `piprail_pay_request` is flagged **value-moving** (not read-only,
|
|
15
|
+
destructive, non-idempotent) so a client can surface that it's the one tool that spends;
|
|
16
|
+
`piprail_register` writes a listing but is non-destructive. New exported type `ToolAnnotations`.
|
|
17
|
+
Backward-compatible — `annotations` is optional and non-MCP runtimes ignore it. (`@piprail/mcp`
|
|
18
|
+
≥ 0.2.2 passes them through on the wire.)
|
|
19
|
+
|
|
7
20
|
## [1.7.0] — 2026-06-06
|
|
8
21
|
|
|
9
22
|
### Added
|
|
@@ -479,6 +492,7 @@ straight into your wallet. The API is small and self-contained.
|
|
|
479
492
|
to your wallet; PipRail never holds funds.
|
|
480
493
|
- `viem ^2.21` is a peer dependency. Node 20+ or a modern browser.
|
|
481
494
|
|
|
495
|
+
[1.8.0]: https://www.npmjs.com/package/@piprail/sdk
|
|
482
496
|
[1.7.0]: https://www.npmjs.com/package/@piprail/sdk
|
|
483
497
|
[1.6.0]: https://www.npmjs.com/package/@piprail/sdk
|
|
484
498
|
[1.5.1]: https://www.npmjs.com/package/@piprail/sdk
|
package/README.md
CHANGED
|
@@ -113,9 +113,15 @@ For **every rail the 402 offers on your chain**, the plan reads **token balance
|
|
|
113
113
|
|
|
114
114
|
```ts
|
|
115
115
|
import { paymentTools } from '@piprail/sdk'
|
|
116
|
-
const tools = paymentTools(client) // → [piprail_quote_payment, piprail_plan_payment, piprail_pay_request]
|
|
116
|
+
const tools = paymentTools(client) // → [piprail_discover, piprail_quote_payment, piprail_plan_payment, piprail_pay_request, piprail_register]
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
+
Each descriptor also carries advisory **`annotations`** (MCP-style `ToolAnnotations` — `title`,
|
|
120
|
+
`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`): the three reads are flagged
|
|
121
|
+
**read-only**, `piprail_pay_request` is flagged **value-moving** (the one tool that spends), and
|
|
122
|
+
`piprail_register` is non-destructive — so an MCP client can render the right consent. They're hints,
|
|
123
|
+
not the boundary; the spend policy is. `@piprail/mcp` advertises them on the wire.
|
|
124
|
+
|
|
119
125
|
See [`examples/agent-tools.mjs`](../examples/agent-tools.mjs) for MCP / AI-SDK wiring.
|
|
120
126
|
|
|
121
127
|
## Be discoverable — find and be found ($0, no backend)
|
|
@@ -162,6 +168,11 @@ const hits = await client.discover({ query: 'weather', maxPrice: 0.01 })
|
|
|
162
168
|
const res = await client.fetch(hits[0].resource) // then quote → plan → pay as usual
|
|
163
169
|
```
|
|
164
170
|
|
|
171
|
+
`network` defaults to `'self'` (your chain only); pass `'any'` to search every chain, or a CAIP-2 id
|
|
172
|
+
(`'eip155:8453'`) for a specific one. Chain slugs map to CAIP-2 through the `SLUG_TO_CAIP2` table —
|
|
173
|
+
adding a chain adds one entry there (see [DISCOVERY.md](./DISCOVERY.md) §2.5), and an unresolved
|
|
174
|
+
network is kept, never hidden.
|
|
175
|
+
|
|
165
176
|
**3) Emit a discovery file** — turn your gate's config into the artifacts a crawler reads (pure, no
|
|
166
177
|
I/O); serve the result as a static file on **your own** origin:
|
|
167
178
|
|
|
@@ -173,11 +184,13 @@ const openapi = buildOpenApi({
|
|
|
173
184
|
origin: 'https://api.example.com',
|
|
174
185
|
resources: [await gate.describe('https://api.example.com/report')],
|
|
175
186
|
})
|
|
176
|
-
// serve `openapi` at https://api.example.com/openapi.json
|
|
187
|
+
// serve `openapi` at https://api.example.com/openapi.json — each priced op carries an `x-payment-info`
|
|
188
|
+
// block (the field indexes crawl) plus a default root `x-generator` attribution stamp.
|
|
177
189
|
// buildWellKnownX402(...) emits the legacy /.well-known/x402 file; buildX402DnsTxt(...) the _x402 DNS line
|
|
178
190
|
```
|
|
179
191
|
|
|
180
|
-
For an LLM/MCP
|
|
192
|
+
For an LLM/MCP these are two more tools — **`piprail_discover`** (find) and **`piprail_register`**
|
|
193
|
+
(be found) — on top of the three payment tools, so `paymentTools(client)` / `@piprail/mcp` expose **five**.
|
|
181
194
|
|
|
182
195
|
> **Two honest caveats.** The open indexes assume the mainstream `exact` scheme, so to be *usefully*
|
|
183
196
|
> listed also offer a standard `exact` USDC rail on Base/Solana (`discover()` results are
|
package/dist/index.cjs
CHANGED
|
@@ -2040,6 +2040,13 @@ function paymentTools(client) {
|
|
|
2040
2040
|
{
|
|
2041
2041
|
name: "piprail_discover",
|
|
2042
2042
|
description: `Find x402 payment-gated resources on the OPEN indexes (a phone book of payable APIs) WITHOUT paying. Use it to answer "what can I buy?" \u2014 search by topic, then quote/plan/pay a chosen one. By default returns only resources payable on your wallet's chain (network='self'); pass 'any' for every chain. Results are cross-scheme: ALWAYS call piprail_quote_payment on a chosen resource (it re-checks the live price) before piprail_pay_request.`,
|
|
2043
|
+
annotations: {
|
|
2044
|
+
title: "Discover payable x402 APIs",
|
|
2045
|
+
readOnlyHint: true,
|
|
2046
|
+
// reads the open indexes only; never pays
|
|
2047
|
+
openWorldHint: true
|
|
2048
|
+
// reaches external indexes (402 Index, CDP Bazaar)
|
|
2049
|
+
},
|
|
2043
2050
|
parameters: {
|
|
2044
2051
|
type: "object",
|
|
2045
2052
|
properties: {
|
|
@@ -2076,6 +2083,13 @@ function paymentTools(client) {
|
|
|
2076
2083
|
{
|
|
2077
2084
|
name: "piprail_quote_payment",
|
|
2078
2085
|
description: "Get the price of an x402 payment-gated URL WITHOUT paying. Returns the amount, token, chain, recipient, and whether it is within the spend policy. Returns { gated: false } when the URL needs no payment. Call this first to decide whether a resource is worth buying.",
|
|
2086
|
+
annotations: {
|
|
2087
|
+
title: "Quote an x402 price",
|
|
2088
|
+
readOnlyHint: true,
|
|
2089
|
+
// reads the 402 challenge; never pays
|
|
2090
|
+
openWorldHint: true
|
|
2091
|
+
// fetches an arbitrary URL
|
|
2092
|
+
},
|
|
2079
2093
|
parameters: {
|
|
2080
2094
|
type: "object",
|
|
2081
2095
|
properties: {
|
|
@@ -2092,6 +2106,13 @@ function paymentTools(client) {
|
|
|
2092
2106
|
{
|
|
2093
2107
|
name: "piprail_plan_payment",
|
|
2094
2108
|
description: "Check whether you CAN pay an x402-gated URL before paying. Reads your wallet balance, native gas, and whether the recipient can receive \u2014 across every rail the URL offers on your chain \u2014 and returns { gated, payable, best, options, fundingHint }. payable:false means do NOT attempt the payment; fundingHint says exactly what to top up. Call this before piprail_pay_request so you never commit to a payment you cannot finish. Returns { gated: false } when no payment is needed.",
|
|
2109
|
+
annotations: {
|
|
2110
|
+
title: "Plan an x402 payment",
|
|
2111
|
+
readOnlyHint: true,
|
|
2112
|
+
// reads balances + the challenge; never pays
|
|
2113
|
+
openWorldHint: true
|
|
2114
|
+
// fetches a URL and reads chain state
|
|
2115
|
+
},
|
|
2095
2116
|
parameters: {
|
|
2096
2117
|
type: "object",
|
|
2097
2118
|
properties: {
|
|
@@ -2130,6 +2151,17 @@ function paymentTools(client) {
|
|
|
2130
2151
|
{
|
|
2131
2152
|
name: "piprail_pay_request",
|
|
2132
2153
|
description: "Fetch an x402 payment-gated URL, automatically paying the required on-chain payment if needed (subject to the spend policy + approval hook). Returns the HTTP status, the response body, and a payment receipt if one settled. If the payment is refused by policy or the approval hook, returns { declined: true, reason } \u2014 no funds moved.",
|
|
2154
|
+
annotations: {
|
|
2155
|
+
title: "Pay an x402 request",
|
|
2156
|
+
readOnlyHint: false,
|
|
2157
|
+
// this is the one tool that MOVES FUNDS
|
|
2158
|
+
destructiveHint: true,
|
|
2159
|
+
// an on-chain payment is value-moving and not reversible
|
|
2160
|
+
idempotentHint: false,
|
|
2161
|
+
// paying twice = two payments
|
|
2162
|
+
openWorldHint: true
|
|
2163
|
+
// fetches a URL and settles on-chain
|
|
2164
|
+
},
|
|
2133
2165
|
parameters: {
|
|
2134
2166
|
type: "object",
|
|
2135
2167
|
properties: {
|
|
@@ -2180,6 +2212,16 @@ function paymentTools(client) {
|
|
|
2180
2212
|
{
|
|
2181
2213
|
name: "piprail_register",
|
|
2182
2214
|
description: "List an x402 payment-gated resource YOU run on the open indexes so other agents can discover it. Default target is 402 Index \u2014 no auth, no signature, no payment; searchable within seconds. Returns one outcome per index ({ source, ok, detail }); a step the chain can't satisfy comes back ok:false with the reason. Moves no funds; nothing is PipRail-hosted.",
|
|
2215
|
+
annotations: {
|
|
2216
|
+
title: "Register an x402 endpoint",
|
|
2217
|
+
readOnlyHint: false,
|
|
2218
|
+
// writes a listing to an external index
|
|
2219
|
+
destructiveHint: false,
|
|
2220
|
+
// adds a listing; nothing is destroyed and no funds move
|
|
2221
|
+
openWorldHint: true
|
|
2222
|
+
// posts to external indexes (402 Index)
|
|
2223
|
+
// idempotentHint intentionally omitted — index dedup behaviour isn't guaranteed.
|
|
2224
|
+
},
|
|
2183
2225
|
parameters: {
|
|
2184
2226
|
type: "object",
|
|
2185
2227
|
properties: {
|
package/dist/index.d.cts
CHANGED
|
@@ -4636,6 +4636,25 @@ declare class PipRailClient {
|
|
|
4636
4636
|
*/
|
|
4637
4637
|
declare function planAcross(clients: PipRailClient[], url: string, init?: RequestInit): Promise<PaymentPlan | null>;
|
|
4638
4638
|
|
|
4639
|
+
/**
|
|
4640
|
+
* MCP-style tool annotations — optional, advisory hints that let an MCP client or
|
|
4641
|
+
* agent reason about a tool's *nature* (is it safe to call freely? does it move
|
|
4642
|
+
* value?). They mirror the MCP spec's `ToolAnnotations`. NOTE: hints only — a
|
|
4643
|
+
* client must never make a security decision solely on these; the spend policy is
|
|
4644
|
+
* the real boundary.
|
|
4645
|
+
*/
|
|
4646
|
+
interface ToolAnnotations {
|
|
4647
|
+
/** Human-friendly title for the tool. */
|
|
4648
|
+
title?: string;
|
|
4649
|
+
/** True when the tool only READS — no state change, no funds moved. */
|
|
4650
|
+
readOnlyHint?: boolean;
|
|
4651
|
+
/** True when the tool may move value or do something not easily undone (only meaningful when not read-only). */
|
|
4652
|
+
destructiveHint?: boolean;
|
|
4653
|
+
/** True when calling repeatedly with the same args has no additional effect. */
|
|
4654
|
+
idempotentHint?: boolean;
|
|
4655
|
+
/** True when the tool reaches the open world — external indexes, chains, or arbitrary URLs. */
|
|
4656
|
+
openWorldHint?: boolean;
|
|
4657
|
+
}
|
|
4639
4658
|
/** A framework-agnostic tool definition an agent runtime can register. */
|
|
4640
4659
|
interface AgentTool {
|
|
4641
4660
|
/** Unique tool name (snake_case, namespaced `piprail_…`). */
|
|
@@ -4644,6 +4663,8 @@ interface AgentTool {
|
|
|
4644
4663
|
description: string;
|
|
4645
4664
|
/** JSON Schema (draft-07 object) describing the arguments. */
|
|
4646
4665
|
parameters: Record<string, unknown>;
|
|
4666
|
+
/** Advisory MCP-style hints about the tool's nature (read-only, value-moving, …). */
|
|
4667
|
+
annotations?: ToolAnnotations;
|
|
4647
4668
|
/** Execute the tool. Returns a JSON-serialisable result. */
|
|
4648
4669
|
invoke: (args: Record<string, unknown>) => Promise<unknown>;
|
|
4649
4670
|
}
|
|
@@ -5296,4 +5317,4 @@ declare function encodeXPaymentHeader(input: {
|
|
|
5296
5317
|
x402Version?: number;
|
|
5297
5318
|
}): string;
|
|
5298
5319
|
|
|
5299
|
-
export { type AcceptOption, type AddressId, type AgentTool, type AlgorandToken, type AptosToken, type AssetId, type BuildExactParams, CHAINS, type Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoverySigner, type DiscoverySource, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, GENERATOR, InsufficientFundsError, InvalidEnvelopeError, type ManifestInput, MaxRetriesExceededError, MissingDriverError, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, type PayBlocker, type PayOption, type PayWarning, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, PaymentTimeoutError, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, type PolicyDecision, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SolanaToken, type SpendAssetTotal, type SpendRecord, type SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type TronToken, UnknownTokenError, UnsupportedNetworkError, type VerifyErrorCode, type VerifyPaymentResult, type VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, type WellKnownX402, WrongChainError, WrongFamilyError, type X402AcceptEntry, type X402Challenge, type X402DnsRecord, type X402InvalidBody, type X402PaymentSignature, type X402Receipt, type X402ResourceObject, type XrplToken, buildChallengeHeader, buildExactAuthorization, buildOpenApi, buildReceiptHeader, buildSignatureHeader, buildWellKnownX402, buildX402DnsTxt, chainIdForExactNetwork, createPaymentGate, encodeXPaymentHeader, evaluatePolicy, normalizeNetwork, parseChallenge, parseExactRequirements, parseReceipt, parseSignatureHeader, paymentTools, pickAccept, planAcross, register402Index, registerDriver, registerX402Scan, requirePayment, resolveChain, searchOpenIndexes, toInsufficientFundsError, toInvalidBody };
|
|
5320
|
+
export { type AcceptOption, type AddressId, type AgentTool, type AlgorandToken, type AptosToken, type AssetId, type BuildExactParams, CHAINS, type Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoverySigner, type DiscoverySource, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, GENERATOR, InsufficientFundsError, InvalidEnvelopeError, type ManifestInput, MaxRetriesExceededError, MissingDriverError, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, type PayBlocker, type PayOption, type PayWarning, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, PaymentTimeoutError, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, type PolicyDecision, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SolanaToken, type SpendAssetTotal, type SpendRecord, type SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UnknownTokenError, UnsupportedNetworkError, type VerifyErrorCode, type VerifyPaymentResult, type VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, type WellKnownX402, WrongChainError, WrongFamilyError, type X402AcceptEntry, type X402Challenge, type X402DnsRecord, type X402InvalidBody, type X402PaymentSignature, type X402Receipt, type X402ResourceObject, type XrplToken, buildChallengeHeader, buildExactAuthorization, buildOpenApi, buildReceiptHeader, buildSignatureHeader, buildWellKnownX402, buildX402DnsTxt, chainIdForExactNetwork, createPaymentGate, encodeXPaymentHeader, evaluatePolicy, normalizeNetwork, parseChallenge, parseExactRequirements, parseReceipt, parseSignatureHeader, paymentTools, pickAccept, planAcross, register402Index, registerDriver, registerX402Scan, requirePayment, resolveChain, searchOpenIndexes, toInsufficientFundsError, toInvalidBody };
|
package/dist/index.d.ts
CHANGED
|
@@ -4636,6 +4636,25 @@ declare class PipRailClient {
|
|
|
4636
4636
|
*/
|
|
4637
4637
|
declare function planAcross(clients: PipRailClient[], url: string, init?: RequestInit): Promise<PaymentPlan | null>;
|
|
4638
4638
|
|
|
4639
|
+
/**
|
|
4640
|
+
* MCP-style tool annotations — optional, advisory hints that let an MCP client or
|
|
4641
|
+
* agent reason about a tool's *nature* (is it safe to call freely? does it move
|
|
4642
|
+
* value?). They mirror the MCP spec's `ToolAnnotations`. NOTE: hints only — a
|
|
4643
|
+
* client must never make a security decision solely on these; the spend policy is
|
|
4644
|
+
* the real boundary.
|
|
4645
|
+
*/
|
|
4646
|
+
interface ToolAnnotations {
|
|
4647
|
+
/** Human-friendly title for the tool. */
|
|
4648
|
+
title?: string;
|
|
4649
|
+
/** True when the tool only READS — no state change, no funds moved. */
|
|
4650
|
+
readOnlyHint?: boolean;
|
|
4651
|
+
/** True when the tool may move value or do something not easily undone (only meaningful when not read-only). */
|
|
4652
|
+
destructiveHint?: boolean;
|
|
4653
|
+
/** True when calling repeatedly with the same args has no additional effect. */
|
|
4654
|
+
idempotentHint?: boolean;
|
|
4655
|
+
/** True when the tool reaches the open world — external indexes, chains, or arbitrary URLs. */
|
|
4656
|
+
openWorldHint?: boolean;
|
|
4657
|
+
}
|
|
4639
4658
|
/** A framework-agnostic tool definition an agent runtime can register. */
|
|
4640
4659
|
interface AgentTool {
|
|
4641
4660
|
/** Unique tool name (snake_case, namespaced `piprail_…`). */
|
|
@@ -4644,6 +4663,8 @@ interface AgentTool {
|
|
|
4644
4663
|
description: string;
|
|
4645
4664
|
/** JSON Schema (draft-07 object) describing the arguments. */
|
|
4646
4665
|
parameters: Record<string, unknown>;
|
|
4666
|
+
/** Advisory MCP-style hints about the tool's nature (read-only, value-moving, …). */
|
|
4667
|
+
annotations?: ToolAnnotations;
|
|
4647
4668
|
/** Execute the tool. Returns a JSON-serialisable result. */
|
|
4648
4669
|
invoke: (args: Record<string, unknown>) => Promise<unknown>;
|
|
4649
4670
|
}
|
|
@@ -5296,4 +5317,4 @@ declare function encodeXPaymentHeader(input: {
|
|
|
5296
5317
|
x402Version?: number;
|
|
5297
5318
|
}): string;
|
|
5298
5319
|
|
|
5299
|
-
export { type AcceptOption, type AddressId, type AgentTool, type AlgorandToken, type AptosToken, type AssetId, type BuildExactParams, CHAINS, type Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoverySigner, type DiscoverySource, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, GENERATOR, InsufficientFundsError, InvalidEnvelopeError, type ManifestInput, MaxRetriesExceededError, MissingDriverError, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, type PayBlocker, type PayOption, type PayWarning, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, PaymentTimeoutError, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, type PolicyDecision, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SolanaToken, type SpendAssetTotal, type SpendRecord, type SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type TronToken, UnknownTokenError, UnsupportedNetworkError, type VerifyErrorCode, type VerifyPaymentResult, type VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, type WellKnownX402, WrongChainError, WrongFamilyError, type X402AcceptEntry, type X402Challenge, type X402DnsRecord, type X402InvalidBody, type X402PaymentSignature, type X402Receipt, type X402ResourceObject, type XrplToken, buildChallengeHeader, buildExactAuthorization, buildOpenApi, buildReceiptHeader, buildSignatureHeader, buildWellKnownX402, buildX402DnsTxt, chainIdForExactNetwork, createPaymentGate, encodeXPaymentHeader, evaluatePolicy, normalizeNetwork, parseChallenge, parseExactRequirements, parseReceipt, parseSignatureHeader, paymentTools, pickAccept, planAcross, register402Index, registerDriver, registerX402Scan, requirePayment, resolveChain, searchOpenIndexes, toInsufficientFundsError, toInvalidBody };
|
|
5320
|
+
export { type AcceptOption, type AddressId, type AgentTool, type AlgorandToken, type AptosToken, type AssetId, type BuildExactParams, CHAINS, type Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoverySigner, type DiscoverySource, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, GENERATOR, InsufficientFundsError, InvalidEnvelopeError, type ManifestInput, MaxRetriesExceededError, MissingDriverError, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, type PayBlocker, type PayOption, type PayWarning, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, PaymentTimeoutError, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, type PolicyDecision, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SolanaToken, type SpendAssetTotal, type SpendRecord, type SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UnknownTokenError, UnsupportedNetworkError, type VerifyErrorCode, type VerifyPaymentResult, type VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, type WellKnownX402, WrongChainError, WrongFamilyError, type X402AcceptEntry, type X402Challenge, type X402DnsRecord, type X402InvalidBody, type X402PaymentSignature, type X402Receipt, type X402ResourceObject, type XrplToken, buildChallengeHeader, buildExactAuthorization, buildOpenApi, buildReceiptHeader, buildSignatureHeader, buildWellKnownX402, buildX402DnsTxt, chainIdForExactNetwork, createPaymentGate, encodeXPaymentHeader, evaluatePolicy, normalizeNetwork, parseChallenge, parseExactRequirements, parseReceipt, parseSignatureHeader, paymentTools, pickAccept, planAcross, register402Index, registerDriver, registerX402Scan, requirePayment, resolveChain, searchOpenIndexes, toInsufficientFundsError, toInvalidBody };
|
package/dist/index.js
CHANGED
|
@@ -2040,6 +2040,13 @@ function paymentTools(client) {
|
|
|
2040
2040
|
{
|
|
2041
2041
|
name: "piprail_discover",
|
|
2042
2042
|
description: `Find x402 payment-gated resources on the OPEN indexes (a phone book of payable APIs) WITHOUT paying. Use it to answer "what can I buy?" \u2014 search by topic, then quote/plan/pay a chosen one. By default returns only resources payable on your wallet's chain (network='self'); pass 'any' for every chain. Results are cross-scheme: ALWAYS call piprail_quote_payment on a chosen resource (it re-checks the live price) before piprail_pay_request.`,
|
|
2043
|
+
annotations: {
|
|
2044
|
+
title: "Discover payable x402 APIs",
|
|
2045
|
+
readOnlyHint: true,
|
|
2046
|
+
// reads the open indexes only; never pays
|
|
2047
|
+
openWorldHint: true
|
|
2048
|
+
// reaches external indexes (402 Index, CDP Bazaar)
|
|
2049
|
+
},
|
|
2043
2050
|
parameters: {
|
|
2044
2051
|
type: "object",
|
|
2045
2052
|
properties: {
|
|
@@ -2076,6 +2083,13 @@ function paymentTools(client) {
|
|
|
2076
2083
|
{
|
|
2077
2084
|
name: "piprail_quote_payment",
|
|
2078
2085
|
description: "Get the price of an x402 payment-gated URL WITHOUT paying. Returns the amount, token, chain, recipient, and whether it is within the spend policy. Returns { gated: false } when the URL needs no payment. Call this first to decide whether a resource is worth buying.",
|
|
2086
|
+
annotations: {
|
|
2087
|
+
title: "Quote an x402 price",
|
|
2088
|
+
readOnlyHint: true,
|
|
2089
|
+
// reads the 402 challenge; never pays
|
|
2090
|
+
openWorldHint: true
|
|
2091
|
+
// fetches an arbitrary URL
|
|
2092
|
+
},
|
|
2079
2093
|
parameters: {
|
|
2080
2094
|
type: "object",
|
|
2081
2095
|
properties: {
|
|
@@ -2092,6 +2106,13 @@ function paymentTools(client) {
|
|
|
2092
2106
|
{
|
|
2093
2107
|
name: "piprail_plan_payment",
|
|
2094
2108
|
description: "Check whether you CAN pay an x402-gated URL before paying. Reads your wallet balance, native gas, and whether the recipient can receive \u2014 across every rail the URL offers on your chain \u2014 and returns { gated, payable, best, options, fundingHint }. payable:false means do NOT attempt the payment; fundingHint says exactly what to top up. Call this before piprail_pay_request so you never commit to a payment you cannot finish. Returns { gated: false } when no payment is needed.",
|
|
2109
|
+
annotations: {
|
|
2110
|
+
title: "Plan an x402 payment",
|
|
2111
|
+
readOnlyHint: true,
|
|
2112
|
+
// reads balances + the challenge; never pays
|
|
2113
|
+
openWorldHint: true
|
|
2114
|
+
// fetches a URL and reads chain state
|
|
2115
|
+
},
|
|
2095
2116
|
parameters: {
|
|
2096
2117
|
type: "object",
|
|
2097
2118
|
properties: {
|
|
@@ -2130,6 +2151,17 @@ function paymentTools(client) {
|
|
|
2130
2151
|
{
|
|
2131
2152
|
name: "piprail_pay_request",
|
|
2132
2153
|
description: "Fetch an x402 payment-gated URL, automatically paying the required on-chain payment if needed (subject to the spend policy + approval hook). Returns the HTTP status, the response body, and a payment receipt if one settled. If the payment is refused by policy or the approval hook, returns { declined: true, reason } \u2014 no funds moved.",
|
|
2154
|
+
annotations: {
|
|
2155
|
+
title: "Pay an x402 request",
|
|
2156
|
+
readOnlyHint: false,
|
|
2157
|
+
// this is the one tool that MOVES FUNDS
|
|
2158
|
+
destructiveHint: true,
|
|
2159
|
+
// an on-chain payment is value-moving and not reversible
|
|
2160
|
+
idempotentHint: false,
|
|
2161
|
+
// paying twice = two payments
|
|
2162
|
+
openWorldHint: true
|
|
2163
|
+
// fetches a URL and settles on-chain
|
|
2164
|
+
},
|
|
2133
2165
|
parameters: {
|
|
2134
2166
|
type: "object",
|
|
2135
2167
|
properties: {
|
|
@@ -2180,6 +2212,16 @@ function paymentTools(client) {
|
|
|
2180
2212
|
{
|
|
2181
2213
|
name: "piprail_register",
|
|
2182
2214
|
description: "List an x402 payment-gated resource YOU run on the open indexes so other agents can discover it. Default target is 402 Index \u2014 no auth, no signature, no payment; searchable within seconds. Returns one outcome per index ({ source, ok, detail }); a step the chain can't satisfy comes back ok:false with the reason. Moves no funds; nothing is PipRail-hosted.",
|
|
2215
|
+
annotations: {
|
|
2216
|
+
title: "Register an x402 endpoint",
|
|
2217
|
+
readOnlyHint: false,
|
|
2218
|
+
// writes a listing to an external index
|
|
2219
|
+
destructiveHint: false,
|
|
2220
|
+
// adds a listing; nothing is destroyed and no funds move
|
|
2221
|
+
openWorldHint: true
|
|
2222
|
+
// posts to external indexes (402 Index)
|
|
2223
|
+
// idempotentHint intentionally omitted — index dedup behaviour isn't guaranteed.
|
|
2224
|
+
},
|
|
2183
2225
|
parameters: {
|
|
2184
2226
|
type: "object",
|
|
2185
2227
|
properties: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piprail/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Accept x402 crypto payments across 28 chains — every major EVM chain plus Solana, TON, Tron, NEAR, Sui, Aptos, Algorand, Stellar & XRPL — in a couple of lines. No backend, no database, no fee; payments settle straight to your wallet.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|