/** * Server-attested delivery-audience evidence for owner-private disclosures. * * Evidence uses an enumerable module-private symbol plus a WeakMap token, so it * survives ordinary in-process message spreads while JSON and request bodies * cannot mint or replay it. Canonical connector rooms are attested from their * stored room and participant set; authenticated API routes use the separate * host-principal attestor. * * Agent-internal turns (canonical SELF/AUTONOMOUS rooms whose actor is the * agent, the canonical owner, or an explicitly registered runtime-managed * synthetic actor) are ALLOWED for disclosure-gate purposes. Room membership * alone never proves synthetic identity. This is sound because this gate only * controls what enters the in-process turn: nothing composed here becomes * visible without passing the egress seams, which re-validate the CURRENT room * audience at delivery time. * * When a gate denial suppresses owner-private surfaces, the suppression is * recorded on the turn so state composition can surface an explicit note the * model can see — silence would read as the capabilities not existing. * * Evidence expires after a fixed TTL. A turn that is still active may renew it * (see {@link beginTrustedDeliveryAudienceTurn}): renewal re-derives the * evidence from current trusted authority and only succeeds when the audience * is unchanged, so a long turn keeps working without a longer TTL, while a * completed or cancelled turn can never acquire renewed access. */ import type { DisclosureGate } from "../types/components.js"; import type { Memory } from "../types/memory.js"; import { type UUID } from "../types/primitives.js"; import type { IAgentRuntime } from "../types/runtime.js"; declare const trustedDeliveryAudienceBrand: unique symbol; export declare const OWNER_EXCLUSIVE_DISCLOSURE_GATE: Readonly<{ readonly require: "owner_exclusive"; }>; export declare const PRIVACY_DENIED_TEXT = "I can\u2019t access or disclose owner-private information in this destination because its audience is not verified as owner-only."; export type TrustedDeliveryAudienceKind = "direct" | "group" | "channel" | "public" | "api_private" | "api_external" | "voice_private" | "voice_shared" | "internal_agent" | "unknown"; export type TrustedDeliveryAudienceProvenance = "canonical_room" | "authenticated_owner_api" | "service_gateway"; /** * Read-only evidence returned for diagnostics and provider execution context. * The unexported brand prevents structural construction outside this module; * only the WeakMap-bound instance is authoritative for access decisions. */ export interface TrustedDeliveryAudience { readonly [trustedDeliveryAudienceBrand]: true; readonly attestationId: string; readonly kind: TrustedDeliveryAudienceKind; readonly provenance: TrustedDeliveryAudienceProvenance; readonly actorEntityId: UUID; readonly canonicalOwnerEntityId: UUID | null; readonly agentEntityId: UUID; readonly roomId: UUID; readonly participantEntityIds: readonly UUID[]; readonly membershipVersion: string; readonly issuedAtMs: number; readonly expiresAtMs: number; } export type TrustedApiPrincipal = { kind: "owner_session" | "owner_api_token"; principalId: string; } | { kind: "service_gateway"; principalId: string; /** * Present only when the HTTP boundary authenticated a revocable, * DB-backed machine session (device pairing) whose boundary role is * USER-rank or above. Typed as the literal "USER" so this seam can * carry exactly one non-owner tier — it structurally cannot mint * ADMIN/OWNER attribution. Absent for unauthenticated callers, * shared-server-gateway tokens, and principal-only (non-session) * authorities. Consumers may use it to grant the minted external * entity USER world membership; the principal stays external for * audience attestation (owner-only disclosure is unaffected). */ sessionRole?: "USER"; /** Auth-identity id backing `sessionRole` — the grant's audit ref. */ sessionIdentityId?: string; }; export type OwnerExclusiveDisclosureDenial = "missing_attestation" | "expired_attestation" | "future_attestation" | "actor_mismatch" | "agent_mismatch" | "room_mismatch" | "runtime_mismatch" | "owner_mismatch" | "participant_mismatch" | "destination_not_private" | "audience_changed" | "audience_lookup_failed"; export declare const OWNER_PRIVATE_DESTINATION_DISCLOSURE_BASIS = "owner_private_destination"; export declare const INTERNAL_AGENT_TURN_DISCLOSURE_BASIS = "internal_agent_turn"; /** * Why an allowed decision is allowed: a verified owner-only destination, or an * agent-internal turn whose visible egress is separately re-validated. Kept as * a required discriminant so callers that must NOT extend internal-turn trust * to a visible delivery can tell the two apart. */ export type OwnerExclusiveDisclosureBasis = typeof OWNER_PRIVATE_DESTINATION_DISCLOSURE_BASIS | typeof INTERNAL_AGENT_TURN_DISCLOSURE_BASIS; export type OwnerExclusiveDisclosureDecision = { allowed: true; basis: OwnerExclusiveDisclosureBasis; audience: TrustedDeliveryAudience; } | { allowed: false; reason: OwnerExclusiveDisclosureDenial; audience?: TrustedDeliveryAudience; }; /** * Re-checks an authenticated API principal with a fresh credential/session * lookup, never cached ingress authorization. Returns `null` when the * principal is no longer valid. */ export type TrustedApiPrincipalRevalidator = () => Promise; /** * Register a synthetic actor that the runtime itself uses to originate an * internal turn. The returned release function is reference-counted so * overlapping trigger deliveries cannot revoke each other's authority. */ export declare function registerRuntimeManagedInternalActor(runtime: IAgentRuntime, actorEntityId: UUID): () => void; /** * Attest a connector turn from canonical room state. Message content and * metadata are intentionally not consulted for destination or membership. */ export declare function attestDeliveryAudienceFromCanonicalRoom(runtime: IAgentRuntime, message: Memory, options?: { nowMs?: number; ttlMs?: number; }): Promise; /** * Attest an HTTP turn after the server, not the request body, has classified * its authenticated principal. Service-gateway callers remain external even * when they supply owner-looking `userId`, source, or channel labels. */ export declare function attestAuthenticatedApiDeliveryAudience(runtime: IAgentRuntime, message: Memory, principal: TrustedApiPrincipal, options?: { nowMs?: number; ttlMs?: number; /** * Fresh credential/session re-check used to renew this evidence during a * long active turn. Without it, API evidence is never renewed. */ revalidatePrincipal?: TrustedApiPrincipalRevalidator; }): Promise; /** * Mark this exact turn's evidence as renewable while the turn runs. Call once * the turn is admitted, with the turn's cancellation signal, and call the * returned function when the turn completes (success, failure or abort). * Renewal is refused after that, after the signal aborts, for evidence minted * by another runtime, and for evidence that had already expired when the turn * began — a lease never revives a stale attestation. */ export declare function beginTrustedDeliveryAudienceTurn(runtime: IAgentRuntime, message: Memory, options?: { signal?: AbortSignal; nowMs?: number; }): () => void; export type TrustedDeliveryAudienceRenewal = { renewed: true; audience: TrustedDeliveryAudience; } | { renewed: false; reason: "not_expired" | "no_active_turn" | "turn_cancelled" | "runtime_mismatch" | "actor_mismatch" | "verification_unavailable" | "principal_revoked" | "audience_changed" | "audience_lookup_failed"; }; /** * Renew expired evidence for an active turn from current trusted authority. * Canonical-room evidence re-reads the room kind, canonical owner and complete * participant census; authenticated-API evidence re-checks its principal with * the host's fresh revalidator. Renewal succeeds only when the result matches * the original audience exactly (actor, agent, room, destination kind, owner, * census); anything else leaves the expired evidence in place so every gate * keeps denying. Sensitive-disclosure bookkeeping is preserved. */ export declare function renewTrustedDeliveryAudience(runtime: IAgentRuntime, message: Memory, nowMs?: number): Promise; /** * Renew this turn's evidence when it has expired and the turn is still active; * a no-op otherwise. Call before synchronous exposure or execution gates. */ export declare function renewExpiredTrustedDeliveryAudience(runtime: IAgentRuntime, message: Memory | undefined, nowMs?: number): Promise; /** Return the trusted evidence attached to this exact in-memory turn. */ export declare function getTrustedDeliveryAudience(message: Memory | undefined): TrustedDeliveryAudience | undefined; /** Whether this turn's process-local evidence was minted by this runtime. */ export declare function trustedDeliveryAudienceIsBoundToRuntime(message: Memory, runtime: IAgentRuntime): boolean; /** Record that an owner-private surface was withheld from this exact turn. */ export declare function recordOwnerExclusiveSuppression(message: Memory, reason: OwnerExclusiveDisclosureDenial): void; /** * Model-visible note appended to composed state when this turn had * owner-private surfaces suppressed. Silence would read to the model as the * capabilities not existing; the note lets it answer honestly instead of * fabricating either the data or a permanent inability. */ export declare function ownerExclusiveSuppressionNote(message: Memory | undefined): string | undefined; /** Synchronous gate used by catalogs and other pre-execution exposure paths. */ export declare function evaluateOwnerExclusiveDisclosure(message: Memory | undefined, nowMs?: number): OwnerExclusiveDisclosureDecision; /** * Re-read canonical room membership before sensitive provider/action execution * and before visible egress. API-private turns also re-read room membership: * authentication proves the caller, but it cannot make a shared conversation * an owner-only destination. */ export declare function revalidateOwnerExclusiveDisclosure(runtime: IAgentRuntime, message: Memory, nowMs?: number): Promise; /** Revalidate and mark that this turn has consumed owner-private information. */ export declare function authorizeOwnerExclusiveDisclosure(runtime: IAgentRuntime, message: Memory): Promise; export declare function markOwnerExclusiveDisclosureUsed(message: Memory): void; export declare function ownerExclusiveDisclosureWasUsed(message: Memory): boolean; /** Stable process-local partition for in-flight provider coalescing. */ export declare function trustedDeliveryAudienceCacheKey(message: Memory): string; /** * Apply a component's owner-exclusive disclosure policy. * * Scoped to the `owner_exclusive` gate variant only: the min-over-members * `audience_admission` variant is evaluated in the access-control layer * (`audienceAdmissionGateFailure`), which owns the value dependency on the * policy core, so this security-layer function stays free of an access-control * import cycle. A non-owner-exclusive gate is a no-op here (the action-gate * routes it to the admission evaluator instead), never a mis-evaluation. */ export declare function disclosureGateFailure(gate: DisclosureGate | undefined, message: Memory | undefined): string | undefined; export {};