@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
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `/api/review` — the annotation contract.
|
|
8
|
+
*
|
|
9
|
+
* What is pinned is what a silent wrong answer would cost: a save that replaces
|
|
10
|
+
* instead of stacking (a block carries ONE judgement), a delete that answers
|
|
11
|
+
* success for an id that does not exist (the caller would believe the mark is
|
|
12
|
+
* gone), a body the server never validates (a note reaching SQLite as an
|
|
13
|
+
* object), and a repo that escapes its root (two documents sharing one scope).
|
|
14
|
+
*
|
|
15
|
+
* The database is a temp SQLite file, never the developer's — the same
|
|
16
|
+
* `isolateDb` rule every database-touching suite follows.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { afterAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
20
|
+
import fs from 'node:fs';
|
|
21
|
+
import os from 'node:os';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
|
|
24
|
+
import { getDb } from '@/server/db.server';
|
|
25
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
26
|
+
import { removeDir } from '@/test-support/remove-dir';
|
|
27
|
+
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
28
|
+
import { action, loader } from '@/server/routes/review/index';
|
|
29
|
+
|
|
30
|
+
const ROOT = path.join(os.tmpdir(), `kabmo-review-route-${process.pid}`);
|
|
31
|
+
|
|
32
|
+
function request(method: string, url: string, body?: unknown): Request {
|
|
33
|
+
return new Request(`http://localhost${url}`, {
|
|
34
|
+
method,
|
|
35
|
+
headers: body === undefined ? undefined : { 'content-type': 'application/json' },
|
|
36
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function get(query: string) {
|
|
41
|
+
const response = (await loader({ request: request('GET', `/api/review?${query}`) } as LoaderFunctionArgs)) as Response;
|
|
42
|
+
return { status: response.status, body: (await response.json()) as Record<string, any> };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function call(method: 'POST' | 'DELETE', url: string, body?: unknown) {
|
|
46
|
+
const response = (await action({ request: request(method, url, body) } as ActionFunctionArgs)) as Response;
|
|
47
|
+
return { status: response.status, body: (await response.json()) as Record<string, any> };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const target = { path: 'NOTES.md', root: ROOT, repo: '.' };
|
|
51
|
+
|
|
52
|
+
beforeEach(async () => {
|
|
53
|
+
fs.mkdirSync(path.join(ROOT, 'nested'), { recursive: true });
|
|
54
|
+
await isolateDb();
|
|
55
|
+
// `resolveRoot` only accepts an allow-listed directory (the app root, a
|
|
56
|
+
// dropped-in root, or a REGISTERED workspace), so a temp directory has to be
|
|
57
|
+
// registered exactly as the UI's own folder creation would register it —
|
|
58
|
+
// otherwise every scope in this suite silently falls back to the app root and
|
|
59
|
+
// the assertions below would pass for the wrong reason.
|
|
60
|
+
const db = await getDb();
|
|
61
|
+
await db.run('INSERT INTO workspace_folders (name, project_path) VALUES (?, ?)', ['review-test', ROOT]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
afterAll(async () => {
|
|
65
|
+
await releaseDb();
|
|
66
|
+
removeDir(ROOT);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('POST /api/review', () => {
|
|
70
|
+
test('a save is readable back under the resolved scope', async () => {
|
|
71
|
+
const saved = await call('POST', '/api/review', {
|
|
72
|
+
...target,
|
|
73
|
+
blockKey: 'paragraph:abc#1',
|
|
74
|
+
lineStart: 3,
|
|
75
|
+
lineEnd: 4,
|
|
76
|
+
verdict: 'needs-work',
|
|
77
|
+
note: 'stale',
|
|
78
|
+
quote: 'Some paragraph',
|
|
79
|
+
});
|
|
80
|
+
expect(saved.status).toBe(200);
|
|
81
|
+
expect(saved.body.annotation).toMatchObject({ blockKey: 'paragraph:abc#1', verdict: 'needs-work', note: 'stale' });
|
|
82
|
+
|
|
83
|
+
const listed = await get(`path=NOTES.md&root=${encodeURIComponent(ROOT)}&repo=.`);
|
|
84
|
+
expect(listed.status).toBe(200);
|
|
85
|
+
expect(listed.body.annotations).toHaveLength(1);
|
|
86
|
+
// The scope is the resolved pair, not the raw `root` as sent.
|
|
87
|
+
expect(listed.body.scope).toBe(`${ROOT}\u0000.`);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('a second judgement on the SAME block replaces the first', async () => {
|
|
91
|
+
const base = { ...target, blockKey: 'paragraph:abc#1', lineStart: 3, lineEnd: 3, quote: 'x' };
|
|
92
|
+
await call('POST', '/api/review', { ...base, verdict: 'needs-work', note: 'wrong' });
|
|
93
|
+
const second = await call('POST', '/api/review', { ...base, verdict: 'good', note: 'fixed' });
|
|
94
|
+
|
|
95
|
+
expect(second.body.annotation.note).toBe('fixed');
|
|
96
|
+
const listed = await get(`path=NOTES.md&root=${encodeURIComponent(ROOT)}`);
|
|
97
|
+
expect(listed.body.annotations).toHaveLength(1);
|
|
98
|
+
expect(listed.body.annotations[0].verdict).toBe('good');
|
|
99
|
+
// `created_at` survives the replace, so "when was this first judged" stays
|
|
100
|
+
// answerable; `updated_at` moves.
|
|
101
|
+
expect(listed.body.annotations[0].createdAt).toBe(second.body.annotation.createdAt);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('two paths and two scopes never see each other', async () => {
|
|
105
|
+
const body = { blockKey: 'paragraph:abc#1', lineStart: 1, lineEnd: 1, verdict: 'good', note: '', quote: '' };
|
|
106
|
+
await call('POST', '/api/review', { ...body, path: 'A.md', root: ROOT });
|
|
107
|
+
await call('POST', '/api/review', { ...body, path: 'B.md', root: ROOT });
|
|
108
|
+
await call('POST', '/api/review', { ...body, path: 'A.md', root: ROOT, repo: 'nested' });
|
|
109
|
+
|
|
110
|
+
const a = await get(`path=A.md&root=${encodeURIComponent(ROOT)}`);
|
|
111
|
+
const nested = await get(`path=A.md&root=${encodeURIComponent(ROOT)}&repo=nested`);
|
|
112
|
+
expect(a.body.annotations).toHaveLength(1);
|
|
113
|
+
expect(nested.body.annotations).toHaveLength(1);
|
|
114
|
+
expect(a.body.scope).not.toBe(nested.body.scope);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('a bad verdict, a missing blockKey and a missing path are 400s with reasons', async () => {
|
|
118
|
+
const badVerdict = await call('POST', '/api/review', { ...target, blockKey: 'k', verdict: 'meh' });
|
|
119
|
+
expect(badVerdict.status).toBe(400);
|
|
120
|
+
expect(badVerdict.body.error).toContain('verdict');
|
|
121
|
+
|
|
122
|
+
const noKey = await call('POST', '/api/review', { ...target, verdict: 'good' });
|
|
123
|
+
expect(noKey.status).toBe(400);
|
|
124
|
+
expect(noKey.body.error).toContain('blockKey');
|
|
125
|
+
|
|
126
|
+
const noPath = await call('POST', '/api/review', { verdict: 'good', blockKey: 'k' });
|
|
127
|
+
expect(noPath.status).toBe(400);
|
|
128
|
+
expect(noPath.body.error).toContain('path');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('an unregistered root falls back to the server default, never to the path sent', async () => {
|
|
132
|
+
const unregistered = path.join(os.tmpdir(), `kabmo-not-a-workspace-${process.pid}`);
|
|
133
|
+
fs.mkdirSync(unregistered, { recursive: true });
|
|
134
|
+
const listed = await get(`path=NOTES.md&root=${encodeURIComponent(unregistered)}`);
|
|
135
|
+
expect(listed.status).toBe(200);
|
|
136
|
+
expect(listed.body.scope).not.toContain(unregistered);
|
|
137
|
+
removeDir(unregistered);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('a repo outside the root is refused, not silently scoped elsewhere', async () => {
|
|
141
|
+
const response = await call('POST', '/api/review', {
|
|
142
|
+
...target,
|
|
143
|
+
repo: '../../etc',
|
|
144
|
+
blockKey: 'k',
|
|
145
|
+
verdict: 'good',
|
|
146
|
+
});
|
|
147
|
+
expect(response.status).toBe(403);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('a non-positive line number is stored as 0 rather than corrupting the row', async () => {
|
|
151
|
+
const saved = await call('POST', '/api/review', {
|
|
152
|
+
...target,
|
|
153
|
+
blockKey: 'k',
|
|
154
|
+
lineStart: -4,
|
|
155
|
+
lineEnd: 2.5,
|
|
156
|
+
verdict: 'good',
|
|
157
|
+
});
|
|
158
|
+
expect(saved.body.annotation.lineStart).toBe(0);
|
|
159
|
+
expect(saved.body.annotation.lineEnd).toBe(0);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('DELETE /api/review', () => {
|
|
164
|
+
test('removes the row, and an unknown id is a 404 rather than a success', async () => {
|
|
165
|
+
const saved = await call('POST', '/api/review', { ...target, blockKey: 'k', verdict: 'good' });
|
|
166
|
+
const id = saved.body.annotation.id as string;
|
|
167
|
+
|
|
168
|
+
const removed = await call('DELETE', `/api/review?id=${id}`);
|
|
169
|
+
expect(removed.status).toBe(200);
|
|
170
|
+
expect((await get(`path=NOTES.md&root=${encodeURIComponent(ROOT)}`)).body.annotations).toHaveLength(0);
|
|
171
|
+
|
|
172
|
+
const again = await call('DELETE', `/api/review?id=${id}`);
|
|
173
|
+
expect(again.status).toBe(404);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('a missing id is a 400', async () => {
|
|
177
|
+
const response = await call('DELETE', '/api/review');
|
|
178
|
+
expect(response.status).toBe(400);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe('the route owns its verbs', () => {
|
|
183
|
+
test('an unsupported method answers 405, not a phantom success', async () => {
|
|
184
|
+
const response = await action({ request: request('PUT', '/api/review', {}) } as ActionFunctionArgs);
|
|
185
|
+
expect((response as Response).status).toBe(405);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('a GET without a path is a 400', async () => {
|
|
189
|
+
expect((await get('')).status).toBe(400);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Agents settings route, which reads and writes omp's OWN definition files
|
|
8
|
+
* (`~/.omp/agent/agents/*.md`, `<workspace>/.omp/agents/*.md`).
|
|
9
|
+
*
|
|
10
|
+
* These cases live here rather than in the SQLite-store suite because this route
|
|
11
|
+
* touches no database: the file is the record, and the panel is a view of it.
|
|
12
|
+
* Each case pins a failure a user would otherwise see as "saving did nothing":
|
|
13
|
+
*
|
|
14
|
+
* - a write lands in the agent dir, and the list answers with the file it
|
|
15
|
+
* came from, so the pane can rename or delete the right one;
|
|
16
|
+
* - a rename REMOVES the old file (otherwise one definition survives twice);
|
|
17
|
+
* - an unsafe file name or an empty prompt is a 400 with a sentence, not a 500;
|
|
18
|
+
* - MOCK serves the demo presets and refuses to touch disk.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { afterAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
22
|
+
import fs from 'fs';
|
|
23
|
+
import os from 'os';
|
|
24
|
+
import path from 'path';
|
|
25
|
+
import { DEFAULT_AGENTS_LIST } from '@/client/data/agent-data';
|
|
26
|
+
import { action as agentsAction, loader as agentsLoader } from '@/server/routes/settings/agents';
|
|
27
|
+
import { removeDir } from '@/test-support/remove-dir';
|
|
28
|
+
|
|
29
|
+
const ROOT = path.join(os.tmpdir(), 'omc-settings-agents-route-test');
|
|
30
|
+
const API = 'http://localhost/api/settings';
|
|
31
|
+
const ORIGINAL_AGENT_DIR = Bun.env.PI_CODING_AGENT_DIR;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A CLEAN agent dir per case, not one shared by the file.
|
|
35
|
+
*
|
|
36
|
+
* The cases assert on what a write left behind (`toEqual(['helper-2.md'])`), so
|
|
37
|
+
* a file a previous case created is a failure that names the wrong thing: a
|
|
38
|
+
* delete refused for a full-path `fileName` left `reviewer.md` behind and the
|
|
39
|
+
* rename case then failed on the leftover rather than on its own behaviour.
|
|
40
|
+
*/
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
removeDir(ROOT);
|
|
43
|
+
fs.mkdirSync(path.join(ROOT, 'agent', 'agents'), { recursive: true });
|
|
44
|
+
Bun.env.PI_CODING_AGENT_DIR = path.join(ROOT, 'agent');
|
|
45
|
+
delete Bun.env.MOCK;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
afterAll(() => {
|
|
49
|
+
if (ORIGINAL_AGENT_DIR === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
50
|
+
else Bun.env.PI_CODING_AGENT_DIR = ORIGINAL_AGENT_DIR;
|
|
51
|
+
delete Bun.env.MOCK;
|
|
52
|
+
removeDir(ROOT);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
type Handler = (args: never) => unknown;
|
|
56
|
+
|
|
57
|
+
function call(handler: Handler, request: Request): Promise<Response> {
|
|
58
|
+
return handler({ request, params: {} } as never) as Promise<Response>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function send(url: string, verb: string, body?: unknown): Request {
|
|
62
|
+
return new Request(url, {
|
|
63
|
+
method: verb,
|
|
64
|
+
...(body === undefined ? {} : { body: JSON.stringify(body), headers: { 'content-type': 'application/json' } }),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
describe('settings agents', () => {
|
|
69
|
+
test('the list is omp’s definition files, with the file each one came from', async () => {
|
|
70
|
+
await call(agentsAction, send(`${API}/agents`, 'POST', {
|
|
71
|
+
type: 'write', fileName: 'reviewer', name: 'Reviewer', systemPrompt: 'You review.',
|
|
72
|
+
}));
|
|
73
|
+
const body = await (await call(agentsLoader, new Request(`${API}/agents`))).json();
|
|
74
|
+
expect(body.isMock).toBe(false);
|
|
75
|
+
expect(body.agents).toHaveLength(1);
|
|
76
|
+
expect(body.agents[0]).toMatchObject({
|
|
77
|
+
id: 'omp-user-reviewer',
|
|
78
|
+
name: 'Reviewer',
|
|
79
|
+
scope: 'user',
|
|
80
|
+
sourceRoot: 'user',
|
|
81
|
+
fileName: 'reviewer',
|
|
82
|
+
isBuiltIn: false,
|
|
83
|
+
});
|
|
84
|
+
expect(body.agents[0].filePath).toEndWith('reviewer.md');
|
|
85
|
+
await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'delete', fileName: 'reviewer' }));
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('a write lands in the agent dir and a rename removes the old file', async () => {
|
|
89
|
+
const written = await call(agentsAction, send(`${API}/agents`, 'POST', {
|
|
90
|
+
type: 'write', fileName: 'helper', name: 'Helper', systemPrompt: 'You help.',
|
|
91
|
+
}));
|
|
92
|
+
expect(written.status).toBe(200);
|
|
93
|
+
expect((await written.json()).path).toEndWith('helper.md');
|
|
94
|
+
|
|
95
|
+
const renamed = await call(agentsAction, send(`${API}/agents`, 'POST', {
|
|
96
|
+
type: 'write', fileName: 'helper-2', name: 'Helper 2', previousFileName: 'helper', systemPrompt: 'You help twice.',
|
|
97
|
+
}));
|
|
98
|
+
expect(renamed.status).toBe(200);
|
|
99
|
+
expect(fs.readdirSync(path.join(ROOT, 'agent', 'agents'))).toEqual(['helper-2.md']);
|
|
100
|
+
|
|
101
|
+
const deleted = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'delete', fileName: 'helper-2' }));
|
|
102
|
+
expect(deleted.status).toBe(200);
|
|
103
|
+
expect((await deleted.json()).agents).toEqual([]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('a definition carries every key the pane offers, and nothing it does not', async () => {
|
|
107
|
+
await call(agentsAction, send(`${API}/agents`, 'POST', {
|
|
108
|
+
type: 'write',
|
|
109
|
+
fileName: 'tuned',
|
|
110
|
+
name: 'Tuned',
|
|
111
|
+
description: 'Capabilities pinned',
|
|
112
|
+
model: 'kenari/deepseek-v4-1-flash',
|
|
113
|
+
thinkingLevel: 'high',
|
|
114
|
+
tools: ['read', 'grep'],
|
|
115
|
+
spawns: '*',
|
|
116
|
+
systemPrompt: 'You are tuned.',
|
|
117
|
+
}));
|
|
118
|
+
const file = fs.readFileSync(path.join(ROOT, 'agent', 'agents', 'tuned.md'), 'utf8');
|
|
119
|
+
expect(file).toContain('model: "kenari/deepseek-v4-1-flash"');
|
|
120
|
+
expect(file).toContain('thinkingLevel: high');
|
|
121
|
+
expect(file).toContain('tools: read, grep');
|
|
122
|
+
expect(file).toContain('spawns: "*"');
|
|
123
|
+
// omp ignores these three, so writing them would be dead config.
|
|
124
|
+
expect(file).not.toContain('mode:');
|
|
125
|
+
expect(file).not.toContain('temperature');
|
|
126
|
+
expect(file).not.toContain('top_p');
|
|
127
|
+
|
|
128
|
+
const body = await (await call(agentsLoader, new Request(`${API}/agents`))).json();
|
|
129
|
+
expect(body.agents[0]).toMatchObject({
|
|
130
|
+
name: 'Tuned',
|
|
131
|
+
model: 'kenari/deepseek-v4-1-flash',
|
|
132
|
+
thinkingLevel: 'high',
|
|
133
|
+
tools: ['read', 'grep'],
|
|
134
|
+
spawns: '*',
|
|
135
|
+
});
|
|
136
|
+
await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'delete', fileName: 'tuned' }));
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('deleting a file that does not exist names it', async () => {
|
|
140
|
+
const missing = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'delete', fileName: 'gone' }));
|
|
141
|
+
expect(missing.status).toBe(404);
|
|
142
|
+
expect(await missing.json()).toEqual({ error: 'No agent file named “gone”' });
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('an invalid file name and an empty prompt are 400 refusals', async () => {
|
|
146
|
+
const badName = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'write', fileName: 'bad name', systemPrompt: 'x' }));
|
|
147
|
+
expect(badName.status).toBe(400);
|
|
148
|
+
expect(await badName.json()).toEqual({
|
|
149
|
+
error: 'Agent file name may contain letters, numbers, dots, dashes, and underscores',
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const empty = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'write', fileName: 'ok', systemPrompt: ' ' }));
|
|
153
|
+
expect(empty.status).toBe(400);
|
|
154
|
+
expect(await empty.json()).toEqual({ error: 'Agent system prompt cannot be empty' });
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('an unknown action is refused rather than silently ignored', async () => {
|
|
158
|
+
const res = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'write_native', fileName: 'x' }));
|
|
159
|
+
expect(res.status).toBe(400);
|
|
160
|
+
expect(await res.json()).toEqual({ error: 'Unknown action “write_native”' });
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('MOCK serves the demo presets and refuses every write', async () => {
|
|
164
|
+
Bun.env.MOCK = 'true';
|
|
165
|
+
const write = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'write', fileName: 'x', systemPrompt: 'y' }));
|
|
166
|
+
expect(write.status).toBe(400);
|
|
167
|
+
expect(await write.json()).toEqual({ error: 'Agent files cannot be written in mock mode' });
|
|
168
|
+
|
|
169
|
+
const body = await (await call(agentsLoader, new Request(`${API}/agents`))).json();
|
|
170
|
+
expect(body.isMock).toBe(true);
|
|
171
|
+
expect(body.agents).toHaveLength(DEFAULT_AGENTS_LIST.length);
|
|
172
|
+
Bun.env.MOCK = 'false';
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test('a wrong verb is the route-owned 405', async () => {
|
|
176
|
+
const res = await call(agentsAction, send(`${API}/agents`, 'PATCH'));
|
|
177
|
+
expect(res.status).toBe(405);
|
|
178
|
+
expect(await res.json()).toEqual({ error: 'Method not allowed' });
|
|
179
|
+
});
|
|
180
|
+
});
|
|
@@ -1,140 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Native omp agents — the definitions omp itself loads.
|
|
8
|
+
*
|
|
9
|
+
* A definition is a markdown file with frontmatter, and the FILE is the only
|
|
10
|
+
* thing omp reads: user agents at `~/.omp/agent/agents/*.md`, project agents at
|
|
11
|
+
* `<workspace>/.omp/agents/*.md`. The panel therefore reads and writes those
|
|
12
|
+
* files directly. It used to keep a mirrored list in Kabmo's SQLite and POST
|
|
13
|
+
* into it, which made "Create Agent" a button that reported success and changed
|
|
14
|
+
* nothing the agent could see.
|
|
15
|
+
*
|
|
16
|
+
* Project agents stay read-only: that directory belongs to the workspace, and a
|
|
17
|
+
* console that rewrites another checkout's definitions is a surprise. The route
|
|
18
|
+
* still lists them, flagged `sourceRoot: 'project'`.
|
|
19
|
+
*/
|
|
20
|
+
|
|
1
21
|
import { json } from '@/server/lib/remix-compat';
|
|
2
22
|
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
3
23
|
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
4
|
-
import { getDb } from '@/server/db.server';
|
|
5
24
|
import { DEFAULT_AGENTS_LIST } from '@/client/data/agent-data';
|
|
6
25
|
import { isMockMode } from '@/server/mock.server';
|
|
7
|
-
import type { AgentItem } from '@/shared/types';
|
|
8
|
-
import { createSettingsListStore } from '@/server/lib/db/settings-store';
|
|
9
26
|
import { join } from 'path';
|
|
10
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
deleteAgentDefinition,
|
|
29
|
+
discoverNativeAgents,
|
|
30
|
+
writeAgentDefinition,
|
|
31
|
+
type DiscoveredAgent,
|
|
32
|
+
} from '@/server/lib/omp/config/agents';
|
|
33
|
+
import { agentFileBaseName } from '@/shared/lib/omp/config/agent-file';
|
|
11
34
|
import { resolveRoot } from '@/server/lib/fs/root';
|
|
35
|
+
import type { AgentItem } from '@/shared/types';
|
|
12
36
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
mockDefaults: DEFAULT_AGENTS_LIST,
|
|
16
|
-
idOf: (agent) => agent.id,
|
|
17
|
-
singular: 'agent',
|
|
18
|
-
plural: 'agents',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Convert a natively discovered omp agent into Kabmo AgentItem shape.
|
|
23
|
-
* Native agents are surfaced as read-only built-ins (isBuiltIn) so the UI
|
|
24
|
-
* lists them alongside app-local custom agents without offering edits that
|
|
25
|
-
* would silently not persist.
|
|
26
|
-
*/
|
|
27
|
-
function nativeToAgentItem(agent: DiscoveredAgent): AgentItem & { sourceRoot: string } {
|
|
37
|
+
/** Project agents are listed but never written from here. */
|
|
38
|
+
function toAgentItem(agent: DiscoveredAgent): AgentItem {
|
|
28
39
|
return {
|
|
29
40
|
id: agent.id,
|
|
30
41
|
name: agent.name,
|
|
31
|
-
description: agent.description || `
|
|
42
|
+
description: agent.description || `omp agent (${agent.sourceRoot})`,
|
|
32
43
|
scope: agent.sourceRoot === 'user' ? 'user' : 'project',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
topP: agent.topP,
|
|
44
|
+
...(agent.tools ? { tools: agent.tools } : {}),
|
|
45
|
+
...(agent.spawns ? { spawns: agent.spawns } : {}),
|
|
46
|
+
...(agent.model ? { model: agent.model } : {}),
|
|
47
|
+
...(agent.thinkingLevel ? { thinkingLevel: agent.thinkingLevel } : {}),
|
|
38
48
|
systemPrompt: agent.systemPrompt,
|
|
39
|
-
isBuiltIn:
|
|
49
|
+
isBuiltIn: agent.sourceRoot !== 'user',
|
|
50
|
+
filePath: agent.filePath,
|
|
51
|
+
fileName: agentFileBaseName(agent.filePath),
|
|
40
52
|
sourceRoot: agent.sourceRoot,
|
|
41
53
|
};
|
|
42
54
|
}
|
|
43
55
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
56
|
+
async function readList(projectRoot: string | null): Promise<AgentItem[]> {
|
|
57
|
+
const projectDir = projectRoot
|
|
58
|
+
? join(await resolveRoot(projectRoot, ''), '.omp', 'agents')
|
|
59
|
+
: undefined;
|
|
60
|
+
return (await discoverNativeAgents(projectDir)).map(toAgentItem);
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
export async function loader({ request }: LoaderFunctionArgs) {
|
|
64
|
+
const mock = isMockMode();
|
|
65
|
+
if (mock) return json({ agents: DEFAULT_AGENTS_LIST, isMock: true });
|
|
52
66
|
try {
|
|
53
|
-
const db = await getDb();
|
|
54
67
|
const url = new URL(request.url);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
const agents = await agentsStore.read(db);
|
|
58
|
-
|
|
59
|
-
// The panel's project picker is a SCOPE, not decoration: `<workspace>/.omp/agents`
|
|
60
|
-
// holds agents that only exist for that workspace, and an unscoped read
|
|
61
|
-
// could never list them. Gated through `resolveRoot` like every other
|
|
62
|
-
// client-supplied path, so an arbitrary directory is not readable here.
|
|
63
|
-
const rawRoot = url.searchParams.get('root');
|
|
64
|
-
const projectDir = rawRoot
|
|
65
|
-
? join(await resolveRoot(rawRoot, ''), '.omp', 'agents')
|
|
66
|
-
: undefined;
|
|
67
|
-
|
|
68
|
-
if (includeNative && !mock) {
|
|
69
|
-
return json({ agents: await mergeAgents(agents, projectDir), isMock: mock });
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return json({ agents, isMock: mock });
|
|
68
|
+
const root = url.searchParams.get('root');
|
|
69
|
+
return json({ agents: await readList(root), isMock: false });
|
|
73
70
|
} catch (error) {
|
|
74
71
|
const message = error instanceof Error ? error.message : String(error);
|
|
75
|
-
return json({ error: message, agents:
|
|
72
|
+
return json({ error: message, agents: [], isMock: false }, { status: 500 });
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
export async function action({ request, params }: ActionFunctionArgs) {
|
|
77
|
+
if (request.method !== 'POST') {
|
|
78
|
+
return methodNotAllowed({ request, params });
|
|
79
|
+
}
|
|
80
|
+
if (isMockMode()) {
|
|
81
|
+
return json({ error: 'Agent files cannot be written in mock mode' }, { status: 400 });
|
|
82
|
+
}
|
|
80
83
|
try {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const url = new URL(request.url);
|
|
85
|
-
const id = url.searchParams.get('id');
|
|
86
|
-
if (!id) {
|
|
87
|
-
return json({ error: 'id is required' }, { status: 400 });
|
|
88
|
-
}
|
|
89
|
-
if (id.startsWith('omp-')) {
|
|
90
|
-
return json({ error: 'Native omp agents are read-only in Kabmo' }, { status: 403 });
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const list = await agentsStore.remove(db, id);
|
|
94
|
-
return json({ success: true, agents: list });
|
|
84
|
+
const body: unknown = await request.json();
|
|
85
|
+
if (typeof body !== 'object' || body === null || !('type' in body)) {
|
|
86
|
+
return json({ error: 'type is required (write or delete)' }, { status: 400 });
|
|
95
87
|
}
|
|
88
|
+
const root = 'root' in body && typeof body.root === 'string' ? body.root : null;
|
|
96
89
|
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// Native agent file write: { type: "write_native", fileName, ...definition }
|
|
101
|
-
if (body.type === 'write_native') {
|
|
102
|
-
if (isMockMode()) return json({ error: 'Native agent writes are unavailable in mock mode' }, { status: 400 });
|
|
103
|
-
const written = await writeAgentDefinition({
|
|
104
|
-
fileName: String(body.fileName ?? ''),
|
|
105
|
-
name: typeof body.name === 'string' ? body.name : undefined,
|
|
106
|
-
description: typeof body.description === 'string' ? body.description : undefined,
|
|
107
|
-
mode: typeof body.mode === 'string' ? body.mode : undefined,
|
|
108
|
-
model: typeof body.model === 'string' ? body.model : undefined,
|
|
109
|
-
thinking: typeof body.thinking === 'string' ? body.thinking : undefined,
|
|
110
|
-
temperature: typeof body.temperature === 'number' ? body.temperature : null,
|
|
111
|
-
topP: typeof body.topP === 'number' ? body.topP : null,
|
|
112
|
-
tools: Array.isArray(body.tools) ? body.tools.map(String) : undefined,
|
|
113
|
-
systemPrompt: String(body.systemPrompt ?? ''),
|
|
114
|
-
});
|
|
115
|
-
return json({ success: true, path: written.path, agents: await mergeAgents([]) });
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Native agent file delete: { type: "delete_native", fileName }
|
|
119
|
-
if (body.type === 'delete_native') {
|
|
120
|
-
if (isMockMode()) return json({ error: 'Native agent deletes are unavailable in mock mode' }, { status: 400 });
|
|
121
|
-
const removed = await deleteAgentDefinition(String(body.fileName ?? ''));
|
|
122
|
-
if (!removed) return json({ error: 'Native agent file not found' }, { status: 404 });
|
|
123
|
-
return json({ success: true, agents: await mergeAgents([]) });
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (!Array.isArray(body) && !Array.isArray(body.agents) && body.agent
|
|
127
|
-
&& typeof body.agent.id === 'string' && body.agent.id.startsWith('omp-')) {
|
|
128
|
-
return json({ error: 'Native omp agents are read-only in Kabmo' }, { status: 403 });
|
|
90
|
+
if (body.type === 'delete') {
|
|
91
|
+
if (!('fileName' in body) || typeof body.fileName !== 'string') {
|
|
92
|
+
return json({ error: 'fileName is required' }, { status: 400 });
|
|
129
93
|
}
|
|
94
|
+
const removed = await deleteAgentDefinition(body.fileName);
|
|
95
|
+
if (!removed) return json({ error: `No agent file named “${body.fileName}”` }, { status: 404 });
|
|
96
|
+
return json({ success: true, agents: await readList(root) });
|
|
97
|
+
}
|
|
130
98
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
99
|
+
if (body.type === 'write') {
|
|
100
|
+
const fileName = 'fileName' in body && typeof body.fileName === 'string' ? body.fileName : '';
|
|
101
|
+
const systemPrompt = 'systemPrompt' in body && typeof body.systemPrompt === 'string' ? body.systemPrompt : '';
|
|
102
|
+
const text = (key: string): string | undefined => (
|
|
103
|
+
key in body && typeof body[key as keyof typeof body] === 'string'
|
|
104
|
+
? String(body[key as keyof typeof body])
|
|
105
|
+
: undefined
|
|
106
|
+
);
|
|
107
|
+
const tools = 'tools' in body && Array.isArray(body.tools)
|
|
108
|
+
? body.tools.filter((item): item is string => typeof item === 'string')
|
|
109
|
+
: undefined;
|
|
110
|
+
const written = await writeAgentDefinition({
|
|
111
|
+
fileName,
|
|
112
|
+
name: text('name') ?? fileName,
|
|
113
|
+
description: text('description') ?? '',
|
|
114
|
+
...(text('model') ? { model: text('model') } : {}),
|
|
115
|
+
...(text('thinkingLevel') ? { thinkingLevel: text('thinkingLevel') } : {}),
|
|
116
|
+
...(text('spawns') ? { spawns: text('spawns') } : {}),
|
|
117
|
+
...(tools ? { tools } : {}),
|
|
118
|
+
systemPrompt,
|
|
119
|
+
});
|
|
120
|
+
// A rename writes the new file and removes the old one, so one definition
|
|
121
|
+
// cannot survive under two names.
|
|
122
|
+
const previous = 'previousFileName' in body && typeof body.previousFileName === 'string'
|
|
123
|
+
? body.previousFileName
|
|
124
|
+
: '';
|
|
125
|
+
if (previous && previous !== fileName) await deleteAgentDefinition(previous);
|
|
126
|
+
return json({ success: true, path: written.path, agents: await readList(root) });
|
|
134
127
|
}
|
|
135
128
|
|
|
136
|
-
return
|
|
129
|
+
return json({ error: `Unknown action “${String(body.type)}”` }, { status: 400 });
|
|
137
130
|
} catch (error) {
|
|
138
|
-
return json({ error: error instanceof Error ? error.message : String(error) }, { status:
|
|
131
|
+
return json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 });
|
|
139
132
|
}
|
|
140
133
|
}
|