import { createClaudeSession, } from '../../../modules/claude-invocation/entities/claudeSession/claudeSession.js';
export async function dispatchClaudeSession(input, deps) {
    if (deps.environment.hasAnthropicApiKey()) {
        return { status: 'billing-regression-prevented' };
    }
    if (deps.billingState.read().dispatchPaused) {
        return { status: 'paused' };
    }
    const result = await deps.sessionGateway.dispatch({
        prompt: input.prompt,
        flags: input.flags,
        localPath: input.localPath,
        jobId: input.jobId,
        jobType: input.jobType,
    });
    if (result.status === 'rate-limited') {
        return { status: 'rate-limited', rawStderr: result.rawStderr };
    }
    if (result.status === 'failed') {
        return { status: 'failed', rawStderr: result.rawStderr };
    }
    const session = createClaudeSession({
        sessionId: result.sessionId,
        jobId: input.jobId,
        jobType: input.jobType,
        localPath: input.localPath,
        mergeRequestId: input.mergeRequestId,
        dispatchedAt: deps.now(),
    });
    return { status: 'dispatched', session };
}
//# sourceMappingURL=dispatchClaudeSession.usecase.js.map