cli

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package cli handles command-line argument parsing and event streaming.

Index

Constants

View Source
const (
	DefaultBackend = "opencode-acp"
)
View Source
const DefaultPermissionClaimTimeout = 30 * time.Second

DefaultPermissionClaimTimeout is the default value for --permission-claim-timeout: how long resolvePermission will wait for a connected socket client to send answer_permission before falling through to the file-handler (or the no-resolver path). This bounds the TOCTOU window where HasClients() was true at the gate but the client disconnects or goes silent before answering.

Variables

This section is empty.

Functions

func DerivePermBase added in v0.8.0

func DerivePermBase(sentinelPath string) string

derivePermBase derives the permission handler base path from a sentinel path. Rule: if the path ends in ".done", strip it and append ".perm". Otherwise append ".perm" directly. This mirrors the derive_permission_base function in dispatch-avenor.sh.

func GenerateRunID added in v0.8.0

func GenerateRunID() string

generateRunID returns a random 16-character hex string (8 bytes of entropy). If crypto/rand is unavailable (e.g. fd exhaustion), it falls back to a time+pid-derived ID prefixed with "auto-" so consumers can distinguish it from the normal random form. The fallback is logged to stderr; the function never panics.

func NewEventWriter added in v0.8.0

func NewEventWriter(path string) (*eventWriter, error)

func OverrideStopReason

func OverrideStopReason(stopReason string, cancelled bool, timedOut bool) string

func ParsePermissionHandler added in v0.8.0

func ParsePermissionHandler(value string) (*permission.FileHandler, error)

func Run

func Run(args []string) int

func StartSession added in v0.8.0

func StartSession(ctx context.Context, provider runtime.Provider, opts runtime.StartOptions, resumeID string) (runtime.Session, error)

func WaitForSession added in v0.8.0

func WaitForSession(ctx context.Context, provider runtime.Provider, cfg SessionWaitConfig, deps SessionWaitDeps) sessionResult

func WriteSentinel added in v0.8.0

func WriteSentinel(path string, exitCode int, sessionID, stopReason, runID string, stderr io.Writer)

WriteSentinel writes the completion sentinel file at path using an atomic tmp+rename strategy. Errors are logged to stderr but never affect the caller's exit code.

func WriteSentinelWithReason added in v0.9.0

func WriteSentinelWithReason(path string, exitCode int, sessionID, stopReason, runID, reason string, stderr io.Writer)

WriteSentinelWithReason writes the completion sentinel file at path using an atomic tmp+rename strategy, with an optional reason line (used for exit code 5 "blocked" sentinels). Errors are logged to stderr but never affect the caller's exit code.

Types

type EventSink added in v0.8.0

type EventSink interface {
	Write(events.Event) error
	Close() error
}

type ServerDiscovery

type ServerDiscovery struct {
	URL    string
	Source string
	Mode   string
}

func DiscoverServer

func DiscoverServer(flagURL string, getenv func(string) string) ServerDiscovery

type SessionWaitConfig added in v0.9.0

type SessionWaitConfig struct {
	EventCh                <-chan events.Event
	PromptDone             <-chan error
	InterruptCh            <-chan struct{}
	SessionID              string
	RunID                  string
	RunLabel               string
	AutoApprove            bool
	PermissionClaimTimeout time.Duration
	ProgressTimeout        time.Duration
	Timeout                <-chan time.Time
}

type SessionWaitDeps added in v0.9.0

type SessionWaitDeps struct {
	Writer        EventSink
	FileHandler   *permission.FileHandler
	ControlServer *control.ControlServer
	Stderr        io.Writer
}

Jump to

Keyboard shortcuts

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