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.
- flock/__init__.py +4 -0
- flock/agents/__init__.py +3 -0
- flock/agents/batch_agent.py +175 -0
- flock/agents/declarative_agent.py +166 -0
- flock/agents/loop_agent.py +178 -0
- flock/agents/trigger_agent.py +191 -0
- flock/agents/user_agent.py +230 -0
- flock/app/components/__init__.py +14 -0
- flock/app/components/charts/agent_workflow.py +14 -0
- flock/app/components/charts/core_architecture.py +14 -0
- flock/app/components/charts/tool_system.py +14 -0
- flock/app/components/history_grid.py +168 -0
- flock/app/components/history_grid_alt.py +189 -0
- flock/app/components/sidebar.py +19 -0
- flock/app/components/theme.py +9 -0
- flock/app/components/util.py +18 -0
- flock/app/hive_app.py +118 -0
- flock/app/html/d3.html +179 -0
- flock/app/modules/__init__.py +12 -0
- flock/app/modules/about.py +17 -0
- flock/app/modules/agent_detail.py +70 -0
- flock/app/modules/agent_list.py +59 -0
- flock/app/modules/playground.py +322 -0
- flock/app/modules/settings.py +96 -0
- flock/core/__init__.py +7 -0
- flock/core/agent.py +150 -0
- flock/core/agent_registry.py +162 -0
- flock/core/config/declarative_agent_config.py +0 -0
- flock/core/context.py +279 -0
- flock/core/context_vars.py +6 -0
- flock/core/flock.py +208 -0
- flock/core/handoff/handoff_base.py +12 -0
- flock/core/logging/__init__.py +18 -0
- flock/core/logging/error_handler.py +84 -0
- flock/core/logging/formatters.py +122 -0
- flock/core/logging/handlers.py +117 -0
- flock/core/logging/logger.py +107 -0
- flock/core/serializable.py +206 -0
- flock/core/tools/basic_tools.py +98 -0
- flock/workflow/activities.py +115 -0
- flock/workflow/agent_activities.py +26 -0
- flock/workflow/temporal_setup.py +37 -0
- flock/workflow/workflow.py +53 -0
- flock_core-0.1.1.dist-info/METADATA +449 -0
- flock_core-0.1.1.dist-info/RECORD +48 -0
- flock_core-0.1.1.dist-info/WHEEL +4 -0
- flock_core-0.1.1.dist-info/entry_points.txt +2 -0
- 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 subgraph User Application UA[User Code] --> |Uses| SM[Flock Manager] end subgraph Flock Core SM --> |Manages| AR[Agent Registry] SM --> |Executes| WF[Workflow System] subgraph Agents AR --> |Registers| DA[Declarative Agent] DA --> |Uses| TS[Type System] DA --> |Uses| TM[Tool Manager] end subgraph Workflow WF --> |Runs| AC[Activities] WF --> |Uses| TW[Temporal Worker] AC --> |Executes| DA end end subgraph External Systems TW --> |Connects to| TS1[Temporal Server] TM --> |Integrates| T1[Web Search] TM --> |Integrates| T2[Code Eval] TM --> |Integrates| T3[Math Tools] DA --> |Uses| LLM[LLM Provider] end classDef core fill:#f9f,stroke:#333,stroke-width:2px classDef external fill:#bbf,stroke:#333,stroke-width:2px classDef user fill:#bfb,stroke:#333,stroke-width:2px class SM,AR,DA,WF,AC,TM,TS core class TS1,T1,T2,T3,LLM external class UA user \\" 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 participant User participant Flock participant Agent participant Tools participant LLM participant Temporal User->>Flock: Create Agent Flock->>Agent: Initialize User->>Flock: activate(agent, input) alt Local Debug Mode Flock->>Agent: Execute Directly else Production Mode Flock->>Temporal: Start Workflow Temporal->>Agent: Execute via Activity end loop Agent Execution Agent->>LLM: Process Input opt Tool Usage Agent->>Tools: Execute Tool Tools-->>Agent: Tool Result end Agent->>LLM: Generate Output end alt Has Hand-off Agent->>Flock: Hand off to Next Agent Flock->>Agent: Start Next Agent else No Hand-off Agent-->>Flock: Return Result end Flock-->>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 subgraph Temporal Integration WF[Workflow System] --> |Manages| TW[Temporal Worker] TW --> |Executes| AC[Activities] TW --> |Connects to| TS[Temporal Server] subgraph State Management TS --> |Manages| WS[Workflow State] WS --> |Tracks| AS[Agent State] WS --> |Tracks| TS1[Tool State] WS --> |Tracks| ES[Error State] end subgraph Reliability Features TS --> |Provides| R1[Automatic Retries] TS --> |Provides| R2[Error Recovery] TS --> |Provides| R3[State Persistence] TS --> |Provides| R4[Workflow History] end subgraph Monitoring TS --> |Enables| M1[Execution Metrics] TS --> |Enables| M2[Error Tracking] TS --> |Enables| M3[Performance Stats] TS --> |Enables| M4[Workflow Visualization] end end classDef core fill:#f9f,stroke:#333,stroke-width:2px classDef state fill:#bbf,stroke:#333,stroke-width:2px classDef feature fill:#bfb,stroke:#333,stroke-width:2px classDef monitor fill:#fbb,stroke:#333,stroke-width:2px class WF,TW,AC,TS core class WS,AS,TS1,ES state class R1,R2,R3,R4 feature class M1,M2,M3,M4 monitor \\" 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 subgraph Tool Management TM[Tool Manager] --> |Manages| TR[Tool Registry] TR --> |Registers| T1[Web Search Tool] TR --> |Registers| T2[Code Eval Tool] TR --> |Registers| T3[Math Tool] TM --> |Provides| TI[Tool Interface] TI --> |Used by| DA[Declarative Agent] end subgraph Tool Execution T1 --> |Uses| WS[Web Search API] T2 --> |Uses| CE[Code Executor] T3 --> |Uses| ME[Math Engine] WS --> |Returns| R1[Search Results] CE --> |Returns| R2[Execution Results] ME --> |Returns| R3[Math Results] end subgraph Error Handling TM --> |Manages| EH[Error Handler] EH --> |Handles| E1[API Errors] EH --> |Handles| E2[Execution Errors] EH --> |Handles| E3[Validation Errors] end classDef core fill:#f9f,stroke:#333,stroke-width:2px classDef tool fill:#bbf,stroke:#333,stroke-width:2px classDef handler fill:#bfb,stroke:#333,stroke-width:2px class TM,TR,TI core class T1,T2,T3,WS,CE,ME tool 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 class TypeSystem { +register_type(name, validator, serializer) +validate(value, type_def) +parse_type_string(type_str) -_validate_complex_type(value, type_def) } class TypeDefinition { +name: str +validators: List +serializers: Optional +validate(value) +serialize(value) } class DeclarativeAgent { +input: str +output: str +tools: List +validate_input(value) +validate_output(value) } class Validator { +validate(value) +coerce(value) } TypeSystem --> TypeDefinition : manages DeclarativeAgent --> TypeSystem : uses TypeDefinition --> Validator : uses \\" 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 subgraph User Application UA[User Code] --> |Uses| SM[Flock Manager] end subgraph Flock Core SM --> |Manages| AR[Agent Registry] SM --> |Executes| WF[Workflow System] subgraph Agents AR --> |Registers| DA[Declarative Agent] DA --> |Uses| TS[Type System] DA --> |Uses| TM[Tool Manager] end subgraph Workflow WF --> |Runs| AC[Activities] WF --> |Uses| TW[Temporal Worker] AC --> |Executes| DA end end subgraph External Systems TW --> |Connects to| TS1[Temporal Server] TM --> |Integrates| T1[Web Search] TM --> |Integrates| T2[Code Eval] TM --> |Integrates| T3[Math Tools] DA --> |Uses| LLM[LLM Provider] end classDef core fill:#f9f,stroke:#333,stroke-width:2px classDef external fill:#bbf,stroke:#333,stroke-width:2px classDef user fill:#bfb,stroke:#333,stroke-width:2px class SM,AR,DA,WF,AC,TM,TS core class TS1,T1,T2,T3,LLM external class UA user \\" 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 participant User participant Flock participant Agent participant Tools participant LLM participant Temporal User->>Flock: Create Agent Flock->>Agent: Initialize User->>Flock: activate(agent, input) alt Local Debug Mode Flock->>Agent: Execute Directly else Production Mode Flock->>Temporal: Start Workflow Temporal->>Agent: Execute via Activity end loop Agent Execution Agent->>LLM: Process Input opt Tool Usage Agent->>Tools: Execute Tool Tools-->>Agent: Tool Result end Agent->>LLM: Generate Output end alt Has Hand-off Agent->>Flock: Hand off to Next Agent Flock->>Agent: Start Next Agent else No Hand-off Agent-->>Flock: Return Result end Flock-->>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 subgraph Temporal Integration WF[Workflow System] --> |Manages| TW[Temporal Worker] TW --> |Executes| AC[Activities] TW --> |Connects to| TS[Temporal Server] subgraph State Management TS --> |Manages| WS[Workflow State] WS --> |Tracks| AS[Agent State] WS --> |Tracks| TS1[Tool State] WS --> |Tracks| ES[Error State] end subgraph Reliability Features TS --> |Provides| R1[Automatic Retries] TS --> |Provides| R2[Error Recovery] TS --> |Provides| R3[State Persistence] TS --> |Provides| R4[Workflow History] end subgraph Monitoring TS --> |Enables| M1[Execution Metrics] TS --> |Enables| M2[Error Tracking] TS --> |Enables| M3[Performance Stats] TS --> |Enables| M4[Workflow Visualization] end end classDef core fill:#f9f,stroke:#333,stroke-width:2px classDef state fill:#bbf,stroke:#333,stroke-width:2px classDef feature fill:#bfb,stroke:#333,stroke-width:2px classDef monitor fill:#fbb,stroke:#333,stroke-width:2px class WF,TW,AC,TS core class WS,AS,TS1,ES state class R1,R2,R3,R4 feature class M1,M2,M3,M4 monitor \\" 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 subgraph Tool Management TM[Tool Manager] --> |Manages| TR[Tool Registry] TR --> |Registers| T1[Web Search Tool] TR --> |Registers| T2[Code Eval Tool] TR --> |Registers| T3[Math Tool] TM --> |Provides| TI[Tool Interface] TI --> |Used by| DA[Declarative Agent] end subgraph Tool Execution T1 --> |Uses| WS[Web Search API] T2 --> |Uses| CE[Code Executor] T3 --> |Uses| ME[Math Engine] WS --> |Returns| R1[Search Results] CE --> |Returns| R2[Execution Results] ME --> |Returns| R3[Math Results] end subgraph Error Handling TM --> |Manages| EH[Error Handler] EH --> |Handles| E1[API Errors] EH --> |Handles| E2[Execution Errors] EH --> |Handles| E3[Validation Errors] end classDef core fill:#f9f,stroke:#333,stroke-width:2px classDef tool fill:#bbf,stroke:#333,stroke-width:2px classDef handler fill:#bfb,stroke:#333,stroke-width:2px class TM,TR,TI core class T1,T2,T3,WS,CE,ME tool 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 class TypeSystem { +register_type(name, validator, serializer) +validate(value, type_def) +parse_type_string(type_str) -_validate_complex_type(value, type_def) } class TypeDefinition { +name: str +validators: List +serializers: Optional +validate(value) +serialize(value) } class DeclarativeAgent { +input: str +output: str +tools: List +validate_input(value) +validate_output(value) } class Validator { +validate(value) +coerce(value) } TypeSystem --> TypeDefinition : manages DeclarativeAgent --> TypeSystem : uses TypeDefinition --> Validator : uses \\" 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 subgraph User Application UA[User Code] --> |Uses| SM[Flock Manager] end subgraph Flock Core SM --> |Manages| AR[Agent Registry] SM --> |Executes| WF[Workflow System] subgraph Agents AR --> |Registers| DA[Declarative Agent] DA --> |Uses| TS[Type System] DA --> |Uses| TM[Tool Manager] end subgraph Workflow WF --> |Runs| AC[Activities] WF --> |Uses| TW[Temporal Worker] AC --> |Executes| DA end end subgraph External Systems TW --> |Connects to| TS1[Temporal Server] TM --> |Integrates| T1[Web Search] TM --> |Integrates| T2[Code Eval] TM --> |Integrates| T3[Math Tools] DA --> |Uses| LLM[LLM Provider] end classDef core fill:#f9f,stroke:#333,stroke-width:2px classDef external fill:#bbf,stroke:#333,stroke-width:2px classDef user fill:#bfb,stroke:#333,stroke-width:2px class SM,AR,DA,WF,AC,TM,TS core class TS1,T1,T2,T3,LLM external class UA user \\" 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 participant User participant Flock participant Agent participant Tools participant LLM participant Temporal User->>Flock: Create Agent Flock->>Agent: Initialize User->>Flock: activate(agent, input) alt Local Debug Mode Flock->>Agent: Execute Directly else Production Mode Flock->>Temporal: Start Workflow Temporal->>Agent: Execute via Activity end loop Agent Execution Agent->>LLM: Process Input opt Tool Usage Agent->>Tools: Execute Tool Tools-->>Agent: Tool Result end Agent->>LLM: Generate Output end alt Has Hand-off Agent->>Flock: Hand off to Next Agent Flock->>Agent: Start Next Agent else No Hand-off Agent-->>Flock: Return Result end Flock-->>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 subgraph Temporal Integration WF[Workflow System] --> |Manages| TW[Temporal Worker] TW --> |Executes| AC[Activities] TW --> |Connects to| TS[Temporal Server] subgraph State Management TS --> |Manages| WS[Workflow State] WS --> |Tracks| AS[Agent State] WS --> |Tracks| TS1[Tool State] WS --> |Tracks| ES[Error State] end subgraph Reliability Features TS --> |Provides| R1[Automatic Retries] TS --> |Provides| R2[Error Recovery] TS --> |Provides| R3[State Persistence] TS --> |Provides| R4[Workflow History] end subgraph Monitoring TS --> |Enables| M1[Execution Metrics] TS --> |Enables| M2[Error Tracking] TS --> |Enables| M3[Performance Stats] TS --> |Enables| M4[Workflow Visualization] end end classDef core fill:#f9f,stroke:#333,stroke-width:2px classDef state fill:#bbf,stroke:#333,stroke-width:2px classDef feature fill:#bfb,stroke:#333,stroke-width:2px classDef monitor fill:#fbb,stroke:#333,stroke-width:2px class WF,TW,AC,TS core class WS,AS,TS1,ES state class R1,R2,R3,R4 feature class M1,M2,M3,M4 monitor \\" 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 subgraph Tool Management TM[Tool Manager] --> |Manages| TR[Tool Registry] TR --> |Registers| T1[Web Search Tool] TR --> |Registers| T2[Code Eval Tool] TR --> |Registers| T3[Math Tool] TM --> |Provides| TI[Tool Interface] TI --> |Used by| DA[Declarative Agent] end subgraph Tool Execution T1 --> |Uses| WS[Web Search API] T2 --> |Uses| CE[Code Executor] T3 --> |Uses| ME[Math Engine] WS --> |Returns| R1[Search Results] CE --> |Returns| R2[Execution Results] ME --> |Returns| R3[Math Results] end subgraph Error Handling TM --> |Manages| EH[Error Handler] EH --> |Handles| E1[API Errors] EH --> |Handles| E2[Execution Errors] EH --> |Handles| E3[Validation Errors] end classDef core fill:#f9f,stroke:#333,stroke-width:2px classDef tool fill:#bbf,stroke:#333,stroke-width:2px classDef handler fill:#bfb,stroke:#333,stroke-width:2px class TM,TR,TI core class T1,T2,T3,WS,CE,ME tool 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 class TypeSystem { +register_type(name, validator, serializer) +validate(value, type_def) +parse_type_string(type_str) -_validate_complex_type(value, type_def) } class TypeDefinition { +name: str +validators: List +serializers: Optional +validate(value) +serialize(value) } class DeclarativeAgent { +input: str +output: str +tools: List +validate_input(value) +validate_output(value) } class Validator { +validate(value) +coerce(value) } TypeSystem --> TypeDefinition : manages DeclarativeAgent --> TypeSystem : uses TypeDefinition --> Validator : uses \\" 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
|
+
)
|