mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
* chore(rtk): initialize compression roadmap branch * feat(compression): add RTK engine and compression combos Introduce RTK command-aware tool-output compression alongside stacked RTK -> Caveman pipelines for mixed prompt contexts. Add engine registration, declarative RTK filter packs, language-aware Caveman rule loading, compression combo persistence and assignments, analytics grouped by engine/combo, and new MCP/API endpoints for configuration, previews, filters, and combo management. Expose the new capabilities in the dashboard with dedicated Context & Cache pages for Caveman, RTK, and compression combos, and update docs, i18n strings, migrations, and tests to cover the expanded compression surface. * feat(compression): expand RTK DSL, filter catalog, and recovery APIs Add RTK parity features across the compression pipeline, dashboard, and management APIs. This expands the built-in filter catalog, adds trust-gated custom filter loading, inline filter verification, code stripping, smarter detection, and optional redacted raw-output retention for authenticated recovery. Also extend Caveman with file-based multilingual rule packs, localized output-mode instructions, stricter preview/config schemas, engine registry metadata, analytics fields, and broad unit test coverage for RTK, rule loading, and stacked compression behavior. * fix(auth): protect oauth routes and health reset operations Require authenticated dashboard access for OAuth endpoints that can create or import provider connections when login enforcement is enabled. Move `/api/monitoring/health` to the readonly public route list so safe methods remain public while DELETE now returns 401 for anonymous requests. Also update Next.js native `.node` handling to avoid webpack parse failures from external packages such as ngrok and keytar, and add coverage for the new auth behavior. * build(compression): ship RTK rule and filter assets with app bundles Include compression JSON assets in Next output tracing, prepublish copies, and pack artifact policy checks so standalone and packaged builds can load RTK filters and caveman rule packs at runtime. Also harden compression runtime behavior by resolving alternate asset directories, scoping rule cache entries by source path, carrying RTK raw output pointers through stacked runs, degrading oversized preview diffs, and applying combo language/output mode defaults during chat routing. Add coverage for packaging rules, provider-scoped model parsing, smart truncate edge cases, raw output retention, and combo-driven compression behavior. * docs(workflows): update local repo paths to OmniRoute Replace outdated `/home/diegosouzapw/dev/proxys/9router` references with the current `OmniRoute` directory across deploy, release, and version bump workflow guides so local command examples match the renamed repository layout * feat(compression): complete RTK parity coverage * test(build): align next config assertions --------- Co-authored-by: diegosouzapw <diego.souza.pw@gmail.com>
95 lines
3.0 KiB
TypeScript
95 lines
3.0 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { validateRtkFilter } from "../../../open-sse/services/compression/engines/rtk/filterSchema.ts";
|
|
import { applyLineFilter } from "../../../open-sse/services/compression/engines/rtk/lineFilter.ts";
|
|
|
|
function makeFilter(overrides: Record<string, unknown> = {}) {
|
|
return validateRtkFilter({
|
|
id: "dsl-test",
|
|
label: "DSL Test",
|
|
category: "generic",
|
|
priority: 100,
|
|
match: { outputTypes: ["dsl-test"], commands: ["^dsl"], patterns: [] },
|
|
preserve: { errorPatterns: ["error"], summaryPatterns: [] },
|
|
...overrides,
|
|
});
|
|
}
|
|
|
|
describe("RTK declarative DSL pipeline", () => {
|
|
it("runs stripAnsi, replace, strip, truncateLineAt, max lines, and onEmpty in order", () => {
|
|
const filter = makeFilter({
|
|
rules: {
|
|
stripAnsi: true,
|
|
replace: [{ pattern: "NOISE", replacement: "drop" }],
|
|
dropPatterns: ["^drop"],
|
|
truncateLineAt: 8,
|
|
maxLines: 2,
|
|
headLines: 2,
|
|
tailLines: 0,
|
|
onEmpty: "dsl: empty",
|
|
},
|
|
});
|
|
|
|
const result = applyLineFilter(
|
|
"\u001b[31mNOISE one\u001b[0m\nimportant-long-line\nsecond-long-line\nthird-long-line",
|
|
filter
|
|
);
|
|
|
|
assert.ok(result.appliedRules.includes("dsl-test:strip-ansi"));
|
|
assert.ok(result.appliedRules.includes("dsl-test:replace"));
|
|
assert.ok(result.appliedRules.includes("dsl-test:strip"));
|
|
assert.ok(result.appliedRules.includes("dsl-test:truncate-line"));
|
|
assert.ok(result.text.includes("impor..."));
|
|
assert.ok(!result.text.includes("NOISE"));
|
|
});
|
|
|
|
it("short-circuits matchOutput and respects unless", () => {
|
|
const filter = makeFilter({
|
|
rules: {
|
|
matchOutput: [
|
|
{ pattern: "Build complete", message: "build: ok", unless: "error|failed" },
|
|
{ pattern: "Build complete", message: "build: completed with diagnostics" },
|
|
],
|
|
dropPatterns: ["^noise"],
|
|
},
|
|
});
|
|
|
|
assert.equal(applyLineFilter("Build complete", filter).text, "build: ok");
|
|
assert.equal(
|
|
applyLineFilter("Build complete\nerror: warning promoted", filter).text,
|
|
"build: completed with diagnostics"
|
|
);
|
|
});
|
|
|
|
it("uses onEmpty when filtering removes every line", () => {
|
|
const filter = makeFilter({
|
|
rules: {
|
|
dropPatterns: [".*"],
|
|
onEmpty: "dsl: empty",
|
|
},
|
|
});
|
|
|
|
assert.equal(applyLineFilter("drop me", filter).text, "dsl: empty");
|
|
});
|
|
|
|
it("normalizes stderr prefixes before applying keep/drop rules", () => {
|
|
const filter = makeFilter({
|
|
rules: {
|
|
filterStderr: true,
|
|
includePatterns: ["^error:"],
|
|
dropPatterns: ["debug"],
|
|
},
|
|
});
|
|
|
|
const result = applyLineFilter(
|
|
"stdout | ok\nstderr | error: boom\nstderr: debug noise",
|
|
filter
|
|
);
|
|
|
|
assert.equal(result.text, "error: boom");
|
|
assert.ok(result.appliedRules.includes("dsl-test:filter-stderr"));
|
|
assert.ok(result.appliedRules.includes("dsl-test:keep"));
|
|
});
|
|
});
|