Skip to main content

Crate adk_surface

Crate adk_surface 

Source
Expand description

§adk-surface

Agent surfaces for ADK-Rust (spec 3.3): one engine under every window a person opens onto their agents — the web home, the terminal, chat, the phone, the desktop tray, voice. Nothing lives in a surface: a decision is made once, from anywhere, and every other window shows who made it.

§The engine

SurfaceEngine is always compiled. It reads a Source — an in-process kernel, harness or runner (LocalSource), or a kernel’s control plane (ControlSource) — and gives every surface the same three things (spec 3.3 §6):

PartWhatWhere
FeedA session’s events numbered by their position in the session store, as a snapshot then a live tail, resumable after the last seq seenSurfaceEngine::feed, SurfaceEngine::thread
ProjectionDecision cards (§7.1), thread items, agent rows, the status line and the “While you were away” briefing, in the words of §8model, words
CommandsDecide at the version seen, send, queue, stop all, resume all, change the mode — each with its caller’s subject and Origin, auditedSurfaceEngine::execute, Command

What each surface may decide (§7.2) and the rules on every surface (§7.4) are enforced by the engine in rules, not left to renderers.

The live camera surface (spec 3.7 §8.2) is camera: a camera source’s facts, the hub that drops every frame of a camera switched off or paused by Stop all, and the view model; its routes are served with web once the engine is built with SurfaceEngineBuilder::cameras, and with vision-camera its cameras run on adk-vision’s frame pipeline.

§Surfaces

FeatureSurfaceStability
webThe web home: its HTTP API under /api/surface, mounted with ServerBuilder::add_api_routes, with its OpenAPI document, and its page at /ui/, mounted with ServerBuilder::add_root_routesBeta
tuiThe terminal (spec 3.3 §5.2): full screen, inline and JSON lines on the engine, decisions answered by key, light and dark; the adk-rust binary’s tui featureBeta
channelsChat: the Telegram adapter over the kernel’s channel contract, channels::TelegramAdapter (spec 3.3 §5.3)Beta
whatsapp, slack, discord, matrix, teamsChat on WhatsApp, Slack, Discord, Matrix and Microsoft Teams over the same contract, channels::WhatsAppAdapter, SlackAdapter, DiscordAdapter, MatrixAdapter, TeamsAdapter (spec 3.5 §10 X12); each implies channelsExperimental
mobileThe phone: the web home installed on a phone, Web Push from the person’s own kernel, pairing QR codes and “Confirm it’s you”, mobile::router (spec 3.3 §5.4); implies webBeta
voiceVoice and video: spoken “allow once” and “deny” through the engine with a cancel window, the camera and the screen as input while their switches are on; with web, the voice view’s socket (voice::router, voice::socket_routes) (spec 3.3 §5.6)Beta
voice-livevoice with Gemini Live and the OpenAI Realtime API compiled in, for the live voice test and the voice_home example; a host passes its own provider modelsBeta
computer-useScreen plans on decision cards (spec 3.7 Q8): a previewed plan of desktop actions parks as one card, decided with one answer through the harness’s computer-use pack (Harness::decide_held_screen_plan), with the plan’s binding on every stepExperimental
vision-cameraThe live camera surface on adk-vision’s frame pipeline (spec 3.7 §7.13, §8.2): camera::PipelineCameras runs each camera through StreamPipeline and reports what it measured; the voice screen’s camera through SurfaceCameraSourceExperimental
websiteThe website’s views on the web home (spec 3.5 §8.2): the web editor, onboarding, the charter cards, the site view and the weekly review over adk-website’s desk, web::website::router; implies webExperimental
verb-uiScreen actions people and agents share (spec 3.3 §2 item 7, §6.1): snoozing something in Coming up from the home, the terminal, voice and an agent, always through the governed path, verbs::VerbRegistry; with web, web::verbs::routerExperimental
workflowThe workflow observer (spec 3.3 §12 developer track): a graph agent’s runs, steps and forks, card hints for its governed nodes, workflow::Workflows; with web, the Runs tab’s routes, web::workflow::routerBeta
genuiAgent-drawn UI (spec 3.3 §6.1, §7.4 rule 5): the A2UI v0.9.1 model, the forms 1.0 catalog, the validator that keeps approval controls and secrets out of drawings, the render tools agents draw with (genui::DrawToolset), drawings in the thread and a drawn form’s Send, which asks the person first (Command::SubmitDrawn), and with web the capabilities route (web::genui::router)Beta
genui-appsApps from MCP servers in a thread (spec 3.3 §6.1): framed sandboxed on their own origin, their tool calls held for the person, never able to approve anything, genui::McpAppsHost; implies genui and webBeta

§Example

