smart_agent 0.1.4 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aad42cabbf228718122054fac2c219a4dac68e2b4cd0314160a2929972eb9583
4
- data.tar.gz: 177428d5673d9529d7fded1abac348e8168b0186995ef581e5addaf54bef9355
3
+ metadata.gz: bc51f77bbfd49a0c1c2c151b020d2073f7997804e17d762a7be8ca36ad8e4ecb
4
+ data.tar.gz: f50d74c5c9d6dcb998ecbe9832cb2cbc0631019b8fd980ba4d7ed90bef81f792
5
5
  SHA512:
6
- metadata.gz: 3cdbda0be5802a5bdcb52b3c5bfc92e075824803a0f4e5cbac13bda79180f099d19d4c8d4fe1adaf14c2a6e0c2c8a20892f1e1554de0bc30ab57d0c2acb7c6a0
7
- data.tar.gz: 29c74e9f6dd2839c139d37f05c0ba309e8d2e0f11e7120badb5ca6d988984d2e382b63c6572168e3ec3403ca8e58e390258e39f86b5d1c99c9bef9f2540a6068
6
+ metadata.gz: 88727a08ccbf0215cfc43bbc1ce1bf73de0d740a6bdbdd97596f549af1c2586637d34735451320b7bb6846a15013fbe74d6293f0e11e12905b07a6b603a359ab
7
+ data.tar.gz: ce309f0ebec190be1870aba2afdc3b22878d0e2872fdba5679248296c398e4cf20db8483773cb22e482258ea24e3373780f55a7d863b0477db20a09382e6b102
@@ -85,29 +85,32 @@ module SmartAgent
85
85
  params[:with_history] = with_history
86
86
  ret = nil
87
87
  if @agent.on_event
88
- tool_result = {}
88
+ full_result = {}
89
89
  tool_calls = []
90
90
  result = SmartAgent.prompt_engine.call_worker_by_stream(name, params) do |chunk, _bytesize|
