import z from "zod";
import { createToolFactory, ToolCategory } from "../../tools2/types.js";
import { executeRequest } from "./internal.js";
export const runCodeToolFactory = createToolFactory("runCode", (clark) => {
    return {
        category: ToolCategory.GENERAL,
        description: `
      Use this tool to execute Python or JavaScript code in configured code execution integrations.

      IMPORTANT: Only read-only operations are supported. Do NOT use this tool for any operations that modify data or have side effects.

      Response data is returned as a JSON object
`,
        inputSchema: z.object({
            integrationId: z
                .string()
                .min(1)
                .describe("The ID of the code execution integration"),
            script: z
                .string()
                .min(1)
                .describe("The Python or JavaScript code to execute"),
        }),
        execute: async (params) => {
            const { integrationId, script } = params;
            const request = { body: script };
            return await executeRequest(clark.context, integrationId, request);
        },
        readOnly: true,
        getSummary: (input) => {
            const scriptPreview = input.script.length > 50
                ? input.script.substring(0, 50) + "..."
                : input.script;
            return {
                input: `script: ${scriptPreview}`,
                output: "Code executed",
            };
        },
    };
});
//# sourceMappingURL=run-code.js.map