From 6bff78eb05210073005125fec13b37c4b930e9db Mon Sep 17 00:00:00 2001 From: Peter <304086198+peter-research@users.noreply.github.com> Date: Wed, 14 Oct 2026 13:13:02 +0200 Subject: [PATCH 1/2] Align JSON value types with AI SDK readonly values --- common/src/types/json.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/types/json.ts b/common/src/types/json.ts index 244e9a31d8..32433b3d4d 100644 --- a/common/src/types/json.ts +++ b/common/src/types/json.ts @@ -5,8 +5,8 @@ export type JSONValue = | string | number | boolean - | JSONObject - | JSONArray + | Readonly + | readonly JSONValue[] export const jsonValueSchema: z.ZodType = z.lazy(() => z.union([ z.null(), @@ -26,4 +26,4 @@ export type JSONObject = { [key in string]: JSONValue | undefined } export const jsonArraySchema: z.ZodType = z.lazy(() => z.array(jsonValueSchema), ) -export type JSONArray = JSONValue[] +export type JSONArray = readonly JSONValue[] From e254403dc7d25e853c9ea52a945bbb92f00eb6fb Mon Sep 17 00:00:00 2001 From: Peter <304086198+peter-research@users.noreply.github.com> Date: Wed, 14 Oct 2026 13:13:11 +0200 Subject: [PATCH 2/2] Test compatibility with AI SDK provider option types --- .../json-provider-compatibility.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 common/src/types/__tests__/json-provider-compatibility.test.ts diff --git a/common/src/types/__tests__/json-provider-compatibility.test.ts b/common/src/types/__tests__/json-provider-compatibility.test.ts new file mode 100644 index 0000000000..7a199158ea --- /dev/null +++ b/common/src/types/__tests__/json-provider-compatibility.test.ts @@ -0,0 +1,23 @@ +import { describe, expect, test } from 'bun:test' +import type { ToolModelMessage } from 'ai' + +import type { ProviderMetadata } from '../messages/provider-metadata' + +function toLocalProviderMetadata( + options: NonNullable, +): ProviderMetadata { + return options +} + +describe('AI SDK provider metadata compatibility', () => { + test('accepts provider options containing nested JSON arrays and objects', () => { + const providerOptions: NonNullable = { + example: { + enabled: true, + nested: [1, { label: 'readonly JSON value' }], + }, + } + + expect(toLocalProviderMetadata(providerOptions)).toEqual(providerOptions) + }) +})