statemanager

package
v0.226.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store added in v0.207.0

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

Store provides centralized state management with proper synchronization

func NewStore added in v0.207.0

func NewStore(debugMode bool) *Store

NewStore creates a new state manager

func (*Store) AddQueuedMessage added in v0.207.0

func (sm *Store) AddQueuedMessage(message sdk.Message, requestID string)

AddQueuedMessage adds a message to the input queue

func (*Store) AreAllAgentsReady added in v0.207.0

func (sm *Store) AreAllAgentsReady() bool

AreAllAgentsReady returns true if all agents are ready

func (*Store) BroadcastEvent added in v0.207.0

func (sm *Store) BroadcastEvent(event agentdomain.ChatEvent)

BroadcastEvent publishes an event to the EventBridge for external consumers

func (*Store) ClearAgentReadiness added in v0.207.0

func (sm *Store) ClearAgentReadiness()

ClearAgentReadiness clears the agent readiness state

func (*Store) ClearApprovalUIState added in v0.207.0

func (sm *Store) ClearApprovalUIState()

ClearApprovalUIState clears the approval UI state

func (*Store) ClearComputerUsePauseState added in v0.207.0

func (sm *Store) ClearComputerUsePauseState()

ClearComputerUsePauseState clears the pause state

func (*Store) ClearLastClickCoordinates added in v0.207.0

func (sm *Store) ClearLastClickCoordinates()

ClearLastClickCoordinates clears the stored click coordinates

func (*Store) ClearLastFocusedApp added in v0.207.0

func (sm *Store) ClearLastFocusedApp()

ClearLastFocusedApp clears the stored focused app

func (*Store) ClearMessageEditState added in v0.207.0

func (sm *Store) ClearMessageEditState()

ClearMessageEditState clears the message edit state

func (*Store) ClearPlanApprovalUIState added in v0.207.0

func (sm *Store) ClearPlanApprovalUIState()

ClearPlanApprovalUIState clears the plan approval UI state

func (*Store) ClearQueuedMessages added in v0.207.0

func (sm *Store) ClearQueuedMessages()

ClearQueuedMessages clears all queued messages

func (*Store) ClearUserQuestionUIState added in v0.207.0

func (sm *Store) ClearUserQuestionUIState()

ClearUserQuestionUIState clears the AskUserQuestion form state

func (*Store) CompleteCurrentTool added in v0.207.0

func (sm *Store) CompleteCurrentTool(result *agentdomain.ToolExecutionResult) error

CompleteCurrentTool marks the current tool as completed

func (*Store) CycleAgentMode added in v0.207.0

func (sm *Store) CycleAgentMode() agentdomain.AgentMode

CycleAgentMode cycles to the next agent mode

func (*Store) EndChatSession added in v0.207.0

func (sm *Store) EndChatSession()

EndChatSession ends the current chat session

func (*Store) EndToolExecution added in v0.207.0

func (sm *Store) EndToolExecution()

EndToolExecution ends the current tool execution session

func (*Store) FailCurrentTool added in v0.207.0

func (sm *Store) FailCurrentTool(result *agentdomain.ToolExecutionResult) error

FailCurrentTool marks the current tool as failed

func (*Store) GetAgentMode added in v0.207.0

func (sm *Store) GetAgentMode() agentdomain.AgentMode

GetAgentMode returns the current agent mode

func (*Store) GetAgentReadiness added in v0.207.0

func (sm *Store) GetAgentReadiness() *tui.AgentReadinessState

GetAgentReadiness returns the current agent readiness state

func (*Store) GetApprovalUIState added in v0.207.0

func (sm *Store) GetApprovalUIState() *tui.ApprovalUIState

GetApprovalUIState returns the current approval UI state

func (*Store) GetChatSession added in v0.207.0

func (sm *Store) GetChatSession() *tui.ChatSession

GetChatSession returns the current chat session (read-only)

func (*Store) GetCurrentView added in v0.207.0

func (sm *Store) GetCurrentView() tui.ViewState

GetCurrentView returns the current view state

func (*Store) GetDimensions added in v0.207.0

func (sm *Store) GetDimensions() (int, int)

GetDimensions returns the current UI dimensions

func (*Store) GetEventBridge added in v0.207.0

func (sm *Store) GetEventBridge() agentdomain.EventBridge

GetEventBridge returns the event bridge for control event forwarding

func (*Store) GetLastClickCoordinates added in v0.207.0

func (sm *Store) GetLastClickCoordinates() (x, y int)

GetLastClickCoordinates returns the coordinates of the last click

