Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- **cursor:** vision (`image_url`) input for the Cursor provider — OpenAI image parts are encoded as `SelectedContext.selected_images[]` in the `agent.v1` protobuf, plus a tool-commit directive (lifts composer-2.5's tool-call rate), `tool_choice` none/required/specific handling, and `response_format`/`max_tokens`/`stop` output constraints surfaced to the agent. Hardened with SSRF + DNS-rebinding guards, a 1 MiB pre-decode cap, and a protobuf length-overrun check. (#3104 — thanks @payne0420)
- **deepseek-web:** opt-in persistent session + rolling-window conversation memory (`persistSession`, `historyWindow` per-connection settings) and bidirectional tool-call translation — tool schemas are injected as a system prompt and `<tool>{…}</tool>` blocks in the reply are parsed back into OpenAI `tool_calls` (replacing the old hard `400`). ([#2942](https://github.com/diegosouzapw/OmniRoute/issues/2942), [#2820](https://github.com/diegosouzapw/OmniRoute/issues/2820))
- **i18n:** Turkish locale-aware search & sorting — a `turkishText` helper (`normalizeForSearch`, `matchesSearch`, `compareTr`) folds the dotted/dotless İ/ı correctly and uses `Intl.Collator("tr")`, wired across dashboard search/sort call-sites with an ESLint guard (warn) against raw `toLowerCase().includes()`. (#3115 — thanks @osrt91)
- **kiro:** add Claude Opus 4.8 to the Kiro (AWS CodeWhisperer) model catalog — Kiro previously topped out at Opus 4.7 even though Opus 4.8 was already defined and served by the `claude` provider. (#3131 — thanks @artickc)

### 🔧 Bug Fixes

Expand All @@ -44,11 +45,14 @@
- **cli:** handle Windows `.exe` healthchecks with spaces in the path — direct executables skip the shell (so `cmd.exe` doesn't split `C:\…\Name With Spaces\…\claude.exe`) while `.cmd`/`.bat` wrappers still run through it. (#3111 — thanks @EmpRider)
- **cli:** don't write `STORAGE_ENCRYPTION_KEY` to `.env` on informational commands — `omniroute --version`/`--help` no longer generate a key or create `~/.omniroute/.env`; provisioning is scoped to commands that actually touch encrypted storage (#3129).
- **tests:** remove a stale lowercase `db-apikeys-crud.test.ts` duplicate that collided with the canonical `db-apiKeys-crud.test.ts` on case-insensitive filesystems (no coverage lost). (#3125 — thanks @juandisay)
- **kimi:** add a dedicated `KimiExecutor` so Kimi thinking-mode responses no longer drop `reasoning_content` — the reasoning stream is now surfaced instead of being lost. (#3132 — thanks @bypanghu)
- **handler:** provide a `connectionId` fallback when it is undefined, fixing kilo (kilocode) calls that were silently not being written to `call_logs`. (#3130 — thanks @androw)

### 🔧 Build

- **build-output-isolation:** unified standalone assembly into one shared `assembleStandalone` module; isolated build output into `.build/` (intermediates, gitignored) and `dist/` (shippable bundle, gitignored), replacing the old repo-root `app/` and `.next/` directories; dropped the duplicate `next build` that prepublish previously ran; added `build:release` script for a clean rebuild with a `dist/BUILD_SHA` HEAD sentinel that guards against deploying stale bundles. **Operators using custom `app/` paths:** the published bundle directory on the VPS image (`/usr/lib/node_modules/omniroute/app/`) is unchanged — only the in-repo build output path moved. Update any local scripts that reference the repo-local `app/` build output to `dist/` instead.
- **build:** re-apply the build-reorg follow-ups that landed after the main refactor merged — the `serve` CLI now falls back from `dist/` to the legacy `app/` location for upgrade safety, and the deploy skills `pm2 stop` before `rsync --delete` to avoid a transient `Cannot find module ./chunks/…` race (#3127).
- **build:** fix the standalone static-asset path so the dashboard renders after the build-output reorg — `assembleStandalone` was copying `static/` into `<bundle>/.next/static`, but the standalone server (built with `distDir=.build/next`) serves `/_next/static` from `<bundle>/.build/next/static`, so every JS/CSS chunk 404'd and the login UI rendered as a blank page. The static (and `required-server-files.json` / Turbopack chunk) destinations are now derived from the configured `distDir` instead of a hard-coded `.next`.

### 📦 Dependencies

Expand All @@ -62,7 +66,7 @@

Huge thanks to everyone whose work shipped in v3.8.9:

@branben (Obsidian context source), @oyi77 (claude-web 403 fix, autoCombo connection rotation), @xz-dev (SiliconFlow model sync), @nmime (open opaque tool schemas), @payne0420 (Cursor vision input), @mgarmash (image-gen fetch timeout), @yinaoxiong (Codex native passthrough tools/history), @0xtbug (logs page perf), @EmpRider (Windows CLI healthcheck paths), @ahmet-cetinkaya (Antigravity 429 retry bound + quota lockout), @juandisay (duplicate test cleanup), and @osrt91 (Turkish locale-aware search & sorting).
@branben (Obsidian context source), @oyi77 (claude-web 403 fix, autoCombo connection rotation), @xz-dev (SiliconFlow model sync), @nmime (open opaque tool schemas), @payne0420 (Cursor vision input), @mgarmash (image-gen fetch timeout), @yinaoxiong (Codex native passthrough tools/history), @0xtbug (logs page perf), @EmpRider (Windows CLI healthcheck paths), @ahmet-cetinkaya (Antigravity 429 retry bound + quota lockout), @juandisay (duplicate test cleanup), @osrt91 (Turkish locale-aware search & sorting), @artickc (Kiro Opus 4.8 catalog), @bypanghu (Kimi thinking-mode reasoning_content fix), and @androw (connectionId fallback + kilo call logging).

And thank you to the OmniRoute community for the bug reports, reproductions, and testing that drove these fixes. 🎉

Expand Down
28 changes: 20 additions & 8 deletions scripts/build/assembleStandalone.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,13 @@
* @param {string} outDir - assembled standalone output directory
* @returns {number} number of path replacements made
*/
export function assemblePathSanitize(projectRoot, outDir) {
export function assemblePathSanitize(projectRoot, outDir, distDir = ".next") {
const buildRoot = projectRoot.replace(/\\/g, "/"); // normalise for regex safety

Check warning on line 287 in scripts/build/assembleStandalone.mjs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `String#replaceAll()` over `String#replace()`.

See more on https://sonarcloud.io/project/issues?id=diegosouzapw_OmniRoute&issues=AZ6Rku6hHTnZ1Z9U8PoM&open=AZ6Rku6hHTnZ1Z9U8PoM&pullRequest=3135
const sanitizeTargets = [
path.join(outDir, "server.js"),
path.join(outDir, ".next", "required-server-files.json"),
// required-server-files.json lives under the distDir (e.g. .build/next), not
// a literal .next — the standalone preserves the configured distDir path.
path.join(outDir, distDir, "required-server-files.json"),
];
Comment on lines +286 to 293

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If distDir is passed as an absolute path, path.join(outDir, distDir, ...) will produce an incorrect path (e.g., outDir/absolute/path/...), causing fsSync.existsSync to fail and silently skipping the sanitization of required-server-files.json.

Since assemblePathSanitize has access to projectRoot, we can defensively normalize distDir to be relative to projectRoot if it is absolute.

Suggested change
export function assemblePathSanitize(projectRoot, outDir, distDir = ".next") {
const buildRoot = projectRoot.replace(/\\/g, "/"); // normalise for regex safety
const sanitizeTargets = [
path.join(outDir, "server.js"),
path.join(outDir, ".next", "required-server-files.json"),
// required-server-files.json lives under the distDir (e.g. .build/next), not
// a literal .next — the standalone preserves the configured distDir path.
path.join(outDir, distDir, "required-server-files.json"),
];
export function assemblePathSanitize(projectRoot, outDir, distDir = ".next") {
const buildRoot = projectRoot.replace(/\\/g, "/"); // normalise for regex safety
const relDistDir = path.isAbsolute(distDir) ? path.relative(projectRoot, distDir) : distDir;
const sanitizeTargets = [
path.join(outDir, "server.js"),
// required-server-files.json lives under the distDir (e.g. .build/next), not
// a literal .next — the standalone preserves the configured distDir path.
path.join(outDir, relDistDir, "required-server-files.json"),
];


let sanitisedCount = 0;
Expand All @@ -295,7 +297,7 @@
if (!fsSync.existsSync(filePath)) continue;
let content = fsSync.readFileSync(filePath, "utf8");
// Escape special regex characters in the path
const escaped = buildRoot.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");

Check warning on line 300 in scripts/build/assembleStandalone.mjs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

`String.raw` should be used to avoid escaping `\`.

See more on https://sonarcloud.io/project/issues?id=diegosouzapw_OmniRoute&issues=AZ6Rku6hHTnZ1Z9U8PoN&open=AZ6Rku6hHTnZ1Z9U8PoN&pullRequest=3135
const re = new RegExp(escaped, "g");
const matches = content.match(re);
if (matches) {
Expand All @@ -316,8 +318,8 @@
* @param {string} outDir - assembled standalone output directory
* @returns {{ patchedFiles: number, patchedMatches: number }}
*/
export function patchTurbopackChunks(outDir) {
const serverOutput = path.join(outDir, ".next", "server");
export function patchTurbopackChunks(outDir, distDir = ".next") {
const serverOutput = path.join(outDir, distDir, "server");
const HASH_RE = /(['"\\])([a-z@][a-z0-9@./_-]+?-[0-9a-f]{16}(?:\/[^'"\\]+)?)\1/g;
let patchedFiles = 0;
let patchedMatches = 0;
Expand Down Expand Up @@ -381,7 +383,7 @@
* @param {boolean} [opts.copyNatives] - copy native assets + extra modules (default true)
* @returns {void}
*/
export function assembleStandalone({

Check failure on line 386 in scripts/build/assembleStandalone.mjs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 29 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=diegosouzapw_OmniRoute&issues=AZ6Rku6hHTnZ1Z9U8PoO&open=AZ6Rku6hHTnZ1Z9U8PoO&pullRequest=3135
distDir,
outDir,
projectRoot = process.cwd(),
Expand All @@ -392,6 +394,12 @@
if (!distDir) throw new Error("[assembleStandalone] distDir is required");
if (!outDir) throw new Error("[assembleStandalone] outDir is required");

// The standalone bundle preserves the distDir path RELATIVE to projectRoot
// (the server's baked config uses e.g. "./.build/next"), so output dest paths
// for static / required-server-files / server chunks must use the relative
// distDir appended to outDir — never the absolute build-machine distDir.
const relDistDir = path.isAbsolute(distDir) ? path.relative(projectRoot, distDir) : distDir;

const standaloneDir = path.resolve(path.join(distDir, "standalone"));
Comment on lines +573 to 579

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If distDir is relative and projectRoot is different from process.cwd(), path.resolve(path.join(distDir, "standalone")) will resolve against process.cwd() instead of projectRoot. This can lead to incorrect path resolution in monorepos or custom build environments.

We should resolve distDir against projectRoot first if it is relative, and then derive relDistDir and standaloneDir from it.

Suggested change
// The standalone bundle preserves the distDir path RELATIVE to projectRoot
// (the server's baked config uses e.g. "./.build/next"), so output dest paths
// for static / required-server-files / server chunks must use the relative
// distDir appended to outDir — never the absolute build-machine distDir.
const relDistDir = path.isAbsolute(distDir) ? path.relative(projectRoot, distDir) : distDir;
const standaloneDir = path.resolve(path.join(distDir, "standalone"));
// The standalone bundle preserves the distDir path RELATIVE to projectRoot
// (the server's baked config uses e.g. "./.build/next"), so output dest paths
// for static / required-server-files / server chunks must use the relative
// distDir appended to outDir — never the absolute build-machine distDir.
const resolvedDistDir = path.isAbsolute(distDir) ? distDir : path.resolve(projectRoot, distDir);
const relDistDir = path.relative(projectRoot, resolvedDistDir);
const standaloneDir = path.join(resolvedDistDir, "standalone");

const resolvedOutDir = path.resolve(outDir);
if (!fsSync.existsSync(standaloneDir)) {
Expand Down Expand Up @@ -425,9 +433,13 @@
}
}

// 2. Copy <distDir>/static -> resolvedOutDir/.next/static
// 2. Copy <distDir>/static -> resolvedOutDir/<distDir>/static
// CRITICAL: the standalone server.js is built with distDir baked into its config
// (e.g. "./.build/next"), so it serves /_next/static from <outDir>/<distDir>/static,
// NOT a literal <outDir>/.next/static. Copying to .next/static leaves the server's
// static dir empty → every JS/CSS chunk 404s → blank page. Mirror the distDir path.
const staticSrc = path.join(distDir, "static");
const staticDest = path.join(resolvedOutDir, ".next", "static");
const staticDest = path.join(resolvedOutDir, relDistDir, "static");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure correct path resolution when projectRoot is different from process.cwd() and distDir is relative, staticSrc should be resolved using resolvedDistDir instead of distDir.

Suggested change
const staticSrc = path.join(distDir, "static");
const staticDest = path.join(resolvedOutDir, ".next", "static");
const staticDest = path.join(resolvedOutDir, relDistDir, "static");
const staticSrc = path.join(resolvedDistDir, "static");
const staticDest = path.join(resolvedOutDir, relDistDir, "static");

if (fsSync.existsSync(staticSrc)) {
fsSync.mkdirSync(path.dirname(staticDest), { recursive: true });
fsSync.cpSync(staticSrc, staticDest, { recursive: true, force: true });
Expand All @@ -442,15 +454,15 @@

// 4. Optionally sanitize abs paths
if (sanitizePaths) {
const count = assemblePathSanitize(projectRoot, resolvedOutDir);
const count = assemblePathSanitize(projectRoot, resolvedOutDir, relDistDir);
if (count > 0) {
console.log(`[assembleStandalone] Sanitised ${count} hardcoded path references`);
}
}

// 5. Optionally patch Turbopack hashed chunks
if (doPatchChunks) {
const { patchedFiles, patchedMatches } = patchTurbopackChunks(resolvedOutDir);
const { patchedFiles, patchedMatches } = patchTurbopackChunks(resolvedOutDir, relDistDir);
if (patchedMatches > 0) {
console.log(
`[assembleStandalone] Hash-strip: patched ${patchedMatches} hashed require() in ${patchedFiles} server chunk file(s)`
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/build/assemble-standalone.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ test("assembleStandalone copies standalone + static + public + sidecars into out
assembleStandalone({ distDir, outDir, projectRoot: tmp, sanitizePaths: false, copyNatives: false });

assert.ok(fs.existsSync(path.join(outDir, "server.js")), "server.js copied");
assert.ok(fs.existsSync(path.join(outDir, ".next/static/x.js")), "static copied");
// Static lands under the distDir path (.build/next/static), where the standalone
// server.js — built with distDir baked into its config — serves /_next/static from.
assert.ok(
fs.existsSync(path.join(outDir, ".build/next/static/x.js")),
"static copied under distDir"
);
assert.ok(
!fs.existsSync(path.join(outDir, ".next/static/x.js")),
"static is NOT placed under a literal .next (would 404 against distDir server)"
);
assert.ok(fs.existsSync(path.join(outDir, "public/logo.svg")), "public copied");
fs.rmSync(tmp, { recursive: true, force: true });
});