@kabmo-labs/kabmo 0.23.0 → 0.25.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/dist/client/index.html +1 -1
- package/dist/client/index.js +805 -736
- package/dist/client/static/js/index-bc9aa4mx.css +1 -0
- package/dist/client/static/js/{index-ph0q59rs.js → index-ga8cbpt4.js} +1071 -1171
- package/package.json +2 -4
- package/src/cli/lib/args.js +24 -1
- package/src/cli/lib/args.test.js +16 -0
- package/src/cli/lib/commands/session.js +233 -0
- package/src/cli/lib/commands/session.test.js +103 -0
- package/src/cli/main.js +1 -1
- package/src/client/components/common/ComposerPicker.tsx +3 -0
- package/src/client/components/common/Modal.tsx +2 -6
- package/src/client/components/common/code-surface/shiki.test.ts +82 -0
- package/src/client/components/common/code-surface/shiki.ts +28 -7
- package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +113 -0
- package/src/client/components/common/session-actions-menu/index.tsx +33 -2
- package/src/client/components/common/session-row/StatusSlot.tsx +4 -4
- package/src/client/components/common/session-row/index.tsx +27 -1
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
- package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +25 -12
- package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +66 -0
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +28 -3
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +20 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +59 -12
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +94 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +120 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +47 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +55 -46
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +18 -5
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +21 -4
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +27 -5
- package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +31 -0
- package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +49 -0
- package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
- package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +135 -118
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
- package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +4 -0
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +5 -2
- package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
- package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
- package/src/client/components/workspace/file-explorer/index.tsx +9 -3
- package/src/client/components/workspace/model-dropdown/harness-models.test.ts +17 -0
- package/src/client/components/workspace/model-dropdown/harness-models.ts +33 -18
- package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
- package/src/client/components/workspace/model-dropdown/popover-metrics.ts +4 -1
- package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
- package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
- package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
- package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
- package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
- package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
- package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
- package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
- package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
- package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
- package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
- package/src/client/data/settings/omp-schema.json +5 -5
- package/src/client/data/theme/terminal.test.ts +25 -0
- package/src/client/data/theme/terminal.ts +96 -79
- package/src/client/hooks/chat/composer/items.test.ts +12 -26
- package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
- package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
- package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
- package/src/client/hooks/chat/timeline/actions.ts +2 -2
- package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
- package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
- package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
- package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
- package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
- package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
- package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
- package/src/client/hooks/chat/timeline/rewind-actions.test.ts +24 -1
- package/src/client/hooks/chat/timeline/rewind-actions.ts +15 -11
- package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
- package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
- package/src/client/hooks/chat/timeline/send-execute.test.ts +56 -0
- package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
- package/src/client/hooks/chat/timeline/send-props.ts +5 -3
- package/src/client/hooks/chat/timeline/send-steer.test.ts +4 -4
- package/src/client/hooks/chat/timeline/send.test-util.ts +8 -2
- package/src/client/hooks/chat/timeline/send.test.ts +4 -4
- package/src/client/hooks/chat/timeline/send.ts +59 -53
- package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
- package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
- package/src/client/hooks/chat/timeline/session-load.ts +6 -14
- package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
- package/src/client/hooks/chat/timeline/use-fork-session.ts +49 -0
- package/src/client/hooks/models/harness-catalog.ts +114 -0
- package/src/client/hooks/models/provider-writes.test.ts +81 -0
- package/src/client/hooks/models/provider-writes.ts +10 -3
- package/src/client/hooks/models/use-harness-update.test.ts +193 -0
- package/src/client/hooks/models/use-harness-update.ts +202 -0
- package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
- package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
- package/src/client/hooks/models/use-harnesses.test.ts +2 -1
- package/src/client/hooks/models/use-harnesses.ts +48 -114
- package/src/client/hooks/workspace/child-expansion.ts +33 -0
- package/src/client/hooks/workspace/terminal/index.ts +17 -3
- package/src/client/hooks/workspace/terminal/socket.ts +9 -4
- package/src/client/lib/session-tree.test.ts +50 -0
- package/src/client/lib/session-tree.ts +59 -0
- package/src/client/tailwind.css +26 -12
- package/src/server/index.ts +2 -0
- package/src/server/lib/auth/guard.ts +10 -0
- package/src/server/lib/btw/session-copy.server.ts +6 -44
- package/src/server/lib/btw/session-copy.test.ts +2 -1
- package/src/server/lib/db/schema.ts +4 -0
- package/src/server/lib/db/seed-terminal.test.ts +1 -1
- package/src/server/lib/db/seed.test.ts +1 -1
- package/src/server/lib/harness/acp/activation.test.ts +81 -0
- package/src/server/lib/harness/acp/activation.ts +72 -0
- package/src/server/lib/harness/acp/background-work.test.ts +262 -0
- package/src/server/lib/harness/acp/background-work.ts +320 -0
- package/src/server/lib/harness/acp/client.ts +2 -2
- package/src/server/lib/harness/acp/frames.test.ts +50 -1
- package/src/server/lib/harness/acp/frames.ts +17 -5
- package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
- package/src/server/lib/harness/acp/gateway-env.ts +70 -0
- package/src/server/lib/harness/acp/mapper.ts +6 -4
- package/src/server/lib/harness/acp/prompt.test.ts +20 -0
- package/src/server/lib/harness/acp/prompt.ts +19 -3
- package/src/server/lib/harness/acp/session-background.test.ts +129 -0
- package/src/server/lib/harness/acp/session-config.test.ts +73 -0
- package/src/server/lib/harness/acp/session-config.ts +87 -6
- package/src/server/lib/harness/acp/session-exit.ts +31 -0
- package/src/server/lib/harness/acp/session-handshake.test.ts +108 -0
- package/src/server/lib/harness/acp/session-handshake.ts +36 -3
- package/src/server/lib/harness/acp/session-idle.ts +51 -0
- package/src/server/lib/harness/acp/session-listeners.ts +31 -0
- package/src/server/lib/harness/acp/session-notifications.ts +19 -3
- package/src/server/lib/harness/acp/session-observers.test.ts +9 -0
- package/src/server/lib/harness/acp/session-options.ts +33 -0
- package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
- package/src/server/lib/harness/acp/session-requests.ts +47 -0
- package/src/server/lib/harness/acp/session-turns.ts +20 -5
- package/src/server/lib/harness/acp/session.test-util.ts +54 -3
- package/src/server/lib/harness/acp/session.test.ts +65 -3
- package/src/server/lib/harness/acp/session.ts +79 -79
- package/src/server/lib/harness/acp/turn.test.ts +81 -0
- package/src/server/lib/harness/acp/turn.ts +54 -13
- package/src/server/lib/harness/acp/verbs.ts +12 -2
- package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
- package/src/server/lib/harness/auto-probe.server.ts +178 -0
- package/src/server/lib/harness/config.server.test.ts +1 -1
- package/src/server/lib/harness/config.server.ts +1 -1
- package/src/server/lib/harness/launch-table.ts +195 -0
- package/src/server/lib/harness/launch.test.ts +37 -0
- package/src/server/lib/harness/launch.ts +16 -116
- package/src/server/lib/harness/provider-entry.ts +32 -0
- package/src/server/lib/harness/provider-file.server.ts +3 -0
- package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
- package/src/server/lib/harness/provider-sources.server.ts +26 -2
- package/src/server/lib/harness/provider-write.server.ts +21 -32
- package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
- package/src/server/lib/harness/provider-zcode.server.ts +324 -0
- package/src/server/lib/harness/spawn.server.ts +15 -2
- package/src/server/lib/harness/update-job-store.test.ts +126 -0
- package/src/server/lib/harness/update-job-store.ts +109 -0
- package/src/server/lib/harness/update-job.server.ts +203 -0
- package/src/server/lib/harness/update-state.server.ts +15 -20
- package/src/server/lib/harness/update-worker.test.ts +153 -0
- package/src/server/lib/harness/update-worker.ts +197 -0
- package/src/server/lib/lifecycle/after-listen.ts +7 -0
- package/src/server/lib/lifecycle/paths.ts +23 -0
- package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
- package/src/server/lib/models/registry-refresh.server.ts +98 -0
- package/src/server/lib/omp/rpc/child-config.ts +5 -4
- package/src/server/lib/omp/rpc/constants.test.ts +2 -1
- package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
- package/src/server/lib/omp/rpc/manager.ts +5 -5
- package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
- package/src/server/lib/omp/rpc/session-registry.ts +14 -2
- package/src/server/lib/omp/rpc/terminal-settle.ts +53 -5
- package/src/server/lib/omp/session/delete-flow.server.ts +62 -8
- package/src/server/lib/omp/session/delete.server.ts +17 -0
- package/src/server/lib/omp/session/rewind-file.ts +39 -21
- package/src/server/lib/omp/session/sidebar-data.server.ts +6 -6
- package/src/server/lib/omp/session/transcript-copy.ts +123 -0
- package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
- package/src/server/lib/sessions/agent-token.server.ts +134 -0
- package/src/server/lib/sessions/answers.server.test.ts +33 -0
- package/src/server/lib/sessions/answers.server.ts +37 -0
- package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
- package/src/server/lib/sessions/dispatch.server.ts +128 -0
- package/src/server/lib/sessions/fork.server.test.ts +209 -0
- package/src/server/lib/sessions/fork.server.ts +304 -0
- package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
- package/src/server/lib/sessions/lifecycle.server.ts +71 -0
- package/src/server/lib/sessions/notify.server.test.ts +112 -0
- package/src/server/lib/sessions/notify.server.ts +212 -0
- package/src/server/lib/sessions/relation-types.ts +76 -0
- package/src/server/lib/sessions/relations.server.test.ts +207 -0
- package/src/server/lib/sessions/relations.server.ts +337 -0
- package/src/server/lib/sessions/resolve.server.ts +106 -0
- package/src/server/lib/sessions/schema.server.ts +82 -0
- package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
- package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
- package/src/server/lib/sessions/spawn.server.test.ts +196 -0
- package/src/server/lib/sessions/spawn.server.ts +310 -0
- package/src/server/lib/terminal/attach-replay.test.ts +2 -2
- package/src/server/lib/terminal/output.test.ts +2 -2
- package/src/server/lib/terminal/output.ts +1 -1
- package/src/server/lib/terminal/resize.test.ts +99 -0
- package/src/server/lib/terminal/runtime.server.ts +26 -6
- package/src/server/lib/terminal/send-result.test.ts +18 -1
- package/src/server/lib/terminal/send-result.ts +26 -2
- package/src/server/lib/terminal/session.server.ts +6 -6
- package/src/server/lib/usage/new-api.test.ts +92 -0
- package/src/server/lib/usage/new-api.ts +131 -0
- package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
- package/src/server/lib/usage/provider-key.ts +33 -0
- package/src/server/lib/usage/providers.server.ts +10 -3
- package/src/server/lib/usage/vendor-balance.server.ts +4 -53
- package/src/server/lib/usage/vendor-http.ts +41 -0
- package/src/server/lib/usage/window.ts +55 -0
- package/src/server/routes/agent/command.ts +14 -1
- package/src/server/routes/agent/harness-command.ts +6 -0
- package/src/server/routes/agent/new.ts +15 -0
- package/src/server/routes/chat/rewind.test.ts +147 -0
- package/src/server/routes/chat/rewind.ts +29 -7
- package/src/server/routes/chat/session.test.ts +165 -10
- package/src/server/routes/chat/session.ts +60 -7
- package/src/server/routes/harness/add-provider.test.ts +9 -1
- package/src/server/routes/harness/import-action.ts +22 -4
- package/src/server/routes/harness/import.test.ts +1 -1
- package/src/server/routes/harness/index.ts +5 -1
- package/src/server/routes/harness/root.ts +8 -49
- package/src/server/routes/harness/toggle.test.ts +20 -0
- package/src/server/routes/harness/update-status.ts +26 -0
- package/src/server/routes/harness/update.test.ts +119 -0
- package/src/server/routes/harness/update.ts +67 -113
- package/src/server/routes/harness/versions.ts +5 -1
- package/src/server/routes/sessions/answer.ts +24 -0
- package/src/server/routes/sessions/batch-delete.ts +11 -5
- package/src/server/routes/sessions/delete-acp.test.ts +227 -0
- package/src/server/routes/sessions/delete.ts +4 -2
- package/src/server/routes/sessions/fork.ts +74 -0
- package/src/server/routes/sessions/index.ts +14 -0
- package/src/server/routes/sessions/relations.ts +85 -0
- package/src/server/routes/sessions/session.ts +4 -0
- package/src/server/routes/sessions/spawn.ts +134 -0
- package/src/server/routes/settings/model-override.ts +5 -2
- package/src/server/routes/settings/provider-entry.ts +2 -2
- package/src/server/routes/settings/provider-model.ts +2 -2
- package/src/server/routes/settings/provider-models.ts +2 -2
- package/src/server/routes/settings/provider-refresh.ts +6 -4
- package/src/server/routes/settings/providers.ts +3 -1
- package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
- package/src/server/routes/terminal/ws.ts +3 -3
- package/src/shared/lib/chat/ask-form/fields.ts +76 -0
- package/src/shared/lib/chat/ask-form/index.ts +323 -0
- package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
- package/src/shared/lib/chat/ask-form/types.ts +43 -0
- package/src/shared/lib/chat/ask-form.test.ts +137 -0
- package/src/shared/lib/chat/ask-questions.test.ts +65 -1
- package/src/shared/lib/chat/ask-questions.ts +51 -145
- package/src/shared/lib/chat/ask-results.ts +198 -0
- package/src/shared/lib/chat/composer/client.ts +31 -2
- package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
- package/src/shared/lib/chat/composer/delegation.ts +206 -0
- package/src/shared/lib/chat/notice-text.ts +1 -1
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
- package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
- package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
- package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
- package/src/shared/lib/code/ansi.ts +1 -1
- package/src/shared/lib/fonts/nerd-symbols.css +4 -3
- package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
- package/src/shared/lib/harness/catalog.test.ts +1 -1
- package/src/shared/lib/harness/config-fields.test.ts +4 -0
- package/src/shared/lib/harness/config-fields.ts +19 -4
- package/src/shared/lib/harness/dialects.test.ts +8 -0
- package/src/shared/lib/harness/dialects.ts +12 -0
- package/src/shared/lib/harness/provider-facts.test.ts +59 -8
- package/src/shared/lib/harness/provider-facts.ts +46 -11
- package/src/shared/lib/harness/providers.ts +44 -1
- package/src/shared/lib/harness/rewind.ts +24 -0
- package/src/shared/lib/harness/update-job.ts +33 -0
- package/src/shared/lib/harness/update-plan.test.ts +69 -4
- package/src/shared/lib/harness/update-plan.ts +57 -9
- package/src/shared/lib/harness/updates.test.ts +22 -0
- package/src/shared/lib/harness/updates.ts +24 -1
- package/src/shared/lib/models/client.ts +10 -1
- package/src/shared/lib/omp/dialog-methods.ts +4 -3
- package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
- package/src/shared/lib/omp/session/wait-idle.ts +12 -2
- package/src/shared/lib/theme/catalog.test.ts +13 -9
- package/src/shared/lib/theme/color.test.ts +2 -2
- package/src/shared/lib/theme/color.ts +4 -4
- package/src/shared/lib/theme/css.ts +2 -0
- package/src/shared/lib/theme/ink-scale.ts +21 -1
- package/src/shared/lib/theme/theme.test.ts +26 -10
- package/src/shared/lib/ui/safe-area.test.ts +28 -0
- package/src/shared/lib/ui/safe-area.ts +42 -0
- package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
- package/src/shared/lib/workspace/terminal/input.ts +33 -0
- package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
- package/src/shared/lib/workspace/terminal/keys.ts +7 -7
- package/src/shared/types/chat.ts +1 -1
- package/src/shared/types/harness-update.ts +65 -0
- package/src/shared/types/harness.ts +30 -4
- package/src/shared/types/omp/agent.ts +19 -2
- package/src/shared/types/workspace.ts +4 -0
- package/src/test-support/fake-omp-fork.ts +16 -2
- package/src/test-support/file-explorer-render.test-util.ts +37 -0
- package/src/test-support/file-explorer.test-util.ts +20 -18
- package/src/test-support/harness-table.test-util.ts +21 -4
- package/dist/client/static/js/index-jhmg4w91.css +0 -1
- package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
- package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Running a harness probe, and the boot pass that refreshes every ON harness.
|
|
8
|
+
*
|
|
9
|
+
* Three callers need the config-aware probe: the settings route's Check status,
|
|
10
|
+
* switching a harness on, and this module's startup pass. It cannot live in a
|
|
11
|
+
* route (`routes/harness/root.ts` used to own it) because the boot clock is not
|
|
12
|
+
* a request and a route must not be the import of the startup path.
|
|
13
|
+
*
|
|
14
|
+
* **The startup pass is per PROCESS, not per module evaluation.** A `bun --hot`
|
|
15
|
+
* reload re-runs the server entry, and a probe spawns an agent process; without
|
|
16
|
+
* the `globalThis` pid guard every edit during development would start one agent
|
|
17
|
+
* per enabled harness. A real restart is a new pid and therefore a fresh pass,
|
|
18
|
+
* which is the moment the requirement names: every Kabmo restart re-checks the
|
|
19
|
+
* harnesses the user keeps ON.
|
|
20
|
+
*
|
|
21
|
+
* It runs in the BACKGROUND. A probe can take a minute (an agent that has to
|
|
22
|
+
* authenticate, a wrapper that resolves a container), and the listener is
|
|
23
|
+
* already accepting requests — boot must not wait for twelve agents to answer.
|
|
24
|
+
*
|
|
25
|
+
* Which harnesses are checked:
|
|
26
|
+
*
|
|
27
|
+
* - switched OFF (`omp_harness_disabled`) is skipped — the roster is the user's
|
|
28
|
+
* answer, and probing an agent they hid would start a process for a tab they
|
|
29
|
+
* never see;
|
|
30
|
+
* - the built-in `omp-rpc` transport is skipped: there is no agent to spawn;
|
|
31
|
+
* - a harness whose launch command is not resolvable is skipped for the same
|
|
32
|
+
* measured reason as the toggle route: the card already says "not installed",
|
|
33
|
+
* and spawning a missing binary only reports that fact again.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import type { HarnessProbe } from '@/server/lib/harness/capabilities';
|
|
37
|
+
import {
|
|
38
|
+
launchFromConfig,
|
|
39
|
+
loadHarnessConfig,
|
|
40
|
+
resolveLaunch,
|
|
41
|
+
} from '@/server/lib/harness/config.server';
|
|
42
|
+
import type { HarnessConfig } from '@/shared/lib/harness/config';
|
|
43
|
+
import { loadDisabledHarnesses } from '@/server/lib/harness/enabled.server';
|
|
44
|
+
import { blockedProbe, probeHarness } from '@/server/lib/harness/launch';
|
|
45
|
+
import { HARNESS_LAUNCH, harnessRequirementMet, type HarnessLaunch } from '@/server/lib/harness/launch-table';
|
|
46
|
+
import { resolveOmpBin } from '@/server/lib/omp/core/cli';
|
|
47
|
+
import { rememberProbe } from '@/server/lib/harness/probe-cache.server';
|
|
48
|
+
import { HARNESS_IDS, harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
49
|
+
import { harnessEnabled } from '@/shared/lib/harness/enabled';
|
|
50
|
+
|
|
51
|
+
declare global {
|
|
52
|
+
// eslint-disable-next-line no-var
|
|
53
|
+
var __kabmoHarnessAutoProbePid: number | undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Is a launch command first-token resolvable? The omp binary has its own
|
|
58
|
+
* resolver (KABMO_OMP_BIN, then PATH) and is never "missing" through PATH alone.
|
|
59
|
+
*
|
|
60
|
+
* The USER's command override decides this, not the build's table: a harness
|
|
61
|
+
* whose binary lives behind a wrapper, a container (`docker run … agy acp`) or an
|
|
62
|
+
* absolute path read as "not installed" and could not even be switched on, while
|
|
63
|
+
* a spawn of that same configured command worked.
|
|
64
|
+
*/
|
|
65
|
+
export function commandAvailable(id: HarnessId, config?: HarnessConfig): boolean {
|
|
66
|
+
if (id === 'omp-acp') return Boolean(resolveOmpBin());
|
|
67
|
+
let launch: HarnessLaunch | undefined = HARNESS_LAUNCH[id];
|
|
68
|
+
if (config) {
|
|
69
|
+
try {
|
|
70
|
+
const configured = launchFromConfig(id, config);
|
|
71
|
+
if (configured) launch = configured;
|
|
72
|
+
} catch {
|
|
73
|
+
// An unusable env line is reported by the probe; availability falls back
|
|
74
|
+
// to the build's table rather than claiming "not installed".
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const [binary] = launch?.command ?? [];
|
|
78
|
+
if (!binary) return false;
|
|
79
|
+
// An adapter can need a binary it SPAWNS rather than execs: the zcode bridge
|
|
80
|
+
// starts `zcode app-server --stdio`, so `npx` being present says nothing.
|
|
81
|
+
if (!harnessRequirementMet(launch?.requires, launch?.env)) return false;
|
|
82
|
+
if (binary === 'npx') return Boolean(Bun.which('npx') ?? Bun.which('node'));
|
|
83
|
+
return Boolean(Bun.which(binary));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Probe a harness the way a SPAWN would launch it: the user's command and env
|
|
88
|
+
* override are part of what is being measured.
|
|
89
|
+
*
|
|
90
|
+
* Without this, a harness that only works with its configured env — `CODEX_HOME`,
|
|
91
|
+
* a provider base URL, a wrapper that logs in — probed as "Authentication
|
|
92
|
+
* required" in Settings while its chats ran fine. A launch line that cannot even
|
|
93
|
+
* be resolved (an invalid env line) answers a `blocked` record instead of a 500.
|
|
94
|
+
*/
|
|
95
|
+
export async function probeWithConfig(id: HarnessId, cwd: string): Promise<HarnessProbe> {
|
|
96
|
+
try {
|
|
97
|
+
const configured = await loadHarnessConfig(id);
|
|
98
|
+
return await probeHarness(id, cwd, resolveLaunch(id, configured));
|
|
99
|
+
} catch (cause) {
|
|
100
|
+
return blockedProbe(id, cause instanceof Error ? cause.message : String(cause));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Seams for the tests: the real catalog, availability and probe by default. */
|
|
105
|
+
export interface AutoProbeOptions {
|
|
106
|
+
cwd?: string;
|
|
107
|
+
ids?: readonly HarnessId[];
|
|
108
|
+
available?: (id: HarnessId, config: HarnessConfig) => boolean;
|
|
109
|
+
probe?: (id: HarnessId, cwd: string) => Promise<HarnessProbe>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The harnesses the user keeps ON that this machine can actually launch. */
|
|
113
|
+
export async function autoProbeTargets(
|
|
114
|
+
options: Pick<AutoProbeOptions, 'ids' | 'available'> = {},
|
|
115
|
+
): Promise<HarnessId[]> {
|
|
116
|
+
const ids = options.ids ?? HARNESS_IDS;
|
|
117
|
+
const available = options.available ?? commandAvailable;
|
|
118
|
+
const disabled = await loadDisabledHarnesses();
|
|
119
|
+
const targets: HarnessId[] = [];
|
|
120
|
+
for (const id of ids) {
|
|
121
|
+
if (harnessDescriptor(id)?.builtIn) continue;
|
|
122
|
+
if (!harnessEnabled(id, disabled)) continue;
|
|
123
|
+
const config = await loadHarnessConfig(id);
|
|
124
|
+
if (!available(id, config)) continue;
|
|
125
|
+
targets.push(id);
|
|
126
|
+
}
|
|
127
|
+
return targets;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** What one boot pass did, for the log line and for the tests. */
|
|
131
|
+
export interface AutoProbeOutcome {
|
|
132
|
+
probed: HarnessId[];
|
|
133
|
+
failed: Array<{ id: HarnessId; error: string }>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Probe every target, one at a time, and write each answer to the cache.
|
|
138
|
+
*
|
|
139
|
+
* Sequential on purpose: these are agent processes, and a boot that starts one
|
|
140
|
+
* per installed harness at once competes with the chat the user just opened. A
|
|
141
|
+
* failure on one harness is recorded and the pass continues — the others still
|
|
142
|
+
* deserve their answer.
|
|
143
|
+
*/
|
|
144
|
+
export async function runAutoProbe(options: AutoProbeOptions = {}): Promise<AutoProbeOutcome> {
|
|
145
|
+
const cwd = options.cwd ?? process.cwd();
|
|
146
|
+
const probe = options.probe ?? probeWithConfig;
|
|
147
|
+
const targets = await autoProbeTargets(options);
|
|
148
|
+
const outcome: AutoProbeOutcome = { probed: [], failed: [] };
|
|
149
|
+
for (const id of targets) {
|
|
150
|
+
try {
|
|
151
|
+
await rememberProbe(id, await probe(id, cwd));
|
|
152
|
+
outcome.probed.push(id);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
outcome.failed.push({ id, error: error instanceof Error ? error.message : String(error) });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return outcome;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Start the boot pass. Idempotent within one process — a `bun --hot` reload must
|
|
162
|
+
* not spawn the agents again — and never awaited, because boot does not wait for
|
|
163
|
+
* an agent to answer.
|
|
164
|
+
*/
|
|
165
|
+
export function startHarnessAutoProbe(): void {
|
|
166
|
+
if (globalThis.__kabmoHarnessAutoProbePid === process.pid) return;
|
|
167
|
+
globalThis.__kabmoHarnessAutoProbePid = process.pid;
|
|
168
|
+
void runAutoProbe()
|
|
169
|
+
.then(({ probed, failed }) => {
|
|
170
|
+
if (probed.length > 0) console.log(`[harness] probed on boot: ${probed.join(', ')}`);
|
|
171
|
+
for (const failure of failed) {
|
|
172
|
+
console.error(`[harness] ${failure.id}: boot probe failed — ${failure.error}`);
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
.catch((error) => {
|
|
176
|
+
console.error('[harness] boot probe skipped:', error);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
@@ -21,7 +21,7 @@ import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:tes
|
|
|
21
21
|
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
22
22
|
import { EMPTY_HARNESS_CONFIG, parseHarnessConfig } from '@/shared/lib/harness/config';
|
|
23
23
|
import { loadHarnessConfig, resolveLaunch, saveHarnessConfig } from '@/server/lib/harness/config.server';
|
|
24
|
-
import { HARNESS_LAUNCH } from '@/server/lib/harness/launch';
|
|
24
|
+
import { HARNESS_LAUNCH } from '@/server/lib/harness/launch-table';
|
|
25
25
|
|
|
26
26
|
beforeEach(async () => {
|
|
27
27
|
await isolateDb();
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { getDb } from '@/server/db.server';
|
|
18
18
|
import { readSettingsJson, writeSettingsJson } from '@/server/lib/db/settings-store';
|
|
19
|
-
import { HARNESS_LAUNCH, type HarnessLaunch } from '@/server/lib/harness/launch';
|
|
19
|
+
import { HARNESS_LAUNCH, type HarnessLaunch } from '@/server/lib/harness/launch-table';
|
|
20
20
|
import {
|
|
21
21
|
harnessConfigKey,
|
|
22
22
|
isHarnessConfigured,
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The launch table, and the extra indirection a launch line can need.
|
|
8
|
+
*
|
|
9
|
+
* Split from `launch.ts` so the table (data) and the probe (spawns one agent)
|
|
10
|
+
* stay under the file ceiling. `commandAvailable` reads this table; a probe
|
|
11
|
+
* reads it too, and both must agree about a bridge like `zcode`, whose command
|
|
12
|
+
* is `npx` but whose chat needs a separate runtime binary.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { existsSync } from 'node:fs';
|
|
16
|
+
import { homedir } from 'node:os';
|
|
17
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
18
|
+
|
|
19
|
+
/** One harness's launch configuration. */
|
|
20
|
+
export interface HarnessLaunch {
|
|
21
|
+
id: HarnessId;
|
|
22
|
+
command: string[];
|
|
23
|
+
/** Extra env the adapter needs (a wrapper path, a log dir, …). */
|
|
24
|
+
env?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* A binary the launch line SPAWNS but does not exec itself. The `zcode`
|
|
27
|
+
* bridge starts `zcode app-server --stdio`, so `npx` being present says
|
|
28
|
+
* nothing about whether a chat can run.
|
|
29
|
+
*/
|
|
30
|
+
requires?: HarnessRequirement;
|
|
31
|
+
/** Where the CLI installs from, for the settings page's install hint. */
|
|
32
|
+
install?: string;
|
|
33
|
+
/** What the agent looked like when measured on this machine. Display copy
|
|
34
|
+
* only — every panel reads the LIVE probe, never this. */
|
|
35
|
+
note: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** An indirection the launcher resolves on its own (the app-server case). */
|
|
39
|
+
export interface HarnessRequirement {
|
|
40
|
+
/** Binary name on PATH. */
|
|
41
|
+
binary: string;
|
|
42
|
+
/** Env var that overrides the lookup with a path or a name. */
|
|
43
|
+
env?: string;
|
|
44
|
+
/** App-bundle paths that also satisfy it. */
|
|
45
|
+
bundled?: readonly string[];
|
|
46
|
+
/** What a missing one is called in the card. */
|
|
47
|
+
label: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A configured path, a `~`-relative path, or a name on PATH. */
|
|
51
|
+
function resolvable(value: string): boolean {
|
|
52
|
+
const trimmed = value.trim();
|
|
53
|
+
if (!trimmed) return false;
|
|
54
|
+
if (trimmed.includes('/') || trimmed.includes('\\')) {
|
|
55
|
+
return existsSync(trimmed.replace(/^~(?=[/\\])/, homedir()));
|
|
56
|
+
}
|
|
57
|
+
return Boolean(Bun.which(trimmed));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Is the indirection this launch line needs actually present?
|
|
62
|
+
*
|
|
63
|
+
* An explicit `ZCODE_BIN` is authoritative (the bridge uses it verbatim), so a
|
|
64
|
+
* stale path DOES NOT fall back to PATH: claiming "available" would hide the
|
|
65
|
+
* broken setting behind a working install. With no override, PATH and the
|
|
66
|
+
* desktop bundle both count — those are the bridge's own resolution order.
|
|
67
|
+
*/
|
|
68
|
+
export function harnessRequirementMet(
|
|
69
|
+
requirement: HarnessRequirement | undefined,
|
|
70
|
+
env?: Record<string, string>,
|
|
71
|
+
): boolean {
|
|
72
|
+
if (!requirement) return true;
|
|
73
|
+
// A per-harness override wins, then the server's own environment: the spawn
|
|
74
|
+
// merges both, and `ZCODE_BIN` is commonly exported before Kabmo starts.
|
|
75
|
+
const explicit = requirement.env
|
|
76
|
+
? (env?.[requirement.env] ?? Bun.env[requirement.env] ?? '').trim()
|
|
77
|
+
: '';
|
|
78
|
+
if (explicit) return resolvable(explicit);
|
|
79
|
+
if (Bun.which(requirement.binary)) return true;
|
|
80
|
+
return (requirement.bundled ?? []).some(resolvable);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The launch table. A harness whose binary is missing reports the failure from
|
|
85
|
+
* `session/new`/spawn and the tab shows it with the install hint below.
|
|
86
|
+
*/
|
|
87
|
+
export const HARNESS_LAUNCH: Readonly<Partial<Record<HarnessId, HarnessLaunch>>> = {
|
|
88
|
+
'omp-acp': {
|
|
89
|
+
id: 'omp-acp',
|
|
90
|
+
command: ['omp', 'acp'],
|
|
91
|
+
install: 'curl -fsSL https://omp.sh/install | sh',
|
|
92
|
+
note: 'fastest handshake measured (0.08 s init, 0.22 s session/new); 221 models',
|
|
93
|
+
},
|
|
94
|
+
claude: {
|
|
95
|
+
id: 'claude',
|
|
96
|
+
command: ['npx', '-y', '@agentclientprotocol/claude-agent-acp@0.100.0'],
|
|
97
|
+
install: 'npm i -g @agentclientprotocol/claude-agent-acp',
|
|
98
|
+
note: 'mode 5 · model 5 · effort 6 · fast · ultracode; needs a Claude login',
|
|
99
|
+
},
|
|
100
|
+
codex: {
|
|
101
|
+
id: 'codex',
|
|
102
|
+
command: ['npx', '-y', '@agentclientprotocol/codex-acp@2.5.0'],
|
|
103
|
+
install: 'npm i -g @agentclientprotocol/codex-acp',
|
|
104
|
+
note: 'bridges `codex app-server`; set CODEX_PATH when the bundled binary cannot run',
|
|
105
|
+
},
|
|
106
|
+
opencode: {
|
|
107
|
+
id: 'opencode',
|
|
108
|
+
command: ['opencode', 'acp'],
|
|
109
|
+
install: 'curl -fsSL https://opencode.ai/install | bash',
|
|
110
|
+
note: 'plugin activation can gate session/new for ~80 s; Kabmo waits it out. Writes plugin logs to stdout',
|
|
111
|
+
},
|
|
112
|
+
dsh: {
|
|
113
|
+
id: 'dsh',
|
|
114
|
+
command: ['dsh', '--profile', 'acp'],
|
|
115
|
+
install: 'npm i -g @deepseek-ai/dsh',
|
|
116
|
+
note: 'no loadSession: history replays from Kabmo\u2019s own stored frames',
|
|
117
|
+
},
|
|
118
|
+
// `cmd` is the bin npm installs; the package also ships `cmdc` (Windows) and the
|
|
119
|
+
// long `command-code` / `commandcode` aliases. Measured: 0.77 s handshake, 43 ms
|
|
120
|
+
// session/new, 96 models · 4 thought levels, and list/resume/close advertised.
|
|
121
|
+
// Todos are off by default (`cmd mods enable todos -g`, then restart).
|
|
122
|
+
'command-code': {
|
|
123
|
+
id: 'command-code',
|
|
124
|
+
command: ['cmd', 'acp'],
|
|
125
|
+
install: 'npm i -g command-code',
|
|
126
|
+
note: 'needs `cmd login`; 96 models · 4 thought levels; todos off by default',
|
|
127
|
+
},
|
|
128
|
+
// Antigravity CLI (`agy`) replaced Gemini CLI, which Google deprecated. Its ACP
|
|
129
|
+
// server is `agy acp`, and it serves one project per process.
|
|
130
|
+
antigravity: {
|
|
131
|
+
id: 'antigravity',
|
|
132
|
+
command: ['agy', 'acp'],
|
|
133
|
+
install: 'download agy_cli_<os>_<arch>.tar.gz from github.com/google-antigravity/antigravity-cli/releases',
|
|
134
|
+
note: 'ACP since 1.5; sign in once (`agy acp --login`) or authenticate with a Gemini API key; runs under Docker on Linux',
|
|
135
|
+
},
|
|
136
|
+
minimax: {
|
|
137
|
+
id: 'minimax',
|
|
138
|
+
command: ['mcode', 'acp'],
|
|
139
|
+
install: 'npm i -g @minimax-ai/code',
|
|
140
|
+
note: 'needs `mcode login`; fork/resume/close/list all advertised',
|
|
141
|
+
},
|
|
142
|
+
pi: {
|
|
143
|
+
id: 'pi',
|
|
144
|
+
command: ['npx', '-y', 'pi-acp@0.0.34'],
|
|
145
|
+
install: 'npm i -g @earendil-works/pi-coding-agent pi-acp',
|
|
146
|
+
note: 'shells out to a `pi` binary on PATH; needs `pi auth` before a turn succeeds',
|
|
147
|
+
},
|
|
148
|
+
qwen: {
|
|
149
|
+
id: 'qwen',
|
|
150
|
+
command: ['qwen', '--acp'],
|
|
151
|
+
install: 'npm i -g @qwen-code/qwen-code',
|
|
152
|
+
note: 'list/resume; needs `qwen` auth',
|
|
153
|
+
},
|
|
154
|
+
kimi: {
|
|
155
|
+
id: 'kimi',
|
|
156
|
+
command: ['kimi', 'acp'],
|
|
157
|
+
install: 'curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash',
|
|
158
|
+
note: 'ACP needs an onboarded provider (config.toml) or a signed-in account',
|
|
159
|
+
},
|
|
160
|
+
cursor: {
|
|
161
|
+
id: 'cursor',
|
|
162
|
+
command: ['cursor-agent', 'acp'],
|
|
163
|
+
install: 'registry binary (cursor-agent)',
|
|
164
|
+
note: 'registry shape; no CLI probe run here',
|
|
165
|
+
},
|
|
166
|
+
// ZCode's ACP surface is a BRIDGE, not a subcommand: the vendor CLI ships no
|
|
167
|
+
// `acp` verb, and `zcode-acp-server` spawns `zcode app-server --stdio` and
|
|
168
|
+
// translates its events. The bridge resolves the CLI itself (`ZCODE_BIN` →
|
|
169
|
+
// `zcode` on PATH → the desktop app bundle), so the only requirement is a
|
|
170
|
+
// signed-in ZCode install; credentials stay in `~/.zcode`.
|
|
171
|
+
// Measured through Kabmo's own ACP client on 0.82.3: agentInfo
|
|
172
|
+
// `zcode-acp-server` 0.82.3, `session/new` in ~1 s, **1 model · 3 thought
|
|
173
|
+
// levels · 5 modes**, `list`/`resume`/`fork` advertised, steering supported.
|
|
174
|
+
zcode: {
|
|
175
|
+
id: 'zcode',
|
|
176
|
+
command: ['npx', '-y', 'zcode-acp-server@0.82.3'],
|
|
177
|
+
// The bridge spawns `zcode app-server --stdio`; without that binary the
|
|
178
|
+
// probe still answers (its model list comes from files) and every turn
|
|
179
|
+
// exits with "zcode not found". Check the thing a chat actually needs.
|
|
180
|
+
requires: {
|
|
181
|
+
binary: 'zcode',
|
|
182
|
+
env: 'ZCODE_BIN',
|
|
183
|
+
bundled: [
|
|
184
|
+
'/Applications/ZCode.app/Contents/Resources/glm/zcode.cjs',
|
|
185
|
+
'~/Applications/ZCode.app/Contents/Resources/glm/zcode.cjs',
|
|
186
|
+
'/opt/ZCode/resources/glm/zcode.cjs',
|
|
187
|
+
'/usr/share/zcode/resources/glm/zcode.cjs',
|
|
188
|
+
...(Bun.env.LOCALAPPDATA ? [`${Bun.env.LOCALAPPDATA}/Programs/ZCode/resources/glm/zcode.cjs`] : []),
|
|
189
|
+
],
|
|
190
|
+
label: 'a ZCode runtime (the desktop app, or `npm i -g zcode-app-cli`)',
|
|
191
|
+
},
|
|
192
|
+
install: 'npm i -g zcode-acp-server zcode-app-cli # the app-server runtime (or install the ZCode desktop app)',
|
|
193
|
+
note: 'bridges `zcode app-server --stdio`; measured 1 model · 3 thought levels · 5 modes, list/resume/fork + steering; needs a ZCode runtime — the desktop app, or `zcode-app-cli` on PATH (`ZCODE_BIN` for a custom install). Custom providers go in ~/.zcode/v2/provider_config.json; the bridge lists only selectable ones',
|
|
194
|
+
},
|
|
195
|
+
};
|
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { describe, expect, test } from 'bun:test';
|
|
18
|
+
import fs from 'node:fs';
|
|
19
|
+
import os from 'node:os';
|
|
18
20
|
import { join } from 'node:path';
|
|
19
21
|
import { blockedProbe, capabilitiesFrom, configByCategory, probeHarness, selectValues, sessionLaunchCommand } from '@/server/lib/harness/launch';
|
|
22
|
+
import { harnessRequirementMet } from '@/server/lib/harness/launch-table';
|
|
20
23
|
import type { AcpInitializeResult, AcpConfigOption } from '@/server/lib/harness/acp/protocol';
|
|
21
24
|
|
|
22
25
|
const ompInit: AcpInitializeResult = {
|
|
@@ -181,3 +184,37 @@ describe('probeHarness launch override', () => {
|
|
|
181
184
|
expect(probe.harness).toBe('pi');
|
|
182
185
|
});
|
|
183
186
|
});
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A launch line can depend on a binary it does NOT exec.
|
|
190
|
+
*
|
|
191
|
+
* The zcode bridge starts `zcode app-server --stdio`; the probe still answers
|
|
192
|
+
* (its models come from files), so `npx` being present painted the tab ready
|
|
193
|
+
* while every turn exited with "zcode not found". These cases pin the
|
|
194
|
+
* resolution order the bridge itself uses.
|
|
195
|
+
*/
|
|
196
|
+
describe('harnessRequirementMet', () => {
|
|
197
|
+
const dir = fs.mkdtempSync(join(os.tmpdir(), 'kabmo-require-'));
|
|
198
|
+
const present = join(dir, 'zcode.cjs');
|
|
199
|
+
fs.writeFileSync(present, '');
|
|
200
|
+
|
|
201
|
+
test('no requirement means nothing to check', () => {
|
|
202
|
+
expect(harnessRequirementMet(undefined)).toBe(true);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test('an explicit env path is authoritative, including when it is wrong', () => {
|
|
206
|
+
const requirement = { binary: 'definitely-not-zcode-xyz', env: 'ZCODE_BIN', label: 'runtime' };
|
|
207
|
+
expect(harnessRequirementMet(requirement, { ZCODE_BIN: present })).toBe(true);
|
|
208
|
+
// A stale override must NOT fall back to PATH: the bridge uses it verbatim.
|
|
209
|
+
expect(harnessRequirementMet(requirement, { ZCODE_BIN: join(dir, 'missing.cjs') })).toBe(false);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('a bundled app path counts when PATH has nothing', () => {
|
|
213
|
+
const requirement = { binary: 'definitely-not-zcode-xyz', bundled: [present], label: 'runtime' };
|
|
214
|
+
expect(harnessRequirementMet(requirement)).toBe(true);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('a binary that is neither on PATH nor bundled is missing', () => {
|
|
218
|
+
expect(harnessRequirementMet({ binary: 'definitely-not-zcode-xyz', label: 'runtime' })).toBe(false);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
@@ -16,127 +16,21 @@
|
|
|
16
16
|
* capability flags, then disposes. That is deliberately not done for all
|
|
17
17
|
* harnesses at once: seven agents cost ~6 s and seven processes, which is why
|
|
18
18
|
* the sidebar reads Kabmo's own index and this runs on an explicit action.
|
|
19
|
+
*
|
|
20
|
+
* The launch TABLE itself lives in `launch-table.ts` so this module is the probe
|
|
21
|
+
* and the session argv, both under the file ceiling.
|
|
19
22
|
*/
|
|
20
23
|
|
|
21
24
|
import { AcpProcess } from '@/server/lib/harness/acp/client';
|
|
25
|
+
import { withGatewayCompatibility } from '@/server/lib/harness/acp/gateway-env';
|
|
26
|
+
import { newSessionAfterActivation } from '@/server/lib/harness/acp/activation';
|
|
22
27
|
import type { AcpConfigOption, AcpInitializeResult } from '@/server/lib/harness/acp/protocol';
|
|
23
28
|
import { acpOptionValues } from '@/server/lib/harness/acp/protocol';
|
|
24
29
|
import { UNPROBED_CAPABILITIES, type HarnessCapabilities, type HarnessProbe } from '@/server/lib/harness/capabilities';
|
|
30
|
+
import { HARNESS_LAUNCH, type HarnessLaunch } from '@/server/lib/harness/launch-table';
|
|
25
31
|
import { kabmoExtensionArgs } from '@/server/lib/omp/extensions/locator';
|
|
26
32
|
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
27
33
|
|
|
28
|
-
/** One harness's launch configuration. */
|
|
29
|
-
export interface HarnessLaunch {
|
|
30
|
-
id: HarnessId;
|
|
31
|
-
command: string[];
|
|
32
|
-
/** Extra env the adapter needs (a wrapper path, a log dir, …). */
|
|
33
|
-
env?: Record<string, string>;
|
|
34
|
-
/** Where the CLI installs from, for the settings page's install hint. */
|
|
35
|
-
install?: string;
|
|
36
|
-
/** What the agent looked like when measured on this machine. Display copy
|
|
37
|
-
* only — every panel reads the LIVE probe, never this. */
|
|
38
|
-
note: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The launch table. A harness whose binary is missing reports the failure from
|
|
43
|
-
* `session/new`/spawn and the tab shows it with the install hint below.
|
|
44
|
-
*/
|
|
45
|
-
export const HARNESS_LAUNCH: Readonly<Partial<Record<HarnessId, HarnessLaunch>>> = {
|
|
46
|
-
'omp-acp': {
|
|
47
|
-
id: 'omp-acp',
|
|
48
|
-
command: ['omp', 'acp'],
|
|
49
|
-
install: 'curl -fsSL https://omp.sh/install | sh',
|
|
50
|
-
note: 'fastest handshake measured (0.08 s init, 0.22 s session/new); 221 models',
|
|
51
|
-
},
|
|
52
|
-
claude: {
|
|
53
|
-
id: 'claude',
|
|
54
|
-
command: ['npx', '-y', '@agentclientprotocol/claude-agent-acp@0.100.0'],
|
|
55
|
-
install: 'npm i -g @agentclientprotocol/claude-agent-acp',
|
|
56
|
-
note: 'mode 5 · model 5 · effort 6 · fast · ultracode; needs a Claude login',
|
|
57
|
-
},
|
|
58
|
-
codex: {
|
|
59
|
-
id: 'codex',
|
|
60
|
-
command: ['npx', '-y', '@agentclientprotocol/codex-acp@2.5.0'],
|
|
61
|
-
install: 'npm i -g @agentclientprotocol/codex-acp',
|
|
62
|
-
note: 'bridges `codex app-server`; set CODEX_PATH when the bundled binary cannot run',
|
|
63
|
-
},
|
|
64
|
-
opencode: {
|
|
65
|
-
id: 'opencode',
|
|
66
|
-
command: ['opencode', 'acp'],
|
|
67
|
-
install: 'curl -fsSL https://opencode.ai/install | bash',
|
|
68
|
-
note: 'slowest start measured (2.3 s, plugin boot) and writes plugin logs to stdout',
|
|
69
|
-
},
|
|
70
|
-
dsh: {
|
|
71
|
-
id: 'dsh',
|
|
72
|
-
command: ['dsh', '--profile', 'acp'],
|
|
73
|
-
install: 'npm i -g @deepseek-ai/dsh',
|
|
74
|
-
note: 'no loadSession: history replays from Kabmo\u2019s own stored frames',
|
|
75
|
-
},
|
|
76
|
-
// `cmd` is the bin npm installs; the package also ships `cmdc` (Windows) and the
|
|
77
|
-
// long `command-code` / `commandcode` aliases. Measured: 0.77 s handshake, 43 ms
|
|
78
|
-
// session/new, 96 models · 4 thought levels, and list/resume/close advertised.
|
|
79
|
-
// Todos are off by default (`cmd mods enable todos -g`, then restart).
|
|
80
|
-
'command-code': {
|
|
81
|
-
id: 'command-code',
|
|
82
|
-
command: ['cmd', 'acp'],
|
|
83
|
-
install: 'npm i -g command-code',
|
|
84
|
-
note: 'needs `cmd login`; 96 models · 4 thought levels; todos off by default',
|
|
85
|
-
},
|
|
86
|
-
// Antigravity CLI (`agy`) replaced Gemini CLI, which Google deprecated. Its ACP
|
|
87
|
-
// server is `agy acp`, and it serves one project per process.
|
|
88
|
-
antigravity: {
|
|
89
|
-
id: 'antigravity',
|
|
90
|
-
command: ['agy', 'acp'],
|
|
91
|
-
install: 'download agy_cli_<os>_<arch>.tar.gz from github.com/google-antigravity/antigravity-cli/releases',
|
|
92
|
-
note: 'ACP since 1.5; sign in once (`agy acp --login`) or authenticate with a Gemini API key; runs under Docker on Linux',
|
|
93
|
-
},
|
|
94
|
-
minimax: {
|
|
95
|
-
id: 'minimax',
|
|
96
|
-
command: ['mcode', 'acp'],
|
|
97
|
-
install: 'npm i -g @minimax-ai/code',
|
|
98
|
-
note: 'needs `mcode login`; fork/resume/close/list all advertised',
|
|
99
|
-
},
|
|
100
|
-
pi: {
|
|
101
|
-
id: 'pi',
|
|
102
|
-
command: ['npx', '-y', 'pi-acp@0.0.34'],
|
|
103
|
-
install: 'npm i -g @earendil-works/pi-coding-agent pi-acp',
|
|
104
|
-
note: 'shells out to a `pi` binary on PATH; needs `pi auth` before a turn succeeds',
|
|
105
|
-
},
|
|
106
|
-
qwen: {
|
|
107
|
-
id: 'qwen',
|
|
108
|
-
command: ['qwen', '--acp'],
|
|
109
|
-
install: 'npm i -g @qwen-code/qwen-code',
|
|
110
|
-
note: 'list/resume; needs `qwen` auth',
|
|
111
|
-
},
|
|
112
|
-
kimi: {
|
|
113
|
-
id: 'kimi',
|
|
114
|
-
command: ['kimi', 'acp'],
|
|
115
|
-
install: 'curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash',
|
|
116
|
-
note: 'ACP needs an onboarded provider (config.toml) or a signed-in account',
|
|
117
|
-
},
|
|
118
|
-
cursor: {
|
|
119
|
-
id: 'cursor',
|
|
120
|
-
command: ['cursor-agent', 'acp'],
|
|
121
|
-
install: 'registry binary (cursor-agent)',
|
|
122
|
-
note: 'registry shape; no CLI probe run here',
|
|
123
|
-
},
|
|
124
|
-
// ZCode's ACP surface is a BRIDGE, not a subcommand: the vendor CLI ships no
|
|
125
|
-
// `acp` verb, and `zcode-acp-server` spawns `zcode app-server --stdio` and
|
|
126
|
-
// translates its events. The bridge resolves the CLI itself (`ZCODE_BIN` →
|
|
127
|
-
// `zcode` on PATH → the desktop app bundle), so the only requirement is a
|
|
128
|
-
// signed-in ZCode install; credentials stay in `~/.zcode`.
|
|
129
|
-
// Measured through Kabmo's own ACP client on 0.82.3: agentInfo
|
|
130
|
-
// `zcode-acp-server` 0.82.3, `session/new` in ~1 s, **1 model · 3 thought
|
|
131
|
-
// levels · 5 modes**, `list`/`resume`/`fork` advertised, steering supported.
|
|
132
|
-
zcode: {
|
|
133
|
-
id: 'zcode',
|
|
134
|
-
command: ['npx', '-y', 'zcode-acp-server@0.82.3'],
|
|
135
|
-
install: 'npm i -g zcode-acp-server',
|
|
136
|
-
note: 'bridges `zcode app-server --stdio`; measured 1 model · 3 thought levels · 5 modes, list/resume/fork + steering; needs ZCode credentials in ~/.zcode, `ZCODE_BIN` for a custom install',
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
|
|
140
34
|
/**
|
|
141
35
|
* The argv a SESSION spawns with, as opposed to the one a probe runs.
|
|
142
36
|
*
|
|
@@ -248,12 +142,13 @@ export async function probeHarness(
|
|
|
248
142
|
let proc: AcpProcess | null = null;
|
|
249
143
|
/** `agentInfo` from a handshake that succeeded before a later step failed. */
|
|
250
144
|
let agent: AcpInitializeResult['agentInfo'] | undefined;
|
|
145
|
+
const env = withGatewayCompatibility(id, launch.env);
|
|
251
146
|
|
|
252
147
|
try {
|
|
253
|
-
|
|
148
|
+
const agentProcess = new AcpProcess({
|
|
254
149
|
command: launch.command,
|
|
255
150
|
cwd,
|
|
256
|
-
...(
|
|
151
|
+
...(env ? { env } : {}),
|
|
257
152
|
onStderr: (line) => {
|
|
258
153
|
stderrTail = `${stderrTail}${line}\n`.slice(-2_000);
|
|
259
154
|
},
|
|
@@ -268,12 +163,17 @@ export async function probeHarness(
|
|
|
268
163
|
if (update.sessionUpdate === 'plan') observed.plan = true;
|
|
269
164
|
},
|
|
270
165
|
});
|
|
271
|
-
|
|
166
|
+
proc = agentProcess;
|
|
167
|
+
const init = await agentProcess.initialize();
|
|
272
168
|
// Kept for the failure path below: an agent that answers `initialize` and
|
|
273
169
|
// then refuses `session/new` ("Authentication required") still told us who
|
|
274
170
|
// it is, and the card can name it beside the refusal.
|
|
275
171
|
agent = init.agentInfo;
|
|
276
|
-
|
|
172
|
+
// opencode gates `session/new` on its own plugin activation; a probe that
|
|
173
|
+
// read the five-second refusal as final reported a booting agent as blocked.
|
|
174
|
+
const session = await newSessionAfterActivation(id, cwd, (dir, timeoutMs) =>
|
|
175
|
+
agentProcess.newSession(dir, timeoutMs),
|
|
176
|
+
);
|
|
277
177
|
const options = session.configOptions ?? [];
|
|
278
178
|
return {
|
|
279
179
|
harness: id,
|
|
@@ -74,6 +74,38 @@ function requireDialect(kind: ProviderRegistryKind, draft: ProviderDraft, target
|
|
|
74
74
|
return dialect;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* The fields of an EXISTING entry that the import must not overwrite.
|
|
79
|
+
*
|
|
80
|
+
* A stored credential is the one that matters: an import brings an endpoint, and
|
|
81
|
+
* replacing a key the user set by hand is not what asking to copy a provider
|
|
82
|
+
* meant. `npm`/`type`/`wire_api` (the dialect) are kept too — they describe how
|
|
83
|
+
* that provider already works, and the source's dialect is a guess about a
|
|
84
|
+
* different agent.
|
|
85
|
+
*
|
|
86
|
+
* Lives here with the entry builders it mirrors, so the writer is read-modify-
|
|
87
|
+
* write and this module is "what does an entry look like".
|
|
88
|
+
*/
|
|
89
|
+
export function pickExisting(existing: Record<string, unknown>, incoming: Record<string, unknown>): Record<string, unknown> {
|
|
90
|
+
const keep: Record<string, unknown> = {};
|
|
91
|
+
const scalarKeys = ['npm', 'type', 'wire_api', 'api', 'name'];
|
|
92
|
+
for (const key of scalarKeys) {
|
|
93
|
+
if (existing[key] !== undefined && incoming[key] !== undefined) keep[key] = existing[key];
|
|
94
|
+
}
|
|
95
|
+
// Credentials, in each format's spelling: a top-level apiKey/api_key, or one
|
|
96
|
+
// nested inside opencode's `options`.
|
|
97
|
+
if (typeof existing.apiKey === 'string' && existing.apiKey) keep.apiKey = existing.apiKey;
|
|
98
|
+
if (typeof existing.api_key === 'string' && existing.api_key) keep.api_key = existing.api_key;
|
|
99
|
+
const existingOptions = asRecord(existing.options);
|
|
100
|
+
const incomingOptions = asRecord(incoming.options);
|
|
101
|
+
if (Object.keys(incomingOptions).length > 0) {
|
|
102
|
+
// `options` is merged key by key, so an endpoint arrives while a stored key
|
|
103
|
+
// and any hand-written option stay.
|
|
104
|
+
keep.options = { ...incomingOptions, ...existingOptions };
|
|
105
|
+
}
|
|
106
|
+
return keep;
|
|
107
|
+
}
|
|
108
|
+
|
|
77
109
|
/** kimi requires a context window per alias; 128k is the documented fallback. */
|
|
78
110
|
const DEFAULT_CONTEXT_WINDOW = 128_000;
|
|
79
111
|
|
|
@@ -30,6 +30,9 @@ export function serialise(kind: ProviderRegistryKind, doc: Record<string, unknow
|
|
|
30
30
|
case 'yaml-providers': return YAML.stringify(doc);
|
|
31
31
|
case 'toml-model-providers':
|
|
32
32
|
case 'toml-providers': return `${stringifyToml(doc)}\n`;
|
|
33
|
+
// The desktop's own writer emits two-space JSON with NO trailing newline;
|
|
34
|
+
// a non-canonical file is read fine but rewritten on the app's next save.
|
|
35
|
+
case 'zcode-provider-rules': return JSON.stringify(doc, null, 2);
|
|
33
36
|
default: return `${JSON.stringify(doc, null, 2)}\n`;
|
|
34
37
|
}
|
|
35
38
|
}
|