10 "github.com/charmbracelet/crush/internal/shell"
14 JobOutputToolName = "job_output"
17//go:embed job_output.md
18var jobOutputDescription []byte
20type JobOutputParams struct {
21 ShellID string `json:"shell_id" description:"The ID of the background shell to retrieve output from"`
24type JobOutputResponseMetadata struct {
25 ShellID string `json:"shell_id"`
26 Command string `json:"command"`
27 Description string `json:"description"`
28 Done bool `json:"done"`
29 WorkingDirectory string `json:"working_directory"`
32func NewJobOutputTool() fantasy.AgentTool {
33 return fantasy.NewAgentTool(
35 string(jobOutputDescription),
36 func(ctx context.Context, params JobOutputParams, call fantasy.ToolCall) (fantasy.ToolResponse, error) {
37 if params.ShellID == "" {
38 return fantasy.NewTextErrorResponse("missing shell_id"), nil
41 bgManager := shell.GetBackgroundShellManager()
42 bgShell, ok := bgManager.Get(params.ShellID)
44 return fantasy.NewTextErrorResponse(fmt.Sprintf("background shell not found: %s", params.ShellID)), nil
47 stdout, stderr, done, err := bgShell.GetOutput()
49 var outputParts []string
51 outputParts = append(outputParts, stdout)
54 outputParts = append(outputParts, stderr)
61 exitCode := shell.ExitCode(err)
63 outputParts = append(outputParts, fmt.Sprintf("Exit code %d", exitCode))
68 output := strings.Join(outputParts, "\n")
70 metadata := JobOutputResponseMetadata{
71 ShellID: params.ShellID,
72 Command: bgShell.Command,
73 Description: bgShell.Description,
75 WorkingDirectory: bgShell.WorkingDir,
82 result := fmt.Sprintf("Status: %s\n\n%s", status, output)
83 return fantasy.WithResponseMetadata(fantasy.NewTextResponse(result), metadata), nil
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list