fix(runtime): split cli provider and abort seams

This commit is contained in:
Vincent Koc
2026-04-11 21:15:32 +01:00
parent dc469a3db5
commit d7fcd23091
4 changed files with 22 additions and 21 deletions

View File

@@ -0,0 +1,17 @@
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { resolveRuntimeCliBackends } from "../plugins/cli-backends.runtime.js";
import { resolvePluginSetupCliBackendRuntime } from "../plugins/setup-registry.runtime.js";
import { normalizeProviderId } from "./model-selection-normalize.js";
export function isCliProvider(provider: string, cfg?: OpenClawConfig): boolean {
const normalized = normalizeProviderId(provider);
const cliBackends = resolveRuntimeCliBackends();
if (cliBackends.some((backend) => normalizeProviderId(backend.id) === normalized)) {
return true;
}
if (resolvePluginSetupCliBackendRuntime({ backend: normalized })) {
return true;
}
const backends = cfg?.agents?.defaults?.cliBackends ?? {};
return Object.keys(backends).some((key) => normalizeProviderId(key) === normalized);
}

View File

@@ -6,8 +6,6 @@ import {
} from "../config/model-input.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { resolveRuntimeCliBackends } from "../plugins/cli-backends.runtime.js";
import { resolvePluginSetupCliBackendRuntime } from "../plugins/setup-registry.runtime.js";
import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalLowercaseString,
@@ -76,19 +74,7 @@ export {
parseModelRef,
};
export type { ModelRef };
export function isCliProvider(provider: string, cfg?: OpenClawConfig): boolean {
const normalized = normalizeProviderId(provider);
const cliBackends = resolveRuntimeCliBackends();
if (cliBackends.some((backend) => normalizeProviderId(backend.id) === normalized)) {
return true;
}
if (resolvePluginSetupCliBackendRuntime({ backend: normalized })) {
return true;
}
const backends = cfg?.agents?.defaults?.cliBackends ?? {};
return Object.keys(backends).some((key) => normalizeProviderId(key) === normalized);
}
export { isCliProvider } from "./model-selection-cli.js";
export function resolvePersistedOverrideModelRef(params: {
defaultProvider: string;

View File

@@ -1,5 +1,6 @@
import { normalizeLowercaseStringOrEmpty } from "../../shared/string-coerce.js";
import { normalizeCommandBody, type CommandNormalizeOptions } from "../commands-registry.js";
import { normalizeCommandBody } from "../commands-registry-normalize.js";
import type { CommandNormalizeOptions } from "../commands-registry.types.js";
const ABORT_TRIGGERS = new Set([
"stop",

View File

@@ -3,11 +3,8 @@ import { normalizeChannelId } from "../channels/plugins/index.js";
import { listPairingChannels, notifyPairingApproved } from "../channels/plugins/pairing.js";
import { loadConfig } from "../config/config.js";
import { resolvePairingIdLabel } from "../pairing/pairing-labels.js";
import {
approveChannelPairingCode,
listChannelPairingRequests,
type PairingChannel,
} from "../pairing/pairing-store.js";
import { approveChannelPairingCode, listChannelPairingRequests } from "../pairing/pairing-store.js";
import type { PairingChannel } from "../pairing/pairing-store.types.js";
import { defaultRuntime } from "../runtime.js";
import {
normalizeLowercaseStringOrEmpty,