repl

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 60 Imported by: 0 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

Index

Constants

View Source
const (
	HeadlessFormatText = "text"
	HeadlessFormatJSON = "json"
)

Variables

View Source
var ErrCompletionSignalMissing = errors.New("completion signal not found in response")

ErrCompletionSignalMissing is returned when a --completion-signal was configured but the final response did not contain it. The caller should continue the loop with another iteration.

Functions

func RunREPL

func RunREPL(
	version string,
	workingDir string,
	cfg *config.ResolvedConfig,
	loader *config.Loader,
	globalCfg *config.GlobalConfig,
	registry *providers.Registry,
	needsSetup bool,
	mcpRuntime keenmcp.Runtime,
	resumeSession *session.LoadedSession,
) (string, error)

Types

type HeadlessRunOptions

type HeadlessRunOptions struct {
	WorkingDir       string
	Config           *config.ResolvedConfig
	GlobalConfig     *config.GlobalConfig
	MCPRuntime       keenmcp.Runtime
	Client           llm.LLMClient
	SessionID        string
	Prompt           string
	Format           string
	CompletionSignal string
	Out              io.Writer
	// Progress, when set and Format is text, receives live text chunks and
	// tool end lines as the run happens.
	Progress io.Writer
}

type HeadlessRunResult

type HeadlessRunResult struct {
	SessionID         string         `json:"session_id"`
	OpenCodeSessionID string         `json:"opencode_session_id"`
	Text              string         `json:"text"`
	Usage             *headlessUsage `json:"usage,omitempty"`
}

func RunHeadless

func RunHeadless(ctx context.Context, opts HeadlessRunOptions) (*HeadlessRunResult, error)

type StreamHandler

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

func NewStreamHandler

func NewStreamHandler(mdRenderer *replmarkdown.Renderer) *StreamHandler

func (*StreamHandler) Checkpoint

func (sh *StreamHandler) Checkpoint() ([]string, string, []streamSegment)

Checkpoint returns the current visible content and starts a fresh segment collection without disconnecting the active stream.

func (*StreamHandler) GetLoadingText

func (sh *StreamHandler) GetLoadingText() string

func (*StreamHandler) GetPendingChoice

func (sh *StreamHandler) GetPendingChoice() replpermissions.Choice

func (*StreamHandler) GetPendingPermissionRequest

func (sh *StreamHandler) GetPendingPermissionRequest() *replpermissions.Request

func (*StreamHandler) GetRawResponse

func (sh *StreamHandler) GetRawResponse() string

func (*StreamHandler) GetResponse

func (sh *StreamHandler) GetResponse() string

func (*StreamHandler) HandleBashEnd

func (sh *StreamHandler) HandleBashEnd(toolCall *llm.ToolCall)

func (*StreamHandler) HandleBashStart

func (sh *StreamHandler) HandleBashStart(command, summary string)

func (*StreamHandler) HandleChunk

func (sh *StreamHandler) HandleChunk(chunk string)

func (*StreamHandler) HandleDiff

func (sh *StreamHandler) HandleDiff(lines []tools.EditDiffLine)

func (*StreamHandler) HandleDone

func (sh *StreamHandler) HandleDone() ([]string, string)

func (*StreamHandler) HandleError

func (sh *StreamHandler) HandleError(err error) ([]string, string)

func (*StreamHandler) HandleInterrupt

func (sh *StreamHandler) HandleInterrupt() []string

func (*StreamHandler) HandlePermissionRequest

func (sh *StreamHandler) HandlePermissionRequest(req *replpermissions.Request)

func (*StreamHandler) HandleReasoningChunk

func (sh *StreamHandler) HandleReasoningChunk(chunk string)

func (*StreamHandler) HandleSubagentActivity

func (sh *StreamHandler) HandleSubagentActivity(activity subagents.ToolActivity)

func (*StreamHandler) HandleToolEnd

func (sh *StreamHandler) HandleToolEnd(toolCall *llm.ToolCall)

func (*StreamHandler) HandleToolStart

func (sh *StreamHandler) HandleToolStart(toolCall *llm.ToolCall)

func (*StreamHandler) HasContent

func (sh *StreamHandler) HasContent() bool

func (*StreamHandler) HasPendingPermission

func (sh *StreamHandler) HasPendingPermission() bool

func (*StreamHandler) Interrupt

func (sh *StreamHandler) Interrupt()

func (*StreamHandler) IsActive

func (sh *StreamHandler) IsActive() bool

func (*StreamHandler) MovePendingCursor

func (sh *StreamHandler) MovePendingCursor(delta int)

func (*StreamHandler) ResetContent

func (sh *StreamHandler) ResetContent()

func (*StreamHandler) ResolvePendingPermission

func (sh *StreamHandler) ResolvePendingPermission(status replpermissions.Status)

func (*StreamHandler) RewindForRetry

func (sh *StreamHandler) RewindForRetry()

RewindForRetry discards only the in-flight assistant/reasoning chunks from a failed stream attempt so the upcoming retry does not duplicate them. Segments from completed prior tool-loop iterations (tool calls, bash output, diffs, permissions) are preserved. The accumulated response strings are rebuilt from the surviving assistant segments so they match what the user still sees.

func (*StreamHandler) SetAskUser added in v0.49.0

func (sh *StreamHandler) SetAskUser(state *askUserState)

func (*StreamHandler) SetLoadingText

func (sh *StreamHandler) SetLoadingText(loadingText string)

func (*StreamHandler) Start

func (sh *StreamHandler) Start(eventCh <-chan llm.StreamEvent, loadingText string)

func (*StreamHandler) View

func (sh *StreamHandler) View(width int) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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