moi-computer 0.12.1-next.0 → 0.12.1-next.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 (354) hide show
  1. package/README.md +26 -26
  2. package/bin/moi.mjs +2 -2
  3. package/client/AGENTS.md +7 -3
  4. package/client/api/app-config.ts +5 -10
  5. package/client/api/workspace-keys.ts +3 -2
  6. package/client/app/app-provider.tsx +25 -0
  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} +22 -23
  10. package/client/app/shell/{SidebarLayout.tsx → sidebar-layout.tsx} +29 -23
  11. package/client/dev/index.html +43 -0
  12. package/client/dev/index.ts +15 -0
  13. package/client/features/applets/api.ts +1 -1
  14. package/client/features/applets/{AppletContainer.tsx → applet-container.tsx} +1 -1
  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 +4 -4
  19. package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +11 -11
  20. package/client/features/chat/{ChatPopup.tsx → chat-popup.tsx} +1 -1
  21. package/client/features/chat/composer/attachments/{DrawingAttachmentChip.tsx → drawing-attachment-chip.tsx} +1 -1
  22. package/client/features/chat/composer/attachments/{FileAttachmentChip.tsx → file-attachment-chip.tsx} +1 -1
  23. package/client/features/chat/composer/attachments/{TextAttachmentChip.tsx → text-attachment-chip.tsx} +1 -1
  24. package/client/features/chat/composer/banners/{ComposerBanner.tsx → composer-banner.tsx} +0 -14
  25. package/client/features/chat/composer/banners/{ErrorBanner.tsx → error-banner.tsx} +1 -1
  26. package/client/features/chat/composer/banners/{SkillUpdateBanner.tsx → skill-update-banner.tsx} +3 -3
  27. package/client/features/chat/composer/{ChatComposer.tsx → chat-composer.tsx} +8 -7
  28. package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +1 -1
  29. package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +12 -28
  30. package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
  31. package/client/features/chat/connection/chat-frames.ts +3 -3
  32. package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +4 -4
  33. package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +1 -1
  34. package/client/features/chat/messages/tool-group/index.ts +1 -1
  35. package/client/features/chat/messages/tool-group/{ReadImagePreview.tsx → read-image-preview.tsx} +2 -2
  36. package/client/features/chat/messages/tool-group/{SubagentCard.tsx → subagent-card.tsx} +3 -3
  37. package/client/features/chat/messages/tool-group/{TimelineRow.tsx → timeline-row.tsx} +1 -1
  38. package/client/features/chat/messages/tool-group/{ToolCallGroup.tsx → tool-call-group.tsx} +8 -8
  39. package/client/features/chat/messages/tool-group/{ToolOutput.tsx → tool-output.tsx} +1 -1
  40. package/client/features/chat/messages/{TurnView.tsx → turn-view.tsx} +4 -4
  41. package/client/features/chat/sessions/api.ts +3 -3
  42. package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +2 -2
  43. package/client/features/chat/sessions/{useSelectedSession.ts → use-selected-session.ts} +2 -2
  44. package/client/features/chat/{useChat.ts → use-chat.ts} +4 -4
  45. package/client/features/collab/host-state.ts +24 -7
  46. package/client/features/collab/local-user.ts +1 -1
  47. package/client/features/collab/proxy-user.ts +4 -9
  48. package/client/features/connectors/mcp-icons.ts +1 -1
  49. package/client/features/connectors/{McpServerCards.tsx → mcp-server-cards.tsx} +1 -1
  50. package/client/features/{home/workspace-setup/DemoDialog.tsx → demo/demo-dialog.tsx} +26 -80
  51. package/client/features/dev/chat-states-fixtures.ts +4 -4
  52. package/client/features/dev/{ChatStatesPage.tsx → chat-states-page.tsx} +6 -6
  53. package/client/features/dev/collab/local-user-settings.tsx +4 -4
  54. package/client/features/dev/{DevIndexPage.tsx → dev-index-page.tsx} +7 -1
  55. package/client/features/dev/{DevRoutes.tsx → dev-routes.tsx} +8 -6
  56. package/client/features/dev/workspace-setup-mocks.ts +102 -0
  57. package/client/features/dev/workspace-setup-page.tsx +11 -0
  58. package/client/features/dev/workspace-setup-preview.tsx +253 -0
  59. package/client/features/drawings/{DrawingToolbar.tsx → drawing-toolbar.tsx} +1 -1
  60. package/client/features/drawings/{useChatAnnotation.ts → use-chat-annotation.ts} +29 -23
  61. package/client/features/drawings/{useDrawingLayer.ts → use-drawing-layer.ts} +1 -1
  62. package/client/features/drawings/{useViewSketch.ts → use-view-sketch.ts} +1 -1
  63. package/client/features/harness/api.ts +36 -0
  64. package/client/features/harness/device-login-steps.tsx +97 -0
  65. package/client/features/home/api.ts +29 -89
  66. package/client/features/home/{HomeLogo.tsx → home-logo.tsx} +1 -1
  67. package/client/features/home/{HomePage.tsx → home-page.tsx} +13 -14
  68. package/client/features/overview/api.ts +2 -2
  69. package/client/features/overview/default/registry.tsx +1 -1
  70. package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +1 -1
  71. package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
  72. package/client/features/overview/{Overview.tsx → overview.tsx} +6 -6
  73. package/client/features/overview/{WidgetCanvas.tsx → widget-canvas.tsx} +1 -1
  74. package/client/features/overview/{WidgetFrame.tsx → widget-frame.tsx} +1 -1
  75. package/client/features/overview/workspace-name.tsx +55 -0
  76. package/client/features/scratchpad/{Scratchpad.tsx → scratchpad.tsx} +10 -13
  77. package/client/features/scratchpad/{useScratchpadSnapshot.tsx → use-scratchpad-snapshot.tsx} +3 -3
  78. package/client/features/settings/api.ts +15 -9
  79. package/client/features/settings/{ConnectorsSettings.tsx → connectors-settings.tsx} +3 -3
  80. package/client/features/settings/{EnvironmentSettings.tsx → environment-settings.tsx} +3 -3
  81. package/client/features/settings/{GeneralSettings.tsx → general-settings.tsx} +5 -5
  82. package/client/features/settings/{useEnvVars.ts → use-env-vars.ts} +1 -1
  83. package/client/features/settings/{WorkspaceIconPicker.tsx → workspace-icon-picker.tsx} +1 -1
  84. package/client/features/settings/{WorkspaceSettingsDialog.tsx → workspace-settings-dialog.tsx} +3 -3
  85. package/client/features/update/api.ts +1 -1
  86. package/client/features/views/api.ts +1 -1
  87. package/client/features/views/{PendingViewScreen.tsx → pending-view-screen.tsx} +7 -4
  88. package/client/features/views/{useViewActions.ts → use-view-actions.ts} +2 -2
  89. package/client/features/views/{useViewDrafts.ts → use-view-drafts.ts} +15 -6
  90. package/client/features/views/{ViewManager.tsx → view-manager.tsx} +3 -3
  91. package/client/features/views/view-submission.ts +1 -1
  92. package/client/features/workspace/add/api.ts +80 -0
  93. package/client/features/{home/workspace-setup/CreateWorkspaceDialog.tsx → workspace/add/create-workspace-dialog.tsx} +56 -42
  94. package/client/features/workspace/add/import-workspace-dialog.tsx +81 -0
  95. package/client/features/{home/workspace-setup/useWorkspaceImport.ts → workspace/add/use-workspace-import.ts} +1 -1
  96. package/client/features/workspace/add/workspace-agent-options.ts +53 -0
  97. package/client/features/{home/workspace-setup/WorkspaceAgentStep.tsx → workspace/add/workspace-agent-selector.tsx} +59 -98
  98. package/client/features/{home/workspace-setup/WorkspaceDialogContent.tsx → workspace/add/workspace-dialog-content.tsx} +1 -1
  99. package/client/features/workspace/api.ts +31 -26
  100. package/client/features/workspace/browser-tab-state.ts +1 -1
  101. package/client/features/workspace/moi-context.ts +1 -1
  102. package/client/features/workspace/setup/workspace-login-state.tsx +175 -0
  103. package/client/features/workspace/setup/workspace-recovery-states.tsx +125 -0
  104. package/client/features/workspace/setup/workspace-setup-panel.tsx +18 -0
  105. package/client/features/workspace/setup/workspace-setup.tsx +78 -0
  106. package/client/features/workspace/setup/workspace-welcome-state.tsx +81 -0
  107. package/client/features/workspace/{ThemePanel.tsx → theme-panel.tsx} +3 -3
  108. package/client/features/workspace/{useWorkspaceNavigation.ts → use-workspace-navigation.ts} +2 -2
  109. package/client/features/workspace/{WorkspaceScreen.tsx → workspace-content.tsx} +37 -80
  110. package/client/features/workspace/workspace-frame.tsx +76 -0
  111. package/client/features/workspace/workspace-identity.tsx +40 -0
  112. package/client/features/workspace/{WorkspaceLayoutContext.tsx → workspace-layout-context.tsx} +2 -0
  113. package/client/features/workspace/{WorkspaceMenu.tsx → workspace-menu.tsx} +3 -3
  114. package/client/features/workspace/workspace-pending-screen.tsx +26 -0
  115. package/client/features/{home → workspace}/workspace-presentation.tsx +10 -3
  116. package/client/features/workspace/workspace-screen.tsx +28 -0
  117. package/client/features/workspace/{WorkspaceSplitLayout.tsx → workspace-split-layout.tsx} +1 -1
  118. package/client/features/workspace/{WorkspaceTabs.tsx → workspace-tabs.tsx} +2 -2
  119. package/client/index.css +2 -2
  120. package/client/index.html +29 -10
  121. package/client/index.tsx +7 -2
  122. package/client/lib/agent-availability.ts +0 -5
  123. package/client/lib/browser-tab-id.ts +4 -0
  124. package/client/main.tsx +10 -7
  125. package/client/runtime/app-context.ts +20 -0
  126. package/client/runtime/use-workspace-events.ts +56 -0
  127. package/client/runtime/workspace-events.ts +151 -0
  128. package/dist/chunk-00rh9df4.js +2 -0
  129. package/dist/chunk-4nh7y1hq.css +1 -0
  130. package/dist/{chunk-vqpkqtdr.js → chunk-am4agx6v.js} +1 -1
  131. package/dist/{chunk-gps4qc38.js → chunk-d7cbm65e.js} +1 -1
  132. package/dist/chunk-hbpdv7vd.js +1 -0
  133. package/dist/chunk-hmka9rt5.js +2 -0
  134. package/dist/{chunk-j905va8r.js → chunk-hvh9f5h0.js} +1 -1
  135. package/dist/chunk-mjjregkn.js +10 -0
  136. package/dist/chunk-rt30jbcm.js +1 -0
  137. package/dist/chunk-vt6zybej.js +2 -0
  138. package/dist/chunk-wbkwf6cc.js +68 -0
  139. package/dist/chunk-xjyfyz64.js +1 -0
  140. package/dist/{chunk-hzwr8dp8.js → chunk-y8nbwp21.js} +71 -71
  141. package/dist/chunk-ysfdcew7.js +1 -0
  142. package/dist/index.html +30 -11
  143. package/lib/format.ts +1 -1
  144. package/lib/harness-instructions.ts +30 -0
  145. package/lib/ids.ts +3 -3
  146. package/lib/moi-context.ts +2 -2
  147. package/lib/scratchpad-skew.ts +3 -3
  148. package/lib/types.ts +28 -20
  149. package/lib/update.ts +1 -1
  150. package/package.json +5 -2
  151. package/server/AGENTS.md +10 -4
  152. package/server/README.md +102 -0
  153. package/server/api/harnesses.ts +56 -0
  154. package/server/{api.ts → api/index.ts} +125 -118
  155. package/server/app-config.ts +24 -12
  156. package/server/app-settings.ts +1 -1
  157. package/server/applets/applet-css.ts +1 -1
  158. package/server/applets/build-applet.ts +4 -4
  159. package/server/applets/build-worker.ts +1 -1
  160. package/server/applets/config.ts +1 -1
  161. package/server/{functions-worker.ts → applets/functions-worker.ts} +1 -1
  162. package/server/{functions.ts → applets/functions.ts} +2 -2
  163. package/server/applets/index.ts +2 -2
  164. package/server/{thumbnails.ts → applets/thumbnails.ts} +9 -6
  165. package/server/{applet-typecheck.ts → applets/typecheck.ts} +4 -4
  166. package/server/{ui-components.ts → applets/ui-components.ts} +2 -2
  167. package/server/{views.ts → applets/views.ts} +7 -7
  168. package/server/{widgets.ts → applets/widgets.ts} +2 -2
  169. package/server/cli/applet-selector.ts +19 -0
  170. package/server/cli/args.ts +5 -0
  171. package/server/{cli-colors.ts → cli/colors.ts} +1 -1
  172. package/server/cli/commands/bundle.ts +119 -0
  173. package/server/cli/commands/call-server-fn.ts +42 -0
  174. package/server/cli/commands/check.ts +53 -0
  175. package/server/cli/commands/config.ts +132 -0
  176. package/server/cli/commands/debug.ts +119 -0
  177. package/server/cli/commands/env.ts +162 -0
  178. package/server/cli/commands/hermes.ts +149 -0
  179. package/server/cli/commands/init.ts +286 -0
  180. package/server/cli/commands/navigate.ts +35 -0
  181. package/server/cli/commands/openclaw.ts +168 -0
  182. package/server/cli/commands/refresh.ts +39 -0
  183. package/server/cli/commands/scratch.ts +496 -0
  184. package/server/cli/commands/service.ts +298 -0
  185. package/server/cli/commands/skill.ts +122 -0
  186. package/server/cli/commands/start.ts +138 -0
  187. package/server/cli/commands/status.ts +80 -0
  188. package/server/cli/commands/tabs.ts +43 -0
  189. package/server/cli/commands/theme.ts +192 -0
  190. package/server/cli/commands/ui-components.ts +15 -0
  191. package/server/cli/commands/update.ts +192 -0
  192. package/server/cli/commands/version.ts +9 -0
  193. package/server/cli/commands/views.ts +87 -0
  194. package/server/cli/control.ts +89 -0
  195. package/server/{cli-env.ts → cli/env.ts} +9 -9
  196. package/server/cli/index.ts +171 -0
  197. package/server/{cli-pc.ts → cli/pc.ts} +1 -1
  198. package/server/cli/provider.ts +25 -0
  199. package/server/cli/server-version.ts +16 -0
  200. package/server/cli/server.ts +81 -0
  201. package/server/{cli-ui-components.ts → cli/ui-components.ts} +5 -5
  202. package/server/cli.ts +2 -3252
  203. package/server/collab/manager.ts +3 -3
  204. package/server/collab/skill/index.ts +2 -2
  205. package/server/control.ts +20 -20
  206. package/server/harness/README.md +47 -25
  207. package/server/harness/acp/NOTES.md +11 -11
  208. package/server/harness/acp/archived.ts +3 -3
  209. package/server/harness/acp/client.ts +2 -2
  210. package/server/harness/acp/run-durations.ts +1 -1
  211. package/server/harness/acp/session.ts +5 -5
  212. package/server/harness/auth.ts +303 -0
  213. package/server/harness/claude-code/NOTES.md +9 -7
  214. package/server/harness/claude-code/auth.ts +125 -17
  215. package/server/harness/claude-code/index.ts +2 -1
  216. package/server/harness/claude-code/mcp.ts +1 -1
  217. package/server/harness/claude-code/session.ts +10 -7
  218. package/server/harness/codex/NOTES.md +12 -12
  219. package/server/harness/codex/auth.ts +86 -19
  220. package/server/harness/codex/client.ts +17 -13
  221. package/server/harness/codex/index.ts +2 -1
  222. package/server/harness/codex/permissions.ts +3 -3
  223. package/server/harness/codex/probe.ts +3 -5
  224. package/server/harness/codex/session.ts +16 -13
  225. package/server/harness/codex/thread-list.ts +4 -0
  226. package/server/harness/codex/transport.ts +5 -5
  227. package/server/harness/executable.ts +42 -18
  228. package/server/harness/hermes/NOTES.md +70 -70
  229. package/server/harness/hermes/discovery.ts +1 -1
  230. package/server/harness/openclaw/NOTES.md +24 -24
  231. package/server/harness/openclaw/adapter.ts +1 -1
  232. package/server/harness/openclaw/compat.ts +1 -1
  233. package/server/harness/openclaw/session.ts +5 -2
  234. package/server/harness/registry.ts +1 -1
  235. package/server/harness/shell-path.ts +31 -21
  236. package/server/harness/types.ts +9 -2
  237. package/server/navigation-relay.ts +1 -1
  238. package/server/open-browser.ts +7 -0
  239. package/server/{scratchpad-assets.ts → scratchpad/assets.ts} +4 -4
  240. package/server/{scratchpad.ts → scratchpad/document.ts} +8 -8
  241. package/server/{scratchpad-executor.ts → scratchpad/executor.ts} +7 -7
  242. package/server/{scratchpad-relay.ts → scratchpad/relay.ts} +4 -5
  243. package/server/{scratchpad-shape-defaults.ts → scratchpad/shape-defaults.ts} +2 -2
  244. package/server/server-cwd.ts +1 -1
  245. package/server/service.ts +2 -2
  246. package/server/{session-archive.ts → sessions/archive.ts} +5 -5
  247. package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
  248. package/server/{session-config.ts → sessions/config.ts} +1 -1
  249. package/server/{session-lifecycle.ts → sessions/lifecycle.ts} +3 -3
  250. package/server/{pending-views.ts → sessions/pending-views.ts} +3 -3
  251. package/server/{selected-session.ts → sessions/selected.ts} +1 -1
  252. package/server/{session-store.ts → sessions/store.ts} +1 -1
  253. package/server/{view-sessions.ts → sessions/view-sessions.ts} +9 -9
  254. package/server/{skills-template.ts → skills/template.ts} +1 -1
  255. package/server/{skill-update.ts → skills/update.ts} +5 -5
  256. package/server/{skill-version.ts → skills/version.ts} +4 -4
  257. package/server/static.ts +5 -3
  258. package/server/status.ts +3 -3
  259. package/server/vendor.ts +23 -30
  260. package/server/web.ts +17 -9
  261. package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
  262. package/server/{workspace-env.ts → workspaces/env.ts} +3 -3
  263. package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
  264. package/server/{workspace-init.ts → workspaces/init.ts} +5 -5
  265. package/server/{layout.ts → workspaces/layout.ts} +13 -8
  266. package/server/{preview.ts → workspaces/preview.ts} +1 -1
  267. package/server/{registry.ts → workspaces/registry.ts} +3 -3
  268. package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
  269. package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +3 -3
  270. package/ui-components/button.tsx +1 -1
  271. package/ui-components/docs/attachment.md +2 -2
  272. package/ui-components/docs/button.md +1 -1
  273. package/ui-components/docs/calendar.md +1 -1
  274. package/ui-components/docs/chart.md +4 -4
  275. package/ui-components/docs/data-table.md +1 -1
  276. package/ui-components/docs/drawer.md +1 -1
  277. package/ui-components/docs/field.md +1 -1
  278. package/ui-components/docs/input.md +2 -2
  279. package/ui-components/docs/label.md +2 -2
  280. package/ui-components/docs/table.md +2 -2
  281. package/workspace/.claude/skills/moi-workspace/SKILL.md +12 -12
  282. package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +2 -2
  283. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +2 -2
  284. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +2 -2
  285. package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +0 -101
  286. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
  287. package/client/features/overview/WorkspaceName.tsx +0 -60
  288. package/client/runtime/useWorkspaceEvents.ts +0 -189
  289. package/dist/chunk-1zhnhy00.js +0 -1
  290. package/dist/chunk-27501vke.js +0 -1
  291. package/dist/chunk-9xtv6djt.js +0 -2
  292. package/dist/chunk-am1x230f.js +0 -2
  293. package/dist/chunk-darpsw65.js +0 -1
  294. package/dist/chunk-n33w9y38.js +0 -10
  295. package/dist/chunk-r63ks44z.js +0 -68
  296. package/dist/chunk-wd46nk26.css +0 -1
  297. package/dist/chunk-xgt7vxt9.js +0 -1
  298. package/dist/chunk-yvzhwtfa.js +0 -2
  299. package/server/agent.ts +0 -223
  300. /package/client/components/shared/{AgentBlobatar.tsx → agent-blobatar.tsx} +0 -0
  301. /package/client/components/shared/{BottomPanel.tsx → bottom-panel.tsx} +0 -0
  302. /package/client/components/shared/{Composer.tsx → composer.tsx} +0 -0
  303. /package/client/components/shared/{LedLogo.tsx → led-logo.tsx} +0 -0
  304. /package/client/components/shared/{PanelHeader.tsx → panel-header.tsx} +0 -0
  305. /package/client/components/shared/{ReorderableList.tsx → reorderable-list.tsx} +0 -0
  306. /package/client/components/shared/{WorkspaceIcon.tsx → workspace-icon.tsx} +0 -0
  307. /package/client/features/applets/{WidgetErrorBoundary.tsx → widget-error-boundary.tsx} +0 -0
  308. /package/client/features/chat/composer/attachments/{AttachmentChip.tsx → attachment-chip.tsx} +0 -0
  309. /package/client/features/chat/messages/{ChatPromptBubbles.tsx → chat-prompt-bubbles.tsx} +0 -0
  310. /package/client/features/chat/messages/{ShimmerText.tsx → shimmer-text.tsx} +0 -0
  311. /package/client/features/chat/messages/tool-group/{CodeBlock.tsx → code-block.tsx} +0 -0
  312. /package/client/features/chat/messages/tool-group/{Collapse.tsx → collapse.tsx} +0 -0
  313. /package/client/features/chat/messages/{useStickToBottom.ts → use-stick-to-bottom.ts} +0 -0
  314. /package/client/features/connectors/{IconMcp.tsx → icon-mcp.tsx} +0 -0
  315. /package/client/features/dev/{BlobatarShapesPage.tsx → blobatar-shapes-page.tsx} +0 -0
  316. /package/client/features/dev/{HarnessDebugPage.tsx → harness-debug-page.tsx} +0 -0
  317. /package/client/features/dev/{TextureLabPage.tsx → texture-lab-page.tsx} +0 -0
  318. /package/client/features/dev/{ToolCallsPage.tsx → tool-calls-page.tsx} +0 -0
  319. /package/client/features/drawings/{DrawingLayer.tsx → drawing-layer.tsx} +0 -0
  320. /package/client/features/home/{WorkspacePreview.tsx → workspace-preview.tsx} +0 -0
  321. /package/client/features/overview/{useGridReconcile.ts → use-grid-reconcile.ts} +0 -0
  322. /package/client/features/scratchpad/{ScratchpadControls.tsx → scratchpad-controls.tsx} +0 -0
  323. /package/client/features/settings/{SettingsLayout.tsx → settings-layout.tsx} +0 -0
  324. /package/client/features/update/{UpdateControl.tsx → update-control.tsx} +0 -0
  325. /package/client/features/workspace/{UnavailablePage.tsx → unavailable-page.tsx} +0 -0
  326. /package/client/features/workspace/{useFitsSplitLayout.ts → use-fits-split-layout.ts} +0 -0
  327. /package/client/features/workspace/{WorkspaceContext.tsx → workspace-context.tsx} +0 -0
  328. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom-client.js +0 -0
  329. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom.js +0 -0
  330. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-dev-runtime.js +0 -0
  331. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-runtime.js +0 -0
  332. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react.js +0 -0
  333. /package/client/vendor/react/{development → 19.2.4/development}/react-dom-client.js +0 -0
  334. /package/client/vendor/react/{development → 19.2.4/development}/react-dom.js +0 -0
  335. /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-dev-runtime.js +0 -0
  336. /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-runtime.js +0 -0
  337. /package/client/vendor/react/{development → 19.2.4/development}/react.js +0 -0
  338. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom-client.js +0 -0
  339. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom.js +0 -0
  340. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-dev-runtime.js +0 -0
  341. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-runtime.js +0 -0
  342. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react.js +0 -0
  343. /package/client/vendor/react/{production → 19.2.4/production}/react-dom-client.js +0 -0
  344. /package/client/vendor/react/{production → 19.2.4/production}/react-dom.js +0 -0
  345. /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-dev-runtime.js +0 -0
  346. /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-runtime.js +0 -0
  347. /package/client/vendor/react/{production → 19.2.4/production}/react.js +0 -0
  348. /package/server/{bundle-queue.ts → applets/bundle-queue.ts} +0 -0
  349. /package/server/{applet-log.ts → applets/log.ts} +0 -0
  350. /package/server/{cli-ui.ts → cli/ui.ts} +0 -0
  351. /package/server/{workspace-config.ts → workspaces/config.ts} +0 -0
  352. /package/server/{icon.ts → workspaces/icon.ts} +0 -0
  353. /package/server/{tabs.ts → workspaces/tabs.ts} +0 -0
  354. /package/server/{theme.ts → workspaces/theme.ts} +0 -0
