diff --git a/src/lib/guardrails/visionBridge.ts b/src/lib/guardrails/visionBridge.ts index 34fa2f10bd..33801b4810 100644 --- a/src/lib/guardrails/visionBridge.ts +++ b/src/lib/guardrails/visionBridge.ts @@ -28,6 +28,11 @@ export { isProviderConnectionUsable, hasUsableCredentialsForModel }; type ComboVisionBridgeDecision = "process" | "skip" | "not-combo"; +export function resolveVisionComboName(mapping: Record): string | null { + const comboName = mapping.comboName ?? mapping.name ?? null; + return typeof comboName === "string" && comboName.length > 0 ? comboName : null; +} + /// Check if a combo model should trigger vision bridge processing. /// Resolves combo targets and returns: /// - "process" if any target cannot be proven vision-capable @@ -45,7 +50,7 @@ async function getComboVisionBridgeDecision(model: string): Promise { assert.strictEqual(guardrail.enabled, false); }); +test("resolveVisionComboName accepts only non-empty string mapping names", () => { + assert.equal(resolveVisionComboName({ comboName: "vision-fallback" }), "vision-fallback"); + assert.equal(resolveVisionComboName({ name: "legacy-fallback" }), "legacy-fallback"); + assert.equal(resolveVisionComboName({ comboName: { nested: true } }), null); + assert.equal(resolveVisionComboName({ comboName: 42 }), null); + assert.equal(resolveVisionComboName({ comboName: "" }), null); +}); + // ── VB-S05: Vision Bridge disabled via settings ──────────────────────────── test("VB-S05: passthroughs when visionBridgeEnabled is false", async () => {