MCPcopy
hub / github.com/Doorman11991/smallcode / parseLiquidToolCalls

Function parseLiquidToolCalls

src/tools/liquid_tool_parser.js:44–62  ·  view source on GitHub ↗

* @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)

Source from the content-addressed store, hash-verified

42 * stripped after a successful extraction
43 */
44function 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

Callers 2

extractFromMessageFunction · 0.85

Calls 1

_parseCallListFunction · 0.85

Tested by

no test coverage detected