MCPcopy Create free account
hub / github.com/clawbot7/cli-gateway / parseToolActionPart

Function parseToolActionPart

src/gateway/bindingRuntime.ts:848–872  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

846}
847
848function parseToolActionPart(text: string): ToolAction | null {
849 const trimmed = text.trim();
850 if (!trimmed) return null;
851
852 const patterns: Array<[RegExp, ToolActionVerb]> = [
853 [/^(?:run|execute)\s+(.+)$/i, 'run'],
854 [/^(?:read|view)\s+(.+)$/i, 'read'],
855 [/^(?:write|edit|modify|update)\s+(.+)$/i, 'edit'],
856 [/^(?:list)\s+(.+)$/i, 'list'],
857 [/^(?:search|find|grep)\s+(.+)$/i, 'search'],
858 [/^(?:fetch|download|request)\s+(.+)$/i, 'fetch'],
859 [/^(?:move|rename)\s+(.+)$/i, 'move'],
860 [/^(?:delete|remove|rm)\s+(.+)$/i, 'delete'],
861 ];
862
863 for (const [pattern, verb] of patterns) {
864 const match = trimmed.match(pattern);
865 if (!match) continue;
866 const target = match[1]?.trim();
867 if (!target) return null;
868 return { verb, target };
869 }
870
871 return null;
872}
873
874function summarizeInferredActions(
875 actions: ToolAction[],

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected