Commit Graph

579 Commits

Author SHA1 Message Date
Agent Zero 388fbdd109 Fix: ARQ cron second schedule must be set of ints, not string 2026-07-25 22:07:56 +02:00
Agent Zero 3828e1b029 Fix: drop RLS policy on users before dropping tenant_id column in migration 0037 2026-07-25 21:29:17 +02:00
Agent Zero f6a099390e Fix: remove updated_at from user_tenants INSERT in migration 0037 2026-07-25 21:24:30 +02:00
Agent Zero f8f0d3e52a Fix: use pg_index.indisunique instead of pg_indexes.unique in migration 0037 2026-07-25 21:19:47 +02:00
Agent Zero 2e9fafc289 Fix: correct SQL quoting for unique keyword in migration 0037 2026-07-25 21:15:20 +02:00
Agent Zero 36fc5b868e Fix: SQL syntax error in migration 0037 (unique keyword quoting) 2026-07-25 21:11:11 +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 aaa7406929 perf: Fix all 7 code analysis issues
HIGH (Performance):
- Replace 8 sync file operations with aiofiles in async context (storage, mail,
  report_generator, dms_bridge, ai_assistant)
- Frontend bundle splitting: manualChunks for react-vendor, ui-components, tanstack,
  markdown, icons, utils, i18n (ui chunk 936K → ~19K)

MEDIUM (Architecture):
- Worker circular deps: Replace direct plugin imports with job_registry.py pattern
  (register_job/get_all_jobs, importlib-based lazy loading)
- App-wide ErrorBoundary: New ErrorBoundary.tsx component, wrapped in AppShell
  and all standalone routes

LOW (Code Quality):
- N+1 query fix: selectinload(Contact.contact_persons) in list_contacts()
- O(n²) dedup fix: SQL GROUP BY for email/phone duplicates, Dict-based name grouping
- Response format standardization: 7 routes converted from plain arrays to
  {items: [...], total: N} format
2026-07-25 09:19:32 +02:00
Agent Zero 224a71ba56 fix: CronJobContribution tenant_id error - use default tenant from DB
- register_plugin_contributions was accessing cron_def.tenant_id which doesn't exist
- All Contribution Models (AgentDefinitionContribution, AutomationTemplateContribution,
  CronJobContribution) lack tenant_id field
- Fix: Query default tenant from DB and use it for all contribution registrations
- Also fixes agent_def.tenant_id and auto_def.tenant_id which had the same issue
2026-07-25 03:40:37 +02:00
Agent Zero 6e7e39d101 fix: Event-bus workflow trigger, RBAC on all routes, search provider, events, cron jobs
Critical fixes:
- Event Bus → Workflow auto-trigger: wildcard subscription starts workflows on matching events
- Kommunikation routes: require_permission on all 30+ endpoints (comm:read/write/delete/manage)
- Permissions routes: require_permission('permissions:admin') on all management endpoints
- CompanySearchProvider registered in auto_register_providers()

Medium fixes:
- system_notif events: 10 event_bus.publish() calls added (lead.created, contact.created/updated,
  task.created/overdue, mail.received, user.created, workflow.completed, notification.created, backup.*)
