* 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)
| 639 | * there stay disabled even if their sub-config is present. |
| 640 | */ |
| 641 | function 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 | |
| 682 | function writeNativeToolConfigField(field, kind, rawSubconfigs) { |
| 683 | // writeMessageField intentionally drops empty buffers for most call sites; |
no test coverage detected