exa-ai 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/README.md +72 -1
  4. data/exe/exa-ai +139 -1
  5. data/exe/exa-ai-enrichment-cancel +108 -0
  6. data/exe/exa-ai-enrichment-create +188 -0
  7. data/exe/exa-ai-enrichment-delete +122 -0
  8. data/exe/exa-ai-enrichment-get +104 -0
  9. data/exe/exa-ai-enrichment-list +99 -0
  10. data/exe/exa-ai-enrichment-update +140 -0
  11. data/exe/exa-ai-import-create +224 -0
  12. data/exe/exa-ai-import-delete +92 -0
  13. data/exe/exa-ai-import-get +92 -0
  14. data/exe/exa-ai-import-list +71 -0
  15. data/exe/exa-ai-import-update +130 -0
  16. data/exe/exa-ai-monitor-create +180 -0
  17. data/exe/exa-ai-monitor-delete +101 -0
  18. data/exe/exa-ai-monitor-get +92 -0
  19. data/exe/exa-ai-monitor-list +89 -0
  20. data/exe/exa-ai-monitor-runs-get +103 -0
  21. data/exe/exa-ai-monitor-runs-list +110 -0
  22. data/exe/exa-ai-monitor-update +192 -0
  23. data/exe/exa-ai-search +10 -0
  24. data/exe/exa-ai-search-monitor-create +1 -1
  25. data/exe/exa-ai-search-monitor-delete +1 -1
  26. data/exe/exa-ai-search-monitor-get +1 -1
  27. data/exe/exa-ai-search-monitor-list +1 -1
  28. data/exe/exa-ai-search-monitor-trigger +1 -1
  29. data/exe/exa-ai-webset-cancel +97 -0
  30. data/exe/exa-ai-webset-create +220 -0
  31. data/exe/exa-ai-webset-delete +111 -0
  32. data/exe/exa-ai-webset-get +93 -0
  33. data/exe/exa-ai-webset-item-delete +111 -0
  34. data/exe/exa-ai-webset-item-get +105 -0
  35. data/exe/exa-ai-webset-item-list +108 -0
  36. data/exe/exa-ai-webset-list +96 -0
  37. data/exe/exa-ai-webset-search-cancel +104 -0
  38. data/exe/exa-ai-webset-search-create +231 -0
  39. data/exe/exa-ai-webset-search-get +105 -0
  40. data/exe/exa-ai-webset-update +116 -0
  41. data/lib/exa/cli/formatters/enrichment_formatter.rb +125 -0
  42. data/lib/exa/cli/formatters/import_formatter.rb +153 -0
  43. data/lib/exa/cli/formatters/monitor_formatter.rb +144 -0
  44. data/lib/exa/cli/formatters/monitor_run_formatter.rb +126 -0
  45. data/lib/exa/cli/formatters/search_formatter.rb +22 -1
  46. data/lib/exa/cli/formatters/search_monitor_formatter.rb +1 -1
  47. data/lib/exa/cli/formatters/webset_formatter.rb +134 -0
  48. data/lib/exa/cli/formatters/webset_item_formatter.rb +132 -0
  49. data/lib/exa/cli/formatters/webset_search_formatter.rb +57 -0
  50. data/lib/exa/cli/search_parser.rb +4 -0
  51. data/lib/exa/client.rb +313 -1
  52. data/lib/exa/constants/websets.rb +19 -0
  53. data/lib/exa/resources/import.rb +111 -0
  54. data/lib/exa/resources/import_collection.rb +33 -0
  55. data/lib/exa/resources/monitor.rb +72 -0
  56. data/lib/exa/resources/monitor_collection.rb +30 -0
  57. data/lib/exa/resources/monitor_run.rb +82 -0
  58. data/lib/exa/resources/monitor_run_collection.rb +30 -0
  59. data/lib/exa/resources/search_monitor.rb +1 -0
  60. data/lib/exa/resources/search_result.rb +5 -1
  61. data/lib/exa/resources/webset.rb +106 -0
  62. data/lib/exa/resources/webset_collection.rb +33 -0
  63. data/lib/exa/resources/webset_enrichment.rb +71 -0
  64. data/lib/exa/resources/webset_enrichment_collection.rb +28 -0
  65. data/lib/exa/resources/webset_item.rb +63 -0
  66. data/lib/exa/resources/webset_item_collection.rb +33 -0
  67. data/lib/exa/resources/webset_search.rb +140 -0
  68. data/lib/exa/services/parameter_converter.rb +3 -2
  69. data/lib/exa/services/search.rb +2 -1
  70. data/lib/exa/services/websets/cancel.rb +19 -0
  71. data/lib/exa/services/websets/cancel_enrichment.rb +35 -0
  72. data/lib/exa/services/websets/cancel_search.rb +23 -0
  73. data/lib/exa/services/websets/create.rb +28 -0
  74. data/lib/exa/services/websets/create_enrichment.rb +35 -0
  75. data/lib/exa/services/websets/create_search.rb +28 -0
  76. data/lib/exa/services/websets/create_search_validator.rb +135 -0
  77. data/lib/exa/services/websets/create_validator.rb +214 -0
  78. data/lib/exa/services/websets/delete.rb +19 -0
  79. data/lib/exa/services/websets/delete_enrichment.rb +35 -0
  80. data/lib/exa/services/websets/delete_item.rb +20 -0
  81. data/lib/exa/services/websets/get_item.rb +20 -0
  82. data/lib/exa/services/websets/get_search.rb +22 -0
  83. data/lib/exa/services/websets/import_create.rb +22 -0
  84. data/lib/exa/services/websets/import_delete.rb +19 -0
  85. data/lib/exa/services/websets/import_get.rb +19 -0
  86. data/lib/exa/services/websets/import_list.rb +25 -0
  87. data/lib/exa/services/websets/import_update.rb +20 -0
  88. data/lib/exa/services/websets/import_upload.rb +59 -0
  89. data/lib/exa/services/websets/list.rb +25 -0
  90. data/lib/exa/services/websets/list_items.rb +26 -0
  91. data/lib/exa/services/websets/monitors/create.rb +31 -0
  92. data/lib/exa/services/websets/monitors/delete.rb +21 -0
  93. data/lib/exa/services/websets/monitors/get.rb +22 -0
  94. data/lib/exa/services/websets/monitors/list.rb +27 -0
  95. data/lib/exa/services/websets/monitors/runs/get.rb +25 -0
  96. data/lib/exa/services/websets/monitors/runs/list.rb +30 -0
  97. data/lib/exa/services/websets/monitors/update.rb +28 -0
  98. data/lib/exa/services/websets/retrieve.rb +30 -0
  99. data/lib/exa/services/websets/retrieve_enrichment.rb +35 -0
  100. data/lib/exa/services/websets/update.rb +40 -0
  101. data/lib/exa/services/websets/update_enrichment.rb +36 -0
  102. data/lib/exa/services/websets_parameter_converter.rb +51 -0
  103. data/lib/exa/version.rb +1 -1
  104. data/lib/exa.rb +51 -0
  105. metadata +331 -227
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72c23508be312974a2ba67df65b3aa1cd24c183cf6db67787bc797c4381bf965
4
- data.tar.gz: fc4fae56ae5ef045b2349066f3055878aab34a443f014ee04ee2c54a938603d1
3
+ metadata.gz: 2436428a3c1bce8790470095a183d21d6b5c4a7d00b024cb78846026bc962306
4
+ data.tar.gz: 9d62b68464806682621d5dad44b2a71e8b2d4bcd9ed07601abd64e05e8c9204d
5
5
  SHA512:
