opentool 0.7.1 → 0.7.3
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 +42 -15
- package/dist/cli/index.d.ts +4 -3
- package/dist/cli/index.js +264 -669
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +595 -865
- package/dist/index.js.map +1 -1
- package/dist/validate-BrOwtVYW.d.ts +382 -0
- package/dist/x402/index.d.ts +154 -0
- package/dist/x402/index.js +708 -0
- package/dist/x402/index.js.map +1 -0
- package/package.json +11 -7
- package/dist/index-D_bCF2Bf.d.ts +0 -487
- package/dist/payment/index.d.ts +0 -2
- package/dist/payment/index.js +0 -969
- package/dist/payment/index.js.map +0 -1
- package/dist/validate-CqB2Juma.d.ts +0 -216
package/README.md
CHANGED
|
@@ -65,36 +65,63 @@ npx opentool validate
|
|
|
65
65
|
npx opentool dev
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
### 4. x402
|
|
68
|
+
### 4. Add x402 payments (optional)
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Protect your tools with crypto payments using x402:
|
|
71
71
|
|
|
72
72
|
```typescript
|
|
73
|
-
|
|
74
|
-
import {
|
|
73
|
+
// tools/premium-report.ts
|
|
74
|
+
import { z } from "zod";
|
|
75
|
+
import { defineX402Payment } from "opentool/x402";
|
|
76
|
+
|
|
77
|
+
export const schema = z.object({
|
|
78
|
+
symbol: z.string().describe("Crypto symbol (e.g., BTC)"),
|
|
79
|
+
});
|
|
75
80
|
|
|
76
|
-
export const payment =
|
|
77
|
-
amount: "0.
|
|
81
|
+
export const payment = defineX402Payment({
|
|
82
|
+
amount: "0.001",
|
|
83
|
+
payTo: process.env.WALLET_ADDRESS!,
|
|
78
84
|
currency: "USDC",
|
|
79
|
-
|
|
80
|
-
message: "Premium analytics require payment
|
|
81
|
-
acceptedMethods: ["x402", "402"],
|
|
82
|
-
acceptedCurrencies: ["USDC"],
|
|
83
|
-
chains: ["base"],
|
|
84
|
-
facilitator: "opentool",
|
|
85
|
+
network: "base-sepolia",
|
|
86
|
+
message: "Premium analytics require payment",
|
|
85
87
|
});
|
|
86
88
|
|
|
87
89
|
export async function POST(request: Request) {
|
|
88
90
|
const payload = await request.json();
|
|
89
91
|
const { symbol } = schema.parse(payload);
|
|
90
|
-
|
|
92
|
+
|
|
91
93
|
return Response.json({
|
|
92
|
-
|
|
94
|
+
report: `Premium analytics for ${symbol}`,
|
|
93
95
|
});
|
|
94
96
|
}
|
|
95
97
|
```
|
|
96
98
|
|
|
97
|
-
|
|
99
|
+
Test the payment flow:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Start dev server
|
|
103
|
+
WALLET_ADDRESS=0x... npx opentool dev --input tools
|
|
104
|
+
|
|
105
|
+
# Test with the x402 client
|
|
106
|
+
PRIVATE_KEY=0x... bun examples/full-metadata/test-x402.ts
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Or test manually:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Get 402 response with payment requirements
|
|
113
|
+
curl -X POST http://localhost:7000/premium-report \
|
|
114
|
+
-H "content-type: application/json" \
|
|
115
|
+
-d '{"symbol":"BTC"}'
|
|
116
|
+
|
|
117
|
+
# Pay and retry with X-PAYMENT header (generated by x402 client)
|
|
118
|
+
curl -X POST http://localhost:7000/premium-report \
|
|
119
|
+
-H "content-type: application/json" \
|
|
120
|
+
-H "X-PAYMENT: ${X402_HEADER}" \
|
|
121
|
+
-d '{"symbol":"BTC"}'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### MCP
|
|
98
125
|
|
|
99
126
|
By default, tools are HTTP-only. Want them accessible via MCP clients like Claude Desktop? Just add this to your tool file:
|
|
100
127
|
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { h as Metadata, I as InternalToolDefinition } from '../validate-
|
|
3
|
-
export { G as GenerateMetadataOptions,
|
|
2
|
+
import { h as Metadata, I as InternalToolDefinition } from '../validate-BrOwtVYW.js';
|
|
3
|
+
export { G as GenerateMetadataOptions, j as GenerateMetadataResult, V as ValidateOptions, g as generateMetadata, a as generateMetadataCommand, l as loadAndValidateTools, v as validateCommand, k as validateFullCommand } from '../validate-BrOwtVYW.js';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '../index
|
|
5
|
+
import '../x402/index.js';
|
|
6
|
+
import 'viem';
|
|
6
7
|
|
|
7
8
|
interface BuildOptions {
|
|
8
9
|
input: string;
|