flock-core 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flock-core might be problematic. Click here for more details.

Files changed (48) hide show
  1. flock/__init__.py +4 -0
  2. flock/agents/__init__.py +3 -0
  3. flock/agents/batch_agent.py +175 -0
  4. flock/agents/declarative_agent.py +166 -0
  5. flock/agents/loop_agent.py +178 -0
  6. flock/agents/trigger_agent.py +191 -0
  7. flock/agents/user_agent.py +230 -0
  8. flock/app/components/__init__.py +14 -0
  9. flock/app/components/charts/agent_workflow.py +14 -0
  10. flock/app/components/charts/core_architecture.py +14 -0
  11. flock/app/components/charts/tool_system.py +14 -0
  12. flock/app/components/history_grid.py +168 -0
  13. flock/app/components/history_grid_alt.py +189 -0
  14. flock/app/components/sidebar.py +19 -0
  15. flock/app/components/theme.py +9 -0
  16. flock/app/components/util.py +18 -0
  17. flock/app/hive_app.py +118 -0
  18. flock/app/html/d3.html +179 -0
  19. flock/app/modules/__init__.py +12 -0
  20. flock/app/modules/about.py +17 -0
  21. flock/app/modules/agent_detail.py +70 -0
  22. flock/app/modules/agent_list.py +59 -0
  23. flock/app/modules/playground.py +322 -0
  24. flock/app/modules/settings.py +96 -0
  25. flock/core/__init__.py +7 -0
  26. flock/core/agent.py +150 -0
  27. flock/core/agent_registry.py +162 -0
  28. flock/core/config/declarative_agent_config.py +0 -0
  29. flock/core/context.py +279 -0
  30. flock/core/context_vars.py +6 -0
  31. flock/core/flock.py +208 -0
  32. flock/core/handoff/handoff_base.py +12 -0
  33. flock/core/logging/__init__.py +18 -0
  34. flock/core/logging/error_handler.py +84 -0
  35. flock/core/logging/formatters.py +122 -0
  36. flock/core/logging/handlers.py +117 -0
  37. flock/core/logging/logger.py +107 -0
  38. flock/core/serializable.py +206 -0
  39. flock/core/tools/basic_tools.py +98 -0
  40. flock/workflow/activities.py +115 -0
  41. flock/workflow/agent_activities.py +26 -0
  42. flock/workflow/temporal_setup.py +37 -0
  43. flock/workflow/workflow.py +53 -0
  44. flock_core-0.1.1.dist-info/METADATA +449 -0
  45. flock_core-0.1.1.dist-info/RECORD +48 -0
  46. flock_core-0.1.1.dist-info/WHEEL +4 -0
  47. flock_core-0.1.1.dist-info/entry_points.txt +2 -0
  48. flock_core-0.1.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,191 @@
