@beggar-bot/langchain 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 +9 -2
  2. package/package.json +34 -4
  3. package/src/index.js +41 -0
package/README.md CHANGED
@@ -1,3 +1,10 @@
1
- # Temporary Holding Version
1
+ # @beggar-bot/langchain
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
+ LangChain-style tools for Beggar Bot. Each tool has `name`, `description`, `schema` (JSON Schema) and `invoke` / `func`. In a LangChain app you can wrap them with `tool()` from `@langchain/core/tools` (optional peer; this package does not import it).
4
+
5
+ ```js
6
+ import { beggarBotTools } from "@beggar-bot/langchain";
7
+
8
+ const tools = beggarBotTools({ signer });
9
+ const result = await tools.find((t) => t.name === "wallet_portfolio").invoke({ address: "0x…" });
10
+ ```
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "@beggar-bot/langchain",
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": "LangChain-style tools 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/langchain"
31
+ },
32
+ "homepage": "https://github.com/beggar-bot-x402/beggar-bot-connectors/tree/main/packages/langchain",
33
+ "bugs": {
34
+ "url": "https://github.com/beggar-bot-x402/beggar-bot-connectors/issues"
35
+ }
36
+ }
package/src/index.js ADDED
@@ -0,0 +1,41 @@
1
+ import { asSigner, callCatalog, paidRequest, CATALOG, jsonSchemaFor } from "@beggar-bot/x402-client";
2
+
3
+ export function beggarBotTools(opts = {}) {
4
+ const signer = asSigner(opts.signer);
5
+ const common = { ...opts, signer };
6
+ const tools = CATALOG.map((entry) => makeTool({
7
+ name: entry.name,
8
+ description: entry.description,
9
+ schema: jsonSchemaFor(entry),
10
+ invoke: async (args) => pack(await callCatalog(entry.name, args, common)),
11
+ }));
12
+ tools.push(makeTool({
13
+ name: "call_endpoint",
14
+ description: "Call any Beggar Bot path (600+ routes) at $0.02 USDC via x402. Pass path and optional query.",
15
+ schema: {
16
+ type: "object",
17
+ properties: {
18
+ path: { type: "string", description: "Path or URL, e.g. /v1/stablepeg" },
19
+ query: { type: "object", description: "Optional query parameters" },
20
+ },
21
+ required: ["path"],
22
+ },
23
+ invoke: async (args) => pack(await paidRequest(args.path, { ...common, method: "GET", query: args.query })),
24
+ }));
25
+ return tools;
26
+ }
27
+
28
+ function pack(result) {
29
+ return JSON.stringify({ ok: result.ok, status: result.status, data: result.data, tx: result.payment?.transaction || null });
30
+ }
31
+
32
+ function makeTool({ name, description, schema, invoke }) {
33
+ async function fn(args) {
34
+ return invoke(args);
35
+ }
36
+ return { name, description, schema, invoke: fn, func: fn, call: fn };
37
+ }
38
+
39
+ export function beggarBotLangChainTools(opts) {
40
+ return beggarBotTools(opts);
41
+ }