Documentation
¶
Index ¶
- func ComputeAuth(cmd map[string]any) (resp map[string]any, authenticated bool)
- func Emit(event map[string]any)
- func EmitType(typ string)
- func IsAuthCommand(typ string) bool
- func MountCmdBridge(r chi.Router, state *ServerState, port int)
- func Run()
- func SetEmitSink(sink EmitSink)
- func StartTodoScheduler(state *ServerState)
- type EmitSink
- type ServerState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeAuth ¶
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 ¶
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 ¶
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 ¶
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.
Source Files
¶
- emitter.go
- handlers_access.go
- handlers_agent.go
- handlers_agents.go
- handlers_analytics.go
- handlers_auth.go
- handlers_channels.go
- handlers_channels_meta.go
- handlers_etl.go
- handlers_fs_browse.go
- handlers_init.go
- handlers_kv.go
- handlers_mcp.go
- handlers_memory.go
- handlers_memory_full.go
- handlers_model_info.go
- handlers_providers.go
- handlers_sessions.go
- handlers_sessions_ext.go
- handlers_settings.go
- handlers_skills.go
- handlers_skills_full.go
- handlers_teams.go
- handlers_terminal.go
- handlers_todo_tasks.go
- handlers_workspace.go
- server.go
- state.go
- webbridge.go