Documentation
¶
Overview ¶
Package console is the seed of the runtime's dashboard. It receives the push notifications of every task an agent runs (see package observer), and shows:
- a task tree across agents, with time spent working vs waiting on a human vs waiting on a credential (the "C" part: traces for free, because the events flow through us)
- each task's timeline and artifacts
- an inbox where a person answers tasks in INPUT_REQUIRED (the "B" part: a human in the loop over plain A2A). The answer goes back to the agent as a structuredinput response, and the task resumes.
State lives in memory; a restart forgets everything.
Index ¶
- Constants
- type AgentMessage
- type Config
- type Console
- func (c *Console) Answer(ctx context.Context, taskID a2a.TaskID, answeredBy string, ...) error
- func (c *Console) Handler() http.Handler
- func (c *Console) Messages() []AgentMessage
- func (c *Console) Mount(prefix string, h http.Handler, label, href string)
- func (c *Console) PushURL(agentURL string) string
- func (c *Console) Record(agentURL string, event a2a.Event, at time.Time)
- func (c *Console) Task(id a2a.TaskID) (*Task, bool)
- func (c *Console) Tasks() []*Task
- func (c *Console) Token() string
- type Event
- type Notification
- type Notifier
- type SlackWebhook
- type Task
Constants ¶
const AnsweredByKey = "https://threeagents.dev/ext/answered-by/v1"
AnsweredByKey is the message metadata key that names the person who answered from the inbox. Agents can copy it into their audit trail.
const TokenHeader = "A2A-Notification-Token"
TokenHeader is the header a2a-go's push sender uses for PushConfig.Token.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentMessage ¶
type AgentMessage struct {
At time.Time `json:"at"`
AgentURL string `json:"agentUrl"`
AgentName string `json:"agentName"`
Summary string `json:"summary"`
}
AgentMessage is a reply that was a plain Message rather than a task.
type Config ¶
type Config struct {
// PublicURL is where people and agents reach the console, e.g. "http://localhost:8088".
PublicURL string
// Token is the push token agents must send. Empty disables the check.
Token string
// Notifier, if set, is told whenever a task starts waiting on a person.
Notifier Notifier
Logger *slog.Logger
}
Config configures a Console.
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Console holds the observed tasks.
func (*Console) Answer ¶
func (c *Console) Answer(ctx context.Context, taskID a2a.TaskID, answeredBy string, form func(string) string) error
Answer sends a person's answer to a task waiting in INPUT_REQUIRED, as a structuredinput response. The call returns as soon as the agent accepts the message; the task then continues on its own.
func (*Console) Messages ¶
func (c *Console) Messages() []AgentMessage
Messages returns the plain-message replies the console saw, newest first.
func (*Console) Mount ¶
Mount serves h under prefix (which must end in "/") and, when label is not empty, adds a navigation link to href.
func (*Console) PushURL ¶
PushURL is the webhook URL an agent at agentURL should push its task events to.
type Event ¶
type Event struct {
At time.Time `json:"at"`
Kind string `json:"kind"`
State a2a.TaskState `json:"state,omitempty"`
Summary string `json:"summary"`
}
Event is one entry of a task's timeline.
type Notification ¶
Notification tells people that a task is waiting on them.
type Notifier ¶
type Notifier interface {
Notify(ctx context.Context, n Notification) error
}
Notifier delivers notifications to a channel such as Slack, email or WhatsApp.
type SlackWebhook ¶
SlackWebhook posts notifications to a Slack incoming webhook. It only links to the inbox; answering inside Slack needs a Slack app with interactivity, which is a later step.
func (SlackWebhook) Notify ¶
func (s SlackWebhook) Notify(ctx context.Context, n Notification) error
Notify implements Notifier.
type Task ¶
type Task struct {
ID a2a.TaskID `json:"id"`
ContextID string `json:"contextId,omitempty"`
AgentURL string `json:"agentUrl"`
AgentName string `json:"agentName"`
State a2a.TaskState `json:"state"`
Status *a2a.Message `json:"status,omitempty"`
Artifacts []*a2a.Artifact `json:"artifacts,omitempty"`
Events []Event `json:"events"`
ParentID a2a.TaskID `json:"parentId,omitempty"`
Children []a2a.TaskID `json:"children,omitempty"`
FirstSeen time.Time `json:"firstSeen"`
LastSeen time.Time `json:"lastSeen"`
// TimeIn is how long the task spent in each state, as observed by the console.
TimeIn map[a2a.TaskState]time.Duration `json:"timeIn"`
// contains filtered or unexported fields
}
Task is the console's view of one task, rebuilt from the push events it received.
func (*Task) Duration ¶
Duration is the time between the first and the last event seen for the task.
func (*Task) TimeBreakdown ¶
TimeBreakdown lists non-zero time-in-state entries in a stable order.