kailash 0.1.4__tar.gz → 0.2.0__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 (139) hide show
  1. {kailash-0.1.4/src/kailash.egg-info → kailash-0.2.0}/PKG-INFO +446 -13
  2. {kailash-0.1.4 → kailash-0.2.0}/README.md +438 -12
  3. {kailash-0.1.4 → kailash-0.2.0}/pyproject.toml +8 -1
  4. {kailash-0.1.4 → kailash-0.2.0}/setup.py +1 -1
  5. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/__init__.py +1 -1
  6. kailash-0.2.0/src/kailash/access_control.py +740 -0
  7. kailash-0.2.0/src/kailash/api/__main__.py +6 -0
  8. kailash-0.2.0/src/kailash/api/auth.py +668 -0
  9. kailash-0.2.0/src/kailash/api/custom_nodes.py +285 -0
  10. kailash-0.2.0/src/kailash/api/custom_nodes_secure.py +377 -0
  11. kailash-0.2.0/src/kailash/api/database.py +620 -0
  12. kailash-0.2.0/src/kailash/api/studio.py +915 -0
  13. kailash-0.2.0/src/kailash/api/studio_secure.py +893 -0
  14. kailash-0.2.0/src/kailash/mcp/__init__.py +53 -0
  15. kailash-0.2.0/src/kailash/mcp/__main__.py +13 -0
  16. kailash-0.2.0/src/kailash/mcp/ai_registry_server.py +712 -0
  17. kailash-0.2.0/src/kailash/mcp/client.py +447 -0
  18. kailash-0.2.0/src/kailash/mcp/client_new.py +334 -0
  19. kailash-0.2.0/src/kailash/mcp/server.py +293 -0
  20. kailash-0.2.0/src/kailash/mcp/server_new.py +336 -0
  21. kailash-0.2.0/src/kailash/mcp/servers/__init__.py +12 -0
  22. kailash-0.2.0/src/kailash/mcp/servers/ai_registry.py +289 -0
  23. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/__init__.py +4 -2
  24. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/ai/__init__.py +38 -0
  25. kailash-0.2.0/src/kailash/nodes/ai/a2a.py +1790 -0
  26. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/ai/agents.py +116 -2
  27. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/ai/ai_providers.py +206 -8
  28. kailash-0.2.0/src/kailash/nodes/ai/intelligent_agent_orchestrator.py +2108 -0
  29. kailash-0.2.0/src/kailash/nodes/ai/iterative_llm_agent.py +1280 -0
  30. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/ai/llm_agent.py +324 -1
  31. kailash-0.2.0/src/kailash/nodes/ai/self_organizing.py +1623 -0
  32. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/api/http.py +106 -25
  33. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/api/rest.py +116 -21
  34. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/base.py +15 -2
  35. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/base_async.py +45 -0
  36. kailash-0.2.0/src/kailash/nodes/base_cycle_aware.py +374 -0
  37. kailash-0.2.0/src/kailash/nodes/base_with_acl.py +338 -0
  38. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/code/python.py +135 -27
  39. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/data/readers.py +116 -53
  40. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/data/writers.py +16 -6
  41. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/logic/__init__.py +8 -0
  42. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/logic/async_operations.py +48 -9
  43. kailash-0.2.0/src/kailash/nodes/logic/convergence.py +642 -0
  44. kailash-0.2.0/src/kailash/nodes/logic/loop.py +153 -0
  45. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/logic/operations.py +212 -27
  46. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/logic/workflow.py +26 -18
  47. kailash-0.2.0/src/kailash/nodes/mixins/__init__.py +11 -0
  48. kailash-0.2.0/src/kailash/nodes/mixins/mcp.py +228 -0
  49. kailash-0.2.0/src/kailash/nodes/mixins.py +387 -0
  50. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/transform/__init__.py +8 -1
  51. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/transform/processors.py +119 -4
  52. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/runtime/__init__.py +2 -1
  53. kailash-0.2.0/src/kailash/runtime/access_controlled.py +458 -0
  54. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/runtime/local.py +106 -33
  55. kailash-0.2.0/src/kailash/runtime/parallel_cyclic.py +529 -0
  56. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/sdk_exceptions.py +90 -5
  57. kailash-0.2.0/src/kailash/security.py +845 -0
  58. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/tracking/manager.py +38 -15
  59. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/tracking/models.py +1 -1
  60. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/tracking/storage/filesystem.py +30 -2
  61. kailash-0.2.0/src/kailash/utils/__init__.py +8 -0
  62. kailash-0.2.0/src/kailash/workflow/__init__.py +33 -0
  63. kailash-0.2.0/src/kailash/workflow/convergence.py +270 -0
  64. kailash-0.2.0/src/kailash/workflow/cycle_analyzer.py +768 -0
  65. kailash-0.2.0/src/kailash/workflow/cycle_builder.py +573 -0
  66. kailash-0.2.0/src/kailash/workflow/cycle_config.py +709 -0
  67. kailash-0.2.0/src/kailash/workflow/cycle_debugger.py +760 -0
  68. kailash-0.2.0/src/kailash/workflow/cycle_exceptions.py +601 -0
  69. kailash-0.2.0/src/kailash/workflow/cycle_profiler.py +671 -0
  70. kailash-0.2.0/src/kailash/workflow/cycle_state.py +338 -0
  71. kailash-0.2.0/src/kailash/workflow/cyclic_runner.py +985 -0
  72. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/workflow/graph.py +500 -39
  73. kailash-0.2.0/src/kailash/workflow/migration.py +768 -0
  74. kailash-0.2.0/src/kailash/workflow/safety.py +365 -0
  75. kailash-0.2.0/src/kailash/workflow/templates.py +744 -0
  76. kailash-0.2.0/src/kailash/workflow/validation.py +693 -0
  77. {kailash-0.1.4 → kailash-0.2.0/src/kailash.egg-info}/PKG-INFO +446 -13
  78. {kailash-0.1.4 → kailash-0.2.0}/src/kailash.egg-info/SOURCES.txt +44 -4
  79. {kailash-0.1.4 → kailash-0.2.0}/src/kailash.egg-info/requires.txt +7 -0
  80. kailash-0.1.4/src/kailash/nodes/mcp/__init__.py +0 -11
  81. kailash-0.1.4/src/kailash/nodes/mcp/client.py +0 -554
  82. kailash-0.1.4/src/kailash/nodes/mcp/resource.py +0 -682
  83. kailash-0.1.4/src/kailash/nodes/mcp/server.py +0 -577
  84. kailash-0.1.4/src/kailash/utils/__init__.py +0 -0
  85. kailash-0.1.4/src/kailash/workflow/__init__.py +0 -15
  86. {kailash-0.1.4 → kailash-0.2.0}/LICENSE +0 -0
  87. {kailash-0.1.4 → kailash-0.2.0}/MANIFEST.in +0 -0
  88. {kailash-0.1.4 → kailash-0.2.0}/setup.cfg +0 -0
  89. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/__main__.py +0 -0
  90. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/api/__init__.py +0 -0
  91. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/api/gateway.py +0 -0
  92. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/api/mcp_integration.py +0 -0
  93. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/api/workflow_api.py +0 -0
  94. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/cli/__init__.py +0 -0
  95. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/cli/commands.py +0 -0
  96. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/manifest.py +0 -0
  97. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/ai/embedding_generator.py +0 -0
  98. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/ai/models.py +0 -0
  99. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/api/__init__.py +0 -0
  100. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/api/auth.py +0 -0
  101. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/api/graphql.py +0 -0
  102. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/api/rate_limiting.py +0 -0
  103. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/code/__init__.py +0 -0
  104. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/data/__init__.py +0 -0
  105. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/data/retrieval.py +0 -0
  106. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/data/sharepoint_graph.py +0 -0
  107. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/data/sources.py +0 -0
  108. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/data/sql.py +0 -0
  109. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/data/streaming.py +0 -0
  110. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/data/vector_db.py +0 -0
  111. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/transform/chunkers.py +0 -0
  112. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/nodes/transform/formatters.py +0 -0
  113. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/runtime/async_local.py +0 -0
  114. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/runtime/docker.py +0 -0
  115. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/runtime/parallel.py +0 -0
  116. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/runtime/runner.py +0 -0
  117. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/runtime/testing.py +0 -0
  118. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/tracking/__init__.py +0 -0
  119. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/tracking/metrics_collector.py +0 -0
  120. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/tracking/storage/__init__.py +0 -0
  121. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/tracking/storage/base.py +0 -0
  122. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/tracking/storage/database.py +0 -0
  123. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/utils/export.py +0 -0
  124. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/utils/templates.py +0 -0
  125. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/visualization/__init__.py +0 -0
  126. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/visualization/api.py +0 -0
  127. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/visualization/dashboard.py +0 -0
  128. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/visualization/performance.py +0 -0
  129. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/visualization/reports.py +0 -0
  130. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/workflow/builder.py +0 -0
  131. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/workflow/mermaid_visualizer.py +0 -0
  132. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/workflow/mock_registry.py +0 -0
  133. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/workflow/runner.py +0 -0
  134. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/workflow/state.py +0 -0
  135. {kailash-0.1.4 → kailash-0.2.0}/src/kailash/workflow/visualization.py +0 -0
  136. {kailash-0.1.4 → kailash-0.2.0}/src/kailash.egg-info/dependency_links.txt +0 -0
  137. {kailash-0.1.4 → kailash-0.2.0}/src/kailash.egg-info/entry_points.txt +0 -0
  138. {kailash-0.1.4 → kailash-0.2.0}/src/kailash.egg-info/not-zip-safe +0 -0
  139. {kailash-0.1.4 → kailash-0.2.0}/src/kailash.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kailash
