runtime

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 32 Imported by: 1 module, 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

Overview

Package runtime owns the shared MCP protocol, tools and task lifetimes. Application configuration, credential stores and UI belong to host adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMCPError

func FormatMCPError(err error) error

Types

type ClientIdentity

type ClientIdentity struct{ ClientID, TokenID string }

ClientIdentity is the verified client and credential attached to an HTTP tool invocation. IDs contain no bearer secret and survive detached SDK calls.

func ClientIdentityFromContext

func ClientIdentityFromContext(ctx context.Context) (ClientIdentity, bool)

type CreateTunnelInput

type CreateTunnelInput struct {
	RequestID  string `` /* 157-byte string literal not displayed */
	NodeID     string `json:"nodeID" jsonschema:"Managed SSH node ID or alias, including canonical openssh:host IDs returned by tunnel tools."`
	Mode       string `` /* 202-byte string literal not displayed */
	ListenHost string `` /* 140-byte string literal not displayed */
	ListenPort int    `json:"listenPort" jsonschema:"Listening TCP port, 0 to 65535. Zero requests an automatically allocated port."`
	TargetHost string `` /* 130-byte string literal not displayed */
	TargetPort int    `json:"targetPort" jsonschema:"Destination TCP port, 1 to 65535."`
	TTLSeconds int    `` /* 133-byte string literal not displayed */
}

type FSBaseOutput

type FSBaseOutput struct {
	Status string `json:"status" jsonschema:"Operation status"`
}

type FSCpInput

type FSCpInput struct {
	NodeID string `json:"nodeID" jsonschema:"Node ID for the remote machine"`
	Src    string `json:"srcPath" jsonschema:"Absolute path to source"`
	Dest   string `json:"destPath" jsonschema:"Absolute path to destination"`
}

type FSListInput

type FSListInput struct {
	NodeID string `json:"nodeID" jsonschema:"Node ID for the remote machine"`
	Path   string `json:"path" jsonschema:"Absolute path to the remote directory"`
}

type FSListOutput

type FSListOutput struct {
	Files  []FileInfo `json:"files" jsonschema:"List of files in the directory"`
	Status string     `json:"status" jsonschema:"Operation status"`
}

type FSMkdirInput

type FSMkdirInput struct {
	NodeID string `json:"nodeID" jsonschema:"Node ID for the remote machine"`
	Path   string `json:"path" jsonschema:"Absolute path to the directory to create"`
}

type FSMvInput

type FSMvInput struct {
	NodeID string `json:"nodeID" jsonschema:"Node ID for the remote machine"`
	Old    string `json:"oldPath" jsonschema:"Original absolute path"`
	New    string `json:"newPath" jsonschema:"New absolute destination path"`
}

type FSRmInput

type FSRmInput struct {
	NodeID string `json:"nodeID" jsonschema:"Node ID for the remote machine"`
	Path   string `json:"path" jsonschema:"Absolute path to the file/directory to securely delete"`
}

type FSTouchInput

type FSTouchInput struct {
	NodeID string `json:"nodeID" jsonschema:"Node ID for the remote machine"`
	Path   string `json:"path" jsonschema:"Absolute path to the file to create"`
}

type FileInfo

type FileInfo struct {
	Name    string    `json:"name" jsonschema:"File name"`
	Size    int64     `json:"size" jsonschema:"Size in bytes"`
	Mode    string    `json:"mode" jsonschema:"File mode/permissions"`
	ModTime time.Time `json:"modTime" jsonschema:"Last modification time"`
	IsDir   bool      `json:"isDir" jsonschema:"True if it is a directory"`
}

type HTTPOptions

type HTTPOptions struct {
	Listen    string
	PublicURL string
	Token     string
	// TokenVerifier supplies deployment-owned authentication. It is mutually
	// exclusive with Token and must return a stable, nonempty UserID. The
	// optional Extra["tokenID"] identifies the credential, not the client.
	TokenVerifier   auth.TokenVerifier
	StateDir        string
	AllowedHosts    []string
	AllowedOrigins  []string
	HeaderTimeout   time.Duration
	BodyTimeout     time.Duration
	StreamIdle      time.Duration
	ToolTimeout     time.Duration
	SessionTimeout  time.Duration
	ShutdownTimeout time.Duration
	MaxSessions     int
	MaxRequests     int // Per-lane capacity, including independent dynamic authentication.
	Transfers       transfer.Limits
	// contains filtered or unexported fields
}

HTTPOptions configures authenticated Streamable HTTP. Token is consumed at construction; the runtime retains only its digest, never a printable token.

func DefaultHTTPOptions

func DefaultHTTPOptions() HTTPOptions

