MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / handleToolSearchSelect

Function handleToolSearchSelect

tools/builtin.go:888–949  ·  view source on GitHub ↗
(query string, registry *ToolRegistry)

Source from the content-addressed store, hash-verified

886 if runtimeDir := projectRuntimeDirFromContext(execCtx, cwd); strings.TrimSpace(runtimeDir) != "" {
887 _ = os.MkdirAll(runtimeDir, 0o755)
888 }
889 readRoots := append([]string{cwd}, rootsFromAny(execCtx["allowed_read_roots"])...)
890 writeRoots := append([]string{cwd}, rootsFromAny(execCtx["allowed_write_roots"])...)
891 argv = t.sandboxManager.GetSandboxCommand(in.Command, bashpkg.SandboxConfig{
892 Enabled: true, AllowWrite: writeRoots, AllowRead: readRoots, AllowNetwork: false, AllowProcesses: true,
893 }, cwd)
894 if len(argv) == 0 {
895 return "<tool_use_error>\nSandbox initialization failed. The command was not executed. Enable YOLO mode explicitly to run without sandbox isolation.\n</tool_use_error>", nil
896 }
897 }
898
899 if in.RunInBackground {
900 return t.executeBackground(execCtx, in.Command, in.Description, argv, cwd, timeout)
901 }
902
903 var exitCode int
904 var output string
905 exitCode, output = runArgvCommand(ctx, argv, cwd, timeout, in.Command)
906 output = truncateBashOutput(output)
907 exitInfo := bashpkg.FormatExitCode(in.Command, exitCode)
908 parts := []string{exitInfo}
909 if strings.TrimSpace(resultPrefix) != "" {
910 parts = append(parts, resultPrefix)
911 }
912 if strings.TrimSpace(output) == "" {
913 return strings.Join(parts, "\n\n"), nil
914 }
915 parts = append(parts, output)
916 return strings.Join(parts, "\n\n"), nil
917}
918
919func (t *BashTool) SandboxSetupRequest(execCtx ExecutionContext, input any) (bool, map[string]any) {
920 in := deref[BashInput](input)
921 if in.RunInBackground {
922 return false, nil
923 }
924 cfg := configFromExecCtx(execCtx)
925 t.configureSandbox(cfg)
926 status := t.sandboxManager.WSLSetupStatus(in.Command, bashYoloEnabled(execCtx))
927 if !status.Needed {
928 return false, nil
929 }
930 return true, map[string]any{
931 "sandbox_setup_request": map[string]any{
932 "kind": "wsl-bwrap",
933 "distro": status.Distro,
934 "reason": status.Reason,
935 "image_url": status.ImageURL,
936 "image_path": status.ImagePath,
937 "can_install": status.CanInstall,
938 "allow_local_fallback": status.AllowLocalFallback,
939 },
940 "risk": "high",
941 "dangerous": true,
942 }
943}
944
945func (t *BashTool) configureSandbox(cfg config.Config) {

Callers 1

ExecuteMethod · 0.85

Calls 7

jsonMarshalCompactFunction · 0.85
toolSearchSimilarityFunction · 0.85
ActivateToolMethod · 0.80
GetDeferredToolNamesMethod · 0.80
ToAPISchemaMethod · 0.65
DescriptionMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected