tuiserver

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 106 Imported by: 1 module, 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 AttachBytesMaxBytes = attachBytesMaxBytes

Byte cap of an attached payload the owner's image staging enforces

Variables

View Source
var (
	SlashCompleter       func(ctx context.Context, skillCommands, skillBundles skills.SkillCommands) func(text string) []SlashCompletion
	GatewayKnownCommands func() map[string]bool
)

Hooks into pkg/commands assigned in cmd/icebath/wiring.go, the slash completer and the gateway command names

View Source
var (
	SaveClipboardImage    func(dest string) bool
	HasClipboardImage     func() bool
	ClipboardImageBlocker func() (missing string, noDesktop bool)
)

Clipboard image helpers set by the binary

View Source
var ActivePersonalityName func(cfg map[string]any) string

Active personality name of a config, the personality owner assigned at startup

View Source
var AvailablePersonalities func(cfg map[string]any) map[string]any

Personalities a config offers, the built ins merged with its own, assigned by the command wiring

View Source
	ReleaseDate     string
	AvailableSkills func(ctx context.Context) *pyjson.Object
	UpdateResult    func(timeout time.Duration) *int64
}

CLI banner facts the session info reports, assigned by the command wiring from the app package

View Source
var CatalogRegistry func(ctx context.Context) ([]CatalogCommand, map[string][]string)

Builtin registry rows in registry order and the subcommand table of pkg/commands, assigned in cmd/icebath/wiring.go

View Source
var CommandsByCategory func() []HelpCategory

CommandsByCategory lists the CLI command registry by category, assigned in cmd/icebath/wiring.go

View Source
var HostedSetupFlows map[string]func(ctx context.Context, ask setupflow.Asker) error

Setup sections and first run modes a hosted job runs besides the model section, assigned in cmd/icebath/wiring.go

View Source
var NormalizePersonalityName func(value any) string

NormalizePersonalityName is the personality name normalizer of the CLI, assigned in cmd/icebath/wiring.go

View Source
var PersistPersonality func(ctx context.Context, value any) bool

PersistPersonality saves the chosen personality to config, assigned in cmd/icebath/wiring.go

View Source
var Personality struct {
	EphemeralSystemPrompt func(cfg map[string]any) string
}

Session overlay prompt of the personality commands package, assigned by the command wiring

View Source
var Prefill struct {
	ResolveFile func(ctx context.Context, cfg map[string]any) string
	Load        func(ctx context.Context, filePath, baseDir string) []any
}

Prefill message loaders of the CLI config package, assigned by the command wiring from the app package

View Source
var QuickSnapshots func(home string, t func(key string, kwargs map[string]any) string) SnapshotLines

Shared /snapshot command over a profile home and a catalog lookup, set by the wiring

View Source
var RegistryPluginCommands func(ctx context.Context) ([]CatalogCommand, map[string][]string)

Plugin owned registry commands sorted by name with their subcommand table, assigned in cmd/icebath/wiring.go

View Source
var RenderPersonalityPrompt func(value any) string

RenderPersonalityPrompt renders a personality definition as its prompt, assigned in cmd/icebath/wiring.go

View Source
var ResolveCommand func(name string) (ResolvedCommand, bool)

Registry resolver of pkg/commands assigned at startup, false for a name no command or alias carries

View Source
var SaveConfigValue func(ctx context.Context, keyPath string, value any) bool

Persists one dot separated key into the active home config, the cli save_config_value assigned in cmd/icebath/wiring.go

View Source
var StatusReport struct {
	Fields func(ctx context.Context, sessionID string, a *agent.AIAgent, meta map[string]any, model, provider string, tokens any, agentRunning bool, profileHome string) map[string]any
	Lines  func(fields map[string]any, keys ...string) []string
}

Status report facts and their display lines, assigned from the CLI status report at startup

Functions

func AtExit

func AtExit()

Runs and clears the queued exit functions newest first, a panicking one not stopping the rest

func BindHostedRoomServer

func BindHostedRoomServer()

Binds the hosted room service over these installed handlers into the process slot without starting it

func ClearTUIMessageInjector

func ClearTUIMessageInjector(ctx context.Context, manager *plugins.Manager)

Drops this process's TUI host, leaving a different owner in place

func CommandCatalog

Registry backed slash metadata by category, each discovery source degrading into the warning on failure

func ConsumeTypedStopPhrase

func ConsumeTypedStopPhrase(ctx context.Context, text, sessionID string) (bool, error)

Typed stop check of the canonical prompt submit, the submitter answered in the reply instead of an event

func DecodeAttachBase64

func DecodeAttachBase64(raw, mimePrefix string, maxBytes int) ([]byte, error)

Decoded data URL or bare base64 payload under the cap, nil when invalid

func Dispatch

func Dispatch(ctx context.Context, req any, transport tuihost.Transport) map[string]any

Routes one inbound RPC, a long handler to the pool returning nil and every other inline with its response

func DispatchTUIGatewayEntry

func DispatchTUIGatewayEntry(ctx context.Context, exit func(int))

Runs the stdio gateway when the binary was re-executed as it, ending the process through exit

func GatewayToolsets

func GatewayToolsets(ctx context.Context, platform string) (enabled, disabled []string)

Enabled and configured disabled toolsets a TUI session of the platform is built with

func HandleWS

func HandleWS(ctx context.Context, ws ServedSocket, authIdentity map[string]any, subprotocol *string, operator bool) error

Runs one WebSocket session wire compatible with the stdio entry, the identity the upgrade verified owning its sessions

func InstallTUIMessageInjector

func InstallTUIMessageInjector(ctx context.Context, manager *plugins.Manager)

Publishes the TUI host on manager, or process wide and on the active profile's manager when manager is nil

func OpenLaunchStore

func OpenLaunchStore(ctx context.Context) error

Opens the launch session store before a gateway serves, the described failure stopping the start

func PathCompletionItems

func PathCompletionItems(ctx context.Context, word, root, sessionKey string, local bool) ([]tuigateway.CompletionItem, error)

Path and context ref rows for a word rooted in a folder, an empty root meaning the terminal workspace

func ProfileRuntimeScope

func ProfileRuntimeScope(ctx context.Context, profileHome string) context.Context

Context bound to the home, hydrated secrets and terminal policy of a profile home, empty meaning the launch profile

func ProjectInfoForCwd

func ProjectInfoForCwd(ctx context.Context, cwd string) any

Project of a working directory with its id, slug, name and primary path, nil when none

func RefreshLiveSessions

func RefreshLiveSessions(ctx context.Context, h *string, preservePrefix bool, pluginNote *[2]string) error

Rebuilds live session tool snapshots of a home for the gateway plugin activation hook

func RunToolsSetupFlow

func RunToolsSetupFlow(ctx context.Context, h string, ask setupflow.Asker) error

Tools section of /setup asked through a flow asker, the Blank Slate tool selector included

func SessionSteerAuthority

func SessionSteerAuthority(ctx context.Context, sessionID string) (any, any)

Steer authority of the bound request as untyped values, both nil when the transport holds none

func SettleWorktree

func SettleWorktree(ctx context.Context, tree map[string]string, choice string, echo func(string))

Carries out an exit choice, else removes a clean tree and its branch or echoes why the tree is kept

func SlashCompletions

func SlashCompletions(ctx context.Context, text string, scope func(context.Context) (context.Context, error)) (tuigateway.CompleteSlashResult, error)

Slash popup rows for the text, skills and bundles read inside the scope of the calling session, for both routes

func SniffImageExt

func SniffImageExt(data []byte, filename string) string

Image extension from the filename hint, else magic bytes, else png

func StageImageBytes

func StageImageBytes(directory string, data []byte, ext, prefix string) (string, error)

Private collision free image staging shared by local and canonical byte uploads

Types

type CatalogCommand

type CatalogCommand struct {
	Name, Category, Description string
	Aliases                     []string
	GatewayOnly                 bool
}

One builtin registry command as the palette catalog reads it

type CompressionBusy

type CompressionBusy struct{ Msg string }

Manual compression refused because a turn already holds the session

func (*CompressionBusy) Error

func (e *CompressionBusy) Error() string

type CompressionLockHeld

type CompressionLockHeld struct{ Holder string }

Compression skipped because a concurrent compression lock row is held

func (*CompressionLockHeld) Error

func (e *CompressionLockHeld) Error() string

type Handler

type Handler func(ctx context.Context, rid any, params map[string]any) map[string]any

JSON RPC handler of one registered method

func Method

func Method(name string) Handler

Handler registered for the method name, nil when none, the lookup of the server _methods table

type HelpCategory

type HelpCategory struct {
	Category string
	Rows     [][2]string
}

HelpCategory is one help category of the command registry with its command and description rows

type HostedRoomServer

type HostedRoomServer struct {
	Method          func(name string) Handler
	SessionRecord   func(sessionID string) *tuihost.Session
	PendingApproval func(ctx context.Context, sessionKey string) map[string]any
	ProfileHome     func(profile string) (string, error)
}

Server surface the adapter drives, its installed handlers, live session records, pending approvals and profile homes

func InstalledHostedRoomServer

func InstalledHostedRoomServer() HostedRoomServer

The fully initialized server of this process

type HostedRoomServerRPC

type HostedRoomServerRPC struct {
	DBPath *string
	// contains filtered or unexported fields
}

Installed server handlers normalized for the hosted room runtime

func NewHostedRoomServerRPC

func NewHostedRoomServerRPC(server HostedRoomServer, dbPath *string) *HostedRoomServerRPC

Server RPC whose event bound files resolve from the room store at the path, none without a store

func (*HostedRoomServerRPC) AcceptsAttachments

func (r *HostedRoomServerRPC) AcceptsAttachments() bool

Whether event bound files can be resolved for a turn on this route

func (*HostedRoomServerRPC) Approve

func (r *HostedRoomServerRPC) Approve(ctx context.Context, sessionID, requestID, choice string) (map[string]any, error)

Resolves one exact local room approval without broad policy changes

func (*HostedRoomServerRPC) Create

func (r *HostedRoomServerRPC) Create(ctx context.Context, profile, title, source string) (map[string]any, error)

Hidden room plumbing session that follows the profile config and survives disconnects

func (*HostedRoomServerRPC) History

func (r *HostedRoomServerRPC) History(ctx context.Context, profile, sessionID, source string) ([]map[string]any, error)

Message rows of the session, non dict rows dropped

func (*HostedRoomServerRPC) Info

func (r *HostedRoomServerRPC) Info(ctx context.Context, profile, sessionID, source string) (map[string]any, error)

Whether the live record runs, its hosted task and any approval it waits on

func (*HostedRoomServerRPC) Interrupt

func (r *HostedRoomServerRPC) Interrupt(ctx context.Context, profile, sessionID, source, expectedTaskID string) (map[string]any, error)

Interrupts the session only while the expected hosted task is the running one

func (*HostedRoomServerRPC) ResolveExact

func (r *HostedRoomServerRPC) ResolveExact(ctx context.Context, profile, title, source string) (map[string]any, error)

Newest hidden session with exactly the title, nil when the profile holds none

func (*HostedRoomServerRPC) Resume

func (r *HostedRoomServerRPC) Resume(ctx context.Context, profile, sessionID, source string) (map[string]any, error)

Resumed session without its message list

func (*HostedRoomServerRPC) Submit

Submits one fenced member turn, its bound files staged in the member's own home under a capture lease

type HostedRoomSessionError

type HostedRoomSessionError struct {
	Method      string
	Code        int64
	Msg         string
	NotAdmitted bool
}

An in process session operation the installed handler rejected

func (*HostedRoomSessionError) Error

func (e *HostedRoomSessionError) Error() string

type OwnerUnavailableError

type OwnerUnavailableError struct {
	Msg         string
	NotRunning  bool
	Unconfirmed bool
	Cause       error
}

Owner could not take the prompt, NotRunning when no gateway serves the home and Unconfirmed when it may be queued

func (*OwnerUnavailableError) Error

