AgentSea.Crew.Coordinator (agentsea_crews v0.1.0)

Copy Markdown

Drives a crew's task DAG, modeled as a :gen_statem whose states are the crew lifecycle: :idle → :running → :completed, with :paused (pause/resume) and :aborted branches.

On kickoff/1 it dispatches every task whose dependencies are satisfied to an agent (chosen by the delegation strategy) as a supervised Task. Results arrive as messages; dependents unlock as their dependencies complete; tasks whose dependencies failed are marked :dependency_failed. When everything is settled it replies to the kickoff caller with the aggregate result.

pause stops dispatching new tasks (in-flight work finishes), resume continues, and abort cancels in-flight tasks and settles the crew. Invalid transitions return {:error, {:invalid_status, state}}.

Summary

Functions

Cancel in-flight tasks and settle as :aborted; the kickoff caller gets {:error, :aborted}.

Stop dispatching new tasks; in-flight tasks finish. Only valid while :running.

Resume dispatching after a pause. Only valid while :paused.

Functions

abort(crew)

Cancel in-flight tasks and settle as :aborted; the kickoff caller gets {:error, :aborted}.

add_task(crew, attrs)

child_spec(spec)

kickoff(crew, timeout \\ 60000)

pause(crew)

Stop dispatching new tasks; in-flight tasks finish. Only valid while :running.

resume(crew)

Resume dispatching after a pause. Only valid while :paused.

start_link(spec)

status(crew)