code

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package code provides CodeRunner implementations for LLM code execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPRunner added in v0.9.0

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

HTTPRunner executes code by POSTing to a remote sandbox service. It implements oasis.CodeRunner.

The sandbox communicates tool calls back via HTTP to a callback server managed by HTTPRunner. On first Run(), the callback server starts automatically unless WithCallbackExternal was configured.

func NewHTTPRunner added in v0.9.0

func NewHTTPRunner(sandboxURL string, opts ...Option) *HTTPRunner

NewHTTPRunner creates an HTTPRunner that POSTs code to the sandbox at sandboxURL (e.g. "http://sandbox:9000").

func (*HTTPRunner) Close added in v0.9.0

func (r *HTTPRunner) Close() error

Close shuts down the auto-started callback server. No-op when WithCallbackExternal is set.

func (*HTTPRunner) Handler added in v0.9.0

func (r *HTTPRunner) Handler() http.Handler

Handler returns the http.Handler for the /_oasis/dispatch endpoint. Mount this on your own mux when using WithCallbackExternal:

mux.Handle("/_oasis/dispatch", runner.Handler())

func (*HTTPRunner) Run added in v0.9.0

Run executes code via the sandbox HTTP service. Implements oasis.CodeRunner.

type Option

type Option func(*runnerConfig)

Option configures an HTTPRunner.

func WithCallbackAddr added in v0.9.0

func WithCallbackAddr(addr string) Option

WithCallbackAddr sets the address for the auto-started callback HTTP server. The callback server handles tool dispatch requests from the sandbox. Default: "127.0.0.1:0" (OS-assigned port).

func WithCallbackExternal added in v0.9.0

func WithCallbackExternal(publicAddr string) Option

WithCallbackExternal tells HTTPRunner that the callback handler is mounted on an external HTTP server at the given address. HTTPRunner will not start its own listener. Use runner.Handler() to get the http.Handler to mount.

publicAddr should be the base URL reachable from the sandbox, e.g. "http://app:8080". The dispatch path /_oasis/dispatch is appended automatically.

func WithMaxFileSize added in v0.9.0

func WithMaxFileSize(bytes int64) Option

WithMaxFileSize sets the maximum size in bytes for a single returned file. Files exceeding this limit are included without data (metadata only). Default: 10MB.

func WithMaxOutput

func WithMaxOutput(bytes int) Option

WithMaxOutput sets the maximum output size in bytes. Output beyond this limit is truncated. Default: 64KB.

func WithMaxRetries added in v0.9.0

func WithMaxRetries(n int) Option

WithMaxRetries sets the total number of attempts for the sandbox HTTP request. 1 means no retry; 2 means one retry on transient failure. Default: 2.

func WithRetryDelay added in v0.9.0

func WithRetryDelay(d time.Duration) Option

WithRetryDelay sets the initial backoff delay between retries. The delay doubles on each subsequent retry. Default: 500ms.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the maximum execution duration for code. Default: 30s.

Jump to

Keyboard shortcuts

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