@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,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creating and unpacking archives for the Files panel.
|
|
8
|
+
*
|
|
9
|
+
* There is no archive library in this repository, and one is not worth adding:
|
|
10
|
+
* every desktop already carries the platform tools, and a pure-JS replacement
|
|
11
|
+
* would still miss `.rar`. So the work is delegated to the system binaries and
|
|
12
|
+
* the module's job is the two things an external command cannot decide for us:
|
|
13
|
+
* which tool is present, and which failure sentence a user reads when none is.
|
|
14
|
+
*
|
|
15
|
+
* The argv is quoted for `/bin/sh` because `runShell` is the one spawn path in
|
|
16
|
+
* the server with a timeout that kills the whole process group — an archive of
|
|
17
|
+
* a large tree must not outlive the request. Output is captured, not parsed:
|
|
18
|
+
* the tools' own stderr is the best description of a refusal.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
import fs from 'node:fs';
|
|
23
|
+
import { runShell, shellOk, type ShellResult } from '@/server/lib/fs/shell';
|
|
24
|
+
import {
|
|
25
|
+
archiveKindOf,
|
|
26
|
+
type ArchiveFormat,
|
|
27
|
+
COMPRESS_FORMATS,
|
|
28
|
+
} from '@/shared/lib/fs/archive';
|
|
29
|
+
|
|
30
|
+
export interface CompressFormatAvailability {
|
|
31
|
+
id: ArchiveFormat;
|
|
32
|
+
label: string;
|
|
33
|
+
extension: string;
|
|
34
|
+
available: boolean;
|
|
35
|
+
/** The binary the format needs, for the dialog's refusal. */
|
|
36
|
+
tool: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A tool name and the binaries that can stand in for it, best first. */
|
|
40
|
+
const TOOLS: Record<string, readonly string[]> = {
|
|
41
|
+
zip: ['zip'],
|
|
42
|
+
unzip: ['unzip'],
|
|
43
|
+
sevenZip: ['7z', '7zz', '7za'],
|
|
44
|
+
rar: ['rar'],
|
|
45
|
+
unrar: ['unrar'],
|
|
46
|
+
tar: ['tar'],
|
|
47
|
+
bsdtar: ['bsdtar'],
|
|
48
|
+
gzip: ['gzip'],
|
|
49
|
+
bzip2: ['bzip2'],
|
|
50
|
+
xz: ['xz'],
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** The first binary of `names` that exists on this machine, or null. */
|
|
54
|
+
export function findTool(names: readonly string[]): string | null {
|
|
55
|
+
for (const name of names) {
|
|
56
|
+
if (Bun.which(name)) return name;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Which compress formats this machine can actually write. */
|
|
62
|
+
export function compressFormats(): CompressFormatAvailability[] {
|
|
63
|
+
return COMPRESS_FORMATS.map((format) => {
|
|
64
|
+
const needed = compressToolFor(format.id);
|
|
65
|
+
return { ...format, available: needed !== null, tool: needed ?? toolLabelFor(format.id) };
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The binary a format writes with, or null when it is not installed. */
|
|
70
|
+
function compressToolFor(format: ArchiveFormat): string | null {
|
|
71
|
+
switch (format) {
|
|
72
|
+
case 'zip':
|
|
73
|
+
return findTool(TOOLS.zip!);
|
|
74
|
+
case '7z':
|
|
75
|
+
return findTool(TOOLS.sevenZip!);
|
|
76
|
+
case 'rar':
|
|
77
|
+
return findTool(TOOLS.rar!);
|
|
78
|
+
case 'tar':
|
|
79
|
+
case 'tar.gz':
|
|
80
|
+
return findTool(TOOLS.tar!);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function toolLabelFor(format: ArchiveFormat): string {
|
|
85
|
+
switch (format) {
|
|
86
|
+
case 'zip':
|
|
87
|
+
return 'zip';
|
|
88
|
+
case '7z':
|
|
89
|
+
return '7z';
|
|
90
|
+
case 'rar':
|
|
91
|
+
return 'rar';
|
|
92
|
+
case 'tar':
|
|
93
|
+
case 'tar.gz':
|
|
94
|
+
return 'tar';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Quote one argument for `/bin/sh`. */
|
|
99
|
+
function q(value: string): string {
|
|
100
|
+
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A bounded, single-line description of a failed command. */
|
|
104
|
+
function failureText(result: { stderr: string; stdout: string }, fallback: string): string {
|
|
105
|
+
const text = (result.stderr.trim() || result.stdout.trim()).split('\n')[0]?.trim();
|
|
106
|
+
return text ? text.slice(0, 300) : fallback;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface CompressOptions {
|
|
110
|
+
/** Absolute folder that becomes the command's working directory. */
|
|
111
|
+
destinationDir: string;
|
|
112
|
+
/** Archive file name, one segment, inside `destinationDir`. */
|
|
113
|
+
name: string;
|
|
114
|
+
format: ArchiveFormat;
|
|
115
|
+
/** Absolute paths of the entries to add; each must live inside the destination. */
|
|
116
|
+
sources: string[];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type ArchiveOutcome = { ok: true; path: string } | { ok: false; error: string; status: number };
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Write `sources` into one new archive beside them.
|
|
123
|
+
*
|
|
124
|
+
* The destination is refused when it exists: the same rule Create, Save As and
|
|
125
|
+
* Rename follow. `--` and a `./` prefix keep a file whose name begins with a
|
|
126
|
+
* dash from being read as an option, and every argument is a path relative to
|
|
127
|
+
* the working directory so the archive stores clean names.
|
|
128
|
+
*/
|
|
129
|
+
export async function compressEntries(options: CompressOptions): Promise<ArchiveOutcome> {
|
|
130
|
+
const { destinationDir, name, format, sources } = options;
|
|
131
|
+
const binary = compressToolFor(format);
|
|
132
|
+
if (!binary) {
|
|
133
|
+
return {
|
|
134
|
+
ok: false,
|
|
135
|
+
status: 501,
|
|
136
|
+
error: `${toolLabelFor(format)} is not installed on this machine`,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
if (sources.length === 0) return { ok: false, status: 400, error: 'Nothing to compress' };
|
|
140
|
+
|
|
141
|
+
const destination = path.join(destinationDir, name);
|
|
142
|
+
if (await Bun.file(destination).exists()) {
|
|
143
|
+
return { ok: false, status: 409, error: `${name} already exists` };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const relative: string[] = [];
|
|
147
|
+
for (const source of sources) {
|
|
148
|
+
const rel = path.relative(destinationDir, source).split(path.sep).join('/');
|
|
149
|
+
if (rel === '' || rel.startsWith('../') || path.isAbsolute(rel)) {
|
|
150
|
+
return {
|
|
151
|
+
ok: false,
|
|
152
|
+
status: 400,
|
|
153
|
+
error: 'Compress into a folder that contains every selected item',
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
relative.push(rel);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const args = relative.map((rel) => `./${rel}`).join(' ');
|
|
160
|
+
const command = (() => {
|
|
161
|
+
switch (format) {
|
|
162
|
+
case 'zip':
|
|
163
|
+
return `${binary} -r -q ${q(name)} ${args}`;
|
|
164
|
+
case '7z':
|
|
165
|
+
return `${binary} a -y -- ${q(name)} ${args}`;
|
|
166
|
+
case 'rar':
|
|
167
|
+
return `${binary} a -r -ep1 ${q(name)} ${args}`;
|
|
168
|
+
case 'tar':
|
|
169
|
+
return `${binary} -cf ${q(name)} ${args}`;
|
|
170
|
+
case 'tar.gz':
|
|
171
|
+
return `${binary} -czf ${q(name)} ${args}`;
|
|
172
|
+
}
|
|
173
|
+
})();
|
|
174
|
+
|
|
175
|
+
const result = await runShell(command, { cwd: destinationDir, timeout: 120_000 });
|
|
176
|
+
if (!shellOk(result)) {
|
|
177
|
+
return { ok: false, status: 500, error: failureText(result, `Could not write ${name}`) };
|
|
178
|
+
}
|
|
179
|
+
return { ok: true, path: destination };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface ExtractOptions {
|
|
183
|
+
/** Absolute archive path. */
|
|
184
|
+
archivePath: string;
|
|
185
|
+
/** Absolute folder the entries land in; created when missing. */
|
|
186
|
+
destinationDir: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Unpack one archive into `destinationDir`. */
|
|
190
|
+
export async function extractArchive(options: ExtractOptions): Promise<ArchiveOutcome> {
|
|
191
|
+
const { archivePath, destinationDir } = options;
|
|
192
|
+
const kind = archiveKindOf(path.basename(archivePath));
|
|
193
|
+
if (!kind) return { ok: false, status: 400, error: 'That file is not a recognised archive' };
|
|
194
|
+
|
|
195
|
+
const stat = await Bun.file(archivePath).stat().catch(() => null);
|
|
196
|
+
if (!stat || stat.isDirectory()) return { ok: false, status: 404, error: 'That archive no longer exists' };
|
|
197
|
+
|
|
198
|
+
await fs.promises.mkdir(destinationDir, { recursive: true });
|
|
199
|
+
|
|
200
|
+
const quotedArchive = q(archivePath);
|
|
201
|
+
const quotedDestination = q(destinationDir);
|
|
202
|
+
const run = (command: string) => runShell(command, { timeout: 300_000 });
|
|
203
|
+
|
|
204
|
+
const archive = quotedArchive;
|
|
205
|
+
const dest = quotedDestination;
|
|
206
|
+
const sevenZip = findTool(TOOLS.sevenZip!);
|
|
207
|
+
const bsdtar = findTool(TOOLS.bsdtar!);
|
|
208
|
+
|
|
209
|
+
switch (kind) {
|
|
210
|
+
case 'zip': {
|
|
211
|
+
const unzip = findTool(TOOLS.unzip!);
|
|
212
|
+
if (unzip) return outcome(await run(`${unzip} -o -q ${archive} -d ${dest}`), archivePath);
|
|
213
|
+
if (bsdtar) return outcome(await run(`${bsdtar} -xf ${archive} -C ${dest}`), archivePath);
|
|
214
|
+
return missingTool('unzip');
|
|
215
|
+
}
|
|
216
|
+
case '7z': {
|
|
217
|
+
if (sevenZip) return outcome(await run(`${sevenZip} x -y -o${dest} ${archive}`), archivePath);
|
|
218
|
+
if (bsdtar) return outcome(await run(`${bsdtar} -xf ${archive} -C ${dest}`), archivePath);
|
|
219
|
+
return missingTool('7z');
|
|
220
|
+
}
|
|
221
|
+
case 'rar': {
|
|
222
|
+
const unrar = findTool(TOOLS.unrar!);
|
|
223
|
+
if (unrar) return outcome(await run(`${unrar} x -o+ ${archive} ${dest}`), archivePath);
|
|
224
|
+
if (sevenZip) return outcome(await run(`${sevenZip} x -y -o${dest} ${archive}`), archivePath);
|
|
225
|
+
if (bsdtar) return outcome(await run(`${bsdtar} -xf ${archive} -C ${dest}`), archivePath);
|
|
226
|
+
return missingTool('unrar or 7z');
|
|
227
|
+
}
|
|
228
|
+
case 'tar':
|
|
229
|
+
case 'tar.gz':
|
|
230
|
+
case 'tar.bz2':
|
|
231
|
+
case 'tar.xz': {
|
|
232
|
+
const tar = findTool(TOOLS.tar!);
|
|
233
|
+
if (tar) return outcome(await run(`${tar} -xf ${archive} -C ${dest}`), archivePath);
|
|
234
|
+
if (bsdtar) return outcome(await run(`${bsdtar} -xf ${archive} -C ${dest}`), archivePath);
|
|
235
|
+
return missingTool('tar');
|
|
236
|
+
}
|
|
237
|
+
case 'gz':
|
|
238
|
+
case 'bz2':
|
|
239
|
+
case 'xz': {
|
|
240
|
+
const decompressor = kind === 'gz' ? findTool(TOOLS.gzip!) : kind === 'bz2' ? findTool(TOOLS.bzip2!) : findTool(TOOLS.xz!);
|
|
241
|
+
const outName = path.basename(archivePath).replace(/\.(gz|bz2|xz)$/i, '');
|
|
242
|
+
const out = q(path.join(destinationDir, outName));
|
|
243
|
+
if (decompressor) {
|
|
244
|
+
return outcome(await run(`${decompressor} -dc ${archive} > ${out}`), outName);
|
|
245
|
+
}
|
|
246
|
+
if (bsdtar) return outcome(await run(`${bsdtar} -xf ${archive} -C ${dest}`), archivePath);
|
|
247
|
+
return missingTool(kind);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function outcome(result: ShellResult, successPath: string): ArchiveOutcome {
|
|
253
|
+
if (shellOk(result)) return { ok: true, path: successPath };
|
|
254
|
+
return { ok: false, status: 500, error: failureText(result, 'The archive could not be extracted') };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function missingTool(name: string): ArchiveOutcome {
|
|
258
|
+
return { ok: false, status: 501, error: `No tool available to extract this archive (install ${name})` };
|
|
259
|
+
}
|
|
@@ -51,6 +51,7 @@ beforeAll(() => {
|
|
|
51
51
|
git('config', 'user.name', 'Test');
|
|
52
52
|
write('mod.txt', EIGHT_LINES);
|
|
53
53
|
write('staged.txt', 's1\n');
|
|
54
|
+
write('both.txt', 'b1\nb2\nb3\n');
|
|
54
55
|
write('clean.txt', 'c1\n');
|
|
55
56
|
write('deleted.txt', 'd1\nd2\n');
|
|
56
57
|
write('sub dir/f.txt', 'sub1\n');
|
|
@@ -73,6 +74,11 @@ beforeAll(() => {
|
|
|
73
74
|
write('mod.txt', 'l1\nl2\nCHANGED\nl4\nl5\nl6\nl7\nl8\n');
|
|
74
75
|
write('staged.txt', 's1\ns2\n');
|
|
75
76
|
git('add', 'staged.txt');
|
|
77
|
+
// One file with BOTH a staged edit and a further unstaged edit: the two
|
|
78
|
+
// views must not answer with the same pair.
|
|
79
|
+
write('both.txt', 'b1\nSTAGED\nb3\n');
|
|
80
|
+
git('add', 'both.txt');
|
|
81
|
+
write('both.txt', 'b1\nSTAGED\nWORKTREE\n');
|
|
76
82
|
write('untracked.txt', 'u1\nu2\n');
|
|
77
83
|
git('rm', '-q', 'deleted.txt');
|
|
78
84
|
write('sub dir/f.txt', 'sub1\nsub2\n');
|
|
@@ -124,8 +130,27 @@ describe('tracked changes', () => {
|
|
|
124
130
|
expect(result.diff).toContain('+s2');
|
|
125
131
|
});
|
|
126
132
|
|
|
133
|
+
// A file can be in both lists at once. The staged view is HEAD -> index and
|
|
134
|
+
// the unstaged view is index -> working file; reading HEAD vs the working
|
|
135
|
+
// file for both made the two tabs show the same patch.
|
|
136
|
+
test('a file with staged and unstaged edits reports a different pair per view', async () => {
|
|
137
|
+
const staged = await fetchWorkingFileDiff(repo, 'both.txt', true);
|
|
138
|
+
expect(staged.oldContent).toBe('b1\nb2\nb3\n');
|
|
139
|
+
expect(staged.newContent).toBe('b1\nSTAGED\nb3\n');
|
|
140
|
+
expect(staged.diff).toContain('+STAGED');
|
|
141
|
+
expect(staged.diff).not.toContain('WORKTREE');
|
|
142
|
+
|
|
143
|
+
const unstaged = await fetchWorkingFileDiff(repo, 'both.txt', false);
|
|
144
|
+
expect(unstaged.oldContent).toBe('b1\nSTAGED\nb3\n');
|
|
145
|
+
expect(unstaged.newContent).toBe('b1\nSTAGED\nWORKTREE\n');
|
|
146
|
+
expect(unstaged.diff).toContain('+WORKTREE');
|
|
147
|
+
expect(unstaged.diff).not.toContain('+STAGED');
|
|
148
|
+
});
|
|
149
|
+
|
|
127
150
|
test('a deletion is counted as deletions, not additions', async () => {
|
|
128
|
-
|
|
151
|
+
// `git rm` stages the deletion, so the staged view is the one that carries
|
|
152
|
+
// it; the unstaged view of the same file has nothing left to compare.
|
|
153
|
+
const result = await fetchWorkingFileDiff(repo, 'deleted.txt', true);
|
|
129
154
|
expect(result.status).toBe('D');
|
|
130
155
|
expect(result.additions).toBe(0);
|
|
131
156
|
expect(result.deletions).toBe(2);
|
|
@@ -24,6 +24,18 @@ async function gitOut(args: string[], cwd: string, timeout: number, maxBuffer: n
|
|
|
24
24
|
return result.error === undefined && result.exitCode === 0 ? result.stdout : '';
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* One `git show <rev>` read, or `null` when the rev does not resolve.
|
|
29
|
+
*
|
|
30
|
+
* Distinct from `gitOut` because `''` is a real answer here: a file that is
|
|
31
|
+
* empty in the index or at HEAD must not be confused with a path that is
|
|
32
|
+
* absent from that tree — the pair below is chosen from which side exists.
|
|
33
|
+
*/
|
|
34
|
+
async function gitShow(rev: string, cwd: string): Promise<string | null> {
|
|
35
|
+
const result = await runGit(['show', rev], { cwd, timeout: 5000 });
|
|
36
|
+
return result.error === undefined && result.exitCode === 0 ? result.stdout : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
/**
|
|
28
40
|
* Fetch git diff for a specific file in the working directory or index.
|
|
29
41
|
*
|
|
@@ -68,16 +80,34 @@ export async function fetchWorkingFileDiff(
|
|
|
68
80
|
status = statusLine.slice(0, 2).trim() || status;
|
|
69
81
|
}
|
|
70
82
|
|
|
71
|
-
//
|
|
83
|
+
// The two SIDES depend on which view was asked for, and reading them off
|
|
84
|
+
// the wrong trees is what made a file's staged and unstaged views
|
|
85
|
+
// identical: a staged read compares HEAD with the index, an unstaged read
|
|
86
|
+
// compares the index with the working file. Reading HEAD vs the working
|
|
87
|
+
// file for both is a different diff from either.
|
|
88
|
+
const headContent = await gitShow(`HEAD:${cleanFile}`, targetDir);
|
|
89
|
+
const indexContent = await gitShow(`:0:${cleanFile}`, targetDir);
|
|
90
|
+
let workingContent = '';
|
|
72
91
|
try {
|
|
73
|
-
|
|
92
|
+
workingContent = await Bun.file(fullPath).text();
|
|
74
93
|
} catch {
|
|
75
|
-
|
|
94
|
+
workingContent = '';
|
|
95
|
+
}
|
|
96
|
+
if (staged) {
|
|
97
|
+
oldContent = headContent ?? '';
|
|
98
|
+
// `null` means the path is not in the index. For a staged deletion that
|
|
99
|
+
// is the empty side of the pair, not a reason to fall back to the file;
|
|
100
|
+
// an untracked path has no index entry either, and its "would be added"
|
|
101
|
+
// side is the file on disk.
|
|
102
|
+
newContent = indexContent ?? (status === '??' ? workingContent : '');
|
|
103
|
+
} else {
|
|
104
|
+
// An untracked or unmerged path has no stage-0 entry; its "before" side is
|
|
105
|
+
// HEAD for the unmerged case and empty otherwise. A path deleted from the
|
|
106
|
+
// index (`git rm --cached`) is the exception: its index side is empty, so
|
|
107
|
+
// HEAD would claim a change the working tree does not have.
|
|
108
|
+
oldContent = indexContent ?? (status.startsWith('D') ? '' : headContent ?? '');
|
|
109
|
+
newContent = workingContent;
|
|
76
110
|
}
|
|
77
|
-
|
|
78
|
-
// Read old content from index or HEAD
|
|
79
|
-
oldContent = await gitOut(['show', `HEAD:${cleanFile}`], targetDir, 5000)
|
|
80
|
-
|| await gitOut(['show', `:0:${cleanFile}`], targetDir, 5000);
|
|
81
111
|
|
|
82
112
|
// `-U<n>` on every probe: the full-code mode asks for the whole file, and
|
|
83
113
|
// the diff-only mode keeps git's own default by passing no flag at all.
|
|
@@ -91,21 +121,19 @@ export async function fetchWorkingFileDiff(
|
|
|
91
121
|
? Math.max(1024 * 1024 * 16, (oldContent.length + newContent.length) * 2 + 1024 * 1024)
|
|
92
122
|
: 1024 * 1024 * 2;
|
|
93
123
|
|
|
124
|
+
// No fallbacks between the two views. `git diff --cached` is the staged
|
|
125
|
+
// view and `git diff` is the unstaged one; substituting the other when the
|
|
126
|
+
// asked-for diff is empty is how a file listed under "Changes" showed its
|
|
127
|
+
// staged patch.
|
|
94
128
|
if (staged) {
|
|
95
|
-
|
|
96
|
-
diff = await gitOut(['diff', ...ctx, '--cached', '--', cleanFile], targetDir, 10000, buf)
|
|
97
|
-
|| await gitOut(['diff', ...ctx, 'HEAD', '--', cleanFile], targetDir, 10000, buf)
|
|
98
|
-
|| await gitOut(['diff', ...ctx, '--', cleanFile], targetDir, 10000, buf);
|
|
129
|
+
diff = await gitOut(['diff', ...ctx, '--cached', '--', cleanFile], targetDir, 10000, buf);
|
|
99
130
|
} else if (status === '??' || status === 'U' || status === '?') {
|
|
100
131
|
// Untracked file: `--no-index` exits 1 when it produced a diff, so read
|
|
101
132
|
// stdout directly instead of relying on the exit code.
|
|
102
133
|
const untracked = await runGit(['diff', ...ctx, '--no-index', '/dev/null', cleanFile], { cwd: targetDir, timeout: 10000, maxBuffer: buf });
|
|
103
134
|
diff = untracked.stdout.trim() ? untracked.stdout : '';
|
|
104
135
|
} else {
|
|
105
|
-
|
|
106
|
-
diff = await gitOut(['diff', ...ctx, '--', cleanFile], targetDir, 10000, buf)
|
|
107
|
-
|| await gitOut(['diff', ...ctx, '--cached', '--', cleanFile], targetDir, 10000, buf)
|
|
108
|
-
|| await gitOut(['diff', ...ctx, 'HEAD', '--', cleanFile], targetDir, 10000, buf);
|
|
136
|
+
diff = await gitOut(['diff', ...ctx, '--', cleanFile], targetDir, 10000, buf);
|
|
109
137
|
}
|
|
110
138
|
|
|
111
139
|
// 4. If git diff is still empty but new content exists:
|
|
@@ -25,17 +25,15 @@
|
|
|
25
25
|
* explicitly refused — never dropped.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import type { Subprocess } from 'bun';
|
|
29
|
-
import { readLines } from '@/server/lib/omp/rpc/lines';
|
|
30
28
|
import { PendingCalls } from '@/server/lib/harness/acp/calls';
|
|
31
|
-
import {
|
|
32
|
-
import { stripKabmoHostEnv, withToolchainPath } from '@kabmo-labs/kabmo-sdk';
|
|
29
|
+
import { AgentStdio } from '@/server/lib/harness/acp/stdio';
|
|
33
30
|
import * as verbs from '@/server/lib/harness/acp/verbs';
|
|
34
31
|
import { initializeAcpAgent } from '@/server/lib/harness/acp/client-initialize';
|
|
35
32
|
import { ACP_ERROR } from '@/server/lib/harness/acp/protocol';
|
|
36
33
|
import type {
|
|
37
34
|
AcpId,
|
|
38
35
|
AcpInitializeResult,
|
|
36
|
+
AcpMcpServer,
|
|
39
37
|
AcpNotification,
|
|
40
38
|
AcpProtocolVersion,
|
|
41
39
|
AcpRequest,
|
|
@@ -72,15 +70,13 @@ export interface AcpClientOptions {
|
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
const DEFAULT_REQUEST_TIMEOUT_MS = 60_000;
|
|
75
|
-
const STDERR_TAIL_LIMIT = 8_000;
|
|
76
73
|
|
|
77
74
|
export class AcpProcess {
|
|
78
|
-
private readonly
|
|
75
|
+
private readonly stdio: AgentStdio;
|
|
79
76
|
private readonly pending = new PendingCalls();
|
|
80
77
|
private readonly options: AcpClientOptions;
|
|
81
78
|
private nextId = 1;
|
|
82
79
|
private exited = false;
|
|
83
|
-
private stderrTail = '';
|
|
84
80
|
private writeQueue: Promise<void> = Promise.resolve();
|
|
85
81
|
/** The negotiated ACP major. 1 until `initialize` answers; every verb that
|
|
86
82
|
* changed shape between versions reads it. */
|
|
@@ -88,49 +84,38 @@ export class AcpProcess {
|
|
|
88
84
|
/** Set once `initialize` answers, so a request sent earlier fails loudly
|
|
89
85
|
* instead of racing the handshake. */
|
|
90
86
|
private initialized = false;
|
|
87
|
+
/** The one `initialize` this process ever runs. A prewarmed child is handed
|
|
88
|
+
* to a session that would otherwise handshake a second time; the cached
|
|
89
|
+
* answer is what makes adopting it free. */
|
|
90
|
+
private init: Promise<AcpInitializeResult> | null = null;
|
|
91
|
+
/** The frame sinks, re-bindable: a prewarmed process is created before the
|
|
92
|
+
* session that will own it exists, so its handlers are attached at claim. */
|
|
93
|
+
private sinks: Pick<AcpClientOptions, 'onNotification' | 'onClientRequest' | 'onExit' | 'onStderr'>;
|
|
91
94
|
|
|
92
95
|
constructor(options: AcpClientOptions) {
|
|
93
96
|
this.options = options;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
process.platform,
|
|
99
|
-
);
|
|
100
|
-
try {
|
|
101
|
-
this.child = Bun.spawn({
|
|
102
|
-
cmd: [command, ...args],
|
|
97
|
+
this.sinks = options;
|
|
98
|
+
this.stdio = new AgentStdio(
|
|
99
|
+
{
|
|
100
|
+
command: options.command,
|
|
103
101
|
cwd: options.cwd,
|
|
104
|
-
env:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
void readLines(this.child.stderr, (line) => {
|
|
122
|
-
this.stderrTail = `${this.stderrTail}${line}\n`.slice(-STDERR_TAIL_LIMIT);
|
|
123
|
-
this.options.onStderr?.(line);
|
|
124
|
-
});
|
|
125
|
-
void this.child.exited.then((code) => {
|
|
126
|
-
this.exited = true;
|
|
127
|
-
// The agent's own last words, when it left any: `exited (code 0)` is what
|
|
128
|
-
// a shadowed/deprecated binary prints while it explains itself on stderr,
|
|
129
|
-
// and without the tail the spawn failure names nothing actionable.
|
|
130
|
-
const detail = this.stderrTail.trim().split('\n').slice(-3).join(' · ');
|
|
131
|
-
this.rejectAll(new Error(`ACP agent exited (code ${code})${detail ? ` — ${detail}` : ''}`));
|
|
132
|
-
this.options.onExit?.({ code, signal: null, stderrTail: this.stderrTail });
|
|
133
|
-
});
|
|
102
|
+
...(options.env ? { env: options.env } : {}),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
onLine: (line) => this.handleLine(line),
|
|
106
|
+
onStderr: (line) => this.sinks.onStderr?.(line),
|
|
107
|
+
onExit: ({ code, stderrTail }) => {
|
|
108
|
+
this.exited = true;
|
|
109
|
+
// The agent's own last words, when it left any: `exited (code 0)` is
|
|
110
|
+
// what a shadowed/deprecated binary prints while it explains itself on
|
|
111
|
+
// stderr, and without the tail the spawn failure names nothing
|
|
112
|
+
// actionable.
|
|
113
|
+
const detail = stderrTail.trim().split('\n').slice(-3).join(' · ');
|
|
114
|
+
this.rejectAll(new Error(`ACP agent exited (code ${code})${detail ? ` — ${detail}` : ''}`));
|
|
115
|
+
this.sinks.onExit?.({ code, signal: null, stderrTail });
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
);
|
|
134
119
|
}
|
|
135
120
|
|
|
136
121
|
get isAlive(): boolean {
|
|
@@ -138,15 +123,35 @@ export class AcpProcess {
|
|
|
138
123
|
}
|
|
139
124
|
|
|
140
125
|
get pid(): number | undefined {
|
|
141
|
-
return this.
|
|
126
|
+
return this.stdio.pid;
|
|
142
127
|
}
|
|
143
128
|
|
|
144
|
-
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
129
|
+
/**
|
|
130
|
+
* `initialize`; the client advertises exactly what it can serve.
|
|
131
|
+
*
|
|
132
|
+
* Idempotent: a prewarmed process has already answered, and the session that
|
|
133
|
+
* adopts it must not pay a second round trip (or, worse, send a second
|
|
134
|
+
* `initialize` the agent may refuse).
|
|
135
|
+
*/
|
|
136
|
+
initialize(capabilities?: Record<string, unknown>, timeoutMs = 60_000): Promise<AcpInitializeResult> {
|
|
137
|
+
this.init ??= initializeAcpAgent(this.call, capabilities, timeoutMs).then((result) => {
|
|
138
|
+
this.protocolVersion = result.protocolVersion === 2 ? 2 : 1;
|
|
139
|
+
this.initialized = true;
|
|
140
|
+
return result;
|
|
141
|
+
});
|
|
142
|
+
return this.init;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Re-bind the frame sinks.
|
|
147
|
+
*
|
|
148
|
+
* A prewarmed process is spawned before the session that will own it exists,
|
|
149
|
+
* so its notifications and agent→client requests have nowhere to go until the
|
|
150
|
+
* claim. Attaching here is what makes the warm child indistinguishable from a
|
|
151
|
+
* cold one for the rest of its life.
|
|
152
|
+
*/
|
|
153
|
+
attachSinks(sinks: Pick<AcpClientOptions, 'onNotification' | 'onClientRequest' | 'onExit' | 'onStderr'>): void {
|
|
154
|
+
this.sinks = sinks;
|
|
150
155
|
}
|
|
151
156
|
|
|
152
157
|
get hasInitialized(): boolean {
|
|
@@ -157,20 +162,27 @@ export class AcpProcess {
|
|
|
157
162
|
// Thin delegates to `verbs.ts`: the transport owns framing, the verbs own the
|
|
158
163
|
// wire shape. Callers keep using `proc.newSession(...)`.
|
|
159
164
|
|
|
160
|
-
newSession(cwd: string, timeoutMs?: number) {
|
|
161
|
-
return verbs.newSession(this.call, cwd, timeoutMs, this.protocolVersion);
|
|
165
|
+
newSession(cwd: string, timeoutMs?: number, mcpServers?: AcpMcpServer[]) {
|
|
166
|
+
return verbs.newSession(this.call, cwd, timeoutMs, this.protocolVersion, mcpServers);
|
|
162
167
|
}
|
|
163
168
|
|
|
164
|
-
loadSession(sessionId: string, cwd: string, timeoutMs?: number) {
|
|
165
|
-
return verbs.loadSession(this.call, sessionId, cwd, timeoutMs);
|
|
169
|
+
loadSession(sessionId: string, cwd: string, timeoutMs?: number, mcpServers?: AcpMcpServer[]) {
|
|
170
|
+
return verbs.loadSession(this.call, sessionId, cwd, timeoutMs, mcpServers);
|
|
166
171
|
}
|
|
167
172
|
|
|
168
|
-
resumeSession(sessionId: string, cwd: string, timeoutMs?: number) {
|
|
169
|
-
return verbs.resumeSession(this.call, sessionId, cwd, timeoutMs, this.protocolVersion);
|
|
173
|
+
resumeSession(sessionId: string, cwd: string, timeoutMs?: number, mcpServers?: AcpMcpServer[]) {
|
|
174
|
+
return verbs.resumeSession(this.call, sessionId, cwd, timeoutMs, this.protocolVersion, mcpServers);
|
|
170
175
|
}
|
|
171
176
|
|
|
172
|
-
forkSession(
|
|
173
|
-
|
|
177
|
+
forkSession(
|
|
178
|
+
sessionId: string,
|
|
179
|
+
cwd: string,
|
|
180
|
+
timeoutMs?: number,
|
|
181
|
+
target?: Record<string, unknown>,
|
|
182
|
+
meta?: Record<string, unknown>,
|
|
183
|
+
mcpServers?: AcpMcpServer[],
|
|
184
|
+
) {
|
|
185
|
+
return verbs.forkSession(this.call, sessionId, cwd, timeoutMs, target, meta, mcpServers);
|
|
174
186
|
}
|
|
175
187
|
|
|
176
188
|
listSessions(cwd?: string, timeoutMs?: number) {
|
|
@@ -239,23 +251,7 @@ export class AcpProcess {
|
|
|
239
251
|
/** Graceful then forceful shutdown of the whole process group. */
|
|
240
252
|
async dispose(gracePeriodMs = 5_000): Promise<void> {
|
|
241
253
|
if (this.exited) return;
|
|
242
|
-
|
|
243
|
-
try {
|
|
244
|
-
this.child.stdin.end();
|
|
245
|
-
} catch {
|
|
246
|
-
// Already closed.
|
|
247
|
-
}
|
|
248
|
-
const term = setTimeout(() => {
|
|
249
|
-
if (!this.exited) killProcessTree(this.child.pid, false, 'SIGTERM');
|
|
250
|
-
}, gracePeriodMs);
|
|
251
|
-
const kill = setTimeout(() => {
|
|
252
|
-
if (!this.exited) killProcessTree(this.child.pid, true, 'SIGKILL');
|
|
253
|
-
}, gracePeriodMs * 2);
|
|
254
|
-
term.unref?.();
|
|
255
|
-
kill.unref?.();
|
|
256
|
-
await exited;
|
|
257
|
-
clearTimeout(term);
|
|
258
|
-
clearTimeout(kill);
|
|
254
|
+
await this.stdio.dispose(gracePeriodMs);
|
|
259
255
|
this.rejectAll(new Error('ACP agent disposed'));
|
|
260
256
|
}
|
|
261
257
|
|
|
@@ -284,14 +280,12 @@ export class AcpProcess {
|
|
|
284
280
|
private write(frame: AcpRequest | AcpNotification | AcpResponse): void {
|
|
285
281
|
if (this.exited) return;
|
|
286
282
|
const line = `${JSON.stringify(frame)}\n`;
|
|
283
|
+
// Serialized: two frames interleaved on one pipe would corrupt the stream,
|
|
284
|
+
// and a closed pipe is reported by `exited` rather than thrown into the
|
|
285
|
+
// queue (which would wedge every later frame).
|
|
287
286
|
this.writeQueue = this.writeQueue.then(async () => {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
await this.child.stdin.flush();
|
|
291
|
-
} catch {
|
|
292
|
-
// A closed pipe is reported by `exited`; the writer must not throw into
|
|
293
|
-
// the queue and wedge every later frame.
|
|
294
|
-
}
|
|
287
|
+
this.stdio.write(line);
|
|
288
|
+
await this.stdio.flush();
|
|
295
289
|
});
|
|
296
290
|
}
|
|
297
291
|
|
|
@@ -315,7 +309,7 @@ export class AcpProcess {
|
|
|
315
309
|
if (record.id !== undefined && record.id !== null) {
|
|
316
310
|
void this.handleAgentRequest(record.id as AcpId, record.method, record.params);
|
|
317
311
|
} else {
|
|
318
|
-
this.
|
|
312
|
+
this.sinks.onNotification(record.method, (record.params ?? {}) as Record<string, unknown>);
|
|
319
313
|
}
|
|
320
314
|
return;
|
|
321
315
|
}
|
|
@@ -327,7 +321,7 @@ export class AcpProcess {
|
|
|
327
321
|
private async handleAgentRequest(id: AcpId, method: string, params: unknown): Promise<void> {
|
|
328
322
|
const bag = (params ?? {}) as Record<string, unknown>;
|
|
329
323
|
try {
|
|
330
|
-
const handled = await this.
|
|
324
|
+
const handled = await this.sinks.onClientRequest?.(id, method, bag);
|
|
331
325
|
if (handled?.answered) {
|
|
332
326
|
this.respond(id, handled.result);
|
|
333
327
|
return;
|