@beggar-bot/agentkit 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.
Files changed (3) hide show
  1. package/README.md +11 -2
  2. package/package.json +34 -4
  3. package/src/index.js +54 -0
package/README.md CHANGED
@@ -1,3 +1,12 @@
1
- # Temporary Holding Version
1
+ # @beggar-bot/agentkit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A Coinbase AgentKit-style action provider. Actions call Beggar Bot over x402 using the **buyer's** signer (a viem account or any `{ address, signTypedData }`). Pass the provider into `actionProviders` once `@coinbase/agentkit` is in your app.
4
+
5
+ This package does not import `@coinbase/agentkit` (optional peer). It exposes `name`, `supportsNetwork`, and `getActions()`, which return `{ name, description, schema, invoke }` objects AgentKit-style agents can register.
6
+
7
+ ```js
8
+ import { beggarBotActionProvider } from "@beggar-bot/agentkit";
9
+
10
+ const provider = beggarBotActionProvider({ signer });
11
+ const agentKit = await AgentKit.from({ actionProviders: [provider] }); // in the host app
12
+ ```
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "@beggar-bot/agentkit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Coinbase AgentKit-style action provider for Beggar Bot (--.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/agentkit"
31
+ },
32
+ "homepage": "https://github.com/beggar-bot-x402/beggar-bot-connectors/tree/main/packages/agentkit",
33
+ "bugs": {
34
+ "url": "https://github.com/beggar-bot-x402/beggar-bot-connectors/issues"
35
+ }
36
+ }
package/src/index.js ADDED
@@ -0,0 +1,54 @@
1
+ import { asSigner, callCatalog, paidRequest, CATALOG, jsonSchemaFor, DEFAULT_BASE_URL } from "@beggar-bot/x402-client";
2
+
3
+ export class BeggarBotActionProvider {
4
+ constructor(opts = {}) {
5
+ this.name = "beggar-bot";
6
+ this.opts = opts;
7
+ this.signer = opts.signer ? asSigner(opts.signer) : null;
8
+ }
9
+
10
+ supportsNetwork = (_network) => true;
11
+
12
+ getActions(_walletProvider) {
13
+ const signer = this.signer || walletSigner(this.opts, _walletProvider);
14
+ const common = { ...this.opts, signer };
15
+ const actions = CATALOG.map((entry) => ({
16
+ name: entry.name,
17
+ description: entry.description,
18
+ schema: jsonSchemaFor(entry),
19
+ invoke: async (args) => stringify(await callCatalog(entry.name, args, common)),
20
+ }));
21
+ actions.push({
22
+ name: "call_endpoint",
23
+ description:
24
+ "Call any Beggar Bot path (600+ routes) at $0.02 USDC via x402. Pass path (e.g. /v1/stablepeg) and optional query object.",
25
+ schema: {
26
+ type: "object",
27
+ properties: {
28
+ path: { type: "string", description: "Path or full URL, e.g. /v1/txstatus" },
29
+ query: { type: "object", description: "Optional query parameters" },
30
+ },
31
+ required: ["path"],
32
+ },
33
+ invoke: async (args) => stringify(await paidRequest(args.path, { ...common, method: "GET", query: args.query })),
34
+ });
35
+ return actions;
36
+ }
37
+ }
38
+
39
+ function walletSigner(opts, walletProvider) {
40
+ if (opts.signer) return asSigner(opts.signer);
41
+ if (walletProvider?.signTypedData && (walletProvider.address || walletProvider.getAddress)) {
42
+ const address = walletProvider.address || (typeof walletProvider.getAddress === "function" ? walletProvider.getAddress() : null);
43
+ return { address, signTypedData: (t) => walletProvider.signTypedData(t) };
44
+ }
45
+ throw new Error("beggarBotActionProvider needs a signer or an AgentKit wallet with signTypedData");
46
+ }
47
+
48
+ function stringify(result) {
49
+ return JSON.stringify({ ok: result.ok, status: result.status, data: result.data, tx: result.payment?.transaction || null });
50
+ }
51
+
52
+ export function beggarBotActionProvider(opts) {
53
+ return new BeggarBotActionProvider(opts);
54
+ }