MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / normalizeNativeToolConfigKind

Function normalizeNativeToolConfigKind

src/windsurf.js:706–742  ·  view source on GitHub ↗
(kind)

Source from the content-addressed store, hash-verified

704}
705
706function normalizeNativeToolConfigKind(kind) {
707 const key = String(kind || '').trim();
708 const fieldMatch = key.match(/^(?:field_|field|f)([1-9]\d{0,8})$/i);
709 if (fieldMatch) {
710 const n = Number(fieldMatch[1]);
711 if (!Number.isInteger(n) || n <= 0 || n > 536870911 || n === 32) {
712 throw new Error(`Invalid native tool config field override: ${key}`);
713 }
714 return n;
715 }
716 const map = new Map([
717 ['run_command', 'run_command'],
718 ['shell_command', 'run_command'],
719 ['bash', 'run_command'],
720 ['view_file', 'view_file'],
721 ['read_file', 'view_file'],
722 ['read', 'view_file'],
723 ['list_dir', 'list_dir'],
724 ['list_directory', 'list_dir'],
725 ['grep_v2', 'grep_v2'],
726 ['grep_search_v2', 'grep_v2'],
727 ['grep_search', 'grep_v2'],
728 ['grep', 'grep_v2'],
729 ['find', 'find'],
730 ['glob', 'find'],
731 ['search_web', 'search_web'],
732 ['web_search', 'search_web'],
733 ['websearch', 'search_web'],
734 ['toolsearch', 'search_web'],
735 ['read_url_content', 'read_url_content'],
736 ['web_fetch', 'read_url_content'],
737 ['webfetch', 'read_url_content'],
738 ]);
739 const normalized = map.get(key.toLowerCase());
740 if (!normalized) throw new Error(`Unknown native tool config kind: ${key}`);
741 return normalized;
742}
743
744function decodeNativeToolConfigRawPayload(rawValue) {
745 let value = String(rawValue || '').trim();

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected