v2.0: Multi-user platform with agent catalog, admin panel, LLM providers
This commit is contained in:
@@ -3,9 +3,12 @@
|
||||
|
||||
from daily_briefing import run
|
||||
|
||||
INSTANCE_ID = int(__import__('os').environ.get("ANGELA_INSTANCE_ID", "0"))
|
||||
|
||||
CONFIG = {
|
||||
"person": "Angela",
|
||||
"agent_id": "angela-daily-briefing",
|
||||
"instance_id": INSTANCE_ID,
|
||||
"wiki_parent_doc_id": "65966bd6-4ef8-4b79-9b79-e4aa62b94e96",
|
||||
"location": {
|
||||
"name": "Providence",
|
||||
|
||||
@@ -121,15 +121,19 @@ def run(config):
|
||||
location (dict): {name, state, country, lat, lon}
|
||||
"""
|
||||
agent_id = config["agent_id"]
|
||||
instance_id = config.get("instance_id", 0)
|
||||
|
||||
# Fetch live config from dashboard API, merge over defaults
|
||||
try:
|
||||
live_config = api_request(f"{DASHBOARD_API}/api/agents/{agent_id}/config")
|
||||
if live_config.get("location"):
|
||||
config["location"] = live_config["location"]
|
||||
print(f"Using live config location: {config['location'].get('name', '?')}")
|
||||
except Exception as e:
|
||||
print(f"Could not fetch live config, using defaults: {e}")
|
||||
if instance_id:
|
||||
try:
|
||||
live_config = api_request(f"{DASHBOARD_API}/api/instances/{instance_id}/config")
|
||||
if live_config.get("location"):
|
||||
config["location"] = live_config["location"]
|
||||
print(f"Using live config location: {config['location'].get('name', '?')}")
|
||||
if live_config.get("calendars"):
|
||||
config["calendars"] = live_config["calendars"]
|
||||
except Exception as e:
|
||||
print(f"Could not fetch live config, using defaults: {e}")
|
||||
|
||||
try:
|
||||
print(f"Collecting sub-agent data for {config['person']}...")
|
||||
@@ -145,7 +149,7 @@ def run(config):
|
||||
|
||||
summaries = "; ".join(f"{name}: {s}" for name, _, s in sections)
|
||||
output = f"Briefing {action}. {summaries}"
|
||||
log_run(agent_id, "success", output=output, metadata={
|
||||
log_run(agent_id, "success", output=output, instance_id=instance_id, metadata={
|
||||
"wiki_doc_id": doc_id,
|
||||
"action": action,
|
||||
"sub_agents": [name for name, _, _ in sections],
|
||||
@@ -155,5 +159,5 @@ def run(config):
|
||||
except Exception as e:
|
||||
err_msg = f"{type(e).__name__}: {e}"
|
||||
print(f"Error: {err_msg}", file=sys.stderr)
|
||||
log_run(agent_id, "failed", err=err_msg)
|
||||
log_run(agent_id, "failed", err=err_msg, instance_id=instance_id)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
from daily_briefing import run
|
||||
|
||||
# Instance ID will be set after migration (updated by deploy script)
|
||||
INSTANCE_ID = int(__import__('os').environ.get("ERIC_INSTANCE_ID", "0"))
|
||||
|
||||
CONFIG = {
|
||||
"person": "Eric",
|
||||
"agent_id": "eric-daily-briefing",
|
||||
"instance_id": INSTANCE_ID,
|
||||
"wiki_parent_doc_id": "2a891fe8-579b-450b-a663-de93915896b7",
|
||||
"location": {
|
||||
"name": "Providence",
|
||||
|
||||
+10
-12
@@ -33,19 +33,17 @@ def api_request(url, data=None, headers=None, method="GET"):
|
||||
return json.loads(resp.read().decode())
|
||||
|
||||
|
||||
def log_run(agent_id, status, output="", err="", metadata=None):
|
||||
"""Log a run to the dashboard API."""
|
||||
def log_run(agent_id, status, output="", err="", metadata=None, instance_id=None):
|
||||
"""Log a run to the dashboard API. Uses instance_id if available (v2), falls back to agent_id."""
|
||||
try:
|
||||
api_request(
|
||||
f"{DASHBOARD_API}/api/agents/{agent_id}/runs",
|
||||
data={
|
||||
"status": status,
|
||||
"output": output,
|
||||
"error": err,
|
||||
"metadata": metadata or {},
|
||||
},
|
||||
method="POST",
|
||||
)
|
||||
if instance_id:
|
||||
api_request(
|
||||
f"{DASHBOARD_API}/api/instances/{instance_id}/runs",
|
||||
data={"status": status, "output": output, "error": err, "metadata": metadata or {}},
|
||||
method="POST",
|
||||
)
|
||||
else:
|
||||
print(f"Warning: no instance_id, run not logged for {agent_id}", file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f"Warning: failed to log run to dashboard: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user