executeworker

package
v0.0.0-...-820128f Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package executeworker implements the bounded framed protocol used to isolate provider-facing MVM execution in a helper process.

Index

Constants

View Source
const (
	// MaxFrameSize is the largest encoded protocol message accepted by a worker.
	MaxFrameSize = executionlimits.MaxFrameSize
	// MaxResultSize is the largest encoded evaluation value accepted across the protocol.
	MaxResultSize = executionlimits.MaxResultSize
)

Variables

This section is empty.

Functions

func Serve

func Serve(input io.Reader, output io.Writer) error

Serve runs one evaluation. Tool bindings are synchronous callback RPCs to the parent; only JSON values cross the process boundary.

func Write

func Write(writer io.Writer, message *Message) error

Write encodes one length-prefixed message to w.

Types

type Client

type Client struct {
	Handler    RPCHandler
	Executable string
}

Client evaluates source in a separate worker process.

func (Client) Eval

func (client Client) Eval(ctx context.Context, source string) (mvmhost.Result, error)

Eval evaluates provider-facing source, forwarding callback requests to Handler.

func (Client) EvalRequest

func (client Client) EvalRequest(ctx context.Context, eval *Request) (mvmhost.Result, error)

EvalRequest evaluates source in the requested worker mode.

type Message

type Message struct {
	Stderr    string          `json:"stderr,omitempty"`
	Source    string          `json:"source,omitempty"`
	Method    string          `json:"method,omitempty"`
	Mode      string          `json:"mode,omitempty"`
	Name      string          `json:"name,omitempty"`
	Query     string          `json:"query,omitempty"`
	Stdout    string          `json:"stdout,omitempty"`
	Type      string          `json:"type"`
	Error     string          `json:"error,omitempty"`
	ErrorKind string          `json:"error_kind,omitempty"`
	ValueKind string          `json:"value_kind,omitempty"`
	Input     json.RawMessage `json:"input,omitempty"`
	Value     json.RawMessage `json:"value,omitempty"`
	Arguments json.RawMessage `json:"arguments,omitempty"`
	ID        uint64          `json:"id,omitempty"`
	ExitCode  int             `json:"exit_code,omitempty"`
}

Message is a framed request or response exchanged with an execute worker.

func Read

func Read(reader io.Reader) (Message, error)

Read decodes one length-prefixed message from r.

type RPCHandler

type RPCHandler func(context.Context, *Message) (any, error)

RPCHandler handles a callback request received from an execute worker.

type Request

type Request struct {
	Arguments any
	Mode      string
	Name      string
	Source    string
}

Request describes one isolated MVM evaluation.

type ToolCallResult

type ToolCallResult struct {
	Details map[string]any      `json:"details"`
	Error   string              `json:"error,omitempty"`
	Content []tool.ContentBlock `json:"content"`
	IsError bool                `json:"is_error"`
}

ToolCallResult is the typed result of a tools.Call callback. Keeping this envelope typed on both sides of the worker boundary preserves content blocks and details instead of decoding them through map[string]any.

Jump to

Keyboard shortcuts

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