Documentation
¶
Overview ¶
Package askattach is how a file an agent names reaches an attention ask (docs/attention.md "Attachments and context"): the bounds every hop shares, the types an ask may carry, and the client that sends one workspace file to muster's upload store from where the file is.
muster-server cannot read an agent's filesystem, so the file is sent from the agent's side, and the ask carries the upload's id:
- a MIRRORED Claude Code session: its host's muster-mirror (the local MCP endpoint, internal/mirrorhost) takes attention_ask's `attachments` paths, resolves each against the calling session's working directory, sends it to POST MirrorPath with the host's mirror token, and forwards the call with `attachment_ids` in their place;
- a DISPATCHED agent's pod: `ccd ask-attach <path>` sends it to POST AgentPath with the agent's own token and prints the id, which the agent passes as `attachment_ids`.
🔴 THE PATH IS CONFINED ON THE AGENT'S SIDE (internal/workspacefile), BECAUSE ONLY THAT SIDE SEES THE FILESYSTEM. The bytes are the other half: muster sniffs and caps them again on arrival, whatever sent them (Allowed, MaxBytes).
Index ¶
Constants ¶
const ( // MaxCount is how many files one ask may carry (attention.MaxAttachments // is this; migration 0145's CHECK holds it). MaxCount = 4 // MaxBytes caps one attached file. muster's upload store may allow more // (MUSTER_UPLOAD_MAX_BYTES); an ask's file is held to the smaller. MaxBytes int64 = 10 << 20 // MirrorPath is muster's route a mirror host sends an ask's file to, with // its mirror token and the calling session (X-Muster-Claude-Session). MirrorPath = "/mirror/ask-attachments" // AgentPath is muster's route a dispatched agent's pod sends one to, with // the agent's own token (X-Muster-Token). AgentPath = "/agent/ask-attachments" // SniffLen is how much of a file its type is read from // (http.DetectContentType's window). SniffLen = 512 )
Variables ¶
var ErrTooLarge = fmt.Errorf("the file is over %d MiB, the most an ask may carry", MaxBytes>>20)
ErrTooLarge is a file over MaxBytes.
Functions ¶
func Allowed ¶
Allowed reports whether a file whose SNIFFED type is contentType may be attached to an ask.
Types ¶
type Record ¶
type Record struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Size int64 `json:"size"`
}
Record is muster's answer to one sent file: the upload's id, as an ask's attachment_ids takes it, and what it stored.
func Upload ¶
Upload sends file p — resolved inside root (workspacefile.Resolve) — to t, and returns muster's record of it. The type is sniffed from the file's leading bytes and must be Allowed; the size is capped at MaxBytes before the upload (Stat) and while it streams. client nil is a client that follows no redirect (the request carries a credential).
type Spec ¶
type Spec struct {
Target
// MaxBytes caps the file, before the upload (Stat) and while it streams;
// TooLarge is the error for file p over it.
MaxBytes int64
TooLarge func(p string) error
// Type checks file p (its size, its first SniffLen bytes) and answers the
// Content-Type to send, or the refusal.
Type func(p string, size int64, head []byte) (string, error)
// Noun names the file in muster's refusal: "muster refused <Noun> (413): …".
Noun string
}
Spec is one kind of workspace upload.