|
9 | 9 |
|
10 | 10 | __all__ = [ |
11 | 11 | "MonitorCreateParams", |
12 | | - "ChangeDetection", |
13 | | - "ChangeDetectionMonitorsExactChangeDetection", |
14 | | - "ChangeDetectionMonitorsSemanticChangeDetection", |
15 | | - "Schedule", |
16 | 12 | "Target", |
17 | 13 | "TargetMonitorsPageTarget", |
18 | 14 | "TargetMonitorsSitemapTarget", |
19 | 15 | "TargetMonitorsExtractTarget", |
| 16 | + "ChangeDetection", |
| 17 | + "ChangeDetectionMonitorsExactChangeDetection", |
| 18 | + "ChangeDetectionMonitorsSemanticChangeDetection", |
| 19 | + "Schedule", |
20 | 20 | "Webhook", |
21 | 21 | ] |
22 | 22 |
|
23 | 23 |
|
24 | 24 | class MonitorCreateParams(TypedDict, total=False): |
25 | | - change_detection: Required[ChangeDetection] |
26 | | - """Discriminated union describing how changes are detected.""" |
27 | | - |
28 | 25 | name: Required[str] |
29 | 26 |
|
30 | | - schedule: Required[Schedule] |
31 | | - """Run the monitor on a fixed interval defined by a frequency and a unit, e.g. |
32 | | -
|
33 | | - every 6 hours or every 2 days. The total interval (frequency × unit) must be |
34 | | - between 10 minutes and 1 year. |
35 | | - """ |
36 | | - |
37 | 27 | target: Required[Target] |
38 | 28 | """Discriminated union describing what the monitor watches.""" |
39 | 29 |
|
| 30 | + change_detection: ChangeDetection |
| 31 | + """Discriminated union describing how changes are detected.""" |
| 32 | + |
40 | 33 | mode: Literal["web"] |
41 | 34 | """Top-level monitor category. |
42 | 35 |
|
43 | 36 | Always `web` today; the concrete behavior is described by `target` and |
44 | 37 | `change_detection`. |
45 | 38 | """ |
46 | 39 |
|
47 | | - tags: SequenceNotStr[str] |
48 | | - """User-defined tags for grouping and filtering monitors and their changes. |
49 | | -
|
50 | | - Duplicates are removed. |
51 | | - """ |
52 | | - |
53 | | - webhook: Optional[Webhook] |
54 | | - |
55 | | - |
56 | | -class ChangeDetectionMonitorsExactChangeDetection(TypedDict, total=False): |
57 | | - """Detect exact changes. |
58 | | -
|
59 | | - For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals. |
60 | | - """ |
61 | | - |
62 | | - type: Required[Literal["exact"]] |
63 | | - |
64 | | - |
65 | | -class ChangeDetectionMonitorsSemanticChangeDetection(TypedDict, total=False): |
66 | | - """ |
67 | | - Detect meaning-level changes to tracked page content, ignoring cosmetic or paraphrase-only differences. Which changes are meaningful is judged against the extract target's `instructions` (and `schema`, when provided). |
68 | | - """ |
69 | | - |
70 | | - type: Required[Literal["semantic"]] |
71 | | - |
72 | | - confidence_threshold: float |
73 | | - |
74 | | - |
75 | | -ChangeDetection: TypeAlias = Union[ |
76 | | - ChangeDetectionMonitorsExactChangeDetection, ChangeDetectionMonitorsSemanticChangeDetection |
77 | | -] |
78 | | - |
79 | | - |
80 | | -class Schedule(TypedDict, total=False): |
| 40 | + schedule: Schedule |
81 | 41 | """Run the monitor on a fixed interval defined by a frequency and a unit, e.g. |
82 | 42 |
|
83 | | - every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year. |
| 43 | + every 6 hours or every 2 days. The total interval (frequency × unit) must be |
| 44 | + between 10 minutes and 1 year. |
84 | 45 | """ |
85 | 46 |
|
86 | | - frequency: Required[int] |
87 | | - """Number of units between runs. |
| 47 | + tags: SequenceNotStr[str] |
| 48 | + """User-defined tags for grouping and filtering monitors and their changes. |
88 | 49 |
|
89 | | - The resulting interval (frequency × unit) must be at least 10 minutes and at |
90 | | - most 1 year (e.g. minimum 10 when unit is minutes; maximum 365 when unit is |
91 | | - days). |
| 50 | + Duplicates are removed. |
92 | 51 | """ |
93 | 52 |
|
94 | | - type: Required[Literal["interval"]] |
95 | | - |
96 | | - unit: Required[Literal["minutes", "hours", "days"]] |
| 53 | + webhook: Optional[Webhook] |
97 | 54 |
|
98 | 55 |
|
99 | 56 | class TargetMonitorsPageTarget(TypedDict, total=False): |
@@ -169,6 +126,49 @@ class TargetMonitorsExtractTarget(TypedDict, total=False): |
169 | 126 | Target: TypeAlias = Union[TargetMonitorsPageTarget, TargetMonitorsSitemapTarget, TargetMonitorsExtractTarget] |
170 | 127 |
|
171 | 128 |
|
| 129 | +class ChangeDetectionMonitorsExactChangeDetection(TypedDict, total=False): |
| 130 | + """Detect exact changes. |
| 131 | +
|
| 132 | + For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals. |
| 133 | + """ |
| 134 | + |
| 135 | + type: Required[Literal["exact"]] |
| 136 | + |
| 137 | + |
| 138 | +class ChangeDetectionMonitorsSemanticChangeDetection(TypedDict, total=False): |
| 139 | + """ |
| 140 | + Detect meaning-level changes to tracked page content, ignoring cosmetic or paraphrase-only differences. Which changes are meaningful is judged against the extract target's `instructions` (and `schema`, when provided). |
| 141 | + """ |
| 142 | + |
| 143 | + type: Required[Literal["semantic"]] |
| 144 | + |
| 145 | + confidence_threshold: float |
| 146 | + |
| 147 | + |
| 148 | +ChangeDetection: TypeAlias = Union[ |
| 149 | + ChangeDetectionMonitorsExactChangeDetection, ChangeDetectionMonitorsSemanticChangeDetection |
| 150 | +] |
| 151 | + |
| 152 | + |
| 153 | +class Schedule(TypedDict, total=False): |
| 154 | + """Run the monitor on a fixed interval defined by a frequency and a unit, e.g. |
| 155 | +
|
| 156 | + every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year. |
| 157 | + """ |
| 158 | + |
| 159 | + frequency: Required[int] |
| 160 | + """Number of units between runs. |
| 161 | +
|
| 162 | + The resulting interval (frequency × unit) must be at least 10 minutes and at |
| 163 | + most 1 year (e.g. minimum 10 when unit is minutes; maximum 365 when unit is |
| 164 | + days). |
| 165 | + """ |
| 166 | + |
| 167 | + type: Required[Literal["interval"]] |
| 168 | + |
| 169 | + unit: Required[Literal["minutes", "hours", "days"]] |
| 170 | + |
| 171 | + |
172 | 172 | class Webhook(TypedDict, total=False): |
173 | 173 | url: Required[str] |
174 | 174 | """Webhook URL events are delivered to.""" |
|
0 commit comments