mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 07:12:12 +03:00
fix(types): preserve non-streaming response metadata (#9118)
Validated in local merge-train (devbox-vm-06-dev002) @ combined-tip (FAST gates: typecheck/complexity/cognitive/changelog/vitest — only pre-existing audit.test.ts flake). Evidence: /home/diegosouzapw/dev/proxys/OmniRoute/.claude/worktrees/merge-train-20260805-222248-suite.log
This commit is contained in:
@@ -0,0 +1 @@
|
||||
- **fix(types):** narrowed non-streaming chat response metadata inputs to the shared header contract without changing emitted metadata headers ([#9118](https://github.com/diegosouzapw/OmniRoute/pull/9118))
|
||||
@@ -16,9 +16,9 @@ export function buildNonStreamingResponseHeaders(
|
||||
provider: string | null | undefined;
|
||||
model: string | null | undefined;
|
||||
startTime: number;
|
||||
responseUsage: unknown;
|
||||
responseUsage: Record<string, unknown> | null | undefined;
|
||||
estimatedCost: number;
|
||||
requestId: unknown;
|
||||
requestId: string | null | undefined;
|
||||
compressionResponseMeta?: string | null | undefined;
|
||||
comboStrategy?: string | null | undefined;
|
||||
},
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
const { buildNonStreamingResponseHeaders } = await import(
|
||||
"../../open-sse/handlers/chatCore/nonStreamingResponseHeaders.ts"
|
||||
);
|
||||
const { buildNonStreamingResponseHeaders } =
|
||||
await import("../../open-sse/handlers/chatCore/nonStreamingResponseHeaders.ts");
|
||||
|
||||
function makeDeps(now = 1000) {
|
||||
const metaCalls: Array<{ headers: Record<string, string>; meta: Record<string, unknown> }> = [];
|
||||
const deps = {
|
||||
attachOmniRouteMetaHeaders: (headers: Record<string, string>, meta: Record<string, unknown>) => {
|
||||
attachOmniRouteMetaHeaders: (
|
||||
headers: Record<string, string>,
|
||||
meta: Record<string, unknown>
|
||||
) => {
|
||||
metaCalls.push({ headers, meta });
|
||||
headers["x-omniroute-meta"] = "attached";
|
||||
},
|
||||
@@ -35,6 +37,17 @@ function baseArgs(overrides: Record<string, unknown> = {}) {
|
||||
} as Parameters<typeof buildNonStreamingResponseHeaders>[0];
|
||||
}
|
||||
|
||||
function acceptsAttachMetaInputContract(args: {
|
||||
responseUsage: Record<string, unknown> | null | undefined;
|
||||
requestId: string | null | undefined;
|
||||
}) {
|
||||
return args;
|
||||
}
|
||||
|
||||
test("builder input types match the metadata attachment contract", () => {
|
||||
acceptsAttachMetaInputContract(baseArgs());
|
||||
});
|
||||
|
||||
test("static headers: Content-Type json + cache MISS", () => {
|
||||
const { deps } = makeDeps();
|
||||
const h = buildNonStreamingResponseHeaders(baseArgs(), deps);
|
||||
@@ -59,7 +72,10 @@ test("meta receives provider/model/cacheHit false/latency/usage/cost/requestId",
|
||||
|
||||
test("no compression meta → no compression header", () => {
|
||||
const { deps } = makeDeps();
|
||||
const h = buildNonStreamingResponseHeaders(baseArgs({ compressionResponseMeta: undefined }), deps);
|
||||
const h = buildNonStreamingResponseHeaders(
|
||||
baseArgs({ compressionResponseMeta: undefined }),
|
||||
deps
|
||||
);
|
||||
assert.ok(!Object.values(h).includes("engine:x"));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user