MCPcopy Index your code
hub / github.com/coder/coder / Execute

Function Execute

coderd/x/chatd/chattool/execute.go:92–107  ·  view source on GitHub ↗

Execute returns an AgentTool that runs a shell command in the workspace via the agent HTTP API.

(options ExecuteOptions)

Source from the content-addressed store, hash-verified

90// Execute returns an AgentTool that runs a shell command in the
91// workspace via the agent HTTP API.
92func Execute(options ExecuteOptions) fantasy.AgentTool {
93 return fantasy.NewAgentTool(
94 ExecuteToolName,
95 "Execute a shell command in the workspace. Runs the command and waits for completion up to the timeout (default 10s, override with the timeout parameter e.g. '30s', '5m'). If the command exceeds the timeout, the response includes a background_process_id; use process_output with that ID to re-attach and wait for the result. Use run_in_background=true for persistent processes (dev servers, file watchers) or when you want to continue other work while the command runs. Never use shell '&' for backgrounding.",
96 func(ctx context.Context, args ExecuteArgs, _ fantasy.ToolCall) (fantasy.ToolResponse, error) {
97 if options.GetWorkspaceConn == nil {
98 return fantasy.NewTextErrorResponse("workspace connection resolver is not configured"), nil
99 }
100 conn, err := options.GetWorkspaceConn(ctx)
101 if err != nil {
102 return fantasy.NewTextErrorResponse(err.Error()), nil
103 }
104 return executeTool(ctx, conn, args, options.DefaultTimeout), nil
105 },
106 )
107}
108
109func executeTool(
110 ctx context.Context,

Callers 4

runChatMethod · 0.92
TestExecuteToolFunction · 0.92
newExecuteToolFunction · 0.92
runForegroundWithOutputFunction · 0.85

Calls 2

executeToolFunction · 0.85
ErrorMethod · 0.45

Tested by 3

TestExecuteToolFunction · 0.74
newExecuteToolFunction · 0.74
runForegroundWithOutputFunction · 0.68