1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Task payload access helpers.
//!
//! A2A task payloads sometimes nest fields below `task`, so these helpers keep
//! that compatibility logic away from the main task-processing functions.
//!
//! # Examples
//!
//! ```ignore
//! let id = task_str(&payload, "id");
//! ```
/// Looks up a raw task field from either the top-level object or `task`.
///
/// This allows the worker to accept legacy and normalized payload shapes.
///
/// # Examples
///
/// ```ignore
/// let value = task_value(&payload, "id");
/// assert!(value.is_some());
/// ```
pub
/// Reads a string field from a task payload.
///
/// The worker uses this when routing and reporting on task metadata.
///
/// # Examples
///
/// ```ignore
/// let title = task_str(&payload, "title");
/// ```
pub
/// Extracts the metadata object from a task payload.
///
/// Missing metadata returns an empty map so callers can use it without extra
/// branching.
///
/// # Examples
///
/// ```ignore
/// let metadata = task_metadata(&payload);
/// assert!(metadata.is_object() || metadata.is_empty());
/// ```
pub