mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 12:22:14 +03:00
* chore(release): open v3.8.13 development cycle Bump 3.8.12 → 3.8.13 across package.json, lockfile, electron/, open-sse/, and docs/reference/openapi.yaml; add the [3.8.13] cycle placeholder to the root CHANGELOG and the 41 i18n mirrors. Integration branch for the v3.8.13 cycle — fixes/features land here via per-issue PRs and it merges to main at release time. * fix(ci): skip auto-deploy when VPS host is unreachable from the runner (#3299) Integrated into release/v3.8.13 * fix(dev): auto-rebuild better-sqlite3 on Node ABI mismatch at dev startup (#3301) Integrated into release/v3.8.13 * feat(api): accept path-scoped API keys on client API routes (#3300) Integrated into release/v3.8.13 * fix(sse): harden against empty responses causing Copilot Chat failures (#3297) Integrated into release/v3.8.13 * fix(api): remove Completions.me rickroll provider (discussion #3293) (#3302) Integrated into release/v3.8.13 * fix(opencode-provider): extract contextLength from live model catalog (#3298) Integrated into release/v3.8.13 * feat(web-cookie): self-service login infrastructure + auto-refresh daemon (#3292) Integrated into release/v3.8.13 * docs(changelog): record the v3.8.13 PRs merged this round (#3292/#3300/#3297/#3298/#3301/#3302/#3299) * fix(auth): harden URL token extraction — drop query-string fallback, gate to client routes (security follow-up to #3300) (#3309) Security follow-up to #3300 — integrated into release/v3.8.13 * docs: rename resolve-issues → review-issues skill references * fix(dashboard): keep no-auth providers visible under 'Show configured only' (#3290) (#3312) no-auth providers (opencode, duckduckgo-web, theoldllm, veoaifree-web) never create a DB connection row so stats.total stays 0, which the configured-only filter treated as 'unconfigured' and hid them — even though they are always usable and appear unconditionally in /v1/models. filterConfiguredProviderEntries now treats displayAuthType === 'no-auth' as configured. Co-authored-by: uniQta <uniQta@users.noreply.github.com> * fix(cli): resolve update paths relative to script + recursive backup (#3295) (#3313) omniroute update always failed on a global install: - getCurrentVersion() read package.json from process.cwd(), which on a global npm/brew install is the user's working dir, not the package root → null → 'Could not determine current version'. - createBackup() resolved bin/ from cwd too, and passed the 'cli' directory to copyFileSync → EISDIR, swallowed by the catch → 'Failed to create backup'. Both now resolve package.json/bin relative to the script via import.meta.url, and the backup uses cpSync({recursive:true}) so the cli/ directory is copied. Co-authored-by: uniQta <uniQta@users.noreply.github.com> * fix(theoldllm): read upstream body once to avoid [502] body-already-read (#3296) (#3314) On the cached-token path the executor never enters the refresh branch, so the same upstream Response was read with .text() twice (token-rejection check + final body). A Response body is single-use, so the second read threw 'Body is unusable: Body has already been read', caught and surfaced as [502]. Read the body once into finalBody and only re-read after a token-rejection refetch. Co-authored-by: onizukashonan14-png <onizukashonan14-png@users.noreply.github.com> * fix(sse): strip leaked internal tool envelopes from streaming output (#3311) Integrated into release/v3.8.13 * fix(sse): expose Claude + Gemini budget tiers in the antigravity catalog (#3184) (#3303) Integrated into release/v3.8.13 (#3184) * fix(catalog): compute combo context_length from known targets only (#3304) Integrated into release/v3.8.13 — live contextLength + known-targets combo context (#3298 follow-up) * chore(i18n): add message keys for proxy UI + vscode/ollama endpoint (#3307) Integrated into release/v3.8.13 — i18n message keys for proxy UI + vscode/ollama * feat(dashboard): i18n the proxy settings UI (#3310) Integrated into release/v3.8.13 — i18n the proxy settings UI * feat(api): model catalog enrichment + MCP model-catalog tools (#3306) Integrated into release/v3.8.13 — model catalog enrichment + MCP model-catalog tools, reconciled with #3309 URL-token hardening * test(catalog): align Antigravity preview-alias test with #3303 budget tiers #3303 added the Gemini `-high`/`-low` budget tiers to ANTIGRAVITY_PUBLIC_MODELS (user-callable on the Antigravity OAuth backend, verified via #3184), but did not update the catalog-route test that asserted `antigravity/gemini-3.1-pro-high` must NOT be exposed. The assertion now reflects the intended behavior — the client-visible budget alias IS surfaced — while keeping the legacy `gemini-claude-*` alias keys unexposed. Caught running the full catalog suite on the merged release HEAD (the #3303 round only ran the antigravity-aliases and usage-hardening files). * docs(changelog): record the 6 PRs merged this review round into v3.8.13 #3306/#3307/#3310 (New Features — VS Code split: catalog+MCP, i18n keys, proxy UI i18n), #3311/#3303/#3304 (Bug Fixes — SSE envelope sanitizer, antigravity budget tiers, combo known-targets context_length). * chore(release): finalize v3.8.13 changelog and cleanup Finalize the v3.8.13 changelog with release date, maintenance notes, and contributor credits. Update MCP docs to reference the correct tool inventory diagram, exclude nested .claude worktrees from ESLint scans, and tighten a response sanitizer type guard. * fix(dashboard): refresh connections after provider auth import (#3320) Integrated into release/v3.8.13 — refresh connections after provider auth import * fix(codex): strip client-only params on native /responses passthrough (#3317) (#3325) A /v1/responses request against the built-in codex/ provider does an openai-responses -> openai-responses passthrough (CodexExecutor.transformRequest returns the body early for _nativeCodexPassthrough). It forwarded client-only fields verbatim and the Codex upstream rejected them with 400 Unsupported parameter: prompt_cache_retention / safety_identifier / user — breaking Factory Droid (which injects all three). The chat-completions path already strips these (base.ts #1884, openai-responses translator #2770) but the passthrough skips translation. Strip the three fields in the shared block before the passthrough return; user is removed unconditionally since Codex /responses always rejects it. Co-authored-by: tycronk20 <tycronk20@users.noreply.github.com> * fix(dashboard): normalize agent-bridge /state response to stop page crash (#3318) (#3326) The Agent Bridge page seeded a well-shaped initialData default then replaced it wholesale with the raw /api/tools/agent-bridge/state response. The route returns { server, agents } but the UI reads { serverState, agentStates, bypassPatterns, mappings }, so serverState became undefined and AgentBridgeServerCard crashed on serverState.running — surfaced as the full-page 'Internal Server Error' boundary (client render error, not a real 5xx). Add a shared normalizeAgentBridgeState() that maps the route shape into the page contract (server.running/certExists -> serverState) and always returns safe defaults (never undefined serverState). Wired into both the SSR loader (page.tsx) and the polling hook. The legacy 'agents' entry shape differs from AgentStateEntry so it is not coerced; full route<->page contract reconciliation (port, upstreamCa, bypassPatterns, mappings, agentStates) is a follow-up. Co-authored-by: tycronk20 <tycronk20@users.noreply.github.com> * docs: VS Code/Ollama endpoints + env & i18n tooling (#3319) Integrated into release/v3.8.13 — VS Code/Ollama docs + env & i18n tooling * feat(provider): test-all endpoint, rate-limit overrides, visibility f… (#3267) Integrated into release/v3.8.13 — provider test-all endpoint, rate-limit overrides, model visibility * feat: auto-combo optimization, playground model dropdown, only-configured toggle (#3322) Integrated into release/v3.8.13 — auto-combo candidate expansion + playground dropdown + only-configured toggle * feat(api): VS Code Copilot Ollama-compatible BYOK endpoint (#3316) Integrated into release/v3.8.13 — VS Code Copilot Ollama-compatible BYOK endpoint (reconciled with #3306/#3309 auth hardening) * chore(release): document #3320 in the v3.8.13 changelog + contributor credits --------- Co-authored-by: Felipe Almeman <4226997+zhiru@users.noreply.github.com> Co-authored-by: Wilson <pedbookmed@gmail.com> Co-authored-by: Hernan Javier Ardila Sanchez <hjasgr@gmail.com> Co-authored-by: Paijo <14921983+oyi77@users.noreply.github.com> Co-authored-by: uniQta <uniQta@users.noreply.github.com> Co-authored-by: onizukashonan14-png <onizukashonan14-png@users.noreply.github.com> Co-authored-by: tycronk20 <tycronk20@users.noreply.github.com> Co-authored-by: Vinayrnani <vinayrnani@gmail.com>
189 lines
5.9 KiB
JavaScript
189 lines
5.9 KiB
JavaScript
import { printHeading, printInfo, printSuccess, printError } from "../io.mjs";
|
|
import { homedir } from "node:os";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { execFile } from "node:child_process";
|
|
import { promisify } from "node:util";
|
|
import { t } from "../i18n.mjs";
|
|
|
|
const execFileAsync = promisify(execFile);
|
|
|
|
// This file lives at <pkgRoot>/bin/cli/commands/update.mjs — resolve package
|
|
// paths relative to the script, NOT process.cwd(). On a global npm/brew install
|
|
// the user's cwd is not the package root, so cwd-relative lookups break (#3295).
|
|
const SCRIPT_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
const PKG_ROOT = path.resolve(SCRIPT_DIR, "..", "..", "..");
|
|
const BIN_DIR = path.join(PKG_ROOT, "bin");
|
|
|
|
export async function getCurrentVersion() {
|
|
try {
|
|
const { readFileSync } = await import("node:fs");
|
|
const pkg = JSON.parse(readFileSync(path.join(PKG_ROOT, "package.json"), "utf-8"));
|
|
return pkg.version;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
async function getLatestVersion() {
|
|
try {
|
|
const { stdout } = await execFileAsync("npm", ["view", "omniroute", "version"], {
|
|
timeout: 15000,
|
|
});
|
|
return stdout.trim();
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function compareVersions(a, b) {
|
|
const pa = a.split(".").map(Number);
|
|
const pb = b.split(".").map(Number);
|
|
for (let i = 0; i < 3; i++) {
|
|
if ((pa[i] || 0) > (pb[i] || 0)) return 1;
|
|
if ((pa[i] || 0) < (pb[i] || 0)) return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
export async function createBackup() {
|
|
const binPath = BIN_DIR;
|
|
const backupDir = path.join(homedir(), ".omniroute", "backups", `omniroute-${Date.now()}`);
|
|
|
|
try {
|
|
const { mkdirSync, cpSync, existsSync } = await import("node:fs");
|
|
if (!existsSync(binPath)) return null;
|
|
|
|
mkdirSync(backupDir, { recursive: true });
|
|
const files = ["omniroute.mjs", "cli", "nodeRuntimeSupport.mjs", "mcp-server.mjs"];
|
|
for (const f of files) {
|
|
const src = path.join(binPath, f);
|
|
if (existsSync(src)) {
|
|
// cpSync handles both files and directories; the old copyFileSync threw
|
|
// EISDIR on the "cli" directory, which was swallowed by the catch (#3295).
|
|
cpSync(src, path.join(backupDir, f), { recursive: true });
|
|
}
|
|
}
|
|
return backupDir;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function registerUpdate(program) {
|
|
program
|
|
.command("update")
|
|
.description(t("update.checking"))
|
|
.option("--check", "Check for available update — exit 0 if up-to-date, exit 1 if outdated")
|
|
.option("--apply", "Install latest version automatically (npm install -g)")
|
|
.option("--changelog", "Show changelog for the latest release")
|
|
.option("--dry-run", "Show what would be updated without applying")
|
|
.option("--no-backup", "Skip backup creation")
|
|
.option("--yes", "Skip confirmation prompt")
|
|
.action(async (opts, cmd) => {
|
|
const globalOpts = cmd.optsWithGlobals();
|
|
const exitCode = await runUpdateCommand({ ...opts, output: globalOpts.output });
|
|
if (exitCode !== 0) process.exit(exitCode);
|
|
});
|
|
}
|
|
|
|
export async function runUpdateCommand(opts = {}) {
|
|
const checkOnly = opts.check ?? false;
|
|
const applyNow = opts.apply ?? false;
|
|
const showChangelog = opts.changelog ?? false;
|
|
const dryRun = opts.dryRun ?? false;
|
|
const skipBackup = !(opts.backup ?? true);
|
|
const skipConfirm = opts.yes ?? applyNow;
|
|
|
|
const current = await getCurrentVersion();
|
|
const latest = await getLatestVersion();
|
|
|
|
if (!current) {
|
|
printError("Could not determine current version");
|
|
return 1;
|
|
}
|
|
|
|
if (!latest) {
|
|
printError("Could not check latest version. Is npm available?");
|
|
return 1;
|
|
}
|
|
|
|
if (showChangelog) {
|
|
try {
|
|
const { stdout } = await execFileAsync("npm", ["view", "omniroute", "changelog"], {
|
|
timeout: 10000,
|
|
});
|
|
if (stdout.trim()) {
|
|
console.log(stdout.trim());
|
|
} else {
|
|
console.log(`Changelog: https://github.com/your-org/omniroute/releases/tag/v${latest}`);
|
|
}
|
|
} catch {
|
|
console.log(`Changelog: https://github.com/your-org/omniroute/releases/tag/v${latest}`);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
printHeading("OmniRoute Update");
|
|
console.log(` Current version: ${current}`);
|
|
console.log(` Latest version: ${latest}`);
|
|
|
|
const cmp = compareVersions(current, latest);
|
|
if (cmp >= 0) {
|
|
printSuccess("You are running the latest version!");
|
|
return 0;
|
|
}
|
|
|
|
console.log(`\n Update available: ${current} → ${latest}`);
|
|
|
|
if (checkOnly) {
|
|
console.log("\n Run `omniroute update --apply` to install automatically.");
|
|
return 1; // exit 1 = outdated (useful for scripts)
|
|
}
|
|
|
|
if (dryRun) {
|
|
console.log("\n [DRY RUN] Would run: npm install -g omniroute@latest");
|
|
if (!skipBackup) console.log(" [DRY RUN] Would create backup in ~/.omniroute/backups/");
|
|
return 0;
|
|
}
|
|
|
|
if (!skipBackup) {
|
|
printInfo("Creating backup...");
|
|
const backupPath = await createBackup();
|
|
if (backupPath) {
|
|
printSuccess(`Backup created: ${backupPath}`);
|
|
} else {
|
|
printError("Failed to create backup. Aborting update.");
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
if (!skipConfirm) {
|
|
const readline = await import("node:readline");
|
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
const answer = await new Promise((resolve) =>
|
|
rl.question(`Proceed with update to ${latest}? [y/N] `, resolve)
|
|
);
|
|
rl.close();
|
|
if (!/^y(es)?$/i.test(answer)) {
|
|
printInfo("Update aborted.");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
printInfo("Updating OmniRoute...");
|
|
try {
|
|
const { execSync } = await import("child_process");
|
|
execSync("npm install -g omniroute@latest", { stdio: "inherit" });
|
|
printSuccess(`Updated to version ${latest}`);
|
|
printInfo("Run `omniroute --version` to verify.");
|
|
return 0;
|
|
} catch (err) {
|
|
printError(`Update failed: ${err.message}`);
|
|
printInfo("Restore from backup:");
|
|
const backupDir = path.join(homedir(), ".omniroute", "backups");
|
|
printInfo(` ls ${backupDir}`);
|
|
return 1;
|
|
}
|
|
}
|