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
@@ -70,6 +70,19 @@ module ContextDev
70
70
  sig { returns(Time) }
71
71
  attr_accessor :updated_at
72
72
 
73
+ # Current baseline: the last observed value the monitor compares new snapshots
74
+ # against. Its shape follows `target.type` (page/sitemap/extract). Only populated
75
+ # on GET /monitors/{monitor_id}; null until the first baseline run completes (and
76
+ # after a target or change_detection update, which resets the baseline).
77
+ sig do
78
+ returns(
79
+ T.nilable(
80
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::Variants
81
+ )
82
+ )
83
+ end
84
+ attr_accessor :baseline
85
+
73
86
  sig { returns(T.nilable(Time)) }
74
87
  attr_accessor :last_change_at
75
88
 
@@ -143,6 +156,14 @@ module ContextDev
143
156
  ContextDev::Models::MonitorRetrieveResponse::Target::Extract::OrHash
144
157
  ),
145
158
  updated_at: Time,
159
+ baseline:
160
+ T.nilable(
161
+ T.any(
162
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::MonitorsPageBaseline::OrHash,
163
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::MonitorsSitemapBaseline::OrHash,
164
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::MonitorsExtractBaseline::OrHash
165
+ )
166
+ ),
146
167
  last_change_at: T.nilable(Time),
147
168
  last_error:
148
169
  T.nilable(
@@ -179,6 +200,11 @@ module ContextDev
179
200
  # Discriminated union describing what the monitor watches.
180
201
  target:,
181
202
  updated_at:,
203
+ # Current baseline: the last observed value the monitor compares new snapshots
204
+ # against. Its shape follows `target.type` (page/sitemap/extract). Only populated
205
+ # on GET /monitors/{monitor_id}; null until the first baseline run completes (and
206
+ # after a target or change_detection update, which resets the baseline).
207
+ baseline: nil,
182
208
  last_change_at: nil,
183
209
  # Error from the most recent failed run; null when the last run succeeded.
184
210
  last_error: nil,
@@ -207,6 +233,10 @@ module ContextDev
207
233
  target:
208
234
  ContextDev::Models::MonitorRetrieveResponse::Target::Variants,
209
235
  updated_at: Time,
236
+ baseline:
237
+ T.nilable(
238
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::Variants
239
+ ),
210
240
  last_change_at: T.nilable(Time),
211
241
  last_error:
212
242
  T.nilable(ContextDev::Models::MonitorRetrieveResponse::LastError),
@@ -265,9 +295,6 @@ module ContextDev
265
295
  )
266
296
  end
267
297
 
268
- sig { returns(String) }
269
- attr_accessor :query
270
-
271
298
  sig { returns(Symbol) }
272
299
  attr_accessor :type
273
300
 
@@ -277,21 +304,19 @@ module ContextDev
277
304
  sig { params(confidence_threshold: Float).void }
278
305
  attr_writer :confidence_threshold
279
306
 
280
- # Detect meaning-level changes that match a natural language query.
307
+ # Detect meaning-level changes to the extracted data, ignoring cosmetic or
308
+ # paraphrase-only differences. What is watched is determined by the extract
309
+ # target's `schema` and `instructions`.
281
310
  sig do
282
- params(
283
- query: String,
284
- confidence_threshold: Float,
285
- type: Symbol
286
- ).returns(T.attached_class)
311
+ params(confidence_threshold: Float, type: Symbol).returns(
312
+ T.attached_class
313
+ )
287
314
  end
288
- def self.new(query:, confidence_threshold: nil, type: :semantic)
315
+ def self.new(confidence_threshold: nil, type: :semantic)
289
316
  end
290
317
 
291
318
  sig do
292
- override.returns(
293
- { query: String, type: Symbol, confidence_threshold: Float }
294
- )
319
+ override.returns({ type: Symbol, confidence_threshold: Float })
295
320
  end
296
321
  def to_hash
297
322
  end
@@ -610,8 +635,9 @@ module ContextDev
610
635
 
611
636
  # Watch a sitemap for URL additions and removals. Crawled URLs are normalized
612
637
  # (lowercased host, no trailing slash/fragment) and scoped to the monitored site
