diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e6c39adb..0746cbe2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.11.0" + ".": "2.12.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 9673209d..ad6cd802 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 41 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-b0c72d2fe5911c9ce155275b954198bf2152e915a7e5b9f719aad50e222b9ef8.yml -openapi_spec_hash: 5cf943ea5718059b7975417b012cee28 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-2c3f4e4b357ca78c019a3aacd006e2bb8b332d4172a300ee6c46c076a216ed3f.yml +openapi_spec_hash: b89be415cf6ee594b521885a9deb25ac config_hash: 0fb0ceca5946298c416cec0cca5260c7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 46da4ad4..6230918d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 2.12.0 (2026-08-23) + +Full Changelog: [v2.11.0...v2.12.0](https://github.com/context-dot-dev/context-ruby-sdk/compare/v2.11.0...v2.12.0) + +### Features + +* **api:** api update ([f7adbd6](https://github.com/context-dot-dev/context-ruby-sdk/commit/f7adbd63407b697245019ea9483dc090de9ba0ff)) +* **api:** api update ([c26b304](https://github.com/context-dot-dev/context-ruby-sdk/commit/c26b30411607dcc2eaad14962d582f4588f5193f)) +* **api:** api update ([852a96e](https://github.com/context-dot-dev/context-ruby-sdk/commit/852a96e58dab7e6fef53af10093119ffc237f52e)) +* **api:** api update ([c16beb5](https://github.com/context-dot-dev/context-ruby-sdk/commit/c16beb55d66977611c58711b489132f347ab2c96)) + ## 2.11.0 (2026-08-18) Full Changelog: [v2.10.0...v2.11.0](https://github.com/context-dot-dev/context-ruby-sdk/compare/v2.10.0...v2.11.0) diff --git a/Gemfile.lock b/Gemfile.lock index c19d1c76..cacfdc3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - context.dev (2.11.0) + context.dev (2.12.0) cgi connection_pool diff --git a/README.md b/README.md index 3c7187c4..611fa5cb 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "context.dev", "~> 2.11.0" +gem "context.dev", "~> 2.12.0" ``` diff --git a/lib/context_dev/models/ai_extract_product_response.rb b/lib/context_dev/models/ai_extract_product_response.rb index 62fb20bc..adb580c6 100644 --- a/lib/context_dev/models/ai_extract_product_response.rb +++ b/lib/context_dev/models/ai_extract_product_response.rb @@ -123,6 +123,14 @@ class Product < ContextDev::Internal::Type::BaseModel # @return [Array] required :target_audience, ContextDev::Internal::Type::ArrayOf[String] + # @!attribute availability + # Normalized stock or ordering availability + # + # @return [Symbol, ContextDev::Models::AIExtractProductResponse::Product::Availability, nil] + optional :availability, + enum: -> { ContextDev::Models::AIExtractProductResponse::Product::Availability }, + nil?: true + # @!attribute billing_frequency # Billing frequency for the product # @@ -143,6 +151,12 @@ class Product < ContextDev::Internal::Type::BaseModel # @return [String, nil] optional :currency, String, nil?: true + # @!attribute dimensions + # Dimension statements shown for the product, preserving labels, values, and units + # + # @return [Array, nil] + optional :dimensions, ContextDev::Internal::Type::ArrayOf[String] + # @!attribute image_url # URL to the product image # @@ -163,13 +177,22 @@ class Product < ContextDev::Internal::Type::BaseModel enum: -> { ContextDev::Models::AIExtractProductResponse::Product::PricingModel }, nil?: true + # @!attribute regular_price + # Original or regular price before a displayed discount + # + # @return [Float, nil] + optional :regular_price, Float, nil?: true + # @!attribute url # URL to the product page # # @return [String, nil] optional :url, String, nil?: true - # @!method initialize(description:, features:, images:, name:, sku:, tags:, target_audience:, billing_frequency: nil, category: nil, currency: nil, image_url: nil, price: nil, pricing_model: nil, url: nil) + # @!method initialize(description:, features:, images:, name:, sku:, tags:, target_audience:, availability: nil, billing_frequency: nil, category: nil, currency: nil, dimensions: nil, image_url: nil, price: nil, pricing_model: nil, regular_price: nil, url: nil) + # Some parameter documentations has been truncated, see + # {ContextDev::Models::AIExtractProductResponse::Product} for more details. + # # The extracted product data, or null if not a product page # # @param description [String] Description of the product @@ -186,20 +209,44 @@ class Product < ContextDev::Internal::Type::BaseModel # # @param target_audience [Array] Target audience for the product (array of strings) # + # @param availability [Symbol, ContextDev::Models::AIExtractProductResponse::Product::Availability, nil] Normalized stock or ordering availability + # # @param billing_frequency [Symbol, ContextDev::Models::AIExtractProductResponse::Product::BillingFrequency, nil] Billing frequency for the product # # @param category [String, nil] Category of the product # # @param currency [String, nil] Currency code for the price (e.g., USD, EUR) # + # @param dimensions [Array] Dimension statements shown for the product, preserving labels, values, and units + # # @param image_url [String, nil] URL to the product image # # @param price [Float, nil] Price of the product # # @param pricing_model [Symbol, ContextDev::Models::AIExtractProductResponse::Product::PricingModel, nil] Pricing model for the product # + # @param regular_price [Float, nil] Original or regular price before a displayed discount + # # @param url [String, nil] URL to the product page + # Normalized stock or ordering availability + # + # @see ContextDev::Models::AIExtractProductResponse::Product#availability + module Availability + extend ContextDev::Internal::Type::Enum + + IN_STOCK = :in_stock + OUT_OF_STOCK = :out_of_stock + LIMITED_AVAILABILITY = :limited_availability + PREORDER = :preorder + BACKORDER = :backorder + MADE_TO_ORDER = :made_to_order + DISCONTINUED = :discontinued + + # @!method self.values + # @return [Array] + end + # Billing frequency for the product # # @see ContextDev::Models::AIExtractProductResponse::Product#billing_frequency diff --git a/lib/context_dev/models/ai_extract_products_response.rb b/lib/context_dev/models/ai_extract_products_response.rb index 69d207d9..22c9ba3c 100644 --- a/lib/context_dev/models/ai_extract_products_response.rb +++ b/lib/context_dev/models/ai_extract_products_response.rb @@ -92,6 +92,14 @@ class Product < ContextDev::Internal::Type::BaseModel # @return [Array] required :target_audience, ContextDev::Internal::Type::ArrayOf[String] + # @!attribute availability + # Normalized stock or ordering availability + # + # @return [Symbol, ContextDev::Models::AIExtractProductsResponse::Product::Availability, nil] + optional :availability, + enum: -> { ContextDev::Models::AIExtractProductsResponse::Product::Availability }, + nil?: true + # @!attribute billing_frequency # Billing frequency for the product # @@ -112,6 +120,12 @@ class Product < ContextDev::Internal::Type::BaseModel # @return [String, nil] optional :currency, String, nil?: true + # @!attribute dimensions + # Dimension statements shown for the product, preserving labels, values, and units + # + # @return [Array, nil] + optional :dimensions, ContextDev::Internal::Type::ArrayOf[String] + # @!attribute image_url # URL to the product image # @@ -132,13 +146,22 @@ class Product < ContextDev::Internal::Type::BaseModel enum: -> { ContextDev::Models::AIExtractProductsResponse::Product::PricingModel }, nil?: true + # @!attribute regular_price + # Original or regular price before a displayed discount + # + # @return [Float, nil] + optional :regular_price, Float, nil?: true + # @!attribute url # URL to the product page # # @return [String, nil] optional :url, String, nil?: true - # @!method initialize(description:, features:, images:, name:, sku:, tags:, target_audience:, billing_frequency: nil, category: nil, currency: nil, image_url: nil, price: nil, pricing_model: nil, url: nil) + # @!method initialize(description:, features:, images:, name:, sku:, tags:, target_audience:, availability: nil, billing_frequency: nil, category: nil, currency: nil, dimensions: nil, image_url: nil, price: nil, pricing_model: nil, regular_price: nil, url: nil) + # Some parameter documentations has been truncated, see + # {ContextDev::Models::AIExtractProductsResponse::Product} for more details. + # # @param description [String] Description of the product # # @param features [Array] List of product features @@ -153,20 +176,44 @@ class Product < ContextDev::Internal::Type::BaseModel # # @param target_audience [Array] Target audience for the product (array of strings) # + # @param availability [Symbol, ContextDev::Models::AIExtractProductsResponse::Product::Availability, nil] Normalized stock or ordering availability + # # @param billing_frequency [Symbol, ContextDev::Models::AIExtractProductsResponse::Product::BillingFrequency, nil] Billing frequency for the product # # @param category [String, nil] Category of the product # # @param currency [String, nil] Currency code for the price (e.g., USD, EUR) # + # @param dimensions [Array] Dimension statements shown for the product, preserving labels, values, and units + # # @param image_url [String, nil] URL to the product image # # @param price [Float, nil] Price of the product # # @param pricing_model [Symbol, ContextDev::Models::AIExtractProductsResponse::Product::PricingModel, nil] Pricing model for the product # + # @param regular_price [Float, nil] Original or regular price before a displayed discount + # # @param url [String, nil] URL to the product page + # Normalized stock or ordering availability + # + # @see ContextDev::Models::AIExtractProductsResponse::Product#availability + module Availability + extend ContextDev::Internal::Type::Enum + + IN_STOCK = :in_stock + OUT_OF_STOCK = :out_of_stock + LIMITED_AVAILABILITY = :limited_availability + PREORDER = :preorder + BACKORDER = :backorder + MADE_TO_ORDER = :made_to_order + DISCONTINUED = :discontinued + + # @!method self.values + # @return [Array] + end + # Billing frequency for the product # # @see ContextDev::Models::AIExtractProductsResponse::Product#billing_frequency diff --git a/lib/context_dev/models/news_search_params.rb b/lib/context_dev/models/news_search_params.rb index 43636c24..ddaa759c 100644 --- a/lib/context_dev/models/news_search_params.rb +++ b/lib/context_dev/models/news_search_params.rb @@ -413,6 +413,7 @@ module SourceCountry CG = :cg CH = :ch CL = :cl + CZ = :cz DE = :de FI = :fi FR = :fr diff --git a/lib/context_dev/models/web_extract_params.rb b/lib/context_dev/models/web_extract_params.rb index cce22e2d..215daa6b 100644 --- a/lib/context_dev/models/web_extract_params.rb +++ b/lib/context_dev/models/web_extract_params.rb @@ -8,9 +8,11 @@ class WebExtractParams < ContextDev::Internal::Type::BaseModel include ContextDev::Internal::Type::RequestParameters # @!attribute schema - # JSON Schema for the returned data object. TypeScript Zod users can pass a JSON - # Schema generated from a Zod object; Python users can pass the equivalent JSON - # Schema object. + # JSON Schema for the returned data object. Image fields such as `image_urls` or + # `product_photos` automatically make page image references available to + # extraction, so product data and photos can be returned in one call. TypeScript + # Zod users can pass a JSON Schema generated from a Zod object; Python users can + # pass the equivalent JSON Schema object. # # @return [Hash{Symbol=>Object}] required :schema, ContextDev::Internal::Type::HashOf[ContextDev::Internal::Type::Unknown] @@ -22,6 +24,15 @@ class WebExtractParams < ContextDev::Internal::Type::BaseModel # @return [String] required :url, String + # @!attribute actions + # Optional browser actions executed in order on the requested page after it loads, + # before links are discovered or additional pages are crawled. Requires a paid + # plan. When actions are provided and stopAfterMs is omitted, the crawl budget + # defaults to 110000 ms. + # + # @return [Array, nil] + optional :actions, -> { ContextDev::Internal::Type::ArrayOf[union: ContextDev::WebExtractParams::Action] } + # @!attribute fact_check # When true, every returned value must be grounded in facts stated on the page; # fields that cannot be supported by the page are returned as null/empty. When @@ -87,7 +98,8 @@ class WebExtractParams < ContextDev::Internal::Type::BaseModel # @!attribute stop_after_ms # Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 - # (110s). Default: 80000 (80s). + # (110s). Defaults to 80000 (80s), or 110000 (110s) when browser actions are + # provided. # # @return [Integer, nil] optional :stop_after_ms, Integer, api_name: :stopAfterMs @@ -113,14 +125,16 @@ class WebExtractParams < ContextDev::Internal::Type::BaseModel # @return [Integer, nil] optional :wait_for_ms, Integer, api_name: :waitForMs - # @!method initialize(schema:, url:, fact_check: nil, follow_subdomains: nil, include_frames: nil, instructions: nil, max_age_ms: nil, max_depth: nil, max_pages: nil, pdf: nil, settle_animations: nil, stop_after_ms: nil, tags: nil, timeout_ms: nil, wait_for_ms: nil, request_options: {}) + # @!method initialize(schema:, url:, actions: nil, fact_check: nil, follow_subdomains: nil, include_frames: nil, instructions: nil, max_age_ms: nil, max_depth: nil, max_pages: nil, pdf: nil, settle_animations: nil, stop_after_ms: nil, tags: nil, timeout_ms: nil, wait_for_ms: nil, request_options: {}) # Some parameter documentations has been truncated, see # {ContextDev::Models::WebExtractParams} for more details. # - # @param schema [Hash{Symbol=>Object}] JSON Schema for the returned data object. TypeScript Zod users can pass a JSON S + # @param schema [Hash{Symbol=>Object}] JSON Schema for the returned data object. Image fields such as `image_urls` or ` # # @param url [String] The starting website URL to crawl and extract from. Must include http:// or http # + # @param actions [Array] Optional browser actions executed in order on the requested page after it loads, + # # @param fact_check [Boolean] When true, every returned value must be grounded in facts stated on the page; fi # # @param follow_subdomains [Boolean] When true, follow links on subdomains of the starting URL's domain. @@ -149,6 +163,155 @@ class WebExtractParams < ContextDev::Internal::Type::BaseModel # # @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}] + # Browser action discriminated by `do`. Each variant exposes only its applicable + # fields. + module Action + extend ContextDev::Internal::Type::Union + + discriminator :do + + # Pause for a fixed number of milliseconds before continuing to the next action. + variant :wait, -> { ContextDev::WebExtractParams::Action::Wait } + + # Resolve and perform one natural-language browser action. + variant :perform, -> { ContextDev::WebExtractParams::Action::Perform } + + # Scroll the page or a selected scrollable container, waiting adaptively for content and dimensions to settle after each iteration. + variant :scroll, -> { ContextDev::WebExtractParams::Action::Scroll } + + class Wait < ContextDev::Internal::Type::BaseModel + # @!attribute do_ + # + # @return [Symbol, :wait] + required :do_, const: :wait, api_name: :do + + # @!attribute time_ms + # + # @return [Integer] + required :time_ms, Integer, api_name: :timeMs + + # @!method initialize(time_ms:, do_: :wait) + # Pause for a fixed number of milliseconds before continuing to the next action. + # + # @param time_ms [Integer] + # @param do_ [Symbol, :wait] + end + + class Perform < ContextDev::Internal::Type::BaseModel + # @!attribute action + # + # @return [String] + required :action, String + + # @!attribute do_ + # + # @return [Symbol, :perform] + required :do_, const: :perform, api_name: :do + + # @!method initialize(action:, do_: :perform) + # Resolve and perform one natural-language browser action. + # + # @param action [String] + # @param do_ [Symbol, :perform] + end + + class Scroll < ContextDev::Internal::Type::BaseModel + # @!attribute do_ + # + # @return [Symbol, :scroll] + required :do_, const: :scroll, api_name: :do + + # @!attribute amount + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + # + # @return [Integer, Symbol, ContextDev::Models::WebExtractParams::Action::Scroll::Amount, nil] + optional :amount, union: -> { ContextDev::WebExtractParams::Action::Scroll::Amount } + + # @!attribute container + # CSS selector for the first matching scroll container. Defaults to the page. + # + # @return [String, nil] + optional :container, String + + # @!attribute direction + # Direction to scroll. Defaults to down. + # + # @return [Symbol, ContextDev::Models::WebExtractParams::Action::Scroll::Direction, nil] + optional :direction, enum: -> { ContextDev::WebExtractParams::Action::Scroll::Direction } + + # @!attribute max_scrolls + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + # + # @return [Integer, nil] + optional :max_scrolls, Integer, api_name: :maxScrolls + + # @!method initialize(amount: nil, container: nil, direction: nil, max_scrolls: nil, do_: :scroll) + # Some parameter documentations has been truncated, see + # {ContextDev::Models::WebExtractParams::Action::Scroll} for more details. + # + # Scroll the page or a selected scrollable container, waiting adaptively for + # content and dimensions to settle after each iteration. + # + # @param amount [Integer, Symbol, ContextDev::Models::WebExtractParams::Action::Scroll::Amount] Pixels per scroll, one visible viewport, or the current scroll boundary. Default + # + # @param container [String] CSS selector for the first matching scroll container. Defaults to the page. + # + # @param direction [Symbol, ContextDev::Models::WebExtractParams::Action::Scroll::Direction] Direction to scroll. Defaults to down. + # + # @param max_scrolls [Integer] Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # + # @param do_ [Symbol, :scroll] + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + # + # @see ContextDev::Models::WebExtractParams::Action::Scroll#amount + module Amount + extend ContextDev::Internal::Type::Union + + variant Integer + + variant const: -> { ContextDev::Models::WebExtractParams::Action::Scroll::Amount::VIEWPORT } + + variant const: -> { ContextDev::Models::WebExtractParams::Action::Scroll::Amount::MAX } + + # @!method self.variants + # @return [Array(Integer, Symbol)] + + define_sorbet_constant!(:Variants) do + T.type_alias { T.any(Integer, ContextDev::WebExtractParams::Action::Scroll::Amount::TaggedSymbol) } + end + + # @!group + + VIEWPORT = :viewport + MAX = :max + + # @!endgroup + end + + # Direction to scroll. Defaults to down. + # + # @see ContextDev::Models::WebExtractParams::Action::Scroll#direction + module Direction + extend ContextDev::Internal::Type::Enum + + UP = :up + DOWN = :down + LEFT = :left + RIGHT = :right + + # @!method self.values + # @return [Array] + end + end + + # @!method self.variants + # @return [Array(ContextDev::Models::WebExtractParams::Action::Wait, ContextDev::Models::WebExtractParams::Action::Perform, ContextDev::Models::WebExtractParams::Action::Scroll)] + end + class Pdf < ContextDev::Internal::Type::BaseModel # @!attribute end_ # Last 1-based PDF page to parse. Must be greater than or equal to start when both diff --git a/lib/context_dev/models/web_extract_response.rb b/lib/context_dev/models/web_extract_response.rb index 174281c3..3637820e 100644 --- a/lib/context_dev/models/web_extract_response.rb +++ b/lib/context_dev/models/web_extract_response.rb @@ -90,7 +90,15 @@ class Metadata < ContextDev::Internal::Type::BaseModel # @return [Integer] required :num_urls, Integer, api_name: :numUrls - # @!method initialize(max_crawl_depth:, num_blocked:, num_failed:, num_skipped:, num_succeeded:, num_urls:) + # @!attribute actions_applied + # One verified outcome per requested browser action, in request order. + # + # @return [Array, nil] + optional :actions_applied, + -> { ContextDev::Internal::Type::ArrayOf[ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied] }, + api_name: :actionsApplied + + # @!method initialize(max_crawl_depth:, num_blocked:, num_failed:, num_skipped:, num_succeeded:, num_urls:, actions_applied: nil) # Some parameter documentations has been truncated, see # {ContextDev::Models::WebExtractResponse::Metadata} for more details. # @@ -105,6 +113,82 @@ class Metadata < ContextDev::Internal::Type::BaseModel # @param num_succeeded [Integer] # # @param num_urls [Integer] + # + # @param actions_applied [Array] One verified outcome per requested browser action, in request order. + + class ActionsApplied < ContextDev::Internal::Type::BaseModel + # @!attribute instruction + # + # @return [String] + required :instruction, String + + # @!attribute status + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + # + # @return [Symbol, ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status] + required :status, enum: -> { ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status } + + # @!attribute completion_evidence + # Visible page evidence used to verify an applied action. + # + # @return [String, nil] + optional :completion_evidence, String, api_name: :completionEvidence + + # @!attribute duration_ms + # + # @return [Float, nil] + optional :duration_ms, Float, api_name: :durationMs + + # @!attribute error + # + # @return [String, nil] + optional :error, String + + # @!attribute method_ + # + # @return [String, nil] + optional :method_, String, api_name: :method + + # @!attribute target_description + # + # @return [String, nil] + optional :target_description, String, api_name: :targetDescription + + # @!method initialize(instruction:, status:, completion_evidence: nil, duration_ms: nil, error: nil, method_: nil, target_description: nil) + # Some parameter documentations has been truncated, see + # {ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied} for more + # details. + # + # @param instruction [String] + # + # @param status [Symbol, ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status] Applied means the requested page state was visibly verified. Failed means it was + # + # @param completion_evidence [String] Visible page evidence used to verify an applied action. + # + # @param duration_ms [Float] + # + # @param error [String] + # + # @param method_ [String] + # + # @param target_description [String] + + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + # + # @see ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied#status + module Status + extend ContextDev::Internal::Type::Enum + + APPLIED = :applied + FAILED = :failed + SKIPPED = :skipped + + # @!method self.values + # @return [Array] + end + end end # @see ContextDev::Models::WebExtractResponse#key_metadata diff --git a/lib/context_dev/models/web_web_crawl_md_params.rb b/lib/context_dev/models/web_web_crawl_md_params.rb index e83498b8..62a9bffa 100644 --- a/lib/context_dev/models/web_web_crawl_md_params.rb +++ b/lib/context_dev/models/web_web_crawl_md_params.rb @@ -129,7 +129,9 @@ class WebWebCrawlMdParams < ContextDev::Internal::Type::BaseModel optional :timeout_ms, Integer, api_name: :timeoutMS # @!attribute url_regex - # Regex pattern. Only URLs matching this pattern will be followed and scraped. + # Regex pattern. Only URLs matching this pattern will be followed and scraped. An + # automatic prefix scope in the form ^ follows a redirect of the + # starting page. # # @return [String, nil] optional :url_regex, String, api_name: :urlRegex @@ -142,8 +144,8 @@ class WebWebCrawlMdParams < ContextDev::Internal::Type::BaseModel optional :use_main_content_only, ContextDev::Internal::Type::Boolean, api_name: :useMainContentOnly # @!attribute wait_for_ms - # Optional browser wait time in milliseconds after initial page load for each - # crawled page. Min: 0. Max: 30000 (30 seconds). + # Browser wait time in milliseconds after initial page load for each crawled page. + # Defaults to 3500 (3.5 seconds). Min: 0. Max: 30000 (30 seconds). # # @return [Integer, nil] optional :wait_for_ms, Integer, api_name: :waitForMs @@ -195,11 +197,11 @@ class WebWebCrawlMdParams < ContextDev::Internal::Type::BaseModel # # @param timeout_ms [Integer] Optional timeout in milliseconds for the request. If the request takes longer th # - # @param url_regex [String] Regex pattern. Only URLs matching this pattern will be followed and scraped. + # @param url_regex [String] Regex pattern. Only URLs matching this pattern will be followed and scraped. An # # @param use_main_content_only [Boolean] Extract only the main content, stripping headers, footers, sidebars, and navigat # - # @param wait_for_ms [Integer] Optional browser wait time in milliseconds after initial page load for each craw + # @param wait_for_ms [Integer] Browser wait time in milliseconds after initial page load for each crawled page. # # @param zdr [Symbol, ContextDev::Models::WebWebCrawlMdParams::Zdr] Set to enabled to bypass shared caches and omit request and response content fro # diff --git a/lib/context_dev/models/web_web_scrape_html_params.rb b/lib/context_dev/models/web_web_scrape_html_params.rb index a3b89e71..31f5880f 100644 --- a/lib/context_dev/models/web_web_scrape_html_params.rb +++ b/lib/context_dev/models/web_web_scrape_html_params.rb @@ -18,7 +18,7 @@ class WebWebScrapeHTMLParams < ContextDev::Internal::Type::BaseModel # content is captured. Requires a paid plan. Send a JSON array in the query # parameter. Maximum: 5 actions. # - # @return [Array, nil] + # @return [Array, nil] optional :actions, -> { ContextDev::Internal::Type::ArrayOf[union: ContextDev::WebWebScrapeHTMLParams::Action] }, nil?: true @@ -128,7 +128,7 @@ class WebWebScrapeHTMLParams < ContextDev::Internal::Type::BaseModel # # @param url [String] Full URL to scrape (must include http:// or https:// protocol) # - # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before + # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before # # @param country [Symbol, ContextDev::Models::WebWebScrapeHTMLParams::Country] Fetch the target page through a residential proxy in this country (ISO 3166-1 al # @@ -171,6 +171,9 @@ module Action # Resolve and perform one natural-language browser action. variant :perform, -> { ContextDev::WebWebScrapeHTMLParams::Action::Perform } + # Scroll the page or a selected scrollable container, waiting adaptively for content and dimensions to settle after each iteration. + variant :scroll, -> { ContextDev::WebWebScrapeHTMLParams::Action::Scroll } + class Wait < ContextDev::Internal::Type::BaseModel # @!attribute do_ # @@ -207,8 +210,101 @@ class Perform < ContextDev::Internal::Type::BaseModel # @param do_ [Symbol, :perform] end + class Scroll < ContextDev::Internal::Type::BaseModel + # @!attribute do_ + # + # @return [Symbol, :scroll] + required :do_, const: :scroll, api_name: :do + + # @!attribute amount + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + # + # @return [Integer, Symbol, ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::Amount, nil] + optional :amount, union: -> { ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount } + + # @!attribute container + # CSS selector for the first matching scroll container. Defaults to the page. + # + # @return [String, nil] + optional :container, String + + # @!attribute direction + # Direction to scroll. Defaults to down. + # + # @return [Symbol, ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::Direction, nil] + optional :direction, enum: -> { ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction } + + # @!attribute max_scrolls + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + # + # @return [Integer, nil] + optional :max_scrolls, Integer, api_name: :maxScrolls + + # @!method initialize(amount: nil, container: nil, direction: nil, max_scrolls: nil, do_: :scroll) + # Some parameter documentations has been truncated, see + # {ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll} for more details. + # + # Scroll the page or a selected scrollable container, waiting adaptively for + # content and dimensions to settle after each iteration. + # + # @param amount [Integer, Symbol, ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::Amount] Pixels per scroll, one visible viewport, or the current scroll boundary. Default + # + # @param container [String] CSS selector for the first matching scroll container. Defaults to the page. + # + # @param direction [Symbol, ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::Direction] Direction to scroll. Defaults to down. + # + # @param max_scrolls [Integer] Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # + # @param do_ [Symbol, :scroll] + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + # + # @see ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll#amount + module Amount + extend ContextDev::Internal::Type::Union + + variant Integer + + variant const: -> { ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::Amount::VIEWPORT } + + variant const: -> { ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::Amount::MAX } + + # @!method self.variants + # @return [Array(Integer, Symbol)] + + define_sorbet_constant!(:Variants) do + T.type_alias { T.any(Integer, ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount::TaggedSymbol) } + end + + # @!group + + VIEWPORT = :viewport + MAX = :max + + # @!endgroup + end + + # Direction to scroll. Defaults to down. + # + # @see ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll#direction + module Direction + extend ContextDev::Internal::Type::Enum + + UP = :up + DOWN = :down + LEFT = :left + RIGHT = :right + + # @!method self.values + # @return [Array] + end + end + # @!method self.variants - # @return [Array(ContextDev::Models::WebWebScrapeHTMLParams::Action::Wait, ContextDev::Models::WebWebScrapeHTMLParams::Action::Perform)] + # @return [Array(ContextDev::Models::WebWebScrapeHTMLParams::Action::Wait, ContextDev::Models::WebWebScrapeHTMLParams::Action::Perform, ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll)] end # Fetch the target page through a residential proxy in this country (ISO 3166-1 diff --git a/lib/context_dev/models/web_web_scrape_images_params.rb b/lib/context_dev/models/web_web_scrape_images_params.rb index 548d30a6..d7e1b754 100644 --- a/lib/context_dev/models/web_web_scrape_images_params.rb +++ b/lib/context_dev/models/web_web_scrape_images_params.rb @@ -18,7 +18,7 @@ class WebWebScrapeImagesParams < ContextDev::Internal::Type::BaseModel # content is captured. Requires a paid plan. Send a JSON array in the query # parameter. Maximum: 5 actions. # - # @return [Array, nil] + # @return [Array, nil] optional :actions, -> { ContextDev::Internal::Type::ArrayOf[union: ContextDev::WebWebScrapeImagesParams::Action] @@ -85,7 +85,7 @@ class WebWebScrapeImagesParams < ContextDev::Internal::Type::BaseModel # # @param url [String] Page URL to inspect. Must include http:// or https://. # - # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before + # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before # # @param dedupe [Boolean] When true, visually duplicate images are removed: every image is loaded and perc # @@ -116,6 +116,9 @@ module Action # Resolve and perform one natural-language browser action. variant :perform, -> { ContextDev::WebWebScrapeImagesParams::Action::Perform } + # Scroll the page or a selected scrollable container, waiting adaptively for content and dimensions to settle after each iteration. + variant :scroll, -> { ContextDev::WebWebScrapeImagesParams::Action::Scroll } + class Wait < ContextDev::Internal::Type::BaseModel # @!attribute do_ # @@ -152,8 +155,101 @@ class Perform < ContextDev::Internal::Type::BaseModel # @param do_ [Symbol, :perform] end + class Scroll < ContextDev::Internal::Type::BaseModel + # @!attribute do_ + # + # @return [Symbol, :scroll] + required :do_, const: :scroll, api_name: :do + + # @!attribute amount + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + # + # @return [Integer, Symbol, ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::Amount, nil] + optional :amount, union: -> { ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount } + + # @!attribute container + # CSS selector for the first matching scroll container. Defaults to the page. + # + # @return [String, nil] + optional :container, String + + # @!attribute direction + # Direction to scroll. Defaults to down. + # + # @return [Symbol, ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::Direction, nil] + optional :direction, enum: -> { ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction } + + # @!attribute max_scrolls + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + # + # @return [Integer, nil] + optional :max_scrolls, Integer, api_name: :maxScrolls + + # @!method initialize(amount: nil, container: nil, direction: nil, max_scrolls: nil, do_: :scroll) + # Some parameter documentations has been truncated, see + # {ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll} for more details. + # + # Scroll the page or a selected scrollable container, waiting adaptively for + # content and dimensions to settle after each iteration. + # + # @param amount [Integer, Symbol, ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::Amount] Pixels per scroll, one visible viewport, or the current scroll boundary. Default + # + # @param container [String] CSS selector for the first matching scroll container. Defaults to the page. + # + # @param direction [Symbol, ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::Direction] Direction to scroll. Defaults to down. + # + # @param max_scrolls [Integer] Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # + # @param do_ [Symbol, :scroll] + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + # + # @see ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll#amount + module Amount + extend ContextDev::Internal::Type::Union + + variant Integer + + variant const: -> { ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::Amount::VIEWPORT } + + variant const: -> { ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::Amount::MAX } + + # @!method self.variants + # @return [Array(Integer, Symbol)] + + define_sorbet_constant!(:Variants) do + T.type_alias { T.any(Integer, ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount::TaggedSymbol) } + end + + # @!group + + VIEWPORT = :viewport + MAX = :max + + # @!endgroup + end + + # Direction to scroll. Defaults to down. + # + # @see ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll#direction + module Direction + extend ContextDev::Internal::Type::Enum + + UP = :up + DOWN = :down + LEFT = :left + RIGHT = :right + + # @!method self.values + # @return [Array] + end + end + # @!method self.variants - # @return [Array(ContextDev::Models::WebWebScrapeImagesParams::Action::Wait, ContextDev::Models::WebWebScrapeImagesParams::Action::Perform)] + # @return [Array(ContextDev::Models::WebWebScrapeImagesParams::Action::Wait, ContextDev::Models::WebWebScrapeImagesParams::Action::Perform, ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll)] end class Enrichment < ContextDev::Internal::Type::BaseModel diff --git a/lib/context_dev/models/web_web_scrape_images_response.rb b/lib/context_dev/models/web_web_scrape_images_response.rb index 3ec5e1b9..fc58fe83 100644 --- a/lib/context_dev/models/web_web_scrape_images_response.rb +++ b/lib/context_dev/models/web_web_scrape_images_response.rb @@ -23,6 +23,14 @@ class WebWebScrapeImagesResponse < ContextDev::Internal::Type::BaseModel # @return [String] required :url, String + # @!attribute actions_applied + # One verified outcome per requested browser action, in request order. + # + # @return [Array, nil] + optional :actions_applied, + -> { ContextDev::Internal::Type::ArrayOf[ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied] }, + api_name: :actionsApplied + # @!attribute key_metadata # Metadata about the API key used for the request. Included in every response # whenever a valid API key is provided, even when the response status is not 200. @@ -30,7 +38,7 @@ class WebWebScrapeImagesResponse < ContextDev::Internal::Type::BaseModel # @return [ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata, nil] optional :key_metadata, -> { ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata } - # @!method initialize(images:, success:, url:, key_metadata: nil) + # @!method initialize(images:, success:, url:, actions_applied: nil, key_metadata: nil) # Some parameter documentations has been truncated, see # {ContextDev::Models::WebWebScrapeImagesResponse} for more details. # @@ -40,6 +48,8 @@ class WebWebScrapeImagesResponse < ContextDev::Internal::Type::BaseModel # # @param url [String] Page URL that was scraped. # + # @param actions_applied [Array] One verified outcome per requested browser action, in request order. + # # @param key_metadata [ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata] Metadata about the API key used for the request. Included in every response when class Image < ContextDev::Internal::Type::BaseModel @@ -196,6 +206,80 @@ module Success # @return [Array] end + class ActionsApplied < ContextDev::Internal::Type::BaseModel + # @!attribute instruction + # + # @return [String] + required :instruction, String + + # @!attribute status + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + # + # @return [Symbol, ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status] + required :status, enum: -> { ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status } + + # @!attribute completion_evidence + # Visible page evidence used to verify an applied action. + # + # @return [String, nil] + optional :completion_evidence, String, api_name: :completionEvidence + + # @!attribute duration_ms + # + # @return [Float, nil] + optional :duration_ms, Float, api_name: :durationMs + + # @!attribute error + # + # @return [String, nil] + optional :error, String + + # @!attribute method_ + # + # @return [String, nil] + optional :method_, String, api_name: :method + + # @!attribute target_description + # + # @return [String, nil] + optional :target_description, String, api_name: :targetDescription + + # @!method initialize(instruction:, status:, completion_evidence: nil, duration_ms: nil, error: nil, method_: nil, target_description: nil) + # Some parameter documentations has been truncated, see + # {ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied} for more + # details. + # + # @param instruction [String] + # + # @param status [Symbol, ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status] Applied means the requested page state was visibly verified. Failed means it was + # + # @param completion_evidence [String] Visible page evidence used to verify an applied action. + # + # @param duration_ms [Float] + # + # @param error [String] + # + # @param method_ [String] + # + # @param target_description [String] + + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + # + # @see ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied#status + module Status + extend ContextDev::Internal::Type::Enum + + APPLIED = :applied + FAILED = :failed + SKIPPED = :skipped + + # @!method self.values + # @return [Array] + end + end + # @see ContextDev::Models::WebWebScrapeImagesResponse#key_metadata class KeyMetadata < ContextDev::Internal::Type::BaseModel # @!attribute credits_consumed diff --git a/lib/context_dev/models/web_web_scrape_md_params.rb b/lib/context_dev/models/web_web_scrape_md_params.rb index fd1b46ec..ac23a488 100644 --- a/lib/context_dev/models/web_web_scrape_md_params.rb +++ b/lib/context_dev/models/web_web_scrape_md_params.rb @@ -19,7 +19,7 @@ class WebWebScrapeMdParams < ContextDev::Internal::Type::BaseModel # content is captured. Requires a paid plan. Send a JSON array in the query # parameter. Maximum: 5 actions. # - # @return [Array, nil] + # @return [Array, nil] optional :actions, -> { ContextDev::Internal::Type::ArrayOf[union: ContextDev::WebWebScrapeMdParams::Action] }, nil?: true @@ -155,7 +155,7 @@ class WebWebScrapeMdParams < ContextDev::Internal::Type::BaseModel # # @param url [String] Full URL to scrape into LLM usable Markdown (must include http:// or https:// pr # - # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before + # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before # # @param country [Symbol, ContextDev::Models::WebWebScrapeMdParams::Country] Fetch the target page through a residential proxy in this country (ISO 3166-1 al # @@ -206,6 +206,9 @@ module Action # Resolve and perform one natural-language browser action. variant :perform, -> { ContextDev::WebWebScrapeMdParams::Action::Perform } + # Scroll the page or a selected scrollable container, waiting adaptively for content and dimensions to settle after each iteration. + variant :scroll, -> { ContextDev::WebWebScrapeMdParams::Action::Scroll } + class Wait < ContextDev::Internal::Type::BaseModel # @!attribute do_ # @@ -242,8 +245,101 @@ class Perform < ContextDev::Internal::Type::BaseModel # @param do_ [Symbol, :perform] end + class Scroll < ContextDev::Internal::Type::BaseModel + # @!attribute do_ + # + # @return [Symbol, :scroll] + required :do_, const: :scroll, api_name: :do + + # @!attribute amount + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + # + # @return [Integer, Symbol, ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::Amount, nil] + optional :amount, union: -> { ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount } + + # @!attribute container + # CSS selector for the first matching scroll container. Defaults to the page. + # + # @return [String, nil] + optional :container, String + + # @!attribute direction + # Direction to scroll. Defaults to down. + # + # @return [Symbol, ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::Direction, nil] + optional :direction, enum: -> { ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction } + + # @!attribute max_scrolls + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + # + # @return [Integer, nil] + optional :max_scrolls, Integer, api_name: :maxScrolls + + # @!method initialize(amount: nil, container: nil, direction: nil, max_scrolls: nil, do_: :scroll) + # Some parameter documentations has been truncated, see + # {ContextDev::Models::WebWebScrapeMdParams::Action::Scroll} for more details. + # + # Scroll the page or a selected scrollable container, waiting adaptively for + # content and dimensions to settle after each iteration. + # + # @param amount [Integer, Symbol, ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::Amount] Pixels per scroll, one visible viewport, or the current scroll boundary. Default + # + # @param container [String] CSS selector for the first matching scroll container. Defaults to the page. + # + # @param direction [Symbol, ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::Direction] Direction to scroll. Defaults to down. + # + # @param max_scrolls [Integer] Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # + # @param do_ [Symbol, :scroll] + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + # + # @see ContextDev::Models::WebWebScrapeMdParams::Action::Scroll#amount + module Amount + extend ContextDev::Internal::Type::Union + + variant Integer + + variant const: -> { ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::Amount::VIEWPORT } + + variant const: -> { ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::Amount::MAX } + + # @!method self.variants + # @return [Array(Integer, Symbol)] + + define_sorbet_constant!(:Variants) do + T.type_alias { T.any(Integer, ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount::TaggedSymbol) } + end + + # @!group + + VIEWPORT = :viewport + MAX = :max + + # @!endgroup + end + + # Direction to scroll. Defaults to down. + # + # @see ContextDev::Models::WebWebScrapeMdParams::Action::Scroll#direction + module Direction + extend ContextDev::Internal::Type::Enum + + UP = :up + DOWN = :down + LEFT = :left + RIGHT = :right + + # @!method self.values + # @return [Array] + end + end + # @!method self.variants - # @return [Array(ContextDev::Models::WebWebScrapeMdParams::Action::Wait, ContextDev::Models::WebWebScrapeMdParams::Action::Perform)] + # @return [Array(ContextDev::Models::WebWebScrapeMdParams::Action::Wait, ContextDev::Models::WebWebScrapeMdParams::Action::Perform, ContextDev::Models::WebWebScrapeMdParams::Action::Scroll)] end # Fetch the target page through a residential proxy in this country (ISO 3166-1 diff --git a/lib/context_dev/resources/web.rb b/lib/context_dev/resources/web.rb index 625244a6..7f76b7a7 100644 --- a/lib/context_dev/resources/web.rb +++ b/lib/context_dev/resources/web.rb @@ -9,12 +9,14 @@ class Web # Crawl a website, use the provided JSON Schema and instructions to prioritize # relevant internal links, and extract structured data from the selected pages. # - # @overload extract(schema:, url:, fact_check: nil, follow_subdomains: nil, include_frames: nil, instructions: nil, max_age_ms: nil, max_depth: nil, max_pages: nil, pdf: nil, settle_animations: nil, stop_after_ms: nil, tags: nil, timeout_ms: nil, wait_for_ms: nil, request_options: {}) + # @overload extract(schema:, url:, actions: nil, fact_check: nil, follow_subdomains: nil, include_frames: nil, instructions: nil, max_age_ms: nil, max_depth: nil, max_pages: nil, pdf: nil, settle_animations: nil, stop_after_ms: nil, tags: nil, timeout_ms: nil, wait_for_ms: nil, request_options: {}) # - # @param schema [Hash{Symbol=>Object}] JSON Schema for the returned data object. TypeScript Zod users can pass a JSON S + # @param schema [Hash{Symbol=>Object}] JSON Schema for the returned data object. Image fields such as `image_urls` or ` # # @param url [String] The starting website URL to crawl and extract from. Must include http:// or http # + # @param actions [Array] Optional browser actions executed in order on the requested page after it loads, + # # @param fact_check [Boolean] When true, every returned value must be grounded in facts stated on the page; fi # # @param follow_subdomains [Boolean] When true, follow links on subdomains of the starting URL's domain. @@ -320,11 +322,11 @@ def search(params) # # @param timeout_ms [Integer] Optional timeout in milliseconds for the request. If the request takes longer th # - # @param url_regex [String] Regex pattern. Only URLs matching this pattern will be followed and scraped. + # @param url_regex [String] Regex pattern. Only URLs matching this pattern will be followed and scraped. An # # @param use_main_content_only [Boolean] Extract only the main content, stripping headers, footers, sidebars, and navigat # - # @param wait_for_ms [Integer] Optional browser wait time in milliseconds after initial page load for each craw + # @param wait_for_ms [Integer] Browser wait time in milliseconds after initial page load for each crawled page. # # @param zdr [Symbol, ContextDev::Models::WebWebCrawlMdParams::Zdr] Set to enabled to bypass shared caches and omit request and response content fro # @@ -354,7 +356,7 @@ def web_crawl_md(params) # # @param url [String] Full URL to scrape (must include http:// or https:// protocol) # - # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before + # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before # # @param country [Symbol, ContextDev::Models::WebWebScrapeHTMLParams::Country] Fetch the target page through a residential proxy in this country (ISO 3166-1 al # @@ -421,7 +423,7 @@ def web_scrape_html(params) # # @param url [String] Page URL to inspect. Must include http:// or https://. # - # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before + # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before # # @param dedupe [Boolean] When true, visually duplicate images are removed: every image is loaded and perc # @@ -495,7 +497,7 @@ def web_scrape_images(params) # # @param url [String] Full URL to scrape into LLM usable Markdown (must include http:// or https:// pr # - # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before + # @param actions [Array, nil] Optional browser actions executed in array order after the page loads and before # # @param country [Symbol, ContextDev::Models::WebWebScrapeMdParams::Country] Fetch the target page through a residential proxy in this country (ISO 3166-1 al # diff --git a/lib/context_dev/version.rb b/lib/context_dev/version.rb index 279b966c..9bf00f9c 100644 --- a/lib/context_dev/version.rb +++ b/lib/context_dev/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ContextDev - VERSION = "2.11.0" + VERSION = "2.12.0" end diff --git a/rbi/context_dev/models/ai_extract_product_response.rbi b/rbi/context_dev/models/ai_extract_product_response.rbi index 31365682..6e49b0f3 100644 --- a/rbi/context_dev/models/ai_extract_product_response.rbi +++ b/rbi/context_dev/models/ai_extract_product_response.rbi @@ -232,6 +232,16 @@ module ContextDev sig { returns(T::Array[String]) } attr_accessor :target_audience + # Normalized stock or ordering availability + sig do + returns( + T.nilable( + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ) + ) + end + attr_accessor :availability + # Billing frequency for the product sig do returns( @@ -250,6 +260,13 @@ module ContextDev sig { returns(T.nilable(String)) } attr_accessor :currency + # Dimension statements shown for the product, preserving labels, values, and units + sig { returns(T.nilable(T::Array[String])) } + attr_reader :dimensions + + sig { params(dimensions: T::Array[String]).void } + attr_writer :dimensions + # URL to the product image sig { returns(T.nilable(String)) } attr_accessor :image_url @@ -268,6 +285,10 @@ module ContextDev end attr_accessor :pricing_model + # Original or regular price before a displayed discount + sig { returns(T.nilable(Float)) } + attr_accessor :regular_price + # URL to the product page sig { returns(T.nilable(String)) } attr_accessor :url @@ -282,18 +303,24 @@ module ContextDev sku: T.nilable(String), tags: T::Array[String], target_audience: T::Array[String], + availability: + T.nilable( + ContextDev::Models::AIExtractProductResponse::Product::Availability::OrSymbol + ), billing_frequency: T.nilable( ContextDev::Models::AIExtractProductResponse::Product::BillingFrequency::OrSymbol ), category: T.nilable(String), currency: T.nilable(String), + dimensions: T::Array[String], image_url: T.nilable(String), price: T.nilable(Float), pricing_model: T.nilable( ContextDev::Models::AIExtractProductResponse::Product::PricingModel::OrSymbol ), + regular_price: T.nilable(Float), url: T.nilable(String) ).returns(T.attached_class) end @@ -312,18 +339,24 @@ module ContextDev tags:, # Target audience for the product (array of strings) target_audience:, + # Normalized stock or ordering availability + availability: nil, # Billing frequency for the product billing_frequency: nil, # Category of the product category: nil, # Currency code for the price (e.g., USD, EUR) currency: nil, + # Dimension statements shown for the product, preserving labels, values, and units + dimensions: nil, # URL to the product image image_url: nil, # Price of the product price: nil, # Pricing model for the product pricing_model: nil, + # Original or regular price before a displayed discount + regular_price: nil, # URL to the product page url: nil ) @@ -339,18 +372,24 @@ module ContextDev sku: T.nilable(String), tags: T::Array[String], target_audience: T::Array[String], + availability: + T.nilable( + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ), billing_frequency: T.nilable( ContextDev::Models::AIExtractProductResponse::Product::BillingFrequency::TaggedSymbol ), category: T.nilable(String), currency: T.nilable(String), + dimensions: T::Array[String], image_url: T.nilable(String), price: T.nilable(Float), pricing_model: T.nilable( ContextDev::Models::AIExtractProductResponse::Product::PricingModel::TaggedSymbol ), + regular_price: T.nilable(Float), url: T.nilable(String) } ) @@ -358,6 +397,66 @@ module ContextDev def to_hash end + # Normalized stock or ordering availability + module Availability + extend ContextDev::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::Models::AIExtractProductResponse::Product::Availability + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + IN_STOCK = + T.let( + :in_stock, + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ) + OUT_OF_STOCK = + T.let( + :out_of_stock, + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ) + LIMITED_AVAILABILITY = + T.let( + :limited_availability, + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ) + PREORDER = + T.let( + :preorder, + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ) + BACKORDER = + T.let( + :backorder, + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ) + MADE_TO_ORDER = + T.let( + :made_to_order, + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ) + DISCONTINUED = + T.let( + :discontinued, + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + ContextDev::Models::AIExtractProductResponse::Product::Availability::TaggedSymbol + ] + ) + end + def self.values + end + end + # Billing frequency for the product module BillingFrequency extend ContextDev::Internal::Type::Enum diff --git a/rbi/context_dev/models/ai_extract_products_response.rbi b/rbi/context_dev/models/ai_extract_products_response.rbi index 576d26ac..bb14b00c 100644 --- a/rbi/context_dev/models/ai_extract_products_response.rbi +++ b/rbi/context_dev/models/ai_extract_products_response.rbi @@ -158,6 +158,16 @@ module ContextDev sig { returns(T::Array[String]) } attr_accessor :target_audience + # Normalized stock or ordering availability + sig do + returns( + T.nilable( + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ) + ) + end + attr_accessor :availability + # Billing frequency for the product sig do returns( @@ -176,6 +186,13 @@ module ContextDev sig { returns(T.nilable(String)) } attr_accessor :currency + # Dimension statements shown for the product, preserving labels, values, and units + sig { returns(T.nilable(T::Array[String])) } + attr_reader :dimensions + + sig { params(dimensions: T::Array[String]).void } + attr_writer :dimensions + # URL to the product image sig { returns(T.nilable(String)) } attr_accessor :image_url @@ -194,6 +211,10 @@ module ContextDev end attr_accessor :pricing_model + # Original or regular price before a displayed discount + sig { returns(T.nilable(Float)) } + attr_accessor :regular_price + # URL to the product page sig { returns(T.nilable(String)) } attr_accessor :url @@ -207,18 +228,24 @@ module ContextDev sku: T.nilable(String), tags: T::Array[String], target_audience: T::Array[String], + availability: + T.nilable( + ContextDev::Models::AIExtractProductsResponse::Product::Availability::OrSymbol + ), billing_frequency: T.nilable( ContextDev::Models::AIExtractProductsResponse::Product::BillingFrequency::OrSymbol ), category: T.nilable(String), currency: T.nilable(String), + dimensions: T::Array[String], image_url: T.nilable(String), price: T.nilable(Float), pricing_model: T.nilable( ContextDev::Models::AIExtractProductsResponse::Product::PricingModel::OrSymbol ), + regular_price: T.nilable(Float), url: T.nilable(String) ).returns(T.attached_class) end @@ -237,18 +264,24 @@ module ContextDev tags:, # Target audience for the product (array of strings) target_audience:, + # Normalized stock or ordering availability + availability: nil, # Billing frequency for the product billing_frequency: nil, # Category of the product category: nil, # Currency code for the price (e.g., USD, EUR) currency: nil, + # Dimension statements shown for the product, preserving labels, values, and units + dimensions: nil, # URL to the product image image_url: nil, # Price of the product price: nil, # Pricing model for the product pricing_model: nil, + # Original or regular price before a displayed discount + regular_price: nil, # URL to the product page url: nil ) @@ -264,18 +297,24 @@ module ContextDev sku: T.nilable(String), tags: T::Array[String], target_audience: T::Array[String], + availability: + T.nilable( + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ), billing_frequency: T.nilable( ContextDev::Models::AIExtractProductsResponse::Product::BillingFrequency::TaggedSymbol ), category: T.nilable(String), currency: T.nilable(String), + dimensions: T::Array[String], image_url: T.nilable(String), price: T.nilable(Float), pricing_model: T.nilable( ContextDev::Models::AIExtractProductsResponse::Product::PricingModel::TaggedSymbol ), + regular_price: T.nilable(Float), url: T.nilable(String) } ) @@ -283,6 +322,66 @@ module ContextDev def to_hash end + # Normalized stock or ordering availability + module Availability + extend ContextDev::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::Models::AIExtractProductsResponse::Product::Availability + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + IN_STOCK = + T.let( + :in_stock, + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ) + OUT_OF_STOCK = + T.let( + :out_of_stock, + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ) + LIMITED_AVAILABILITY = + T.let( + :limited_availability, + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ) + PREORDER = + T.let( + :preorder, + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ) + BACKORDER = + T.let( + :backorder, + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ) + MADE_TO_ORDER = + T.let( + :made_to_order, + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ) + DISCONTINUED = + T.let( + :discontinued, + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + ContextDev::Models::AIExtractProductsResponse::Product::Availability::TaggedSymbol + ] + ) + end + def self.values + end + end + # Billing frequency for the product module BillingFrequency extend ContextDev::Internal::Type::Enum diff --git a/rbi/context_dev/models/news_search_params.rbi b/rbi/context_dev/models/news_search_params.rbi index 9329ff76..12184352 100644 --- a/rbi/context_dev/models/news_search_params.rbi +++ b/rbi/context_dev/models/news_search_params.rbi @@ -1123,6 +1123,11 @@ module ContextDev :cl, ContextDev::NewsSearchParams::FilterBy::SourceCountry::TaggedSymbol ) + CZ = + T.let( + :cz, + ContextDev::NewsSearchParams::FilterBy::SourceCountry::TaggedSymbol + ) DE = T.let( :de, diff --git a/rbi/context_dev/models/web_extract_params.rbi b/rbi/context_dev/models/web_extract_params.rbi index ed351d32..bc1fb712 100644 --- a/rbi/context_dev/models/web_extract_params.rbi +++ b/rbi/context_dev/models/web_extract_params.rbi @@ -11,9 +11,11 @@ module ContextDev T.any(ContextDev::WebExtractParams, ContextDev::Internal::AnyHash) end - # JSON Schema for the returned data object. TypeScript Zod users can pass a JSON - # Schema generated from a Zod object; Python users can pass the equivalent JSON - # Schema object. + # JSON Schema for the returned data object. Image fields such as `image_urls` or + # `product_photos` automatically make page image references available to + # extraction, so product data and photos can be returned in one call. TypeScript + # Zod users can pass a JSON Schema generated from a Zod object; Python users can + # pass the equivalent JSON Schema object. sig { returns(T::Hash[Symbol, T.anything]) } attr_accessor :schema @@ -22,6 +24,39 @@ module ContextDev sig { returns(String) } attr_accessor :url + # Optional browser actions executed in order on the requested page after it loads, + # before links are discovered or additional pages are crawled. Requires a paid + # plan. When actions are provided and stopAfterMs is omitted, the crawl budget + # defaults to 110000 ms. + sig do + returns( + T.nilable( + T::Array[ + T.any( + ContextDev::WebExtractParams::Action::Wait, + ContextDev::WebExtractParams::Action::Perform, + ContextDev::WebExtractParams::Action::Scroll + ) + ] + ) + ) + end + attr_reader :actions + + sig do + params( + actions: + T::Array[ + T.any( + ContextDev::WebExtractParams::Action::Wait::OrHash, + ContextDev::WebExtractParams::Action::Perform::OrHash, + ContextDev::WebExtractParams::Action::Scroll::OrHash + ) + ] + ).void + end + attr_writer :actions + # When true, every returned value must be grounded in facts stated on the page; # fields that cannot be supported by the page are returned as null/empty. When # false (default), the model may make reasonable inferences and derivations from @@ -95,7 +130,8 @@ module ContextDev attr_writer :settle_animations # Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 - # (110s). Default: 80000 (80s). + # (110s). Defaults to 80000 (80s), or 110000 (110s) when browser actions are + # provided. sig { returns(T.nilable(Integer)) } attr_reader :stop_after_ms @@ -130,6 +166,14 @@ module ContextDev params( schema: T::Hash[Symbol, T.anything], url: String, + actions: + T::Array[ + T.any( + ContextDev::WebExtractParams::Action::Wait::OrHash, + ContextDev::WebExtractParams::Action::Perform::OrHash, + ContextDev::WebExtractParams::Action::Scroll::OrHash + ) + ], fact_check: T::Boolean, follow_subdomains: T::Boolean, include_frames: T::Boolean, @@ -147,13 +191,20 @@ module ContextDev ).returns(T.attached_class) end def self.new( - # JSON Schema for the returned data object. TypeScript Zod users can pass a JSON - # Schema generated from a Zod object; Python users can pass the equivalent JSON - # Schema object. + # JSON Schema for the returned data object. Image fields such as `image_urls` or + # `product_photos` automatically make page image references available to + # extraction, so product data and photos can be returned in one call. TypeScript + # Zod users can pass a JSON Schema generated from a Zod object; Python users can + # pass the equivalent JSON Schema object. schema:, # The starting website URL to crawl and extract from. Must include http:// or # https://. url:, + # Optional browser actions executed in order on the requested page after it loads, + # before links are discovered or additional pages are crawled. Requires a paid + # plan. When actions are provided and stopAfterMs is omitted, the crawl budget + # defaults to 110000 ms. + actions: nil, # When true, every returned value must be grounded in facts stated on the page; # fields that cannot be supported by the page are returned as null/empty. When # false (default), the model may make reasonable inferences and derivations from @@ -182,7 +233,8 @@ module ContextDev # exchange for more stable output on animated pages. settle_animations: nil, # Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 - # (110s). Default: 80000 (80s). + # (110s). Defaults to 80000 (80s), or 110000 (110s) when browser actions are + # provided. stop_after_ms: nil, # Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters. tags: nil, @@ -202,6 +254,14 @@ module ContextDev { schema: T::Hash[Symbol, T.anything], url: String, + actions: + T::Array[ + T.any( + ContextDev::WebExtractParams::Action::Wait, + ContextDev::WebExtractParams::Action::Perform, + ContextDev::WebExtractParams::Action::Scroll + ) + ], fact_check: T::Boolean, follow_subdomains: T::Boolean, include_frames: T::Boolean, @@ -222,6 +282,291 @@ module ContextDev def to_hash end + # Browser action discriminated by `do`. Each variant exposes only its applicable + # fields. + module Action + extend ContextDev::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + ContextDev::WebExtractParams::Action::Wait, + ContextDev::WebExtractParams::Action::Perform, + ContextDev::WebExtractParams::Action::Scroll + ) + end + + class Wait < ContextDev::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + ContextDev::WebExtractParams::Action::Wait, + ContextDev::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :do_ + + sig { returns(Integer) } + attr_accessor :time_ms + + # Pause for a fixed number of milliseconds before continuing to the next action. + sig do + params(time_ms: Integer, do_: Symbol).returns(T.attached_class) + end + def self.new(time_ms:, do_: :wait) + end + + sig { override.returns({ do_: Symbol, time_ms: Integer }) } + def to_hash + end + end + + class Perform < ContextDev::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + ContextDev::WebExtractParams::Action::Perform, + ContextDev::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :action + + sig { returns(Symbol) } + attr_accessor :do_ + + # Resolve and perform one natural-language browser action. + sig { params(action: String, do_: Symbol).returns(T.attached_class) } + def self.new(action:, do_: :perform) + end + + sig { override.returns({ action: String, do_: Symbol }) } + def to_hash + end + end + + class Scroll < ContextDev::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + ContextDev::WebExtractParams::Action::Scroll, + ContextDev::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :do_ + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + sig do + returns( + T.nilable( + T.any( + Integer, + ContextDev::WebExtractParams::Action::Scroll::Amount::OrSymbol + ) + ) + ) + end + attr_reader :amount + + sig do + params( + amount: + T.any( + Integer, + ContextDev::WebExtractParams::Action::Scroll::Amount::OrSymbol + ) + ).void + end + attr_writer :amount + + # CSS selector for the first matching scroll container. Defaults to the page. + sig { returns(T.nilable(String)) } + attr_reader :container + + sig { params(container: String).void } + attr_writer :container + + # Direction to scroll. Defaults to down. + sig do + returns( + T.nilable( + ContextDev::WebExtractParams::Action::Scroll::Direction::OrSymbol + ) + ) + end + attr_reader :direction + + sig do + params( + direction: + ContextDev::WebExtractParams::Action::Scroll::Direction::OrSymbol + ).void + end + attr_writer :direction + + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + sig { returns(T.nilable(Integer)) } + attr_reader :max_scrolls + + sig { params(max_scrolls: Integer).void } + attr_writer :max_scrolls + + # Scroll the page or a selected scrollable container, waiting adaptively for + # content and dimensions to settle after each iteration. + sig do + params( + amount: + T.any( + Integer, + ContextDev::WebExtractParams::Action::Scroll::Amount::OrSymbol + ), + container: String, + direction: + ContextDev::WebExtractParams::Action::Scroll::Direction::OrSymbol, + max_scrolls: Integer, + do_: Symbol + ).returns(T.attached_class) + end + def self.new( + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + amount: nil, + # CSS selector for the first matching scroll container. Defaults to the page. + container: nil, + # Direction to scroll. Defaults to down. + direction: nil, + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + max_scrolls: nil, + do_: :scroll + ) + end + + sig do + override.returns( + { + do_: Symbol, + amount: + T.any( + Integer, + ContextDev::WebExtractParams::Action::Scroll::Amount::OrSymbol + ), + container: String, + direction: + ContextDev::WebExtractParams::Action::Scroll::Direction::OrSymbol, + max_scrolls: Integer + } + ) + end + def to_hash + end + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + module Amount + extend ContextDev::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Integer, + ContextDev::WebExtractParams::Action::Scroll::Amount::TaggedSymbol + ) + end + + sig do + override.returns( + T::Array[ + ContextDev::WebExtractParams::Action::Scroll::Amount::Variants + ] + ) + end + def self.variants + end + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::WebExtractParams::Action::Scroll::Amount + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIEWPORT = + T.let( + :viewport, + ContextDev::WebExtractParams::Action::Scroll::Amount::TaggedSymbol + ) + MAX = + T.let( + :max, + ContextDev::WebExtractParams::Action::Scroll::Amount::TaggedSymbol + ) + end + + # Direction to scroll. Defaults to down. + module Direction + extend ContextDev::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::WebExtractParams::Action::Scroll::Direction + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + UP = + T.let( + :up, + ContextDev::WebExtractParams::Action::Scroll::Direction::TaggedSymbol + ) + DOWN = + T.let( + :down, + ContextDev::WebExtractParams::Action::Scroll::Direction::TaggedSymbol + ) + LEFT = + T.let( + :left, + ContextDev::WebExtractParams::Action::Scroll::Direction::TaggedSymbol + ) + RIGHT = + T.let( + :right, + ContextDev::WebExtractParams::Action::Scroll::Direction::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + ContextDev::WebExtractParams::Action::Scroll::Direction::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + sig do + override.returns( + T::Array[ContextDev::WebExtractParams::Action::Variants] + ) + end + def self.variants + end + end + class Pdf < ContextDev::Internal::Type::BaseModel OrHash = T.type_alias do diff --git a/rbi/context_dev/models/web_extract_response.rbi b/rbi/context_dev/models/web_extract_response.rbi index 328c7186..af444db0 100644 --- a/rbi/context_dev/models/web_extract_response.rbi +++ b/rbi/context_dev/models/web_extract_response.rbi @@ -123,6 +123,28 @@ module ContextDev sig { returns(Integer) } attr_accessor :num_urls + # One verified outcome per requested browser action, in request order. + sig do + returns( + T.nilable( + T::Array[ + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied + ] + ) + ) + end + attr_reader :actions_applied + + sig do + params( + actions_applied: + T::Array[ + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::OrHash + ] + ).void + end + attr_writer :actions_applied + sig do params( max_crawl_depth: Integer, @@ -130,7 +152,11 @@ module ContextDev num_failed: Integer, num_skipped: Integer, num_succeeded: Integer, - num_urls: Integer + num_urls: Integer, + actions_applied: + T::Array[ + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::OrHash + ] ).returns(T.attached_class) end def self.new( @@ -141,7 +167,9 @@ module ContextDev num_failed:, num_skipped:, num_succeeded:, - num_urls: + num_urls:, + # One verified outcome per requested browser action, in request order. + actions_applied: nil ) end @@ -153,12 +181,153 @@ module ContextDev num_failed: Integer, num_skipped: Integer, num_succeeded: Integer, - num_urls: Integer + num_urls: Integer, + actions_applied: + T::Array[ + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied + ] } ) end def to_hash end + + class ActionsApplied < ContextDev::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied, + ContextDev::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :instruction + + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + sig do + returns( + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status::TaggedSymbol + ) + end + attr_accessor :status + + # Visible page evidence used to verify an applied action. + sig { returns(T.nilable(String)) } + attr_reader :completion_evidence + + sig { params(completion_evidence: String).void } + attr_writer :completion_evidence + + sig { returns(T.nilable(Float)) } + attr_reader :duration_ms + + sig { params(duration_ms: Float).void } + attr_writer :duration_ms + + sig { returns(T.nilable(String)) } + attr_reader :error + + sig { params(error: String).void } + attr_writer :error + + sig { returns(T.nilable(String)) } + attr_reader :method_ + + sig { params(method_: String).void } + attr_writer :method_ + + sig { returns(T.nilable(String)) } + attr_reader :target_description + + sig { params(target_description: String).void } + attr_writer :target_description + + sig do + params( + instruction: String, + status: + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status::OrSymbol, + completion_evidence: String, + duration_ms: Float, + error: String, + method_: String, + target_description: String + ).returns(T.attached_class) + end + def self.new( + instruction:, + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + status:, + # Visible page evidence used to verify an applied action. + completion_evidence: nil, + duration_ms: nil, + error: nil, + method_: nil, + target_description: nil + ) + end + + sig do + override.returns( + { + instruction: String, + status: + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status::TaggedSymbol, + completion_evidence: String, + duration_ms: Float, + error: String, + method_: String, + target_description: String + } + ) + end + def to_hash + end + + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + module Status + extend ContextDev::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + APPLIED = + T.let( + :applied, + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status::TaggedSymbol + ) + FAILED = + T.let( + :failed, + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status::TaggedSymbol + ) + SKIPPED = + T.let( + :skipped, + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::Status::TaggedSymbol + ] + ) + end + def self.values + end + end + end end class KeyMetadata < ContextDev::Internal::Type::BaseModel diff --git a/rbi/context_dev/models/web_web_crawl_md_params.rbi b/rbi/context_dev/models/web_web_crawl_md_params.rbi index 59a1ffc9..6976f930 100644 --- a/rbi/context_dev/models/web_web_crawl_md_params.rbi +++ b/rbi/context_dev/models/web_web_crawl_md_params.rbi @@ -150,7 +150,9 @@ module ContextDev sig { params(timeout_ms: Integer).void } attr_writer :timeout_ms - # Regex pattern. Only URLs matching this pattern will be followed and scraped. + # Regex pattern. Only URLs matching this pattern will be followed and scraped. An + # automatic prefix scope in the form ^ follows a redirect of the + # starting page. sig { returns(T.nilable(String)) } attr_reader :url_regex @@ -165,8 +167,8 @@ module ContextDev sig { params(use_main_content_only: T::Boolean).void } attr_writer :use_main_content_only - # Optional browser wait time in milliseconds after initial page load for each - # crawled page. Min: 0. Max: 30000 (30 seconds). + # Browser wait time in milliseconds after initial page load for each crawled page. + # Defaults to 3500 (3.5 seconds). Min: 0. Max: 30000 (30 seconds). sig { returns(T.nilable(Integer)) } attr_reader :wait_for_ms @@ -263,13 +265,15 @@ module ContextDev # than this value, it will be aborted with a 408 status code. Maximum allowed # value is 300000ms (5 minutes). timeout_ms: nil, - # Regex pattern. Only URLs matching this pattern will be followed and scraped. + # Regex pattern. Only URLs matching this pattern will be followed and scraped. An + # automatic prefix scope in the form ^ follows a redirect of the + # starting page. url_regex: nil, # Extract only the main content, stripping headers, footers, sidebars, and # navigation use_main_content_only: nil, - # Optional browser wait time in milliseconds after initial page load for each - # crawled page. Min: 0. Max: 30000 (30 seconds). + # Browser wait time in milliseconds after initial page load for each crawled page. + # Defaults to 3500 (3.5 seconds). Min: 0. Max: 30000 (30 seconds). wait_for_ms: nil, # Set to enabled to bypass shared caches and omit request and response content # from retained usage logs. Requires zero data retention to be enabled for your diff --git a/rbi/context_dev/models/web_web_scrape_html_params.rbi b/rbi/context_dev/models/web_web_scrape_html_params.rbi index 32aff419..fc21ff29 100644 --- a/rbi/context_dev/models/web_web_scrape_html_params.rbi +++ b/rbi/context_dev/models/web_web_scrape_html_params.rbi @@ -27,7 +27,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeHTMLParams::Action::Wait, - ContextDev::WebWebScrapeHTMLParams::Action::Perform + ContextDev::WebWebScrapeHTMLParams::Action::Perform, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll ) ] ) @@ -155,7 +156,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeHTMLParams::Action::Wait::OrHash, - ContextDev::WebWebScrapeHTMLParams::Action::Perform::OrHash + ContextDev::WebWebScrapeHTMLParams::Action::Perform::OrHash, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::OrHash ) ] ), @@ -242,7 +244,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeHTMLParams::Action::Wait, - ContextDev::WebWebScrapeHTMLParams::Action::Perform + ContextDev::WebWebScrapeHTMLParams::Action::Perform, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll ) ] ), @@ -275,7 +278,8 @@ module ContextDev T.type_alias do T.any( ContextDev::WebWebScrapeHTMLParams::Action::Wait, - ContextDev::WebWebScrapeHTMLParams::Action::Perform + ContextDev::WebWebScrapeHTMLParams::Action::Perform, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll ) end @@ -331,6 +335,216 @@ module ContextDev end end + class Scroll < ContextDev::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + ContextDev::WebWebScrapeHTMLParams::Action::Scroll, + ContextDev::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :do_ + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + sig do + returns( + T.nilable( + T.any( + Integer, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount::OrSymbol + ) + ) + ) + end + attr_reader :amount + + sig do + params( + amount: + T.any( + Integer, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount::OrSymbol + ) + ).void + end + attr_writer :amount + + # CSS selector for the first matching scroll container. Defaults to the page. + sig { returns(T.nilable(String)) } + attr_reader :container + + sig { params(container: String).void } + attr_writer :container + + # Direction to scroll. Defaults to down. + sig do + returns( + T.nilable( + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction::OrSymbol + ) + ) + end + attr_reader :direction + + sig do + params( + direction: + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction::OrSymbol + ).void + end + attr_writer :direction + + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + sig { returns(T.nilable(Integer)) } + attr_reader :max_scrolls + + sig { params(max_scrolls: Integer).void } + attr_writer :max_scrolls + + # Scroll the page or a selected scrollable container, waiting adaptively for + # content and dimensions to settle after each iteration. + sig do + params( + amount: + T.any( + Integer, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount::OrSymbol + ), + container: String, + direction: + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction::OrSymbol, + max_scrolls: Integer, + do_: Symbol + ).returns(T.attached_class) + end + def self.new( + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + amount: nil, + # CSS selector for the first matching scroll container. Defaults to the page. + container: nil, + # Direction to scroll. Defaults to down. + direction: nil, + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + max_scrolls: nil, + do_: :scroll + ) + end + + sig do + override.returns( + { + do_: Symbol, + amount: + T.any( + Integer, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount::OrSymbol + ), + container: String, + direction: + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction::OrSymbol, + max_scrolls: Integer + } + ) + end + def to_hash + end + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + module Amount + extend ContextDev::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Integer, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount::TaggedSymbol + ) + end + + sig do + override.returns( + T::Array[ + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount::Variants + ] + ) + end + def self.variants + end + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIEWPORT = + T.let( + :viewport, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount::TaggedSymbol + ) + MAX = + T.let( + :max, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Amount::TaggedSymbol + ) + end + + # Direction to scroll. Defaults to down. + module Direction + extend ContextDev::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + UP = + T.let( + :up, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction::TaggedSymbol + ) + DOWN = + T.let( + :down, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction::TaggedSymbol + ) + LEFT = + T.let( + :left, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction::TaggedSymbol + ) + RIGHT = + T.let( + :right, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::Direction::TaggedSymbol + ] + ) + end + def self.values + end + end + end + sig do override.returns( T::Array[ContextDev::WebWebScrapeHTMLParams::Action::Variants] diff --git a/rbi/context_dev/models/web_web_scrape_images_params.rbi b/rbi/context_dev/models/web_web_scrape_images_params.rbi index 0fa5f0a6..30d37f64 100644 --- a/rbi/context_dev/models/web_web_scrape_images_params.rbi +++ b/rbi/context_dev/models/web_web_scrape_images_params.rbi @@ -27,7 +27,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeImagesParams::Action::Wait, - ContextDev::WebWebScrapeImagesParams::Action::Perform + ContextDev::WebWebScrapeImagesParams::Action::Perform, + ContextDev::WebWebScrapeImagesParams::Action::Scroll ) ] ) @@ -105,7 +106,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeImagesParams::Action::Wait::OrHash, - ContextDev::WebWebScrapeImagesParams::Action::Perform::OrHash + ContextDev::WebWebScrapeImagesParams::Action::Perform::OrHash, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::OrHash ) ] ), @@ -166,7 +168,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeImagesParams::Action::Wait, - ContextDev::WebWebScrapeImagesParams::Action::Perform + ContextDev::WebWebScrapeImagesParams::Action::Perform, + ContextDev::WebWebScrapeImagesParams::Action::Scroll ) ] ), @@ -194,7 +197,8 @@ module ContextDev T.type_alias do T.any( ContextDev::WebWebScrapeImagesParams::Action::Wait, - ContextDev::WebWebScrapeImagesParams::Action::Perform + ContextDev::WebWebScrapeImagesParams::Action::Perform, + ContextDev::WebWebScrapeImagesParams::Action::Scroll ) end @@ -250,6 +254,216 @@ module ContextDev end end + class Scroll < ContextDev::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + ContextDev::WebWebScrapeImagesParams::Action::Scroll, + ContextDev::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :do_ + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + sig do + returns( + T.nilable( + T.any( + Integer, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount::OrSymbol + ) + ) + ) + end + attr_reader :amount + + sig do + params( + amount: + T.any( + Integer, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount::OrSymbol + ) + ).void + end + attr_writer :amount + + # CSS selector for the first matching scroll container. Defaults to the page. + sig { returns(T.nilable(String)) } + attr_reader :container + + sig { params(container: String).void } + attr_writer :container + + # Direction to scroll. Defaults to down. + sig do + returns( + T.nilable( + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction::OrSymbol + ) + ) + end + attr_reader :direction + + sig do + params( + direction: + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction::OrSymbol + ).void + end + attr_writer :direction + + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + sig { returns(T.nilable(Integer)) } + attr_reader :max_scrolls + + sig { params(max_scrolls: Integer).void } + attr_writer :max_scrolls + + # Scroll the page or a selected scrollable container, waiting adaptively for + # content and dimensions to settle after each iteration. + sig do + params( + amount: + T.any( + Integer, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount::OrSymbol + ), + container: String, + direction: + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction::OrSymbol, + max_scrolls: Integer, + do_: Symbol + ).returns(T.attached_class) + end + def self.new( + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + amount: nil, + # CSS selector for the first matching scroll container. Defaults to the page. + container: nil, + # Direction to scroll. Defaults to down. + direction: nil, + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + max_scrolls: nil, + do_: :scroll + ) + end + + sig do + override.returns( + { + do_: Symbol, + amount: + T.any( + Integer, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount::OrSymbol + ), + container: String, + direction: + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction::OrSymbol, + max_scrolls: Integer + } + ) + end + def to_hash + end + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + module Amount + extend ContextDev::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Integer, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount::TaggedSymbol + ) + end + + sig do + override.returns( + T::Array[ + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount::Variants + ] + ) + end + def self.variants + end + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIEWPORT = + T.let( + :viewport, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount::TaggedSymbol + ) + MAX = + T.let( + :max, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Amount::TaggedSymbol + ) + end + + # Direction to scroll. Defaults to down. + module Direction + extend ContextDev::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + UP = + T.let( + :up, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction::TaggedSymbol + ) + DOWN = + T.let( + :down, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction::TaggedSymbol + ) + LEFT = + T.let( + :left, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction::TaggedSymbol + ) + RIGHT = + T.let( + :right, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + ContextDev::WebWebScrapeImagesParams::Action::Scroll::Direction::TaggedSymbol + ] + ) + end + def self.values + end + end + end + sig do override.returns( T::Array[ContextDev::WebWebScrapeImagesParams::Action::Variants] diff --git a/rbi/context_dev/models/web_web_scrape_images_response.rbi b/rbi/context_dev/models/web_web_scrape_images_response.rbi index 4bec769e..f05ac660 100644 --- a/rbi/context_dev/models/web_web_scrape_images_response.rbi +++ b/rbi/context_dev/models/web_web_scrape_images_response.rbi @@ -29,6 +29,28 @@ module ContextDev sig { returns(String) } attr_accessor :url + # One verified outcome per requested browser action, in request order. + sig do + returns( + T.nilable( + T::Array[ + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied + ] + ) + ) + end + attr_reader :actions_applied + + sig do + params( + actions_applied: + T::Array[ + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::OrHash + ] + ).void + end + attr_writer :actions_applied + # Metadata about the API key used for the request. Included in every response # whenever a valid API key is provided, even when the response status is not 200. sig do @@ -55,6 +77,10 @@ module ContextDev success: ContextDev::Models::WebWebScrapeImagesResponse::Success::OrBoolean, url: String, + actions_applied: + T::Array[ + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::OrHash + ], key_metadata: ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata::OrHash ).returns(T.attached_class) @@ -66,6 +92,8 @@ module ContextDev success:, # Page URL that was scraped. url:, + # One verified outcome per requested browser action, in request order. + actions_applied: nil, # Metadata about the API key used for the request. Included in every response # whenever a valid API key is provided, even when the response status is not 200. key_metadata: nil @@ -80,6 +108,10 @@ module ContextDev success: ContextDev::Models::WebWebScrapeImagesResponse::Success::TaggedBoolean, url: String, + actions_applied: + T::Array[ + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied + ], key_metadata: ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata } @@ -484,6 +516,143 @@ module ContextDev end end + class ActionsApplied < ContextDev::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied, + ContextDev::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :instruction + + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + sig do + returns( + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status::TaggedSymbol + ) + end + attr_accessor :status + + # Visible page evidence used to verify an applied action. + sig { returns(T.nilable(String)) } + attr_reader :completion_evidence + + sig { params(completion_evidence: String).void } + attr_writer :completion_evidence + + sig { returns(T.nilable(Float)) } + attr_reader :duration_ms + + sig { params(duration_ms: Float).void } + attr_writer :duration_ms + + sig { returns(T.nilable(String)) } + attr_reader :error + + sig { params(error: String).void } + attr_writer :error + + sig { returns(T.nilable(String)) } + attr_reader :method_ + + sig { params(method_: String).void } + attr_writer :method_ + + sig { returns(T.nilable(String)) } + attr_reader :target_description + + sig { params(target_description: String).void } + attr_writer :target_description + + sig do + params( + instruction: String, + status: + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status::OrSymbol, + completion_evidence: String, + duration_ms: Float, + error: String, + method_: String, + target_description: String + ).returns(T.attached_class) + end + def self.new( + instruction:, + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + status:, + # Visible page evidence used to verify an applied action. + completion_evidence: nil, + duration_ms: nil, + error: nil, + method_: nil, + target_description: nil + ) + end + + sig do + override.returns( + { + instruction: String, + status: + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status::TaggedSymbol, + completion_evidence: String, + duration_ms: Float, + error: String, + method_: String, + target_description: String + } + ) + end + def to_hash + end + + # Applied means the requested page state was visibly verified. Failed means it was + # not verified. Skipped means it was not attempted. + module Status + extend ContextDev::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + APPLIED = + T.let( + :applied, + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status::TaggedSymbol + ) + FAILED = + T.let( + :failed, + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status::TaggedSymbol + ) + SKIPPED = + T.let( + :skipped, + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::Status::TaggedSymbol + ] + ) + end + def self.values + end + end + end + class KeyMetadata < ContextDev::Internal::Type::BaseModel OrHash = T.type_alias do diff --git a/rbi/context_dev/models/web_web_scrape_md_params.rbi b/rbi/context_dev/models/web_web_scrape_md_params.rbi index 0ff34b7a..b90ea2c6 100644 --- a/rbi/context_dev/models/web_web_scrape_md_params.rbi +++ b/rbi/context_dev/models/web_web_scrape_md_params.rbi @@ -25,7 +25,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeMdParams::Action::Wait, - ContextDev::WebWebScrapeMdParams::Action::Perform + ContextDev::WebWebScrapeMdParams::Action::Perform, + ContextDev::WebWebScrapeMdParams::Action::Scroll ) ] ) @@ -179,7 +180,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeMdParams::Action::Wait::OrHash, - ContextDev::WebWebScrapeMdParams::Action::Perform::OrHash + ContextDev::WebWebScrapeMdParams::Action::Perform::OrHash, + ContextDev::WebWebScrapeMdParams::Action::Scroll::OrHash ) ] ), @@ -281,7 +283,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeMdParams::Action::Wait, - ContextDev::WebWebScrapeMdParams::Action::Perform + ContextDev::WebWebScrapeMdParams::Action::Perform, + ContextDev::WebWebScrapeMdParams::Action::Scroll ) ] ), @@ -318,7 +321,8 @@ module ContextDev T.type_alias do T.any( ContextDev::WebWebScrapeMdParams::Action::Wait, - ContextDev::WebWebScrapeMdParams::Action::Perform + ContextDev::WebWebScrapeMdParams::Action::Perform, + ContextDev::WebWebScrapeMdParams::Action::Scroll ) end @@ -374,6 +378,216 @@ module ContextDev end end + class Scroll < ContextDev::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + ContextDev::WebWebScrapeMdParams::Action::Scroll, + ContextDev::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :do_ + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + sig do + returns( + T.nilable( + T.any( + Integer, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount::OrSymbol + ) + ) + ) + end + attr_reader :amount + + sig do + params( + amount: + T.any( + Integer, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount::OrSymbol + ) + ).void + end + attr_writer :amount + + # CSS selector for the first matching scroll container. Defaults to the page. + sig { returns(T.nilable(String)) } + attr_reader :container + + sig { params(container: String).void } + attr_writer :container + + # Direction to scroll. Defaults to down. + sig do + returns( + T.nilable( + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction::OrSymbol + ) + ) + end + attr_reader :direction + + sig do + params( + direction: + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction::OrSymbol + ).void + end + attr_writer :direction + + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + sig { returns(T.nilable(Integer)) } + attr_reader :max_scrolls + + sig { params(max_scrolls: Integer).void } + attr_writer :max_scrolls + + # Scroll the page or a selected scrollable container, waiting adaptively for + # content and dimensions to settle after each iteration. + sig do + params( + amount: + T.any( + Integer, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount::OrSymbol + ), + container: String, + direction: + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction::OrSymbol, + max_scrolls: Integer, + do_: Symbol + ).returns(T.attached_class) + end + def self.new( + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + amount: nil, + # CSS selector for the first matching scroll container. Defaults to the page. + container: nil, + # Direction to scroll. Defaults to down. + direction: nil, + # Maximum scroll iterations. Stops early when scrolling and scrollable extent stop + # changing. Defaults to 1. + max_scrolls: nil, + do_: :scroll + ) + end + + sig do + override.returns( + { + do_: Symbol, + amount: + T.any( + Integer, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount::OrSymbol + ), + container: String, + direction: + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction::OrSymbol, + max_scrolls: Integer + } + ) + end + def to_hash + end + + # Pixels per scroll, one visible viewport, or the current scroll boundary. + # Defaults to viewport. + module Amount + extend ContextDev::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Integer, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount::TaggedSymbol + ) + end + + sig do + override.returns( + T::Array[ + ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount::Variants + ] + ) + end + def self.variants + end + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIEWPORT = + T.let( + :viewport, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount::TaggedSymbol + ) + MAX = + T.let( + :max, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Amount::TaggedSymbol + ) + end + + # Direction to scroll. Defaults to down. + module Direction + extend ContextDev::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + UP = + T.let( + :up, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction::TaggedSymbol + ) + DOWN = + T.let( + :down, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction::TaggedSymbol + ) + LEFT = + T.let( + :left, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction::TaggedSymbol + ) + RIGHT = + T.let( + :right, + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + ContextDev::WebWebScrapeMdParams::Action::Scroll::Direction::TaggedSymbol + ] + ) + end + def self.values + end + end + end + sig do override.returns( T::Array[ContextDev::WebWebScrapeMdParams::Action::Variants] diff --git a/rbi/context_dev/resources/web.rbi b/rbi/context_dev/resources/web.rbi index b61dd31b..bacf45f1 100644 --- a/rbi/context_dev/resources/web.rbi +++ b/rbi/context_dev/resources/web.rbi @@ -9,6 +9,14 @@ module ContextDev params( schema: T::Hash[Symbol, T.anything], url: String, + actions: + T::Array[ + T.any( + ContextDev::WebExtractParams::Action::Wait::OrHash, + ContextDev::WebExtractParams::Action::Perform::OrHash, + ContextDev::WebExtractParams::Action::Scroll::OrHash + ) + ], fact_check: T::Boolean, follow_subdomains: T::Boolean, include_frames: T::Boolean, @@ -26,13 +34,20 @@ module ContextDev ).returns(ContextDev::Models::WebExtractResponse) end def extract( - # JSON Schema for the returned data object. TypeScript Zod users can pass a JSON - # Schema generated from a Zod object; Python users can pass the equivalent JSON - # Schema object. + # JSON Schema for the returned data object. Image fields such as `image_urls` or + # `product_photos` automatically make page image references available to + # extraction, so product data and photos can be returned in one call. TypeScript + # Zod users can pass a JSON Schema generated from a Zod object; Python users can + # pass the equivalent JSON Schema object. schema:, # The starting website URL to crawl and extract from. Must include http:// or # https://. url:, + # Optional browser actions executed in order on the requested page after it loads, + # before links are discovered or additional pages are crawled. Requires a paid + # plan. When actions are provided and stopAfterMs is omitted, the crawl budget + # defaults to 110000 ms. + actions: nil, # When true, every returned value must be grounded in facts stated on the page; # fields that cannot be supported by the page are returned as null/empty. When # false (default), the model may make reasonable inferences and derivations from @@ -61,7 +76,8 @@ module ContextDev # exchange for more stable output on animated pages. settle_animations: nil, # Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 - # (110s). Default: 80000 (80s). + # (110s). Defaults to 80000 (80s), or 110000 (110s) when browser actions are + # provided. stop_after_ms: nil, # Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters. tags: nil, @@ -408,13 +424,15 @@ module ContextDev # than this value, it will be aborted with a 408 status code. Maximum allowed # value is 300000ms (5 minutes). timeout_ms: nil, - # Regex pattern. Only URLs matching this pattern will be followed and scraped. + # Regex pattern. Only URLs matching this pattern will be followed and scraped. An + # automatic prefix scope in the form ^ follows a redirect of the + # starting page. url_regex: nil, # Extract only the main content, stripping headers, footers, sidebars, and # navigation use_main_content_only: nil, - # Optional browser wait time in milliseconds after initial page load for each - # crawled page. Min: 0. Max: 30000 (30 seconds). + # Browser wait time in milliseconds after initial page load for each crawled page. + # Defaults to 3500 (3.5 seconds). Min: 0. Max: 30000 (30 seconds). wait_for_ms: nil, # Set to enabled to bypass shared caches and omit request and response content # from retained usage logs. Requires zero data retention to be enabled for your @@ -435,7 +453,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeHTMLParams::Action::Wait::OrHash, - ContextDev::WebWebScrapeHTMLParams::Action::Perform::OrHash + ContextDev::WebWebScrapeHTMLParams::Action::Perform::OrHash, + ContextDev::WebWebScrapeHTMLParams::Action::Scroll::OrHash ) ] ), @@ -526,7 +545,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeImagesParams::Action::Wait::OrHash, - ContextDev::WebWebScrapeImagesParams::Action::Perform::OrHash + ContextDev::WebWebScrapeImagesParams::Action::Perform::OrHash, + ContextDev::WebWebScrapeImagesParams::Action::Scroll::OrHash ) ] ), @@ -615,7 +635,8 @@ module ContextDev T::Array[ T.any( ContextDev::WebWebScrapeMdParams::Action::Wait::OrHash, - ContextDev::WebWebScrapeMdParams::Action::Perform::OrHash + ContextDev::WebWebScrapeMdParams::Action::Perform::OrHash, + ContextDev::WebWebScrapeMdParams::Action::Scroll::OrHash ) ] ), diff --git a/sig/context_dev/models/ai_extract_product_response.rbs b/sig/context_dev/models/ai_extract_product_response.rbs index 2853a464..7d2872e9 100644 --- a/sig/context_dev/models/ai_extract_product_response.rbs +++ b/sig/context_dev/models/ai_extract_product_response.rbs @@ -78,12 +78,15 @@ module ContextDev sku: String?, tags: ::Array[String], target_audience: ::Array[String], + availability: ContextDev::Models::AIExtractProductResponse::Product::availability?, billing_frequency: ContextDev::Models::AIExtractProductResponse::Product::billing_frequency?, category: String?, currency: String?, + dimensions: ::Array[String], image_url: String?, price: Float?, pricing_model: ContextDev::Models::AIExtractProductResponse::Product::pricing_model?, + regular_price: Float?, url: String? } @@ -102,18 +105,26 @@ module ContextDev attr_accessor target_audience: ::Array[String] + attr_accessor availability: ContextDev::Models::AIExtractProductResponse::Product::availability? + attr_accessor billing_frequency: ContextDev::Models::AIExtractProductResponse::Product::billing_frequency? attr_accessor category: String? attr_accessor currency: String? + attr_reader dimensions: ::Array[String]? + + def dimensions=: (::Array[String]) -> ::Array[String] + attr_accessor image_url: String? attr_accessor price: Float? attr_accessor pricing_model: ContextDev::Models::AIExtractProductResponse::Product::pricing_model? + attr_accessor regular_price: Float? + attr_accessor url: String? def initialize: ( @@ -124,12 +135,15 @@ module ContextDev sku: String?, tags: ::Array[String], target_audience: ::Array[String], + ?availability: ContextDev::Models::AIExtractProductResponse::Product::availability?, ?billing_frequency: ContextDev::Models::AIExtractProductResponse::Product::billing_frequency?, ?category: String?, ?currency: String?, + ?dimensions: ::Array[String], ?image_url: String?, ?price: Float?, ?pricing_model: ContextDev::Models::AIExtractProductResponse::Product::pricing_model?, + ?regular_price: Float?, ?url: String? ) -> void @@ -141,15 +155,41 @@ module ContextDev sku: String?, tags: ::Array[String], target_audience: ::Array[String], + availability: ContextDev::Models::AIExtractProductResponse::Product::availability?, billing_frequency: ContextDev::Models::AIExtractProductResponse::Product::billing_frequency?, category: String?, currency: String?, + dimensions: ::Array[String], image_url: String?, price: Float?, pricing_model: ContextDev::Models::AIExtractProductResponse::Product::pricing_model?, + regular_price: Float?, url: String? } + type availability = + :in_stock + | :out_of_stock + | :limited_availability + | :preorder + | :backorder + | :made_to_order + | :discontinued + + module Availability + extend ContextDev::Internal::Type::Enum + + IN_STOCK: :in_stock + OUT_OF_STOCK: :out_of_stock + LIMITED_AVAILABILITY: :limited_availability + PREORDER: :preorder + BACKORDER: :backorder + MADE_TO_ORDER: :made_to_order + DISCONTINUED: :discontinued + + def self?.values: -> ::Array[ContextDev::Models::AIExtractProductResponse::Product::availability] + end + type billing_frequency = :monthly | :yearly | :one_time | :usage_based module BillingFrequency diff --git a/sig/context_dev/models/ai_extract_products_response.rbs b/sig/context_dev/models/ai_extract_products_response.rbs index f2d0a529..d327ebb4 100644 --- a/sig/context_dev/models/ai_extract_products_response.rbs +++ b/sig/context_dev/models/ai_extract_products_response.rbs @@ -57,12 +57,15 @@ module ContextDev sku: String?, tags: ::Array[String], target_audience: ::Array[String], + availability: ContextDev::Models::AIExtractProductsResponse::Product::availability?, billing_frequency: ContextDev::Models::AIExtractProductsResponse::Product::billing_frequency?, category: String?, currency: String?, + dimensions: ::Array[String], image_url: String?, price: Float?, pricing_model: ContextDev::Models::AIExtractProductsResponse::Product::pricing_model?, + regular_price: Float?, url: String? } @@ -81,18 +84,26 @@ module ContextDev attr_accessor target_audience: ::Array[String] + attr_accessor availability: ContextDev::Models::AIExtractProductsResponse::Product::availability? + attr_accessor billing_frequency: ContextDev::Models::AIExtractProductsResponse::Product::billing_frequency? attr_accessor category: String? attr_accessor currency: String? + attr_reader dimensions: ::Array[String]? + + def dimensions=: (::Array[String]) -> ::Array[String] + attr_accessor image_url: String? attr_accessor price: Float? attr_accessor pricing_model: ContextDev::Models::AIExtractProductsResponse::Product::pricing_model? + attr_accessor regular_price: Float? + attr_accessor url: String? def initialize: ( @@ -103,12 +114,15 @@ module ContextDev sku: String?, tags: ::Array[String], target_audience: ::Array[String], + ?availability: ContextDev::Models::AIExtractProductsResponse::Product::availability?, ?billing_frequency: ContextDev::Models::AIExtractProductsResponse::Product::billing_frequency?, ?category: String?, ?currency: String?, + ?dimensions: ::Array[String], ?image_url: String?, ?price: Float?, ?pricing_model: ContextDev::Models::AIExtractProductsResponse::Product::pricing_model?, + ?regular_price: Float?, ?url: String? ) -> void @@ -120,15 +134,41 @@ module ContextDev sku: String?, tags: ::Array[String], target_audience: ::Array[String], + availability: ContextDev::Models::AIExtractProductsResponse::Product::availability?, billing_frequency: ContextDev::Models::AIExtractProductsResponse::Product::billing_frequency?, category: String?, currency: String?, + dimensions: ::Array[String], image_url: String?, price: Float?, pricing_model: ContextDev::Models::AIExtractProductsResponse::Product::pricing_model?, + regular_price: Float?, url: String? } + type availability = + :in_stock + | :out_of_stock + | :limited_availability + | :preorder + | :backorder + | :made_to_order + | :discontinued + + module Availability + extend ContextDev::Internal::Type::Enum + + IN_STOCK: :in_stock + OUT_OF_STOCK: :out_of_stock + LIMITED_AVAILABILITY: :limited_availability + PREORDER: :preorder + BACKORDER: :backorder + MADE_TO_ORDER: :made_to_order + DISCONTINUED: :discontinued + + def self?.values: -> ::Array[ContextDev::Models::AIExtractProductsResponse::Product::availability] + end + type billing_frequency = :monthly | :yearly | :one_time | :usage_based module BillingFrequency diff --git a/sig/context_dev/models/news_search_params.rbs b/sig/context_dev/models/news_search_params.rbs index dfa0b2d6..609b1b2c 100644 --- a/sig/context_dev/models/news_search_params.rbs +++ b/sig/context_dev/models/news_search_params.rbs @@ -450,6 +450,7 @@ module ContextDev | :cg | :ch | :cl + | :cz | :de | :fi | :fr @@ -479,6 +480,7 @@ module ContextDev CG: :cg CH: :ch CL: :cl + CZ: :cz DE: :de FI: :fi FR: :fr diff --git a/sig/context_dev/models/web_extract_params.rbs b/sig/context_dev/models/web_extract_params.rbs index e04099ae..532cf546 100644 --- a/sig/context_dev/models/web_extract_params.rbs +++ b/sig/context_dev/models/web_extract_params.rbs @@ -4,6 +4,7 @@ module ContextDev { schema: ::Hash[Symbol, top], url: String, + actions: ::Array[ContextDev::Models::WebExtractParams::action], fact_check: bool, follow_subdomains: bool, include_frames: bool, @@ -28,6 +29,12 @@ module ContextDev attr_accessor url: String + attr_reader actions: ::Array[ContextDev::Models::WebExtractParams::action]? + + def actions=: ( + ::Array[ContextDev::Models::WebExtractParams::action] + ) -> ::Array[ContextDev::Models::WebExtractParams::action] + attr_reader fact_check: bool? def fact_check=: (bool) -> bool @@ -85,6 +92,7 @@ module ContextDev def initialize: ( schema: ::Hash[Symbol, top], url: String, + ?actions: ::Array[ContextDev::Models::WebExtractParams::action], ?fact_check: bool, ?follow_subdomains: bool, ?include_frames: bool, @@ -104,6 +112,7 @@ module ContextDev def to_hash: -> { schema: ::Hash[Symbol, top], url: String, + actions: ::Array[ContextDev::Models::WebExtractParams::action], fact_check: bool, follow_subdomains: bool, include_frames: bool, @@ -120,6 +129,114 @@ module ContextDev request_options: ContextDev::RequestOptions } + type action = + ContextDev::WebExtractParams::Action::Wait + | ContextDev::WebExtractParams::Action::Perform + | ContextDev::WebExtractParams::Action::Scroll + + module Action + extend ContextDev::Internal::Type::Union + + type wait = { do_: :wait, time_ms: Integer } + + class Wait < ContextDev::Internal::Type::BaseModel + attr_accessor do_: :wait + + attr_accessor time_ms: Integer + + def initialize: (time_ms: Integer, ?do_: :wait) -> void + + def to_hash: -> { do_: :wait, time_ms: Integer } + end + + type perform = { action: String, do_: :perform } + + class Perform < ContextDev::Internal::Type::BaseModel + attr_accessor action: String + + attr_accessor do_: :perform + + def initialize: (action: String, ?do_: :perform) -> void + + def to_hash: -> { action: String, do_: :perform } + end + + type scroll = + { + do_: :scroll, + amount: ContextDev::Models::WebExtractParams::Action::Scroll::amount, + container: String, + direction: ContextDev::Models::WebExtractParams::Action::Scroll::direction, + max_scrolls: Integer + } + + class Scroll < ContextDev::Internal::Type::BaseModel + attr_accessor do_: :scroll + + attr_reader amount: ContextDev::Models::WebExtractParams::Action::Scroll::amount? + + def amount=: ( + ContextDev::Models::WebExtractParams::Action::Scroll::amount + ) -> ContextDev::Models::WebExtractParams::Action::Scroll::amount + + attr_reader container: String? + + def container=: (String) -> String + + attr_reader direction: ContextDev::Models::WebExtractParams::Action::Scroll::direction? + + def direction=: ( + ContextDev::Models::WebExtractParams::Action::Scroll::direction + ) -> ContextDev::Models::WebExtractParams::Action::Scroll::direction + + attr_reader max_scrolls: Integer? + + def max_scrolls=: (Integer) -> Integer + + def initialize: ( + ?amount: ContextDev::Models::WebExtractParams::Action::Scroll::amount, + ?container: String, + ?direction: ContextDev::Models::WebExtractParams::Action::Scroll::direction, + ?max_scrolls: Integer, + ?do_: :scroll + ) -> void + + def to_hash: -> { + do_: :scroll, + amount: ContextDev::Models::WebExtractParams::Action::Scroll::amount, + container: String, + direction: ContextDev::Models::WebExtractParams::Action::Scroll::direction, + max_scrolls: Integer + } + + type amount = Integer | :viewport | :max + + module Amount + extend ContextDev::Internal::Type::Union + + def self?.variants: -> ::Array[ContextDev::Models::WebExtractParams::Action::Scroll::amount] + + VIEWPORT: :viewport + MAX: :max + end + + type direction = :up | :down | :left | :right + + module Direction + extend ContextDev::Internal::Type::Enum + + UP: :up + DOWN: :down + LEFT: :left + RIGHT: :right + + def self?.values: -> ::Array[ContextDev::Models::WebExtractParams::Action::Scroll::direction] + end + end + + def self?.variants: -> ::Array[ContextDev::Models::WebExtractParams::action] + end + type pdf = { end_: Integer, should_parse: bool, start: Integer } class Pdf < ContextDev::Internal::Type::BaseModel diff --git a/sig/context_dev/models/web_extract_response.rbs b/sig/context_dev/models/web_extract_response.rbs index 91e9bf30..59142056 100644 --- a/sig/context_dev/models/web_extract_response.rbs +++ b/sig/context_dev/models/web_extract_response.rbs @@ -52,7 +52,8 @@ module ContextDev num_failed: Integer, num_skipped: Integer, num_succeeded: Integer, - num_urls: Integer + num_urls: Integer, + actions_applied: ::Array[ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied] } class Metadata < ContextDev::Internal::Type::BaseModel @@ -68,13 +69,20 @@ module ContextDev attr_accessor num_urls: Integer + attr_reader actions_applied: ::Array[ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied]? + + def actions_applied=: ( + ::Array[ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied] + ) -> ::Array[ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied] + def initialize: ( max_crawl_depth: Integer, num_blocked: Integer, num_failed: Integer, num_skipped: Integer, num_succeeded: Integer, - num_urls: Integer + num_urls: Integer, + ?actions_applied: ::Array[ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied] ) -> void def to_hash: -> { @@ -83,8 +91,78 @@ module ContextDev num_failed: Integer, num_skipped: Integer, num_succeeded: Integer, - num_urls: Integer + num_urls: Integer, + actions_applied: ::Array[ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied] } + + type actions_applied = + { + instruction: String, + status: ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::status, + completion_evidence: String, + duration_ms: Float, + error: String, + method_: String, + target_description: String + } + + class ActionsApplied < ContextDev::Internal::Type::BaseModel + attr_accessor instruction: String + + attr_accessor status: ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::status + + attr_reader completion_evidence: String? + + def completion_evidence=: (String) -> String + + attr_reader duration_ms: Float? + + def duration_ms=: (Float) -> Float + + attr_reader error: String? + + def error=: (String) -> String + + attr_reader method_: String? + + def method_=: (String) -> String + + attr_reader target_description: String? + + def target_description=: (String) -> String + + def initialize: ( + instruction: String, + status: ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::status, + ?completion_evidence: String, + ?duration_ms: Float, + ?error: String, + ?method_: String, + ?target_description: String + ) -> void + + def to_hash: -> { + instruction: String, + status: ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::status, + completion_evidence: String, + duration_ms: Float, + error: String, + method_: String, + target_description: String + } + + type status = :applied | :failed | :skipped + + module Status + extend ContextDev::Internal::Type::Enum + + APPLIED: :applied + FAILED: :failed + SKIPPED: :skipped + + def self?.values: -> ::Array[ContextDev::Models::WebExtractResponse::Metadata::ActionsApplied::status] + end + end end type key_metadata = diff --git a/sig/context_dev/models/web_web_scrape_html_params.rbs b/sig/context_dev/models/web_web_scrape_html_params.rbs index e5b2264c..40c992ff 100644 --- a/sig/context_dev/models/web_web_scrape_html_params.rbs +++ b/sig/context_dev/models/web_web_scrape_html_params.rbs @@ -119,6 +119,7 @@ module ContextDev type action = ContextDev::WebWebScrapeHTMLParams::Action::Wait | ContextDev::WebWebScrapeHTMLParams::Action::Perform + | ContextDev::WebWebScrapeHTMLParams::Action::Scroll module Action extend ContextDev::Internal::Type::Union @@ -147,6 +148,79 @@ module ContextDev def to_hash: -> { action: String, do_: :perform } end + type scroll = + { + do_: :scroll, + amount: ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::amount, + container: String, + direction: ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::direction, + max_scrolls: Integer + } + + class Scroll < ContextDev::Internal::Type::BaseModel + attr_accessor do_: :scroll + + attr_reader amount: ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::amount? + + def amount=: ( + ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::amount + ) -> ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::amount + + attr_reader container: String? + + def container=: (String) -> String + + attr_reader direction: ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::direction? + + def direction=: ( + ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::direction + ) -> ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::direction + + attr_reader max_scrolls: Integer? + + def max_scrolls=: (Integer) -> Integer + + def initialize: ( + ?amount: ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::amount, + ?container: String, + ?direction: ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::direction, + ?max_scrolls: Integer, + ?do_: :scroll + ) -> void + + def to_hash: -> { + do_: :scroll, + amount: ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::amount, + container: String, + direction: ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::direction, + max_scrolls: Integer + } + + type amount = Integer | :viewport | :max + + module Amount + extend ContextDev::Internal::Type::Union + + def self?.variants: -> ::Array[ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::amount] + + VIEWPORT: :viewport + MAX: :max + end + + type direction = :up | :down | :left | :right + + module Direction + extend ContextDev::Internal::Type::Enum + + UP: :up + DOWN: :down + LEFT: :left + RIGHT: :right + + def self?.values: -> ::Array[ContextDev::Models::WebWebScrapeHTMLParams::Action::Scroll::direction] + end + end + def self?.variants: -> ::Array[ContextDev::Models::WebWebScrapeHTMLParams::action] end diff --git a/sig/context_dev/models/web_web_scrape_images_params.rbs b/sig/context_dev/models/web_web_scrape_images_params.rbs index d9a027c2..e9913f45 100644 --- a/sig/context_dev/models/web_web_scrape_images_params.rbs +++ b/sig/context_dev/models/web_web_scrape_images_params.rbs @@ -73,6 +73,7 @@ module ContextDev type action = ContextDev::WebWebScrapeImagesParams::Action::Wait | ContextDev::WebWebScrapeImagesParams::Action::Perform + | ContextDev::WebWebScrapeImagesParams::Action::Scroll module Action extend ContextDev::Internal::Type::Union @@ -101,6 +102,79 @@ module ContextDev def to_hash: -> { action: String, do_: :perform } end + type scroll = + { + do_: :scroll, + amount: ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::amount, + container: String, + direction: ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::direction, + max_scrolls: Integer + } + + class Scroll < ContextDev::Internal::Type::BaseModel + attr_accessor do_: :scroll + + attr_reader amount: ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::amount? + + def amount=: ( + ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::amount + ) -> ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::amount + + attr_reader container: String? + + def container=: (String) -> String + + attr_reader direction: ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::direction? + + def direction=: ( + ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::direction + ) -> ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::direction + + attr_reader max_scrolls: Integer? + + def max_scrolls=: (Integer) -> Integer + + def initialize: ( + ?amount: ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::amount, + ?container: String, + ?direction: ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::direction, + ?max_scrolls: Integer, + ?do_: :scroll + ) -> void + + def to_hash: -> { + do_: :scroll, + amount: ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::amount, + container: String, + direction: ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::direction, + max_scrolls: Integer + } + + type amount = Integer | :viewport | :max + + module Amount + extend ContextDev::Internal::Type::Union + + def self?.variants: -> ::Array[ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::amount] + + VIEWPORT: :viewport + MAX: :max + end + + type direction = :up | :down | :left | :right + + module Direction + extend ContextDev::Internal::Type::Enum + + UP: :up + DOWN: :down + LEFT: :left + RIGHT: :right + + def self?.values: -> ::Array[ContextDev::Models::WebWebScrapeImagesParams::Action::Scroll::direction] + end + end + def self?.variants: -> ::Array[ContextDev::Models::WebWebScrapeImagesParams::action] end diff --git a/sig/context_dev/models/web_web_scrape_images_response.rbs b/sig/context_dev/models/web_web_scrape_images_response.rbs index fd5aa453..4bd88bac 100644 --- a/sig/context_dev/models/web_web_scrape_images_response.rbs +++ b/sig/context_dev/models/web_web_scrape_images_response.rbs @@ -5,6 +5,7 @@ module ContextDev images: ::Array[ContextDev::Models::WebWebScrapeImagesResponse::Image], success: ContextDev::Models::WebWebScrapeImagesResponse::success, url: String, + actions_applied: ::Array[ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied], key_metadata: ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata } @@ -15,6 +16,12 @@ module ContextDev attr_accessor url: String + attr_reader actions_applied: ::Array[ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied]? + + def actions_applied=: ( + ::Array[ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied] + ) -> ::Array[ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied] + attr_reader key_metadata: ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata? def key_metadata=: ( @@ -25,6 +32,7 @@ module ContextDev images: ::Array[ContextDev::Models::WebWebScrapeImagesResponse::Image], success: ContextDev::Models::WebWebScrapeImagesResponse::success, url: String, + ?actions_applied: ::Array[ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied], ?key_metadata: ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata ) -> void @@ -32,6 +40,7 @@ module ContextDev images: ::Array[ContextDev::Models::WebWebScrapeImagesResponse::Image], success: ContextDev::Models::WebWebScrapeImagesResponse::success, url: String, + actions_applied: ::Array[ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied], key_metadata: ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata } @@ -199,6 +208,75 @@ module ContextDev def self?.values: -> ::Array[ContextDev::Models::WebWebScrapeImagesResponse::success] end + type actions_applied = + { + instruction: String, + status: ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::status, + completion_evidence: String, + duration_ms: Float, + error: String, + method_: String, + target_description: String + } + + class ActionsApplied < ContextDev::Internal::Type::BaseModel + attr_accessor instruction: String + + attr_accessor status: ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::status + + attr_reader completion_evidence: String? + + def completion_evidence=: (String) -> String + + attr_reader duration_ms: Float? + + def duration_ms=: (Float) -> Float + + attr_reader error: String? + + def error=: (String) -> String + + attr_reader method_: String? + + def method_=: (String) -> String + + attr_reader target_description: String? + + def target_description=: (String) -> String + + def initialize: ( + instruction: String, + status: ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::status, + ?completion_evidence: String, + ?duration_ms: Float, + ?error: String, + ?method_: String, + ?target_description: String + ) -> void + + def to_hash: -> { + instruction: String, + status: ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::status, + completion_evidence: String, + duration_ms: Float, + error: String, + method_: String, + target_description: String + } + + type status = :applied | :failed | :skipped + + module Status + extend ContextDev::Internal::Type::Enum + + APPLIED: :applied + FAILED: :failed + SKIPPED: :skipped + + def self?.values: -> ::Array[ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied::status] + end + end + type key_metadata = { credits_consumed: Integer, credits_remaining: Integer } diff --git a/sig/context_dev/models/web_web_scrape_md_params.rbs b/sig/context_dev/models/web_web_scrape_md_params.rbs index 9f8a3aec..2c16d38c 100644 --- a/sig/context_dev/models/web_web_scrape_md_params.rbs +++ b/sig/context_dev/models/web_web_scrape_md_params.rbs @@ -147,6 +147,7 @@ module ContextDev type action = ContextDev::WebWebScrapeMdParams::Action::Wait | ContextDev::WebWebScrapeMdParams::Action::Perform + | ContextDev::WebWebScrapeMdParams::Action::Scroll module Action extend ContextDev::Internal::Type::Union @@ -175,6 +176,79 @@ module ContextDev def to_hash: -> { action: String, do_: :perform } end + type scroll = + { + do_: :scroll, + amount: ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::amount, + container: String, + direction: ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::direction, + max_scrolls: Integer + } + + class Scroll < ContextDev::Internal::Type::BaseModel + attr_accessor do_: :scroll + + attr_reader amount: ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::amount? + + def amount=: ( + ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::amount + ) -> ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::amount + + attr_reader container: String? + + def container=: (String) -> String + + attr_reader direction: ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::direction? + + def direction=: ( + ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::direction + ) -> ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::direction + + attr_reader max_scrolls: Integer? + + def max_scrolls=: (Integer) -> Integer + + def initialize: ( + ?amount: ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::amount, + ?container: String, + ?direction: ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::direction, + ?max_scrolls: Integer, + ?do_: :scroll + ) -> void + + def to_hash: -> { + do_: :scroll, + amount: ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::amount, + container: String, + direction: ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::direction, + max_scrolls: Integer + } + + type amount = Integer | :viewport | :max + + module Amount + extend ContextDev::Internal::Type::Union + + def self?.variants: -> ::Array[ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::amount] + + VIEWPORT: :viewport + MAX: :max + end + + type direction = :up | :down | :left | :right + + module Direction + extend ContextDev::Internal::Type::Enum + + UP: :up + DOWN: :down + LEFT: :left + RIGHT: :right + + def self?.values: -> ::Array[ContextDev::Models::WebWebScrapeMdParams::Action::Scroll::direction] + end + end + def self?.variants: -> ::Array[ContextDev::Models::WebWebScrapeMdParams::action] end diff --git a/sig/context_dev/resources/web.rbs b/sig/context_dev/resources/web.rbs index 40ebce6e..7e883cdc 100644 --- a/sig/context_dev/resources/web.rbs +++ b/sig/context_dev/resources/web.rbs @@ -4,6 +4,7 @@ module ContextDev def extract: ( schema: ::Hash[Symbol, top], url: String, + ?actions: ::Array[ContextDev::Models::WebExtractParams::action], ?fact_check: bool, ?follow_subdomains: bool, ?include_frames: bool, diff --git a/test/context_dev/resources/web_test.rb b/test/context_dev/resources/web_test.rb index b3f2c6a5..cb68886d 100644 --- a/test/context_dev/resources/web_test.rb +++ b/test/context_dev/resources/web_test.rb @@ -185,6 +185,7 @@ def test_web_scrape_images_required_params images: ^(ContextDev::Internal::Type::ArrayOf[ContextDev::Models::WebWebScrapeImagesResponse::Image]), success: ContextDev::Models::WebWebScrapeImagesResponse::Success, url: String, + actions_applied: ^(ContextDev::Internal::Type::ArrayOf[ContextDev::Models::WebWebScrapeImagesResponse::ActionsApplied]) | nil, key_metadata: ContextDev::Models::WebWebScrapeImagesResponse::KeyMetadata | nil } end