Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ UPCOMING_CHANGELOG.md
logs/
*.bun-build
tsconfig.tsbuildinfo
.emrg/
18 changes: 18 additions & 0 deletions packages/opencode/src/tool/json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ function normalize(value: unknown, options: { stripNull?: boolean } = {}): unkno
]),
)

// Convert tuple-style items (array) to prefixItems for JSON Schema 2020-12 compliance.
// Effect's Schema.toJsonSchemaDocument can produce items as an array (Draft 4/7 tuple
// format), but 2020-12 requires items to be a single schema or boolean. Convert to
// prefixItems + items: false to preserve tuple semantics.
if (Array.isArray(schema.items)) {
const prefixItems = schema.items
schema.prefixItems = prefixItems
schema.items = false
}

// Filter boolean exclusiveMinimum/exclusiveMaximum values produced by Effect's JSON
// Schema generation. Boolean constraints are invalid in 2020-12; only numeric
// exclusiveMinimum/exclusiveMaximum are allowed. (Zod-sourced schemas are already
// handled in registry.ts normalizeZodJsonSchema.)
for (const key of ["exclusiveMinimum", "exclusiveMaximum"] as const) {
if (typeof schema[key] === "boolean") delete schema[key]
}

if (schema.additionalProperties === true) delete schema.additionalProperties

if (options.stripNull && Array.isArray(schema.anyOf)) {
Expand Down
Loading