localruntime

package
v0.8.1-alpha.9 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Overview

Package localruntime implements app-runtime v3 adapters for local execution. Providers, identities and persistence are explicit dependencies.

Index

Constants

View Source
const ManagedPostgresImage = "pgvector/pgvector@sha256:ac08538c6f8b9904c33c8224c5e5706dbe760aca29db1d096972b4052c22a75d"

ManagedPostgresImage pins the PostgreSQL 17 pgvector amd64/arm64 manifest.

Variables

This section is empty.

Functions

func Executor

func Executor(config ExecutorConfig) (chatruntime.ExecutorFactory, error)

Executor returns a lazy factory. It does not connect to Docker or open a transport until an approved run_js call needs an executor. Build local images explicitly with jsexec.BuildImage before running tests that execute scripts.

func ModelHandler

func ModelHandler(models map[string]stream.Model) http.Handler

ModelHandler implements the SDK streaming model proxy using explicit bindings.

func StorageHandler

func StorageHandler(store *FileStorage, op string) http.Handler

StorageHandler serves an explicit app-local store using the SDK wire protocol.

Types

type AppBackend

type AppBackend struct {
	URL      string
	Token    string
	Client   *http.Client
	Scope    wire.RuntimeContext
	Catalog  []capability.Definition
	Platform chatruntime.Backend
}

AppBackend dispatches through the actual authenticated v3 app listener. The admitted scope and catalog are host-owned, not supplied by callback input.

func (*AppBackend) Invoke

type Config

type Config struct {
	AppID           string
	Token           string
	AppURL          string
	RouteURL        string
	State           *State
	Storage         *FileStorage
	Models          map[string]ModelBinding
	Client          *http.Client
	ExecutorFactory chatruntime.ExecutorFactory
	Discovery       capability.Discovery
	Platform        chatruntime.Backend
	Resources       Resources
	NoAuthResources Resources
	EnvVars         map[string]string
	// ResourceSession is the verified remote session coordinate, never a token.
	ResourceSession string
}

Config supplies local host dependencies. AppURL addresses the real SDK app listener; its client may use an injected transport in isolated tests.

type DirectResources

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

DirectResources serves only fixed no-auth declarations. Managed credentials and bound needs belong to the separately injected Resources adapter.

func NewDirectResources

func NewDirectResources(manifest wire.AgentManifest, client *http.Client) *DirectResources

func (*DirectResources) Connection

func (p *DirectResources) Connection(ctx context.Context, _ wire.Caller, slug string, input wire.ProxyRequest) (*http.Response, error)

func (*DirectResources) Discover

func (p *DirectResources) Discover(ctx context.Context, slug string) (schemas []wire.MCPToolSchema, err error)

func (*DirectResources) MCP

type ExecutorConfig

type ExecutorConfig struct {
	Image         string
	OpenTransport func(context.Context) (io.ReadWriteCloser, error)
	Limits        jsexec.Limits
	// User is the optional caller display context exposed to JavaScript. Use
	// the same identity as Chat's RuntimeContext; it does not authorize calls.
	User *jsexec.User
}

ExecutorConfig selects exactly one transport. OpenTransport lets a builder inject a socket-free transport to an isolated executor owned by its host; test containers must not mount the Docker socket. Image selects local Docker. Both transports execute the same framed jsexec protocol and Deno runtime.

type FileStorage

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

FileStorage is a durable app-local namespace. An atomically published catalog maps logical paths to immutable SHA-256 blobs. File locks serialize replicas; every operation reloads the catalog from shared disk.

func NewFileStorage

func NewFileStorage(root string) (*FileStorage, error)

func (*FileStorage) Close

func (s *FileStorage) Close() error

func (*FileStorage) Copy

func (s *FileStorage) Copy(ctx context.Context, src, dst string) error

func (*FileStorage) Delete

func (s *FileStorage) Delete(ctx context.Context, p string) error

func (*FileStorage) List

func (s *FileStorage) List(ctx context.Context, p string, recursive bool) ([]wire.FileInfo, error)

func (*FileStorage) Open

func (s *FileStorage) Open(ctx context.Context, p string) (io.ReadCloser, error)

func (*FileStorage) Stat

func (s *FileStorage) Stat(ctx context.Context, p string) (wire.FileInfo, error)

func (*FileStorage) Write

func (s *FileStorage) Write(ctx context.Context, p string, r io.Reader, mime string) (wire.FileInfo, error)

type Host

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

func New

func New(config Config) (*Host, error)

func (*Host) Admit

func (h *Host) Admit(ctx context.Context, caller wire.Caller) (wire.RuntimeContext, error)

func (*Host) CloseInvocation

func (h *Host) CloseInvocation(ctx context.Context, id string) error

CloseInvocation closes the exact ingress scope after app dispatch drains.

func (*Host) Handler

func (h *Host) Handler() http.Handler

func (*Host) Run

func (h *Host) Run(ctx context.Context) error

Run owns bounded worker goroutines. Filesystem leases and owner tokens are durable; another process can recover expired work with the same task ID.

func (*Host) WorkOnce

func (h *Host) WorkOnce(ctx context.Context) (bool, error)

type ManagedPostgres

type ManagedPostgres struct {
	DSN, ContainerID, Directory string
	// contains filtered or unexported fields
}

func StartManagedPostgres

func StartManagedPostgres(ctx context.Context, config PostgresConfig) (result *ManagedPostgres, err error)

func (*ManagedPostgres) Close

func (p *ManagedPostgres) Close() error

Close drains only this verified container, confirms auto-removal, then releases the lifetime lock. Host data and credentials are retained for the next run.

type ModelBinding

type ModelBinding struct {
	Model  stream.Model
	Limits session.ModelLimits
}

type PostgresConfig

type PostgresConfig struct{ AppID, Directory, Image string }

Directory contains credentials.json and pgdata/. The container is ephemeral; neither database bytes nor credentials are kept in a Docker named volume.

type Resources

Resources is the credential-free resource boundary. The adapter owns remote authentication and uses the admitted actor, never untrusted callback headers.

type State

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

State serializes durable local control state on a shared filesystem. The lock spans read, mutation, fsync and atomic publication, never network effects.

func OpenState

func OpenState(directory, appID string) (*State, error)

type StorageModel

type StorageModel struct {
	stream.Model
	Storage  *FileStorage
	Manifest wire.AgentManifest
}

storageModel materializes only explicitly configured object references at the provider boundary. Transcript/checkpoint data retain their durable references.

func (*StorageModel) Stream

func (m *StorageModel) Stream(ctx context.Context, options *stream.CallOptions) (<-chan stream.Event, error)

Jump to

Keyboard shortcuts

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