moi-computer 0.10.1-next.6 → 0.11.1-dev.1c52199
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 +2 -2
- package/client/AGENTS.md +2 -2
- package/client/api/app-config.ts +2 -1
- package/client/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +33 -27
- package/client/app/shell/SidebarLayout.tsx +18 -15
- package/client/components/shared/BottomPanel.tsx +26 -14
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/shared/ReorderableList.tsx +7 -2
- package/client/components/shared/WorkspaceIcon.tsx +92 -0
- package/client/components/ui/alert-dialog.tsx +1 -0
- package/client/components/ui/button.tsx +1 -53
- package/client/components/ui/checkbox.tsx +1 -0
- package/client/components/ui/collapsible.tsx +1 -15
- package/client/components/ui/dialog.tsx +1 -58
- package/client/components/ui/dropdown-menu.tsx +1 -254
- package/client/components/ui/hover-card.tsx +1 -44
- package/client/components/ui/inline-input.tsx +84 -0
- package/client/components/ui/input.tsx +1 -21
- package/client/components/ui/popover.tsx +1 -88
- package/client/components/ui/resizable.tsx +1 -40
- package/client/components/ui/skeleton.tsx +1 -13
- package/client/components/ui/slider.tsx +1 -70
- package/client/components/ui/spinner.tsx +1 -18
- package/client/components/ui/switch.tsx +1 -23
- package/client/components/ui/tabs.tsx +1 -0
- package/client/components/ui/textarea.tsx +1 -18
- package/client/components/ui/toast.tsx +2 -2
- package/client/components/ui/tooltip.tsx +1 -51
- package/client/features/applets/AppletMount.tsx +5 -2
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +158 -108
- package/client/features/applets/applet-styles.ts +2 -2
- package/client/features/applets/applet-thumbnail.ts +6 -8
- package/client/features/applets/useApplet.ts +10 -9
- package/client/features/chat/ChatPanel.tsx +24 -15
- package/client/features/chat/ChatPopup.tsx +9 -5
- package/client/features/chat/applet-chat-intents.ts +179 -0
- package/client/features/chat/chat-send.ts +116 -64
- package/client/features/chat/chat-store.ts +51 -62
- package/client/features/chat/composer/ChatComposer.tsx +43 -128
- package/client/features/chat/composer/ModelPicker.tsx +47 -60
- package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
- package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
- package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
- package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
- package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
- package/client/features/chat/composer/attachments/types.ts +25 -0
- package/client/features/chat/composer/attachments/uploads.ts +26 -0
- package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
- package/client/features/chat/composer/model-order.ts +15 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
- package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
- package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +10 -8
- package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
- package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
- package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +27 -19
- package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +12 -0
- package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
- package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
- package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
- package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
- package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
- package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
- package/client/features/chat/{api.ts → sessions/api.ts} +5 -14
- package/client/features/chat/sessions/session-view.ts +53 -0
- package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +64 -20
- package/client/features/chat/useChat.ts +46 -24
- package/client/features/collab/DevCollabIdentity.tsx +170 -0
- package/client/features/collab/DevCollabKit.tsx +501 -0
- package/client/features/collab/DevCollabPage.tsx +25 -0
- package/client/features/collab/WorkspaceCollabControls.tsx +313 -0
- package/client/features/collab/client.ts +146 -0
- package/client/features/collab/components.tsx +307 -0
- package/client/features/collab/dev-persona.ts +66 -0
- package/client/features/collab/engine.ts +96 -0
- package/client/features/collab/entry.tsx +35 -0
- package/client/features/collab/facehash-avatar.ts +132 -0
- package/client/features/collab/fake-engine.ts +130 -0
- package/client/features/collab/hooks.tsx +253 -0
- package/client/features/collab/identity.ts +305 -0
- package/client/features/collab/index.ts +45 -0
- package/client/features/collab/people.ts +102 -0
- package/client/features/collab/personal-state.ts +61 -0
- package/client/features/collab/presence-publisher.ts +29 -0
- package/client/features/collab/presence-target.ts +10 -0
- package/client/features/collab/primitives.tsx +398 -0
- package/client/features/collab/proxy-identity.ts +24 -0
- package/client/features/collab/store.ts +156 -0
- package/client/features/dev/ChatStatesPage.tsx +8 -7
- package/client/features/dev/DevIndexPage.tsx +10 -0
- package/client/features/dev/DevRoutes.tsx +16 -1
- package/client/features/dev/HarnessDebugPage.tsx +11 -8
- package/client/features/dev/ToolCallsPage.tsx +1 -1
- package/client/features/dev/UiComponentPreviews.tsx +855 -0
- package/client/features/dev/UiComponentsPage.tsx +60 -0
- package/client/features/dev/chat-states-fixtures.ts +13 -2
- package/client/features/drawings/capture-element.ts +13 -1
- package/client/features/drawings/useChatAnnotation.ts +17 -17
- package/client/features/drawings/useDrawingLayer.ts +7 -9
- package/client/features/drawings/useViewBuilderSketch.ts +18 -15
- package/client/features/home/HomePage.tsx +8 -7
- package/client/features/home/WorkspacePreview.tsx +2 -2
- package/client/features/home/workspace-presentation.tsx +1 -11
- package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
- package/client/features/overview/HiddenPanel.tsx +109 -0
- package/client/features/overview/Overview.tsx +302 -0
- package/client/features/overview/WidgetCanvas.tsx +164 -0
- package/client/features/{widgets → overview}/WidgetFrame.tsx +25 -17
- package/client/features/overview/WorkspaceName.tsx +60 -0
- package/client/features/overview/api.ts +30 -0
- package/client/features/overview/default/ViewsWidget.tsx +252 -0
- package/client/features/overview/default/registry.tsx +36 -0
- package/client/features/{widgets → overview}/grid.ts +36 -0
- package/client/features/overview/useGridReconcile.ts +94 -0
- package/client/features/scratchpad/Scratchpad.tsx +7 -8
- package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
- package/client/features/settings/GeneralSettings.tsx +55 -58
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
- package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
- package/client/features/settings/api.ts +48 -24
- package/client/features/views/ViewBuilder.tsx +5 -4
- package/client/features/views/ViewManager.tsx +28 -22
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +11 -5
- package/client/features/views/useViewBuilderDrafts.ts +23 -21
- package/client/features/views/view-presentation.ts +13 -0
- package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
- package/client/features/workspace/UnavailablePage.tsx +21 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +22 -10
- package/client/features/workspace/WorkspaceScreen.tsx +228 -172
- package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +5 -31
- package/client/features/workspace/layout-save.ts +13 -0
- package/client/features/workspace/moi-context.ts +15 -11
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +173 -101
- package/client/index.css +23 -30
- package/client/index.tsx +4 -3
- package/client/lib/app-icon-registry.ts +2 -0
- package/client/lib/use-latest-ref.ts +11 -0
- package/client/main.tsx +1 -1
- package/client/runtime/useWorkspaceEvents.ts +59 -14
- package/client/theme.css +5 -5
- package/dist/chunk-1ftessc8.js +2 -0
- package/dist/chunk-3802vh2p.js +2 -0
- package/dist/chunk-542a2m9m.js +1 -0
- package/dist/chunk-5745d83v.js +2 -0
- package/dist/chunk-5zxdsjym.js +1 -0
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-7r4z77ry.js +2 -0
- package/dist/chunk-9cm0wjah.js +79 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-cvgdm1hq.js +2 -0
- package/dist/chunk-gptm4jpd.js +546 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-wnmf38ta.js +5 -0
- package/dist/chunk-xaehhr1j.css +1 -0
- package/dist/chunk-xpt063fx.js +1 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +1 -0
- package/lib/applet-selector.ts +24 -0
- package/lib/chat-title.ts +6 -1
- package/lib/collab/colors.ts +24 -0
- package/lib/collab/protocol.ts +83 -0
- package/lib/collab/types.ts +63 -0
- package/lib/default-widgets.ts +32 -0
- package/lib/experimental.ts +14 -0
- package/lib/format.ts +67 -7
- package/lib/message-attachments.ts +40 -0
- package/lib/moi-attachments.ts +204 -0
- package/lib/moi-context.ts +27 -35
- package/lib/navigation.ts +84 -0
- package/lib/themes.ts +6 -6
- package/lib/types.ts +103 -40
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +44 -32
- package/registry.json +656 -0
- package/server/AGENTS.md +2 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +162 -68
- package/server/app-config.ts +127 -34
- package/server/applet-typecheck.ts +100 -0
- package/server/applets/applet-css.ts +55 -0
- package/server/{bundler → applets}/build-applet.ts +21 -240
- package/server/applets/build-worker.ts +178 -0
- package/server/applets/config.ts +226 -0
- package/server/applets/dependencies.ts +206 -0
- package/server/{applets.ts → applets/index.ts} +44 -189
- package/server/applets/runtime/base.ts +4 -0
- package/server/applets/runtime/moi.ts +42 -0
- package/server/applets/runtime/rpc.ts +17 -0
- package/server/applets/view-source.ts +67 -0
- package/server/attachment-message.ts +95 -0
- package/server/chat-selection.ts +23 -0
- package/server/cli-ui-components.ts +28 -33
- package/server/cli.ts +226 -120
- package/server/collab/applet-module.ts +50 -0
- package/server/collab/cloudflare-access.ts +77 -0
- package/server/collab/config.ts +18 -0
- package/server/collab/ipc.ts +10 -0
- package/server/collab/manager.ts +407 -0
- package/server/collab/service.ts +137 -0
- package/server/collab/skill/collab-env.d.ts +92 -0
- package/server/collab/skill/index.ts +59 -0
- package/server/collab/worker.ts +52 -0
- package/server/control.ts +63 -42
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +45 -50
- package/server/harness/acp/NOTES.md +426 -0
- package/server/harness/acp/adapter.ts +7 -21
- package/server/harness/acp/discovery.ts +27 -30
- package/server/harness/acp/model-state.ts +57 -0
- package/server/harness/acp/session.ts +49 -56
- package/server/harness/claude-code/NOTES.md +54 -13
- package/server/harness/claude-code/adapter.ts +8 -25
- package/server/harness/claude-code/cli.ts +40 -0
- package/server/harness/claude-code/index.ts +13 -5
- package/server/harness/claude-code/models.ts +72 -19
- package/server/harness/claude-code/session.ts +447 -343
- package/server/harness/claude-code/sessions.ts +9 -4
- package/server/harness/codex/NOTES.md +222 -350
- package/server/harness/codex/adapter.ts +102 -52
- package/server/harness/codex/auth.ts +1 -3
- package/server/harness/codex/client.ts +169 -249
- package/server/harness/codex/discovery.ts +9 -17
- package/server/harness/codex/index.ts +3 -1
- package/server/harness/codex/pagination.ts +24 -0
- package/server/harness/codex/permissions.ts +32 -8
- package/server/harness/codex/probe.ts +10 -13
- package/server/harness/codex/session.ts +567 -181
- package/server/harness/codex/transport.ts +184 -0
- package/server/harness/debug.ts +1 -1
- package/server/harness/hermes/NOTES.md +19 -1
- package/server/harness/hermes/discovery.ts +20 -0
- package/server/harness/hermes/index.ts +13 -0
- package/server/harness/hermes/models.ts +28 -8
- package/server/harness/openclaw/NOTES.md +1 -1
- package/server/harness/openclaw/adapter.ts +22 -4
- package/server/harness/openclaw/gateway.ts +5 -3
- package/server/harness/openclaw/session.ts +27 -27
- package/server/harness/types.ts +9 -5
- package/server/layout.ts +24 -16
- package/server/moi-scaffold.ts +22 -14
- package/server/navigation-relay.ts +110 -0
- package/server/preview.ts +3 -1
- package/server/registry.ts +71 -41
- package/server/scratchpad-executor.ts +79 -56
- package/server/scratchpad-shape-defaults.ts +82 -0
- package/server/selected-session.ts +24 -4
- package/server/skill-update.ts +5 -3
- package/server/skill-version.ts +4 -7
- package/server/skills-template.ts +60 -9
- package/server/tabs.ts +19 -33
- package/server/tldraw-package.d.ts +4 -0
- package/server/ui-components.ts +101 -434
- package/server/uploads.ts +0 -0
- package/server/view-builders.ts +20 -2
- package/server/views.ts +126 -6
- package/server/web.ts +108 -30
- package/server/widgets.ts +12 -5
- package/server/workspace-config.ts +13 -9
- package/server/workspace-env.ts +3 -2
- package/tsconfig.json +0 -1
- package/ui-components/accordion.tsx +71 -0
- package/ui-components/alert-dialog.tsx +165 -0
- package/ui-components/alert.tsx +68 -0
- package/ui-components/attachment.tsx +195 -0
- package/ui-components/avatar.tsx +91 -0
- package/ui-components/badge.tsx +49 -0
- package/ui-components/button-group.tsx +78 -0
- package/ui-components/button.tsx +55 -0
- package/ui-components/calendar.tsx +180 -0
- package/ui-components/card.tsx +84 -0
- package/ui-components/carousel.tsx +235 -0
- package/ui-components/chart.tsx +338 -0
- package/ui-components/checkbox.tsx +28 -0
- package/ui-components/collapsible.tsx +15 -0
- package/ui-components/combobox.tsx +267 -0
- package/ui-components/context-menu.tsx +244 -0
- package/ui-components/dialog.tsx +138 -0
- package/ui-components/docs/accordion.md +463 -0
- package/ui-components/docs/alert-dialog.md +481 -0
- package/ui-components/docs/alert.md +301 -0
- package/ui-components/docs/attachment.md +689 -0
- package/ui-components/docs/avatar.md +495 -0
- package/ui-components/docs/badge.md +258 -0
- package/ui-components/docs/button-group.md +879 -0
- package/ui-components/docs/button.md +26 -0
- package/ui-components/docs/calendar.md +862 -0
- package/ui-components/docs/card.md +265 -0
- package/ui-components/docs/carousel.md +627 -0
- package/ui-components/docs/chart.md +1256 -0
- package/ui-components/docs/checkbox.md +477 -0
- package/ui-components/docs/collapsible.md +446 -0
- package/ui-components/docs/combobox.md +1003 -0
- package/ui-components/docs/context-menu.md +860 -0
- package/ui-components/docs/data-table.md +1580 -0
- package/ui-components/docs/date-picker.md +614 -0
- package/ui-components/docs/dialog.md +414 -0
- package/ui-components/docs/drawer.md +51 -0
- package/ui-components/docs/dropdown-menu.md +1000 -0
- package/ui-components/docs/field.md +1192 -0
- package/ui-components/docs/hover-card.md +275 -0
- package/ui-components/docs/input-group.md +866 -0
- package/ui-components/docs/input.md +456 -0
- package/ui-components/docs/kbd.md +191 -0
- package/ui-components/docs/label.md +295 -0
- package/ui-components/docs/pagination.md +416 -0
- package/ui-components/docs/popover.md +348 -0
- package/ui-components/docs/progress.md +214 -0
- package/ui-components/docs/radio-group.md +389 -0
- package/ui-components/docs/resizable.md +265 -0
- package/ui-components/docs/select.md +616 -0
- package/ui-components/docs/separator.md +216 -0
- package/ui-components/docs/skeleton.md +205 -0
- package/ui-components/docs/slider.md +226 -0
- package/ui-components/docs/spinner.md +332 -0
- package/ui-components/docs/switch.md +236 -0
- package/ui-components/docs/table.md +551 -0
- package/ui-components/docs/tabs.md +379 -0
- package/ui-components/docs/textarea.md +187 -0
- package/ui-components/docs/toggle-group.md +370 -0
- package/ui-components/docs/toggle.md +91 -0
- package/ui-components/docs/tooltip.md +290 -0
- package/ui-components/drawer.tsx +213 -0
- package/ui-components/dropdown-menu.tsx +263 -0
- package/ui-components/field.tsx +224 -0
- package/ui-components/hover-card.tsx +46 -0
- package/ui-components/input-group.tsx +146 -0
- package/ui-components/input.tsx +20 -0
- package/ui-components/kbd.tsx +32 -0
- package/ui-components/label.tsx +17 -0
- package/ui-components/pagination.tsx +124 -0
- package/ui-components/popover.tsx +81 -0
- package/ui-components/progress.tsx +63 -0
- package/ui-components/radio-group.tsx +38 -0
- package/ui-components/resizable.tsx +40 -0
- package/ui-components/scoped-portal.tsx +31 -0
- package/ui-components/select.tsx +195 -0
- package/ui-components/separator.tsx +18 -0
- package/ui-components/skeleton.tsx +15 -0
- package/ui-components/slider.tsx +75 -0
- package/ui-components/spinner.tsx +20 -0
- package/ui-components/switch.tsx +27 -0
- package/ui-components/table.tsx +86 -0
- package/ui-components/tabs.tsx +75 -0
- package/ui-components/textarea.tsx +17 -0
- package/ui-components/toggle-group.tsx +85 -0
- package/ui-components/toggle.tsx +42 -0
- package/ui-components/tooltip.tsx +61 -0
- package/ui-components/utils.ts +8 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +295 -248
- package/workspace/.claude/skills/moi-workspace/references/COLLABORATIVE.md +151 -0
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -152
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
- package/client/features/chat/attachment-staging.ts +0 -153
- package/client/features/chat/uploads.ts +0 -18
- package/client/features/chat/useAppletChatMessage.ts +0 -68
- package/client/features/settings/IconPicker.tsx +0 -442
- package/client/features/settings/WorkspaceSettings.tsx +0 -92
- package/client/features/settings/render-icon.ts +0 -173
- package/client/features/widgets/HiddenPanel.tsx +0 -80
- package/client/features/widgets/WidgetGrid.tsx +0 -123
- package/client/features/widgets/Widgets.tsx +0 -260
- package/client/features/widgets/useGridReconcile.ts +0 -73
- package/dist/chunk-104m57qw.js +0 -2
- package/dist/chunk-7paadv61.js +0 -1
- package/dist/chunk-bj3akjs2.js +0 -1
- package/dist/chunk-c9pjqx9m.js +0 -14
- package/dist/chunk-j2w2vak4.js +0 -546
- package/dist/chunk-k2r9c95m.js +0 -10
- package/dist/chunk-kmbxhgwv.js +0 -1
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-r8s1b672.css +0 -1
- package/dist/chunk-tny85yt2.js +0 -2
- package/dist/chunk-v7wr1df4.js +0 -2
- package/dist/chunk-vwzshv0d.js +0 -83
- package/server/bundler/applet-css.ts +0 -155
- /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
- /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
- /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
- /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// Newline JSON-RPC only. Workspace/process policy lives in client.ts; keeping
|
|
2
|
+
// framing separate lets tests exercise the same transport with in-memory pipes.
|
|
3
|
+
import { codexServerRequestResponse } from './permissions'
|
|
4
|
+
|
|
5
|
+
export type Json = Record<string, unknown>
|
|
6
|
+
export type NotificationListener = (method: string, params: Json) => void
|
|
7
|
+
|
|
8
|
+
export class CodexRpcError extends Error {
|
|
9
|
+
constructor(
|
|
10
|
+
message: string,
|
|
11
|
+
readonly code: number,
|
|
12
|
+
readonly data?: unknown
|
|
13
|
+
) {
|
|
14
|
+
super(message)
|
|
15
|
+
this.name = 'CodexRpcError'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type CodexTransport = {
|
|
20
|
+
rpc: <T>(method: string, params?: Json) => Promise<T>
|
|
21
|
+
notify: (method: string, params?: Json) => void
|
|
22
|
+
onNotification: (listener: NotificationListener) => () => void
|
|
23
|
+
isAlive: () => boolean
|
|
24
|
+
close: (error?: Error) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type TransportOptions = {
|
|
28
|
+
stdout: ReadableStream<Uint8Array>
|
|
29
|
+
write: (line: string) => void | Promise<void>
|
|
30
|
+
stop: () => void
|
|
31
|
+
tap?: (direction: 'send' | 'recv', frame: Json) => void
|
|
32
|
+
timeoutMs?: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createCodexTransport(options: TransportOptions): CodexTransport {
|
|
36
|
+
let alive = true
|
|
37
|
+
let nextId = 1
|
|
38
|
+
const listeners = new Set<NotificationListener>()
|
|
39
|
+
const pending = new Map<
|
|
40
|
+
number,
|
|
41
|
+
{
|
|
42
|
+
resolve: (value: unknown) => void
|
|
43
|
+
reject: (error: Error) => void
|
|
44
|
+
timer: Timer
|
|
45
|
+
}
|
|
46
|
+
>()
|
|
47
|
+
const reader = options.stdout.getReader()
|
|
48
|
+
|
|
49
|
+
function fanout(method: string, params: Json) {
|
|
50
|
+
for (const listener of listeners) {
|
|
51
|
+
try {
|
|
52
|
+
listener(method, params)
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('[codex] notification listener threw', error)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function close(
|
|
60
|
+
error = new Error('Codex disconnected. Send another message to resume this chat.')
|
|
61
|
+
) {
|
|
62
|
+
if (!alive) return
|
|
63
|
+
alive = false
|
|
64
|
+
for (const request of pending.values()) {
|
|
65
|
+
clearTimeout(request.timer)
|
|
66
|
+
request.reject(error)
|
|
67
|
+
}
|
|
68
|
+
pending.clear()
|
|
69
|
+
fanout('__exit', { message: error.message })
|
|
70
|
+
listeners.clear()
|
|
71
|
+
void reader.cancel().catch(() => {})
|
|
72
|
+
try {
|
|
73
|
+
options.stop()
|
|
74
|
+
} catch {
|
|
75
|
+
/* The process may already have exited. */
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function send(frame: Json) {
|
|
80
|
+
if (!alive) throw new Error('Codex app-server is not running')
|
|
81
|
+
options.tap?.('send', frame)
|
|
82
|
+
// Bun's flush can be asynchronous; observe failures instead of leaving an
|
|
83
|
+
// unhandled rejection and waiting for every RPC to time out independently.
|
|
84
|
+
try {
|
|
85
|
+
const written = options.write(JSON.stringify(frame) + '\n')
|
|
86
|
+
if (written)
|
|
87
|
+
void written.catch(error =>
|
|
88
|
+
close(error instanceof Error ? error : new Error(String(error)))
|
|
89
|
+
)
|
|
90
|
+
} catch (error) {
|
|
91
|
+
close(error instanceof Error ? error : new Error(String(error)))
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function rpc<T>(method: string, params: Json = {}): Promise<T> {
|
|
96
|
+
if (!alive) return Promise.reject(new Error('Codex app-server is not running'))
|
|
97
|
+
const id = nextId++
|
|
98
|
+
return new Promise<T>((resolve, reject) => {
|
|
99
|
+
const timer = setTimeout(() => {
|
|
100
|
+
pending.delete(id)
|
|
101
|
+
reject(new Error(`Codex request timed out: ${method}`))
|
|
102
|
+
}, options.timeoutMs ?? 30_000)
|
|
103
|
+
// Register before writing: a synchronous response must find its waiter.
|
|
104
|
+
pending.set(id, { resolve: resolve as (value: unknown) => void, reject, timer })
|
|
105
|
+
send({ jsonrpc: '2.0', id, method, params })
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function handleLine(line: string) {
|
|
110
|
+
if (!line.trim()) return
|
|
111
|
+
let parsed: unknown
|
|
112
|
+
try {
|
|
113
|
+
parsed = JSON.parse(line)
|
|
114
|
+
} catch {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return
|
|
118
|
+
const msg = parsed as Json
|
|
119
|
+
options.tap?.('recv', msg)
|
|
120
|
+
if (typeof msg.method === 'string') {
|
|
121
|
+
const params =
|
|
122
|
+
msg.params && typeof msg.params === 'object' && !Array.isArray(msg.params)
|
|
123
|
+
? (msg.params as Json)
|
|
124
|
+
: {}
|
|
125
|
+
if ('id' in msg) {
|
|
126
|
+
if (typeof msg.id !== 'string' && typeof msg.id !== 'number') return
|
|
127
|
+
send({ jsonrpc: '2.0', id: msg.id, ...codexServerRequestResponse(msg.method, params) })
|
|
128
|
+
} else fanout(msg.method, params)
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
if (typeof msg.id !== 'number') return
|
|
132
|
+
const request = pending.get(msg.id)
|
|
133
|
+
if (!request) return
|
|
134
|
+
pending.delete(msg.id)
|
|
135
|
+
clearTimeout(request.timer)
|
|
136
|
+
if (msg.error && typeof msg.error === 'object') {
|
|
137
|
+
const error = msg.error as Json
|
|
138
|
+
request.reject(
|
|
139
|
+
new CodexRpcError(
|
|
140
|
+
typeof error.message === 'string' ? error.message : 'Codex request failed',
|
|
141
|
+
typeof error.code === 'number' ? error.code : -32603,
|
|
142
|
+
error.data
|
|
143
|
+
)
|
|
144
|
+
)
|
|
145
|
+
} else request.resolve(msg.result)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
void (async () => {
|
|
149
|
+
const decoder = new TextDecoder()
|
|
150
|
+
let buffer = ''
|
|
151
|
+
try {
|
|
152
|
+
while (alive) {
|
|
153
|
+
const { done, value } = await reader.read()
|
|
154
|
+
if (done) break
|
|
155
|
+
buffer += decoder.decode(value, { stream: true })
|
|
156
|
+
let start = 0
|
|
157
|
+
let end: number
|
|
158
|
+
while ((end = buffer.indexOf('\n', start)) >= 0) {
|
|
159
|
+
handleLine(buffer.slice(start, end))
|
|
160
|
+
start = end + 1
|
|
161
|
+
}
|
|
162
|
+
buffer = buffer.slice(start)
|
|
163
|
+
}
|
|
164
|
+
if (alive) handleLine(buffer + decoder.decode())
|
|
165
|
+
} catch (error) {
|
|
166
|
+
close(error instanceof Error ? error : new Error(String(error)))
|
|
167
|
+
} finally {
|
|
168
|
+
close()
|
|
169
|
+
}
|
|
170
|
+
})()
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
rpc,
|
|
174
|
+
notify: (method, params = {}) => send({ jsonrpc: '2.0', method, params }),
|
|
175
|
+
onNotification(listener) {
|
|
176
|
+
listeners.add(listener)
|
|
177
|
+
return () => {
|
|
178
|
+
listeners.delete(listener)
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
isAlive: () => alive,
|
|
182
|
+
close
|
|
183
|
+
}
|
|
184
|
+
}
|
package/server/harness/debug.ts
CHANGED
|
@@ -182,6 +182,24 @@ what moi's current backends expose — it already carries `cwd`, `git_branch`,
|
|
|
182
182
|
`git_repo_root`, `parent_session_id`, per-session token counts and
|
|
183
183
|
`estimated_cost_usd`/`actual_cost_usd`.
|
|
184
184
|
|
|
185
|
+
#### 3.2.2 The default model rides on `currentModelId`, and the catalog is cached
|
|
186
|
+
|
|
187
|
+
`session/new` also returns `currentModelId` — the model Hermes resolves from
|
|
188
|
+
the profile's `config.yaml` (`model.default` + `model.provider`, rewritten by
|
|
189
|
+
`hermes model`). `./models.ts` maps it onto a synthetic `default` row with
|
|
190
|
+
`resolvedModel`, the same convention the Claude and Codex harnesses use, so
|
|
191
|
+
the picker preselects the model a promptless chat would actually run.
|
|
192
|
+
Verified against v0.20.0 (`xai-oauth:grok-build-0.1`, 67 raw rows).
|
|
193
|
+
|
|
194
|
+
The catalog only ever arrives on `session/new`, and every such call persists a
|
|
195
|
+
zero-message row in `state.db` that `hermes sessions list` shows as a blank
|
|
196
|
+
entry (moi's own list hides them). So the state is cached per workspace
|
|
197
|
+
(`../acp/model-state.ts`): the first picker snapshot opens one throwaway
|
|
198
|
+
session, every real chat start refreshes the cache from its own `session/new`,
|
|
199
|
+
and the cache is stamped with the mtimes of the profile's `config.yaml` and
|
|
200
|
+
`.env` (`hermesConfigFingerprint`) so a default changed outside moi is
|
|
201
|
+
rediscovered on the next snapshot instead of on every one.
|
|
202
|
+
|
|
185
203
|
### 3.3 The prompt stream
|
|
186
204
|
|
|
187
205
|
`session/prompt` streams `session/update` notifications and resolves with
|
|
@@ -564,7 +582,7 @@ precedent: `lib/types.ts` (`WorkspaceType` union), `lib/workspace-types.ts`
|
|
|
564
582
|
(ordering), `lib/format.ts` (`provider` union), `server/harness/registry.ts`,
|
|
565
583
|
`server/harness/executable.ts` (PATH lookup), `server/api.ts`
|
|
566
584
|
(`CREATABLE_TYPES`), and a handful of client files that branch on provider
|
|
567
|
-
(`client/features/chat/tool-group/format.ts`,
|
|
585
|
+
(`client/features/chat/messages/tool-group/format/index.ts`,
|
|
568
586
|
`client/features/home/workspace-setup/WorkspaceAgentStep.tsx`,
|
|
569
587
|
`client/features/dev/HarnessDebugPage.tsx`).
|
|
570
588
|
|
|
@@ -153,3 +153,23 @@ export async function resolveHermesProfile(
|
|
|
153
153
|
}
|
|
154
154
|
return profiles.find(p => p.path === workspacePath) ?? null
|
|
155
155
|
}
|
|
156
|
+
|
|
157
|
+
// Version stamp for the profile inputs that decide its default model:
|
|
158
|
+
// config.yaml (`model.default`, rewritten by `hermes model`) and .env
|
|
159
|
+
// (provider keys, which gate which entries the catalog lists at all). Mtimes,
|
|
160
|
+
// not contents — the ACP session reports the real resolved state, this only
|
|
161
|
+
// says when to ask again. A missing file stamps as such, so creating it later
|
|
162
|
+
// still counts as a change.
|
|
163
|
+
export async function hermesConfigFingerprint(home: string | null): Promise<string | undefined> {
|
|
164
|
+
if (!home) return undefined
|
|
165
|
+
const stamps = await Promise.all(
|
|
166
|
+
['config.yaml', '.env'].map(async file => {
|
|
167
|
+
try {
|
|
168
|
+
return String((await stat(join(home, file))).mtimeMs)
|
|
169
|
+
} catch {
|
|
170
|
+
return 'missing'
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
)
|
|
174
|
+
return stamps.join(' ')
|
|
175
|
+
}
|
|
@@ -26,6 +26,7 @@ import { getAcpProcessInfo, killAcpWorkspace, killAllAcpClients } from '../acp/c
|
|
|
26
26
|
import {
|
|
27
27
|
DEFAULT_PROFILE,
|
|
28
28
|
discoverHermesProfiles,
|
|
29
|
+
hermesConfigFingerprint,
|
|
29
30
|
profileHomeFromWorkspace,
|
|
30
31
|
resolveHermesProfile
|
|
31
32
|
} from './discovery'
|
|
@@ -42,6 +43,14 @@ const config: AcpProviderConfig = {
|
|
|
42
43
|
provider: 'hermes',
|
|
43
44
|
noPromptModeId: NO_PROMPT_MODE,
|
|
44
45
|
mapModels: hermesModels,
|
|
46
|
+
// The profile's default model (`currentModelId` on `session/new`) follows
|
|
47
|
+
// config.yaml, which `hermes model` and hand edits change while moi runs.
|
|
48
|
+
// Stamp the cache with the config mtimes so such a change is picked up on
|
|
49
|
+
// the next snapshot without opening a throwaway session every time.
|
|
50
|
+
modelStateFingerprint: async ctx => {
|
|
51
|
+
const profile = await resolveHermesProfile(ctx.workspacePath, ctx.agentId)
|
|
52
|
+
return hermesConfigFingerprint(profile?.home ?? profileHomeFromWorkspace(ctx.workspacePath))
|
|
53
|
+
},
|
|
45
54
|
supportsImages: true,
|
|
46
55
|
async spawn(ctx) {
|
|
47
56
|
const bin = findHarnessExecutable('hermes')
|
|
@@ -129,6 +138,10 @@ export const hermesHarness: Harness = {
|
|
|
129
138
|
forgetAcpWorkspaceSessions(workspacePath)
|
|
130
139
|
killAcpWorkspace(workspacePath)
|
|
131
140
|
},
|
|
141
|
+
stopWorkspace: workspacePath => {
|
|
142
|
+
forgetAcpWorkspaceSessions(workspacePath)
|
|
143
|
+
killAcpWorkspace(workspacePath)
|
|
144
|
+
},
|
|
132
145
|
shutdown: () => {
|
|
133
146
|
forgetAllAcpSessions()
|
|
134
147
|
killAllAcpClients()
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
// in `description` alone, which is why the group comes from that field.
|
|
16
16
|
import type { Model } from '@/lib/types'
|
|
17
17
|
|
|
18
|
-
import type { AcpModelInfo } from '../acp/wire'
|
|
18
|
+
import type { AcpModelInfo, AcpModelState } from '../acp/wire'
|
|
19
19
|
|
|
20
20
|
const PROVIDER_PREFIX = /^Provider:\s*/
|
|
21
|
-
//
|
|
21
|
+
// This is display cleanup only. The default comes from structured
|
|
22
|
+
// `currentModelId`, never by inferring it from this suffix.
|
|
22
23
|
const CURRENT_SUFFIX = /\s*•\s*current$/
|
|
23
24
|
|
|
24
25
|
function providerOf(description: string | undefined): string | undefined {
|
|
@@ -65,15 +66,34 @@ function hermesModel(info: AcpModelInfo): Model {
|
|
|
65
66
|
// — for the same endpoint and model. Both spellings work, so keep the first
|
|
66
67
|
// and drop rows the picker would render as an exact duplicate. Keyed on
|
|
67
68
|
// `providerId` where there is one, since both spellings normalize to it.
|
|
68
|
-
export function hermesModels(
|
|
69
|
-
const seen = new
|
|
69
|
+
export function hermesModels(state: AcpModelState): Model[] {
|
|
70
|
+
const seen = new Map<string, number>()
|
|
70
71
|
const out: Model[] = []
|
|
71
|
-
for (const info of
|
|
72
|
+
for (const info of state.availableModels ?? []) {
|
|
72
73
|
const model = hermesModel(info)
|
|
73
74
|
const key = `${model.providerId ?? model.group ?? ''} ${model.displayName}`
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
const existingIndex = seen.get(key)
|
|
76
|
+
if (existingIndex !== undefined) {
|
|
77
|
+
// If Hermes names a duplicate spelling as current, retain that exact id
|
|
78
|
+
// so the structured default can resolve to a visible picker row.
|
|
79
|
+
if (info.modelId === state.currentModelId) out[existingIndex] = model
|
|
80
|
+
continue
|
|
81
|
+
}
|
|
82
|
+
seen.set(key, out.length)
|
|
76
83
|
out.push(model)
|
|
77
84
|
}
|
|
78
|
-
|
|
85
|
+
|
|
86
|
+
if (!state.currentModelId) return out
|
|
87
|
+
const currentIndex = out.findIndex(model => model.value === state.currentModelId)
|
|
88
|
+
if (currentIndex === -1) return out
|
|
89
|
+
|
|
90
|
+
out[currentIndex] = { ...out[currentIndex], resolvedModel: state.currentModelId }
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
value: 'default',
|
|
94
|
+
resolvedModel: state.currentModelId,
|
|
95
|
+
displayName: 'Default (from Hermes)'
|
|
96
|
+
},
|
|
97
|
+
...out
|
|
98
|
+
]
|
|
79
99
|
}
|
|
@@ -570,7 +570,7 @@ So there is no Read card on a codex-backed run: the model reads by shelling out
|
|
|
570
570
|
records. Nothing is being dropped.
|
|
571
571
|
|
|
572
572
|
The client's tool-card labels and briefs live in
|
|
573
|
-
`client/features/chat/tool-group/format.ts`; the OpenClaw path falls back to the
|
|
573
|
+
`client/features/chat/messages/tool-group/format/index.ts`; the OpenClaw path falls back to the
|
|
574
574
|
Claude Code vocabulary for the `claude-cli` case.
|
|
575
575
|
|
|
576
576
|
**`agent`/`item` frames are not a second source of tool cards.** They carry
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
//
|
|
9
9
|
// `toStreamEvents` is the cold path (REST replay); `messageToTurn` is the
|
|
10
10
|
// per-frame path the live session uses.
|
|
11
|
+
import { replayAttachmentParts, stripAttachmentsLoose } from '@/lib/moi-attachments'
|
|
11
12
|
import type { Part, StreamEvent, ToolCall, ToolState, Turn, TurnMeta } from '@/lib/format'
|
|
12
13
|
import type { SessionInfo } from '@/lib/types'
|
|
13
14
|
|
|
@@ -28,7 +29,9 @@ import { stripSubagentEnvelope, stripUserMessageMetadata } from './strip'
|
|
|
28
29
|
// every title source, not just the preview, so no title shows the envelope.
|
|
29
30
|
// A no-op on channel/cron labels that never contain it.
|
|
30
31
|
function cleanTitle(text: string | undefined): string {
|
|
31
|
-
return stripSubagentEnvelope(
|
|
32
|
+
return stripSubagentEnvelope(
|
|
33
|
+
stripAttachmentsLoose(stripMoiContextLoose(text?.trim() ?? ''))
|
|
34
|
+
).trim()
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
export function toSessionInfo(row: OpenClawSessionRow, cwd: string): SessionInfo {
|
|
@@ -36,7 +39,9 @@ export function toSessionInfo(row: OpenClawSessionRow, cwd: string): SessionInfo
|
|
|
36
39
|
cleanTitle(row.label) ||
|
|
37
40
|
cleanTitle(row.displayName) ||
|
|
38
41
|
cleanTitle(row.derivedTitle) ||
|
|
39
|
-
formatChatTitle(
|
|
42
|
+
formatChatTitle(
|
|
43
|
+
stripSubagentEnvelope(stripMoiContextLoose(row.lastMessagePreview?.trim() ?? ''))
|
|
44
|
+
) ||
|
|
40
45
|
''
|
|
41
46
|
// External channel provenance. 'webchat' is moi's own chat surface — only
|
|
42
47
|
// real external channels (telegram/irc/discord/…) get an origin badge.
|
|
@@ -224,9 +229,22 @@ export function messageToTurn(
|
|
|
224
229
|
: typeof msg.content === 'string'
|
|
225
230
|
? [{ type: 'text', text: msg.content }]
|
|
226
231
|
: []
|
|
227
|
-
const
|
|
228
|
-
.
|
|
232
|
+
const rawParts = blocks
|
|
233
|
+
.flatMap(b => {
|
|
234
|
+
if (msg.role === 'user' && b.type === 'text' && typeof b.text === 'string') {
|
|
235
|
+
return [
|
|
236
|
+
blockToPart(
|
|
237
|
+
{ ...b, text: stripUserMessageMetadata(b.text) },
|
|
238
|
+
msg.role,
|
|
239
|
+
results,
|
|
240
|
+
omitToolCallIds
|
|
241
|
+
)
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
return [blockToPart(b, msg.role, results, omitToolCallIds)]
|
|
245
|
+
})
|
|
229
246
|
.filter((p): p is Part => p !== null)
|
|
247
|
+
const parts = msg.role === 'user' ? replayAttachmentParts(rawParts) : rawParts
|
|
230
248
|
if (parts.length === 0) return null
|
|
231
249
|
const ocId = msg.__openclaw?.id
|
|
232
250
|
const seq = msg.__openclaw?.seq
|
|
@@ -17,6 +17,8 @@ import { readFile } from 'node:fs/promises'
|
|
|
17
17
|
import { homedir } from 'node:os'
|
|
18
18
|
import { join } from 'node:path'
|
|
19
19
|
|
|
20
|
+
import type { GatewayClient as OpenClawGatewayClient } from 'openclaw/plugin-sdk/gateway-runtime'
|
|
21
|
+
|
|
20
22
|
import { type GatewayFailure, type GatewayInfo, classifyGatewayError, parseHelloOk } from './compat'
|
|
21
23
|
import { tapWire } from '../debug'
|
|
22
24
|
|
|
@@ -41,7 +43,7 @@ export function getOpenClawGatewayStatus(): {
|
|
|
41
43
|
return { connected: current !== null, info: lastInfo, failure: lastFailure }
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
type ClientCtor = typeof
|
|
46
|
+
type ClientCtor = typeof OpenClawGatewayClient
|
|
45
47
|
type GatewayInstance = InstanceType<ClientCtor>
|
|
46
48
|
|
|
47
49
|
const CONNECT_TIMEOUT_MS = 5_000
|
|
@@ -238,7 +240,7 @@ function fanout(event: string, payload: Record<string, unknown>) {
|
|
|
238
240
|
async function startClient(): Promise<{ handle: GatewayHandle; client: GatewayInstance }> {
|
|
239
241
|
const cfg = await readGatewayConfig()
|
|
240
242
|
if (!cfg) throw new Error('openclaw config missing or invalid')
|
|
241
|
-
let GatewayClient:
|
|
243
|
+
let GatewayClient: ClientCtor
|
|
242
244
|
try {
|
|
243
245
|
;({ GatewayClient } = await import('openclaw/plugin-sdk/gateway-runtime'))
|
|
244
246
|
} catch {
|
|
@@ -415,7 +417,7 @@ export async function withOneShotGateway<T>(fn: (rpc: Rpc) => Promise<T>): Promi
|
|
|
415
417
|
if (!cfg) return null
|
|
416
418
|
// `openclaw` is an optionalDependency — a missing package must degrade to
|
|
417
419
|
// the silent-null path (no agents discovered), never a rejected promise.
|
|
418
|
-
let GatewayClient:
|
|
420
|
+
let GatewayClient: ClientCtor
|
|
419
421
|
try {
|
|
420
422
|
;({ GatewayClient } = await import('openclaw/plugin-sdk/gateway-runtime'))
|
|
421
423
|
} catch {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MessageAttachment } from '@/lib/types'
|
|
1
2
|
// Per-(workspaceId, sessionId) live OpenClaw session.
|
|
2
3
|
//
|
|
3
4
|
// Holds the in-memory view for one session and keeps it current from the
|
|
@@ -10,13 +11,9 @@
|
|
|
10
11
|
// The frame families and the order they arrive in are documented in NOTES.md
|
|
11
12
|
// §6; the rules that follow from it (who owns a tool card, why identity is
|
|
12
13
|
// decided once) are worth reading before changing anything here.
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
appendMoiContext,
|
|
17
|
-
renderMoiContext,
|
|
18
|
-
stripMoiContext
|
|
19
|
-
} from '@/lib/moi-context'
|
|
14
|
+
import { replayAttachmentParts } from '@/lib/moi-attachments'
|
|
15
|
+
import { materializeAttachmentPaths, prepareAttachmentMessage } from '../../attachment-message'
|
|
16
|
+
import { type MoiContext, appendMoiContext, renderMoiContext } from '@/lib/moi-context'
|
|
20
17
|
import {
|
|
21
18
|
type PreviewBlock,
|
|
22
19
|
type ToolCall,
|
|
@@ -25,7 +22,7 @@ import {
|
|
|
25
22
|
applyEvent,
|
|
26
23
|
emptyViewState
|
|
27
24
|
} from '@/lib/format'
|
|
28
|
-
import type { SessionActivity, StreamEvent, ViewState } from '@/lib/types'
|
|
25
|
+
import type { Part, SessionActivity, StreamEvent, ViewState } from '@/lib/types'
|
|
29
26
|
|
|
30
27
|
import { messageIdempotencyKey } from './compat'
|
|
31
28
|
|
|
@@ -50,7 +47,6 @@ import {
|
|
|
50
47
|
} from './gateway'
|
|
51
48
|
import { recordOpenClawThinkingProfile, recordOpenClawThinkingRejection } from './thinking'
|
|
52
49
|
import { broadcast } from '../../state'
|
|
53
|
-
import { materializeToPath, resolveUploads } from '../../uploads'
|
|
54
50
|
import {
|
|
55
51
|
markViewBuilderBuildingBySession,
|
|
56
52
|
markViewBuilderWaitingBySession,
|
|
@@ -490,7 +486,19 @@ function previewMessageId(sessionKey: string, runId: string): string {
|
|
|
490
486
|
// between what we sent and what the gateway stored can't defeat the match.
|
|
491
487
|
export function normalizeEchoText(text: string | undefined): string {
|
|
492
488
|
if (typeof text !== 'string') return ''
|
|
493
|
-
return
|
|
489
|
+
return userEchoKey(replayAttachmentParts([{ type: 'text', text }]))
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export function userEchoKey(parts: readonly Part[]): string {
|
|
493
|
+
const text = parts
|
|
494
|
+
.filter(p => p.type === 'text')
|
|
495
|
+
.map(p => p.text)
|
|
496
|
+
.join('\n')
|
|
497
|
+
const visible = text.replace(/\s+/g, ' ').trim()
|
|
498
|
+
const attachments = parts.filter(
|
|
499
|
+
p => p.type === 'text-attachment' || p.type === 'file-attachment'
|
|
500
|
+
)
|
|
501
|
+
return attachments.length ? `${visible}\n${JSON.stringify(attachments)}` : visible
|
|
494
502
|
}
|
|
495
503
|
|
|
496
504
|
// Synthetic turns (live tool cards, live thinking spans) have no transcript
|
|
@@ -526,7 +534,7 @@ function emitTurn(rec: SessionRecord, msg: OpenClawMessage, idx: number): void {
|
|
|
526
534
|
)
|
|
527
535
|
: -1
|
|
528
536
|
if (at < 0) {
|
|
529
|
-
const text =
|
|
537
|
+
const text = userEchoKey(turn.parts)
|
|
530
538
|
if (text) at = rec.pendingUserEchoes.findIndex(e => normalizeEchoText(e.text) === text)
|
|
531
539
|
}
|
|
532
540
|
if (at >= 0) {
|
|
@@ -1216,7 +1224,7 @@ export async function sendOpenClawMessage(input: {
|
|
|
1216
1224
|
// message, so we materialize each upload to a temp file and append the paths
|
|
1217
1225
|
// for the agent to read. Rich vision blocks await a gateway content-block API
|
|
1218
1226
|
// (see dev/file-uploads.md).
|
|
1219
|
-
attachments?:
|
|
1227
|
+
attachments?: MessageAttachment[]
|
|
1220
1228
|
optimisticId?: string
|
|
1221
1229
|
// Picker selections, applied to the gateway session via `sessions.patch`
|
|
1222
1230
|
// before the send (see applySessionSettings).
|
|
@@ -1229,21 +1237,13 @@ export async function sendOpenClawMessage(input: {
|
|
|
1229
1237
|
// rendezvous keeps matching on the user's text.
|
|
1230
1238
|
context?: MoiContext
|
|
1231
1239
|
}): Promise<void> {
|
|
1232
|
-
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
for (const u of uploads) {
|
|
1240
|
-
const p = await materializeToPath(u)
|
|
1241
|
-
if (p) files.push({ filename: u.filename, path: p })
|
|
1242
|
-
}
|
|
1243
|
-
content = appendAttachmentNote(input.content, files)
|
|
1244
|
-
}
|
|
1245
|
-
// Attachment-only send whose ids all expired → nothing to say; don't open a
|
|
1246
|
-
// session for an empty message.
|
|
1240
|
+
await materializeAttachmentPaths(input.workspaceId, input.attachments)
|
|
1241
|
+
const { text: content } = prepareAttachmentMessage(
|
|
1242
|
+
input.workspaceId,
|
|
1243
|
+
input.content,
|
|
1244
|
+
input.attachments,
|
|
1245
|
+
false
|
|
1246
|
+
)
|
|
1247
1247
|
if (!content) return
|
|
1248
1248
|
return sendOpenClawMessageImpl({ ...input, content })
|
|
1249
1249
|
}
|
package/server/harness/types.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// by moi. See README.md in this folder for the full checklist and the
|
|
3
3
|
// message-type layers; each harness's index.ts exports one Harness object
|
|
4
4
|
// wrapping its session/adapter/transport modules.
|
|
5
|
+
import type { MessageAttachment } from '@/lib/types'
|
|
5
6
|
import type { MoiContext } from '@/lib/moi-context'
|
|
6
7
|
import type {
|
|
7
8
|
HarnessAvailability,
|
|
@@ -26,9 +27,8 @@ export type SendMessageInput = {
|
|
|
26
27
|
sessionId: string
|
|
27
28
|
isNew: boolean
|
|
28
29
|
content: string
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
attachments?: string[]
|
|
30
|
+
// Uploaded files and drawings, or structured context from applets.
|
|
31
|
+
attachments?: MessageAttachment[]
|
|
32
32
|
optimisticId?: string
|
|
33
33
|
model?: string
|
|
34
34
|
effort?: string
|
|
@@ -72,6 +72,8 @@ export type DiscoveredWorkspaceCandidate = {
|
|
|
72
72
|
type: WorkspaceType
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
export type HarnessWorkspace = Pick<WorkspaceEntry, 'id' | 'path' | 'type' | 'agentId'>
|
|
76
|
+
|
|
75
77
|
export type Harness = {
|
|
76
78
|
id: WorkspaceType
|
|
77
79
|
capabilities: HarnessCapabilities
|
|
@@ -104,14 +106,16 @@ export type Harness = {
|
|
|
104
106
|
discoverWorkspaces?(registeredPaths: Set<string>): Promise<DiscoveredWorkspaceCandidate[]>
|
|
105
107
|
// Without a workspace, only check whether the runtime is installed. With a
|
|
106
108
|
// workspace, also check provider state such as authentication.
|
|
107
|
-
availability?(ws?:
|
|
109
|
+
availability?(ws?: HarnessWorkspace): Promise<HarnessAvailability>
|
|
108
110
|
// Optional recovery flow the host can start without a terminal.
|
|
109
|
-
startLogin?(ws:
|
|
111
|
+
startLogin?(ws: HarnessWorkspace): Promise<HarnessLogin>
|
|
110
112
|
|
|
111
113
|
// -- host integration hooks -------------------------------------------------
|
|
112
114
|
// Env is frozen at spawn everywhere; this reaps idle sessions/processes so
|
|
113
115
|
// the next message picks up fresh env.
|
|
114
116
|
onEnvChanged?(workspacePath: string): void
|
|
117
|
+
// Workspace removal: stop every child process owned by that workspace.
|
|
118
|
+
stopWorkspace?(workspacePath: string): void
|
|
115
119
|
// Server shutdown: kill child processes so nothing is orphaned.
|
|
116
120
|
shutdown?(): void
|
|
117
121
|
// Where this backend loads workspace skills from (workspace provisioning).
|
package/server/layout.ts
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { join } from 'path'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type {
|
|
4
|
+
AppletKind,
|
|
5
|
+
WorkspaceLayout,
|
|
6
|
+
WorkspaceLayoutSave,
|
|
7
|
+
WorkspacePreview
|
|
8
|
+
} from '@/lib/types'
|
|
9
|
+
import { createDefaultWorkspaceLayout, normalizeWorkspaceTabs } from '@/lib/workspace-layout'
|
|
10
|
+
import { isWorkspaceIcon } from '@/lib/workspace-icon'
|
|
6
11
|
|
|
7
12
|
import { getCapturedThumbnails } from './thumbnails'
|
|
8
13
|
|
|
9
|
-
function normalizeTabs(value: unknown): WorkspaceLayout['tabs'] {
|
|
10
|
-
if (!value || typeof value !== 'object') return createDefaultWorkspaceTabs()
|
|
11
|
-
const raw = value as Record<string, unknown>
|
|
12
|
-
const open = Array.isArray(raw.open)
|
|
13
|
-
? raw.open.filter(isWorkspaceTabId).filter((tab, index, all) => all.indexOf(tab) === index)
|
|
14
|
-
: []
|
|
15
|
-
if (open.length === 0) return createDefaultWorkspaceTabs()
|
|
16
|
-
const active = isWorkspaceTabId(raw.active) && open.includes(raw.active) ? raw.active : open[0]
|
|
17
|
-
return { open, active }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
14
|
function normalizeLayout(parsed: Record<string, unknown>): WorkspaceLayout {
|
|
21
15
|
const defaults = createDefaultWorkspaceLayout()
|
|
22
16
|
const layout = { ...defaults, ...parsed } as Record<string, unknown>
|
|
23
17
|
if (layout.layoutMode !== 'split' && layout.layoutMode !== 'fullscreen') {
|
|
24
18
|
layout.layoutMode = defaults.layoutMode
|
|
25
19
|
}
|
|
26
|
-
layout.tabs =
|
|
20
|
+
layout.tabs = normalizeWorkspaceTabs(layout.tabs)
|
|
21
|
+
delete layout.experimental
|
|
22
|
+
delete layout.collab
|
|
23
|
+
delete layout.collabReference
|
|
24
|
+
if (typeof layout.icon === 'string') {
|
|
25
|
+
layout.icon = { type: 'upload', value: layout.icon }
|
|
26
|
+
} else if (layout.icon !== undefined && !isWorkspaceIcon(layout.icon)) {
|
|
27
|
+
delete layout.icon
|
|
28
|
+
}
|
|
27
29
|
// Legacy thumbnail caches are intentionally dropped, not migrated — images
|
|
28
30
|
// now live as files under `.moi/.cache/thumbnails` (server/thumbnails.ts)
|
|
29
31
|
// and applets are simply captured again there.
|
|
@@ -65,14 +67,20 @@ export async function saveLayout(layout: WorkspaceLayout, workspacePath: string)
|
|
|
65
67
|
// as `name: undefined`.
|
|
66
68
|
export function mergeLayoutForSave(
|
|
67
69
|
existing: WorkspaceLayout,
|
|
68
|
-
body:
|
|
70
|
+
body: WorkspaceLayoutSave
|
|
69
71
|
): WorkspaceLayout {
|
|
70
72
|
const { name: _name, icon: _icon, ...editor } = body
|
|
73
|
+
delete (editor as Record<string, unknown>).experimental
|
|
74
|
+
delete (editor as Record<string, unknown>).collab
|
|
75
|
+
delete (editor as Record<string, unknown>).collabReference
|
|
71
76
|
// Stale clients may still round-trip the pre-`.cache` thumbnail records;
|
|
72
77
|
// never let a layout PUT resurrect them in `.workspace.json`.
|
|
73
78
|
delete (editor as Record<string, unknown>).appletThumbnails
|
|
74
79
|
return {
|
|
75
80
|
...editor,
|
|
81
|
+
// Personal navigation never writes tabs. Other layout edits must not
|
|
82
|
+
// round-trip a stale copy of the workspace's authored defaults.
|
|
83
|
+
tabs: editor.tabs === undefined ? existing.tabs : normalizeWorkspaceTabs(editor.tabs),
|
|
76
84
|
...(existing.name !== undefined && { name: existing.name }),
|
|
77
85
|
...(existing.icon !== undefined && { icon: existing.icon })
|
|
78
86
|
}
|