MCPcopy Create free account
hub / github.com/53AI/53AIHub / buildSandboxRequest

Function buildSandboxRequest

api/service/tools/executor.go:2042–2065  ·  view source on GitHub ↗

buildSandboxRequest constructs a sandbox request from context and parameters

(ctx context.Context, language string, code string)

Source from the content-addressed store, hash-verified

2040
2041// buildSandboxRequest constructs a sandbox request from context and parameters
2042func buildSandboxRequest(ctx context.Context, language string, code string) SandboxRequest {
2043 code = normalizeSandboxTextContentForLanguage(language, code)
2044 reqPayload := SandboxRequest{
2045 Code: code,
2046 Language: language,
2047 Timeout: 30,
2048 SessionID: resolveSandboxSessionID(ctx, map[string]interface{}{}),
2049 Cwd: resolveSandboxCWD(ctx, map[string]interface{}{}),
2050 EnvVars: resolveSandboxEnvVars(ctx, map[string]interface{}{}),
2051 }
2052
2053 // Inject skill files if available. When no explicit resources are declared, seed the
2054 // entire skill directory so script-based skills can execute relative paths directly.
2055 if files, err := buildSkillFilesForSandbox(ctx); err != nil {
2056 logger.Warnf(ctx, "Failed to read skill files: %v", err)
2057 } else if len(files) > 0 {
2058 reqPayload.Files = files
2059 if skillRootPath, ok := ctx.Value(SkillRootPathKey).(string); ok && skillRootPath != "" {
2060 logger.Infof(ctx, "Injected %d files from skill path: %s", len(files), skillRootPath)
2061 }
2062 }
2063
2064 return reqPayload
2065}
2066
2067// parseSSEStream reads SSE events from response body and calls handler
2068// Returns final ToolResult after parsing tool.completed event

Callers 3

executeSandboxCodeFunction · 0.85
executeSandboxCodeStreamFunction · 0.85

Calls 7

resolveSandboxSessionIDFunction · 0.85
resolveSandboxCWDFunction · 0.85
resolveSandboxEnvVarsFunction · 0.85
WarnfMethod · 0.80
InfofMethod · 0.80

Tested by

no test coverage detected