kailash 0.8.4__py3-none-any.whl → 0.8.6__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.
- kailash/__init__.py +5 -11
- kailash/channels/__init__.py +2 -1
- kailash/channels/mcp_channel.py +23 -4
- kailash/cli/__init__.py +11 -1
- kailash/cli/validate_imports.py +202 -0
- kailash/cli/validation_audit.py +570 -0
- kailash/core/actors/supervisor.py +1 -1
- kailash/core/resilience/bulkhead.py +15 -5
- kailash/core/resilience/circuit_breaker.py +74 -1
- kailash/core/resilience/health_monitor.py +433 -33
- kailash/edge/compliance.py +33 -0
- kailash/edge/consistency.py +609 -0
- kailash/edge/coordination/__init__.py +30 -0
- kailash/edge/coordination/global_ordering.py +355 -0
- kailash/edge/coordination/leader_election.py +217 -0
- kailash/edge/coordination/partition_detector.py +296 -0
- kailash/edge/coordination/raft.py +485 -0
- kailash/edge/discovery.py +63 -1
- kailash/edge/migration/__init__.py +19 -0
- kailash/edge/migration/edge_migration_service.py +384 -0
- kailash/edge/migration/edge_migrator.py +832 -0
- kailash/edge/monitoring/__init__.py +21 -0
- kailash/edge/monitoring/edge_monitor.py +736 -0
- kailash/edge/prediction/__init__.py +10 -0
- kailash/edge/prediction/predictive_warmer.py +591 -0
- kailash/edge/resource/__init__.py +102 -0
- kailash/edge/resource/cloud_integration.py +796 -0
- kailash/edge/resource/cost_optimizer.py +949 -0
- kailash/edge/resource/docker_integration.py +919 -0
- kailash/edge/resource/kubernetes_integration.py +893 -0
- kailash/edge/resource/platform_integration.py +913 -0
- kailash/edge/resource/predictive_scaler.py +959 -0
- kailash/edge/resource/resource_analyzer.py +824 -0
- kailash/edge/resource/resource_pools.py +610 -0
- kailash/integrations/dataflow_edge.py +261 -0
- kailash/mcp_server/registry_integration.py +1 -1
- kailash/mcp_server/server.py +351 -8
- kailash/mcp_server/transports.py +305 -0
- kailash/middleware/gateway/event_store.py +1 -0
- kailash/monitoring/__init__.py +18 -0
- kailash/monitoring/alerts.py +646 -0
- kailash/monitoring/metrics.py +677 -0
- kailash/nodes/__init__.py +2 -0
- kailash/nodes/ai/semantic_memory.py +2 -2
- kailash/nodes/base.py +622 -1
- kailash/nodes/code/python.py +44 -3
- kailash/nodes/data/async_sql.py +42 -20
- kailash/nodes/edge/__init__.py +36 -0
- kailash/nodes/edge/base.py +240 -0
- kailash/nodes/edge/cloud_node.py +710 -0
- kailash/nodes/edge/coordination.py +239 -0
- kailash/nodes/edge/docker_node.py +825 -0
- kailash/nodes/edge/edge_data.py +582 -0
- kailash/nodes/edge/edge_migration_node.py +396 -0
- kailash/nodes/edge/edge_monitoring_node.py +421 -0
- kailash/nodes/edge/edge_state.py +673 -0
- kailash/nodes/edge/edge_warming_node.py +393 -0
- kailash/nodes/edge/kubernetes_node.py +652 -0
- kailash/nodes/edge/platform_node.py +766 -0
- kailash/nodes/edge/resource_analyzer_node.py +378 -0
- kailash/nodes/edge/resource_optimizer_node.py +501 -0
- kailash/nodes/edge/resource_scaler_node.py +397 -0
- kailash/nodes/governance.py +410 -0
- kailash/nodes/ports.py +676 -0
- kailash/nodes/rag/registry.py +1 -1
- kailash/nodes/transaction/distributed_transaction_manager.py +48 -1
- kailash/nodes/transaction/saga_state_storage.py +2 -1
- kailash/nodes/validation.py +8 -8
- kailash/runtime/local.py +374 -1
- kailash/runtime/validation/__init__.py +12 -0
- kailash/runtime/validation/connection_context.py +119 -0
- kailash/runtime/validation/enhanced_error_formatter.py +202 -0
- kailash/runtime/validation/error_categorizer.py +164 -0
- kailash/runtime/validation/import_validator.py +446 -0
- kailash/runtime/validation/metrics.py +380 -0
- kailash/runtime/validation/performance.py +615 -0
- kailash/runtime/validation/suggestion_engine.py +212 -0
- kailash/testing/fixtures.py +2 -2
- kailash/utils/data_paths.py +74 -0
- kailash/workflow/builder.py +413 -8
- kailash/workflow/contracts.py +418 -0
- kailash/workflow/edge_infrastructure.py +369 -0
- kailash/workflow/mermaid_visualizer.py +3 -1
- kailash/workflow/migration.py +3 -3
- kailash/workflow/templates.py +6 -6
- kailash/workflow/type_inference.py +669 -0
- kailash/workflow/validation.py +134 -3
- {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/METADATA +52 -34
- {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/RECORD +93 -42
- kailash/nexus/__init__.py +0 -21
- kailash/nexus/cli/__init__.py +0 -5
- kailash/nexus/cli/__main__.py +0 -6
- kailash/nexus/cli/main.py +0 -176
- kailash/nexus/factory.py +0 -413
- kailash/nexus/gateway.py +0 -545
- {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/WHEEL +0 -0
- {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/entry_points.txt +0 -0
- {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/licenses/LICENSE +0 -0
- {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/top_level.txt +0 -0
kailash/nexus/__init__.py
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
"""Kailash Nexus - Multi-channel workflow orchestration framework."""
|
2
|
-
|
3
|
-
from .factory import (
|
4
|
-
create_api_nexus,
|
5
|
-
create_cli_nexus,
|
6
|
-
create_development_nexus,
|
7
|
-
create_mcp_nexus,
|
8
|
-
create_nexus,
|
9
|
-
create_production_nexus,
|
10
|
-
)
|
11
|
-
from .gateway import NexusGateway
|
12
|
-
|
13
|
-
__all__ = [
|
14
|
-
"NexusGateway",
|
15
|
-
"create_nexus",
|
16
|
-
"create_api_nexus",
|
17
|
-
"create_cli_nexus",
|
18
|
-
"create_mcp_nexus",
|
19
|
-
"create_development_nexus",
|
20
|
-
"create_production_nexus",
|
21
|
-
]
|
kailash/nexus/cli/__init__.py
DELETED
kailash/nexus/cli/__main__.py
DELETED
kailash/nexus/cli/main.py
DELETED
@@ -1,176 +0,0 @@
|
|
1
|
-
"""Main CLI interface for Nexus workflow orchestration.
|
2
|
-
|
3
|
-
This module provides command-line access to Nexus workflows running on a server.
|
4
|
-
It connects to a running Nexus instance and allows listing and executing workflows.
|
5
|
-
"""
|
6
|
-
|
7
|
-
import argparse
|
8
|
-
import json
|
9
|
-
import sys
|
10
|
-
from typing import Any, Dict, Optional
|
11
|
-
|
12
|
-
import requests
|
13
|
-
|
14
|
-
|
15
|
-
class NexusCLI:
|
16
|
-
"""Command-line interface for Nexus workflows."""
|
17
|
-
|
18
|
-
def __init__(self, base_url: str = "http://localhost:8000"):
|
19
|
-
"""Initialize CLI with Nexus server URL.
|
20
|
-
|
21
|
-
Args:
|
22
|
-
base_url: Base URL of the Nexus server
|
23
|
-
"""
|
24
|
-
self.base_url = base_url.rstrip("/")
|
25
|
-
|
26
|
-
def list_workflows(self) -> None:
|
27
|
-
"""List all available workflows."""
|
28
|
-
try:
|
29
|
-
response = requests.get(f"{self.base_url}/workflows", timeout=5)
|
30
|
-
response.raise_for_status()
|
31
|
-
|
32
|
-
workflows = response.json()
|
33
|
-
|
34
|
-
if not workflows:
|
35
|
-
print("No workflows available.")
|
36
|
-
return
|
37
|
-
|
38
|
-
print("Available workflows:")
|
39
|
-
for workflow_name in sorted(workflows.keys()):
|
40
|
-
print(f" - {workflow_name}")
|
41
|
-
|
42
|
-
except requests.RequestException as e:
|
43
|
-
print(f"Error connecting to Nexus server: {e}", file=sys.stderr)
|
44
|
-
sys.exit(1)
|
45
|
-
except json.JSONDecodeError as e:
|
46
|
-
print(f"Error parsing server response: {e}", file=sys.stderr)
|
47
|
-
sys.exit(1)
|
48
|
-
|
49
|
-
def run_workflow(
|
50
|
-
self, workflow_name: str, parameters: Optional[Dict[str, Any]] = None
|
51
|
-
) -> None:
|
52
|
-
"""Execute a workflow with optional parameters.
|
53
|
-
|
54
|
-
Args:
|
55
|
-
workflow_name: Name of the workflow to execute
|
56
|
-
parameters: Optional parameters for the workflow
|
57
|
-
"""
|
58
|
-
try:
|
59
|
-
payload = {"parameters": parameters or {}}
|
60
|
-
|
61
|
-
response = requests.post(
|
62
|
-
f"{self.base_url}/workflows/{workflow_name}", json=payload, timeout=30
|
63
|
-
)
|
64
|
-
response.raise_for_status()
|
65
|
-
|
66
|
-
result = response.json()
|
67
|
-
|
68
|
-
# Handle enterprise workflow execution format
|
69
|
-
if "outputs" in result:
|
70
|
-
# Extract results from each node
|
71
|
-
for node_name, node_result in result["outputs"].items():
|
72
|
-
if "result" in node_result:
|
73
|
-
node_output = node_result["result"]
|
74
|
-
# Print meaningful output
|
75
|
-
for key, value in node_output.items():
|
76
|
-
print(f"{key}: {value}")
|
77
|
-
else:
|
78
|
-
# Handle direct result format
|
79
|
-
print(json.dumps(result, indent=2))
|
80
|
-
|
81
|
-
except requests.RequestException as e:
|
82
|
-
print(f"Error executing workflow: {e}", file=sys.stderr)
|
83
|
-
sys.exit(1)
|
84
|
-
except json.JSONDecodeError as e:
|
85
|
-
print(f"Error parsing execution result: {e}", file=sys.stderr)
|
86
|
-
sys.exit(1)
|
87
|
-
|
88
|
-
def parse_parameters(self, param_strings: list) -> Dict[str, Any]:
|
89
|
-
"""Parse parameter strings in key=value format.
|
90
|
-
|
91
|
-
Args:
|
92
|
-
param_strings: List of parameter strings in "key=value" format
|
93
|
-
|
94
|
-
Returns:
|
95
|
-
Dictionary of parsed parameters
|
96
|
-
"""
|
97
|
-
parameters = {}
|
98
|
-
|
99
|
-
for param_str in param_strings:
|
100
|
-
if "=" not in param_str:
|
101
|
-
print(
|
102
|
-
f"Invalid parameter format: {param_str}. Use key=value format.",
|
103
|
-
file=sys.stderr,
|
104
|
-
)
|
105
|
-
sys.exit(1)
|
106
|
-
|
107
|
-
key, value = param_str.split("=", 1)
|
108
|
-
|
109
|
-
# Try to parse as JSON for complex values, otherwise use as string
|
110
|
-
try:
|
111
|
-
parameters[key] = json.loads(value)
|
112
|
-
except json.JSONDecodeError:
|
113
|
-
parameters[key] = value
|
114
|
-
|
115
|
-
return parameters
|
116
|
-
|
117
|
-
|
118
|
-
def main():
|
119
|
-
"""Main CLI entry point."""
|
120
|
-
parser = argparse.ArgumentParser(
|
121
|
-
description="Nexus CLI - Command-line interface for workflow orchestration",
|
122
|
-
formatter_class=argparse.RawDescriptionHelpFormatter,
|
123
|
-
epilog="""
|
124
|
-
Examples:
|
125
|
-
python -m kailash.nexus.cli list
|
126
|
-
python -m kailash.nexus.cli run my-workflow
|
127
|
-
python -m kailash.nexus.cli run my-workflow --param name=value --param count=5
|
128
|
-
|
129
|
-
# Connect to different server:
|
130
|
-
python -m kailash.nexus.cli --url http://localhost:8001 list
|
131
|
-
""",
|
132
|
-
)
|
133
|
-
|
134
|
-
parser.add_argument(
|
135
|
-
"--url",
|
136
|
-
default="http://localhost:8000",
|
137
|
-
help="Base URL of the Nexus server (default: http://localhost:8000)",
|
138
|
-
)
|
139
|
-
|
140
|
-
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
141
|
-
|
142
|
-
# List command
|
143
|
-
list_parser = subparsers.add_parser("list", help="List available workflows")
|
144
|
-
|
145
|
-
# Run command
|
146
|
-
run_parser = subparsers.add_parser("run", help="Execute a workflow")
|
147
|
-
run_parser.add_argument("workflow", help="Name of the workflow to execute")
|
148
|
-
run_parser.add_argument(
|
149
|
-
"--param",
|
150
|
-
action="append",
|
151
|
-
default=[],
|
152
|
-
help="Workflow parameters in key=value format (can be used multiple times)",
|
153
|
-
)
|
154
|
-
|
155
|
-
args = parser.parse_args()
|
156
|
-
|
157
|
-
if not args.command:
|
158
|
-
parser.print_help()
|
159
|
-
sys.exit(1)
|
160
|
-
|
161
|
-
# Initialize CLI client
|
162
|
-
cli = NexusCLI(base_url=args.url)
|
163
|
-
|
164
|
-
# Execute command
|
165
|
-
if args.command == "list":
|
166
|
-
cli.list_workflows()
|
167
|
-
elif args.command == "run":
|
168
|
-
parameters = cli.parse_parameters(args.param)
|
169
|
-
cli.run_workflow(args.workflow, parameters)
|
170
|
-
else:
|
171
|
-
parser.print_help()
|
172
|
-
sys.exit(1)
|
173
|
-
|
174
|
-
|
175
|
-
if __name__ == "__main__":
|
176
|
-
main()
|
kailash/nexus/factory.py
DELETED
@@ -1,413 +0,0 @@
|
|
1
|
-
"""Factory functions for creating Nexus Gateway instances."""
|
2
|
-
|
3
|
-
import logging
|
4
|
-
from typing import Any, Dict, List, Optional, Union
|
5
|
-
|
6
|
-
from ..workflow import Workflow
|
7
|
-
from .gateway import NexusConfig, NexusGateway
|
8
|
-
|
9
|
-
logger = logging.getLogger(__name__)
|
10
|
-
|
11
|
-
|
12
|
-
def create_nexus(
|
13
|
-
name: Optional[str] = None,
|
14
|
-
description: Optional[str] = None,
|
15
|
-
# Channel configuration
|
16
|
-
enable_api: bool = True,
|
17
|
-
enable_cli: bool = True,
|
18
|
-
enable_mcp: bool = True,
|
19
|
-
# API settings
|
20
|
-
api_host: str = "localhost",
|
21
|
-
api_port: int = 8000,
|
22
|
-
api_cors_origins: Optional[List[str]] = None,
|
23
|
-
# CLI settings
|
24
|
-
cli_interactive: bool = False,
|
25
|
-
cli_prompt: str = "nexus> ",
|
26
|
-
# MCP settings
|
27
|
-
mcp_host: str = "localhost",
|
28
|
-
mcp_port: int = 3001,
|
29
|
-
mcp_server_name: Optional[str] = None,
|
30
|
-
# Session management
|
31
|
-
session_timeout: int = 3600,
|
32
|
-
session_cleanup_interval: int = 300,
|
33
|
-
# Event routing
|
34
|
-
enable_event_routing: bool = True,
|
35
|
-
event_queue_size: int = 10000,
|
36
|
-
# Advanced settings
|
37
|
-
enable_health_monitoring: bool = True,
|
38
|
-
health_check_interval: int = 30,
|
39
|
-
graceful_shutdown_timeout: int = 30,
|
40
|
-
# Initial workflows
|
41
|
-
workflows: Optional[Dict[str, Workflow]] = None,
|
42
|
-
# Custom configuration
|
43
|
-
**kwargs,
|
44
|
-
) -> NexusGateway:
|
45
|
-
"""Create a Nexus Gateway with the specified configuration.
|
46
|
-
|
47
|
-
This is the main entry point for creating a Nexus Gateway instance
|
48
|
-
with sensible defaults for different use cases.
|
49
|
-
|
50
|
-
Args:
|
51
|
-
name: Gateway name (defaults to "kailash-nexus")
|
52
|
-
description: Gateway description
|
53
|
-
|
54
|
-
# Channel Configuration
|
55
|
-
enable_api: Enable HTTP API channel
|
56
|
-
enable_cli: Enable CLI channel
|
57
|
-
enable_mcp: Enable MCP channel
|
58
|
-
|
59
|
-
# API Channel Settings
|
60
|
-
api_host: API server host
|
61
|
-
api_port: API server port
|
62
|
-
api_cors_origins: CORS origins for API
|
63
|
-
|
64
|
-
# CLI Channel Settings
|
65
|
-
cli_interactive: Enable interactive CLI mode
|
66
|
-
cli_prompt: CLI prompt template
|
67
|
-
|
68
|
-
# MCP Channel Settings
|
69
|
-
mcp_host: MCP server host
|
70
|
-
mcp_port: MCP server port
|
71
|
-
mcp_server_name: MCP server name
|
72
|
-
|
73
|
-
# Session Management
|
74
|
-
session_timeout: Session timeout in seconds
|
75
|
-
session_cleanup_interval: Session cleanup interval in seconds
|
76
|
-
|
77
|
-
# Event Routing
|
78
|
-
enable_event_routing: Enable cross-channel event routing
|
79
|
-
event_queue_size: Event queue size
|
80
|
-
|
81
|
-
# Advanced Settings
|
82
|
-
enable_health_monitoring: Enable background health monitoring
|
83
|
-
health_check_interval: Health check interval in seconds
|
84
|
-
graceful_shutdown_timeout: Graceful shutdown timeout in seconds
|
85
|
-
|
86
|
-
# Initial Workflows
|
87
|
-
workflows: Dictionary of workflows to register initially
|
88
|
-
|
89
|
-
# Custom Configuration
|
90
|
-
**kwargs: Additional configuration options
|
91
|
-
|
92
|
-
Returns:
|
93
|
-
Configured NexusGateway instance
|
94
|
-
|
95
|
-
Examples:
|
96
|
-
Create a basic Nexus with all channels:
|
97
|
-
>>> nexus = create_nexus()
|
98
|
-
|
99
|
-
Create API-only Nexus:
|
100
|
-
>>> nexus = create_nexus(
|
101
|
-
... enable_cli=False,
|
102
|
-
... enable_mcp=False,
|
103
|
-
... api_port=9000
|
104
|
-
... )
|
105
|
-
|
106
|
-
Create Nexus with custom configuration:
|
107
|
-
>>> nexus = create_nexus(
|
108
|
-
... name="my-nexus",
|
109
|
-
... description="Custom multi-channel gateway",
|
110
|
-
... api_port=8080,
|
111
|
-
... mcp_port=3002,
|
112
|
-
... session_timeout=7200, # 2 hours
|
113
|
-
... workflows={"my_workflow": my_workflow_instance}
|
114
|
-
... )
|
115
|
-
"""
|
116
|
-
|
117
|
-
# Build configuration
|
118
|
-
config = NexusConfig(
|
119
|
-
name=name or "kailash-nexus",
|
120
|
-
description=description or "Multi-channel workflow orchestration gateway",
|
121
|
-
# Channel configuration
|
122
|
-
enable_api=enable_api,
|
123
|
-
enable_cli=enable_cli,
|
124
|
-
enable_mcp=enable_mcp,
|
125
|
-
# API settings
|
126
|
-
api_host=api_host,
|
127
|
-
api_port=api_port,
|
128
|
-
api_cors_origins=api_cors_origins or ["*"],
|
129
|
-
# CLI settings
|
130
|
-
cli_interactive=cli_interactive,
|
131
|
-
cli_prompt_template=cli_prompt,
|
132
|
-
# MCP settings
|
133
|
-
mcp_host=mcp_host,
|
134
|
-
mcp_port=mcp_port,
|
135
|
-
mcp_server_name=mcp_server_name or f"{name or 'kailash'}-nexus-mcp",
|
136
|
-
# Session management
|
137
|
-
session_timeout=session_timeout,
|
138
|
-
session_cleanup_interval=session_cleanup_interval,
|
139
|
-
# Event routing
|
140
|
-
enable_event_routing=enable_event_routing,
|
141
|
-
event_queue_size=event_queue_size,
|
142
|
-
# Advanced settings
|
143
|
-
enable_health_monitoring=enable_health_monitoring,
|
144
|
-
health_check_interval=health_check_interval,
|
145
|
-
graceful_shutdown_timeout=graceful_shutdown_timeout,
|
146
|
-
)
|
147
|
-
|
148
|
-
# Apply any additional kwargs to config
|
149
|
-
for key, value in kwargs.items():
|
150
|
-
if hasattr(config, key):
|
151
|
-
setattr(config, key, value)
|
152
|
-
else:
|
153
|
-
logger.warning(f"Unknown configuration option: {key}")
|
154
|
-
|
155
|
-
# Create gateway
|
156
|
-
nexus = NexusGateway(config)
|
157
|
-
|
158
|
-
# Register initial workflows if provided
|
159
|
-
if workflows:
|
160
|
-
for workflow_name, workflow in workflows.items():
|
161
|
-
nexus.register_workflow(workflow_name, workflow)
|
162
|
-
logger.info(f"Registered initial workflow: {workflow_name}")
|
163
|
-
|
164
|
-
logger.info(f"Created Nexus Gateway: {config.name}")
|
165
|
-
logger.info(
|
166
|
-
f"Enabled channels: API={enable_api}, CLI={enable_cli}, MCP={enable_mcp}"
|
167
|
-
)
|
168
|
-
|
169
|
-
return nexus
|
170
|
-
|
171
|
-
|
172
|
-
def create_api_nexus(
|
173
|
-
name: Optional[str] = None,
|
174
|
-
port: int = 8000,
|
175
|
-
host: str = "localhost",
|
176
|
-
cors_origins: Optional[List[str]] = None,
|
177
|
-
workflows: Optional[Dict[str, Workflow]] = None,
|
178
|
-
**kwargs,
|
179
|
-
) -> NexusGateway:
|
180
|
-
"""Create an API-only Nexus Gateway.
|
181
|
-
|
182
|
-
This is a convenience function for creating a Nexus Gateway
|
183
|
-
that only exposes the HTTP API channel.
|
184
|
-
|
185
|
-
Args:
|
186
|
-
name: Gateway name
|
187
|
-
port: API server port
|
188
|
-
host: API server host
|
189
|
-
cors_origins: CORS origins
|
190
|
-
workflows: Initial workflows to register
|
191
|
-
**kwargs: Additional configuration options
|
192
|
-
|
193
|
-
Returns:
|
194
|
-
Configured NexusGateway with only API channel enabled
|
195
|
-
|
196
|
-
Example:
|
197
|
-
>>> nexus = create_api_nexus(
|
198
|
-
... name="api-only-nexus",
|
199
|
-
... port=9000,
|
200
|
-
... workflows={"my_workflow": workflow}
|
201
|
-
... )
|
202
|
-
"""
|
203
|
-
return create_nexus(
|
204
|
-
name=name or "kailash-api-nexus",
|
205
|
-
description="API-only workflow gateway",
|
206
|
-
enable_api=True,
|
207
|
-
enable_cli=False,
|
208
|
-
enable_mcp=False,
|
209
|
-
api_host=host,
|
210
|
-
api_port=port,
|
211
|
-
api_cors_origins=cors_origins,
|
212
|
-
workflows=workflows,
|
213
|
-
**kwargs,
|
214
|
-
)
|
215
|
-
|
216
|
-
|
217
|
-
def create_cli_nexus(
|
218
|
-
name: Optional[str] = None,
|
219
|
-
interactive: bool = True,
|
220
|
-
prompt: str = "nexus-cli> ",
|
221
|
-
workflows: Optional[Dict[str, Workflow]] = None,
|
222
|
-
**kwargs,
|
223
|
-
) -> NexusGateway:
|
224
|
-
"""Create a CLI-only Nexus Gateway.
|
225
|
-
|
226
|
-
This is a convenience function for creating a Nexus Gateway
|
227
|
-
that only exposes the CLI channel.
|
228
|
-
|
229
|
-
Args:
|
230
|
-
name: Gateway name
|
231
|
-
interactive: Enable interactive CLI mode
|
232
|
-
prompt: CLI prompt template
|
233
|
-
workflows: Initial workflows to register
|
234
|
-
**kwargs: Additional configuration options
|
235
|
-
|
236
|
-
Returns:
|
237
|
-
Configured NexusGateway with only CLI channel enabled
|
238
|
-
|
239
|
-
Example:
|
240
|
-
>>> nexus = create_cli_nexus(
|
241
|
-
... name="cli-nexus",
|
242
|
-
... interactive=True,
|
243
|
-
... workflows={"help": help_workflow}
|
244
|
-
... )
|
245
|
-
"""
|
246
|
-
return create_nexus(
|
247
|
-
name=name or "kailash-cli-nexus",
|
248
|
-
description="CLI-only workflow gateway",
|
249
|
-
enable_api=False,
|
250
|
-
enable_cli=True,
|
251
|
-
enable_mcp=False,
|
252
|
-
cli_interactive=interactive,
|
253
|
-
cli_prompt=prompt,
|
254
|
-
workflows=workflows,
|
255
|
-
**kwargs,
|
256
|
-
)
|
257
|
-
|
258
|
-
|
259
|
-
def create_mcp_nexus(
|
260
|
-
name: Optional[str] = None,
|
261
|
-
port: int = 3001,
|
262
|
-
host: str = "localhost",
|
263
|
-
server_name: Optional[str] = None,
|
264
|
-
workflows: Optional[Dict[str, Workflow]] = None,
|
265
|
-
**kwargs,
|
266
|
-
) -> NexusGateway:
|
267
|
-
"""Create an MCP-only Nexus Gateway.
|
268
|
-
|
269
|
-
This is a convenience function for creating a Nexus Gateway
|
270
|
-
that only exposes the MCP channel.
|
271
|
-
|
272
|
-
Args:
|
273
|
-
name: Gateway name
|
274
|
-
port: MCP server port
|
275
|
-
host: MCP server host
|
276
|
-
server_name: MCP server name
|
277
|
-
workflows: Initial workflows to register
|
278
|
-
**kwargs: Additional configuration options
|
279
|
-
|
280
|
-
Returns:
|
281
|
-
Configured NexusGateway with only MCP channel enabled
|
282
|
-
|
283
|
-
Example:
|
284
|
-
>>> nexus = create_mcp_nexus(
|
285
|
-
... name="mcp-nexus",
|
286
|
-
... port=3002,
|
287
|
-
... workflows={"ai_tool": ai_workflow}
|
288
|
-
... )
|
289
|
-
"""
|
290
|
-
return create_nexus(
|
291
|
-
name=name or "kailash-mcp-nexus",
|
292
|
-
description="MCP-only workflow gateway",
|
293
|
-
enable_api=False,
|
294
|
-
enable_cli=False,
|
295
|
-
enable_mcp=True,
|
296
|
-
mcp_host=host,
|
297
|
-
mcp_port=port,
|
298
|
-
mcp_server_name=server_name,
|
299
|
-
workflows=workflows,
|
300
|
-
**kwargs,
|
301
|
-
)
|
302
|
-
|
303
|
-
|
304
|
-
def create_development_nexus(
|
305
|
-
name: Optional[str] = None,
|
306
|
-
api_port: int = 8000,
|
307
|
-
mcp_port: int = 3001,
|
308
|
-
workflows: Optional[Dict[str, Workflow]] = None,
|
309
|
-
**kwargs,
|
310
|
-
) -> NexusGateway:
|
311
|
-
"""Create a development-focused Nexus Gateway.
|
312
|
-
|
313
|
-
This configuration is optimized for development with:
|
314
|
-
- All channels enabled
|
315
|
-
- Interactive CLI
|
316
|
-
- Health monitoring
|
317
|
-
- Verbose logging
|
318
|
-
- Short timeouts for faster iteration
|
319
|
-
|
320
|
-
Args:
|
321
|
-
name: Gateway name
|
322
|
-
api_port: API server port
|
323
|
-
mcp_port: MCP server port
|
324
|
-
workflows: Initial workflows to register
|
325
|
-
**kwargs: Additional configuration options
|
326
|
-
|
327
|
-
Returns:
|
328
|
-
Configured NexusGateway optimized for development
|
329
|
-
|
330
|
-
Example:
|
331
|
-
>>> nexus = create_development_nexus(
|
332
|
-
... name="dev-nexus",
|
333
|
-
... workflows={"test": test_workflow}
|
334
|
-
... )
|
335
|
-
"""
|
336
|
-
return create_nexus(
|
337
|
-
name=name or "kailash-dev-nexus",
|
338
|
-
description="Development multi-channel gateway",
|
339
|
-
# Enable all channels
|
340
|
-
enable_api=True,
|
341
|
-
enable_cli=True,
|
342
|
-
enable_mcp=True,
|
343
|
-
# Development-friendly settings
|
344
|
-
api_port=api_port,
|
345
|
-
mcp_port=mcp_port,
|
346
|
-
cli_interactive=True,
|
347
|
-
cli_prompt="dev-nexus> ",
|
348
|
-
# Faster cleanup for development
|
349
|
-
session_timeout=1800, # 30 minutes
|
350
|
-
session_cleanup_interval=60, # 1 minute
|
351
|
-
health_check_interval=10, # 10 seconds
|
352
|
-
graceful_shutdown_timeout=10, # 10 seconds
|
353
|
-
# Enhanced monitoring
|
354
|
-
enable_health_monitoring=True,
|
355
|
-
enable_event_routing=True,
|
356
|
-
workflows=workflows,
|
357
|
-
**kwargs,
|
358
|
-
)
|
359
|
-
|
360
|
-
|
361
|
-
def create_production_nexus(
|
362
|
-
name: Optional[str] = None,
|
363
|
-
api_port: int = 80,
|
364
|
-
mcp_port: int = 3001,
|
365
|
-
workflows: Optional[Dict[str, Workflow]] = None,
|
366
|
-
**kwargs,
|
367
|
-
) -> NexusGateway:
|
368
|
-
"""Create a production-optimized Nexus Gateway.
|
369
|
-
|
370
|
-
This configuration is optimized for production with:
|
371
|
-
- Conservative timeouts
|
372
|
-
- Enhanced monitoring
|
373
|
-
- Larger queue sizes
|
374
|
-
- Robust error handling
|
375
|
-
|
376
|
-
Args:
|
377
|
-
name: Gateway name
|
378
|
-
api_port: API server port (defaults to 80 for production)
|
379
|
-
mcp_port: MCP server port
|
380
|
-
workflows: Initial workflows to register
|
381
|
-
**kwargs: Additional configuration options
|
382
|
-
|
383
|
-
Returns:
|
384
|
-
Configured NexusGateway optimized for production
|
385
|
-
|
386
|
-
Example:
|
387
|
-
>>> nexus = create_production_nexus(
|
388
|
-
... name="prod-nexus",
|
389
|
-
... api_port=8080,
|
390
|
-
... workflows=production_workflows
|
391
|
-
... )
|
392
|
-
"""
|
393
|
-
return create_nexus(
|
394
|
-
name=name or "kailash-prod-nexus",
|
395
|
-
description="Production multi-channel gateway",
|
396
|
-
# Production ports
|
397
|
-
api_port=api_port,
|
398
|
-
mcp_port=mcp_port,
|
399
|
-
# Conservative timeouts
|
400
|
-
session_timeout=7200, # 2 hours
|
401
|
-
session_cleanup_interval=300, # 5 minutes
|
402
|
-
health_check_interval=60, # 1 minute
|
403
|
-
graceful_shutdown_timeout=60, # 1 minute
|
404
|
-
# Larger queues for production load
|
405
|
-
event_queue_size=50000,
|
406
|
-
# Enhanced monitoring
|
407
|
-
enable_health_monitoring=True,
|
408
|
-
enable_event_routing=True,
|
409
|
-
# CLI disabled by default in production
|
410
|
-
enable_cli=False,
|
411
|
-
workflows=workflows,
|
412
|
-
**kwargs,
|
413
|
-
)
|