
!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]="72ac2ffb-f92d-5644-bd83-7f9701f4f37f")}catch(e){}}();
import { createApifyClientWithSkyfireSupport } from '../../apify_client.js';
import { TOOL_STATUS } from '../../const.js';
import { logHttpError } from '../../utils/logging.js';
import { buildMCPResponse, buildUsageMeta } from '../../utils/mcp.js';
import { fetchActorRunData, getActorRunArgs, getActorRunMetadata, } from '../core/get_actor_run_common.js';
/**
 * Default mode get-actor-run tool.
 * Returns full JSON dump of the run without widget metadata.
 */
export const defaultGetActorRun = Object.freeze({
    ...getActorRunMetadata,
    call: async (toolArgs) => {
        const { args, apifyToken, apifyMcpServer, mcpSessionId } = toolArgs;
        const parsed = getActorRunArgs.parse(args);
        const client = createApifyClientWithSkyfireSupport(apifyMcpServer, args, apifyToken);
        try {
            const fetchResult = await fetchActorRunData({
                runId: parsed.runId,
                client,
                mcpSessionId,
            });
            if ('error' in fetchResult) {
                return fetchResult.error;
            }
            const { run, structuredContent } = fetchResult.result;
            const texts = [
                `# Actor Run Information\n\`\`\`json\n${JSON.stringify(run, null, 2)}\n\`\`\``,
            ];
            return buildMCPResponse({
                texts,
                structuredContent,
                _meta: buildUsageMeta(run),
            });
        }
        catch (error) {
            logHttpError(error, 'Failed to get Actor run', { runId: parsed.runId });
            return buildMCPResponse({
                texts: [`Failed to get Actor run '${parsed.runId}': ${error instanceof Error ? error.message : String(error)}.
Please verify the run ID and ensure that the run exists.`],
                isError: true,
                toolStatus: TOOL_STATUS.SOFT_FAIL,
            });
        }
    },
});
//# sourceMappingURL=get_actor_run.js.map
//# debugId=72ac2ffb-f92d-5644-bd83-7f9701f4f37f
