context.dev 2.0.0 → 2.1.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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +1 -1
  4. data/lib/context_dev/models/brand_retrieve_params.rb +46 -3
  5. data/lib/context_dev/models/monitor_create_params.rb +30 -27
  6. data/lib/context_dev/models/monitor_create_response.rb +152 -28
  7. data/lib/context_dev/models/monitor_list_params.rb +4 -4
  8. data/lib/context_dev/models/monitor_list_response.rb +152 -28
  9. data/lib/context_dev/models/monitor_retrieve_change_response.rb +1 -8
  10. data/lib/context_dev/models/monitor_retrieve_response.rb +152 -28
  11. data/lib/context_dev/models/monitor_update_params.rb +30 -27
  12. data/lib/context_dev/models/monitor_update_response.rb +152 -28
  13. data/lib/context_dev/resources/brand.rb +4 -2
  14. data/lib/context_dev/resources/monitors.rb +1 -1
  15. data/lib/context_dev/version.rb +1 -1
  16. data/rbi/context_dev/models/brand_retrieve_params.rbi +67 -0
  17. data/rbi/context_dev/models/monitor_create_params.rbi +32 -31
  18. data/rbi/context_dev/models/monitor_create_response.rbi +231 -31
  19. data/rbi/context_dev/models/monitor_list_params.rbi +9 -6
  20. data/rbi/context_dev/models/monitor_list_response.rbi +235 -31
  21. data/rbi/context_dev/models/monitor_retrieve_change_response.rbi +0 -9
  22. data/rbi/context_dev/models/monitor_retrieve_response.rbi +231 -31
  23. data/rbi/context_dev/models/monitor_update_params.rbi +32 -31
  24. data/rbi/context_dev/models/monitor_update_response.rbi +231 -31
  25. data/rbi/context_dev/resources/brand.rbi +4 -1
  26. data/rbi/context_dev/resources/monitors.rbi +2 -2
  27. data/sig/context_dev/models/brand_retrieve_params.rbs +26 -0
  28. data/sig/context_dev/models/monitor_create_params.rbs +7 -17
  29. data/sig/context_dev/models/monitor_create_response.rbs +81 -17
  30. data/sig/context_dev/models/monitor_list_params.rbs +2 -2
  31. data/sig/context_dev/models/monitor_list_response.rbs +81 -17
  32. data/sig/context_dev/models/monitor_retrieve_change_response.rbs +0 -7
  33. data/sig/context_dev/models/monitor_retrieve_response.rbs +81 -17
  34. data/sig/context_dev/models/monitor_update_params.rbs +7 -17
  35. data/sig/context_dev/models/monitor_update_response.rbs +81 -17
  36. metadata +2 -2
@@ -67,6 +67,19 @@ module ContextDev
67
67
  sig { returns(Time) }
68
68
  attr_accessor :updated_at
69
69
 
70
+ # Current baseline: the last observed value the monitor compares new snapshots
71
+ # against. Its shape follows `target.type` (page/sitemap/extract). Only populated
72
+ # on GET /monitors/{monitor_id}; null until the first baseline run completes (and
73
+ # after a target or change_detection update, which resets the baseline).
74
+ sig do
75
+ returns(
76
+ T.nilable(
77
+ ContextDev::Models::MonitorUpdateResponse::Baseline::Variants
78
+ )
79
+ )
80
+ end
81
+ attr_accessor :baseline
82
+
70
83
  sig { returns(T.nilable(Time)) }
71
84
  attr_accessor :last_change_at
72
85
 
@@ -137,6 +150,14 @@ module ContextDev
137
150
  ContextDev::Models::MonitorUpdateResponse::Target::Extract::OrHash
138
151
  ),
139
152
  updated_at: Time,
153
+ baseline:
154
+ T.nilable(
155
+ T.any(
156
+ ContextDev::Models::MonitorUpdateResponse::Baseline::MonitorsPageBaseline::OrHash,
157
+ ContextDev::Models::MonitorUpdateResponse::Baseline::MonitorsSitemapBaseline::OrHash,
158
+ ContextDev::Models::MonitorUpdateResponse::Baseline::MonitorsExtractBaseline::OrHash
159
+ )
160
+ ),
140
161
  last_change_at: T.nilable(Time),
