/**
 * IAgentQuestionService — Output port for the unified agent-question
 * pipeline (spec 093, FR-6 / FR-7 / FR-8).
 *
 * One service owns:
 *  - persisting an {@link AgentQuestion} row,
 *  - resolving its lifecycle (answered / cancelled / expired),
 *  - bridging the asynchronous DB-backed answer back to an in-process
 *    awaiter when the question was raised by the SDK V2 `canUseTool`
 *    callback (interactive mode).
 *
 * The bridge is split into a sibling primitive — see
 * {@link IDeferredQuestionRegistry} — so this port can be implemented
 * with or without an in-process awaiter (e.g. a CLI-only adapter that
 * never blocks the SDK still satisfies this interface).
 *
 * Cross-app isolation (NFR-7): every read MUST be scoped by `appId`.
 */
/**
 * Default timeout for a deferred-question awaiter when no per-question
 * timeout is supplied. 30 minutes matches the research-decision figure
 * for blocking-priority questions.
 */
export const DEFAULT_DEFERRED_QUESTION_TIMEOUT_MS = 30 * 60 * 1000;
/**
 * Errors emitted by the deferred-question registry. Surfaced as typed
 * errors so callers can branch on the cause without string matching.
 */
export class AgentQuestionTimeoutError extends Error {
    questionId;
    timeoutMs;
    code = 'AGENT_QUESTION_TIMEOUT';
    constructor(questionId, timeoutMs) {
        super(`Agent question ${questionId} timed out after ${timeoutMs}ms with no answer recorded`);
        this.questionId = questionId;
        this.timeoutMs = timeoutMs;
        this.name = 'AgentQuestionTimeoutError';
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class AgentQuestionCancelledError extends Error {
    questionId;
    reason;
    code = 'AGENT_QUESTION_CANCELLED';
    constructor(questionId, reason) {
        super(`Agent question ${questionId} was cancelled${reason ? `: ${reason}` : ''}`);
        this.questionId = questionId;
        this.reason = reason;
        this.name = 'AgentQuestionCancelledError';
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
