lua

package
v0.0.0-...-5f0d849 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: AGPL-3.0 Imports: 47 Imported by: 0

Documentation

Overview

Package lua — claudio.analytics.summary() API implementation.

Package lua — data provider APIs exposed as claudio.session.*, claudio.files.*, claudio.tasks.*, claudio.tokens.* for Lua plugins (especially sidebar.lua).

Package lua: claudio.lsp Lua API module.

Exposes LSP server lifecycle management and code-intelligence queries to Lua plugins so users can register, start, stop, and query LSP servers at runtime instead of (or in addition to) settings.json lspServers.

Package lua — claudio.mailbox.* API for team messaging. Exposes internal/teams/mailbox.go to Lua plugins via a MailboxProvider interface wired from lua_providers.go.

Package lua: primitive data-list APIs exposed as claudio.sessions.*, claudio.models.*, claudio.commands.*, claudio.skills.*, claudio.windows.*, claudio.actions.*.

Package lua: claudio.ui.progress — floating progress overlay API.

Package lua — UI extension APIs exposed as claudio.ui.*

Package lua — claudio.win.new / claudio.win.new_panel API implementation.

Package lua — PanelRegistry and supporting types for the claudio.win.new_panel API.

Package lua: picker and finder APIs exposed as claudio.picker.*, claudio.finder.*, and claudio.previewer.*.

Package lua embeds a single gopher-lua VM to provide a Neovim-style plugin system. All plugins share the main Lua state so that require() naturally resolves across plugins (via package.loaded). Each plugin registers its APIs through a `claudio` global table exposing tool registration, event bus, config, hooks, and notification APIs.

Package lua: window/buffer APIs exposed as claudio.buf.* and claudio.ui.*.

Index

Constants

View Source
const (
	EventTurnStart             = "turn_start"
	EventTurnEnd               = "turn_end"
	EventMessageStart          = "message_start"
	EventMessageUpdate         = "message_update"
	EventMessageEnd            = "message_end"
	EventContext               = "context"
	EventBeforeProviderRequest = "before_provider_request"
	EventAfterProviderResponse = "after_provider_response"
	EventToolExecutionStart    = "tool_execution_start"
	EventToolCall              = "tool_call"
	EventToolExecutionUpdate   = "tool_execution_update"
	EventToolResult            = "tool_result"
	EventToolExecutionEnd      = "tool_execution_end"
	EventBeforeAgentStart      = "before_agent_start"
	EventAgentStart            = "agent_start"
	EventAgentEnd              = "agent_end"
	EventModelSelect           = "model_select"
	EventThinkingLevelSelect   = "thinking_level_select"
	EventSessionStart          = "session_start"
	EventSessionBeforeSwitch   = "session_before_switch"
	EventSessionBeforeFork     = "session_before_fork"
	EventSessionBeforeCompact  = "session_before_compact"
	EventSessionCompact        = "session_compact"
	EventSessionBeforeTree     = "session_before_tree"
	EventSessionTree           = "session_tree"
	EventSessionShutdown       = "session_shutdown"
	EventResourcesDiscover     = "resources_discover"
	EventInput                 = "input"
	EventUserBash              = "user_bash"
)

Unified event names — used by claudio.on() subscribers and FireEventSync/FireEventNotify callers.

View Source
const APIVersion = "1.0.0"

APIVersion is the current Lua API version.

Variables

This section is empty.

Functions

func NormalizeLuaKey

func NormalizeLuaKey(key string) string

NormalizeLuaKey converts user-facing key names (Vim/Lua style like "<Esc>", "<Enter>", "<Space>") to the BubbleTea v2 strings that msg.String() returns ("esc", "enter", " "). This allows Lua authors to use either style.

Types

type BridgeManager

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

BridgeManager correlates outgoing bridge requests with incoming responses. Lua code calls claudio.bridge.request(eventType, payload) which blocks until an external system (e.g. claudio-forge) delivers a response via the bridge_response IPC command.

