Documentation
¶
Overview ¶
Package localruntime implements app-runtime v3 adapters for local execution. Providers, identities and persistence are explicit dependencies.
Index ¶
- Constants
- func Executor(config ExecutorConfig) (chatruntime.ExecutorFactory, error)
- func ModelHandler(models map[string]stream.Model) http.Handler
- func StorageHandler(store *FileStorage, op string) http.Handler
- type AppBackend
- type Config
- type DirectResources
- func (p *DirectResources) Connection(ctx context.Context, _ wire.Caller, slug string, input wire.ProxyRequest) (*http.Response, error)
- func (p *DirectResources) Discover(ctx context.Context, slug string) (schemas []wire.MCPToolSchema, err error)
- func (p *DirectResources) MCP(ctx context.Context, _ wire.Caller, slug string, input wire.MCPToolCallRequest) (out wire.MCPToolCallResponse, err error)
- type ExecutorConfig
- type FileStorage
- func (s *FileStorage) Close() error
- func (s *FileStorage) Copy(ctx context.Context, src, dst string) error
- func (s *FileStorage) Delete(ctx context.Context, p string) error
- func (s *FileStorage) List(ctx context.Context, p string, recursive bool) ([]wire.FileInfo, error)
- func (s *FileStorage) Open(ctx context.Context, p string) (io.ReadCloser, error)
- func (s *FileStorage) Stat(ctx context.Context, p string) (wire.FileInfo, error)
- func (s *FileStorage) Write(ctx context.Context, p string, r io.Reader, mime string) (wire.FileInfo, error)
- type Host
- func (h *Host) Admit(ctx context.Context, caller wire.Caller) (wire.RuntimeContext, error)
- func (h *Host) CloseInvocation(ctx context.Context, id string) error
- func (h *Host) Handler() http.Handler
- func (h *Host) Run(ctx context.Context) error
- func (h *Host) WorkOnce(ctx context.Context) (bool, error)
- type ManagedPostgres
- type ModelBinding
- type PostgresConfig
- type Resources
- type State
- type StorageModel
Constants ¶
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 ¶
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 ¶
func (b *AppBackend) Invoke(ctx context.Context, in chatruntime.Invocation) (tool.Result, error)
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 (*DirectResources) Discover ¶
func (p *DirectResources) Discover(ctx context.Context, slug string) (schemas []wire.MCPToolSchema, err error)
func (*DirectResources) MCP ¶
func (p *DirectResources) MCP(ctx context.Context, _ wire.Caller, slug string, input wire.MCPToolCallRequest) (out wire.MCPToolCallResponse, err error)
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) Open ¶
func (s *FileStorage) Open(ctx context.Context, p string) (io.ReadCloser, error)
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
func (*Host) CloseInvocation ¶
CloseInvocation closes the exact ingress scope after app dispatch drains.
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 ¶
type Resources interface {
Connection(context.Context, wire.Caller, string, wire.ProxyRequest) (*http.Response, error)
MCP(context.Context, wire.Caller, string, wire.MCPToolCallRequest) (wire.MCPToolCallResponse, error)
}
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.
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)