app

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTitleGenerating = fmt.Errorf("title generation in progress, please wait")

UpdateSessionTitle updates the current session's title and persists it. It works with both local and remote runtimes. ErrTitleGenerating is returned when attempting to set a title while generation is in progress.

Functions

This section is empty.

Types

type App

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

func New

func New(ctx context.Context, rt runtime.Runtime, sess *session.Session, opts ...Opt) *App

func (*App) AvailableModels

func (a *App) AvailableModels(ctx context.Context) []runtime.ModelChoice

AvailableModels returns the list of models available for selection. Returns nil if model switching is not supported.

func (*App) CompactSession

func (a *App) CompactSession(ctx context.Context, additionalPrompt string)

func (*App) CurrentAgentCommands

func (a *App) CurrentAgentCommands(ctx context.Context) types.Commands

CurrentAgentCommands returns the commands for the active agent

func (*App) CurrentAgentModel

func (a *App) CurrentAgentModel() string

CurrentAgentModel returns the model ID for the current agent. Returns the tracked model from AgentInfoEvent, or falls back to session overrides. Returns empty string if no model information is available (fail-open scenario).

func (*App) CurrentAgentSkills

func (a *App) CurrentAgentSkills() []skills.Skill

CurrentAgentSkills returns the available skills if skills are enabled for the current agent.

func (*App) CurrentMCPPrompts

func (a *App) CurrentMCPPrompts(ctx context.Context) map[string]mcptools.PromptInfo

CurrentMCPPrompts returns the available MCP prompts for the active agent

func (*App) EmitStartupInfo

func (a *App) EmitStartupInfo(ctx context.Context, events chan runtime.Event)

EmitStartupInfo emits initial agent, team, and toolset information to the provided channel

func (*App) ExecuteMCPPrompt

func (a *App) ExecuteMCPPrompt(ctx context.Context, promptName string, arguments map[string]string) (string, error)

ExecuteMCPPrompt executes an MCP prompt with provided arguments and returns the content

func (*App) ExportHTML

func (a *App) ExportHTML(ctx context.Context, filename string) (string, error)

ExportHTML exports the current session as a standalone HTML file. If filename is empty, a default name based on the session title and timestamp is used.

func (*App) HasPermissions

func (a *App) HasPermissions() bool

HasPermissions returns true if any permissions are configured (team or session level).

func (*App) IsTitleGenerating

func (a *App) IsTitleGenerating() bool

IsTitleGenerating returns true if title generation is currently in progress.

func (*App) NewSession

func (a *App) NewSession()

func (*App) PermissionsInfo

func (a *App) PermissionsInfo() *runtime.PermissionsInfo

PermissionsInfo returns combined permissions info from team and session. Returns nil if no permissions are configured at either level.

func (*App) PlainTextTranscript

func (a *App) PlainTextTranscript() string

func (*App) RegenerateSessionTitle

func (a *App) RegenerateSessionTitle(ctx context.Context) error

RegenerateSessionTitle triggers AI-based title regeneration for the current session. Returns ErrTitleGenerating if a title generation is already in progress.

func (*App) ReplaceSession

func (a *App) ReplaceSession(ctx context.Context, sess *session.Session)

ReplaceSession replaces the current session with the given session. This is used when loading a past session. It also re-emits startup info so the sidebar displays the agent and tool information. If the session has stored model overrides, they are applied to the runtime.

func (*App) ResolveCommand

func (a *App) ResolveCommand(ctx context.Context, userInput string) string

ResolveCommand converts /command to its prompt text

func (*App) ResolveInput

func (a *App) ResolveInput(ctx context.Context, input string) string

ResolveInput resolves the user input by trying skill commands first, then agent commands. Returns the resolved content ready to send to the agent.

func (*App) ResolveSkillCommand

func (a *App) ResolveSkillCommand(input string) (string, error)

