Documentation
¶
Overview ¶
Package appsession is the UI-neutral controller behind the Golder desktop app. It owns one conversation at a time: the session file, the live run configuration, the agent loop, the approval channel and the transcript the view renders.
Nothing in this package imports a GUI toolkit. The MyGo view under gui/mygoui consumes the Controller through Snapshot, Commands and Events, which keeps the orchestration testable without a window and lets the CLI/TUI keep their own front-ends unchanged.
Index ¶
- Constants
- Variables
- func ModelForProvider(providerName string) string
- func ParseDiffStat(patch string) (files, added, deleted int)
- func PermissionModes() []string
- func SaveDisplaySettings(settings DisplaySettings) error
- func ThinkingLevels() []string
- type Action
- type ActionResult
- type Answer
- type ApprovalView
- type BrowserInput
- type BrowserInputKind
- type BrowserPreview
- type BrowserSurface
- func (s *BrowserSurface) ActivateTab(ctx context.Context, id string) error
- func (s *BrowserSurface) Back(ctx context.Context) error
- func (s *BrowserSurface) Close()
- func (s *BrowserSurface) CloseTab(ctx context.Context, id string) error
- func (s *BrowserSurface) Forward(ctx context.Context) error
- func (s *BrowserSurface) Frame(ctx context.Context) ([]byte, error)
- func (s *BrowserSurface) Input(event BrowserInput) bool
- func (s *BrowserSurface) Navigate(ctx context.Context, rawURL string) error
- func (s *BrowserSurface) NewTab(ctx context.Context, rawURL string) error
- func (s *BrowserSurface) Reload(ctx context.Context) error
- func (s *BrowserSurface) Resize(ctx context.Context, width, height int) error
- func (s *BrowserSurface) State() (title, rawURL string, err error)
- func (s *BrowserSurface) Tabs(ctx context.Context) ([]BrowserTab, error)
- type BrowserTab
- type ChangeView
- type Changes
- type Controller
- func (c *Controller) AddProject(path string) (ProjectFolder, error)
- func (c *Controller) ArchiveSession(ctx context.Context, id string, archived bool) error
- func (c *Controller) AttachComputer(expectedSessionID string, s *computeruse.Session) error
- func (c *Controller) AttachTTY(id string) (io.ReadWriteCloser, error)
- func (c *Controller) AuthorizeLark(ctx context.Context, service string, show func(ExtensionSetupEvent)) error
- func (c *Controller) BrowserScreenshot(ctx context.Context, socket string, fullPage bool) ([]byte, error)
- func (c *Controller) Browsers(ctx context.Context) []BrowserPreview
- func (c *Controller) Cancel()
- func (c *Controller) ChangedFiles(ctx context.Context) ([]FileStatus, error)
- func (c *Controller) Changes(ctx context.Context) (Changes, error)
- func (c *Controller) ChangesFor(ctx context.Context, view ChangeView) (Changes, error)
- func (c *Controller) Close() error
- func (c *Controller) Compact(ctx context.Context) (string, error)
- func (c *Controller) ConfigureLark(ctx context.Context, edit LarkExtensionEdit) error
- func (c *Controller) ContinueComputer(ctx context.Context, sessionID string, desktop *computeruse.Session) error
- func (c *Controller) DeleteSession(ctx context.Context, id string) error
- func (c *Controller) DetachComputer(expected *computeruse.Session)
- func (c *Controller) DetectLarkCLIs(preferredLark, preferredProject string) (larkCLI, projectCLI string, larkFound, projectFound bool)
- func (c *Controller) DisableLark() error
- func (c *Controller) DiscoverLarkCLIs(preferredLark, preferredProject string) (larkCLI, projectCLI string)
- func (c *Controller) EnableLark() error
- func (c *Controller) Events() <-chan Event
- func (c *Controller) Export(format, path string) error
- func (c *Controller) ExportSession(id, format, path string) error
- func (c *Controller) ExtensionSettings() (LarkExtensionSettings, error)
- func (c *Controller) ExtensionSources() []ExtensionSourceView
- func (c *Controller) FileDiff(ctx context.Context, view ChangeView, path string) (FileDiff, error)
- func (c *Controller) InstallLarkPackage(ctx context.Context, source, checksum, version string) error
- func (c *Controller) InstallOfficialLarkCLI(ctx context.Context, project bool) (string, error)
- func (c *Controller) InterruptTTY(id string) error
- func (c *Controller) IsRunning() bool
- func (c *Controller) ListActions(ctx context.Context) []Action
- func (c *Controller) ListModels(ctx context.Context) ([]ModelOption, error)
- func (c *Controller) ListProjectFiles(relative string) ([]ProjectFileEntry, error)
- func (c *Controller) ListProjectFilesWithHidden(relative string, showHidden bool) ([]ProjectFileEntry, error)
- func (c *Controller) ListProjects() ([]ProjectFolder, string, error)
- func (c *Controller) ListSessions(ctx context.Context) ([]SessionSummary, error)
- func (c *Controller) LoadProviderSettings() (ProviderSettings, error)
- func (c *Controller) NewSession(ctx context.Context) error
- func (c *Controller) NewSessionInProject(ctx context.Context, path string) error
- func (c *Controller) Open(ctx context.Context) error
- func (c *Controller) PendingApprovals() []ApprovalView
- func (c *Controller) Project() string
- func (c *Controller) Providers() []string
- func (c *Controller) ReadProjectFile(relative string) (ProjectFilePreview, error)
- func (c *Controller) RemoveProject(path string) error
- func (c *Controller) RenameSession(ctx context.Context, id, title string) error
- func (c *Controller) ResetComputerRequest()
- func (c *Controller) ResetLark() error
- func (c *Controller) RespondApproval(id string, a Answer) error
- func (c *Controller) Resume(ctx context.Context, id string) error
- func (c *Controller) RunAction(ctx context.Context, id, args string) (ActionResult, error)
- func (c *Controller) SaveProjectFile(expectedProject, relative, expectedDigest, text string) (string, error)
- func (c *Controller) SaveProviderSettings(ctx context.Context, edit ProviderSettingsEdit, apply bool) (ProviderSettings, error)
- func (c *Controller) SelectModel(ctx context.Context, providerName, model string, ...) error
- func (c *Controller) SelectProject(path string) error
- func (c *Controller) SessionID() string
- func (c *Controller) SetAllStaged(ctx context.Context, staged bool) error
- func (c *Controller) SetExtensionEnabled(kind, id string, enabled bool) error
- func (c *Controller) SetFileStaged(ctx context.Context, path string, staged bool) error
- func (c *Controller) SetPermissionMode(ctx context.Context, name string) error
- func (c *Controller) SetThinking(level agentcore.ThinkingLevel) error
- func (c *Controller) Snapshot() Snapshot
- func (c *Controller) StopComputer()
- func (c *Controller) Submit(ctx context.Context, text string) error
- func (c *Controller) SubmitAttachments(ctx context.Context, text string, attachments []UserAttachment) error
- func (c *Controller) TTYSessions() []TTYSummary
- func (c *Controller) TestExtension(ctx context.Context, kind, id string) error
- func (c *Controller) TestLark(ctx context.Context) error
- func (c *Controller) TestProviderSettings(ctx context.Context, edit ProviderSettingsEdit) error
- func (c *Controller) UninstallLark() error
- func (c *Controller) UpdateLarkPackage(ctx context.Context, source, checksum, version string) error
- func (c *Controller) Version() string
- type CredentialView
- type DisplaySettings
- type Event
- type EventKind
- type ExtensionPackageView
- type ExtensionSetupEvent
- type ExtensionSourceView
- type FileDiff
- type FileStatus
- type Item
- type ItemKind
- type LarkExtensionEdit
- type LarkExtensionSettings
- type ModelOption
- type NoteState
- type Options
- type ProjectEnvironmentFactory
- type ProjectFileEntry
- type ProjectFilePreview
- type ProjectFolder
- type ProjectSetup
- type ProviderSettings
- type ProviderSettingsEdit
- type SessionSummary
- type SessionWriterView
- type Snapshot
- type Status
- type TTYSummary
- type ToolState
- type UserAttachment
Constants ¶
const ( ActionNewSession = "gui:new-session" ActionCompact = "gui:compact" ActionCopyLast = "gui:copy-last" )
GUI-only action IDs. They are not slash commands: they exist because a window can do something a terminal cannot.
Variables ¶
var ErrBusy = errors.New("a turn is already running")
ErrBusy is returned by commands that cannot run while an agent turn is in flight.
var ErrClosed = errors.New("controller is closed")
ErrClosed is returned once Close has been called.
var ErrNotPending = errors.New("approval is no longer pending")
ErrNotPending is returned when an approval id is unknown: it was answered already, withdrawn when the run ended, or never issued.
var ErrReadOnly = errors.New("session is open read-only in this process")
ErrReadOnly is returned when a second frontend views a session whose writer lease is held by another live process.
Functions ¶
func ModelForProvider ¶
ModelForProvider returns the model a switch to providerName would start with.
func ParseDiffStat ¶
ParseDiffStat reads the summary line git prints after a diff, if present.
func PermissionModes ¶
func PermissionModes() []string
PermissionModes lists the selectable modes in display order.
func SaveDisplaySettings ¶ added in v1.5.57
func SaveDisplaySettings(settings DisplaySettings) error
func ThinkingLevels ¶
func ThinkingLevels() []string
ThinkingLevels lists the selectable reasoning levels.
Types ¶
type Action ¶
type Action struct {
ID string
Label string
Category string
Description string
ArgumentHint string
Source string
}
Action is one runnable command surfaced by the command palette: a slash command, a GUI action, or a skill.
type ActionResult ¶
type ActionResult struct {
// Message is text to show in the transcript.
Message string
// Prompt, when non-empty, is a turn to run after Message.
Prompt string
}
ActionResult is what running an action produced.
type ApprovalView ¶
type ApprovalView struct {
ID string
// Kind is "consent" or "trust".
Kind string
Tool string
// Summary is the call's one-line preview.
Summary string
// Rationale is the reviewer's explanation, already in the user's language.
Rationale string
// Source names the deciding layer (jev, local, llm, static).
Source string
// Level is the gate's grade (allow, confirm, contain, deny).
Level string
// Mode is the approval mode in force.
Mode string
// Needs lists the capabilities the call requires.
Needs []string
// TrustDir names the folder a trust question is about.
TrustDir string
// Origin names a sub-agent that asked, when it is not this conversation.
Origin string
}
ApprovalView is one pending human decision. The controller owns the reply channel; the view only renders Require and answers with an Answer.
type BrowserInput ¶ added in v1.5.49
type BrowserInput struct {
Kind BrowserInputKind
X, Y float64
DX, DY float64
Button int
Clicks int
Text, Key string
}
BrowserInput carries viewport CSS coordinates. Text is committed IME input; Key is a non-printing browser key such as Enter or ArrowLeft.
type BrowserInputKind ¶ added in v1.5.49
type BrowserInputKind uint8
BrowserInputKind is one person-originated event for a native browser surface.
const ( BrowserPointerDown BrowserInputKind = iota + 1 BrowserPointerUp BrowserPointerMove BrowserScroll BrowserText BrowserKey )
type BrowserPreview ¶
type BrowserPreview struct {
Socket string
Browser string
TabID string
TargetID string
URL string
Title string
}
BrowserPreview is one live browser page the GUI can show.
type BrowserSurface ¶ added in v1.5.49
type BrowserSurface struct {
// contains filtered or unexported fields
}
BrowserSurface is a terminal-independent view of one controlled Chromium tab. Frames come from the existing screenshot endpoint; input is serialized onto the same typed action socket. kitty-browse remains the CDP owner.
func OpenBrowserSurface ¶ added in v1.5.49
func OpenBrowserSurface(ctx context.Context, preview BrowserPreview) (*BrowserSurface, error)
OpenBrowserSurface attaches to a browser already admitted by the owner-only socket and starts its serialized manual-input worker.
func (*BrowserSurface) ActivateTab ¶ added in v1.5.49
func (s *BrowserSurface) ActivateTab(ctx context.Context, id string) error
ActivateTab switches the native surface to an existing tab.
func (*BrowserSurface) Back ¶ added in v1.5.49
func (s *BrowserSurface) Back(ctx context.Context) error
Back, Forward and Reload expose native browser chrome actions.
func (*BrowserSurface) Close ¶ added in v1.5.49
func (s *BrowserSurface) Close()
func (*BrowserSurface) CloseTab ¶ added in v1.5.49
func (s *BrowserSurface) CloseTab(ctx context.Context, id string) error
CloseTab closes one tab; kitty-browse chooses the next active tab.
func (*BrowserSurface) Forward ¶ added in v1.5.49
func (s *BrowserSurface) Forward(ctx context.Context) error
func (*BrowserSurface) Frame ¶ added in v1.5.49
func (s *BrowserSurface) Frame(ctx context.Context) ([]byte, error)
Frame captures the current viewport as PNG. The endpoint already bounds the response and uses kitty-browse's idle/still recovery path.
func (*BrowserSurface) Input ¶ added in v1.5.49
func (s *BrowserSurface) Input(event BrowserInput) bool
Input queues a person-originated event without blocking MyGo's main thread. Under sustained control-socket pressure a new event is consumed but dropped; the UI must stay responsive even when Chromium is hung.
func (*BrowserSurface) Navigate ¶ added in v1.5.49
func (s *BrowserSurface) Navigate(ctx context.Context, rawURL string) error
Navigate loads a URL through kitty-browse's validated action path.
func (*BrowserSurface) NewTab ¶ added in v1.5.49
func (s *BrowserSurface) NewTab(ctx context.Context, rawURL string) error
NewTab opens and activates a new tab.
func (*BrowserSurface) Reload ¶ added in v1.5.49
func (s *BrowserSurface) Reload(ctx context.Context) error
func (*BrowserSurface) Resize ¶ added in v1.5.49
func (s *BrowserSurface) Resize(ctx context.Context, width, height int) error
Resize changes the active Chromium viewport. Dimensions are CSS pixels.
func (*BrowserSurface) State ¶ added in v1.5.49
func (s *BrowserSurface) State() (title, rawURL string, err error)
State returns display metadata and the last input error, without exposing the control socket or any page content.
func (*BrowserSurface) Tabs ¶ added in v1.5.49
func (s *BrowserSurface) Tabs(ctx context.Context) ([]BrowserTab, error)
Tabs refreshes the browser's tab strip metadata.
type BrowserTab ¶ added in v1.5.49
BrowserTab is safe native chrome metadata for one controlled tab.
type ChangeView ¶ added in v1.5.50
type ChangeView string
ChangeView selects which side of Git's index the review pane displays.
const ( ChangesUnstaged ChangeView = "unstaged" ChangesStaged ChangeView = "staged" )
type Changes ¶
type Changes struct {
Files []FileStatus
View ChangeView
Project string
RepoRoot string
Branch string
TotalFiles int
Added int
Deleted int
Truncated bool
NotGitRepo bool
}
Changes is the project's uncommitted work, for the changes drawer.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller owns one conversation and the run in flight, if any.
func New ¶
func New(opts Options) *Controller
New creates a controller. Open must be called before any other command.
func (*Controller) AddProject ¶ added in v1.5.50
func (c *Controller) AddProject(path string) (ProjectFolder, error)
AddProject validates and canonically records one operator-selected directory. It does not start an Agent or create a Session.
func (*Controller) ArchiveSession ¶ added in v1.5.49
ArchiveSession hides or restores a non-current session.
func (*Controller) AttachComputer ¶ added in v1.5.57
func (c *Controller) AttachComputer(expectedSessionID string, s *computeruse.Session) error
AttachComputer is an operator-facing entry point. The session must already have an explicitly selected target and grants; no model-provided identifier can call this method. It only changes the model tool set while idle.
func (*Controller) AttachTTY ¶ added in v1.5.49
func (c *Controller) AttachTTY(id string) (io.ReadWriteCloser, error)
AttachTTY returns a detachable connection to one existing Agent bash PTY. Closing it never kills the process; the bash/write_stdin lifecycle remains authoritative.
func (*Controller) AuthorizeLark ¶ added in v1.5.49
func (c *Controller) AuthorizeLark(ctx context.Context, service string, show func(ExtensionSetupEvent)) error
AuthorizeLark runs the reviewed setup command and forwards only sanitized events. service is "lark" or the declared "project" variant.
func (*Controller) BrowserScreenshot ¶
func (c *Controller) BrowserScreenshot(ctx context.Context, socket string, fullPage bool) ([]byte, error)
BrowserScreenshot returns the active tab's viewport as PNG. The caller draws it; nothing here needs a terminal graphics protocol.
func (*Controller) Browsers ¶
func (c *Controller) Browsers(ctx context.Context) []BrowserPreview
Browsers discovers Golder browser control sockets under the project. It is independent of tuios workspace discovery: a native GUI browser talks to the browser owner directly.
func (*Controller) Cancel ¶
func (c *Controller) Cancel()
Cancel interrupts the run in flight. It is a no-op when nothing runs.
func (*Controller) ChangedFiles ¶
func (c *Controller) ChangedFiles(ctx context.Context) ([]FileStatus, error)
ChangedFiles returns just the file list, for a cheap status refresh.
func (*Controller) Changes ¶
func (c *Controller) Changes(ctx context.Context) (Changes, error)
Changes returns the project's unstaged status list. File patches are loaded separately through FileDiff so opening the drawer never builds every diff. A directory that is not a Git repository reports so instead of an error, because the drawer is always available.
func (*Controller) ChangesFor ¶ added in v1.5.50
func (c *Controller) ChangesFor(ctx context.Context, view ChangeView) (Changes, error)
ChangesFor returns either working-tree (unstaged) or index (staged) changes. Keeping those views separate mirrors Git and prevents a combined HEAD diff from making a file look accepted when it still has unstaged edits.
func (*Controller) Close ¶
func (c *Controller) Close() error
Close ends the controller: a run in flight is cancelled and every pending approval is answered as unanswered, which the gates treat as fail-closed.
func (*Controller) Compact ¶
func (c *Controller) Compact(ctx context.Context) (string, error)
Compact replaces the context with a fresh summary plus the recent tail.
func (*Controller) ConfigureLark ¶ added in v1.5.49
func (c *Controller) ConfigureLark(ctx context.Context, edit LarkExtensionEdit) error
ConfigureLark stores a new App Secret by name, writes a disabled source, then updates the live manager without granting trust or starting code.
func (*Controller) ContinueComputer ¶ added in v1.5.57
func (c *Controller) ContinueComputer(ctx context.Context, sessionID string, desktop *computeruse.Session) error
ContinueComputer resumes the original request only if the same conversation and operator-authorized desktop session are still current.
func (*Controller) DeleteSession ¶ added in v1.5.49
func (c *Controller) DeleteSession(ctx context.Context, id string) error
DeleteSession permanently removes a non-current session.
func (*Controller) DetachComputer ¶ added in v1.5.57
func (c *Controller) DetachComputer(expected *computeruse.Session)
DetachComputer revokes only the specified session; nil means the current one. This prevents a delayed UI callback from stopping a newer session.
func (*Controller) DetectLarkCLIs ¶ added in v1.5.57
func (c *Controller) DetectLarkCLIs(preferredLark, preferredProject string) (larkCLI, projectCLI string, larkFound, projectFound bool)
DetectLarkCLIs is DiscoverLarkCLIs with explicit match flags for UI feedback. A configured but invalid preferred path is preserved, but is not reported as detected.
func (*Controller) DisableLark ¶ added in v1.5.49
func (c *Controller) DisableLark() error
func (*Controller) DiscoverLarkCLIs ¶ added in v1.5.57
func (c *Controller) DiscoverLarkCLIs(preferredLark, preferredProject string) (larkCLI, projectCLI string)
DiscoverLarkCLIs performs bounded local discovery only. Script/npm wrappers are ignored; returned paths are resolved native executables.
func (*Controller) EnableLark ¶ added in v1.5.49
func (c *Controller) EnableLark() error
EnableLark is the explicit review boundary. It fingerprints the helper and official CLI dependencies, remembers approval, persists enabled=true and only then admits the source to the current session.
func (*Controller) Events ¶
func (c *Controller) Events() <-chan Event
Events returns the ordered event stream. The channel is never closed; Close ends delivery and unblocks the producer.
func (*Controller) Export ¶
func (c *Controller) Export(format, path string) error
Export writes the session as JSONL or Markdown.
func (*Controller) ExportSession ¶ added in v1.5.49
func (c *Controller) ExportSession(id, format, path string) error
ExportSession writes any stored session as JSONL or Markdown.
func (*Controller) ExtensionSettings ¶ added in v1.5.49
func (c *Controller) ExtensionSettings() (LarkExtensionSettings, error)
ExtensionSettings returns package and live source state without starting an extension process.
func (*Controller) ExtensionSources ¶ added in v1.5.49
func (c *Controller) ExtensionSources() []ExtensionSourceView
ExtensionSources lists every configured source without executing it.
func (*Controller) FileDiff ¶ added in v1.5.50
func (c *Controller) FileDiff(ctx context.Context, view ChangeView, path string) (FileDiff, error)
FileDiff lazily loads one file only. It never builds a repository-wide patch, and the subprocess writer discards bytes beyond maxPatchBytes.
func (*Controller) InstallLarkPackage ¶ added in v1.5.49
func (c *Controller) InstallLarkPackage(ctx context.Context, source, checksum, version string) error
InstallLarkPackage explicitly installs the signed GUI helper. It configures or executes nothing.
func (*Controller) InstallOfficialLarkCLI ¶ added in v1.5.57
InstallOfficialLarkCLI downloads one pinned official native distribution, verifies its release integrity and installs it without npm or Node.
func (*Controller) InterruptTTY ¶ added in v1.5.49
func (c *Controller) InterruptTTY(id string) error
InterruptTTY sends the same first/second interrupt sequence write_stdin uses.
func (*Controller) IsRunning ¶
func (c *Controller) IsRunning() bool
IsRunning reports whether a turn is in flight.
func (*Controller) ListActions ¶
func (c *Controller) ListActions(ctx context.Context) []Action
ListActions returns every action the command palette can run: the session's slash commands plus the window-only actions.
func (*Controller) ListModels ¶
func (c *Controller) ListModels(ctx context.Context) ([]ModelOption, error)
ListModels returns the models the live provider serves, newest families first. A failed catalog fetch falls back to the bundled floor for the provider, never to an empty picker.
func (*Controller) ListProjectFiles ¶ added in v1.5.57
func (c *Controller) ListProjectFiles(relative string) ([]ProjectFileEntry, error)
ListProjectFiles lists a directory without following symlinks or dotfiles.
func (*Controller) ListProjectFilesWithHidden ¶ added in v1.5.58
func (c *Controller) ListProjectFilesWithHidden(relative string, showHidden bool) ([]ProjectFileEntry, error)
ListProjectFilesWithHidden optionally includes dotfiles, still excluding large generated non-dot directories and never following symbolic links.
func (*Controller) ListProjects ¶ added in v1.5.50
func (c *Controller) ListProjects() ([]ProjectFolder, string, error)
ListProjects returns the explicit desktop project list, most recently opened first. It never derives rows from historical session Cwd values.
func (*Controller) ListSessions ¶
func (c *Controller) ListSessions(ctx context.Context) ([]SessionSummary, error)
ListSessions returns the stored sessions, newest first, marking the current.
func (*Controller) LoadProviderSettings ¶ added in v1.5.49
func (c *Controller) LoadProviderSettings() (ProviderSettings, error)
LoadProviderSettings reads the shared config and derives a non-secret credential status. When the file omits a value, the current live session is a useful form default but is not written until Save is clicked.
func (*Controller) NewSession ¶
func (c *Controller) NewSession(ctx context.Context) error
NewSession starts a fresh conversation in the same project.
func (*Controller) NewSessionInProject ¶ added in v1.5.50
func (c *Controller) NewSessionInProject(ctx context.Context, path string) error
NewSessionInProject starts a fresh conversation rooted at the explicitly selected desktop project, rebuilding every cwd-bound runtime component when the folder differs from the active Session.
func (*Controller) Open ¶
func (c *Controller) Open(ctx context.Context) error
Open resolves the session (resume or fresh), assembles the live configuration and wires the slash commands and hooks. It is idempotent only in the sense that a second call reports an error instead of replacing a live session.
func (*Controller) PendingApprovals ¶
func (c *Controller) PendingApprovals() []ApprovalView
PendingApprovals returns the approvals waiting for an answer.
func (*Controller) Project ¶
func (c *Controller) Project() string
Project returns the project directory.
func (*Controller) Providers ¶
func (c *Controller) Providers() []string
Providers lists the conversation providers, ready ones first.
func (*Controller) ReadProjectFile ¶ added in v1.5.57
func (c *Controller) ReadProjectFile(relative string) (ProjectFilePreview, error)
ReadProjectFile returns a bounded UTF-8 preview. Binary files are identified without rendering their bytes; symlinks and paths outside the project fail.
func (*Controller) RemoveProject ¶ added in v1.5.50
func (c *Controller) RemoveProject(path string) error
RemoveProject removes one sidebar row only. Session files and project files are untouched.
func (*Controller) RenameSession ¶ added in v1.5.49
func (c *Controller) RenameSession(ctx context.Context, id, title string) error
RenameSession writes a display-name override. Renaming the active in-memory session works before its first message creates a file; the name is persisted with that first turn.
func (*Controller) ResetComputerRequest ¶ added in v1.5.57
func (c *Controller) ResetComputerRequest()
func (*Controller) ResetLark ¶ added in v1.5.49
func (c *Controller) ResetLark() error
func (*Controller) RespondApproval ¶
func (c *Controller) RespondApproval(id string, a Answer) error
RespondApproval answers one pending approval.
func (*Controller) Resume ¶
func (c *Controller) Resume(ctx context.Context, id string) error
Resume switches to a stored session after saving the current one.
func (*Controller) RunAction ¶
func (c *Controller) RunAction(ctx context.Context, id, args string) (ActionResult, error)
RunAction runs one action by ID. A prompt-producing command is submitted as the next turn; an action command's status line is returned as Message.
func (*Controller) SaveProjectFile ¶ added in v1.5.58
func (c *Controller) SaveProjectFile(expectedProject, relative, expectedDigest, text string) (string, error)
SaveProjectFile is a direct operator action, not an agent tool call. It uses normal OS permissions and refuses to overwrite a file changed since preview. The opened root confines path resolution even if a directory is replaced.
func (*Controller) SaveProviderSettings ¶ added in v1.5.49
func (c *Controller) SaveProviderSettings(ctx context.Context, edit ProviderSettingsEdit, apply bool) (ProviderSettings, error)
SaveProviderSettings writes a named credential first, then atomically updates config.toml to reference it. A failed credential write therefore never leaves a config reference to a value that was not saved.
func (*Controller) SelectModel ¶
func (c *Controller) SelectModel(ctx context.Context, providerName, model string, thinking agentcore.ThinkingLevel) error
SelectModel switches the live model (and provider, when the id belongs to another gateway).
func (*Controller) SelectProject ¶ added in v1.5.50
func (c *Controller) SelectProject(path string) error
SelectProject changes the sidebar/new-session target without mutating the currently open conversation.
func (*Controller) SessionID ¶
func (c *Controller) SessionID() string
SessionID returns the active session id.
func (*Controller) SetAllStaged ¶ added in v1.5.50
func (c *Controller) SetAllStaged(ctx context.Context, staged bool) error
SetAllStaged stages or unstages every path in the active repository without modifying working-tree contents.
func (*Controller) SetExtensionEnabled ¶ added in v1.5.49
func (c *Controller) SetExtensionEnabled(kind, id string, enabled bool) error
SetExtensionEnabled is the generic explicit enable/disable action for an already-configured source. Enabling fingerprints and remembers approval.
func (*Controller) SetFileStaged ¶ added in v1.5.50
SetFileStaged stages or unstages one status path from the active repository.
func (*Controller) SetPermissionMode ¶
func (c *Controller) SetPermissionMode(ctx context.Context, name string) error
SetPermissionMode switches the live approval mode.
func (*Controller) SetThinking ¶
func (c *Controller) SetThinking(level agentcore.ThinkingLevel) error
SetThinking changes the reasoning level for the next turn.
func (*Controller) Snapshot ¶
func (c *Controller) Snapshot() Snapshot
Snapshot returns the complete current state.
func (*Controller) StopComputer ¶ added in v1.5.57
func (c *Controller) StopComputer()
StopComputer revokes desktop access immediately, even during a turn. The tool is removed from future provider requests once the run is idle.
func (*Controller) Submit ¶
func (c *Controller) Submit(ctx context.Context, text string) error
Submit sends one prompt as a new turn.
func (*Controller) SubmitAttachments ¶ added in v1.5.50
func (c *Controller) SubmitAttachments(ctx context.Context, text string, attachments []UserAttachment) error
SubmitAttachments sends one prompt plus operator-selected local files.
func (*Controller) TTYSessions ¶ added in v1.5.49
func (c *Controller) TTYSessions() []TTYSummary
TTYSessions lists the interactive bash sessions backing the current tool set. Pipe-only commands are intentionally absent.
func (*Controller) TestExtension ¶ added in v1.5.49
func (c *Controller) TestExtension(ctx context.Context, kind, id string) error
func (*Controller) TestLark ¶ added in v1.5.49
func (c *Controller) TestLark(ctx context.Context) error
func (*Controller) TestProviderSettings ¶ added in v1.5.49
func (c *Controller) TestProviderSettings(ctx context.Context, edit ProviderSettingsEdit) error
TestProviderSettings resolves the same provider and credential a save would use, then asks its catalog endpoint for a model list. It is the only settings action that performs network I/O.
func (*Controller) UninstallLark ¶ added in v1.5.49
func (c *Controller) UninstallLark() error
UninstallLark removes source configuration and the managed helper, but keeps server-side consent and named App Secret. Reset and credential removal are separate explicit destructive operations.
func (*Controller) UpdateLarkPackage ¶ added in v1.5.55
func (c *Controller) UpdateLarkPackage(ctx context.Context, source, checksum, version string) error
UpdateLarkPackage installs the verified bundled helper and rebuilds the existing Source around that exact package. Existing non-secret settings, named credential references and source-scoped login HOME are preserved; the replacement Source is disabled and must be explicitly approved again.
func (*Controller) Version ¶ added in v1.5.49
func (c *Controller) Version() string
Version returns the desktop/core build version supplied by the command.
type CredentialView ¶ added in v1.5.49
CredentialView is safe settings metadata. It never contains the credential.
type DisplaySettings ¶ added in v1.5.57
type DisplaySettings struct {
Version int `json:"version"`
Theme string `json:"theme"`
FontScale float32 `json:"font_scale"`
}
func DefaultDisplaySettings ¶ added in v1.5.57
func DefaultDisplaySettings() DisplaySettings
func LoadDisplaySettings ¶ added in v1.5.57
func LoadDisplaySettings() (DisplaySettings, error)
type Event ¶
type Event struct {
Seq uint64
Session string
Kind EventKind
Item *Item
ID string
Approval *ApprovalView
Status *Status
Error string
}
Event is one ordered controller notification. Seq increases monotonically for the controller's lifetime, so a view can detect a missed event and re-read Snapshot.
type EventKind ¶
type EventKind string
EventKind classifies a controller event.
const ( // EventItemAddressed means Item was appended. EventItemAdded EventKind = "item_added" // EventItemUpdated means the item of Item.ID changed. EventItemUpdated EventKind = "item_updated" // EventApproval means a new approval is pending. EventApproval EventKind = "approval_requested" // EventApprovalDone means the approval of ID was answered or withdrawn. EventApprovalDone EventKind = "approval_resolved" // EventStatus means the live configuration or run state changed. EventStatus EventKind = "status" // EventRunEnd means the run ended; Error carries a failure. EventRunEnd EventKind = "run_end" // EventComputerRequest asks the local view to offer an operator-owned picker. EventComputerRequest EventKind = "computer_request" )
type ExtensionPackageView ¶ added in v1.5.49
type ExtensionPackageView struct {
ID string
Name string
Description string
Installed bool
Configured bool
Enabled bool
Trusted bool
Version string
BundledVersion string
InstalledVersion string
ActiveVersion string
ActiveManaged bool
UpdateAvailable bool
State string
Authentication string
LastError string
}
ExtensionPackageView is the compact package/source state the native Settings page renders. It contains no environment values, credentials or setup URLs.
type ExtensionSetupEvent ¶ added in v1.5.49
type ExtensionSetupEvent struct {
Type string
Service string
Message string
VerificationURL string
UserCode string
Authenticated bool
Phase string
Code string
Retryable bool
}
ExtensionSetupEvent is the already-sanitized operator event the GUI may show.
type ExtensionSourceView ¶ added in v1.5.49
type ExtensionSourceView struct {
Kind string
ID string
Type string
Enabled bool
Trusted bool
State string
Authentication string
Version string
LastError string
Endpoint string
Network bool
StateDir bool
Executables int
Tools int
}
ExtensionSourceView is one configured MCP/CLI/RPC source in the manager.
type FileStatus ¶
FileStatus is one changed file in the project.
type Item ¶
type Item struct {
ID string
Kind ItemKind
Text string
// Done is true once the item can no longer change. Streaming assistant text
// and a running tool are open.
Done bool
// Tool holds the structured call for ItemTool.
Tool *ToolState
// Note holds the verdict for ItemNote.
Note *NoteState
// Failed marks a tool error, a denied call or a failed run.
Failed bool
// Time is when the item first appeared.
Time time.Time
}
Item is one row of the transcript. The view renders it and never mutates it; a change arrives as an Event that replaces the item of the same ID.
type ItemKind ¶
type ItemKind string
ItemKind classifies one transcript entry.
const ( // ItemUser is a message the person sent. ItemUser ItemKind = "user" // ItemAssistant is model text: streaming while Done is false. ItemAssistant ItemKind = "assistant" // ItemThinking is reasoning text, shown collapsed by the view. ItemThinking ItemKind = "thinking" // ItemTool is one tool call and its (bounded) result. ItemTool ItemKind = "tool" // ItemNote is a permission-gate verdict (approval, denial, sandbox routing). ItemNote ItemKind = "note" // ItemNotice is a controller-level announcement (compaction, provider retry, // interrupt, persistence failure). ItemNotice ItemKind = "notice" )
type LarkExtensionEdit ¶ added in v1.5.49
type LarkExtensionEdit struct {
LarkCLI string
ProjectCLI string
AppID string
CredentialName string
NewAppSecret string
Domains []string
ProjectHost string
}
LarkExtensionEdit carries one configuration save. NewAppSecret is write-only and never returned by ExtensionSettings.
type LarkExtensionSettings ¶ added in v1.5.49
type LarkExtensionSettings struct {
ExtensionPackageView
LarkCLI string
ProjectCLI string
SavedLarkCLI string
SavedProjectCLI string
SavedProjectHost string
AppID string
CredentialName string
CredentialAvailable bool
Domains []string
ProjectHost string
}
LarkExtensionSettings is the non-secret editable Lark configuration.
type ModelOption ¶
type ModelOption struct {
ID string
Provider string
// Current marks the model in use.
Current bool
// Default marks the model a new session would start with.
Default bool
}
ModelOption is one choice in the model picker.
type NoteState ¶
type NoteState struct {
Tool string
Kind int
Level string
Summary string
Source string
Rationale string
Mode string
// Granted is true for approvals that let a call proceed.
Granted bool
// Failure is true for denials and blocks.
Failure bool
}
NoteState is one permission-gate announcement.
type Options ¶
type Options struct {
Model string
ProviderName string
Provider provider.Provider
BaseURL string
APIKey string
Protocol string
// Credentials is the shared resolver assembled by run.SetupEnv. APIKey is a
// fallback for embedders that construct Options directly.
Credentials *provider.CredentialStore
Version string
ThinkingLevel agentcore.ThinkingLevel
Tools []agentcore.AgentTool
SysPrompt string
Prompt runtime.PromptInputs
// ResumeID loads an existing session instead of creating one.
ResumeID string
// Approve grants the launch directory session trust up front.
Approve bool
Skills []*runtime.Skill
Extensions *extensions.Manager
ConfigPrompts []string
CliPrompts []string
// NoPromptTemplates disables prompt-template discovery.
NoPromptTemplates bool
Permissions *permissions.State
ReviewNotes *run.ReviewNotes
Budget *contextbudget.State
MaxContext config.MaxContext
Memory *memory.Store
// ProjectFactory is required to create or resume a session in a folder other
// than the launch directory. CLI/TUI embedders may leave it nil.
ProjectFactory ProjectEnvironmentFactory
// Cwd is the project directory. Empty means the process working directory.
Cwd string
// Store overrides the shared session store (tests).
Store *session.Store
// Warn receives non-fatal setup warnings; nil discards them.
Warn io.Writer
}
Options is the assembled run environment the GUI controller starts from. The command builds it with run.SetupEnv, exactly as the CLI/TUI do, so the GUI shares provider resolution, tool construction, skills and the system prompt.
type ProjectEnvironmentFactory ¶ added in v1.5.50
type ProjectEnvironmentFactory func(ctx context.Context, cwd string, setup ProjectSetup) (run.Env, error)
ProjectEnvironmentFactory assembles the project-rooted tools, prompt, extensions and memory resources for one explicit desktop project folder.
type ProjectFileEntry ¶ added in v1.5.57
type ProjectFilePreview ¶ added in v1.5.57
type ProjectFolder ¶ added in v1.5.50
type ProjectFolder struct {
Path string `json:"path"`
Name string `json:"name"`
AddedAt time.Time `json:"added_at"`
LastOpened time.Time `json:"last_opened"`
}
ProjectFolder is one folder the person explicitly added to the desktop sidebar. Sessions do not create project rows implicitly.
type ProjectSetup ¶ added in v1.5.50
type ProjectSetup struct {
Model string
ProviderName string
BaseURL string
Protocol string
APIKey string
}
ProjectSetup is the live provider state a project environment factory needs. APIKey is launch-only secret material and must not be displayed or persisted.
type ProviderSettings ¶ added in v1.5.49
type ProviderSettings struct {
Provider string
Model string
BaseURL string
Protocol string
Credential CredentialView
ThinkingLevel string
Providers []string
Protocols []string
}
ProviderSettings is the global provider defaults shown by Settings.
type ProviderSettingsEdit ¶ added in v1.5.49
type ProviderSettingsEdit struct {
Provider string
Model string
BaseURL string
Protocol string
CredentialName string
NewCredential string
RemoveCredential bool
ThinkingLevel string
}
ProviderSettingsEdit is one settings save. NewCredential is write-only: it is consumed immediately and is never returned by a load or event.
type SessionSummary ¶
type SessionSummary struct {
ID string
Title string
Model string
Provider string
Cwd string
UpdatedAt time.Time
Current bool
Archived bool
}
SessionSummary is one row of the session sidebar.
type SessionWriterView ¶ added in v1.5.57
type Snapshot ¶
type Snapshot struct {
Status
Project string
// Items is the transcript in display order.
Items []Item
// Pending are the approvals waiting for an answer, oldest first.
Pending []ApprovalView
}
Snapshot is a complete view of the controller, taken at one instant. A view builds from it and then applies Events.
type Status ¶
type Status struct {
Model string
Provider string
Thinking agentcore.ThinkingLevel
Permission string
Running bool
RunID string
SessionID string
Title string
ContextUsed int
ContextLimit int
ReadOnly bool
Writer SessionWriterView
// Error is the last controller error worth showing, "" when none.
Error string
}
Status is the live state the composer footer shows.
type TTYSummary ¶ added in v1.5.49
TTYSummary is one interactive bash session available for terminal takeover.
type ToolState ¶
type ToolState struct {
ID string
Name string
Input map[string]any
Output string
// Details is structured tool metadata (for example bash_id). It is not
// rendered wholesale; views pick known non-secret fields.
Details map[string]any
// Running is true until the executor reports the end.
Running bool
// Error is the executor's failure flag, not a parse result.
Error bool
}
ToolState is one tool invocation, as the view shows it.
type UserAttachment ¶ added in v1.5.50
type UserAttachment struct {
Path string
}
UserAttachment is a local file explicitly selected in the native composer picker. Images become multimodal blocks; small text files are inlined.