- Role: The "State Authority".
- Responsibility:
- Holds the master state (Task Context, Action History, Tab Registry).
- Serializes state to
chrome.storage.localfor persistence. - Acts as the mutex/lock for task execution (ensures only one "run" is active).
- Routes messages between the UI (Side Panel) and the Worker (Agent).
- Role: The "Task Runner".
- Responsibility:
- Runs the main loop (
startAutoRun). - Fetches plans from the Planner (LLM).
- Executes tools on the Content Script.
- Reports progress and errors back to the Coordinator.
- Failure Behavior: If a tool fails, it attempts a local retry (refresh DOM -> retry with signature) before escalating to a replan.
- Runs the main loop (
- Role: The "Local Operative".
- Responsibility:
- Scans the page for elements.
- Executes atomic actions (Click, Type).
- Failure Behavior: If an element ID is missing, it uses the "Signature" (Text, Role, Attributes) to find the best semantic match.
- UI sends
START_TASKto Coordinator. - Coordinator initializes
TaskContextand sets status to "Running". - Coordinator triggers Worker (
startAutoRun).
- Worker requests
GET_STATEfrom Coordinator. - Worker requests
simplify(Element Map) from DOM Agent. - Worker sends Prompt to Planner (LLM).
- Planner returns
Action. - Worker sends
EXECUTEto DOM Agent.- Payload includes:
id,signature(fallback).
- Payload includes:
- DOM Agent returns
Result. - Worker sends
RECORD_ACTIONto Coordinator. - Coordinator saves state to Storage.
-
Tool Failure (Element Not Found):
- DOM Agent reports failure.
- Worker triggers
simplify(Refresh Map). - Worker retries
EXECUTEwith the same action (using Signature). - If 2nd failure: Worker reports error to Coordinator and requests a Re-plan (new LLM call).
-
System Crash / Restart:
- Coordinator (
background.js) wakes up. - Loads state from
chrome.storage.local. - If task was "Running", it can resume (future capability) or show "Paused" state to user.
- Coordinator (
GET_STATE: Returns full browser state.UPDATE_TASK_CONTEXT: Updates subtasks, errors, or data.RECORD_ACTION: Logs a completed action.TASK_ADD_RELEVANT_TAB: Tracks tabs used in the task.
- Key:
heybro_state - Value:
{ taskContext: {...}, actionHistory: [...] }