@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,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* GET /api/fs/digest?path=<rel>&root=<abs>&repo=<rel> — the content fingerprint
|
|
8
|
+
* of a file inside the panel's scope.
|
|
9
|
+
*
|
|
10
|
+
* The editor polls this while a tab is open so a file changed from OUTSIDE the
|
|
11
|
+
* console (an agent's tool call, `git checkout`, another editor) reaches the
|
|
12
|
+
* buffer without the user reloading anything. The question is deliberately not
|
|
13
|
+
* "did the mtime move": a checkout or a formatter rewrites a file with bytes
|
|
14
|
+
* the buffer may already hold, and reloading over that would drop a caret and a
|
|
15
|
+
* scroll position for no change at all. The answer is the hash of the content,
|
|
16
|
+
* so the caller replaces its buffer only when the bytes really differ.
|
|
17
|
+
*
|
|
18
|
+
* Scope resolution is identical to `/api/fs/exists` and `/api/fs/read` (same
|
|
19
|
+
* root allow-list, same `resolveWithinRoot` containment), so a path that reads
|
|
20
|
+
* as text is a path whose digest can be asked about.
|
|
21
|
+
*
|
|
22
|
+
* The hash is CACHED per path against the raw mtime and size, because a 3s poll
|
|
23
|
+
* of a 30 MB file would otherwise re-read and re-hash it forever. The cache's
|
|
24
|
+
* blind spot is the one the save path already documents: a write that leaves
|
|
25
|
+
* both the size and the millisecond-identical mtime unchanged is not seen until
|
|
26
|
+
* something else moves. `touch`ing a file invalidates the entry and re-reads —
|
|
27
|
+
* the answer is then the same hash, which is exactly what "the bytes did not
|
|
28
|
+
* change" means.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { json, type LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
32
|
+
import { isMockMode } from '@/server/mock.server';
|
|
33
|
+
import { getDefaultFsRoot, resolveRoot, resolveWithinRoot } from '@/server/lib/fs/root';
|
|
34
|
+
import { stableMtime } from '@/server/lib/fs/write-conflict';
|
|
35
|
+
import { contentHash } from '@/shared/lib/fs/content-hash';
|
|
36
|
+
import { EDITOR_MAX_FILE_BYTES } from '@/shared/lib/fs/file-kind';
|
|
37
|
+
|
|
38
|
+
interface CachedDigest {
|
|
39
|
+
/** The RAW stat mtime the hash was built from; never the rounded value. */
|
|
40
|
+
mtimeMs: number;
|
|
41
|
+
size: number;
|
|
42
|
+
hash: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** One entry per open tab is the normal size; the cap only bounds a leak. */
|
|
46
|
+
const CACHE_LIMIT = 64;
|
|
47
|
+
const HASH_CACHE = new Map<string, CachedDigest>();
|
|
48
|
+
|
|
49
|
+
function cacheDigest(fullPath: string, digest: CachedDigest): void {
|
|
50
|
+
HASH_CACHE.delete(fullPath);
|
|
51
|
+
HASH_CACHE.set(fullPath, digest);
|
|
52
|
+
while (HASH_CACHE.size > CACHE_LIMIT) {
|
|
53
|
+
const oldest = HASH_CACHE.keys().next().value;
|
|
54
|
+
if (oldest === undefined) break;
|
|
55
|
+
HASH_CACHE.delete(oldest);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function fileDigest({ request }: LoaderFunctionArgs) {
|
|
60
|
+
const url = new URL(request.url);
|
|
61
|
+
const filePath = url.searchParams.get('path');
|
|
62
|
+
if (!filePath) {
|
|
63
|
+
return json({ error: 'Missing path' }, { status: 400 });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let baseDir = await resolveRoot(url.searchParams.get('root'), await getDefaultFsRoot(isMockMode()));
|
|
67
|
+
const repo = url.searchParams.get('repo');
|
|
68
|
+
if (repo && repo !== '.') {
|
|
69
|
+
const repoDir = resolveWithinRoot(baseDir, repo);
|
|
70
|
+
if (repoDir) baseDir = repoDir;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const fullPath = resolveWithinRoot(baseDir, filePath.replace(/^\/+/, ''));
|
|
74
|
+
if (!fullPath) {
|
|
75
|
+
return json({ error: 'Invalid path' }, { status: 403 });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// A directory standing where the file was is "gone" for the same reason the
|
|
79
|
+
// existence probe answers that way: the file the tab names is not there.
|
|
80
|
+
const stat = await Bun.file(fullPath).stat().catch(() => null);
|
|
81
|
+
if (!stat || stat.isDirectory()) {
|
|
82
|
+
return json({ exists: false, mtimeMs: null, hash: null });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// A file past the editor's ceiling was never openable, and hashing it would
|
|
86
|
+
// cost the read this route exists to avoid. `null` tells the caller it has no
|
|
87
|
+
// fingerprint to compare against.
|
|
88
|
+
if (stat.size > EDITOR_MAX_FILE_BYTES) {
|
|
89
|
+
return json({ exists: true, mtimeMs: stableMtime(stat.mtimeMs), hash: null });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const cached = HASH_CACHE.get(fullPath);
|
|
93
|
+
if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) {
|
|
94
|
+
return json({ exists: true, mtimeMs: stableMtime(stat.mtimeMs), hash: cached.hash });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
const hash = await contentHash(await Bun.file(fullPath).text());
|
|
99
|
+
cacheDigest(fullPath, { mtimeMs: stat.mtimeMs, size: stat.size, hash });
|
|
100
|
+
return json({ exists: true, mtimeMs: stableMtime(stat.mtimeMs), hash });
|
|
101
|
+
} catch {
|
|
102
|
+
// An unreadable file has no verdict — the caller must not treat a failed
|
|
103
|
+
// probe as "the disk changed".
|
|
104
|
+
return json({ exists: true, mtimeMs: stableMtime(stat.mtimeMs), hash: null });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -20,21 +20,24 @@ import path from 'path';
|
|
|
20
20
|
import { action } from '@/server/routes/fs/grant';
|
|
21
21
|
import { resolveFileScope } from '@/server/routes/fs/scope';
|
|
22
22
|
import { clearExternalRoots, externalRoots, isExternalRoot } from '@/server/lib/fs/external-roots';
|
|
23
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
23
24
|
|
|
24
25
|
/** A file OUTSIDE the app root and outside every workspace. */
|
|
25
26
|
let outside: string;
|
|
26
27
|
let outsideFile: string;
|
|
27
28
|
|
|
28
|
-
beforeEach(() => {
|
|
29
|
+
beforeEach(async () => {
|
|
30
|
+
await isolateDb();
|
|
29
31
|
clearExternalRoots();
|
|
30
32
|
outside = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-grant-'));
|
|
31
33
|
outsideFile = path.join(outside, 'report.md');
|
|
32
34
|
fs.writeFileSync(outsideFile, '# report\n');
|
|
33
35
|
});
|
|
34
36
|
|
|
35
|
-
afterEach(() => {
|
|
37
|
+
afterEach(async () => {
|
|
36
38
|
clearExternalRoots();
|
|
37
39
|
fs.rmSync(outside, { recursive: true, force: true });
|
|
40
|
+
await releaseDb();
|
|
38
41
|
});
|
|
39
42
|
|
|
40
43
|
function grantRequest(body: unknown, headers: Record<string, string> = {}): Request {
|
|
@@ -2,8 +2,10 @@ import { bindingsFor, type HandlerBinding } from '@/server/lib/route-adapter';
|
|
|
2
2
|
import { browseDirectories, listDirectory, listFiles, readFile, readReferencedFile } from '@/server/routes/fs/read';
|
|
3
3
|
import { resolveFileScope } from '@/server/routes/fs/scope';
|
|
4
4
|
import { fileExists } from '@/server/routes/fs/exists';
|
|
5
|
+
import { fileDigest } from '@/server/routes/fs/digest';
|
|
5
6
|
import { serveRawFile } from '@/server/routes/fs/raw';
|
|
6
7
|
import * as fsAction from '@/server/routes/fs/action';
|
|
8
|
+
import * as fsArchive from '@/server/routes/fs/archive';
|
|
7
9
|
import * as fsGit from '@/server/routes/fs/git';
|
|
8
10
|
import * as fsGrant from '@/server/routes/fs/grant';
|
|
9
11
|
import * as fsReplace from '@/server/routes/fs/replace';
|
|
@@ -12,12 +14,14 @@ import * as fsValidate from '@/server/routes/fs/validate';
|
|
|
12
14
|
|
|
13
15
|
export const fsBindings: HandlerBinding[] = [
|
|
14
16
|
...bindingsFor(fsAction, '/api/fs/action'),
|
|
17
|
+
...bindingsFor(fsArchive, '/api/fs/archive'),
|
|
15
18
|
...bindingsFor(fsGit, '/api/fs/git'),
|
|
16
19
|
...bindingsFor(fsGrant, '/api/fs/grant', { mutating: ['POST'] }),
|
|
17
20
|
...bindingsFor(fsReplace, '/api/fs/replace'),
|
|
18
21
|
...bindingsFor(fsSearch, '/api/fs/search'),
|
|
19
22
|
...bindingsFor(fsValidate, '/api/fs/validate'),
|
|
20
23
|
{ method: 'GET', path: '/api/fs/browse', handler: browseDirectories },
|
|
24
|
+
{ method: 'GET', path: '/api/fs/digest', handler: fileDigest },
|
|
21
25
|
{ method: 'GET', path: '/api/fs/dir', handler: listDirectory },
|
|
22
26
|
{ method: 'GET', path: '/api/fs/exists', handler: fileExists },
|
|
23
27
|
{ method: 'GET', path: '/api/fs/list', handler: listFiles },
|
|
@@ -7,6 +7,7 @@ import { json, type LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
|
7
7
|
import { listDirectoryEntries } from '@/server/lib/fs/listing';
|
|
8
8
|
import { errorResponse } from '@/server/lib/route-adapter';
|
|
9
9
|
import { stableMtime } from '@/server/lib/fs/write-conflict';
|
|
10
|
+
import { contentHash } from '@/shared/lib/fs/content-hash';
|
|
10
11
|
import { homedir } from 'os';
|
|
11
12
|
import { dirname, isAbsolute, join, resolve } from 'path';
|
|
12
13
|
import fs from 'fs';
|
|
@@ -283,7 +284,11 @@ export async function readFile({ request }: LoaderFunctionArgs) {
|
|
|
283
284
|
// `baseMtime`, and the server refuses a write whose base is no longer what is
|
|
284
285
|
// on disk. A buffer with no base (a handle-backed file, an older client) still
|
|
285
286
|
// writes unconditionally — see `save-file.ts`.
|
|
286
|
-
|
|
287
|
+
//
|
|
288
|
+
// The content hash travels too, and it is the one the editor's auto-refresh
|
|
289
|
+
// compares against (`/api/fs/digest`): a file rewritten with the SAME bytes
|
|
290
|
+
// must not replace the buffer, and only a byte-level fingerprint can say so.
|
|
291
|
+
return json({ content, mtimeMs: stableMtime(stat.mtimeMs), hash: await contentHash(content) });
|
|
287
292
|
} catch (error) {
|
|
288
293
|
return errorResponse(error);
|
|
289
294
|
}
|
|
@@ -15,19 +15,23 @@
|
|
|
15
15
|
* scoped to).
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { afterEach, describe, expect, test } from 'bun:test';
|
|
18
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
19
19
|
import fs from 'fs';
|
|
20
20
|
import path from 'path';
|
|
21
21
|
import { testPosix } from '@/test-support/platform';
|
|
22
22
|
import { resolveFileScope } from '@/server/routes/fs/scope';
|
|
23
23
|
import { DOCUMENT_MAX_FILE_BYTES, EDITOR_MAX_FILE_BYTES, PDF_MAX_FILE_BYTES } from '@/shared/lib/fs/file-kind';
|
|
24
24
|
import { formatBytes } from '@/shared/lib/format/number';
|
|
25
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
25
26
|
|
|
26
27
|
const APP = process.cwd();
|
|
27
28
|
const DIR = path.join(APP, 'tmp-scope-probe');
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
beforeEach(isolateDb);
|
|
31
|
+
|
|
32
|
+
afterEach(async () => {
|
|
30
33
|
fs.rmSync(DIR, { recursive: true, force: true });
|
|
34
|
+
await releaseDb();
|
|
31
35
|
});
|
|
32
36
|
|
|
33
37
|
async function scope(rawPath: string) {
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A harness the user adds, end to end through the route.
|
|
8
|
+
*
|
|
9
|
+
* The transport was already generic; what these tests pin is the registry the
|
|
10
|
+
* synchronous call sites read: a saved row must become a descriptor, a launch
|
|
11
|
+
* line, a catalog entry and a probe target, and a removal must take all four
|
|
12
|
+
* away without rewriting the chats that ran on it.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
16
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
17
|
+
import { getDb } from '@/server/db.server';
|
|
18
|
+
import { action, loader } from '@/server/routes/harness/root';
|
|
19
|
+
import { loadHarnessConfig, resolveLaunch } from '@/server/lib/harness/config.server';
|
|
20
|
+
import { customHarness, refreshCustomHarnesses } from '@/server/lib/harness/custom.server';
|
|
21
|
+
import { harnessDescriptor } from '@/shared/lib/harness/catalog';
|
|
22
|
+
|
|
23
|
+
const API = 'http://localhost/api/harness';
|
|
24
|
+
|
|
25
|
+
type Handler = (args: never) => unknown;
|
|
26
|
+
|
|
27
|
+
function call(handler: Handler, request: Request): Promise<Response> {
|
|
28
|
+
return handler({ request, params: {} } as never) as Promise<Response>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function post(body: unknown): Request {
|
|
32
|
+
return new Request(API, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
body: JSON.stringify(body),
|
|
35
|
+
headers: { 'content-type': 'application/json' },
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The route's refusal sentence, narrowed rather than cast. */
|
|
40
|
+
async function errorOf(response: Response): Promise<string> {
|
|
41
|
+
const payload: unknown = await response.json();
|
|
42
|
+
if (payload && typeof payload === 'object' && 'error' in payload && typeof payload.error === 'string') {
|
|
43
|
+
return payload.error;
|
|
44
|
+
}
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function add(overrides: Record<string, unknown> = {}): Promise<Response> {
|
|
49
|
+
return call(action, post({
|
|
50
|
+
customHarness: {
|
|
51
|
+
id: 'my-agent',
|
|
52
|
+
label: 'My Agent',
|
|
53
|
+
command: 'npx -y my-agent acp',
|
|
54
|
+
...overrides,
|
|
55
|
+
},
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
beforeEach(async () => {
|
|
60
|
+
await isolateDb();
|
|
61
|
+
await (await getDb()).run('DELETE FROM custom_harnesses');
|
|
62
|
+
await refreshCustomHarnesses();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
afterAll(async () => {
|
|
66
|
+
await releaseDb();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('custom harness route', () => {
|
|
70
|
+
test('a saved harness becomes a descriptor and a launch line', async () => {
|
|
71
|
+
const response = await add({ env: 'TOKEN=abc' });
|
|
72
|
+
expect(response.status).toBe(200);
|
|
73
|
+
|
|
74
|
+
expect(customHarness('my-agent')?.label).toBe('My Agent');
|
|
75
|
+
expect(harnessDescriptor('my-agent')).toMatchObject({
|
|
76
|
+
id: 'my-agent',
|
|
77
|
+
label: 'My Agent',
|
|
78
|
+
transport: 'acp',
|
|
79
|
+
glyph: 'custom',
|
|
80
|
+
});
|
|
81
|
+
const launch = resolveLaunch('my-agent', await loadHarnessConfig('my-agent'));
|
|
82
|
+
expect(launch.command).toEqual(['npx', '-y', 'my-agent', 'acp']);
|
|
83
|
+
expect(launch.env).toEqual({ TOKEN: 'abc' });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('the catalog lists it with custom and initial', async () => {
|
|
87
|
+
await add();
|
|
88
|
+
const response = await call(loader, new Request(API));
|
|
89
|
+
const payload = (await response.json()) as { harnesses: Array<Record<string, unknown>> };
|
|
90
|
+
const row = payload.harnesses.find((entry) => entry.id === 'my-agent');
|
|
91
|
+
expect(row).toMatchObject({ custom: true, label: 'My Agent', initial: 'M', transport: 'acp' });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('a built-in id is refused by name', async () => {
|
|
95
|
+
const response = await add({ id: 'claude' });
|
|
96
|
+
expect(response.status).toBe(400);
|
|
97
|
+
expect(await errorOf(response)).toContain('already ships');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('a malformed id is refused', async () => {
|
|
101
|
+
const response = await add({ id: 'My Agent!' });
|
|
102
|
+
expect(response.status).toBe(400);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('an empty command is refused', async () => {
|
|
106
|
+
const response = await add({ command: ' ' });
|
|
107
|
+
expect(response.status).toBe(400);
|
|
108
|
+
expect(await errorOf(response)).toContain('command is required');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('an invalid env line is refused', async () => {
|
|
112
|
+
const response = await add({ env: 'NOT A LINE' });
|
|
113
|
+
expect(response.status).toBe(400);
|
|
114
|
+
expect(await errorOf(response)).toContain('invalid env line');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('removal drops the descriptor and the launch line', async () => {
|
|
118
|
+
await add();
|
|
119
|
+
const response = await call(action, post({ removeHarness: 'my-agent' }));
|
|
120
|
+
expect(response.status).toBe(200);
|
|
121
|
+
expect(customHarness('my-agent')).toBeUndefined();
|
|
122
|
+
expect(harnessDescriptor('my-agent')).toBeUndefined();
|
|
123
|
+
expect(() => resolveLaunch('my-agent', { command: '', env: '', provider: '', model: '', thinking: '', mode: '' }))
|
|
124
|
+
.toThrow('No launch command is configured');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('a built-in cannot be removed', async () => {
|
|
128
|
+
const response = await call(action, post({ removeHarness: 'claude' }));
|
|
129
|
+
expect(response.status).toBe(400);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import { json } from '@/server/lib/remix-compat';
|
|
27
|
-
import {
|
|
27
|
+
import { isBuiltinHarness, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
28
28
|
import { adaptBaseUrl, planProtocol, supportedProtocols, type CanonicalProtocol } from '@/shared/lib/harness/dialects';
|
|
29
|
-
import { providerFacts } from '@/shared/lib/harness/provider-
|
|
29
|
+
import { providerFacts } from '@/shared/lib/harness/provider-lookup';
|
|
30
30
|
import { providerEnv, providerLevel, registryLabel } from '@/shared/lib/harness/providers';
|
|
31
31
|
import { providerIdProblem, providerSlugFrom } from '@/shared/lib/harness/provider-slug';
|
|
32
32
|
import { withEnvValues } from '@/shared/lib/harness/config';
|
|
@@ -270,7 +270,7 @@ export function isImportBody(value: unknown): boolean {
|
|
|
270
270
|
|
|
271
271
|
/** A source id the import may read from. Refuses before any file is touched. */
|
|
272
272
|
export function importSourceOf(value: unknown): HarnessId | null {
|
|
273
|
-
return typeof value === 'string' &&
|
|
273
|
+
return typeof value === 'string' && isBuiltinHarness(value)
|
|
274
274
|
? (value as HarnessId)
|
|
275
275
|
: null;
|
|
276
276
|
}
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
import { json } from '@/server/lib/remix-compat';
|
|
19
19
|
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
20
20
|
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
21
|
-
import {
|
|
21
|
+
import { harnessDescriptor, harnessIds, isBuiltinHarness, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
22
|
+
import { customLaunch, ensureCustomHarnesses, removeCustomHarness, saveCustomHarness, type CustomHarnessInput } from '@/server/lib/harness/custom.server';
|
|
22
23
|
import { HARNESS_LAUNCH } from '@/server/lib/harness/launch-table';
|
|
23
24
|
import type { HarnessProbe } from '@/server/lib/harness/capabilities';
|
|
24
25
|
import { forgetProbe, loadProbes, rememberProbe } from '@/server/lib/harness/probe-cache.server';
|
|
@@ -34,7 +35,7 @@ import {
|
|
|
34
35
|
providerLevel,
|
|
35
36
|
registryLabel,
|
|
36
37
|
} from '@/shared/lib/harness/providers';
|
|
37
|
-
import { providerFacts } from '@/shared/lib/harness/provider-
|
|
38
|
+
import { providerFacts } from '@/shared/lib/harness/provider-lookup';
|
|
38
39
|
import type { HarnessProviderSupport } from '@/shared/types/harness';
|
|
39
40
|
import { parseHarnessConfig, type HarnessConfig } from '@/shared/lib/harness/config';
|
|
40
41
|
|
|
@@ -54,7 +55,13 @@ export interface HarnessSummary {
|
|
|
54
55
|
* choice, so the settings page omits it — see `installable` on the catalog
|
|
55
56
|
* descriptor. */
|
|
56
57
|
builtIn?: true;
|
|
58
|
+
/** True for a harness the user added, so the card can offer Remove. */
|
|
59
|
+
custom?: true;
|
|
60
|
+
/** The letter the UI draws when there is no vendor mark. */
|
|
61
|
+
initial: string;
|
|
57
62
|
install?: string;
|
|
63
|
+
/** The built-in launch line, as the config form should show it. */
|
|
64
|
+
command?: string;
|
|
58
65
|
note?: string;
|
|
59
66
|
probe: HarnessProbe | null;
|
|
60
67
|
/** Why it cannot run, without probing: the launch command is missing. */
|
|
@@ -62,6 +69,9 @@ export interface HarnessSummary {
|
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
export async function listHarnesses(): Promise<HarnessSummary[]> {
|
|
72
|
+
// A user-added harness is a database row; the synchronous launch resolver
|
|
73
|
+
// reads the registry this fills.
|
|
74
|
+
await ensureCustomHarnesses();
|
|
65
75
|
// ONE read for the whole catalog, from disk when memory is cold: the probe
|
|
66
76
|
// cache used to be process-only, so every restart — every `bun --hot` reload —
|
|
67
77
|
// turned a harness the user had just checked back into `not probed`.
|
|
@@ -72,10 +82,10 @@ export async function listHarnesses(): Promise<HarnessSummary[]> {
|
|
|
72
82
|
// above — this is the one catalog answer.
|
|
73
83
|
const disabled = await loadDisabledHarnesses();
|
|
74
84
|
const configs: Record<string, HarnessConfig> = {};
|
|
75
|
-
for (const id of
|
|
76
|
-
return
|
|
85
|
+
for (const id of harnessIds()) configs[id] = await loadHarnessConfig(id);
|
|
86
|
+
return harnessIds().map((id) => {
|
|
77
87
|
const descriptor = harnessDescriptor(id);
|
|
78
|
-
const launch = HARNESS_LAUNCH[id];
|
|
88
|
+
const launch = HARNESS_LAUNCH[id] ?? customLaunch(id);
|
|
79
89
|
const cached = stored.get(id) ?? null;
|
|
80
90
|
// A BUILT-IN transport is never represented by a probe. There is no agent to
|
|
81
91
|
// spawn, so `probeHarness` can only answer "no launch command is configured"
|
|
@@ -88,10 +98,15 @@ export async function listHarnesses(): Promise<HarnessSummary[]> {
|
|
|
88
98
|
id,
|
|
89
99
|
label: descriptor?.label ?? id,
|
|
90
100
|
transport: descriptor?.transport ?? 'acp',
|
|
101
|
+
initial: descriptor?.initial ?? id.charAt(0).toUpperCase(),
|
|
91
102
|
canLaunch: available,
|
|
92
103
|
enabled: harnessEnabled(id, disabled),
|
|
93
104
|
...(descriptor?.builtIn ? { builtIn: true as const } : {}),
|
|
105
|
+
...(isBuiltinHarness(id) ? {} : { custom: true as const }),
|
|
94
106
|
...(launch?.install ? { install: launch.install } : {}),
|
|
107
|
+
// The line a spawn actually runs when the config's command is empty —
|
|
108
|
+
// what the settings card's placeholder must name.
|
|
109
|
+
...(launch?.command.length ? { command: launch.command.join(' ') } : {}),
|
|
95
110
|
...(launch?.note ? { note: launch.note } : {}),
|
|
96
111
|
probe: fresh,
|
|
97
112
|
...(available ? {} : {
|
|
@@ -104,10 +119,11 @@ export async function listHarnesses(): Promise<HarnessSummary[]> {
|
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
export async function loader({ request }: LoaderFunctionArgs) {
|
|
122
|
+
await ensureCustomHarnesses();
|
|
107
123
|
const url = new URL(request.url);
|
|
108
124
|
const target = url.searchParams.get('probe');
|
|
109
125
|
if (target) {
|
|
110
|
-
if (!
|
|
126
|
+
if (!harnessDescriptor(target)) {
|
|
111
127
|
return json({ error: `Unknown harness: ${target}` }, { status: 400 });
|
|
112
128
|
}
|
|
113
129
|
// Refused, not probed: a built-in transport has nothing to spawn, and the
|
|
@@ -126,14 +142,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|
|
126
142
|
// card renders its form from this one payload, so opening a card cannot show a
|
|
127
143
|
// stale value the server would then refuse to save.
|
|
128
144
|
const configs: Record<string, HarnessConfig> = {};
|
|
129
|
-
for (const id of
|
|
145
|
+
for (const id of harnessIds()) configs[id] = await loadHarnessConfig(id);
|
|
130
146
|
|
|
131
147
|
// What each harness can do about OTHER providers, from the MEASURED table: the
|
|
132
148
|
// file, the field names, whether Kabmo may write it, and the credential-free
|
|
133
149
|
// list of entries a copy could take. No credential travels here — the key is
|
|
134
150
|
// read by the request that writes.
|
|
135
151
|
const providerSupportByHarness: Record<string, HarnessProviderSupport> = {};
|
|
136
|
-
for (const id of
|
|
152
|
+
for (const id of harnessIds()) {
|
|
137
153
|
const facts = providerFacts(id);
|
|
138
154
|
const level = providerLevel(id);
|
|
139
155
|
if (level === 'none') continue;
|
|
@@ -168,6 +184,9 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|
|
168
184
|
|
|
169
185
|
export async function action({ request, params }: ActionFunctionArgs) {
|
|
170
186
|
if (request.method !== 'POST') return methodNotAllowed({ request, params });
|
|
187
|
+
// A custom harness is a database row and the descriptor helpers are
|
|
188
|
+
// synchronous; load the registry before any branch reads one.
|
|
189
|
+
await ensureCustomHarnesses();
|
|
171
190
|
// The body is UNTRUSTED and every branch below reads a different field, so it
|
|
172
191
|
// is narrowed to a record ONCE. `record` is a real runtime check, not a cast:
|
|
173
192
|
// a request that is not a JSON object falls through to the probe validation
|
|
@@ -177,8 +196,27 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
177
196
|
parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
178
197
|
? (parsed as Record<string, unknown>)
|
|
179
198
|
: {};
|
|
199
|
+
// A CUSTOM HARNESS write: `{ customHarness: { id, label, command, env? } }`.
|
|
200
|
+
// Handled before the probe validation because it names no probe.
|
|
201
|
+
if (body.customHarness !== undefined) {
|
|
202
|
+
try {
|
|
203
|
+
const saved = await saveCustomHarness(body.customHarness as CustomHarnessInput);
|
|
204
|
+
return json({ customHarness: saved });
|
|
205
|
+
} catch (cause) {
|
|
206
|
+
return json({ error: cause instanceof Error ? cause.message : 'Could not save this harness' }, { status: 400 });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// A REMOVAL: `{ removeHarness: id }`. Built-ins are refused by name.
|
|
210
|
+
if (typeof body.removeHarness === 'string') {
|
|
211
|
+
const target = body.removeHarness;
|
|
212
|
+
if (isBuiltinHarness(target)) {
|
|
213
|
+
return json({ error: `${target} is a harness this build ships and cannot be removed` }, { status: 400 });
|
|
214
|
+
}
|
|
215
|
+
await removeCustomHarness(target);
|
|
216
|
+
return json({ removed: target });
|
|
217
|
+
}
|
|
180
218
|
const id = typeof body.probe === 'string' ? body.probe : null;
|
|
181
|
-
if (!id || !
|
|
219
|
+
if (!id || !harnessDescriptor(id)) {
|
|
182
220
|
return json({ error: 'probe must name a known harness id' }, { status: 400 });
|
|
183
221
|
}
|
|
184
222
|
// A TOGGLE: `{ probe: id, enabled: boolean }`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the settings card's launch box is told about the agent.
|
|
8
|
+
*
|
|
9
|
+
* The box advertised `agy acp` on every card — Antigravity's line, printed on
|
|
10
|
+
* omp's and Claude's too — and its hint quoted the INSTALL command as "the
|
|
11
|
+
* built-in line". A user typing that hint's example launches nothing, and the
|
|
12
|
+
* form's placeholder claimed a command this harness does not run.
|
|
13
|
+
*
|
|
14
|
+
* So the catalog now carries the line the spawn would actually run, and this
|
|
15
|
+
* pins it to the launch table itself rather than to a second copy.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
19
|
+
|
|
20
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
21
|
+
import { HARNESS_LAUNCH } from '@/server/lib/harness/launch-table';
|
|
22
|
+
import { listHarnesses } from '@/server/routes/harness/root';
|
|
23
|
+
|
|
24
|
+
beforeEach(async () => {
|
|
25
|
+
await isolateDb();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterEach(async () => {
|
|
29
|
+
await releaseDb();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('the catalog carries each harness’s own launch line', () => {
|
|
33
|
+
test('every harness with a launch entry reports that entry’s command', async () => {
|
|
34
|
+
const rows = new Map((await listHarnesses()).map((row) => [row.id, row]));
|
|
35
|
+
for (const [id, launch] of Object.entries(HARNESS_LAUNCH)) {
|
|
36
|
+
if (!launch) continue;
|
|
37
|
+
expect(rows.get(id)?.command, id).toBe(launch.command.join(' '));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('omp and Claude name their own binaries, not Antigravity’s', async () => {
|
|
42
|
+
const rows = new Map((await listHarnesses()).map((row) => [row.id, row]));
|
|
43
|
+
expect(rows.get('omp-acp')?.command).toBe('omp acp');
|
|
44
|
+
expect(rows.get('claude')?.command).toBe(
|
|
45
|
+
'npx -y @agentclientprotocol/claude-agent-acp@0.100.0',
|
|
46
|
+
);
|
|
47
|
+
// The install line is a different fact and must not stand in for the command.
|
|
48
|
+
expect(rows.get('omp-acp')?.command).not.toBe(rows.get('omp-acp')?.install);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* `GET /api/harness/update/status` — every harness's background update record
|
|
7
|
+
* `GET /api/harness/update/status` — every harness's background update record —
|
|
8
|
+
* and `DELETE` on the same path, which dismisses one settled result.
|
|
8
9
|
*
|
|
9
10
|
* The POST answers in milliseconds and the install keeps running in a detached
|
|
10
11
|
* worker, so this is how the dialog learns where each run is and whether it
|
|
@@ -21,12 +22,50 @@
|
|
|
21
22
|
* An empty array is a real answer — no update has ever run — and it must not be
|
|
22
23
|
* a 404: the About card asks this on every open, and a "not found" would read as
|
|
23
24
|
* a broken route rather than "nothing is running".
|
|
25
|
+
*
|
|
26
|
+
* **A settled record is history, and history can be dismissed.** The row used to
|
|
27
|
+
* keep "claude updated (adapter) — it now reports 0.106.0" forever, because the
|
|
28
|
+
* record had no way out: a dismissal has to delete it (or the next open reads it
|
|
29
|
+
* back) and must refuse while the run is still moving — deleting a live record
|
|
30
|
+
* would hide the spinner and let a second install start.
|
|
24
31
|
*/
|
|
25
32
|
|
|
26
33
|
import { json, NO_STORE_HEADERS } from '@/server/lib/remix-compat';
|
|
27
|
-
import {
|
|
34
|
+
import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
|
|
35
|
+
import { methodNotAllowed, parseJsonBody } from '@/server/lib/route-adapter';
|
|
36
|
+
import { getHarnessUpdateStatusPath } from '@/server/lib/lifecycle/paths';
|
|
37
|
+
import { pumpUpdateQueue, serializeUpdateWork } from '@/server/lib/harness/update-queue.server';
|
|
38
|
+
import { readUpdateJob, removeUpdateJob } from '@/server/lib/harness/update-job-store';
|
|
39
|
+
import { isBuiltinHarness } from '@/shared/lib/harness/catalog';
|
|
40
|
+
import { jobUnfinished } from '@/shared/lib/harness/update-job';
|
|
28
41
|
|
|
29
42
|
export async function loader() {
|
|
30
43
|
const jobs = await pumpUpdateQueue();
|
|
31
44
|
return json({ jobs }, { headers: NO_STORE_HEADERS });
|
|
32
45
|
}
|
|
46
|
+
|
|
47
|
+
export async function action({ request, params }: ActionFunctionArgs) {
|
|
48
|
+
if (request.method !== 'DELETE') return methodNotAllowed({ request, params });
|
|
49
|
+
|
|
50
|
+
const parsed = await parseJsonBody<{ harness?: unknown }>(request);
|
|
51
|
+
if (!parsed.ok) return json({ error: 'Request body is not valid JSON' }, { status: 400 });
|
|
52
|
+
const id = parsed.body?.harness;
|
|
53
|
+
if (typeof id !== 'string' || !isBuiltinHarness(id)) {
|
|
54
|
+
return json({ error: 'Unknown harness' }, { status: 400 });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Serialized with the queue's own reads/writes: the post-install probe writes
|
|
58
|
+
// the record after answering, so a delete between its read and its write would
|
|
59
|
+
// otherwise be undone and the dismissed message would come back.
|
|
60
|
+
return serializeUpdateWork(async () => {
|
|
61
|
+
const path = getHarnessUpdateStatusPath(id);
|
|
62
|
+
const job = await readUpdateJob(path);
|
|
63
|
+
if (job && jobUnfinished(job)) {
|
|
64
|
+
return json({
|
|
65
|
+
error: `${job.label} update is still ${job.queuedAt !== null ? 'queued' : 'running'} — nothing to dismiss yet`,
|
|
66
|
+
}, { status: 409, headers: NO_STORE_HEADERS });
|
|
67
|
+
}
|
|
68
|
+
await removeUpdateJob(path);
|
|
69
|
+
return json({ dismissed: true }, { headers: NO_STORE_HEADERS });
|
|
70
|
+
});
|
|
71
|
+
}
|