6
- metadata.gz: 57b11369ccdb3eb61c0e639dd64bb162b07fc3f012049f33004e3540730b89d0dca90a92bd0b7cf4f4021718a60a79ebb8a5ef23034a054fa7f183c110866ef8
7
- data.tar.gz: 0c6d345677f78a11912a695ab358f1115dc2ad039cf0860242bbcf1cf23de994cd6ab4d1c2d884603ffc99177a317c53ef431bbc9a20a46c0d3b24a896ce0e22
6
+ metadata.gz: 4653bba5218c8d6129ea73089986fc0792c4bf84acc91a3fd84ed1291a836045b8fd88e997da0e39f1acfde7766911e316231691bd6b489642008c9b33643a6e
7
+ data.tar.gz: c1878cc8216d7e9a9f28d6329105d5b1fda310fa28d3ba4334b6f4a6646befeb44cf8484e309a9d9da8cf15bcb3d8086dfba943ae75867e873b836ff4563541b
data/CHANGELOG.md CHANGED
@@ -5,6 +5,37 @@ All notable changes to the exa-ai gem will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [0.16.0] - 2026-12-03
11
+
12
+ ### Added
13
+ - **Search Decisions** - `client.search(query, decisions: {...})` asks typed questions (`noul`, `choice`, `score`) that the API answers from the results. Question names and choice options are sent as given, and `SearchResult#decisions` returns the API's `decisions` object, `refusal` answers included. `exa-ai search --decisions JSON|@file` sends them; `pretty` and `text` output show each answer, and `json` output keeps `decisions`. With `search_stream`, the answers arrive on the `done` chunk
14
+ - **Websets support is back, for Websets V2** - Exa released Websets V2 on 2026-11-17, and everyone on the usage plan can now use the Websets API. Everything that 0.14.0 removed is back, with the same names, except the status helpers listed under Changed. The API paths under `https://api.exa.ai/websets/v0/` did not change
15
+ - Commands (30): `exa-ai webset-*` (create, get, list, update, delete, cancel), `exa-ai webset-search-*` (create, get, cancel), `exa-ai webset-item-*` (list, get, delete), `exa-ai enrichment-*` (create, get, list, update, delete, cancel), `exa-ai import-*` (create, list, get, update, delete) and the Websets monitor commands `exa-ai monitor-*` (create, get, list, update, delete, runs-list, runs-get). The `monitor-*` commands are for Websets monitors. They are not the `search-monitor-*` commands, which call the separate search monitors API
16
+ - Client methods: websets (`list_websets`, `get_webset`, `create_webset`, `update_webset`, `delete_webset`, `cancel_webset`), webset searches (`create_webset_search`, `get_webset_search`, `cancel_webset_search`), webset items (`list_items`, `get_item`, `delete_item`), enrichments (`create_enrichment`, `get_enrichment`, `update_enrichment`, `delete_enrichment`, `cancel_enrichment`), imports (`list_imports`, `create_import`, `upload_import`, `get_import`, `update_import`, `delete_import`) and Websets monitors and their runs (`create_monitor`, `list_monitors`, `get_monitor`, `update_monitor`, `delete_monitor`, `list_monitor_runs`, `get_monitor_run`)
17
+ - Classes: the `Exa::Services::Websets` services, `Exa::Constants::Websets`, the `Webset*`, `Import*`, `Monitor`, `MonitorCollection`, `MonitorRun` and `MonitorRunCollection` resources, and their CLI formatters
18
+ - **New Websets fields** - `Webset#dashboard_url`, `WebsetSearch#max_people_per_company`, `Monitor#last_run`, `#next_run_at` and `#metadata`, and `MonitorRun#type` (`search` or `refresh`) and `#canceled_at`. Each one is also in `to_h`
19
+ - **New Websets options** - `max_people_per_company` (an integer of at least 1) on `create_webset_search` and in the `search` of `create_webset`; it is sent as `maxPeoplePerCompany`. `search:` on `list_websets` finds websets by ID, external ID or title (the API takes 2 to 50 characters). `status:` on `update_monitor` turns a monitor on or off (`enabled` or `disabled`)
20
+ - **New Websets flags** - `exa-ai webset-search-create --max-people-per-company N`, `exa-ai webset-list --search TEXT` and `exa-ai monitor-update --status enabled|disabled`
21
+
22
+ ### Changed (compared with Websets before 0.14.0)
23
+ - **Validation follows the current Websets spec** - `create_webset_search` now requires `query` and `count`, and `exa-ai webset-search-create` needs `--query` and `--count`. `create_webset` and `exa-ai webset-create` no longer require a `search` or an `import`, and `create_webset` no longer limits the title to 1000 characters. `update_monitor` refuses a `status` other than `enabled` or `disabled`
24
+ - **Websets monitor behavior follows the spec** - `exa-ai monitor-create` and `exa-ai monitor-update` send `behavior` as `{type: "search", config: {query, count, behavior}}`. `--count` is now required on `monitor-create`, where `--query` is optional and the API then uses the webset's last search query. On `monitor-update`, any behavior flag now needs both `--query` and `--count`, because the API replaces the whole behavior; before, `monitor-update --count 25` could drop the query and mode. `--behavior-type` is optional and takes only `search`, the one type the API has; `refresh` is gone. Before 0.14.0, these commands sent the query, count and mode at the top level of `behavior`. With the client, pass `behavior:` to `create_monitor` and `update_monitor` in the spec shape. The text output of the `monitor-*` commands reads the query and count from `behavior.config`
25
+ - **`list_websets`, `list_imports`, `list_monitors` and `list_monitor_runs` return resource objects** - each item in their `data` is now an `Exa::Resources::Webset`, `Import`, `Monitor` or `MonitorRun`, like the result of `get_webset`, `get_import`, `get_monitor` and `get_monitor_run`. Before, each item was the raw API hash with camelCase string keys. The `json` and `toon` output of `exa-ai webset-list`, `import-list`, `monitor-list` and `monitor-runs-list` now uses each object's `to_h`, so the top-level keys are snake_case (such as `created_at` on every item and `monitor_id` on a monitor run) and fields with a null value are left out, like the matching `get` commands. In Ruby, a camelCase lookup on an item, such as `item["createdAt"]`, now raises `NameError`; `item["id"]` still works. Nested objects (such as a webset's `searches`, or a monitor's `cadence`, `behavior`, `last_run` and `metadata`) keep the API's keys. The `pretty` and `text` output of `webset-list`, `monitor-list` and `monitor-runs-list` does not change.
26
+ - **`get_item` and `list_items` return `WebsetItem` objects** - `get_item` now returns an `Exa::Resources::WebsetItem` instead of a Hash, and each item in the `data` of `list_items` is a `WebsetItem` instead of the raw API hash. Read an item's fields as attributes, such as `item.webset_id` and `item.properties["url"]`. The `json` and `toon` output of `exa-ai webset-item-get` and `webset-item-list` now uses `to_h`, so the top-level keys are snake_case (such as `webset_id` and `created_at`) and fields with a null value are left out. The json and toon output carry only the fields that `WebsetItem` maps. In Ruby, a camelCase lookup on an item, such as `item["websetId"]`, now raises `NameError`, and Hash methods such as `key?` and `fetch` are gone; `item["id"]` still works. `properties`, `evaluations` and `enrichments` keep the API's keys
27
+ - **`Webset#items` holds `WebsetItem` objects** - when `get_webset` is called with `expand: ["items"]`, each item in `Webset#items` is now an `Exa::Resources::WebsetItem`, like the result of `get_item`, instead of the raw API hash. `Webset#to_h` maps each item with `to_h`, so the `json` and `toon` output of `exa-ai webset-get` use snake_case keys for items (such as `webset_id`), like `webset-item-get`. A camelCase lookup on an item, such as `item["websetId"]`, now raises `NameError`; `item["id"]` still works
28
+ - **Status helpers** - these helpers checked a status that the API no longer sends, and they did not come back: `Webset#processing?`, `WebsetEnrichment#running?`, `Monitor#pending?`, `#active?` and `#paused?`, `MonitorRun#pending?`, and `WebsetSearch#failed?`. Use `Monitor#enabled?` and `#disabled?` for a monitor
29
+ - **Websets commands follow the current CLI rules** - like every other `exa-ai` command, a flag with no value, or with another flag or `-h` as its value, stops the command with one `Error: <flag>` line, exit 1 and no request. A flag in the ID position, such as `exa-ai webset-get --bogus`, stops with `Unknown option: --bogus`. Before 0.14.0, these commands sent the next flag as the value, and `enrichment-create`, `import-create`, `import-update`, `monitor-create` and `monitor-update` printed help for `-h` anywhere on the command line, even as a flag value
30
+
31
+ ### Fixed
32
+ - **`--wait` stops on canceled and paused** - with `--wait`, `exa-ai enrichment-create` now stops when the enrichment is canceled and exits 1, and `exa-ai webset-create` now stops when the webset is paused. Before, both kept polling until the 300-second timeout
33
+ - **Websets `Monitor` objects, and the `MonitorRun` that `get_monitor_run` returns, are now frozen on creation** - the `Monitor` `cadence` and `behavior` hashes passed in are frozen in place, so code that changed a `Monitor`, that `MonitorRun` or those hashes afterwards now raises `FrozenError`
34
+ - **`update_webset` checks its params** - `update_webset` now refuses keys other than `title` and `metadata` (such as `external_id`), and checks their limits before it sends a request: `title` must not be empty, metadata keys can have at most 250 characters, and metadata values must be strings of at most 1000 characters. Before, it sent all params to the API unchanged. `create_webset` now also refuses metadata keys longer than 250 characters
35
+ - **`exa-ai webset-update`, `webset-create`, `webset-search-create` and `monitor-update` validation errors** - when the client refuses a param, such as `--metadata '{"tags":["important"]}'` (metadata values must be Strings), `--count 0` on `webset-search-create` or `--status paused` on `monitor-update`, these commands now print one `Error:` line, exit 1 and send no request. Before, they printed `Unexpected error: <message>`
36
+ - **`exa-ai import-list` pretty and text output** - `exa-ai import-list` with `--output-format pretty` or `text` now prints the imports. Before, it stopped with `NoMethodError`, because `list_imports` returned hashes and the formatter read `Import` attributes
37
+ - **`exa-ai webset-item-get` and `webset-item-list` pretty and text output** - these commands now show the item type, URL, title and description (description on `webset-item-get` only) from the item's `properties`. The title comes from the part of `properties` for the item type, such as `company.name` or `researchPaper.title`. Before, they showed only the item ID and dates, because they read `url` and `title` at the top level of the item, where the API does not send them. The `Status` and `Entity` lines are gone, because the API spec defines neither for an item
38
+
8
39
  ## [0.15.0] - 2026-11-17
