mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
Background Hono/Bun service that scans mana_sync for due Missions and will plan them via mana-llm without requiring an open browser tab. Complements the foreground `startMissionTick` in the webapp. v0.1 scope — scaffold that's deployable, boots cleanly, and reads real data. Execution write-back is tracked as the next PR so we don't commit a half-baked proposal-sync design. Shipped: - Hono app on :3066 with `/health` + service-key-gated `/internal/tick` - `src/db/missions-projection.ts` — field-level LWW replay of `sync_changes` for appId='ai' / table='aiMissions' → live Mission records. Mirrors the webapp's `applyServerChanges` semantics against Postgres instead of Dexie. - `src/db/connection.ts` — bounded `postgres.js` pool (max 4, idle 30s) - `src/cron/tick.ts` — overlap-guarded scheduler, `runTickOnce()` also reachable via HTTP for CI/ops triggering - `src/planner/client.ts` — mana-llm HTTP client shape (OpenAI-compatible `/v1/chat/completions`) - `src/middleware/service-auth.ts` — X-Service-Key gate, no end-user JWTs reach this service - Dockerfile + graceful SIGTERM shutdown (stops timer + releases pool) Not yet implemented (documented in CLAUDE.md with design trade-offs): - Prompt/parser server-side copies — today they live in the webapp. Recommended next step: extract `@mana/shared-ai` package. - Input resolvers for notes / kontext / goals — need projections or a mana-sync internal endpoint - Plan → Mission-iteration write-back + how proposals get back to the user's device (leaning option (a): server writes iterations, the webapp's sync effect translates them into local Proposals) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.2 KiB
Docker
36 lines
1.2 KiB
Docker
# Install stage: use node + pnpm to resolve workspace dependencies
|
|
FROM node:22-alpine AS installer
|
|
|
|
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy workspace structure
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
COPY services/mana-ai/package.json ./services/mana-ai/
|
|
COPY packages/shared-hono ./packages/shared-hono
|
|
|
|
# Install only mana-ai and its workspace deps
|
|
RUN pnpm install --filter @mana/ai-service... --no-frozen-lockfile --ignore-scripts
|
|
|
|
# Runtime stage: bun
|
|
FROM oven/bun:1 AS production
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=installer /app/node_modules ./node_modules
|
|
COPY --from=installer /app/services/mana-ai/node_modules ./services/mana-ai/node_modules
|
|
COPY --from=installer /app/packages ./packages
|
|
|
|
COPY services/mana-ai/package.json ./services/mana-ai/
|
|
COPY services/mana-ai/src ./services/mana-ai/src
|
|
COPY services/mana-ai/tsconfig.json ./services/mana-ai/
|
|
|
|
WORKDIR /app/services/mana-ai
|
|
|
|
EXPOSE 3066
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
|
CMD bun -e "fetch('http://localhost:3066/health').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"
|
|
|
|
CMD ["bun", "run", "src/index.ts"]
|