agentpi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 30 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agentpi adapts Pi 1.6 RPC sessions to the unified agent contract.

Each session owns a local Pi process with automatic extension discovery disabled. Open and Resume use Pi's normal process permissions (fullAccess). The host controls any external isolation. Open and Resume accept ProcessEnv as a child process overlay. On macOS and Linux, ShellEnv loads a Pi 1.6.0 extension that applies its overlay to the model-facing bash tool.

Use OpenWithOptions or ResumeWithOptions to require approval before local write, edit, bash, and PowerShell tools. Set agent.Features.AgentQuestions explicitly to true to expose the single-question tool. Each dialog uses a live InteractionRef, expires independently and accepts one answer. Pi's response channel confirms a local frame write. The tool result reports its outcome.

StartOrSteer accepts one optional text block followed by inline images. A queued receipt confirms native admission. Watch for an idle state update after Interrupt before submitting new work that must run independently. Set Config.EnableInject to load the session extension and enable agent.Injector. Pi appends idle context immediately and active context after the current turn. An Inject receipt reports command admission. Read native history or events to observe when Pi appends the context.

To select a model, set Config.Provider and pass the model ID in agent.OpenOptions.Config. If the initial model is omitted, Pi selects its default. Config.Provider also supplies the provider for runtime model changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	CLIPath string
	// Args are launcher arguments, such as a CLI script when launching Node.js.
	Args []string
	// Env overlays the inherited process environment.
	Env []string
	// SessionDir selects a Pi session directory for both Open and exact Resume.
	SessionDir string
	// Provider qualifies the initial model when one is supplied and is required
	// for runtime model changes.
	Provider string
	// EnableInject exposes agent.Injector on sessions that load and verify
	// the private Pi 1.6.0 SDK session extension.
	EnableInject   bool
	Tracer         agent.Tracer
	TracerProvider trace.TracerProvider
	MeterProvider  metric.MeterProvider
}

Config selects the Pi executable and persistent session scope.

type Core

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

Core owns one lease per attached Pi process.

func New

func New(config Config) *Core

New prepares a Core without starting Pi.

func (*Core) Open

func (p *Core) Open(ctx context.Context, options agent.OpenOptions) (agent.Session, error)

func (*Core) OpenWithOptions

func (p *Core) OpenWithOptions(ctx context.Context, options agent.OpenOptions, piOptions SessionOptions) (agent.Session, error)

OpenWithOptions starts a Pi session with additional per-session settings.

func (*Core) Resume

func (p *Core) Resume(ctx context.Context, options agent.ResumeOptions) (agent.Session, error)

func (*Core) ResumeWithOptions

func (p *Core) ResumeWithOptions(ctx context.Context, options agent.ResumeOptions, piOptions SessionOptions) (agent.Session, error)

ResumeWithOptions starts Pi for an exact persisted session with new settings.

func (*Core) Start

func (p *Core) Start(ctx context.Context) (agent.Capabilities, error)

func (*Core) Stop

func (p *Core) Stop(ctx context.Context) error

type SessionOptions

type SessionOptions struct {
	// ToolApproval asks for confirmation before Pi's local write, edit,
	// bash, and PowerShell tools execute. It provides no sandbox.
	ToolApproval bool
	// InteractionTimeout bounds each SDK dialog. Zero selects one minute.
	InteractionTimeout time.Duration
}

SessionOptions contains the Pi-specific settings for one Open or Resume.

Directories

Path Synopsis
tests
pipeer
Package pipeer serves the controlled Pi RPC peer used by adapter tests.
Package pipeer serves the controlled Pi RPC peer used by adapter tests.

Jump to

Keyboard shortcuts

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