AgentForge.Runtime (AgentForge v0.1.0)
View SourceProvides the runtime environment for executing flows in the AgentForge system.
Summary
Functions
Creates a new runtime configuration for a flow. This allows storing configuration that can be reused for multiple executions.
Creates a new runtime configuration that maintains state between executions. Similar to configure/2 but automatically stores and retrieves state.
Executes a flow with the given signal and options. Returns the result of processing the flow.
Types
Functions
@spec configure(AgentForge.Flow.flow(), runtime_options()) :: (AgentForge.Signal.t() -> {:ok, term(), term()} | {:error, term()})
Creates a new runtime configuration for a flow. This allows storing configuration that can be reused for multiple executions.
Examples
iex> handler = fn signal, state ->
...> {AgentForge.Signal.emit(:done, signal.data), state}
...> end
iex> runtime = AgentForge.Runtime.configure([handler], debug: true, name: "test_flow")
iex> is_function(runtime, 1)
true
@spec configure_stateful(AgentForge.Flow.flow(), runtime_options()) :: (AgentForge.Signal.t() -> {:ok, term(), term()} | {:error, term()})
Creates a new runtime configuration that maintains state between executions. Similar to configure/2 but automatically stores and retrieves state.
Examples
iex> increment = fn _signal, state ->
...> count = Map.get(state, :count, 0) + 1
...> {AgentForge.Signal.emit(:count, count), Map.put(state, :count, count)}
...> end
iex> runtime = AgentForge.Runtime.configure_stateful([increment],
...> store_key: :counter,
...> debug: true
...> )
iex> is_function(runtime, 1)
true
@spec execute(AgentForge.Flow.flow(), AgentForge.Signal.t(), runtime_options()) :: {:ok, AgentForge.Signal.t() | term(), term()} | {:error, term()}
Executes a flow with the given signal and options. Returns the result of processing the flow.
Options
:debug- Enables debug logging (default: false):name- Name for the flow execution (default: "flow"):store_prefix- Prefix for store keys (default: "flow"):store_name- Name of the store to use (optional)
Examples
iex> handler = fn signal, state ->
...> {AgentForge.Signal.emit(:done, "Processed: " <> signal.data), state}
...> end
iex> {:ok, result, _state} = AgentForge.Runtime.execute([handler],
...> AgentForge.Signal.new(:start, "test"),
...> debug: true
...> )
iex> result.data
"Processed: test"