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
package/lib/moi-context.ts
CHANGED
|
@@ -39,27 +39,25 @@ const SYSTEM_REMINDER_CLOSE = '</system-reminder>'
|
|
|
39
39
|
// claim to be another one.
|
|
40
40
|
export type MoiAppletMessage = {
|
|
41
41
|
source: string
|
|
42
|
-
// The structured payload the applet attached to the call. JSON-plain, and
|
|
43
|
-
// dropped entirely when it doesn't survive serialization.
|
|
44
|
-
context?: Record<string, unknown>
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
// The structured form built at send time — by the client for chat sends, by
|
|
48
45
|
// the server for programmatic sends (the view builder). Extend this (and
|
|
49
46
|
// `renderMoiContext`) when new ambient fields land.
|
|
50
47
|
export type MoiContext = {
|
|
48
|
+
collabReference?: string
|
|
51
49
|
// The workspace tab the user is on when they hit send — for a view-builder
|
|
52
|
-
// request that's the builder's own tab (`view-
|
|
50
|
+
// request that's the builder's own tab (`view-builders/<id>`).
|
|
53
51
|
activeTab: WorkspaceTabId
|
|
54
52
|
// UI label of the active tab when it differs from the id — a view's
|
|
55
|
-
// configured title (e.g. "Grading review" for `
|
|
53
|
+
// configured title (e.g. "Grading review" for `views/color-studio`), or a
|
|
56
54
|
// view builder's claimed title while the build runs. The tab bar falls
|
|
57
55
|
// back to the id when unset; so does the envelope.
|
|
58
56
|
tabTitle?: string
|
|
59
57
|
// The params the active view is rendering with right now, straight from
|
|
60
|
-
//
|
|
58
|
+
// URL query strings. The emitter side of the same contract (`navigate`) sets
|
|
61
59
|
// them, so the agent sees a view's addressable state in both directions.
|
|
62
|
-
// Absent for tabs that take no params (
|
|
60
|
+
// Absent for tabs that take no params (overview, scratchpad, agent).
|
|
63
61
|
tabParams?: Record<string, unknown>
|
|
64
62
|
// Set when this message came from applet UI instead of the composer.
|
|
65
63
|
applet?: MoiAppletMessage
|
|
@@ -68,14 +66,10 @@ export type MoiContext = {
|
|
|
68
66
|
directives?: string[]
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
// Cap on
|
|
72
|
-
|
|
73
|
-
// boundary rather than letting it ride the wire — the renderer's truncation is
|
|
74
|
-
// the backstop for anything that still gets through (e.g. a server-built
|
|
75
|
-
// context).
|
|
76
|
-
export const MAX_APPLET_CONTEXT_CHARS = 2000
|
|
69
|
+
// Cap on ambient view params rendered into the workspace envelope.
|
|
70
|
+
const MAX_TAB_PARAMS_CHARS = 2000
|
|
77
71
|
|
|
78
|
-
// Applet-authored strings (view titles, applet names,
|
|
72
|
+
// Applet-authored strings (view titles, applet names, view params) get
|
|
79
73
|
// interpolated into the envelope, and applet code is agent-authored — a
|
|
80
74
|
// crafted value containing `</moi-context>` would otherwise close the envelope
|
|
81
75
|
// early and forge sections the host never wrote. Escaping `<` defuses every
|
|
@@ -88,7 +82,7 @@ function escapeTags(text: string): string {
|
|
|
88
82
|
// Render an applet-authored record for the envelope, or null when there's
|
|
89
83
|
// nothing worth printing. Non-serializable values (cycles, BigInt) drop rather
|
|
90
84
|
// than throw mid-send.
|
|
91
|
-
function
|
|
85
|
+
function renderTabParams(value: Record<string, unknown>): string | null {
|
|
92
86
|
let json: string
|
|
93
87
|
try {
|
|
94
88
|
json = JSON.stringify(value)
|
|
@@ -97,8 +91,8 @@ function renderAppletJson(value: Record<string, unknown>): string | null {
|
|
|
97
91
|
}
|
|
98
92
|
if (!json || json === '{}') return null
|
|
99
93
|
const capped =
|
|
100
|
-
json.length >
|
|
101
|
-
? `${json.slice(0,
|
|
94
|
+
json.length > MAX_TAB_PARAMS_CHARS
|
|
95
|
+
? `${json.slice(0, MAX_TAB_PARAMS_CHARS)}… (truncated)`
|
|
102
96
|
: json
|
|
103
97
|
return escapeTags(capped)
|
|
104
98
|
}
|
|
@@ -128,16 +122,16 @@ function describeTab(tab: WorkspaceTabId, rawTitle?: string): string {
|
|
|
128
122
|
// other applet-authored string in here.
|
|
129
123
|
const title = rawTitle === undefined ? undefined : escapeTags(rawTitle)
|
|
130
124
|
if (tab === 'agent') return 'The user is on the "Agent" tab (full page chat).'
|
|
131
|
-
if (tab === '
|
|
125
|
+
if (tab === 'overview') return 'The user is on the "Overview" tab.'
|
|
132
126
|
if (tab === 'scratchpad') return 'The user is on the "Scratchpad" tab.'
|
|
133
|
-
if (tab.startsWith('view-
|
|
134
|
-
const id = tab.slice('view-
|
|
127
|
+
if (tab.startsWith('view-builders/')) {
|
|
128
|
+
const id = tab.slice('view-builders/'.length)
|
|
135
129
|
return title
|
|
136
130
|
? `The user is building a new view "${title}". Builder id "${id}".`
|
|
137
131
|
: `The user is building a new view. Builder id "${id}".`
|
|
138
132
|
}
|
|
139
|
-
if (tab.startsWith('
|
|
140
|
-
const id = tab.slice('
|
|
133
|
+
if (tab.startsWith('views/')) {
|
|
134
|
+
const id = tab.slice('views/'.length)
|
|
141
135
|
return `The user is on the "${title ?? id}" view tab (.moi/views/${id}.tsx).`
|
|
142
136
|
}
|
|
143
137
|
return `The user is on the "${tab}" tab.`
|
|
@@ -155,16 +149,17 @@ export function renderMoiContextBody(ctx: MoiContext): string {
|
|
|
155
149
|
'Read the **`moi-workspace` skill** before responding — even to a simple question — unless you already read it in this chat.'
|
|
156
150
|
].join('\n')
|
|
157
151
|
const tabLines = [describeTab(ctx.activeTab, ctx.tabTitle)]
|
|
158
|
-
const tabParams = ctx.tabParams ?
|
|
152
|
+
const tabParams = ctx.tabParams ? renderTabParams(ctx.tabParams) : null
|
|
159
153
|
if (tabParams) tabLines.push(`Params it is rendering with right now: ${tabParams}`)
|
|
160
154
|
const sections = [`# Active tab\n${tabLines.join('\n')}`]
|
|
155
|
+
if (ctx.collabReference)
|
|
156
|
+
sections.push(
|
|
157
|
+
`# Collab\nThe collab runtime is available. Before writing collaborative applets, read ${escapeTags(ctx.collabReference)}.`
|
|
158
|
+
)
|
|
161
159
|
if (ctx.applet) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const context = ctx.applet.context ? renderAppletJson(ctx.applet.context) : null
|
|
166
|
-
if (context) appletLines.push(`It attached this context: ${context}`)
|
|
167
|
-
sections.push(`# Applet message\n${appletLines.join('\n')}`)
|
|
160
|
+
sections.push(
|
|
161
|
+
`# Applet message\nThe message above was not typed by the user — the ${describeAppletSource(ctx.applet.source)} sent it when the user acted in its UI.`
|
|
162
|
+
)
|
|
168
163
|
}
|
|
169
164
|
if (ctx.directives?.length) {
|
|
170
165
|
sections.push(`# This message only\n${ctx.directives.join('\n')}`)
|
|
@@ -184,6 +179,7 @@ export function renderMoiContext(ctx: MoiContext): string {
|
|
|
184
179
|
export function isMoiContext(value: unknown): value is MoiContext {
|
|
185
180
|
if (typeof value !== 'object' || value === null) return false
|
|
186
181
|
const v = value as {
|
|
182
|
+
collabReference?: unknown
|
|
187
183
|
activeTab?: unknown
|
|
188
184
|
tabTitle?: unknown
|
|
189
185
|
tabParams?: unknown
|
|
@@ -192,6 +188,7 @@ export function isMoiContext(value: unknown): value is MoiContext {
|
|
|
192
188
|
}
|
|
193
189
|
return (
|
|
194
190
|
typeof v.activeTab === 'string' &&
|
|
191
|
+
(v.collabReference === undefined || typeof v.collabReference === 'string') &&
|
|
195
192
|
(v.tabTitle === undefined || typeof v.tabTitle === 'string') &&
|
|
196
193
|
(v.tabParams === undefined || isParamsRecord(v.tabParams)) &&
|
|
197
194
|
(v.applet === undefined || isMoiAppletMessage(v.applet)) &&
|
|
@@ -202,12 +199,7 @@ export function isMoiContext(value: unknown): value is MoiContext {
|
|
|
202
199
|
|
|
203
200
|
function isMoiAppletMessage(value: unknown): value is MoiAppletMessage {
|
|
204
201
|
if (!isParamsRecord(value)) return false
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
typeof v.source === 'string' &&
|
|
208
|
-
v.source.length > 0 &&
|
|
209
|
-
(v.context === undefined || isParamsRecord(v.context))
|
|
210
|
-
)
|
|
202
|
+
return typeof value.source === 'string' && value.source.length > 0
|
|
211
203
|
}
|
|
212
204
|
|
|
213
205
|
// Claude Code: the envelope rides as its OWN text block wrapped in
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { WorkspaceTabId } from './types'
|
|
2
|
+
import { isWorkspaceTabId } from './workspace-tabs'
|
|
3
|
+
|
|
4
|
+
export type ViewParams = Record<string, string>
|
|
5
|
+
export type WorkspaceAddress = { tab: WorkspaceTabId; search: string }
|
|
6
|
+
|
|
7
|
+
// Public destinations deliberately exclude the current singleton chat and
|
|
8
|
+
// transient builders.
|
|
9
|
+
export function parseMoiHref(href: unknown): WorkspaceAddress {
|
|
10
|
+
if (typeof href !== 'string' || !href.startsWith('moi:/') || href.startsWith('moi://')) {
|
|
11
|
+
throw new Error('Expected a workspace address such as moi:/views/events?eventId=123')
|
|
12
|
+
}
|
|
13
|
+
const path = href.slice(5).split(/[?#]/, 1)[0]
|
|
14
|
+
if (href.includes('#') || /[\s\\]/.test(path)) throw new Error('Invalid workspace address')
|
|
15
|
+
const tab = tabFromPath(path)
|
|
16
|
+
if (!tab || tab === 'agent' || tab.startsWith('view-builders/')) {
|
|
17
|
+
throw new Error(`Unsupported workspace destination: ${path}`)
|
|
18
|
+
}
|
|
19
|
+
const query = href.indexOf('?')
|
|
20
|
+
const search = query < 0 ? '' : canonicalSearch(href.slice(query + 1))
|
|
21
|
+
return { tab, search }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function canonicalSearch(search: string): string {
|
|
25
|
+
// Sorting makes equivalent addresses a no-op instead of adding history entries.
|
|
26
|
+
const params = new URLSearchParams(search)
|
|
27
|
+
params.sort()
|
|
28
|
+
const result = params.toString()
|
|
29
|
+
return result ? `?${result}` : ''
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function readViewParams(search: string): ViewParams {
|
|
33
|
+
const params = new URLSearchParams(search)
|
|
34
|
+
return Object.fromEntries(Array.from(params.keys(), key => [key, params.get(key)!]))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function tabFromPath(path: string): WorkspaceTabId | null {
|
|
38
|
+
try {
|
|
39
|
+
const tab = decodeURIComponent(path)
|
|
40
|
+
return isWorkspaceTabId(tab) ? tab : null
|
|
41
|
+
} catch {
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Compatibility for old browser bookmarks only; saved tab state uses paths.
|
|
47
|
+
export function legacyTabFromPath(path: string): WorkspaceTabId | null {
|
|
48
|
+
const match = /^(view|view-builder):(.+)$/.exec(path)
|
|
49
|
+
return match ? tabFromPath(`${match[1]}s/${match[2]}`) : null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function moiHref(tab: WorkspaceTabId, search = ''): string {
|
|
53
|
+
return `moi:/${tab}${canonicalSearch(search)}`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Deployment-specific addressing is confined to this host adapter. Callers
|
|
57
|
+
// may supply the router base; portable links never contain it.
|
|
58
|
+
export function workspacePath(workspaceId: string, base = ''): string {
|
|
59
|
+
return `${base.replace(/\/$/, '')}/workspace/${encodeURIComponent(workspaceId)}`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function addressPath(workspaceId: string, address: WorkspaceAddress, base = ''): string {
|
|
63
|
+
return `${workspacePath(workspaceId, base)}/${address.tab}${address.search}`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function workspaceTabPath(workspaceId: string, tab: WorkspaceTabId): string {
|
|
67
|
+
return addressPath(workspaceId, { tab, search: '' })
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function resolveWorkspaceHref(workspaceId: string, href: string, base = ''): string {
|
|
71
|
+
if (href.startsWith('moi:')) return addressPath(workspaceId, parseMoiHref(href), base)
|
|
72
|
+
// Only explicit ordinary web addresses may leave the workspace through the
|
|
73
|
+
// imperative API. Native anchors keep their existing protocol policy.
|
|
74
|
+
const url = new URL(href)
|
|
75
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') throw new Error('Unsupported URL')
|
|
76
|
+
return url.href
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type NavigationRequest = {
|
|
80
|
+
type: 'navigation:request'
|
|
81
|
+
requestId: string
|
|
82
|
+
workspaceId: string
|
|
83
|
+
href: string
|
|
84
|
+
}
|
package/lib/themes.ts
CHANGED
|
@@ -119,11 +119,11 @@ const THEME_COLOR_DERIVATIONS = {
|
|
|
119
119
|
workspace: {
|
|
120
120
|
primary: primary => primary,
|
|
121
121
|
primaryForeground: primary => foregroundForPrimary(primary),
|
|
122
|
-
background: () => 'color-mix(in srgb, var(--primary)
|
|
122
|
+
background: () => 'color-mix(in srgb, var(--primary) 2%, oklch(1 0 0) 98%)',
|
|
123
123
|
foreground: () => 'color-mix(in srgb, var(--primary) 20%, oklch(0 0 0) 80%)',
|
|
124
|
-
muted: () => 'color-mix(in srgb, var(--background)
|
|
124
|
+
muted: () => 'color-mix(in srgb, var(--background) 95%, var(--foreground) 5%)',
|
|
125
125
|
mutedForeground: () => 'color-mix(in srgb, var(--background) 50%, var(--foreground) 50%)',
|
|
126
|
-
accent: () => 'color-mix(in srgb, var(--primary)
|
|
126
|
+
accent: () => 'color-mix(in srgb, var(--primary) 3%, var(--foreground) 4%)',
|
|
127
127
|
accentForeground: () => 'var(--foreground)',
|
|
128
128
|
border: () => 'color-mix(in srgb, var(--foreground) 7%, transparent)',
|
|
129
129
|
ring: () => 'color-mix(in srgb, var(--background) 50%, var(--primary) 50%)'
|
|
@@ -131,11 +131,11 @@ const THEME_COLOR_DERIVATIONS = {
|
|
|
131
131
|
widget: {
|
|
132
132
|
background: primary => primary,
|
|
133
133
|
foreground: primary => foregroundForPrimary(primary),
|
|
134
|
-
primary: () => 'color-mix(in srgb, var(--background)
|
|
134
|
+
primary: () => 'color-mix(in srgb, var(--background) 2%, oklch(1 0 0) 98%)',
|
|
135
135
|
primaryForeground: () => 'color-mix(in srgb, var(--background) 20%, oklch(0 0 0) 80%)',
|
|
136
|
-
muted: () => 'color-mix(in srgb, var(--background)
|
|
136
|
+
muted: () => 'color-mix(in srgb, var(--background) 95%, var(--foreground) 5%)',
|
|
137
137
|
mutedForeground: () => 'color-mix(in srgb, var(--background) 50%, var(--foreground) 50%)',
|
|
138
|
-
accent: () => 'color-mix(in srgb, var(--primary)
|
|
138
|
+
accent: () => 'color-mix(in srgb, var(--primary) 3%, var(--foreground) 4%)',
|
|
139
139
|
accentForeground: () => 'var(--foreground)',
|
|
140
140
|
border: () => 'color-mix(in srgb, var(--foreground) 15%, transparent)',
|
|
141
141
|
ring: () => 'color-mix(in srgb, var(--background) 50%, var(--primary) 50%)'
|
package/lib/types.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import type { PreviewBlock, StreamEvent } from './format'
|
|
2
|
+
import type { AppIconId } from './app-icons'
|
|
3
|
+
import type { ExperimentalFeatures } from './experimental'
|
|
4
|
+
import type { MoiContext } from './moi-context'
|
|
5
|
+
import type { WorkspaceTheme } from './themes'
|
|
2
6
|
|
|
3
7
|
// A custom UI unit embedded in a workspace.
|
|
4
8
|
export type AppletKind = 'view' | 'widget'
|
|
5
9
|
|
|
10
|
+
// What a bundled applet's `moi` module may call on its host-attached bridge.
|
|
11
|
+
// Inputs stay unknown at this trust boundary; the browser host narrows them.
|
|
12
|
+
export type AppletBridge = {
|
|
13
|
+
addChatAttachment: (input: unknown) => void
|
|
14
|
+
navigate: (href: unknown) => void
|
|
15
|
+
resolveHref: (href: unknown) => string
|
|
16
|
+
sendChatMessage: (input: unknown, context?: unknown) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
export type AppletInfo = {
|
|
7
20
|
id: string
|
|
8
21
|
// Content revision of the built bundle (`<size>-<mtime>` of index.js).
|
|
@@ -68,7 +81,7 @@ export type ViewBuilder = {
|
|
|
68
81
|
// server-side (bundle pipeline, RPC route); `load`/`render`/`window`/`runtime`
|
|
69
82
|
// are browser-side and reach the journal via POST
|
|
70
83
|
// /api/workspaces/:id/applet-log. `runtime` is the applet API refusing a
|
|
71
|
-
// request rather than code throwing — a `
|
|
84
|
+
// request rather than code throwing — a `navigate` to a view that no longer
|
|
72
85
|
// exists, a `sendChatMessage` dropped by the rate limit — which the applet's
|
|
73
86
|
// own code never sees.
|
|
74
87
|
export type AppletLogSource = 'build' | 'load' | 'render' | 'window' | 'rpc' | 'runtime'
|
|
@@ -184,11 +197,45 @@ export type ScratchOpResult = { name: string } | { image: string } | { ok: true
|
|
|
184
197
|
// the snapshot can name the version it needs (see lib/scratchpad-skew.ts).
|
|
185
198
|
export type ScratchpadWriter = { moi: string; tldraw: string }
|
|
186
199
|
|
|
187
|
-
//
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// the
|
|
200
|
+
// Attachments: caller input → upload receipt → send reference → resolved data.
|
|
201
|
+
// Text skips uploading. Origin and drawing purpose follow the attachment.
|
|
202
|
+
export type DrawingPurpose = 'annotation' | 'sketch'
|
|
203
|
+
|
|
204
|
+
// Host-stamped ID of the applet or workspace tab that created the attachment.
|
|
205
|
+
export type AttachmentOrigin = { source: string }
|
|
206
|
+
|
|
207
|
+
export type TextAttachment = Partial<AttachmentOrigin> & { label: string; text: string }
|
|
208
|
+
|
|
209
|
+
type FileAttachment = Partial<AttachmentOrigin> & {
|
|
210
|
+
mediaType: string
|
|
211
|
+
path: string
|
|
212
|
+
// Only set when the file contains a drawing image.
|
|
213
|
+
purpose?: DrawingPurpose
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
type ImageAttachment = Partial<AttachmentOrigin> & {
|
|
217
|
+
mediaType: string
|
|
218
|
+
label: string
|
|
219
|
+
purpose?: DrawingPurpose
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Resolved payloads: JSON-safe data shared by prompts and transcript replay.
|
|
223
|
+
export type Attachment =
|
|
224
|
+
| ({ type: 'text' } & TextAttachment)
|
|
225
|
+
| ({ type: 'file' } & FileAttachment)
|
|
226
|
+
| ({ type: 'image' } & ImageAttachment)
|
|
227
|
+
|
|
228
|
+
// Caller input: text or a browser file / workspace-relative path.
|
|
229
|
+
export type TextAttachmentInput = Pick<TextAttachment, 'label' | 'text'>
|
|
230
|
+
|
|
231
|
+
type FileAttachmentInput = { file: File; path?: never } | { path: string; file?: never }
|
|
232
|
+
|
|
233
|
+
export type AttachmentInput =
|
|
234
|
+
| ({ type: 'text' } & TextAttachmentInput)
|
|
235
|
+
| ({ type: 'file' } & FileAttachmentInput)
|
|
236
|
+
|
|
237
|
+
// Upload receipt: returned by the upload API before sending the message.
|
|
238
|
+
// Bytes or an absolute file path live in the server's workspace-scoped store.
|
|
192
239
|
export type UploadKind = 'image' | 'file'
|
|
193
240
|
export type UploadInfo = {
|
|
194
241
|
id: string
|
|
@@ -202,9 +249,13 @@ export type UploadInfo = {
|
|
|
202
249
|
height?: number
|
|
203
250
|
}
|
|
204
251
|
|
|
205
|
-
//
|
|
206
|
-
//
|
|
207
|
-
|
|
252
|
+
// Send reference: inline text or an upload ID for the server to resolve.
|
|
253
|
+
// Drawing purpose belongs to this message's use of the uploaded image.
|
|
254
|
+
export type MessageAttachment =
|
|
255
|
+
| ({ type: 'text' } & TextAttachment)
|
|
256
|
+
| ({ type: 'upload'; uploadId: string; purpose?: DrawingPurpose } & Partial<AttachmentOrigin>)
|
|
257
|
+
|
|
258
|
+
// Client → server messages, routed by workspaceId over the shared WebSocket.
|
|
208
259
|
export type ClientMessage =
|
|
209
260
|
| {
|
|
210
261
|
type: 'chat'
|
|
@@ -212,10 +263,12 @@ export type ClientMessage =
|
|
|
212
263
|
content: string
|
|
213
264
|
sessionId: string
|
|
214
265
|
isNew: boolean
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
|
|
266
|
+
// The browser owns its selected session; creating this chat must not
|
|
267
|
+
// update the installation's shared selection or switch other tabs.
|
|
268
|
+
personalSelection?: boolean
|
|
269
|
+
// Text and upload references for this turn. The server resolves uploads
|
|
270
|
+
// and describes all attachments together, preserving their order.
|
|
271
|
+
attachments?: MessageAttachment[]
|
|
219
272
|
// Client-chosen stable id for the user's turn. The server tells the
|
|
220
273
|
// adapter to use this id when the SDK echoes the user input back, so
|
|
221
274
|
// the optimistic bubble the client rendered gets upserted in place.
|
|
@@ -240,7 +293,7 @@ export type ClientMessage =
|
|
|
240
293
|
// snapshotted at send time, assembled by
|
|
241
294
|
// client/features/workspace/moi-context.ts. The server renders it per
|
|
242
295
|
// harness; display paths strip the rendered envelope from bubbles.
|
|
243
|
-
context?:
|
|
296
|
+
context?: MoiContext
|
|
244
297
|
}
|
|
245
298
|
| { type: 'stop'; workspaceId: string; sessionId: string }
|
|
246
299
|
// Reply to a relayed Scratchpad op (see ScratchpadOpMessage). Carries the
|
|
@@ -285,20 +338,20 @@ export type AppSettings = {
|
|
|
285
338
|
autoUpdateSkills: boolean
|
|
286
339
|
}
|
|
287
340
|
|
|
288
|
-
// Client-safe
|
|
289
|
-
//
|
|
290
|
-
//
|
|
291
|
-
// forever. See server/app-config.ts.
|
|
341
|
+
// Client-safe startup config, served by GET /api/config. Deployment settings
|
|
342
|
+
// come from config.json and MOI_* env overrides; experimental flags come from
|
|
343
|
+
// explicit CLI options. See server/app-config.ts.
|
|
292
344
|
export type ClientAppConfig = {
|
|
293
345
|
// Cloud demo deployment: workspace creation is blocked; the UI offers the
|
|
294
346
|
// cloud-demo promo dialog instead.
|
|
295
347
|
cloudDemo: boolean
|
|
296
|
-
|
|
297
|
-
experiments: string[]
|
|
348
|
+
experimental: ExperimentalFeatures
|
|
298
349
|
// Link target for the cloud-demo promo dialog.
|
|
299
350
|
demoInstallUrl: string
|
|
300
351
|
}
|
|
301
352
|
|
|
353
|
+
export type { ExperimentalFeatures } from './experimental'
|
|
354
|
+
|
|
302
355
|
export type UpdateStatus = {
|
|
303
356
|
runningVersion: string
|
|
304
357
|
availableVersion: string | null
|
|
@@ -436,6 +489,11 @@ export type AgentLoginState =
|
|
|
436
489
|
| { state: 'pending'; url?: string }
|
|
437
490
|
| { state: 'failed'; reason: string }
|
|
438
491
|
|
|
492
|
+
export type WorkspaceIcon =
|
|
493
|
+
| { type: 'emoji'; value: string; background?: 'theme' }
|
|
494
|
+
| { type: 'glyph'; value: AppIconId; background?: 'theme' }
|
|
495
|
+
| { type: 'upload'; value: string }
|
|
496
|
+
|
|
439
497
|
// One MCP server's connection status, as surfaced by GET /api/workspaces/:id/mcp
|
|
440
498
|
// (a subset of the agent SDK's McpServerStatus — only what the UI renders).
|
|
441
499
|
export type McpServerState = 'connected' | 'failed' | 'needs-auth' | 'pending' | 'disabled'
|
|
@@ -454,9 +512,11 @@ export type WorkspaceEntry = {
|
|
|
454
512
|
// basename). Persisted so we don't re-probe the gateway for each listing.
|
|
455
513
|
// The list endpoint overrides this with the live layout `name` when set.
|
|
456
514
|
name?: string
|
|
457
|
-
// Workspace icon override
|
|
458
|
-
|
|
459
|
-
|
|
515
|
+
// Workspace icon override. Undefined uses the provider icon.
|
|
516
|
+
icon?: WorkspaceIcon
|
|
517
|
+
// Merged in from the layout so app-wide workspace lists can paint a themed
|
|
518
|
+
// icon without inheriting the active workspace's color.
|
|
519
|
+
theme?: WorkspaceTheme
|
|
460
520
|
// Home-relative rendering of `path` (e.g. "~/.openclaw/workspace"). Set by
|
|
461
521
|
// the server on the wire — clients render it as-is.
|
|
462
522
|
displayPath?: string
|
|
@@ -492,6 +552,9 @@ export type ErrorFrame = {
|
|
|
492
552
|
workspaceId: string
|
|
493
553
|
sessionId: string
|
|
494
554
|
content: string
|
|
555
|
+
// A failed steer or interrupt leaves the current run active. Older senders
|
|
556
|
+
// omit this field and retain terminal-error behavior.
|
|
557
|
+
terminal?: boolean
|
|
495
558
|
}
|
|
496
559
|
|
|
497
560
|
export type StoppedFrame = {
|
|
@@ -504,8 +567,8 @@ export type StoppedFrame = {
|
|
|
504
567
|
// lifecycle signal (CC `session_state_changed`, Codex `turn/*`, OpenClaw run
|
|
505
568
|
// lifecycle) rather than derived by counting messages:
|
|
506
569
|
// running — the agent is working; the client shows the loader/Stop
|
|
507
|
-
// requires-action —
|
|
508
|
-
//
|
|
570
|
+
// requires-action — waiting for user input; no loader/Stop. Input notices
|
|
571
|
+
// provide the answer form independently of this state.
|
|
509
572
|
// idle — everything else, including interrupted/failed turns
|
|
510
573
|
export type SessionActivity = 'idle' | 'running' | 'requires-action'
|
|
511
574
|
|
|
@@ -526,10 +589,10 @@ export type LayoutMode = 'fullscreen' | 'split'
|
|
|
526
589
|
|
|
527
590
|
export type WorkspaceTabId =
|
|
528
591
|
| 'agent'
|
|
529
|
-
| '
|
|
592
|
+
| 'overview'
|
|
530
593
|
| 'scratchpad'
|
|
531
|
-
| `
|
|
532
|
-
| `view-
|
|
594
|
+
| `views/${string}`
|
|
595
|
+
| `view-builders/${string}`
|
|
533
596
|
|
|
534
597
|
// Open tabs plus the workspace's saved DEFAULT tab. `active` is not live focus
|
|
535
598
|
// state — the live active tab is each browser tab's URL (`/workspace/:id/<tab>`).
|
|
@@ -543,6 +606,8 @@ export type WorkspaceTabsState = {
|
|
|
543
606
|
|
|
544
607
|
export type { AgentTheme, ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from './themes'
|
|
545
608
|
|
|
609
|
+
export type WorkspaceLayoutSave = Omit<WorkspaceLayout, 'tabs'> & { tabs?: WorkspaceTabsState }
|
|
610
|
+
|
|
546
611
|
export type WorkspaceLayout = {
|
|
547
612
|
version: 1
|
|
548
613
|
widgetGrid: LayoutGridItem[]
|
|
@@ -553,9 +618,8 @@ export type WorkspaceLayout = {
|
|
|
553
618
|
// User-set display-name override. When empty/undefined the API falls back to
|
|
554
619
|
// the workspace folder name, so the resolved name always comes from the API.
|
|
555
620
|
name?: string
|
|
556
|
-
// Workspace icon override
|
|
557
|
-
|
|
558
|
-
icon?: string
|
|
621
|
+
// Workspace icon override. Emoji and glyphs may use a themed background.
|
|
622
|
+
icon?: WorkspaceIcon
|
|
559
623
|
// Model id chosen in the composer picker (`supportedModels()` `value`, an
|
|
560
624
|
// alias like `sonnet`). Persisted so the choice survives a reload. Sent with
|
|
561
625
|
// each chat frame; undefined means the agent runs on the SDK default. Note
|
|
@@ -571,7 +635,7 @@ export type WorkspaceLayout = {
|
|
|
571
635
|
selectedEffort?: string
|
|
572
636
|
// Fast-mode default for new sessions. Undefined inherits the provider setting.
|
|
573
637
|
selectedFastMode?: boolean
|
|
574
|
-
theme?:
|
|
638
|
+
theme?: WorkspaceTheme
|
|
575
639
|
}
|
|
576
640
|
|
|
577
641
|
// One applet's thumbnail freshness record. Image bytes live as files in the
|
|
@@ -648,12 +712,14 @@ export type Model = {
|
|
|
648
712
|
// Id used to select the model (Claude `value`; OpenClaw catalog id).
|
|
649
713
|
value: string
|
|
650
714
|
// Canonical wire model id this row resolves to (Claude, e.g. 'default' and
|
|
651
|
-
// 'opus[1m]' both → 'claude-opus-4-8[1m]'
|
|
652
|
-
//
|
|
715
|
+
// 'opus[1m]' both → 'claude-opus-4-8[1m]'; Hermes maps its structured ACP
|
|
716
|
+
// default the same way). Lets the picker map a synthetic "default" entry
|
|
717
|
+
// onto the concrete model it points at.
|
|
653
718
|
resolvedModel?: string
|
|
654
719
|
// Human-readable label (Claude `displayName`; OpenClaw `name`).
|
|
655
720
|
displayName: string
|
|
656
|
-
//
|
|
721
|
+
// One-line blurb (Claude: "Most efficient for everyday tasks"). Not shown by
|
|
722
|
+
// the picker. Absent for OpenClaw.
|
|
657
723
|
description?: string
|
|
658
724
|
// Heading this model sits under in the picker (Hermes: the upstream provider,
|
|
659
725
|
// e.g. 'Ollama'). Absent when the backend serves one flat catalog.
|
|
@@ -677,11 +743,8 @@ export type Model = {
|
|
|
677
743
|
supportsAutoMode?: boolean
|
|
678
744
|
}
|
|
679
745
|
|
|
680
|
-
// GET /api/workspaces/:id/agent
|
|
681
|
-
//
|
|
682
|
-
// `models` and capabilities are stable per process; `availability` and `login`
|
|
683
|
-
// are the volatile part, kept fresh after load by `agent:updated` events
|
|
684
|
-
// instead of refetches.
|
|
746
|
+
// GET /api/workspaces/:id/agent. Model changes arrive on refetch;
|
|
747
|
+
// `agent:updated` events refresh availability and login state.
|
|
685
748
|
export type WorkspaceAgent = {
|
|
686
749
|
// The agent backend that produced this snapshot — matches the workspace
|
|
687
750
|
// provider.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isAppIconId } from './app-icons'
|
|
2
|
+
import type { WorkspaceIcon } from './types'
|
|
3
|
+
|
|
4
|
+
export function isWorkspaceIcon(value: unknown): value is WorkspaceIcon {
|
|
5
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return false
|
|
6
|
+
const icon = value as Record<string, unknown>
|
|
7
|
+
if (typeof icon.value !== 'string') return false
|
|
8
|
+
if (icon.background !== undefined && icon.background !== 'theme') return false
|
|
9
|
+
|
|
10
|
+
switch (icon.type) {
|
|
11
|
+
case 'emoji':
|
|
12
|
+
return icon.value.length > 0 && icon.value.length <= 64
|
|
13
|
+
case 'glyph':
|
|
14
|
+
return isAppIconId(icon.value)
|
|
15
|
+
case 'upload':
|
|
16
|
+
return icon.background === undefined
|
|
17
|
+
default:
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
}
|
package/lib/workspace-layout.ts
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
|
+
import { createDefaultWidgetGrid } from './default-widgets'
|
|
1
2
|
import type { WorkspaceLayout, WorkspaceTabsState } from './types'
|
|
3
|
+
import { isWorkspaceTabId } from './workspace-tabs'
|
|
2
4
|
|
|
3
5
|
export function createDefaultWorkspaceTabs(): WorkspaceTabsState {
|
|
4
|
-
return { open: ['
|
|
6
|
+
return { open: ['overview', 'agent', 'scratchpad'], active: 'overview' }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function normalizeWorkspaceTabs(value: unknown): WorkspaceTabsState {
|
|
10
|
+
const defaults = createDefaultWorkspaceTabs()
|
|
11
|
+
if (!value || typeof value !== 'object') return defaults
|
|
12
|
+
|
|
13
|
+
const raw = value as Record<string, unknown>
|
|
14
|
+
const savedOpen = Array.isArray(raw.open)
|
|
15
|
+
? raw.open.filter(isWorkspaceTabId).filter((tab, index, all) => all.indexOf(tab) === index)
|
|
16
|
+
: []
|
|
17
|
+
if (savedOpen.length === 0) return defaults
|
|
18
|
+
|
|
19
|
+
const open = [
|
|
20
|
+
'overview',
|
|
21
|
+
...savedOpen.filter(tab => tab !== 'overview')
|
|
22
|
+
] satisfies WorkspaceTabsState['open']
|
|
23
|
+
const active = isWorkspaceTabId(raw.active) && open.includes(raw.active) ? raw.active : 'overview'
|
|
24
|
+
return { open, active }
|
|
5
25
|
}
|
|
6
26
|
|
|
7
27
|
export function createDefaultWorkspaceLayout(): WorkspaceLayout {
|
|
8
28
|
return {
|
|
9
29
|
version: 1,
|
|
10
|
-
widgetGrid:
|
|
30
|
+
widgetGrid: createDefaultWidgetGrid(),
|
|
11
31
|
layoutMode: 'split',
|
|
12
32
|
tabs: createDefaultWorkspaceTabs()
|
|
13
33
|
}
|
package/lib/workspace-tabs.ts
CHANGED
|
@@ -1,48 +1,24 @@
|
|
|
1
|
-
//
|
|
2
|
-
// and the CLI. A tab id doubles as the URL suffix of `/workspace/:id/<tab>` —
|
|
3
|
-
// ids are URL-safe as-is (`:` is a legal path character), so building a path
|
|
4
|
-
// is plain concatenation and parsing is plain validation.
|
|
1
|
+
// Tab IDs are workspace-relative paths without query strings.
|
|
5
2
|
import type { WorkspaceTabId } from './types'
|
|
6
3
|
|
|
7
4
|
export function isWorkspaceTabId(value: unknown): value is WorkspaceTabId {
|
|
8
5
|
return (
|
|
9
6
|
value === 'agent' ||
|
|
10
|
-
value === '
|
|
7
|
+
value === 'overview' ||
|
|
11
8
|
value === 'scratchpad' ||
|
|
12
|
-
//
|
|
13
|
-
(typeof value === 'string' &&
|
|
14
|
-
(/^view:[^/]+$/.test(value) || /^view-builder:[^/]+$/.test(value)))
|
|
9
|
+
// Match the applet IDs accepted by the server's module routes.
|
|
10
|
+
(typeof value === 'string' && /^(views|view-builders)\/[a-zA-Z0-9_-]+$/.test(value))
|
|
15
11
|
)
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
// missing or isn't a tab id (bare `/workspace/:id`, stale or mangled links).
|
|
20
|
-
export function parseWorkspaceTab(segment: string | null | undefined): WorkspaceTabId | null {
|
|
21
|
-
return isWorkspaceTabId(segment) ? segment : null
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function workspaceTabPath(workspaceId: string, tab: WorkspaceTabId): string {
|
|
25
|
-
return `/workspace/${workspaceId}/${tab}`
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const viewTabId = (viewId: string): WorkspaceTabId => `view:${viewId}`
|
|
14
|
+
export const viewTabId = (viewId: string): WorkspaceTabId => `views/${viewId}`
|
|
29
15
|
export const viewIdFromTab = (tab: WorkspaceTabId): string | null =>
|
|
30
|
-
tab.startsWith('
|
|
31
|
-
export const viewBuilderTabId = (builderId: string): WorkspaceTabId => `view-
|
|
16
|
+
tab.startsWith('views/') ? tab.slice('views/'.length) : null
|
|
17
|
+
export const viewBuilderTabId = (builderId: string): WorkspaceTabId => `view-builders/${builderId}`
|
|
32
18
|
export const viewBuilderIdFromTab = (tab: WorkspaceTabId): string | null =>
|
|
33
|
-
tab.startsWith('view-
|
|
19
|
+
tab.startsWith('view-builders/') ? tab.slice('view-builders/'.length) : null
|
|
34
20
|
|
|
35
|
-
//
|
|
36
|
-
// object. Arrays and null are valid JSON but not a params record.
|
|
21
|
+
// A record check shared by JSON boundary validators.
|
|
37
22
|
export function isParamsRecord(value: unknown): value is Record<string, unknown> {
|
|
38
23
|
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
39
24
|
}
|
|
40
|
-
|
|
41
|
-
// Applet params as read back from navigation state (`state.appletParams`).
|
|
42
|
-
// Anything malformed degrades to `{}` — a view must render with empty params
|
|
43
|
-
// anyway (fresh mount, new browser tab, plain tab-bar click).
|
|
44
|
-
export function readAppletParams(state: unknown): Record<string, unknown> {
|
|
45
|
-
if (!isParamsRecord(state)) return {}
|
|
46
|
-
const params = (state as { appletParams?: unknown }).appletParams
|
|
47
|
-
return isParamsRecord(params) ? params : {}
|
|
48
|
-
}
|