91
- if tool_result.empty?
92
- tool_result["id"] = chunk["id"]
93
- tool_result["object"] = chunk["object"]
94
- tool_result["created"] = chunk["created"]
95
- tool_result["model"] = chunk["model"]
96
- tool_result["choices"] = [{
91
+ if full_result.empty?
92
+ full_result["id"] = chunk["id"]
93
+ full_result["object"] = chunk["object"]
94
+ full_result["created"] = chunk["created"]
95
+ full_result["model"] = chunk["model"]
96
+ full_result["choices"] = [{
97
97
  "index" => 0,
98
98
  "message" => {
99
99
  "role" => "assistant",
100
100
  "content" => "",
101
+ "reasoning_content" => "",
101
102
  "tool_calls" => [],
102
103
  },
103
104
  }]
104
- tool_result["usage"] = chunk["usage"]
105
- tool_result["system_fingerprint"] = chunk["system_fingerprint"]
105
+ full_result["usage"] = chunk["usage"]
106
+ full_result["system_fingerprint"] = chunk["system_fingerprint"]
106
107
  end
107
108
  if chunk.dig("choices", 0, "delta", "reasoning_content")
109
+ full_result["choices"][0]["message"]["reasoning_content"] += chunk.dig("choices", 0, "delta", "reasoning_content")
108
110
  @agent.processor(:reasoning).call(chunk) if @agent.processor(:reasoning)
109
111
  end
110
112
  if chunk.dig("choices", 0, "delta", "content")
113
+ full_result["choices"][0]["message"]["content"] += chunk.dig("choices", 0, "delta", "content")
111
114
  @agent.processor(:content).call(chunk) if @agent.processor(:content)
112
115
  end
113
116
  if chunk_tool_calls = chunk.dig("choices", 0, "delta", "tool_calls")
@@ -120,8 +123,8 @@ module SmartAgent
120
123
  end
121
124
  end
122
125
  end
123
- tool_result["choices"][0]["message"]["tool_calls"] = tool_calls
124
- result = tool_result
126
+ full_result["choices"][0]["message"]["tool_calls"] = tool_calls
127
+ result = full_result
125
128
  else
126
129
  result = SmartAgent.prompt_engine.call_worker(name, params)
127
130
  end
@@ -141,17 +144,18 @@ module SmartAgent
141
144
  @agent.processor(:tool).call({ :content => "ToolName is `#{tool_name}`\n" }) if @agent.processor(:tool)
142
145
  @agent.processor(:tool).call({ :content => "params is `#{params}`\n" }) if @agent.processor(:tool)
143
146
  tool_result = Tool.find_tool(tool_name).call(params)
144
- SmartAgent.prompt_engine.history_messages << result.response.dig("choices", 0, "message")
147
+
148
+ SmartAgent.prompt_engine.history_messages << { "role" => "assistant", "content" => "", "tool_calls" => [tool] } #result.response.dig("choices", 0, "message")
145
149
  SmartAgent.prompt_engine.history_messages << { "role" => "tool", "tool_call_id" => tool_call_id, "content" => tool_result.to_s.force_encoding("UTF-8") }
146
- results << result
150
+ results << tool_result
147
151
  end
148
152
  if server_name = MCPClient.find_server_by_tool_name(tool_name)
149
153
  @agent.processor(:tool).call({ :content => "MCP Server is `#{server_name}`, ToolName is `#{tool_name}`\n" }) if @agent.processor(:tool)
150
154
  @agent.processor(:tool).call({ :content => "params is `#{params}`\n" }) if @agent.processor(:tool)
151
155
  tool_result = MCPClient.new(server_name).call(tool_name, params)
152
- SmartAgent.prompt_engine.history_messages << result.response.dig("choices", 0, "message")
156
+ SmartAgent.prompt_engine.history_messages << { "role" => "assistant", "content" => "", "tool_calls" => [tool] } # result.response.dig("choices", 0, "message")
153
157
  SmartAgent.prompt_engine.history_messages << { "role" => "tool", "tool_call_id" => tool_call_id, "content" => tool_result.to_s }
154
- results << result
158
+ results << tool_result
155
159
  end
156
160
  @agent.processor(:tool).call({ :content => " ... done\n" }) if @agent.processor(:tool)
157
161
  end
@@ -10,7 +10,11 @@ module SmartAgent
10
10
  @context = MCPContext.new
11
11
  @context.instance_eval(&@code)
12
12
  command_path = @context.command_path
13
- client = MCP::Client.new(command_path)
13
+ if @context.mcp_type == :stdio
14
+ client = MCP::StdioClient.new(command_path)
15
+ else
16
+ client = MCP::SSEClient.new(command_path)
17
+ end
14
18
  client.start
15
19
  mcp_server_json = client.list_tools
16
20
  if mcp_server_json
@@ -25,7 +29,11 @@ module SmartAgent
25
29
  @context = MCPContext.new
26
30
  @context.instance_eval(&@code)
27
31
  command_path = @context.command_path
28
- client = MCP::Client.new(command_path)
32
+ if @context.mcp_type == :stdio
33
+ client = MCP::StdioClient.new(command_path)
34
+ else
35
+ client = MCP::SSEClient.new(command_path)
36
+ end
29
37
  client.start
30
38
  client.call_method(
31
39
  {
@@ -63,6 +71,10 @@ module SmartAgent
63
71
  @mcp_type = mcp_type
64
72
  end
65
73
 
74
+ def mcp_type
75
+ @mcp_type
76
+ end
77
+
66
78
  def command_path
67
79
  @command_path
68
80
  end
@@ -70,5 +82,9 @@ module SmartAgent
70
82
  def command(path)
71
83
  @command_path = path
72
84
  end
85
+
86
+ def url(url)
87
+ @command_path = url
88
+ end
73
89
  end
74
90
  end
@@ -1,3 +1,3 @@
1
1
  module SmartAgent
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Your Name
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: smart_prompt
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 3.6.4
74
+ rubygems_version: 3.6.7
75
75
  specification_version: 4
76
76
  summary: Intelligent agent framework with DSL and MCP integration
77
77
  test_files: []