import { type CatalogModelInfo } from './variant-backfill'; /** v2 `Plugin.define` 的返回形状(不 import @opencode/plugin,保持零运行时依赖) */ export interface V2PluginDefinition { id: string; setup: (ctx: V2Context) => Promise<() => void> | (() => void); } /** * 只读的模型目录视图(仅取我们需要的部分)。 * * 分工:`get` 用于确认模型已存在,`update` 只作用于已存在模型—— * 宿主 `update` 是 upsert,对未知模型调用会创建空模型污染目录。 */ interface CatalogView { model?: { update?(providerID: string, modelID: string, fn: (draft: CatalogModelInfo) => void): void; get?(providerID: string, modelID: string): CatalogModelInfo | undefined; }; } /** 只声明我们真正用到的 v2 上下文能力,避免把宿主类型变成硬依赖 */ interface V2Context { location?: { directory?: string; }; options?: Record; catalog?: { transform(fn: (catalog: CatalogView) => unknown): Promise | unknown; }; agent?: { transform: (fn: (editor: V2AgentEditor) => void) => Promise; }; tool?: { transform: (fn: (editor: V2ToolEditor) => void) => Promise; hook: (name: 'execute.before' | 'execute.after', fn: (input: unknown) => unknown) => Promise; }; session?: { hook: (name: string, fn: (input: unknown) => unknown) => Promise; }; shell?: { hook: (name: 'create.before', fn: (input: unknown) => unknown) => Promise; }; event?: { subscribe: (options?: { types?: readonly string[]; }) => AsyncIterable<{ type?: string; data?: Record; }>; }; permission?: { hook: (name: 'evaluate', fn: (input: unknown) => unknown) => Promise; }; } interface V2AgentEditor { list: () => ReadonlyArray<{ id: string; }>; get: (id: string) => Record | undefined; update: (id: string, fn: (agent: Record) => void) => void; default: (id: string | undefined) => void; } interface V2ToolEditor { list: () => ReadonlyArray<{ id: string; }>; add: (tool: Record) => void; update: (id: string, fn: (tool: Record) => void) => void; } export { buildVariantBody } from './variant-backfill'; /** * 构造 v2 插件定义。 * * 注意 `setup` 里对 v1 工厂的调用是**一次性的**:v1 工厂在调用期间会启动 * 两个定时器(过期任务清理 / 上下文清理),v2 没有对应的 dispose 时机, * 因此把清理函数交给 setup 返回的 cleanup,由宿主在卸载插件时调用。 */ export declare function createV2Plugin(): V2PluginDefinition; declare const _default: V2PluginDefinition; export default _default; //# sourceMappingURL=index.d.ts.map