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.
- package/README.md +27 -27
- package/bin/moi.mjs +2 -2
- package/client/AGENTS.md +7 -4
- package/client/api/app-config.ts +3 -2
- package/client/api/app-ui-keys.ts +1 -1
- package/client/api/workspace-keys.ts +2 -4
- package/client/app/{AppRouter.tsx → app-router.tsx} +4 -4
- package/client/app/routes/{HomeRoute.tsx → home-route.tsx} +2 -2
- package/client/app/routes/{WorkspaceRoute.tsx → workspace-route.tsx} +20 -31
- package/client/app/shell/{SidebarLayout.tsx → sidebar-layout.tsx} +10 -10
- package/client/dev/index.html +43 -0
- package/client/dev/index.ts +15 -0
- package/client/features/applets/{AppletContainer.tsx → applet-container.tsx} +1 -1
- package/client/features/applets/applet-runtime.ts +11 -13
- package/client/features/applets/applet-thumbnail.ts +1 -1
- package/client/features/applets/{useApplet.ts → use-applet.ts} +2 -2
- package/client/features/applets/{WidgetShell.tsx → widget-shell.tsx} +4 -4
- package/client/features/chat/applet-chat-intents.ts +33 -14
- package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +80 -59
- package/client/features/chat/chat-popup.tsx +171 -0
- package/client/features/chat/chat-send.ts +33 -1
- package/client/features/chat/chat-store.ts +10 -0
- package/client/features/chat/composer/attachments/{DrawingAttachmentChip.tsx → drawing-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/attachments/{FileAttachmentChip.tsx → file-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/attachments/{TextAttachmentChip.tsx → text-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/banners/{ComposerBanner.tsx → composer-banner.tsx} +0 -14
- package/client/features/chat/composer/banners/{ErrorBanner.tsx → error-banner.tsx} +1 -1
- package/client/features/chat/composer/banners/{SkillUpdateBanner.tsx → skill-update-banner.tsx} +3 -3
- package/client/features/chat/composer/{ChatComposer.tsx → chat-composer.tsx} +31 -33
- package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +4 -4
- package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +14 -30
- package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
- package/client/features/chat/connection/chat-frames.ts +15 -8
- package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +37 -23
- package/client/features/chat/messages/fork-history.ts +14 -0
- package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +4 -4
- package/client/features/chat/messages/tool-group/index.ts +1 -1
- package/client/features/chat/messages/tool-group/{ReadImagePreview.tsx → read-image-preview.tsx} +2 -2
- package/client/features/chat/messages/tool-group/{SubagentCard.tsx → subagent-card.tsx} +3 -3
- package/client/features/chat/messages/tool-group/{TimelineRow.tsx → timeline-row.tsx} +1 -1
- package/client/features/chat/messages/tool-group/{ToolCallGroup.tsx → tool-call-group.tsx} +8 -8
- package/client/features/chat/messages/tool-group/{ToolOutput.tsx → tool-output.tsx} +1 -1
- package/client/features/chat/messages/{TurnView.tsx → turn-view.tsx} +4 -4
- package/client/features/chat/sessions/api.ts +109 -19
- package/client/features/chat/sessions/browser-tab-state.ts +30 -7
- package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +139 -80
- package/client/features/chat/sessions/use-selected-session.ts +351 -0
- package/client/features/chat/{useChat.ts → use-chat.ts} +46 -48
- package/client/features/collab/client.ts +10 -11
- package/client/features/collab/hooks.tsx +6 -11
- package/client/features/collab/host-state.ts +57 -128
- package/client/features/collab/provider.tsx +3 -3
- package/client/features/collab/proxy-user.ts +1 -1
- package/client/features/collab/testing/fake-engine.ts +6 -27
- package/client/features/collab/workspace-users-menu.tsx +3 -7
- package/client/features/connectors/mcp-icons.ts +1 -1
- package/client/features/connectors/{McpServerCards.tsx → mcp-server-cards.tsx} +1 -1
- package/client/features/{home/workspace-setup/DemoDialog.tsx → demo/demo-dialog.tsx} +6 -6
- package/client/features/dev/chat-states-fixtures.ts +4 -4
- package/client/features/dev/{ChatStatesPage.tsx → chat-states-page.tsx} +6 -6
- package/client/features/dev/collab/local-user-settings.tsx +4 -4
- package/client/features/dev/{DevIndexPage.tsx → dev-index-page.tsx} +7 -1
- package/client/features/dev/{DevRoutes.tsx → dev-routes.tsx} +8 -6
- package/client/features/dev/workspace-setup-mocks.ts +102 -0
- package/client/features/dev/workspace-setup-page.tsx +11 -0
- package/client/features/dev/workspace-setup-preview.tsx +226 -0
- package/client/features/drawings/{DrawingToolbar.tsx → drawing-toolbar.tsx} +1 -1
- package/client/features/drawings/{useChatAnnotation.ts → use-chat-annotation.ts} +29 -23
- package/client/features/drawings/{useDrawingLayer.ts → use-drawing-layer.ts} +1 -1
- package/client/features/drawings/{useViewBuilderSketch.ts → use-view-sketch.ts} +8 -8
- package/client/features/harness/api.ts +36 -0
- package/client/features/harness/device-login-steps.tsx +97 -0
- package/client/features/home/api.ts +1 -81
- package/client/features/home/{HomeLogo.tsx → home-logo.tsx} +1 -1
- package/client/features/home/{HomePage.tsx → home-page.tsx} +16 -20
- package/client/features/overview/api.ts +2 -2
- package/client/features/overview/default/registry.tsx +3 -5
- package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +6 -13
- package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
- package/client/features/overview/{Overview.tsx → overview.tsx} +9 -12
- package/client/features/overview/{WidgetCanvas.tsx → widget-canvas.tsx} +1 -1
- package/client/features/overview/{WidgetFrame.tsx → widget-frame.tsx} +1 -1
- package/client/features/overview/workspace-name.tsx +55 -0
- package/client/features/scratchpad/{Scratchpad.tsx → scratchpad.tsx} +7 -7
- package/client/features/scratchpad/{useScratchpadSnapshot.tsx → use-scratchpad-snapshot.tsx} +3 -3
- package/client/features/settings/api.ts +1 -1
- package/client/features/settings/{ConnectorsSettings.tsx → connectors-settings.tsx} +3 -3
- package/client/features/settings/{EnvironmentSettings.tsx → environment-settings.tsx} +3 -3
- package/client/features/settings/{GeneralSettings.tsx → general-settings.tsx} +5 -5
- package/client/features/settings/{useEnvVars.ts → use-env-vars.ts} +1 -1
- package/client/features/settings/{WorkspaceIconPicker.tsx → workspace-icon-picker.tsx} +1 -1
- package/client/features/settings/{WorkspaceSettingsDialog.tsx → workspace-settings-dialog.tsx} +3 -3
- package/client/features/update/api.ts +1 -1
- package/client/features/views/api.ts +64 -131
- package/client/features/views/pending-view-screen.tsx +282 -0
- package/client/features/views/use-view-actions.ts +151 -0
- package/client/features/views/use-view-drafts.ts +88 -0
- package/client/features/views/{ViewManager.tsx → view-manager.tsx} +13 -13
- package/client/features/views/view-presentation.ts +4 -5
- package/client/features/views/view-submission.ts +88 -0
- package/client/features/workspace/add/api.ts +80 -0
- package/client/features/{home/workspace-setup/CreateWorkspaceDialog.tsx → workspace/add/create-workspace-dialog.tsx} +56 -42
- package/client/features/workspace/add/import-workspace-dialog.tsx +81 -0
- package/client/features/{home/workspace-setup/useWorkspaceImport.ts → workspace/add/use-workspace-import.ts} +1 -1
- package/client/features/workspace/add/workspace-agent-options.ts +53 -0
- package/client/features/{home/workspace-setup/WorkspaceAgentStep.tsx → workspace/add/workspace-agent-selector.tsx} +59 -98
- package/client/features/{home/workspace-setup/WorkspaceDialogContent.tsx → workspace/add/workspace-dialog-content.tsx} +1 -1
- package/client/features/workspace/api.ts +24 -15
- package/client/features/workspace/browser-tab-state.ts +16 -9
- package/client/features/workspace/moi-context.ts +14 -16
- package/client/features/workspace/setup/workspace-login-state.tsx +175 -0
- package/client/features/workspace/setup/workspace-recovery-states.tsx +125 -0
- package/client/features/workspace/setup/workspace-setup-panel.tsx +18 -0
- package/client/features/workspace/setup/workspace-setup.tsx +77 -0
- package/client/features/workspace/setup/workspace-welcome-state.tsx +81 -0
- package/client/features/workspace/tab-resolution.ts +16 -29
- package/client/features/workspace/{ThemePanel.tsx → theme-panel.tsx} +3 -3
- package/client/features/workspace/use-workspace-navigation.ts +245 -0
- package/client/features/workspace/workspace-content.tsx +641 -0
- package/client/features/workspace/workspace-identity.tsx +40 -0
- package/client/features/workspace/workspace-menu.tsx +63 -0
- package/client/features/{home → workspace}/workspace-presentation.tsx +10 -3
- package/client/features/workspace/workspace-screen.tsx +28 -0
- package/client/features/workspace/{WorkspaceSplitLayout.tsx → workspace-split-layout.tsx} +1 -1
- package/client/features/workspace/{WorkspaceTabs.tsx → workspace-tabs.tsx} +2 -2
- package/client/index.css +2 -2
- package/client/index.html +1 -1
- package/client/index.tsx +5 -1
- package/client/lib/agent-availability.ts +0 -5
- package/client/main.tsx +1 -1
- package/client/runtime/{useWorkspaceEvents.ts → use-workspace-events.ts} +10 -18
- package/client/store/ui.ts +25 -29
- package/dist/chunk-08ndj2rg.js +2 -0
- package/dist/chunk-2x040tmg.js +68 -0
- package/dist/chunk-3smxq0ts.js +1 -0
- package/dist/chunk-68ch5hs8.js +2 -0
- package/dist/{chunk-z3byfve5.js → chunk-9vg3xa81.js} +2 -2
- package/dist/chunk-c2p00p9j.css +1 -0
- package/dist/chunk-cs833y9j.js +1 -0
- package/dist/{chunk-97eg9mjn.js → chunk-d7cbm65e.js} +1 -1
- package/dist/{chunk-efdyz6xp.js → chunk-hvh9f5h0.js} +1 -1
- package/dist/{chunk-vfpsc75k.js → chunk-jvyvwwv3.js} +1 -1
- package/dist/chunk-nwevqe86.js +10 -0
- package/dist/{chunk-3a48fyf7.js → chunk-q0gbdts4.js} +4 -4
- package/dist/chunk-rt30jbcm.js +1 -0
- package/dist/chunk-y5y3kj67.js +1 -0
- package/dist/index.html +2 -2
- package/lib/format.ts +1 -1
- package/lib/harness-instructions.ts +30 -0
- package/lib/ids.ts +3 -6
- package/lib/moi-context.ts +102 -75
- package/lib/navigation.ts +48 -87
- package/lib/scratchpad-skew.ts +3 -3
- package/lib/session-drafts.ts +10 -0
- package/lib/types.ts +92 -51
- package/lib/update.ts +1 -1
- package/lib/view-build-directives.ts +12 -0
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-tabs.ts +12 -7
- package/package.json +7 -2
- package/server/AGENTS.md +10 -4
- package/server/README.md +102 -0
- package/server/agent-launcher.ts +27 -0
- package/server/api/harnesses.ts +56 -0
- package/server/{api.ts → api/index.ts} +197 -299
- package/server/app-config.ts +45 -14
- package/server/app-settings.ts +1 -1
- package/server/applets/applet-css.ts +1 -1
- package/server/applets/build-applet.ts +4 -4
- package/server/applets/build-worker.ts +3 -2
- package/server/applets/config.ts +1 -1
- package/server/{functions-worker.ts → applets/functions-worker.ts} +1 -1
- package/server/{functions.ts → applets/functions.ts} +3 -2
- package/server/applets/index.ts +2 -2
- package/server/{thumbnails.ts → applets/thumbnails.ts} +1 -1
- package/server/{applet-typecheck.ts → applets/typecheck.ts} +4 -4
- package/server/{ui-components.ts → applets/ui-components.ts} +2 -2
- package/server/applets/view-source.ts +7 -1
- package/server/{views.ts → applets/views.ts} +35 -46
- package/server/{widgets.ts → applets/widgets.ts} +2 -2
- package/server/cli/applet-selector.ts +19 -0
- package/server/cli/args.ts +5 -0
- package/server/{cli-colors.ts → cli/colors.ts} +1 -1
- package/server/cli/commands/bundle.ts +119 -0
- package/server/cli/commands/call-server-fn.ts +42 -0
- package/server/cli/commands/check.ts +53 -0
- package/server/cli/commands/config.ts +132 -0
- package/server/cli/commands/debug.ts +119 -0
- package/server/cli/commands/env.ts +162 -0
- package/server/cli/commands/hermes.ts +149 -0
- package/server/cli/commands/init.ts +286 -0
- package/server/cli/commands/navigate.ts +35 -0
- package/server/cli/commands/openclaw.ts +168 -0
- package/server/cli/commands/refresh.ts +39 -0
- package/server/cli/commands/scratch.ts +496 -0
- package/server/cli/commands/service.ts +298 -0
- package/server/cli/commands/skill.ts +122 -0
- package/server/cli/commands/start.ts +138 -0
- package/server/cli/commands/status.ts +80 -0
- package/server/cli/commands/tabs.ts +43 -0
- package/server/cli/commands/theme.ts +192 -0
- package/server/cli/commands/ui-components.ts +15 -0
- package/server/cli/commands/update.ts +192 -0
- package/server/cli/commands/version.ts +9 -0
- package/server/cli/commands/views.ts +87 -0
- package/server/cli/control.ts +89 -0
- package/server/{cli-env.ts → cli/env.ts} +78 -56
- package/server/cli/index.ts +171 -0
- package/server/{cli-pc.ts → cli/pc.ts} +1 -1
- package/server/cli/provider.ts +25 -0
- package/server/cli/server-version.ts +16 -0
- package/server/cli/server.ts +81 -0
- package/server/{cli-ui-components.ts → cli/ui-components.ts} +5 -5
- package/server/cli.ts +2 -3215
- package/server/collab/manager.ts +3 -3
- package/server/collab/skill/index.ts +2 -2
- package/server/control.ts +97 -78
- package/server/data-dir.ts +13 -0
- package/server/harness/README.md +55 -25
- package/server/harness/acp/NOTES.md +11 -11
- package/server/harness/acp/adapter.ts +2 -2
- package/server/harness/acp/archived.ts +3 -3
- package/server/harness/acp/client.ts +4 -3
- package/server/harness/acp/discovery.ts +3 -3
- package/server/harness/acp/run-durations.ts +1 -1
- package/server/harness/acp/session.ts +9 -12
- package/server/harness/auth.ts +303 -0
- package/server/harness/claude-code/NOTES.md +9 -7
- package/server/harness/claude-code/adapter.ts +13 -8
- package/server/harness/claude-code/auth.ts +127 -18
- package/server/harness/claude-code/cli.ts +3 -1
- package/server/harness/claude-code/git-worktree.ts +5 -2
- package/server/harness/claude-code/index.ts +7 -1
- package/server/harness/claude-code/mcp.ts +3 -1
- package/server/harness/claude-code/models.ts +2 -0
- package/server/harness/claude-code/session.ts +13 -39
- package/server/harness/claude-code/sessions.ts +8 -12
- package/server/harness/codex/NOTES.md +35 -16
- package/server/harness/codex/adapter.ts +5 -3
- package/server/harness/codex/auth.ts +86 -19
- package/server/harness/codex/client.ts +30 -34
- package/server/harness/codex/index.ts +20 -1
- package/server/harness/codex/permissions.ts +3 -3
- package/server/harness/codex/probe.ts +3 -5
- package/server/harness/codex/session.ts +20 -25
- package/server/harness/codex/thread-list.ts +74 -0
- package/server/harness/codex/transport.ts +5 -5
- package/server/harness/executable.ts +42 -18
- package/server/harness/fork.ts +12 -0
- package/server/harness/hermes/NOTES.md +70 -70
- package/server/harness/hermes/discovery.ts +1 -1
- package/server/harness/openclaw/NOTES.md +24 -24
- package/server/harness/openclaw/adapter.ts +4 -4
- package/server/harness/openclaw/compat.ts +1 -1
- package/server/harness/openclaw/session.ts +6 -31
- package/server/harness/registry.ts +1 -1
- package/server/harness/session-title.ts +12 -3
- package/server/harness/shell-path.ts +31 -21
- package/server/harness/types.ts +17 -5
- package/server/navigation-relay.ts +1 -1
- package/server/open-browser.ts +7 -0
- package/server/{scratchpad-assets.ts → scratchpad/assets.ts} +4 -4
- package/server/{scratchpad.ts → scratchpad/document.ts} +8 -8
- package/server/{scratchpad-executor.ts → scratchpad/executor.ts} +7 -7
- package/server/{scratchpad-relay.ts → scratchpad/relay.ts} +4 -5
- package/server/{scratchpad-shape-defaults.ts → scratchpad/shape-defaults.ts} +2 -2
- package/server/server-cwd.ts +1 -1
- package/server/service.ts +18 -4
- package/server/sessions/archive.ts +32 -0
- package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
- package/server/sessions/config.ts +41 -0
- package/server/sessions/lifecycle.ts +17 -0
- package/server/sessions/pending-views.ts +164 -0
- package/server/sessions/selected.ts +199 -0
- package/server/sessions/store.ts +127 -0
- package/server/sessions/view-sessions.ts +267 -0
- package/server/{skills-template.ts → skills/template.ts} +1 -1
- package/server/{skill-update.ts → skills/update.ts} +5 -5
- package/server/{skill-version.ts → skills/version.ts} +4 -4
- package/server/static.ts +1 -1
- package/server/status.ts +6 -4
- package/server/web.ts +58 -49
- package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
- package/server/{workspace-env.ts → workspaces/env.ts} +30 -3
- package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
- package/server/{workspace-init.ts → workspaces/init.ts} +10 -6
- package/server/{layout.ts → workspaces/layout.ts} +2 -2
- package/server/{preview.ts → workspaces/preview.ts} +1 -1
- package/server/{registry.ts → workspaces/registry.ts} +17 -7
- package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
- package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +4 -3
- package/server/{tabs.ts → workspaces/tabs.ts} +7 -10
- package/ui-components/button.tsx +1 -1
- package/ui-components/docs/attachment.md +2 -2
- package/ui-components/docs/button.md +1 -1
- package/ui-components/docs/calendar.md +1 -1
- package/ui-components/docs/chart.md +4 -4
- package/ui-components/docs/data-table.md +1 -1
- package/ui-components/docs/drawer.md +1 -1
- package/ui-components/docs/field.md +1 -1
- package/ui-components/docs/input.md +2 -2
- package/ui-components/docs/label.md +2 -2
- package/ui-components/docs/table.md +2 -2
- package/workspace/.claude/skills/moi-workspace/SKILL.md +61 -32
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +4 -7
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +2 -2
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +2 -2
- package/client/features/chat/ChatPopup.tsx +0 -98
- package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +0 -101
- package/client/features/chat/sessions/useSelectedSession.ts +0 -185
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
- package/client/features/overview/WorkspaceName.tsx +0 -60
- package/client/features/views/ViewBuilder.tsx +0 -239
- package/client/features/views/useViewBuilderActions.ts +0 -103
- package/client/features/views/useViewBuilderDrafts.ts +0 -68
- package/client/features/workspace/WorkspaceScreen.tsx +0 -839
- package/client/features/workspace/useWorkspaceNavigation.ts +0 -203
- package/dist/chunk-2jncyq65.js +0 -1
- package/dist/chunk-e2q5ken7.js +0 -68
- package/dist/chunk-h2kj1ysj.js +0 -1
- package/dist/chunk-jf6czgrz.js +0 -2
- package/dist/chunk-nez8sdta.js +0 -1
- package/dist/chunk-nzwgm8vc.css +0 -1
- package/dist/chunk-ph0h6h86.js +0 -1
- package/dist/chunk-ryg9z3kn.js +0 -10
- package/dist/chunk-tpn177bt.js +0 -2
- package/lib/view-builder-directives.ts +0 -16
- package/server/agent.ts +0 -223
- package/server/chat-selection.ts +0 -22
- package/server/selected-session.ts +0 -152
- package/server/session-config.ts +0 -136
- package/server/view-builders.ts +0 -453
- /package/client/components/shared/{AgentBlobatar.tsx → agent-blobatar.tsx} +0 -0
- /package/client/components/shared/{BottomPanel.tsx → bottom-panel.tsx} +0 -0
- /package/client/components/shared/{Composer.tsx → composer.tsx} +0 -0
- /package/client/components/shared/{LedLogo.tsx → led-logo.tsx} +0 -0
- /package/client/components/shared/{PanelHeader.tsx → panel-header.tsx} +0 -0
- /package/client/components/shared/{ReorderableList.tsx → reorderable-list.tsx} +0 -0
- /package/client/components/shared/{WorkspaceIcon.tsx → workspace-icon.tsx} +0 -0
- /package/client/features/applets/{WidgetErrorBoundary.tsx → widget-error-boundary.tsx} +0 -0
- /package/client/features/chat/composer/attachments/{AttachmentChip.tsx → attachment-chip.tsx} +0 -0
- /package/client/features/chat/messages/{ChatPromptBubbles.tsx → chat-prompt-bubbles.tsx} +0 -0
- /package/client/features/chat/messages/{ShimmerText.tsx → shimmer-text.tsx} +0 -0
- /package/client/features/chat/messages/tool-group/{CodeBlock.tsx → code-block.tsx} +0 -0
- /package/client/features/chat/messages/tool-group/{Collapse.tsx → collapse.tsx} +0 -0
- /package/client/features/chat/messages/{useStickToBottom.ts → use-stick-to-bottom.ts} +0 -0
- /package/client/features/connectors/{IconMcp.tsx → icon-mcp.tsx} +0 -0
- /package/client/features/dev/{BlobatarShapesPage.tsx → blobatar-shapes-page.tsx} +0 -0
- /package/client/features/dev/{HarnessDebugPage.tsx → harness-debug-page.tsx} +0 -0
- /package/client/features/dev/{TextureLabPage.tsx → texture-lab-page.tsx} +0 -0
- /package/client/features/dev/{ToolCallsPage.tsx → tool-calls-page.tsx} +0 -0
- /package/client/features/drawings/{DrawingLayer.tsx → drawing-layer.tsx} +0 -0
- /package/client/features/home/{WorkspacePreview.tsx → workspace-preview.tsx} +0 -0
- /package/client/features/overview/{useGridReconcile.ts → use-grid-reconcile.ts} +0 -0
- /package/client/features/scratchpad/{ScratchpadControls.tsx → scratchpad-controls.tsx} +0 -0
- /package/client/features/settings/{SettingsLayout.tsx → settings-layout.tsx} +0 -0
- /package/client/features/update/{UpdateControl.tsx → update-control.tsx} +0 -0
- /package/client/features/workspace/{UnavailablePage.tsx → unavailable-page.tsx} +0 -0
- /package/client/features/workspace/{useFitsSplitLayout.ts → use-fits-split-layout.ts} +0 -0
- /package/client/features/workspace/{WorkspaceContext.tsx → workspace-context.tsx} +0 -0
- /package/client/features/workspace/{WorkspaceLayoutContext.tsx → workspace-layout-context.tsx} +0 -0
- /package/server/{bundle-queue.ts → applets/bundle-queue.ts} +0 -0
- /package/server/{applet-log.ts → applets/log.ts} +0 -0
- /package/server/{cli-ui.ts → cli/ui.ts} +0 -0
- /package/server/{workspace-config.ts → workspaces/config.ts} +0 -0
- /package/server/{icon.ts → workspaces/icon.ts} +0 -0
- /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'
|
|
@@ -13,93 +14,94 @@ import type {
|
|
|
13
14
|
AppletThumbnailBatch,
|
|
14
15
|
AppSettings,
|
|
15
16
|
HarnessAvailability,
|
|
16
|
-
SessionInfo,
|
|
17
17
|
SelectedSessionScope,
|
|
18
18
|
UploadInfo,
|
|
19
|
-
ViewBuilderInput,
|
|
20
19
|
WorkspaceAgent,
|
|
21
20
|
WorkspaceEntry,
|
|
22
21
|
WorkspaceType
|
|
23
22
|
} from '@/lib/types'
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
import { isWorkspaceTabId } from '@/lib/workspace-tabs'
|
|
24
|
+
|
|
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'
|
|
41
43
|
import {
|
|
42
44
|
getAppletThumbnailRecords,
|
|
43
45
|
isValidAppletId,
|
|
44
46
|
saveAppletThumbnails,
|
|
45
47
|
serveAppletThumbnail
|
|
46
|
-
} from '
|
|
47
|
-
import { getClientFrameLog, getWireLog } from '
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
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'
|
|
50
52
|
import {
|
|
51
53
|
discoverWorkspaces,
|
|
52
54
|
getWorkspace,
|
|
53
55
|
listWorkspaces,
|
|
54
56
|
registerWorkspace,
|
|
55
57
|
removeWorkspace,
|
|
56
|
-
reorderWorkspaces
|
|
57
|
-
|
|
58
|
-
} from '
|
|
59
|
-
import {
|
|
60
|
-
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'
|
|
61
62
|
import {
|
|
62
|
-
|
|
63
|
+
getPinnedSession,
|
|
63
64
|
getSelectedSession,
|
|
64
|
-
|
|
65
|
+
getWorkspaceSessionSelection,
|
|
66
|
+
pinSession,
|
|
65
67
|
saveSelectedSession
|
|
66
|
-
} from '
|
|
67
|
-
import type { SelectedSessionUpdate } from '
|
|
68
|
-
import {
|
|
69
|
-
import type { SessionConfigPatch } from '
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
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'
|
|
75
79
|
import {
|
|
76
80
|
deleteView,
|
|
77
|
-
|
|
81
|
+
listCompiledViews,
|
|
78
82
|
listViews,
|
|
79
83
|
serveView,
|
|
80
84
|
updateViewTitle,
|
|
81
85
|
ViewMutationError
|
|
82
|
-
} from '
|
|
86
|
+
} from '../applets/views'
|
|
83
87
|
import {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} from '
|
|
92
|
-
import {
|
|
93
|
-
import { getWorkspaceConfig, setWorkspaceConfig } from './workspace-config'
|
|
88
|
+
createPendingView,
|
|
89
|
+
discardPendingView,
|
|
90
|
+
getPendingView,
|
|
91
|
+
updatePendingView,
|
|
92
|
+
PendingViewError
|
|
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'
|
|
94
97
|
import {
|
|
95
|
-
|
|
98
|
+
createdWorkspacesRoot,
|
|
96
99
|
provisionWorkspace,
|
|
97
100
|
validateWorkspaceFolderName
|
|
98
|
-
} from '
|
|
99
|
-
import { resolveWorkspaceImportMetadata } from '
|
|
100
|
-
import type { WorkspaceImportMetadata } from '
|
|
101
|
-
import { getWorkspaceEnvView,
|
|
102
|
-
import type { EnvUpdate } 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'
|
|
103
105
|
import {
|
|
104
106
|
getCachedUpdateStatus,
|
|
105
107
|
hasRunningAgentSessions,
|
|
@@ -107,7 +109,7 @@ import {
|
|
|
107
109
|
restartPendingForUpdate,
|
|
108
110
|
scheduleRestartForUpdate,
|
|
109
111
|
updateInProgress
|
|
110
|
-
} from '
|
|
112
|
+
} from '../update'
|
|
111
113
|
|
|
112
114
|
// The resolved workspace is stashed on the context by `withWorkspace`, so every
|
|
113
115
|
// `/api/workspaces/:id/*` handler can read it without re-querying the registry.
|
|
@@ -178,7 +180,7 @@ one.use('*', withWorkspace)
|
|
|
178
180
|
|
|
179
181
|
one.get('/preview', async c => {
|
|
180
182
|
const ws = c.get('ws')
|
|
181
|
-
const views = await
|
|
183
|
+
const views = await listCompiledViews(ws.path)
|
|
182
184
|
return c.json(
|
|
183
185
|
await getWorkspacePreview(ws.path, {
|
|
184
186
|
getProviderPreview: includeFirstUserMessage =>
|
|
@@ -210,13 +212,34 @@ one.get('/views', c => listViews(c.get('ws').path))
|
|
|
210
212
|
one.patch('/views/:viewId', async c => {
|
|
211
213
|
const ws = c.get('ws')
|
|
212
214
|
const body = await c.req.json().catch(() => null)
|
|
215
|
+
if (await getPendingView(ws.path, c.req.param('viewId'))) {
|
|
216
|
+
try {
|
|
217
|
+
if (
|
|
218
|
+
typeof body?.requirements !== 'string' &&
|
|
219
|
+
typeof body?.title !== 'string' &&
|
|
220
|
+
typeof body?.icon !== 'string'
|
|
221
|
+
)
|
|
222
|
+
return c.text('Expected requirements, title, or icon', 400)
|
|
223
|
+
return c.json(
|
|
224
|
+
await updatePendingView(ws.id, ws.path, c.req.param('viewId'), {
|
|
225
|
+
requirements: typeof body.requirements === 'string' ? body.requirements : undefined,
|
|
226
|
+
title: typeof body.title === 'string' ? body.title.trim() : undefined,
|
|
227
|
+
icon: typeof body.icon === 'string' ? body.icon : undefined
|
|
228
|
+
})
|
|
229
|
+
)
|
|
230
|
+
} catch (error) {
|
|
231
|
+
if (error instanceof PendingViewError) return c.text(error.message, error.status)
|
|
232
|
+
throw error
|
|
233
|
+
}
|
|
234
|
+
}
|
|
213
235
|
const title = typeof body?.title === 'string' ? body.title.trim() : ''
|
|
214
236
|
if (!title) return c.text('Expected { title: string }', 400)
|
|
215
237
|
|
|
216
238
|
try {
|
|
217
239
|
return c.json(await updateViewTitle(publishEvent, ws.id, ws.path, c.req.param('viewId'), title))
|
|
218
240
|
} catch (error) {
|
|
219
|
-
if (error instanceof ViewMutationError
|
|
241
|
+
if (error instanceof ViewMutationError || error instanceof PendingViewError)
|
|
242
|
+
return c.text(error.message, error.status)
|
|
220
243
|
throw error
|
|
221
244
|
}
|
|
222
245
|
})
|
|
@@ -224,10 +247,20 @@ one.patch('/views/:viewId', async c => {
|
|
|
224
247
|
one.delete('/views/:viewId', async c => {
|
|
225
248
|
const ws = c.get('ws')
|
|
226
249
|
try {
|
|
227
|
-
|
|
250
|
+
const viewId = c.req.param('viewId')
|
|
251
|
+
if (await getPendingView(ws.path, viewId)) {
|
|
252
|
+
const active = new Set(
|
|
253
|
+
harnessFor(ws)
|
|
254
|
+
.activeSessions()
|
|
255
|
+
.filter(session => session.workspaceId === ws.id)
|
|
256
|
+
.map(session => session.sessionId)
|
|
257
|
+
)
|
|
258
|
+
await discardPendingView(ws, viewId, active)
|
|
259
|
+
} else await deleteView(publishEvent, ws, viewId)
|
|
228
260
|
return c.body(null, 204)
|
|
229
261
|
} catch (error) {
|
|
230
|
-
if (error instanceof ViewMutationError
|
|
262
|
+
if (error instanceof ViewMutationError || error instanceof PendingViewError)
|
|
263
|
+
return c.text(error.message, error.status)
|
|
231
264
|
throw error
|
|
232
265
|
}
|
|
233
266
|
})
|
|
@@ -239,80 +272,26 @@ one.get('/views/*', c => {
|
|
|
239
272
|
return serveView(name, file, ws.path, apiBaseFor(ws.id), c.req.header('if-none-match'))
|
|
240
273
|
})
|
|
241
274
|
|
|
242
|
-
|
|
243
|
-
return err instanceof ViewBuilderError ? { message: err.message, status: err.status } : null
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function parseAvailableViewIcons(value: unknown): string[] | null {
|
|
247
|
-
if (!Array.isArray(value)) return null
|
|
248
|
-
const icons = value.filter(
|
|
249
|
-
(icon): icon is string =>
|
|
250
|
-
typeof icon === 'string' && /^[a-z0-9][a-z0-9-]*$/.test(icon) && icon.length <= 64
|
|
251
|
-
)
|
|
252
|
-
return icons.length > 0 ? [...new Set(icons)] : null
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
one.get('/view-builders', async c => {
|
|
256
|
-
const ws = c.get('ws')
|
|
257
|
-
const activeSessionIds = new Set(
|
|
258
|
-
allHarnesses()
|
|
259
|
-
.flatMap(h => h.activeSessions())
|
|
260
|
-
.filter(session => session.workspaceId === ws.id)
|
|
261
|
-
.map(session => session.sessionId)
|
|
262
|
-
)
|
|
263
|
-
const builders = await reconcileViewBuilders(
|
|
264
|
-
ws.id,
|
|
265
|
-
ws.path,
|
|
266
|
-
await getViewList(ws.path),
|
|
267
|
-
activeSessionIds
|
|
268
|
-
)
|
|
269
|
-
// Widget builders are record-only for now — reconciled server-side but kept
|
|
270
|
-
// out of the host's view-builder tab list until their UI lands.
|
|
271
|
-
return c.json({ builders: builders.filter(builder => builder.kind !== 'widget') })
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
one.post('/view-builders', async c => {
|
|
275
|
+
one.post('/views', async c => {
|
|
275
276
|
const ws = c.get('ws')
|
|
276
|
-
return c.json(await
|
|
277
|
+
return c.json(await createPendingView(ws.id, ws.path), 201)
|
|
277
278
|
})
|
|
278
279
|
|
|
279
|
-
one.
|
|
280
|
-
const ws = c.get('ws')
|
|
281
|
-
const body = await c.req.json<{ input?: Partial<ViewBuilderInput> }>()
|
|
282
|
-
if (typeof body?.input?.requirements !== 'string') {
|
|
283
|
-
return c.text('Expected { input: { requirements: string } }', 400)
|
|
284
|
-
}
|
|
285
|
-
try {
|
|
286
|
-
return c.json(
|
|
287
|
-
await updateViewBuilderInput(
|
|
288
|
-
ws.id,
|
|
289
|
-
ws.path,
|
|
290
|
-
c.req.param('builderId'),
|
|
291
|
-
body.input.requirements
|
|
292
|
-
)
|
|
293
|
-
)
|
|
294
|
-
} catch (err) {
|
|
295
|
-
const known = viewBuilderError(err)
|
|
296
|
-
if (known) return c.text(known.message, known.status)
|
|
297
|
-
throw err
|
|
298
|
-
}
|
|
299
|
-
})
|
|
300
|
-
|
|
301
|
-
one.post('/view-builders/:builderId/submit', async c => {
|
|
280
|
+
one.post('/views/:viewId/submit', async c => {
|
|
302
281
|
const ws = c.get('ws')
|
|
303
282
|
const body = await c.req.json<{
|
|
304
|
-
|
|
283
|
+
requirements?: string
|
|
284
|
+
sessionId?: string
|
|
305
285
|
optimisticId?: string
|
|
306
286
|
selectedSessionScope?: SelectedSessionScope
|
|
307
287
|
model?: string
|
|
308
288
|
effort?: string
|
|
309
289
|
fastMode?: boolean
|
|
310
290
|
stream?: boolean
|
|
311
|
-
availableIcons?: unknown
|
|
312
291
|
attachments?: unknown
|
|
313
292
|
}>()
|
|
314
|
-
if (typeof body?.
|
|
315
|
-
return c.text('Expected {
|
|
293
|
+
if (typeof body?.requirements !== 'string') {
|
|
294
|
+
return c.text('Expected { requirements: string }', 400)
|
|
316
295
|
}
|
|
317
296
|
if (body.optimisticId !== undefined && typeof body.optimisticId !== 'string') {
|
|
318
297
|
return c.text('Invalid optimisticId', 400)
|
|
@@ -324,8 +303,6 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
324
303
|
) {
|
|
325
304
|
return c.text('Invalid selectedSessionScope', 400)
|
|
326
305
|
}
|
|
327
|
-
const availableIcons = parseAvailableViewIcons(body.availableIcons)
|
|
328
|
-
if (!availableIcons) return c.text('Available view icons are required', 400)
|
|
329
306
|
const attachments = body.attachments ?? []
|
|
330
307
|
if (!isMessageAttachments(attachments)) return c.text('Invalid attachments', 400)
|
|
331
308
|
for (const attachment of attachments) {
|
|
@@ -337,65 +314,22 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
337
314
|
const availability = await workspaceTypeAvailability(ws.type ?? 'claude-code')
|
|
338
315
|
if (availability.status !== 'available') return c.text(availability.reason, 400)
|
|
339
316
|
try {
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
...(collabReference ? { collabReference } : {}),
|
|
353
|
-
activeTab: `view-builders/${builder.id}`,
|
|
354
|
-
directives: [
|
|
355
|
-
...viewBuilderDirectives(builder.id, availableIcons),
|
|
356
|
-
...(attachments.length > 0
|
|
357
|
-
? ['Use the attachments as reference material for the intended view.']
|
|
358
|
-
: [])
|
|
359
|
-
]
|
|
360
|
-
}
|
|
361
|
-
try {
|
|
362
|
-
await selectChatSession(ws, builder.sessionId, body.selectedSessionScope)
|
|
363
|
-
await harnessFor(ws).sendMessage({
|
|
364
|
-
workspaceId: ws.id,
|
|
365
|
-
workspacePath: ws.path,
|
|
366
|
-
sessionId: builder.sessionId,
|
|
367
|
-
isNew: true,
|
|
368
|
-
content: builder.input.requirements,
|
|
369
|
-
attachments,
|
|
370
|
-
context,
|
|
371
|
-
optimisticId: body.optimisticId,
|
|
372
|
-
model: typeof body.model === 'string' ? body.model : undefined,
|
|
373
|
-
effort: typeof body.effort === 'string' ? body.effort : undefined,
|
|
374
|
-
fastMode: typeof body.fastMode === 'boolean' ? body.fastMode : undefined,
|
|
375
|
-
stream: body.stream === true ? true : undefined,
|
|
376
|
-
agentId: ws.agentId
|
|
377
|
-
})
|
|
378
|
-
} catch (err) {
|
|
379
|
-
const message = err instanceof Error ? err.message : 'Could not start view builder'
|
|
380
|
-
await markViewBuilderWaiting(ws.id, ws.path, builder.id, message)
|
|
381
|
-
return c.text(message, 500)
|
|
382
|
-
}
|
|
383
|
-
return c.json(builder)
|
|
384
|
-
} catch (err) {
|
|
385
|
-
const known = viewBuilderError(err)
|
|
386
|
-
if (known) return c.text(known.message, known.status)
|
|
387
|
-
throw err
|
|
388
|
-
}
|
|
389
|
-
})
|
|
390
|
-
|
|
391
|
-
one.delete('/view-builders/:builderId', async c => {
|
|
392
|
-
const ws = c.get('ws')
|
|
393
|
-
try {
|
|
394
|
-
await deleteViewBuilder(ws.id, ws.path, c.req.param('builderId'))
|
|
395
|
-
return c.body(null, 204)
|
|
317
|
+
const result = await submitView(ws, c.req.param('viewId'), {
|
|
318
|
+
requirements: body.requirements,
|
|
319
|
+
sessionId: typeof body.sessionId === 'string' ? body.sessionId : undefined,
|
|
320
|
+
selectedSessionScope: body.selectedSessionScope,
|
|
321
|
+
attachments,
|
|
322
|
+
optimisticId: body.optimisticId,
|
|
323
|
+
model: typeof body.model === 'string' ? body.model : undefined,
|
|
324
|
+
effort: typeof body.effort === 'string' ? body.effort : undefined,
|
|
325
|
+
fastMode: typeof body.fastMode === 'boolean' ? body.fastMode : undefined,
|
|
326
|
+
stream: body.stream === true ? true : undefined
|
|
327
|
+
})
|
|
328
|
+
return c.json(result)
|
|
396
329
|
} catch (err) {
|
|
397
|
-
|
|
398
|
-
if (
|
|
330
|
+
if (err instanceof PendingViewError) return c.text(err.message, err.status)
|
|
331
|
+
if (err instanceof ViewStartupError)
|
|
332
|
+
return c.json({ error: err.message, viewId: err.viewId, sessionId: err.sessionId }, 500)
|
|
399
333
|
throw err
|
|
400
334
|
}
|
|
401
335
|
})
|
|
@@ -425,7 +359,7 @@ one.post('/rpc/*', c => {
|
|
|
425
359
|
// `moi debug logs` reads it back (docs/self-correction.md). Unauthenticated
|
|
426
360
|
// localhost route, so treat the payload as hostile: whitelist the browser-only
|
|
427
361
|
// sources (`build`/`rpc` are server-recorded and can't be spoofed by a tab),
|
|
428
|
-
// pattern-check the applet name, cap the batch size;
|
|
362
|
+
// pattern-check the applet name, cap the batch size; applets/log.ts caps string
|
|
429
363
|
// lengths.
|
|
430
364
|
one.post('/applet-log', async c => {
|
|
431
365
|
let body: { events?: unknown }
|
|
@@ -469,7 +403,7 @@ one.post('/applet-log', async c => {
|
|
|
469
403
|
|
|
470
404
|
// Downscaled image preview of a workspace file. The chat's expanded tool rows
|
|
471
405
|
// use this to show the picture an agent `Read` — same guards as /files/ above,
|
|
472
|
-
// images only, resized server-side (see server/preview.ts).
|
|
406
|
+
// images only, resized server-side (see server/workspaces/preview.ts).
|
|
473
407
|
one.get('/preview/*', c => {
|
|
474
408
|
const ws = c.get('ws')
|
|
475
409
|
const tail = new URL(c.req.url).pathname.split(`/api/workspaces/${ws.id}/preview/`)[1] ?? ''
|
|
@@ -528,7 +462,7 @@ one.post('/uploads/from-path', async c => {
|
|
|
528
462
|
if (error instanceof Error && 'code' in error) {
|
|
529
463
|
if (error.code === 'ENOENT') return c.text('This file no longer exists', 400)
|
|
530
464
|
if (error.code === 'EACCES' || error.code === 'EPERM')
|
|
531
|
-
return c.text('This file can’t be read by
|
|
465
|
+
return c.text('This file can’t be read by Moi', 400)
|
|
532
466
|
return c.text('Something went wrong while adding this file', 400)
|
|
533
467
|
}
|
|
534
468
|
return c.text(
|
|
@@ -558,27 +492,35 @@ one.get('/uploads/:uploadId', c => {
|
|
|
558
492
|
|
|
559
493
|
one.get('/sessions', async c => {
|
|
560
494
|
const ws = c.get('ws')
|
|
561
|
-
return c.json(await harnessFor(ws).listSessions(ws))
|
|
495
|
+
return c.json(await withSessionRecords(ws.path, await harnessFor(ws).listSessions(ws)))
|
|
562
496
|
})
|
|
563
497
|
|
|
564
498
|
one.get('/selected-session', async c => {
|
|
499
|
+
return c.json(await getWorkspaceSessionSelection(c.get('ws').path))
|
|
500
|
+
})
|
|
501
|
+
|
|
502
|
+
one.put('/pinned-session', async c => {
|
|
565
503
|
const ws = c.get('ws')
|
|
566
|
-
|
|
567
|
-
if (sessionId
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
(session.lastModified === current.lastModified &&
|
|
574
|
-
session.sessionId.localeCompare(current.sessionId) < 0)
|
|
575
|
-
? session
|
|
576
|
-
: current,
|
|
577
|
-
undefined
|
|
504
|
+
const body = await c.req.json<{ sessionId: string | null }>()
|
|
505
|
+
if (body.sessionId !== null && typeof body.sessionId !== 'string')
|
|
506
|
+
return c.text('Invalid chat', 400)
|
|
507
|
+
if (body.sessionId) {
|
|
508
|
+
const harness = harnessFor(ws)
|
|
509
|
+
const found = (await harness.listSessions(ws)).some(
|
|
510
|
+
session => session.sessionId === body.sessionId
|
|
578
511
|
)
|
|
579
|
-
|
|
512
|
+
const active = harness
|
|
513
|
+
.activeSessions()
|
|
514
|
+
.some(session => session.workspaceId === ws.id && session.sessionId === body.sessionId)
|
|
515
|
+
if (!found && !active) return c.text('Chat not found', 404)
|
|
580
516
|
}
|
|
581
|
-
|
|
517
|
+
await pinSession(ws.path, body.sessionId)
|
|
518
|
+
publishEvent({
|
|
519
|
+
type: 'selected-session:updated',
|
|
520
|
+
workspaceId: ws.id,
|
|
521
|
+
sessionId: (await getSelectedSession(ws.path)) ?? null
|
|
522
|
+
})
|
|
523
|
+
return c.json({ pinnedSessionId: body.sessionId })
|
|
582
524
|
})
|
|
583
525
|
|
|
584
526
|
one.put('/selected-session', async c => {
|
|
@@ -586,7 +528,10 @@ one.put('/selected-session', async c => {
|
|
|
586
528
|
const body: unknown = await c.req.json().catch(() => null)
|
|
587
529
|
if (!body || typeof body !== 'object') return c.text('Bad request', 400)
|
|
588
530
|
|
|
589
|
-
const input = body as { sessionId?: unknown; previousSessionId?: unknown }
|
|
531
|
+
const input = body as { sessionId?: unknown; previousSessionId?: unknown; tabId?: unknown }
|
|
532
|
+
const tabId = input.tabId ?? 'overview'
|
|
533
|
+
if (!isWorkspaceTabId(tabId)) return c.text('Invalid chat tab', 400)
|
|
534
|
+
if (await getPinnedSession(ws.path)) return c.text('Unpin chat before switching', 409)
|
|
590
535
|
const validSessionId = input.sessionId === null || typeof input.sessionId === 'string'
|
|
591
536
|
const hasPreviousSessionId = Object.prototype.hasOwnProperty.call(input, 'previousSessionId')
|
|
592
537
|
const validPreviousSessionId =
|
|
@@ -598,7 +543,8 @@ one.put('/selected-session', async c => {
|
|
|
598
543
|
const update = await saveSelectedSession(
|
|
599
544
|
ws.path,
|
|
600
545
|
input.sessionId as string | null,
|
|
601
|
-
hasPreviousSessionId ? (input.previousSessionId as string | null) : undefined
|
|
546
|
+
hasPreviousSessionId ? (input.previousSessionId as string | null) : undefined,
|
|
547
|
+
tabId
|
|
602
548
|
)
|
|
603
549
|
publishSelectedSession(ws.id, update)
|
|
604
550
|
return c.json({ sessionId: update.sessionId })
|
|
@@ -611,10 +557,7 @@ one.post('/sessions/:sessionId/archive', async c => {
|
|
|
611
557
|
if (!harness.archiveSession) return c.text('Chat archiving is not supported', 501)
|
|
612
558
|
|
|
613
559
|
try {
|
|
614
|
-
await
|
|
615
|
-
await harness.archiveSession(ws, sessionId)
|
|
616
|
-
publishSelectedSession(ws.id, await clearSelectedSession(ws.path, sessionId))
|
|
617
|
-
broadcast(ws.id, { type: 'sessions_changed', sessionId })
|
|
560
|
+
await archiveWorkspaceSession(ws, sessionId)
|
|
618
561
|
return c.body(null, 204)
|
|
619
562
|
} catch (error) {
|
|
620
563
|
console.error(`[api] archive chat failed for ${harness.id}`, error)
|
|
@@ -628,17 +571,15 @@ one.post('/sessions/:sessionId/archive', async c => {
|
|
|
628
571
|
|
|
629
572
|
one.get('/sessions/:sessionId/events', async c => {
|
|
630
573
|
const ws = c.get('ws')
|
|
631
|
-
|
|
574
|
+
const sessionId = c.req.param('sessionId')
|
|
575
|
+
return c.json(await harnessFor(ws).sessionEvents(ws, sessionId))
|
|
632
576
|
})
|
|
633
577
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
// defaults); PUT patches it (a field as `null` clears it, omitted leaves it).
|
|
637
|
-
// The change takes effect on the session's next message.
|
|
638
|
-
one.get('/sessions/:sessionId/config', async c => {
|
|
639
|
-
return c.json(await getSessionConfig(c.get('ws').path, c.req.param('sessionId')))
|
|
578
|
+
one.get('/sessions/:sessionId', async c => {
|
|
579
|
+
return c.json(await getSessionRecord(c.get('ws').path, c.req.param('sessionId')))
|
|
640
580
|
})
|
|
641
581
|
|
|
582
|
+
// Patch run settings and return the complete session record. null clears a setting.
|
|
642
583
|
one.put('/sessions/:sessionId/config', async c => {
|
|
643
584
|
const body = await c.req.json().catch(() => null)
|
|
644
585
|
if (typeof body !== 'object' || body === null) {
|
|
@@ -661,7 +602,10 @@ one.put('/sessions/:sessionId/config', async c => {
|
|
|
661
602
|
}
|
|
662
603
|
patch.fastMode = value
|
|
663
604
|
}
|
|
664
|
-
|
|
605
|
+
const workspacePath = c.get('ws').path
|
|
606
|
+
const sessionId = c.req.param('sessionId')
|
|
607
|
+
await saveSessionConfig(workspacePath, sessionId, patch)
|
|
608
|
+
return c.json(await getSessionRecord(workspacePath, sessionId))
|
|
665
609
|
})
|
|
666
610
|
|
|
667
611
|
one.get('/mcp', async c => {
|
|
@@ -701,35 +645,8 @@ one.get('/env', async c => {
|
|
|
701
645
|
// the only way).
|
|
702
646
|
one.put('/env', async c => {
|
|
703
647
|
const ws = c.get('ws')
|
|
704
|
-
const
|
|
705
|
-
if (
|
|
706
|
-
return c.text('Bad request', 400)
|
|
707
|
-
}
|
|
708
|
-
const patch: EnvUpdate = {}
|
|
709
|
-
if (body.set !== undefined) {
|
|
710
|
-
if (typeof body.set !== 'object' || body.set === null) {
|
|
711
|
-
return c.text('set must be an object', 400)
|
|
712
|
-
}
|
|
713
|
-
for (const [k, v] of Object.entries(body.set)) {
|
|
714
|
-
if (!isValidEnvKey(k)) return c.text(`Invalid env key: ${k}`, 400)
|
|
715
|
-
if (typeof v !== 'string') {
|
|
716
|
-
return c.text(`Value for ${k} must be a string`, 400)
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
patch.set = body.set as Record<string, string>
|
|
720
|
-
}
|
|
721
|
-
if (body.remove !== undefined) {
|
|
722
|
-
if (!Array.isArray(body.remove) || body.remove.some((k: unknown) => typeof k !== 'string')) {
|
|
723
|
-
return c.text('remove must be an array of strings', 400)
|
|
724
|
-
}
|
|
725
|
-
patch.remove = body.remove as string[]
|
|
726
|
-
}
|
|
727
|
-
if (body.inheritDotenv !== undefined) {
|
|
728
|
-
if (typeof body.inheritDotenv !== 'boolean') {
|
|
729
|
-
return c.text('inheritDotenv must be a boolean', 400)
|
|
730
|
-
}
|
|
731
|
-
patch.inheritDotenv = body.inheritDotenv
|
|
732
|
-
}
|
|
648
|
+
const patch = parseEnvUpdate(await c.req.json().catch(() => null))
|
|
649
|
+
if (typeof patch === 'string') return c.text(patch, 400)
|
|
733
650
|
|
|
734
651
|
// Skip the write + reaps for a no-op PUT (no recognized fields) so an empty
|
|
735
652
|
// body doesn't needlessly kill warm workers / idle sessions.
|
|
@@ -744,20 +661,6 @@ one.put('/env', async c => {
|
|
|
744
661
|
return c.json(await getWorkspaceEnvView(ws.path, requiredEnvFor(ws.path)))
|
|
745
662
|
})
|
|
746
663
|
|
|
747
|
-
// Start a provider login ceremony. Codex returns a browser OAuth URL for the
|
|
748
|
-
// host to open; Claude launches its browser flow through the CLI itself.
|
|
749
|
-
// Browser-based logins reuse a pending URL; URL-less provider flows restart
|
|
750
|
-
// when requested again. Completion is pushed as `agent:updated`.
|
|
751
|
-
one.post('/auth/login', async c => {
|
|
752
|
-
const ws = c.get('ws')
|
|
753
|
-
if (!harnessFor(ws).startLogin) return c.text('This agent requires terminal sign-in', 409)
|
|
754
|
-
try {
|
|
755
|
-
return c.json(await agentStore.startLogin(ws))
|
|
756
|
-
} catch (err) {
|
|
757
|
-
return c.text(err instanceof Error ? err.message : 'Could not start sign-in', 500)
|
|
758
|
-
}
|
|
759
|
-
})
|
|
760
|
-
|
|
761
664
|
one.get('/skills', async c => {
|
|
762
665
|
const ws = c.get('ws')
|
|
763
666
|
return c.json(await getWorkspaceSkillsStatus(ws.path, ws.type))
|
|
@@ -770,31 +673,40 @@ one.post('/skills/update', async c => {
|
|
|
770
673
|
})
|
|
771
674
|
|
|
772
675
|
// The workspace's agent backend in one snapshot: provider, availability
|
|
773
|
-
// (runtime presence + auth,
|
|
774
|
-
//
|
|
775
|
-
// open; the volatile parts stay fresh afterwards via `agent:updated` events,
|
|
776
|
-
// not refetches.
|
|
676
|
+
// (runtime presence + auth), the model catalog, and capabilities.
|
|
677
|
+
// Workspace readiness stays fresh via `harness:updated` events and refetches.
|
|
777
678
|
one.get('/agent', async c => {
|
|
778
679
|
const ws = c.get('ws')
|
|
779
680
|
const harness = harnessFor(ws)
|
|
681
|
+
const capabilities = {
|
|
682
|
+
provider: harness.id,
|
|
683
|
+
supportsStreaming: harness.capabilities.supportsStreaming,
|
|
684
|
+
supportsArchiving: Boolean(harness.archiveSession)
|
|
685
|
+
}
|
|
686
|
+
if (!existsSync(ws.path)) {
|
|
687
|
+
return c.json({
|
|
688
|
+
...capabilities,
|
|
689
|
+
workspaceFolderMissing: true,
|
|
690
|
+
availability: { status: 'unavailable', reason: 'Workspace folder not found' },
|
|
691
|
+
models: []
|
|
692
|
+
} satisfies WorkspaceAgent)
|
|
693
|
+
}
|
|
694
|
+
const refresh = c.req.query('refresh') === 'true'
|
|
695
|
+
if (refresh) await loginShellPath({ refresh: true })
|
|
780
696
|
// A backend that can't answer (codex CLI missing, gateway down) degrades to
|
|
781
697
|
// an empty catalog — the picker hides and chat surfaces the real problem via
|
|
782
|
-
//
|
|
698
|
+
// workspace setup, instead of this endpoint failing on page load.
|
|
783
699
|
const [availability, models] = await Promise.all([
|
|
784
|
-
|
|
700
|
+
refresh ? harnessStore.refresh(ws) : harnessStore.getAvailability(ws),
|
|
785
701
|
harness.listModels(ws).catch(err => {
|
|
786
702
|
console.error(`[api] listModels failed for ${harness.id}`, err)
|
|
787
703
|
return []
|
|
788
704
|
})
|
|
789
705
|
])
|
|
790
|
-
const login = agentStore.getLogin(ws.id)
|
|
791
706
|
return c.json({
|
|
792
|
-
|
|
707
|
+
...capabilities,
|
|
793
708
|
availability,
|
|
794
|
-
|
|
795
|
-
models,
|
|
796
|
-
supportsStreaming: harness.capabilities.supportsStreaming,
|
|
797
|
-
supportsArchiving: Boolean(harness.archiveSession)
|
|
709
|
+
models
|
|
798
710
|
} satisfies WorkspaceAgent)
|
|
799
711
|
})
|
|
800
712
|
|
|
@@ -831,7 +743,7 @@ one.put('/config', async c => {
|
|
|
831
743
|
// snapshot ({ document, origin }) and broadcasts so other open tabs reload.
|
|
832
744
|
// `origin` is the writing tab's id — echoed in the broadcast so that tab can
|
|
833
745
|
// ignore its own save. This is the browser's write path; the agent's draws are
|
|
834
|
-
// written server-side (see scratchpad
|
|
746
|
+
// written server-side (see server/scratchpad/executor.ts). See docs/moi-scratchpad.md.
|
|
835
747
|
one.get('/scratchpad', async c => {
|
|
836
748
|
return c.json(await loadScratchpadDoc(c.get('ws').path))
|
|
837
749
|
})
|
|
@@ -853,7 +765,7 @@ one.put('/scratchpad', async c => {
|
|
|
853
765
|
|
|
854
766
|
// Scratchpad assets: pasted/dropped image bytes live as content-addressed files
|
|
855
767
|
// in `.moi/.scratchpad/`, referenced from the snapshot by `asset:` srcs —
|
|
856
|
-
// never inlined as base64 in the JSON (see server/scratchpad
|
|
768
|
+
// never inlined as base64 in the JSON (see server/scratchpad/assets.ts). The
|
|
857
769
|
// browser's TLAssetStore POSTs the raw file here on paste and resolves `asset:`
|
|
858
770
|
// srcs back through the GET when rendering.
|
|
859
771
|
one.post('/scratchpad/assets', async c => {
|
|
@@ -1045,10 +957,10 @@ workspaces.put('/order', async c => {
|
|
|
1045
957
|
// provisioned with its workspaces; the UI never sends these requests (it opens
|
|
1046
958
|
// the cloud demo promo dialog instead), so a 403 here means the API was called
|
|
1047
959
|
// directly.
|
|
1048
|
-
const DEMO_CREATE_BLOCKED = 'Workspace creation is not available in the
|
|
960
|
+
const DEMO_CREATE_BLOCKED = 'Workspace creation is not available in the Moi demo'
|
|
1049
961
|
|
|
1050
962
|
workspaces.post('/', async c => {
|
|
1051
|
-
if (getAppConfig().
|
|
963
|
+
if (getAppConfig().demo) return c.text(DEMO_CREATE_BLOCKED, 403)
|
|
1052
964
|
const body = await c.req.json()
|
|
1053
965
|
if (!body?.path) return c.text('Missing path', 400)
|
|
1054
966
|
const requestedType: unknown = body?.type ?? 'claude-code'
|
|
@@ -1090,31 +1002,16 @@ async function workspaceTypeAvailability(type: WorkspaceType): Promise<HarnessAv
|
|
|
1090
1002
|
return (await harnessFor(type).availability?.()) ?? { status: 'available' }
|
|
1091
1003
|
}
|
|
1092
1004
|
|
|
1093
|
-
//
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
out[h.id] = await workspaceTypeAvailability(h.id)
|
|
1099
|
-
}
|
|
1100
|
-
return out
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
// Where `/workspace/create` places new folders — the client shows the resolved
|
|
1104
|
-
// location while the user types a name. `availability` lets the dialog disable
|
|
1105
|
-
// backends whose runtime is missing.
|
|
1106
|
-
workspaces.get('/create', async c =>
|
|
1107
|
-
c.json({
|
|
1108
|
-
root: CREATED_WORKSPACES_ROOT,
|
|
1109
|
-
displayRoot: tildify(CREATED_WORKSPACES_ROOT),
|
|
1110
|
-
availability: await harnessAvailability()
|
|
1111
|
-
})
|
|
1112
|
-
)
|
|
1005
|
+
// Both workspace dialogs only need installation facts to offer agent choices.
|
|
1006
|
+
workspaces.get('/create', async c => {
|
|
1007
|
+
c.header('Cache-Control', 'no-store')
|
|
1008
|
+
return c.json({ installed: await detectInstalledHarnesses() })
|
|
1009
|
+
})
|
|
1113
1010
|
|
|
1114
|
-
// Create a brand-new workspace: a fresh folder under
|
|
1011
|
+
// Create a brand-new workspace: a fresh folder under createdWorkspacesRoot(),
|
|
1115
1012
|
// provisioned (skills + `.moi/` scaffold) and registered.
|
|
1116
1013
|
workspaces.post('/create', async c => {
|
|
1117
|
-
if (getAppConfig().
|
|
1014
|
+
if (getAppConfig().demo) return c.text(DEMO_CREATE_BLOCKED, 403)
|
|
1118
1015
|
const body = await c.req.json()
|
|
1119
1016
|
const requestedType: unknown = body?.type ?? 'claude-code'
|
|
1120
1017
|
if (!isHarnessType(requestedType)) {
|
|
@@ -1129,7 +1026,7 @@ workspaces.post('/create', async c => {
|
|
|
1129
1026
|
const name = typeof body?.name === 'string' ? body.name.trim() : ''
|
|
1130
1027
|
const invalid = validateWorkspaceFolderName(name)
|
|
1131
1028
|
if (invalid) return c.text(invalid, 400)
|
|
1132
|
-
const path = join(
|
|
1029
|
+
const path = join(createdWorkspacesRoot(), name)
|
|
1133
1030
|
if (existsSync(path)) return c.text('A folder with that name already exists', 409)
|
|
1134
1031
|
try {
|
|
1135
1032
|
await provisionWorkspace(path, type)
|
|
@@ -1152,6 +1049,7 @@ workspaces.route('/:id', one)
|
|
|
1152
1049
|
export const api = new Hono()
|
|
1153
1050
|
|
|
1154
1051
|
api.route('/api/workspaces', workspaces)
|
|
1052
|
+
api.route('/api/harnesses', harnesses)
|
|
1155
1053
|
|
|
1156
1054
|
// Startup config (config.json in the data dir + MOI_* env), client-safe
|
|
1157
1055
|
// subset. Immutable for the process lifetime — clients cache it forever.
|
|
@@ -1177,7 +1075,7 @@ api.post('/api/update', async c => {
|
|
|
1177
1075
|
if (updateInProgress()) {
|
|
1178
1076
|
return c.text(
|
|
1179
1077
|
restartPendingForUpdate()
|
|
1180
|
-
? 'An update is installed —
|
|
1078
|
+
? 'An update is installed — Moi is restarting.'
|
|
1181
1079
|
: 'An update is already in progress.',
|
|
1182
1080
|
409
|
|
1183
1081
|
)
|
|
@@ -1192,7 +1090,7 @@ api.post('/api/update', async c => {
|
|
|
1192
1090
|
|
|
1193
1091
|
try {
|
|
1194
1092
|
const result = await installUpdate()
|
|
1195
|
-
if (!result) return c.text('This
|
|
1093
|
+
if (!result) return c.text('This Moi install cannot be updated from the app.', 409)
|
|
1196
1094
|
const response = c.json(result)
|
|
1197
1095
|
scheduleRestartForUpdate()
|
|
1198
1096
|
return response
|