141
162
  last_error:
142
163
  T.nilable(
@@ -173,6 +194,11 @@ module ContextDev
173
194
  # Discriminated union describing what the monitor watches.
174
195
  target:,
175
196
  updated_at:,
197
+ # Current baseline: the last observed value the monitor compares new snapshots
198
+ # against. Its shape follows `target.type` (page/sitemap/extract). Only populated
199
+ # on GET /monitors/{monitor_id}; null until the first baseline run completes (and
200
+ # after a target or change_detection update, which resets the baseline).
201
+ baseline: nil,
176
202
  last_change_at: nil,
177
203
  # Error from the most recent failed run; null when the last run succeeded.
178
204
  last_error: nil,
@@ -199,6 +225,10 @@ module ContextDev
199
225
  ContextDev::Models::MonitorUpdateResponse::Status::TaggedSymbol,
200
226
  target: ContextDev::Models::MonitorUpdateResponse::Target::Variants,
201
227
  updated_at: Time,
228
+ baseline:
229
+ T.nilable(
230
+ ContextDev::Models::MonitorUpdateResponse::Baseline::Variants
231
+ ),
202
232
  last_change_at: T.nilable(Time),
203
233
  last_error:
204
234
  T.nilable(ContextDev::Models::MonitorUpdateResponse::LastError),
@@ -257,9 +287,6 @@ module ContextDev
257
287
  )
258
288
  end
259
289
 
260
- sig { returns(String) }
261
- attr_accessor :query
262
-
263
290
  sig { returns(Symbol) }
264
291
  attr_accessor :type
265
292
 
@@ -269,21 +296,19 @@ module ContextDev
269
296
  sig { params(confidence_threshold: Float).void }
270
297
  attr_writer :confidence_threshold
271
298
 
272
- # Detect meaning-level changes that match a natural language query.
299
+ # Detect meaning-level changes to the extracted data, ignoring cosmetic or
300
+ # paraphrase-only differences. What is watched is determined by the extract
301
+ # target's `schema` and `instructions`.
273
302
  sig do
274
- params(
275
- query: String,
276
- confidence_threshold: Float,
277
- type: Symbol
278
- ).returns(T.attached_class)
303
+ params(confidence_threshold: Float, type: Symbol).returns(
304
+ T.attached_class
305
+ )
279
306
  end
280
- def self.new(query:, confidence_threshold: nil, type: :semantic)
307
+ def self.new(confidence_threshold: nil, type: :semantic)
281
308
  end
282
309
 
283
310
  sig do
284
- override.returns(
285
- { query: String, type: Symbol, confidence_threshold: Float }
286
- )
311
+ override.returns({ type: Symbol, confidence_threshold: Float })
287
312
  end
288
313
  def to_hash
289
314
  end
@@ -602,8 +627,9 @@ module ContextDev
602
627
 
603
628
  # Watch a sitemap for URL additions and removals. Crawled URLs are normalized
604
629
  # (lowercased host, no trailing slash/fragment) and scoped to the monitored site
605
- # and its subdomains before comparison. A new URL set must be observed on two
606
- # consecutive runs before a change is reported, suppressing one-run crawl flaps.
630
+ # and its subdomains before comparison. On a detected difference the sitemap is
631
+ # re-fetched within the same run and only URLs both observations agree on are
632
+ # reported, suppressing transient crawl flaps.
607
633
  sig do
608
634
  params(
609
635
  url: String,
@@ -650,6 +676,11 @@ module ContextDev
650
676
  )
651
677
  end
652
678
 
679
+ # Natural-language instructions guiding which pages and facts to track and which
680
+ # changes to report.
681
+ sig { returns(String) }
682
+ attr_accessor :instructions
683
+
653
684
  sig { returns(Symbol) }
654
685
  attr_accessor :type
655
686
 
@@ -663,13 +694,6 @@ module ContextDev
663
694
  sig { params(follow_subdomains: T::Boolean).void }
664
695
  attr_writer :follow_subdomains
