fix(opencode): avoid nullable webfetch format schema (#30215)
This commit is contained in:
@@ -17,7 +17,7 @@ export const Parameters = Schema.Struct({
|
|||||||
description: "The format to return the content in (text, markdown, or html). Defaults to markdown.",
|
description: "The format to return the content in (text, markdown, or html). Defaults to markdown.",
|
||||||
default: "markdown",
|
default: "markdown",
|
||||||
})
|
})
|
||||||
.pipe(Schema.optional, Schema.withDecodingDefault(Effect.succeed("markdown" as const))),
|
.pipe(Schema.withDecodingDefault(Effect.succeed("markdown" as const))),
|
||||||
timeout: Schema.optional(Schema.Number).annotate({ description: "Optional timeout in seconds (max 120)" }),
|
timeout: Schema.optional(Schema.Number).annotate({ description: "Optional timeout in seconds (max 120)" }),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -396,21 +396,14 @@ exports[`tool parameters JSON Schema (wire shape) webfetch 1`] = `
|
|||||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
"properties": {
|
"properties": {
|
||||||
"format": {
|
"format": {
|
||||||
"anyOf": [
|
"default": "markdown",
|
||||||
{
|
"description": "The format to return the content in (text, markdown, or html). Defaults to markdown.",
|
||||||
"default": "markdown",
|
"enum": [
|
||||||
"description": "The format to return the content in (text, markdown, or html). Defaults to markdown.",
|
"text",
|
||||||
"enum": [
|
"markdown",
|
||||||
"text",
|
"html",
|
||||||
"markdown",
|
|
||||||
"html",
|
|
||||||
],
|
|
||||||
"type": "string",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "null",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
|
"type": "string",
|
||||||
},
|
},
|
||||||
"timeout": {
|
"timeout": {
|
||||||
"description": "Optional timeout in seconds (max 120)",
|
"description": "Optional timeout in seconds (max 120)",
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ describe("tool parameters", () => {
|
|||||||
properties: { value: { minimum: Number.MIN_SAFE_INTEGER, maximum: Number.MAX_SAFE_INTEGER } },
|
properties: { value: { minimum: Number.MIN_SAFE_INTEGER, maximum: Number.MAX_SAFE_INTEGER } },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("does not expose defaulted optional keys as nullable", () => {
|
||||||
|
expect(toJsonSchema(WebFetch)).toMatchObject({
|
||||||
|
properties: { format: { type: "string", enum: ["text", "markdown", "html"], default: "markdown" } },
|
||||||
|
})
|
||||||
|
expect(toJsonSchema(WebFetch).properties?.format).not.toHaveProperty("anyOf")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("apply_patch", () => {
|
describe("apply_patch", () => {
|
||||||
@@ -257,8 +264,15 @@ describe("tool parameters", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("webfetch", () => {
|
describe("webfetch", () => {
|
||||||
test("accepts url-only", () => {
|
test("defaults omitted format to markdown", () => {
|
||||||
expect(parse(WebFetch, { url: "https://example.com" }).url).toBe("https://example.com")
|
expect(parse(WebFetch, { url: "https://example.com" })).toEqual({
|
||||||
|
url: "https://example.com",
|
||||||
|
format: "markdown",
|
||||||
|
})
|
||||||
|
expect(parse(WebFetch, { url: "https://example.com", format: undefined })).toEqual({
|
||||||
|
url: "https://example.com",
|
||||||
|
format: "markdown",
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user