# `AgentSessionManager.WorkflowBridge`
[🔗](https://github.com/nshkrdotcom/agent_session_manager/blob/v0.8.0/lib/agent_session_manager/workflow_bridge.ex#L1)

Thin integration layer for calling ASM from workflow/DAG engines.

WorkflowBridge adapts AgentSessionManager's API into workflow-friendly
primitives: step execution, normalized results, error classification,
and multi-run session lifecycle management.

This module does NOT depend on any external workflow library. It produces
data shapes that any workflow engine (Jido, Broadway, custom) can consume.

# `adapter`

```elixir
@type adapter() :: AgentSessionManager.SessionManager.adapter()
```

# `step_params`

```elixir
@type step_params() :: %{
  :input =&gt; map(),
  optional(:session_id) =&gt; String.t(),
  optional(:agent_id) =&gt; String.t(),
  optional(:context) =&gt; map(),
  optional(:metadata) =&gt; map(),
  optional(:tags) =&gt; [String.t()],
  optional(:continuation) =&gt; :auto | :replay | false,
  optional(:continuation_opts) =&gt; keyword(),
  optional(:adapter_opts) =&gt; keyword(),
  optional(:policy) =&gt; map(),
  optional(:workspace) =&gt; keyword(),
  optional(:event_callback) =&gt; (map() -&gt; any())
}
```

# `store`

```elixir
@type store() :: AgentSessionManager.SessionManager.store()
```

# `classify_error`

```elixir
@spec classify_error(AgentSessionManager.Core.Error.t()) ::
  AgentSessionManager.WorkflowBridge.ErrorClassification.t()
```

Classify an ASM error for workflow routing decisions.

Returns an `ErrorClassification` struct with:
- `retryable` - whether the error is retryable
- `category` - error category atom
- `recommended_action` - :retry, :failover, :wait_and_retry, :abort, or :cancel

# `complete_workflow_session`

```elixir
@spec complete_workflow_session(store(), String.t(), keyword()) ::
  :ok | {:error, AgentSessionManager.Core.Error.t()}
```

Complete or fail a shared workflow session.

With default opts, completes the session. Pass `status: :failed` and
optionally `error: %Error{}` to fail it.

Returns `:ok` or `{:error, Error.t()}`.

# `setup_workflow_session`

```elixir
@spec setup_workflow_session(store(), adapter(), map()) ::
  {:ok, String.t()} | {:error, AgentSessionManager.Core.Error.t()}
```

Create and activate a shared session for a multi-step workflow.

Returns `{:ok, session_id}` or `{:error, Error.t()}`.

# `step_execute`

```elixir
@spec step_execute(store(), adapter(), step_params()) ::
  {:ok, AgentSessionManager.WorkflowBridge.StepResult.t()}
  | {:error, AgentSessionManager.Core.Error.t()}
```

Execute a single workflow step via ASM.

When `params.session_id` is provided, executes within an existing session
(multi-run mode). Otherwise, creates a standalone one-shot session.

Returns `{:ok, StepResult.t()}` or `{:error, Error.t()}`.

# `step_result`

```elixir
@spec step_result(
  map(),
  keyword()
) :: AgentSessionManager.WorkflowBridge.StepResult.t()
```

Normalize a raw ASM result map into a StepResult struct.

Accepts either a `run_once` result (has `session_id`, `run_id`) or
an `execute_run` result (no `session_id`/`run_id`) plus optional
session_id and run_id overrides.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
