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

Method ExecuteCodeStream

api/service/sandbox/client.go:157–180  ·  view source on GitHub ↗
(ctx context.Context, req ExecuteCodeRequest)

Source from the content-addressed store, hash-verified

155}
156
157func (c *Client) ExecuteCodeStream(ctx context.Context, req ExecuteCodeRequest) (*http.Response, error) {
158 jsonData, err := json.Marshal(req)
159 if err != nil {
160 return nil, fmt.Errorf("failed to marshal request: %v", err)
161 }
162
163 httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/execute/stream", bytes.NewBuffer(jsonData))
164 if err != nil {
165 return nil, err
166 }
167 httpReq.Header.Set("Content-Type", "application/json")
168 httpReq.Header.Set("Accept", "text/event-stream")
169
170 resp, err := c.httpClient.Do(httpReq)
171 if err != nil {
172 return nil, err
173 }
174 if resp.StatusCode != http.StatusOK {
175 defer resp.Body.Close()
176 body, _ := io.ReadAll(resp.Body)
177 return nil, fmt.Errorf("sandbox streaming failed (status %d): %s", resp.StatusCode, string(body))
178 }
179 return resp, nil
180}
181
182func (c *Client) ExecuteShell(ctx context.Context, req ShellRequest) (*ShellResponse, error) {
183 var resp ShellResponse

Callers 1

executeSandboxCodeStreamFunction · 0.80

Calls 4

ErrorfMethod · 0.80
SetMethod · 0.80
DoMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected