/** * Plain AI SDK tool definitions: description, inputSchema and execute. * No import from "ai", so this file type-checks and tests without it. * tools.ts wraps each one in tool() from "ai". */ import { AFTER_CHECKOUT_DESCRIPTION, BEFORE_CHECKOUT_DESCRIPTION, afterCheckout, beforeCheckout, userAgentFor, type ArcOptions } from "../core/arc.ts"; import { afterCheckoutSchema, beforeCheckoutSchema, type AfterCheckoutArgs, type BeforeCheckoutArgs } from "../core/schemas.ts"; export const AI_SDK_REF = "int-ai-sdk"; export type ArcToolConfig = ArcOptions & { /** Reported as agent_name on after_checkout. No personal name. */ agentName?: string; /** Reported as agent_family, such as "browser" or a model family. */ agentFamily?: string; }; export function arcToolDefinitions(config: ArcToolConfig = {}) { const options: ArcOptions = { userAgent: userAgentFor("ai-sdk"), ref: AI_SDK_REF, ...config }; return { arcBeforeCheckout: { description: BEFORE_CHECKOUT_DESCRIPTION, inputSchema: beforeCheckoutSchema, execute: (args: BeforeCheckoutArgs) => beforeCheckout(args, options), }, arcAfterCheckout: { description: AFTER_CHECKOUT_DESCRIPTION, inputSchema: afterCheckoutSchema, execute: (args: AfterCheckoutArgs) => afterCheckout({ ...args, agent_name: config.agentName ?? "ai-sdk-agent", agent_family: config.agentFamily ?? "ai-sdk" }, options), }, }; }