@curekit/actions-x402 0.2.4

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.
@@ -0,0 +1,3 @@
1
+ export { X402Provider, x402Actions } from "./x402ActionProvider.js";
2
+ export declare const X402_ACTION_PROVIDER_NAME = "x402";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpE,eAAO,MAAM,yBAAyB,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { X402Provider, x402Actions } from "./x402ActionProvider.js";
2
+ export const X402_ACTION_PROVIDER_NAME = "x402";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpE,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { z } from "zod";
2
+ import type { WalletProvider } from "@curekit/core";
3
+ import { ActionProvider } from "@curekit/core";
4
+ declare const PaySchema: z.ZodObject<{
5
+ url: z.ZodString;
6
+ method: z.ZodDefault<z.ZodOptional<z.ZodEnum<["GET", "POST"]>>>;
7
+ price: z.ZodOptional<z.ZodString>;
8
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
9
+ body: z.ZodOptional<z.ZodString>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ url: string;
12
+ method: "GET" | "POST";
13
+ price?: string | undefined;
14
+ headers?: Record<string, string> | undefined;
15
+ body?: string | undefined;
16
+ }, {
17
+ url: string;
18
+ method?: "GET" | "POST" | undefined;
19
+ price?: string | undefined;
20
+ headers?: Record<string, string> | undefined;
21
+ body?: string | undefined;
22
+ }>;
23
+ declare const DiscoverSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
24
+ export declare class X402Provider extends ActionProvider {
25
+ constructor();
26
+ pay(_wallet: WalletProvider, args: z.infer<typeof PaySchema>): Promise<string>;
27
+ discoverServices(_wallet: WalletProvider, _args: z.infer<typeof DiscoverSchema>): Promise<string>;
28
+ }
29
+ /** Create an x402 action provider for HTTP 402 payments. */
30
+ export declare const x402Actions: () => X402Provider;
31
+ export {};
32
+ //# sourceMappingURL=x402ActionProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402ActionProvider.d.ts","sourceRoot":"","sources":["../src/x402ActionProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAU,cAAc,EAAE,MAAM,eAAe,CAAC;AAEvD,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;EAMb,CAAC;AAEH,QAAA,MAAM,cAAc,gDAAe,CAAC;AAEpC,qBAAa,YAAa,SAAQ,cAAc;;IAYxC,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB9E,gBAAgB,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAMxG;AAED,4DAA4D;AAC5D,eAAO,MAAM,WAAW,oBAA2B,CAAC"}
@@ -0,0 +1,65 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { z } from "zod";
11
+ import { Action, ActionProvider } from "@curekit/core";
12
+ const PaySchema = z.object({
13
+ url: z.string().describe("API endpoint URL"),
14
+ method: z.enum(["GET", "POST"]).optional().default("GET").describe("HTTP method"),
15
+ price: z.string().optional().describe("Maximum price to pay (e.g., '$0.01'). Fetched from server if not specified."),
16
+ headers: z.record(z.string()).optional().describe("Additional HTTP headers"),
17
+ body: z.string().optional().describe("Request body (for POST)"),
18
+ });
19
+ const DiscoverSchema = z.object({});
20
+ export class X402Provider extends ActionProvider {
21
+ constructor() {
22
+ super("x402", []);
23
+ }
24
+ async pay(_wallet, args) {
25
+ const method = args.method || "GET";
26
+ const network = _wallet.getNetwork();
27
+ return `x402 payment to ${args.url} initiated via ${method} on ${network.networkId}. ` +
28
+ `${args.price ? `Price: ${args.price}. ` : ""}` +
29
+ `Transaction would be signed by wallet ${_wallet.getAddress()}. ` +
30
+ `Mock result: Payment successful.`;
31
+ }
32
+ async discoverServices(_wallet, _args) {
33
+ return "Discovered x402 services:\n" +
34
+ "- Stellar AI Oracle: https://oracle.stellar.org/x402 (USDC 0.01/req)\n" +
35
+ "- Blend Data Feed: https://data.blend.capital/x402 (USDC 0.05/req)\n" +
36
+ "- Soroswap Price API: https://api.soroswap.io/x402 (USDC 0.02/req)";
37
+ }
38
+ }
39
+ __decorate([
40
+ Action({
41
+ name: "pay",
42
+ description: "Make a paid HTTP request to an x402-enabled API. The agent pays USDC per request via the Stellar network.",
43
+ similes: ["pay api", "make paid request", "x402 request"],
44
+ schema: PaySchema,
45
+ needsWallet: true,
46
+ }),
47
+ __metadata("design:type", Function),
48
+ __metadata("design:paramtypes", [Function, void 0]),
49
+ __metadata("design:returntype", Promise)
50
+ ], X402Provider.prototype, "pay", null);
51
+ __decorate([
52
+ Action({
53
+ name: "discover_services",
54
+ description: "Discover x402-enabled API services on the network",
55
+ similes: ["find paid apis", "x402 services", "paid api discovery"],
56
+ schema: DiscoverSchema,
57
+ needsWallet: true,
58
+ }),
59
+ __metadata("design:type", Function),
60
+ __metadata("design:paramtypes", [Function, void 0]),
61
+ __metadata("design:returntype", Promise)
62
+ ], X402Provider.prototype, "discoverServices", null);
63
+ /** Create an x402 action provider for HTTP 402 payments. */
64
+ export const x402Actions = () => new X402Provider();
65
+ //# sourceMappingURL=x402ActionProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402ActionProvider.js","sourceRoot":"","sources":["../src/x402ActionProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC;IACjF,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6EAA6E,CAAC;IACpH,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;IAC5E,IAAI,EAAE,CAAC,CA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AI;KAClB,CAAC;;;;oDAMD;AAGH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=x402ActionProvider.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402ActionProvider.test.d.ts","sourceRoot":"","sources":["../src/x402ActionProvider.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { MockWalletProvider } from "@curekit/core";
3
+ import { X402Provider } from "./x402ActionProvider.js";
4
+ describe("X402Provider", () => {
5
+ const wallet = new MockWalletProvider();
6
+ const provider = new X402Provider();
7
+ it("should provide x402 actions", () => {
8
+ const actions = provider.getActions(wallet);
9
+ const names = actions.map((a) => a.name);
10
+ expect(names).toContain("x402_pay");
11
+ expect(names).toContain("x402_discover_services");
12
+ });
13
+ it("should describe actions for LLM", () => {
14
+ const actions = provider.getActions(wallet);
15
+ const pay = actions.find((a) => a.name === "x402_pay");
16
+ expect(pay.description).toContain("paid HTTP request");
17
+ expect(pay.similes.length).toBeGreaterThan(0);
18
+ });
19
+ it("should make a paid request", async () => {
20
+ const actions = provider.getActions(wallet);
21
+ const pay = actions.find((a) => a.name === "x402_pay");
22
+ const result = await pay.invoke({
23
+ url: "https://api.example.com/data",
24
+ method: "GET",
25
+ });
26
+ expect(result).toContain("x402 payment");
27
+ expect(result).toContain("api.example.com");
28
+ });
29
+ it("should discover services", async () => {
30
+ const actions = provider.getActions(wallet);
31
+ const discover = actions.find((a) => a.name === "x402_discover_services");
32
+ const result = await discover.invoke({});
33
+ expect(result).toContain("Discovered x402 services");
34
+ expect(result).toContain("Stellar AI Oracle");
35
+ });
36
+ });
37
+ //# sourceMappingURL=x402ActionProvider.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402ActionProvider.test.js","sourceRoot":"","sources":["../src/x402ActionProvider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AQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAE,CAAC;QACxD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC;YAC9B,GAAG,EAAE,8BAA8B;YACnC,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;QACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,wBAAwB,CAAE,CAAC;QAC3E,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC;QACrD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@curekit/actions-x402",
3
+ "version": "0.2.4",
4
+ "description": "x402 agentic HTTP 402 payment actions for AgentKit Stellar",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "zod": "^3.24.0",
21
+ "@curekit/core": "0.2.4"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.7.0",
25
+ "vitest": "^3.0.0"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "license": "MIT",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/anomalyco/agentkit-stellar.git",
34
+ "directory": "packages/actions-x402"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc && node ../../scripts/fix-esm-imports.mjs dist",
38
+ "test": "vitest run",
39
+ "lint": "eslint src/",
40
+ "typecheck": "tsc --noEmit",
41
+ "clean": "rm -rf dist"
42
+ }
43
+ }