@xona-labs/xpay 0.2.2 → 0.2.4

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +40 -10
  3. package/SKILL.md +28 -0
  4. package/dist/agenc/api.d.ts +138 -0
  5. package/dist/agenc/api.d.ts.map +1 -0
  6. package/dist/agenc/api.js +194 -0
  7. package/dist/agenc/api.js.map +1 -0
  8. package/dist/agenc/hire.d.ts +41 -0
  9. package/dist/agenc/hire.d.ts.map +1 -0
  10. package/dist/agenc/hire.js +123 -0
  11. package/dist/agenc/hire.js.map +1 -0
  12. package/dist/agenc/price.d.ts +8 -0
  13. package/dist/agenc/price.d.ts.map +1 -0
  14. package/dist/agenc/price.js +47 -0
  15. package/dist/agenc/price.js.map +1 -0
  16. package/dist/cli/agenc.d.ts +22 -0
  17. package/dist/cli/agenc.d.ts.map +1 -0
  18. package/dist/cli/agenc.js +115 -0
  19. package/dist/cli/agenc.js.map +1 -0
  20. package/dist/cli/discover.d.ts.map +1 -1
  21. package/dist/cli/discover.js +18 -2
  22. package/dist/cli/discover.js.map +1 -1
  23. package/dist/cli/index.js +24 -1
  24. package/dist/cli/index.js.map +1 -1
  25. package/dist/discover/index.d.ts +12 -4
  26. package/dist/discover/index.d.ts.map +1 -1
  27. package/dist/discover/index.js +74 -17
  28. package/dist/discover/index.js.map +1 -1
  29. package/dist/do/index.d.ts +3 -0
  30. package/dist/do/index.d.ts.map +1 -1
  31. package/dist/do/index.js +1 -0
  32. package/dist/do/index.js.map +1 -1
  33. package/dist/guardrail/index.d.ts +8 -0
  34. package/dist/guardrail/index.d.ts.map +1 -1
  35. package/dist/guardrail/index.js +42 -13
  36. package/dist/guardrail/index.js.map +1 -1
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +4 -2
  40. package/dist/index.js.map +1 -1
  41. package/dist/profile/types.d.ts +12 -0
  42. package/dist/profile/types.d.ts.map +1 -1
  43. package/dist/signers/raw-solana.d.ts +1 -0
  44. package/dist/signers/raw-solana.d.ts.map +1 -1
  45. package/dist/signers/raw-solana.js +1 -1
  46. package/dist/signers/raw-solana.js.map +1 -1
  47. package/dist/tools/index.d.ts.map +1 -1
  48. package/dist/tools/index.js +27 -3
  49. package/dist/tools/index.js.map +1 -1
  50. package/dist/types.d.ts +5 -0
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/use/index.d.ts +11 -1
  53. package/dist/use/index.d.ts.map +1 -1
  54. package/dist/use/index.js +11 -3
  55. package/dist/use/index.js.map +1 -1
  56. package/package.json +8 -3
package/CHANGELOG.md CHANGED
@@ -6,6 +6,42 @@ versioning follows [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.4] – 2026-07-03
10
+
11
+ Re-release of 0.2.3 with no code changes (registry hygiene).
12
+
13
+ ## [0.2.3] – 2026-07-03
14
+
15
+ ### Added
16
+ - **AgenC marketplace (agenc.ag) as a discovery source with smart-routed
17
+ execution.** Hireable AgenC listings now appear in `xpay discover` /
18
+ `xpay_discover` alongside x402 services (marked `metadata.source: "agenc"`,
19
+ priced in SOL). Discovery merges sources with failure isolation — one
20
+ catalog going down no longer breaks discovery — and reserves result slots so
21
+ marketplace listings aren't drowned out by the 21k-item x402 catalog. Opt
22
+ out with `XPAY_DISCOVERY_SOURCES=orbitx402` or `discover({ sources })`.
23
+ - **Smart execution routing in `use()`.** AgenC resources are detected by
24
+ their `agenc-hire` payment scheme and executed as on-chain SOL escrow hires
25
+ via `@tetsuo-ai/marketplace-sdk` (humanless entry point — tasks pin to
26
+ CreatorReview, so escrow never auto-releases without the buyer's
27
+ acceptance). x402 resources keep the existing payment path; same
28
+ `use()`/`do()` API for both. The result of a hire is a receipt
29
+ (`task`, `hireRecord`, `txSig`, explorer link) — the provider works
30
+ asynchronously.
31
+ - **CLI `xpay agenc hire <listingPda>` / `xpay agenc status <taskPda>`** and
32
+ MCP tool `xpay_agenc_status` for tracking hire progress.
33
+ - **Guardrail SOL pricing.** AgenC hires are converted lamports → USD at spot
34
+ (multi-feed: CoinGecko → Coinbase → Kraken, 60s cache) and enforced against
35
+ the existing USD caps before signing; fails closed if no feed is reachable
36
+ while caps are configured.
37
+ - Examples: `examples/agenc-hire.ts` (live discover → hire → poll) and
38
+ `examples/agenc-local-sandbox.ts` (full hire lifecycle against the real
39
+ compiled program in-process via litesvm — no RPC, no SOL spent).
40
+
41
+ ### Changed
42
+ - `@solana/kit` bumped `^5.5.1` → `^6.9.0` (required by the AgenC SDK;
43
+ `@x402/svm` accepts `>=5.1.0`).
44
+
9
45
  ## [0.2.2] – 2026-06-30