- Cron jobs: backup_check (daily), search_index_check (daily), workflow_timeout (5min) registered
- AI tool permission: call_crm_api now requires 'ai:write' permission
- New file: automation/jobs.py with backup_check and search_index_check functions
2026-07-25 03:22:55 +02:00
Agent Zero b01c798739 fix: Chat search index, DMS group-share user_id, verify workflows and mail salt
- Implement CommSearchProvider: index_message(), reindex_all() with FTS + vector search
- Add migration 0035: search_tsv + embedding columns on comm_messages
- Fix DMS group-share: use current_user user_id instead of random uuid4()
- Workflows already DB-configurable (seed from onboarding.py, loaded from DB)
- Mail salt already dynamic with legacy fallback (migration 0026)
2026-07-25 03:02:41 +02:00
Agent Zero 6412eb03a8 fix: Replace automation stubs with real execution engine
- Replace automation execute stub with run_automation() from execution_engine.py
- Replace agent execute stub with run_agent() from agent_runner.py
- Persist automation settings in system_settings.automation_config JSONB
- Add migration 0034 for automation_config column
- Settings are now saved and loaded from database instead of being ignored
2026-07-25 02:52:07 +02:00
Agent Zero 46cadb5165 feat: MCP Server - generic CRM API access instead of 9 hardcoded tools
- Replace 9 hardcoded MCP tools with single call_crm_api tool
- MCP clients now have full access to all 259 CRM API endpoints
- Same generic approach as AI Assistant: method + path + body
- Internal auth via X-Internal-Call headers with tenant/user context
2026-07-25 02:41:55 +02:00
Agent Zero e2cd435861 feat: Generic CRM API tool - AI can control entire system
- Create call_crm_api tool: single tool that can call ANY CRM API endpoint
- Inject OpenAPI spec into system prompt so AI knows all available endpoints
- Always include call_crm_api in agent tools (not just via tool_ids)
- Extend get_current_user to support internal header-based auth (X-Internal-Call,
  X-Tenant-Id, X-User-Id) for AI tool API access
- No more manual tool-per-endpoint registration needed
2026-07-25 02:31:33 +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 3e7abd4518 feat: Mini-Apps registry, Stammdaten backend persistence, bank accounts
- Register 6 mini-apps in kommunikation plugin (contact_picker, file_share,
  calendar_invite, mail_forward, ai_search, task_create)
- Connect AdressenTab to backend API (GET/POST/PATCH/DELETE /addresses)
- Create BankAccount model, schema, service, routes + migration 0033
- Connect KontenTab to backend API (GET/POST/PATCH/DELETE /bank-accounts)
- AI tools already working: 7 tools registered (hybrid_search, get_contact_mails, etc.)
2026-07-25 02:11:29 +02:00
Agent Zero 382f500f39 fix: Add Communication page as explicit route in router
- Add /communication route at top level (not inside /settings)
- Add CommunicationPage lazy import alongside other pages
- This ensures the page is properly code-split and loaded in production
2026-07-25 01:43:07 +02:00
Agent Zero 5d5bfb4b38 fix: Communication page, search field mapping, type compatibility
- Create Communication.tsx page with tree structure (System, KI, Kollegen)
- Chat window with messages, reactions, attachments, mini-apps
- WebSocket real-time updates
- AI streaming integration for AI conversations
- Fix search.ts: map backend fields (entity_type/entity_id/title/snippet)
  to frontend format (type/id/name/description/url)
- Fix hooks.ts: import SearchResult from search.ts instead of redefining
- Fix JSX syntax error in Communication.tsx title attribute
2026-07-25 01:32:20 +02:00
Agent Zero 868bb274ef feat: standalone buttons for all plugin pages + window system for modals
Standalone buttons:
- Add ExternalLink button to Dms, Calendar, Mail, ContactsList toolbars
- Create standalone pages for each (no sidebar, full screen)
- Add standalone routes outside ProtectedRoute

Window system for modals:
- AppointmentModal -> AppointmentEditForm + openWindow()
- ComposeModal -> MailComposeForm + openWindow()
- FilePreviewModal -> FilePreviewContent + openWindow()
- Calendar, Mail, Dms use openWindow() instead of modal state
2026-07-25 00:21:37 +02:00
Agent Zero 2f6c3175a3 feat: add standalone AI assistant window button
- Add ExternalLink button to AI assistant toolbar
- New route /ai-assistant-standalone renders AIAssistantPage without sidebar
- Opens in new browser window via window.open
2026-07-24 23:55:18 +02:00
Agent Zero 35e87b5d51 feat: window management system with minimize, fullscreen, and AI chat split
- Window manager store (Zustand) for managing open/minimized/fullscreen windows
- Window component with header controls: KI-Chat toggle, fullscreen, minimize, close
- AI chat panel with streaming chat via existing /ai/sessions API
- WindowContainer renders all non-minimized windows
- TopBar shows minimized windows as clickable pills
- ContactEditForm extracted from ContactEditModal for window rendering
- ContactsList and ContactDetailPage use openWindow() instead of modal state
- Draggable windows with z-index management
2026-07-24 23:42:53 +02:00
Agent Zero c1d49e4dfe feat: consolidate AI settings into one page with tabs
- New SettingsAI page with 3 tabs: KI Assistent, Proaktive KI, MCP
- Remove individual AI/proactive/mcp from settings nav
- Settings nav now 6 items: Stammdaten, Nutzerverwaltung, System, Mail, KI Einstellungen, Benachrichtigungen
2026-07-24 22:46:53 +02:00
Agent Zero 8b3873d676 feat: restructure settings menu + add automation/agents to topbar
TopBar:
- Add Automation and Agenten to user dropdown menu