func NewBridgeManager

func NewBridgeManager() *BridgeManager

NewBridgeManager creates a ready-to-use BridgeManager.

func (*BridgeManager) Deliver

func (bm *BridgeManager) Deliver(requestID string, payload json.RawMessage) error

Deliver sends a response to the waiting bridge.request() call. Returns an error if no pending request exists for that ID.

type FileEntry

type FileEntry struct {
	Path  string
	Name  string
	IsDir bool
}

FileEntry represents a single file in the sidebar file list.

type FilesProvider

type FilesProvider interface {
	List() []FileEntry
}

FilesProvider supplies the list of files touched in the current session.

type InputRequest

type InputRequest struct {
	Prompt      string
	Default     string
	Placeholder string
	OnConfirm   func(value string) // called with the entered text on Enter
	OnCancel    func()             // called on Esc (may be nil)
}

InputRequest is sent to the TUI when claudio.ui.input() is called. The TUI shows a text-input overlay and calls OnConfirm/OnCancel when done.

type LLMCompleteResult

type LLMCompleteResult struct {
	Text         string
	InputTokens  int
	OutputTokens int
}

LLMCompleteResult holds the result returned by the llm.complete callback.

type LuaBackend

type LuaBackend struct {
	L *lua.LState
	// contains filtered or unexported fields
}

LuaBackend wraps a Lua table with a spawn function behind the teams.Backend interface. It allows Lua plugins to provide custom agent execution backends.

mu serializes all Lua calls — gopher-lua LState is NOT goroutine-safe.

func NewLuaBackend

func NewLuaBackend(L *lua.LState, mu *sync.Mutex, tbl *lua.LTable) (*LuaBackend, error)

NewLuaBackend creates a LuaBackend from a Lua table. The table must have a "spawn" key whose value is a Lua function.

func (*LuaBackend) Name

func (lb *LuaBackend) Name() string

Name returns the human-readable identifier for this backend.

func (*LuaBackend) SpawnAgent

SpawnAgent calls the Lua spawn function with the agent configuration.

The Lua function receives a table:

{ id=string, name=string, system=string, prompt=string, model=string }

It must return a table with a "wait" function field:

{ wait = function() return result_string end }

type LuaBackendHandle

type LuaBackendHandle struct {
	L *lua.LState
	// contains filtered or unexported fields
}

LuaBackendHandle wraps a Lua handle object returned by a LuaBackend's spawn function.

func (*LuaBackendHandle) Wait

func (lbh *LuaBackendHandle) Wait(_ context.Context) (string, error)

Wait calls the Lua wait function and returns its string result. The Lua function must return a string containing the agent's output.

type LuaCapability

type LuaCapability struct {
	Name      string
	ToolNames []string
}

LuaCapability holds a capability name and tool names registered by a Lua plugin.

type LuaProviderConfig

type LuaProviderConfig struct {
	Name          string
	Type          string
	BaseURL       string
	APIKey        string
	Models        map[string]string // alias → full model name
	Routes        []string
	ContextWindow int
}

LuaProviderConfig holds provider configuration registered via Lua.

type MailboxMessage

type MailboxMessage struct {
	From      string
	Text      string
	Timestamp time.Time
	Read      bool
}

MailboxMessage is a single message in the team-lead inbox.

type MailboxProvider

type MailboxProvider interface {
	Send(to, msg string) error
	Broadcast(msg string) error
	ReadAll() []MailboxMessage
	ReadUnread() []MailboxMessage
	UnreadCount() int
	Clear()
	OnMessage(fn func(from, text string))
}

MailboxProvider supplies mailbox operations for claudio.mailbox.*. All read/write methods operate on the "team-lead" inbox. OnMessage registers a Go callback that is called (possibly from a goroutine) whenever a new message arrives.

type PaletteEntry

type PaletteEntry struct {
	Name        string
	Action      string
	Description string
}

