Skip to content

Commit b48d886

Browse files
author
stlc-bot
committed
feat(monitors): add page selector filters (#1037)
Stainless-Generated-From: 68ee80f
1 parent bd837b5 commit b48d886

7 files changed

Lines changed: 116 additions & 0 deletions

File tree

‎src/context/dev/types/monitor_create_params.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ class TargetMonitorsPageTarget(TypedDict, total=False):
6464

6565
url: Required[str]
6666

67+
exclude_selectors: SequenceNotStr[str]
68+
"""CSS selectors for HTML regions to remove before text extraction.
69+
70+
Applied after include_selectors; exclusion takes precedence when an element
71+
matches both. Omit or pass an empty array to apply no explicit exclusions.
72+
Changing these selectors creates a new baseline.
73+
"""
74+
75+
include_selectors: SequenceNotStr[str]
76+
"""CSS selectors defining the HTML regions to monitor.
77+
78+
Matching subtrees are combined in document order before text extraction, instead
79+
of automatic main-content selection. Omit or pass an empty array to use
80+
automatic main-content extraction. If the filtered page has no usable text, the
81+
run fails without replacing the baseline. Changing these selectors creates a new
82+
baseline.
83+
"""
84+
6785
instructions: str
6886
"""Plain-language goal describing which page changes matter.
6987

‎src/context/dev/types/monitor_create_response.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ class TargetMonitorsPageTarget(BaseModel):
8484

8585
url: str
8686

87+
exclude_selectors: Optional[List[str]] = None
88+
"""CSS selectors for HTML regions to remove before text extraction.
89+
90+
Applied after include_selectors; exclusion takes precedence when an element
91+
matches both. Omit or pass an empty array to apply no explicit exclusions.
92+
Changing these selectors creates a new baseline.
93+
"""
94+
95+
include_selectors: Optional[List[str]] = None
96+
"""CSS selectors defining the HTML regions to monitor.
97+
98+
Matching subtrees are combined in document order before text extraction, instead
99+
of automatic main-content selection. Omit or pass an empty array to use
100+
automatic main-content extraction. If the filtered page has no usable text, the
101+
run fails without replacing the baseline. Changing these selectors creates a new
102+
baseline.
103+
"""
104+
87105
instructions: Optional[str] = None
88106
"""Plain-language goal describing which page changes matter.
89107

‎src/context/dev/types/monitor_list_response.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ class DataTargetMonitorsPageTarget(BaseModel):
8585

8686
url: str
8787

88+
exclude_selectors: Optional[List[str]] = None
89+
"""CSS selectors for HTML regions to remove before text extraction.
90+
91+
Applied after include_selectors; exclusion takes precedence when an element
92+
matches both. Omit or pass an empty array to apply no explicit exclusions.
93+
Changing these selectors creates a new baseline.
94+
"""
95+
96+
include_selectors: Optional[List[str]] = None
97+
"""CSS selectors defining the HTML regions to monitor.
98+
99+
Matching subtrees are combined in document order before text extraction, instead
100+
of automatic main-content selection. Omit or pass an empty array to use
101+
automatic main-content extraction. If the filtered page has no usable text, the
102+
run fails without replacing the baseline. Changing these selectors creates a new
103+
baseline.
104+
"""
105+
88106
instructions: Optional[str] = None
89107
"""Plain-language goal describing which page changes matter.
90108

‎src/context/dev/types/monitor_retrieve_response.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ class TargetMonitorsPageTarget(BaseModel):
8484

8585
url: str
8686

87+
exclude_selectors: Optional[List[str]] = None
88+
"""CSS selectors for HTML regions to remove before text extraction.
89+
90+
Applied after include_selectors; exclusion takes precedence when an element
91+
matches both. Omit or pass an empty array to apply no explicit exclusions.
92+
Changing these selectors creates a new baseline.
93+
"""
94+
95+
include_selectors: Optional[List[str]] = None
96+
"""CSS selectors defining the HTML regions to monitor.
97+
98+
Matching subtrees are combined in document order before text extraction, instead
99+
of automatic main-content selection. Omit or pass an empty array to use
100+
automatic main-content extraction. If the filtered page has no usable text, the
101+
run fails without replacing the baseline. Changing these selectors creates a new
102+
baseline.
103+
"""
104+
87105
instructions: Optional[str] = None
88106
"""Plain-language goal describing which page changes matter.
89107

‎src/context/dev/types/monitor_update_params.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ class TargetMonitorsPageTarget(TypedDict, total=False):
103103

104104
url: Required[str]
105105

106+
exclude_selectors: SequenceNotStr[str]
107+
"""CSS selectors for HTML regions to remove before text extraction.
108+
109+
Applied after include_selectors; exclusion takes precedence when an element
110+
matches both. Omit or pass an empty array to apply no explicit exclusions.
111+
Changing these selectors creates a new baseline.
112+
"""
113+
114+
include_selectors: SequenceNotStr[str]
115+
"""CSS selectors defining the HTML regions to monitor.
116+
117+
Matching subtrees are combined in document order before text extraction, instead
118+
of automatic main-content selection. Omit or pass an empty array to use
119+
automatic main-content extraction. If the filtered page has no usable text, the
120+
run fails without replacing the baseline. Changing these selectors creates a new
121+
baseline.
122+
"""
123+
106124
instructions: str
107125
"""Plain-language goal describing which page changes matter.
108126

‎src/context/dev/types/monitor_update_response.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ class TargetMonitorsPageTarget(BaseModel):
8484

8585
url: str
8686

87+
exclude_selectors: Optional[List[str]] = None
88+
"""CSS selectors for HTML regions to remove before text extraction.
89+
90+
Applied after include_selectors; exclusion takes precedence when an element
91+
matches both. Omit or pass an empty array to apply no explicit exclusions.
92+
Changing these selectors creates a new baseline.
93+
"""
94+
95+
include_selectors: Optional[List[str]] = None
96+
"""CSS selectors defining the HTML regions to monitor.
97+
98+
Matching subtrees are combined in document order before text extraction, instead
99+
of automatic main-content selection. Omit or pass an empty array to use
100+
automatic main-content extraction. If the filtered page has no usable text, the
101+
run fails without replacing the baseline. Changing these selectors creates a new
102+
baseline.
103+
"""
104+
87105
instructions: Optional[str] = None
88106
"""Plain-language goal describing which page changes matter.
89107

‎tests/api_resources/test_monitors.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def test_method_create_with_all_params(self, client: ContextDev) -> None:
5252
target={
5353
"type": "page",
5454
"url": "https://acme.com/pricing",
55+
"exclude_selectors": [".carousel", '[id^="TA_"]'],
56+
"include_selectors": ["#attraction-details"],
5557
"instructions": "Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.",
5658
"normalize_whitespace": True,
5759
},
@@ -172,6 +174,8 @@ def test_method_update_with_all_params(self, client: ContextDev) -> None:
172174
target={
173175
"type": "page",
174176
"url": "https://acme.com/pricing",
177+
"exclude_selectors": [".carousel", '[id^="TA_"]'],
178+
"include_selectors": ["#attraction-details"],
175179
"instructions": "Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.",
176180
"normalize_whitespace": True,
177181
},
@@ -668,6 +672,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncContextDev
668672
target={
669673
"type": "page",
670674
"url": "https://acme.com/pricing",
675+
"exclude_selectors": [".carousel", '[id^="TA_"]'],
676+
"include_selectors": ["#attraction-details"],
671677
"instructions": "Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.",
672678
"normalize_whitespace": True,
673679
},
@@ -788,6 +794,8 @@ async def test_method_update_with_all_params(self, async_client: AsyncContextDev
788794
target={
789795
"type": "page",
790796
"url": "https://acme.com/pricing",
797+
"exclude_selectors": [".carousel", '[id^="TA_"]'],
798+
"include_selectors": ["#attraction-details"],
791799
"instructions": "Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.",
792800
"normalize_whitespace": True,
793801
},

0 commit comments

Comments
 (0)