v2 phase 1: foundation — types, DB layer, logging

Add the v2 data layer: typed interfaces, central DB with migration
runner, per-entity CRUD, and agent-runner session DB operations.

- src/log.ts: concise message-first logging API
- src/types-v2.ts: AgentGroup, MessagingGroup, Session, MessageIn/Out
- src/db/: connection (WAL), migration runner, 001-initial schema,
  CRUD for agent_groups, messaging_groups, sessions, pending_questions
- container/agent-runner/src/db/: session DB connection, messages_in
  reads + status transitions, messages_out writes
- 31 new tests, all 277 tests pass

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-04-08 23:34:09 +03:00
parent 90acff28ad
commit 3f0451b7b0
15 changed files with 1267 additions and 0 deletions

37
src/db/index.ts Normal file
View File

@@ -0,0 +1,37 @@
export { initDb, initTestDb, getDb, closeDb } from './connection.js';
export { runMigrations } from './migrations/index.js';
export {
createAgentGroup,
getAgentGroup,
getAgentGroupByFolder,
getAllAgentGroups,
getAdminAgentGroup,
updateAgentGroup,
deleteAgentGroup,
} from './agent-groups.js';
export {
createMessagingGroup,
getMessagingGroup,
getMessagingGroupByPlatform,
getAllMessagingGroups,
updateMessagingGroup,
deleteMessagingGroup,
createMessagingGroupAgent,
getMessagingGroupAgents,
getMessagingGroupAgent,
updateMessagingGroupAgent,
deleteMessagingGroupAgent,
} from './messaging-groups.js';
export {
createSession,
getSession,
findSession,
getSessionsByAgentGroup,
getActiveSessions,
getRunningSessions,
updateSession,
deleteSession,
createPendingQuestion,
getPendingQuestion,
deletePendingQuestion,
} from './sessions.js';