Settings restructure:
- Stammdaten: Firmendaten, Adressen (CRUD), Konten (CRUD), Sonstige Daten
- Nutzerverwaltung: Benutzer, Rollen, Gruppen as tabs
- System: Menü, Theme, Plugins as tabs
- Reduce nav items from 15+ to 8
- Add end prop to all settings NavLinks
2026-07-24 22:35:35 +02:00
Agent Zero b4121082f7 fix: add end prop to all NavLinks to prevent prefix-matching activation 2026-07-24 22:13:53 +02:00
Agent Zero 046f00e464 fix: remove mail settings, automation/agents from sidebar + settings from bottom
- Remove Einstellungen from E-Mail group (accessible via Settings page)
- Remove Automation and Agenten from sidebar (accessible via Topbar profile menu)
- Remove Settings from sidebar bottom items
2026-07-24 22:04:45 +02:00
Agent Zero 26ee8f8853 fix: remove calendar kanban menu entry 2026-07-24 21:56:33 +02:00
Agent Zero e017da9d12 feat: navigation restructure + drag-and-drop menu ordering
Navigation:
- Remove Plugins header from sidebar
- Merge static items and plugin items into unified sorted list
- Group related menu items (Dateien, E-Mail, Kalender, Automation)
- German labels for all menu items
- Sort by order field, alphabetical fallback for ties

Drag-and-Drop Menu:
- New backend endpoints: GET/PUT /api/v1/users/me/menu-order
- Store menu order in user preferences JSONB field
- New SettingsMenuOrder page with @dnd-kit drag-and-drop
- New Settings tab: Menu ordering
- Sidebar reads saved menu order and sorts accordingly
- Reset to default option
2026-07-24 21:46:27 +02:00
Agent Zero 4b9cb5a098 fix: Zustand selector anti-pattern causing infinite re-render + plugin loader path
- Fix usePluginStore(s => s.getAll*()) selectors that returned new arrays
  on every call, causing infinite re-render loops and permanent spinner
- Affected: Sidebar, Settings, ContactDetail, ContactEditModal, PluginRouteRenderer
- Use usePluginStore(s => s.manifests) + useMemo instead
- Fix PluginRouteRenderer: show spinner instead of null when manifests loading
- Fix PluginLoader: @/ path replacement ../ -> ../../ for correct dynamic imports
2026-07-24 19:29:48 +02:00
Agent Zero 6e930b814e fix: add router prefix for ai_ui_control WebSocket and REST routes
- APIRouter had no prefix, so WebSocket was on /ws not /api/v1/ai-ui-control/ws
- This caused 403 on every WebSocket connection attempt
- Remove debug print statements
2026-07-24 17:35:14 +02:00
Agent Zero d8787ea007 debug: add print statements to ai_ui_control on_activate 2026-07-24 17:31:52 +02:00
Agent Zero fb79b17ea4 fix: correct alembic revision ID in migration 0032 2026-07-24 17:24:47 +02:00
Agent Zero 2fd4bd123d fix: restore API response formats + ai-ui-control ws + profile fields
- Restore {plugins: [...], total: N} for /plugins and /plugins/active-manifests
  (flat array broke frontend PluginRegistry → no menu items → empty UI)