9
40
 
10
41
  ### Added
data/README.md CHANGED
@@ -135,6 +135,12 @@ client = Exa::Client.new
135
135
  results = client.search("Ruby programming language")
136
136
  results.results.each { |item| puts "#{item['title']}: #{item['url']}" }
137
137
 
138
+ # Ask typed questions that the API answers from the search results
139
+ results = client.search("Mailgun company", decisions: {
140
+ questions: { sells_to_businesses: { type: "noul", instructions: "Does Mailgun sell mainly to businesses?" } }
141
+ })
142
+ results.decisions&.dig("answers", "sells_to_businesses") # => {"type"=>"noul", "noul"=>1}
143
+
138
144
  # Find similar content (deprecated: prefer search with a query that describes the page)
139
145
  similar = client.find_similar("https://arxiv.org/abs/2307.06435")
140
146
  similar.results.each { |item| puts item['url'] }
@@ -178,6 +184,52 @@ exa-ai search "AI/ML infrastructure startups with Series A funding" --print-requ
178
184
 
179
185
  # Stop with an error, and send no request, when a deprecated flag is given
180
186
  exa-ai search "venture-backed SaaS companies" --livecrawl --strict
187
+
188
+ # Webset Management
189
+ exa-ai webset-create --search '{"query":"technology companies","count":1}'
190
+ exa-ai webset-list --limit 5
191
+ exa-ai webset-get WEBSET_ID
192
+ exa-ai webset-update WEBSET_ID --metadata '{"updated":"true","version":"2"}'
193
+ exa-ai webset-delete WEBSET_ID --force
194
+ exa-ai webset-cancel WEBSET_ID
195
+
196
+ # Webset Searches
197
+ exa-ai webset-search-create WEBSET_ID --query "Ford Mustang" --count 10 --entity custom --entity-description "vintage cars"
198
+ exa-ai webset-search-create WEBSET_ID --query "tech CEOs" --entity person --count 20
199
+ exa-ai webset-search-create WEBSET_ID --query "Y Combinator startups" --count 10 --entity company
200
+ exa-ai webset-search-get WEBSET_ID SEARCH_ID
201
+ exa-ai webset-search-cancel WEBSET_ID SEARCH_ID
202
+
203
+ # Webset Items
204
+ exa-ai webset-item-list WEBSET_ID
205
+ exa-ai webset-item-get WEBSET_ID ITEM_ID
206
+ exa-ai webset-item-delete WEBSET_ID ITEM_ID --force
207
+
208
+ # Enrichments
209
+ exa-ai enrichment-create WEBSET_ID --description "Find company email" --format text
210
+ exa-ai enrichment-create WEBSET_ID --description "Company size category" --format options --options '[{"label":"Small (1-10)"},{"label":"Medium (11-50)"},{"label":"Large (51+)"}]'
211
+ exa-ai enrichment-list WEBSET_ID
212
+ exa-ai enrichment-get WEBSET_ID ENRICHMENT_ID
213
+ exa-ai enrichment-update WEBSET_ID ENRICHMENT_ID --description "Updated description"
214
+ exa-ai enrichment-delete WEBSET_ID ENRICHMENT_ID --force
215
+ exa-ai enrichment-cancel WEBSET_ID ENRICHMENT_ID
216
+
217
+ # Webset Imports
218
+ exa-ai import-create companies.csv --count 100 --title "My Companies" --format csv --entity-type company
219
+ exa-ai import-create data.csv --count 50 --title "Tech Startups" --format csv --entity-type company --csv-identifier 0
220
+ exa-ai import-create import.csv --count 100 --title "Import" --format csv --entity-type company --metadata '{"source":"crm"}' --quiet
221
+ exa-ai import-list
222
+ exa-ai import-get IMPORT_ID
223
+ exa-ai import-update IMPORT_ID --title "Updated Title"
224
+ exa-ai import-delete IMPORT_ID
225
+
226
+ # Webset Monitors (scheduled runs on a webset; not the same as search-monitor-*)
227
+ exa-ai monitor-create WEBSET_ID --cron "0 0 * * *" --timezone "UTC" --query "AI startups in Europe" --count 10
228
+ exa-ai monitor-list
229
+ exa-ai monitor-get MONITOR_ID
230
+ exa-ai monitor-update MONITOR_ID --status disabled
231
+ exa-ai monitor-runs-list MONITOR_ID
232
+ exa-ai monitor-delete MONITOR_ID
181
233
  ```
182
234
 
183
235
  ## Features
@@ -240,6 +292,14 @@ Each entry has these keys, in this order:
240
292
 
241
293
  The commands reject any flag that is not in their list. The constants and the `--flags-json` output are public API: wrappers can rely on them instead of reading the gem's source.
242
294
 
295
+ ### Websets
296
+ - **Webset Management** — Create, update, delete, and list datasets of web pages
297
+ - **Webset Searches** — Run searches within websets and manage search tasks
298
+ - **Webset Items** — List, retrieve, and manage individual items in websets
299
+ - **Enrichments** — Create and manage AI-powered data enrichment tasks on websets
300
+ - **Imports** — Upload CSV files to import external data into websets
301
+ - **Monitors** — Run a new webset search on a cron schedule. These are Websets monitors (`monitor-*`), not the search monitors (`search-monitor-*`)
302
+
243
303
  ### Agent
244
304
  - **Agent API** — Asynchronous research agent with citations, streaming, and full run lifecycle
245
305
 
@@ -377,7 +437,7 @@ exa-ai agent-run-events <run_id> --limit 50 --cursor <next_cursor>
377
437
 
378
438
  ## Search Monitors
379
439
 
380
- A search monitor runs an Exa search on a schedule and posts new results to your webhook. This is the Monitors API (`/monitors`).
440
+ A search monitor runs an Exa search on a schedule and posts new results to your webhook. This is the Monitors API (`/monitors`). It is a different product from Websets monitors (`create_monitor`, `exa-ai monitor-*`), which run new searches on a webset.
381
441
 
382
442
  ### Ruby API
383
443
 
@@ -468,6 +528,9 @@ bundle exec rake test
468
528
 
469
529
  # Run integration tests (VCR-based, no real API calls)
470
530
  RUN_INTEGRATION_TESTS=true bundle exec rake test
531
+
532
+ # Run CLI integration tests (real API calls, requires explicit opt-in)
533
+ RUN_CLI_INTEGRATION_TESTS=true bundle exec rake test
471
534
  ```
