import { z } from "zod"; import type { ApprovalRequest } from "./grants.js"; import { type IsoDateTime, type RunId } from "./ids.js"; import { type Principal } from "./principal.js"; import type { RunContext } from "./run-context.js"; import type { ToolOutcome } from "./tools.js"; import { type Step, type TriggerSource } from "./triggers.js"; /** `atm_<32 hex>` when minted, `atm_` or * `atm_` when a code/manifest declaration names its own identity — * the identity a reconcile matches on. */ export type AutomationId = string; /** The inline budget shape `RunModel` used to carry, named because four surfaces * now pass it by name. */ export interface Budget { maxToolCalls?: number; } /** The AUTHORING input — all five `.on()` shapes and the chat tool's `when`. * A bare string is a cron expression, validated at declaration. */ export type When = string | { every: string; } | { at: IsoDateTime; } | { event: string; } | { webhook: string; }; /** What a record RUNS. `"goal"` goes to the named runner; `"steps"` runs in the * engine's own process. */ export type AutomationTask = { kind: "goal"; prompt: string; budget?: Budget; } | { kind: "steps"; steps: Step[]; }; /** * THE record. * * INVARIANT: no app reference of any kind. A task reaches an app only by naming * one of its functions as an ordinary granted tool inside `task`, so an app that * is deleted fails at tool resolution — loudly, in the run ledger — rather than * leaving a dangling field here. */ export interface AutomationRecord { id: AutomationId; owner: Principal; when: TriggerSource; task: AutomationTask; /** Runner-map name. Absent → {@link DEFAULT_RUNNER_NAME}. Steps never carry one. */ agent?: string; armed: boolean; authoredBy: "chat" | "code" | "manifest"; /** Cron/`every` are evaluated in this zone; absent → UTC. */ timezone?: string; /** The grant SET this record's standing grants belong to, so one decision can * settle every ask. The grants themselves are `vendo_grants` rows keyed to * `automation_id` — never inlined here. */ grantSetId?: string; /** External records only: the standard-webhooks HMAC key, base64url, minted at * create. Redacted by list/get; only the webhook door reads it. */ webhookSecret?: string; /** Set when a PERSON disarmed it. {@link reconcileAutomations} never re-arms a * record carrying this — the manual kill switch survives every redeploy. */ disarmedBy?: "user"; createdAt: IsoDateTime; updatedAt: IsoDateTime; } /** The budget shape, beside its interface like every other core schema. */ export declare const budgetSchema: z.ZodObject<{ maxToolCalls: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; export declare const automationTaskSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">>]>; export declare const automationRecordSchema: z.ZodObject<{ id: z.ZodString; owner: 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">>; when: z.ZodEffects; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>]>, z.objectOutputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | z.objectInputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough"> | z.objectInputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; task: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">>]>; agent: z.ZodOptional; armed: z.ZodBoolean; authoredBy: z.ZodEnum<["chat", "code", "manifest"]>; timezone: z.ZodOptional; grantSetId: z.ZodOptional; webhookSecret: z.ZodOptional; disarmedBy: z.ZodOptional>; createdAt: z.ZodString; updatedAt: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; owner: 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">>; when: z.ZodEffects; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>]>, z.objectOutputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | z.objectInputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough"> | z.objectInputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; task: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">>]>; agent: z.ZodOptional; armed: z.ZodBoolean; authoredBy: z.ZodEnum<["chat", "code", "manifest"]>; timezone: z.ZodOptional; grantSetId: z.ZodOptional; webhookSecret: z.ZodOptional; disarmedBy: z.ZodOptional>; createdAt: z.ZodString; updatedAt: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; owner: 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">>; when: z.ZodEffects; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>]>, z.objectOutputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"schedule">; cron: z.ZodOptional; every: z.ZodOptional; at: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | z.objectInputType<{ kind: z.ZodLiteral<"host-event">; event: z.ZodString; }, z.ZodTypeAny, "passthrough"> | z.objectInputType<{ kind: z.ZodLiteral<"external">; connector: z.ZodString; event: z.ZodOptional; config: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; task: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"goal">; prompt: z.ZodString; budget: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ maxToolCalls: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ kind: z.ZodLiteral<"steps">; steps: z.ZodArray>; if: z.ZodOptional; forEach: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; tool: z.ZodString; args: z.ZodOptional>; if: z.ZodOptional; forEach: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">>]>; agent: z.ZodOptional; armed: z.ZodBoolean; authoredBy: z.ZodEnum<["chat", "code", "manifest"]>; timezone: z.ZodOptional; grantSetId: z.ZodOptional; webhookSecret: z.ZodOptional; disarmedBy: z.ZodOptional>; createdAt: z.ZodString; updatedAt: z.ZodString; }, z.ZodTypeAny, "passthrough">>; /** 07 §5 — a RUN's lifecycle. There is no waiting state: a run that meets a * permission it does not hold fails LOUDLY (`error`, code `needs-permission`) * and the person grants it and re-runs. A run that could be resumed later was a * run nobody could see the end of — it held an approval open, an identity open, * and an intent open across an unbounded gap. * * Here rather than in the automations engine because `@vendoai/vendo/store` persists * these rows and may not import that package (dependency-guard). */ export declare const RUN_STATUSES: readonly ["running", "ok", "error", "stopped"]; export type RunStatus = (typeof RUN_STATUSES)[number]; /** The engine's four plus `pending-approval`, which no engine writes: the STORE * is the wider acceptor here, and `parseRunData` has taken it since before the * ledger dropped its waiting state. Derived from the tuple above so the four * can never drift, and narrowing it would be a behaviour change, not a * consolidation. * * Here rather than in `@vendoai/vendo/store` for the same reason `RUN_STATUSES` is * here: the readers of this ledger live outside the store — Vendo Cloud's * console validates a `?status=` query param against it — and console code * consumes contracts from this package, never the store implementation. A * reader narrower than the acceptor refuses rows the store will happily hold. */ export declare const RUN_ROW_STATUSES: readonly ["running", "ok", "error", "stopped", "pending-approval"]; export type RunRowStatus = (typeof RUN_ROW_STATUSES)[number]; /** 07 §5 — ONE ledger. The owner / agent / automation / console views are * FILTERS over it, never separate tables. The automations engine serves these * rows and `@vendoai/vendo/ui` renders them; neither may import the other. */ export interface RunRecord { id: RunId; automationId: AutomationId; /** Who it ran as — the filter every owner-scoped view reads. */ owner: Principal; /** Which runner ran it; absent for a steps task. */ agent?: string; trigger: { kind: TriggerSource["kind"]; event?: string; }; /** The ACCEPTOR's width, not the engine's four: no engine writes * `pending-approval` but the ledger stores it, and a reader narrower than * its writer drops real rows. */ status: RunRowStatus; startedAt: IsoDateTime; finishedAt?: IsoDateTime; /** Goal runs: the report's toolCalls. Steps: one per call. */ steps: Array<{ id: string; tool: string; outcome: ToolOutcome["status"]; at: IsoDateTime; detail?: string; }>; /** Goal: model-written; steps: generated. */ summary?: string; /** `code: "needs-permission"` is the one a surface acts on: the run met a * permission nobody had granted, the ask is pending, and `tool`/`slug` name * exactly what it needed — so the row can offer Grant & re-run instead of * making the person go looking. */ error?: { code: string; message: string; tool?: string; slug?: string; }; } /** 07 §5 — what `POST /automations/:id/dry-run` answers. */ export interface RunPlan { steps: Array<{ id: string; tool: string; wouldAsk: boolean; }>; grantsMissing: string[]; } /** 07 §1 — what `POST /automations/:id/enable` answers. `grantSetId` names the * ONE set the `missing` asks belong to, so a single decision settles them all; * present exactly when `missing` is non-empty. */ export interface EnableResult { enabled: boolean; missing: ApprovalRequest[]; grantSetId?: string; } /** 07 §1 — one entry of `GET /automations`: the record itself, with * `webhookSecret` redacted by the server on every read. */ export type AutomationEntry = AutomationRecord; /** THE one create operation, as a type — the implementation is * `packages/vendo/src/automations/create-surface.ts`, reached through * `automationsInternals(engine)` and never exposed on `vendo.automations`. * Named here so the app-generation code can hold one without importing the * automations engine it is composed beside. */ export type CreateAutomation = (input: CreateAutomationInput, ctx: RunContext) => Promise; export interface CreateAutomationInput { /** Declared identity. Absent → minted. Present and already stored → that * record is REPLACED, which is what makes a redeploy idempotent. */ id?: AutomationId; owner: Principal; when: When; task: AutomationTask; agent?: string; timezone?: string; authoredBy: AutomationRecord["authoredBy"]; /** `false` creates it disarmed; absent → armed. */ armed?: boolean; } /** Where a rejected declaration sends its author. The docs are their own host — * `vendo.run/docs/**` is a 404, so a refusal built on it sends the developer to * a dead page. */ export declare const AUTOMATIONS_DOCS_URL = "https://docs.vendo.run/capabilities/automations"; /** ``, or null. The tick reads it too, so it is stated once here * rather than once per package. */ export declare const durationMs: (value: string) => number | null; /** * The ONE converter from the authoring shape to the stored one. All four * authoring doors call it, so a cron nobody can run is refused at DECLARATION — * synchronously, before the process serves anything — rather than at 2am. */ export declare function toTriggerSource(when: When): TriggerSource; /** * The content identity of a record: sha256 over the RFC 8785 canonical form of * what it DOES. * * One hash, two jobs, and they must not disagree. It mints the default id for a * declaration (so editing the cron or the words is a NEW automation and the old * one is disarmed), and it is the intent an owner's sponsorship is bound to (so * a record whose content changed under a live sponsorship stops loudly). */ export declare function automationHash(content: { when: TriggerSource; task: AutomationTask; agent?: string; timezone?: string; }): string; /** What `.on()` and the manifest fold-in collected. */ export interface DeclaredAutomation { /** Stable identity; absent → {@link automationHash}. */ id?: string; when: When; task: AutomationTask; agent?: string; timezone?: string; } export interface ReconcilePlan { /** New, and changed (the changed one's new identity). */ create: CreateAutomationInput[]; /** Removed from code, and the superseded identities of changed ones. Consent * was the code; the code no longer says it, so it is DISARMED — never * deleted, so its run history survives. */ disarm: AutomationId[]; } /** The id a declaration takes: its own name, or its content hash. */ export declare const declaredAutomationId: (declared: DeclaredAutomation, when: TriggerSource) => AutomationId; /** * Declared-vs-stored, as a pure diff — no I/O, no store, no engine. `agent.on`'s * boot reconcile and the `vendo.json` manifest fold-in both drive the engine's * create/disable operations from this ONE plan. * * `stored` is filtered to the same author and owner before diffing: a code * reconcile never touches a chat-authored record. A record a PERSON disarmed is * left alone entirely — the kill switch survives every redeploy. */ export declare function reconcileAutomations(declared: readonly DeclaredAutomation[], stored: readonly AutomationRecord[], owner: Principal, authoredBy: "code" | "manifest"): ReconcilePlan;