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.
Files changed (408) hide show
  1. package/.env.example +23 -0
  2. package/.genie/mailbox/cli-sent.jsonl +3 -0
  3. package/.genie/mailbox/ds1-wave2-engineer-1.json +15 -0
  4. package/.genie/mailbox/ds1-wave2-engineer-2.json +15 -0
  5. package/.genie/mailbox/ds1-wave2-engineer-3.json +15 -0
  6. package/.genie/state/os-observability.json +39 -0
  7. package/.genie/state/tmux-control-mode-terminal.json +28 -0
  8. package/.genie/wishes/genieos-one-theme/WISH.md +417 -0
  9. package/.genie/wishes/workos-prod-rbac/WISH.md +345 -0
  10. package/.github/workflows/ci.yml +39 -0
  11. package/.github/workflows/release.yml +78 -0
  12. package/.github/workflows/version.yml +122 -0
  13. package/.husky/pre-commit +1 -0
  14. package/.pnpm-approve-builds.json +1 -0
  15. package/CLAUDE.md +117 -0
  16. package/LICENSE +21 -0
  17. package/README.md +38 -0
  18. package/biome.json +124 -0
  19. package/bun.lock +1249 -0
  20. package/docs/workos-setup.md +116 -0
  21. package/ecosystem.config.cjs +26 -0
  22. package/instrumentation.ts +8 -0
  23. package/knip.json +35 -0
  24. package/nats.conf +7 -0
  25. package/next.config.ts +25 -0
  26. package/package.json +78 -0
  27. package/packages/dev3000-app/components.ts +12 -0
  28. package/packages/dev3000-app/manifest.ts +19 -0
  29. package/packages/dev3000-app/package.json +23 -0
  30. package/packages/dev3000-app/views/dev3000/Dev3000App.tsx +758 -0
  31. package/packages/dev3000-app/views/dev3000/ErrorsPanel.tsx +160 -0
  32. package/packages/dev3000-app/views/dev3000/dev3000-context.tsx +21 -0
  33. package/packages/dev3000-app/views/dev3000/index.ts +4 -0
  34. package/packages/dev3000-app/views/dev3000/schema.ts +55 -0
  35. package/packages/dev3000-app/views/dev3000/service/index.ts +358 -0
  36. package/packages/dev3000-app/views/dev3000/service/runtime +1 -0
  37. package/packages/dev3000-app/views/dev3000/subjects.ts +9 -0
  38. package/packages/dev3000-app/views/dev3000/types.ts +77 -0
  39. package/packages/files-app/components.ts +12 -0
  40. package/packages/files-app/manifest.ts +19 -0
  41. package/packages/files-app/package.json +23 -0
  42. package/packages/files-app/views/files/ContextMenu.tsx +151 -0
  43. package/packages/files-app/views/files/DeleteConfirmDialog.tsx +39 -0
  44. package/packages/files-app/views/files/FileItem.tsx +128 -0
  45. package/packages/files-app/views/files/FilesApp.tsx +509 -0
  46. package/packages/files-app/views/files/FilesListView.tsx +201 -0
  47. package/packages/files-app/views/files/FilesToolbar.tsx +117 -0
  48. package/packages/files-app/views/files/GridView.tsx +90 -0
  49. package/packages/files-app/views/files/InlineInput.tsx +131 -0
  50. package/packages/files-app/views/files/UploadOverlay.tsx +61 -0
  51. package/packages/files-app/views/files/schema.ts +49 -0
  52. package/packages/files-app/views/files/service/index.ts +184 -0
  53. package/packages/files-app/views/files/service/runtime +1 -0
  54. package/packages/files-app/views/files/use-files.ts +201 -0
  55. package/packages/files-app/views/files/use-upload.ts +105 -0
  56. package/packages/genie-app/components.ts +12 -0
  57. package/packages/genie-app/lib/subjects.ts +87 -0
  58. package/packages/genie-app/manifest.ts +19 -0
  59. package/packages/genie-app/package.json +29 -0
  60. package/packages/genie-app/views/genie/service/agent-lifecycle.ts +136 -0
  61. package/packages/genie-app/views/genie/service/cli.ts +114 -0
  62. package/packages/genie-app/views/genie/service/comms.ts +141 -0
  63. package/packages/genie-app/views/genie/service/directory.ts +167 -0
  64. package/packages/genie-app/views/genie/service/index.ts +219 -0
  65. package/packages/genie-app/views/genie/service/system.ts +123 -0
  66. package/packages/genie-app/views/genie/service/teams.ts +191 -0
  67. package/packages/genie-app/views/genie/service/terminal-proxy.ts +184 -0
  68. package/packages/genie-app/views/genie/service/tmux-control.ts +318 -0
  69. package/packages/genie-app/views/genie/service/wishes.ts +270 -0
  70. package/packages/genie-app/views/genie/ui/GenieApp.tsx +5 -0
  71. package/packages/genie-app/views/genie/ui/PaneCard.tsx +307 -0
  72. package/packages/genie-app/views/genie/ui/Sidebar.tsx +212 -0
  73. package/packages/genie-app/views/genie/ui/TabBar.tsx +70 -0
  74. package/packages/genie-app/views/genie/ui/WorkspaceCanvas.tsx +343 -0
  75. package/packages/genie-app/views/genie/ui/XTermPane.tsx +306 -0
  76. package/packages/genie-app/views/genie/ui/hooks/useNatsAction.ts +54 -0
  77. package/packages/genie-app/views/genie/ui/hooks/useNatsRequest.ts +68 -0
  78. package/packages/genie-app/views/genie/ui/panels/AgentsPanel.tsx +399 -0
  79. package/packages/genie-app/views/genie/ui/panels/ChatPanel.tsx +351 -0
  80. package/packages/genie-app/views/genie/ui/panels/SystemPanel.tsx +195 -0
  81. package/packages/genie-app/views/genie/ui/panels/TeamsPanel.tsx +560 -0
  82. package/packages/genie-app/views/genie/ui/panels/WishesPanel.tsx +424 -0
  83. package/packages/nats-viewer-app/components.ts +12 -0
  84. package/packages/nats-viewer-app/manifest.ts +18 -0
  85. package/packages/nats-viewer-app/package.json +14 -0
  86. package/packages/nats-viewer-app/views/nats-viewer/ActiveSubs.tsx +34 -0
  87. package/packages/nats-viewer-app/views/nats-viewer/MessageLog.tsx +247 -0
  88. package/packages/nats-viewer-app/views/nats-viewer/NatsViewer.tsx +209 -0
  89. package/packages/nats-viewer-app/views/nats-viewer/PublishPanel.tsx +111 -0
  90. package/packages/nats-viewer-app/views/nats-viewer/RequestPanel.tsx +165 -0
  91. package/packages/nats-viewer-app/views/nats-viewer/Sidebar.tsx +59 -0
  92. package/packages/nats-viewer-app/views/nats-viewer/SubjectCatalog.tsx +63 -0
  93. package/packages/nats-viewer-app/views/nats-viewer/SubscribeInput.tsx +59 -0
  94. package/packages/nats-viewer-app/views/nats-viewer/index.ts +5 -0
  95. package/packages/nats-viewer-app/views/nats-viewer/nats-viewer-context.tsx +31 -0
  96. package/packages/nats-viewer-app/views/nats-viewer/types.ts +7 -0
  97. package/packages/nats-viewer-app/views/nats-viewer/use-message-buffer.ts +55 -0
  98. package/packages/os-cli/package.json +18 -0
  99. package/packages/os-cli/src/commands/events.ts +176 -0
  100. package/packages/os-cli/src/commands/logs.ts +96 -0
  101. package/packages/os-cli/src/commands/status.ts +53 -0
  102. package/packages/os-cli/src/commands/traces.ts +115 -0
  103. package/packages/os-cli/src/index.ts +15 -0
  104. package/packages/os-cli/src/lib/formatter.ts +123 -0
  105. package/packages/os-cli/src/lib/nats.ts +16 -0
  106. package/packages/os-cli/src/lib/trace-tree.ts +144 -0
  107. package/packages/os-cli/tsconfig.json +12 -0
  108. package/packages/os-sdk/package.json +27 -0
  109. package/packages/os-sdk/src/api/handler.ts +67 -0
  110. package/packages/os-sdk/src/config.ts +68 -0
  111. package/packages/os-sdk/src/db/factory.test.ts +42 -0
  112. package/packages/os-sdk/src/db/factory.ts +72 -0
  113. package/packages/os-sdk/src/db/migrate.ts +140 -0
  114. package/packages/os-sdk/src/db/provision.ts +44 -0
  115. package/packages/os-sdk/src/index.ts +36 -0
  116. package/packages/os-sdk/src/service/console-intercept.ts +60 -0
  117. package/packages/os-sdk/src/service/logger.ts +88 -0
  118. package/packages/os-sdk/src/service/o11y-streams.ts +88 -0
  119. package/packages/os-sdk/src/service/runtime.ts +259 -0
  120. package/packages/os-sdk/src/service/trace.ts +71 -0
  121. package/packages/os-sdk/tsconfig.json +16 -0
  122. package/packages/os-ui/package.json +13 -0
  123. package/packages/os-ui/src/index.ts +29 -0
  124. package/packages/os-ui/src/server.ts +4 -0
  125. package/packages/os-ui/tsconfig.json +19 -0
  126. package/packages/settings-app/components.ts +12 -0
  127. package/packages/settings-app/manifest.ts +18 -0
  128. package/packages/settings-app/package.json +14 -0
  129. package/packages/settings-app/views/settings/Settings.tsx +492 -0
  130. package/packages/terminal-app/components.ts +12 -0
  131. package/packages/terminal-app/manifest.ts +20 -0
  132. package/packages/terminal-app/package.json +23 -0
  133. package/packages/terminal-app/views/terminal/schema.ts +82 -0
  134. package/packages/terminal-app/views/terminal/service/index.ts +133 -0
  135. package/packages/terminal-app/views/terminal/service/runtime +1 -0
  136. package/packages/terminal-app/views/terminal/service/session.ts +290 -0
  137. package/packages/terminal-app/views/terminal/service/shell-hooks/bashrc-hook.sh +21 -0
  138. package/packages/terminal-app/views/terminal/types.ts +26 -0
  139. package/packages/terminal-app/views/terminal/ui/MultiTerminalApp.tsx +615 -0
  140. package/packages/terminal-app/views/terminal/ui/SplitDragHandle.tsx +91 -0
  141. package/packages/terminal-app/views/terminal/ui/SplitPaneRenderer.tsx +112 -0
  142. package/packages/terminal-app/views/terminal/ui/TerminalPane.tsx +478 -0
  143. package/packages/terminal-app/views/terminal/ui/TerminalTabBar.tsx +131 -0
  144. package/pnpm-workspace.yaml +9 -0
  145. package/postcss.config.mjs +7 -0
  146. package/public/file.svg +1 -0
  147. package/public/globe.svg +1 -0
  148. package/public/icons/code-server.svg +6 -0
  149. package/public/icons/default.svg +5 -0
  150. package/public/icons/dusk/1password.svg +1 -0
  151. package/public/icons/dusk/activity_monitor.svg +1 -0
  152. package/public/icons/dusk/app_store.svg +1 -0
  153. package/public/icons/dusk/atom.svg +1 -0
  154. package/public/icons/dusk/brave.svg +1 -0
  155. package/public/icons/dusk/calculator.svg +1 -0
  156. package/public/icons/dusk/calendar.svg +1 -0
  157. package/public/icons/dusk/chrome.svg +1 -0
  158. package/public/icons/dusk/chrome2.svg +1 -0
  159. package/public/icons/dusk/dashboard.svg +13 -0
  160. package/public/icons/dusk/discord.svg +1 -0
  161. package/public/icons/dusk/dropbox.svg +1 -0
  162. package/public/icons/dusk/electron.svg +1 -0
  163. package/public/icons/dusk/figma.svg +1 -0
  164. package/public/icons/dusk/finder.svg +1 -0
  165. package/public/icons/dusk/finder2.svg +1 -0
  166. package/public/icons/dusk/finder3.svg +1 -0
  167. package/public/icons/dusk/firefox.svg +1 -0
  168. package/public/icons/dusk/framer.svg +1 -0
  169. package/public/icons/dusk/gimp.svg +1 -0
  170. package/public/icons/dusk/github_desktop.svg +1 -0
  171. package/public/icons/dusk/hyper.svg +1 -0
  172. package/public/icons/dusk/hyper3.svg +1 -0
  173. package/public/icons/dusk/intellij.svg +1 -0
  174. package/public/icons/dusk/iterm2.svg +1 -0
  175. package/public/icons/dusk/itunes.svg +1 -0
  176. package/public/icons/dusk/mail.svg +1 -0
  177. package/public/icons/dusk/messenger.svg +1 -0
  178. package/public/icons/dusk/mongodb.svg +1 -0
  179. package/public/icons/dusk/notes.svg +1 -0
  180. package/public/icons/dusk/notion.svg +1 -0
  181. package/public/icons/dusk/obs.svg +1 -0
  182. package/public/icons/dusk/pages.svg +1 -0
  183. package/public/icons/dusk/photos.svg +1 -0
  184. package/public/icons/dusk/postman.svg +1 -0
  185. package/public/icons/dusk/preview.svg +1 -0
  186. package/public/icons/dusk/reminders.svg +1 -0
  187. package/public/icons/dusk/safari.svg +1 -0
  188. package/public/icons/dusk/sequel_pro.svg +1 -0
  189. package/public/icons/dusk/sketch.svg +1 -0
  190. package/public/icons/dusk/skype.svg +1 -0
  191. package/public/icons/dusk/slack.svg +1 -0
  192. package/public/icons/dusk/slack2.svg +1 -0
  193. package/public/icons/dusk/spotify.svg +1 -0
  194. package/public/icons/dusk/steam.svg +1 -0
  195. package/public/icons/dusk/system_preferences.svg +1 -0
  196. package/public/icons/dusk/tableplus.svg +1 -0
  197. package/public/icons/dusk/teams.svg +1 -0
  198. package/public/icons/dusk/telegram.svg +1 -0
  199. package/public/icons/dusk/terminal.svg +1 -0
  200. package/public/icons/dusk/todoist.svg +1 -0
  201. package/public/icons/dusk/trash.svg +1 -0
  202. package/public/icons/dusk/trello.svg +1 -0
  203. package/public/icons/dusk/vivaldi.svg +1 -0
  204. package/public/icons/dusk/vlc.svg +1 -0
  205. package/public/icons/dusk/vscode.svg +1 -0
  206. package/public/icons/dusk/whatsapp.svg +1 -0
  207. package/public/icons/dusk/xeyes.svg +1 -0
  208. package/public/icons/dusk/zoom.svg +1 -0
  209. package/public/icons/files.svg +5 -0
  210. package/public/icons/pwa/icon-192.png +0 -0
  211. package/public/icons/pwa/icon-512.png +0 -0
  212. package/public/icons/settings.svg +14 -0
  213. package/public/icons/terminal.svg +5 -0
  214. package/public/icons/text-editor.svg +7 -0
  215. package/public/manifest.json +38 -0
  216. package/public/next.svg +1 -0
  217. package/public/sw.js +41 -0
  218. package/public/vercel.svg +1 -0
  219. package/public/wallpapers/default.svg +10 -0
  220. package/public/window.svg +1 -0
  221. package/scripts/generate-pwa-icons.mjs +33 -0
  222. package/scripts/install-nats.sh +37 -0
  223. package/sentry.client.config.ts +21 -0
  224. package/sentry.edge.config.ts +12 -0
  225. package/sentry.server.config.ts +12 -0
  226. package/src/app/api/files/download/route.ts +81 -0
  227. package/src/app/api/files/download-zip/route.ts +102 -0
  228. package/src/app/api/files/upload/route.ts +58 -0
  229. package/src/app/api/webhooks/workos/route.ts +98 -0
  230. package/src/app/auth/callback/route.ts +16 -0
  231. package/src/app/auth/logout/route.ts +15 -0
  232. package/src/app/desktop/desktop-shell.tsx +110 -0
  233. package/src/app/desktop/layout.tsx +8 -0
  234. package/src/app/desktop/page.tsx +24 -0
  235. package/src/app/favicon.ico +0 -0
  236. package/src/app/globals.css +7 -0
  237. package/src/app/layout.tsx +64 -0
  238. package/src/app/offline/page.tsx +83 -0
  239. package/src/app/page.tsx +5 -0
  240. package/src/app/standalone/[appId]/page.tsx +28 -0
  241. package/src/app/standalone/layout.tsx +10 -0
  242. package/src/components/app-icon.tsx +55 -0
  243. package/src/components/apps/_echo/schema.ts +14 -0
  244. package/src/components/apps/_echo/service/index.ts +42 -0
  245. package/src/components/apps/app-manifest.ts +97 -0
  246. package/src/components/apps/app-registry.ts +55 -0
  247. package/src/components/apps/dev3000/Dev3000App.tsx +224 -0
  248. package/src/components/apps/dev3000/ErrorsPanel.tsx +160 -0
  249. package/src/components/apps/dev3000/Sidebar.tsx +41 -0
  250. package/src/components/apps/dev3000/TimelineLog.tsx +173 -0
  251. package/src/components/apps/dev3000/dev3000-context.tsx +29 -0
  252. package/src/components/apps/dev3000/index.ts +4 -0
  253. package/src/components/apps/dev3000/schema.ts +48 -0
  254. package/src/components/apps/dev3000/service/index.ts +520 -0
  255. package/src/components/apps/dev3000/service/runtime +1 -0
  256. package/src/components/apps/dev3000/types.ts +15 -0
  257. package/src/components/apps/dev3000/use-message-buffer.ts +46 -0
  258. package/src/components/apps/files/ContextMenu.tsx +151 -0
  259. package/src/components/apps/files/DeleteConfirmDialog.tsx +78 -0
  260. package/src/components/apps/files/FileItem.tsx +128 -0
  261. package/src/components/apps/files/FilesApp.tsx +509 -0
  262. package/src/components/apps/files/FilesListView.tsx +201 -0
  263. package/src/components/apps/files/FilesToolbar.tsx +117 -0
  264. package/src/components/apps/files/GridView.tsx +90 -0
  265. package/src/components/apps/files/InlineInput.tsx +131 -0
  266. package/src/components/apps/files/UploadOverlay.tsx +61 -0
  267. package/src/components/apps/files/schema.ts +49 -0
  268. package/src/components/apps/files/service/index.ts +227 -0
  269. package/src/components/apps/files/service/runtime +1 -0
  270. package/src/components/apps/files/use-files.ts +201 -0
  271. package/src/components/apps/files/use-upload.ts +105 -0
  272. package/src/components/apps/nats-viewer/ActiveSubs.tsx +34 -0
  273. package/src/components/apps/nats-viewer/MessageLog.tsx +247 -0
  274. package/src/components/apps/nats-viewer/NatsViewer.tsx +209 -0
  275. package/src/components/apps/nats-viewer/PublishPanel.tsx +113 -0
  276. package/src/components/apps/nats-viewer/RequestPanel.tsx +167 -0
  277. package/src/components/apps/nats-viewer/Sidebar.tsx +62 -0
  278. package/src/components/apps/nats-viewer/SubjectCatalog.tsx +64 -0
  279. package/src/components/apps/nats-viewer/SubscribeInput.tsx +59 -0
  280. package/src/components/apps/nats-viewer/index.ts +5 -0
  281. package/src/components/apps/nats-viewer/nats-viewer-context.tsx +31 -0
  282. package/src/components/apps/nats-viewer/types.ts +7 -0
  283. package/src/components/apps/nats-viewer/use-message-buffer.ts +55 -0
  284. package/src/components/apps/settings/Settings.tsx +492 -0
  285. package/src/components/apps/terminal/schema.ts +82 -0
  286. package/src/components/apps/terminal/service/index.ts +189 -0
  287. package/src/components/apps/terminal/service/runtime +1 -0
  288. package/src/components/apps/terminal/service/session.ts +296 -0
  289. package/src/components/apps/terminal/service/shell-hooks/bashrc-hook.sh +21 -0
  290. package/src/components/apps/terminal/types.ts +26 -0
  291. package/src/components/apps/terminal/ui/MultiTerminalApp.tsx +617 -0
  292. package/src/components/apps/terminal/ui/SplitDragHandle.tsx +91 -0
  293. package/src/components/apps/terminal/ui/SplitPaneRenderer.tsx +112 -0
  294. package/src/components/apps/terminal/ui/TerminalPane.tsx +476 -0
  295. package/src/components/apps/terminal/ui/TerminalTabBar.tsx +131 -0
  296. package/src/components/desktop/AnimatedBackground.tsx +69 -0
  297. package/src/components/desktop/Desktop.tsx +79 -0
  298. package/src/components/desktop/DesktopBackground.tsx +16 -0
  299. package/src/components/desktop/DesktopIcon.tsx +49 -0
  300. package/src/components/desktop/ShortcutViewer.tsx +136 -0
  301. package/src/components/desktop/WindowRenderer.tsx +34 -0
  302. package/src/components/desktop/WindowSwitcher.tsx +42 -0
  303. package/src/components/notifications/NotificationCenter.tsx +153 -0
  304. package/src/components/notifications/NotificationToasts.tsx +66 -0
  305. package/src/components/notifications/OrphanSessionToast.tsx +293 -0
  306. package/src/components/os-primitives/collapsible-sidebar.tsx +226 -0
  307. package/src/components/os-primitives/dialog.tsx +76 -0
  308. package/src/components/os-primitives/empty-state.tsx +43 -0
  309. package/src/components/os-primitives/index.ts +21 -0
  310. package/src/components/os-primitives/list-view.tsx +155 -0
  311. package/src/components/os-primitives/property-panel.tsx +108 -0
  312. package/src/components/os-primitives/section-header.tsx +19 -0
  313. package/src/components/os-primitives/sidebar-nav.tsx +110 -0
  314. package/src/components/os-primitives/split-pane.tsx +146 -0
  315. package/src/components/os-primitives/status-badge.tsx +10 -0
  316. package/src/components/os-primitives/status-bar.tsx +100 -0
  317. package/src/components/os-primitives/toolbar.tsx +152 -0
  318. package/src/components/taskbar/AppLauncher.tsx +114 -0
  319. package/src/components/taskbar/RunningApps.tsx +71 -0
  320. package/src/components/taskbar/SystemTray.tsx +134 -0
  321. package/src/components/taskbar/Taskbar.tsx +45 -0
  322. package/src/components/taskbar/UserMenu.tsx +138 -0
  323. package/src/components/taskbar/WorkspaceSwitcher.tsx +9 -0
  324. package/src/components/ui/ContextMenu.tsx +130 -0
  325. package/src/components/ui/badge.tsx +39 -0
  326. package/src/components/ui/button.tsx +102 -0
  327. package/src/components/ui/command.tsx +165 -0
  328. package/src/components/ui/dropdown-menu.tsx +233 -0
  329. package/src/components/ui/input.tsx +48 -0
  330. package/src/components/ui/note.tsx +55 -0
  331. package/src/components/ui/separator.tsx +25 -0
  332. package/src/components/ui/spinner.tsx +42 -0
  333. package/src/components/ui/switch.tsx +36 -0
  334. package/src/components/ui/theme-provider.tsx +24 -0
  335. package/src/components/ui/theme-switcher.tsx +51 -0
  336. package/src/components/ui/tooltip.tsx +62 -0
  337. package/src/components/window/MobileWindowStack.tsx +218 -0
  338. package/src/components/window/SnapPreview.tsx +37 -0
  339. package/src/components/window/StandaloneFrame.tsx +170 -0
  340. package/src/components/window/Window.tsx +423 -0
  341. package/src/components/window/WindowContent.tsx +14 -0
  342. package/src/components/window/WindowControlsOverlay.tsx +89 -0
  343. package/src/components/window/WindowFrame.tsx +124 -0
  344. package/src/lib/auth/index.ts +27 -0
  345. package/src/lib/auth/roles.ts +50 -0
  346. package/src/lib/auth/types.ts +32 -0
  347. package/src/lib/auth/use-auth.ts +53 -0
  348. package/src/lib/auth/webhook-handler.ts +87 -0
  349. package/src/lib/auth/workos.ts +67 -0
  350. package/src/lib/constants.ts +1 -0
  351. package/src/lib/desktop/dedup.ts +57 -0
  352. package/src/lib/desktop/schema.ts +55 -0
  353. package/src/lib/files/filename-validation.ts +41 -0
  354. package/src/lib/files/safe-path.ts +49 -0
  355. package/src/lib/hooks/use-desktop-nats.ts +438 -0
  356. package/src/lib/hooks/use-is-mobile.ts +23 -0
  357. package/src/lib/hooks/use-launch-app.ts +79 -0
  358. package/src/lib/hooks/use-nats-notifications.ts +84 -0
  359. package/src/lib/hooks/use-nats.ts +60 -0
  360. package/src/lib/hooks/use-visual-viewport.ts +72 -0
  361. package/src/lib/icons/resolve-window-icon.ts +10 -0
  362. package/src/lib/keyboard/defaults.ts +146 -0
  363. package/src/lib/keyboard/types.ts +52 -0
  364. package/src/lib/keyboard/use-global-keybinds.ts +231 -0
  365. package/src/lib/nats-client.ts +255 -0
  366. package/src/lib/nats.ts +35 -0
  367. package/src/lib/notifications/schema.ts +12 -0
  368. package/src/lib/service-loader.ts +171 -0
  369. package/src/lib/subjects.ts +64 -0
  370. package/src/lib/utils.ts +6 -0
  371. package/src/lib/ws-bridge.ts +288 -0
  372. package/src/lib/ws-protocol.ts +53 -0
  373. package/src/lib/ws-server.ts +167 -0
  374. package/src/middleware.ts +57 -0
  375. package/src/stores/desktop-store.ts +112 -0
  376. package/src/stores/keybind-store.ts +66 -0
  377. package/src/stores/notification-store.ts +271 -0
  378. package/src/stores/theme-store.ts +25 -0
  379. package/src/stores/window-store.ts +294 -0
  380. package/src/theme/animations.css +68 -0
  381. package/src/theme/base.css +123 -0
  382. package/src/theme/controls.css +35 -0
  383. package/src/theme/design-tokens.css +276 -0
  384. package/src/theme/index.css +23 -0
  385. package/src/theme/menus.css +45 -0
  386. package/src/theme/status.css +41 -0
  387. package/src/theme/surfaces.css +94 -0
  388. package/src/theme/tailwind-map.css +138 -0
  389. package/src/theme/taskbar.css +25 -0
  390. package/src/theme/terminal.css +55 -0
  391. package/src/theme/typography.css +26 -0
  392. package/src/theme/utilities.css +156 -0
  393. package/src/theme/window.css +103 -0
  394. package/src/types/desktop-entry.ts +12 -0
  395. package/src/types/use-descendants.d.ts +13 -0
  396. package/src/types/window.ts +28 -0
  397. package/src/types.d.ts +9 -0
  398. package/tauri/Cargo.lock +5464 -0
  399. package/tauri/Cargo.toml +19 -0
  400. package/tauri/build.rs +3 -0
  401. package/tauri/capabilities/default.json +36 -0
  402. package/tauri/icons/128x128.png +0 -0
  403. package/tauri/icons/128x128@2x.png +0 -0
  404. package/tauri/icons/32x32.png +0 -0
  405. package/tauri/icons/icon.png +0 -0
  406. package/tauri/src/main.rs +396 -0
  407. package/tauri/tauri.conf.json +23 -0
  408. package/tsconfig.json +43 -0