PaletteEntry is a command palette entry registered by a plugin.

type PanelDef

type PanelDef struct {
	ID       string // optional identifier; auto-generated if empty
	Title    string // display title
	Position string // "left" | "right" | "bottom" | "float" | "center"
	Width    int
	Height   int
	Visible  bool
	Focused  bool // true when this panel has TUI keyboard focus
	// ZIndex controls rendering order for float/center panels.
	// Higher value = rendered on top. Default 0.
	ZIndex int
	// Float positioning: Row/Col set explicit top-left offset for float/center panels.
	// When both are >= 0 the panel is placed at that screen position instead of being centered.
	Row int // -1 = auto (centered)
	Col int // -1 = auto (centered)
	// Border style for float/center panels. "" = no border, "single", "double", "rounded".
	Border           string
	State            any // optional; if *windows.StatefulBuffer, focus/key events fire Lua callbacks
	Mu               sync.Mutex
	Sections         []*SectionDef
	KeyBindings      map[string]func()             // panel-local key handlers, keyed by key name
	NotifyVisibility func(id string, visible bool) // set by Runtime; emits EventPanelVisibility
	NotifyFocus      func(id string)               // set by Runtime; emits EventPanelFocus + calls SetFocus
}

PanelDef describes a panel created by claudio.win.new / claudio.win.new_panel.

func (*PanelDef) AddSection

func (p *PanelDef) AddSection(s *SectionDef)

AddSection appends a section (caller must hold Mu).

func (*PanelDef) BindKey

func (p *PanelDef) BindKey(key string, fn func())

BindKey registers a panel-local key handler (caller must hold Mu).

func (*PanelDef) IsFocused

func (p *PanelDef) IsFocused() bool

IsFocused reports whether this panel currently holds TUI keyboard focus.

func (*PanelDef) RemoveSection

func (p *PanelDef) RemoveSection(id string) bool

RemoveSection removes the section with the given ID (caller must hold Mu).

func (*PanelDef) SetFocused

func (p *PanelDef) SetFocused(focused bool)

SetFocused updates the panel's focus state and fires the appropriate StatefulBuffer lifecycle callback (NotifyFocus or NotifyBlur) if State is set. Idempotent: if the panel is already in the requested focus state, no callback is fired. Safe to call from any goroutine; callbacks are invoked without the lock held to avoid deadlock if a callback re-enters panel state.

type PanelRegistry

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

PanelRegistry is a thread-safe store for all panels created by Lua plugins.

func NewPanelRegistry

func NewPanelRegistry() *PanelRegistry

NewPanelRegistry creates an empty registry.

func (*PanelRegistry) AllPanels

func (r *PanelRegistry) AllPanels() []*PanelDef

AllPanels returns all registered panels regardless of position or visibility.

func (*PanelRegistry) ByID

func (r *PanelRegistry) ByID(id string) *PanelDef

ByID returns the panel with the given ID, or nil if not found. Also matches by buffer name (the StatefulBuffer.Name()) so that Lua code can use the buffer name it passed to buf.new() as the panel identifier.

func (*PanelRegistry) ClearFocus

func (r *PanelRegistry) ClearFocus()

ClearFocus marks all panels as unfocused. Called when the TUI returns focus to the prompt (e.g. after ESC closes a Lua panel).

func (*PanelRegistry) DispatchKey

func (r *PanelRegistry) DispatchKey(key string) bool

DispatchKey routes a key to the appropriate panel key handler.

Priority order:

  1. If any panel is currently focused (Focused=true) and has a binding for key, that handler is called exclusively.
  2. Otherwise, falls back to the original behaviour: first visible panel with a binding wins (backward-compatible with single-panel setups).

Returns true if a handler was found and invoked (key consumed).

func (*PanelRegistry) FlushPending

func (r *PanelRegistry) FlushPending() []*PanelDef

