executeworker

package
v0.0.0-...-1e7ba32 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 21 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 CompileBindings

func CompileBindings(
	profile guestapi.Profile,
	version guestapi.Version,
) (mvmhost.Bindings, error)

CompileBindings returns the same profile/version manifest used by runtime evaluation, with inert callbacks suitable for compile-only validation.

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
	Progress   workflowprogress.Sink
	Executable string
}

Client evaluates source in a separate worker process.

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 {
	Progress  *workflowprogress.Event `json:"progress,omitempty"`
	Stderr    string                  `json:"stderr,omitempty"`
	Source    string                  `json:"source,omitempty"`
	Method    string                  `json:"method,omitempty"`
	Profile   guestapi.Profile        `json:"profile,omitempty"`
	GuestAPI  guestapi.Version        `json:"guest_api_version,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
	Profile         guestapi.Profile
	GuestAPIVersion guestapi.Version
	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