import { z } from "zod"; import { type AppId, type ApprovalId, type GrantId, type IsoDateTime, 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 ToolCall, type ToolDescriptor, type ToolOutcome } from "./tools.js"; /** 01-core §5, amended 2026-08-03 (connector discovery) — `service-tool` is a * third width between the two the contract froze. * * `tool` and `exact` are the two widths a HOST tool has: this whole tool, or * this one payload. The connector dispatcher ({@link USE_SERVICE_TOOL}) has * neither, because its tool name is not its action: `tool` on it would be * consent to a third-party catalog of ~20,000 actions, and `exact` would be a * permission good for one payload and useless on the next run. `service-tool` * is the missing middle — ONE service action, any arguments — which is exactly * the width `tool` has on a host tool, measured at the level a person can * actually consent to. */ export type GrantScope = { kind: "tool"; } | { kind: "exact"; inputHash: string; inputPreview: string; } | { kind: "service-tool"; slug: string; }; /** 01-core §5 */ export declare const grantScopeSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; /** The service action a call names, or undefined for every call that is not a * connector dispatch. The one place the dispatcher's argument shape is read as * authority, so the grant law, the arm-time capture, and the mint cannot * disagree about what was consented to. */ export declare function serviceToolSlug(call: Pick): string | undefined; /** A service action in a person's words — `GMAIL_SEND_EMAIL` → "send email in * Gmail" — for the consent sentence, which may never print a raw identifier at * someone (design §3's voice law). * * DISPLAY ONLY. Nothing about authority or risk is ever read out of a name * (#747 deleted the word lists on purpose) — the grade comes from the broker's * own per-tool tag through the risk resolver. Chrome holds the brand table * ("googlecalendar" → "Google Calendar") and renders the richer label beside a * logo; this is the plain sentence the engine can write with no UI on hand. */ export declare function serviceToolPhrase(slug: string): string; /** 01-core §5 */ export type GrantDuration = "standing" | "session" | "task"; /** 01-core §5 */ export declare const grantDurationSchema: z.ZodEnum<["standing", "session", "task"]>; /** 01-core §5 */ export interface PermissionGrant { id: GrantId; subject: string; tool: string; descriptorHash: string; scope: GrantScope; duration: GrantDuration; contextKey?: string; appId?: AppId; /** * WHICH automation this grant is for. Each record is consented to on its own, * so a grant minted while arming one never authorizes another and the * fire-time lookup matches on this alone — an automation record holds no app * reference for `appId` to pair with. Absent on every grant that is not an * automation's. */ automationId?: string; /** * How this grant was minted. `"mcp"` is additive (same mechanism the door * wave used for `AuditEvent.kind: "door-auth"`, 01-core §15) and has exactly * one mint point: the actions-side projection of the door's OAuth consent * (10-mcp §3) — the per-call, honestly-labeled authority handed to `actAs` * for venue="mcp" host execution. It is never persisted and never consulted * by guard; the other sources are minted from in-product decisions. * * `"approval"` is the other projection of that kind, and the same three things * are true of it: one mint point (the guard's `#grantForExecution`, when an * away call runs on a CONSUMED approval), never persisted, never matched. It * says what it is — the person's tap on this one call — so a host reading it * in `actAs` is told the authority is one allowed call, not a standing yes. */ source: "chat" | "batch" | "automation" | "mcp" | "approval"; grantedAt: IsoDateTime; expiresAt?: IsoDateTime; revokedAt?: IsoDateTime; } /** 01-core §5 */ export declare const permissionGrantSchema: z.ZodObject<{ id: z.ZodString; subject: z.ZodString; tool: z.ZodString; descriptorHash: z.ZodString; scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; contextKey: z.ZodOptional; appId: z.ZodOptional; automationId: z.ZodOptional; source: z.ZodEnum<["chat", "batch", "automation", "mcp", "approval"]>; grantedAt: z.ZodString; expiresAt: z.ZodOptional; revokedAt: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; subject: z.ZodString; tool: z.ZodString; descriptorHash: z.ZodString; scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; contextKey: z.ZodOptional; appId: z.ZodOptional; automationId: z.ZodOptional; source: z.ZodEnum<["chat", "batch", "automation", "mcp", "approval"]>; grantedAt: z.ZodString; expiresAt: z.ZodOptional; revokedAt: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; subject: z.ZodString; tool: z.ZodString; descriptorHash: z.ZodString; scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; contextKey: z.ZodOptional; appId: z.ZodOptional; automationId: z.ZodOptional; source: z.ZodEnum<["chat", "batch", "automation", "mcp", "approval"]>; grantedAt: z.ZodString; expiresAt: z.ZodOptional; revokedAt: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; /** What `GET /approvals/:id` answers for a parked guarded call: the frozen * approval-embed vocabulary, carrying the full request while pending (so the * consent card can show real inputs) and the resumed call's outcome once * executed — errors included, which the embed renders with the failed * vocabulary rather than a blank. * * The request is absent where the ask is gone but the answer is not in yet — * an in-app parked press during the resume window, or a door-parked call whose * yes is in and whose caller has not retried. Surfaces keep waiting on it. The * outcome is absent for that same door lane: nothing server-side ran the call, * so "it ran" is all its receipt can say. */ export type ApprovalResolution = { state: "pending"; request?: ApprovalRequest; } | { state: "executed"; outcome?: ToolOutcome; } | { state: "declined"; } | { state: "expired"; }; /** 01-core §5 */ export interface ApprovalRequest { id: ApprovalId; call: ToolCall; descriptor: ToolDescriptor; inputPreview: string; /** * The standing powers ONE yes to this ask mints — human tool TITLES, never * identifiers. * * Present only on an ask that is a consent moment for work nobody has asked * for yet: arming an automation (07 §3), where the yes authorizes calls the * agent will make at 2am. That ask parks BEFORE the record exists, so the set * is computed at park time and rides here — which is the whole point of * putting it on the request rather than in a renderer. Every surface (a text, * a card, a console feed) names the same powers because there is one * computation, and a surface that has not learned to render them simply shows * the ask it always showed. * * Absent on every ordinary ask, where the call in hand IS the whole of what is * being allowed. */ powers?: string[]; invalidatedGrant?: { id: GrantId; grantedAt: IsoDateTime; }; ctx: { principal: Principal; venue: RunContext["venue"]; presence: RunContext["presence"]; /** The conversation that parked it (`RunContext.sessionId`) — the identity * approval delivery is scoped by. Optional only because rows persisted * before it existed can't carry it; every new park writes it, and * scoped consumers fail closed on its absence. */ sessionId?: string; /** The TURN that parked it (`RunContext.turnId`) — the id * `turns.resume(turnId, …)` addresses, and the same join key every audit * row this turn wrote already carries. Without it a parked call is * findable only as one of a subject's asks, and a caller holding the id * their interrupted turn returned has nothing to look it up by. Optional * because a park outside a turn (a door-side check, a row written before * this field existed) has no turn to name. */ turnId?: TurnId; /** The AGENT that parked it (`RunContext.agent`) — the axis a turn is * answered on. Two agents over one store share this collection and mount * descriptors that hash identically, so without it a yes to one agent's * ask dispatched the other's same-named tool. Optional because a park * outside an agent (a door-side check, a row written before this field * existed) has none; scoped consumers fail closed on its absence. */ agent?: string; appId?: AppId; trigger?: TriggerRef; }; createdAt: IsoDateTime; } /** 01-core §5 */ export declare const approvalRequestSchema: z.ZodObject<{ id: z.ZodString; call: z.ZodObject<{ id: z.ZodString; tool: z.ZodString; args: z.ZodType<{}, z.ZodTypeDef, {}>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodType<{}, z.ZodTypeDef, {}>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodType<{}, z.ZodTypeDef, {}>; }, z.ZodTypeAny, "passthrough">>; descriptor: z.ZodObject<{ name: z.ZodString; description: z.ZodString; inputSchema: z.ZodRecord; outputSchema: z.ZodOptional>; risk: z.ZodEnum<["read", "write", "destructive", "ungraded"]>; confirmEach: z.ZodOptional; title: z.ZodOptional; toolkit: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodString; description: z.ZodString; inputSchema: z.ZodRecord; outputSchema: z.ZodOptional>; risk: z.ZodEnum<["read", "write", "destructive", "ungraded"]>; confirmEach: z.ZodOptional; title: z.ZodOptional; toolkit: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodString; description: z.ZodString; inputSchema: z.ZodRecord; outputSchema: z.ZodOptional>; risk: z.ZodEnum<["read", "write", "destructive", "ungraded"]>; confirmEach: z.ZodOptional; title: z.ZodOptional; toolkit: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; inputPreview: z.ZodString; powers: z.ZodOptional>; invalidatedGrant: z.ZodOptional, z.objectInputType<{ id: z.ZodString; grantedAt: z.ZodString; }, z.ZodTypeAny, "passthrough">>>; ctx: z.ZodObject<{ 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"]>; sessionId: z.ZodOptional; turnId: z.ZodOptional; agent: z.ZodOptional; 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">>>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ 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"]>; sessionId: z.ZodOptional; turnId: z.ZodOptional; agent: z.ZodOptional; 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">>>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ 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"]>; sessionId: z.ZodOptional; turnId: z.ZodOptional; agent: z.ZodOptional; 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">>>; }, z.ZodTypeAny, "passthrough">>; createdAt: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; call: z.ZodObject<{ id: z.ZodString; tool: z.ZodString; args: z.ZodType<{}, z.ZodTypeDef, {}>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodType<{}, z.ZodTypeDef, {}>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodType<{}, z.ZodTypeDef, {}>; }, z.ZodTypeAny, "passthrough">>; descriptor: z.ZodObject<{ name: z.ZodString; description: z.ZodString; inputSchema: z.ZodRecord; outputSchema: z.ZodOptional>; risk: z.ZodEnum<["read", "write", "destructive", "ungraded"]>; confirmEach: z.ZodOptional; title: z.ZodOptional; toolkit: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodString; description: z.ZodString; inputSchema: z.ZodRecord; outputSchema: z.ZodOptional>; risk: z.ZodEnum<["read", "write", "destructive", "ungraded"]>; confirmEach: z.ZodOptional; title: z.ZodOptional; toolkit: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodString; description: z.ZodString; inputSchema: z.ZodRecord; outputSchema: z.ZodOptional>; risk: z.ZodEnum<["read", "write", "destructive", "ungraded"]>; confirmEach: z.ZodOptional; title: z.ZodOptional; toolkit: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; inputPreview: z.ZodString; powers: z.ZodOptional>; invalidatedGrant: z.ZodOptional, z.objectInputType<{ id: z.ZodString; grantedAt: z.ZodString; }, z.ZodTypeAny, "passthrough">>>; ctx: z.ZodObject<{ 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"]>; sessionId: z.ZodOptional; turnId: z.ZodOptional; agent: z.ZodOptional; 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">>>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ 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"]>; sessionId: z.ZodOptional; turnId: z.ZodOptional; agent: z.ZodOptional; 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">>>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ 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"]>; sessionId: z.ZodOptional; turnId: z.ZodOptional; agent: z.ZodOptional; 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">>>; }, z.ZodTypeAny, "passthrough">>; createdAt: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; call: z.ZodObject<{ id: z.ZodString; tool: z.ZodString; args: z.ZodType<{}, z.ZodTypeDef, {}>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodType<{}, z.ZodTypeDef, {}>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodType<{}, z.ZodTypeDef, {}>; }, z.ZodTypeAny, "passthrough">>; descriptor: z.ZodObject<{ name: z.ZodString; description: z.ZodString; inputSchema: z.ZodRecord; outputSchema: z.ZodOptional>; risk: z.ZodEnum<["read", "write", "destructive", "ungraded"]>; confirmEach: z.ZodOptional; title: z.ZodOptional; toolkit: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodString; description: z.ZodString; inputSchema: z.ZodRecord; outputSchema: z.ZodOptional>; risk: z.ZodEnum<["read", "write", "destructive", "ungraded"]>; confirmEach: z.ZodOptional; title: z.ZodOptional; toolkit: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodString; description: z.ZodString; inputSchema: z.ZodRecord; outputSchema: z.ZodOptional>; risk: z.ZodEnum<["read", "write", "destructive", "ungraded"]>; confirmEach: z.ZodOptional; title: z.ZodOptional; toolkit: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; inputPreview: z.ZodString; powers: z.ZodOptional>; invalidatedGrant: z.ZodOptional, z.objectInputType<{ id: z.ZodString; grantedAt: z.ZodString; }, z.ZodTypeAny, "passthrough">>>; ctx: z.ZodObject<{ 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"]>; sessionId: z.ZodOptional; turnId: z.ZodOptional; agent: z.ZodOptional; 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">>>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ 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"]>; sessionId: z.ZodOptional; turnId: z.ZodOptional; agent: z.ZodOptional; 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">>>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ 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"]>; sessionId: z.ZodOptional; turnId: z.ZodOptional; agent: z.ZodOptional; 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">>>; }, z.ZodTypeAny, "passthrough">>; createdAt: z.ZodString; }, z.ZodTypeAny, "passthrough">>; /** * The refs projection every `vendo_approvals` row carries, so ref-filtered * listings — the guard's pending feed, its abandoned-ask sweep — can see the * row on ANY StoreAdapter. One helper because the collection has more than * one writer (the guard's park, the automations arming capture): reserved * store tables derive these from the row's own columns, but a generic * adapter honors exactly what a writer passes, and a writer that skips them * mints asks no listing can return and no sweep can expire (field: linkwarden * 2026-08-09 — an automation counted pending grants nobody could see or pay). */ export declare function approvalRecordRefs(request: ApprovalRequest, status: "pending" | "approved" | "denied"): Record; /** * Everything a mint is told. The subject, the tool, the descriptor hash and the * app are read off the approved REQUEST and never off the caller, so a grant is * bound to exactly what the person was shown. */ export interface MintGrantInput { request: ApprovalRequest; /** An omitted `scope` is derived: a connector dispatch is granted at the width * of its SLUG — "allow use_service_tool" would be consent to the broker's * whole catalog — and every other tool tool-wide. */ remember: { duration: GrantDuration; scope?: GrantScope; }; source: PermissionGrant["source"]; /** WHICH automation this is for; omitted ⇒ not an automation's grant. */ automationId?: string; /** `session`/`task` durations only; omitted ⇒ the request's runId ?? sessionId. */ contextKey?: string; } /** * The ONE grant row. The guard's decide path and the automations engine's * consent moment both mint through here, so a grant cannot mean two things * depending on which of them wrote it. */ export declare function buildGrant({ request, remember, source, automationId, contextKey }: MintGrantInput, id: GrantId, grantedAt: IsoDateTime): PermissionGrant; /** * The refs projection every `vendo_grants` row carries. The same reason * {@link approvalRecordRefs} exists: reserved store tables derive these from the * row's own columns, but a generic adapter honors exactly what a writer passes * — and one that filtered on `app_id` alone would hand back a SIBLING trigger's * grant, making the ref-trusting adapter wider than the JS filter above it. */ export declare function grantRefs(grant: PermissionGrant): Record; /** 01-core §5 */ export interface ApprovalDecision { approve: boolean; remember?: { scope: GrantScope; duration: GrantDuration; }; } /** 01-core §5 */ export declare const approvalDecisionSchema: z.ZodObject<{ approve: z.ZodBoolean; remember: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; }, z.ZodTypeAny, "passthrough">>>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ approve: z.ZodBoolean; remember: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ approve: z.ZodBoolean; remember: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"tool">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"tool">; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"exact">; inputHash: z.ZodString; inputPreview: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"service-tool">; slug: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; duration: z.ZodEnum<["standing", "session", "task"]>; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">>;