A2aEngine.Parts (a2a_engine v0.1.0)

Copy Markdown View Source

Helpers that operate on a list of decoded Part maps (the shape Parts take once JSON-decoded but before being encoded back for transport).

Owner filtering

The checkpoint-in-envelope convention (see A2aEngine.Types.DataPart) stores worker/caller resumable state as a DataPart tagged metadata: {"type" => "checkpoint", "owner" => <agent>, "session" => <id>}. A broker forwarding a message to the next hop should only include checkpoints whose owner matches the recipient — otherwise each side's private state leaks to the other.

filter_by_owner/2 enforces that rule. TextParts, FileParts, and DataParts without checkpoint metadata pass through unchanged — this function only acts on tagged checkpoints.

Summary

Functions

Keep only the Parts that the named recipient is allowed to see.

Same rule at the part level. Useful for artifact-carried DataParts where the artifact itself is public but an embedded DataPart may be private.

Functions

filter_by_owner(parts, recipient)

@spec filter_by_owner([map()], String.t()) :: [map()]

Keep only the Parts that the named recipient is allowed to see.

  • TextPart / FilePart → always kept.
  • DataPart without checkpoint metadata → always kept.
  • DataPart with metadata.type == "checkpoint" → kept only if metadata.owner == recipient.

visible_to?(arg1, recipient)

@spec visible_to?(map(), String.t()) :: boolean()

Same rule at the part level. Useful for artifact-carried DataParts where the artifact itself is public but an embedded DataPart may be private.