context.dev 2.19.0 → 2.21.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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +219 -0
  3. data/README.md +1 -1
  4. data/lib/context_dev/client.rb +6 -0
  5. data/lib/context_dev/models/feedback_submit_params.rb +73 -0
  6. data/lib/context_dev/models/feedback_submit_response.rb +68 -0
  7. data/lib/context_dev/models/news_search_params.rb +13 -6
  8. data/lib/context_dev/models/web_scrape_params.rb +149 -14
  9. data/lib/context_dev/models/web_scrape_response.rb +404 -12
  10. data/lib/context_dev/models.rb +2 -0
  11. data/lib/context_dev/resources/feedback.rb +50 -0
  12. data/lib/context_dev/resources/news.rb +8 -4
  13. data/lib/context_dev/resources/web.rb +26 -8
  14. data/lib/context_dev/version.rb +1 -1
  15. data/lib/context_dev.rb +3 -0
  16. data/rbi/context_dev/client.rbi +5 -0
  17. data/rbi/context_dev/models/feedback_submit_params.rbi +133 -0
  18. data/rbi/context_dev/models/feedback_submit_response.rbi +122 -0
  19. data/rbi/context_dev/models/news_search_params.rbi +12 -6
  20. data/rbi/context_dev/models/web_scrape_params.rbi +248 -18
  21. data/rbi/context_dev/models/web_scrape_response.rbi +702 -30
  22. data/rbi/context_dev/models.rbi +2 -0
  23. data/rbi/context_dev/resources/feedback.rbi +42 -0
  24. data/rbi/context_dev/resources/news.rbi +7 -4
  25. data/rbi/context_dev/resources/web.rbi +38 -12
  26. data/sig/context_dev/client.rbs +2 -0
  27. data/sig/context_dev/models/feedback_submit_params.rbs +73 -0
  28. data/sig/context_dev/models/feedback_submit_response.rbs +58 -0
  29. data/sig/context_dev/models/web_scrape_params.rbs +91 -0
  30. data/sig/context_dev/models/web_scrape_response.rbs +302 -18
  31. data/sig/context_dev/models.rbs +2 -0
  32. data/sig/context_dev/resources/feedback.rbs +16 -0
  33. data/sig/context_dev/resources/web.rbs +3 -0
  34. metadata +11 -2
@@ -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
@@ -97,12 +131,16 @@ module ContextDev
97
131
  attr_writer :tags
98
132
 
99
133
  # Total deadline, including navigation, actions, waiting, and all outputs.
100
- # Defaults to 60000 milliseconds with behavior fail. Use return-partial to capture
101
- # the current page state and return captured images if image processing cannot
102
- # finish before the deadline; these responses set isPartial and are not cached.
103
- # Every requested format must still be available. Fixed waits must fit before a
104
- # response reserve of up to 5000 milliseconds (at most one quarter of the timeout)
105
- # when using return-partial.
134
+ # Defaults to 60000 milliseconds with behavior fail. Individual outputs have
135
+ # internal deadlines that reserve time to return completed outputs; timed-out
136
+ # outputs have success: false and data: null under either behavior. The overall
137
+ # request deadline remains enforced: fail returns an error if that deadline is
138
+ # reached. Use return-partial to allow the current page state and available
139
+ # outputs when the page is still loading. Partial responses set isPartial. Failed
140
+ # retrievals and incomplete captures are not cached; valid captured pieces may be
141
+ # cached independently. Fixed waits must fit before a response reserve of up to
142
+ # 5000 milliseconds (at most one quarter of the timeout) when using
143
+ # return-partial.
106
144
  sig { returns(T.nilable(ContextDev::WebScrapeParams::TimeoutOpts)) }
107
145
  attr_reader :timeout_opts
108
146
 
