From 6dd2155f87bf79592c50f64cfb998a3db81ddeb2 Mon Sep 17 00:00:00 2001 From: Jim Tang Date: Wed, 8 Apr 2026 15:26:25 +0100 Subject: [PATCH] feat(slack): implement FileSender for direct file uploads (#475) Adds SendFile to the Slack platform, mirroring SendImage. Both use Slack's UploadFileV2Context, which already handles arbitrary file types. The engine routes attachments from `cc-connect send --file` (invoked by agents via the system-prompt-documented CLI) to this method via the core.FileSender interface assertion. https://claude.ai/code/session_01WyqXEst7Z8tiMbzeh4rTfX Co-authored-by: Claude --- platform/slack/slack.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/platform/slack/slack.go b/platform/slack/slack.go index 9490b4a..2679604 100644 --- a/platform/slack/slack.go +++ b/platform/slack/slack.go @@ -414,6 +414,34 @@ func (p *Platform) SendImage(ctx context.Context, rctx any, img core.ImageAttach var _ core.ImageSender = (*Platform)(nil) +// SendFile uploads and sends a generic file to the channel. +// Implements core.FileSender. +func (p *Platform) SendFile(ctx context.Context, rctx any, file core.FileAttachment) error { + rc, ok := rctx.(replyContext) + if !ok { + return fmt.Errorf("slack: SendFile: invalid reply context type %T", rctx) + } + + name := file.FileName + if name == "" { + name = "attachment" + } + + _, err := p.client.UploadFileV2Context(ctx, slack.UploadFileV2Parameters{ + Reader: bytes.NewReader(file.Data), + FileSize: len(file.Data), + Filename: name, + Channel: rc.channel, + ThreadTimestamp: rc.timestamp, + }) + if err != nil { + return fmt.Errorf("slack: send file: %w", err) + } + return nil +} + +var _ core.FileSender = (*Platform)(nil) + func (p *Platform) downloadSlackFile(url string) ([]byte, error) { if url == "" { return nil, fmt.Errorf("empty URL")