diff --git a/.release-please-manifest.json b/.release-please-manifest.json index c3c9552..31d8238 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.9.0" + ".": "1.28.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 1fd2991..76e9cb4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 41 +configured_endpoints: 40 diff --git a/CHANGELOG.md b/CHANGELOG.md index 37e8d11..e3b3100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,362 @@ # Changelog +## [1.28.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.27.0...v1.28.0) (2026-11-12) + + +### Features + +* **zdr:** accept zero data retention on people search and company search ([#2852](https://github.com/context-dot-dev/context-dev-cli/issues/2852)) ([a586170](https://github.com/context-dot-dev/context-dev-cli/commit/a586170472c5ba3999aa9ebbeabeff05cf9457ff)) + +## [1.27.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.26.0...v1.27.0) (2026-11-09) + + +### Features + +* **parse:** support WARC archives in parsing and scraping ([#2761](https://github.com/context-dot-dev/context-dev-cli/issues/2761)) ([2c4ef4b](https://github.com/context-dot-dev/context-dev-cli/commit/2c4ef4b28b8b40a9f8bd079ba3bf311a71ede93c)) + +## [1.26.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.25.0...v1.26.0) (2026-11-08) + + +### Features + +* **batch:** raise batch submissions to 2,500 per minute per organization ([#2734](https://github.com/context-dot-dev/context-dev-cli/issues/2734)) ([e06a001](https://github.com/context-dot-dev/context-dev-cli/commit/e06a0014ce50c79ad9006c66104972323dc1d410)) + +## [1.25.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.24.1...v1.25.0) (2026-11-07) + + +### Features + +* **batch:** accept lightweight submissions and queue pending work ([#2683](https://github.com/context-dot-dev/context-dev-cli/issues/2683)) ([140be90](https://github.com/context-dot-dev/context-dev-cli/commit/140be90f1d0df87d23df1d5898dd86a9617d2eae)) + +## [1.24.1](https://github.com/context-dot-dev/context-dev-cli/compare/v1.24.0...v1.24.1) (2026-11-05) + + +### Documentation + +* **logs:** say that a request log appears a few seconds after the request ([#2564](https://github.com/context-dot-dev/context-dev-cli/issues/2564)) ([177caae](https://github.com/context-dot-dev/context-dev-cli/commit/177caaeff369bbf15957648f429c842207960cd5)) + +## [1.24.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.23.1...v1.24.0) (2026-11-05) + + +### Features + +* **scrape:** add Tripadvisor reviews parser ([#2508](https://github.com/context-dot-dev/context-dev-cli/issues/2508)) ([3c2e330](https://github.com/context-dot-dev/context-dev-cli/commit/3c2e33014dce8b6ba7431072444394018de0db0e)) + +## [1.23.1](https://github.com/context-dot-dev/context-dev-cli/compare/v1.23.0...v1.23.1) (2026-10-29) + + +### Bug Fixes + +* **scrape:** derive the /web/scrape request spec from its zod schema ([#2044](https://github.com/context-dot-dev/context-dev-cli/issues/2044)) ([9d9a0d7](https://github.com/context-dot-dev/context-dev-cli/commit/9d9a0d73bd586e9ce7c7bcfd8090fc2f4e7066a8)) + +## [1.23.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.22.0...v1.23.0) (2026-10-28) + + +### Features + +* **access-policies:** limit which websites API requests can reach ([#2213](https://github.com/context-dot-dev/context-dev-cli/issues/2213)) ([de6d2cb](https://github.com/context-dot-dev/context-dev-cli/commit/de6d2cbfc75b87734e147d17054e3453eae0a9c1)) +* **access-policies:** limit which websites API requests can reach ([#2213](https://github.com/context-dot-dev/context-dev-cli/issues/2213)) ([d834285](https://github.com/context-dot-dev/context-dev-cli/commit/d834285939f71ee9f02a7e64f88060d7336c0327)) +* **access-policies:** limit which websites API requests can reach ([#2213](https://github.com/context-dot-dev/context-dev-cli/issues/2213)) ([8bcacae](https://github.com/context-dot-dev/context-dev-cli/commit/8bcacae1949b95afcc1c768aacfb25836bfd4bd8)) +* **access-policies:** limit which websites API requests can reach ([#2213](https://github.com/context-dot-dev/context-dev-cli/issues/2213)) ([b45f902](https://github.com/context-dot-dev/context-dev-cli/commit/b45f902e1d99193a4f78c694934650220c246387)) +* **brand:** support log-free brand and styleguide requests ([#2231](https://github.com/context-dot-dev/context-dev-cli/issues/2231)) ([de6d2cb](https://github.com/context-dot-dev/context-dev-cli/commit/de6d2cbfc75b87734e147d17054e3453eae0a9c1)) +* **brand:** support log-free brand and styleguide requests ([#2231](https://github.com/context-dot-dev/context-dev-cli/issues/2231)) ([d834285](https://github.com/context-dot-dev/context-dev-cli/commit/d834285939f71ee9f02a7e64f88060d7336c0327)) +* **brand:** support log-free brand and styleguide requests ([#2231](https://github.com/context-dot-dev/context-dev-cli/issues/2231)) ([8bcacae](https://github.com/context-dot-dev/context-dev-cli/commit/8bcacae1949b95afcc1c768aacfb25836bfd4bd8)) +* **monitors:** add search target to watch the web for new developments ([#2215](https://github.com/context-dot-dev/context-dev-cli/issues/2215)) ([de6d2cb](https://github.com/context-dot-dev/context-dev-cli/commit/de6d2cbfc75b87734e147d17054e3453eae0a9c1)) + + +### Bug Fixes + +* **brand:** keep metadata-only usage logs for ZDR brand requests ([#2234](https://github.com/context-dot-dev/context-dev-cli/issues/2234)) ([de6d2cb](https://github.com/context-dot-dev/context-dev-cli/commit/de6d2cbfc75b87734e147d17054e3453eae0a9c1)) +* **brand:** keep metadata-only usage logs for ZDR brand requests ([#2234](https://github.com/context-dot-dev/context-dev-cli/issues/2234)) ([d834285](https://github.com/context-dot-dev/context-dev-cli/commit/d834285939f71ee9f02a7e64f88060d7336c0327)) +* **openapi:** keep legacy batch inputs in the spec as deprecated ([#2225](https://github.com/context-dot-dev/context-dev-cli/issues/2225)) ([de6d2cb](https://github.com/context-dot-dev/context-dev-cli/commit/de6d2cbfc75b87734e147d17054e3453eae0a9c1)) +* **openapi:** keep legacy batch inputs in the spec as deprecated ([#2225](https://github.com/context-dot-dev/context-dev-cli/issues/2225)) ([d834285](https://github.com/context-dot-dev/context-dev-cli/commit/d834285939f71ee9f02a7e64f88060d7336c0327)) +* **openapi:** keep legacy batch inputs in the spec as deprecated ([#2225](https://github.com/context-dot-dev/context-dev-cli/issues/2225)) ([8bcacae](https://github.com/context-dot-dev/context-dev-cli/commit/8bcacae1949b95afcc1c768aacfb25836bfd4bd8)) +* **openapi:** keep legacy batch inputs in the spec as deprecated ([#2225](https://github.com/context-dot-dev/context-dev-cli/issues/2225)) ([b45f902](https://github.com/context-dot-dev/context-dev-cli/commit/b45f902e1d99193a4f78c694934650220c246387)) + +## [1.22.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.21.1...v1.22.0) (2026-10-27) + + +### Features + +* **parse:** mark PDF page numbers inline in Markdown with includeNumberedPages ([#2110](https://github.com/context-dot-dev/context-dev-cli/issues/2110)) ([56653ad](https://github.com/context-dot-dev/context-dev-cli/commit/56653ad48cadf607d345179a60b08dac28b04473)) + + +### Bug Fixes + +* **people:** split ultra people ranking on its strongest phrase signals ([#2209](https://github.com/context-dot-dev/context-dev-cli/issues/2209)) ([29fdba0](https://github.com/context-dot-dev/context-dev-cli/commit/29fdba02207215a66d76d0455c97ea1fdaf9e867)) + +## [1.21.1](https://github.com/context-dot-dev/context-dev-cli/compare/v1.21.0...v1.21.1) (2026-10-27) + + +### Documentation + +* **people:** note that complex ultra people searches can take up to 60 seconds ([#2206](https://github.com/context-dot-dev/context-dev-cli/issues/2206)) ([1486b9b](https://github.com/context-dot-dev/context-dev-cli/commit/1486b9bbaf9b344291159d73cbb4df1d9c5f2871)) + +## [1.21.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.20.0...v1.21.0) (2026-10-27) + + +### Features + +* **people:** add ultra mode to people search ([#2149](https://github.com/context-dot-dev/context-dev-cli/issues/2149)) ([519ce28](https://github.com/context-dot-dev/context-dev-cli/commit/519ce28caa2dbf5bb5d04578fc52412414dee232)) + +## [1.20.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.19.1...v1.20.0) (2026-10-26) + + +### Features + +* **people:** publish people search in the API specification ([#2094](https://github.com/context-dot-dev/context-dev-cli/issues/2094)) ([a4ebbf1](https://github.com/context-dot-dev/context-dev-cli/commit/a4ebbf18af3825489773684de04a2e974f4e05b5)) + +## [1.19.1](https://github.com/context-dot-dev/context-dev-cli/compare/v1.19.0...v1.19.1) (2026-10-21) + + +### Documentation + +* **openapi:** unify regex wording and shorten sourcePreference descriptions ([#2051](https://github.com/context-dot-dev/context-dev-cli/issues/2051)) ([e4e8b47](https://github.com/context-dot-dev/context-dev-cli/commit/e4e8b478ad6b55fb6059f5ab1deb5b80c057e2a2)) + +## [1.19.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.18.1...v1.19.0) (2026-10-21) + + +### Features + +* **scrape:** add sourcePreference to choose between HTML conversion and published Markdown ([#2010](https://github.com/context-dot-dev/context-dev-cli/issues/2010)) ([fcdf0a1](https://github.com/context-dot-dev/context-dev-cli/commit/fcdf0a17ac9a9ffa7fd786e1cf1ec767986183a1)) + +## [1.18.1](https://github.com/context-dot-dev/context-dev-cli/compare/v1.18.0...v1.18.1) (2026-10-21) + + +### Bug Fixes + +* **openapi:** document request_id and key_metadata on every response in one place ([#2042](https://github.com/context-dot-dev/context-dev-cli/issues/2042)) ([d5a84d7](https://github.com/context-dot-dev/context-dev-cli/commit/d5a84d70c84415ceb67b3b4776b2087ca90e0841)) + +## [1.18.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.17.0...v1.18.0) (2026-10-21) + + +### Features + +* **company-search:** prepare public response contract ([#2021](https://github.com/context-dot-dev/context-dev-cli/issues/2021)) ([2aebf21](https://github.com/context-dot-dev/context-dev-cli/commit/2aebf210f72f171fa351b37c2d904a42993d3a9a)) + +## [1.17.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.16.0...v1.17.0) (2026-10-19) + + +### Features + +* **crawl:** add exclude URL regex to crawl and sitemap endpoints ([#1982](https://github.com/context-dot-dev/context-dev-cli/issues/1982)) ([70096c2](https://github.com/context-dot-dev/context-dev-cli/commit/70096c2b04297fdf7827e4fa7d937b69dbe45878)) + +## [1.16.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.15.0...v1.16.0) (2026-10-19) + + +### Features + +* **news:** add natural-language search to POST /news/search ([#1975](https://github.com/context-dot-dev/context-dev-cli/issues/1975)) ([b9fdc24](https://github.com/context-dot-dev/context-dev-cli/commit/b9fdc241fcf37d84f848514c5f02eee4510f7560)) + +## [1.15.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.14.0...v1.15.0) (2026-10-18) + + +### Features + +* **people:** allow enrichment on free plans ([#1961](https://github.com/context-dot-dev/context-dev-cli/issues/1961)) ([28cee50](https://github.com/context-dot-dev/context-dev-cli/commit/28cee504b98775250d6655f3dabc413881d42fd8)) + +## [1.14.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.13.1...v1.14.0) (2026-10-17) + + +### Features + +* **batches:** keep batch result files for 180 days ([#1638](https://github.com/context-dot-dev/context-dev-cli/issues/1638)) ([a63190d](https://github.com/context-dot-dev/context-dev-cli/commit/a63190db1976e55c6f108bf8d00aab9f5fbf9f34)) +* **batch:** support Scrape Anything batches up to 100k URLs ([#1883](https://github.com/context-dot-dev/context-dev-cli/issues/1883)) ([403f0b2](https://github.com/context-dot-dev/context-dev-cli/commit/403f0b2c6bc0829d489f77820706306b0892d210)) +* **brand:** add search metadata and country and language filters ([#1945](https://github.com/context-dot-dev/context-dev-cli/issues/1945)) ([62df7fe](https://github.com/context-dot-dev/context-dev-cli/commit/62df7fe640328a3d22cc1b9e8cf8f67dcb21dc28)) +* **search:** /web/search - for news results extend description with matching passages from article. ([563d59d](https://github.com/context-dot-dev/context-dev-cli/commit/563d59d3ebc0ff8ddd40c20fac1e82b843ecf2d5)) +* **search:** add languages filter to web search ([#1833](https://github.com/context-dot-dev/context-dev-cli/issues/1833)) ([90701fc](https://github.com/context-dot-dev/context-dev-cli/commit/90701fca61494842859958c9d33c62f6d6f495b0)) +* **search:** allow requesting a single result ([#1880](https://github.com/context-dot-dev/context-dev-cli/issues/1880)) ([fc43a74](https://github.com/context-dot-dev/context-dev-cli/commit/fc43a74e9c16576ec16142f674813b7567ea4601)) +* **web-search:** charge markdown per delivered page ([#1729](https://github.com/context-dot-dev/context-dev-cli/issues/1729)) ([d408dfc](https://github.com/context-dot-dev/context-dev-cli/commit/d408dfc3871e492825a6fbf6998de72e2db7ddcd)) + + +### Documentation + +* **sdks:** lead generated READMEs with Context.dev scraping ([#1669](https://github.com/context-dot-dev/context-dev-cli/issues/1669)) ([4d9adde](https://github.com/context-dot-dev/context-dev-cli/commit/4d9adde80335dfd702a23a3c4729dca5b35d4bf9)) + +## [1.13.1](https://github.com/context-dot-dev/context-dev-cli/compare/v1.13.0...v1.13.1) (2026-09-30) + + +### Bug Fixes + +* **api:** derive OpenAPI request docs from runtime Zod schemas ([#1421](https://github.com/context-dot-dev/context-dev-cli/issues/1421)) ([9d63939](https://github.com/context-dot-dev/context-dev-cli/commit/9d63939d08a20d32642a84788bf47d2c971979ff)) + +## [1.13.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.12.0...v1.13.0) (2026-09-29) + + +### Features + +* **answers:** route people and company research with faster answers ([#1336](https://github.com/context-dot-dev/context-dev-cli/issues/1336)) ([89aa64e](https://github.com/context-dot-dev/context-dev-cli/commit/89aa64eab8bd67244f8cb3c3c8a6135eec6d028b)) +* **monitors:** support browser actions on page monitors ([#1365](https://github.com/context-dot-dev/context-dev-cli/issues/1365)) ([1cf2e4a](https://github.com/context-dot-dev/context-dev-cli/commit/1cf2e4a95e62219aa6c70ceafed49d9d133ea70d)) +* **scrape:** default POST /web/scrape deadline to 90s ([#1428](https://github.com/context-dot-dev/context-dev-cli/issues/1428)) ([a3d1b58](https://github.com/context-dot-dev/context-dev-cli/commit/a3d1b5805b673c421b3e97e54d614881e214ec2d)) +* **search:** add highlights to web search and bill page reads per 10 results ([#1387](https://github.com/context-dot-dev/context-dev-cli/issues/1387)) ([b5ffb30](https://github.com/context-dot-dev/context-dev-cli/commit/b5ffb309e99c714c38946f528eccb26ed9d3f792)) +* **web-search:** extend page cache defaults ([#1408](https://github.com/context-dot-dev/context-dev-cli/issues/1408)) ([4cb3f9c](https://github.com/context-dot-dev/context-dev-cli/commit/4cb3f9c58f33795255532994e6c2e48a5245164a)) + + +### Bug Fixes + +* **api:** document search domain limits and clarify scrape parameter errors ([#1388](https://github.com/context-dot-dev/context-dev-cli/issues/1388)) ([6635afc](https://github.com/context-dot-dev/context-dev-cli/commit/6635afc3531000dc1baab3e7633ea0010002d3e8)) +* **openapi:** document exclusive news filters ([#1265](https://github.com/context-dot-dev/context-dev-cli/issues/1265)) ([2ed83fb](https://github.com/context-dot-dev/context-dev-cli/commit/2ed83fb006e021cfd3117bb1c8ebd7dd6b7faca4)) + + +### Documentation + +* **openapi:** complete concise API reference metadata ([#1329](https://github.com/context-dot-dev/context-dev-cli/issues/1329)) ([3fc839d](https://github.com/context-dot-dev/context-dev-cli/commit/3fc839d159980463cf821a727458358f740a1787)) + +## [1.12.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.11.0...v1.12.0) (2026-09-22) + + +### Features + +* **answers:** add live web research with fast and ultra modes ([#954](https://github.com/context-dot-dev/context-dev-cli/issues/954)) ([8f226f8](https://github.com/context-dot-dev/context-dev-cli/commit/8f226f8287e196fcd383f1bef037d804a493c222)) +* **api-keys:** enforce scoped API key permissions ([#1038](https://github.com/context-dot-dev/context-dev-cli/issues/1038)) ([f2427ba](https://github.com/context-dot-dev/context-dev-cli/commit/f2427ba6e9d7538546b0dee7b90a037c082b6d03)) +* **api:** api update ([985ccab](https://github.com/context-dot-dev/context-dev-cli/commit/985ccab2173e91b5cf40749f33133d7c92527652)) +* **api:** api update ([3583e1a](https://github.com/context-dot-dev/context-dev-cli/commit/3583e1aff934cfb1ce1bad257ffbfa262b3a8733)) +* **api:** api update ([7b5b53f](https://github.com/context-dot-dev/context-dev-cli/commit/7b5b53f167b6bf29d2c4de02f348edc2122d5e80)) +* **api:** api update ([af18337](https://github.com/context-dot-dev/context-dev-cli/commit/af1833778a6a1620a5e3f0008b7f67cd5dae53c0)) +* **api:** api update ([42b486d](https://github.com/context-dot-dev/context-dev-cli/commit/42b486d2ef88a5dff7e3217b01adae0ab433c36f)) +* **api:** api update ([22478e2](https://github.com/context-dot-dev/context-dev-cli/commit/22478e2f26fc4bcc47509a449e47a7f4e0ec8a23)) +* **api:** api update ([7e6e3b7](https://github.com/context-dot-dev/context-dev-cli/commit/7e6e3b7c6d540b53660b82ec81cf1d92fc4fe1b5)) +* **api:** api update ([eb22b56](https://github.com/context-dot-dev/context-dev-cli/commit/eb22b56ccf04e0c18195a7bc0f5289de452c2952)) +* **api:** api update ([18adfb0](https://github.com/context-dot-dev/context-dev-cli/commit/18adfb09e23af7efc8a64370e13d5cc38fe73859)) +* **api:** api update ([df232b5](https://github.com/context-dot-dev/context-dev-cli/commit/df232b58f81c68fd6a914e7fe63882a0f3de9fd4)) +* **api:** api update ([e21a8ff](https://github.com/context-dot-dev/context-dev-cli/commit/e21a8ff46d495a59b9c751965bb9d980a0765c78)) +* **api:** api update ([48a68cb](https://github.com/context-dot-dev/context-dev-cli/commit/48a68cb9ad422157ee55deef66773a161e320f44)) +* **api:** api update ([ad50292](https://github.com/context-dot-dev/context-dev-cli/commit/ad502925051676385440177ba5a4113631ff2dfa)) +* **api:** api update ([5650e87](https://github.com/context-dot-dev/context-dev-cli/commit/5650e87248bd4d1dabd6027007f510650684d511)) +* **api:** api update ([4ca42b8](https://github.com/context-dot-dev/context-dev-cli/commit/4ca42b8b8bdbe6750a50db1bc39b4ff098346f65)) +* **api:** api update ([92be0b6](https://github.com/context-dot-dev/context-dev-cli/commit/92be0b69f74d40bddb2748939d27c5b9f2660f46)) +* **api:** api update ([90cad89](https://github.com/context-dot-dev/context-dev-cli/commit/90cad89d5524f42fcd1e84e040bc19ab3e9d1052)) +* **api:** api update ([e216795](https://github.com/context-dot-dev/context-dev-cli/commit/e216795e82dfdbf993710845866636a503bda557)) +* **api:** api update ([b649e03](https://github.com/context-dot-dev/context-dev-cli/commit/b649e034740d7aae62e30bccf0446c846a39e282)) +* **api:** api update ([ccba916](https://github.com/context-dot-dev/context-dev-cli/commit/ccba91605a6095370892bec901f58a75f91a04c6)) +* **api:** api update ([b8de4ec](https://github.com/context-dot-dev/context-dev-cli/commit/b8de4ec1e8a39c97e3bbf04dd259c9fa3e8aa44f)) +* **api:** api update ([3c2c3c2](https://github.com/context-dot-dev/context-dev-cli/commit/3c2c3c2daf40ad8df4df6b9861ed88291b539f91)) +* **api:** api update ([0b487b1](https://github.com/context-dot-dev/context-dev-cli/commit/0b487b175434d6db1ce66501382164a55b68c557)) +* **api:** api update ([cd4503b](https://github.com/context-dot-dev/context-dev-cli/commit/cd4503b7722a10614512c2d1ea9c3dffc670f434)) +* **api:** api update ([af90e28](https://github.com/context-dot-dev/context-dev-cli/commit/af90e280f6fe278065c1d873be594fae7f9d61a4)) +* **api:** api update ([5f2e61b](https://github.com/context-dot-dev/context-dev-cli/commit/5f2e61b15cc331ec398111cac0d43b409826da40)) +* **api:** api update ([e21218b](https://github.com/context-dot-dev/context-dev-cli/commit/e21218b5cb90979c8a2ef32539859d671a33967a)) +* **api:** api update ([21c81e4](https://github.com/context-dot-dev/context-dev-cli/commit/21c81e4faf5385a5c02c21585524d8d04794f598)) +* **api:** api update ([0468ad1](https://github.com/context-dot-dev/context-dev-cli/commit/0468ad177e1bfb23732f4bda41ad34fb37f972b4)) +* **api:** api update ([349f90c](https://github.com/context-dot-dev/context-dev-cli/commit/349f90c23ba4ac35c8c5dee81060a495475435c3)) +* **api:** api update ([47fc775](https://github.com/context-dot-dev/context-dev-cli/commit/47fc77546b9d9979e7d14d80d0bed7a6cfaa9e44)) +* **api:** api update ([0a8b58e](https://github.com/context-dot-dev/context-dev-cli/commit/0a8b58e4e26794d3c2a67f2d4ff92a85a8396d54)) +* **api:** api update ([16201c6](https://github.com/context-dot-dev/context-dev-cli/commit/16201c67e3dd1e192a0ca50557518d4bf8314580)) +* **api:** api update ([e636b6d](https://github.com/context-dot-dev/context-dev-cli/commit/e636b6d51d9c58cfb2f0845900e22eddcd939d50)) +* **api:** api update ([e16a2a9](https://github.com/context-dot-dev/context-dev-cli/commit/e16a2a9ef5a60f1b135bc081867e7404c1e2c8f5)) +* **api:** api update ([fd7e3fe](https://github.com/context-dot-dev/context-dev-cli/commit/fd7e3fec2da55fc91c40c2e4f0e7d9247ebf5400)) +* **api:** api update ([058e8d0](https://github.com/context-dot-dev/context-dev-cli/commit/058e8d0a1dd1728ab42524cd52a39fa83c8d5aee)) +* **api:** api update ([487caec](https://github.com/context-dot-dev/context-dev-cli/commit/487caec519e5299562b2b864240395e13a8a5791)) +* **api:** api update ([40129c5](https://github.com/context-dot-dev/context-dev-cli/commit/40129c5f3a5fb562d1ef4c0a2f2ab408d0ca2732)) +* **api:** api update ([8b611d1](https://github.com/context-dot-dev/context-dev-cli/commit/8b611d174d071bd86accc7c31ce6233949247457)) +* **api:** api update ([a0e254f](https://github.com/context-dot-dev/context-dev-cli/commit/a0e254f262eb656902ba18f4894a29e19c81b3a7)) +* **api:** api update ([a9d6531](https://github.com/context-dot-dev/context-dev-cli/commit/a9d6531da6214adc7f8bd0b0e147c11b0fe9e1d1)) +* **api:** api update ([4d0ddd0](https://github.com/context-dot-dev/context-dev-cli/commit/4d0ddd0adb859f0103c397807ed41afb6190329c)) +* **api:** api update ([6a98028](https://github.com/context-dot-dev/context-dev-cli/commit/6a9802898695bda06edd6aaee2f5ce1b7d90f746)) +* **api:** api update ([6b8d1cc](https://github.com/context-dot-dev/context-dev-cli/commit/6b8d1cc9593681bdee01369a730094ebca3d6fc4)) +* **api:** api update ([1722d54](https://github.com/context-dot-dev/context-dev-cli/commit/1722d543bb09c25729bf6af74de4642c77b3b078)) +* **api:** api update ([5deab14](https://github.com/context-dot-dev/context-dev-cli/commit/5deab142468bc18e41383400e9d14ad5cc905508)) +* **api:** api update ([f0bbbf0](https://github.com/context-dot-dev/context-dev-cli/commit/f0bbbf071979c9eae27bd53804b9a0b60d32037c)) +* **api:** api update ([3a5899b](https://github.com/context-dot-dev/context-dev-cli/commit/3a5899babfedea3bed0980934c4a7c87cecb4c63)) +* **api:** api update ([17b3e2c](https://github.com/context-dot-dev/context-dev-cli/commit/17b3e2c78ef859b656f78deb7ae2b7d295865f27)) +* **api:** api update ([e9b3454](https://github.com/context-dot-dev/context-dev-cli/commit/e9b3454a43a4f9f7614a56a6039eb260b398de52)) +* **api:** api update ([d9b903c](https://github.com/context-dot-dev/context-dev-cli/commit/d9b903c39a5521064f49f658d32205f310f54e00)) +* **api:** api update ([e4387a5](https://github.com/context-dot-dev/context-dev-cli/commit/e4387a54271251c65f16cfd1dce035e177393db2)) +* **api:** api update ([f6c4de7](https://github.com/context-dot-dev/context-dev-cli/commit/f6c4de7fc399ff172e50ec287aa6302d69741c13)) +* **api:** api update ([c1a847a](https://github.com/context-dot-dev/context-dev-cli/commit/c1a847ad433d451d723b8dcd37359b1fc3dd95f2)) +* **api:** enable ZDR on remaining AI endpoints via OpenAI ([#1099](https://github.com/context-dot-dev/context-dev-cli/issues/1099)) ([cd708ca](https://github.com/context-dot-dev/context-dev-cli/commit/cd708cab6ed78bd33d9d6237f09cbc38e45347d4)) +* **api:** manual updates ([6a9b2f5](https://github.com/context-dot-dev/context-dev-cli/commit/6a9b2f59ae223e0e70e61a8e63012c8c4160a431)) +* **api:** manual updates ([35e256a](https://github.com/context-dot-dev/context-dev-cli/commit/35e256a85572f24f11f89dbc452a7fa81640cef3)) +* **api:** manual updates ([0a31daa](https://github.com/context-dot-dev/context-dev-cli/commit/0a31daa87ff77541579b3e9147c08981779c073f)) +* **api:** manual updates ([5b0ef3e](https://github.com/context-dot-dev/context-dev-cli/commit/5b0ef3ebae76534b4a1997d4e13311cc225bb555)) +* **api:** manual updates ([e02d02e](https://github.com/context-dot-dev/context-dev-cli/commit/e02d02e69c215116d5d3e1aec5cab2be279da032)) +* **api:** manual updates ([d742101](https://github.com/context-dot-dev/context-dev-cli/commit/d74210104ea1f0a693d91aa8f8b53d6ea433ec70)) +* **api:** manual updates ([1aef807](https://github.com/context-dot-dev/context-dev-cli/commit/1aef8079dd1d7f31da5c7f5e65291396c178283b)) +* **api:** manual updates ([85a84a1](https://github.com/context-dot-dev/context-dev-cli/commit/85a84a193090a6f424364c9196f7b24619953635)) +* **api:** manual updates ([d416480](https://github.com/context-dot-dev/context-dev-cli/commit/d416480c31a74e1dc682c23b5c838f8b4147b31f)) +* **api:** unify timeout configuration and return partial results ([#1030](https://github.com/context-dot-dev/context-dev-cli/issues/1030)) ([467f13a](https://github.com/context-dot-dev/context-dev-cli/commit/467f13ab47753ff0889e46d3315604841dab78d4)) +* **billing:** charge for 404s and skip fraud accounting ([#1152](https://github.com/context-dot-dev/context-dev-cli/issues/1152)) ([da081b1](https://github.com/context-dot-dev/context-dev-cli/commit/da081b109221008938d7e9665584fcbbedc3a49c)) +* initial stlc build ([5dc353c](https://github.com/context-dot-dev/context-dev-cli/commit/5dc353c8190ed4d2747a3e07c09fffb4ad7ec710)) +* **logs:** expose request log endpoints in SDKs ([#1025](https://github.com/context-dot-dev/context-dev-cli/issues/1025)) ([08ee0eb](https://github.com/context-dot-dev/context-dev-cli/commit/08ee0ebeb58a3fa865c4df7c5ba2364d2745b9ee)) +* **monitors:** add page selector filters ([#1037](https://github.com/context-dot-dev/context-dev-cli/issues/1037)) ([39ca377](https://github.com/context-dot-dev/context-dev-cli/commit/39ca377527e965766a22a5dcf583101cbffd1692)) +* **scrape:** add cache age support to byte downloads ([#1171](https://github.com/context-dot-dev/context-dev-cli/issues/1171)) ([5f66062](https://github.com/context-dot-dev/context-dev-cli/commit/5f66062092a3fa099f0cd043915e726f315c0de5)) +* **scrape:** add CSS extraction rules to HTML scraping ([#1146](https://github.com/context-dot-dev/context-dev-cli/issues/1146)) ([7312544](https://github.com/context-dot-dev/context-dev-cli/commit/7312544df2c45bcc1a83b53385349c5c0f587280)) +* **scrape:** align timeout options and public SDK methods ([#1207](https://github.com/context-dot-dev/context-dev-cli/issues/1207)) ([b022ea7](https://github.com/context-dot-dev/context-dev-cli/commit/b022ea7a62ec6e043d354c691ddaa16df07f1b2b)) +* **scrape:** support country for image scraping ([#1172](https://github.com/context-dot-dev/context-dev-cli/issues/1172)) ([5f66062](https://github.com/context-dot-dev/context-dev-cli/commit/5f66062092a3fa099f0cd043915e726f315c0de5)) +* **scrape:** support custom screenshot headers ([#1169](https://github.com/context-dot-dev/context-dev-cli/issues/1169)) ([efaf864](https://github.com/context-dot-dev/context-dev-cli/commit/efaf86495456996b4b0e7f21eb1f7608da6ff1e6)) +* **scrape:** support waitForMs for byte downloads ([#1170](https://github.com/context-dot-dev/context-dev-cli/issues/1170)) ([0d84fa4](https://github.com/context-dot-dev/context-dev-cli/commit/0d84fa4da25faa2ba9687880140bf82e6868199b)) +* **sitemap:** add subdomain discovery ([126d27d](https://github.com/context-dot-dev/context-dev-cli/commit/126d27d4684b5f3e75de83dfe32de7c34f9c5a81)) +* **stlc:** configurable CI runner and private-production-repo support in workflow templates ([d55d529](https://github.com/context-dot-dev/context-dev-cli/commit/d55d5297e92d05dc7bc507f2ac9f3c02f1f9d178)) +* **web:** add raw bytes scraping endpoint ([#1081](https://github.com/context-dot-dev/context-dev-cli/issues/1081)) ([5d45957](https://github.com/context-dot-dev/context-dev-cli/commit/5d4595725c6a850bc9df5e265ddcd2b6eb8321eb)) +* **web:** add URL-based scrape screenshot endpoint ([#1150](https://github.com/context-dot-dev/context-dev-cli/issues/1150)) ([7309030](https://github.com/context-dot-dev/context-dev-cli/commit/730903032b70d9bbd6026d005946170cd79ef560)) +* **webhooks:** add configurable retries and manual replay ([d366bd3](https://github.com/context-dot-dev/context-dev-cli/commit/d366bd323f7875132dfe35ceb8fdfe3d92e9edaf)) +* **webhooks:** simplify delivery APIs ([7fd54b9](https://github.com/context-dot-dev/context-dev-cli/commit/7fd54b92fa451965a26df73df1ac6b4cc0d8d458)) + + +### Bug Fixes + +* **api:** guarantee search descriptions and align response types ([#1089](https://github.com/context-dot-dev/context-dev-cli/issues/1089)) ([1fc274a](https://github.com/context-dot-dev/context-dev-cli/commit/1fc274a8c9bbe1711442c49f0cef7d393318c270)) +* **api:** honour maxAgeMs=0 on brand retrieve, styleguide and fonts endpoints ([#998](https://github.com/context-dot-dev/context-dev-cli/issues/998)) ([97370fd](https://github.com/context-dot-dev/context-dev-cli/commit/97370fd41d8d503270a786dc474ffe2a84c94214)) +* **api:** lower partial scrape timeout minimum to five seconds ([#1118](https://github.com/context-dot-dev/context-dev-cli/issues/1118)) ([29338a1](https://github.com/context-dot-dev/context-dev-cli/commit/29338a15ff1b82c1c1908af5db66c6011461814d)) +* **api:** reject timeoutMS too short for waitForMs ([7e03bf3](https://github.com/context-dot-dev/context-dev-cli/commit/7e03bf3075934de07ee9364819531f14756816e5)) +* **deps:** bump context-go-sdk to v1.4.0 for Monitors support ([65efe3d](https://github.com/context-dot-dev/context-dev-cli/commit/65efe3d9954b7d31dce3fac9e4db41bc054ef499)) +* **deps:** bump context-go-sdk to v1.4.0 for Monitors support ([4d95632](https://github.com/context-dot-dev/context-dev-cli/commit/4d956323f13357bdecae14c57fa47bcf7560b1a0)) +* **openapi:** strip empty-object defaults from the generated spec ([9cb38d9](https://github.com/context-dot-dev/context-dev-cli/commit/9cb38d9e7702224885e18d5060b151d9e9d2ae8e)) +* **webhooks:** format Slack webhook notifications ([#1045](https://github.com/context-dot-dev/context-dev-cli/issues/1045)) ([d7173ff](https://github.com/context-dot-dev/context-dev-cli/commit/d7173ff5eff964c53db99e59a4da62df112bdaba)) + + +### Chores + +* configure new SDK language ([e89b37b](https://github.com/context-dot-dev/context-dev-cli/commit/e89b37b1061f3d846832b13852a6a4117c49910b)) +* **internal:** codegen related update ([87780eb](https://github.com/context-dot-dev/context-dev-cli/commit/87780eb7d4bbb0df65fde3ecfbc74bfa191c04b7)) +* **internal:** codegen related update ([3c366ea](https://github.com/context-dot-dev/context-dev-cli/commit/3c366ea25e8f6ac84cbbe835a03bf3c8294831dc)) +* release 1.10.0 ([a874a70](https://github.com/context-dot-dev/context-dev-cli/commit/a874a70ab78e646ccf82a33d670daeed84282e81)) +* update SDK settings ([2cb5f95](https://github.com/context-dot-dev/context-dev-cli/commit/2cb5f95e56c35f5bf415999f877917625025e7ef)) + +## [1.11.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.10.0...v1.11.0) (2026-09-22) + + +### Features + +* **api:** enable ZDR on remaining AI endpoints via OpenAI ([#1099](https://github.com/context-dot-dev/context-dev-cli/issues/1099)) ([cd708ca](https://github.com/context-dot-dev/context-dev-cli/commit/cd708cab6ed78bd33d9d6237f09cbc38e45347d4)) +* **billing:** charge for 404s and skip fraud accounting ([#1152](https://github.com/context-dot-dev/context-dev-cli/issues/1152)) ([da081b1](https://github.com/context-dot-dev/context-dev-cli/commit/da081b109221008938d7e9665584fcbbedc3a49c)) +* **scrape:** add cache age support to byte downloads ([#1171](https://github.com/context-dot-dev/context-dev-cli/issues/1171)) ([5f66062](https://github.com/context-dot-dev/context-dev-cli/commit/5f66062092a3fa099f0cd043915e726f315c0de5)) +* **scrape:** add CSS extraction rules to HTML scraping ([#1146](https://github.com/context-dot-dev/context-dev-cli/issues/1146)) ([7312544](https://github.com/context-dot-dev/context-dev-cli/commit/7312544df2c45bcc1a83b53385349c5c0f587280)) +* **scrape:** align timeout options and public SDK methods ([#1207](https://github.com/context-dot-dev/context-dev-cli/issues/1207)) ([b022ea7](https://github.com/context-dot-dev/context-dev-cli/commit/b022ea7a62ec6e043d354c691ddaa16df07f1b2b)) +* **scrape:** support country for image scraping ([#1172](https://github.com/context-dot-dev/context-dev-cli/issues/1172)) ([5f66062](https://github.com/context-dot-dev/context-dev-cli/commit/5f66062092a3fa099f0cd043915e726f315c0de5)) +* **scrape:** support custom screenshot headers ([#1169](https://github.com/context-dot-dev/context-dev-cli/issues/1169)) ([efaf864](https://github.com/context-dot-dev/context-dev-cli/commit/efaf86495456996b4b0e7f21eb1f7608da6ff1e6)) +* **scrape:** support waitForMs for byte downloads ([#1170](https://github.com/context-dot-dev/context-dev-cli/issues/1170)) ([0d84fa4](https://github.com/context-dot-dev/context-dev-cli/commit/0d84fa4da25faa2ba9687880140bf82e6868199b)) +* **web:** add URL-based scrape screenshot endpoint ([#1150](https://github.com/context-dot-dev/context-dev-cli/issues/1150)) ([7309030](https://github.com/context-dot-dev/context-dev-cli/commit/730903032b70d9bbd6026d005946170cd79ef560)) + + +### Bug Fixes + +* **api:** lower partial scrape timeout minimum to five seconds ([#1118](https://github.com/context-dot-dev/context-dev-cli/issues/1118)) ([29338a1](https://github.com/context-dot-dev/context-dev-cli/commit/29338a15ff1b82c1c1908af5db66c6011461814d)) + +## [1.10.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.9.0...v1.10.0) (2026-09-15) + + +### Features + +* **answers:** add live web research with fast and ultra modes ([#954](https://github.com/context-dot-dev/context-dev-cli/issues/954)) ([8f226f8](https://github.com/context-dot-dev/context-dev-cli/commit/8f226f8287e196fcd383f1bef037d804a493c222)) +* **api-keys:** enforce scoped API key permissions ([#1038](https://github.com/context-dot-dev/context-dev-cli/issues/1038)) ([f2427ba](https://github.com/context-dot-dev/context-dev-cli/commit/f2427ba6e9d7538546b0dee7b90a037c082b6d03)) +* **api:** unify timeout configuration and return partial results ([#1030](https://github.com/context-dot-dev/context-dev-cli/issues/1030)) ([467f13a](https://github.com/context-dot-dev/context-dev-cli/commit/467f13ab47753ff0889e46d3315604841dab78d4)) +* **logs:** expose request log endpoints in SDKs ([#1025](https://github.com/context-dot-dev/context-dev-cli/issues/1025)) ([08ee0eb](https://github.com/context-dot-dev/context-dev-cli/commit/08ee0ebeb58a3fa865c4df7c5ba2364d2745b9ee)) +* **monitors:** add page selector filters ([#1037](https://github.com/context-dot-dev/context-dev-cli/issues/1037)) ([39ca377](https://github.com/context-dot-dev/context-dev-cli/commit/39ca377527e965766a22a5dcf583101cbffd1692)) +* **sitemap:** add subdomain discovery ([126d27d](https://github.com/context-dot-dev/context-dev-cli/commit/126d27d4684b5f3e75de83dfe32de7c34f9c5a81)) +* **web:** add raw bytes scraping endpoint ([#1081](https://github.com/context-dot-dev/context-dev-cli/issues/1081)) ([5d45957](https://github.com/context-dot-dev/context-dev-cli/commit/5d4595725c6a850bc9df5e265ddcd2b6eb8321eb)) +* **webhooks:** add configurable retries and manual replay ([d366bd3](https://github.com/context-dot-dev/context-dev-cli/commit/d366bd323f7875132dfe35ceb8fdfe3d92e9edaf)) +* **webhooks:** simplify delivery APIs ([7fd54b9](https://github.com/context-dot-dev/context-dev-cli/commit/7fd54b92fa451965a26df73df1ac6b4cc0d8d458)) + + +### Bug Fixes + +* **api:** guarantee search descriptions and align response types ([#1089](https://github.com/context-dot-dev/context-dev-cli/issues/1089)) ([1fc274a](https://github.com/context-dot-dev/context-dev-cli/commit/1fc274a8c9bbe1711442c49f0cef7d393318c270)) +* **api:** honour maxAgeMs=0 on brand retrieve, styleguide and fonts endpoints ([#998](https://github.com/context-dot-dev/context-dev-cli/issues/998)) ([97370fd](https://github.com/context-dot-dev/context-dev-cli/commit/97370fd41d8d503270a786dc474ffe2a84c94214)) +* **api:** reject timeoutMS too short for waitForMs ([7e03bf3](https://github.com/context-dot-dev/context-dev-cli/commit/7e03bf3075934de07ee9364819531f14756816e5)) +* **openapi:** strip empty-object defaults from the generated spec ([9cb38d9](https://github.com/context-dot-dev/context-dev-cli/commit/9cb38d9e7702224885e18d5060b151d9e9d2ae8e)) +* **webhooks:** format Slack webhook notifications ([#1045](https://github.com/context-dot-dev/context-dev-cli/issues/1045)) ([d7173ff](https://github.com/context-dot-dev/context-dev-cli/commit/d7173ff5eff964c53db99e59a4da62df112bdaba)) + ## [1.9.0](https://github.com/context-dot-dev/context-dev-cli/compare/v1.8.0...v1.9.0) (2026-08-27) diff --git a/README.md b/README.md index b36987c..17e4cb4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Context Dev CLI +# Context.dev CLI The official CLI for the [Context Dev REST API](https://docs.context.dev/). @@ -50,7 +50,7 @@ context-dev [resource] [flags...] ```sh context-dev brand retrieve \ --api-key 'My API Key' \ - --domain REPLACE_ME \ + --domain example.com \ --type by_domain ``` diff --git a/go.mod b/go.mod index e8318bb..ac04565 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 github.com/charmbracelet/x/term v0.2.1 - github.com/context-dot-dev/context-go-sdk/v2 v2.12.0 + github.com/context-dot-dev/context-go-sdk/v2 v2.47.0 github.com/goccy/go-yaml v1.18.0 github.com/itchyny/json2yaml v0.1.4 github.com/muesli/reflow v0.3.0 diff --git a/go.sum b/go.sum index 8aeb563..23f5623 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payR github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= -github.com/context-dot-dev/context-go-sdk/v2 v2.12.0 h1:cA6jbkTtWal7kfdGDi0Km1ABgAD4sjmKayD8HttGil0= -github.com/context-dot-dev/context-go-sdk/v2 v2.12.0/go.mod h1:CvRANWLP0FHj5XyUwzEVX79ujdwr/2Jy375UVzKNQm8= +github.com/context-dot-dev/context-go-sdk/v2 v2.47.0 h1:WLked7GTZad5/b4s/3LIbnBQE5uiCqton132Cr+9SJM= +github.com/context-dot-dev/context-go-sdk/v2 v2.47.0/go.mod h1:CvRANWLP0FHj5XyUwzEVX79ujdwr/2Jy375UVzKNQm8= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/pkg/cmd/ai.go b/pkg/cmd/ai.go deleted file mode 100644 index 34a436a..0000000 --- a/pkg/cmd/ai.go +++ /dev/null @@ -1,170 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package cmd - -import ( - "context" - "fmt" - - "github.com/context-dot-dev/context-dev-cli/internal/apiquery" - "github.com/context-dot-dev/context-dev-cli/internal/requestflag" - "github.com/context-dot-dev/context-go-sdk/v2" - "github.com/context-dot-dev/context-go-sdk/v2/option" - "github.com/tidwall/gjson" - "github.com/urfave/cli/v3" -) - -var aiExtractProduct = cli.Command{ - Name: "extract-product", - Usage: "Given a single URL, determines if it is a product page and extracts the product\ninformation.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "url", - Usage: "The product page URL to extract product data from.", - Required: true, - BodyPath: "url", - }, - &requestflag.Flag[int64]{ - Name: "max-age-ms", - Usage: "Return a cached result if a prior scrape for the same parameters exists and is younger than this many milliseconds. Defaults to 7 days (604800000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.", - Default: 604800000, - BodyPath: "maxAgeMs", - }, - &requestflag.Flag[[]string]{ - Name: "tag", - Usage: "Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.", - BodyPath: "tags", - }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - BodyPath: "timeoutMS", - }, - }, - Action: handleAIExtractProduct, - HideHelpCommand: true, -} - -var aiExtractProducts = cli.Command{ - Name: "extract-products", - Usage: "Extract product information from a brand's website. We will analyze the website\nand return a list of products with details such as name, description, image,\npricing, features, and more.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "domain", - Usage: "The domain name to analyze.", - BodyPath: "domain", - }, - &requestflag.Flag[int64]{ - Name: "max-age-ms", - Usage: "Return a cached result if a prior scrape for the same parameters exists and is younger than this many milliseconds. Defaults to 7 days (604800000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.", - Default: 604800000, - BodyPath: "maxAgeMs", - }, - &requestflag.Flag[int64]{ - Name: "max-products", - Usage: "Maximum number of products to extract.", - BodyPath: "maxProducts", - }, - &requestflag.Flag[[]string]{ - Name: "tag", - Usage: "Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.", - BodyPath: "tags", - }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - BodyPath: "timeoutMS", - }, - &requestflag.Flag[string]{ - Name: "direct-url", - Usage: "A specific URL to use directly as the starting point for extraction without domain resolution.", - BodyPath: "directUrl", - }, - }, - Action: handleAIExtractProducts, - HideHelpCommand: true, -} - -func handleAIExtractProduct(ctx context.Context, cmd *cli.Command) error { - client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatComma, - ApplicationJSON, - false, - ) - if err != nil { - return err - } - - params := contextdev.AIExtractProductParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.AI.ExtractProduct(ctx, params, options...) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "ai extract-product", - Transform: transform, - }) -} - -func handleAIExtractProducts(ctx context.Context, cmd *cli.Command) error { - client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatComma, - ApplicationJSON, - false, - ) - if err != nil { - return err - } - - params := contextdev.AIExtractProductsParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.AI.ExtractProducts(ctx, params, options...) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "ai extract-products", - Transform: transform, - }) -} diff --git a/pkg/cmd/ai_test.go b/pkg/cmd/ai_test.go deleted file mode 100644 index e6ed136..0000000 --- a/pkg/cmd/ai_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package cmd - -import ( - "testing" - - "github.com/context-dot-dev/context-dev-cli/internal/mocktest" -) - -func TestAIExtractProduct(t *testing.T) { - t.Skip("Mock server tests are disabled") - t.Run("regular flags", func(t *testing.T) { - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "ai", "extract-product", - "--url", "https://example.com", - "--max-age-ms", "0", - "--tag", "production", - "--tag", "team-alpha", - "--timeout-ms", "1000", - ) - }) - - t.Run("piping data", func(t *testing.T) { - // Test piping YAML data over stdin - pipeData := []byte("" + - "url: https://example.com\n" + - "maxAgeMs: 0\n" + - "tags:\n" + - " - production\n" + - " - team-alpha\n" + - "timeoutMS: 1000\n") - mocktest.TestRunMockTestWithPipeAndFlags( - t, pipeData, - "--api-key", "string", - "ai", "extract-product", - ) - }) -} - -func TestAIExtractProducts(t *testing.T) { - t.Skip("Mock server tests are disabled") - t.Run("regular flags", func(t *testing.T) { - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "ai", "extract-products", - "--domain", "domain", - "--max-age-ms", "0", - "--max-products", "1", - "--tag", "production", - "--tag", "team-alpha", - "--timeout-ms", "1000", - ) - }) - - t.Run("piping data", func(t *testing.T) { - // Test piping YAML data over stdin - pipeData := []byte("" + - "domain: domain\n" + - "maxAgeMs: 0\n" + - "maxProducts: 1\n" + - "tags:\n" + - " - production\n" + - " - team-alpha\n" + - "timeoutMS: 1000\n") - mocktest.TestRunMockTestWithPipeAndFlags( - t, pipeData, - "--api-key", "string", - "ai", "extract-products", - ) - }) -} diff --git a/pkg/cmd/batch.go b/pkg/cmd/batch.go index 1eff5c6..d7147c1 100644 --- a/pkg/cmd/batch.go +++ b/pkg/cmd/batch.go @@ -16,12 +16,12 @@ import ( var batchRetrieve = cli.Command{ Name: "retrieve", - Usage: "Check progress, and get download links once the batch finishes.", + Usage: "Get batch progress and result download links. Result files are deleted 180 days\nafter the batch finishes.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "batch-id", - Usage: "ID of the batch to retrieve or cancel.", + Usage: "Batch ID.", Required: true, PathParam: "batch_id", }, @@ -32,7 +32,7 @@ var batchRetrieve = cli.Command{ var batchList = cli.Command{ Name: "list", - Usage: "List your batches from newest to oldest. Filter by status or continue with a\ncursor.", + Usage: "List your batches, newest first, with optional filters.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -43,6 +43,7 @@ var batchList = cli.Command{ &requestflag.Flag[int64]{ Name: "limit", Usage: "Batches per page. Defaults to 25.", + Default: 25, QueryPath: "limit", }, &requestflag.Flag[string]{ @@ -55,14 +56,20 @@ var batchList = cli.Command{ Usage: "`prefix` for as-you-type prefix matching (default), `exact` for full-token matching.", QueryPath: "search_type", }, + &requestflag.Flag[bool]{ + Name: "should-include-unified", + Usage: "Include batches submitted with Scrape Anything formats. Defaults to false.", + Default: false, + QueryPath: "shouldIncludeUnified", + }, &requestflag.Flag[string]{ Name: "status", Usage: "Filter by status.", QueryPath: "status", }, - &requestflag.Flag[string]{ + &requestflag.Flag[any]{ Name: "tags", - Usage: "Comma-separated list of tags to filter by (matches batches having any of them).", + Usage: "Tags to filter by (matches batches having any of them). Pass repeated `tags` params or one comma-separated list, e.g. `tags=docs,competitor`.", QueryPath: "tags", }, }, @@ -72,12 +79,12 @@ var batchList = cli.Command{ var batchDelete = cli.Command{ Name: "delete", - Usage: "Permanently delete a finished batch and its stored results. Active batches must\nsettle first.", + Usage: "Permanently delete a finished batch and its results. Its webhook deliveries can\nno longer be retried.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "batch-id", - Usage: "ID of the batch to retrieve or cancel.", + Usage: "Batch ID.", Required: true, PathParam: "batch_id", }, @@ -88,12 +95,12 @@ var batchDelete = cli.Command{ var batchCancel = cli.Command{ Name: "cancel", - Usage: "Stop a batch from starting new pages. In-progress pages finish, and unused\ncredits are refunded.", + Usage: "Stop a batch from starting new pages. Pages already in progress finish before\nthe batch becomes cancelled.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "batch-id", - Usage: "ID of the batch to retrieve or cancel.", + Usage: "Batch ID.", Required: true, PathParam: "batch_id", }, @@ -104,12 +111,12 @@ var batchCancel = cli.Command{ var batchGetResults = cli.Command{ Name: "get-results", - Usage: "Page through a finished batch's results as JSON instead of downloading the\nNDJSON files.", + Usage: "Page through a finished batch’s results as JSON. Each record contains result\nwith the same outputs and per-format errors as POST /web/scrape. Results remain\navailable for 180 days.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "batch-id", - Usage: "ID of the batch to retrieve or cancel.", + Usage: "Batch ID.", Required: true, PathParam: "batch_id", }, @@ -121,6 +128,7 @@ var batchGetResults = cli.Command{ &requestflag.Flag[int64]{ Name: "limit", Usage: "Records per page. Defaults to 25. A page can close early so its payload stays under ~8 MB; rely on next_cursor rather than counting records.", + Default: 25, QueryPath: "limit", }, }, @@ -128,9 +136,9 @@ var batchGetResults = cli.Command{ HideHelpCommand: true, } -var batchSubmit = cli.Command{ +var batchSubmit = requestflag.WithInnerFlags(cli.Command{ Name: "submit", - Usage: "Scrape 25K URLs or crawl large websites asynchronously.", + Usage: "Scrape up to 100,000 URLs, or crawl a site, asynchronously using the same\nformats and scrape parameters as POST /web/scrape. Choose Markdown, HTML,\nscreenshots, images, bytes, parsed fields, products, highlights, and JSON.\nSubmission persists the input and returns immediately with status pending.\nOrganizations with fewer than 10 available credits and no overage are rejected\nwith 402 up front. Each organization can submit up to 2,500 batches per minute,\nindependently of its polling budget. Batches wait pending when execution\ncapacity is full. Validation, sitemap discovery, the full credit quote, and\nshard scheduling happen afterward. Poll the batch ID or receive a webhook when\nit finishes. Deferred rejections appear as status failed with a failure code and\nmessage.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[map[string]any]{ @@ -139,25 +147,48 @@ var batchSubmit = cli.Command{ Required: true, BodyPath: "input", }, + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Access policy IDs to apply to every page. A URL must pass every policy.", + BodyPath: "policies", + }, &requestflag.Flag[[]string]{ Name: "tag", Usage: "Tags stored on the batch. Filter the batch list by them later.", BodyPath: "tags", }, + &requestflag.Flag[map[string]any]{ + Name: "webhook", + Usage: "Where to send the batch's final-status event. Omit `retry` for one attempt; `{}` uses the default retry schedule.", + BodyPath: "webhook", + }, &requestflag.Flag[string]{ Name: "webhook-url", - Usage: "URL notified when the batch finishes.", + Usage: "Legacy URL notified when the batch finishes. Preserves one best-effort attempt. Cannot be combined with webhook.", BodyPath: "webhookUrl", }, &requestflag.Flag[string]{ Name: "idempotency-key", - Usage: "Any string unique to this submission. Retries with the same key return the original batch.", + Usage: "Unique key per submission. Retrying with the same key and body returns the original batch; a different body returns `409`.", HeaderPath: "Idempotency-Key", }, }, Action: handleBatchSubmit, HideHelpCommand: true, -} +}, map[string][]requestflag.HasOuterFlag{ + "webhook": { + &requestflag.InnerFlag[string]{ + Name: "webhook.url", + Usage: "Public HTTP(S) URL that receives batch completion, failure, or cancellation events.", + InnerField: "url", + }, + &requestflag.InnerFlag[map[string]any]{ + Name: "webhook.retry", + Usage: "Webhook retry settings. Use {} for the default schedule.", + InnerField: "retry", + }, + }, +}) func handleBatchRetrieve(ctx context.Context, cmd *cli.Command) error { client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) diff --git a/pkg/cmd/batch_test.go b/pkg/cmd/batch_test.go index 82a5e97..224fb20 100644 --- a/pkg/cmd/batch_test.go +++ b/pkg/cmd/batch_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/context-dot-dev/context-dev-cli/internal/mocktest" + "github.com/context-dot-dev/context-dev-cli/internal/requestflag" ) func TestBatchRetrieve(t *testing.T) { @@ -31,7 +32,8 @@ func TestBatchList(t *testing.T) { "--limit", "1", "--q", "batch_1a2b", "--search-type", "exact", - "--status", "queued", + "--should-include-unified=true", + "--status", "pending", "--tags", "docs,competitor", ) }) @@ -69,7 +71,7 @@ func TestBatchGetResults(t *testing.T) { "--api-key", "string", "batch", "get-results", "--batch-id", "batch_9f2c8a", - "--cursor", "cursor", + "--cursor", "321669910225:155771193", "--limit", "1", ) }) @@ -82,10 +84,32 @@ func TestBatchSubmit(t *testing.T) { t, "--api-key", "string", "batch", "submit", - "--input", "{data: {format: markdown, urls: [{url: https://example.com/products/anvil, itemId: sku-1, meta: {category: bar}}, {url: https://example.com/products/hammer, itemId: sku-2, meta: {foo: bar}}], options: {country: de, excludeSelectors: [x], includeHTML: true, includeImages: true, includeLinks: true, includeSelectors: [x], maxAgeMs: 0, pdf: {end: 1, ocr: true, shouldParse: true, start: 1}, settleAnimations: true, shortenBase64Images: true, useMainContentOnly: true, waitForMs: 0}}, mode: scrape}", + "--input", "{data: {formats: {bytes: true, highlights: true, html: true, images: true, json: true, markdown: true, parse: true, product: true, screenshot: true}, urls: [{url: https://example.com/products/anvil, itemId: sku-1, meta: {category: bar}}, {url: https://example.com/products/hammer, itemId: sku-2, meta: {foo: bar}}], highlightsParams: {query: x, maxCharacters: 100}, imageParams: {dedupe: none, enrich: [dimensions]}, jsonParams: {schema: {type: bar, properties: bar, required: bar, additionalProperties: bar}, instructions: instructions}, markdownParams: {includeImages: true, includeLinks: true, inlineImages: placeholder, sourcePreference: [html-conversion]}, maxAgeMs: 0, parseParams: {rules: {title: h1, links: {selector: a, output: '@href', type: list}}, type: custom}, productParams: {dedupeImages: true, useAIFallback: true}, screenshotParams: {area: viewport, format: png}, sharedParams: {actions: [{action: Click the product details tab, type: perform}], country: US, dismissCookies: true, dismissPopups: true, excludeSelectors: [P], headers: {Accept-Language: en-US}, includeFrames: true, includeSelectors: [P], mainContentOnly: true, parsers: {pdf: {endPage: 1, includeNumberedPages: true, ocr: 'off', startPage: 1}}, profile: {profileId: prof_210b9798eb53baa4e69d31c1071cf03d, type: existing}, settleAnimations: true, theme: light, viewport: {height: 240, width: 240}, waitFor: 500}, tags: [production, team-alpha], timeoutOpts: {milliseconds: 1, behavior: fail}, zdr: disabled}, mode: scrape}", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", + "--tag", "docs", + "--tag", "competitor", + "--webhook", "{url: https://example.com, retry: {delays_seconds: [10, 60, 300, 1800, 7200, 21600, 57600]}}", + "--webhook-url", "https://example.com", + "--idempotency-key", "Idempotency-Key", + ) + }) + + t.Run("inner flags", func(t *testing.T) { + // Check that inner flags have been set up correctly + requestflag.CheckInnerFlags(batchSubmit) + + // Alternative argument passing style using inner flags + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "batch", "submit", + "--input", "{data: {formats: {bytes: true, highlights: true, html: true, images: true, json: true, markdown: true, parse: true, product: true, screenshot: true}, urls: [{url: https://example.com/products/anvil, itemId: sku-1, meta: {category: bar}}, {url: https://example.com/products/hammer, itemId: sku-2, meta: {foo: bar}}], highlightsParams: {query: x, maxCharacters: 100}, imageParams: {dedupe: none, enrich: [dimensions]}, jsonParams: {schema: {type: bar, properties: bar, required: bar, additionalProperties: bar}, instructions: instructions}, markdownParams: {includeImages: true, includeLinks: true, inlineImages: placeholder, sourcePreference: [html-conversion]}, maxAgeMs: 0, parseParams: {rules: {title: h1, links: {selector: a, output: '@href', type: list}}, type: custom}, productParams: {dedupeImages: true, useAIFallback: true}, screenshotParams: {area: viewport, format: png}, sharedParams: {actions: [{action: Click the product details tab, type: perform}], country: US, dismissCookies: true, dismissPopups: true, excludeSelectors: [P], headers: {Accept-Language: en-US}, includeFrames: true, includeSelectors: [P], mainContentOnly: true, parsers: {pdf: {endPage: 1, includeNumberedPages: true, ocr: 'off', startPage: 1}}, profile: {profileId: prof_210b9798eb53baa4e69d31c1071cf03d, type: existing}, settleAnimations: true, theme: light, viewport: {height: 240, width: 240}, waitFor: 500}, tags: [production, team-alpha], timeoutOpts: {milliseconds: 1, behavior: fail}, zdr: disabled}, mode: scrape}", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--tag", "docs", "--tag", "competitor", - "--webhook-url", "webhookUrl", + "--webhook.url", "https://example.com", + "--webhook.retry", "{delays_seconds: [10, 60, 300, 1800, 7200, 21600, 57600]}", + "--webhook-url", "https://example.com", "--idempotency-key", "Idempotency-Key", ) }) @@ -95,7 +119,16 @@ func TestBatchSubmit(t *testing.T) { pipeData := []byte("" + "input:\n" + " data:\n" + - " format: markdown\n" + + " formats:\n" + + " bytes: true\n" + + " highlights: true\n" + + " html: true\n" + + " images: true\n" + + " json: true\n" + + " markdown: true\n" + + " parse: true\n" + + " product: true\n" + + " screenshot: true\n" + " urls:\n" + " - url: https://example.com/products/anvil\n" + " itemId: sku-1\n" + @@ -105,30 +138,96 @@ func TestBatchSubmit(t *testing.T) { " itemId: sku-2\n" + " meta:\n" + " foo: bar\n" + - " options:\n" + - " country: de\n" + - " excludeSelectors:\n" + - " - x\n" + - " includeHTML: true\n" + + " highlightsParams:\n" + + " query: x\n" + + " maxCharacters: 100\n" + + " imageParams:\n" + + " dedupe: none\n" + + " enrich:\n" + + " - dimensions\n" + + " jsonParams:\n" + + " schema:\n" + + " type: bar\n" + + " properties: bar\n" + + " required: bar\n" + + " additionalProperties: bar\n" + + " instructions: instructions\n" + + " markdownParams:\n" + " includeImages: true\n" + " includeLinks: true\n" + + " inlineImages: placeholder\n" + + " sourcePreference:\n" + + " - html-conversion\n" + + " maxAgeMs: 0\n" + + " parseParams:\n" + + " rules:\n" + + " title: h1\n" + + " links:\n" + + " selector: a\n" + + " output: '@href'\n" + + " type: list\n" + + " type: custom\n" + + " productParams:\n" + + " dedupeImages: true\n" + + " useAIFallback: true\n" + + " screenshotParams:\n" + + " area: viewport\n" + + " format: png\n" + + " sharedParams:\n" + + " actions:\n" + + " - action: Click the product details tab\n" + + " type: perform\n" + + " country: US\n" + + " dismissCookies: true\n" + + " dismissPopups: true\n" + + " excludeSelectors:\n" + + " - P\n" + + " headers:\n" + + " Accept-Language: en-US\n" + + " includeFrames: true\n" + " includeSelectors:\n" + - " - x\n" + - " maxAgeMs: 0\n" + - " pdf:\n" + - " end: 1\n" + - " ocr: true\n" + - " shouldParse: true\n" + - " start: 1\n" + + " - P\n" + + " mainContentOnly: true\n" + + " parsers:\n" + + " pdf:\n" + + " endPage: 1\n" + + " includeNumberedPages: true\n" + + " ocr: 'off'\n" + + " startPage: 1\n" + + " profile:\n" + + " profileId: prof_210b9798eb53baa4e69d31c1071cf03d\n" + + " type: existing\n" + " settleAnimations: true\n" + - " shortenBase64Images: true\n" + - " useMainContentOnly: true\n" + - " waitForMs: 0\n" + + " theme: light\n" + + " viewport:\n" + + " height: 240\n" + + " width: 240\n" + + " waitFor: 500\n" + + " tags:\n" + + " - production\n" + + " - team-alpha\n" + + " timeoutOpts:\n" + + " milliseconds: 1\n" + + " behavior: fail\n" + + " zdr: disabled\n" + " mode: scrape\n" + + "policies:\n" + + " - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" + "tags:\n" + " - docs\n" + " - competitor\n" + - "webhookUrl: webhookUrl\n") + "webhook:\n" + + " url: https://example.com\n" + + " retry:\n" + + " delays_seconds:\n" + + " - 10\n" + + " - 60\n" + + " - 300\n" + + " - 1800\n" + + " - 7200\n" + + " - 21600\n" + + " - 57600\n" + + "webhookUrl: https://example.com\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", diff --git a/pkg/cmd/brand.go b/pkg/cmd/brand.go index 249d26f..9d099a5 100644 --- a/pkg/cmd/brand.go +++ b/pkg/cmd/brand.go @@ -14,9 +14,9 @@ import ( "github.com/urfave/cli/v3" ) -var brandRetrieve = cli.Command{ +var brandRetrieve = requestflag.WithInnerFlags(cli.Command{ Name: "retrieve", - Usage: "Retrieve logos, backdrops, colors, industry, description, and more. Provide\nexactly one lookup identifier in the request body: a domain, company name, email\naddress, stock ticker, transaction descriptor, or direct URL. Note:\n`by_direct_url` fetches brand data only from the provided URL — not from the\nentire internet.", + Usage: "Retrieve logos, colors, company details, and social links using one lookup\nidentifier. A direct URL limits extraction to that page.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -37,7 +37,7 @@ var brandRetrieve = cli.Command{ }, &requestflag.Flag[int64]{ Name: "max-age-ms", - Usage: "Maximum age in milliseconds for cached brand data before the API performs a hard refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms) are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1 year.", + Usage: "Maximum age of cached brand data in ms. Defaults to 3 months; clamped to 0–1 year. `0` refreshes.", BodyPath: "maxAgeMs", }, &requestflag.Flag[bool]{ @@ -45,15 +45,25 @@ var brandRetrieve = cli.Command{ Usage: "Optional parameter to optimize the API call for maximum speed. When set to true, the API will skip time-consuming operations for faster response at the cost of less comprehensive data.", BodyPath: "maxSpeed", }, + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Access policy IDs to apply. A URL must pass every policy.", + BodyPath: "policies", + }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.", + Usage: "Labels for filtering usage in the dashboard.", BodyPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - BodyPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + BodyPath: "timeoutOpts", + }, + &requestflag.Flag[string]{ + Name: "zdr", + Usage: "`enabled` disables request logs and traces and omits request and response content from usage logs. Brand data and hosted assets may still be stored. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", + BodyPath: "zdr", }, &requestflag.Flag[string]{ Name: "name", @@ -62,7 +72,7 @@ var brandRetrieve = cli.Command{ }, &requestflag.Flag[string]{ Name: "country-gl", - Usage: "Optional country code hint (GL parameter) to specify the country when looking up by company name.", + Usage: "Two-letter ISO 3166-1 alpha-2 country code (GL parameter) used to localize search.", BodyPath: "country_gl", }, &requestflag.Flag[string]{ @@ -77,7 +87,7 @@ var brandRetrieve = cli.Command{ }, &requestflag.Flag[string]{ Name: "ticker-exchange", - Usage: "Optional stock exchange for the ticker. Defaults to NASDAQ if not specified.", + Usage: "Stock exchange code.", BodyPath: "ticker_exchange", }, &requestflag.Flag[string]{ @@ -113,48 +123,24 @@ var brandRetrieve = cli.Command{ }, Action: handleBrandRetrieve, HideHelpCommand: true, -} - -var brandRetrieveSimplified = cli.Command{ - Name: "retrieve-simplified", - Usage: "Returns a simplified version of brand data containing only essential\ninformation: domain, title, colors, logos, and backdrops. Optimized for faster\nresponses and reduced data transfer.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "domain", - Usage: "Domain name to retrieve simplified brand data for", - Required: true, - QueryPath: "domain", - }, - &requestflag.Flag[*int64]{ - Name: "max-age-ms", - Usage: "Maximum age in milliseconds for cached brand data before the API performs a hard refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms) are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1 year.", - Default: requestflag.Ptr[int64](7776000000), - QueryPath: "maxAgeMs", +}, map[string][]requestflag.HasOuterFlag{ + "timeout-opts": { + &requestflag.InnerFlag[int64]{ + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", }, - &requestflag.Flag[[]string]{ - Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", - QueryPath: "tags", - }, - &requestflag.Flag[string]{ - Name: "theme", - Usage: "Optional theme preference used when selecting brand assets.", - QueryPath: "theme", - }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag.`, + InnerField: "behavior", }, }, - Action: handleBrandRetrieveSimplified, - HideHelpCommand: true, -} +}) var brandSearch = cli.Command{ Name: "search", - Usage: "Search indexed brands by name or domain", + Usage: "Find up to 10 brands by name or domain, ordered by popularity. Optionally filter\nby country and primary language; both filters must match when provided together.\nResults include description, country, and language when available. Use the\nreturned domain to retrieve a full brand profile.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -169,6 +155,16 @@ var brandSearch = cli.Command{ Default: true, QueryPath: "autocomplete", }, + &requestflag.Flag[string]{ + Name: "country", + Usage: "Only return brands in this country, as an uppercase ISO 3166-1 alpha-2 code such as US or GB.", + QueryPath: "country", + }, + &requestflag.Flag[string]{ + Name: "language", + Usage: "Only return brands with this primary language, such as english or french.", + QueryPath: "language", + }, &requestflag.Flag[[]string]{ Name: "query-by", Usage: "Fields to match the search term against, as a comma-separated list or repeated parameter: 'name', 'domain', or both. Defaults to both.", @@ -177,7 +173,7 @@ var brandSearch = cli.Command{ }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", + Usage: "Comma-separated labels for filtering usage, e.g. `production,team-alpha`.", QueryPath: "tags", }, &requestflag.Flag[int64]{ @@ -232,47 +228,6 @@ func handleBrandRetrieve(ctx context.Context, cmd *cli.Command) error { }) } -func handleBrandRetrieveSimplified(ctx context.Context, cmd *cli.Command) error { - client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatComma, - EmptyBody, - false, - ) - if err != nil { - return err - } - - params := contextdev.BrandGetSimplifiedParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.Brand.GetSimplified(ctx, params, options...) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "brand retrieve-simplified", - Transform: transform, - }) -} - func handleBrandSearch(ctx context.Context, cmd *cli.Command) error { client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) unusedArgs := cmd.Args().Slice() diff --git a/pkg/cmd/brand_test.go b/pkg/cmd/brand_test.go index a46bd9c..a7f8e1a 100644 --- a/pkg/cmd/brand_test.go +++ b/pkg/cmd/brand_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/context-dot-dev/context-dev-cli/internal/mocktest" + "github.com/context-dot-dev/context-dev-cli/internal/requestflag" ) func TestBrandRetrieve(t *testing.T) { @@ -20,9 +21,34 @@ func TestBrandRetrieve(t *testing.T) { "--force-language", "afrikaans", "--max-age-ms", "0", "--max-speed=true", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts", "{milliseconds: 1000, behavior: fail}", + "--zdr", "enabled", + ) + }) + + t.Run("inner flags", func(t *testing.T) { + // Check that inner flags have been set up correctly + requestflag.CheckInnerFlags(brandRetrieve) + + // Alternative argument passing style using inner flags + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "brand", "retrieve", + "--domain", "xxx", + "--type", "by_domain", + "--force-language", "afrikaans", + "--max-age-ms", "0", + "--max-speed=true", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", + "--tag", "production", + "--tag", "team-alpha", + "--timeout-opts.milliseconds", "1000", + "--timeout-opts.behavior", "fail", + "--zdr", "enabled", ) }) @@ -34,10 +60,15 @@ func TestBrandRetrieve(t *testing.T) { "force_language: afrikaans\n" + "maxAgeMs: 0\n" + "maxSpeed: true\n" + + "policies:\n" + + " - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" + "tags:\n" + " - production\n" + " - team-alpha\n" + - "timeoutMS: 1000\n") + "timeoutOpts:\n" + + " milliseconds: 1000\n" + + " behavior: fail\n" + + "zdr: enabled\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", @@ -46,23 +77,6 @@ func TestBrandRetrieve(t *testing.T) { }) } -func TestBrandRetrieveSimplified(t *testing.T) { - t.Skip("Mock server tests are disabled") - t.Run("regular flags", func(t *testing.T) { - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "brand", "retrieve-simplified", - "--domain", "xxx", - "--max-age-ms", "0", - "--tag", "production", - "--tag", "team-alpha", - "--theme", "light", - "--timeout-ms", "1000", - ) - }) -} - func TestBrandSearch(t *testing.T) { t.Skip("Mock server tests are disabled") t.Run("regular flags", func(t *testing.T) { @@ -72,6 +86,8 @@ func TestBrandSearch(t *testing.T) { "brand", "search", "--query", "x", "--autocomplete=true", + "--country", "US", + "--language", "afrikaans", "--query-by", "name", "--tag", "production", "--tag", "team-alpha", diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index 673b8eb..1451ff2 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -97,26 +97,12 @@ func init() { Category: "API RESOURCE", Suggest: true, Commands: []*cli.Command{ - &webExtract, + &webAnswers, &webExtractCompetitors, - &webExtractFonts, &webExtractStyleguide, &webScreenshot, &webSearch, &webWebCrawlMd, - &webWebScrapeHTML, - &webWebScrapeImages, - &webWebScrapeMd, - &webWebScrapeSitemap, - }, - }, - { - Name: "ai", - Category: "API RESOURCE", - Suggest: true, - Commands: []*cli.Command{ - &aiExtractProduct, - &aiExtractProducts, }, }, { @@ -125,7 +111,6 @@ func init() { Suggest: true, Commands: []*cli.Command{ &brandRetrieve, - &brandRetrieveSimplified, &brandSearch, }, }, @@ -179,12 +164,24 @@ func init() { &batchSubmit, }, }, + { + Name: "webhooks:deliveries", + Category: "API RESOURCE", + Suggest: true, + Commands: []*cli.Command{ + &webhooksDeliveriesRetrieve, + &webhooksDeliveriesList, + &webhooksDeliveriesListAttempts, + &webhooksDeliveriesRetry, + }, + }, { Name: "people", Category: "API RESOURCE", Suggest: true, Commands: []*cli.Command{ &peopleEnrich, + &peopleSearch, }, }, { @@ -195,6 +192,15 @@ func init() { &newsSearch, }, }, + { + Name: "logs", + Category: "API RESOURCE", + Suggest: true, + Commands: []*cli.Command{ + &logsRetrieve, + &logsList, + }, + }, { Name: "@manpages", Usage: "Generate documentation for 'man'", diff --git a/pkg/cmd/industry.go b/pkg/cmd/industry.go index 4fd74f4..50e974f 100644 --- a/pkg/cmd/industry.go +++ b/pkg/cmd/industry.go @@ -14,9 +14,9 @@ import ( "github.com/urfave/cli/v3" ) -var industryRetrieveNaics = cli.Command{ +var industryRetrieveNaics = requestflag.WithInnerFlags(cli.Command{ Name: "retrieve-naics", - Usage: "Classify any brand into 2022 NAICS industry codes from its domain or name.", + Usage: "Classify a company into NAICS industry codes.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -39,22 +39,41 @@ var industryRetrieveNaics = cli.Command{ }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", + Usage: "Comma-separated labels for filtering usage, e.g. `production,team-alpha`.", QueryPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + QueryPath: "timeoutOpts", + }, + &requestflag.Flag[string]{ + Name: "zdr", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", + Default: "disabled", + QueryPath: "zdr", }, }, Action: handleIndustryRetrieveNaics, HideHelpCommand: true, -} +}, map[string][]requestflag.HasOuterFlag{ + "timeout-opts": { + &requestflag.InnerFlag[int64]{ + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", + }, + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag.`, + InnerField: "behavior", + }, + }, +}) -var industryRetrieveSic = cli.Command{ +var industryRetrieveSic = requestflag.WithInnerFlags(cli.Command{ Name: "retrieve-sic", - Usage: "Classify any brand into Standard Industrial Classification (SIC) codes from its\ndomain or name. Choose between the original SIC system (`original_sic`) or the\nlatest SIC list maintained by the SEC (`latest_sec`).", + Usage: "Classify a company into SIC industry codes.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -77,24 +96,43 @@ var industryRetrieveSic = cli.Command{ }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", + Usage: "Comma-separated labels for filtering usage, e.g. `production,team-alpha`.", QueryPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + QueryPath: "timeoutOpts", }, &requestflag.Flag[string]{ Name: "type", - Usage: "Which SIC dataset to classify against. `original_sic` uses the 1987 Standard Industrial Classification system; `latest_sec` uses the current SIC list as published by the SEC. Defaults to `original_sic`.", + Usage: "SIC dataset: `original_sic` (1987) or `latest_sec` (current SEC list).", Default: "original_sic", QueryPath: "type", }, + &requestflag.Flag[string]{ + Name: "zdr", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", + Default: "disabled", + QueryPath: "zdr", + }, }, Action: handleIndustryRetrieveSic, HideHelpCommand: true, -} +}, map[string][]requestflag.HasOuterFlag{ + "timeout-opts": { + &requestflag.InnerFlag[int64]{ + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", + }, + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag.`, + InnerField: "behavior", + }, + }, +}) func handleIndustryRetrieveNaics(ctx context.Context, cmd *cli.Command) error { client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) diff --git a/pkg/cmd/industry_test.go b/pkg/cmd/industry_test.go index b7f6329..7400553 100644 --- a/pkg/cmd/industry_test.go +++ b/pkg/cmd/industry_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/context-dot-dev/context-dev-cli/internal/mocktest" + "github.com/context-dot-dev/context-dev-cli/internal/requestflag" ) func TestIndustryRetrieveNaics(t *testing.T) { @@ -20,7 +21,28 @@ func TestIndustryRetrieveNaics(t *testing.T) { "--min-results", "1", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts", "{milliseconds: 1000, behavior: fail}", + "--zdr", "enabled", + ) + }) + + t.Run("inner flags", func(t *testing.T) { + // Check that inner flags have been set up correctly + requestflag.CheckInnerFlags(industryRetrieveNaics) + + // Alternative argument passing style using inner flags + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "industry", "retrieve-naics", + "--input", "xxxx", + "--max-results", "1", + "--min-results", "1", + "--tag", "production", + "--tag", "team-alpha", + "--timeout-opts.milliseconds", "1000", + "--timeout-opts.behavior", "fail", + "--zdr", "enabled", ) }) } @@ -37,8 +59,30 @@ func TestIndustryRetrieveSic(t *testing.T) { "--min-results", "1", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts", "{milliseconds: 1000, behavior: fail}", + "--type", "original_sic", + "--zdr", "enabled", + ) + }) + + t.Run("inner flags", func(t *testing.T) { + // Check that inner flags have been set up correctly + requestflag.CheckInnerFlags(industryRetrieveSic) + + // Alternative argument passing style using inner flags + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "industry", "retrieve-sic", + "--input", "xxxx", + "--max-results", "1", + "--min-results", "1", + "--tag", "production", + "--tag", "team-alpha", + "--timeout-opts.milliseconds", "1000", + "--timeout-opts.behavior", "fail", "--type", "original_sic", + "--zdr", "enabled", ) }) } diff --git a/pkg/cmd/log.go b/pkg/cmd/log.go new file mode 100644 index 0000000..996fb22 --- /dev/null +++ b/pkg/cmd/log.go @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package cmd + +import ( + "context" + "fmt" + + "github.com/context-dot-dev/context-dev-cli/internal/apiquery" + "github.com/context-dot-dev/context-dev-cli/internal/requestflag" + "github.com/context-dot-dev/context-go-sdk/v2" + "github.com/context-dot-dev/context-go-sdk/v2/option" + "github.com/tidwall/gjson" + "github.com/urfave/cli/v3" +) + +var logsRetrieve = cli.Command{ + Name: "retrieve", + Usage: "Retrieve a request’s metadata, retained input, and response. An entry becomes\nretrievable a few seconds after its request completes, so a 404 NOT_FOUND for a\nrequest that just finished means ingestion has not caught up yet; retry after a\nfew seconds.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "request-id", + Usage: "The request ID of the logged API call.", + Required: true, + PathParam: "request_id", + }, + }, + Action: handleLogsRetrieve, + HideHelpCommand: true, +} + +var logsList = cli.Command{ + Name: "list", + Usage: "List your organization’s request logs with filters and pagination. Logs also\ninclude batch settlements and monitor runs.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "error-code", + Usage: "Filter by the `error_code` returned in the response.", + QueryPath: "error_code", + }, + &requestflag.Flag[bool]{ + Name: "errors-only", + Usage: "Only include requests that returned a 4xx or 5xx status.", + Default: false, + QueryPath: "errors_only", + }, + &requestflag.Flag[any]{ + Name: "from", + Usage: "Only include requests at or after this ISO 8601 timestamp. Defaults to 24 hours before `to`.", + QueryPath: "from", + }, + &requestflag.Flag[string]{ + Name: "key-id", + Usage: "Filter by the API key that made the request.", + QueryPath: "key_id", + }, + &requestflag.Flag[int64]{ + Name: "limit", + Usage: "Number of log entries per page.", + Default: 50, + QueryPath: "limit", + }, + &requestflag.Flag[int64]{ + Name: "page", + Usage: "Page number, starting at 1.", + Default: 1, + QueryPath: "page", + }, + &requestflag.Flag[string]{ + Name: "path", + Usage: "Filter by endpoint path, with or without the /v1 prefix.", + QueryPath: "path", + }, + &requestflag.Flag[string]{ + Name: "search", + Usage: "Case-insensitive substring match against the request query and body, e.g. a domain.", + QueryPath: "search", + }, + &requestflag.Flag[int64]{ + Name: "status-code", + Usage: "Filter by exact HTTP status code.", + QueryPath: "status_code", + }, + &requestflag.Flag[string]{ + Name: "tags", + Usage: "Comma-separated request tags. Matches requests carrying any of them. Up to 20 tags, each 1-50 characters.", + QueryPath: "tags", + }, + &requestflag.Flag[any]{ + Name: "to", + Usage: "Only include requests at or before this ISO 8601 timestamp. Defaults to now.", + QueryPath: "to", + }, + }, + Action: handleLogsList, + HideHelpCommand: true, +} + +func handleLogsRetrieve(ctx context.Context, cmd *cli.Command) error { + client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + if !cmd.IsSet("request-id") && len(unusedArgs) > 0 { + cmd.Set("request-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatComma, + EmptyBody, + false, + ) + if err != nil { + return err + } + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.Logs.Get(ctx, cmd.Value("request-id").(string), options...) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "logs retrieve", + Transform: transform, + }) +} + +func handleLogsList(ctx context.Context, cmd *cli.Command) error { + client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatComma, + EmptyBody, + false, + ) + if err != nil { + return err + } + + params := contextdev.LogListParams{} + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.Logs.List(ctx, params, options...) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "logs list", + Transform: transform, + }) +} diff --git a/pkg/cmd/log_test.go b/pkg/cmd/log_test.go new file mode 100644 index 0000000..b1088a5 --- /dev/null +++ b/pkg/cmd/log_test.go @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package cmd + +import ( + "testing" + + "github.com/context-dot-dev/context-dev-cli/internal/mocktest" +) + +func TestLogsRetrieve(t *testing.T) { + t.Skip("Mock server tests are disabled") + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "logs", "retrieve", + "--request-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + }) +} + +func TestLogsList(t *testing.T) { + t.Skip("Mock server tests are disabled") + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "logs", "list", + "--error-code", "WEBSITE_ACCESS_ERROR", + "--errors-only=true", + "--from", "'2026-09-10T00:00:00Z'", + "--key-id", "x", + "--limit", "1", + "--page", "1", + "--path", "/brand/retrieve", + "--search", "acme.com", + "--status-code", "500", + "--tags", "nightly-import,team-alpha", + "--to", "'2026-09-11T00:00:00Z'", + ) + }) +} diff --git a/pkg/cmd/monitor.go b/pkg/cmd/monitor.go index fac0f1c..0815317 100644 --- a/pkg/cmd/monitor.go +++ b/pkg/cmd/monitor.go @@ -16,30 +16,36 @@ import ( var monitorsCreate = requestflag.WithInnerFlags(cli.Command{ Name: "create", - Usage: "Creates a monitor. The request body is a union of the supported target/change\ndetection combinations. The monitor runs immediately after creation to create\nits initial baseline.", + Usage: "Watch a page, URL inventory, or extracted website data on a schedule. A run\nstarts immediately to capture the baseline.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "name", + Usage: "Display name for the monitor.", Required: true, BodyPath: "name", }, &requestflag.Flag[map[string]any]{ Name: "target", - Usage: "Discriminated union describing what the monitor watches.", + Usage: "What to watch: a page, a sitemap, data extracted from a site, or web search results.", Required: true, BodyPath: "target", }, &requestflag.Flag[map[string]any]{ Name: "change-detection", - Usage: "Discriminated union describing how changes are detected.", + Usage: "How changes are judged. Defaults to `semantic` for extract and search targets and page targets with `instructions`, otherwise `exact`.", BodyPath: "change_detection", }, &requestflag.Flag[string]{ Name: "mode", - Usage: "Top-level monitor category. Always `web` today; the concrete behavior is described by `target` and `change_detection`.", + Usage: "Always `web`. Optional.", BodyPath: "mode", }, + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Access policy IDs to apply to every run.", + BodyPath: "policies", + }, &requestflag.Flag[map[string]any]{ Name: "schedule", Usage: "Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.", @@ -47,11 +53,12 @@ var monitorsCreate = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "User-defined tags for grouping and filtering monitors and their changes. Duplicates are removed.", + Usage: "Labels for filtering monitors, their changes, and their usage.", BodyPath: "tags", }, &requestflag.Flag[map[string]any]{ Name: "webhook", + Usage: "Webhook destination and delivery settings. Null means no webhook is configured.", BodyPath: "webhook", }, }, @@ -66,29 +73,34 @@ var monitorsCreate = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.InnerFlag[string]{ Name: "schedule.type", - Usage: `Allowed values: "interval".`, + Usage: "Use `interval` to run on a repeating schedule.", InnerField: "type", }, &requestflag.InnerFlag[string]{ Name: "schedule.unit", - Usage: `Allowed values: "minutes", "hours", "days".`, + Usage: "Time unit used with `frequency` to set the run interval.", InnerField: "unit", }, }, "webhook": { &requestflag.InnerFlag[string]{ Name: "webhook.url", - Usage: "Webhook URL events are delivered to.", + Usage: "Public HTTP(S) URL that receives events. Slack and GovSlack URLs get formatted messages.", InnerField: "url", }, &requestflag.InnerFlag[[]string]{ Name: "webhook.events", - Usage: "Events delivered to this endpoint. `change.detected` fires only when a run detects a change; `run.completed` fires on every completed run — including runs that detected no change — and embeds the change when one was detected. Defaults to `[\"change.detected\"]` when omitted.", + Usage: "Events to deliver. Defaults to `change.detected`; `run.completed` also includes unchanged runs.", InnerField: "events", }, + &requestflag.InnerFlag[map[string]any]{ + Name: "webhook.retry", + Usage: "Webhook retry settings. Use {} for the default schedule.", + InnerField: "retry", + }, &requestflag.InnerFlag[string]{ Name: "webhook.secret", - Usage: "Signing secret used to verify webhook authenticity. Each delivery includes an `X-Context-Signature: t=,v1=` header, where the HMAC is SHA-256 over `\"{t}.{rawRequestBody}\"` keyed by this secret. Recompute it with a constant-time compare and reject stale timestamps to prevent replay. Generated by the API; cannot be set by clients.", + Usage: "API-generated signing secret. Visible only with full access or `monitors:write` permission.", InnerField: "secret", }, }, @@ -96,11 +108,12 @@ var monitorsCreate = requestflag.WithInnerFlags(cli.Command{ var monitorsRetrieve = cli.Command{ Name: "retrieve", - Usage: "Get a monitor", + Usage: "Retrieve a monitor’s configuration and current state.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "monitor-id", + Usage: "ID of the monitor.", Required: true, PathParam: "monitor_id", }, @@ -111,23 +124,30 @@ var monitorsRetrieve = cli.Command{ var monitorsUpdate = requestflag.WithInnerFlags(cli.Command{ Name: "update", - Usage: "Updates a monitor. If `target` or `change_detection` changes, the monitor\ncreates a new baseline. Unsupported target/change detection combinations are\nrejected.", + Usage: "Update a monitor. Changing its target or change detection replaces the baseline\nand queues a new baseline run.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "monitor-id", + Usage: "ID of the monitor.", Required: true, PathParam: "monitor_id", }, &requestflag.Flag[map[string]any]{ Name: "change-detection", - Usage: "Discriminated union describing how changes are detected.", + Usage: "How changes are judged. Defaults to `semantic` for extract and search targets and page targets with `instructions`, otherwise `exact`.", BodyPath: "change_detection", }, &requestflag.Flag[string]{ Name: "name", + Usage: "Display name for the monitor.", BodyPath: "name", }, + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Access policy IDs to apply to every run. Send an empty list to remove them.", + BodyPath: "policies", + }, &requestflag.Flag[map[string]any]{ Name: "schedule", Usage: "Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.", @@ -135,22 +155,22 @@ var monitorsUpdate = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[string]{ Name: "status", - Usage: `Allowed values: "active", "paused".`, + Usage: "Set `paused` to stop scheduled runs or `active` to resume them.", BodyPath: "status", }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "User-defined tags for grouping and filtering monitors and their changes. Duplicates are removed.", + Usage: "Labels for filtering monitors, their changes, and their usage.", BodyPath: "tags", }, &requestflag.Flag[map[string]any]{ Name: "target", - Usage: "Discriminated union describing what the monitor watches.", + Usage: "What to watch: a page, a sitemap, data extracted from a site, or web search results.", BodyPath: "target", }, &requestflag.Flag[map[string]any]{ Name: "webhook", - Usage: "Set to null to remove the webhook.", + Usage: "Set to null to remove the webhook. Changing `url` issues a new secret.", BodyPath: "webhook", }, }, @@ -165,29 +185,34 @@ var monitorsUpdate = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.InnerFlag[string]{ Name: "schedule.type", - Usage: `Allowed values: "interval".`, + Usage: "Use `interval` to run on a repeating schedule.", InnerField: "type", }, &requestflag.InnerFlag[string]{ Name: "schedule.unit", - Usage: `Allowed values: "minutes", "hours", "days".`, + Usage: "Time unit used with `frequency` to set the run interval.", InnerField: "unit", }, }, "webhook": { &requestflag.InnerFlag[string]{ Name: "webhook.url", - Usage: "Webhook URL events are delivered to.", + Usage: "Public HTTP(S) URL that receives events. Slack and GovSlack URLs get formatted messages.", InnerField: "url", }, &requestflag.InnerFlag[[]string]{ Name: "webhook.events", - Usage: "Events delivered to this endpoint. `change.detected` fires only when a run detects a change; `run.completed` fires on every completed run — including runs that detected no change — and embeds the change when one was detected. Defaults to `[\"change.detected\"]` when omitted.", + Usage: "Events to deliver. Defaults to `change.detected`; `run.completed` also includes unchanged runs.", InnerField: "events", }, + &requestflag.InnerFlag[map[string]any]{ + Name: "webhook.retry", + Usage: "Webhook retry settings. Use {} for the default schedule.", + InnerField: "retry", + }, &requestflag.InnerFlag[string]{ Name: "webhook.secret", - Usage: "Signing secret used to verify webhook authenticity. Each delivery includes an `X-Context-Signature: t=,v1=` header, where the HMAC is SHA-256 over `\"{t}.{rawRequestBody}\"` keyed by this secret. Recompute it with a constant-time compare and reject stale timestamps to prevent replay. Generated by the API; cannot be set by clients.", + Usage: "API-generated signing secret. Visible only with full access or `monitors:write` permission.", InnerField: "secret", }, }, @@ -195,7 +220,7 @@ var monitorsUpdate = requestflag.WithInnerFlags(cli.Command{ var monitorsList = cli.Command{ Name: "list", - Usage: "Lists monitors for the authenticated organization. Supports free-text search\n(`q` over `search_by` fields, `prefix` or `exact` via `search_type`) plus\nstatus/type/tag filters. Results are paginated via the opaque `cursor`.", + Usage: "List your monitors with optional search and filters.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -220,7 +245,7 @@ var monitorsList = cli.Command{ }, &requestflag.Flag[any]{ Name: "search-by", - Usage: "Comma-separated fields to search with `q`. Defaults to all of them. Note `instructions` only exists on extract monitors.", + Usage: "Fields to search with `q`. Defaults to all fields; page, extract, and search targets can have instructions, and `url` matches a search target’s query.", QueryPath: "search_by", }, &requestflag.Flag[string]{ @@ -255,11 +280,12 @@ var monitorsList = cli.Command{ var monitorsDelete = cli.Command{ Name: "delete", - Usage: "Delete a monitor", + Usage: "Delete a monitor and stop future runs and webhook retries.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "monitor-id", + Usage: "ID of the monitor.", Required: true, PathParam: "monitor_id", }, @@ -270,7 +296,7 @@ var monitorsDelete = cli.Command{ var monitorsGetCreditUsage = cli.Command{ Name: "get-credit-usage", - Usage: "Returns credits charged per monitor over an optional [since, until] window,\nnewest spenders first.", + Usage: "Return usage per monitor, highest first, for up to the 10,000 most recent runs\nin the requested window.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[any]{ @@ -290,7 +316,7 @@ var monitorsGetCreditUsage = cli.Command{ var monitorsGetLimits = cli.Command{ Name: "get-limits", - Usage: "Returns how many monitors the account has and the maximum it allows.", + Usage: "Retrieve your organization’s monitor allowance and usage.", Suggest: true, Flags: []cli.Flag{}, Action: handleMonitorsGetLimits, @@ -299,7 +325,7 @@ var monitorsGetLimits = cli.Command{ var monitorsListAccountChanges = cli.Command{ Name: "list-account-changes", - Usage: "Returns an account-wide feed of detected changes across monitors.", + Usage: "List full change records across your monitors, newest first.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -349,7 +375,7 @@ var monitorsListAccountChanges = cli.Command{ var monitorsListAccountRuns = cli.Command{ Name: "list-account-runs", - Usage: "Returns an account-wide feed of monitor runs across all monitors.", + Usage: "List runs across your monitors, newest first.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -374,11 +400,12 @@ var monitorsListAccountRuns = cli.Command{ var monitorsListChanges = cli.Command{ Name: "list-changes", - Usage: "List changes for a monitor", + Usage: "List full change records for a monitor, newest first.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "monitor-id", + Usage: "ID of the monitor.", Required: true, PathParam: "monitor_id", }, @@ -414,11 +441,12 @@ var monitorsListChanges = cli.Command{ var monitorsListRuns = cli.Command{ Name: "list-runs", - Usage: "List monitor runs", + Usage: "List a monitor’s runs, newest first.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "monitor-id", + Usage: "ID of the monitor.", Required: true, PathParam: "monitor_id", }, @@ -444,11 +472,12 @@ var monitorsListRuns = cli.Command{ var monitorsRetrieveChange = cli.Command{ Name: "retrieve-change", - Usage: "Get a change", + Usage: "Retrieve a detected change, including its diff and available evidence.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "change-id", + Usage: "ID of the detected change.", Required: true, PathParam: "change_id", }, @@ -459,11 +488,12 @@ var monitorsRetrieveChange = cli.Command{ var monitorsRun = cli.Command{ Name: "run", - Usage: "Triggers an immediate run of the monitor outside its normal schedule. The run is\nqueued and processed asynchronously.", + Usage: "Queue a run without changing the regular schedule. Paused monitors return 409.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "monitor-id", + Usage: "ID of the monitor.", Required: true, PathParam: "monitor_id", }, diff --git a/pkg/cmd/monitor_test.go b/pkg/cmd/monitor_test.go index 983650e..6f90c7c 100644 --- a/pkg/cmd/monitor_test.go +++ b/pkg/cmd/monitor_test.go @@ -17,13 +17,14 @@ func TestMonitorsCreate(t *testing.T) { "--api-key", "string", "monitors", "create", "--name", "Acme pricing page", - "--target", "{type: page, url: https://acme.com/pricing, instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}", + "--target", `{type: page, url: https://acme.com/pricing, actions: [{do: wait, timeMs: 0}], exclude_selectors: [.carousel, '[id^="TA_"]'], include_selectors: ['#attraction-details'], instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}`, "--change-detection", "{type: exact}", "--mode", "web", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--schedule", "{frequency: 6, type: interval, unit: hours}", "--tag", "pricing", "--tag", "competitor", - "--webhook", "{url: https://example.com/webhook, events: [change.detected, run.completed]}", + "--webhook", "{url: https://example.com/webhook, events: [change.detected, run.completed], retry: {delays_seconds: [10, 60, 300, 1800, 7200, 21600, 57600]}}", ) }) @@ -37,9 +38,10 @@ func TestMonitorsCreate(t *testing.T) { "--api-key", "string", "monitors", "create", "--name", "Acme pricing page", - "--target", "{type: page, url: https://acme.com/pricing, instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}", + "--target", `{type: page, url: https://acme.com/pricing, actions: [{do: wait, timeMs: 0}], exclude_selectors: [.carousel, '[id^="TA_"]'], include_selectors: ['#attraction-details'], instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}`, "--change-detection", "{type: exact}", "--mode", "web", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--schedule.frequency", "6", "--schedule.type", "interval", "--schedule.unit", "hours", @@ -47,6 +49,7 @@ func TestMonitorsCreate(t *testing.T) { "--tag", "competitor", "--webhook.url", "https://example.com/webhook", "--webhook.events", "[change.detected, run.completed]", + "--webhook.retry", "{delays_seconds: [10, 60, 300, 1800, 7200, 21600, 57600]}", ) }) @@ -57,6 +60,14 @@ func TestMonitorsCreate(t *testing.T) { "target:\n" + " type: page\n" + " url: https://acme.com/pricing\n" + + " actions:\n" + + " - do: wait\n" + + " timeMs: 0\n" + + " exclude_selectors:\n" + + " - .carousel\n" + + " - '[id^=\"TA_\"]'\n" + + " include_selectors:\n" + + " - '#attraction-details'\n" + " instructions: >-\n" + " Report pricing or plan availability changes. Ignore counters, timestamps,\n" + " testimonials, and navigation.\n" + @@ -64,6 +75,8 @@ func TestMonitorsCreate(t *testing.T) { "change_detection:\n" + " type: exact\n" + "mode: web\n" + + "policies:\n" + + " - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" + "schedule:\n" + " frequency: 6\n" + " type: interval\n" + @@ -75,7 +88,16 @@ func TestMonitorsCreate(t *testing.T) { " url: https://example.com/webhook\n" + " events:\n" + " - change.detected\n" + - " - run.completed\n") + " - run.completed\n" + + " retry:\n" + + " delays_seconds:\n" + + " - 10\n" + + " - 60\n" + + " - 300\n" + + " - 1800\n" + + " - 7200\n" + + " - 21600\n" + + " - 57600\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", @@ -106,12 +128,13 @@ func TestMonitorsUpdate(t *testing.T) { "--monitor-id", "mon_123", "--change-detection", "{type: exact}", "--name", "Acme pricing monitor", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--schedule", "{frequency: 1, type: interval, unit: hours}", "--status", "active", "--tag", "pricing", "--tag", "competitor", - "--target", "{type: page, url: https://acme.com/pricing, instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}", - "--webhook", "{url: https://example.com/webhook, events: [change.detected, run.completed]}", + "--target", `{type: page, url: https://acme.com/pricing, actions: [{do: wait, timeMs: 0}], exclude_selectors: [.carousel, '[id^="TA_"]'], include_selectors: ['#attraction-details'], instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}`, + "--webhook", "{url: https://example.com/webhook, events: [change.detected, run.completed], retry: {delays_seconds: [10, 60, 300, 1800, 7200, 21600, 57600]}}", ) }) @@ -127,15 +150,17 @@ func TestMonitorsUpdate(t *testing.T) { "--monitor-id", "mon_123", "--change-detection", "{type: exact}", "--name", "Acme pricing monitor", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--schedule.frequency", "1", "--schedule.type", "interval", "--schedule.unit", "hours", "--status", "active", "--tag", "pricing", "--tag", "competitor", - "--target", "{type: page, url: https://acme.com/pricing, instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}", + "--target", `{type: page, url: https://acme.com/pricing, actions: [{do: wait, timeMs: 0}], exclude_selectors: [.carousel, '[id^="TA_"]'], include_selectors: ['#attraction-details'], instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}`, "--webhook.url", "https://example.com/webhook", "--webhook.events", "[change.detected, run.completed]", + "--webhook.retry", "{delays_seconds: [10, 60, 300, 1800, 7200, 21600, 57600]}", ) }) @@ -145,6 +170,8 @@ func TestMonitorsUpdate(t *testing.T) { "change_detection:\n" + " type: exact\n" + "name: Acme pricing monitor\n" + + "policies:\n" + + " - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" + "schedule:\n" + " frequency: 1\n" + " type: interval\n" + @@ -156,6 +183,14 @@ func TestMonitorsUpdate(t *testing.T) { "target:\n" + " type: page\n" + " url: https://acme.com/pricing\n" + + " actions:\n" + + " - do: wait\n" + + " timeMs: 0\n" + + " exclude_selectors:\n" + + " - .carousel\n" + + " - '[id^=\"TA_\"]'\n" + + " include_selectors:\n" + + " - '#attraction-details'\n" + " instructions: >-\n" + " Report pricing or plan availability changes. Ignore counters, timestamps,\n" + " testimonials, and navigation.\n" + @@ -164,7 +199,16 @@ func TestMonitorsUpdate(t *testing.T) { " url: https://example.com/webhook\n" + " events:\n" + " - change.detected\n" + - " - run.completed\n") + " - run.completed\n" + + " retry:\n" + + " delays_seconds:\n" + + " - 10\n" + + " - 60\n" + + " - 300\n" + + " - 1800\n" + + " - 7200\n" + + " - 21600\n" + + " - 57600\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", diff --git a/pkg/cmd/news.go b/pkg/cmd/news.go index e9f54cc..f8344f5 100644 --- a/pkg/cmd/news.go +++ b/pkg/cmd/news.go @@ -16,12 +16,12 @@ import ( var newsSearch = requestflag.WithInnerFlags(cli.Command{ Name: "search", - Usage: "Searches live and historical company news for one company, identified in\nsearchBy by name, domain, ticker (optionally disambiguated by exchange), or\nISIN. Results can be filtered by publisher domain, publisher country, article\nlanguage, article type, and published-at date, and include stable story IDs,\nsource metadata, verified entity relevance, and cursor pagination.", + Usage: "Find news about a company by name, domain, ticker, or ISIN, or search all news\nwith a natural-language query. Filter articles and continue through results with\na cursor.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[map[string]any]{ Name: "search-by", - Usage: "What to search for.", + Usage: "What to search for: a specific company, or a natural-language query across all news.", Required: true, BodyPath: "searchBy", }, @@ -32,8 +32,7 @@ var newsSearch = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[map[string]any]{ Name: "filter-by", - Usage: "Optional result filters.", - Default: map[string]any{}, + Usage: "Optional result filters. Use at most one of sourceDomain, sourceCountry, articleLanguage, or articleType. A date range may accompany that category; date.from must not exceed date.to.", BodyPath: "filterBy", }, &requestflag.Flag[int64]{ @@ -42,33 +41,25 @@ var newsSearch = requestflag.WithInnerFlags(cli.Command{ Default: 10, BodyPath: "limit", }, + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Access policy IDs to apply. A URL must pass every policy.", + BodyPath: "policies", + }, &requestflag.Flag[map[string]any]{ Name: "sort-by", - Usage: "Result ordering. Defaults to newest.", - Default: map[string]any{"type": "newest"}, + Usage: "Result ordering. Defaults to newest for entity searches. Natural-language searches are always ordered by relevance.", BodyPath: "sortBy", }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.", + Usage: "Labels for filtering usage in the dashboard.", BodyPath: "tags", }, }, Action: handleNewsSearch, HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ - "search-by": { - &requestflag.InnerFlag[map[string]any]{ - Name: "search-by.entity", - Usage: "The company to search news for, identified by name, domain, ticker, or ISIN.", - InnerField: "entity", - }, - &requestflag.InnerFlag[string]{ - Name: "search-by.type", - Usage: "How to search. Only entity search is supported.", - InnerField: "type", - }, - }, "filter-by": { &requestflag.InnerFlag[[]string]{ Name: "filter-by.article-language", @@ -82,7 +73,7 @@ var newsSearch = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.InnerFlag[map[string]any]{ Name: "filter-by.date", - Usage: "Published-at window in epoch milliseconds.", + Usage: "Published-at window in epoch milliseconds. from must be before or equal to to.", InnerField: "date", }, &requestflag.InnerFlag[[]string]{ diff --git a/pkg/cmd/news_test.go b/pkg/cmd/news_test.go index 5260a23..9b9cfeb 100644 --- a/pkg/cmd/news_test.go +++ b/pkg/cmd/news_test.go @@ -16,10 +16,11 @@ func TestNewsSearch(t *testing.T) { t, "--api-key", "string", "news", "search", - "--search-by", "{entity: {name: xx, type: name}, type: entity}", + "--search-by", "{entity: {domain: stripe.com, type: domain}, type: entity}", "--cursor", "cursor", - "--filter-by", "{articleLanguage: [ar], articleType: [editorial], date: {from: 0, to: 0}, sourceCountry: [ae], sourceDomain: [x]}", + "--filter-by", "{articleLanguage: [am], articleType: [editorial], date: {from: 0, to: 0}, sourceCountry: [ae], sourceDomain: [x]}", "--limit", "1", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--sort-by", "{type: relevance}", "--tag", "production", "--tag", "team-alpha", @@ -35,15 +36,15 @@ func TestNewsSearch(t *testing.T) { t, "--api-key", "string", "news", "search", - "--search-by.entity", "{name: xx, type: name}", - "--search-by.type", "entity", + "--search-by", "{entity: {domain: stripe.com, type: domain}, type: entity}", "--cursor", "cursor", - "--filter-by.article-language", "[ar]", + "--filter-by.article-language", "[am]", "--filter-by.article-type", "[editorial]", "--filter-by.date", "{from: 0, to: 0}", "--filter-by.source-country", "[ae]", "--filter-by.source-domain", "[x]", "--limit", "1", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--sort-by.type", "relevance", "--tag", "production", "--tag", "team-alpha", @@ -55,13 +56,13 @@ func TestNewsSearch(t *testing.T) { pipeData := []byte("" + "searchBy:\n" + " entity:\n" + - " name: xx\n" + - " type: name\n" + + " domain: stripe.com\n" + + " type: domain\n" + " type: entity\n" + "cursor: cursor\n" + "filterBy:\n" + " articleLanguage:\n" + - " - ar\n" + + " - am\n" + " articleType:\n" + " - editorial\n" + " date:\n" + @@ -72,6 +73,8 @@ func TestNewsSearch(t *testing.T) { " sourceDomain:\n" + " - x\n" + "limit: 1\n" + + "policies:\n" + + " - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" + "sortBy:\n" + " type: relevance\n" + "tags:\n" + diff --git a/pkg/cmd/parse.go b/pkg/cmd/parse.go index 7f53188..b965d54 100644 --- a/pkg/cmd/parse.go +++ b/pkg/cmd/parse.go @@ -18,7 +18,7 @@ import ( var parseHandle = requestflag.WithInnerFlags(cli.Command{ Name: "handle", - Usage: "Converts raw text, source code, web/data, PDF, Microsoft Office, and image bytes\ninto LLM-usable Markdown.", + Usage: "Convert uploaded file bytes into Markdown and optional HTML. WARC and WARC.GZ\narchives combine HTTP response, resource, and conversion records in archive\norder. Revisit and segmented records are skipped. Decoded WARC content is\nlimited to 50 MiB.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -34,7 +34,7 @@ var parseHandle = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[string]{ Name: "extension", - Usage: "Optional file extension hint, such as pdf, docx, xlsx, pptx, html, json, csv, md, py, rtf, jpg, png, or txt.", + Usage: "Optional file extension hint, such as pdf, docx, xlsx, pptx, html, json, csv, md, py, rtf, jpg, png, txt, warc, or warc.gz.", QueryPath: "extension", }, &requestflag.Flag[bool]{ @@ -49,16 +49,21 @@ var parseHandle = requestflag.WithInnerFlags(cli.Command{ Default: true, QueryPath: "includeLinks", }, + &requestflag.Flag[bool]{ + Name: "include-numbered-pages", + Usage: "Start each PDF page in the Markdown with a `` line, where N is the original 1-based page number.", + Default: false, + QueryPath: "includeNumberedPages", + }, &requestflag.Flag[bool]{ Name: "ocr", - Usage: "When true for PDF inputs, OCR the selected pages that have no usable text layer (scans), replacing each recovered page's text with the OCR result while pages with a real text layer keep it. pdf.start/pdf.end limit the inclusive page range. Billed at 1 credit per page OCR actually recovered, on top of the base request cost. When false, no OCR runs.", + Usage: "Read text from images and scanned PDF pages. PDF page ranges still apply.", Default: false, QueryPath: "ocr", }, &requestflag.Flag[map[string]any]{ Name: "pdf", Usage: `PDF page-range options as a JSON object, e.g. {"start": 2, "end": 5}.`, - Default: map[string]any{}, QueryPath: "pdf", }, &requestflag.Flag[bool]{ @@ -69,7 +74,7 @@ var parseHandle = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", + Usage: "Comma-separated labels for filtering usage, e.g. `production,team-alpha`.", QueryPath: "tags", }, &requestflag.Flag[bool]{ @@ -80,7 +85,7 @@ var parseHandle = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[string]{ Name: "zdr", - Usage: "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 organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", Default: "disabled", QueryPath: "zdr", }, @@ -91,12 +96,12 @@ var parseHandle = requestflag.WithInnerFlags(cli.Command{ "pdf": { &requestflag.InnerFlag[int64]{ Name: "pdf.end", - Usage: "Last 1-based PDF page to parse. When omitted, parsing ends at the last page. Must be greater than or equal to start when both are provided.", + Usage: "Last PDF page to parse (1-based, inclusive). Defaults to the final page. Must be >= start.", InnerField: "end", }, &requestflag.InnerFlag[int64]{ Name: "pdf.start", - Usage: "First 1-based PDF page to parse. When omitted, parsing starts at the first page.", + Usage: "First 1-based PDF page to parse.", InnerField: "start", }, }, diff --git a/pkg/cmd/parse_test.go b/pkg/cmd/parse_test.go index fd11604..47ba4ff 100644 --- a/pkg/cmd/parse_test.go +++ b/pkg/cmd/parse_test.go @@ -18,9 +18,10 @@ func TestParseHandle(t *testing.T) { "parse", "handle", "--body", mocktest.TestFile(t, "Example data"), "--client", "x", - "--extension", "txt", + "--extension", "warc", "--include-images=true", "--include-links=true", + "--include-numbered-pages=true", "--ocr=true", "--pdf", "{end: 1, start: 1}", "--shorten-base64-images=true", @@ -42,9 +43,10 @@ func TestParseHandle(t *testing.T) { "parse", "handle", "--body", mocktest.TestFile(t, "Example data"), "--client", "x", - "--extension", "txt", + "--extension", "warc", "--include-images=true", "--include-links=true", + "--include-numbered-pages=true", "--ocr=true", "--pdf.end", "1", "--pdf.start", "1", @@ -64,9 +66,10 @@ func TestParseHandle(t *testing.T) { "--api-key", "string", "parse", "handle", "--client", "x", - "--extension", "txt", + "--extension", "warc", "--include-images=true", "--include-links=true", + "--include-numbered-pages=true", "--ocr=true", "--pdf", "{end: 1, start: 1}", "--shorten-base64-images=true", diff --git a/pkg/cmd/person.go b/pkg/cmd/person.go index efc6e30..0b8cf9a 100644 --- a/pkg/cmd/person.go +++ b/pkg/cmd/person.go @@ -16,42 +16,53 @@ import ( var peopleEnrich = requestflag.WithInnerFlags(cli.Command{ Name: "enrich", - Usage: "Finds and normalizes the best available person candidate from additive identity\nclues, then assigns an identity match score from 0 to 100. Available on all paid\nplans. Successful requests cost 20 credits. Disposable and free email addresses\n(like gmail.com, yahoo.com) will throw a 422 error.", + Usage: "Find a person from identity clues and return their profile with a match score.\nAvailable on all plans; free or disposable email addresses return 422.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[map[string]any]{ Name: "company", + Usage: "Company context to help identify the person. Provide a name or domain.", BodyPath: "company", }, &requestflag.Flag[[]map[string]any]{ Name: "education", + Usage: "Education history to help distinguish people with similar names.", BodyPath: "education", }, &requestflag.Flag[string]{ Name: "email", + Usage: "Email address of the person to find.", BodyPath: "email", }, &requestflag.Flag[map[string]any]{ Name: "location", + Usage: "Location context to help identify the person. Provide a city, region, or country.", BodyPath: "location", }, &requestflag.Flag[map[string]any]{ Name: "name", + Usage: "Person name. Without an email or person-profile URL, provide both first and last name plus company, education, or location.", BodyPath: "name", }, &requestflag.Flag[[]string]{ Name: "social-url", + Usage: "Public profile URLs for the person. A person-profile URL can identify the person without a name.", BodyPath: "social_urls", }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.", + Usage: "Labels for filtering usage in the dashboard.", BodyPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - BodyPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + BodyPath: "timeoutOpts", + }, + &requestflag.Flag[string]{ + Name: "zdr", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", + BodyPath: "zdr", }, }, Action: handlePeopleEnrich, @@ -60,55 +71,138 @@ var peopleEnrich = requestflag.WithInnerFlags(cli.Command{ "company": { &requestflag.InnerFlag[string]{ Name: "company.domain", + Usage: "Website domain of a company associated with the person.", InnerField: "domain", }, &requestflag.InnerFlag[string]{ Name: "company.name", + Usage: "Name of a company associated with the person.", InnerField: "name", }, }, "education": { &requestflag.InnerFlag[string]{ Name: "education.degree", + Usage: "Degree or qualification earned.", InnerField: "degree", }, &requestflag.InnerFlag[string]{ Name: "education.field-of-study", + Usage: "Subject or major studied.", InnerField: "field_of_study", }, &requestflag.InnerFlag[int64]{ Name: "education.graduation-year", + Usage: "Four-digit graduation year.", InnerField: "graduation_year", }, &requestflag.InnerFlag[map[string]any]{ Name: "education.institution", + Usage: "School or university, identified by name or domain.", InnerField: "institution", }, }, "location": { &requestflag.InnerFlag[string]{ Name: "location.city", + Usage: "City associated with the person.", InnerField: "city", }, &requestflag.InnerFlag[string]{ Name: "location.country", + Usage: "Country associated with the person.", InnerField: "country", }, &requestflag.InnerFlag[string]{ Name: "location.region", + Usage: "State, province, or region associated with the person.", InnerField: "region", }, }, "name": { &requestflag.InnerFlag[string]{ Name: "name.first", + Usage: "First or given name.", InnerField: "first", }, &requestflag.InnerFlag[string]{ Name: "name.last", + Usage: "Last or family name.", InnerField: "last", }, }, + "timeout-opts": { + &requestflag.InnerFlag[int64]{ + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", + }, + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag.`, + InnerField: "behavior", + }, + }, +}) + +var peopleSearch = requestflag.WithInnerFlags(cli.Command{ + Name: "search", + Usage: "Find people with a natural-language query.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "query", + Usage: "Describe the people to find. Up to 500 characters in `fast` mode and 5000 in `ultra` mode.", + Required: true, + BodyPath: "query", + }, + &requestflag.Flag[string]{ + Name: "cursor", + Usage: "Use next_cursor with the same query, mode and filters to fetch the next page.", + BodyPath: "cursor", + }, + &requestflag.Flag[map[string]any]{ + Name: "filters", + Usage: "Additional constraints every result must match.", + BodyPath: "filters", + }, + &requestflag.Flag[string]{ + Name: "mode", + Usage: "`fast` matches people on basic criteria (e.g. their role, location or background); `ultra` plans a deeper search, judges each candidate against every criterion in the query. Complex `ultra` searches can take up to 30 seconds to complete, so allow for that in your client timeout.", + Default: "fast", + BodyPath: "mode", + }, + &requestflag.Flag[[]string]{ + Name: "tag", + Usage: "Labels for filtering usage in the dashboard.", + BodyPath: "tags", + }, + &requestflag.Flag[string]{ + Name: "zdr", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", + BodyPath: "zdr", + }, + }, + Action: handlePeopleSearch, + HideHelpCommand: true, +}, map[string][]requestflag.HasOuterFlag{ + "filters": { + &requestflag.InnerFlag[[]string]{ + Name: "filters.countries", + Usage: "Countries people live in as two-letter codes, such as US or GB.", + InnerField: "countries", + }, + &requestflag.InnerFlag[int64]{ + Name: "filters.years-of-experience-max", + Usage: "Maximum years of professional experience.", + InnerField: "years_of_experience_max", + }, + &requestflag.InnerFlag[int64]{ + Name: "filters.years-of-experience-min", + Usage: "Minimum years of professional experience.", + InnerField: "years_of_experience_min", + }, + }, }) func handlePeopleEnrich(ctx context.Context, cmd *cli.Command) error { @@ -151,3 +245,44 @@ func handlePeopleEnrich(ctx context.Context, cmd *cli.Command) error { Transform: transform, }) } + +func handlePeopleSearch(ctx context.Context, cmd *cli.Command) error { + client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatComma, + ApplicationJSON, + false, + ) + if err != nil { + return err + } + + params := contextdev.PersonSearchParams{} + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.People.Search(ctx, params, options...) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "people search", + Transform: transform, + }) +} diff --git a/pkg/cmd/person_test.go b/pkg/cmd/person_test.go index 2a1a4b1..4018699 100644 --- a/pkg/cmd/person_test.go +++ b/pkg/cmd/person_test.go @@ -24,7 +24,8 @@ func TestPeopleEnrich(t *testing.T) { "--social-url", "https://www.linkedin.com/in/ada-lovelace/", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts", "{milliseconds: 1000, behavior: fail}", + "--zdr", "enabled", ) }) @@ -52,7 +53,9 @@ func TestPeopleEnrich(t *testing.T) { "--social-url", "https://www.linkedin.com/in/ada-lovelace/", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts.milliseconds", "1000", + "--timeout-opts.behavior", "fail", + "--zdr", "enabled", ) }) @@ -82,7 +85,10 @@ func TestPeopleEnrich(t *testing.T) { "tags:\n" + " - production\n" + " - team-alpha\n" + - "timeoutMS: 1000\n") + "timeoutOpts:\n" + + " milliseconds: 1000\n" + + " behavior: fail\n" + + "zdr: enabled\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", @@ -90,3 +96,64 @@ func TestPeopleEnrich(t *testing.T) { ) }) } + +func TestPeopleSearch(t *testing.T) { + t.Skip("Mock server tests are disabled") + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "people", "search", + "--query", "VPs of sales at solar companies in California", + "--cursor", "cursor", + "--filters", "{countries: [SE], years_of_experience_max: 0, years_of_experience_min: 0}", + "--mode", "fast", + "--tag", "production", + "--tag", "team-alpha", + "--zdr", "enabled", + ) + }) + + t.Run("inner flags", func(t *testing.T) { + // Check that inner flags have been set up correctly + requestflag.CheckInnerFlags(peopleSearch) + + // Alternative argument passing style using inner flags + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "people", "search", + "--query", "VPs of sales at solar companies in California", + "--cursor", "cursor", + "--filters.countries", "[SE]", + "--filters.years-of-experience-max", "0", + "--filters.years-of-experience-min", "0", + "--mode", "fast", + "--tag", "production", + "--tag", "team-alpha", + "--zdr", "enabled", + ) + }) + + t.Run("piping data", func(t *testing.T) { + // Test piping YAML data over stdin + pipeData := []byte("" + + "query: VPs of sales at solar companies in California\n" + + "cursor: cursor\n" + + "filters:\n" + + " countries:\n" + + " - SE\n" + + " years_of_experience_max: 0\n" + + " years_of_experience_min: 0\n" + + "mode: fast\n" + + "tags:\n" + + " - production\n" + + " - team-alpha\n" + + "zdr: enabled\n") + mocktest.TestRunMockTestWithPipeAndFlags( + t, pipeData, + "--api-key", "string", + "people", "search", + ) + }) +} diff --git a/pkg/cmd/utility.go b/pkg/cmd/utility.go index 4173edf..9bb4f49 100644 --- a/pkg/cmd/utility.go +++ b/pkg/cmd/utility.go @@ -14,9 +14,9 @@ import ( "github.com/urfave/cli/v3" ) -var utilityPrefetch = cli.Command{ +var utilityPrefetch = requestflag.WithInnerFlags(cli.Command{ Name: "prefetch", - Usage: "Signal that you may fetch data soon to improve latency. The type field selects\nwhat to prefetch ('brand' queues a brand data fetch, 'styleguide' queues a\nstyleguide extraction) and identifier carries exactly one lookup key: a domain,\nor an email whose domain is extracted and validated (free email providers and\ndisposable email addresses are not allowed).", + Usage: "Queue brand or styleguide data so a later lookup can return sooner.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[map[string]any]{ @@ -27,24 +27,42 @@ var utilityPrefetch = cli.Command{ }, &requestflag.Flag[string]{ Name: "type", - Usage: "What to prefetch: 'brand' warms the brand data cache, 'styleguide' warms the styleguide cache.", + Usage: "Data to prefetch.", Required: true, BodyPath: "type", }, + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Access policy IDs to apply. A URL must pass every policy.", + BodyPath: "policies", + }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.", + Usage: "Labels for filtering usage in the dashboard.", BodyPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - BodyPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + BodyPath: "timeoutOpts", }, }, Action: handleUtilityPrefetch, HideHelpCommand: true, -} +}, map[string][]requestflag.HasOuterFlag{ + "timeout-opts": { + &requestflag.InnerFlag[int64]{ + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", + }, + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `Only "fail" is supported: return 408 at the deadline.`, + InnerField: "behavior", + }, + }, +}) func handleUtilityPrefetch(ctx context.Context, cmd *cli.Command) error { client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) diff --git a/pkg/cmd/utility_test.go b/pkg/cmd/utility_test.go index 8f43739..4067d14 100644 --- a/pkg/cmd/utility_test.go +++ b/pkg/cmd/utility_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/context-dot-dev/context-dev-cli/internal/mocktest" + "github.com/context-dot-dev/context-dev-cli/internal/requestflag" ) func TestUtilityPrefetch(t *testing.T) { @@ -15,11 +16,31 @@ func TestUtilityPrefetch(t *testing.T) { t, "--api-key", "string", "utility", "prefetch", - "--identifier", "{domain: xxx}", + "--identifier", "{domain: stripe.com}", "--type", "brand", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts", "{milliseconds: 1000, behavior: fail}", + ) + }) + + t.Run("inner flags", func(t *testing.T) { + // Check that inner flags have been set up correctly + requestflag.CheckInnerFlags(utilityPrefetch) + + // Alternative argument passing style using inner flags + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "utility", "prefetch", + "--identifier", "{domain: stripe.com}", + "--type", "brand", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", + "--tag", "production", + "--tag", "team-alpha", + "--timeout-opts.milliseconds", "1000", + "--timeout-opts.behavior", "fail", ) }) @@ -27,12 +48,16 @@ func TestUtilityPrefetch(t *testing.T) { // Test piping YAML data over stdin pipeData := []byte("" + "identifier:\n" + - " domain: xxx\n" + + " domain: stripe.com\n" + "type: brand\n" + + "policies:\n" + + " - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" + "tags:\n" + " - production\n" + " - team-alpha\n" + - "timeoutMS: 1000\n") + "timeoutOpts:\n" + + " milliseconds: 1000\n" + + " behavior: fail\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index a82500c..52f6224 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -2,4 +2,4 @@ package cmd -const Version = "1.9.0" // x-release-please-version +const Version = "1.28.0" // x-release-please-version diff --git a/pkg/cmd/web.go b/pkg/cmd/web.go index bd2b64d..5cdf5e3 100644 --- a/pkg/cmd/web.go +++ b/pkg/cmd/web.go @@ -14,124 +14,66 @@ import ( "github.com/urfave/cli/v3" ) -var webExtract = requestflag.WithInnerFlags(cli.Command{ - Name: "extract", - Usage: "Crawl a website, use the provided JSON Schema and instructions to prioritize\nrelevant internal links, and extract structured data from the selected pages.", +var webAnswers = requestflag.WithInnerFlags(cli.Command{ + Name: "answers", + Usage: "Research the web and return a sourced answer in your JSON shape. Choose `fast`\nfor a short task or `ultra` for deeper research.", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[map[string]any]{ - Name: "schema", - Usage: "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.", - Required: true, - BodyPath: "schema", - }, &requestflag.Flag[string]{ - Name: "url", - Usage: "The starting website URL to crawl and extract from. Must include http:// or https://.", + Name: "task", + Usage: "Research task. The agent selects company/profile lookups, web searches, or page reads. Include domains or URLs to focus the research.", Required: true, - BodyPath: "url", - }, - &requestflag.Flag[[]map[string]any]{ - Name: "action", - Usage: "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.", - BodyPath: "actions", - }, - &requestflag.Flag[bool]{ - Name: "fact-check", - Usage: "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 the page content (e.g. ideal customer, competitor analysis, recommendations) while keeping verifiable specifics (names, quotes, URLs, dates, metrics) faithful to the source.", - Default: false, - BodyPath: "factCheck", - }, - &requestflag.Flag[bool]{ - Name: "follow-subdomains", - Usage: "When true, follow links on subdomains of the starting URL's domain.", - Default: false, - BodyPath: "followSubdomains", - }, - &requestflag.Flag[bool]{ - Name: "include-frames", - Usage: "When true, iframe contents are included in Markdown before extraction.", - Default: false, - BodyPath: "includeFrames", - }, - &requestflag.Flag[string]{ - Name: "instructions", - Usage: "Optional extraction guidance, such as which facts to prioritize or how to interpret fields in the schema.", - BodyPath: "instructions", - }, - &requestflag.Flag[int64]{ - Name: "max-age-ms", - Usage: "Return cached scrape results if a prior scrape for the same parameters is younger than this many milliseconds. Defaults to 7 days (604800000 ms).", - Default: 604800000, - BodyPath: "maxAgeMs", - }, - &requestflag.Flag[int64]{ - Name: "max-depth", - Usage: "Optional maximum link depth from the starting URL (0 = only the starting page). If omitted, there is no crawl depth limit.", - BodyPath: "maxDepth", - }, - &requestflag.Flag[int64]{ - Name: "max-pages", - Usage: "Maximum number of pages to analyze for extraction. Hard cap: 50. Defaults to 5.", - Default: 5, - BodyPath: "maxPages", + BodyPath: "task", }, &requestflag.Flag[map[string]any]{ - Name: "pdf", - Default: map[string]any{"shouldParse": true}, - BodyPath: "pdf", + Name: "json-format", + Usage: "Example answer object, not JSON Schema. Up to 8 levels, 500 values, and 16000 characters; unknowns may be null.", + BodyPath: "json_format", }, - &requestflag.Flag[bool]{ - Name: "settle-animations", - Usage: "When true, waits briefly for CSS and transition animations to settle before extracting each crawled page. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages.", - Default: false, - BodyPath: "settleAnimations", + &requestflag.Flag[string]{ + Name: "mode", + Usage: "`fast` prioritizes speed, with extra verification for people and companies; `ultra` supports deeper research (default).", + BodyPath: "mode", }, - &requestflag.Flag[int64]{ - Name: "stop-after-ms", - Usage: "Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 (110s). Defaults to 80000 (80s), or 110000 (110s) when browser actions are provided.", - Default: 80000, - BodyPath: "stopAfterMs", + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Access policy IDs to apply. A URL must pass every policy.", + BodyPath: "policies", }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.", + Usage: "Labels for filtering usage in the dashboard.", BodyPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - BodyPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + BodyPath: "timeoutOpts", }, - &requestflag.Flag[int64]{ - Name: "wait-for-ms", - Usage: "Optional browser wait time in milliseconds after initial page load for each crawled page.", - BodyPath: "waitForMs", + &requestflag.Flag[string]{ + Name: "zdr", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", + BodyPath: "zdr", }, }, - Action: handleWebExtract, + Action: handleWebAnswers, HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ - "pdf": { + "timeout-opts": { &requestflag.InnerFlag[int64]{ - Name: "pdf.end", - Usage: "Last 1-based PDF page to parse. Must be greater than or equal to start when both are provided.", - InnerField: "end", + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", }, - &requestflag.InnerFlag[bool]{ - Name: "pdf.should-parse", - Usage: "When true, PDF pages are fetched and parsed. When false, PDF pages are skipped.", - InnerField: "shouldParse", - }, - &requestflag.InnerFlag[int64]{ - Name: "pdf.start", - Usage: "First 1-based PDF page to parse.", - InnerField: "start", + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag.`, + InnerField: "behavior", }, }, }) -var webExtractCompetitors = cli.Command{ +var webExtractCompetitors = requestflag.WithInnerFlags(cli.Command{ Name: "extract-competitors", Usage: "Analyze a company's landing page and web search evidence to return direct\ncompetitors for the same product or market.", Suggest: true, @@ -150,58 +92,41 @@ var webExtractCompetitors = cli.Command{ }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", + Usage: "Comma-separated labels for filtering usage, e.g. `production,team-alpha`.", QueryPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + QueryPath: "timeoutOpts", + }, + &requestflag.Flag[string]{ + Name: "zdr", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", + Default: "disabled", + QueryPath: "zdr", }, }, Action: handleWebExtractCompetitors, HideHelpCommand: true, -} - -var webExtractFonts = cli.Command{ - Name: "extract-fonts", - Usage: "Scrape font information from a website including font families, usage\nstatistics, fallbacks, and element/word counts.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "direct-url", - Usage: "A specific URL to fetch fonts from directly, bypassing domain resolution (e.g., 'https://example.com/design-system'). When provided, fonts are extracted from this exact URL. You must provide either 'domain' or 'directUrl', but not both.", - QueryPath: "directUrl", - }, - &requestflag.Flag[string]{ - Name: "domain", - Usage: "Domain name to extract fonts from (e.g., 'example.com', 'google.com'). The domain will be automatically normalized and validated. You must provide either 'domain' or 'directUrl', but not both.", - QueryPath: "domain", - }, - &requestflag.Flag[*int64]{ - Name: "max-age-ms", - Usage: "Maximum age in milliseconds for cached brand data before the API performs a hard refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms) are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1 year.", - Default: requestflag.Ptr[int64](7776000000), - QueryPath: "maxAgeMs", - }, - &requestflag.Flag[[]string]{ - Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", - QueryPath: "tags", +}, map[string][]requestflag.HasOuterFlag{ + "timeout-opts": { + &requestflag.InnerFlag[int64]{ + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag.`, + InnerField: "behavior", }, }, - Action: handleWebExtractFonts, - HideHelpCommand: true, -} +}) -var webExtractStyleguide = cli.Command{ +var webExtractStyleguide = requestflag.WithInnerFlags(cli.Command{ Name: "extract-styleguide", - Usage: "Extract a comprehensive design system from a website including colors,\ntypography, spacing, shadows, and UI components.", + Usage: "Extract colors, typography, spacing, and component styles from a website.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -211,7 +136,7 @@ var webExtractStyleguide = cli.Command{ }, &requestflag.Flag[string]{ Name: "direct-url", - Usage: "A specific URL to fetch the styleguide from directly, bypassing domain resolution (e.g., 'https://example.com/design-system'). When provided, the styleguide is extracted from this exact URL. You must provide either 'domain' or 'directUrl', but not both.", + Usage: "Exact URL to inspect. Provide either `domain` or `directUrl`, not both.", QueryPath: "directUrl", }, &requestflag.Flag[string]{ @@ -221,24 +146,47 @@ var webExtractStyleguide = cli.Command{ }, &requestflag.Flag[*int64]{ Name: "max-age-ms", - Usage: "Maximum age in milliseconds for cached brand data before the API performs a hard refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms) are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1 year.", + Usage: "Maximum age of cached brand data in ms. Defaults to 3 months; clamped to 0–1 year. `0` refreshes.", Default: requestflag.Ptr[int64](7776000000), QueryPath: "maxAgeMs", }, + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Comma-separated access policy IDs to apply. A URL must pass every policy.", + QueryPath: "policies", + }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", + Usage: "Comma-separated labels for filtering usage, e.g. `production,team-alpha`.", QueryPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + QueryPath: "timeoutOpts", + }, + &requestflag.Flag[string]{ + Name: "zdr", + Usage: "`enabled` disables request logs and traces and omits request and response content from usage logs. Brand data and hosted assets may still be stored. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", + QueryPath: "zdr", }, }, Action: handleWebExtractStyleguide, HideHelpCommand: true, -} +}, map[string][]requestflag.HasOuterFlag{ + "timeout-opts": { + &requestflag.InnerFlag[int64]{ + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", + }, + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag. "return-partial" requires at least 5000 ms.`, + InnerField: "behavior", + }, + }, +}) var webScreenshot = requestflag.WithInnerFlags(cli.Command{ Name: "screenshot", @@ -258,7 +206,7 @@ var webScreenshot = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[string]{ Name: "country", - Usage: "Fetch the target page through a residential proxy in this country (ISO 3166-1 alpha-2).", + Usage: "Fetch from this country (ISO 3166-1 alpha-2).", QueryPath: "country", }, &requestflag.Flag[string]{ @@ -282,6 +230,11 @@ var webScreenshot = requestflag.WithInnerFlags(cli.Command{ Default: false, QueryPath: "handleCookiePopup", }, + &requestflag.Flag[map[string]any]{ + Name: "headers", + Usage: "Optional outbound HTTP headers, using the same JSON object or deep-object query format as other scrape endpoints (for example headers[Authorization]=Bearer token). Headers are scoped to the target origin during capture. For domain/page requests, discovery receives no custom headers and only pages on the resolved origin are eligible. Non-empty headers bypass screenshot caching and return an in-memory data URL; no screenshot is uploaded. Empty objects behave like omitted headers.", + QueryPath: "headers", + }, &requestflag.Flag[*int64]{ Name: "max-age-ms", Usage: "Return a cached screenshot if a prior screenshot for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always capture fresh.", @@ -300,13 +253,13 @@ var webScreenshot = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", + Usage: "Comma-separated labels for filtering usage, e.g. `production,team-alpha`.", QueryPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + QueryPath: "timeoutOpts", }, &requestflag.Flag[map[string]any]{ Name: "viewport", @@ -316,13 +269,13 @@ var webScreenshot = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[*int64]{ Name: "wait-for-ms", - Usage: "Optional browser wait time in milliseconds after initial page load before taking the screenshot. Min: 0. Max: 30000 (30 seconds). Defaults to 3000 ms when omitted.", + Usage: "Optional browser wait time in milliseconds after initial page load before taking the screenshot. Min: 0. Max: 30000 (30 seconds). Defaults to 3000 ms when omitted. When combined with timeoutOpts, timeoutOpts.milliseconds must be at least waitForMs + 10000 ms; a shorter deadline is rejected with 400 TIMEOUT_TOO_SHORT_FOR_WAIT.", Default: requestflag.Ptr[int64](3000), QueryPath: "waitForMs", }, &requestflag.Flag[string]{ Name: "zdr", - Usage: "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 organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", Default: "disabled", QueryPath: "zdr", }, @@ -330,6 +283,18 @@ var webScreenshot = requestflag.WithInnerFlags(cli.Command{ Action: handleWebScreenshot, HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ + "timeout-opts": { + &requestflag.InnerFlag[int64]{ + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", + }, + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag. "return-partial" requires at least 5000 ms.`, + InnerField: "behavior", + }, + }, "viewport": { &requestflag.InnerFlag[int64]{ Name: "viewport.height", @@ -346,7 +311,7 @@ var webScreenshot = requestflag.WithInnerFlags(cli.Command{ var webSearch = requestflag.WithInnerFlags(cli.Command{ Name: "search", - Usage: "Search the web and optionally scrape each result to Markdown in one round-trip.", + Usage: "Search the web and optionally return page content or relevant passages with each\nresult.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -360,9 +325,15 @@ var webSearch = requestflag.WithInnerFlags(cli.Command{ Usage: "Two-letter ISO 3166-1 alpha-2 country code to localize results to a specific country (maps to Google's `gl` parameter). Example: \"us\", \"gb\", \"de\".", BodyPath: "country", }, + &requestflag.Flag[*int64]{ + Name: "description-max-characters", + Usage: "Maximum length of each result's `description`, in characters.", + Default: nil, + BodyPath: "descriptionMaxCharacters", + }, &requestflag.Flag[[]string]{ Name: "exclude-domain", - Usage: `Blocklist — drop results from these domains. Example: ["pinterest.com", "reddit.com"].`, + Usage: `Blocklist — drop results from these domains. Up to 100 domains. Example: ["pinterest.com", "reddit.com"].`, BodyPath: "excludeDomains", }, &requestflag.Flag[string]{ @@ -370,11 +341,22 @@ var webSearch = requestflag.WithInnerFlags(cli.Command{ Usage: "Restrict results to content published within this window.", BodyPath: "freshness", }, + &requestflag.Flag[map[string]any]{ + Name: "highlights-options", + Usage: "Passages from each result page that are relevant to the query. Pages are read with the `markdownOptions` settings.", + BodyPath: "highlightsOptions", + }, &requestflag.Flag[[]string]{ Name: "include-domain", - Usage: `Allowlist — only return results from these domains. Example: ["arxiv.org", "github.com"].`, + Usage: `Allowlist — only return results from these domains. Up to 100 domains. Example: ["arxiv.org", "github.com"].`, BodyPath: "includeDomains", }, + &requestflag.Flag[any]{ + Name: "languages", + Usage: "Languages to return results in, as BCP 47 language codes such as `en` or `de`, or \"all\" for any language. Defaults to \"all\". Example: [\"en\", \"de\"].", + Default: "all", + BodyPath: "languages", + }, &requestflag.Flag[map[string]any]{ Name: "markdown-options", Usage: "Inline Markdown scraping for each result. Set `enabled: true` to activate.", @@ -382,33 +364,56 @@ var webSearch = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[int64]{ Name: "num-results", - Usage: "Number of results to request and return (10–100). Defaults to 10.", + Usage: "Number of results to request and return (1–100). Defaults to 10.", Default: 10, BodyPath: "numResults", }, + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Access policy IDs to apply. A URL must pass every policy.", + BodyPath: "policies", + }, &requestflag.Flag[bool]{ Name: "query-fanout", - Usage: "Expand the query into multiple parallel variants for broader recall.", + Usage: "Currently has no effect.", BodyPath: "queryFanout", }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.", + Usage: "Labels for filtering usage in the dashboard.", BodyPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - BodyPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + BodyPath: "timeoutOpts", + }, + &requestflag.Flag[string]{ + Name: "zdr", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", + Default: "disabled", + BodyPath: "zdr", }, }, Action: handleWebSearch, HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ + "highlights-options": { + &requestflag.InnerFlag[bool]{ + Name: "highlights-options.enabled", + Usage: "Return relevant passages for each result. Adds 1 credit per 10 results.", + InnerField: "enabled", + }, + &requestflag.InnerFlag[int64]{ + Name: "highlights-options.max-characters", + Usage: "Maximum combined length of passages per result.", + InnerField: "maxCharacters", + }, + }, "markdown-options": { &requestflag.InnerFlag[bool]{ Name: "markdown-options.enabled", - Usage: "Scrape each result to Markdown. Off by default to keep search cheap and fast.", + Usage: "Scrape each result to Markdown. Adds 1 credit per result with Markdown.", InnerField: "enabled", }, &requestflag.InnerFlag[bool]{ @@ -426,14 +431,14 @@ var webSearch = requestflag.WithInnerFlags(cli.Command{ Usage: "Keep hyperlinks in the Markdown.", InnerField: "includeLinks", }, - &requestflag.InnerFlag[int64]{ + &requestflag.InnerFlag[*int64]{ Name: "markdown-options.max-age-ms", - Usage: "Cache TTL in ms for scraped Markdown keyed by URL + options. Default 1 day, max 30 days. Set to 0 to force a fresh scrape.", + Usage: "Maximum cache age in milliseconds for result page content. Defaults to 180 days (15552000000 ms) when Markdown is requested, or 365 days (31536000000 ms) when only highlights are requested. Explicit values override either default. Maximum: 365 days. Set to 0 to force a fresh scrape.", InnerField: "maxAgeMs", }, &requestflag.InnerFlag[map[string]any]{ Name: "markdown-options.pdf", - Usage: "PDF handling. Use start/end to bound text extraction and OCR to a page range.", + Usage: "PDF handling. `start`/`end` limit parsing to an inclusive, 1-based page range.", InnerField: "pdf", }, &requestflag.InnerFlag[bool]{ @@ -441,45 +446,62 @@ var webSearch = requestflag.WithInnerFlags(cli.Command{ Usage: "Truncate inline base64 image payloads to keep responses small.", InnerField: "shortenBase64Images", }, - &requestflag.InnerFlag[int64]{ - Name: "markdown-options.timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - InnerField: "timeoutMS", + &requestflag.InnerFlag[map[string]any]{ + Name: "markdown-options.timeout-opts", + Usage: "Request deadline and what to return when it passes.", + InnerField: "timeoutOpts", }, &requestflag.InnerFlag[bool]{ Name: "markdown-options.use-main-content-only", Usage: "Strip nav, header, footer, and sidebar — keep only the primary article content.", InnerField: "useMainContentOnly", }, - &requestflag.InnerFlag[int64]{ + &requestflag.InnerFlag[*int64]{ Name: "markdown-options.wait-for-ms", Usage: "Extra wait after page load before rendering, in ms (0–30000). Useful for JS-heavy pages.", InnerField: "waitForMs", }, }, + "timeout-opts": { + &requestflag.InnerFlag[int64]{ + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", + }, + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag.`, + InnerField: "behavior", + }, + }, }) var webWebCrawlMd = requestflag.WithInnerFlags(cli.Command{ Name: "web-crawl-md", - Usage: "Performs a crawl starting from a given URL, extracts page content as Markdown,\nand returns results for all crawled pages.", + Usage: "Crawl a website and return page content as Markdown. Use a batch for crawls\nbeyond 500 pages.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ Name: "url", - Usage: "The starting URL for the crawl (must include http:// or https:// protocol)", + Usage: "Start URL, including `http://` or `https://`.", Required: true, BodyPath: "url", }, &requestflag.Flag[string]{ Name: "country", - Usage: "Fetch the target page through a residential proxy in this country (ISO 3166-1 alpha-2).", + Usage: "Fetch from this country (ISO 3166-1 alpha-2).", BodyPath: "country", }, - &requestflag.Flag[[]string]{ + &requestflag.Flag[any]{ Name: "exclude-selector", - Usage: `CSS selectors to remove before each crawled page is converted to Markdown. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]".`, + Usage: "Remove matching elements after inclusions. Exclusions take precedence.", BodyPath: "excludeSelectors", }, + &requestflag.Flag[string]{ + Name: "exclude-url-regex", + Usage: "Regex pattern. URLs matching this pattern are never followed or scraped, even when they match urlRegex. The starting URL is always scraped.", + BodyPath: "excludeUrlRegex", + }, &requestflag.Flag[bool]{ Name: "follow-subdomains", Usage: "When true, follow links on subdomains of the starting URL's domain (e.g. docs.example.com when starting from example.com). www and apex are always treated as equivalent.", @@ -494,25 +516,25 @@ var webWebCrawlMd = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[bool]{ Name: "include-images", - Usage: "Include image references in the Markdown output", + Usage: "Include image references in the Markdown output (`html-conversion` only).", Default: false, BodyPath: "includeImages", }, &requestflag.Flag[bool]{ Name: "include-links", - Usage: "Preserve hyperlinks in the Markdown output", + Usage: "Preserve hyperlinks in the Markdown output (`html-conversion` only).", Default: true, BodyPath: "includeLinks", }, - &requestflag.Flag[[]string]{ + &requestflag.Flag[any]{ Name: "include-selector", - Usage: `CSS selectors. When provided, only matching HTML subtrees (and their descendants) are kept before each crawled page is converted to Markdown. When omitted, the entire document is kept. Examples: "article.main", "#content", "[role=main]".`, + Usage: "Keep matching HTML subtrees before converting each page to Markdown.", BodyPath: "includeSelectors", }, - &requestflag.Flag[int64]{ + &requestflag.Flag[*int64]{ Name: "max-age-ms", - Usage: "Return a cached result if a prior scrape for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.", - Default: 86400000, + Usage: "Maximum cache age in milliseconds. Defaults to 1 day; `0` fetches fresh.", + Default: requestflag.Ptr[int64](86400000), BodyPath: "maxAgeMs", }, &requestflag.Flag[int64]{ @@ -522,43 +544,54 @@ var webWebCrawlMd = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.Flag[int64]{ Name: "max-pages", - Usage: "Maximum number of pages to crawl. Hard cap: 500.", + Usage: "Maximum pages to crawl.", Default: 100, BodyPath: "maxPages", }, &requestflag.Flag[map[string]any]{ Name: "pdf", - Usage: "PDF parsing controls. Use start/end to limit text extraction and embedded-image detection/OCR to an inclusive 1-based page range.", + Usage: "PDF handling. `start`/`end` limit parsing to an inclusive, 1-based page range.", Default: map[string]any{"shouldParse": true, "ocr": false}, BodyPath: "pdf", }, + &requestflag.Flag[[]string]{ + Name: "policy", + Usage: "Access policy IDs to apply. A URL must pass every policy.", + BodyPath: "policies", + }, &requestflag.Flag[bool]{ Name: "settle-animations", - Usage: "When true, waits briefly for CSS and transition animations to settle before extracting each crawled page. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages.", + Usage: "Wait briefly for CSS animations and transitions to settle before reading each page.", Default: false, BodyPath: "settleAnimations", }, &requestflag.Flag[bool]{ Name: "shorten-base64-images", - Usage: "Truncate base64-encoded image data in the Markdown output", + Usage: "Truncate base64-encoded image data in the Markdown output (`html-conversion` only).", Default: true, BodyPath: "shortenBase64Images", }, + &requestflag.Flag[[]string]{ + Name: "source-preference", + Usage: "Markdown sources in order of preference: `html-conversion` converts the page HTML, `markdown-direct` uses Markdown the site publishes.", + Default: []string{"html-conversion", "markdown-direct"}, + BodyPath: "sourcePreference", + }, &requestflag.Flag[int64]{ Name: "stop-after-ms", - Usage: "Soft time budget for the crawl in milliseconds. After each scrape, the crawler checks the elapsed time and, if exceeded, returns the pages collected so far instead of continuing. Min: 10000 (10s). Max: 110000 (110s). Default: 80000 (80s).", + Usage: "Soft crawl deadline in milliseconds. Returns pages collected before the next deadline check.", Default: 80000, BodyPath: "stopAfterMs", }, &requestflag.Flag[[]string]{ Name: "tag", - Usage: "Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.", + Usage: "Labels for filtering usage in the dashboard.", BodyPath: "tags", }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - BodyPath: "timeoutMS", + &requestflag.Flag[map[string]any]{ + Name: "timeout-opts", + Usage: "Request deadline and what to return when it passes.", + BodyPath: "timeoutOpts", }, &requestflag.Flag[string]{ Name: "url-regex", @@ -571,15 +604,15 @@ var webWebCrawlMd = requestflag.WithInnerFlags(cli.Command{ Default: false, BodyPath: "useMainContentOnly", }, - &requestflag.Flag[int64]{ + &requestflag.Flag[*int64]{ Name: "wait-for-ms", Usage: "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).", - Default: 3500, + Default: requestflag.Ptr[int64](3500), BodyPath: "waitForMs", }, &requestflag.Flag[string]{ Name: "zdr", - Usage: "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 organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.", + Usage: "`enabled` turns on zero data retention. Returns 403 `ZDR_NOT_ENABLED` unless your organization has ZDR.", Default: "disabled", BodyPath: "zdr", }, @@ -590,12 +623,12 @@ var webWebCrawlMd = requestflag.WithInnerFlags(cli.Command{ "pdf": { &requestflag.InnerFlag[int64]{ Name: "pdf.end", - Usage: "Last 1-based PDF page to parse. When omitted, parsing ends at the last page. Must be greater than or equal to start when both are provided.", + Usage: "Last PDF page to parse (1-based, inclusive). Defaults to the final page. Must be >= start.", InnerField: "end", }, &requestflag.InnerFlag[bool]{ Name: "pdf.ocr", - Usage: "When true, OCR the selected PDF pages that have no usable text layer (scans), replacing each recovered page's text with the OCR result while pages with a real text layer keep it. Billed at 1 credit per page OCR actually recovered, on top of the base request cost.", + Usage: "Read scanned PDF pages with OCR; preserve pages that already have text.", InnerField: "ocr", }, &requestflag.InnerFlag[bool]{ @@ -605,406 +638,25 @@ var webWebCrawlMd = requestflag.WithInnerFlags(cli.Command{ }, &requestflag.InnerFlag[int64]{ Name: "pdf.start", - Usage: "First 1-based PDF page to parse. When omitted, parsing starts at the first page.", + Usage: "First 1-based PDF page to parse.", InnerField: "start", }, }, -}) - -var webWebScrapeHTML = requestflag.WithInnerFlags(cli.Command{ - Name: "web-scrape-html", - Usage: "Scrapes the given URL and returns the raw HTML content of the page. The base\nrequest costs 1 credit; requests with browser actions cost 2 credits.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "url", - Usage: "Full URL to scrape (must include http:// or https:// protocol)", - Required: true, - QueryPath: "url", - }, - &requestflag.Flag[any]{ - Name: "action", - Usage: "Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions.", - QueryPath: "actions", - }, - &requestflag.Flag[string]{ - Name: "country", - Usage: "Fetch the target page through a residential proxy in this country (ISO 3166-1 alpha-2).", - QueryPath: "country", - }, - &requestflag.Flag[any]{ - Name: "exclude-selector", - Usage: `CSS selectors to remove from the result. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]".`, - QueryPath: "excludeSelectors", - }, - &requestflag.Flag[map[string]any]{ - Name: "headers", - Usage: "Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.", - QueryPath: "headers", - }, - &requestflag.Flag[bool]{ - Name: "include-frames", - Usage: "When true, iframes are rendered inline into the returned HTML.", - Default: false, - QueryPath: "includeFrames", - }, - &requestflag.Flag[any]{ - Name: "include-selector", - Usage: `CSS selectors. When provided, only matching subtrees (and their descendants) are kept and everything else is dropped. When omitted, the entire document is kept. Examples: "article.main", "#content", "[role=main]".`, - QueryPath: "includeSelectors", - }, - &requestflag.Flag[*int64]{ - Name: "max-age-ms", - Usage: "Return a cached result if a prior scrape for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.", - Default: requestflag.Ptr[int64](86400000), - QueryPath: "maxAgeMs", - }, - &requestflag.Flag[map[string]any]{ - Name: "pdf", - Usage: "PDF parsing controls. Use start/end to limit text extraction and embedded-image detection/OCR to an inclusive 1-based page range.", - Default: map[string]any{"shouldParse": true, "ocr": false}, - QueryPath: "pdf", - }, - &requestflag.Flag[bool]{ - Name: "settle-animations", - Usage: "When true, waits briefly for CSS and transition animations to settle before extracting HTML. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages.", - Default: false, - QueryPath: "settleAnimations", - }, - &requestflag.Flag[[]string]{ - Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", - QueryPath: "tags", - }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", - }, - &requestflag.Flag[bool]{ - Name: "use-main-content-only", - Usage: "When true, return only the page's main content in the HTML response, excluding headers, footers, sidebars, and navigation when detectable.", - Default: false, - QueryPath: "useMainContentOnly", - }, - &requestflag.Flag[*int64]{ - Name: "wait-for-ms", - Usage: "Optional browser wait time in milliseconds after initial page load. Min: 0. Max: 30000 (30 seconds).", - QueryPath: "waitForMs", - }, - &requestflag.Flag[string]{ - Name: "zdr", - Usage: "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 organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.", - Default: "disabled", - QueryPath: "zdr", - }, - }, - Action: handleWebWebScrapeHTML, - HideHelpCommand: true, -}, map[string][]requestflag.HasOuterFlag{ - "pdf": { + "timeout-opts": { &requestflag.InnerFlag[int64]{ - Name: "pdf.end", - Usage: "Last 1-based PDF page to parse. When omitted, parsing ends at the last page. Must be greater than or equal to start when both are provided.", - InnerField: "end", - }, - &requestflag.InnerFlag[bool]{ - Name: "pdf.ocr", - Usage: "When true, OCR the selected PDF pages that have no usable text layer (scans), replacing each recovered page's text with the OCR result while pages with a real text layer keep it. Billed at 1 credit per page OCR actually recovered, on top of the base request cost. When false, no OCR runs.", - InnerField: "ocr", - }, - &requestflag.InnerFlag[bool]{ - Name: "pdf.should-parse", - Usage: "When true, PDF URLs are fetched and parsed. When false, PDF URLs are skipped and a 400 PDF_SKIPPED is returned.", - InnerField: "shouldParse", + Name: "timeout-opts.milliseconds", + Usage: "Deadline in milliseconds.", + InnerField: "milliseconds", }, - &requestflag.InnerFlag[int64]{ - Name: "pdf.start", - Usage: "First 1-based PDF page to parse. When omitted, parsing starts at the first page.", - InnerField: "start", + &requestflag.InnerFlag[string]{ + Name: "timeout-opts.behavior", + Usage: `"fail" returns 408 at the deadline. "return-partial" returns available results; inspect the response’s partial flag.`, + InnerField: "behavior", }, }, }) -var webWebScrapeImages = requestflag.WithInnerFlags(cli.Command{ - Name: "web-scrape-images", - Usage: "Extract image assets from a web page, including standard URLs, inline SVGs, data\nURIs, responsive image sources, metadata, CSS backgrounds, video posters, and\nembeds. The base request costs 1 credit, or 2 credits with browser actions. When\nenrichment is enabled, the entire call costs 5 credits, including requests that\nalso use actions.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "url", - Usage: "Page URL to inspect. Must include http:// or https://.", - Required: true, - QueryPath: "url", - }, - &requestflag.Flag[any]{ - Name: "action", - Usage: "Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions.", - QueryPath: "actions", - }, - &requestflag.Flag[bool]{ - Name: "dedupe", - Usage: "When true, visually duplicate images are removed: every image is loaded and perceptually hashed, and only the highest-resolution copy of each duplicate group is kept. Images that cannot be downloaded or hashed are kept. Default: false.", - Default: false, - QueryPath: "dedupe", - }, - &requestflag.Flag[map[string]any]{ - Name: "enrichment", - Usage: "Optional per-image processing, sent as deep-object query params such as enrichment[resolution]=true.", - QueryPath: "enrichment", - }, - &requestflag.Flag[map[string]any]{ - Name: "headers", - Usage: "Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.", - QueryPath: "headers", - }, - &requestflag.Flag[*int64]{ - Name: "max-age-ms", - Usage: "Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1 day). Set to 0 to bypass cache. Maximum: 2592000000 (30 days).", - Default: requestflag.Ptr[int64](86400000), - QueryPath: "maxAgeMs", - }, - &requestflag.Flag[[]string]{ - Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", - QueryPath: "tags", - }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", - }, - &requestflag.Flag[*int64]{ - Name: "wait-for-ms", - Usage: "Optional browser wait time in milliseconds after initial page load before collecting images. Min: 0. Max: 30000 (30 seconds).", - QueryPath: "waitForMs", - }, - }, - Action: handleWebWebScrapeImages, - HideHelpCommand: true, -}, map[string][]requestflag.HasOuterFlag{ - "enrichment": { - &requestflag.InnerFlag[bool]{ - Name: "enrichment.classification", - Usage: "Classify each image by visual asset type.", - InnerField: "classification", - }, - &requestflag.InnerFlag[bool]{ - Name: "enrichment.hosted-url", - Usage: "Host materializable images on the Brand.dev CDN and return their URL and MIME type.", - InnerField: "hostedUrl", - }, - &requestflag.InnerFlag[int64]{ - Name: "enrichment.max-time-per-ms", - Usage: "Per-image enrichment timeout in milliseconds. Default: 30000. Maximum: 60000.", - InnerField: "maxTimePerMs", - }, - &requestflag.InnerFlag[bool]{ - Name: "enrichment.resolution", - Usage: "Measure image width and height when possible.", - InnerField: "resolution", - }, - }, -}) - -var webWebScrapeMd = requestflag.WithInnerFlags(cli.Command{ - Name: "web-scrape-md", - Usage: "Scrapes the given URL into LLM usable Markdown. Inspect key_metadata on JSON\nresponses from a recognized API key; use error_code to distinguish stable\nfailure categories.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "url", - Usage: "Full URL to scrape into LLM usable Markdown (must include http:// or https:// protocol)", - Required: true, - QueryPath: "url", - }, - &requestflag.Flag[any]{ - Name: "action", - Usage: "Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions.", - QueryPath: "actions", - }, - &requestflag.Flag[string]{ - Name: "country", - Usage: "Fetch the target page through a residential proxy in this country (ISO 3166-1 alpha-2).", - QueryPath: "country", - }, - &requestflag.Flag[any]{ - Name: "exclude-selector", - Usage: `CSS selectors to remove before conversion to Markdown. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]".`, - QueryPath: "excludeSelectors", - }, - &requestflag.Flag[map[string]any]{ - Name: "headers", - Usage: "Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.", - QueryPath: "headers", - }, - &requestflag.Flag[bool]{ - Name: "include-frames", - Usage: "When true, the contents of iframes are rendered to Markdown.", - Default: false, - QueryPath: "includeFrames", - }, - &requestflag.Flag[bool]{ - Name: "include-html", - Usage: "When true, the response also includes an `html` field with the page HTML the Markdown was converted from — the same body the Scrape HTML endpoint returns for the equivalent request.", - Default: false, - QueryPath: "includeHTML", - }, - &requestflag.Flag[bool]{ - Name: "include-images", - Usage: "Include image references in Markdown output", - Default: false, - QueryPath: "includeImages", - }, - &requestflag.Flag[bool]{ - Name: "include-links", - Usage: "Preserve hyperlinks in Markdown output", - Default: true, - QueryPath: "includeLinks", - }, - &requestflag.Flag[any]{ - Name: "include-selector", - Usage: `CSS selectors. When provided, only matching HTML subtrees (and their descendants) are kept before conversion to Markdown. When omitted, the entire document is kept. Examples: "article.main", "#content", "[role=main]".`, - QueryPath: "includeSelectors", - }, - &requestflag.Flag[*int64]{ - Name: "max-age-ms", - Usage: "Return a cached result if a prior scrape for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.", - Default: requestflag.Ptr[int64](86400000), - QueryPath: "maxAgeMs", - }, - &requestflag.Flag[map[string]any]{ - Name: "pdf", - Usage: "PDF parsing controls. Use start/end to limit text extraction and embedded-image detection/OCR to an inclusive 1-based page range.", - Default: map[string]any{"shouldParse": true, "ocr": false}, - QueryPath: "pdf", - }, - &requestflag.Flag[bool]{ - Name: "settle-animations", - Usage: "When true, waits briefly for CSS and transition animations to settle before converting to Markdown. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages.", - Default: false, - QueryPath: "settleAnimations", - }, - &requestflag.Flag[bool]{ - Name: "shorten-base64-images", - Usage: "Shorten base64-encoded image data in the Markdown output", - Default: true, - QueryPath: "shortenBase64Images", - }, - &requestflag.Flag[[]string]{ - Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", - QueryPath: "tags", - }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", - }, - &requestflag.Flag[bool]{ - Name: "use-main-content-only", - Usage: "Extract only the main content of the page, excluding headers, footers, sidebars, and navigation", - Default: false, - QueryPath: "useMainContentOnly", - }, - &requestflag.Flag[*int64]{ - Name: "wait-for-ms", - Usage: "Optional browser wait time in milliseconds after initial page load before converting the page to Markdown. Min: 0. Max: 30000 (30 seconds).", - QueryPath: "waitForMs", - }, - &requestflag.Flag[string]{ - Name: "zdr", - Usage: "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 organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.", - Default: "disabled", - QueryPath: "zdr", - }, - }, - Action: handleWebWebScrapeMd, - HideHelpCommand: true, -}, map[string][]requestflag.HasOuterFlag{ - "pdf": { - &requestflag.InnerFlag[int64]{ - Name: "pdf.end", - Usage: "Last 1-based PDF page to parse. When omitted, parsing ends at the last page. Must be greater than or equal to start when both are provided.", - InnerField: "end", - }, - &requestflag.InnerFlag[bool]{ - Name: "pdf.ocr", - Usage: "When true, OCR the selected PDF pages that have no usable text layer (scans), replacing each recovered page's text with the OCR result while pages with a real text layer keep it. Billed at 1 credit per page OCR actually recovered, on top of the base request cost. When false, no OCR runs.", - InnerField: "ocr", - }, - &requestflag.InnerFlag[bool]{ - Name: "pdf.should-parse", - Usage: "When true, PDF URLs are fetched and parsed. When false, PDF URLs are skipped and a 400 PDF_SKIPPED is returned.", - InnerField: "shouldParse", - }, - &requestflag.InnerFlag[int64]{ - Name: "pdf.start", - Usage: "First 1-based PDF page to parse. When omitted, parsing starts at the first page.", - InnerField: "start", - }, - }, -}) - -var webWebScrapeSitemap = cli.Command{ - Name: "web-scrape-sitemap", - Usage: "Crawl an entire website's sitemap and return all discovered page URLs. Pass\n`search` to have the crawled sitemap filtered down to the pages about a phrase\n(for example `pricing and plans` or `api authentication docs`), most relevant\nfirst — a searched crawl scans the whole sitemap and costs 2 credits instead\nof 1.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "domain", - Usage: "Domain to build a sitemap for", - Required: true, - QueryPath: "domain", - }, - &requestflag.Flag[map[string]any]{ - Name: "headers", - Usage: "Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.", - QueryPath: "headers", - }, - &requestflag.Flag[int64]{ - Name: "max-links", - Usage: "Maximum number of links to return from the sitemap crawl. Defaults to 10,000. Minimum is 1, maximum is 100,000.", - Default: 10000, - QueryPath: "maxLinks", - }, - &requestflag.Flag[string]{ - Name: "search", - Usage: "Optional search phrase. When provided, the crawled sitemap is filtered to the pages whose URLs are about that phrase, most relevant first, and the request costs 2 credits instead of 1.", - QueryPath: "search", - }, - &requestflag.Flag[string]{ - Name: "sitemap-url", - Usage: "Optional explicit sitemap URL. When provided, exactly this sitemap is crawled instead of discovering the domain's sitemaps.", - QueryPath: "sitemapUrl", - }, - &requestflag.Flag[[]string]{ - Name: "tag", - Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.", - QueryPath: "tags", - }, - &requestflag.Flag[int64]{ - Name: "timeout-ms", - Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).", - QueryPath: "timeoutMS", - }, - &requestflag.Flag[string]{ - Name: "url-regex", - Usage: "Optional RE2-compatible regex pattern. Only URLs matching this pattern are returned and counted against maxLinks.", - QueryPath: "urlRegex", - }, - &requestflag.Flag[string]{ - Name: "zdr", - Usage: "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 organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.", - Default: "disabled", - QueryPath: "zdr", - }, - }, - Action: handleWebWebScrapeSitemap, - HideHelpCommand: true, -} - -func handleWebExtract(ctx context.Context, cmd *cli.Command) error { +func handleWebAnswers(ctx context.Context, cmd *cli.Command) error { client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) unusedArgs := cmd.Args().Slice() @@ -1023,11 +675,11 @@ func handleWebExtract(ctx context.Context, cmd *cli.Command) error { return err } - params := contextdev.WebExtractParams{} + params := contextdev.WebAnswersParams{} var res []byte options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.Web.Extract(ctx, params, options...) + _, err = client.Web.Answers(ctx, params, options...) if err != nil { return err } @@ -1040,7 +692,7 @@ func handleWebExtract(ctx context.Context, cmd *cli.Command) error { ExplicitFormat: explicitFormat, Format: format, RawOutput: cmd.Root().Bool("raw-output"), - Title: "web extract", + Title: "web answers", Transform: transform, }) } @@ -1086,47 +738,6 @@ func handleWebExtractCompetitors(ctx context.Context, cmd *cli.Command) error { }) } -func handleWebExtractFonts(ctx context.Context, cmd *cli.Command) error { - client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatComma, - EmptyBody, - false, - ) - if err != nil { - return err - } - - params := contextdev.WebExtractFontsParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.Web.ExtractFonts(ctx, params, options...) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "web extract-fonts", - Transform: transform, - }) -} - func handleWebExtractStyleguide(ctx context.Context, cmd *cli.Command) error { client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) unusedArgs := cmd.Args().Slice() @@ -1290,167 +901,3 @@ func handleWebWebCrawlMd(ctx context.Context, cmd *cli.Command) error { Transform: transform, }) } - -func handleWebWebScrapeHTML(ctx context.Context, cmd *cli.Command) error { - client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatComma, - EmptyBody, - false, - ) - if err != nil { - return err - } - - params := contextdev.WebWebScrapeHTMLParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.Web.WebScrapeHTML(ctx, params, options...) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "web web-scrape-html", - Transform: transform, - }) -} - -func handleWebWebScrapeImages(ctx context.Context, cmd *cli.Command) error { - client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatComma, - EmptyBody, - false, - ) - if err != nil { - return err - } - - params := contextdev.WebWebScrapeImagesParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.Web.WebScrapeImages(ctx, params, options...) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "web web-scrape-images", - Transform: transform, - }) -} - -func handleWebWebScrapeMd(ctx context.Context, cmd *cli.Command) error { - client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatComma, - EmptyBody, - false, - ) - if err != nil { - return err - } - - params := contextdev.WebWebScrapeMdParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.Web.WebScrapeMd(ctx, params, options...) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "web web-scrape-md", - Transform: transform, - }) -} - -func handleWebWebScrapeSitemap(ctx context.Context, cmd *cli.Command) error { - client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatComma, - EmptyBody, - false, - ) - if err != nil { - return err - } - - params := contextdev.WebWebScrapeSitemapParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.Web.WebScrapeSitemap(ctx, params, options...) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "web web-scrape-sitemap", - Transform: transform, - }) -} diff --git a/pkg/cmd/web_test.go b/pkg/cmd/web_test.go index acbcf47..ebe1e72 100644 --- a/pkg/cmd/web_test.go +++ b/pkg/cmd/web_test.go @@ -9,98 +9,66 @@ import ( "github.com/context-dot-dev/context-dev-cli/internal/requestflag" ) -func TestWebExtract(t *testing.T) { +func TestWebAnswers(t *testing.T) { t.Skip("Mock server tests are disabled") t.Run("regular flags", func(t *testing.T) { mocktest.TestRunMockTestWithFlags( t, "--api-key", "string", - "web", "extract", - "--schema", "{type: bar, properties: bar, required: bar, additionalProperties: bar}", - "--url", "https://example.com", - "--action", "{do: wait, timeMs: 0}", - "--fact-check=true", - "--follow-subdomains=true", - "--include-frames=true", - "--instructions", "instructions", - "--max-age-ms", "0", - "--max-depth", "0", - "--max-pages", "1", - "--pdf", "{end: 1, shouldParse: true, start: 1}", - "--settle-animations=true", - "--stop-after-ms", "10000", + "web", "answers", + "--task", "Find the pricing page URL and plan names for context.dev.", + "--json-format", "{pricing_page_url: bar, plans: bar}", + "--mode", "fast", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", - "--wait-for-ms", "0", + "--timeout-opts", "{milliseconds: 1000, behavior: fail}", + "--zdr", "enabled", ) }) t.Run("inner flags", func(t *testing.T) { // Check that inner flags have been set up correctly - requestflag.CheckInnerFlags(webExtract) + requestflag.CheckInnerFlags(webAnswers) // Alternative argument passing style using inner flags mocktest.TestRunMockTestWithFlags( t, "--api-key", "string", - "web", "extract", - "--schema", "{type: bar, properties: bar, required: bar, additionalProperties: bar}", - "--url", "https://example.com", - "--action", "{do: wait, timeMs: 0}", - "--fact-check=true", - "--follow-subdomains=true", - "--include-frames=true", - "--instructions", "instructions", - "--max-age-ms", "0", - "--max-depth", "0", - "--max-pages", "1", - "--pdf.end", "1", - "--pdf.should-parse=true", - "--pdf.start", "1", - "--settle-animations=true", - "--stop-after-ms", "10000", + "web", "answers", + "--task", "Find the pricing page URL and plan names for context.dev.", + "--json-format", "{pricing_page_url: bar, plans: bar}", + "--mode", "fast", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", - "--wait-for-ms", "0", + "--timeout-opts.milliseconds", "1000", + "--timeout-opts.behavior", "fail", + "--zdr", "enabled", ) }) t.Run("piping data", func(t *testing.T) { // Test piping YAML data over stdin pipeData := []byte("" + - "schema:\n" + - " type: bar\n" + - " properties: bar\n" + - " required: bar\n" + - " additionalProperties: bar\n" + - "url: https://example.com\n" + - "actions:\n" + - " - do: wait\n" + - " timeMs: 0\n" + - "factCheck: true\n" + - "followSubdomains: true\n" + - "includeFrames: true\n" + - "instructions: instructions\n" + - "maxAgeMs: 0\n" + - "maxDepth: 0\n" + - "maxPages: 1\n" + - "pdf:\n" + - " end: 1\n" + - " shouldParse: true\n" + - " start: 1\n" + - "settleAnimations: true\n" + - "stopAfterMs: 10000\n" + + "task: Find the pricing page URL and plan names for context.dev.\n" + + "json_format:\n" + + " pricing_page_url: bar\n" + + " plans: bar\n" + + "mode: fast\n" + + "policies:\n" + + " - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" + "tags:\n" + " - production\n" + " - team-alpha\n" + - "timeoutMS: 1000\n" + - "waitForMs: 0\n") + "timeoutOpts:\n" + + " milliseconds: 1000\n" + + " behavior: fail\n" + + "zdr: enabled\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", - "web", "extract", + "web", "answers", ) }) } @@ -116,31 +84,55 @@ func TestWebExtractCompetitors(t *testing.T) { "--num-competitors", "1", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts", "{milliseconds: 1000, behavior: fail}", + "--zdr", "enabled", + ) + }) + + t.Run("inner flags", func(t *testing.T) { + // Check that inner flags have been set up correctly + requestflag.CheckInnerFlags(webExtractCompetitors) + + // Alternative argument passing style using inner flags + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "web", "extract-competitors", + "--domain", "xxx", + "--num-competitors", "1", + "--tag", "production", + "--tag", "team-alpha", + "--timeout-opts.milliseconds", "1000", + "--timeout-opts.behavior", "fail", + "--zdr", "enabled", ) }) } -func TestWebExtractFonts(t *testing.T) { +func TestWebExtractStyleguide(t *testing.T) { t.Skip("Mock server tests are disabled") t.Run("regular flags", func(t *testing.T) { mocktest.TestRunMockTestWithFlags( t, "--api-key", "string", - "web", "extract-fonts", + "web", "extract-styleguide", + "--color-scheme", "light", "--direct-url", "https://example.com", "--domain", "xxx", "--max-age-ms", "0", + "--policy", "string", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts", "{milliseconds: 1, behavior: fail}", + "--zdr", "enabled", ) }) -} -func TestWebExtractStyleguide(t *testing.T) { - t.Skip("Mock server tests are disabled") - t.Run("regular flags", func(t *testing.T) { + t.Run("inner flags", func(t *testing.T) { + // Check that inner flags have been set up correctly + requestflag.CheckInnerFlags(webExtractStyleguide) + + // Alternative argument passing style using inner flags mocktest.TestRunMockTestWithFlags( t, "--api-key", "string", @@ -149,9 +141,12 @@ func TestWebExtractStyleguide(t *testing.T) { "--direct-url", "https://example.com", "--domain", "xxx", "--max-age-ms", "0", + "--policy", "string", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts.milliseconds", "1", + "--timeout-opts.behavior", "fail", + "--zdr", "enabled", ) }) } @@ -170,12 +165,13 @@ func TestWebScreenshot(t *testing.T) { "--domain", "xxx", "--full-screenshot", "true", "--handle-cookie-popup=true", + "--headers", "{foo: J!}", "--max-age-ms", "0", "--page", "login", "--scroll-offset", "0", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1", + "--timeout-opts", "{milliseconds: 1, behavior: fail}", "--viewport", "{height: 240, width: 240}", "--wait-for-ms", "0", "--zdr", "enabled", @@ -198,12 +194,14 @@ func TestWebScreenshot(t *testing.T) { "--domain", "xxx", "--full-screenshot", "true", "--handle-cookie-popup=true", + "--headers", "{foo: J!}", "--max-age-ms", "0", "--page", "login", "--scroll-offset", "0", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1", + "--timeout-opts.milliseconds", "1", + "--timeout-opts.behavior", "fail", "--viewport.height", "240", "--viewport.width", "240", "--wait-for-ms", "0", @@ -219,17 +217,22 @@ func TestWebSearch(t *testing.T) { t, "--api-key", "string", "web", "search", - "--query", "x", + "--query", "Stripe API authentication", "--country", "af", - "--exclude-domain", "string", + "--description-max-characters", "0", + "--exclude-domain", "xxx", "--freshness", "last_24_hours", - "--include-domain", "string", - "--markdown-options", "{enabled: true, includeFrames: true, includeImages: true, includeLinks: true, maxAgeMs: 0, pdf: {end: 1, shouldParse: true, start: 1}, shortenBase64Images: true, timeoutMS: 1000, useMainContentOnly: true, waitForMs: 0}", + "--highlights-options", "{enabled: true, maxCharacters: 100}", + "--include-domain", "xxx", + "--languages", "all", + "--markdown-options", "{enabled: true, includeFrames: true, includeImages: true, includeLinks: true, maxAgeMs: 0, pdf: {end: 1, shouldParse: true, start: 1}, shortenBase64Images: true, timeoutOpts: {milliseconds: 1, behavior: fail}, useMainContentOnly: true, waitForMs: 0}", "--num-results", "10", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--query-fanout=true", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts", "{milliseconds: 1000, behavior: fail}", + "--zdr", "enabled", ) }) @@ -242,11 +245,15 @@ func TestWebSearch(t *testing.T) { t, "--api-key", "string", "web", "search", - "--query", "x", + "--query", "Stripe API authentication", "--country", "af", - "--exclude-domain", "string", + "--description-max-characters", "0", + "--exclude-domain", "xxx", "--freshness", "last_24_hours", - "--include-domain", "string", + "--highlights-options.enabled=true", + "--highlights-options.max-characters", "100", + "--include-domain", "xxx", + "--languages", "all", "--markdown-options.enabled=true", "--markdown-options.include-frames=true", "--markdown-options.include-images=true", @@ -254,27 +261,35 @@ func TestWebSearch(t *testing.T) { "--markdown-options.max-age-ms", "0", "--markdown-options.pdf", "{end: 1, shouldParse: true, start: 1}", "--markdown-options.shorten-base64-images=true", - "--markdown-options.timeout-ms", "1000", + "--markdown-options.timeout-opts", "{milliseconds: 1, behavior: fail}", "--markdown-options.use-main-content-only=true", "--markdown-options.wait-for-ms", "0", "--num-results", "10", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--query-fanout=true", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts.milliseconds", "1000", + "--timeout-opts.behavior", "fail", + "--zdr", "enabled", ) }) t.Run("piping data", func(t *testing.T) { // Test piping YAML data over stdin pipeData := []byte("" + - "query: x\n" + + "query: Stripe API authentication\n" + "country: af\n" + + "descriptionMaxCharacters: 0\n" + "excludeDomains:\n" + - " - string\n" + + " - xxx\n" + "freshness: last_24_hours\n" + + "highlightsOptions:\n" + + " enabled: true\n" + + " maxCharacters: 100\n" + "includeDomains:\n" + - " - string\n" + + " - xxx\n" + + "languages: all\n" + "markdownOptions:\n" + " enabled: true\n" + " includeFrames: true\n" + @@ -286,15 +301,22 @@ func TestWebSearch(t *testing.T) { " shouldParse: true\n" + " start: 1\n" + " shortenBase64Images: true\n" + - " timeoutMS: 1000\n" + + " timeoutOpts:\n" + + " milliseconds: 1\n" + + " behavior: fail\n" + " useMainContentOnly: true\n" + " waitForMs: 0\n" + "numResults: 10\n" + + "policies:\n" + + " - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" + "queryFanout: true\n" + "tags:\n" + " - production\n" + " - team-alpha\n" + - "timeoutMS: 1000\n") + "timeoutOpts:\n" + + " milliseconds: 1000\n" + + " behavior: fail\n" + + "zdr: enabled\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", @@ -312,22 +334,25 @@ func TestWebWebCrawlMd(t *testing.T) { "web", "web-crawl-md", "--url", "https://example.com", "--country", "de", - "--exclude-selector", "string", + "--exclude-selector", "[x]", + "--exclude-url-regex", "/tag/|/author/", "--follow-subdomains=true", "--include-frames=true", "--include-images=true", "--include-links=true", - "--include-selector", "string", + "--include-selector", "[x]", "--max-age-ms", "0", "--max-depth", "0", - "--max-pages", "1", + "--max-pages", "10", "--pdf", "{end: 1, ocr: true, shouldParse: true, start: 1}", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--settle-animations=true", "--shorten-base64-images=true", + "--source-preference", "html-conversion", "--stop-after-ms", "10000", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts", "{milliseconds: 1000, behavior: fail}", "--url-regex", "^https?://[^/]+/blog/", "--use-main-content-only=true", "--wait-for-ms", "0", @@ -346,25 +371,29 @@ func TestWebWebCrawlMd(t *testing.T) { "web", "web-crawl-md", "--url", "https://example.com", "--country", "de", - "--exclude-selector", "string", + "--exclude-selector", "[x]", + "--exclude-url-regex", "/tag/|/author/", "--follow-subdomains=true", "--include-frames=true", "--include-images=true", "--include-links=true", - "--include-selector", "string", + "--include-selector", "[x]", "--max-age-ms", "0", "--max-depth", "0", - "--max-pages", "1", + "--max-pages", "10", "--pdf.end", "1", "--pdf.ocr=true", "--pdf.should-parse=true", "--pdf.start", "1", + "--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e", "--settle-animations=true", "--shorten-base64-images=true", + "--source-preference", "html-conversion", "--stop-after-ms", "10000", "--tag", "production", "--tag", "team-alpha", - "--timeout-ms", "1000", + "--timeout-opts.milliseconds", "1000", + "--timeout-opts.behavior", "fail", "--url-regex", "^https?://[^/]+/blog/", "--use-main-content-only=true", "--wait-for-ms", "0", @@ -378,28 +407,35 @@ func TestWebWebCrawlMd(t *testing.T) { "url: https://example.com\n" + "country: de\n" + "excludeSelectors:\n" + - " - string\n" + + " - x\n" + + "excludeUrlRegex: /tag/|/author/\n" + "followSubdomains: true\n" + "includeFrames: true\n" + "includeImages: true\n" + "includeLinks: true\n" + "includeSelectors:\n" + - " - string\n" + + " - x\n" + "maxAgeMs: 0\n" + "maxDepth: 0\n" + - "maxPages: 1\n" + + "maxPages: 10\n" + "pdf:\n" + " end: 1\n" + " ocr: true\n" + " shouldParse: true\n" + " start: 1\n" + + "policies:\n" + + " - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" + "settleAnimations: true\n" + "shortenBase64Images: true\n" + + "sourcePreference:\n" + + " - html-conversion\n" + "stopAfterMs: 10000\n" + "tags:\n" + " - production\n" + " - team-alpha\n" + - "timeoutMS: 1000\n" + + "timeoutOpts:\n" + + " milliseconds: 1000\n" + + " behavior: fail\n" + "urlRegex: ^https?://[^/]+/blog/\n" + "useMainContentOnly: true\n" + "waitForMs: 0\n" + @@ -411,194 +447,3 @@ func TestWebWebCrawlMd(t *testing.T) { ) }) } - -func TestWebWebScrapeHTML(t *testing.T) { - t.Skip("Mock server tests are disabled") - t.Run("regular flags", func(t *testing.T) { - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "web", "web-scrape-html", - "--url", "https://example.com", - "--action", "[{do: wait, timeMs: 0}]", - "--country", "de", - "--exclude-selector", "[x]", - "--headers", "{foo: J!}", - "--include-frames=true", - "--include-selector", "[x]", - "--max-age-ms", "0", - "--pdf", "{end: 1, ocr: true, shouldParse: true, start: 1}", - "--settle-animations=true", - "--tag", "production", - "--tag", "team-alpha", - "--timeout-ms", "1", - "--use-main-content-only=true", - "--wait-for-ms", "0", - "--zdr", "enabled", - ) - }) - - t.Run("inner flags", func(t *testing.T) { - // Check that inner flags have been set up correctly - requestflag.CheckInnerFlags(webWebScrapeHTML) - - // Alternative argument passing style using inner flags - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "web", "web-scrape-html", - "--url", "https://example.com", - "--action", "[{do: wait, timeMs: 0}]", - "--country", "de", - "--exclude-selector", "[x]", - "--headers", "{foo: J!}", - "--include-frames=true", - "--include-selector", "[x]", - "--max-age-ms", "0", - "--pdf.end", "1", - "--pdf.ocr=true", - "--pdf.should-parse=true", - "--pdf.start", "1", - "--settle-animations=true", - "--tag", "production", - "--tag", "team-alpha", - "--timeout-ms", "1", - "--use-main-content-only=true", - "--wait-for-ms", "0", - "--zdr", "enabled", - ) - }) -} - -func TestWebWebScrapeImages(t *testing.T) { - t.Skip("Mock server tests are disabled") - t.Run("regular flags", func(t *testing.T) { - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "web", "web-scrape-images", - "--url", "https://example.com", - "--action", "[{do: wait, timeMs: 0}]", - "--dedupe=true", - "--enrichment", "{classification: true, hostedUrl: true, maxTimePerMs: 1, resolution: true}", - "--headers", "{foo: J!}", - "--max-age-ms", "0", - "--tag", "production", - "--tag", "team-alpha", - "--timeout-ms", "1", - "--wait-for-ms", "0", - ) - }) - - t.Run("inner flags", func(t *testing.T) { - // Check that inner flags have been set up correctly - requestflag.CheckInnerFlags(webWebScrapeImages) - - // Alternative argument passing style using inner flags - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "web", "web-scrape-images", - "--url", "https://example.com", - "--action", "[{do: wait, timeMs: 0}]", - "--dedupe=true", - "--enrichment.classification=true", - "--enrichment.hosted-url=true", - "--enrichment.max-time-per-ms", "1", - "--enrichment.resolution=true", - "--headers", "{foo: J!}", - "--max-age-ms", "0", - "--tag", "production", - "--tag", "team-alpha", - "--timeout-ms", "1", - "--wait-for-ms", "0", - ) - }) -} - -func TestWebWebScrapeMd(t *testing.T) { - t.Skip("Mock server tests are disabled") - t.Run("regular flags", func(t *testing.T) { - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "web", "web-scrape-md", - "--url", "https://example.com", - "--action", "[{do: wait, timeMs: 0}]", - "--country", "de", - "--exclude-selector", "[x]", - "--headers", "{foo: J!}", - "--include-frames=true", - "--include-html=true", - "--include-images=true", - "--include-links=true", - "--include-selector", "[x]", - "--max-age-ms", "0", - "--pdf", "{end: 1, ocr: true, shouldParse: true, start: 1}", - "--settle-animations=true", - "--shorten-base64-images=true", - "--tag", "production", - "--tag", "team-alpha", - "--timeout-ms", "1", - "--use-main-content-only=true", - "--wait-for-ms", "0", - "--zdr", "enabled", - ) - }) - - t.Run("inner flags", func(t *testing.T) { - // Check that inner flags have been set up correctly - requestflag.CheckInnerFlags(webWebScrapeMd) - - // Alternative argument passing style using inner flags - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "web", "web-scrape-md", - "--url", "https://example.com", - "--action", "[{do: wait, timeMs: 0}]", - "--country", "de", - "--exclude-selector", "[x]", - "--headers", "{foo: J!}", - "--include-frames=true", - "--include-html=true", - "--include-images=true", - "--include-links=true", - "--include-selector", "[x]", - "--max-age-ms", "0", - "--pdf.end", "1", - "--pdf.ocr=true", - "--pdf.should-parse=true", - "--pdf.start", "1", - "--settle-animations=true", - "--shorten-base64-images=true", - "--tag", "production", - "--tag", "team-alpha", - "--timeout-ms", "1", - "--use-main-content-only=true", - "--wait-for-ms", "0", - "--zdr", "enabled", - ) - }) -} - -func TestWebWebScrapeSitemap(t *testing.T) { - t.Skip("Mock server tests are disabled") - t.Run("regular flags", func(t *testing.T) { - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "web", "web-scrape-sitemap", - "--domain", "xxx", - "--headers", "{foo: J!}", - "--max-links", "1", - "--search", "help center and troubleshooting articles", - "--sitemap-url", "https://example.com", - "--tag", "production", - "--tag", "team-alpha", - "--timeout-ms", "1", - "--url-regex", "^https?://[^/]+/blog/", - "--zdr", "enabled", - ) - }) -} diff --git a/pkg/cmd/webhookdelivery.go b/pkg/cmd/webhookdelivery.go new file mode 100644 index 0000000..597c9f5 --- /dev/null +++ b/pkg/cmd/webhookdelivery.go @@ -0,0 +1,345 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package cmd + +import ( + "context" + "fmt" + + "github.com/context-dot-dev/context-dev-cli/internal/apiquery" + "github.com/context-dot-dev/context-dev-cli/internal/requestflag" + "github.com/context-dot-dev/context-go-sdk/v2" + "github.com/context-dot-dev/context-go-sdk/v2/option" + "github.com/tidwall/gjson" + "github.com/urfave/cli/v3" +) + +var webhooksDeliveriesRetrieve = cli.Command{ + Name: "retrieve", + Usage: "Retrieve a webhook delivery’s status and original payload.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "delivery-id", + Usage: "Delivery ID.", + Required: true, + PathParam: "delivery_id", + }, + &requestflag.Flag[[]string]{ + Name: "tag", + Usage: "Comma-separated labels for filtering usage, e.g. `production,team-alpha`.", + QueryPath: "tags", + }, + }, + Action: handleWebhooksDeliveriesRetrieve, + HideHelpCommand: true, +} + +var webhooksDeliveriesList = cli.Command{ + Name: "list", + Usage: "List batch and monitor webhook deliveries from the last 30 days.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "type", + Usage: "Delivery source.", + Required: true, + BodyPath: "type", + }, + &requestflag.Flag[string]{ + Name: "batch-id", + Usage: "Filter by batch ID.", + BodyPath: "batch_id", + }, + &requestflag.Flag[any]{ + Name: "created-after", + Usage: "Only include events created after this ISO 8601 timestamp.", + BodyPath: "created_after", + }, + &requestflag.Flag[string]{ + Name: "cursor", + Usage: "The next_cursor from the previous response.", + BodyPath: "cursor", + }, + &requestflag.Flag[int64]{ + Name: "limit", + Usage: "Number of deliveries to return.", + Default: 25, + BodyPath: "limit", + }, + &requestflag.Flag[string]{ + Name: "status", + Usage: "Filter by delivery status.", + BodyPath: "status", + }, + &requestflag.Flag[[]string]{ + Name: "tag", + Usage: "Labels for filtering usage in the dashboard.", + BodyPath: "tags", + }, + &requestflag.Flag[string]{ + Name: "monitor-id", + Usage: "Filter by monitor ID.", + BodyPath: "monitor_id", + }, + &requestflag.Flag[string]{ + Name: "run-id", + Usage: "Filter by monitor run ID.", + BodyPath: "run_id", + }, + }, + Action: handleWebhooksDeliveriesList, + HideHelpCommand: true, +} + +var webhooksDeliveriesListAttempts = cli.Command{ + Name: "list-attempts", + Usage: "List a delivery’s attempts, newest first.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "delivery-id", + Usage: "Delivery ID.", + Required: true, + PathParam: "delivery_id", + }, + &requestflag.Flag[string]{ + Name: "cursor", + Usage: "The next_cursor from the previous response.", + QueryPath: "cursor", + }, + &requestflag.Flag[int64]{ + Name: "limit", + Usage: "Number of attempts to return.", + Default: 25, + QueryPath: "limit", + }, + &requestflag.Flag[[]string]{ + Name: "tag", + Usage: "Comma-separated labels for filtering usage, e.g. `production,team-alpha`.", + QueryPath: "tags", + }, + }, + Action: handleWebhooksDeliveriesListAttempts, + HideHelpCommand: true, +} + +var webhooksDeliveriesRetry = cli.Command{ + Name: "retry", + Usage: "Resend the original payload using the source’s current URL and secret. Available\nfor 7 days after the event.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "delivery-id", + Usage: "Delivery ID.", + Required: true, + PathParam: "delivery_id", + }, + &requestflag.Flag[bool]{ + Name: "force", + Usage: "Resend even if the delivery already succeeded. Defaults to false.", + Default: false, + BodyPath: "force", + }, + &requestflag.Flag[[]string]{ + Name: "tag", + Usage: "Labels for filtering usage in the dashboard.", + BodyPath: "tags", + }, + &requestflag.Flag[string]{ + Name: "idempotency-key", + Usage: "Unique key to prevent duplicate retry requests.", + HeaderPath: "Idempotency-Key", + }, + }, + Action: handleWebhooksDeliveriesRetry, + HideHelpCommand: true, +} + +func handleWebhooksDeliveriesRetrieve(ctx context.Context, cmd *cli.Command) error { + client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + if !cmd.IsSet("delivery-id") && len(unusedArgs) > 0 { + cmd.Set("delivery-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatComma, + EmptyBody, + false, + ) + if err != nil { + return err + } + + params := contextdev.WebhookDeliveryGetParams{} + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.Webhooks.Deliveries.Get( + ctx, + cmd.Value("delivery-id").(string), + params, + options..., + ) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "webhooks:deliveries retrieve", + Transform: transform, + }) +} + +func handleWebhooksDeliveriesList(ctx context.Context, cmd *cli.Command) error { + client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatComma, + ApplicationJSON, + false, + ) + if err != nil { + return err + } + + params := contextdev.WebhookDeliveryListParams{} + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.Webhooks.Deliveries.List(ctx, params, options...) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "webhooks:deliveries list", + Transform: transform, + }) +} + +func handleWebhooksDeliveriesListAttempts(ctx context.Context, cmd *cli.Command) error { + client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + if !cmd.IsSet("delivery-id") && len(unusedArgs) > 0 { + cmd.Set("delivery-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatComma, + EmptyBody, + false, + ) + if err != nil { + return err + } + + params := contextdev.WebhookDeliveryListAttemptsParams{} + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.Webhooks.Deliveries.ListAttempts( + ctx, + cmd.Value("delivery-id").(string), + params, + options..., + ) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "webhooks:deliveries list-attempts", + Transform: transform, + }) +} + +func handleWebhooksDeliveriesRetry(ctx context.Context, cmd *cli.Command) error { + client := contextdev.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + if !cmd.IsSet("delivery-id") && len(unusedArgs) > 0 { + cmd.Set("delivery-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatComma, + ApplicationJSON, + false, + ) + if err != nil { + return err + } + + params := contextdev.WebhookDeliveryRetryParams{} + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.Webhooks.Deliveries.Retry( + ctx, + cmd.Value("delivery-id").(string), + params, + options..., + ) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "webhooks:deliveries retry", + Transform: transform, + }) +} diff --git a/pkg/cmd/webhookdelivery_test.go b/pkg/cmd/webhookdelivery_test.go new file mode 100644 index 0000000..7c6e670 --- /dev/null +++ b/pkg/cmd/webhookdelivery_test.go @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package cmd + +import ( + "testing" + + "github.com/context-dot-dev/context-dev-cli/internal/mocktest" +) + +func TestWebhooksDeliveriesRetrieve(t *testing.T) { + t.Skip("Mock server tests are disabled") + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "webhooks:deliveries", "retrieve", + "--delivery-id", "whd_210b9798eb53baa4e69d31c1071cf03d", + "--tag", "production", + "--tag", "team-alpha", + ) + }) +} + +func TestWebhooksDeliveriesList(t *testing.T) { + t.Skip("Mock server tests are disabled") + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "webhooks:deliveries", "list", + "--type", "batch", + "--batch-id", "batch_id", + "--created-after", "'2026-09-01T00:00:00Z'", + "--cursor", "whd_210b9798eb53baa4e69d31c1071cf03d", + "--limit", "1", + "--status", "pending", + "--tag", "production", + "--tag", "team-alpha", + ) + }) + + t.Run("piping data", func(t *testing.T) { + // Test piping YAML data over stdin + pipeData := []byte("" + + "type: batch\n" + + "batch_id: batch_id\n" + + "created_after: '2026-09-01T00:00:00Z'\n" + + "cursor: whd_210b9798eb53baa4e69d31c1071cf03d\n" + + "limit: 1\n" + + "status: pending\n" + + "tags:\n" + + " - production\n" + + " - team-alpha\n") + mocktest.TestRunMockTestWithPipeAndFlags( + t, pipeData, + "--api-key", "string", + "webhooks:deliveries", "list", + ) + }) +} + +func TestWebhooksDeliveriesListAttempts(t *testing.T) { + t.Skip("Mock server tests are disabled") + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "webhooks:deliveries", "list-attempts", + "--delivery-id", "whd_210b9798eb53baa4e69d31c1071cf03d", + "--cursor", "wha_210b9798eb53baa4e69d31c1071cf03d", + "--limit", "1", + "--tag", "production", + "--tag", "team-alpha", + ) + }) +} + +func TestWebhooksDeliveriesRetry(t *testing.T) { + t.Skip("Mock server tests are disabled") + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "webhooks:deliveries", "retry", + "--delivery-id", "whd_210b9798eb53baa4e69d31c1071cf03d", + "--force=true", + "--tag", "production", + "--tag", "team-alpha", + "--idempotency-key", "Idempotency-Key", + ) + }) + + t.Run("piping data", func(t *testing.T) { + // Test piping YAML data over stdin + pipeData := []byte("" + + "force: true\n" + + "tags:\n" + + " - production\n" + + " - team-alpha\n") + mocktest.TestRunMockTestWithPipeAndFlags( + t, pipeData, + "--api-key", "string", + "webhooks:deliveries", "retry", + "--delivery-id", "whd_210b9798eb53baa4e69d31c1071cf03d", + "--idempotency-key", "Idempotency-Key", + ) + }) +}