Preserve long histories and parsed attachments, expose paged process and Subagent output, isolate MCP discovery failures, and expand browser snapshots and knowledge result selection. Remove fixed Harness output and updated remote Runtime duration limits. Keep released Agent profile and v1 bridge compatibility while enabling larger framed exchanges and optional limits for updated peers. Document remote coverage requirements and real-model boundary validation. Release note: Long model tasks can retain more context and continue reading complete tool output; remote execution preserves compatibility with released Agents. Updated remote limits require an updated Agent and Runtime bundle.
87 lines
2.5 KiB
TypeScript
87 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
REMOTE_MODEL_GATEWAY_LIMITS,
|
|
remoteModelGatewayRequestSchema,
|
|
remoteModelGatewayResponseSchema
|
|
} from './remote-model-gateway-contracts'
|
|
|
|
const validRequest = {
|
|
method: 'POST',
|
|
path: '/v1/messages',
|
|
headers: {
|
|
accept: 'application/json',
|
|
'content-type': 'application/json'
|
|
},
|
|
bodyBase64: Buffer.from('{"messages":[]}').toString('base64')
|
|
} as const
|
|
|
|
describe('remote model gateway contracts', () => {
|
|
it('accepts request and response bodies above the old 768 KiB ceiling', () => {
|
|
const bodyBase64 = Buffer.alloc(2 * 1024 * 1024, 'x').toString('base64')
|
|
expect(remoteModelGatewayRequestSchema.parse({ ...validRequest, bodyBase64 }).bodyBase64).toBe(bodyBase64)
|
|
expect(remoteModelGatewayResponseSchema.parse({ status: 200, headers: {}, bodyBase64 }).bodyBase64).toBe(bodyBase64)
|
|
})
|
|
|
|
it('accepts only POST requests to fixed provider API paths', () => {
|
|
expect(remoteModelGatewayRequestSchema.parse(validRequest)).toEqual(
|
|
validRequest
|
|
)
|
|
for (const path of [
|
|
'https://api.example/v1/messages',
|
|
'//api.example/v1/messages',
|
|
'/v1/messages?key=secret',
|
|
'/v1/messages#fragment',
|
|
'/v1/../messages',
|
|
'/images/generations'
|
|
]) {
|
|
expect(() =>
|
|
remoteModelGatewayRequestSchema.parse({ ...validRequest, path })
|
|
).toThrow()
|
|
}
|
|
expect(() =>
|
|
remoteModelGatewayRequestSchema.parse({
|
|
...validRequest,
|
|
method: 'GET'
|
|
})
|
|
).toThrow()
|
|
})
|
|
|
|
it('rejects credentials and arbitrary headers', () => {
|
|
for (const headers of [
|
|
{ authorization: 'Bearer remote-secret' },
|
|
{ 'x-api-key': 'remote-secret' },
|
|
{ cookie: 'private=value' },
|
|
{ Accept: 'application/json' },
|
|
{ accept: 'ok\r\nx-injected: true' }
|
|
]) {
|
|
expect(() =>
|
|
remoteModelGatewayRequestSchema.parse({ ...validRequest, headers })
|
|
).toThrow()
|
|
}
|
|
})
|
|
|
|
it('enforces decoded byte limits and canonical base64', () => {
|
|
expect(() =>
|
|
remoteModelGatewayRequestSchema.parse({
|
|
...validRequest,
|
|
bodyBase64: Buffer.alloc(
|
|
REMOTE_MODEL_GATEWAY_LIMITS.maximumRequestBodyBytes + 1
|
|
).toString('base64')
|
|
})
|
|
).toThrow()
|
|
expect(() =>
|
|
remoteModelGatewayRequestSchema.parse({
|
|
...validRequest,
|
|
bodyBase64: 'not base64'
|
|
})
|
|
).toThrow()
|
|
expect(() =>
|
|
remoteModelGatewayResponseSchema.parse({
|
|
status: 200,
|
|
headers: { authorization: 'Bearer secret' },
|
|
bodyBase64: ''
|
|
})
|
|
).toThrow()
|
|
})
|
|
})
|