1
+ from collections.abc import Callable
2
+ from typing import Any
3
+
4
+ from pydantic import Field
5
+
6
+ from flock.core.agent import Agent
7
+ from flock.core.context import FlockContext
8
+ from flock.core.logging import flock_logger, live_update_handler, performance_handler
9
+
10
+
11
+ class TriggerAgent(Agent):
12
+ """An agent that executes based on specific triggers/conditions.
13
+
14
+ Attributes:
15
+ input: Input domain for the agent
16
+ output: Output types for the agent
17
+ tools: Tools the agent is allowed to use
18
+ trigger_condition: Callable that evaluates whether the agent should execute
19
+ trigger_check_interval: How often to check the trigger condition (in seconds)
20
+ max_wait_time: Maximum time to wait for trigger (in seconds)
21
+ """
22
+
23
+ input: str = Field(default="", description="Input domain for the agent")
24
+ output: str = Field(default="", description="Output types for the agent")
25
+ tools: list[Callable] | None = Field(default=None, description="Tools the agent is allowed to use")
26
+ trigger_condition: Callable[[dict[str, Any]], bool] = Field(
27
+ ..., description="Function that evaluates trigger conditions"
28
+ )
29
+ trigger_check_interval: float = Field(default=1.0, description="Interval between trigger checks (seconds)")
30
+ max_wait_time: float = Field(default=60.0, description="Maximum time to wait for trigger (seconds)")
31
+
32
+ async def _evaluate_trigger(self, context: FlockContext) -> bool:
33
+ """Evaluate the trigger condition."""
34
+ try:
35
+ with performance_handler.track_time("trigger_evaluation"):
36
+ flock_logger.debug("Evaluating trigger condition", agent=self.name)
37
+ result = self.trigger_condition(context.state)
38
+ flock_logger.debug(
39
+ "Trigger evaluation result",
40
+ triggered=result,
41
+ agent=self.name,
42
+ )
43
+ return result
44
+ except Exception as e:
45
+ flock_logger.error(
46
+ "Trigger evaluation failed",
47
+ error=str(e),
48
+ agent=self.name,
49
+ )
50
+ raise
51
+
52
+ async def _execute_action(self, context: FlockContext) -> dict[str, Any]:
53
+ """Execute the agent's action once triggered."""
54
+ try:
55
+ with performance_handler.track_time("action_execution"):
56
+ flock_logger.info("Executing triggered action", agent=self.name)
57
+ # Here you would implement the actual action logic
58
+ # For now, we'll just return a simple result
59
+ result = {"status": "completed", "trigger_time": context.state.get("current_time")}
60
+ flock_logger.success("Action executed successfully", agent=self.name)
61
+ return result
62
+ except Exception as e:
63
+ flock_logger.error(
64
+ "Action execution failed",
65
+ error=str(e),
66
+ agent=self.name,
67
+ )
68
+ raise
69
+
70
+ async def run(self, context: FlockContext) -> dict[str, Any]:
71
+ """Run the agent, waiting for and responding to triggers."""
72
+ import asyncio
73
+ import time
74
+
75
+ try:
76
+ flock_logger.info(f"Starting trigger agent: {self.name}")
77
+ start_time = time.time()
78
+ triggered = False
79
+
80
+ with live_update_handler.progress_tracker("Waiting for trigger") as update_progress:
81
+ while (time.time() - start_time) < self.max_wait_time:
82
+ # Update progress based on elapsed time
83
+ elapsed = time.time() - start_time
84
+ progress = min(elapsed * 100 / self.max_wait_time, 100)
85
+ update_progress(progress)
86
+
87
+ # Check trigger with status tracking
88
+ with live_update_handler.update_activity_status(
89
+ self.name,
90
+ "Checking Trigger",
91
+ "Running",
92
+ {
93
+ "elapsed_time": f"{elapsed:.1f}s",
94
+ "max_wait_time": f"{self.max_wait_time:.1f}s",
95
+ },
96
+ ):
97
+ if await self._evaluate_trigger(context):
98
+ triggered = True
99
+ break
100
+
101
+ await asyncio.sleep(self.trigger_check_interval)
102
+
103
+ if not triggered:
104
+ flock_logger.warning(
105
+ "Trigger timeout reached",
106
+ max_wait_time=self.max_wait_time,
107
+ agent=self.name,
108
+ )
109
+ return {"error": "Trigger timeout", "max_wait_time": self.max_wait_time}
110
+
111
+ # Execute action when triggered
112
+ result = await self._execute_action(context)
113
+ return result
114
+
115
+ except Exception as e:
116
+ flock_logger.error(
117
+ "Trigger agent execution failed",
118
+ error=str(e),
119
+ agent=self.name,
120
+ )
121
+ raise
122
+
123
+ async def run_temporal(self, context: FlockContext) -> dict[str, Any]:
124
+ """Run the trigger agent via Temporal."""
125
+ try:
126
+ from temporalio.client import Client
127
+
128
+ from flock.workflow.agent_activities import run_agent_activity
129
+ from flock.workflow.temporal_setup import run_activity
130
+
131
+ with performance_handler.track_time("temporal_setup"):
132
+ flock_logger.info(f"Starting temporal trigger agent: {self.name}")
133
+ client = await Client.connect("localhost:7233", namespace="default")
134
+
135
+ with live_update_handler.update_workflow_status(
136
+ self.name,
137
+ "Running",
138
+ {
139
+ "phase": "trigger_monitoring",
140
+ "check_interval": self.trigger_check_interval,
141
+ "max_wait_time": self.max_wait_time,
142
+ },
143
+ ):
144
+ # First activity: Monitor trigger
145
+ context_data = {
146
+ "state": context.state,
147
+ "history": [record.__dict__ for record in context.history],
148
+ "agent_definitions": [definition.__dict__ for definition in context.agent_definitions],
149
+ }
150
+ agent_data = self.dict()
151
+
152
+ with performance_handler.track_time("temporal_trigger_monitoring"):
153
+ flock_logger.info("Starting trigger monitoring activity")
154
+ monitor_result = await run_activity(
155
+ client,
156
+ f"{self.name}_monitor",
157
+ run_agent_activity,
158
+ {"agent_data": agent_data, "context_data": context_data},
159
+ )
160
+
161
+ if monitor_result.get("error"):
162
+ flock_logger.warning(
163
+ "Trigger monitoring ended without activation",
164
+ reason=monitor_result["error"],
165
+ agent=self.name,
166
+ )
167
+ return monitor_result
168
+
169
+ # Second activity: Execute action
170
+ with performance_handler.track_time("temporal_action_execution"):
171
+ flock_logger.info("Starting action execution activity")
172
+ action_result = await run_activity(
173
+ client,
174
+ f"{self.name}_action",
175
+ run_agent_activity,
176
+ {"agent_data": agent_data, "context_data": context_data},
177
+ )
178
+
179
+ flock_logger.success(
180
+ "Temporal trigger agent completed successfully",
181
+ agent=self.name,
182
+ )
183
+ return action_result
184
+
185
+ except Exception as e:
186
+ flock_logger.error(
187
+ "Temporal trigger agent execution failed",
188
+ error=str(e),
189
+ agent=self.name,
190
+ )
191
+ raise
@@ -0,0 +1,230 @@
1
+ from collections.abc import Callable
2
+ from typing import Any
3
+
4
+ from pydantic import Field
5
+ from temporalio import activity
6
+
7
+ from flock.core.agent import Agent
8
+ from flock.core.context import FlockContext
9
+ from flock.core.logging import flock_logger, live_update_handler, performance_handler
10
+
11
+
12
+ @activity.defn
13
+ async def run_user_agent_activity(context: dict[str, Any]) -> dict[str, Any]:
14
+ """Temporal activity to process a user agent task.
15
+
16
+ Expects context to contain:
17
+ - "model": the model name
18
+ - "agent_input": the key used for the input
19
+ - "output": the agent output specification
20
+ - "init_input": the initial input
21
+ - "tools": (optional) list of tools
22
+ """
23
+ try:
24
+ import dspy
25
+
26
+ flock_logger.info("Starting user agent activity", context=context)
27
+
28
+ with performance_handler.track_time("model_configuration"):
29
+ model = context.get("model")
30
+ agent_input = context.get("agent_input")
31
+ output = context.get("output")
32
+ init_input = context.get("init_input")
33
+ tools = context.get("tools")
34
+
35
+ flock_logger.debug(
36
+ "Configuring model",
37
+ model=model,
38
+ input=agent_input,
39
+ output=output,
40
+ )
41
+
42
+ lm = dspy.LM(model)
43
+ dspy.configure(lm=lm)
44
+
45
+ with performance_handler.track_time("task_execution"):
46
+ if tools:
47
+ flock_logger.info("Creating ReAct task with tools", num_tools=len(tools))
48
+ agent_task = dspy.ReAct(f"{agent_input} -> {output}", tools=tools)
49
+ else:
50
+ flock_logger.info("Creating Predict task")
51
+ agent_task = dspy.Predict(f"{agent_input} -> {output}")
52
+
53
+ kwargs = {agent_input: init_input}
54
+ flock_logger.info("Executing task", kwargs=kwargs)
55
+ result = agent_task(**kwargs).toDict()
56
+ result[agent_input] = init_input
57
+
58
+ flock_logger.success("Task completed successfully")
59
+ return result
60
+
61
+ except Exception as e:
62
+ flock_logger.error(
63
+ "User agent activity failed",
64
+ error=str(e),
65
+ context=context,
66
+ )
67
+ raise
68
+
69
+
70
+ class UserAgent(Agent):
71
+ """An agent that evaluates declarative inputs with user interaction capabilities.
72
+
73
+ This agent extends the base Agent class with the ability to interact with users
74
+ during execution, while maintaining compatibility with both local and Temporal
75
+ execution modes.
76
+
77
+ Attributes:
78
+ input: Input domain for the agent
79
+ output: Output types for the agent
80
+ tools: Tools the agent is allowed to use
81
+ require_confirmation: Whether to require user confirmation before proceeding
82
+ """
83
+
84
+ input: str = Field(default="", description="Input domain for the agent")
85
+ output: str = Field(default="", description="Output types for the agent")
86
+ tools: list[Callable] | None = Field(default=None, description="Tools the agent is allowed to use")
87
+ require_confirmation: bool = Field(default=False, description="Whether to require user confirmation")
88
+
89
+ async def _configure_model(self) -> tuple[Any, Any]:
90
+ """Configure the model and create the appropriate task."""
91
+ try:
92
+ with performance_handler.track_time("model_configuration"):
93
+ import dspy
94
+
95
+ flock_logger.debug(
96
+ "Configuring model",
97
+ model=self.model,
98
+ input=self.input,
99
+ output=self.output,
100
+ )
101
+
102
+ lm = dspy.LM(self.model)
103
+ dspy.configure(lm=lm)
104
+
105
+ if self.tools:
106
+ flock_logger.info("Creating ReAct task with tools", num_tools=len(self.tools))
107
+ agent_task = dspy.ReAct(f"{self.input} -> {self.output}", tools=self.tools)
108
+ else:
109
+ flock_logger.info("Creating Predict task")
110
+ agent_task = dspy.Predict(f"{self.input} -> {self.output}")
111
+
112
+ return lm, agent_task
113
+
114
+ except Exception as e:
115
+ flock_logger.error(
116
+ "Model configuration failed",
117
+ error=str(e),
118
+ agent=self.name,
119
+ )
120
+ raise
121
+
122
+ async def _execute_task(self, task: Any, context: FlockContext) -> dict[str, Any]:
123
+ """Execute the configured task."""
124
+ try:
125
+ with performance_handler.track_time("task_execution"):
126
+ kwargs = {self.input: context.get_variable("init_input")}
127
+ flock_logger.info("Executing task", kwargs=kwargs)
128
+
129
+ with live_update_handler.update_activity_status(
130
+ self.name,
131
+ "Executing Task",
132
+ "Running",
133
+ {"input": kwargs},
134
+ ):
135
+ result = task(**kwargs).toDict()
136
+ result[self.input] = kwargs[self.input]
137
+
138
+ flock_logger.success("Task executed successfully")
139
+ return result
140
+
141
+ except Exception as e:
142
+ flock_logger.error(
143
+ "Task execution failed",
144
+ error=str(e),
145
+ agent=self.name,
146
+ kwargs=kwargs,
147
+ )
148
+ raise
149
+
150
+ async def run(self, context: FlockContext) -> dict[str, Any]:
151
+ """Run the agent on a task with optional user interaction."""
152
+ try:
153
+ flock_logger.info(f"Starting user agent: {self.name}")
154
+
155
+ # Configure model and task
156
+ _, task = await self._configure_model()
157
+
158
+ # Execute with user confirmation if required
159
+ if self.require_confirmation:
160
+ with live_update_handler.update_activity_status(
161
+ self.name,
162
+ "Awaiting User Confirmation",
163
+ "Paused",
164
+ {"agent": self.name},
165
+ ):
166
+ flock_logger.info("Waiting for user confirmation")
167
+ # Here you would implement user confirmation logic
168
+ # For now, we'll just proceed
169
+ pass
170
+
171
+ # Execute the task
172
+ result = await self._execute_task(task, context)
173
+ return result
174
+
175
+ except Exception as e:
176
+ flock_logger.error(
177
+ "User agent execution failed",
178
+ error=str(e),
179
+ agent=self.name,
180
+ )
181
+ raise
182
+
183
+ async def run_temporal(self, context: FlockContext) -> dict[str, Any]:
184
+ """Run the user agent via Temporal."""
185
+ try:
186
+ from temporalio.client import Client
187
+
188
+ from flock.workflow.temporal_setup import run_activity
189
+
190
+ with performance_handler.track_time("temporal_setup"):
191
+ flock_logger.info(f"Starting temporal user agent: {self.name}")
192
+ client = await Client.connect("localhost:7233", namespace="default")
193
+
194
+ # Prepare context for temporal activity
195
+ activity_context = {
196
+ "model": self.model,
197
+ "agent_input": self.input,
198
+ "output": self.output,
199
+ "init_input": context.get_variable("init_input"),
200
+ "tools": self.tools,
201
+ }
202
+
203
+ with live_update_handler.update_workflow_status(
204
+ self.name,
205
+ "Running",
206
+ {"phase": "user_agent_execution"},
207
+ ):
208
+ # Execute the activity
209
+ with performance_handler.track_time("temporal_execution"):
210
+ flock_logger.info("Starting user agent activity")
211
+ result = await run_activity(
212
+ client,
213
+ self.name,
214
+ run_user_agent_activity,
215
+ activity_context,
216
+ )
217
+
218
+ flock_logger.success(
219
+ "Temporal user agent completed successfully",
220
+ agent=self.name,
221
+ )
222
+ return result
223
+
224
+ except Exception as e:
225
+ flock_logger.error(
226
+ "Temporal user agent execution failed",
227
+ error=str(e),
228
+ agent=self.name,
229
+ )
230
+ raise
@@ -0,0 +1,14 @@
1
+ from .charts.agent_workflow import AgentWorkflowChart
2
+ from .charts.core_architecture import CoreArchitectureChart
3
+ from .history_grid import HistoryGrid
4
+ from .sidebar import Sidebar
5
+ from .theme import Theme, ThemeDialog
6
+
7
+ __all__ = [
8
+ "AgentWorkflowChart",
9
+ "CoreArchitectureChart",
10
+ "HistoryGrid",
11
+ "Sidebar",
12
+ "Theme",
13
+ "ThemeDialog",
14
+ ]
@@ -0,0 +1,14 @@
1
+ from fasthtml.common import *
2
+ from fasthtml.svg import *
3
+ from monsterui.all import *
4
+
5
+
6
+ def AgentWorkflowChart():
7
+ return Div(
8
+ Div(
9
+ style="max-width:100%;border:1px solid transparent;",
10
+ data_mxgraph='{"highlight":"#0000ff","nav":true,"resize":true,"page":1,"toolbar":"pages zoom layers tags lightbox","edit":"_blank","xml":"<mxfile><diagram id=\\"l7_B5a2V6sOU66k4eApJ\\" name=\\"Core Architecture\\"><mxGraphModel dx=\\"1139\\" dy=\\"934\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#FFFFFF\\" math=\\"0\\" shadow=\\"1\\"><root><mxCell id=\\"0\\"/><mxCell id=\\"1\\" parent=\\"0\\"/><mxCell id=\\"3\\" value=\\"graph TB&#10; subgraph User Application&#10; UA[User Code] --&gt; |Uses| SM[Flock Manager]&#10; end&#10;&#10; subgraph Flock Core&#10; SM --&gt; |Manages| AR[Agent Registry]&#10; SM --&gt; |Executes| WF[Workflow System]&#10; &#10; subgraph Agents&#10; AR --&gt; |Registers| DA[Declarative Agent]&#10; DA --&gt; |Uses| TS[Type System]&#10; DA --&gt; |Uses| TM[Tool Manager]&#10; end&#10; &#10; subgraph Workflow&#10; WF --&gt; |Runs| AC[Activities]&#10; WF --&gt; |Uses| TW[Temporal Worker]&#10; AC --&gt; |Executes| DA&#10; end&#10; end&#10;&#10; subgraph External Systems&#10; TW --&gt; |Connects to| TS1[Temporal Server]&#10; TM --&gt; |Integrates| T1[Web Search]&#10; TM --&gt; |Integrates| T2[Code Eval]&#10; TM --&gt; |Integrates| T3[Math Tools]&#10; DA --&gt; |Uses| LLM[LLM Provider]&#10; end&#10;&#10; classDef core fill:#f9f,stroke:#333,stroke-width:2px&#10; classDef external fill:#bbf,stroke:#333,stroke-width:2px&#10; classDef user fill:#bfb,stroke:#333,stroke-width:2px&#10; &#10; class SM,AR,DA,WF,AC,TM,TS core&#10; class TS1,T1,T2,T3,LLM external&#10; class UA user&#10;&#10;\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;rounded=1;\\" parent=\\"1\\" vertex=\\"1\\"><mxGeometry x=\\"200\\" y=\\"310\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/></mxCell></root></mxGraphModel></diagram><diagram id=\\"m33Os__FMXyp1zJ4IDTH\\" name=\\"Agent Workflow\\"><mxGraphModel dx=\\"1139\\" dy=\\"934\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\"><root><mxCell id=\\"0\\"/><mxCell id=\\"1\\" parent=\\"0\\"/><mxCell id=\\"Yf0mmGmI6B4_u023lZ5C-1\\" value=\\"sequenceDiagram&#10; participant User&#10; participant Flock&#10; participant Agent&#10; participant Tools&#10; participant LLM&#10; participant Temporal&#10;&#10; User-&gt;&gt;Flock: Create Agent&#10; Flock-&gt;&gt;Agent: Initialize&#10; User-&gt;&gt;Flock: activate(agent, input)&#10; &#10; alt Local Debug Mode&#10; Flock-&gt;&gt;Agent: Execute Directly&#10; else Production Mode&#10; Flock-&gt;&gt;Temporal: Start Workflow&#10; Temporal-&gt;&gt;Agent: Execute via Activity&#10; end&#10;&#10; loop Agent Execution&#10; Agent-&gt;&gt;LLM: Process Input&#10; opt Tool Usage&#10; Agent-&gt;&gt;Tools: Execute Tool&#10; Tools--&gt;&gt;Agent: Tool Result&#10; end&#10; Agent-&gt;&gt;LLM: Generate Output&#10; end&#10;&#10; alt Has Hand-off&#10; Agent-&gt;&gt;Flock: Hand off to Next Agent&#10; Flock-&gt;&gt;Agent: Start Next Agent&#10; else No Hand-off&#10; Agent--&gt;&gt;Flock: Return Result&#10; end&#10;&#10; Flock--&gt;&gt;User: Return Final Result\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" parent=\\"1\\" vertex=\\"1\\"><mxGeometry x=\\"275\\" y=\\"114\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/></mxCell></root></mxGraphModel></diagram><diagram id=\\"zsmzvY-bLYlccnSXdfzv\\" name=\\"Temporal Workflow\\">\\n <mxGraphModel dx=\\"205\\" dy=\\"165\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\">\\n <root>\\n <mxCell id=\\"0\\"/>\\n <mxCell id=\\"1\\" parent=\\"0\\"/>\\n <mxCell id=\\"LGo0nXY-PDX6Si-UCiUW-1\\" value=\\"graph TB&#10; subgraph Temporal Integration&#10; WF[Workflow System] --&gt; |Manages| TW[Temporal Worker]&#10; TW --&gt; |Executes| AC[Activities]&#10; TW --&gt; |Connects to| TS[Temporal Server]&#10; &#10; subgraph State Management&#10; TS --&gt; |Manages| WS[Workflow State]&#10; WS --&gt; |Tracks| AS[Agent State]&#10; WS --&gt; |Tracks| TS1[Tool State]&#10; WS --&gt; |Tracks| ES[Error State]&#10; end&#10;&#10; subgraph Reliability Features&#10; TS --&gt; |Provides| R1[Automatic Retries]&#10; TS --&gt; |Provides| R2[Error Recovery]&#10; TS --&gt; |Provides| R3[State Persistence]&#10; TS --&gt; |Provides| R4[Workflow History]&#10; end&#10;&#10; subgraph Monitoring&#10; TS --&gt; |Enables| M1[Execution Metrics]&#10; TS --&gt; |Enables| M2[Error Tracking]&#10; TS --&gt; |Enables| M3[Performance Stats]&#10; TS --&gt; |Enables| M4[Workflow Visualization]&#10; end&#10; end&#10;&#10; classDef core fill:#f9f,stroke:#333,stroke-width:2px&#10; classDef state fill:#bbf,stroke:#333,stroke-width:2px&#10; classDef feature fill:#bfb,stroke:#333,stroke-width:2px&#10; classDef monitor fill:#fbb,stroke:#333,stroke-width:2px&#10;&#10; class WF,TW,AC,TS core&#10; class WS,AS,TS1,ES state&#10; class R1,R2,R3,R4 feature&#10; class M1,M2,M3,M4 monitor&#10;&#10;\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" vertex=\\"1\\" parent=\\"1\\">\\n <mxGeometry x=\\"242\\" y=\\"169\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/>\\n </mxCell>\\n </root>\\n </mxGraphModel>\\n </diagram><diagram id=\\"FU8wRJNSLGF58lYnAYQQ\\" name=\\"Tool System\\">\\n <mxGraphModel dx=\\"307\\" dy=\\"248\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\">\\n <root>\\n <mxCell id=\\"0\\"/>\\n <mxCell id=\\"1\\" parent=\\"0\\"/>\\n <mxCell id=\\"T-pgXY2fyKOihok5m5tA-1\\" value=\\"graph TB&#10; subgraph Tool Management&#10; TM[Tool Manager] --&gt; |Manages| TR[Tool Registry]&#10; TR --&gt; |Registers| T1[Web Search Tool]&#10; TR --&gt; |Registers| T2[Code Eval Tool]&#10; TR --&gt; |Registers| T3[Math Tool]&#10; &#10; TM --&gt; |Provides| TI[Tool Interface]&#10; TI --&gt; |Used by| DA[Declarative Agent]&#10; end&#10;&#10; subgraph Tool Execution&#10; T1 --&gt; |Uses| WS[Web Search API]&#10; T2 --&gt; |Uses| CE[Code Executor]&#10; T3 --&gt; |Uses| ME[Math Engine]&#10; &#10; WS --&gt; |Returns| R1[Search Results]&#10; CE --&gt; |Returns| R2[Execution Results]&#10; ME --&gt; |Returns| R3[Math Results]&#10; end&#10;&#10; subgraph Error Handling&#10; TM --&gt; |Manages| EH[Error Handler]&#10; EH --&gt; |Handles| E1[API Errors]&#10; EH --&gt; |Handles| E2[Execution Errors]&#10; EH --&gt; |Handles| E3[Validation Errors]&#10; end&#10;&#10; classDef core fill:#f9f,stroke:#333,stroke-width:2px&#10; classDef tool fill:#bbf,stroke:#333,stroke-width:2px&#10; classDef handler fill:#bfb,stroke:#333,stroke-width:2px&#10;&#10; class TM,TR,TI core&#10; class T1,T2,T3,WS,CE,ME tool&#10; class EH,E1,E2,E3 handler\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" vertex=\\"1\\" parent=\\"1\\">\\n <mxGeometry x=\\"240\\" y=\\"170\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/>\\n </mxCell>\\n </root>\\n </mxGraphModel>\\n </diagram><diagram id=\\"44PLLl0pgulDx2n2xTWC\\" name=\\"Type System\\">\\n <mxGraphModel dx=\\"767\\" dy=\\"620\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\">\\n <root>\\n <mxCell id=\\"0\\"/>\\n <mxCell id=\\"1\\" parent=\\"0\\"/>\\n <mxCell id=\\"jTONh3Pudjw2xIwc2DDu-1\\" value=\\"classDiagram&#10; class TypeSystem {&#10; +register_type(name, validator, serializer)&#10; +validate(value, type_def)&#10; +parse_type_string(type_str)&#10; -_validate_complex_type(value, type_def)&#10; }&#10;&#10; class TypeDefinition {&#10; +name: str&#10; +validators: List&#10; +serializers: Optional&#10; +validate(value)&#10; +serialize(value)&#10; }&#10;&#10; class DeclarativeAgent {&#10; +input: str&#10; +output: str&#10; +tools: List&#10; +validate_input(value)&#10; +validate_output(value)&#10; }&#10;&#10; class Validator {&#10; +validate(value)&#10; +coerce(value)&#10; }&#10;&#10; TypeSystem --&gt; TypeDefinition : manages&#10; DeclarativeAgent --&gt; TypeSystem : uses&#10; TypeDefinition --&gt; Validator : uses&#10;&#10;\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" vertex=\\"1\\" parent=\\"1\\">\\n <mxGeometry x=\\"242\\" y=\\"169\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/>\\n </mxCell>\\n </root>\\n </mxGraphModel>\\n </diagram></mxfile>"}',
11
+ cls="mxgraph",
12
+ ),
13
+ Script(type="text/javascript", src="https://viewer.diagrams.net/js/viewer-static.min.js"),
14
+ )
@@ -0,0 +1,14 @@
1
+ from fasthtml.common import *
2
+ from fasthtml.svg import *
3
+ from monsterui.all import *
4
+
5
+
6
+ def CoreArchitectureChart():
7
+ return Div(
8
+ Div(
9
+ style="max-width:100%;border:1px solid transparent;",
10
+ data_mxgraph='{"highlight":"#0000ff","nav":true,"resize":true,"page":0,"toolbar":"pages zoom layers tags lightbox","edit":"_blank","xml":"<mxfile><diagram id=\\"l7_B5a2V6sOU66k4eApJ\\" name=\\"Core Architecture\\"><mxGraphModel dx=\\"1139\\" dy=\\"934\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#FFFFFF\\" math=\\"0\\" shadow=\\"1\\"><root><mxCell id=\\"0\\"/><mxCell id=\\"1\\" parent=\\"0\\"/><mxCell id=\\"3\\" value=\\"graph TB&#10; subgraph User Application&#10; UA[User Code] --&gt; |Uses| SM[Flock Manager]&#10; end&#10;&#10; subgraph Flock Core&#10; SM --&gt; |Manages| AR[Agent Registry]&#10; SM --&gt; |Executes| WF[Workflow System]&#10; &#10; subgraph Agents&#10; AR --&gt; |Registers| DA[Declarative Agent]&#10; DA --&gt; |Uses| TS[Type System]&#10; DA --&gt; |Uses| TM[Tool Manager]&#10; end&#10; &#10; subgraph Workflow&#10; WF --&gt; |Runs| AC[Activities]&#10; WF --&gt; |Uses| TW[Temporal Worker]&#10; AC --&gt; |Executes| DA&#10; end&#10; end&#10;&#10; subgraph External Systems&#10; TW --&gt; |Connects to| TS1[Temporal Server]&#10; TM --&gt; |Integrates| T1[Web Search]&#10; TM --&gt; |Integrates| T2[Code Eval]&#10; TM --&gt; |Integrates| T3[Math Tools]&#10; DA --&gt; |Uses| LLM[LLM Provider]&#10; end&#10;&#10; classDef core fill:#f9f,stroke:#333,stroke-width:2px&#10; classDef external fill:#bbf,stroke:#333,stroke-width:2px&#10; classDef user fill:#bfb,stroke:#333,stroke-width:2px&#10; &#10; class SM,AR,DA,WF,AC,TM,TS core&#10; class TS1,T1,T2,T3,LLM external&#10; class UA user&#10;&#10;\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;rounded=1;\\" parent=\\"1\\" vertex=\\"1\\"><mxGeometry x=\\"200\\" y=\\"310\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/></mxCell></root></mxGraphModel></diagram><diagram id=\\"m33Os__FMXyp1zJ4IDTH\\" name=\\"Agent Workflow\\"><mxGraphModel dx=\\"1139\\" dy=\\"934\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\"><root><mxCell id=\\"0\\"/><mxCell id=\\"1\\" parent=\\"0\\"/><mxCell id=\\"Yf0mmGmI6B4_u023lZ5C-1\\" value=\\"sequenceDiagram&#10; participant User&#10; participant Flock&#10; participant Agent&#10; participant Tools&#10; participant LLM&#10; participant Temporal&#10;&#10; User-&gt;&gt;Flock: Create Agent&#10; Flock-&gt;&gt;Agent: Initialize&#10; User-&gt;&gt;Flock: activate(agent, input)&#10; &#10; alt Local Debug Mode&#10; Flock-&gt;&gt;Agent: Execute Directly&#10; else Production Mode&#10; Flock-&gt;&gt;Temporal: Start Workflow&#10; Temporal-&gt;&gt;Agent: Execute via Activity&#10; end&#10;&#10; loop Agent Execution&#10; Agent-&gt;&gt;LLM: Process Input&#10; opt Tool Usage&#10; Agent-&gt;&gt;Tools: Execute Tool&#10; Tools--&gt;&gt;Agent: Tool Result&#10; end&#10; Agent-&gt;&gt;LLM: Generate Output&#10; end&#10;&#10; alt Has Hand-off&#10; Agent-&gt;&gt;Flock: Hand off to Next Agent&#10; Flock-&gt;&gt;Agent: Start Next Agent&#10; else No Hand-off&#10; Agent--&gt;&gt;Flock: Return Result&#10; end&#10;&#10; Flock--&gt;&gt;User: Return Final Result\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" parent=\\"1\\" vertex=\\"1\\"><mxGeometry x=\\"275\\" y=\\"114\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/></mxCell></root></mxGraphModel></diagram><diagram id=\\"zsmzvY-bLYlccnSXdfzv\\" name=\\"Temporal Workflow\\">\\n <mxGraphModel dx=\\"205\\" dy=\\"165\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\">\\n <root>\\n <mxCell id=\\"0\\"/>\\n <mxCell id=\\"1\\" parent=\\"0\\"/>\\n <mxCell id=\\"LGo0nXY-PDX6Si-UCiUW-1\\" value=\\"graph TB&#10; subgraph Temporal Integration&#10; WF[Workflow System] --&gt; |Manages| TW[Temporal Worker]&#10; TW --&gt; |Executes| AC[Activities]&#10; TW --&gt; |Connects to| TS[Temporal Server]&#10; &#10; subgraph State Management&#10; TS --&gt; |Manages| WS[Workflow State]&#10; WS --&gt; |Tracks| AS[Agent State]&#10; WS --&gt; |Tracks| TS1[Tool State]&#10; WS --&gt; |Tracks| ES[Error State]&#10; end&#10;&#10; subgraph Reliability Features&#10; TS --&gt; |Provides| R1[Automatic Retries]&#10; TS --&gt; |Provides| R2[Error Recovery]&#10; TS --&gt; |Provides| R3[State Persistence]&#10; TS --&gt; |Provides| R4[Workflow History]&#10; end&#10;&#10; subgraph Monitoring&#10; TS --&gt; |Enables| M1[Execution Metrics]&#10; TS --&gt; |Enables| M2[Error Tracking]&#10; TS --&gt; |Enables| M3[Performance Stats]&#10; TS --&gt; |Enables| M4[Workflow Visualization]&#10; end&#10; end&#10;&#10; classDef core fill:#f9f,stroke:#333,stroke-width:2px&#10; classDef state fill:#bbf,stroke:#333,stroke-width:2px&#10; classDef feature fill:#bfb,stroke:#333,stroke-width:2px&#10; classDef monitor fill:#fbb,stroke:#333,stroke-width:2px&#10;&#10; class WF,TW,AC,TS core&#10; class WS,AS,TS1,ES state&#10; class R1,R2,R3,R4 feature&#10; class M1,M2,M3,M4 monitor&#10;&#10;\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" vertex=\\"1\\" parent=\\"1\\">\\n <mxGeometry x=\\"242\\" y=\\"169\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/>\\n </mxCell>\\n </root>\\n </mxGraphModel>\\n </diagram><diagram id=\\"FU8wRJNSLGF58lYnAYQQ\\" name=\\"Tool System\\">\\n <mxGraphModel dx=\\"307\\" dy=\\"248\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\">\\n <root>\\n <mxCell id=\\"0\\"/>\\n <mxCell id=\\"1\\" parent=\\"0\\"/>\\n <mxCell id=\\"T-pgXY2fyKOihok5m5tA-1\\" value=\\"graph TB&#10; subgraph Tool Management&#10; TM[Tool Manager] --&gt; |Manages| TR[Tool Registry]&#10; TR --&gt; |Registers| T1[Web Search Tool]&#10; TR --&gt; |Registers| T2[Code Eval Tool]&#10; TR --&gt; |Registers| T3[Math Tool]&#10; &#10; TM --&gt; |Provides| TI[Tool Interface]&#10; TI --&gt; |Used by| DA[Declarative Agent]&#10; end&#10;&#10; subgraph Tool Execution&#10; T1 --&gt; |Uses| WS[Web Search API]&#10; T2 --&gt; |Uses| CE[Code Executor]&#10; T3 --&gt; |Uses| ME[Math Engine]&#10; &#10; WS --&gt; |Returns| R1[Search Results]&#10; CE --&gt; |Returns| R2[Execution Results]&#10; ME --&gt; |Returns| R3[Math Results]&#10; end&#10;&#10; subgraph Error Handling&#10; TM --&gt; |Manages| EH[Error Handler]&#10; EH --&gt; |Handles| E1[API Errors]&#10; EH --&gt; |Handles| E2[Execution Errors]&#10; EH --&gt; |Handles| E3[Validation Errors]&#10; end&#10;&#10; classDef core fill:#f9f,stroke:#333,stroke-width:2px&#10; classDef tool fill:#bbf,stroke:#333,stroke-width:2px&#10; classDef handler fill:#bfb,stroke:#333,stroke-width:2px&#10;&#10; class TM,TR,TI core&#10; class T1,T2,T3,WS,CE,ME tool&#10; class EH,E1,E2,E3 handler\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" vertex=\\"1\\" parent=\\"1\\">\\n <mxGeometry x=\\"240\\" y=\\"170\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/>\\n </mxCell>\\n </root>\\n </mxGraphModel>\\n </diagram><diagram id=\\"44PLLl0pgulDx2n2xTWC\\" name=\\"Type System\\">\\n <mxGraphModel dx=\\"767\\" dy=\\"620\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\">\\n <root>\\n <mxCell id=\\"0\\"/>\\n <mxCell id=\\"1\\" parent=\\"0\\"/>\\n <mxCell id=\\"jTONh3Pudjw2xIwc2DDu-1\\" value=\\"classDiagram&#10; class TypeSystem {&#10; +register_type(name, validator, serializer)&#10; +validate(value, type_def)&#10; +parse_type_string(type_str)&#10; -_validate_complex_type(value, type_def)&#10; }&#10;&#10; class TypeDefinition {&#10; +name: str&#10; +validators: List&#10; +serializers: Optional&#10; +validate(value)&#10; +serialize(value)&#10; }&#10;&#10; class DeclarativeAgent {&#10; +input: str&#10; +output: str&#10; +tools: List&#10; +validate_input(value)&#10; +validate_output(value)&#10; }&#10;&#10; class Validator {&#10; +validate(value)&#10; +coerce(value)&#10; }&#10;&#10; TypeSystem --&gt; TypeDefinition : manages&#10; DeclarativeAgent --&gt; TypeSystem : uses&#10; TypeDefinition --&gt; Validator : uses&#10;&#10;\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" vertex=\\"1\\" parent=\\"1\\">\\n <mxGeometry x=\\"242\\" y=\\"169\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/>\\n </mxCell>\\n </root>\\n </mxGraphModel>\\n </diagram></mxfile>"}',
11
+ cls="mxgraph",
12
+ ),
13
+ Script(type="text/javascript", src="https://viewer.diagrams.net/js/viewer-static.min.js"),
14
+ )
@@ -0,0 +1,14 @@
1
+ from fasthtml.common import *
2
+ from fasthtml.svg import *
3
+ from monsterui.all import *
4
+
5
+
6
+ def ToolSystemChart():
7
+ return Div(
8
+ Div(
9
+ style="max-width:100%;border:1px solid transparent;",
10
+ data_mxgraph='{"highlight":"#0000ff","nav":true,"resize":true,"page":3,"toolbar":"pages zoom layers tags lightbox","edit":"_blank","xml":"<mxfile><diagram id=\\"l7_B5a2V6sOU66k4eApJ\\" name=\\"Core Architecture\\"><mxGraphModel dx=\\"380\\" dy=\\"311\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#FFFFFF\\" math=\\"0\\" shadow=\\"0\\"><root><mxCell id=\\"0\\"/><mxCell id=\\"1\\" parent=\\"0\\"/><mxCell id=\\"3\\" value=\\"graph TB&#10; subgraph User Application&#10; UA[User Code] --&gt; |Uses| SM[Flock Manager]&#10; end&#10;&#10; subgraph Flock Core&#10; SM --&gt; |Manages| AR[Agent Registry]&#10; SM --&gt; |Executes| WF[Workflow System]&#10; &#10; subgraph Agents&#10; AR --&gt; |Registers| DA[Declarative Agent]&#10; DA --&gt; |Uses| TS[Type System]&#10; DA --&gt; |Uses| TM[Tool Manager]&#10; end&#10; &#10; subgraph Workflow&#10; WF --&gt; |Runs| AC[Activities]&#10; WF --&gt; |Uses| TW[Temporal Worker]&#10; AC --&gt; |Executes| DA&#10; end&#10; end&#10;&#10; subgraph External Systems&#10; TW --&gt; |Connects to| TS1[Temporal Server]&#10; TM --&gt; |Integrates| T1[Web Search]&#10; TM --&gt; |Integrates| T2[Code Eval]&#10; TM --&gt; |Integrates| T3[Math Tools]&#10; DA --&gt; |Uses| LLM[LLM Provider]&#10; end&#10;&#10; classDef core fill:#f9f,stroke:#333,stroke-width:2px&#10; classDef external fill:#bbf,stroke:#333,stroke-width:2px&#10; classDef user fill:#bfb,stroke:#333,stroke-width:2px&#10; &#10; class SM,AR,DA,WF,AC,TM,TS core&#10; class TS1,T1,T2,T3,LLM external&#10; class UA user&#10;&#10;\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;rounded=1;\\" parent=\\"1\\" vertex=\\"1\\"><mxGeometry x=\\"200\\" y=\\"310\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/></mxCell></root></mxGraphModel></diagram><diagram id=\\"m33Os__FMXyp1zJ4IDTH\\" name=\\"Agent Workflow\\"><mxGraphModel dx=\\"316\\" dy=\\"259\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"0\\"><root><mxCell id=\\"0\\"/><mxCell id=\\"1\\" parent=\\"0\\"/><mxCell id=\\"Yf0mmGmI6B4_u023lZ5C-1\\" value=\\"sequenceDiagram&#10; participant User&#10; participant Flock&#10; participant Agent&#10; participant Tools&#10; participant LLM&#10; participant Temporal&#10;&#10; User-&gt;&gt;Flock: Create Agent&#10; Flock-&gt;&gt;Agent: Initialize&#10; User-&gt;&gt;Flock: activate(agent, input)&#10; &#10; alt Local Debug Mode&#10; Flock-&gt;&gt;Agent: Execute Directly&#10; else Production Mode&#10; Flock-&gt;&gt;Temporal: Start Workflow&#10; Temporal-&gt;&gt;Agent: Execute via Activity&#10; end&#10;&#10; loop Agent Execution&#10; Agent-&gt;&gt;LLM: Process Input&#10; opt Tool Usage&#10; Agent-&gt;&gt;Tools: Execute Tool&#10; Tools--&gt;&gt;Agent: Tool Result&#10; end&#10; Agent-&gt;&gt;LLM: Generate Output&#10; end&#10;&#10; alt Has Hand-off&#10; Agent-&gt;&gt;Flock: Hand off to Next Agent&#10; Flock-&gt;&gt;Agent: Start Next Agent&#10; else No Hand-off&#10; Agent--&gt;&gt;Flock: Return Result&#10; end&#10;&#10; Flock--&gt;&gt;User: Return Final Result\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" parent=\\"1\\" vertex=\\"1\\"><mxGeometry x=\\"275\\" y=\\"114\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/></mxCell></root></mxGraphModel></diagram><diagram id=\\"zsmzvY-bLYlccnSXdfzv\\" name=\\"Temporal Workflow\\"><mxGraphModel dx=\\"1139\\" dy=\\"934\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\"><root><mxCell id=\\"0\\"/><mxCell id=\\"1\\" parent=\\"0\\"/><mxCell id=\\"LGo0nXY-PDX6Si-UCiUW-1\\" value=\\"graph TB&#10; subgraph Temporal Integration&#10; WF[Workflow System] --&gt; |Manages| TW[Temporal Worker]&#10; TW --&gt; |Executes| AC[Activities]&#10; TW --&gt; |Connects to| TS[Temporal Server]&#10; &#10; subgraph State Management&#10; TS --&gt; |Manages| WS[Workflow State]&#10; WS --&gt; |Tracks| AS[Agent State]&#10; WS --&gt; |Tracks| TS1[Tool State]&#10; WS --&gt; |Tracks| ES[Error State]&#10; end&#10;&#10; subgraph Reliability Features&#10; TS --&gt; |Provides| R1[Automatic Retries]&#10; TS --&gt; |Provides| R2[Error Recovery]&#10; TS --&gt; |Provides| R3[State Persistence]&#10; TS --&gt; |Provides| R4[Workflow History]&#10; end&#10;&#10; subgraph Monitoring&#10; TS --&gt; |Enables| M1[Execution Metrics]&#10; TS --&gt; |Enables| M2[Error Tracking]&#10; TS --&gt; |Enables| M3[Performance Stats]&#10; TS --&gt; |Enables| M4[Workflow Visualization]&#10; end&#10; end&#10;&#10; classDef core fill:#f9f,stroke:#333,stroke-width:2px&#10; classDef state fill:#bbf,stroke:#333,stroke-width:2px&#10; classDef feature fill:#bfb,stroke:#333,stroke-width:2px&#10; classDef monitor fill:#fbb,stroke:#333,stroke-width:2px&#10;&#10; class WF,TW,AC,TS core&#10; class WS,AS,TS1,ES state&#10; class R1,R2,R3,R4 feature&#10; class M1,M2,M3,M4 monitor&#10;&#10;\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" parent=\\"1\\" vertex=\\"1\\"><mxGeometry x=\\"242\\" y=\\"169\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/></mxCell></root></mxGraphModel></diagram><diagram id=\\"FU8wRJNSLGF58lYnAYQQ\\" name=\\"Tool System\\"><mxGraphModel dx=\\"316\\" dy=\\"259\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"0\\"><root><mxCell id=\\"0\\"/><mxCell id=\\"1\\" parent=\\"0\\"/><mxCell id=\\"T-pgXY2fyKOihok5m5tA-1\\" value=\\"graph TB&#10; subgraph Tool Management&#10; TM[Tool Manager] --&gt; |Manages| TR[Tool Registry]&#10; TR --&gt; |Registers| T1[Web Search Tool]&#10; TR --&gt; |Registers| T2[Code Eval Tool]&#10; TR --&gt; |Registers| T3[Math Tool]&#10; &#10; TM --&gt; |Provides| TI[Tool Interface]&#10; TI --&gt; |Used by| DA[Declarative Agent]&#10; end&#10;&#10; subgraph Tool Execution&#10; T1 --&gt; |Uses| WS[Web Search API]&#10; T2 --&gt; |Uses| CE[Code Executor]&#10; T3 --&gt; |Uses| ME[Math Engine]&#10; &#10; WS --&gt; |Returns| R1[Search Results]&#10; CE --&gt; |Returns| R2[Execution Results]&#10; ME --&gt; |Returns| R3[Math Results]&#10; end&#10;&#10; subgraph Error Handling&#10; TM --&gt; |Manages| EH[Error Handler]&#10; EH --&gt; |Handles| E1[API Errors]&#10; EH --&gt; |Handles| E2[Execution Errors]&#10; EH --&gt; |Handles| E3[Validation Errors]&#10; end&#10;&#10; classDef core fill:#f9f,stroke:#333,stroke-width:2px&#10; classDef tool fill:#bbf,stroke:#333,stroke-width:2px&#10; classDef handler fill:#bfb,stroke:#333,stroke-width:2px&#10;&#10; class TM,TR,TI core&#10; class T1,T2,T3,WS,CE,ME tool&#10; class EH,E1,E2,E3 handler\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" parent=\\"1\\" vertex=\\"1\\"><mxGeometry x=\\"224\\" y=\\"232\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/></mxCell></root></mxGraphModel></diagram><diagram id=\\"44PLLl0pgulDx2n2xTWC\\" name=\\"Type System\\"><mxGraphModel dx=\\"380\\" dy=\\"311\\" grid=\\"0\\" gridSize=\\"10\\" guides=\\"1\\" tooltips=\\"1\\" connect=\\"1\\" arrows=\\"1\\" fold=\\"1\\" page=\\"1\\" pageScale=\\"1\\" pageWidth=\\"850\\" pageHeight=\\"1100\\" background=\\"#ffffff\\" math=\\"0\\" shadow=\\"1\\"><root><mxCell id=\\"0\\"/><mxCell id=\\"1\\" parent=\\"0\\"/><mxCell id=\\"jTONh3Pudjw2xIwc2DDu-1\\" value=\\"classDiagram&#10; class TypeSystem {&#10; +register_type(name, validator, serializer)&#10; +validate(value, type_def)&#10; +parse_type_string(type_str)&#10; -_validate_complex_type(value, type_def)&#10; }&#10;&#10; class TypeDefinition {&#10; +name: str&#10; +validators: List&#10; +serializers: Optional&#10; +validate(value)&#10; +serialize(value)&#10; }&#10;&#10; class DeclarativeAgent {&#10; +input: str&#10; +output: str&#10; +tools: List&#10; +validate_input(value)&#10; +validate_output(value)&#10; }&#10;&#10; class Validator {&#10; +validate(value)&#10; +coerce(value)&#10; }&#10;&#10; TypeSystem --&gt; TypeDefinition : manages&#10; DeclarativeAgent --&gt; TypeSystem : uses&#10; TypeDefinition --&gt; Validator : uses&#10;&#10;\\" style=\\"shadow=0;dashed=0;align=left;strokeWidth=1;shape=mxgraph.mermaid.abstract.mermaid;labelBackgroundColor=#ffffff;noLabel=1;theme=default;\\" parent=\\"1\\" vertex=\\"1\\"><mxGeometry x=\\"242\\" y=\\"169\\" width=\\"300\\" height=\\"300\\" as=\\"geometry\\"/></mxCell></root></mxGraphModel></diagram></mxfile>"}',
11
+ cls="mxgraph",
12
+ ),
13
+ Script(type="text/javascript", src="https://viewer.diagrams.net/js/viewer-static.min.js"),
14
+ )