/** * Typed adapters for common Claude Code tool payloads. * * The core hook event schemas intentionally preserve Claude Code's raw wire * format (`tool_input` / `tool_response` as loose records). This module adds a * thin typed layer for the built-in tool shapes documented by Claude Code. * * @since 0.1.0 */ import * as Effect from 'effect/Effect'; import * as Schema from 'effect/Schema'; import { HookToolDecodeError } from '../Errors.js'; import type * as PostToolUse from './Events/PostToolUse.js'; import type * as PreToolUse from './Events/PreToolUse.js'; /** * Typed adapter for decoding a `tool_input` payload. * * @category Models * @since 0.1.0 */ export interface PreToolAdapter { readonly toolName: TName; readonly inputSchema: Schema.Decoder; } /** * Typed adapter for decoding both `tool_input` and `tool_response` payloads. * * @category Models * @since 0.1.0 */ export interface PostToolAdapter extends PreToolAdapter { readonly responseSchema: Schema.Decoder; } /** * Define a typed pre-tool adapter from a schema. * * @category Constructors * @since 0.1.0 */ export declare const definePreAdapter: (config: { readonly toolName: TName; readonly inputSchema: Schema.Decoder; }) => PreToolAdapter; /** * Define a typed post-tool adapter from input / response schemas. * * @category Constructors * @since 0.1.0 */ export declare const definePostAdapter: (config: { readonly toolName: TName; readonly inputSchema: Schema.Decoder; readonly responseSchema: Schema.Decoder; }) => PostToolAdapter; declare const BashToolInput_base: Schema.Class; readonly timeout: Schema.optional; readonly run_in_background: Schema.optional; }>, {}>; /** * Typed `tool_input` payload for the `Bash` tool. * * @category Schemas * @since 0.1.0 */ export declare class BashToolInput extends BashToolInput_base { } declare const BashToolResponse_base: Schema.Class; readonly stderr: Schema.optional; readonly interrupted: Schema.optional; readonly isImage: Schema.optional; }>, {}>; /** * Typed `tool_response` payload for the `Bash` tool. * * @category Schemas * @since 0.1.0 */ export declare class BashToolResponse extends BashToolResponse_base { } declare const ReadToolInput_base: Schema.Class; readonly limit: Schema.optional; }>, {}>; /** * Typed `tool_input` payload for the `Read` tool. * * @category Schemas * @since 0.1.0 */ export declare class ReadToolInput extends ReadToolInput_base { } declare const ReadToolResponse_base: Schema.Class; }>, {}>; /** * Typed `tool_response` payload for the `Read` tool. * * @category Schemas * @since 0.1.0 */ export declare class ReadToolResponse extends ReadToolResponse_base { } declare const WriteToolInput_base: Schema.Class, {}>; /** * Typed `tool_input` payload for the `Write` tool. * * @category Schemas * @since 0.1.0 */ export declare class WriteToolInput extends WriteToolInput_base { } declare const EditToolInput_base: Schema.Class; }>, {}>; /** * Typed `tool_input` payload for the `Edit` tool. * * @category Schemas * @since 0.1.0 */ export declare class EditToolInput extends EditToolInput_base { } declare const GlobToolInput_base: Schema.Class; }>, {}>; /** * Typed `tool_input` payload for the `Glob` tool. * * @category Schemas * @since 0.1.0 */ export declare class GlobToolInput extends GlobToolInput_base { } export declare const GrepOutputMode: Schema.Literals; declare const GrepToolInput_base: Schema.Class; readonly glob: Schema.optional; readonly output_mode: Schema.optional>; readonly '-i': Schema.optional; readonly multiline: Schema.optional; }>, {}>; /** * Typed `tool_input` payload for the `Grep` tool. * * @category Schemas * @since 0.1.0 */ export declare class GrepToolInput extends GrepToolInput_base { } declare const WebFetchToolInput_base: Schema.Class, {}>; /** * Typed `tool_input` payload for the `WebFetch` tool. * * @category Schemas * @since 0.1.0 */ export declare class WebFetchToolInput extends WebFetchToolInput_base { } declare const WebSearchToolInput_base: Schema.Class>; readonly blocked_domains: Schema.optional>; }>, {}>; /** * Typed `tool_input` payload for the `WebSearch` tool. * * @category Schemas * @since 0.1.0 */ export declare class WebSearchToolInput extends WebSearchToolInput_base { } declare const AgentToolInput_base: Schema.Class; }>, {}>; /** * Typed `tool_input` payload for the `Agent` tool. * * @category Schemas * @since 0.1.0 */ export declare class AgentToolInput extends AgentToolInput_base { } declare const AgentToolResponse_base: Schema.Class>; readonly agentId: Schema.optional; readonly content: Schema.optional>; readonly totalTokens: Schema.optional; readonly totalDurationMs: Schema.optional; readonly totalToolUseCount: Schema.optional; readonly usage: Schema.optional>; readonly description: Schema.optional; readonly prompt: Schema.optional; readonly outputFile: Schema.optional; }>, {}>; /** * Typed `tool_response` payload for the `Agent` tool. * * @category Schemas * @since 0.1.0 */ export declare class AgentToolResponse extends AgentToolResponse_base { } declare const AskUserQuestionOption_base: Schema.Class; }>, {}>; /** * A single option for the `AskUserQuestion` tool. * * @category Schemas * @since 0.1.0 */ export declare class AskUserQuestionOption extends AskUserQuestionOption_base { } declare const AskUserQuestionQuestion_base: Schema.Class; readonly multiSelect: Schema.optional; }>, {}>; /** * A single question for the `AskUserQuestion` tool. * * @category Schemas * @since 0.1.0 */ export declare class AskUserQuestionQuestion extends AskUserQuestionQuestion_base { } declare const AskUserQuestionToolInput_base: Schema.Class; readonly answers: Schema.optional>; }>, {}>; /** * Typed `tool_input` payload for the `AskUserQuestion` tool. * * @category Schemas * @since 0.1.0 */ export declare class AskUserQuestionToolInput extends AskUserQuestionToolInput_base { } declare const ExitPlanAllowedPrompt_base: Schema.Class, {}>; /** * A prompt-based permission request in `ExitPlanMode`. * * @category Schemas * @since 0.1.0 */ export declare class ExitPlanAllowedPrompt extends ExitPlanAllowedPrompt_base { } declare const ExitPlanModeToolInput_base: Schema.Class>; }>, {}>; /** * Typed `tool_input` payload for the `ExitPlanMode` tool. * * @category Schemas * @since 0.1.0 */ export declare class ExitPlanModeToolInput extends ExitPlanModeToolInput_base { } declare const ExitPlanModeToolResponse_base: Schema.Class; readonly filePath: Schema.optional; readonly approved: Schema.optional; }>, {}>; /** * Typed `tool_response` payload for the `ExitPlanMode` tool. * * @category Schemas * @since 0.1.0 */ export declare class ExitPlanModeToolResponse extends ExitPlanModeToolResponse_base { } /** * Built-in adapter for the `Bash` tool. * * @category Adapters * @since 0.1.0 */ export declare const BashAdapter: PostToolAdapter<"Bash", BashToolInput, BashToolResponse>; /** * Built-in adapter for the `Read` tool. * * @category Adapters * @since 0.1.0 */ export declare const ReadAdapter: PostToolAdapter<"Read", ReadToolInput, ReadToolResponse>; /** * Built-in adapter for the `Write` tool. * * @category Adapters * @since 0.1.0 */ export declare const WriteAdapter: PostToolAdapter<"Write", WriteToolInput, unknown>; /** * Built-in adapter for the `Edit` tool. * * @category Adapters * @since 0.1.0 */ export declare const EditAdapter: PostToolAdapter<"Edit", EditToolInput, unknown>; /** * Built-in adapter for the `Glob` tool. * * @category Adapters * @since 0.1.0 */ export declare const GlobAdapter: PostToolAdapter<"Glob", GlobToolInput, unknown>; /** * Built-in adapter for the `Grep` tool. * * @category Adapters * @since 0.1.0 */ export declare const GrepAdapter: PostToolAdapter<"Grep", GrepToolInput, unknown>; /** * Built-in adapter for the `WebFetch` tool. * * @category Adapters * @since 0.1.0 */ export declare const WebFetchAdapter: PostToolAdapter<"WebFetch", WebFetchToolInput, unknown>; /** * Built-in adapter for the `WebSearch` tool. * * @category Adapters * @since 0.1.0 */ export declare const WebSearchAdapter: PostToolAdapter<"WebSearch", WebSearchToolInput, unknown>; /** * Built-in adapter for the `Agent` tool. * * @category Adapters * @since 0.1.0 */ export declare const AgentAdapter: PostToolAdapter<"Agent", AgentToolInput, AgentToolResponse>; /** * Built-in adapter for the `AskUserQuestion` tool. * * @category Adapters * @since 0.1.0 */ export declare const AskUserQuestionAdapter: PostToolAdapter<"AskUserQuestion", AskUserQuestionToolInput, unknown>; /** * Built-in adapter for the `ExitPlanMode` tool. * * @category Adapters * @since 0.1.0 */ export declare const ExitPlanModeAdapter: PostToolAdapter<"ExitPlanMode", ExitPlanModeToolInput, ExitPlanModeToolResponse>; /** * Tool names with built-in typed adapters. * * @category Schemas * @since 0.1.0 */ export declare const SupportedToolName: Schema.Literals; export type SupportedToolName = typeof SupportedToolName.Type; interface PreToolTypeMap { readonly Bash: BashToolInput; readonly Read: ReadToolInput; readonly Write: WriteToolInput; readonly Edit: EditToolInput; readonly Glob: GlobToolInput; readonly Grep: GrepToolInput; readonly WebFetch: WebFetchToolInput; readonly WebSearch: WebSearchToolInput; readonly Agent: AgentToolInput; readonly AskUserQuestion: AskUserQuestionToolInput; readonly ExitPlanMode: ExitPlanModeToolInput; } interface PostToolTypeMap { readonly Bash: { readonly tool: BashToolInput; readonly response: BashToolResponse; }; readonly Read: { readonly tool: ReadToolInput; readonly response: ReadToolResponse; }; readonly Write: { readonly tool: WriteToolInput; readonly response: unknown; }; readonly Edit: { readonly tool: EditToolInput; readonly response: unknown; }; readonly Glob: { readonly tool: GlobToolInput; readonly response: unknown; }; readonly Grep: { readonly tool: GrepToolInput; readonly response: unknown; }; readonly WebFetch: { readonly tool: WebFetchToolInput; readonly response: unknown; }; readonly WebSearch: { readonly tool: WebSearchToolInput; readonly response: unknown; }; readonly Agent: { readonly tool: AgentToolInput; readonly response: AgentToolResponse; }; readonly AskUserQuestion: { readonly tool: AskUserQuestionToolInput; readonly response: unknown; }; readonly ExitPlanMode: { readonly tool: ExitPlanModeToolInput; readonly response: ExitPlanModeToolResponse; }; } /** * Decoded typed view over a `PreToolUse` payload. * * @category Models * @since 0.1.0 */ export type DecodedPreToolUseWith = { readonly input: PreToolUse.Input; readonly tool: TTool; }; /** * Decoded typed view over a built-in `PreToolUse` payload. * * @category Models * @since 0.1.0 */ export type DecodedPreToolUse = DecodedPreToolUseWith; /** * Decoded typed view over a `PostToolUse` payload. * * @category Models * @since 0.1.0 */ export type DecodedPostToolUseWith = { readonly input: PostToolUse.Input; readonly tool: TTool; readonly response: TResponse; }; /** * Decoded typed view over a built-in `PostToolUse` payload. * * @category Models * @since 0.1.0 */ export type DecodedPostToolUse = DecodedPostToolUseWith; /** * Decode a `PreToolUse` payload with a custom adapter. * * @category Decoding * @since 0.1.0 */ export declare const decodePreToolUseWith: (adapter: PreToolAdapter, input: PreToolUse.Input) => Effect.Effect, HookToolDecodeError>; /** * Decode a `PostToolUse` payload with a custom adapter. * * @category Decoding * @since 0.1.0 */ export declare const decodePostToolUseWith: (adapter: PostToolAdapter, input: PostToolUse.Input) => Effect.Effect, HookToolDecodeError>; /** * Decode the typed payload for a supported `PreToolUse` tool event. * * @category Decoding * @since 0.1.0 */ export declare const decodePreToolUse: (toolName: T, input: PreToolUse.Input) => Effect.Effect, HookToolDecodeError>; /** * Decode the typed payload for a supported `PostToolUse` tool event. * * @category Decoding * @since 0.1.0 */ export declare const decodePostToolUse: (toolName: T, input: PostToolUse.Input) => Effect.Effect, HookToolDecodeError>; export {}; //# sourceMappingURL=Tool.d.ts.map