@beggar-bot/ai-sdk 0.0.0-stage → 0.1.0
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 +12 -2
- package/package.json +34 -4
- package/src/index.js +35 -0
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @beggar-bot/ai-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vercel AI SDK-style tools for Beggar Bot. Each tool is `{ description, inputSchema, execute }` (AI SDK 5 `inputSchema` shape; `parameters` is also set for SDK 4). Spread them into `generateText({ tools })`.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { beggarBotAiTools } from "@beggar-bot/ai-sdk";
|
|
7
|
+
import { generateText } from "ai";
|
|
8
|
+
|
|
9
|
+
const tools = beggarBotAiTools({ signer });
|
|
10
|
+
await generateText({ model, tools, prompt: "What is the ETH price on Base?" });
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This package does not import `ai` (optional peer).
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beggar-bot/ai-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vercel AI SDK-style tools for Beggar Bot ($0.02 x402 on Base, buyer's wallet).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@beggar-bot/x402-client": "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Beggar Bot",
|
|
22
|
+
"email": "beggarbot@mail.grokbot.com"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/beggar-bot-x402/beggar-bot-connectors.git",
|
|
30
|
+
"directory": "packages/ai-sdk"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/beggar-bot-x402/beggar-bot-connectors/tree/main/packages/ai-sdk",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/beggar-bot-x402/beggar-bot-connectors/issues"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { asSigner, callCatalog, paidRequest, CATALOG, jsonSchemaFor } from "@beggar-bot/x402-client";
|
|
2
|
+
|
|
3
|
+
export function beggarBotAiTools(opts = {}) {
|
|
4
|
+
const signer = asSigner(opts.signer);
|
|
5
|
+
const common = { ...opts, signer };
|
|
6
|
+
const tools = {};
|
|
7
|
+
for (const entry of CATALOG) {
|
|
8
|
+
const schema = jsonSchemaFor(entry);
|
|
9
|
+
const execute = async (args) => pack(await callCatalog(entry.name, args, common));
|
|
10
|
+
tools[entry.name] = { description: entry.description, inputSchema: schema, parameters: schema, execute };
|
|
11
|
+
}
|
|
12
|
+
const callSchema = {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {
|
|
15
|
+
path: { type: "string", description: "Path or URL, e.g. /v1/stablepeg" },
|
|
16
|
+
query: { type: "object", description: "Optional query parameters" },
|
|
17
|
+
},
|
|
18
|
+
required: ["path"],
|
|
19
|
+
};
|
|
20
|
+
tools.call_endpoint = {
|
|
21
|
+
description: "Call any Beggar Bot path (600+ routes) at $0.02 USDC via x402. Pass path and optional query.",
|
|
22
|
+
inputSchema: callSchema,
|
|
23
|
+
parameters: callSchema,
|
|
24
|
+
execute: async (args) => pack(await paidRequest(args.path, { ...common, method: "GET", query: args.query })),
|
|
25
|
+
};
|
|
26
|
+
return tools;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function pack(result) {
|
|
30
|
+
return { ok: result.ok, status: result.status, data: result.data, tx: result.payment?.transaction || null };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function beggarBotVercelAiTools(opts) {
|
|
34
|
+
return beggarBotAiTools(opts);
|
|
35
|
+
}
|