* @param {string} content Text from `message.content` * @returns {{ calls: Array<{name:string, arguments:object}>, ranges: Array<[number,number]> }} * `calls` — extracted, in document order * `ranges` — [start, end) spans in the original content that should be * stripped afte
(content)
| 42 | * stripped after a successful extraction |
| 43 | */ |
| 44 | function parseLiquidToolCalls(content) { |
| 45 | if (typeof content !== 'string' || !content.includes('tool_call')) { |
| 46 | return { calls: [], ranges: [] }; |
| 47 | } |
| 48 | |
| 49 | const calls = []; |
| 50 | const ranges = []; |
| 51 | |
| 52 | for (const match of content.matchAll(LIQUID_BLOCK_RE)) { |
| 53 | const inner = match[1].trim(); |
| 54 | const parsed = _parseCallList(inner); |
| 55 | if (parsed.length > 0) { |
| 56 | for (const c of parsed) calls.push(c); |
| 57 | ranges.push([match.index, match.index + match[0].length]); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | return { calls, ranges }; |
| 62 | } |
| 63 | |
| 64 | // ── Internal: parse `[func1(...), func2(...)]` or bare `func(...)` ────────── |
| 65 |
no test coverage detected