Agent Zero
0c67eb0754
fix: WebSocket 403 — require_active_plugin skips WebSocket requests
...
Simpler approach: require_active_plugin._check() now accepts Request
parameter and returns early for WebSocket upgrade requests.
No route splitting needed — all routes stay in their original router.
2026-07-27 01:34:50 +02:00
Agent Zero
aae3dc2297
fix: add missing APIRouter import for WebSocket route registration
2026-07-27 01:26:26 +02:00
Agent Zero
00180f8f7d
fix: WebSocket 403 — register WebSocket routes without require_active_plugin dependency
...
WebSocket routes were getting require_active_plugin dependency applied
via include_router(dependencies=[...]) which caused 403 Forbidden
before the WebSocket upgrade could happen.
Fix: Split router into HTTP routes (with dependency) and WebSocket routes
(registered separately without the active-plugin check). WebSocket auth
is handled inside the endpoint itself via session cookie verification.
2026-07-27 01:23:07 +02:00
Agent Zero
7968630840
fix: UploadFile ForwardRef + WebSocket 403 — root cause fixed
...
1. plugin_error_handler.py: Remove _UploadFile alias, import UploadFile directly
so FastAPI can resolve ForwardRef('UploadFile') in the wrapper's namespace.
Also import WebSocket for ForwardRef resolution.
2. main.py: Skip WebSocket routes in wrap_plugin_route — WebSocket endpoints
must not be wrapped (different protocol, no JSONResponse on error)
2026-07-27 01:17:59 +02:00
Agent Zero
ece3cdf75a
feat: report ALL errors to Forgejo — backend 4xx/5xx, unhandled exceptions, worker job failures
...
- main.py: RequestLoggingMiddleware reports 4xx/5xx responses and unhandled exceptions to Forgejo
- worker.py: Plugin activation failures and outbox job failures reported to Forgejo
- 401/403 are NOT reported (expected auth/permission behavior)
- All other errors (422, 404, 500, network, worker) ARE reported
2026-07-27 00:36:37 +02:00
Agent Zero
604a2b7648
Phase 2: Fix high-priority security and stability issues (H1-H7)
...
H1: Sanitize error endpoint context (strip tokens/passwords, limit depth/size)
H2: Rate limiter IP spoofing fix (trusted proxy CIDR check for X-Forwarded-For)
H3: CSRF middleware uses Redis singleton instead of per-request connection
H4: WebSocket origin verification added to both kommunikation and ai_ui_control
H5: Storage path traversal protection, get_url() returns relative URL not filesystem path
H6: Security headers middleware (HSTS, X-Content-Type-Options, X-Frame-Options, CSP, Referrer-Policy)
H7: Forward-repair migration 0045 for databases that ran original 0021/0027
Also: add trusted_proxy_cidrs to config, add verify_ws_origin to auth
2026-07-26 20:49:15 +02:00
Agent Zero
5ec1fc9b05
Phase 1: Fix all critical release blockers (B1-B10)
...
B1: Remove duplicate get_redis() — singleton no longer overwritten
B2: Plugin routes now enforce activation status via require_active_plugin()
B3: Fix UploadFile ForwardRef error — remove functools.wraps from wrap_plugin_route
B4: DMS upload uses true streaming via save_stream() instead of RAM accumulation
B5: Worker on_startup registers plugin event handlers + webhook dispatcher
B6: Implement send_password_reset_email job, remove raw token logging
B7: Webhook SSRF protection (IP validation, no redirects), secret removed from response
B8: RLS repair migration 0044 + separate crm_runtime DB user (NOSUPERUSER, NOBYPASSRLS)
B9: Fix .env.docker.example AUTH_SECRET → SECRET_KEY
B10: Remove Redis default password, remove exposed DB/Redis ports
Also: add frontend_url to config, add SMTP settings to .env.docker.example,
update prestart.sh to use MIGRATION_DATABASE_URL for alembic.
2026-07-26 20:45:42 +02:00
Agent Zero
c3e41906bf
feat: add forgejo_error_reporter plugin for automatic error reporting to Forgejo issues
2026-07-26 12:49:39 +02:00
Agent Zero
808da564f3
fix: improve error handling and stability - no logout on transient errors, add ErrorBoundary, global error logging
2026-07-26 12:18:52 +02:00
Agent Zero
79ece0fe2e
Phase 4: Webhooks, Backup/Restore UI, Onboarding/Tutorial
...
- Webhooks Backend: model, schema, service (HMAC-SHA256, httpx), routes, event bus dispatcher, migration 0042
- Webhooks Frontend: SettingsWebhooksPage (CRUD, test button, event multi-select), API client
- Backup/Restore Backend: model, schema, service (pg_dump/pg_restore), routes (admin-only), migration 0043
- Backup/Restore Frontend: SettingsBackupPage (create, list, restore dialog with RESTORE confirmation, auto-refresh)
- Onboarding: OnboardingTour (8 steps, custom CSS overlay), WelcomeDialog, onboardingStore (zustand + localStorage)
- Onboarding integrated into AppShell
- Routes: /settings/webhooks, /settings/backup registered
- Settings nav: Webhooks, Backup & Restore entries added
- Migration conflict fixed: 0042_webhooks → 0043_backups chain
2026-07-26 03:17:40 +02:00
Agent Zero
a7e3890634
Phase 2: Tags UI, Custom Fields UI, Notifications Bell
...
- Tags UI: TagsPage (CRUD, color picker), TagBadge, TagSelector (multi-select, inline creation)
- Custom Fields Backend: model, schema, service, routes, migration 0041
- Custom Fields Frontend: CustomFieldsPage (definitions CRUD), CustomFieldRenderer (dynamic field rendering)
- Custom Fields: _collect_custom_field_definitions() extended to merge DB definitions with plugin definitions
- Notifications Bell: NotificationBell (30s polling, unread badge), NotificationDropdown, NotificationItem
- NotificationBell integrated into TopBar
- Routes: /tags, /settings/custom-fields registered
- Settings nav: Custom Fields entry added
- Menu items: Tags added to automation plugin manifest
2026-07-26 03:02:25 +02:00
Agent Zero
30b94fc738
Fix: use direct plugin module imports instead of BUILTIN_PLUGINS
2026-07-26 00:52:27 +02:00
Agent Zero
054ecb1c91
Fix: register plugin routes in create_app() not lifespan(); add status column to contacts migration 0039; add updated_at to user_tenants migration 0037
2026-07-26 00:42:31 +02:00
Agent Zero
727d86614e
Security fixes: P0-P2 complete (22 fixes)
...
P0 (7): Auth-bypass removed, migrations fixed, plugin-upload disabled, RLS FORCE+WITH CHECK, plugin double-registration fixed, persistent volume, domain removed
P1 (11): User/tenant model, Redis centralized, worker separated, transactional outbox, XSS fixed, DMS chunked streaming, permissions unified, password reset, metrics secured, config/docs fixed, cross-tenant FK
P2 (4): Contact model normalized, cross-imports reduced 94%, commands+state machines for contacts/dms/mail/calendar, SPA path-traversal
8 new migrations, 99 unit tests, 13 commands, 8 contracts, 72 files changed
2026-07-25 21:03:46 +02:00
Agent Zero
6a622665a2
fix: Register bank_accounts router in main.py
...
- Add bank_accounts import to main.py
- Add app.include_router(bank_accounts.router)
- Add bank_accounts to permissions metadata
2026-07-25 02:16:20 +02:00
Agent Zero
7b4a2c0791
fix: embedding migration, worker error handling, path traversal security, response mismatches (unread-count, plugins, manifests), frontend type safety
2026-07-24 14:23:28 +02:00
Agent Zero
036e87a9ed
Task 5.25: Dashboard-System — GET /api/v1/dashboard/widgets, DashboardWidgetLoader, DashboardGrid with drag-and-drop, 3 example widgets (RecentContacts, TasksSummary, CalendarUpcoming), updated Dashboard.tsx, i18n, 6 tests
2026-07-24 00:09:26 +02:00
Agent Zero
182af355d1
feat(5.22): Saved Searches / Smart Lists — reusable filters for list views
...
- SavedFilter model with TenantMixin (name, entity_type, filter_criteria JSONB, user_id)
- Routes: GET/POST /saved-filters, DELETE /saved-filters/{id} with RBAC
- Alembic migration 0029_saved_filters creates saved_filters table
- Frontend: SavedFilters.tsx component with save/load/delete UI
- Frontend: api/savedFilters.ts with React Query hooks
- Integrated into ContactsListPage as example
- i18n keys for savedFilters.* in de.json and en.json
- Tests: test_saved_filters.py (9 tests) + SavedFilters.test.tsx (3 tests)
- Registered SavedFilter in conftest.py
2026-07-23 23:44:50 +02:00
Agent Zero
bdad91a649
feat(5.20): Custom Fields — plugin-defined fields in Contact UI
...
- Add CustomFieldDefinition to PluginManifest (text/number/date/select/multiselect/boolean)
- Add GET/PATCH /api/v1/contacts/{id}/custom-fields routes
- Merge plugin definitions with stored values in contacts.custom JSONB
- Add CustomFieldRenderer component (read + edit modes)
- Integrate into ContactDetail (read-only) and ContactEditModal (editable)
- Add custom_fields to pluginStore and active manifests API
- Add useCustomFields/useUpdateCustomFields React Query hooks
- Tests: test_custom_fields.py (9 tests) + CustomFieldRenderer.test.tsx (5 tests)
- i18n keys already present (contacts.customFields)
2026-07-23 23:35:35 +02:00
Agent Zero
66b6c32ed8
Phase 5.14: API documentation - OpenAPI tags, response models, examples, docs
2026-07-23 22:44:54 +02:00
Agent Zero
75a7063bff
feat(5.2): add User Preferences API with full-stack implementation
...
Backend:
- Create app/models/user_preference.py with TenantMixin (user_id, key, value JSONB)
- Create app/routes/user_preferences.py with GET/PUT/DELETE endpoints + RBAC
- Add user_preferences:read/write to CORE_PERMISSIONS
- Add user_preferences to legacy role permissions (admin/editor/viewer)
- Register route in app/main.py and app/routes/__init__.py
- Create alembic migration 0028_user_preferences
- Add UserPreference model to conftest.py for test schema
- Fix pre-existing conftest seed (Contact industry field removed in migration 0027)
Frontend:
- Create frontend/src/api/userPreferences.ts with React Query hooks
- Create frontend/src/hooks/useUserPreferences.ts syncing with uiStore
- Add i18n entries for de.json and en.json
Tests:
- 13 tests covering CRUD, tenant isolation, CSRF, unauthenticated access
- All tests passing
2026-07-23 20:39:42 +02:00
Agent Zero
879106c4eb
Phase 1C: Frontend unified contact UI
2026-07-23 17:17:32 +02:00
Agent Zero
ec81940178
Phase 0 Complete: Tasks 0.7-0.20
...
- 0.7: UI-Design-Richtlinien (docs/ui-design-guidelines.md, 535 lines)
- 0.8: Theme-Customization Backend (4 theme fields, migration 0023)
- 0.9: Theme-Customization Frontend (SettingsTheme.tsx, themeStore.ts, live preview)
- 0.10: RBAC-Audit (4 plugins secured, 53 routes with require_permission)
- 0.11: LiteLLM-Cleanup (llm_client.py migrated from httpx to litellm)
- 0.12: KI-Agent-Framework docs (plugin-development-guide.md, agent_capabilities field)
- 0.13: Heartbeat configurable (ProactiveSettings, migration 0024, frontend UI)
- 0.14: Unified Search Field-Level RBAC (resolve_permissions + filter_fields_by_permission)
- 0.15: Undo/History-System (EntityHistory model, service, routes, migration 0025, HistoryViewer)
- 0.16: Storage Backend (LocalStorage + S3Storage, DMS/attachments/mail updated)
- 0.17: Import/Export unified Contact fields (firstname, surname, email_1, phone_1)
- 0.18: .gitignore & Config-Cleanup (webui→frontend, python-jose removed, .env untracked)
- 0.19: Mail-Salt Security-Fix (per-account random salt, migration 0026)
- 0.20: AGPL replaced (PyMuPDF→pypdf, OnlyOffice→Collabora, LICENSE + THIRD_PARTY_LICENSES.md)
2026-07-23 08:42:26 +02:00
Agent Zero
c2143eea19
debug: add startup print statements for plugin activation
2026-07-22 02:14:29 +02:00
Agent Zero
29202325a6
feat: Kontakt-Ordner mit Drag&Drop Baum (wie KI-Chat Sidebar)
...
- Backend: ContactFolder model (hierarchisch, parent_id, sort_order)
- Migration 0022: contact_folders Tabelle + folder_id FK auf contacts
- CRUD Routes: /api/v1/contact-folders (list, create, update, delete, reorder)
- Move Contact API: /api/v1/contact-folders/contacts/{id}/move
- folder_id Filter in contacts list API
- Frontend: ContactFolderTree mit Baum-Struktur, Drag&Drop, Kontext-Menü
- Kontakt-Personen-Icon statt Ordner-Symbol
- ContactList Items draggable (List/Table/Cards View)
- React Query Hooks für Folder CRUD + Move Contact
- Alle 266 Frontend-Tests passing
2026-07-20 01:33:44 +02:00
Agent Zero
beaca24480
feat: phase 3 - field-level permissions with plugin field definitions, service-layer filtering, 20 core field definitions
2026-07-15 23:02:30 +02:00
Agent Zero
b490a62322
feat: granular RBAC system with user groups, deny-list, permission registry, system-admin, self-mod prevention
2026-07-15 21:59:45 +02:00
leocrm-bot
bb4b0ce514
feat: Core Plugin system — is_core flag, topological sort dependency resolution, deactivation protection
2026-07-07 07:44:02 +02:00
Leopoldadmin
d13f82ae8b
A/C1/C6: Register addresses+audit routers, add seed_default_data in lifespan
2026-07-04 01:30:08 +00:00
Leopoldadmin
3bacf1949b
feat(core): register attachment router in main.py
2026-07-04 00:29:39 +00:00
Leopoldadmin
3eeb1f4102
feat(core): register system_settings router in main.py
2026-07-04 00:26:22 +00:00
Leopoldadmin
4b8562f1c1
feat(core): register sequence router in main.py
2026-07-04 00:24:41 +00:00
Leopoldadmin
f799d11950
feat(core): register tax router in main.py
2026-07-04 00:23:36 +00:00
Leopoldadmin
d3033056fd
feat(core): register currency router in main.py
2026-07-04 00:22:08 +00:00
Leopoldadmin
812ccdeaf0
fix: add missing display_name to PluginModel creation in lifespan
...
The PluginModel.display_name column is NOT NULL but was not set when
auto-installing builtin plugins during app startup, causing IntegrityError.
Fix mirrors the pattern used in registry.install().
2026-07-03 00:12:43 +00:00
leocrm-bot
36ac1d0df9
fix: register plugin routes in create_app BEFORE SPA catch-all
...
- Plugin routes now registered in create_app (sync context) before SPA catch-all
- Previously plugin routes were added in lifespan (async) AFTER SPA catch-all
- FastAPI matches routes in registration order — catch-all was shadowing plugin routes
- Fixes: Calendar/Mail/DMS/Tags/Permissions returning 404 despite being in OpenAPI
2026-07-02 14:37:30 +02:00
leocrm-bot
07bf6ce445
fix: auto-install discovered builtin plugins on startup — create DB records, run migrations, activate, register routes
...
- Lifespan creates PluginModel records for discovered plugins if missing
- Runs plugin migrations automatically
- Activates plugins and registers routes in FastAPI
- Fixes: Calendar/Mail/DMS/Tags/Permissions 404 after restart
2026-07-02 13:32:48 +02:00
leocrm-bot
5dc4d6d4c0
fix: activate plugins on startup + register routes + seed admin script
...
- lifespan: load active plugins from DB, call on_activate, register routes
- Fixes: Calendar/Mail/DMS/Tags/Permissions routes returning 404
- scripts/seed_admin.py: creates default tenant + admin user
2026-07-02 13:02:38 +02:00
leocrm-bot
f477efc366
fix: serve frontend in production — multi-stage Dockerfile with Node build + StaticFiles mount
...
- Dockerfile: add Node.js frontend build stage (vite build)
- Dockerfile: copy frontend/dist into runtime image
- app/main.py: mount /assets static files + SPA catch-all fallback
- app/main.py: serve index.html for all non-API routes
- Fixes: https://crm.media-on.de/ returning 404 (frontend not served)
2026-07-02 09:55:50 +02:00
leocrm-bot
4c7f09c518
chore: ruff lint auto-fix — 9 errors fixed (import sorting, unused imports)
...
- I001: import block sorting in main.py, routes/__init__.py, companies.py, conftest.py, check_indexes.py
- F401: unused imports removed (asyncio, UTC, datetime, AsyncSession)
- 6 ASYNC240/230 warnings remain (os.path.exists in async, open() in test) — minor, non-blocking
2026-07-02 00:20:15 +02:00
leocrm-bot
69e91fd5d0
T10: Monitoring, Performance, Documentation & Environment Config — 38 tests, ruff clean, docs OK
...
- Extended health endpoint: DB+Redis+Storage+Worker checks with degraded status
- Prometheus metrics endpoint: admin-only, text/plain format
- Metrics: http_requests_total, db_pool_connections, arq_jobs_total
- Structured JSON logging (structlog): timestamp, level, method, path, status, duration_ms, tenant_id
- Performance: page_size max 100 enforced (422), streaming CSV export (StreamingResponse)
- Scripts: seed_perf_data.py, check_indexes.py
- Docs: admin-guide.md (Deploy, Backup, Restore, Env-Vars, Troubleshooting), api-overview.md
- README updated: prod setup, API section, env profiles, admin-guide link
- .env.example: added SECRET_KEY, STORAGE_PATH, SMTP_* vars
- 38 new tests, full regression 564/564 pass (0 failures)
- Ruff: all checks passed
2026-07-01 23:15:35 +02:00
leocrm-bot
a2452cc04b
chore: fix all ruff lint errors + format — 0 errors, 306 tests pass
2026-06-29 17:43:56 +02:00
leocrm-bot
851e7999ba
T09: KI-Copilot API + Hybrid Workflow Engine + LLM client + event-triggered workflows
...
- KI-Copilot: NL query → proposed actions, execute with RBAC, history, audit logging
- LLM client: mock mode (no API key) + OpenAI-compatible mode (AI_MODEL/AI_API_KEY)
- Action mapper: NL intent → API calls (create/update/delete/search company/contact)
- Workflow engine: step types (action/approval/notification/condition), JSONB steps
- Workflow lifecycle: pending → in_progress → completed/rejected/cancelled
- Event-triggered workflows: event bus → auto-start instances
- Code-engine workflows: onboarding on user.created event
- Approval timeout: auto-reject after configured hours
- 5 new tenant-scoped tables with RLS: ai_conversations, ai_messages, workflows, workflow_instances, workflow_step_history
- Migration 0004: all tables + RLS policies + tenant_id + indexes
- 238 tests pass (30 AC + 105 coverage + 103 existing), 84.12% T09 module coverage
- MissingGreenlet fix: safe accessor helpers for async ORM attribute access
2026-06-29 08:02:15 +02:00
leocrm-bot
9678344f0e
T03: plugin system framework + lifecycle + migrations + event bus + DI
...
- Plugin registry with discover/install/activate/deactivate/uninstall lifecycle
- PluginManifest Pydantic v2 schema (name, version, dependencies, routes, events, migrations)
- BasePlugin abstract class with lifecycle hooks (on_install/activate/deactivate/uninstall)
- Migration runner with tenant_id validator (rejects tables without tenant_id)
- Event bus integration: register/unregister listeners on activate/deactivate
- Service container DI: plugins receive db, cache, event_bus, storage, notifications
- Idempotent operations (activate active=200, deactivate inactive=200)
- UI registry for frontend component registration
- 47 new tests (14 ACs + 33 unit tests), 103 total tests pass
- Migration 0003: plugins + plugin_migrations tables
- Coverage: 85.92% for plugin modules
2026-06-29 08:02:15 +02:00
leocrm-bot
dd16940bb2
T02: companies + contacts + import/export + N:M + soft-delete + GDPR + FTS
...
- Company CRUD with soft-delete, FTS search (tsvector + GIN), filter, pagination
- Contact CRUD with N:M company linking via company_contacts
- CSV/XLSX export, CSV import with dry-run preview
- GDPR hard-delete with deletion_log
- Audit log on all mutations
- 27 new tests (24 ACs), 56 total tests pass
- Migration 0002: contacts, company_contacts, FTS search_tsv
- Fixed T01 tests: POST→201, PATCH→PUT compatibility
2026-06-29 08:02:15 +02:00
leocrm-bot
3ab4925783
T01: core infrastructure + auth + multi-tenant + RLS
...
- 10 models: tenants, users, user_tenants, roles, sessions, audit_log, deletion_log, notifications, password_reset_tokens, api_tokens
- Session-based auth (Redis + PostgreSQL audit trail)
- Multi-tenant with ORM-level filtering + PostgreSQL RLS (set_config)
- RBAC with roles/permissions + field-level permissions
- CSRF protection via Origin header validation
- Auth rate limiting (Redis counters with TTL)
- CORS with explicit origins (no wildcard)
- Health endpoint (no auth required)
- Notification service + audit log middleware
- 29 tests, 26 ACs, all passing
- Coverage: 62% (infrastructure modules pending coverage in later tasks)
2026-06-29 08:02:14 +02:00
Agent Zero
b5f7a220fe
chore(quality): apply ruff autofixes and formatting (223 fixes, regression-free: 118/118 tests pass)
2026-06-29 08:01:45 +02:00
Leopoldadmin
a5efb0cf72
Upload app/main.py
2026-06-29 08:01:44 +02:00