func (*Store) GetLastFocusedApp added in v0.207.0

func (sm *Store) GetLastFocusedApp() string

GetLastFocusedApp returns the application ID of the last focused application

func (*Store) GetMessageEditState added in v0.207.0

func (sm *Store) GetMessageEditState() *tui.MessageEditState

GetMessageEditState returns the current message edit state

func (*Store) GetPausedRequestID added in v0.207.0

func (sm *Store) GetPausedRequestID() string

GetPausedRequestID returns the request ID of the paused execution

func (*Store) GetPlanApprovalUIState added in v0.207.0

func (sm *Store) GetPlanApprovalUIState() *tui.PlanApprovalUIState

GetPlanApprovalUIState returns the current plan approval UI state

func (*Store) GetPreviousView added in v0.207.0

func (sm *Store) GetPreviousView() tui.ViewState

GetPreviousView returns the previous view state

func (*Store) GetQueuedMessages added in v0.207.0

func (sm *Store) GetQueuedMessages() []convdomain.QueuedMessage

GetQueuedMessages returns the current queued messages

func (*Store) GetRetryStatus added in v0.207.0

func (sm *Store) GetRetryStatus() *agentdomain.RetryStatus

GetRetryStatus returns a copy of the current retry status, or nil when the connection is healthy. Besides explicit reconnect attempts (set by the agent's reconnect loop), it synthesizes a zero-attempt status when a streaming session has produced no chunks for stallThreshold - the render tick calls this on every frame, so a stalled connection surfaces without any timer of its own. A synthesized status has Attempt == 0. Terminal sessions never report a status, so a stale explicit retry can't outlive the turn it belonged to (the input field is disabled while this returns non-nil).

func (*Store) GetTodos added in v0.207.0

func (sm *Store) GetTodos() []agentdomain.TodoItem

GetTodos returns the current todo list

func (*Store) GetToolExecution added in v0.207.0

func (sm *Store) GetToolExecution() *tui.ToolExecutionSession

GetToolExecution returns the current tool execution session (read-only)

func (*Store) GetUserQuestionUIState added in v0.207.0

func (sm *Store) GetUserQuestionUIState() *tui.UserQuestionUIState

GetUserQuestionUIState returns the current AskUserQuestion form state

func (*Store) InitializeAgentReadiness added in v0.207.0

func (sm *Store) InitializeAgentReadiness(totalAgents int)

InitializeAgentReadiness initializes the agent readiness tracking

func (*Store) IsAgentBusy added in v0.207.0

func (sm *Store) IsAgentBusy() bool

IsAgentBusy returns true if the agent is currently processing a request

func (*Store) IsComputerUsePaused added in v0.207.0

func (sm *Store) IsComputerUsePaused() bool

IsComputerUsePaused returns whether computer use is currently paused

func (*Store) IsDebugMode added in v0.207.0

func (sm *Store) IsDebugMode() bool

IsDebugMode returns whether debug mode is enabled

func (*Store) IsEditingMessage added in v0.207.0

func (sm *Store) IsEditingMessage() bool

IsEditingMessage returns true if currently editing a message

func (*Store) PopQueuedMessage added in v0.207.0

func (sm *Store) PopQueuedMessage() *convdomain.QueuedMessage

PopQueuedMessage removes and returns the first message from the queue (FIFO order)

func (*Store) RecoverFromInconsistentState added in v0.207.0

func (sm *Store) RecoverFromInconsistentState() error

RecoverFromInconsistentState attempts to recover from an inconsistent state

func (*Store) RemoveAgent added in v0.207.0

func (sm *Store) RemoveAgent(name string)

RemoveAgent removes an agent from the readiness tracking

func (*Store) SetAgentError added in v0.207.0

func (sm *Store) SetAgentError(name string, err error)

SetAgentError sets an error for a specific agent

func (*Store) SetAgentMode added in v0.207.0

func (sm *Store) SetAgentMode(mode agentdomain.AgentMode)

SetAgentMode sets the agent mode

func (*Store) SetChatPending added in v0.207.0

func (sm *Store) SetChatPending()

SetChatPending marks the agent as busy before the chat actually starts. This prevents race conditions where messages might not be queued between the time we decide to start a chat and when StartChatSession is called.

Promotes to "pending" if there is no existing chat session OR if the existing session is in a terminal status (Completed/Error/Cancelled/Idle). Terminal sessions are leftovers from a prior chat that hasn't been GC'd yet; treating them as "in progress" would make IsAgentBusy() return false here but true for a subsequent caller that just won the SetChatPending race, which is exactly the window the chat-mode async rollover relies on for queueing.

func (*Store) SetComputerUsePaused added in v0.207.0

func (sm *Store) SetComputerUsePaused(paused bool, requestID string)

SetComputerUsePaused sets the paused state for computer use

func (*Store) SetDebugMode added in v0.207.0

func (sm *Store) SetDebugMode(enabled bool)

SetDebugMode enables or disables debug mode

func (*Store) SetDimensions added in v0.207.0

func (sm *Store) SetDimensions(width, height int)

SetDimensions updates the UI dimensions

func (*Store) SetEventBridge added in v0.207.0

func (sm *Store) SetEventBridge(bridge agentdomain.EventBridge)

SetEventBridge sets the event bridge for multicasting events to external consumers

func (*Store) SetLastClickCoordinates added in v0.207.0

func (sm *Store) SetLastClickCoordinates(x, y int)

SetLastClickCoordinates stores the coordinates of the last click

func (*Store) SetLastFocusedApp added in v0.207.0

func (sm *Store) SetLastFocusedApp(appID string)

SetLastFocusedApp stores the application ID of the last focused application

func (*Store) SetMessageEditState added in v0.207.0

func (sm *Store) SetMessageEditState(state *tui.MessageEditState)

SetMessageEditState sets the message edit state

func (*Store) SetPlanApprovalSelectedIndex added in v0.207.0

func (sm *Store) SetPlanApprovalSelectedIndex(index int)

SetPlanApprovalSelectedIndex sets the plan approval selection index

func (*Store) SetRetryStatus added in v0.207.0

func (sm *Store) SetRetryStatus(status *agentdomain.RetryStatus)

SetRetryStatus updates the retry status on the current chat session. Called by the agent's reconnect loop to provide visual feedback in the status bar while it is reconnecting after a failure.

func (*Store) SetStallThreshold added in v0.207.0

func (sm *Store) SetStallThreshold(threshold time.Duration)

SetStallThreshold sets how long a streaming session may go without chunks before GetRetryStatus reports it as reconnecting. Zero or negative disables stall detection.

func (*Store) SetTodos added in v0.207.0

func (sm *Store) SetTodos(todos []agentdomain.TodoItem)

SetTodos sets the todo list

func (*Store) SetupApprovalUIState added in v0.207.0

func (sm *Store) SetupApprovalUIState(toolCall *sdk.ChatCompletionMessageToolCall, responseChan chan agentdomain.ApprovalAction)

SetupApprovalUIState initializes approval UI state

func (*Store) SetupPlanApprovalUIState added in v0.207.0

func (sm *Store) SetupPlanApprovalUIState(planContent, planID string, responseChan chan agentdomain.PlanApprovalAction)

SetupPlanApprovalUIState initializes plan approval UI state

func (*Store) SetupUserQuestionUIState added in v0.207.0

func (sm *Store) SetupUserQuestionUIState(questions []agentdomain.UserQuestion, responseChan chan []agentdomain.UserQuestionAnswer)

SetupUserQuestionUIState initializes the AskUserQuestion form state

func (*Store) StartChatSession added in v0.207.0

func (sm *Store) StartChatSession(requestID, model string, eventChan <-chan agentdomain.ChatEvent) error

StartChatSession starts a new chat session

func (*Store) StartToolExecution added in v0.207.0

func (sm *Store) StartToolExecution(toolCalls []sdk.ChatCompletionMessageToolCall) error

StartToolExecution starts a new tool execution session

func (*Store) TouchChatActivity added in v0.207.0

func (sm *Store) TouchChatActivity()

TouchChatActivity records stream output on the current session, clearing any retry status and resetting the stall clock.

func (*Store) TransitionToView added in v0.207.0

func (sm *Store) TransitionToView(newView tui.ViewState) error

TransitionToView transitions to a new view with validation and logging

func (*Store) UpdateAgentPullProgress added in v0.207.0

func (sm *Store) UpdateAgentPullProgress(name string, done, total int)

UpdateAgentPullProgress updates the image pull layer counts for a specific agent

func (*Store) UpdateAgentStatus added in v0.207.0

func (sm *Store) UpdateAgentStatus(name string, state a2adomain.AgentState, message string, url string, image string)

UpdateAgentStatus updates the status of a specific agent

func (*Store) UpdateChatStatus added in v0.207.0

func (sm *Store) UpdateChatStatus(status tui.ChatStatus) error

UpdateChatStatus updates the chat session status with validation

Jump to

Keyboard shortcuts

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