import type { AskUserQuestion, CapabilityRequest, ThreadEvidenceRecord, ThreadId, ThreadMetadata, ToolApprovalClass, ToolConflictStrategy, ToolEffect, ToolExpectedDurationClass, ToolExecutionClass, ToolHeartbeatPolicy, ToolInputValue, ToolReplayPolicy, ToolResultEnvelope, ToolSummary, TurnId, SandboxProfile } from "@best-agent/protocol";
import type { ThreadStore } from "../core/thread-store.js";
import type { LocalSandbox } from "../sandbox/local-sandbox.js";
import type { ZodToolInputSchema } from "./schema-types.js";
/** Plain JSON Schema object used by legacy / test tool definitions. */
export interface ToolInputJsonSchema {
    additionalProperties?: boolean;
    enum?: ToolInputValue[];
    items?: ToolInputJsonSchema;
    properties?: Record<string, ToolInputJsonSchema>;
    required?: string[];
    type?: "array" | "boolean" | "integer" | "number" | "object" | "string" | Array<"array" | "boolean" | "integer" | "number" | "object" | "string">;
}
type WebSearchInput = {
    domains?: string[];
    limit: number;
    query: string;
    recency_days?: number;
};
export interface ToolExecutionResultMetadata {
    envelope?: Partial<ToolResultEnvelope>;
    forceTracePersistence?: boolean;
    outputManaged?: boolean;
    structuredContent?: ThreadMetadata;
    traceOutput?: string;
}
export interface ToolExecutionContext {
    abortSignal?: AbortSignal;
    assertWorkspaceMutationAllowed(path: string): void;
    cwd: string;
    heartbeat(): void;
    promoteWorkspaceWrite(path: string): void;
    reportOutput?(output: {
        stream: "stderr" | "stdout";
        text: string;
    }): void;
    recordWorkspaceRead(path: string): void;
    sandbox: LocalSandbox;
    sandboxProfile?: SandboxProfile;
    setResultMetadata?(metadata: ToolExecutionResultMetadata): void;
    store: ThreadStore;
    threadId: ThreadId;
    threadPaths: {
        artifactsDir: string;
        memoryDir: string;
        scratchDir: string;
        threadDir: string;
    };
    toolInputMode?: ToolInputMode;
    turnId: TurnId;
    webSearch?(input: WebSearchInput): Promise<string>;
    webSearchBudget?: {
        currentCount: number;
        limit: number;
        scope: "workflow";
    };
    withWorkspaceWriteLocks<T>(paths: string[], action: () => Promise<T>): Promise<T>;
}
export type ToolEvidenceRecord = Partial<ThreadEvidenceRecord>;
export type ToolInputMode = "strict" | "legacy";
/** Upper bound for TInput on ToolDefinition.
 *  Uses `Record<string, unknown>` alongside ToolInputValue so that types
 *  referencing protocol interfaces (which lack implicit index signatures)
 *  still satisfy the constraint. */
export type ToolInputBase = ToolInputValue | Record<string, unknown>;
export interface ToolDefinition<TInput extends ToolInputBase = ToolInputValue> {
    approvalClass?: ToolApprovalClass;
    capabilities(input: TInput, context: ToolExecutionContext): Promise<CapabilityRequest[]> | CapabilityRequest[];
    concurrencyGroup?: string;
    description: string;
    effect?: ToolEffect;
    evidenceExtractor?(input: TInput, output: string, envelope: ToolResultEnvelope): ToolEvidenceRecord[] | Promise<ToolEvidenceRecord[]>;
    execute(input: TInput, context: ToolExecutionContext): Promise<string> | string;
    executionClass: ToolExecutionClass;
    expectedDurationClass?: ToolExpectedDurationClass;
    formatInput?(input: TInput): string;
    heartbeatPolicy?: ToolHeartbeatPolicy;
    idempotent: boolean;
    historyInput?(input: TInput): ToolInputValue | undefined;
    /** Schema that validates and produces TInput.
     *  In strict mode the Zod schema is the sole authority.
     *  In legacy mode the legacyAdapter transforms wire input first, then the
     *  schema validates the adapted result.  Use ToolInputJsonSchema when no
     *  Zod parsing is needed. */
    inputSchema: ZodToolInputSchema<TInput> | ToolInputJsonSchema;
    isContentBearingInput?(input: TInput): boolean;
    /** Only used when context.toolInputMode is "legacy". Tool definitions cannot opt normal provider execution into legacy mode. */
    legacyAdapter?: ToolInputAdapter<TInput>;
    name: string;
    providerHistoryInput?(input: TInput): ToolInputValue;
    replayPolicy?: ToolReplayPolicy;
    resultEnvelope?(input: TInput, output: string): Partial<ToolResultEnvelope>;
    source: ToolSummary["source"];
    sourceExtension?: string;
    sourcePlugin?: string;
    sourceServer?: string;
    summarize?(input: TInput, output: string): string;
}
export interface RuntimeToolDefinition {
    approvalClass?: ToolApprovalClass;
    capabilities(input: ToolInputValue, context: ToolExecutionContext): Promise<CapabilityRequest[]> | CapabilityRequest[];
    concurrencyGroup?: string;
    description: string;
    effect: ToolEffect;
    evidenceExtractor?(input: ToolInputValue, output: string, envelope: ToolResultEnvelope): ToolEvidenceRecord[] | Promise<ToolEvidenceRecord[]>;
    execute(input: ToolInputValue, context: ToolExecutionContext): Promise<string> | string;
    executionClass: ToolExecutionClass;
    expectedDurationClass?: ToolExpectedDurationClass;
    formatInput?(input: ToolInputValue): string;
    heartbeatPolicy?: ToolHeartbeatPolicy;
    idempotent: boolean;
    historyInput?(input: ToolInputValue): ToolInputValue | undefined;
    inputSchema: unknown;
    isContentBearingInput?(input: ToolInputValue): boolean;
    name: string;
    parse(input: ToolInputValue, context: ToolExecutionContext): Promise<ToolInputValue>;
    providerHistoryInput?(input: ToolInputValue): ToolInputValue;
    replayPolicy?: ToolReplayPolicy;
    resultEnvelope?(input: ToolInputValue, output: string): Partial<ToolResultEnvelope>;
    source: ToolSummary["source"];
    sourceExtension?: string;
    sourcePlugin?: string;
    sourceServer?: string;
    summarize?(input: ToolInputValue, output: string): string;
}
/** Runtime storage/view of a tool definition for registry boundaries. */
export type AnyToolDefinition = RuntimeToolDefinition;
export interface ToolInputAdapter<TInput = ToolInputValue> {
    adapt(input: ToolInputValue, context: ToolExecutionContext): Promise<TInput> | TInput;
}
export type NormalizedAskUserInput = {
    questions: AskUserQuestion[];
};
export interface ToolRegistryOptions {
    conflictStrategy?: ToolConflictStrategy;
}
export {};
//# sourceMappingURL=contracts.d.ts.map