func (e *OwnerUnavailableError) Error() string

func (*OwnerUnavailableError) Unwrap

func (e *OwnerUnavailableError) Unwrap() error

type ProfileUnavailableError

type ProfileUnavailableError struct{ Msg string }

Explicit profile param naming no live profile on this host, answered as JSON RPC 4064

func (*ProfileUnavailableError) Error

func (e *ProfileUnavailableError) Error() string

func (*ProfileUnavailableError) PyTypeName

func (e *ProfileUnavailableError) PyTypeName() string

Python exception class name the error stands for

type ResolvedCommand

type ResolvedCommand struct {
	Name, Category string
	Describe       func(ctx context.Context) string
}

Registry command a typed name resolves to with its localized description and category

type ServedSocket

type ServedSocket interface {
	tuihost.WSConn
	Accept(ctx context.Context, subprotocol *string) error
	// Next text frame, a SocketDisconnect once the peer leaves
	ReceiveText(ctx context.Context) (string, error)
	// Peer address, nil when the server reports none
	Client() *SocketPeer
	// Raw stream socket under the connection, nil when the server exposes none
	RawConn() net.Conn
	// Session authority of the route scope, else of the app state, nil when the backend has none
	SessionAuthority() *gateway.SessionAuthority
}

Accepted WebSocket one session connection runs over, as the gateway session route hands it in

type SlashCompletion

type SlashCompletion struct {
	Text, Display, Meta string
}

One completion of the prompt slash completer, display and meta already plain text

type SnapshotLines

type SnapshotLines interface {
	List() ([]string, error)
	Create(parts []string) ([]string, error)
	Prune(parts []string) ([]string, error)
	RestoreTarget(parts []string) (string, []string, error)
}

Lines of the shared /snapshot subcommands

type SocketDisconnect

type SocketDisconnect struct {
	Code   any
	Reason any
}

Peer close a socket read reports, the starlette WebSocketDisconnect with its code and reason

func (*SocketDisconnect) Error

func (e *SocketDisconnect) Error() string

type SocketPeer

type SocketPeer struct {
	Host string
	Port *int
}

Host and port of a socket peer, the port nil when unknown

type StoreUnavailableError

type StoreUnavailableError = state.StoreUnavailableError

Session store that would not open, shared with the messaging gateway so both name the cause alike

type SyntheticHeavyAgent

type SyntheticHeavyAgent struct {
	SessionID, Model, Provider, APIMode           string
	BaseURL, APIKey, Platform, CachedSystemPrompt string
	ConfigContextLength                           int
	SessionInputTokens, SessionOutputTokens       int64
	SessionPromptTokens, SessionCompletionTokens  int64
	SessionReasoningTokens, SessionTotalTokens    int64
	SessionAPICalls                               int64
	History                                       []map[string]any
	// contains filtered or unexported fields
}

Agent shaped CPU burn whose turn holds a core with pure computation and streams synthetic deltas

func NewSyntheticHeavyAgent

func NewSyntheticHeavyAgent(sessionID, model string) *SyntheticHeavyAgent

Synthetic agent for a session reporting the given model label

func (*SyntheticHeavyAgent) ClearInterrupt

func (a *SyntheticHeavyAgent) ClearInterrupt()

Clears a pending interrupt before the next turn

func (*SyntheticHeavyAgent) Close

func (a *SyntheticHeavyAgent) Close()

Teardown that also stops the burn

func (*SyntheticHeavyAgent) HasStreamConsumers

func (a *SyntheticHeavyAgent) HasStreamConsumers() bool

Whether the turn has stream consumers, always true for the synthetic loop

func (*SyntheticHeavyAgent) Interrupt

func (a *SyntheticHeavyAgent) Interrupt()

Stops the running burn

func (*SyntheticHeavyAgent) RunConversation

func (a *SyntheticHeavyAgent) RunConversation(message any, conversationHistory []map[string]any, streamCallback func(string)) (map[string]any, error)

Runs one synthetic turn, burning CPU and streaming deltas until the duration elapses or an interrupt lands

Source Files

Jump to

Keyboard shortcuts

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