Files
leleka/engine/strata/apps/host/tests/native-chat.test.mjs
T
Pavlo RatushnyiandClaude Sonnet 5.5 87e2633afe engine/strata: bring the Strata subtree to upstream 41cf05a0 (engine 0.1.50) with the local patches re-applied
Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree
(570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base =
the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main).

Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR
experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details,
conflict table and left-out files are in docs/upstream.md.

Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61),
docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out.

scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run").
Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR
macros on. No GPU run, no quality gate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:49:15 +01:00

13 lines
1.8 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import http from 'node:http';
import {proxyCompletion} from '../server/inference.mjs';
test('native chat sends image content, auth and tool opt-in and exposes reported MCP events',async()=>{
let received;
const server=http.createServer(async(req,res)=>{let text='';for await(const c of req)text+=c;received={body:JSON.parse(text),key:req.headers.authorization};res.writeHead(200,{'content-type':'text/event-stream'});res.end('data: {"strata_mcp":{"event":"call","id":"c1","name":"read_file","arguments":{"path":"example.txt"}}}\n\ndata: {"strata_mcp":{"event":"result","id":"c1","ok":true,"text":"Contents","ms":5}}\n\ndata: {"choices":[{"delta":{"content":"A picture"}}]}\n\ndata: {"usage":{"prompt_tokens":44,"completion_tokens":2},"timings":{"predicted_per_second":20,"prompt_per_second":800}}\n\ndata: [DONE]\n\n');});
await new Promise(r=>server.listen(0,'127.0.0.1',r));
try{const events=[];const result=await proxyCompletion({baseUrl:`http://127.0.0.1:${server.address().port}/v1`,modelId:'iq2_xs',authorization:'private-test-key',message:'Describe',images:[{url:'data:image/png;base64,aGVsbG8='}],extra:{strata_mcp:true,reasoning_effort:'none'},onFrame:f=>events.push(f),signal:new AbortController().signal});
assert.equal(received.key,'Bearer private-test-key');assert.equal(received.body.strata_mcp,true);assert.equal(received.body.messages.at(-1).content[1].image_url.url,'data:image/png;base64,aGVsbG8=');assert.equal(received.body.model,'iq2_xs');assert.deepEqual(events.filter(e=>e.type==='native-tool').map(e=>e.event.event),['call','result']);assert.equal(result.tokensIn,44);assert.equal(result.tokensOut,2);assert.equal(result.usageSource,'reported');
}finally{server.closeAllConnections();await new Promise(r=>server.close(r));}
});