fromWire static method
Implementation
static ZorphyBoundaryResult<AgentToolCall> fromWire(
Map<String, Object?> raw,
) {
final violations = <FieldViolation>[];
final Object? raw_name = raw['name'];
String? _name;
_name = _boundaryAs<String>(raw_name, '/name', violations);
final Object? raw_turn = raw['turn'];
int? _turn;
_turn = _boundaryAs<int>(raw_turn, '/turn', violations);
final Object? raw_outcome = raw['outcome'];
ToolCallOutcome? _outcome;
if (raw_outcome != null) {
final map_outcome = _boundaryObject(raw_outcome, '/outcome', violations);
if (map_outcome != null) {
ToolCallOutcome.fromWire(map_outcome).fold(
(value) {
_outcome = value;
},
(error) =>
violations.addAll(_boundaryPrefix(error.violations, '/outcome')),
);
}
}
final Object? raw_summary = raw['summary'];
String? _summary;
if (raw_summary != null) {
_summary = _boundaryAs<String>(raw_summary, '/summary', violations);
}
if (violations.isNotEmpty) {
return BoundaryErr<AgentToolCall>(
targetType: 'AgentToolCall',
violations: violations,
);
}
return BoundaryOk<AgentToolCall>(
AgentToolCall.fromTrusted(
name: _name!,
turn: _turn!,
outcome: _outcome,
summary: _summary,
),
);
}