feat: add autonomous mode with --autonomous flag to enable self-directed execution

This commit is contained in:
2025-11-07 21:07:32 +00:00
parent 2ecc479427
commit 37268d2591
5 changed files with 49 additions and 13 deletions
+16 -9
View File
@@ -4,6 +4,11 @@ import urllib.parse
import urllib.request
import json
import urllib.parse
import urllib.request
def http_fetch(url, headers=None):
"""Fetch content from an HTTP URL.
@@ -15,25 +20,26 @@ def http_fetch(url, headers=None):
Dict with status and content.
"""
try:
req = urllib.request.Request(url)
request = urllib.request.Request(url)
if headers:
for key, value in headers.items():
req.add_header(key, value)
with urllib.request.urlopen(req) as response:
for header_key, header_value in headers.items():
request.add_header(header_key, header_value)
with urllib.request.urlopen(request) as response:
content = response.read().decode("utf-8")
return {"status": "success", "content": content[:10000]}
except Exception as e:
return {"status": "error", "error": str(e)}
except Exception as exception:
return {"status": "error", "error": str(exception)}
def _perform_search(base_url, query, params=None):
try:
full_url = f"https://static.molodetz.nl/search.cgi?query={query}"
encoded_query = urllib.parse.quote(query)
full_url = f"{base_url}?query={encoded_query}"
with urllib.request.urlopen(full_url) as response:
content = response.read().decode("utf-8")
return {"status": "success", "content": json.loads(content)}
except Exception as e:
return {"status": "error", "error": str(e)}
except Exception as exception:
return {"status": "error", "error": str(exception)}
def web_search(query):
@@ -60,3 +66,4 @@ def web_search_news(query):
"""
base_url = "https://search.molodetz.nl/search"
return _perform_search(base_url, query)