Parlora.Backend behaviour (Parlora v0.1.0)

Copy Markdown View Source

Contract for application-owned work, independent of the voice provider.

Use a built-in adapter from Parlora.Backends.Jido, Parlora.Backends.Sagents, or Parlora.Backends.Legion, or implement this behaviour without an agent framework. Configure the session with backend: {module, options}.

Admission and completion are separate: submit/2 admits work, then the adapter emits correlated events containing the request/task/revision identities from Parlora.BackendRequest. Results carry verified application facts in Parlora.BackendResult. Cancellation may be advisory and never implies an undo.

Your application owns authorization, service timeouts, operation idempotency, and reconciliation of uncertain external effects. See the backend contract for callbacks and events.

Summary

Callbacks

cancel(pid, t, t, term)

@callback cancel(pid(), String.t(), String.t(), term()) ::
  :ok | {:error, Parlora.Error.t()}

capabilities(pid)

@callback capabilities(pid()) ::
  {:ok, Parlora.Backend.Capabilities.t()} | {:error, Parlora.Error.t()}

close(pid, t, term)

@callback close(pid(), String.t(), term()) :: :ok | {:error, Parlora.Error.t()}

start_link(t, keyword)

@callback start_link(Parlora.AdapterInit.t(), keyword()) ::
  {:ok, pid()} | {:error, Parlora.Error.t()}

submit(pid, t)

@callback submit(pid(), Parlora.BackendRequest.t()) :: :ok | {:error, Parlora.Error.t()}

update(pid, t, t, t)

@callback update(pid(), String.t(), String.t(), Parlora.BackendRequest.t()) ::
  :ok | {:error, Parlora.Error.t()}