import { z } from "zod"; import { type AppId, type IsoDateTime, type Json, type TurnId } from "./ids.js"; import { type Principal } from "./principal.js"; import { type RunContext } from "./run-context.js"; import { type TriggerRef } from "./triggers.js"; import type { GuardDecision } from "./guard.js"; import { type RiskLabel, type ToolOutcome } from "./tools.js"; /** The audit enums' members. ONE spelling each: the interface below, the row * schema, and the wire's request filters (`store-wire.ts`) all build from these * tuples, so a member added in one place cannot silently miss the others. * `venue` needs no tuple here — `VENUES` is already its one source, and the * `satisfies` on the other two ties them to the types that own them. */ export declare const AUDIT_KINDS: readonly ["tool-call", "approval", "policy-decision", "run", "app-lifecycle", "share", "door-auth", "principal"]; export type AuditKind = (typeof AUDIT_KINDS)[number]; export declare const AUDIT_OUTCOMES: readonly ["ok", "error", "pending-approval", "blocked", "connect-required"]; export declare const AUDIT_DECIDED_BY: readonly ["grant", "rule", "judge", "default", "confirmEach", "breaker", "denied", "org", "frozen"]; /** 01-core §7 */ export interface AuditEvent { id: string; at: IsoDateTime; kind: AuditKind; principal: Principal; venue: RunContext["venue"]; presence: RunContext["presence"]; appId?: AppId; trigger?: TriggerRef; /** The turn this row came out of, so a turn's rows join to each other, to its * mirrored calls and to the views it painted. Copied from the `RunContext` by * the mint helpers — never authored by a caller. Absent on a run with no turn * (a webhook, a schedule fire, an org-policy load). */ turnId?: TurnId; /** The MCP client this row came in on — `mcpc_*` or a CIMD URL for a * third-party agent, `svc:` for a host's own service key. Absent on * every row that did not arrive at the door. */ clientId?: string; tool?: string; /** The risk the guard actually gated on — the EFFECTIVE grade, after any * `resolveRisk`, not the descriptor's static label. Absent on rows written * with no tool descriptor in hand, and on a control/frozen row: the freeze * short-circuit runs before risk resolution, so it has no effective grade to * report and omits the field rather than chip the declared label. */ risk?: RiskLabel; inputPreview?: string; outcome?: ToolOutcome["status"]; decidedBy?: GuardDecision["decidedBy"]; detail?: Json; } /** * The ctx half of an audit row — the fields every row copies off the run it came * out of. ONE copy: hand-spreading these at each mint site is how `turnId` * reached three writers and silently missed five, and a row that cannot be * joined to its turn is an unanswerable question for billing and reconciliation. * * Absent optionals stay ABSENT rather than becoming `undefined` keys, so a row * built through this is byte-identical to a hand-written one. */ export declare const auditContext: (ctx: Pick) => Pick; /** 01-core §7 */ export declare const auditEventSchema: z.ZodObject<{ id: z.ZodString; at: z.ZodString; kind: z.ZodEnum<["tool-call", "approval", "policy-decision", "run", "app-lifecycle", "share", "door-auth", "principal"]>; principal: z.ZodObject<{ kind: z.ZodEnum<["user", "org"]>; subject: z.ZodString; display: z.ZodOptional; ephemeral: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodEnum<["user", "org"]>; subject: z.ZodString; display: z.ZodOptional; ephemeral: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodEnum<["user", "org"]>; subject: z.ZodString; display: z.ZodOptional; ephemeral: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; venue: z.ZodEnum<["chat", "app", "automation", "mcp"]>; presence: z.ZodEnum<["present", "away"]>; appId: z.ZodOptional; trigger: z.ZodOptional; automationId: z.ZodOptional; lineageId: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ runId: z.ZodString; kind: z.ZodEnum<["schedule", "host-event", "external"]>; automationId: z.ZodOptional; lineageId: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ runId: z.ZodString; kind: z.ZodEnum<["schedule", "host-event", "external"]>; automationId: z.ZodOptional; lineageId: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; turnId: z.ZodOptional; clientId: z.ZodOptional; tool: z.ZodOptional; risk: z.ZodOptional>; inputPreview: z.ZodOptional; outcome: z.ZodOptional>; decidedBy: z.ZodOptional>; detail: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; at: z.ZodString; kind: z.ZodEnum<["tool-call", "approval", "policy-decision", "run", "app-lifecycle", "share", "door-auth", "principal"]>; principal: z.ZodObject<{ kind: z.ZodEnum<["user", "org"]>; subject: z.ZodString; display: z.ZodOptional; ephemeral: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodEnum<["user", "org"]>; subject: z.ZodString; display: z.ZodOptional; ephemeral: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodEnum<["user", "org"]>; subject: z.ZodString; display: z.ZodOptional; ephemeral: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; venue: z.ZodEnum<["chat", "app", "automation", "mcp"]>; presence: z.ZodEnum<["present", "away"]>; appId: z.ZodOptional; trigger: z.ZodOptional; automationId: z.ZodOptional; lineageId: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ runId: z.ZodString; kind: z.ZodEnum<["schedule", "host-event", "external"]>; automationId: z.ZodOptional; lineageId: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ runId: z.ZodString; kind: z.ZodEnum<["schedule", "host-event", "external"]>; automationId: z.ZodOptional; lineageId: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; turnId: z.ZodOptional; clientId: z.ZodOptional; tool: z.ZodOptional; risk: z.ZodOptional>; inputPreview: z.ZodOptional; outcome: z.ZodOptional>; decidedBy: z.ZodOptional>; detail: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; at: z.ZodString; kind: z.ZodEnum<["tool-call", "approval", "policy-decision", "run", "app-lifecycle", "share", "door-auth", "principal"]>; principal: z.ZodObject<{ kind: z.ZodEnum<["user", "org"]>; subject: z.ZodString; display: z.ZodOptional; ephemeral: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodEnum<["user", "org"]>; subject: z.ZodString; display: z.ZodOptional; ephemeral: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodEnum<["user", "org"]>; subject: z.ZodString; display: z.ZodOptional; ephemeral: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; venue: z.ZodEnum<["chat", "app", "automation", "mcp"]>; presence: z.ZodEnum<["present", "away"]>; appId: z.ZodOptional; trigger: z.ZodOptional; automationId: z.ZodOptional; lineageId: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ runId: z.ZodString; kind: z.ZodEnum<["schedule", "host-event", "external"]>; automationId: z.ZodOptional; lineageId: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ runId: z.ZodString; kind: z.ZodEnum<["schedule", "host-event", "external"]>; automationId: z.ZodOptional; lineageId: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; turnId: z.ZodOptional; clientId: z.ZodOptional; tool: z.ZodOptional; risk: z.ZodOptional>; inputPreview: z.ZodOptional; outcome: z.ZodOptional>; decidedBy: z.ZodOptional>; detail: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>;