/** * Component instantiator helpers * * These functions create ComponentInstantiator objects that determine how * components are created when the conductor receives an initialize request. * * ## Instantiation Modes * * - **Static**: Components are determined at construction time (e.g., from a list of commands) * - **Dynamic**: Components are determined at runtime based on the initialize request * * ## Lazy Instantiation * * All instantiators are lazy - components are only spawned when the first * `initialize` request arrives. This allows the conductor to be constructed * before the component processes need to exist. */ import type { ComponentConnector, ComponentInstantiator, InitializeRequest, InstantiatedComponents } from "./types.js"; import type { StdioConnectorOptions } from "./connectors/stdio.js"; /** * Options for a component command */ export interface CommandOptions extends StdioConnectorOptions { } /** * A command specification - either a string or full options */ export type CommandSpec = string | CommandOptions; /** * Static configuration for component instantiation */ export interface StaticInstantiatorConfig { /** Proxy commands to spawn (in order) */ proxies?: CommandSpec[]; /** Agent command to spawn (required) */ agent: CommandSpec; } /** * Create a component instantiator from static command specifications. * * This is the most common way to create an instantiator - provide the * commands for each component and they will be spawned when needed. * * @example * ```ts * // Simple string commands * const instantiator = staticInstantiator({ * proxies: ['sparkle-acp'], * agent: 'claude-agent', * }); * * // With options * const instantiator = staticInstantiator({ * agent: { * command: 'my-agent', * args: ['--mode', 'production'], * env: { DEBUG: 'true' }, * }, * }); * ``` */ export declare function staticInstantiator(config: StaticInstantiatorConfig): ComponentInstantiator; /** * Create a component instantiator from a simple list of commands. * * The last command is treated as the agent, all others as proxies. * This is a convenience wrapper around `staticInstantiator`. * * @example * ```ts * // Single agent (no proxies) * const instantiator = fromCommands(['claude-agent']); * * // Agent with proxies * const instantiator = fromCommands(['sparkle-acp', 'claude-agent']); * ``` */ export declare function fromCommands(commands: CommandSpec[]): ComponentInstantiator; /** * Create a component instantiator from explicit connectors. * * This is useful when you have pre-configured connectors or want to use * in-memory connections for testing. * * @example * ```ts * const instantiator = fromConnectors(agentConnector, [proxyConnector]); * ``` */ export declare function fromConnectors(agent: ComponentConnector, proxies?: ComponentConnector[]): ComponentInstantiator; /** * Factory function type for dynamic instantiation. * * The factory receives the initialize request and returns the components * to instantiate. This allows for runtime decisions about what to spawn. */ export type DynamicInstantiatorFactory = (initRequest: InitializeRequest) => Promise; /** * Create a component instantiator with a dynamic factory function. * * The factory function is called when the first `initialize` request arrives, * allowing you to make decisions about what components to spawn based on * the request content. * * @example * ```ts * const instantiator = dynamic(async (initRequest) => { * // Choose agent based on client capabilities * const capabilities = initRequest.params?.capabilities ?? {}; * const agentCommand = capabilities.advanced ? 'advanced-agent' : 'basic-agent'; * * const { StdioConnector } = await import('./connectors/stdio.js'); * return { * proxies: [], * agent: new StdioConnector(agentCommand), * }; * }); * * // Or use it to inspect MCP servers * const instantiator = dynamic(async (initRequest) => { * const mcpServers = initRequest.params?.mcpServers ?? []; * console.log('Client provided MCP servers:', mcpServers); * * // ... create appropriate components * }); * ``` */ export declare function dynamic(factory: DynamicInstantiatorFactory): ComponentInstantiator; //# sourceMappingURL=instantiators.d.ts.map