moi-computer 0.12.0 → 0.12.1-next.1

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 (367) hide show
  1. package/README.md +27 -27
  2. package/bin/moi.mjs +2 -2
  3. package/client/AGENTS.md +7 -4
  4. package/client/api/app-config.ts +3 -2
  5. package/client/api/app-ui-keys.ts +1 -1
  6. package/client/api/workspace-keys.ts +2 -4
  7. package/client/app/{AppRouter.tsx → app-router.tsx} +4 -4
  8. package/client/app/routes/{HomeRoute.tsx → home-route.tsx} +2 -2
  9. package/client/app/routes/{WorkspaceRoute.tsx → workspace-route.tsx} +20 -31
  10. package/client/app/shell/{SidebarLayout.tsx → sidebar-layout.tsx} +10 -10
  11. package/client/dev/index.html +43 -0
  12. package/client/dev/index.ts +15 -0
  13. package/client/features/applets/{AppletContainer.tsx → applet-container.tsx} +1 -1
  14. package/client/features/applets/applet-runtime.ts +11 -13
  15. package/client/features/applets/applet-thumbnail.ts +1 -1
  16. package/client/features/applets/{useApplet.ts → use-applet.ts} +2 -2
  17. package/client/features/applets/{WidgetShell.tsx → widget-shell.tsx} +4 -4
  18. package/client/features/chat/applet-chat-intents.ts +33 -14
  19. package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +80 -59
  20. package/client/features/chat/chat-popup.tsx +171 -0
  21. package/client/features/chat/chat-send.ts +33 -1
  22. package/client/features/chat/chat-store.ts +10 -0
  23. package/client/features/chat/composer/attachments/{DrawingAttachmentChip.tsx → drawing-attachment-chip.tsx} +1 -1
  24. package/client/features/chat/composer/attachments/{FileAttachmentChip.tsx → file-attachment-chip.tsx} +1 -1
  25. package/client/features/chat/composer/attachments/{TextAttachmentChip.tsx → text-attachment-chip.tsx} +1 -1
  26. package/client/features/chat/composer/banners/{ComposerBanner.tsx → composer-banner.tsx} +0 -14
  27. package/client/features/chat/composer/banners/{ErrorBanner.tsx → error-banner.tsx} +1 -1
  28. package/client/features/chat/composer/banners/{SkillUpdateBanner.tsx → skill-update-banner.tsx} +3 -3
  29. package/client/features/chat/composer/{ChatComposer.tsx → chat-composer.tsx} +31 -33
  30. package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +4 -4
  31. package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +14 -30
  32. package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
  33. package/client/features/chat/connection/chat-frames.ts +15 -8
  34. package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +37 -23
  35. package/client/features/chat/messages/fork-history.ts +14 -0
  36. package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +4 -4
  37. package/client/features/chat/messages/tool-group/index.ts +1 -1
  38. package/client/features/chat/messages/tool-group/{ReadImagePreview.tsx → read-image-preview.tsx} +2 -2
  39. package/client/features/chat/messages/tool-group/{SubagentCard.tsx → subagent-card.tsx} +3 -3
  40. package/client/features/chat/messages/tool-group/{TimelineRow.tsx → timeline-row.tsx} +1 -1
  41. package/client/features/chat/messages/tool-group/{ToolCallGroup.tsx → tool-call-group.tsx} +8 -8
  42. package/client/features/chat/messages/tool-group/{ToolOutput.tsx → tool-output.tsx} +1 -1
  43. package/client/features/chat/messages/{TurnView.tsx → turn-view.tsx} +4 -4
  44. package/client/features/chat/sessions/api.ts +109 -19
  45. package/client/features/chat/sessions/browser-tab-state.ts +30 -7
  46. package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +139 -80
  47. package/client/features/chat/sessions/use-selected-session.ts +351 -0
  48. package/client/features/chat/{useChat.ts → use-chat.ts} +46 -48
  49. package/client/features/collab/client.ts +10 -11
  50. package/client/features/collab/hooks.tsx +6 -11
  51. package/client/features/collab/host-state.ts +57 -128
  52. package/client/features/collab/provider.tsx +3 -3
  53. package/client/features/collab/proxy-user.ts +1 -1
  54. package/client/features/collab/testing/fake-engine.ts +6 -27
  55. package/client/features/collab/workspace-users-menu.tsx +3 -7
  56. package/client/features/connectors/mcp-icons.ts +1 -1
  57. package/client/features/connectors/{McpServerCards.tsx → mcp-server-cards.tsx} +1 -1
  58. package/client/features/{home/workspace-setup/DemoDialog.tsx → demo/demo-dialog.tsx} +6 -6
  59. package/client/features/dev/chat-states-fixtures.ts +4 -4
  60. package/client/features/dev/{ChatStatesPage.tsx → chat-states-page.tsx} +6 -6
  61. package/client/features/dev/collab/local-user-settings.tsx +4 -4
  62. package/client/features/dev/{DevIndexPage.tsx → dev-index-page.tsx} +7 -1
  63. package/client/features/dev/{DevRoutes.tsx → dev-routes.tsx} +8 -6
  64. package/client/features/dev/workspace-setup-mocks.ts +102 -0
  65. package/client/features/dev/workspace-setup-page.tsx +11 -0
  66. package/client/features/dev/workspace-setup-preview.tsx +226 -0
  67. package/client/features/drawings/{DrawingToolbar.tsx → drawing-toolbar.tsx} +1 -1
  68. package/client/features/drawings/{useChatAnnotation.ts → use-chat-annotation.ts} +29 -23
  69. package/client/features/drawings/{useDrawingLayer.ts → use-drawing-layer.ts} +1 -1
  70. package/client/features/drawings/{useViewBuilderSketch.ts → use-view-sketch.ts} +8 -8
  71. package/client/features/harness/api.ts +36 -0
  72. package/client/features/harness/device-login-steps.tsx +97 -0
  73. package/client/features/home/api.ts +1 -81
  74. package/client/features/home/{HomeLogo.tsx → home-logo.tsx} +1 -1
  75. package/client/features/home/{HomePage.tsx → home-page.tsx} +16 -20
  76. package/client/features/overview/api.ts +2 -2
  77. package/client/features/overview/default/registry.tsx +3 -5
  78. package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +6 -13
  79. package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
  80. package/client/features/overview/{Overview.tsx → overview.tsx} +9 -12
  81. package/client/features/overview/{WidgetCanvas.tsx → widget-canvas.tsx} +1 -1
  82. package/client/features/overview/{WidgetFrame.tsx → widget-frame.tsx} +1 -1
  83. package/client/features/overview/workspace-name.tsx +55 -0
  84. package/client/features/scratchpad/{Scratchpad.tsx → scratchpad.tsx} +7 -7
  85. package/client/features/scratchpad/{useScratchpadSnapshot.tsx → use-scratchpad-snapshot.tsx} +3 -3
  86. package/client/features/settings/api.ts +1 -1
  87. package/client/features/settings/{ConnectorsSettings.tsx → connectors-settings.tsx} +3 -3
  88. package/client/features/settings/{EnvironmentSettings.tsx → environment-settings.tsx} +3 -3
  89. package/client/features/settings/{GeneralSettings.tsx → general-settings.tsx} +5 -5
  90. package/client/features/settings/{useEnvVars.ts → use-env-vars.ts} +1 -1
  91. package/client/features/settings/{WorkspaceIconPicker.tsx → workspace-icon-picker.tsx} +1 -1
  92. package/client/features/settings/{WorkspaceSettingsDialog.tsx → workspace-settings-dialog.tsx} +3 -3
  93. package/client/features/update/api.ts +1 -1
  94. package/client/features/views/api.ts +64 -131
  95. package/client/features/views/pending-view-screen.tsx +282 -0
  96. package/client/features/views/use-view-actions.ts +151 -0
  97. package/client/features/views/use-view-drafts.ts +88 -0
  98. package/client/features/views/{ViewManager.tsx → view-manager.tsx} +13 -13
  99. package/client/features/views/view-presentation.ts +4 -5
  100. package/client/features/views/view-submission.ts +88 -0
  101. package/client/features/workspace/add/api.ts +80 -0
  102. package/client/features/{home/workspace-setup/CreateWorkspaceDialog.tsx → workspace/add/create-workspace-dialog.tsx} +56 -42
  103. package/client/features/workspace/add/import-workspace-dialog.tsx +81 -0
  104. package/client/features/{home/workspace-setup/useWorkspaceImport.ts → workspace/add/use-workspace-import.ts} +1 -1
  105. package/client/features/workspace/add/workspace-agent-options.ts +53 -0
  106. package/client/features/{home/workspace-setup/WorkspaceAgentStep.tsx → workspace/add/workspace-agent-selector.tsx} +59 -98
  107. package/client/features/{home/workspace-setup/WorkspaceDialogContent.tsx → workspace/add/workspace-dialog-content.tsx} +1 -1
  108. package/client/features/workspace/api.ts +24 -15
  109. package/client/features/workspace/browser-tab-state.ts +16 -9
  110. package/client/features/workspace/moi-context.ts +14 -16
  111. package/client/features/workspace/setup/workspace-login-state.tsx +175 -0
  112. package/client/features/workspace/setup/workspace-recovery-states.tsx +125 -0
  113. package/client/features/workspace/setup/workspace-setup-panel.tsx +18 -0
  114. package/client/features/workspace/setup/workspace-setup.tsx +77 -0
  115. package/client/features/workspace/setup/workspace-welcome-state.tsx +81 -0
  116. package/client/features/workspace/tab-resolution.ts +16 -29
  117. package/client/features/workspace/{ThemePanel.tsx → theme-panel.tsx} +3 -3
  118. package/client/features/workspace/use-workspace-navigation.ts +245 -0
  119. package/client/features/workspace/workspace-content.tsx +641 -0
  120. package/client/features/workspace/workspace-identity.tsx +40 -0
  121. package/client/features/workspace/workspace-menu.tsx +63 -0
  122. package/client/features/{home → workspace}/workspace-presentation.tsx +10 -3
  123. package/client/features/workspace/workspace-screen.tsx +28 -0
  124. package/client/features/workspace/{WorkspaceSplitLayout.tsx → workspace-split-layout.tsx} +1 -1
  125. package/client/features/workspace/{WorkspaceTabs.tsx → workspace-tabs.tsx} +2 -2
  126. package/client/index.css +2 -2
  127. package/client/index.html +1 -1
  128. package/client/index.tsx +5 -1
  129. package/client/lib/agent-availability.ts +0 -5
  130. package/client/main.tsx +1 -1
  131. package/client/runtime/{useWorkspaceEvents.ts → use-workspace-events.ts} +10 -18
  132. package/client/store/ui.ts +25 -29
  133. package/dist/chunk-08ndj2rg.js +2 -0
  134. package/dist/chunk-2x040tmg.js +68 -0
  135. package/dist/chunk-3smxq0ts.js +1 -0
  136. package/dist/chunk-68ch5hs8.js +2 -0
  137. package/dist/{chunk-z3byfve5.js → chunk-9vg3xa81.js} +2 -2
  138. package/dist/chunk-c2p00p9j.css +1 -0
  139. package/dist/chunk-cs833y9j.js +1 -0
  140. package/dist/{chunk-97eg9mjn.js → chunk-d7cbm65e.js} +1 -1
  141. package/dist/{chunk-efdyz6xp.js → chunk-hvh9f5h0.js} +1 -1
  142. package/dist/{chunk-vfpsc75k.js → chunk-jvyvwwv3.js} +1 -1
  143. package/dist/chunk-nwevqe86.js +10 -0
  144. package/dist/{chunk-3a48fyf7.js → chunk-q0gbdts4.js} +4 -4
  145. package/dist/chunk-rt30jbcm.js +1 -0
  146. package/dist/chunk-y5y3kj67.js +1 -0
  147. package/dist/index.html +2 -2
  148. package/lib/format.ts +1 -1
  149. package/lib/harness-instructions.ts +30 -0
  150. package/lib/ids.ts +3 -6
  151. package/lib/moi-context.ts +102 -75
  152. package/lib/navigation.ts +48 -87
  153. package/lib/scratchpad-skew.ts +3 -3
  154. package/lib/session-drafts.ts +10 -0
  155. package/lib/types.ts +92 -51
  156. package/lib/update.ts +1 -1
  157. package/lib/view-build-directives.ts +12 -0
  158. package/lib/workspace-layout.ts +1 -1
  159. package/lib/workspace-tabs.ts +12 -7
  160. package/package.json +7 -2
  161. package/server/AGENTS.md +10 -4
  162. package/server/README.md +102 -0
  163. package/server/agent-launcher.ts +27 -0
  164. package/server/api/harnesses.ts +56 -0
  165. package/server/{api.ts → api/index.ts} +197 -299
  166. package/server/app-config.ts +45 -14
  167. package/server/app-settings.ts +1 -1
  168. package/server/applets/applet-css.ts +1 -1
  169. package/server/applets/build-applet.ts +4 -4
  170. package/server/applets/build-worker.ts +3 -2
  171. package/server/applets/config.ts +1 -1
  172. package/server/{functions-worker.ts → applets/functions-worker.ts} +1 -1
  173. package/server/{functions.ts → applets/functions.ts} +3 -2
  174. package/server/applets/index.ts +2 -2
  175. package/server/{thumbnails.ts → applets/thumbnails.ts} +1 -1
  176. package/server/{applet-typecheck.ts → applets/typecheck.ts} +4 -4
  177. package/server/{ui-components.ts → applets/ui-components.ts} +2 -2
  178. package/server/applets/view-source.ts +7 -1
  179. package/server/{views.ts → applets/views.ts} +35 -46
  180. package/server/{widgets.ts → applets/widgets.ts} +2 -2
  181. package/server/cli/applet-selector.ts +19 -0
  182. package/server/cli/args.ts +5 -0
  183. package/server/{cli-colors.ts → cli/colors.ts} +1 -1
  184. package/server/cli/commands/bundle.ts +119 -0
  185. package/server/cli/commands/call-server-fn.ts +42 -0
  186. package/server/cli/commands/check.ts +53 -0
  187. package/server/cli/commands/config.ts +132 -0
  188. package/server/cli/commands/debug.ts +119 -0
  189. package/server/cli/commands/env.ts +162 -0
  190. package/server/cli/commands/hermes.ts +149 -0
  191. package/server/cli/commands/init.ts +286 -0
  192. package/server/cli/commands/navigate.ts +35 -0
  193. package/server/cli/commands/openclaw.ts +168 -0
  194. package/server/cli/commands/refresh.ts +39 -0
  195. package/server/cli/commands/scratch.ts +496 -0
  196. package/server/cli/commands/service.ts +298 -0
  197. package/server/cli/commands/skill.ts +122 -0
  198. package/server/cli/commands/start.ts +138 -0
  199. package/server/cli/commands/status.ts +80 -0
  200. package/server/cli/commands/tabs.ts +43 -0
  201. package/server/cli/commands/theme.ts +192 -0
  202. package/server/cli/commands/ui-components.ts +15 -0
  203. package/server/cli/commands/update.ts +192 -0
  204. package/server/cli/commands/version.ts +9 -0
  205. package/server/cli/commands/views.ts +87 -0
  206. package/server/cli/control.ts +89 -0
  207. package/server/{cli-env.ts → cli/env.ts} +78 -56
  208. package/server/cli/index.ts +171 -0
  209. package/server/{cli-pc.ts → cli/pc.ts} +1 -1
  210. package/server/cli/provider.ts +25 -0
  211. package/server/cli/server-version.ts +16 -0
  212. package/server/cli/server.ts +81 -0
  213. package/server/{cli-ui-components.ts → cli/ui-components.ts} +5 -5
  214. package/server/cli.ts +2 -3215
  215. package/server/collab/manager.ts +3 -3
  216. package/server/collab/skill/index.ts +2 -2
  217. package/server/control.ts +97 -78
  218. package/server/data-dir.ts +13 -0
  219. package/server/harness/README.md +55 -25
  220. package/server/harness/acp/NOTES.md +11 -11
  221. package/server/harness/acp/adapter.ts +2 -2
  222. package/server/harness/acp/archived.ts +3 -3
  223. package/server/harness/acp/client.ts +4 -3
  224. package/server/harness/acp/discovery.ts +3 -3
  225. package/server/harness/acp/run-durations.ts +1 -1
  226. package/server/harness/acp/session.ts +9 -12
  227. package/server/harness/auth.ts +303 -0
  228. package/server/harness/claude-code/NOTES.md +9 -7
  229. package/server/harness/claude-code/adapter.ts +13 -8
  230. package/server/harness/claude-code/auth.ts +127 -18
  231. package/server/harness/claude-code/cli.ts +3 -1
  232. package/server/harness/claude-code/git-worktree.ts +5 -2
  233. package/server/harness/claude-code/index.ts +7 -1
  234. package/server/harness/claude-code/mcp.ts +3 -1
  235. package/server/harness/claude-code/models.ts +2 -0
  236. package/server/harness/claude-code/session.ts +13 -39
  237. package/server/harness/claude-code/sessions.ts +8 -12
  238. package/server/harness/codex/NOTES.md +35 -16
  239. package/server/harness/codex/adapter.ts +5 -3
  240. package/server/harness/codex/auth.ts +86 -19
  241. package/server/harness/codex/client.ts +30 -34
  242. package/server/harness/codex/index.ts +20 -1
  243. package/server/harness/codex/permissions.ts +3 -3
  244. package/server/harness/codex/probe.ts +3 -5
  245. package/server/harness/codex/session.ts +20 -25
  246. package/server/harness/codex/thread-list.ts +74 -0
  247. package/server/harness/codex/transport.ts +5 -5
  248. package/server/harness/executable.ts +42 -18
  249. package/server/harness/fork.ts +12 -0
  250. package/server/harness/hermes/NOTES.md +70 -70
  251. package/server/harness/hermes/discovery.ts +1 -1
  252. package/server/harness/openclaw/NOTES.md +24 -24
  253. package/server/harness/openclaw/adapter.ts +4 -4
  254. package/server/harness/openclaw/compat.ts +1 -1
  255. package/server/harness/openclaw/session.ts +6 -31
  256. package/server/harness/registry.ts +1 -1
  257. package/server/harness/session-title.ts +12 -3
  258. package/server/harness/shell-path.ts +31 -21
  259. package/server/harness/types.ts +17 -5
  260. package/server/navigation-relay.ts +1 -1
  261. package/server/open-browser.ts +7 -0
  262. package/server/{scratchpad-assets.ts → scratchpad/assets.ts} +4 -4
  263. package/server/{scratchpad.ts → scratchpad/document.ts} +8 -8
  264. package/server/{scratchpad-executor.ts → scratchpad/executor.ts} +7 -7
  265. package/server/{scratchpad-relay.ts → scratchpad/relay.ts} +4 -5
  266. package/server/{scratchpad-shape-defaults.ts → scratchpad/shape-defaults.ts} +2 -2
  267. package/server/server-cwd.ts +1 -1
  268. package/server/service.ts +18 -4
  269. package/server/sessions/archive.ts +32 -0
  270. package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
  271. package/server/sessions/config.ts +41 -0
  272. package/server/sessions/lifecycle.ts +17 -0
  273. package/server/sessions/pending-views.ts +164 -0
  274. package/server/sessions/selected.ts +199 -0
  275. package/server/sessions/store.ts +127 -0
  276. package/server/sessions/view-sessions.ts +267 -0
  277. package/server/{skills-template.ts → skills/template.ts} +1 -1
  278. package/server/{skill-update.ts → skills/update.ts} +5 -5
  279. package/server/{skill-version.ts → skills/version.ts} +4 -4
  280. package/server/static.ts +1 -1
  281. package/server/status.ts +6 -4
  282. package/server/web.ts +58 -49
  283. package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
  284. package/server/{workspace-env.ts → workspaces/env.ts} +30 -3
  285. package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
  286. package/server/{workspace-init.ts → workspaces/init.ts} +10 -6
  287. package/server/{layout.ts → workspaces/layout.ts} +2 -2
  288. package/server/{preview.ts → workspaces/preview.ts} +1 -1
  289. package/server/{registry.ts → workspaces/registry.ts} +17 -7
  290. package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
  291. package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +4 -3
  292. package/server/{tabs.ts → workspaces/tabs.ts} +7 -10
  293. package/ui-components/button.tsx +1 -1
  294. package/ui-components/docs/attachment.md +2 -2
  295. package/ui-components/docs/button.md +1 -1
  296. package/ui-components/docs/calendar.md +1 -1
  297. package/ui-components/docs/chart.md +4 -4
  298. package/ui-components/docs/data-table.md +1 -1
  299. package/ui-components/docs/drawer.md +1 -1
  300. package/ui-components/docs/field.md +1 -1
  301. package/ui-components/docs/input.md +2 -2
  302. package/ui-components/docs/label.md +2 -2
  303. package/ui-components/docs/table.md +2 -2
  304. package/workspace/.claude/skills/moi-workspace/SKILL.md +61 -32
  305. package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +4 -7
  306. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +2 -2
  307. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +2 -2
  308. package/client/features/chat/ChatPopup.tsx +0 -98
  309. package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +0 -101
  310. package/client/features/chat/sessions/useSelectedSession.ts +0 -185
  311. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
  312. package/client/features/overview/WorkspaceName.tsx +0 -60
  313. package/client/features/views/ViewBuilder.tsx +0 -239
  314. package/client/features/views/useViewBuilderActions.ts +0 -103
  315. package/client/features/views/useViewBuilderDrafts.ts +0 -68
  316. package/client/features/workspace/WorkspaceScreen.tsx +0 -839
  317. package/client/features/workspace/useWorkspaceNavigation.ts +0 -203
  318. package/dist/chunk-2jncyq65.js +0 -1
  319. package/dist/chunk-e2q5ken7.js +0 -68
  320. package/dist/chunk-h2kj1ysj.js +0 -1
  321. package/dist/chunk-jf6czgrz.js +0 -2
  322. package/dist/chunk-nez8sdta.js +0 -1
  323. package/dist/chunk-nzwgm8vc.css +0 -1
  324. package/dist/chunk-ph0h6h86.js +0 -1
  325. package/dist/chunk-ryg9z3kn.js +0 -10
  326. package/dist/chunk-tpn177bt.js +0 -2
  327. package/lib/view-builder-directives.ts +0 -16
  328. package/server/agent.ts +0 -223
  329. package/server/chat-selection.ts +0 -22
  330. package/server/selected-session.ts +0 -152
  331. package/server/session-config.ts +0 -136
  332. package/server/view-builders.ts +0 -453
  333. /package/client/components/shared/{AgentBlobatar.tsx → agent-blobatar.tsx} +0 -0
  334. /package/client/components/shared/{BottomPanel.tsx → bottom-panel.tsx} +0 -0
  335. /package/client/components/shared/{Composer.tsx → composer.tsx} +0 -0
  336. /package/client/components/shared/{LedLogo.tsx → led-logo.tsx} +0 -0
  337. /package/client/components/shared/{PanelHeader.tsx → panel-header.tsx} +0 -0
  338. /package/client/components/shared/{ReorderableList.tsx → reorderable-list.tsx} +0 -0
  339. /package/client/components/shared/{WorkspaceIcon.tsx → workspace-icon.tsx} +0 -0
  340. /package/client/features/applets/{WidgetErrorBoundary.tsx → widget-error-boundary.tsx} +0 -0
  341. /package/client/features/chat/composer/attachments/{AttachmentChip.tsx → attachment-chip.tsx} +0 -0
  342. /package/client/features/chat/messages/{ChatPromptBubbles.tsx → chat-prompt-bubbles.tsx} +0 -0
  343. /package/client/features/chat/messages/{ShimmerText.tsx → shimmer-text.tsx} +0 -0
  344. /package/client/features/chat/messages/tool-group/{CodeBlock.tsx → code-block.tsx} +0 -0
  345. /package/client/features/chat/messages/tool-group/{Collapse.tsx → collapse.tsx} +0 -0
  346. /package/client/features/chat/messages/{useStickToBottom.ts → use-stick-to-bottom.ts} +0 -0
  347. /package/client/features/connectors/{IconMcp.tsx → icon-mcp.tsx} +0 -0
  348. /package/client/features/dev/{BlobatarShapesPage.tsx → blobatar-shapes-page.tsx} +0 -0
  349. /package/client/features/dev/{HarnessDebugPage.tsx → harness-debug-page.tsx} +0 -0
  350. /package/client/features/dev/{TextureLabPage.tsx → texture-lab-page.tsx} +0 -0
  351. /package/client/features/dev/{ToolCallsPage.tsx → tool-calls-page.tsx} +0 -0
  352. /package/client/features/drawings/{DrawingLayer.tsx → drawing-layer.tsx} +0 -0
  353. /package/client/features/home/{WorkspacePreview.tsx → workspace-preview.tsx} +0 -0
  354. /package/client/features/overview/{useGridReconcile.ts → use-grid-reconcile.ts} +0 -0
  355. /package/client/features/scratchpad/{ScratchpadControls.tsx → scratchpad-controls.tsx} +0 -0
  356. /package/client/features/settings/{SettingsLayout.tsx → settings-layout.tsx} +0 -0
  357. /package/client/features/update/{UpdateControl.tsx → update-control.tsx} +0 -0
  358. /package/client/features/workspace/{UnavailablePage.tsx → unavailable-page.tsx} +0 -0
  359. /package/client/features/workspace/{useFitsSplitLayout.ts → use-fits-split-layout.ts} +0 -0
  360. /package/client/features/workspace/{WorkspaceContext.tsx → workspace-context.tsx} +0 -0
  361. /package/client/features/workspace/{WorkspaceLayoutContext.tsx → workspace-layout-context.tsx} +0 -0
  362. /package/server/{bundle-queue.ts → applets/bundle-queue.ts} +0 -0
  363. /package/server/{applet-log.ts → applets/log.ts} +0 -0
  364. /package/server/{cli-ui.ts → cli/ui.ts} +0 -0
  365. /package/server/{workspace-config.ts → workspaces/config.ts} +0 -0
  366. /package/server/{icon.ts → workspaces/icon.ts} +0 -0
  367. /package/server/{theme.ts → workspaces/theme.ts} +0 -0