FlushPending moves all pending panels into the live registry and returns them.

func (*PanelRegistry) Panels

func (r *PanelRegistry) Panels(position string) []*PanelDef

Panels returns all panels at the given position (only visible ones).

func (*PanelRegistry) PendingCount

func (r *PanelRegistry) PendingCount() int

PendingCount returns the number of queued panels (for testing).

func (*PanelRegistry) QueuePending

func (r *PanelRegistry) QueuePending(p *PanelDef)

QueuePending adds a panel to the pending queue (before TUI is wired).

func (*PanelRegistry) Register

func (r *PanelRegistry) Register(p *PanelDef)

Register adds a panel to the live registry.

func (*PanelRegistry) SetFocus

func (r *PanelRegistry) SetFocus(id string)

SetFocus transitions keyboard focus to the panel with the given ID. The previously focused panel (if any) receives SetFocused(false); the new panel receives SetFocused(true). Panels not matching id get SetFocused(false). If id is empty or not found, all panels lose focus.

func (*PanelRegistry) Unregister

func (r *PanelRegistry) Unregister(id string) *PanelDef

Unregister removes the panel with the given ID from the live registry. Returns the removed panel, or nil if not found.

func (*PanelRegistry) UnregisterByPlugin

func (r *PanelRegistry) UnregisterByPlugin(plugin *loadedPlugin)

UnregisterByPlugin removes all panels that have sections belonging to the given plugin. Used to clean up when a plugin script fails mid-execution.

type Runtime

type Runtime struct {
	StatuslineFn *lua.LFunction

	StatusbarFn *lua.LFunction

	// Bridge manager for blocking request/response across IPC boundary.
	Bridge *BridgeManager
	// contains filtered or unexported fields
}

Runtime manages Lua plugin lifecycle: loading, sandbox creation, and shutdown.

func New

func New(
	toolReg *tools.Registry,
	skillsReg *skills.Registry,
	eventBus *bus.Bus,
	hooksMgr *hooks.Manager,
	cfg *config.Settings,
	db *storage.DB,
	caps *capabilities.Registry,
) *Runtime

New creates a Lua plugin runtime wired to the given app dependencies.

func (*Runtime) ApplyProviders

func (r *Runtime) ApplyProviders(client *api.Client)

ApplyProviders registers all Lua-configured providers into the API client. Call this from app.go after the API client is created and after Lua plugins have been loaded (so pendingProviders is fully populated). It also applies any model routing registered via claudio.providers.route() or the routing key in claudio.setup({}).

func (*Runtime) ApplySkillsSpawnHooks

func (r *Runtime) ApplySkillsSpawnHooks(agentName string, skillNames []string) []string

ApplySkillsSpawnHooks calls each registered on_agent_spawn callback with (agentName, skillNames) and returns the (possibly modified) skill name list. It handles two handler styles:

  • skillsSpawnHdlrs: old-style fn(agent_name, skills) → skills
  • toolsSpawnHdlrs: harness-style fn(agent_name, tools, skills) → tools, skills (tools arg is empty; skills return is used)

func (*Runtime) ApplyToolsSpawnHooks

func (r *Runtime) ApplyToolsSpawnHooks(agentName string, toolNames []string) []string

ApplyToolsSpawnHooks calls each tools.on_agent_spawn handler with (agentName, toolNames, emptySkills) and returns the (possibly filtered) tool name list from the first return value. Each handler uses signature fn(agent_name, tools, skills) → tools, skills.

func (*Runtime) Close

func (r *Runtime) Close()

Close shuts down all Lua VMs, cancels in-flight AI/agent calls, and unsubscribes bus handlers.

func (*Runtime) CurrentVimMode

func (r *Runtime) CurrentVimMode() string

CurrentVimMode returns the current vim mode string by reading the wired prompt pointer. Returns "unknown" when the prompt is not yet wired. This is used as the SetGetModeFunc getter so claudio.mode.get() works.

