diff --git a/packages/cordis/tool-cordis/tests/mount.spec.ts b/packages/cordis/tool-cordis/tests/mount.spec.ts index 28ac6f2a5f..6bc2d5970d 100644 --- a/packages/cordis/tool-cordis/tests/mount.spec.ts +++ b/packages/cordis/tool-cordis/tests/mount.spec.ts @@ -392,6 +392,7 @@ describe('cordis_mount', () => { ['parameters: { value: { type: \'json\', default: (() => { const v = {}; v.self = v; return v })() } }', 'parameters.value.default.self must be lossless JSON data'], ['parameters: { value: { type: \'json\', default: Array(2) } }', 'parameters.value.default must be lossless JSON data'], ['parameters: { value: { type: \'json\', default: Object.assign([1], { extra: true }) } }', 'parameters.value.default must be lossless JSON data'], + ['parameters: { value: { type: \'json\', default: (() => { const v = Array(1); v.extra = true; return v })() } }', 'parameters.value.default must be lossless JSON data'], ['parameters: { value: { type: \'json\', default: new (class DefaultValue { constructor() { this.ok = true } })() } }', 'parameters.value.default must be lossless JSON data'], ['parameters: { value: { type: \'json\', default: new Date(0) } }', 'parameters.value.default must be lossless JSON data'], ])('rejects a malformed ParameterSchemaSpec (%s) with a teaching error', async (parameters, message) => { diff --git a/packages/core/session/tests/json.spec.ts b/packages/core/session/tests/json.spec.ts index 435126c22e..35d521f6d1 100644 --- a/packages/core/session/tests/json.spec.ts +++ b/packages/core/session/tests/json.spec.ts @@ -69,6 +69,8 @@ describe('snapshotJsonValue', () => { } class ExoticArray extends Array {} const sparse = new Array(1) + const compensatedSparse = new Array(1) + Object.defineProperty(compensatedSparse, 'extra', { value: true }) const decorated = [1] Object.defineProperty(decorated, 'extra', { value: true }) const symbolDecorated = [1] @@ -80,6 +82,7 @@ describe('snapshotJsonValue', () => { expect(snapshotJsonValue(new Map([['value', 1]]))).toBeUndefined() expect(snapshotJsonValue(new ExoticArray(1))).toBeUndefined() expect(snapshotJsonValue(sparse)).toBeUndefined() + expect(snapshotJsonValue(compensatedSparse)).toBeUndefined() expect(snapshotJsonValue(decorated)).toBeUndefined() expect(snapshotJsonValue(symbolDecorated)).toBeUndefined() expect(snapshotJsonValue(cyclic)).toBeUndefined() @@ -145,6 +148,8 @@ describe('isJsonValue', () => { } class ExoticArray extends Array {} const sparse = new Array(1) + const compensatedSparse = new Array(1) + Object.defineProperty(compensatedSparse, 'extra', { value: true }) const decorated = Object.assign([1], { extra: true }) const symbolDecorated = [1] Object.defineProperty(symbolDecorated, Symbol('extra'), { value: true }) @@ -152,6 +157,7 @@ describe('isJsonValue', () => { cyclic.self = cyclic expect(isJsonValue(sparse)).toBe(false) + expect(isJsonValue(compensatedSparse)).toBe(false) expect(isJsonValue(decorated)).toBe(false) expect(isJsonValue(symbolDecorated)).toBe(false) expect(isJsonValue(new ExoticArray(1))).toBe(false) diff --git a/packages/core/tools/tests/properties.spec.ts b/packages/core/tools/tests/properties.spec.ts index 54c4088909..e04e9f5c5b 100644 --- a/packages/core/tools/tests/properties.spec.ts +++ b/packages/core/tools/tests/properties.spec.ts @@ -7,6 +7,7 @@ import { describe, expect, it } from 'vitest' import fc from 'fast-check' +import { isJsonValue } from '@deepseek-ai/dsh-session' import { parameterSchemaSpecToJsonSchema, validateArgs } from '@deepseek-ai/dsh-tools' import type { ParameterPropertySpec, ParameterSchemaSpec, ValueSchemaSpec } from '@deepseek-ai/dsh-tools' @@ -80,7 +81,7 @@ function valueForProp(prop: ParameterPropertySpec): fc.Arbitrary { case 'null': return fc.constant(null) case 'object': return prop.properties ? validArgsForSpec(prop.properties) : fc.constant({}) case 'array': return prop.items ? fc.array(valueForProp(prop.items), { maxLength: 3 }) : fc.constant([]) - case 'json': return fc.jsonValue() + case 'json': return fc.jsonValue().filter(value => isJsonValue(value)) } }