3
- Version: 0.1.4
3
+ Version: 0.2.0
4
4
  Summary: Python SDK for the Kailash container-node architecture
5
5
  Home-page: https://github.com/integrum/kailash-python-sdk
6
6
  Author: Integrum
@@ -47,6 +47,13 @@ Requires-Dist: pytest-asyncio>=1.0.0
47
47
  Requires-Dist: pre-commit>=4.2.0
48
48
  Requires-Dist: twine>=6.1.0
49
49
  Requires-Dist: ollama>=0.5.1
50
+ Requires-Dist: sqlalchemy>=2.0.0
51
+ Requires-Dist: websockets>=12.0
52
+ Requires-Dist: httpx>=0.25.0
53
+ Requires-Dist: python-jose>=3.5.0
54
+ Requires-Dist: pytest-xdist>=3.6.0
55
+ Requires-Dist: pytest-timeout>=2.3.0
56
+ Requires-Dist: pytest-split>=0.9.0
50
57
  Provides-Extra: dev
51
58
  Requires-Dist: pytest>=7.0; extra == "dev"
52
59
  Requires-Dist: pytest-cov>=3.0; extra == "dev"
@@ -66,7 +73,7 @@ Dynamic: requires-python
66
73
  <a href="https://pepy.tech/project/kailash"><img src="https://static.pepy.tech/badge/kailash" alt="Downloads"></a>
