Download packages/agent-core-v2/src/tool/tool-args-parse.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 603 Bytes
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/tool/tool-args-parse.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/agent-core-v2/src/tool/tool-args-parse.ts
-
curl -L -o tool-args-parse.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/tool/tool-args-parse.ts
603 Bytes
| export function parseToolCallArguments(raw: unknown): { | |
| readonly data: unknown; | |
| readonly parseFailed: boolean; | |
| readonly error?: string; | |
| } { | |
| if (raw === null || raw === undefined || (typeof raw === 'string' && raw.length === 0)) { | |
| return { data: {}, parseFailed: false }; | |
| } | |
| if (typeof raw !== 'string') { | |
| return { data: raw, parseFailed: false }; | |
| } | |
| try { | |
| return { data: JSON.parse(raw) as unknown, parseFailed: false }; | |
| } catch (error) { | |
| return { | |
| data: {}, | |
| parseFailed: true, | |
| error: error instanceof Error ? error.message : String(error), | |
| }; | |
| } | |
| } | |