@myrialabs/clopen 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +5 -0
- package/.env.example +2 -5
- package/CONTRIBUTING.md +4 -0
- package/README.md +4 -2
- package/backend/{lib/auth → auth}/auth-service.ts +2 -2
- package/backend/{lib/chat → chat}/stream-manager.ts +1 -1
- package/backend/{lib/database → database}/queries/message-queries.ts +42 -0
- package/backend/{lib/database → database}/utils/connection.ts +5 -5
- package/backend/{lib/engine → engine}/adapters/claude/environment.ts +3 -4
- package/backend/{lib/engine → engine}/adapters/opencode/message-converter.ts +1 -1
- package/backend/{lib/engine → engine}/adapters/opencode/server.ts +7 -1
- package/backend/{lib/files → files}/file-watcher.ts +1 -1
- package/backend/{lib/git → git}/git-executor.ts +3 -2
- package/backend/index.ts +16 -16
- package/backend/{lib/mcp → mcp}/README.md +68 -79
- package/backend/{lib/mcp → mcp}/config.ts +1 -1
- package/backend/{lib/mcp → mcp}/servers/browser-automation/actions.ts +4 -4
- package/backend/{lib/mcp → mcp}/servers/browser-automation/browser.ts +3 -3
- package/backend/{lib/mcp → mcp}/servers/browser-automation/inspection.ts +3 -3
- package/backend/middleware/cors.ts +1 -1
- package/backend/middleware/error-handler.ts +1 -1
- package/backend/{lib/preview → preview}/browser/browser-preview-service.ts +1 -1
- package/backend/{lib/preview → preview}/browser/browser-tab-manager.ts +1 -1
- package/backend/{lib/preview → preview}/browser/types.ts +1 -1
- package/backend/{lib/project → project}/status-manager.ts +223 -223
- package/backend/{lib/snapshot → snapshot}/blob-store.ts +2 -2
- package/backend/{lib/terminal → terminal}/shell-utils.ts +1 -1
- package/backend/{lib/shared → utils}/env.ts +13 -15
- package/backend/{lib/shared → utils}/index.ts +4 -1
- package/backend/utils/paths.ts +11 -0
- package/backend/{lib/shared → utils}/port-utils.ts +19 -6
- package/backend/{lib/utils → utils}/ws.ts +2 -2
- package/backend/ws/README.md +9 -9
- package/backend/ws/auth/invites.ts +2 -2
- package/backend/ws/auth/login.ts +9 -9
- package/backend/ws/auth/status.ts +2 -2
- package/backend/ws/auth/users.ts +1 -1
- package/backend/ws/chat/background.ts +2 -2
- package/backend/ws/chat/stream.ts +3 -3
- package/backend/ws/engine/claude/accounts.ts +4 -4
- package/backend/ws/engine/claude/status.ts +1 -1
- package/backend/ws/files/read.ts +2 -2
- package/backend/ws/files/watch.ts +2 -2
- package/backend/ws/files/write.ts +1 -1
- package/backend/ws/git/branch.ts +2 -2
- package/backend/ws/git/commit.ts +2 -2
- package/backend/ws/git/conflict.ts +2 -2
- package/backend/ws/git/diff.ts +2 -2
- package/backend/ws/git/log.ts +2 -2
- package/backend/ws/git/remote.ts +2 -2
- package/backend/ws/git/staging.ts +2 -2
- package/backend/ws/git/status.ts +3 -3
- package/backend/ws/messages/crud.ts +53 -1
- package/backend/ws/preview/browser/cleanup.ts +2 -2
- package/backend/ws/preview/browser/console.ts +2 -2
- package/backend/ws/preview/browser/interact.ts +2 -2
- package/backend/ws/preview/browser/mcp.ts +1 -1
- package/backend/ws/preview/browser/native-ui.ts +2 -2
- package/backend/ws/preview/browser/stats.ts +2 -2
- package/backend/ws/preview/browser/tab-info.ts +2 -2
- package/backend/ws/preview/browser/tab.ts +2 -2
- package/backend/ws/preview/browser/webcodecs.ts +2 -2
- package/backend/ws/projects/crud.ts +3 -3
- package/backend/ws/projects/presence.ts +3 -3
- package/backend/ws/projects/status.ts +3 -3
- package/backend/ws/sessions/crud.ts +2 -2
- package/backend/ws/settings/crud.ts +2 -2
- package/backend/ws/snapshot/restore.ts +5 -5
- package/backend/ws/snapshot/timeline.ts +3 -3
- package/backend/ws/system/operations.ts +1 -1
- package/backend/ws/terminal/persistence.ts +3 -3
- package/backend/ws/terminal/session.ts +6 -6
- package/backend/ws/terminal/stream.ts +2 -2
- package/backend/ws/tunnel/operations.ts +1 -1
- package/backend/ws/user/crud.ts +4 -4
- package/bin/clopen.ts +15 -15
- package/docker-compose.yml +31 -0
- package/frontend/App.svelte +13 -13
- package/frontend/{lib/components → components}/auth/InvitePage.svelte +2 -2
- package/frontend/{lib/components → components}/auth/LoginPage.svelte +1 -1
- package/frontend/{lib/components → components}/auth/SetupPage.svelte +49 -17
- package/frontend/{lib/components → components}/chat/ChatInterface.svelte +14 -14
- package/frontend/{lib/components → components}/chat/formatters/ErrorMessage.svelte +1 -1
- package/frontend/{lib/components → components}/chat/formatters/MessageFormatter.svelte +4 -4
- package/frontend/{lib/components → components}/chat/formatters/TextMessage.svelte +1 -1
- package/frontend/{lib/components → components}/chat/formatters/Tools.svelte +1 -1
- package/frontend/{lib/components → components}/chat/input/ChatInput.svelte +12 -12
- package/frontend/{lib/components → components}/chat/input/components/ChatInputActions.svelte +1 -1
- package/frontend/{lib/components → components}/chat/input/components/EditModeIndicator.svelte +2 -2
- package/frontend/{lib/components → components}/chat/input/components/EngineModelPicker.svelte +9 -9
- package/frontend/{lib/components → components}/chat/input/components/FileAttachmentPreview.svelte +1 -1
- package/frontend/{lib/components → components}/chat/input/components/LoadingIndicator.svelte +2 -2
- package/frontend/{lib/components → components}/chat/input/composables/use-chat-actions.svelte.ts +8 -8
- package/frontend/{lib/components → components}/chat/input/composables/use-file-handling.svelte.ts +1 -1
- package/frontend/{lib/components → components}/chat/input/composables/use-input-state.svelte.ts +6 -6
- package/frontend/{lib/components → components}/chat/message/ChatMessage.svelte +8 -8
- package/frontend/{lib/components → components}/chat/message/ChatMessages.svelte +7 -7
- package/frontend/{lib/components → components}/chat/message/MessageBubble.svelte +1 -1
- package/frontend/{lib/components → components}/chat/message/MessageHeader.svelte +2 -2
- package/frontend/{lib/components → components}/chat/modal/DebugModal.svelte +2 -2
- package/frontend/{lib/components → components}/chat/modal/TokenUsageModal.svelte +2 -2
- package/frontend/{lib/components → components}/chat/tools/AskUserQuestionTool.svelte +4 -4
- package/frontend/{lib/components → components}/chat/tools/CustomMcpTool.svelte +1 -1
- package/frontend/{lib/components → components}/chat/tools/EditTool.svelte +1 -1
- package/frontend/{lib/components → components}/chat/tools/TodoWriteTool.svelte +1 -1
- package/frontend/{lib/components → components}/chat/tools/components/CodeBlock.svelte +2 -2
- package/frontend/{lib/components → components}/chat/tools/components/DiffBlock.svelte +1 -1
- package/frontend/{lib/components → components}/chat/tools/components/FileHeader.svelte +2 -2
- package/frontend/{lib/components → components}/chat/tools/components/InfoLine.svelte +1 -1
- package/frontend/{lib/components → components}/chat/widgets/FloatingTodoList.svelte +127 -13
- package/frontend/{lib/components → components}/chat/widgets/TokenUsage.svelte +4 -4
- package/frontend/{lib/components → components}/checkpoint/TimelineModal.svelte +10 -10
- package/frontend/{lib/components → components}/checkpoint/timeline/TimelineNode.svelte +1 -1
- package/frontend/{lib/components/common → components/common/display}/Icon.svelte +2 -2
- package/frontend/{lib/components/common → components/common/display}/PageTemplate.svelte +1 -1
- package/frontend/{lib/components/common → components/common/display}/ProjectUserAvatars.svelte +1 -1
- package/frontend/{lib/components/common → components/common/display}/ThemeToggle.svelte +1 -1
- package/frontend/{lib/components/common → components/common/editor}/MonacoEditor.svelte +2 -2
- package/frontend/{lib/components/common → components/common/feedback}/Alert.svelte +1 -1
- package/frontend/{lib/components/common → components/common/feedback}/ConnectionBanner.svelte +3 -3
- package/frontend/{lib/components/common → components/common/feedback}/LoadingScreen.svelte +1 -1
- package/frontend/{lib/components/common → components/common/feedback}/NotificationToast.svelte +2 -2
- package/frontend/{lib/components/common → components/common/feedback}/UpdateBanner.svelte +5 -5
- package/frontend/{lib/components/common → components/common/form}/Checkbox.svelte +1 -1
- package/frontend/{lib/components/common → components/common/form}/FolderBrowser.svelte +6 -6
- package/frontend/{lib/components/common → components/common/form}/Input.svelte +1 -1
- package/frontend/{lib/components/common → components/common/form}/ModelSelector.svelte +3 -3
- package/frontend/{lib/components/common → components/common/form}/Select.svelte +1 -1
- package/frontend/{lib/components/common → components/common/form}/Textarea.svelte +1 -1
- package/frontend/{lib/components/common → components/common/overlay}/Dialog.svelte +1 -1
- package/frontend/{lib/components/common → components/common/overlay}/Lightbox.svelte +3 -3
- package/frontend/{lib/components/common → components/common/overlay}/ModalProvider.svelte +2 -2
- package/frontend/{lib/components → components}/common/xterm/XTerm.svelte +5 -5
- package/frontend/{lib/components → components}/common/xterm/xterm-service.ts +2 -2
- package/frontend/{lib/components → components}/files/FileNode.svelte +3 -3
- package/frontend/{lib/components → components}/files/FileTree.svelte +5 -5
- package/frontend/{lib/components → components}/files/FileViewer.svelte +7 -7
- package/frontend/{lib/components → components}/files/SearchResults.svelte +3 -3
- package/frontend/{lib/components → components}/git/BranchManager.svelte +6 -6
- package/frontend/{lib/components → components}/git/ChangesSection.svelte +1 -1
- package/frontend/{lib/components → components}/git/CommitForm.svelte +1 -1
- package/frontend/{lib/components → components}/git/ConflictResolver.svelte +1 -1
- package/frontend/{lib/components → components}/git/DiffViewer.svelte +7 -7
- package/frontend/{lib/components → components}/git/FileChangeItem.svelte +3 -3
- package/frontend/{lib/components → components}/git/GitButton.svelte +1 -1
- package/frontend/{lib/components → components}/git/GitLog.svelte +2 -2
- package/frontend/{lib/components → components}/git/GitModal.svelte +3 -3
- package/frontend/{lib/components → components}/history/HistoryModal.svelte +41 -89
- package/frontend/{lib/components → components}/history/HistoryView.svelte +57 -104
- package/frontend/{lib/components → components}/index.ts +9 -9
- package/frontend/{lib/components → components}/preview/browser/BrowserPreview.svelte +3 -3
- package/frontend/{lib/components → components}/preview/browser/components/Canvas.svelte +2 -2
- package/frontend/{lib/components → components}/preview/browser/components/ConsolePanel.svelte +1 -1
- package/frontend/{lib/components → components}/preview/browser/components/Container.svelte +2 -2
- package/frontend/{lib/components → components}/preview/browser/components/ContextMenu.svelte +1 -1
- package/frontend/{lib/components → components}/preview/browser/components/SelectDropdown.svelte +1 -1
- package/frontend/{lib/components → components}/preview/browser/components/Toolbar.svelte +2 -2
- package/frontend/{lib/components → components}/preview/browser/core/cleanup.svelte.ts +1 -1
- package/frontend/{lib/components → components}/preview/browser/core/coordinator.svelte.ts +4 -4
- package/frontend/{lib/components → components}/preview/browser/core/interactions.svelte.ts +3 -3
- package/frontend/{lib/components → components}/preview/browser/core/mcp-handlers.svelte.ts +2 -2
- package/frontend/{lib/components → components}/preview/browser/core/native-ui-handlers.svelte.ts +2 -2
- package/frontend/{lib/components → components}/preview/browser/core/tab-manager.svelte.ts +1 -1
- package/frontend/{lib/components → components}/preview/browser/core/tab-operations.svelte.ts +3 -3
- package/frontend/{lib/components → components}/settings/SettingsModal.svelte +4 -4
- package/frontend/{lib/components → components}/settings/SettingsView.svelte +2 -2
- package/frontend/{lib/components → components}/settings/admin/InviteManagement.svelte +5 -5
- package/frontend/{lib/components → components}/settings/admin/UserManagement.svelte +5 -5
- package/frontend/{lib/components → components}/settings/appearance/AppearanceSettings.svelte +5 -5
- package/frontend/{lib/components → components}/settings/appearance/LayoutPresetSettings.svelte +3 -3
- package/frontend/{lib/components → components}/settings/appearance/LayoutPreview.svelte +1 -1
- package/frontend/{lib/components → components}/settings/engines/AIEnginesSettings.svelte +6 -6
- package/frontend/{lib/components → components}/settings/general/AdvancedSettings.svelte +5 -5
- package/frontend/{lib/components → components}/settings/general/AuthModeSettings.svelte +5 -5
- package/frontend/{lib/components → components}/settings/general/DataManagementSettings.svelte +9 -9
- package/frontend/{lib/components → components}/settings/general/UpdateSettings.svelte +3 -3
- package/frontend/{lib/components → components}/settings/model/ModelSettings.svelte +2 -2
- package/frontend/{lib/components → components}/settings/notifications/NotificationSettings.svelte +4 -4
- package/frontend/{lib/components → components}/settings/user/UserSettings.svelte +5 -5
- package/frontend/{lib/components → components}/terminal/Terminal.svelte +9 -9
- package/frontend/{lib/components → components}/terminal/TerminalTabs.svelte +1 -1
- package/frontend/{lib/components → components}/terminal/TerminalView.svelte +5 -5
- package/frontend/{lib/components → components}/tunnel/TunnelActive.svelte +3 -3
- package/frontend/{lib/components → components}/tunnel/TunnelButton.svelte +2 -2
- package/frontend/{lib/components → components}/tunnel/TunnelInactive.svelte +4 -4
- package/frontend/{lib/components → components}/tunnel/TunnelModal.svelte +2 -2
- package/frontend/{lib/components → components}/workspace/DesktopNavigator.svelte +372 -372
- package/frontend/{lib/components → components}/workspace/MobileNavigator.svelte +380 -380
- package/frontend/{lib/components → components}/workspace/PanelContainer.svelte +3 -3
- package/frontend/{lib/components → components}/workspace/PanelHeader.svelte +10 -10
- package/frontend/{lib/components → components}/workspace/ViewMenu.svelte +4 -4
- package/frontend/{lib/components → components}/workspace/WorkspaceLayout.svelte +17 -17
- package/frontend/{lib/components → components}/workspace/layout/DesktopLayout.svelte +1 -1
- package/frontend/{lib/components → components}/workspace/layout/MobileLayout.svelte +1 -1
- package/frontend/{lib/components → components}/workspace/layout/split-pane/Container.svelte +1 -1
- package/frontend/{lib/components → components}/workspace/layout/split-pane/Handle.svelte +2 -2
- package/frontend/{lib/components → components}/workspace/layout/split-pane/Layout.svelte +2 -2
- package/frontend/{lib/components → components}/workspace/panels/ChatPanel.svelte +14 -14
- package/frontend/{lib/components → components}/workspace/panels/FilesPanel.svelte +51 -13
- package/frontend/{lib/components → components}/workspace/panels/GitPanel.svelte +55 -17
- package/frontend/{lib/components → components}/workspace/panels/PreviewPanel.svelte +5 -5
- package/frontend/{lib/components → components}/workspace/panels/TerminalPanel.svelte +6 -6
- package/frontend/{lib/services → services}/chat/chat.service.ts +8 -8
- package/frontend/{lib/services → services}/notification/global-stream-monitor.ts +117 -117
- package/frontend/{lib/services → services}/notification/push.service.ts +1 -1
- package/frontend/{lib/services → services}/notification/sound.service.ts +1 -1
- package/frontend/{lib/services → services}/preview/browser/browser-console.service.ts +1 -1
- package/frontend/{lib/services → services}/preview/browser/browser-webcodecs.service.ts +1 -1
- package/frontend/{lib/services → services}/preview/browser/mcp-integration.svelte.ts +2 -2
- package/frontend/{lib/services → services}/project/status.service.ts +160 -160
- package/frontend/{lib/services → services}/snapshot/snapshot.service.ts +2 -2
- package/frontend/{lib/services → services}/terminal/background/index.ts +1 -1
- package/frontend/{lib/services → services}/terminal/background/session-restore.ts +1 -1
- package/frontend/{lib/services → services}/terminal/background/stream-manager.ts +1 -1
- package/frontend/{lib/services → services}/terminal/project.service.ts +2 -2
- package/frontend/{lib/services → services}/terminal/terminal.service.ts +2 -2
- package/frontend/{lib/stores → stores}/core/app.svelte.ts +1 -1
- package/frontend/{lib/stores → stores}/core/presence.svelte.ts +4 -4
- package/frontend/{lib/stores → stores}/core/projects.svelte.ts +5 -5
- package/frontend/{lib/stores → stores}/core/sessions.svelte.ts +3 -3
- package/frontend/{lib/stores → stores}/features/auth.svelte.ts +30 -2
- package/frontend/{lib/stores → stores}/features/claude-accounts.svelte.ts +1 -1
- package/frontend/{lib/stores → stores}/features/models.svelte.ts +1 -1
- package/frontend/{lib/stores → stores}/features/settings.svelte.ts +2 -2
- package/frontend/{lib/stores → stores}/features/terminal.svelte.ts +4 -4
- package/frontend/{lib/stores → stores}/features/tunnel.svelte.ts +1 -1
- package/frontend/{lib/stores → stores}/features/user.svelte.ts +1 -1
- package/frontend/{lib/stores → stores}/ui/edit-mode.svelte.ts +3 -3
- package/frontend/{lib/stores → stores}/ui/update.svelte.ts +8 -2
- package/frontend/{lib/utils → utils}/theme.ts +1 -1
- package/frontend/{lib/utils → utils}/ws.ts +1 -1
- package/package.json +2 -2
- package/scripts/dev.ts +4 -3
- package/scripts/generate-icons.ts +2 -2
- package/scripts/start.ts +24 -0
- package/shared/types/ui/icons.ts +4 -4
- package/shared/utils/anonymous-user.ts +1 -1
- package/shared/utils/ws-server.ts +3 -3
- package/vite.config.ts +2 -2
- /package/backend/{lib/auth → auth}/index.ts +0 -0
- /package/backend/{lib/auth → auth}/permissions.ts +0 -0
- /package/backend/{lib/auth → auth}/rate-limiter.ts +0 -0
- /package/backend/{lib/auth → auth}/tokens.ts +0 -0
- /package/backend/{lib/chat → chat}/helpers.ts +0 -0
- /package/backend/{lib/chat → chat}/index.ts +0 -0
- /package/backend/{lib/database → database}/README.md +0 -0
- /package/backend/{lib/database → database}/index.ts +0 -0
- /package/backend/{lib/database → database}/migrations/001_create_projects_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/002_create_chat_sessions_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/003_create_messages_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/004_create_prompt_templates_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/005_create_settings_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/006_add_user_to_messages.ts +0 -0
- /package/backend/{lib/database → database}/migrations/007_create_stream_states_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/008_create_message_snapshots_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/009_add_delta_snapshot_fields.ts +0 -0
- /package/backend/{lib/database → database}/migrations/010_add_soft_delete_and_branch_support.ts +0 -0
- /package/backend/{lib/database → database}/migrations/011_git_like_commit_graph.ts +0 -0
- /package/backend/{lib/database → database}/migrations/012_add_file_change_statistics.ts +0 -0
- /package/backend/{lib/database → database}/migrations/013_checkpoint_tree_state.ts +0 -0
- /package/backend/{lib/database → database}/migrations/014_add_engine_to_sessions.ts +0 -0
- /package/backend/{lib/database → database}/migrations/015_add_model_to_sessions.ts +0 -0
- /package/backend/{lib/database → database}/migrations/016_create_user_projects_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/017_add_current_session_to_user_projects.ts +0 -0
- /package/backend/{lib/database → database}/migrations/018_create_claude_accounts_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/019_add_claude_account_to_sessions.ts +0 -0
- /package/backend/{lib/database → database}/migrations/020_add_snapshot_tree_hash.ts +0 -0
- /package/backend/{lib/database → database}/migrations/021_drop_prompt_templates_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/022_add_snapshot_changes_column.ts +0 -0
- /package/backend/{lib/database → database}/migrations/023_create_user_unread_sessions_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/024_create_users_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/025_create_auth_sessions_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/026_create_invite_tokens_table.ts +0 -0
- /package/backend/{lib/database → database}/migrations/index.ts +0 -0
- /package/backend/{lib/database → database}/queries/auth-queries.ts +0 -0
- /package/backend/{lib/database → database}/queries/checkpoint-queries.ts +0 -0
- /package/backend/{lib/database → database}/queries/engine-queries.ts +0 -0
- /package/backend/{lib/database → database}/queries/index.ts +0 -0
- /package/backend/{lib/database → database}/queries/project-queries.ts +0 -0
- /package/backend/{lib/database → database}/queries/session-queries.ts +0 -0
- /package/backend/{lib/database → database}/queries/settings-queries.ts +0 -0
- /package/backend/{lib/database → database}/queries/snapshot-queries.ts +0 -0
- /package/backend/{lib/database → database}/queries/utils-queries.ts +0 -0
- /package/backend/{lib/database → database}/seeders/index.ts +0 -0
- /package/backend/{lib/database → database}/seeders/settings_seeder.ts +0 -0
- /package/backend/{lib/database → database}/utils/index.ts +0 -0
- /package/backend/{lib/database → database}/utils/migration-runner.ts +0 -0
- /package/backend/{lib/database → database}/utils/seeder-runner.ts +0 -0
- /package/backend/{lib/engine → engine}/adapters/claude/error-handler.ts +0 -0
- /package/backend/{lib/engine → engine}/adapters/claude/index.ts +0 -0
- /package/backend/{lib/engine → engine}/adapters/claude/path-utils.ts +0 -0
- /package/backend/{lib/engine → engine}/adapters/claude/stream.ts +0 -0
- /package/backend/{lib/engine → engine}/adapters/opencode/index.ts +0 -0
- /package/backend/{lib/engine → engine}/adapters/opencode/stream.ts +0 -0
- /package/backend/{lib/engine → engine}/index.ts +0 -0
- /package/backend/{lib/engine → engine}/types.ts +0 -0
- /package/backend/{lib/files → files}/file-operations.ts +0 -0
- /package/backend/{lib/files → files}/file-reading.ts +0 -0
- /package/backend/{lib/files → files}/path-browsing.ts +0 -0
- /package/backend/{lib/git → git}/git-parser.ts +0 -0
- /package/backend/{lib/git → git}/git-service.ts +0 -0
- /package/backend/{lib/mcp → mcp}/index.ts +0 -0
- /package/backend/{lib/mcp → mcp}/project-context.ts +0 -0
- /package/backend/{lib/mcp → mcp}/remote-server.ts +0 -0
- /package/backend/{lib/mcp → mcp}/servers/browser-automation/index.ts +0 -0
- /package/backend/{lib/mcp → mcp}/servers/helper.ts +0 -0
- /package/backend/{lib/mcp → mcp}/servers/index.ts +0 -0
- /package/backend/{lib/mcp → mcp}/servers/weather/get-temperature.ts +0 -0
- /package/backend/{lib/mcp → mcp}/servers/weather/index.ts +0 -0
- /package/backend/{lib/mcp → mcp}/types.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/browser-audio-capture.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/browser-console-manager.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/browser-dialog-handler.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/browser-interaction-handler.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/browser-mcp-control.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/browser-native-ui-handler.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/browser-navigation-tracker.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/browser-pool.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/browser-video-capture.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/scripts/audio-stream.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/scripts/cursor-tracking.ts +0 -0
- /package/backend/{lib/preview → preview}/browser/scripts/video-stream.ts +0 -0
- /package/backend/{lib/preview → preview}/index.ts +0 -0
- /package/backend/{lib/project → project}/index.ts +0 -0
- /package/backend/{lib/snapshot → snapshot}/gitignore.ts +0 -0
- /package/backend/{lib/snapshot → snapshot}/helpers.ts +0 -0
- /package/backend/{lib/snapshot → snapshot}/snapshot-service.ts +0 -0
- /package/backend/{lib/terminal → terminal}/helpers.ts +0 -0
- /package/backend/{lib/terminal → terminal}/index.ts +0 -0
- /package/backend/{lib/terminal → terminal}/pty-manager.ts +0 -0
- /package/backend/{lib/terminal → terminal}/pty-session-manager.ts +0 -0
- /package/backend/{lib/terminal → terminal}/stream-manager.ts +0 -0
- /package/backend/{lib/tunnel → tunnel}/global-tunnel-manager.ts +0 -0
- /package/backend/{lib/tunnel → tunnel}/project-tunnel-manager.ts +0 -0
- /package/backend/{lib/shared → utils}/process-manager.ts +0 -0
- /package/backend/{lib/user/helpers.ts → utils/user-helpers.ts} +0 -0
- /package/frontend/{lib/app-environment.ts → app-environment.ts} +0 -0
- /package/frontend/{lib/components → components}/chat/formatters/index.ts +0 -0
- /package/frontend/{lib/components → components}/chat/input/components/DragDropOverlay.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/input/composables/use-animations.svelte.ts +0 -0
- /package/frontend/{lib/components → components}/chat/input/composables/use-textarea-resize.svelte.ts +0 -0
- /package/frontend/{lib/components → components}/chat/message/DateSeparator.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/shared/index.ts +0 -0
- /package/frontend/{lib/components → components}/chat/shared/utils.ts +0 -0
- /package/frontend/{lib/components → components}/chat/tools/AgentTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/BashOutputTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/BashTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/EnterPlanModeTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/ExitPlanModeTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/GlobTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/GrepTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/ListMcpResourcesTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/NotebookEditTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/ReadMcpResourceTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/ReadTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/TaskStopTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/TaskTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/WebFetchTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/WebSearchTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/WriteTool.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/components/StatsBadges.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/components/TerminalCommand.svelte +0 -0
- /package/frontend/{lib/components → components}/chat/tools/components/index.ts +0 -0
- /package/frontend/{lib/components → components}/chat/tools/index.ts +0 -0
- /package/frontend/{lib/components → components}/checkpoint/timeline/TimelineEdge.svelte +0 -0
- /package/frontend/{lib/components → components}/checkpoint/timeline/TimelineGraph.svelte +0 -0
- /package/frontend/{lib/components → components}/checkpoint/timeline/TimelineVersionGroup.svelte +0 -0
- /package/frontend/{lib/components → components}/checkpoint/timeline/animation.ts +0 -0
- /package/frontend/{lib/components → components}/checkpoint/timeline/config.ts +0 -0
- /package/frontend/{lib/components → components}/checkpoint/timeline/graph-builder.ts +0 -0
- /package/frontend/{lib/components → components}/checkpoint/timeline/types.ts +0 -0
- /package/frontend/{lib/components → components}/checkpoint/timeline/utils.ts +0 -0
- /package/frontend/{lib/components/common → components/common/display}/AvatarBubble.svelte +0 -0
- /package/frontend/{lib/components/common → components/common/display}/Button.svelte +0 -0
- /package/frontend/{lib/components/common → components/common/display}/Card.svelte +0 -0
- /package/frontend/{lib/components/common → components/common/feedback}/LoadingSpinner.svelte +0 -0
- /package/frontend/{lib/components → components}/common/lucide-icons.ts +0 -0
- /package/frontend/{lib/components → components}/common/material-icons.ts +0 -0
- /package/frontend/{lib/components/common → components/common/overlay}/Modal.svelte +0 -0
- /package/frontend/{lib/components → components}/common/xterm/index.ts +0 -0
- /package/frontend/{lib/components → components}/common/xterm/terminal-config.ts +0 -0
- /package/frontend/{lib/components → components}/common/xterm/types.ts +0 -0
- /package/frontend/{lib/components → components}/preview/browser/components/VirtualCursor.svelte +0 -0
- /package/frontend/{lib/components → components}/preview/browser/core/stream-handler.svelte.ts +0 -0
- /package/frontend/{lib/components → components}/preview/index.ts +0 -0
- /package/frontend/{lib/components → components}/settings/account/AccountSettings.svelte +0 -0
- /package/frontend/{lib/components → components}/settings/general/GeneralSettings.svelte +0 -0
- /package/frontend/{lib/components → components}/settings/security/SecuritySettings.svelte +0 -0
- /package/frontend/{lib/components → components}/settings/system/SystemSettings.svelte +0 -0
- /package/frontend/{lib/components → components}/tunnel/TunnelQRCode.svelte +0 -0
- /package/frontend/{lib/services → services}/chat/index.ts +0 -0
- /package/frontend/{lib/services → services}/notification/index.ts +0 -0
- /package/frontend/{lib/services → services}/preview/index.ts +0 -0
- /package/frontend/{lib/services → services}/project/index.ts +0 -0
- /package/frontend/{lib/services → services}/terminal/index.ts +0 -0
- /package/frontend/{lib/services → services}/terminal/persistence.service.ts +0 -0
- /package/frontend/{lib/services → services}/terminal/session.service.ts +0 -0
- /package/frontend/{lib/stores → stores}/core/files.svelte.ts +0 -0
- /package/frontend/{lib/stores → stores}/ui/chat-input.svelte.ts +0 -0
- /package/frontend/{lib/stores → stores}/ui/chat-model.svelte.ts +0 -0
- /package/frontend/{lib/stores → stores}/ui/connection.svelte.ts +0 -0
- /package/frontend/{lib/stores → stores}/ui/dialog.svelte.ts +0 -0
- /package/frontend/{lib/stores → stores}/ui/notification.svelte.ts +0 -0
- /package/frontend/{lib/stores → stores}/ui/settings-modal.svelte.ts +0 -0
- /package/frontend/{lib/stores → stores}/ui/theme.svelte.ts +0 -0
- /package/frontend/{lib/stores → stores}/ui/workspace.svelte.ts +0 -0
- /package/frontend/{lib/utils → utils}/chat/date-separator.ts +0 -0
- /package/frontend/{lib/utils → utils}/chat/message-grouper.ts +0 -0
- /package/frontend/{lib/utils → utils}/chat/message-processor.ts +0 -0
- /package/frontend/{lib/utils → utils}/chat/tool-handler.ts +0 -0
- /package/frontend/{lib/utils → utils}/chat/virtual-scroll.svelte.ts +0 -0
- /package/frontend/{lib/utils → utils}/click-outside.ts +0 -0
- /package/frontend/{lib/utils → utils}/context-manager.ts +0 -0
- /package/frontend/{lib/utils → utils}/file-icon-mappings.ts +0 -0
- /package/frontend/{lib/utils → utils}/folder-icon-mappings.ts +0 -0
- /package/frontend/{lib/utils → utils}/git-status.ts +0 -0
- /package/frontend/{lib/types → utils}/native-ui.ts +0 -0
- /package/frontend/{lib/utils → utils}/platform.ts +0 -0
- /package/frontend/{lib/utils → utils}/port-check.ts +0 -0
- /package/frontend/{lib/constants/preview.ts → utils/preview-constants.ts} +0 -0
- /package/frontend/{lib/utils/terminalFormatter.ts → utils/terminal-formatter.ts} +0 -0
- /package/frontend/{lib/utils → utils}/tree-visualizer.ts +0 -0
package/.env.example
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
# Node Environment (development | production)
|
|
2
|
-
NODE_ENV=production
|
|
3
|
-
|
|
4
1
|
# Server configuration
|
|
5
2
|
HOST=localhost
|
|
6
3
|
|
|
@@ -8,5 +5,5 @@ HOST=localhost
|
|
|
8
5
|
PORT=9141
|
|
9
6
|
|
|
10
7
|
# Development ports (two ports — Vite proxies to Elysia)
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
PORT_FRONTEND=9151
|
|
9
|
+
PORT_BACKEND=9161
|
package/CONTRIBUTING.md
CHANGED
|
@@ -22,6 +22,10 @@ bun install
|
|
|
22
22
|
bun run check
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
### Data Directory
|
|
26
|
+
|
|
27
|
+
When running `bun run dev`, Clopen stores data in `~/.clopen-dev` instead of `~/.clopen`. This keeps development data separate from any production instance — especially important since Clopen can be used to develop itself.
|
|
28
|
+
|
|
25
29
|
### Keep Updated
|
|
26
30
|
|
|
27
31
|
```bash
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
|
-
- **Multi-Account Claude Code** - Manage multiple accounts (personal, work, team) and switch instantly per session, isolated under `~/.clopen/claude/user/` without touching system-level Claude config
|
|
12
|
+
- **Multi-Account Claude Code** - Manage multiple accounts (personal, work, team) and switch instantly per session, isolated under `~/.clopen/claude/user/` (or `~/.clopen-dev/` in development) without touching system-level Claude config
|
|
13
13
|
- **Multi-Engine Support** - Switch between Claude Code and OpenCode
|
|
14
14
|
- **AI Chat Interface** - Streaming responses with tool use visualization
|
|
15
15
|
- **Background Processing** - Chat, terminal, and other processes continue running even when you close the browser — come back later and pick up where you left off
|
|
@@ -92,6 +92,8 @@ bun run dev # Start development server
|
|
|
92
92
|
bun run check # Type checking
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
When running in development mode, Clopen uses `~/.clopen-dev` instead of `~/.clopen`, keeping dev data separate from any production instance.
|
|
96
|
+
|
|
95
97
|
---
|
|
96
98
|
|
|
97
99
|
## Architecture
|
|
@@ -123,7 +125,7 @@ Clopen uses an engine-agnostic adapter pattern — both engines normalize output
|
|
|
123
125
|
### Port 9141 Already in Use
|
|
124
126
|
|
|
125
127
|
```bash
|
|
126
|
-
clopen --port
|
|
128
|
+
clopen --port 9145
|
|
127
129
|
```
|
|
128
130
|
|
|
129
131
|
Or kill the existing process:
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Core authentication logic: user creation, session management, invite handling.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { authQueries, settingsQueries } from '$backend/
|
|
7
|
+
import { authQueries, settingsQueries } from '$backend/database/queries';
|
|
8
8
|
import { generateSessionToken, generatePAT, generateInviteToken, hashToken, getTokenType } from './tokens';
|
|
9
|
-
import { generateColorFromString, getInitials } from '$backend/
|
|
9
|
+
import { generateColorFromString, getInitials } from '$backend/utils/user-helpers';
|
|
10
10
|
import { debug } from '$shared/utils/logger';
|
|
11
11
|
|
|
12
12
|
/** Default session lifetime in days */
|
|
@@ -1097,7 +1097,7 @@ class StreamManager extends EventEmitter {
|
|
|
1097
1097
|
// Update checkpoint_tree_state when saving a new checkpoint (real user message)
|
|
1098
1098
|
if (message.type === 'user') {
|
|
1099
1099
|
try {
|
|
1100
|
-
const { isCheckpointMessage, buildCheckpointTree, getCheckpointPathToRoot } = await import('
|
|
1100
|
+
const { isCheckpointMessage, buildCheckpointTree, getCheckpointPathToRoot } = await import('../snapshot/helpers');
|
|
1101
1101
|
const { checkpointQueries } = await import('../database/queries');
|
|
1102
1102
|
|
|
1103
1103
|
// Check if this new message is a checkpoint
|
|
@@ -42,6 +42,48 @@ export const messageQueries = {
|
|
|
42
42
|
});
|
|
43
43
|
},
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Get minimal preview data for a session: first user msg, last assistant msg, and counts.
|
|
47
|
+
* Used by the Sessions/History modal to avoid loading all messages.
|
|
48
|
+
*/
|
|
49
|
+
getSessionPreview(sessionId: string): {
|
|
50
|
+
firstUserMessage: DatabaseMessage | null;
|
|
51
|
+
lastAssistantMessage: DatabaseMessage | null;
|
|
52
|
+
userCount: number;
|
|
53
|
+
assistantCount: number;
|
|
54
|
+
} {
|
|
55
|
+
const db = getDatabase();
|
|
56
|
+
|
|
57
|
+
const firstUserMessage = db.prepare(`
|
|
58
|
+
SELECT * FROM messages
|
|
59
|
+
WHERE session_id = ? AND json_extract(sdk_message, '$.type') = 'user'
|
|
60
|
+
ORDER BY timestamp ASC
|
|
61
|
+
LIMIT 1
|
|
62
|
+
`).get(sessionId) as DatabaseMessage | null;
|
|
63
|
+
|
|
64
|
+
const lastAssistantMessage = db.prepare(`
|
|
65
|
+
SELECT * FROM messages
|
|
66
|
+
WHERE session_id = ? AND json_extract(sdk_message, '$.type') = 'assistant'
|
|
67
|
+
ORDER BY timestamp DESC
|
|
68
|
+
LIMIT 1
|
|
69
|
+
`).get(sessionId) as DatabaseMessage | null;
|
|
70
|
+
|
|
71
|
+
const counts = db.prepare(`
|
|
72
|
+
SELECT
|
|
73
|
+
SUM(CASE WHEN json_extract(sdk_message, '$.type') = 'user' THEN 1 ELSE 0 END) AS user_count,
|
|
74
|
+
SUM(CASE WHEN json_extract(sdk_message, '$.type') = 'assistant' THEN 1 ELSE 0 END) AS assistant_count
|
|
75
|
+
FROM messages
|
|
76
|
+
WHERE session_id = ?
|
|
77
|
+
`).get(sessionId) as { user_count: number; assistant_count: number } | null;
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
firstUserMessage,
|
|
81
|
+
lastAssistantMessage,
|
|
82
|
+
userCount: counts?.user_count ?? 0,
|
|
83
|
+
assistantCount: counts?.assistant_count ?? 0
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
|
|
45
87
|
/**
|
|
46
88
|
* Get all messages for a session including deleted ones (for timeline view)
|
|
47
89
|
*/
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
-
import { homedir } from 'os';
|
|
3
2
|
import { Database } from 'bun:sqlite';
|
|
4
3
|
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
5
4
|
|
|
6
5
|
import { debug } from '$shared/utils/logger';
|
|
6
|
+
import { getClopenDir } from '../../utils/index.js';
|
|
7
|
+
|
|
7
8
|
export class DatabaseManager {
|
|
8
9
|
private static instance: DatabaseManager | null = null;
|
|
9
10
|
private db: DatabaseConnection | null = null;
|
|
10
11
|
private readonly dbPath: string;
|
|
11
12
|
|
|
12
13
|
private constructor() {
|
|
13
|
-
|
|
14
|
-
this.dbPath = join(clopenDir, 'app.db');
|
|
14
|
+
this.dbPath = join(getClopenDir(), 'app.db');
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
static getInstance(): DatabaseManager {
|
|
@@ -29,8 +29,8 @@ export class DatabaseManager {
|
|
|
29
29
|
debug.log('database', '🔗 Connecting to database...');
|
|
30
30
|
|
|
31
31
|
try {
|
|
32
|
-
// Create
|
|
33
|
-
const clopenDir =
|
|
32
|
+
// Create clopen directory if it doesn't exist
|
|
33
|
+
const clopenDir = getClopenDir();
|
|
34
34
|
const dirFile = Bun.file(clopenDir);
|
|
35
35
|
|
|
36
36
|
// Check if directory exists, if not create it
|
|
@@ -7,22 +7,21 @@
|
|
|
7
7
|
* stream concurrently.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { homedir } from 'os';
|
|
11
10
|
import { join } from 'path';
|
|
12
11
|
import { isWindows, findGitBash } from '../../../terminal/shell-utils.js';
|
|
13
12
|
import { engineQueries } from '../../../database/queries';
|
|
14
13
|
import { debug } from '$shared/utils/logger';
|
|
15
|
-
import { getCleanSpawnEnv } from '../../../
|
|
14
|
+
import { getCleanSpawnEnv, getClopenDir } from '../../../utils/index.js';
|
|
16
15
|
|
|
17
16
|
let _ready = false;
|
|
18
17
|
let _initPromise: Promise<void> | null = null;
|
|
19
18
|
let _envOverrides: Record<string, string> = {};
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
|
-
* Returns the isolated Claude config directory under
|
|
21
|
+
* Returns the isolated Claude config directory under {clopenDir}/claude/user/
|
|
23
22
|
*/
|
|
24
23
|
export function getClaudeUserConfigDir(): string {
|
|
25
|
-
return join(
|
|
24
|
+
return join(getClopenDir(), 'claude', 'user');
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
/**
|
|
@@ -141,7 +141,7 @@ const TOOL_NAME_MAP: Record<string, string> = {
|
|
|
141
141
|
|
|
142
142
|
/** Map Open Code tool name to Claude Code tool name for UI rendering */
|
|
143
143
|
export function mapToolName(openCodeToolName: string): string {
|
|
144
|
-
// Check if this is a custom MCP tool (resolves via single source in backend/
|
|
144
|
+
// Check if this is a custom MCP tool (resolves via single source in backend/mcp)
|
|
145
145
|
const mcpName = resolveOpenCodeToolName(openCodeToolName);
|
|
146
146
|
if (mcpName) return mcpName;
|
|
147
147
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import type { OpencodeClient } from '@opencode-ai/sdk';
|
|
12
12
|
import { getOpenCodeMcpConfig } from '../../../mcp';
|
|
13
13
|
import { debug } from '$shared/utils/logger';
|
|
14
|
+
import { findAvailablePort } from '../../../utils/port-utils';
|
|
14
15
|
|
|
15
16
|
const OPENCODE_PORT = 4096;
|
|
16
17
|
const OPENCODE_HOST = '127.0.0.1';
|
|
@@ -58,9 +59,14 @@ async function init(): Promise<void> {
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
const actualPort = await findAvailablePort(OPENCODE_PORT);
|
|
63
|
+
if (actualPort !== OPENCODE_PORT) {
|
|
64
|
+
debug.log('engine', `Open Code port ${OPENCODE_PORT} in use, using ${actualPort} instead`);
|
|
65
|
+
}
|
|
66
|
+
|
|
61
67
|
const result = await createOpencode({
|
|
62
68
|
hostname: OPENCODE_HOST,
|
|
63
|
-
port:
|
|
69
|
+
port: actualPort,
|
|
64
70
|
...(Object.keys(mcpConfig).length > 0 && {
|
|
65
71
|
config: { mcp: mcpConfig },
|
|
66
72
|
}),
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { watch, type FSWatcher, existsSync } from 'node:fs';
|
|
13
13
|
import { stat } from 'node:fs/promises';
|
|
14
14
|
import { join, relative, normalize, sep } from 'node:path';
|
|
15
|
-
import { ws } from '$backend/
|
|
15
|
+
import { ws } from '$backend/utils/ws';
|
|
16
16
|
import { debug } from '$shared/utils/logger';
|
|
17
17
|
import type { FileChange } from '$shared/types/filesystem';
|
|
18
18
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { debug } from '$shared/utils/logger';
|
|
7
|
-
import { getCleanSpawnEnv } from '../
|
|
7
|
+
import { getCleanSpawnEnv } from '../utils/env';
|
|
8
8
|
|
|
9
9
|
export interface GitExecResult {
|
|
10
10
|
stdout: string;
|
|
@@ -22,7 +22,8 @@ export async function execGit(
|
|
|
22
22
|
): Promise<GitExecResult> {
|
|
23
23
|
debug.log('git', `Executing: git ${args.join(' ')} in ${cwd}`);
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const safeCwd = cwd.replace(/\\/g, '/');
|
|
26
|
+
const proc = Bun.spawn(['git', '-c', `safe.directory=${safeCwd}`, ...args], {
|
|
26
27
|
cwd,
|
|
27
28
|
stdout: 'pipe',
|
|
28
29
|
stderr: 'pipe',
|
package/backend/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ if (typeof globalThis.Bun === 'undefined') {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
// MUST be first import — cleans process.env before any other module reads it
|
|
12
|
-
import { SERVER_ENV } from './
|
|
12
|
+
import { SERVER_ENV } from './utils/env';
|
|
13
13
|
|
|
14
14
|
import { Elysia } from 'elysia';
|
|
15
15
|
import { corsMiddleware } from './middleware/cors';
|
|
@@ -17,10 +17,9 @@ import { errorHandlerMiddleware } from './middleware/error-handler';
|
|
|
17
17
|
import { loggerMiddleware } from './middleware/logger';
|
|
18
18
|
|
|
19
19
|
// Database initialization
|
|
20
|
-
import { initializeDatabase, closeDatabase } from './
|
|
21
|
-
import { disposeAllEngines } from './
|
|
20
|
+
import { initializeDatabase, closeDatabase } from './database';
|
|
21
|
+
import { disposeAllEngines } from './engine';
|
|
22
22
|
import { debug } from '$shared/utils/logger';
|
|
23
|
-
import { findAvailablePort } from './lib/shared/port-utils';
|
|
24
23
|
import { networkInterfaces } from 'os';
|
|
25
24
|
import { resolve } from 'node:path';
|
|
26
25
|
import { statSync } from 'node:fs';
|
|
@@ -29,11 +28,11 @@ import { statSync } from 'node:fs';
|
|
|
29
28
|
import { wsRouter } from './ws';
|
|
30
29
|
|
|
31
30
|
// MCP remote server for Open Code custom tools
|
|
32
|
-
import { handleMcpRequest, closeMcpServer } from './
|
|
31
|
+
import { handleMcpRequest, closeMcpServer } from './mcp/remote-server';
|
|
33
32
|
|
|
34
33
|
// Auth middleware
|
|
35
|
-
import { checkRouteAccess } from './
|
|
36
|
-
import { ws as wsServer } from './
|
|
34
|
+
import { checkRouteAccess } from './auth/permissions';
|
|
35
|
+
import { ws as wsServer } from './utils/ws';
|
|
37
36
|
|
|
38
37
|
// Register auth gate on WebSocket router — blocks unauthenticated/unauthorized access
|
|
39
38
|
wsRouter.setAuthMiddleware(async (conn, action) => {
|
|
@@ -45,7 +44,7 @@ wsRouter.setAuthMiddleware(async (conn, action) => {
|
|
|
45
44
|
/**
|
|
46
45
|
* Clopen - Elysia Backend Server
|
|
47
46
|
*
|
|
48
|
-
* Development: Elysia runs on port
|
|
47
|
+
* Development: Elysia runs on port 9161, Vite dev server proxies /api and /ws from port 9151
|
|
49
48
|
* Production: Elysia runs on port 9141, serves static files from dist/ + API + WebSocket
|
|
50
49
|
*/
|
|
51
50
|
|
|
@@ -117,11 +116,12 @@ if (!isDevelopment) {
|
|
|
117
116
|
|
|
118
117
|
// Start server with proper initialization sequence
|
|
119
118
|
async function startServer() {
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
// Port resolution is handled by the caller:
|
|
120
|
+
// - Development: scripts/dev.ts resolves ports and passes via PORT_BACKEND env
|
|
121
|
+
// - Production: scripts/start.ts resolves port and passes via PORT env
|
|
122
|
+
// - CLI: bin/clopen.ts resolves port and passes via PORT env
|
|
123
|
+
// This avoids double port-check race conditions (e.g. zombie processes on
|
|
124
|
+
// Windows causing silent desync between Vite proxy and backend).
|
|
125
125
|
|
|
126
126
|
// Initialize database first before accepting connections
|
|
127
127
|
try {
|
|
@@ -133,18 +133,18 @@ async function startServer() {
|
|
|
133
133
|
|
|
134
134
|
// Start listening after database is ready
|
|
135
135
|
app.listen({
|
|
136
|
-
port:
|
|
136
|
+
port: PORT,
|
|
137
137
|
hostname: HOST
|
|
138
138
|
}, () => {
|
|
139
139
|
if (isDevelopment) {
|
|
140
140
|
console.log('🚀 Backend ready — waiting for frontend...');
|
|
141
141
|
} else {
|
|
142
|
-
console.log(`🚀 Clopen running at http://localhost:${
|
|
142
|
+
console.log(`🚀 Clopen running at http://localhost:${PORT}`);
|
|
143
143
|
}
|
|
144
144
|
if (HOST === '0.0.0.0') {
|
|
145
145
|
const ips = getLocalIps();
|
|
146
146
|
for (const ip of ips) {
|
|
147
|
-
console.log(`🌐 Network access: http://${ip}:${
|
|
147
|
+
console.log(`🌐 Network access: http://${ip}:${PORT}`);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
});
|