inprocess

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package inprocess provides an in-process plugin router that dispatches tool calls, storage operations, and prompt requests via direct Go function calls instead of QUIC network round-trips. It implements the Sender interface used by StdioTransport and the StorageClient interface used by plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientTLSConfigForBridge

func ClientTLSConfigForBridge(certsDir string) (*tls.Config, error)

ClientTLSConfigForBridge returns a TLS config suitable for the orchestra host to connect to child plugin QUIC servers. This is a convenience wrapper around the SDK's ClientTLSConfig with the correct ALPN protocol.

Types

type ExternalPlugin

type ExternalPlugin struct {
	ID         string
	ProvidesAI []string
	ToolDefs   []*pluginv1.ToolDefinition
	PromptDefs []*pluginv1.PromptDefinition
	Client     Sender
}

ExternalPlugin represents a QUIC-connected plugin that runs as a separate process (e.g. engine-rag written in Rust, or third-party plugins). The router forwards requests to it via its Send method.

func (*ExternalPlugin) Send

Send forwards a request to the external plugin via its QUIC client.

type QUICBridge

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

QUICBridge is a QUIC listener that child plugin processes connect to for storage access and cross-plugin tool calls. The router proxies all requests through its in-process handlers.

type Router

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

Router dispatches PluginRequests to in-process tool handlers, storage handlers, and prompt handlers. It replaces the QUIC-based orchestrator router for local IDE use. External plugins (e.g. engine-rag) are supported via ExternalPlugin entries that forward requests over QUIC.

Router implements the Sender interface:

Send(ctx, *PluginRequest) (*PluginResponse, error)

This means it can be passed directly to StdioTransport and also used as the clientAdapter for plugins that need cross-plugin storage calls.

func NewRouter

func NewRouter() *Router

NewRouter creates a new in-process Router.

func (*Router) ListToolNames

func (r *Router) ListToolNames() []string

ListToolNames returns a list of all registered tool names (for logging).

func (*Router) ListenAndServeQUIC

func (r *Router) ListenAndServeQUIC(ctx context.Context, addr string, certsDir string) (string, error)

ListenAndServeQUIC starts a QUIC listener using mTLS certificates from the given certsDir. Child plugins connect to this address (passed as --orchestrator-addr) to make storage and cross-plugin RPC calls.

Returns the actual bound address (e.g. "127.0.0.1:56789") which should be passed to spawnPlugin when starting child processes.

func (*Router) RegisterExternal

func (r *Router) RegisterExternal(ep *ExternalPlugin)

RegisterExternal adds an external QUIC-connected plugin to the router.

func (*Router) RegisterPlugin

func (r *Router) RegisterPlugin(ep *plugin.ExportedPlugin)

RegisterPlugin registers all tools, streaming tools, and prompts from an ExportedPlugin. If the plugin's manifest declares ProvidesAI, tools are indexed under the AI routing table instead of the generic tool table.

func (*Router) Send

Send implements the Sender interface. It dispatches a PluginRequest to the appropriate in-process handler based on the request type.

func (*Router) SetStorageHandler

func (r *Router) SetStorageHandler(h plugin.StorageHandler)

SetStorageHandler sets the storage backend (typically storage-markdown).

type Sender

type Sender interface {
	Send(ctx context.Context, req *pluginv1.PluginRequest) (*pluginv1.PluginResponse, error)
}

Sender abstracts the QUIC client for external plugins.

type TCPServer

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

TCPServer listens for desktop app connections (Swift, Windows, Linux) using the same length-delimited Protobuf protocol as the orchestrator's TCP bridge. Each TCP connection handles one request/response pair.

func NewTCPServer

func NewTCPServer(addr string, router *Router) *TCPServer

NewTCPServer creates a TCP server bound to the given address.

func (*TCPServer) Addr

func (s *TCPServer) Addr() string

Addr returns the actual listening address. Only valid after ListenAndServe.

func (*TCPServer) ListenAndServe

func (s *TCPServer) ListenAndServe(ctx context.Context) error

ListenAndServe starts the TCP listener and processes connections until the context is cancelled. Each connection receives one PluginRequest and gets one PluginResponse back, using the SDK's length-delimited Protobuf framing.

Jump to

Keyboard shortcuts

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