/**
 * Runtime-side pending host-tool timeout policy.
 *
 * This file does not control host-side execution timers. It controls the
 * fallback timer inside `PendingHostToolRequests`: after the worker emits a
 * host-tool request, how long should the runtime wait for the browser/main
 * thread to apply a result before treating the bridge request as stuck?
 */
import { EXECUTE_CODE_KIND } from './execute-code/index.js';
import { MODIFY_SKILL_KIND } from './modify-skill/index.js';
import { REQUEST_CREDENTIAL_KIND } from './request-credential/index.js';
import { REQUEST_OAUTH_KIND } from './request-oauth/index.js';
import { SWITCH_MODE_KIND } from './switch-mode/index.js';
const SECOND = 1000;
export const DEFAULT_HOST_TOOL_TIMEOUT_MS = 300 * SECOND;
export const HOST_TOOL_TIMEOUT_MS = {
    executeCode: 180 * SECOND,
    executeBashCommand: 300 * SECOND,
    invokeLlm: 60 * SECOND,
    sandboxLlm: 300 * SECOND,
    webSearch: 90 * SECOND,
    webCrawl: 60 * SECOND,
    createWebsite: 300 * SECOND,
    taskQueryFile: 60 * SECOND,
    takeScreenshot: 120 * SECOND,
    switchMode: 300 * SECOND,
    requestCredential: 300 * SECOND,
    requestOauth: 300 * SECOND
};
/** Raw per-kind timeout budget. Use this for direct tools and host-side execution timers. */
export function getHostToolTimeoutMs(kind) {
    const value = HOST_TOOL_TIMEOUT_MS[kind];
    return typeof value === 'number' ? value : DEFAULT_HOST_TOOL_TIMEOUT_MS;
}
/**
 * Tools whose normal lifecycle is owned by host UI or host-action state.
 *
 * The runtime must not start a normal pending-request timeout for these,
 * because "pending" can mean "waiting for a user decision", not "host work is
 * stuck". Their product timeout, if any, belongs in the host-side lifecycle.
 */
const HOST_LIFECYCLE_OWNED_TOOL_KINDS = new Set([
    EXECUTE_CODE_KIND,
    MODIFY_SKILL_KIND,
    REQUEST_CREDENTIAL_KIND,
    REQUEST_OAUTH_KIND,
    SWITCH_MODE_KIND
]);
/**
 * Runtime fallback timeout for pending host-tool requests.
 *
 * Returns 0 when the host/UI lifecycle owns the request, otherwise returns the
 * direct-tool timeout budget. A return value of 0 means "do not arm the
 * runtime pending-request timer".
 */
export function getRuntimePendingHostToolTimeoutMs(kind) {
    if (HOST_LIFECYCLE_OWNED_TOOL_KINDS.has(kind)) {
        return 0;
    }
    return getHostToolTimeoutMs(kind);
}
//# sourceMappingURL=timeouts.js.map