func (*Runtime) ExecString

func (r *Runtime) ExecString(code string) (string, error)

ExecString runs a Lua string in a transient sandboxed state — public API for :lua REPL. Returns any string value left on the stack and any execution error.

func (*Runtime) FireEventNotify

func (r *Runtime) FireEventNotify(event string, data map[string]lua.LValue)

FireEventNotify fires all claudio.on() handlers for the given event synchronously. Return values from handlers are ignored. Used for notification-only events.

func (*Runtime) FireEventSync

func (r *Runtime) FireEventSync(event string, data map[string]lua.LValue) (map[string]any, error)

FireEventSync fires all claudio.on() handlers for the given event synchronously in the calling goroutine. Each handler receives a context table built from data. Return tables are merged (later handlers override earlier keys). If any handler returns { cancel = true }, execution stops early. Returns nil if no handler returned data.

func (*Runtime) FireNotifyGo

func (r *Runtime) FireNotifyGo(event string, data map[string]any)

FireNotifyGo is a Go-friendly wrapper around FireEventNotify that accepts map[string]any instead of map[string]lua.LValue. This lets callers outside the lua package fire notification events without importing gopher-lua.

func (*Runtime) FireOnMessage

func (r *Runtime) FireOnMessage(sessionID, role, content string)

FireOnMessage calls all on_message handlers whose session filter matches sessionID (or is unset) and publishes a "session.message_complete" bus event. It is safe to call from any goroutine; each handler runs in its own goroutine.

func (*Runtime) FireSyncGo

func (r *Runtime) FireSyncGo(event string, data map[string]any) (map[string]any, error)

FireSyncGo is a Go-friendly wrapper around FireEventSync that accepts map[string]any instead of map[string]lua.LValue, performing the conversion inside each plugin's LState. This lets callers outside the lua package fire events without importing gopher-lua.

func (*Runtime) GetPanelRegistry

func (r *Runtime) GetPanelRegistry() *PanelRegistry

GetPanelRegistry returns the wired PanelRegistry (nil until TUI is ready).

func (*Runtime) GetWindowManager

func (r *Runtime) GetWindowManager() *windows.Manager

GetWindowManager returns the wired window manager (nil until TUI is ready).

func (*Runtime) LoadDefaults

func (r *Runtime) LoadDefaults() error

LoadDefaults executes the embedded defaults.lua, setting initial config values on the Runtime's Settings before user init or plugins run.

func (*Runtime) LoadPlugin

func (r *Runtime) LoadPlugin(name, dir string) (retErr error)

LoadPlugin loads a single init.lua from dir in the main shared LState. PLUGIN_DIR is set before execution and cleared afterwards so that each plugin's init.lua sees its own directory. package.path is augmented to include the plugin directory so require() can find the plugin's modules.

func (*Runtime) LoadProjectInit

func (r *Runtime) LoadProjectInit(projectDir string) error

LoadProjectInit loads <projectDir>/.claudio/init.lua if it exists. Injects PROJECT_CLAUDIO_DIR global pointing to <projectDir>/.claudio so require() and file paths work without debug.getinfo hacks. Missing file silently returns nil; any parse or runtime error is returned. Symlinks are rejected to prevent loading files outside trusted directories.

func (*Runtime) LoadUserInit

func (r *Runtime) LoadUserInit(path string) error

LoadUserInit loads the Lua file at path if it exists. If the file is absent, nil is returned (missing user init is not an error). Any parse or runtime error in the file is returned to the caller. Symlinks are rejected to prevent loading files outside trusted directories.

func (*Runtime) NotifyBranchCreated

func (r *Runtime) NotifyBranchCreated(branchID, parentID, messageID string)

NotifyBranchCreated fires all registered on_branch handlers. Called from TUI or Lua after a branch session is created.

func (*Runtime) PendingPaletteEntries

func (r *Runtime) PendingPaletteEntries() []PaletteEntry

