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

Function AttachFile

coderd/x/chatd/chattool/attachfile.go:26–46  ·  view source on GitHub ↗

AttachFile returns a tool that stores a workspace file as a durable chat attachment so the user can download it directly from the conversation.

(options AttachFileOptions)

Source from the content-addressed store, hash-verified

24// AttachFile returns a tool that stores a workspace file as a durable chat
25// attachment so the user can download it directly from the conversation.
26func AttachFile(options AttachFileOptions) fantasy.AgentTool {
27 return fantasy.NewAgentTool(
28 "attach_file",
29 "Attach a workspace file to the current chat so the user can download it directly from the conversation. "+
30 "Use this when the user should receive an artifact such as a screenshot, log, patch, or document. "+
31 "Pass an absolute file path. The file must already exist in the workspace.",
32 func(ctx context.Context, args AttachFileArgs, _ fantasy.ToolCall) (fantasy.ToolResponse, error) {
33 if options.GetWorkspaceConn == nil {
34 return fantasy.NewTextErrorResponse("workspace connection resolver is not configured"), nil
35 }
36 if options.StoreFile == nil {
37 return fantasy.NewTextErrorResponse("file storage is not configured"), nil
38 }
39 conn, err := options.GetWorkspaceConn(ctx)
40 if err != nil {
41 return fantasy.NewTextErrorResponse(err.Error()), nil
42 }
43 return executeAttachFileTool(ctx, conn, args, options.StoreFile)
44 },
45 )
46}
47
48func executeAttachFileTool(
49 ctx context.Context,

Callers 2

runChatMethod · 0.92
newAttachFileToolFunction · 0.92

Calls 2

executeAttachFileToolFunction · 0.85
ErrorMethod · 0.45

Tested by 1

newAttachFileToolFunction · 0.74