moi-computer 0.12.1-next.0 → 0.12.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -26
- package/bin/moi.mjs +2 -2
- package/client/AGENTS.md +7 -3
- package/client/api/app-config.ts +5 -10
- package/client/api/workspace-keys.ts +3 -2
- package/client/app/app-provider.tsx +25 -0
- 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} +22 -23
- package/client/app/shell/{SidebarLayout.tsx → sidebar-layout.tsx} +29 -23
- package/client/dev/index.html +43 -0
- package/client/dev/index.ts +15 -0
- package/client/features/applets/api.ts +1 -1
- package/client/features/applets/{AppletContainer.tsx → applet-container.tsx} +1 -1
- 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 +4 -4
- package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +11 -11
- package/client/features/chat/{ChatPopup.tsx → chat-popup.tsx} +1 -1
- 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} +8 -7
- package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +1 -1
- package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +12 -28
- package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
- package/client/features/chat/connection/chat-frames.ts +3 -3
- package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +4 -4
- package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +1 -1
- 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 +3 -3
- package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +2 -2
- package/client/features/chat/sessions/{useSelectedSession.ts → use-selected-session.ts} +2 -2
- package/client/features/chat/{useChat.ts → use-chat.ts} +4 -4
- package/client/features/collab/host-state.ts +24 -7
- package/client/features/collab/local-user.ts +1 -1
- package/client/features/collab/proxy-user.ts +4 -9
- 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} +26 -80
- 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 +253 -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/{useViewSketch.ts → use-view-sketch.ts} +1 -1
- package/client/features/harness/api.ts +36 -0
- package/client/features/harness/device-login-steps.tsx +97 -0
- package/client/features/home/api.ts +29 -89
- package/client/features/home/{HomeLogo.tsx → home-logo.tsx} +1 -1
- package/client/features/home/{HomePage.tsx → home-page.tsx} +13 -14
- package/client/features/overview/api.ts +2 -2
- package/client/features/overview/default/registry.tsx +1 -1
- package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +1 -1
- package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
- package/client/features/overview/{Overview.tsx → overview.tsx} +6 -6
- 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} +10 -13
- package/client/features/scratchpad/{useScratchpadSnapshot.tsx → use-scratchpad-snapshot.tsx} +3 -3
- package/client/features/settings/api.ts +15 -9
- 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 +1 -1
- package/client/features/views/{PendingViewScreen.tsx → pending-view-screen.tsx} +7 -4
- package/client/features/views/{useViewActions.ts → use-view-actions.ts} +2 -2
- package/client/features/views/{useViewDrafts.ts → use-view-drafts.ts} +15 -6
- package/client/features/views/{ViewManager.tsx → view-manager.tsx} +3 -3
- package/client/features/views/view-submission.ts +1 -1
- 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 +31 -26
- package/client/features/workspace/browser-tab-state.ts +1 -1
- package/client/features/workspace/moi-context.ts +1 -1
- 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 +78 -0
- package/client/features/workspace/setup/workspace-welcome-state.tsx +81 -0
- package/client/features/workspace/{ThemePanel.tsx → theme-panel.tsx} +3 -3
- package/client/features/workspace/{useWorkspaceNavigation.ts → use-workspace-navigation.ts} +2 -2
- package/client/features/workspace/{WorkspaceScreen.tsx → workspace-content.tsx} +37 -80
- package/client/features/workspace/workspace-frame.tsx +76 -0
- package/client/features/workspace/workspace-identity.tsx +40 -0
- package/client/features/workspace/{WorkspaceLayoutContext.tsx → workspace-layout-context.tsx} +2 -0
- package/client/features/workspace/{WorkspaceMenu.tsx → workspace-menu.tsx} +3 -3
- package/client/features/workspace/workspace-pending-screen.tsx +26 -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 +29 -10
- package/client/index.tsx +7 -2
- package/client/lib/agent-availability.ts +0 -5
- package/client/lib/browser-tab-id.ts +4 -0
- package/client/main.tsx +10 -7
- package/client/runtime/app-context.ts +20 -0
- package/client/runtime/use-workspace-events.ts +56 -0
- package/client/runtime/workspace-events.ts +151 -0
- package/dist/chunk-00rh9df4.js +2 -0
- package/dist/chunk-4nh7y1hq.css +1 -0
- package/dist/{chunk-vqpkqtdr.js → chunk-am4agx6v.js} +1 -1
- package/dist/{chunk-gps4qc38.js → chunk-d7cbm65e.js} +1 -1
- package/dist/chunk-hbpdv7vd.js +1 -0
- package/dist/chunk-hmka9rt5.js +2 -0
- package/dist/{chunk-j905va8r.js → chunk-hvh9f5h0.js} +1 -1
- package/dist/chunk-mjjregkn.js +10 -0
- package/dist/chunk-rt30jbcm.js +1 -0
- package/dist/chunk-vt6zybej.js +2 -0
- package/dist/chunk-wbkwf6cc.js +68 -0
- package/dist/chunk-xjyfyz64.js +1 -0
- package/dist/{chunk-hzwr8dp8.js → chunk-y8nbwp21.js} +71 -71
- package/dist/chunk-ysfdcew7.js +1 -0
- package/dist/index.html +30 -11
- package/lib/format.ts +1 -1
- package/lib/harness-instructions.ts +30 -0
- package/lib/ids.ts +3 -3
- package/lib/moi-context.ts +2 -2
- package/lib/scratchpad-skew.ts +3 -3
- package/lib/types.ts +28 -20
- package/lib/update.ts +1 -1
- package/package.json +5 -2
- package/server/AGENTS.md +10 -4
- package/server/README.md +102 -0
- package/server/api/harnesses.ts +56 -0
- package/server/{api.ts → api/index.ts} +125 -118
- package/server/app-config.ts +24 -12
- 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 +1 -1
- 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} +2 -2
- package/server/applets/index.ts +2 -2
- package/server/{thumbnails.ts → applets/thumbnails.ts} +9 -6
- package/server/{applet-typecheck.ts → applets/typecheck.ts} +4 -4
- package/server/{ui-components.ts → applets/ui-components.ts} +2 -2
- package/server/{views.ts → applets/views.ts} +7 -7
- 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} +9 -9
- 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 -3252
- package/server/collab/manager.ts +3 -3
- package/server/collab/skill/index.ts +2 -2
- package/server/control.ts +20 -20
- package/server/harness/README.md +47 -25
- package/server/harness/acp/NOTES.md +11 -11
- package/server/harness/acp/archived.ts +3 -3
- package/server/harness/acp/client.ts +2 -2
- package/server/harness/acp/run-durations.ts +1 -1
- package/server/harness/acp/session.ts +5 -5
- package/server/harness/auth.ts +303 -0
- package/server/harness/claude-code/NOTES.md +9 -7
- package/server/harness/claude-code/auth.ts +125 -17
- package/server/harness/claude-code/index.ts +2 -1
- package/server/harness/claude-code/mcp.ts +1 -1
- package/server/harness/claude-code/session.ts +10 -7
- package/server/harness/codex/NOTES.md +12 -12
- package/server/harness/codex/auth.ts +86 -19
- package/server/harness/codex/client.ts +17 -13
- package/server/harness/codex/index.ts +2 -1
- package/server/harness/codex/permissions.ts +3 -3
- package/server/harness/codex/probe.ts +3 -5
- package/server/harness/codex/session.ts +16 -13
- package/server/harness/codex/thread-list.ts +4 -0
- package/server/harness/codex/transport.ts +5 -5
- package/server/harness/executable.ts +42 -18
- 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 +1 -1
- package/server/harness/openclaw/compat.ts +1 -1
- package/server/harness/openclaw/session.ts +5 -2
- package/server/harness/registry.ts +1 -1
- package/server/harness/shell-path.ts +31 -21
- package/server/harness/types.ts +9 -2
- 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 +2 -2
- package/server/{session-archive.ts → sessions/archive.ts} +5 -5
- package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
- package/server/{session-config.ts → sessions/config.ts} +1 -1
- package/server/{session-lifecycle.ts → sessions/lifecycle.ts} +3 -3
- package/server/{pending-views.ts → sessions/pending-views.ts} +3 -3
- package/server/{selected-session.ts → sessions/selected.ts} +1 -1
- package/server/{session-store.ts → sessions/store.ts} +1 -1
- package/server/{view-sessions.ts → sessions/view-sessions.ts} +9 -9
- 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 +5 -3
- package/server/status.ts +3 -3
- package/server/vendor.ts +23 -30
- package/server/web.ts +17 -9
- package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
- package/server/{workspace-env.ts → workspaces/env.ts} +3 -3
- package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
- package/server/{workspace-init.ts → workspaces/init.ts} +5 -5
- package/server/{layout.ts → workspaces/layout.ts} +13 -8
- package/server/{preview.ts → workspaces/preview.ts} +1 -1
- package/server/{registry.ts → workspaces/registry.ts} +3 -3
- package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
- package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +3 -3
- 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 +12 -12
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +2 -2
- 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/composer/banners/AgentAvailabilityBanner.tsx +0 -101
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
- package/client/features/overview/WorkspaceName.tsx +0 -60
- package/client/runtime/useWorkspaceEvents.ts +0 -189
- package/dist/chunk-1zhnhy00.js +0 -1
- package/dist/chunk-27501vke.js +0 -1
- package/dist/chunk-9xtv6djt.js +0 -2
- package/dist/chunk-am1x230f.js +0 -2
- package/dist/chunk-darpsw65.js +0 -1
- package/dist/chunk-n33w9y38.js +0 -10
- package/dist/chunk-r63ks44z.js +0 -68
- package/dist/chunk-wd46nk26.css +0 -1
- package/dist/chunk-xgt7vxt9.js +0 -1
- package/dist/chunk-yvzhwtfa.js +0 -2
- package/server/agent.ts +0 -223
- /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/vendor/react/{development → 19.2.4/development}/_impl/react-dom-client.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-dom-client.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-dom.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom-client.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-dom-client.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-dom.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react.js +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/{tabs.ts → workspaces/tabs.ts} +0 -0
- /package/server/{theme.ts → workspaces/theme.ts} +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
// Login is global per harness. Workspace readiness is checked independently
|
|
2
|
+
// using each workspace’s environment.
|
|
3
|
+
import type {
|
|
4
|
+
HarnessLoginState,
|
|
5
|
+
HarnessAvailability,
|
|
6
|
+
HarnessLogin,
|
|
7
|
+
WorkspaceType
|
|
8
|
+
} from '@/lib/types'
|
|
9
|
+
|
|
10
|
+
import { listWorkspaces } from '../workspaces/registry'
|
|
11
|
+
import { publishEvent } from '../events'
|
|
12
|
+
import { harnessFor } from './registry'
|
|
13
|
+
import type { HarnessWorkspace, HarnessLoginAttempt } from './types'
|
|
14
|
+
|
|
15
|
+
export type HarnessUpdatedEvent = {
|
|
16
|
+
type: 'harness:updated'
|
|
17
|
+
workspaceId: string
|
|
18
|
+
availability: HarnessAvailability
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Readiness can target a harness account or an individual workspace.
|
|
22
|
+
type HarnessTarget = WorkspaceType | HarnessWorkspace
|
|
23
|
+
|
|
24
|
+
function entryKey(context: HarnessTarget): string {
|
|
25
|
+
return typeof context === 'string' ? `default:${context}` : `workspace:${context.id}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type HarnessStoreOptions = {
|
|
29
|
+
probe: (ws: HarnessTarget) => Promise<HarnessAvailability>
|
|
30
|
+
startLogin: (type: WorkspaceType) => Promise<HarnessLoginAttempt>
|
|
31
|
+
publish: (event: HarnessUpdatedEvent) => void
|
|
32
|
+
onAuthChanged?: (type: WorkspaceType) => Promise<void>
|
|
33
|
+
availabilityTtlMs?: number
|
|
34
|
+
loginPollMs?: number
|
|
35
|
+
loginDeadlineMs?: number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type LoginCeremony = {
|
|
39
|
+
state: HarnessLoginState
|
|
40
|
+
// The in-flight provider call; joiners await it instead of starting a
|
|
41
|
+
// second flow. Cleared once settled.
|
|
42
|
+
starting?: Promise<HarnessLogin>
|
|
43
|
+
stop: () => void
|
|
44
|
+
attempt?: HarnessLoginAttempt
|
|
45
|
+
completed?: boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type HarnessEntry = {
|
|
49
|
+
cached?: { value: HarnessAvailability; checkedAt: number }
|
|
50
|
+
// In-flight probe, shared by concurrent callers.
|
|
51
|
+
probe?: Promise<HarnessAvailability>
|
|
52
|
+
login?: LoginCeremony
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function failedProbeAvailability(ws: HarnessTarget, err: unknown): HarnessAvailability {
|
|
56
|
+
console.error(`[harness-auth] availability probe failed for ${harnessFor(ws).id}`, err)
|
|
57
|
+
return { status: 'unavailable', reason: 'Could not check agent availability' }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function sameAvailability(a: HarnessAvailability, b: HarnessAvailability): boolean {
|
|
61
|
+
if (a.status !== b.status) return false
|
|
62
|
+
if (a.status === 'available' || b.status === 'available') return true
|
|
63
|
+
return (
|
|
64
|
+
a.reason === b.reason &&
|
|
65
|
+
(a.status !== 'unavailable' || b.status !== 'unavailable' || a.code === b.code)
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function createHarnessStore(options: HarnessStoreOptions) {
|
|
70
|
+
const ttlMs = options.availabilityTtlMs ?? 30_000
|
|
71
|
+
const pollMs = options.loginPollMs ?? 2_000
|
|
72
|
+
const deadlineMs = options.loginDeadlineMs ?? 10 * 60_000
|
|
73
|
+
const entries = new Map<string, HarnessEntry>()
|
|
74
|
+
|
|
75
|
+
function entryFor(context: HarnessTarget): HarnessEntry {
|
|
76
|
+
const key = entryKey(context)
|
|
77
|
+
let entry = entries.get(key)
|
|
78
|
+
if (!entry) {
|
|
79
|
+
entry = {}
|
|
80
|
+
entries.set(key, entry)
|
|
81
|
+
}
|
|
82
|
+
return entry
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function publish(context: HarnessTarget, availability: HarnessAvailability) {
|
|
86
|
+
if (typeof context === 'string') return options.onAuthChanged?.(context)
|
|
87
|
+
options.publish({
|
|
88
|
+
type: 'harness:updated',
|
|
89
|
+
workspaceId: context.id,
|
|
90
|
+
availability
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function probeFresh(ws: HarnessTarget): Promise<HarnessAvailability> {
|
|
95
|
+
const entry = entryFor(ws)
|
|
96
|
+
if (!entry.probe) {
|
|
97
|
+
entry.probe = Promise.resolve()
|
|
98
|
+
.then(() => options.probe(ws))
|
|
99
|
+
.catch(err => failedProbeAvailability(ws, err))
|
|
100
|
+
.finally(() => {
|
|
101
|
+
entry.probe = undefined
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
const value = await entry.probe
|
|
105
|
+
entry.cached = { value, checkedAt: Date.now() }
|
|
106
|
+
return value
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function getAvailability(ws: HarnessTarget): Promise<HarnessAvailability> {
|
|
110
|
+
const entry = entryFor(ws)
|
|
111
|
+
if (entry.cached && Date.now() - entry.cached.checkedAt < ttlMs) {
|
|
112
|
+
return entry.cached.value
|
|
113
|
+
}
|
|
114
|
+
return probeFresh(ws)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Bypass the TTL and push the result even if it's unchanged. For callers
|
|
118
|
+
// that suspect the cached snapshot is stale for a reason other than an env
|
|
119
|
+
// change (e.g. a send just failed, which can mean the provider was signed
|
|
120
|
+
// out from outside moi — a `codex logout` in a terminal, say).
|
|
121
|
+
async function refresh(ws: HarnessTarget): Promise<HarnessAvailability> {
|
|
122
|
+
const value = await probeFresh(ws)
|
|
123
|
+
await publish(ws, value)
|
|
124
|
+
return value
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function getLogin(context: WorkspaceType): HarnessLoginState | undefined {
|
|
128
|
+
return entries.get(entryKey(context))?.login?.state
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Re-probe until the login lands or the deadline passes. One loop per
|
|
132
|
+
// ceremony; a replaced or completed ceremony stops its loop.
|
|
133
|
+
function watch(
|
|
134
|
+
type: WorkspaceType,
|
|
135
|
+
login: LoginCeremony,
|
|
136
|
+
initialAvailability: HarnessAvailability
|
|
137
|
+
) {
|
|
138
|
+
const deadline = Date.now() + deadlineMs
|
|
139
|
+
let stopped = false
|
|
140
|
+
let publishedAvailability = initialAvailability
|
|
141
|
+
let timer: ReturnType<typeof setTimeout>
|
|
142
|
+
login.stop = () => {
|
|
143
|
+
stopped = true
|
|
144
|
+
clearTimeout(timer)
|
|
145
|
+
}
|
|
146
|
+
const tick = async () => {
|
|
147
|
+
const value = await probeFresh(type)
|
|
148
|
+
if (stopped) return
|
|
149
|
+
const entry = entryFor(type)
|
|
150
|
+
if (value.status === 'available' && (!login.attempt?.completed || login.completed)) {
|
|
151
|
+
entry.login = undefined
|
|
152
|
+
await publish(type, value)
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
if (Date.now() >= deadline) {
|
|
156
|
+
// Keep the failed state so the connection panel can show it; the next
|
|
157
|
+
// startLogin replaces it.
|
|
158
|
+
stopLogin(login)
|
|
159
|
+
login.state = { state: 'failed', reason: 'Sign-in did not complete. Try again' }
|
|
160
|
+
await publish(type, value)
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
if (!sameAvailability(value, publishedAvailability)) {
|
|
164
|
+
publishedAvailability = value
|
|
165
|
+
await publish(type, value)
|
|
166
|
+
}
|
|
167
|
+
timer = setTimeout(tick, pollMs)
|
|
168
|
+
timer.unref?.()
|
|
169
|
+
}
|
|
170
|
+
// Unref'd so a pending ceremony never keeps the process alive on its own.
|
|
171
|
+
timer = setTimeout(tick, pollMs)
|
|
172
|
+
timer.unref?.()
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function startLogin(type: WorkspaceType): Promise<HarnessLogin> {
|
|
176
|
+
const entry = entryFor(type)
|
|
177
|
+
// Concurrent starts share the provider call; active attempts reuse their instructions.
|
|
178
|
+
const current = entry.login
|
|
179
|
+
if (current?.starting) return current.starting
|
|
180
|
+
if (current?.state.state === 'pending') {
|
|
181
|
+
const { state: _state, ...instructions } = current.state
|
|
182
|
+
return instructions
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (current) stopLogin(current)
|
|
186
|
+
const starting = options.startLogin(type).then(attempt => {
|
|
187
|
+
const { completed, cancel: _cancel, submitCode: _submitCode, ...instructions } = attempt
|
|
188
|
+
login.attempt = attempt
|
|
189
|
+
if (entry.login !== login) {
|
|
190
|
+
stopLogin(login)
|
|
191
|
+
}
|
|
192
|
+
void completed?.then(
|
|
193
|
+
() => {
|
|
194
|
+
login.completed = true
|
|
195
|
+
},
|
|
196
|
+
() => {
|
|
197
|
+
if (entry.login !== login) return
|
|
198
|
+
stopLogin(login)
|
|
199
|
+
login.state = { state: 'failed', reason: 'Sign-in failed or expired. Try again' }
|
|
200
|
+
void refresh(type)
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
return instructions
|
|
204
|
+
})
|
|
205
|
+
const login: LoginCeremony = { state: { state: 'starting' }, starting, stop: () => {} }
|
|
206
|
+
entry.login = login
|
|
207
|
+
try {
|
|
208
|
+
const result = await starting
|
|
209
|
+
if (entry.login !== login) return result
|
|
210
|
+
login.starting = undefined
|
|
211
|
+
if (login.state.state === 'starting') login.state = { state: 'pending', ...result }
|
|
212
|
+
const availability = entry.cached?.value ?? {
|
|
213
|
+
status: 'login-required',
|
|
214
|
+
reason: 'Waiting for sign-in'
|
|
215
|
+
}
|
|
216
|
+
await publish(type, availability)
|
|
217
|
+
if (login.state.state === 'pending') watch(type, login, availability)
|
|
218
|
+
return result
|
|
219
|
+
} catch (err) {
|
|
220
|
+
if (entry.login === login) entry.login = undefined
|
|
221
|
+
throw err
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Drop the cached snapshot so the next read re-probes (e.g. after an env
|
|
226
|
+
// change swaps credentials).
|
|
227
|
+
function invalidate(context: HarnessTarget) {
|
|
228
|
+
const entry = entries.get(entryKey(context))
|
|
229
|
+
if (!entry) return
|
|
230
|
+
entry.cached = undefined
|
|
231
|
+
if (entry.login) stopLogin(entry.login)
|
|
232
|
+
entry.login = undefined
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function stopLogin(login: LoginCeremony) {
|
|
236
|
+
login.stop()
|
|
237
|
+
void Promise.resolve()
|
|
238
|
+
.then(() => login.attempt?.cancel?.())
|
|
239
|
+
.catch(() => {})
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function activeLogin(type: WorkspaceType, id: string) {
|
|
243
|
+
const login = entryFor(type).login
|
|
244
|
+
if (!login || login.state.state !== 'pending' || login.state.id !== id) {
|
|
245
|
+
throw new Error('This sign-in attempt has ended. Start again')
|
|
246
|
+
}
|
|
247
|
+
return login
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async function submitCode(type: WorkspaceType, id: string, code: string) {
|
|
251
|
+
const login = activeLogin(type, id)
|
|
252
|
+
if (!login.attempt?.submitCode) throw new Error('This sign-in does not accept a code')
|
|
253
|
+
await login.attempt.submitCode(code)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function shutdown() {
|
|
257
|
+
for (const entry of entries.values()) {
|
|
258
|
+
if (entry.login) stopLogin(entry.login)
|
|
259
|
+
entry.login = undefined
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
getAvailability,
|
|
265
|
+
refresh,
|
|
266
|
+
getLogin,
|
|
267
|
+
startLogin,
|
|
268
|
+
submitCode,
|
|
269
|
+
invalidate,
|
|
270
|
+
shutdown
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export type HarnessStore = ReturnType<typeof createHarnessStore>
|
|
275
|
+
|
|
276
|
+
export const harnessStore = createHarnessStore({
|
|
277
|
+
probe: async context => {
|
|
278
|
+
const harness = harnessFor(context)
|
|
279
|
+
if (typeof context !== 'string') {
|
|
280
|
+
return (await harness.availability?.(context)) ?? { status: 'available' }
|
|
281
|
+
}
|
|
282
|
+
if (!harness.authStatus)
|
|
283
|
+
return { status: 'unavailable', reason: 'This agent requires terminal sign-in' }
|
|
284
|
+
return harness.authStatus()
|
|
285
|
+
},
|
|
286
|
+
startLogin: type => {
|
|
287
|
+
const start = harnessFor(type).startLogin
|
|
288
|
+
if (!start) throw new Error('This agent requires terminal sign-in')
|
|
289
|
+
return start()
|
|
290
|
+
},
|
|
291
|
+
publish: publishEvent,
|
|
292
|
+
onAuthChanged: async type => {
|
|
293
|
+
// Shared credentials still need an independent check in each workspace.
|
|
294
|
+
try {
|
|
295
|
+
const workspaces = await listWorkspaces()
|
|
296
|
+
await Promise.all(
|
|
297
|
+
workspaces.filter(ws => harnessFor(ws).id === type).map(ws => harnessStore.refresh(ws))
|
|
298
|
+
)
|
|
299
|
+
} catch (error) {
|
|
300
|
+
console.error('[harness-auth] could not refresh workspaces after login', error)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
})
|
|
@@ -10,7 +10,7 @@ spec for the CC adapter.
|
|
|
10
10
|
> their wire examples are not an exhaustive list of today's SDK messages, and
|
|
11
11
|
> the migration proposed in §14 has shipped. Current display types live in
|
|
12
12
|
> `lib/format.ts`, mapping in `adapter.ts`, and rendering in
|
|
13
|
-
> `client/features/chat/messages/
|
|
13
|
+
> `client/features/chat/messages/turn-view.tsx`. Use the installed `sdk.d.ts` for current
|
|
14
14
|
> wire types.
|
|
15
15
|
|
|
16
16
|
Evidence drawn from:
|
|
@@ -19,7 +19,9 @@ Evidence drawn from:
|
|
|
19
19
|
- Upstream nested content types: `node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.ts`
|
|
20
20
|
- SDK bundled source: `sdk.mjs` (for undocumented behavior around `isSynthetic` / `isReplay`)
|
|
21
21
|
- Official docs: <https://code.claude.com/docs/en/agent-sdk/typescript>
|
|
22
|
-
-
|
|
22
|
+
- Historical repo code at capture time: `server/agent.ts`, `server/state.ts`,
|
|
23
|
+
`lib/types.ts`, `client/components/MessageBlock.tsx`. These are research-era
|
|
24
|
+
locations; current module ownership is described in the status note above.
|
|
23
25
|
- Captured live: `workspace/raw-sdk-messages.jsonl` (skill load + sub-agent run)
|
|
24
26
|
|
|
25
27
|
---
|
|
@@ -29,14 +31,14 @@ Evidence drawn from:
|
|
|
29
31
|
The Agent SDK remains the transport layer, but every `query()` explicitly uses
|
|
30
32
|
the `claude` executable through `pathToClaudeCodeExecutable`. Lookup goes
|
|
31
33
|
through `../executable.ts`: the server's PATH merged with the user's
|
|
32
|
-
login-shell PATH (`../shell-path.ts`, probed once at startup), so a
|
|
34
|
+
login-shell PATH (`../shell-path.ts`, probed once at startup), so a Moi server
|
|
33
35
|
launched outside a terminal still finds CLIs from `~/.local/bin`, homebrew,
|
|
34
36
|
and version-manager shims. There is no SDK bundled-executable fallback. If the
|
|
35
37
|
command is missing, setup and existing workspaces report:
|
|
36
|
-
`Run curl -fsSL https://claude.ai/install.sh | sh
|
|
38
|
+
`Run in terminal to install Claude Code: curl -fsSL https://claude.ai/install.sh | sh`.
|
|
37
39
|
|
|
38
40
|
**In-place updates.** Claude Code can replace its binary at the same path
|
|
39
|
-
while
|
|
41
|
+
while Moi keeps running, changing which models are available.
|
|
40
42
|
|
|
41
43
|
- Every spawn resolves the executable afresh, so new sessions run the new
|
|
42
44
|
binary. A live session keeps the subprocess it started with until it is torn
|
|
@@ -50,7 +52,7 @@ while moi keeps running, changing which models are available.
|
|
|
50
52
|
jobs to finish, replaces the subprocess, and resumes the same session from
|
|
51
53
|
disk. Replacement happens on demand.
|
|
52
54
|
- Pending messages and their model, effort, fast-mode, and streaming settings
|
|
53
|
-
stay in
|
|
55
|
+
stay in Moi's per-session queue. Only one user message enters the SDK per
|
|
54
56
|
turn. Matching result IDs prevent an autonomous background turn from
|
|
55
57
|
releasing a waiting user prompt. When the CLI emits lifecycle events,
|
|
56
58
|
dispatch also waits for `idle`. The queue follows session ID renames and
|
|
@@ -60,7 +62,7 @@ while moi keeps running, changing which models are available.
|
|
|
60
62
|
An absent effort or fast-mode value clears that flag with `null`, restoring
|
|
61
63
|
provider defaults.
|
|
62
64
|
- Background jobs retain their subprocess. Messages requiring a replacement
|
|
63
|
-
wait in
|
|
65
|
+
wait in Moi until those jobs finish, including replacements for streaming
|
|
64
66
|
changes. `background_tasks_changed` replaces the complete task set, including
|
|
65
67
|
backgrounded subagents and ambient watchers. Task start/update/completion
|
|
66
68
|
events are a fallback only until the process emits its first snapshot; their
|
|
@@ -1,7 +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
10
|
import { agentCommand } from '../../agent-launcher'
|
|
4
|
-
import { resolveWorkspaceEnv } from '../../
|
|
11
|
+
import { resolveWorkspaceEnv } from '../../workspaces/env'
|
|
5
12
|
import { findHarnessExecutable } from '../executable'
|
|
6
13
|
|
|
7
14
|
function signedOut(reason: string): HarnessAvailability {
|
|
@@ -29,13 +36,14 @@ export function claudeAuthReadiness(result: ClaudeAuthProbeResult): HarnessAvail
|
|
|
29
36
|
// Claude Code documents exit 0 as logged in and exit 1 as logged out. Run the
|
|
30
37
|
// probe with the same workspace env as the actual Agent SDK subprocess so
|
|
31
38
|
// API-key and enterprise provider configuration match the eventual send.
|
|
32
|
-
export async function getClaudeAuthReadiness(workspacePath
|
|
39
|
+
export async function getClaudeAuthReadiness(workspacePath?: string): Promise<HarnessAvailability> {
|
|
33
40
|
const executable = findHarnessExecutable('claude-code')
|
|
34
|
-
if (!executable)
|
|
41
|
+
if (!executable)
|
|
42
|
+
return { status: 'unavailable', code: 'not-installed', reason: 'Claude is not installed' }
|
|
35
43
|
|
|
36
|
-
const workspaceEnv = await resolveWorkspaceEnv(workspacePath)
|
|
44
|
+
const workspaceEnv = workspacePath ? await resolveWorkspaceEnv(workspacePath) : {}
|
|
37
45
|
const proc = Bun.spawn(agentCommand([executable, 'auth', 'status']), {
|
|
38
|
-
cwd: workspacePath,
|
|
46
|
+
cwd: workspacePath ?? homedir(),
|
|
39
47
|
env: { ...process.env, ...workspaceEnv },
|
|
40
48
|
stdin: 'ignore',
|
|
41
49
|
stdout: 'ignore',
|
|
@@ -54,17 +62,117 @@ export async function getClaudeAuthReadiness(workspacePath: string): Promise<Har
|
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
64
|
|
|
57
|
-
|
|
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> {
|
|
58
79
|
const executable = findHarnessExecutable('claude-code')
|
|
59
80
|
if (!executable) throw new Error('Claude is not installed')
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
+
}
|
|
70
178
|
}
|
|
@@ -112,7 +112,8 @@ export const claudeCodeHarness: Harness = {
|
|
|
112
112
|
const runtime = await pathHarnessAvailability('claude-code')
|
|
113
113
|
return runtime.status === 'available' && ws ? getClaudeAuthReadiness(ws.path) : runtime
|
|
114
114
|
},
|
|
115
|
-
startLogin:
|
|
115
|
+
startLogin: startClaudeLogin,
|
|
116
|
+
authStatus: getClaudeAuthReadiness,
|
|
116
117
|
|
|
117
118
|
onEnvChanged: workspacePath => restartWorkspaceSessions(workspacePath),
|
|
118
119
|
stopWorkspace: workspacePath => killWorkspaceSessions(workspacePath),
|
|
@@ -6,7 +6,7 @@ import { debugEnabled } from '../../debug'
|
|
|
6
6
|
import { requireHarnessExecutable } from '../executable'
|
|
7
7
|
|
|
8
8
|
// MCP server status probing. Intentionally decoupled from agent chat runs
|
|
9
|
-
// (
|
|
9
|
+
// (session.ts): connecting to MCP servers and reading their status is a
|
|
10
10
|
// metadata concern, not part of any conversation. Nothing here submits a user
|
|
11
11
|
// turn, so probing costs zero model tokens.
|
|
12
12
|
//
|
|
@@ -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,10 +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 { hasSessionConfig, saveSessionConfig } from '../../
|
|
31
|
-
import { renameSessionReferences } from '../../
|
|
33
|
+
import { hasSessionConfig, saveSessionConfig } from '../../sessions/config'
|
|
34
|
+
import { renameSessionReferences } from '../../sessions/lifecycle'
|
|
32
35
|
import { claudeCodeSpawn } from '../../agent-launcher'
|
|
33
|
-
import { resolveWorkspaceEnv } from '../../
|
|
36
|
+
import { resolveWorkspaceEnv } from '../../workspaces/env'
|
|
34
37
|
import { requireHarnessExecutable } from '../executable'
|
|
35
38
|
import type { SendMessageInput } from '../types'
|
|
36
39
|
|
|
@@ -395,7 +398,7 @@ function renameSession(s: LiveSession, realId: string): string {
|
|
|
395
398
|
}
|
|
396
399
|
|
|
397
400
|
// Keep the active message reserved across async bookkeeping. Sends arriving
|
|
398
|
-
// here join
|
|
401
|
+
// here join Moi's queue; they cannot race a teardown or change the live model.
|
|
399
402
|
async function onSessionIdle(s: LiveSession) {
|
|
400
403
|
const active = s.messages.active
|
|
401
404
|
if (s.messages.dispatching || (active && !s.turnEnded)) return
|
|
@@ -662,7 +665,7 @@ function createLiveSession(input: {
|
|
|
662
665
|
return session
|
|
663
666
|
}
|
|
664
667
|
|
|
665
|
-
// Accept immediately, but keep the prompt and its settings in
|
|
668
|
+
// Accept immediately, but keep the prompt and its settings in Moi until its
|
|
666
669
|
// turn starts. The returned promise settles when the message reaches the SDK.
|
|
667
670
|
export async function sendCCMessage(input: SendMessageInput): Promise<void> {
|
|
668
671
|
const prepared = prepareAttachmentMessage(input.workspaceId, input.content, input.attachments)
|