payloadshrink

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 11 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

Index

Constants

View Source
const ToolName = "runkite_retrieve_payload"

ToolName is injected on tools/list and intercepted on tools/call so the runner's MCP client never forwards the retrieve to the connector.

Variables

View Source
var ErrNotFound = errors.New("payload not found")

ErrNotFound is a cache miss (expired TTL, wrong ref, or never stored).

Functions

func Apply

func Apply(ctx context.Context, store Store, s Settings, runID string, generation int64, respBody []byte) []byte

Apply rewrites a successful JSON-RPC tools/call body when it is over max_bytes and the stash fits the run+generation budget. On any store error it returns the original body. Downstream already succeeded, so this never fails the MCP call.

func InjectRetrieveTool

func InjectRetrieveTool(body []byte) []byte

InjectRetrieveTool appends (or replaces) the retrieve tool on a tools/list JSON-RPC result. Unparseable bodies pass through.

func IsDisabled

func IsDisabled(err error) bool

func IsMissingRef

func IsMissingRef(err error) bool

func Live

func Live(s Settings, store Store) bool

Live is true when shrink may rewrite a tools/call body.

func ParseRef

func ParseRef(args json.RawMessage) string

func Retrieve

func Retrieve(ctx context.Context, store Store, s Settings, runID string, generation int64, ref string) ([]byte, error)

Retrieve returns the stashed inner MCP result for this run+generation.

Types

type FailStore

type FailStore struct {
	Err error
}

FailStore returns Err on every method so a Redis blip cannot fail the already-successful downstream tools/call.

func (FailStore) DecrBy

func (f FailStore) DecrBy(context.Context, string, int64) (int64, error)

func (FailStore) Expire

func (FailStore) Get

func (f FailStore) Get(context.Context, string) ([]byte, error)

func (FailStore) IncrBy

func (f FailStore) IncrBy(context.Context, string, int64) (int64, error)

func (FailStore) Set

type MemoryStore

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

MemoryStore is an in-process stash for tests. TTL is ignored.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) DecrBy

func (m *MemoryStore) DecrBy(_ context.Context, key string, n int64) (int64, error)

func (*MemoryStore) Expire

func (*MemoryStore) Get

func (m *MemoryStore) Get(_ context.Context, key string) ([]byte, error)

func (*MemoryStore) IncrBy

func (m *MemoryStore) IncrBy(_ context.Context, key string, n int64) (int64, error)

func (*MemoryStore) Set

func (m *MemoryStore) Set(_ context.Context, key string, value []byte, _ time.Duration) error

type RedisAPI

type RedisAPI interface {
	Get(ctx context.Context, key string) *redis.StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	IncrBy(ctx context.Context, key string, value int64) *redis.IntCmd
	DecrBy(ctx context.Context, key string, decrement int64) *redis.IntCmd
	Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd
}

RedisAPI is the go-redis subset Store needs.

type Settings

type Settings struct {
	Enabled       bool
	MaxBytes      int
	PreviewBytes  int
	CacheTTL      time.Duration
	MaxStoreBytes int
}

Settings is the runtime shrink config after defaults and validation.

func (Settings) Validate

func (s Settings) Validate() error

Validate enforces the fail-loud bounds used at serve startup.

type Store

type Store interface {
	Get(ctx context.Context, key string) ([]byte, error)
	Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
	IncrBy(ctx context.Context, key string, n int64) (int64, error)
	DecrBy(ctx context.Context, key string, n int64) (int64, error)
	Expire(ctx context.Context, key string, ttl time.Duration) error
}

Store is the Redis (or test) backend for original MCP result bytes.

func NewRedisStore

func NewRedisStore(rdb RedisAPI) Store

Jump to

Keyboard shortcuts

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