/** Selects full, redacted, or omitted artifact metadata for the requester. Authorization applies to the referencing record; content-addressed URLs remain byte-access capabilities. Grants are additive and missing disclosure scope defaults to owner-private. */ import type { AccessContext } from "../types/access-context.js"; import type { ArtifactRoomSnapshot, ArtifactShareGrant, ArtifactShareMetadata, Memory, MemoryScope } from "../types/memory.js"; import type { UUID } from "../types/primitives.js"; /** What a viewer's DTO may contain for one artifact. */ export type ArtifactDisclosure = "full" | "redacted" | "none"; /** Typed share metadata parsed from a record's jsonb metadata. */ export interface ParsedArtifactShareMetadata { grants: ArtifactShareGrant[]; /** Room roster captured with a share so later disclosure can be replayed. */ roomSnapshot?: ArtifactRoomSnapshot; } /** * Parse `metadata.share.grants` off an untyped stored record into typed * grants. Malformed entries are dropped — a grant that cannot be read grants * NOTHING (fail closed), it never degrades into some default access. */ export declare function parseArtifactShareMetadata(metadata: unknown): ParsedArtifactShareMetadata; export declare function parseArtifactShareGrants(metadata: unknown): ArtifactShareGrant[]; /** The disclosure-relevant fields of one artifact-referencing record. */ export interface ArtifactDisclosureRecord { /** Stored visibility scope (callers normalize; unknown fails closed). */ scope: MemoryScope; /** Entity the record is scoped to (owner/speaker), for entity-scoped tiers. */ scopedEntityId?: UUID; /** Parsed share grants from the record's metadata. */ grants?: readonly ArtifactShareGrant[]; /** Full typed share metadata when callers already carry the parsed contract. */ share?: ParsedArtifactShareMetadata | ArtifactShareMetadata; } /** * Normalize one stored memory into the artifact-disclosure record shape. * * Storage metadata is jsonb and therefore untrusted at read time. Unknown scope * values collapse to `owner-private`, and malformed grants/scoped ids are * ignored, so a corrupt row cannot widen disclosure by accident. */ export declare function artifactDisclosureRecordFromMemory(memory: Pick): ArtifactDisclosureRecord; /** * Decide what `ctx`'s requester may see of one artifact record. * * Tier order (most privileged first): * 1. No access context → `full`. The single-owner local boundary deliberately * omits a context (see `RouteHandlerContext.accessContext`), and existing * unfiltered behavior there is a documented product decision. * 2. Agent self-read, OWNER, or ADMIN rank → `full`. * 3. An explicit per-entity grant wins in BOTH directions: a `full` grant * elevates past the scope ladder, and a `redacted` grant narrows the viewer * to the variant even when the scope ladder would allow full — the owner's * per-viewer instruction (e.g. an admin "redact for everyone" pass) must * not be undone by a coarse `global` scope. * 4. No grant → the scope ladder (`canReadScope`): a USER still reads global * records and their own user-private records in full; the `owner-private` * default fails closed to `none`. */ export declare function resolveArtifactDisclosure(record: ArtifactDisclosureRecord, ctx: AccessContext | undefined, agentId: UUID): ArtifactDisclosure; export interface ArtifactVariantUrls { fullUrl?: string | null; redactedUrl?: string | null; } export interface DisclosedArtifactUrl { disclosure: Exclude; url: string; redacted: boolean; } /** * Select the URL a DTO may disclose for a resolved artifact decision. * * A redacted grant is fail-closed: if no redacted variant exists yet, callers * must omit the artifact instead of falling back to the original bytes. */ export declare function selectDisclosedArtifactUrl(disclosure: ArtifactDisclosure, urls: ArtifactVariantUrls): DisclosedArtifactUrl | null;