askattach

package
v0.268.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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
)
View Source
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

View Source
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.

View Source
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

func Allowed(contentType string) bool

Allowed reports whether a file whose SNIFFED type is contentType may be attached to an ask.

func DeclaredAssetType added in v0.256.0

func DeclaredAssetType(p, declared string) string

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

func PageAssetMirrorPath(id int64) string

PageAssetMirrorPath is muster's route a mirror host sends one of page id's assets to, with its mirror token and the calling session.

func Refused

func Refused(name, contentType string) string

Refused is the sentence for a file whose sniffed type Allowed refuses.

func Send

func Send(ctx context.Context, client *http.Client, s Spec, root, p string) ([]byte, error)

Send sends file p — resolved inside root (workspacefile.Resolve) — as s says, with client as given (the caller decides the redirect rule), and returns muster's 2xx answer body; a non-2xx is muster's refusal, in its own words when it gave some.

func Sniff

func Sniff(head []byte) string

Sniff is the type of a file whose first bytes are head.

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

func Upload(ctx context.Context, client *http.Client, t Target, root, p string) (Record, error)

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.

type Target

type Target struct {
	Base   string
	Path   string
	Header http.Header
}

Target is where Upload sends a file: muster's base URL, the route (MirrorPath or AgentPath) and the headers that authenticate it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL