b100325fe0
Build Electron Desktop App / Validate version (push) Failing after 29s
Build Electron Desktop App / Build Electron (macos-arm64) (push) Has been skipped
Build Electron Desktop App / Build Electron (linux) (push) Has been skipped
Build Electron Desktop App / Build Electron (macos-intel) (push) Has been skipped
Build Electron Desktop App / Build Electron (windows) (push) Has been skipped
Build Electron Desktop App / Create Release (push) Has been skipped
Build Electron Desktop App / Publish to npm (push) Has been skipped
* feat(qoder): native cosy integration * feat(qoder): implement native COSY encryption algorithm and remove CLI child instances, plus workflow bumps * feat(resilience): context overflow fallback, OAuth token detection, empty content guard & context-optimized combo strategy - Add isContextOverflowError + isContextOverflow detectors (400 + token-limit signals) - Auto-fallback to next family model on context overflow in chatCore - Add isEmptyContentResponse to catch fake-success empty responses, trigger fallback + recursive retry - Add OAUTH_INVALID_TOKEN error type (T11) with isOAuthInvalidToken signal matching; warn instead of deactivating node - Add getModelContextLimit helper in modelsDevSync (reads limit_context from synced capabilities) - Upgrade getTokenLimit in contextManager to check models.dev DB before registry (fixes gemini-2.5-pro: 1000000→1048576) - Add findLargerContextModel in modelFamilyFallback for context-aware model selection - Add sortModelsByContextSize + context-optimized combo strategy in combo.ts - Update context-manager unit test for corrected gemini-2.5-pro limit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(review): address Gemini code review — tool_calls path, infinite recursion, dedup signals, findLargerContextModel - Fix isEmptyContentResponse: check message.tool_calls/delta.tool_calls instead of firstChoice.tool_calls (wrong OpenAI API path, caused tool-call responses to be falsely flagged as empty) - Fix empty content fallback: replace recursive handleChatCore call (infinite recursion risk + wrong model due to original body.model) with non-recursive pattern — call executeProviderRequest, parse fallback response body, reassign responseBody and fall through to existing processing - Fix context overflow: use findLargerContextModel over family candidates first, fall back to getNextFamilyFallback — ensures we pick a model with actually larger context window on overflow - Fix signal dedup: export CONTEXT_OVERFLOW_SIGNALS + CONTEXT_OVERFLOW_REGEX from errorClassifier.ts; import shared regex in modelFamilyFallback.ts, removing duplicate signal list and per-call RegExp construction Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(UI): add context-optimized strategy to frontend schema and options * fix(sse): preserve Responses API events in stream translation When translating Claude-format responses (e.g. GLM) to Responses API format for Codex CLI, the sanitizer stripped {event, data} structured items to {"object":"chat.completion.chunk"}, losing all content and the critical response.completed event. Only run sanitizeStreamingChunk on OpenAI Chat Completions chunks, skipping items that have the Responses API {event, data} structure. * test(sse): add regression test for Claude→Responses stream sanitization Verifies that {event,data} structured items from the Responses API translator bypass sanitizeStreamingChunk when translating Claude-format providers (e.g. GLM) to Responses API format for Codex CLI. * fix(sse): strengthen Responses API event detection with response. prefix check Use explicit `response.` prefix check instead of generic `event && data` presence check, as recommended in PR review. * fix: pin Next.js to 16.0.10 to prevent Turbopack hashed module bug Remove ^ prefix from next and eslint-config-next to prevent automatic upgrades to 16.1.x+ which introduced content-based hashing for external module references in Turbopack. Also remove duplicate Material Symbols @import from globals.css (font already loaded via <link> in layout.tsx). Fixes #509 * align cc-compatible cache handling with client passthrough * chore: integrate resilience and turbopack fixes (PRs #992, #990, #987) * chore(release): bump to v3.5.2 — changelog, docs, version sync * docs(i18n): sync documentation updates to 33 languages * fix(qoder): replace any with unknown to comply with strict any-budget --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: oyi77 <oyi77@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Chris Staley <christopher-s@users.noreply.github.com> Co-authored-by: Ivan <shanin-i2011@yandex.ru> Co-authored-by: R.D. <rogerproself@gmail.com>
262 lines
7.7 KiB
JavaScript
262 lines
7.7 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const { openaiResponsesToOpenAIResponse } = await import(
|
|
"../../open-sse/translator/response/openai-responses.ts"
|
|
);
|
|
const { FORMATS } = await import("../../open-sse/translator/formats.ts");
|
|
const { createSSETransformStreamWithLogger } = await import("../../open-sse/utils/stream.ts");
|
|
|
|
test("Responses->Chat: output_item.done emits arguments when no delta chunks were sent", () => {
|
|
const state = {
|
|
started: true,
|
|
chatId: "chatcmpl-test",
|
|
created: 1234567890,
|
|
toolCallIndex: 0,
|
|
finishReasonSent: false,
|
|
currentToolCallId: "call_abc",
|
|
currentToolCallArgsBuffer: "",
|
|
};
|
|
|
|
const chunk = {
|
|
type: "response.output_item.done",
|
|
item: {
|
|
type: "function_call",
|
|
call_id: "call_abc",
|
|
name: "search_tasks",
|
|
status: "completed",
|
|
arguments: '{"query":"select:TaskCreate,TaskUpdate","max_results":10}',
|
|
},
|
|
};
|
|
|
|
const result = openaiResponsesToOpenAIResponse(chunk, state);
|
|
|
|
assert.ok(result);
|
|
assert.equal(
|
|
result.choices[0].delta.tool_calls[0].function.arguments,
|
|
'{"query":"select:TaskCreate,TaskUpdate","max_results":10}'
|
|
);
|
|
assert.equal(state.toolCallIndex, 1);
|
|
});
|
|
|
|
test("Responses->Chat: output_item.done does not re-emit arguments already streamed via deltas", () => {
|
|
const state = {
|
|
started: true,
|
|
chatId: "chatcmpl-test",
|
|
created: 1234567890,
|
|
toolCallIndex: 0,
|
|
finishReasonSent: false,
|
|
currentToolCallId: "call_abc",
|
|
currentToolCallArgsBuffer: '{"query":"search"}',
|
|
};
|
|
|
|
const chunk = {
|
|
type: "response.output_item.done",
|
|
item: {
|
|
type: "function_call",
|
|
call_id: "call_abc",
|
|
name: "search",
|
|
status: "completed",
|
|
arguments: '{"query":"search"}',
|
|
},
|
|
};
|
|
|
|
const result = openaiResponsesToOpenAIResponse(chunk, state);
|
|
|
|
assert.equal(result, null);
|
|
assert.equal(state.toolCallIndex, 1);
|
|
});
|
|
|
|
test("Responses->Chat: empty-name tool call is deferred until done provides a valid name", () => {
|
|
const state = {
|
|
started: true,
|
|
chatId: "chatcmpl-test",
|
|
created: 1234567890,
|
|
toolCallIndex: 0,
|
|
finishReasonSent: false,
|
|
currentToolCallArgsBuffer: "",
|
|
currentToolCallDeferred: false,
|
|
};
|
|
|
|
const added = openaiResponsesToOpenAIResponse(
|
|
{
|
|
type: "response.output_item.added",
|
|
item: { type: "function_call", call_id: "call_deferred", name: " " },
|
|
},
|
|
state
|
|
);
|
|
assert.equal(added, null);
|
|
|
|
const delta = openaiResponsesToOpenAIResponse(
|
|
{
|
|
type: "response.function_call_arguments.delta",
|
|
delta: '{"query":"deferred"}',
|
|
},
|
|
state
|
|
);
|
|
assert.equal(delta, null);
|
|
|
|
const done = openaiResponsesToOpenAIResponse(
|
|
{
|
|
type: "response.output_item.done",
|
|
item: {
|
|
type: "function_call",
|
|
call_id: "call_deferred",
|
|
name: "search_tasks",
|
|
arguments: '{"query":"deferred"}',
|
|
},
|
|
},
|
|
state
|
|
);
|
|
|
|
assert.ok(done);
|
|
assert.equal(done.choices[0].delta.tool_calls[0].function.name, "search_tasks");
|
|
assert.equal(done.choices[0].delta.tool_calls[0].function.arguments, '{"query":"deferred"}');
|
|
});
|
|
|
|
test("Responses->Chat: empty-name tool call is dropped when done still has no valid name", () => {
|
|
const state = {
|
|
started: true,
|
|
chatId: "chatcmpl-test",
|
|
created: 1234567890,
|
|
toolCallIndex: 0,
|
|
finishReasonSent: false,
|
|
currentToolCallArgsBuffer: "",
|
|
currentToolCallDeferred: false,
|
|
};
|
|
|
|
openaiResponsesToOpenAIResponse(
|
|
{
|
|
type: "response.output_item.added",
|
|
item: { type: "function_call", call_id: "call_empty", name: "" },
|
|
},
|
|
state
|
|
);
|
|
|
|
const done = openaiResponsesToOpenAIResponse(
|
|
{
|
|
type: "response.output_item.done",
|
|
item: {
|
|
type: "function_call",
|
|
call_id: "call_empty",
|
|
name: " ",
|
|
arguments: '{"ignored":true}',
|
|
},
|
|
},
|
|
state
|
|
);
|
|
|
|
assert.equal(done, null);
|
|
assert.equal(state.toolCallIndex, 0);
|
|
});
|
|
|
|
test("Claude->Responses: {event,data} items bypass sanitization in translate mode", async () => {
|
|
// Regression test: when translating Claude-format (GLM) to Responses API for Codex CLI,
|
|
// the sanitizer was stripping {event,data} items to {"object":"chat.completion.chunk"},
|
|
// losing all content and the critical response.completed event.
|
|
const encoder = new TextEncoder();
|
|
const decoder = new TextDecoder();
|
|
|
|
// Create stream translating claude → openai-responses (same path as GLM via Codex CLI)
|
|
const stream = createSSETransformStreamWithLogger(
|
|
FORMATS.CLAUDE,
|
|
FORMATS.OPENAI_RESPONSES,
|
|
"glm",
|
|
null,
|
|
null,
|
|
"glm-5.1",
|
|
"conn-test",
|
|
{ messages: [{ role: "user", content: "hi" }] },
|
|
null,
|
|
null
|
|
);
|
|
|
|
const writer = stream.writable.getWriter();
|
|
// Simulate Claude-format SSE from GLM
|
|
await writer.write(
|
|
encoder.encode(
|
|
'event: message_start\ndata: {"type":"message_start","message":{"id":"msg_test","type":"message","role":"assistant","model":"glm-5.1","content":[],"stop_reason":null,"usage":{"input_tokens":10,"output_tokens":0}}}\n\n'
|
|
)
|
|
);
|
|
await writer.write(
|
|
encoder.encode(
|
|
'event: content_block_start\ndata: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}\n\n'
|
|
)
|
|
);
|
|
await writer.write(
|
|
encoder.encode(
|
|
'event: content_block_delta\ndata: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"hello"}}\n\n'
|
|
)
|
|
);
|
|
await writer.write(
|
|
encoder.encode(
|
|
'event: message_delta\ndata: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":5}}\n\n'
|
|
)
|
|
);
|
|
await writer.write(encoder.encode('event: message_stop\ndata: {"type":"message_stop"}\n\n'));
|
|
await writer.close();
|
|
|
|
const reader = stream.readable.getReader();
|
|
let output = "";
|
|
while (true) {
|
|
const { value, done } = await reader.read();
|
|
if (done) break;
|
|
output += decoder.decode(value, { stream: true });
|
|
}
|
|
output += decoder.decode();
|
|
|
|
// Must emit Responses API events (not sanitized chat.completion.chunk objects)
|
|
assert.match(output, /event: response\.created/);
|
|
assert.match(output, /event: response\.output_text\.delta/);
|
|
assert.match(output, /event: response\.completed/);
|
|
assert.match(output, /"delta":"hello"/);
|
|
assert.match(output, /"status":"completed"/);
|
|
|
|
// Must NOT contain sanitized empty chunks
|
|
assert.doesNotMatch(output, /data: \{"object":"chat\.completion\.chunk"\}\n\n/);
|
|
});
|
|
|
|
test("Responses->Claude: translated Claude SSE is not sanitized into empty OpenAI chunks", async () => {
|
|
const encoder = new TextEncoder();
|
|
const decoder = new TextDecoder();
|
|
const stream = createSSETransformStreamWithLogger(
|
|
FORMATS.OPENAI_RESPONSES,
|
|
FORMATS.CLAUDE,
|
|
"codex",
|
|
null,
|
|
null,
|
|
"gpt-5.4",
|
|
"conn-test",
|
|
{ messages: [{ role: "user", content: "hi" }] },
|
|
null,
|
|
null
|
|
);
|
|
|
|
const writer = stream.writable.getWriter();
|
|
await writer.write(
|
|
encoder.encode('data: {"type":"response.output_text.delta","delta":"hello"}\n\n')
|
|
);
|
|
await writer.write(
|
|
encoder.encode(
|
|
'data: {"type":"response.completed","response":{"usage":{"input_tokens":12,"output_tokens":3}}}\n\n'
|
|
)
|
|
);
|
|
await writer.close();
|
|
|
|
const reader = stream.readable.getReader();
|
|
let output = "";
|
|
while (true) {
|
|
const { value, done } = await reader.read();
|
|
if (done) break;
|
|
output += decoder.decode(value, { stream: true });
|
|
}
|
|
output += decoder.decode();
|
|
|
|
assert.match(output, /event: message_start/);
|
|
assert.match(output, /event: content_block_start/);
|
|
assert.match(output, /event: content_block_delta/);
|
|
assert.match(output, /event: message_delta/);
|
|
assert.match(output, /event: message_stop/);
|
|
assert.doesNotMatch(output, /data: \{"object":"chat\.completion\.chunk"\}\n\n/);
|
|
});
|