mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-05-05 09:46:30 +00:00
Introduce a runtime settings layer that hydrates persisted config at startup and reapplies aliases, payload rules, cache behavior, CLI compatibility, usage tuning, and related switches when settings change or SQLite updates. Replace the legacy prompt injection middleware path with a guardrail registry that supports prompt injection detection, PII masking, disabled guardrail overrides, and post-call response handling across the chat pipeline. Add a metadata registry for model catalog and alias resolution so catalog endpoints return enriched capabilities plus diagnostic headers and typed alias errors instead of ad hoc responses. Convert unsupported built-in web_search tools into an OmniRoute fallback tool, execute them through builtin skills, and preserve Responses API function call output with sanitized usage fields. Centralize provider header fingerprints for GitHub, Cursor, Qwen, Qoder, Kiro, and Antigravity, and migrate management passwords from env or plaintext storage into persisted bcrypt hashes during startup and login.
68 lines
3.3 KiB
TypeScript
68 lines
3.3 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
CURSOR_REGISTRY_VERSION,
|
|
GITHUB_COPILOT_API_VERSION,
|
|
GITHUB_COPILOT_CHAT_PLUGIN_VERSION,
|
|
GITHUB_COPILOT_CHAT_USER_AGENT,
|
|
GITHUB_COPILOT_EDITOR_VERSION,
|
|
GITHUB_COPILOT_REFRESH_PLUGIN_VERSION,
|
|
GITHUB_COPILOT_REFRESH_USER_AGENT,
|
|
KIRO_AMZ_USER_AGENT,
|
|
KIRO_SDK_USER_AGENT,
|
|
QODER_DASHSCOPE_COMPAT_USER_AGENT,
|
|
QWEN_CLI_USER_AGENT,
|
|
getCursorUsageHeaders,
|
|
getGitHubCopilotChatHeaders,
|
|
getGitHubCopilotInternalUserHeaders,
|
|
getGitHubCopilotRefreshHeaders,
|
|
getKiroServiceHeaders,
|
|
getQoderDashscopeCompatHeaders,
|
|
getQwenOauthHeaders,
|
|
} from "../../open-sse/config/providerHeaderProfiles.ts";
|
|
|
|
test("provider header profiles expose current GitHub chat and internal headers", () => {
|
|
const chatHeaders = getGitHubCopilotChatHeaders("text/event-stream", "agent");
|
|
assert.equal(chatHeaders["editor-version"], GITHUB_COPILOT_EDITOR_VERSION);
|
|
assert.equal(chatHeaders["editor-plugin-version"], GITHUB_COPILOT_CHAT_PLUGIN_VERSION);
|
|
assert.equal(chatHeaders["user-agent"], GITHUB_COPILOT_CHAT_USER_AGENT);
|
|
assert.equal(chatHeaders["x-github-api-version"], GITHUB_COPILOT_API_VERSION);
|
|
assert.equal(chatHeaders["X-Initiator"], "agent");
|
|
assert.equal(chatHeaders.Accept, "text/event-stream");
|
|
|
|
const internalHeaders = getGitHubCopilotInternalUserHeaders("token gh-access");
|
|
assert.equal(internalHeaders.Authorization, "token gh-access");
|
|
assert.equal(internalHeaders["User-Agent"], GITHUB_COPILOT_CHAT_USER_AGENT);
|
|
assert.equal(internalHeaders["Editor-Version"], GITHUB_COPILOT_EDITOR_VERSION);
|
|
assert.equal(internalHeaders["Editor-Plugin-Version"], GITHUB_COPILOT_CHAT_PLUGIN_VERSION);
|
|
assert.equal(internalHeaders["X-GitHub-Api-Version"], GITHUB_COPILOT_API_VERSION);
|
|
});
|
|
|
|
test("provider header profiles expose dedicated refresh, qwen, qoder, kiro and cursor variants", () => {
|
|
const refreshHeaders = getGitHubCopilotRefreshHeaders("token gh-access");
|
|
assert.equal(refreshHeaders.Authorization, "token gh-access");
|
|
assert.equal(refreshHeaders["User-Agent"], GITHUB_COPILOT_REFRESH_USER_AGENT);
|
|
assert.equal(refreshHeaders["Editor-Version"], GITHUB_COPILOT_EDITOR_VERSION);
|
|
assert.equal(refreshHeaders["Editor-Plugin-Version"], GITHUB_COPILOT_REFRESH_PLUGIN_VERSION);
|
|
|
|
const qwenHeaders = getQwenOauthHeaders();
|
|
assert.equal(qwenHeaders["User-Agent"], QWEN_CLI_USER_AGENT);
|
|
assert.equal(qwenHeaders["X-Dashscope-UserAgent"], QWEN_CLI_USER_AGENT);
|
|
assert.equal(qwenHeaders["X-Stainless-Package-Version"], "5.11.0");
|
|
|
|
const qoderHeaders = getQoderDashscopeCompatHeaders();
|
|
assert.equal(qoderHeaders["user-agent"], QODER_DASHSCOPE_COMPAT_USER_AGENT);
|
|
assert.equal(qoderHeaders["x-dashscope-useragent"], QODER_DASHSCOPE_COMPAT_USER_AGENT);
|
|
|
|
const kiroHeaders = getKiroServiceHeaders("application/json");
|
|
assert.equal(kiroHeaders.Accept, "application/json");
|
|
assert.equal(kiroHeaders["User-Agent"], KIRO_SDK_USER_AGENT);
|
|
assert.equal(kiroHeaders["X-Amz-User-Agent"], KIRO_AMZ_USER_AGENT);
|
|
|
|
const cursorHeaders = getCursorUsageHeaders("cursor-token");
|
|
assert.equal(cursorHeaders.Authorization, "Bearer cursor-token");
|
|
assert.equal(cursorHeaders["User-Agent"], `Cursor/${CURSOR_REGISTRY_VERSION}`);
|
|
assert.equal(cursorHeaders["x-cursor-user-agent"], `Cursor/${CURSOR_REGISTRY_VERSION}`);
|
|
assert.equal(cursorHeaders["x-cursor-client-version"], CURSOR_REGISTRY_VERSION);
|
|
});
|