@paystage/ai-sdk 0.0.0-stage → 0.1.1-canary.30
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 +54 -2
- package/package.json +54 -4
package/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @paystage/ai-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
PayStage preflight as [AI SDK](https://ai-sdk.dev) tools. Decide whether an x402 payment should be
|
|
4
|
+
signed **inside the same loop that would sign it**, with the rules that fired.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @paystage/ai-sdk ai zod
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { generateText, gateway } from "ai";
|
|
12
|
+
import { paystageTools } from "@paystage/ai-sdk";
|
|
13
|
+
|
|
14
|
+
const policy = {
|
|
15
|
+
version: 1,
|
|
16
|
+
max_amount: { value: "0.05", asset: "USDC", decimals: 6 },
|
|
17
|
+
allowed_assets: [{ symbol: "USDC", decimals: 6, address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", network: "eip155:8453" }],
|
|
18
|
+
allowed_networks: ["eip155:8453"],
|
|
19
|
+
unknown_payee: "deny",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const { text } = await generateText({
|
|
23
|
+
model: gateway("openai/gpt-5-mini"),
|
|
24
|
+
tools: { ...paystageTools({ policy }), ...yourPaymentTools },
|
|
25
|
+
prompt: "Buy the weather data, but not above 2 cents.",
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## The two tools
|
|
30
|
+
|
|
31
|
+
| tool | returns |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `paystage_evaluate_payment` | `decision` (`pay` / `review` / `do_not_pay`), `reasons[]`, `summary` |
|
|
34
|
+
| `paystage_should_pay` | `allowed`, `decision`, `reasons[]` — one-word form for when reasoning is noise |
|
|
35
|
+
|
|
36
|
+
## What it will not do
|
|
37
|
+
|
|
38
|
+
**Nothing here signs, holds a key, or moves money.** That is not a limitation, it is the design: the
|
|
39
|
+
tool that decides must not be the tool that spends. Your payment tool stays where it is; these tools
|
|
40
|
+
only tell the model whether to call it.
|
|
41
|
+
|
|
42
|
+
Read-only also means the cost is predictable — evaluating a payment is a local computation, not a
|
|
43
|
+
network call and not a paid request.
|
|
44
|
+
|
|
45
|
+
## `onReview`
|
|
46
|
+
|
|
47
|
+
`review` means the policy found something worth a human's attention (an unknown payee, an unusual
|
|
48
|
+
amount) but did not refuse. `onReview: "refuse"` turns those into refusals; the default `"pay"` lets
|
|
49
|
+
them through with the reason attached.
|
|
50
|
+
|
|
51
|
+
## Related
|
|
52
|
+
|
|
53
|
+
- [`@paystage/x402-guard`](https://www.npmjs.com/package/@paystage/x402-guard) — the same policy, wrapping `fetch` so a refusal never reaches the signer
|
|
54
|
+
- [`@paystage/mcp`](https://www.npmjs.com/package/@paystage/mcp) — nine tools over MCP, for Claude, Cursor and anything else that speaks it
|
|
55
|
+
- Hosted, no install: `https://api.paystage.xyz/mcp`
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paystage/ai-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1-canary.30",
|
|
4
|
+
"description": "PayStage preflight as AI SDK tools: pay / review / do_not_pay before an agent signs an x402 payment",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"!dist/**/*.map",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"ai-sdk",
|
|
22
|
+
"vercel",
|
|
23
|
+
"x402",
|
|
24
|
+
"payments",
|
|
25
|
+
"agents",
|
|
26
|
+
"preflight",
|
|
27
|
+
"mcp"
|
|
28
|
+
],
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/base-buzz/paystage",
|
|
32
|
+
"directory": "packages/ai-sdk"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://paystage.xyz/ai-sdk",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"test": "vitest run"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@paystage/preflight": "0.3.0-canary.30",
|
|
41
|
+
"zod": "^4.6.7"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"ai": ">=5"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"ai": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"ai": "^6.0.0",
|
|
53
|
+
"typescript": "^5.9.0",
|
|
54
|
+
"vitest": "^4.1.12"
|
|
55
|
+
}
|
|
56
|
+
}
|