mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 20:35:39 -06:00
a5d1d9e473
- Align OAuth model-discovery client_version with the pinned @openai/codex package (contract test ties it to extensions/codex/package.json). - Static OAuth fallback advertises only the proven GPT-5.6 subscription route (Sol); Terra/Luna come from live discovery when entitled. (#105445) - Honor the deprecated whole-agent agentRuntime openclaw opt-out for implicit Codex plugin installation; explicit model policy still wins. (#95131) - Half-open reprobe for long WHAM subscription blocks: bounded 45-minute background probes with durable claims, generation checks, and process dedupe so restored capacity unblocks profiles early. (#107262)
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
/** Agent runtime id normalization and retired runtime-selection compatibility helpers. */
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import { normalizeAgentId } from "../routing/session-key.js";
|
|
|
|
export type EmbeddedAgentRuntime = "openclaw" | "auto" | (string & {});
|
|
|
|
export const OPENCLAW_AGENT_RUNTIME_ID = "openclaw";
|
|
export const AUTO_AGENT_RUNTIME_ID = "auto";
|
|
|
|
/** Normalizes configured runtime aliases to the current embedded-agent runtime id vocabulary. */
|
|
export function normalizeEmbeddedAgentRuntime(raw: string | undefined): EmbeddedAgentRuntime {
|
|
const value = raw?.trim();
|
|
if (!value) {
|
|
return OPENCLAW_AGENT_RUNTIME_ID;
|
|
}
|
|
if (value === "openclaw" || value === "pi") {
|
|
return OPENCLAW_AGENT_RUNTIME_ID;
|
|
}
|
|
if (value === "auto") {
|
|
return AUTO_AGENT_RUNTIME_ID;
|
|
}
|
|
if (value === "codex-app-server") {
|
|
return "codex";
|
|
}
|
|
return value;
|
|
}
|
|
|
|
/** Normalizes an optional unknown runtime id value, returning undefined when absent/invalid. */
|
|
export function normalizeOptionalAgentRuntimeId(raw: unknown): EmbeddedAgentRuntime | undefined {
|
|
if (typeof raw !== "string") {
|
|
return undefined;
|
|
}
|
|
const value = raw.trim().toLowerCase();
|
|
return value ? normalizeEmbeddedAgentRuntime(value) : undefined;
|
|
}
|
|
|
|
/** Resolves the deprecated explicit whole-agent runtime override, when present. */
|
|
export function resolveAgentScopedRuntimeOverride(params: {
|
|
config?: OpenClawConfig;
|
|
agentId?: string;
|
|
}): EmbeddedAgentRuntime | undefined {
|
|
const agentId = params.agentId ? normalizeAgentId(params.agentId) : undefined;
|
|
const agentRuntime = agentId
|
|
? params.config?.agents?.list?.find((entry) => normalizeAgentId(entry.id) === agentId)
|
|
?.agentRuntime?.id
|
|
: undefined;
|
|
return normalizeOptionalAgentRuntimeId(
|
|
agentRuntime ?? params.config?.agents?.defaults?.agentRuntime?.id,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @deprecated Whole-agent runtime environment selection is retired. Use
|
|
* provider/model runtime policy or a registered agent harness instead.
|
|
*/
|
|
export function resolveEmbeddedAgentRuntime(
|
|
_env: NodeJS.ProcessEnv = process.env,
|
|
): EmbeddedAgentRuntime {
|
|
return OPENCLAW_AGENT_RUNTIME_ID;
|
|
}
|
|
|
|
/** Returns whether a runtime id should be treated as the default runtime selection. */
|
|
export function isDefaultAgentRuntimeId(runtime: string | undefined): boolean {
|
|
return runtime === undefined || runtime === AUTO_AGENT_RUNTIME_ID || runtime === "default";
|
|
}
|