472
535
 
473
536
  ### Integration Tests
@@ -480,12 +543,20 @@ RUN_INTEGRATION_TESTS=true bundle exec rake test
480
543
  - Set `RUN_INTEGRATION_TESTS=true` to run them
481
544
  - Safe to run during development
482
545
 
546
+ **CLI integration tests (`RUN_CLI_INTEGRATION_TESTS`):**
547
+ - Make real API calls through shell commands
548
+ - Consume Exa's concurrent search quota
549
+ - Set `RUN_CLI_INTEGRATION_TESTS=true` AND `EXA_API_KEY` to run them
550
+ - **Warning:** Can exhaust API quota and trigger rate limits lasting 1-2 days
551
+
483
552
  **When to run integration tests:**
484
553
  - VCR tests: Anytime (safe, no real API calls)
554
+ - CLI tests: Only before releases or when testing CLI-specific functionality
485
555
 
486
556
  **Test Coverage:**
487
557
  - **Unit tests** - Fast, no API calls, always run
488
558
  - **VCR integration tests** - Replay cassettes, skipped by default
559
+ - **CLI integration tests** - Real API calls via shell, skipped by default
489
560
 
490
561
  ## Support
491
562
 
data/exe/exa-ai CHANGED
@@ -12,6 +12,36 @@ module ExaCLI
12
12
  "answer" => "Generate an answer to a question",
