import { ApifyApiError } from 'apify-client';
import { z } from 'zod';
import { HelperTools } from '../../const.js';
import type { InternalToolArgs, ToolInputSchema } from '../../types.js';
import { buildMCPResponse } from '../../utils/mcp.js';
import { getActorsAsTools } from './actor_tools_factory.js';
export declare const CALL_ACTOR_MCP_MISSING_TOOL_NAME_MSG = "When calling an MCP server Actor, you must specify the tool name in the actor parameter as \"{actorName}:{toolName}\" in the \"actor\" input property.";
/** Shared MCP server instructions — identical in both modes. */
export declare const CALL_ACTOR_MCP_SERVER_SECTION = "For MCP server Actors:\n- Use fetch-actor-details with output={ mcpTools: true } to list available tools\n- Call using format: \"actorName:toolName\" (e.g., \"apify/actors-mcp-server:fetch-apify-docs\")";
/** Shared "two ways to run" + USAGE section — identical in both modes. */
export declare const CALL_ACTOR_USAGE_SECTION: string;
/** Shared examples section — identical in both modes. */
export declare const CALL_ACTOR_EXAMPLES_SECTION = "EXAMPLES:\n- user_input: Get instagram posts using apify/instagram-scraper";
type CallActorDescriptionParams = {
    actorGetDetailsTool: HelperTools.ACTOR_GET_DETAILS;
    alwaysAsync: boolean;
};
type StartedActorRun = {
    id: string;
    status: string;
    startedAt?: Date;
};
type StartAsyncResponseResult = {
    content: {
        type: 'text';
        text: string;
    }[];
    structuredContent: {
        runId: string;
        actorName: string;
        status: string;
        startedAt: string;
        input: Record<string, unknown>;
    };
    _meta?: Record<string, unknown>;
};
type CallActorErrorResponseParams = {
    actorName: string;
    error: unknown;
    actorId?: string;
    isAsync: boolean;
    mcpSessionId?: string;
    actorGetDetailsTool: HelperTools.ACTOR_GET_DETAILS;
};
export declare function buildCallActorDescription(params: CallActorDescriptionParams): string;
export declare function buildStartAsyncResponse(params: {
    actorName: string;
    actorRun: StartedActorRun;
    input: Record<string, unknown>;
    widget: boolean;
}): StartAsyncResponseResult;
export declare function isPermissionApprovalError(error: unknown): error is ApifyApiError;
/** Exported for native actor tool error handling in server.ts — no logging, no telemetry. */
export declare function buildPermissionApprovalResponse(error: ApifyApiError): ReturnType<typeof buildMCPResponse>;
export declare function buildCallActorErrorResponse(params: CallActorErrorResponseParams): ReturnType<typeof buildMCPResponse>;
/**
 * Zod schema for call-actor arguments — shared between default and apps variants.
 */
export declare const callActorArgs: z.ZodObject<{
    actor: z.ZodString;
    input: z.ZodObject<{}, z.core.$loose>;
    async: z.ZodOptional<z.ZodBoolean>;
    previewOutput: z.ZodOptional<z.ZodBoolean>;
    callOptions: z.ZodOptional<z.ZodObject<{
        memory: z.ZodOptional<z.ZodNumber>;
        timeout: z.ZodOptional<z.ZodNumber>;
    }, z.core.$strip>>;
}, z.core.$strip>;
/**
 * Compiled AJV input schema — shared between both variants.
 */
export declare const callActorInputSchema: ToolInputSchema;
export declare const callActorAjvValidate: import("ajv").ValidateFunction<unknown>;
/**
 * Parsed call-actor arguments.
 */
export type CallActorParsedArgs = z.infer<typeof callActorArgs>;
/**
 * Resolves MCP URL and parses the "actor:tool" format.
 * Shared pre-processing step used by both default and apps variants.
 */
export declare function resolveActorContext(actorName: string): {
    baseActorName: string;
    mcpToolName: string | undefined;
};
/**
 * Handles the MCP tool call flow (when actorName contains ":toolName").
 * Returns a response if handled, or null if this is not an MCP tool call.
 */
export declare function handleMcpToolCall(params: {
    baseActorName: string;
    mcpToolName: string;
    input: Record<string, unknown>;
    isActorMcpServer: boolean;
    mcpServerUrl: string | false;
    apifyToken: string;
    mcpSessionId?: string;
}): Promise<object | null>;
/**
 * Validates the actor and its input, returning the resolved actor tool or an error response.
 * Shared validation logic used by both default and openai execution paths.
 */
export declare function resolveAndValidateActor(params: {
    actorName: string;
    input: Record<string, unknown>;
    toolArgs: InternalToolArgs;
}): Promise<{
    error: object;
} | {
    actor: Awaited<ReturnType<typeof getActorsAsTools>>[0];
}>;
/**
 * Performs the pre-execution checks common to both modes:
 * - Parses args
 * - Resolves actor/MCP context
 * - Handles payment provider restrictions
 * - Handles MCP tool calls
 *
 * Returns either an early response (error or MCP tool result) or the parsed context for mode-specific execution.
 *
 * Applies the same `actor` string normalization as `getActorsAsTools` **before** MCP URL lookup and routing so
 * clients cannot pass a clean-enough id for definition fetch but a dirty id to `apifyClient.actor()` (see Mezmo:
 * e.g. trailing `` ` `` on `apify/rag-web-browser`).
 */
export declare function callActorPreExecute(toolArgs: InternalToolArgs, options: {
    route: string;
}): Promise<{
    earlyResponse: object;
} | {
    parsed: CallActorParsedArgs;
    baseActorName: string;
    mcpToolName: string | undefined;
}>;
export {};
//# sourceMappingURL=call_actor_common.d.ts.map