Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

chore(lint): add ESLint to server and cli workspaces, enforce in CI (#1076) (#1121)

suantea (asuan_suan)08d915f5d969
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f68c7c76..b498cc9c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -40,5 +40,10 @@ jobs:
COVERAGE: ${{ matrix.node-version == '22' && '1' || '' }}
run: npm test
+ # server + cli only; the client has its own backlog of ESLint violations
+ # and is brought in under a separate change.
+ - name: Lint
+ run: npm run lint
+
- name: Build workspaces
run: npm run build
diff --git a/cli/eslint.config.js b/cli/eslint.config.js
new file mode 100644
index 00000000..8c97539c
--- /dev/null
+++ b/cli/eslint.config.js
@@ -0,0 +1,28 @@
+import js from '@eslint/js'
+import globals from 'globals'
+import tseslint from 'typescript-eslint'
+import { defineConfig, globalIgnores } from 'eslint/config'
+
+export default defineConfig([
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.ts'],
+ extends: [
+ js.configs.recommended,
+ tseslint.configs.recommended,
+ ],
+ languageOptions: {
+ ecmaVersion: 2022,
+ globals: globals.node,
+ },
+ rules: {
+ '@typescript-eslint/no-explicit-any': 'off',
+ '@typescript-eslint/no-unused-vars': ['error', {
+ argsIgnorePattern: '^_',
+ varsIgnorePattern: '^_',
+ caughtErrorsIgnorePattern: '^_',
+ }],
+ 'no-empty': ['error', { allowEmptyCatch: true }],
+ },
+ },
+])
diff --git a/cli/package.json b/cli/package.json
index d36ccebc..3f539a50 100644
--- a/cli/package.json
+++ b/cli/package.json
@@ -51,6 +51,7 @@
"scripts": {
"build": "tsc",
"test": "vitest run",
+ "lint": "eslint .",
"prepublishOnly": "npm run build && npm test"
},
"engines": {
@@ -63,6 +64,10 @@
"devDependencies": {
"@types/node": "^24.12.2",
"typescript": "~6.0.2",
- "vitest": "^3.1.3"
+ "vitest": "^3.1.3",
+ "@eslint/js": "^9.39.4",
+ "eslint": "^9.39.4",
+ "globals": "^17.4.0",
+ "typescript-eslint": "^8.58.0"
}
}
diff --git a/cli/src/tools.ts b/cli/src/tools.ts
index 1152484c..aeecba20 100644
--- a/cli/src/tools.ts
+++ b/cli/src/tools.ts
@@ -575,7 +575,7 @@ function mimo(ctx: GenerateContext): Generation {
};
}
-function cursor(ctx: GenerateContext): Generation {
+function cursor(_ctx: GenerateContext): Generation {
return {
files: [],
notes: [
diff --git a/package-lock.json b/package-lock.json
index 0eb7ba88..f701c2f9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -32,8 +32,12 @@
"freellmapi": "dist/index.js"
},
"devDependencies": {
+ "@eslint/js": "^9.39.4",
"@types/node": "^24.12.2",
+ "eslint": "^9.39.4",
+ "globals": "^17.4.0",
"typescript": "~6.0.2",
+ "typescript-eslint": "^8.58.0",
"vitest": "^3.1.3"
},
"engines": {
@@ -13282,6 +13286,7 @@
"zod": "^3.24.4"
},
"devDependencies": {
+ "@eslint/js": "^9.39.4",
"@types/better-sqlite3": "^7.6.13",
"@types/compression": "^1.7.5",
"@types/cors": "^2.8.17",
@@ -13289,8 +13294,11 @@
"@types/multer": "^2.1.0",
"@types/node": "^22.15.3",
"@vitest/coverage-v8": "^3.1.3",
+ "eslint": "^9.39.4",
+ "globals": "^17.4.0",
"tsx": "^4.19.4",
"typescript": "^5.8.3",
+ "typescript-eslint": "^8.58.0",
"vitest": "^3.1.3"
},
"engines": {
diff --git a/package.json b/package.json
index bcb4a195..f76604b2 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
"test:bootstrap": "node --test scripts/dev-bootstrap.test.mjs",
"test:hooks": "node --test .claude/hooks/contributing-check.test.mjs",
"build": "npm run build -w server && npm run build -w cli && npm run build -w client",
+ "lint": "npm run lint -w server && npm run lint -w cli",
"build:server": "npm run build -w server",
"test:migrations": "npm run test:migrations -w server",
"desktop:dev": "npm run build -w client && npm --prefix desktop run dev",
diff --git a/server/eslint.config.js b/server/eslint.config.js
new file mode 100644
index 00000000..673877f2
--- /dev/null
+++ b/server/eslint.config.js
@@ -0,0 +1,33 @@
+import js from '@eslint/js'
+import globals from 'globals'
+import tseslint from 'typescript-eslint'
+import { defineConfig, globalIgnores } from 'eslint/config'
+
+export default defineConfig([
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.ts'],
+ extends: [
+ js.configs.recommended,
+ tseslint.configs.recommended,
+ ],
+ languageOptions: {
+ ecmaVersion: 2022,
+ globals: globals.node,
+ },
+ rules: {
+ // The codebase predates ESLint and uses `any` extensively at provider/
+ // route boundaries; enforcing the ban today would be a giant unrelated
+ // refactor. Keep the rule off until that cleanup lands.
+ '@typescript-eslint/no-explicit-any': 'off',
+ // Standard test-scaffolding conventions: `_`-prefixed names are
+ // intentionally unused, and empty catch blocks assert error paths.
+ '@typescript-eslint/no-unused-vars': ['error', {
+ argsIgnorePattern: '^_',
+ varsIgnorePattern: '^_',
+ caughtErrorsIgnorePattern: '^_',
+ }],
+ 'no-empty': ['error', { allowEmptyCatch: true }],
+ },
+ },
+])
diff --git a/server/package.json b/server/package.json
index afc8050a..306e550a 100644
--- a/server/package.json
+++ b/server/package.json
@@ -11,6 +11,7 @@
"test:watch": "vitest",
"test:coverage": "vitest run --pool=forks --fileParallelism=false --coverage",
"test:migrations": "vitest run --pool=forks --fileParallelism=false src/__tests__/db/migrate/roundtrip.test.ts",
+ "lint": "eslint .",
"export-catalog": "tsx src/scripts/export-catalog.ts",
"rotate-encryption-key": "tsx src/scripts/rotate-encryption-key.ts",
"db:migration:up": "tsx src/db/migrate/cli.ts up",
@@ -34,6 +35,7 @@
"zod": "^3.24.4"
},
"devDependencies": {
+ "@eslint/js": "^9.39.4",
"@types/better-sqlite3": "^7.6.13",
"@types/compression": "^1.7.5",
"@types/cors": "^2.8.17",
@@ -41,8 +43,11 @@
"@types/multer": "^2.1.0",
"@types/node": "^22.15.3",
"@vitest/coverage-v8": "^3.1.3",
+ "eslint": "^9.39.4",
+ "globals": "^17.4.0",
"tsx": "^4.19.4",
"typescript": "^5.8.3",
+ "typescript-eslint": "^8.58.0",
"vitest": "^3.1.3"
},
"engines": {
diff --git a/server/src/__tests__/db/factory-injection.test.ts b/server/src/__tests__/db/factory-injection.test.ts
index da34c7bb..5d23f9a2 100644
--- a/server/src/__tests__/db/factory-injection.test.ts
+++ b/server/src/__tests__/db/factory-injection.test.ts
@@ -4,7 +4,6 @@ import type { Db, DbFactory } from '../../db/types.js';
// A minimal in-memory stub that satisfies the Db interface.
function makeStubDb(): Db {
- const store = new Map<string, unknown>();
return {
prepare: vi.fn().mockReturnValue({
get: vi.fn(),
diff --git a/server/src/__tests__/db/idempotency.test.ts b/server/src/__tests__/db/idempotency.test.ts
index a4b6af02..fe8bbd2f 100644
--- a/server/src/__tests__/db/idempotency.test.ts
+++ b/server/src/__tests__/db/idempotency.test.ts
@@ -1,5 +1,4 @@
import { describe, it, expect } from 'vitest';
-import Database from 'better-sqlite3';
import { initDb } from '../../db/index.js';
/**
diff --git a/server/src/__tests__/lib/fallback-loop-hedge.test.ts b/server/src/__tests__/lib/fallback-loop-hedge.test.ts
index 3ce06113..ebd6220f 100644
--- a/server/src/__tests__/lib/fallback-loop-hedge.test.ts
+++ b/server/src/__tests__/lib/fallback-loop-hedge.test.ts
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import { initDb, getDb } from '../../db/index.js';
import { runFallbackLoop, newFallbackState, type FallbackState } from '../../lib/fallback-loop.js';
import { isHedgeAbortError, newHedgeAbortError, isClientAbortError, isRetryableError } from '../../lib/error-classify.js';
-import { acquireLease, releaseLease, resetLeases, inFlightForKey } from '../../services/ratelimit.js';
+import { acquireLease, releaseLease, resetLeases } from '../../services/ratelimit.js';
import type { RouteResult } from '../../services/router.js';
/**
diff --git a/server/src/__tests__/routes/anthropic-documents.test.ts b/server/src/__tests__/routes/anthropic-documents.test.ts
index a5dcdf72..d7da98b1 100644
--- a/server/src/__tests__/routes/anthropic-documents.test.ts
+++ b/server/src/__tests__/routes/anthropic-documents.test.ts
@@ -94,7 +94,7 @@ describe('Anthropic document blocks', () => {
afterEach(() => vi.restoreAllMocks());
it('refuses a base64 PDF with an actionable error instead of answering without it', async () => {
- const captured = mockJson(OK_RESPONSE);
+ mockJson(OK_RESPONSE);
const { status, body } = await request(app, '/v1/messages', {
model: 'claude-sonnet-4-5',
diff --git a/server/src/__tests__/routes/custom-model-discovery.test.ts b/server/src/__tests__/routes/custom-model-discovery.test.ts
index 435c11d9..0cf79966 100644
--- a/server/src/__tests__/routes/custom-model-discovery.test.ts
+++ b/server/src/__tests__/routes/custom-model-discovery.test.ts
@@ -311,7 +311,7 @@ describe('median seeding for custom models (#488)', () => {
// A registered model means the probe already knows what to hit: one POST
// /chat/completions, no discovery GET. Were discovery consulted, it would
// put 'aaa-first' ahead of the registered 'relay-a'.
- const mock = vi.fn(async (url: string, init?: RequestInit) => {
+ const mock = vi.fn(async (url: string, _init?: RequestInit) => {
if (String(url).endsWith('/models')) {
return jsonResponse({ object: 'list', data: [{ id: 'aaa-first' }, { id: 'relay-a' }] });
}
diff --git a/server/src/__tests__/routes/error-handler-security.test.ts b/server/src/__tests__/routes/error-handler-security.test.ts
index 52e671f9..529693b5 100644
--- a/server/src/__tests__/routes/error-handler-security.test.ts
+++ b/server/src/__tests__/routes/error-handler-security.test.ts
@@ -1,6 +1,5 @@
import { describe, it, expect, beforeAll } from 'vitest';
import express from 'express';
-import type { Express } from 'express';
import { errorHandler } from '../../middleware/errorHandler.js';
async function triggerError(message: string, status: number) {
diff --git a/server/src/__tests__/routes/keys-import-selected-custom.test.ts b/server/src/__tests__/routes/keys-import-selected-custom.test.ts
index a61e6ff9..df65286b 100644
--- a/server/src/__tests__/routes/keys-import-selected-custom.test.ts
+++ b/server/src/__tests__/routes/keys-import-selected-custom.test.ts
@@ -1,4 +1,4 @@
-import { describe, it, expect, beforeAll, beforeEach, vi } from 'vitest';
+import { describe, it, expect, beforeAll, beforeEach } from 'vitest';
import type { Express } from 'express';
import { createApp } from '../../app.js';
import { initDb, getDb } from '../../db/index.js';
diff --git a/server/src/__tests__/routes/proxy-empty-completion.test.ts b/server/src/__tests__/routes/proxy-empty-completion.test.ts
index 5407feb8..6e327886 100644
--- a/server/src/__tests__/routes/proxy-empty-completion.test.ts
+++ b/server/src/__tests__/routes/proxy-empty-completion.test.ts
@@ -157,6 +157,7 @@ describe('Empty-completion failover', () => {
// at stream open was misclassified as mid-stream → returned to the client
// with no failover and no cooldown (observed as 17 consecutive 503s to
// the same model). With lazy headers it must take the retry path.
+ // eslint-disable-next-line require-yield -- mock stream that errors at open, no frames.
async function* failsAtOpen(): AsyncGenerator<any> {
throw new Error('OpenRouter API error 503: Provider returned error');
}
diff --git a/server/src/__tests__/routes/responses-fallback-convergence.test.ts b/server/src/__tests__/routes/responses-fallback-convergence.test.ts
index 4459dc4f..abdb6188 100644
--- a/server/src/__tests__/routes/responses-fallback-convergence.test.ts
+++ b/server/src/__tests__/routes/responses-fallback-convergence.test.ts
@@ -34,6 +34,7 @@ function fakeRoute(provider: any) {
function throwingProvider(err: any) {
return {
async chatCompletion() { throw err; },
+ // eslint-disable-next-line require-yield -- mock stream that errors immediately.
async *streamChatCompletion(): AsyncGenerator<any> { throw err; },
};
}
diff --git a/server/src/__tests__/services/embeddings.test.ts b/server/src/__tests__/services/embeddings.test.ts
index 36632a80..016e90f4 100644
--- a/server/src/__tests__/services/embeddings.test.ts
+++ b/server/src/__tests__/services/embeddings.test.ts
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import type { MockedFunction } from 'vitest';
import { initDb, getDb } from '../../db/index.js';
import { encrypt } from '../../lib/crypto.js';
-import { resolveFamily, getDefaultFamily, runEmbeddings, EmbeddingsError } from '../../services/embeddings.js';
+import { resolveFamily, getDefaultFamily, runEmbeddings } from '../../services/embeddings.js';
const realFetch = globalThis.fetch;
diff --git a/server/src/__tests__/services/media.test.ts b/server/src/__tests__/services/media.test.ts
index fa744d13..7de62660 100644
--- a/server/src/__tests__/services/media.test.ts
+++ b/server/src/__tests__/services/media.test.ts
@@ -1,7 +1,7 @@
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import { initDb, getDb } from '../../db/index.js';
import { encrypt } from '../../lib/crypto.js';
-import { runImageGeneration, runVideoGeneration, runSpeech, MediaError } from '../../services/media.js';
+import { runImageGeneration, runVideoGeneration, runSpeech } from '../../services/media.js';
const realFetch = globalThis.fetch;
diff --git a/server/src/__tests__/services/routing-exhaustion.test.ts b/server/src/__tests__/services/routing-exhaustion.test.ts
index 77925907..1cab9500 100644
--- a/server/src/__tests__/services/routing-exhaustion.test.ts
+++ b/server/src/__tests__/services/routing-exhaustion.test.ts
@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import { routeRequest, setRoutingStrategy } from '../../services/router.js';
import * as ratelimit from '../../services/ratelimit.js';
import { getDb, initDb } from '../../db/index.js';
-import * as crypto from '../../lib/crypto.js';
// Mock ratelimit to control quota availability
vi.mock('../../services/ratelimit.js', async () => {
diff --git a/server/src/db/migrations/20260101_000000_legacy_baseline.ts b/server/src/db/migrations/20260101_000000_legacy_baseline.ts
index 79fb2a04..3cd532a5 100644
--- a/server/src/db/migrations/20260101_000000_legacy_baseline.ts
+++ b/server/src/db/migrations/20260101_000000_legacy_baseline.ts
@@ -363,9 +363,6 @@ function seedModels(db: Db) {
*/
function migrateModels(db: Db) {
// 1) Replace outdated models in-place (preserves fallback_config & any references)
- const renames: Array<[string, string, string, string, number, string, number | null, number | null, number]> = [
- // platform, oldModelId, newModelId, newDisplayName, intelligenceRank, monthlyBudget, rpdLimit, contextWindow, sizeLabelPriority(unused)
- ];
const renameStmt = db.prepare(`
UPDATE models
SET model_id = ?, display_name = ?, intelligence_rank = ?,
diff --git a/server/src/db/types.ts b/server/src/db/types.ts
index 47783a21..2f98e21b 100644
--- a/server/src/db/types.ts
+++ b/server/src/db/types.ts
@@ -10,7 +10,6 @@ export interface Db {
// Mirrors better-sqlite3's pattern: transaction() wraps fn and returns a
// callable with the same signature. The F extends constraint covers both
// zero-arg transactions and the parameterised form used in routes/embeddings.
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
transaction<F extends (...args: any[]) => unknown>(fn: F): F;
pragma(source: string): unknown;
// Optional file metadata, populated when the backing store is better-sqlite3
diff --git a/server/src/lib/anthropic-documents.ts b/server/src/lib/anthropic-documents.ts
index 1542b590..d0c1c456 100644
--- a/server/src/lib/anthropic-documents.ts
+++ b/server/src/lib/anthropic-documents.ts
@@ -31,6 +31,7 @@ const TEXTUAL_SOURCE_TYPES = new Set(['text', 'content']);
const MAX_TITLE_LENGTH = 120;
/** C0 controls, DEL, and the C1 range — they can carry terminal escapes. */
+// eslint-disable-next-line no-control-regex -- matching control chars is the point.
const CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f]/g;
export interface DocumentBlockOk {
diff --git a/server/src/lib/log-redaction.ts b/server/src/lib/log-redaction.ts
index 59c9f54d..0dbcf499 100644
--- a/server/src/lib/log-redaction.ts
+++ b/server/src/lib/log-redaction.ts
@@ -21,6 +21,9 @@
import { recordConsoleLine } from './server-logs.js';
import type { ServerLogLevel } from './server-logs.js';
+/* eslint-disable no-useless-escape -- credential regexes deliberately keep
+ explicit `\-` escapes for readability; the redaction must not change. */
+
const REDACTED = '[redacted-key]';
// Ordered most-specific first: prefixed provider keys, then bearer tokens, then
diff --git a/server/src/lib/task-type.ts b/server/src/lib/task-type.ts
index 85fa8c48..9721dab1 100644
--- a/server/src/lib/task-type.ts
+++ b/server/src/lib/task-type.ts
@@ -35,7 +35,7 @@ const CODE_MARKERS: readonly RegExp[] = [
/```/,
// Shell prompt at the start of a line, followed by a command-looking word.
// The word gate keeps "$ 20 per seat" out.
- /^[ \t]*\$[ \t]+[a-z][\w.\/-]*(?=[ \t]|$)/m,
+ /^[ \t]*\$[ \t]+[a-z][\w./-]*(?=[ \t]|$)/m,
// Declarations and definitions.
/\b(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*=/,
/\bfunction\s*\*?\s*[A-Za-z_$][\w$]*\s*\(/,
@@ -52,10 +52,10 @@ const CODE_MARKERS: readonly RegExp[] = [
/\brequire\s*\(\s*['"]/,
/^[ \t]*#\s*include\s*[<"]/m,
// A source file path next to a line number: `src/router.ts:214`.
- /\b[\w.\/-]+\.(?:[jt]sx?|mjs|cjs|py|rb|go|rs|java|kt|swift|php|cs|cpp|cc|hpp|sh|sql|css|scss|html|vue|svelte|ya?ml|json|toml)\s*:\s*\d+/,
+ /\b[\w./-]+\.(?:[jt]sx?|mjs|cjs|py|rb|go|rs|java|kt|swift|php|cs|cpp|cc|hpp|sh|sql|css|scss|html|vue|svelte|ya?ml|json|toml)\s*:\s*\d+/,
// Same, for the one-letter C extensions — the base name must start with a
// letter so an enumerated prose clause ("4.c: twelve") cannot match.
- /\b[A-Za-z_][\w.\/-]*\.[ch]\s*:\s*\d+/,
+ /\b[A-Za-z_][\w./-]*\.[ch]\s*:\s*\d+/,
// Stack frames: V8 (`at fn (file.js:1:2)`), Python (`File "x.py", line 3`).
/^\s*at\s+\S.*\(.*:\d+:\d+\)/m,
/^\s*File\s+"[^"\n]+",\s*line\s+\d+/m,
diff --git a/server/src/providers/sail.ts b/server/src/providers/sail.ts
index fe0b7aff..ea078f8f 100644
--- a/server/src/providers/sail.ts
+++ b/server/src/providers/sail.ts
@@ -237,18 +237,16 @@ export class SailProvider extends BaseProvider {
if (ms <= 0) return;
if (signal?.aborted) throw signal.reason ?? new Error('Sail request aborted');
await new Promise<void>((resolve, reject) => {
- let timer: ReturnType<typeof setTimeout>;
- let onAbort: () => void;
const finish = (error?: unknown) => {
clearTimeout(timer);
signal?.removeEventListener('abort', onAbort);
if (error !== undefined) reject(error);
else resolve();
};
- onAbort = () => {
+ const onAbort = () => {
finish(signal?.reason ?? new Error('Sail request aborted'));
};
- timer = setTimeout(() => finish(), ms);
+ const timer = setTimeout(() => finish(), ms);
signal?.addEventListener('abort', onAbort, { once: true });
});
}
diff --git a/server/src/routes/keys.ts b/server/src/routes/keys.ts
index 00c003a7..8cea9e45 100644
--- a/server/src/routes/keys.ts
+++ b/server/src/routes/keys.ts
@@ -10,9 +10,7 @@ import { parseKeysFromFile, stripJsoncComments, stripTrailingCommas } from '../l
import { assessProviderUrl } from '../lib/url-guard.js';
import { verifyCredentials } from '../services/auth.js';
import { getActiveCooldownsForKeys, clearCooldownsForKey } from '../services/ratelimit.js';
-import { ensureModelInProfiles } from '../services/profile-models.js';
import { resolveCustomEndpointKey, customEndpointKeyIds, siblingEndpointKeyId, endpointHasCredential } from '../services/custom-endpoint.js';
-import { customModelSeed } from '../services/custom-model-seed.js';
import { registerCustomModels, registerCustomChatModels } from '../services/custom-model-register.js';
import { registerCustomMediaModel } from '../services/custom-media-register.js';
import { discoverEndpointModels, probeEndpointModel, classifyModelId, ModelDiscoveryError } from '../services/model-discovery.js';
@@ -1325,7 +1323,6 @@ keysRouter.post('/import-selected', async (req: Request, res: Response) => {
}
let imported = 0;
- let duplicateSkipped = 0;
let modelsRegistered = 0;
const errors: Array<{ key: string; error: string }> = [];
@@ -1387,7 +1384,6 @@ keysRouter.post('/import-selected', async (req: Request, res: Response) => {
}
if (existingKeys.has(key.keyValue.trim())) {
- duplicateSkipped++;
errors.push({ key: keyName, error: 'Duplicate key — already exists' });
continue;
}
diff --git a/server/src/routes/proxy.ts b/server/src/routes/proxy.ts
index 9c0882d9..369eeb0c 100644
--- a/server/src/routes/proxy.ts
+++ b/server/src/routes/proxy.ts
@@ -2,9 +2,8 @@ import crypto from 'crypto';
import { Router } from 'express';
import type { Request, Response } from 'express';
import { z } from 'zod';
-import type { ChatMessage, ChatToolCall, ModelListRow, TokenUsage } from '@freellmapi/shared/types.js';
-import { routeRequest, resolveRoutingChain, resolveModelGroupCandidates, resolveStickyPreference, recordRateLimitHit, recordSuccess, hasEnabledVisionModel, hasEnabledToolsModel, hasOtherUsableKey, routingReserveTokens, type RouteResult, type ResolvedChain, type ChainRow } from '../services/router.js';
-import { recordRequest, recordTokens, setCooldown, getCooldownDurationForLimit, PAYMENT_REQUIRED_COOLDOWN_MS, MODEL_FORBIDDEN_COOLDOWN_MS, learnLimitFromError } from '../services/ratelimit.js';
+import type { ChatMessage, ChatToolCall, TokenUsage } from '@freellmapi/shared/types.js';
+import { type RouteResult, type ResolvedChain, type ChainRow, routeRequest, resolveRoutingChain, resolveModelGroupCandidates, resolveStickyPreference, hasEnabledVisionModel, hasEnabledToolsModel, routingReserveTokens } from '../services/router.js';
import { runEmbeddings, EmbeddingsError } from '../services/embeddings.js';
import { runImageGeneration, runVideoGeneration, runSpeech, runTranscription, MediaError, MAX_TRANSCRIPTION_BYTES } from '../services/media.js';
import multer from 'multer';
diff --git a/server/src/services/compression/engines/toolfilter.ts b/server/src/services/compression/engines/toolfilter.ts
index 4553b291..c1f3996c 100644
--- a/server/src/services/compression/engines/toolfilter.ts
+++ b/server/src/services/compression/engines/toolfilter.ts
@@ -6,6 +6,7 @@ import { BUILTIN_FILTERS, type ToolFilterRule } from './filter-definitions.js';
import { loadCustomFilters } from './custom-filters.js';
import type { CompressionEngine, ToolCallOrigin } from '../types.js';
+// eslint-disable-next-line no-control-regex -- matching ANSI escapes is the point.
const ANSI_RE = /\u001b\[[0-?]*[ -/]*[@-~]/g;
export const ERROR_GUARD_RE = /\b(?:error|exception|fatal|failed|failure|traceback|panic|assert(?:ion)?|not ok|✗|×)\b/i;
diff --git a/server/src/services/model-groups.ts b/server/src/services/model-groups.ts
index bebadaf8..6b8e61ad 100644
--- a/server/src/services/model-groups.ts
+++ b/server/src/services/model-groups.ts
@@ -166,13 +166,6 @@ export function qualifiedMemberId(row: GroupableRow): string | null {
return qualifiedModelMemberId(row.platform, row.model_id, row.endpoint_scope);
}
-// The grouping token for a row, after applying overrides. Split wins first
-// (forces a singleton/explicit key); then a merge redirects to its target;
-// otherwise the normalized display name.
-function tokenForRow(row: GroupableRow, ov: UnifyOverrides): string {
- return tokenSourceForRow(row, ov).token;
-}
-
/** The grouping token plus whether an operator override chose it. */
function tokenSourceForRow(row: GroupableRow, ov: UnifyOverrides): { token: string; userDefined: boolean } {
const mid = memberId(row);