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

Function executeAttachFileTool

coderd/x/chatd/chattool/attachfile.go:48–78  ·  view source on GitHub ↗
(
	ctx context.Context,
	conn workspacesdk.AgentConn,
	args AttachFileArgs,
	storeFile StoreFileFunc,
)

Source from the content-addressed store, hash-verified

46}
47
48func executeAttachFileTool(
49 ctx context.Context,
50 conn workspacesdk.AgentConn,
51 args AttachFileArgs,
52 storeFile StoreFileFunc,
53) (fantasy.ToolResponse, error) {
54 path := strings.TrimSpace(args.Path)
55 if path == "" {
56 return fantasy.NewTextErrorResponse("path is required (use an absolute path, e.g. /home/coder/build.log)"), nil
57 }
58
59 attachment, size, err := storeWorkspaceAttachment(
60 ctx,
61 conn,
62 path,
63 strings.TrimSpace(args.Name),
64 storeFile,
65 )
66 if err != nil {
67 return fantasy.NewTextErrorResponse(err.Error()), nil
68 }
69
70 return WithAttachments(toolResponse(map[string]any{
71 "ok": true,
72 "path": path,
73 "file_id": attachment.FileID.String(),
74 "name": attachment.Name,
75 "media_type": attachment.MediaType,
76 "size": size,
77 }), attachment), nil
78}

Callers 1

AttachFileFunction · 0.85

Calls 5

storeWorkspaceAttachmentFunction · 0.85
WithAttachmentsFunction · 0.85
toolResponseFunction · 0.85
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected