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
@@ -21,6 +21,8 @@ module ContextDev
21
21
 
22
22
  Failure = ContextDev::Models::Failure
23
23
 
24
+ FeedbackSubmitParams = ContextDev::Models::FeedbackSubmitParams
25
+
24
26
  IndustryRetrieveNaicsParams = ContextDev::Models::IndustryRetrieveNaicsParams
25
27
 
26
28
  IndustryRetrieveSicParams = ContextDev::Models::IndustryRetrieveSicParams
@@ -0,0 +1,42 @@
1
+ # typed: strong
2
+
3
+ module ContextDev
4
+ module Resources
5
+ # Report bugs, docs mismatches, and friction with any Context.dev API. Submissions
6
+ # cost no credits and use a separate rate limit.
7
+ class Feedback
8
+ # Report a problem with a Context.dev API call, docs page, SDK, or CLI. Include
9
+ # request_id, url, or both.
10
+ sig do
11
+ params(
12
+ category: ContextDev::FeedbackSubmitParams::Category::OrSymbol,
13
+ note: String,
14
+ request_id: String,
15
+ tags: T::Array[String],
16
+ url: String,
17
+ request_options: ContextDev::RequestOptions::OrHash
18
+ ).returns(ContextDev::Models::FeedbackSubmitResponse)
19
+ end
20
+ def submit(
21
+ # Kind of issue.
22
+ category:,
23
+ # What went wrong and what you expected instead.
24
+ note:,
25
+ # The request_id of the API call the feedback is about, from its response body or
26
+ # X-Request-Id header.
27
+ request_id: nil,
28
+ # Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.
29
+ tags: nil,
30
+ # The page the feedback is about, such as one page of a crawl or a docs page.
31
+ url: nil,
32
+ request_options: {}
33
+ )
34
+ end
35
+
36
+ # @api private
37
+ sig { params(client: ContextDev::Client).returns(T.attached_class) }
38
+ def self.new(client:)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -6,9 +6,10 @@ module ContextDev
6
6
  class News
7
7
  # Searches live and historical company news for one company, identified in
8
8
  # searchBy by name, domain, ticker (optionally disambiguated by exchange), or
9
- # ISIN. Results can be filtered by publisher domain, publisher country, article
10
- # language, article type, and published-at date, and include stable story IDs,
11
- # source metadata, verified entity relevance, and cursor pagination.
9
+ # ISIN. Results can be filtered by one of publisher domain, publisher country,
10
+ # article language, or article type, optionally combined with a published-at date
11
+ # range, and include stable story IDs, source metadata, verified entity relevance,
12
+ # and cursor pagination.
12
13
  sig do
