@zeroxyz/sdk 0.8.0 → 0.9.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 CHANGED
@@ -4,6 +4,13 @@ All notable changes to `@zeroxyz/sdk` will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) — with the pre-1.0 caveat that minor versions may include breaking changes.
6
6
 
7
+ ## 0.9.0
8
+
9
+ ### Added
10
+
11
+ - **`CapabilityResponse.pricing`** — the server-resolved price as a single structured object: `{ kind, summary, primary, accepted }`. `summary` is the canonical display string (render it verbatim instead of re-deriving from raw fields); `kind` classifies the price shape (`static | dynamic | session | metered | subscription | free | unknown`); `primary`/`accepted[]` carry the normalized payment options (`protocol`, `network`, `amountUsd`, `per`, `confidence`, optional `depositUsd`). Optional — absent on older API deploys. (#708, ZERO-199)
12
+ - **Price fields the server was already emitting but the SDK schemas silently stripped** (#687, ZERO-199): `CapabilityResponse.priceDynamic` / `priceHint` (usage-priced caps advertise a rate like `"$0.01/result"`, not a flat scalar), `sessionDeposit` (`{ amountUsd, asset }` — the upfront channel deposit for `mode='session'` caps, distinct from the per-call price), `priceStatus` (`priced | proven_free | free_handshake | unknown_unparsed | unprobed`) and `requiresHandshake`, per-rail `asset`/`unit`/`depositMicros`/`planRef` on `paymentMethods[]`, and `SearchResult.protocol`.
13
+
7
14
  ## 0.8.0
8
15
 
9
16
  ### Added
package/README.md CHANGED
@@ -188,7 +188,7 @@ for (const warning of result.warnings ?? []) {
188
188
 
189
189
  `maxPay` is your hard per-call ceiling, in USDC. The challenge amount is checked against it **before** anything is signed; an over-cap challenge aborts with `outcome: "payment_failed"` and no on-chain spend. Set it on every paid call — it's the guardrail that keeps a mispriced or hostile endpoint from draining the wallet.
190
190
 
191
- To put a human in the loop before any spend, read the price up front (`cost.amount` is on every search result and on `capabilities.get()`), show it to your user, and only call `fetch()` with `maxPay` once they approve.
191
+ To put a human in the loop before any spend, read the price up front, show it to your user, and only call `fetch()` with `maxPay` once they approve. Prefer `capabilities.get()`'s **`pricing`** object when present: `pricing.summary` is the server-resolved display string (render it verbatim — don't re-derive from raw fields), `pricing.kind` classifies the shape (`static | dynamic | session | metered | subscription | free | unknown`), and `pricing.primary.amountUsd` / `depositUsd` give the structured numbers for sizing `maxPay`. `cost.amount` remains on every search result as the raw advertised scalar, but it flattens usage-priced caps — a `dynamic` cap's real cost scales with input.
192
192
 
193
193
  ## Wallet & funding
194
194
 
@@ -1838,7 +1838,7 @@ var clientFetch = async (client, url, opts = {}) => {
1838
1838
 
1839
1839
  // package.json
1840
1840
  var package_default = {
1841
- version: "0.8.0"};
1841
+ version: "0.9.0"};
1842
1842
 
1843
1843
  // src/version.ts
1844
1844
  var SDK_VERSION = package_default.version;
@@ -2442,6 +2442,15 @@ var ratingSchema = zod.z.object({
2442
2442
  });
2443
2443
 
2444
2444
  // src/schemas/capabilities.ts
2445
+ var pricingOptionSchema = zod.z.object({
2446
+ kind: zod.z.string(),
2447
+ protocol: zod.z.string(),
2448
+ network: zod.z.string().nullable(),
2449
+ amountUsd: zod.z.string().nullable(),
2450
+ per: zod.z.string(),
2451
+ confidence: zod.z.string(),
2452
+ depositUsd: zod.z.string().optional()
2453
+ });
2445
2454
  var capabilityResponseSchema = zod.z.object({
2446
2455
  uid: zod.z.string(),
2447
2456
  slug: zod.z.string(),
@@ -2466,6 +2475,23 @@ var capabilityResponseSchema = zod.z.object({
2466
2475
  instructions: zod.z.string().nullable().optional(),
2467
2476
  displayCostAmount: zod.z.string(),
2468
2477
  displayCostAsset: zod.z.string(),
2478
+ // Whether the upstream advertises variable/usage-based pricing, and the raw
2479
+ // hint string (e.g. "$0.01/result"). The server emits both; without them an
2480
+ // agent sees a single scalar with no signal that the price scales with input
2481
+ // (ZERO-199). Optional so an older API deploy still parses.
2482
+ priceDynamic: zod.z.boolean().optional(),
2483
+ priceHint: zod.z.string().nullable().optional(),
2484
+ // ZERO-199: the authoritative price classification. Only `proven_free` may be
2485
+ // rendered "Free"; `unknown_unparsed` is a parse miss (never free); a parse
2486
+ // miss must not become "0"→Free. Optional so older deploys still parse.
2487
+ priceStatus: zod.z.enum([
2488
+ "priced",
2489
+ "proven_free",
2490
+ "free_handshake",
2491
+ "unknown_unparsed",
2492
+ "unprobed"
2493
+ ]).optional(),
2494
+ requiresHandshake: zod.z.boolean().optional(),
2469
2495
  reviewCount: zod.z.number(),
2470
2496
  rating: ratingSchema,
2471
2497
  priceObserved: zod.z.object({
@@ -2488,9 +2514,27 @@ var capabilityResponseSchema = zod.z.object({
2488
2514
  mode: zod.z.string(),
2489
2515
  costAmount: zod.z.string(),
2490
2516
  costPer: zod.z.string(),
2491
- priority: zod.z.number()
2517
+ priority: zod.z.number(),
2518
+ // ZERO-199 rail-union fields (optional; older deploys omit them).
2519
+ asset: zod.z.string().nullable().optional(),
2520
+ unit: zod.z.string().optional(),
2521
+ depositMicros: zod.z.number().nullable().optional(),
2522
+ planRef: zod.z.string().nullable().optional()
2492
2523
  })
2493
2524
  ).nullable(),
2525
+ // Recommended channel deposit for a `mode='session'` cap (the seller's
2526
+ // advertised `suggestedDeposit`). Without it an agent can't size an MPP
2527
+ // session channel. The server emits it; optional for older-deploy parsing
2528
+ // (ZERO-199).
2529
+ sessionDeposit: zod.z.object({ amountUsd: zod.z.string(), asset: zod.z.string() }).nullable().optional(),
2530
+ // ZERO-199 P-B — the single resolved price. Prefer `pricing.summary`/`kind`
2531
+ // over re-deriving from the legacy fields. Optional so older deploys parse.
2532
+ pricing: zod.z.object({
2533
+ kind: zod.z.string(),
2534
+ summary: zod.z.string(),
2535
+ primary: pricingOptionSchema.nullable(),
2536
+ accepted: zod.z.array(pricingOptionSchema)
2537
+ }).optional(),
2494
2538
  availabilityStatus: zod.z.enum(["healthy", "unknown", "down"]).nullable().optional(),
2495
2539
  /**
2496
2540
  * @deprecated The API no longer emits `displayStatus`; it has been replaced
@@ -2921,6 +2965,11 @@ var searchResultSchema = zod.z.object({
2921
2965
  url: zod.z.string(),
2922
2966
  urlTemplate: zod.z.string().nullable().optional(),
2923
2967
  cost: zod.z.object({ amount: zod.z.string(), asset: zod.z.string() }),
2968
+ // Payment protocol (x402 | mpp) for this result. The server emits it; the SDK
2969
+ // previously stripped it, leaving an agent unable to tell which handshake to
2970
+ // engage from a search row. Optional/nullable so older deploys still parse
2971
+ // (ZERO-199).
2972
+ protocol: zod.z.string().nullable().optional(),
2924
2973
  reviewCount: zod.z.number().optional(),
2925
2974
  rating: ratingSchema,
2926
2975
  // All-time activation count (non-deleted runs), mirroring capabilities.ts.
@@ -3352,5 +3401,5 @@ exports.normalizeTransportEnvelopeRequest = normalizeTransportEnvelopeRequest;
3352
3401
  exports.paymentHasAnchor = paymentHasAnchor;
3353
3402
  exports.tempoChainLabelFromId = tempoChainLabelFromId;
3354
3403
  exports.unwrapTransportEnvelope = unwrapTransportEnvelope;
3355
- //# sourceMappingURL=chunk-72WCE7HE.cjs.map
3356
- //# sourceMappingURL=chunk-72WCE7HE.cjs.map
3404
+ //# sourceMappingURL=chunk-O7QJMY3Y.cjs.map
3405
+ //# sourceMappingURL=chunk-O7QJMY3Y.cjs.map