stdio

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeAuth

func ComputeAuth(cmd map[string]any) (resp map[string]any, authenticated bool)

ComputeAuth handles an auth_* command without emitting, returning the response map to send back to the requesting connection and whether the command left the caller authenticated (a successful login/registration, or a valid session check). The response is intended for connection-local delivery, never a broadcast.

func Emit

func Emit(event map[string]any)

Emit delivers a single event to the active sink (stdout by default). Thread-safe: multiple goroutines (agent tasks) may call this concurrently.

func EmitType

func EmitType(typ string)

EmitType is a shorthand for Emit when you only need a type field.

func IsAuthCommand

func IsAuthCommand(typ string) bool

IsAuthCommand reports whether typ is an auth bootstrap command.

func MountCmdBridge

func MountCmdBridge(r chi.Router, state *ServerState, port int)

MountCmdBridge mounts the /ws/cmd command WebSocket onto r and installs the broadcasting emit sink so events reach authenticated browsers. It shares the single provided ServerState across every connection, matching the desktop model where one sidecar process serves one user. port is the loopback port the server listens on, used to validate the handshake Origin.

func Run

func Run()

Run starts the JSON-over-stdio server. Blocks until stdin is closed. Called from main when --stdio flag is set.

func SetEmitSink

func SetEmitSink(sink EmitSink)

SetEmitSink replaces the event transport. Pass nil to restore stdout output. Safe to call while other goroutines are emitting.

func StartTodoScheduler

func StartTodoScheduler(state *ServerState)

StartTodoScheduler launches a background goroutine that fires due scheduled tasks every 30 seconds. Must be called once from Run().

Types

type EmitSink

type EmitSink func(event map[string]any)

EmitSink receives every event passed to Emit. The default sink writes one JSON line to stdout (the Tauri IPC transport). Web mode installs a sink that broadcasts to connected /ws/cmd clients instead. Set via SetEmitSink.

type ServerState

type ServerState struct {
	Workspace      string
	SessionID      string
	Mode           string
	ThinkingBudget int    // Anthropic budget (kept for Anthropic provider)
	ThinkLevel     string // Ollama: "", "true", "false", "low", "medium", "high"
	ActiveSkills   []string

	AllowAllMemory bool

	// AllowAllShell auto-approves run_shell commands without showing a permission prompt.
	AllowAllShell bool

	// MaxSessionMessages triggers session_limit_reached when a session exceeds this
	// number of messages. 0 = unlimited.
	MaxSessionMessages int
	// contains filtered or unexported fields
}

ServerState holds the mutable IPC state for the stdio server.

func NewWebState

func NewWebState() *ServerState

NewWebState creates a fresh server state for web mode, equivalent to the state stdio.Run() builds for the desktop IPC transport.

Jump to

Keyboard shortcuts

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