ruboty-ai_agent 0.1.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 +7 -0
- data/.gitignore +19 -0
- data/.rspec +3 -0
- data/.rubocop.yml +45 -0
- data/AGENTS.md +22 -0
- data/CHANGELOG.md +3 -0
- data/CLAUDE.md +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +14 -0
- data/README.md +118 -0
- data/Rakefile +47 -0
- data/Steepfile +12 -0
- data/bin/console +15 -0
- data/bin/ruboty +34 -0
- data/bin/setup +8 -0
- data/lib/ruboty/ai_agent/actions/add_ai_command.rb +22 -0
- data/lib/ruboty/ai_agent/actions/add_ai_memory.rb +20 -0
- data/lib/ruboty/ai_agent/actions/add_mcp.rb +94 -0
- data/lib/ruboty/ai_agent/actions/base.rb +43 -0
- data/lib/ruboty/ai_agent/actions/chat.rb +64 -0
- data/lib/ruboty/ai_agent/actions/list_ai_commands.rb +19 -0
- data/lib/ruboty/ai_agent/actions/list_ai_memories.rb +18 -0
- data/lib/ruboty/ai_agent/actions/list_mcp.rb +18 -0
- data/lib/ruboty/ai_agent/actions/remove_ai_command.rb +18 -0
- data/lib/ruboty/ai_agent/actions/remove_ai_memory.rb +25 -0
- data/lib/ruboty/ai_agent/actions/remove_mcp.rb +24 -0
- data/lib/ruboty/ai_agent/actions/set_system_prompt.rb +31 -0
- data/lib/ruboty/ai_agent/actions/show_system_prompt.rb +30 -0
- data/lib/ruboty/ai_agent/actions.rb +22 -0
- data/lib/ruboty/ai_agent/agent.rb +71 -0
- data/lib/ruboty/ai_agent/cached_value.rb +43 -0
- data/lib/ruboty/ai_agent/chat_message.rb +60 -0
- data/lib/ruboty/ai_agent/chat_thread.rb +31 -0
- data/lib/ruboty/ai_agent/chat_thread_associations.rb +34 -0
- data/lib/ruboty/ai_agent/chat_thread_messages.rb +17 -0
- data/lib/ruboty/ai_agent/commands/base.rb +39 -0
- data/lib/ruboty/ai_agent/commands/clear.rb +29 -0
- data/lib/ruboty/ai_agent/commands/compact.rb +80 -0
- data/lib/ruboty/ai_agent/commands/usage.rb +52 -0
- data/lib/ruboty/ai_agent/commands.rb +33 -0
- data/lib/ruboty/ai_agent/database/query_methods.rb +84 -0
- data/lib/ruboty/ai_agent/database.rb +40 -0
- data/lib/ruboty/ai_agent/global_settings.rb +33 -0
- data/lib/ruboty/ai_agent/http_mcp_client.rb +215 -0
- data/lib/ruboty/ai_agent/llm/openai/model.rb +29 -0
- data/lib/ruboty/ai_agent/llm/openai.rb +181 -0
- data/lib/ruboty/ai_agent/llm/response.rb +21 -0
- data/lib/ruboty/ai_agent/llm.rb +11 -0
- data/lib/ruboty/ai_agent/mcp_clients.rb +48 -0
- data/lib/ruboty/ai_agent/mcp_configuration.rb +31 -0
- data/lib/ruboty/ai_agent/record_set.rb +71 -0
- data/lib/ruboty/ai_agent/recordable.rb +116 -0
- data/lib/ruboty/ai_agent/token_usage.rb +45 -0
- data/lib/ruboty/ai_agent/tool.rb +29 -0
- data/lib/ruboty/ai_agent/user.rb +52 -0
- data/lib/ruboty/ai_agent/user_ai_memories.rb +17 -0
- data/lib/ruboty/ai_agent/user_associations.rb +34 -0
- data/lib/ruboty/ai_agent/user_mcp_caches.rb +90 -0
- data/lib/ruboty/ai_agent/user_mcp_client.rb +93 -0
- data/lib/ruboty/ai_agent/user_mcp_configurations.rb +15 -0
- data/lib/ruboty/ai_agent/user_mcp_tools_caches.rb +14 -0
- data/lib/ruboty/ai_agent/version.rb +7 -0
- data/lib/ruboty/ai_agent.rb +40 -0
- data/lib/ruboty/handlers/ai_agent.rb +84 -0
- data/rbs_collection.yaml +23 -0
- data/ruboty-ai_agent.gemspec +49 -0
- data/script/generate-concern-rbs.rb +351 -0
- data/script/generate-data-rbs.rb +250 -0
- data/script/generate-memorized-ivar-rbs.rb +292 -0
- data/sig/generated/ruboty/ai_agent/actions/add_ai_command.rbs +16 -0
- data/sig/generated/ruboty/ai_agent/actions/add_ai_memory.rbs +14 -0
- data/sig/generated/ruboty/ai_agent/actions/add_mcp.rbs +26 -0
- data/sig/generated/ruboty/ai_agent/actions/base.rbs +34 -0
- data/sig/generated/ruboty/ai_agent/actions/chat.rbs +17 -0
- data/sig/generated/ruboty/ai_agent/actions/list_ai_commands.rbs +13 -0
- data/sig/generated/ruboty/ai_agent/actions/list_ai_memories.rbs +12 -0
- data/sig/generated/ruboty/ai_agent/actions/list_mcp.rbs +12 -0
- data/sig/generated/ruboty/ai_agent/actions/remove_ai_command.rbs +14 -0
- data/sig/generated/ruboty/ai_agent/actions/remove_ai_memory.rbs +14 -0
- data/sig/generated/ruboty/ai_agent/actions/remove_mcp.rbs +14 -0
- data/sig/generated/ruboty/ai_agent/actions/set_system_prompt.rbs +16 -0
- data/sig/generated/ruboty/ai_agent/actions/show_system_prompt.rbs +12 -0
- data/sig/generated/ruboty/ai_agent/actions.rbs +9 -0
- data/sig/generated/ruboty/ai_agent/agent.rbs +29 -0
- data/sig/generated/ruboty/ai_agent/cached_value.rbs +28 -0
- data/sig/generated/ruboty/ai_agent/chat_message.rbs +34 -0
- data/sig/generated/ruboty/ai_agent/chat_thread.rbs +22 -0
- data/sig/generated/ruboty/ai_agent/chat_thread_associations.rbs +21 -0
- data/sig/generated/ruboty/ai_agent/chat_thread_messages.rbs +13 -0
- data/sig/generated/ruboty/ai_agent/commands/base.rbs +40 -0
- data/sig/generated/ruboty/ai_agent/commands/clear.rbs +20 -0
- data/sig/generated/ruboty/ai_agent/commands/compact.rbs +30 -0
- data/sig/generated/ruboty/ai_agent/commands/usage.rbs +26 -0
- data/sig/generated/ruboty/ai_agent/commands.rbs +13 -0
- data/sig/generated/ruboty/ai_agent/database/query_methods.rbs +39 -0
- data/sig/generated/ruboty/ai_agent/database.rbs +27 -0
- data/sig/generated/ruboty/ai_agent/global_settings.rbs +23 -0
- data/sig/generated/ruboty/ai_agent/http_mcp_client.rbs +62 -0
- data/sig/generated/ruboty/ai_agent/llm/openai/model.rbs +21 -0
- data/sig/generated/ruboty/ai_agent/llm/openai.rbs +54 -0
- data/sig/generated/ruboty/ai_agent/llm/response.rbs +29 -0
- data/sig/generated/ruboty/ai_agent/llm.rbs +9 -0
- data/sig/generated/ruboty/ai_agent/mcp_clients.rbs +24 -0
- data/sig/generated/ruboty/ai_agent/mcp_configuration.rbs +35 -0
- data/sig/generated/ruboty/ai_agent/record_set.rbs +42 -0
- data/sig/generated/ruboty/ai_agent/recordable.rbs +56 -0
- data/sig/generated/ruboty/ai_agent/token_usage.rbs +30 -0
- data/sig/generated/ruboty/ai_agent/tool.rbs +27 -0
- data/sig/generated/ruboty/ai_agent/user.rbs +35 -0
- data/sig/generated/ruboty/ai_agent/user_ai_memories.rbs +11 -0
- data/sig/generated/ruboty/ai_agent/user_associations.rbs +21 -0
- data/sig/generated/ruboty/ai_agent/user_mcp_caches.rbs +44 -0
- data/sig/generated/ruboty/ai_agent/user_mcp_client.rbs +58 -0
- data/sig/generated/ruboty/ai_agent/user_mcp_configurations.rbs +11 -0
- data/sig/generated/ruboty/ai_agent/user_mcp_tools_caches.rbs +11 -0
- data/sig/generated/ruboty/ai_agent/version.rbs +7 -0
- data/sig/generated/ruboty/ai_agent.rbs +9 -0
- data/sig/generated/ruboty/handlers/ai_agent.rbs +32 -0
- data/sig/generated-by-scripts/concerns.rbs +27 -0
- data/sig/generated-by-scripts/memorized_ivars.rbs +42 -0
- data/sig-lib/event_stream_parser/event_stream_parser.rbs +21 -0
- data/sig-lib/mem/mem.rbs +19 -0
- data/sig-lib/ruboty/ruboty.rbs +421 -0
- metadata +263 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/actions/remove_ai_memory.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module Actions
|
6
|
+
# RemoveAiMemory action for Ruboty::AiAgent
|
7
|
+
class RemoveAiMemory < Base
|
8
|
+
def call: () -> untyped
|
9
|
+
|
10
|
+
def index_param: () -> String
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/actions/remove_mcp.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module Actions
|
6
|
+
# RemoveMcp action for Ruboty::AiAgent
|
7
|
+
class RemoveMcp < Base
|
8
|
+
def call: () -> untyped
|
9
|
+
|
10
|
+
def name_param: () -> String
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/actions/set_system_prompt.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module Actions
|
6
|
+
# SetSystemPrompt action for Ruboty::AiAgent
|
7
|
+
class SetSystemPrompt < Base
|
8
|
+
def call: () -> untyped
|
9
|
+
|
10
|
+
def prompt_param: () -> String
|
11
|
+
|
12
|
+
def scope_param: () -> String
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/actions/show_system_prompt.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module Actions
|
6
|
+
# ShowSystemPrompt action for Ruboty::AiAgent
|
7
|
+
class ShowSystemPrompt < Base
|
8
|
+
def call: () -> untyped
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/agent.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Agent class to interact with LLM and manage conversations.
|
6
|
+
class Agent
|
7
|
+
attr_reader llm: LLM::OpenAI
|
8
|
+
|
9
|
+
attr_reader messages: Array[ChatMessage]
|
10
|
+
|
11
|
+
attr_reader tools: Array[Tool]
|
12
|
+
|
13
|
+
# @rbs llm: LLM::OpenAI
|
14
|
+
# @rbs messages: Array[ChatMessage]
|
15
|
+
# @rbs tools: Array[Tool]
|
16
|
+
def initialize: (llm: LLM::OpenAI, ?messages: Array[ChatMessage], ?tools: Array[Tool]) -> untyped
|
17
|
+
|
18
|
+
def complete: () ?{ (?) -> untyped } -> untyped
|
19
|
+
|
20
|
+
def on_new_message: (untyped message) ?{ (?) -> untyped } -> untyped
|
21
|
+
|
22
|
+
def on_tool_call: (tool: untyped, tool_arguments: untyped) ?{ (?) -> untyped } -> untyped
|
23
|
+
|
24
|
+
def on_tool_response: (tool_response: untyped, message: untyped) ?{ (?) -> untyped } -> untyped
|
25
|
+
|
26
|
+
def on_response: (untyped response) ?{ (?) -> untyped } -> untyped
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/cached_value.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Cache for MCP operations
|
6
|
+
# @rbs generic D < Object
|
7
|
+
class CachedValue[D < Object]
|
8
|
+
include Recordable
|
9
|
+
|
10
|
+
attr_reader expires_at: Time
|
11
|
+
|
12
|
+
attr_reader data: D
|
13
|
+
|
14
|
+
# @rbs data: D
|
15
|
+
# @rbs expires_at: Time
|
16
|
+
def initialize: (data: D, expires_at: Time) -> untyped
|
17
|
+
|
18
|
+
# @rbs return: Hash[Symbol, untyped]
|
19
|
+
def to_h: () -> Hash[Symbol, untyped]
|
20
|
+
|
21
|
+
# @rbs return: bool
|
22
|
+
def expired?: () -> bool
|
23
|
+
|
24
|
+
# @rbs return: bool
|
25
|
+
def valid?: () -> bool
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/chat_message.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Save MCP configuration details.
|
6
|
+
class ChatMessage
|
7
|
+
include Recordable
|
8
|
+
|
9
|
+
attr_reader role: Symbol
|
10
|
+
|
11
|
+
attr_reader content: String
|
12
|
+
|
13
|
+
attr_reader tool_call_id: String?
|
14
|
+
|
15
|
+
attr_reader tool_name: String?
|
16
|
+
|
17
|
+
attr_reader tool_arguments: Hash[Symbol | String, untyped]?
|
18
|
+
|
19
|
+
attr_reader token_usage: TokenUsage?
|
20
|
+
|
21
|
+
# @rbs role: Symbol
|
22
|
+
# @rbs content: String
|
23
|
+
# @rbs ?tool_call_id: String?
|
24
|
+
# @rbs ?tool_name: String?
|
25
|
+
# @rbs ?tool_arguments: Hash[Symbol | String, untyped]?
|
26
|
+
# @rbs ?token_usage: TokenUsage?
|
27
|
+
def initialize: (role: Symbol, content: String, ?tool_call_id: untyped, ?tool_name: untyped, ?tool_arguments: untyped, ?token_usage: untyped) -> untyped
|
28
|
+
|
29
|
+
def to_h: () -> Hash[Symbol, untyped]
|
30
|
+
|
31
|
+
def self.from_llm_response: (tool: untyped, tool_call_id: untyped, tool_arguments: untyped, tool_response: untyped) -> ChatMessage
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/chat_thread.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Manage thread-specific data.
|
6
|
+
class ChatThread
|
7
|
+
attr_reader database: Ruboty::AiAgent::Database
|
8
|
+
|
9
|
+
attr_reader id: String
|
10
|
+
|
11
|
+
def self.find_or_create: (database: untyped, id: untyped) -> ChatThread
|
12
|
+
|
13
|
+
def initialize: (database: untyped, id: untyped) -> untyped
|
14
|
+
|
15
|
+
# @rbs %a{memorized}
|
16
|
+
%a{memorized}
|
17
|
+
def messages: () -> ChatThreadMessages
|
18
|
+
|
19
|
+
def clear: () -> void
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/chat_thread_associations.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# A set of records for a specific thread.
|
6
|
+
# @rbs generic Record
|
7
|
+
class ChatThreadAssociations[Record] < RecordSet[Record]
|
8
|
+
attr_reader chat_thread_id: String
|
9
|
+
|
10
|
+
def initialize: (database: untyped, chat_thread_id: untyped) -> untyped
|
11
|
+
|
12
|
+
def self.association_key: () -> Symbol
|
13
|
+
|
14
|
+
def self.association_key=: (Symbol) -> Symbol
|
15
|
+
|
16
|
+
def association_key: () -> Symbol
|
17
|
+
|
18
|
+
def namespace_keys: () -> untyped
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/chat_thread_messages.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Manage messages for the chat thread.
|
6
|
+
class ChatThreadMessages < ChatThreadAssociations[ChatMessage]
|
7
|
+
# @rbs message: ChatMessage
|
8
|
+
def add: (ChatMessage message) -> void
|
9
|
+
|
10
|
+
alias << add
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/commands/base.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module Commands
|
6
|
+
# Base class for commands.
|
7
|
+
# @abstract
|
8
|
+
class Base
|
9
|
+
class Matcher < Data
|
10
|
+
attr_reader pattern(): untyped
|
11
|
+
|
12
|
+
attr_reader description(): untyped
|
13
|
+
|
14
|
+
attr_reader name(): untyped
|
15
|
+
|
16
|
+
def self.new: (untyped pattern, untyped description, untyped name) -> instance
|
17
|
+
| (pattern: untyped, description: untyped, name: untyped) -> instance
|
18
|
+
|
19
|
+
def self.members: () -> [ :pattern, :description, :name ]
|
20
|
+
|
21
|
+
def members: () -> [ :pattern, :description, :name ]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.matchers: () -> Array[Matcher]
|
25
|
+
|
26
|
+
def self.on: (untyped pattern, name: untyped, description: untyped) -> untyped
|
27
|
+
|
28
|
+
# @rbs *args: untyped
|
29
|
+
# @rbs return: void
|
30
|
+
def call: (*untyped args) -> void
|
31
|
+
|
32
|
+
# @rbs commandline: String
|
33
|
+
# @rbs return: boolish
|
34
|
+
def match?: (String commandline) -> boolish
|
35
|
+
|
36
|
+
def matchers: () -> Array[Matcher]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/commands/clear.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module Commands
|
6
|
+
# Clear histories of the chat thread.
|
7
|
+
class Clear < Base
|
8
|
+
attr_reader message: Ruboty::Message
|
9
|
+
|
10
|
+
attr_reader chat_thread: Ruboty::AiAgent::ChatThread
|
11
|
+
|
12
|
+
# @rbs message: Ruboty::Message
|
13
|
+
# @rbs chat_thread: Ruboty::AiAgent::ChatThread
|
14
|
+
def initialize: (message: Ruboty::Message, chat_thread: Ruboty::AiAgent::ChatThread) -> untyped
|
15
|
+
|
16
|
+
def call: () -> void
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/commands/compact.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module Commands
|
6
|
+
# Compact chat history by summarizing it
|
7
|
+
class Compact < Base
|
8
|
+
attr_reader message: Ruboty::Message
|
9
|
+
|
10
|
+
attr_reader chat_thread: Ruboty::AiAgent::ChatThread
|
11
|
+
|
12
|
+
# @rbs message: Ruboty::Message
|
13
|
+
# @rbs chat_thread: Ruboty::AiAgent::ChatThread
|
14
|
+
def initialize: (message: Ruboty::Message, chat_thread: Ruboty::AiAgent::ChatThread) -> untyped
|
15
|
+
|
16
|
+
def call: () -> void
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @rbs messages: Array[ChatMessage]
|
21
|
+
# @rbs return: String
|
22
|
+
def generate_summary: (Array[ChatMessage] messages) -> String
|
23
|
+
|
24
|
+
# @rbs messages: Array[ChatMessage]
|
25
|
+
# @rbs return: String
|
26
|
+
def format_messages_for_summary: (Array[ChatMessage] messages) -> String
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/commands/usage.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module Commands
|
6
|
+
# Show token usage information for the latest AI response
|
7
|
+
class Usage < Base
|
8
|
+
attr_reader message: Ruboty::Message
|
9
|
+
|
10
|
+
attr_reader chat_thread: Ruboty::AiAgent::ChatThread
|
11
|
+
|
12
|
+
# @rbs message: Ruboty::Message
|
13
|
+
# @rbs chat_thread: Ruboty::AiAgent::ChatThread
|
14
|
+
def initialize: (message: Ruboty::Message, chat_thread: Ruboty::AiAgent::ChatThread) -> untyped
|
15
|
+
|
16
|
+
def call: () -> void
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @rbs number: Integer
|
21
|
+
# @rbs return: String
|
22
|
+
def format_number: (Integer number) -> String
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/commands.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Interaction commands (a.k.a. Slash commands, Prompts, etc)
|
6
|
+
module Commands
|
7
|
+
# @rbs message: Ruboty::Message
|
8
|
+
# @rbs chat_thread: ChatThread
|
9
|
+
# @rbs return: Array[Commands::Base]
|
10
|
+
def self.builtins: (message: Ruboty::Message, chat_thread: ChatThread) -> Array[Commands::Base]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/database/query_methods.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
class Database
|
6
|
+
interface _WithData
|
7
|
+
def data: () -> Hash[keynable, untyped]
|
8
|
+
end
|
9
|
+
|
10
|
+
# @rbs module-self _WithData
|
11
|
+
module QueryMethods : _WithData
|
12
|
+
# @rbs *keys: keynable
|
13
|
+
# @rbs return: untyped
|
14
|
+
def fetch: (*keynable keys) -> untyped
|
15
|
+
|
16
|
+
# @rbs *keys: keynable
|
17
|
+
# @rbs return: Integer
|
18
|
+
def len: (*keynable keys) -> Integer
|
19
|
+
|
20
|
+
# @rbs *keys: keynable
|
21
|
+
# @rbs return: void
|
22
|
+
def delete: (*keynable keys) -> void
|
23
|
+
|
24
|
+
# @rbs *keys: keynable
|
25
|
+
# @rbs return: Array[keynable]
|
26
|
+
def keys: (*keynable keys) -> Array[keynable]
|
27
|
+
|
28
|
+
# @rbs *keys: keynable
|
29
|
+
# @rbs return: boolish
|
30
|
+
def key?: (*keynable keys) -> boolish
|
31
|
+
|
32
|
+
# @rbs at: Array[keynable]
|
33
|
+
# @rbs value: untyped
|
34
|
+
# @rbs return: void
|
35
|
+
def store: (untyped value, at: Array[keynable]) -> void
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/database.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Memorize and retrieve information using Ruboty's brain.
|
6
|
+
class Database
|
7
|
+
type keynable = Symbol | String | Integer
|
8
|
+
|
9
|
+
include QueryMethods
|
10
|
+
|
11
|
+
NAMESPACE: ::Symbol
|
12
|
+
|
13
|
+
attr_reader brain: Ruboty::Brains::Base
|
14
|
+
|
15
|
+
# @rbs brain: Ruboty::Brains::Base
|
16
|
+
def initialize: (Ruboty::Brains::Base brain) -> untyped
|
17
|
+
|
18
|
+
def data: () -> Hash[keynable, untyped]
|
19
|
+
|
20
|
+
def user: (untyped id) -> User
|
21
|
+
|
22
|
+
def chat_thread: (untyped id) -> ChatThread
|
23
|
+
|
24
|
+
def global_settings: () -> GlobalSettings
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/global_settings.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Global settings for AI agent.
|
6
|
+
class GlobalSettings
|
7
|
+
attr_reader database: Ruboty::AiAgent::Database
|
8
|
+
|
9
|
+
NAMESPACE_KEYS: Array[Database::keynable]
|
10
|
+
|
11
|
+
def self.find_or_create: (database: untyped) -> GlobalSettings
|
12
|
+
|
13
|
+
# @rbs database: Ruboty::AiAgent::Database
|
14
|
+
def initialize: (database: Ruboty::AiAgent::Database) -> untyped
|
15
|
+
|
16
|
+
def system_prompt: () -> String?
|
17
|
+
|
18
|
+
# @rbs prompt: String?
|
19
|
+
# @rbs return: void
|
20
|
+
def system_prompt=: (String? prompt) -> void
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/http_mcp_client.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Mcp client with HTTP transport.
|
6
|
+
class HttpMcpClient
|
7
|
+
attr_reader base_url: untyped
|
8
|
+
|
9
|
+
attr_reader headers: untyped
|
10
|
+
|
11
|
+
attr_reader session_id: untyped
|
12
|
+
|
13
|
+
def initialize: (url: untyped, ?headers: untyped, ?session_id: untyped) -> untyped
|
14
|
+
|
15
|
+
def initialize_session: () -> untyped
|
16
|
+
|
17
|
+
def ping: () -> untyped
|
18
|
+
|
19
|
+
def list_tools: () -> untyped
|
20
|
+
|
21
|
+
# @rbs name: String
|
22
|
+
# @rbs &block: ? (Hash[String, untyped]) -> void
|
23
|
+
def call_tool: (String name, ?untyped arguments) ?{ (Hash[String, untyped]) -> void } -> untyped
|
24
|
+
|
25
|
+
def list_prompts: () -> untyped
|
26
|
+
|
27
|
+
def get_prompt: (untyped name, ?untyped arguments) -> untyped
|
28
|
+
|
29
|
+
def list_resources: () -> untyped
|
30
|
+
|
31
|
+
def read_resource: (untyped uri) -> untyped
|
32
|
+
|
33
|
+
def cleanup_session: () -> untyped
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
@initialize_called: bool
|
38
|
+
|
39
|
+
def ensure_initialized: () -> untyped
|
40
|
+
|
41
|
+
# @rbs method: String
|
42
|
+
# @rbs ?params: Hash[String | Symbol, untyped]?
|
43
|
+
# @rbs ?id: String?
|
44
|
+
# @rbs &block: ? (Hash[String, untyped]) -> void
|
45
|
+
# @rbs return: Array[Hash[String, untyped]]
|
46
|
+
def send_request: (method: String, ?params: untyped, ?id: untyped) ?{ (Hash[String, untyped]) -> void } -> Array[Hash[String, untyped]]
|
47
|
+
|
48
|
+
# @rbs response: Net::HTTPResponse
|
49
|
+
# @rbs &block: ? (Hash[String, untyped]) -> void
|
50
|
+
# @rbs return: Array[Hash[String, untyped]]
|
51
|
+
def handle_response: (Net::HTTPResponse response) ?{ (Hash[String, untyped]) -> void } -> Array[Hash[String, untyped]]
|
52
|
+
|
53
|
+
# @rbs response: Net::HTTPResponse
|
54
|
+
# @rbs &block: ? (Hash[String, untyped]) -> void
|
55
|
+
# @rbs return: Array[Hash[String, untyped]]
|
56
|
+
def handle_streaming_response: (Net::HTTPResponse response) ?{ (Hash[String, untyped]) -> void } -> Array[Hash[String, untyped]]
|
57
|
+
|
58
|
+
class Error < StandardError
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/llm/openai/model.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module LLM
|
6
|
+
class OpenAI
|
7
|
+
# Model information and token limit estimation
|
8
|
+
class Model
|
9
|
+
attr_reader name: String
|
10
|
+
|
11
|
+
# @rbs name: String
|
12
|
+
def initialize: (String name) -> untyped
|
13
|
+
|
14
|
+
# Estimate token limit based on model name
|
15
|
+
# @rbs return: Integer
|
16
|
+
def token_limit: () -> Integer
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/llm/openai.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module LLM
|
6
|
+
# LLM interface for OpenAI's chat completion API.
|
7
|
+
class OpenAI
|
8
|
+
attr_reader client: OpenAI::Client
|
9
|
+
|
10
|
+
attr_reader model: String
|
11
|
+
|
12
|
+
# @rbs client: OpenAI::Client
|
13
|
+
# @rbs model: String
|
14
|
+
def initialize: (client: OpenAI::Client, model: String) -> untyped
|
15
|
+
|
16
|
+
# @rbs %a{memorized}
|
17
|
+
%a{memorized}
|
18
|
+
def model_info: () -> Model
|
19
|
+
|
20
|
+
# @rbs messages: Array[ChatMessage]
|
21
|
+
# @rbs tools: Array[Tool]
|
22
|
+
# @rbs return: Response
|
23
|
+
def complete: (messages: Array[ChatMessage], ?tools: Array[Tool]) -> Response
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
type tool_call = { id: String, type: "function", function: { name: String, arguments: String } }
|
28
|
+
|
29
|
+
type system_message = { role: "system", content: String }
|
30
|
+
|
31
|
+
type user_message = { role: "user", content: String }
|
32
|
+
|
33
|
+
type assistant_message = { role: "assistant", content: String, tool_calls: Array[tool_call]? }
|
34
|
+
|
35
|
+
type tool_message = { role: "tool", tool_call_id: String, content: String }
|
36
|
+
|
37
|
+
type message = system_message | user_message | assistant_message | tool_message
|
38
|
+
|
39
|
+
# @rbs messages: Array[ChatMessage]
|
40
|
+
# @rbs return: Array[OpenAI::Models::Chat::chat_completion_message_param]
|
41
|
+
def openai_messages_from_messages: (Array[ChatMessage] messages) -> Array[OpenAI::Models::Chat::chat_completion_message_param]
|
42
|
+
|
43
|
+
# @rbs tools: Array[Tool]
|
44
|
+
# @rbs return: Array[OpenAI::Models::Chat::chat_completion_tool]
|
45
|
+
def openai_tools_from_tools: (Array[Tool] tools) -> Array[OpenAI::Models::Chat::chat_completion_tool]
|
46
|
+
|
47
|
+
# @rbs openai_response: OpenAI::Models::Chat::ChatCompletion
|
48
|
+
# @rbs tools: Array[Tool]
|
49
|
+
# @rbs return: Response
|
50
|
+
def to_response: (openai_response: OpenAI::Models::Chat::ChatCompletion, tools: Array[Tool]) -> Response
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/llm/response.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
module LLM
|
6
|
+
class Response < Data
|
7
|
+
attr_reader message(): ChatMessage
|
8
|
+
|
9
|
+
attr_reader tool(): Ruboty::AiAgent::Tool?
|
10
|
+
|
11
|
+
attr_reader tool_call_id(): String?
|
12
|
+
|
13
|
+
attr_reader tool_arguments(): Hash[String, String]?
|
14
|
+
|
15
|
+
def self.new: (ChatMessage message, Ruboty::AiAgent::Tool? tool, String? tool_call_id, Hash[String, String]? tool_arguments) -> instance
|
16
|
+
| (message: ChatMessage, tool: Ruboty::AiAgent::Tool?, tool_call_id: String?, tool_arguments: Hash[String, String]?) -> instance
|
17
|
+
|
18
|
+
def self.members: () -> [ :message, :tool, :tool_call_id, :tool_arguments ]
|
19
|
+
|
20
|
+
def members: () -> [ :message, :tool, :tool_call_id, :tool_arguments ]
|
21
|
+
end
|
22
|
+
|
23
|
+
# General response class for LLM interactions.
|
24
|
+
class Response
|
25
|
+
def call_tool: () -> String?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Generated from lib/ruboty/ai_agent/mcp_clients.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module AiAgent
|
5
|
+
# Manages multiple MCP (Model Context Protocol) clients
|
6
|
+
class McpClients
|
7
|
+
attr_reader clients: Array[UserMcpClient]
|
8
|
+
|
9
|
+
# @rbs clients: Array[UserMcpClient]
|
10
|
+
def initialize: (Array[UserMcpClient] clients) -> untyped
|
11
|
+
|
12
|
+
# @rbs return: Array[Tool]
|
13
|
+
def available_tools: () -> Array[Tool]
|
14
|
+
|
15
|
+
# @rbs function_name: String
|
16
|
+
# @rbs arguments: Hash[String, untyped]
|
17
|
+
# @rbs return: untyped
|
18
|
+
def execute_tool: (String function_name, Hash[String, untyped] arguments) -> untyped
|
19
|
+
|
20
|
+
# @rbs return: bool
|
21
|
+
def any?: () -> bool
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|