mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-07 15:52:52 +03:00
* test: resolve typescript strictness complaints in unit tests * Update Claude Code obfuscation to version 2.1.114 (#1403) * fix(cloud-code): scope thinking stripping to executor boundaries (#1401) * fix(cloud-code): scope thinking stripping to executors * fix(cloud-code): guard antigravity normalized body * Update Claude Code obfuscation to version 2.1.114 - Update Claude Code version from 2.1.87 to 2.1.114 - Update X-Stainless-Package-Version from 0.80.0 to 0.81.0 - Add new beta flags: redact-thinking-2026-02-12, advisor-tool-2026-03-01, advanced-tool-use-2025-11-20 - Add missing headers: anthropic-version, anthropic-dangerous-direct-browser-access, x-app, X-Stainless-Timeout - Add all X-Stainless-* headers (Arch, Lang, OS, Runtime, Runtime-Version, Retry-Count) - Fix accept-encoding header: identity -> gzip, deflate, br, zstd - Add connection: keep-alive header - Update tool name mapping: add lsp, apply_patch, websearch These changes ensure that requests from OpenCode through Omniroute are indistinguishable from genuine Claude Code 2.1.114 requests, allowing proper authentication with Anthropic's API without triggering extra credits errors. * fix: resolve CodeQL password hash alert and TruffleHog CI failure --------- Co-authored-by: Randi <55005611+rdself@users.noreply.github.com> Co-authored-by: Diego Rodrigues de Sa e Souza <8016841+diegosouzapw@users.noreply.github.com> Co-authored-by: Nikolay Popov <ekklesio.dev@gmail.com> Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> * fix(claude-code): scope obfuscation to cli clients and fix tests * docs(workflows): enforce PR merge instead of manual close * docs(changelog): update 3.6.9 notes with missing PR 1403 and fixes * docs(workflows): update generate-release to use full changelog for PR body * fix(tsc): silence baseUrl deprecation warnings for TS 5.5+ * fix(chatcore): apply proactive compression before provider translation (#1406) Integrated into release/v3.6.9 * docs(changelog): add PR 1406 * Makes text visible in dark-mode (#1409) Integrated into release/v3.6.9 * docs(changelog): add PR 1409 * chore: save local work * chore(release): sync version references to 3.6.9 * fix(codex): prevent proactive token refresh consumption and strip background parameter * ci: shard long-running suites and relax timeouts * ci: allow manual CI dispatch for release branches * feat(skills): provider-aware marketplace UX, scored AUTO injection, and memory pipeline hardening (#1411) * fix/400 for GeminiCLI(add "ref" in GEMINI_UNSUPPORTED_SCHEMA_KEYS) * feat(cc-compatible): align request shape with Claude CLI * fix(cc-compatible): add Claude CLI system skeleton for OpenAI input * preserve reasoning when translating chat to responses (#1414) Integrated into release/v3.6.9 * fix(skills): optimize AUTO scoring and include Responses input context (#1418) Integrated into release/v3.6.9 * chore: fix TS errors and update review-prs workflow * fix(api): stop sending unsupported Gemini and Codex parameters Prevent Gemini request translation from injecting default thoughtSignature values that the upstream API strictly validates and rejects. Only preserve real signatures resolved from prior upstream responses, and strip additionalProperties from Gemini function schemas to avoid 400 "Unknown name" errors. Also remove fallback-injected session_id and conversation_id fields before sending Codex requests, and restore compatibility with the legacy OUTBOUND_SSRF_GUARD_ENABLED flag when determining whether private provider URLs are allowed. Updates the Gemini translator and regression tests for issue #1410 and related 400 error cases. * fix(core): stabilization fixes for token refresh, usage translation, and testing - Update Codex token refresh detection logic - Mark provider connections invalid on unrecoverable refresh error - Fix Claude usage translation under-reporting cached tokens - Update test expectations - Update CHANGELOG.md for v3.6.9 * fix(auth): reload fresh token state and unify expiry persistence Refresh checks now re-read the latest stored provider connection before attempting rotation so they do not use stale refresh tokens captured by an earlier sweep. Token updates also persist both expiresAt and tokenExpiresAt across the health check, usage-limit refresh path, and SSE refresh flow. This keeps known token expiry metadata in sync and avoids interval-based refreshes for connections whose tokens are still valid well into the future. * fix: resolve SSRF environment static evaluation bug (#1427) Fix import aliases and strict TS typings for tests and ACP agents. * test: resolve remaining strict type errors in test files * test: fix provider service assertion for anthropic-compatible header * fix(codex): respect openaiStoreEnabled setting during native passthrough (#1432) * fix(codex): fix token refresh unrecoverable detection for expired tokens * fix(ci): restore release v3.6.9 build and flaky tests * fix(cc-compatible): trim default OpenAI system skeleton (#1433) Integrated into release/v3.6.9 * fix: prevent masked API keys from being written to CLI tool configs (#1435) * feat: mark Qwen provider as deprecated and add deprecation warning to CLI tool (#1437) * docs(changelog): comprehensive v3.6.9 update with all 59 commits since v3.6.8 * test(ci): align qwen guide settings assertions * fix(security): resolve CodeQL alert 163 for incomplete URL sanitization in Qwen CLI settings --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: Nikolay Popov <74762779+nikolay-popov-ideogram@users.noreply.github.com> Co-authored-by: Randi <55005611+rdself@users.noreply.github.com> Co-authored-by: Nikolay Popov <ekklesio.dev@gmail.com> Co-authored-by: Paijo <14921983+oyi77@users.noreply.github.com> Co-authored-by: Tim Massey <tim-massey@users.noreply.github.com> Co-authored-by: Paijo <oyi77@users.noreply.github.com> Co-authored-by: dail45 <dail45@yandex.ru> Co-authored-by: R.D. <rogerproself@gmail.com>
308 lines
9.3 KiB
TypeScript
308 lines
9.3 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 tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-skillssh-"));
|
|
const originalDataDir = process.env.DATA_DIR;
|
|
process.env.DATA_DIR = tmpDir;
|
|
|
|
const core = await import("../../src/lib/db/core.ts");
|
|
const settingsDb = await import("../../src/lib/db/settings.ts");
|
|
const { skillRegistry } = await import("../../src/lib/skills/registry.ts");
|
|
const { searchSkillsSh, fetchSkillMd, SkillsShSearchResponseSchema, SkillsShSkillSchema } =
|
|
await import("../../src/lib/skills/skillssh.ts");
|
|
const searchRoute = await import("../../src/app/api/skills/skillssh/route.ts");
|
|
const installRoute = await import("../../src/app/api/skills/skillssh/install/route.ts");
|
|
|
|
function clearSkillRegistry() {
|
|
skillRegistry.registeredSkills?.clear?.();
|
|
skillRegistry.versionCache?.clear?.();
|
|
}
|
|
|
|
function resetStorage() {
|
|
core.resetDbInstance();
|
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
clearSkillRegistry();
|
|
core.getDbInstance();
|
|
}
|
|
|
|
const originalFetch = globalThis.fetch;
|
|
|
|
test.beforeEach(async () => {
|
|
resetStorage();
|
|
await settingsDb.updateSettings({ skillsProvider: "skillssh", requireLogin: false });
|
|
globalThis.fetch = originalFetch;
|
|
});
|
|
|
|
test.after(() => {
|
|
core.resetDbInstance();
|
|
clearSkillRegistry();
|
|
globalThis.fetch = originalFetch;
|
|
process.env.DATA_DIR = originalDataDir;
|
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
});
|
|
|
|
// ── Zod schema validation tests ──
|
|
|
|
test("SkillsShSkillSchema parses a valid skill object", () => {
|
|
const result = SkillsShSkillSchema.parse({
|
|
id: "supabase/agent-skills/supabase-postgres",
|
|
skillId: "supabase-postgres",
|
|
name: "Supabase Postgres",
|
|
installs: 42,
|
|
source: "supabase/agent-skills",
|
|
});
|
|
assert.equal(result.id, "supabase/agent-skills/supabase-postgres");
|
|
assert.equal(result.installs, 42);
|
|
});
|
|
|
|
test("SkillsShSkillSchema defaults installs to 0 when missing", () => {
|
|
const result = SkillsShSkillSchema.parse({
|
|
id: "x/y/z",
|
|
skillId: "z",
|
|
name: "Z Skill",
|
|
source: "x/y",
|
|
});
|
|
assert.equal(result.installs, 0);
|
|
});
|
|
|
|
test("SkillsShSearchResponseSchema parses a full response", () => {
|
|
const result = SkillsShSearchResponseSchema.parse({
|
|
query: "postgres",
|
|
searchType: "text",
|
|
skills: [{ id: "a/b/c", skillId: "c", name: "C", source: "a/b" }],
|
|
count: 1,
|
|
duration_ms: 50,
|
|
});
|
|
assert.equal(result.skills.length, 1);
|
|
assert.equal(result.count, 1);
|
|
});
|
|
|
|
test("SkillsShSearchResponseSchema defaults skills to empty array", () => {
|
|
const result = SkillsShSearchResponseSchema.parse({});
|
|
assert.deepEqual(result.skills, []);
|
|
});
|
|
|
|
// ── searchSkillsSh tests ──
|
|
|
|
test("searchSkillsSh returns parsed results on success", async () => {
|
|
const mockPayload = {
|
|
query: "test",
|
|
searchType: "text",
|
|
skills: [
|
|
{
|
|
id: "owner/repo/skill-a",
|
|
skillId: "skill-a",
|
|
name: "Skill A",
|
|
installs: 10,
|
|
source: "owner/repo",
|
|
},
|
|
],
|
|
count: 1,
|
|
duration_ms: 12,
|
|
};
|
|
|
|
globalThis.fetch = async (url) => {
|
|
assert.ok(url.includes("skills.sh/api/search"));
|
|
assert.ok(url.includes("q=test"));
|
|
return new Response(JSON.stringify(mockPayload), { status: 200 });
|
|
};
|
|
|
|
const result = await searchSkillsSh("test", 10);
|
|
assert.equal(result.skills.length, 1);
|
|
assert.equal(result.skills[0].skillId, "skill-a");
|
|
});
|
|
|
|
test("searchSkillsSh throws on non-ok response", async () => {
|
|
globalThis.fetch = async () => new Response("Server Error", { status: 500 });
|
|
|
|
await assert.rejects(
|
|
() => searchSkillsSh("fail"),
|
|
(err) => err.message.includes("skills.sh API error: 500")
|
|
);
|
|
});
|
|
|
|
// ── fetchSkillMd tests ──
|
|
|
|
test("fetchSkillMd returns SKILL.md content on success", async () => {
|
|
const mdContent = "# My Skill\nDoes things.";
|
|
globalThis.fetch = async (url) => {
|
|
const u = new URL(url.toString());
|
|
assert.equal(u.hostname, "raw.githubusercontent.com");
|
|
assert.ok(u.pathname.includes("/owner/repo/main/skills/my-skill/SKILL.md"));
|
|
return new Response(mdContent, { status: 200 });
|
|
};
|
|
|
|
const result = await fetchSkillMd("owner/repo", "my-skill");
|
|
assert.equal(result, mdContent);
|
|
});
|
|
|
|
test("fetchSkillMd throws on 404", async () => {
|
|
globalThis.fetch = async () => new Response("Not Found", { status: 404 });
|
|
|
|
await assert.rejects(
|
|
() => fetchSkillMd("owner/repo", "missing-skill"),
|
|
(err) => err.message.includes("Failed to fetch SKILL.md: 404")
|
|
);
|
|
});
|
|
|
|
// ── GET /api/skills/skillssh route tests ──
|
|
|
|
test("skillssh search route returns skills from the API", async () => {
|
|
const mockPayload = {
|
|
query: "docker",
|
|
searchType: "text",
|
|
skills: [
|
|
{
|
|
id: "o/r/docker-skill",
|
|
skillId: "docker-skill",
|
|
name: "Docker Skill",
|
|
installs: 5,
|
|
source: "o/r",
|
|
},
|
|
{
|
|
id: "o/r/compose-skill",
|
|
skillId: "compose-skill",
|
|
name: "Compose Skill",
|
|
installs: 3,
|
|
source: "o/r",
|
|
},
|
|
],
|
|
count: 2,
|
|
duration_ms: 8,
|
|
};
|
|
|
|
globalThis.fetch = async () => new Response(JSON.stringify(mockPayload), { status: 200 });
|
|
|
|
const req = new Request("http://localhost/api/skills/skillssh?q=docker&limit=10");
|
|
const res = await searchRoute.GET(req);
|
|
const body = await res.json();
|
|
|
|
assert.equal(res.status, 200);
|
|
assert.equal(body.skills.length, 2);
|
|
assert.equal(body.skills[0].name, "Docker Skill");
|
|
assert.equal(body.skills[1].skillId, "compose-skill");
|
|
});
|
|
|
|
test("skillssh search route returns 500 when upstream fails", async () => {
|
|
globalThis.fetch = async () => new Response("Bad Gateway", { status: 502 });
|
|
|
|
const req = new Request("http://localhost/api/skills/skillssh?q=broken");
|
|
const res = await searchRoute.GET(req);
|
|
const body = await res.json();
|
|
|
|
assert.equal(res.status, 500);
|
|
assert.ok(body.error.includes("skills.sh API error"));
|
|
});
|
|
|
|
// ── POST /api/skills/skillssh/install route tests ──
|
|
|
|
test("skillssh install route registers a skill from skills.sh", async () => {
|
|
const mdContent = "# Docker Best Practices\nContent here.";
|
|
|
|
globalThis.fetch = async (url) => {
|
|
if (new URL(url.toString()).hostname === "raw.githubusercontent.com") {
|
|
return new Response(mdContent, { status: 200 });
|
|
}
|
|
return new Response("Not Found", { status: 404 });
|
|
};
|
|
|
|
const req = new Request("http://localhost/api/skills/skillssh/install", {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json" },
|
|
body: JSON.stringify({
|
|
name: "docker-best-practices",
|
|
description: "Docker best practices skill",
|
|
source: "owner/repo",
|
|
skillId: "docker-best-practices",
|
|
version: "1.0.0",
|
|
}),
|
|
});
|
|
|
|
const res = await installRoute.POST(req);
|
|
const body = await res.json();
|
|
|
|
assert.equal(res.status, 200);
|
|
assert.equal(body.success, true);
|
|
assert.ok(body.id);
|
|
|
|
// Verify the skill was registered with correct metadata
|
|
const skills = skillRegistry.list();
|
|
const installed = skills.find((s) => s.name === "docker-best-practices");
|
|
assert.ok(installed);
|
|
assert.equal(installed.apiKeyId, "skillssh");
|
|
assert.ok(installed.handler.includes("Installed from skills.sh"));
|
|
assert.ok(installed.handler.includes(mdContent));
|
|
});
|
|
|
|
test("skillssh install route returns 400 for invalid payload", async () => {
|
|
const req = new Request("http://localhost/api/skills/skillssh/install", {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json" },
|
|
body: JSON.stringify({
|
|
name: "",
|
|
description: "Missing name",
|
|
source: "owner/repo",
|
|
skillId: "something",
|
|
}),
|
|
});
|
|
|
|
const res = await installRoute.POST(req);
|
|
assert.equal(res.status, 400);
|
|
});
|
|
|
|
test("skillssh install route returns 500 when SKILL.md fetch fails", async () => {
|
|
globalThis.fetch = async () => new Response("Not Found", { status: 404 });
|
|
|
|
const req = new Request("http://localhost/api/skills/skillssh/install", {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json" },
|
|
body: JSON.stringify({
|
|
name: "missing-skill",
|
|
description: "Skill that does not exist",
|
|
source: "owner/repo",
|
|
skillId: "nonexistent",
|
|
}),
|
|
});
|
|
|
|
const res = await installRoute.POST(req);
|
|
const body = await res.json();
|
|
|
|
assert.equal(res.status, 500);
|
|
assert.ok(body.error.includes("Failed to fetch SKILL.md"));
|
|
});
|
|
|
|
test("skillssh install route defaults version to 1.0.0 when omitted", async () => {
|
|
globalThis.fetch = async (url) => {
|
|
if (new URL(url.toString()).hostname === "raw.githubusercontent.com") {
|
|
return new Response("# Skill Content", { status: 200 });
|
|
}
|
|
return new Response("Not Found", { status: 404 });
|
|
};
|
|
|
|
const req = new Request("http://localhost/api/skills/skillssh/install", {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json" },
|
|
body: JSON.stringify({
|
|
name: "version-default-test",
|
|
description: "Test version default",
|
|
source: "owner/repo",
|
|
skillId: "vd-test",
|
|
}),
|
|
});
|
|
|
|
const res = await installRoute.POST(req);
|
|
const body = await res.json();
|
|
|
|
assert.equal(res.status, 200);
|
|
assert.equal(body.success, true);
|
|
|
|
const skills = skillRegistry.list();
|
|
const installed = skills.find((s) => s.name === "version-default-test");
|
|
assert.ok(installed);
|
|
assert.equal(installed.version, "1.0.0");
|
|
});
|