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 ¶
- type Config
- type Core
- func (p *Core) Open(ctx context.Context, options agent.OpenOptions) (agent.Session, error)
- func (p *Core) OpenWithOptions(ctx context.Context, options agent.OpenOptions, piOptions SessionOptions) (agent.Session, error)
- func (p *Core) Resume(ctx context.Context, options agent.ResumeOptions) (agent.Session, error)
- func (p *Core) ResumeWithOptions(ctx context.Context, options agent.ResumeOptions, piOptions SessionOptions) (agent.Session, error)
- func (p *Core) Start(ctx context.Context) (agent.Capabilities, error)
- func (p *Core) Stop(ctx context.Context) error
- type SessionOptions
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 (*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) 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.
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.