Documentation
¶
Index ¶
Constants ¶
const CacheRootEnv = "AGENT_ADAPTOR_SKILL_CACHE_ROOT"
CacheRootEnv is the environment variable that overrides the default materializer's cache root. Adapters inspect the same variable (indirectly through internal/skillruntime.ManagedSkillCacheRoot) to identify the paths they are allowed to manage, so exposing it here keeps both sides of the contract in sync.
Variables ¶
var ErrArchiveFormat = errors.New("agentadaptor: archive format error")
Functions ¶
func ReadArchiveBytes ¶
ReadArchiveBytes reads from rc up to limit+1 bytes; if more is available it returns errArchiveTooLarge so the caller can refuse the archive without OOMing on a multi-gigabyte stream.
Types ¶
type Config ¶
type Config struct {
CacheRoot string
MaxArchiveBytes int64
MaxFileBytes int64
MaxArchiveEntries int
SourceMissing error
}
func DefaultConfig ¶
type Extraction ¶
Extraction is the result of safely walking an archive.
Files maps forward-slashed entry paths (relative to Subpath) to their uncompressed content. The map is suitable for direct hand-off to writeFiles.
func ExtractArchive ¶
ExtractArchive decompresses and extracts an archive byte slice into memory subject to the configured safety limits.
The implementation rejects:
- any entry whose cleaned path escapes the archive root (zip slip)
- any entry whose cleaned path escapes Subpath (after normalisation)
- any non-regular entry: symbolic links, hardlinks, devices, fifos are silently dropped (they don't make sense in a SKILL.md tree)
- any single uncompressed entry larger than cfg.MaxFileBytes
- more than cfg.MaxArchiveEntries entries (file + dir count)
Subpath is the prefix inside the archive where SKILL.md is expected to live. Empty means the archive root. Subpath is treated as a forward-slashed posix path; "./" / "../" / leading "/" are normalised away before matching.
type Format ¶
type Format string
func SniffArchiveFormat ¶
SniffArchiveFormat detects the supported archive formats by their canonical magic bytes. An unknown payload returns FormatAuto and is rejected by ExtractArchive.
type Materializer ¶
defaultSkillMaterializer implements Materializer using the SDK's XDG-like cache root described in docs/api-reference.md §11.1. The archive-handling subset is configurable through Option.
func New ¶
func New(sourceMissing error, opts ...Option) Materializer
New returns the shared private implementation. sourceMissing is injected explicitly so this package remains below the public skill vocabulary while every caller still returns skill's one canonical sentinel.
type Option ¶
type Option func(*Config)
Option configures the private materializer returned by New.
func WithMaxArchiveEntries ¶
WithMaxArchiveEntries caps the number of entries (files + dirs) in a single archive. Archives with more entries than the cap surface as an error before any file is written. Default 10000. Values <= 0 are treated as the default.
func WithMaxArchiveSize ¶
WithMaxArchiveSize caps the total compressed bytes the materializer will read from a SkillFromArchive stream. Streams that exceed the cap surface as an error before any extraction begins. Default 256 MiB. Values <= 0 are treated as the default.
func WithMaxFileSize ¶
WithMaxFileSize caps the uncompressed bytes a single archive entry is allowed to occupy. Decompression bombs that inflate one entry past the cap surface as an error mid-extraction; partially-extracted staging directories are cleaned up. Default 64 MiB. Values <= 0 are treated as the default.
func WithSkillCacheRoot ¶
WithSkillCacheRoot overrides the cache root the default materializer writes to. Empty input falls back to the AGENT_ADAPTOR_SKILL_CACHE_ROOT env var, then os.UserCacheDir(), then os.TempDir() — see managedSkillCacheRoot for the resolution order.