@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
|
@@ -73,6 +73,8 @@ const SOURCE_DIALECTS: Readonly<Record<string, CanonicalProtocol>> = {
|
|
|
73
73
|
chat: 'openai-chat',
|
|
74
74
|
'chat-completions': 'openai-chat',
|
|
75
75
|
chatcompletions: 'openai-chat',
|
|
76
|
+
'openai-chat-completions': 'openai-chat',
|
|
77
|
+
'openaichatcompletions': 'openai-chat',
|
|
76
78
|
'ai-sdk-openai-compatible': 'openai-chat',
|
|
77
79
|
'opencode-ai-providers-openai-compatible': 'openai-chat',
|
|
78
80
|
kimi: 'openai-chat',
|
|
@@ -170,6 +172,16 @@ export function dialectFor(kind: ProviderRegistryKind, protocol: CanonicalProtoc
|
|
|
170
172
|
'google-genai': 'gemini',
|
|
171
173
|
'vertex-ai': 'vertex-ai',
|
|
172
174
|
}[protocol];
|
|
175
|
+
case 'zcode-provider-rules':
|
|
176
|
+
// ZCode's own enum (`config.api.type`). Google has no route in its
|
|
177
|
+
// registry, so a Gemini endpoint is refused instead of mislabelled.
|
|
178
|
+
return {
|
|
179
|
+
'openai-chat': 'openai-chat-completions',
|
|
180
|
+
'openai-responses': 'openai-responses',
|
|
181
|
+
'anthropic-messages': 'anthropic-messages',
|
|
182
|
+
'google-genai': null,
|
|
183
|
+
'vertex-ai': null,
|
|
184
|
+
}[protocol];
|
|
173
185
|
default:
|
|
174
186
|
return null;
|
|
175
187
|
}
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
import { describe, expect, test } from 'bun:test';
|
|
28
28
|
import {
|
|
29
|
+
aliasModelFor,
|
|
29
30
|
credentialFieldLabel,
|
|
30
31
|
credentialIsEnvName,
|
|
31
32
|
dialectChoices,
|
|
@@ -46,6 +47,7 @@ const WRITABLE: Record<string, string> = {
|
|
|
46
47
|
pi: 'json-providers',
|
|
47
48
|
kimi: 'toml-providers',
|
|
48
49
|
qwen: 'json-model-providers',
|
|
50
|
+
zcode: 'zcode-provider-rules',
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
describe('the measured registry table', () => {
|
|
@@ -86,18 +88,26 @@ describe('the measured registry table', () => {
|
|
|
86
88
|
expect(managesProviders('minimax')).toBe(false);
|
|
87
89
|
});
|
|
88
90
|
|
|
89
|
-
test('zcode
|
|
90
|
-
//
|
|
91
|
-
//
|
|
91
|
+
test('zcode writes personal providers beside the app, never the app config', () => {
|
|
92
|
+
// 3.12+ stores user-added providers in `provider_config.json`; the legacy
|
|
93
|
+
// `config.json` map is the desktop app's and keeps its credentials. Writing
|
|
94
|
+
// THAT file is how a signed-in install stops signing in.
|
|
92
95
|
const registry = providerFacts('zcode').registry;
|
|
93
|
-
expect(registry.kind).toBe('
|
|
94
|
-
expect(registry.file).toBe('.zcode/v2/
|
|
95
|
-
expect(registry.
|
|
96
|
-
expect(
|
|
96
|
+
expect(registry.kind).toBe('zcode-provider-rules');
|
|
97
|
+
expect(registry.file).toBe('.zcode/v2/provider_config.json');
|
|
98
|
+
expect(registry.file).not.toBe('.zcode/v2/config.json');
|
|
99
|
+
expect(registry.pointer).toBe('config.providerConfigRules.providerRules');
|
|
100
|
+
expect(registry.baseUrlField).toBe('config.api.baseUrl');
|
|
101
|
+
expect(registry.apiKeyField).toBe('config.access.apiKey');
|
|
102
|
+
expect(registry.dialectField).toBe('config.api.type');
|
|
103
|
+
expect(registry.writable).toBe(true);
|
|
104
|
+
expect(managesProviders('zcode')).toBe(true);
|
|
97
105
|
});
|
|
98
106
|
|
|
99
107
|
test('the env-only harnesses keep their vendor variable names', () => {
|
|
100
|
-
|
|
108
|
+
// The alias table is asserted in `providerEnv` below; this is the endpoint
|
|
109
|
+
// and key each vendor documents.
|
|
110
|
+
expect(providerFacts('claude').env).toMatchObject({
|
|
101
111
|
baseUrl: 'ANTHROPIC_BASE_URL', apiKey: 'ANTHROPIC_AUTH_TOKEN', model: 'ANTHROPIC_MODEL',
|
|
102
112
|
});
|
|
103
113
|
expect(providerFacts('antigravity').env).toEqual({
|
|
@@ -154,6 +164,10 @@ describe('labels a reader can check against the vendor docs', () => {
|
|
|
154
164
|
expect(dialectChoices('toml-providers').map((d) => d.value)).toContain('openai_legacy');
|
|
155
165
|
// qwen routes by protocol id, so it has no dialect field of its own.
|
|
156
166
|
expect(dialectChoices('json-model-providers')).toEqual([]);
|
|
167
|
+
// ZCode documents exactly these three wire types; Gemini has no route there.
|
|
168
|
+
expect(dialectChoices('zcode-provider-rules').map((d) => d.value)).toEqual([
|
|
169
|
+
'anthropic-messages', 'openai-chat-completions', 'openai-responses',
|
|
170
|
+
]);
|
|
157
171
|
});
|
|
158
172
|
});
|
|
159
173
|
|
|
@@ -163,6 +177,43 @@ describe('providerEnv', () => {
|
|
|
163
177
|
.toEqual({ ANTHROPIC_BASE_URL: 'https://gw', ANTHROPIC_AUTH_TOKEN: 'sk-1', ANTHROPIC_MODEL: 'claude-sonnet-5' });
|
|
164
178
|
});
|
|
165
179
|
|
|
180
|
+
test('claude pins every picker alias, so a gateway id can replace the vendor’s', () => {
|
|
181
|
+
// Measured: `--model sonnet` against a gateway listing `claude-sonnet-5-5`
|
|
182
|
+
// answered `400 model not found: sonnet` until the alias variable existed.
|
|
183
|
+
expect(providerFacts('claude').env?.modelAliases).toEqual([
|
|
184
|
+
{ family: 'opus', env: 'ANTHROPIC_DEFAULT_OPUS_MODEL' },
|
|
185
|
+
{ family: 'sonnet', env: 'ANTHROPIC_DEFAULT_SONNET_MODEL' },
|
|
186
|
+
{ family: 'haiku', env: 'ANTHROPIC_DEFAULT_HAIKU_MODEL' },
|
|
187
|
+
{ family: 'fable', env: 'ANTHROPIC_DEFAULT_FABLE_MODEL' },
|
|
188
|
+
]);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('a versioned provider id is reduced to the id the endpoint expects', () => {
|
|
192
|
+
// The gateway's own list may spell the model provider-qualified; the env
|
|
193
|
+
// variable names the model, not the route.
|
|
194
|
+
expect(aliasModelFor('sonnet', ['kenari/claude-sonnet-5'])).toBe('claude-sonnet-5');
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test('an endpoint with no model of the family pins nothing', () => {
|
|
198
|
+
expect(aliasModelFor('opus', ['qwen3-8-27b:free', 'glm-5-3-flash'])).toBeNull();
|
|
199
|
+
expect(providerEnv('claude', { baseUrl: 'https://gw', apiKey: 'sk-1', models: ['qwen3-8-27b:free'] }))
|
|
200
|
+
.not.toHaveProperty('ANTHROPIC_DEFAULT_OPUS_MODEL');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test('every alias the endpoint serves is pinned, and none it does not', () => {
|
|
204
|
+
// Measured on kenari: `sonnet` and `opus` are answered 400 as literal ids
|
|
205
|
+
// while their family ids complete. The list is the authority.
|
|
206
|
+
const env = providerEnv('claude', {
|
|
207
|
+
baseUrl: 'https://gw',
|
|
208
|
+
apiKey: 'sk-1',
|
|
209
|
+
models: ['claude-sonnet-5', 'claude-opus-5', 'deepseek-v4-pro'],
|
|
210
|
+
});
|
|
211
|
+
expect(env.ANTHROPIC_DEFAULT_SONNET_MODEL).toBe('claude-sonnet-5');
|
|
212
|
+
expect(env.ANTHROPIC_DEFAULT_OPUS_MODEL).toBe('claude-opus-5');
|
|
213
|
+
expect(env).not.toHaveProperty('ANTHROPIC_DEFAULT_HAIKU_MODEL');
|
|
214
|
+
expect(env).not.toHaveProperty('ANTHROPIC_DEFAULT_FABLE_MODEL');
|
|
215
|
+
});
|
|
216
|
+
|
|
166
217
|
test('a blank field writes no variable at all', () => {
|
|
167
218
|
// An empty env var is a real thing to set, so the form must not do it by
|
|
168
219
|
// accident.
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* | minimax | its own BYOK store, written by `mcode` | not a file Kabmo may edit |
|
|
35
35
|
* | claude | env only | `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` |
|
|
36
36
|
* | antigravity | env only | `GOOGLE_GEMINI_BASE_URL`, `GEMINI_API_KEY` |
|
|
37
|
-
* | zcode | `~/.zcode/v2/
|
|
37
|
+
* | zcode | `~/.zcode/v2/provider_config.json` | `config.providerConfigRules.providerRules` (3.12+ personal providers) |
|
|
38
38
|
* | cursor, dsh | none Kabmo can write | the launch line and its env |
|
|
39
39
|
*
|
|
40
40
|
* A file Kabmo may READ but must not WRITE is marked `readOnly`: minimax keeps its
|
|
@@ -59,6 +59,9 @@ export type ProviderRegistryKind =
|
|
|
59
59
|
| 'toml-providers'
|
|
60
60
|
/** A JSON settings document with `modelProviders` (qwen). */
|
|
61
61
|
| 'json-model-providers'
|
|
62
|
+
/** ZCode's personal-provider rules: arrays under `config.providerConfigRules`
|
|
63
|
+
* and `config.modelConfigRules` (3.12+). */
|
|
64
|
+
| 'zcode-provider-rules'
|
|
62
65
|
/** No provider registry this build writes; an env contract instead. */
|
|
63
66
|
| 'env'
|
|
64
67
|
/** A registry that exists but belongs to the agent's own writer. */
|
|
@@ -97,11 +100,23 @@ export interface ProviderRegistry {
|
|
|
97
100
|
modelsAreRows?: boolean;
|
|
98
101
|
}
|
|
99
102
|
|
|
103
|
+
/**
|
|
104
|
+
* One picker alias a vendor SDK resolves from the environment. Claude Code's
|
|
105
|
+
* `opus`/`sonnet`/`haiku`/`fable` aliases resolve to ids the VENDOR ships
|
|
106
|
+
* unless `ANTHROPIC_DEFAULT_<FAMILY>_MODEL` pins them; a gateway that lists
|
|
107
|
+
* only its own ids answers the vendor ids with `400 model not found`.
|
|
108
|
+
*/
|
|
109
|
+
export interface EnvModelAlias {
|
|
110
|
+
family: string;
|
|
111
|
+
env: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
100
114
|
/** The env names an `environment` harness reads, in the order its docs list. */
|
|
101
115
|
export interface EnvProviderContract {
|
|
102
116
|
baseUrl: string;
|
|
103
117
|
apiKey: string;
|
|
104
118
|
model?: string;
|
|
119
|
+
modelAliases?: readonly EnvModelAlias[];
|
|
105
120
|
}
|
|
106
121
|
|
|
107
122
|
export interface HarnessProviderFacts {
|
|
@@ -239,7 +254,20 @@ export const HARNESS_PROVIDER_FACTS: Readonly<Partial<Record<HarnessId, HarnessP
|
|
|
239
254
|
kind: 'env', file: null, pointer: 'environment',
|
|
240
255
|
writable: true, baseUrlField: null, apiKeyField: null, modelsField: null,
|
|
241
256
|
},
|
|
242
|
-
env: {
|
|
257
|
+
env: {
|
|
258
|
+
baseUrl: 'ANTHROPIC_BASE_URL',
|
|
259
|
+
apiKey: 'ANTHROPIC_AUTH_TOKEN',
|
|
260
|
+
model: 'ANTHROPIC_MODEL',
|
|
261
|
+
// The picker's aliases resolve through these variables. Set only the ones
|
|
262
|
+
// the gateway serves: an unmapped alias keeps resolving to the vendor's
|
|
263
|
+
// id, which a custom endpoint answers with `400 model not found`.
|
|
264
|
+
modelAliases: [
|
|
265
|
+
{ family: 'opus', env: 'ANTHROPIC_DEFAULT_OPUS_MODEL' },
|
|
266
|
+
{ family: 'sonnet', env: 'ANTHROPIC_DEFAULT_SONNET_MODEL' },
|
|
267
|
+
{ family: 'haiku', env: 'ANTHROPIC_DEFAULT_HAIKU_MODEL' },
|
|
268
|
+
{ family: 'fable', env: 'ANTHROPIC_DEFAULT_FABLE_MODEL' },
|
|
269
|
+
],
|
|
270
|
+
},
|
|
243
271
|
// Claude Code speaks Anthropic Messages only, and appends `/v1/messages`
|
|
244
272
|
// itself — measured: BASE_URL with `/v1` still on it requested
|
|
245
273
|
// `/v1/v1/messages` and answered with an empty turn.
|
|
@@ -279,17 +307,24 @@ export const HARNESS_PROVIDER_FACTS: Readonly<Partial<Record<HarnessId, HarnessP
|
|
|
279
307
|
},
|
|
280
308
|
zcode: {
|
|
281
309
|
registry: {
|
|
282
|
-
// MEASURED against the bridge's own reference
|
|
283
|
-
//
|
|
284
|
-
//
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
|
|
310
|
+
// MEASURED against the bridge's own reference and the installed 0.82.3
|
|
311
|
+
// bundle: `~/.zcode/v2/config.json` is the LEGACY provider map, and the
|
|
312
|
+
// personal providers a user adds in the 3.12+ desktop app (or the CLI's
|
|
313
|
+
// setup wizard) live in `provider_config.json`. The bridge reads both: the
|
|
314
|
+
// rule arrays are authoritative for custom providers, while `config.json`
|
|
315
|
+
// keeps builtin credentials. Writing `provider_config.json` is supported by
|
|
316
|
+
// the runtime (`provider-config.ts` writes it through a file lock and the
|
|
317
|
+
// backend absorbs external edits on a ~1s poll), so this registry is
|
|
318
|
+
// writable — unlike `config.json`, which the app owns.
|
|
319
|
+
kind: 'zcode-provider-rules', file: '.zcode/v2/provider_config.json',
|
|
320
|
+
pointer: 'config.providerConfigRules.providerRules',
|
|
321
|
+
writable: true, baseUrlField: 'config.api.baseUrl',
|
|
322
|
+
apiKeyField: 'config.access.apiKey', dialectField: 'config.api.type',
|
|
323
|
+
modelsField: 'config.personalModelIds', modelsAreRows: true,
|
|
289
324
|
},
|
|
290
325
|
createsChoice: true,
|
|
291
|
-
importFrom: [],
|
|
292
|
-
summary: 'ZCode keeps providers
|
|
326
|
+
importFrom: ['omp-rpc', 'opencode', 'codex', 'pi', 'kimi', 'qwen'],
|
|
327
|
+
summary: 'ZCode keeps user-added providers in ~/.zcode/v2/provider_config.json (3.12+), as provider rules plus one model rule per id. Kabmo merges one provider into that file and leaves the app’s legacy config.json untouched. Chats still need a ZCode runtime: the desktop app, or `zcode-app-cli` on PATH (`ZCODE_BIN` for a custom install).',
|
|
293
328
|
},
|
|
294
329
|
};
|
|
295
330
|
|
|
@@ -36,6 +36,7 @@ export function registryLabel(id: string | null | undefined): string {
|
|
|
36
36
|
case 'json-providers': return 'models.json (pi)';
|
|
37
37
|
case 'toml-providers': return 'config.toml (kimi)';
|
|
38
38
|
case 'json-model-providers': return 'settings.json (qwen)';
|
|
39
|
+
case 'zcode-provider-rules': return 'provider_config.json (zcode)';
|
|
39
40
|
case 'agent-managed': return "the agent's own provider command";
|
|
40
41
|
case 'env': return 'environment variables';
|
|
41
42
|
default: return 'launch command and env';
|
|
@@ -56,6 +57,31 @@ export function supportsProviderEditor(id: string | null | undefined): boolean {
|
|
|
56
57
|
return providerLevel(id) === 'full';
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
/**
|
|
61
|
+
* The id an endpoint serves for one picker alias, or null when it serves no
|
|
62
|
+
* model of that family.
|
|
63
|
+
*
|
|
64
|
+
* Claude Code's picker offers FAMILY aliases (`opus`, `sonnet`, `haiku`,
|
|
65
|
+
* `fable`). An alias that is not pinned with `ANTHROPIC_DEFAULT_*_MODEL` keeps
|
|
66
|
+
* resolving to Anthropic's own model id, which a gateway answers with
|
|
67
|
+
* `400 model not found: sonnet` (measured against kenari.id). The model list
|
|
68
|
+
* the endpoint published is what says which id belongs to the family.
|
|
69
|
+
*
|
|
70
|
+
* The id is returned BARE: `kenari/claude-sonnet-5` becomes
|
|
71
|
+
* `claude-sonnet-5`, because the variable names the model the endpoint expects,
|
|
72
|
+
* not the provider-qualified spelling an agent's own list may use.
|
|
73
|
+
*/
|
|
74
|
+
export function aliasModelFor(family: string, models: readonly string[]): string | null {
|
|
75
|
+
const pattern = new RegExp(`\\b${family.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`, 'i');
|
|
76
|
+
for (const raw of models) {
|
|
77
|
+
const id = raw.trim();
|
|
78
|
+
if (!id) continue;
|
|
79
|
+
const bare = id.slice(id.lastIndexOf('/') + 1);
|
|
80
|
+
if (pattern.test(bare)) return bare;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
59
85
|
/**
|
|
60
86
|
* The env a provider becomes for an `environment` harness.
|
|
61
87
|
*
|
|
@@ -64,10 +90,15 @@ export function supportsProviderEditor(id: string | null | undefined): boolean {
|
|
|
64
90
|
* form labels each field with the variable it becomes. A blank field writes NO
|
|
65
91
|
* variable — an empty env var is a real thing to set, so the form must not do it
|
|
66
92
|
* by accident.
|
|
93
|
+
*
|
|
94
|
+
* `models` is the endpoint's own listing. When given, every picker alias that
|
|
95
|
+
* family serves is PINNED to that id. Without the pin the alias still resolves
|
|
96
|
+
* to the vendor's model, so a picker row the user can see answers a gateway
|
|
97
|
+
* with `400 model not found` (measured on `sonnet` against kenari.id).
|
|
67
98
|
*/
|
|
68
99
|
export function providerEnv(
|
|
69
100
|
id: string | null | undefined,
|
|
70
|
-
provider: { baseUrl: string; apiKey: string; model?: string },
|
|
101
|
+
provider: { baseUrl: string; apiKey: string; model?: string; models?: readonly string[] },
|
|
71
102
|
): Record<string, string> {
|
|
72
103
|
const contract = providerFacts(id).env;
|
|
73
104
|
if (!contract) return {};
|
|
@@ -75,6 +106,10 @@ export function providerEnv(
|
|
|
75
106
|
if (provider.baseUrl.trim()) env[contract.baseUrl] = provider.baseUrl.trim();
|
|
76
107
|
if (provider.apiKey.trim()) env[contract.apiKey] = provider.apiKey.trim();
|
|
77
108
|
if (contract.model && provider.model?.trim()) env[contract.model] = provider.model.trim();
|
|
109
|
+
for (const alias of contract.modelAliases ?? []) {
|
|
110
|
+
const model = aliasModelFor(alias.family, provider.models ?? []);
|
|
111
|
+
if (model) env[alias.env] = model;
|
|
112
|
+
}
|
|
78
113
|
return env;
|
|
79
114
|
}
|
|
80
115
|
|
|
@@ -134,6 +169,14 @@ export function dialectChoices(kind: ProviderRegistryKind): readonly { value: st
|
|
|
134
169
|
{ value: 'kimi', label: 'Kimi' },
|
|
135
170
|
{ value: 'vertexai', label: 'Google Vertex AI' },
|
|
136
171
|
];
|
|
172
|
+
case 'zcode-provider-rules':
|
|
173
|
+
// The three wire types ZCode's provider reference documents. Google is
|
|
174
|
+
// absent from its own enum, so it is not offered as a choice here.
|
|
175
|
+
return [
|
|
176
|
+
{ value: 'anthropic-messages', label: 'Anthropic Messages' },
|
|
177
|
+
{ value: 'openai-chat-completions', label: 'OpenAI Chat Completions' },
|
|
178
|
+
{ value: 'openai-responses', label: 'OpenAI Responses' },
|
|
179
|
+
];
|
|
137
180
|
default:
|
|
138
181
|
return [];
|
|
139
182
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Which harnesses Kabmo can rewind IN PLACE.
|
|
8
|
+
*
|
|
9
|
+
* Undo and Retry truncate the conversation and then re-run a turn, so the
|
|
10
|
+
* agent's own context must be truncatable with it. That is only true where the
|
|
11
|
+
* transcript is the JSONL omp writes — `omp-rpc` and `omp-acp` are the same
|
|
12
|
+
* product over two transports, and the ACP child is torn down before the file
|
|
13
|
+
* is rewritten (the next prompt resumes it over RPC).
|
|
14
|
+
*
|
|
15
|
+
* Every other ACP agent keeps the conversation in its own store, and ACP
|
|
16
|
+
* defines no truncation verb (`session/load` replays the whole history, a fork
|
|
17
|
+
* copies it). Truncating Kabmo's copy there would leave the agent answering
|
|
18
|
+
* from turns the timeline no longer shows — a silent divergence, not a rewind.
|
|
19
|
+
* An UNKNOWN harness keeps the historical allow: the caller has not resolved it
|
|
20
|
+
* yet, and the endpoint answers the real refusal.
|
|
21
|
+
*/
|
|
22
|
+
export function harnessSupportsRewind(harness: string | null | undefined): boolean {
|
|
23
|
+
return !harness || harness === 'omp-rpc' || harness === 'omp-acp';
|
|
24
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Narrowing a harness-update record that came from somewhere else.
|
|
8
|
+
*
|
|
9
|
+
* Two readers get one over the wire or off disk — the About card, which parses
|
|
10
|
+
* the status response, and the server, which parses the file a detached worker
|
|
11
|
+
* wrote — and neither may assume the shape: a half-written file or an older
|
|
12
|
+
* build's payload would otherwise reach `job.steps.find(...)` and throw inside a
|
|
13
|
+
* render. The guard IS the check, so a payload that fails it reads as "no run".
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { HarnessUpdateJob } from '@/shared/types/harness-update';
|
|
17
|
+
|
|
18
|
+
export function isHarnessUpdateJob(value: unknown): value is HarnessUpdateJob {
|
|
19
|
+
if (!value || typeof value !== 'object') return false;
|
|
20
|
+
const job = value as Partial<HarnessUpdateJob>;
|
|
21
|
+
return typeof job.harness === 'string'
|
|
22
|
+
&& typeof job.label === 'string'
|
|
23
|
+
&& typeof job.startedAt === 'number'
|
|
24
|
+
&& Array.isArray(job.steps)
|
|
25
|
+
&& (job.finishedAt === null || typeof job.finishedAt === 'number');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The `job` field of a status payload, or null when it is not a record. */
|
|
29
|
+
export function updateJobFrom(payload: unknown): HarnessUpdateJob | null {
|
|
30
|
+
if (!payload || typeof payload !== 'object') return null;
|
|
31
|
+
const found: unknown = (payload as { job?: unknown }).job;
|
|
32
|
+
return isHarnessUpdateJob(found) ? found : null;
|
|
33
|
+
}
|
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { describe, expect, test } from 'bun:test';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
planHarnessUpdate,
|
|
24
|
+
repointAdapterLaunch,
|
|
25
|
+
type HarnessUpdateStep,
|
|
26
|
+
type UpdatePlanState,
|
|
27
|
+
} from '@/shared/lib/harness/update-plan';
|
|
23
28
|
import { harnessUpdateFacts } from '@/shared/lib/harness/updates';
|
|
24
29
|
|
|
25
30
|
const CLAUDE = harnessUpdateFacts('claude');
|
|
@@ -33,11 +38,46 @@ function state(overrides: Partial<UpdatePlanState> = {}): UpdatePlanState {
|
|
|
33
38
|
};
|
|
34
39
|
}
|
|
35
40
|
|
|
41
|
+
describe('repointing a launch line after an adapter install', () => {
|
|
42
|
+
const install: HarnessUpdateStep = {
|
|
43
|
+
part: 'adapter',
|
|
44
|
+
command: 'npm install -g @agentclientprotocol/claude-agent-acp@0.101.0 --allow-scripts=@agentclientprotocol/claude-agent-acp',
|
|
45
|
+
argv: [
|
|
46
|
+
'npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0',
|
|
47
|
+
'--allow-scripts=@agentclientprotocol/claude-agent-acp',
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
test('a pinned npx adapter is pointed at the binary the install wrote', () => {
|
|
52
|
+
// The launch requests 0.100.0; the install wrote 0.101.0. Without this, the
|
|
53
|
+
// press reports success and every new session still starts the pinned build.
|
|
54
|
+
expect(repointAdapterLaunch(CLAUDE, [install], '', true)).toBe('claude-agent-acp');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('a user command is never replaced', () => {
|
|
58
|
+
expect(repointAdapterLaunch(CLAUDE, [install], '/opt/bin/my-claude-wrapper', true)).toBeNull();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('no install step, no repoint', () => {
|
|
62
|
+
expect(repointAdapterLaunch(CLAUDE, [], '', true)).toBeNull();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('a binary that did not land on PATH is not claimed', () => {
|
|
66
|
+
expect(repointAdapterLaunch(CLAUDE, [install], '', false)).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
36
70
|
describe('planning a harness update', () => {
|
|
37
71
|
test('both parts behind runs the install AND the CLI updater, in that order', () => {
|
|
38
72
|
const steps = planHarnessUpdate('claude', CLAUDE, state(), '0.100.0');
|
|
39
73
|
expect(steps.map((step) => step.argv[0])).toEqual(['npm', 'claude']);
|
|
40
|
-
|
|
74
|
+
// The per-package `--allow-scripts` is part of the plan: npm 11 skips
|
|
75
|
+
// postinstall by default, and a native CLI installed without it is broken on
|
|
76
|
+
// disk (measured: `bin/claude.exe` left as a "native binary not installed" stub).
|
|
77
|
+
expect(steps[0].argv).toEqual([
|
|
78
|
+
'npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0',
|
|
79
|
+
'--allow-scripts=@agentclientprotocol/claude-agent-acp',
|
|
80
|
+
]);
|
|
41
81
|
expect(steps[0].part).toBe('adapter');
|
|
42
82
|
expect(steps[1].argv).toEqual(['claude', 'update']);
|
|
43
83
|
expect(steps[1].part).toBe('Claude Code');
|
|
@@ -64,7 +104,13 @@ describe('planning a harness update', () => {
|
|
|
64
104
|
'0.100.0',
|
|
65
105
|
);
|
|
66
106
|
expect(steps).toHaveLength(1);
|
|
67
|
-
|
|
107
|
+
// The per-package `--allow-scripts` is part of the plan: npm 11 skips
|
|
108
|
+
// postinstall by default, and a native CLI installed without it is broken on
|
|
109
|
+
// disk (measured: `bin/claude.exe` left as a "native binary not installed" stub).
|
|
110
|
+
expect(steps[0].argv).toEqual([
|
|
111
|
+
'npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0',
|
|
112
|
+
'--allow-scripts=@agentclientprotocol/claude-agent-acp',
|
|
113
|
+
]);
|
|
68
114
|
});
|
|
69
115
|
|
|
70
116
|
test('nothing behind plans nothing, so the route can say "already up to date"', () => {
|
|
@@ -99,6 +145,25 @@ describe('planning a harness update', () => {
|
|
|
99
145
|
expect(steps[0].argv[0]).toBe('npm');
|
|
100
146
|
});
|
|
101
147
|
|
|
148
|
+
test('an npm CLI with no vendor updater moves through its own package', () => {
|
|
149
|
+
// `dsh` reports the ACP surface (0.0.1) while `dsh --version` is 0.2.2-rc.1;
|
|
150
|
+
// the CLI carries the package and has no `dsh update`. Leaving this half out
|
|
151
|
+
// made every press compare the adapter's version to the CLI's package.
|
|
152
|
+
const steps = planHarnessUpdate(
|
|
153
|
+
'deepseek-harness',
|
|
154
|
+
harnessUpdateFacts('dsh'),
|
|
155
|
+
{
|
|
156
|
+
installed: true,
|
|
157
|
+
agent: { version: '0.0.1', latest: null },
|
|
158
|
+
cli: { name: 'deepseek-harness', version: '0.2.2-rc.1', latest: '0.3.0' },
|
|
159
|
+
},
|
|
160
|
+
'0.0.1',
|
|
161
|
+
);
|
|
162
|
+
expect(steps).toHaveLength(1);
|
|
163
|
+
expect(steps[0].part).toBe('deepseek-harness');
|
|
164
|
+
expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@deepseek-ai/dsh@0.3.0', '--allow-scripts=@deepseek-ai/dsh']);
|
|
165
|
+
});
|
|
166
|
+
|
|
102
167
|
test('a plain npm harness names itself, not "adapter"', () => {
|
|
103
168
|
const steps = planHarnessUpdate(
|
|
104
169
|
'qwen',
|
|
@@ -108,6 +173,6 @@ describe('planning a harness update', () => {
|
|
|
108
173
|
);
|
|
109
174
|
expect(steps).toHaveLength(1);
|
|
110
175
|
expect(steps[0].part).toBe('qwen');
|
|
111
|
-
expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@qwen-code/qwen-code@0.10.0']);
|
|
176
|
+
expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@qwen-code/qwen-code@0.10.0', '--allow-scripts=@qwen-code/qwen-code']);
|
|
112
177
|
});
|
|
113
178
|
});
|
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
* read (a `self` CLI, a CLI with no package in the facts) is never planned: Kabmo
|
|
20
20
|
* cannot claim it is behind.
|
|
21
21
|
*
|
|
22
|
+
* **The install allows the vendor's own lifecycle scripts, for that package only.**
|
|
23
|
+
* npm 11 blocks postinstall by default, and the packages here need it: measured on
|
|
24
|
+
* this machine, `@anthropic-ai/claude-code` was present with its native binary
|
|
25
|
+
* missing — `bin/claude.exe` was a stub printing "claude native binary not
|
|
26
|
+
* installed", and `claude update` then failed with
|
|
27
|
+
* `update_apply_native_binary_missing`. A per-package `--allow-scripts=<pkg>` is
|
|
28
|
+
* the narrow form; blanket script execution is not.
|
|
29
|
+
*
|
|
22
30
|
* Pure, so the decision is testable without spawning anything — the route only
|
|
23
31
|
* runs the argv this returns.
|
|
24
32
|
*/
|
|
@@ -77,8 +85,8 @@ export function planHarnessUpdate(
|
|
|
77
85
|
// An adapter over a CLI is named `adapter`, so a report cannot be read as
|
|
78
86
|
// "the CLI moved" when only its bridge did.
|
|
79
87
|
part: state.cli ? 'adapter' : label,
|
|
80
|
-
command: `npm install -g ${facts.pkg}@${latest}`,
|
|
81
|
-
argv: ['npm', 'install', '-g', `${facts.pkg}@${latest}`],
|
|
88
|
+
command: `npm install -g ${facts.pkg}@${latest} --allow-scripts=${facts.pkg}`,
|
|
89
|
+
argv: ['npm', 'install', '-g', `${facts.pkg}@${latest}`, `--allow-scripts=${facts.pkg}`],
|
|
82
90
|
});
|
|
83
91
|
}
|
|
84
92
|
}
|
|
@@ -86,15 +94,55 @@ export function planHarnessUpdate(
|
|
|
86
94
|
// The CLI moves through ITS OWN updater (`claude update`), invoked by name: the
|
|
87
95
|
// adapter pins the CLI version it bridges, so this is the half that used to be
|
|
88
96
|
// left stale — and it is also the ONLY half that moves when the adapter is
|
|
89
|
-
// already current.
|
|
97
|
+
// already current. An npm CLI with no vendor updater (`dsh`) moves through the
|
|
98
|
+
// package the facts name instead; without that half its installed number could
|
|
99
|
+
// never be compared, let alone moved.
|
|
90
100
|
const { cli } = state;
|
|
91
|
-
if (cli &&
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
if (cli && cli.latest && cli.version && isNewer(cli.latest, cli.version)) {
|
|
102
|
+
if (facts.command) {
|
|
103
|
+
steps.push({
|
|
104
|
+
part: cli.name,
|
|
105
|
+
command: facts.command,
|
|
106
|
+
argv: facts.command.split(' '),
|
|
107
|
+
});
|
|
108
|
+
} else if (facts.cli?.pkg) {
|
|
109
|
+
steps.push({
|
|
110
|
+
part: cli.name,
|
|
111
|
+
command: `npm install -g ${facts.cli.pkg}@${cli.latest} --allow-scripts=${facts.cli.pkg}`,
|
|
112
|
+
argv: ['npm', 'install', '-g', `${facts.cli.pkg}@${cli.latest}`, `--allow-scripts=${facts.cli.pkg}`],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
97
115
|
}
|
|
98
116
|
|
|
99
117
|
return steps;
|
|
100
118
|
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The launch command a successful adapter install should leave behind, or null.
|
|
122
|
+
*
|
|
123
|
+
* The launch table starts an npm adapter through a PINNED `npx -y pkg@x.y.z`,
|
|
124
|
+
* while the update installs the package GLOBALLY. Those are two different
|
|
125
|
+
* resolvers: `npm i -g` writes a binary onto PATH that `npx` never consults, so
|
|
126
|
+
* the press reported success while every new session still started the old
|
|
127
|
+
* pinned build — measured on `claude` (global 0.101.0, launch requested 0.100.0)
|
|
128
|
+
* and true by construction for codex/pi/zcode.
|
|
129
|
+
*
|
|
130
|
+
* The answer is the installed binary's name ONLY when this run installed the
|
|
131
|
+
* adapter, the binary is on PATH, and the harness has no user command of its
|
|
132
|
+
* own. A configured command is an explicit choice about how this machine starts
|
|
133
|
+
* the harness, so it is never replaced.
|
|
134
|
+
*/
|
|
135
|
+
export function repointAdapterLaunch(
|
|
136
|
+
facts: HarnessUpdateFacts | null,
|
|
137
|
+
steps: readonly HarnessUpdateStep[],
|
|
138
|
+
currentCommand: string,
|
|
139
|
+
agentBinOnPath: boolean,
|
|
140
|
+
): string | null {
|
|
141
|
+
const bin = facts?.agentBin;
|
|
142
|
+
const pkg = facts?.pkg;
|
|
143
|
+
if (!bin || !pkg || !agentBinOnPath || currentCommand.trim()) return null;
|
|
144
|
+
const installed = steps.some(
|
|
145
|
+
(step) => step.argv[0] === 'npm' && step.argv[3]?.startsWith(`${pkg}@`),
|
|
146
|
+
);
|
|
147
|
+
return installed ? bin : null;
|
|
148
|
+
}
|
|
@@ -76,6 +76,28 @@ describe('update facts per harness', () => {
|
|
|
76
76
|
expect(harnessUpdateFacts('omp-acp')?.command).toBe('omp update');
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
+
test('dsh compares its CLI package, not the ACP surface version', () => {
|
|
80
|
+
// Measured: the probe reports `deepseek-harness-acp` 0.0.1 while the
|
|
81
|
+
// installed CLI is 0.2.2-rc.1. The agent part has no registry package of its
|
|
82
|
+
// own; the CLI does, and that is the number an update can move.
|
|
83
|
+
expect(latestSourceFor('dsh')).toBeNull();
|
|
84
|
+
expect(harnessUpdateFacts('dsh')?.cli).toEqual({
|
|
85
|
+
bin: 'dsh',
|
|
86
|
+
name: 'deepseek-harness',
|
|
87
|
+
pkg: '@deepseek-ai/dsh',
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('an npx-launched adapter names the binary a global install writes', () => {
|
|
92
|
+
// The launch line pins `npx -y pkg@version`; `npm i -g` writes this binary,
|
|
93
|
+
// and the update route repoints the harness at it. Without the name the
|
|
94
|
+
// install cannot take effect on the next spawn.
|
|
95
|
+
expect(harnessUpdateFacts('claude')?.agentBin).toBe('claude-agent-acp');
|
|
96
|
+
expect(harnessUpdateFacts('codex')?.agentBin).toBe('codex-acp');
|
|
97
|
+
expect(harnessUpdateFacts('pi')?.agentBin).toBe('pi-acp');
|
|
98
|
+
expect(harnessUpdateFacts('zcode')?.agentBin).toBe('zcode-acp-server');
|
|
99
|
+
});
|
|
100
|
+
|
|
79
101
|
test('an unknown harness has no facts at all', () => {
|
|
80
102
|
expect(harnessUpdateFacts('some-future-agent')).toBeNull();
|
|
81
103
|
expect(latestSourceFor('some-future-agent')).toBeNull();
|