Download packages/agent-core-v2/src/tool/input-schema.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 719 Bytes
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/tool/input-schema.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/agent-core-v2/src/tool/input-schema.ts
-
curl -L -o input-schema.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/tool/input-schema.ts
719 Bytes
| import { z } from 'zod'; | |
| export function toInputJsonSchema(schema: z.ZodType): Record<string, unknown> { | |
| const jsonSchema = z.toJSONSchema(schema, { | |
| target: 'draft-7', | |
| io: 'input', | |
| }); | |
| closeObjectNodes(jsonSchema); | |
| return jsonSchema; | |
| } | |
| function closeObjectNodes(value: unknown): void { | |
| if (Array.isArray(value)) { | |
| for (const item of value) closeObjectNodes(item); | |
| return; | |
| } | |
| if (typeof value !== 'object' || value === null) return; | |
| const node = value as Record<string, unknown>; | |
| if (node['type'] === 'object' && node['additionalProperties'] === undefined) { | |
| node['additionalProperties'] = false; | |
| } | |
| for (const child of Object.values(node)) { | |
| closeObjectNodes(child); | |
| } | |
| } | |