
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cf8ec6d6-210f-5f95-b2ee-76f05b58597d")}catch(e){}}();
import { ApifyClient } from '../../apify_client.js';
import { buildActorDetailsTextResponse, buildActorNotFoundResponse, buildCardOptions, fetchActorDetails, resolveOutputOptions, } from '../../utils/actor_details.js';
import { buildMCPResponse } from '../../utils/mcp.js';
import { fetchActorDetailsMetadata, fetchActorDetailsToolArgsSchema, } from '../core/fetch_actor_details_common.js';
/**
 * Default mode fetch-actor-details tool.
 * Returns full text response with output schema fetch.
 */
export const defaultFetchActorDetails = Object.freeze({
    ...fetchActorDetailsMetadata,
    call: async (toolArgs) => {
        var _a;
        const { args, apifyToken, apifyMcpServer, mcpSessionId } = toolArgs;
        const parsed = fetchActorDetailsToolArgsSchema.parse(args);
        const apifyClient = new ApifyClient({ token: apifyToken });
        const resolvedOutput = resolveOutputOptions(parsed.output);
        const cardOptions = buildCardOptions(resolvedOutput);
        const details = await fetchActorDetails(apifyClient, parsed.actor, cardOptions);
        if (!details) {
            return buildActorNotFoundResponse(parsed.actor);
        }
        // Fetch output schema from ActorStore if available and requested
        const actorOutputSchema = resolvedOutput.outputSchema
            ? await ((_a = apifyMcpServer.actorStore) === null || _a === void 0 ? void 0 : _a.getActorOutputSchemaAsTypeObject(parsed.actor).catch(() => null))
            : undefined;
        // NOTE: Data duplication between texts and structuredContent is intentional and required.
        // Some MCP clients only read text content, while others only read structured content.
        const { texts, structuredContent: responseStructuredContent } = await buildActorDetailsTextResponse({
            actorName: parsed.actor,
            details,
            output: resolvedOutput,
            cardOptions,
            apifyClient,
            apifyToken,
            actorOutputSchema,
            skyfireMode: apifyMcpServer === null || apifyMcpServer === void 0 ? void 0 : apifyMcpServer.options.skyfireMode,
            mcpSessionId,
        });
        return buildMCPResponse({ texts, structuredContent: responseStructuredContent });
    },
});
//# sourceMappingURL=fetch_actor_details.js.map
//# debugId=cf8ec6d6-210f-5f95-b2ee-76f05b58597d