func (*HTTPOptions) ValidateLimits

func (o *HTTPOptions) ValidateLimits() error

ValidateLimits lets host configuration adapters validate typed limits before loading authentication material or starting a runtime.

type ListNodesInput

type ListNodesInput struct {
	Tag string `json:"tag,omitempty" jsonschema:"Filter nodes by tag. If empty, lists all nodes."`
}

type ListNodesOutput

type ListNodesOutput struct {
	Nodes  []NodeInfo `json:"nodes" jsonschema:"List of available nodes with detailed information"`
	Status string     `json:"status" jsonschema:"Operation status"`
}

type ListTunnelsInput

type ListTunnelsInput struct {
	NodeID string `json:"nodeID,omitempty" jsonschema:"Optional node ID or alias filter; accepts returned canonical openssh:host IDs."`
	State  string `json:"state,omitempty" jsonschema:"Optional state: starting, running, stopping, stopped, expired, or failed."`
}

type ListTunnelsOutput

type ListTunnelsOutput struct {
	Tunnels []tunnel.Status `json:"tunnels"`
}

type NodeInfo

type NodeInfo = ports.NodeInfo

type Option

type Option func(*serverConfig)

func WithDependencies

func WithDependencies(dependencies ports.Dependencies) Option

func WithHTTP

func WithHTTP(options HTTPOptions) Option

WithHTTP switches the runtime to HTTP tools and session-based Streamable HTTP. Start it with Runtime.ServeHTTP rather than the stdio Run entry point.

func WithLogger

func WithLogger(log logger.DebugLogger) Option

func WithToolTimeout

func WithToolTimeout(timeout time.Duration) Option

WithToolTimeout sets a positive tool deadline for stdio and HTTP. It overrides HTTPOptions.ToolTimeout regardless of option order, including HTTP request and SDK middleware deadlines. Session and file-transfer limits are independent.

func WithTunnelRunner

func WithTunnelRunner(run tunnel.Runner) Option

WithTunnelRunner supplies a host-owned dedicated runner for compatibility adapters. HTTP never enables tunnel tools regardless of this option.

type PrepareDownloadInput

type PrepareDownloadInput struct {
	RequestID  string `json:"requestID" jsonschema:"Client-generated idempotency key"`
	NodeID     string `json:"nodeID" jsonschema:"Managed SSH node ID"`
	RemotePath string `json:"remotePath" jsonschema:"Absolute source file path on the SSH target"`
}

type PrepareUploadInput

type PrepareUploadInput struct {
	RequestID  string `json:"requestID" jsonschema:"Client-generated idempotency key; keep the same key when retrying preparation"`
	NodeID     string `json:"nodeID" jsonschema:"Managed SSH node ID"`
	RemotePath string `json:"remotePath" jsonschema:"Absolute destination file path on the SSH target"`
	Size       int64  `json:"size" jsonschema:"Exact client file size in bytes"`
	SHA256     string `json:"sha256" jsonschema:"Lowercase SHA-256 of the client file"`
	Overwrite  bool   `json:"overwrite,omitempty" jsonschema:"Explicitly replace an existing ordinary file atomically; new file mode is 0600"`
}

type PreparedTransferOutput

type PreparedTransferOutput struct {
	Task      transfer.Status   `json:"task"`
	URL       string            `json:"url,omitempty"`
	Method    string            `json:"method,omitempty"`
	Headers   map[string]string `json:"headers,omitempty"`
	StatusURL string            `json:"statusURL"`
	CancelURL string            `json:"cancelURL"`
}

type ReadFileInput

type ReadFileInput struct {
	NodeID string `json:"nodeID" jsonschema:"Node ID for the remote machine"`
	Path   string `json:"path" jsonschema:"Absolute path to the remote file"`
	Offset int64  `json:"offset,omitempty" jsonschema:"Byte offset to start reading from"`
	Limit  int64  `json:"limit,omitempty" jsonschema:"Max bytes to read (default 50KB, max 100KB)"`
}

type ReadFileOutput

type ReadFileOutput struct {
	Content string `json:"content" jsonschema:"File content represented as string"`
	EOF     bool   `json:"eof" jsonschema:"True if end of file reached"`
	Size    int64  `json:"size" jsonschema:"Total size of the remote file"`
	Status  string `json:"status" jsonschema:"Operation status"`
}

type RecoveryEntry

type RecoveryEntry struct {
	Task              transfer.Status `json:"task"`
	TemporaryPath     string          `json:"temporaryPath,omitempty"`
	Verified          bool            `json:"verified"`
	DestinationExists bool            `json:"destinationExists"`
	ActualSize        int64           `json:"actualSize,omitempty"`
	ActualSHA256      string          `json:"actualSHA256,omitempty"`
	MatchesExpected   bool            `json:"matchesExpected"`
	Resolution        string          `json:"resolution,omitempty"`
}

