Documentation
¶
Index ¶
- Constants
- func AgentDisplayPath(ws cw.Service, path string) string
- func AgentLLMPath(ctx context.Context, ws cw.Service, path string) string
- func CanonicalStoredPath(ws cw.Service, rel string) string
- func CanonicalWorkPath(ws cw.Service, rel string) string
- func DataURL(mime string, data []byte) string
- func DetectMIME(path string, data []byte) string
- func EnsureInboundFileName(name, mime string, data []byte) string
- func ExtensionForMIME(mime string) string
- func FitForVision(data []byte, mime string, opt VisionFitOptions) ([]byte, string, error)
- func FormatReadImageResult(path, mime string, size int64) string
- func FormatReadImageTooLarge(path string, size, max int64) string
- func IsImage(mimeType, path string) bool
- func IsImageMIME(mime string) bool
- func IsImagePath(path string) bool
- func LoadWorkspaceImage(ctx context.Context, ws workspace.Service, workRel string, maxPayloadBytes int) ([]byte, string, error)
- func LooksLikeImageData(data []byte) bool
- func NormalizeWorkRel(ws cw.Service, rel string) string
- func ParseReadImagePath(content string) string
- func ReadFileHead(path string, n int) ([]byte, error)
- func RewritePathsInText(ctx context.Context, ws cw.Service, text string) string
- func WorkspaceFileMayBeImage(ctx context.Context, ws workspace.Service, workRel string) (bool, error)
- type VisionFitOptions
Constants ¶
const ContentTypeAttachmentRef = "attachment_ref"
ContentTypeAttachmentRef is persisted in session history for stripped attachments.
const DefaultMaxVisionEdgePixels = 2048
DefaultMaxVisionEdgePixels limits the longest image edge when FitForVision is enabled.
const DefaultMaxVisionPayloadBytes = 1 << 20
DefaultMaxVisionPayloadBytes is used when FitForVision is enabled (optional).
const DefaultMaxWorkspaceImageBytes = 10 << 20
DefaultMaxWorkspaceImageBytes caps raw image bytes sent to vision models.
const DefaultMaxWorkspaceImageReadBytes = 10 << 20
DefaultMaxWorkspaceImageReadBytes is the largest workspace image file tools and hydrate may load.
Variables ¶
This section is empty.
Functions ¶
func AgentDisplayPath ¶ added in v0.3.23
AgentDisplayPath is AgentLLMPath without request context; prefer AgentLLMPath when ctx carries tenant workspace.
func AgentLLMPath ¶ added in v0.3.23
AgentLLMPath formats a path for model-facing text and session storage. local:/global: appear only in configuration. Paths under the agent work directory are relative to that directory (e.g. upload/foo, same as shell cwd and fs root); global and out-of-work files use absolute paths.
func CanonicalStoredPath ¶ added in v0.3.23
CanonicalStoredPath normalizes attachment paths for session JSONL (no local:/global: prefixes).
func CanonicalWorkPath ¶ added in v0.3.23
CanonicalWorkPath returns the agent-facing path under the configured work layout.
func DetectMIME ¶
DetectMIME guesses image MIME type from path and magic bytes.
func EnsureInboundFileName ¶ added in v0.3.22
EnsureInboundFileName adds a standard image extension when MIME or content indicates an image.
func ExtensionForMIME ¶ added in v0.3.22
ExtensionForMIME maps an image MIME type to a file extension including the dot.
func FitForVision ¶ added in v0.3.22
FitForVision downscales and re-encodes images that exceed vision limits. When the input is already within limits, it is returned unchanged. If decoding or re-encoding fails, the original bytes are returned unchanged.
func FormatReadImageResult ¶
FormatReadImageResult is the read-tool metadata format hydrated before LLM calls.
func FormatReadImageTooLarge ¶
FormatReadImageTooLarge explains why a workspace image cannot be viewed.
func IsImageMIME ¶
IsImageMIME reports whether a MIME type is an image.
func IsImagePath ¶
IsImagePath reports whether a workspace-relative path looks like an image file.
func LoadWorkspaceImage ¶
func LoadWorkspaceImage(ctx context.Context, ws workspace.Service, workRel string, maxPayloadBytes int) ([]byte, string, error)
LoadWorkspaceImage reads a workspace image and tries FitForVision before LLM vision input. When fitting fails, the original file bytes are returned (up to DefaultMaxWorkspaceImageReadBytes). workRel is relative to work/ (e.g. upload/foo.png or work/upload/foo.png). maxPayloadBytes caps the returned payload after fitting; 0 uses DefaultMaxVisionPayloadBytes. Files larger than DefaultMaxWorkspaceImageReadBytes are skipped (empty result).
func LooksLikeImageData ¶ added in v0.3.22
LooksLikeImageData reports whether bytes begin with a known image signature.
func NormalizeWorkRel ¶
NormalizeWorkRel strips the configured work-dir prefix from a tenant-local relative path.
func ParseReadImagePath ¶
ParseReadImagePath extracts a workspace image path from a read-tool result.
func ReadFileHead ¶ added in v0.3.22
ReadFileHead reads up to n bytes from a file for content sniffing.
func RewritePathsInText ¶ added in v0.3.23
RewritePathsInText replaces scoped workspace path tokens in free text for LLM history.
Types ¶
type VisionFitOptions ¶ added in v0.3.22
VisionFitOptions controls downscaling and re-encoding for LLM vision input.
func DefaultVisionFitOptions ¶ added in v0.3.22
func DefaultVisionFitOptions() VisionFitOptions
DefaultVisionFitOptions returns the standard vision payload limits.