@redditech/provider-kit 0.2.0 → 0.2.1

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 CHANGED
@@ -2,11 +2,14 @@
2
2
 
3
3
  Run your own paid provider on Reddi Agent Protocol: one config file, one command, any OpenAI-compatible model.
4
4
 
5
- > Payments prove transfer; RAP Assurance proves paid work.
6
-
7
5
  You bring a model (OpenRouter, a hosted API, or a local Ollama or vLLM server) and a Solana wallet. The kit puts a paid endpoint in front of it. Buyers pay per token through a metered escrow, and every paid answer carries a receipt signed by your wallet.
8
6
 
9
- **Status.** Repo-local and not yet on npm. Tested against a simulated chain; the devnet walk-through below is the next proof. The V1 escrow program is not on mainnet yet, so use `solana-devnet`. The kit is new code and has had no independent security review.
7
+ ```bash
8
+ npm install -g @redditech/provider-kit
9
+ rap-provider --help
10
+ ```
11
+
12
+ Mainnet is coming soon. Until the V1 escrow program is live there, run your provider on `solana-devnet`: the walk-through below takes you from a new wallet to a paid, receipted call.
10
13
 
11
14
  ## How a paid call works
12
15
 
@@ -34,10 +37,7 @@ The buyer is charged only after the model has answered, and the answer is sent o
34
37
  You need Node 20 or newer and the Solana CLI (https://solana.com/docs/intro/installation). Devnet SOL and USDC come from web faucets: the command-line airdrop is closed on devnet.
35
38
 
36
39
  ```bash
37
- # From a checkout of this repository, until the packages are on npm:
38
- npm --prefix packages/x402-solana ci && npm --prefix packages/x402-solana run build
39
- npm --prefix packages/provider-kit ci && npm --prefix packages/provider-kit run build
40
- alias rap-provider="node $PWD/packages/provider-kit/dist/src/cli.js"
40
+ npm install -g @redditech/provider-kit
41
41
 
42
42
  # 1. A wallet for the provider. Fund its address with 0.5 devnet SOL at
43
43
  # https://faucet.solana.com, then create its USDC token account.
@@ -49,16 +49,19 @@ spl-token create-account 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU \
49
49
 
50
50
  # 2. A config. It starts with mock answers so you can try the payment flow first.
51
51
  rap-provider init --wallet "$(solana address -k ~/.config/solana/provider.json)"
52
- # then set "keypairPath": "~/.config/solana/provider.json" in provider.json
52
+ # init points keypairPath at the Solana CLI default, ~/.config/solana/id.json.
53
+ # Set "keypairPath": "~/.config/solana/provider.json" in provider.json instead.
53
54
 
54
- # 3. Check the setup. This reads only; it sends and spends nothing.
55
+ # 3. Check the setup. This reads only; it sends and spends nothing. It opens the
56
+ # key file named in keypairPath to check it matches your wallet, and says which
57
+ # file it read; nothing from it is printed or sent.
55
58
  rap-provider doctor
56
59
 
57
60
  # 4. Serve.
58
61
  rap-provider start
59
62
  ```
60
63
 
61
- In another terminal, make a paid call as a buyer. Use a second, devnet-only wallet: give it 0.5 devnet SOL at https://faucet.solana.com for fees, and devnet USDC at https://faucet.circle.com (choose Solana Devnet), which also creates its USDC token account.
64
+ In another terminal, make a paid call as a buyer with the example scripts in this repository (clone it, then run `npm ci && npm run build` in `packages/x402-solana` and `packages/provider-kit`). Use a second, devnet-only wallet: give it 0.5 devnet SOL at https://faucet.solana.com for fees, and devnet USDC at https://faucet.circle.com (choose Solana Devnet), which also creates its USDC token account.
62
65
 
63
66
  ```bash
64
67
  solana-keygen new --outfile ~/.config/solana/buyer.json
@@ -113,7 +116,7 @@ The most one call can cost is the price of every input token a request can hold
113
116
 
114
117
  `publicUrl` must be a public https address before you list. Set `listing.capabilities` to say what the provider is for, for example `{ "taskTypes": ["writing"] }`, and `listing.appUrl` (or `RAP_APP_URL`) for another deployment of the app.
115
118
 
116
- The wallet sign-in was checked against the devnet app on 21 November 2026: a message signed by the kit is accepted and the app confirms the session for that wallet. A full `register` with a listing has not been run yet.
119
+ The wallet sign-in works against the devnet app: a message signed by the kit is accepted and the app confirms the session for that wallet.
117
120
 
118
121
  ## Configuration
119
122
 
@@ -188,16 +191,15 @@ The worst case of a call counts four characters of input as one token. A model t
188
191
  - **Your key signs two things only**: settle (or decline) transactions for escrows payable to you, and receipts. It is read once from the key file and is never logged or sent anywhere.
189
192
  - **Run one process per payment memory file.** For several instances behind a load balancer, use a shared database store (`DatabaseReplayStore` in `@redditech/x402-solana`) through the library API.
190
193
 
191
- ## Limits today
194
+ ## Good to know
195
+
196
+ - Single paid calls and multi-call sessions run end to end on devnet. Mainnet is coming soon; `rap-provider doctor` checks that your token account and the treasury's are ready for your currency before you take payment.
197
+ - A single-call settle that did not land is logged as `settle_failed` with the escrow's address. The lock stays open until its refund window, so you can settle it by hand in that time. (A session's settle is retried by the sweep.)
198
+ - Calls take text messages and answer in one piece; `stream: true` is refused.
199
+ - Prices are in token currencies (USDC, AUDD, PYUSD, USDG).
200
+ - The estimate counts four characters as one token, and the same count is used when a model reports no usage. A buyer who locks exactly the minimum caps your payment at that estimate, so text that tokenises more densely can cost you the difference.
192
201
 
193
- - Do not run a funded provider on mainnet yet. A single paid call and a three-call session were run end to end on devnet on 21 November 2026 (mock answers, devnet USDC); the payout refusals and recovery paths above are covered by tests against a simulated chain only. The treasury's token accounts must be confirmed ready for each currency first (`rap-provider doctor` checks yours).
194
- - A single-call settle known not to have landed is not retried later by itself (a session's settle is retried by the sweep until the refund window). The log line `settle_failed` names the escrow; the lock stays open until its refund window, and you can settle it by hand within that time.
195
- - No streaming responses. Requests with `stream: true` are refused.
196
- - Message content must be text.
197
- - Token currencies only. SOL-priced metered calls are not offered.
198
- - The estimate counts four characters as one token. A buyer who locks exactly the minimum caps your payment at that estimate, so text that tokenises more densely can cost you the difference.
199
- - When the model reports no usage, tokens are estimated the same way.
200
- - Sessions on a rated escrow are not offered yet.
202
+ On the roadmap: streaming responses, SOL-priced metered calls, sessions on rated escrows, automatic retry of a single-call settle, and hardware wallet payers.
201
203
 
202
204
  ## Library use
203
205
 
package/dist/src/cli.js CHANGED
@@ -17,7 +17,7 @@ import { createProviderChain } from "./chain.js";
17
17
  import { listingBody, publishListing, readListings } from "./listing.js";
18
18
  import { AGENT_REGISTRATION_FEE_LAMPORTS, agentAddress, buildRegisterAgentInstruction, readAgentRecord } from "./registry.js";
19
19
  import { checkProviderCluster } from "@redditech/x402-solana";
20
- import { DEFAULT_CONFIG_FILE, exampleConfig, parseProviderConfig } from "./config.js";
20
+ import { DEFAULT_CONFIG_FILE, exampleConfig, parseProviderConfig, SOLANA_CLI_DEFAULT_KEY } from "./config.js";
21
21
  import { formatDoctor, runDoctor } from "./doctor.js";
22
22
  import { ADL_PATH, providerAdlText } from "./adl.js";
23
23
  import { loadProviderKey } from "./keys.js";
@@ -100,7 +100,7 @@ export async function runCli(args, io) {
100
100
  return 1;
101
101
  }
102
102
  writeFileSync(path, `${JSON.stringify(file, null, 2)}\n`, { mode: 0o600 });
103
- io.out(`Wrote ${path}.${wallet ? "" : " Set wallet to your provider wallet's address."}\nNext: rap-provider doctor`);
103
+ io.out(`Wrote ${path}.${wallet ? "" : " Set wallet to your provider wallet's address."}\nIts keypairPath is the Solana CLI default, ${SOLANA_CLI_DEFAULT_KEY}: point it at your provider wallet's key file. doctor reads that file only to check it matches the wallet.\nNext: rap-provider doctor`);
104
104
  return 0;
105
105
  }