13
14
  params(
14
15
  search_by: ContextDev::NewsSearchParams::SearchBy::OrHash,
@@ -25,7 +26,9 @@ module ContextDev
25
26
  search_by:,
26
27
  # Opaque next_cursor from the previous response, or null for the first page.
27
28
  cursor: nil,
28
- # Optional result filters.
29
+ # Optional result filters. Use at most one of sourceDomain, sourceCountry,
30
+ # articleLanguage, or articleType. A date range may accompany that category;
31
+ # date.from must not exceed date.to.
29
32
  filter_by: nil,
30
33
  # Maximum results to return. Defaults to 10.
31
34
  limit: nil,
@@ -201,20 +201,36 @@ module ContextDev
201
201
 
202
202
  # Reuse cached outputs independently and capture missing formats in one page
203
203
  # visit. Each cache key includes only the settings that affect that output. HTML
204
- # is shared with Markdown and parsed fields. Cached outputs can come from
205
- # different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests
206
- # use the existing fast acquisition path. One credit per request, including cache
207
- # hits, or two with browser actions; PDF OCR adds one credit per recovered page on
208
- # fresh extraction. Original response bytes and screenshots are limited to 20 MiB
209
- # each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
204
+ # is shared with Markdown, parsed fields, product data, highlights, and JSON
205
+ # extraction. Cached outputs can come from different visits within maxAgeMs; use 0
206
+ # for a fresh capture. HTML-only requests use the existing fast acquisition path.
207
+ # Highlights return Markdown excerpts most relevant to highlightsParams.query.
208
+ # Requests with at least one successful output cost one base credit, including
209
+ # cache hits, or two with browser actions. All-failed responses are unbilled
210
+ # except missing pages, which retain the base price and the one-credit product
211
+ # charge when product was requested. Highlights add 3 credits when passages are
212
+ # returned. JSON extraction runs an LLM over nonempty page Markdown and adds four
213
+ # credits only when its result is returned successfully. PDF OCR adds one credit
214
+ # per recovered page on fresh extraction. Product adds one credit when its
215
+ # successful result is returned, plus six if that result used the specialized
216
+ # model. Original response bytes and screenshots are limited to 20 MiB each,
217
+ # screenshots to 40 megapixels, and the combined response to 60 MiB. An oversized
218
+ # output has success: false and data: null. If the combined response exceeds its
219
+ # limit, the largest outputs are marked failed until the remaining outputs fit.
220
+ # Valid captured pieces may still be cached when omitted to meet the response size
221
+ # limit.
210
222
  sig do
211
223
  params(
212
224
  formats: ContextDev::WebScrapeParams::Formats::OrHash,
213
225
  url: String,
226
+ highlights_params:
227
+ ContextDev::WebScrapeParams::HighlightsParams::OrHash,
214
228
  image_params: ContextDev::WebScrapeParams::ImageParams::OrHash,
229
+ json_params: ContextDev::WebScrapeParams::JsonParams::OrHash,
215
230
  markdown_params: ContextDev::WebScrapeParams::MarkdownParams::OrHash,
216
231
  max_age_ms: Integer,
217
232
  parse_params: ContextDev::WebScrapeParams::ParseParams::OrHash,
233
+ product_params: ContextDev::WebScrapeParams::ProductParams::OrHash,
218
234
  screenshot_params:
219
235
  ContextDev::WebScrapeParams::ScreenshotParams::OrHash,
220
236
  shared_params: ContextDev::WebScrapeParams::SharedParams::OrHash,
@@ -229,8 +245,12 @@ module ContextDev
229
245
  formats:,
230
246
  # The URL to scrape.
231
247
  url:,
248
+ # Highlight options. Requires formats.highlights: true.
249
+ highlights_params: nil,
232
250
  # Image options. Requires formats.images: true.
233
251
  image_params: nil,
252
+ # Required when formats.json is true.
253
+ json_params: nil,
234
254
  # Markdown options. Requires formats.markdown: true.
235
255
  markdown_params: nil,
236
256
  # Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and
@@ -240,6 +260,8 @@ module ContextDev
240
260
  max_age_ms: nil,
241
261
  # Required when formats.parse is true.
242
262
  parse_params: nil,
263
+ # Product options. Requires formats.product: true.
264
+ product_params: nil,
243
265
  # Screenshot options. Requires formats.screenshot: true.
244
266
  screenshot_params: nil,
245
267
  # Shared browser and content settings. Content filters leave screenshots and
@@ -248,12 +270,16 @@ module ContextDev
248
270
  # Labels for tracking request usage. Not retained when zdr is enabled.
249
271
  tags: nil,
250
272
  # Total deadline, including navigation, actions, waiting, and all outputs.
251
- # Defaults to 60000 milliseconds with behavior fail. Use return-partial to capture
252
- # the current page state and return captured images if image processing cannot
253
- # finish before the deadline; these responses set isPartial and are not cached.
254
- # Every requested format must still be available. Fixed waits must fit before a
255
- # response reserve of up to 5000 milliseconds (at most one quarter of the timeout)
256
- # when using return-partial.
273
+ # Defaults to 60000 milliseconds with behavior fail. Individual outputs have
274
+ # internal deadlines that reserve time to return completed outputs; timed-out
275
+ # outputs have success: false and data: null under either behavior. The overall
276
+ # request deadline remains enforced: fail returns an error if that deadline is
277
+ # reached. Use return-partial to allow the current page state and available
278
+ # outputs when the page is still loading. Partial responses set isPartial. Failed
279
+ # retrievals and incomplete captures are not cached; valid captured pieces may be
280
+ # cached independently. Fixed waits must fit before a response reserve of up to
281
+ # 5000 milliseconds (at most one quarter of the timeout) when using
282
+ # return-partial.
257
283
  timeout_opts: nil,
258
284
  # Zero data retention. Bypasses caches and uploads; excludes request/response
259
285
  # content and tags from logs. Must be enabled for your organization.
@@ -32,6 +32,8 @@ module ContextDev
32
32
 
33
33
  attr_reader logs: ContextDev::Resources::Logs
34
34
 
35
+ attr_reader feedback: ContextDev::Resources::Feedback
36
+
35
37
  private def auth_headers: -> ::Hash[String, String]
36
38
 
37
39
  def initialize: (
@@ -0,0 +1,73 @@
1
+ module ContextDev
2
+ module Models
3
+ type feedback_submit_params =
4
+ {
5
+ category: ContextDev::Models::FeedbackSubmitParams::category,
6
+ note: String,
7
+ request_id: String,
8
+ tags: ::Array[String],
9
+ url: String
10
+ }
11
+ & ContextDev::Internal::Type::request_parameters
12
+
13
+ class FeedbackSubmitParams < ContextDev::Internal::Type::BaseModel
14
+ extend ContextDev::Internal::Type::RequestParameters::Converter
15
+ include ContextDev::Internal::Type::RequestParameters
16
+
17
+ attr_accessor category: ContextDev::Models::FeedbackSubmitParams::category
18
+
19
+ attr_accessor note: String
20
+
21
+ attr_reader request_id: String?
22
+
23
+ def request_id=: (String) -> String
24
+
25
+ attr_reader tags: ::Array[String]?
26
+
27
+ def tags=: (::Array[String]) -> ::Array[String]
28
+
29
+ attr_reader url: String?
30
+
31
+ def url=: (String) -> String
32
+
33
+ def initialize: (
34
+ category: ContextDev::Models::FeedbackSubmitParams::category,
35
+ note: String,
36
+ ?request_id: String,
37
+ ?tags: ::Array[String],
38
+ ?url: String,
39
+ ?request_options: ContextDev::request_opts
40
+ ) -> void
41
+
42
+ def to_hash: -> {
43
+ category: ContextDev::Models::FeedbackSubmitParams::category,
44
+ note: String,
45
+ request_id: String,
46
+ tags: ::Array[String],
47
+ url: String,
48
+ request_options: ContextDev::RequestOptions
49
+ }
50
+
51
+ type category =
52
+ :bug
53
+ | :docs_mismatch
54
+ | :friction
55
+ | :feature_gap
56
+ | :quality_degradation
57
+ | :other
58
+
59
+ module Category
60
+ extend ContextDev::Internal::Type::Enum
61
+
62
+ BUG: :bug
63
+ DOCS_MISMATCH: :docs_mismatch
64
+ FRICTION: :friction
65
+ FEATURE_GAP: :feature_gap
66
+ QUALITY_DEGRADATION: :quality_degradation
67
+ OTHER: :other
68
+
69
+ def self?.values: -> ::Array[ContextDev::Models::FeedbackSubmitParams::category]
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,58 @@
1
+ module ContextDev
2
+ module Models
3
+ type feedback_submit_response =
4
+ {
5
+ already_submitted: bool,
6
+ feedback_id: String,
7
+ request_id: String,
8
+ key_metadata: ContextDev::Models::FeedbackSubmitResponse::KeyMetadata
9
+ }
10
+
11
+ class FeedbackSubmitResponse < ContextDev::Internal::Type::BaseModel
12
+ attr_accessor already_submitted: bool
13
+
14
+ attr_accessor feedback_id: String
15
+
16
+ attr_accessor request_id: String
17
+
18
+ attr_reader key_metadata: ContextDev::Models::FeedbackSubmitResponse::KeyMetadata?
19
+
20
+ def key_metadata=: (
21
+ ContextDev::Models::FeedbackSubmitResponse::KeyMetadata
22
+ ) -> ContextDev::Models::FeedbackSubmitResponse::KeyMetadata
23
+
24
+ def initialize: (
25
+ already_submitted: bool,
26
+ feedback_id: String,
27
+ request_id: String,
28
+ ?key_metadata: ContextDev::Models::FeedbackSubmitResponse::KeyMetadata
29
+ ) -> void
30
+
31
+ def to_hash: -> {
32
+ already_submitted: bool,
33
+ feedback_id: String,
34
+ request_id: String,
35
+ key_metadata: ContextDev::Models::FeedbackSubmitResponse::KeyMetadata
36
+ }
37
+
38
+ type key_metadata =
39
+ { credits_consumed: Integer, credits_remaining: Integer }
40
+
41
+ class KeyMetadata < ContextDev::Internal::Type::BaseModel
42
+ attr_accessor credits_consumed: Integer
43
+
44
+ attr_accessor credits_remaining: Integer
45
+
46
+ def initialize: (
47
+ credits_consumed: Integer,
48
+ credits_remaining: Integer
49
+ ) -> void
50
+
51
+ def to_hash: -> {
52
+ credits_consumed: Integer,
53
+ credits_remaining: Integer
54
+ }
55
+ end
56
+ end
57
+ end
58
+ end
@@ -4,10 +4,13 @@ module ContextDev
4
4
  {
5
5
  formats: ContextDev::WebScrapeParams::Formats,
6
6
  url: String,
7
+ highlights_params: ContextDev::WebScrapeParams::HighlightsParams,
7
8
  image_params: ContextDev::WebScrapeParams::ImageParams,
9
+ json_params: ContextDev::WebScrapeParams::JsonParams,
8
10
  markdown_params: ContextDev::WebScrapeParams::MarkdownParams,
9
11
  max_age_ms: Integer,
10
12
  parse_params: ContextDev::WebScrapeParams::ParseParams,
13
+ product_params: ContextDev::WebScrapeParams::ProductParams,
11
14
  screenshot_params: ContextDev::WebScrapeParams::ScreenshotParams,
12
15
  shared_params: ContextDev::WebScrapeParams::SharedParams,
13
16
  tags: ::Array[String],
@@ -24,12 +27,24 @@ module ContextDev
24
27
 
25
28
  attr_accessor url: String
26
29
 
30
+ attr_reader highlights_params: ContextDev::WebScrapeParams::HighlightsParams?
31
+
32
+ def highlights_params=: (
33
+ ContextDev::WebScrapeParams::HighlightsParams
34
+ ) -> ContextDev::WebScrapeParams::HighlightsParams
35
+
27
36
  attr_reader image_params: ContextDev::WebScrapeParams::ImageParams?
28
37
 
29
38
  def image_params=: (
30
39
  ContextDev::WebScrapeParams::ImageParams
31
40
  ) -> ContextDev::WebScrapeParams::ImageParams
32
41
 
42
+ attr_reader json_params: ContextDev::WebScrapeParams::JsonParams?
43
+
44
+ def json_params=: (
45
+ ContextDev::WebScrapeParams::JsonParams
46
+ ) -> ContextDev::WebScrapeParams::JsonParams
47
+
33
48
  attr_reader markdown_params: ContextDev::WebScrapeParams::MarkdownParams?
34
49
 
35
50
  def markdown_params=: (
@@ -46,6 +61,12 @@ module ContextDev
46
61
  ContextDev::WebScrapeParams::ParseParams
47
62
  ) -> ContextDev::WebScrapeParams::ParseParams
48
63
 
64
+ attr_reader product_params: ContextDev::WebScrapeParams::ProductParams?
65
+
66
+ def product_params=: (
67
+ ContextDev::WebScrapeParams::ProductParams
68
+ ) -> ContextDev::WebScrapeParams::ProductParams
69
+
49
70
  attr_reader screenshot_params: ContextDev::WebScrapeParams::ScreenshotParams?
50
71
 
51
72
  def screenshot_params=: (
@@ -77,10 +98,13 @@ module ContextDev
77
98
  def initialize: (
78
99
  formats: ContextDev::WebScrapeParams::Formats,
79
100
  url: String,
101
+ ?highlights_params: ContextDev::WebScrapeParams::HighlightsParams,
80
102
  ?image_params: ContextDev::WebScrapeParams::ImageParams,
103
+ ?json_params: ContextDev::WebScrapeParams::JsonParams,
81
104
  ?markdown_params: ContextDev::WebScrapeParams::MarkdownParams,
82
105
  ?max_age_ms: Integer,
83
106
  ?parse_params: ContextDev::WebScrapeParams::ParseParams,
107
+ ?product_params: ContextDev::WebScrapeParams::ProductParams,
84
108
  ?screenshot_params: ContextDev::WebScrapeParams::ScreenshotParams,
85
109
  ?shared_params: ContextDev::WebScrapeParams::SharedParams,
86
110
  ?tags: ::Array[String],
@@ -92,10 +116,13 @@ module ContextDev
92
116
  def to_hash: -> {
93
117
  formats: ContextDev::WebScrapeParams::Formats,
94
118
  url: String,
119
+ highlights_params: ContextDev::WebScrapeParams::HighlightsParams,
95
120
  image_params: ContextDev::WebScrapeParams::ImageParams,
121
+ json_params: ContextDev::WebScrapeParams::JsonParams,
96
122
  markdown_params: ContextDev::WebScrapeParams::MarkdownParams,
97
123
  max_age_ms: Integer,
98
124
  parse_params: ContextDev::WebScrapeParams::ParseParams,
125
+ product_params: ContextDev::WebScrapeParams::ProductParams,
99
126
  screenshot_params: ContextDev::WebScrapeParams::ScreenshotParams,
100
127
  shared_params: ContextDev::WebScrapeParams::SharedParams,
101
128
  tags: ::Array[String],
@@ -107,10 +134,13 @@ module ContextDev
107
134
  type formats =
108
135
  {
109
136
  bytes: bool,
137
+ highlights: bool,
110
138
  html: bool,
111
139
  images: bool,
140
+ json: bool,
112
141
  markdown: bool,
113
142
  parse: bool,
143
+ product: bool,
114
144
  screenshot: bool
115
145
  }
116
146
 
@@ -119,6 +149,10 @@ module ContextDev
119
149
 
120
150
  def bytes=: (bool) -> bool
121
151
 
152
+ attr_reader highlights: bool?
153
+
154
+ def highlights=: (bool) -> bool
155
+
122
156
  attr_reader html: bool?
123
157
 
124
158
  def html=: (bool) -> bool
@@ -127,6 +161,10 @@ module ContextDev
127
161
 
128
162
  def images=: (bool) -> bool
129
163
 
164
+ attr_reader json: bool?
165
+
166
+ def json=: (bool) -> bool
167
+
130
168
  attr_reader markdown: bool?
131
169
 
132
170
  def markdown=: (bool) -> bool
@@ -135,29 +173,53 @@ module ContextDev
135
173
 
136
174
  def parse=: (bool) -> bool
137
175
 
176
+ attr_reader product: bool?
177
+
178
+ def product=: (bool) -> bool
179
+
138
180
  attr_reader screenshot: bool?
139
181
 
140
182
  def screenshot=: (bool) -> bool
141
183
 
142
184
  def initialize: (
143
185
  ?bytes: bool,
186
+ ?highlights: bool,
144
187
  ?html: bool,
145
188
  ?images: bool,
189
+ ?json: bool,
146
190
  ?markdown: bool,
147
191
  ?parse: bool,
192
+ ?product: bool,
148
193
  ?screenshot: bool
149
194
  ) -> void
150
195
 
151
196
  def to_hash: -> {
152
197
  bytes: bool,
198
+ highlights: bool,
153
199
  html: bool,
154
200
  images: bool,
201
+ json: bool,
155
202
  markdown: bool,
156
203
  parse: bool,
204
+ product: bool,
157
205
  screenshot: bool
158
206
  }
159
207
  end
160
208
 
209
+ type highlights_params = { query: String, max_characters: Integer }
210
+
211
+ class HighlightsParams < ContextDev::Internal::Type::BaseModel
212
+ attr_accessor query: String
213
+
214
+ attr_reader max_characters: Integer?
215
+
216
+ def max_characters=: (Integer) -> Integer
217
+
218
+ def initialize: (query: String, ?max_characters: Integer) -> void
219
+
220
+ def to_hash: -> { query: String, max_characters: Integer }
221
+ end
222
+
161
223
  type image_params =
162
224
  {
163
225
  dedupe: ContextDev::Models::WebScrapeParams::ImageParams::dedupe,
@@ -211,6 +273,23 @@ module ContextDev
211
273
  end
212
274
  end
213
275
 
276
+ type json_params = { schema: ::Hash[Symbol, top], instructions: String }
277
+
278
+ class JsonParams < ContextDev::Internal::Type::BaseModel
279
+ attr_accessor schema: ::Hash[Symbol, top]
280
+
281
+ attr_reader instructions: String?
282
+
283
+ def instructions=: (String) -> String
284
+
285
+ def initialize: (
286
+ schema: ::Hash[Symbol, top],
287
+ ?instructions: String
288
+ ) -> void
289
+
290
+ def to_hash: -> { schema: ::Hash[Symbol, top], instructions: String }
291
+ end
292
+
214
293
  type markdown_params =
215
294
  {
216
295
  include_images: bool,
@@ -340,6 +419,18 @@ module ContextDev
340
419
  end
341
420
  end
342
421
 
422
+ type product_params = { use_ai_fallback: bool }
423
+
424
+ class ProductParams < ContextDev::Internal::Type::BaseModel
425
+ attr_reader use_ai_fallback: bool?
426
+
427
+ def use_ai_fallback=: (bool) -> bool
428
+
429
+ def initialize: (?use_ai_fallback: bool) -> void
430
+
431
+ def to_hash: -> { use_ai_fallback: bool }
432
+ end
433
+
343
434
  type screenshot_params =
344
435
  {
345
436
  area: ContextDev::Models::WebScrapeParams::ScreenshotParams::area,