67
74
  <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT License">
68
75
  <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black">
69
- <img src="https://img.shields.io/badge/tests-753%20passing-brightgreen.svg" alt="Tests: 753 passing">
76
+ <img src="https://img.shields.io/badge/tests-734%20passing-brightgreen.svg" alt="Tests: 734 passing">
70
77
  <img src="https://img.shields.io/badge/coverage-100%25-brightgreen.svg" alt="Coverage: 100%">
71
78
  </p>
72
79
 
@@ -92,6 +99,13 @@ Dynamic: requires-python
92
99
  - 🧠 **Retrieval-Augmented Generation**: Full RAG pipeline with intelligent document processing
93
100
  - 🌐 **REST API Wrapper**: Expose any workflow as a production-ready API in 3 lines
94
101
  - 🚪 **Multi-Workflow Gateway**: Manage multiple workflows through unified API with MCP integration
102
+ - 🤖 **Self-Organizing Agents**: Autonomous agent pools with intelligent team formation and convergence detection
103
+ - 🧠 **Agent-to-Agent Communication**: Shared memory pools and intelligent caching for coordinated multi-agent systems
104
+ - 🔒 **Production Security**: Comprehensive security framework with path traversal prevention, code sandboxing, and audit logging
105
+ - 🎨 **Visual Workflow Builder**: Kailash Workflow Studio - drag-and-drop interface for creating and managing workflows (coming soon)
106
+ - 🔁 **Cyclic Workflows (v0.2.0)**: Universal Hybrid Cyclic Graph Architecture with 30,000+ iterations/second performance
107
+ - 🛠️ **Developer Tools**: CycleAnalyzer, CycleDebugger, CycleProfiler for production-ready cyclic workflows
108
+ - 📈 **High Performance**: Optimized execution engine supporting 100,000+ iteration workflows
95
109
 
96
110
  ## 🎯 Who Is This For?
97
111
 
@@ -276,6 +290,141 @@ results, run_id = runtime.execute(workflow)
276
290
  print("RAG Response:", results["llm_agent"]["response"])
