ProcessList returns an AgentTool that lists all tracked processes on the workspace agent.
(options ProcessToolOptions)
| 486 | // ProcessList returns an AgentTool that lists all tracked |
| 487 | // processes on the workspace agent. |
| 488 | func ProcessList(options ProcessToolOptions) fantasy.AgentTool { |
| 489 | return fantasy.NewAgentTool( |
| 490 | "process_list", |
| 491 | "List all tracked processes in the workspace. "+ |
| 492 | "Returns process IDs, commands, status (running or "+ |
| 493 | "exited), and exit codes. Use this to discover "+ |
| 494 | "processes or check which are still running.", |
| 495 | func(ctx context.Context, _ struct{}, _ fantasy.ToolCall) (fantasy.ToolResponse, error) { |
| 496 | if options.GetWorkspaceConn == nil { |
| 497 | return fantasy.NewTextErrorResponse("workspace connection resolver is not configured"), nil |
| 498 | } |
| 499 | conn, err := options.GetWorkspaceConn(ctx) |
| 500 | if err != nil { |
| 501 | return fantasy.NewTextErrorResponse(err.Error()), nil |
| 502 | } |
| 503 | resp, err := conn.ListProcesses(ctx) |
| 504 | if err != nil { |
| 505 | return errorResult(fmt.Sprintf("list processes: %v", err)), nil |
| 506 | } |
| 507 | data, err := json.Marshal(resp) |
| 508 | if err != nil { |
| 509 | return fantasy.NewTextErrorResponse(err.Error()), nil |
| 510 | } |
| 511 | return fantasy.NewTextResponse(string(data)), nil |
| 512 | }, |
| 513 | ) |
| 514 | } |
| 515 | |
| 516 | // ProcessSignalArgs are the parameters accepted by the |
| 517 | // process_signal tool. |
no test coverage detected