use std::sync::Arc;
use adk_core::{InMemoryApprovalStore, StoreApprovalService};
use adk_session::InMemorySessionService;
use adk_surface::{Caller, LocalSource, Origin, SurfaceEngine, SurfaceKind};

let source = LocalSource::builder("adk-rust")
    .sessions(Arc::new(InMemorySessionService::new()))
    .approvals(Arc::new(StoreApprovalService::new(Arc::new(InMemoryApprovalStore::new()))))
    .build()?;
let engine = SurfaceEngine::builder(Arc::new(source)).build();

let me = Caller::human("ana", SurfaceKind::Phone, Origin::Touch);
let status = engine.status(&me, None).await?;
assert_eq!(status.decisions, 0);

§Stability

Beta — new in 3.0.0; verb-ui and the WhatsApp, Slack, Discord, Matrix and Teams adapters are Experimental. See STABILITY.md.

Re-exports§

pub use answers::AnswerLog;
pub use answers::AnswerRecord;
pub use answers::AnswerSummary;
pub use answers::AuditAnswerLog;
pub use answers::InMemoryAnswerLog;
pub use answers::RECORD_LINES;
pub use answers::RecordAnswerLog;
pub use answers::SURFACE_AUDIT_DECIDE;
pub use answers::SurfaceCount;
pub use error::Result;
pub use error::SurfaceError;
pub use images::MAX_IMAGE_BYTES;
pub use images::MAX_IMAGES;
pub use images::MessageImage;
pub use model::CardDetail;
pub use model::AgentRef;
pub use model::AgentRow;
pub use model::AgentStatus;
pub use model::Avatar;
pub use model::Briefing;
pub use model::BriefingLine;
pub use model::CallView;
pub use model::CardStatus;
pub use model::Decided;
pub use model::DecidedAnswer;
pub use model::DecisionCard;
pub use model::ElicitationView;
pub use model::ElicitedField;
pub use model::ElicitedKind;
pub use model::ElicitedOption;
pub use model::FeedEntry;
pub use model::Mode;
pub use model::ModeView;
pub use model::ParkedView;
pub use model::Pill;
pub use model::QuietView;
pub use model::Reversibility;
pub use model::ScreenPlanStepView;
pub use model::ScreenPlanView;
pub use model::Served;
pub use model::Speaker;
pub use model::SpendView;
pub use model::StatusLine;
pub use model::ThreadItem;
pub use model::TimelineStep;
pub use model::CommandRun;
pub use model::ImageData;
pub use model::OutputLine;
pub use model::RunStop;
pub use model::ShellPlace;
pub use model::ShellView;
pub use rules::Allowed;
pub use rules::Answer;
pub use rules::AnswerOption;
pub use rules::Risk;

Modules§

answers
How each answer was given (spec 3.3 §8.1 “Decided”, §11).
camera
The live camera surface (spec 3.7 §8.2, X12): watching a stream and acting on it, on the web home and the phone, built to the signed-off boards (camera-*, board choices C1–C15).
channels
Chat channels (spec 3.3 §5.3, §6.1; feature channels): the doorbell and the conversation, through someone else’s servers.
error
Errors of the engine and its sources (spec 3.3 §6).
genui
Agent-drawn UI (spec 3.3 §6.1 genui, §7.4 rule 5): forms, cards, tables and screens an agent draws in a person’s threads, which never contain approval controls.
images
Images a person sends with a message (spec 3.3 §5.1): a screenshot of a failing build, a photo of a receipt. They reach the agent as the message’s own parts, so a model that sees images reads them with the text.
mobile
The phone (spec 3.3 §5.4, §8.2; feature mobile): the web home installed on a phone, woken by push from the person’s own kernel, approving high-risk calls after “Confirm it’s you”.
model
The projection types every surface draws from (spec 3.3 §6, §7.1, §8).
rules
What each surface may decide (spec 3.3 §7.2) and the rules on every surface (§7.4), enforced by the engine rather than left to renderers.
suggest
Suggested replies (spec 3.3 §5.1): an agent offers the person up to four short replies they might send next. The home shows them under the agent’s latest message; tapping one fills the message box, and the person still sends it. A suggestion is the person’s own message once sent, never an answer to a decision (§7.4, S-I4).
tui
The terminal (spec 3.3 §5.2): the same home as the web, from the keyboard.
verbs
Screen actions people and agents share (spec 3.3 §2 item 7, §5.6, §6.1 verb-ui; Experimental): one way to change something a surface shows — first, snoozing something in Coming up — from the home, the terminal, voice and an agent, always through the governed path.
viewer
The annotated viewer (spec 3.7 §8.2, X12): looking at what an agent saw.
voice
Voice and video (spec 3.3 §5.6; feature voice).
web
The web home (spec 3.3 §5.1, §6; feature web): its HTTP API and its page.
words
The words every surface shows (spec 3.3 §8).
workflow
The workflow observer and debugger (spec 3.3 §6.1 workflow, §12 developer track): a graph agent’s runs, steps and forks, for the web home’s Runs tab.