665
696
 
666
- # Optional natural-language instructions guiding what to extract.
667
- sig { returns(T.nilable(String)) }
668
- attr_reader :instructions
669
-
670
- sig { params(instructions: String).void }
671
- attr_writer :instructions
672
-
673
697
  # Optional maximum link depth from the starting URL (0 = only the starting page).
674
698
  sig { returns(T.nilable(Integer)) }
675
699
  attr_reader :max_depth
@@ -677,14 +701,15 @@ module ContextDev
677
701
  sig { params(max_depth: Integer).void }
678
702
  attr_writer :max_depth
679
703
 
680
- # Maximum number of pages to analyze during extraction.
704
+ # Maximum number of pages to track.
681
705
  sig { returns(T.nilable(Integer)) }
682
706
  attr_reader :max_pages
683
707
 
684
708
  sig { params(max_pages: Integer).void }
685
709
  attr_writer :max_pages
686
710
 
687
- # JSON Schema describing the structured data to extract and watch for changes. If
711
+ # JSON Schema describing the data you care about. It guides which pages are
712
+ # selected for tracking and gives the change judge context on what matters. If
688
713
  # omitted, a default summary + key-points schema is used.
689
714
  sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
690
715
  attr_reader :schema
@@ -692,12 +717,16 @@ module ContextDev
692
717
  sig { params(schema: T::Hash[Symbol, T.anything]).void }
693
718
  attr_writer :schema
694
719
 
695
- # Watch a site's extracted structured data.
720
+ # Watch the monitor-relevant pages of a site for meaningful changes. A crawl
721
+ # guided by `schema`/`instructions` selects up to `max_pages` relevant pages to
722
+ # track; each run re-checks exactly those pages, and confirmed content changes are
723
+ # judged against the monitor's instructions. The tracked page set is refreshed by
724
+ # a periodic re-discovery crawl.
696
725
  sig do
697
726
  params(
727
+ instructions: String,
698
728
  url: String,
699
729
  follow_subdomains: T::Boolean,
700
- instructions: String,
701
730
  max_depth: Integer,
702
731
  max_pages: Integer,
703
732
  schema: T::Hash[Symbol, T.anything],
@@ -705,16 +734,18 @@ module ContextDev
705
734
  ).returns(T.attached_class)
706
735
  end
