| 139 | }; |
| 140 | |
| 141 | function mapTools(tools: unknown): string[] | undefined { |
| 142 | if (!tools) return undefined; |
| 143 | const list = Array.isArray(tools) ? tools : String(tools).split(','); |
| 144 | const out = new Set<string>(); |
| 145 | for (const t of list) { |
| 146 | const key = String(t).trim().toLowerCase().replace(/[^a-z0-9]/g, ''); |
| 147 | for (const mapped of TOOL_NAME_MAP[key] ?? []) out.add(mapped); |
| 148 | } |
| 149 | return out.size > 0 ? [...out] : undefined; |
| 150 | } |
| 151 | |
| 152 | function parseAgent(raw: string, fallbackName: string): { name: string; role: RoleConfig } | null { |
| 153 | const m = raw.match(/^---\s*\n([\s\S]*?)\n---\s*\r?\n?([\s\S]*)$/); |