managarten/services/mana-ai/src/db
Till JS 2a18cb5ee4 feat(mana-ai): v0.7 — cross-tick Deep Research Max pre-planning
Opt-in path for missions that want Gemini Deep Research Max (up to 60 min
per task) instead of the shallow RSS pre-research. Because Max runs well
past a single 60-second tick, the state is carried across ticks:

  tick N:   submit → INSERT mission_research_jobs row → skip planner
  tick N+k: poll → still running → skip planner (metric pending_skips)
  tick N+m: poll → completed → inject as ResolvedInput, DELETE row, plan

- ManaResearchClient talks to mana-research's new internal
  /v1/internal/research/async endpoints with X-Service-Key +
  X-User-Id. Graceful-null on transport errors so a flaky
  mana-research never crashes the tick loop.
- New table mana_ai.mission_research_jobs with PK (user_id, mission_id)
  — presence is the "pending" flag; delete-on-terminal keeps queries
  trivial.
- handleDeepResearch() encapsulates the state machine; planOneMission
  now returns a discriminated union (planned | skipped | failed) so
  "research pending" isn't miscounted as a parse failure.
- Opt-in at TWO gates to keep cost in check ($3–7/task, 1500 credits
  per run):
    1. MANA_AI_DEEP_RESEARCH_ENABLED=true server-side (default off)
    2. DEEP_RESEARCH_TRIGGER regex matches the mission objective
       (strict: "deep research", "tiefe recherche", "umfassende
       recherche", "hintergrundrecherche", "deep dive")
  Falls back to shallow RSS when either gate fails or the submit
  errors upstream.
- Prom metrics: mana_ai_research_jobs_{submitted,completed,failed}_total
  labelled by provider, plus _pending_skips_total.
- docker-compose wires MANA_RESEARCH_URL + the opt-in flag and adds
  mana-research to depends_on.
- Full write-up with real API response shape (outputs plural, not
  OpenAI-style), step-3 MCP-server plan (security-gated, not built),
  ops + kill-switch: docs/reports/gemini-deep-research.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 17:56:06 +02:00
..
resolvers docs: update architecture comparison — 5/10 roadmap items done 2026-04-16 15:00:09 +02:00
agents-projection.test.ts feat(mana-ai): agent-aware tick loop + snapshot projection (Phase 3) 2026-04-15 20:46:57 +02:00
agents-projection.ts feat(ai): policy is read from the owning agent (Phase 4) 2026-04-15 21:43:04 +02:00
audit-read.ts feat(ai): Mission Grant consent UI + Workbench audit tab 2026-04-15 13:53:11 +02:00
audit.ts feat(mana-ai): encrypted resolver + tick uses Mission Grant to decrypt scoped inputs 2026-04-15 13:42:31 +02:00
connection.ts feat(ai): close the loop — server write-back + webapp staging effect 2026-04-15 00:29:30 +02:00
iteration-writer.ts feat(mana-ai): agent-aware tick loop + snapshot projection (Phase 3) 2026-04-15 20:46:57 +02:00
migrate.ts feat(mana-ai): v0.7 — cross-tick Deep Research Max pre-planning 2026-04-22 17:56:06 +02:00
missions-projection.test.ts refactor(mana-ai): RLS-scope mission reads via per-user two-phase query 2026-04-15 01:06:17 +02:00
missions-projection.ts feat(mana-ai): agent-aware tick loop + snapshot projection (Phase 3) 2026-04-15 20:46:57 +02:00
research-jobs.ts feat(mana-ai): v0.7 — cross-tick Deep Research Max pre-planning 2026-04-22 17:56:06 +02:00
snapshot-refresh.test.ts perf(mana-ai): materialize mission snapshots, drop per-tick full replay 2026-04-15 01:28:24 +02:00
snapshot-refresh.ts perf(mana-ai): materialize mission snapshots, drop per-tick full replay 2026-04-15 01:28:24 +02:00