Synaptic (synaptic v0.3.0-alpha.8)

View Source

Synaptic provides a declarative workflow engine with a DSL for orchestrating LLM-backed steps, human-in-the-loop pauses, and resumable executions.

Summary

Functions

Calls a registered service/instance/task reference through the agent router.

Returns the status of an async agent job.

Starts an asynchronous routed job and returns a job handle.

Attaches a voice session to an already running workflow run.

Returns the step-level history collected for a workflow run.

Returns a snapshot of the current workflow state for a run id.

Returns a list of currently running workflows with their run ids, workflow module, and snapshot context.

Lists task references for a user from the built-in task reference memory.

Registers an agent/service definition in the directory.

Resumes a previously suspended workflow run with the supplied payload.

Starts a workflow module with the provided input context.

Starts a voice session and a workflow run in one call.

Stops a running workflow. Returns :ok when the runner terminates or {:error, :not_found} if the run id is unknown.

Subscribes the calling process to PubSub events for the given run_id.

Unsubscribes the calling process from workflow events for the given run_id.

Fetches the compiled workflow definition for a module.

Functions

agent_call(target, payload, opts \\ [])

Calls a registered service/instance/task reference through the agent router.

agent_job_status(job_id, opts \\ [])

Returns the status of an async agent job.

agent_start_job(target, payload, opts \\ [])

Starts an asynchronous routed job and returns a job handle.

attach_voice_session(run_id, opts \\ [])

Attaches a voice session to an already running workflow run.

history(run_id)

Returns the step-level history collected for a workflow run.

inspect(run_id, timeout \\ 5000)

Returns a snapshot of the current workflow state for a run id.

Options

  • :timeout - Timeout in milliseconds for the snapshot call (default: 5000). Use :infinity to wait indefinitely.

list_runs()

Returns a list of currently running workflows with their run ids, workflow module, and snapshot context.

list_user_agent_tasks(user_id, filters \\ %{}, opts \\ [])

Lists task references for a user from the built-in task reference memory.

register_agent_service(service_id, spec, opts \\ [])

Registers an agent/service definition in the directory.

resume(run_id, payload)

Resumes a previously suspended workflow run with the supplied payload.

start(workflow_module, input \\ %{}, opts \\ [])

Starts a workflow module with the provided input context.

Options

  • :run_id - Custom run ID (defaults to auto-generated)
  • :start_at_step - Start execution at a specific step by name (atom). The step must exist in the workflow definition. The provided context should contain all data that would have been accumulated up to that step.

Examples

# Start from the beginning (default)
{:ok, run_id} = Synaptic.start(MyWorkflow, %{initial: :data})

# Start at a specific step with pre-populated context
{:ok, run_id} = Synaptic.start(MyWorkflow, %{precomputed: :value}, start_at_step: :middle_step)

start_voice_session(workflow_module, input \\ %{}, opts \\ [])

Starts a voice session and a workflow run in one call.

stop(run_id, reason \\ :canceled)

Stops a running workflow. Returns :ok when the runner terminates or {:error, :not_found} if the run id is unknown.

subscribe(run_id)

Subscribes the calling process to PubSub events for the given run_id.

Events are delivered as {:synaptic_event, %{run_id: ..., event: ...}} tuples.

unsubscribe(run_id)

Unsubscribes the calling process from workflow events for the given run_id.

workflow_definition(module)

Fetches the compiled workflow definition for a module.