ResolveSkillCommand checks if the input matches a skill slash command (e.g. /skill-name args). If matched, it reads the skill content and returns the resolved prompt. Otherwise returns "".

func (*App) Resume

func (a *App) Resume(req runtime.ResumeRequest)

Resume resumes the runtime with the given confirmation request

func (*App) ResumeElicitation

func (a *App) ResumeElicitation(ctx context.Context, action tools.ElicitationAction, content map[string]any) error

ResumeElicitation resumes an elicitation request with the given action and content

func (*App) Run

func (a *App) Run(ctx context.Context, cancel context.CancelFunc, message string, attachments []messages.Attachment)

Run one agent loop

func (*App) RunBangCommand

func (a *App) RunBangCommand(ctx context.Context, command string)

func (*App) RunWithMessage

func (a *App) RunWithMessage(ctx context.Context, cancel context.CancelFunc, msg *session.Message)

RunWithMessage runs the agent loop with a pre-constructed message. This is used for special cases like image attachments.

func (*App) SendFirstMessage

func (a *App) SendFirstMessage() tea.Cmd

func (*App) Session

func (a *App) Session() *session.Session

func (*App) SessionStore

func (a *App) SessionStore() session.Store

SessionStore returns the session store for browsing/loading sessions. Returns nil if no session store is configured.

func (*App) SetCurrentAgentModel

func (a *App) SetCurrentAgentModel(ctx context.Context, modelRef string) error

SetCurrentAgentModel sets the model for the current agent and persists the override in the session. Returns an error if model switching is not supported by the runtime (e.g., remote runtimes). Pass an empty modelRef to clear the override and use the agent's default model.

func (*App) ShouldExitAfterFirstResponse

func (a *App) ShouldExitAfterFirstResponse() bool

ShouldExitAfterFirstResponse returns true if the app is configured to exit after the first assistant response completes.

func (*App) SubscribeWith

func (a *App) SubscribeWith(ctx context.Context, send func(tea.Msg))

SubscribeWith subscribes to app events using a custom send function. This allows callers to wrap or transform messages before sending them to the Bubble Tea program (e.g. to tag events with a session ID for routing).

func (*App) SupportsModelSwitching

func (a *App) SupportsModelSwitching() bool

SupportsModelSwitching returns true if the runtime supports model switching.

func (*App) SwitchAgent

func (a *App) SwitchAgent(agentName string) error

SwitchAgent switches the currently active agent for subsequent user messages

func (*App) TrackCurrentAgentModel

func (a *App) TrackCurrentAgentModel(model string)

TrackCurrentAgentModel updates the tracked model ID for the current agent. This is called when AgentInfoEvent is received from the runtime.

func (*App) UpdateSessionTitle

func (a *App) UpdateSessionTitle(ctx context.Context, title string) error

type Opt

type Opt func(*App)

Opt is an option for creating a new App.

func WithExitAfterFirstResponse

func WithExitAfterFirstResponse() Opt

WithExitAfterFirstResponse configures the app to exit after the first assistant response.

func WithFirstMessage

func WithFirstMessage(msg string) Opt

WithFirstMessage sets the first message to send.

func WithFirstMessageAttachment

func WithFirstMessageAttachment(path string) Opt

WithFirstMessageAttachment sets the attachment path for the first message.

func WithQueuedMessages

func WithQueuedMessages(msgs []string) Opt

WithQueuedMessages sets messages to be queued after the first message is sent. These messages will be delivered to the TUI as SendMsg events, which the chat page will queue and process sequentially after each agent response.

func WithTitleGenerator

func WithTitleGenerator(gen *sessiontitle.Generator) Opt

WithTitleGenerator sets the title generator for local title generation. If not set, title generation will be handled by the runtime (for remote) or skipped.

Directories

Path Synopsis
Package export provides HTML export functionality for docker agent sessions.
Package export provides HTML export functionality for docker agent sessions.

Jump to

Keyboard shortcuts

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