executeBackground starts a process in the background and returns immediately with the process ID.
( ctx context.Context, conn workspacesdk.AgentConn, command string, workDir string, env map[string]string, )
| 149 | // executeBackground starts a process in the background and |
| 150 | // returns immediately with the process ID. |
| 151 | func executeBackground( |
| 152 | ctx context.Context, |
| 153 | conn workspacesdk.AgentConn, |
| 154 | command string, |
| 155 | workDir string, |
| 156 | env map[string]string, |
| 157 | ) fantasy.ToolResponse { |
| 158 | resp, err := conn.StartProcess(ctx, workspacesdk.StartProcessRequest{ |
| 159 | Command: command, |
| 160 | WorkDir: workDir, |
| 161 | Env: env, |
| 162 | Background: true, |
| 163 | }) |
| 164 | if err != nil { |
| 165 | return errorResult(fmt.Sprintf("start background process: %v", err)) |
| 166 | } |
| 167 | |
| 168 | result := ExecuteResult{ |
| 169 | Success: true, |
| 170 | BackgroundProcessID: resp.ID, |
| 171 | } |
| 172 | data, err := json.Marshal(result) |
| 173 | if err != nil { |
| 174 | return fantasy.NewTextErrorResponse(err.Error()) |
| 175 | } |
| 176 | return fantasy.NewTextResponse(string(data)) |
| 177 | } |
| 178 | |
| 179 | // executeForeground starts a process and waits for its |
| 180 | // completion, enforcing the configured timeout. |
no test coverage detected