feat(portal-bff): ai-bridge controller — SSE chat + JSON rag/models
CI / scan (pull_request) Successful in 2m59s
CI / commits (pull_request) Successful in 3m6s
CI / check (pull_request) Successful in 3m32s
CI / a11y (pull_request) Successful in 1m50s
Docs site / build (pull_request) Successful in 2m34s
CI / perf (pull_request) Successful in 4m4s
CI / scan (pull_request) Successful in 2m59s
CI / commits (pull_request) Successful in 3m6s
CI / check (pull_request) Successful in 3m32s
CI / a11y (pull_request) Successful in 1m50s
Docs site / build (pull_request) Successful in 2m34s
CI / perf (pull_request) Successful in 4m4s
Wires the AI relay into the BFF per ADR-0024 (now accepted): - AiBridgeController exposes POST /api/ai/chat (text/event-stream), GET /api/ai/rag/search, GET /api/ai/models under /api/ai/*. Session-gated (req.session.user) without an admin role — AI is an end-user surface. CSRF and double-submit token handled by the global middleware mounted in main.ts. - sse.writer translates ChatEvent oneof cases to kebab-case SSE event names (token / citation / agent-step / tool-call / error / done), JSON-encodes the inner payload, and produces a relay-side error frame on upstream failures (mapped from gRPC Status codes into the urn:apf-ai:* namespace the AI service already uses). - DTOs (class-validator) cap message count + length, restrict the role enum to user/assistant/system (tool messages are constructed caller-side by the BFF when tool dispatch lands), and bound RAG top_k between 1 and 50. - Browser disconnect (req 'close' event) → AbortController → call.cancel(), upstream LLM stops without leaking the stream. - AiClientModule now implements OnApplicationShutdown to close the four gRPC stubs on SIGTERM/SIGINT; main.ts calls app.enableShutdownHooks() to make it fire. - ADR-0024 promoted from proposed to accepted; README index + the CLAUDE.md roll-up updated. apps/portal-bff/.env.example documents AI_SERVICE_GRPC_ENDPOINT / CLIENT_ID / TLS for local boot.
This commit is contained in:
@@ -206,3 +206,16 @@ CORS_ALLOWED_ORIGINS=http://localhost:4200,http://localhost:4300
|
||||
# BFF_JWKS_KID — wired
|
||||
# <SERVICE>_API_BASE_URL (per integrated downstream — lands with the first integration)
|
||||
# <SERVICE>_TIMEOUT_MS (optional, defaults to 5000 — lands with the first integration)
|
||||
|
||||
# AI service relay (ADR-0024) — the BFF dials apf-ai-service over
|
||||
# native gRPC HTTP/2 and bridges chat streams to SSE for the SPA.
|
||||
# apf-ai-service runs from its own repo (../apf-ai-service); use
|
||||
# that repo's docker-compose.yml to bring it up locally, then point
|
||||
# AI_SERVICE_GRPC_ENDPOINT here at the host-published port. No
|
||||
# JWT/auth on the wire in v1 — the Principal travels in the proto
|
||||
# body (per ADR-0024 §"Sub-decision 4 — POC unsigned principal").
|
||||
AI_SERVICE_GRPC_ENDPOINT=localhost:8080
|
||||
AI_SERVICE_CLIENT_ID=apf-portal-dev
|
||||
# Set to 'true' in preprod/prod (h2 + TLS via the edge proxy);
|
||||
# 'false' in dev for h2c against the local apf-ai-service.
|
||||
AI_SERVICE_GRPC_TLS=false
|
||||
|
||||
Reference in New Issue
Block a user