buildSandboxRequest constructs a sandbox request from context and parameters
(ctx context.Context, language string, code string)
| 2040 | |
| 2041 | // buildSandboxRequest constructs a sandbox request from context and parameters |
| 2042 | func 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 |
no test coverage detected