export type NativeToolInput = Record; export type NativeToolProcessOptions = { command: string; args?: string[]; cwd?: string; env?: Record; allowNonZeroExit?: boolean; }; export type NativeToolProcessResult = { exitCode: number; stdout: string; stderr: string; }; export type NativeToolProgress = { message: string; channel?: string; }; export type NativeToolContentPart = | { type: 'text'; text: string } | { type: 'json'; value: unknown } | { type: 'image'; data: string; mediaType: string }; export type NativeToolRichResult = { content: NativeToolContentPart[]; structuredContent?: unknown; }; export type NativeToolContext = { protocolVersion: 1; projectRoot: string; pluginDir: string; toolName: string; signal: AbortSignal; workspace: { readText(path: string): Promise; writeText(path: string, content: string): Promise; exists(path: string): Promise; }; process: { run(options: NativeToolProcessOptions): Promise; }; progress(update: string | NativeToolProgress): void; secrets: { get(name: string): string | null; }; storage: { get(key: string): Promise; set(key: string, value: unknown): Promise; delete(key: string): Promise; }; output: { image(path: string, mediaType?: string): Promise; }; }; export type NativeToolHandler< Input extends NativeToolInput = NativeToolInput, Output = unknown, > = (input: Input, context: NativeToolContext) => Output | Promise; export type NativeToolModule = | NativeToolHandler | { execute: NativeToolHandler };