@botsrated/ai-sdk 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +39 -2
- package/dist/index.d.ts +1626 -0
- package/dist/index.js +62 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BotsRated
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @botsrated/ai-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[AI SDK](https://ai-sdk.dev) tools for [BotsRated](https://botsrated.com) (beta). Use them as a
|
|
4
|
+
pre-payment check before an agent pays an x402 seller.
|
|
5
|
+
|
|
6
|
+
**Status: published on npm as [`@botsrated/ai-sdk`](https://www.npmjs.com/package/@botsrated/ai-sdk) (0.1.0).** It depends on
|
|
7
|
+
[`@botsrated/x402-preflight`](https://www.npmjs.com/package/@botsrated/x402-preflight) `^0.1.0`. Docs: https://botsrated.com/docs/ai-sdk
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @botsrated/ai-sdk ai zod
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { generateText, stepCountIs } from "ai";
|
|
15
|
+
import { botsratedTools } from "@botsrated/ai-sdk";
|
|
16
|
+
|
|
17
|
+
const { text } = await generateText({
|
|
18
|
+
model: "openai/gpt-5-mini",
|
|
19
|
+
prompt: "Before paying https://blockrun.ai/api/v1/chat/completions (payTo 0xe903...1aBf), check it.",
|
|
20
|
+
tools: botsratedTools(), // { botsratedPreflight } – free
|
|
21
|
+
stopWhen: stepCountIs(3), // AI SDK 7 also exports isStepCount(3)
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`stepCountIs` works on AI SDK 5, 6 and 7. `isStepCount` is the AI SDK 7 name (AI SDK 7 needs Node 22+).
|
|
26
|
+
|
|
27
|
+
Opt-in paid check, capped by a budget:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
|
|
31
|
+
import { BotsRatedClient, botsratedTools } from "@botsrated/ai-sdk";
|
|
32
|
+
|
|
33
|
+
const client = new BotsRatedClient({ paid: { budgetUsd: 0.02, fetchWithPayment: wrapFetchWithPayment(fetch, x402) } });
|
|
34
|
+
const tools = botsratedTools(client); // { botsratedPreflight, botsratedCheck ($0.001 each after 100 free/day, stops at $0.02) }
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
To guard every x402 payment, not only those the model calls a tool for, register
|
|
38
|
+
`createPrePaymentGuard().beforePaymentCreation` from `@botsrated/x402-preflight` on your `x402Client`.
|
|
39
|
+
|
|
40
|
+
Tests: `npm test`. They include a `generateText` run with `MockLanguageModelV3`.
|