Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

feat: update browser_nonvisual_human_in_the_loop and EdgeOnePagesMCPToolkit (#2710)

Tao Suna3c30db8844e
diff --git a/camel/toolkits/__init__.py b/camel/toolkits/__init__.py
index d1e5354af..ab929931c 100644
--- a/camel/toolkits/__init__.py
+++ b/camel/toolkits/__init__.py
@@ -78,6 +78,7 @@ from .playwright_mcp_toolkit import PlaywrightMCPToolkit
from .wolfram_alpha_toolkit import WolframAlphaToolkit
from .task_planning_toolkit import TaskPlanningToolkit
from .non_visual_browser_toolkit import BrowserNonVisualToolkit
+from .edgeone_pages_mcp_toolkit import EdgeOnePagesMCPToolkit
__all__ = [
@@ -144,4 +145,5 @@ __all__ = [
'BohriumToolkit',
'TaskPlanningToolkit',
'BrowserNonVisualToolkit',
+ 'EdgeOnePagesMCPToolkit',
]
diff --git a/camel/toolkits/edgeone_pages_mcp_toolkit.py b/camel/toolkits/edgeone_pages_mcp_toolkit.py
new file mode 100644
index 000000000..f17c02ffd
--- /dev/null
+++ b/camel/toolkits/edgeone_pages_mcp_toolkit.py
@@ -0,0 +1,69 @@
+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
+
+from typing import List, Optional
+
+from camel.toolkits import BaseToolkit, FunctionTool
+
+from .mcp_toolkit import MCPToolkit
+
+
+class EdgeOnePagesMCPToolkit(BaseToolkit):
+ r"""EdgeOnePagesMCPToolkit provides an interface for interacting with
+ EdgeOne pages using the EdgeOne Pages MCP server.
+
+ Attributes:
+ timeout (Optional[float]): Connection timeout in seconds.
+ (default: :obj:`None`)
+ """
+
+ def __init__(
+ self,
+ timeout: Optional[float] = None,
+ ) -> None:
+ r"""Initializes the EdgeOnePagesMCPToolkit.
+
+ Args:
+ timeout (Optional[float]): Connection timeout in seconds.
+ (default: :obj:`None`)
+ """
+ super().__init__(timeout=timeout)
+
+ self._mcp_toolkit = MCPToolkit(
+ config_dict={
+ "mcpServers": {
+ "edgeone-pages-mcp-server": {
+ "command": "npx",
+ "args": ["edgeone-pages-mcp"],
+ }
+ }
+ },
+ timeout=timeout,
+ )
+
+ async def connect(self):
+ r"""Explicitly connect to the EdgeOne Pages MCP server."""
+ await self._mcp_toolkit.connect()
+
+ async def disconnect(self):
+ r"""Explicitly disconnect from the EdgeOne Pages MCP server."""
+ await self._mcp_toolkit.disconnect()
+
+ def get_tools(self) -> List[FunctionTool]:
+ r"""Returns a list of tools provided by the EdgeOnePagesMCPToolkit.
+
+ Returns:
+ List[FunctionTool]: List of available tools.
+ """
+ return self._mcp_toolkit.get_tools()
diff --git a/camel/toolkits/non_visual_browser_toolkit/browser_non_visual_toolkit.py b/camel/toolkits/non_visual_browser_toolkit/browser_non_visual_toolkit.py
index cae8dd274..a4d1b9129 100644
--- a/camel/toolkits/non_visual_browser_toolkit/browser_non_visual_toolkit.py
+++ b/camel/toolkits/non_visual_browser_toolkit/browser_non_visual_toolkit.py
@@ -115,16 +115,19 @@ class BrowserNonVisualToolkit(BaseToolkit):
async def open_browser(
self, start_url: Optional[str] = None
) -> Dict[str, str]:
- r"""Launch a Playwright browser session.
+ r"""Launches a new browser session. This should be the first step.
Args:
- start_url (Optional[str]): Optional URL to navigate to immediately
- after the browser launches. If not provided, the browser will
- not navigate to any URL. (default: :obj:`None`)
+ start_url (Optional[str]): The URL to navigate to after the browser
+ launches. If not provided, the browser will open with a blank
+ page. (default: :obj:`None`)
Returns:
- Dict[str, str]: Keys: ``result`` for action outcome,
- ``snapshot`` for full DOM snapshot.
+ Dict[str, str]: A dictionary containing the result of the action
+ and a snapshot of the page. The keys are "result" and
+ "snapshot". The "snapshot" is a YAML-like representation of
+ the page's DOM structure, including element references
+ (e.g., "e3") that can be used in other tool calls.
"""
await self._session.ensure_browser()
if start_url:
@@ -136,10 +139,12 @@ class BrowserNonVisualToolkit(BaseToolkit):
return {"result": "Browser session started.", "snapshot": snapshot}
async def close_browser(self) -> str:
- r"""Terminate the current browser session and free all resources.
+ r"""Closes the current browser session, freeing up all associated
+ resources. This should be called when the browsing task is complete.
Returns:
- str: Confirmation message.
+ str: A confirmation message indicating the session has been
+ closed.
"""
# Close agent if it exists
if self._agent is not None:
@@ -154,14 +159,17 @@ class BrowserNonVisualToolkit(BaseToolkit):
return "Browser session closed."
async def visit_page(self, url: str) -> Dict[str, str]:
- r"""Navigate the current page to the specified URL.
+ r"""Navigates the current browser page to a new URL.
Args:
- url (str): The destination URL.
+ url (str): The URL to navigate to. Must be a fully qualified URL
+ (e.g., "https://www.google.com").
Returns:
- Dict[str, str]: Keys: ``result`` for action outcome,
- ``snapshot`` for full DOM snapshot.
+ Dict[str, str]: A dictionary containing the navigation result and a
+ snapshot of the new page. The keys are "result" and
+ "snapshot". The "snapshot" provides a fresh view of the
+ page's DOM structure.
"""
if not url or not isinstance(url, str):
raise ValueError("visit_page(): 'url' must be a non-empty string")
@@ -192,14 +200,16 @@ class BrowserNonVisualToolkit(BaseToolkit):
)
async def click(self, *, ref: str) -> Dict[str, str]:
- r"""Click an element identified by ``ref``
+ r"""Performs a click action on a specified element on the current page.
Args:
- ref (str): Element reference ID extracted from snapshot
- (e.g.``"e3"``).
+ ref (str): The reference ID of the element to click. This ID is
+ obtained from the page snapshot (e.g., "e12").
Returns:
- Dict[str, str]: Result message from ``ActionExecutor``.
+ Dict[str, str]: A dictionary containing the result of the action.
+ If the click causes a change in the page's structure, a
+ "snapshot" key will be included with a diff of the changes.
"""
self._validate_ref(ref, "click")
@@ -207,15 +217,16 @@ class BrowserNonVisualToolkit(BaseToolkit):
return await self._exec_with_snapshot(action)
async def type(self, *, ref: str, text: str) -> Dict[str, str]:
- r"""Type text into an input or textarea element.
+ r"""Types text into an input field or textarea on the current page.
Args:
- ref (str): Element reference ID extracted from snapshot.
- (e.g.``"e3"``).
- text (str): The text to enter.
+ ref (str): The reference ID of the input element. This ID is
+ obtained from the page snapshot (e.g., "e25").
+ text (str): The text to be typed into the element.
Returns:
- Dict[str, str]: Execution result message.
+ Dict[str, str]: A dictionary containing the result of the action.
+ The key is "result".
"""
self._validate_ref(ref, "type")
@@ -223,14 +234,17 @@ class BrowserNonVisualToolkit(BaseToolkit):
return await self._exec_with_snapshot(action)
async def select(self, *, ref: str, value: str) -> Dict[str, str]:
- r"""Select an option in a ``<select>`` element.
+ r"""Selects an option from a dropdown (<select>) element on the page.
Args:
- ref (str): Element reference ID.
- value (str): The value / option to select.
+ ref (str): The reference ID of the <select> element. This ID is
+ obtained from the page snapshot.
+ value (str): The value of the option to be selected. This should
+ match the 'value' attribute of an <option> tag.
Returns:
- Dict[str, str]: Execution result message.
+ Dict[str, str]: A dictionary containing the result of the action.
+ The key is "result".
"""
self._validate_ref(ref, "select")
@@ -238,15 +252,16 @@ class BrowserNonVisualToolkit(BaseToolkit):
return await self._exec_with_snapshot(action)
async def scroll(self, *, direction: str, amount: int) -> Dict[str, str]:
- r"""Scroll the page.
+ r"""Scrolls the current page up or down by a specified amount.
Args:
- direction (str): Scroll direction, should be ``"down"`` or
- ``"up"``.
- amount (int): Pixel distance to scroll.
+ direction (str): The direction to scroll. Must be either "up" or
+ "down".
+ amount (int): The number of pixels to scroll.
Returns:
- Dict[str, str]: Execution result message.
+ Dict[str, str]: A dictionary containing the result of the action.
+ The key is "result".
"""
if direction not in ("up", "down"):
logger.error("scroll(): 'direction' must be 'up' or 'down'")
@@ -258,53 +273,72 @@ class BrowserNonVisualToolkit(BaseToolkit):
return await self._exec_with_snapshot(action)
async def enter(self, *, ref: str) -> Dict[str, str]:
- r"""Press the Enter key.
+ r"""Simulates pressing the Enter key on a specific element.
+ This is often used to submit forms.
Args:
- ref (str): Element reference ID to focus before pressing.
+ ref (str): The reference ID of the element to focus before
+ pressing Enter. This ID is obtained from the page snapshot.
Returns:
- Dict[str, str]: Execution result message.
+ Dict[str, str]: A dictionary containing the result of the action.
+ If pressing Enter causes a page navigation or DOM change, a
+ "snapshot" key will be included with a diff of the changes.
"""
self._validate_ref(ref, "enter")
action: Dict[str, Any] = {"type": "enter", "ref": ref}
return await self._exec_with_snapshot(action)
- async def wait_user(self, *, seconds: float = 1.0) -> Dict[str, str]:
- r"""Pause execution for a given amount of *real* time and then
- return a *full* page snapshot.
-
- This is a convenience wrapper around the existing wait action for
- scenarios where you encounter a CAPTCHA or need to pause for manual
- user input, and want to retrieve the complete DOM snapshot afterward.
+ async def wait_user(
+ self,
+ timeout_sec: Optional[float] = None,
+ ) -> Dict[str, str]:
+ r"""Pauses the agent's execution and waits for human intervention.
+ This is useful for tasks that require manual steps, like solving a
+ CAPTCHA. The agent will print a message and wait for the user to
+ press the Enter key in the console.
Args:
- seconds (float): How long to sleep, expressed in seconds. Must
- be a positive number. (default: :obj:`1.0`)
+ timeout_sec (Optional[float]): The maximum time in seconds to wait
+ for the user. If `None`, it will wait indefinitely. Defaults
+ to `None`. (default: :obj:`None`)
Returns:
- Dict[str, str]: Keys ``result`` and ``snapshot``.
+ Dict[str, str]: A dictionary containing a result message and a
+ full snapshot of the current page after the user has acted.
+ The keys are "result" and "snapshot".
"""
- if seconds is None or seconds <= 0:
- logger.error("wait_time(): 'seconds' must be a positive number")
- return {
- "result": "wait_time(): 'seconds' must be a positive number"
- }
- # Reuse underlying ActionExecutor's ``wait`` implementation (expects
- # ms)
- timeout_ms = int(seconds * 1000)
- action: Dict[str, Any] = {"type": "wait", "timeout": timeout_ms}
+ import asyncio
+
+ prompt = (
+ "🕑 Agent is waiting for human input. "
+ "Complete the required action in the browser, then press Enter "
+ "to continue..."
+ )
- # Execute the sleep via ActionExecutor (no snapshot diff expected)
- result = await self._exec(action)
+ logger.info(f"\n{prompt}\n")
+
+ async def _await_enter():
+ await asyncio.to_thread(input, ">>> Press Enter to resume <<<\n")
+
+ try:
+ if timeout_sec is not None:
+ await asyncio.wait_for(_await_enter(), timeout=timeout_sec)
+ result_msg = "User resumed."
+ else:
+ await _await_enter()
+ result_msg = "User resumed."
+ except asyncio.TimeoutError:
+ result_msg = f"Timeout {timeout_sec}s reached, auto-resumed."
- # Always return a *full* snapshot after the pause
snapshot = await self._session.get_snapshot(
- force_refresh=True, diff_only=False
+ force_refresh=True,
+ diff_only=False,
)
- return {"result": result, "snapshot": snapshot}
+
+ return {"result": result_msg, "snapshot": snapshot}
# Helper to run through ActionExecutor
async def _exec(self, action: Dict[str, Any]) -> str:
diff --git a/examples/toolkits/browser_non_visual_toolkit_example.py b/examples/toolkits/browser_non_visual_toolkit_example.py
index bdffe362c..2e4093b04 100644
--- a/examples/toolkits/browser_non_visual_toolkit_example.py
+++ b/examples/toolkits/browser_non_visual_toolkit_example.py
@@ -41,14 +41,12 @@ model_backend = ModelFactory.create(
web_toolkit = BrowserNonVisualToolkit(
headless=False,
- user_data_dir=USER_DATA_DIR,
)
agent = ChatAgent(
- system_message="""
- """,
model=model_backend,
tools=[*web_toolkit.get_tools()],
+ max_iteration=10,
)
TASK_PROMPT = """Click "Sign in to Google Account" on Google.
diff --git a/examples/toolkits/edgeone_pages_mcp_toolkit.py b/examples/toolkits/edgeone_pages_mcp_toolkit.py
new file mode 100644
index 000000000..c1fb5dda3
--- /dev/null
+++ b/examples/toolkits/edgeone_pages_mcp_toolkit.py
@@ -0,0 +1,56 @@
+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
+import asyncio
+
+from camel.agents import ChatAgent
+from camel.models import ModelFactory
+from camel.toolkits import EdgeOnePagesMCPToolkit
+from camel.types import ModelPlatformType, ModelType
+
+
+async def main():
+ edgeone_pages_mcp_toolkit = EdgeOnePagesMCPToolkit()
+
+ # connect to edgeone pages mcp
+ await edgeone_pages_mcp_toolkit.connect()
+
+ model = ModelFactory.create(
+ model_platform=ModelPlatformType.DEFAULT,
+ model_type=ModelType.DEFAULT,
+ )
+
+ chat_agent = ChatAgent(
+ model=model,
+ tools=edgeone_pages_mcp_toolkit.get_tools(),
+ )
+
+ response = await chat_agent.astep(
+ "write a hello world page",
+ )
+ print(response.msg.content)
+
+ # disconnect from edgeone pages mcp
+ await edgeone_pages_mcp_toolkit.disconnect()
+
+
+# Run the async main function
+if __name__ == "__main__":
+ asyncio.run(main())
+
+"""
+==============================================================================
+I have created a "Hello, World!" web page for you. You can view it here:
+https://mcp.edgeone.site/share/7D8SNj2ftY9SRtPrWZ5rW
+==============================================================================
+"""
diff --git a/examples/workforce/eigent.py b/examples/workforce/eigent.py
index b7226fd49..b196bac65 100644
--- a/examples/workforce/eigent.py
+++ b/examples/workforce/eigent.py
@@ -25,6 +25,7 @@ from camel.toolkits import (
BrowserNonVisualToolkit,
CodeExecutionToolkit,
DalleToolkit,
+ EdgeOnePagesMCPToolkit,
FileWriteToolkit,
FunctionTool,
HumanToolkit,
@@ -43,13 +44,17 @@ from camel.toolkits import (
from camel.types import ModelPlatformType, ModelType
-def developer_agent_factory(model: BaseModelBackend, task_id: str):
+def developer_agent_factory(
+ model: BaseModelBackend,
+ task_id: str,
+ edgeone_pages_mcp_toolkit: EdgeOnePagesMCPToolkit,
+):
r"""Factory for creating a developer agent."""
tools = [
- *TerminalToolkit().get_tools(),
HumanToolkit().ask_human_via_console,
*TerminalToolkit(clone_current_env=True).get_tools(),
*CodeExecutionToolkit().get_tools(),
+ *edgeone_pages_mcp_toolkit.get_tools(),
]
system_message = """You are a skilled coding assistant with DIRECT CODE
@@ -62,6 +67,10 @@ def developer_agent_factory(model: BaseModelBackend, task_id: str):
needed for efficient solutions
- IMPLEMENT complete, production-ready code rather than theoretical
examples
+ - USE edgeone pages mcp toolkit to create and edit web pages, after you
+ have created the web page, you can use the browser toolkit to view the
+ web page,you can let search agent to visit the web page and verify the
+ web page.
- DEMONSTRATE results with proper error handling and practical
implementation
- If there's dependency issues when you try to execute code, you should
@@ -339,94 +348,132 @@ When assisting users, always:
async def main():
- # Create a single model backend for all agents
- model_backend = ModelFactory.create(
- model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_4_1_MINI,
- # model_config_dict={
- # "max_tokens": 32768,
- # },
- )
-
- model_backend_reason = ModelFactory.create(
- model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_4_1_MINI,
- # model_config_dict={
- # "max_tokens": 32768,
- # },
- )
-
- task_id = 'workforce_task'
-
- # Create agents using factory functions
- search_agent = search_agent_factory(model_backend, task_id)
- developer_agent = developer_agent_factory(model_backend, task_id)
- document_agent = document_agent_factory(model_backend, task_id)
- multi_modal_agent = multi_modal_agent_factory(model_backend, task_id)
- # social_medium_agent = social_medium_agent_factory(model_backend,
- # task_id)
-
- # Configure kwargs for all agents to use the same model_backend
- coordinator_agent_kwargs = {"model": model_backend_reason}
- task_agent_kwargs = {"model": model_backend_reason}
- new_worker_agent_kwargs = {"model": model_backend}
-
- workforce = Workforce(
- 'A workforce',
- graceful_shutdown_timeout=30.0, # 30 seconds for debugging
- share_memory=False,
- coordinator_agent_kwargs=coordinator_agent_kwargs,
- task_agent_kwargs=task_agent_kwargs,
- new_worker_agent_kwargs=new_worker_agent_kwargs,
- )
-
- workforce.add_single_agent_worker(
- "Search Agent: Can search the web, extract webpage content, "
- "simulate browser actions, and provide relevant information to "
- "solve the given task.",
- worker=search_agent,
- ).add_single_agent_worker(
- "Developer Agent: A skilled coding assistant that can write and "
- "execute code, run terminal commands, and verify solutions to "
- "complete tasks.",
- worker=developer_agent,
- ).add_single_agent_worker(
- "Document Agent: A document processing assistant for creating, "
- "modifying, and managing various document formats, including "
- "presentations.",
- worker=document_agent,
- ).add_single_agent_worker(
- "Multi-Modal Agent: A multi-modal processing assistant for "
- "analyzing, and generating media content like audio and images.",
- worker=multi_modal_agent,
- )
-
- # specify the task to be solved
- human_task = Task(
- content=(
- """
-I want to read papers about GUI Agent. Please help me find ten papers and summarize them into a report.
- """ # noqa: E501
- ),
- id='0',
- )
-
- # Use the async version directly to avoid hanging with async tools
- await workforce.process_task_async(human_task)
-
- # Test WorkforceLogger features
- print("\n--- Workforce Log Tree ---")
- print(workforce.get_workforce_log_tree())
-
- print("\n--- Workforce KPIs ---")
- kpis = workforce.get_workforce_kpis()
- for key, value in kpis.items():
- print(f"{key}: {value}")
-
- log_file_path = "eigent_logs.json"
- print(f"\n--- Dumping Workforce Logs to {log_file_path} ---")
- workforce.dump_workforce_logs(log_file_path)
- print(f"Logs dumped. Please check the file: {log_file_path}")
+ edgeone_pages_mcp_toolkit = EdgeOnePagesMCPToolkit()
+ try:
+ await edgeone_pages_mcp_toolkit.connect()
+
+ # Create a single model backend for all agents
+ model_backend = ModelFactory.create(
+ model_platform=ModelPlatformType.OPENAI,
+ model_type=ModelType.GPT_4_1_MINI,
+ # model_config_dict={
+ # "max_tokens": 32768,
+ # },
+ )
+
+ model_backend_reason = ModelFactory.create(
+ model_platform=ModelPlatformType.OPENAI,
+ model_type=ModelType.GPT_4_1_MINI,
+ # model_config_dict={
+ # "max_tokens": 32768,
+ # },
+ )
+
+ task_id = 'workforce_task'
+
+ # Configure kwargs for all agents to use the same model_backend
+ coordinator_agent_kwargs = {"model": model_backend_reason}
+ task_agent_kwargs = {"model": model_backend_reason}
+ new_worker_agent_kwargs = {"model": model_backend}
+
+ # Create agents using factory functions
+ search_agent = search_agent_factory(
+ model_backend, task_id, edgeone_pages_mcp_toolkit
+ )
+ developer_agent = developer_agent_factory(model_backend, task_id)
+ document_agent = document_agent_factory(model_backend, task_id)
+ multi_modal_agent = multi_modal_agent_factory(model_backend, task_id)
+
+ # Configure kwargs for all agents to use the same model_backend
+ coordinator_agent_kwargs = {"model": model_backend_reason}
+ task_agent_kwargs = {"model": model_backend_reason}
+ new_worker_agent_kwargs = {"model": model_backend}
+
+ # Create workforce instance before adding workers
+ workforce = Workforce(
+ 'A workforce',
+ graceful_shutdown_timeout=30.0, # 30 seconds for debugging
+ share_memory=False,
+ coordinator_agent_kwargs=coordinator_agent_kwargs,
+ task_agent_kwargs=task_agent_kwargs,
+ new_worker_agent_kwargs=new_worker_agent_kwargs,
+ )
+
+ workforce.add_single_agent_worker(
+ "Search Agent: Can search the web, extract webpage content, "
+ "simulate browser actions, and provide relevant information to "
+ "solve the given task.",
+ worker=search_agent,
+ ).add_single_agent_worker(
+ "Developer Agent: A skilled coding assistant that can write and "
+ "execute code, run terminal commands, and verify solutions to "
+ "complete tasks.",
+ worker=developer_agent,
+ ).add_single_agent_worker(
+ "Document Agent: A document processing assistant for creating, "
+ "modifying, and managing various document formats, including "
+ "presentations.",
+ worker=document_agent,
+ ).add_single_agent_worker(
+ "Multi-Modal Agent: A multi-modal processing assistant for "
+ "analyzing, and generating media content like audio and images.",
+ worker=multi_modal_agent,
+ )
+
+ # specify the task to be solved
+ human_task = Task(
+ content=(
+ """
+ I want to read papers about GUI Agent. Please help me find ten papers and summarize them into a report.
+ """ # noqa: E501
+ ),
+ id='0',
+ )
+
+ workforce.add_single_agent_worker(
+ "Search Agent: Can search the web, extract webpage content, "
+ "simulate browser actions, and provide relevant information to "
+ "solve the given task.",
+ worker=search_agent,
+ )
+
+ workforce.add_single_agent_worker(
+ "Document Agent: A document processing assistant for creating, "
+ "modifying, and managing various document formats, including "
+ "presentations.",
+ worker=document_agent,
+ )
+
+ # specify the task to be solved
+ human_task = Task(
+ content=(
+ """
+ Gather today's headline news from BBC, Washington Post, Google News and
+ CNN. Each headline can be processed in parallel by the SearchAgent pool.
+ """
+ ),
+ id='0',
+ )
+
+ # Use the async version directly to avoid hanging with async tools
+ await workforce.process_task_async(human_task)
+
+ # Test WorkforceLogger features
+ print("\n--- Workforce Log Tree ---")
+ print(workforce.get_workforce_log_tree())
+
+ print("\n--- Workforce KPIs ---")
+ kpis = workforce.get_workforce_kpis()
+ for key, value in kpis.items():
+ print(f"{key}: {value}")
+
+ log_file_path = "eigent_logs.json"
+ print(f"\n--- Dumping Workforce Logs to {log_file_path} ---")
+ workforce.dump_workforce_logs(log_file_path)
+ print(f"Logs dumped. Please check the file: {log_file_path}")
+
+ finally:
+ await edgeone_pages_mcp_toolkit.disconnect()
if __name__ == "__main__":