import type { HttpContext } from '@adonisjs/core/http';
import type { ActorResolver } from '../spi/actor-resolver.js';
import type { Actor } from '../types.js';
import type { AccessDeniedOption, AgentDashboardAuthorize } from './define_config.js';
/** The outcome of the console access gate: proceed (with the actor, when one resolved), or deny. */
export type DashboardGateVerdict = {
    ok: true;
    actor?: Actor;
} | {
    ok: false;
    status: 401 | 403;
    error: 'forbidden' | 'unauthenticated';
    /** The thrown error's message, only outside production. */
    detail?: string;
    redirectTo?: string;
};
/** What {@link evaluateDashboardGate} needs. */
export interface DashboardGateOptions {
    /** The agent config's resolver; its actor (if any) is handed to `authorize` as the 2nd argument. */
    actorResolver?: ActorResolver | undefined;
    /** The console's `authorize` (`dashboard.authorize` in `config/agent.ts`). */
    authorize?: AgentDashboardAuthorize | undefined;
    /** `app.inProduction`: without `authorize`, the console is open outside production, closed in it. */
    inProduction?: boolean;
}
/**
 * Decide whether a request may use the agent console — the SPA shell AND the `/agent/governance/*`
 * routes it reads go through this same check. Touches nothing on the response, so it is unit
 * testable free of the router:
 *
 * - `authorize` omitted → allowed outside production, `403 forbidden` in production.
 * - otherwise the actor is resolved (best effort: `undefined` when there is none) and
 *   `authorize(ctx, actor)` decides: `true`/`{ allowed: true }` allow; `false`/`{ allowed: false }`
 *   → `403 forbidden`; `reason: 'unauthenticated'` → `401 unauthenticated`; `{ redirectTo }` → `401`
 *   carrying the path; a throw → `403` (its message as `detail` outside production only).
 */
export declare function evaluateDashboardGate(ctx: HttpContext, options: DashboardGateOptions): Promise<DashboardGateVerdict>;
/**
 * Write a refused {@link DashboardGateVerdict} as JSON — what the `/agent/governance/*` routes (and
 * any non-page request to the shell) answer: `{ error }`, plus `redirectTo` when `authorize` asked
 * for one. A page navigation with `redirectTo` is redirected instead. Stands down when the hook
 * already answered the request itself.
 */
export declare function answerConsoleDenialJson(ctx: HttpContext, verdict: Extract<DashboardGateVerdict, {
    ok: false;
}>): void;
/** What {@link answerDashboardDenial} needs to serve (or delegate) the access-denied page. */
export interface DashboardDenialOptions {
    /** The console's mount (`/agent/dashboard`) — reported to a custom renderer as `basePath`. */
    basePath: string;
    /** The host's `dashboard.accessDenied` option — tweak the built-in page, or render it. */
    accessDenied?: AccessDeniedOption | undefined;
}
/**
 * Write a refused {@link DashboardGateVerdict} for the SPA shell — shared by BOTH dashboard providers
 * (embedded and standalone) so they refuse identically. A page navigation gets the built-in
 * access-denied page (or the host's `accessDenied` customisation of it), or a redirect when
 * `authorize` returned `{ redirectTo }`; anything else gets the JSON {@link answerConsoleDenialJson}
 * writes. Stands down when `authorize` (or the renderer) already answered the request.
 */
export declare function answerDashboardDenial(ctx: HttpContext, verdict: Extract<DashboardGateVerdict, {
    ok: false;
}>, options: DashboardDenialOptions): Promise<void>;
//# sourceMappingURL=gate.d.ts.map