@@ -125,10 +163,14 @@ module ContextDev
125
163
  params(
126
164
  formats: ContextDev::WebScrapeParams::Formats::OrHash,
127
165
  url: String,
166
+ highlights_params:
167
+ ContextDev::WebScrapeParams::HighlightsParams::OrHash,
128
168
  image_params: ContextDev::WebScrapeParams::ImageParams::OrHash,
169
+ json_params: ContextDev::WebScrapeParams::JsonParams::OrHash,
129
170
  markdown_params: ContextDev::WebScrapeParams::MarkdownParams::OrHash,
130
171
  max_age_ms: Integer,
131
172
  parse_params: ContextDev::WebScrapeParams::ParseParams::OrHash,
173
+ product_params: ContextDev::WebScrapeParams::ProductParams::OrHash,
132
174
  screenshot_params:
133
175
  ContextDev::WebScrapeParams::ScreenshotParams::OrHash,
134
176
  shared_params: ContextDev::WebScrapeParams::SharedParams::OrHash,
@@ -143,8 +185,12 @@ module ContextDev
143
185
  formats:,
144
186
  # The URL to scrape.
145
187
  url:,
188
+ # Highlight options. Requires formats.highlights: true.
189
+ highlights_params: nil,
146
190
  # Image options. Requires formats.images: true.
147
191
  image_params: nil,
192
+ # Required when formats.json is true.
193
+ json_params: nil,
148
194
  # Markdown options. Requires formats.markdown: true.
149
195
  markdown_params: nil,
150
196
  # Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and
@@ -154,6 +200,8 @@ module ContextDev
154
200
  max_age_ms: nil,
155
201
  # Required when formats.parse is true.
156
202
  parse_params: nil,
203
+ # Product options. Requires formats.product: true.
204
+ product_params: nil,
157
205
  # Screenshot options. Requires formats.screenshot: true.
158
206
  screenshot_params: nil,
159
207
  # Shared browser and content settings. Content filters leave screenshots and
@@ -162,12 +210,16 @@ module ContextDev
162
210
  # Labels for tracking request usage. Not retained when zdr is enabled.
163
211
  tags: nil,
164
212
  # Total deadline, including navigation, actions, waiting, and all outputs.
165
- # Defaults to 60000 milliseconds with behavior fail. Use return-partial to capture
166
- # the current page state and return captured images if image processing cannot
167
- # finish before the deadline; these responses set isPartial and are not cached.
168
- # Every requested format must still be available. Fixed waits must fit before a
169
- # response reserve of up to 5000 milliseconds (at most one quarter of the timeout)
170
- # when using return-partial.
213
+ # Defaults to 60000 milliseconds with behavior fail. Individual outputs have
214
+ # internal deadlines that reserve time to return completed outputs; timed-out
215
+ # outputs have success: false and data: null under either behavior. The overall
216
+ # request deadline remains enforced: fail returns an error if that deadline is
217
+ # reached. Use return-partial to allow the current page state and available
218
+ # outputs when the page is still loading. Partial responses set isPartial. Failed
219
+ # retrievals and incomplete captures are not cached; valid captured pieces may be
220
+ # cached independently. Fixed waits must fit before a response reserve of up to
221
+ # 5000 milliseconds (at most one quarter of the timeout) when using
222
+ # return-partial.
171
223
  timeout_opts: nil,
172
224
  # Zero data retention. Bypasses caches and uploads; excludes request/response
173
225
  # content and tags from logs. Must be enabled for your organization.
@@ -181,10 +233,13 @@ module ContextDev
181
233
  {
182
234
  formats: ContextDev::WebScrapeParams::Formats,
183
235
  url: String,
236
+ highlights_params: ContextDev::WebScrapeParams::HighlightsParams,
184
237
  image_params: ContextDev::WebScrapeParams::ImageParams,
238
+ json_params: ContextDev::WebScrapeParams::JsonParams,
185
239
  markdown_params: ContextDev::WebScrapeParams::MarkdownParams,
186
240
  max_age_ms: Integer,
187
241
  parse_params: ContextDev::WebScrapeParams::ParseParams,
242
+ product_params: ContextDev::WebScrapeParams::ProductParams,
188
243
  screenshot_params: ContextDev::WebScrapeParams::ScreenshotParams,
189
244
  shared_params: ContextDev::WebScrapeParams::SharedParams,
190
245
  tags: T::Array[String],
@@ -213,6 +268,15 @@ module ContextDev
213
268
  sig { params(bytes: T::Boolean).void }
214
269
  attr_writer :bytes
215
270
 
271
+ # Relevant Markdown excerpts for your question or topic, preserving code, lists,
272
+ # and tables, with headings included when needed for context. Adds 3 credits when
273
+ # passages are returned.
274
+ sig { returns(T.nilable(T::Boolean)) }
275
+ attr_reader :highlights
276
+
277
+ sig { params(highlights: T::Boolean).void }
278
+ attr_writer :highlights
279
+
216
280
  # Rendered HTML.
217
281
  sig { returns(T.nilable(T::Boolean)) }
218
282
  attr_reader :html
@@ -227,6 +291,14 @@ module ContextDev
227
291
  sig { params(images: T::Boolean).void }
228
292
  attr_writer :images
229
293
 
294
+ # Page data extracted using your schema. Adds 4 credits when extraction succeeds
295
+ # and its result is returned.
296
+ sig { returns(T.nilable(T::Boolean)) }
297
+ attr_reader :json
298
+
299
+ sig { params(json: T::Boolean).void }
300
+ attr_writer :json
301
+
230
302
  # Page content as Markdown.
231
303
  sig { returns(T.nilable(T::Boolean)) }
232
304
  attr_reader :markdown
@@ -241,6 +313,14 @@ module ContextDev
241
313
  sig { params(parse: T::Boolean).void }
242
314
  attr_writer :parse
243
315
 
316
+ # Product details such as name, price, and availability. Adds 1 credit when its
317
+ # successful result is returned or the target page is missing.
318
+ sig { returns(T.nilable(T::Boolean)) }
319
+ attr_reader :product
320
+
321
+ sig { params(product: T::Boolean).void }
322
+ attr_writer :product
323
+
244
324
  # An inline image of the page.
245
325
  sig { returns(T.nilable(T::Boolean)) }
246
326
  attr_reader :screenshot
@@ -252,24 +332,37 @@ module ContextDev
252
332
  sig do
253
333
  params(
254
334
  bytes: T::Boolean,
335
+ highlights: T::Boolean,
255
336
  html: T::Boolean,
256
337
  images: T::Boolean,
338
+ json: T::Boolean,
257
339
  markdown: T::Boolean,
258
340
  parse: T::Boolean,
341
+ product: T::Boolean,
259
342
  screenshot: T::Boolean
260
343
  ).returns(T.attached_class)
261
344
  end
262
345
  def self.new(
263
346
  # The original HTTP response body.
264
347
  bytes: nil,
348
+ # Relevant Markdown excerpts for your question or topic, preserving code, lists,
349
+ # and tables, with headings included when needed for context. Adds 3 credits when
350
+ # passages are returned.
351
+ highlights: nil,
265
352
  # Rendered HTML.
266
353
  html: nil,
267
354
  # Images found on the page.
268
355
  images: nil,
356
+ # Page data extracted using your schema. Adds 4 credits when extraction succeeds
357
+ # and its result is returned.
358
+ json: nil,
269
359
  # Page content as Markdown.
270
360
  markdown: nil,
271
361
  # Fields selected by parseParams.rules.
272
362
  parse: nil,
363
+ # Product details such as name, price, and availability. Adds 1 credit when its
364
+ # successful result is returned or the target page is missing.
365
+ product: nil,
273
366
  # An inline image of the page.
274
367
  screenshot: nil
275
368
  )
@@ -279,10 +372,13 @@ module ContextDev
279
372
  override.returns(
280
373
  {
281
374
  bytes: T::Boolean,
375
+ highlights: T::Boolean,
282
376
  html: T::Boolean,
283
377
  images: T::Boolean,
378
+ json: T::Boolean,
284
379
  markdown: T::Boolean,
285
380
  parse: T::Boolean,
381
+ product: T::Boolean,
286
382
  screenshot: T::Boolean
287
383
  }
288
384
  )
@@ -291,6 +387,45 @@ module ContextDev
291
387
  end
292
388
  end
293
389
 
390
+ class HighlightsParams < ContextDev::Internal::Type::BaseModel
391
+ OrHash =
392
+ T.type_alias do
393
+ T.any(
394
+ ContextDev::WebScrapeParams::HighlightsParams,
395
+ ContextDev::Internal::AnyHash
396
+ )
397
+ end
398
+
399
+ # The question or topic to find passages for.
400
+ sig { returns(String) }
401
+ attr_accessor :query
402
+
403
+ # Maximum combined length of the returned passages, in characters.
404
+ sig { returns(T.nilable(Integer)) }
405
+ attr_reader :max_characters
406
+
407
+ sig { params(max_characters: Integer).void }
408
+ attr_writer :max_characters
409
+
410
+ # Highlight options. Requires formats.highlights: true.
411
+ sig do
412
+ params(query: String, max_characters: Integer).returns(
413
+ T.attached_class
414
+ )
415
+ end
416
+ def self.new(
417
+ # The question or topic to find passages for.
418
+ query:,
419
+ # Maximum combined length of the returned passages, in characters.
420
+ max_characters: nil
421
+ )
422
+ end
423
+
424
+ sig { override.returns({ query: String, max_characters: Integer }) }
425
+ def to_hash
426
+ end
427
+ end
428
+
294
429
  class ImageParams < ContextDev::Internal::Type::BaseModel
295
430
  OrHash =
296
431
  T.type_alias do
@@ -445,6 +580,60 @@ module ContextDev
445
580
  end
446
581
  end
447
582
 
583
+ class JsonParams < ContextDev::Internal::Type::BaseModel
584
+ OrHash =
585
+ T.type_alias do
586
+ T.any(
587
+ ContextDev::WebScrapeParams::JsonParams,
588
+ ContextDev::Internal::AnyHash
589
+ )
590
+ end
591
+
592
+ # JSON Schema for the returned object. Must describe a top-level object; at most
593
+ # 50 KB serialized. Optional fields the page does not state are omitted, or null
594
+ # when their type allows null, while required non-nullable fields always receive a
595
+ # best-effort value, so prefer nullable or optional fields for data a page may
596
+ # omit. Zod users can pass the output of z.toJSONSchema().
597
+ sig { returns(T::Hash[Symbol, T.anything]) }
598
+ attr_accessor :schema
599
+
600
+ # Optional guidance on which facts to prioritize or how to interpret schema
601
+ # fields.
602
+ sig { returns(T.nilable(String)) }
603
+ attr_reader :instructions
604
+
605
+ sig { params(instructions: String).void }
606
+ attr_writer :instructions
607
+
608
+ # Required when formats.json is true.
609
+ sig do
610
+ params(
611
+ schema: T::Hash[Symbol, T.anything],
612
+ instructions: String
613
+ ).returns(T.attached_class)
614
+ end
615
+ def self.new(
616
+ # JSON Schema for the returned object. Must describe a top-level object; at most
617
+ # 50 KB serialized. Optional fields the page does not state are omitted, or null
618
+ # when their type allows null, while required non-nullable fields always receive a
619
+ # best-effort value, so prefer nullable or optional fields for data a page may
620
+ # omit. Zod users can pass the output of z.toJSONSchema().
621
+ schema:,
622
+ # Optional guidance on which facts to prioritize or how to interpret schema
623
+ # fields.
624
+ instructions: nil
625
+ )
626
+ end
627
+
628
+ sig do
629
+ override.returns(
630
+ { schema: T::Hash[Symbol, T.anything], instructions: String }
631
+ )
632
+ end
633
+ def to_hash
634
+ end
635
+ end
636
+
448
637
  class MarkdownParams < ContextDev::Internal::Type::BaseModel
449
638
  OrHash =
450
639
  T.type_alias do
@@ -798,6 +987,43 @@ module ContextDev
798
987
  end
799
988
  end
800
989
 
990
+ class ProductParams < ContextDev::Internal::Type::BaseModel
991
+ OrHash =
992
+ T.type_alias do
993
+ T.any(
994
+ ContextDev::WebScrapeParams::ProductParams,
995
+ ContextDev::Internal::AnyHash
996
+ )
997
+ end
998
+
999
+ # Extract the product with a specialized model when the page has no structured
1000
+ # product data. Adds six credits when the model verdict is returned successfully.
1001
+ # If the fallback fails, the product output has success: false and data: null with
1002
+ # no fallback charge; other outputs remain available. Request deadlines and client
1003
+ # disconnects still apply.
1004
+ sig { returns(T.nilable(T::Boolean)) }
1005
+ attr_reader :use_ai_fallback
1006
+
1007
+ sig { params(use_ai_fallback: T::Boolean).void }
1008
+ attr_writer :use_ai_fallback
1009
+
1010
+ # Product options. Requires formats.product: true.
1011
+ sig { params(use_ai_fallback: T::Boolean).returns(T.attached_class) }
1012
+ def self.new(
1013
+ # Extract the product with a specialized model when the page has no structured
1014
+ # product data. Adds six credits when the model verdict is returned successfully.
1015
+ # If the fallback fails, the product output has success: false and data: null with
1016
+ # no fallback charge; other outputs remain available. Request deadlines and client
1017
+ # disconnects still apply.
1018
+ use_ai_fallback: nil
1019
+ )
1020
+ end
1021
+
1022
+ sig { override.returns({ use_ai_fallback: T::Boolean }) }
1023
+ def to_hash
1024
+ end
1025
+ end
1026
+
801
1027
  class ScreenshotParams < ContextDev::Internal::Type::BaseModel
802
1028
  OrHash =
803
1029
  T.type_alias do
@@ -1899,12 +2125,16 @@ module ContextDev
1899
2125
  attr_writer :behavior
1900
2126
 
1901
2127
  # Total deadline, including navigation, actions, waiting, and all outputs.
1902
- # Defaults to 60000 milliseconds with behavior fail. Use return-partial to capture
1903
- # the current page state and return captured images if image processing cannot
1904
- # finish before the deadline; these responses set isPartial and are not cached.
1905
- # Every requested format must still be available. Fixed waits must fit before a
1906
- # response reserve of up to 5000 milliseconds (at most one quarter of the timeout)
1907
- # when using return-partial.
2128
+ # Defaults to 60000 milliseconds with behavior fail. Individual outputs have
2129
+ # internal deadlines that reserve time to return completed outputs; timed-out
2130
+ # outputs have success: false and data: null under either behavior. The overall
2131
+ # request deadline remains enforced: fail returns an error if that deadline is
2132
+ # reached. Use return-partial to allow the current page state and available
2133
+ # outputs when the page is still loading. Partial responses set isPartial. Failed
2134
+ # retrievals and incomplete captures are not cached; valid captured pieces may be
2135
+ # cached independently. Fixed waits must fit before a response reserve of up to
2136
+ # 5000 milliseconds (at most one quarter of the timeout) when using
2137
+ # return-partial.
1908
2138
  sig do
1909
2139
  params(
1910
2140
  milliseconds: Integer,