pi

package
v0.10.10 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const PiModelDiscoveryFreshnessWindow = 24 * time.Hour

Variables

This section is empty.

Functions

func DefaultPiModelDiscovery

func DefaultPiModelDiscovery() harnesses.ModelDiscoverySnapshot

DefaultPiModelDiscovery returns the compatibility-table fallback used when live pi CLI model discovery is unavailable.

func ReadPiModelDiscoveryFromHelp

func ReadPiModelDiscoveryFromHelp(ctx context.Context, binary string, args ...string) (harnesses.ModelDiscoverySnapshot, error)

ReadPiModelDiscoveryFromHelp captures the stable pi --help surface. Help exposes the default model and thinking levels without requiring credentials.

func ReadPiModelDiscoveryFromListModels

func ReadPiModelDiscoveryFromListModels(ctx context.Context, binary string, args ...string) (harnesses.ModelDiscoverySnapshot, error)

ReadPiModelDiscoveryFromListModels captures the concrete model table from pi --list-models. The command prints catalog metadata and does not execute a prompt, but callers can fall back to ReadPiModelDiscoveryFromHelp if a local pi build lacks the command.

func ReadPiModelDiscoveryFromListModelsForProviders

func ReadPiModelDiscoveryFromListModelsForProviders(ctx context.Context, binary string, providers []string, args ...string) (harnesses.ModelDiscoverySnapshot, error)

ReadPiModelDiscoveryFromListModelsForProviders parses `pi --list-models` and returns a snapshot whose Models list is restricted to the supplied provider names (case-insensitive). This is the surface used when a caller has configured local providers (e.g. lmstudio, omlx) and only wants Pi's concrete model table for those providers.

If providers is empty the snapshot carries all discovered models.

Types

type PiListModel

type PiListModel struct {
	Provider string
	Model    string
}

PiListModel is one row of the `pi --list-models` provider/model table.

type Runner

type Runner struct {
	// Binary is the absolute path to the pi executable. When empty the
	// runner resolves "pi" via PATH at Execute time.
	Binary string

	// BaseArgs is prepended to the per-request argument list.
	// Pi default: ["--mode", "json", "--print"]
	BaseArgs []string

	// PromptMode controls how the prompt is delivered:
	//   "arg" (default) — prompt is appended as the final positional argument
	//   "stdin"         — prompt is piped on stdin
	PromptMode string

	// EventBuffer overrides the per-Execute channel buffer size.
	EventBuffer int
}

Runner is the subprocess-backed pi harness. It launches pi in --mode json --print mode, parses each JSONL line into harness Events, and emits a final Event when the subprocess exits.

Pi emits JSONL where each line is a JSON object. The relevant event types:

  • type=text_end or type=text_delta carries message.usage or partial.usage
  • Final output text is in the last line's response field

func (*Runner) Execute

func (r *Runner) Execute(ctx context.Context, req harnesses.ExecuteRequest) (<-chan harnesses.Event, error)

Execute runs one resolved request through the pi CLI and emits JSONL-derived events on the returned channel.

func (*Runner) HealthCheck

func (r *Runner) HealthCheck(ctx context.Context) error

HealthCheck verifies the pi binary is present.

func (*Runner) Info

func (r *Runner) Info() harnesses.HarnessInfo

Info returns identity + capability metadata for this harness.

Jump to

Keyboard shortcuts

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