277
291
  ```
278
292
 
293
+ ### Cyclic Workflows - Iterative Processing with Convergence
294
+
295
+ Build workflows that iterate until a condition is met, perfect for optimization, retries, and ML training:
296
+
297
+ ```python
298
+ from kailash.workflow import Workflow
299
+ from kailash.nodes.base_cycle_aware import CycleAwareNode
300
+ from kailash.nodes.base import NodeParameter
301
+ from kailash.runtime.local import LocalRuntime
302
+ from typing import Any, Dict
303
+
304
+ # Create a custom cycle-aware node for data quality improvement
305
+ class DataQualityImproverNode(CycleAwareNode):
306
+ def get_parameters(self) -> Dict[str, NodeParameter]:
307
+ return {
308
+ "data": NodeParameter(name="data", type=list, required=True),
309
+ "target_quality": NodeParameter(name="target_quality", type=float, required=False, default=0.95)
310
+ }
311
+
312
+ def run(self, context: Dict[str, Any], **kwargs) -> Dict[str, Any]:
313
+ """Iteratively improve data quality."""
314
+ data = kwargs["data"]
315
+ target_quality = kwargs.get("target_quality", 0.95)
316
+
317
+ # Get current iteration and previous state
318
+ iteration = self.get_iteration(context)
319
+ prev_state = self.get_previous_state(context)
320
+
321
+ # Calculate current quality
322
+ quality = prev_state.get("quality", 0.5) + 0.1 # Improve by 10% each iteration
323
+ quality = min(quality, 1.0)
324
+
325
+ # Process data (simplified)
326
+ processed_data = [item for item in data if item is not None]
327
+
328
+ # Track quality history
329
+ quality_history = self.accumulate_values(context, "quality_history", quality, max_history=10)
330
+
331
+ # Detect convergence trend
332
+ trend = self.detect_convergence_trend(context, "quality_history", window_size=5)
333
+ converged = quality >= target_quality or (trend and trend["slope"] < 0.01)
334
+
335
+ # Log progress
336
+ self.log_cycle_info(context, f"Iteration {iteration}: Quality={quality:.2%}")
337
+
338
+ # Save state for next iteration
339
+ self.set_cycle_state({"quality": quality, "processed_count": len(processed_data)})
340
+
341
+ return {
342
+ "data": processed_data,
343
+ "quality": quality,
344
+ "converged": converged,
345
+ "iteration": iteration,
346
+ "history": quality_history
347
+ }
348
+
349
+ # Build cyclic workflow
350
+ workflow = Workflow("quality_improvement", "Iterative Data Quality")
351
+ workflow.add_node("improver", DataQualityImproverNode())
352
+
353
+ # Create a cycle - node connects to itself!
354
+ workflow.connect("improver", "improver",
355
+ mapping={"data": "data"}, # Pass data to next iteration
356
+ cycle=True, # This is a cycle
357
+ max_iterations=20, # Safety limit
358
+ convergence_check="converged == True") # Stop condition
359
+
360
+ # Execute with automatic iteration management
361
+ runtime = LocalRuntime()
362
+ results, run_id = runtime.execute(workflow, parameters={
363
+ "improver": {
364
+ "data": [1, None, 3, None, 5, 6, None, 8, 9, 10],
365
+ "target_quality": 0.9
366
+ }
367
+ })
368
+
369
+ print(f"Converged after {results['improver']['iteration']} iterations")
370
+ print(f"Final quality: {results['improver']['quality']:.2%}")
371
+ print(f"Quality history: {results['improver']['history']}")
372
+ ```
373
+
374
+ ### NEW in v0.2.0: CycleBuilder API
375
+
376
+ The new CycleBuilder API provides a fluent interface for creating cyclic workflows:
377
+
378
+ ```python
379
+ # Modern approach with CycleBuilder
380
+ workflow.create_cycle("optimization_loop")
381
+ .connect("gradient", "optimizer")
382
+ .connect("optimizer", "evaluator")
383
+ .connect("evaluator", "gradient")
384
+ .max_iterations(100)
385
+ .converge_when("loss < 0.01")
386
+ .early_stop_when("gradient_norm < 1e-6")
387
+ .checkpoint_every(10)
388
+ .build()
389
+
390
+ # Developer tools for production workflows
391
+ from kailash.workflow import CycleAnalyzer, CycleDebugger, CycleProfiler
392
+
393
+ # Analyze cycle patterns
394
+ analyzer = CycleAnalyzer(workflow)
395
+ report = analyzer.analyze()
396
+ print(f"Found {len(report.cycles)} cycles")
397
+ print(f"Max depth: {report.max_cycle_depth}")
398
+
399
+ # Debug with breakpoints
400
+ debugger = CycleDebugger(workflow)
401
+ debugger.set_breakpoint("optimizer", iteration=50)
402
+ debugger.set_trace("gradient_norm", lambda x: x < 0.001)
403
+
404
+ # Profile performance
405
+ profiler = CycleProfiler(workflow)
406
+ profile_data = profiler.profile(runtime, parameters)
407
+ print(f"Bottleneck: {profile_data.bottleneck_node}")
408
+ print(f"Iterations/sec: {profile_data.iterations_per_second}")
409
+ ```
410
+
411
+ #### Cyclic Workflow Features
412
+
413
+ - **Built-in Iteration Management**: No manual loops or recursion needed
414
+ - **State Persistence**: Maintain state across iterations with `get_previous_state()` and `set_cycle_state()`
415
+ - **Convergence Detection**: Automatic trend analysis with `detect_convergence_trend()`
416
+ - **Value Accumulation**: Track metrics over time with `accumulate_values()`
417
+ - **Safety Limits**: Max iterations prevent infinite loops
418
+ - **Performance**: Optimized execution with ~30,000 iterations/second
419
+ - **Developer Tools**: CycleAnalyzer, CycleDebugger, CycleProfiler for production workflows
420
+
421
+ Common cyclic patterns include:
422
+ - **Retry with Backoff**: ETL pipelines with automatic retry
423
+ - **Optimization Loops**: Iterative parameter tuning
424
+ - **ML Training**: Training until accuracy threshold
425
+ - **Polling**: API polling with rate limiting
426
+ - **Stream Processing**: Windowed data processing
427
+
279
428
  ### Workflow API Wrapper - Expose Workflows as REST APIs
280
429
 
281
430
  Transform any Kailash workflow into a production-ready REST API in just 3 lines of code:
@@ -410,6 +559,173 @@ gateway.run(port=8000)
410
559
 
411
560
  See the [Gateway examples](examples/integration_examples/gateway_comprehensive_demo.py) for complete implementation patterns.
412
561
 
562
+ ### Self-Organizing Agent Pools - Autonomous Multi-Agent Systems
563
+
564
+ Build intelligent agent systems that can autonomously form teams, share information, and solve complex problems collaboratively:
565
+
566
+ ```python
567
+ from kailash import Workflow
568
+ from kailash.runtime import LocalRuntime
569
+ from kailash.nodes.ai.intelligent_agent_orchestrator import (
570
+ OrchestrationManagerNode,
571
+ IntelligentCacheNode,
572
+ ConvergenceDetectorNode
573
+ )
574
+ from kailash.nodes.ai.self_organizing import (
575
+ AgentPoolManagerNode,
576
+ TeamFormationNode,
577
+ ProblemAnalyzerNode
578
+ )
579
+ from kailash.nodes.ai.a2a import SharedMemoryPoolNode, A2AAgentNode
580
+
581
+ # Create self-organizing agent workflow
582
+ workflow = Workflow("self_organizing_research")
583
+
584
+ # Shared infrastructure
585
+ memory_pool = SharedMemoryPoolNode(
586
+ memory_size_limit=1000,
587
+ attention_window=50
588
+ )
589
+ workflow.add_node("memory", memory_pool)
590
+
591
+ # Intelligent caching to prevent redundant operations
592
+ cache = IntelligentCacheNode(
593
+ ttl=3600, # 1 hour cache
594
+ similarity_threshold=0.8,
595
+ max_entries=1000
596
+ )
597
+ workflow.add_node("cache", cache)
598
+
599
+ # Problem analysis and team formation
600
+ problem_analyzer = ProblemAnalyzerNode()
601
+ team_former = TeamFormationNode(
602
+ formation_strategy="capability_matching",
603
+ optimization_rounds=3
604
+ )
605
+ workflow.add_node("analyzer", problem_analyzer)
606
+ workflow.add_node("team_former", team_former)
607
+
608
+ # Self-organizing agent pool
609
+ pool_manager = AgentPoolManagerNode(
610
+ max_active_agents=20,
611
+ agent_timeout=120
612
+ )
613
+ workflow.add_node("pool", pool_manager)
614
+
615
+ # Convergence detection for stopping criteria
616
+ convergence = ConvergenceDetectorNode(
617
+ quality_threshold=0.85,
618
+ improvement_threshold=0.02,
619
+ max_iterations=10
620
+ )
621
+ workflow.add_node("convergence", convergence)
622
+
623
+ # Orchestration manager coordinates the entire system
624
+ orchestrator = OrchestrationManagerNode(
625
+ max_iterations=10,
626
+ quality_threshold=0.85,
627
+ parallel_execution=True
628
+ )
629
+ workflow.add_node("orchestrator", orchestrator)
630
+
631
+ # Execute with complex business problem
632
+ runtime = LocalRuntime()
633
+ result, _ = runtime.execute(workflow, parameters={
634
+ "orchestrator": {
635
+ "query": "Analyze market trends and develop growth strategy for fintech",
636
+ "agent_pool_size": 12,
637
+ "mcp_servers": [
638
+ {"name": "market_data", "command": "python", "args": ["-m", "market_mcp"]},
639
+ {"name": "financial", "command": "python", "args": ["-m", "finance_mcp"]},
640
+ {"name": "research", "command": "python", "args": ["-m", "research_mcp"]}
641
+ ],
642
+ "context": {
643
+ "domain": "fintech",
644
+ "depth": "comprehensive",
645
+ "output_format": "strategic_report"
646
+ }
647
+ }
648
+ })
649
+
650
+ print(f"Solution Quality: {result['orchestrator']['quality_score']:.2%}")
651
+ print(f"Agents Used: {result['orchestrator']['agents_deployed']}")
652
+ print(f"Iterations: {result['orchestrator']['iterations_completed']}")
653
+ print(f"Final Strategy: {result['orchestrator']['final_solution']['strategy']}")
654
+ ```
655
+
656
+ #### Key Self-Organizing Features
657
+
658
+ - **Autonomous Team Formation**: Agents automatically form optimal teams based on:
659
+ - Capability matching for skill-specific tasks
660
+ - Swarm-based formation for exploration
661
+ - Market-based allocation for resource constraints
662
+ - Hierarchical organization for complex problems
663
+
664
+ - **Intelligent Information Sharing**:
665
+ - **SharedMemoryPoolNode**: Selective attention mechanisms for relevant information
666
+ - **IntelligentCacheNode**: Semantic similarity detection prevents redundant operations
667
+ - **A2AAgentNode**: Direct agent-to-agent communication with context awareness
668
+
669
+ - **Convergence Detection**: Automatic termination when:
670
+ - Solution quality exceeds threshold (e.g., 85% confidence)
671
+ - Improvement rate drops below minimum (e.g., <2% per iteration)
672
+ - Maximum iterations reached
673
+ - Time limits exceeded
674
+
675
+ - **MCP Integration**: Agents can access external tools and data sources:
676
+ - File systems, databases, APIs
677
+ - Web scraping and research tools
678
+ - Specialized domain knowledge bases
679
+ - Real-time data streams
680
+
681
+ - **Performance Optimization**:
682
+ - Multi-level caching strategies
683
+ - Parallel agent execution
684
+ - Resource management and monitoring
685
+ - Cost tracking for API usage
686
+
687
+ See the [Self-Organizing Agents examples](examples/integration_examples/) for complete implementation patterns and the [Agent Systems Guide](docs/guides/self_organizing_agents.rst) for detailed documentation.
688
+
689
+ ### Zero-Code MCP Ecosystem - Visual Workflow Builder
690
+
691
+ Build and deploy workflows through an interactive web interface without writing any code:
692
+
693
+ ```python
694
+ from kailash.api.gateway import WorkflowAPIGateway
695
+ from kailash.api.mcp_integration import MCPServerRegistry
696
+
697
+ # Run the MCP ecosystem demo
698
+ # cd examples/integration_examples
699
+ # ./run_ecosystem.sh
700
+
701
+ # Or run programmatically:
702
+ python examples/integration_examples/mcp_ecosystem_demo.py
703
+ ```
704
+
705
+ #### Features
706
+
707
+ - **Drag-and-Drop Builder**: Visual interface for creating workflows
708
+ - Drag nodes from palette (CSV Reader, Python Code, JSON Writer, etc.)
709
+ - Drop onto canvas to build workflows
710
+ - Deploy with one click
711
+
712
+ - **Live Dashboard**: Real-time monitoring and statistics
713
+ - Connected MCP server status
714
+ - Running workflow count
715
+ - Execution logs with timestamps
716
+
717
+ - **Pre-built Templates**: One-click deployment
718
+ - GitHub → Slack Notifier
719
+ - Data Processing Pipeline (CSV → Transform → JSON)
720
+ - AI Research Assistant
721
+
722
+ - **Technology Stack**: Lightweight and fast
723
+ - Backend: FastAPI + Kailash SDK
724
+ - Frontend: Vanilla HTML/CSS/JavaScript (no frameworks)
725
+ - Zero build process required
726
+
727
+ See the [MCP Ecosystem example](examples/integration_examples/) for the complete zero-code workflow deployment platform.
728
+
413
729
  ## 📚 Documentation
414
730
 
415
731
  | Resource | Description |
@@ -471,6 +787,21 @@ The SDK includes a rich set of pre-built nodes for common operations:
471
787
  - `SentimentAnalyzer` - Sentiment analysis
472
788
  - `NamedEntityRecognizer` - NER extraction
473
789
 
790
+ **Self-Organizing Agent Nodes**
791
+ - `SharedMemoryPoolNode` - Agent memory sharing
792
+ - `A2AAgentNode` - Agent-to-agent communication
793
+ - `A2ACoordinatorNode` - Multi-agent coordination
794
+ - `IntelligentCacheNode` - Semantic caching system
795
+ - `MCPAgentNode` - MCP-enabled agents
796
+ - `QueryAnalysisNode` - Query complexity analysis
797
+ - `OrchestrationManagerNode` - System orchestration
798
+ - `ConvergenceDetectorNode` - Solution convergence
799
+ - `AgentPoolManagerNode` - Agent pool management
800
+ - `ProblemAnalyzerNode` - Problem decomposition
801
+ - `TeamFormationNode` - Optimal team creation
802
+ - `SolutionEvaluatorNode` - Multi-criteria evaluation
803
+ - `SelfOrganizingAgentNode` - Adaptive individual agents
804
+
474
805
  </td>
475
806
  <td width="50%">
476
807
 
@@ -918,6 +1249,95 @@ This example demonstrates:
918
1249
  - **Context formatting** for LLM input
919
1250
  - **Answer generation** using Ollama's llama3.2 model
920
1251
 
1252
+ ### 🔒 Access Control and Security
1253
+
1254
+ Kailash SDK provides comprehensive access control and security features for enterprise deployments:
1255
+
1256
+ #### Role-Based Access Control (RBAC)
1257
+ ```python
1258
+ from kailash.access_control import UserContext, PermissionRule, NodePermission
1259
+ from kailash.runtime.access_controlled import AccessControlledRuntime
1260
+
1261
+ # Define user with roles
1262
+ user = UserContext(
1263
+ user_id="analyst_001",
1264
+ tenant_id="company_abc",
1265
+ email="analyst@company.com",
1266
+ roles=["analyst", "viewer"]
1267
+ )
1268
+
1269
+ # Create secure runtime
1270
+ runtime = AccessControlledRuntime(user_context=user)
1271
+
1272
+ # Execute workflow with automatic permission checks
1273
+ results, run_id = runtime.execute(workflow, parameters={})
1274
+ ```
1275
+
1276
+ #### Multi-Tenant Isolation
1277
+ ```python
1278
+ from kailash.access_control import get_access_control_manager, PermissionEffect, WorkflowPermission
1279
+
1280
+ # Configure tenant-based access rules
1281
+ acm = get_access_control_manager()
1282
+ acm.enabled = True
1283
+
1284
+ # Tenant isolation rule
1285
+ acm.add_rule(PermissionRule(
1286
+ id="tenant_isolation",
1287
+ resource_type="workflow",
1288
+ resource_id="customer_analytics",
1289
+ permission=WorkflowPermission.EXECUTE,
1290
+ effect=PermissionEffect.ALLOW,
1291
+ tenant_id="company_abc" # Only this tenant can access
1292
+ ))
1293
+ ```
1294
+
1295
+ #### Data Masking and Field Protection
1296
+ ```python
1297
+ from kailash.nodes.base_with_acl import add_access_control
1298
+
1299
+ # Add access control to sensitive data nodes
1300
+ secure_reader = add_access_control(
1301
+ CSVReaderNode(file_path="customers.csv"),
1302
+ enable_access_control=True,
1303
+ required_permission=NodePermission.READ_OUTPUT,
1304
+ mask_output_fields=["ssn", "phone"] # Mask for non-admin users
1305
+ )
1306
+
1307
+ workflow.add_node("secure_data", secure_reader)
1308
+ ```
1309
+
1310
+ #### Permission-Based Routing
1311
+ ```python
1312
+ # Different execution paths based on user permissions
1313
+ from kailash.access_control import NodePermission
1314
+
1315
+ # Admin users get full processing
1316
+ admin_processor = PythonCodeNode.from_function(
1317
+ lambda data: {"result": process_all_data(data)},
1318
+ name="admin_processor"
1319
+ )
1320
+
1321
+ # Analyst users get limited processing
1322
+ analyst_processor = PythonCodeNode.from_function(
1323
+ lambda data: {"result": process_limited_data(data)},
1324
+ name="analyst_processor"
1325
+ )
1326
+
1327
+ # Runtime automatically routes based on user permissions
1328
+ workflow.add_node("admin_path", admin_processor)
1329
+ workflow.add_node("analyst_path", analyst_processor)
1330
+ ```
1331
+
1332
+ **Security Features:**
1333
+ - 🔐 **JWT Authentication**: Token-based authentication with refresh support
1334
+ - 👥 **Multi-Tenant Isolation**: Complete data separation between tenants
1335
+ - 🛡️ **Field-Level Security**: Mask sensitive data based on user roles
1336
+ - 📊 **Audit Logging**: Complete access attempt logging for compliance
1337
+ - 🚫 **Path Traversal Prevention**: Built-in protection against directory attacks
1338
+ - 🏗️ **Backward Compatibility**: Existing workflows work unchanged
1339
+ - ⚡ **Performance Optimized**: Minimal overhead with caching
1340
+
921
1341
  ## 💻 CLI Commands
922
1342
 
923
1343
  The SDK includes a comprehensive CLI for workflow management:
@@ -1104,7 +1524,7 @@ pre-commit run pytest-check
1104
1524
  <td width="40%">
1105
1525
 
1106
1526
  ### ✅ Completed
1107
- - Core node system with 15+ node types
1527
+ - Core node system with 66+ node types
1108
1528
  - Workflow builder with DAG validation
1109
1529
  - Local & async execution engines
1110
1530
  - Task tracking with metrics
@@ -1114,21 +1534,33 @@ pre-commit run pytest-check
1114
1534
  - Immutable state management
1115
1535
  - API integration with rate limiting
1116
1536
  - OAuth 2.0 authentication
1537
+ - Production security framework
1538
+ - Path traversal prevention
1539
+ - Code execution sandboxing
1540
+ - Comprehensive security testing
1117
1541
  - SharePoint Graph API integration
1542
+ - **Self-organizing agent pools with 13 specialized nodes**
1543
+ - **Agent-to-agent communication and shared memory**
1544
+ - **Intelligent caching and convergence detection**
1545
+ - **MCP integration for external tool access**
1546
+ - **Multi-strategy team formation algorithms**
1118
1547
  - **Real-time performance metrics collection**
1119
1548
  - **Performance visualization dashboards**
1120
1549
  - **Real-time monitoring dashboard with WebSocket streaming**
1121
1550
  - **Comprehensive performance reports (HTML, Markdown, JSON)**
1122
- - **89% test coverage (571 tests)**
1123
- - **15 test categories all passing**
1124
- - 37 working examples
1551
+ - **100% test coverage (591 tests)**
1552
+ - **All test categories passing**
1553
+ - 68 working examples
1125
1554
 
1126
1555
  </td>
1127
1556
  <td width="30%">
1128
1557
 
1129
1558
  ### 🚧 In Progress
1130
- - Comprehensive API documentation
1131
- - Security audit & hardening
1559
+ - **Kailash Workflow Studio** - Visual workflow builder UI
1560
+ - React-based drag-and-drop interface
1561
+ - Multi-tenant architecture with Docker
1562
+ - WorkflowStudioAPI backend
1563
+ - Real-time execution monitoring
1132
1564
  - Performance optimizations
1133
1565
  - Docker runtime finalization
1134
1566
 
@@ -1146,11 +1578,12 @@ pre-commit run pytest-check
1146
1578
  </table>
1147
1579
 
1148
1580
  ### 🎯 Test Suite Status
1149
- - **Total Tests**: 571 passing (89%)
1150
- - **Test Categories**: 15/15 at 100%
1151
- - **Integration Tests**: 65 passing
1152
- - **Examples**: 37/37 working
1153
- - **Code Coverage**: 89%
1581
+ - **Total Tests**: 591 passing (100%)
1582
+ - **Test Categories**: All passing
1583
+ - **Integration Tests**: All passing
1584
+ - **Security Tests**: 10 consolidated comprehensive tests
1585
+ - **Examples**: 68/68 working
1586
+ - **Code Coverage**: 100%
1154
1587
 
1155
1588
  ## ⚠️ Known Issues
1156
1589