Documentation
¶
Overview ¶
Package desktop implements the BuildMax desktop app (Wails) and is used by cmd/buildmax-desktop.
Index ¶
- func Run(assets fs.FS) error
- type App
- func (a *App) CancelRun(projectID string) error
- func (a *App) ClearProjectSessions(projectID string) ([]string, error)
- func (a *App) CreateProject(name, folderPath string) (*Project, error)
- func (a *App) DeleteProject(id string) error
- func (a *App) DeleteSession(sessionID string) error
- func (a *App) DoLogin(serverURL, email, otp string) (*auth.AuthInfo, error)
- func (a *App) DoLoginWithPassword(serverURL, email, password string) (*auth.AuthInfo, error)
- func (a *App) GetAuthStatus() (*auth.AuthInfo, error)
- func (a *App) GetGitBranch(projectID string) (string, error)
- func (a *App) GetRunStatus(projectID, sessionID string) (RunStatusPayload, error)
- func (a *App) GetSession(sessionID string) (SessionDetail, error)
- func (a *App) GetSlashAgents(projectID string) (SlashAgentsResult, error)
- func (a *App) GetSlashMCP(projectID string) (SlashMCPResult, error)
- func (a *App) GetSlashModels(projectID string) (SlashModelsResult, error)
- func (a *App) GetSlashSkills(projectID string) (SlashSkillsResult, error)
- func (a *App) GetWorkspaceDiff(projectID string) (git.WorkspaceDiff, error)
- func (a *App) ListProjects() ([]Project, error)
- func (a *App) ListSessions() ([]session.SessionItem, error)
- func (a *App) Logout() error
- func (a *App) OpenFolderDialog() (string, error)
- func (a *App) RenameProject(id, newName string) error
- func (a *App) RenameSession(sessionID, title string) error
- func (a *App) RequestOTP(serverURL, email, intent string) error
- func (a *App) RespondApproval(projectID string, approved bool)
- func (a *App) SendMessageStream(projectID, sessionID, prompt string) error
- func (a *App) SetProjectModel(projectID, modelName string) error
- func (a *App) SetSessionPinned(sessionID string, pinned bool) error
- func (a *App) Shutdown(_ context.Context)
- func (a *App) Startup(ctx context.Context)
- type ApprovalRequestPayload
- type DesktopApprovalHandler
- type Project
- type ReplyPayload
- type RunStatusPayload
- type SessionDetail
- type SlashAgentEntry
- type SlashAgentsResult
- type SlashMCPResult
- type SlashMCPServer
- type SlashModelEntry
- type SlashModelsResult
- type SlashSkillEntry
- type SlashSkillsResult
- type StreamErrorPayload
- type ToolEndPayload
- type ToolStartPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App holds desktop application state and implements Wails lifecycle hooks. Each project gets its own AgentApp and ApprovalHandler instance, created lazily on first use.
func (*App) CancelRun ¶
CancelRun cancels the in-flight run for the given project, if any. Cancellation is cooperative: the agent loop returns the partial assistant reply produced so far and emits desktop/stream-done as a normal completion. Calling CancelRun when no run is in flight is a no-op.
func (*App) ClearProjectSessions ¶
func (*App) CreateProject ¶
CreateProject creates a new project with the given name and folder.
func (*App) DeleteProject ¶
DeleteProject removes a project and closes its AgentApp if one was running.
func (*App) DeleteSession ¶
func (*App) DoLogin ¶
DoLogin authenticates with a single-use login code and saves credentials on success. It is the recovery path: claiming a new account, or getting back in after a forgotten password.
func (*App) DoLoginWithPassword ¶
DoLoginWithPassword authenticates with a password and saves credentials on success. This is the everyday path.
func (*App) GetAuthStatus ¶
GetAuthStatus returns the current authentication state for the frontend.
func (*App) GetGitBranch ¶
GetGitBranch returns the current git branch for the given project's folder, or an empty string if the folder is not a git repository.
func (*App) GetRunStatus ¶
func (a *App) GetRunStatus(projectID, sessionID string) (RunStatusPayload, error)
func (*App) GetSession ¶
func (a *App) GetSession(sessionID string) (SessionDetail, error)
GetSession loads one session by ID and returns it for display.
func (*App) GetSlashAgents ¶
func (a *App) GetSlashAgents(projectID string) (SlashAgentsResult, error)
GetSlashAgents returns all agent types (builtin + user-defined) for the project.
func (*App) GetSlashMCP ¶
func (a *App) GetSlashMCP(projectID string) (SlashMCPResult, error)
GetSlashMCP returns the MCP server status for the given project.
func (*App) GetSlashModels ¶
func (a *App) GetSlashModels(projectID string) (SlashModelsResult, error)
GetSlashModels returns configured models and the active model for a project.
func (*App) GetSlashSkills ¶
func (a *App) GetSlashSkills(projectID string) (SlashSkillsResult, error)
GetSlashSkills returns all skills discovered for the given project.
func (*App) GetWorkspaceDiff ¶
func (a *App) GetWorkspaceDiff(projectID string) (git.WorkspaceDiff, error)
GetWorkspaceDiff returns the current git-backed changed-file view for a project.
func (*App) ListProjects ¶
ListProjects returns all saved projects.
func (*App) ListSessions ¶
func (a *App) ListSessions() ([]session.SessionItem, error)
ListSessions returns all sessions across all projects.
func (*App) Logout ¶
Logout clears stored credentials and revokes the session on the server.
A server that cannot be reached is not a failed logout: the credentials are gone from this machine either way, and returning an error would leave the UI showing someone as signed in when they are not.
func (*App) OpenFolderDialog ¶
OpenFolderDialog opens a native directory picker and returns the selected path.
func (*App) RenameProject ¶
RenameProject updates the name of a project.
func (*App) RenameSession ¶
func (*App) RequestOTP ¶
RequestOTP calls the server's OTP endpoint.
func (*App) RespondApproval ¶
RespondApproval is called by the frontend when the user approves or denies a tool call. projectID must match the project that triggered the desktop/approval-request event.
func (*App) SendMessageStream ¶
SendMessageStream runs a prompt in the given project and session with streaming. It returns immediately and emits desktop/stream-delta, then desktop/stream-done or desktop/stream-error. sessionID may be empty to start a new session.
At most one run per project may be in flight; a second call while a run is active returns an error so the frontend can surface it.
func (*App) SetProjectModel ¶
SetProjectModel switches the active model for a project's agent.
type ApprovalRequestPayload ¶
type ApprovalRequestPayload struct {
ProjectID string `json:"project_id"`
ToolName string `json:"tool_name"`
Args map[string]any `json:"args"`
}
ApprovalRequestPayload is emitted to the frontend when a tool call needs approval.
type DesktopApprovalHandler ¶
type DesktopApprovalHandler struct {
// contains filtered or unexported fields
}
DesktopApprovalHandler implements agent.ApprovalHandler for the Wails desktop app. It emits a Wails event to the frontend and blocks until RespondApproval is called.
func (*DesktopApprovalHandler) RequestApproval ¶
func (h *DesktopApprovalHandler) RequestApproval(name string, args map[string]any) bool
RequestApproval emits an approval-request event to the frontend and blocks until the user responds via RespondApproval. Returns false if the app context is not ready.
type Project ¶
type Project struct {
ID string `json:"id"`
Name string `json:"name"`
FolderPath string `json:"folder_path"`
CreatedAt string `json:"created_at"`
LastUsedAt string `json:"last_used_at"`
}
Project is a named local folder that groups desktop sessions.
type ReplyPayload ¶
type ReplyPayload struct {
Reply string `json:"reply"`
SessionID string `json:"session_id"`
ContextTokens int `json:"context_tokens"`
ContextWindow int `json:"context_window"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalPromptTokens int `json:"total_prompt_tokens"`
TotalCompletionTokens int `json:"total_completion_tokens"`
}
ReplyPayload is returned when a desktop prompt completes successfully.
type RunStatusPayload ¶
type RunStatusPayload struct {
ContextTokens int `json:"context_tokens"`
ContextWindow int `json:"context_window"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalPromptTokens int `json:"total_prompt_tokens"`
TotalCompletionTokens int `json:"total_completion_tokens"`
}
type SessionDetail ¶
type SessionDetail struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
CreatedAt string `json:"created_at"`
Messages []llm.Message `json:"messages,omitempty"`
}
SessionDetail is the session payload returned to the frontend for display.
type SlashAgentEntry ¶
type SlashAgentsResult ¶
type SlashAgentsResult struct {
Agents []SlashAgentEntry `json:"agents"`
}
type SlashMCPResult ¶
type SlashMCPResult struct {
LoadError string `json:"load_error,omitempty"`
Servers []SlashMCPServer `json:"servers"`
}
type SlashMCPServer ¶
type SlashModelEntry ¶
type SlashModelEntry struct {
Name string `json:"name"`
ProviderModel string `json:"provider_model,omitempty"`
IsCurrent bool `json:"is_current"`
// Managed and Destination say where this model sends prompts. Two entries
// can share a display name and reach different places, so the selector has
// to be able to tell them apart.
Managed bool `json:"managed"`
Destination string `json:"destination,omitempty"`
}
type SlashModelsResult ¶
type SlashModelsResult struct {
Current string `json:"current"`
Models []SlashModelEntry `json:"models"`
}
type SlashSkillEntry ¶
type SlashSkillsResult ¶
type SlashSkillsResult struct {
Skills []SlashSkillEntry `json:"skills"`
}
type StreamErrorPayload ¶
type StreamErrorPayload struct {
Message string `json:"message"`
}
StreamErrorPayload is emitted when streaming fails (event desktop/stream-error).
type ToolEndPayload ¶
type ToolEndPayload struct {
ToolCallID string `json:"tool_call_id"`
ToolName string `json:"tool_name"`
DurationMs int64 `json:"duration_ms,omitempty"`
IsError bool `json:"is_error,omitempty"`
Denied bool `json:"denied,omitempty"`
Reason string `json:"reason,omitempty"`
}
ToolEndPayload is emitted when a tool call finishes or is denied.
type ToolStartPayload ¶
type ToolStartPayload struct {
ToolCallID string `json:"tool_call_id"`
ToolName string `json:"tool_name"`
Args string `json:"args"`
}
ToolStartPayload is emitted when a tool call begins executing.