GenAI.Approval.Host behaviour (GenAI Approval v0.1.0)

Copy Markdown View Source

Behaviour a host application implements to surface approval runs (PRD §7.2). Mirrors the proven park/respond split: the engine calls present/2 and streams on_event/3; the host answers by issuing GenAI.Approval.command/2.

Voice hosts implement this without any visual surface — the engine enforces confirm phrases and grant-scope acknowledgment regardless of presentation (R7.4).

Summary

Callbacks

A run is ready for the operator; return a handle for later events.

Resolve a preamble credential("id") reference to executor auth config.

Types

presentation_ref()

@type presentation_ref() :: term()

session_ctx()

@type session_ctx() :: term()

Callbacks

on_event(event, presentation_ref, session_ctx)

@callback on_event(event :: map(), presentation_ref(), session_ctx()) :: :ok

A run event (see GenAI.Approval.Runner event stream).

present(run_summary, session_ctx)

@callback present(run_summary :: map(), session_ctx()) ::
  {:ok, presentation_ref()} | {:error, term()}

A run is ready for the operator; return a handle for later events.

resolve_credential(credential_id, session_ctx)

(optional)
@callback resolve_credential(credential_id :: String.t(), session_ctx()) ::
  {:ok, term()} | {:error, :unknown_credential}

Resolve a preamble credential("id") reference to executor auth config.