Commit graph

1124 commits

Author SHA1 Message Date
Till-JS
d4663b5643 feat(mana-media): add centralized media storage with NutriPhi integration
- Implement mana-media service with PostgreSQL/Drizzle ORM persistence
- Add content-addressable storage (SHA-256) for automatic deduplication
- Add Matrix MXC URL import endpoint to copy images from Matrix
- Create @manacore/media-client package for service consumption
- Integrate mana-media into NutriPhi bot for persistent image storage
- Update pnpm-workspace.yaml to include nested service packages
- Add mana-media to docker-compose with port 3015

Images sent to NutriPhi bot are now stored in mana-media after analysis,
providing persistent storage with deduplication across all apps.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:30:14 +01:00
Till-JS
171cf7a854 fix(contacts-web): use runtime URLs instead of build-time baked values
- user-settings.svelte.ts: use getAuthUrl() for settings API
- contacts.ts: use getAuthUrl() for tags API client
- feedback.ts: use getAuthUrl() for feedback service

This fixes Mixed Content errors where the app was trying to reach
internal Docker URLs (http://mana-auth:3001) instead of production
URLs (https://auth.mana.how).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:22:59 +01:00
Till-JS
30f0dbef5d feat(contacts-web): add hooks.server.ts for runtime URL injection
Fixes contacts-web using localhost URLs instead of production URLs.
SvelteKit bakes environment variables at build time, so we need to
inject runtime URLs via hooks.server.ts for Docker deployments.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:14:03 +01:00
Till-JS
1fe498e758 fix(shared-ui): export calculateFadeOpacity from index
This utility function was used by contacts-web skeletons but wasn't
exported from the main shared-ui package entry point.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:07:49 +01:00
Till-JS
49c5873af1 chore(docker): build contacts-web locally instead of using GHCR image
GHCR image was outdated (2026-01-29), missing:
- Demo mode removal (2026-01-30)
- SSO implementation (2026-02-02)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:06:12 +01:00
Till-JS
5b3c87b245 fix(docker): use monorepo root as build context for mana-auth
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:52:09 +01:00
Till-JS
ce5f3b5384 chore(docker): build mana-auth locally instead of using GHCR image
Allows faster iteration on auth fixes without needing to push to GHCR.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:51:25 +01:00
Till-JS
85df234ff2 feat(mana-core-auth): auto-link Matrix users on OIDC login
When users log into Matrix via OIDC (Sign in with Mana Core), their
Matrix user ID is now automatically linked to their Mana account.
This enables automatic bot authentication without requiring a
separate !login command.

- Add autoLinkOnOidcLogin() method to MatrixSessionService
- Hook into OIDC userinfo endpoint to create links automatically
- Calculate Matrix user ID from email using Synapse's template

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:50:28 +01:00
Till-JS
75937d6ce9 fix(mana-core-auth): align JWT issuer validation with Better Auth signing config
Better Auth signs JWTs with issuer=BASE_URL (https://auth.mana.how) for OIDC
compatibility, but validation was using jwt.issuer config which defaults to
'manacore'. This caused "unexpected iss claim value" errors.

Fixed in:
- better-auth.service.ts validateToken()
- jwt-auth.guard.ts
- optional-auth.guard.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:50:04 +01:00
Till-JS
0538a6ca10 fix(mana-core-auth): use Better Auth signJWT in refresh endpoint
The refresh endpoint was using manual jwt.sign with RSA keys, but the
server doesn't have JWT_PRIVATE_KEY configured. Changed to use Better
Auth's signJWT method which uses the JWKS/EdDSA keys from the database.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:40:37 +01:00
Till-JS
c196144d1c fix(mana-core-auth): return real refreshToken from signIn endpoint
Same issue as sessionToToken - the signIn method was returning the
session cookie token as refreshToken, but the /api/v1/auth/refresh
endpoint expects the actual refreshToken field from the sessions table.

Now signIn:
- Fetches the session from database after Better Auth creates it
- Uses existing refreshToken if available
- Generates and stores a new refreshToken if missing
- Returns the actual refreshToken that works with token refresh

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:37:54 +01:00
Till-JS
d64016d1e5 fix(mana-core-auth): exclude /api/auth/get-session from global prefix
The get-session endpoint needs to be accessible at /api/auth/get-session
(without the /api/v1 prefix) for SSO to work.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:29:17 +01:00
Till-JS
95e9b3764d feat(mana-core-auth): add /api/auth/get-session endpoint for SSO
The SSO flow in client apps calls /api/auth/get-session with cookies
to check if the user has a valid session. This endpoint was missing
from the NestJS passthrough controller.

Now the endpoint forwards the request with cookies to Better Auth's
native handler and returns the session data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:27:39 +01:00
Till-JS
9c45879363 feat(nutriphi-bot): auto-analyze images when received
Images are now automatically analyzed when sent to the bot, removing
the need for the !analyze command after sending a photo.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:27:03 +01:00
Till-JS
f556665ac2 fix(shared-nestjs-setup): export compiled JS instead of TypeScript
The package was incorrectly exporting src/index.ts which causes runtime
errors when used with plain Node.js. Changed to export from dist/.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:19:39 +01:00
Till-JS
ad22d264aa fix(nutriphi): add shared-drizzle-config and make db:push non-fatal
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:17:22 +01:00
Till-JS
b6925e0b63 feat(matrix-bots): enable cross-bot SSO via Redis sessions
All 19 Matrix bots now use SessionModule.forRoot({ storageMode: 'redis' })
to share user sessions across all bots via Redis. Users only need to
login once with any bot to be authenticated with all bots.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:16:22 +01:00
Till-JS
0cafd4f94f chore: update pnpm-lock.yaml for express dependency
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:14:51 +01:00
Till-JS
ac477aae24 fix(nutriphi): add missing shared packages to Dockerfile
Added shared-tsconfig, shared-nestjs-setup, and shared-nestjs-health
packages required for the backend build.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:14:04 +01:00
Till-JS
509bbb9920 fix(nutriphi): add shared-nestjs-setup to Dockerfile
The package is required for the bodyLimit configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:09:44 +01:00
Till-JS
b404ddc9a8 fix(nutriphi): increase body size limit to 50mb for image uploads
The NutriPhi bot was failing with 413 "request entity too large" when
analyzing images via Base64. Added configurable bodyLimit option to
shared-nestjs-setup and set NutriPhi backend to 50mb.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:08:14 +01:00
Till-JS
c2c80efc50 feat(matrix-bots): add i18n system and direct message fallback
- Add I18nService with per-user language preferences (de/en)
- Add !language/!sprache command to all 4 bots (todo, calendar, contacts, clock)
- Add fallback behavior: messages without commands create tasks/events/contacts/timers
- Improve clock bot duration parsing to accept bare numbers as minutes (e.g. "25" = 25min)
- Add support for more duration formats: "25 minuten", "1 stunde", etc.

Language preferences stored in SessionService, default configurable via BOT_DEFAULT_LANGUAGE env var.
2026-02-02 16:07:27 +01:00
Till-JS
5c688d713e fix(mana-core-auth): return real refreshToken in SSO session-to-token exchange
The sessionToToken method was incorrectly returning the session cookie
token instead of the actual refreshToken from the database. This caused
"No refresh token available" errors when users logged in via SSO
(cross-domain cookie) because the /api/v1/auth/refresh endpoint expects
the refreshToken field from the sessions table, not the cookie token.

Now the method:
- Fetches the session from database by cookie token
- Uses existing refreshToken if available
- Generates and stores a new refreshToken if missing
- Returns the actual refreshToken that works with token refresh

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 16:05:44 +01:00
Till-JS
9d7e6c670e fix(matrix-web): change bots page to single column layout
More readable and cleaner UX with narrower max-width

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 15:46:35 +01:00
Till-JS
23852cf605 feat(matrix-web): add bots page with all 19 Matrix bots
- Add /bots route with bot overview grid
- Create BotCard component with expandable details
- Implement search and category filtering (AI, Productivity, Media, Lifestyle, Tools)
- Add bot data structure with commands, descriptions, and metadata
- Support starting chat with bots (creates DM or navigates to existing room)
- Add German and English translations
- Add robot icon to PillNavigation component

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 15:36:49 +01:00
Till-JS
aba79f5c16 fix(mana-llm): fix SSE double data prefix causing message parsing issues
EventSourceResponse from sse-starlette adds its own 'data:' prefix,
so we should yield dicts with a 'data' key instead of pre-formatted
SSE strings. This was causing 'data: data:' double prefixes and
backticks appearing in chat messages.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 15:29:11 +01:00
Till-JS
60d2f6422c fix(matrix-bots): update all bots for async SessionService methods
Update all Matrix bots to properly await async SessionService methods
after the migration to Redis-backed session storage. This includes:

- Adding await to getSessionData, getSession, getToken, isLoggedIn calls
- Making requireAuth helper methods async and return Promise<string>
- Making session data helper methods async (getCurrentConversation, etc.)
- Fixing handleLogout and other methods that use session operations

Affected bots:
- matrix-chat-bot (extensive changes for session helpers)
- matrix-clock-bot (getToken helper + session calls)
- matrix-contacts-bot, matrix-manadeck-bot, matrix-nutriphi-bot
- matrix-ollama-bot, matrix-picture-bot, matrix-planta-bot
- matrix-presi-bot, matrix-project-doc-bot, matrix-skilltree-bot
- matrix-storage-bot, matrix-zitare-bot, matrix-tts-bot
- matrix-mana-bot (help handler)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 15:04:30 +01:00
Till-JS
0b46d203bb feat(infra): add mana-llm service to production deployment
- Add mana-llm FastAPI service for LLM API gateway
- Configure CORS for playground.mana.how
- Use shared Redis from existing infra
- Connect playground to mana-llm container

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:58:44 +01:00
Till-JS
a416dade7b fix(playground): add missing shared packages to Dockerfile
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:55:02 +01:00
Till-JS
8525020e8a feat(playground): integrate shared auth UI for consistent login experience
- Add PlaygroundLogo to shared-branding package
- Add playground to APP_BRANDING, APP_ICONS, and APP_URLS
- Replace custom login/register pages with shared-auth-ui components
- Update authStore with resendVerificationEmail and improved signUp
- Add Caddy reverse proxy entry for playground.mana.how

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:53:51 +01:00
Till-JS
2777f604fd feat(bots): enable Redis SSO for todo-bot and calendar-bot
- Activate Redis session storage in both bots for cross-bot SSO
- Update SessionHelper to async methods for Redis-backed SessionService
- Fix async/await issues in todo-bot and calendar-bot matrix.service.ts
- Remove unused imports from calendar-api and todo-api services
- Add CALENDAR_BACKEND_URL and MANA_CORE_SERVICE_KEY to .env.development

Note: SessionService methods are now async (Redis-backed). Other bots
need their matrix.service.ts updated to await these async calls.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 14:51:23 +01:00
Till-JS
7bad849258 docs(server): document Docker on external SSD and Matrix Bots
- Add Docker Desktop relocation to external SSD via symlink
- Document ~80GB freed on internal SSD
- Add Matrix Bots section with all 10 bots and ports
- Include health check, logs, and management commands

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 13:43:39 +01:00
Till-JS
feaf27dd14 feat(auth): implement cross-subdomain SSO for all web apps
Add Single Sign-On (SSO) support across all mana.how subdomains:

- Add trySSO() method to @manacore/shared-auth that exchanges session
  cookies for JWT tokens
- Add /api/v1/auth/session-to-token endpoint to mana-core-auth service
- Update all 15 web apps to try SSO during auth initialization

SSO Flow:
1. User logs in on any app (e.g., calendar.mana.how)
2. Session cookie is set with Domain=.mana.how
3. When visiting another app (e.g., todo.mana.how), it checks for
   local tokens first
4. If no local tokens, tries SSO via session cookie
5. Session cookie is exchanged for JWT tokens via new endpoint
6. User is automatically authenticated

Apps updated: calendar, chat, clock, contacts, manacore, manadeck,
nutriphi, picture, planta, presi, questions, skilltree, storage,
todo, zitare

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 13:17:04 +01:00
Till-JS
352070fb2f docs(auth): add SSO documentation and test credentials
- Document cross-domain SSO with COOKIE_DOMAIN configuration
- Add production test credentials for automated testing
- Explain cookie-based SSO flow across *.mana.how subdomains

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:09:07 +01:00
Till-JS
f03c09ff17 feat(auth): enable cross-domain SSO via shared cookies on .mana.how
- Configure Better Auth with crossSubDomainCookies for .mana.how domain
- Add COOKIE_DOMAIN environment variable (production: .mana.how)
- Sync trustedOrigins with all production subdomains
- Users now login once and are authenticated across all apps

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:58:29 +01:00
Till-JS
9a22c89857 fix(calendar-web): inject cross-app API URLs for client-side
The calendar frontend integrates with todo and contacts backends
for tasks and birthdays. The env vars were only available during
SSR, not in client-side JavaScript.

- Add PUBLIC_TODO_BACKEND_URL and PUBLIC_CONTACTS_API_URL injection
  in hooks.server.ts
- Update todos.ts to use injected window variable
- Update birthdays.ts to use injected window variable

Fixes 404 errors on calendar.mana.how for /tasks/* and /contacts/birthdays

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:26:46 +01:00
Till-JS
a7c1908f25 fix(project-doc-bot): add include/exclude to tsconfig for correct dist output
The tsconfig was missing include/exclude which caused the build to
output to dist/src/main.js instead of dist/main.js.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:01:12 +01:00
Till-JS
ea0198cc18 fix(bots): install wget for Docker health checks
node:20-slim doesn't include wget or curl, which is required
for the HEALTHCHECK commands in the Dockerfiles.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 17:19:08 +01:00
Till-JS
d9fe46ae3e 🧹 chore(bot-services): remove unused CreditConsumeResult import
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 15:08:58 +01:00
Till-JS
a8521d7acd 🐛 fix(matrix-bots): disable E2EE crypto module via pnpm override
Add root-level pnpm override to replace @matrix-org/matrix-sdk-crypto-nodejs
with empty-npm-package. This disables E2EE support but allows matrix bots
to run without native module compilation issues.

The bots don't need E2EE since Matrix Synapse handles encryption at
the server level for our use case.

Also removes the explicit pnpm add commands from Dockerfiles since the
override handles the module replacement.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 15:08:28 +01:00
Till-JS
3dba7d8695 🐛 fix(matrix-bots): explicitly install linux-x64-gnu crypto module
The pnpm lockfile doesn't contain the linux-x64-gnu variant of
@matrix-org/matrix-sdk-crypto-nodejs since it was created on macOS.
Explicitly adding this package during Docker build ensures the
correct native binary is available at runtime.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 15:04:42 +01:00
Till-JS
dc0d425f61 🐛 fix(matrix-web): handle Matrix SSO loginToken callback
Add loginWithLoginToken function to exchange Matrix SSO loginToken for credentials.
The app layout now detects the loginToken URL parameter and completes the SSO flow.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 15:02:47 +01:00
Till-JS
9e9db590dc 📝 docs: update SSD documentation for ManaData volume
- Rename SSD references from TillJakob-S04 to ManaData
- Add Docker integration section documenting SSD mounts
- Add benefits comparison table (Docker VM vs SSD)
- Document PostgreSQL and MinIO bind mount configuration
- Add Docker Desktop Full Disk Access requirement
- Update directory structure with postgres/ and minio/ folders
- Update backup script path references

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 15:01:42 +01:00
Till-JS
38101bca00 🐛 fix(matrix-bots): add pnpm rebuild for native crypto module
The @matrix-org/matrix-sdk-crypto-nodejs package needs a rebuild step
after install to properly select the platform-specific prebuilt binary.
Without this, the module fails to find the correct binding at runtime.

Adds `pnpm rebuild @matrix-org/matrix-sdk-crypto-nodejs || true` after
both the dev and prod install steps in all matrix bot Dockerfiles.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:58:05 +01:00
Till-JS
7d7e31e486 feat(infra): migrate PostgreSQL to SSD storage
Move PostgreSQL data from Docker volume to /Volumes/ManaData/postgres
for better data safety and performance.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:56:42 +01:00
Till-JS
6c937b6c80 🐛 fix(matrix-bots): restore --ignore-scripts to skip root postinstall
The root package.json has postinstall hooks (generate-env, build:packages,
husky) that fail in Docker context. --ignore-scripts prevents these from
running while still allowing the build to complete.

Using node:20-slim (glibc) should handle matrix-sdk crypto modules via
prebuilt binaries without needing install scripts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:47:04 +01:00
Till-JS
a384bed181 🐛 fix(matrix-bots): switch to node:20-slim for native module support
- Changed base images from Alpine to Debian slim (glibc vs musl)
- Removed --ignore-scripts to allow native module builds
- Fixed user creation commands for Debian-based images

The matrix-bot-sdk requires @matrix-org/matrix-sdk-crypto-nodejs which
needs platform-specific native binaries. Alpine's musl libc causes
compatibility issues with these modules.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:41:34 +01:00
Till-JS
02604e6d1c 🔧 fix(docker): add platform linux/amd64 for matrix bots on arm64 hosts
Mac Mini with Apple Silicon needs explicit platform specification
to pull amd64 images since matrix bots only have amd64 builds.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:32:24 +01:00
Till-JS
a50d98c7a1 🐛 fix(matrix-bots): disable arm64 builds for all matrix bots
All matrix bots use matrix-bot-sdk which has native dependencies
(cpu-features, ssh2) that cause QEMU emulation failures during CI
arm64 builds. Build amd64 only - can run on arm64 via Rosetta.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:25:05 +01:00
Till-JS
6ca2d3b76d feat(infra): use SSD for MinIO storage
Mount MinIO data directly to /Volumes/ManaData/minio for better
performance and persistence on external SSD.

Requires Docker Desktop "Full Disk Access" permission on Mac Mini.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:23:43 +01:00