(_ context.Context, params ViewBackgroundJobArgs)
| 434 | } |
| 435 | |
| 436 | func (h *shellHandler) ViewBackgroundJob(_ context.Context, params ViewBackgroundJobArgs) (*tools.ToolCallResult, error) { |
| 437 | job, exists := h.jobs.Load(params.JobID) |
| 438 | if !exists { |
| 439 | return tools.ResultError("Job not found: " + params.JobID), nil |
| 440 | } |
| 441 | |
| 442 | status := job.status.Load() |
| 443 | |
| 444 | job.outputMu.RLock() |
| 445 | output := job.output.String() |
| 446 | exitCode := job.exitCode |
| 447 | job.outputMu.RUnlock() |
| 448 | |
| 449 | var result strings.Builder |
| 450 | fmt.Fprintf(&result, "Job ID: %s\n", job.id) |
| 451 | fmt.Fprintf(&result, "Command: %s\n", job.cmd) |
| 452 | fmt.Fprintf(&result, "Status: %s\n", statusToString(status)) |
| 453 | fmt.Fprintf(&result, "Runtime: %s\n", time.Since(job.startTime).Round(time.Second)) |
| 454 | if status != statusRunning { |
| 455 | fmt.Fprintf(&result, "Exit Code: %d\n", exitCode) |
| 456 | } |
| 457 | result.WriteString("\n--- Output ---\n") |
| 458 | if output == "" { |
| 459 | result.WriteString("<no output>\n") |
| 460 | } else { |
| 461 | result.WriteString(output) |
| 462 | if len(output) >= 10*1024*1024 { |
| 463 | result.WriteString("\n\n[Output truncated at 10MB limit]") |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | return tools.ResultSuccess(result.String()), nil |
| 468 | } |
| 469 | |
| 470 | func (h *shellHandler) StopBackgroundJob(_ context.Context, params StopBackgroundJobArgs) (*tools.ToolCallResult, error) { |
| 471 | job, exists := h.jobs.Load(params.JobID) |
nothing calls this directly
no test coverage detected