UNPKG

@tanstack/ai-code-mode

Version:

Code Mode for TanStack AI - LLM-driven code execution in secure sandboxes

42 lines (41 loc) 1.57 kB
import { CodeModeToolConfig } from './types.js'; /** * Create both the `execute_typescript` tool and its matching system prompt * from a single config object. * * This is the recommended way to set up Code Mode — it ensures the tool and * system prompt always stay in sync. * * @example * ```typescript * import { createCodeMode } from '@tanstack/ai-code-mode' * import { createNodeIsolateDriver } from '@tanstack/ai-isolate-node' * * const { tool, systemPrompt } = createCodeMode({ * driver: createNodeIsolateDriver(), * tools: [weatherTool, dbTool], * timeout: 30000, * }) * * chat({ * systemPrompts: [myPrompt, systemPrompt], * tools: [tool, ...otherTools], * messages, * }) * ``` */ export declare function createCodeMode(config: CodeModeToolConfig): { tool: import('@tanstack/ai').ServerTool<import('zod').ZodObject<{ typescriptCode: import('zod').ZodString; }, import('zod/v4/core').$strip>, import('zod').ZodObject<{ success: import('zod').ZodBoolean; result: import('zod').ZodOptional<import('zod').ZodUnknown>; logs: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodString>>; error: import('zod').ZodOptional<import('zod').ZodObject<{ message: import('zod').ZodString; name: import('zod').ZodOptional<import('zod').ZodString>; line: import('zod').ZodOptional<import('zod').ZodNumber>; }, import('zod/v4/core').$strip>>; }, import('zod/v4/core').$strip>, "execute_typescript">; systemPrompt: string; };