import assert from "node:assert/strict"; import test from "node:test"; import { createDiscoveredModelId } from "../src/components/admin/model-id.ts"; const providerA = "11111111-1111-4111-8111-111111111111"; const providerB = "22222222-2222-4222-8222-222222222222"; test("discovered model IDs are deterministic, distinct, and API-compatible", async () => { const inputs = [ [providerA, "gpt-4o"], [providerB, "gpt-4o"], [providerA, "GPT-4o"], [providerA, " gpt-4o"], [providerA, "gpt-4o "], [providerA, "模型-α"], ] as const; const ids = await Promise.all(inputs.map(([providerId, providerModel]) => createDiscoveredModelId(providerId, providerModel))); assert.equal(new Set(ids).size, inputs.length); assert.equal(ids[0], "m-f1966f65ba46e2c192e274f77c120dbc90f32e6caa2bcd75bb52e4f985b8cb"); assert.equal(await createDiscoveredModelId(providerA, "gpt-4o"), ids[0]); for (const id of ids) { assert.equal(id.length, 64); assert.match(id, /^m-[0-9a-f]{62}$/); } });