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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +72 -1
- data/exe/exa-ai +139 -1
- data/exe/exa-ai-enrichment-cancel +108 -0
- data/exe/exa-ai-enrichment-create +188 -0
- data/exe/exa-ai-enrichment-delete +122 -0
- data/exe/exa-ai-enrichment-get +104 -0
- data/exe/exa-ai-enrichment-list +99 -0
- data/exe/exa-ai-enrichment-update +140 -0
- data/exe/exa-ai-import-create +224 -0
- data/exe/exa-ai-import-delete +92 -0
- data/exe/exa-ai-import-get +92 -0
- data/exe/exa-ai-import-list +71 -0
- data/exe/exa-ai-import-update +130 -0
- data/exe/exa-ai-monitor-create +180 -0
- data/exe/exa-ai-monitor-delete +101 -0
- data/exe/exa-ai-monitor-get +92 -0
- data/exe/exa-ai-monitor-list +89 -0
- data/exe/exa-ai-monitor-runs-get +103 -0
- data/exe/exa-ai-monitor-runs-list +110 -0
- data/exe/exa-ai-monitor-update +192 -0
- data/exe/exa-ai-search +10 -0
- data/exe/exa-ai-search-monitor-create +1 -1
- data/exe/exa-ai-search-monitor-delete +1 -1
- data/exe/exa-ai-search-monitor-get +1 -1
- data/exe/exa-ai-search-monitor-list +1 -1
- data/exe/exa-ai-search-monitor-trigger +1 -1
- data/exe/exa-ai-webset-cancel +97 -0
- data/exe/exa-ai-webset-create +220 -0
- data/exe/exa-ai-webset-delete +111 -0
- data/exe/exa-ai-webset-get +93 -0
- data/exe/exa-ai-webset-item-delete +111 -0
- data/exe/exa-ai-webset-item-get +105 -0
- data/exe/exa-ai-webset-item-list +108 -0
- data/exe/exa-ai-webset-list +96 -0
- data/exe/exa-ai-webset-search-cancel +104 -0
- data/exe/exa-ai-webset-search-create +231 -0
- data/exe/exa-ai-webset-search-get +105 -0
- data/exe/exa-ai-webset-update +116 -0
- data/lib/exa/cli/formatters/enrichment_formatter.rb +125 -0
- data/lib/exa/cli/formatters/import_formatter.rb +153 -0
- data/lib/exa/cli/formatters/monitor_formatter.rb +144 -0
- data/lib/exa/cli/formatters/monitor_run_formatter.rb +126 -0
- data/lib/exa/cli/formatters/search_formatter.rb +22 -1
- data/lib/exa/cli/formatters/search_monitor_formatter.rb +1 -1
- data/lib/exa/cli/formatters/webset_formatter.rb +134 -0
- data/lib/exa/cli/formatters/webset_item_formatter.rb +132 -0
- data/lib/exa/cli/formatters/webset_search_formatter.rb +57 -0
- data/lib/exa/cli/search_parser.rb +4 -0
- data/lib/exa/client.rb +313 -1
- data/lib/exa/constants/websets.rb +19 -0
- data/lib/exa/resources/import.rb +111 -0
- data/lib/exa/resources/import_collection.rb +33 -0
- data/lib/exa/resources/monitor.rb +72 -0
- data/lib/exa/resources/monitor_collection.rb +30 -0
- data/lib/exa/resources/monitor_run.rb +82 -0
- data/lib/exa/resources/monitor_run_collection.rb +30 -0
- data/lib/exa/resources/search_monitor.rb +1 -0
- data/lib/exa/resources/search_result.rb +5 -1
- data/lib/exa/resources/webset.rb +106 -0
- data/lib/exa/resources/webset_collection.rb +33 -0
- data/lib/exa/resources/webset_enrichment.rb +71 -0
- data/lib/exa/resources/webset_enrichment_collection.rb +28 -0
- data/lib/exa/resources/webset_item.rb +63 -0
- data/lib/exa/resources/webset_item_collection.rb +33 -0
- data/lib/exa/resources/webset_search.rb +140 -0
- data/lib/exa/services/parameter_converter.rb +3 -2
- data/lib/exa/services/search.rb +2 -1
- data/lib/exa/services/websets/cancel.rb +19 -0
- data/lib/exa/services/websets/cancel_enrichment.rb +35 -0
- data/lib/exa/services/websets/cancel_search.rb +23 -0
- data/lib/exa/services/websets/create.rb +28 -0
- data/lib/exa/services/websets/create_enrichment.rb +35 -0
- data/lib/exa/services/websets/create_search.rb +28 -0
- data/lib/exa/services/websets/create_search_validator.rb +135 -0
- data/lib/exa/services/websets/create_validator.rb +214 -0
- data/lib/exa/services/websets/delete.rb +19 -0
- data/lib/exa/services/websets/delete_enrichment.rb +35 -0
- data/lib/exa/services/websets/delete_item.rb +20 -0
- data/lib/exa/services/websets/get_item.rb +20 -0
- data/lib/exa/services/websets/get_search.rb +22 -0
- data/lib/exa/services/websets/import_create.rb +22 -0
- data/lib/exa/services/websets/import_delete.rb +19 -0
- data/lib/exa/services/websets/import_get.rb +19 -0
- data/lib/exa/services/websets/import_list.rb +25 -0
- data/lib/exa/services/websets/import_update.rb +20 -0
- data/lib/exa/services/websets/import_upload.rb +59 -0
- data/lib/exa/services/websets/list.rb +25 -0
- data/lib/exa/services/websets/list_items.rb +26 -0
- data/lib/exa/services/websets/monitors/create.rb +31 -0
- data/lib/exa/services/websets/monitors/delete.rb +21 -0
- data/lib/exa/services/websets/monitors/get.rb +22 -0
- data/lib/exa/services/websets/monitors/list.rb +27 -0
- data/lib/exa/services/websets/monitors/runs/get.rb +25 -0
- data/lib/exa/services/websets/monitors/runs/list.rb +30 -0
- data/lib/exa/services/websets/monitors/update.rb +28 -0
- data/lib/exa/services/websets/retrieve.rb +30 -0
- data/lib/exa/services/websets/retrieve_enrichment.rb +35 -0
- data/lib/exa/services/websets/update.rb +40 -0
- data/lib/exa/services/websets/update_enrichment.rb +36 -0
- data/lib/exa/services/websets_parameter_converter.rb +51 -0
- data/lib/exa/version.rb +1 -1
- data/lib/exa.rb +51 -0
- metadata +331 -227
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
# Parse arguments
|
|
7
|
+
monitor_id = nil
|
|
8
|
+
api_key = nil
|
|
9
|
+
output_format = "json"
|
|
10
|
+
|
|
11
|
+
args = ARGV.dup
|
|
12
|
+
while args.any?
|
|
13
|
+
arg = args.shift
|
|
14
|
+
case arg
|
|
15
|
+
when "--api-key"
|
|
16
|
+
api_key = Exa::CLI::Base.text_value("--api-key", args.shift)
|
|
17
|
+
when "--output-format"
|
|
18
|
+
output_format = Exa::CLI::Base.text_value("--output-format", args.shift)
|
|
19
|
+
when "--help", "-h"
|
|
20
|
+
puts <<~HELP
|
|
21
|
+
Usage: exa-ai monitor-get <monitor_id> [OPTIONS]
|
|
22
|
+
|
|
23
|
+
Retrieve details for a monitor
|
|
24
|
+
|
|
25
|
+
Arguments:
|
|
26
|
+
monitor_id ID of the monitor to retrieve (required)
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
30
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
31
|
+
--help, -h Show this help message
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
exa-ai monitor-get mon_abc123
|
|
35
|
+
exa-ai monitor-get mon_abc123 --output-format pretty
|
|
36
|
+
HELP
|
|
37
|
+
exit 0
|
|
38
|
+
else
|
|
39
|
+
# First positional argument is monitor_id
|
|
40
|
+
if monitor_id.nil? && !arg.start_with?("-")
|
|
41
|
+
monitor_id = arg
|
|
42
|
+
else
|
|
43
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
44
|
+
exit 1
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Validate
|
|
50
|
+
if monitor_id.nil?
|
|
51
|
+
$stderr.puts "Error: monitor_id argument is required"
|
|
52
|
+
$stderr.puts "Usage: exa-ai monitor-get <monitor_id> [OPTIONS]"
|
|
53
|
+
$stderr.puts "Try 'exa-ai monitor-get --help' for more information"
|
|
54
|
+
exit 1
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
begin
|
|
58
|
+
# Resolve API key and format
|
|
59
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
60
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
61
|
+
|
|
62
|
+
# Build client
|
|
63
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
64
|
+
|
|
65
|
+
# Get monitor
|
|
66
|
+
monitor = client.get_monitor(id: monitor_id)
|
|
67
|
+
|
|
68
|
+
# Format and output
|
|
69
|
+
output = Exa::CLI::Formatters::MonitorFormatter.format(monitor, output_format)
|
|
70
|
+
puts output
|
|
71
|
+
|
|
72
|
+
rescue Exa::NotFound => e
|
|
73
|
+
$stderr.puts "Monitor not found: #{e.message}"
|
|
74
|
+
exit 1
|
|
75
|
+
rescue Exa::Unauthorized => e
|
|
76
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
77
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
78
|
+
exit 1
|
|
79
|
+
rescue Exa::ClientError => e
|
|
80
|
+
$stderr.puts "Client error: #{e.message}"
|
|
81
|
+
exit 1
|
|
82
|
+
rescue Exa::ServerError => e
|
|
83
|
+
$stderr.puts "Server error: #{e.message}"
|
|
84
|
+
exit 1
|
|
85
|
+
rescue Exa::Error => e
|
|
86
|
+
$stderr.puts "Error: #{e.message}"
|
|
87
|
+
exit 1
|
|
88
|
+
rescue StandardError => e
|
|
89
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
90
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
91
|
+
exit 1
|
|
92
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
# Parse arguments
|
|
7
|
+
limit = nil
|
|
8
|
+
cursor = 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 "--limit"
|
|
17
|
+
limit = Exa::CLI::Base.parse_integer("--limit", args.shift)
|
|
18
|
+
when "--cursor"
|
|
19
|
+
cursor = Exa::CLI::Base.text_value("--cursor", args.shift)
|
|
20
|
+
when "--api-key"
|
|
21
|
+
api_key = Exa::CLI::Base.text_value("--api-key", args.shift)
|
|
22
|
+
when "--output-format"
|
|
23
|
+
output_format = Exa::CLI::Base.text_value("--output-format", args.shift)
|
|
24
|
+
when "--help", "-h"
|
|
25
|
+
puts <<~HELP
|
|
26
|
+
Usage: exa-ai monitor-list [OPTIONS]
|
|
27
|
+
|
|
28
|
+
List all monitors with optional pagination
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--limit N Maximum number of monitors to return (default: 25, max: 100)
|
|
32
|
+
--cursor CURSOR Cursor for pagination (use next_cursor from previous response)
|
|
33
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
34
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
35
|
+
--help, -h Show this help message
|
|
36
|
+
|
|
37
|
+
Examples:
|
|
38
|
+
exa-ai monitor-list
|
|
39
|
+
exa-ai monitor-list --limit 10
|
|
40
|
+
exa-ai monitor-list --limit 5 --cursor "abc123"
|
|
41
|
+
exa-ai monitor-list --output-format pretty
|
|
42
|
+
HELP
|
|
43
|
+
exit 0
|
|
44
|
+
else
|
|
45
|
+
Exa::CLI::Base.reject_unknown_option(arg)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
begin
|
|
50
|
+
# Resolve API key and format
|
|
51
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
52
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
53
|
+
|
|
54
|
+
# Build client
|
|
55
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
56
|
+
|
|
57
|
+
# List monitors with optional pagination
|
|
58
|
+
list_params = {}
|
|
59
|
+
list_params[:limit] = limit if limit
|
|
60
|
+
list_params[:cursor] = cursor if cursor
|
|
61
|
+
|
|
62
|
+
collection = client.list_monitors(**list_params)
|
|
63
|
+
|
|
64
|
+
# Format and output
|
|
65
|
+
output = Exa::CLI::Formatters::MonitorFormatter.format_collection(collection, output_format)
|
|
66
|
+
puts output
|
|
67
|
+
|
|
68
|
+
rescue Exa::ConfigurationError => e
|
|
69
|
+
$stderr.puts "Configuration error: #{e.message}"
|
|
70
|
+
exit 1
|
|
71
|
+
rescue Exa::Unauthorized => e
|
|
72
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
73
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
74
|
+
exit 1
|
|
75
|
+
rescue Exa::ClientError => e
|
|
76
|
+
$stderr.puts "Client error: #{e.message}"
|
|
77
|
+
exit 1
|
|
78
|
+
rescue Exa::ServerError => e
|
|
79
|
+
$stderr.puts "Server error: #{e.message}"
|
|
80
|
+
$stderr.puts "The Exa API may be experiencing issues. Please try again later."
|
|
81
|
+
exit 1
|
|
82
|
+
rescue Exa::Error => e
|
|
83
|
+
$stderr.puts "Error: #{e.message}"
|
|
84
|
+
exit 1
|
|
85
|
+
rescue StandardError => e
|
|
86
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
87
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
88
|
+
exit 1
|
|
89
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
# Parse arguments
|
|
7
|
+
monitor_id = nil
|
|
8
|
+
run_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 monitor-runs-get <monitor_id> <run_id> [OPTIONS]
|
|
23
|
+
|
|
24
|
+
Retrieve details for a specific monitor run
|
|
25
|
+
|
|
26
|
+
Arguments:
|
|
27
|
+
monitor_id ID of the monitor (required)
|
|
28
|
+
run_id ID of the run to retrieve (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 monitor-runs-get mon_abc123 run_xyz789
|
|
37
|
+
exa-ai monitor-runs-get mon_abc123 run_xyz789 --output-format pretty
|
|
38
|
+
HELP
|
|
39
|
+
exit 0
|
|
40
|
+
else
|
|
41
|
+
# First positional argument is monitor_id, second is run_id
|
|
42
|
+
if monitor_id.nil? && !arg.start_with?("-")
|
|
43
|
+
monitor_id = arg
|
|
44
|
+
elsif run_id.nil? && !arg.start_with?("-")
|
|
45
|
+
run_id = arg
|
|
46
|
+
else
|
|
47
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
48
|
+
exit 1
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Validate
|
|
54
|
+
if monitor_id.nil?
|
|
55
|
+
$stderr.puts "Error: monitor_id argument is required"
|
|
56
|
+
$stderr.puts "Usage: exa-ai monitor-runs-get <monitor_id> <run_id> [OPTIONS]"
|
|
57
|
+
$stderr.puts "Try 'exa-ai monitor-runs-get --help' for more information"
|
|
58
|
+
exit 1
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if run_id.nil?
|
|
62
|
+
$stderr.puts "Error: run_id argument is required"
|
|
63
|
+
$stderr.puts "Usage: exa-ai monitor-runs-get <monitor_id> <run_id> [OPTIONS]"
|
|
64
|
+
$stderr.puts "Try 'exa-ai monitor-runs-get --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
|
+
# Get monitor run
|
|
77
|
+
monitor_run = client.get_monitor_run(monitor_id: monitor_id, id: run_id)
|
|
78
|
+
|
|
79
|
+
# Format and output
|
|
80
|
+
output = Exa::CLI::Formatters::MonitorRunFormatter.format(monitor_run, output_format)
|
|
81
|
+
puts output
|
|
82
|
+
|
|
83
|
+
rescue Exa::NotFound => e
|
|
84
|
+
$stderr.puts "Monitor run not found: #{e.message}"
|
|
85
|
+
exit 1
|
|
86
|
+
rescue Exa::Unauthorized => e
|
|
87
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
88
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
89
|
+
exit 1
|
|
90
|
+
rescue Exa::ClientError => e
|
|
91
|
+
$stderr.puts "Client error: #{e.message}"
|
|
92
|
+
exit 1
|
|
93
|
+
rescue Exa::ServerError => e
|
|
94
|
+
$stderr.puts "Server error: #{e.message}"
|
|
95
|
+
exit 1
|
|
96
|
+
rescue Exa::Error => e
|
|
97
|
+
$stderr.puts "Error: #{e.message}"
|
|
98
|
+
exit 1
|
|
99
|
+
rescue StandardError => e
|
|
100
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
101
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
102
|
+
exit 1
|
|
103
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
# Parse arguments
|
|
7
|
+
monitor_id = nil
|
|
8
|
+
limit = nil
|
|
9
|
+
cursor = nil
|
|
10
|
+
api_key = nil
|
|
11
|
+
output_format = "json"
|
|
12
|
+
|
|
13
|
+
args = ARGV.dup
|
|
14
|
+
while args.any?
|
|
15
|
+
arg = args.shift
|
|
16
|
+
case arg
|
|
17
|
+
when "--limit"
|
|
18
|
+
limit = Exa::CLI::Base.parse_integer("--limit", args.shift)
|
|
19
|
+
when "--cursor"
|
|
20
|
+
cursor = Exa::CLI::Base.text_value("--cursor", args.shift)
|
|
21
|
+
when "--api-key"
|
|
22
|
+
api_key = Exa::CLI::Base.text_value("--api-key", args.shift)
|
|
23
|
+
when "--output-format"
|
|
24
|
+
output_format = Exa::CLI::Base.text_value("--output-format", args.shift)
|
|
25
|
+
when "--help", "-h"
|
|
26
|
+
puts <<~HELP
|
|
27
|
+
Usage: exa-ai monitor-runs-list <monitor_id> [OPTIONS]
|
|
28
|
+
|
|
29
|
+
List execution runs for a monitor
|
|
30
|
+
|
|
31
|
+
Arguments:
|
|
32
|
+
monitor_id ID of the monitor (required)
|
|
33
|
+
|
|
34
|
+
Options:
|
|
35
|
+
--limit N Maximum number of runs to return (default: 25, max: 100)
|
|
36
|
+
--cursor CURSOR Cursor for pagination (use next_cursor from previous response)
|
|
37
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
38
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
39
|
+
--help, -h Show this help message
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
exa-ai monitor-runs-list mon_abc123
|
|
43
|
+
exa-ai monitor-runs-list mon_abc123 --limit 10
|
|
44
|
+
exa-ai monitor-runs-list mon_abc123 --limit 5 --cursor "abc123"
|
|
45
|
+
exa-ai monitor-runs-list mon_abc123 --output-format pretty
|
|
46
|
+
HELP
|
|
47
|
+
exit 0
|
|
48
|
+
else
|
|
49
|
+
# First positional argument is monitor_id
|
|
50
|
+
if monitor_id.nil? && !arg.start_with?("-")
|
|
51
|
+
monitor_id = arg
|
|
52
|
+
else
|
|
53
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
54
|
+
exit 1
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Validate
|
|
60
|
+
if monitor_id.nil?
|
|
61
|
+
$stderr.puts "Error: monitor_id argument is required"
|
|
62
|
+
$stderr.puts "Usage: exa-ai monitor-runs-list <monitor_id> [OPTIONS]"
|
|
63
|
+
$stderr.puts "Try 'exa-ai monitor-runs-list --help' for more information"
|
|
64
|
+
exit 1
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
begin
|
|
68
|
+
# Resolve API key and format
|
|
69
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
70
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
71
|
+
|
|
72
|
+
# Build client
|
|
73
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
74
|
+
|
|
75
|
+
# List monitor runs with optional pagination
|
|
76
|
+
list_params = {monitor_id: monitor_id}
|
|
77
|
+
list_params[:limit] = limit if limit
|
|
78
|
+
list_params[:cursor] = cursor if cursor
|
|
79
|
+
|
|
80
|
+
collection = client.list_monitor_runs(**list_params)
|
|
81
|
+
|
|
82
|
+
# Format and output
|
|
83
|
+
output = Exa::CLI::Formatters::MonitorRunFormatter.format_collection(collection, output_format)
|
|
84
|
+
puts output
|
|
85
|
+
|
|
86
|
+
rescue Exa::NotFound => e
|
|
87
|
+
$stderr.puts "Monitor not found: #{e.message}"
|
|
88
|
+
exit 1
|
|
89
|
+
rescue Exa::ConfigurationError => e
|
|
90
|
+
$stderr.puts "Configuration error: #{e.message}"
|
|
91
|
+
exit 1
|
|
92
|
+
rescue Exa::Unauthorized => e
|
|
93
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
94
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
95
|
+
exit 1
|
|
96
|
+
rescue Exa::ClientError => e
|
|
97
|
+
$stderr.puts "Client error: #{e.message}"
|
|
98
|
+
exit 1
|
|
99
|
+
rescue Exa::ServerError => e
|
|
100
|
+
$stderr.puts "Server error: #{e.message}"
|
|
101
|
+
$stderr.puts "The Exa API may be experiencing issues. Please try again later."
|
|
102
|
+
exit 1
|
|
103
|
+
rescue Exa::Error => e
|
|
104
|
+
$stderr.puts "Error: #{e.message}"
|
|
105
|
+
exit 1
|
|
106
|
+
rescue StandardError => e
|
|
107
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
108
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
109
|
+
exit 1
|
|
110
|
+
end
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
VALID_BEHAVIOR_TYPES = %w[search].freeze
|
|
7
|
+
VALID_BEHAVIOR_MODES = %w[override append].freeze
|
|
8
|
+
|
|
9
|
+
# Parse command-line arguments
|
|
10
|
+
def parse_args(argv)
|
|
11
|
+
args = {
|
|
12
|
+
output_format: "json",
|
|
13
|
+
api_key: nil
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
i = 0
|
|
17
|
+
|
|
18
|
+
while i < argv.length
|
|
19
|
+
arg = argv[i]
|
|
20
|
+
case arg
|
|
21
|
+
when "--cron"
|
|
22
|
+
args[:cron] = Exa::CLI::Base.text_value("--cron", argv[i + 1])
|
|
23
|
+
i += 2
|
|
24
|
+
when "--timezone"
|
|
25
|
+
args[:timezone] = Exa::CLI::Base.text_value("--timezone", argv[i + 1])
|
|
26
|
+
i += 2
|
|
27
|
+
when "--behavior-type"
|
|
28
|
+
args[:behavior_type] = Exa::CLI::Base.text_value("--behavior-type", argv[i + 1])
|
|
29
|
+
i += 2
|
|
30
|
+
when "--query"
|
|
31
|
+
args[:query] = Exa::CLI::Base.text_value("--query", argv[i + 1])
|
|
32
|
+
i += 2
|
|
33
|
+
when "--count"
|
|
34
|
+
args[:count] = Exa::CLI::Base.parse_integer("--count", argv[i + 1])
|
|
35
|
+
i += 2
|
|
36
|
+
when "--behavior-mode"
|
|
37
|
+
args[:behavior_mode] = Exa::CLI::Base.text_value("--behavior-mode", argv[i + 1])
|
|
38
|
+
i += 2
|
|
39
|
+
when "--status"
|
|
40
|
+
args[:status] = Exa::CLI::Base.text_value("--status", argv[i + 1])
|
|
41
|
+
i += 2
|
|
42
|
+
when "--api-key"
|
|
43
|
+
args[:api_key] = Exa::CLI::Base.text_value("--api-key", argv[i + 1])
|
|
44
|
+
i += 2
|
|
45
|
+
when "--output-format"
|
|
46
|
+
args[:output_format] = Exa::CLI::Base.text_value("--output-format", argv[i + 1])
|
|
47
|
+
i += 2
|
|
48
|
+
when "--help", "-h"
|
|
49
|
+
puts <<~HELP
|
|
50
|
+
Usage: exa-ai monitor-update <monitor_id> [OPTIONS]
|
|
51
|
+
|
|
52
|
+
Update a monitor's schedule or behavior
|
|
53
|
+
|
|
54
|
+
Required:
|
|
55
|
+
<monitor_id> Monitor ID
|
|
56
|
+
|
|
57
|
+
Cadence options:
|
|
58
|
+
--cron EXPR Cron expression (e.g., "0 0 * * *")
|
|
59
|
+
--timezone TZ Timezone (e.g., "America/New_York")
|
|
60
|
+
|
|
61
|
+
Behavior options (--query and --count are required when any of them is given):
|
|
62
|
+
--count N Number of new items each run looks for
|
|
63
|
+
--query TEXT Search query
|
|
64
|
+
--behavior-mode MODE override or append (default: append)
|
|
65
|
+
--behavior-type TYPE Only search, the default (the API has no other type)
|
|
66
|
+
|
|
67
|
+
Other options:
|
|
68
|
+
--status STATUS enabled or disabled
|
|
69
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
70
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
71
|
+
--help, -h Show this help message
|
|
72
|
+
|
|
73
|
+
Examples:
|
|
74
|
+
# Update cron schedule
|
|
75
|
+
exa-ai monitor-update mon_123 --cron "0 */12 * * *"
|
|
76
|
+
|
|
77
|
+
# Update search query
|
|
78
|
+
exa-ai monitor-update mon_123 --query "AI startups in Europe" --count 25
|
|
79
|
+
|
|
80
|
+
# Update multiple fields
|
|
81
|
+
exa-ai monitor-update mon_123 --cron "0 0 * * *" --timezone "UTC" \\
|
|
82
|
+
--query "New companies" --count 100
|
|
83
|
+
HELP
|
|
84
|
+
exit 0
|
|
85
|
+
else
|
|
86
|
+
# The first argument that is not a flag is the monitor_id
|
|
87
|
+
if args[:monitor_id].nil? && !arg.start_with?("-")
|
|
88
|
+
args[:monitor_id] = arg
|
|
89
|
+
i += 1
|
|
90
|
+
else
|
|
91
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
92
|
+
exit 1
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
args
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Validate required arguments
|
|
101
|
+
def validate_args(args)
|
|
102
|
+
unless args[:monitor_id]
|
|
103
|
+
$stderr.puts "Error: monitor_id argument is required"
|
|
104
|
+
$stderr.puts "Usage: exa-ai monitor-update <monitor_id> [OPTIONS]"
|
|
105
|
+
$stderr.puts "Try 'exa-ai monitor-update --help' for more information"
|
|
106
|
+
exit 1
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Validate behavior type if provided
|
|
110
|
+
if args[:behavior_type] && !VALID_BEHAVIOR_TYPES.include?(args[:behavior_type])
|
|
111
|
+
$stderr.puts "Error: --behavior-type must be one of: #{VALID_BEHAVIOR_TYPES.join(', ')}"
|
|
112
|
+
exit 1
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if args[:behavior_mode] && !VALID_BEHAVIOR_MODES.include?(args[:behavior_mode])
|
|
116
|
+
$stderr.puts "Error: --behavior-mode must be one of: #{VALID_BEHAVIOR_MODES.join(', ')}"
|
|
117
|
+
exit 1
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# The API replaces the whole behavior, so a change must give the query and count again.
|
|
121
|
+
if (args[:behavior_type] || args[:query] || args[:count] || args[:behavior_mode]) && !(args[:query] && args[:count])
|
|
122
|
+
$stderr.puts "Error: --query and --count are required when you change the behavior"
|
|
123
|
+
exit 1
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Main execution
|
|
128
|
+
args = parse_args(ARGV)
|
|
129
|
+
validate_args(args)
|
|
130
|
+
|
|
131
|
+
begin
|
|
132
|
+
# Resolve API key and format
|
|
133
|
+
api_key = Exa::CLI::Base.resolve_api_key(args[:api_key])
|
|
134
|
+
output_format = Exa::CLI::Base.resolve_output_format(args[:output_format])
|
|
135
|
+
|
|
136
|
+
# Build client
|
|
137
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
138
|
+
|
|
139
|
+
# Build update params
|
|
140
|
+
update_params = {}
|
|
141
|
+
|
|
142
|
+
update_params[:status] = args[:status] if args[:status]
|
|
143
|
+
|
|
144
|
+
# Build cadence object if any cadence params provided
|
|
145
|
+
if args[:cron] || args[:timezone]
|
|
146
|
+
update_params[:cadence] = {}
|
|
147
|
+
update_params[:cadence][:cron] = args[:cron] if args[:cron]
|
|
148
|
+
update_params[:cadence][:timezone] = args[:timezone] if args[:timezone]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Build behavior object as the spec defines it: {type, config}
|
|
152
|
+
if args[:count]
|
|
153
|
+
config = { query: args[:query], count: args[:count], behavior: args[:behavior_mode] }.compact
|
|
154
|
+
update_params[:behavior] = { type: "search", config: config }
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Update monitor
|
|
158
|
+
monitor = client.update_monitor(id: args[:monitor_id], **update_params)
|
|
159
|
+
|
|
160
|
+
# Format and output
|
|
161
|
+
output = Exa::CLI::Formatters::MonitorFormatter.format(monitor, output_format)
|
|
162
|
+
puts output
|
|
163
|
+
|
|
164
|
+
rescue Exa::NotFound => e
|
|
165
|
+
$stderr.puts "Monitor not found: #{e.message}"
|
|
166
|
+
exit 1
|
|
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 ArgumentError => e
|
|
185
|
+
# update_monitor refuses bad params, such as a status other than enabled or disabled.
|
|
186
|
+
$stderr.puts "Error: #{e.message}"
|
|
187
|
+
exit 1
|
|
188
|
+
rescue StandardError => e
|
|
189
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
190
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
191
|
+
exit 1
|
|
192
|
+
end
|
data/exe/exa-ai-search
CHANGED
|
@@ -44,6 +44,13 @@ def print_help
|
|
|
44
44
|
--additional-queries QUERY Additional search queries (repeatable)
|
|
45
45
|
--output-schema JSON JSON schema for output structure (@file syntax)
|
|
46
46
|
Required to get synthesized 'output' from deep/deep-reasoning
|
|
47
|
+
--decisions JSON Typed questions answered from the results (@file syntax).
|
|
48
|
+
{"questions": {NAME: QUESTION, ...}, "decision_prompt": TEXT}
|
|
49
|
+
Each QUESTION has "type", "instructions" and "criteria":
|
|
50
|
+
noul yes/no; criteria optional: {"true": TEXT, "false": TEXT}
|
|
51
|
+
choice criteria {OPTION: TEXT, ...}, 2 to 255 options
|
|
52
|
+
score criteria [LEVEL, ...], 2 to 10 levels, lowest first
|
|
53
|
+
See https://exa.ai/docs/search/decisions
|
|
47
54
|
--user-location LOC User location: ISO country code (US), or a JSON
|
|
48
55
|
object with country, latitude, longitude
|
|
49
56
|
(@file syntax)
|
|
@@ -68,6 +75,8 @@ def print_help
|
|
|
68
75
|
exa-ai search "machine learning" --num-results 5 --type deep
|
|
69
76
|
exa-ai search "Latest LLM research" --category publication
|
|
70
77
|
exa-ai search "AI startups" --category company
|
|
78
|
+
exa-ai search "Mailgun company" --decisions '{"questions":{"is_public":{"type":"noul","instructions":"Is Mailgun publicly traded?"}}}'
|
|
79
|
+
exa-ai search "Mailgun company" --decisions '{"questions":{"status":{"type":"choice","instructions":"What is Mailgun status today?","criteria":{"operating":"Still operating","acquired":"Acquired"}},"dev_focus":{"type":"score","instructions":"How strongly does Mailgun target developers?","criteria":["Not at all","Partly","Mainly"]}}}'
|
|
71
80
|
exa-ai search "Dario Amodei" --category people
|
|
72
81
|
exa-ai search "AI research" --include-domains arxiv.org,scholar.google.com
|
|
73
82
|
exa-ai search "tutorials" --output-format pretty
|
|
@@ -120,6 +129,7 @@ begin
|
|
|
120
129
|
search_params[:exclude_text] = args[:exclude_text] if args[:exclude_text]
|
|
121
130
|
search_params[:additional_queries] = args[:additional_queries] if args[:additional_queries]
|
|
122
131
|
search_params[:output_schema] = args[:output_schema] if args[:output_schema]
|
|
132
|
+
search_params[:decisions] = args[:decisions] if args[:decisions]
|
|
123
133
|
search_params[:user_location] = args[:user_location] if args[:user_location]
|
|
124
134
|
search_params[:system_prompt] = args[:system_prompt] if args[:system_prompt]
|
|
125
135
|
search_params[:moderation] = args[:moderation] if args[:moderation]
|
|
@@ -42,7 +42,7 @@ while args.any?
|
|
|
42
42
|
Usage: exa-ai search-monitor-create --query TEXT --webhook-url URL [options]
|
|
43
43
|
|
|
44
44
|
Create a search monitor: a scheduled Exa search that posts new results to a webhook.
|
|
45
|
-
Search monitors are the /monitors API.
|
|
45
|
+
Search monitors are the /monitors API, not Websets monitors (exa-ai monitor-*).
|
|
46
46
|
|
|
47
47
|
Required:
|
|
48
48
|
--query TEXT Search query
|
|
@@ -20,7 +20,7 @@ while args.any?
|
|
|
20
20
|
Usage: exa-ai search-monitor-delete ID [options]
|
|
21
21
|
|
|
22
22
|
Delete a search monitor.
|
|
23
|
-
Search monitors are the /monitors API.
|
|
23
|
+
Search monitors are the /monitors API, not Websets monitors (exa-ai monitor-*).
|
|
24
24
|
|
|
25
25
|
Options:
|
|
26
26
|
--api-key KEY Exa API key (or use EXA_API_KEY env var)
|
|
@@ -20,7 +20,7 @@ while args.any?
|
|
|
20
20
|
Usage: exa-ai search-monitor-get ID [options]
|
|
21
21
|
|
|
22
22
|
Get a search monitor.
|
|
23
|
-
Search monitors are the /monitors API.
|
|
23
|
+
Search monitors are the /monitors API, not Websets monitors (exa-ai monitor-*).
|
|
24
24
|
|
|
25
25
|
Options:
|
|
26
26
|
--api-key KEY Exa API key (or use EXA_API_KEY env var)
|
|
@@ -27,7 +27,7 @@ while args.any?
|
|
|
27
27
|
puts <<~HELP
|
|
28
28
|
Usage: exa-ai search-monitor-list [options]
|
|
29
29
|
|
|
30
|
-
List search monitors (the /monitors API).
|
|
30
|
+
List search monitors (the /monitors API, not Websets monitors).
|
|
31
31
|
|
|
32
32
|
Options:
|
|
33
33
|
--status STATUS Filter by status: active, paused, or disabled
|
|
@@ -20,7 +20,7 @@ while args.any?
|
|
|
20
20
|
Usage: exa-ai search-monitor-trigger ID [options]
|
|
21
21
|
|
|
22
22
|
Run a search monitor now (status must be active or paused).
|
|
23
|
-
Search monitors are the /monitors API.
|
|
23
|
+
Search monitors are the /monitors API, not Websets monitors (exa-ai monitor-*).
|
|
24
24
|
|
|
25
25
|
Options:
|
|
26
26
|
--api-key KEY Exa API key (or use EXA_API_KEY env var)
|