106
106
  if (command === "doctor") {
@@ -162,4 +162,6 @@ export declare function knownMint(network: ProviderNetwork, currency: string): s
162
162
  */
163
163
  export declare function parseProviderConfig(file: unknown, env?: Record<string, string | undefined>): ConfigResult;
164
164
  /** A starting config for `rap-provider init`. Mock upstream, devnet, USDC. */
165
+ /** The Solana CLI's default keypair, which `init` points at until the operator names a dedicated provider key. */
166
+ export declare const SOLANA_CLI_DEFAULT_KEY = "~/.config/solana/id.json";
165
167
  export declare function exampleConfig(wallet: string): ProviderConfigFile;
@@ -233,6 +233,8 @@ export function parseProviderConfig(file, env = {}) {
233
233
  };
234
234
  }
235
235
  /** A starting config for `rap-provider init`. Mock upstream, devnet, USDC. */
236
+ /** The Solana CLI's default keypair, which `init` points at until the operator names a dedicated provider key. */
237
+ export const SOLANA_CLI_DEFAULT_KEY = "~/.config/solana/id.json";
236
238
  export function exampleConfig(wallet) {
237
239
  return {
238
240
  name: "My provider",
@@ -243,6 +245,6 @@ export function exampleConfig(wallet) {
243
245
  model: "openai/gpt-4o-mini",
244
246
  upstream: { baseUrl: "https://openrouter.ai/api/v1", apiKeyEnv: "UPSTREAM_API_KEY", mock: true },
245
247
  price: { currency: "USDC", inputPerMillion: "0.15", outputPerMillion: "0.60", maxOutputTokens: 1000 },
246
- keypairPath: "~/.config/solana/id.json",
248
+ keypairPath: SOLANA_CLI_DEFAULT_KEY,
247
249
  };
248
250
  }
@@ -1,5 +1,5 @@
1
1
  import type { ProviderChain } from "./chain.js";
2
- import type { ProviderConfig } from "./config.js";
2
+ import { type ProviderConfig } from "./config.js";
3
3
  import type { ProviderKeyResult } from "./keys.js";
4
4
  export type CheckStatus = "pass" | "warn" | "fail";
5
5
  export interface DoctorCheck {
@@ -6,6 +6,7 @@ import { accessSync, constants, existsSync } from "node:fs";
6
6
  import { dirname, resolve } from "node:path";
7
7
  import { PublicKey } from "@solana/web3.js";
8
8
  import { checkProviderCluster, checkTokenAccount, checkTreasuryReadiness, ESCROW_PROTOCOL_TREASURY, token2022MintPosture, treasuryTokenAccount } from "@redditech/x402-solana";
9
+ import { SOLANA_CLI_DEFAULT_KEY } from "./config.js";
9
10
  import { ADL_PATH, maxPerCall, providerAdlText } from "./adl.js";
10
11
  /** Enough for transaction fees, with room for the rent of a token account. */
11
12
  export const WALLET_MIN_LAMPORTS = 10000000n;
@@ -114,9 +115,12 @@ export async function runDoctor(input) {
114
115
  add({ name: "Chain accounts", status: "fail", detail: "an account could not be read", fix: "Check the RPC endpoint and try again." });
115
116
  return done();
116
117
  }
118
+ // Say which file was read, so reading the Solana CLI's default key never comes as a surprise.
119
+ const keyFile = config.keypairPath?.trim();
120
+ const keyNote = keyFile ? ` (read ${keyFile} to compare its public key; nothing from it is printed or sent${keyFile === SOLANA_CLI_DEFAULT_KEY ? ". This is the Solana CLI's default key: set keypairPath to use a dedicated provider wallet" : ""})` : "";
117
121
  add(input.key.ok
118
- ? { name: "Signing key", status: "pass", detail: "the key file belongs to the configured wallet" }
119
- : { name: "Signing key", status: "fail", detail: input.key.message, fix: "Point keypairPath (or RAP_PROVIDER_KEYPAIR_PATH) at the wallet's keypair file." });
122
+ ? { name: "Signing key", status: "pass", detail: `the key file belongs to the configured wallet${keyNote}` }
123
+ : { name: "Signing key", status: "fail", detail: `${input.key.message}${keyNote}`, fix: "Point keypairPath (or RAP_PROVIDER_KEYPAIR_PATH) at the wallet's keypair file." });
120
124
  if (config.upstream.mock) {
121
125
  add({ name: "Model", status: config.network === "solana-mainnet-beta" ? "fail" : "warn", detail: "mock answers are on, so buyers would pay for canned text", fix: "Set upstream.mock to false and upstream.baseUrl to your model before you list." });
122
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redditech/provider-kit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Run your own paid, per-token priced provider on Reddi Agent Protocol: one config file, one command, any OpenAI-compatible model.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -41,8 +41,8 @@
41
41
  "node": ">=20"
42
42
  },
43
43
  "dependencies": {
44
- "@redditech/agent-protocol": "^0.2.0",
45
- "@redditech/x402-solana": "^0.1.0",
44
+ "@redditech/agent-protocol": "^0.2.1",
45
+ "@redditech/x402-solana": "^0.1.1",
46
46
  "@solana/web3.js": "^1.98.4"
47
47
  },
48
48
  "devDependencies": {