func RecoverTransfers

func RecoverTransfers(ctx context.Context, options RecoveryOptions, opts ...Option) (_ []RecoveryEntry, retErr error)

RecoverTransfers is offline maintenance: the permanent journal lock prevents racing a running service. Listing never mutates task records or contacts SSH. Remote verification/cleanup and operator acknowledgement are explicit options.

type RecoveryOptions

type RecoveryOptions struct {
	StateDir       string
	TransferID     string
	Verify         bool
	Cleanup        bool
	ResolveUnknown bool
	Reason         string
	MaxRecords     int
	MaxFileBytes   int64
}

type Runtime

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

func NewRuntime

func NewRuntime(ctx context.Context, opts ...Option) (_ *Runtime, retErr error)

func (*Runtime) Close

func (r *Runtime) Close() error

func (*Runtime) HTTPHandler

func (r *Runtime) HTTPHandler() (http.Handler, error)

HTTPHandler returns the authenticated handler owned by this runtime. Every HTTP server using it must bind its lifecycle to this runtime and call Close.

func (*Runtime) Run

func (r *Runtime) Run(transport mcp.Transport) error

Run serves a transport until it ends or the runtime is closed. It does not relinquish the caller's responsibility to close the runtime.

func (*Runtime) ServeHTTP

func (r *Runtime) ServeHTTP(listener net.Listener) (retErr error)

ServeHTTP takes ownership of listener. It stops accepting requests on runtime cancellation and force-closes connections if graceful shutdown times out.

func (*Runtime) Shutdown

func (r *Runtime) Shutdown(ctx context.Context) error

type SshRunInput

type SshRunInput struct {
	NodeID    string               `json:"nodeID" jsonschema:"The ID of the node to execute command on"`
	Command   string               `json:"command" jsonschema:"The shell command to execute"`
	Sudo      bool                 `json:"sudo,omitempty" jsonschema:"Whether to use sudo to execute the command"`
	Execution *ssh.ExecutionConfig `` /* 240-byte string literal not displayed */
}

type SshRunOutput

type SshRunOutput struct {
	Output     string  `json:"output" jsonschema:"Command stdout/stderr"`
	Status     string  `json:"status" jsonschema:"Operation status"`
	Error      string  `json:"error,omitempty" jsonschema:"Error message if failed"`
	Outcome    string  `json:"outcome,omitempty" jsonschema:"Execution outcome: not_started, completed, or unknown"`
	ExitCode   *uint32 `json:"exitCode,omitempty" jsonschema:"Exit status code if received"`
	Signal     string  `json:"signal,omitempty" jsonschema:"Termination signal if terminated by signal"`
	PlanDigest string  `json:"planDigest,omitempty" jsonschema:"Digest of the executed command plan"`
	Truncated  bool    `json:"truncated,omitempty" jsonschema:"Whether output exceeded limit and was truncated"`
}

type TransferFileInput

type TransferFileInput struct {
	NodeID     string `json:"nodeID" jsonschema:"Node ID for the remote machine"`
	LocalPath  string `json:"localPath" jsonschema:"Absolute path to the local file or directory"`
	RemotePath string `json:"remotePath" jsonschema:"Absolute path to the remote file or directory"`
}

type TransferFileOutput

type TransferFileOutput struct {
	Status string `json:"status" jsonschema:"Operation status"`
}

type TransferTaskInput

type TransferTaskInput struct {
	TransferID string `json:"transferID" jsonschema:"Transfer task ID returned by a prepare tool"`
}

type TunnelInput

type TunnelInput struct {
	TunnelID string `json:"tunnelID" jsonschema:"Tunnel ID returned by xops_tunnel_create or xops_tunnel_list."`
}

type TunnelOutput

type TunnelOutput struct {
	Tunnel tunnel.Status `json:"tunnel"`
}

type WriteFileInput

type WriteFileInput struct {
	NodeID  string `json:"nodeID" jsonschema:"Node ID for the remote machine"`
	Path    string `json:"path" jsonschema:"Absolute path to the remote file"`
	Content string `json:"content" jsonschema:"Content to write"`
	Append  bool   `json:"append,omitempty" jsonschema:"If true, append to existing file; if false, overwrite completely"`
}

type WriteFileOutput

type WriteFileOutput struct {
	BytesWritten int    `json:"bytesWritten" jsonschema:"Number of bytes written"`
	Status       string `json:"status" jsonschema:"Operation status"`
}

Jump to

Keyboard shortcuts

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