/** * @file esm-context-factories.ts * @description Factory functions that create context classes for ESM-loaded primitives. * * Unlike remote-mcp context factories (which proxy to a remote MCP server), * these factories create classes that execute code locally in-process. * The ESM module's functions are closed over via closure. */ import { type Type } from '@frontmcp/di'; import type { CallToolResult, GetPromptResult, ReadResourceResult } from '@frontmcp/protocol'; import { PromptContext, ResourceContext, ToolContext, type ToolInputType, type ToolOutputType } from '../../common'; /** * Handler type for ESM tool execution. * This is the execute function exported by the ESM package. */ export type EsmToolExecuteHandler = (input: Record) => Promise; /** * Handler type for ESM resource reading. */ export type EsmResourceReadHandler = (uri: string, params: Record) => Promise; /** * Handler type for ESM prompt execution. */ export type EsmPromptExecuteHandler = (args: Record) => Promise; /** * Creates an ESM tool context class that executes locally in-process. * * The returned class closes over the ESM module's execute function. * When called, it runs the tool handler directly in the same Node.js process. * * @param executeFn - The tool's execute function from the ESM module * @param toolName - The name of the tool (for debugging) * @returns A ToolContext class that executes the ESM tool locally */ export declare function createEsmToolContextClass(executeFn: EsmToolExecuteHandler, toolName: string): Type>; /** * Creates an ESM resource context class that reads locally in-process. * * @param readFn - The resource's read function from the ESM module * @param resourceName - The name of the resource (for debugging) * @returns A ResourceContext class that reads the ESM resource locally */ export declare function createEsmResourceContextClass = Record>(readFn: EsmResourceReadHandler, resourceName: string): Type>; /** * Creates an ESM prompt context class that executes locally in-process. * * @param executeFn - The prompt's execute function from the ESM module * @param promptName - The name of the prompt (for debugging) * @returns A PromptContext class that executes the ESM prompt locally */ export declare function createEsmPromptContextClass(executeFn: EsmPromptExecuteHandler, promptName: string): Type; //# sourceMappingURL=esm-context-factories.d.ts.map