Documentation
¶
Overview ¶
Package attachments stores prompt attachments in a cwd-local sandbox and builds ACP resource blocks that point at the stored files.
Defensive helpers for attachment storage paths the production caller cannot realistically trigger. Excluded from coverage via the `_must.go` suffix rule in .covignore.
Index ¶
- Constants
- func FileResourceLinkBlock(name, absPath, contentType string) acp.ContentBlock
- func ResourceLinkBlock(name, uri, contentType string) acp.ContentBlock
- func TextResourceBlock(uri, text, mimeType string) acp.ContentBlock
- func URLResourceLinkBlock(a Attachment) acp.ContentBlock
- type Attachment
- type File
- type Store
Constants ¶
const ( // DefaultDirName is the attachment directory created inside a session cwd. DefaultDirName = ".acp-attachments" // DefaultMaxBytes caps a single downloaded or written attachment. DefaultMaxBytes int64 = 25 << 20 // 25 MiB )
Variables ¶
This section is empty.
Functions ¶
func FileResourceLinkBlock ¶
func FileResourceLinkBlock(name, absPath, contentType string) acp.ContentBlock
FileResourceLinkBlock builds a ResourceLink for absPath using a properly escaped file:// URI.
func ResourceLinkBlock ¶
func ResourceLinkBlock(name, uri, contentType string) acp.ContentBlock
ResourceLinkBlock builds an ACP ResourceLink block and sets MimeType when known.
func TextResourceBlock ¶
func TextResourceBlock(uri, text, mimeType string) acp.ContentBlock
TextResourceBlock builds an embedded text Resource block for agents that advertise embedded context support.
func URLResourceLinkBlock ¶
func URLResourceLinkBlock(a Attachment) acp.ContentBlock
URLResourceLinkBlock builds a ResourceLink for an original remote attachment URL.
Types ¶
type Attachment ¶
Attachment is the transport-neutral attachment metadata the store needs.
type File ¶
File describes one attachment stored on disk.
func (File) ResourceLinkBlock ¶
func (f File) ResourceLinkBlock() acp.ContentBlock
ResourceLinkBlock returns a file:// ResourceLink block for f.
type Store ¶
type Store struct {
// DirName is created inside the ACP session cwd. Empty => DefaultDirName.
DirName string
// MaxBytes caps one attachment. <=0 => DefaultMaxBytes.
MaxBytes int64
// Client is used by Download. nil => http.DefaultClient.
Client *http.Client
}
Store owns the on-disk layout and byte limits for attachments.
func (Store) Download ¶
func (s Store) Download(ctx context.Context, cwd, msgID string, used map[string]struct{}, a Attachment) (File, error)
Download fetches a.URL and writes it under <cwd>/<DirName>/<msgID>/<name>. Names are opened through os.Root, so hostile names cannot escape the message directory. used tracks per-prompt filename collisions; nil is accepted.