PendingPaletteEntries returns all palette entries registered by plugins.

func (*Runtime) PluginListForDisplay

func (r *Runtime) PluginListForDisplay() string

PluginListForDisplay returns a human-readable summary of declared plugins. Used by the :plugins command.

func (*Runtime) Reload

func (r *Runtime) Reload() error

Reload gracefully tears down all Lua plugins and replays the initial load sequence (defaults → user init → project init). Plugins declared via claudio.plugin.use() in init.lua are re-registered and loaded from their already-installed directories. In-flight AI/agent calls are NOT cancelled. Returns the first error encountered, if any.

func (*Runtime) RenderStatusbar

func (r *Runtime) RenderStatusbar(ctx StatusbarCtx) string

RenderStatusbar calls the Lua statusbar function with the given ctx. Returns "" if no function is registered or on any error. Results are cached for statusbarCacheTTL to avoid calling Lua on every View() frame.

func (*Runtime) RenderStatusline

func (r *Runtime) RenderStatusline(ctx StatuslineCtx) string

RenderStatusline calls the Lua statusline function with the given ctx. Returns "" if no function is registered or on any error. Results are cached for statuslineCacheTTL to avoid calling Lua on every View() frame.

func (*Runtime) RunPromptHooks

func (r *Runtime) RunPromptHooks(text string) (string, bool)

RunPromptHooks runs all registered on_submit hooks in registration order.

Each hook receives the current text. If any hook returns false (Lua boolean), submission is cancelled and (text, true) is returned. If a hook returns a string, that string replaces the text for subsequent hooks. Nil / no return value passes text through unchanged.

Returns the (possibly transformed) text and whether submission was cancelled.

func (*Runtime) SetAnalyticsTracker

func (r *Runtime) SetAnalyticsTracker(t *analytics.Tracker)

SetAnalyticsTracker wires the analytics tracker for claudio.analytics.summary().

func (*Runtime) SetBindKeyFn

func (r *Runtime) SetBindKeyFn(fn func(key string, goFn func()))

SetBindKeyFn wires the callback that registers a buffer-local key binding in the TUI. Called by the TUI after Model init; fn stores the Go func in the active buffer's keyBindings map.

func (*Runtime) SetCommandRegistry

func (r *Runtime) SetCommandRegistry(reg *commands.Registry)

SetCommandRegistry wires the command registry and flushes pending commands.

func (*Runtime) SetCurrentSessionID

func (r *Runtime) SetCurrentSessionID(id string)

SetCurrentSessionID updates the cached current session ID used by claudio.session.id() and branch APIs. Call this whenever the active session changes (e.g. from a bus "session.load" subscription).

func (*Runtime) SetFilesProvider

func (r *Runtime) SetFilesProvider(p FilesProvider)

SetFilesProvider wires the files data provider for claudio.files.list().

func (*Runtime) SetGetModeFunc

func (r *Runtime) SetGetModeFunc(fn func() string)

SetGetModeFunc wires the mode getter from the TUI root model. Called by app.go after TUI init. The function should return one of: "normal", "insert", "visual", "command".

func (*Runtime) SetInputOpener

func (r *Runtime) SetInputOpener(fn func(InputRequest))

SetInputOpener wires the opener callback so Lua plugins can open a text-input overlay. The fn is called with an InputRequest whenever claudio.ui.input() is invoked.

func (*Runtime) SetKeymapRegistry

func (r *Runtime) SetKeymapRegistry(reg *vim.KeymapRegistry)

SetKeymapRegistry wires the keymap registry.

func (*Runtime) SetLSPManager

func (r *Runtime) SetLSPManager(mgr *lsp.ServerManager)

SetLSPManager wires the LSP ServerManager so Lua plugins can register and control LSP servers.

func (*Runtime) SetLeaderKeymap

func (r *Runtime) SetLeaderKeymap(km *keymapPkg.Keymap)

