
!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]="06988cc3-a9b5-5cce-8530-b39e5fbd3fa6")}catch(e){}}();
import { ApifyClient } from '../../apify_client.js';
import { getWidgetConfig, WIDGET_URIS } from '../../resources/widgets.js';
import { buildActorNotFoundResponse, buildCardOptions, fetchActorDetails, processActorDetailsForResponse, resolveOutputOptions, } from '../../utils/actor_details.js';
import { buildMCPResponse } from '../../utils/mcp.js';
import { fetchActorDetailsMetadata, fetchActorDetailsToolArgsSchema, } from '../core/fetch_actor_details_common.js';
/**
 * OpenAI mode fetch-actor-details tool.
 * Returns simplified structured content with interactive widget metadata.
 */
export const openaiFetchActorDetails = Object.freeze({
    ...fetchActorDetailsMetadata,
    call: async (toolArgs) => {
        const { args, apifyToken } = 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);
        }
        const { structuredContent: processedStructuredContent, actorUrl } = processActorDetailsForResponse(details);
        const structuredContent = {
            actorInfo: details.actorCardStructured,
            inputSchema: details.inputSchema,
            actorDetails: processedStructuredContent.actorDetails,
        };
        const texts = [`
# Actor information:
- **Actor:** ${parsed.actor}
- **URL:** ${actorUrl}

An interactive widget has been rendered with detailed Actor information.
`];
        const widgetConfig = getWidgetConfig(WIDGET_URIS.SEARCH_ACTORS);
        return buildMCPResponse({
            texts,
            structuredContent,
            // Response-level meta; only returned in openai mode (this handler is openai-only)
            _meta: {
                ...widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.meta,
                'openai/widgetDescription': `Actor details for ${parsed.actor} from Apify Store`,
            },
        });
    },
});
//# sourceMappingURL=fetch_actor_details.js.map
//# debugId=06988cc3-a9b5-5cce-8530-b39e5fbd3fa6
