test(ci): align preserved native and catalog contracts
This commit is contained in:
@@ -71,8 +71,12 @@ test('Messages builds native system/tool history, bounds images, and seals a dis
|
||||
assert.equal(body.messages[2].content[1].text, '继续'); assert.equal(body.max_tokens, 256); assert.equal(body.tool_choice.type, 'auto');
|
||||
assert.deepEqual(body.tools[0].input_schema, definition.function.parameters); assert.equal(body.tools[0].function, undefined);
|
||||
assert.equal(requestImages(body)[0], image.dataUrl); assert.equal(requestMetrics(body).imageReservationTokens, 4096);
|
||||
assert.equal(requestHistory(body).filter(m => m.role === 'tool')[0].tool_call_id, tool.id);
|
||||
assert.deepEqual(requestHistory(body).filter(m => m.role === 'system').map(m => m.content), ['系统一', '系统二']);
|
||||
const projected = requestHistory(body);
|
||||
assert.equal(projected.filter(m => m.role === 'tool')[0].tool_call_id, tool.id);
|
||||
assert.deepEqual(projected.filter(m => m.role === 'system'), [{ role: 'system', content: '系统一系统二',
|
||||
providerInput: { protocol, content: body.system } }]);
|
||||
assert.deepEqual(completionBody({ ...cfg, inputImages: [] }, projected, body.tools), body,
|
||||
'native blocks, tools and images survive the history projection without adding the task image twice');
|
||||
assert.equal(completionBody(config('https://example.test'), [{ role: 'user', content: 'OK' }], []).tool_choice, undefined);
|
||||
const members = [{ id: 'chat', protocol: 'chat-completions', model: 'gpt-owned' }, { id: 'messages', protocol, model, baseUrl: cfg.baseUrl }];
|
||||
const mixed = completionBody({ ...cfg, modelRouting: { members } }, history, [definition]);
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ test('the bundled local service enforces host, origin, token and JSON object con
|
||||
assert.equal(badHostStatus, 421);
|
||||
await assert.rejects(server.api('/sessions', null), { status: 400 });
|
||||
assert.equal(server.bootstrap.capabilities.commands, 'per-call-approval');
|
||||
const page = await fetch(server.url); assert.equal(page.status, 200); assert.match(await page.text(), /Agent Workbench/);
|
||||
const page = await fetch(server.url); assert.equal(page.status, 200); assert.match(await page.text(), /<title>Orven · AI 开发工作台<\/title>/);
|
||||
assert.equal(page.headers.get('x-frame-options'), 'DENY');
|
||||
assert.equal(page.headers.get('referrer-policy'), 'no-referrer');
|
||||
assert.match(page.headers.get('content-security-policy'), /script-src 'self'/);
|
||||
|
||||
@@ -7,12 +7,14 @@ import { catalogModel } from '../src/shared/contracts/model-catalog.mjs';
|
||||
import { completionBody, requestVariants } from '../src/shared/contracts/model-request.mjs';
|
||||
import { modelSnapshot } from '../src/shared/contracts/execution.mjs';
|
||||
|
||||
test('catalog accepts published camel-case capacity without inventing missing maxima', () => {
|
||||
test('catalog keeps published camel-case input capacity separate from an unknown context maximum', () => {
|
||||
const model = catalogModel({ name: 'owned-model', displayName: 'Owned model', inputTokenLimit: 200000, outputTokenLimit: 128000 });
|
||||
assert.equal(model.name, 'Owned model');
|
||||
assert.equal(model.contextLimit, 200000); assert.equal(model.maxOutputTokens, 128000);
|
||||
assert.equal(model.contextLimit, null); assert.equal(model.maxInputTokens, 200000); assert.equal(model.maxOutputTokens, 128000);
|
||||
const distinct = catalogModel({ id: 'distinct-capacity', context_window: 300000, inputTokenLimit: 200000, outputTokenLimit: 128000 });
|
||||
assert.equal(distinct.contextLimit, 300000); assert.equal(distinct.maxInputTokens, 200000); assert.equal(distinct.maxOutputTokens, 128000);
|
||||
const missing = catalogModel({ id: 'no-capacity', outputTokenLimit: 0 });
|
||||
assert.equal(missing.contextLimit, null); assert.equal(missing.maxOutputTokens, null);
|
||||
assert.equal(missing.contextLimit, null); assert.equal(missing.maxInputTokens, null); assert.equal(missing.maxOutputTokens, null);
|
||||
});
|
||||
|
||||
test('refresh updates only selected upstream declarations and future Messages wire, preserving saved credentials and frozen requests', async t => {
|
||||
@@ -40,8 +42,11 @@ test('refresh updates only selected upstream declarations and future Messages wi
|
||||
const preview = await hub.catalog.fetch({ id: source.id, revision: source.revision });
|
||||
const refresh = hub.catalog.apply({ previewId: preview.id, models: ['child', 'source'] });
|
||||
assert.deepEqual(refresh.added, []); assert.deepEqual(refresh.existing, [child.id, source.id]);
|
||||
const requestBinding = { credentialRevision: keyObject.revision, contract: { schemaVersion: 1, protocol: 'anthropic-messages',
|
||||
requestUrl: upstream.baseUrl + '/models', headers: [['anthropic-version', '2023-06-01'], ['content-type', 'application/json'], ['x-api-key', '{{credential}}']] } };
|
||||
assert.deepEqual(hub.connection(child.id), { ...childBefore, upstreamModel: { ...preview.entries.find(model => model.id === 'child'),
|
||||
fetchedAt: preview.fetchedAt, endpoint: upstream.baseUrl } });
|
||||
fetchedAt: preview.fetchedAt, endpoint: upstream.baseUrl, requestBinding } });
|
||||
assert.deepEqual(hub.connection(source.id).upstreamModel.requestBinding, requestBinding);
|
||||
assert.deepEqual(hub.connection(result.added[1]), previous.connections.find(model => model.id === result.added[1]));
|
||||
assert.equal(provider.credentials.get(source.id), keyObject); assert.equal(hub.credential(hub.connection(source.id)), keyObject);
|
||||
assert.deepEqual(f.store.storage.meta('modelCredentials'), encrypted);
|
||||
|
||||
Reference in New Issue
Block a user