Structs§

AgentCardView
The definition on the decision that adds a suggested agent (spec 3.3 §5.7 “The decision that adds an agent”, S-I13): every field, from the inbox entry the kernel wrote, never from the model.
AgentChoices
What a person may choose for an agent on this kernel (spec 3.3 §5.7, decision 21): the models of the providers whose key the kernel has, the packs, the areas and the colours.
AgentDetail
One agent a person added (spec 3.3 §5.7): what Settings shows.
AgentDraft
An agent’s definition as Set it up yourself and Settings edit it, in the order of spec 3.3 §5.7 “The definition”.
AgentPreview
Here is what Finance can do (spec 3.3 §5.7): what a change lets an agent do, its risk, and the digest the change is confirmed with.
AgentState
An agent’s state as a source reports it, before projection into an AgentRow (spec 3.3 §8.1).
AgentThreads
An agent’s threads, newest first: GET /surface/agents/{id}/threads.
AlwaysAllowOffer
How a source grants “Always allow” (spec 3.3 §8.2): the label it offers for a request, and the standing rule it creates.
AreaChoice
An area a person may put an agent in.
Caller
The authenticated caller of an engine read or command (spec 3.3 §6, §11 S-I8).
CardHint
What a feature says about one of its decisions (spec 3.3 §7.1). Every field is optional. When several hints answer the same decision, the first that sets a wording field wins, and any of them can mark money or remove Always allow.
CardLine
One line of an agent’s definition on a card: “Area · Home”.
CardMedia
A held call’s images on its card (spec 3.7 §8.2, X11): what would leave, after redaction, with what was covered, where it goes, what it costs, how long it is kept and why nothing can be sent when that is so.
ColorChoice
A colour a person may choose.
ControlSource
The engine’s source over a kernel’s control plane (spec 3.3 §6, spec 3.2 §7.11): a terminal or a home attached to a kernel elsewhere, over its socket, named pipe or HTTP.
CoveredLine
What was covered of one class, as a line of “Covered before it leaves”.
EndedWork
What removing an agent ends, counted (spec 3.3 §5.7 “Pausing and removing”).
EvidenceBytes
An image a surface loads for a card, after the source checked its digest.
EvidenceImage
One image a held call would send, as its card shows it.
EvidenceRegion
A region drawn over an evidence image, in the image’s own pixels.
GoesTo
Where the images go, in words.
GrantedUse
Something the home lets every agent on it do beyond its definition, because the host gives each agent it runs the tools for it (spec 3.3 §5.7, S-I12, S-I13): shown under “Here is what Finance can do” as “On this home it can also:”. Hosts register each with SurfaceEngineBuilder::grant.
HeldPlan
A held call that is a step of a previewed screen plan, as a source tells the engine (spec 3.7 Q8): the plan’s first step carries the plan’s one card, and the steps held with it wait behind that card.
ImageChange
A change to an evidence image before it leaves (board choices A7, A8): the crop can only shrink and covering can only grow, so a change never shows more than the image it changes.
ImageChanged
What a change made: the image it replaces and the new one.
ImageFacts
What a feature knows about one image of a call: the field it shows and why it was sent.
LocalSource
The engine’s source for surfaces in the same process as the agents (spec 3.3 §6): the session store the feed numbers events from, the approval service decisions go through, and whichever of an in-process Kernel, a Harness and a Runner runs the turns.
LocalSourceBuilder
Builds a LocalSource.
MediaFacts
What a feature knows about the images one of its calls would send, which the evidence alone does not say: where they go, what they are, the estimated cost and what they were cut from (spec 3.7 §8.2). A CardHint carries it.
MediaNotice
A notice on the card about its images: why nothing can be sent.
ModelView
A model an agent runs on; never a key (spec 3.3 decision 21).
Place
Somewhere a decision is also shown, for “Also on your phone and in Telegram” (spec 3.3 §7.1).
PurgedView
An evidence image that is no longer kept (board choice A13).
RemovedAgent
An agent the person removed, whose threads stay readable (spec 3.3 §5.7, §13 decision 18; owner, at the wave 3 gate: “Removed agents” at the roster’s foot).
RemovedThread
One thread of a removed agent, read only.
SpendToday
Today’s spend and the daily limit, in micro-USD (spec 3.3 §8.1 “Daily spending limit”).
SurfaceEngine
The engine every surface runs on (spec 3.3 §6): it reads a Source, projects what it reads into cards, thread items, agent rows, the status line and the briefing, and carries out commands under the rules of §7.2 and §7.4.
SurfaceEngineBuilder
Builds a SurfaceEngine.
ThreadSummary
One of an agent’s threads (spec 3.3 §5.1 “Thread history”): its session and when it last changed.
TurnFailure
A turn of a session that ended in an error, as a source reports it: the thread shows it where the agent’s reply would have been (Source::turn_failures).
UsesDraft
What an agent can use (spec 3.3 §5.7 “What it can use”).
Via
Where and how an answer was given, as a decision answered elsewhere shows it (spec 3.3 §8.1 “Decided”).