SetLeaderKeymap wires the TUI's leader keymap so that claudio.keymap.map/unmap calls take effect immediately. Any bindings registered before this call (e.g. from defaults.lua) are flushed now. Lua defaults only apply if the user has not already set a binding for that sequence via keymap.json.

func (*Runtime) SetMailboxProvider

func (r *Runtime) SetMailboxProvider(p MailboxProvider)

SetMailboxProvider wires the mailbox provider. Registers a Go callback for new-message notifications so that Lua on_message handlers are dispatched.

func (*Runtime) SetPanelRegistry

func (r *Runtime) SetPanelRegistry(reg *PanelRegistry)

SetPanelRegistry wires the panel registry. Any panels queued before this call are flushed into the live registry.

func (*Runtime) SetPickerOpener

func (r *Runtime) SetPickerOpener(fn func(picker.Config))

SetPickerOpener wires the opener callback so Lua plugins can open picker overlays. The fn is called with a picker.Config whenever Lua requests a picker open.

func (*Runtime) SetPrompt

func (r *Runtime) SetPrompt(p *prompt.Model)

SetPrompt wires the prompt model so claudio.prompt.* calls can mutate it. Any placeholder or mode set before TUI init is applied immediately.

Stale-pointer risk: p must remain valid for the lifetime of the Runtime. Root passes &m.prompt where m is the root bubbletea Model stored on the heap; the address is stable as long as the root Model is not replaced. If the TUI ever reinitializes the root Model (e.g. a full restart without process exit), SetPrompt must be called again with the new address before any Lua prompt.* calls can safely reach the live prompt.

func (*Runtime) SetReloadPaths

func (r *Runtime) SetReloadPaths(userInit string, projectDir string)

SetReloadPaths stores the paths needed by Reload(). Call this from app.go after the initial load sequence completes, passing the same paths that were used.

func (*Runtime) SetRunAICall

func (r *Runtime) SetRunAICall(fn func(ctx context.Context, system, user, model string) (string, error))

SetRunAICall wires the lightweight AI call callback for claudio.ai.run().

func (*Runtime) SetRunAgentCall

func (r *Runtime) SetRunAgentCall(fn func(ctx context.Context, system, prompt, model string, maxTurns int, allowedTools []string) (string, error))

SetRunAgentCall wires the sub-agent call callback for claudio.agent.spawn().

func (*Runtime) SetRunLLMComplete

func (r *Runtime) SetRunLLMComplete(fn func(ctx context.Context, model, system string, maxTokens int, messages []api.Message) (*LLMCompleteResult, error))

SetRunLLMComplete wires the full LLM complete callback for claudio.llm.complete().

func (*Runtime) SetSessionProvider

func (r *Runtime) SetSessionProvider(p SessionProvider)

SetSessionProvider wires the session data provider for claudio.session.current().

func (*Runtime) SetSocketPath

func (r *Runtime) SetSocketPath(path string)

SetSocketPath stores the IPC socket path so Lua can retrieve it via claudio.server.socket_path().

func (*Runtime) SetTasksProvider

func (r *Runtime) SetTasksProvider(p TasksProvider)

SetTasksProvider wires the tasks data provider for claudio.tasks.list().

func (*Runtime) SetTeamManager

func (r *Runtime) SetTeamManager(mgr *teams.Manager)

SetTeamManager wires the team Manager so Lua plugins can inspect team configuration.

func (*Runtime) SetTeamRunner

func (r *Runtime) SetTeamRunner(runner *teams.TeammateRunner)

SetTeamRunner wires the TeammateRunner so Lua plugins can inspect agent state.

func (*Runtime) SetTokensProvider

func (r *Runtime) SetTokensProvider(p TokensProvider)

SetTokensProvider wires the tokens data provider for claudio.tokens.usage().

func (*Runtime) SetWindowManager

func (r *Runtime) SetWindowManager(wm *windows.Manager)

