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
- Variables
- func Allowed(contentType string) bool
- func DeclaredAssetType(p, declared string) string
- func PageAssetMirrorPath(id int64) string
- func Refused(name, contentType string) string
- func Send(ctx context.Context, client *http.Client, s Spec, root, p string) ([]byte, error)
- func Sniff(head []byte) string
- type PageAsset
- type Record
- type Spec
- type Target
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 )
const PageAssetTool = "page_asset_upload"
PageAssetTool is the page tool whose file muster-mirror's MCP proxy sends from this host (internal/mirrorhost) before it forwards the call, and internal/api's name for it.
Variables ¶
var ErrAssetTooLarge = fmt.Errorf("the file is over %d MiB, the most one page asset may be", pages.MaxAssetBytes>>20)
ErrAssetTooLarge is a file over pages.MaxAssetBytes.
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.
func DeclaredAssetType ¶ added in v0.256.0
DeclaredAssetType is the type a page asset at path p is sent as: declared when the caller named one, else its extension's (assetExtTypes), else "" (the bytes alone decide).
func PageAssetMirrorPath ¶ added in v0.256.0
PageAssetMirrorPath is muster's route a mirror host sends one of page id's assets to, with its mirror token and the calling session.
Types ¶
type PageAsset ¶ added in v0.256.0
type PageAsset struct {
ID string `json:"asset_id"`
Ref string `json:"ref"`
Name string `json:"name"`
Type string `json:"type"`
Size int64 `json:"size"`
}
PageAsset is muster's answer to one sent asset: its id, the reference a block uses, and what was stored.
func UploadPageAsset ¶ added in v0.256.0
func UploadPageAsset(ctx context.Context, client *http.Client, t Target, root, p, declared string) (PageAsset, error)
UploadPageAsset sends file p — resolved inside root — to t as one of a page's assets, declared as declared (DeclaredAssetType's rule), and returns muster's record of it. The bytes are checked HERE first, as muster checks them again: one of the six types, and the declared one when one is named (pages.CheckAssetType); at most pages.MaxAssetBytes, before and while it streams. client nil follows no redirect (the request carries a credential).
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.