context.dev 2.19.0 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,6 +22,18 @@ module ContextDev
22
22
  sig { returns(String) }
23
23
  attr_accessor :url
24
24
 
25
+ # Highlight options. Requires formats.highlights: true.
26
+ sig { returns(T.nilable(ContextDev::WebScrapeParams::HighlightsParams)) }
27
+ attr_reader :highlights_params
28
+
29
+ sig do
30
+ params(
31
+ highlights_params:
32
+ ContextDev::WebScrapeParams::HighlightsParams::OrHash
33
+ ).void
34
+ end
35
+ attr_writer :highlights_params
36
+
25
37
  # Image options. Requires formats.images: true.
26
38
  sig { returns(T.nilable(ContextDev::WebScrapeParams::ImageParams)) }
27
39
  attr_reader :image_params
@@ -33,6 +45,17 @@ module ContextDev
33
45
  end
34
46
  attr_writer :image_params
35
47
 
48
+ # Required when formats.json is true.
49
+ sig { returns(T.nilable(ContextDev::WebScrapeParams::JsonParams)) }
50
+ attr_reader :json_params
51
+
52
+ sig do
53
+ params(
54
+ json_params: ContextDev::WebScrapeParams::JsonParams::OrHash
55
+ ).void
56
+ end
57
+ attr_writer :json_params
58
+
36
59
  # Markdown options. Requires formats.markdown: true.
37
60
  sig { returns(T.nilable(ContextDev::WebScrapeParams::MarkdownParams)) }
38
61
  attr_reader :markdown_params
@@ -65,6 +88,17 @@ module ContextDev
65
88
  end
66
89
  attr_writer :parse_params
67
90
 
91
+ # Product options. Requires formats.product: true.
92
+ sig { returns(T.nilable(ContextDev::WebScrapeParams::ProductParams)) }
93
+ attr_reader :product_params
94
+
95
+ sig do
96
+ params(
97
+ product_params: ContextDev::WebScrapeParams::ProductParams::OrHash
98
+ ).void
99
+ end
100
+ attr_writer :product_params
101
+
68
102
  # Screenshot options. Requires formats.screenshot: true.
69
103
  sig { returns(T.nilable(ContextDev::WebScrapeParams::ScreenshotParams)) }
70
104
  attr_reader :screenshot_params
@@ -114,7 +148,8 @@ module ContextDev
114
148
  attr_writer :timeout_opts
115
149
 
116
150
  # Zero data retention. Bypasses caches and uploads; excludes request/response
117
- # content and tags from logs. Must be enabled for your organization.
151
+ # content and tags from logs. Must be enabled for your organization. Not available
152
+ # with the highlights output.
118
153
  sig { returns(T.nilable(ContextDev::WebScrapeParams::Zdr::OrSymbol)) }
119
154
  attr_reader :zdr
120
155
 
@@ -125,10 +160,14 @@ module ContextDev
125
160
  params(
126
161
  formats: ContextDev::WebScrapeParams::Formats::OrHash,
127
162
  url: String,
163
+ highlights_params:
164
+ ContextDev::WebScrapeParams::HighlightsParams::OrHash,
128
165
  image_params: ContextDev::WebScrapeParams::ImageParams::OrHash,
166
+ json_params: ContextDev::WebScrapeParams::JsonParams::OrHash,
129
167
  markdown_params: ContextDev::WebScrapeParams::MarkdownParams::OrHash,
130
168
  max_age_ms: Integer,
131
169
  parse_params: ContextDev::WebScrapeParams::ParseParams::OrHash,
170
+ product_params: ContextDev::WebScrapeParams::ProductParams::OrHash,
132
171
  screenshot_params:
133
172
  ContextDev::WebScrapeParams::ScreenshotParams::OrHash,
134
173
  shared_params: ContextDev::WebScrapeParams::SharedParams::OrHash,
@@ -143,8 +182,12 @@ module ContextDev
143
182
  formats:,
144
183
  # The URL to scrape.
145
184
  url:,
185
+ # Highlight options. Requires formats.highlights: true.
186
+ highlights_params: nil,
146
187
  # Image options. Requires formats.images: true.
147
188
  image_params: nil,
189
+ # Required when formats.json is true.
190
+ json_params: nil,
148
191
  # Markdown options. Requires formats.markdown: true.
149
192
  markdown_params: nil,
150
193
  # Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and
@@ -154,6 +197,8 @@ module ContextDev
154
197
  max_age_ms: nil,
155
198
  # Required when formats.parse is true.
156
199
  parse_params: nil,
200
+ # Product options. Requires formats.product: true.
201
+ product_params: nil,
157
202
  # Screenshot options. Requires formats.screenshot: true.
158
203
  screenshot_params: nil,
159
204
  # Shared browser and content settings. Content filters leave screenshots and
@@ -170,7 +215,8 @@ module ContextDev
170
215
  # when using return-partial.
171
216
  timeout_opts: nil,
172
217
  # Zero data retention. Bypasses caches and uploads; excludes request/response
173
- # content and tags from logs. Must be enabled for your organization.
218
+ # content and tags from logs. Must be enabled for your organization. Not available
219
+ # with the highlights output.
174
220
  zdr: nil,
175
221
  request_options: {}
176
222
  )
