Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(api,agents): point api->agents proxy at port 8084 and reorder /playbooks/runs

Beenu Arora1d7b3258e222
diff --git a/docker-compose.demo.yml b/docker-compose.demo.yml
index 89df9bc73..8b7ad1fce 100644
--- a/docker-compose.demo.yml
+++ b/docker-compose.demo.yml
@@ -149,6 +149,11 @@ services:
ENVIRONMENT: development
LOG_LEVEL: info
CORS_ORIGINS: http://localhost:3000
+ # The agents service listens on port 8084 inside the Docker network
+ # (see its Dockerfile + the agents service block below). Without this
+ # the api defaults to `http://agents:8000` and every playbook / case
+ # investigation request 503s with "All connection attempts failed".
+ AGENTS_SERVICE_URL: http://agents:8084
networks:
- aisoc-demo
restart: unless-stopped
diff --git a/services/agents/app/api/playbooks.py b/services/agents/app/api/playbooks.py
index 7b9a59ded..89b368351 100644
--- a/services/agents/app/api/playbooks.py
+++ b/services/agents/app/api/playbooks.py
@@ -61,6 +61,35 @@ async def create_playbook(playbook: Playbook) -> dict:
return created.model_dump()
+# ---------------------------------------------------------------------------
+# Run queries (declared BEFORE /{playbook_id} so FastAPI matches the literal
+# "/runs" prefix instead of treating "runs" as a playbook_id path param).
+# ---------------------------------------------------------------------------
+
+
[email protected]("/runs", summary="List recent playbook runs")
+async def list_runs(limit: int = 50) -> list[dict]:
+ recent = sorted(
+ _runs.values(),
+ key=lambda r: r.started_at or "",
+ reverse=True,
+ )[:limit]
+ return [r.to_dict() for r in recent]
+
+
[email protected]("/runs/{run_id}", summary="Get a playbook run result")
+async def get_run(run_id: str) -> dict:
+ pr = _runs.get(run_id)
+ if not pr:
+ raise HTTPException(status_code=404, detail="Playbook run not found")
+ return pr.to_dict()
+
+
+# ---------------------------------------------------------------------------
+# CRUD by id
+# ---------------------------------------------------------------------------
+
+
@router.get("/{playbook_id}", summary="Get a playbook")
async def get_playbook(playbook_id: str) -> dict:
store = PlaybookStore.default()
@@ -135,21 +164,3 @@ async def _execute_and_update(playbook: Playbook, context: dict[str, Any], dry_r
# Preserve the pre-allocated run_id
pr.run_id = run_id
_runs[run_id] = pr
-
-
[email protected]("/runs/{run_id}", summary="Get a playbook run result")
-async def get_run(run_id: str) -> dict:
- pr = _runs.get(run_id)
- if not pr:
- raise HTTPException(status_code=404, detail="Playbook run not found")
- return pr.to_dict()
-
-
[email protected]("/runs", summary="List recent playbook runs")
-async def list_runs(limit: int = 50) -> list[dict]:
- recent = sorted(
- _runs.values(),
- key=lambda r: r.started_at or "",
- reverse=True,
- )[:limit]
- return [r.to_dict() for r in recent]
diff --git a/services/api/app/api/v1/endpoints/cases.py b/services/api/app/api/v1/endpoints/cases.py
index 6566fa77d..437655df4 100644
--- a/services/api/app/api/v1/endpoints/cases.py
+++ b/services/api/app/api/v1/endpoints/cases.py
@@ -14,7 +14,7 @@ from app.api.v1.deps import AuthUser, DBSession, require_permission
from app.db.rls import TenantDBSession
from app.models.case import Case, CaseTimeline
-_AGENTS_URL = os.getenv("AGENTS_SERVICE_URL", "http://agents:8000")
+_AGENTS_URL = os.getenv("AGENTS_SERVICE_URL", "http://agents:8084")
router = APIRouter(prefix="/cases", tags=["cases"])
diff --git a/services/api/app/api/v1/endpoints/playbooks.py b/services/api/app/api/v1/endpoints/playbooks.py
index d7869111e..afd8c776a 100644
--- a/services/api/app/api/v1/endpoints/playbooks.py
+++ b/services/api/app/api/v1/endpoints/playbooks.py
@@ -14,7 +14,7 @@ from typing import Any
import httpx
from fastapi import APIRouter, HTTPException, Request
-_AGENTS_URL = os.getenv("AGENTS_SERVICE_URL", "http://agents:8000")
+_AGENTS_URL = os.getenv("AGENTS_SERVICE_URL", "http://agents:8084")
router = APIRouter(prefix="/playbooks", tags=["playbooks"])
diff --git a/services/api/app/graphql/query.py b/services/api/app/graphql/query.py
index 361e7ed95..63b0ddf50 100644
--- a/services/api/app/graphql/query.py
+++ b/services/api/app/graphql/query.py
@@ -41,7 +41,7 @@ from app.models.case import Case
from app.models.connector import Connector
from app.models.detection_rule import DetectionRule
-_AGENTS_URL = os.getenv("AGENTS_SERVICE_URL", "http://agents:8000")
+_AGENTS_URL = os.getenv("AGENTS_SERVICE_URL", "http://agents:8084")
# ─── helpers ──────────────────────────────────────────────────────────────────