@@ -6,33 +6,17 @@ import {
|
6 | 6 | } from "@openclaw/model-catalog-core/provider-model-id-normalize"; |
7 | 7 | import { isRecord as isPlainRecord } from "@openclaw/normalization-core/record-coerce"; |
8 | 8 | import { |
9 | | -normalizeLowercaseStringOrEmpty, |
10 | 9 | normalizeOptionalString, |
11 | 10 | resolvePrimaryStringValue, |
12 | 11 | } from "@openclaw/normalization-core/string-coerce"; |
| 12 | +import { modelKey } from "../shared/model-key.js"; |
13 | 13 | import type { AgentModelConfig, AgentToolModelConfig } from "./types.agents-shared.js"; |
14 | 14 | |
15 | 15 | type AgentModelListLike = { |
16 | 16 | primary?: string; |
17 | 17 | fallbacks?: string[]; |
18 | 18 | }; |
19 | 19 | |
20 | | -function modelKeyForConfig(provider: string, model: string): string { |
21 | | -const providerId = provider.trim(); |
22 | | -const modelId = model.trim(); |
23 | | -if (!providerId) { |
24 | | -return modelId; |
25 | | -} |
26 | | -if (!modelId) { |
27 | | -return providerId; |
28 | | -} |
29 | | -return normalizeLowercaseStringOrEmpty(modelId).startsWith( |
30 | | -`${normalizeLowercaseStringOrEmpty(providerId)}/`, |
31 | | -) |
32 | | - ? modelId |
33 | | - : `${providerId}/${modelId}`; |
34 | | -} |
35 | | - |
36 | 20 | type AgentModelInput = AgentModelConfig | AgentToolModelConfig; |
37 | 21 | |
38 | 22 | /** Returns the primary model ref from either string or object-style agent model config. */ |
@@ -90,7 +74,7 @@ export function normalizeAgentModelRefForConfig(model: string): string {
|
90 | 74 | : provider === "together" |
91 | 75 | ? normalizeTogetherModelId(modelSuffix) |
92 | 76 | : modelSuffix; |
93 | | -return modelKeyForConfig(provider, normalizedModel); |
| 77 | +return modelKey(provider, normalizedModel); |
94 | 78 | } |
95 | 79 | |
96 | 80 | function mergeAgentModelEntryForConfig(existing: unknown, incoming: unknown): unknown { |
|