• Admin's avatar
    feat: add agent log viewer, SSE streaming, and L1 sandbox · 71aa8270
    Admin authored
    - services/agent_log_writer.py: Writes ExecutionRunLog rows via AIAgent
      callbacks (tool_start, tool_complete, step, status). Errors swallowed
      to never block agent execution.
    
    - services/workspace_manager.py: Creates isolated workspace directories
      per agent run (workspaces/{company_id}/{run_id}/) with src/,
      .agent_output/, README.md structure.
    
    - services/path_security.py: Path validation to prevent directory
      traversal, blocks dangerous paths (C:\Windows, /etc, .env, .git).
    
    - api/routes/run_logs.py: Added company-scoped runs_router with:
      GET /companies/{id}/runs/{runId} — run detail with all logs
      GET /companies/{id}/runs/{runId}/stream — SSE real-time log stream
    
    - api/routes/agents.py: run_agent_in_background now creates workspace,
      instantiates AgentLogWriter, passes callbacks to AIAgent, and cleans
      up workspace in finally block.
    
    - tests/test_agent_flow.py: Updated to mock WorkspaceManager and
      AgentLogWriter, relaxed AIAgent assertion to check core kwargs only.
    
    All 3 tests pass. Dashboard verified 0 JS errors via Playwright.
    71aa8270
main_router.py 7.03 KB