mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
refactor: move model catalog refs into core package
Move model catalog ref helpers into @openclaw/model-catalog-core/model-catalog-refs and update internal callers/package-boundary aliases. Also fix the timestamp predicate typing that blocked prod type checks on current main.
This commit is contained in:
committed by
GitHub
parent
b80dcbd650
commit
4e8b74568f
@@ -108,6 +108,9 @@
|
||||
"@openclaw/model-catalog-core/configured-model-refs": [
|
||||
"../dist/plugin-sdk/packages/model-catalog-core/src/configured-model-refs.d.ts"
|
||||
],
|
||||
"@openclaw/model-catalog-core/model-catalog-refs": [
|
||||
"../dist/plugin-sdk/packages/model-catalog-core/src/model-catalog-refs.d.ts"
|
||||
],
|
||||
"@openclaw/model-catalog-core/provider-id": [
|
||||
"../dist/plugin-sdk/packages/model-catalog-core/src/provider-id.d.ts"
|
||||
],
|
||||
|
||||
@@ -117,6 +117,9 @@
|
||||
"@openclaw/model-catalog-core/configured-model-refs": [
|
||||
"../../dist/plugin-sdk/packages/model-catalog-core/src/configured-model-refs.d.ts"
|
||||
],
|
||||
"@openclaw/model-catalog-core/model-catalog-refs": [
|
||||
"../../dist/plugin-sdk/packages/model-catalog-core/src/model-catalog-refs.d.ts"
|
||||
],
|
||||
"@openclaw/model-catalog-core/provider-id": [
|
||||
"../../dist/plugin-sdk/packages/model-catalog-core/src/provider-id.d.ts"
|
||||
],
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
"import": "./dist/configured-model-refs.mjs",
|
||||
"default": "./dist/configured-model-refs.mjs"
|
||||
},
|
||||
"./model-catalog-refs": {
|
||||
"types": "./dist/model-catalog-refs.d.mts",
|
||||
"import": "./dist/model-catalog-refs.mjs",
|
||||
"default": "./dist/model-catalog-refs.mjs"
|
||||
},
|
||||
"./provider-id": {
|
||||
"types": "./dist/provider-id.d.mts",
|
||||
"import": "./dist/provider-id.mjs",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from "./configured-model-refs.js";
|
||||
export * from "./model-catalog-refs.js";
|
||||
export * from "./provider-id.js";
|
||||
export * from "./provider-model-id-normalization.js";
|
||||
export * from "./provider-model-id-normalize.js";
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildModelCatalogMergeKey, buildModelCatalogRef } from "./model-catalog-refs.js";
|
||||
|
||||
describe("model catalog refs", () => {
|
||||
it("normalizes provider ids without lowercasing model ids in refs", () => {
|
||||
expect(buildModelCatalogRef("OpenAI", "GPT-5.4")).toBe("openai/GPT-5.4");
|
||||
expect(buildModelCatalogMergeKey("OpenAI", "GPT-5.4")).toBe("openai::gpt-5.4");
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
|
||||
import { normalizeLowercaseStringOrEmpty } from "./provider-id.js";
|
||||
|
||||
export function normalizeModelCatalogProviderId(provider: string): string {
|
||||
return normalizeLowercaseStringOrEmpty(provider);
|
||||
@@ -63,6 +63,9 @@ export const EXTENSION_PACKAGE_BOUNDARY_BASE_PATHS = {
|
||||
"@openclaw/model-catalog-core/configured-model-refs": [
|
||||
"../dist/plugin-sdk/packages/model-catalog-core/src/configured-model-refs.d.ts",
|
||||
],
|
||||
"@openclaw/model-catalog-core/model-catalog-refs": [
|
||||
"../dist/plugin-sdk/packages/model-catalog-core/src/model-catalog-refs.d.ts",
|
||||
],
|
||||
"@openclaw/model-catalog-core/provider-id": [
|
||||
"../dist/plugin-sdk/packages/model-catalog-core/src/provider-id.d.ts",
|
||||
],
|
||||
|
||||
@@ -70,6 +70,7 @@ const ROOT_DTS_REQUIRED_OUTPUTS = [
|
||||
"dist/plugin-sdk/packages/terminal-core/src/terminal-link.d.ts",
|
||||
"dist/plugin-sdk/packages/terminal-core/src/theme.d.ts",
|
||||
"dist/plugin-sdk/packages/model-catalog-core/src/configured-model-refs.d.ts",
|
||||
"dist/plugin-sdk/packages/model-catalog-core/src/model-catalog-refs.d.ts",
|
||||
"dist/plugin-sdk/packages/model-catalog-core/src/provider-id.d.ts",
|
||||
"dist/plugin-sdk/packages/model-catalog-core/src/provider-model-id-normalization.d.ts",
|
||||
"dist/plugin-sdk/packages/model-catalog-core/src/provider-model-id-normalize.d.ts",
|
||||
@@ -96,6 +97,7 @@ const PACKAGE_DTS_REQUIRED_OUTPUTS = [
|
||||
"packages/plugin-sdk/dist/packages/media-generation-core/src/model-ref.d.ts",
|
||||
"packages/plugin-sdk/dist/packages/media-generation-core/src/normalization.d.ts",
|
||||
"packages/plugin-sdk/dist/packages/model-catalog-core/src/configured-model-refs.d.ts",
|
||||
"packages/plugin-sdk/dist/packages/model-catalog-core/src/model-catalog-refs.d.ts",
|
||||
"packages/plugin-sdk/dist/packages/model-catalog-core/src/provider-id.d.ts",
|
||||
"packages/plugin-sdk/dist/packages/model-catalog-core/src/provider-model-id-normalization.d.ts",
|
||||
"packages/plugin-sdk/dist/packages/model-catalog-core/src/provider-model-id-normalize.d.ts",
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { normalizeModelCatalogProviderId } from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import {
|
||||
normalizeModelCatalogProviderId,
|
||||
planManifestModelCatalogRows,
|
||||
} from "../../model-catalog/index.js";
|
||||
import { planManifestModelCatalogRows } from "../../model-catalog/index.js";
|
||||
import type { NormalizedModelCatalogRow } from "../../model-catalog/index.js";
|
||||
import { loadManifestMetadataSnapshot } from "../../plugins/manifest-contract-eligibility.js";
|
||||
import type { PluginManifestRegistry } from "../../plugins/manifest-registry.js";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { normalizeModelCatalogProviderId } from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import {
|
||||
loadOpenClawProviderIndex,
|
||||
normalizeModelCatalogProviderId,
|
||||
planProviderIndexModelCatalogRows,
|
||||
} from "../../model-catalog/index.js";
|
||||
import type { NormalizedModelCatalogRow } from "../../model-catalog/index.js";
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
export { mergeModelCatalogRowsByAuthority } from "./authority.js";
|
||||
export {
|
||||
buildModelCatalogMergeKey,
|
||||
buildModelCatalogRef,
|
||||
normalizeModelCatalogProviderId,
|
||||
} from "./refs.js";
|
||||
export { normalizeModelCatalog, normalizeModelCatalogRows } from "./normalize.js";
|
||||
export { loadOpenClawProviderIndex } from "./provider-index/index.js";
|
||||
export {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import {
|
||||
buildModelCatalogMergeKey,
|
||||
normalizeModelCatalogProviderId,
|
||||
} from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
|
||||
import { normalizeUniqueStringEntries } from "../shared/string-normalization.js";
|
||||
import { normalizeModelCatalogProviderRows } from "./normalize.js";
|
||||
import { buildModelCatalogMergeKey, normalizeModelCatalogProviderId } from "./refs.js";
|
||||
import type {
|
||||
ModelCatalog,
|
||||
ModelCatalogAlias,
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildModelCatalogMergeKey,
|
||||
buildModelCatalogRef,
|
||||
normalizeModelCatalog,
|
||||
normalizeModelCatalogRows,
|
||||
} from "./index.js";
|
||||
} from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { normalizeModelCatalog, normalizeModelCatalogRows } from "./index.js";
|
||||
|
||||
describe("model catalog normalization", () => {
|
||||
it("normalizes catalog ownership, aliases, suppressions, and row fields", () => {
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
buildModelCatalogMergeKey,
|
||||
buildModelCatalogRef,
|
||||
normalizeModelCatalogProviderId,
|
||||
} from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import {
|
||||
MODEL_APIS,
|
||||
isModelThinkingFormat,
|
||||
@@ -13,11 +18,6 @@ import {
|
||||
normalizeTrimmedStringList,
|
||||
} from "../shared/string-normalization.js";
|
||||
import { isRecord } from "../utils.js";
|
||||
import {
|
||||
buildModelCatalogMergeKey,
|
||||
buildModelCatalogRef,
|
||||
normalizeModelCatalogProviderId,
|
||||
} from "./refs.js";
|
||||
import type {
|
||||
ModelCatalog,
|
||||
ModelCatalogAlias,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { normalizeModelCatalogProviderId } from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import { normalizeModelCatalogProviderRows } from "./normalize.js";
|
||||
import type { OpenClawProviderIndex } from "./provider-index/index.js";
|
||||
import { normalizeModelCatalogProviderId } from "./refs.js";
|
||||
import type { ModelCatalogProvider, NormalizedModelCatalogRow } from "./types.js";
|
||||
|
||||
type ProviderIndexModelCatalogPlanEntry = {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { normalizeModelCatalogProviderId } from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import { parseClawHubPluginSpec } from "../../infra/clawhub-spec.js";
|
||||
import { parseRegistryNpmSpec } from "../../infra/npm-registry-spec.js";
|
||||
import { isBlockedObjectKey } from "../../infra/prototype-keys.js";
|
||||
@@ -6,7 +7,6 @@ import { normalizeOptionalString } from "../../shared/string-coerce.js";
|
||||
import { normalizeUniqueTrimmedStringList } from "../../shared/string-normalization.js";
|
||||
import { isRecord } from "../../utils.js";
|
||||
import { normalizeModelCatalog } from "../normalize.js";
|
||||
import { normalizeModelCatalogProviderId } from "../refs.js";
|
||||
import type { ModelCatalogProvider } from "../types.js";
|
||||
import type {
|
||||
OpenClawProviderIndex,
|
||||
|
||||
@@ -6,6 +6,10 @@ import { listGitTrackedFiles } from "../../test-utils/repo-files.js";
|
||||
const REPO_ROOT = path.resolve(import.meta.dirname, "../../..");
|
||||
const LEGACY_MODEL_CATALOG_BRIDGES = new Map([
|
||||
[path.join(REPO_ROOT, "src/agents/provider-id.ts"), "@openclaw/model-catalog-core/provider-id"],
|
||||
[
|
||||
path.join(REPO_ROOT, "src/model-catalog/refs.ts"),
|
||||
"@openclaw/model-catalog-core/model-catalog-refs",
|
||||
],
|
||||
[
|
||||
path.join(REPO_ROOT, "src/config/model-refs.ts"),
|
||||
"@openclaw/model-catalog-core/configured-model-refs",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { buildModelCatalogMergeKey } from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import { normalizeProviderId } from "@openclaw/model-catalog-core/provider-id";
|
||||
import { collectConfiguredAgentHarnessRuntimes } from "../agents/harness-runtimes.js";
|
||||
import {
|
||||
@@ -12,7 +13,6 @@ import {
|
||||
resolveMemoryDreamingPluginId,
|
||||
} from "../memory-host-sdk/dreaming.js";
|
||||
import { planManifestModelCatalogRows } from "../model-catalog/manifest-planner.js";
|
||||
import { buildModelCatalogMergeKey } from "../model-catalog/refs.js";
|
||||
import { isRecord } from "../shared/record-coerce.js";
|
||||
import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js";
|
||||
import { hasExplicitChannelConfig } from "./channel-presence-policy.js";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { buildModelCatalogMergeKey } from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import {
|
||||
buildModelCatalogMergeKey,
|
||||
planManifestModelCatalogSuppressions,
|
||||
type ManifestModelCatalogSuppressionEntry,
|
||||
} from "../model-catalog/index.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { normalizeModelCatalogProviderId } from "@openclaw/model-catalog-core/model-catalog-refs";
|
||||
import type { ChannelConfigRuntimeSchema } from "../channels/plugins/types.config.js";
|
||||
import { MANIFEST_KEY } from "../compat/legacy-names.js";
|
||||
import { ENV_SECRET_REF_ID_RE } from "../config/types.secrets.js";
|
||||
@@ -7,7 +8,6 @@ import { matchRootFileOpenFailure, openRootFileSync } from "../infra/boundary-fi
|
||||
import { isBlockedObjectKey } from "../infra/prototype-keys.js";
|
||||
import {
|
||||
normalizeModelCatalog,
|
||||
normalizeModelCatalogProviderId,
|
||||
type ModelCatalog,
|
||||
type ModelCatalogAlias,
|
||||
type ModelCatalogCost,
|
||||
|
||||
@@ -833,6 +833,13 @@ const WORKSPACE_PACKAGE_ALIAS_ENTRIES = [
|
||||
srcFile: "configured-model-refs.ts",
|
||||
distFile: "configured-model-refs.mjs",
|
||||
},
|
||||
{
|
||||
packageName: "@openclaw/model-catalog-core",
|
||||
packageDir: "model-catalog-core",
|
||||
subpath: "model-catalog-refs",
|
||||
srcFile: "model-catalog-refs.ts",
|
||||
distFile: "model-catalog-refs.mjs",
|
||||
},
|
||||
{
|
||||
packageName: "@openclaw/model-catalog-core",
|
||||
packageDir: "model-catalog-core",
|
||||
|
||||
@@ -247,6 +247,16 @@ export const sharedVitestConfig = {
|
||||
"configured-model-refs.ts",
|
||||
),
|
||||
},
|
||||
{
|
||||
find: "@openclaw/model-catalog-core/model-catalog-refs",
|
||||
replacement: path.join(
|
||||
repoRoot,
|
||||
"packages",
|
||||
"model-catalog-core",
|
||||
"src",
|
||||
"model-catalog-refs.ts",
|
||||
),
|
||||
},
|
||||
{
|
||||
find: "@openclaw/model-catalog-core/provider-id",
|
||||
replacement: path.join(repoRoot, "packages", "model-catalog-core", "src", "provider-id.ts"),
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
"@openclaw/model-catalog-core/configured-model-refs": [
|
||||
"./packages/model-catalog-core/src/configured-model-refs.ts"
|
||||
],
|
||||
"@openclaw/model-catalog-core/model-catalog-refs": [
|
||||
"./packages/model-catalog-core/src/model-catalog-refs.ts"
|
||||
],
|
||||
"@openclaw/model-catalog-core/provider-id": [
|
||||
"./packages/model-catalog-core/src/provider-id.ts"
|
||||
],
|
||||
|
||||
@@ -470,6 +470,7 @@ function buildModelCatalogCoreDistEntries(): Record<string, string> {
|
||||
return {
|
||||
index: "packages/model-catalog-core/src/index.ts",
|
||||
"configured-model-refs": "packages/model-catalog-core/src/configured-model-refs.ts",
|
||||
"model-catalog-refs": "packages/model-catalog-core/src/model-catalog-refs.ts",
|
||||
"provider-id": "packages/model-catalog-core/src/provider-id.ts",
|
||||
"provider-model-id-normalization":
|
||||
"packages/model-catalog-core/src/provider-model-id-normalization.ts",
|
||||
|
||||
Reference in New Issue
Block a user