console

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 22 Imported by: ? 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

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

View Source
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.

View Source
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 New

func New(cfg Config) *Console

New creates a console.

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) Handler

func (c *Console) Handler() http.Handler

Handler returns the console's HTTP handler.

func (*Console) Messages

func (c *Console) Messages() []AgentMessage

Messages returns the plain-message replies the console saw, newest first.

func (*Console) Mount

func (c *Console) Mount(prefix string, h http.Handler, label, href string)

Mount serves h under prefix (which must end in "/") and, when label is not empty, adds a navigation link to href.

func (*Console) PushURL

func (c *Console) PushURL(agentURL string) string

PushURL is the webhook URL an agent at agentURL should push its task events to.

func (*Console) Record

func (c *Console) Record(agentURL string, event a2a.Event, at time.Time)

Record applies one event pushed by the agent at agentURL.

func (*Console) Task

func (c *Console) Task(id a2a.TaskID) (*Task, bool)

Task returns a copy of one task.

func (*Console) Tasks

func (c *Console) Tasks() []*Task

Tasks returns copies of all observed tasks, newest first.

func (*Console) Token

func (c *Console) Token() string

Token is the push token agents must send.

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

type Notification struct {
	Title string
	Text  string
	Link  string
}

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

type SlackWebhook struct {
	URL    string
	Client *http.Client
}

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

func (t *Task) Duration() time.Duration

Duration is the time between the first and the last event seen for the task.

func (*Task) TaskInfo

func (t *Task) TaskInfo() a2a.TaskInfo

TaskInfo implements a2a.TaskInfoProvider.

func (*Task) TimeBreakdown

func (t *Task) TimeBreakdown() []string

TimeBreakdown lists non-zero time-in-state entries in a stable order.

func (*Task) Waiting

func (t *Task) Waiting() bool

Waiting reports whether the task is interrupted (spec 4.1.3): it needs an answer or a credential.

Jump to

Keyboard shortcuts

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