(value: unknown)
| 454 | } |
| 455 | |
| 456 | function normalizeAgentTools(value: unknown) { |
| 457 | if (!value) return value |
| 458 | if (Array.isArray(value)) { |
| 459 | const record: Record<string, boolean> = {} |
| 460 | for (const item of value) { |
| 461 | if (typeof item !== "string") continue |
| 462 | const tool = normalizeToolName(item) |
| 463 | record[tool] = true |
| 464 | } |
| 465 | return record |
| 466 | } |
| 467 | if (typeof value === "string") { |
| 468 | const record: Record<string, boolean> = {} |
| 469 | for (const item of value |
| 470 | .split(",") |
| 471 | .map((x) => x.trim()) |
| 472 | .filter(Boolean)) { |
| 473 | const tool = normalizeToolName(item) |
| 474 | record[tool] = true |
| 475 | } |
| 476 | return record |
| 477 | } |
| 478 | if (typeof value === "object") return value |
| 479 | return value |
| 480 | } |
| 481 | |
| 482 | function normalizeToolName(value: string) { |
| 483 | const key = value.trim().toLowerCase().replace(/\s+/g, "_") |
no test coverage detected