function nowIso() {
    return new Date().toISOString();
}
export function buildEvaluationRequest({ samplesPath, skillDir, artifacts, model, executor, noJudge, concurrency, timeoutMs, noCache, dryRun, blind, project, owner, tags, repeat, batch, judgeRepeat, judgeModels, bootstrap, bootstrapSamples, lengthDebias, budget, effort, }) {
    return {
        samplesPath,
        skillDir,
        artifacts,
        model,
        executor,
        noJudge,
        concurrency,
        timeoutMs,
        noCache,
        dryRun,
        blind,
        project,
        owner,
        tags,
        repeat,
        batch,
        judgeRepeat,
        judgeModels,
        bootstrap,
        bootstrapSamples,
        lengthDebias,
        budget,
        ...(effort ? { effort } : {}),
    };
}
export function createEvaluationRun(runId, startedAt = nowIso()) {
    return {
        startedAt,
        run: {
            runId,
            startedAt,
            status: 'running',
        },
    };
}
export function finalizeEvaluationRun(run, finishedAt = nowIso()) {
    return {
        ...run,
        finishedAt,
        status: 'succeeded',
    };
}
export function failEvaluationRun(run, finishedAt = nowIso()) {
    return {
        ...run,
        finishedAt,
        status: 'failed',
    };
}
export function createQueuedJob({ jobId, request, createdAt = nowIso(), }) {
    return {
        jobId,
        status: 'queued',
        createdAt,
        updatedAt: createdAt,
        request,
    };
}
export function markJobRunning(job, runId, startedAt = nowIso()) {
    return {
        ...job,
        status: 'running',
        runId,
        startedAt,
        updatedAt: startedAt,
    };
}
export function createSucceededJob({ jobId, runId, reportId, request, createdAt, startedAt, finishedAt, }) {
    return {
        jobId,
        status: 'succeeded',
        createdAt,
        startedAt,
        finishedAt,
        updatedAt: finishedAt,
        request,
        runId,
        resultReportId: reportId,
    };
}
export function classifyEvaluationError(error) {
    const normalized = error.toLowerCase();
    if (normalized.includes('missing required field')
        || normalized.includes('invalid samples file')
        || normalized.includes('skill not found')
        || normalized.includes('samples file')
        || normalized.includes('未发现任何 skill')) {
        return 'user';
    }
    if (normalized.includes('judge')
        || normalized.includes('semantic_similarity')
        || normalized.includes('failed to parse judge response')) {
        return 'judge';
    }
    if (normalized.includes('timed out')
        || normalized.includes('api request timed out')
        || normalized.includes('execution timed out')
        || normalized.includes('mcp')
        || normalized.includes('network')) {
        return 'executor';
    }
    return 'system';
}
export function createFailedJob({ job, error, errorCategory = classifyEvaluationError(error), finishedAt = nowIso(), }) {
    return {
        ...job,
        status: 'failed',
        finishedAt,
        updatedAt: finishedAt,
        error,
        errorCategory,
    };
}
//# sourceMappingURL=evaluation-job.js.map