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

Function buildNativeCascadeToolConfig

src/windsurf.js:641–680  ·  view source on GitHub ↗

* Build a minimal CascadeToolConfig for native bridge mode. * * field numbers (exa.cortex_pb.proto, message CascadeToolConfig): * 8 RunCommandToolConfig run_command * 10 ViewFileToolConfig view_file * 19 ListDirToolConfig list_dir * 13 SearchWebToolConfig search_web * 37 Read

(allowlist = null)

Source from the content-addressed store, hash-verified

639 * there stay disabled even if their sub-config is present.
640 */
641function buildNativeCascadeToolConfig(allowlist = null) {
642 const list = Array.isArray(allowlist) && allowlist.length
643 ? allowlist
644 : ['view_file', 'run_command', 'grep_search_v2', 'find', 'list_dir'];
645 const enabled = nativeToolConfigSwitches(list);
646 const rawSubconfigs = parseNativeToolConfigRawOverrides();
647 const parts = [];
648 // Empty messages = "use defaults" for each enabled tool. For protocol
649 // reverse-engineering only, WINDSURFAPI_NATIVE_TOOL_BRIDGE_CONFIG_RAW can
650 // replace a sub-message body with exact protobuf bytes.
651 if (enabled.runCommand) {
652 parts.push(writeNativeToolConfigField(8, 'run_command', rawSubconfigs));
653 }
654 if (enabled.viewFile) {
655 parts.push(writeNativeToolConfigField(10, 'view_file', rawSubconfigs));
656 }
657 if (enabled.listDir) {
658 parts.push(writeNativeToolConfigField(19, 'list_dir', rawSubconfigs));
659 }
660 if (enabled.grepV2) {
661 parts.push(writeNativeToolConfigField(33, 'grep_v2', rawSubconfigs));
662 }
663 if (enabled.find) {
664 parts.push(writeNativeToolConfigField(5, 'find', rawSubconfigs));
665 }
666 if (enabled.searchWeb) {
667 parts.push(writeNativeToolConfigField(13, 'search_web', rawSubconfigs));
668 }
669 if (enabled.readUrlContent) {
670 parts.push(writeNativeToolConfigField(37, 'read_url_content', rawSubconfigs));
671 }
672 for (const [field, payload] of rawSubconfigs.unknownFields) {
673 parts.push(writeBytesField(field, payload));
674 }
675 // tool_allowlist (field 32, repeated string)
676 for (const name of list) {
677 parts.push(writeStringField(32, name));
678 }
679 return Buffer.concat(parts);
680}
681
682function writeNativeToolConfigField(field, kind, rawSubconfigs) {
683 // writeMessageField intentionally drops empty buffers for most call sites;

Callers 1

buildCascadeConfigFunction · 0.85

Calls 6

writeBytesFieldFunction · 0.90
writeStringFieldFunction · 0.90
nativeToolConfigSwitchesFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected