@zeroxyz/sdk 0.6.0 → 0.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 CHANGED
@@ -4,6 +4,20 @@ 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.8.0
8
+
9
+ ### Added
10
+
11
+ - **`CapabilityResponse.instructions`** — optional natural-language field describing how an agent should call this capability (authentication hints, required context, usage notes). Exposed on `capabilities.get()` responses and in the `CapabilityResponse` type. (#693, ZERO-134)
12
+
13
+ ## 0.7.0
14
+
15
+ ### Added
16
+
17
+ - **`SearchResult.token`** — every search result now carries a short server-issued attribution token (`z_xxx.N` format, where `xxx` is a 6-char base-62 ID shared across all results from the same search and `N` is the 1-based position). Pass it directly as the `id` to `capabilities.get()` or as `capabilityId` to `client.fetch()` — the server resolves it back to the capability and ties the run to the originating search for accurate ranking and analytics. Tokens are generated per-search and expire when the session rolls. (#665)
18
+ - **`isShortToken(id)`** — exported predicate that returns `true` when a string is a `z_xxx.N` attribution token (vs a uid, slug, or URL). Use it to route capabilityId arguments without regex-ing the format yourself. (#665)
19
+ - **`@deprecated`** JSDoc on `GetCapabilityOptions.searchId`, `FetchOptions.searchId`, and `CreateRunInput.searchId` — pass the token as the `id`/`capabilityId` argument instead; the token already embeds the search context. These fields remain in place for back-compat with callers that pass uid + searchId separately. (#665)
20
+
7
21
  ## 0.6.0
8
22
 
9
23
  ### Added
package/README.md CHANGED
@@ -104,6 +104,8 @@ Endpoints that don't charge pass straight through: a `200` on the first request
104
104
 
105
105
  **Building the request — search → get → fetch.** A `search()` result carries the `url` and `method`, so a no-body `GET` capability can go straight to `fetch()`. For anything that takes a request body, call `capabilities.get()` first: its `bodySchema`, `method`, and `headers` are what tell you how to construct the call. Don't guess the body from the search summary.
106
106
 
107
+ Each search result also carries a `token` field (format: `z_xxx.N`) — a short server-issued attribution token that encodes the search context and the result's position. Pass it as `capabilityId` to `fetch()` (or as the `id` to `capabilities.get()`) instead of the raw uid/slug; the server uses it to attribute the run back to the originating search for ranking and analytics. Tokens expire when the session rolls, so use them within the same search session.
108
+
107
109
  **The HTTP-transport envelope.** Some capabilities store their request contract as Zero's HTTP-transport envelope — `{ input: { type: "http", method, queryParams, body } }` — rather than a bare body. You don't have to special-case it: `fetch()` detects an envelope body and normalizes it to the real wire request — it **carries the method** (from the envelope's `input.method`, never inferring `POST` from body-presence) and moves a `GET`'s `queryParams` onto the URL query string. So passing the envelope straight through works:
108
110
 
109
111
  ```ts
@@ -180,7 +182,7 @@ for (const warning of result.warnings ?? []) {
180
182
  | `warnings` | `string[]?` | Non-fatal notes (truncated body, MPP close failure, …) — keyed by `FETCH_WARNINGS`. |
181
183
  | `runTrackingSkipped` | `string[]?` | Why a run wasn't recorded (e.g. no `capabilityId`) — keyed by `FETCH_SKIP_REASONS`. |
182
184
 
183
- `capabilityId` accepts the capability's `uid` (`cap_…`) or `slug` i.e. the `id`/`slug` from a `search()` result or the `uid`/`slug` from `capabilities.get()`.
185
+ `capabilityId` accepts the capability's `uid` (`cap_…`), `slug`, or an attribution token (`z_xxx.N`) from a `search()` result. Prefer the token when one is available — it lets the server tie the run back to the originating search for accurate ranking and analytics. Pass the uid or slug for direct fetches where no search was performed.
184
186
 
185
187
  ### `maxPay`
186
188
 
@@ -232,8 +234,9 @@ const { capabilities } = await client.search("translate text to french", {
232
234
  protocol: "x402", // optional: "x402" | "mpp"
233
235
  });
234
236
 
235
- // Capabilities — full detail for one capability by id
236
- const cap = await client.capabilities.get("cap_abc");
237
+ // Capabilities — full detail for one capability by uid, slug, or attribution token
238
+ const cap = await client.capabilities.get("cap_abc"); // by uid
239
+ const cap2 = await client.capabilities.get("z_Ab12cd.1"); // by search token
237
240
 
238
241
  // Wallet — balance + one-time funding URL. See "Wallet & funding" above.
239
242
  const { amount } = await client.wallet.balance();