SetWindowManager wires the window manager and flushes any pending window registrations.

func (*Runtime) SetWorkerRunner

func (r *Runtime) SetWorkerRunner(runner *teams.TeammateRunner)

SetWorkerRunner wires the background worker runner so Lua plugins can list/kill workers.

func (*Runtime) SyncPlugins

func (r *Runtime) SyncPlugins(ctx context.Context, progressFn func(string)) error

SyncPlugins clones or updates all registered plugin specs, then loads each plugin that isn't already loaded. progressFn is called with a human-readable status line for each step. Errors during individual plugin operations are reported via progressFn and logged but do not abort the full sync.

func (*Runtime) UnloadPlugin

func (r *Runtime) UnloadPlugin(name string) error

UnloadPlugin unloads a single plugin by name: unsubscribes bus handlers, closes the Lua VM, and removes the plugin from the runtime.

type SectionDef

type SectionDef struct {
	ID        string
	Title     string
	Weight    int
	MinHeight int

	GoRender func(w, h int) string // Go-based render (used when renderFn is nil)
	// contains filtered or unexported fields
}

SectionDef describes one section inside a panel.

func (*SectionDef) CallRender

func (s *SectionDef) CallRender(w, h int) string

CallRender invokes the render function with (w, h) and returns the string. Prefers GoRender if set (for StatefulBuffer-backed sections); otherwise falls through to the Lua renderFn. Lua renders are cached for renderCacheTTL to avoid running expensive callbacks (git, analytics) on every View() frame.

func (*SectionDef) Render

func (s *SectionDef) Render(w, h int) string

Render returns the section content at (w, h). Public interface for TUI consumers.

type SessionProvider

type SessionProvider interface {
	CurrentID() string
	CurrentName() string
	CurrentModel() string
}

SessionProvider supplies session metadata for claudio.session.current().

type StatusbarCtx

type StatusbarCtx struct {
	Mode               string
	VimMode            string
	Model              string
	Tokens             int
	Cost               float64
	Turns              int
	Streaming          bool
	SpinText           string
	SessionName        string
	PanelName          string
	ContextUsed        int
	ContextMax         int
	BackgroundSessions int
	TeamSummary        string
	UnreadMailbox      int
	RateLimitWarning   string
	RateLimitError     string
	IsUsingOverage     bool
	Width              int
}

StatusbarCtx holds contextual data passed to the Lua statusbar function. It is a superset of StatuslineCtx, providing all status-bar fields.

type StatuslineCtx

type StatuslineCtx struct {
	Mode    string
	Model   string
	Tokens  int
	Session string
}

StatuslineCtx holds contextual data passed to the Lua statusline function.

type TaskEntry

type TaskEntry struct {
	ID         string
	Title      string
	Status     string
	ActiveForm string
}

TaskEntry represents a task for the Lua API surface.

type TasksProvider

type TasksProvider interface {
	List() []TaskEntry
}

TasksProvider supplies the list of tracked tasks.

type TokenUsage

type TokenUsage struct {
	Used int
	Max  int
	Cost float64
}

TokenUsage holds token usage stats for claudio.tokens.usage().

type TokensProvider

type TokensProvider interface {
	Usage() TokenUsage
}

TokensProvider supplies token usage data.

type UIInputPayload

type UIInputPayload struct {
	Prompt      string `json:"prompt"`
	Default     string `json:"default,omitempty"`
	Placeholder string `json:"placeholder,omitempty"`
}

UIInputPayload is published on bus.EventUIInput.

type UINotificationPayload

type UINotificationPayload struct {
	Message string `json:"message"`
	Level   string `json:"level"`
	Source  string `json:"source"`
}

UINotificationPayload is the payload published on bus.EventUINotification.

type WindowDef

type WindowDef struct {
	Window *windows.Window
}

WindowDef queues a window registration before WindowManager is wired.

Jump to

Keyboard shortcuts

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