AgentEngine.Collaboration (agent_engine v0.2.0)

Copy Markdown View Source

Shared state container for multi-agent work.

This module intentionally provides only the data structure and helper functions used by host applications. It does not execute turns.

Summary

Functions

Mark the collaboration as complete.

Read a key from the shared state.

Assign a display name to a participant.

Create a collaboration from already-loaded agent configs.

Pause a collaboration.

Store a key-value in the shared state.

Append a turn to the shared conversation and turn log.

Resume a paused collaboration.

List participant roles and names.

Serialize a collaboration into a persistence-friendly map.

Types

participant()

@type participant() :: %{
  agent: map(),
  entries: [CommBus.Entry.t()],
  name: String.t() | nil
}

role()

@type role() :: atom()

t()

@type t() :: %AgentEngine.Collaboration{
  context: map(),
  conversation: CommBus.Conversation.t(),
  created_at: DateTime.t(),
  id: String.t(),
  participants: %{required(role()) => participant()},
  shared_state: map(),
  status: :active | :paused | :complete,
  task: String.t(),
  turn_log: [turn_entry()]
}

turn_entry()

@type turn_entry() :: %{
  role: role(),
  input: String.t(),
  output: String.t(),
  signals: list(),
  timestamp: DateTime.t()
}

Functions

complete(collab, reason \\ "done")

@spec complete(t(), String.t()) :: t()

Mark the collaboration as complete.

get_state(collab, key, default \\ nil)

@spec get_state(t(), term(), term()) :: term()

Read a key from the shared state.

name_participant(collab, role, name)

@spec name_participant(t(), role(), String.t()) :: t()

Assign a display name to a participant.

new(opts)

@spec new(keyword()) :: {:ok, t()} | {:error, term()}

Create a collaboration from already-loaded agent configs.

pause(collab)

@spec pause(t()) :: t()

Pause a collaboration.

put_state(collab, key, value)

@spec put_state(t(), term(), term()) :: t()

Store a key-value in the shared state.

record_turn(collab, role, input, output, signals \\ [])

@spec record_turn(t(), role(), String.t(), String.t(), list()) :: t()

Append a turn to the shared conversation and turn log.

resume(collab)

@spec resume(t()) :: t()

Resume a paused collaboration.

roster(collaboration)

@spec roster(t()) :: [{role(), String.t() | nil}]

List participant roles and names.

serialize(collab)

@spec serialize(t()) :: map()

Serialize a collaboration into a persistence-friendly map.