Documentation
¶
Overview ¶
Package remote provides a backend that executes code on a remote runtime service. Generic target for dedicated runtime services, batch systems, or job runners.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRemoteNotAvailable is returned when the remote service is not available. ErrRemoteNotAvailable = errors.New("remote service not available") // ErrConnectionFailed is returned when connection to remote service fails. ErrConnectionFailed = errors.New("connection to remote service failed") // ErrRemoteExecutionFailed is returned when remote execution fails. ErrRemoteExecutionFailed = errors.New("remote execution failed") // ErrClientNotConfigured is returned when no remote client is configured. ErrClientNotConfigured = errors.New("remote client not configured") )
Errors for remote backend operations.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend executes code on a remote runtime service.
func (*Backend) Execute ¶
func (b *Backend) Execute(ctx context.Context, req runtime.ExecuteRequest) (runtime.ExecuteResult, error)
Execute runs code on the remote runtime service.
func (*Backend) Kind ¶
func (b *Backend) Kind() runtime.BackendKind
Kind returns the backend kind identifier.
type Config ¶
type Config struct {
// Client executes remote requests.
// Required. Provide a RemoteClient from an integration package.
Client RemoteClient
// GatewayEndpoint is the URL of the tool gateway available to the remote runtime.
// Optional, but recommended when remote code needs tool access.
GatewayEndpoint string
// GatewayToken is an optional token to authorize gateway access.
GatewayToken string
// TimeoutOverhead is additional timeout added to account for network latency.
// Default: 5s
TimeoutOverhead time.Duration
// EnableStreaming enables SSE streaming when supported by the remote service.
EnableStreaming bool
// Logger is an optional logger for backend events.
Logger Logger
}
Config configures a remote backend.
type EndpointProvider ¶ added in v0.2.0
type EndpointProvider interface {
Endpoint() string
}
EndpointProvider optionally exposes the configured endpoint for diagnostics.
type ExecutePayload ¶ added in v0.2.0
type ExecutePayload struct {
Language string `json:"language,omitempty"`
Code string `json:"code"`
TimeoutMillis int64 `json:"timeout_ms,omitempty"`
Limits LimitsPayload `json:"limits,omitempty"`
Profile string `json:"profile,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
EnableTracing bool `json:"enable_tracing,omitempty"`
RequestedScope string `json:"requested_scope,omitempty"`
}
ExecutePayload defines the code execution request payload.
type ExecuteResultPayload ¶ added in v0.2.0
type ExecuteResultPayload struct {
Value any `json:"value,omitempty"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
ToolCalls []ToolCallPayload `json:"tool_calls,omitempty"`
DurationMillis int64 `json:"duration_ms,omitempty"`
LimitsEnforced runtime.LimitsEnforced `json:"limits_enforced,omitempty"`
}
ExecuteResultPayload is the remote execution result payload.
type GatewayDescriptor ¶ added in v0.2.0
type GatewayDescriptor struct {
URL string `json:"url"`
Token string `json:"token,omitempty"`
Protocol string `json:"protocol,omitempty"`
}
GatewayDescriptor describes the tool gateway accessible to the runtime.
type LimitsPayload ¶ added in v0.2.0
type LimitsPayload struct {
MaxToolCalls int `json:"max_tool_calls,omitempty"`
MaxChainSteps int `json:"max_chain_steps,omitempty"`
CPUQuotaMillis int64 `json:"cpu_quota_millis,omitempty"`
MemoryBytes int64 `json:"memory_bytes,omitempty"`
PidsMax int64 `json:"pids_max,omitempty"`
DiskBytes int64 `json:"disk_bytes,omitempty"`
}
LimitsPayload encodes execution limits for remote runtimes.
type Logger ¶
type Logger interface {
Info(msg string, args ...any)
Warn(msg string, args ...any)
Error(msg string, args ...any)
}
Logger is the interface for logging.
Contract: - Concurrency: implementations must be safe for concurrent use. - Errors: logging must be best-effort and must not panic.
type RemoteClient ¶ added in v0.2.0
type RemoteClient interface {
Execute(ctx context.Context, req RemoteRequest) (RemoteResponse, error)
}
RemoteClient executes remote requests.
Contract: - Concurrency: Implementations must be safe for concurrent use. - Context: Execute must honor cancellation and deadlines.
type RemoteError ¶ added in v0.2.0
RemoteError describes a remote runtime error.
type RemoteRequest ¶ added in v0.2.0
type RemoteRequest struct {
Request ExecutePayload `json:"request"`
Gateway *GatewayDescriptor `json:"gateway,omitempty"`
Stream bool `json:"stream,omitempty"`
}
RemoteRequest is the wire request to a remote runtime.
type RemoteResponse ¶ added in v0.2.0
type RemoteResponse struct {
Result *ExecuteResultPayload `json:"result,omitempty"`
Error *RemoteError `json:"error,omitempty"`
}
RemoteResponse is the wire response from a remote runtime.