ipc

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ipc carries the wire protocol between Praxis and a praxis-pluginhost child process. The transport is line-delimited JSON over stdin/stdout — no protobuf, no gRPC, no third-party runtime dependency. Each line is one Frame; request and response share the same shape and are correlated by ID.

Phase 4 out-of-process loader.

Index

Constants

View Source
const (
	MethodManifest     = "manifest"
	MethodCapabilities = "capabilities"
	MethodExecute      = "execute"
	MethodSimulate     = "simulate"
)

Method enumerates the four RPCs the host binary serves. Strings are part of the wire contract; never rename without bumping a protocol version (this protocol has none yet — additive RPCs are safe).

Variables

This section is empty.

Functions

func DecodeParams

func DecodeParams(raw json.RawMessage, v any) error

DecodeParams unmarshals a Frame's Params into a typed struct.

func DecodeResult

func DecodeResult(raw json.RawMessage, v any) error

DecodeResult is DecodeParams for response payloads.

func EncodeParams

func EncodeParams(v any) (json.RawMessage, error)

EncodeParams serialises a typed params struct into RawMessage for embedding in a Frame.

func EncodeResult

func EncodeResult(v any) (json.RawMessage, error)

EncodeResult is EncodeParams for response payloads.

Types

type CapabilitiesResult

type CapabilitiesResult struct {
	Capabilities []CapabilityDescriptor `json:"capabilities"`
}

CapabilitiesResult lists the capabilities the loaded plugin declares.

type CapabilityDescriptor

type CapabilityDescriptor struct {
	Name         string   `json:"name"`
	Description  string   `json:"description,omitempty"`
	InputSchema  any      `json:"input_schema,omitempty"`
	OutputSchema any      `json:"output_schema,omitempty"`
	Permissions  []string `json:"permissions,omitempty"`
	Simulatable  bool     `json:"simulatable,omitempty"`
	Idempotent   bool     `json:"idempotent,omitempty"`
}

CapabilityDescriptor is the minimal capability shape transferred over IPC. Mirrors the fields the parent needs to reconstruct a domain.Capability without pulling the full struct (and its non-JSON fields) across the boundary.

type Codec

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

Codec wraps a paired Reader/Writer with newline-framing and a write mutex so concurrent goroutines can call Send safely. Decode is expected to run in a single dispatcher goroutine on each side.

func NewCodec

func NewCodec(r io.Reader, w io.Writer) *Codec

NewCodec wraps r and w as a JSON line-delimited codec. The decoder uses json.Decoder's streaming behaviour so it advances one frame at a time without buffering the rest of the stream.

func (*Codec) Recv

func (c *Codec) Recv() (Frame, error)

Recv reads one Frame from the stream. EOF surfaces as io.EOF unwrapped so the caller can branch on errors.Is.

func (*Codec) Send

func (c *Codec) Send(f Frame) error

Send marshals a Frame and writes it as one line. The trailing newline keeps line-buffered child processes happy and lets a human `tail` the IPC stream during debugging.

type ExecuteParams

type ExecuteParams struct {
	Capability string         `json:"capability"`
	Payload    map[string]any `json:"payload,omitempty"`
}

ExecuteParams identifies which capability to call and carries its JSON-encoded payload.

type ExecuteResult

type ExecuteResult struct {
	Output map[string]any `json:"output,omitempty"`
}

ExecuteResult is the handler's output map.

type Frame

type Frame struct {
	ID     string          `json:"id"`
	Method string          `json:"method,omitempty"`
	Params json.RawMessage `json:"params,omitempty"`
	Result json.RawMessage `json:"result,omitempty"`
	Error  string          `json:"error,omitempty"`
}

Frame is the one-line envelope. Either Method+Params is set (request) or Result/Error is set (response). ID correlates the pair; the parent owns ID generation.

type ManifestParams

type ManifestParams struct{}

ManifestParams is the request body for MethodManifest. No fields today; reserved for future extension.

type ManifestResult

type ManifestResult struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Author      string `json:"author,omitempty"`
	Description string `json:"description,omitempty"`
	Homepage    string `json:"homepage,omitempty"`
	License     string `json:"license,omitempty"`
}

ManifestResult is the response body for MethodManifest. Mirrors plugin.Manifest.

Jump to

Keyboard shortcuts

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