13
13
  "context" => "Get code context from repositories",
14
14
  "get-contents" => "Retrieve page contents",
15
+ "webset-create" => "Create a new webset",
16
+ "webset-get" => "Get webset details",
17
+ "webset-list" => "List websets",
18
+ "webset-update" => "Update a webset",
19
+ "webset-delete" => "Delete a webset",
20
+ "webset-cancel" => "Cancel a webset",
21
+ "webset-search-create" => "Create a search in a webset",
22
+ "webset-search-get" => "Get webset search details",
23
+ "webset-search-cancel" => "Cancel a webset search",
24
+ "webset-item-list" => "List items in a webset",
25
+ "webset-item-get" => "Get webset item details",
26
+ "webset-item-delete" => "Delete a webset item",
27
+ "enrichment-create" => "Create an enrichment",
28
+ "enrichment-get" => "Get enrichment details",
29
+ "enrichment-list" => "List enrichments",
30
+ "enrichment-update" => "Update an enrichment",
31
+ "enrichment-delete" => "Delete an enrichment",
32
+ "enrichment-cancel" => "Cancel an enrichment",
33
+ "import-create" => "Create a new import",
34
+ "import-list" => "List imports",
35
+ "import-get" => "Get import details",
36
+ "import-update" => "Update an import",
37
+ "import-delete" => "Delete an import",
38
+ "monitor-create" => "Create a webset monitor",
39
+ "monitor-get" => "Get monitor details",
40
+ "monitor-list" => "List monitors",
41
+ "monitor-update" => "Update a monitor",
42
+ "monitor-delete" => "Delete a monitor",
43
+ "monitor-runs-list" => "List monitor runs",
44
+ "monitor-runs-get" => "Get monitor run details",
15
45
  "search-monitor-create" => "Create a search monitor",
16
46
  "search-monitor-get" => "Get search monitor details",
17
47
  "search-monitor-list" => "List search monitors",
@@ -51,6 +81,66 @@ module ExaCLI
51
81
  exec File.expand_path("../exa-ai-context", __FILE__), *ARGV[1..]
52
82
  when "get-contents"
53
83
  exec File.expand_path("../exa-ai-get-contents", __FILE__), *ARGV[1..]
