90 lines
3.4 KiB
JavaScript
90 lines
3.4 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import test from 'node:test';
|
|
|
|
import { startDeepseekNoThinkProxy } from '../deepseek-no-think-proxy.mjs';
|
|
|
|
const ROOT = path.resolve(new URL('..', import.meta.url).pathname);
|
|
|
|
test('sanitized production tool-round replay reaches DeepSeek with thinking disabled', async (t) => {
|
|
const forwarded = [];
|
|
const proxy = await startDeepseekNoThinkProxy({
|
|
host: '127.0.0.1',
|
|
port: 0,
|
|
logger: { info() {}, warn() {}, error() {} },
|
|
fetchImpl: async (_url, init) => {
|
|
forwarded.push(JSON.parse(String(init.body)));
|
|
return new Response(JSON.stringify({
|
|
choices: [{ message: { role: 'assistant', content: 'synthetic result' } }],
|
|
}), {
|
|
status: 200,
|
|
headers: { 'content-type': 'application/json' },
|
|
});
|
|
},
|
|
});
|
|
t.after(() => new Promise((resolve) => proxy.close(resolve)));
|
|
const address = proxy.address();
|
|
|
|
const response = await fetch(
|
|
`http://127.0.0.1:${address.port}/v1/chat/completions`,
|
|
{
|
|
method: 'POST',
|
|
headers: {
|
|
authorization: 'Bearer synthetic-key',
|
|
'content-type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
model: 'deepseek-v4-pro',
|
|
thinking: { type: 'enabled' },
|
|
messages: [
|
|
{ role: 'user', content: 'Use the synthetic filesystem tool.' },
|
|
{ role: 'assistant', tool_calls: [{ id: 'call-1', type: 'function' }] },
|
|
{ role: 'tool', tool_call_id: 'call-1', content: 'synthetic file list' },
|
|
],
|
|
}),
|
|
},
|
|
);
|
|
|
|
assert.equal(response.status, 200);
|
|
assert.equal(forwarded.length, 1);
|
|
assert.deepEqual(forwarded[0].thinking, { type: 'disabled' });
|
|
assert.equal(forwarded[0].messages[2].role, 'tool');
|
|
});
|
|
|
|
test('Gate, artifact, candidate routing and rollback share one compatibility contract', async () => {
|
|
const [
|
|
builder,
|
|
localStack,
|
|
candidateRunner,
|
|
compatRunner,
|
|
canaryRelease,
|
|
canaryRollback,
|
|
] = await Promise.all([
|
|
fs.readFile(path.join(ROOT, 'scripts', 'build-portal-runtime.mjs'), 'utf8'),
|
|
fs.readFile(path.join(ROOT, 'release-gate', 'local-stack.mjs'), 'utf8'),
|
|
fs.readFile(path.join(ROOT, 'scripts', 'run-memind-portal-candidate.sh'), 'utf8'),
|
|
fs.readFile(
|
|
path.join(ROOT, 'scripts', 'run-deepseek-compat-proxy-candidate.sh'),
|
|
'utf8',
|
|
),
|
|
fs.readFile(path.join(ROOT, 'scripts', 'release-portal-canary-prod.sh'), 'utf8'),
|
|
fs.readFile(path.join(ROOT, 'scripts', 'rollback-portal-canary-prod.sh'), 'utf8'),
|
|
]);
|
|
|
|
assert.match(builder, /--outfile=\.runtime\/portal\/deepseek-no-think-proxy\.mjs/);
|
|
assert.match(
|
|
localStack,
|
|
/path\.join\(resolvedPortalRoot, 'deepseek-no-think-proxy\.mjs'\)/,
|
|
);
|
|
assert.match(candidateRunner, /export MEMIND_DEEPSEEK_DISABLE_THINKING=1/);
|
|
assert.match(candidateRunner, /export MEMIND_GOOSED_HOST_GATEWAY=host\.docker\.internal/);
|
|
assert.match(compatRunner, /source "\$\{STABLE_ROOT\}\/\.env"/);
|
|
assert.match(compatRunner, /export MEMIND_DEEPSEEK_PROXY_ENTRYPOINT=1/);
|
|
assert.match(canaryRelease, /run-deepseek-compat-proxy-candidate\.sh/);
|
|
assert.match(canaryRelease, /MEMIND_CANARY_CANDIDATE_HEALTH_URLS/);
|
|
assert.match(canaryRelease, /host\.docker\.internal:\$\{DEEPSEEK_COMPAT_PORT\}\/health/);
|
|
assert.match(canaryRelease, /bootout.*DEEPSEEK_COMPAT_LABEL/);
|
|
assert.match(canaryRollback, /bootout.*DEEPSEEK_COMPAT_LABEL/);
|
|
});
|