jaf-py 2.5.10__py3-none-any.whl → 2.5.12__py3-none-any.whl

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 (92) hide show
  1. jaf/__init__.py +154 -57
  2. jaf/a2a/__init__.py +42 -21
  3. jaf/a2a/agent.py +79 -126
  4. jaf/a2a/agent_card.py +87 -78
  5. jaf/a2a/client.py +30 -66
  6. jaf/a2a/examples/client_example.py +12 -12
  7. jaf/a2a/examples/integration_example.py +38 -47
  8. jaf/a2a/examples/server_example.py +56 -53
  9. jaf/a2a/memory/__init__.py +0 -4
  10. jaf/a2a/memory/cleanup.py +28 -21
  11. jaf/a2a/memory/factory.py +155 -133
  12. jaf/a2a/memory/providers/composite.py +21 -26
  13. jaf/a2a/memory/providers/in_memory.py +89 -83
  14. jaf/a2a/memory/providers/postgres.py +117 -115
  15. jaf/a2a/memory/providers/redis.py +128 -121
  16. jaf/a2a/memory/serialization.py +77 -87
  17. jaf/a2a/memory/tests/run_comprehensive_tests.py +112 -83
  18. jaf/a2a/memory/tests/test_cleanup.py +211 -94
  19. jaf/a2a/memory/tests/test_serialization.py +73 -68
  20. jaf/a2a/memory/tests/test_stress_concurrency.py +186 -133
  21. jaf/a2a/memory/tests/test_task_lifecycle.py +138 -120
  22. jaf/a2a/memory/types.py +91 -53
  23. jaf/a2a/protocol.py +95 -125
  24. jaf/a2a/server.py +90 -118
  25. jaf/a2a/standalone_client.py +30 -43
  26. jaf/a2a/tests/__init__.py +16 -33
  27. jaf/a2a/tests/run_tests.py +17 -53
  28. jaf/a2a/tests/test_agent.py +40 -140
  29. jaf/a2a/tests/test_client.py +54 -117
  30. jaf/a2a/tests/test_integration.py +28 -82
  31. jaf/a2a/tests/test_protocol.py +54 -139
  32. jaf/a2a/tests/test_types.py +50 -136
  33. jaf/a2a/types.py +58 -34
  34. jaf/cli.py +21 -41
  35. jaf/core/__init__.py +7 -1
  36. jaf/core/agent_tool.py +93 -72
  37. jaf/core/analytics.py +257 -207
  38. jaf/core/checkpoint.py +223 -0
  39. jaf/core/composition.py +249 -235
  40. jaf/core/engine.py +817 -519
  41. jaf/core/errors.py +55 -42
  42. jaf/core/guardrails.py +276 -202
  43. jaf/core/handoff.py +47 -31
  44. jaf/core/parallel_agents.py +69 -75
  45. jaf/core/performance.py +75 -73
  46. jaf/core/proxy.py +43 -44
  47. jaf/core/proxy_helpers.py +24 -27
  48. jaf/core/regeneration.py +220 -129
  49. jaf/core/state.py +68 -66
  50. jaf/core/streaming.py +115 -108
  51. jaf/core/tool_results.py +111 -101
  52. jaf/core/tools.py +114 -116
  53. jaf/core/tracing.py +310 -210
  54. jaf/core/types.py +403 -151
  55. jaf/core/workflows.py +209 -168
  56. jaf/exceptions.py +46 -38
  57. jaf/memory/__init__.py +1 -6
  58. jaf/memory/approval_storage.py +54 -77
  59. jaf/memory/factory.py +4 -4
  60. jaf/memory/providers/in_memory.py +216 -180
  61. jaf/memory/providers/postgres.py +216 -146
  62. jaf/memory/providers/redis.py +173 -116
  63. jaf/memory/types.py +70 -51
  64. jaf/memory/utils.py +36 -34
  65. jaf/plugins/__init__.py +12 -12
  66. jaf/plugins/base.py +105 -96
  67. jaf/policies/__init__.py +0 -1
  68. jaf/policies/handoff.py +37 -46
  69. jaf/policies/validation.py +76 -52
  70. jaf/providers/__init__.py +6 -3
  71. jaf/providers/mcp.py +97 -51
  72. jaf/providers/model.py +475 -283
  73. jaf/server/__init__.py +1 -1
  74. jaf/server/main.py +7 -11
  75. jaf/server/server.py +514 -359
  76. jaf/server/types.py +208 -52
  77. jaf/utils/__init__.py +17 -18
  78. jaf/utils/attachments.py +111 -116
  79. jaf/utils/document_processor.py +175 -174
  80. jaf/visualization/__init__.py +1 -1
  81. jaf/visualization/example.py +111 -110
  82. jaf/visualization/functional_core.py +46 -71
  83. jaf/visualization/graphviz.py +154 -189
  84. jaf/visualization/imperative_shell.py +7 -16
  85. jaf/visualization/types.py +8 -4
  86. {jaf_py-2.5.10.dist-info → jaf_py-2.5.12.dist-info}/METADATA +2 -2
  87. jaf_py-2.5.12.dist-info/RECORD +97 -0
  88. jaf_py-2.5.10.dist-info/RECORD +0 -96
  89. {jaf_py-2.5.10.dist-info → jaf_py-2.5.12.dist-info}/WHEEL +0 -0
  90. {jaf_py-2.5.10.dist-info → jaf_py-2.5.12.dist-info}/entry_points.txt +0 -0
  91. {jaf_py-2.5.10.dist-info → jaf_py-2.5.12.dist-info}/licenses/LICENSE +0 -0
  92. {jaf_py-2.5.10.dist-info → jaf_py-2.5.12.dist-info}/top_level.txt +0 -0
jaf/__init__.py CHANGED
@@ -16,6 +16,7 @@ from .core.tools import (
16
16
  )
17
17
  from .core.tracing import ConsoleTraceCollector, TraceCollector
18
18
  from .core.types import *
19
+
19
20
  # Import attachment utilities for convenience
20
21
  from .utils.attachments import (
21
22
  make_image_attachment,
@@ -83,6 +84,7 @@ try:
83
84
  monitor_performance,
84
85
  get_performance_summary,
85
86
  )
87
+
86
88
  _PERFORMANCE_AVAILABLE = True
87
89
  except ImportError:
88
90
  _PERFORMANCE_AVAILABLE = False
@@ -96,6 +98,7 @@ try:
96
98
  create_sse_response,
97
99
  stream_to_websocket,
98
100
  )
101
+
99
102
  _STREAMING_AVAILABLE = True
100
103
  except ImportError:
101
104
  _STREAMING_AVAILABLE = False
@@ -110,6 +113,7 @@ try:
110
113
  with_timeout,
111
114
  compose,
112
115
  )
116
+
113
117
  _COMPOSITION_AVAILABLE = True
114
118
  except ImportError:
115
119
  _COMPOSITION_AVAILABLE = False
@@ -122,6 +126,7 @@ try:
122
126
  PluginRegistry,
123
127
  get_plugin_registry,
124
128
  )
129
+
125
130
  _PLUGINS_AVAILABLE = True
126
131
  except ImportError:
127
132
  _PLUGINS_AVAILABLE = False
@@ -135,6 +140,7 @@ try:
135
140
  get_analytics_report,
136
141
  analyze_conversation_quality,
137
142
  )
143
+
138
144
  _ANALYTICS_AVAILABLE = True
139
145
  except ImportError:
140
146
  _ANALYTICS_AVAILABLE = False
@@ -159,6 +165,7 @@ try:
159
165
  create_parallel_workflow,
160
166
  execute_workflow_stream,
161
167
  )
168
+
162
169
  _WORKFLOWS_AVAILABLE = True
163
170
  except ImportError:
164
171
  _WORKFLOWS_AVAILABLE = False
@@ -174,6 +181,7 @@ try:
174
181
  get_graph_dot,
175
182
  validate_graph_options,
176
183
  )
184
+
177
185
  _VISUALIZATION_AVAILABLE = True
178
186
  except ImportError:
179
187
  _VISUALIZATION_AVAILABLE = False
@@ -187,47 +195,89 @@ def generate_trace_id() -> TraceId:
187
195
  """Generate a new trace ID."""
188
196
  return create_trace_id(str(uuid.uuid4()))
189
197
 
198
+
190
199
  def generate_run_id() -> RunId:
191
200
  """Generate a new run ID."""
192
201
  return create_run_id(str(uuid.uuid4()))
193
202
 