10
46
 
11
47
  ### Fixed
package/README.md CHANGED
@@ -5,13 +5,14 @@
5
5
  [![license](https://img.shields.io/npm/l/@xona-labs/xpay)](https://github.com/xona-labs/xpay/blob/main/LICENSE)
6
6
  ![node](https://img.shields.io/badge/node-%3E%3D18-brightgreen)
7
7
 
8
- > **Agentic-commerce wallet.** Multi-network USDC wallet, x402 payments, and discovery across 20,000+ services — as a CLI, an SDK, and an MCP server.
8
+ > **Agentic-commerce wallet.** Multi-network USDC wallet, x402 payments, AgenC marketplace hires, and discovery across 20,000+ services — as a CLI, an SDK, and an MCP server.
9
9
 
10
10
  ```bash
11
11
  npm install -g @xona-labs/xpay
12
12
  xpay init # creates Solana + EVM keys, encrypted
13
- xpay discover "research API" # 21k catalog, ranked
13
+ xpay discover "research API" # 21k x402 catalog + AgenC agent listings, ranked
14
14
  xpay pay https://api.example.com/x402 # x402 one-liner
15
+ xpay agenc hire <listingPda> # hire an on-chain agent (SOL escrow)
15
16
  xpay transfer 5 USDC 7G73PL...gC # direct USDC transfer
16
17
  xpay balance # unified across networks
17
18
  xpay report # daily / weekly / monthly report via OrbitX402
@@ -62,8 +63,10 @@ xpay pay https://orbisapi.com/proxy/image-alt-text-generator-api-1c9472
62
63
  | `xpay init [name]` | Create a profile (Solana + EVM keys from one BIP-39 seed). `--import` to restore from a phrase, `--no-encrypt` for dev wallets, `--workspace` to store locally. |
63
64
  | `xpay accounts list \| show \| use` | List profiles, inspect one, or set the active profile. |
64
65
  | `xpay balance` | USDC balance per network for the active profile. |
65
- | `xpay discover [query]` | Search 21k+ x402 services across chains — Solana, Base, **BNB Chain**, and other EVM networks (cached on disk). `--network`, `--limit`, `--json`. |
66
+ | `xpay discover [query]` | Search 21k+ x402 services across chains — Solana, Base, **BNB Chain**, and other EVM networks — plus **AgenC marketplace** agent listings (cached on disk). `--network`, `--limit`, `--json`. |
66
67
  | `xpay pay <url>` | Pay an x402 endpoint. Works on catalog URLs and any URL that returns 402. `--max-usd`, `--body`, `-y`. |
68
+ | `xpay agenc hire <listingPda>` | Hire an [AgenC marketplace](#agenc-marketplace-hire-on-chain-agents) listing — escrows its SOL price on-chain; the provider works asynchronously. `--max-usd`, `--review-window`, `-y`. |
69
+ | `xpay agenc status <taskPda>` | Check a hire's progress (read-only, no wallet). `--json`. |
67
70
  | `xpay transfer <amount> USDC <to>` | Direct USDC transfer, subject to the guardrail. `--network`, `-y`. |
68
71
  | `xpay report` | Comprehensive USDC activity report — totals, net flow, timeline, top counterparties, biggest txs. `--period daily\|weekly\|monthly`, `--network`, `--json`. |
69
72
  | `xpay guardrail show \| set \| clear` | Inspect or edit spending caps and allowed hosts. |
@@ -160,7 +163,7 @@ That's the whole setup. The generated wallet's **Solana address is printed to
160
163
  stderr on first run** — fund it with USDC and the agent can pay. It persists
161
164
  under `~/.xpay` and is reused on every later boot, so the address is stable.
162
165
 
163
- The host sees the core tools: `xpay_discover`, `xpay_use`, `xpay_do`, `xpay_transfer`, `xpay_balance`, `xpay_report`, `xpay_guardrail`, plus `xpay_bento_status` / `xpay_bento_enable` / `xpay_bento_disable` to manage the [intent firewall](#security--bento-intent-firewall-optional). If you've linked a Sana key (see below), eight additional `sana_*` tools are also registered automatically.
166
+ The host sees the core tools: `xpay_discover`, `xpay_use`, `xpay_do`, `xpay_transfer`, `xpay_balance`, `xpay_report`, `xpay_guardrail`, `xpay_agenc_status`, plus `xpay_bento_status` / `xpay_bento_enable` / `xpay_bento_disable` to manage the [intent firewall](#security--bento-intent-firewall-optional). If you've linked a Sana key (see below), eight additional `sana_*` tools are also registered automatically.
164
167
 
165
168
  **Bring your own wallet instead** — the wallet source order is *existing profile → key env → auto-generate*, so any of these overrides the generated wallet:
166
169
 
@@ -319,6 +322,31 @@ xpay sana unlink # removes the key from the profile
319
322
 
320
323
  The `sana_*` tools disappear from the MCP server on next restart.
321
324
 
325
+ ## AgenC marketplace — hire on-chain agents
326
+
327
+ [AgenC](https://agenc.ag) is a Solana-mainnet marketplace where registered agents sell services with on-chain escrow. Its hireable listings appear in `xpay discover` alongside x402 services — but they **execute differently**, and xpay routes them automatically:
328
+
329
+ | | x402 service | AgenC listing |
330
+ |---|---|---|
331
+ | Priced in | USDC | native **SOL** |
332
+ | Payment | HTTP `X-Payment` header | on-chain **escrow** (program `HJsZ…w1xK`) |
333
+ | Result | immediate HTTP response | **hire receipt** — the provider works asynchronously |
334
+ | Settlement | instant | after your review window (default 24h) |
335
+
336
+ ```bash
337
+ xpay discover "research" # AgenC listings show as “agenc escrow”, priced in ◎SOL
338
+ xpay agenc hire <listingPda> # confirm → escrow SOL → get a task PDA
339
+ xpay agenc status <taskPda> # poll: open → claimed → review → settled
340
+ ```
341
+
342
+ The same smart routing works in the SDK and MCP — `xpay.use(resource)` / `xpay_use` detect the `agenc-hire` payment scheme and run the escrow flow, returning a receipt (`task`, `txSig`, explorer link) as `data`. Hires are made through AgenC's *humanless* entry point, which pins the task to **CreatorReview** — escrowed funds never auto-release without your acceptance.
343
+
344
+ Notes:
345
+ - The guardrail applies to hires too: SOL prices are converted to USD at spot (multi-feed, cached) and checked against `maxPerTx`/`maxPerDay` **before signing**. If no price feed is reachable and caps are set, the hire fails closed.
346
+ - The wallet needs **SOL** (escrow + fees), not just USDC.
347
+ - Reviewing/accepting results happens on [agenc.ag](https://agenc.ag) for now; `xpay agenc accept` is planned.
348
+ - Config (optional): `agenc: { rpcUrl, reviewWindowSecs, endpoint }` in the profile, or `XPAY_AGENC_ENDPOINT`. Opt out of the discovery source with `XPAY_DISCOVERY_SOURCES=orbitx402`.
349
+
322
350
  ## Multi-network
323
351
 
324
352
  `init` configures Solana and Base by default. Add or change via `~/.xpay/<name>/config.json`:
@@ -340,23 +368,25 @@ Public RPCs work for development but rate-limit hard. Production deployments sho
340
368
  ## How it works
341
369
 
342
370
  - **Keys** — One BIP-39 mnemonic per profile derives Solana (`m/44'/501'/0'/0'`, Phantom-compatible) and EVM (`m/44'/60'/0'/0/0`, MetaMask-compatible) keypairs. Encrypted at rest with scrypt + AES-256-GCM.
343
- - **Discovery** — the catalog spans 21k+ x402 endpoints across multiple chains — **Solana, Base, BNB Chain, and other EVM networks** — so `discover()` surfaces BNB Chain x402 resources alongside everything else. The fetcher walks the offset-pagination, validates each entry against a Zod schema, and persists to `~/.xpay/cache/` so repeat lookups skip the cold-fetch tax. (Filter with `--network` / `discover({ networks })`.)
344
- - **Pay** — `use()` and `useByUrl()` both go: guardrail check → signer.pay(USDC) on the right network → `X-Payment` header → retry. The signer abstraction means the same code path works for Solana SPL transfers and EVM ERC-20 transfers.
371
+ - **Discovery** — the catalog spans 21k+ x402 endpoints across multiple chains — **Solana, Base, BNB Chain, and other EVM networks** — plus AgenC marketplace listings, merged from independent sources (`Promise.allSettled`, so one source failing never kills discovery). The fetcher walks each API's pagination, validates every entry against a Zod schema, and persists to `~/.xpay/cache/` so repeat lookups skip the cold-fetch tax. (Filter with `--network` / `discover({ networks })`; pick sources with `discover({ sources })` or `XPAY_DISCOVERY_SOURCES`.)
372
+ - **Pay** — `use()` and `useByUrl()` both go: guardrail check → signer.pay(USDC) on the right network → `X-Payment` header → retry. The signer abstraction means the same code path works for Solana SPL transfers and EVM ERC-20 transfers. AgenC resources are detected by their `agenc-hire` payment scheme and routed to the on-chain escrow flow instead — same `use()` call, different rail.
345
373
  - **Report** — Comprehensive USDC activity (daily / weekly / monthly) fetched from the OrbitX402 API. On-chain data is resolved server-side — no RPC calls from xpay, no rate-limiting, no RPC key required.
346
374
 
347
375
  ## Project status
348
376
 
349
- **v0.1 (current):**
350
- - ✅ CLI: init, accounts, balance, discover, pay, transfer, report, guardrail, mcp
377
+ **v0.2.4 (current):**
378
+ - ✅ CLI: init, accounts, balance, discover, pay, agenc, transfer, report, guardrail, mcp
351
379
  - ✅ SDK: full parity with CLI; tool exporters for Claude / OpenAI / Gemini
352
- - ✅ MCP server on stdio with 10 tools (incl. the Bento intent firewall)
380
+ - ✅ MCP server on stdio with 11 tools (incl. the Bento intent firewall)
353
381
  - ✅ Solana + Base mainnet with disk caching
354
382
  - ✅ Optional Sana agent card integration (`xpay sana link`) — 8 additional `sana_*` tools
383
+ - ✅ AgenC marketplace as a discovery source + smart-routed SOL escrow hires (`xpay agenc hire|status`)
355
384
 
356
- **v0.2 planned:**
385
+ **Planned:**
357
386
  - `bridge` — USDC EVM ↔ SVM via CCTP (Circle's native burn/mint)
358
387
  - `link / unlink` — opt-in cloud sync (audit log, dashboard)
359
388
  - Pay catalog + xona-labs catalog as additional discovery sources
389
+ - `xpay agenc accept|rate` — review AgenC hire results without leaving the CLI
360
390
 
361
391
  ## License
362
392
 
package/SKILL.md CHANGED
@@ -45,6 +45,7 @@ the MCP `env`. To require an explicit wallet (no auto-generation), set
45
45
  | `xpay_balance` | The wallet's balance per network, plus its addresses (use this to tell the user where to send funds). |
46
46
  | `xpay_report` | Spending/income report (daily / weekly / monthly). |
47
47
  | `xpay_guardrail` | Read the active spending caps (per-tx, per-day, allowed hosts, approval threshold). |
48
+ | `xpay_agenc_status` | Check the progress of an AgenC marketplace hire (see below). Read-only. |
48
49
  | `xpay_bento_status` | Check whether the Bento intent firewall is on (read-only). |
49
50
  | `xpay_bento_enable` | Turn the Bento intent firewall on. Returns the agent wallet address to register at app.bentoguard.xyz. |
50
51
  | `xpay_bento_disable` | Turn the Bento firewall off — use if the wallet isn't registered and payments are rejected. |
@@ -66,6 +67,28 @@ The agent pays from its own wallet, so **it must be funded first**. If a call
66
67
  fails for lack of funds, ask the user to send USDC to the address from
67
68
  `xpay_balance` (Solana mainnet or Base).
68
69
 
70
+ ## AgenC marketplace listings — a different execution rail
71
+
72
+ `xpay_discover` results may include **AgenC marketplace** listings
73
+ (`metadata.source === "agenc"`) — on-chain agent services priced in **SOL**,
74
+ not USDC. Calling `xpay_use` on one is detected automatically and runs a
75
+ Solana **escrow hire** instead of an HTTP payment:
76
+
77
+ - The listing's SOL price is escrowed on-chain; the wallet needs **SOL**, not
78
+ USDC, for these.
79
+ - The result is a **hire receipt** (`data.kind === "agenc-hire-receipt"` with
80
+ `task`, `txSig`, `explorer`), **not** the service's output — the provider
81
+ works asynchronously.
82
+ - Poll `xpay_agenc_status { taskPda }` to track progress:
83
+ `open/claimed → review → settled`. A just-created task can 404 for ~a minute
84
+ (the API snapshot lags); retry, don't treat it as failure.
85
+ - Tell the user the work is in progress and how to review it
86
+ (https://agenc.ag/tasks/<taskPda>) — escrow only settles after their review
87
+ window.
88
+
89
+ The guardrail still applies (SOL converted to USD at spot, checked before
90
+ signing), and hires never auto-release funds without the buyer's acceptance.
91
+
69
92
  ## Safety — built in, respect it
70
93
 
71
94
  - **Spending guardrail.** Per-tx and per-day USD caps and an allowed-host list
@@ -94,6 +117,11 @@ fails for lack of funds, ask the user to send USDC to the address from
94
117
  **Receive funds**
95
118
  - `xpay_balance` → give the user the Solana address to send USDC to.
96
119
 
120
+ **Hire an on-chain agent (AgenC)**
121
+ 1. `xpay_discover { query: "..." }` → pick a result with `metadata.source === "agenc"`
122
+ 2. Confirm the SOL price with the user, then `xpay_use { resource: <that object> }`
123
+ 3. Report the receipt's `task` + `explorer` link; later, `xpay_agenc_status { taskPda }`.
124
+
97
125
  **Send funds (with approval)**
98
126
  1. `xpay_transfer { amount: 5, to: "<address>", token: "USDC" }` → returns a code
99
127
  2. Confirm details with the user
@@ -0,0 +1,138 @@
1
+ /**
2
+ * AgenC marketplace client — keyless reads of Solana-mainnet marketplace state.
3
+ *
4
+ * AgenC (https://agenc.ag) lists standing service offers from registered
5
+ * on-chain agents. Discovery is a public REST API (cached snapshot of chain
6
+ * state, rebuilt ~every 45s); execution is NOT x402 — hiring escrows native
7
+ * SOL on-chain via `@tetsuo-ai/marketplace-sdk` (see ./hire.ts).
8
+ */
9
+ import { z } from "zod";
10
+ import type { Resource } from "../types.js";
11
+ /** Payment scheme marking a resource as an AgenC escrow hire. `use()` dispatches on this. */
12
+ export declare const AGENC_SCHEME = "agenc-hire";
13
+ /** Listing shape returned by GET /api/listings. Lamports are u64 decimal strings. */
14
+ declare const AgencListingSchema: z.ZodObject<{
15
+ pda: z.ZodString;
16
+ providerAgent: z.ZodString;
17
+ authority: z.ZodString;
18
+ name: z.ZodDefault<z.ZodString>;
19
+ specHash: z.ZodString;
20
+ specUri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
+ priceLamports: z.ZodString;
22
+ /** null = priced in native SOL. Anything else is an SPL mint (not hireable). */
23
+ priceMint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ defaultDeadlineSecs: z.ZodOptional<z.ZodNumber>;
25
+ operator: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ operatorFeeBps: z.ZodOptional<z.ZodNumber>;
27
+ /** 0=Active, 1=Paused, 2=Retired */
28
+ state: z.ZodNumber;
29
+ maxOpenJobs: z.ZodOptional<z.ZodNumber>;
30
+ openJobs: z.ZodOptional<z.ZodNumber>;
31
+ totalHires: z.ZodOptional<z.ZodString>;
32
+ ratingCount: z.ZodOptional<z.ZodNumber>;
33
+ version: z.ZodDefault<z.ZodString>;
34
+ createdAtUnix: z.ZodOptional<z.ZodNumber>;
35
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
36
+ pda: z.ZodString;
37
+ providerAgent: z.ZodString;
38
+ authority: z.ZodString;
39
+ name: z.ZodDefault<z.ZodString>;
40
+ specHash: z.ZodString;
41
+ specUri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
+ priceLamports: z.ZodString;
43
+ /** null = priced in native SOL. Anything else is an SPL mint (not hireable). */
44
+ priceMint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
+ defaultDeadlineSecs: z.ZodOptional<z.ZodNumber>;
46
+ operator: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ operatorFeeBps: z.ZodOptional<z.ZodNumber>;
48
+ /** 0=Active, 1=Paused, 2=Retired */
49
+ state: z.ZodNumber;
50
+ maxOpenJobs: z.ZodOptional<z.ZodNumber>;
51
+ openJobs: z.ZodOptional<z.ZodNumber>;
52
+ totalHires: z.ZodOptional<z.ZodString>;
53
+ ratingCount: z.ZodOptional<z.ZodNumber>;
54
+ version: z.ZodDefault<z.ZodString>;
55
+ createdAtUnix: z.ZodOptional<z.ZodNumber>;
56
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
57
+ pda: z.ZodString;
58
+ providerAgent: z.ZodString;
59
+ authority: z.ZodString;
60
+ name: z.ZodDefault<z.ZodString>;
61
+ specHash: z.ZodString;
62
+ specUri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
63
+ priceLamports: z.ZodString;
64
+ /** null = priced in native SOL. Anything else is an SPL mint (not hireable). */
65
+ priceMint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ defaultDeadlineSecs: z.ZodOptional<z.ZodNumber>;
67
+ operator: z.ZodOptional<z.ZodNullable<z.ZodString>>;
68
+ operatorFeeBps: z.ZodOptional<z.ZodNumber>;
69
+ /** 0=Active, 1=Paused, 2=Retired */
70
+ state: z.ZodNumber;
71
+ maxOpenJobs: z.ZodOptional<z.ZodNumber>;
72
+ openJobs: z.ZodOptional<z.ZodNumber>;
73
+ totalHires: z.ZodOptional<z.ZodString>;
74
+ ratingCount: z.ZodOptional<z.ZodNumber>;
75
+ version: z.ZodDefault<z.ZodString>;
76
+ createdAtUnix: z.ZodOptional<z.ZodNumber>;
77
+ }, z.ZodTypeAny, "passthrough">>;
78
+ export type AgencListing = z.infer<typeof AgencListingSchema>;
79
+ /** Task shape returned by GET /api/tasks/:pda — used to poll hire progress. */
80
+ declare const AgencTaskSchema: z.ZodObject<{
81
+ pda: z.ZodString;
82
+ title: z.ZodOptional<z.ZodString>;
83
+ status: z.ZodString;
84
+ rewardLamports: z.ZodOptional<z.ZodString>;
85
+ deadlineUnix: z.ZodOptional<z.ZodNumber>;
86
+ createdAtUnix: z.ZodOptional<z.ZodNumber>;
87
+ creatorPda: z.ZodOptional<z.ZodString>;
88
+ workerPda: z.ZodOptional<z.ZodNullable<z.ZodString>>;
89
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
90
+ pda: z.ZodString;
91
+ title: z.ZodOptional<z.ZodString>;
92
+ status: z.ZodString;
93
+ rewardLamports: z.ZodOptional<z.ZodString>;
94
+ deadlineUnix: z.ZodOptional<z.ZodNumber>;
95
+ createdAtUnix: z.ZodOptional<z.ZodNumber>;
96
+ creatorPda: z.ZodOptional<z.ZodString>;
97
+ workerPda: z.ZodOptional<z.ZodNullable<z.ZodString>>;
98
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
99
+ pda: z.ZodString;
100
+ title: z.ZodOptional<z.ZodString>;
101
+ status: z.ZodString;
102
+ rewardLamports: z.ZodOptional<z.ZodString>;
103
+ deadlineUnix: z.ZodOptional<z.ZodNumber>;
104
+ createdAtUnix: z.ZodOptional<z.ZodNumber>;
105
+ creatorPda: z.ZodOptional<z.ZodString>;
106
+ workerPda: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
+ }, z.ZodTypeAny, "passthrough">>;
108
+ export type AgencTask = z.infer<typeof AgencTaskSchema>;
109
+ export interface AgencClientOptions {
110
+ /** API base. Defaults to https://api.agenc.ag (override: XPAY_AGENC_ENDPOINT). */
111
+ endpoint?: string;
112
+ maxItems?: number;
113
+ fetch?: typeof fetch;
114
+ }
115
+ /**
116
+ * Fetch all hireable listings (Active, SOL-priced, moderation-passed) and map
117
+ * them into xpay's Resource shape. The API pre-filters via `hireable=true`;
118
+ * we re-check state/mint per item as belt-and-suspenders.
119
+ */
120
+ export declare function fetchAgencResources(opts?: AgencClientOptions): Promise<Resource[]>;
121
+ /**
122
+ * Map an AgenC listing into xpay's Resource shape. Everything `hire.ts` needs
123
+ * to execute rides in `accepts[0].extra`, so a discovered resource is
124
+ * self-contained — no extra API round-trips at hire time.
125
+ */
126
+ export declare function listingToResource(l: AgencListing): Resource;
127
+ /** Whether a discovered resource is an AgenC listing (executes as an escrow hire, not HTTP). */
128
+ export declare function isAgencResource(r: Resource): boolean;
129
+ /**
130
+ * Fetch a single listing by PDA — used as a pre-hire freshness check. The API
131
+ * has no listing-by-pda route, so scan the hireable pages for a match.
132
+ * Returns undefined when the listing is gone or no longer hireable.
133
+ */
134
+ export declare function fetchAgencListing(pda: string, opts?: AgencClientOptions): Promise<AgencListing | undefined>;
135
+ /** Fetch a task by PDA (GET /api/tasks/:pda) — the status of a hire. */
136
+ export declare function fetchAgencTask(pda: string, opts?: AgencClientOptions): Promise<AgencTask>;
137
+ export {};
138
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/agenc/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,6FAA6F;AAC7F,eAAO,MAAM,YAAY,eAAe,CAAC;AAEzC,qFAAqF;AACrF,QAAA,MAAM,kBAAkB;;;;;;;;IASpB,gFAAgF;;;;;IAKhF,oCAAoC;;;;;;;;;;;;;;;;IALpC,gFAAgF;;;;;IAKhF,oCAAoC;;;;;;;;;;;;;;;;IALpC,gFAAgF;;;;;IAKhF,oCAAoC;;;;;;;;gCASxB,CAAC;AACjB,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,+EAA+E;AAC/E,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAWL,CAAC;AACjB,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AASD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAkC5F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,YAAY,GAAG,QAAQ,CAiC3D;AAED,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,kBAAuB,GAC5B,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAsBnC;AAED,wEAAwE;AACxE,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,CAoBnG"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * AgenC marketplace client — keyless reads of Solana-mainnet marketplace state.
3
+ *
4
+ * AgenC (https://agenc.ag) lists standing service offers from registered
5
+ * on-chain agents. Discovery is a public REST API (cached snapshot of chain
6
+ * state, rebuilt ~every 45s); execution is NOT x402 — hiring escrows native
7
+ * SOL on-chain via `@tetsuo-ai/marketplace-sdk` (see ./hire.ts).
8
+ */
9
+ import { z } from "zod";
10
+ const DEFAULT_ENDPOINT = "https://api.agenc.ag";
11
+ const PAGE_SIZE = 100; // API max
12
+ /** Payment scheme marking a resource as an AgenC escrow hire. `use()` dispatches on this. */
13
+ export const AGENC_SCHEME = "agenc-hire";
14
+ /** Listing shape returned by GET /api/listings. Lamports are u64 decimal strings. */
15
+ const AgencListingSchema = z
16
+ .object({
17
+ pda: z.string(),
18
+ providerAgent: z.string(),
19
+ authority: z.string(),
20
+ name: z.string().default(""),
21
+ specHash: z.string(),
22
+ specUri: z.string().nullable().optional(),
23
+ priceLamports: z.string(),
24
+ /** null = priced in native SOL. Anything else is an SPL mint (not hireable). */
25
+ priceMint: z.string().nullable().optional(),
26
+ defaultDeadlineSecs: z.number().optional(),
27
+ operator: z.string().nullable().optional(),
28
+ operatorFeeBps: z.number().optional(),
29
+ /** 0=Active, 1=Paused, 2=Retired */
30
+ state: z.number(),
31
+ maxOpenJobs: z.number().optional(),
32
+ openJobs: z.number().optional(),
33
+ totalHires: z.string().optional(),
34
+ ratingCount: z.number().optional(),
35
+ version: z.string().default("1"),
36
+ createdAtUnix: z.number().optional(),
37
+ })
38
+ .passthrough();
39
+ /** Task shape returned by GET /api/tasks/:pda — used to poll hire progress. */
40
+ const AgencTaskSchema = z
41
+ .object({
42
+ pda: z.string(),
43
+ title: z.string().optional(),
44
+ status: z.string(),
45
+ rewardLamports: z.string().optional(),
46
+ deadlineUnix: z.number().optional(),
47
+ createdAtUnix: z.number().optional(),
48
+ creatorPda: z.string().optional(),
49
+ workerPda: z.string().nullable().optional(),
50
+ })
51
+ .passthrough();
52
+ /**
53
+ * Fetch all hireable listings (Active, SOL-priced, moderation-passed) and map
54
+ * them into xpay's Resource shape. The API pre-filters via `hireable=true`;
55
+ * we re-check state/mint per item as belt-and-suspenders.
56
+ */
57
+ export async function fetchAgencResources(opts = {}) {
58
+ const endpoint = opts.endpoint ?? process.env.XPAY_AGENC_ENDPOINT ?? DEFAULT_ENDPOINT;
59
+ const maxItems = opts.maxItems ?? Infinity;
60
+ const fetchImpl = opts.fetch ?? fetch;
61
+ const all = [];
62
+ let total = Infinity;
63
+ for (let page = 1; page <= 100 && all.length < Math.min(total, maxItems); page++) {
64
+ const url = new URL("/api/listings", endpoint);
65
+ url.searchParams.set("hireable", "true");
66
+ url.searchParams.set("page", String(page));
67
+ url.searchParams.set("pageSize", String(PAGE_SIZE));
68
+ const res = await fetchImpl(url.toString(), { headers: { accept: "application/json" } });
69
+ if (!res.ok)
70
+ throw new Error(await apiError("AgenC discovery", res));
71
+ const body = (await res.json());
72
+ const rawItems = body.items ?? [];
73
+ for (const raw of rawItems) {
74
+ const parsed = AgencListingSchema.safeParse(raw);
75
+ if (!parsed.success)
76
+ continue;
77
+ const l = parsed.data;
78
+ if (l.state !== 0 || (l.priceMint !== null && l.priceMint !== undefined))
79
+ continue;
80
+ all.push(listingToResource(l));
81
+ if (all.length >= maxItems)
82
+ return all;
83
+ }
84
+ total = body.total ?? all.length;
85
+ if (rawItems.length < PAGE_SIZE)
86
+ break;
87
+ }
88
+ return all;
89
+ }
90
+ /**
91
+ * Map an AgenC listing into xpay's Resource shape. Everything `hire.ts` needs
92
+ * to execute rides in `accepts[0].extra`, so a discovered resource is
93
+ * self-contained — no extra API round-trips at hire time.
94
+ */
95
+ export function listingToResource(l) {
96
+ return {
97
+ resource: `https://agenc.ag/listings/${l.pda}`,
98
+ type: "agenc",
99
+ method: "HIRE",
100
+ accepts: [
101
+ {
102
+ scheme: AGENC_SCHEME,
103
+ network: "solana",
104
+ asset: "SOL",
105
+ payTo: l.authority,
106
+ amount: l.priceLamports,
107
+ ...(l.defaultDeadlineSecs ? { maxTimeoutSeconds: l.defaultDeadlineSecs } : {}),
108
+ extra: {
109
+ listingPda: l.pda,
110
+ specHash: l.specHash,
111
+ version: l.version,
112
+ providerAgent: l.providerAgent,
113
+ operator: l.operator ?? null,
114
+ operatorFeeBps: l.operatorFeeBps ?? 0,
115
+ },
116
+ },
117
+ ],
118
+ metadata: {
119
+ source: "agenc",
120
+ name: l.name,
121
+ listingPda: l.pda,
122
+ specUri: l.specUri ?? null,
123
+ reputation: { ratingCount: l.ratingCount ?? 0, totalHires: l.totalHires ?? "0" },
124
+ capacity: { openJobs: l.openJobs ?? 0, maxOpenJobs: l.maxOpenJobs ?? 0 },
125
+ execution: "solana-escrow-hire",
126
+ },
127
+ };
128
+ }
129
+ /** Whether a discovered resource is an AgenC listing (executes as an escrow hire, not HTTP). */
130
+ export function isAgencResource(r) {
131
+ return r.accepts.some((a) => a.scheme === AGENC_SCHEME);
132
+ }
133
+ /**
134
+ * Fetch a single listing by PDA — used as a pre-hire freshness check. The API
135
+ * has no listing-by-pda route, so scan the hireable pages for a match.
136
+ * Returns undefined when the listing is gone or no longer hireable.
137
+ */
138
+ export async function fetchAgencListing(pda, opts = {}) {
139
+ const endpoint = opts.endpoint ?? process.env.XPAY_AGENC_ENDPOINT ?? DEFAULT_ENDPOINT;
140
+ const fetchImpl = opts.fetch ?? fetch;
141
+ for (let page = 1; page <= 100; page++) {
142
+ const url = new URL("/api/listings", endpoint);
143
+ url.searchParams.set("hireable", "true");
144
+ url.searchParams.set("page", String(page));
145
+ url.searchParams.set("pageSize", String(PAGE_SIZE));
146
+ const res = await fetchImpl(url.toString(), { headers: { accept: "application/json" } });
147
+ if (!res.ok)
148
+ throw new Error(await apiError("AgenC listing lookup", res));
149
+ const body = (await res.json());
150
+ const rawItems = body.items ?? [];
151
+ for (const raw of rawItems) {
152
+ const parsed = AgencListingSchema.safeParse(raw);
153
+ if (parsed.success && parsed.data.pda === pda)
154
+ return parsed.data;
155
+ }
156
+ if (rawItems.length < PAGE_SIZE)
157
+ break;
158
+ }
159
+ return undefined;
160
+ }
161
+ /** Fetch a task by PDA (GET /api/tasks/:pda) — the status of a hire. */
162
+ export async function fetchAgencTask(pda, opts = {}) {
163
+ const endpoint = opts.endpoint ?? process.env.XPAY_AGENC_ENDPOINT ?? DEFAULT_ENDPOINT;
164
+ const fetchImpl = opts.fetch ?? fetch;
165
+ const url = new URL(`/api/tasks/${encodeURIComponent(pda)}`, endpoint);
166
+ const res = await fetchImpl(url.toString(), { headers: { accept: "application/json" } });
167
+ if (res.status === 404) {
168
+ throw new Error(`AgenC task ${pda} not found. The API snapshot rebuilds ~every 45s — ` +
169
+ `if this hire just landed, retry in about a minute.`);
170
+ }
171
+ if (!res.ok)
172
+ throw new Error(await apiError("AgenC task lookup", res));
173
+ const body = (await res.json());
174
+ const parsed = AgencTaskSchema.safeParse(body.task ?? body);
175
+ if (!parsed.success) {
176
+ throw new Error(`AgenC task lookup: unexpected response shape for ${pda}`);
177
+ }
178
+ return parsed.data;
179
+ }
180
+ /** Render an API failure, surfacing the `{error}` body and the 503 chain-lag case. */
181
+ async function apiError(what, res) {
182
+ let reason = "";
183
+ try {
184
+ const body = (await res.json());
185
+ if (body?.error)
186
+ reason = ` — ${body.error}`;
187
+ }
188
+ catch {
189
+ /* no JSON body */
190
+ }
191
+ const hint = res.status === 503 ? " (chain snapshot lagging; retry shortly)" : "";
192
+ return `${what} failed: ${res.status} ${res.statusText}${reason}${hint}`;
193
+ }
194
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/agenc/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAChD,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,UAAU;AAEjC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC;AAEzC,qFAAqF;AACrF,MAAM,kBAAkB,GAAG,CAAC;KACzB,MAAM,CAAC;IACN,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC5B,QAAQ,EAAE,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,UAAU,QAAQ,CAAC,IAAY,EAAE,GAAa;IACjD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAuB,CAAC;QACtD,IAAI,IAAI,EAAE,KAAK;YAAE,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,kBAAkB;IACpB,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,EAAE,CAAC;IAClF,OAAO,GAAG,IAAI,YAAY,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * AgenC hire execution — the non-x402 payment rail.
3
+ *
4
+ * Hiring a listing is a Solana transaction (program
5
+ * HJsZ53Zb27b8QMRbQpuDngE44AdwCGxvEZr61Zmxw1xK) that escrows the listing's
6
+ * price in native SOL and creates a Task + HireRecord on-chain. The provider
7
+ * then works ASYNCHRONOUSLY: escrow → work → review → settle. So unlike an
8
+ * x402 call, `use()` on an AgenC resource returns a hire *receipt*, not a
9
+ * response body — poll progress with `xpay agenc status <taskPda>`.
10
+ *
11
+ * The humanless entry point pins the task to CreatorReview, so escrowed funds
12
+ * never auto-release without the buyer accepting the result.
13
+ */
14
+ import type { UseResult } from "../types.js";
15
+ import { type UseArgs } from "../use/index.js";
16
+ export interface AgencHireConfig {
17
+ /** Solana RPC for building/sending the hire tx. Falls back to XPAY_SOLANA_RPC, then xpay's default. */
18
+ rpcUrl?: string;
19
+ /** Buyer review window after the provider submits, in seconds. Default 86400 (24h). */
20
+ reviewWindowSecs?: number;
21
+ /** AgenC API base override (freshness check + status polling). */
22
+ endpoint?: string;
23
+ }
24
+ /** Returned as `UseResult.data` for an AgenC hire. */
25
+ export interface AgencHireReceipt {
26
+ kind: "agenc-hire-receipt";
27
+ /** Listing PDA that was hired. */
28
+ listing: string;
29
+ /** Task PDA created by the hire — the handle for status polling and review. */
30
+ task: string;
31
+ /** HireRecord PDA linking the task back to the listing. */
32
+ hireRecord: string;
33
+ providerAgent: string;
34
+ priceLamports: string;
35
+ txSig: string;
36
+ status: "escrowed";
37
+ statusHint: string;
38
+ explorer: string;
39
+ }
40
+ export declare function useAgencHire(args: UseArgs): Promise<UseResult>;
41
+ //# sourceMappingURL=hire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hire.d.ts","sourceRoot":"","sources":["../../src/agenc/hire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAsB,SAAS,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAIlE,MAAM,WAAW,eAAe;IAC9B,uGAAuG;IACvG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uFAAuF;IACvF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAQD,wBAAsB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAoGpE"}