WorkerAgent class

Worker agent that executes assigned tasks by generating code.

Workers are assigned tasks by the MayorAgent and execute them by:

  1. Reading current file context
  2. Generating code changes via LLM
  3. Writing file changes to disk
  4. Updating state files
Inheritance

Constructors

WorkerAgent({required String id, required LLMProvider provider, required Logger logger, TaskCompletedCallback? onTaskCompleted})
Creates a new worker agent.

Properties

activeTask SpectraTask?
The currently assigned task, if any.
no setter
currentTaskId String?
ID of the task currently being processed, if any.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
id String
Unique identifier for this agent.
finalinherited
lastActivity DateTime
Timestamp of the agent's last activity.
getter/setter pairinherited
logger → Logger
Logger for agent output.
finalinherited
onTaskCompleted TaskCompletedCallback?
Optional callback when a task is completed successfully.
getter/setter pair
provider LLMProvider
The LLM provider used for AI-powered operations.
finalinherited
role AgentRole
The role this agent fulfills (mayor, worker, witness).
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state AgentState
Returns the current state of this agent as an immutable snapshot.
no setterinherited
status AgentStatus
Current operational status of the agent.
getter/setter pairinherited

Methods

assignTask(SpectraTask task) → void
Assigns a task to this worker.
markActive() → void
Marks the agent as active (updates lastActivity).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
step() Future<void>
Executes a single step of the agent's main logic.
override
toString() String
A string representation of this object.
inherited
updateStatus(AgentStatus newStatus) → void
Updates the agent's status and marks it as active.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited