StructuredResponse class

Common reply shape: summary + optional warnings + nextSteps. Renders both human text and structuredContent so callers can branch on data instead of parsing prose.

Constructors

StructuredResponse({required String summary, List<String> warnings = const [], List<String> nextSteps = const [], Map<String, Object?>? data, bool isError = false, bool textOnly = false, List<String> imagePaths = const []})
StructuredResponse.appBusy(Duration timeout, {String? summary, bool maybeQueued = false})
The VM gave no answer within timeout though the app has drawn frames before: busy, not starting. summary overrides the headline.
factory
StructuredResponse.backendError(String summary, Object e)
A backend exception as a reply: a BackendFailure keeps its kind, data and next steps; anything unknown is a backendToolError.
factory
StructuredResponse.error({required String summary, required GlintErrorKind errorKind, String? detail, List<String> nextSteps = const []})
factory
StructuredResponse.fromActionResult(ActionResult r, {bool detail = false})
Builds a response from an ActionResult. The envelope already carries summary/warnings/nextSteps at the top level, so those are dropped from data rather than duplicated. Geometry (painted, hittable, logicalCenter) is omitted unless detail is true; the agent only needs ok + the changed-signal to continue. The failure reason is routed to the shared detail key so it surfaces in prose and the action log.
factory
StructuredResponse.notOnThisDevice(Ability ability, AbilityGap gap)
ability refused on a device that lacks it, with the reason and what to do instead from gap.
factory
StructuredResponse.toolchainBlocked(IosToolchainBlocked e)
A bridge action refused by the iOS toolchain check.
factory

Properties

data → Map<String, Object?>?
final
hashCode → int
The hash code for this object.
no setterinherited
imagePaths → List<String>
PNG files shipped inline as image content, so the agent sees them without a second read.
final
isError → bool
final
nextSteps → List<String>
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
summary → String
final
textOnly → bool
Ship only the plain text: no structuredContent, so a scene-sized reply reaches the agent once and unescaped instead of as JSON-encoded text.
final
warnings → List<String>
final
wireBytes → int
Bytes the client receives: the structured payload, or the text alone.
no setter

Methods

addWarnings(List<String> extra) → StructuredResponse
Appends extra to warnings (no-op when empty).
copyWith({String? summary, List<String>? warnings, List<String>? nextSteps, Map<String, Object?>? data, bool? isError, bool? textOnly, List<String>? imagePaths}) → StructuredResponse
Returns a copy with the given fields replaced — so callers augmenting a response don't re-list all five fields by hand.
mergeData(Map<String, Object?> extra) → StructuredResponse
Merges extra into data (extra keys win).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
renderText() → String
toCallResult() → CallToolResult
toString() → String
A string representation of this object.
inherited
toStructuredContent() → Map<String, Object?>

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

refuse(DeviceTarget device, Ability ability) → StructuredResponse?
ability on device: a refusal when the device lacks it, null when it has it.