Interactive approval scripts for agents.
An agent submits a small, non-Turing-complete script (endpoint preamble, typed variables, steps with conditionals, declared outputs); a human drives it call-by-call — step / next / run-all / edit / halt — with breakpoints and scoped allow/block permission rules. The structured result (per-step outcomes, notes, edit diffs, outputs, halt reason, grants) returns to the calling agent.
{:ok, script} = GenAI.Approval.load(source)
{:ok, run} =
GenAI.Approval.start_run(script,
executors: %{"notify" => {GenAI.Approval.Executor.Local, handlers}},
subscriber: self(),
permission: [store: {Store.ETS, MyStore}, subject: "keith", session_id: "sess-1"]
)
:ok = GenAI.Approval.command(run, :step)
{:ok, result} = GenAI.Approval.await(run)
Summary
Functions
Block until the run terminates; returns {:ok, result} (PRD §9 contract).
Issue a control command to a run (pid or run id).
Replay buffer of run events (oldest first, bounded ring).
Snapshot of run status.
Parse + statically check a script source.
UI-facing state snapshot; feed to GenAI.Approval.Render.model/1.
Start an interactive run under the library's supervisor.
Add a live event subscriber (defaults to the caller).
Functions
Block until the run terminates; returns {:ok, result} (PRD §9 contract).
Issue a control command to a run (pid or run id).
Replay buffer of run events (oldest first, bounded ring).
Snapshot of run status.
@spec load( String.t(), keyword() ) :: {:ok, GenAI.Approval.Script.t()} | {:error, [GenAI.Approval.Error.t()]}
Parse + statically check a script source.
Options: :max_script_size (bytes, default 64 KiB), :max_steps
(default 50). Returns {:ok, %Script{}} or {:error, [%Error{}]}.
UI-facing state snapshot; feed to GenAI.Approval.Render.model/1.
@spec start_run( GenAI.Approval.Script.t(), keyword() ) :: {:ok, pid()} | {:error, term()}
Start an interactive run under the library's supervisor.
Options (see GenAI.Approval.Runner): :executors (required — map of
endpoint alias to {module, config}), :subscriber, :variables,
:permission, :budgets, :run_id.
Add a live event subscriber (defaults to the caller).