Enums§

AgentColor
An agent’s colour: one of the eight avatar colours, never a free value (spec 3.3 §5.7).
AgentLife
Where an agent is in its life, as a surface shows it (spec 3.3 §5.7, §8.1).
AgentPreviewRequest
What POST /surface/agents/preview previews (spec 3.3 §5.7 “Show, then confirm”).
Command
A command from a surface (spec 3.3 §6). Every command runs as an authenticated Caller, whose subject, surface and Origin reach its audit record.
CommandOutcome
What a command did (spec 3.3 §6).
CoverClass
What a region on an evidence image covers, by the class the egress gate redacted it as (spec 3.7 §7.8 step 3).
EvidenceKept
Whether an evidence image is still kept, as the source knows it.
FeedFrame
One frame of a session’s feed (spec 3.3 §6): the snapshot, then the live tail.
FileUse
Where an agent’s files are: none, read, or read and change (spec 3.3 §5.7).
MediaNoticeKind
Why a card’s images cannot be sent.
Origin
How an input was given (spec 3.3 §6, §11): every command carries one, and it reaches the audit record, so “What your agents did” can say “from Telegram”.
ShellUse
Where an agent’s commands run: nowhere, in the sandbox, or on this computer.
Steered
What became of a message a running turn was offered (spec 3.3 §6 “steer”).
SurfaceKind
The surface a person uses (spec 3.3 §5, §7.2).
WebUse
What of the web an agent reaches.

Constants§

CALL_TEXT_LIMIT
How long a call’s text may be before it is shown truncated (spec 3.3 §7.1).
DEFAULT_POLL_INTERVAL
How often the feed reads the session store when the source has nothing faster.
EVIDENCE_RETENTION_DAYS
How many days an image held as evidence is kept, unless a feature says otherwise (spec 3.7 Q13).
RUN_LINES
The most lines of a run’s output a thread shows: its last ones (spec 3.3 §5.1).
SURFACE_AUDIT_ANSWER
The audit action of an answer as it is given, written before it takes effect; its surface.decide record says how it ended (spec 3.3 §11).
SURFACE_AUDIT_APP_CALL_AUTO_APPROVED
The audit action of an app’s call approved by the home’s opt-in consent policy instead of a person (spec 3.3 §6.1 genui-apps).
SURFACE_AUDIT_DRAWN_SEALED
The audit action of a person’s approval of a form’s call, sealed to the drawing they saw (spec 3.3 §7.4 rule 5).
SURFACE_AUDIT_DRAWN_SUBMITTED
The audit action of a drawn form’s Send (spec 3.3 §7.4 rule 5, §11).
SURFACE_AUDIT_IMAGE_CHANGE
The audit action of a person changing an image before it leaves: the old digest, the new one and the change, written before the call is held again (spec 3.7 §9.3 vision.edit).
SURFACE_AUDIT_RESUME_ALL
The audit action of “Resume all” (spec 3.3 §11).
SURFACE_AUDIT_SEND
The audit action of “Send” and “Queue” (spec 3.3 §11).
SURFACE_AUDIT_SET_MODE
The audit action of a mode change (spec 3.3 §11).
SURFACE_AUDIT_STEER
The audit action of a message sent to a running turn (spec 3.3 §6 “steer”, §11): what “Steer” was refused or offered, and how a message a turn held ended.
SURFACE_AUDIT_STOP_ALL
The audit action of “Stop all” (spec 3.3 §11).
SURFACE_AUDIT_STOP_TURN
The audit action of Stop the turn (spec 3.3 §5.1), recorded before the turn stops.
SURFACE_AUDIT_VISION_EXAMPLE
The audit action of a labelled example saved from the annotated viewer (spec 3.7 §8.2): the session, the answer, the image’s digest, the file, the case and the region kept.

Traits§

CardHints
A feature’s hints for the decisions its tools ask (spec 3.3 §7.1), read by the engine wherever it draws a card.
RuleCommit
A standing rule prepared for “Always allow”, granted only once the decision it belongs to was recorded.
Source
The seam between the engine and what it shows (spec 3.3 §6).

Functions§

short_digest
sha256:c52ca5…ce7550: the scheme, the first six and the last six hex digits (board choice S4).

Type Aliases§

Steering
The wait for what became of a message a running turn holds (Source::steer).