feat(agiliton-account): Phase 1 service scaffold

TypeScript + Fastify service implementing:
- Google + Microsoft SSO (POST /v1/auth/sso/{google,microsoft})
- JWT issuance + LiteLLM virtual key provisioning on first login
- AES-256-GCM encrypted virtual key storage in Postgres
- Conversation CRUD (GET/POST/DELETE /v1/conversations, /messages)
- GDPR export + soft-delete (/v1/me/export, /v1/me/delete)
- WebSocket MCP bridge (/v1/mcp-bridge) with JWT auth
- MCP demux endpoint (/mcp/demux/:customer_id/mcp) for LiteLLM tool routing
- DB migration script creating sb_customers, sb_conversations, sb_messages
- 9 unit tests (bridge + crypto), all passing
- Dockerfile + docker-compose targeting port 4100

CF-3032

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-04-10 16:06:16 +03:00
commit 7ab23554c0
26 changed files with 4855 additions and 0 deletions

24
src/db/pool.ts Normal file
View File

@@ -0,0 +1,24 @@
import { Pool } from "pg";
import { config } from "../config.js";
export const pool = new Pool({ connectionString: config.dbUrl });
pool.on("error", (err) => {
console.error("[db] unexpected pool error", err);
});
export async function query<T extends object = Record<string, unknown>>(
sql: string,
params?: unknown[]
): Promise<T[]> {
const { rows } = await pool.query<T>(sql, params);
return rows;
}
export async function queryOne<T extends object = Record<string, unknown>>(
sql: string,
params?: unknown[]
): Promise<T | null> {
const rows = await query<T>(sql, params);
return rows[0] ?? null;
}