/* Copyright 2026 Marimo. All rights reserved. */ /* oxlint-disable typescript/no-explicit-any */ import type { ZodType } from "zod"; export type PluginFunction = (args: REQ) => Promise; /** * Functions that can be called from the plugin. */ export type PluginFunctions = Record; // Utility types for extracting schemas from functions. export type ExtractInputSchema = F extends ( args: infer REQ, ) => Promise ? ZodType : never; export type ExtractOutputSchema = F extends ( args: any, ) => Promise ? ZodType : never; /** * Schemas for the plugin functions. */ export type FunctionSchemas = { [K in keyof F]: { /** * Validate the function arguments. */ input: ExtractInputSchema; /** * Validate the function output. */ output: ExtractOutputSchema; }; }; /** * RPC builder for plugin functions. */ export const rpc = { input(inputSchema: ZodType) { return { output(outputSchema: ZodType) { return { input: inputSchema, output: outputSchema, }; }, }; }, };