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,6 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { stripVTControlCharacters } from 'node:util'
|
|
2
|
+
import { getAppConfig } from '../../app-config'
|
|
3
|
+
import type { HarnessLoginAttempt } from '../types'
|
|
4
|
+
import { homedir, tmpdir } from 'node:os'
|
|
5
|
+
import { mkdtemp, chmod, rm } from 'node:fs/promises'
|
|
6
|
+
import { join } from 'node:path'
|
|
7
|
+
import { openBrowser } from '../../open-browser'
|
|
8
|
+
import type { HarnessAvailability } from '@/lib/types'
|
|
2
9
|
|
|
3
|
-
import {
|
|
10
|
+
import { agentCommand } from '../../agent-launcher'
|
|
11
|
+
import { resolveWorkspaceEnv } from '../../workspaces/env'
|
|
4
12
|
import { findHarnessExecutable } from '../executable'
|
|
5
13
|
|
|
6
14
|
function signedOut(reason: string): HarnessAvailability {
|
|
@@ -28,13 +36,14 @@ export function claudeAuthReadiness(result: ClaudeAuthProbeResult): HarnessAvail
|
|
|
28
36
|
// Claude Code documents exit 0 as logged in and exit 1 as logged out. Run the
|
|
29
37
|
// probe with the same workspace env as the actual Agent SDK subprocess so
|
|
30
38
|
// API-key and enterprise provider configuration match the eventual send.
|
|
31
|
-
export async function getClaudeAuthReadiness(workspacePath
|
|
39
|
+
export async function getClaudeAuthReadiness(workspacePath?: string): Promise<HarnessAvailability> {
|
|
32
40
|
const executable = findHarnessExecutable('claude-code')
|
|
33
|
-
if (!executable)
|
|
41
|
+
if (!executable)
|
|
42
|
+
return { status: 'unavailable', code: 'not-installed', reason: 'Claude is not installed' }
|
|
34
43
|
|
|
35
|
-
const workspaceEnv = await resolveWorkspaceEnv(workspacePath)
|
|
36
|
-
const proc = Bun.spawn([executable, 'auth', 'status'], {
|
|
37
|
-
cwd: workspacePath,
|
|
44
|
+
const workspaceEnv = workspacePath ? await resolveWorkspaceEnv(workspacePath) : {}
|
|
45
|
+
const proc = Bun.spawn(agentCommand([executable, 'auth', 'status']), {
|
|
46
|
+
cwd: workspacePath ?? homedir(),
|
|
38
47
|
env: { ...process.env, ...workspaceEnv },
|
|
39
48
|
stdin: 'ignore',
|
|
40
49
|
stdout: 'ignore',
|
|
@@ -53,17 +62,117 @@ export async function getClaudeAuthReadiness(workspacePath: string): Promise<Har
|
|
|
53
62
|
}
|
|
54
63
|
}
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
// Read an OAuth URL from CLI output or the captured browser invocation.
|
|
66
|
+
export function claudeLoginUrl(output: string): string | undefined {
|
|
67
|
+
const text = stripVTControlCharacters(output)
|
|
68
|
+
return text.match(/https:\/\/[^\s]+(?=\s)/g)?.find(value => {
|
|
69
|
+
try {
|
|
70
|
+
const url = new URL(value)
|
|
71
|
+
return url.searchParams.get('response_type') === 'code' && url.searchParams.has('state')
|
|
72
|
+
} catch {
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function startClaudeLogin(): Promise<HarnessLoginAttempt> {
|
|
57
79
|
const executable = findHarnessExecutable('claude-code')
|
|
58
80
|
if (!executable) throw new Error('Claude is not installed')
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
81
|
+
const local = getAppConfig().environment === 'local'
|
|
82
|
+
const captureDir = local ? await mkdtemp(join(tmpdir(), 'moi-claude-login-')) : undefined
|
|
83
|
+
let processExit: Promise<number> | undefined
|
|
84
|
+
try {
|
|
85
|
+
const capturePath = captureDir ? join(captureDir, 'url') : undefined
|
|
86
|
+
const windows = process.platform === 'win32'
|
|
87
|
+
const browser = captureDir ? join(captureDir, windows ? 'browser.cmd' : 'browser') : 'true'
|
|
88
|
+
if (captureDir) {
|
|
89
|
+
// Capture the exact callback URL the CLI opens; its printed URL is code-only.
|
|
90
|
+
await Bun.write(
|
|
91
|
+
browser,
|
|
92
|
+
windows
|
|
93
|
+
? [
|
|
94
|
+
'@echo off',
|
|
95
|
+
'setlocal DisableDelayedExpansion',
|
|
96
|
+
'set "MOI_LOGIN_URL=%~1"',
|
|
97
|
+
'powershell.exe -NoProfile -NonInteractive -Command "[IO.File]::WriteAllText($env:MOI_LOGIN_URL_FILE, $env:MOI_LOGIN_URL + [Environment]::NewLine)"',
|
|
98
|
+
''
|
|
99
|
+
].join('\r\n')
|
|
100
|
+
: `#!/bin/sh\nprintf '%s\\n' "$1" > "$MOI_LOGIN_URL_FILE"\n`
|
|
101
|
+
)
|
|
102
|
+
if (!windows) await chmod(browser, 0o700)
|
|
103
|
+
}
|
|
104
|
+
const proc = Bun.spawn(agentCommand([executable, 'auth', 'login']), {
|
|
105
|
+
cwd: homedir(),
|
|
106
|
+
env: { ...process.env, BROWSER: browser, MOI_LOGIN_URL_FILE: capturePath },
|
|
107
|
+
stdin: 'pipe',
|
|
108
|
+
stdout: 'pipe',
|
|
109
|
+
stderr: 'ignore'
|
|
110
|
+
})
|
|
111
|
+
processExit = proc.exited
|
|
112
|
+
const completed = processExit.then(async code => {
|
|
113
|
+
// Windows can still be executing the batch helper after it writes the URL.
|
|
114
|
+
if (captureDir) await rm(captureDir, { recursive: true, force: true })
|
|
115
|
+
if (code !== 0) throw new Error('Claude sign-in failed or expired. Try again')
|
|
116
|
+
})
|
|
117
|
+
// The process can fail before its URL is available.
|
|
118
|
+
void completed.catch(() => {})
|
|
119
|
+
const timeout = setTimeout(() => proc.kill(), 30_000)
|
|
120
|
+
try {
|
|
121
|
+
let output = ''
|
|
122
|
+
const decoder = new TextDecoder()
|
|
123
|
+
const reader = proc.stdout.getReader()
|
|
124
|
+
let url: string | undefined
|
|
125
|
+
while (!url) {
|
|
126
|
+
const chunk = await reader.read()
|
|
127
|
+
if (chunk.done)
|
|
128
|
+
throw new Error('Claude did not return a sign-in link. Update Claude and try again')
|
|
129
|
+
output += decoder.decode(chunk.value, { stream: true })
|
|
130
|
+
if (output.length > 65_536) throw new Error('Could not read the Claude sign-in link')
|
|
131
|
+
url = claudeLoginUrl(output)
|
|
132
|
+
}
|
|
133
|
+
reader.releaseLock()
|
|
134
|
+
// Drain subsequent CLI output without storing authorization codes or tokens.
|
|
135
|
+
void proc.stdout.pipeTo(new WritableStream({ write() {} })).catch(() => {})
|
|
136
|
+
const codeUrl = url
|
|
137
|
+
if (capturePath) {
|
|
138
|
+
let callbackUrl: string | undefined
|
|
139
|
+
while (!callbackUrl) {
|
|
140
|
+
if (proc.exitCode !== null)
|
|
141
|
+
throw new Error('Claude did not open a local sign-in link. Try again')
|
|
142
|
+
// Bun.file caches a missing file; the browser helper may write it later.
|
|
143
|
+
const file = Bun.file(capturePath)
|
|
144
|
+
if (await file.exists()) callbackUrl = claudeLoginUrl(await file.text())
|
|
145
|
+
if (!callbackUrl) await Bun.sleep(50)
|
|
146
|
+
}
|
|
147
|
+
url = callbackUrl
|
|
148
|
+
void openBrowser(url)
|
|
149
|
+
}
|
|
150
|
+
const state = new URL(codeUrl).searchParams.get('state')
|
|
151
|
+
return {
|
|
152
|
+
id: crypto.randomUUID(),
|
|
153
|
+
url,
|
|
154
|
+
codeUrl,
|
|
155
|
+
completed,
|
|
156
|
+
cancel: () => {
|
|
157
|
+
proc.kill()
|
|
158
|
+
},
|
|
159
|
+
submitCode: async code => {
|
|
160
|
+
const parts = code.trim().split('#')
|
|
161
|
+
if (parts.length !== 2 || !parts[0] || parts[1] !== state || /\s/.test(code.trim())) {
|
|
162
|
+
throw new Error('Copy the full code from this sign-in attempt and try again')
|
|
163
|
+
}
|
|
164
|
+
if (proc.exitCode !== null) throw new Error('Sign-in expired. Start again')
|
|
165
|
+
proc.stdin.write(code.trim() + '\n')
|
|
166
|
+
await proc.stdin.flush()
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
} catch (error) {
|
|
170
|
+
proc.kill()
|
|
171
|
+
throw error
|
|
172
|
+
} finally {
|
|
173
|
+
clearTimeout(timeout)
|
|
174
|
+
}
|
|
175
|
+
} finally {
|
|
176
|
+
if (captureDir && !processExit) await rm(captureDir, { recursive: true, force: true })
|
|
177
|
+
}
|
|
69
178
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { agentCommand } from '../../agent-launcher'
|
|
2
|
+
|
|
1
3
|
// Include the version in CLI identity: auto-updates can replace the binary
|
|
2
4
|
// without changing its path.
|
|
3
5
|
|
|
@@ -24,7 +26,7 @@ export function claudeCliKey(cli: ClaudeCli): string {
|
|
|
24
26
|
export async function probeClaudeCli(executable: string): Promise<ClaudeCli> {
|
|
25
27
|
let timeout: ReturnType<typeof setTimeout> | undefined
|
|
26
28
|
try {
|
|
27
|
-
const proc = Bun.spawn([executable, '--version'], {
|
|
29
|
+
const proc = Bun.spawn(agentCommand([executable, '--version']), {
|
|
28
30
|
stdin: 'ignore',
|
|
29
31
|
stdout: 'pipe',
|
|
30
32
|
stderr: 'ignore'
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
// Claude Code accumulates session history in every directory an agent ever ran
|
|
4
4
|
// in, including the throwaway checkouts created for worktree-isolated runs.
|
|
5
5
|
// Those derived directories shouldn't surface as importable workspaces in the
|
|
6
|
-
// discovery list, so we filter them out.
|
|
7
|
-
// worktree
|
|
6
|
+
// discovery list, so we filter them out. This is a filter on discovery only:
|
|
7
|
+
// moi doesn't support running inside a linked worktree as a workspace, and a
|
|
8
|
+
// worktree that was already imported stays registered until removed by hand.
|
|
9
|
+
// Detection fails open — a read error means "not a worktree" — so a transient
|
|
10
|
+
// filesystem hiccup can let a worktree through but never hides a real repo.
|
|
8
11
|
import { readFile } from 'node:fs/promises'
|
|
9
12
|
import { join } from 'node:path'
|
|
10
13
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Claude Code as a Harness. Thin wiring over this folder's modules — see
|
|
2
2
|
// ../types.ts for the contract and ../README.md for the architecture.
|
|
3
3
|
import { join } from 'node:path'
|
|
4
|
+
import { forkSession } from '@anthropic-ai/claude-agent-sdk'
|
|
4
5
|
|
|
5
6
|
import type { McpServer } from '@/lib/types'
|
|
6
7
|
|
|
@@ -92,6 +93,10 @@ export const claudeCodeHarness: Harness = {
|
|
|
92
93
|
sendMessage: input => sendCCMessage(input),
|
|
93
94
|
interrupt: (workspaceId, sessionId) => interruptCCSession(workspaceId, sessionId),
|
|
94
95
|
archiveSession: (ws, sessionId) => archiveClaudeSession(sessionId, ws.path),
|
|
96
|
+
forkSession: async (ws, sourceId) => {
|
|
97
|
+
const { sessionId } = await forkSession(sourceId, { dir: ws.path })
|
|
98
|
+
return sessionId
|
|
99
|
+
},
|
|
95
100
|
activeSessions: () => getCCActiveSessions(),
|
|
96
101
|
|
|
97
102
|
listSessions: ws => getSessions(ws.path),
|
|
@@ -107,7 +112,8 @@ export const claudeCodeHarness: Harness = {
|
|
|
107
112
|
const runtime = await pathHarnessAvailability('claude-code')
|
|
108
113
|
return runtime.status === 'available' && ws ? getClaudeAuthReadiness(ws.path) : runtime
|
|
109
114
|
},
|
|
110
|
-
startLogin:
|
|
115
|
+
startLogin: startClaudeLogin,
|
|
116
|
+
authStatus: getClaudeAuthReadiness,
|
|
111
117
|
|
|
112
118
|
onEnvChanged: workspacePath => restartWorkspaceSessions(workspacePath),
|
|
113
119
|
stopWorkspace: workspacePath => killWorkspaceSessions(workspacePath),
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { query } from '@anthropic-ai/claude-agent-sdk'
|
|
2
2
|
import type { McpServerStatus, SDKUserMessage } from '@anthropic-ai/claude-agent-sdk'
|
|
3
3
|
|
|
4
|
+
import { claudeCodeSpawn } from '../../agent-launcher'
|
|
4
5
|
import { debugEnabled } from '../../debug'
|
|
5
6
|
import { requireHarnessExecutable } from '../executable'
|
|
6
7
|
|
|
7
8
|
// MCP server status probing. Intentionally decoupled from agent chat runs
|
|
8
|
-
// (
|
|
9
|
+
// (session.ts): connecting to MCP servers and reading their status is a
|
|
9
10
|
// metadata concern, not part of any conversation. Nothing here submits a user
|
|
10
11
|
// turn, so probing costs zero model tokens.
|
|
11
12
|
//
|
|
@@ -62,6 +63,7 @@ async function probeMcpStatus(workspacePath: string): Promise<McpServerStatus[]>
|
|
|
62
63
|
options: {
|
|
63
64
|
cwd: workspacePath,
|
|
64
65
|
pathToClaudeCodeExecutable: requireHarnessExecutable('claude-code'),
|
|
66
|
+
spawnClaudeCodeProcess: claudeCodeSpawn(),
|
|
65
67
|
persistSession: false,
|
|
66
68
|
settingSources: ['user', 'project'],
|
|
67
69
|
env: { ...process.env, CLAUDECODE: undefined }
|
|
@@ -3,6 +3,7 @@ import type { ModelInfo } from '@anthropic-ai/claude-agent-sdk'
|
|
|
3
3
|
|
|
4
4
|
import type { Model } from '@/lib/types'
|
|
5
5
|
|
|
6
|
+
import { claudeCodeSpawn } from '../../agent-launcher'
|
|
6
7
|
import { requireHarnessExecutable } from '../executable'
|
|
7
8
|
import { type ClaudeCli, claudeCliKey, probeClaudeCli } from './cli'
|
|
8
9
|
|
|
@@ -13,6 +14,7 @@ async function fetchClaudeModels(cwd: string, executable: string): Promise<Model
|
|
|
13
14
|
options: {
|
|
14
15
|
cwd,
|
|
15
16
|
pathToClaudeCodeExecutable: executable,
|
|
17
|
+
spawnClaudeCodeProcess: claudeCodeSpawn(),
|
|
16
18
|
persistSession: false,
|
|
17
19
|
settingSources: ['user', 'project'],
|
|
18
20
|
env: { ...process.env, CLAUDECODE: undefined }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// One long-lived SDK query per session, with follow-ups queued in
|
|
1
|
+
// One long-lived SDK query per session, with follow-ups queued in Moi.
|
|
2
2
|
//
|
|
3
3
|
// Dispatch waits for the preceding user turn to finish before applying the next
|
|
4
4
|
// message's settings. Pending messages survive subprocess replacement; running
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
//
|
|
7
7
|
// The SDK persists history to disk. After eviction or a server restart, the
|
|
8
8
|
// next message resumes that history in a new process.
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
prepareAttachmentMessage,
|
|
11
|
+
type PreparedAttachmentMessage
|
|
12
|
+
} from '../../sessions/attachment-message'
|
|
10
13
|
import { attachmentLabel } from '@/lib/moi-attachments'
|
|
11
14
|
import {
|
|
12
15
|
type Options,
|
|
@@ -27,14 +30,10 @@ import { moiContextSystemReminder, renderMoiContext } from '@/lib/moi-context'
|
|
|
27
30
|
import { debug } from '../../debug'
|
|
28
31
|
import { tapWire } from '../debug'
|
|
29
32
|
import { broadcast } from '../../state'
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
markViewBuilderWaitingBySession,
|
|
35
|
-
renameViewBuilderSession
|
|
36
|
-
} from '../../view-builders'
|
|
37
|
-
import { resolveWorkspaceEnv } from '../../workspace-env'
|
|
33
|
+
import { hasSessionConfig, saveSessionConfig } from '../../sessions/config'
|
|
34
|
+
import { renameSessionReferences } from '../../sessions/lifecycle'
|
|
35
|
+
import { claudeCodeSpawn } from '../../agent-launcher'
|
|
36
|
+
import { resolveWorkspaceEnv } from '../../workspaces/env'
|
|
38
37
|
import { requireHarnessExecutable } from '../executable'
|
|
39
38
|
import type { SendMessageInput } from '../types'
|
|
40
39
|
|
|
@@ -139,8 +138,6 @@ type LiveSession = {
|
|
|
139
138
|
staleCli: boolean
|
|
140
139
|
idleTimer: ReturnType<typeof setTimeout> | null
|
|
141
140
|
closed: boolean
|
|
142
|
-
// Passed to the view builder when the session becomes idle.
|
|
143
|
-
lastBuilderError: string | undefined
|
|
144
141
|
// Introspection only (surfaced by /status) — not load-bearing.
|
|
145
142
|
createdAt: number
|
|
146
143
|
lastActivityAt: number
|
|
@@ -401,16 +398,10 @@ function renameSession(s: LiveSession, realId: string): string {
|
|
|
401
398
|
}
|
|
402
399
|
|
|
403
400
|
// Keep the active message reserved across async bookkeeping. Sends arriving
|
|
404
|
-
// here join
|
|
401
|
+
// here join Moi's queue; they cannot race a teardown or change the live model.
|
|
405
402
|
async function onSessionIdle(s: LiveSession) {
|
|
406
403
|
const active = s.messages.active
|
|
407
404
|
if (s.messages.dispatching || (active && !s.turnEnded)) return
|
|
408
|
-
await markViewBuilderWaitingBySession(
|
|
409
|
-
s.workspaceId,
|
|
410
|
-
s.workspacePath,
|
|
411
|
-
s.sessionId,
|
|
412
|
-
s.lastBuilderError
|
|
413
|
-
)
|
|
414
405
|
if (s.closed || s.messages.dispatching || s.messages.active !== active) return
|
|
415
406
|
active?.complete()
|
|
416
407
|
s.messages.active = null
|
|
@@ -429,15 +420,7 @@ async function consume(s: LiveSession) {
|
|
|
429
420
|
const realId = msg.session_id
|
|
430
421
|
if (realId && realId !== s.sessionId) {
|
|
431
422
|
const from = renameSession(s, realId)
|
|
432
|
-
|
|
433
|
-
await renameSessionConfig(s.workspacePath, from, s.sessionId)
|
|
434
|
-
await renameSelectedSession(s.workspacePath, from, s.sessionId)
|
|
435
|
-
await renameViewBuilderSession(s.workspaceId, s.workspacePath, from, s.sessionId)
|
|
436
|
-
broadcast(s.workspaceId, {
|
|
437
|
-
type: 'session_renamed',
|
|
438
|
-
from,
|
|
439
|
-
to: s.sessionId
|
|
440
|
-
})
|
|
423
|
+
await renameSessionReferences(s.workspaceId, s.workspacePath, from, s.sessionId)
|
|
441
424
|
}
|
|
442
425
|
startClaudeSessionTitleJob(s)
|
|
443
426
|
// Seed explicit startup settings only when no saved picker choice exists.
|
|
@@ -531,12 +514,6 @@ async function consume(s: LiveSession) {
|
|
|
531
514
|
!active || (!msg.queued_turn_count && (!consumed || consumed.includes(active.wireId)))
|
|
532
515
|
if (turnFinished) s.turnEnded = true
|
|
533
516
|
s.lastActivityAt = Date.now()
|
|
534
|
-
// Remembered for the idle transition — the view builder shows the last
|
|
535
|
-
// turn's error once the queue drains.
|
|
536
|
-
s.lastBuilderError =
|
|
537
|
-
msg.subtype === 'success'
|
|
538
|
-
? undefined
|
|
539
|
-
: msg.errors.join('\n') || msg.subtype.replaceAll('_', ' ')
|
|
540
517
|
debug(`cc result ws=${s.workspaceId} session=${s.sessionId} subtype=${msg.subtype}`)
|
|
541
518
|
if (s.refreshSessionsOnResult) {
|
|
542
519
|
s.refreshSessionsOnResult = false
|
|
@@ -560,7 +537,6 @@ async function consume(s: LiveSession) {
|
|
|
560
537
|
sessionId: s.sessionId,
|
|
561
538
|
content: message
|
|
562
539
|
})
|
|
563
|
-
await markViewBuilderWaitingBySession(s.workspaceId, s.workspacePath, s.sessionId, message)
|
|
564
540
|
}
|
|
565
541
|
} finally {
|
|
566
542
|
// An expected restart only replaces the subprocess. An unexpected exit
|
|
@@ -624,6 +600,7 @@ function createLiveSession(input: {
|
|
|
624
600
|
const options: Options = {
|
|
625
601
|
abortController: abort,
|
|
626
602
|
pathToClaudeCodeExecutable: requireHarnessExecutable('claude-code'),
|
|
603
|
+
spawnClaudeCodeProcess: claudeCodeSpawn(),
|
|
627
604
|
// One query spans many user messages.
|
|
628
605
|
maxTurns: 1000,
|
|
629
606
|
cwd: input.workspacePath,
|
|
@@ -672,7 +649,6 @@ function createLiveSession(input: {
|
|
|
672
649
|
staleCli: false,
|
|
673
650
|
idleTimer: null,
|
|
674
651
|
closed: false,
|
|
675
|
-
lastBuilderError: undefined,
|
|
676
652
|
createdAt: Date.now(),
|
|
677
653
|
lastActivityAt: Date.now(),
|
|
678
654
|
lastUserText: undefined,
|
|
@@ -689,7 +665,7 @@ function createLiveSession(input: {
|
|
|
689
665
|
return session
|
|
690
666
|
}
|
|
691
667
|
|
|
692
|
-
// Accept immediately, but keep the prompt and its settings in
|
|
668
|
+
// Accept immediately, but keep the prompt and its settings in Moi until its
|
|
693
669
|
// turn starts. The returned promise settles when the message reaches the SDK.
|
|
694
670
|
export async function sendCCMessage(input: SendMessageInput): Promise<void> {
|
|
695
671
|
const prepared = prepareAttachmentMessage(input.workspaceId, input.content, input.attachments)
|
|
@@ -830,7 +806,6 @@ async function dispatchNextMessage(messages: SessionMessages): Promise<void> {
|
|
|
830
806
|
if (s.closed) throw new Error('Agent session closed before the message was sent')
|
|
831
807
|
}
|
|
832
808
|
}
|
|
833
|
-
await markViewBuilderBuildingBySession(s.workspaceId, s.workspacePath, s.sessionId)
|
|
834
809
|
if (cancelled()) return
|
|
835
810
|
if (s.closed) throw new Error('Agent session closed before the message was sent')
|
|
836
811
|
// A catalog refresh can arrive during any of the awaits above. Retry
|
|
@@ -926,7 +901,6 @@ export async function interruptCCSession(workspaceId: string, sessionId: string)
|
|
|
926
901
|
}
|
|
927
902
|
broadcast(s.workspaceId, { kind: 'stopped', sessionId: s.sessionId })
|
|
928
903
|
if (!messages.active) setActivity(s, 'idle')
|
|
929
|
-
await markViewBuilderWaitingBySession(s.workspaceId, s.workspacePath, s.sessionId)
|
|
930
904
|
if (!s.closed && !messages.active) armIdle(s)
|
|
931
905
|
void dispatchNextMessage(messages)
|
|
932
906
|
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
isAttachmentOnlyPlaceholder,
|
|
15
15
|
splitAttachmentNote
|
|
16
16
|
} from '@/lib/attachment-note'
|
|
17
|
-
import type {
|
|
17
|
+
import type { SessionSummary, StreamEvent } from '@/lib/types'
|
|
18
18
|
|
|
19
19
|
import { ClaudeAdapter } from './adapter'
|
|
20
20
|
|
|
@@ -52,7 +52,7 @@ export function visibleClaudeSessions<T extends Pick<SDKSessionInfo, 'tag'>>(ses
|
|
|
52
52
|
return sessions.filter(session => session.tag !== MOI_ARCHIVED_SESSION_TAG)
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export async function getSessions(workspacePath: string): Promise<
|
|
55
|
+
export async function getSessions(workspacePath: string): Promise<SessionSummary[]> {
|
|
56
56
|
const sessions = visibleClaudeSessions(await listSessions({ dir: workspacePath }))
|
|
57
57
|
return sessions.map(s => ({
|
|
58
58
|
sessionId: s.sessionId,
|
|
@@ -142,16 +142,12 @@ export async function getSessionEvents(
|
|
|
142
142
|
): Promise<StreamEvent[]> {
|
|
143
143
|
const adapter = new ClaudeAdapter()
|
|
144
144
|
const events: StreamEvent[] = []
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
for (const ev of adapter.ingest(msg)) if (ev.kind !== 'preview') events.push(ev)
|
|
152
|
-
}
|
|
153
|
-
} catch {
|
|
154
|
-
// session file missing or unreadable — return whatever we have (often [])
|
|
145
|
+
const raw = await getSessionMessages(sessionId, { dir: workspacePath })
|
|
146
|
+
for (const msg of raw) {
|
|
147
|
+
// Disk replay carries no `stream_event` messages, so the adapter never
|
|
148
|
+
// produces previews here — filter defensively to keep this the pure,
|
|
149
|
+
// persisted StreamEvent path that reconnect-healing trusts.
|
|
150
|
+
for (const ev of adapter.ingest(msg)) if (ev.kind !== 'preview') events.push(ev)
|
|
155
151
|
}
|
|
156
152
|
return events
|
|
157
153
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Codex harness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Moi drives chats through `codex app-server`, a persistent process speaking
|
|
4
4
|
newline-delimited JSON-RPC over stdio. It provides native model and session
|
|
5
5
|
lists, token deltas, steering, and interruption. Codex owns durable history;
|
|
6
|
-
|
|
6
|
+
Moi holds a display copy and translates native items into shared chat events.
|
|
7
7
|
|
|
8
8
|
The upstream [app-server specification](https://learn.chatgpt.com/docs/app-server)
|
|
9
9
|
defines the protocol; generated types from the installed CLI define its exact wire shapes.
|
|
@@ -20,7 +20,8 @@ defines the protocol; generated types from the installed CLI define its exact wi
|
|
|
20
20
|
| `permissions.ts` | Defines sandbox access and the default approval policy; rejects unsupported requests. |
|
|
21
21
|
| `auth.ts`, `discovery.ts`, `status.ts` | Check login readiness, discover workspace paths from rollout heads, and report running processes. |
|
|
22
22
|
| `session-title.ts` | Generates a title with a separate ephemeral `codex exec` call and applies it if the session is still unnamed. |
|
|
23
|
-
| `
|
|
23
|
+
| `thread-list.ts` | Lists workspace threads from the state DB and hides agent-created tasks. |
|
|
24
|
+
| `probe.ts` | Runs standalone protocol diagnostics without Moi's session or workspace policy. |
|
|
24
25
|
|
|
25
26
|
The shared contract and event layers are in [../README.md](../README.md).
|
|
26
27
|
|
|
@@ -39,7 +40,7 @@ its active runs. Idle display eviction does not stop the workspace process.
|
|
|
39
40
|
Codex resolves its own configuration and credentials, including `CODEX_HOME`
|
|
40
41
|
(default `~/.codex`). Installations can share that home while running different
|
|
41
42
|
binary versions. `config/read` with the workspace cwd supplies effective model,
|
|
42
|
-
effort, and tier defaults;
|
|
43
|
+
effort, and tier defaults; Moi does not rewrite the user's Codex config.
|
|
43
44
|
|
|
44
45
|
Initialization enables `experimentalApi`, reads the version from `userAgent`,
|
|
45
46
|
and then sends `initialized`. The availability check rejects parsed versions
|
|
@@ -53,8 +54,11 @@ reach the harness's 30-second RPC timeout before Bun closes the connection.
|
|
|
53
54
|
|
|
54
55
|
## Session lifecycle
|
|
55
56
|
|
|
56
|
-
- A new chat starts under a temporary
|
|
57
|
-
id; `session_renamed` rekeys the chat, saved settings, and
|
|
57
|
+
- A new chat starts under a temporary Moi id. `thread/start` supplies the real
|
|
58
|
+
id; `session_renamed` rekeys the chat, saved settings, and pending-build references.
|
|
59
|
+
- View handoffs pass the source chat's saved model to `thread/fork`. Codex 0.160.0
|
|
60
|
+
otherwise starts the fork with the configured default; switching an active-source
|
|
61
|
+
fork to `gpt-6.1-sol` on its first turn can fail with a `rustponsesapi` model error.
|
|
58
62
|
- Concurrent resumes share one promise. Subscribe before `thread/resume`,
|
|
59
63
|
buffer notifications while loading history, then apply them after the
|
|
60
64
|
snapshot. Otherwise a live update can be overwritten by replay.
|
|
@@ -77,9 +81,24 @@ reach the harness's 30-second RPC timeout before Bun closes the connection.
|
|
|
77
81
|
`thread/read` provides a static fallback when live resume fails.
|
|
78
82
|
|
|
79
83
|
`thread/list` uses cwd filtering, `updated_at` ordering, and every cursor page.
|
|
80
|
-
Repeated cursors fail instead of looping.
|
|
81
|
-
|
|
82
|
-
up to
|
|
84
|
+
Repeated cursors fail instead of looping. Listings pass `useStateDbOnly`: the
|
|
85
|
+
default mode decodes rollout heads from every workspace under
|
|
86
|
+
`$CODEX_HOME/sessions` (up to 10,000 files), which can exceed the RPC deadline
|
|
87
|
+
on large histories. Only the known state-database listing error falls back to
|
|
88
|
+
that scan; older CLIs ignore the field. CLI 0.162 reports code `-32603` with a
|
|
89
|
+
message ending in `failed to list threads from state database` (wrapped by the
|
|
90
|
+
thread store and app-server). Timeouts, disconnects, other RPC errors, and
|
|
91
|
+
app-server startup failures propagate so a failed refresh preserves cached chats.
|
|
92
|
+
|
|
93
|
+
The state DB also returns Codex Desktop tasks that an agent started through
|
|
94
|
+
`create_thread` (`threadSource: agent_created_thread`); the rollout scan drops
|
|
95
|
+
them only because their first input is a tool output, not a user message. moi
|
|
96
|
+
hides them. `thread/list` returns `threadSource` as null (CLI 0.162), so each
|
|
97
|
+
thread is read once with `thread/read` and its source is cached by id.
|
|
98
|
+
|
|
99
|
+
Child-history loading is limited to four concurrent reads. Home-card previews
|
|
100
|
+
reuse an existing app-server and read the same listing; rendering the home page
|
|
101
|
+
does not spawn one per card.
|
|
83
102
|
Workspace import discovery separately reads up to 400 recent rollout heads
|
|
84
103
|
under the server's `$CODEX_HOME/sessions`, without requiring a CLI executable.
|
|
85
104
|
|
|
@@ -104,14 +123,14 @@ otherwise the adapter uses its advertised default. Fast mode is available when
|
|
|
104
123
|
to `additionalSpeedTiers: ["fast"]`. A non-null configured tier takes precedence
|
|
105
124
|
over the catalog default.
|
|
106
125
|
|
|
107
|
-
|
|
|
126
|
+
| Moi fast-mode setting | Native `serviceTier` |
|
|
108
127
|
| --------------------- | ---------------------------------------- |
|
|
109
128
|
| On | `"priority"` |
|
|
110
129
|
| Off | `null` |
|
|
111
130
|
| Unset | Omitted; inherits the config/thread tier |
|
|
112
131
|
|
|
113
132
|
Model, effort, and tier changes apply on the next **new turn**. `turn/steer`
|
|
114
|
-
has no fields for changing them during an active turn.
|
|
133
|
+
has no fields for changing them during an active turn. Moi uses the persistent
|
|
115
134
|
`serviceTier` override for chat settings; it does not use the newer
|
|
116
135
|
`serviceTierForTurn` override, which affects only one turn.
|
|
117
136
|
|
|
@@ -126,14 +145,14 @@ The version gate matters because older servers can silently ignore the field.
|
|
|
126
145
|
|
|
127
146
|
`permissions.ts` selects workspace-write access and `approvalPolicy: 'on-request'`
|
|
128
147
|
on start/resume. New turns explicitly set the workspace-write sandbox with
|
|
129
|
-
network access disabled.
|
|
148
|
+
network access disabled. Moi automatically accepts supported permission
|
|
130
149
|
requests; there is no command-approval UI.
|
|
131
150
|
Command/file requests use `decision: 'accept'`, legacy requests use `approved`,
|
|
132
151
|
and permission extensions grant the requested network/file-system fields for
|
|
133
152
|
`scope: 'turn'`. Unknown request methods receive an unsupported-method error.
|
|
134
153
|
|
|
135
154
|
Native question forms (`item/tool/requestUserInput`) are not supported and
|
|
136
|
-
receive the same unsupported-method error.
|
|
155
|
+
receive the same unsupported-method error. Moi does not opt into
|
|
137
156
|
`features.default_mode_request_user_input`. MCP schema/URL elicitation is
|
|
138
157
|
declined with `action: 'decline'`.
|
|
139
158
|
|
|
@@ -162,7 +181,7 @@ Before restoring support:
|
|
|
162
181
|
|
|
163
182
|
- Native items become display turns or notices. `clientUserMessageId` is echoed
|
|
164
183
|
as `clientId` on live user items, so the optimistic bubble is updated in place.
|
|
165
|
-
Replay can change item ids and omit `clientId`; they are not durable
|
|
184
|
+
Replay can change item ids and omit `clientId`; they are not durable Moi ids.
|
|
166
185
|
- Agent text and reasoning-summary deltas become cumulative previews, batched
|
|
167
186
|
every 40ms. Item completion removes its pending preview. Command output
|
|
168
187
|
deltas are also batched; the live tail is bounded to 64K characters until the
|
|
@@ -199,7 +218,7 @@ Before restoring support:
|
|
|
199
218
|
frames and pending native input before assuming it is still generating.
|
|
200
219
|
3. Update the selected standalone CLI with `codex update` when it supports that
|
|
201
220
|
command. Already-running app-servers keep the old executable until restarted;
|
|
202
|
-
let active chats finish before restarting them or the
|
|
221
|
+
let active chats finish before restarting them or the Moi dev server.
|
|
203
222
|
|
|
204
223
|
Read-only standalone probes (run from the repo root):
|
|
205
224
|
|
|
@@ -210,7 +229,7 @@ bun server/harness/codex/probe.ts rpc "$PWD" config/read '{}'
|
|
|
210
229
|
```
|
|
211
230
|
|
|
212
231
|
The probe uses the invoking shell's PATH/environment, disables experimental
|
|
213
|
-
fields, and logs raw frames. Use the running
|
|
232
|
+
fields, and logs raw frames. Use the running Moi wire tap to verify workspace
|
|
214
233
|
policy or actual UI behavior.
|
|
215
234
|
|
|
216
235
|
Wire types are a hand-written subset, read defensively. Generate reference
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
Turn
|
|
14
14
|
} from '@/lib/format'
|
|
15
15
|
import { stripMoiContextLoose } from '@/lib/moi-context'
|
|
16
|
-
import type { McpServer, Model,
|
|
16
|
+
import type { McpServer, Model, SessionSummary } from '@/lib/types'
|
|
17
17
|
|
|
18
18
|
import type { WorkspaceActivityPreview } from '../types'
|
|
19
19
|
|
|
@@ -97,6 +97,8 @@ export type CodexThread = {
|
|
|
97
97
|
createdAt?: number
|
|
98
98
|
updatedAt?: number
|
|
99
99
|
name?: string | null
|
|
100
|
+
// Scalar label such as `user` or `agent_created_thread`; null in thread/list.
|
|
101
|
+
threadSource?: string | null
|
|
100
102
|
status?: { type?: string; activeFlags?: string[] }
|
|
101
103
|
turns?: CodexTurn[]
|
|
102
104
|
}
|
|
@@ -143,11 +145,11 @@ function cleanPreview(preview: string | undefined): string {
|
|
|
143
145
|
return preview ? formatChatTitle(stripMoiContextLoose(preview)) : ''
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
export function codexThreadToSessionInfo(t: CodexThread):
|
|
148
|
+
export function codexThreadToSessionInfo(t: CodexThread): SessionSummary {
|
|
147
149
|
return {
|
|
148
150
|
sessionId: t.id,
|
|
149
151
|
summary: t.name?.trim() || cleanPreview(t.preview),
|
|
150
|
-
// Codex timestamps are unix seconds;
|
|
152
|
+
// Codex timestamps are unix seconds; moi uses milliseconds.
|
|
151
153
|
lastModified: (t.updatedAt ?? t.createdAt ?? 0) * 1000,
|
|
152
154
|
cwd: t.cwd
|
|
153
155
|
}
|