613
- # and its subdomains before comparison. A new URL set must be observed on two
614
- # consecutive runs before a change is reported, suppressing one-run crawl flaps.
638
+ # and its subdomains before comparison. On a detected difference the sitemap is
639
+ # re-fetched within the same run and only URLs both observations agree on are
640
+ # reported, suppressing transient crawl flaps.
615
641
  sig do
616
642
  params(
617
643
  url: String,
@@ -658,6 +684,11 @@ module ContextDev
658
684
  )
659
685
  end
660
686
 
687
+ # Natural-language instructions guiding which pages and facts to track and which
688
+ # changes to report.
689
+ sig { returns(String) }
690
+ attr_accessor :instructions
691
+
661
692
  sig { returns(Symbol) }
662
693
  attr_accessor :type
663
694
 
@@ -671,13 +702,6 @@ module ContextDev
671
702
  sig { params(follow_subdomains: T::Boolean).void }
672
703
  attr_writer :follow_subdomains
673
704
 
674
- # Optional natural-language instructions guiding what to extract.
675
- sig { returns(T.nilable(String)) }
676
- attr_reader :instructions
677
-
678
- sig { params(instructions: String).void }
679
- attr_writer :instructions
680
-
681
705
  # Optional maximum link depth from the starting URL (0 = only the starting page).
682
706
  sig { returns(T.nilable(Integer)) }
683
707
  attr_reader :max_depth
@@ -685,14 +709,15 @@ module ContextDev
685
709
  sig { params(max_depth: Integer).void }
686
710
  attr_writer :max_depth
687
711
 
688
- # Maximum number of pages to analyze during extraction.
712
+ # Maximum number of pages to track.
689
713
  sig { returns(T.nilable(Integer)) }
690
714
  attr_reader :max_pages
691
715
 
692
716
  sig { params(max_pages: Integer).void }
693
717
  attr_writer :max_pages
694
718
 
695
- # JSON Schema describing the structured data to extract and watch for changes. If
719
+ # JSON Schema describing the data you care about. It guides which pages are
720
+ # selected for tracking and gives the change judge context on what matters. If
696
721
  # omitted, a default summary + key-points schema is used.
697
722
  sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
698
723
  attr_reader :schema
@@ -700,12 +725,16 @@ module ContextDev
700
725
  sig { params(schema: T::Hash[Symbol, T.anything]).void }
701
726
  attr_writer :schema
702
727
 
703
- # Watch a site's extracted structured data.
728
+ # Watch the monitor-relevant pages of a site for meaningful changes. A crawl
729
+ # guided by `schema`/`instructions` selects up to `max_pages` relevant pages to
730
+ # track; each run re-checks exactly those pages, and confirmed content changes are
731
+ # judged against the monitor's instructions. The tracked page set is refreshed by
732
+ # a periodic re-discovery crawl.
704
733
  sig do
705
734
  params(
735
+ instructions: String,
706
736
  url: String,
707
737
  follow_subdomains: T::Boolean,
708
- instructions: String,
709
738
  max_depth: Integer,
710
739
  max_pages: Integer,
711
740
  schema: T::Hash[Symbol, T.anything],
@@ -713,16 +742,18 @@ module ContextDev
713
742
  ).returns(T.attached_class)
714
743
  end
