mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-10-19 05:20:05 +00:00
Thanks @Junior-HJ! This adds CodeBuddy international (codebuddy-intl / cbai), splitting the CN and intl modules over shared executor, OAuth, usage and token-refresh helpers. Your commits are kept intact. Maintainer fix-up commits on top: restored the 'N AI providers' wording that the count bump had turned into bare numbers in 67 llm.txt files, README alt texts and SVGs; synced the total to 372, since the tip had meanwhile added typesafe without regenerating the reference; typed the two `any` casts in codebuddyDeviceAuth.ts; and regenerated the executor-map and translate-path goldens. The translate-path golden had been generated on win32. Protected surfaces (AGENTS.md, llm.txt) carry the count change only, approved by the owner. Validated: typecheck:core, open-sse typecheck, file-size, t11 any-budget, ESLint, check:docs-all, provider consistency/assets/order/provenance, and 195/195 focused tests across 13 files.
30 lines
1.4 KiB
TypeScript
30 lines
1.4 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, resolve } from "node:path";
|
|
|
|
// Regression guard for the device-code provider that returned "ошибка сервера OmniRoute":
|
|
//
|
|
// codebuddy-cn— the Tencent state endpoint reads `platform` from the QUERY string, not the JSON
|
|
// body; body-only returned 400 "platform is empty" (verified live). The fix passes
|
|
// it as a query param. Guard: requestDeviceCode builds the URL with ?platform=.
|
|
//
|
|
// Source-level: the real validation is the live upstream 200 (can't be hit from CI); these pin
|
|
// the exact change so a revert to the broken host / body-only platform fails here.
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const read = (p: string) => readFileSync(resolve(here, "../..", p), "utf8");
|
|
|
|
test("codebuddy-cn device-code sends platform as a query param (not body-only)", () => {
|
|
const cb = read("src/lib/oauth/providers/codebuddyDeviceAuth.ts");
|
|
assert.match(
|
|
cb,
|
|
/\?platform=\$\{encodeURIComponent\(config\.platform\)\}/,
|
|
"platform query param"
|
|
);
|
|
});
|
|
|
|
test("codebuddy-intl device-code re-uses the shared query-param platform flow", () => {
|
|
const intl = read("src/lib/oauth/providers/codebuddy-intl.ts");
|
|
assert.match(intl, /codebuddyDeviceAuth/, "re-uses shared requestDeviceCode implementation");
|
|
});
|