openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
40 lines (39 loc) • 2.05 kB
JavaScript
import { n as sanitizeTerminalText } from "./safe-text-C80HAQ2e.mjs";
import { t as GATEWAY_SERVER_CAPS } from "./server-capabilities-BDosLJeN.mjs";
import { o as readActiveGatewayLockIdentity } from "./gateway-lock-IYOwJQai.mjs";
import { f as isImplicitLocalGatewayTarget, r as callGateway } from "./call-DVCK1deJ.mjs";
//#region src/commands/models/catalog-warnings.ts
/** Shares model inventory's target selection without falling back across Gateways. */
async function readSelectedGatewayModelCatalog(e, t, n) {
const r = await isImplicitLocalGatewayTarget({ config: e });
const i = Boolean(process.env.OPENCLAW_GATEWAY_PORT?.trim());
const a = r && !i ? await readActiveGatewayLockIdentity({ requireInspection: true }) : void 0;
if (r && !i && !a) return;
return callGateway({
config: e,
method: "models.list",
...t.preparedOnly ? { sharedStateMode: "read-only" } : {},
...n ? { timeoutMs: n } : {},
requiredCapabilities: [GATEWAY_SERVER_CAPS.PUBLISHED_MODEL_CATALOG],
...a ? { localPortOverride: a.port } : {},
params: t
});
}
function getModelCatalogWarnings(e) {
return e?.providerOutcomes?.flatMap((e) => e.status === "ready" ? (e.unlistedConfiguredModelIds ?? []).map((t) => ({
ref: `${e.provider}/${t}`,
message: `Configured model "${sanitizeTerminalText(`${e.provider}/${t}`)}" is not present in the provider's last successful server catalog${e.profileId ? ` (profile ${sanitizeTerminalText(e.profileId)})` : ""}.`,
fixHint: "Pull or download it on that server, or fix the configured model name; then run openclaw models list --refresh. The model remains selectable."
})) : []) ?? [];
}
/** Diagnostic reads consume a prepared publication; they never discover or probe providers. */
async function readModelCatalog(e, t) {
return readSelectedGatewayModelCatalog(e, {
view: "all",
includeDetails: true,
preparedOnly: true,
...t ? { agentId: t } : {}
}, 5e3).catch(() => void 0);
}
//#endregion
export { readModelCatalog as n, readSelectedGatewayModelCatalog as r, getModelCatalogWarnings as t };