const APPROVAL_SCOPE = "approval";
const APPROVAL_POLICY_KEY = "manualToolApproval";
export class ApprovalService {
    state;
    constructor(state) {
        this.state = state;
    }
    list(status) {
        return this.state.listApprovalGates({ status }, 50);
    }
    listForSubject(subjectType, subjectId) {
        return this.state.listApprovalGates({ subjectType, subjectId }, 20);
    }
    request(runId, summary, subjectType = "run", subjectId = runId) {
        return this.state.createApprovalGate({ runId, subjectType, subjectId, summary });
    }
    decide(id, status, rationale = "") {
        return this.state.decideApprovalGate(id, status, rationale);
    }
    policy() {
        return {
            manualToolApproval: Boolean(this.state.getUiState(APPROVAL_SCOPE, APPROVAL_POLICY_KEY)),
        };
    }
    setManualToolApproval(enabled) {
        this.state.setUiState(APPROVAL_SCOPE, APPROVAL_POLICY_KEY, enabled);
        return this.policy();
    }
}
