exa-ai 0.12.2 → 0.14.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 (159) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +120 -83
  3. data/exe/exa-ai +45 -152
  4. data/exe/exa-ai-agent-run-create +55 -20
  5. data/exe/exa-ai-agent-run-delete +1 -8
  6. data/exe/exa-ai-agent-run-events +21 -1
  7. data/exe/exa-ai-agent-run-list +1 -1
  8. data/exe/{exa-ai-research-list → exa-ai-agent-run-stop} +31 -32
  9. data/exe/exa-ai-answer +25 -0
  10. data/exe/exa-ai-context +6 -2
  11. data/exe/exa-ai-find-similar +26 -68
  12. data/exe/exa-ai-get-contents +138 -42
  13. data/exe/exa-ai-search +27 -104
  14. data/exe/exa-ai-search-monitor-batch +93 -0
  15. data/exe/exa-ai-search-monitor-create +104 -0
  16. data/exe/exa-ai-search-monitor-delete +69 -0
  17. data/exe/exa-ai-search-monitor-get +69 -0
  18. data/exe/exa-ai-search-monitor-list +73 -0
  19. data/exe/exa-ai-search-monitor-runs-get +68 -0
  20. data/exe/exa-ai-search-monitor-runs-list +75 -0
  21. data/exe/exa-ai-search-monitor-trigger +69 -0
  22. data/exe/exa-ai-search-monitor-update +102 -0
  23. data/lib/exa/cli/base.rb +57 -0
  24. data/lib/exa/cli/contents_flags.rb +199 -0
  25. data/lib/exa/cli/formatters/agent_run_formatter.rb +79 -3
  26. data/lib/exa/cli/formatters/search_formatter.rb +18 -2
  27. data/lib/exa/cli/formatters/search_monitor_formatter.rb +98 -0
  28. data/lib/exa/cli/search_parser.rb +46 -87
  29. data/lib/exa/client.rb +183 -333
  30. data/lib/exa/middleware/raise_error.rb +14 -0
  31. data/lib/exa/resources/agent_run.rb +5 -3
  32. data/lib/exa/resources/agent_run_deletion.rb +17 -0
  33. data/lib/exa/resources/answer.rb +3 -3
  34. data/lib/exa/resources/contents_result.rb +5 -1
  35. data/lib/exa/resources/find_similar_result.rb +5 -1
  36. data/lib/exa/resources/search_monitor.rb +42 -0
  37. data/lib/exa/resources/search_monitor_batch_result.rb +11 -0
  38. data/lib/exa/resources/{research_list.rb → search_monitor_list.rb} +3 -2
  39. data/lib/exa/resources/search_monitor_run.rb +46 -0
  40. data/lib/exa/resources/search_monitor_trigger_result.rb +11 -0
  41. data/lib/exa/resources/search_result.rb +11 -1
  42. data/lib/exa/services/agent_run_cancel.rb +1 -12
  43. data/lib/exa/services/agent_run_create.rb +1 -12
  44. data/lib/exa/services/agent_run_delete.rb +6 -14
  45. data/lib/exa/services/agent_run_events.rb +33 -4
  46. data/lib/exa/services/agent_run_get.rb +1 -12
  47. data/lib/exa/services/agent_run_list.rb +1 -12
  48. data/lib/exa/services/agent_run_stop.rb +21 -0
  49. data/lib/exa/services/agent_run_stream.rb +56 -52
  50. data/lib/exa/services/answer.rb +5 -2
  51. data/lib/exa/services/answer_stream.rb +57 -46
  52. data/lib/exa/services/context.rb +3 -1
  53. data/lib/exa/services/find_similar.rb +9 -2
  54. data/lib/exa/services/get_contents.rb +14 -15
  55. data/lib/exa/services/parameter_converter.rb +128 -111
  56. data/lib/exa/services/search.rb +58 -19
  57. data/lib/exa/services/search_monitors/batch.rb +36 -0
  58. data/lib/exa/services/search_monitors/create.rb +37 -0
  59. data/lib/exa/services/search_monitors/delete.rb +22 -0
  60. data/lib/exa/services/search_monitors/get.rb +22 -0
  61. data/lib/exa/services/search_monitors/list.rb +29 -0
  62. data/lib/exa/services/search_monitors/runs_get.rb +23 -0
  63. data/lib/exa/services/search_monitors/runs_list.rb +29 -0
  64. data/lib/exa/services/search_monitors/trigger.rb +22 -0
  65. data/lib/exa/services/search_monitors/update.rb +42 -0
  66. data/lib/exa/services/search_stream.rb +38 -0
  67. data/lib/exa/version.rb +1 -1
  68. data/lib/exa.rb +18 -56
  69. metadata +31 -94
  70. data/exe/exa-ai-enrichment-cancel +0 -108
  71. data/exe/exa-ai-enrichment-create +0 -226
  72. data/exe/exa-ai-enrichment-delete +0 -122
  73. data/exe/exa-ai-enrichment-get +0 -104
  74. data/exe/exa-ai-enrichment-list +0 -99
  75. data/exe/exa-ai-enrichment-update +0 -171
  76. data/exe/exa-ai-import-create +0 -253
  77. data/exe/exa-ai-import-delete +0 -92
  78. data/exe/exa-ai-import-get +0 -92
  79. data/exe/exa-ai-import-list +0 -72
  80. data/exe/exa-ai-import-update +0 -164
  81. data/exe/exa-ai-monitor-create +0 -223
  82. data/exe/exa-ai-monitor-delete +0 -101
  83. data/exe/exa-ai-monitor-get +0 -92
  84. data/exe/exa-ai-monitor-list +0 -90
  85. data/exe/exa-ai-monitor-runs-get +0 -103
  86. data/exe/exa-ai-monitor-runs-list +0 -110
  87. data/exe/exa-ai-monitor-update +0 -207
  88. data/exe/exa-ai-research-get +0 -109
  89. data/exe/exa-ai-research-start +0 -174
  90. data/exe/exa-ai-webset-cancel +0 -97
  91. data/exe/exa-ai-webset-create +0 -254
  92. data/exe/exa-ai-webset-delete +0 -111
  93. data/exe/exa-ai-webset-get +0 -93
  94. data/exe/exa-ai-webset-item-delete +0 -111
  95. data/exe/exa-ai-webset-item-get +0 -105
  96. data/exe/exa-ai-webset-item-list +0 -108
  97. data/exe/exa-ai-webset-list +0 -91
  98. data/exe/exa-ai-webset-search-cancel +0 -104
  99. data/exe/exa-ai-webset-search-create +0 -247
  100. data/exe/exa-ai-webset-search-get +0 -105
  101. data/exe/exa-ai-webset-update +0 -143
  102. data/lib/exa/cli/formatters/enrichment_formatter.rb +0 -125
  103. data/lib/exa/cli/formatters/import_formatter.rb +0 -153
  104. data/lib/exa/cli/formatters/monitor_formatter.rb +0 -144
  105. data/lib/exa/cli/formatters/monitor_run_formatter.rb +0 -126
  106. data/lib/exa/cli/formatters/research_formatter.rb +0 -124
  107. data/lib/exa/cli/formatters/webset_formatter.rb +0 -134
  108. data/lib/exa/cli/formatters/webset_item_formatter.rb +0 -131
  109. data/lib/exa/cli/formatters/webset_search_formatter.rb +0 -57
  110. data/lib/exa/constants/websets.rb +0 -19
  111. data/lib/exa/resources/import.rb +0 -86
  112. data/lib/exa/resources/import_collection.rb +0 -33
  113. data/lib/exa/resources/monitor.rb +0 -48
  114. data/lib/exa/resources/monitor_collection.rb +0 -30
  115. data/lib/exa/resources/monitor_run.rb +0 -52
  116. data/lib/exa/resources/monitor_run_collection.rb +0 -30
  117. data/lib/exa/resources/research_task.rb +0 -39
  118. data/lib/exa/resources/webset.rb +0 -74
  119. data/lib/exa/resources/webset_collection.rb +0 -33
  120. data/lib/exa/resources/webset_enrichment.rb +0 -71
  121. data/lib/exa/resources/webset_enrichment_collection.rb +0 -28
  122. data/lib/exa/resources/webset_item_collection.rb +0 -33
  123. data/lib/exa/resources/webset_search.rb +0 -112
  124. data/lib/exa/services/research_get.rb +0 -30
  125. data/lib/exa/services/research_list.rb +0 -37
  126. data/lib/exa/services/research_start.rb +0 -26
  127. data/lib/exa/services/websets/cancel.rb +0 -36
  128. data/lib/exa/services/websets/cancel_enrichment.rb +0 -35
  129. data/lib/exa/services/websets/cancel_search.rb +0 -44
  130. data/lib/exa/services/websets/create.rb +0 -45
  131. data/lib/exa/services/websets/create_enrichment.rb +0 -35
  132. data/lib/exa/services/websets/create_search.rb +0 -48
  133. data/lib/exa/services/websets/create_search_validator.rb +0 -128
  134. data/lib/exa/services/websets/create_validator.rb +0 -213
  135. data/lib/exa/services/websets/delete.rb +0 -36
  136. data/lib/exa/services/websets/delete_enrichment.rb +0 -35
  137. data/lib/exa/services/websets/delete_item.rb +0 -20
  138. data/lib/exa/services/websets/get_item.rb +0 -20
  139. data/lib/exa/services/websets/get_search.rb +0 -43
  140. data/lib/exa/services/websets/import_create.rb +0 -40
  141. data/lib/exa/services/websets/import_delete.rb +0 -37
  142. data/lib/exa/services/websets/import_get.rb +0 -37
  143. data/lib/exa/services/websets/import_list.rb +0 -25
  144. data/lib/exa/services/websets/import_update.rb +0 -38
  145. data/lib/exa/services/websets/import_upload.rb +0 -58
  146. data/lib/exa/services/websets/list.rb +0 -25
  147. data/lib/exa/services/websets/list_items.rb +0 -26
  148. data/lib/exa/services/websets/monitors/create.rb +0 -42
  149. data/lib/exa/services/websets/monitors/delete.rb +0 -32
  150. data/lib/exa/services/websets/monitors/get.rb +0 -33
  151. data/lib/exa/services/websets/monitors/list.rb +0 -27
  152. data/lib/exa/services/websets/monitors/runs/get.rb +0 -37
  153. data/lib/exa/services/websets/monitors/runs/list.rb +0 -30
  154. data/lib/exa/services/websets/monitors/update.rb +0 -33
  155. data/lib/exa/services/websets/retrieve.rb +0 -47
  156. data/lib/exa/services/websets/retrieve_enrichment.rb +0 -35
  157. data/lib/exa/services/websets/update.rb +0 -37
  158. data/lib/exa/services/websets/update_enrichment.rb +0 -36
  159. data/lib/exa/services/websets_parameter_converter.rb +0 -45
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module CLI
5
- module Formatters
6
- class EnrichmentFormatter
7
- def self.format(enrichment, output_format)
8
- case output_format
9
- when "json"
10
- JSON.generate(enrichment.to_h)
11
- when "pretty"
12
- format_as_pretty(enrichment)
13
- when "text"
14
- format_as_text(enrichment)
15
- when "toon"
16
- Exa::CLI::Base.encode_as_toon(enrichment.to_h)
17
- else
18
- raise ArgumentError, "Unknown output format: #{output_format}"
19
- end
20
- end
21
-
22
- def self.format_collection(collection, output_format)
23
- case output_format
24
- when "json"
25
- JSON.generate(collection.to_h)
26
- when "pretty"
27
- format_collection_as_pretty(collection)
28
- when "text"
29
- format_collection_as_text(collection)
30
- when "toon"
31
- Exa::CLI::Base.encode_as_toon(collection.to_h)
32
- else
33
- raise ArgumentError, "Unknown output format: #{output_format}"
34
- end
35
- end
36
-
37
- def self.format_as_pretty(enrichment)
38
- lines = []
39
- lines << "Enrichment ID: #{enrichment.id}"
40
- lines << "Webset ID: #{enrichment.webset_id}" if enrichment.webset_id
41
- lines << "Status: #{enrichment.status}"
42
- lines << "Title: #{enrichment.title}" if enrichment.title
43
- lines << "Description: #{enrichment.description}" if enrichment.description
44
- lines << "Format: #{enrichment.format}" if enrichment.format
45
-
46
- if enrichment.options && !enrichment.options.empty?
47
- lines << ""
48
- lines << "Options (#{enrichment.options.length}):"
49
- enrichment.options.each do |option|
50
- lines << " • #{option['label']}" if option['label']
51
- end
52
- end
53
-
54
- lines << ""
55
- lines << "Created: #{enrichment.created_at}" if enrichment.created_at
56
- lines << "Updated: #{enrichment.updated_at}" if enrichment.updated_at
57
-
58
- lines.join("\n")
59
- end
60
- private_class_method :format_as_pretty
61
-
62
- def self.format_as_text(enrichment)
63
- lines = []
64
- lines << "Enrichment: #{enrichment.id}"
65
- lines << "Webset: #{enrichment.webset_id}" if enrichment.webset_id
66
- lines << "Status: #{enrichment.status}"
67
- lines << "Title: #{enrichment.title}" if enrichment.title
68
- lines << "Description: #{enrichment.description}" if enrichment.description
69
- lines << "Format: #{enrichment.format}" if enrichment.format
70
-
71
- if enrichment.options && !enrichment.options.empty?
72
- lines << "\nOptions:"
73
- enrichment.options.each do |option|
74
- lines << " - #{option['label']}" if option['label']
75
- end
76
- end
77
-
78
- lines << "Created: #{enrichment.created_at}" if enrichment.created_at
79
- lines << "Updated: #{enrichment.updated_at}" if enrichment.updated_at
80
-
81
- lines.join("\n")
82
- end
83
- private_class_method :format_as_text
84
-
85
- def self.format_collection_as_pretty(collection)
86
- lines = []
87
- lines << "Enrichments (#{collection.data.length} items)"
88
- lines << ""
89
-
90
- collection.data.each_with_index do |enr, idx|
91
- lines << "" if idx > 0 # Blank line between enrichments
92
-
93
- lines << "Enrichment ID: #{enr['id']}"
94
- lines << "Webset ID: #{enr['websetId']}" if enr['websetId']
95
- lines << "Status: #{enr['status']}"
96
- lines << "Title: #{enr['title']}" if enr['title']
97
- lines << "Description: #{enr['description']}" if enr['description']
98
- lines << "Format: #{enr['format']}" if enr['format']
99
- lines << "Created: #{enr['createdAt']}" if enr['createdAt']
100
- lines << "Updated: #{enr['updatedAt']}" if enr['updatedAt']
101
- end
102
-
103
- if collection.has_more
104
- lines << ""
105
- lines << "Next Cursor: #{collection.next_cursor}"
106
- end
107
-
108
- lines.join("\n")
109
- end
110
- private_class_method :format_collection_as_pretty
111
-
112
- def self.format_collection_as_text(collection)
113
- lines = ["Enrichments (#{collection.data.length} items):"]
114
- collection.data.each do |enr|
115
- lines << "\n #{enr['id']}"
116
- lines << " Status: #{enr['status']}"
117
- lines << " Title: #{enr['title']}" if enr['title']
118
- end
119
- lines.join("\n")
120
- end
121
- private_class_method :format_collection_as_text
122
- end
123
- end
124
- end
125
- end
@@ -1,153 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module CLI
5
- module Formatters
6
- class ImportFormatter
7
- def self.format(import, output_format)
8
- case output_format
9
- when "json"
10
- JSON.generate(import.to_h)
11
- when "pretty"
12
- format_as_pretty(import)
13
- when "text"
14
- format_as_text(import)
15
- when "toon"
16
- Exa::CLI::Base.encode_as_toon(import.to_h)
17
- else
18
- raise ArgumentError, "Unknown output format: #{output_format}"
19
- end
20
- end
21
-
22
- def self.format_collection(collection, output_format)
23
- case output_format
24
- when "json"
25
- JSON.generate(collection.to_h)
26
- when "pretty"
27
- format_collection_as_pretty(collection)
28
- when "text"
29
- format_collection_as_text(collection)
30
- when "toon"
31
- Exa::CLI::Base.encode_as_toon(collection.to_h)
32
- else
33
- raise ArgumentError, "Unknown output format: #{output_format}"
34
- end
35
- end
36
-
37
- def self.format_as_pretty(import)
38
- lines = []
39
- lines << "Import ID: #{import.id}"
40
- lines << "Status: #{import.status}"
41
- lines << "Title: #{import.title}" if import.title
42
- lines << "Format: #{import.format}" if import.format
43
-
44
- if import.entity
45
- entity_type = import.entity['type'] || import.entity[:type]
46
- lines << "Entity Type: #{entity_type}" if entity_type
47
- end
48
-
49
- lines << "Count: #{import.count}" if import.count
50
-
51
- if import.failed?
52
- lines << ""
53
- lines << "Failure:"
54
- lines << " Reason: #{import.failed_reason}" if import.failed_reason
55
- lines << " Message: #{import.failed_message}" if import.failed_message
56
- lines << " Failed At: #{import.failed_at}" if import.failed_at
57
- end
58
-
59
- if import.upload_url
60
- lines << ""
61
- lines << "Upload:"
62
- lines << " URL: #{import.upload_url}"
63
- lines << " Valid Until: #{import.upload_valid_until}" if import.upload_valid_until
64
- end
65
-
66
- lines << ""
67
- lines << "Created: #{import.created_at}" if import.created_at
68
- lines << "Updated: #{import.updated_at}" if import.updated_at
69
-
70
- lines.join("\n")
71
- end
72
- private_class_method :format_as_pretty
73
-
74
- def self.format_as_text(import)
75
- lines = []
76
- lines << "Import: #{import.id}"
77
- lines << "Status: #{import.status}"
78
- lines << "Title: #{import.title}" if import.title
79
- lines << "Format: #{import.format}" if import.format
80
-
81
- if import.entity
82
- entity_type = import.entity['type'] || import.entity[:type]
83
- lines << "Entity Type: #{entity_type}" if entity_type
84
- end
85
-
86
- lines << "Count: #{import.count}" if import.count
87
-
88
- if import.failed?
89
- lines << "\nFailure Details:"
90
- lines << " Reason: #{import.failed_reason}" if import.failed_reason
91
- lines << " Message: #{import.failed_message}" if import.failed_message
92
- lines << " Failed At: #{import.failed_at}" if import.failed_at
93
- end
94
-
95
- if import.upload_url
96
- lines << "\nUpload:"
97
- lines << " URL: #{import.upload_url}"
98
- lines << " Valid Until: #{import.upload_valid_until}" if import.upload_valid_until
99
- end
100
-
101
- lines << "\nCreated: #{import.created_at}" if import.created_at
102
- lines << "Updated: #{import.updated_at}" if import.updated_at
103
-
104
- lines.join("\n")
105
- end
106
- private_class_method :format_as_text
107
-
108
- def self.format_collection_as_pretty(collection)
109
- lines = []
110
- lines << "Imports (#{collection.data.length} items)"
111
- lines << ""
112
-
113
- collection.data.each_with_index do |imp, idx|
114
- lines << "" if idx > 0 # Blank line between imports
115
-
116
- lines << "Import ID: #{imp.id}"
117
- lines << "Status: #{imp.status}"
118
- lines << "Title: #{imp.title}" if imp.title
119
- lines << "Format: #{imp.format}" if imp.format
120
- lines << "Entity Type: #{imp.entity['type']}" if imp.entity && imp.entity['type']
121
- lines << "Count: #{imp.count}" if imp.count
122
- lines << "Created: #{imp.created_at}" if imp.created_at
123
- lines << "Updated: #{imp.updated_at}" if imp.updated_at
124
-
125
- if imp.status == 'failed'
126
- lines << "Failed Reason: #{imp.failed_reason}" if imp.failed_reason
127
- end
128
- end
129
-
130
- if collection.has_more
131
- lines << ""
132
- lines << "Next Cursor: #{collection.next_cursor}"
133
- end
134
-
135
- lines.join("\n")
136
- end
137
- private_class_method :format_collection_as_pretty
138
-
139
- def self.format_collection_as_text(collection)
140
- lines = ["Imports (#{collection.data.length} items):"]
141
- collection.data.each do |imp|
142
- lines << "\n #{imp.id}"
143
- lines << " Status: #{imp.status}"
144
- lines << " Title: #{imp.title}" if imp.title
145
- lines << " Count: #{imp.count}" if imp.count
146
- end
147
- lines.join("\n")
148
- end
149
- private_class_method :format_collection_as_text
150
- end
151
- end
152
- end
153
- end
@@ -1,144 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module CLI
5
- module Formatters
6
- class MonitorFormatter
7
- def self.format(monitor, output_format)
8
- case output_format
9
- when "json"
10
- JSON.generate(monitor.to_h)
11
- when "pretty"
12
- format_as_pretty(monitor)
13
- when "text"
14
- format_as_text(monitor)
15
- when "toon"
16
- Exa::CLI::Base.encode_as_toon(monitor.to_h)
17
- else
18
- raise ArgumentError, "Unknown output format: #{output_format}"
19
- end
20
- end
21
-
22
- def self.format_collection(collection, output_format)
23
- case output_format
24
- when "json"
25
- JSON.generate(collection.to_h)
26
- when "pretty"
27
- format_collection_as_pretty(collection)
28
- when "text"
29
- format_collection_as_text(collection)
30
- when "toon"
31
- Exa::CLI::Base.encode_as_toon(collection.to_h)
32
- else
33
- raise ArgumentError, "Unknown output format: #{output_format}"
34
- end
35
- end
36
-
37
- def self.format_as_pretty(monitor)
38
- lines = []
39
- lines << "Monitor ID: #{monitor.id}"
40
- lines << "Webset ID: #{monitor.webset_id}" if monitor.webset_id
41
- lines << "Status: #{monitor.status}"
42
-
43
- if monitor.cadence
44
- lines << ""
45
- lines << "Cadence:"
46
- lines << " Cron: #{monitor.cadence['cron']}" if monitor.cadence['cron']
47
- lines << " Timezone: #{monitor.cadence['timezone']}" if monitor.cadence['timezone']
48
- end
49
-
50
- if monitor.behavior
51
- lines << ""
52
- lines << "Behavior:"
53
- lines << " Type: #{monitor.behavior['type']}" if monitor.behavior['type']
54
- lines << " Query: #{monitor.behavior['query']}" if monitor.behavior['query']
55
- lines << " Count: #{monitor.behavior['count']}" if monitor.behavior['count']
56
- end
57
-
58
- lines << ""
59
- lines << "Created: #{monitor.created_at}" if monitor.created_at
60
- lines << "Updated: #{monitor.updated_at}" if monitor.updated_at
61
-
62
- lines.join("\n")
63
- end
64
- private_class_method :format_as_pretty
65
-
66
- def self.format_as_text(monitor)
67
- lines = []
68
- lines << "Monitor: #{monitor.id}"
69
- lines << "Webset: #{monitor.webset_id}" if monitor.webset_id
70
- lines << "Status: #{monitor.status}"
71
-
72
- if monitor.cadence
73
- lines << "\nCadence:"
74
- lines << " Cron: #{monitor.cadence['cron']}" if monitor.cadence['cron']
75
- lines << " Timezone: #{monitor.cadence['timezone']}" if monitor.cadence['timezone']
76
- end
77
-
78
- if monitor.behavior
79
- lines << "\nBehavior:"
80
- lines << " Type: #{monitor.behavior['type']}" if monitor.behavior['type']
81
- lines << " Query: #{monitor.behavior['query']}" if monitor.behavior['query']
82
- lines << " Count: #{monitor.behavior['count']}" if monitor.behavior['count']
83
- end
84
-
85
- lines << "\nCreated: #{monitor.created_at}" if monitor.created_at
86
- lines << "Updated: #{monitor.updated_at}" if monitor.updated_at
87
-
88
- lines.join("\n")
89
- end
90
- private_class_method :format_as_text
91
-
92
- def self.format_collection_as_pretty(collection)
93
- lines = []
94
- lines << "Monitors (#{collection.data.length} items)"
95
- lines << ""
96
-
97
- collection.data.each_with_index do |mon, idx|
98
- lines << "" if idx > 0 # Blank line between monitors
99
-
100
- lines << "Monitor ID: #{mon['id']}"
101
- lines << "Webset ID: #{mon['websetId']}" if mon['websetId']
102
- lines << "Status: #{mon['status']}"
103
-
104
- if mon['cadence']
105
- lines << "Cron: #{mon['cadence']['cron']}" if mon['cadence']['cron']
106
- lines << "Timezone: #{mon['cadence']['timezone']}" if mon['cadence']['timezone']
107
- end
108
-
109
- if mon['behavior']
110
- lines << "Query: #{mon['behavior']['query']}" if mon['behavior']['query']
111
- end
112
-
113
- lines << "Created: #{mon['createdAt']}" if mon['createdAt']
114
- lines << "Updated: #{mon['updatedAt']}" if mon['updatedAt']
115
- end
116
-
117
- if collection.has_more
118
- lines << ""
119
- lines << "Next Cursor: #{collection.next_cursor}"
120
- end
121
-
122
- lines.join("\n")
123
- end
124
- private_class_method :format_collection_as_pretty
125
-
126
- def self.format_collection_as_text(collection)
127
- lines = ["Monitors (#{collection.data.length} items):"]
128
- collection.data.each do |mon|
129
- lines << "\n #{mon['id']}"
130
- lines << " Status: #{mon['status']}"
131
- lines << " Webset: #{mon['websetId']}" if mon['websetId']
132
- end
133
-
134
- if collection.has_more
135
- lines << "\nMore available (cursor: #{collection.next_cursor})"
136
- end
137
-
138
- lines.join("\n")
139
- end
140
- private_class_method :format_collection_as_text
141
- end
142
- end
143
- end
144
- end
@@ -1,126 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module CLI
5
- module Formatters
6
- class MonitorRunFormatter
7
- def self.format(monitor_run, output_format)
8
- case output_format
9
- when "json"
10
- JSON.generate(monitor_run.to_h)
11
- when "pretty"
12
- format_as_pretty(monitor_run)
13
- when "text"
14
- format_as_text(monitor_run)
15
- when "toon"
16
- Exa::CLI::Base.encode_as_toon(monitor_run.to_h)
17
- else
18
- raise ArgumentError, "Unknown output format: #{output_format}"
19
- end
20
- end
21
-
22
- def self.format_collection(collection, output_format)
23
- case output_format
24
- when "json"
25
- JSON.generate(collection.to_h)
26
- when "pretty"
27
- format_collection_as_pretty(collection)
28
- when "text"
29
- format_collection_as_text(collection)
30
- when "toon"
31
- Exa::CLI::Base.encode_as_toon(collection.to_h)
32
- else
33
- raise ArgumentError, "Unknown output format: #{output_format}"
34
- end
35
- end
36
-
37
- def self.format_as_pretty(monitor_run)
38
- lines = []
39
- lines << "Monitor Run ID: #{monitor_run.id}"
40
- lines << "Monitor ID: #{monitor_run.monitor_id}" if monitor_run.monitor_id
41
- lines << "Status: #{monitor_run.status}"
42
-
43
- lines << ""
44
- lines << "Created: #{monitor_run.created_at}" if monitor_run.created_at
45
- lines << "Updated: #{monitor_run.updated_at}" if monitor_run.updated_at
46
- lines << "Completed: #{monitor_run.completed_at}" if monitor_run.completed_at
47
-
48
- if monitor_run.failed?
49
- lines << ""
50
- lines << "Failed: #{monitor_run.failed_at}" if monitor_run.failed_at
51
- lines << "Reason: #{monitor_run.failed_reason}" if monitor_run.failed_reason
52
- end
53
-
54
- lines.join("\n")
55
- end
56
- private_class_method :format_as_pretty
57
-
58
- def self.format_as_text(monitor_run)
59
- lines = []
60
- lines << "Monitor Run: #{monitor_run.id}"
61
- lines << "Monitor: #{monitor_run.monitor_id}" if monitor_run.monitor_id
62
- lines << "Status: #{monitor_run.status}"
63
-
64
- lines << "\nCreated: #{monitor_run.created_at}" if monitor_run.created_at
65
- lines << "Updated: #{monitor_run.updated_at}" if monitor_run.updated_at
66
- lines << "Completed: #{monitor_run.completed_at}" if monitor_run.completed_at
67
-
68
- if monitor_run.failed?
69
- lines << "Failed: #{monitor_run.failed_at}" if monitor_run.failed_at
70
- lines << "Reason: #{monitor_run.failed_reason}" if monitor_run.failed_reason
71
- end
72
-
73
- lines.join("\n")
74
- end
75
- private_class_method :format_as_text
76
-
77
- def self.format_collection_as_pretty(collection)
78
- lines = []
79
- lines << "Monitor Runs (#{collection.data.length} items)"
80
- lines << ""
81
-
82
- collection.data.each_with_index do |run, idx|
83
- lines << "" if idx > 0 # Blank line between runs
84
-
85
- lines << "Monitor Run ID: #{run['id']}"
86
- lines << "Monitor ID: #{run['monitorId']}" if run['monitorId']
87
- lines << "Status: #{run['status']}"
88
- lines << "Created: #{run['createdAt']}" if run['createdAt']
89
- lines << "Updated: #{run['updatedAt']}" if run['updatedAt']
90
- lines << "Completed: #{run['completedAt']}" if run['completedAt']
91
-
92
- if run['status'] == 'failed'
93
- lines << "Failed: #{run['failedAt']}" if run['failedAt']
94
- lines << "Reason: #{run['failedReason']}" if run['failedReason']
95
- end
96
- end
97
-
98
- if collection.has_more
99
- lines << ""
100
- lines << "Next Cursor: #{collection.next_cursor}"
101
- end
102
-
103
- lines.join("\n")
104
- end
105
- private_class_method :format_collection_as_pretty
106
-
107
- def self.format_collection_as_text(collection)
108
- lines = ["Monitor Runs (#{collection.data.length} items):"]
109
- collection.data.each do |run|
110
- lines << "\n #{run['id']}"
111
- lines << " Status: #{run['status']}"
112
- lines << " Completed: #{run['completedAt']}" if run['completedAt']
113
- lines << " Failed: #{run['failedReason']}" if run['failedReason']
114
- end
115
-
116
- if collection.has_more
117
- lines << "\nMore available (cursor: #{collection.next_cursor})"
118
- end
119
-
120
- lines.join("\n")
121
- end
122
- private_class_method :format_collection_as_text
123
- end
124
- end
125
- end
126
- end
@@ -1,124 +0,0 @@
1
- module Exa
2
- module CLI
3
- module Formatters
4
- class ResearchFormatter
5
- def self.format_task(task, format, show_events: false)
6
- case format
7
- when "json"
8
- JSON.pretty_generate(task.to_h)
9
- when "pretty"
10
- format_task_pretty(task, show_events: show_events)
11
- when "text"
12
- format_task_text(task, show_events: show_events)
13
- when "toon"
14
- Exa::CLI::Base.encode_as_toon(task.to_h)
15
- else
16
- JSON.pretty_generate(task.to_h)
17
- end
18
- end
19
-
20
- def self.format_list(list, format)
21
- case format
22
- when "json"
23
- JSON.pretty_generate(list.to_h)
24
- when "pretty"
25
- format_list_pretty(list)
26
- when "text"
27
- format_list_text(list)
28
- when "toon"
29
- Exa::CLI::Base.encode_as_toon(list.to_h)
30
- else
31
- JSON.pretty_generate(list.to_h)
32
- end
33
- end
34
-
35
- private
36
-
37
- def self.format_task_pretty(task, show_events: false)
38
- output = []
39
- output << "Research Task: #{task.research_id}"
40
- output << "Status: #{task.status.upcase}"
41
- output << "Created: #{task.created_at}"
42
- output << ""
43
-
44
- case task.status
45
- when "pending"
46
- output << "Task is pending execution..."
47
- when "running"
48
- output << "Task is running... ⚙️"
49
- when "completed"
50
- output << "Output:"
51
- output << "--------"
52
- output << task.output.to_s
53
- output << ""
54
- output << "Cost: $#{task.cost_dollars}" if task.cost_dollars
55
- when "failed"
56
- output << "Error: #{task.error}"
57
- when "canceled"
58
- output << "Task was canceled"
59
- output << "Finished: #{task.finished_at}" if task.finished_at
60
- end
61
-
62
- if show_events && task.events && !task.events.empty?
63
- output << ""
64
- output << "Events:"
65
- output << "-------"
66
- task.events.each do |event|
67
- output << "- #{event}"
68
- end
69
- end
70
-
71
- output.join("\n")
72
- end
73
-
74
- def self.format_list_pretty(list)
75
- output = []
76
- output << "Research Tasks (#{list.data.length}):"
77
- output << ""
78
-
79
- if list.data.empty?
80
- output << "No tasks found."
81
- else
82
- # Simple table format
83
- output << "%-40s %-15s %s" % ["Task ID", "Status", "Created"]
84
- output << "-" * 70
85
-
86
- list.data.each do |task|
87
- task_id = task.research_id.to_s[0..38]
88
- status = task.status.upcase[0..14]
89
- created = task.created_at.to_s[0..19]
90
- output << "%-40s %-15s %s" % [task_id, status, created]
91
- end
92
- end
93
-
94
- output << ""
95
- if list.has_more
96
- output << "More results available. Use --cursor #{list.next_cursor} for next page."
97
- else
98
- output << "End of results."
99
- end
100
-
101
- output.join("\n")
102
- end
103
-
104
- def self.format_task_text(task, show_events: false)
105
- output = []
106
- output << "#{task.research_id} #{task.status.upcase} #{task.created_at}"
107
- if task.status == "completed"
108
- output << task.output.to_s
109
- elsif task.status == "failed"
110
- output << "Error: #{task.error}"
111
- end
112
- output.join("\n")
113
- end
114
-
115
- def self.format_list_text(list)
116
- output = list.data.map do |task|
117
- "#{task.research_id} #{task.status.upcase} #{task.created_at}"
118
- end
119
- output.join("\n")
120
- end
121
- end
122
- end
123
- end
124
- end