MCPcopy Index your code
hub / github.com/docker/docker-agent / ViewBackgroundJob

Method ViewBackgroundJob

pkg/tools/builtin/shell/shell.go:436–468  ·  view source on GitHub ↗
(_ context.Context, params ViewBackgroundJobArgs)

Source from the content-addressed store, hash-verified

434}
435
436func (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
470func (h *shellHandler) StopBackgroundJob(_ context.Context, params StopBackgroundJobArgs) (*tools.ToolCallResult, error) {
471 job, exists := h.jobs.Load(params.JobID)

Callers

nothing calls this directly

Calls 5

ResultErrorFunction · 0.92
ResultSuccessFunction · 0.92
statusToStringFunction · 0.85
LoadMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected