chuk-tool-processor 0.6.9__tar.gz → 0.6.10__tar.gz

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 (65) hide show
  1. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/PKG-INFO +1 -1
  2. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/pyproject.toml +1 -1
  3. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/transport/sse_transport.py +51 -15
  4. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor.egg-info/PKG-INFO +1 -1
  5. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/README.md +0 -0
  6. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/setup.cfg +0 -0
  7. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/__init__.py +0 -0
  8. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/core/__init__.py +0 -0
  9. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/core/exceptions.py +0 -0
  10. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/core/processor.py +0 -0
  11. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/execution/__init__.py +0 -0
  12. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/execution/strategies/__init__.py +0 -0
  13. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/execution/strategies/inprocess_strategy.py +0 -0
  14. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/execution/strategies/subprocess_strategy.py +0 -0
  15. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/execution/tool_executor.py +0 -0
  16. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/execution/wrappers/__init__.py +0 -0
  17. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/execution/wrappers/caching.py +0 -0
  18. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/execution/wrappers/rate_limiting.py +0 -0
  19. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/execution/wrappers/retry.py +0 -0
  20. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/logging/__init__.py +0 -0
  21. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/logging/context.py +0 -0
  22. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/logging/formatter.py +0 -0
  23. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/logging/helpers.py +0 -0
  24. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/logging/metrics.py +0 -0
  25. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/__init__.py +0 -0
  26. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/mcp_tool.py +0 -0
  27. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/register_mcp_tools.py +0 -0
  28. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/setup_mcp_http_streamable.py +0 -0
  29. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/setup_mcp_sse.py +0 -0
  30. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/setup_mcp_stdio.py +0 -0
  31. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/stream_manager.py +0 -0
  32. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/transport/__init__.py +0 -0
  33. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/transport/base_transport.py +0 -0
  34. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/transport/http_streamable_transport.py +0 -0
  35. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/mcp/transport/stdio_transport.py +0 -0
  36. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/models/__init__.py +0 -0
  37. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/models/execution_strategy.py +0 -0
  38. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/models/streaming_tool.py +0 -0
  39. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/models/tool_call.py +0 -0
  40. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/models/tool_export_mixin.py +0 -0
  41. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/models/tool_result.py +0 -0
  42. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/models/validated_tool.py +0 -0
  43. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/plugins/__init__.py +0 -0
  44. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/plugins/discovery.py +0 -0
  45. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/plugins/parsers/__init__.py +0 -0
  46. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/plugins/parsers/base.py +0 -0
  47. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/plugins/parsers/function_call_tool.py +0 -0
  48. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/plugins/parsers/json_tool.py +0 -0
  49. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/plugins/parsers/openai_tool.py +0 -0
  50. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/plugins/parsers/xml_tool.py +0 -0
  51. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/registry/__init__.py +0 -0
  52. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/registry/auto_register.py +0 -0
  53. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/registry/decorators.py +0 -0
  54. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/registry/interface.py +0 -0
  55. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/registry/metadata.py +0 -0
  56. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/registry/provider.py +0 -0
  57. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/registry/providers/__init__.py +0 -0
  58. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/registry/providers/memory.py +0 -0
  59. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/registry/tool_export.py +0 -0
  60. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/utils/__init__.py +0 -0
  61. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor/utils/validation.py +0 -0
  62. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor.egg-info/SOURCES.txt +0 -0
  63. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor.egg-info/dependency_links.txt +0 -0
  64. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor.egg-info/requires.txt +0 -0
  65. {chuk_tool_processor-0.6.9 → chuk_tool_processor-0.6.10}/src/chuk_tool_processor.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chuk-tool-processor
3
- Version: 0.6.9
3
+ Version: 0.6.10
4
4
  Summary: Async-native framework for registering, discovering, and executing tools referenced in LLM responses
5
5
  Author-email: CHUK Team <chrishayuk@somejunkmailbox.com>
6
6
  Maintainer-email: CHUK Team <chrishayuk@somejunkmailbox.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chuk-tool-processor"
7
- version = "0.6.9"
7
+ version = "0.6.10"
8
8
  description = "Async-native framework for registering, discovering, and executing tools referenced in LLM responses"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -8,6 +8,9 @@ Implements Server-Sent Events transport with two-step async pattern:
8
8
 
9
9
  Note: This transport is deprecated in favor of HTTP Streamable (spec 2025-03-26)
10
10
  but remains supported for backward compatibility.
11
+
12
+ FIXED: Updated to support both old format (/messages/) and new event-based format
13
+ (event: endpoint + data: https://...) for session discovery.
11
14
  """
12
15
  from __future__ import annotations
13
16
 
@@ -32,6 +35,8 @@ class SSETransport(MCPBaseTransport):
32
35
  This transport uses a dual-connection approach:
33
36
  - SSE stream for receiving responses
34
37
  - HTTP POST for sending requests
38
+
39
+ FIXED: Supports both old and new session discovery formats.
35
40
  """
36
41
 
37
42
  def __init__(self, url: str, api_key: Optional[str] = None,
@@ -215,33 +220,61 @@ class SSETransport(MCPBaseTransport):
215
220
  return False
216
221
 
217
222
  async def _process_sse_stream(self):
218
- """Process the persistent SSE stream for responses and session discovery."""
223
+ """
224
+ Process the persistent SSE stream for responses and session discovery.
225
+
226
+ FIXED: Supports both old format (/messages/) and new event-based format
227
+ (event: endpoint + data: https://...) for session discovery.
228
+ """
219
229
  try:
220
230
  logger.debug("Starting SSE stream processing...")
221
231
 
232
+ current_event = None # Track current event type
233
+
222
234
  async for line in self.sse_response.aiter_lines():
223
235
  line = line.strip()
224
236
  if not line:
225
237
  continue
226
238
 
227
- # Handle session endpoint discovery
228
- if not self.message_url and line.startswith('data:') and '/messages/' in line:
229
- endpoint_path = line.split(':', 1)[1].strip()
230
- self.message_url = f"{self.url}{endpoint_path}"
239
+ # Handle event type declarations
240
+ if line.startswith('event:'):
241
+ current_event = line.split(':', 1)[1].strip()
242
+ logger.debug("SSE event type: %s", current_event)
243
+ continue
244
+
245
+ # Handle session endpoint discovery (BOTH FORMATS)
246
+ if not self.message_url and line.startswith('data:'):
247
+ data_part = line.split(':', 1)[1].strip()
231
248
 
232
- # Extract session ID if present
233
- if 'session_id=' in endpoint_path:
234
- self.session_id = endpoint_path.split('session_id=')[1].split('&')[0]
249
+ # NEW FORMAT: event: endpoint + data: https://...
250
+ if current_event == "endpoint" and data_part.startswith('http'):
251
+ self.message_url = data_part
252
+
253
+ # Extract session ID from URL if present
254
+ if 'session_id=' in data_part:
255
+ self.session_id = data_part.split('session_id=')[1].split('&')[0]
256
+
257
+ logger.debug("Session endpoint discovered via event format: %s", self.session_id)
258
+ continue
235
259
 
236
- logger.debug("Session endpoint discovered: %s", self.session_id)
237
- continue
260
+ # OLD FORMAT: data: /messages/... (backwards compatibility)
261
+ elif '/messages/' in data_part:
262
+ endpoint_path = data_part
263
+ self.message_url = f"{self.url}{endpoint_path}"
264
+
265
+ # Extract session ID if present
266
+ if 'session_id=' in endpoint_path:
267
+ self.session_id = endpoint_path.split('session_id=')[1].split('&')[0]
268
+
269
+ logger.debug("Session endpoint discovered via old format: %s", self.session_id)
270
+ continue
238
271
 
239
272
  # Handle JSON-RPC responses
240
273
  if line.startswith('data:'):
241
274
  data_part = line.split(':', 1)[1].strip()
242
275
 
243
276
  # Skip keepalive pings and empty data
244
- if not data_part or data_part.startswith('ping'):
277
+ if not data_part or data_part.startswith('ping') or data_part in ('{}', '[]'):
245
278
  continue
246
279
 
247
280
  try:
@@ -260,6 +293,10 @@ class SSETransport(MCPBaseTransport):
260
293
 
261
294
  except json.JSONDecodeError as e:
262
295
  logger.debug("Non-JSON data in SSE stream (ignoring): %s", e)
296
+
297
+ # Reset event type after processing data (only if we processed JSON-RPC)
298
+ if line.startswith('data:') and current_event not in ("endpoint",):
299
+ current_event = None
263
300
 
264
301
  except Exception as e:
265
302
  if self.enable_metrics:
@@ -403,7 +440,7 @@ class SSETransport(MCPBaseTransport):
403
440
 
404
441
  start_time = time.time()
405
442
  if self.enable_metrics:
406
- self._metrics["total_calls"] += 1 # FIXED: INCREMENT FIRST
443
+ self._metrics["total_calls"] += 1
407
444
 
408
445
  try:
409
446
  logger.debug("Calling tool '%s' with arguments: %s", tool_name, arguments)
@@ -461,7 +498,6 @@ class SSETransport(MCPBaseTransport):
461
498
  self._metrics["failed_calls"] += 1
462
499
 
463
500
  self._metrics["total_time"] += response_time
464
- # FIXED: Only calculate average if we have total calls
465
501
  if self._metrics["total_calls"] > 0:
466
502
  self._metrics["avg_response_time"] = (
467
503
  self._metrics["total_time"] / self._metrics["total_calls"]
@@ -582,13 +618,13 @@ class SSETransport(MCPBaseTransport):
582
618
  return []
583
619
 
584
620
  # ------------------------------------------------------------------ #
585
- # Context manager support (now uses base class with fixed error) #
621
+ # Context manager support #
586
622
  # ------------------------------------------------------------------ #
587
623
  async def __aenter__(self):
588
624
  """Context manager entry."""
589
625
  success = await self.initialize()
590
626
  if not success:
591
- raise RuntimeError("Failed to initialize SSETransport") # FIXED: message
627
+ raise RuntimeError("Failed to initialize SSETransport")
592
628
  return self
593
629
 
594
630
  async def __aexit__(self, exc_type, exc_val, exc_tb):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chuk-tool-processor
3
- Version: 0.6.9
3
+ Version: 0.6.10
4
4
  Summary: Async-native framework for registering, discovering, and executing tools referenced in LLM responses
5
5
  Author-email: CHUK Team <chrishayuk@somejunkmailbox.com>
6
6
  Maintainer-email: CHUK Team <chrishayuk@somejunkmailbox.com>