194
- __version__ = "2.5.10"
203
+
204
+ __version__ = "2.5.12"
195
205
  __all__ = [
196
206
  # Core types and functions
197
- "TraceId", "RunId", "ValidationResult", "Message", "ModelConfig",
198
- "Tool", "Agent", "Guardrail", "RunState", "JAFError", "RunResult",
199
- "TraceEvent", "ModelProvider", "RunConfig",
200
- "create_trace_id", "create_run_id", "generate_trace_id", "generate_run_id",
201
-
207
+ "TraceId",
208
+ "RunId",
209
+ "ValidationResult",
210
+ "Message",
211
+ "ModelConfig",
212
+ "Tool",
213
+ "Agent",
214
+ "Guardrail",
215
+ "RunState",
216
+ "JAFError",
217
+ "RunResult",
218
+ "TraceEvent",
219
+ "ModelProvider",
220
+ "RunConfig",
221
+ "create_trace_id",
222
+ "create_run_id",
223
+ "generate_trace_id",
224
+ "generate_run_id",
202
225
  # Enums for type safety
203
- "Model", "ToolParameterType", "ToolSource", "ContentRole", "PartType",
204
-
226
+ "Model",
227
+ "ToolParameterType",
228
+ "ToolSource",
229
+ "ContentRole",
230
+ "PartType",
205
231
  # Tool factory functions
206
- "create_function_tool", "create_function_tool_legacy",
207
- "create_async_function_tool", "create_async_function_tool_legacy",
208
- "FunctionToolConfig", "ToolExecuteFunction", "function_tool",
209
-
232
+ "create_function_tool",
233
+ "create_function_tool_legacy",
234
+ "create_async_function_tool",
235
+ "create_async_function_tool_legacy",
236
+ "FunctionToolConfig",
237
+ "ToolExecuteFunction",
238
+ "function_tool",
210
239
  # Exception classes
211
- "JAFException", "AgentException", "AgentNotFoundError", "HandoffError",
212
- "ToolException", "ToolExecutionError", "ToolValidationError",
213
- "ModelException", "ModelProviderError", "ModelResponseError",
214
- "ValidationException", "GuardrailViolationError", "InputValidationError",
215
- "MemoryException", "MemoryConnectionError", "MemoryStorageError",
216
- "SessionException", "SessionStateError", "MaxTurnsExceededError",
217
- "A2AException", "A2AProtocolError", "A2ATaskError",
218
- "ConfigurationException", "InvalidConfigurationError",
219
- "create_agent_error", "create_tool_error", "create_session_error", "create_memory_error",
220
-
240
+ "JAFException",
241
+ "AgentException",
242
+ "AgentNotFoundError",
243
+ "HandoffError",
244
+ "ToolException",
245
+ "ToolExecutionError",
246
+ "ToolValidationError",
247
+ "ModelException",
248
+ "ModelProviderError",
249
+ "ModelResponseError",
250
+ "ValidationException",
251
+ "GuardrailViolationError",
252
+ "InputValidationError",
253
+ "MemoryException",
254
+ "MemoryConnectionError",
255
+ "MemoryStorageError",
256
+ "SessionException",
257
+ "SessionStateError",
258
+ "MaxTurnsExceededError",
259
+ "A2AException",
260
+ "A2AProtocolError",
261
+ "A2ATaskError",
262
+ "ConfigurationException",
263
+ "InvalidConfigurationError",
264
+ "create_agent_error",
265
+ "create_tool_error",
266
+ "create_session_error",
267
+ "create_memory_error",
221
268
  # Engine
222
269
  "run",
223
-
224
270
  # Tracing
225
- "TraceCollector", "ConsoleTraceCollector",
226
-
271
+ "TraceCollector",
272
+ "ConsoleTraceCollector",
227
273
  # Tool results
228
- "ToolResult", "ToolResultStatus", "ToolResponse", "ToolErrorCodes",
229
- "with_error_handling", "require_permissions", "tool_result_to_string",
230
-
274
+ "ToolResult",
275
+ "ToolResultStatus",
276
+ "ToolResponse",
277
+ "ToolErrorCodes",
278
+ "with_error_handling",
279
+ "require_permissions",
280
+ "tool_result_to_string",
231
281
  # Providers
232
282
  "make_litellm_provider",
233
283
  "FastMCPTool",
@@ -235,45 +285,92 @@ __all__ = [
235
285
  "create_mcp_stdio_tools",
236
286
  "create_mcp_sse_tools",
237
287
  "create_mcp_http_tools",
238
-
239
288
  # Memory system
240
- "ConversationMemory", "MemoryProvider", "MemoryQuery", "MemoryConfig",
241
- "Result", "Success", "Failure",
242
- "InMemoryConfig", "RedisConfig", "PostgresConfig", "MemoryProviderConfig",
243
- "MemoryError", "MemoryConnectionError", "MemoryNotFoundError", "MemoryStorageError",
244
- "create_memory_provider_from_env", "get_memory_provider_info", "test_memory_provider_connection",
245
- "create_in_memory_provider", "create_redis_provider", "create_postgres_provider",
246
-
289
+ "ConversationMemory",
290
+ "MemoryProvider",
291
+ "MemoryQuery",
292
+ "MemoryConfig",
293
+ "Result",
294
+ "Success",
295
+ "Failure",
296
+ "InMemoryConfig",
297
+ "RedisConfig",
298
+ "PostgresConfig",
299
+ "MemoryProviderConfig",
300
+ "MemoryError",
301
+ "MemoryConnectionError",
302
+ "MemoryNotFoundError",
303
+ "MemoryStorageError",
304
+ "create_memory_provider_from_env",
305
+ "get_memory_provider_info",
306
+ "test_memory_provider_connection",
307
+ "create_in_memory_provider",
308
+ "create_redis_provider",
309
+ "create_postgres_provider",
247
310
  # Server
248
311
  "run_server",
249
-
250
312
  # Performance monitoring (NEW)
251
- "PerformanceMonitor", "PerformanceMetrics", "monitor_performance", "get_performance_summary",
252
-
313
+ "PerformanceMonitor",
314
+ "PerformanceMetrics",
315
+ "monitor_performance",
316
+ "get_performance_summary",
253
317
  # Streaming support (NEW)
254
- "run_streaming", "StreamingEvent", "StreamingEventType", "StreamingCollector",
255
- "create_sse_response", "stream_to_websocket",
256
-
318
+ "run_streaming",
319
+ "StreamingEvent",
320
+ "StreamingEventType",
321
+ "StreamingCollector",
322
+ "create_sse_response",
323
+ "stream_to_websocket",
257
324
  # Tool composition (NEW)
258
- "create_tool_pipeline", "create_parallel_tools", "create_conditional_tool",
259
- "with_retry", "with_cache", "with_timeout", "compose",
260
-
325
+ "create_tool_pipeline",
326
+ "create_parallel_tools",
327
+ "create_conditional_tool",
328
+ "with_retry",
329
+ "with_cache",
330
+ "with_timeout",
331
+ "compose",
261
332
  # Plugin system (NEW)
262
- "JAFPlugin", "PluginMetadata", "PluginStatus", "PluginRegistry", "get_plugin_registry",
263
-
333
+ "JAFPlugin",
334
+ "PluginMetadata",
335
+ "PluginStatus",
336
+ "PluginRegistry",
337
+ "get_plugin_registry",
264
338
  # Analytics system (NEW)
265
- "ConversationAnalytics", "AgentAnalytics", "SystemAnalytics", "AnalyticsEngine",
266
- "get_analytics_report", "analyze_conversation_quality",
267
-
339
+ "ConversationAnalytics",
340
+ "AgentAnalytics",
341
+ "SystemAnalytics",
342
+ "AnalyticsEngine",
343
+ "get_analytics_report",
344
+ "analyze_conversation_quality",
268
345
  # Workflow orchestration (NEW)
269
- "Workflow", "WorkflowStep", "WorkflowContext", "WorkflowResult", "StepResult",
270
- "WorkflowStatus", "StepStatus", "AgentStep", "ToolStep", "ConditionalStep",
271
- "ParallelStep", "LoopStep", "WorkflowBuilder", "create_workflow",
272
- "create_sequential_workflow", "create_parallel_workflow", "execute_workflow_stream",
346
+ "Workflow",
347
+ "WorkflowStep",
348
+ "WorkflowContext",
349
+ "WorkflowResult",
350
+ "StepResult",
351
+ "WorkflowStatus",
352
+ "StepStatus",
353
+ "AgentStep",
354
+ "ToolStep",
355
+ "ConditionalStep",
356
+ "ParallelStep",
357
+ "LoopStep",
358
+ "WorkflowBuilder",
359
+ "create_workflow",
360
+ "create_sequential_workflow",
361
+ "create_parallel_workflow",
362
+ "execute_workflow_stream",
273
363
  ] + (
274
364
  # Visualization (conditional)
275
365
  [
276
- "generate_agent_graph", "generate_tool_graph", "generate_runner_graph",
277
- "GraphOptions", "GraphResult", "get_graph_dot", "validate_graph_options"
278
- ] if _VISUALIZATION_AVAILABLE else []
366
+ "generate_agent_graph",
367
+ "generate_tool_graph",
368
+ "generate_runner_graph",
369
+ "GraphOptions",
370
+ "GraphResult",
371
+ "get_graph_dot",
372
+ "validate_graph_options",
373
+ ]
374
+ if _VISUALIZATION_AVAILABLE
375
+ else []
279
376
  )
