import type { GenerateToolScriptJob, GenerateToolScriptJobOperationResponse, GenerateToolScriptRequest, GenerateToolScriptResponse, GetToolJobResponse, ToolScriptDescriptor, ToolScriptAttachment, ToolScriptInputSchema, RepairGenerateToolScriptRequest, ToolPromptEnhancement } from './types.js'; type UnknownRecord = Record; export type ToolScriptInputMode = 'stdin' | 'file' | 'environment'; export interface ToolGenerationClient { generateToolScript(payload: GenerateToolScriptRequest): Promise; getToolJob(jobId: string): Promise; repairToolScript(payload: RepairGenerateToolScriptRequest): Promise; } export interface GenerateToolScriptParams { client: ToolGenerationClient; sessionId: string; query: string; preferredInputMode?: ToolScriptInputMode; outputFormat?: string; fileNameHint?: string; includeShebang?: boolean; additionalContext?: string; attachments?: ToolScriptAttachment[]; pollIntervalMs?: number; timeoutMs?: number; maxSubmitRetries?: number; submitRetryBackoffMs?: number; signal?: AbortSignal; onJobUpdate?: (job: GenerateToolScriptJob) => void; /** Enables automatic repair attempts for known failure codes (default: true). */ autoRepair?: boolean; /** Maximum number of automatic repair attempts (default: 3). */ maxAutoRepairAttempts?: number; /** Optional context appended to each repair request. */ repairAdditionalContext?: string; /** * Optional custom instruction builder. Return `undefined` to fall back to the * default error-specific instructions. */ repairInstructionBuilder?: ((job: GenerateToolScriptJob) => string | undefined | Promise) | null; /** Callback invoked before a repair attempt is submitted. */ onRepairAttempt?: (attempt: ToolGenerationRepairAttempt) => void; /** Callback invoked after a prompt enhancement has been generated. */ onPromptEnhancement?: (enhancement: ToolPromptEnhancement) => void; } export interface GeneratedToolScript { code: string; language?: string; summary: string; description?: string; descriptor: ToolScriptDescriptor; inputSchema?: ToolScriptInputSchema; expectedOutputDescription?: string | null; suggestedFileName: string; job: GenerateToolScriptJob; initialResponse: GenerateToolScriptJobOperationResponse; result: GenerateToolScriptResponse; repairHistory: ToolGenerationRepairAttempt[]; promptEnhancement?: ToolPromptEnhancement | null; } export declare const MAX_TOOL_SCRIPT_ATTACHMENTS = 4; export declare const MAX_TOOL_SCRIPT_ATTACHMENT_CHARS = 1000000; export declare const MAX_TOOL_SCRIPT_ATTACHMENT_TOTAL_CHARS = 2000000; export declare class ToolGenerationJobFailedError extends Error { readonly job: GenerateToolScriptJob; readonly repairs: ToolGenerationRepairAttempt[]; constructor(job: GenerateToolScriptJob, repairs?: ToolGenerationRepairAttempt[]); } export declare class ToolGenerationJobTimeoutError extends Error { readonly job: GenerateToolScriptJob; constructor(job: GenerateToolScriptJob, timeoutMs: number); } export interface ToolGenerationRepairAttempt { attempt: number; previousJob: GenerateToolScriptJob; repairJob: GenerateToolScriptJob; instructions?: string; } export declare class ToolGenerationRepairLimitReachedError extends Error { readonly job: GenerateToolScriptJob; readonly repairs: ToolGenerationRepairAttempt[]; constructor(job: GenerateToolScriptJob, repairs?: ToolGenerationRepairAttempt[]); } export interface ToolGenerationErrorDetails { code?: string; message?: string; metadata?: UnknownRecord; attempts?: unknown; rawBody: unknown; } export declare function buildToolGenerationPrompt(query: string, options?: { preferredInputMode?: ToolScriptInputMode; outputFormat?: string; includeShebang?: boolean; additionalContext?: string; }): string; export declare function extractPrimaryCodeBlock(value: string): { code: string; language?: string; } | null; export declare function deriveSuggestedFileName(query: string, explicitName?: string): string; export declare function normalizeToolScriptAttachments(attachments?: ToolScriptAttachment[] | null): ToolScriptAttachment[] | undefined; export declare function generateToolScript({ client, sessionId, query, preferredInputMode, outputFormat, fileNameHint, includeShebang, additionalContext, attachments, pollIntervalMs, timeoutMs, maxSubmitRetries, submitRetryBackoffMs, signal, onJobUpdate, autoRepair, maxAutoRepairAttempts, repairAdditionalContext, repairInstructionBuilder, onRepairAttempt, onPromptEnhancement }: GenerateToolScriptParams): Promise; export declare function extractToolGenerationErrorDetails(body: unknown): ToolGenerationErrorDetails | null; export {};