707
736
  def self.new(
737
+ # Natural-language instructions guiding which pages and facts to track and which
738
+ # changes to report.
739
+ instructions:,
708
740
  # Root URL to extract structured data from.
709
741
  url:,
710
742
  follow_subdomains: nil,
711
- # Optional natural-language instructions guiding what to extract.
712
- instructions: nil,
713
743
  # Optional maximum link depth from the starting URL (0 = only the starting page).
714
744
  max_depth: nil,
715
- # Maximum number of pages to analyze during extraction.
745
+ # Maximum number of pages to track.
716
746
  max_pages: nil,
717
- # JSON Schema describing the structured data to extract and watch for changes. If
747
+ # JSON Schema describing the data you care about. It guides which pages are
748
+ # selected for tracking and gives the change judge context on what matters. If
718
749
  # omitted, a default summary + key-points schema is used.
719
750
  schema: nil,
720
751
  type: :extract
@@ -724,10 +755,10 @@ module ContextDev
724
755
  sig do
725
756
  override.returns(
726
757
  {
758
+ instructions: String,
727
759
  type: Symbol,
728
760
  url: String,
729
761
  follow_subdomains: T::Boolean,
730
- instructions: String,
731
762
  max_depth: Integer,
732
763
  max_pages: Integer,
733
764
  schema: T::Hash[Symbol, T.anything]
@@ -749,6 +780,175 @@ module ContextDev
749
780
  end
750
781
  end
751
782
 
783
+ # Current baseline: the last observed value the monitor compares new snapshots
784
+ # against. Its shape follows `target.type` (page/sitemap/extract). Only populated
785
+ # on GET /monitors/{monitor_id}; null until the first baseline run completes (and
786
+ # after a target or change_detection update, which resets the baseline).
787
+ module Baseline
788
+ extend ContextDev::Internal::Type::Union
789
+
790
+ Variants =
791
+ T.type_alias do
792
+ T.any(
793
+ ContextDev::Models::MonitorUpdateResponse::Baseline::MonitorsPageBaseline,
794
+ ContextDev::Models::MonitorUpdateResponse::Baseline::MonitorsSitemapBaseline,
795
+ ContextDev::Models::MonitorUpdateResponse::Baseline::MonitorsExtractBaseline
796
+ )
797
+ end
798
+
799
+ class MonitorsPageBaseline < ContextDev::Internal::Type::BaseModel
800
+ OrHash =
801
+ T.type_alias do
802
+ T.any(
803
+ ContextDev::Models::MonitorUpdateResponse::Baseline::MonitorsPageBaseline,
804
+ ContextDev::Internal::AnyHash
805
+ )
806
+ end
807
+
808
+ # When this baseline was last captured or replaced.
809
+ sig { returns(Time) }
810
+ attr_accessor :captured_at
811
+
812
+ # The page's visible text as last observed.
813
+ sig { returns(String) }
814
+ attr_accessor :text
815
+
816
+ # Current baseline of a `page` monitor: the visible page text as last observed.
817
+ sig do
818
+ params(captured_at: Time, text: String).returns(T.attached_class)
819
+ end
820
+ def self.new(
821
+ # When this baseline was last captured or replaced.
822
+ captured_at:,
823
+ # The page's visible text as last observed.
824
+ text:
825
+ )
826
+ end
827
+
828
+ sig { override.returns({ captured_at: Time, text: String }) }
829
+ def to_hash
830
+ end
831
+ end
832
+
833
+ class MonitorsSitemapBaseline < ContextDev::Internal::Type::BaseModel
834
+ OrHash =
835
+ T.type_alias do
836
+ T.any(
837
+ ContextDev::Models::MonitorUpdateResponse::Baseline::MonitorsSitemapBaseline,
838
+ ContextDev::Internal::AnyHash
839
+ )
840
+ end
841
+
842
+ # When this baseline was last captured or replaced.
843
+ sig { returns(Time) }
844
+ attr_accessor :captured_at
845
+
846
+ # Number of URLs in the baseline.
847
+ sig { returns(Integer) }
848
+ attr_accessor :url_count
849
+
850
+ # The sitemap URLs as last observed (sorted, normalized).
851
+ sig { returns(T::Array[String]) }
852
+ attr_accessor :urls
853
+
854
+ # Current baseline of a `sitemap` monitor: the normalized URL set as last
855
+ # observed.
856
+ sig do
857
+ params(
858
+ captured_at: Time,
859
+ url_count: Integer,
860
+ urls: T::Array[String]
861
+ ).returns(T.attached_class)
862
+ end
863
+ def self.new(
864
+ # When this baseline was last captured or replaced.
865
+ captured_at:,
866
+ # Number of URLs in the baseline.
867
+ url_count:,
868
+ # The sitemap URLs as last observed (sorted, normalized).
869
+ urls:
870
+ )
871
+ end
872
+
873
+ sig do
874
+ override.returns(
875
+ { captured_at: Time, url_count: Integer, urls: T::Array[String] }
876
+ )
877
+ end
878
+ def to_hash
879
+ end
880
+ end
881
+
882
+ class MonitorsExtractBaseline < ContextDev::Internal::Type::BaseModel
883
+ OrHash =
884
+ T.type_alias do
885
+ T.any(
886
+ ContextDev::Models::MonitorUpdateResponse::Baseline::MonitorsExtractBaseline,
887
+ ContextDev::Internal::AnyHash
888
+ )
889
+ end
890
+
891
+ # When this baseline was last captured or replaced.
892
+ sig { returns(Time) }
893
+ attr_accessor :captured_at
894
+
895
+ # The extracted structured data, matching the monitor's extraction schema (same
896
+ # shape as the /web/extract endpoint's `data`). Refreshed when the monitor
897
+ # re-discovers its page set (at most about once a day); `null` when no extraction
898
+ # has been captured yet.
899
+ sig { returns(T.anything) }
900
+ attr_accessor :data
901
+
902
+ # The page URLs the monitor tracks and analyzes for changes.
903
+ sig { returns(T::Array[String]) }
904
+ attr_accessor :urls_analyzed
905
+
906
+ # Current baseline of an `extract` monitor: the pages it tracks and the structured
907
+ # data as last extracted.
908
+ sig do
909
+ params(
910
+ captured_at: Time,
911
+ data: T.anything,
912
+ urls_analyzed: T::Array[String]
913
+ ).returns(T.attached_class)
914
+ end
915
+ def self.new(
916
+ # When this baseline was last captured or replaced.
917
+ captured_at:,
918
+ # The extracted structured data, matching the monitor's extraction schema (same
919
+ # shape as the /web/extract endpoint's `data`). Refreshed when the monitor
920
+ # re-discovers its page set (at most about once a day); `null` when no extraction
921
+ # has been captured yet.
922
+ data:,
923
+ # The page URLs the monitor tracks and analyzes for changes.
924
+ urls_analyzed:
925
+ )
926
+ end
927
+
928
+ sig do
929
+ override.returns(
930
+ {
931
+ captured_at: Time,
932
+ data: T.anything,
933
+ urls_analyzed: T::Array[String]
934
+ }
935
+ )
936
+ end
937
+ def to_hash
938
+ end
939
+ end
940
+
941
+ sig do
942
+ override.returns(
943
+ T::Array[
944
+ ContextDev::Models::MonitorUpdateResponse::Baseline::Variants
945
+ ]
946
+ )
947
+ end
948
+ def self.variants
949
+ end
950
+ end
951
+
752
952
  class LastError < ContextDev::Internal::Type::BaseModel
753
953
  OrHash =
754
954
  T.type_alias do
@@ -5,7 +5,9 @@ module ContextDev
5
5
  class Brand
6
6
  # Retrieve logos, backdrops, colors, industry, description, and more. Provide
7
7
  # exactly one lookup identifier in the request body: a domain, company name, email
8
- # address, stock ticker, or transaction descriptor.
8
+ # address, stock ticker, transaction descriptor, or direct URL. Note:
9
+ # `by_direct_url` fetches brand data only from the provided URL — not from the
10
+ # entire internet.
9
11
  sig do
10
12
  params(
11
13
  body:
@@ -14,6 +16,7 @@ module ContextDev
14
16
  ContextDev::BrandRetrieveParams::Body::ByName::OrHash,
15
17
  ContextDev::BrandRetrieveParams::Body::ByEmail::OrHash,
16
18
  ContextDev::BrandRetrieveParams::Body::ByTicker::OrHash,
19
+ ContextDev::BrandRetrieveParams::Body::ByDirectURL::OrHash,
17
20
  ContextDev::BrandRetrieveParams::Body::ByTransaction::OrHash
18
21
  ),
19
22
  request_options: ContextDev::RequestOptions::OrHash
@@ -131,8 +131,8 @@ module ContextDev
131
131
  limit: nil,
132
132
  # Free-text search term, matched against the fields named in `search_by`.
133
133
  q: nil,
134
- # Comma-separated fields to search with `q`. Defaults to all of them. Note `query`
135
- # only exists on semantic monitors.
134
+ # Comma-separated fields to search with `q`. Defaults to all of them. Note
135
+ # `instructions` only exists on extract monitors.
136
136
  search_by: nil,
137
137
  # `prefix` for as-you-type prefix matching (default), `exact` for full-token
138
138
  # matching.
@@ -25,6 +25,7 @@ module ContextDev
25
25
  | ContextDev::BrandRetrieveParams::Body::ByName
26
26
  | ContextDev::BrandRetrieveParams::Body::ByEmail
27
27
  | ContextDev::BrandRetrieveParams::Body::ByTicker
28
+ | ContextDev::BrandRetrieveParams::Body::ByDirectURL
28
29
  | ContextDev::BrandRetrieveParams::Body::ByTransaction
29
30
 
30
31
  module Body
@@ -1248,6 +1249,31 @@ module ContextDev
1248
1249
  end
1249
1250
  end
1250
1251
 
1252
+ type by_direct_url =
1253
+ { direct_url: String, type: :by_direct_url, timeout_ms: Integer }
1254
+
1255
+ class ByDirectURL < ContextDev::Internal::Type::BaseModel
1256
+ attr_accessor direct_url: String
1257
+
1258
+ attr_accessor type: :by_direct_url
1259
+
1260
+ attr_reader timeout_ms: Integer?
1261
+
1262
+ def timeout_ms=: (Integer) -> Integer
1263
+
1264
+ def initialize: (
1265
+ direct_url: String,
1266
+ ?timeout_ms: Integer,
1267
+ ?type: :by_direct_url
1268
+ ) -> void
1269
+
1270
+ def to_hash: -> {
1271
+ direct_url: String,
1272
+ type: :by_direct_url,
1273
+ timeout_ms: Integer
1274
+ }
1275
+ end
1276
+
1251
1277
  type by_transaction =
1252
1278
  {
1253
1279
  transaction_info: String,
@@ -75,12 +75,9 @@ module ContextDev
75
75
  def to_hash: -> { type: :exact }
76
76
  end
77
77
 
78
- type semantic =
79
- { query: String, type: :semantic, confidence_threshold: Float }
78
+ type semantic = { type: :semantic, confidence_threshold: Float }
80
79
 
81
80
  class Semantic < ContextDev::Internal::Type::BaseModel
82
- attr_accessor query: String
83
-
84
81
  attr_accessor type: :semantic
85
82
 
86
83
  attr_reader confidence_threshold: Float?
@@ -88,16 +85,11 @@ module ContextDev
88
85
  def confidence_threshold=: (Float) -> Float
89
86
 
90
87
  def initialize: (
91
- query: String,
92
88
  ?confidence_threshold: Float,
93
89
  ?type: :semantic
94
90
  ) -> void
95
91
 
96
- def to_hash: -> {
97
- query: String,
98
- type: :semantic,
99
- confidence_threshold: Float
100
- }
92
+ def to_hash: -> { type: :semantic, confidence_threshold: Float }
101
93
  end
102
94
 
103
95
  def self?.variants: -> ::Array[ContextDev::Models::MonitorCreateParams::change_detection]
@@ -229,16 +221,18 @@ module ContextDev
229
221
 
230
222
  type extract =
231
223
  {
224
+ instructions: String,
232
225
  type: :extract,
233
226
  url: String,
234
227
  follow_subdomains: bool,
235
- instructions: String,
236
228
  max_depth: Integer,
237
229
  max_pages: Integer,
238
230
  schema: ::Hash[Symbol, top]
239
231
  }
240
232
 
241
233
  class Extract < ContextDev::Internal::Type::BaseModel
234
+ attr_accessor instructions: String
235
+
242
236
  attr_accessor type: :extract
243
237
 
244
238
  attr_accessor url: String
@@ -247,10 +241,6 @@ module ContextDev
247
241
 
248
242
  def follow_subdomains=: (bool) -> bool
249
243
 
250
- attr_reader instructions: String?
251
-
252
- def instructions=: (String) -> String
253
-
254
244
  attr_reader max_depth: Integer?
255
245
 
256
246
  def max_depth=: (Integer) -> Integer
@@ -264,9 +254,9 @@ module ContextDev
264
254
  def schema=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top]
265
255
 
266
256
  def initialize: (
257
+ instructions: String,
267
258
  url: String,
268
259
  ?follow_subdomains: bool,
269
- ?instructions: String,
270
260
  ?max_depth: Integer,
271
261
  ?max_pages: Integer,
272
262
  ?schema: ::Hash[Symbol, top],
@@ -274,10 +264,10 @@ module ContextDev
274
264
  ) -> void
275
265
 
276
266
  def to_hash: -> {
267
+ instructions: String,
277
268
  type: :extract,
278
269
  url: String,
279
270
  follow_subdomains: bool,
280
- instructions: String,
281
271
  max_depth: Integer,
282
272
  max_pages: Integer,
283
273
  schema: ::Hash[Symbol, top]