fetchsvc

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package fetchsvc provides a runtime skill fetch service for agents running in sandboxes. It validates, fetches, caches, and uploads skill directories on behalf of in-sandbox agent processes.

Index

Constants

View Source
const DefaultMaxFetches = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type FetchRequest

type FetchRequest struct {
	URL string `json:"url"` // full URL including #sha256=<tree-hash>
}

FetchRequest is a runtime skill fetch request from an in-sandbox agent.

type FetchResponse

type FetchResponse struct {
	LocalPath string `json:"local_path,omitempty"` // sandbox-local skill directory path
	Error     string `json:"error,omitempty"`
}

FetchResponse is returned after a fetch attempt.

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

RateLimiter enforces a maximum number of runtime fetches per agent run. It uses an atomic counter for thread safety without requiring a mutex.

func NewRateLimiter

func NewRateLimiter(max int) *RateLimiter

NewRateLimiter creates a rate limiter with the given maximum. If max <= 0, DefaultMaxFetches is used.

func (*RateLimiter) Allow

func (r *RateLimiter) Allow() bool

Allow checks if another fetch is permitted. Returns true and increments the counter atomically if under the limit. Thread-safe for concurrent use.

func (*RateLimiter) Count

func (r *RateLimiter) Count() int32

Count returns the current number of fetches performed.

func (*RateLimiter) Release

func (r *RateLimiter) Release()

Release returns a previously consumed slot to the pool. It is safe to call even if no slot was consumed; the counter will not go below zero.

type SandboxUploader

type SandboxUploader struct{}

SandboxUploader implements the Uploader interface by delegating to sandbox.UploadDir for tarball-based directory transfer into the sandbox.

func (*SandboxUploader) UploadSkillDir

func (u *SandboxUploader) UploadSkillDir(sandboxName, localPath, remotePath string) error

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles runtime skill fetch requests from agents running in sandboxes.

func New

func New(cfg ServiceConfig) *Service

New creates a runtime fetch service.

func (*Service) HandleFetch

func (s *Service) HandleFetch(ctx context.Context, req FetchRequest) (FetchResponse, error)

HandleFetch processes a single runtime skill fetch request. On success it returns a FetchResponse with LocalPath set and a nil error. On failure it returns a *fetchError with an appropriate HTTP status code.

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for HTTP-based transports.

type ServiceConfig

type ServiceConfig struct {
	Harness       *harness.Harness
	TreeFetcher   gitfetch.TreeFetchFunc
	GitToken      string
	FetchPolicy   fetch.FetchPolicy
	WorkspaceRoot string // host-side root for .fullsend-cache/
	AuditLogPath  string
	TraceID       string
	SandboxName   string
	MaxFetches    int      // 0 → DefaultMaxFetches (10)
	Uploader      Uploader // nil → skip upload step
	SkillDestDir  string   // "" → /sandbox/claude-config/skills
}

ServiceConfig holds configuration for creating a new Service.

type Uploader

type Uploader interface {
	UploadSkillDir(sandboxName, localPath, remotePath string) error
}

Uploader abstracts uploading skill directories into the sandbox.

Jump to

Keyboard shortcuts

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