jaf/a2a/__init__.py CHANGED
@@ -195,28 +195,49 @@ from .types import (
195
195
  # Main exports for easy access
196
196
  __all__ = [
197
197
  # Types
198
- "A2AMessage", "A2ATask", "A2AAgent", "A2AAgentTool", "A2AArtifact",
199
- "A2ATaskStatus", "A2APart", "A2AStreamEvent", "A2AError", "A2AErrorCodes",
200
- "JSONRPCRequest", "JSONRPCResponse", "JSONRPCError",
201
- "AgentCard", "AgentSkill", "AgentCapabilities", "AgentProvider",
202
- "A2AServerConfig", "A2AClientConfig", "A2AClientState",
203
-
198
+ "A2AMessage",
199
+ "A2ATask",
200
+ "A2AAgent",
201
+ "A2AAgentTool",
202
+ "A2AArtifact",
203
+ "A2ATaskStatus",
204
+ "A2APart",
205
+ "A2AStreamEvent",
206
+ "A2AError",
207
+ "A2AErrorCodes",
208
+ "JSONRPCRequest",
209
+ "JSONRPCResponse",
210
+ "JSONRPCError",
211
+ "AgentCard",
212
+ "AgentSkill",
213
+ "AgentCapabilities",
214
+ "AgentProvider",
215
+ "A2AServerConfig",
216
+ "A2AClientConfig",
217
+ "A2AClientState",
204
218
  # Agent utilities
205
- "create_a2a_agent", "create_a2a_tool", "transform_a2a_agent_to_jaf",
206
- "process_agent_query", "execute_a2a_agent", "execute_a2a_agent_with_streaming",
207
-
219
+ "create_a2a_agent",
220
+ "create_a2a_tool",
221
+ "transform_a2a_agent_to_jaf",
222
+ "process_agent_query",
223
+ "execute_a2a_agent",
224
+ "execute_a2a_agent_with_streaming",
208
225
  # Protocol
209
- "validate_jsonrpc_request", "route_a2a_request",
210
-
226
+ "validate_jsonrpc_request",
227
+ "route_a2a_request",
211
228
  # Agent Card
212
- "generate_agent_card", "validate_agent_card",
213
-
229
+ "generate_agent_card",
230
+ "validate_agent_card",
214
231
  # Server
215
- "create_a2a_server", "start_a2a_server", "create_server_config",
216
-
232
+ "create_a2a_server",
233
+ "start_a2a_server",
234
+ "create_server_config",
217
235
  # Client
218
- "create_a2a_client", "connect_to_a2a_agent", "send_message",
219
- "stream_message", "discover_agents"
236
+ "create_a2a_client",
237
+ "connect_to_a2a_agent",
238
+ "send_message",
239
+ "stream_message",
240
+ "discover_agents",
220
241
  ]
221
242
 
222
243
 
@@ -224,12 +245,12 @@ __all__ = [
224
245
  class A2A:
225
246
  """
226
247
  Convenience class for A2A operations
227
-
248
+
228
249
  Usage:
229
250
  # Create client
230
251
  a2a = A2A.client("http://localhost:3000")
231
252
  response = await a2a.ask("Hello")
232
-
253
+
233
254
  # Create server
234
255
  server = A2A.server(agents, "My Server", "Description", 3000)
235
256
  await server.start()
@@ -279,11 +300,11 @@ A2A_SUPPORTED_METHODS = [
279
300
  "message/stream",
280
301
  "tasks/get",
281
302
  "tasks/cancel",
282
- "agent/getAuthenticatedExtendedCard"
303
+ "agent/getAuthenticatedExtendedCard",
283
304
  ]
284
305
  A2A_SUPPORTED_TRANSPORTS = ["JSONRPC"]
285
306
  A2A_DEFAULT_CAPABILITIES = {
286
307
  "streaming": True,
287
308
  "pushNotifications": False,
288
- "stateTransitionHistory": True
309
+ "stateTransitionHistory": True,
289
310
  }