Skip to content

Commit d2a0ffb

Browse files
author
stlc-bot
committed
fix(openapi): keep legacy batch inputs in the spec as deprecated (#2225)
feat(access-policies): limit which websites API requests can reach (#2213) feat(brand): support log-free brand and styleguide requests (#2231) fix(brand): keep metadata-only usage logs for ZDR brand requests (#2234) feat(monitors): add search target to watch the web for new developments (#2215) Stainless-Generated-From: e9cdf82d83cd475d9dc2cd5ede9284207a0559f9
1 parent 5daf298 commit d2a0ffb

16 files changed

Lines changed: 396 additions & 77 deletions

‎src/context/dev/resources/monitors.py‎

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ def create(
9696
Args:
9797
name: Display name for the monitor.
9898
99-
target: What to watch: a page, a sitemap, or data extracted from a site.
99+
target: What to watch: a page, a sitemap, data extracted from a site, or web search
100+
results.
100101
101-
change_detection: How changes are judged. Defaults to `semantic` for extract targets and page
102-
targets with `instructions`, otherwise `exact`.
102+
change_detection: How changes are judged. Defaults to `semantic` for extract and search targets
103+
and page targets with `instructions`, otherwise `exact`.
103104
104105
mode: Always `web`. Optional.
105106
@@ -204,8 +205,8 @@ def update(
204205
Args:
205206
monitor_id: ID of the monitor.
206207
207-
change_detection: How changes are judged. Defaults to `semantic` for extract targets and page
208-
targets with `instructions`, otherwise `exact`.
208+
change_detection: How changes are judged. Defaults to `semantic` for extract and search targets
209+
and page targets with `instructions`, otherwise `exact`.
209210
210211
name: Display name for the monitor.
211212
@@ -219,7 +220,8 @@ def update(
219220
220221
tags: Labels for filtering monitors, their changes, and their usage.
221222
222-
target: What to watch: a page, a sitemap, or data extracted from a site.
223+
target: What to watch: a page, a sitemap, data extracted from a site, or web search
224+
results.
223225
224226
webhook: Set to null to remove the webhook. Changing `url` issues a new secret.
225227
@@ -266,7 +268,7 @@ def list(
266268
status: Literal["active", "paused", "failed"] | Omit = omit,
267269
tag: str | Omit = omit,
268270
tags: Optional[SequenceNotStr[str]] | Omit = omit,
269-
target_type: Literal["page", "sitemap", "extract"] | Omit = omit,
271+
target_type: Literal["page", "sitemap", "extract", "search"] | Omit = omit,
270272
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
271273
# The extra values given here take precedence over values defined on the client or passed to this method.
272274
extra_headers: Headers | None = None,
@@ -286,8 +288,8 @@ def list(
286288
287289
q: Free-text search term, matched against the fields named in `search_by`.
288290
289-
search_by: Fields to search with `q`. Defaults to all fields; page and extract targets can
290-
have instructions.
291+
search_by: Fields to search with `q`. Defaults to all fields; page, extract, and search
292+
targets can have instructions, and `url` matches a search target’s query.
291293
292294
search_type: `prefix` for as-you-type prefix matching (default), `exact` for full-token
293295
matching.
@@ -444,7 +446,7 @@ def list_account_changes(
444446
monitor_id: str | Omit = omit,
445447
since: Union[str, datetime] | Omit = omit,
446448
tag: str | Omit = omit,
447-
target_type: Literal["page", "sitemap", "extract"] | Omit = omit,
449+
target_type: Literal["page", "sitemap", "extract", "search"] | Omit = omit,
448450
until: Union[str, datetime] | Omit = omit,
449451
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
450452
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -870,10 +872,11 @@ async def create(
870872
Args:
871873
name: Display name for the monitor.
872874
873-
target: What to watch: a page, a sitemap, or data extracted from a site.
875+
target: What to watch: a page, a sitemap, data extracted from a site, or web search
876+
results.
874877
875-
change_detection: How changes are judged. Defaults to `semantic` for extract targets and page
876-
targets with `instructions`, otherwise `exact`.
878+
change_detection: How changes are judged. Defaults to `semantic` for extract and search targets
879+
and page targets with `instructions`, otherwise `exact`.
877880
878881
mode: Always `web`. Optional.
879882
@@ -978,8 +981,8 @@ async def update(
978981
Args:
979982
monitor_id: ID of the monitor.
980983
981-
change_detection: How changes are judged. Defaults to `semantic` for extract targets and page
982-
targets with `instructions`, otherwise `exact`.
984+
change_detection: How changes are judged. Defaults to `semantic` for extract and search targets
985+
and page targets with `instructions`, otherwise `exact`.
983986
984987
name: Display name for the monitor.
985988
@@ -993,7 +996,8 @@ async def update(
993996
994997
tags: Labels for filtering monitors, their changes, and their usage.
995998
996-
target: What to watch: a page, a sitemap, or data extracted from a site.
999+
target: What to watch: a page, a sitemap, data extracted from a site, or web search
1000+
results.
9971001
9981002
webhook: Set to null to remove the webhook. Changing `url` issues a new secret.
9991003
@@ -1040,7 +1044,7 @@ async def list(
10401044
status: Literal["active", "paused", "failed"] | Omit = omit,
10411045
tag: str | Omit = omit,
10421046
tags: Optional[SequenceNotStr[str]] | Omit = omit,
1043-
target_type: Literal["page", "sitemap", "extract"] | Omit = omit,
1047+
target_type: Literal["page", "sitemap", "extract", "search"] | Omit = omit,
10441048
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
10451049
# The extra values given here take precedence over values defined on the client or passed to this method.
10461050
extra_headers: Headers | None = None,
@@ -1060,8 +1064,8 @@ async def list(
10601064
10611065
q: Free-text search term, matched against the fields named in `search_by`.
10621066
1063-
search_by: Fields to search with `q`. Defaults to all fields; page and extract targets can
1064-
have instructions.
1067+
search_by: Fields to search with `q`. Defaults to all fields; page, extract, and search
1068+
targets can have instructions, and `url` matches a search target’s query.
10651069
10661070
search_type: `prefix` for as-you-type prefix matching (default), `exact` for full-token
10671071
matching.
@@ -1218,7 +1222,7 @@ async def list_account_changes(
12181222
monitor_id: str | Omit = omit,
12191223
since: Union[str, datetime] | Omit = omit,
12201224
tag: str | Omit = omit,
1221-
target_type: Literal["page", "sitemap", "extract"] | Omit = omit,
1225+
target_type: Literal["page", "sitemap", "extract", "search"] | Omit = omit,
12221226
until: Union[str, datetime] | Omit = omit,
12231227
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
12241228
# The extra values given here take precedence over values defined on the client or passed to this method.

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"TargetMonitorsPageTargetActionWebScrapeScrollAction",
2020
"TargetMonitorsSitemapTarget",
2121
"TargetMonitorsExtractTarget",
22+
"TargetMonitorsSearchTarget",
2223
"ChangeDetection",
2324
"ChangeDetectionMonitorsExactChangeDetection",
2425
"ChangeDetectionMonitorsSemanticChangeDetection",
@@ -32,13 +33,16 @@ class MonitorCreateParams(TypedDict, total=False):
3233
"""Display name for the monitor."""
3334

3435
target: Required[Target]
35-
"""What to watch: a page, a sitemap, or data extracted from a site."""
36+
"""
37+
What to watch: a page, a sitemap, data extracted from a site, or web search
38+
results.
39+
"""
3640

3741
change_detection: ChangeDetection
3842
"""How changes are judged.
3943
40-
Defaults to `semantic` for extract targets and page targets with `instructions`,
41-
otherwise `exact`.
44+
Defaults to `semantic` for extract and search targets and page targets with
45+
`instructions`, otherwise `exact`.
4246
"""
4347

4448
mode: Literal["web"]
@@ -205,17 +209,37 @@ class TargetMonitorsExtractTarget(TypedDict, total=False):
205209
"""
206210

207211

208-
Target: TypeAlias = Union[TargetMonitorsPageTarget, TargetMonitorsSitemapTarget, TargetMonitorsExtractTarget]
212+
class TargetMonitorsSearchTarget(TypedDict, total=False):
213+
"""
214+
Search the web on every run and report results not seen before, listed in the change’s `matched_urls` and `evidence`. Semantic detection reports only results describing a new development that matches `instructions`; exact detection reports every new result.
215+
"""
216+
217+
query: Required[str]
218+
"""Web search query to run on every check.
219+
220+
Supports operators such as `site:`, `-site:`, and quoted phrases.
221+
"""
222+
223+
type: Required[Literal["search"]]
224+
"""Use `search` to watch the whole web for new results about a topic."""
225+
226+
instructions: str
227+
"""Plain-language description of which new results matter. Defaults to the query."""
228+
229+
230+
Target: TypeAlias = Union[
231+
TargetMonitorsPageTarget, TargetMonitorsSitemapTarget, TargetMonitorsExtractTarget, TargetMonitorsSearchTarget
232+
]
209233

210234

211235
class ChangeDetectionMonitorsExactChangeDetection(TypedDict, total=False):
212236
"""Detect exact changes.
213237
214-
For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals.
238+
For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals. For search targets, this means every new result.
215239
"""
216240

217241
type: Required[Literal["exact"]]
218-
"""Use `exact` to compare visible text or sitemap URLs."""
242+
"""Use `exact` to compare visible text, sitemap URLs, or search results."""
219243

220244

221245
class ChangeDetectionMonitorsSemanticChangeDetection(TypedDict, total=False):

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

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323
"TargetMonitorsPageTargetActionWebScrapeScrollAction",
2424
"TargetMonitorsSitemapTarget",
2525
"TargetMonitorsExtractTarget",
26+
"TargetMonitorsSearchTarget",
2627
"Baseline",
2728
"BaselineMonitorsPageBaseline",
2829
"BaselineMonitorsSitemapBaseline",
2930
"BaselineMonitorsExtractBaseline",
31+
"BaselineMonitorsSearchBaseline",
32+
"BaselineMonitorsSearchBaselineResult",
3033
"KeyMetadata",
3134
"LastError",
3235
"Schedule",
@@ -38,11 +41,11 @@
3841
class ChangeDetectionMonitorsExactChangeDetection(BaseModel):
3942
"""Detect exact changes.
4043
41-
For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals.
44+
For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals. For search targets, this means every new result.
4245
"""
4346

4447
type: Literal["exact"]
45-
"""Use `exact` to compare visible text or sitemap URLs."""
48+
"""Use `exact` to compare visible text, sitemap URLs, or search results."""
4649

4750

4851
class ChangeDetectionMonitorsSemanticChangeDetection(BaseModel):
@@ -210,8 +213,28 @@ class TargetMonitorsExtractTarget(BaseModel):
210213
"""
211214

212215

216+
class TargetMonitorsSearchTarget(BaseModel):
217+
"""
218+
Search the web on every run and report results not seen before, listed in the change’s `matched_urls` and `evidence`. Semantic detection reports only results describing a new development that matches `instructions`; exact detection reports every new result.
219+
"""
220+
221+
query: str
222+
"""Web search query to run on every check.
223+
224+
Supports operators such as `site:`, `-site:`, and quoted phrases.
225+
"""
226+
227+
type: Literal["search"]
228+
"""Use `search` to watch the whole web for new results about a topic."""
229+
230+
instructions: Optional[str] = None
231+
"""Plain-language description of which new results matter. Defaults to the query."""
232+
233+
213234
Target: TypeAlias = Annotated[
214-
Union[TargetMonitorsPageTarget, TargetMonitorsSitemapTarget, TargetMonitorsExtractTarget],
235+
Union[
236+
TargetMonitorsPageTarget, TargetMonitorsSitemapTarget, TargetMonitorsExtractTarget, TargetMonitorsSearchTarget
237+
],
215238
PropertyInfo(discriminator="type"),
216239
]
217240

@@ -259,8 +282,34 @@ class BaselineMonitorsExtractBaseline(BaseModel):
259282
"""The page URLs the monitor tracks and analyzes for changes."""
260283

261284

285+
class BaselineMonitorsSearchBaselineResult(BaseModel):
286+
description: str
287+
"""Result snippet."""
288+
289+
published_at: Optional[datetime] = None
290+
"""When the result was published, when known."""
291+
292+
title: str
293+
294+
url: str
295+
296+
297+
class BaselineMonitorsSearchBaseline(BaseModel):
298+
"""Current baseline of a `search` monitor: the search results as last observed."""
299+
300+
captured_at: datetime
301+
"""When this baseline was last captured or replaced."""
302+
303+
results: List[BaselineMonitorsSearchBaselineResult]
304+
"""Search results as last observed."""
305+
306+
262307
Baseline: TypeAlias = Union[
263-
BaselineMonitorsPageBaseline, BaselineMonitorsSitemapBaseline, BaselineMonitorsExtractBaseline, None
308+
BaselineMonitorsPageBaseline,
309+
BaselineMonitorsSitemapBaseline,
310+
BaselineMonitorsExtractBaseline,
311+
BaselineMonitorsSearchBaseline,
312+
None,
264313
]
265314

266315

@@ -355,8 +404,8 @@ class MonitorCreateResponse(BaseModel):
355404
change_detection: ChangeDetection
356405
"""How changes are judged.
357406
358-
Defaults to `semantic` for extract targets and page targets with `instructions`,
359-
otherwise `exact`.
407+
Defaults to `semantic` for extract and search targets and page targets with
408+
`instructions`, otherwise `exact`.
360409
"""
361410

362411
created_at: datetime
@@ -386,7 +435,10 @@ class MonitorCreateResponse(BaseModel):
386435
"""
387436

388437
target: Target
389-
"""What to watch: a page, a sitemap, or data extracted from a site."""
438+
"""
439+
What to watch: a page, a sitemap, data extracted from a site, or web search
440+
results.
441+
"""
390442

391443
updated_at: datetime
392444

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MonitorListAccountChangesParams(TypedDict, total=False):
3030
tag: str
3131
"""Filter to items that have this tag."""
3232

33-
target_type: Literal["page", "sitemap", "extract"]
33+
target_type: Literal["page", "sitemap", "extract", "search"]
3434
"""Filter by target type."""
3535

3636
until: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ class Data(BaseModel):
4242
tags: List[str]
4343
"""Labels for filtering monitors, their changes, and their usage."""
4444

45-
target_type: Literal["page", "sitemap", "extract"]
45+
target_type: Literal["page", "sitemap", "extract", "search"]
4646

4747
title: str
4848

4949
url: str
50+
"""The monitored URL. For search targets, the first newly reported result."""
5051

5152
added_url_count: Optional[int] = None
5253

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Data(BaseModel):
4444
paused, or superseded by a concurrent run).
4545
"""
4646

47-
target_type: Literal["page", "sitemap", "extract"]
47+
target_type: Literal["page", "sitemap", "extract", "search"]
4848

4949
change_id: Optional[str] = None
5050

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ class Data(BaseModel):
4242
tags: List[str]
4343
"""Labels for filtering monitors, their changes, and their usage."""
4444

45-
target_type: Literal["page", "sitemap", "extract"]
45+
target_type: Literal["page", "sitemap", "extract", "search"]
4646

4747
title: str
4848

4949
url: str
50+
"""The monitored URL. For search targets, the first newly reported result."""
5051

5152
added_url_count: Optional[int] = None
5253

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class MonitorListParams(TypedDict, total=False):
2626
search_by: Optional[List[Literal["name", "url", "instructions", "tags"]]]
2727
"""Fields to search with `q`.
2828
29-
Defaults to all fields; page and extract targets can have instructions.
29+
Defaults to all fields; page, extract, and search targets can have instructions,
30+
and `url` matches a search target’s query.
3031
"""
3132

3233
search_type: Literal["exact", "prefix"]
@@ -46,5 +47,5 @@ class MonitorListParams(TypedDict, total=False):
4647
Comma-separated list of tags to filter by (matches monitors having any of them).
4748
"""
4849

49-
target_type: Literal["page", "sitemap", "extract"]
50+
target_type: Literal["page", "sitemap", "extract", "search"]
5051
"""Filter by target type."""

0 commit comments

Comments
 (0)