praxo-core 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4975c4a8d241b094789de25f7bf80ab08b442d154abb816c7bb54b30c5400784
4
- data.tar.gz: d43f996a431634a84484de307d0dd4668e8052d99d61c2f8fdc7853683e51760
3
+ metadata.gz: 6e50f98ad5296f743956594ac18c6e4675c27aecc3ba8da8de988ac71c2b3925
4
+ data.tar.gz: 2025d3d8b1ea545d9759034921c4387265f2ce734995b0fb883d94299819343d
5
5
  SHA512:
6
- metadata.gz: a9f62729753be864c1bf4f19cc8fa1536f418944efb39d81cf43c0c10e9066a737132bbe64465ea1a3a4434c9adca191678f05a011543da64e7339dc178f9818
7
- data.tar.gz: 6117c0418bb0e50d88683ef9bbbdc6d836f18d48cb3b167f5410dc35a7c05d83914dc84a95805a69f2f5a71b8258000a26d4b299fcb9c1124d278f6cd0dedb10
6
+ metadata.gz: 3d3879cf7f8e5cf9437568252cb31896c96890dcd83284febcf2c9dadb28d12da6e9ea50b939da2a35d67108b7b6dab21c34510a72eceb32b28fec9a84bcb700
7
+ data.tar.gz: 70f2686e31b7d4dbdc7cfc8d2e93d9a1484ee76e2f460690a6e69a16570d88d70a3152703dc131990e067e6a1393940e81cb534ffb7c82e10a14a6e2edf48bc8
data/README.md CHANGED
@@ -21,7 +21,7 @@ reference implementation.
21
21
  - Registry introduction: [REGISTRY.md](https://github.com/axisvela/praxo-core/blob/main/language/ruby/REGISTRY.md)
22
22
  - Machine-readable entry: [llms.txt](https://github.com/axisvela/praxo-core/blob/main/language/ruby/llms.txt) and [llms.md](https://github.com/axisvela/praxo-core/blob/main/language/ruby/llms.md)
23
23
  - Coding-agent contract: [docs/getting-started/coding-agents.md](https://github.com/axisvela/praxo-core/blob/main/docs/getting-started/coding-agents.md)
24
- - Registry: [RubyGems](https://rubygems.org/gems/praxo-core/versions/0.4.1)
24
+ - Registry: [RubyGems](https://rubygems.org/gems/praxo-core/versions/0.5.0)
25
25
 
26
26
  ## Install
27
27
 
data/REGISTRY.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # PRAXO-CORE Ruby Registry Introduction
2
2
 
3
- **Status:** published; split source repository. Source version `0.5.0`, source
4
- tag `ruby/v0.5.0`. Published registry version: `0.4.1`. Registry
3
+ **Status:** published; split source repository. Source version `0.6.0`, source
4
+ tag `ruby/v0.6.0`. Published registry version: `0.5.0`. Registry
5
5
  pages are release snapshots; verify the published version before relying on a
6
6
  feature.
7
7
 
@@ -14,12 +14,12 @@ PRAXO-CORE is an embeddable, MIT-licensed agent framework. This gem is its nativ
14
14
  | Field | Value |
15
15
  | --- | --- |
16
16
  | Package | `praxo-core` |
17
- | Registry | [RubyGems](https://rubygems.org/gems/praxo-core/versions/0.4.1) |
18
- | Source version | `0.5.0` |
19
- | Published registry version | `0.4.1` |
17
+ | Registry | [RubyGems](https://rubygems.org/gems/praxo-core/versions/0.5.0) |
18
+ | Source version | `0.6.0` |
19
+ | Published registry version | `0.5.0` |
20
20
  | Install (published) | `gem install praxo-core` |
21
21
  | Install (source/release prepared) | `gem install praxo-core` |
22
- | Source tag | `ruby/v0.5.0` |
22
+ | Source tag | `ruby/v0.6.0` |
23
23
  | Tier | Core |
24
24
  | Contract | `SPEC_VERSION` `0.2.0` |
25
25
  | Documentation | https://axisvela.github.io/praxo-core/languages/ruby/ |
data/api/0.6.0.txt ADDED
@@ -0,0 +1,122 @@
1
+ # PRAXO-CORE Ruby API 0.6.0
2
+ # SPEC_VERSION 0.2.0
3
+
4
+ class AgentOptions
5
+ class CallLimit
6
+ class CheckpointAllowlist
7
+ class ContextBudget
8
+ class Error
9
+ class FilterSink
10
+ class FuncTool
11
+ class MemoryStore
12
+ class MultiSink
13
+ class PathChecker
14
+ class PiiRedactor
15
+ class Runner
16
+ class StaticModel
17
+ class StructuredOutput
18
+ class ToolRegistry
19
+ class ToolSelection
20
+ def action
21
+ def after_run
22
+ def allowed?
23
+ def allows?
24
+ def apply
25
+ def apply_interrupt
26
+ def array
27
+ def as_int
28
+ def as_object
29
+ def as_string
30
+ def authorize
31
+ def before_model
32
+ def before_run
33
+ def before_tool
34
+ def bool
35
+ def check
36
+ def check_cancelled
37
+ def check_enum
38
+ def check_keys
39
+ def compact
40
+ def content_block
41
+ def decision
42
+ def emit
43
+ def emit_stream
44
+ def equals
45
+ def error
46
+ def error_code
47
+ def estimate_tokens
48
+ def event
49
+ def execute_tool
50
+ def extract_json
51
+ def fallback_model
52
+ def filter
53
+ def generate
54
+ def get
55
+ def has?
56
+ def initialize
57
+ def int
58
+ def interrupt
59
+ def interrupt_decision
60
+ def invoke
61
+ def invoke_tool
62
+ def invoke_tools
63
+ def marshal
64
+ def memory_record
65
+ def message
66
+ def message_assistant
67
+ def message_text
68
+ def message_tool
69
+ def message_wire
70
+ def parse
71
+ def parse_input_json
72
+ def parse_json_call
73
+ def parse_manifest
74
+ def parse_plain
75
+ def parse_tag
76
+ def parse_toolcall
77
+ def parse_xml
78
+ def plus
79
+ def prepare_tool
80
+ def put
81
+ def redact
82
+ def redact_value
83
+ def register
84
+ def reject
85
+ def request
86
+ def resolve_path
87
+ def response
88
+ def run
89
+ def run_agent
90
+ def run_result
91
+ def search
92
+ def session
93
+ def specs
94
+ def stream_part
95
+ def string
96
+ def stringify
97
+ def strip_markup
98
+ def structured_apply
99
+ def text_present
100
+ def tool_call
101
+ def tool_spec
102
+ def truncate_to_tokens
103
+ def unmarshal
104
+ def usage
105
+ def validate
106
+ def visit
107
+ def visit_array
108
+ def visit_boolean
109
+ def visit_number
110
+ def visit_object
111
+ def visit_string
112
+ def within?
113
+ module Agent
114
+ module Json
115
+ module JsonSchema
116
+ module Middleware
117
+ module Models
118
+ module Plugin
119
+ module Praxo
120
+ module Runtime
121
+ module SSE
122
+ module Toolcall
@@ -10,13 +10,16 @@ module Praxo
10
10
 
11
11
  attr_reader :protocol_version, :server_info
12
12
 
13
- def initialize(command: nil, args: [], env: {}, timeout: 5, reader: nil, writer: nil)
13
+ def initialize(command: nil, args: [], env: {}, timeout: 5, reader: nil, writer: nil,
14
+ transport: nil, protocol_version: DEFAULT_PROTOCOL_VERSION)
14
15
  @command = command
15
16
  @args = args
16
17
  @env = env
17
18
  @timeout = timeout
18
19
  @reader = reader
19
20
  @writer = writer
21
+ @transport = transport
22
+ @protocol_version = protocol_version
20
23
  @next_id = 0
21
24
  @closed = false
22
25
  @connected = false
@@ -25,7 +28,7 @@ module Praxo
25
28
  def start
26
29
  return self if @connected
27
30
 
28
- if @reader.nil? || @writer.nil?
31
+ if @transport.nil? && (@reader.nil? || @writer.nil?)
29
32
  raise Praxo::Error.new('MCP_TRANSPORT', 'mcp: command is required') if @command.nil?
30
33
 
31
34
  @stdin, @stdout, @stderr, @wait = Open3.popen3(@env, @command, *@args)
@@ -33,9 +36,9 @@ module Praxo
33
36
  @reader = @stdout
34
37
  end
35
38
  result = request('initialize', {
36
- protocolVersion: DEFAULT_PROTOCOL_VERSION,
39
+ protocolVersion: @protocol_version,
37
40
  capabilities: {},
38
- clientInfo: { name: 'praxo-core', version: '0.5.0' }
41
+ clientInfo: { name: 'praxo-core', version: '0.6.0' }
39
42
  })
40
43
  version = result.is_a?(Hash) ? result['protocolVersion'] : nil
41
44
  if version.nil? || version.empty?
@@ -92,6 +95,15 @@ module Praxo
92
95
  return if @closed
93
96
 
94
97
  @closed = true
98
+ if @transport
99
+ begin
100
+ @transport.close
101
+ rescue StandardError
102
+ nil
103
+ end
104
+ @connected = false
105
+ return
106
+ end
95
107
  begin
96
108
  @writer.close if @writer && !@writer.closed?
97
109
  rescue IOError
@@ -125,6 +137,8 @@ module Praxo
125
137
  def request(method, params, timeout: nil)
126
138
  raise Praxo::Error.new('MCP_CLOSED', 'mcp: client is closed') if @closed
127
139
 
140
+ return @transport.request(method, params, timeout: timeout || @timeout) if @transport
141
+
128
142
  @next_id += 1
129
143
  id = @next_id
130
144
  write({ jsonrpc: '2.0', id: id, method: method, params: params })
@@ -157,6 +171,7 @@ module Praxo
157
171
 
158
172
  def notify(method, params)
159
173
  return if @closed
174
+ return @transport.notify(method, params) if @transport
160
175
 
161
176
  write({ jsonrpc: '2.0', method: method, params: params })
162
177
  end
@@ -0,0 +1,158 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require 'uri'
4
+
5
+ module Praxo
6
+ module Adapters
7
+ # Streamable HTTP MCP transport (2025-03-26).
8
+ class HttpMCPTransport
9
+ def initialize(endpoint, headers: {}, protocol_version: '2025-03-26', timeout: 30)
10
+ @uri = URI.parse(endpoint)
11
+ unless %w[http https].include?(@uri.scheme)
12
+ raise Praxo::Error.new('MCP_TRANSPORT', 'mcp: invalid HTTP endpoint')
13
+ end
14
+ if @uri.scheme == 'http' && !self.class.loopback?(@uri.host)
15
+ raise Praxo::Error.new('MCP_TRANSPORT', 'mcp: HTTP endpoint must use HTTPS')
16
+ end
17
+
18
+ @headers = headers
19
+ @protocol_version = protocol_version
20
+ @timeout = timeout
21
+ @session_id = ''
22
+ @next_id = 0
23
+ @closed = false
24
+ end
25
+
26
+ def request(method, params, timeout: nil)
27
+ raise Praxo::Error.new('MCP_CLOSED', 'mcp: client is closed') if @closed
28
+
29
+ @next_id += 1
30
+ message = {
31
+ jsonrpc: '2.0',
32
+ id: @next_id,
33
+ method: method,
34
+ params: params
35
+ }
36
+ response = post(message, timeout || @timeout)
37
+ if response['error']
38
+ detail = response['error'].is_a?(Hash) ? response['error']['message'] : 'JSON-RPC error'
39
+ raise Praxo::Error.new('MCP_RPC', "mcp: #{method} failed: #{detail}")
40
+ end
41
+ result = response['result'] || {}
42
+ unless result.is_a?(Hash)
43
+ raise Praxo::Error.new('MCP_PROTOCOL', "mcp: #{method} result must be an object")
44
+ end
45
+ result
46
+ end
47
+
48
+ def notify(method, params)
49
+ return if @closed
50
+
51
+ post({ jsonrpc: '2.0', method: method, params: params }, @timeout)
52
+ end
53
+
54
+ def close
55
+ return if @closed
56
+
57
+ @closed = true
58
+ return if @session_id.empty?
59
+
60
+ begin
61
+ request = Net::HTTP::Delete.new(@uri)
62
+ apply_headers(request)
63
+ Net::HTTP.start(
64
+ @uri.host,
65
+ @uri.port,
66
+ use_ssl: @uri.scheme == 'https',
67
+ read_timeout: @timeout
68
+ ) { |http| http.request(request) }
69
+ rescue StandardError
70
+ nil
71
+ end
72
+ end
73
+
74
+ def self.loopback?(host)
75
+ value = host.to_s.downcase
76
+ ['localhost', '127.0.0.1', '::1', '[::1]'].include?(value) || value.start_with?('127.')
77
+ end
78
+
79
+ private
80
+
81
+ def post(message, timeout)
82
+ request = Net::HTTP::Post.new(@uri)
83
+ request.body = JSON.generate(message)
84
+ apply_headers(request)
85
+ response = Net::HTTP.start(
86
+ @uri.host,
87
+ @uri.port,
88
+ use_ssl: @uri.scheme == 'https',
89
+ read_timeout: timeout
90
+ ) { |http| http.request(request) }
91
+ session = response['mcp-session-id']
92
+ @session_id = session unless session.nil? || session.empty?
93
+ status = response.code.to_i
94
+ body = response.body.to_s
95
+ return {} if [202, 204].include?(status) || body.strip.empty?
96
+ if status < 200 || status >= 300
97
+ raise Praxo::Error.new('MCP_TRANSPORT', "mcp: HTTP #{status}: #{body[0, 512]}")
98
+ end
99
+
100
+ decoded = if response['content-type'].to_s.downcase.include?('text/event-stream')
101
+ parse_sse(body, message[:id] || message['id'])
102
+ else
103
+ parse_json(body, message[:id] || message['id'])
104
+ end
105
+ version = decoded.dig('result', 'protocolVersion')
106
+ @protocol_version = version if version.is_a?(String) && !version.empty?
107
+ decoded
108
+ end
109
+
110
+ def apply_headers(request)
111
+ request['Content-Type'] = 'application/json'
112
+ request['Accept'] = 'application/json, text/event-stream'
113
+ request['MCP-Protocol-Version'] = @protocol_version
114
+ request['MCP-Session-Id'] = @session_id unless @session_id.empty?
115
+ @headers.each { |key, value| request[key] = value }
116
+ end
117
+
118
+ def parse_json(body, id)
119
+ decoded = JSON.parse(body)
120
+ raise Praxo::Error.new('MCP_PROTOCOL', 'mcp: server sent invalid JSON') unless decoded.is_a?(Hash)
121
+
122
+ decoded
123
+ rescue JSON::ParserError
124
+ raise Praxo::Error.new('MCP_PROTOCOL', 'mcp: server sent invalid JSON')
125
+ end
126
+
127
+ def parse_sse(body, id)
128
+ messages = []
129
+ data = []
130
+ body.split(/\r\n|\n|\r/).each do |line|
131
+ if line.empty?
132
+ unless data.empty?
133
+ messages << decode_message(data.join("\n"))
134
+ data = []
135
+ end
136
+ next
137
+ end
138
+ next if line.start_with?(':')
139
+ data << line[5..].to_s.lstrip if line.start_with?('data:')
140
+ end
141
+ messages << decode_message(data.join("\n")) unless data.empty?
142
+ return messages.find { |item| item['id'] == id } || messages.first unless messages.empty?
143
+
144
+ raise Praxo::Error.new('MCP_PROTOCOL', 'mcp: response contained no message')
145
+ end
146
+
147
+ def decode_message(text)
148
+ decoded = JSON.parse(text)
149
+ unless decoded.is_a?(Hash)
150
+ raise Praxo::Error.new('MCP_PROTOCOL', 'mcp: server sent a non-object message')
151
+ end
152
+ decoded
153
+ rescue JSON::ParserError
154
+ raise Praxo::Error.new('MCP_PROTOCOL', 'mcp: server sent invalid SSE JSON')
155
+ end
156
+ end
157
+ end
158
+ end
data/lib/praxo.rb CHANGED
@@ -12,4 +12,5 @@ require_relative 'praxo/adapters/openai_compatible'
12
12
  require_relative 'praxo/adapters/anthropic'
13
13
  require_relative 'praxo/adapters/gemini'
14
14
  require_relative 'praxo/adapters/mcp'
15
+ require_relative 'praxo/adapters/mcp_http'
15
16
  require_relative 'praxo/adapters/harmovela_sink'
data/llms.md CHANGED
@@ -7,12 +7,12 @@
7
7
  ## Package
8
8
 
9
9
  - package: `praxo-core`
10
- - registry: [RubyGems](https://rubygems.org/gems/praxo-core/versions/0.4.1)
11
- - source_version: `0.5.0`
12
- - published_version: `0.4.1`
10
+ - registry: [RubyGems](https://rubygems.org/gems/praxo-core/versions/0.5.0)
11
+ - source_version: `0.6.0`
12
+ - published_version: `0.5.0`
13
13
  - install_published: `gem install praxo-core`
14
14
  - install_source: `gem install praxo-core`
15
- - source_tag: `ruby/v0.5.0`
15
+ - source_tag: `ruby/v0.6.0`
16
16
  - tier: Core
17
17
  - contract: `SPEC_VERSION` `0.2.0`
18
18
  - documentation: https://axisvela.github.io/praxo-core/languages/ruby/
data/llms.txt CHANGED
@@ -7,12 +7,12 @@
7
7
  # Package
8
8
 
9
9
  - package: `praxo-core`
10
- - registry: [RubyGems](https://rubygems.org/gems/praxo-core/versions/0.4.1)
11
- - source_version: `0.5.0`
12
- - published_version: `0.4.1`
10
+ - registry: [RubyGems](https://rubygems.org/gems/praxo-core/versions/0.5.0)
11
+ - source_version: `0.6.0`
12
+ - published_version: `0.5.0`
13
13
  - install_published: `gem install praxo-core`
14
14
  - install_source: `gem install praxo-core`
15
- - source_tag: `ruby/v0.5.0`
15
+ - source_tag: `ruby/v0.6.0`
16
16
  - tier: Core
17
17
  - contract: `SPEC_VERSION` `0.2.0`
18
18
  - documentation: https://axisvela.github.io/praxo-core/languages/ruby/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: praxo-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AxisVela
@@ -26,11 +26,13 @@ files:
26
26
  - api/0.4.0.txt
27
27
  - api/0.4.1.txt
28
28
  - api/0.5.0.txt
29
+ - api/0.6.0.txt
29
30
  - lib/praxo.rb
30
31
  - lib/praxo/adapters/anthropic.rb
31
32
  - lib/praxo/adapters/gemini.rb
32
33
  - lib/praxo/adapters/harmovela_sink.rb
33
34
  - lib/praxo/adapters/mcp.rb
35
+ - lib/praxo/adapters/mcp_http.rb
34
36
  - lib/praxo/adapters/openai_compatible.rb
35
37
  - lib/praxo/agent.rb
36
38
  - lib/praxo/errors.rb