@kabmo-labs/kabmo 0.27.0 → 0.29.0
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/bunfig.toml +6 -0
- package/dist/client/index.html +2 -2
- package/dist/client/index.js +530 -493
- package/dist/client/static/js/{index-e3qh2yps.js → index-43z47ngg.js} +1178 -1034
- package/dist/client/static/js/index-naa91727.css +1 -0
- package/dist/client/static/{manifest-q6h8k9e0.webmanifest → manifest-vdvdqpre.webmanifest} +1 -0
- package/marketplace/plugins/command-runner/package.json +3 -17
- package/marketplace/plugins/command-runner/settings-schema.json +14 -0
- package/marketplace/plugins/git-forge/README.md +17 -7
- package/marketplace/plugins/git-forge/package.json +4 -30
- package/marketplace/plugins/git-forge/panel.css +16 -0
- package/marketplace/plugins/git-forge/settings-schema.json +27 -0
- package/marketplace/plugins/git-forge/src/panel/Badge.tsx +35 -22
- package/marketplace/plugins/git-forge/src/panel/Change.tsx +20 -24
- package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +16 -7
- package/marketplace/plugins/git-forge/src/panel/Credential.tsx +31 -26
- package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +18 -2
- package/marketplace/plugins/git-forge/src/panel/Header.tsx +160 -96
- package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +60 -44
- package/marketplace/plugins/git-forge/src/panel/List.tsx +150 -22
- package/marketplace/plugins/git-forge/src/panel/Row.tsx +11 -5
- package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +17 -15
- package/marketplace/plugins/git-forge/src/panel/Write.tsx +84 -61
- package/marketplace/plugins/git-forge/src/panel/format.test.ts +99 -0
- package/marketplace/plugins/git-forge/src/panel/format.ts +59 -16
- package/marketplace/plugins/git-forge/src/panel/index.test.tsx +109 -5
- package/marketplace/plugins/git-forge/src/panel/index.tsx +37 -4
- package/marketplace/plugins/git-forge/src/panel/use-forge.ts +17 -0
- package/marketplace/plugins/git-forge/src/panel/write.test.tsx +31 -0
- package/marketplace/plugins/session-info/package.json +2 -10
- package/marketplace/plugins/session-info/settings-schema.json +8 -0
- package/marketplace/plugins/stats/README.md +17 -5
- package/marketplace/plugins/stats/package.json +3 -23
- package/marketplace/plugins/stats/settings-schema.json +20 -0
- package/marketplace/plugins/stats/src/app.tsx +1 -1
- package/marketplace/plugins/stats/src/groups.test.ts +46 -1
- package/marketplace/plugins/stats/src/groups.ts +22 -11
- package/marketplace/plugins/stats/src/harness-leases.test.ts +84 -0
- package/marketplace/plugins/stats/src/harness-leases.ts +132 -0
- package/marketplace/plugins/stats/src/labels.test.ts +54 -1
- package/marketplace/plugins/stats/src/labels.ts +33 -7
- package/marketplace/plugins/stats/src/sampler.test.ts +61 -0
- package/marketplace/plugins/stats/src/sampler.ts +39 -5
- package/marketplace/plugins/stats/src/snapshot.ts +6 -0
- package/package.json +4 -3
- package/public/manifest.webmanifest +1 -0
- package/src/client/components/common/ComposerTextarea.test.tsx +109 -0
- package/src/client/components/common/ComposerTextarea.tsx +6 -0
- package/src/client/components/common/ReloadPageButton.test.tsx +14 -0
- package/src/client/components/common/ReloadPageButton.tsx +11 -2
- package/src/client/components/common/diagram-viewer/read-block.test.ts +71 -0
- package/src/client/components/common/diagram-viewer/read-block.ts +40 -16
- package/src/client/components/common/file-icon/index.tsx +7 -1
- package/src/client/components/common/harness-glyph/brands.ts +7 -1
- package/src/client/components/common/harness-glyph/index.tsx +18 -1
- package/src/client/components/common/image-viewer/index.tsx +37 -165
- package/src/client/components/common/picker-search/index.tsx +70 -0
- package/src/client/components/common/search-select/index.tsx +2 -7
- package/src/client/components/common/session-actions-menu/index.test.tsx +106 -0
- package/src/client/components/common/session-actions-menu/index.tsx +43 -1
- package/src/client/components/common/session-row/TrailingSlot.tsx +9 -4
- package/src/client/components/common/session-row/index.tsx +4 -0
- package/src/client/components/common/session-row/session-row.test.tsx +6 -0
- package/src/client/components/common/zoom-pan-stage/index.tsx +258 -0
- package/src/client/components/common/zoom-pan-stage/zoom-pan-stage.test.tsx +87 -0
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +2 -1
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +1 -1
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +9 -1
- package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +7 -3
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +4 -1
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +12 -1
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.test.tsx +82 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +23 -3
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +1 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +2 -1
- package/src/client/components/layout/session-sidebar/modern/index.tsx +1 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +202 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +80 -19
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +29 -7
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +3 -0
- package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +8 -0
- package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +181 -0
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +41 -86
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +6 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +9 -1
- package/src/client/components/settings/Modal.tsx +6 -2
- package/src/client/components/settings/Sidebar.tsx +32 -7
- package/src/client/components/settings/categories/HarnessSettings.tsx +15 -9
- package/src/client/components/settings/categories/NotificationSettings.test.tsx +40 -15
- package/src/client/components/settings/categories/NotificationSettings.tsx +142 -64
- package/src/client/components/settings/categories/PanelPluginSettings.tsx +3 -3
- package/src/client/components/settings/categories/PluginSettings.tsx +1 -1
- package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +3 -6
- package/src/client/components/settings/categories/harness-settings/CustomHarnessForm.tsx +186 -0
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +36 -0
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +11 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +1 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +15 -1
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +1 -3
- package/src/client/components/settings/categories/panel-plugins/SettingsModal.test.tsx +165 -0
- package/src/client/components/settings/categories/panel-plugins/SettingsModal.tsx +260 -0
- package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +18 -4
- package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +64 -61
- package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +15 -4
- package/src/client/components/settings/groups.test.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +24 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +8 -4
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +34 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -2
- package/src/client/components/workspace/chat-timeline/IrcNotice.test.tsx +55 -0
- package/src/client/components/workspace/chat-timeline/IrcNotice.tsx +71 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.fork.test.ts +80 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +13 -4
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +8 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +9 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +4 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +19 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +32 -3
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.search.test.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +53 -33
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +5 -5
- package/src/client/components/workspace/chat-timeline/index.tsx +11 -5
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +1 -9
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +129 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +30 -12
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +47 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +55 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +3 -2
- package/src/client/components/workspace/editor/FilePane.tsx +41 -4
- package/src/client/components/workspace/editor/Notices.tsx +2 -2
- package/src/client/components/workspace/editor/Pane.tsx +2 -2
- package/src/client/components/workspace/editor/Toolbar.tsx +20 -10
- package/src/client/components/workspace/editor/index.tsx +6 -10
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +5 -3
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +26 -14
- package/src/client/components/workspace/editor/viewers/CsvGrid.tsx +52 -5
- package/src/client/components/workspace/editor/viewers/DataGrid.tsx +227 -41
- package/src/client/components/workspace/editor/viewers/DrawioView.tsx +93 -0
- package/src/client/components/workspace/editor/viewers/GridRow.tsx +91 -0
- package/src/client/components/workspace/editor/viewers/GridToolbar.tsx +53 -0
- package/src/client/components/workspace/editor/viewers/SheetView.tsx +152 -57
- package/src/client/components/workspace/editor/viewers/dispatch.tsx +42 -9
- package/src/client/components/workspace/editor/viewers/drawio-pages.test.ts +80 -0
- package/src/client/components/workspace/editor/viewers/drawio-pages.ts +63 -0
- package/src/client/components/workspace/editor/viewers/grid.test.ts +296 -0
- package/src/client/components/workspace/editor/viewers/use-cell-edit.ts +64 -0
- package/src/client/components/workspace/editor/viewers/use-grid-interaction.ts +216 -0
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +47 -2
- package/src/client/components/workspace/editor/viewers/workbook.ts +149 -0
- package/src/client/components/workspace/file-explorer/ArchiveModals.tsx +262 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +30 -6
- package/src/client/components/workspace/file-explorer/Modals.tsx +8 -3
- package/src/client/components/workspace/file-explorer/RootOverlays.tsx +60 -0
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +6 -2
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +39 -49
- package/src/client/components/workspace/file-explorer/TreeItemModals.tsx +80 -0
- package/src/client/components/workspace/file-explorer/index.tsx +53 -29
- package/src/client/components/workspace/file-explorer/selection.test.tsx +109 -0
- package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +9 -1
- package/src/client/components/workspace/terminal-panel/focus.test.ts +70 -0
- package/src/client/components/workspace/terminal-panel/focus.ts +46 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +14 -1
- package/src/client/components/workspace/terminal-panel/mount.ts +17 -9
- package/src/client/components/workspace/terminal-panel/scroll-hold.test.ts +158 -0
- package/src/client/components/workspace/terminal-panel/scroll-hold.ts +136 -0
- package/src/client/data/settings/omp-schema.json +169 -22
- package/src/client/glass.css +39 -14
- package/src/client/glass.test.ts +37 -0
- package/src/client/hooks/chat/composer/history.test.ts +267 -0
- package/src/client/hooks/chat/composer/history.ts +146 -0
- package/src/client/hooks/chat/composer/use-draft.ts +45 -1
- package/src/client/hooks/chat/omp/pending-sessions.waiting.test.ts +11 -10
- package/src/client/hooks/chat/omp/pending-waiting.ts +15 -7
- package/src/client/hooks/chat/omp/prompt-send.test.ts +11 -0
- package/src/client/hooks/chat/omp/prompt-send.ts +3 -0
- package/src/client/hooks/chat/timeline/actions.ts +4 -4
- package/src/client/hooks/chat/timeline/ask-frames.test.ts +54 -0
- package/src/client/hooks/chat/timeline/ask-frames.ts +29 -1
- package/src/client/hooks/chat/timeline/composer-modes.ts +13 -2
- package/src/client/hooks/chat/timeline/fork-open.ts +52 -0
- package/src/client/hooks/chat/timeline/index.ts +5 -2
- package/src/client/hooks/chat/timeline/mode-availability.ts +7 -0
- package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
- package/src/client/hooks/chat/timeline/modes-hydrate.ts +93 -0
- package/src/client/hooks/chat/timeline/modes.ts +32 -52
- package/src/client/hooks/chat/timeline/new-chat-open.ts +7 -6
- package/src/client/hooks/chat/timeline/new-chat.ts +10 -1
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +4 -0
- package/src/client/hooks/chat/timeline/pending-session-mode.test.ts +136 -0
- package/src/client/hooks/chat/timeline/pending-session-mode.ts +69 -0
- package/src/client/hooks/chat/timeline/pending-warmup.test.ts +147 -0
- package/src/client/hooks/chat/timeline/pending-warmup.ts +62 -0
- package/src/client/hooks/chat/timeline/run-identity.test.ts +12 -0
- package/src/client/hooks/chat/timeline/run-identity.ts +4 -1
- package/src/client/hooks/chat/timeline/send-props.ts +2 -0
- package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -0
- package/src/client/hooks/chat/timeline/send.test-util.ts +1 -0
- package/src/client/hooks/chat/timeline/send.test.ts +1 -0
- package/src/client/hooks/chat/timeline/session-harness.ts +4 -0
- package/src/client/hooks/chat/timeline/timeline-rail.test.ts +34 -2
- package/src/client/hooks/chat/timeline/use-fork-session.ts +9 -22
- package/src/client/hooks/chat/timeline/user-turns.ts +31 -2
- package/src/client/hooks/chat/waiting/cancel.ts +13 -6
- package/src/client/hooks/chat/waiting/choice.ts +13 -16
- package/src/client/hooks/chat/waiting/composer-wait.ts +70 -0
- package/src/client/hooks/chat/waiting/dispatch.ts +48 -28
- package/src/client/hooks/chat/waiting/held.ts +37 -13
- package/src/client/hooks/chat/waiting/hold.test.ts +22 -0
- package/src/client/hooks/chat/waiting/hold.ts +20 -11
- package/src/client/hooks/chat/waiting/restore.test.ts +69 -0
- package/src/client/hooks/chat/waiting/restore.ts +34 -0
- package/src/client/hooks/chat/waiting/store.ts +9 -3
- package/src/client/hooks/editor/file-editor-types.ts +36 -12
- package/src/client/hooks/editor/save-bytes.ts +79 -0
- package/src/client/hooks/editor/save-file.test.ts +1 -1
- package/src/client/hooks/editor/save-file.ts +35 -8
- package/src/client/hooks/editor/target-key.ts +17 -0
- package/src/client/hooks/editor/use-disk-digest.test.ts +82 -0
- package/src/client/hooks/editor/use-disk-digest.ts +164 -0
- package/src/client/hooks/editor/use-disk-sync.ts +212 -0
- package/src/client/hooks/editor/use-file-cache.ts +113 -0
- package/src/client/hooks/editor/use-file-editor.test.ts +120 -0
- package/src/client/hooks/editor/use-file-editor.ts +143 -57
- package/src/client/hooks/editor/use-file-read.ts +45 -12
- package/src/client/hooks/editor/use-file-writes.ts +4 -4
- package/src/client/hooks/editor/use-grid-selection.ts +160 -0
- package/src/client/hooks/models/harness-catalog.ts +15 -0
- package/src/client/hooks/models/use-harness-update.test.ts +35 -2
- package/src/client/hooks/models/use-harness-update.ts +49 -10
- package/src/client/hooks/ui/notifications.ts +17 -8
- package/src/client/hooks/workspace/diff-file.test.ts +72 -0
- package/src/client/hooks/workspace/diff-file.ts +12 -6
- package/src/client/hooks/workspace/file-archive.ts +220 -0
- package/src/client/hooks/workspace/file-clipboard.test.ts +4 -4
- package/src/client/hooks/workspace/file-clipboard.ts +37 -26
- package/src/client/hooks/workspace/file-selection.test.ts +67 -0
- package/src/client/hooks/workspace/file-selection.ts +156 -0
- package/src/client/hooks/workspace/file-tree-actions-clipboard.test.ts +5 -5
- package/src/client/hooks/workspace/file-tree-actions.ts +36 -8
- package/src/client/hooks/workspace/panel-registry.ts +1 -1
- package/src/client/hooks/workspace/scheduled-tasks.ts +26 -11
- package/src/client/lib/editor/workbook-drafts.ts +42 -0
- package/src/client/lib/launch/file-handlers.ts +2 -2
- package/src/client/lib/notifications/os.test.ts +1 -30
- package/src/client/lib/notifications/os.ts +0 -15
- package/src/client/lib/notifications/platform.test.ts +68 -0
- package/src/client/lib/notifications/platform.ts +36 -0
- package/src/client/lib/scrollbar-activity.test.ts +21 -88
- package/src/client/lib/scrollbar-activity.ts +71 -73
- package/src/client/lib/scrollbar-events.ts +143 -0
- package/src/client/lib/scrollbar-input.test.ts +126 -0
- package/src/client/lib/scrollbar-probe.test-util.ts +107 -0
- package/src/client/tailwind.css +32 -1
- package/src/server/db.server.test.ts +50 -1
- package/src/server/db.server.ts +36 -3
- package/src/server/index.ts +7 -0
- package/src/server/lib/chat/prompt-history.server.test.ts +92 -0
- package/src/server/lib/chat/prompt-history.server.ts +65 -0
- package/src/server/lib/chat/schema.server.ts +35 -0
- package/src/server/lib/db/schema.ts +3 -0
- package/src/server/lib/fs/archive.test.ts +139 -0
- package/src/server/lib/fs/archive.ts +259 -0
- package/src/server/lib/fs/git-diff.test.ts +26 -1
- package/src/server/lib/fs/git-diff.ts +43 -15
- package/src/server/lib/harness/acp/client.ts +81 -87
- package/src/server/lib/harness/acp/prewarm.server.ts +237 -0
- package/src/server/lib/harness/acp/prewarm.test.ts +171 -0
- package/src/server/lib/harness/acp/prompt.test.ts +70 -1
- package/src/server/lib/harness/acp/prompt.ts +32 -1
- package/src/server/lib/harness/acp/protocol.ts +23 -0
- package/src/server/lib/harness/acp/session-handshake.test.ts +26 -0
- package/src/server/lib/harness/acp/session-handshake.ts +22 -20
- package/src/server/lib/harness/acp/session-options.ts +16 -0
- package/src/server/lib/harness/acp/session-process.ts +43 -0
- package/src/server/lib/harness/acp/session.ts +11 -12
- package/src/server/lib/harness/acp/stdio.ts +129 -0
- package/src/server/lib/harness/acp/verbs.test.ts +97 -0
- package/src/server/lib/harness/acp/verbs.ts +16 -6
- package/src/server/lib/harness/auto-probe.server.ts +4 -3
- package/src/server/lib/harness/capabilities.ts +8 -0
- package/src/server/lib/harness/config.server.ts +3 -2
- package/src/server/lib/harness/custom.server.ts +209 -0
- package/src/server/lib/harness/launch-table.ts +19 -0
- package/src/server/lib/harness/launch.ts +6 -1
- package/src/server/lib/harness/provider-entry.ts +1 -1
- package/src/server/lib/harness/provider-file.server.ts +1 -1
- package/src/server/lib/harness/provider-sources.server.ts +2 -1
- package/src/server/lib/harness/provider-write.server.ts +2 -1
- package/src/server/lib/harness/register.server.ts +8 -1
- package/src/server/lib/harness/schema.server.ts +21 -0
- package/src/server/lib/harness/session-lease.server.test.ts +99 -0
- package/src/server/lib/harness/session-lease.server.ts +193 -0
- package/src/server/lib/harness/session-store.server.test.ts +8 -8
- package/src/server/lib/harness/session-store.server.ts +25 -4
- package/src/server/lib/harness/session-title.server.ts +12 -2
- package/src/server/lib/harness/spawn.server.ts +123 -20
- package/src/server/lib/harness/update-job-store.ts +12 -0
- package/src/server/lib/harness/update-queue.server.ts +18 -13
- package/src/server/lib/lifecycle/after-listen.ts +12 -1
- package/src/server/lib/lifecycle/paths.ts +19 -1
- package/src/server/lib/mcp/registry.server.ts +155 -0
- package/src/server/lib/mcp/registry.test.ts +169 -0
- package/src/server/lib/mcp/store.server.ts +38 -0
- package/src/server/lib/omp/rpc/frame-fold-contract.ts +59 -0
- package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +64 -1
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +2 -1
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +5 -1
- package/src/server/lib/omp/rpc/frame-fold.test.ts +7 -2
- package/src/server/lib/omp/rpc/frame-fold.ts +6 -45
- package/src/server/lib/omp/rpc/lifecycle.test.ts +4 -0
- package/src/server/lib/omp/rpc/prewarm-pool.ts +19 -5
- package/src/server/lib/omp/rpc/run-model.test.ts +116 -0
- package/src/server/lib/omp/rpc/run-model.ts +4 -2
- package/src/server/lib/omp/session/auto-title.server.test.ts +4 -0
- package/src/server/lib/omp/session/delete.server.ts +1 -0
- package/src/server/lib/omp/session/goal-driver.test.ts +5 -1
- package/src/server/lib/omp/session/goal-settings.test.ts +5 -1
- package/src/server/lib/omp/session/sidebar-data.harness.test.ts +6 -3
- package/src/server/lib/omp/session/standby.server.ts +13 -2
- package/src/server/lib/panels/auto-update.server.test.ts +5 -2
- package/src/server/lib/panels/git-update.server.test.ts +5 -2
- package/src/server/lib/panels/install.server.test.ts +5 -2
- package/src/server/lib/panels/manifest.test.ts +47 -1
- package/src/server/lib/panels/manifest.ts +19 -0
- package/src/server/lib/panels/registry.server.ts +19 -2
- package/src/server/lib/panels/remove.server.test.ts +5 -2
- package/src/server/lib/panels/scan.server.ts +26 -2
- package/src/server/lib/panels/settings-schema.server.ts +72 -0
- package/src/server/lib/plugins/background.server.ts +21 -3
- package/src/server/lib/plugins/background.test.ts +13 -0
- package/src/server/lib/plugins/loader.server.ts +35 -51
- package/src/server/lib/plugins/mcp.server.ts +100 -0
- package/src/server/lib/plugins/mcp.test.ts +75 -0
- package/src/server/lib/plugins/schedule-runner.server.ts +153 -0
- package/src/server/lib/plugins/schedule-runner.test.ts +186 -0
- package/src/server/lib/plugins/schedule-store.server.ts +107 -0
- package/src/server/lib/plugins/schema.server.ts +8 -0
- package/src/server/lib/plugins/settings.server.ts +56 -19
- package/src/server/lib/plugins/shutdown.server.ts +58 -0
- package/src/server/lib/plugins/shutdown.test.ts +28 -3
- package/src/server/lib/realtime/topics/global.server.ts +5 -1
- package/src/server/lib/schedule/rows.server.ts +9 -0
- package/src/server/lib/schedule/runtime.server.test.ts +91 -0
- package/src/server/lib/schedule/runtime.server.ts +101 -23
- package/src/server/lib/schedule/schema.server.ts +15 -0
- package/src/server/lib/schedule/store.server.test.ts +34 -0
- package/src/server/lib/schedule/store.server.ts +33 -9
- package/src/server/lib/sessions/fork.server.test.ts +47 -0
- package/src/server/lib/sessions/fork.server.ts +17 -1
- package/src/server/lib/sessions/spawn.server.ts +2 -2
- package/src/server/lib/waiting/runtime.server.test.ts +48 -0
- package/src/server/lib/waiting/runtime.server.ts +22 -0
- package/src/server/lib/waiting/schema.server.ts +8 -0
- package/src/server/lib/waiting/store.server.test.ts +14 -0
- package/src/server/lib/waiting/store.server.ts +6 -2
- package/src/server/routes/agent/command-resume.test.ts +9 -4
- package/src/server/routes/agent/command.ts +11 -0
- package/src/server/routes/agent/new-mode.test.ts +40 -0
- package/src/server/routes/agent/new.ts +36 -10
- package/src/server/routes/agent/prewarm.ts +48 -7
- package/src/server/routes/chat/index.ts +5 -0
- package/src/server/routes/chat/prompt-history.test.ts +67 -0
- package/src/server/routes/chat/prompt-history.ts +31 -0
- package/src/server/routes/chat/stream.test.ts +21 -0
- package/src/server/routes/chat/stream.ts +5 -0
- package/src/server/routes/fs/action-archive.test.ts +128 -0
- package/src/server/routes/fs/action-bulk.ts +106 -0
- package/src/server/routes/fs/action-save-bytes.test.ts +59 -0
- package/src/server/routes/fs/action-transfer.test.ts +26 -0
- package/src/server/routes/fs/action.ts +100 -12
- package/src/server/routes/fs/archive.ts +20 -0
- package/src/server/routes/fs/digest.test.ts +100 -0
- package/src/server/routes/fs/digest.ts +106 -0
- package/src/server/routes/fs/grant.test.ts +5 -2
- package/src/server/routes/fs/index.ts +4 -0
- package/src/server/routes/fs/read.ts +6 -1
- package/src/server/routes/fs/scope.test.ts +6 -2
- package/src/server/routes/harness/custom.test.ts +131 -0
- package/src/server/routes/harness/import-action.ts +3 -3
- package/src/server/routes/harness/root.ts +47 -9
- package/src/server/routes/harness/summary.test.ts +50 -0
- package/src/server/routes/harness/update-status.ts +41 -2
- package/src/server/routes/harness/update.test.ts +56 -2
- package/src/server/routes/harness/update.ts +2 -2
- package/src/server/routes/panels/bindings.ts +2 -0
- package/src/server/routes/panels/settings.test.ts +165 -0
- package/src/server/routes/panels/settings.ts +106 -0
- package/src/server/routes/schedule/body.ts +14 -0
- package/src/server/routes/schedule/index.ts +28 -4
- package/src/server/routes/sessions/delete.test.ts +4 -0
- package/src/server/routes/settings/mcp.ts +9 -26
- package/src/server/routes/waiting/index.ts +21 -2
- package/src/server/routes/waiting/routes.test.ts +21 -0
- package/src/shared/lib/chat/ask-form/index.ts +39 -31
- package/src/shared/lib/chat/ask-form/labels.ts +46 -0
- package/src/shared/lib/chat/ask-form/tokens.ts +11 -2
- package/src/shared/lib/chat/ask-form.test.ts +57 -0
- package/src/shared/lib/chat/ask-questions.ts +31 -0
- package/src/shared/lib/chat/composer/delegation.ts +3 -3
- package/src/shared/lib/chat/composer/history.test.ts +67 -0
- package/src/shared/lib/chat/composer/history.ts +61 -0
- package/src/shared/lib/chat/irc-notice.ts +42 -0
- package/src/shared/lib/chat/timeline/fork-anchor.test.ts +99 -0
- package/src/shared/lib/chat/timeline/fork-anchor.ts +47 -0
- package/src/shared/lib/chat/todo/parser.ts +6 -4
- package/src/shared/lib/fs/archive.test.ts +101 -0
- package/src/shared/lib/fs/archive.ts +191 -0
- package/src/shared/lib/fs/clipboard.test.ts +32 -7
- package/src/shared/lib/fs/clipboard.ts +59 -14
- package/src/shared/lib/fs/content-hash.ts +29 -0
- package/src/shared/lib/fs/csv.test.ts +50 -0
- package/src/shared/lib/fs/csv.ts +40 -0
- package/src/shared/lib/fs/document-kind.test.ts +13 -6
- package/src/shared/lib/fs/document-kind.ts +18 -6
- package/src/shared/lib/fs/file-kind-classify.test.ts +4 -0
- package/src/shared/lib/fs/file-kind.test.ts +2 -7
- package/src/shared/lib/fs/file-kind.ts +4 -2
- package/src/shared/lib/fs/grid-edit.test.ts +24 -0
- package/src/shared/lib/fs/grid-edit.ts +29 -0
- package/src/shared/lib/fs/grid-selection.test.ts +137 -0
- package/src/shared/lib/fs/grid-selection.ts +138 -0
- package/src/shared/lib/harness/brand-color.ts +5 -0
- package/src/shared/lib/harness/catalog.test.ts +22 -0
- package/src/shared/lib/harness/catalog.ts +60 -7
- package/src/shared/lib/harness/config-fields.test.ts +25 -0
- package/src/shared/lib/harness/config-fields.ts +33 -3
- package/src/shared/lib/harness/dialects.ts +1 -1
- package/src/shared/lib/harness/fork.ts +60 -0
- package/src/shared/lib/harness/mcp-facts.test.ts +30 -0
- package/src/shared/lib/harness/mcp-facts.ts +69 -0
- package/src/shared/lib/harness/menu.test.ts +16 -1
- package/src/shared/lib/harness/menu.ts +2 -2
- package/src/shared/lib/harness/provider-contracts.ts +109 -0
- package/src/shared/lib/harness/provider-facts.test.ts +2 -1
- package/src/shared/lib/harness/provider-facts.ts +24 -115
- package/src/shared/lib/harness/provider-lookup.ts +37 -0
- package/src/shared/lib/harness/providers.ts +2 -1
- package/src/shared/lib/harness/rewind.ts +6 -6
- package/src/shared/lib/harness/session-modes.ts +31 -0
- package/src/shared/lib/harness/transcript.test.ts +29 -0
- package/src/shared/lib/harness/transcript.ts +19 -0
- package/src/shared/lib/harness/updates.ts +10 -0
- package/src/shared/lib/notifications/settings.test.ts +21 -0
- package/src/shared/lib/notifications/settings.ts +24 -0
- package/src/shared/lib/omp/session/mapper.test.ts +31 -0
- package/src/shared/lib/omp/session/mapper.ts +17 -0
- package/src/shared/lib/omp/session/messages-map-notice.test.ts +68 -0
- package/src/shared/lib/omp/session/messages-map.test.ts +1 -35
- package/src/shared/lib/omp/session/messages-map.ts +17 -0
- package/src/shared/lib/omp/session/prewarm.test.ts +28 -4
- package/src/shared/lib/omp/session/prewarm.ts +25 -6
- package/src/shared/lib/omp/session/stream-state.server.test.ts +25 -0
- package/src/shared/lib/omp/session/stream-state.server.ts +8 -4
- package/src/shared/lib/omp/session/wait.ts +10 -1
- package/src/shared/lib/panels/capabilities.test.ts +1 -1
- package/src/shared/lib/panels/capabilities.ts +3 -0
- package/src/shared/lib/plugins/settings.ts +22 -0
- package/src/shared/lib/schedule/parse.test.ts +48 -0
- package/src/shared/lib/schedule/parse.ts +69 -45
- package/src/shared/lib/schedule/timezone.ts +128 -0
- package/src/shared/lib/settings/defaults.ts +2 -0
- package/src/shared/lib/settings/sections.ts +8 -4
- package/src/shared/lib/ui/picker-filter.test.ts +23 -0
- package/src/shared/lib/ui/picker-filter.ts +20 -0
- package/src/shared/lib/workspace/refresh-cadence.test.ts +25 -1
- package/src/shared/lib/workspace/relative-time.ts +16 -0
- package/src/shared/types/chat.ts +4 -0
- package/src/shared/types/harness.ts +12 -1
- package/src/shared/types/omp/agent.ts +6 -0
- package/src/shared/types/omp/session.ts +18 -0
- package/src/shared/types/panels-registry.ts +3 -3
- package/src/shared/types/panels.ts +4 -2
- package/src/shared/types/schedule.ts +13 -0
- package/src/shared/types/settings/state.ts +18 -7
- package/src/shared/types/todo.ts +3 -1
- package/src/shared/types/waiting.ts +9 -0
- package/src/test-support/file-actions.test-util.ts +4 -0
- package/src/test-support/file-archive.test-util.ts +41 -0
- package/src/test-support/file-clipboard.test-util.ts +9 -6
- package/src/test-support/file-editor.test-util.ts +70 -5
- package/src/test-support/harness-table.test-util.ts +2 -0
- package/src/test-support/preload.ts +46 -0
- package/dist/client/static/js/index-32rpkj6b.css +0 -1
- package/src/client/hooks/editor/use-external-change-notice.ts +0 -71
- package/src/client/hooks/editor/use-external-change.test.ts +0 -88
- package/src/client/hooks/editor/use-external-change.ts +0 -146
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The MCP list a session receives.
|
|
8
|
+
*
|
|
9
|
+
* The bug this pins: the settings pane read omp's `mcp.json`, the ACP spawn
|
|
10
|
+
* passed `mcpServers: []`, and a plugin had no way to contribute — so a server
|
|
11
|
+
* the user configured reached exactly one harness. These tests drive the merge
|
|
12
|
+
* over a temp agent dir, a temp project and an isolated database.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
16
|
+
import { mkdir, mkdtemp, rm, writeFile } from 'fs/promises';
|
|
17
|
+
import { tmpdir } from 'os';
|
|
18
|
+
import { join } from 'path';
|
|
19
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
20
|
+
import {
|
|
21
|
+
definitionFromItem,
|
|
22
|
+
definitionFromNative,
|
|
23
|
+
mcpServersFor,
|
|
24
|
+
toAcpMcpServers,
|
|
25
|
+
} from '@/server/lib/mcp/registry.server';
|
|
26
|
+
import { writeCustomMcpServers } from '@/server/lib/mcp/store.server';
|
|
27
|
+
import { clearPluginMcp, createPluginMcp } from '@/server/lib/plugins/mcp.server';
|
|
28
|
+
import { getDb } from '@/server/db.server';
|
|
29
|
+
import type { McpServerItem } from '@/shared/types';
|
|
30
|
+
|
|
31
|
+
let root = '';
|
|
32
|
+
let agentDir = '';
|
|
33
|
+
let project = '';
|
|
34
|
+
const previousAgentDir = Bun.env.PI_CODING_AGENT_DIR;
|
|
35
|
+
|
|
36
|
+
beforeAll(async () => {
|
|
37
|
+
root = await mkdtemp(join(tmpdir(), 'kabmo-mcp-registry-'));
|
|
38
|
+
agentDir = join(root, 'agent');
|
|
39
|
+
project = join(root, 'project');
|
|
40
|
+
await mkdir(agentDir, { recursive: true });
|
|
41
|
+
await mkdir(join(project, '.omp'), { recursive: true });
|
|
42
|
+
Bun.env.PI_CODING_AGENT_DIR = agentDir;
|
|
43
|
+
await isolateDb();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterAll(async () => {
|
|
47
|
+
await releaseDb();
|
|
48
|
+
if (previousAgentDir === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
49
|
+
else Bun.env.PI_CODING_AGENT_DIR = previousAgentDir;
|
|
50
|
+
await rm(root, { recursive: true, force: true });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
function item(overrides: Partial<McpServerItem> = {}): McpServerItem {
|
|
54
|
+
return {
|
|
55
|
+
id: 'custom-1',
|
|
56
|
+
name: 'custom',
|
|
57
|
+
scope: 'every-project',
|
|
58
|
+
enabled: true,
|
|
59
|
+
reachType: 'command',
|
|
60
|
+
commandArgs: ['npx', '-y', 'custom-mcp'],
|
|
61
|
+
envVars: [],
|
|
62
|
+
...overrides,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
describe('definitionFromNative', () => {
|
|
67
|
+
test('a command entry becomes a stdio server', () => {
|
|
68
|
+
expect(definitionFromNative('notes', { command: 'npx', args: ['-y', 'notes'], env: { TOKEN: 'x' } })).toEqual({
|
|
69
|
+
name: 'notes',
|
|
70
|
+
transport: 'stdio',
|
|
71
|
+
command: 'npx',
|
|
72
|
+
args: ['-y', 'notes'],
|
|
73
|
+
env: { TOKEN: 'x' },
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('a url entry becomes an http server', () => {
|
|
78
|
+
expect(definitionFromNative('remote', { url: 'https://mcp.example/sse', headers: { Authorization: 'Bearer x' } })).toEqual({
|
|
79
|
+
name: 'remote',
|
|
80
|
+
transport: 'http',
|
|
81
|
+
url: 'https://mcp.example/sse',
|
|
82
|
+
headers: { Authorization: 'Bearer x' },
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('an entry naming neither is dropped, not guessed at', () => {
|
|
87
|
+
expect(definitionFromNative('broken', {})).toBeNull();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('definitionFromItem', () => {
|
|
92
|
+
test('a disabled row is not injected', () => {
|
|
93
|
+
expect(definitionFromItem(item({ enabled: false }))).toBeNull();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('a masked credential is never injected as the literal dots', () => {
|
|
97
|
+
const definition = definitionFromItem(
|
|
98
|
+
item({ envVars: [{ id: '1', key: 'TOKEN', value: '••••••••' }, { id: '2', key: 'MODE', value: 'fast' }] }),
|
|
99
|
+
);
|
|
100
|
+
expect(definition?.env).toEqual({ MODE: 'fast' });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('a link row becomes an http server', () => {
|
|
104
|
+
expect(definitionFromItem(item({ reachType: 'link', linkUrl: 'https://mcp.example' }))).toEqual({
|
|
105
|
+
name: 'custom',
|
|
106
|
+
transport: 'http',
|
|
107
|
+
url: 'https://mcp.example',
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('toAcpMcpServers', () => {
|
|
113
|
+
test('maps both transports to the wire shape', () => {
|
|
114
|
+
expect(
|
|
115
|
+
toAcpMcpServers([
|
|
116
|
+
{ name: 'a', transport: 'stdio', command: 'npx', args: ['x'], env: { K: 'V' } },
|
|
117
|
+
{ name: 'b', transport: 'http', url: 'https://x', headers: { H: '1' } },
|
|
118
|
+
]),
|
|
119
|
+
).toEqual([
|
|
120
|
+
{ name: 'a', command: 'npx', args: ['x'], env: [{ name: 'K', value: 'V' }] },
|
|
121
|
+
{ type: 'http', name: 'b', url: 'https://x', headers: [{ name: 'H', value: '1' }] },
|
|
122
|
+
]);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('mcpServersFor', () => {
|
|
127
|
+
test('merges user, project, app-local and plugin servers, first name wins', async () => {
|
|
128
|
+
await writeFile(
|
|
129
|
+
join(agentDir, 'mcp.json'),
|
|
130
|
+
JSON.stringify({
|
|
131
|
+
mcpServers: {
|
|
132
|
+
shared: { command: 'user-command' },
|
|
133
|
+
off: { command: 'disabled-command' },
|
|
134
|
+
},
|
|
135
|
+
disabledServers: ['off'],
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
await writeFile(
|
|
139
|
+
join(project, '.omp', 'mcp.json'),
|
|
140
|
+
JSON.stringify({ mcpServers: { project: { command: 'project-command' } } }),
|
|
141
|
+
);
|
|
142
|
+
await writeCustomMcpServers(await getDb(), [
|
|
143
|
+
item({ id: 'shared', name: 'shared', commandArgs: ['custom-command'] }),
|
|
144
|
+
item({ id: 'local', name: 'local', commandArgs: ['local-command'] }),
|
|
145
|
+
]);
|
|
146
|
+
const plugin = createPluginMcp('demo');
|
|
147
|
+
plugin.register({ id: 'tools', transport: 'stdio', command: 'plugin-command' });
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
const servers = await mcpServersFor(project);
|
|
151
|
+
expect(servers.map((server) => server.name)).toEqual(['shared', 'project', 'local', 'demo:tools']);
|
|
152
|
+
// The user's entry wins over the app-local row of the same name.
|
|
153
|
+
expect(servers[0]?.command).toBe('user-command');
|
|
154
|
+
expect(servers.some((server) => server.name === 'off')).toBe(false);
|
|
155
|
+
} finally {
|
|
156
|
+
clearPluginMcp('demo');
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('a project-scoped row is only injected into its own project', async () => {
|
|
161
|
+
await writeCustomMcpServers(await getDb(), [
|
|
162
|
+
item({ id: 'scoped', name: 'scoped', scope: 'this-project', projectPath: project }),
|
|
163
|
+
]);
|
|
164
|
+
const elsewhere = join(root, 'elsewhere');
|
|
165
|
+
await mkdir(elsewhere, { recursive: true });
|
|
166
|
+
expect((await mcpServersFor(project)).some((server) => server.name === 'scoped')).toBe(true);
|
|
167
|
+
expect((await mcpServersFor(elsewhere)).some((server) => server.name === 'scoped')).toBe(false);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The MCP settings rows, in one place.
|
|
8
|
+
*
|
|
9
|
+
* Split out of the settings route so the SPAWN path can read the same list: an
|
|
10
|
+
* ACP session injects the enabled servers into `session/new`, and a second
|
|
11
|
+
* reader that re-derived the key or the mock default would drift from the pane
|
|
12
|
+
* the user actually edited.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { DEFAULT_MCP_SERVERS } from '@/client/data/settings/mcp';
|
|
16
|
+
import { createSettingsListStore } from '@/server/lib/db/settings-store';
|
|
17
|
+
import { isMockMode } from '@/server/mock.server';
|
|
18
|
+
import type { DbClient } from '@/server/lib/db/client';
|
|
19
|
+
import type { McpServerItem } from '@/shared/types';
|
|
20
|
+
|
|
21
|
+
export const MCP_SETTINGS_KEY = 'omp_mcp_servers';
|
|
22
|
+
|
|
23
|
+
export const mcpStore = createSettingsListStore<McpServerItem>({
|
|
24
|
+
key: MCP_SETTINGS_KEY,
|
|
25
|
+
mockDefaults: DEFAULT_MCP_SERVERS,
|
|
26
|
+
idOf: (server) => server.id,
|
|
27
|
+
singular: 'server',
|
|
28
|
+
plural: 'servers',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/** The app-local rows, with the mock default only in mock mode. */
|
|
32
|
+
export async function readCustomMcpServers(db: DbClient): Promise<McpServerItem[]> {
|
|
33
|
+
return mcpStore.readStored(db, { absent: isMockMode() ? DEFAULT_MCP_SERVERS : [] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function writeCustomMcpServers(db: DbClient, servers: McpServerItem[]): Promise<void> {
|
|
37
|
+
await mcpStore.write(db, servers);
|
|
38
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The contract between the frame fold and the session wrapper it folds into.
|
|
8
|
+
* Types only, split out to keep `frame-fold.ts` under the size ceiling.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { AutoTitleHost } from '@/server/lib/omp/session/auto-title.server';
|
|
12
|
+
import type { QueueDeliveryHost } from '@/server/lib/queue/delivery.server';
|
|
13
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
14
|
+
import type { ModeMirror } from '@/server/lib/omp/rpc/mode-mirror';
|
|
15
|
+
import type { SessionRunModel } from '@/shared/lib/omp/session/stream-state.server';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Wrapper surface the fold reads and writes. Every field is owned by the
|
|
19
|
+
* wrapper; the fold mutates them in place exactly as the inline switch did.
|
|
20
|
+
* Composes the two host contracts the settle path hands the wrapper to
|
|
21
|
+
* (auto-title, queue delivery) so the wrapper itself satisfies this whole type.
|
|
22
|
+
*/
|
|
23
|
+
export interface SessionFrameHost extends AutoTitleHost, QueueDeliveryHost {
|
|
24
|
+
promptRunning: boolean;
|
|
25
|
+
streaming: boolean;
|
|
26
|
+
compacting: boolean;
|
|
27
|
+
/** Abort verdict of the current run — see `endedAborted` in `terminal-settle.ts`. */
|
|
28
|
+
runAborted: boolean;
|
|
29
|
+
awaitingAgentStart: boolean;
|
|
30
|
+
awaitingAgentStartDeadline: number;
|
|
31
|
+
continuationGraceUntil: number;
|
|
32
|
+
emit(event: AgentEvent): void;
|
|
33
|
+
/** Remember a blocking ask/approval dialog so a reattaching client can answer it. */
|
|
34
|
+
trackUiDialog(frame: AgentEvent): void;
|
|
35
|
+
/** Mirror of omp's plan/goal mode, fed by the frames this fold sees. */
|
|
36
|
+
modeMirror: ModeMirror;
|
|
37
|
+
/**
|
|
38
|
+
* The model the child is serving with, as the wrapper last reconciled it.
|
|
39
|
+
* The `stream` row this fold writes carries it.
|
|
40
|
+
*/
|
|
41
|
+
runModel: SessionRunModel | null;
|
|
42
|
+
/** Fold a subagent frame into the liveness roster. */
|
|
43
|
+
observeSubagent(frame: AgentEvent, now: number): void;
|
|
44
|
+
/**
|
|
45
|
+
* Re-read the model the child is actually serving with and rename the live run
|
|
46
|
+
* row to match — omp's payload-less `model_changed`, e.g. a fallback-chain
|
|
47
|
+
* retry that swapped the model mid-run.
|
|
48
|
+
*/
|
|
49
|
+
syncRunModel(): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** What the caller must do after the fold. */
|
|
53
|
+
export interface FrameFoldResult {
|
|
54
|
+
/** The fold already handled this frame's user-visible effect and the caller
|
|
55
|
+
* must NOT forward it: a failed `prompt` response has emitted its own
|
|
56
|
+
* `prompt_error`, and a `command_output` belonging to Kabmo's own
|
|
57
|
+
* background rename must stay out of the timeline. */
|
|
58
|
+
suppressForward: boolean;
|
|
59
|
+
}
|
|
@@ -14,11 +14,19 @@
|
|
|
14
14
|
* idle-looking session in the middle of a compaction.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { describe, expect, test } from 'bun:test';
|
|
17
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
18
18
|
|
|
19
19
|
import { foldSessionFrame } from '@/server/lib/omp/rpc/frame-fold';
|
|
20
20
|
import { releasesStreamRowOnPromptResult } from '@/shared/lib/omp/session/stream-heal.server';
|
|
21
21
|
import { makeHost } from '@/server/lib/omp/rpc/frame-fold-host.test-util';
|
|
22
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
23
|
+
import { onRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
24
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
25
|
+
import {
|
|
26
|
+
loadStreamStates,
|
|
27
|
+
markStreamStatus,
|
|
28
|
+
type SessionRunModel,
|
|
29
|
+
} from '@/shared/lib/omp/session/stream-state.server';
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* The `prompt_result` frame is where omp reports `agentInvoked`, and the
|
|
@@ -129,3 +137,58 @@ describe('compaction frames', () => {
|
|
|
129
137
|
});
|
|
130
138
|
|
|
131
139
|
});
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The `stream` row a frame opens must name the model the run is served by.
|
|
143
|
+
*
|
|
144
|
+
* `agent_start`/`turn_start`/`message_start` are the only writers for a run
|
|
145
|
+
* whose prompt never went through the dispatcher, and they wrote the status
|
|
146
|
+
* alone: the sidebar's `runModel` was then empty and the docked indicator read
|
|
147
|
+
* `Loading…` for the whole answer.
|
|
148
|
+
*/
|
|
149
|
+
describe('the stream row names the run model', () => {
|
|
150
|
+
beforeEach(async () => {
|
|
151
|
+
// The row writes resolve the database; isolated so the real `~/.kabmo` is
|
|
152
|
+
// never opened. Same helper the stream-state suite uses.
|
|
153
|
+
await isolateDb();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
afterEach(async () => {
|
|
157
|
+
await releaseDb();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
/** Fold one frame and wait for its fire-and-forget write via `stream-status`. */
|
|
161
|
+
async function foldAndReadRow(
|
|
162
|
+
sessionId: string,
|
|
163
|
+
frame: AgentEvent,
|
|
164
|
+
runModel: SessionRunModel | null,
|
|
165
|
+
) {
|
|
166
|
+
const { promise, resolve } = Promise.withResolvers<void>();
|
|
167
|
+
const off = onRealtimeSignal((event) => {
|
|
168
|
+
if (event.signal === 'stream-status') resolve();
|
|
169
|
+
});
|
|
170
|
+
try {
|
|
171
|
+
foldSessionFrame(makeHost({ sessionId, runModel }), frame);
|
|
172
|
+
await promise;
|
|
173
|
+
} finally {
|
|
174
|
+
off();
|
|
175
|
+
}
|
|
176
|
+
return (await loadStreamStates())[sessionId];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
test('agent_start writes the host model into the row it opens', async () => {
|
|
180
|
+
expect(await foldAndReadRow('s1', { type: 'agent_start' }, { provider: 'anthropic', modelId: 'claude' })).toEqual({
|
|
181
|
+
status: 'stream',
|
|
182
|
+
model: { provider: 'anthropic', modelId: 'claude' },
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('a later frame with no reconciled model keeps a pair the dispatch stored', async () => {
|
|
187
|
+
await markStreamStatus('s1', 'stream', { provider: 'openai', modelId: 'gpt-5' });
|
|
188
|
+
|
|
189
|
+
expect(await foldAndReadRow('s1', { type: 'turn_start' }, null)).toEqual({
|
|
190
|
+
status: 'stream',
|
|
191
|
+
model: { provider: 'openai', modelId: 'gpt-5' },
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* returns first and the tests stay pure.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type { SessionFrameHost } from '@/server/lib/omp/rpc/frame-fold';
|
|
18
|
+
import type { SessionFrameHost } from '@/server/lib/omp/rpc/frame-fold-contract';
|
|
19
19
|
import { ModeMirror } from '@/server/lib/omp/rpc/mode-mirror';
|
|
20
20
|
|
|
21
21
|
export function makeHost(overrides: Partial<SessionFrameHost> = {}): SessionFrameHost {
|
|
@@ -34,6 +34,7 @@ export function makeHost(overrides: Partial<SessionFrameHost> = {}): SessionFram
|
|
|
34
34
|
awaitingAgentStartDeadline: 0,
|
|
35
35
|
continuationGraceUntil: 0,
|
|
36
36
|
proc: { sendCommand: async () => undefined as never },
|
|
37
|
+
runModel: null,
|
|
37
38
|
emit() {},
|
|
38
39
|
trackUiDialog() {},
|
|
39
40
|
observeSubagent() {},
|
|
@@ -23,11 +23,15 @@
|
|
|
23
23
|
* per-file ceiling.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import { describe, expect, test } from 'bun:test';
|
|
26
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
27
27
|
|
|
28
28
|
import { foldSessionFrame } from '@/server/lib/omp/rpc/frame-fold';
|
|
29
29
|
import { makeHost } from '@/server/lib/omp/rpc/frame-fold-host.test-util';
|
|
30
30
|
import { onRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
31
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
32
|
+
|
|
33
|
+
beforeEach(isolateDb);
|
|
34
|
+
afterEach(releaseDb);
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
37
|
* The `tool_execution_end` frame is what moves a running session's sidebar row
|
|
@@ -17,11 +17,16 @@
|
|
|
17
17
|
* observable proof that the branch was reached.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { describe, expect, test } from 'bun:test';
|
|
20
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
21
21
|
|
|
22
|
-
import { foldSessionFrame
|
|
22
|
+
import { foldSessionFrame } from '@/server/lib/omp/rpc/frame-fold';
|
|
23
|
+
import type { SessionFrameHost } from '@/server/lib/omp/rpc/frame-fold-contract';
|
|
23
24
|
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
24
25
|
import { makeHost } from '@/server/lib/omp/rpc/frame-fold-host.test-util';
|
|
26
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
27
|
+
|
|
28
|
+
beforeEach(isolateDb);
|
|
29
|
+
afterEach(releaseDb);
|
|
25
30
|
|
|
26
31
|
/** Fold one frame and report the flags the trigger leaves behind. */
|
|
27
32
|
function fold(host: SessionFrameHost, event: AgentEvent): void {
|
|
@@ -23,9 +23,7 @@ import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
|
23
23
|
import {
|
|
24
24
|
consumeAutoTitleOutput,
|
|
25
25
|
triggerAutoSessionTitle,
|
|
26
|
-
type AutoTitleHost,
|
|
27
26
|
} from '@/server/lib/omp/session/auto-title.server';
|
|
28
|
-
import { type QueueDeliveryHost } from '@/server/lib/queue/delivery.server';
|
|
29
27
|
import { clearStreamStatus, markStreamStatus } from '@/shared/lib/omp/session/stream-state.server';
|
|
30
28
|
import { releasesStreamRowOnPromptResult } from '@/shared/lib/omp/session/stream-heal.server';
|
|
31
29
|
import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
@@ -34,46 +32,7 @@ import { NON_TERMINAL_CONTINUATION_GRACE_MS, type AgentEvent } from '@/server/li
|
|
|
34
32
|
import { settleTerminalRun } from '@/server/lib/omp/rpc/terminal-settle';
|
|
35
33
|
import { parseModeMarker } from '@/shared/lib/omp/mode/markers';
|
|
36
34
|
import { SKILL_PROMPT_CUSTOM_TYPE } from '@/shared/lib/omp/session/operator-title';
|
|
37
|
-
import type {
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Wrapper surface the fold reads and writes. Every field is owned by the
|
|
41
|
-
* wrapper; the fold mutates them in place exactly as the inline switch did.
|
|
42
|
-
* Composes the two host contracts the settle path hands the wrapper to
|
|
43
|
-
* (auto-title, queue delivery) so the wrapper itself satisfies this whole type.
|
|
44
|
-
*/
|
|
45
|
-
export interface SessionFrameHost extends AutoTitleHost, QueueDeliveryHost {
|
|
46
|
-
promptRunning: boolean;
|
|
47
|
-
streaming: boolean;
|
|
48
|
-
compacting: boolean;
|
|
49
|
-
/** Abort verdict of the current run — see `endedAborted` in `terminal-settle.ts`. */
|
|
50
|
-
runAborted: boolean;
|
|
51
|
-
awaitingAgentStart: boolean;
|
|
52
|
-
awaitingAgentStartDeadline: number;
|
|
53
|
-
continuationGraceUntil: number;
|
|
54
|
-
emit(event: AgentEvent): void;
|
|
55
|
-
/** Remember a blocking ask/approval dialog so a reattaching client can answer it. */
|
|
56
|
-
trackUiDialog(frame: AgentEvent): void;
|
|
57
|
-
/** Mirror of omp's plan/goal mode, fed by the frames this fold sees. */
|
|
58
|
-
modeMirror: ModeMirror;
|
|
59
|
-
/** Fold a subagent frame into the liveness roster. */
|
|
60
|
-
observeSubagent(frame: AgentEvent, now: number): void;
|
|
61
|
-
/**
|
|
62
|
-
* Re-read the model the child is actually serving with and rename the live run
|
|
63
|
-
* row to match — omp's payload-less `model_changed`, e.g. a fallback-chain
|
|
64
|
-
* retry that swapped the model mid-run.
|
|
65
|
-
*/
|
|
66
|
-
syncRunModel(): void;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** What the caller must do after the fold. */
|
|
70
|
-
export interface FrameFoldResult {
|
|
71
|
-
/** The fold already handled this frame's user-visible effect and the caller
|
|
72
|
-
* must NOT forward it: a failed `prompt` response has emitted its own
|
|
73
|
-
* `prompt_error`, and a `command_output` belonging to Kabmo's own
|
|
74
|
-
* background rename must stay out of the timeline. */
|
|
75
|
-
suppressForward: boolean;
|
|
76
|
-
}
|
|
35
|
+
import type { FrameFoldResult, SessionFrameHost } from '@/server/lib/omp/rpc/frame-fold-contract';
|
|
77
36
|
|
|
78
37
|
/**
|
|
79
38
|
* The `message_end` branch: the one place a title can be derived from the
|
|
@@ -201,7 +160,9 @@ export function foldSessionFrame(host: SessionFrameHost, event: AgentEvent): Fra
|
|
|
201
160
|
// what bounds this to the conversation's first run.
|
|
202
161
|
host.autoTitleRequested = false;
|
|
203
162
|
clearSessionFileCaches();
|
|
204
|
-
|
|
163
|
+
// The row carries the model the wrapper reconciled; a run whose dispatch
|
|
164
|
+
// stored none would otherwise name no provider/model. COALESCE keeps a pair.
|
|
165
|
+
if (host.sessionId) void markStreamStatus(host.sessionId, 'stream', host.runModel);
|
|
205
166
|
// Belt for a switch omp did not announce: a fallback that landed between
|
|
206
167
|
// runs leaves `runModel` (and the row the indicator names the run by) on
|
|
207
168
|
// the pre-fallback model. `model_changed` covers the switches omp reports;
|
|
@@ -213,13 +174,13 @@ export function foldSessionFrame(host: SessionFrameHost, event: AgentEvent): Fra
|
|
|
213
174
|
// Redundant with agent_start in the happy path, but the run-level
|
|
214
175
|
// counterpart can be missed (e.g. the state was cleared by a command
|
|
215
176
|
// between frames). The turn is proof enough the session is live.
|
|
216
|
-
if (host.sessionId) void markStreamStatus(host.sessionId, 'stream');
|
|
177
|
+
if (host.sessionId) void markStreamStatus(host.sessionId, 'stream', host.runModel);
|
|
217
178
|
break;
|
|
218
179
|
case 'message_start':
|
|
219
180
|
// Same recovery as turn_start: a message frame is only emitted inside a
|
|
220
181
|
// live run, so its arrival re-arms the `stream` row no matter what stale
|
|
221
182
|
// status sits there (upsert overwrites any terminal badge).
|
|
222
|
-
if (host.sessionId) void markStreamStatus(host.sessionId, 'stream');
|
|
183
|
+
if (host.sessionId) void markStreamStatus(host.sessionId, 'stream', host.runModel);
|
|
223
184
|
break;
|
|
224
185
|
case 'message_end':
|
|
225
186
|
handleMessageEnd(host, event);
|
|
@@ -13,6 +13,10 @@ import { afterEach, beforeEach, describe, expect, test, vi } from 'bun:test';
|
|
|
13
13
|
|
|
14
14
|
import { AgentSessionWrapper, WebRpcError } from '@/server/lib/omp/rpc/manager';
|
|
15
15
|
import { RpcCommandTimeoutError, type RpcProcess } from '@/server/lib/omp/rpc/process';
|
|
16
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
17
|
+
|
|
18
|
+
beforeEach(isolateDb);
|
|
19
|
+
afterEach(releaseDb);
|
|
16
20
|
|
|
17
21
|
/** Commands whose ack is fabricated as timed out; everything else resolves, so
|
|
18
22
|
* only the timeout policy is under test. */
|
|
@@ -43,14 +43,28 @@ export function getPrewarmed(): Map<string, PrewarmedEntry> {
|
|
|
43
43
|
return globalThis.__ompPrewarmed;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/** The same selection spellings the claim compares, so the two cannot drift. */
|
|
47
|
+
function modesOf(env?: Record<string, string>): string {
|
|
48
|
+
return env?.KABMO_MODES ?? env?.CHAMBER_MODES ?? '';
|
|
49
|
+
}
|
|
50
|
+
|
|
46
51
|
/** Spawn (at most one) idle omp process for `cwd` so the next new-session
|
|
47
52
|
* send starts instantly. Fire-and-forget; a failed spawn just clears itself.
|
|
48
|
-
* Safe to call repeatedly — an existing live or in-flight entry wins
|
|
53
|
+
* Safe to call repeatedly — an existing live or in-flight entry wins, unless it
|
|
54
|
+
* was warmed for a DIFFERENT selection: that child can never serve this chat
|
|
55
|
+
* (the extension reads the mode env once, at start), so it is recycled here
|
|
56
|
+
* instead of being killed by the claim and paid for twice. */
|
|
49
57
|
export function prewarmRpcSession(cwd: string, approvalMode?: ApprovalMode, modeEnv?: Record<string, string>): void {
|
|
50
58
|
const pool = getPrewarmed();
|
|
51
|
-
const existing = pool.get(cwd);
|
|
52
|
-
if (existing) return;
|
|
53
59
|
const mode = approvalMode ?? DEFAULT_APPROVAL_MODE;
|
|
60
|
+
const existing = pool.get(cwd);
|
|
61
|
+
if (existing) {
|
|
62
|
+
if (existing.claimed) return;
|
|
63
|
+
if (existing.approvalMode === mode && modesOf(existing.modeEnv) === modesOf(modeEnv)) return;
|
|
64
|
+
existing.claimed = true;
|
|
65
|
+
pool.delete(cwd);
|
|
66
|
+
void existing.ready.then((wrapper) => wrapper.destroyAndWait()).catch(() => {});
|
|
67
|
+
}
|
|
54
68
|
// The prewarmed child is a session host with a real id, so it gets its own
|
|
55
69
|
// callback credential now; the claim path must not replace it, because the
|
|
56
70
|
// child's environment already carries this value.
|
|
@@ -146,8 +160,8 @@ export async function claimPrewarmedSession(
|
|
|
146
160
|
// time, so a MODE selection that differs from its own can no longer be served
|
|
147
161
|
// by it — the extension reads the mode env once, at session start. Treated
|
|
148
162
|
// exactly like a mode mismatch: claim and kill, then spawn cold.
|
|
149
|
-
const entryModes = entry.modeEnv
|
|
150
|
-
const wantedModes = modeEnv
|
|
163
|
+
const entryModes = modesOf(entry.modeEnv);
|
|
164
|
+
const wantedModes = modesOf(modeEnv);
|
|
151
165
|
const usable = !entry.claimed && entry.approvalMode === approvalMode && entryModes === wantedModes;
|
|
152
166
|
|
|
153
167
|
if (usable) {
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `get_state` probe that keeps the run row's model true.
|
|
8
|
+
*
|
|
9
|
+
* The repair half is what these cases pin: a live row can exist with no pair at
|
|
10
|
+
* all, and a wrapper that already knew the pair used to skip the write — the
|
|
11
|
+
* docked indicator then read `Loading…` for the whole answer.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
15
|
+
|
|
16
|
+
import { syncRunModel, type RunModelHost } from '@/server/lib/omp/rpc/run-model';
|
|
17
|
+
import type { RpcProcess } from '@/server/lib/omp/rpc/process';
|
|
18
|
+
import type { RpcSessionState } from '@/server/lib/omp/rpc/constants';
|
|
19
|
+
import { onRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
20
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
21
|
+
import { loadStreamStates, markStreamStatus } from '@/shared/lib/omp/session/stream-state.server';
|
|
22
|
+
|
|
23
|
+
/** A host whose probe answers with the given state, or rejects. */
|
|
24
|
+
function makeHost(
|
|
25
|
+
answer: RpcSessionState | Error,
|
|
26
|
+
runModel: RunModelHost['runModel'] = null,
|
|
27
|
+
): RunModelHost {
|
|
28
|
+
return {
|
|
29
|
+
sessionId: 's1',
|
|
30
|
+
runModel,
|
|
31
|
+
proc: {
|
|
32
|
+
sendCommand: async () => {
|
|
33
|
+
if (answer instanceof Error) throw answer;
|
|
34
|
+
return answer;
|
|
35
|
+
},
|
|
36
|
+
} as unknown as RpcProcess,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function state(model?: { provider: string; id: string }): RpcSessionState {
|
|
41
|
+
return {
|
|
42
|
+
sessionId: 's1',
|
|
43
|
+
sessionFile: '/tmp/s.jsonl',
|
|
44
|
+
isStreaming: true,
|
|
45
|
+
isSettled: false,
|
|
46
|
+
isCompacting: false,
|
|
47
|
+
...(model ? { model } : {}),
|
|
48
|
+
} as RpcSessionState;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Flush the probe's fire-and-forget chain to completion.
|
|
53
|
+
*
|
|
54
|
+
* A database round trip is the ordering point: a write the probe queued ahead
|
|
55
|
+
* of this read has landed by the time it resolves, so the assertions below are
|
|
56
|
+
* about the write, not about how long the event loop took.
|
|
57
|
+
*/
|
|
58
|
+
async function settleProbe(): Promise<void> {
|
|
59
|
+
for (let round = 0; round < 3; round += 1) await loadStreamStates();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
beforeEach(async () => {
|
|
63
|
+
await isolateDb();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
afterEach(async () => {
|
|
67
|
+
await releaseDb();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('syncRunModel repairs the live row', () => {
|
|
71
|
+
test('fills a row that carries no model, even when the wrapper already knew the pair', async () => {
|
|
72
|
+
await markStreamStatus('s1', 'stream');
|
|
73
|
+
const host = makeHost(state({ provider: 'anthropic', id: 'claude' }), {
|
|
74
|
+
provider: 'anthropic',
|
|
75
|
+
modelId: 'claude',
|
|
76
|
+
});
|
|
77
|
+
// The repair is a change, so the row write raises `stream-status` after the
|
|
78
|
+
// UPDATE lands — the completion event to await.
|
|
79
|
+
const { promise, resolve } = Promise.withResolvers<void>();
|
|
80
|
+
const off = onRealtimeSignal((event) => {
|
|
81
|
+
if (event.signal === 'stream-status') resolve();
|
|
82
|
+
});
|
|
83
|
+
try {
|
|
84
|
+
syncRunModel(host);
|
|
85
|
+
await promise;
|
|
86
|
+
} finally {
|
|
87
|
+
off();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
expect((await loadStreamStates()).s1).toEqual({
|
|
91
|
+
status: 'stream',
|
|
92
|
+
model: { provider: 'anthropic', modelId: 'claude' },
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('leaves a terminal row alone', async () => {
|
|
97
|
+
await markStreamStatus('s1', 'finish');
|
|
98
|
+
syncRunModel(makeHost(state({ provider: 'anthropic', id: 'claude' })));
|
|
99
|
+
await settleProbe();
|
|
100
|
+
|
|
101
|
+
// The fallback probe fires on the run's last frame too; it must not name a
|
|
102
|
+
// model on a badge that means "the run is over".
|
|
103
|
+
expect((await loadStreamStates()).s1).toEqual({ status: 'finish' });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('keeps the last known pair when the probe fails', async () => {
|
|
107
|
+
await markStreamStatus('s1', 'stream', { provider: 'openai', modelId: 'gpt-5' });
|
|
108
|
+
syncRunModel(makeHost(new Error('timeout')));
|
|
109
|
+
await settleProbe();
|
|
110
|
+
|
|
111
|
+
expect((await loadStreamStates()).s1).toEqual({
|
|
112
|
+
status: 'stream',
|
|
113
|
+
model: { provider: 'openai', modelId: 'gpt-5' },
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|