mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-16 11:52:26 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
78 lines
3.2 KiB
TypeScript
78 lines
3.2 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-puter-removed-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
|
|
const { REGISTRY } = await import("../../open-sse/config/providerRegistry.ts");
|
|
const { APIKEY_PROVIDERS } = await import("../../src/shared/constants/providers.ts");
|
|
const { FREE_MODEL_BUDGETS } = await import("../../open-sse/config/freeModelCatalog.data.ts");
|
|
const { hasSpecializedExecutor } = await import("../../open-sse/executors/index.ts");
|
|
const core = await import("../../src/lib/db/core.ts");
|
|
|
|
// Regression guard: the Puter provider (id `puter`, alias `pu`,
|
|
// https://puter.com) was removed at the request of Puter's owner
|
|
// (Nariman Jelveh). It must stay out of every provider catalog, the
|
|
// executor map, and the free model catalog, and migration 152 must clean
|
|
// up any locally stored Puter configuration.
|
|
|
|
test.after(() => {
|
|
core.resetDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
});
|
|
|
|
test("puter provider is removed from the chat registry (id and alias)", () => {
|
|
assert.equal(REGISTRY["puter"], undefined);
|
|
assert.equal(REGISTRY["pu"], undefined);
|
|
});
|
|
|
|
test("puter provider is removed from the API-key provider presets", () => {
|
|
assert.equal((APIKEY_PROVIDERS as Record<string, unknown>)["puter"], undefined);
|
|
});
|
|
|
|
test("puter has no entries in the free model catalog", () => {
|
|
const offenders = FREE_MODEL_BUDGETS.filter((b) => b.provider === "puter");
|
|
assert.deepEqual(offenders, []);
|
|
});
|
|
|
|
test("puter executor is removed from the executor map (id and alias)", () => {
|
|
assert.equal(hasSpecializedExecutor("puter"), false);
|
|
assert.equal(hasSpecializedExecutor("pu"), false);
|
|
});
|
|
|
|
test("migration 152 deletes stored puter configuration and is idempotent", () => {
|
|
const db = core.getDbInstance();
|
|
|
|
const applied = db
|
|
.prepare("SELECT version FROM _omniroute_migrations WHERE version = 152")
|
|
.get() as { version: number } | undefined;
|
|
assert.ok(applied, "migration 152 must be recorded as applied");
|
|
|
|
// Simulate a pre-removal install that still has Puter configuration, then
|
|
// re-apply the migration SQL and assert every row is cleaned up.
|
|
db.prepare(
|
|
"INSERT INTO provider_connections (id, provider, auth_type, name, is_active, created_at, updated_at) VALUES (?, ?, ?, ?, 1, datetime('now'), datetime('now'))"
|
|
).run("puter-conn-test", "puter", "apikey", "puter-main");
|
|
db.prepare(
|
|
"INSERT INTO key_value (namespace, key, value) VALUES ('customModels', 'puter', '[]')"
|
|
).run();
|
|
|
|
const sql = fs.readFileSync(
|
|
path.join(process.cwd(), "src/lib/db/migrations/152_remove_puter_provider.sql"),
|
|
"utf8"
|
|
);
|
|
db.exec(sql);
|
|
db.exec(sql); // idempotent — a second run must not throw
|
|
|
|
const conn = db.prepare("SELECT id FROM provider_connections WHERE provider = 'puter'").get();
|
|
assert.equal(conn, undefined, "puter provider_connections rows must be deleted");
|
|
|
|
const custom = db
|
|
.prepare("SELECT key FROM key_value WHERE namespace = 'customModels' AND key = 'puter'")
|
|
.get();
|
|
assert.equal(custom, undefined, "puter custom models must be deleted");
|
|
});
|