activeagent 1.0.0.rc1 → 1.0.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 (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -1
  3. data/lib/active_agent/providers/_base_provider.rb +92 -82
  4. data/lib/active_agent/providers/anthropic/_types.rb +2 -2
  5. data/lib/active_agent/providers/anthropic/request.rb +135 -81
  6. data/lib/active_agent/providers/anthropic/transforms.rb +353 -0
  7. data/lib/active_agent/providers/anthropic_provider.rb +96 -53
  8. data/lib/active_agent/providers/common/messages/_types.rb +37 -1
  9. data/lib/active_agent/providers/common/responses/base.rb +118 -70
  10. data/lib/active_agent/providers/common/usage.rb +385 -0
  11. data/lib/active_agent/providers/concerns/instrumentation.rb +263 -0
  12. data/lib/active_agent/providers/log_subscriber.rb +64 -246
  13. data/lib/active_agent/providers/mock_provider.rb +23 -23
  14. data/lib/active_agent/providers/ollama/chat/request.rb +214 -35
  15. data/lib/active_agent/providers/ollama/chat/transforms.rb +135 -0
  16. data/lib/active_agent/providers/ollama/embedding/request.rb +160 -47
  17. data/lib/active_agent/providers/ollama/embedding/transforms.rb +160 -0
  18. data/lib/active_agent/providers/ollama_provider.rb +0 -1
  19. data/lib/active_agent/providers/open_ai/_base.rb +3 -2
  20. data/lib/active_agent/providers/open_ai/chat/_types.rb +13 -1
  21. data/lib/active_agent/providers/open_ai/chat/request.rb +132 -186
  22. data/lib/active_agent/providers/open_ai/chat/transforms.rb +364 -0
  23. data/lib/active_agent/providers/open_ai/chat_provider.rb +57 -36
  24. data/lib/active_agent/providers/open_ai/embedding/_types.rb +13 -2
  25. data/lib/active_agent/providers/open_ai/embedding/request.rb +38 -70
  26. data/lib/active_agent/providers/open_ai/embedding/transforms.rb +88 -0
  27. data/lib/active_agent/providers/open_ai/responses/_types.rb +1 -7
  28. data/lib/active_agent/providers/open_ai/responses/request.rb +100 -134
  29. data/lib/active_agent/providers/open_ai/responses/transforms.rb +228 -0
  30. data/lib/active_agent/providers/open_ai/responses_provider.rb +77 -30
  31. data/lib/active_agent/providers/open_ai_provider.rb +0 -3
  32. data/lib/active_agent/providers/open_router/_types.rb +27 -1
  33. data/lib/active_agent/providers/open_router/options.rb +49 -1
  34. data/lib/active_agent/providers/open_router/request.rb +232 -66
  35. data/lib/active_agent/providers/open_router/requests/_types.rb +0 -1
  36. data/lib/active_agent/providers/open_router/requests/messages/_types.rb +37 -40
  37. data/lib/active_agent/providers/open_router/requests/messages/content/file.rb +19 -3
  38. data/lib/active_agent/providers/open_router/requests/messages/content/files/details.rb +15 -4
  39. data/lib/active_agent/providers/open_router/requests/plugin.rb +19 -3
  40. data/lib/active_agent/providers/open_router/requests/plugins/pdf_config.rb +30 -8
  41. data/lib/active_agent/providers/open_router/requests/prediction.rb +17 -0
  42. data/lib/active_agent/providers/open_router/requests/provider_preferences/max_price.rb +41 -7
  43. data/lib/active_agent/providers/open_router/requests/provider_preferences.rb +60 -19
  44. data/lib/active_agent/providers/open_router/requests/response_format.rb +30 -2
  45. data/lib/active_agent/providers/open_router/transforms.rb +134 -0
  46. data/lib/active_agent/providers/open_router_provider.rb +9 -0
  47. data/lib/active_agent/version.rb +1 -1
  48. metadata +15 -159
  49. data/lib/active_agent/generation_provider/open_router/types.rb +0 -505
  50. data/lib/active_agent/generation_provider/xai_provider.rb +0 -144
  51. data/lib/active_agent/providers/anthropic/requests/_types.rb +0 -190
  52. data/lib/active_agent/providers/anthropic/requests/container_params.rb +0 -19
  53. data/lib/active_agent/providers/anthropic/requests/content/base.rb +0 -21
  54. data/lib/active_agent/providers/anthropic/requests/content/sources/base.rb +0 -22
  55. data/lib/active_agent/providers/anthropic/requests/context_management_config.rb +0 -18
  56. data/lib/active_agent/providers/anthropic/requests/messages/_types.rb +0 -189
  57. data/lib/active_agent/providers/anthropic/requests/messages/assistant.rb +0 -23
  58. data/lib/active_agent/providers/anthropic/requests/messages/base.rb +0 -63
  59. data/lib/active_agent/providers/anthropic/requests/messages/content/_types.rb +0 -143
  60. data/lib/active_agent/providers/anthropic/requests/messages/content/base.rb +0 -21
  61. data/lib/active_agent/providers/anthropic/requests/messages/content/document.rb +0 -26
  62. data/lib/active_agent/providers/anthropic/requests/messages/content/image.rb +0 -23
  63. data/lib/active_agent/providers/anthropic/requests/messages/content/redacted_thinking.rb +0 -21
  64. data/lib/active_agent/providers/anthropic/requests/messages/content/search_result.rb +0 -27
  65. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/_types.rb +0 -171
  66. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/base.rb +0 -22
  67. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_base64.rb +0 -25
  68. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_file.rb +0 -23
  69. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_text.rb +0 -25
  70. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_url.rb +0 -23
  71. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_base64.rb +0 -27
  72. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_file.rb +0 -23
  73. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_url.rb +0 -23
  74. data/lib/active_agent/providers/anthropic/requests/messages/content/text.rb +0 -22
  75. data/lib/active_agent/providers/anthropic/requests/messages/content/thinking.rb +0 -23
  76. data/lib/active_agent/providers/anthropic/requests/messages/content/tool_result.rb +0 -24
  77. data/lib/active_agent/providers/anthropic/requests/messages/content/tool_use.rb +0 -28
  78. data/lib/active_agent/providers/anthropic/requests/messages/user.rb +0 -21
  79. data/lib/active_agent/providers/anthropic/requests/metadata.rb +0 -18
  80. data/lib/active_agent/providers/anthropic/requests/response_format.rb +0 -22
  81. data/lib/active_agent/providers/anthropic/requests/thinking_config/_types.rb +0 -60
  82. data/lib/active_agent/providers/anthropic/requests/thinking_config/base.rb +0 -20
  83. data/lib/active_agent/providers/anthropic/requests/thinking_config/disabled.rb +0 -16
  84. data/lib/active_agent/providers/anthropic/requests/thinking_config/enabled.rb +0 -20
  85. data/lib/active_agent/providers/anthropic/requests/tool_choice/_types.rb +0 -78
  86. data/lib/active_agent/providers/anthropic/requests/tool_choice/any.rb +0 -17
  87. data/lib/active_agent/providers/anthropic/requests/tool_choice/auto.rb +0 -17
  88. data/lib/active_agent/providers/anthropic/requests/tool_choice/base.rb +0 -20
  89. data/lib/active_agent/providers/anthropic/requests/tool_choice/none.rb +0 -16
  90. data/lib/active_agent/providers/anthropic/requests/tool_choice/tool.rb +0 -20
  91. data/lib/active_agent/providers/ollama/chat/requests/_types.rb +0 -3
  92. data/lib/active_agent/providers/ollama/chat/requests/messages/_types.rb +0 -116
  93. data/lib/active_agent/providers/ollama/chat/requests/messages/assistant.rb +0 -19
  94. data/lib/active_agent/providers/ollama/chat/requests/messages/user.rb +0 -19
  95. data/lib/active_agent/providers/ollama/embedding/requests/_types.rb +0 -83
  96. data/lib/active_agent/providers/ollama/embedding/requests/options.rb +0 -104
  97. data/lib/active_agent/providers/open_ai/chat/requests/_types.rb +0 -229
  98. data/lib/active_agent/providers/open_ai/chat/requests/audio.rb +0 -24
  99. data/lib/active_agent/providers/open_ai/chat/requests/messages/_types.rb +0 -123
  100. data/lib/active_agent/providers/open_ai/chat/requests/messages/assistant.rb +0 -42
  101. data/lib/active_agent/providers/open_ai/chat/requests/messages/base.rb +0 -78
  102. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/_types.rb +0 -133
  103. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/audio.rb +0 -35
  104. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/base.rb +0 -24
  105. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/file.rb +0 -26
  106. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/files/_types.rb +0 -60
  107. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/files/details.rb +0 -41
  108. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/image.rb +0 -37
  109. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/refusal.rb +0 -25
  110. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/text.rb +0 -25
  111. data/lib/active_agent/providers/open_ai/chat/requests/messages/developer.rb +0 -25
  112. data/lib/active_agent/providers/open_ai/chat/requests/messages/function.rb +0 -25
  113. data/lib/active_agent/providers/open_ai/chat/requests/messages/system.rb +0 -25
  114. data/lib/active_agent/providers/open_ai/chat/requests/messages/tool.rb +0 -26
  115. data/lib/active_agent/providers/open_ai/chat/requests/messages/user.rb +0 -32
  116. data/lib/active_agent/providers/open_ai/chat/requests/prediction.rb +0 -46
  117. data/lib/active_agent/providers/open_ai/chat/requests/response_format.rb +0 -53
  118. data/lib/active_agent/providers/open_ai/chat/requests/stream_options.rb +0 -24
  119. data/lib/active_agent/providers/open_ai/chat/requests/tool_choice.rb +0 -26
  120. data/lib/active_agent/providers/open_ai/chat/requests/tools/_types.rb +0 -5
  121. data/lib/active_agent/providers/open_ai/chat/requests/tools/base.rb +0 -22
  122. data/lib/active_agent/providers/open_ai/chat/requests/tools/custom_tool.rb +0 -41
  123. data/lib/active_agent/providers/open_ai/chat/requests/tools/function_tool.rb +0 -51
  124. data/lib/active_agent/providers/open_ai/chat/requests/web_search_options.rb +0 -45
  125. data/lib/active_agent/providers/open_ai/embedding/requests/_types.rb +0 -49
  126. data/lib/active_agent/providers/open_ai/responses/requests/_types.rb +0 -231
  127. data/lib/active_agent/providers/open_ai/responses/requests/conversation.rb +0 -23
  128. data/lib/active_agent/providers/open_ai/responses/requests/inputs/_types.rb +0 -264
  129. data/lib/active_agent/providers/open_ai/responses/requests/inputs/assistant_message.rb +0 -22
  130. data/lib/active_agent/providers/open_ai/responses/requests/inputs/base.rb +0 -89
  131. data/lib/active_agent/providers/open_ai/responses/requests/inputs/code_interpreter_tool_call.rb +0 -30
  132. data/lib/active_agent/providers/open_ai/responses/requests/inputs/computer_tool_call.rb +0 -28
  133. data/lib/active_agent/providers/open_ai/responses/requests/inputs/computer_tool_call_output.rb +0 -33
  134. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/_types.rb +0 -207
  135. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/base.rb +0 -22
  136. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_audio.rb +0 -26
  137. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_file.rb +0 -28
  138. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_image.rb +0 -28
  139. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_text.rb +0 -25
  140. data/lib/active_agent/providers/open_ai/responses/requests/inputs/custom_tool_call.rb +0 -28
  141. data/lib/active_agent/providers/open_ai/responses/requests/inputs/custom_tool_call_output.rb +0 -27
  142. data/lib/active_agent/providers/open_ai/responses/requests/inputs/developer_message.rb +0 -20
  143. data/lib/active_agent/providers/open_ai/responses/requests/inputs/file_search_tool_call.rb +0 -25
  144. data/lib/active_agent/providers/open_ai/responses/requests/inputs/function_call_output.rb +0 -32
  145. data/lib/active_agent/providers/open_ai/responses/requests/inputs/function_tool_call.rb +0 -28
  146. data/lib/active_agent/providers/open_ai/responses/requests/inputs/image_gen_tool_call.rb +0 -27
  147. data/lib/active_agent/providers/open_ai/responses/requests/inputs/input_message.rb +0 -31
  148. data/lib/active_agent/providers/open_ai/responses/requests/inputs/item_reference.rb +0 -23
  149. data/lib/active_agent/providers/open_ai/responses/requests/inputs/local_shell_tool_call.rb +0 -26
  150. data/lib/active_agent/providers/open_ai/responses/requests/inputs/local_shell_tool_call_output.rb +0 -33
  151. data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_approval_request.rb +0 -30
  152. data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_approval_response.rb +0 -28
  153. data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_list_tools.rb +0 -29
  154. data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_tool_call.rb +0 -35
  155. data/lib/active_agent/providers/open_ai/responses/requests/inputs/output_message.rb +0 -35
  156. data/lib/active_agent/providers/open_ai/responses/requests/inputs/reasoning.rb +0 -33
  157. data/lib/active_agent/providers/open_ai/responses/requests/inputs/system_message.rb +0 -20
  158. data/lib/active_agent/providers/open_ai/responses/requests/inputs/tool_call_base.rb +0 -27
  159. data/lib/active_agent/providers/open_ai/responses/requests/inputs/tool_message.rb +0 -23
  160. data/lib/active_agent/providers/open_ai/responses/requests/inputs/user_message.rb +0 -20
  161. data/lib/active_agent/providers/open_ai/responses/requests/inputs/web_search_tool_call.rb +0 -24
  162. data/lib/active_agent/providers/open_ai/responses/requests/prompt_reference.rb +0 -23
  163. data/lib/active_agent/providers/open_ai/responses/requests/reasoning.rb +0 -23
  164. data/lib/active_agent/providers/open_ai/responses/requests/stream_options.rb +0 -20
  165. data/lib/active_agent/providers/open_ai/responses/requests/text/_types.rb +0 -89
  166. data/lib/active_agent/providers/open_ai/responses/requests/text/base.rb +0 -22
  167. data/lib/active_agent/providers/open_ai/responses/requests/text/json_object.rb +0 -20
  168. data/lib/active_agent/providers/open_ai/responses/requests/text/json_schema.rb +0 -48
  169. data/lib/active_agent/providers/open_ai/responses/requests/text/plain.rb +0 -20
  170. data/lib/active_agent/providers/open_ai/responses/requests/text.rb +0 -41
  171. data/lib/active_agent/providers/open_ai/responses/requests/tool_choice.rb +0 -26
  172. data/lib/active_agent/providers/open_ai/responses/requests/tools/_types.rb +0 -112
  173. data/lib/active_agent/providers/open_ai/responses/requests/tools/base.rb +0 -25
  174. data/lib/active_agent/providers/open_ai/responses/requests/tools/code_interpreter_tool.rb +0 -23
  175. data/lib/active_agent/providers/open_ai/responses/requests/tools/computer_tool.rb +0 -27
  176. data/lib/active_agent/providers/open_ai/responses/requests/tools/custom_tool.rb +0 -28
  177. data/lib/active_agent/providers/open_ai/responses/requests/tools/file_search_tool.rb +0 -27
  178. data/lib/active_agent/providers/open_ai/responses/requests/tools/function_tool.rb +0 -29
  179. data/lib/active_agent/providers/open_ai/responses/requests/tools/image_generation_tool.rb +0 -37
  180. data/lib/active_agent/providers/open_ai/responses/requests/tools/local_shell_tool.rb +0 -21
  181. data/lib/active_agent/providers/open_ai/responses/requests/tools/mcp_tool.rb +0 -41
  182. data/lib/active_agent/providers/open_ai/responses/requests/tools/web_search_preview_tool.rb +0 -24
  183. data/lib/active_agent/providers/open_ai/responses/requests/tools/web_search_tool.rb +0 -25
  184. data/lib/active_agent/providers/open_ai/schema.yml +0 -65937
  185. data/lib/active_agent/providers/open_router/requests/message.rb +0 -1
  186. data/lib/active_agent/providers/open_router/requests/messages/assistant.rb +0 -20
  187. data/lib/active_agent/providers/open_router/requests/messages/user.rb +0 -30
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_agent/providers/common/model"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- # Tool choice configuration for Responses API
11
- # Controls how the model should select which tool (or tools) to use when generating a response.
12
- class ToolChoice < Common::BaseModel
13
- # Can be string ("none", "auto", "required") or object with type and tool details
14
- attribute :mode, :string
15
- attribute :type, :string
16
- attribute :function # Hash with name
17
- attribute :custom # Hash with name
18
-
19
- validates :mode, inclusion: { in: %w[none auto required] }, allow_nil: true
20
- validates :type, inclusion: { in: %w[function custom] }, allow_nil: true
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,112 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
- require_relative "code_interpreter_tool"
5
- require_relative "computer_tool"
6
- require_relative "custom_tool"
7
- require_relative "file_search_tool"
8
- require_relative "function_tool"
9
- require_relative "image_generation_tool"
10
- require_relative "local_shell_tool"
11
- require_relative "mcp_tool"
12
- require_relative "web_search_preview_tool"
13
- require_relative "web_search_tool"
14
-
15
- module ActiveAgent
16
- module Providers
17
- module OpenAI
18
- module Responses
19
- module Requests
20
- module Tools
21
- # Type for collection of tools
22
- class ToolsType < ActiveModel::Type::Value
23
- def initialize
24
- super
25
- @tool_type = ToolType.new
26
- end
27
-
28
- def cast(value)
29
- return nil if value.nil?
30
- return [] if value == []
31
-
32
- array = Array(value)
33
- array.map { |tool| @tool_type.cast(tool) }
34
- end
35
-
36
- def serialize(value)
37
- return nil if value.nil?
38
- return [] if value == []
39
-
40
- array = Array(value)
41
- array.map { |tool| @tool_type.serialize(tool) }
42
- end
43
-
44
- def deserialize(value)
45
- cast(value)
46
- end
47
- end
48
-
49
- # Type for individual tool
50
- class ToolType < ActiveModel::Type::Value
51
- def cast(value)
52
- case value
53
- when Base
54
- value
55
- when Hash
56
- hash = value.deep_symbolize_keys
57
- type = hash[:type]&.to_sym
58
-
59
- case type
60
- when :function
61
- FunctionTool.new(**hash)
62
- when :custom
63
- CustomTool.new(**hash)
64
- when :web_search, :web_search_2025_08_26
65
- WebSearchTool.new(**hash)
66
- when :web_search_preview, :web_search_preview_2025_03_11
67
- WebSearchPreviewTool.new(**hash)
68
- when :code_interpreter
69
- CodeInterpreterTool.new(**hash)
70
- when :file_search
71
- FileSearchTool.new(**hash)
72
- when :computer_use_preview
73
- ComputerTool.new(**hash)
74
- when :mcp
75
- McpTool.new(**hash)
76
- when :image_generation
77
- ImageGenerationTool.new(**hash)
78
- when :local_shell
79
- LocalShellTool.new(**hash)
80
- else
81
- raise ArgumentError, "Unknown tool type: #{type.inspect}"
82
- end
83
- when nil
84
- nil
85
- else
86
- raise ArgumentError, "Cannot cast #{value.class} to Tool (expected Base, Hash, or nil)"
87
- end
88
- end
89
-
90
- def serialize(value)
91
- case value
92
- when Base
93
- value.serialize
94
- when Hash
95
- value
96
- when nil
97
- nil
98
- else
99
- raise ArgumentError, "Cannot serialize #{value.class} as Tool"
100
- end
101
- end
102
-
103
- def deserialize(value)
104
- cast(value)
105
- end
106
- end
107
- end
108
- end
109
- end
110
- end
111
- end
112
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_agent/providers/common/model"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Base class for tools in Responses API
12
- class Base < Common::BaseModel
13
- attribute :type, :string
14
-
15
- validates :type, inclusion: {
16
- in: %w[function custom web_search web_search_2025_08_26 code_interpreter file_search computer_use_preview mcp image_generation local_shell web_search_preview web_search_preview_2025_03_11],
17
- allow_nil: true
18
- }
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Built-in code interpreter tool
12
- class CodeInterpreterTool < Base
13
- attribute :type, :string, as: "code_interpreter"
14
- attribute :container # Required: can be string (container ID) or hash { type: "auto", file_ids: [] }
15
-
16
- validates :container, presence: true
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Built-in computer tool (note: type should be "computer_use_preview" per schema)
12
- class ComputerTool < Base
13
- attribute :type, :string, as: "computer_use_preview"
14
- attribute :display_height, :integer # Required: height of the computer display
15
- attribute :display_width, :integer # Required: width of the computer display
16
- attribute :environment, :string # Required: type of computer environment to control
17
-
18
- validates :display_height, presence: true, numericality: { greater_than: 0 }
19
- validates :display_width, presence: true, numericality: { greater_than: 0 }
20
- validates :environment, presence: true
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Custom tool
12
- class CustomTool < Base
13
- attribute :type, :string, as: "custom"
14
- attribute :name, :string # Required: name of the custom tool
15
- attribute :description, :string # Optional: description
16
- attribute :format # Optional: hash with input format
17
- # Can be { type: "text" } for unconstrained text
18
- # Or { type: "grammar", definition: string, syntax: "lark"|"regex" }
19
-
20
- validates :name, presence: true, length: { maximum: 64 }
21
- validates :name, format: { with: /\A[a-zA-Z0-9_-]+\z/, message: "must contain only a-z, A-Z, 0-9, underscores and dashes" }, if: -> { name.present? }
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Built-in file search tool
12
- class FileSearchTool < Base
13
- attribute :type, :string, as: "file_search"
14
- attribute :vector_store_ids # Array - required: The IDs of the vector stores to search
15
- attribute :filters # Hash - optional: A filter to apply
16
- attribute :max_num_results, :integer # Optional: maximum number of results (1-50)
17
- attribute :ranking_options # Hash - optional: { ranker: string, score_threshold: number }
18
-
19
- validates :vector_store_ids, presence: true
20
- validates :max_num_results, numericality: { greater_than_or_equal_to: 1, less_than_or_equal_to: 50 }, allow_nil: true
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Function tool for custom function calling
12
- class FunctionTool < Base
13
- attribute :type, :string, as: "function"
14
- attribute :name, :string
15
- attribute :parameters # Hash - JSON Schema object (required)
16
- attribute :strict, :boolean # Required - whether to enforce strict parameter validation (default true)
17
- attribute :description, :string # Optional description
18
-
19
- validates :name, presence: true, length: { maximum: 64 }
20
- validates :name, format: { with: /\A[a-zA-Z0-9_-]+\z/, message: "must contain only a-z, A-Z, 0-9, underscores and dashes" }, if: -> { name.present? }
21
- validates :parameters, presence: true
22
- validates :strict, inclusion: { in: [ true, false ] }, allow_nil: false
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Image generation tool
12
- class ImageGenerationTool < Base
13
- attribute :type, :string, as: "image_generation"
14
- attribute :background, :string, default: "auto" # Optional: "transparent", "opaque", or "auto"
15
- attribute :input_fidelity, :string, default: "low" # Optional: "high" or "low"
16
- attribute :input_image_mask # Optional: hash with image_url and/or file_id
17
- attribute :model, :string, default: "gpt-image-1" # Optional: model to use
18
- attribute :moderation, :string, default: "auto" # Optional: moderation level
19
- attribute :output_compression, :integer, default: 100 # Optional: compression level
20
- attribute :output_format, :string, default: "png" # Optional: "png", "webp", or "jpeg"
21
- attribute :partial_images, :integer, default: 0 # Optional: 0-3
22
- attribute :quality, :string, default: "auto" # Optional: "low", "medium", "high", or "auto"
23
- attribute :size, :string, default: "auto" # Optional: "1024x1024", "1024x1536", "1536x1024", or "auto"
24
-
25
- validates :background, inclusion: { in: %w[transparent opaque auto] }, allow_nil: true
26
- validates :input_fidelity, inclusion: { in: %w[high low] }, allow_nil: true
27
- validates :output_format, inclusion: { in: %w[png webp jpeg] }, allow_nil: true
28
- validates :partial_images, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 3 }, allow_nil: true
29
- validates :quality, inclusion: { in: %w[low medium high auto] }, allow_nil: true
30
- validates :size, inclusion: { in: %w[1024x1024 1024x1536 1536x1024 auto] }, allow_nil: true
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Local shell tool
12
- class LocalShellTool < Base
13
- attribute :type, :string, as: "local_shell"
14
- attribute :local_shell # Hash with optional configuration
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # MCP (Model Context Protocol) tool
12
- class McpTool < Base
13
- attribute :type, :string, as: "mcp"
14
- attribute :server_label, :string # Required: label for this MCP server
15
- attribute :allowed_tools # Optional: array of tool names or filter object
16
- attribute :authorization, :string # Optional: OAuth access token
17
- attribute :connector_id, :string # Optional: service connector ID (e.g., "connector_googledrive")
18
- attribute :headers # Optional: hash of HTTP headers
19
- attribute :require_approval # Optional: string ("always"/"never") or object with approval filters
20
- attribute :server_description, :string # Optional: description of the MCP server
21
- attribute :server_url, :string # Optional: URL for the MCP server
22
-
23
- validates :server_label, presence: true
24
-
25
- # Either server_url or connector_id must be provided
26
- validate :validate_server_url_or_connector_id
27
-
28
- private
29
-
30
- def validate_server_url_or_connector_id
31
- if server_url.blank? && connector_id.blank?
32
- errors.add(:base, "Either server_url or connector_id must be provided")
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Web search preview tool (older version)
12
- class WebSearchPreviewTool < Base
13
- attribute :type, :string, as: "web_search_preview" # Can be "web_search_preview" or "web_search_preview_2025_03_11"
14
- attribute :search_context_size, :string # Optional: "low", "medium", or "high"
15
- attribute :user_location # Hash - optional: { type: "approximate", city, country, region, timezone }
16
-
17
- validates :search_context_size, inclusion: { in: %w[low medium high] }, allow_nil: true
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Responses
9
- module Requests
10
- module Tools
11
- # Built-in web search tool
12
- class WebSearchTool < Base
13
- attribute :type, :string, as: "web_search" # Can be "web_search" or "web_search_2025_08_26"
14
- attribute :filters # Hash - optional: { allowed_domains: [] }
15
- attribute :search_context_size, :string, default: "medium" # Optional: "low", "medium", or "high"
16
- attribute :user_location # Hash - optional: { type: "approximate", city, country, region, timezone }
17
-
18
- validates :search_context_size, inclusion: { in: %w[low medium high] }, allow_nil: true
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end