/** * Host-owned processing admission for model attempts and action effects. * * This extends the confidential-inference boundary (`confidential-inference.ts`) * from "which handler/route may run" to "may this payload be processed here at * all". It is consulted before any payload preparation: before secret/PII * substitution, pipeline hooks, and the handler for a model attempt, and before * the handler for an action effect. When no policy is installed nothing is * consulted and behavior is unchanged. When one is installed, anything the * policy cannot evaluate (unknown modality, undeclared action destinations, a * throwing or malformed policy) is denied, and a denial is terminal: dispatch * never fails over to another provider after a processing denial. * * Only the runtime constructor installs a policy. Plugin metadata and runtime * settings never grant authority. */ import { ElizaError } from "../errors.js"; import type { ProcessingModality } from "../runtime/model-modality.js"; export declare const PROCESSING_POLICY_DENIED = "PROCESSING_POLICY_DENIED"; /** Correlation the runtime can attest for the current turn, when present. */ export interface ProcessingScope { readonly agentId: string; readonly roomId?: string; readonly messageId?: string; /** Pipeline stage of the active trajectory (e.g. "response", "action"). */ readonly stage?: string; } export interface ProcessingModelAttempt { /** The registered slot actually being called (after model-type fallback). */ readonly modelType: string; /** The slot the caller asked for. */ readonly requestedModelType: string; readonly modality: ProcessingModality; readonly provider: string; /** Exact handler identity; a provider name cannot impersonate one. */ readonly handler: (...args: never[]) => unknown; /** 1-based attempt number within this useModel call. */ readonly attempt: number; /** `failover` for any attempt after a failed provider. */ readonly reason: "primary" | "failover"; } export interface ProcessingActionEffect { readonly name: string; /** The action's declared destinations (`Action.egress`). */ readonly egress: readonly string[]; } export type ProcessingRequest = ProcessingScope & ({ readonly kind: "model_attempt"; readonly model: ProcessingModelAttempt; } | { readonly kind: "action_effect"; readonly action: ProcessingActionEffect; }); export type ProcessingDecision = { readonly allow: true; /** Policy-owned receipt identifying this admission in the host audit. */ readonly receiptId: string; readonly policyRevision: string; } | { readonly allow: false; readonly code: string; readonly policyRevision: string | null; }; /** Implemented by measured host code; must read current policy on every call. */ export interface ProcessingPolicy { decide(request: ProcessingRequest): ProcessingDecision | Promise; } export type ProcessingDenialReason = "policy_denied" | "policy_unavailable" | "decision_malformed" | "modality_unknown" | "destination_undeclared"; /** Terminal processing denial. The payload was not sent. */ export declare class ProcessingPolicyDeniedError extends ElizaError { readonly name: string; readonly reason: ProcessingDenialReason; readonly policyCode: string | undefined; constructor(args: { reason: ProcessingDenialReason; kind: ProcessingRequest["kind"]; subject: string; policyCode?: string; policyRevision?: string | null; cause?: unknown; }); } /** True when `error` or anything in its cause chain is a processing denial. */ export declare function isProcessingPolicyDenial(error: unknown): boolean; /** * Bind a host policy to a runtime. Called only by the runtime constructor; a * bound policy can never be replaced or removed. */ export declare function bindProcessingPolicy(runtime: object, policy: ProcessingPolicy): void; export declare function processingPolicyFor(runtime: object): ProcessingPolicy | undefined; type AdmissionInput = { kind: "model_attempt"; model: Omit & { modality: ProcessingModality | undefined; }; } | { kind: "action_effect"; action: { name: string; egress: readonly string[] | undefined; }; }; /** * Admit one model attempt or action effect. Returns `undefined` without a * policy, the allow decision otherwise, and throws * {@link ProcessingPolicyDeniedError} on every denial. */ export declare function admitProcessing(policy: ProcessingPolicy | undefined, agentId: string, input: AdmissionInput, cause?: unknown): Promise | undefined>; export {};