(args, fallbackCommand)
| 705 | } |
| 706 | |
| 707 | function extractModelToolPayload(args, fallbackCommand) { |
| 708 | if (typeof args === 'string' && args.trim()) { |
| 709 | return args.trim(); |
| 710 | } |
| 711 | if (!args || typeof args !== 'object') { |
| 712 | return String(fallbackCommand || '').trim(); |
| 713 | } |
| 714 | for (const key of ['input', 'cmd', 'command', 'bash_command']) { |
| 715 | if (typeof args[key] === 'string' && args[key].trim()) { |
| 716 | return args[key].trim(); |
| 717 | } |
| 718 | } |
| 719 | const picked = {}; |
| 720 | ['query', 'path', 'pattern', 'skill', 'filePath', 'old_path', 'new_path'].forEach((key) => { |
| 721 | if (typeof args[key] === 'string' && args[key].trim()) { |
| 722 | picked[key] = args[key].trim(); |
| 723 | } |
| 724 | }); |
| 725 | if (Array.isArray(args.urls) && args.urls.length) { |
| 726 | picked.urls = args.urls; |
| 727 | } |
| 728 | return Object.keys(picked).length ? JSON.stringify(picked, null, 2) : String(fallbackCommand || '').trim(); |
| 729 | } |
| 730 | |
| 731 | function extractFirstPath(text) { |
| 732 | const match = String(text || '').match(/\/(?:[^\s`*]|\\ )+/); |
no outgoing calls
no test coverage detected