UNPKG

@coinbase/agentkit

Version:

Coinbase AgentKit core primitives

80 lines (79 loc) 2.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DirectX402RequestSchema = exports.RetryWithX402Schema = exports.HttpRequestSchema = void 0; const zod_1 = require("zod"); // Schema for initial HTTP request exports.HttpRequestSchema = zod_1.z .object({ url: zod_1.z .string() .url() .describe("The URL of the API endpoint (can be localhost for development)"), method: zod_1.z .enum(["GET", "POST", "PUT", "DELETE", "PATCH"]) .nullable() .default("GET") .describe("The HTTP method to use for the request"), headers: zod_1.z .record(zod_1.z.string()) .optional() .nullable() .describe("Optional headers to include in the request"), body: zod_1.z .any() .optional() .nullable() .describe("Optional request body for POST/PUT/PATCH requests"), }) .strip() .describe("Instructions for making a basic HTTP request"); // Schema for retrying a failed request with x402 payment exports.RetryWithX402Schema = zod_1.z .object({ url: zod_1.z .string() .url() .describe("The URL of the API endpoint (can be localhost for development)"), method: zod_1.z .enum(["GET", "POST", "PUT", "DELETE", "PATCH"]) .nullable() .default("GET") .describe("The HTTP method to use for the request"), headers: zod_1.z.record(zod_1.z.string()).optional().describe("Optional headers to include in the request"), body: zod_1.z.any().optional().describe("Optional request body for POST/PUT/PATCH requests"), selectedPaymentOption: zod_1.z .object({ scheme: zod_1.z.string(), network: zod_1.z.string(), maxAmountRequired: zod_1.z.string(), asset: zod_1.z.string(), }) .describe("The payment option to use for this request"), }) .strip() .describe("Instructions for retrying a request with x402 payment after receiving a 402 response"); // Schema for direct x402 payment request (with warning) exports.DirectX402RequestSchema = zod_1.z .object({ url: zod_1.z .string() .url() .describe("The URL of the API endpoint (can be localhost for development)"), method: zod_1.z .enum(["GET", "POST", "PUT", "DELETE", "PATCH"]) .nullable() .default("GET") .describe("The HTTP method to use for the request"), headers: zod_1.z .record(zod_1.z.string()) .optional() .nullable() .describe("Optional headers to include in the request"), body: zod_1.z .any() .optional() .nullable() .describe("Optional request body for POST/PUT/PATCH requests"), }) .strip() .describe("Instructions for making an HTTP request with automatic x402 payment handling. WARNING: This bypasses user confirmation - only use when explicitly told to skip confirmation!");