add main for sandbox_agent

This commit is contained in:
GhostC
2025-07-20 02:17:08 +08:00
parent 5731b63984
commit 398ae434ed
3 changed files with 37 additions and 0 deletions
+1
View File
@@ -71,6 +71,7 @@ class SandboxManus(ToolCallAgent):
def initialize_sandbox_tools(self,password="123456") -> None:
sandbox = create_sandbox(password=password)
print(f"VNC link: {sandbox.get_preview_link(6080)}")
computer_tool = SandboxBrowserTool.create_with_sandbox(sandbox)
sandbox_tools=[computer_tool]
self.available_tools.add_tools(*sandbox_tools)
+36
View File
@@ -0,0 +1,36 @@
import argparse
import asyncio
from app.agent.sandbox_agent import SandboxManus
from app.logger import logger
async def main():
# Parse command line arguments
parser = argparse.ArgumentParser(description="Run Manus agent with a prompt")
parser.add_argument(
"--prompt", type=str, required=False, help="Input prompt for the agent"
)
args = parser.parse_args()
# Create and initialize Manus agent
agent = await SandboxManus.create()
try:
# Use command line prompt if provided, otherwise ask for input
prompt = args.prompt if args.prompt else input("Enter your prompt: ")
if not prompt.strip():
logger.warning("Empty prompt provided.")
return
logger.warning("Processing your request...")
await agent.run(prompt)
logger.info("Request processing completed.")
except KeyboardInterrupt:
logger.warning("Operation interrupted.")
finally:
# Ensure agent resources are cleaned up before exiting
await agent.cleanup()
if __name__ == "__main__":
asyncio.run(main())
View File