"use strict";
/**
 * Platform defaults — single source of truth for tunable constants.
 *
 * Every value can be overridden via the corresponding environment variable.
 * When adding a new constant, follow the pattern:
 *   env → parse → fallback to sensible default.
 *
 * Grouped by domain so related knobs live together.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.YAML_LINE_WIDTH = exports.STOP_WORDS = exports.CLAIM_DURATION_OPTIONS = exports.YAML_VERSION_LIMIT = exports.YAML_LIST_LIMIT = exports.QUERY_LIMIT_MAX = exports.QUERY_LIMIT_DEFAULT = exports.CONFIG_CACHE_TTL_MS = exports.MCP_TOOL_TIMEOUT_MS = exports.WORKFLOW_SYNC_TIMEOUT_MS = exports.JOB_EXPIRE_SECS = exports.WORKFLOW_EXPIRE_SECS = exports.TOOL_ARG_LIMIT_CAP = exports.TOOL_ROUNDS_MCP_QUERY = exports.TOOL_ROUNDS_TRIAGE = exports.TOOL_RESULT_MAX_CHARS = exports.LLM_MAX_INPUT_CHARS = exports.LLM_MAX_ARRAY_ITEMS = exports.LLM_MAX_TOKENS_VISION = exports.LLM_MAX_TOKENS_JSON = exports.LLM_MAX_TOKENS_DEFAULT = exports.LLM_BASE_URL = exports.LLM_MODEL_SECONDARY = exports.LLM_MODEL_PRIMARY = void 0;
function envInt(key, fallback) {
    const v = process.env[key];
    if (v === undefined || v === '')
        return fallback;
    const n = parseInt(v, 10);
    return Number.isNaN(n) ? fallback : n;
}
function envStr(key, fallback) {
    return process.env[key] || fallback;
}
// ── LLM ──────────────────────────────────────────────────────────────
/** Primary model for agentic/insight workflows (tool-calling capable). */
exports.LLM_MODEL_PRIMARY = envStr('LT_LLM_MODEL_PRIMARY', 'claude-sonnet-4-6');
/** Lighter model for summarization, interpretation, and vision tasks. */
exports.LLM_MODEL_SECONDARY = envStr('LT_LLM_MODEL_SECONDARY', 'claude-haiku-4-5-20251001');
/** Base URL for OpenAI-compatible providers (Groq, Together, local). */
exports.LLM_BASE_URL = process.env.LT_LLM_BASE_URL || undefined;
/** Default max_tokens when the LLM is called without tool definitions. */
exports.LLM_MAX_TOKENS_DEFAULT = envInt('LT_LLM_MAX_TOKENS_DEFAULT', 1500);
/** Max tokens for structured JSON interpretation steps. */
exports.LLM_MAX_TOKENS_JSON = envInt('LT_LLM_MAX_TOKENS_JSON', 800);
/** Max tokens for vision/document extraction calls. */
exports.LLM_MAX_TOKENS_VISION = envInt('LT_LLM_MAX_TOKENS_VISION', 2000);
/** Truncate arrays beyond this length before sending to the LLM. */
exports.LLM_MAX_ARRAY_ITEMS = envInt('LT_LLM_MAX_ARRAY_ITEMS', 25);
/** Hard character cap on serialized input payloads sent to the LLM. */
exports.LLM_MAX_INPUT_CHARS = envInt('LT_LLM_MAX_INPUT_CHARS', 12_000);
/** Max characters for a single tool result before truncation in the agentic loop. */
exports.TOOL_RESULT_MAX_CHARS = envInt('LT_TOOL_RESULT_MAX_CHARS', 50_000);
// ── Tool execution ───────────────────────────────────────────────────
/** Max agentic loop iterations for MCP triage workflows. */
exports.TOOL_ROUNDS_TRIAGE = envInt('LT_TOOL_ROUNDS_TRIAGE', 10);
/** Max agentic loop iterations for mcpQuery (higher — includes recall + discover + persist phases). */
exports.TOOL_ROUNDS_MCP_QUERY = envInt('LT_TOOL_ROUNDS_MCP_QUERY', 15);
/** Cap on `limit` argument baked into generated YAML tool steps. */
exports.TOOL_ARG_LIMIT_CAP = envInt('LT_TOOL_ARG_LIMIT_CAP', 25);
// ── Workflow execution ───────────────────────────────────────────────
/** Default graph expiry in seconds for generated YAML workflows (5 min — must exceed longest activity chain). */
exports.WORKFLOW_EXPIRE_SECS = envInt('LT_WORKFLOW_EXPIRE_SECS', 300);
/** Default job expiry in seconds for workflow executions (30 days). */
exports.JOB_EXPIRE_SECS = envInt('LT_JOB_EXPIRE_SECS', 30 * 24 * 60 * 60);
/** Default timeout (ms) for synchronous workflow invocations (5 min — matches WORKFLOW_EXPIRE_SECS). */
exports.WORKFLOW_SYNC_TIMEOUT_MS = envInt('LT_WORKFLOW_SYNC_TIMEOUT_MS', 300_000);
/** MCP tool call timeout (ms). Overrides the MCP SDK default of 60s which is too short for browser automation. */
exports.MCP_TOOL_TIMEOUT_MS = envInt('LT_MCP_TOOL_TIMEOUT_MS', 300_000);
/** Config cache TTL in milliseconds. */
exports.CONFIG_CACHE_TTL_MS = envInt('LT_CONFIG_CACHE_TTL_MS', 5 * 60 * 1000);
// ── Query / pagination ───────────────────────────────────────────────
/** Default page size for MCP DB tool queries (find_tasks, etc.). */
exports.QUERY_LIMIT_DEFAULT = envInt('LT_QUERY_LIMIT_DEFAULT', 25);
/** Maximum allowed page size for MCP DB tool queries. */
exports.QUERY_LIMIT_MAX = envInt('LT_QUERY_LIMIT_MAX', 100);
/** Default page size for YAML workflow listings. */
exports.YAML_LIST_LIMIT = envInt('LT_YAML_LIST_LIMIT', 50);
/** Default page size for YAML workflow version history. */
exports.YAML_VERSION_LIMIT = envInt('LT_YAML_VERSION_LIMIT', 20);
// ── Escalation ──────────────────────────────────────────────────────
/**
 * Claim duration presets shown in the dashboard (minutes).
 * Override via JSON array, e.g. LT_CLAIM_DURATION_OPTIONS='[15,30,60,480]'
 */
exports.CLAIM_DURATION_OPTIONS = (() => {
    const raw = process.env.LT_CLAIM_DURATION_OPTIONS;
    if (!raw)
        return [15, 30, 60, 240];
    try {
        const parsed = JSON.parse(raw);
        if (Array.isArray(parsed) && parsed.every((n) => typeof n === 'number' && n > 0)) {
            return parsed;
        }
    }
    catch { /* fall through */ }
    return [15, 30, 60, 240];
})();
// ── Text processing ─────────────────────────────────────────────────
/** Common stop words filtered from keyword extraction (tag derivation, FTS queries, prompt parsing). */
exports.STOP_WORDS = new Set([
    'the', 'and', 'for', 'with', 'from', 'that', 'this', 'are', 'was',
    'not', 'but', 'has', 'have', 'had', 'been', 'will', 'can', 'all',
    'please', 'take', 'make', 'show', 'get', 'use', 'find', 'give',
    'want', 'need', 'would', 'could', 'should', 'about', 'what', 'how',
]);
// ── Formatting ───────────────────────────────────────────────────────
/** YAML dump line width. */
exports.YAML_LINE_WIDTH = envInt('LT_YAML_LINE_WIDTH', 120);
