mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 12:22:14 +03:00
* chore(release): v3.7.9 — gemini-cli cloud code separation * chore(provider): Update Jina AI model catalog (#1874) Integrated into release/v3.7.9 * docs: update CHANGELOG for PR 1874 and retroactive credits * fix: resolve stream defaults and codex prompt mapping (#1873, #1872) * chore(compression): start caveman compression update * feat(compression): expand caveman compression and analytics pipeline Add caveman intensity levels, output mode instructions, validation, and preview diffs across the compression pipeline. Extend MCP and dashboard settings to support auto-trigger mode, system prompt preservation, MCP description compression, and caveman rule metadata. Record richer compression analytics with receipt fields, validation fallbacks, output mode data, and add the related database migration. Improve preservation handling for code, URLs, markdown, math, and other protected content while adding broad unit, integration, and golden-set coverage for caveman parity and compression behavior. * feat(compression): expose rule intensities and track usd savings Add estimated USD savings to compression analytics so saved tokens can be reported in cost terms alongside existing token metrics. Expose caveman rule intensity metadata for settings consumers and add a settings API route alias for rule lookup. Also preserve system prompts when aggressive compression falls back to lite mode. * feat(compression): RTK compression roadmap (#1889) * 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> * feat(compression): expand caveman parity and MCP metadata compression Compress MCP registry and list metadata descriptions for tools, prompts, resources, and resource templates while keeping tool-response bodies unchanged. Expose those savings in compression status as `mcp_metadata_estimate` metadata rather than provider usage. Add Caveman rule-pack support for custom regex flags and match-specific replacement maps, update English rules for upstream parity, and tighten article and pleasantry handling. Also process RTK multipart text blocks independently so mixed media content compresses safely without duplicating output. * feat(compression): unify config validation and persist MCP savings Centralize compression config schemas across settings, preview, RTK, and combo APIs to enforce consistent validation for stacked pipelines and engine-specific options. Expand caveman and stacked compression behavior by applying default combos at runtime, surfacing validation and fallback metadata, and exposing aggressive and ultra adapter schemas for configuration UI and tests. Persist MCP description compression snapshots into analytics without counting them as provider usage, and extend the dashboard with the new RTK controls and localized labels. * fix(auth): require dashboard management auth for compression preview Block preview requests unless they come from a valid management session token so protected settings cannot be probed through the preview API. Add unit coverage for unauthenticated requests, invalid bearer tokens, and successful authenticated preview execution. * fix(compression): preserve stacked defaults and secure metadata routes Only apply saved default compression combos when they contain a stacked pipeline so seeded Caveman-only defaults do not replace the builtin stacked behavior. Also require management auth for compression language pack and rules metadata endpoints, and defer usage receipt attachment until compression analytics writes have completed to keep analytics records consistent. * fix(compression): align seeded standard savings combo with stacked default Update the seeded default compression combo to use the RTK then Caveman pipeline in both fresh installs and upgraded databases. Add a targeted migration and runtime guard that only rewrites the legacy seeded record when its original metadata and single-step pipeline still match, preserving user-customized default combos. Refresh docs and tests to reflect the stacked default and expanded RTK filter catalog. * docs(compression): document RTK+Caveman stacked savings ranges Refresh the compression docs and README to describe the default stacked pipeline in terms of eligible-context savings instead of the older generic token-saving range. Add upstream RTK and Caveman benchmark references, explain the multiplicative savings math behind the stacked default, and update feature summaries plus package metadata to match the revised positioning. * feat(image-gen): add NanoGPT image generation provider (#1899) Integrated into release/v3.7.9 * fix(codex): sanitize raw responses input (#1895) Integrated into release/v3.7.9 * Fix combo provider breaker profile handling (#1891) Integrated into release/v3.7.9 * fix(combos): align strategy contracts (#1892) Integrated into release/v3.7.9 * feat(proxy): move proxy configuration to dedicated System → Proxy page (#1907) Integrated into release/v3.7.9 * feat: add K/M/B/T cost shortener to prevent UI overflow (#1902) Integrated into release/v3.7.9 * feat(providers): implement bulk paste for extra API keys (#1916) Integrated into release/v3.7.9 * fix(migrations): treat duplicate-column ALTER as no-op (#1886) Integrated into release/v3.7.9 * fix(analytics): robust model pricing resolution, dark mode charts and SQL aggregation fixes (#1896) Integrated into release/v3.7.9 (migration renumbered to 044) * fix(oauth): per-connection mutex for rotating refresh tokens (#1885) Integrated into release/v3.7.9 * fix: resolve 3 bugs — Codex tool normalization (#1914), image gen proxy (#1904), zero-arg MCP tools (#1898) - fix(codex): flatten Chat Completions tool format to Responses format in normalizeCodexTools. Prevents 'Missing required parameter: tools[0].name' upstream errors when clients send {type:'function', function:{name,...}} instead of {type:'function', name,...}. - fix(proxy): add proxy-aware execution context to image generation route. Image requests now correctly use proxy settings from the connection's ProxyRegistry assignment, matching the pattern used by chat pipeline. - fix(translator): inject properties:{} into zero-argument MCP tool schemas during Anthropic→OpenAI translation. OpenAI strict mode requires explicit properties even for empty object schemas. Closes #1914, Closes #1904, Closes #1898 * chore(release): v3.7.9 — all changes in ONE commit * fix: allow local ollama provider connections (#1893) * fix(copilot): emit compatible reasoning text deltas (#1919) Integrated into release/v3.7.9 * fix(api-manager): show validation errors inline in modals, not behind backdrop (#1920) Integrated into release/v3.7.9 * docs: update changelog and pr body with merged prs * fix(providers): route agentrouter through anthropic endpoint headers Update the AgentRouter provider registry to use the Claude-compatible messages API and required Anthropic-style authentication headers. This bypasses unauthorized_client_error responses and exposes the supported model list through passthrough configuration. Also update the changelog and release PR notes to document the fix for #1921 * feat(logs): show compression tokens in request log UI (#1923) * docs: add PR #1923 to changelog --------- Co-authored-by: diegosouzapw <diego.souza.pw@gmail.com> Co-authored-by: backryun <bakryun0718@proton.me> Co-authored-by: Aculeasis <42580940+Aculeasis@users.noreply.github.com> Co-authored-by: Raxxoor <manker_lol@hotmail.com> Co-authored-by: Randi <55005611+rdself@users.noreply.github.com> Co-authored-by: Paijo <14921983+oyi77@users.noreply.github.com> Co-authored-by: Tubagus <54710482+0xtbug@users.noreply.github.com> Co-authored-by: smartenok-ops <smartenok@gmail.com> Co-authored-by: Gi99lin <74502520+Gi99lin@users.noreply.github.com> Co-authored-by: ivan-mezentsev <ivan@mezentsev.me> Co-authored-by: Andrew Munsell <andrew@wizardapps.net>
1055 lines
33 KiB
TypeScript
1055 lines
33 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-compression-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
process.env.REQUIRE_API_KEY = "false";
|
|
process.env.API_KEY_SECRET = process.env.API_KEY_SECRET || "test-compression-secret";
|
|
|
|
const core = await import("../../src/lib/db/core.ts");
|
|
const providersDb = await import("../../src/lib/db/providers.ts");
|
|
const readCacheDb = await import("../../src/lib/db/readCache.ts");
|
|
const combosDb = await import("../../src/lib/db/combos.ts");
|
|
const compressionDb = await import("../../src/lib/db/compression.ts");
|
|
const compressionCombosDb = await import("../../src/lib/db/compressionCombos.ts");
|
|
const compressionAnalyticsDb = await import("../../src/lib/db/compressionAnalytics.ts");
|
|
const { handleChatCore } = await import("../../open-sse/handlers/chatCore.ts");
|
|
const { estimateTokens, getTokenLimit } = await import("../../open-sse/services/contextManager.ts");
|
|
const { resetAllCircuitBreakers } = await import("../../src/shared/utils/circuitBreaker.ts");
|
|
|
|
const originalFetch = globalThis.fetch;
|
|
|
|
async function resetStorage() {
|
|
globalThis.fetch = originalFetch;
|
|
resetAllCircuitBreakers();
|
|
readCacheDb.invalidateDbCache();
|
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
core.resetDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
fs.mkdirSync(TEST_DATA_DIR, { recursive: true });
|
|
}
|
|
|
|
test.beforeEach(async () => {
|
|
await resetStorage();
|
|
});
|
|
|
|
test.after(async () => {
|
|
globalThis.fetch = originalFetch;
|
|
core.closeDbInstance();
|
|
try {
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
} catch {}
|
|
});
|
|
|
|
test("chatCore integration: compressContext called proactively when context exceeds 85% threshold", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: true,
|
|
defaultMode: "off",
|
|
autoTriggerTokens: 0,
|
|
});
|
|
|
|
// Create multiple messages with history that can be compressed
|
|
// Use the same pattern as test 3 which successfully tests compression
|
|
const body = {
|
|
model,
|
|
stream: false,
|
|
messages: [
|
|
{ role: "system", content: "You are helpful." },
|
|
{ role: "user", content: "x".repeat(50000) },
|
|
{ role: "assistant", content: "Response 1" },
|
|
{ role: "user", content: "x".repeat(50000) },
|
|
{ role: "assistant", content: "Response 2" },
|
|
{ role: "user", content: "x".repeat(50000) },
|
|
{ role: "assistant", content: "Response 3" },
|
|
{ role: "user", content: "Final question" },
|
|
],
|
|
};
|
|
|
|
// Create provider connection
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
const connectionId = connection.id;
|
|
|
|
// Mock fetch to capture the request
|
|
let capturedBody: any = null;
|
|
globalThis.fetch = async (url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedBody = JSON.parse(init.body as string);
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "test" } }],
|
|
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body,
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: {
|
|
debug: () => {},
|
|
info: () => {},
|
|
warn: () => {},
|
|
error: () => {},
|
|
},
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId,
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
comboName: null,
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
assert.ok(capturedBody, "Fetch should have been called");
|
|
|
|
// Verify that compression preserved the message structure
|
|
assert.ok(Array.isArray(capturedBody.messages), "Messages should remain an array");
|
|
assert.ok(capturedBody.messages.length > 0, "Messages should not be empty");
|
|
|
|
// Verify that the final question was preserved (compression keeps recent messages)
|
|
const lastMessage = capturedBody.messages[capturedBody.messages.length - 1];
|
|
assert.equal(lastMessage.content, "Final question", "Last user message should be preserved");
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: disabled prompt compression leaves combo override requests unchanged", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
const originalContextLength = process.env.CONTEXT_LENGTH_OPENAI;
|
|
process.env.CONTEXT_LENGTH_OPENAI = "8192";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: false,
|
|
defaultMode: "off",
|
|
autoTriggerTokens: 1,
|
|
comboOverrides: { "disabled-compression-combo": "lite" },
|
|
});
|
|
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
|
|
await combosDb.createCombo({
|
|
name: "disabled-compression-combo",
|
|
strategy: "priority",
|
|
models: [
|
|
{
|
|
kind: "model",
|
|
model: `${provider}/${model}`,
|
|
connectionId: connection.id,
|
|
},
|
|
],
|
|
config: {
|
|
compressionMode: "lite",
|
|
},
|
|
});
|
|
|
|
const body = {
|
|
model: "combo/disabled-compression-combo",
|
|
stream: false,
|
|
messages: [
|
|
{ role: "system", content: "You are helpful." },
|
|
{ role: "user", content: `${"Keep spacing.\n\n\n".repeat(2000)}First long turn.` },
|
|
{ role: "assistant", content: "Response 1" },
|
|
{ role: "user", content: `${"Keep spacing.\n\n\n".repeat(2000)}Second long turn.` },
|
|
{ role: "assistant", content: "Response 2" },
|
|
{ role: "user", content: `${"Keep spacing.\n\n\n".repeat(2000)}Final question.` },
|
|
],
|
|
};
|
|
const contextLimit = getTokenLimit(provider, model);
|
|
const proactiveThreshold = Math.floor(contextLimit * 0.7);
|
|
assert.ok(
|
|
estimateTokens(JSON.stringify(body.messages)) > proactiveThreshold,
|
|
"Test body should exceed proactive compression threshold"
|
|
);
|
|
|
|
let capturedBody: { messages?: Array<{ role?: string; content?: string }> } | null = null;
|
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedBody = JSON.parse(init.body as string) as typeof capturedBody;
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "test" } }],
|
|
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body,
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} },
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId: connection.id,
|
|
isCombo: true,
|
|
comboName: "disabled-compression-combo",
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
assert.ok(capturedBody, "Fetch should have been called");
|
|
assert.deepEqual(capturedBody.messages, body.messages);
|
|
|
|
const summary = compressionAnalyticsDb.getCompressionAnalyticsSummary();
|
|
assert.equal(summary.totalRequests, 0, "Disabled compression should not record analytics");
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
if (originalContextLength === undefined) {
|
|
delete process.env.CONTEXT_LENGTH_OPENAI;
|
|
} else {
|
|
process.env.CONTEXT_LENGTH_OPENAI = originalContextLength;
|
|
}
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: compressContext NOT called when context is below 85% threshold", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: true,
|
|
defaultMode: "off",
|
|
autoTriggerTokens: 0,
|
|
});
|
|
const contextLimit = getTokenLimit(provider, model);
|
|
const threshold = Math.floor(contextLimit * 0.85);
|
|
|
|
const smallMessage = "Hello, how are you?";
|
|
const body = {
|
|
model,
|
|
stream: false,
|
|
messages: [
|
|
{ role: "system", content: "You are helpful." },
|
|
{ role: "user", content: smallMessage },
|
|
],
|
|
};
|
|
|
|
const estimatedTokens = estimateTokens(JSON.stringify(body.messages));
|
|
assert.ok(
|
|
estimatedTokens < threshold,
|
|
`Expected ${estimatedTokens} to be below threshold ${threshold}`
|
|
);
|
|
|
|
// Create provider connection
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
const connectionId = connection.id;
|
|
|
|
// Mock fetch to capture the request
|
|
let capturedBody: any = null;
|
|
globalThis.fetch = async (url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedBody = JSON.parse(init.body as string);
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "test" } }],
|
|
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body,
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} },
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId,
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
comboName: null,
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
assert.ok(capturedBody, "Fetch should have been called");
|
|
|
|
// Verify NO compression occurred
|
|
const originalTokens = estimateTokens(JSON.stringify(body.messages));
|
|
const finalTokens = estimateTokens(JSON.stringify(capturedBody.messages));
|
|
|
|
assert.equal(
|
|
finalTokens,
|
|
originalTokens,
|
|
`Context should NOT be compressed: ${finalTokens} === ${originalTokens}`
|
|
);
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: compression preserves message structure", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: true,
|
|
defaultMode: "off",
|
|
autoTriggerTokens: 0,
|
|
});
|
|
|
|
const body = {
|
|
model,
|
|
stream: false,
|
|
messages: [
|
|
{ role: "system", content: "You are helpful." },
|
|
{ role: "user", content: "x".repeat(50000) },
|
|
{ role: "assistant", content: "Response 1" },
|
|
{ role: "user", content: "x".repeat(50000) },
|
|
{ role: "assistant", content: "Response 2" },
|
|
{ role: "user", content: "Final question" },
|
|
],
|
|
};
|
|
|
|
// Create provider connection
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
const connectionId = connection.id;
|
|
|
|
// Mock fetch to capture the request
|
|
let capturedBody: any = null;
|
|
globalThis.fetch = async (url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedBody = JSON.parse(init.body as string);
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "test" } }],
|
|
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body,
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: {
|
|
debug: (tag: string, msg: string) => console.log(`[DEBUG] ${tag}: ${msg}`),
|
|
info: (tag: string, msg: string) => console.log(`[INFO] ${tag}: ${msg}`),
|
|
warn: (tag: string, msg: string) => console.log(`[WARN] ${tag}: ${msg}`),
|
|
error: (tag: string, msg: string) => console.log(`[ERROR] ${tag}: ${msg}`),
|
|
},
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId,
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
comboName: null,
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
assert.ok(capturedBody, "Fetch should have been called");
|
|
assert.ok(Array.isArray(capturedBody.messages), "Messages should remain an array");
|
|
assert.ok(capturedBody.messages.length > 0, "Messages should not be empty");
|
|
|
|
const hasSystem = capturedBody.messages.some((m: any) => m.role === "system");
|
|
assert.ok(hasSystem, "System message should be preserved");
|
|
|
|
const lastMessage = capturedBody.messages[capturedBody.messages.length - 1];
|
|
assert.equal(lastMessage.content, "Final question", "Last user message should be preserved");
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: compression handles tool messages", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
|
|
const longToolOutput = "x".repeat(10000);
|
|
const body = {
|
|
model,
|
|
stream: false,
|
|
messages: [
|
|
{ role: "system", content: "You are helpful." },
|
|
{ role: "user", content: "Run the tool" },
|
|
{ role: "assistant", content: "Running tool", tool_calls: [{ id: "t1", type: "function" }] },
|
|
{ role: "tool", content: longToolOutput, tool_call_id: "t1" },
|
|
{ role: "user", content: "What's the result?" },
|
|
],
|
|
};
|
|
|
|
// Create provider connection
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
const connectionId = connection.id;
|
|
|
|
// Mock fetch to capture the request
|
|
let capturedBody: any = null;
|
|
globalThis.fetch = async (url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedBody = JSON.parse(init.body as string);
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "test" } }],
|
|
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body,
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} },
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId,
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
comboName: null,
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
assert.ok(capturedBody, "Fetch should have been called");
|
|
|
|
const toolMessage = capturedBody.messages.find((m: any) => m.role === "tool");
|
|
assert.ok(toolMessage, "Tool message should exist");
|
|
|
|
// Tool message should be truncated if compression was triggered
|
|
if (toolMessage.content.length < longToolOutput.length) {
|
|
assert.ok(
|
|
toolMessage.content.includes("[truncated]"),
|
|
"Tool message should have truncation marker"
|
|
);
|
|
}
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: combo requests run proactive compression before Kiro translation", async () => {
|
|
const provider = "kiro";
|
|
const model = "claude-sonnet-4.5";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: true,
|
|
defaultMode: "off",
|
|
autoTriggerTokens: 0,
|
|
});
|
|
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
const connectionId = connection.id;
|
|
|
|
await combosDb.createCombo({
|
|
name: "test-kiro-compression-combo",
|
|
strategy: "priority",
|
|
models: [
|
|
{
|
|
kind: "model",
|
|
model: `${provider}/${model}`,
|
|
connectionId,
|
|
},
|
|
],
|
|
});
|
|
|
|
const body = {
|
|
model: "combo/test-kiro-compression-combo",
|
|
stream: false,
|
|
messages: [
|
|
{ role: "system", content: "You are helpful." },
|
|
{ role: "user", content: "x".repeat(50000) },
|
|
{ role: "assistant", content: "Ack 1" },
|
|
{ role: "user", content: "x".repeat(50000) },
|
|
{ role: "assistant", content: "Ack 2" },
|
|
{ role: "user", content: "x".repeat(50000) },
|
|
{ role: "assistant", content: "Ack 3" },
|
|
{ role: "user", content: "Please summarize everything." },
|
|
],
|
|
};
|
|
|
|
let capturedTranslatedBody: Record<string, unknown> | null = null;
|
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedTranslatedBody = JSON.parse(init.body as string) as Record<string, unknown>;
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "ok" } }],
|
|
usage: { prompt_tokens: 11, completion_tokens: 5, total_tokens: 16 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body,
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} },
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId,
|
|
isCombo: true,
|
|
comboName: "test-kiro-compression-combo",
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
});
|
|
|
|
// Kiro response translation in this integration harness may fail depending on upstream
|
|
// payload shape, but the regression target is request-side behavior before translation.
|
|
assert.ok(result, "Handler should return a result object");
|
|
assert.ok(capturedTranslatedBody, "Translated body should be sent upstream");
|
|
|
|
// Ensure request was translated to Kiro shape (messages are not sent directly upstream).
|
|
const conversationState = capturedTranslatedBody?.conversationState as
|
|
| Record<string, unknown>
|
|
| undefined;
|
|
assert.ok(conversationState, "Kiro translated request should include conversationState");
|
|
|
|
const history = Array.isArray(conversationState?.history)
|
|
? (conversationState.history as unknown[])
|
|
: [];
|
|
assert.ok(
|
|
history.length < body.messages.length - 1,
|
|
"History should be reduced by proactive compression before translation"
|
|
);
|
|
|
|
const currentMessage = conversationState?.currentMessage as Record<string, unknown> | undefined;
|
|
const userInputMessage = currentMessage?.userInputMessage as
|
|
| Record<string, unknown>
|
|
| undefined;
|
|
const currentContent =
|
|
typeof userInputMessage?.content === "string" ? userInputMessage.content : "";
|
|
assert.match(currentContent, /Please summarize everything\./);
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: assigned compression combo applies language packs and output mode", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: true,
|
|
defaultMode: "off",
|
|
autoTriggerTokens: 0,
|
|
cavemanOutputMode: {
|
|
enabled: false,
|
|
intensity: "full",
|
|
autoClarity: true,
|
|
},
|
|
languageConfig: {
|
|
enabled: false,
|
|
defaultLanguage: "en",
|
|
autoDetect: true,
|
|
enabledPacks: ["en"],
|
|
},
|
|
});
|
|
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
|
|
const routingCombo = await combosDb.createCombo({
|
|
name: "assigned-compression-combo",
|
|
strategy: "priority",
|
|
models: [
|
|
{
|
|
kind: "model",
|
|
model: `${provider}/${model}`,
|
|
connectionId: connection.id,
|
|
},
|
|
],
|
|
});
|
|
|
|
const compressionCombo = compressionCombosDb.createCompressionCombo({
|
|
name: "Assigned PT Output Mode",
|
|
pipeline: [{ engine: "caveman", intensity: "lite" }],
|
|
languagePacks: ["pt-BR"],
|
|
outputMode: true,
|
|
outputModeIntensity: "lite",
|
|
});
|
|
assert.equal(
|
|
compressionCombosDb.assignRoutingCombo(compressionCombo.id, routingCombo.id as string),
|
|
true
|
|
);
|
|
|
|
let capturedBody: any = null;
|
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedBody = JSON.parse(init.body as string);
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "ok" } }],
|
|
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body: {
|
|
model: "combo/assigned-compression-combo",
|
|
stream: false,
|
|
messages: [{ role: "user", content: "Resuma esta implementacao." }],
|
|
},
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} },
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId: connection.id,
|
|
isCombo: true,
|
|
comboName: "assigned-compression-combo",
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
assert.ok(capturedBody, "Fetch should receive the request body");
|
|
const firstMessage = capturedBody.messages?.[0];
|
|
assert.equal(firstMessage?.role, "system");
|
|
assert.match(firstMessage?.content ?? "", /OmniRoute Caveman Output Mode/);
|
|
assert.match(firstMessage?.content ?? "", /Responda conciso/);
|
|
|
|
for (
|
|
let attempt = 0;
|
|
attempt < 100 && compressionAnalyticsDb.getCompressionAnalyticsSummary().totalRequests === 0;
|
|
attempt += 1
|
|
) {
|
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
}
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: default stacked compression combo applies for unassigned stacked requests", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: true,
|
|
defaultMode: "stacked",
|
|
autoTriggerTokens: 0,
|
|
cavemanOutputMode: {
|
|
enabled: false,
|
|
intensity: "full",
|
|
autoClarity: true,
|
|
},
|
|
languageConfig: {
|
|
enabled: false,
|
|
defaultLanguage: "en",
|
|
autoDetect: true,
|
|
enabledPacks: ["en"],
|
|
},
|
|
});
|
|
|
|
const compressionCombo = compressionCombosDb.createCompressionCombo({
|
|
name: "Default PT Output Mode",
|
|
pipeline: [
|
|
{ engine: "rtk", intensity: "standard" },
|
|
{ engine: "caveman", intensity: "lite" },
|
|
],
|
|
languagePacks: ["pt-BR"],
|
|
outputMode: true,
|
|
outputModeIntensity: "lite",
|
|
isDefault: true,
|
|
});
|
|
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
|
|
let capturedBody: { messages?: Array<{ role?: string; content?: string }> } | null = null;
|
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedBody = JSON.parse(init.body as string) as typeof capturedBody;
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "ok" } }],
|
|
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body: {
|
|
model,
|
|
stream: false,
|
|
messages: [{ role: "user", content: "Resuma esta implementacao." }],
|
|
},
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} },
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId: connection.id,
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
comboName: null,
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
assert.ok(capturedBody, "Fetch should receive the request body");
|
|
const firstMessage = capturedBody.messages?.[0];
|
|
assert.equal(firstMessage?.role, "system");
|
|
assert.match(firstMessage?.content ?? "", /OmniRoute Caveman Output Mode/);
|
|
assert.match(firstMessage?.content ?? "", /Responda conciso/);
|
|
|
|
let summary = compressionAnalyticsDb.getCompressionAnalyticsSummary();
|
|
for (
|
|
let attempt = 0;
|
|
attempt < 100 && !summary.byCompressionCombo[compressionCombo.id];
|
|
attempt += 1
|
|
) {
|
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
summary = compressionAnalyticsDb.getCompressionAnalyticsSummary();
|
|
}
|
|
|
|
assert.equal(summary.byCompressionCombo[compressionCombo.id].count, 1);
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: seeded default combo runs RTK before Caveman", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: true,
|
|
defaultMode: "stacked",
|
|
autoTriggerTokens: 0,
|
|
cavemanOutputMode: {
|
|
enabled: false,
|
|
intensity: "full",
|
|
autoClarity: true,
|
|
},
|
|
languageConfig: {
|
|
enabled: false,
|
|
defaultLanguage: "en",
|
|
autoDetect: true,
|
|
enabledPacks: ["en"],
|
|
},
|
|
});
|
|
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
|
|
let capturedBody: { messages?: Array<{ role?: string; content?: string }> } | null = null;
|
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedBody = JSON.parse(init.body as string) as typeof capturedBody;
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "ok" } }],
|
|
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body: {
|
|
model,
|
|
stream: false,
|
|
messages: [
|
|
{
|
|
role: "tool",
|
|
content: Array.from({ length: 8 }, () => "same noisy line").join("\n"),
|
|
},
|
|
],
|
|
},
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} },
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId: connection.id,
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
comboName: null,
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
assert.ok(capturedBody, "Fetch should receive the request body");
|
|
const toolContent = capturedBody.messages?.[0]?.content ?? "";
|
|
assert.match(toolContent, /rtk:dropped 7 repeated lines/);
|
|
|
|
let summary = compressionAnalyticsDb.getCompressionAnalyticsSummary();
|
|
for (
|
|
let attempt = 0;
|
|
attempt < 100 &&
|
|
(summary.byCompressionCombo["default-caveman"]?.count !== 1 ||
|
|
summary.realUsage.requestsWithReceipts === 0);
|
|
attempt += 1
|
|
) {
|
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
summary = compressionAnalyticsDb.getCompressionAnalyticsSummary();
|
|
}
|
|
|
|
assert.equal(summary.totalRequests, 1);
|
|
assert.equal(summary.byCompressionCombo["default-caveman"].count, 1);
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: modular compression records analytics row best-effort", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: true,
|
|
defaultMode: "lite",
|
|
autoTriggerTokens: 0,
|
|
});
|
|
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
|
|
const body = {
|
|
model,
|
|
stream: false,
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: `Please help with this request. ${"Keep spacing. ".repeat(400)}\n\n\n\nFinal line.`,
|
|
},
|
|
],
|
|
};
|
|
|
|
globalThis.fetch = async () =>
|
|
new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "ok" } }],
|
|
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body,
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} },
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId: connection.id,
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
comboName: null,
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
|
|
let summary = compressionAnalyticsDb.getCompressionAnalyticsSummary();
|
|
for (
|
|
let attempt = 0;
|
|
attempt < 100 &&
|
|
(summary.totalRequests === 0 || summary.realUsage.requestsWithReceipts === 0);
|
|
attempt += 1
|
|
) {
|
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
summary = compressionAnalyticsDb.getCompressionAnalyticsSummary();
|
|
}
|
|
|
|
assert.equal(summary.totalRequests, 1);
|
|
assert.ok(summary.totalTokensSaved > 0, "Analytics should record token savings");
|
|
assert.equal(summary.byMode.lite.count, 1);
|
|
assert.equal(summary.byProvider.openai.count, 1);
|
|
assert.equal(summary.realUsage.requestsWithReceipts, 1);
|
|
assert.equal(summary.realUsage.totalTokens, 15);
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("chatCore integration: caveman output mode records analytics and receipts without prompt compression", async () => {
|
|
const provider = "openai";
|
|
const model = "gpt-4";
|
|
|
|
await compressionDb.updateCompressionSettings({
|
|
enabled: false,
|
|
defaultMode: "off",
|
|
autoTriggerTokens: 0,
|
|
cavemanOutputMode: {
|
|
enabled: true,
|
|
intensity: "full",
|
|
autoClarity: true,
|
|
},
|
|
});
|
|
|
|
const connection = await providersDb.createProviderConnection({
|
|
provider,
|
|
apiKey: "test-key",
|
|
isActive: true,
|
|
});
|
|
|
|
let capturedBody: any = null;
|
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
if (init?.body) {
|
|
capturedBody = JSON.parse(init.body as string);
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
choices: [{ message: { role: "assistant", content: "ok" } }],
|
|
usage: { prompt_tokens: 20, completion_tokens: 4, total_tokens: 24 },
|
|
}),
|
|
{
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
}
|
|
);
|
|
};
|
|
|
|
try {
|
|
const result = await handleChatCore({
|
|
body: {
|
|
model,
|
|
stream: false,
|
|
messages: [{ role: "user", content: "Summarize this implementation." }],
|
|
},
|
|
modelInfo: { provider, model },
|
|
credentials: { apiKey: "test-key" },
|
|
log: { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} },
|
|
clientRawRequest: { endpoint: "/v1/chat/completions", headers: new Map() },
|
|
connectionId: connection.id,
|
|
onCredentialsRefreshed: () => {},
|
|
onRequestSuccess: () => {},
|
|
onStreamFailure: () => {},
|
|
onDisconnect: () => {},
|
|
userAgent: "test-agent",
|
|
comboName: null,
|
|
});
|
|
|
|
assert.ok(result.success, "Request should succeed");
|
|
assert.match(capturedBody.messages[0].content, /Caveman Output Mode/);
|
|
|
|
let summary = compressionAnalyticsDb.getCompressionAnalyticsSummary();
|
|
for (
|
|
let attempt = 0;
|
|
attempt < 100 &&
|
|
(summary.totalRequests === 0 || summary.realUsage.requestsWithReceipts === 0);
|
|
attempt += 1
|
|
) {
|
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
summary = compressionAnalyticsDb.getCompressionAnalyticsSummary();
|
|
}
|
|
|
|
assert.equal(summary.byMode["output-caveman"].count, 1);
|
|
assert.equal(summary.realUsage.requestsWithReceipts, 1);
|
|
assert.equal(summary.realUsage.totalTokens, 24);
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|