@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
|
@@ -27,9 +27,12 @@
|
|
|
27
27
|
|
|
28
28
|
import { startNewRpcSession, startRpcSession, resolveSpawnCwd } from '@/server/lib/omp/rpc/manager';
|
|
29
29
|
import { resolveSessionPathOr404 } from '@/server/lib/omp/session/locator';
|
|
30
|
+
import { startAcpSession, type AcpSpawnRequest } from '@/server/lib/harness/spawn.server';
|
|
31
|
+
import { loadHarnessSession } from '@/server/lib/harness/session-store.server';
|
|
30
32
|
import { loadPersistedAccessMode } from '@/shared/lib/omp/config/access-mode.server';
|
|
31
33
|
import { claimDueTasks, finishScheduledRun, startScheduledRun } from '@/server/lib/schedule/store.server';
|
|
32
34
|
import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
|
|
35
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
33
36
|
import type { ScheduledTask } from '@/shared/types/schedule';
|
|
34
37
|
|
|
35
38
|
/**
|
|
@@ -78,6 +81,10 @@ export interface ScheduleDeps {
|
|
|
78
81
|
): Promise<{ session: ScheduleSessionHandle; realSessionId: string }>;
|
|
79
82
|
resolveSpawnCwd(recordedCwd?: string | null): Promise<string>;
|
|
80
83
|
resolveSessionPathOr404(sessionId: string): Promise<{ filePath: string; recordedCwd: string | null } | { response: Response }>;
|
|
84
|
+
/** Start an ACP session for a task whose harness is not the built-in RPC. */
|
|
85
|
+
startAcpSession(request: AcpSpawnRequest): Promise<{ session: ScheduleSessionHandle; realSessionId: string }>;
|
|
86
|
+
/** The agent's own session id, for resuming an ACP chat. */
|
|
87
|
+
loadHarnessSession(sessionId: string): Promise<{ harness: string; agentSessionId: string } | null>;
|
|
81
88
|
loadPersistedAccessMode(): Promise<ApprovalMode>;
|
|
82
89
|
claimDueTasks(now: number): Promise<ScheduledTask[]>;
|
|
83
90
|
startScheduledRun(taskId: string, sessionId: string | null): Promise<string>;
|
|
@@ -95,6 +102,8 @@ const defaultDeps: ScheduleDeps = {
|
|
|
95
102
|
startRpcSession,
|
|
96
103
|
resolveSpawnCwd,
|
|
97
104
|
resolveSessionPathOr404,
|
|
105
|
+
startAcpSession,
|
|
106
|
+
loadHarnessSession,
|
|
98
107
|
loadPersistedAccessMode,
|
|
99
108
|
claimDueTasks,
|
|
100
109
|
startScheduledRun,
|
|
@@ -105,6 +114,13 @@ interface ScheduleRuntimeSlot {
|
|
|
105
114
|
timer: NodeJS.Timeout | null;
|
|
106
115
|
/** In-flight tick, so a slow dispatch does not overlap the next interval. */
|
|
107
116
|
ticking: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Runs in flight, keyed by task id. A manual "Run now" is refused while one
|
|
119
|
+
* is present: a second click would spawn a second omp session for the same
|
|
120
|
+
* prompt. A scheduled fire is NOT refused — the claim already advanced its
|
|
121
|
+
* clock, so skipping it would lose the fire.
|
|
122
|
+
*/
|
|
123
|
+
running: Map<string, number>;
|
|
108
124
|
}
|
|
109
125
|
|
|
110
126
|
declare global {
|
|
@@ -113,7 +129,12 @@ declare global {
|
|
|
113
129
|
}
|
|
114
130
|
|
|
115
131
|
function slot(): ScheduleRuntimeSlot {
|
|
116
|
-
return (globalThis.__kabmoScheduleRuntime ??= { timer: null, ticking: false });
|
|
132
|
+
return (globalThis.__kabmoScheduleRuntime ??= { timer: null, ticking: false, running: new Map() });
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Whether a run for this task is in flight right now. */
|
|
136
|
+
export function isTaskRunning(id: string): boolean {
|
|
137
|
+
return (slot().running.get(id) ?? 0) > 0;
|
|
117
138
|
}
|
|
118
139
|
|
|
119
140
|
function withTimeout<T>(promise: Promise<T>, ms: number, message: string): Promise<T> {
|
|
@@ -133,7 +154,46 @@ function withTimeout<T>(promise: Promise<T>, ms: number, message: string): Promi
|
|
|
133
154
|
}
|
|
134
155
|
|
|
135
156
|
/**
|
|
136
|
-
*
|
|
157
|
+
* Open an ACP session for a task whose harness is not the built-in RPC.
|
|
158
|
+
*
|
|
159
|
+
* A task that names a session resumes it only when the recorded row belongs to
|
|
160
|
+
* the SAME harness: an omp session id means nothing to `claude`, and asking the
|
|
161
|
+
* agent to load it would fail the run. A missing or foreign row starts a fresh
|
|
162
|
+
* conversation, which is the same fallback the RPC path uses for a pruned file.
|
|
163
|
+
*/
|
|
164
|
+
async function openAcpTarget(
|
|
165
|
+
task: ScheduledTask,
|
|
166
|
+
deps: ScheduleDeps,
|
|
167
|
+
mode: ApprovalMode,
|
|
168
|
+
): Promise<{ session: ScheduleSessionHandle; sessionId: string; note: string }> {
|
|
169
|
+
const cwd = await deps.resolveSpawnCwd(task.cwd);
|
|
170
|
+
let resumeAgentSessionId: string | undefined;
|
|
171
|
+
let note = 'new session';
|
|
172
|
+
|
|
173
|
+
if (task.sessionId) {
|
|
174
|
+
const recorded = await deps.loadHarnessSession(task.sessionId);
|
|
175
|
+
if (recorded && recorded.harness === task.harness && recorded.agentSessionId) {
|
|
176
|
+
resumeAgentSessionId = recorded.agentSessionId;
|
|
177
|
+
note = 'resumed session';
|
|
178
|
+
} else {
|
|
179
|
+
note = 'session not found; started a new one';
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const { session, realSessionId } = await deps.startAcpSession({
|
|
184
|
+
harness: task.harness as HarnessId,
|
|
185
|
+
sessionId: `__new__${crypto.randomUUID()}`,
|
|
186
|
+
cwd,
|
|
187
|
+
model: task.model ? { provider: task.model.provider, modelId: task.model.modelId } : null,
|
|
188
|
+
thinkingLevel: task.model?.thinkingLevel ?? null,
|
|
189
|
+
accessMode: mode,
|
|
190
|
+
...(resumeAgentSessionId ? { resumeAgentSessionId } : {}),
|
|
191
|
+
});
|
|
192
|
+
return { session, sessionId: realSessionId, note };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Resolve the child a fire should drive, and the prompt to send.
|
|
137
197
|
*
|
|
138
198
|
* A task with `sessionId` RESUMES that conversation, so "every morning, in this
|
|
139
199
|
* thread" keeps one transcript. A missing file falls back to a fresh session
|
|
@@ -146,6 +206,10 @@ async function openDispatchTarget(
|
|
|
146
206
|
): Promise<{ session: ScheduleSessionHandle; sessionId: string; note: string }> {
|
|
147
207
|
const mode = task.model?.accessMode ?? (await deps.loadPersistedAccessMode());
|
|
148
208
|
|
|
209
|
+
if (task.harness && task.harness !== 'omp-rpc') {
|
|
210
|
+
return openAcpTarget(task, deps, mode);
|
|
211
|
+
}
|
|
212
|
+
|
|
149
213
|
if (task.sessionId) {
|
|
150
214
|
const resolved = await deps.resolveSessionPathOr404(task.sessionId);
|
|
151
215
|
if (!('response' in resolved)) {
|
|
@@ -179,30 +243,44 @@ export async function runScheduledTask(
|
|
|
179
243
|
options: { manual?: boolean; deps?: ScheduleDeps } = {},
|
|
180
244
|
): Promise<string> {
|
|
181
245
|
const deps = options.deps ?? defaultDeps;
|
|
182
|
-
const
|
|
246
|
+
const state = slot();
|
|
247
|
+
// Backstop for the route's own check: a manual run never overlaps another
|
|
248
|
+
// run of the same task.
|
|
249
|
+
if (options.manual && isTaskRunning(task.id)) return '';
|
|
250
|
+
state.running.set(task.id, (state.running.get(task.id) ?? 0) + 1);
|
|
183
251
|
try {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
252
|
+
const runId = await deps.startScheduledRun(task.id, task.sessionId);
|
|
253
|
+
try {
|
|
254
|
+
const target = await withTimeout(openDispatchTarget(task, deps), DISPATCH_TIMEOUT_MS, 'The omp process did not start in time.');
|
|
255
|
+
// An ACP session applies the model and thinking picks during its
|
|
256
|
+
// handshake; sending them again would ask an agent that may publish no
|
|
257
|
+
// such selector, and the spawn already refused a model it does not list.
|
|
258
|
+
if (task.harness === 'omp-rpc' && task.model) {
|
|
259
|
+
await target.session.send({ type: 'set_model', provider: task.model.provider, modelId: task.model.modelId });
|
|
260
|
+
if (task.model.thinkingLevel !== 'auto') {
|
|
261
|
+
await target.session.send({ type: 'set_thinking_level', level: task.model.thinkingLevel });
|
|
262
|
+
}
|
|
189
263
|
}
|
|
264
|
+
await withTimeout(
|
|
265
|
+
target.session.send({ type: 'prompt', message: task.prompt }),
|
|
266
|
+
DISPATCH_TIMEOUT_MS,
|
|
267
|
+
'The omp session did not accept the prompt in time.',
|
|
268
|
+
);
|
|
269
|
+
const detail = options.manual ? `Ran now (${target.note})` : target.note;
|
|
270
|
+
await deps.finishScheduledRun(runId, task.id, 'success', detail, {
|
|
271
|
+
sessionId: target.sessionId,
|
|
272
|
+
countRun: !options.manual,
|
|
273
|
+
});
|
|
274
|
+
return target.sessionId;
|
|
275
|
+
} catch (error) {
|
|
276
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
277
|
+
await deps.finishScheduledRun(runId, task.id, 'error', message, { countRun: !options.manual });
|
|
278
|
+
return '';
|
|
190
279
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
);
|
|
196
|
-
const detail = options.manual ? `Ran now (${target.note})` : target.note;
|
|
197
|
-
await deps.finishScheduledRun(runId, task.id, 'success', detail, {
|
|
198
|
-
sessionId: target.sessionId,
|
|
199
|
-
countRun: !options.manual,
|
|
200
|
-
});
|
|
201
|
-
return target.sessionId;
|
|
202
|
-
} catch (error) {
|
|
203
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
204
|
-
await deps.finishScheduledRun(runId, task.id, 'error', message, { countRun: !options.manual });
|
|
205
|
-
return '';
|
|
280
|
+
} finally {
|
|
281
|
+
const remaining = (state.running.get(task.id) ?? 1) - 1;
|
|
282
|
+
if (remaining > 0) state.running.set(task.id, remaining);
|
|
283
|
+
else state.running.delete(task.id);
|
|
206
284
|
}
|
|
207
285
|
}
|
|
208
286
|
|
|
@@ -24,6 +24,8 @@ const SCHEDULE_SCHEMA_SQL = `
|
|
|
24
24
|
prompt TEXT NOT NULL DEFAULT '',
|
|
25
25
|
kind TEXT NOT NULL,
|
|
26
26
|
spec TEXT NOT NULL,
|
|
27
|
+
harness TEXT,
|
|
28
|
+
timezone TEXT,
|
|
27
29
|
folder_id INTEGER,
|
|
28
30
|
cwd TEXT,
|
|
29
31
|
session_id TEXT,
|
|
@@ -57,4 +59,17 @@ const SCHEDULE_SCHEMA_SQL = `
|
|
|
57
59
|
/** Idempotent: the scheduler's own tables, created on every database open. */
|
|
58
60
|
export async function ensureScheduleSchema(db: DbClient): Promise<void> {
|
|
59
61
|
await db.exec(SCHEDULE_SCHEMA_SQL);
|
|
62
|
+
// `timezone` arrived after the table shipped. `CREATE TABLE IF NOT EXISTS`
|
|
63
|
+
// leaves an existing table alone, so an install created before it would miss
|
|
64
|
+
// the column and every read would fail on the absent field. A legacy row
|
|
65
|
+
// reads as the server's zone, which is the behaviour it had.
|
|
66
|
+
const columns = (await db.all('PRAGMA table_info(scheduled_tasks)')) as { name?: string }[];
|
|
67
|
+
if (!columns.some((column) => column.name === 'timezone')) {
|
|
68
|
+
await db.exec('ALTER TABLE scheduled_tasks ADD COLUMN timezone TEXT');
|
|
69
|
+
}
|
|
70
|
+
// `harness` arrived with the per-task harness picker. A legacy row reads as
|
|
71
|
+
// `omp-rpc`, which is the transport it actually ran on.
|
|
72
|
+
if (!columns.some((column) => column.name === 'harness')) {
|
|
73
|
+
await db.exec('ALTER TABLE scheduled_tasks ADD COLUMN harness TEXT');
|
|
74
|
+
}
|
|
60
75
|
}
|
|
@@ -28,6 +28,8 @@ import { tmpdir } from 'node:os';
|
|
|
28
28
|
import { join } from 'node:path';
|
|
29
29
|
import { createDb, type DbClient } from '@/server/lib/db/client';
|
|
30
30
|
import { ensureScheduleSchema } from '@/server/lib/schedule/schema.server';
|
|
31
|
+
import { rowToScheduledTask, type TaskRow } from '@/server/lib/schedule/rows.server';
|
|
32
|
+
import { serverTimeZone } from '@/shared/lib/schedule/timezone';
|
|
31
33
|
|
|
32
34
|
const paths: string[] = [];
|
|
33
35
|
|
|
@@ -145,6 +147,38 @@ describe('ensureScheduleSchema', () => {
|
|
|
145
147
|
const indexes = (await db.all("SELECT name FROM sqlite_master WHERE type = 'index'")) as { name: string }[];
|
|
146
148
|
expect(indexes.map((index) => index.name)).toContain('idx_scheduled_tasks_due');
|
|
147
149
|
});
|
|
150
|
+
|
|
151
|
+
test('adds the timezone column to a table created before it existed', async () => {
|
|
152
|
+
const path = join(tmpdir(), `schedule-legacy-${crypto.randomUUID()}.sqlite`);
|
|
153
|
+
paths.push(path);
|
|
154
|
+
const db = createDb(path);
|
|
155
|
+
await db.exec(`CREATE TABLE scheduled_tasks (
|
|
156
|
+
id TEXT PRIMARY KEY, name TEXT NOT NULL DEFAULT '', prompt TEXT NOT NULL DEFAULT '',
|
|
157
|
+
kind TEXT NOT NULL, spec TEXT NOT NULL, folder_id INTEGER, cwd TEXT, session_id TEXT,
|
|
158
|
+
provider TEXT, model_id TEXT, thinking_level TEXT, access_mode TEXT,
|
|
159
|
+
enabled INTEGER NOT NULL DEFAULT 1, next_run_at INTEGER, last_run_at INTEGER,
|
|
160
|
+
last_status TEXT, last_error TEXT, run_count INTEGER NOT NULL DEFAULT 0,
|
|
161
|
+
created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL
|
|
162
|
+
)`);
|
|
163
|
+
await ensureScheduleSchema(db);
|
|
164
|
+
const columns = (await db.all('PRAGMA table_info(scheduled_tasks)')) as { name: string }[];
|
|
165
|
+
expect(columns.map((column) => column.name)).toContain('timezone');
|
|
166
|
+
expect(columns.map((column) => column.name)).toContain('harness');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('a legacy row with no timezone reads as the server zone', async () => {
|
|
170
|
+
const db = await tempDb();
|
|
171
|
+
await insertTask(db, { id: 'legacy', kind: 'cron', spec: '0 9 * * *' });
|
|
172
|
+
const row = db.raw.query('SELECT * FROM scheduled_tasks WHERE id = ?').get('legacy') as TaskRow;
|
|
173
|
+
expect(rowToScheduledTask(row).timezone).toBe(serverTimeZone());
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('a legacy row with no harness reads as omp-rpc', async () => {
|
|
177
|
+
const db = await tempDb();
|
|
178
|
+
await insertTask(db, { id: 'legacy-harness', kind: 'every', spec: '1h' });
|
|
179
|
+
const row = db.raw.query('SELECT * FROM scheduled_tasks WHERE id = ?').get('legacy-harness') as TaskRow;
|
|
180
|
+
expect(rowToScheduledTask(row).harness).toBe('omp-rpc');
|
|
181
|
+
});
|
|
148
182
|
});
|
|
149
183
|
|
|
150
184
|
describe('claiming due tasks', () => {
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
import { getDb } from '@/server/db.server';
|
|
23
23
|
import { withTransaction } from '@/shared/lib/db/transaction.server';
|
|
24
24
|
import { nextRunAfter, validateSchedule } from '@/shared/lib/schedule/parse';
|
|
25
|
+
import { isValidTimeZone, serverTimeZone } from '@/shared/lib/schedule/timezone';
|
|
26
|
+
import { harnessDescriptor } from '@/shared/lib/harness/catalog';
|
|
25
27
|
import { rowToRun, rowToScheduledTask, type RunRow, type TaskRow } from '@/server/lib/schedule/rows.server';
|
|
26
28
|
import type {
|
|
27
29
|
ScheduleKind,
|
|
@@ -63,6 +65,8 @@ export interface ScheduledTaskInput {
|
|
|
63
65
|
prompt: string;
|
|
64
66
|
kind: ScheduleKind;
|
|
65
67
|
spec: string;
|
|
68
|
+
harness: string;
|
|
69
|
+
timezone: string;
|
|
66
70
|
folderId: number | null;
|
|
67
71
|
cwd: string | null;
|
|
68
72
|
sessionId: string | null;
|
|
@@ -75,19 +79,24 @@ export interface ScheduledTaskInput {
|
|
|
75
79
|
* be a task the runtime can only skip forever.
|
|
76
80
|
*/
|
|
77
81
|
export async function createScheduledTask(input: ScheduledTaskInput): Promise<ScheduledTask> {
|
|
78
|
-
const
|
|
82
|
+
const harness = input.harness.trim() || 'omp-rpc';
|
|
83
|
+
if (!harnessDescriptor(harness)) throw new Error(`Unknown harness: ${harness}`);
|
|
84
|
+
const timezone = input.timezone.trim() || serverTimeZone();
|
|
85
|
+
if (!isValidTimeZone(timezone)) throw new Error(`Unknown timezone: ${timezone}`);
|
|
86
|
+
const validation = validateSchedule(input.kind, input.spec, Date.now(), timezone);
|
|
79
87
|
if (!validation.ok) throw new Error(validation.error);
|
|
80
88
|
const db = await getDb();
|
|
81
89
|
const now = Date.now();
|
|
82
90
|
const id = crypto.randomUUID();
|
|
83
91
|
await db.run(
|
|
84
92
|
`INSERT INTO scheduled_tasks
|
|
85
|
-
(id, name, prompt, kind, spec, folder_id, cwd, session_id,
|
|
93
|
+
(id, name, prompt, kind, spec, harness, timezone, folder_id, cwd, session_id,
|
|
86
94
|
provider, model_id, thinking_level, access_mode,
|
|
87
95
|
enabled, next_run_at, run_count, created_at, updated_at)
|
|
88
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, 0, ?, ?)`,
|
|
96
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, 0, ?, ?)`,
|
|
89
97
|
[
|
|
90
|
-
id, input.name, input.prompt, input.kind, input.spec.trim(),
|
|
98
|
+
id, input.name, input.prompt, input.kind, input.spec.trim(), harness, timezone,
|
|
99
|
+
input.folderId, input.cwd, input.sessionId,
|
|
91
100
|
input.model?.provider ?? null, input.model?.modelId ?? null,
|
|
92
101
|
input.model?.thinkingLevel ?? null, input.model?.accessMode ?? null,
|
|
93
102
|
validation.nextRunAt, now, now,
|
|
@@ -101,6 +110,8 @@ export interface ScheduledTaskPatch {
|
|
|
101
110
|
prompt?: string;
|
|
102
111
|
kind?: ScheduleKind;
|
|
103
112
|
spec?: string;
|
|
113
|
+
harness?: string;
|
|
114
|
+
timezone?: string;
|
|
104
115
|
folderId?: number | null;
|
|
105
116
|
cwd?: string | null;
|
|
106
117
|
sessionId?: string | null;
|
|
@@ -121,16 +132,24 @@ export async function updateScheduledTask(id: string, patch: ScheduledTaskPatch)
|
|
|
121
132
|
|
|
122
133
|
const kind = patch.kind ?? existing.kind;
|
|
123
134
|
const spec = patch.spec !== undefined ? patch.spec.trim() : existing.spec;
|
|
135
|
+
const harness = patch.harness !== undefined ? patch.harness.trim() : existing.harness;
|
|
136
|
+
if (!harnessDescriptor(harness)) throw new Error(`Unknown harness: ${harness}`);
|
|
137
|
+
const harnessChanged = harness !== existing.harness;
|
|
138
|
+
const timezone = patch.timezone !== undefined ? patch.timezone.trim() : existing.timezone;
|
|
139
|
+
if (!isValidTimeZone(timezone)) throw new Error(`Unknown timezone: ${timezone}`);
|
|
124
140
|
const enabled = patch.enabled ?? existing.enabled;
|
|
125
141
|
const scheduleChanged = patch.kind !== undefined || patch.spec !== undefined;
|
|
142
|
+
// A zone change moves every wall-clock fire, so it resets the clock exactly
|
|
143
|
+
// like a spec edit does.
|
|
144
|
+
const timezoneChanged = timezone !== existing.timezone;
|
|
126
145
|
|
|
127
146
|
let nextRunAt = existing.nextRunAt;
|
|
128
|
-
if (scheduleChanged || (enabled && !existing.enabled)) {
|
|
147
|
+
if (scheduleChanged || timezoneChanged || (enabled && !existing.enabled)) {
|
|
129
148
|
// The old clock described a schedule (or a pause) that no longer applies.
|
|
130
149
|
if (!enabled) {
|
|
131
150
|
nextRunAt = null;
|
|
132
151
|
} else {
|
|
133
|
-
const validation = validateSchedule(kind, spec);
|
|
152
|
+
const validation = validateSchedule(kind, spec, Date.now(), timezone);
|
|
134
153
|
if (!validation.ok) throw new Error(validation.error);
|
|
135
154
|
nextRunAt = validation.nextRunAt;
|
|
136
155
|
}
|
|
@@ -138,11 +157,14 @@ export async function updateScheduledTask(id: string, patch: ScheduledTaskPatch)
|
|
|
138
157
|
nextRunAt = null;
|
|
139
158
|
}
|
|
140
159
|
|
|
141
|
-
|
|
160
|
+
// A model snapshot belongs to the harness that published it: an omp model id
|
|
161
|
+
// means nothing to an ACP agent. A harness change without an explicit model
|
|
162
|
+
// therefore drops the snapshot and lets the new harness's default apply.
|
|
163
|
+
const model = patch.model !== undefined ? patch.model : harnessChanged ? null : existing.model;
|
|
142
164
|
const db = await getDb();
|
|
143
165
|
await db.run(
|
|
144
166
|
`UPDATE scheduled_tasks SET
|
|
145
|
-
name = ?, prompt = ?, kind = ?, spec = ?, folder_id = ?, cwd = ?, session_id = ?,
|
|
167
|
+
name = ?, prompt = ?, kind = ?, spec = ?, harness = ?, timezone = ?, folder_id = ?, cwd = ?, session_id = ?,
|
|
146
168
|
provider = ?, model_id = ?, thinking_level = ?, access_mode = ?,
|
|
147
169
|
enabled = ?, next_run_at = ?, updated_at = ?
|
|
148
170
|
WHERE id = ?`,
|
|
@@ -151,6 +173,8 @@ export async function updateScheduledTask(id: string, patch: ScheduledTaskPatch)
|
|
|
151
173
|
patch.prompt ?? existing.prompt,
|
|
152
174
|
kind,
|
|
153
175
|
spec,
|
|
176
|
+
harness,
|
|
177
|
+
timezone,
|
|
154
178
|
patch.folderId !== undefined ? patch.folderId : existing.folderId,
|
|
155
179
|
patch.cwd !== undefined ? patch.cwd : existing.cwd,
|
|
156
180
|
patch.sessionId !== undefined ? patch.sessionId : existing.sessionId,
|
|
@@ -197,7 +221,7 @@ export async function claimDueTasks(now: number): Promise<ScheduledTask[]> {
|
|
|
197
221
|
const claimed: ScheduledTask[] = [];
|
|
198
222
|
for (const row of rows) {
|
|
199
223
|
const task = rowToScheduledTask(row);
|
|
200
|
-
const next = nextRunAfter(task.kind, task.spec, now);
|
|
224
|
+
const next = nextRunAfter(task.kind, task.spec, now, task.timezone);
|
|
201
225
|
db.raw.run(
|
|
202
226
|
'UPDATE scheduled_tasks SET next_run_at = ?, enabled = ?, updated_at = ? WHERE id = ?',
|
|
203
227
|
[next, next === null ? 0 : 1, now, task.id],
|
|
@@ -245,6 +245,53 @@ describe('forkSession (ACP)', () => {
|
|
|
245
245
|
]);
|
|
246
246
|
});
|
|
247
247
|
|
|
248
|
+
test('an anchored fork of a session with no local transcript is refused, not forked whole', async () => {
|
|
249
|
+
await saveHarnessSession({
|
|
250
|
+
sessionId: 'acp-source',
|
|
251
|
+
harness: 'zcode',
|
|
252
|
+
agentSessionId: 'agent-1',
|
|
253
|
+
cwd: '/tmp/project',
|
|
254
|
+
});
|
|
255
|
+
const deps = fakeDeps('never', { forkSupported: true });
|
|
256
|
+
await expect(
|
|
257
|
+
forkSession({ sourceSessionId: 'acp-source', anchorEntryId: 'u1' }, deps),
|
|
258
|
+
).rejects.toMatchObject({ code: 'anchor_unsupported' });
|
|
259
|
+
expect(deps.acpCalls).toHaveLength(0);
|
|
260
|
+
expect(await getSessionRelation('never')).toBeNull();
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test('claude and codex fork at the anchored message through the AIR extension', async () => {
|
|
264
|
+
for (const harness of ['claude', 'codex'] as const) {
|
|
265
|
+
await saveHarnessSession({
|
|
266
|
+
sessionId: 'acp-source',
|
|
267
|
+
harness,
|
|
268
|
+
agentSessionId: 'agent-1',
|
|
269
|
+
cwd: '/tmp/project',
|
|
270
|
+
});
|
|
271
|
+
const deps = fakeDeps(`acp-fork-${harness}`, { forkSupported: true });
|
|
272
|
+
await forkSession({ sourceSessionId: 'acp-source', anchorEntryId: 'a2' }, deps);
|
|
273
|
+
expect(deps.acpCalls).toEqual([
|
|
274
|
+
expect.objectContaining({
|
|
275
|
+
harness,
|
|
276
|
+
forkMeta: { jetbrains: { air: { fork: { version: 1, messageId: 'a2' } } } },
|
|
277
|
+
}),
|
|
278
|
+
]);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test('a whole-chat claude fork sends no fork point', async () => {
|
|
283
|
+
await saveHarnessSession({
|
|
284
|
+
sessionId: 'acp-source',
|
|
285
|
+
harness: 'claude',
|
|
286
|
+
agentSessionId: 'agent-1',
|
|
287
|
+
cwd: '/tmp/project',
|
|
288
|
+
});
|
|
289
|
+
const deps = fakeDeps('acp-fork', { forkSupported: true });
|
|
290
|
+
await forkSession({ sourceSessionId: 'acp-source' }, deps);
|
|
291
|
+
expect(deps.acpCalls).toEqual([expect.objectContaining({ harness: 'claude' })]);
|
|
292
|
+
expect(deps.acpCalls[0]).not.toHaveProperty('forkMeta');
|
|
293
|
+
});
|
|
294
|
+
|
|
248
295
|
test('a harness without fork support is refused before spawning', async () => {
|
|
249
296
|
await saveHarnessSession({
|
|
250
297
|
sessionId: 'acp-source',
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
transcriptTitle,
|
|
37
37
|
} from '@/server/lib/omp/session/transcript-copy';
|
|
38
38
|
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
39
|
+
import { airForkPoint, harnessForksAtMessage } from '@/shared/lib/harness/fork';
|
|
39
40
|
import type { SelectedModel } from '@/shared/types/models';
|
|
40
41
|
import type { AgentImage } from '@/shared/types/omp/agent';
|
|
41
42
|
import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
|
|
@@ -56,6 +57,7 @@ export type SessionForkErrorCode =
|
|
|
56
57
|
| 'source_archived'
|
|
57
58
|
| 'cwd_required'
|
|
58
59
|
| 'anchor_not_found'
|
|
60
|
+
| 'anchor_unsupported'
|
|
59
61
|
| 'fork_unsupported'
|
|
60
62
|
| 'fork_requires_checkpoint'
|
|
61
63
|
| 'fork_failed';
|
|
@@ -89,6 +91,8 @@ export interface ForkSessionDeps {
|
|
|
89
91
|
harness: HarnessId;
|
|
90
92
|
sessionId: string;
|
|
91
93
|
forkAgentSessionId: string;
|
|
94
|
+
/** The fork point an agent extension reads; omitted forks the whole chat. */
|
|
95
|
+
forkMeta?: Record<string, unknown>;
|
|
92
96
|
cwd: string;
|
|
93
97
|
accessMode: ApprovalMode;
|
|
94
98
|
model: SelectedModel | null;
|
|
@@ -228,7 +232,7 @@ export async function forkSession(
|
|
|
228
232
|
if (input.anchorEntryId && !records.some((record) => record?.id === input.anchorEntryId)) {
|
|
229
233
|
throw new SessionForkError(
|
|
230
234
|
'anchor_not_found',
|
|
231
|
-
`The transcript has no entry ${input.anchorEntryId}
|
|
235
|
+
`The transcript has no entry ${input.anchorEntryId}; a builtin command's row is stored by Kabmo only, so fork at a chat turn instead.`,
|
|
232
236
|
);
|
|
233
237
|
}
|
|
234
238
|
const cutIndex = cutIndexFor(records, input.anchorEntryId ?? null);
|
|
@@ -255,6 +259,17 @@ export async function forkSession(
|
|
|
255
259
|
if (!harness || harness === 'omp-rpc') {
|
|
256
260
|
throw new SessionForkError('fork_unsupported', 'This session has no transcript to fork');
|
|
257
261
|
}
|
|
262
|
+
// `session/fork` copies the agent's WHOLE history and takes no anchor.
|
|
263
|
+
// The AIR adapters (claude, codex) read a fork point from `_meta` and keep
|
|
264
|
+
// the history up to that message. Every other agent would silently hand
|
|
265
|
+
// back turns the user did not point at, so an anchor there is refused
|
|
266
|
+
// instead of being answered with the tip.
|
|
267
|
+
if (input.anchorEntryId && !harnessForksAtMessage(harness)) {
|
|
268
|
+
throw new SessionForkError(
|
|
269
|
+
'anchor_unsupported',
|
|
270
|
+
`${harness} keeps this chat's history in its own store, so it can only be forked whole.`,
|
|
271
|
+
);
|
|
272
|
+
}
|
|
258
273
|
if (!(await deps.probeForkSupported(harness))) {
|
|
259
274
|
throw new SessionForkError('fork_unsupported', `${harness} does not support session/fork`);
|
|
260
275
|
}
|
|
@@ -263,6 +278,7 @@ export async function forkSession(
|
|
|
263
278
|
harness,
|
|
264
279
|
sessionId: `__new__${Bun.randomUUIDv7()}`,
|
|
265
280
|
forkAgentSessionId: source.agentSessionId || input.sourceSessionId,
|
|
281
|
+
...(input.anchorEntryId ? { forkMeta: airForkPoint(input.anchorEntryId) } : {}),
|
|
266
282
|
cwd,
|
|
267
283
|
accessMode,
|
|
268
284
|
model,
|
|
@@ -29,7 +29,7 @@ import { startAcpSession } from '@/server/lib/harness/spawn.server';
|
|
|
29
29
|
import { getLiveSession, harnessOfSession, startNewRpcSession } from '@/server/lib/omp/rpc/session-registry';
|
|
30
30
|
import { harnessProbeModels } from '@/server/lib/harness/probe-cache.server';
|
|
31
31
|
import { getDb } from '@/server/db.server';
|
|
32
|
-
import {
|
|
32
|
+
import { harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
33
33
|
import type { SelectedModel } from '@/shared/types/models';
|
|
34
34
|
import type { AgentImage } from '@/shared/types/omp/agent';
|
|
35
35
|
import { MAX_SESSION_DEPTH } from '@/server/lib/sessions/relation-types';
|
|
@@ -122,7 +122,7 @@ export interface SpawnChildSessionResult {
|
|
|
122
122
|
|
|
123
123
|
function harnessOf(value: string | null | undefined): HarnessId | null {
|
|
124
124
|
if (!value) return null;
|
|
125
|
-
return
|
|
125
|
+
return harnessDescriptor(value) ? (value as HarnessId) : null;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
@@ -34,6 +34,7 @@ function prompt(overrides: Partial<WaitingPrompt> = {}): WaitingPrompt {
|
|
|
34
34
|
pendingId: 'new-1',
|
|
35
35
|
dependsOn: 'dep-a',
|
|
36
36
|
dependsOnTitle: 'Session A',
|
|
37
|
+
targetSessionId: null,
|
|
37
38
|
prompt: 'do the thing',
|
|
38
39
|
attachments: [],
|
|
39
40
|
model: null,
|
|
@@ -61,6 +62,8 @@ interface Harness {
|
|
|
61
62
|
setRowWrittenAt(at: number | null): void;
|
|
62
63
|
setQueued(queued: boolean): void;
|
|
63
64
|
setDelivering(delivering: boolean): void;
|
|
65
|
+
/** Make an existing chat live, and record the commands sent to it. */
|
|
66
|
+
setExisting(sessionId: string): void;
|
|
64
67
|
failSpawnWith(error: Error | null): void;
|
|
65
68
|
failSendWith(error: Error | null): void;
|
|
66
69
|
}
|
|
@@ -76,6 +79,7 @@ function harness(initial: WaitingPrompt[] = [prompt()]): Harness {
|
|
|
76
79
|
let delivering = false;
|
|
77
80
|
let spawnError: Error | null = null;
|
|
78
81
|
let sendError: Error | null = null;
|
|
82
|
+
let existing: Record<string, { sessionId: string; isAlive(): boolean; isBusy(): boolean; send(command: Record<string, unknown>): Promise<unknown> }> = {};
|
|
79
83
|
const sent: Harness['sent'] = {};
|
|
80
84
|
const spawned: string[] = [];
|
|
81
85
|
const writes: string[] = [];
|
|
@@ -100,6 +104,12 @@ function harness(initial: WaitingPrompt[] = [prompt()]): Harness {
|
|
|
100
104
|
};
|
|
101
105
|
},
|
|
102
106
|
getSession: () => undefined,
|
|
107
|
+
ensureSessionLive: async (sessionId) => {
|
|
108
|
+
const host = existing[sessionId];
|
|
109
|
+
if (!host) return null;
|
|
110
|
+
sent[sessionId] = [];
|
|
111
|
+
return host;
|
|
112
|
+
},
|
|
103
113
|
loadStreamStates: async () => streams,
|
|
104
114
|
streamRowWrittenAt: async () => rowWrittenAt,
|
|
105
115
|
hasQueuedItem: async () => queued,
|
|
@@ -159,6 +169,22 @@ function harness(initial: WaitingPrompt[] = [prompt()]): Harness {
|
|
|
159
169
|
setDelivering: (next) => {
|
|
160
170
|
delivering = next;
|
|
161
171
|
},
|
|
172
|
+
setExisting: (sessionId) => {
|
|
173
|
+
sent[sessionId] = [];
|
|
174
|
+
existing = {
|
|
175
|
+
...existing,
|
|
176
|
+
[sessionId]: {
|
|
177
|
+
sessionId,
|
|
178
|
+
isAlive: () => true,
|
|
179
|
+
isBusy: () => false,
|
|
180
|
+
async send(command) {
|
|
181
|
+
if (sendError) throw sendError;
|
|
182
|
+
sent[sessionId].push(command);
|
|
183
|
+
return null;
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
},
|
|
162
188
|
failSpawnWith: (error) => {
|
|
163
189
|
spawnError = error;
|
|
164
190
|
},
|
|
@@ -275,4 +301,26 @@ describe('sweepWaitingPrompts', () => {
|
|
|
275
301
|
expect(await sweepWaitingPrompts({ now: NOW, deps: h.deps })).toBe(0);
|
|
276
302
|
expect(h.spawned).toEqual([]);
|
|
277
303
|
});
|
|
304
|
+
|
|
305
|
+
// A NEXT prompt in a chat that already exists belongs to that chat. Spawning
|
|
306
|
+
// a second session would strand the text in a conversation the user never
|
|
307
|
+
// opened.
|
|
308
|
+
test('delivers a next prompt into the existing session it names', async () => {
|
|
309
|
+
const h = harness([prompt({ pendingId: null, targetSessionId: 'sess-open' })]);
|
|
310
|
+
h.setExisting('sess-open');
|
|
311
|
+
expect(await sweepWaitingPrompts({ now: NOW, deps: h.deps })).toBe(1);
|
|
312
|
+
expect(h.spawned).toEqual([]);
|
|
313
|
+
expect(h.sent['sess-open']).toEqual([{ type: 'prompt', message: 'do the thing' }]);
|
|
314
|
+
expect(h.writes).toContain('dispatched wait-1 sess-open');
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// The target may itself be mid-turn when the dependency ends. omp refuses a
|
|
318
|
+
// prompt mid-turn and drops it, so the row stays `waiting` for a later sweep.
|
|
319
|
+
test('holds the prompt while its target session is still streaming', async () => {
|
|
320
|
+
const h = harness([prompt({ pendingId: null, targetSessionId: 'sess-open' })]);
|
|
321
|
+
h.setExisting('sess-open');
|
|
322
|
+
h.setStreams({ 'dep-a': { status: 'finish' }, 'sess-open': { status: 'stream' } });
|
|
323
|
+
expect(await sweepWaitingPrompts({ now: NOW, deps: h.deps })).toBe(0);
|
|
324
|
+
expect(h.sent['sess-open']).toEqual([]);
|
|
325
|
+
});
|
|
278
326
|
});
|
|
@@ -31,6 +31,8 @@ import {
|
|
|
31
31
|
type AgentSessionWrapper,
|
|
32
32
|
} from '@/server/lib/omp/rpc/manager';
|
|
33
33
|
import { getRpcSession } from '@/server/lib/omp/rpc/session-registry';
|
|
34
|
+
import { ensureSessionLive } from '@/server/lib/sessions/dispatch.server';
|
|
35
|
+
import type { QueueDeliveryHost } from '@/server/lib/queue/delivery.server';
|
|
34
36
|
import { kabmoModeEnv } from '@/server/lib/omp/extensions/locator';
|
|
35
37
|
import { hasQueuedItem } from '@/server/lib/queue/store.server';
|
|
36
38
|
import { hasPendingDelivery } from '@/server/lib/queue/delivery.server';
|
|
@@ -86,6 +88,8 @@ export interface WaitingDeps {
|
|
|
86
88
|
modeEnv?: Record<string, string>,
|
|
87
89
|
): Promise<{ session: WaitingSessionHandle; realSessionId: string }>;
|
|
88
90
|
getSession(sessionId: string): AgentSessionWrapper | undefined;
|
|
91
|
+
/** Wake an EXISTING chat so a held next prompt can be delivered into it. */
|
|
92
|
+
ensureSessionLive(sessionId: string): Promise<QueueDeliveryHost | null>;
|
|
89
93
|
loadStreamStates(): Promise<StreamRowMap>;
|
|
90
94
|
/** Epoch ms of a session's last status write, or null when unknown. */
|
|
91
95
|
streamRowWrittenAt(sessionId: string): Promise<number | null>;
|
|
@@ -113,6 +117,7 @@ function defaultDeps(): WaitingDeps {
|
|
|
113
117
|
return {
|
|
114
118
|
startNewRpcSession,
|
|
115
119
|
getSession: getRpcSession,
|
|
120
|
+
ensureSessionLive,
|
|
116
121
|
loadStreamStates,
|
|
117
122
|
streamRowWrittenAt,
|
|
118
123
|
hasQueuedItem,
|
|
@@ -181,6 +186,16 @@ async function dispatchWaitingPrompt(
|
|
|
181
186
|
prompt: WaitingPrompt,
|
|
182
187
|
deps: WaitingDeps,
|
|
183
188
|
): Promise<{ sessionId: string }> {
|
|
189
|
+
// A next prompt in a chat that already exists is delivered THERE. Spawning
|
|
190
|
+
// would create a second session for text the user wrote in the first one.
|
|
191
|
+
if (prompt.targetSessionId) {
|
|
192
|
+
const target = await deps.ensureSessionLive(prompt.targetSessionId);
|
|
193
|
+
if (!target) throw new Error(`Session ${prompt.targetSessionId} could not be woken for the held prompt.`);
|
|
194
|
+
const send = (command: Record<string, unknown>) => target.send(command);
|
|
195
|
+
await applyModelSnapshot(send, prompt.model);
|
|
196
|
+
await send(promptCommand({ text: prompt.prompt, attachments: prompt.attachments, model: prompt.model }));
|
|
197
|
+
return { sessionId: prompt.targetSessionId };
|
|
198
|
+
}
|
|
184
199
|
const accessMode = prompt.model?.accessMode ?? (await deps.loadPersistedAccessMode());
|
|
185
200
|
const modeEnv = prompt.modes ? kabmoModeEnv(prompt.modes) : undefined;
|
|
186
201
|
const { session, realSessionId } = await deps.startNewRpcSession(prompt.cwd, accessMode, modeEnv);
|
|
@@ -215,6 +230,13 @@ export async function sweepWaitingPrompts(
|
|
|
215
230
|
for (const prompt of waiting) {
|
|
216
231
|
const state = await readDependencyState(prompt.dependsOn, deps, streams);
|
|
217
232
|
if (!dependencyVerdict(state, now).settled) continue;
|
|
233
|
+
// A target that is itself mid-turn refuses a prompt (omp drops it). The
|
|
234
|
+
// prompt is still wanted, so it stays `waiting` for the next sweep — the
|
|
235
|
+
// same conservative rule the dependency's own queue uses.
|
|
236
|
+
if (prompt.targetSessionId) {
|
|
237
|
+
const target = await readDependencyState(prompt.targetSessionId, deps, streams);
|
|
238
|
+
if (!dependencyVerdict(target, now).settled) continue;
|
|
239
|
+
}
|
|
218
240
|
if (!(await deps.claimWaitingPrompt(prompt.id))) continue;
|
|
219
241
|
try {
|
|
220
242
|
const { sessionId } = await withTimeout(
|