84
+ when "webset-create"
85
+ exec File.expand_path("../exa-ai-webset-create", __FILE__), *ARGV[1..]
86
+ when "webset-get"
87
+ exec File.expand_path("../exa-ai-webset-get", __FILE__), *ARGV[1..]
88
+ when "webset-list"
89
+ exec File.expand_path("../exa-ai-webset-list", __FILE__), *ARGV[1..]
90
+ when "webset-update"
91
+ exec File.expand_path("../exa-ai-webset-update", __FILE__), *ARGV[1..]
92
+ when "webset-delete"
93
+ exec File.expand_path("../exa-ai-webset-delete", __FILE__), *ARGV[1..]
94
+ when "webset-cancel"
95
+ exec File.expand_path("../exa-ai-webset-cancel", __FILE__), *ARGV[1..]
96
+ when "webset-search-create"
97
+ exec File.expand_path("../exa-ai-webset-search-create", __FILE__), *ARGV[1..]
98
+ when "webset-search-get"
99
+ exec File.expand_path("../exa-ai-webset-search-get", __FILE__), *ARGV[1..]
100
+ when "webset-search-cancel"
101
+ exec File.expand_path("../exa-ai-webset-search-cancel", __FILE__), *ARGV[1..]
102
+ when "webset-item-list"
103
+ exec File.expand_path("../exa-ai-webset-item-list", __FILE__), *ARGV[1..]
104
+ when "webset-item-get"
105
+ exec File.expand_path("../exa-ai-webset-item-get", __FILE__), *ARGV[1..]
106
+ when "webset-item-delete"
107
+ exec File.expand_path("../exa-ai-webset-item-delete", __FILE__), *ARGV[1..]
108
+ when "enrichment-create"
109
+ exec File.expand_path("../exa-ai-enrichment-create", __FILE__), *ARGV[1..]
110
+ when "enrichment-get"
111
+ exec File.expand_path("../exa-ai-enrichment-get", __FILE__), *ARGV[1..]
112
+ when "enrichment-list"
113
+ exec File.expand_path("../exa-ai-enrichment-list", __FILE__), *ARGV[1..]
114
+ when "enrichment-update"
115
+ exec File.expand_path("../exa-ai-enrichment-update", __FILE__), *ARGV[1..]
116
+ when "enrichment-delete"
117
+ exec File.expand_path("../exa-ai-enrichment-delete", __FILE__), *ARGV[1..]
118
+ when "enrichment-cancel"
119
+ exec File.expand_path("../exa-ai-enrichment-cancel", __FILE__), *ARGV[1..]
120
+ when "import-create"
121
+ exec File.expand_path("../exa-ai-import-create", __FILE__), *ARGV[1..]
122
+ when "import-list"
123
+ exec File.expand_path("../exa-ai-import-list", __FILE__), *ARGV[1..]
124
+ when "import-get"
125
+ exec File.expand_path("../exa-ai-import-get", __FILE__), *ARGV[1..]
126
+ when "import-update"
127
+ exec File.expand_path("../exa-ai-import-update", __FILE__), *ARGV[1..]
128
+ when "import-delete"
129
+ exec File.expand_path("../exa-ai-import-delete", __FILE__), *ARGV[1..]
130
+ when "monitor-create"
131
+ exec File.expand_path("../exa-ai-monitor-create", __FILE__), *ARGV[1..]
132
+ when "monitor-get"
133
+ exec File.expand_path("../exa-ai-monitor-get", __FILE__), *ARGV[1..]
134
+ when "monitor-list"
135
+ exec File.expand_path("../exa-ai-monitor-list", __FILE__), *ARGV[1..]
136
+ when "monitor-update"
137
+ exec File.expand_path("../exa-ai-monitor-update", __FILE__), *ARGV[1..]
138
+ when "monitor-delete"
139
+ exec File.expand_path("../exa-ai-monitor-delete", __FILE__), *ARGV[1..]
140
+ when "monitor-runs-list"
141
+ exec File.expand_path("../exa-ai-monitor-runs-list", __FILE__), *ARGV[1..]
142
+ when "monitor-runs-get"
143
+ exec File.expand_path("../exa-ai-monitor-runs-get", __FILE__), *ARGV[1..]
54
144
  when "search-monitor-create"
55
145
  exec File.expand_path("../exa-ai-search-monitor-create", __FILE__), *ARGV[1..]
56
146
  when "search-monitor-get"
@@ -106,6 +196,44 @@ module ExaCLI
106
196
  ["get-contents", "Retrieve page contents"]
107
197
  ])
108
198
 
199
+ print_command_section("Websets", [
200
+ ["webset-create", "Create a new webset"],
201
+ ["webset-get", "Get webset details"],
202
+ ["webset-list", "List websets"],
203
+ ["webset-update", "Update a webset"],
204
+ ["webset-delete", "Delete a webset"],
205
+ ["webset-cancel", "Cancel a webset"]
206
+ ])
207
+
208
+ print_command_section("Webset Searches", [
209
+ ["webset-search-create", "Create a search in a webset"],
210
+ ["webset-search-get", "Get webset search details"],
211
+ ["webset-search-cancel", "Cancel a webset search"]
212
+ ])
213
+
214
+ print_command_section("Webset Items", [
215
+ ["webset-item-list", "List items in a webset"],
216
+ ["webset-item-get", "Get webset item details"],
217
+ ["webset-item-delete", "Delete a webset item"]
218
+ ])
219
+
220
+ print_command_section("Webset Enrichments", [
221
+ ["enrichment-create", "Create an enrichment"],
222
+ ["enrichment-get", "Get enrichment details"],
223
+ ["enrichment-list", "List enrichments"],
224
+ ["enrichment-update", "Update an enrichment"],
225
+ ["enrichment-delete", "Delete an enrichment"],
226
+ ["enrichment-cancel", "Cancel an enrichment"]
227
+ ])
228
+
229
+ print_command_section("Imports", [
230
+ ["import-create", "Create a new import"],
231
+ ["import-list", "List imports"],
232
+ ["import-get", "Get import details"],
233
+ ["import-update", "Update an import"],
234
+ ["import-delete", "Delete an import"]
235
+ ])
236
+
109
237
  print_command_section("Agent Runs", [
110
238
  ["agent-run-create", "Create an agent run"],
111
239
  ["agent-run-get", "Get agent run details"],
@@ -116,7 +244,17 @@ module ExaCLI
116
244
  ["agent-run-events", "Get events for an agent run"]
117
245
  ])
118
246
 