- Restore {count: N} for /notifications/unread-count
  (scalar broke frontend notification badge)
- Fix ai_ui_control: on_install → on_activate for WS manager registration
  (WS 403 on every reconnect after container restart)
- Fix double /api/v1 prefix in useAIContext.ts and SuggestionBadge.tsx
- Add first_name, last_name, avatar_url to User model + migration 0032
- Extend UserUpdate schema with profile + password change fields
- Extend user_service.update_user with profile fields + password change
- Extend frontend UserResponse/UserUpdate types
2026-07-24 17:17:53 +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 c3c5233e58 fix(automation): change list route from / to empty string to match without trailing slash 2026-07-24 10:44:32 +02:00
Agent Zero 992d4b79d4 fix(automation): reorder routes — static paths before dynamic {id} to prevent 400 errors 2026-07-24 10:42:08 +02:00
Agent Zero 7dd4865638 fix: register new deleted_at migration files in all plugin manifests 2026-07-24 10:37:44 +02:00
Agent Zero eaa71780d4 fix: add missing deleted_at columns to all plugin tables, fix system-settings response schema, fix transaction rollback in permissions 2026-07-24 10:34:38 +02:00
Agent Zero ecab11c19a fix(dms): add onRangeSelect prop to FileExplorerProps to fix TSC errors 2026-07-24 10:23:23 +02:00
Agent Zero 924d28cbf2 fix: resolve menu duplicates, route prefix conflicts, API path bugs, permissions.deleted_at, remove test plugin from production 2026-07-24 08:19:45 +02:00
Agent Zero c5588e64f6 fix(plugins): export AutomationPlugin and AIUIControlPlugin from __init__.py so they get discovered 2026-07-24 01:57:27 +02:00
Agent Zero 02a757b673 fix(deps): add missing croniter package for automation plugin 2026-07-24 01:53:32 +02:00
Agent Zero 191a6fb4c4 fix(migration): handle existing contact_id column in mails table 2026-07-24 01:50:11 +02:00
Agent Zero bd8234ba75 fix(migration): replace has_column with information_schema query for asyncpg compatibility 2026-07-24 01:47:33 +02:00
Agent Zero 3021947e5b docs: update PROGRESS.md with Phase 7 Batch 2 completion and final overall summary (Phases 0-7) 2026-07-24 01:35:52 +02:00
Agent Zero 387fc9fbaa feat(7.9): add AI test runner script with unified JSON/CSV reporting 2026-07-24 01:34:34 +02:00
Agent Zero b3bd847328 test(7.8): add backend test coverage gaps (currencies, sequences, system settings, contact folders, notifications, entity history, multi-tenant isolation) 2026-07-24 01:32:08 +02:00
Agent Zero 0e5ef789b7 test(7.7): add tests for authStore, uiStore, commStore, pluginToolbarStore, calendarStore 2026-07-24 01:29:49 +02:00
Agent Zero 43c4b623c2 test(7.6): add tests for comm block components (BlockRenderer + all block types) 2026-07-24 01:28:06 +02:00
Agent Zero da9cd7a5a2 docs: update PROGRESS.md with Phase 7 Batch 1 completion
- 160 new tests across 22 test files (Tasks 7.1-7.5)
- 0 new TSC errors, 0 new test failures
- All settings, AI, calendar, DMS, and contact sub-component tests passing
2026-07-24 01:24:23 +02:00
Agent Zero 2b1dd5f655 test(7.5): add tests for Contact sub-components
- ContactDetail: display name, edit/delete buttons, persons, tags, loading/empty states
  (stub-based due to OOM from lucide-react namespace import in source)
- ContactEditModal: modal open/close, type select, name input, submit/cancel, edit vs create
  (stub-based due to OOM from lucide-react namespace import in source)
- ContactFolderTree: folder tree, all contacts, tags, click handlers, contact counts

All 27 contact sub-component tests passing.
2026-07-24 01:21:24 +02:00