@@ -0,0 +1,298 @@
1
+ import { defineCommand } from 'citty'
2
+ import { existsSync } from 'node:fs'
3
+ import { dirname } from 'path'
4
+ import {
5
+ analyzeInstall,
6
+ captureServiceEnv,
7
+ installService,
8
+ queryServerInfo,
9
+ restartService,
10
+ ServiceError,
11
+ serviceLogPath,
12
+ serviceStatus,
13
+ uninstallService,
14
+ webAddress
15
+ } from '../../service'
16
+ import { isServerRunning } from '../control'
17
+ import pc from '../pc'
18
+ import { versionMismatchNotice } from '../server-version'
19
+
20
+ function serviceFail(err: unknown): never {
21
+ const message = err instanceof ServiceError ? err.message : String(err)
22
+ console.error('\n' + pc.red('✗') + ' ' + message + '\n')
23
+ process.exit(1)
24
+ }
25
+
26
+ // Shared success line after install/restart: did the server actually come up,
27
+ // and on which version?
28
+ function printServiceServer(info: Awaited<ReturnType<typeof queryServerInfo>>) {
29
+ if (info) {
30
+ console.log(
31
+ ' server ' +
32
+ pc.bold(`v${info.version}`) +
33
+ ` running on ${webAddress(info)}` +
34
+ pc.dim(` (pid ${info.pid})`)
35
+ )
36
+ const mismatch = versionMismatchNotice(info.version)
37
+ if (mismatch) console.log('\n' + mismatch)
38
+ } else {
39
+ console.log(
40
+ ' ' +
41
+ pc.yellow('server did not come up — check `moi service logs`') +
42
+ pc.dim(' (it may still be starting)')
43
+ )
44
+ }
45
+ }
46
+
47
+ const serviceInstall = defineCommand({
48
+ meta: {
49
+ name: 'install',
50
+ description: 'Install and start the user service (launchd on macOS, systemd on Linux)'
51
+ },
52
+ args: {
53
+ port: { type: 'string', description: 'HTTP port for the service server (default: 13337)' },
54
+ env: {
55
+ type: 'string',
56
+ description:
57
+ 'Extra env var names to capture from this shell, comma-separated (e.g. --env MY_TOKEN,OTHER)'
58
+ }
59
+ },
60
+ async run({ args }) {
61
+ // Check the install shape first: telling someone to stop their server only
62
+ // to then refuse the checkout would be a pointless round-trip.
63
+ const analysis = analyzeInstall()
64
+ if (analysis.kind !== 'global') {
65
+ try {
66
+ await installService() // throws the precise refusal for this analysis
67
+ } catch (err) {
68
+ serviceFail(err)
69
+ }
70
+ }
71
+ const port = args.port ? Number(args.port) : undefined
72
+ if (port !== undefined && (!Number.isInteger(port) || port < 1 || port > 65535)) {
73
+ serviceFail(new ServiceError(`Invalid --port value "${args.port}" — use a port number.`))
74
+ }
75
+ // citty hands back an array when the flag repeats — accept both shapes.
76
+ const envArg = Array.isArray(args.env) ? args.env.join(',') : args.env
77
+ const extraEnv = (envArg ?? '')
78
+ .split(',')
79
+ .map(k => k.trim())
80
+ .filter(Boolean)
81
+ const serviceEnv = captureServiceEnv(process.env, dirname(process.execPath), extraEnv)
82
+ const missingEnv = extraEnv.filter(key => !(key in serviceEnv))
83
+ if (missingEnv.length > 0) {
84
+ serviceFail(
85
+ new ServiceError(
86
+ `--env ${missingEnv.join(', ')}: not set in this shell (or the value is not capturable).`
87
+ )
88
+ )
89
+ }
90
+ // A foreground `moi start` holds the same ports the service needs. Refuse
91
+ // rather than install a unit that instantly fails on bind.
92
+ const runningInfo = await queryServerInfo()
93
+ const foreground = (await isServerRunning()) && !runningInfo?.service
94
+ if (foreground) {
95
+ serviceFail(
96
+ new ServiceError(
97
+ 'A foreground server is running' +
98
+ (runningInfo?.pid ? ` (pid ${runningInfo.pid})` : '') +
99
+ '.\n Stop it (Ctrl-C in its terminal), then rerun `moi service install`.'
100
+ )
101
+ )
102
+ }
103
+ try {
104
+ const result = await installService({ port, extraEnv })
105
+ console.log(
106
+ '\n' +
107
+ pc.green('✓') +
108
+ ' Service installed ' +
109
+ pc.dim(`(${process.platform === 'darwin' ? 'launchd' : 'systemd user unit'})`)
110
+ )
111
+ console.log(' unit ' + pc.dim(tildifyPath(result.unitPath)))
112
+ if (result.logPath) console.log(' logs ' + pc.dim(tildifyPath(result.logPath)))
113
+ printServiceServer(result.info)
114
+ console.log(pc.dim('\n Starts on login, restarts on crash, survives reboots.'))
115
+ for (const note of result.notes) console.log(pc.yellow(' ' + note))
116
+ console.log()
117
+ } catch (err) {
118
+ serviceFail(err)
119
+ }
120
+ }
121
+ })
122
+
123
+ const serviceUninstall = defineCommand({
124
+ meta: { name: 'uninstall', description: 'Stop the service and remove its unit' },
125
+ async run() {
126
+ try {
127
+ const { unitPath, existed } = await uninstallService()
128
+ if (!existed) {
129
+ console.log(
130
+ '\n' +
131
+ pc.dim('○') +
132
+ ' Service is not installed ' +
133
+ pc.dim(`(${tildifyPath(unitPath)})`) +
134
+ '\n'
135
+ )
136
+ return
137
+ }
138
+ console.log(
139
+ '\n' + pc.green('✓') + ' Service removed ' + pc.dim(`(${tildifyPath(unitPath)})`) + '\n'
140
+ )
141
+ } catch (err) {
142
+ serviceFail(err)
143
+ }
144
+ }
145
+ })
146
+
147
+ const serviceRestart = defineCommand({
148
+ meta: { name: 'restart', description: 'Restart the service server' },
149
+ async run() {
150
+ try {
151
+ const info = await restartService()
152
+ console.log('\n' + pc.green('✓') + ' Service restarted')
153
+ printServiceServer(info)
154
+ console.log()
155
+ } catch (err) {
156
+ serviceFail(err)
157
+ }
158
+ }
159
+ })
160
+
161
+ const serviceLogs = defineCommand({
162
+ meta: { name: 'logs', description: 'Show server logs (journalctl on Linux, log file on macOS)' },
163
+ args: {
164
+ lines: { type: 'string', default: '80', description: 'How many trailing lines to show' },
165
+ follow: {
166
+ type: 'boolean',
167
+ alias: 'f',
168
+ default: false,
169
+ description: 'Keep following new output'
170
+ }
171
+ },
172
+ async run({ args }) {
173
+ const n = Math.max(1, Number(args.lines) || 80)
174
+ if (process.platform === 'linux') {
175
+ // journald owns the log (bounded, rotated). Inherit stdio so -f streams.
176
+ const argv = ['journalctl', '--user', '-u', 'moi.service', '-n', String(n), '--no-pager']
177
+ if (args.follow) argv.push('-f')
178
+ const proc = Bun.spawn(argv, { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit' })
179
+ process.exit(await proc.exited)
180
+ }
181
+ const logPath = serviceLogPath()
182
+ if (!existsSync(logPath)) {
183
+ console.log('\n' + pc.dim('○') + ' No logs yet ' + pc.dim(`(${tildifyPath(logPath)})`) + '\n')
184
+ process.exit(0)
185
+ }
186
+ console.error(pc.dim(tildifyPath(logPath)))
187
+ const proc = Bun.spawn(['tail', '-n', String(n), ...(args.follow ? ['-F'] : []), logPath], {
188
+ stdin: 'inherit',
189
+ stdout: 'inherit',
190
+ stderr: 'inherit'
191
+ })
192
+ process.exit(await proc.exited)
193
+ }
194
+ })
195
+
196
+ function tildifyPath(p: string): string {
197
+ const home = process.env.HOME
198
+ return home && p.startsWith(home) ? '~' + p.slice(home.length) : p
199
+ }
200
+
201
+ async function runServiceStatus() {
202
+ try {
203
+ const s = await serviceStatus()
204
+ const flavor = s.platform === 'darwin' ? 'launchd user agent' : 'systemd user unit'
205
+ console.log('\n' + pc.bold('moi service') + pc.dim(` — ${flavor}`))
206
+ console.log()
207
+ if (!s.installed) {
208
+ console.log(' ' + pc.dim('○') + ' Not installed')
209
+ console.log(
210
+ pc.dim(' Run `moi service install` to start Moi on login and keep it running.')
211
+ )
212
+ console.log()
213
+ process.exit(0)
214
+ }
215
+ const rt = s.runtime
216
+ const stateLabel =
217
+ rt === null
218
+ ? pc.dim('unknown')
219
+ : rt.state === 'running'
220
+ ? pc.green('● running') + (rt.pid ? pc.dim(` (pid ${rt.pid})`) : '')
221
+ : rt.state === 'failed'
222
+ ? pc.red('✗ failed') + pc.dim(rt.detail ? ` (${rt.detail})` : '')
223
+ : rt.state === 'unavailable'
224
+ ? pc.yellow('? unavailable') + pc.dim(rt.detail ? ` — ${rt.detail}` : '')
225
+ : pc.dim('○ ' + rt.state)
226
+ console.log(' state ' + stateLabel)
227
+ console.log(' unit ' + pc.dim(tildifyPath(s.unitPath)))
228
+ if (s.logPath)
229
+ console.log(' logs ' + pc.dim(tildifyPath(s.logPath)) + pc.dim(' (`moi service logs`)'))
230
+ else
231
+ console.log(' logs ' + pc.dim('journalctl --user -u moi.service (`moi service logs`)'))
232
+ const info = await queryServerInfo()
233
+ if (info) {
234
+ console.log(
235
+ ' server ' +
236
+ pc.bold(`v${info.version}`) +
237
+ pc.dim(` on ${webAddress(info)} (pid ${info.pid})`)
238
+ )
239
+ if (!info.service) {
240
+ console.log(
241
+ pc.yellow(' ⚠ The running server is a foreground `moi start`, not the service.')
242
+ )
243
+ }
244
+ } else if (rt?.state === 'running') {
245
+ console.log(' server ' + pc.yellow('unreachable on the control port'))
246
+ }
247
+ console.log()
248
+ if (s.binMissing && s.bin) {
249
+ console.log(
250
+ pc.yellow(` ⚠ The service execs ${s.bin}, which no longer exists`) +
251
+ pc.dim(' (Moi moved or was reinstalled elsewhere).') +
252
+ '\n' +
253
+ pc.dim(' Rerun `moi service install` to re-capture paths.')
254
+ )
255
+ }
256
+ if (s.bunMissing) {
257
+ console.log(
258
+ pc.yellow(' ⚠ No bun on the service PATH — the server cannot start.') +
259
+ '\n' +
260
+ pc.dim(' Reinstall bun, then rerun `moi service install`.')
261
+ )
262
+ }
263
+ if (s.linger === 'disabled') {
264
+ console.log(
265
+ pc.yellow(' ⚠ Lingering is off — the service stops when your last session ends.') +
266
+ '\n' +
267
+ pc.dim(' Enable: loginctl enable-linger')
268
+ )
269
+ }
270
+ const mismatch = info ? versionMismatchNotice(info.version) : null
271
+ if (mismatch) console.log(mismatch.replace(/^/gm, ' ').replace(/^ {2}⚠/, ' ⚠') + '\n')
272
+ process.exit(0)
273
+ } catch (err) {
274
+ serviceFail(err)
275
+ }
276
+ }
277
+
278
+ const serviceSubCommands = {
279
+ install: serviceInstall,
280
+ uninstall: serviceUninstall,
281
+ restart: serviceRestart,
282
+ logs: serviceLogs
283
+ }
284
+
285
+ export const service = defineCommand({
286
+ meta: {
287
+ name: 'service',
288
+ description: 'Run Moi as a user service: `moi service install|uninstall|restart|logs`'
289
+ },
290
+ subCommands: serviceSubCommands,
291
+ async run({ rawArgs }) {
292
+ // citty invokes the parent run even after dispatching a subcommand — only
293
+ // show status when none ran (same pattern as `moi env` / `moi tabs`).
294
+ const sub = rawArgs.find(a => !a.startsWith('-'))
295
+ if (sub && Object.hasOwn(serviceSubCommands, sub)) return
296
+ await runServiceStatus()
297
+ }
298
+ })
@@ -0,0 +1,122 @@
1
+ import type { WorkspaceSkillStatus } from '@/lib/types'
2
+ import { defineCommand } from 'citty'
3
+ import { resolve } from 'path'
4
+ import { updateWorkspaceSkills } from '../../skills/update'
5
+ import { isBehind, isMinorBehind, resolveWorkspace, skillStatuses } from '../../skills/version'
6
+ import { dirArg } from '../args'
7
+ import pc from '../pc'
8
+ import { columns } from '../ui'
9
+
10
+ // Re-copy bundled skills into a workspace, then report what changed. Pure
11
+ // filesystem op — no running server needed. Resolves the workspace root the
12
+ // same way `moi bundle` does, so it works from `.moi/` or any subdirectory.
13
+ async function runSkillUpdate(cwd: string): Promise<void> {
14
+ // Type-aware: an OpenClaw workspace keeps its skills in `skills/`, so the
15
+ // update must target the same dir the agent actually loads from.
16
+ const { root, type } = await resolveWorkspace(cwd)
17
+ const { before, status, changedSkills, updatedAppletTypes } = await updateWorkspaceSkills(
18
+ root,
19
+ type ?? 'claude-code'
20
+ )
21
+ const after = status.skills
22
+ const heading = changedSkills.length > 0 ? 'Skills updated in ' : 'Skills unchanged in '
23
+
24
+ console.log('\n' + pc.green('✓') + ' ' + heading + pc.bold(root) + '\n')
25
+ printSkillUpdateTable(before, after, changedSkills)
26
+ for (const file of updatedAppletTypes) {
27
+ console.log(pc.dim(' Applet types regenerated: ') + pc.bold(`.moi/${file}\n`))
28
+ }
29
+ }
30
+
31
+ function printSkillUpdateTable(
32
+ before: WorkspaceSkillStatus[],
33
+ after: WorkspaceSkillStatus[],
34
+ changedSkills: string[]
35
+ ): void {
36
+ const changedSkillNames = new Set(changedSkills)
37
+ console.log(
38
+ columns(
39
+ ['skill', 'from', 'to'].map(h => pc.dim(h)),
40
+ after.map(s => {
41
+ const prev = before.find(b => b.name === s.name)?.installed ?? null
42
+ const versionChanged = prev !== s.installed
43
+ const filesChanged = changedSkillNames.has(s.name)
44
+ return [
45
+ s.name,
46
+ prev ?? pc.dim('none'),
47
+ versionChanged
48
+ ? pc.green(s.installed ?? '?')
49
+ : filesChanged
50
+ ? pc.green((s.installed ?? '?') + ' (files changed)')
51
+ : pc.dim((s.installed ?? '?') + ' (no change)')
52
+ ]
53
+ })
54
+ )
55
+ )
56
+ const nextStep =
57
+ changedSkills.length > 0
58
+ ? ` Reload changed skills before using them again: ${changedSkills.join(', ')}.`
59
+ : ' No skill files changed. Keep using the copies already in context.'
60
+ console.log('\n' + pc.dim(nextStep) + '\n')
61
+ }
62
+
63
+ // Colored status label for one skill row: minor+ behind is actionable, a patch
64
+ // gap is informational, otherwise current.
65
+ function skillState(s: WorkspaceSkillStatus): string {
66
+ if (isMinorBehind(s.installed, s.bundled)) return pc.yellow('update available')
67
+ if (isBehind(s.installed, s.bundled)) return pc.dim('patch behind')
68
+ return pc.green('up to date')
69
+ }
70
+
71
+ // `update` and `install` are the same operation under two names (install kept
72
+ // for symmetry with how skills first land in a workspace). `dir` is a `--dir`
73
+ // option, not a positional: citty treats a bare positional on a command that
74
+ // carries subcommands as an unknown subcommand. Reuses the shared `dirArg`.
75
+ const defineSkillUpdate = (name: string, description: string) =>
76
+ defineCommand({
77
+ meta: { name, description },
78
+ args: { dir: dirArg },
79
+ async run({ args }) {
80
+ await runSkillUpdate(resolve(args.dir))
81
+ }
82
+ })
83
+
84
+ const skillSubCommands = {
85
+ update: defineSkillUpdate(
86
+ 'update',
87
+ 'Update this workspace’s skills to the version shipped with the CLI'
88
+ ),
89
+ install: defineSkillUpdate('install', 'Alias for `moi skill update`')
90
+ }
91
+
92
+ export const skill = defineCommand({
93
+ meta: { name: 'skill', description: 'Show or update the workspace skills shipped with Moi' },
94
+ subCommands: skillSubCommands,
95
+ args: { dir: dirArg },
96
+ async run({ args, rawArgs }) {
97
+ // citty runs this parent handler even after dispatching a subcommand, so
98
+ // bail when one was given — otherwise `moi skill update` also prints status.
99
+ const sub = rawArgs.find(a => !a.startsWith('-'))
100
+ if (sub && sub in skillSubCommands) return
101
+
102
+ const { root, type } = await resolveWorkspace(resolve(args.dir))
103
+ const statuses = await skillStatuses(root, type)
104
+
105
+ console.log('\n' + pc.bold('moi skill') + pc.dim(' — workspace skills') + '\n')
106
+ console.log(
107
+ columns(
108
+ ['skill', 'installed', 'bundled', 'status'].map(h => pc.dim(h)),
109
+ statuses.map(s => [
110
+ s.name,
111
+ s.installed ?? pc.dim('—'),
112
+ s.bundled ?? pc.dim('—'),
113
+ skillState(s)
114
+ ])
115
+ )
116
+ )
117
+ if (statuses.some(s => isBehind(s.installed, s.bundled))) {
118
+ console.log('\n' + pc.dim(' Run ') + pc.bold('moi skill update') + pc.dim(' to refresh.'))
119
+ }
120
+ console.log()
121
+ }
122
+ })
@@ -0,0 +1,138 @@
1
+ import type { ExperimentalFeatures } from '@/lib/experimental'
2
+ import { EXPERIMENTAL_FEATURES, experimentalFlagName } from '@/lib/experimental'
3
+ import { defineCommand } from 'citty'
4
+ import { getAppConfig, initializeAppConfig } from '../../app-config'
5
+ import { CONTROL_PORT, PORT } from '../../constants'
6
+ import { serverCwd } from '../../server-cwd'
7
+ import { queryServerInfo, webAddress } from '../../service'
8
+ import { superviseServerUpdates } from '../../update'
9
+ import { PACKAGE_ROOT } from '../../version'
10
+ import { isServerRunning } from '../control'
11
+ import pc from '../pc'
12
+ import { runDevSupervisor, spawnServer } from '../server'
13
+
14
+ const experimentalArgs = Object.fromEntries(
15
+ EXPERIMENTAL_FEATURES.map(feature => {
16
+ const name = experimentalFlagName(feature)
17
+ const label = name.slice('experimental-'.length).replaceAll('-', ' ')
18
+ return [name, { type: 'boolean' as const, description: `Enable experimental ${label}` }]
19
+ })
20
+ )
21
+
22
+ export const start = defineCommand({
23
+ meta: { name: 'start', description: 'Start the Moi web server' },
24
+ args: {
25
+ port: {
26
+ type: 'string',
27
+ description: 'HTTP port to listen on (default: 13337)'
28
+ },
29
+ ...experimentalArgs
30
+ },
31
+ async run({ args, rawArgs }) {
32
+ const knownFlags = new Set(EXPERIMENTAL_FEATURES.map(experimentalFlagName))
33
+ for (const arg of rawArgs) {
34
+ if (arg.startsWith('--experimental-') && !knownFlags.has(arg.slice(2))) {
35
+ throw new Error(`Unknown experimental feature: ${arg.slice('--experimental-'.length)}`)
36
+ }
37
+ }
38
+ const experimental: Partial<ExperimentalFeatures> = {}
39
+ const experimentalFlags: string[] = []
40
+ for (const feature of EXPERIMENTAL_FEATURES) {
41
+ const flag = experimentalFlagName(feature)
42
+ if (args[flag] !== true) continue
43
+ experimental[feature] = true
44
+ experimentalFlags.push(`--${flag}`)
45
+ }
46
+ const projectRoot = PACKAGE_ROOT
47
+ // Undocumented: --dev runs the watch-and-full-restart dev supervisor.
48
+ const dev = process.argv.includes('--dev')
49
+ // Undocumented: --debug turns on the messaging trace (MOI_DEBUG) in the
50
+ // server — console lines for each message/session/turn in the chat pipeline.
51
+ const debug = process.argv.includes('--debug')
52
+
53
+ // Launcher path: we are the CLI, not the server. Decide whether to bail
54
+ // (a server is already up), run the dev supervisor, or spawn a one-shot
55
+ // server. Skipped when MOI_SERVER=1 (we are the spawned server itself).
56
+ if (!process.env.MOI_SERVER) {
57
+ if (await isServerRunning()) {
58
+ // Say who owns the running server: a service-managed one is expected
59
+ // to be here, and `moi service` is how to manage it.
60
+ const info = await queryServerInfo()
61
+ if (info?.service) {
62
+ console.log(
63
+ '\n' +
64
+ pc.yellow('◆') +
65
+ ' The Moi service is already running on ' +
66
+ webAddress(info) +
67
+ pc.dim(` (v${info.version})`) +
68
+ '\n' +
69
+ pc.dim(' Manage it with `moi service` — restart, logs, uninstall.') +
70
+ '\n'
71
+ )
72
+ } else {
73
+ console.log(
74
+ '\n' + pc.yellow('◆') + ' Server is already running on ' + webAddress(info) + '\n'
75
+ )
76
+ }
77
+ process.exit(0)
78
+ }
79
+
80
+ // Spawn server with correct cwd so bunfig.toml is picked up at Bun startup.
81
+ // MOI_DEV tells the server to use the live bundler + HMR even if a stale
82
+ // `dist/` exists in the tree (prod serves prebuilt `dist/` statically).
83
+ const env = {
84
+ ...process.env,
85
+ // The dev bundler snapshots process.env at server startup, so the
86
+ // PUBLIC_* inlining (bunfig `[serve.static] env`) only sees vars that
87
+ // are set before the server process spawns — setting one later from
88
+ // server code does nothing. Default the tldraw key here so an unset
89
+ // key inlines as '' (→ watermark) instead of leaving a bare
90
+ // `process.env.…` in the browser bundle that throws.
91
+ PUBLIC_TLDRAW_LICENSE_KEY: process.env.PUBLIC_TLDRAW_LICENSE_KEY ?? '',
92
+ ...(args.port ? { PORT: args.port } : {}),
93
+ ...(dev ? { MOI_DEV: '1' } : {}),
94
+ ...(debug ? { MOI_DEBUG: '1' } : {})
95
+ }
96
+ if (dev) {
97
+ await runDevSupervisor(projectRoot, env, experimentalFlags)
98
+ return
99
+ }
100
+ const cwd = serverCwd(projectRoot, dev)
101
+ const proc = spawnServer(cwd, env, experimentalFlags)
102
+ process.exit(
103
+ await superviseServerUpdates(proc, () => spawnServer(cwd, env, experimentalFlags))
104
+ )
105
+ }
106
+
107
+ // This IS the server process (MOI_SERVER=1). cwd is the package root when the
108
+ // dev bundler runs (bunfig loaded at Bun startup) or a neutral dir for a
109
+ // prebuilt install — see serverCwd().
110
+ initializeAppConfig(experimental)
111
+ try {
112
+ await import('../../web')
113
+ } catch (err) {
114
+ // Startup failure (port taken, config error). Under the service manager
115
+ // exit 0 on purpose: launchd (KeepAlive.SuccessfulExit=false) and
116
+ // systemd (Restart=on-failure) both read a clean exit as "do not
117
+ // respawn", so a permanently-broken start idles instead of looping.
118
+ const code = (err as { code?: string })?.code
119
+ if (code === 'EADDRINUSE') {
120
+ console.error(
121
+ `\n${pc.red('✗')} Port already in use (http :${PORT} / control :${CONTROL_PORT}) — ` +
122
+ 'is another Moi server running?'
123
+ )
124
+ } else {
125
+ console.error(`\n${pc.red('✗')} Server failed to start: ${String(err)}`)
126
+ }
127
+ if (process.env.MOI_SERVICE) {
128
+ console.error(pc.dim(' The service stays idle — fix this, then `moi service restart`.\n'))
129
+ process.exit(0)
130
+ }
131
+ process.exit(1)
132
+ }
133
+ const { unixSocket } = getAppConfig()
134
+ console.log(`\n${pc.green('✓')} Server started on ${unixSocket ?? `http://localhost:${PORT}`}`)
135
+ console.log(pc.dim(' Press Ctrl+C to stop\n'))
136
+ // Stay alive as the server
137
+ }
138
+ })
@@ -0,0 +1,80 @@
1
+ import type { WorkspaceEntry } from '@/lib/types'
2
+ import { defineCommand } from 'citty'
3
+ import { CONTROL_HOST, CONTROL_PORT, CONTROL_URL, PORT } from '../../constants'
4
+ import type { ControlProbe } from '../../control-client'
5
+ import { controlFailureMessage, probeControlServer } from '../../control-client'
6
+ import { queryServerInfo } from '../../service'
7
+ import { staleSkillNotice } from '../../skills/version'
8
+ import { VERSION } from '../../version'
9
+ import pc from '../pc'
10
+ import { versionMismatchNotice } from '../server-version'
11
+
12
+ export const status = defineCommand({
13
+ meta: { name: 'status', description: 'Show server status and registered workspaces' },
14
+ async run() {
15
+ const probe: ControlProbe = await probeControlServer()
16
+ const notice = await staleSkillNotice(process.cwd())
17
+
18
+ if (probe.status === 'not-running') {
19
+ console.log('\n' + pc.dim('○') + ' Server is ' + pc.bold('not running'))
20
+ console.log(pc.dim(` cli version ${VERSION}`) + '\n')
21
+ process.exit(0)
22
+ }
23
+
24
+ // The dial failed for a reason other than an empty port, so the server may
25
+ // be up and healthy. Name the real obstacle instead of blaming the process.
26
+ if (probe.status === 'unreachable') {
27
+ console.log('\n' + pc.yellow('◆') + ' Server is ' + pc.bold('unreachable'))
28
+ console.log(pc.dim(` control port ${CONTROL_HOST}:${CONTROL_PORT} — ${probe.reason}`))
29
+ console.log(pc.dim(` cli version ${VERSION}`) + '\n')
30
+ process.exit(1)
31
+ }
32
+
33
+ const info = await queryServerInfo()
34
+ console.log(
35
+ '\n' +
36
+ pc.green('●') +
37
+ ' Server is ' +
38
+ pc.bold('running') +
39
+ pc.dim(
40
+ (info?.unixSocket
41
+ ? ` (web socket: ${info.unixSocket}`
42
+ : ` (http port: ${info?.port || PORT}`) +
43
+ `, control port: ${CONTROL_PORT}` +
44
+ (info?.pid ? `, pid: ${info.pid}` : '') +
45
+ ')'
46
+ )
47
+ )
48
+ if (info) {
49
+ console.log(
50
+ pc.dim(` server version ${info.version}`) +
51
+ (info.service ? pc.dim(' · service-managed (`moi service`)') : '')
52
+ )
53
+ }
54
+ console.log(pc.dim(` cli version ${VERSION}`))
55
+ const mismatch = info ? versionMismatchNotice(info.version) : null
56
+ if (mismatch) console.log('\n' + mismatch)
57
+
58
+ await new Promise<void>((resolve, reject) => {
59
+ const ws = new WebSocket(CONTROL_URL)
60
+
61
+ ws.onopen = () => ws.send(JSON.stringify({ type: 'workspace:list' }))
62
+
63
+ ws.onmessage = event => {
64
+ const res = JSON.parse(String(event.data))
65
+ const workspaces: WorkspaceEntry[] = res.workspaces ?? []
66
+ const n = workspaces.length
67
+ console.log(pc.dim(` ${n} workspace${n === 1 ? '' : 's'} registered\n`))
68
+
69
+ ws.close()
70
+ resolve()
71
+ }
72
+
73
+ ws.onerror = () =>
74
+ void probeControlServer().then(p => reject(new Error(controlFailureMessage(p))))
75
+ })
76
+
77
+ if (notice) console.log(pc.yellow(notice) + '\n')
78
+ process.exit(0)
79
+ }
80
+ })
@@ -0,0 +1,43 @@
1
+ import { defineCommand } from 'citty'
2
+ import { resolve } from 'path'
3
+ import { dirArg } from '../args'
4
+ import { sendControl } from '../control'
5
+ import pc from '../pc'
6
+ import { columns } from '../ui'
7
+
8
+ // The listing behind `moi tabs`: every tab (static + views), one per row, the
9
+ // saved default (`layout.tabs.active`) marked. The
10
+ // addresses are documented in docs/navigation.md.
11
+ function runTabsList(dir: string) {
12
+ const path = resolve(dir)
13
+ sendControl(path, { type: 'tabs', path }, res => {
14
+ type Row = { title: string; isDefault: boolean; href: string }
15
+ const rows: Row[] = Array.isArray(res.tabs) ? (res.tabs as Row[]) : []
16
+ console.log(
17
+ '\n' + pc.bold('moi tabs') + pc.dim(' — workspace tabs, the default one marked') + '\n'
18
+ )
19
+ console.log(
20
+ columns(
21
+ ['', 'title', 'address'].map(h => pc.dim(h)),
22
+ rows.map(row => [
23
+ row.isDefault ? pc.green('●') : ' ',
24
+ row.isDefault ? pc.bold(row.title) : row.title,
25
+ row.href
26
+ ])
27
+ )
28
+ )
29
+ console.log('\n' + pc.dim(' Open one: moi navigate <address>') + '\n')
30
+ })
31
+ }
32
+
33
+ export const tabs = defineCommand({
34
+ meta: { name: 'tabs', description: 'List workspace tabs and their navigation addresses' },
35
+ args: { dir: dirArg },
36
+ run({ args }) {
37
+ if (args._.length) {
38
+ console.error('moi tabs only lists tabs. Use moi navigate <address> to navigate.')
39
+ process.exit(1)
40
+ }
41
+ runTabsList(args.dir)
42
+ }
43
+ })