@@ -1,3 +1,4 @@
1
+ import { detectInstalledHarnesses } from '../harness/executable'
1
2
  import { isMessageAttachments } from '@/lib/message-attachments'
2
3
  import { Hono } from 'hono'
3
4
  import { serveStatic } from 'hono/bun'
@@ -21,54 +22,60 @@ import type {
21
22
  } from '@/lib/types'
22
23
  import { isWorkspaceTabId } from '@/lib/workspace-tabs'
23
24
 
24
- import { proxyUserState } from './collab/cloudflare-access'
25
- import { collabManager } from './collab/manager'
26
- import { agentStore } from './agent'
27
- import { clientAppConfig, getAppConfig } from './app-config'
28
- import { getAppSettings, pickAppSettingsPatch, saveAppSettings } from './app-settings'
29
- import { appletForModule, recordAppletError } from './applet-log'
30
- import { apiBaseFor, parseAppletTail, serveWorkspaceFile } from './applets'
31
- import { applyEnvChanged } from './env-apply'
32
- import { publishEvent } from './events'
33
- import { callFunction, parseFunctionPath } from './functions'
34
- import { processIcon } from './icon'
35
- import { getWorkspacePreview, loadLayout, mergeLayoutForSave, saveLayout } from './layout'
25
+ import { proxyUserState } from '../collab/cloudflare-access'
26
+ import { collabManager } from '../collab/manager'
27
+ import { harnessStore } from '../harness/auth'
28
+ import { harnesses } from './harnesses'
29
+ import { clientAppConfig, getAppConfig } from '../app-config'
30
+ import { getAppSettings, pickAppSettingsPatch, saveAppSettings } from '../app-settings'
31
+ import { appletForModule, recordAppletError } from '../applets/log'
32
+ import { apiBaseFor, parseAppletTail, serveWorkspaceFile } from '../applets'
33
+ import { applyEnvChanged } from '../workspaces/env-apply'
34
+ import { publishEvent } from '../events'
35
+ import { callFunction, parseFunctionPath } from '../applets/functions'
36
+ import { processIcon } from '../workspaces/icon'
37
+ import {
38
+ getWorkspacePreview,
39
+ loadLayout,
40
+ mergeLayoutForSave,
41
+ saveLayout
42
+ } from '../workspaces/layout'
36
43
  import {
37
44
  getAppletThumbnailRecords,
38
45
  isValidAppletId,
39
46
  saveAppletThumbnails,
40
47
  serveAppletThumbnail
41
- } from './thumbnails'
42
- import { getClientFrameLog, getWireLog } from './harness/debug'
43
- import { allHarnesses, harnessFor, isHarnessType } from './harness/registry'
48
+ } from '../applets/thumbnails'
49
+ import { getClientFrameLog, getWireLog } from '../harness/debug'
50
+ import { loginShellPath } from '../harness/shell-path'
51
+ import { allHarnesses, harnessFor, isHarnessType } from '../harness/registry'
44
52
  import {
45
53
  discoverWorkspaces,
46
54
  getWorkspace,
47
55
  listWorkspaces,
48
56
  registerWorkspace,
49
57
  removeWorkspace,
50
- reorderWorkspaces,
51
- tildify
52
- } from './registry'
53
- import { loadScratchpadDoc, saveScratchpadDoc } from './scratchpad'
54
- import { MAX_ASSET_BYTES, scratchpadAssetFile, storeScratchpadAsset } from './scratchpad-assets'
58
+ reorderWorkspaces
59
+ } from '../workspaces/registry'
60
+ import { loadScratchpadDoc, saveScratchpadDoc } from '../scratchpad/document'
61
+ import { MAX_ASSET_BYTES, scratchpadAssetFile, storeScratchpadAsset } from '../scratchpad/assets'
55
62
  import {
56
63
  getPinnedSession,
57
64
  getSelectedSession,
58
65
  getWorkspaceSessionSelection,
59
66
  pinSession,
60
67
  saveSelectedSession
61
- } from './selected-session'
62
- import type { SelectedSessionUpdate } from './selected-session'
63
- import { saveSessionConfig } from './session-config'
64
- import type { SessionConfigPatch } from './session-config'
65
- import { getSessionRecord, withSessionRecords } from './session-store'
66
- import { archiveWorkspaceSession } from './session-archive'
67
- import { DIST_DIR, prebuilt } from './static'
68
- import { getWorkspaceSkillsStatus, updateWorkspaceSkills } from './skill-update'
69
- import { serveWorkspaceImagePreview } from './preview'
70
- import { MAX_UPLOAD_BYTES, addUpload, addWorkspaceFileUpload, getUpload } from './uploads'
71
- import { requiredEnvFor } from './required-env'
68
+ } from '../sessions/selected'
69
+ import type { SelectedSessionUpdate } from '../sessions/selected'
70
+ import { saveSessionConfig } from '../sessions/config'
71
+ import type { SessionConfigPatch } from '../sessions/config'
72
+ import { getSessionRecord, withSessionRecords } from '../sessions/store'
73
+ import { archiveWorkspaceSession } from '../sessions/archive'
74
+ import { DIST_DIR, prebuilt } from '../static'
75
+ import { getWorkspaceSkillsStatus, updateWorkspaceSkills } from '../skills/update'
76
+ import { serveWorkspaceImagePreview } from '../workspaces/preview'
77
+ import { MAX_UPLOAD_BYTES, addUpload, addWorkspaceFileUpload, getUpload } from '../uploads'
78
+ import { requiredEnvFor } from '../workspaces/required-env'
72
79
  import {
73
80
  deleteView,
74
81
  listCompiledViews,
@@ -76,25 +83,25 @@ import {
76
83
  serveView,
77
84
  updateViewTitle,
78
85
  ViewMutationError
79
- } from './views'
86
+ } from '../applets/views'
80
87
  import {
81
88
  createPendingView,
82
89
  discardPendingView,
83
90
  getPendingView,
84
91
  updatePendingView,
85
92
  PendingViewError
86
- } from './pending-views'
87
- import { submitView, ViewStartupError } from './view-sessions'
88
- import { listWidgets, serveWidget } from './widgets'
89
- import { getWorkspaceConfig, setWorkspaceConfig } from './workspace-config'
93
+ } from '../sessions/pending-views'
94
+ import { submitView, ViewStartupError } from '../sessions/view-sessions'
95
+ import { listWidgets, serveWidget } from '../applets/widgets'
96
+ import { getWorkspaceConfig, setWorkspaceConfig } from '../workspaces/config'
90
97
  import {
91
98
  createdWorkspacesRoot,
92
99
  provisionWorkspace,
93
100
  validateWorkspaceFolderName
94
- } from './workspace-init'
95
- import { resolveWorkspaceImportMetadata } from './workspace-import'
96
- import type { WorkspaceImportMetadata } from './workspace-import'
97
- import { getWorkspaceEnvView, parseEnvUpdate, updateWorkspaceEnv } from './workspace-env'
101
+ } from '../workspaces/init'
102
+ import { resolveWorkspaceImportMetadata } from '../workspaces/import'
103
+ import type { WorkspaceImportMetadata } from '../workspaces/import'
104
+ import { getWorkspaceEnvView, parseEnvUpdate, updateWorkspaceEnv } from '../workspaces/env'
98
105
  import {
99
106
  getCachedUpdateStatus,
100
107
  hasRunningAgentSessions,
@@ -102,12 +109,18 @@ import {
102
109
  restartPendingForUpdate,
103
110
  scheduleRestartForUpdate,
104
111
  updateInProgress
105
- } from './update'
112
+ } from '../update'
106
113
 