@@ -181,10 +227,13 @@ module ContextDev
181
227
  {
182
228
  formats: ContextDev::WebScrapeParams::Formats,
183
229
  url: String,
230
+ highlights_params: ContextDev::WebScrapeParams::HighlightsParams,
184
231
  image_params: ContextDev::WebScrapeParams::ImageParams,
232
+ json_params: ContextDev::WebScrapeParams::JsonParams,
185
233
  markdown_params: ContextDev::WebScrapeParams::MarkdownParams,
186
234
  max_age_ms: Integer,
187
235
  parse_params: ContextDev::WebScrapeParams::ParseParams,
236
+ product_params: ContextDev::WebScrapeParams::ProductParams,
188
237
  screenshot_params: ContextDev::WebScrapeParams::ScreenshotParams,
189
238
  shared_params: ContextDev::WebScrapeParams::SharedParams,
190
239
  tags: T::Array[String],
@@ -213,6 +262,15 @@ module ContextDev
213
262
  sig { params(bytes: T::Boolean).void }
214
263
  attr_writer :bytes
215
264
 
265
+ # Plain-text passages from the page that are most relevant to
266
+ # highlightsParams.query, each prefixed with its section heading. Adds 3 credits.
267
+ # Not available with zdr enabled.
268
+ sig { returns(T.nilable(T::Boolean)) }
269
+ attr_reader :highlights
270
+
271
+ sig { params(highlights: T::Boolean).void }
272
+ attr_writer :highlights
273
+
216
274
  # Rendered HTML.
217
275
  sig { returns(T.nilable(T::Boolean)) }
218
276
  attr_reader :html
@@ -227,6 +285,16 @@ module ContextDev
227
285
  sig { params(images: T::Boolean).void }
228
286
  attr_writer :images
229
287
 
288
+ # Page data extracted by an LLM from the page Markdown into jsonParams.schema;
289
+ # values carried only in attributes or CSS classes need formats.parse instead.
290
+ # Adds four credits when the page has text to extract; when shared content filters
291
+ # leave no text the result is an empty object and only the base price applies.
292
+ sig { returns(T.nilable(T::Boolean)) }
293
+ attr_reader :json
294
+
295
+ sig { params(json: T::Boolean).void }
296
+ attr_writer :json
297
+
230
298
  # Page content as Markdown.
231
299
  sig { returns(T.nilable(T::Boolean)) }
232
300
  attr_reader :markdown
@@ -241,6 +309,13 @@ module ContextDev
241
309
  sig { params(parse: T::Boolean).void }
242
310
  attr_writer :parse
243
311
 
312
+ # Structured product data for product detail pages. Adds one credit.
313
+ sig { returns(T.nilable(T::Boolean)) }
314
+ attr_reader :product
315
+
316
+ sig { params(product: T::Boolean).void }
317
+ attr_writer :product
318
+
244
319
  # An inline image of the page.
245
320
  sig { returns(T.nilable(T::Boolean)) }
246
321
  attr_reader :screenshot
@@ -252,24 +327,38 @@ module ContextDev
252
327
  sig do
253
328
  params(
254
329
  bytes: T::Boolean,
330
+ highlights: T::Boolean,
255
331
  html: T::Boolean,
256
332
  images: T::Boolean,
333
+ json: T::Boolean,
257
334
  markdown: T::Boolean,
258
335
  parse: T::Boolean,
336
+ product: T::Boolean,
259
337
  screenshot: T::Boolean
260
338
  ).returns(T.attached_class)
261
339
  end
262
340
  def self.new(
263
341
  # The original HTTP response body.
264
342
  bytes: nil,
343
+ # Plain-text passages from the page that are most relevant to
344
+ # highlightsParams.query, each prefixed with its section heading. Adds 3 credits.
345
+ # Not available with zdr enabled.
346
+ highlights: nil,
265
347
  # Rendered HTML.
266
348
  html: nil,
267
349
  # Images found on the page.
268
350
  images: nil,
351
+ # Page data extracted by an LLM from the page Markdown into jsonParams.schema;
352
+ # values carried only in attributes or CSS classes need formats.parse instead.
353
+ # Adds four credits when the page has text to extract; when shared content filters
354
+ # leave no text the result is an empty object and only the base price applies.
355
+ json: nil,
269
356
  # Page content as Markdown.
270
357
  markdown: nil,
271
358
  # Fields selected by parseParams.rules.
272
359
  parse: nil,
360
+ # Structured product data for product detail pages. Adds one credit.
361
+ product: nil,
273
362
  # An inline image of the page.
274
363
  screenshot: nil
275
364
  )
@@ -279,10 +368,13 @@ module ContextDev
279
368
  override.returns(
280
369
  {
281
370
  bytes: T::Boolean,
371
+ highlights: T::Boolean,
282
372
  html: T::Boolean,
283
373
  images: T::Boolean,
374
+ json: T::Boolean,
284
375
  markdown: T::Boolean,
285
376
  parse: T::Boolean,
377
+ product: T::Boolean,
286
378
  screenshot: T::Boolean
287
379
  }
288
380
  )
@@ -291,6 +383,45 @@ module ContextDev
291
383
  end
292
384
  end
293
385
 
386
+ class HighlightsParams < ContextDev::Internal::Type::BaseModel
387
+ OrHash =
388
+ T.type_alias do
389
+ T.any(
390
+ ContextDev::WebScrapeParams::HighlightsParams,
391
+ ContextDev::Internal::AnyHash
392
+ )
393
+ end
394
+
395
+ # The question or topic to find passages for.
396
+ sig { returns(String) }
397
+ attr_accessor :query
398
+
399
+ # Maximum combined length of the returned passages, in characters.
400
+ sig { returns(T.nilable(Integer)) }
401
+ attr_reader :max_characters
402
+
403
+ sig { params(max_characters: Integer).void }
404
+ attr_writer :max_characters
405
+
406
+ # Highlight options. Requires formats.highlights: true.
407
+ sig do
408
+ params(query: String, max_characters: Integer).returns(
409
+ T.attached_class
410
+ )
411
+ end
412
+ def self.new(
413
+ # The question or topic to find passages for.
414
+ query:,
415
+ # Maximum combined length of the returned passages, in characters.
416
+ max_characters: nil
417
+ )
418
+ end
419
+
420
+ sig { override.returns({ query: String, max_characters: Integer }) }
421
+ def to_hash
422
+ end
423
+ end
424
+
294
425
  class ImageParams < ContextDev::Internal::Type::BaseModel
295
426
  OrHash =
296
427
  T.type_alias do
@@ -445,6 +576,60 @@ module ContextDev
445
576
  end
446
577
  end
447
578
 
579
+ class JsonParams < ContextDev::Internal::Type::BaseModel
580
+ OrHash =
581
+ T.type_alias do
582
+ T.any(
583
+ ContextDev::WebScrapeParams::JsonParams,
584
+ ContextDev::Internal::AnyHash
585
+ )
586
+ end
587
+
588
+ # JSON Schema for the returned object. Must describe a top-level object; at most
589
+ # 50 KB serialized. Optional fields the page does not state are omitted, or null
590
+ # when their type allows null, while required non-nullable fields always receive a
591
+ # best-effort value, so prefer nullable or optional fields for data a page may
592
+ # omit. Zod users can pass the output of z.toJSONSchema().
593
+ sig { returns(T::Hash[Symbol, T.anything]) }
594
+ attr_accessor :schema
595
+
596
+ # Optional guidance on which facts to prioritize or how to interpret schema
597
+ # fields.
598
+ sig { returns(T.nilable(String)) }
599
+ attr_reader :instructions
600
+
601
+ sig { params(instructions: String).void }
602
+ attr_writer :instructions
603
+
604
+ # Required when formats.json is true.
605
+ sig do
606
+ params(
607
+ schema: T::Hash[Symbol, T.anything],
608
+ instructions: String
609
+ ).returns(T.attached_class)
610
+ end
611
+ def self.new(
612
+ # JSON Schema for the returned object. Must describe a top-level object; at most
613
+ # 50 KB serialized. Optional fields the page does not state are omitted, or null
614
+ # when their type allows null, while required non-nullable fields always receive a
615
+ # best-effort value, so prefer nullable or optional fields for data a page may
616
+ # omit. Zod users can pass the output of z.toJSONSchema().
617
+ schema:,
618
+ # Optional guidance on which facts to prioritize or how to interpret schema
619
+ # fields.
620
+ instructions: nil
621
+ )
622
+ end
623
+
624
+ sig do
625
+ override.returns(
626
+ { schema: T::Hash[Symbol, T.anything], instructions: String }
627
+ )
628
+ end
629
+ def to_hash
630
+ end
631
+ end
632
+
448
633
  class MarkdownParams < ContextDev::Internal::Type::BaseModel
449
634
  OrHash =
450
635
  T.type_alias do
@@ -798,6 +983,41 @@ module ContextDev
798
983
  end
799
984
  end
800
985
 
986
+ class ProductParams < ContextDev::Internal::Type::BaseModel
987
+ OrHash =
988
+ T.type_alias do
989
+ T.any(
990
+ ContextDev::WebScrapeParams::ProductParams,
991
+ ContextDev::Internal::AnyHash
992
+ )
993
+ end
994
+
995
+ # Extract the product with a specialized model when the page has no structured
996
+ # product data. Adds six credits when the model returns a verdict. If the fallback
997
+ # fails, returns a partial response with the deterministic result and no fallback
998
+ # charge. Request deadlines and client disconnects still apply.
999
+ sig { returns(T.nilable(T::Boolean)) }
1000
+ attr_reader :use_ai_fallback
1001
+
1002
+ sig { params(use_ai_fallback: T::Boolean).void }
1003
+ attr_writer :use_ai_fallback
1004
+
1005
+ # Product options. Requires formats.product: true.
1006
+ sig { params(use_ai_fallback: T::Boolean).returns(T.attached_class) }
1007
+ def self.new(
1008
+ # Extract the product with a specialized model when the page has no structured
1009
+ # product data. Adds six credits when the model returns a verdict. If the fallback
1010
+ # fails, returns a partial response with the deterministic result and no fallback
1011
+ # charge. Request deadlines and client disconnects still apply.
1012
+ use_ai_fallback: nil
1013
+ )
1014
+ end
1015
+
1016
+ sig { override.returns({ use_ai_fallback: T::Boolean }) }
1017
+ def to_hash
1018
+ end
1019
+ end
1020
+
801
1021
  class ScreenshotParams < ContextDev::Internal::Type::BaseModel
802
1022
  OrHash =
803
1023
  T.type_alias do
@@ -1974,7 +2194,8 @@ module ContextDev
1974
2194
  end
1975
2195
 
1976
2196
  # Zero data retention. Bypasses caches and uploads; excludes request/response
1977
- # content and tags from logs. Must be enabled for your organization.
2197
+ # content and tags from logs. Must be enabled for your organization. Not available
2198
+ # with the highlights output.
1978
2199
  module Zdr
1979
2200
  extend ContextDev::Internal::Type::Enum
1980
2201