mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-19 13:23:50 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
73 lines
2.9 KiB
TypeScript
73 lines
2.9 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const { __test__ } = await import("../../open-sse/executors/zed-hosted.ts");
|
|
const { wrapZedCompletionStream } = __test__;
|
|
|
|
// zed-hosted's Anthropic backend converts Claude events to OpenAI chunks
|
|
// inside the executor (wrapZedCompletionStream → claudeToOpenAIResponse),
|
|
// bypassing chatCore's suppressThinkClose wiring. Responses API clients
|
|
// receive reasoning as structured items, so the textual `</think>` close
|
|
// marker must be suppressed on that path (same policy as chatCore / GLM).
|
|
|
|
function buildZedAnthropicNdjson(): string {
|
|
const lines = [
|
|
{ event: { type: "message_start", message: { id: "msg_zed", model: "claude-test" } } },
|
|
{ event: { type: "content_block_start", index: 0, content_block: { type: "thinking" } } },
|
|
{
|
|
event: {
|
|
type: "content_block_delta",
|
|
index: 0,
|
|
delta: { type: "thinking_delta", thinking: "plan" },
|
|
},
|
|
},
|
|
{ event: { type: "content_block_stop", index: 0 } },
|
|
{ event: { type: "content_block_start", index: 1, content_block: { type: "text", text: "" } } },
|
|
{
|
|
event: { type: "content_block_delta", index: 1, delta: { type: "text_delta", text: "Hi" } },
|
|
},
|
|
{ event: { type: "content_block_stop", index: 1 } },
|
|
{
|
|
event: {
|
|
type: "message_delta",
|
|
delta: { stop_reason: "end_turn" },
|
|
usage: { output_tokens: 3 },
|
|
},
|
|
},
|
|
{ event: { type: "message_stop" } },
|
|
];
|
|
return lines.map((l) => JSON.stringify(l)).join("\n") + "\n";
|
|
}
|
|
|
|
async function readAll(stream: ReadableStream<Uint8Array>): Promise<string> {
|
|
const reader = stream.getReader();
|
|
const decoder = new TextDecoder();
|
|
let out = "";
|
|
for (;;) {
|
|
const { value, done } = await reader.read();
|
|
if (done) break;
|
|
out += decoder.decode(value, { stream: true });
|
|
}
|
|
return out;
|
|
}
|
|
|
|
function wrapAnthropic(options?: Record<string, unknown>): Promise<string> {
|
|
const response = new Response(buildZedAnthropicNdjson(), { status: 200 });
|
|
// "anthropic" is the wire value normalizeZedProvider now returns (and the one
|
|
// cloud.zed.dev accepts); the capitalized spelling 500s upstream.
|
|
const wrapped = wrapZedCompletionStream(response, "anthropic", "claude-test", options);
|
|
return readAll(wrapped.body as ReadableStream<Uint8Array>);
|
|
}
|
|
|
|
test("zed anthropic stream keeps the close marker by default (#4633)", async () => {
|
|
const out = await wrapAnthropic();
|
|
assert.ok(out.includes('"content":"</think>"'), "expected default marker emission");
|
|
});
|
|
|
|
test("zed anthropic stream suppresses the close marker when asked", async () => {
|
|
const out = await wrapAnthropic({ suppressThinkClose: true });
|
|
assert.ok(!out.includes("</think>"), "marker must not leak into output");
|
|
assert.ok(out.includes('"content":"Hi"'), "text content still flows");
|
|
assert.ok(out.includes('"reasoning_content":"plan"'), "reasoning still flows");
|
|
});
|