Jidoka.Session (Jidoka v0.8.0-beta.1)

Copy Markdown View Source

Ergonomic session facade backed by Jidoka.Harness.Session.

Jidoka.Harness.Session is the durable data contract. This module is the developer-facing API for starting, running, resuming, and inspecting sessions without reaching into the lower-level harness namespace for common workflows.

Summary

Functions

Waits for a request handle returned by chat_async/3.

Runs one turn for a session and returns final assistant text.

Starts one session chat turn asynchronously.

Fetches a persisted session from a configured session store.

Lists persisted sessions from a configured session store.

Lists pending human-review requests from a session or session store.

Returns a data-only replay view for a session.

Resumes the latest hibernated snapshot for a session.

Runs one turn for a session and returns the full harness result.

Starts a new session for an agent, spec, or plan.

Starts a new session with an explicit session id.

Writes one memory entry through the configured memory store.

Types

agent_input()

@type agent_input() :: module() | Jidoka.Harness.plan_input()

async_result()

@type async_result() :: {:ok, Jidoka.Chat.Request.t()} | {:error, term()}

chat_result()

@type chat_result() ::
  {:ok, t(), String.t()}
  | {:hibernate, t(), Jidoka.Runtime.AgentSnapshot.t()}
  | {:error, term()}

opts()

@type opts() :: keyword()

request_input()

@type request_input() :: Jidoka.Harness.request_input()

run_result()

@type run_result() :: Jidoka.Harness.session_run_result()

session_input()

@type session_input() :: Jidoka.Harness.session_input()

t()

@type t() :: Jidoka.Harness.Session.t()

Functions

await(request, opts \\ [])

@spec await(Jidoka.Chat.Request.t(), opts()) :: chat_result()

Waits for a request handle returned by chat_async/3.

chat(session_or_id, input, opts \\ [])

@spec chat(session_input(), String.t(), opts()) :: chat_result()

Runs one turn for a session and returns final assistant text.

The updated session is returned with the text so caller-managed sessions do not lose durable state when no store is configured.

chat_async(session_or_id, input, opts \\ [])

@spec chat_async(session_input(), String.t(), opts()) :: async_result()

Starts one session chat turn asynchronously.

Pass stream: true to stream request-scoped Jidoka.Event values to the caller mailbox while the request is running.

get(store, session_id)

@spec get(Jidoka.Harness.Store.store(), String.t()) :: {:ok, t()} | {:error, term()}

Fetches a persisted session from a configured session store.

list(store)

@spec list(Jidoka.Harness.Store.store()) :: {:ok, [t()]} | {:error, term()}

Lists persisted sessions from a configured session store.

pending_reviews(session_or_store)

@spec pending_reviews(t() | Jidoka.Harness.Store.store()) ::
  {:ok, [Jidoka.Review.Request.t()]} | {:error, term()}

Lists pending human-review requests from a session or session store.

replay(session)

@spec replay(t()) :: {:ok, Jidoka.Harness.Replay.t()} | {:error, term()}

Returns a data-only replay view for a session.

resume(session_or_id, opts \\ [])

@spec resume(session_input(), opts()) :: run_result()

Resumes the latest hibernated snapshot for a session.

run(session_or_id, request_input, opts \\ [])

@spec run(session_input(), request_input(), opts()) :: run_result()

Runs one turn for a session and returns the full harness result.

start(agent_or_plan, opts \\ [])

@spec start(agent_input(), opts() | String.t()) :: {:ok, t()} | {:error, term()}

Starts a new session for an agent, spec, or plan.

The returned value is a Jidoka.Harness.Session struct. A DSL agent module is accepted directly:

{:ok, session} = Jidoka.Session.start(MyApp.SupportAgent, "support-123")

Pass store: ... to persist the session immediately.

start(agent_or_plan, session_id, opts)

@spec start(agent_input(), String.t(), opts()) :: {:ok, t()} | {:error, term()}

Starts a new session with an explicit session id.

write_memory(session, content, opts \\ [])

@spec write_memory(t(), String.t(), opts()) ::
  {:ok, Jidoka.Memory.WriteResult.t()} | {:error, term()}

Writes one memory entry through the configured memory store.