Documentation
¶
Index ¶
- Constants
- func NormalizeTaskState(state adk.TaskState) adk.TaskState
- func TaskStateDisplayName(state string) string
- type AgentCardService
- type AgentState
- type AgentSupervisor
- type BackgroundTaskService
- type CachedAgentCard
- type Clearer
- type TaskInfo
- type TaskPollingState
- type TaskRetentionService
- type TaskTracker
Constants ¶
const ( TaskStatusRunning = "Running" TaskStatusSubmitted = "Submitted" TaskStatusWorking = "Working" TaskStatusCompleted = "Completed" TaskStatusFailed = "Failed" TaskStatusCanceled = "Canceled" TaskStatusRejected = "Rejected" TaskStatusInputRequired = "Input Required" TaskStatusAuthRequired = "Auth Required" TaskStatusUnknown = "Unknown" )
Task statuses as the task view names them. Running covers any task still in flight whose remote state is not known yet.
Variables ¶
This section is empty.
Functions ¶
func NormalizeTaskState ¶
NormalizeTaskState maps the state a remote agent reports to its adk.TaskState constant. Agents report the prefixed enum (TASK_STATE_COMPLETED) or a bare form such as completed, input-required or canceled. An unknown state is returned unchanged.
func TaskStateDisplayName ¶
TaskStateDisplayName names a task state for display. Every adk.TaskState has a name. An unknown state is title-cased with its "TASK_STATE_" prefix stripped, so it never shows as a raw enum.
Types ¶
type AgentCardService ¶
type AgentCardService interface {
GetAgentCards(ctx context.Context) ([]*CachedAgentCard, error)
GetConfiguredAgents() []string
}
AgentCardService resolves the configured A2A agents and their agent cards.
type AgentState ¶
type AgentState int
AgentState represents the current state of an agent
const ( AgentStateUnknown AgentState = iota AgentStatePullingImage AgentStateStarting AgentStateWaitingReady AgentStateReady AgentStateFailed )
func (AgentState) DisplayName ¶
func (a AgentState) DisplayName() string
DisplayName returns a user-friendly display name for the agent state
func (AgentState) String ¶
func (a AgentState) String() string
type AgentSupervisor ¶
type AgentSupervisor interface {
// StartAgents starts all agents configured with run: true
StartAgents(ctx context.Context) error
// WaitForAgentsReady blocks until every run:true agent started by
// StartAgents has settled (ready or failed), or ctx is done
WaitForAgentsReady(ctx context.Context)
// StopAgents stops all running agent containers
StopAgents(ctx context.Context) error
// StopAgent stops a specific agent container by name
StopAgent(ctx context.Context, agentName string) error
// IsRunning returns whether any agents are running
IsRunning() bool
// SetStatusCallback sets the callback function for agent status updates
SetStatusCallback(callback func(agentName string, state AgentState, message string, url string, image string))
// SetPullProgressCallback sets the callback function for image pull progress updates
SetPullProgressCallback(callback func(agentName string, done, total int))
}
AgentSupervisor manages the lifecycle of A2A agent containers
type BackgroundTaskService ¶
type BackgroundTaskService interface {
// GetBackgroundTasks returns all current background polling tasks
GetBackgroundTasks() []TaskPollingState
// CancelBackgroundTask cancels a background task by task ID
CancelBackgroundTask(taskID string) error
}
BackgroundTaskService handles background A2A task operations Only enabled when A2A is enabled - provides task cancellation and retrieval
type CachedAgentCard ¶
type CachedAgentCard struct {
Card *adk.AgentCard `json:"card"`
URL string `json:"url"`
FetchedAt time.Time `json:"fetched_at"`
}
CachedAgentCard represents a cached agent card with metadata
type Clearer ¶
type Clearer interface {
ClearAllAgents()
}
Clearer forgets the A2A context/task graph and discards the in-flight A2A tasks. Conversation clear and switch call it, since the graph belongs to the conversation that is being left.
type TaskInfo ¶
type TaskInfo struct {
// ADK Task contains: ID, ContextID, Status (with State), History, Artifacts, Metadata
Task adk.Task
// UI-specific fields
AgentURL string
StartedAt time.Time
CompletedAt time.Time
}
TaskInfo wraps ADK Task with UI-specific metadata for completed/terminal tasks Used for A2A task retention and display
type TaskPollingState ¶
type TaskPollingState struct {
TaskID string
ContextID string
AgentURL string
TaskDescription string
IsPolling bool
StartedAt time.Time
LastKnownState string
}
TaskPollingState is the data record for one in-flight A2A task that the task view reads. Monitoring is owned by the job supervisor, which runs the task's background job that polls the remote agent.
type TaskRetentionService ¶
type TaskRetentionService interface {
// AddTask adds a terminal task (completed, failed, canceled, etc.) to retention
AddTask(task TaskInfo)
// GetTasks returns all retained tasks
GetTasks() []TaskInfo
// Clear removes all retained tasks
Clear()
// SetMaxRetention updates the maximum retention count
SetMaxRetention(maxRetention int)
// GetMaxRetention returns the current maximum retention count
GetMaxRetention() int
}
TaskRetentionService manages in-memory retention of completed/terminal A2A tasks Only enabled when A2A is enabled - decouples task retention from the TUI state store
type TaskTracker ¶
type TaskTracker interface {
// Context management (contexts are server-generated and tracked here).
// Multiple contexts per agent enable multi-tenant/multi-session support.
RegisterContext(agentURL, contextID string)
GetLatestContextForAgent(agentURL string) string
HasContext(contextID string) bool
// Task management (tasks are server-generated and scoped to contexts per A2A spec)
AddTask(contextID, taskID string)
GetLatestTaskForContext(contextID string) string
RemoveTask(taskID string)
// Agent management
Clearer
// Polling state management (one polling state per task)
StartPolling(taskID string, state *TaskPollingState)
StopPolling(taskID string)
GetPollingState(taskID string) *TaskPollingState
}
TaskTracker handles A2A task ID and context ID tracking within chat sessions. Following A2A spec: supports multi-tenant with multiple contexts per agent.