715
744
  def self.new(
745
+ # Natural-language instructions guiding which pages and facts to track and which
746
+ # changes to report.
747
+ instructions:,
716
748
  # Root URL to extract structured data from.
717
749
  url:,
718
750
  follow_subdomains: nil,
719
- # Optional natural-language instructions guiding what to extract.
720
- instructions: nil,
721
751
  # Optional maximum link depth from the starting URL (0 = only the starting page).
722
752
  max_depth: nil,
723
- # Maximum number of pages to analyze during extraction.
753
+ # Maximum number of pages to track.
724
754
  max_pages: nil,
725
- # JSON Schema describing the structured data to extract and watch for changes. If
755
+ # JSON Schema describing the data you care about. It guides which pages are
756
+ # selected for tracking and gives the change judge context on what matters. If
726
757
  # omitted, a default summary + key-points schema is used.
727
758
  schema: nil,
728
759
  type: :extract
@@ -732,10 +763,10 @@ module ContextDev
732
763
  sig do
733
764
  override.returns(
734
765
  {
766
+ instructions: String,
735
767
  type: Symbol,
736
768
  url: String,
737
769
  follow_subdomains: T::Boolean,
738
- instructions: String,
739
770
  max_depth: Integer,
740
771
  max_pages: Integer,
741
772
  schema: T::Hash[Symbol, T.anything]
@@ -757,6 +788,175 @@ module ContextDev
757
788
  end
758
789
  end
759
790
 
791
+ # Current baseline: the last observed value the monitor compares new snapshots
792
+ # against. Its shape follows `target.type` (page/sitemap/extract). Only populated
793
+ # on GET /monitors/{monitor_id}; null until the first baseline run completes (and
794
+ # after a target or change_detection update, which resets the baseline).
795
+ module Baseline
796
+ extend ContextDev::Internal::Type::Union
797
+
798
+ Variants =
799
+ T.type_alias do
800
+ T.any(
801
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::MonitorsPageBaseline,
802
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::MonitorsSitemapBaseline,
803
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::MonitorsExtractBaseline
804
+ )
805
+ end
806
+
807
+ class MonitorsPageBaseline < ContextDev::Internal::Type::BaseModel
808
+ OrHash =
809
+ T.type_alias do
810
+ T.any(
811
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::MonitorsPageBaseline,
812
+ ContextDev::Internal::AnyHash
813
+ )
814
+ end
815
+
816
+ # When this baseline was last captured or replaced.
817
+ sig { returns(Time) }
818
+ attr_accessor :captured_at
819
+
820
+ # The page's visible text as last observed.
821
+ sig { returns(String) }
822
+ attr_accessor :text
823
+
824
+ # Current baseline of a `page` monitor: the visible page text as last observed.
825
+ sig do
826
+ params(captured_at: Time, text: String).returns(T.attached_class)
827
+ end
828
+ def self.new(
829
+ # When this baseline was last captured or replaced.
830
+ captured_at:,
831
+ # The page's visible text as last observed.
832
+ text:
833
+ )
834
+ end
835
+
836
+ sig { override.returns({ captured_at: Time, text: String }) }
837
+ def to_hash
838
+ end
839
+ end
840
+
841
+ class MonitorsSitemapBaseline < ContextDev::Internal::Type::BaseModel
842
+ OrHash =
843
+ T.type_alias do
844
+ T.any(
845
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::MonitorsSitemapBaseline,
846
+ ContextDev::Internal::AnyHash
847
+ )
848
+ end
849
+
850
+ # When this baseline was last captured or replaced.
851
+ sig { returns(Time) }
852
+ attr_accessor :captured_at
853
+
854
+ # Number of URLs in the baseline.
855
+ sig { returns(Integer) }
856
+ attr_accessor :url_count
857
+
858
+ # The sitemap URLs as last observed (sorted, normalized).
859
+ sig { returns(T::Array[String]) }
860
+ attr_accessor :urls
861
+
862
+ # Current baseline of a `sitemap` monitor: the normalized URL set as last
863
+ # observed.
864
+ sig do
865
+ params(
866
+ captured_at: Time,
867
+ url_count: Integer,
868
+ urls: T::Array[String]
869
+ ).returns(T.attached_class)
870
+ end
871
+ def self.new(
872
+ # When this baseline was last captured or replaced.
873
+ captured_at:,
874
+ # Number of URLs in the baseline.
875
+ url_count:,
876
+ # The sitemap URLs as last observed (sorted, normalized).
877
+ urls:
878
+ )
879
+ end
880
+
881
+ sig do
882
+ override.returns(
883
+ { captured_at: Time, url_count: Integer, urls: T::Array[String] }
884
+ )
885
+ end
886
+ def to_hash
887
+ end
888
+ end
889
+
890
+ class MonitorsExtractBaseline < ContextDev::Internal::Type::BaseModel
891
+ OrHash =
892
+ T.type_alias do
893
+ T.any(
894
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::MonitorsExtractBaseline,
895
+ ContextDev::Internal::AnyHash
896
+ )
897
+ end
898
+
899
+ # When this baseline was last captured or replaced.
900
+ sig { returns(Time) }
901
+ attr_accessor :captured_at
902
+
903
+ # The extracted structured data, matching the monitor's extraction schema (same
904
+ # shape as the /web/extract endpoint's `data`). Refreshed when the monitor
905
+ # re-discovers its page set (at most about once a day); `null` when no extraction
906
+ # has been captured yet.
907
+ sig { returns(T.anything) }
908
+ attr_accessor :data
909
+
910
+ # The page URLs the monitor tracks and analyzes for changes.
911
+ sig { returns(T::Array[String]) }
912
+ attr_accessor :urls_analyzed
913
+
914
+ # Current baseline of an `extract` monitor: the pages it tracks and the structured
915
+ # data as last extracted.
916
+ sig do
917
+ params(
918
+ captured_at: Time,
919
+ data: T.anything,
920
+ urls_analyzed: T::Array[String]
921
+ ).returns(T.attached_class)
922
+ end
923
+ def self.new(
924
+ # When this baseline was last captured or replaced.
925
+ captured_at:,
926
+ # The extracted structured data, matching the monitor's extraction schema (same
927
+ # shape as the /web/extract endpoint's `data`). Refreshed when the monitor
928
+ # re-discovers its page set (at most about once a day); `null` when no extraction
929
+ # has been captured yet.
930
+ data:,
931
+ # The page URLs the monitor tracks and analyzes for changes.
932
+ urls_analyzed:
933
+ )
934
+ end
935
+
936
+ sig do
937
+ override.returns(
938
+ {
939
+ captured_at: Time,
940
+ data: T.anything,
941
+ urls_analyzed: T::Array[String]
942
+ }
943
+ )
944
+ end
945
+ def to_hash
946
+ end
947
+ end
948
+
949
+ sig do
950
+ override.returns(
951
+ T::Array[
952
+ ContextDev::Models::MonitorRetrieveResponse::Baseline::Variants
953
+ ]
954
+ )
955
+ end
956
+ def self.variants
957
+ end
958
+ end
959
+
760
960
  class LastError < ContextDev::Internal::Type::BaseModel
761
961
  OrHash =
762
962
  T.type_alias do
@@ -222,9 +222,6 @@ module ContextDev
222
222
  )
223
223
  end
224
224
 
225
- sig { returns(String) }
226
- attr_accessor :query
227
-
228
225
  sig { returns(Symbol) }
229
226
  attr_accessor :type
230
227
 
@@ -234,21 +231,19 @@ module ContextDev
234
231
  sig { params(confidence_threshold: Float).void }
235
232
  attr_writer :confidence_threshold
236
233
 
237
- # Detect meaning-level changes that match a natural language query.
234
+ # Detect meaning-level changes to the extracted data, ignoring cosmetic or
235
+ # paraphrase-only differences. What is watched is determined by the extract
236
+ # target's `schema` and `instructions`.
238
237
  sig do
239
- params(
240
- query: String,
241
- confidence_threshold: Float,
242
- type: Symbol
243
- ).returns(T.attached_class)
238
+ params(confidence_threshold: Float, type: Symbol).returns(
239
+ T.attached_class
240
+ )
244
241
  end
245
- def self.new(query:, confidence_threshold: nil, type: :semantic)
242
+ def self.new(confidence_threshold: nil, type: :semantic)
246
243
  end
247
244
 
248
245
  sig do
249
- override.returns(
250
- { query: String, type: Symbol, confidence_threshold: Float }
251
- )
246
+ override.returns({ type: Symbol, confidence_threshold: Float })
252
247
  end
253
248
  def to_hash
254
249
  end
@@ -505,8 +500,9 @@ module ContextDev
505
500
 
506
501
  # Watch a sitemap for URL additions and removals. Crawled URLs are normalized
507
502
  # (lowercased host, no trailing slash/fragment) and scoped to the monitored site
508
- # and its subdomains before comparison. A new URL set must be observed on two
509
- # consecutive runs before a change is reported, suppressing one-run crawl flaps.
503
+ # and its subdomains before comparison. On a detected difference the sitemap is
504
+ # re-fetched within the same run and only URLs both observations agree on are
505
+ # reported, suppressing transient crawl flaps.
510
506
  sig do
511
507
  params(
512
508
  url: String,
@@ -553,6 +549,11 @@ module ContextDev
553
549
  )
554
550
  end
555
551
 
552
+ # Natural-language instructions guiding which pages and facts to track and which
553
+ # changes to report.
554
+ sig { returns(String) }
555
+ attr_accessor :instructions
556
+
556
557
  sig { returns(Symbol) }
557
558
  attr_accessor :type
558
559
 
@@ -566,13 +567,6 @@ module ContextDev
566
567
  sig { params(follow_subdomains: T::Boolean).void }
567
568
  attr_writer :follow_subdomains
568
569
 
569
- # Optional natural-language instructions guiding what to extract.
570
- sig { returns(T.nilable(String)) }
571
- attr_reader :instructions
572
-
573
- sig { params(instructions: String).void }
574
- attr_writer :instructions
575
-
576
570
  # Optional maximum link depth from the starting URL (0 = only the starting page).
577
571
  sig { returns(T.nilable(Integer)) }
578
572
  attr_reader :max_depth
@@ -580,14 +574,15 @@ module ContextDev
580
574
  sig { params(max_depth: Integer).void }
581
575
  attr_writer :max_depth
582
576
 
583
- # Maximum number of pages to analyze during extraction.
577
+ # Maximum number of pages to track.
584
578
  sig { returns(T.nilable(Integer)) }
585
579
  attr_reader :max_pages
586
580
 
587
581
  sig { params(max_pages: Integer).void }
588
582
  attr_writer :max_pages
589
583
 
590
- # JSON Schema describing the structured data to extract and watch for changes. If
584
+ # JSON Schema describing the data you care about. It guides which pages are
585
+ # selected for tracking and gives the change judge context on what matters. If
591
586
  # omitted, a default summary + key-points schema is used.
592
587
  sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
593
588
  attr_reader :schema
@@ -595,12 +590,16 @@ module ContextDev
595
590
  sig { params(schema: T::Hash[Symbol, T.anything]).void }
596
591
  attr_writer :schema
597
592
 
598
- # Watch a site's extracted structured data.
593
+ # Watch the monitor-relevant pages of a site for meaningful changes. A crawl
594
+ # guided by `schema`/`instructions` selects up to `max_pages` relevant pages to
595
+ # track; each run re-checks exactly those pages, and confirmed content changes are
596
+ # judged against the monitor's instructions. The tracked page set is refreshed by
597
+ # a periodic re-discovery crawl.
599
598
  sig do
600
599
  params(
600
+ instructions: String,
601
601
  url: String,
602
602
  follow_subdomains: T::Boolean,
603
- instructions: String,
604
603
  max_depth: Integer,
605
604
  max_pages: Integer,
606
605
  schema: T::Hash[Symbol, T.anything],
@@ -608,16 +607,18 @@ module ContextDev
608
607
  ).returns(T.attached_class)
609
608
  end
610
609
  def self.new(
610
+ # Natural-language instructions guiding which pages and facts to track and which
611
+ # changes to report.
612
+ instructions:,
611
613
  # Root URL to extract structured data from.
612
614
  url:,
613
615
  follow_subdomains: nil,
614
- # Optional natural-language instructions guiding what to extract.
615
- instructions: nil,
616
616
  # Optional maximum link depth from the starting URL (0 = only the starting page).
617
617
  max_depth: nil,
618
- # Maximum number of pages to analyze during extraction.
618
+ # Maximum number of pages to track.
619
619
  max_pages: nil,
620
- # JSON Schema describing the structured data to extract and watch for changes. If
620
+ # JSON Schema describing the data you care about. It guides which pages are
621
+ # selected for tracking and gives the change judge context on what matters. If
621
622
  # omitted, a default summary + key-points schema is used.
622
623
  schema: nil,
623
624
  type: :extract
@@ -627,10 +628,10 @@ module ContextDev
627
628
  sig do
628
629
  override.returns(
629
630
  {
631
+ instructions: String,
630
632
  type: Symbol,
631
633
  url: String,
632
634
  follow_subdomains: T::Boolean,
633
- instructions: String,
634
635
  max_depth: Integer,
635
636
  max_pages: Integer,
636
637
  schema: T::Hash[Symbol, T.anything]