solace-agent-mesh 0.0.1__py3-none-any.whl → 0.1.1__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.
Potentially problematic release.
This version of solace-agent-mesh might be problematic. Click here for more details.
- solace_agent_mesh/__init__.py +0 -3
- solace_agent_mesh/agents/__init__.py +0 -0
- solace_agent_mesh/agents/base_agent_component.py +224 -0
- solace_agent_mesh/agents/global/__init__.py +0 -0
- solace_agent_mesh/agents/global/actions/__init__.py +0 -0
- solace_agent_mesh/agents/global/actions/agent_state_change.py +54 -0
- solace_agent_mesh/agents/global/actions/clear_history.py +32 -0
- solace_agent_mesh/agents/global/actions/convert_file_to_markdown.py +160 -0
- solace_agent_mesh/agents/global/actions/create_file.py +70 -0
- solace_agent_mesh/agents/global/actions/error_action.py +45 -0
- solace_agent_mesh/agents/global/actions/plantuml_diagram.py +93 -0
- solace_agent_mesh/agents/global/actions/plotly_graph.py +117 -0
- solace_agent_mesh/agents/global/actions/retrieve_file.py +51 -0
- solace_agent_mesh/agents/global/global_agent_component.py +38 -0
- solace_agent_mesh/agents/image_processing/__init__.py +0 -0
- solace_agent_mesh/agents/image_processing/actions/__init__.py +0 -0
- solace_agent_mesh/agents/image_processing/actions/create_image.py +75 -0
- solace_agent_mesh/agents/image_processing/actions/describe_image.py +115 -0
- solace_agent_mesh/agents/image_processing/image_processing_agent_component.py +23 -0
- solace_agent_mesh/agents/slack/__init__.py +1 -0
- solace_agent_mesh/agents/slack/actions/__init__.py +1 -0
- solace_agent_mesh/agents/slack/actions/post_message.py +177 -0
- solace_agent_mesh/agents/slack/slack_agent_component.py +59 -0
- solace_agent_mesh/agents/web_request/__init__.py +0 -0
- solace_agent_mesh/agents/web_request/actions/__init__.py +0 -0
- solace_agent_mesh/agents/web_request/actions/do_image_search.py +84 -0
- solace_agent_mesh/agents/web_request/actions/do_news_search.py +47 -0
- solace_agent_mesh/agents/web_request/actions/do_suggestion_search.py +34 -0
- solace_agent_mesh/agents/web_request/actions/do_web_request.py +134 -0
- solace_agent_mesh/agents/web_request/actions/download_file.py +69 -0
- solace_agent_mesh/agents/web_request/web_request_agent_component.py +33 -0
- solace_agent_mesh/assets/web-visualizer/assets/index-C5awueeJ.js +109 -0
- solace_agent_mesh/assets/web-visualizer/assets/index-D0qORgkg.css +1 -0
- solace_agent_mesh/assets/web-visualizer/index.html +14 -0
- solace_agent_mesh/assets/web-visualizer/vite.svg +1 -0
- solace_agent_mesh/cli/__init__.py +1 -0
- solace_agent_mesh/cli/commands/__init__.py +0 -0
- solace_agent_mesh/cli/commands/add/__init__.py +3 -0
- solace_agent_mesh/cli/commands/add/add.py +88 -0
- solace_agent_mesh/cli/commands/add/agent.py +110 -0
- solace_agent_mesh/cli/commands/add/copy_from_plugin.py +90 -0
- solace_agent_mesh/cli/commands/add/gateway.py +221 -0
- solace_agent_mesh/cli/commands/build.py +631 -0
- solace_agent_mesh/cli/commands/chat/__init__.py +3 -0
- solace_agent_mesh/cli/commands/chat/chat.py +361 -0
- solace_agent_mesh/cli/commands/config.py +29 -0
- solace_agent_mesh/cli/commands/init/__init__.py +3 -0
- solace_agent_mesh/cli/commands/init/ai_provider_step.py +76 -0
- solace_agent_mesh/cli/commands/init/broker_step.py +102 -0
- solace_agent_mesh/cli/commands/init/builtin_agent_step.py +88 -0
- solace_agent_mesh/cli/commands/init/check_if_already_done.py +13 -0
- solace_agent_mesh/cli/commands/init/create_config_file_step.py +52 -0
- solace_agent_mesh/cli/commands/init/create_other_project_files_step.py +96 -0
- solace_agent_mesh/cli/commands/init/file_service_step.py +73 -0
- solace_agent_mesh/cli/commands/init/init.py +114 -0
- solace_agent_mesh/cli/commands/init/project_structure_step.py +45 -0
- solace_agent_mesh/cli/commands/init/rest_api_step.py +50 -0
- solace_agent_mesh/cli/commands/init/web_ui_step.py +40 -0
- solace_agent_mesh/cli/commands/plugin/__init__.py +3 -0
- solace_agent_mesh/cli/commands/plugin/add.py +98 -0
- solace_agent_mesh/cli/commands/plugin/build.py +217 -0
- solace_agent_mesh/cli/commands/plugin/create.py +117 -0
- solace_agent_mesh/cli/commands/plugin/plugin.py +109 -0
- solace_agent_mesh/cli/commands/plugin/remove.py +71 -0
- solace_agent_mesh/cli/commands/run.py +68 -0
- solace_agent_mesh/cli/commands/visualizer.py +138 -0
- solace_agent_mesh/cli/config.py +81 -0
- solace_agent_mesh/cli/main.py +306 -0
- solace_agent_mesh/cli/utils.py +246 -0
- solace_agent_mesh/common/__init__.py +0 -0
- solace_agent_mesh/common/action.py +91 -0
- solace_agent_mesh/common/action_list.py +37 -0
- solace_agent_mesh/common/action_response.py +327 -0
- solace_agent_mesh/common/constants.py +3 -0
- solace_agent_mesh/common/mysql_database.py +40 -0
- solace_agent_mesh/common/postgres_database.py +79 -0
- solace_agent_mesh/common/prompt_templates.py +30 -0
- solace_agent_mesh/common/prompt_templates_unused_delete.py +161 -0
- solace_agent_mesh/common/stimulus_utils.py +152 -0
- solace_agent_mesh/common/time.py +24 -0
- solace_agent_mesh/common/utils.py +638 -0
- solace_agent_mesh/configs/agent_global.yaml +74 -0
- solace_agent_mesh/configs/agent_image_processing.yaml +82 -0
- solace_agent_mesh/configs/agent_slack.yaml +64 -0
- solace_agent_mesh/configs/agent_web_request.yaml +75 -0
- solace_agent_mesh/configs/conversation_to_file.yaml +56 -0
- solace_agent_mesh/configs/error_catcher.yaml +56 -0
- solace_agent_mesh/configs/monitor.yaml +0 -0
- solace_agent_mesh/configs/monitor_stim_and_errors_to_slack.yaml +106 -0
- solace_agent_mesh/configs/monitor_user_feedback.yaml +58 -0
- solace_agent_mesh/configs/orchestrator.yaml +241 -0
- solace_agent_mesh/configs/service_embedding.yaml +81 -0
- solace_agent_mesh/configs/service_llm.yaml +265 -0
- solace_agent_mesh/configs/visualize_websocket.yaml +55 -0
- solace_agent_mesh/gateway/__init__.py +0 -0
- solace_agent_mesh/gateway/components/__init__.py +0 -0
- solace_agent_mesh/gateway/components/gateway_base.py +41 -0
- solace_agent_mesh/gateway/components/gateway_input.py +265 -0
- solace_agent_mesh/gateway/components/gateway_output.py +289 -0
- solace_agent_mesh/gateway/identity/bamboohr_identity.py +18 -0
- solace_agent_mesh/gateway/identity/identity_base.py +10 -0
- solace_agent_mesh/gateway/identity/identity_provider.py +60 -0
- solace_agent_mesh/gateway/identity/no_identity.py +9 -0
- solace_agent_mesh/gateway/identity/passthru_identity.py +9 -0
- solace_agent_mesh/monitors/base_monitor_component.py +26 -0
- solace_agent_mesh/monitors/feedback/user_feedback_monitor.py +75 -0
- solace_agent_mesh/monitors/stim_and_errors/stim_and_error_monitor.py +560 -0
- solace_agent_mesh/orchestrator/__init__.py +0 -0
- solace_agent_mesh/orchestrator/action_manager.py +225 -0
- solace_agent_mesh/orchestrator/components/__init__.py +0 -0
- solace_agent_mesh/orchestrator/components/orchestrator_action_manager_timeout_component.py +54 -0
- solace_agent_mesh/orchestrator/components/orchestrator_action_response_component.py +179 -0
- solace_agent_mesh/orchestrator/components/orchestrator_register_component.py +107 -0
- solace_agent_mesh/orchestrator/components/orchestrator_stimulus_processor_component.py +477 -0
- solace_agent_mesh/orchestrator/components/orchestrator_streaming_output_component.py +246 -0
- solace_agent_mesh/orchestrator/orchestrator_main.py +166 -0
- solace_agent_mesh/orchestrator/orchestrator_prompt.py +410 -0
- solace_agent_mesh/services/__init__.py +0 -0
- solace_agent_mesh/services/authorization/providers/base_authorization_provider.py +56 -0
- solace_agent_mesh/services/bamboo_hr_service/__init__.py +3 -0
- solace_agent_mesh/services/bamboo_hr_service/bamboo_hr.py +182 -0
- solace_agent_mesh/services/common/__init__.py +4 -0
- solace_agent_mesh/services/common/auto_expiry.py +45 -0
- solace_agent_mesh/services/common/singleton.py +18 -0
- solace_agent_mesh/services/file_service/__init__.py +14 -0
- solace_agent_mesh/services/file_service/file_manager/__init__.py +0 -0
- solace_agent_mesh/services/file_service/file_manager/bucket_file_manager.py +149 -0
- solace_agent_mesh/services/file_service/file_manager/file_manager_base.py +162 -0
- solace_agent_mesh/services/file_service/file_manager/memory_file_manager.py +64 -0
- solace_agent_mesh/services/file_service/file_manager/volume_file_manager.py +106 -0
- solace_agent_mesh/services/file_service/file_service.py +432 -0
- solace_agent_mesh/services/file_service/file_service_constants.py +54 -0
- solace_agent_mesh/services/file_service/file_transformations.py +131 -0
- solace_agent_mesh/services/file_service/file_utils.py +322 -0
- solace_agent_mesh/services/file_service/transformers/__init__.py +5 -0
- solace_agent_mesh/services/history_service/__init__.py +3 -0
- solace_agent_mesh/services/history_service/history_providers/__init__.py +0 -0
- solace_agent_mesh/services/history_service/history_providers/base_history_provider.py +78 -0
- solace_agent_mesh/services/history_service/history_providers/memory_history_provider.py +167 -0
- solace_agent_mesh/services/history_service/history_providers/redis_history_provider.py +163 -0
- solace_agent_mesh/services/history_service/history_service.py +139 -0
- solace_agent_mesh/services/llm_service/components/llm_request_component.py +293 -0
- solace_agent_mesh/services/llm_service/components/llm_service_component_base.py +152 -0
- solace_agent_mesh/services/middleware_service/__init__.py +0 -0
- solace_agent_mesh/services/middleware_service/middleware_service.py +20 -0
- solace_agent_mesh/templates/action.py +38 -0
- solace_agent_mesh/templates/agent.py +29 -0
- solace_agent_mesh/templates/agent.yaml +70 -0
- solace_agent_mesh/templates/gateway-config-template.yaml +6 -0
- solace_agent_mesh/templates/gateway-default-config.yaml +28 -0
- solace_agent_mesh/templates/gateway-flows.yaml +81 -0
- solace_agent_mesh/templates/gateway-header.yaml +16 -0
- solace_agent_mesh/templates/gateway_base.py +15 -0
- solace_agent_mesh/templates/gateway_input.py +98 -0
- solace_agent_mesh/templates/gateway_output.py +71 -0
- solace_agent_mesh/templates/plugin-pyproject.toml +30 -0
- solace_agent_mesh/templates/rest-api-default-config.yaml +24 -0
- solace_agent_mesh/templates/rest-api-flows.yaml +80 -0
- solace_agent_mesh/templates/slack-default-config.yaml +9 -0
- solace_agent_mesh/templates/slack-flows.yaml +90 -0
- solace_agent_mesh/templates/solace-agent-mesh-default.yaml +77 -0
- solace_agent_mesh/templates/solace-agent-mesh-plugin-default.yaml +8 -0
- solace_agent_mesh/templates/web-default-config.yaml +5 -0
- solace_agent_mesh/templates/web-flows.yaml +86 -0
- solace_agent_mesh/tools/__init__.py +0 -0
- solace_agent_mesh/tools/components/__init__.py +0 -0
- solace_agent_mesh/tools/components/conversation_formatter.py +111 -0
- solace_agent_mesh/tools/components/file_resolver_component.py +58 -0
- solace_agent_mesh/tools/config/runtime_config.py +26 -0
- solace_agent_mesh-0.1.1.dist-info/METADATA +179 -0
- solace_agent_mesh-0.1.1.dist-info/RECORD +174 -0
- solace_agent_mesh-0.1.1.dist-info/entry_points.txt +3 -0
- solace_agent_mesh-0.0.1.dist-info/licenses/LICENSE.txt → solace_agent_mesh-0.1.1.dist-info/licenses/LICENSE +1 -2
- solace_agent_mesh-0.0.1.dist-info/METADATA +0 -51
- solace_agent_mesh-0.0.1.dist-info/RECORD +0 -5
- {solace_agent_mesh-0.0.1.dist-info → solace_agent_mesh-0.1.1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import http.server
|
|
3
|
+
import socketserver
|
|
4
|
+
import socket
|
|
5
|
+
import click
|
|
6
|
+
import json
|
|
7
|
+
|
|
8
|
+
from cli.utils import get_cli_root_dir, log_error
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_local_ip():
|
|
12
|
+
"""Get the local IP address of the machine."""
|
|
13
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
14
|
+
try:
|
|
15
|
+
# Connect to an external address, doesn't send any packets, just determines IP
|
|
16
|
+
s.connect(("8.8.8.8", 80))
|
|
17
|
+
ip = s.getsockname()[0]
|
|
18
|
+
except Exception:
|
|
19
|
+
ip = "localhost"
|
|
20
|
+
finally:
|
|
21
|
+
s.close()
|
|
22
|
+
return ip
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_wss_url(url: str) -> str:
|
|
26
|
+
"""Get the WSS URL from a WS URL."""
|
|
27
|
+
if url.startswith("ws://") or url.startswith("wss://"):
|
|
28
|
+
return url
|
|
29
|
+
elif url.startswith("tcp://"):
|
|
30
|
+
url = url.replace("tcp://", "ws://")
|
|
31
|
+
# Change port to 443
|
|
32
|
+
if len(url.split(":")) > 1:
|
|
33
|
+
url = url.split(":")
|
|
34
|
+
url[-1] = "443"
|
|
35
|
+
url = ":".join(url)
|
|
36
|
+
elif url.startswith("tcps://"):
|
|
37
|
+
url = url.replace("tcps://", "wss://")
|
|
38
|
+
# Change port to 443
|
|
39
|
+
if len(url.split(":")) > 1:
|
|
40
|
+
url = url.split(":")
|
|
41
|
+
url[-1] = "443"
|
|
42
|
+
url = ":".join(url)
|
|
43
|
+
return url
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def visualizer_command(port, find_unused_port=False, host=False, use_env=False):
|
|
47
|
+
"""Runs a GUI web-based visualizer for inspecting events inside the solace agent mesh."""
|
|
48
|
+
config = click.get_current_context().obj["solace_agent_mesh"]
|
|
49
|
+
if use_env:
|
|
50
|
+
try:
|
|
51
|
+
from dotenv import load_dotenv
|
|
52
|
+
|
|
53
|
+
env_file = config["env_file"]
|
|
54
|
+
load_dotenv(env_file, override=True)
|
|
55
|
+
except ImportError:
|
|
56
|
+
log_error(
|
|
57
|
+
"Failed to import dotenv. Please install it using 'pip install python-dotenv'"
|
|
58
|
+
)
|
|
59
|
+
return 1
|
|
60
|
+
except Exception as e:
|
|
61
|
+
log_error(f"Failed to load environment variables. {e}")
|
|
62
|
+
return 1
|
|
63
|
+
|
|
64
|
+
visualizer_directory = os.path.join(get_cli_root_dir(), "assets", "web-visualizer")
|
|
65
|
+
# Check if the visualizer directory exists
|
|
66
|
+
if not os.path.exists(visualizer_directory):
|
|
67
|
+
visualizer_directory = os.path.join(
|
|
68
|
+
get_cli_root_dir(), "web-visualizer", "dist"
|
|
69
|
+
)
|
|
70
|
+
if not os.path.exists(visualizer_directory):
|
|
71
|
+
log_error("Error: Built Web-Visualizer directory not found.")
|
|
72
|
+
return 1
|
|
73
|
+
|
|
74
|
+
# Find an unused port if the specified port is in use
|
|
75
|
+
while True:
|
|
76
|
+
# Check if port is available
|
|
77
|
+
try:
|
|
78
|
+
with socketserver.TCPServer(("localhost", port), None) as s:
|
|
79
|
+
pass
|
|
80
|
+
except OSError:
|
|
81
|
+
log_error(f"Error: Port {port} is already in use.")
|
|
82
|
+
if find_unused_port:
|
|
83
|
+
port += 1
|
|
84
|
+
click.echo(f"Trying port {port}...")
|
|
85
|
+
continue
|
|
86
|
+
else:
|
|
87
|
+
return 1
|
|
88
|
+
break
|
|
89
|
+
|
|
90
|
+
# Change the current working directory to the visualizer directory
|
|
91
|
+
os.chdir(visualizer_directory)
|
|
92
|
+
|
|
93
|
+
# Write the Solace broker configuration to a file for client pickup
|
|
94
|
+
config = {
|
|
95
|
+
"url": get_wss_url(os.getenv("SOLACE_BROKER_URL", "")),
|
|
96
|
+
"username": os.getenv("SOLACE_BROKER_USERNAME", ""),
|
|
97
|
+
"password": os.getenv("SOLACE_BROKER_PASSWORD", ""),
|
|
98
|
+
"vpn": os.getenv("SOLACE_BROKER_VPN", ""),
|
|
99
|
+
"namespace": os.getenv("SOLACE_AGENT_MESH_NAMESPACE", ""),
|
|
100
|
+
}
|
|
101
|
+
with open("config.json", "w") as f:
|
|
102
|
+
json.dump(config, f)
|
|
103
|
+
|
|
104
|
+
# Set up a handler to serve files from the specified directory
|
|
105
|
+
handler = http.server.SimpleHTTPRequestHandler
|
|
106
|
+
|
|
107
|
+
# Determine the host binding
|
|
108
|
+
if host:
|
|
109
|
+
# Bind to '0.0.0.0' to expose to the network
|
|
110
|
+
bind_address = "0.0.0.0"
|
|
111
|
+
local_ip = get_local_ip() # Get local network IP address
|
|
112
|
+
else:
|
|
113
|
+
# Bind to 'localhost' to restrict access to the local machine
|
|
114
|
+
bind_address = "localhost"
|
|
115
|
+
local_ip = "localhost"
|
|
116
|
+
|
|
117
|
+
# Start the server
|
|
118
|
+
with socketserver.TCPServer((bind_address, port), handler) as httpd:
|
|
119
|
+
click.echo(f"Serving solace-agent-mesh web-visualizer.")
|
|
120
|
+
click.echo(
|
|
121
|
+
click.style(f"\tLocal: http://localhost:{port}", bold=True, fg="blue")
|
|
122
|
+
)
|
|
123
|
+
click.echo(
|
|
124
|
+
click.style(
|
|
125
|
+
"\tNetwork: "
|
|
126
|
+
+ (f"http://{local_ip}:{port}" if host else "use --host to expose"),
|
|
127
|
+
bold=True,
|
|
128
|
+
fg="blue",
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
click.echo("Press Ctrl+C to stop the server.")
|
|
132
|
+
try:
|
|
133
|
+
httpd.serve_forever()
|
|
134
|
+
except KeyboardInterrupt:
|
|
135
|
+
click.echo("Shutting down server.")
|
|
136
|
+
httpd.shutdown()
|
|
137
|
+
finally:
|
|
138
|
+
os.remove("config.json")
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from ruamel.yaml import YAML
|
|
3
|
+
|
|
4
|
+
# Initialize a YAML object
|
|
5
|
+
yaml = YAML()
|
|
6
|
+
yaml.preserve_quotes = True # To preserve quotes in the YAML
|
|
7
|
+
|
|
8
|
+
from cli.utils import merge_dicts, load_template, remove_duplicate
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Config:
|
|
12
|
+
default_config_file = "solace-agent-mesh-default.yaml"
|
|
13
|
+
user_config_file = "solace-agent-mesh.yaml"
|
|
14
|
+
user_plugin_config_file = "solace-agent-mesh-plugin.yaml"
|
|
15
|
+
default_plugin_config_file = "solace-agent-mesh-plugin-default.yaml"
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def get_default_config():
|
|
19
|
+
loaded_config = load_template(Config.default_config_file)
|
|
20
|
+
return yaml.load(loaded_config)
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def get_default_plugin_config():
|
|
24
|
+
loaded_config = load_template(Config.default_plugin_config_file)
|
|
25
|
+
return yaml.load(loaded_config)
|
|
26
|
+
|
|
27
|
+
@staticmethod
|
|
28
|
+
def get_user_config(config_file=None):
|
|
29
|
+
config_file_path = config_file or Config.user_config_file
|
|
30
|
+
if os.path.exists(config_file_path):
|
|
31
|
+
with open(config_file_path, "r", encoding="utf-8") as f:
|
|
32
|
+
return yaml.load(f) or {}
|
|
33
|
+
return {}
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def get_user_plugin_config(config_file=None):
|
|
37
|
+
config_file_path = config_file or Config.user_plugin_config_file
|
|
38
|
+
if os.path.exists(config_file_path):
|
|
39
|
+
with open(config_file_path, "r", encoding="utf-8") as f:
|
|
40
|
+
return yaml.load(f) or {}
|
|
41
|
+
return {}
|
|
42
|
+
|
|
43
|
+
@staticmethod
|
|
44
|
+
def get_config(config_file=None):
|
|
45
|
+
user_config = Config.get_user_config(config_file)
|
|
46
|
+
default_config = Config.get_default_config()
|
|
47
|
+
# Merge user config with default config
|
|
48
|
+
merged_config = merge_dicts(default_config, user_config)
|
|
49
|
+
merged_config["solace_agent_mesh"]["built_in"]["agents"] = remove_duplicate(
|
|
50
|
+
merged_config["solace_agent_mesh"]["built_in"]["agents"],
|
|
51
|
+
lambda agent: agent.get("name"),
|
|
52
|
+
)
|
|
53
|
+
return merged_config
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def get_plugin_config(config_file=None):
|
|
57
|
+
user_config = Config.get_user_plugin_config(config_file)
|
|
58
|
+
default_config = Config.get_default_plugin_config()
|
|
59
|
+
# Merge user config with default config
|
|
60
|
+
merged_config = merge_dicts(default_config, user_config)
|
|
61
|
+
return merged_config
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def is_plugin_project():
|
|
65
|
+
return os.path.exists(Config.user_plugin_config_file)
|
|
66
|
+
|
|
67
|
+
@staticmethod
|
|
68
|
+
@staticmethod
|
|
69
|
+
def write_config(config, path=None):
|
|
70
|
+
if not path:
|
|
71
|
+
path = Config.user_config_file
|
|
72
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
73
|
+
yaml.dump(config, f)
|
|
74
|
+
|
|
75
|
+
@staticmethod
|
|
76
|
+
def load_config(path=None):
|
|
77
|
+
if not path:
|
|
78
|
+
path = Config.user_config_file
|
|
79
|
+
if os.path.exists(path):
|
|
80
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
81
|
+
return yaml.load(f)
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import click
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
+
sys.path.append(os.path.dirname(SCRIPT_DIR))
|
|
7
|
+
|
|
8
|
+
from cli.config import Config
|
|
9
|
+
from cli.commands.config import config_command
|
|
10
|
+
from cli.commands.add import add_command
|
|
11
|
+
from cli.commands.build import build_command
|
|
12
|
+
from cli.commands.run import run_command
|
|
13
|
+
from cli.commands.visualizer import visualizer_command
|
|
14
|
+
from cli.commands.init import init_command
|
|
15
|
+
from cli.commands.plugin import plugin_command
|
|
16
|
+
from cli.commands.chat import chat_command
|
|
17
|
+
from cli import __version__
|
|
18
|
+
|
|
19
|
+
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@click.group(context_settings=CONTEXT_SETTINGS)
|
|
23
|
+
@click.version_option(__version__)
|
|
24
|
+
@click.pass_context
|
|
25
|
+
@click.option(
|
|
26
|
+
"-c",
|
|
27
|
+
"--config-file",
|
|
28
|
+
type=click.Path(),
|
|
29
|
+
help="Path to solace-agent-mesh.yaml file. By default, it looks for the file in the current directory.",
|
|
30
|
+
)
|
|
31
|
+
def cli(ctx=None, config_file=None):
|
|
32
|
+
"""Solace Agent Mesh CLI application.
|
|
33
|
+
|
|
34
|
+
This cli application can be used to create, build, and run Solace Agent Mesh systems.
|
|
35
|
+
"""
|
|
36
|
+
try:
|
|
37
|
+
ctx.obj = Config.get_config(config_file)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
click.echo(f"Failed to load configurations: {e}")
|
|
40
|
+
sys.exit(1)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@cli.group()
|
|
44
|
+
def add():
|
|
45
|
+
"""
|
|
46
|
+
Creates a template for an agent or gateway.
|
|
47
|
+
"""
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@cli.command()
|
|
52
|
+
@click.option(
|
|
53
|
+
"-y", default=False, is_flag=True, help="Skip confirmation and build immediately."
|
|
54
|
+
)
|
|
55
|
+
@click.option(
|
|
56
|
+
"-N",
|
|
57
|
+
"--no-init",
|
|
58
|
+
default=False,
|
|
59
|
+
is_flag=True,
|
|
60
|
+
help="Skip running the init command if not already run.",
|
|
61
|
+
)
|
|
62
|
+
def build(y, no_init):
|
|
63
|
+
"""Build the Solace Agent Mesh application."""
|
|
64
|
+
return build_command(skip_without_asking=y, no_init=no_init)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@cli.command()
|
|
68
|
+
@click.option(
|
|
69
|
+
"-e",
|
|
70
|
+
"--use-env",
|
|
71
|
+
default=False,
|
|
72
|
+
is_flag=True,
|
|
73
|
+
help="Loads the environment variables file defined in the config.",
|
|
74
|
+
)
|
|
75
|
+
@click.option(
|
|
76
|
+
"-s",
|
|
77
|
+
"--skip",
|
|
78
|
+
help="Exclude file from the list of files to run.",
|
|
79
|
+
multiple=True,
|
|
80
|
+
)
|
|
81
|
+
@click.argument("files", nargs=-1, type=click.Path())
|
|
82
|
+
@click.option(
|
|
83
|
+
"-q",
|
|
84
|
+
"--quick-build",
|
|
85
|
+
default=False,
|
|
86
|
+
is_flag=True,
|
|
87
|
+
help="Uses default behavior for init and build command if not have already been run.",
|
|
88
|
+
)
|
|
89
|
+
@click.option(
|
|
90
|
+
"-i",
|
|
91
|
+
"--ignore-build",
|
|
92
|
+
default=False,
|
|
93
|
+
is_flag=True,
|
|
94
|
+
help="Skips running the build command if build directory does not exist. Mutally exclusive with --force-build.",
|
|
95
|
+
)
|
|
96
|
+
@click.option(
|
|
97
|
+
"-b",
|
|
98
|
+
"--force-build",
|
|
99
|
+
default=False,
|
|
100
|
+
is_flag=True,
|
|
101
|
+
help="Runs the build command first regardless of the build directory. Mutually exclusive with --ignore-build.",
|
|
102
|
+
)
|
|
103
|
+
def run(use_env, files, skip, quick_build, ignore_build, force_build):
|
|
104
|
+
"""Run the Solace Agent Mesh application.
|
|
105
|
+
|
|
106
|
+
FILES: Config files to run. Uses all the yaml files in the build directory if not provided.
|
|
107
|
+
"""
|
|
108
|
+
return run_command(
|
|
109
|
+
use_env, list(files), list(skip), quick_build, ignore_build, force_build
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@cli.command()
|
|
114
|
+
def config():
|
|
115
|
+
"""Update the config file with newly added default settings."""
|
|
116
|
+
return config_command()
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@cli.command()
|
|
120
|
+
@click.option(
|
|
121
|
+
"-p", "--port", default=8080, help="Port number to run the visualizer on."
|
|
122
|
+
)
|
|
123
|
+
@click.option(
|
|
124
|
+
"-f",
|
|
125
|
+
"--find-unused-port",
|
|
126
|
+
default=False,
|
|
127
|
+
is_flag=True,
|
|
128
|
+
help="If port is in use, Uses the next available port.",
|
|
129
|
+
)
|
|
130
|
+
@click.option(
|
|
131
|
+
"-h",
|
|
132
|
+
"--host",
|
|
133
|
+
default=False,
|
|
134
|
+
is_flag=True,
|
|
135
|
+
help="Expose the visualizer to the network.",
|
|
136
|
+
)
|
|
137
|
+
@click.option(
|
|
138
|
+
"-e",
|
|
139
|
+
"--use-env",
|
|
140
|
+
default=False,
|
|
141
|
+
is_flag=True,
|
|
142
|
+
help="Loads the environment variables file defined in the config.",
|
|
143
|
+
)
|
|
144
|
+
def visualize(port, find_unused_port, host, use_env):
|
|
145
|
+
"""Runs a web GUI visualizer for inspecting stimuli inside the solace agent mesh."""
|
|
146
|
+
return visualizer_command(port, find_unused_port, host, use_env)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@cli.command()
|
|
150
|
+
@click.option(
|
|
151
|
+
"--skip",
|
|
152
|
+
is_flag=True,
|
|
153
|
+
default=False,
|
|
154
|
+
help="Non-interactive mode. Skip all the prompts, Uses provided options and default values.",
|
|
155
|
+
)
|
|
156
|
+
@click.option(
|
|
157
|
+
"--namespace",
|
|
158
|
+
help="project namespace",
|
|
159
|
+
)
|
|
160
|
+
@click.option(
|
|
161
|
+
"--config-dir",
|
|
162
|
+
help="base directory for config files",
|
|
163
|
+
)
|
|
164
|
+
@click.option(
|
|
165
|
+
"--module-dir",
|
|
166
|
+
help="base directory for python modules",
|
|
167
|
+
)
|
|
168
|
+
@click.option(
|
|
169
|
+
"--build-dir",
|
|
170
|
+
help="base directory for the build output",
|
|
171
|
+
)
|
|
172
|
+
@click.option(
|
|
173
|
+
"--env-file",
|
|
174
|
+
help="environment file path",
|
|
175
|
+
)
|
|
176
|
+
@click.option(
|
|
177
|
+
"--broker-type",
|
|
178
|
+
help="broker type to use (container, solace, dev_broker)",
|
|
179
|
+
)
|
|
180
|
+
@click.option(
|
|
181
|
+
"--broker-url",
|
|
182
|
+
help="Solace broker url endpoint",
|
|
183
|
+
)
|
|
184
|
+
@click.option(
|
|
185
|
+
"--broker-vpn",
|
|
186
|
+
help="Solace broker vpn name",
|
|
187
|
+
)
|
|
188
|
+
@click.option(
|
|
189
|
+
"--broker-username",
|
|
190
|
+
help="Solace broker username",
|
|
191
|
+
)
|
|
192
|
+
@click.option(
|
|
193
|
+
"--broker-password",
|
|
194
|
+
help="Solace broker password",
|
|
195
|
+
)
|
|
196
|
+
@click.option(
|
|
197
|
+
"--container-engine",
|
|
198
|
+
help="container engine to use (podman, docker)",
|
|
199
|
+
)
|
|
200
|
+
@click.option(
|
|
201
|
+
"--llm-model-name",
|
|
202
|
+
help="LLM model name to use",
|
|
203
|
+
)
|
|
204
|
+
@click.option(
|
|
205
|
+
"--llm-endpoint-url",
|
|
206
|
+
help="LLM endpoint URL",
|
|
207
|
+
)
|
|
208
|
+
@click.option(
|
|
209
|
+
"--llm-api-key",
|
|
210
|
+
help="LLM API Key",
|
|
211
|
+
)
|
|
212
|
+
@click.option(
|
|
213
|
+
"--embedding-model-name",
|
|
214
|
+
help="Embedding model name to use",
|
|
215
|
+
)
|
|
216
|
+
@click.option(
|
|
217
|
+
"--embedding-endpoint-url",
|
|
218
|
+
help="Embedding endpoint URL",
|
|
219
|
+
)
|
|
220
|
+
@click.option(
|
|
221
|
+
"--embedding-api-key",
|
|
222
|
+
help="Embedding API Key",
|
|
223
|
+
)
|
|
224
|
+
@click.option(
|
|
225
|
+
"--built-in-agent",
|
|
226
|
+
help="Built-in agents to use, multiple values can be provided (global, image_processing, ...)",
|
|
227
|
+
multiple=True,
|
|
228
|
+
)
|
|
229
|
+
@click.option(
|
|
230
|
+
"--file-service-provider",
|
|
231
|
+
help="File service provider to use (volume, bucket)",
|
|
232
|
+
)
|
|
233
|
+
@click.option(
|
|
234
|
+
"--file-service-config",
|
|
235
|
+
help="Key value pairs for file service configuration (eg directory=/path/to/volume)",
|
|
236
|
+
multiple=True,
|
|
237
|
+
)
|
|
238
|
+
@click.option(
|
|
239
|
+
"--env-var",
|
|
240
|
+
help="Adds Key value pairs to the env file (eg key=value)",
|
|
241
|
+
multiple=True,
|
|
242
|
+
)
|
|
243
|
+
@click.option(
|
|
244
|
+
"--rest-api-enabled",
|
|
245
|
+
is_flag=True,
|
|
246
|
+
default=None,
|
|
247
|
+
help="Enable/disable REST API Interface",
|
|
248
|
+
)
|
|
249
|
+
@click.option(
|
|
250
|
+
"--rest-api-server-input-port",
|
|
251
|
+
help="REST API server port",
|
|
252
|
+
)
|
|
253
|
+
@click.option(
|
|
254
|
+
"--rest-api-server-host",
|
|
255
|
+
help="REST API server host",
|
|
256
|
+
)
|
|
257
|
+
@click.option(
|
|
258
|
+
"--rest-api-server-input-endpoint",
|
|
259
|
+
help="REST API endpoint",
|
|
260
|
+
)
|
|
261
|
+
@click.option(
|
|
262
|
+
"--rest-api-gateway-name",
|
|
263
|
+
help="Name for the REST API gateway",
|
|
264
|
+
)
|
|
265
|
+
@click.option(
|
|
266
|
+
"--webui-enabled",
|
|
267
|
+
is_flag=True,
|
|
268
|
+
default=None,
|
|
269
|
+
help="Enable/disable Web UI",
|
|
270
|
+
)
|
|
271
|
+
@click.option(
|
|
272
|
+
"--webui-listen-port",
|
|
273
|
+
help="Web UI server listen port",
|
|
274
|
+
)
|
|
275
|
+
@click.option(
|
|
276
|
+
"--webui-host",
|
|
277
|
+
help="Web UI server host",
|
|
278
|
+
)
|
|
279
|
+
def init(**kwargs):
|
|
280
|
+
"""
|
|
281
|
+
Initialize the Solace Agent Mesh application.
|
|
282
|
+
"""
|
|
283
|
+
return init_command(kwargs)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@cli.group()
|
|
287
|
+
def plugin():
|
|
288
|
+
"""Manage plugins - Create, build, add, and remove plugins."""
|
|
289
|
+
pass
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
@cli.group()
|
|
293
|
+
def chat():
|
|
294
|
+
"""Start chatting with the Solace Agent Mesh application."""
|
|
295
|
+
pass
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def main():
|
|
299
|
+
add_command(add)
|
|
300
|
+
plugin_command(plugin)
|
|
301
|
+
chat_command(chat)
|
|
302
|
+
cli()
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
if __name__ == "__main__":
|
|
306
|
+
main()
|