Spaces:
Paused
Paused
frdel commited on
Commit ·
e8387ce
1
Parent(s): 1f02b5e
cleanup
Browse files- prompts/hacker/agent.system.main.environment.md +7 -0
- prompts/reflection/agent.system.main.communication.md +0 -28
- prompts/reflection/agent.system.main.solving.md +0 -36
- prompts/reflection/agent.system.main.tips.md +0 -20
- python/helpers/tunnel_manager.py +1 -1
- python/tools/browser._py +61 -0
- python/tools/browser.py +0 -61
- python/tools/browser_do._py +64 -0
- python/tools/browser_do.py +0 -64
- python/tools/browser_open._py +30 -0
- python/tools/browser_open.py +0 -30
prompts/hacker/agent.system.main.environment.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Environment
|
| 2 |
+
live in kali linux docker container use debian kali packages
|
| 3 |
+
agent zero framework is python project in /a0 folder
|
| 4 |
+
linux fully root accessible via terminal
|
| 5 |
+
utilize kali hacking tools for job
|
| 6 |
+
wordlists need downloading
|
| 7 |
+
consider fact running in docker for network operations
|
prompts/reflection/agent.system.main.communication.md
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
## Communication
|
| 3 |
-
|
| 4 |
-
respond valid json with fields
|
| 5 |
-
thoughts: decompose ➔ create decision trees ➔ forest of thoughts
|
| 6 |
-
reflection: question logical frameworks ➔ refine thoughts ➔ perform metareflection
|
| 7 |
-
math requires katex $...$ delims, only use in response tool
|
| 8 |
-
tool_name: use tool name
|
| 9 |
-
tool_args: key value pairs tool arguments
|
| 10 |
-
no other text
|
| 11 |
-
|
| 12 |
-
### Response example
|
| 13 |
-
|
| 14 |
-
~~~json
|
| 15 |
-
{
|
| 16 |
-
"thoughts": [
|
| 17 |
-
"...",
|
| 18 |
-
],
|
| 19 |
-
"reflection": [
|
| 20 |
-
"...",
|
| 21 |
-
],
|
| 22 |
-
"tool_name": "name_of_tool",
|
| 23 |
-
"tool_args": {
|
| 24 |
-
"arg1": "val1",
|
| 25 |
-
"arg2": "val2"
|
| 26 |
-
}
|
| 27 |
-
}
|
| 28 |
-
~~~
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prompts/reflection/agent.system.main.solving.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
## Problem solving
|
| 2 |
-
|
| 3 |
-
0 think
|
| 4 |
-
thoughts: decision trees forming
|
| 5 |
-
never assume always verify
|
| 6 |
-
model missing variables
|
| 7 |
-
reflection: metareflection
|
| 8 |
-
reflect and adapt
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
1 check memories solutions instruments prefer instruments
|
| 12 |
-
|
| 13 |
-
2 use knowledge_tool for online sources
|
| 14 |
-
seek simple solutions compatible with tools
|
| 15 |
-
prefer opensource python nodejs terminal tools
|
| 16 |
-
|
| 17 |
-
3 refine
|
| 18 |
-
validate widen approach
|
| 19 |
-
prefer simple compatible solutions
|
| 20 |
-
favor open-source Python Node.js Linux terminal tools
|
| 21 |
-
|
| 22 |
-
4 solve or delegate
|
| 23 |
-
tools solve subtasks
|
| 24 |
-
you can use subordinates for specific subtasks
|
| 25 |
-
call_subordinate tool
|
| 26 |
-
always describe role for new subordinate
|
| 27 |
-
they must execute their assigned tasks
|
| 28 |
-
|
| 29 |
-
5 task reporting
|
| 30 |
-
consolidate explain status
|
| 31 |
-
present results verify with tools
|
| 32 |
-
don't accept failure retry with fixes be high-agency
|
| 33 |
-
save useful info with memorize tool
|
| 34 |
-
fullfil initial user task
|
| 35 |
-
response_tool reports final result
|
| 36 |
-
responses need response_tool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prompts/reflection/agent.system.main.tips.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
## General operation manual
|
| 3 |
-
|
| 4 |
-
reason refine execute tasks
|
| 5 |
-
avoid repetition ensure progress
|
| 6 |
-
never assume success
|
| 7 |
-
memory refers to knowledge_tool and memorize_tool not own knowledge
|
| 8 |
-
beware cognitive biases
|
| 9 |
-
|
| 10 |
-
## Instruments
|
| 11 |
-
|
| 12 |
-
instruments are programs to solve tasks
|
| 13 |
-
instrument descriptions in prompt executed with code_execution_tool
|
| 14 |
-
|
| 15 |
-
## Best practices
|
| 16 |
-
|
| 17 |
-
python nodejs linux libraries for solutions
|
| 18 |
-
use tools to simplify tasks
|
| 19 |
-
sometimes tools are unnecessary
|
| 20 |
-
never rely on aging memories like time date etc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
python/helpers/tunnel_manager.py
CHANGED
|
@@ -35,7 +35,7 @@ class TunnelManager:
|
|
| 35 |
config = FlareConfig(port=port, verbose=True)
|
| 36 |
self.tunnel = FlareTunnel(config)
|
| 37 |
else: # Default to serveo
|
| 38 |
-
config = ServeoConfig(port=port)
|
| 39 |
self.tunnel = ServeoTunnel(config)
|
| 40 |
|
| 41 |
self.tunnel.start()
|
|
|
|
| 35 |
config = FlareConfig(port=port, verbose=True)
|
| 36 |
self.tunnel = FlareTunnel(config)
|
| 37 |
else: # Default to serveo
|
| 38 |
+
config = ServeoConfig(port=port) # type: ignore
|
| 39 |
self.tunnel = ServeoTunnel(config)
|
| 40 |
|
| 41 |
self.tunnel.start()
|
python/tools/browser._py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# import asyncio
|
| 2 |
+
# from dataclasses import dataclass
|
| 3 |
+
# import time
|
| 4 |
+
# from python.helpers.tool import Tool, Response
|
| 5 |
+
# from python.helpers import files, rfc_exchange
|
| 6 |
+
# from python.helpers.print_style import PrintStyle
|
| 7 |
+
# from python.helpers.browser import Browser as BrowserManager
|
| 8 |
+
# import uuid
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# @dataclass
|
| 12 |
+
# class State:
|
| 13 |
+
# browser: BrowserManager
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# class Browser(Tool):
|
| 17 |
+
|
| 18 |
+
# async def execute(self, **kwargs):
|
| 19 |
+
# raise NotImplementedError
|
| 20 |
+
|
| 21 |
+
# def get_log_object(self):
|
| 22 |
+
# return self.agent.context.log.log(
|
| 23 |
+
# type="browser",
|
| 24 |
+
# heading=f"{self.agent.agent_name}: Using tool '{self.name}'",
|
| 25 |
+
# content="",
|
| 26 |
+
# kvps=self.args,
|
| 27 |
+
# )
|
| 28 |
+
|
| 29 |
+
# # async def after_execution(self, response, **kwargs):
|
| 30 |
+
# # await self.agent.hist_add_tool_result(self.name, response.message)
|
| 31 |
+
|
| 32 |
+
# async def save_screenshot(self):
|
| 33 |
+
# await self.prepare_state()
|
| 34 |
+
# path = files.get_abs_path("tmp/browser", f"{uuid.uuid4()}.png")
|
| 35 |
+
# await self.state.browser.screenshot(path, True)
|
| 36 |
+
# return "img://" + path
|
| 37 |
+
|
| 38 |
+
# async def prepare_state(self, reset=False):
|
| 39 |
+
# self.state = self.agent.get_data("_browser_state")
|
| 40 |
+
# if not self.state or reset:
|
| 41 |
+
# self.state = State(browser=BrowserManager())
|
| 42 |
+
# self.agent.set_data("_browser_state", self.state)
|
| 43 |
+
|
| 44 |
+
# def update_progress(self, text):
|
| 45 |
+
# progress = f"Browser: {text}"
|
| 46 |
+
# self.log.update(progress=text)
|
| 47 |
+
# self.agent.context.log.set_progress(progress)
|
| 48 |
+
|
| 49 |
+
# def cleanup_history(self):
|
| 50 |
+
# def cleanup_message(msg):
|
| 51 |
+
# if not msg.ai and isinstance(msg.content, dict) and "tool_name" in msg.content and str(msg.content["tool_name"]).startswith("browser_"):
|
| 52 |
+
# if not msg.summary:
|
| 53 |
+
# msg.summary = "browser content removed to save space"
|
| 54 |
+
|
| 55 |
+
# for msg in self.agent.history.current.messages:
|
| 56 |
+
# cleanup_message(msg)
|
| 57 |
+
|
| 58 |
+
# for prev in self.agent.history.topics:
|
| 59 |
+
# if not prev.summary:
|
| 60 |
+
# for msg in prev.messages:
|
| 61 |
+
# cleanup_message(msg)
|
python/tools/browser.py
DELETED
|
@@ -1,61 +0,0 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
-
from dataclasses import dataclass
|
| 3 |
-
import time
|
| 4 |
-
from python.helpers.tool import Tool, Response
|
| 5 |
-
from python.helpers import files, rfc_exchange
|
| 6 |
-
from python.helpers.print_style import PrintStyle
|
| 7 |
-
from python.helpers.browser import Browser as BrowserManager
|
| 8 |
-
import uuid
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
@dataclass
|
| 12 |
-
class State:
|
| 13 |
-
browser: BrowserManager
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
class Browser(Tool):
|
| 17 |
-
|
| 18 |
-
async def execute(self, **kwargs):
|
| 19 |
-
raise NotImplementedError
|
| 20 |
-
|
| 21 |
-
def get_log_object(self):
|
| 22 |
-
return self.agent.context.log.log(
|
| 23 |
-
type="browser",
|
| 24 |
-
heading=f"{self.agent.agent_name}: Using tool '{self.name}'",
|
| 25 |
-
content="",
|
| 26 |
-
kvps=self.args,
|
| 27 |
-
)
|
| 28 |
-
|
| 29 |
-
# async def after_execution(self, response, **kwargs):
|
| 30 |
-
# await self.agent.hist_add_tool_result(self.name, response.message)
|
| 31 |
-
|
| 32 |
-
async def save_screenshot(self):
|
| 33 |
-
await self.prepare_state()
|
| 34 |
-
path = files.get_abs_path("tmp/browser", f"{uuid.uuid4()}.png")
|
| 35 |
-
await self.state.browser.screenshot(path, True)
|
| 36 |
-
return "img://" + path
|
| 37 |
-
|
| 38 |
-
async def prepare_state(self, reset=False):
|
| 39 |
-
self.state = self.agent.get_data("_browser_state")
|
| 40 |
-
if not self.state or reset:
|
| 41 |
-
self.state = State(browser=BrowserManager())
|
| 42 |
-
self.agent.set_data("_browser_state", self.state)
|
| 43 |
-
|
| 44 |
-
def update_progress(self, text):
|
| 45 |
-
progress = f"Browser: {text}"
|
| 46 |
-
self.log.update(progress=text)
|
| 47 |
-
self.agent.context.log.set_progress(progress)
|
| 48 |
-
|
| 49 |
-
def cleanup_history(self):
|
| 50 |
-
def cleanup_message(msg):
|
| 51 |
-
if not msg.ai and isinstance(msg.content, dict) and "tool_name" in msg.content and str(msg.content["tool_name"]).startswith("browser_"):
|
| 52 |
-
if not msg.summary:
|
| 53 |
-
msg.summary = "browser content removed to save space"
|
| 54 |
-
|
| 55 |
-
for msg in self.agent.history.current.messages:
|
| 56 |
-
cleanup_message(msg)
|
| 57 |
-
|
| 58 |
-
for prev in self.agent.history.topics:
|
| 59 |
-
if not prev.summary:
|
| 60 |
-
for msg in prev.messages:
|
| 61 |
-
cleanup_message(msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
python/tools/browser_do._py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# import asyncio
|
| 2 |
+
# from python.helpers.tool import Tool, Response
|
| 3 |
+
# from python.tools.browser import Browser
|
| 4 |
+
# from python.helpers.browser import NoPageError
|
| 5 |
+
# import asyncio
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
# class BrowserDo(Browser):
|
| 9 |
+
|
| 10 |
+
# async def execute(self, fill=[], press=[], click=[], execute="", **kwargs):
|
| 11 |
+
# await self.prepare_state()
|
| 12 |
+
# result = ""
|
| 13 |
+
# try:
|
| 14 |
+
# if fill:
|
| 15 |
+
# self.update_progress("Filling fields...")
|
| 16 |
+
# for f in fill:
|
| 17 |
+
# await self.state.browser.fill(f["selector"], f["text"])
|
| 18 |
+
# await self.state.browser.wait(0.5)
|
| 19 |
+
# if press:
|
| 20 |
+
# self.update_progress("Pressing keys...")
|
| 21 |
+
# if fill:
|
| 22 |
+
# await self.state.browser.wait(1)
|
| 23 |
+
# for p in press:
|
| 24 |
+
# await self.state.browser.press(p)
|
| 25 |
+
# await self.state.browser.wait(0.5)
|
| 26 |
+
# if click:
|
| 27 |
+
# self.update_progress("Clicking...")
|
| 28 |
+
# if fill:
|
| 29 |
+
# await self.state.browser.wait(1)
|
| 30 |
+
# for c in click:
|
| 31 |
+
# await self.state.browser.click(c)
|
| 32 |
+
# await self.state.browser.wait(0.5)
|
| 33 |
+
# if execute:
|
| 34 |
+
# if fill or press or click:
|
| 35 |
+
# await self.state.browser.wait(1)
|
| 36 |
+
# self.update_progress("Executing...")
|
| 37 |
+
# result = await self.state.browser.execute(execute)
|
| 38 |
+
# self.log.update(result=result)
|
| 39 |
+
|
| 40 |
+
# self.update_progress("Retrieving...")
|
| 41 |
+
# await self.state.browser.wait_for_action()
|
| 42 |
+
# dom = await self.state.browser.get_clean_dom()
|
| 43 |
+
# if result:
|
| 44 |
+
# response = f"Result:\n{result}\n\nDOM:\n{dom}"
|
| 45 |
+
# else:
|
| 46 |
+
# response = dom
|
| 47 |
+
# self.update_progress("Taking screenshot...")
|
| 48 |
+
# screenshot = await self.save_screenshot()
|
| 49 |
+
# self.log.update(screenshot=screenshot)
|
| 50 |
+
# except Exception as e:
|
| 51 |
+
# response = str(e)
|
| 52 |
+
# self.log.update(error=response)
|
| 53 |
+
|
| 54 |
+
# try:
|
| 55 |
+
# screenshot = await self.save_screenshot()
|
| 56 |
+
# dom = await self.state.browser.get_clean_dom()
|
| 57 |
+
# response = f"Error:\n{response}\n\nDOM:\n{dom}"
|
| 58 |
+
# self.log.update(screenshot=screenshot)
|
| 59 |
+
# except Exception:
|
| 60 |
+
# pass
|
| 61 |
+
|
| 62 |
+
# self.cleanup_history()
|
| 63 |
+
# self.update_progress("Done")
|
| 64 |
+
# return Response(message=response, break_loop=False)
|
python/tools/browser_do.py
DELETED
|
@@ -1,64 +0,0 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
-
from python.helpers.tool import Tool, Response
|
| 3 |
-
from python.tools.browser import Browser
|
| 4 |
-
from python.helpers.browser import NoPageError
|
| 5 |
-
import asyncio
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
class BrowserDo(Browser):
|
| 9 |
-
|
| 10 |
-
async def execute(self, fill=[], press=[], click=[], execute="", **kwargs):
|
| 11 |
-
await self.prepare_state()
|
| 12 |
-
result = ""
|
| 13 |
-
try:
|
| 14 |
-
if fill:
|
| 15 |
-
self.update_progress("Filling fields...")
|
| 16 |
-
for f in fill:
|
| 17 |
-
await self.state.browser.fill(f["selector"], f["text"])
|
| 18 |
-
await self.state.browser.wait(0.5)
|
| 19 |
-
if press:
|
| 20 |
-
self.update_progress("Pressing keys...")
|
| 21 |
-
if fill:
|
| 22 |
-
await self.state.browser.wait(1)
|
| 23 |
-
for p in press:
|
| 24 |
-
await self.state.browser.press(p)
|
| 25 |
-
await self.state.browser.wait(0.5)
|
| 26 |
-
if click:
|
| 27 |
-
self.update_progress("Clicking...")
|
| 28 |
-
if fill:
|
| 29 |
-
await self.state.browser.wait(1)
|
| 30 |
-
for c in click:
|
| 31 |
-
await self.state.browser.click(c)
|
| 32 |
-
await self.state.browser.wait(0.5)
|
| 33 |
-
if execute:
|
| 34 |
-
if fill or press or click:
|
| 35 |
-
await self.state.browser.wait(1)
|
| 36 |
-
self.update_progress("Executing...")
|
| 37 |
-
result = await self.state.browser.execute(execute)
|
| 38 |
-
self.log.update(result=result)
|
| 39 |
-
|
| 40 |
-
self.update_progress("Retrieving...")
|
| 41 |
-
await self.state.browser.wait_for_action()
|
| 42 |
-
dom = await self.state.browser.get_clean_dom()
|
| 43 |
-
if result:
|
| 44 |
-
response = f"Result:\n{result}\n\nDOM:\n{dom}"
|
| 45 |
-
else:
|
| 46 |
-
response = dom
|
| 47 |
-
self.update_progress("Taking screenshot...")
|
| 48 |
-
screenshot = await self.save_screenshot()
|
| 49 |
-
self.log.update(screenshot=screenshot)
|
| 50 |
-
except Exception as e:
|
| 51 |
-
response = str(e)
|
| 52 |
-
self.log.update(error=response)
|
| 53 |
-
|
| 54 |
-
try:
|
| 55 |
-
screenshot = await self.save_screenshot()
|
| 56 |
-
dom = await self.state.browser.get_clean_dom()
|
| 57 |
-
response = f"Error:\n{response}\n\nDOM:\n{dom}"
|
| 58 |
-
self.log.update(screenshot=screenshot)
|
| 59 |
-
except Exception:
|
| 60 |
-
pass
|
| 61 |
-
|
| 62 |
-
self.cleanup_history()
|
| 63 |
-
self.update_progress("Done")
|
| 64 |
-
return Response(message=response, break_loop=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
python/tools/browser_open._py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# import asyncio
|
| 2 |
+
# from python.helpers.tool import Tool, Response
|
| 3 |
+
# from python.tools import browser
|
| 4 |
+
# from python.tools.browser import Browser
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
# class BrowserOpen(Browser):
|
| 8 |
+
|
| 9 |
+
# async def execute(self, url="", **kwargs):
|
| 10 |
+
# self.update_progress("Initializing...")
|
| 11 |
+
# await self.prepare_state()
|
| 12 |
+
|
| 13 |
+
# try:
|
| 14 |
+
# if url:
|
| 15 |
+
# self.update_progress("Opening page...")
|
| 16 |
+
# await self.state.browser.open(url)
|
| 17 |
+
|
| 18 |
+
# self.update_progress("Retrieving...")
|
| 19 |
+
# await self.state.browser.wait_for_action()
|
| 20 |
+
# response = await self.state.browser.get_clean_dom()
|
| 21 |
+
# self.update_progress("Taking screenshot...")
|
| 22 |
+
# screenshot = await self.save_screenshot()
|
| 23 |
+
# self.log.update(screenshot=screenshot)
|
| 24 |
+
# except Exception as e:
|
| 25 |
+
# response = str(e)
|
| 26 |
+
# self.log.update(error=response)
|
| 27 |
+
|
| 28 |
+
# self.cleanup_history()
|
| 29 |
+
# self.update_progress("Done")
|
| 30 |
+
# return Response(message=response, break_loop=False)
|
python/tools/browser_open.py
DELETED
|
@@ -1,30 +0,0 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
-
from python.helpers.tool import Tool, Response
|
| 3 |
-
from python.tools import browser
|
| 4 |
-
from python.tools.browser import Browser
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
class BrowserOpen(Browser):
|
| 8 |
-
|
| 9 |
-
async def execute(self, url="", **kwargs):
|
| 10 |
-
self.update_progress("Initializing...")
|
| 11 |
-
await self.prepare_state()
|
| 12 |
-
|
| 13 |
-
try:
|
| 14 |
-
if url:
|
| 15 |
-
self.update_progress("Opening page...")
|
| 16 |
-
await self.state.browser.open(url)
|
| 17 |
-
|
| 18 |
-
self.update_progress("Retrieving...")
|
| 19 |
-
await self.state.browser.wait_for_action()
|
| 20 |
-
response = await self.state.browser.get_clean_dom()
|
| 21 |
-
self.update_progress("Taking screenshot...")
|
| 22 |
-
screenshot = await self.save_screenshot()
|
| 23 |
-
self.log.update(screenshot=screenshot)
|
| 24 |
-
except Exception as e:
|
| 25 |
-
response = str(e)
|
| 26 |
-
self.log.update(error=response)
|
| 27 |
-
|
| 28 |
-
self.cleanup_history()
|
| 29 |
-
self.update_progress("Done")
|
| 30 |
-
return Response(message=response, break_loop=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|