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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Session discovery + history replay for Claude Code workspaces, backed by
|
|
2
2
|
// the Agent SDK's persisted `.jsonl` session files.
|
|
3
|
+
import { attachmentLabel, splitAttachments, stripAttachmentsLoose } from '@/lib/moi-attachments'
|
|
3
4
|
import {
|
|
4
5
|
getSessionInfo,
|
|
5
6
|
getSessionMessages,
|
|
@@ -35,12 +36,16 @@ export function claudeSessionSummary(
|
|
|
35
36
|
session: Pick<SDKSessionInfo, 'customTitle' | 'firstPrompt' | 'summary'>
|
|
36
37
|
): string {
|
|
37
38
|
if (session.customTitle || !session.firstPrompt || session.summary !== session.firstPrompt) {
|
|
38
|
-
return session.summary
|
|
39
|
+
return stripAttachmentsLoose(session.summary)
|
|
39
40
|
}
|
|
40
|
-
const
|
|
41
|
+
const attached = splitAttachments(session.firstPrompt)
|
|
42
|
+
const split = splitAttachmentNote(attached.text)
|
|
41
43
|
return isAttachmentOnlyPlaceholder(split.text)
|
|
42
44
|
? attachmentOnlyFilenames(split.text).join(', ')
|
|
43
|
-
:
|
|
45
|
+
: stripAttachmentsLoose(split.text) ||
|
|
46
|
+
[...attached.attachments.map(attachmentLabel), ...split.files.map(f => f.filename)].join(
|
|
47
|
+
', '
|
|
48
|
+
)
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export function visibleClaudeSessions<T extends Pick<SDKSessionInfo, 'tag'>>(sessions: T[]): T[] {
|
|
@@ -67,7 +72,7 @@ export function selectOldestSessionFirstUserMessage(
|
|
|
67
72
|
(a.createdAt ?? a.lastModified) - (b.createdAt ?? b.lastModified) ||
|
|
68
73
|
a.sessionId.localeCompare(b.sessionId)
|
|
69
74
|
)[0]
|
|
70
|
-
return oldest?.firstPrompt
|
|
75
|
+
return oldest?.firstPrompt ? stripAttachmentsLoose(oldest.firstPrompt) : undefined
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
export function selectLatestSessionUpdatedAt(
|
|
@@ -1,356 +1,228 @@
|
|
|
1
|
-
# Codex
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
# Codex harness
|
|
2
|
+
|
|
3
|
+
moi drives chats through `codex app-server`, a persistent process speaking
|
|
4
|
+
newline-delimited JSON-RPC over stdio. It provides native model and session
|
|
5
|
+
lists, token deltas, steering, and interruption. Codex owns durable history;
|
|
6
|
+
moi holds a display copy and translates native items into shared chat events.
|
|
7
|
+
|
|
8
|
+
The upstream [app-server specification](https://learn.chatgpt.com/docs/app-server)
|
|
9
|
+
defines the protocol; generated types from the installed CLI define its exact wire shapes.
|
|
10
|
+
|
|
11
|
+
## Module ownership
|
|
12
|
+
|
|
13
|
+
| Module | Responsibility |
|
|
14
|
+
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `index.ts` | Implements the shared `Harness` contract. |
|
|
16
|
+
| `transport.ts` | Frames stdio, routes RPC replies and server requests, times out requests, and closes waiters on disconnect. |
|
|
17
|
+
| `client.ts` | Owns one app-server per workspace, initialization, catalogs, session/history queries, and bounded child-history reads. |
|
|
18
|
+
| `session.ts` | Owns live session state, sends, steering, stop, replay hydration, previews, and notices. |
|
|
19
|
+
| `adapter.ts` | Defines the consumed wire types and maps models, items, and history to display types. |
|
|
20
|
+
| `permissions.ts` | Defines sandbox access and the default approval policy; rejects unsupported requests. |
|
|
21
|
+
| `auth.ts`, `discovery.ts`, `status.ts` | Check login readiness, discover workspace paths from rollout heads, and report running processes. |
|
|
22
|
+
| `session-title.ts` | Generates a title with a separate ephemeral `codex exec` call and applies it if the session is still unnamed. |
|
|
23
|
+
| `probe.ts` | Runs standalone protocol diagnostics without moi's session or workspace policy. |
|
|
24
|
+
|
|
25
|
+
The shared contract and event layers are in [../README.md](../README.md).
|
|
26
|
+
|
|
27
|
+
## Runtime and configuration
|
|
28
|
+
|
|
29
|
+
`../executable.ts` searches the login-shell PATH followed by the server PATH.
|
|
30
|
+
If neither resolves `codex`, it checks the macOS `ChatGPT.app` and `Codex.app`
|
|
31
|
+
bundles. A CLI on PATH wins even when the desktop app bundles a newer version.
|
|
32
|
+
|
|
33
|
+
Each process inherits the server environment plus `resolveWorkspaceEnv()` and
|
|
34
|
+
`MOI_AGENT=1`. Workspace environment variables are fixed at spawn, which is
|
|
35
|
+
why workspaces have separate app-servers. Environment changes close the affected
|
|
36
|
+
process; the next request starts a replacement. Closing a process interrupts
|
|
37
|
+
its active runs. Idle display eviction does not stop the workspace process.
|
|
38
|
+
|
|
39
|
+
Codex resolves its own configuration and credentials, including `CODEX_HOME`
|
|
40
|
+
(default `~/.codex`). Installations can share that home while running different
|
|
41
|
+
binary versions. `config/read` with the workspace cwd supplies effective model,
|
|
42
|
+
effort, and tier defaults; moi does not rewrite the user's Codex config.
|
|
43
|
+
|
|
44
|
+
Initialization enables `experimentalApi`, reads the version from `userAgent`,
|
|
45
|
+
and then sends `initialized`. The availability check rejects parsed versions
|
|
46
|
+
below 0.89.0, the harness's basic protocol floor; unknown and development
|
|
47
|
+
versions are allowed. This floor does **not** establish support for every
|
|
48
|
+
feature or model. Use the running process's catalog and version when diagnosing
|
|
49
|
+
model errors.
|
|
50
|
+
|
|
51
|
+
The HTTP server allows 60 seconds of inactivity so discovery can finish or
|
|
52
|
+
reach the harness's 30-second RPC timeout before Bun closes the connection.
|
|
53
|
+
|
|
54
|
+
## Session lifecycle
|
|
55
|
+
|
|
56
|
+
- A new chat starts under a temporary moi id. `thread/start` supplies the real
|
|
57
|
+
id; `session_renamed` rekeys the chat, saved settings, and builder references.
|
|
58
|
+
- Concurrent resumes share one promise. Subscribe before `thread/resume`,
|
|
59
|
+
buffer notifications while loading history, then apply them after the
|
|
60
|
+
snapshot. Otherwise a live update can be overwritten by replay.
|
|
61
|
+
- Serialize sends through RPC acknowledgement, not through model completion.
|
|
62
|
+
Follow-ups use `turn/steer` with `expectedTurnId` while a turn is active.
|
|
63
|
+
Only an explicit no-active-turn RPC error permits fallback to `turn/start`.
|
|
64
|
+
A timeout or ambiguous failure must not resubmit potentially accepted input.
|
|
65
|
+
- Native lifecycle notifications determine activity. Completion can arrive
|
|
66
|
+
before the start acknowledgement; completed ids prevent late responses from
|
|
67
|
+
reviving a run. Ignore stale usage and completion from older turns.
|
|
68
|
+
Active waiting flags map to `requires-action`. Closed, archived, deleted, or
|
|
69
|
+
unloaded threads release the live record; later access resumes it again.
|
|
70
|
+
- `error.willRetry` keeps the turn active and emits a retry notice. Failed
|
|
71
|
+
steer/interrupt RPCs keep a known active turn stoppable. A terminal error or
|
|
72
|
+
disconnect clears previews and settles unfinished tool cards.
|
|
73
|
+
- Stop invalidates queued sends and interrupts a start acknowledged after Stop.
|
|
74
|
+
For a running turn, wait for native completion before reporting it stopped.
|
|
75
|
+
- Idle display records expire after 30 minutes, except during active turns,
|
|
76
|
+
hydration, or title generation. Cold access resumes and subscribes again;
|
|
77
|
+
`thread/read` provides a static fallback when live resume fails.
|
|
78
|
+
|
|
79
|
+
`thread/list` uses cwd filtering, `updated_at` ordering, and every cursor page.
|
|
80
|
+
Repeated cursors fail instead of looping. Child-history loading is limited to
|
|
81
|
+
four concurrent reads. Home-card previews reuse an existing app-server and read
|
|
82
|
+
up to 50 recent sessions; rendering the home page does not spawn one per card.
|
|
83
|
+
Workspace import discovery separately reads up to 400 recent rollout heads
|
|
84
|
+
under the server's `$CODEX_HOME/sessions`, without requiring a CLI executable.
|
|
85
|
+
|
|
86
|
+
## Models, effort, and fast mode
|
|
87
|
+
|
|
88
|
+
`model/list` is the source of picker capabilities. The catalog is paginated,
|
|
89
|
+
filters hidden rows, and is cached per client for one minute. Login/account
|
|
90
|
+
notifications invalidate it; replacing the process also replaces its cache.
|
|
91
|
+
Effective config is read separately. Never share catalogs across workspace
|
|
92
|
+
processes, whose environment can select different accounts or providers.
|
|
93
|
+
|
|
94
|
+
The synthetic `default` row resolves to the configured model when listed,
|
|
95
|
+
otherwise the catalog default, otherwise the first available model. The picker
|
|
96
|
+
and send path share `resolveSelectedModel`; when the catalog is available, a
|
|
97
|
+
Codex UI send includes that concrete native model. Omitting it can inherit an
|
|
98
|
+
unavailable config or resumed-thread model while the picker shows a fallback.
|
|
99
|
+
Changing a selection does not retry an earlier failed message.
|
|
100
|
+
|
|
101
|
+
Configured reasoning effort applies when supported by the selected model;
|
|
102
|
+
otherwise the adapter uses its advertised default. Fast mode is available when
|
|
103
|
+
`serviceTiers` includes `priority`. Only catalogs missing that field fall back
|
|
104
|
+
to `additionalSpeedTiers: ["fast"]`. A non-null configured tier takes precedence
|
|
105
|
+
over the catalog default.
|
|
106
|
+
|
|
107
|
+
| moi fast-mode setting | Native `serviceTier` |
|
|
108
|
+
| --------------------- | ---------------------------------------- |
|
|
109
|
+
| On | `"priority"` |
|
|
110
|
+
| Off | `null` |
|
|
111
|
+
| Unset | Omitted; inherits the config/thread tier |
|
|
112
|
+
|
|
113
|
+
Model, effort, and tier changes apply on the next **new turn**. `turn/steer`
|
|
114
|
+
has no fields for changing them during an active turn. moi uses the persistent
|
|
115
|
+
`serviceTier` override for chat settings; it does not use the newer
|
|
116
|
+
`serviceTierForTurn` override, which affects only one turn.
|
|
117
|
+
|
|
118
|
+
## Context and permissions
|
|
119
|
+
|
|
120
|
+
`additionalContext` carries the application context under `moi-context`, and
|
|
121
|
+
localhost access guidance under `moi-control-access`. Values use the unwrapped
|
|
122
|
+
body because Codex supplies the tags; native context is not echoed as a user
|
|
123
|
+
item. `client.ts` gates this channel at 0.135.0. Older or unrecognized versions
|
|
124
|
+
receive a text envelope, which the adapter strips from echoes and previews.
|
|
125
|
+
The version gate matters because older servers can silently ignore the field.
|
|
126
|
+
|
|
127
|
+
`permissions.ts` selects workspace-write access and `approvalPolicy: 'on-request'`
|
|
128
|
+
on start/resume. New turns explicitly set the workspace-write sandbox with
|
|
129
|
+
network access disabled. moi automatically accepts supported permission
|
|
130
|
+
requests; there is no command-approval UI.
|
|
131
|
+
Command/file requests use `decision: 'accept'`, legacy requests use `approved`,
|
|
132
|
+
and permission extensions grant the requested network/file-system fields for
|
|
133
|
+
`scope: 'turn'`. Unknown request methods receive an unsupported-method error.
|
|
134
|
+
|
|
135
|
+
Native question forms (`item/tool/requestUserInput`) are not supported and
|
|
136
|
+
receive the same unsupported-method error. moi does not opt into
|
|
137
|
+
`features.default_mode_request_user_input`. MCP schema/URL elicitation is
|
|
138
|
+
declined with `action: 'decline'`.
|
|
139
|
+
|
|
140
|
+
### TODO: restore native question forms
|
|
141
|
+
|
|
142
|
+
This feature is deferred, not ruled out. It was removed in `1cfce26` because
|
|
143
|
+
the question form exposed an undefined `Field` namespace in Base UI's `Input`
|
|
144
|
+
wrapper in Bun's dev bundle. The earlier workaround changed every shared
|
|
145
|
+
Input to `Field.Control`; the underlying bundler cause was not established.
|
|
146
|
+
The removed implementation is available in that commit's parent for reference.
|
|
147
|
+
|
|
148
|
+
Before restoring support:
|
|
149
|
+
|
|
150
|
+
- Resolve the Input failure at its source and verify the form in both dev and
|
|
151
|
+
production builds before opting into native questions again.
|
|
152
|
+
- Re-read the current app-server spec and generated types. Preserve fixed
|
|
153
|
+
choices, free-text answers, secret fields, and blocking/nonblocking semantics.
|
|
154
|
+
- Restore session-scoped request handling, the answer endpoint, and chat UI.
|
|
155
|
+
Handle reload, skip, stop, disconnect, and `serverRequest/resolved` without
|
|
156
|
+
duplicate replies or stale forms answering reused request ids. Keep answers
|
|
157
|
+
out of debug logs and notice payloads.
|
|
158
|
+
- Verify the full flow with browser interactions and a real Codex session,
|
|
159
|
+
including cancellation and recovery; add tests for those boundaries.
|
|
160
|
+
|
|
161
|
+
## Display and MCP boundaries
|
|
162
|
+
|
|
163
|
+
- Native items become display turns or notices. `clientUserMessageId` is echoed
|
|
164
|
+
as `clientId` on live user items, so the optimistic bubble is updated in place.
|
|
165
|
+
Replay can change item ids and omit `clientId`; they are not durable moi ids.
|
|
166
|
+
- Agent text and reasoning-summary deltas become cumulative previews, batched
|
|
167
|
+
every 40ms. Item completion removes its pending preview. Command output
|
|
168
|
+
deltas are also batched; the live tail is bounded to 64K characters until the
|
|
169
|
+
completed item replaces it with authoritative output. Native plan updates
|
|
170
|
+
upsert a plan card within their turn.
|
|
171
|
+
- New turns request `summary: 'detailed'`. Reasoning can still be absent for a
|
|
172
|
+
trivial prompt. Replay uses native timestamps and duration when supplied,
|
|
173
|
+
rather than deriving duration from items sharing a turn timestamp.
|
|
174
|
+
- Child transcripts nest under `subAgentActivity` cards. Replay excludes
|
|
175
|
+
inherited parent turns and child send-back activity; missing children leave
|
|
176
|
+
their cards visible. Generated images are represented by tool cards without
|
|
177
|
+
embedding the potentially large base64 result in every display event.
|
|
178
|
+
- Uploads send images inline as data URLs and other files as materialized path
|
|
179
|
+
notes. Text-only models reject image sends with an actionable error; absent
|
|
180
|
+
`inputModalities` retains the protocol's image-compatible default. Steering
|
|
181
|
+
checks the running model. Replayed `localImage` items currently show a path label.
|
|
182
|
+
- Warnings, failed MCP startups, and model reroutes appear in the chat timeline.
|
|
183
|
+
Hook notices are retained but have no chat rendering. The connector list uses
|
|
184
|
+
native runtime status; older servers without it remain pending unless auth
|
|
185
|
+
is required. The status request omits resource catalogs with `toolsAndAuthOnly`.
|
|
186
|
+
It targets the workspace's most recently observed loaded chat, since an
|
|
187
|
+
app-scoped request can return null runtime states.
|
|
188
|
+
Full tool definitions are not carried into connector display rows. `codex_apps` branding
|
|
189
|
+
uses the dotted tool-name prefix; connector `_meta` is not forwarded.
|
|
190
|
+
|
|
191
|
+
## Diagnostics and maintenance
|
|
192
|
+
|
|
193
|
+
1. Inspect `/status` for the selected executable, process ids, and active turns.
|
|
194
|
+
Use `/dev/harness` or `GET /api/workspaces/:id/harness/debug` for the native
|
|
195
|
+
wire and display frames. `initialize.userAgent` identifies the running
|
|
196
|
+
version; `codex --version` only identifies what a new terminal process runs.
|
|
197
|
+
2. For a picker mismatch, compare `model/list`, `config/read`, and the outgoing
|
|
198
|
+
`turn/start` model/effort/tier. For a run that stays busy, inspect lifecycle
|
|
199
|
+
frames and pending native input before assuming it is still generating.
|
|
200
|
+
3. Update the selected standalone CLI with `codex update` when it supports that
|
|
201
|
+
command. Already-running app-servers keep the old executable until restarted;
|
|
202
|
+
let active chats finish before restarting them or the moi dev server.
|
|
203
|
+
|
|
204
|
+
Read-only standalone probes (run from the repo root):
|
|
205
|
+
|
|
206
|
+
```sh
|
|
207
|
+
bun server/harness/codex/probe.ts models
|
|
208
|
+
bun server/harness/codex/probe.ts threads "$PWD"
|
|
209
|
+
bun server/harness/codex/probe.ts rpc "$PWD" config/read '{}'
|
|
35
210
|
```
|
|
36
211
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- Because each turn is a new process, _every_ setting is effectively per-turn
|
|
41
|
-
(`resumeThread(id, newOptions)`) — but there's also no live process to
|
|
42
|
-
interrupt (`AbortSignal` kills it) or steer.
|
|
43
|
-
- Events are **item-level**, not token-level: `thread.started`, `turn.started`,
|
|
44
|
-
`item.started/updated/completed`, `turn.completed { usage }`, `turn.failed`.
|
|
45
|
-
Item union: `agent_message`, `reasoning`, `command_execution` (aggregated
|
|
46
|
-
output + exit code), `file_change` (patch summary), `mcp_tool_call`,
|
|
47
|
-
`web_search`, `todo_list`, `error`.
|
|
48
|
-
- Input: plain string or `{type:"text"}` / `{type:"local_image", path}` — no
|
|
49
|
-
base64 image blocks; uploads must be materialized to disk (we already do
|
|
50
|
-
this for OpenClaw).
|
|
51
|
-
- No model list, no session list API, no MCP status probe, no approval
|
|
52
|
-
callbacks. Structured output via `outputSchema` (JSON Schema/Zod) is the one
|
|
53
|
-
feature CC lacks.
|
|
54
|
-
|
|
55
|
-
Fine for CI-style one-shot runs; too thin for a moi chat harness.
|
|
56
|
-
|
|
57
|
-
## 2. The app-server (`codex app-server`)
|
|
58
|
-
|
|
59
|
-
JSON-RPC 2.0 over **stdio** (newline-delimited JSON, `"jsonrpc"` header
|
|
60
|
-
omitted — same transport style as a stdio MCP server). Other transports
|
|
61
|
-
(unix socket, websocket) exist but stdio is the only production-supported one.
|
|
62
|
-
|
|
63
|
-
### Topology
|
|
64
|
-
|
|
65
|
-
- **One process serves N threads in N different cwds.** `cwd` is per-thread
|
|
66
|
-
(`thread/start`) and overridable per-turn. `thread/loaded/list` shows what's
|
|
67
|
-
in memory; a thread with no subscribers and no activity for 30 min is
|
|
68
|
-
unloaded (`thread/closed`). This replaces most of `claude-code/session.ts`'s
|
|
69
|
-
eviction/idle-TTL machinery.
|
|
70
|
-
- **Env vars are process-level.** There is no per-thread env injection, so
|
|
71
|
-
moi's per-workspace `workspaceEnv` doesn't map onto a single shared process.
|
|
72
|
-
Options: one app-server per workspace (env frozen at spawn, restart on env
|
|
73
|
-
change — same semantics as `restartWorkspaceSessions`), or accept
|
|
74
|
-
process-level env.
|
|
75
|
-
- Handshake: one `initialize` request per connection (with `clientInfo`), then
|
|
76
|
-
an `initialized` notification. Everything before that is rejected.
|
|
77
|
-
- The wire carries three shapes the client must route: responses (matched by
|
|
78
|
-
`id`), notifications, and **server-initiated requests** the client must
|
|
79
|
-
answer (approvals, dynamic tool calls).
|
|
80
|
-
- Backpressure: overload → error `-32001`, retry with backoff.
|
|
81
|
-
- Crash recovery: respawn + `thread/resume` (threads persist in
|
|
82
|
-
`~/.codex/sessions`).
|
|
83
|
-
|
|
84
|
-
### Core flow
|
|
212
|
+
The probe uses the invoking shell's PATH/environment, disables experimental
|
|
213
|
+
fields, and logs raw frames. Use the running moi wire tap to verify workspace
|
|
214
|
+
policy or actual UI behavior.
|
|
85
215
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
turn/start { threadId, input, model?, effort?, outputSchema?, ... }
|
|
89
|
-
← turn/started
|
|
90
|
-
← item/started / item/*/delta / item/completed (per item)
|
|
91
|
-
← turn/completed { status: completed|interrupted|failed }
|
|
92
|
-
turn/steer { expectedTurnId, input } — append input to the RUNNING turn
|
|
93
|
-
turn/interrupt { threadId, turnId }
|
|
94
|
-
```
|
|
216
|
+
Wire types are a hand-written subset, read defensively. Generate reference
|
|
217
|
+
bindings into a temporary directory when changing the integration:
|
|
95
218
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
all. `thread/settings/update` queues setting changes without starting a turn.
|
|
99
|
-
|
|
100
|
-
### additionalContext (native per-turn ambient context)
|
|
101
|
-
|
|
102
|
-
`turn/start` and `turn/steer` take an experimental
|
|
103
|
-
`additionalContext: { <key>: { value, kind: 'untrusted' | 'application' } }`
|
|
104
|
-
map (openai/codex#24154, shipped in 0.135.0, May 2026) — moi uses it for the
|
|
105
|
-
`<moi-context>` envelope (key `moi-context`, kind `application`, so the wire
|
|
106
|
-
tag matches the tag the moi-workspace skill triggers on):
|
|
107
|
-
|
|
108
|
-
- `application` injects a developer-role message `<key>value</key>`;
|
|
109
|
-
`untrusted` a user-role `<external_key>value</external_key>`. Values are
|
|
110
|
-
middle-truncated to a ~1,000-token budget.
|
|
111
|
-
- Send the map every turn; the server diffs per key and injects only when a
|
|
112
|
-
value CHANGED since the last turn — unchanged keys cost nothing.
|
|
113
|
-
- Injected fragments never appear as `userMessage` items (live or on
|
|
114
|
-
`thread/read` replay), so nothing to strip.
|
|
115
|
-
- Gated: requires `initialize.capabilities.experimentalApi: true`, else a
|
|
116
|
-
new-enough server rejects the request when the field is present.
|
|
117
|
-
- Servers < 0.135 have no `deny_unknown_fields` on TurnStartParams and
|
|
118
|
-
silently DROP the field — no error to detect. The only reliable support
|
|
119
|
-
signal is the version in the initialize response's `userAgent`
|
|
120
|
-
(`codex_cli_rs/<semver> …`) — see `codexSupportsAdditionalContext`
|
|
121
|
-
(client.ts). Below the cutoff the session path appends the envelope to the
|
|
122
|
-
text item instead (adapter strips it from echoes).
|
|
123
|
-
|
|
124
|
-
### Feature map vs the adapter checklist
|
|
125
|
-
|
|
126
|
-
- **Models**: `model/list` — models with ordered `supportedReasoningEfforts`,
|
|
127
|
-
exactly what the picker needs.
|
|
128
|
-
- **Streaming**: `item/agentMessage/delta`, `item/reasoning/summaryTextDelta`
|
|
129
|
-
(+ raw `textDelta`), `item/commandExecution/outputDelta` (live command
|
|
130
|
-
output — CC has no equivalent). Per-connection opt-out via
|
|
131
|
-
`initialize.capabilities.optOutNotificationMethods`, so non-streaming mode
|
|
132
|
-
is a handshake flag, not a session rebuild.
|
|
133
|
-
- **Items**: `userMessage` (echoes our `clientUserMessageId` as `clientId` —
|
|
134
|
-
native optimistic-id rendezvous), `agentMessage`, `reasoning`
|
|
135
|
-
(summary vs raw content), `commandExecution` (cwd, exit code, duration),
|
|
136
|
-
`fileChange` (structured per-file diffs), `mcpToolCall`, `collabToolCall`
|
|
137
|
-
(subagents: spawn/send/wait/close), `webSearch`, `todoList`/`plan`
|
|
138
|
-
(`turn/plan/updated`), `imageView`, `contextCompaction`, review items.
|
|
139
|
-
Plus `turn/diff/updated` — an aggregated unified diff for the whole turn.
|
|
140
|
-
- **Approvals**: interactive server→client JSON-RPC requests
|
|
141
|
-
(`item/commandExecution/requestApproval`, `item/fileChange/requestApproval`,
|
|
142
|
-
`item/permissions/requestApproval`) answered with
|
|
143
|
-
`accept | acceptForSession | decline | cancel`. Or delegate with
|
|
144
|
-
`approvalsReviewer: "auto_review"`. Sandbox modes / named permission
|
|
145
|
-
profiles (`:read-only`, `:workspace`).
|
|
146
|
-
- **Input**: `{type:"text"}`, `{type:"image", url:"data:..."}` (inline data
|
|
147
|
-
URL — our base64 upload path works), `{type:"localImage", path}`, plus
|
|
148
|
-
skill invocation items (`{type:"skill", name, path}`).
|
|
149
|
-
- **History**: `thread/list` (cursor pagination, cwd filter, search),
|
|
150
|
-
`thread/read` (without resuming), `thread/turns/list`, archive/unarchive/
|
|
151
|
-
delete, `thread/name/set`. Replaces jsonl-scraping entirely.
|
|
152
|
-
- **MCP**: `mcpServerStatus/list` (tools + auth status — our whole `mcp.ts`
|
|
153
|
-
probe becomes one call), `mcpServer/oauth/login`, `config/mcpServer/reload`.
|
|
154
|
-
- **Usage**: `thread/tokenUsage/updated` streamed live (restored on resume);
|
|
155
|
-
`account/rateLimits/read` + `/updated`, `account/usage/read`.
|
|
156
|
-
- **Errors**: typed `codexErrorInfo` enum (`ContextWindowExceeded`,
|
|
157
|
-
`UsageLimitExceeded`, `HttpConnectionFailed{status}`, …).
|
|
158
|
-
- **Auth**: `account/read`, `account/login/start` (API key / ChatGPT OAuth /
|
|
159
|
-
device code), `account/updated` notifications.
|
|
160
|
-
- **Extras with no CC equivalent**: `review/start` (built-in reviewer),
|
|
161
|
-
`thread/shellCommand` (user `!` commands injected into the turn),
|
|
162
|
-
`command/exec` / `process/spawn` (sandboxed/unsandboxed exec with PTY),
|
|
163
|
-
`fs/*` + `fs/watch`, **dynamic client-provided tools** (`item/tool/call` —
|
|
164
|
-
the agent calls back into moi), `thread/compact/start`, structured
|
|
165
|
-
`outputSchema` per turn.
|
|
166
|
-
|
|
167
|
-
### Caveats
|
|
168
|
-
|
|
169
|
-
- Much of the surface is gated behind `capabilities.experimentalApi` or marked
|
|
170
|
-
under development (plugins, environments, realtime). The core
|
|
171
|
-
thread/turn/item/approval/model surface is stable — it's what the VS Code
|
|
172
|
-
extension runs on.
|
|
173
|
-
- Typed bindings are generated, version-matched to the installed binary:
|
|
174
|
-
`codex app-server generate-ts --out DIR` (or `generate-json-schema`).
|
|
175
|
-
|
|
176
|
-
### Binary availability
|
|
177
|
-
|
|
178
|
-
The adapter resolves `codex` through `../executable.ts`: first a PATH lookup
|
|
179
|
-
over the server's PATH merged with the user's login-shell PATH
|
|
180
|
-
(`../shell-path.ts`), then the known macOS app-bundle locations —
|
|
181
|
-
`/Applications/ChatGPT.app/Contents/Resources/codex` and the legacy
|
|
182
|
-
`/Applications/Codex.app/Contents/Resources/codex` — since Codex Desktop
|
|
183
|
-
manages an app-internal binary that is not shell-visible. PATH wins over the
|
|
184
|
-
bundle probe, so a deliberately installed CLI is never shadowed. If nothing
|
|
185
|
-
resolves, install the CLI with
|
|
186
|
-
`curl -fsSL https://chatgpt.com/codex/install.sh | sh`.
|
|
187
|
-
|
|
188
|
-
## 3. Client libraries
|
|
189
|
-
|
|
190
|
-
- **TypeScript: nothing official.** `@openai/codex-sdk` wraps exec only.
|
|
191
|
-
- **Python: official** — `openai-codex` on PyPI (`sdk/python` in openai/codex)
|
|
192
|
-
is a real app-server client: subprocess + stdio JSON-RPC, message router,
|
|
193
|
-
generated pydantic models, approval handler callbacks. Good design
|
|
194
|
-
reference.
|
|
195
|
-
- Community TS/JS bridges exist (see the
|
|
196
|
-
[`codex-app-server` GitHub topic](https://github.com/topics/codex-app-server))
|
|
197
|
-
but are small/young.
|
|
198
|
-
- **Plan for moi**: write the thin client ourselves (~200 lines in Bun — spawn,
|
|
199
|
-
line-split stdio, id→promise map, notification + server-request routing;
|
|
200
|
-
same pattern as `../openclaw/gateway.ts`) and use `generate-ts` for
|
|
201
|
-
types.
|
|
202
|
-
|
|
203
|
-
## 4. Adapter shape
|
|
204
|
-
|
|
205
|
-
A Codex harness would look much closer to `openclaw/session.ts` than
|
|
206
|
-
`claude-code/session.ts`: one long-lived connection to a server that owns session
|
|
207
|
-
lifecycle, subscribe per thread, map `item/*` notifications onto
|
|
208
|
-
`StreamEvent`s. Capability flags: `liveSettingsPerTurn`, `steering`,
|
|
209
|
-
`interactiveApprovals`, `nativeThreadList`, `imagesInline: 'data-url'`.
|
|
210
|
-
|
|
211
|
-
## 5. Implementation notes (shipped, CLI 0.144.5)
|
|
212
|
-
|
|
213
|
-
The adapter landed as `client.ts` (process + stdio JSON-RPC client, one
|
|
214
|
-
app-server per workspace for env injection), `adapter.ts` (item →
|
|
215
|
-
`Turn` mapping, hand-written types), and `session.ts` (per-thread
|
|
216
|
-
state, steer/interrupt, previews, usage). Empirical findings beyond §2:
|
|
217
|
-
|
|
218
|
-
- **Always pass absolute `cwd`.** A relative `thread/start.cwd` is resolved
|
|
219
|
-
against the app-server process cwd, silently nesting paths.
|
|
220
|
-
- **Deltas stream by default** — no opt-in needed; moi's `stream` flag only
|
|
221
|
-
gates forwarding them as preview frames.
|
|
222
|
-
- **Reasoning summaries need `summary: "auto"` on `turn/start`.** Without it
|
|
223
|
-
the model still reasons (nonzero `reasoningOutputTokens`) but the
|
|
224
|
-
`reasoning` item arrives with EMPTY `summary`/`content` — thinking is
|
|
225
|
-
invisible. With it, summaries stream via `item/reasoning/summaryTextDelta`
|
|
226
|
-
and land populated. Also note reasoning is adaptive: trivial prompts at low
|
|
227
|
-
effort legitimately produce no reasoning item at all.
|
|
228
|
-
- **Subagents (collab tools) work unflagged**: the parent emits
|
|
229
|
-
`collabAgentToolCall` (spawn/send/wait/close) and `subAgentActivity` items;
|
|
230
|
-
the child agent runs as its own thread whose full item stream arrives on
|
|
231
|
-
the same connection under `agentThreadId`.
|
|
232
|
-
- **`clientUserMessageId` echo confirmed**: the `userMessage` item carries it
|
|
233
|
-
as `clientId`, on live frames only. `thread/read` replay _renumbers_ item
|
|
234
|
-
ids (`item-1`, `item-2`, …) and drops `clientId`, so replayed turn ids never
|
|
235
|
-
match live ones — harmless under upsert-by-id, but don't key anything
|
|
236
|
-
durable on them.
|
|
237
|
-
- **`turn/completed` carries no items** (`itemsView: "notLoaded"`); items
|
|
238
|
-
arrive only via `item/started`/`item/completed`.
|
|
239
|
-
- **The npm `codex` bin is a Node shim** that spawns the platform binary;
|
|
240
|
-
killing the shim tears down the server via stdin EOF, so no orphans. The
|
|
241
|
-
absolute shim path returned by the PATH lookup is safe to spawn.
|
|
242
|
-
- **Rollout files double as a discovery index.** Each thread persists to
|
|
243
|
-
`~/.codex/sessions/YYYY/MM/DD/rollout-<timestamp>-<uuid>.jsonl` whose first
|
|
244
|
-
line is a `session_meta` record with the thread's `cwd` (older formats put
|
|
245
|
-
the meta fields at the top level). `discovery.ts` reads those heads directly
|
|
246
|
-
— workspace discovery works without the binary installed.
|
|
247
|
-
- **User-level config bleeds in**: threads start MCP servers and hooks from
|
|
248
|
-
`~/.codex/config.toml` / `hooks.json` per thread; their failures arrive as
|
|
249
|
-
notifications (`mcpServer/startupStatus/updated`, `hook/completed`) we
|
|
250
|
-
currently ignore.
|
|
251
|
-
- `thread/start` responses label threads `source: "vscode"` — app-server
|
|
252
|
-
clients are indistinguishable from the VS Code extension in `thread/list`.
|
|
253
|
-
|
|
254
|
-
## 6. MCP servers & connectors (probed at CLI 0.144.5)
|
|
255
|
-
|
|
256
|
-
One-off probe: `bun server/harness/codex/probe.ts rpc . mcpServerStatus/list '{}'`.
|
|
257
|
-
|
|
258
|
-
### `mcpServerStatus/list` payload
|
|
259
|
-
|
|
260
|
-
`{ data: McpServerStatus[] }`, one entry per server Codex loaded:
|
|
261
|
-
|
|
262
|
-
- `name` — the registry key (config.toml table name, or injected name).
|
|
263
|
-
- `serverInfo` — the server's MCP `initialize` result (`name`, `title`,
|
|
264
|
-
`version`, `description`, `icons`, `websiteUrl`), `null` if it never
|
|
265
|
-
answered. A server can list with `serverInfo: null` and an empty `tools`
|
|
266
|
-
map and still be "configured" — that's what a dead/misbehaving remote
|
|
267
|
-
looks like (no error field).
|
|
268
|
-
- `tools` — a **map keyed by tool name**, each value a full MCP tool def:
|
|
269
|
-
`name`, `title`, `description`, `inputSchema`, `outputSchema`,
|
|
270
|
-
`annotations` (`readOnlyHint`/`destructiveHint`/`openWorldHint`), `_meta`.
|
|
271
|
-
This payload is BIG (~0.5 MB with ChatGPT connectors installed) — don't
|
|
272
|
-
fold it into anything broadcast.
|
|
273
|
-
- `resources`, `resourceTemplates` — arrays.
|
|
274
|
-
- `authStatus` — `bearerToken` (authed HTTP/OAuth), `notLoggedIn` (OAuth
|
|
275
|
-
awaiting `mcpServer/oauth/login`; the one `getCodexMcpStatus` maps to
|
|
276
|
-
`needs-auth`), `unsupported` (stdio server, no auth concept).
|
|
277
|
-
|
|
278
|
-
### `codex_apps` — the ChatGPT connector aggregator
|
|
279
|
-
|
|
280
|
-
Injected automatically when signed in with a ChatGPT account; **absent from
|
|
281
|
-
config.toml**. `serverInfo.name` is `plugin-runtime`. It flattens every
|
|
282
|
-
connector installed on the user's ChatGPT account (GitHub, Figma, Granola, …)
|
|
283
|
-
into ONE server whose tool names are dotted `<connector>.<tool>`
|
|
284
|
-
(`figma.generate_deck`). The true brand lives in each tool's `_meta`:
|
|
285
|
-
`connector_id`, `connector_name` ("Figma"), `connector_description`,
|
|
286
|
-
`link_id` (the user's authorization to that connector), plus Apps SDK widget
|
|
287
|
-
hints (`openai/outputTemplate: "ui://widget/….html"`). This is why the
|
|
288
|
-
client's `parseCodexMcp` brands dotted `codex_apps` calls by the prefix
|
|
289
|
-
before the dot, not the server name. The adapter does not currently carry
|
|
290
|
-
`_meta.connector_name` through to the `ToolCall` — icon/brand matching is
|
|
291
|
-
name-based.
|
|
292
|
-
|
|
293
|
-
### Where MCP servers can be defined (config layers)
|
|
294
|
-
|
|
295
|
-
From the 0.144.5 binary's config-layer enum, lowest to highest:
|
|
296
|
-
|
|
297
|
-
1. **User** — `$CODEX_HOME/config.toml` (`[mcp_servers.<name>]`). Shared by
|
|
298
|
-
three writers: hand edits, `codex mcp add/remove`, and other apps (the
|
|
299
|
-
ChatGPT desktop app writes `node_repl` / `computer-use` entries here).
|
|
300
|
-
2. **Profile v2** — `$CODEX_HOME/<name>.config.toml`, layered via `-p <name>`
|
|
301
|
-
(legacy `[profiles.<name>]` tables in config.toml also exist).
|
|
302
|
-
3. **Project** — `.codex/config.toml` in a trusted repo ("sandbox, MCP,
|
|
303
|
-
hooks, model, or reasoning defaults").
|
|
304
|
-
4. **Session flags** — `-c 'mcp_servers.foo.command="…"'` per invocation.
|
|
305
|
-
5. **Plugins** — an enabled plugin can provide MCP servers ("not configured
|
|
306
|
-
in config.toml or an enabled plugin").
|
|
307
|
-
6. **Account-injected** — `codex_apps` (above); server-side, no local file.
|
|
308
|
-
7. **Admin layers** — system config.toml, MDM managed preferences, legacy
|
|
309
|
-
`managed_config.toml`, and an enterprise-managed cloud layer;
|
|
310
|
-
`requirements.toml` restricts (never defines) what the others may set.
|
|
311
|
-
|
|
312
|
-
The app-server can also edit the user layer programmatically
|
|
313
|
-
(`config/value/write`, `config/batchWrite`) — unused by moi.
|
|
314
|
-
|
|
315
|
-
### The full MCP RPC surface (from the 0.144.5 binary's method enums)
|
|
316
|
-
|
|
317
|
-
Requests:
|
|
318
|
-
|
|
319
|
-
- `mcpServerStatus/list` — the registry dump above.
|
|
320
|
-
- `mcpServer/tool/call` — **direct one-off tool invocation, no model turn**:
|
|
321
|
-
`{ threadId, server, tool, arguments }` → a raw MCP `CallToolResult`
|
|
322
|
-
(`{ content: [...], isError }`). Requires a live `threadId` (MCP servers
|
|
323
|
-
are started per thread), but `thread/start` + call works without ever
|
|
324
|
-
running a turn — verified against `mastra_docs`. Argument validation
|
|
325
|
-
errors come back as `isError: true` content, not JSON-RPC errors.
|
|
326
|
-
- `mcpServer/resource/read` — read an MCP resource by uri.
|
|
327
|
-
- `mcpServer/oauth/login` — start OAuth for a `notLoggedIn` server;
|
|
328
|
-
completion arrives as the `mcpServer/oauthLogin/completed` notification.
|
|
329
|
-
- `config/mcpServer/reload` — re-read server definitions without a restart.
|
|
330
|
-
- `config/read`, `config/value/write`, `config/batchWrite`,
|
|
331
|
-
`configRequirements/read` — inspect/edit the config layers that define
|
|
332
|
-
servers.
|
|
333
|
-
|
|
334
|
-
Notifications: `mcpServer/startupStatus/updated` (per-thread startup
|
|
335
|
-
progress/failures — we currently ignore it), `mcpServer/oauthLogin/completed`,
|
|
336
|
-
`item/mcpToolCall/progress` (progress of an in-turn MCP call).
|
|
337
|
-
|
|
338
|
-
Server→client request: `mcpServer/elicitation/request` — an MCP server
|
|
339
|
-
asking the user for input mid-call, forwarded for the client to answer.
|
|
340
|
-
|
|
341
|
-
## 7. Type maintenance (`generate-ts`)
|
|
342
|
-
|
|
343
|
-
The wire types in `adapter.ts`/`client.ts` are a hand-written defensive
|
|
344
|
-
subset of the protocol, produced against the bindings from:
|
|
345
|
-
|
|
346
|
-
```
|
|
347
|
-
codex app-server generate-ts --out /tmp/codex-types # CLI 0.144.5
|
|
219
|
+
```sh
|
|
220
|
+
codex app-server generate-ts --experimental --out /tmp/moi-codex-protocol
|
|
348
221
|
```
|
|
349
222
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
against the subset here.
|
|
223
|
+
Compare the relevant `ServerRequest`, `ServerNotification`, and `v2` types;
|
|
224
|
+
do not generate bindings during builds or require an installed CLI in CI.
|
|
225
|
+
Tests are colocated; run `bun test server/harness/codex` for the harness suite.
|
|
226
|
+
Protocol presence alone is not UI support: review/fork controls, account usage
|
|
227
|
+
limits, direct MCP operations, and general structured chat output are not
|
|
228
|
+
exposed by this harness.
|