mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:20:43 +00:00
feat: Add /models add hot-reload model registration (#70211)
* feat(models): add chat model registration with hot reload * docs(changelog): add models entry for pr 70211 * fix(models): harden add flow follow-ups * fix models add review follow-ups * harden models add config writes * tighten plugin boundary invariant * move models add adapters behind sdk facades * avoid ollama-specific core facade
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
import { createExtensionImportBoundaryChecker } from "./lib/extension-import-boundary-checker.mjs";
|
||||
import { runAsScript } from "./lib/ts-guard-utils.mjs";
|
||||
|
||||
const ALLOWED_EXTENSION_PUBLIC_SURFACE_RE = /^extensions\/[^/]+\/(?:api|runtime-api)\.js$/;
|
||||
|
||||
const checker = createExtensionImportBoundaryChecker({
|
||||
roots: ["src"],
|
||||
boundaryLabel: "src",
|
||||
@@ -10,6 +12,9 @@ const checker = createExtensionImportBoundaryChecker({
|
||||
cleanMessage: "No src import boundary violations found.",
|
||||
inventoryTitle: "Src extension import boundary inventory:",
|
||||
skipSourcesWithoutBundledPluginPrefix: true,
|
||||
allowResolvedPath(resolvedPath) {
|
||||
return ALLOWED_EXTENSION_PUBLIC_SURFACE_RE.test(resolvedPath);
|
||||
},
|
||||
shouldSkipFile(relativeFile) {
|
||||
return (
|
||||
relativeFile.endsWith(".test.ts") ||
|
||||
|
||||
@@ -38,7 +38,7 @@ function classifyResolvedExtensionReason(kind, boundaryLabel) {
|
||||
return `${verb} bundled plugin file from ${boundaryLabel} boundary`;
|
||||
}
|
||||
|
||||
function scanImportBoundaryViolations(sourceFile, filePath, boundaryLabel) {
|
||||
function scanImportBoundaryViolations(sourceFile, filePath, boundaryLabel, allowResolvedPath) {
|
||||
const entries = [];
|
||||
const relativeFile = normalizeRepoPath(repoRoot, filePath);
|
||||
|
||||
@@ -47,6 +47,9 @@ function scanImportBoundaryViolations(sourceFile, filePath, boundaryLabel) {
|
||||
if (!resolvedPath?.startsWith(BUNDLED_PLUGIN_PATH_PREFIX)) {
|
||||
return;
|
||||
}
|
||||
if (allowResolvedPath?.(resolvedPath, { kind, specifier, file: relativeFile })) {
|
||||
return;
|
||||
}
|
||||
entries.push({
|
||||
file: relativeFile,
|
||||
line: toLine(sourceFile, specifierNode),
|
||||
@@ -74,7 +77,12 @@ export function createExtensionImportBoundaryChecker(params) {
|
||||
files,
|
||||
compareEntries,
|
||||
collectEntries(sourceFile, filePath) {
|
||||
return scanImportBoundaryViolations(sourceFile, filePath, params.boundaryLabel);
|
||||
return scanImportBoundaryViolations(
|
||||
sourceFile,
|
||||
filePath,
|
||||
params.boundaryLabel,
|
||||
params.allowResolvedPath,
|
||||
);
|
||||
},
|
||||
shouldParseSource: params.skipSourcesWithoutBundledPluginPrefix
|
||||
? (source) => source.includes(BUNDLED_PLUGIN_PATH_PREFIX)
|
||||
|
||||
Reference in New Issue
Block a user