MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / WorkflowProgress

Class WorkflowProgress

src/workflow/progress.py:66–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65
66class WorkflowProgress:
67 def __init__(
68 self,
69 phases_meta: Optional[list[dict]] = None,
70 *,
71 on_change: Callable[["WorkflowProgress"], None] | None = None,
72 ) -> None:
73 # Seed declared phases (from meta.phases) so the tree shows them before
74 # any agent runs; phase() started later by title reuses the same record.
75 self._phases: list[PhaseRecord] = [
76 PhaseRecord(title=p.get("title", ""), detail=p.get("detail"))
77 for p in (phases_meta or [])
78 if isinstance(p, dict) and p.get("title")
79 ]
80 self._logs: list[str] = []
81 self._current_phase: Optional[str] = None
82 self._on_change = on_change
83
84 # ── mutations ──────────────────────────────────────────────────────────
85 def start_phase(self, title: str) -> None:
86 self._current_phase = title
87 if not any(p.title == title for p in self._phases):
88 self._phases.append(PhaseRecord(title=title))
89 self._changed()
90
91 def log(self, message: str) -> None:
92 self._logs.append(message)
93 self._changed()
94
95 def agent_started(
96 self,
97 index: int,
98 label: str,
99 phase: Optional[str],
100 key: str = "",
101 agent_type: str = "",
102 ) -> AgentRecord:
103 phase = phase or self._current_phase
104 record = AgentRecord(
105 index=index, label=label, phase=phase, key=key,
106 agent_type=agent_type, started_at=time.monotonic(),
107 )
108 self._phase_for(phase).agents.append(record)
109 self._changed()
110 return record
111
112 def agent_finished(
113 self,
114 record: AgentRecord,
115 *,
116 status: AgentStatus,
117 tokens: int = 0,
118 error: Optional[str] = None,
119 tool_count: int = 0,
120 ) -> None:
121 record.status = status
122 record.tokens = tokens
123 record.error = error

Callers 10

_registerFunction · 0.90
test_phase_done_countFunction · 0.90
_registerFunction · 0.90
run_workflowFunction · 0.85
run_workflow_taskFunction · 0.85

Calls

no outgoing calls

Tested by 8

_registerFunction · 0.72
test_phase_done_countFunction · 0.72
_registerFunction · 0.72