mirror of
https://github.com/Gitlawb/openclaude.git
synced 2026-11-06 20:58:14 -04:00
perf(types): keep default-heap Node 24 typecheck under the heap limit (#2414)
* fix(types): narrow SDK response schema consumers * perf(types): bound mixed Zod schema comparisons
This commit is contained in:
@@ -134,7 +134,8 @@ function buildRequiresActionDetails(
|
||||
type PendingRequest<T> = {
|
||||
resolve: (result: T) => void
|
||||
reject: (error: unknown) => void
|
||||
schema?: z.Schema
|
||||
// Response consumers only parse; avoid comparing Zod's fluent builder types.
|
||||
schema?: Pick<z.Schema, 'parse'>
|
||||
request: SDKControlRequest
|
||||
}
|
||||
|
||||
@@ -496,7 +497,7 @@ export class StructuredIO {
|
||||
|
||||
private async sendRequest<Response>(
|
||||
request: SDKControlRequest['request'],
|
||||
schema: z.Schema,
|
||||
schema: Pick<z.Schema, 'parse'>,
|
||||
signal?: AbortSignal,
|
||||
requestId: string = randomUUID(),
|
||||
): Promise<Response> {
|
||||
@@ -798,7 +799,7 @@ export class StructuredIO {
|
||||
message,
|
||||
},
|
||||
z.object({
|
||||
mcp_response: z.any() as z.Schema<JSONRPCMessage>,
|
||||
mcp_response: z.any() as z.core.$ZodType<JSONRPCMessage>,
|
||||
}),
|
||||
)
|
||||
return response.mcp_response
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
import { zodOutputFormat } from '@anthropic-ai/sdk/helpers/zod'
|
||||
import { SandboxRuntimeConfigSchema } from '@anthropic-ai/sandbox-runtime'
|
||||
import type { AnySchema } from '@modelcontextprotocol/sdk/server/zod-compat.js'
|
||||
import { parseWithCompat, toJsonSchemaCompat } from '@modelcontextprotocol/sdk/server/zod-json-schema-compat.js'
|
||||
import { z as legacy } from 'zod/v3'
|
||||
import { z } from 'zod/v4'
|
||||
@@ -14,7 +15,12 @@ describe('dependency schema compatibility', () => {
|
||||
})
|
||||
|
||||
test('the protocol converter and parser support both packaged schema generations', () => {
|
||||
for (const schema of [z.strictObject({ value: z.string() }), legacy.object({ value: legacy.string() }).strict()]) {
|
||||
// Avoid finding a common type by comparing both versions' fluent builders.
|
||||
const schemas: AnySchema[] = [
|
||||
z.strictObject({ value: z.string() }),
|
||||
legacy.object({ value: legacy.string() }).strict(),
|
||||
]
|
||||
for (const schema of schemas) {
|
||||
expect(toJsonSchemaCompat(schema).type).toBe('object')
|
||||
expect(parseWithCompat(schema, { value: 'ok' })).toEqual({ value: 'ok' })
|
||||
expect(() => parseWithCompat(schema, { value: 1 })).toThrow()
|
||||
|
||||
Reference in New Issue
Block a user