Merge branch 'codex/tool-json-schema-dsl' into codex/canonical-tool-output

# Conflicts:
#	packages/core/tools/src/schema.ts
This commit is contained in:
Tianyi Cui
2026-07-21 21:44:00 +08:00
7 changed files with 75 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
import { runInNewContext } from 'node:vm'
import { describe, expect, it } from 'vitest'
import {
assertObjectJsonSchema,
@@ -187,6 +188,16 @@ describe('the enforced raw JSON Schema subset', () => {
.toEqual(['schema.examples annotation must be lossless JSON data'])
})
it('accepts lossless annotation containers from another JavaScript realm', () => {
const schema = runInNewContext(`({
type: 'object',
default: { x: 1 },
examples: [[{ ok: true }]],
})`) as unknown
expect(() => { assertSupportedJsonSchema(schema) }).not.toThrow()
})
it('rejects cyclic/exotic schema structure but permits sibling reuse', () => {
const cyclic: Record<string, unknown> = { type: 'object' }
cyclic.properties = { self: cyclic }

View File

@@ -1807,6 +1807,25 @@ describe('defineTool validation (the runtime-validation Agent Note, part 1)', ()
})
describe('defineTool presentation (presentCall / presentResult)', () => {
it('preserves inline enum and const literals in inferred arguments', () => {
defineTool({
name: 'literal-args',
description: 'literal arguments',
parameters: {
mode: { type: 'string', enum: ['read', 'write'], required: true },
attempt: { type: 'integer', const: 1 },
},
output: {
schema: { type: 'null' },
render: () => [],
},
async execute(args) {
expectTypeOf(args).toEqualTypeOf<{ mode: 'read' | 'write'; attempt?: 1 }>()
return null
},
})
})
it('threads presentCall/presentResult onto the ToolDefinition with typed args', () => {
const tool = defineContentToolFixture({
name: 'demo',