119
- print_command_section("Search Monitors", [
247
+ print_command_section("Webset Monitors", [
248
+ ["monitor-create", "Create a webset monitor"],
249
+ ["monitor-get", "Get monitor details"],
250
+ ["monitor-list", "List monitors"],
251
+ ["monitor-update", "Update a monitor"],
252
+ ["monitor-delete", "Delete a monitor"],
253
+ ["monitor-runs-list", "List monitor runs"],
254
+ ["monitor-runs-get", "Get monitor run details"]
255
+ ])
256
+
257
+ print_command_section("Search Monitors (not Websets monitors)", [
120
258
  ["search-monitor-create", "Create a search monitor"],
121
259
  ["search-monitor-get", "Get search monitor details"],
122
260
  ["search-monitor-list", "List search monitors"],
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "exa-ai"
5
+
6
+ # Parse arguments
7
+ webset_id = nil
8
+ enrichment_id = nil
9
+ api_key = nil
10
+ output_format = "json"
11
+
12
+ args = ARGV.dup
13
+ while args.any?
14
+ arg = args.shift
15
+ case arg
16
+ when "--api-key"
17
+ api_key = Exa::CLI::Base.text_value("--api-key", args.shift)
18
+ when "--output-format"
19
+ output_format = Exa::CLI::Base.text_value("--output-format", args.shift)
20
+ when "--help", "-h"
21
+ puts <<~HELP
22
+ Usage: exa-ai enrichment-cancel <webset_id> <enrichment_id> [OPTIONS]
23
+
24
+ Cancel a running enrichment
25
+
26
+ Arguments:
27
+ webset_id ID of the webset (required)
28
+ enrichment_id ID of the enrichment to cancel (required)
29
+
30
+ Options:
31
+ --api-key KEY Exa API key (or set EXA_API_KEY env var)
32
+ --output-format FMT Output format: json, pretty, or text (default: json)
33
+ --help, -h Show this help message
34
+
35
+ Examples:
36
+ exa-ai enrichment-cancel ws_123 enr_456
37
+ exa-ai enrichment-cancel ws_123 enr_456 --output-format pretty
38
+ HELP
39
+ exit 0
40
+ else
41
+ # First positional argument is webset_id, second is enrichment_id
42
+ if webset_id.nil? && !arg.start_with?("-")
43
+ webset_id = arg
44
+ elsif enrichment_id.nil? && !arg.start_with?("-")
45
+ enrichment_id = arg
46
+ else
47
+ $stderr.puts "Unknown option: #{arg}"
48
+ exit 1
49
+ end
50
+ end
51
+ end
52
+
53
+ # Validate
54
+ if webset_id.nil?
55
+ $stderr.puts "Error: webset_id argument is required"
56
+ $stderr.puts "Usage: exa-ai enrichment-cancel <webset_id> <enrichment_id> [OPTIONS]"
57
+ $stderr.puts "Try 'exa-ai enrichment-cancel --help' for more information"
58
+ exit 1
59
+ end
60
+
61
+ if enrichment_id.nil?
62
+ $stderr.puts "Error: enrichment_id argument is required"
63
+ $stderr.puts "Usage: exa-ai enrichment-cancel <webset_id> <enrichment_id> [OPTIONS]"
64
+ $stderr.puts "Try 'exa-ai enrichment-cancel --help' for more information"
65
+ exit 1
66
+ end
67
+
68
+ begin
69
+ # Resolve API key and format
70
+ api_key = Exa::CLI::Base.resolve_api_key(api_key)
71
+ output_format = Exa::CLI::Base.resolve_output_format(output_format)
72
+
73
+ # Build client
74
+ client = Exa::CLI::Base.build_client(api_key)
75
+
76
+ # Cancel enrichment
77
+ enrichment = client.cancel_enrichment(webset_id: webset_id, id: enrichment_id)
78
+
79
+ # Format and output
80
+ output = Exa::CLI::Formatters::EnrichmentFormatter.format(enrichment, output_format)
81
+ puts output
82
+ $stdout.flush
83
+
84
+ rescue Exa::NotFound => e
85
+ $stderr.puts "Enrichment not found: #{e.message}"
86
+ exit 1
87
+ rescue Exa::ConfigurationError => e
88
+ $stderr.puts "Configuration error: #{e.message}"
89
+ exit 1
90
+ rescue Exa::Unauthorized => e
91
+ $stderr.puts "Authentication error: #{e.message}"
92
+ $stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
93
+ exit 1
94
+ rescue Exa::ClientError => e
95
+ $stderr.puts "Client error: #{e.message}"
96
+ exit 1
97
+ rescue Exa::ServerError => e
98
+ $stderr.puts "Server error: #{e.message}"
99
+ $stderr.puts "The Exa API may be experiencing issues. Please try again later."
100
+ exit 1
101
+ rescue Exa::Error => e
102
+ $stderr.puts "Error: #{e.message}"
103
+ exit 1
104
+ rescue StandardError => e
105
+ $stderr.puts "Unexpected error: #{e.message}"
106
+ $stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
107
+ exit 1
108
+ end
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "exa-ai"
5
+
6
+ VALID_FORMATS = Exa::Constants::Websets::ENRICHMENT_FORMATS
7
+
8
+ # Parse command-line arguments
9
+ def parse_args(argv)
10
+ args = {
11
+ output_format: "json",
12
+ api_key: nil,
13
+ wait: false
14
+ }
15
+
16
+ i = 0
17
+
18
+ while i < argv.length
19
+ arg = argv[i]
20
+ case arg
21
+ when "--description"
22
+ args[:description] = Exa::CLI::Base.text_value("--description", argv[i + 1])
23
+ i += 2
24
+ when "--format"
25
+ args[:format] = Exa::CLI::Base.text_value("--format", argv[i + 1])
26
+ i += 2
27
+ when "--options"
28
+ args[:options] = Exa::CLI::Base.parse_json_or_file("--options", argv[i + 1], symbolize_names: true)
29
+ i += 2
30
+ when "--metadata"
31
+ args[:metadata] = Exa::CLI::Base.parse_json_or_file("--metadata", argv[i + 1], symbolize_names: true)
32
+ i += 2
33
+ when "--wait"
34
+ args[:wait] = true
35
+ i += 1
36
+ when "--api-key"
37
+ args[:api_key] = Exa::CLI::Base.text_value("--api-key", argv[i + 1])
38
+ i += 2
39
+ when "--output-format"
40
+ args[:output_format] = Exa::CLI::Base.text_value("--output-format", argv[i + 1])
41
+ i += 2
42
+ when "--help", "-h"
43
+ puts <<~HELP
44
+ Usage: exa-ai enrichment-create <webset_id> --description TEXT --format TYPE [OPTIONS]
45
+
46
+ Create a new enrichment for a webset
47
+
48
+ Required:
49
+ <webset_id> Webset ID
50
+ --description TEXT What to extract
51
+ --format TYPE One of: #{VALID_FORMATS.join(', ')}
52
+
53
+ Options:
54
+ --options JSON Array of {label: "..."} (required if format=options, supports @file.json)
55
+ --metadata JSON Custom metadata (supports @file.json)
56
+ --wait Wait until completed or canceled (exit 1 if canceled)
57
+ --api-key KEY Exa API key (or set EXA_API_KEY env var)
58
+ --output-format FMT Output format: json, pretty, or text (default: json)
59
+ --help, -h Show this help message
60
+
61
+ Examples:
62
+ exa-ai enrichment-create ws_123 --description "Company size" --format text
63
+ exa-ai enrichment-create ws_123 --description "Industry" --format options --options options.json
64
+ exa-ai enrichment-create ws_123 --description "Website URL" --format url --wait
65
+ HELP
66
+ exit 0
67
+ else
68
+ # The first argument that is not a flag is the webset_id
69
+ if args[:webset_id].nil? && !arg.start_with?("-")
70
+ args[:webset_id] = arg
71
+ i += 1
72
+ else
73
+ $stderr.puts "Unknown option: #{arg}"
74
+ exit 1
75
+ end
76
+ end
77
+ end
78
+
79
+ args
80
+ end
81
+
82
+ # Main execution
83
+ begin
84
+ args = parse_args(ARGV)
85
+
86
+ # Validate required parameters
87
+ unless args[:webset_id]
88
+ $stderr.puts "Error: <webset_id> is required"
89
+ $stderr.puts "Run 'exa-ai enrichment-create --help' for usage information"
90
+ exit 1
91
+ end
92
+
93
+ unless args[:description]
94
+ $stderr.puts "Error: --description is required"
95
+ $stderr.puts "Run 'exa-ai enrichment-create --help' for usage information"
96
+ exit 1
97
+ end
98
+
99
+ unless args[:format]
100
+ $stderr.puts "Error: --format is required"
101
+ $stderr.puts "Run 'exa-ai enrichment-create --help' for usage information"
102
+ exit 1
103
+ end
104
+
105
+ # Validate format
106
+ unless VALID_FORMATS.include?(args[:format])
107
+ $stderr.puts "Error: --format must be one of: #{VALID_FORMATS.join(', ')}"
108
+ exit 1
109
+ end
110
+
111
+ # Validate options requirement for 'options' format
112
+ if args[:format] == "options" && !args[:options]
113
+ $stderr.puts "Error: --options is required when format is 'options'"
114
+ exit 1
115
+ end
116
+
117
+ # Resolve API key
118
+ api_key = Exa::CLI::Base.resolve_api_key(args[:api_key])
119
+
120
+ # Resolve output format
121
+ output_format = Exa::CLI::Base.resolve_output_format(args[:output_format])
122
+
123
+ # Build client
124
+ client = Exa::CLI::Base.build_client(api_key)
125
+
126
+ # Prepare enrichment parameters
127
+ enrichment_params = {
128
+ description: args[:description],
129
+ format: args[:format]
130
+ }
131
+ enrichment_params[:options] = args[:options] if args[:options]
132
+ enrichment_params[:metadata] = args[:metadata] if args[:metadata]
133
+
134
+ # Create enrichment
135
+ enrichment = client.create_enrichment(webset_id: args[:webset_id], **enrichment_params)
136
+
137
+ # If --wait flag is set, poll until enrichment is completed or canceled (exit 1 if canceled)
138
+ if args[:wait]
139
+ $stderr.print "Creating enrichment... "
140
+
141
+ begin
142
+ final_enrichment = Exa::CLI::Polling.poll(max_duration: 300, initial_delay: 2, max_delay: 10) do
143
+ current = client.get_enrichment(webset_id: args[:webset_id], id: enrichment.id)
144
+
145
+ $stderr.print "⏳" if current.pending?
146
+
147
+ done = current.completed? || current.canceled?
148
+ { done: done, result: current, status: current.status }
149
+ end
150
+
151
+ $stderr.puts " #{final_enrichment.status.upcase}"
152
+ enrichment = final_enrichment
153
+
154
+ rescue Exa::CLI::Polling::TimeoutError
155
+ $stderr.puts "\nWarning: Enrichment did not complete within timeout"
156
+ $stderr.puts "Enrichment ID: #{enrichment.id}"
157
+ $stderr.puts "Check status with: exa-ai enrichment-get #{args[:webset_id]} #{enrichment.id}"
158
+ end
159
+ end
160
+
161
+ # Format and output result
162
+ output = Exa::CLI::Formatters::EnrichmentFormatter.format(enrichment, output_format)
163
+ puts output
164
+ $stdout.flush
165
+ exit 1 if args[:wait] && enrichment.canceled?
166
+
167
+ rescue Exa::ConfigurationError => e
168
+ $stderr.puts "Configuration error: #{e.message}"
169
+ exit 1
170
+ rescue Exa::Unauthorized => e
171
+ $stderr.puts "Authentication error: #{e.message}"
172
+ $stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
173
+ exit 1
174
+ rescue Exa::ClientError => e
175
+ $stderr.puts "Client error: #{e.message}"
176
+ exit 1
177
+ rescue Exa::ServerError => e
178
+ $stderr.puts "Server error: #{e.message}"
179
+ $stderr.puts "The Exa API may be experiencing issues. Please try again later."
180
+ exit 1
181
+ rescue Exa::Error => e
182
+ $stderr.puts "Error: #{e.message}"
183
+ exit 1
184
+ rescue StandardError => e
185
+ $stderr.puts "Unexpected error: #{e.message}"
186
+ $stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
187
+ exit 1
188
+ end