statemanager

package
v0.264.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, synchronized state management. eventBridge optionally multicasts events to external consumers.

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) 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) 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 retry status, or nil when the connection is healthy. It synthesizes an Attempt 0 status when a stream has been silent for stallThreshold, so a stall shows without a timer. Terminal sessions never report one, so a stale retry cannot outlive its turn.

func (*Store) GetSessionPlacement added in v0.239.0

func (sm *Store) GetSessionPlacement() tui.SessionPlacement

GetSessionPlacement is where a daemon chat's session runs.

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) 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 busy before the chat starts, so messages queue in the window before StartChatSession. It promotes when there is no session or the existing one is terminal, because a leftover terminal session would make IsAgentBusy disagree between callers racing for the chat.

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) SetSessionPlacement added in v0.239.0

func (sm *Store) SetSessionPlacement(placement tui.SessionPlacement)

SetSessionPlacement records where a daemon chat's session runs.

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