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
63
64
65
66
67
68
69
70
71
72
73
74
75
use Result;
use async_trait;
use BoxStream;
use Value;
/// A trigger event delivered by an [`EventSource`].
///
/// Contains the name of the source that produced it and an arbitrary JSON payload
/// with source-specific metadata (e.g., matched file path, cron tick time, webhook body).
///
/// It carries no idempotency key: a consumer that deduplicates derives one from the payload,
/// as the `adk-kernel` wake sources do (spec 3.2 §7.4, §13 Q7). The struct is
/// `#[non_exhaustive]`; build it with [`new`](Self::new) and
/// [`with_principal`](Self::with_principal).
///
/// # Example
///
/// ```rust
/// use adk_agent::ambient::TriggerEvent;
///
/// let event = TriggerEvent::new("hook", serde_json::json!({"id": 7})).with_principal("partner");
/// assert_eq!(event.principal.as_deref(), Some("partner"));
/// assert_eq!(TriggerEvent::new("cron", serde_json::Value::Null).principal, None);
/// ```
/// A source of trigger events for ambient agents.
///
/// Implementations produce an async stream of [`TriggerEvent`]s. The stream yields
/// events until the source is stopped or the subscription is dropped.
///
/// # Built-in Implementations
///
/// - [`CronTrigger`](super::CronTrigger) — cron schedule
/// - [`WebhookTrigger`](super::WebhookTrigger) — HTTP POST webhook
/// - [`FileWatchTrigger`](super::FileWatchTrigger) — filesystem watcher