agent402-openclaw 0.5.5 → 0.5.7
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 +6 -4
- package/cli.js +1 -1
- package/known-assets.js +37 -1
- package/package.json +2 -2
- package/proxy.js +2 -2
package/README.md
CHANGED
|
@@ -5,8 +5,10 @@ Part of [Agent402](https://agent402.tools), the open-source paid door for AI age
|
|
|
5
5
|
Agent402 as an [OpenClaw](https://openclaw.ai) model provider: the auto-routed
|
|
6
6
|
tier at a **flat per-call price** and explicit frontier models **priced per
|
|
7
7
|
request** from the body, paid in **USDC over x402** from a wallet or with a
|
|
8
|
-
prepaid credits key
|
|
9
|
-
and gateway reach Agent402's 500+ pay-per-call tools
|
|
8
|
+
prepaid credits key (agent402.tools/credits says whether packs are on sale). The
|
|
9
|
+
same key and gateway reach Agent402's 500+ pay-per-call tools; credits pay
|
|
10
|
+
Agent402's own services, so the routes that buy from an outside seller
|
|
11
|
+
(the route-execute tiers, `seller-payability`, `decide-execute` and the flight routes) need a wallet.
|
|
10
12
|
|
|
11
13
|
Guide: https://agent402.tools/guides/openclaw-model-provider
|
|
12
14
|
|
|
@@ -22,7 +24,7 @@ With no credits key and no `AGENT402_WALLET_KEY`, `setup` generates an EVM
|
|
|
22
24
|
wallet into `~/.openclaw/agent402/wallet.key` (0600, the only copy, never
|
|
23
25
|
printed) and prints its address: send it USDC on Base and every call is paid
|
|
24
26
|
from it over x402. `agent402-openclaw wallet` shows the address and balance;
|
|
25
|
-
`--no-wallet` skips the generation. Holding a credits key
|
|
27
|
+
`--no-wallet` skips the generation. Holding a credits key? Run
|
|
26
28
|
`AGENT402_CREDITS_KEY=a402_... npx agent402-openclaw setup --write` (key by env,
|
|
27
29
|
or `--credits-key -` on stdin).
|
|
28
30
|
|
|
@@ -105,7 +107,7 @@ of a cent and a long one pays for what it asks. `--flat` (or
|
|
|
105
107
|
Either way OpenClaw's per-token cost fields stay zero; the price is per call. A model sent to another flat
|
|
106
108
|
tier's route is priced at its home tier: the 402 quotes that tier's price, and the paid call is served under
|
|
107
109
|
that tier's caps (the answer says so in `agent402_tier`). The router, grounded and stealth tiers still answer a
|
|
108
|
-
400 naming the right route; nothing is charged. A client-supplied `Idempotency-Key`
|
|
110
|
+
400 naming the right route; nothing is charged on x402. A client-supplied `Idempotency-Key`
|
|
109
111
|
is passed through: on a credits key, a retry with the same key replays the paid
|
|
110
112
|
answer; on a wallet, each forwarded call signs a fresh payment, which the server
|
|
111
113
|
treats as a new purchase. Without a key, each call is its own payment.
|
package/cli.js
CHANGED
|
@@ -100,7 +100,7 @@ async function main() {
|
|
|
100
100
|
out(` key: ${WALLET_KEY_FILE()} (0600; back it up, it is the only copy)`);
|
|
101
101
|
out(`fund it with USDC on Base (any amount; a call costs from $0.001), then every call is paid from it over x402.`);
|
|
102
102
|
out(`optional: \`agent402-openclaw permit2-approve\` once (needs a little ETH on Base for gas) to pay actual usage instead of the per-request quote.`);
|
|
103
|
-
out(`holding a credits key
|
|
103
|
+
out(`holding a credits key? rerun with --credits-key a402_... instead`);
|
|
104
104
|
} else {
|
|
105
105
|
out(`no payment method yet: install viem + @x402/fetch + @x402/evm and rerun to generate a wallet, set AGENT402_WALLET_KEY, or rerun with --credits-key a402_... if you hold a credits key`);
|
|
106
106
|
}
|
package/known-assets.js
CHANGED
|
@@ -32,10 +32,46 @@ export const KNOWN_ASSETS = Object.freeze({
|
|
|
32
32
|
"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": [{ asset: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", decimals: 6, symbol: "USDC" }], // devnet
|
|
33
33
|
// Stellar: the USDC Stellar Asset Contract (7 decimals on Stellar).
|
|
34
34
|
"stellar:pubnet": [{ asset: "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75", decimals: 7, symbol: "USDC" }],
|
|
35
|
-
// Algorand: USDC is ASA 31566704.
|
|
35
|
+
// Algorand: USDC is ASA 31566704. Mainnet is named by its CAIP-2 id (the
|
|
36
|
+
// first 32 characters of the base64 genesis hash) and, by sellers that
|
|
37
|
+
// predate it, by the full hash.
|
|
38
|
+
"algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k": [{ asset: "31566704", decimals: 6, symbol: "USDC" }],
|
|
36
39
|
"algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=": [{ asset: "31566704", decimals: 6, symbol: "USDC" }],
|
|
37
40
|
});
|
|
38
41
|
|
|
42
|
+
/** Chain name -> every network id in the table that names that chain. A
|
|
43
|
+
* chain spelled two ways on the wire lists both, so a buyer's preference by
|
|
44
|
+
* name, or by either spelling, matches a seller's accept in the other. */
|
|
45
|
+
export const NETWORK_NAMES = Object.freeze({
|
|
46
|
+
base: ["eip155:8453"],
|
|
47
|
+
"base-sepolia": ["eip155:84532"],
|
|
48
|
+
polygon: ["eip155:137"],
|
|
49
|
+
arbitrum: ["eip155:42161"],
|
|
50
|
+
monad: ["eip155:143"],
|
|
51
|
+
celo: ["eip155:42220"],
|
|
52
|
+
avalanche: ["eip155:43114"],
|
|
53
|
+
sei: ["eip155:1329"],
|
|
54
|
+
optimism: ["eip155:10"],
|
|
55
|
+
arc: ["eip155:5042"],
|
|
56
|
+
robinhood: ["eip155:4663"],
|
|
57
|
+
solana: ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
|
|
58
|
+
"solana-devnet": ["solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"],
|
|
59
|
+
stellar: ["stellar:pubnet"],
|
|
60
|
+
algorand: ["algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k", "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8="],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/** The network ids a preference names: a chain name's ids; for an id, every
|
|
64
|
+
* id of the chain it belongs to (so either spelling matches the other); an
|
|
65
|
+
* id the table does not know passes through as itself. */
|
|
66
|
+
export function networkIdsOf(pref) {
|
|
67
|
+
const p = String(pref || "").trim();
|
|
68
|
+
if (!p) return [];
|
|
69
|
+
const byName = NETWORK_NAMES[p.toLowerCase()];
|
|
70
|
+
if (byName) return [...byName];
|
|
71
|
+
for (const ids of Object.values(NETWORK_NAMES)) if (ids.some((id) => id.toLowerCase() === p.toLowerCase())) return [...ids];
|
|
72
|
+
return [p];
|
|
73
|
+
}
|
|
74
|
+
|
|
39
75
|
const EVM_ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
40
76
|
// EVM addresses compare without case (checksum casing is presentation);
|
|
41
77
|
// base58, Stellar and Algorand identifiers compare exactly.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent402-openclaw",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "OpenClaw model provider for Agent402: an auto-routed tier at a flat per-call price and explicit LLM models priced per request, paid in USDC over x402, or with a prepaid credits key
|
|
3
|
+
"version": "0.5.7",
|
|
4
|
+
"description": "OpenClaw model provider for Agent402: an auto-routed tier at a flat per-call price and explicit LLM models priced per request, paid in USDC over x402, or with a prepaid credits key, through a local proxy. Zero dependencies; x402 wallet payment is an optional peer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"exports": {
|
package/proxy.js
CHANGED
|
@@ -243,7 +243,7 @@ export async function startProxy({ upstream = DEFAULT_UPSTREAM, creditsKey = nul
|
|
|
243
243
|
return json(res, 400, { error: { message: `Unknown model "${requested}". Use "auto" or an id from GET /v1/models (${table.size} available).`, type: "invalid_request_error", code: "model_not_found" } });
|
|
244
244
|
}
|
|
245
245
|
if (!paid) {
|
|
246
|
-
return json(res, 402, { error: { message: "No payment method configured. Run `agent402-openclaw setup` to generate an x402 wallet, set AGENT402_WALLET_KEY, or set AGENT402_CREDITS_KEY to a credits key
|
|
246
|
+
return json(res, 402, { error: { message: "No payment method configured. Run `agent402-openclaw setup` to generate an x402 wallet, set AGENT402_WALLET_KEY, or set AGENT402_CREDITS_KEY to a prepaid credits key.", type: "payment_required", code: "agent402_unconfigured" }, topup: `${upstream}/credits`, priceUsd: route.priceUsd });
|
|
247
247
|
}
|
|
248
248
|
const outbound = { ...body };
|
|
249
249
|
if (requested === AUTO_ID) delete outbound.model; else outbound.model = route.id;
|
|
@@ -257,7 +257,7 @@ export async function startProxy({ upstream = DEFAULT_UPSTREAM, creditsKey = nul
|
|
|
257
257
|
return json(res, 400, { type: "error", error: { type: "invalid_request_error", message: "\"model\" is required (any id from GET /v1/models, or a Claude id such as claude-sonnet-5)" } });
|
|
258
258
|
}
|
|
259
259
|
if (!paid) {
|
|
260
|
-
return json(res, 402, { type: "error", error: { type: "payment_required", message: "No payment method configured. Set AGENT402_WALLET_KEY to an EVM key holding USDC on Base (or run `agent402-openclaw setup`), or set AGENT402_CREDITS_KEY to a credits key
|
|
260
|
+
return json(res, 402, { type: "error", error: { type: "payment_required", message: "No payment method configured. Set AGENT402_WALLET_KEY to an EVM key holding USDC on Base (or run `agent402-openclaw setup`), or set AGENT402_CREDITS_KEY to a prepaid credits key." } });
|
|
261
261
|
}
|
|
262
262
|
const outbound = { ...body, model: body.model.trim().replace(/^agent402\//, "") };
|
|
263
263
|
const extra = {};
|