Vibe.Session (vibe v0.2.1)

Copy Markdown View Source

Server-owned Vibe session process.

A session owns semantic UI state, accepts UI-neutral commands, emits events to subscribers, and delegates model work through an injectable ask function. TUI and LiveView clients attach to the same session model instead of owning the conversation themselves.

Sessions are supervised and can be looked up, attached, detached, searched, and restored from durable SQLite-backed event history.

Summary

Types

ask_fun()

@type ask_fun() :: (String.t(), keyword() -> {:ok, term()} | {:error, term()})

Functions

active_count()

@spec active_count() :: non_neg_integer()

Intentional facade for the public Vibe API boundary.

agent_ask_opts(opts)

@spec agent_ask_opts(keyword()) :: keyword()

Returns prompt options passed to the agent after session-only keys are removed.

attach(server, pid \\ self(), opts \\ [])

@spec attach(GenServer.server(), pid(), keyword()) ::
  {:ok, Vibe.UI.State.t(), non_neg_integer()}

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

detach(server, pid \\ self())

@spec detach(GenServer.server(), pid()) :: :ok

dispatch(server, command)

@spec dispatch(
  GenServer.server(),
  Vibe.Session.Command.Intent.t() | atom() | {atom(), map()}
) :: :ok

emit_event(server, event)

@spec emit_event(GenServer.server(), Vibe.Event.t()) :: :ok

emit_transient_event(server, event)

@spec emit_transient_event(GenServer.server(), Vibe.Event.t()) :: :ok

list(opts \\ [])

@spec list(keyword()) :: [map()]

Intentional facade for the public Vibe API boundary.

lock(server, job_id, owner \\ self())

@spec lock(GenServer.server(), String.t(), pid()) :: :ok

lookup(id)

@spec lookup(String.t()) :: {:ok, pid()} | {:error, :not_found}

search(query, opts \\ [])

@spec search(
  String.t(),
  keyword()
) :: [Vibe.Storage.Search.Result.t()]

start(opts \\ [])

@spec start(keyword()) :: {:ok, pid()} | {:error, term()}

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

state(server)

@spec state(GenServer.server()) :: Vibe.UI.State.t()

subscribe(server, pid \\ self())

@spec subscribe(GenServer.server(), pid()) :: :ok

unlock(server, job_id)

@spec unlock(GenServer.server(), String.t()) :: :ok