import type { IncomingMessage } from "node:http";
import type { ChannelId } from "../channels/plugins/types.js";
import type { FasedAgentConfig } from "../config/config.js";
import type { TaskNotifyPolicy } from "../tasks/task-registry.types.js";
import { type HookMappingResolved } from "./hooks-mapping.js";
export type HooksConfigResolved = {
    basePath: string;
    token: string;
    maxBodyBytes: number;
    mappings: HookMappingResolved[];
    agentPolicy: HookAgentPolicyResolved;
    sessionPolicy: HookSessionPolicyResolved;
};
export type HookAgentPolicyResolved = {
    defaultAgentId: string;
    knownAgentIds: Set<string>;
    allowedAgentIds?: Set<string>;
};
export type HookSessionPolicyResolved = {
    defaultSessionKey?: string;
    allowRequestSessionKey: boolean;
    allowedSessionKeyPrefixes?: string[];
};
export declare function resolveHooksConfig(cfg: FasedAgentConfig): HooksConfigResolved | null;
export declare function extractHookToken(req: IncomingMessage): string | undefined;
export declare function readJsonBody(req: IncomingMessage, maxBytes: number): Promise<{
    ok: true;
    value: unknown;
} | {
    ok: false;
    error: string;
}>;
export declare function normalizeHookHeaders(req: IncomingMessage): Record<string, string>;
export declare function normalizeWakePayload(payload: Record<string, unknown>): {
    ok: true;
    value: {
        text: string;
        mode: "now" | "next-heartbeat";
    };
} | {
    ok: false;
    error: string;
};
export type HookAgentPayload = {
    message: string;
    name: string;
    triggerId?: string;
    agentId?: string;
    wakeMode: "now" | "next-heartbeat";
    sessionKey?: string;
    deliver: boolean;
    channel: HookMessageChannel;
    to?: string;
    model?: string;
    thinking?: string;
    timeoutSeconds?: number;
    notifyPolicy?: TaskNotifyPolicy;
};
export type HookAgentDispatchPayload = Omit<HookAgentPayload, "sessionKey"> & {
    sessionKey: string;
    allowUnsafeExternalContent?: boolean;
};
export type HookWorkflowDispatchPayload = {
    workflowDefinitionId: string;
    name: string;
    triggerId?: string;
    agentId?: string;
    sessionKey: string;
    notifyPolicy?: TaskNotifyPolicy;
};
export type HookMessageChannel = ChannelId | "last";
export declare const getHookChannelError: () => string;
export declare function resolveHookChannel(raw: unknown): HookMessageChannel | null;
export declare function resolveHookDeliver(raw: unknown): boolean;
export declare function resolveHookTargetAgentId(hooksConfig: HooksConfigResolved, agentId: string | undefined): string | undefined;
export declare function isHookAgentAllowed(hooksConfig: HooksConfigResolved, agentId: string | undefined): boolean;
export declare const getHookAgentPolicyError: () => string;
export declare const getHookSessionKeyRequestPolicyError: () => string;
export declare const getHookSessionKeyPrefixError: (prefixes: string[]) => string;
export declare function resolveHookSessionKey(params: {
    hooksConfig: HooksConfigResolved;
    source: "request" | "mapping";
    sessionKey?: string;
    idFactory?: () => string;
}): {
    ok: true;
    value: string;
} | {
    ok: false;
    error: string;
};
export declare function normalizeHookDispatchSessionKey(params: {
    sessionKey: string;
    targetAgentId: string | undefined;
}): string;
export declare function normalizeAgentPayload(payload: Record<string, unknown>): {
    ok: true;
    value: HookAgentPayload;
} | {
    ok: false;
    error: string;
};
