@kabmo-labs/kabmo 0.16.0 → 0.18.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 +2 -2
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +552 -471
- package/dist/client/static/js/index-hp75vsv9.css +1 -0
- package/dist/client/static/js/{index-cpydmygd.js → index-tc09dtca.js} +897 -886
- package/package.json +1 -1
- package/src/client/components/common/MarkdownRenderer.tsx +136 -89
- package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
- package/src/client/components/common/anchored-menu/index.tsx +143 -0
- package/src/client/components/common/code-surface/bracket-guide.test.ts +2 -2
- package/src/client/components/common/code-surface/bracket-guide.ts +2 -2
- package/src/client/components/common/code-surface/conflict-markers.ts +5 -5
- package/src/client/components/common/code-surface/extensions.ts +7 -4
- package/src/client/components/common/code-surface/theme.ts +34 -9
- package/src/client/components/common/code-surface/whitespace.test.ts +223 -0
- package/src/client/components/common/code-surface/whitespace.ts +140 -0
- 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/{server-switcher/index.tsx → server-control/Panel.tsx} +92 -44
- package/src/client/components/common/server-control/index.test.tsx +217 -0
- package/src/client/components/common/server-control/index.tsx +120 -0
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +8 -50
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +42 -21
- 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/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/WorkspaceHeader.tsx +28 -10
- 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/update-popup/ReleaseNotes.tsx +8 -3
- package/src/client/components/layout/update-popup/index.tsx +5 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +6 -12
- 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 +41 -13
- 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/settings/Modal.tsx +9 -3
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +19 -9
- package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
- package/src/client/components/settings/categories/AgentSettings.tsx +38 -44
- 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/ProjectSettings.tsx +122 -156
- package/src/client/components/settings/categories/SkillCatalogSettings.tsx +220 -260
- package/src/client/components/settings/categories/SkillSettings.tsx +8 -5
- 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 +14 -2
- package/src/client/components/settings/categories/agent-settings/levels.ts +38 -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 +91 -76
- package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +26 -13
- 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/project-settings/AccentPalette.test.tsx +189 -0
- package/src/client/components/settings/categories/project-settings/AccentPalette.tsx +156 -24
- package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +175 -0
- package/src/client/components/settings/categories/project-settings/DeleteProjectModal.tsx +107 -0
- package/src/client/components/settings/categories/project-settings/DetailsForm.tsx +40 -24
- package/src/client/components/settings/categories/project-settings/DetailsHeader.tsx +17 -7
- package/src/client/components/settings/categories/project-settings/IconGrid.tsx +164 -69
- package/src/client/components/settings/categories/project-settings/ModelDropdown.test.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +124 -53
- package/src/client/components/settings/categories/project-settings/NameInput.tsx +57 -11
- package/src/client/components/settings/categories/project-settings/PathField.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/SidebarList.tsx +100 -59
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +253 -0
- package/src/client/components/settings/categories/skill-catalog/SkillCard.tsx +89 -0
- package/src/client/components/settings/categories/skill-catalog/SourceRail.tsx +122 -0
- package/src/client/components/settings/categories/skill-catalog/catalog-ui.test.tsx +179 -0
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +236 -0
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +164 -239
- package/src/client/components/settings/categories/skill-settings/InstructionsEditor.tsx +84 -0
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +144 -87
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +188 -0
- package/src/client/components/settings/categories/skill-settings/row-meta.ts +58 -0
- 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/chat-timeline/ThinkingSection.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
- package/src/client/components/workspace/chat-timeline/index.tsx +6 -1
- 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/Proc.test.ts +46 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -6
- 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/panels/Wait.test.ts +29 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +11 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +6 -2
- 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/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/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/PreviewPane.tsx +70 -0
- 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/editor/viewers/SvgPreview.tsx +18 -2
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +39 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +18 -5
- package/src/client/components/workspace/file-explorer/Modals.tsx +15 -1
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +68 -0
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +47 -57
- package/src/client/components/workspace/file-explorer/collapsed-chain.test.ts +167 -0
- package/src/client/components/workspace/file-explorer/drag-props.ts +42 -0
- package/src/client/components/workspace/file-explorer/drag.test.ts +43 -0
- package/src/client/components/workspace/file-explorer/index.tsx +21 -20
- package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
- 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 +123 -4
- package/src/client/data/settings/project.ts +9 -28
- package/src/client/data/settings/skill.ts +6 -32
- 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/pending-model.ts +28 -0
- 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/projects/index.ts +294 -0
- package/src/client/hooks/settings/projects.test.ts +237 -0
- package/src/client/hooks/settings/skill-catalog.ts +101 -9
- package/src/client/hooks/settings/skill-git-import.ts +153 -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/shell/servers.test.ts +166 -0
- package/src/client/hooks/{desktop → shell}/servers.ts +17 -14
- package/src/client/hooks/ui/markdown-hydration.ts +125 -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/ui/updates/shell-download.ts +1 -1
- package/src/client/hooks/ui/updates/shell-update.ts +2 -6
- package/src/client/hooks/workspace/file-row-drag.ts +41 -0
- package/src/client/hooks/workspace/file-tree-actions.ts +25 -1
- package/src/client/hooks/workspace/file-tree-edits.ts +23 -6
- package/src/client/hooks/workspace/root-drop-target.ts +77 -0
- package/src/client/hooks/workspace/unfolded-chains.ts +165 -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/desktop/dropped-paths.ts +1 -1
- package/src/client/lib/desktop/titlebar.test.ts +12 -3
- package/src/client/lib/desktop/titlebar.ts +1 -1
- package/src/client/lib/review/client.ts +73 -0
- package/src/client/lib/router/search-params.ts +42 -20
- package/src/client/lib/shell/desktop.ts +117 -0
- package/src/client/lib/shell/servers.ts +75 -0
- package/src/client/lib/shell/transport.ts +216 -0
- package/src/client/main.tsx +9 -0
- package/src/client/tailwind.css +65 -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/fs/git-merge-conflict.test.ts +14 -1
- 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/config/skill-sources.ts +49 -0
- package/src/server/lib/omp/config/skills-git-install.ts +155 -0
- package/src/server/lib/omp/config/skills-git-repo.ts +288 -0
- package/src/server/lib/omp/config/skills-git.test.ts +220 -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/process.ts +11 -14
- package/src/server/lib/omp/rpc/session-commands.ts +6 -3
- 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/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/lib/workspace/project-model.server.test.ts +102 -0
- package/src/server/lib/workspace/project-model.server.ts +47 -0
- package/src/server/lib/workspace/project-patch.server.ts +156 -0
- package/src/server/routes/agent/new.ts +8 -1
- 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 +99 -94
- package/src/server/routes/settings/mcp.test.ts +135 -0
- package/src/server/routes/settings/mcp.ts +14 -6
- package/src/server/routes/settings/projects.ts +53 -19
- package/src/server/routes/settings/settings-projects-routes.test.ts +214 -0
- package/src/server/routes/settings/settings-store-routes.test.ts +11 -115
- package/src/server/routes/settings/skills-catalog-actions.ts +195 -0
- package/src/server/routes/settings/skills.test.ts +225 -0
- package/src/server/routes/settings/skills.ts +18 -15
- 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/fs/folder-chain.test.ts +81 -1
- package/src/shared/lib/fs/folder-chain.ts +84 -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/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 +66 -0
- package/src/shared/lib/omp/config/schema.ts +6 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +48 -47
- package/src/shared/lib/omp/rpc/frame.ts +49 -40
- package/src/shared/lib/omp/session/job-progress.test.ts +37 -1
- package/src/shared/lib/omp/session/job-progress.ts +31 -0
- package/src/shared/lib/omp/session/proc.ts +5 -0
- package/src/shared/lib/omp/session/wait.ts +5 -0
- 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/ui/mobile-overlay.ts +61 -0
- package/src/shared/lib/ui/svg-scope.test.ts +97 -0
- package/src/shared/lib/ui/svg-scope.ts +134 -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/project-accent.test.ts +69 -0
- package/src/shared/lib/workspace/project-accent.ts +63 -0
- package/src/shared/lib/workspace/project-icon.ts +40 -0
- package/src/shared/lib/workspace/project-model.test.ts +79 -0
- package/src/shared/lib/workspace/project-model.ts +64 -0
- package/src/shared/types/browser.ts +78 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/settings/agent.ts +28 -6
- package/src/shared/types/settings/skill.ts +53 -3
- package/src/shared/types/settings/state.ts +4 -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/file-explorer-disk.test-util.ts +25 -1
- package/src/test-support/file-explorer-drag.test-util.ts +88 -0
- package/src/test-support/file-explorer.test-util.ts +47 -47
- package/dist/client/static/js/index-fjnq2z2d.css +0 -1
- package/src/client/components/common/code-surface/indent-guide.ts +0 -104
- package/src/client/components/common/server-switcher/index.test.tsx +0 -150
- package/src/client/components/settings/categories/skill-catalog/AddSourceModal.tsx +0 -133
- package/src/client/hooks/desktop/servers.test.ts +0 -73
- package/src/client/lib/desktop/bridge.ts +0 -203
- 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/shared/lib/code/editor/indent-guide-rule.test.ts +0 -65
- package/src/shared/lib/code/editor/indent-guide-rule.ts +0 -47
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import { SCHEMA_EXTRAS } from '@/shared/lib/omp/config/schema-extras';
|
|
25
25
|
import { ALL_SCHEMA_ENTRIES, OMP_SCHEMA, configValue, entriesForTab, isConditionMet, matchesSearch } from '@/shared/lib/omp/config/schema';
|
|
26
26
|
import type { ConfigEntry } from '@/server/lib/omp/config/config-cli';
|
|
27
|
+
import type { SchemaEntry } from '@/shared/lib/omp/config/schema-types';
|
|
27
28
|
|
|
28
29
|
/** Build a config snapshot from `{ key: value }` pairs. */
|
|
29
30
|
function snapshot(values: Record<string, unknown>): Record<string, ConfigEntry> {
|
|
@@ -86,6 +87,44 @@ describe('OMP_SCHEMA', () => {
|
|
|
86
87
|
expect(entry?.ui.tab).toBe('interaction');
|
|
87
88
|
expect(entry?.ui.group).toBe('Approvals');
|
|
88
89
|
});
|
|
90
|
+
|
|
91
|
+
test('the rows omp 18.15.0 adds are offered', () => {
|
|
92
|
+
// Measured against `omp config list --json` on 18.15.0: all four exist and
|
|
93
|
+
// every one accepts a write through `omp config set`. A schema regenerated
|
|
94
|
+
// without them is a release of settings the panel cannot reach.
|
|
95
|
+
const expected: Record<string, { type: SchemaEntry['type']; tab: string; group: string }> = {
|
|
96
|
+
'providers.openai-codex.daybreak': { type: 'boolean', tab: 'providers', group: 'Protocol' },
|
|
97
|
+
'task.perCallModel': { type: 'enum', tab: 'tasks', group: 'Subagents' },
|
|
98
|
+
'task.perCallModelAllow': { type: 'array', tab: 'tasks', group: 'Subagents' },
|
|
99
|
+
'title.refreshAfterPrompts': { type: 'number', tab: 'tasks', group: 'Modes' },
|
|
100
|
+
};
|
|
101
|
+
for (const [key, want] of Object.entries(expected)) {
|
|
102
|
+
const entry = OMP_SCHEMA.entries[key];
|
|
103
|
+
expect({ key, entry: entry && { type: entry.type, tab: entry.ui.tab, group: entry.ui.group } }).toEqual({
|
|
104
|
+
key,
|
|
105
|
+
entry: want,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('the rows omp 18.16.0 adds are offered', () => {
|
|
111
|
+
// Measured against `omp config list --json` on 18.16.0: all three exist and
|
|
112
|
+
// `omp config get` answers each. Two are TUI-composer features Kabmo has no
|
|
113
|
+
// surface for, but the panel is the only place a user CAN reach an omp
|
|
114
|
+
// setting, so a regenerated schema that drops them removes the row entirely.
|
|
115
|
+
const expected: Record<string, { type: SchemaEntry['type']; tab: string; group: string }> = {
|
|
116
|
+
'btw.inject': { type: 'boolean', tab: 'interaction', group: 'Input' },
|
|
117
|
+
'composer.predictionAlternatives': { type: 'boolean', tab: 'interaction', group: 'Input' },
|
|
118
|
+
'hindsight.globalScope': { type: 'boolean', tab: 'memory', group: 'Hindsight' },
|
|
119
|
+
};
|
|
120
|
+
for (const [key, want] of Object.entries(expected)) {
|
|
121
|
+
const entry = OMP_SCHEMA.entries[key];
|
|
122
|
+
expect({ key, entry: entry && { type: entry.type, tab: entry.ui.tab, group: entry.ui.group } }).toEqual({
|
|
123
|
+
key,
|
|
124
|
+
entry: want,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
89
128
|
});
|
|
90
129
|
|
|
91
130
|
describe('ALL_SCHEMA_ENTRIES', () => {
|
|
@@ -160,9 +199,36 @@ describe('isConditionMet', () => {
|
|
|
160
199
|
expect(isConditionMet('hasImageProtocol', {})).toBe(true);
|
|
161
200
|
});
|
|
162
201
|
|
|
202
|
+
test('the prediction-alternatives row follows composer predictions (omp 18.16.0)', () => {
|
|
203
|
+
// Upstream: `cfgComposerPredictionAlternatives` is gated on
|
|
204
|
+
// `cfgComposerPredictions.get(s) === true`. Falling through to the default
|
|
205
|
+
// arm would keep the modifier row visible with its parent switched off.
|
|
206
|
+
expect(isConditionMet('composerPredictionsEnabled', snapshot({ 'composer.predictions': true }))).toBe(true);
|
|
207
|
+
expect(isConditionMet('composerPredictionsEnabled', snapshot({ 'composer.predictions': false }))).toBe(false);
|
|
208
|
+
expect(isConditionMet('composerPredictionsEnabled', {})).toBe(false);
|
|
209
|
+
// And the row really is the one carrying that condition.
|
|
210
|
+
expect(OMP_SCHEMA.entries['composer.predictionAlternatives']?.ui.condition).toBe('composerPredictionsEnabled');
|
|
211
|
+
expect(OMP_SCHEMA.entries['composer.predictions']?.ui.condition).toBeUndefined();
|
|
212
|
+
});
|
|
213
|
+
|
|
163
214
|
test('an unknown condition degrades to visible', () => {
|
|
164
215
|
expect(isConditionMet('someFutureCondition', {})).toBe(true);
|
|
165
216
|
});
|
|
217
|
+
|
|
218
|
+
test('the provenance conditions degrade to visible, deliberately', () => {
|
|
219
|
+
// These three hide an editor row when a PROJECT layer supplies the value,
|
|
220
|
+
// because the editor writes the GLOBAL layer and promoting a repository's
|
|
221
|
+
// list would be the bug. `omp config list --json` carries no provenance, so
|
|
222
|
+
// the client cannot answer them — visible is the decision, not an oversight.
|
|
223
|
+
// `perCallModelAllowNotProject` arrived with 18.15.0's `task.perCallModelAllow`.
|
|
224
|
+
for (const condition of [
|
|
225
|
+
'contextFilesExtraNotProject',
|
|
226
|
+
'restrictedFoldersNotProject',
|
|
227
|
+
'perCallModelAllowNotProject',
|
|
228
|
+
]) {
|
|
229
|
+
expect({ condition, met: isConditionMet(condition, {}) }).toEqual({ condition, met: true });
|
|
230
|
+
}
|
|
231
|
+
});
|
|
166
232
|
});
|
|
167
233
|
|
|
168
234
|
describe('entriesForTab', () => {
|
|
@@ -55,6 +55,12 @@ export function isConditionMet(condition: string | undefined, entries: Record<st
|
|
|
55
55
|
return configValue(entries, 'retry.usageAwareFallback') === true;
|
|
56
56
|
case 'planModeEnabled':
|
|
57
57
|
return configValue(entries, 'plan.enabled') === true;
|
|
58
|
+
// omp 18.16.0's `composer.predictionAlternatives` hangs off this one: the
|
|
59
|
+
// alternatives row is a modifier of composer predictions, and offering it
|
|
60
|
+
// while predictions are off would present a setting the user cannot reach
|
|
61
|
+
// a use for. Upstream evaluates `cfgComposerPredictions.get(s) === true`.
|
|
62
|
+
case 'composerPredictionsEnabled':
|
|
63
|
+
return configValue(entries, 'composer.predictions') === true;
|
|
58
64
|
case 'planAutosaveEnabled':
|
|
59
65
|
return configValue(entries, 'plan.enabled') === true && configValue(entries, 'plan.autosave') === true;
|
|
60
66
|
case 'unexpectedStopSmart':
|
|
@@ -8,19 +8,21 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Framing bugs are silent data corruption: a frame read as two lines, or a
|
|
10
10
|
* chunk sequence reassembled with the wrong bytes, reaches the session wrapper
|
|
11
|
-
* as a plausible-looking but wrong event. These tests pin the
|
|
12
|
-
*
|
|
13
|
-
* bookkeeping (ordering, count, declared byte length), the strict
|
|
14
|
-
* UTF-8 decoding, and the failure modes that must reject rather than
|
|
11
|
+
* as a plausible-looking but wrong event. These tests pin the OUTBOUND rule
|
|
12
|
+
* (one line, never chunked — omp does not reassemble what Kabmo writes), the
|
|
13
|
+
* inbound chunk bookkeeping (ordering, count, declared byte length), the strict
|
|
14
|
+
* base64 and UTF-8 decoding, and the failure modes that must reject rather than
|
|
15
|
+
* guess.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
import { describe, expect, test } from 'bun:test';
|
|
18
19
|
|
|
19
20
|
import {
|
|
21
|
+
MAX_OUTBOUND_FRAME_BYTES,
|
|
20
22
|
MAX_RPC_FRAME_BYTES,
|
|
21
23
|
MAX_RPC_REASSEMBLED_BYTES,
|
|
22
24
|
RpcFrameDecoder,
|
|
23
|
-
|
|
25
|
+
encodeRpcFrameLine,
|
|
24
26
|
type RpcFrameRecord,
|
|
25
27
|
} from '@/shared/lib/omp/rpc/frame';
|
|
26
28
|
|
|
@@ -36,6 +38,21 @@ function chunk(overrides: Record<string, unknown>): Record<string, unknown> {
|
|
|
36
38
|
return { type: 'rpc_chunk', chunkId: 'c1', index: 0, count: 2, byteLength: MAX_RPC_FRAME_BYTES, data: 'AAAA', ...overrides };
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
/** A complete inbound `rpc_chunk` sequence for `frame`, the shape omp emits.
|
|
42
|
+
* Kabmo never writes one (see `encodeRpcFrameLine`), so the test owns it. */
|
|
43
|
+
function chunkSequence(frame: RpcFrameRecord, chunkId: string): Record<string, unknown>[] {
|
|
44
|
+
const bytes = new TextEncoder().encode(JSON.stringify(frame));
|
|
45
|
+
const count = Math.ceil(bytes.byteLength / (256 * 1024));
|
|
46
|
+
return Array.from({ length: count }, (_, index) => ({
|
|
47
|
+
type: 'rpc_chunk',
|
|
48
|
+
chunkId,
|
|
49
|
+
index,
|
|
50
|
+
count,
|
|
51
|
+
byteLength: bytes.byteLength,
|
|
52
|
+
data: bytes.subarray(index * 256 * 1024, (index + 1) * 256 * 1024).toBase64(),
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
|
|
39
56
|
describe('transport limits', () => {
|
|
40
57
|
test('the frame and reassembly ceilings are the documented values', () => {
|
|
41
58
|
expect(MAX_RPC_FRAME_BYTES).toBe(1024 * 1024);
|
|
@@ -43,54 +60,27 @@ describe('transport limits', () => {
|
|
|
43
60
|
});
|
|
44
61
|
});
|
|
45
62
|
|
|
46
|
-
describe('
|
|
63
|
+
describe('encodeRpcFrameLine — one line, never chunked', () => {
|
|
47
64
|
test('a small frame is one JSON line terminated by a newline', () => {
|
|
48
65
|
const frame = { type: 'ready', n: 1 };
|
|
49
|
-
expect(
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('the exact boundary is a frame whose JSON is MAX-1 bytes (plus newline = MAX)', () => {
|
|
53
|
-
const frame = frameOfBytes(MAX_RPC_FRAME_BYTES - 1);
|
|
54
|
-
const lines = encodeRpcFrames(frame, 1, 'chunk');
|
|
55
|
-
expect(lines.length).toBe(1);
|
|
56
|
-
expect(lines[0].length).toBe(MAX_RPC_FRAME_BYTES);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test('one byte over the boundary stops being a single line', () => {
|
|
60
|
-
const frame = frameOfBytes(MAX_RPC_FRAME_BYTES);
|
|
61
|
-
// v1 has no fallback: an oversized frame is a hard error.
|
|
62
|
-
expect(() => encodeRpcFrames(frame, 1, 'chunk')).toThrow('RPC frame exceeds the v1 transport limit');
|
|
66
|
+
expect(encodeRpcFrameLine(frame)).toBe(`${JSON.stringify(frame)}\n`);
|
|
63
67
|
});
|
|
64
|
-
});
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
test('a frame ABOVE the inbound frame limit is still a single line', () => {
|
|
70
|
+
// The regression this pins: a >1 MiB prompt (any real screenshot) used to be
|
|
71
|
+
// split into `rpc_chunk` records, which omp's rpc-ui stdin loop rejects with
|
|
72
|
+
// `Unknown command: rpc_chunk` — the prompt was never dispatched and the
|
|
73
|
+
// session was reset on ack timeout.
|
|
68
74
|
const frame = frameOfBytes(MAX_RPC_FRAME_BYTES + 5_000);
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
expect(
|
|
73
|
-
|
|
74
|
-
const decoder = new RpcFrameDecoder();
|
|
75
|
-
const records = lines.map((line) => JSON.parse(line));
|
|
76
|
-
for (let i = 0; i < records.length; i++) {
|
|
77
|
-
expect(records[i].type).toBe('rpc_chunk');
|
|
78
|
-
expect(records[i].chunkId).toBe('chunk-1');
|
|
79
|
-
expect(records[i].index).toBe(i);
|
|
80
|
-
expect(records[i].count).toBe(expectedCount);
|
|
81
|
-
expect(records[i].byteLength).toBe(payload.byteLength);
|
|
82
|
-
expect(lines[i].endsWith('\n')).toBe(true);
|
|
83
|
-
// Every push before the last must yield nothing — the decoder is holding
|
|
84
|
-
// an incomplete logical frame.
|
|
85
|
-
const out = decoder.push(records[i]);
|
|
86
|
-
if (i < records.length - 1) expect(out).toBeUndefined();
|
|
87
|
-
else expect(out).toEqual(frame);
|
|
88
|
-
}
|
|
75
|
+
const line = encodeRpcFrameLine(frame);
|
|
76
|
+
expect(line.endsWith('\n')).toBe(true);
|
|
77
|
+
expect(line.indexOf('\n')).toBe(line.length - 1);
|
|
78
|
+
expect(JSON.parse(line)).toEqual(frame);
|
|
89
79
|
});
|
|
90
80
|
|
|
91
|
-
test('a frame over the
|
|
92
|
-
const frame = { type: 'x', pad: 'A'.repeat(
|
|
93
|
-
expect(() =>
|
|
81
|
+
test('a frame over the outbound ceiling is refused instead of chunked', () => {
|
|
82
|
+
const frame = { type: 'x', pad: 'A'.repeat(MAX_OUTBOUND_FRAME_BYTES) };
|
|
83
|
+
expect(() => encodeRpcFrameLine(frame)).toThrow('exceeds the');
|
|
94
84
|
});
|
|
95
85
|
});
|
|
96
86
|
|
|
@@ -232,10 +222,21 @@ describe('RpcFrameDecoder — sequence bookkeeping', () => {
|
|
|
232
222
|
expect(() => decoder.push({ type: 'rpc_chunk', ...base, index: 3, data: last })).toThrow();
|
|
233
223
|
});
|
|
234
224
|
|
|
225
|
+
test('an inbound sequence reassembles to the frame omp emitted', () => {
|
|
226
|
+
// omp → Kabmo is the direction that DOES chunk, so the decoder must keep
|
|
227
|
+
// reassembling: an oversized event (a big tool result) arrives this way.
|
|
228
|
+
const frame = frameOfBytes(MAX_RPC_FRAME_BYTES + 5_000);
|
|
229
|
+
const decoder = new RpcFrameDecoder();
|
|
230
|
+
const records = chunkSequence(frame, 'chunk-1');
|
|
231
|
+
expect(records.length).toBeGreaterThan(1);
|
|
232
|
+
for (const record of records.slice(0, -1)) expect(decoder.push(record)).toBeUndefined();
|
|
233
|
+
expect(decoder.push(records.at(-1))).toEqual(frame);
|
|
234
|
+
});
|
|
235
|
+
|
|
235
236
|
test('a fresh sequence can start after a completed one', () => {
|
|
236
237
|
const decoder = new RpcFrameDecoder();
|
|
237
238
|
const frame = frameOfBytes(MAX_RPC_FRAME_BYTES + 1_000);
|
|
238
|
-
for (const
|
|
239
|
+
for (const record of chunkSequence(frame, 'a')) decoder.push(record);
|
|
239
240
|
expect(decoder.push({ type: 'ready' })).toEqual({ type: 'ready' });
|
|
240
241
|
});
|
|
241
242
|
});
|
|
@@ -4,12 +4,25 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* NDJSON framing for OMP's RPC transport, in both directions.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* The two directions are NOT symmetric, and treating them as if they were is
|
|
10
|
+
* what silently dropped every prompt carrying a real image:
|
|
11
|
+
*
|
|
12
|
+
* - **omp → Kabmo** frames are bounded at `MAX_RPC_FRAME_BYTES`; under protocol
|
|
13
|
+
* v2 (`negotiate_protocol`) a larger event arrives as an `rpc_chunk`
|
|
14
|
+
* sequence, which `RpcFrameDecoder` reassembles.
|
|
15
|
+
* - **Kabmo → omp** frames must go out as ONE line, however long. omp
|
|
16
|
+
* advertises protocol v2 and acks the negotiation, but its rpc-ui stdin loop
|
|
17
|
+
* has no `rpc_chunk` handler: measured against omp 18.14.0 and 18.16.0, every
|
|
18
|
+
* chunk came back `{success:false,error:"Unknown command: rpc_chunk"}` and the
|
|
19
|
+
* prompt was never dispatched — 6 records for a 1.3 MB image, no `agent_start`,
|
|
20
|
+
* no ack, and Kabmo reset the session after `PROMPT_ACK_TIMEOUT_MS`. A single
|
|
21
|
+
* 30 MB line for the same image is accepted and acked in ~26 s, so the limit
|
|
22
|
+
* here is a guard against unbounded writes, not a transport limit.
|
|
23
|
+
*
|
|
24
|
+
* Hence: one encoder (`encodeRpcFrameLine`) that never chunks, and a decoder
|
|
25
|
+
* that still understands chunks.
|
|
13
26
|
*/
|
|
14
27
|
|
|
15
28
|
import { isRecord } from '@/shared/lib/util/guards';
|
|
@@ -35,26 +48,15 @@ function isSafeInteger(value: unknown): value is number {
|
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
/**
|
|
38
|
-
*
|
|
51
|
+
* The byte-length probe for an outbound frame.
|
|
39
52
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* every steer, every tool result. Hoisting it measured 17.2 ms → 8.6 ms per
|
|
43
|
-
* 200k checks. A hoisted encoder rather than `Buffer.byteLength` because this
|
|
44
|
-
* module is in `src/shared/` and is therefore browser-safe: `Buffer` is not.
|
|
53
|
+
* A hoisted encoder rather than `Buffer.byteLength` because this module is in
|
|
54
|
+
* `src/shared/` and is therefore browser-safe: `Buffer` is not.
|
|
45
55
|
*/
|
|
46
56
|
const utf8 = new TextEncoder();
|
|
47
57
|
/** Strict decoder for reassembled chunk payloads — a truncated sequence is an error. */
|
|
48
58
|
const fatalUtf8 = new TextDecoder('utf-8', { fatal: true });
|
|
49
59
|
|
|
50
|
-
function utf8ByteLength(value: string): number {
|
|
51
|
-
return utf8.encode(value).byteLength;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function lineByteLength(value: string): number {
|
|
55
|
-
return utf8ByteLength(value) + 1;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
60
|
/** Strict base64 decode (canonical padding + round-trip equality). */
|
|
59
61
|
function decodeBase64(value: unknown): Uint8Array {
|
|
60
62
|
if (
|
|
@@ -125,27 +127,34 @@ export class RpcFrameDecoder {
|
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
|
|
128
|
-
/**
|
|
129
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Largest logical frame Kabmo will WRITE to an omp child, as one JSONL line.
|
|
132
|
+
*
|
|
133
|
+
* omp reads its command loop line by line, so this is only a guard against an
|
|
134
|
+
* unbounded write (a runaway attachment, a corrupted payload) — not a
|
|
135
|
+
* transport limit. Measured: a 30 MB prompt line is accepted and acked in
|
|
136
|
+
* ~26 s, while the same payload split into `rpc_chunk`s is rejected outright.
|
|
137
|
+
* The ceiling matches the reassembly limit omp advertises for the other
|
|
138
|
+
* direction (`maxReassembledFrameBytes`), so neither side can claim a payload
|
|
139
|
+
* the other refuses.
|
|
140
|
+
*/
|
|
141
|
+
export const MAX_OUTBOUND_FRAME_BYTES = MAX_RPC_REASSEMBLED_BYTES;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* One physical JSONL line for a logical RPC frame.
|
|
145
|
+
*
|
|
146
|
+
* NEVER chunked, whatever `negotiate_protocol` answered: omp's rpc-ui stdin
|
|
147
|
+
* loop answers `Unknown command: rpc_chunk` to every chunk record (verified on
|
|
148
|
+
* 18.14.0 and 18.16.0) and the command is then never dispatched — a prompt
|
|
149
|
+
* carrying a >1 MiB image sat unacked until the ack timeout reset the session.
|
|
150
|
+
* The refusal is thrown at the caller instead, so a payload omp would drop is
|
|
151
|
+
* reported rather than silently lost.
|
|
152
|
+
*/
|
|
153
|
+
export function encodeRpcFrameLine(frame: RpcFrameRecord): string {
|
|
130
154
|
const json = JSON.stringify(frame);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// time to slice it.
|
|
135
|
-
const bytes = utf8.encode(json);
|
|
136
|
-
if (bytes.byteLength + 1 <= MAX_RPC_FRAME_BYTES) return [`${json}\n`];
|
|
137
|
-
if (protocolVersion === 1) throw new Error('RPC frame exceeds the v1 transport limit');
|
|
138
|
-
if (bytes.byteLength > MAX_RPC_REASSEMBLED_BYTES) throw new Error('RPC frame exceeds the v2 reassembly limit');
|
|
139
|
-
const count = Math.ceil(bytes.byteLength / RPC_CHUNK_PAYLOAD_BYTES);
|
|
140
|
-
const lines: string[] = [];
|
|
141
|
-
for (let index = 0; index < count; index++) {
|
|
142
|
-
const chunk = {
|
|
143
|
-
type: 'rpc_chunk', chunkId, index, count, byteLength: bytes.byteLength,
|
|
144
|
-
data: bytes.subarray(index * RPC_CHUNK_PAYLOAD_BYTES, (index + 1) * RPC_CHUNK_PAYLOAD_BYTES).toBase64(),
|
|
145
|
-
};
|
|
146
|
-
const line = JSON.stringify(chunk);
|
|
147
|
-
if (lineByteLength(line) > MAX_RPC_FRAME_BYTES) throw new Error('RPC chunk exceeds the transport limit');
|
|
148
|
-
lines.push(`${line}\n`);
|
|
155
|
+
const bytes = utf8.encode(json).byteLength + 1;
|
|
156
|
+
if (bytes > MAX_OUTBOUND_FRAME_BYTES) {
|
|
157
|
+
throw new Error(`RPC frame of ${bytes} bytes exceeds the ${MAX_OUTBOUND_FRAME_BYTES}-byte outbound limit`);
|
|
149
158
|
}
|
|
150
|
-
return
|
|
159
|
+
return `${json}\n`;
|
|
151
160
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { describe, expect, test } from 'bun:test';
|
|
13
|
-
import { jobProgressLine, jobProgressParts } from '@/shared/lib/omp/session/job-progress';
|
|
13
|
+
import { jobSubject, jobProgressLine, jobProgressParts } from '@/shared/lib/omp/session/job-progress';
|
|
14
14
|
|
|
15
15
|
const RUNNING = {
|
|
16
16
|
status: 'running',
|
|
@@ -74,3 +74,39 @@ describe('jobProgressLine', () => {
|
|
|
74
74
|
expect(jobProgressLine({ status: 'failed', requests: 12 })).toBeUndefined();
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* omp 18.15.0 records the caller's `i` intent on the job and leads its own
|
|
80
|
+
* `/jobs` rows with it. Measured with the release's own `snapshotJobs`, given a
|
|
81
|
+
* bash job whose call carried `intent: "Start the dev server"`:
|
|
82
|
+
*
|
|
83
|
+
* [{ id: 'bg_1', type: 'bash', status: 'running', label: 'bun run dev',
|
|
84
|
+
* intent: 'Start the dev server', durationMs: 42000 }]
|
|
85
|
+
*
|
|
86
|
+
* The label is still the raw command line, so both lines are drawn: the purpose
|
|
87
|
+
* as the subject, the command beneath it.
|
|
88
|
+
*/
|
|
89
|
+
describe('jobSubject', () => {
|
|
90
|
+
test('leads with the model\'s intent and keeps the command beneath', () => {
|
|
91
|
+
expect(jobSubject({ intent: 'Start the dev server', label: 'bun run dev' })).toEqual({
|
|
92
|
+
primary: 'Start the dev server',
|
|
93
|
+
secondary: 'bun run dev',
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('a row without an intent falls back to its label alone', () => {
|
|
98
|
+
// Every `task` job, and every job omp recorded before 18.15.0.
|
|
99
|
+
expect(jobSubject({ label: 'audit the diff' })).toEqual({ primary: 'audit the diff' });
|
|
100
|
+
expect(jobSubject({})).toEqual({ primary: undefined });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('a multi-line intent is collapsed to one line', () => {
|
|
104
|
+
expect(jobSubject({ intent: 'Start\nthe dev server', label: 'bun run dev' }).primary).toBe(
|
|
105
|
+
'Start the dev server',
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('a blank intent is an absence, not an empty subject', () => {
|
|
110
|
+
expect(jobSubject({ intent: ' ', label: 'bun run dev' })).toEqual({ primary: 'bun run dev' });
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -82,3 +82,34 @@ export function jobProgressLine(job: JobProgressFields, options: JobProgressOpti
|
|
|
82
82
|
const parts = jobProgressParts(job, options);
|
|
83
83
|
return parts.length > 0 ? parts.join(' · ') : undefined;
|
|
84
84
|
}
|
|
85
|
+
|
|
86
|
+
/** The two fields a job row leads with. */
|
|
87
|
+
export interface JobSubjectFields {
|
|
88
|
+
/** What the job is for, in the MODEL's words — the `i` intent of the call
|
|
89
|
+
* that started it (omp 18.15.0). Only the tools that start a single job set
|
|
90
|
+
* it, so a subagent task row never has one. */
|
|
91
|
+
intent?: string;
|
|
92
|
+
/** The raw command line (bash) or the task's own label. */
|
|
93
|
+
label?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* What a job row says: the intent first, the command beneath it.
|
|
98
|
+
*
|
|
99
|
+
* omp 18.15.0 records the caller's `i` intent on the job and leads its own
|
|
100
|
+
* `/jobs` rows with it, because `bun run dev` does not say what the job is FOR.
|
|
101
|
+
* Kabmo drew the label alone, so the purpose the model had already stated was
|
|
102
|
+
* dropped and the raw command stood in for it. Resolved in one place so the
|
|
103
|
+
* `wait` card, the `proc://` card and their fact chips cannot disagree about
|
|
104
|
+
* which line is the subject.
|
|
105
|
+
*
|
|
106
|
+
* `primary` falls back to the label when there is no intent, so a row always
|
|
107
|
+
* has something to draw; `secondary` is only present when both exist (the
|
|
108
|
+
* command is still worth reading, under the purpose it serves).
|
|
109
|
+
*/
|
|
110
|
+
export function jobSubject(job: JobSubjectFields): { primary?: string; secondary?: string } {
|
|
111
|
+
const intent = job.intent?.replace(/\s+/g, ' ').trim();
|
|
112
|
+
const label = job.label?.trim();
|
|
113
|
+
if (!intent) return { primary: label };
|
|
114
|
+
return { primary: intent, secondary: label };
|
|
115
|
+
}
|
|
@@ -93,6 +93,10 @@ export interface ProcJob {
|
|
|
93
93
|
type?: string;
|
|
94
94
|
status?: string;
|
|
95
95
|
label?: string;
|
|
96
|
+
/** What the job is for, in the MODEL's words — the `i` intent of the call
|
|
97
|
+
* that started it (omp 18.15.0). Absent on rows omp built before the
|
|
98
|
+
* release, on subagent tasks, and on a call the model gave no intent. */
|
|
99
|
+
intent?: string;
|
|
96
100
|
durationMs?: number;
|
|
97
101
|
exitCode?: number;
|
|
98
102
|
/** Self-estimated completion of a subagent task (0–100). */
|
|
@@ -181,6 +185,7 @@ function jobOf(value: unknown): ProcJob | undefined {
|
|
|
181
185
|
type: asString(value.type),
|
|
182
186
|
status: asString(value.status),
|
|
183
187
|
label: asString(value.label),
|
|
188
|
+
intent: asString(value.intent),
|
|
184
189
|
durationMs: asNumber(value.durationMs),
|
|
185
190
|
exitCode: asNumber(value.exitCode),
|
|
186
191
|
completionPercent: asNumber(value.completionPercent),
|
|
@@ -38,6 +38,10 @@ export interface WaitJob {
|
|
|
38
38
|
type?: string;
|
|
39
39
|
status?: string;
|
|
40
40
|
label?: string;
|
|
41
|
+
/** What the job is for, in the MODEL's words — the `i` intent of the call
|
|
42
|
+
* that started it (omp 18.15.0); absent on subagent tasks and on a call the
|
|
43
|
+
* model gave no intent. */
|
|
44
|
+
intent?: string;
|
|
41
45
|
/** Elapsed time AT SNAPSHOT TIME — omp computes `now - startTime` while the
|
|
42
46
|
* job runs, so a live snapshot's value is the real elapsed clock. */
|
|
43
47
|
durationMs?: number;
|
|
@@ -124,6 +128,7 @@ function jobOf(value: unknown): WaitJob | undefined {
|
|
|
124
128
|
type: asString(value.type),
|
|
125
129
|
status: asString(value.status),
|
|
126
130
|
label: asString(value.label),
|
|
131
|
+
intent: asString(value.intent),
|
|
127
132
|
durationMs: asNumber(value.durationMs),
|
|
128
133
|
exitCode: asNumber(value.exitCode),
|
|
129
134
|
completionPercent: asNumber(value.completionPercent),
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The menu placement arithmetic, without a layout engine.
|
|
8
|
+
*
|
|
9
|
+
* These are the three outcomes a user can SEE: the panel hangs below the
|
|
10
|
+
* trigger, flips above it near the bottom edge, and clamps inside the window's
|
|
11
|
+
* left/right edges. Each was a real defect before the portal existed — the
|
|
12
|
+
* sidebar's folder menu ran off the bottom of a 460px window, and the phone's
|
|
13
|
+
* server sheet was written `absolute` at 340px, which runs off the right edge of
|
|
14
|
+
* a 390px screen.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { describe, expect, test } from 'bun:test';
|
|
18
|
+
import { placeMenu, type AnchorRect } from '@/shared/lib/ui/menu-anchor';
|
|
19
|
+
|
|
20
|
+
const VIEWPORT = { width: 1200, height: 800 };
|
|
21
|
+
|
|
22
|
+
/** A trailing `⋯` at (x, y): 22px wide, 22px tall. */
|
|
23
|
+
function anchorAt(left: number, top: number): AnchorRect {
|
|
24
|
+
return { left, right: left + 22, top, bottom: top + 22 };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('placeMenu', () => {
|
|
28
|
+
test('it hangs below the trigger, right edges aligned', () => {
|
|
29
|
+
const placement = placeMenu(anchorAt(200, 100), { width: 176, height: 94 }, VIEWPORT);
|
|
30
|
+
// 4px gap below the trigger, and the menu's right edge on the trigger's.
|
|
31
|
+
expect(placement.top).toBe(126);
|
|
32
|
+
expect(placement.left).toBe(222 - 176);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('it flips above when the space below cannot hold it', () => {
|
|
36
|
+
const placement = placeMenu(anchorAt(200, 740), { width: 176, height: 94 }, VIEWPORT);
|
|
37
|
+
// Above the trigger rather than past the bottom edge.
|
|
38
|
+
expect(placement.top).toBe(740 - 4 - 94);
|
|
39
|
+
expect(placement.top + 94).toBeLessThanOrEqual(VIEWPORT.height);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('a menu taller than the window pins to the margin and becomes scrollable', () => {
|
|
43
|
+
const placement = placeMenu(anchorAt(200, 300), { width: 176, height: 2000 }, VIEWPORT);
|
|
44
|
+
expect(placement.top).toBe(8);
|
|
45
|
+
expect(placement.maxHeight).toBe(VIEWPORT.height - 8 - 8);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('a trailing menu cannot run past the right edge', () => {
|
|
49
|
+
// This trigger's right edge is 32px off the window: aligned to it, the menu
|
|
50
|
+
// is still inside the margin, so the clamp is what a trigger ON the edge
|
|
51
|
+
// exercises.
|
|
52
|
+
const placement = placeMenu(anchorAt(1150, 100), { width: 176, height: 94 }, VIEWPORT);
|
|
53
|
+
expect(placement.left + 176).toBe(1172);
|
|
54
|
+
expect(placement.left + 176).toBeLessThanOrEqual(VIEWPORT.width - 8);
|
|
55
|
+
|
|
56
|
+
const onEdge = placeMenu(anchorAt(1190, 100), { width: 176, height: 94 }, VIEWPORT);
|
|
57
|
+
expect(onEdge.left).toBe(VIEWPORT.width - 176 - 8);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('a start-aligned menu cannot run past the left edge', () => {
|
|
61
|
+
const placement = placeMenu(anchorAt(-40, 100), { width: 176, height: 94 }, VIEWPORT, 'start');
|
|
62
|
+
expect(placement.left).toBe(8);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('start alignment puts the menu’s left edge on the trigger’s', () => {
|
|
66
|
+
const placement = placeMenu(anchorAt(500, 100), { width: 176, height: 94 }, VIEWPORT, 'start');
|
|
67
|
+
expect(placement.left).toBe(500);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where a popover hangs, as arithmetic.
|
|
8
|
+
*
|
|
9
|
+
* A menu that is placed by CSS alone (`absolute right-0 top-full`) cannot see
|
|
10
|
+
* the edge of the window, so it runs off the bottom of a short window and off
|
|
11
|
+
* the right of a narrow one, and it is placed inside whatever stacking context
|
|
12
|
+
* its trigger happens to live in. Both failure modes were measured on this
|
|
13
|
+
* app's own folder menu and server panel (see `common/anchored-menu/`), which
|
|
14
|
+
* is why the geometry below is computed from the VIEWPORT and then applied to
|
|
15
|
+
* a portalled, `fixed` panel.
|
|
16
|
+
*
|
|
17
|
+
* Pure and viewport-injected (no `window` read) so a test can assert the flip
|
|
18
|
+
* and the clamp without a layout engine.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** The trigger's rectangle in viewport coordinates. */
|
|
22
|
+
export interface AnchorRect {
|
|
23
|
+
top: number;
|
|
24
|
+
right: number;
|
|
25
|
+
bottom: number;
|
|
26
|
+
left: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Which edge of the trigger the menu aligns to.
|
|
31
|
+
*
|
|
32
|
+
* `end` hangs the menu's right edge off the trigger's — what a trailing `⋯`
|
|
33
|
+
* expects. `start` puts the menu's left edge at the trigger's.
|
|
34
|
+
*/
|
|
35
|
+
export type MenuAlign = 'start' | 'end';
|
|
36
|
+
|
|
37
|
+
export interface MenuPlacement {
|
|
38
|
+
top: number;
|
|
39
|
+
left: number;
|
|
40
|
+
/** The panel must scroll rather than run past the bottom edge. */
|
|
41
|
+
maxHeight: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Room kept between a menu and the window's edges. */
|
|
45
|
+
const MARGIN = 8;
|
|
46
|
+
|
|
47
|
+
/** Room between the trigger and the menu that hangs off it. */
|
|
48
|
+
const GAP = 4;
|
|
49
|
+
|
|
50
|
+
function clamp(value: number, min: number, max: number): number {
|
|
51
|
+
return Math.max(min, Math.min(value, max));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Place a menu of `size` against `anchor`, inside `viewport`.
|
|
56
|
+
*
|
|
57
|
+
* Below the trigger first, because that is where a menu is expected; above it
|
|
58
|
+
* when the space below cannot hold it and the space above can. When neither
|
|
59
|
+
* fits, it pins to the top margin and `maxHeight` makes the panel scroll — a
|
|
60
|
+
* menu taller than the window is readable, one pushed past the bottom edge is
|
|
61
|
+
* not.
|
|
62
|
+
*/
|
|
63
|
+
export function placeMenu(
|
|
64
|
+
anchor: AnchorRect,
|
|
65
|
+
size: { width: number; height: number },
|
|
66
|
+
viewport: { width: number; height: number },
|
|
67
|
+
align: MenuAlign = 'end',
|
|
68
|
+
): MenuPlacement {
|
|
69
|
+
const below = anchor.bottom + GAP;
|
|
70
|
+
const above = anchor.top - GAP;
|
|
71
|
+
|
|
72
|
+
let top: number;
|
|
73
|
+
if (below + size.height + MARGIN <= viewport.height) top = below;
|
|
74
|
+
else if (above - size.height >= MARGIN) top = above - size.height;
|
|
75
|
+
else top = MARGIN;
|
|
76
|
+
|
|
77
|
+
const widest = Math.max(MARGIN, viewport.width - size.width - MARGIN);
|
|
78
|
+
const left = align === 'end'
|
|
79
|
+
? clamp(anchor.right - size.width, MARGIN, widest)
|
|
80
|
+
: clamp(anchor.left, MARGIN, widest);
|
|
81
|
+
|
|
82
|
+
return { top, left, maxHeight: Math.max(MARGIN, viewport.height - top - MARGIN) };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The trigger's rect, as the anchor type above. */
|
|
86
|
+
export function anchorRectOf(element: Element): AnchorRect {
|
|
87
|
+
const rect = element.getBoundingClientRect();
|
|
88
|
+
return { top: rect.top, right: rect.right, bottom: rect.bottom, left: rect.left };
|
|
89
|
+
}
|