Merge remote-tracking branch 'origin/master' into gitea/feature/end

Resolved conflicts taking origin/master (v0.5.55) as canonical, with local
features re-applied:
- runtime log level (LOG_LEVEL env + dashboard Settings → Logging, applied
  immediately and persisted across restarts)
- free/noAuth provider enable/disable toggle via providerStrategies.enabled
- parallel model testing (Test All Models / Test Selected Keys)
This commit is contained in:
2026-08-17 00:38:31 +07:00
parent e7470e955e
commit 7e45ead2ac
557 changed files with 53396 additions and 6935 deletions

View File

@@ -250,4 +250,48 @@ describe("handleChatCore Headroom diagnostics", () => {
expect.stringContaining("reported token delta, but outbound JSON shrank <5%; provider may bill near-original payload")
);
});
it("bypasses token savers when requested by the client", async () => {
const log = { debug: vi.fn(), info: vi.fn(), warn: vi.fn() };
const pxpipeTransform = vi.fn();
const messages = [{ role: "user", content: "Write polished prose." }];
global.fetch = vi.fn(async (url) => {
throw new Error(`unexpected fetch: ${url}`);
});
await handleChatCore({
body: { model: "gpt-4o", stream: false, messages },
modelInfo: { provider: "openai", model: "gpt-4o" },
credentials: { apiKey: "test-key", providerSpecificData: {} },
log,
connectionId: "test-conn",
headroomEnabled: true,
headroomUrl: "http://localhost:8787",
headroomCompressUserMessages: true,
rtkEnabled: true,
cavemanEnabled: true,
cavemanLevel: "full",
ponytailEnabled: true,
ponytailLevel: "full",
pxpipeEnabled: true,
pxpipeTransform,
clientRawRequest: {
endpoint: "/v1/chat/completions",
body: {},
headers: {
accept: "application/json",
"x-9router-token-saver": "off",
},
},
});
expect(global.fetch).not.toHaveBeenCalled();
expect(pxpipeTransform).not.toHaveBeenCalled();
expect(executeMock).toHaveBeenCalledWith(expect.objectContaining({
body: expect.objectContaining({
messages: [{ role: "user", content: "Write polished prose." }],
}),
}));
});
});