import type { ImageContent, TextContent } from "@earendil-works/pi-ai/compat";
import type { EditToolDetails } from "../tools/edit.ts";
import type { BashToolDetails, BashToolInput, EditToolInput, FindToolDetails, FindToolInput, LsToolDetails, LsToolInput, ReadToolDetails, ReadToolInput, SearchToolDetails, SearchToolInput, WriteToolInput } from "../tools/index.ts";
interface ToolCallEventBase {
    type: "tool_call";
    toolCallId: string;
}
export interface BashToolCallEvent extends ToolCallEventBase {
    toolName: "bash";
    input: BashToolInput;
}
export interface ReadToolCallEvent extends ToolCallEventBase {
    toolName: "read";
    input: ReadToolInput;
}
export interface EditToolCallEvent extends ToolCallEventBase {
    toolName: "edit";
    input: EditToolInput;
}
export interface WriteToolCallEvent extends ToolCallEventBase {
    toolName: "write";
    input: WriteToolInput;
}
export interface FindToolCallEvent extends ToolCallEventBase {
    toolName: "find";
    input: FindToolInput;
}
export interface SearchToolCallEvent extends ToolCallEventBase {
    toolName: "search";
    input: SearchToolInput;
}
export interface LsToolCallEvent extends ToolCallEventBase {
    toolName: "ls";
    input: LsToolInput;
}
export interface CustomToolCallEvent extends ToolCallEventBase {
    toolName: string;
    input: Record<string, unknown>;
}
/**
 * Fired before a tool executes. Can block.
 *
 * `event.input` is mutable. Mutate it in place to patch tool arguments before execution.
 * Later `tool_call` handlers see earlier mutations. No re-validation is performed after mutation.
 */
export type ToolCallEvent = BashToolCallEvent | ReadToolCallEvent | EditToolCallEvent | WriteToolCallEvent | FindToolCallEvent | SearchToolCallEvent | LsToolCallEvent | CustomToolCallEvent;
interface ToolResultEventBase {
    type: "tool_result";
    toolCallId: string;
    input: Record<string, unknown>;
    content: (TextContent | ImageContent)[];
    isError: boolean;
}
export interface BashToolResultEvent extends ToolResultEventBase {
    toolName: "bash";
    details: BashToolDetails | undefined;
}
export interface ReadToolResultEvent extends ToolResultEventBase {
    toolName: "read";
    details: ReadToolDetails | undefined;
}
export interface EditToolResultEvent extends ToolResultEventBase {
    toolName: "edit";
    details: EditToolDetails | undefined;
}
export interface WriteToolResultEvent extends ToolResultEventBase {
    toolName: "write";
    details: undefined;
}
export interface FindToolResultEvent extends ToolResultEventBase {
    toolName: "find";
    details: FindToolDetails | undefined;
}
export interface SearchToolResultEvent extends ToolResultEventBase {
    toolName: "search";
    details: SearchToolDetails | undefined;
}
export interface LsToolResultEvent extends ToolResultEventBase {
    toolName: "ls";
    details: LsToolDetails | undefined;
}
export interface CustomToolResultEvent extends ToolResultEventBase {
    toolName: string;
    details: unknown;
}
/** Fired after a tool executes. Can modify result. */
export type ToolResultEvent = BashToolResultEvent | ReadToolResultEvent | EditToolResultEvent | WriteToolResultEvent | FindToolResultEvent | SearchToolResultEvent | LsToolResultEvent | CustomToolResultEvent;
export declare function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent;
export declare function isReadToolResult(e: ToolResultEvent): e is ReadToolResultEvent;
export declare function isEditToolResult(e: ToolResultEvent): e is EditToolResultEvent;
export declare function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent;
export declare function isFindToolResult(e: ToolResultEvent): e is FindToolResultEvent;
export declare function isSearchToolResult(e: ToolResultEvent): e is SearchToolResultEvent;
export declare function isLsToolResult(e: ToolResultEvent): e is LsToolResultEvent;
/**
 * Type guard for narrowing ToolCallEvent by tool name.
 *
 * Built-in tools narrow automatically (no type params needed):
 * ```ts
 * if (isToolCallEventType("bash", event)) {
 *   event.input.command;  // string
 * }
 * ```
 *
 * Custom tools require explicit type parameters:
 * ```ts
 * if (isToolCallEventType<"my_tool", MyToolInput>("my_tool", event)) {
 *   event.input.action;  // typed
 * }
 * ```
 *
 * Note: Direct narrowing via `event.toolName === "bash"` doesn't work because
 * CustomToolCallEvent.toolName is `string` which overlaps with all literals.
 */
export declare function isToolCallEventType(toolName: "bash", event: ToolCallEvent): event is BashToolCallEvent;
export declare function isToolCallEventType(toolName: "read", event: ToolCallEvent): event is ReadToolCallEvent;
export declare function isToolCallEventType(toolName: "edit", event: ToolCallEvent): event is EditToolCallEvent;
export declare function isToolCallEventType(toolName: "write", event: ToolCallEvent): event is WriteToolCallEvent;
export declare function isToolCallEventType(toolName: "find", event: ToolCallEvent): event is FindToolCallEvent;
export declare function isToolCallEventType(toolName: "search", event: ToolCallEvent): event is SearchToolCallEvent;
export declare function isToolCallEventType(toolName: "ls", event: ToolCallEvent): event is LsToolCallEvent;
export declare function isToolCallEventType<TName extends string, TInput extends Record<string, unknown>>(toolName: TName, event: ToolCallEvent): event is ToolCallEvent & {
    toolName: TName;
    input: TInput;
};
export {};
//# sourceMappingURL=tool-events.d.ts.map