diff --git a/BACKEND_PLAN.md b/BACKEND_PLAN.md index ab6d3c9..8ed7dd8 100644 --- a/BACKEND_PLAN.md +++ b/BACKEND_PLAN.md @@ -500,6 +500,22 @@ adiuva-api/ | GET | `/api/v1/billing/subscription` | JWT | — | Subscription info | | DELETE | `/api/v1/billing/subscription` | JWT | — | `{ok: true}` | | GET | `/api/v1/health` | No | — | `{status, version}` | +| GET | `/api/v1/agents/catalog` | JWT | — | `AgentCatalogItem[]` | +| GET | `/api/v1/agents/local` | JWT | — | `LocalAgentConfigResponse[]` | +| POST | `/api/v1/agents/local` | JWT | `LocalAgentConfigCreate` | `LocalAgentConfigResponse` | +| PUT | `/api/v1/agents/local/{id}` | JWT | `LocalAgentConfigUpdate` | `LocalAgentConfigResponse` | +| DELETE | `/api/v1/agents/local/{id}` | JWT | — | `{ok: true}` | +| GET | `/api/v1/agents/cloud` | JWT | — | `CloudAgentConfigResponse[]` | +| POST | `/api/v1/agents/cloud` | JWT | `CloudAgentConfigCreate` | `CloudAgentConfigResponse` | +| PUT | `/api/v1/agents/cloud/{id}` | JWT | `CloudAgentConfigUpdate` | `CloudAgentConfigResponse` | +| DELETE | `/api/v1/agents/cloud/{id}` | JWT | — | `{ok: true}` | +| GET | `/api/v1/agents/runs` | JWT | `?agent_id&page&limit` | `AgentRunLogResponse[]` | +| POST | `/api/v1/agents/{id}/run` | JWT | — | `{ok: true, run_id}` | +| POST | `/api/v1/agents/journey/start` | JWT | `{agent_type, data_types}` | `{session_id, message, done}` | +| POST | `/api/v1/agents/journey/message` | JWT | `{session_id, message}` | `{session_id, message, done, prompt_template?}` | +| GET | `/api/v1/oauth/{provider}/authorize` | JWT | — | `{authorization_url}` | +| GET | `/api/v1/oauth/{provider}/callback` | — | OAuth code | `{encrypted_token}` | +| WS | `/api/v1/ws/device` | JWT | `device_hello` (first frame) | Agent trigger + tool_call frames | --- @@ -515,11 +531,34 @@ adiuva-api/ | Vector store | Pinecone or Qdrant (configurable) | | Database | PostgreSQL + SQLAlchemy + Alembic | | Rate limiting | slowapi | +| Cloud integrations | google-api-python-client, msgraph-sdk, msal | +| Agent scheduling | APScheduler | | Testing | pytest + pytest-asyncio + httpx + moto (S3 mock) | | Deployment | Docker → fly.io / Railway / AWS ECS | --- +## Phase 3 — New Files + +| File | Purpose | +|---|---| +| `app/models.py` | Add `LocalAgentConfig`, `CloudAgentConfig`, `AgentRunLog` models | +| `app/schemas.py` | Add agent config schemas + WS agent frame types | +| `app/api/routes/agents.py` | Agent CRUD endpoints (catalog, local, cloud, runs, manual trigger) | +| `app/api/routes/agent_setup.py` | Chatbot Journey endpoints (start + message) | +| `app/api/routes/device_ws.py` | Persistent device WS endpoint (`/api/v1/ws/device`) | +| `app/api/routes/oauth.py` | OAuth authorize/callback for Gmail, Teams, Outlook | +| `app/core/agent_runner.py` | Agent run orchestration — local (WS file request) + cloud (API fetch) | +| `app/core/device_manager.py` | `DeviceConnectionManager` — tracks active Electron WS connections | +| `app/core/agent_scheduler.py` | Periodic scheduler for agent cron triggers | +| `app/integrations/gmail.py` | Gmail API client (fetch messages with filters) | +| `app/integrations/ms_graph.py` | MS Graph client for Outlook emails + Teams messages | +| `app/integrations/__init__.py` | Provider factory | + +> **Full Phase 3 step-by-step plan:** See `AI_REFACTOR_PLAN.md` Phase 3 section. + +--- + ## Development Rules 1. **NEVER persist user data in plaintext.** The DB stores only auth, billing, storage metadata, and marketplace data. User context arrives in requests and is discarded. Cloud blobs are E2E encrypted client-side — backend only stores opaque bytes.