fix: keep runtime model auth alias after build · openclaw/openclaw@8c95664
steipete
·
2026-05-03
·
via Recent Commits to openclaw:main
File tree
extensions/qa-lab/src/providers
| Original file line number | Diff line number | Diff line change |
|---|
@@ -32,14 +32,16 @@ describe("QA provider image generation config", () => {
|
32 | 32 | "qa-channel", |
33 | 33 | ]); |
34 | 34 | }); |
35 | | -it("uses the selected mock provider for AIMock image generation", () => { |
| 35 | +it("routes AIMock image generation through the OpenAI image provider", () => { |
36 | 36 | const patch = buildQaImageGenerationConfigPatch({ |
37 | 37 | providerMode: "aimock", |
38 | 38 | providerBaseUrl: "http://127.0.0.1:45080/v1", |
39 | 39 | requiredPluginIds: [], |
40 | 40 | }); |
41 | 41 | |
42 | | -expect(patch.agents.defaults.imageGenerationModel.primary).toBe("aimock/gpt-image-1"); |
| 42 | +expect(patch.plugins.allow).toEqual(["acpx", "memory-core", "openai"]); |
| 43 | +expect(patch.plugins.entries).toEqual({ openai: { enabled: true } }); |
| 44 | +expect(patch.agents.defaults.imageGenerationModel.primary).toBe("openai/gpt-image-1"); |
43 | 45 | expect(patch.models?.providers.aimock?.baseUrl).toBe("http://127.0.0.1:45080/v1"); |
44 | 46 | expect(patch.models?.providers["mock-openai"]).toBeUndefined(); |
45 | 47 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -45,8 +45,7 @@ export function buildQaImageGenerationConfigPatch(input: QaImageGenerationPatchI
|
45 | 45 | providerBaseUrl: input.providerBaseUrl, |
46 | 46 | }); |
47 | 47 | })(); |
48 | | -const providerPluginIds = |
49 | | -provider.usesModelProviderPlugins || usesOpenAiMockImageProvider ? [imageProviderId] : []; |
| 48 | +const providerPluginIds = imageProviderId ? [imageProviderId] : []; |
50 | 49 | const enabledPluginIds = uniqueNonEmpty(providerPluginIds); |
51 | 50 | |
52 | 51 | return { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,8 +25,9 @@ export function createMockQaProviderDefinition(
|
25 | 25 | serverLabel: params.serverLabel, |
26 | 26 | }, |
27 | 27 | defaultModel: (options) => mockModelRef(params.mode, options?.alternate), |
28 | | -defaultImageGenerationProviderIds: [], |
29 | | -defaultImageGenerationModel: () => `${params.mode}/gpt-image-1`, |
| 28 | +defaultImageGenerationProviderIds: ["openai"], |
| 29 | +defaultImageGenerationModel: ({ modelProviderIds }) => |
| 30 | +modelProviderIds.includes("openai") ? "openai/gpt-image-1" : null, |
30 | 31 | usesFastModeByDefault: () => false, |
31 | 32 | resolveModelParams: () => ({ |
32 | 33 | transport: "sse", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -74,13 +74,38 @@ export function writeStableRootRuntimeAliases(params = {}) {
|
74 | 74 | candidatesByAlias.set(aliasFileName, candidates); |
75 | 75 | } |
76 | 76 | |
| 77 | +const resolveAliasCandidate = (candidates) => { |
| 78 | +if (candidates.length === 1) { |
| 79 | +return candidates[0]; |
| 80 | +} |
| 81 | +const candidateSet = new Set(candidates); |
| 82 | +const wrappers = candidates.filter((candidate) => { |
| 83 | +const filePath = path.join(distDir, candidate); |
| 84 | +let source; |
| 85 | +try { |
| 86 | +source = fsImpl.readFileSync(filePath, "utf8"); |
| 87 | +} catch { |
| 88 | +return false; |
| 89 | +} |
| 90 | +return candidates.some( |
| 91 | +(target) => |
| 92 | +target !== candidate && |
| 93 | +candidateSet.has(target) && |
| 94 | +source.includes(`"./${target}"`) && |
| 95 | +!source.includes("\n//#region "), |
| 96 | +); |
| 97 | +}); |
| 98 | +return wrappers.length === 1 ? wrappers[0] : null; |
| 99 | +}; |
| 100 | + |
77 | 101 | for (const [aliasFileName, candidates] of candidatesByAlias) { |
78 | 102 | const aliasPath = path.join(distDir, aliasFileName); |
79 | | -if (candidates.length !== 1) { |
| 103 | +const candidate = resolveAliasCandidate(candidates); |
| 104 | +if (!candidate) { |
80 | 105 | fsImpl.rmSync?.(aliasPath, { force: true }); |
81 | 106 | continue; |
82 | 107 | } |
83 | | -writeTextFileIfChanged(aliasPath, `export * from "./${candidates[0]}";\n`); |
| 108 | +writeTextFileIfChanged(aliasPath, `export * from "./${candidate}";\n`); |
84 | 109 | } |
85 | 110 | } |
86 | 111 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -145,6 +145,28 @@ describe("runtime postbuild static assets", () => {
|
145 | 145 | await expect(fs.stat(path.join(distDir, "install.runtime.js"))).rejects.toThrow(); |
146 | 146 | }); |
147 | 147 | |
| 148 | +it("keeps stable aliases when one colliding root runtime chunk re-exports the implementation", async () => { |
| 149 | +const rootDir = createTempDir("openclaw-runtime-postbuild-"); |
| 150 | +const distDir = path.join(rootDir, "dist"); |
| 151 | +await fs.mkdir(distDir, { recursive: true }); |
| 152 | +await fs.writeFile( |
| 153 | +path.join(distDir, "runtime-model-auth.runtime-Impl123.js"), |
| 154 | +"export const auth = true;\n", |
| 155 | +"utf8", |
| 156 | +); |
| 157 | +await fs.writeFile( |
| 158 | +path.join(distDir, "runtime-model-auth.runtime-Wrap456.js"), |
| 159 | +'import { auth } from "./runtime-model-auth.runtime-Impl123.js";\nexport { auth };\n', |
| 160 | +"utf8", |
| 161 | +); |
| 162 | + |
| 163 | +writeStableRootRuntimeAliases({ rootDir }); |
| 164 | + |
| 165 | +expect(await fs.readFile(path.join(distDir, "runtime-model-auth.runtime.js"), "utf8")).toBe( |
| 166 | +'export * from "./runtime-model-auth.runtime-Wrap456.js";\n', |
| 167 | +); |
| 168 | +}); |
| 169 | + |
148 | 170 | it("rewrites root runtime imports to stable aliases", async () => { |
149 | 171 | const rootDir = createTempDir("openclaw-runtime-postbuild-"); |
150 | 172 | const distDir = path.join(rootDir, "dist"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。