@@ -0,0 +1,19 @@
1
+ [package]
2
+ name = "genie-os"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ [build-dependencies]
7
+ tauri-build = { version = "2", features = [] }
8
+
9
+ [dependencies]
10
+ tauri = { version = "2", features = ["macos-private-api", "tray-icon"] }
11
+ tauri-plugin-shell = "2"
12
+ serde = { version = "1", features = ["derive"] }
13
+ serde_json = "1"
14
+ reqwest = { version = "0.12", features = ["rustls-tls"], default-features = false }
15
+ dirs = "6"
16
+
17
+ [target."cfg(target_os = \"macos\")".dependencies]
18
+ cocoa = "0.26"
19
+ objc = "0.2"
package/tauri/build.rs ADDED
@@ -0,0 +1,3 @@
1
+ fn main() {
2
+ tauri_build::build()
3
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "identifier": "default",
3
+ "description": "Default capabilities for Genie OS",
4
+ "windows": ["*"],
5
+ "permissions": [
6
+ "core:default",
7
+ "core:event:default",
8
+ "core:event:allow-listen",
9
+ "core:event:allow-emit",
10
+ "core:event:allow-emit-to",
11
+ "core:webview:default",
12
+ "core:webview:allow-create-webview-window",
13
+ "core:webview:allow-internal-toggle-devtools",
14
+ "core:window:default",
15
+ "core:window:allow-show",
16
+ "core:window:allow-hide",
17
+ "core:window:allow-close",
18
+ "core:window:allow-center",
19
+ "core:window:allow-minimize",
20
+ "core:window:allow-maximize",
21
+ "core:window:allow-unmaximize",
22
+ "core:window:allow-is-maximized",
23
+ "core:window:allow-set-focus",
24
+ "core:window:allow-is-visible",
25
+ "core:window:allow-set-background-color",
26
+ "core:window:allow-start-dragging",
27
+ "core:window:allow-set-decorations",
28
+ "core:window:allow-set-size",
29
+ "core:window:allow-set-position",
30
+ "core:window:allow-create",
31
+ "core:tray:default",
32
+ "core:menu:default",
33
+ "shell:default",
34
+ "shell:allow-open"
35
+ ]
36
+ }
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,396 @@
1
+ // Genie OS — Native wrapper for the web-based desktop shell.
2
+ //
3
+ // The Tauri app is a thin client that:
4
+ // 1. Starts the backend services (PM2 or genie-os CLI)
5
+ // 2. Opens a webview pointing to the Next.js app at localhost:8888
6
+ // 3. Exposes Tauri IPC so the frontend can open native windows
7
+ //
8
+ // The same frontend works in both modes:
9
+ // - Browser: window management via Zustand store (div-windows)
10
+ // - Tauri: window management via native OS windows (this app)
11
+ //
12
+ // The frontend detects Tauri via `'__TAURI__' in window` and switches behavior.
13
+
14
+ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
15
+
16
+ use std::sync::Mutex;
17
+ use tauri::Emitter;
18
+ use tauri::Manager;
19
+ use tauri::WebviewWindowBuilder;
20
+ use tauri::WebviewUrl;
21
+ use tauri::ipc::CapabilityBuilder;
22
+ use tauri::menu::{MenuBuilder, MenuItemBuilder};
23
+ use tauri::tray::TrayIconBuilder;
24
+
25
+ const GENIE_OS_URL: &str = "http://localhost:8888";
26
+ const DESKTOP_URL: &str = "http://localhost:8888/desktop";
27
+
28
+ // Track whether we started the services ourselves
29
+ struct AppState {
30
+ services_started_by_us: bool,
31
+ }
32
+
33
+ // ── Commands ─────────────────────────────────────────────────────────────────
34
+
35
+ /// Open a native app window pointing to a URL path on the Genie OS server.
36
+ /// Called from frontend when running in Tauri mode.
37
+ #[tauri::command]
38
+ fn open_app_window(app: tauri::AppHandle, app_id: String, title: Option<String>, url: Option<String>) {
39
+ let label = format!("app-{}", app_id);
40
+
41
+ // If already open, focus it
42
+ if let Some(window) = app.get_webview_window(&label) {
43
+ let _ = window.show();
44
+ let _ = window.set_focus();
45
+ return;
46
+ }
47
+
48
+ // Each app gets its own standalone page — no desktop shell overhead
49
+ let target_url = url.unwrap_or_else(|| format!("{}/standalone/{}", GENIE_OS_URL, app_id));
50
+ let win_title = title.unwrap_or_else(|| app_id.clone());
51
+
52
+ let app_clone = app.clone();
53
+ let label_clone = label.clone();
54
+
55
+ if let Ok(w) = WebviewWindowBuilder::new(
56
+ &app,
57
+ &label,
58
+ WebviewUrl::External(target_url.parse().unwrap()),
59
+ )
60
+ .title(&win_title)
61
+ .inner_size(900.0, 600.0)
62
+ .resizable(true)
63
+ .decorations(false)
64
+ .transparent(true)
65
+ .shadow(false)
66
+ .visible(false) // Start HIDDEN — show after page loads to prevent flash
67
+ .initialization_script(r#"
68
+ // Ensure html/body are transparent for the standalone window
69
+ document.documentElement.style.background = 'transparent';
70
+ document.addEventListener('DOMContentLoaded', function() {
71
+ document.documentElement.style.background = 'transparent';
72
+ if (document.body) document.body.style.background = 'transparent';
73
+ // Signal Tauri to show the window now that content is ready
74
+ if (window.__TAURI__) {
75
+ window.__TAURI__.core.invoke('show_app_window', { appId: document.body.dataset.appId || '' });
76
+ }
77
+ });
78
+ // Fallback: show after 2s even if signal doesn't fire
79
+ setTimeout(function() {
80
+ if (window.__TAURI__) {
81
+ window.__TAURI__.core.invoke('show_app_window', { appId: '' });
82
+ }
83
+ }, 2000);
84
+ "#)
85
+ .build() {
86
+ center_on_cursor_monitor(&w);
87
+
88
+ // Fallback: show window after 3s in case initialization_script doesn't fire
89
+ let label_for_timer = label_clone.clone();
90
+ std::thread::spawn(move || {
91
+ std::thread::sleep(std::time::Duration::from_secs(3));
92
+ if let Some(win) = app_clone.get_webview_window(&label_for_timer) {
93
+ let _ = win.show();
94
+ }
95
+ });
96
+ }
97
+ }
98
+
99
+ /// List all open app windows
100
+ #[tauri::command]
101
+ fn list_app_windows(app: tauri::AppHandle) -> Vec<serde_json::Value> {
102
+ app.webview_windows()
103
+ .iter()
104
+ .filter(|(label, _)| label.starts_with("app-"))
105
+ .map(|(label, _win)| {
106
+ let app_id = label.strip_prefix("app-").unwrap_or(label);
107
+ serde_json::json!({ "appId": app_id, "label": label })
108
+ })
109
+ .collect()
110
+ }
111
+
112
+ /// Show an app window (called from initialization_script when page is ready)
113
+ #[tauri::command]
114
+ fn show_app_window(app: tauri::AppHandle, app_id: String) {
115
+ // Show ALL hidden app windows (the appId from the script may be empty)
116
+ for (label, window) in app.webview_windows() {
117
+ if label.starts_with("app-") && !window.is_visible().unwrap_or(true) {
118
+ let _ = window.show();
119
+ let _ = window.set_focus();
120
+ }
121
+ }
122
+ // Also try the specific one
123
+ if !app_id.is_empty() {
124
+ let label = format!("app-{}", app_id);
125
+ if let Some(window) = app.get_webview_window(&label) {
126
+ let _ = window.show();
127
+ let _ = window.set_focus();
128
+ }
129
+ }
130
+ }
131
+
132
+ /// Focus an app window by appId
133
+ #[tauri::command]
134
+ fn focus_app_window(app: tauri::AppHandle, app_id: String) {
135
+ let label = format!("app-{}", app_id);
136
+ if let Some(window) = app.get_webview_window(&label) {
137
+ let _ = window.show();
138
+ let _ = window.set_focus();
139
+ }
140
+ }
141
+
142
+ /// Close an app window by appId
143
+ #[tauri::command]
144
+ fn close_app_window(app: tauri::AppHandle, app_id: String) {
145
+ let label = format!("app-{}", app_id);
146
+ if let Some(window) = app.get_webview_window(&label) {
147
+ let _ = window.close();
148
+ }
149
+ }
150
+
151
+ /// Check if services are healthy
152
+ #[tauri::command]
153
+ async fn check_services() -> Result<bool, String> {
154
+ // Quick HTTP check on the Next.js server
155
+ let resp = reqwest::get(GENIE_OS_URL).await;
156
+ Ok(resp.is_ok())
157
+ }
158
+
159
+ // ── Helpers ──────────────────────────────────────────────────────────────────
160
+
161
+ fn center_on_cursor_monitor(window: &tauri::WebviewWindow) {
162
+ if let Ok(cursor) = window.cursor_position() {
163
+ if let Ok(Some(monitor)) = window.monitor_from_point(cursor.x, cursor.y) {
164
+ let mon_pos = monitor.position();
165
+ let mon_size = monitor.size();
166
+ if let Ok(win_size) = window.outer_size() {
167
+ let x = mon_pos.x as f64 + (mon_size.width as f64 - win_size.width as f64) / 2.0;
168
+ let y = mon_pos.y as f64 + (mon_size.height as f64 - win_size.height as f64) / 2.0;
169
+ let _ = window.set_position(tauri::Position::Physical(tauri::PhysicalPosition {
170
+ x: x as i32,
171
+ y: y as i32,
172
+ }));
173
+ }
174
+ } else {
175
+ let _ = window.center();
176
+ }
177
+ } else {
178
+ let _ = window.center();
179
+ }
180
+ }
181
+
182
+ fn start_services() -> bool {
183
+ // The Tauri app lives in src-tauri/ inside the genie-os-web repo.
184
+ // ecosystem.config.cjs is in the parent directory (repo root).
185
+ let genie_os_web = std::env::current_exe()
186
+ .ok()
187
+ .and_then(|p| p.parent().map(|p| p.to_path_buf())) // src-tauri/target/debug/
188
+ .map(|p| p.join("../../../..")) // up to repo root
189
+ .map(|p| std::fs::canonicalize(p).unwrap_or_default())
190
+ .unwrap_or_else(|| {
191
+ // Fallback: try known path
192
+ dirs::home_dir()
193
+ .map(|h| h.join("Dev/namastex/genie-os-web"))
194
+ .unwrap_or_default()
195
+ });
196
+
197
+ if !genie_os_web.join("ecosystem.config.cjs").exists() {
198
+ eprintln!("[genie-os] ecosystem.config.cjs not found at {:?}", genie_os_web);
199
+ return false;
200
+ }
201
+
202
+ eprintln!("[genie-os] starting services via PM2...");
203
+ let status = std::process::Command::new("pm2")
204
+ .args(["start", "ecosystem.config.cjs"])
205
+ .current_dir(&genie_os_web)
206
+ .stdout(std::process::Stdio::null())
207
+ .stderr(std::process::Stdio::null())
208
+ .status();
209
+
210
+ match status {
211
+ Ok(s) if s.success() => {
212
+ eprintln!("[genie-os] PM2 services started");
213
+ true
214
+ }
215
+ _ => {
216
+ eprintln!("[genie-os] failed to start PM2 services");
217
+ false
218
+ }
219
+ }
220
+ }
221
+
222
+ fn stop_services() {
223
+ // Stop only genie-os services, not everything in PM2
224
+ for name in &["os-nats", "os-services", "os-dev", "os-ws-bridge"] {
225
+ let _ = std::process::Command::new("pm2")
226
+ .args(["stop", name])
227
+ .stdout(std::process::Stdio::null())
228
+ .stderr(std::process::Stdio::null())
229
+ .status();
230
+ }
231
+ eprintln!("[genie-os] PM2 services stopped");
232
+ }
233
+
234
+ fn wait_for_server(max_secs: u32) -> bool {
235
+ for i in 0..max_secs * 2 {
236
+ if i > 0 {
237
+ std::thread::sleep(std::time::Duration::from_millis(500));
238
+ }
239
+ // Quick TCP check on port 8888
240
+ if std::net::TcpStream::connect("127.0.0.1:8888").is_ok() {
241
+ return true;
242
+ }
243
+ }
244
+ false
245
+ }
246
+
247
+ // ── Main ─────────────────────────────────────────────────────────────────────
248
+
249
+ fn main() {
250
+ tauri::Builder::default()
251
+ .manage(Mutex::new(AppState { services_started_by_us: false }))
252
+ .plugin(tauri_plugin_shell::init())
253
+ .invoke_handler(tauri::generate_handler![
254
+ open_app_window,
255
+ show_app_window,
256
+ list_app_windows,
257
+ focus_app_window,
258
+ close_app_window,
259
+ check_services,
260
+ ])
261
+ .setup(|app| {
262
+ // ── Enable IPC for external localhost pages ──────────────────
263
+ // This allows pages loaded from http://localhost:8888 to access
264
+ // window.__TAURI__ (invoke, window controls, events, etc.)
265
+ app.add_capability(
266
+ CapabilityBuilder::new("localhost-ipc")
267
+ .remote("http://localhost:8888".to_string())
268
+ .permission("core:default")
269
+ .permission("core:window:default")
270
+ .permission("core:window:allow-close")
271
+ .permission("core:window:allow-minimize")
272
+ .permission("core:window:allow-maximize")
273
+ .permission("core:window:allow-unmaximize")
274
+ .permission("core:window:allow-is-maximized")
275
+ .permission("core:window:allow-start-dragging")
276
+ .permission("core:window:allow-set-focus")
277
+ .permission("core:window:allow-show")
278
+ .permission("core:window:allow-hide")
279
+ .permission("core:event:default")
280
+ .window("*")
281
+ )?;
282
+
283
+ // ── Start services if not already running ────────────────────
284
+ let server_up = std::net::TcpStream::connect("127.0.0.1:8888").is_ok();
285
+
286
+ if !server_up {
287
+ let started = start_services();
288
+ if started {
289
+ app.state::<Mutex<AppState>>().lock().unwrap().services_started_by_us = true;
290
+ // Wait for Next.js to be ready
291
+ eprintln!("[genie-os] waiting for server on :8888...");
292
+ if !wait_for_server(30) {
293
+ eprintln!("[genie-os] server did not start in time — opening anyway");
294
+ }
295
+ }
296
+ } else {
297
+ eprintln!("[genie-os] server already running on :8888");
298
+ }
299
+
300
+ // ── Main window: load the web desktop ────────────────────────
301
+ let main_win = WebviewWindowBuilder::new(
302
+ app,
303
+ "main",
304
+ WebviewUrl::External(DESKTOP_URL.parse().unwrap()),
305
+ )
306
+ .title("Genie OS")
307
+ .inner_size(1280.0, 800.0)
308
+ .resizable(true)
309
+ .decorations(false)
310
+ .transparent(true)
311
+ .shadow(false)
312
+ .visible(true)
313
+ .build()?;
314
+
315
+ center_on_cursor_monitor(&main_win);
316
+
317
+ // ── Tray icon ────────────────────────────────────────────────
318
+ let toggle_dock_item = MenuItemBuilder::with_id("toggle_main", "Show/Hide")
319
+ .build(app)?;
320
+ let new_terminal = MenuItemBuilder::with_id("new_terminal", "New Terminal")
321
+ .build(app)?;
322
+ let settings = MenuItemBuilder::with_id("settings", "Settings")
323
+ .build(app)?;
324
+ let quit_item = MenuItemBuilder::with_id("quit", "Quit Genie OS")
325
+ .build(app)?;
326
+
327
+ let tray_menu = MenuBuilder::new(app)
328
+ .item(&toggle_dock_item)
329
+ .separator()
330
+ .item(&new_terminal)
331
+ .item(&settings)
332
+ .separator()
333
+ .item(&quit_item)
334
+ .build()?;
335
+
336
+ let _tray = TrayIconBuilder::new()
337
+ .icon(app.default_window_icon().cloned().unwrap())
338
+ .icon_as_template(true)
339
+ .menu(&tray_menu)
340
+ .tooltip("Genie OS")
341
+ .on_menu_event(move |app_handle, event| {
342
+ match event.id().as_ref() {
343
+ "toggle_main" => {
344
+ if let Some(win) = app_handle.get_webview_window("main") {
345
+ if win.is_visible().unwrap_or(false) {
346
+ let _ = win.hide();
347
+ } else {
348
+ let _ = win.show();
349
+ let _ = win.set_focus();
350
+ }
351
+ }
352
+ }
353
+ "new_terminal" => {
354
+ open_app_window(
355
+ app_handle.clone(),
356
+ "terminal".to_string(),
357
+ Some("Terminal".to_string()),
358
+ None,
359
+ );
360
+ }
361
+ "settings" => {
362
+ open_app_window(
363
+ app_handle.clone(),
364
+ "settings".to_string(),
365
+ Some("Settings".to_string()),
366
+ None,
367
+ );
368
+ }
369
+ "quit" => {
370
+ // Stop services if we started them
371
+ if let Some(state) = app_handle.try_state::<Mutex<AppState>>() {
372
+ if state.lock().unwrap().services_started_by_us {
373
+ stop_services();
374
+ }
375
+ }
376
+ app_handle.exit(0);
377
+ }
378
+ _ => {}
379
+ }
380
+ })
381
+ .build(app)?;
382
+
383
+ Ok(())
384
+ })
385
+ .build(tauri::generate_context!())
386
+ .expect("error building genie-os")
387
+ .run(|app, event| {
388
+ if let tauri::RunEvent::ExitRequested { .. } = event {
389
+ if let Some(state) = app.try_state::<Mutex<AppState>>() {
390
+ if state.lock().unwrap().services_started_by_us {
391
+ stop_services();
392
+ }
393
+ }
394
+ }
395
+ });
396
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "productName": "Genie OS",
3
+ "version": "0.1.0",
4
+ "identifier": "ai.automagik.genie-os",
5
+ "build": {
6
+ "frontendDist": "../dist",
7
+ "beforeDevCommand": "",
8
+ "beforeBuildCommand": ""
9
+ },
10
+ "app": {
11
+ "macOSPrivateApi": true,
12
+ "withGlobalTauri": true,
13
+ "windows": [],
14
+ "security": {
15
+ "csp": "default-src 'self' http://localhost:8888 ws://localhost:* wss://localhost:* ipc: tauri:; style-src 'self' 'unsafe-inline' http://localhost:8888; script-src 'self' 'unsafe-inline' 'unsafe-eval' http://localhost:8888; img-src 'self' data: http://localhost:8888; connect-src 'self' http://localhost:* ws://localhost:* wss://localhost:* ipc: tauri:; font-src 'self' http://localhost:8888 data:"
16
+ }
17
+ },
18
+ "plugins": {
19
+ "shell": {
20
+ "open": true
21
+ }
22
+ }
23
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": [
5
+ "dom",
6
+ "dom.iterable",
7
+ "esnext"
8
+ ],
9
+ "allowJs": true,
10
+ "skipLibCheck": true,
11
+ "strict": true,
12
+ "noEmit": true,
13
+ "esModuleInterop": true,
14
+ "module": "esnext",
15
+ "moduleResolution": "bundler",
16
+ "resolveJsonModule": true,
17
+ "isolatedModules": true,
18
+ "jsx": "react-jsx",
19
+ "incremental": true,
20
+ "plugins": [
21
+ {
22
+ "name": "next"
23
+ }
24
+ ],
25
+ "paths": {
26
+ "@/*": [
27
+ "./src/*"
28
+ ]
29
+ }
30
+ },
31
+ "include": [
32
+ "next-env.d.ts",
33
+ "**/*.ts",
34
+ "**/*.tsx",
35
+ "**/*.mts",
36
+ ".next/types/**/*.ts",
37
+ ".next/dev/types/**/*.ts"
38
+ ],
39
+ "exclude": [
40
+ "node_modules",
41
+ ".next"
42
+ ]
43
+ }