khal-os 1.260324.2
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/.env.example +23 -0
- package/.genie/mailbox/cli-sent.jsonl +3 -0
- package/.genie/mailbox/ds1-wave2-engineer-1.json +15 -0
- package/.genie/mailbox/ds1-wave2-engineer-2.json +15 -0
- package/.genie/mailbox/ds1-wave2-engineer-3.json +15 -0
- package/.genie/state/os-observability.json +39 -0
- package/.genie/state/tmux-control-mode-terminal.json +28 -0
- package/.genie/wishes/genieos-one-theme/WISH.md +417 -0
- package/.genie/wishes/workos-prod-rbac/WISH.md +345 -0
- package/.github/workflows/ci.yml +39 -0
- package/.github/workflows/release.yml +78 -0
- package/.github/workflows/version.yml +122 -0
- package/.husky/pre-commit +1 -0
- package/.pnpm-approve-builds.json +1 -0
- package/CLAUDE.md +117 -0
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/biome.json +124 -0
- package/bun.lock +1249 -0
- package/docs/workos-setup.md +116 -0
- package/ecosystem.config.cjs +26 -0
- package/instrumentation.ts +8 -0
- package/knip.json +35 -0
- package/nats.conf +7 -0
- package/next.config.ts +25 -0
- package/package.json +78 -0
- package/packages/dev3000-app/components.ts +12 -0
- package/packages/dev3000-app/manifest.ts +19 -0
- package/packages/dev3000-app/package.json +23 -0
- package/packages/dev3000-app/views/dev3000/Dev3000App.tsx +758 -0
- package/packages/dev3000-app/views/dev3000/ErrorsPanel.tsx +160 -0
- package/packages/dev3000-app/views/dev3000/dev3000-context.tsx +21 -0
- package/packages/dev3000-app/views/dev3000/index.ts +4 -0
- package/packages/dev3000-app/views/dev3000/schema.ts +55 -0
- package/packages/dev3000-app/views/dev3000/service/index.ts +358 -0
- package/packages/dev3000-app/views/dev3000/service/runtime +1 -0
- package/packages/dev3000-app/views/dev3000/subjects.ts +9 -0
- package/packages/dev3000-app/views/dev3000/types.ts +77 -0
- package/packages/files-app/components.ts +12 -0
- package/packages/files-app/manifest.ts +19 -0
- package/packages/files-app/package.json +23 -0
- package/packages/files-app/views/files/ContextMenu.tsx +151 -0
- package/packages/files-app/views/files/DeleteConfirmDialog.tsx +39 -0
- package/packages/files-app/views/files/FileItem.tsx +128 -0
- package/packages/files-app/views/files/FilesApp.tsx +509 -0
- package/packages/files-app/views/files/FilesListView.tsx +201 -0
- package/packages/files-app/views/files/FilesToolbar.tsx +117 -0
- package/packages/files-app/views/files/GridView.tsx +90 -0
- package/packages/files-app/views/files/InlineInput.tsx +131 -0
- package/packages/files-app/views/files/UploadOverlay.tsx +61 -0
- package/packages/files-app/views/files/schema.ts +49 -0
- package/packages/files-app/views/files/service/index.ts +184 -0
- package/packages/files-app/views/files/service/runtime +1 -0
- package/packages/files-app/views/files/use-files.ts +201 -0
- package/packages/files-app/views/files/use-upload.ts +105 -0
- package/packages/genie-app/components.ts +12 -0
- package/packages/genie-app/lib/subjects.ts +87 -0
- package/packages/genie-app/manifest.ts +19 -0
- package/packages/genie-app/package.json +29 -0
- package/packages/genie-app/views/genie/service/agent-lifecycle.ts +136 -0
- package/packages/genie-app/views/genie/service/cli.ts +114 -0
- package/packages/genie-app/views/genie/service/comms.ts +141 -0
- package/packages/genie-app/views/genie/service/directory.ts +167 -0
- package/packages/genie-app/views/genie/service/index.ts +219 -0
- package/packages/genie-app/views/genie/service/system.ts +123 -0
- package/packages/genie-app/views/genie/service/teams.ts +191 -0
- package/packages/genie-app/views/genie/service/terminal-proxy.ts +184 -0
- package/packages/genie-app/views/genie/service/tmux-control.ts +318 -0
- package/packages/genie-app/views/genie/service/wishes.ts +270 -0
- package/packages/genie-app/views/genie/ui/GenieApp.tsx +5 -0
- package/packages/genie-app/views/genie/ui/PaneCard.tsx +307 -0
- package/packages/genie-app/views/genie/ui/Sidebar.tsx +212 -0
- package/packages/genie-app/views/genie/ui/TabBar.tsx +70 -0
- package/packages/genie-app/views/genie/ui/WorkspaceCanvas.tsx +343 -0
- package/packages/genie-app/views/genie/ui/XTermPane.tsx +306 -0
- package/packages/genie-app/views/genie/ui/hooks/useNatsAction.ts +54 -0
- package/packages/genie-app/views/genie/ui/hooks/useNatsRequest.ts +68 -0
- package/packages/genie-app/views/genie/ui/panels/AgentsPanel.tsx +399 -0
- package/packages/genie-app/views/genie/ui/panels/ChatPanel.tsx +351 -0
- package/packages/genie-app/views/genie/ui/panels/SystemPanel.tsx +195 -0
- package/packages/genie-app/views/genie/ui/panels/TeamsPanel.tsx +560 -0
- package/packages/genie-app/views/genie/ui/panels/WishesPanel.tsx +424 -0
- package/packages/nats-viewer-app/components.ts +12 -0
- package/packages/nats-viewer-app/manifest.ts +18 -0
- package/packages/nats-viewer-app/package.json +14 -0
- package/packages/nats-viewer-app/views/nats-viewer/ActiveSubs.tsx +34 -0
- package/packages/nats-viewer-app/views/nats-viewer/MessageLog.tsx +247 -0
- package/packages/nats-viewer-app/views/nats-viewer/NatsViewer.tsx +209 -0
- package/packages/nats-viewer-app/views/nats-viewer/PublishPanel.tsx +111 -0
- package/packages/nats-viewer-app/views/nats-viewer/RequestPanel.tsx +165 -0
- package/packages/nats-viewer-app/views/nats-viewer/Sidebar.tsx +59 -0
- package/packages/nats-viewer-app/views/nats-viewer/SubjectCatalog.tsx +63 -0
- package/packages/nats-viewer-app/views/nats-viewer/SubscribeInput.tsx +59 -0
- package/packages/nats-viewer-app/views/nats-viewer/index.ts +5 -0
- package/packages/nats-viewer-app/views/nats-viewer/nats-viewer-context.tsx +31 -0
- package/packages/nats-viewer-app/views/nats-viewer/types.ts +7 -0
- package/packages/nats-viewer-app/views/nats-viewer/use-message-buffer.ts +55 -0
- package/packages/os-cli/package.json +18 -0
- package/packages/os-cli/src/commands/events.ts +176 -0
- package/packages/os-cli/src/commands/logs.ts +96 -0
- package/packages/os-cli/src/commands/status.ts +53 -0
- package/packages/os-cli/src/commands/traces.ts +115 -0
- package/packages/os-cli/src/index.ts +15 -0
- package/packages/os-cli/src/lib/formatter.ts +123 -0
- package/packages/os-cli/src/lib/nats.ts +16 -0
- package/packages/os-cli/src/lib/trace-tree.ts +144 -0
- package/packages/os-cli/tsconfig.json +12 -0
- package/packages/os-sdk/package.json +27 -0
- package/packages/os-sdk/src/api/handler.ts +67 -0
- package/packages/os-sdk/src/config.ts +68 -0
- package/packages/os-sdk/src/db/factory.test.ts +42 -0
- package/packages/os-sdk/src/db/factory.ts +72 -0
- package/packages/os-sdk/src/db/migrate.ts +140 -0
- package/packages/os-sdk/src/db/provision.ts +44 -0
- package/packages/os-sdk/src/index.ts +36 -0
- package/packages/os-sdk/src/service/console-intercept.ts +60 -0
- package/packages/os-sdk/src/service/logger.ts +88 -0
- package/packages/os-sdk/src/service/o11y-streams.ts +88 -0
- package/packages/os-sdk/src/service/runtime.ts +259 -0
- package/packages/os-sdk/src/service/trace.ts +71 -0
- package/packages/os-sdk/tsconfig.json +16 -0
- package/packages/os-ui/package.json +13 -0
- package/packages/os-ui/src/index.ts +29 -0
- package/packages/os-ui/src/server.ts +4 -0
- package/packages/os-ui/tsconfig.json +19 -0
- package/packages/settings-app/components.ts +12 -0
- package/packages/settings-app/manifest.ts +18 -0
- package/packages/settings-app/package.json +14 -0
- package/packages/settings-app/views/settings/Settings.tsx +492 -0
- package/packages/terminal-app/components.ts +12 -0
- package/packages/terminal-app/manifest.ts +20 -0
- package/packages/terminal-app/package.json +23 -0
- package/packages/terminal-app/views/terminal/schema.ts +82 -0
- package/packages/terminal-app/views/terminal/service/index.ts +133 -0
- package/packages/terminal-app/views/terminal/service/runtime +1 -0
- package/packages/terminal-app/views/terminal/service/session.ts +290 -0
- package/packages/terminal-app/views/terminal/service/shell-hooks/bashrc-hook.sh +21 -0
- package/packages/terminal-app/views/terminal/types.ts +26 -0
- package/packages/terminal-app/views/terminal/ui/MultiTerminalApp.tsx +615 -0
- package/packages/terminal-app/views/terminal/ui/SplitDragHandle.tsx +91 -0
- package/packages/terminal-app/views/terminal/ui/SplitPaneRenderer.tsx +112 -0
- package/packages/terminal-app/views/terminal/ui/TerminalPane.tsx +478 -0
- package/packages/terminal-app/views/terminal/ui/TerminalTabBar.tsx +131 -0
- package/pnpm-workspace.yaml +9 -0
- package/postcss.config.mjs +7 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/icons/code-server.svg +6 -0
- package/public/icons/default.svg +5 -0
- package/public/icons/dusk/1password.svg +1 -0
- package/public/icons/dusk/activity_monitor.svg +1 -0
- package/public/icons/dusk/app_store.svg +1 -0
- package/public/icons/dusk/atom.svg +1 -0
- package/public/icons/dusk/brave.svg +1 -0
- package/public/icons/dusk/calculator.svg +1 -0
- package/public/icons/dusk/calendar.svg +1 -0
- package/public/icons/dusk/chrome.svg +1 -0
- package/public/icons/dusk/chrome2.svg +1 -0
- package/public/icons/dusk/dashboard.svg +13 -0
- package/public/icons/dusk/discord.svg +1 -0
- package/public/icons/dusk/dropbox.svg +1 -0
- package/public/icons/dusk/electron.svg +1 -0
- package/public/icons/dusk/figma.svg +1 -0
- package/public/icons/dusk/finder.svg +1 -0
- package/public/icons/dusk/finder2.svg +1 -0
- package/public/icons/dusk/finder3.svg +1 -0
- package/public/icons/dusk/firefox.svg +1 -0
- package/public/icons/dusk/framer.svg +1 -0
- package/public/icons/dusk/gimp.svg +1 -0
- package/public/icons/dusk/github_desktop.svg +1 -0
- package/public/icons/dusk/hyper.svg +1 -0
- package/public/icons/dusk/hyper3.svg +1 -0
- package/public/icons/dusk/intellij.svg +1 -0
- package/public/icons/dusk/iterm2.svg +1 -0
- package/public/icons/dusk/itunes.svg +1 -0
- package/public/icons/dusk/mail.svg +1 -0
- package/public/icons/dusk/messenger.svg +1 -0
- package/public/icons/dusk/mongodb.svg +1 -0
- package/public/icons/dusk/notes.svg +1 -0
- package/public/icons/dusk/notion.svg +1 -0
- package/public/icons/dusk/obs.svg +1 -0
- package/public/icons/dusk/pages.svg +1 -0
- package/public/icons/dusk/photos.svg +1 -0
- package/public/icons/dusk/postman.svg +1 -0
- package/public/icons/dusk/preview.svg +1 -0
- package/public/icons/dusk/reminders.svg +1 -0
- package/public/icons/dusk/safari.svg +1 -0
- package/public/icons/dusk/sequel_pro.svg +1 -0
- package/public/icons/dusk/sketch.svg +1 -0
- package/public/icons/dusk/skype.svg +1 -0
- package/public/icons/dusk/slack.svg +1 -0
- package/public/icons/dusk/slack2.svg +1 -0
- package/public/icons/dusk/spotify.svg +1 -0
- package/public/icons/dusk/steam.svg +1 -0
- package/public/icons/dusk/system_preferences.svg +1 -0
- package/public/icons/dusk/tableplus.svg +1 -0
- package/public/icons/dusk/teams.svg +1 -0
- package/public/icons/dusk/telegram.svg +1 -0
- package/public/icons/dusk/terminal.svg +1 -0
- package/public/icons/dusk/todoist.svg +1 -0
- package/public/icons/dusk/trash.svg +1 -0
- package/public/icons/dusk/trello.svg +1 -0
- package/public/icons/dusk/vivaldi.svg +1 -0
- package/public/icons/dusk/vlc.svg +1 -0
- package/public/icons/dusk/vscode.svg +1 -0
- package/public/icons/dusk/whatsapp.svg +1 -0
- package/public/icons/dusk/xeyes.svg +1 -0
- package/public/icons/dusk/zoom.svg +1 -0
- package/public/icons/files.svg +5 -0
- package/public/icons/pwa/icon-192.png +0 -0
- package/public/icons/pwa/icon-512.png +0 -0
- package/public/icons/settings.svg +14 -0
- package/public/icons/terminal.svg +5 -0
- package/public/icons/text-editor.svg +7 -0
- package/public/manifest.json +38 -0
- package/public/next.svg +1 -0
- package/public/sw.js +41 -0
- package/public/vercel.svg +1 -0
- package/public/wallpapers/default.svg +10 -0
- package/public/window.svg +1 -0
- package/scripts/generate-pwa-icons.mjs +33 -0
- package/scripts/install-nats.sh +37 -0
- package/sentry.client.config.ts +21 -0
- package/sentry.edge.config.ts +12 -0
- package/sentry.server.config.ts +12 -0
- package/src/app/api/files/download/route.ts +81 -0
- package/src/app/api/files/download-zip/route.ts +102 -0
- package/src/app/api/files/upload/route.ts +58 -0
- package/src/app/api/webhooks/workos/route.ts +98 -0
- package/src/app/auth/callback/route.ts +16 -0
- package/src/app/auth/logout/route.ts +15 -0
- package/src/app/desktop/desktop-shell.tsx +110 -0
- package/src/app/desktop/layout.tsx +8 -0
- package/src/app/desktop/page.tsx +24 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +7 -0
- package/src/app/layout.tsx +64 -0
- package/src/app/offline/page.tsx +83 -0
- package/src/app/page.tsx +5 -0
- package/src/app/standalone/[appId]/page.tsx +28 -0
- package/src/app/standalone/layout.tsx +10 -0
- package/src/components/app-icon.tsx +55 -0
- package/src/components/apps/_echo/schema.ts +14 -0
- package/src/components/apps/_echo/service/index.ts +42 -0
- package/src/components/apps/app-manifest.ts +97 -0
- package/src/components/apps/app-registry.ts +55 -0
- package/src/components/apps/dev3000/Dev3000App.tsx +224 -0
- package/src/components/apps/dev3000/ErrorsPanel.tsx +160 -0
- package/src/components/apps/dev3000/Sidebar.tsx +41 -0
- package/src/components/apps/dev3000/TimelineLog.tsx +173 -0
- package/src/components/apps/dev3000/dev3000-context.tsx +29 -0
- package/src/components/apps/dev3000/index.ts +4 -0
- package/src/components/apps/dev3000/schema.ts +48 -0
- package/src/components/apps/dev3000/service/index.ts +520 -0
- package/src/components/apps/dev3000/service/runtime +1 -0
- package/src/components/apps/dev3000/types.ts +15 -0
- package/src/components/apps/dev3000/use-message-buffer.ts +46 -0
- package/src/components/apps/files/ContextMenu.tsx +151 -0
- package/src/components/apps/files/DeleteConfirmDialog.tsx +78 -0
- package/src/components/apps/files/FileItem.tsx +128 -0
- package/src/components/apps/files/FilesApp.tsx +509 -0
- package/src/components/apps/files/FilesListView.tsx +201 -0
- package/src/components/apps/files/FilesToolbar.tsx +117 -0
- package/src/components/apps/files/GridView.tsx +90 -0
- package/src/components/apps/files/InlineInput.tsx +131 -0
- package/src/components/apps/files/UploadOverlay.tsx +61 -0
- package/src/components/apps/files/schema.ts +49 -0
- package/src/components/apps/files/service/index.ts +227 -0
- package/src/components/apps/files/service/runtime +1 -0
- package/src/components/apps/files/use-files.ts +201 -0
- package/src/components/apps/files/use-upload.ts +105 -0
- package/src/components/apps/nats-viewer/ActiveSubs.tsx +34 -0
- package/src/components/apps/nats-viewer/MessageLog.tsx +247 -0
- package/src/components/apps/nats-viewer/NatsViewer.tsx +209 -0
- package/src/components/apps/nats-viewer/PublishPanel.tsx +113 -0
- package/src/components/apps/nats-viewer/RequestPanel.tsx +167 -0
- package/src/components/apps/nats-viewer/Sidebar.tsx +62 -0
- package/src/components/apps/nats-viewer/SubjectCatalog.tsx +64 -0
- package/src/components/apps/nats-viewer/SubscribeInput.tsx +59 -0
- package/src/components/apps/nats-viewer/index.ts +5 -0
- package/src/components/apps/nats-viewer/nats-viewer-context.tsx +31 -0
- package/src/components/apps/nats-viewer/types.ts +7 -0
- package/src/components/apps/nats-viewer/use-message-buffer.ts +55 -0
- package/src/components/apps/settings/Settings.tsx +492 -0
- package/src/components/apps/terminal/schema.ts +82 -0
- package/src/components/apps/terminal/service/index.ts +189 -0
- package/src/components/apps/terminal/service/runtime +1 -0
- package/src/components/apps/terminal/service/session.ts +296 -0
- package/src/components/apps/terminal/service/shell-hooks/bashrc-hook.sh +21 -0
- package/src/components/apps/terminal/types.ts +26 -0
- package/src/components/apps/terminal/ui/MultiTerminalApp.tsx +617 -0
- package/src/components/apps/terminal/ui/SplitDragHandle.tsx +91 -0
- package/src/components/apps/terminal/ui/SplitPaneRenderer.tsx +112 -0
- package/src/components/apps/terminal/ui/TerminalPane.tsx +476 -0
- package/src/components/apps/terminal/ui/TerminalTabBar.tsx +131 -0
- package/src/components/desktop/AnimatedBackground.tsx +69 -0
- package/src/components/desktop/Desktop.tsx +79 -0
- package/src/components/desktop/DesktopBackground.tsx +16 -0
- package/src/components/desktop/DesktopIcon.tsx +49 -0
- package/src/components/desktop/ShortcutViewer.tsx +136 -0
- package/src/components/desktop/WindowRenderer.tsx +34 -0
- package/src/components/desktop/WindowSwitcher.tsx +42 -0
- package/src/components/notifications/NotificationCenter.tsx +153 -0
- package/src/components/notifications/NotificationToasts.tsx +66 -0
- package/src/components/notifications/OrphanSessionToast.tsx +293 -0
- package/src/components/os-primitives/collapsible-sidebar.tsx +226 -0
- package/src/components/os-primitives/dialog.tsx +76 -0
- package/src/components/os-primitives/empty-state.tsx +43 -0
- package/src/components/os-primitives/index.ts +21 -0
- package/src/components/os-primitives/list-view.tsx +155 -0
- package/src/components/os-primitives/property-panel.tsx +108 -0
- package/src/components/os-primitives/section-header.tsx +19 -0
- package/src/components/os-primitives/sidebar-nav.tsx +110 -0
- package/src/components/os-primitives/split-pane.tsx +146 -0
- package/src/components/os-primitives/status-badge.tsx +10 -0
- package/src/components/os-primitives/status-bar.tsx +100 -0
- package/src/components/os-primitives/toolbar.tsx +152 -0
- package/src/components/taskbar/AppLauncher.tsx +114 -0
- package/src/components/taskbar/RunningApps.tsx +71 -0
- package/src/components/taskbar/SystemTray.tsx +134 -0
- package/src/components/taskbar/Taskbar.tsx +45 -0
- package/src/components/taskbar/UserMenu.tsx +138 -0
- package/src/components/taskbar/WorkspaceSwitcher.tsx +9 -0
- package/src/components/ui/ContextMenu.tsx +130 -0
- package/src/components/ui/badge.tsx +39 -0
- package/src/components/ui/button.tsx +102 -0
- package/src/components/ui/command.tsx +165 -0
- package/src/components/ui/dropdown-menu.tsx +233 -0
- package/src/components/ui/input.tsx +48 -0
- package/src/components/ui/note.tsx +55 -0
- package/src/components/ui/separator.tsx +25 -0
- package/src/components/ui/spinner.tsx +42 -0
- package/src/components/ui/switch.tsx +36 -0
- package/src/components/ui/theme-provider.tsx +24 -0
- package/src/components/ui/theme-switcher.tsx +51 -0
- package/src/components/ui/tooltip.tsx +62 -0
- package/src/components/window/MobileWindowStack.tsx +218 -0
- package/src/components/window/SnapPreview.tsx +37 -0
- package/src/components/window/StandaloneFrame.tsx +170 -0
- package/src/components/window/Window.tsx +423 -0
- package/src/components/window/WindowContent.tsx +14 -0
- package/src/components/window/WindowControlsOverlay.tsx +89 -0
- package/src/components/window/WindowFrame.tsx +124 -0
- package/src/lib/auth/index.ts +27 -0
- package/src/lib/auth/roles.ts +50 -0
- package/src/lib/auth/types.ts +32 -0
- package/src/lib/auth/use-auth.ts +53 -0
- package/src/lib/auth/webhook-handler.ts +87 -0
- package/src/lib/auth/workos.ts +67 -0
- package/src/lib/constants.ts +1 -0
- package/src/lib/desktop/dedup.ts +57 -0
- package/src/lib/desktop/schema.ts +55 -0
- package/src/lib/files/filename-validation.ts +41 -0
- package/src/lib/files/safe-path.ts +49 -0
- package/src/lib/hooks/use-desktop-nats.ts +438 -0
- package/src/lib/hooks/use-is-mobile.ts +23 -0
- package/src/lib/hooks/use-launch-app.ts +79 -0
- package/src/lib/hooks/use-nats-notifications.ts +84 -0
- package/src/lib/hooks/use-nats.ts +60 -0
- package/src/lib/hooks/use-visual-viewport.ts +72 -0
- package/src/lib/icons/resolve-window-icon.ts +10 -0
- package/src/lib/keyboard/defaults.ts +146 -0
- package/src/lib/keyboard/types.ts +52 -0
- package/src/lib/keyboard/use-global-keybinds.ts +231 -0
- package/src/lib/nats-client.ts +255 -0
- package/src/lib/nats.ts +35 -0
- package/src/lib/notifications/schema.ts +12 -0
- package/src/lib/service-loader.ts +171 -0
- package/src/lib/subjects.ts +64 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/ws-bridge.ts +288 -0
- package/src/lib/ws-protocol.ts +53 -0
- package/src/lib/ws-server.ts +167 -0
- package/src/middleware.ts +57 -0
- package/src/stores/desktop-store.ts +112 -0
- package/src/stores/keybind-store.ts +66 -0
- package/src/stores/notification-store.ts +271 -0
- package/src/stores/theme-store.ts +25 -0
- package/src/stores/window-store.ts +294 -0
- package/src/theme/animations.css +68 -0
- package/src/theme/base.css +123 -0
- package/src/theme/controls.css +35 -0
- package/src/theme/design-tokens.css +276 -0
- package/src/theme/index.css +23 -0
- package/src/theme/menus.css +45 -0
- package/src/theme/status.css +41 -0
- package/src/theme/surfaces.css +94 -0
- package/src/theme/tailwind-map.css +138 -0
- package/src/theme/taskbar.css +25 -0
- package/src/theme/terminal.css +55 -0
- package/src/theme/typography.css +26 -0
- package/src/theme/utilities.css +156 -0
- package/src/theme/window.css +103 -0
- package/src/types/desktop-entry.ts +12 -0
- package/src/types/use-descendants.d.ts +13 -0
- package/src/types/window.ts +28 -0
- package/src/types.d.ts +9 -0
- package/tauri/Cargo.lock +5464 -0
- package/tauri/Cargo.toml +19 -0
- package/tauri/build.rs +3 -0
- package/tauri/capabilities/default.json +36 -0
- package/tauri/icons/128x128.png +0 -0
- package/tauri/icons/128x128@2x.png +0 -0
- package/tauri/icons/32x32.png +0 -0
- package/tauri/icons/icon.png +0 -0
- package/tauri/src/main.rs +396 -0
- package/tauri/tauri.conf.json +23 -0
- package/tsconfig.json +43 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// NOTE: This component connects to tmux panes via control mode (server-side). It does NOT create proxy sessions. NEVER introduce node-pty, _genie_proxy_*, or linked tmux sessions here.
|
|
3
|
+
|
|
4
|
+
import type { FitAddon } from '@xterm/addon-fit';
|
|
5
|
+
import type { WebglAddon } from '@xterm/addon-webgl';
|
|
6
|
+
import type { Terminal } from '@xterm/xterm';
|
|
7
|
+
import { useEffect, useRef } from 'react';
|
|
8
|
+
import { getNatsClient } from '@/lib/nats-client';
|
|
9
|
+
import { SUBJECTS } from '../../../lib/subjects';
|
|
10
|
+
|
|
11
|
+
function decodeBase64(b64: string): Uint8Array {
|
|
12
|
+
const binary = atob(b64);
|
|
13
|
+
const bytes = new Uint8Array(binary.length);
|
|
14
|
+
for (let i = 0; i < binary.length; i++) {
|
|
15
|
+
bytes[i] = binary.charCodeAt(i);
|
|
16
|
+
}
|
|
17
|
+
return bytes;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface XTermPaneProps {
|
|
21
|
+
tmuxPaneId: string;
|
|
22
|
+
onDisconnect?: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* XTermPane connected to a tmux pane via terminal proxy.
|
|
27
|
+
*
|
|
28
|
+
* Uses a "create guard" ref to prevent StrictMode double-mount from
|
|
29
|
+
* creating duplicate proxy sessions. The proxy session ID is stored
|
|
30
|
+
* in a ref and destroyed synchronously via NATS request on cleanup.
|
|
31
|
+
*/
|
|
32
|
+
export function XTermPane({ tmuxPaneId, onDisconnect }: XTermPaneProps) {
|
|
33
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
34
|
+
const terminalRef = useRef<Terminal | null>(null);
|
|
35
|
+
const fitAddonRef = useRef<FitAddon | null>(null);
|
|
36
|
+
const webglAddonRef = useRef<WebglAddon | null>(null);
|
|
37
|
+
const unsubsRef = useRef<Array<() => void>>([]);
|
|
38
|
+
const lastSentDimsRef = useRef('');
|
|
39
|
+
const resizeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
40
|
+
const settleTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
41
|
+
const onDisconnectRef = useRef(onDisconnect);
|
|
42
|
+
onDisconnectRef.current = onDisconnect;
|
|
43
|
+
|
|
44
|
+
// Guard: track the proxy session across StrictMode mount cycles.
|
|
45
|
+
// This ref persists across unmount→remount and prevents double creation.
|
|
46
|
+
const proxySessionRef = useRef<string | null>(null);
|
|
47
|
+
const createInFlightRef = useRef(false);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
let cancelled = false;
|
|
51
|
+
if (!containerRef.current) return;
|
|
52
|
+
|
|
53
|
+
const client = getNatsClient();
|
|
54
|
+
|
|
55
|
+
(async () => {
|
|
56
|
+
const [xtermMod, fitMod] = await Promise.all([import('@xterm/xterm'), import('@xterm/addon-fit')]);
|
|
57
|
+
|
|
58
|
+
// @ts-ignore — CSS import required for xterm rendering
|
|
59
|
+
await import('@xterm/xterm/css/xterm.css');
|
|
60
|
+
|
|
61
|
+
if (cancelled || !containerRef.current) return;
|
|
62
|
+
|
|
63
|
+
const terminal = new xtermMod.Terminal({
|
|
64
|
+
cursorBlink: false,
|
|
65
|
+
cursorStyle: 'block',
|
|
66
|
+
fontSize: 14,
|
|
67
|
+
fontFamily: "'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Menlo', monospace",
|
|
68
|
+
lineHeight: 1.2,
|
|
69
|
+
scrollback: 5000,
|
|
70
|
+
allowProposedApi: true,
|
|
71
|
+
theme: {
|
|
72
|
+
background: '#0a0a0a',
|
|
73
|
+
foreground: '#e0e0e0',
|
|
74
|
+
cursor: '#39ff14',
|
|
75
|
+
cursorAccent: '#0a0a0a',
|
|
76
|
+
selectionBackground: '#39ff1433',
|
|
77
|
+
black: '#0a0a0a',
|
|
78
|
+
red: '#ff5555',
|
|
79
|
+
green: '#39ff14',
|
|
80
|
+
yellow: '#f1fa8c',
|
|
81
|
+
blue: '#6272a4',
|
|
82
|
+
magenta: '#ff79c6',
|
|
83
|
+
cyan: '#8be9fd',
|
|
84
|
+
white: '#e0e0e0',
|
|
85
|
+
brightBlack: '#555555',
|
|
86
|
+
brightRed: '#ff6e6e',
|
|
87
|
+
brightGreen: '#69ff69',
|
|
88
|
+
brightYellow: '#ffffa5',
|
|
89
|
+
brightBlue: '#d6acff',
|
|
90
|
+
brightMagenta: '#ff92df',
|
|
91
|
+
brightCyan: '#a4ffff',
|
|
92
|
+
brightWhite: '#ffffff',
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
terminalRef.current = terminal;
|
|
97
|
+
|
|
98
|
+
const fitAddon = new fitMod.FitAddon();
|
|
99
|
+
fitAddonRef.current = fitAddon;
|
|
100
|
+
terminal.loadAddon(fitAddon);
|
|
101
|
+
terminal.open(containerRef.current);
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
fitAddon.fit();
|
|
105
|
+
} catch {
|
|
106
|
+
// zero dimensions
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const dims = fitAddon.proposeDimensions();
|
|
110
|
+
const cols = dims?.cols ?? 80;
|
|
111
|
+
const rows = dims?.rows ?? 24;
|
|
112
|
+
|
|
113
|
+
if (cancelled) return;
|
|
114
|
+
|
|
115
|
+
// Prevent double creation (StrictMode guard)
|
|
116
|
+
if (createInFlightRef.current || proxySessionRef.current) {
|
|
117
|
+
// Already creating or already created — reuse existing session
|
|
118
|
+
const existingId = proxySessionRef.current;
|
|
119
|
+
if (existingId) {
|
|
120
|
+
wireUpTerminal(terminal, client, existingId, cancelled, cols, rows);
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
createInFlightRef.current = true;
|
|
126
|
+
|
|
127
|
+
let sessionId: string;
|
|
128
|
+
try {
|
|
129
|
+
const resp = (await client.request(SUBJECTS.term.create(), { tmuxPaneId, cols, rows }, 10000)) as {
|
|
130
|
+
sessionId?: string;
|
|
131
|
+
error?: string;
|
|
132
|
+
};
|
|
133
|
+
if (!resp.sessionId) {
|
|
134
|
+
terminal.writeln(`\r\n\x1b[31mFailed: ${resp.error || 'no session'}\x1b[0m`);
|
|
135
|
+
createInFlightRef.current = false;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
sessionId = resp.sessionId;
|
|
139
|
+
} catch (err) {
|
|
140
|
+
terminal.writeln(`\r\n\x1b[31mFailed to connect: ${err}\x1b[0m`);
|
|
141
|
+
createInFlightRef.current = false;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
createInFlightRef.current = false;
|
|
146
|
+
|
|
147
|
+
// If unmounted while awaiting, destroy immediately
|
|
148
|
+
if (cancelled) {
|
|
149
|
+
client.request(SUBJECTS.term.destroy(), { sessionId }, 5000).catch(() => {});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
proxySessionRef.current = sessionId;
|
|
154
|
+
wireUpTerminal(terminal, client, sessionId, cancelled, cols, rows);
|
|
155
|
+
})();
|
|
156
|
+
|
|
157
|
+
function wireUpTerminal(
|
|
158
|
+
terminal: Terminal,
|
|
159
|
+
client: ReturnType<typeof getNatsClient>,
|
|
160
|
+
sessionId: string,
|
|
161
|
+
isCancelled: boolean,
|
|
162
|
+
cols: number,
|
|
163
|
+
rows: number
|
|
164
|
+
) {
|
|
165
|
+
lastSentDimsRef.current = `${cols}x${rows}`;
|
|
166
|
+
|
|
167
|
+
settleTimerRef.current = setTimeout(() => {
|
|
168
|
+
settleTimerRef.current = null;
|
|
169
|
+
if (isCancelled || !proxySessionRef.current) return;
|
|
170
|
+
const settled = fitAddonRef.current?.proposeDimensions();
|
|
171
|
+
if (!settled) return;
|
|
172
|
+
const finalKey = `${settled.cols}x${settled.rows}`;
|
|
173
|
+
if (lastSentDimsRef.current === finalKey) return;
|
|
174
|
+
lastSentDimsRef.current = finalKey;
|
|
175
|
+
client.publish(SUBJECTS.term.resize(proxySessionRef.current), { cols: settled.cols, rows: settled.rows });
|
|
176
|
+
}, 500);
|
|
177
|
+
|
|
178
|
+
const unsubData = client.subscribe(SUBJECTS.term.data(sessionId), (msg: unknown) => {
|
|
179
|
+
if (isCancelled) return;
|
|
180
|
+
const { data } = msg as { data: string };
|
|
181
|
+
if (data) terminal.write(decodeBase64(data));
|
|
182
|
+
});
|
|
183
|
+
unsubsRef.current.push(unsubData);
|
|
184
|
+
|
|
185
|
+
const unsubBuffer = client.subscribe(SUBJECTS.term.buffer(sessionId), (msg: unknown) => {
|
|
186
|
+
if (isCancelled) return;
|
|
187
|
+
const { data } = msg as { data: string };
|
|
188
|
+
if (data) terminal.write(decodeBase64(data));
|
|
189
|
+
});
|
|
190
|
+
unsubsRef.current.push(unsubBuffer);
|
|
191
|
+
|
|
192
|
+
const unsubBufferEnd = client.subscribe(SUBJECTS.term.bufferEnd(sessionId), () => {
|
|
193
|
+
if (isCancelled) return;
|
|
194
|
+
(async () => {
|
|
195
|
+
try {
|
|
196
|
+
const webglMod = await import('@xterm/addon-webgl');
|
|
197
|
+
if (isCancelled || !terminalRef.current) return;
|
|
198
|
+
const addon = new webglMod.WebglAddon();
|
|
199
|
+
addon.onContextLoss(() => addon.dispose());
|
|
200
|
+
terminal.loadAddon(addon);
|
|
201
|
+
webglAddonRef.current = addon;
|
|
202
|
+
} catch {
|
|
203
|
+
// WebGL unavailable
|
|
204
|
+
}
|
|
205
|
+
})();
|
|
206
|
+
});
|
|
207
|
+
unsubsRef.current.push(unsubBufferEnd);
|
|
208
|
+
|
|
209
|
+
client.publish(SUBJECTS.term.replay(sessionId), { sessionId });
|
|
210
|
+
|
|
211
|
+
const unsubExit = client.subscribe(SUBJECTS.term.exit(sessionId), () => {
|
|
212
|
+
if (isCancelled) return;
|
|
213
|
+
terminal.writeln('\r\n\x1b[33m[session ended]\x1b[0m');
|
|
214
|
+
proxySessionRef.current = null;
|
|
215
|
+
onDisconnectRef.current?.();
|
|
216
|
+
});
|
|
217
|
+
unsubsRef.current.push(unsubExit);
|
|
218
|
+
|
|
219
|
+
terminal.onData((data) => {
|
|
220
|
+
if (isCancelled || !proxySessionRef.current) return;
|
|
221
|
+
client.publish(SUBJECTS.term.input(proxySessionRef.current), { data });
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
terminal.onBinary((data) => {
|
|
225
|
+
if (isCancelled || !proxySessionRef.current) return;
|
|
226
|
+
client.publish(SUBJECTS.term.input(proxySessionRef.current), { data });
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
terminal.onResize(({ cols: c, rows: r }) => {
|
|
230
|
+
if (isCancelled || !proxySessionRef.current) return;
|
|
231
|
+
if (settleTimerRef.current) return;
|
|
232
|
+
const dimsKey = `${c}x${r}`;
|
|
233
|
+
if (lastSentDimsRef.current === dimsKey) return;
|
|
234
|
+
if (resizeTimerRef.current) clearTimeout(resizeTimerRef.current);
|
|
235
|
+
resizeTimerRef.current = setTimeout(() => {
|
|
236
|
+
if (isCancelled || !proxySessionRef.current) return;
|
|
237
|
+
lastSentDimsRef.current = dimsKey;
|
|
238
|
+
client.publish(SUBJECTS.term.resize(proxySessionRef.current), { cols: c, rows: r });
|
|
239
|
+
}, 150);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return () => {
|
|
244
|
+
cancelled = true;
|
|
245
|
+
for (const unsub of unsubsRef.current) unsub();
|
|
246
|
+
unsubsRef.current = [];
|
|
247
|
+
|
|
248
|
+
if (webglAddonRef.current) {
|
|
249
|
+
try {
|
|
250
|
+
webglAddonRef.current.dispose();
|
|
251
|
+
} catch {
|
|
252
|
+
// ignore
|
|
253
|
+
}
|
|
254
|
+
webglAddonRef.current = null;
|
|
255
|
+
}
|
|
256
|
+
if (terminalRef.current) {
|
|
257
|
+
terminalRef.current.dispose();
|
|
258
|
+
terminalRef.current = null;
|
|
259
|
+
}
|
|
260
|
+
fitAddonRef.current = null;
|
|
261
|
+
lastSentDimsRef.current = '';
|
|
262
|
+
if (resizeTimerRef.current) {
|
|
263
|
+
clearTimeout(resizeTimerRef.current);
|
|
264
|
+
resizeTimerRef.current = null;
|
|
265
|
+
}
|
|
266
|
+
if (settleTimerRef.current) {
|
|
267
|
+
clearTimeout(settleTimerRef.current);
|
|
268
|
+
settleTimerRef.current = null;
|
|
269
|
+
}
|
|
270
|
+
// NOTE: don't destroy proxySessionRef here — StrictMode will remount
|
|
271
|
+
// and reuse it. Destroy only happens when the component truly unmounts
|
|
272
|
+
// (selectedPaneId changes or user closes), handled by the tmuxPaneId cleanup below.
|
|
273
|
+
};
|
|
274
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
275
|
+
}, [tmuxPaneId]);
|
|
276
|
+
|
|
277
|
+
// Destroy proxy session when tmuxPaneId changes or component fully unmounts
|
|
278
|
+
useEffect(() => {
|
|
279
|
+
return () => {
|
|
280
|
+
const sessionId = proxySessionRef.current;
|
|
281
|
+
if (sessionId) {
|
|
282
|
+
proxySessionRef.current = null;
|
|
283
|
+
createInFlightRef.current = false;
|
|
284
|
+
const client = getNatsClient();
|
|
285
|
+
client.request(SUBJECTS.term.destroy(), { sessionId }, 5000).catch(() => {});
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}, [tmuxPaneId]);
|
|
289
|
+
|
|
290
|
+
// ResizeObserver
|
|
291
|
+
useEffect(() => {
|
|
292
|
+
const observer = new ResizeObserver(() => {
|
|
293
|
+
requestAnimationFrame(() => {
|
|
294
|
+
try {
|
|
295
|
+
fitAddonRef.current?.fit();
|
|
296
|
+
} catch {
|
|
297
|
+
// ignore
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
if (containerRef.current) observer.observe(containerRef.current);
|
|
302
|
+
return () => observer.disconnect();
|
|
303
|
+
}, []);
|
|
304
|
+
|
|
305
|
+
return <div ref={containerRef} className="h-full w-full" style={{ padding: '4px' }} />;
|
|
306
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { getNatsClient } from '@/lib/nats-client';
|
|
5
|
+
|
|
6
|
+
interface UseNatsActionResult<T> {
|
|
7
|
+
execute: (payload?: unknown) => Promise<T>;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generic hook for one-shot NATS mutations (kill, stop, create, etc.).
|
|
14
|
+
* Returns { execute, loading, error }.
|
|
15
|
+
*
|
|
16
|
+
* @param subject NATS subject to request
|
|
17
|
+
*/
|
|
18
|
+
export function useNatsAction<T = unknown>(subject: string): UseNatsActionResult<T> {
|
|
19
|
+
const [loading, setLoading] = useState(false);
|
|
20
|
+
const [error, setError] = useState<string | null>(null);
|
|
21
|
+
const mountedRef = useRef(true);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
mountedRef.current = true;
|
|
25
|
+
return () => {
|
|
26
|
+
mountedRef.current = false;
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
const execute = useCallback(
|
|
31
|
+
async (payload?: unknown): Promise<T> => {
|
|
32
|
+
setLoading(true);
|
|
33
|
+
setError(null);
|
|
34
|
+
try {
|
|
35
|
+
const client = getNatsClient();
|
|
36
|
+
const response = await client.request(subject, payload ?? {}, 10000);
|
|
37
|
+
if (mountedRef.current) {
|
|
38
|
+
setLoading(false);
|
|
39
|
+
}
|
|
40
|
+
return response as T;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
43
|
+
if (mountedRef.current) {
|
|
44
|
+
setError(message);
|
|
45
|
+
setLoading(false);
|
|
46
|
+
}
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
[subject]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return { execute, loading, error };
|
|
54
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { getNatsClient } from '@/lib/nats-client';
|
|
5
|
+
|
|
6
|
+
interface UseNatsRequestResult<T> {
|
|
7
|
+
data: T | null;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
refetch: () => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Generic hook for polling NATS request-reply subjects.
|
|
15
|
+
* Returns { data, loading, error, refetch }.
|
|
16
|
+
*
|
|
17
|
+
* @param subject NATS subject to request
|
|
18
|
+
* @param payload Optional request payload (stable reference recommended)
|
|
19
|
+
* @param interval Polling interval in ms (default 5000, 0 to disable polling)
|
|
20
|
+
*/
|
|
21
|
+
export function useNatsRequest<T = unknown>(
|
|
22
|
+
subject: string,
|
|
23
|
+
payload?: unknown,
|
|
24
|
+
interval = 5000
|
|
25
|
+
): UseNatsRequestResult<T> {
|
|
26
|
+
const [data, setData] = useState<T | null>(null);
|
|
27
|
+
const [loading, setLoading] = useState(true);
|
|
28
|
+
const [error, setError] = useState<string | null>(null);
|
|
29
|
+
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
30
|
+
const mountedRef = useRef(true);
|
|
31
|
+
|
|
32
|
+
const fetchData = useCallback(async () => {
|
|
33
|
+
try {
|
|
34
|
+
const client = getNatsClient();
|
|
35
|
+
const response = await client.request(subject, payload ?? {}, 5000);
|
|
36
|
+
if (!mountedRef.current) return;
|
|
37
|
+
setData(response as T);
|
|
38
|
+
setError(null);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
if (!mountedRef.current) return;
|
|
41
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
42
|
+
} finally {
|
|
43
|
+
if (mountedRef.current) {
|
|
44
|
+
setLoading(false);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, [subject, payload]);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
mountedRef.current = true;
|
|
51
|
+
setLoading(true);
|
|
52
|
+
fetchData();
|
|
53
|
+
|
|
54
|
+
if (interval > 0) {
|
|
55
|
+
intervalRef.current = setInterval(fetchData, interval);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return () => {
|
|
59
|
+
mountedRef.current = false;
|
|
60
|
+
if (intervalRef.current) {
|
|
61
|
+
clearInterval(intervalRef.current);
|
|
62
|
+
intervalRef.current = null;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}, [fetchData, interval]);
|
|
66
|
+
|
|
67
|
+
return { data, loading, error, refetch: fetchData };
|
|
68
|
+
}
|