agent402-client 0.8.9 → 0.8.11
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/README.md +10 -10
- package/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ instance) - the buy side of [Agentic Finance](https://agent402.tools/agentic-fin
|
|
|
5
5
|
agents paying per request over x402 or MPP. **Resolve a task to a tool, then call it - with payment handled for
|
|
6
6
|
you.** Free pure-CPU tools settle with a built-in proof-of-work (no wallet, zero
|
|
7
7
|
dependencies); wallet-only tools settle via an x402- or MPP-wrapped fetch you
|
|
8
|
-
provide, or
|
|
8
|
+
provide, or through a prepaid credits key already issued. Results are cached, and every
|
|
9
9
|
send carries an `Idempotency-Key` that is stable per client and per operation, so
|
|
10
10
|
a retried lost response replays the paid answer on the credits and proof-of-work
|
|
11
11
|
paths (the wallet path is different: see "Retries and double charges").
|
|
@@ -55,7 +55,7 @@ The SDK's spending caps, reservations and caching apply identically on the MPP
|
|
|
55
55
|
path (pinned by `scripts/test-client-mpp.js` in the parent repo, which buys
|
|
56
56
|
through the SDK with a real mppx client).
|
|
57
57
|
|
|
58
|
-
**Over x402** with [`@x402/fetch`](https://www.npmjs.com/package/@x402/fetch) - USDC on
|
|
58
|
+
**Over x402** with [`@x402/fetch`](https://www.npmjs.com/package/@x402/fetch) - this snippet registers the EVM scheme, so it pays USDC on the EVM x402 chains; register the matching scheme package as well to pay on Solana, Stellar or Algorand:
|
|
59
59
|
|
|
60
60
|
```js
|
|
61
61
|
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
@@ -71,15 +71,15 @@ const a = new Agent402({ fetch: payFetch });
|
|
|
71
71
|
const article = await a.call("extract", { url: "https://example.com/article" });
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
##
|
|
74
|
+
## Prepaid credits (keys already issued)
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
`
|
|
78
|
-
|
|
76
|
+
New credits are not on sale. A key already issued (`a402_...`) still works: pass it
|
|
77
|
+
as `creditsKey` and the SDK sends `Authorization: Bearer a402_...` on wallet-only
|
|
78
|
+
calls (the wallet-scoped routes, memory and usage, refuse it and need a wallet); the server authorizes
|
|
79
79
|
against the key's balance before the handler runs and debits the list price only
|
|
80
80
|
on a successful (200) response (the `X-Credits-Balance` header carries what is
|
|
81
|
-
left; credits never expire). A refused call throws with the balance
|
|
82
|
-
|
|
81
|
+
left; credits never expire). A refused call throws with the balance; nothing is
|
|
82
|
+
debited.
|
|
83
83
|
|
|
84
84
|
```js
|
|
85
85
|
const client = new Agent402({ creditsKey: "a402_..." });
|
|
@@ -121,8 +121,8 @@ What the server does with it depends on how the call was paid:
|
|
|
121
121
|
## Workflows (skill packs)
|
|
122
122
|
|
|
123
123
|
For jobs that no single tool covers - e.g. "audit a domain", "build a stock
|
|
124
|
-
brief" - Agent402 ships curated multi-tool **skill packs**:
|
|
125
|
-
composed into a Claude-ready task template. Discover them the same way you'd
|
|
124
|
+
brief" - Agent402 ships curated multi-tool **skill packs**: several catalog
|
|
125
|
+
tools (most packs run three to seven) composed into a Claude-ready task template. Discover them the same way you'd
|
|
126
126
|
discover a tool:
|
|
127
127
|
|
|
128
128
|
```js
|
package/index.js
CHANGED
|
@@ -23,7 +23,7 @@ import { createHash, randomBytes } from "node:crypto";
|
|
|
23
23
|
// `User-Agent: agent402-client/<version>` - a standard header, no extra
|
|
24
24
|
// network calls - so a seller can attribute traffic (and settled payments)
|
|
25
25
|
// to this SDK. Product token only; nothing about the caller rides along.
|
|
26
|
-
const VERSION = "0.8.
|
|
26
|
+
const VERSION = "0.8.11";
|
|
27
27
|
const USER_AGENT = `agent402-client/${VERSION}`;
|
|
28
28
|
// 32MB: about a hundred times any realistic response from this catalog (the
|
|
29
29
|
// largest is a base64 image at a few MB), so it cannot break a legitimate
|
|
@@ -43,7 +43,7 @@ export class Agent402 {
|
|
|
43
43
|
* @param {number} [opts.maxPerCallUsd] hard ceiling on a single paid call (USD); over → SpendingLimitError before paying
|
|
44
44
|
* @param {number} [opts.dailyLimitUsd] hard ceiling on rolling-24h paid spend (USD)
|
|
45
45
|
* @param {number} [opts.maxPerHostUsd] hard ceiling on rolling-24h paid spend to one seller host (USD)
|
|
46
|
-
* @param {string} [opts.creditsKey] a prepaid card-credits key (a402_...)
|
|
46
|
+
* @param {string} [opts.creditsKey] a prepaid card-credits key (a402_...) issued at agent402.tools/credits -
|
|
47
47
|
* pays wallet-only tools by card when no payFetch is given
|
|
48
48
|
* @param {number|null} [opts.maxResponseBytes=33554432]
|
|
49
49
|
* Hard ceiling on a response body, enforced BEFORE it is parsed. null disables it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent402-client",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.11",
|
|
4
4
|
"description": "Agent402 buyer SDK: resolve a task to a tool across 500+ pay-per-call endpoints and call it with payment handled - free via proof-of-work, or over x402 or MPP (a stock mppx fetch works) with a wallet you keep; the buy side of Agentic Finance. Caching, idempotent retries (Idempotency-Key), non-custodial, zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|