@kabmo-labs/kabmo 0.17.0 → 0.19.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/README.md +10 -7
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +523 -441
- package/dist/client/static/js/{index-rerjq5th.js → index-fcee4c13.js} +828 -818
- package/dist/client/static/js/index-sxdw908m.css +1 -0
- package/marketplace/plugins/command-runner/package.json +3 -2
- package/marketplace/plugins/git-forge/package.json +3 -2
- package/marketplace/plugins/session-info/package.json +3 -2
- package/marketplace/plugins/stats/package.json +3 -2
- package/package.json +3 -1
- package/src/client/components/auth/login-screen/index.tsx +2 -1
- package/src/client/components/common/ComposerPicker.tsx +1 -1
- package/src/client/components/common/FolderPicker.tsx +2 -2
- package/src/client/components/common/MarkdownRenderer.tsx +136 -89
- package/src/client/components/common/Modal.tsx +2 -2
- package/src/client/components/common/PWAInstallButton.tsx +2 -2
- package/src/client/components/common/ViewportSelector.tsx +1 -1
- package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
- package/src/client/components/common/anchored-menu/index.tsx +147 -0
- package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
- package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
- package/src/client/components/common/brand-wordmark/index.tsx +13 -2
- package/src/client/components/common/checkbox/style.test.ts +139 -0
- package/src/client/components/common/checkbox/style.ts +51 -0
- package/src/client/components/common/context-usage-button/index.tsx +2 -2
- package/src/client/components/common/file-icon/index.tsx +23 -9
- package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
- package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
- package/src/client/components/common/markdown-review/index.tsx +129 -0
- package/src/client/components/common/panel-mark/index.tsx +97 -0
- package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
- package/src/client/components/common/provider-icon/index.test.ts +14 -0
- package/src/client/components/common/provider-icon/index.tsx +4 -0
- package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
- package/src/client/components/common/provider-icon/resolve.ts +16 -3
- package/src/client/components/common/server-control/Panel.tsx +33 -23
- package/src/client/components/common/server-control/index.test.tsx +11 -5
- package/src/client/components/common/server-control/index.tsx +10 -8
- package/src/client/components/common/session-actions-menu/index.tsx +1 -1
- package/src/client/components/common/toolbar-row/index.tsx +1 -1
- package/src/client/components/layout/ActivityBar.tsx +22 -3
- package/src/client/components/layout/LeftDock.tsx +9 -2
- package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
- package/src/client/components/layout/WindowAura.tsx +27 -0
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
- package/src/client/components/layout/desktop-layout/index.tsx +3 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +44 -23
- package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
- package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
- package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +40 -14
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
- package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
- package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
- package/src/client/components/layout/update-popup/index.tsx +5 -1
- package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
- package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
- package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
- package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
- package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/mobile/panel-chips.tsx +10 -2
- package/src/client/components/settings/Modal.tsx +4 -4
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
- package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
- package/src/client/components/settings/apply-side-effects.test.ts +30 -0
- package/src/client/components/settings/apply-side-effects.ts +14 -0
- package/src/client/components/settings/categories/AgentSettings.tsx +23 -50
- package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
- package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
- package/src/client/components/settings/categories/McpSettings.tsx +4 -21
- package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
- package/src/client/components/settings/categories/SkillSettings.tsx +2 -2
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
- package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
- package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
- package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +9 -2
- package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
- package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
- package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
- package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +93 -77
- package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +28 -15
- package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
- package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
- package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
- package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
- package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
- package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
- package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
- package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
- package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
- package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +37 -8
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +34 -14
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +21 -0
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +15 -6
- package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
- package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
- package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
- package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
- package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
- package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
- package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
- package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
- package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
- package/src/client/components/workspace/browser-panel/index.tsx +50 -4
- package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
- package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
- package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
- package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
- package/src/client/components/workspace/diff-panel/changes.ts +28 -12
- package/src/client/components/workspace/diff-panel/index.tsx +2 -2
- package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
- package/src/client/components/workspace/diff-panel/merge.ts +21 -1
- package/src/client/components/workspace/editor/Body.tsx +7 -0
- package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
- package/src/client/components/workspace/editor/FilePane.tsx +12 -0
- package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
- package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
- package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
- package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
- package/src/client/components/workspace/editor/Tabs.tsx +1 -1
- package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
- package/src/client/components/workspace/editor/index.tsx +25 -22
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
- package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
- package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
- package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
- package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
- package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
- package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
- package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
- package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
- package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
- package/src/client/components/workspace/git-panel/index.tsx +7 -0
- package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
- package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
- package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
- package/src/client/components/workspace/search-panel/Body.tsx +1 -1
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
- package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
- package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
- package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
- package/src/client/data/agent-data/builtin.ts +0 -10
- package/src/client/data/agent-data/orchestrator.ts +0 -45
- package/src/client/data/agent-data/specialist.ts +0 -100
- package/src/client/data/mock/token-usage.ts +170 -120
- package/src/client/data/settings/omp-schema.json +33 -1
- package/src/client/glass.css +785 -0
- package/src/client/glass.test.ts +346 -0
- package/src/client/hooks/browser/use-annotate.test.ts +143 -0
- package/src/client/hooks/browser/use-annotate.ts +98 -0
- package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
- package/src/client/hooks/browser/use-close-tab.ts +67 -0
- package/src/client/hooks/browser/use-screencast.ts +13 -1
- package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
- package/src/client/hooks/chat/composer/browser-context.ts +40 -16
- package/src/client/hooks/chat/composer/items.test.ts +1 -1
- package/src/client/hooks/chat/composer/review-context.ts +38 -0
- package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
- package/src/client/hooks/chat/composer/use-draft.ts +31 -2
- package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
- package/src/client/hooks/editor/use-document-annotations.ts +124 -0
- package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
- package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
- package/src/client/hooks/editor/use-preview-review.ts +148 -0
- package/src/client/hooks/settings/agents.ts +149 -0
- package/src/client/hooks/settings/crud-list.test.ts +28 -6
- package/src/client/hooks/settings/crud-list.ts +96 -57
- package/src/client/hooks/settings/omp-config.ts +164 -0
- package/src/client/hooks/settings/useTokenUsage.ts +125 -0
- package/src/client/hooks/settings/write-feedback.test.ts +104 -0
- package/src/client/hooks/settings/write-feedback.ts +63 -0
- package/src/client/hooks/ui/glass-support.ts +57 -0
- package/src/client/hooks/ui/icon-style.ts +59 -0
- package/src/client/hooks/ui/markdown-hydration.ts +125 -0
- package/src/client/hooks/ui/stuck-header.test.ts +188 -0
- package/src/client/hooks/ui/stuck-header.ts +91 -0
- package/src/client/hooks/ui/style-attributes.test.ts +120 -0
- package/src/client/hooks/ui/surface-style.ts +56 -0
- package/src/client/hooks/ui/updates/index.test.ts +100 -1
- package/src/client/hooks/ui/updates/index.ts +50 -0
- package/src/client/hooks/ui/updates/notes.test.ts +138 -0
- package/src/client/hooks/ui/updates/notes.ts +57 -0
- package/src/client/hooks/workspace/panel-hues.ts +23 -0
- package/src/client/lib/browser/element-at.test.ts +229 -0
- package/src/client/lib/browser/element-at.ts +139 -0
- package/src/client/lib/review/client.ts +73 -0
- package/src/client/lib/router/search-params.ts +42 -20
- package/src/client/main.tsx +10 -0
- package/src/client/tailwind.css +329 -11
- package/src/server/lib/assets/shell-attributes.server.ts +80 -0
- package/src/server/lib/assets/shell-attributes.test.ts +86 -0
- package/src/server/lib/btw/lifecycle.server.ts +2 -2
- package/src/server/lib/db/schema.ts +7 -0
- package/src/server/lib/db/seed-terminal.test.ts +4 -0
- package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
- package/src/server/lib/omp/config/agents.ts +231 -61
- package/src/server/lib/omp/config/definitions.test.ts +9 -105
- package/src/server/lib/omp/config/extensions.ts +16 -7
- package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
- package/src/server/lib/omp/rpc/constants.test.ts +11 -0
- package/src/server/lib/omp/rpc/constants.ts +15 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
- package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
- package/src/server/lib/omp/rpc/manager.ts +2 -2
- package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
- package/src/server/lib/omp/rpc/process.test.ts +106 -0
- package/src/server/lib/omp/rpc/process.ts +39 -18
- package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
- package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
- package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
- package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
- package/src/server/lib/omp/rpc/session-commands.ts +17 -3
- package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
- package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
- package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
- package/src/server/lib/omp/rpc/utility.ts +12 -0
- package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
- package/src/server/lib/panels/manifest.test.ts +20 -0
- package/src/server/lib/panels/manifest.ts +12 -0
- package/src/server/lib/panels/scan.server.ts +4 -0
- package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
- package/src/server/lib/queue/delivery-harness.ts +8 -4
- package/src/server/lib/queue/delivery.server.test.ts +29 -0
- package/src/server/lib/queue/delivery.server.ts +39 -0
- package/src/server/lib/queue/store.server.test.ts +22 -2
- package/src/server/lib/queue/store.server.ts +33 -11
- package/src/server/lib/review/schema.server.ts +45 -0
- package/src/server/lib/review/store.server.ts +138 -0
- package/src/server/lib/terminal/attach-replay.test.ts +132 -0
- package/src/server/lib/terminal/output.test.ts +166 -0
- package/src/server/lib/terminal/output.ts +104 -0
- package/src/server/lib/terminal/runtime.server.ts +5 -0
- package/src/server/lib/terminal/send-result.test.ts +33 -0
- package/src/server/lib/terminal/send-result.ts +32 -0
- package/src/server/lib/terminal/session.server.ts +45 -11
- package/src/server/lib/terminal/store-liveness.test.ts +4 -0
- package/src/server/lib/updates/active-notes.test.ts +149 -0
- package/src/server/lib/updates/active-notes.ts +75 -0
- package/src/server/lib/updates/changelog-file.ts +42 -11
- package/src/server/lib/updates/changelog.test.ts +15 -1
- package/src/server/lib/updates/omp.ts +42 -15
- package/src/server/lib/updates/release-url.ts +27 -1
- package/src/server/lib/usage/index-parse.test.ts +200 -0
- package/src/server/lib/usage/index-parse.ts +178 -0
- package/src/server/lib/usage/index-query.server.ts +248 -0
- package/src/server/lib/usage/index-scan.server.ts +343 -0
- package/src/server/lib/usage/index-schema.server.ts +82 -0
- package/src/server/lib/usage/index.test.ts +234 -0
- package/src/server/lib/usage/providers.server.ts +4 -53
- package/src/server/plugins/ssr.ts +22 -5
- package/src/server/routes/browser/index.ts +3 -0
- package/src/server/routes/browser/stream.ts +31 -2
- package/src/server/routes/browser/tabs.test.ts +94 -0
- package/src/server/routes/browser/tabs.ts +85 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/review/bindings.ts +11 -0
- package/src/server/routes/review/index.ts +127 -0
- package/src/server/routes/review/routes.test.ts +191 -0
- package/src/server/routes/settings/agents.test.ts +180 -0
- package/src/server/routes/settings/agents.ts +95 -102
- package/src/server/routes/settings/mcp.test.ts +135 -0
- package/src/server/routes/settings/mcp.ts +14 -6
- package/src/server/routes/settings/settings-store-routes.test.ts +6 -113
- package/src/server/routes/telemetry/tokens.test.ts +145 -0
- package/src/server/routes/telemetry/tokens.ts +70 -149
- package/src/server/routes/terminal/ws.ts +6 -5
- package/src/server/routes/updates/index.ts +2 -0
- package/src/server/routes/updates/notes.ts +34 -0
- package/src/server/routes/updates/routes.test.ts +49 -0
- package/src/shared/lib/browser/annotate.test.ts +283 -0
- package/src/shared/lib/browser/annotate.ts +231 -0
- package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
- package/src/shared/lib/browser/frame-gate.test.ts +91 -0
- package/src/shared/lib/browser/frame-gate.ts +69 -0
- package/src/shared/lib/browser/frame-params.test.ts +43 -0
- package/src/shared/lib/browser/frame-params.ts +60 -0
- package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
- package/src/shared/lib/browser/frame-pipeline.ts +80 -0
- package/src/shared/lib/browser/page-context.ts +60 -4
- package/src/shared/lib/browser/snapshot.test.ts +115 -0
- package/src/shared/lib/browser/snapshot.ts +112 -0
- package/src/shared/lib/browser/tab-close.test.ts +74 -0
- package/src/shared/lib/browser/tab-close.ts +77 -0
- package/src/shared/lib/browser/viewer.ts +45 -26
- package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
- package/src/shared/lib/chat/tool/artifact.ts +55 -20
- package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
- package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
- package/src/shared/lib/chat/tool/minimized.ts +64 -0
- package/src/shared/lib/chat/tool/summary.test.ts +28 -8
- package/src/shared/lib/chat/tool/summary.ts +3 -32
- package/src/shared/lib/icons/file-brand-color.ts +38 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
- package/src/shared/lib/icons/icon-paint-css.ts +284 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
- package/src/shared/lib/icons/tint.test.ts +273 -0
- package/src/shared/lib/icons/tint.ts +219 -0
- package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
- package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
- package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
- package/src/shared/lib/markdown/blocks/scan.ts +100 -0
- package/src/shared/lib/markdown/blocks/types.ts +62 -0
- package/src/shared/lib/markdown/marked.ts +58 -147
- package/src/shared/lib/markdown/math-extensions.ts +168 -0
- package/src/shared/lib/markdown/review/prompt.ts +77 -0
- package/src/shared/lib/markdown/review/reconcile.ts +55 -0
- package/src/shared/lib/markdown/review/review.test.ts +96 -0
- package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
- package/src/shared/lib/markdown/xml-sections.ts +139 -0
- package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
- package/src/shared/lib/models/provider/brand-color.ts +103 -0
- package/src/shared/lib/models/provider/label.ts +57 -0
- package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
- package/src/shared/lib/omp/config/agent-file.ts +43 -0
- package/src/shared/lib/omp/config/row-value.test.ts +95 -0
- package/src/shared/lib/omp/config/row-value.ts +97 -0
- package/src/shared/lib/omp/config/schema.test.ts +31 -0
- package/src/shared/lib/omp/config/schema.ts +6 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +113 -47
- package/src/shared/lib/omp/rpc/frame.ts +107 -43
- package/src/shared/lib/settings/defaults.ts +4 -0
- package/src/shared/lib/theme/catalog.test.ts +5 -4
- package/src/shared/lib/theme/catalog.ts +18 -3
- package/src/shared/lib/theme/glass-support.test.ts +38 -0
- package/src/shared/lib/theme/glass-support.ts +73 -0
- package/src/shared/lib/theme/icon-style.test.ts +74 -0
- package/src/shared/lib/theme/icon-style.ts +90 -0
- package/src/shared/lib/theme/legibility.ts +91 -0
- package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
- package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
- package/src/shared/lib/theme/surface-style.test.ts +68 -0
- package/src/shared/lib/theme/surface-style.ts +91 -0
- package/src/shared/lib/theme/theme.test.ts +11 -7
- package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
- package/src/shared/lib/ui/menu-anchor.ts +89 -0
- package/src/shared/lib/usage/breakdown.test.ts +197 -0
- package/src/shared/lib/usage/breakdown.ts +241 -0
- package/src/shared/lib/usage/range.test.ts +204 -0
- package/src/shared/lib/usage/range.ts +240 -0
- package/src/shared/lib/usage/view.test.ts +85 -0
- package/src/shared/lib/usage/view.ts +74 -0
- package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
- package/src/shared/lib/workspace/panel-hues.ts +57 -0
- package/src/shared/types/browser.ts +78 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/panels-registry.ts +6 -0
- package/src/shared/types/panels.ts +14 -0
- package/src/shared/types/settings/agent.ts +28 -6
- package/src/shared/types/settings/state.ts +30 -3
- package/src/shared/types/settings/write.ts +6 -0
- package/src/shared/types/tokenUsage.ts +128 -21
- package/src/shared/types/updates.ts +20 -0
- package/src/test-support/fake-omp-frames.ts +163 -0
- package/dist/client/static/js/index-3ve31rzx.css +0 -1
- package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
- package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
- package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
- package/src/server/lib/omp/session/usage/shaping.ts +0 -130
- /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* Protocol v1: commands `{id, type, ...}` on stdin; `{type:"response", id, ...}`
|
|
9
9
|
* plus interleaved event frames on stdout. omp announces readiness with a
|
|
10
10
|
* `{type:"ready"}` frame before accepting commands. When readiness advertises
|
|
11
|
-
* protocol v2, callers negotiate it
|
|
12
|
-
*
|
|
11
|
+
* protocol v2, callers negotiate it so OMP's own OVERSIZED EVENTS arrive as
|
|
12
|
+
* bounded `rpc_chunk` sequences (see `frame.ts` for why the same encoding must
|
|
13
|
+
* never be used in the other direction).
|
|
13
14
|
*
|
|
14
15
|
* Faithful port of omp-web/lib/omp/rpc-process.ts.
|
|
15
16
|
*/
|
|
@@ -18,10 +19,11 @@ import type { Subprocess } from 'bun';
|
|
|
18
19
|
import { signalName, stripKabmoHostEnv } from '@kabmo-labs/kabmo-sdk';
|
|
19
20
|
import { describeSpawnFailure } from '@/server/lib/lifecycle/fd-pressure';
|
|
20
21
|
import { resolveOmpBin } from '@/server/lib/omp/core/cli';
|
|
21
|
-
import { RpcFrameDecoder,
|
|
22
|
+
import { RpcFrameDecoder, encodeRpcFrameLine, type RpcFrameRecord, type RpcProtocolVersion } from '@/shared/lib/omp/rpc/frame';
|
|
23
|
+
import { isRecord } from '@/shared/lib/util/guards';
|
|
22
24
|
import { killProcessTree } from '@/server/lib/lifecycle/kill-tree';
|
|
23
25
|
import { readLines } from '@/server/lib/omp/rpc/lines';
|
|
24
|
-
import { RpcCommandError, RpcCommandTimeoutError, STDERR_TAIL_LIMIT, type PendingCommand, type RpcFrame, type RpcProcessOptions, type RpcResponseFrame } from '@/server/lib/omp/rpc/process-helpers';
|
|
26
|
+
import { MAX_PROTOCOL_ERROR_NOTICES, RpcCommandError, RpcCommandTimeoutError, STDERR_TAIL_LIMIT, type PendingCommand, type RpcFrame, type RpcProcessOptions, type RpcResponseFrame } from '@/server/lib/omp/rpc/process-helpers';
|
|
25
27
|
|
|
26
28
|
export { RpcCommandError, RpcCommandTimeoutError } from '@/server/lib/omp/rpc/process-helpers';
|
|
27
29
|
export type { RpcFrame, RpcProcessOptions, RpcResponseFrame } from '@/server/lib/omp/rpc/process-helpers';
|
|
@@ -37,11 +39,8 @@ export class RpcProcess {
|
|
|
37
39
|
private exited = false;
|
|
38
40
|
private exitInfo: { code: number | null; signal: string | null } | null = null;
|
|
39
41
|
private protocolVersion: RpcProtocolVersion = 1;
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
// `rpc_chunk` records (>1 MiB payloads), and two frames written concurrently
|
|
43
|
-
// would interleave their chunk sequences on stdin, which RpcFrameDecoder
|
|
44
|
-
// rejects. Each logical frame is enqueued whole.
|
|
42
|
+
// Serializes stdin writes: a frame is queued whole so two writers cannot
|
|
43
|
+
// interleave halves of two frames on the pipe.
|
|
45
44
|
private writeQueue: Promise<void> = Promise.resolve();
|
|
46
45
|
|
|
47
46
|
constructor(options: RpcProcessOptions) {
|
|
@@ -92,6 +91,7 @@ export class RpcProcess {
|
|
|
92
91
|
this.readyPromise.catch(() => {});
|
|
93
92
|
|
|
94
93
|
const decoder = new RpcFrameDecoder();
|
|
94
|
+
let protocolErrorNotices = 0;
|
|
95
95
|
void readLines(this.child.stdout, (line) => {
|
|
96
96
|
const trimmed = line.trim();
|
|
97
97
|
if (!trimmed) return;
|
|
@@ -104,18 +104,40 @@ export class RpcProcess {
|
|
|
104
104
|
}
|
|
105
105
|
let frame: RpcFrameRecord;
|
|
106
106
|
try {
|
|
107
|
-
if (parsed &&
|
|
107
|
+
if (isRecord(parsed) && parsed.type === 'rpc_chunk' && this.protocolVersion !== 2) {
|
|
108
108
|
throw new Error('RPC chunk received before protocol negotiation');
|
|
109
109
|
}
|
|
110
110
|
const decoded = decoder.push(parsed);
|
|
111
111
|
if (!decoded) return;
|
|
112
112
|
frame = decoded;
|
|
113
113
|
} catch (error) {
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
// A malformed chunk sequence costs ONE logical frame, not the session:
|
|
115
|
+
// killing the child took its LSP servers, browser targets and prewarm
|
|
116
|
+
// slot down for a transport fault. Report the lost event, then resync.
|
|
117
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
118
|
+
decoder.resync();
|
|
119
|
+
this.stderrTail = (this.stderrTail + `\nRPC protocol error: ${detail}`).slice(-STDERR_TAIL_LIMIT);
|
|
120
|
+
if (protocolErrorNotices < MAX_PROTOCOL_ERROR_NOTICES) {
|
|
121
|
+
protocolErrorNotices++;
|
|
122
|
+
const notice: RpcFrame = {
|
|
123
|
+
type: 'notice',
|
|
124
|
+
level: 'warning',
|
|
125
|
+
message: `OMP sent a malformed RPC frame (${detail}). One event was dropped; the session is still running.`,
|
|
126
|
+
};
|
|
127
|
+
for (const listener of this.frameListeners) {
|
|
128
|
+
try {
|
|
129
|
+
listener(notice);
|
|
130
|
+
} catch {}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
116
133
|
return;
|
|
117
134
|
}
|
|
118
135
|
if (frame.type === 'ready') {
|
|
136
|
+
// The server's own ceilings, which may grow without a protocol bump.
|
|
137
|
+
decoder.setLimits({
|
|
138
|
+
maxFrameBytes: frame.maxFrameBytes,
|
|
139
|
+
maxReassembledFrameBytes: frame.maxReassembledFrameBytes,
|
|
140
|
+
});
|
|
119
141
|
resolveReady(frame);
|
|
120
142
|
return;
|
|
121
143
|
}
|
|
@@ -252,16 +274,15 @@ export class RpcProcess {
|
|
|
252
274
|
}
|
|
253
275
|
|
|
254
276
|
private writeFrame(frame: RpcFrame, callback: (error?: Error | null) => void): void {
|
|
255
|
-
let
|
|
277
|
+
let line: string;
|
|
256
278
|
try {
|
|
257
|
-
|
|
279
|
+
line = encodeRpcFrameLine(frame);
|
|
258
280
|
} catch (error) {
|
|
259
281
|
callback(error instanceof Error ? error : new Error(String(error)));
|
|
260
282
|
return;
|
|
261
283
|
}
|
|
262
|
-
//
|
|
263
|
-
//
|
|
264
|
-
// sink, so two frames can never interleave their chunk sequences.
|
|
284
|
+
// Serialized: a frame is handed to stdin whole before the next one starts,
|
|
285
|
+
// so two writers cannot interleave halves of two frames on the pipe.
|
|
265
286
|
this.writeQueue = this.writeQueue.then(
|
|
266
287
|
() => new Promise<void>((resolve) => {
|
|
267
288
|
if (this.exited || !this.child.stdin) {
|
|
@@ -270,7 +291,7 @@ export class RpcProcess {
|
|
|
270
291
|
return;
|
|
271
292
|
}
|
|
272
293
|
try {
|
|
273
|
-
|
|
294
|
+
this.child.stdin.write(line);
|
|
274
295
|
callback(null);
|
|
275
296
|
} catch (error) {
|
|
276
297
|
callback(error instanceof Error ? error : new Error(String(error)));
|
|
@@ -154,6 +154,18 @@ export class RunSettle {
|
|
|
154
154
|
this.#quietUntil = 0;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Start watching a run the frame path did not announce.
|
|
159
|
+
*
|
|
160
|
+
* A refused dispatch (`agent_busy`) proves a turn is in flight even when this
|
|
161
|
+
* wrapper read idle. The wrapper records that verdict in its own flags, and
|
|
162
|
+
* this clock is what retires them again if the run's terminal frame never
|
|
163
|
+
* arrives — the same repair every other lost-frame run gets.
|
|
164
|
+
*/
|
|
165
|
+
arm(): void {
|
|
166
|
+
this.#arm();
|
|
167
|
+
}
|
|
168
|
+
|
|
157
169
|
/**
|
|
158
170
|
* Probe omp and settle the run when omp itself reports the session quiescent.
|
|
159
171
|
* Returns true when this call released a run.
|
|
@@ -213,6 +213,28 @@ describe('settling a run omp no longer owns', () => {
|
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
+
// A refusal is the only evidence some stranded runs ever leave: omp says a
|
|
217
|
+
// turn is in flight, the wrapper raised its flags from that verdict, and the
|
|
218
|
+
// terminal frame it expects may never arrive (that is what strands a queue —
|
|
219
|
+
// measured: 104 refusals in one session, one per retry). The clock is what
|
|
220
|
+
// retires the flags, exactly as it does for a lost terminal frame.
|
|
221
|
+
test('a run announced only by a refusal is settled on omp\'s quiescence verdict', async () => {
|
|
222
|
+
const { host, emitted } = makeHost(sessionState());
|
|
223
|
+
vi.useFakeTimers();
|
|
224
|
+
try {
|
|
225
|
+
const clock = settle(host, { silenceMs: 10 });
|
|
226
|
+
clock.arm();
|
|
227
|
+
vi.advanceTimersByTime(50);
|
|
228
|
+
await flushMicrotasks();
|
|
229
|
+
expect(host.streaming).toBe(false);
|
|
230
|
+
expect(host.promptRunning).toBe(false);
|
|
231
|
+
expect(emitted).toEqual([{ type: 'agent_end', isTerminal: true, messages: [] }]);
|
|
232
|
+
clock.stop();
|
|
233
|
+
} finally {
|
|
234
|
+
vi.useRealTimers();
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
216
238
|
test('stop() cancels the clock', async () => {
|
|
217
239
|
const { host, sent } = makeHost(sessionState());
|
|
218
240
|
vi.useFakeTimers();
|
|
@@ -49,6 +49,11 @@ export interface SessionCommandHost extends WebStateHost {
|
|
|
49
49
|
/** Arm the deadline watchdog for a dispatch whose turn never opened. Optional
|
|
50
50
|
* so a test host can omit it; the real wrapper always implements it. */
|
|
51
51
|
armAgentStartWatchdog?(): void;
|
|
52
|
+
/** The run-settle clock. A refused dispatch (`agent_busy`) reveals a run this
|
|
53
|
+
* wrapper did not see open, so the clock must be armed for it or a lost
|
|
54
|
+
* terminal frame leaves the session marked busy forever. Optional for the
|
|
55
|
+
* same reason as the watchdog. */
|
|
56
|
+
runSettle?: { arm(): void };
|
|
52
57
|
/** The background `/rename` dispatch a following prompt must be ordered
|
|
53
58
|
* behind (see `session/title-request.server.ts`). Absent on a host that
|
|
54
59
|
* never titles, which is why the barrier treats it as idle. */
|
|
@@ -179,7 +179,8 @@ describe('prompt', () => {
|
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
test('a busy session refuses a retry, and omp\'s own mid-turn refusal is the typed `agent_busy`', async () => {
|
|
182
|
-
|
|
182
|
+
let settleArms = 0;
|
|
183
|
+
const h = makeHarness({ isBusy: () => true, runSettle: { arm: () => { settleArms += 1; } } });
|
|
183
184
|
h.respond(() => {
|
|
184
185
|
throw new RpcCommandTimeoutError('prompt', 1);
|
|
185
186
|
});
|
|
@@ -191,6 +192,13 @@ describe('prompt', () => {
|
|
|
191
192
|
h.respond(() => { throw new RpcCommandError('prompt', 'Agent is already processing.'); });
|
|
192
193
|
const busy = await rejectionOf(dispatchSessionCommand(h.host, { type: 'prompt', message: 'hi' })) as WebRpcError;
|
|
193
194
|
expect([busy.code, busy.message]).toEqual(['agent_busy', AGENT_BUSY_MESSAGE]);
|
|
195
|
+
// The refusal is proof of a live turn, and the wrapper must keep it: the
|
|
196
|
+
// queue's delivery gate and the sidebar both read these flags, so clearing
|
|
197
|
+
// them here is what let a session dispatch at a busy child on every retry.
|
|
198
|
+
expect(h.host.streaming).toBe(true);
|
|
199
|
+
// ...and the settle clock must be able to retire that flag if the run's
|
|
200
|
+
// terminal frame never arrives.
|
|
201
|
+
expect(settleArms).toBe(1);
|
|
194
202
|
});
|
|
195
203
|
|
|
196
204
|
test('a command dispatched during a run\'s ack window does not settle the run', async () => {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { RpcCommandError, RpcCommandTimeoutError } from '@/server/lib/omp/rpc/process';
|
|
13
|
-
import { AGENT_BUSY_MESSAGE, AGENT_BUSY_REFUSAL_RE, AWAITING_AGENT_START_TIMEOUT_MS, GET_STATE_TIMEOUT_MS, IMAGE_BEARING_COMMANDS, PASSTHROUGH_COMMANDS,
|
|
13
|
+
import { AGENT_BUSY_MESSAGE, AGENT_BUSY_REFUSAL_RE, AWAITING_AGENT_START_TIMEOUT_MS, GET_STATE_TIMEOUT_MS, IMAGE_BEARING_COMMANDS, PASSTHROUGH_COMMANDS, RESTARTING_MESSAGE, STEER_ACK_TIMEOUT_MS, WebRpcError, promptAckTimeoutMs, toImageContents, type RpcSessionState, validateAgentImages } from '@/server/lib/omp/rpc/constants';
|
|
14
14
|
import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
15
15
|
import { awaitTitleDispatch } from '@/server/lib/omp/session/title-request.server';
|
|
16
16
|
import { scheduleQueueDelivery } from '@/server/lib/queue/delivery.server';
|
|
@@ -88,12 +88,15 @@ export async function dispatchSessionCommand(host: SessionCommandHost, command:
|
|
|
88
88
|
if (ownsStreamRow) void markStreamStatus(host.sessionId, 'stream', host.runModel);
|
|
89
89
|
}
|
|
90
90
|
try {
|
|
91
|
+
// Resolved once: the same payload decides both what rides the command
|
|
92
|
+
// and how long its ack may take.
|
|
93
|
+
const images = toImageContents(command.images);
|
|
91
94
|
const ack = await host.proc.sendCommand<{ agentInvoked?: boolean } | undefined>({
|
|
92
95
|
type: 'prompt',
|
|
93
96
|
message: command.message as string,
|
|
94
|
-
...(
|
|
97
|
+
...(images ? { images } : {}),
|
|
95
98
|
...(streamingBehavior ? { streamingBehavior } : {}),
|
|
96
|
-
},
|
|
99
|
+
}, promptAckTimeoutMs(command.images));
|
|
97
100
|
if (ack?.agentInvoked === false && !streamingBehavior) {
|
|
98
101
|
// Only a dispatch that CLAIMED the turn slot may settle it. A command
|
|
99
102
|
// dispatched while a run is in flight — a mode toggle, the plan-review
|
|
@@ -139,6 +142,17 @@ export async function dispatchSessionCommand(host: SessionCommandHost, command:
|
|
|
139
142
|
// not know a run was in flight (a second tab, a reload, another
|
|
140
143
|
// instance) recover instead of losing the prompt.
|
|
141
144
|
if (error instanceof RpcCommandError && AGENT_BUSY_REFUSAL_RE.test(error.message)) {
|
|
145
|
+
// omp's verdict outranks our flags: a turn IS in flight, whatever
|
|
146
|
+
// this wrapper believed. The queue's delivery gate reads `isBusy()`,
|
|
147
|
+
// so without this a stale-idle wrapper (a `get_state` probe whose
|
|
148
|
+
// answer landed after `agent_start` clears both flags) dispatched at
|
|
149
|
+
// the child every retry and collected `agent_busy` for the rest of
|
|
150
|
+
// the run — measured as 104 failures in one session, each one
|
|
151
|
+
// requeueing the head. `agent_end`, or the settle probe's `isSettled`,
|
|
152
|
+
// is what clears it again.
|
|
153
|
+
host.streaming = true;
|
|
154
|
+
// ...and the run-settle clock retires it if that frame never comes.
|
|
155
|
+
host.runSettle?.arm();
|
|
142
156
|
throw new WebRpcError(AGENT_BUSY_MESSAGE, 'agent_busy');
|
|
143
157
|
}
|
|
144
158
|
throw error;
|
|
@@ -39,10 +39,32 @@ import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
|
39
39
|
import { publishSidebarStructure } from '@/server/lib/realtime/topics.server';
|
|
40
40
|
|
|
41
41
|
/** The wrapper surface a terminal settle touches. */
|
|
42
|
-
export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {
|
|
42
|
+
export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {
|
|
43
|
+
/** Abort verdict captured from `message_end` — see `SessionFrameHost.runAborted`. */
|
|
44
|
+
runAborted: boolean;
|
|
45
|
+
}
|
|
43
46
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
47
|
+
/**
|
|
48
|
+
* True when the ending turn was a user abort rather than a natural stop.
|
|
49
|
+
*
|
|
50
|
+
* Two sources, because neither is sufficient alone. `host.runAborted` is read
|
|
51
|
+
* from `message_end`, where the message is still whole; `agent_end.messages` is
|
|
52
|
+
* a fallback for a host that attached mid-run (a reattached client, or a
|
|
53
|
+
* synthetic terminal frame from `run-settle.server.ts`), which never saw one.
|
|
54
|
+
*
|
|
55
|
+
* The frame's own array cannot be the primary source: omp compacts an oversized
|
|
56
|
+
* terminal frame by dropping every message it already delivered through
|
|
57
|
+
* `message_end` (keeping only `messageCount`), and the aborted assistant message
|
|
58
|
+
* is always among them — measured on 18.16.0, `message_end`
|
|
59
|
+
* (`role: "assistant"`, `stopReason: "aborted"`) arrives before `agent_end`.
|
|
60
|
+
* Reading only the frame therefore reports a stopped run as finished, and the
|
|
61
|
+
* settle then titles the session, audits the goal and releases the queue for a
|
|
62
|
+
* turn the operator cancelled. 12.7% of the runs in this workstation's own
|
|
63
|
+
* session store (494 of 3901) exceed the 1 MiB frame ceiling, so the trimmed
|
|
64
|
+
* case is routine, not exotic.
|
|
65
|
+
*/
|
|
66
|
+
function endedAborted(host: TerminalSettleHost, messages: unknown): boolean {
|
|
67
|
+
if (host.runAborted) return true;
|
|
46
68
|
return (
|
|
47
69
|
Array.isArray(messages) &&
|
|
48
70
|
messages.some((entry) => {
|
|
@@ -60,11 +82,11 @@ function endedAborted(messages: unknown): boolean {
|
|
|
60
82
|
* Re-check the current row and only upgrade `stream` rows, so a `finish`
|
|
61
83
|
* written here can never clobber a newer run's live `stream`/`abort`.
|
|
62
84
|
*/
|
|
63
|
-
async function markEndStatus(sessionId: string, messages: unknown): Promise<void> {
|
|
85
|
+
async function markEndStatus(sessionId: string, host: TerminalSettleHost, messages: unknown): Promise<void> {
|
|
64
86
|
if (!sessionId) return;
|
|
65
87
|
const current = await loadStreamStatuses();
|
|
66
88
|
if (current[sessionId] !== 'stream') return;
|
|
67
|
-
await markStreamStatus(sessionId, endedAborted(messages) ? 'abort' : 'finish');
|
|
89
|
+
await markStreamStatus(sessionId, endedAborted(host, messages) ? 'abort' : 'finish');
|
|
68
90
|
}
|
|
69
91
|
|
|
70
92
|
/**
|
|
@@ -75,8 +97,8 @@ async function markEndStatus(sessionId: string, messages: unknown): Promise<void
|
|
|
75
97
|
* machine, and this function only performs the work the settle triggers.
|
|
76
98
|
*/
|
|
77
99
|
export function settleTerminalRun(host: TerminalSettleHost, messages: unknown): void {
|
|
78
|
-
const aborted = endedAborted(messages);
|
|
79
|
-
if (host.sessionId) void markEndStatus(host.sessionId, messages);
|
|
100
|
+
const aborted = endedAborted(host, messages);
|
|
101
|
+
if (host.sessionId) void markEndStatus(host.sessionId, host, messages);
|
|
80
102
|
if (!aborted) {
|
|
81
103
|
void triggerAutoSessionTitle(host, 'settle');
|
|
82
104
|
void driveGoalAfterTurn({ host, messages });
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The MCP-free agent-dir overlay: what the utility child is allowed to see, and
|
|
8
|
+
* what must reach the real tree.
|
|
9
|
+
*
|
|
10
|
+
* The rule this pins is the ONE thing the overlay exists for — `mcp.json` is
|
|
11
|
+
* absent, so omp spawns no MCP process — plus the property that makes deferring
|
|
12
|
+
* to symlinks safe: every other entry still resolves to the real file, so a
|
|
13
|
+
* `logout` or a `models.yml` read sees the user's actual state. A regression to
|
|
14
|
+
* "copy the files" would pass a naive smoke test and silently fork credentials.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
18
|
+
import fs from 'fs';
|
|
19
|
+
import { tmpdir } from 'os';
|
|
20
|
+
import path from 'path';
|
|
21
|
+
|
|
22
|
+
import { ensureUtilityAgentDir, removeUtilityAgentDir } from '@/server/lib/omp/rpc/utility-agent-dir';
|
|
23
|
+
|
|
24
|
+
let realAgentDir = '';
|
|
25
|
+
let previousAgentDir: string | undefined;
|
|
26
|
+
|
|
27
|
+
function write(file: string, content: string): void {
|
|
28
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
29
|
+
fs.writeFileSync(file, content);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
realAgentDir = fs.mkdtempSync(path.join(tmpdir(), 'kabmo-util-real-'));
|
|
34
|
+
previousAgentDir = Bun.env.PI_CODING_AGENT_DIR;
|
|
35
|
+
Bun.env.PI_CODING_AGENT_DIR = realAgentDir;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(async () => {
|
|
39
|
+
await removeUtilityAgentDir();
|
|
40
|
+
if (previousAgentDir === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
41
|
+
else Bun.env.PI_CODING_AGENT_DIR = previousAgentDir;
|
|
42
|
+
fs.rmSync(realAgentDir, { recursive: true, force: true });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('ensureUtilityAgentDir', () => {
|
|
46
|
+
test('omits mcp.json and sessions, and mirrors every other entry', async () => {
|
|
47
|
+
write(path.join(realAgentDir, 'mcp.json'), '{"mcpServers":{}}');
|
|
48
|
+
write(path.join(realAgentDir, 'models.yml'), 'providers: []\n');
|
|
49
|
+
write(path.join(realAgentDir, 'agent.db'), 'db');
|
|
50
|
+
fs.mkdirSync(path.join(realAgentDir, 'sessions'), { recursive: true });
|
|
51
|
+
fs.mkdirSync(path.join(realAgentDir, 'skills'), { recursive: true });
|
|
52
|
+
|
|
53
|
+
const overlay = await ensureUtilityAgentDir();
|
|
54
|
+
expect(overlay).toBeString();
|
|
55
|
+
|
|
56
|
+
const entries = fs.readdirSync(overlay!).sort();
|
|
57
|
+
// The whole point of the overlay: no MCP config reaches the child.
|
|
58
|
+
expect(entries).not.toContain('mcp.json');
|
|
59
|
+
// These children run --no-session; a second view of the tree is a bug.
|
|
60
|
+
expect(entries).not.toContain('sessions');
|
|
61
|
+
expect(entries).toContain('models.yml');
|
|
62
|
+
expect(entries).toContain('agent.db');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('state files are symlinks to the real ones, so writes land there', async () => {
|
|
66
|
+
write(path.join(realAgentDir, 'models.yml'), 'providers: [kenari]\n');
|
|
67
|
+
|
|
68
|
+
const overlay = await ensureUtilityAgentDir();
|
|
69
|
+
const link = path.join(overlay!, 'models.yml');
|
|
70
|
+
|
|
71
|
+
expect(fs.lstatSync(link).isSymbolicLink()).toBe(true);
|
|
72
|
+
expect(fs.realpathSync(link)).toBe(fs.realpathSync(path.join(realAgentDir, 'models.yml')));
|
|
73
|
+
// A read through the overlay is the real content, not a stale copy.
|
|
74
|
+
expect(fs.readFileSync(link, 'utf8')).toContain('kenari');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('directories are linked, not materialised empty, so discovery sees them', async () => {
|
|
78
|
+
fs.mkdirSync(path.join(realAgentDir, 'skills'), { recursive: true });
|
|
79
|
+
fs.mkdirSync(path.join(realAgentDir, 'skills', 'diagnose'), { recursive: true });
|
|
80
|
+
|
|
81
|
+
const overlay = await ensureUtilityAgentDir();
|
|
82
|
+
const mounted = path.join(overlay!, 'skills');
|
|
83
|
+
|
|
84
|
+
// An empty stand-in dropped every `skill:` entry from get_available_commands
|
|
85
|
+
// (measured 60 → 52 commands, 1 skill left). The overlay must expose the
|
|
86
|
+
// real root, so a linked child discovers exactly what a plain child does.
|
|
87
|
+
expect(fs.lstatSync(mounted).isSymbolicLink()).toBe(true);
|
|
88
|
+
expect(fs.realpathSync(mounted)).toBe(fs.realpathSync(path.join(realAgentDir, 'skills')));
|
|
89
|
+
expect(fs.readdirSync(mounted)).toEqual(['diagnose']);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('a second call is idempotent and returns the same directory', async () => {
|
|
93
|
+
write(path.join(realAgentDir, 'models.yml'), 'a\n');
|
|
94
|
+
|
|
95
|
+
const first = await ensureUtilityAgentDir();
|
|
96
|
+
const second = await ensureUtilityAgentDir();
|
|
97
|
+
|
|
98
|
+
expect(second).toBe(first!);
|
|
99
|
+
expect(fs.readdirSync(second!)).toContain('models.yml');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('an unreadable agent dir falls back to undefined rather than failing', async () => {
|
|
103
|
+
Bun.env.PI_CODING_AGENT_DIR = path.join(realAgentDir, 'does-not-exist');
|
|
104
|
+
expect(await ensureUtilityAgentDir()).toBeUndefined();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('a file added after the first build appears in the next build', async () => {
|
|
108
|
+
write(path.join(realAgentDir, 'models.yml'), 'a\n');
|
|
109
|
+
const before = await ensureUtilityAgentDir();
|
|
110
|
+
expect(fs.readdirSync(before!)).not.toContain('auth.json');
|
|
111
|
+
|
|
112
|
+
write(path.join(realAgentDir, 'auth.json'), '{}');
|
|
113
|
+
await ensureUtilityAgentDir();
|
|
114
|
+
|
|
115
|
+
expect(fs.readdirSync(before!)).toContain('auth.json');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('removeUtilityAgentDir', () => {
|
|
120
|
+
test('removes the overlay but never the real files it linked to', async () => {
|
|
121
|
+
write(path.join(realAgentDir, 'auth.json'), '{"token":"x"}');
|
|
122
|
+
const overlay = await ensureUtilityAgentDir();
|
|
123
|
+
expect(fs.existsSync(overlay!)).toBe(true);
|
|
124
|
+
|
|
125
|
+
await removeUtilityAgentDir();
|
|
126
|
+
|
|
127
|
+
expect(fs.existsSync(overlay!)).toBe(false);
|
|
128
|
+
expect(fs.readFileSync(path.join(realAgentDir, 'auth.json'), 'utf8')).toBe('{"token":"x"}');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('is a no-op when nothing was built', () => {
|
|
132
|
+
expect(removeUtilityAgentDir()).toBeInstanceOf(Promise);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* An MCP-free view of the agent directory, for the shared utility process.
|
|
8
|
+
*
|
|
9
|
+
* ## Why
|
|
10
|
+
*
|
|
11
|
+
* `omp --mode rpc-ui` connects every configured MCP server at startup, and the
|
|
12
|
+
* child has no flag to skip them (`--no-tools` does not: measured, the codegraph
|
|
13
|
+
* proxy still spawned). The utility pool only answers registry/auth/slash-command
|
|
14
|
+
* queries — `get_available_models`, `get_login_providers`, `get_available_commands`,
|
|
15
|
+
* `get_state`, `get_logout_accounts`/`logout` — and never runs an agent turn, so
|
|
16
|
+
* the `codegraph serve --mcp` proxy plus its main-thread watchdog it spawned were
|
|
17
|
+
* ~88 MB that served nothing. Verified by the `xd://` device notice: with MCP on,
|
|
18
|
+
* omp mounts `mcp__codegraph_explore` into a child that can never call it.
|
|
19
|
+
*
|
|
20
|
+
* The only switch that measurably suppresses it is the agent directory itself:
|
|
21
|
+
* `PI_CODING_AGENT_DIR` pointing at a directory with no `mcp.json` makes the
|
|
22
|
+
* child spawn NO MCP process at all (measured `children=[]`), while every
|
|
23
|
+
* utility command keeps answering — because each state file (models.yml,
|
|
24
|
+
* auth.json, projects.json, the DBs) is symlinked through to the real one.
|
|
25
|
+
*
|
|
26
|
+
* ## Why symlinks, not copies
|
|
27
|
+
*
|
|
28
|
+
* A copy would fork state: `logout` writes credentials, `models.yml` is user
|
|
29
|
+
* config, and the `.db` files are live SQLite with a WAL. Symlinking each entry
|
|
30
|
+
* means the child reads and writes exactly the file the real agent dir uses, so
|
|
31
|
+
* a logout through the utility child lands in the real auth storage. Directories
|
|
32
|
+
* are symlinked too, not materialised empty: `skills/` holds the roots omp
|
|
33
|
+
* DISCOVERS at startup, and an empty stand-in silently dropped every
|
|
34
|
+
* `skill:<name>` entry from `get_available_commands` (measured 60 → 52
|
|
35
|
+
* commands, 1 skill left). A write through a linked directory reaches the real
|
|
36
|
+
* tree, which is exactly what the child does when it runs without an overlay.
|
|
37
|
+
*
|
|
38
|
+
* The one entry never linked is `mcp.json` — that is the whole point — and
|
|
39
|
+
* `sessions/` is skipped because these children run `--no-session` and must not
|
|
40
|
+
* create a second view of the session tree.
|
|
41
|
+
*
|
|
42
|
+
* ## Failure posture
|
|
43
|
+
*
|
|
44
|
+
* An overlay that cannot be built returns `undefined`, and the caller spawns
|
|
45
|
+
* against the real agent dir: a slow registry query is better than a boot
|
|
46
|
+
* failure, and MCP discovery is not worth failing a models list over. The
|
|
47
|
+
* overlay is rebuilt per spawn (cheap: one readdir plus N symlinks) so an agent
|
|
48
|
+
* dir that gains a file after boot is picked up by the next child.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
import fs from 'fs';
|
|
52
|
+
import path from 'path';
|
|
53
|
+
import { tmpdir } from 'os';
|
|
54
|
+
|
|
55
|
+
import { getAgentDir } from '@/server/lib/omp/core/paths';
|
|
56
|
+
|
|
57
|
+
/** Entries a child must never see from the overlay: the whole point, plus a
|
|
58
|
+
* session tree these `--no-session` children have no business mounting. */
|
|
59
|
+
const EXCLUDED: Record<string, true> = { 'mcp.json': true, sessions: true };
|
|
60
|
+
|
|
61
|
+
/** Prefix for the per-process overlay root, so a stale one is recognisable. */
|
|
62
|
+
const OVERLAY_PREFIX = 'kabmo-omp-utility-';
|
|
63
|
+
|
|
64
|
+
function overlayRoot(): string {
|
|
65
|
+
return path.join(tmpdir(), `${OVERLAY_PREFIX}${process.pid}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Narrow the only field read from a failed `fs` call. */
|
|
69
|
+
function errorCode(error: unknown): string | undefined {
|
|
70
|
+
if (error && typeof error === 'object' && 'code' in error && typeof error.code === 'string') {
|
|
71
|
+
return error.code;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Build (idempotently) the MCP-free agent directory and return its path.
|
|
78
|
+
*
|
|
79
|
+
* Returns `undefined` when the real agent dir cannot be read — the caller then
|
|
80
|
+
* uses the real dir, which trades the saved processes for a working child.
|
|
81
|
+
*/
|
|
82
|
+
export async function ensureUtilityAgentDir(): Promise<string | undefined> {
|
|
83
|
+
const real = getAgentDir();
|
|
84
|
+
let entries: fs.Dirent[];
|
|
85
|
+
try {
|
|
86
|
+
entries = await fs.promises.readdir(real, { withFileTypes: true });
|
|
87
|
+
} catch {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const root = overlayRoot();
|
|
92
|
+
try {
|
|
93
|
+
await fs.promises.mkdir(root, { recursive: true });
|
|
94
|
+
for (const entry of entries) {
|
|
95
|
+
if (EXCLUDED[entry.name]) continue;
|
|
96
|
+
const target = path.join(root, entry.name);
|
|
97
|
+
try {
|
|
98
|
+
await fs.promises.symlink(path.join(real, entry.name), target);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
// EEXIST: a previous spawn in this process already linked it. Any other
|
|
101
|
+
// failure skips THIS entry rather than failing the whole overlay; the
|
|
102
|
+
// child still boots, it just sees one fewer file.
|
|
103
|
+
if (errorCode(error) !== 'EEXIST') continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return root;
|
|
107
|
+
} catch {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Remove this process's overlay. Called from the utility pool's shutdown paths
|
|
114
|
+
* so a long-lived server does not accumulate one directory per restart; a
|
|
115
|
+
* removed overlay is rebuilt on the next spawn, so this is safe at any time.
|
|
116
|
+
*
|
|
117
|
+
* Only symlinks and directories are removed — never a file the child created
|
|
118
|
+
* that might hold credentials.
|
|
119
|
+
*/
|
|
120
|
+
export async function removeUtilityAgentDir(): Promise<void> {
|
|
121
|
+
const root = overlayRoot();
|
|
122
|
+
try {
|
|
123
|
+
const entries = await fs.promises.readdir(root, { withFileTypes: true });
|
|
124
|
+
await Promise.all(entries.map(async (entry) => {
|
|
125
|
+
const full = path.join(root, entry.name);
|
|
126
|
+
try {
|
|
127
|
+
// unlink removes a symlink itself, never its target.
|
|
128
|
+
await (entry.isDirectory() ? fs.promises.rmdir(full) : fs.promises.unlink(full));
|
|
129
|
+
} catch {
|
|
130
|
+
// A directory with content (omp created files in a writable mount) or a
|
|
131
|
+
// file the child owns: leave it. The next boot reuses the same path.
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
await fs.promises.rmdir(root);
|
|
135
|
+
} catch {
|
|
136
|
+
// Nothing to remove, or a directory still in use by a live child.
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import { homedir } from 'os';
|
|
21
21
|
import { RpcProcess } from '@/server/lib/omp/rpc/process';
|
|
22
22
|
import { RELOAD_PLUGINS_TIMEOUT_MS } from '@/server/lib/omp/rpc/constants';
|
|
23
|
+
import { ensureUtilityAgentDir, removeUtilityAgentDir } from '@/server/lib/omp/rpc/utility-agent-dir';
|
|
23
24
|
|
|
24
25
|
// Extensions stay ENABLED: they can register models and login providers, and
|
|
25
26
|
// omitting them made the web UI's model/provider lists disagree with the CLI's.
|
|
@@ -124,6 +125,9 @@ export function disposeUtilityRpc(): void {
|
|
|
124
125
|
if (proc) void proc.dispose();
|
|
125
126
|
}
|
|
126
127
|
states.clear();
|
|
128
|
+
// The overlay is rebuilt on the next spawn; removing it here keeps a server
|
|
129
|
+
// that restarts often from leaving one symlink farm per process behind.
|
|
130
|
+
void removeUtilityAgentDir();
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
/**
|
|
@@ -210,9 +214,17 @@ function scheduleIdleKill(state: UtilityRpcState): void {
|
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
async function startProcess(state: UtilityRpcState, cwd: string): Promise<RpcProcess> {
|
|
217
|
+
// MCP is removed for THIS child only, by pointing its agent dir at an overlay
|
|
218
|
+
// with every state file symlinked through and `mcp.json` left out: these
|
|
219
|
+
// children answer registry/auth queries and never run a turn, so an MCP server
|
|
220
|
+
// here is a proxy plus its watchdog (~88 MB) serving nothing. `undefined`
|
|
221
|
+
// means the real dir — a working child beats a saved process.
|
|
222
|
+
// See `utility-agent-dir.ts` for the measurements.
|
|
223
|
+
const agentDir = await ensureUtilityAgentDir();
|
|
213
224
|
const proc = new RpcProcess({
|
|
214
225
|
cwd,
|
|
215
226
|
extraArgs: UTILITY_EXTRA_ARGS,
|
|
227
|
+
env: agentDir ? { PI_CODING_AGENT_DIR: agentDir } : undefined,
|
|
216
228
|
onExit: () => {
|
|
217
229
|
if (state.proc === proc) state.proc = null;
|
|
218
230
|
},
|
|
@@ -46,6 +46,7 @@ export async function readBundledCatalog(bundledRoot: string, installed: Readonl
|
|
|
46
46
|
// details before the plugin is installed. Both come from the bundled
|
|
47
47
|
// directory, which the routes resolve through the same registry.
|
|
48
48
|
...(manifest.icon ? { iconUrl: await iconUrl(pluginDir, manifest.icon) } : {}),
|
|
49
|
+
...(manifest.color ? { color: manifest.color } : {}),
|
|
49
50
|
...(await readmeUrlFor(pluginDir, manifest)),
|
|
50
51
|
...(manifest.author ? { author: manifest.author } : {}),
|
|
51
52
|
...(manifest.homepage ? { homepage: manifest.homepage } : {}),
|
|
@@ -188,6 +188,26 @@ describe('toManifest', () => {
|
|
|
188
188
|
});
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
+
describe('the manifest colour', () => {
|
|
192
|
+
test('a #RRGGBB is kept, lowercased', () => {
|
|
193
|
+
expect(toManifest({ ...MANIFEST, color: '#34D399' }, ROOT)).toMatchObject({ color: '#34d399' });
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('every other form is refused, because the value reaches an inline style', () => {
|
|
197
|
+
// `color` becomes a custom property on the rail's mark, so anything that is
|
|
198
|
+
// not a hex is a refusal rather than a value the host has to escape.
|
|
199
|
+
for (const color of ['red', 'rgb(0 0 0)', '#abc', '#12345', 'url(x)', 'red; background: url(x)', 'var(--x)', '']) {
|
|
200
|
+
const result = toManifest({ ...MANIFEST, color }, ROOT);
|
|
201
|
+
if (color === '') {
|
|
202
|
+
// An empty string is "not declared", not a refusal.
|
|
203
|
+
expect(result).not.toMatchObject({ error: expect.any(String) });
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
expect(result, color).toMatchObject({ error: expect.stringContaining('is not a #RRGGBB hex') });
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
191
211
|
describe('toMarketplaceCatalog', () => {
|
|
192
212
|
|
|
193
213
|
test('accepts a catalog with no plugins array as empty', () => {
|