107
114
  // The resolved workspace is stashed on the context by `withWorkspace`, so every
108
115
  // `/api/workspaces/:id/*` handler can read it without re-querying the registry.
109
116
  type ApiEnv = { Variables: { ws: WorkspaceEntry } }
110
117
 
118
+ // The writing browser tab's id from a request body, echoed on the resulting
119
+ // event so that tab can skip it. See client/lib/browser-tab-id.ts.
120
+ function eventOrigin(value: unknown): string | undefined {
121
+ return typeof value === 'string' ? value : undefined
122
+ }
123
+
111
124
  function publishSelectedSession(workspaceId: string, update: SelectedSessionUpdate): void {
112
125
  if (!update.changed) return
113
126
  publishEvent({
@@ -171,20 +184,6 @@ const withWorkspace = createMiddleware<ApiEnv>(async (c, next) => {
171
184
  const one = new Hono<ApiEnv>()
172
185
  one.use('*', withWorkspace)
173
186
 
174
- one.get('/preview', async c => {
175
- const ws = c.get('ws')
176
- const views = await listCompiledViews(ws.path)
177
- return c.json(
178
- await getWorkspacePreview(ws.path, {
179
- getProviderPreview: includeFirstUserMessage =>
180
- harnessFor(ws).workspacePreview(ws, includeFirstUserMessage),
181
- viewIds: views.map(view => view.id),
182
- thumbnailUrl: (kind, id) =>
183
- `/api/workspaces/${ws.id}/applet-thumbnails/${kind}/${encodeURIComponent(id)}`
184
- })
185
- )
186
- })
187
-
188
187
  one.get('/widgets', c => listWidgets(c.get('ws').path))
189
188
 
190
189
  // Widget bundle: the compiled ESM for one widget, dynamically imported by the
@@ -352,7 +351,7 @@ one.post('/rpc/*', c => {
352
351
  // `moi debug logs` reads it back (docs/self-correction.md). Unauthenticated
353
352
  // localhost route, so treat the payload as hostile: whitelist the browser-only
354
353
  // sources (`build`/`rpc` are server-recorded and can't be spoofed by a tab),
355
- // pattern-check the applet name, cap the batch size; applet-log.ts caps string
354
+ // pattern-check the applet name, cap the batch size; applets/log.ts caps string
356
355
  // lengths.
357
356
  one.post('/applet-log', async c => {
358
357
  let body: { events?: unknown }
@@ -396,7 +395,7 @@ one.post('/applet-log', async c => {
396
395
 
397
396
  // Downscaled image preview of a workspace file. The chat's expanded tool rows
398
397
  // use this to show the picture an agent `Read` — same guards as /files/ above,
399
- // images only, resized server-side (see server/preview.ts).
398
+ // images only, resized server-side (see server/workspaces/preview.ts).
400
399
  one.get('/preview/*', c => {
401
400
  const ws = c.get('ws')
402
401
  const tail = new URL(c.req.url).pathname.split(`/api/workspaces/${ws.id}/preview/`)[1] ?? ''
@@ -455,7 +454,7 @@ one.post('/uploads/from-path', async c => {
455
454
  if (error instanceof Error && 'code' in error) {
456
455
  if (error.code === 'ENOENT') return c.text('This file no longer exists', 400)
457
456
  if (error.code === 'EACCES' || error.code === 'EPERM')
458
- return c.text('This file can’t be read by moi', 400)
457
+ return c.text('This file can’t be read by Moi', 400)
459
458
  return c.text('Something went wrong while adding this file', 400)
460
459
  }
461
460
  return c.text(
@@ -654,20 +653,6 @@ one.put('/env', async c => {
654
653
  return c.json(await getWorkspaceEnvView(ws.path, requiredEnvFor(ws.path)))
655
654
  })
656
655
 
657
- // Start a provider login ceremony. Codex returns a browser OAuth URL for the
658
- // host to open; Claude launches its browser flow through the CLI itself.
659
- // Browser-based logins reuse a pending URL; URL-less provider flows restart
660
- // when requested again. Completion is pushed as `agent:updated`.
661
- one.post('/auth/login', async c => {
662
- const ws = c.get('ws')
663
- if (!harnessFor(ws).startLogin) return c.text('This agent requires terminal sign-in', 409)
664
- try {
665
- return c.json(await agentStore.startLogin(ws))
666
- } catch (err) {
667
- return c.text(err instanceof Error ? err.message : 'Could not start sign-in', 500)
668
- }
669
- })
670
-
671
656
  one.get('/skills', async c => {
672
657
  const ws = c.get('ws')
673
658
  return c.json(await getWorkspaceSkillsStatus(ws.path, ws.type))
@@ -680,31 +665,40 @@ one.post('/skills/update', async c => {
680
665
  })
681
666
 
682
667
  // The workspace's agent backend in one snapshot: provider, availability
683
- // (runtime presence + auth, from the server-side cache), any in-flight login
684
- // ceremony, the model catalog, and capabilities. One request at workspace
685
- // open; the volatile parts stay fresh afterwards via `agent:updated` events,
686
- // not refetches.
668
+ // (runtime presence + auth), the model catalog, and capabilities.
669
+ // Workspace readiness stays fresh via `harness:updated` events and refetches.
687
670
  one.get('/agent', async c => {
688
671
  const ws = c.get('ws')
689
672
  const harness = harnessFor(ws)
673
+ const capabilities = {
674
+ provider: harness.id,
675
+ supportsStreaming: harness.capabilities.supportsStreaming,
676
+ supportsArchiving: Boolean(harness.archiveSession)
677
+ }
678
+ if (!existsSync(ws.path)) {
679
+ return c.json({
680
+ ...capabilities,
681
+ workspaceFolderMissing: true,
682
+ availability: { status: 'unavailable', reason: 'Workspace folder not found' },
683
+ models: []
684
+ } satisfies WorkspaceAgent)
685
+ }
686
+ const refresh = c.req.query('refresh') === 'true'
687
+ if (refresh) await loginShellPath({ refresh: true })
690
688
  // A backend that can't answer (codex CLI missing, gateway down) degrades to
691
689
  // an empty catalog — the picker hides and chat surfaces the real problem via
692
- // the availability banner, instead of this endpoint 500ing on page load.
690
+ // workspace setup, instead of this endpoint failing on page load.
693
691
  const [availability, models] = await Promise.all([
694
- agentStore.getAvailability(ws),
692
+ refresh ? harnessStore.refresh(ws) : harnessStore.getAvailability(ws),
695
693
  harness.listModels(ws).catch(err => {
696
694
  console.error(`[api] listModels failed for ${harness.id}`, err)
697
695
  return []
698
696
  })
699
697
  ])
700
- const login = agentStore.getLogin(ws.id)
701
698
  return c.json({
702
- provider: harness.id,
699
+ ...capabilities,
703
700
  availability,
704
- ...(login ? { login } : {}),
705
- models,
706
- supportsStreaming: harness.capabilities.supportsStreaming,
707
- supportsArchiving: Boolean(harness.archiveSession)
701
+ models
708
702
  } satisfies WorkspaceAgent)
709
703
  })
710
704
 
@@ -732,7 +726,7 @@ one.put('/config', async c => {
732
726
  return c.text('Expected a workspace config field', 400)
733
727
  }
734
728
  await setWorkspaceConfig(ws.path, { name, icon })
735
- publishEvent({ type: 'workspace:updated' })
729
+ publishEvent({ type: 'workspace:updated', origin: eventOrigin(body.origin) })
736
730
  return c.json(await getWorkspaceConfig(ws.path))
737
731
  })
738
732
 
@@ -741,7 +735,7 @@ one.put('/config', async c => {
741
735
  // snapshot ({ document, origin }) and broadcasts so other open tabs reload.
742
736
  // `origin` is the writing tab's id — echoed in the broadcast so that tab can
743
737
  // ignore its own save. This is the browser's write path; the agent's draws are
744
- // written server-side (see scratchpad-executor.ts). See docs/moi-scratchpad.md.
738
+ // written server-side (see server/scratchpad/executor.ts). See docs/moi-scratchpad.md.
745
739
  one.get('/scratchpad', async c => {
746
740
  return c.json(await loadScratchpadDoc(c.get('ws').path))
747
741
  })
@@ -756,14 +750,14 @@ one.put('/scratchpad', async c => {
756
750
  publishEvent({
757
751
  type: 'scratchpad:updated',
758
752
  workspaceId: ws.id,
759
- origin: typeof body.origin === 'string' ? body.origin : undefined
753
+ origin: eventOrigin(body.origin)
760
754
  })
761
755
  return c.body(null, 204)
762
756
  })
763
757
 
764
758
  // Scratchpad assets: pasted/dropped image bytes live as content-addressed files
765
759
  // in `.moi/.scratchpad/`, referenced from the snapshot by `asset:` srcs —
766
- // never inlined as base64 in the JSON (see server/scratchpad-assets.ts). The
760
+ // never inlined as base64 in the JSON (see server/scratchpad/assets.ts). The
767
761
  // browser's TLAssetStore POSTs the raw file here on paste and resolves `asset:`
768
762
  // srcs back through the GET when rendering.
769
763
  one.post('/scratchpad/assets', async c => {
@@ -848,11 +842,15 @@ one.get('/applet-thumbnails', async c =>
848
842
  one.get('/applet-thumbnails/:kind/:name', c => {
849
843
  const kind = c.req.param('kind')
850
844
  if (kind !== 'widget' && kind !== 'view') return c.text('Not found', 404)
845
+ // `<id>` or `<id>:<version>`. Applet ids never contain `:`, and the version
846
+ // lives in the path rather than a query string so every CDN keys on it.
847
+ const [id, version] = c.req.param('name').split(':')
851
848
  return serveAppletThumbnail(
852
849
  c.get('ws').path,
853
850
  kind,
854
- c.req.param('name'),
855
- c.req.header('if-none-match')
851
+ id!,
852
+ c.req.header('if-none-match'),
853
+ version !== undefined
856
854
  )
857
855
  })
858
856
 
@@ -886,16 +884,18 @@ one.put('/', async c => {
886
884
  const ws = c.get('ws')
887
885
  const body = await c.req.json()
888
886
  if (!body || body.version !== 1) return c.text('Bad request', 400)
887
+ // `origin` is the writing tab's id, echoed so that tab skips its own event.
888
+ const { origin, ...layout } = body
889
889
  // Preserve server-owned identity (name/icon) across a grid/theme save so the
890
890
  // client's PUT can't erase a `moi config`-set name. See mergeLayoutForSave.
891
891
  const existing = await loadLayout(ws.path)
892
- const next = mergeLayoutForSave(existing, body)
892
+ const next = mergeLayoutForSave(existing, layout)
893
893
  await saveLayout(next, ws.path)
894
894
  if (
895
895
  JSON.stringify(resolveWorkspaceTheme(existing.theme)) !==
896
896
  JSON.stringify(resolveWorkspaceTheme(next.theme))
897
897
  ) {
898
- publishEvent({ type: 'theme:updated' })
898
+ publishEvent({ type: 'theme:updated', origin: eventOrigin(origin) })
899
899
  }
900
900
  return c.body(null, 204)
901
901
  })
@@ -943,7 +943,7 @@ workspaces.put('/order', async c => {
943
943
  // List-only change: a narrow event so clients refetch just the sidebar
944
944
  // list, not every per-workspace query (`workspace:updated` also triggers
945
945
  // layout refetches in open workspaces).
946
- publishEvent({ type: 'workspaces-list:updated' })
946
+ publishEvent({ type: 'workspaces-list:updated', origin: eventOrigin(body.origin) })
947
947
  return c.json(await mergeWorkspaceList(entries))
948
948
  } catch (err) {
949
949
  const message = err instanceof Error ? err.message : String(err)
@@ -955,10 +955,10 @@ workspaces.put('/order', async c => {
955
955
  // provisioned with its workspaces; the UI never sends these requests (it opens
956
956
  // the cloud demo promo dialog instead), so a 403 here means the API was called
957
957
  // directly.
958
- const DEMO_CREATE_BLOCKED = 'Workspace creation is not available in the moi demo'
958
+ const DEMO_CREATE_BLOCKED = 'Workspace creation is not available in the Moi demo'
959
959
 
960
960
  workspaces.post('/', async c => {
961
- if (getAppConfig().cloudDemo) return c.text(DEMO_CREATE_BLOCKED, 403)
961
+ if (getAppConfig().demo) return c.text(DEMO_CREATE_BLOCKED, 403)
962
962
  const body = await c.req.json()
963
963
  if (!body?.path) return c.text('Missing path', 400)
964
964
  const requestedType: unknown = body?.type ?? 'claude-code'
@@ -992,6 +992,27 @@ workspaces.post('/', async c => {
992
992
 
993
993
  workspaces.get('/discover', async c => c.json(await discoverWorkspaces()))
994
994
 
995
+ // Home-card previews for every workspace in one request, keyed by id, so the
996
+ // home page fetches them beside the list instead of one per card after it.
997
+ workspaces.get('/previews', async c => {
998
+ const entries = await listWorkspaces()
999
+ const previews = await Promise.all(
1000
+ entries.map(async ws => {
1001
+ const views = await listCompiledViews(ws.path).catch(() => [])
1002
+ const preview = await getWorkspacePreview(ws.path, {
1003
+ getProviderPreview: includeFirstUserMessage =>
1004
+ harnessFor(ws).workspacePreview(ws, includeFirstUserMessage),
1005
+ viewIds: views.map(view => view.id),
1006
+ // Capture time in base36 keeps the versioned segment short and URL-safe.
1007
+ thumbnailUrl: (kind, id, capturedAt) =>
1008
+ `/api/workspaces/${ws.id}/applet-thumbnails/${kind}/${id}:${Date.parse(capturedAt).toString(36)}`
1009
+ })
1010
+ return [ws.id, preview] as const
1011
+ })
1012
+ )
1013
+ return c.json(Object.fromEntries(previews))
1014
+ })
1015
+
995
1016
  // Backends the create dialog can provision from scratch. OpenClaw workspaces
996
1017
  // belong to their agents and arrive via discovery.
997
1018
  const CREATABLE_TYPES = new Set<WorkspaceType>(['claude-code', 'codex'])
@@ -1000,31 +1021,16 @@ async function workspaceTypeAvailability(type: WorkspaceType): Promise<HarnessAv
1000
1021
  return (await harnessFor(type).availability?.()) ?? { status: 'available' }
1001
1022
  }
1002
1023
 
1003
- // Per-backend runtime availability, keyed by workspace type. Harnesses without
1004
- // the hook are always available.
1005
- async function harnessAvailability(): Promise<Record<string, HarnessAvailability>> {
1006
- const out: Record<string, HarnessAvailability> = {}
1007
- for (const h of allHarnesses()) {
1008
- out[h.id] = await workspaceTypeAvailability(h.id)
1009
- }
1010
- return out
1011
- }
1012
-
1013
- // Where `/workspace/create` places new folders — the client shows the resolved
1014
- // location while the user types a name. `availability` lets the dialog disable
1015
- // backends whose runtime is missing.
1016
- workspaces.get('/create', async c =>
1017
- c.json({
1018
- root: createdWorkspacesRoot(),
1019
- displayRoot: tildify(createdWorkspacesRoot()),
1020
- availability: await harnessAvailability()
1021
- })
1022
- )
1024
+ // Both workspace dialogs only need installation facts to offer agent choices.
1025
+ workspaces.get('/create', async c => {
1026
+ c.header('Cache-Control', 'no-store')
1027
+ return c.json({ installed: await detectInstalledHarnesses() })
1028
+ })
1023
1029
 
1024
1030
  // Create a brand-new workspace: a fresh folder under createdWorkspacesRoot(),
1025
1031
  // provisioned (skills + `.moi/` scaffold) and registered.
1026
1032
  workspaces.post('/create', async c => {
1027
- if (getAppConfig().cloudDemo) return c.text(DEMO_CREATE_BLOCKED, 403)
1033
+ if (getAppConfig().demo) return c.text(DEMO_CREATE_BLOCKED, 403)
1028
1034
  const body = await c.req.json()
1029
1035
  const requestedType: unknown = body?.type ?? 'claude-code'
1030
1036
  if (!isHarnessType(requestedType)) {
@@ -1062,6 +1068,7 @@ workspaces.route('/:id', one)
1062
1068
  export const api = new Hono()
1063
1069
 
1064
1070
  api.route('/api/workspaces', workspaces)
1071
+ api.route('/api/harnesses', harnesses)
1065
1072
 
1066
1073
  // Startup config (config.json in the data dir + MOI_* env), client-safe
1067
1074
  // subset. Immutable for the process lifetime — clients cache it forever.
@@ -1087,7 +1094,7 @@ api.post('/api/update', async c => {
1087
1094
  if (updateInProgress()) {
1088
1095
  return c.text(
1089
1096
  restartPendingForUpdate()
1090
- ? 'An update is installed — moi is restarting.'
1097
+ ? 'An update is installed — Moi is restarting.'
1091
1098
  : 'An update is already in progress.',
1092
1099
  409
1093
1100
  )
@@ -1102,7 +1109,7 @@ api.post('/api/update', async c => {
1102
1109
 
1103
1110
  try {
1104
1111
  const result = await installUpdate()
1105
- if (!result) return c.text('This moi install cannot be updated from the app.', 409)
1112
+ if (!result) return c.text('This Moi cannot be updated from the app', 409)
1106
1113
  const response = c.json(result)
1107
1114
  scheduleRestartForUpdate()
1108
1115
  return response
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from 'node:fs'
2
2
  import { isAbsolute, join } from 'path'
3
3
 
4
- import type { ClientAppConfig, ExperimentalFeatures } from '@/lib/types'
4
+ import type { AppEnvironment, ClientAppConfig, ExperimentalFeatures } from '@/lib/types'
5
5
  import { EXPERIMENTAL_DEFAULTS } from '@/lib/experimental'
6
6
 
7
7
  import { DATA_DIR } from './data-dir'
@@ -18,9 +18,10 @@ import { DATA_DIR } from './data-dir'
18
18
  // warns on stderr and falls back per-key, so a broken config never takes the
19
19
  // CLI or server down with it.
20
20
  export type AppConfig = {
21
- // Cloud demo deployment: workspace creation is blocked (UI shows the
21
+ environment: AppEnvironment
22
+ // Demo mode: workspace creation is blocked (UI shows the
22
23
  // cloud-demo promo dialog instead) and `moi` system commands are disabled.
23
- cloudDemo: boolean
24
+ demo: boolean
24
25
  experimental: ExperimentalFeatures
25
26
  // Link target for the cloud-demo promo dialog.
26
27
  demoInstallUrl: string
@@ -49,7 +50,8 @@ export type CloudflareAccessConfig = {
49
50
  type DeploymentConfig = Omit<AppConfig, 'experimental'>
50
51
 
51
52
  const DEFAULTS: AppConfig = {
52
- cloudDemo: false,
53
+ environment: 'local',
54
+ demo: false,
53
55
  experimental: { ...EXPERIMENTAL_DEFAULTS },
54
56
  demoInstallUrl: 'https://moi.computer',
55
57
  cloudflareAccess: null,
@@ -74,6 +76,13 @@ function parseBool(raw: string | undefined): boolean | undefined {
74
76
  return undefined
75
77
  }
76
78
 
79
+ function parseEnvironment(raw: unknown): AppEnvironment | undefined {
80
+ if (raw === undefined) return undefined
81
+ if (raw === 'local' || raw === 'cloud') return raw
82
+ warn('ignoring environment — expected "local" or "cloud"')
83
+ return undefined
84
+ }
85
+
77
86
  function parseString(raw: string | undefined): string | undefined {
78
87
  if (raw === undefined || raw.trim() === '') return undefined
79
88
  return raw.trim()
@@ -166,7 +175,7 @@ function readConfigFile(file: string): Record<string, unknown> {
166
175
  // Only a missing file is silent (the normal local case). Anything else —
167
176
  // permissions, mount errors — is loud: a deployment relying on config.json
168
177
  // must not boot un-gated without a diagnostic. Deployments that need the
169
- // demo gate guaranteed should pin MOI_CLOUD_DEMO=1 in the environment,
178
+ // demo gate guaranteed should pin MOI_DEMO=1 in the environment,
170
179
  // which has no read-failure mode.
171
180
  if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {
172
181
  warn(`could not read ${file}: ${err instanceof Error ? err.message : String(err)}`)
@@ -189,9 +198,11 @@ function readConfigFile(file: string): Record<string, unknown> {
189
198
 
190
199
  function fileValues(raw: Record<string, unknown>): Partial<DeploymentConfig> {
191
200
  const out: Partial<DeploymentConfig> = {}
192
- if (raw.cloudDemo !== undefined) {
193
- if (typeof raw.cloudDemo === 'boolean') out.cloudDemo = raw.cloudDemo
194
- else warn('ignoring "cloudDemo" — expected a boolean')
201
+ const environment = parseEnvironment(raw.environment)
202
+ if (environment !== undefined) out.environment = environment
203
+ if (raw.demo !== undefined) {
204
+ if (typeof raw.demo === 'boolean') out.demo = raw.demo
205
+ else warn('ignoring "demo" — expected a boolean')
195
206
  }
196
207
  if (raw.demoInstallUrl !== undefined) {
197
208
  if (typeof raw.demoInstallUrl === 'string') out.demoInstallUrl = raw.demoInstallUrl
@@ -215,7 +226,8 @@ export function loadAppConfig(
215
226
  const raw = readConfigFile(file)
216
227
  const fromFile = fileValues(raw)
217
228
  const fromEnv: Partial<DeploymentConfig> = {
218
- cloudDemo: parseBool(env.MOI_CLOUD_DEMO),
229
+ environment: parseEnvironment(env.MOI_ENVIRONMENT),
230
+ demo: parseBool(env.MOI_DEMO),
219
231
  demoInstallUrl: parseString(env.MOI_DEMO_INSTALL_URL)
220
232
  }
221
233
  const merged = { ...DEFAULTS, ...fromFile }
@@ -243,7 +255,7 @@ export function getAppConfig(): AppConfig {
243
255
  }
244
256
 
245
257
  // Test seam: drop the cached config so the next getAppConfig() re-resolves
246
- // (tests point MOI_DATA_DIR elsewhere or set MOI_CLOUD_DEMO).
258
+ // (tests point MOI_DATA_DIR elsewhere or set MOI_DEMO).
247
259
  export function resetAppConfig(): void {
248
260
  _config = null
249
261
  }
@@ -251,6 +263,6 @@ export function resetAppConfig(): void {
251
263
  // The only shape that reaches the browser (GET /api/config). Server-only keys
252
264
  // added to AppConfig later stay out unless explicitly forwarded here.
253
265
  export function clientAppConfig(): ClientAppConfig {
254
- const { cloudDemo, experimental, demoInstallUrl } = getAppConfig()
255
- return { cloudDemo, experimental: { ...experimental }, demoInstallUrl }
266
+ const { environment, demo, experimental, demoInstallUrl } = getAppConfig()
267
+ return { environment, demo, experimental: { ...experimental }, demoInstallUrl }
256
268
  }
@@ -4,7 +4,7 @@ import type { AppSettings } from '@/lib/types'
4
4
 
5
5
  import { DATA_DIR } from './data-dir'
6
6
 
7
- // App-wide user settings, stored as `settings.json` in moi's data dir next to
7
+ // App-wide user settings, stored as `settings.json` in Moi's data dir next to
8
8
  // the workspace registry. Backed by `conf`: atomic writes, per-key JSON-schema
9
9
  // validation, and migrations when the settings shape evolves. Adding a key
10
10
  // means extending `AppSettings` (lib/types.ts) and the schema here — with a
@@ -10,7 +10,7 @@
10
10
  //
11
11
  // The transform prefixes each selector with `[data-applet="<scope>"]` — the
12
12
  // attribute the client puts on the applet's mount container (see
13
- // client/features/applets/AppletContainer.tsx). Selectors that address the page
13
+ // client/features/applets/applet-container.tsx). Selectors that address the page
14
14
  // root (`:root`, `:host`, `html`, `body`) are mapped onto the container
15
15
  // itself, so theme variables and preflight inheritance (line-height, font)
16
16
  // land there and inherit down. Rules inside `@keyframes` are left alone —
@@ -92,7 +92,7 @@ async function validateServerExports(filePath: string): Promise<string[]> {
92
92
  return runtimeExports
93
93
  }
94
94
 
95
- // Server modules are keyed by their path relative to the moi root
95
+ // Server modules are keyed by their path relative to the Moi root
96
96
  // (`.moi/widgets/hello.server.ts` → `"widgets/hello"`), posix-normalized so
97
97
  // keys are stable across platforms. Throws when the file escapes the root.
98
98
  // Both sides are canonicalized first: Bun's resolver returns realpaths
@@ -112,7 +112,7 @@ function serverModuleKey(serverPath: string, moiRoot: string): string {
112
112
  .split(sep)
113
113
  .join('/')
114
114
  if (key === '..' || key.startsWith('../')) {
115
- throw new Error(`Server file "${serverPath}" escapes the moi root "${moiRoot}"`)
115
+ throw new Error(`Server file "${serverPath}" escapes the Moi root "${moiRoot}"`)
116
116
  }
117
117
  return key
118
118
  }
@@ -172,7 +172,7 @@ function appletRuntimePlugin(
172
172
 
173
173
  // Intercept .server imports (relative only). Resolved against the
174
174
  // importing file's directory — server files may live anywhere under
175
- // the moi root, e.g. `../lib/db.server`.
175
+ // the Moi root, e.g. `../lib/db.server`.
176
176
  build.onResolve({ filter: /\.server(\.ts)?$/ }, args => {
177
177
  if (!args.path.startsWith('.')) return
178
178
  const baseDir =
@@ -210,7 +210,7 @@ function appletRuntimePlugin(
210
210
  // provides the same texture utilities available to host components.
211
211
  const HOST_THEME_PATH = join(import.meta.dir, '..', '..', 'client', 'theme.css')
212
212
 
213
- // The shadcn styling vocabulary, text-inlined from moi's OWN node_modules the
213
+ // The shadcn styling vocabulary, text-inlined from Moi's OWN node_modules the
214
214
  // same way theme.css is. Tailwind v4 only emits utilities it can resolve:
215
215
  // installed ui components lean on `tw-animate-css` (animate-in/out, fade,
216
216
  // zoom, slide) and `shadcn/tailwind.css` (data-open/data-closed variants,
@@ -3,7 +3,7 @@
3
3
  // `Bun.build` shares one process-wide resolver cache with the runtime module
4
4
  // loader: `node_modules` directory listings, `package.json` contents, and —
5
5
  // crucially — FAILED bare-specifier lookups are memoized for the life of the
6
- // process and never invalidated (still true in Bun 1.4). The moi server is
6
+ // process and never invalidated (still true in Bun 1.4). The Moi server is
7
7
  // long-lived, so an in-process build that once failed with `Could not resolve
8
8
  // "pkg"` keeps failing for that specifier after the agent runs `bun add pkg`,
9
9
  // and a workspace that gains its own `node_modules` (or bumps a package's
@@ -21,7 +21,7 @@ type ParsedConfig = {
21
21
  // Static config analysis, shared by compilation and source editing. Never
22
22
  // evaluate workspace code to resolve variables, spreads, or function calls.
23
23
  // Parsed with @babel/parser: it handles TS + JSX with no peer dependencies, so
24
- // it always resolves from moi's own tree. A parser that peer-depends on
24
+ // it always resolves from Moi's own tree. A parser that peer-depends on
25
25
  // `typescript` breaks under bun's shared global tree, where another globally
26
26
  // installed package controls which `typescript` sits at the hoisted root.
27
27
  function parseConfig(source: string, editing = false): ParsedConfig {
@@ -4,7 +4,7 @@ import { parse, stringify } from 'devalue'
4
4
  import { join, resolve, sep } from 'path'
5
5
 
6
6
  const MEI_DIR =
7
- process.env.MEI_FUNCTIONS_DIR ?? join(import.meta.dir, '..', 'test-workspace', '.moi')
7
+ process.env.MEI_FUNCTIONS_DIR ?? join(import.meta.dir, '..', '..', 'test-workspace', '.moi')
8
8
 
9
9
  // The parent spawns us from a neutral cwd so Bun never auto-loads the
10
10
  // workspace's `.env` into this process — moi injects the resolved, scope-filtered
@@ -20,8 +20,8 @@ import { readFileSync } from 'node:fs'
20
20
  import { tmpdir } from 'node:os'
21
21
  import { join } from 'path'
22
22
 
23
- import { agentCommand } from './agent-launcher'
24
- import { resolveWorkspaceEnv } from './workspace-env'
23
+ import { agentCommand } from '../agent-launcher'
24
+ import { resolveWorkspaceEnv } from '../workspaces/env'
25
25
 
26
26
  const WORKER_PATH = join(import.meta.dir, 'functions-worker.ts')
27
27
  const CALL_TIMEOUT_MS = 30_000