@kabmo-labs/kabmo 0.21.1 → 0.22.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 +7 -2
- package/dist/client/index.html +9 -8
- package/dist/client/index.js +334 -334
- package/dist/client/static/js/{index-thwqf24c.js → index-297dck9a.js} +784 -791
- package/dist/client/static/js/index-7ppta1pb.css +1 -0
- package/extensions/kabmo-modes/commands.ts +17 -3
- package/extensions/kabmo-modes/goal-start.ts +101 -0
- package/extensions/kabmo-modes/goal.test.ts +80 -5
- package/extensions/kabmo-modes/goal.ts +13 -38
- package/extensions/kabmo-modes/prompts.test.ts +12 -0
- package/extensions/kabmo-modes/prompts.ts +9 -2
- package/index.html +8 -7
- package/package.json +2 -2
- package/src/cli/lib/args.js +9 -0
- package/src/cli/lib/args.test.js +26 -0
- package/src/cli/lib/commands/doctor.js +153 -0
- package/src/cli/lib/commands/doctor.test.js +139 -0
- package/src/cli/lib/commands/serve.js +23 -10
- package/src/cli/lib/commands/status.js +22 -3
- package/src/cli/lib/omp-setup.js +131 -0
- package/src/cli/lib/omp-setup.test.js +115 -0
- package/src/cli/main.js +1 -1
- package/src/client/components/common/DemoDataBadge.tsx +52 -0
- package/src/client/components/common/FolderPicker.tsx +2 -2
- package/src/client/components/common/Modal.tsx +15 -1
- package/src/client/components/common/code-surface/blame-panel.ts +1 -1
- package/src/client/components/common/context-usage-button/index.test.tsx +1 -1
- package/src/client/components/common/context-usage-button/index.tsx +4 -4
- package/src/client/components/common/demo-data-badge.test.tsx +58 -0
- package/src/client/components/common/diagram-viewer/index.tsx +2 -2
- package/src/client/components/common/editor-view-buttons/index.tsx +2 -2
- package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
- package/src/client/components/common/header-controls/index.tsx +4 -1
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +2 -2
- package/src/client/components/common/markdown-review/ReviewSummary.tsx +1 -1
- package/src/client/components/common/panel-mark/index.tsx +2 -1
- package/src/client/components/common/server-control/Panel.tsx +3 -3
- package/src/client/components/common/server-control/index.tsx +1 -1
- package/src/client/components/common/shell-update-button/Modal.tsx +1 -1
- package/src/client/components/common/todo-row/index.tsx +1 -1
- package/src/client/components/layout/ActivityBar.tsx +4 -0
- package/src/client/components/layout/ShellNotice.tsx +33 -0
- package/src/client/components/layout/desktop-layout/index.tsx +14 -16
- package/src/client/components/layout/desktop-layout/resizer/index.tsx +14 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +2 -1
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +5 -1
- package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
- package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +56 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +2 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +1 -1
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +12 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +2 -1
- package/src/client/components/layout/session-sidebar/modern/index.tsx +6 -2
- package/src/client/components/layout/session-sidebar/new-workspace-modal/CloneField.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 +1 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +3 -3
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +1 -1
- package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +150 -0
- package/src/client/components/layout/session-sidebar/variant-props.ts +6 -0
- package/src/client/components/mobile/LayoutWrapper.tsx +20 -30
- package/src/client/components/mobile/MainView.tsx +5 -2
- package/src/client/components/mobile/RightSidebar.tsx +1 -1
- package/src/client/components/mobile/SessionSidebar.tsx +3 -0
- package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +7 -1
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/settings/Modal.tsx +15 -1
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +1 -1
- package/src/client/components/settings/Sidebar.tsx +2 -2
- package/src/client/components/settings/categories/OmpSettings.tsx +1 -1
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +1 -1
- package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +3 -3
- package/src/client/components/settings/categories/appearance-settings/EditorFontSection.tsx +1 -1
- package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +2 -2
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +5 -5
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +1 -1
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +1 -1
- package/src/client/components/settings/categories/appearance-settings/ThemeCard.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +1 -1
- package/src/client/components/settings/categories/command-settings/DetailPane.tsx +2 -2
- package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +5 -5
- package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +3 -3
- package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +2 -2
- package/src/client/components/settings/categories/panel-plugins/LeftDockSettings.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +4 -3
- package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +2 -2
- package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/NameInput.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/PathField.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +3 -3
- package/src/client/components/settings/categories/provider-settings/AddProviderModal.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +4 -4
- package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/PriceFields.tsx +1 -1
- package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +4 -4
- package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +2 -2
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
- package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +1 -1
- package/src/client/components/settings/categories/usage-settings/KenariCard.tsx +5 -5
- package/src/client/components/workspace/browser-panel/AddressBar.tsx +1 -1
- package/src/client/components/workspace/browser-panel/Screencast.tsx +6 -6
- package/src/client/components/workspace/browser-panel/TabStrip.tsx +1 -1
- package/src/client/components/workspace/browser-panel/index.tsx +1 -1
- package/src/client/components/workspace/browser-toolbar/index.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/AttachmentChips.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +13 -26
- package/src/client/components/workspace/chat-timeline/GoalNotice.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/MinimapShortcuts.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/QueueList.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/SubagentView.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/TaskResultContent.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ArmedGoalStrip.tsx +71 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.test.ts +176 -0
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +70 -81
- package/src/client/components/workspace/chat-timeline/chat-input/GoalSurfaces.tsx +10 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +20 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +13 -7
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +65 -3
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +69 -19
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +174 -0
- package/src/client/components/workspace/chat-timeline/chat-input/goal-modal-parts.tsx +80 -0
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +15 -3
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +1 -1
- 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/ask-panel/FrameControl.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OptionRow.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionCard.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Header.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/SelectBody.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/hashline-patch/index.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AstEdit.tsx +6 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +13 -13
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Checkpoint.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ContextNotes.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Debug.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Edit.tsx +9 -9
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Eval.tsx +10 -10
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/FileMatches.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Goal.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/GoalRecord.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Lsp.tsx +6 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ManageSkill.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Memory.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -15
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Resolve.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchFs.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchTool.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SecurityScan.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/TaskResult.tsx +7 -7
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Think.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Todo.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +4 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +17 -17
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/EnvelopeHeader.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ExcerptCode.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackOutput.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/JsonCodeBlock.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/OutputWindow.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolFactChips.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolPanelHeader.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +1 -1
- package/src/client/components/workspace/context-panel/RawJsonViewer.tsx +2 -2
- package/src/client/components/workspace/context-panel/StatsGrid.tsx +1 -1
- package/src/client/components/workspace/context-panel/index.tsx +1 -1
- package/src/client/components/workspace/diff-panel/ConflictBanner.tsx +1 -1
- package/src/client/components/workspace/editor/EmptyEditor.tsx +1 -1
- package/src/client/components/workspace/editor/FindWidget.tsx +1 -1
- package/src/client/components/workspace/editor/Tabs.tsx +1 -1
- package/src/client/components/workspace/editor/Toolbar.tsx +1 -1
- package/src/client/components/workspace/file-explorer/OutlineSection.tsx +2 -2
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +1 -1
- package/src/client/components/workspace/file-explorer/index.tsx +1 -1
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +2 -2
- package/src/client/components/workspace/git-panel/ChangesList.tsx +3 -3
- package/src/client/components/workspace/git-panel/ConflictItem.tsx +3 -3
- package/src/client/components/workspace/git-panel/FileItem.tsx +2 -2
- package/src/client/components/workspace/git-panel/StashSection.tsx +5 -5
- package/src/client/components/workspace/git-panel/TreeItem.tsx +2 -2
- package/src/client/components/workspace/git-panel/branch-modal/BranchRow.tsx +4 -4
- package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -2
- package/src/client/components/workspace/git-panel/index.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/Item.tsx +3 -3
- package/src/client/components/workspace/model-dropdown/Section.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
- package/src/client/components/workspace/plan-panel/index.tsx +2 -2
- package/src/client/components/workspace/repo-picker/Modal.tsx +1 -1
- package/src/client/components/workspace/repo-picker/Row.tsx +6 -6
- package/src/client/components/workspace/search-panel/Body.tsx +2 -2
- package/src/client/components/workspace/search-panel/Results.tsx +1 -1
- package/src/client/components/workspace/search-panel/index.tsx +1 -1
- package/src/client/components/workspace/terminal-panel/index.tsx +1 -1
- package/src/client/components/workspace/todo-panel/PhaseGroup.tsx +1 -1
- package/src/client/components/workspace/todo-panel/index.tsx +2 -2
- package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -5
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +13 -13
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +4 -4
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +1 -1
- package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +7 -7
- package/src/client/components/workspace/user-browser-panel/Frame.tsx +1 -1
- package/src/client/components/workspace/wiki-panel/Nav.tsx +1 -1
- package/src/client/components/workspace/wiki-panel/index.tsx +2 -2
- package/src/client/glass.css +50 -0
- package/src/client/glass.test.ts +68 -24
- package/src/client/hooks/chat/composer/browser-context.test.ts +6 -6
- package/src/client/hooks/chat/composer/use-draft.test.ts +2 -2
- package/src/client/hooks/chat/omp/prompt-send.test.ts +36 -0
- package/src/client/hooks/chat/omp/prompt-send.ts +24 -18
- package/src/client/hooks/chat/omp/session-list.tsx +24 -70
- package/src/client/hooks/chat/omp/session-merges.ts +89 -0
- package/src/client/hooks/chat/omp/session-sidebar-controller.ts +4 -1
- package/src/client/hooks/chat/timeline/armed-goal-send.test.ts +168 -0
- package/src/client/hooks/chat/timeline/armed-goal.test.ts +178 -0
- package/src/client/hooks/chat/timeline/goal-command.ts +57 -27
- package/src/client/hooks/chat/timeline/index.ts +7 -4
- package/src/client/hooks/chat/timeline/mode-post.ts +46 -0
- package/src/client/hooks/chat/timeline/modes-contract.ts +94 -0
- package/src/client/hooks/chat/timeline/modes.ts +60 -95
- package/src/client/hooks/chat/timeline/send-props.ts +97 -0
- package/src/client/hooks/chat/timeline/send-steer.test.ts +6 -0
- package/src/client/hooks/chat/timeline/send.test-util.ts +55 -8
- package/src/client/hooks/chat/timeline/send.test.ts +17 -1
- package/src/client/hooks/chat/timeline/send.ts +64 -72
- package/src/client/hooks/ui/dialog-behaviour.ts +143 -0
- package/src/client/hooks/ui/theme.ts +17 -0
- package/src/client/hooks/workspace/copy-tab-path.ts +23 -0
- package/src/client/hooks/workspace/mobile-back.ts +71 -0
- package/src/client/palette-class.test.ts +93 -0
- package/src/client/tailwind-contrast.test.ts +194 -0
- package/src/client/tailwind.css +327 -8
- package/src/server/lib/assets/theme-shell.server.ts +4 -10
- package/src/server/lib/omp/config/provider-seeds.test.ts +39 -1
- package/src/server/lib/omp/config/provider-seeds.ts +32 -3
- package/src/server/lib/omp/config/provider-vision-compat.test.ts +140 -0
- package/src/server/lib/omp/core/host-resolution.test.ts +1 -55
- package/src/server/lib/omp/core/install-hint.test.ts +48 -0
- package/src/server/lib/omp/core/install-hint.ts +64 -0
- package/src/server/lib/omp/core/startup.test.ts +125 -0
- package/src/server/lib/omp/core/startup.ts +5 -1
- package/src/server/lib/omp/mode/request.ts +14 -6
- package/src/server/plugins/ssr.ts +2 -1
- package/src/shared/lib/browser/annotate.test.ts +22 -22
- package/src/shared/lib/browser/annotate.ts +14 -14
- package/src/shared/lib/browser/page-context.ts +6 -6
- package/src/shared/lib/icons/icon-paint-authority.test.ts +86 -0
- package/src/shared/lib/icons/icon-paint-authority.ts +94 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +44 -8
- package/src/shared/lib/icons/icon-paint-css.ts +18 -1
- package/src/shared/lib/icons/icon-paint-panel.ts +15 -18
- package/src/shared/lib/icons/icon-paint-weight.ts +20 -1
- package/src/shared/lib/icons/icon-tone.ts +58 -13
- package/src/shared/lib/icons/tint-hues.generated.ts +51 -6
- package/src/shared/lib/icons/tint-tones.test.ts +257 -0
- package/src/shared/lib/icons/tint.test.ts +3 -211
- package/src/shared/lib/icons/tint.ts +23 -25
- package/src/shared/lib/omp/mode/actions.ts +40 -0
- package/src/shared/lib/omp/mode/types.ts +12 -0
- package/src/shared/lib/theme/css.ts +21 -0
- package/src/shared/lib/theme/first-frame.ts +38 -0
- package/src/shared/lib/theme/ink-scale.test.ts +151 -0
- package/src/shared/lib/theme/ink-scale.ts +103 -0
- package/src/shared/lib/theme/shell-palette.test.ts +22 -5
- package/src/shared/lib/theme/shell-palette.ts +9 -4
- package/src/shared/lib/theme/theme.test.ts +28 -3
- package/src/shared/lib/workspace/project-accent.test.ts +33 -1
- package/src/shared/lib/workspace/project-accent.ts +23 -0
- package/src/shared/types/omp/agent.ts +24 -9
- package/dist/client/static/js/index-0721wrkf.css +0 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A goal the operator ARMED is started by the prompt that follows.
|
|
8
|
+
*
|
|
9
|
+
* The two shapes turn the same send into two different things, and that is the
|
|
10
|
+
* whole contract:
|
|
11
|
+
*
|
|
12
|
+
* - `create` — the record is written (`startTurn: false`) and the prompt is
|
|
13
|
+
* still sent, as the goal's first turn.
|
|
14
|
+
* - `guided` — there is no objective yet, so the prompt IS the interview's
|
|
15
|
+
* opening turn; nothing is sent after it, or the same question is asked
|
|
16
|
+
* twice and two user rows appear for one answer.
|
|
17
|
+
*
|
|
18
|
+
* Both were measured against a real child; see the wiki page for the numbers.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { describe, expect, test } from 'bun:test';
|
|
22
|
+
import { act } from 'preact/test-utils';
|
|
23
|
+
import { makeSendHarness } from '@/client/hooks/chat/timeline/send.test-util';
|
|
24
|
+
|
|
25
|
+
// The harness installs the DOM itself. A local `restoreDomGlobals()` here would
|
|
26
|
+
// strip `document` for every file Bun runs after this one (measured: four
|
|
27
|
+
// `document is not defined` failures in `send-refusal.test.ts`), because it
|
|
28
|
+
// restores whatever was captured at import time rather than this file's state.
|
|
29
|
+
|
|
30
|
+
/** Stub the mode POST so a case can read what the send actually created. */
|
|
31
|
+
function installModePost() {
|
|
32
|
+
const posts: Array<{ url: string; body: Record<string, unknown> }> = [];
|
|
33
|
+
const original = globalThis.fetch;
|
|
34
|
+
globalThis.fetch = (async (input: unknown, init?: { body?: string }) => {
|
|
35
|
+
posts.push({ url: String(input), body: JSON.parse(String(init?.body ?? '{}')) });
|
|
36
|
+
return new Response(JSON.stringify({ success: true }), {
|
|
37
|
+
status: 200,
|
|
38
|
+
headers: { 'content-type': 'application/json' },
|
|
39
|
+
});
|
|
40
|
+
}) as typeof fetch;
|
|
41
|
+
return { posts, restore: () => { globalThis.fetch = original; } };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Only the agent route matters here: other subsystems post on mount. */
|
|
45
|
+
function agentPosts(posts: Array<{ url: string; body: Record<string, unknown> }>) {
|
|
46
|
+
return posts.filter((entry) => entry.url.startsWith('/api/agent'));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe('an ARMED goal', () => {
|
|
50
|
+
test('is created at the fence of the prompt, with startTurn false, and then cleared', async () => {
|
|
51
|
+
const h = makeSendHarness({ sessionId: 'omp-1' });
|
|
52
|
+
const post = installModePost();
|
|
53
|
+
try {
|
|
54
|
+
h.goalArmRef.current = { kind: 'create', objective: 'Ship the importer', tokenBudget: 50_000, maxTurns: 4 };
|
|
55
|
+
|
|
56
|
+
await act(async () => {
|
|
57
|
+
await h.sends.executeSend('do the work', []);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// One command, to the session the prompt goes to, and the objective is
|
|
61
|
+
// the one the operator armed.
|
|
62
|
+
expect(agentPosts(post.posts)).toHaveLength(1);
|
|
63
|
+
expect(agentPosts(post.posts)[0].url).toBe('/api/agent/omp-1');
|
|
64
|
+
expect(agentPosts(post.posts)[0].body).toMatchObject({
|
|
65
|
+
type: 'kabmo_mode',
|
|
66
|
+
scope: 'goal',
|
|
67
|
+
action: 'create',
|
|
68
|
+
payload: {
|
|
69
|
+
objective: 'Ship the importer',
|
|
70
|
+
tokenBudget: 50_000,
|
|
71
|
+
maxTurns: 4,
|
|
72
|
+
// The prompt IS the goal's first turn: without this the child opens
|
|
73
|
+
// its own hidden turn and the operator's message becomes a second.
|
|
74
|
+
startTurn: false,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
// Spent, not remembered: a goal must not re-apply to the next prompt.
|
|
78
|
+
expect(h.goalArmRef.current).toBeNull();
|
|
79
|
+
// The prompt still went out.
|
|
80
|
+
expect(h.agent.calls.prompts.map((p) => p.text)).toEqual(['do the work']);
|
|
81
|
+
} finally {
|
|
82
|
+
post.restore();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('a refused creation still sends the prompt and says why', async () => {
|
|
87
|
+
const h = makeSendHarness({ sessionId: 'omp-1' });
|
|
88
|
+
const original = globalThis.fetch;
|
|
89
|
+
globalThis.fetch = (async () => new Response(JSON.stringify({ error: 'cannot create a new goal' }), {
|
|
90
|
+
status: 409,
|
|
91
|
+
headers: { 'content-type': 'application/json' },
|
|
92
|
+
})) as unknown as typeof fetch;
|
|
93
|
+
try {
|
|
94
|
+
h.goalArmRef.current = { kind: 'create', objective: 'x' };
|
|
95
|
+
await act(async () => {
|
|
96
|
+
await h.sends.executeSend('do the work', []);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(h.agent.calls.prompts.map((p) => p.text)).toEqual(['do the work']);
|
|
100
|
+
expect(h.reported.some((message) => message.includes('cannot create a new goal'))).toBe(true);
|
|
101
|
+
} finally {
|
|
102
|
+
globalThis.fetch = original;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('nothing is posted when no goal is armed', async () => {
|
|
107
|
+
const h = makeSendHarness({ sessionId: 'omp-1' });
|
|
108
|
+
const post = installModePost();
|
|
109
|
+
try {
|
|
110
|
+
await act(async () => {
|
|
111
|
+
await h.sends.executeSend('just a message', []);
|
|
112
|
+
});
|
|
113
|
+
expect(agentPosts(post.posts)).toEqual([]);
|
|
114
|
+
} finally {
|
|
115
|
+
post.restore();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('an ARMED interview', () => {
|
|
121
|
+
test('turns the prompt into the kickoff, and sends nothing else', async () => {
|
|
122
|
+
const h = makeSendHarness({ sessionId: 'omp-1' });
|
|
123
|
+
const post = installModePost();
|
|
124
|
+
try {
|
|
125
|
+
h.goalArmRef.current = { kind: 'guided', rough: 'make the tests fast' };
|
|
126
|
+
|
|
127
|
+
await act(async () => {
|
|
128
|
+
await h.sends.executeSend('speed up the test suite', []);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const posts = agentPosts(post.posts);
|
|
132
|
+
expect(posts).toHaveLength(1);
|
|
133
|
+
// The operator's message IS the interview's opening turn: it travels to
|
|
134
|
+
// the extension as the kickoff content, and no separate prompt follows.
|
|
135
|
+
expect(posts[0].body).toMatchObject({
|
|
136
|
+
scope: 'goal',
|
|
137
|
+
action: 'guided',
|
|
138
|
+
payload: { message: 'speed up the test suite' },
|
|
139
|
+
});
|
|
140
|
+
expect(h.agent.calls.prompts).toEqual([]);
|
|
141
|
+
expect(h.goalArmRef.current).toBeNull();
|
|
142
|
+
} finally {
|
|
143
|
+
post.restore();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('a refused interview falls back to an ordinary prompt', async () => {
|
|
148
|
+
const h = makeSendHarness({ sessionId: 'omp-1' });
|
|
149
|
+
const original = globalThis.fetch;
|
|
150
|
+
globalThis.fetch = (async () => new Response(JSON.stringify({ error: 'goal-mode API missing' }), {
|
|
151
|
+
status: 400,
|
|
152
|
+
headers: { 'content-type': 'application/json' },
|
|
153
|
+
})) as unknown as typeof fetch;
|
|
154
|
+
try {
|
|
155
|
+
h.goalArmRef.current = { kind: 'guided', rough: 'x' };
|
|
156
|
+
await act(async () => {
|
|
157
|
+
await h.sends.executeSend('speed up the test suite', []);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// The interview never started, so the words must still reach the agent as
|
|
161
|
+
// an ordinary turn — losing them would swallow the operator's message.
|
|
162
|
+
expect(h.agent.calls.prompts.map((p) => p.text)).toEqual(['speed up the test suite']);
|
|
163
|
+
expect(h.reported.some((message) => message.includes('goal-mode API missing'))).toBe(true);
|
|
164
|
+
} finally {
|
|
165
|
+
globalThis.fetch = original;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Setting a goal ARMS it; it does not start it.
|
|
8
|
+
*
|
|
9
|
+
* The rule the operator asked for, and the reason it is the right one: a goal
|
|
10
|
+
* costs tokens and needs a turn to act on, so the turn has to be the operator's
|
|
11
|
+
* own message. Creating it at that fence is also what keeps the transcript
|
|
12
|
+
* honest — a self-opening goal turn was measured to produce `user ×0`, i.e. an
|
|
13
|
+
* assistant answering a question nobody can see.
|
|
14
|
+
*
|
|
15
|
+
* `chat-command.test.ts` owns the other half (the `/goal` command against a
|
|
16
|
+
* live child); this file owns the armed state and its surfaces.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
20
|
+
import { Window } from 'happy-dom';
|
|
21
|
+
import { h, render } from 'preact';
|
|
22
|
+
import { act } from 'preact/test-utils';
|
|
23
|
+
import { useChatTimelineModes } from '@/client/hooks/chat/timeline/modes';
|
|
24
|
+
import type { ArmedGoal } from '@/shared/lib/omp/mode/actions';
|
|
25
|
+
|
|
26
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event', 'CustomEvent'] as const;
|
|
27
|
+
const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
28
|
+
const nativeFetch = Bun.fetch;
|
|
29
|
+
|
|
30
|
+
/** A session whose transcript exists and has no goal (the modes read answers
|
|
31
|
+
* the empty selection). */
|
|
32
|
+
const LIVE = 'session-live-empty';
|
|
33
|
+
const PENDING = 'new-1790756769131';
|
|
34
|
+
|
|
35
|
+
let container: HTMLElement | undefined;
|
|
36
|
+
const requests: Array<{ url: string; method: string }> = [];
|
|
37
|
+
|
|
38
|
+
beforeAll(() => {
|
|
39
|
+
const win = new Window({ url: 'http://localhost' });
|
|
40
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
41
|
+
for (const key of DOM_GLOBALS) {
|
|
42
|
+
if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
|
|
43
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
44
|
+
}
|
|
45
|
+
target.fetch = async (input: unknown, init?: { method?: string }) => {
|
|
46
|
+
const url = String(input);
|
|
47
|
+
requests.push({ url, method: init?.method ?? 'GET' });
|
|
48
|
+
if (init?.method === 'POST') {
|
|
49
|
+
return new Response(JSON.stringify({ success: true }), {
|
|
50
|
+
status: 200,
|
|
51
|
+
headers: { 'content-type': 'application/json' },
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (url.includes(`/${LIVE}/modes`)) {
|
|
55
|
+
return new Response(JSON.stringify({ sessionId: LIVE, modes: { plan: false, goal: false, goalRecord: null } }), {
|
|
56
|
+
status: 200,
|
|
57
|
+
headers: { 'content-type': 'application/json' },
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return new Response(JSON.stringify({ error: 'Session not found' }), {
|
|
61
|
+
status: 404,
|
|
62
|
+
headers: { 'content-type': 'application/json' },
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
afterAll(() => {
|
|
68
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
69
|
+
for (const key of DOM_GLOBALS) {
|
|
70
|
+
if (nativeGlobals[key] === undefined) delete target[key];
|
|
71
|
+
else target[key] = nativeGlobals[key];
|
|
72
|
+
}
|
|
73
|
+
target.fetch = nativeFetch;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
if (container) render(null, container);
|
|
78
|
+
container?.remove();
|
|
79
|
+
container = undefined;
|
|
80
|
+
requests.length = 0;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
interface Probe {
|
|
84
|
+
el: HTMLElement;
|
|
85
|
+
lastResult: () => unknown;
|
|
86
|
+
armed: () => ArmedGoal | null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Mount the mode hook and expose the two things a case asserts on. */
|
|
90
|
+
async function mount(sessionId: string): Promise<Probe> {
|
|
91
|
+
let lastResult: unknown = null;
|
|
92
|
+
let armed: ArmedGoal | null = null;
|
|
93
|
+
|
|
94
|
+
function ModeProbe({ id }: { id: string }) {
|
|
95
|
+
const modes = useChatTimelineModes(id);
|
|
96
|
+
armed = modes.goalArm;
|
|
97
|
+
return h(
|
|
98
|
+
'div',
|
|
99
|
+
{ id: 'probe' },
|
|
100
|
+
h('button', {
|
|
101
|
+
id: 'set-goal',
|
|
102
|
+
onClick: async () => {
|
|
103
|
+
lastResult = await modes.onGoalAction({ kind: 'create', objective: 'Ship the importer', tokenBudget: 50_000 });
|
|
104
|
+
},
|
|
105
|
+
}, 'set'),
|
|
106
|
+
h('button', {
|
|
107
|
+
id: 'interview',
|
|
108
|
+
onClick: async () => {
|
|
109
|
+
lastResult = await modes.onGoalAction({ kind: 'guided', rough: 'make it fast' });
|
|
110
|
+
},
|
|
111
|
+
}, 'interview'),
|
|
112
|
+
h('button', {
|
|
113
|
+
id: 'disarm',
|
|
114
|
+
onClick: () => modes.disarmGoal(),
|
|
115
|
+
}, 'disarm'),
|
|
116
|
+
h('span', {
|
|
117
|
+
id: 'armed-state',
|
|
118
|
+
'data-kind': modes.goalArm?.kind ?? '',
|
|
119
|
+
}, modes.goalArm ? (modes.goalArm.kind === 'guided' ? modes.goalArm.rough : modes.goalArm.objective) : ''),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
container ??= document.body.appendChild(document.createElement('div'));
|
|
124
|
+
await act(async () => { render(h(ModeProbe, { id: sessionId }), container as HTMLElement); });
|
|
125
|
+
for (let i = 0; i < 6; i += 1) await act(async () => {});
|
|
126
|
+
return {
|
|
127
|
+
el: container,
|
|
128
|
+
lastResult: () => lastResult,
|
|
129
|
+
armed: () => armed,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function click(el: HTMLElement, id: string): Promise<void> {
|
|
134
|
+
await act(async () => { (el.querySelector(`#${id}`) as HTMLButtonElement).click(); });
|
|
135
|
+
for (let i = 0; i < 6; i += 1) await act(async () => {});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
describe('setting a goal arms it', () => {
|
|
139
|
+
test('on a live session, nothing is sent until a prompt carries it', async () => {
|
|
140
|
+
const probe = await mount(LIVE);
|
|
141
|
+
await click(probe.el, 'set-goal');
|
|
142
|
+
|
|
143
|
+
expect(probe.lastResult()).toEqual({ ok: true, armed: true });
|
|
144
|
+
expect(probe.el.querySelector('#armed-state')?.textContent).toBe('Ship the importer');
|
|
145
|
+
// The whole point: no command, no turn, no tokens.
|
|
146
|
+
expect(requests.filter((request) => request.method === 'POST')).toHaveLength(0);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('on a pending chat, arming works the same way', async () => {
|
|
150
|
+
const probe = await mount(PENDING);
|
|
151
|
+
await click(probe.el, 'set-goal');
|
|
152
|
+
|
|
153
|
+
expect(probe.lastResult()).toEqual({ ok: true, armed: true });
|
|
154
|
+
expect(requests.filter((request) => request.method === 'POST')).toHaveLength(0);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('disarming clears the armed goal', async () => {
|
|
158
|
+
const probe = await mount(LIVE);
|
|
159
|
+
await click(probe.el, 'set-goal');
|
|
160
|
+
await click(probe.el, 'disarm');
|
|
161
|
+
|
|
162
|
+
expect(probe.el.querySelector('#armed-state')?.textContent).toBe('');
|
|
163
|
+
expect(probe.armed()).toBeNull();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('a guided interview is armed too, and waits for the message that answers it', async () => {
|
|
167
|
+
const probe = await mount(PENDING);
|
|
168
|
+
await click(probe.el, 'interview');
|
|
169
|
+
|
|
170
|
+
expect(probe.lastResult()).toEqual({ ok: true, armed: true });
|
|
171
|
+
// Armed, and named as an interview: there is no objective yet, so the strip
|
|
172
|
+
// must not pretend one exists.
|
|
173
|
+
expect(probe.armed()).toEqual({ kind: 'guided', rough: 'make it fast' });
|
|
174
|
+
expect(probe.el.querySelector('#armed-state')?.getAttribute('data-kind')).toBe('guided');
|
|
175
|
+
// Still nothing sent: the operator's next message is what starts it.
|
|
176
|
+
expect(requests.filter((request) => request.method === 'POST')).toHaveLength(0);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -18,17 +18,39 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { GoalContinuation, GoalRecord } from '@/shared/lib/omp/mode/types';
|
|
21
|
-
import type { GoalAction } from '@/
|
|
21
|
+
import type { GoalAction } from '@/shared/lib/omp/mode/actions';
|
|
22
|
+
import type { ModeCommandResult } from '@/client/hooks/chat/timeline/mode-post';
|
|
23
|
+
|
|
24
|
+
/** What one goal command produced. The modal closes on `ok` and keeps the form
|
|
25
|
+
* open (with its objective) otherwise, so a refusal can be read and retried
|
|
26
|
+
* instead of throwing away what the user typed. */
|
|
27
|
+
export interface GoalActionResult {
|
|
28
|
+
ok: boolean;
|
|
29
|
+
/** Why it was refused — the route's own sentence, or the child's. */
|
|
30
|
+
error?: string;
|
|
31
|
+
/** Set when the action started a session (a pending chat's goal). */
|
|
32
|
+
sessionId?: string;
|
|
33
|
+
/** True when the goal was RECORDED for the next prompt instead of created:
|
|
34
|
+
* the operator has set an objective, and nothing runs until they send. */
|
|
35
|
+
armed?: boolean;
|
|
36
|
+
}
|
|
22
37
|
|
|
23
38
|
/** Everything the goal commands need from the hook that owns the state. */
|
|
24
39
|
export interface GoalCommandHost {
|
|
25
|
-
/** Dispatch one mode command to the live child
|
|
26
|
-
|
|
40
|
+
/** Dispatch one mode command to the live child. Resolves with the route's
|
|
41
|
+
* refusal reason, which is the same sentence the composer renders — the
|
|
42
|
+
* handler must not re-derive it from state that may not have flushed. */
|
|
43
|
+
send: (scope: 'goal', action: string, payload?: Record<string, unknown>) => Promise<ModeCommandResult>;
|
|
27
44
|
setGoalState: (enabled: boolean) => void;
|
|
28
45
|
setGoalRecord: (update: (prev: GoalRecord | null) => GoalRecord | null) => void;
|
|
29
46
|
setGoalContinuation: (continuation: GoalContinuation | null) => void;
|
|
30
47
|
}
|
|
31
48
|
|
|
49
|
+
/** A refusal result, with the reason the caller supplied. */
|
|
50
|
+
function refused(error: string | undefined, fallback: string): GoalActionResult {
|
|
51
|
+
return { ok: false, error: error ?? fallback };
|
|
52
|
+
}
|
|
53
|
+
|
|
32
54
|
/**
|
|
33
55
|
* Build the `onGoalAction` handler for one hook instance.
|
|
34
56
|
*
|
|
@@ -36,41 +58,49 @@ export interface GoalCommandHost {
|
|
|
36
58
|
* starts over in the child (`resetGoalContinuationTurns`), and omp's own resume
|
|
37
59
|
* opens no turn, so a "stopped at 25 turns" row left standing would describe a
|
|
38
60
|
* state the operator just left.
|
|
61
|
+
*
|
|
62
|
+
* Every action RESOLVES: the modal decides whether to close from the outcome,
|
|
63
|
+
* and a refused command must leave the form — and the objective typed into it —
|
|
64
|
+
* on screen.
|
|
39
65
|
*/
|
|
40
|
-
export function createGoalAction(host: GoalCommandHost): (action: GoalAction) =>
|
|
66
|
+
export function createGoalAction(host: GoalCommandHost): (action: GoalAction) => Promise<GoalActionResult> {
|
|
41
67
|
const { send, setGoalState, setGoalRecord, setGoalContinuation } = host;
|
|
42
68
|
|
|
43
|
-
return (action: GoalAction) => {
|
|
69
|
+
return async (action: GoalAction): Promise<GoalActionResult> => {
|
|
44
70
|
if (action.kind === 'create') {
|
|
45
|
-
|
|
71
|
+
const posted = await send('goal', 'create', {
|
|
46
72
|
objective: action.objective,
|
|
47
73
|
tokenBudget: action.tokenBudget,
|
|
48
74
|
maxTurns: action.maxTurns,
|
|
49
|
-
})
|
|
50
|
-
return;
|
|
75
|
+
});
|
|
76
|
+
if (!posted.ok) return refused(posted.error, 'The goal was refused.');
|
|
77
|
+
setGoalContinuation(null);
|
|
78
|
+
return { ok: true };
|
|
51
79
|
}
|
|
52
80
|
if (action.kind === 'guided') {
|
|
53
|
-
|
|
54
|
-
return;
|
|
81
|
+
const posted = await send('goal', 'guided', { rough: action.rough });
|
|
82
|
+
if (!posted.ok) return refused(posted.error, 'The interview could not start.');
|
|
83
|
+
setGoalContinuation(null);
|
|
84
|
+
return { ok: true };
|
|
55
85
|
}
|
|
56
86
|
if (action.kind === 'budget') {
|
|
57
|
-
|
|
58
|
-
return;
|
|
87
|
+
const posted = await send('goal', 'budget', { value: action.value });
|
|
88
|
+
return posted.ok ? { ok: true } : refused(posted.error, 'The budget was refused.');
|
|
89
|
+
}
|
|
90
|
+
const posted = await send('goal', action.kind);
|
|
91
|
+
if (!posted.ok) return refused(posted.error, 'The mode command was refused.');
|
|
92
|
+
if (action.kind === 'pause') {
|
|
93
|
+
setGoalState(false);
|
|
94
|
+
setGoalRecord((prev) => (prev ? { ...prev, status: 'paused' } : prev));
|
|
95
|
+
} else if (action.kind === 'resume') {
|
|
96
|
+
setGoalState(true);
|
|
97
|
+
setGoalRecord((prev) => (prev ? { ...prev, status: 'active' } : prev));
|
|
98
|
+
setGoalContinuation(null);
|
|
99
|
+
} else if (action.kind === 'drop') {
|
|
100
|
+
setGoalState(false);
|
|
101
|
+
setGoalRecord(() => null);
|
|
102
|
+
setGoalContinuation(null);
|
|
59
103
|
}
|
|
60
|
-
|
|
61
|
-
if (!ok) return;
|
|
62
|
-
if (action.kind === 'pause') {
|
|
63
|
-
setGoalState(false);
|
|
64
|
-
setGoalRecord((prev) => (prev ? { ...prev, status: 'paused' } : prev));
|
|
65
|
-
} else if (action.kind === 'resume') {
|
|
66
|
-
setGoalState(true);
|
|
67
|
-
setGoalRecord((prev) => (prev ? { ...prev, status: 'active' } : prev));
|
|
68
|
-
setGoalContinuation(null);
|
|
69
|
-
} else if (action.kind === 'drop') {
|
|
70
|
-
setGoalState(false);
|
|
71
|
-
setGoalRecord(() => null);
|
|
72
|
-
setGoalContinuation(null);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
104
|
+
return { ok: true };
|
|
75
105
|
};
|
|
76
106
|
}
|
|
@@ -39,10 +39,6 @@ export function useChatTimeline({
|
|
|
39
39
|
reportActionError = (message: string) => console.error(message),
|
|
40
40
|
}: UseChatTimelineOptions = {}) {
|
|
41
41
|
const { sessionId, folderId, selectedFolderId, selectContextFolder, setSearchParams } = useTimelineScope();
|
|
42
|
-
// Plan/goal toggles plus the plan-review surface. PER SESSION, unlike the
|
|
43
|
-
// access mode: they describe what this conversation is doing, and one hook
|
|
44
|
-
// returns both halves because a mode command can produce a proposal.
|
|
45
|
-
const { modes, planReview } = useComposerModes(sessionId);
|
|
46
42
|
|
|
47
43
|
// Ref mirror of loadOlder so the scroll handler can call the latest one
|
|
48
44
|
// without re-creating it (useSessionLoad is defined below the scroll hook).
|
|
@@ -217,6 +213,11 @@ export function useChatTimeline({
|
|
|
217
213
|
}), activityRef, localMessagesRef);
|
|
218
214
|
const spawn = useSpawnTarget(sessionId);
|
|
219
215
|
|
|
216
|
+
// Plan/goal toggles plus the plan-review surface. PER SESSION, unlike the
|
|
217
|
+
// access mode: they describe what this conversation is doing, and a mode
|
|
218
|
+
// command can produce a proposal.
|
|
219
|
+
const { modes, planReview } = useComposerModes(sessionId);
|
|
220
|
+
|
|
220
221
|
const { steerOmpAgent, executeSend } = useChatTimelineSend({
|
|
221
222
|
folders,
|
|
222
223
|
selectedFolderId,
|
|
@@ -240,6 +241,8 @@ export function useChatTimeline({
|
|
|
240
241
|
deferredComposerPickRef,
|
|
241
242
|
accessModeRef,
|
|
242
243
|
spawnSelectionRef: modes.spawnSelectionRef,
|
|
244
|
+
goalArmRef: modes.goalArmRef,
|
|
245
|
+
disarmGoal: modes.disarmGoal,
|
|
243
246
|
spawnWorktreeRef: spawn.worktreePathRef,
|
|
244
247
|
abortControllerRef,
|
|
245
248
|
setInputValue,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One POST of a mode command, and the answer as a value.
|
|
8
|
+
*
|
|
9
|
+
* Extracted because two callers now send these: the composer's toggles (to the
|
|
10
|
+
* session on screen) and the goal spawner (to the session a spawn just
|
|
11
|
+
* answered with, BEFORE the URL has moved to it). Both need the same three
|
|
12
|
+
* outcomes — accepted, refused with the server's sentence, or refused by the
|
|
13
|
+
* transport — and a second copy of that `fetch` is how one of them ends up
|
|
14
|
+
* reporting a refusal as success.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { MODE_COMMAND_TYPE } from '@/shared/lib/omp/mode/types';
|
|
18
|
+
|
|
19
|
+
export interface ModeCommandResult {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** POST `type: 'kabmo_mode'` for `sessionId`. A non-2xx answer carries the
|
|
25
|
+
* route's own reason (`error`), which is the text the composer shows. */
|
|
26
|
+
export async function postModeCommand(
|
|
27
|
+
sessionId: string,
|
|
28
|
+
scope: 'plan' | 'goal',
|
|
29
|
+
action: string,
|
|
30
|
+
payload?: Record<string, unknown>,
|
|
31
|
+
): Promise<ModeCommandResult> {
|
|
32
|
+
try {
|
|
33
|
+
const res = await fetch(`/api/agent/${encodeURIComponent(sessionId)}`, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: { 'Content-Type': 'application/json' },
|
|
36
|
+
body: JSON.stringify({ type: MODE_COMMAND_TYPE, scope, action, ...(payload ? { payload } : {}) }),
|
|
37
|
+
});
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
40
|
+
return { ok: false, error: body.error ?? 'Mode command failed' };
|
|
41
|
+
}
|
|
42
|
+
return { ok: true };
|
|
43
|
+
} catch (err) {
|
|
44
|
+
return { ok: false, error: err instanceof Error ? err.message : 'Mode command failed' };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What `useChatTimelineModes` returns, declared apart from the hook.
|
|
8
|
+
*
|
|
9
|
+
* Split for the repo's per-file ceiling, and the seam is real: the CONTRACT is
|
|
10
|
+
* read by the composer's prop shapes (`chat-input/modes-props.ts`), the goal
|
|
11
|
+
* surfaces and their tests, while the hook file is the implementation. A field
|
|
12
|
+
* added for a new surface therefore never has to be threaded through the hook's
|
|
13
|
+
* own body to be visible.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { KabmoModeSelection, GoalContinuation, GoalRecord } from '@/shared/lib/omp/mode/types';
|
|
17
|
+
import type { GoalActionResult } from '@/client/hooks/chat/timeline/goal-command';
|
|
18
|
+
import type { ArmedGoal, GoalAction } from '@/shared/lib/omp/mode/actions';
|
|
19
|
+
|
|
20
|
+
export interface ChatTimelineModes {
|
|
21
|
+
plan: boolean;
|
|
22
|
+
/** omp's own `enabled` flag: the agent is working toward the goal right now.
|
|
23
|
+
* False for a PAUSED goal, which still exists (see `goalOpen`). */
|
|
24
|
+
goal: boolean;
|
|
25
|
+
/** A goal this chat still owns — omp's `enabled` OR an open record. This is
|
|
26
|
+
* the flag every surface should gate on: pausing clears `enabled` while the
|
|
27
|
+
* record stays resumable, so gating on `goal` alone made the goal vanish
|
|
28
|
+
* from the composer (strip gone, button off, modal offering to create a
|
|
29
|
+
* second goal over the paused one). */
|
|
30
|
+
goalOpen: boolean;
|
|
31
|
+
goalRecord: GoalRecord | null;
|
|
32
|
+
/**
|
|
33
|
+
* The child's last automatic goal turn (`KABMO_GOAL_CONTINUATION`), or
|
|
34
|
+
* null when the loop has not reported one for the current goal. Cleared when
|
|
35
|
+
* the goal itself changes: a counter from the previous goal names a turn this
|
|
36
|
+
* one never took.
|
|
37
|
+
*/
|
|
38
|
+
goalContinuation: GoalContinuation | null;
|
|
39
|
+
/**
|
|
40
|
+
* True while the child's loop is deciding whether to open another automatic
|
|
41
|
+
* turn. The decision is a synchronous guard chain with no other frame, so
|
|
42
|
+
* this is the only signal for the window in which the goal is neither
|
|
43
|
+
* streaming nor idle.
|
|
44
|
+
*/
|
|
45
|
+
goalEvaluating: boolean;
|
|
46
|
+
/** True while a mode command is in flight; the toggle shows a pending state
|
|
47
|
+
* rather than flipping optimistically and snapping back. */
|
|
48
|
+
pending: boolean;
|
|
49
|
+
/** omp refuses to enter one mode while the other is active, so Plan is not
|
|
50
|
+
* offered while Goal is on — a button whose only outcome is a refusal is
|
|
51
|
+
* worse than an absent one. The child enforces the same rule, because this
|
|
52
|
+
* flag only hides a button: a stale client or a typed `/plan` used to reach
|
|
53
|
+
* the child and turn both modes on. */
|
|
54
|
+
planAvailable: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The last refusal, from either side of the wire: the route's own error, or a
|
|
57
|
+
* `KABMO_MODE_ERROR` the extension emitted (an unknown action, a missing
|
|
58
|
+
* omp API, the plan/goal exclusion). Surfaced by the composer because a mode
|
|
59
|
+
* command that fails silently leaves the toggle pressed over a mode the child
|
|
60
|
+
* is not in.
|
|
61
|
+
*/
|
|
62
|
+
error: string | null;
|
|
63
|
+
/** Clear the refusal once it has been shown. */
|
|
64
|
+
clearError: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* For a pending `new-…` chat only: the selection its spawn must carry, since
|
|
67
|
+
* there is no child to command yet. Null once the session exists — from then
|
|
68
|
+
* on the child is authoritative and the value is written to its transcript.
|
|
69
|
+
*
|
|
70
|
+
* A ref rather than a value because the reader is the SEND path
|
|
71
|
+
* (`executeSend`), which runs outside the render that produced it.
|
|
72
|
+
*/
|
|
73
|
+
spawnSelectionRef: { current: KabmoModeSelection | null };
|
|
74
|
+
/**
|
|
75
|
+
* The goal the operator has armed but not started: the objective (and its
|
|
76
|
+
* limits) waiting for the next prompt to become the goal's first turn. Null
|
|
77
|
+
* when no goal is armed.
|
|
78
|
+
*
|
|
79
|
+
* Surfaced as a VALUE, not only a ref, because the strip has to say what is
|
|
80
|
+
* waiting — the button reading as "on" over a goal nothing is pursuing is
|
|
81
|
+
* exactly the lie this state exists to avoid.
|
|
82
|
+
*/
|
|
83
|
+
goalArm: ArmedGoal | null;
|
|
84
|
+
/** Drop the armed goal without starting it. */
|
|
85
|
+
disarmGoal: () => void;
|
|
86
|
+
/** The same arm as a ref, for the SEND path (which runs outside a render). */
|
|
87
|
+
goalArmRef: { current: ArmedGoal | null };
|
|
88
|
+
onTogglePlan: (enabled: boolean) => void;
|
|
89
|
+
/** Goal needs an objective, so the toggle opens a modal instead of sending a
|
|
90
|
+
* bare enable — see `GoalModal`. Resolves with the outcome because the modal
|
|
91
|
+
* closes only on success: a refusal keeps the form and its objective, so the
|
|
92
|
+
* user can read the reason and retry. */
|
|
93
|
+
onGoalAction: (action: GoalAction) => Promise<GoalActionResult>;
|
|
94
|
+
}
|