modes

package
v0.87.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 11 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 modes corresponds to pi's packages/coding-agent/src/modes.

pi: modes/json-event.ts — session event shape emitted by the JSON and RPC stdout protocols: cumulative assistant snapshots are stripped from streaming wire events (message_start provides the initial message, deltas build it, and message_end provides the final authoritative message). Cumulative usage, tool-call ids, and tool names remain available because their size is constant. pig's AssistantMessageEvent already carries toolCall as a typed field, so pi's content-index extraction collapses to reading event.ToolCall.

pi: modes/print-mode.ts — print mode (single-shot): send prompts, output result, exit. Used for `pig -p "prompt"` (text output) and `pig --mode json "prompt"` (JSON event stream).

pig declares a PrintRuntimeHost interface instead of depending on the concrete core.AgentSessionRuntime (pi: runtimeHost: AgentSessionRuntime) — the method set used here is exactly pi's consumption surface, and the interface keeps the mode testable without the runtime constructor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalJsonEvent

func MarshalJsonEvent(event any) ([]byte, error)

MarshalJsonEvent renders one wire event as JSON (pi's JSON.stringify call site in print-mode).

func RunPrintMode

func RunPrintMode(ctx context.Context, runtimeHost PrintRuntimeHost, options PrintModeOptions) int

RunPrintMode runs in print (single-shot) mode: sends prompts to the agent and outputs the result (pi: runPrintMode). Returns the process exit code.

func ToJsonEvent

func ToJsonEvent(event core.AgentSessionEvent) (any, error)

ToJsonEvent removes cumulative assistant snapshots from streaming wire events (pi: toJsonEvent). Returns the event unchanged for non message_update types.

Types

type JsonAgentSessionEvent

type JsonAgentSessionEvent = core.AgentSessionEvent

JsonAgentSessionEvent is the wire event (pi: JsonAgentSessionEvent).

type JsonAssistantMessageEvent

type JsonAssistantMessageEvent struct {
	types.AssistantMessageEvent
	ID       string `json:"id,omitempty"`
	ToolName string `json:"toolName,omitempty"`
}

JsonAssistantMessageEvent is AssistantMessageEvent plus the toolcall_start id/toolName fields (pi's { ...deltaEvent, id, toolName } spread). The embedded struct's fields marshal inline.

type JsonMessageUpdateEvent

type JsonMessageUpdateEvent struct {
	Type                  string                    `json:"type"`
	Usage                 *types.Usage              `json:"usage"`
	AssistantMessageEvent JsonAssistantMessageEvent `json:"assistantMessageEvent"`
}

JsonMessageUpdateEvent is the message_update event with the assistant snapshot removed (pi: JsonMessageUpdateEvent; pig's AssistantMessageEvent clears Partial instead of omitting the key — the JSON shape keeps "partial" absent via omitempty).

type PrintModeOptions

type PrintModeOptions struct {
	// Mode is the output mode: "text" for final response only, "json" for
	// all events.
	Mode string
	// Messages are additional prompts to send after InitialMessage.
	Messages []string
	// InitialMessage is the first message to send (may contain @file
	// content); "" = none.
	InitialMessage string
	// InitialImages are images attached to the initial message.
	InitialImages []types.ImageContent
}

PrintModeOptions are the print mode options (pi: PrintModeOptions).

type PrintRuntimeHost

type PrintRuntimeHost interface {
	Session() *core.AgentSession
	NewSession(ctx context.Context, options *core.RuntimeNewSessionOptions) (cancelled bool, err error)
	Fork(ctx context.Context, entryID string, options *core.ForkOptions) (*core.ForkResult, error)
	SwitchSession(ctx context.Context, sessionPath string, options *core.SwitchSessionOptions) (cancelled bool, err error)
	Dispose() error
	SetRebindSession(rebindSession func(session *core.AgentSession) error)
}

PrintRuntimeHost is the runtime host consumption surface (pi: AgentSessionRuntime's members used by runPrintMode).

Directories

Path Synopsis
pi: src/modes/interactive/bug-report.ts — the `/bug` flow: consent, optional model-written summary, then upload or zip export (pi v0.86.0).
pi: src/modes/interactive/bug-report.ts — the `/bug` flow: consent, optional model-written summary, then upload or zip export (pi v0.86.0).
components
armin.go (pi: components/armin.ts) — "Armin says hi!" easter egg with animated half-block XBM art and 7 random effects.
armin.go (pi: components/armin.ts) — "Armin says hi!" easter egg with animated half-block XBM art and 7 random effects.
theme
fs_watch.go (pi: src/modes/interactive/theme — theme file watching).
fs_watch.go (pi: src/modes/interactive/theme — theme file watching).
Package rpc corresponds to pi's packages/coding-agent/src/modes/rpc.
Package rpc corresponds to pi's packages/coding-agent/src/modes/rpc.

Jump to

Keyboard shortcuts

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