agent402-client 0.8.11 → 0.8.12
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/index.js +5 -5
- package/package.json +1 -1
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.12";
|
|
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,8 +43,8 @@ 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_...) issued
|
|
47
|
-
* pays wallet-only tools
|
|
46
|
+
* @param {string} [opts.creditsKey] a prepaid card-credits key (a402_...) already issued (new credits are
|
|
47
|
+
* not on sale) - pays wallet-only tools 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.
|
|
50
50
|
* @param {{id:string, validate:function}} [opts.outputValidator]
|
|
@@ -387,7 +387,7 @@ export class Agent402 {
|
|
|
387
387
|
const r = await send({ Authorization: `Bearer ${this.creditsKey}` });
|
|
388
388
|
if (r.status === 402) {
|
|
389
389
|
const body = await r.json().catch(() => ({}));
|
|
390
|
-
throw this._fail(slug, r, `call "${slug}" refused by credits: ${body.error || "payment required"}${body.balanceUsd != null ? ` (balance $${body.balanceUsd})` : ""} - top up at ${body.topup
|
|
390
|
+
throw this._fail(slug, r, `call "${slug}" refused by credits: ${body.error || "payment required"}${body.balanceUsd != null ? ` (balance $${body.balanceUsd})` : ""} ${body.topup ? ` - top up at ${body.topup}` : body.topupNote ? ` - ${body.topupNote}` : ""}`);
|
|
391
391
|
}
|
|
392
392
|
if (!r.ok) throw this._fail(slug, r, await this._failureDetail(slug, r));
|
|
393
393
|
this._spendSettle(reservation);
|
|
@@ -397,7 +397,7 @@ export class Agent402 {
|
|
|
397
397
|
}
|
|
398
398
|
const r = await send(); // no wallet - succeeds only on a FREE_MODE instance
|
|
399
399
|
if (r.ok) return this._deliverResponse(slug, r, cacheKey, cache, validator, { maxResponseBytes, paid: false });
|
|
400
|
-
throw this._fail(slug, r, `call "${slug}" failed: HTTP ${r.status} - wallet-only tool; construct with { fetch: payFetch } (an @x402/fetch-wrapped fetch) or { creditsKey } (prepaid
|
|
400
|
+
throw this._fail(slug, r, `call "${slug}" failed: HTTP ${r.status} - wallet-only tool; construct with { fetch: payFetch } (an @x402/fetch-wrapped fetch) or { creditsKey } (a prepaid credits key already issued; new credits are not on sale)`);
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
// Free (compute-payable) tool: succeeds plainly on a FREE_MODE instance,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent402-client",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.12",
|
|
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",
|