jsonrpc

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package jsonrpc implements a Unix socket JSON-RPC server for pi-go. It accepts JSON-RPC requests and streams JSONL events back to clients, enabling editor/IDE integration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Agent      *agent.Agent
	SocketPath string
}

Config holds the RPC server configuration.

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error is a JSON-RPC error object.

type Event

type Event struct {
	Type      string `json:"type"`
	Agent     string `json:"agent,omitempty"`
	Role      string `json:"role,omitempty"`
	Delta     string `json:"delta,omitempty"`
	Content   string `json:"content,omitempty"`
	ToolName  string `json:"tool_name,omitempty"`
	ToolInput any    `json:"tool_input,omitempty"`
}

Event is a JSONL streaming event (same schema as JSON mode).

type PromptParams

type PromptParams struct {
	Text      string `json:"text"`
	SessionID string `json:"session_id,omitempty"`
}

PromptParams are the parameters for the "prompt" method.

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
	ID      any             `json:"id"`
}

Request is a JSON-RPC request from the client.

type Response

type Response struct {
	JSONRPC string `json:"jsonrpc"`
	Result  any    `json:"result,omitempty"`
	Error   *Error `json:"error,omitempty"`
	ID      any    `json:"id"`
}

Response is a JSON-RPC response to the client.

type Server

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

Server is a Unix socket JSON-RPC server.

func NewServer

func NewServer(cfg Config) *Server

NewServer creates a new RPC server.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the server and blocks until shutdown. It listens on the Unix socket and handles client connections concurrently. Graceful shutdown occurs on SIGTERM or SIGINT, or when ctx is canceled.

type SessionResult

type SessionResult struct {
	SessionID string   `json:"session_id,omitempty"`
	Sessions  []string `json:"sessions,omitempty"`
}

SessionResult is the result of session-related methods.

Jump to

Keyboard shortcuts

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