@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
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
import { attachmentHasPayload } from '@/shared/lib/chat/attachments';
|
|
34
34
|
import { parseModeSelection } from '@/server/lib/omp/mode/request';
|
|
35
35
|
import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
|
|
36
|
+
import { resolveSessionRef } from '@/server/lib/sessions/resolve.server';
|
|
36
37
|
import { isMockMode } from '@/server/mock.server';
|
|
37
38
|
|
|
38
39
|
/** GET — every prompt a client may still need (waiting + recent outcomes). */
|
|
@@ -61,6 +62,19 @@ async function createPrompt(request: Request) {
|
|
|
61
62
|
}
|
|
62
63
|
const prompt = typeof body.prompt === 'string' ? body.prompt : '';
|
|
63
64
|
const attachments = Array.isArray(body.attachments) ? body.attachments : [];
|
|
65
|
+
// A NEXT prompt in an existing chat names its target; a pending chat names
|
|
66
|
+
// none and the dispatch spawns the session. The two are exclusive: a prompt
|
|
67
|
+
// with both would either spawn a second chat or silently pick one.
|
|
68
|
+
const targetSessionId = typeof body.targetSessionId === 'string' ? body.targetSessionId.trim() : '';
|
|
69
|
+
if (targetSessionId && !isSinglePathSegment(targetSessionId)) {
|
|
70
|
+
return json({ error: 'The target session id is not valid', code: 'target_invalid' }, { status: 400 });
|
|
71
|
+
}
|
|
72
|
+
if (targetSessionId && targetSessionId === dependsOn) {
|
|
73
|
+
return json(
|
|
74
|
+
{ error: 'A prompt cannot wait for the session it is sent to.', code: 'target_self' },
|
|
75
|
+
{ status: 400 },
|
|
76
|
+
);
|
|
77
|
+
}
|
|
64
78
|
// Same rule the composer's own send guard applies: an empty prompt is not a
|
|
65
79
|
// prompt. Without it a row would be created, spawn a session, and deliver
|
|
66
80
|
// nothing to it.
|
|
@@ -68,11 +82,15 @@ async function createPrompt(request: Request) {
|
|
|
68
82
|
return json({ error: 'The prompt is empty', code: 'prompt_required' }, { status: 400 });
|
|
69
83
|
}
|
|
70
84
|
const cwd = typeof body.cwd === 'string' ? body.cwd.trim() : '';
|
|
85
|
+
// An existing chat already has a home: its session's own cwd is the truthful
|
|
86
|
+
// answer, and a client that forgot to send one must not be refused. The spawn
|
|
87
|
+
// path still requires an absolute directory (a new chat has no other source).
|
|
88
|
+
const resolvedCwd = cwd || (targetSessionId ? (await resolveSessionRef(targetSessionId)).cwd ?? '' : '');
|
|
71
89
|
// `isAbsolute`, not `startsWith('/')`: a Windows workspace names its directory
|
|
72
90
|
// `C:\…`, and the POSIX-only test refused every hold there with
|
|
73
91
|
// `cwd_required` — the prompt was sent immediately instead of being held
|
|
74
92
|
// (measured on the Windows CI leg of `waiting-prompt.e2e.ts`).
|
|
75
|
-
if (!isAbsolute(
|
|
93
|
+
if (!isAbsolute(resolvedCwd)) {
|
|
76
94
|
return json({ error: 'An absolute working directory is required', code: 'cwd_required' }, { status: 400 });
|
|
77
95
|
}
|
|
78
96
|
if (await isDependencySettled(dependsOn)) {
|
|
@@ -86,11 +104,12 @@ async function createPrompt(request: Request) {
|
|
|
86
104
|
pendingId: typeof body.pendingId === 'string' ? body.pendingId : null,
|
|
87
105
|
dependsOn,
|
|
88
106
|
dependsOnTitle: typeof body.dependsOnTitle === 'string' ? body.dependsOnTitle : null,
|
|
107
|
+
targetSessionId: targetSessionId || null,
|
|
89
108
|
prompt,
|
|
90
109
|
attachments,
|
|
91
110
|
model: body.model,
|
|
92
111
|
modes: body.modes === undefined ? null : parseModeSelection(asRecord(body.modes)),
|
|
93
|
-
cwd,
|
|
112
|
+
cwd: resolvedCwd,
|
|
94
113
|
folderId: typeof body.folderId === 'number' ? body.folderId : null,
|
|
95
114
|
});
|
|
96
115
|
emitRealtimeSignal('waiting-changed');
|
|
@@ -118,4 +118,25 @@ describe('/api/waiting — the rest of the validation order', () => {
|
|
|
118
118
|
await call({ dependsOn: 'sess-anything', prompt: 'x', cwd: 'relative/path' });
|
|
119
119
|
expect(await listWaitingPrompts()).toHaveLength(0);
|
|
120
120
|
});
|
|
121
|
+
|
|
122
|
+
test('a prompt cannot wait for the chat it is sent to', async () => {
|
|
123
|
+
const res = await call({ dependsOn: 'sess-a', targetSessionId: 'sess-a', prompt: 'x', cwd: '/tmp/x' });
|
|
124
|
+
expect(res.status).toBe(400);
|
|
125
|
+
expect(res.body.code).toBe('target_self');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('a target id that could name a path is refused', async () => {
|
|
129
|
+
const res = await call({ dependsOn: 'sess-a', targetSessionId: '../sess', prompt: 'x', cwd: '/tmp/x' });
|
|
130
|
+
expect(res.status).toBe(400);
|
|
131
|
+
expect(res.body.code).toBe('target_invalid');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// An existing chat's home is its session's own cwd. When neither the client
|
|
135
|
+
// nor the session can name one, the hold is refused rather than stored with
|
|
136
|
+
// an empty directory for a later sweep to spawn into.
|
|
137
|
+
test('a target session with no resolvable cwd is refused', async () => {
|
|
138
|
+
const res = await call({ dependsOn: 'sess-a', targetSessionId: 'unknown-session', prompt: 'x' });
|
|
139
|
+
expect(res.status).toBe(400);
|
|
140
|
+
expect(res.body.code).toBe('cwd_required');
|
|
141
|
+
});
|
|
121
142
|
});
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
import type { AskQuestion } from '@/shared/lib/chat/ask-form/types';
|
|
24
24
|
import { toQuestions, type DraftField, type DraftOption } from '@/shared/lib/chat/ask-form/fields';
|
|
25
|
+
import { IGNORED_INPUTS, readLabelTargets } from '@/shared/lib/chat/ask-form/labels';
|
|
25
26
|
import {
|
|
26
27
|
BLOCK,
|
|
27
28
|
findChild,
|
|
@@ -36,34 +37,6 @@ import {
|
|
|
36
37
|
type Token,
|
|
37
38
|
} from '@/shared/lib/chat/ask-form/tokens';
|
|
38
39
|
|
|
39
|
-
const IGNORED_INPUTS: Record<string, true> = {
|
|
40
|
-
button: true,
|
|
41
|
-
file: true,
|
|
42
|
-
image: true,
|
|
43
|
-
reset: true,
|
|
44
|
-
submit: true,
|
|
45
|
-
hidden: true,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/** Pre-pass: ids of controls, and the `<label for>` text that names them. */
|
|
49
|
-
function readLabelTargets(tokens: Token[]): Map<string, string> {
|
|
50
|
-
const ids = new Set<string>();
|
|
51
|
-
for (const token of tokens) {
|
|
52
|
-
if (token.kind !== 'open') continue;
|
|
53
|
-
if (token.tag !== 'input' && token.tag !== 'select' && token.tag !== 'textarea') continue;
|
|
54
|
-
if (token.attrs.id) ids.add(token.attrs.id);
|
|
55
|
-
}
|
|
56
|
-
const labels = new Map<string, string>();
|
|
57
|
-
for (let index = 0; index < tokens.length; index += 1) {
|
|
58
|
-
const token = tokens[index];
|
|
59
|
-
if (token.kind !== 'open' || token.tag !== 'label' || token.selfClosing) continue;
|
|
60
|
-
const target = token.attrs.for;
|
|
61
|
-
if (!target || !ids.has(target) || labels.has(target)) continue;
|
|
62
|
-
labels.set(target, textOf(tokens, index + 1, matchingClose(tokens, index, 'label')));
|
|
63
|
-
}
|
|
64
|
-
return labels;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
40
|
/** Fields of one form, in document order, with the question text omp derives. */
|
|
68
41
|
export function parseAskForm(html: string): AskQuestion[] {
|
|
69
42
|
if (!html.trim()) return [];
|
|
@@ -84,7 +57,12 @@ export function parseAskForm(html: string): AskQuestion[] {
|
|
|
84
57
|
};
|
|
85
58
|
|
|
86
59
|
const addField = (field: DraftField) => {
|
|
60
|
+
// The text block immediately before a control is its caption (omp's
|
|
61
|
+
// `fieldQuestions`), so the pending inline run must be flushed BEFORE the
|
|
62
|
+
// field is built — flushing after left `<span>Which?</span><select>` with
|
|
63
|
+
// the control's own name as its question.
|
|
87
64
|
flush();
|
|
65
|
+
field.caption = caption;
|
|
88
66
|
fields.push(field);
|
|
89
67
|
caption = '';
|
|
90
68
|
};
|
|
@@ -104,7 +82,10 @@ export function parseAskForm(html: string): AskQuestion[] {
|
|
|
104
82
|
const value = attrs.value ?? 'on';
|
|
105
83
|
const option: DraftOption = {
|
|
106
84
|
value,
|
|
107
|
-
|
|
85
|
+
// omp's fallback is the RAW `value` attribute, else the name — not the
|
|
86
|
+
// `on` default a valueless checkbox submits. Using `on` made a lone
|
|
87
|
+
// checkbox's question "on" while omp's dialog title was its name.
|
|
88
|
+
label: controlLabel(attrs, wrapping) || attrs.value || name,
|
|
108
89
|
checked: 'checked' in attrs,
|
|
109
90
|
disabled: 'disabled' in attrs,
|
|
110
91
|
};
|
|
@@ -212,7 +193,12 @@ export function parseAskForm(html: string): AskQuestion[] {
|
|
|
212
193
|
else if (tag === 'input') addInput(token.attrs, wrapping);
|
|
213
194
|
continue;
|
|
214
195
|
}
|
|
215
|
-
|
|
196
|
+
// An unclosed tag (`<span class="truncate">` written literally inside a
|
|
197
|
+
// code span) has no `</span>`; `matchingClose` then answers the end of the
|
|
198
|
+
// document, and walking to it re-walked every field after the enclosing
|
|
199
|
+
// block — the same question appeared twice and the frame could not be
|
|
200
|
+
// placed. Clamp to the range this walk owns.
|
|
201
|
+
const close = Math.min(matchingClose(tokens, index, tag), end);
|
|
216
202
|
if (SKIPPED[tag]) {
|
|
217
203
|
index = close;
|
|
218
204
|
continue;
|
|
@@ -267,7 +253,20 @@ export function parseAskForm(html: string): AskQuestion[] {
|
|
|
267
253
|
index = close;
|
|
268
254
|
continue;
|
|
269
255
|
}
|
|
270
|
-
|
|
256
|
+
// A `<table>` of controls (a decision matrix) is LAYOUT: omp walks it, so
|
|
257
|
+
// the row's text captions the control and the field survives. Treating
|
|
258
|
+
// every table as prose dropped the fields entirely, and a tool call whose
|
|
259
|
+
// questions never parsed cannot claim its dialogs — the whole ask fell to
|
|
260
|
+
// the modal.
|
|
261
|
+
if (tag === 'table') {
|
|
262
|
+
settle();
|
|
263
|
+
if (hasControl(tokens, index + 1, close)) walk(index + 1, close, wrapping, depth, quiet);
|
|
264
|
+
else if (!quiet) caption = '';
|
|
265
|
+
settle();
|
|
266
|
+
index = close;
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (tag === 'ul' || tag === 'ol' || tag === 'pre') {
|
|
271
270
|
settle();
|
|
272
271
|
// A list of controls is layout; any other list is a block, which clears
|
|
273
272
|
// the caption the next field would otherwise borrow.
|
|
@@ -280,6 +279,15 @@ export function parseAskForm(html: string): AskQuestion[] {
|
|
|
280
279
|
index = close;
|
|
281
280
|
continue;
|
|
282
281
|
}
|
|
282
|
+
// Cell boundaries separate one cell's text from the next; without them
|
|
283
|
+
// every cell in a row ran together into one caption.
|
|
284
|
+
if (tag === 'td' || tag === 'th' || tag === 'tr') {
|
|
285
|
+
settle();
|
|
286
|
+
walk(index + 1, close, wrapping, depth, quiet);
|
|
287
|
+
settle();
|
|
288
|
+
index = close;
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
283
291
|
if (tag === 'input') {
|
|
284
292
|
addInput(token.attrs, wrapping);
|
|
285
293
|
continue;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Controls Kabmo does not ask about, and the `<label for>` pre-pass that names
|
|
8
|
+
* the ones it does.
|
|
9
|
+
*
|
|
10
|
+
* A `<label for="id">` sits anywhere in the form, so its text cannot be read
|
|
11
|
+
* while walking — the control it names may come first. This collects those
|
|
12
|
+
* pairs up front, keyed by the control's id, and the walk consults the map when
|
|
13
|
+
* a control has no wrapping `<label>`. Split from `ask-form/index.ts` (which
|
|
14
|
+
* owns the walk) to keep that file under the repo's per-file ceiling.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { matchingClose, textOf, type Token } from '@/shared/lib/chat/ask-form/tokens';
|
|
18
|
+
|
|
19
|
+
/** Input types that are never a question: chrome, or state the form carries. */
|
|
20
|
+
export const IGNORED_INPUTS: Record<string, true> = {
|
|
21
|
+
button: true,
|
|
22
|
+
file: true,
|
|
23
|
+
image: true,
|
|
24
|
+
reset: true,
|
|
25
|
+
submit: true,
|
|
26
|
+
hidden: true,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Ids of the controls in the token range, and the `<label for>` text naming them. */
|
|
30
|
+
export function readLabelTargets(tokens: Token[]): Map<string, string> {
|
|
31
|
+
const ids = new Set<string>();
|
|
32
|
+
for (const token of tokens) {
|
|
33
|
+
if (token.kind !== 'open') continue;
|
|
34
|
+
if (token.tag !== 'input' && token.tag !== 'select' && token.tag !== 'textarea') continue;
|
|
35
|
+
if (token.attrs.id) ids.add(token.attrs.id);
|
|
36
|
+
}
|
|
37
|
+
const labels = new Map<string, string>();
|
|
38
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
39
|
+
const token = tokens[index];
|
|
40
|
+
if (token.kind !== 'open' || token.tag !== 'label' || token.selfClosing) continue;
|
|
41
|
+
const target = token.attrs.for;
|
|
42
|
+
if (!target || !ids.has(target) || labels.has(target)) continue;
|
|
43
|
+
labels.set(target, textOf(tokens, index + 1, matchingClose(tokens, index, 'label')));
|
|
44
|
+
}
|
|
45
|
+
return labels;
|
|
46
|
+
}
|
|
@@ -157,10 +157,19 @@ export function textOf(tokens: Token[], start: number, end: number): string {
|
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
159
159
|
if (SKIPPED[tag]) {
|
|
160
|
-
index = matchingClose(tokens, index, tag);
|
|
160
|
+
index = Math.min(matchingClose(tokens, index, tag), end);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
// A control's CONTENT is not text: `<select>`'s options and a `<textarea>`'s
|
|
164
|
+
// value are answers, not the label around them. Skipping only the opening
|
|
165
|
+
// tag leaked every option label into a wrapping `<label>`'s text, so the
|
|
166
|
+
// question read "Akun … prod Akun client … tidak yakin" while omp's dialog
|
|
167
|
+
// title was "Akun … prod" — and the frame could not be claimed.
|
|
168
|
+
if (tag === 'input') continue;
|
|
169
|
+
if (tag === 'select' || tag === 'textarea') {
|
|
170
|
+
index = Math.min(matchingClose(tokens, index, tag), end);
|
|
161
171
|
continue;
|
|
162
172
|
}
|
|
163
|
-
if (tag === 'input' || tag === 'select' || tag === 'textarea') continue;
|
|
164
173
|
if (tag === 'br') parts.push('\n');
|
|
165
174
|
else if (tag === 'img') parts.push(token.attrs.alt ?? '');
|
|
166
175
|
else if (BLOCK[tag] || HEADING[tag]) parts.push(' ');
|
|
@@ -134,4 +134,61 @@ describe('parseAskForm', () => {
|
|
|
134
134
|
const questions = parseAskForm(`<form><label>Yes <input type="radio" name="ok" value="yes"></label></form>`);
|
|
135
135
|
expect(questions[0].question).toBe('Yes');
|
|
136
136
|
});
|
|
137
|
+
|
|
138
|
+
// The question text is the key `splitAskFrames` matches a live dialog's title
|
|
139
|
+
// against. Every case below was measured against omp's own `fieldQuestions`
|
|
140
|
+
// (pi-tui `html-form/data.ts`) on a real session form; a divergence here is a
|
|
141
|
+
// dialog that cannot be claimed and falls to the modal.
|
|
142
|
+
test('a <label> wrapping a <select> names the question without the option text', () => {
|
|
143
|
+
const questions = parseAskForm(`<form>
|
|
144
|
+
<label>Akun yang dipakai di mobilebroadcast prod
|
|
145
|
+
<select name="account">
|
|
146
|
+
<option value="client">Akun client (punya client_id)</option>
|
|
147
|
+
<option value="internal">Akun Jatis / internal</option>
|
|
148
|
+
</select>
|
|
149
|
+
</label>
|
|
150
|
+
</form>`);
|
|
151
|
+
|
|
152
|
+
expect(questions[0].question).toBe('Akun yang dipakai di mobilebroadcast prod');
|
|
153
|
+
expect(questions[0].options.map((option) => option.label)).toEqual([
|
|
154
|
+
'Akun client (punya client_id)',
|
|
155
|
+
'Akun Jatis / internal',
|
|
156
|
+
]);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('inline text before a control captions it, with or without a <br>', () => {
|
|
160
|
+
const span = parseAskForm(`<form><span>Which database?</span><select name="db"><option>a</option><option>b</option></select></form>`);
|
|
161
|
+
const br = parseAskForm(`<form>Which one?<br><select name="pick"><option>a</option><option>b</option></select></form>`);
|
|
162
|
+
|
|
163
|
+
expect(span[0].question).toBe('Which database?');
|
|
164
|
+
expect(br[0].question).toBe('Which one?');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('a table of controls is layout: its cell text captions the field', () => {
|
|
168
|
+
const questions = parseAskForm(`<form>
|
|
169
|
+
<table><tr><td>Pick one</td><td><select name="pick"><option>a</option><option>b</option></select></td></tr></table>
|
|
170
|
+
</form>`);
|
|
171
|
+
|
|
172
|
+
expect(questions).toHaveLength(1);
|
|
173
|
+
expect(questions[0]).toMatchObject({ id: 'pick', question: 'Pick one' });
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('an unclosed inline tag does not re-walk the rest of the form', () => {
|
|
177
|
+
// A model wrote `<span class="truncate">` literally inside a code span, so
|
|
178
|
+
// it never closes. Walking to the end of the document duplicated every
|
|
179
|
+
// field after it, and the duplicated question could not be placed.
|
|
180
|
+
const questions = parseAskForm(`<form>
|
|
181
|
+
<p>a \`<span class="truncate">\` b</p>
|
|
182
|
+
<fieldset><legend>Lokasi</legend><label><input type="radio" name="lokasi" value="a" checked> A</label></fieldset>
|
|
183
|
+
<label>D <input type="text" name="d"></label>
|
|
184
|
+
</form>`);
|
|
185
|
+
|
|
186
|
+
expect(questions.map((question) => question.id)).toEqual(['lokasi', 'd']);
|
|
187
|
+
expect(questions[0].options.map((option) => option.label)).toEqual(['A']);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test('a lone checkbox with no value asks its name, not the submitted "on"', () => {
|
|
191
|
+
const questions = parseAskForm(`<form><input type="checkbox" name="ok"> I agree</form>`);
|
|
192
|
+
expect(questions[0].question).toBe('ok');
|
|
193
|
+
});
|
|
137
194
|
});
|
|
@@ -99,6 +99,37 @@ export function isAskToolCall(tool: ToolCallData): boolean {
|
|
|
99
99
|
return name === 'ask' || tool.title === 'ask';
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Index of the question a dialog's OPTION LIST names, when its title does not.
|
|
104
|
+
*
|
|
105
|
+
* omp titles a per-field dialog with the question it derived, and Kabmo derives
|
|
106
|
+
* that text from the same form — but the two parsers can disagree on a shape
|
|
107
|
+
* neither was written for, and a title that matches nothing used to hand the
|
|
108
|
+
* frame to the modal. The offered rows are the same list either way, so they
|
|
109
|
+
* are the fallback key: the question's own options (minus the synthetic
|
|
110
|
+
* "Other" row) must be exactly the rows the dialog offers (minus omp's "Other"
|
|
111
|
+
* and multi-select "Done" rows), and there must be at least two of them.
|
|
112
|
+
*/
|
|
113
|
+
export function askQuestionForOptions(questions: AskQuestion[], options: unknown): number {
|
|
114
|
+
if (!Array.isArray(options)) return -1;
|
|
115
|
+
const offered = new Set(
|
|
116
|
+
options
|
|
117
|
+
.filter((option): option is string => typeof option === 'string')
|
|
118
|
+
.map(normalizeAskText)
|
|
119
|
+
.filter((label) => label && !isOtherOption(label) && !/done selecting$/.test(label)),
|
|
120
|
+
);
|
|
121
|
+
if (offered.size < 2) return -1;
|
|
122
|
+
let best = -1;
|
|
123
|
+
for (let index = 0; index < questions.length; index += 1) {
|
|
124
|
+
const labels = questions[index].options
|
|
125
|
+
.map((option) => normalizeAskText(option.label))
|
|
126
|
+
.filter((label) => label && !isOtherOption(label));
|
|
127
|
+
if (labels.length < 2 || labels.length !== offered.size) continue;
|
|
128
|
+
if (labels.every((label) => offered.has(label))) best = index;
|
|
129
|
+
}
|
|
130
|
+
return best;
|
|
131
|
+
}
|
|
132
|
+
|
|
102
133
|
/**
|
|
103
134
|
* True for an ask omp has given up on — its dialog was withdrawn (a validation
|
|
104
135
|
* failure, an abort), so no live frame can belong to it and its card renders no
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* known agent name.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import { harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
21
21
|
|
|
22
22
|
export interface HarnessDelegation {
|
|
23
23
|
harness: HarnessId;
|
|
@@ -59,7 +59,7 @@ const HARNESS_ALIASES: Readonly<Record<string, HarnessId>> = {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
function harnessIdFor(name: string): HarnessId | null {
|
|
62
|
-
return HARNESS_ALIASES[name] ?? (
|
|
62
|
+
return HARNESS_ALIASES[name] ?? (harnessDescriptor(name) ? (name as HarnessId) : null);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -182,7 +182,7 @@ export function formatDelegationPrompt(plan: DelegationPlan): string {
|
|
|
182
182
|
const model = delegation.model ?? 'default model';
|
|
183
183
|
lines.push(
|
|
184
184
|
'',
|
|
185
|
-
`${index + 1}. ${
|
|
185
|
+
`${index + 1}. ${harnessDescriptor(delegation.harness)?.label ?? delegation.harness} · ${model}`,
|
|
186
186
|
delegationCommand(delegation, index),
|
|
187
187
|
);
|
|
188
188
|
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The composer's recall cursor: no wrap at either end, the draft restored on
|
|
8
|
+
* the way back down, and the caret rules that keep a multi-line draft's arrows
|
|
9
|
+
* ordinary.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { describe, expect, test } from 'bun:test';
|
|
13
|
+
import { canRecallDown, canRecallUp, stepHistoryCursor } from '@/shared/lib/chat/composer/history';
|
|
14
|
+
|
|
15
|
+
describe('stepHistoryCursor', () => {
|
|
16
|
+
test('ArrowUp enters the newest entry from the draft', () => {
|
|
17
|
+
expect(stepHistoryCursor(3, -1, 'up')).toBe(0);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('ArrowUp walks older and stops at the oldest entry', () => {
|
|
21
|
+
expect(stepHistoryCursor(3, 0, 'up')).toBe(1);
|
|
22
|
+
expect(stepHistoryCursor(3, 1, 'up')).toBe(2);
|
|
23
|
+
expect(stepHistoryCursor(3, 2, 'up')).toBeNull();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('ArrowDown walks newer and returns to the draft', () => {
|
|
27
|
+
expect(stepHistoryCursor(3, 2, 'down')).toBe(1);
|
|
28
|
+
expect(stepHistoryCursor(3, 0, 'down')).toBe(-1);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('ArrowDown from the draft is not a recall', () => {
|
|
32
|
+
expect(stepHistoryCursor(3, -1, 'down')).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('an empty list recalls nothing', () => {
|
|
36
|
+
expect(stepHistoryCursor(0, -1, 'up')).toBeNull();
|
|
37
|
+
expect(stepHistoryCursor(0, 0, 'down')).toBeNull();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('canRecallUp', () => {
|
|
42
|
+
test('an empty draft recalls', () => {
|
|
43
|
+
expect(canRecallUp('', 0)).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('the first line recalls', () => {
|
|
47
|
+
expect(canRecallUp('one line', 4)).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('a caret below the first line moves the caret instead', () => {
|
|
51
|
+
expect(canRecallUp('first\nsecond', 8)).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('a caret at the start of the second line still moves the caret', () => {
|
|
55
|
+
expect(canRecallUp('first\nsecond', 6)).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('canRecallDown', () => {
|
|
60
|
+
test('the last line recalls', () => {
|
|
61
|
+
expect(canRecallDown('first\nsecond', 12)).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('a caret above the last line moves the caret instead', () => {
|
|
65
|
+
expect(canRecallDown('first\nsecond', 2)).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The composer's prompt recall: which commands carry the operator's own words,
|
|
8
|
+
* and how the ArrowUp / ArrowDown cursor moves through the list.
|
|
9
|
+
*
|
|
10
|
+
* Shared because both ends need the same vocabulary: the server records a
|
|
11
|
+
* prompt when one of these commands enters, and the client walks the list it
|
|
12
|
+
* gets back. The cursor rules are pure so the boundaries (no wrap at either
|
|
13
|
+
* end, the draft restored past the newest entry) are testable without a
|
|
14
|
+
* textarea.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Commands whose `message` is text the operator typed in the composer.
|
|
19
|
+
*
|
|
20
|
+
* `prompt` is the ordinary send; `steer` and `follow_up` are the mid-run
|
|
21
|
+
* variants (Ctrl+Enter / Send Now); `abort_and_prompt` is the legacy steer the
|
|
22
|
+
* older clients still post. Everything else — `set_model`, `abort`, a mode
|
|
23
|
+
* request — carries no prompt.
|
|
24
|
+
*/
|
|
25
|
+
export const RECALLABLE_COMMAND_TYPES: Record<string, true> = {
|
|
26
|
+
prompt: true,
|
|
27
|
+
steer: true,
|
|
28
|
+
follow_up: true,
|
|
29
|
+
abort_and_prompt: true,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type HistoryDirection = 'up' | 'down';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The next cursor in a NEWEST-FIRST list, or `null` when the key must do
|
|
36
|
+
* nothing.
|
|
37
|
+
*
|
|
38
|
+
* `-1` is the draft the operator was typing: ArrowUp from there enters the
|
|
39
|
+
* list at its newest entry, ArrowDown from there is a plain caret move, and
|
|
40
|
+
* ArrowDown from the oldest entry walks back to the draft. Neither end wraps.
|
|
41
|
+
*/
|
|
42
|
+
export function stepHistoryCursor(length: number, cursor: number, direction: HistoryDirection): number | null {
|
|
43
|
+
if (length <= 0) return null;
|
|
44
|
+
if (direction === 'up') return cursor + 1 < length ? cursor + 1 : null;
|
|
45
|
+
return cursor > -1 ? cursor - 1 : null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether ArrowUp may recall instead of moving the caret: the caret has to be
|
|
50
|
+
* on the FIRST line, so a multi-line draft keeps its normal arrow behavior.
|
|
51
|
+
*/
|
|
52
|
+
export function canRecallUp(text: string, caret: number | null): boolean {
|
|
53
|
+
const position = caret ?? text.length;
|
|
54
|
+
return !text.slice(0, position).includes('\n');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The mirror rule for ArrowDown: the caret has to be on the LAST line. */
|
|
58
|
+
export function canRecallDown(text: string, caret: number | null): boolean {
|
|
59
|
+
const position = caret ?? text.length;
|
|
60
|
+
return !text.slice(position).includes('\n');
|
|
61
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A peer (IRC) message omp injected into a session.
|
|
8
|
+
*
|
|
9
|
+
* Since 18.18.9 a message that ends a `wait` no longer rides in the wait's
|
|
10
|
+
* result (`CoordinationDetails.waited`): omp hands it to the recipient session,
|
|
11
|
+
* which injects it as a `customType: "irc:incoming"` turn whose content is the
|
|
12
|
+
* `<irc>` prompt envelope. `wait` itself now answers with
|
|
13
|
+
* `Wait interrupted by message.` and `details.interrupted: true`.
|
|
14
|
+
*
|
|
15
|
+
* The envelope is prompt text for the model, not a transcript row: rendered
|
|
16
|
+
* as-is it shows the reply instructions and the raw tag. The turn's `details`
|
|
17
|
+
* carries the sender and the body verbatim, so both transcript mappers read
|
|
18
|
+
* that instead, and a session recorded before 18.18.9 (whose wait result still
|
|
19
|
+
* carries `waited`) keeps rendering through the wait card.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type { IrcMessageData } from '@/shared/types/omp/session';
|
|
23
|
+
import { isRecord } from '@/shared/lib/util/guards';
|
|
24
|
+
|
|
25
|
+
/** The `customType` omp stamps on an injected peer message. */
|
|
26
|
+
export const IRC_INCOMING_CUSTOM_TYPE = 'irc:incoming';
|
|
27
|
+
|
|
28
|
+
/** The peer message in a `details` object, or null when the shape is not one. */
|
|
29
|
+
export function ircMessageFromDetails(details: unknown): IrcMessageData | null {
|
|
30
|
+
if (!isRecord(details)) return null;
|
|
31
|
+
const from = typeof details.from === 'string' ? details.from.trim() : '';
|
|
32
|
+
const message = typeof details.message === 'string' ? details.message.trim() : '';
|
|
33
|
+
if (!from || !message) return null;
|
|
34
|
+
return {
|
|
35
|
+
...(typeof details.id === 'string' && details.id ? { id: details.id } : {}),
|
|
36
|
+
from,
|
|
37
|
+
message,
|
|
38
|
+
...(typeof details.replyTo === 'string' && details.replyTo ? { replyTo: details.replyTo } : {}),
|
|
39
|
+
...(details.progress === true ? { progress: true } : {}),
|
|
40
|
+
...(details.broadcast === true ? { broadcast: true } : {}),
|
|
41
|
+
};
|
|
42
|
+
}
|