/** * local-llm-server 入口。 * * 两种运行模式: * 1. 子进程模式(--child):直接加载模型并启动 HTTP 服务,由主进程 fork 调用。 * 2. 主进程模式(默认导出):fork 子进程,管理其生命周期,提供 baseUrl 给调用方。 * * 主进程通过 startLocalLlmServer() 启动,返回 { baseUrl, stop }。 * 子进程就绪后通过 IPC 发送 { type: "ready" } 通知主进程。 */ export interface LocalLlmServerOptions { port?: number; llmModelPath?: string; embeddingModelPath?: string; /** 上下文窗口 token 数,默认 32768(32K),需能容纳 system + tools + 对话;显存不足时在智能体配置中调小 */ contextSize?: number; /** 等待子进程就绪的超时毫秒数,默认 300000(5 分钟,冷启/大模型加载可能较慢) */ readyTimeoutMs?: number; } export interface LocalLlmServerHandle { baseUrl: string; stop: () => void; } /** * 停止本地 LLM 子进程服务(若正在运行)。用于切换模型前先停止再启动。 */ export declare function stopLocalLlmServer(): void; /** * 启动本地 LLM 子进程服务。 * 已启动时直接返回已有 handle(单例)。需先 stop 再传新参数重启。 */ export declare function startLocalLlmServer(opts?: LocalLlmServerOptions): Promise;