
!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]="e7ac7620-f017-5d6f-930d-3ac7ca1a25d4")}catch(e){}}();
import { parse } from 'node:querystring';
import { processInput } from '../input.js';
import { loadToolsFromInput } from '../utils/tools_loader.js';
/**
 * Process input parameters from URL and get tools
 * If URL contains query parameter `actors`, return tools from Actors otherwise return null.
 * @param url The URL to process
 * @param apifyClient The Apify client instance
 * @param mode Server mode for tool variant resolution
 * @param actorStore
 */
export async function processParamsGetTools(url, apifyClient, mode = 'default', actorStore) {
    const input = parseInputParamsFromUrl(url);
    return await loadToolsFromInput(input, apifyClient, mode, actorStore);
}
export function parseInputParamsFromUrl(url) {
    const query = url.split('?')[1] || '';
    const params = parse(query);
    return processInput(params);
}
/**
 * Checks if a task was cancelled, preventing state transitions from terminal states.
 * Critical for task execution: prevents SDK errors when trying to transition from 'cancelled' to 'working'.
 * @param taskId - The task identifier
 * @param mcpSessionId - The MCP session ID
 * @param taskStore - The task store instance
 * @returns true if task is cancelled, false otherwise
 */
export async function isTaskCancelled(taskId, mcpSessionId, taskStore) {
    const task = await taskStore.getTask(taskId, mcpSessionId);
    return (task === null || task === void 0 ? void 0 : task.status) === 'cancelled';
}
//# sourceMappingURL=utils.js.map
//# debugId=e7ac7620-f017-5d6f-930d-3ac7ca1a25d4
