chore(release): bump version to v6.4.0b4 and update documentation
This commit is contained in:
1 parent
1caa286e65
commit
951961a5d3
29 files changed
+1706
-4390
No files matched your search
@@ -3,7 +3,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
# Connpy (v6.4.0b3)
|
# Connpy (v6.4.0b4)
|
||||||
[](https://pypi.org/pypi/connpy/)
|
[](https://pypi.org/pypi/connpy/)
|
||||||
[](https://pypi.org/pypi/connpy/)
|
[](https://pypi.org/pypi/connpy/)
|
||||||
[](https://pypi.org/pypi/connpy/)
|
[](https://pypi.org/pypi/connpy/)
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
# Connpy (v6.4.0b3)
|
# Connpy (v6.4.0b4)
|
||||||
[](https://pypi.org/pypi/connpy/)
|
[](https://pypi.org/pypi/connpy/)
|
||||||
[](https://pypi.org/pypi/connpy/)
|
[](https://pypi.org/pypi/connpy/)
|
||||||
[](https://pypi.org/pypi/connpy/)
|
[](https://pypi.org/pypi/connpy/)
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
__version__ = "6.4.0b3"
|
__version__ = "6.4.0b4"
|
||||||
+1
-1
@@ -319,7 +319,7 @@ class connapp:
|
|||||||
aiparser.add_argument("--session", nargs=1, help="Resume a specific AI session by ID")
|
aiparser.add_argument("--session", nargs=1, help="Resume a specific AI session by ID")
|
||||||
aiparser.add_argument("--resume", action="store_true", help="Resume the most recent AI session")
|
aiparser.add_argument("--resume", action="store_true", help="Resume the most recent AI session")
|
||||||
aiparser.add_argument("--delete", "--delete-session", dest="delete_session", nargs=1, help="Delete an AI session by ID")
|
aiparser.add_argument("--delete", "--delete-session", dest="delete_session", nargs=1, help="Delete an AI session by ID")
|
||||||
aiparser.add_argument("--mcp", nargs='*', metavar=('ACTION', 'NAME'), help="Manage MCP servers. Actions: list, add, remove, enable, disable. Leave empty for interactive wizard.")
|
aiparser.add_argument("--mcp", nargs=argparse.REMAINDER, metavar=('ACTION', 'NAME'), help="Manage MCP servers. Actions: list, add, remove, enable, disable, serve. Leave empty for interactive wizard.")
|
||||||
aiparser.set_defaults(func=self._ai.dispatch)
|
aiparser.set_defaults(func=self._ai.dispatch)
|
||||||
#RUNPARSER
|
#RUNPARSER
|
||||||
runparser = subparsers.add_parser("run", help="Run scripts or commands on nodes", description="Run scripts or commands on nodes", formatter_class=RichHelpFormatter)
|
runparser = subparsers.add_parser("run", help="Run scripts or commands on nodes", description="Run scripts or commands on nodes", formatter_class=RichHelpFormatter)
|
||||||
|
|||||||
@@ -522,7 +522,15 @@ class ConnpyMCPServer:
|
|||||||
return self.server.run(transport="stdio", **kwargs)
|
return self.server.run(transport="stdio", **kwargs)
|
||||||
|
|
||||||
if transport == "sse":
|
if transport == "sse":
|
||||||
return self.server.run(transport="sse", host=host, port=port, **kwargs)
|
if hasattr(self.server, "settings"):
|
||||||
|
if hasattr(self.server.settings, "host"):
|
||||||
|
self.server.settings.host = host
|
||||||
|
if hasattr(self.server.settings, "port"):
|
||||||
|
self.server.settings.port = port
|
||||||
|
try:
|
||||||
|
return self.server.run(transport="sse", host=host, port=port, **kwargs)
|
||||||
|
except TypeError:
|
||||||
|
return self.server.run(transport="sse", **kwargs)
|
||||||
|
|
||||||
msg = f"Unknown transport: {transport}. Supported transports: 'stdio', 'sse'"
|
msg = f"Unknown transport: {transport}. Supported transports: 'stdio', 'sse'"
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
+27
-11
@@ -150,7 +150,7 @@ el.replaceWith(d);
|
|||||||
import yaml
|
import yaml
|
||||||
try:
|
try:
|
||||||
# 1. Parse YAML
|
# 1. Parse YAML
|
||||||
data = yaml.load(playbook_yaml, Loader=yaml.FullLoader)
|
data = yaml.safe_load(playbook_yaml)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {"valid": False, "error": f"YAML Syntax Error: {e}"}
|
return {"valid": False, "error": f"YAML Syntax Error: {e}"}
|
||||||
|
|
||||||
@@ -473,7 +473,7 @@ el.replaceWith(d);
|
|||||||
import yaml
|
import yaml
|
||||||
try:
|
try:
|
||||||
# 1. Parse YAML
|
# 1. Parse YAML
|
||||||
data = yaml.load(playbook_yaml, Loader=yaml.FullLoader)
|
data = yaml.safe_load(playbook_yaml)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {"valid": False, "error": f"YAML Syntax Error: {e}"}
|
return {"valid": False, "error": f"YAML Syntax Error: {e}"}
|
||||||
|
|
||||||
@@ -638,6 +638,9 @@ class ai:
|
|||||||
self.session_path = os.path.join(self.sessions_dir, f"{self.session_id}.json") if self.session_id else None
|
self.session_path = os.path.join(self.sessions_dir, f"{self.session_id}.json") if self.session_id else None
|
||||||
|
|
||||||
# Agnostic base prompts
|
# Agnostic base prompts
|
||||||
|
self._update_base_prompts()
|
||||||
|
|
||||||
|
def _update_base_prompts(self):
|
||||||
architect_instructions = ""
|
architect_instructions = ""
|
||||||
if self.has_architect:
|
if self.has_architect:
|
||||||
architect_instructions = """
|
architect_instructions = """
|
||||||
@@ -678,7 +681,7 @@ class ai:
|
|||||||
- NO WANDERING: Do not speculate. If stuck, report attempts.
|
- NO WANDERING: Do not speculate. If stuck, report attempts.
|
||||||
- SAFETY: When you use 'run_commands' with configuration commands, the system automatically prompts the user for confirmation. Just execute - don't ask permission first.
|
- SAFETY: When you use 'run_commands' with configuration commands, the system automatically prompts the user for confirmation. Just execute - don't ask permission first.
|
||||||
{architect_instructions}
|
{architect_instructions}
|
||||||
Network Context: {{self.long_term_memory if self.long_term_memory else "Empty."}}
|
Network Context: {self.long_term_memory if self.long_term_memory else "Empty."}
|
||||||
""").strip()
|
""").strip()
|
||||||
|
|
||||||
self._architect_base_prompt = dedent(f"""
|
self._architect_base_prompt = dedent(f"""
|
||||||
@@ -718,6 +721,7 @@ class ai:
|
|||||||
@property
|
@property
|
||||||
def engineer_system_prompt(self):
|
def engineer_system_prompt(self):
|
||||||
"""Build engineer system prompt with plugin extensions."""
|
"""Build engineer system prompt with plugin extensions."""
|
||||||
|
self._update_base_prompts()
|
||||||
if self.engineer_prompt_extensions:
|
if self.engineer_prompt_extensions:
|
||||||
extensions = "\n".join(self.engineer_prompt_extensions)
|
extensions = "\n".join(self.engineer_prompt_extensions)
|
||||||
return self._engineer_base_prompt + f"\n\nPlugin Capabilities:\n{extensions}"
|
return self._engineer_base_prompt + f"\n\nPlugin Capabilities:\n{extensions}"
|
||||||
@@ -726,6 +730,7 @@ class ai:
|
|||||||
@property
|
@property
|
||||||
def architect_system_prompt(self):
|
def architect_system_prompt(self):
|
||||||
"""Build architect system prompt with plugin extensions."""
|
"""Build architect system prompt with plugin extensions."""
|
||||||
|
self._update_base_prompts()
|
||||||
prompt = self._architect_base_prompt
|
prompt = self._architect_base_prompt
|
||||||
if getattr(self, "one_shot", False):
|
if getattr(self, "one_shot", False):
|
||||||
prompt += "\n\nCRITICAL 1-SHOT DIAGNOSTICS DIRECTIVE:\nYou are running in a 1-shot offline diagnostics mode. There is no active conversation loop, and you are NOT conversing with a Network Engineer. You MUST deliver your complete strategic analysis immediately and directly to the user. Do not suggest or attempt to delegate/return control to the engineer."
|
prompt += "\n\nCRITICAL 1-SHOT DIAGNOSTICS DIRECTIVE:\nYou are running in a 1-shot offline diagnostics mode. There is no active conversation loop, and you are NOT conversing with a Network Engineer. You MUST deliver your complete strategic analysis immediately and directly to the user. Do not suggest or attempt to delegate/return control to the engineer."
|
||||||
@@ -1065,6 +1070,7 @@ class ai:
|
|||||||
# Reload memory after update
|
# Reload memory after update
|
||||||
with open(self.memory_path, "r") as f:
|
with open(self.memory_path, "r") as f:
|
||||||
self.long_term_memory = f.read()
|
self.long_term_memory = f.read()
|
||||||
|
self._update_base_prompts()
|
||||||
|
|
||||||
return "Memory updated successfully."
|
return "Memory updated successfully."
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
@@ -1300,7 +1306,7 @@ class ai:
|
|||||||
# Silently fail for LLM tools
|
# Silently fail for LLM tools
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if self.architect_key:
|
if self.has_architect:
|
||||||
base_tools.extend([
|
base_tools.extend([
|
||||||
{"type": "function", "function": {"name": "consult_architect", "description": "Ask the Strategic Reasoning Engine for advice on complex design, architecture, or troubleshooting decisions. You remain in control and will present the response to the user. Use this for: configuration planning, design validation, complex troubleshooting.", "parameters": {"type": "object", "properties": {"question": {"type": "string", "description": "Strategic question or decision needed."}, "technical_summary": {"type": "string", "description": "Technical findings and context gathered so far."}}, "required": ["question", "technical_summary"]}}},
|
{"type": "function", "function": {"name": "consult_architect", "description": "Ask the Strategic Reasoning Engine for advice on complex design, architecture, or troubleshooting decisions. You remain in control and will present the response to the user. Use this for: configuration planning, design validation, complex troubleshooting.", "parameters": {"type": "object", "properties": {"question": {"type": "string", "description": "Strategic question or decision needed."}, "technical_summary": {"type": "string", "description": "Technical findings and context gathered so far."}}, "required": ["question", "technical_summary"]}}},
|
||||||
{"type": "function", "function": {"name": "escalate_to_architect", "description": "Transfer full control to the Strategic Reasoning Engine. Use ONLY when the user explicitly requests the Architect or when the problem requires strategic oversight beyond consultation. After escalation, the Architect takes over the conversation.", "parameters": {"type": "object", "properties": {"reason": {"type": "string", "description": "Why you're escalating (e.g. 'User requested Architect', 'Complex multi-site design needed')."}, "context": {"type": "string", "description": "Full context and findings to hand over."}}, "required": ["reason", "context"]}}}
|
{"type": "function", "function": {"name": "escalate_to_architect", "description": "Transfer full control to the Strategic Reasoning Engine. Use ONLY when the user explicitly requests the Architect or when the problem requires strategic oversight beyond consultation. After escalation, the Architect takes over the conversation.", "parameters": {"type": "object", "properties": {"reason": {"type": "string", "description": "Why you're escalating (e.g. 'User requested Architect', 'Complex multi-site design needed')."}, "context": {"type": "string", "description": "Full context and findings to hand over."}}, "required": ["reason", "context"]}}}
|
||||||
@@ -1657,14 +1663,17 @@ class ai:
|
|||||||
if status: update_status("[architect]Engineer consulting Architect...")
|
if status: update_status("[architect]Engineer consulting Architect...")
|
||||||
try:
|
try:
|
||||||
# Consultation only - Engineer stays in control
|
# Consultation only - Engineer stays in control
|
||||||
|
auth_kwargs = dict(self.architect_auth or {})
|
||||||
|
if self.architect_key and "api_key" not in auth_kwargs:
|
||||||
|
auth_kwargs["api_key"] = self.architect_key
|
||||||
claude_resp = completion(
|
claude_resp = completion(
|
||||||
model=self.architect_model,
|
model=self.architect_model,
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system", "content": self.architect_system_prompt},
|
{"role": "system", "content": self.architect_system_prompt},
|
||||||
{"role": "user", "content": f"The Engineer needs your strategic advice.\n\nTECHNICAL SUMMARY: {args['technical_summary']}\n\nQUESTION: {args['question']}\n\nProvide strategic guidance. The Engineer will continue handling the user."}
|
{"role": "user", "content": f"The Engineer needs your strategic advice.\n\nTECHNICAL SUMMARY: {args['technical_summary']}\n\nQUESTION: {args['question']}\n\nProvide strategic guidance. The Engineer will continue handling the user."}
|
||||||
],
|
],
|
||||||
api_key=self.architect_key,
|
num_retries=3,
|
||||||
num_retries=3
|
**auth_kwargs
|
||||||
)
|
)
|
||||||
obs = claude_resp.choices[0].message.content
|
obs = claude_resp.choices[0].message.content
|
||||||
if debug:
|
if debug:
|
||||||
@@ -2101,11 +2110,11 @@ Node: {node_name}"""
|
|||||||
<dl>
|
<dl>
|
||||||
<dt id="connpy.ai.ai.SAFE_COMMANDS"><code class="name">var <span class="ident">SAFE_COMMANDS</span></code></dt>
|
<dt id="connpy.ai.ai.SAFE_COMMANDS"><code class="name">var <span class="ident">SAFE_COMMANDS</span></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="desc"><p>The type of the None singleton.</p></div>
|
<div class="desc"></div>
|
||||||
</dd>
|
</dd>
|
||||||
<dt id="connpy.ai.ai.deferred_class_hooks"><code class="name">var <span class="ident">deferred_class_hooks</span></code></dt>
|
<dt id="connpy.ai.ai.deferred_class_hooks"><code class="name">var <span class="ident">deferred_class_hooks</span></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="desc"><p>The type of the None singleton.</p></div>
|
<div class="desc"></div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<h3>Instance variables</h3>
|
<h3>Instance variables</h3>
|
||||||
@@ -2119,6 +2128,7 @@ Node: {node_name}"""
|
|||||||
<pre><code class="python">@property
|
<pre><code class="python">@property
|
||||||
def architect_system_prompt(self):
|
def architect_system_prompt(self):
|
||||||
"""Build architect system prompt with plugin extensions."""
|
"""Build architect system prompt with plugin extensions."""
|
||||||
|
self._update_base_prompts()
|
||||||
prompt = self._architect_base_prompt
|
prompt = self._architect_base_prompt
|
||||||
if getattr(self, "one_shot", False):
|
if getattr(self, "one_shot", False):
|
||||||
prompt += "\n\nCRITICAL 1-SHOT DIAGNOSTICS DIRECTIVE:\nYou are running in a 1-shot offline diagnostics mode. There is no active conversation loop, and you are NOT conversing with a Network Engineer. You MUST deliver your complete strategic analysis immediately and directly to the user. Do not suggest or attempt to delegate/return control to the engineer."
|
prompt += "\n\nCRITICAL 1-SHOT DIAGNOSTICS DIRECTIVE:\nYou are running in a 1-shot offline diagnostics mode. There is no active conversation loop, and you are NOT conversing with a Network Engineer. You MUST deliver your complete strategic analysis immediately and directly to the user. Do not suggest or attempt to delegate/return control to the engineer."
|
||||||
@@ -2138,6 +2148,7 @@ def architect_system_prompt(self):
|
|||||||
<pre><code class="python">@property
|
<pre><code class="python">@property
|
||||||
def engineer_system_prompt(self):
|
def engineer_system_prompt(self):
|
||||||
"""Build engineer system prompt with plugin extensions."""
|
"""Build engineer system prompt with plugin extensions."""
|
||||||
|
self._update_base_prompts()
|
||||||
if self.engineer_prompt_extensions:
|
if self.engineer_prompt_extensions:
|
||||||
extensions = "\n".join(self.engineer_prompt_extensions)
|
extensions = "\n".join(self.engineer_prompt_extensions)
|
||||||
return self._engineer_base_prompt + f"\n\nPlugin Capabilities:\n{extensions}"
|
return self._engineer_base_prompt + f"\n\nPlugin Capabilities:\n{extensions}"
|
||||||
@@ -2661,14 +2672,17 @@ def ask(self, user_input, dryrun=False, chat_history=None, status=None, debug=Fa
|
|||||||
if status: update_status("[architect]Engineer consulting Architect...")
|
if status: update_status("[architect]Engineer consulting Architect...")
|
||||||
try:
|
try:
|
||||||
# Consultation only - Engineer stays in control
|
# Consultation only - Engineer stays in control
|
||||||
|
auth_kwargs = dict(self.architect_auth or {})
|
||||||
|
if self.architect_key and "api_key" not in auth_kwargs:
|
||||||
|
auth_kwargs["api_key"] = self.architect_key
|
||||||
claude_resp = completion(
|
claude_resp = completion(
|
||||||
model=self.architect_model,
|
model=self.architect_model,
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system", "content": self.architect_system_prompt},
|
{"role": "system", "content": self.architect_system_prompt},
|
||||||
{"role": "user", "content": f"The Engineer needs your strategic advice.\n\nTECHNICAL SUMMARY: {args['technical_summary']}\n\nQUESTION: {args['question']}\n\nProvide strategic guidance. The Engineer will continue handling the user."}
|
{"role": "user", "content": f"The Engineer needs your strategic advice.\n\nTECHNICAL SUMMARY: {args['technical_summary']}\n\nQUESTION: {args['question']}\n\nProvide strategic guidance. The Engineer will continue handling the user."}
|
||||||
],
|
],
|
||||||
api_key=self.architect_key,
|
num_retries=3,
|
||||||
num_retries=3
|
**auth_kwargs
|
||||||
)
|
)
|
||||||
obs = claude_resp.choices[0].message.content
|
obs = claude_resp.choices[0].message.content
|
||||||
if debug:
|
if debug:
|
||||||
@@ -2976,6 +2990,7 @@ def confirm(self, user_input): return True</code></pre>
|
|||||||
# Reload memory after update
|
# Reload memory after update
|
||||||
with open(self.memory_path, "r") as f:
|
with open(self.memory_path, "r") as f:
|
||||||
self.long_term_memory = f.read()
|
self.long_term_memory = f.read()
|
||||||
|
self._update_base_prompts()
|
||||||
|
|
||||||
return "Memory updated successfully."
|
return "Memory updated successfully."
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
@@ -3024,8 +3039,9 @@ def confirm(self, user_input): return True</code></pre>
|
|||||||
self.tool_status_formatters[name] = status_formatter</code></pre>
|
self.tool_status_formatters[name] = status_formatter</code></pre>
|
||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Register an external tool for the AI system.</p>
|
<div class="desc"><p>Register an external tool for the AI system.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>tool_definition</code></strong> : <code>dict</code></dt>
|
<dt><strong><code>tool_definition</code></strong> : <code>dict</code></dt>
|
||||||
<dd>OpenAI-compatible tool definition.</dd>
|
<dd>OpenAI-compatible tool definition.</dd>
|
||||||
<dt><strong><code>handler</code></strong> : <code>callable</code></dt>
|
<dt><strong><code>handler</code></strong> : <code>callable</code></dt>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ el.replaceWith(d);
|
|||||||
try:
|
try:
|
||||||
self.app.services.ai.delete_session(args.delete_session[0])
|
self.app.services.ai.delete_session(args.delete_session[0])
|
||||||
printer.success(f"Session {args.delete_session[0]} deleted.")
|
printer.success(f"Session {args.delete_session[0]} deleted.")
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))
|
printer.error(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ el.replaceWith(d);
|
|||||||
try:
|
try:
|
||||||
self.app.services.ai.configure_mcp(name, url=url, auto_load_on_os=os_filter)
|
self.app.services.ai.configure_mcp(name, url=url, auto_load_on_os=os_filter)
|
||||||
printer.success(f"MCP server '{name}' added/updated.")
|
printer.success(f"MCP server '{name}' added/updated.")
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))
|
printer.error(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ el.replaceWith(d);
|
|||||||
try:
|
try:
|
||||||
self.app.services.ai.configure_mcp(name, remove=True)
|
self.app.services.ai.configure_mcp(name, remove=True)
|
||||||
printer.success(f"MCP server '{name}' removed.")
|
printer.success(f"MCP server '{name}' removed.")
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))
|
printer.error(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -261,13 +261,54 @@ el.replaceWith(d);
|
|||||||
try:
|
try:
|
||||||
self.app.services.ai.configure_mcp(name, enabled=enabled)
|
self.app.services.ai.configure_mcp(name, enabled=enabled)
|
||||||
printer.success(f"MCP server '{name}' {'enabled' if enabled else 'disabled'}.")
|
printer.success(f"MCP server '{name}' {'enabled' if enabled else 'disabled'}.")
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))
|
printer.error(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
elif action == "serve":
|
||||||
|
transport = "stdio"
|
||||||
|
host = "127.0.0.1"
|
||||||
|
port = 8000
|
||||||
|
trust = getattr(args, "trust", False)
|
||||||
|
|
||||||
|
idx = 1
|
||||||
|
while idx < len(mcp_args):
|
||||||
|
tok = mcp_args[idx]
|
||||||
|
if tok in ["--sse", "sse"]:
|
||||||
|
transport = "sse"
|
||||||
|
elif tok in ["--stdio", "stdio"]:
|
||||||
|
transport = "stdio"
|
||||||
|
elif tok in ["--trust", "trust"]:
|
||||||
|
trust = True
|
||||||
|
elif tok in ["--port", "-p"]:
|
||||||
|
idx += 1
|
||||||
|
if idx < len(mcp_args):
|
||||||
|
try:
|
||||||
|
port = int(mcp_args[idx])
|
||||||
|
except ValueError:
|
||||||
|
printer.error(f"Invalid port: {mcp_args[idx]}")
|
||||||
|
return
|
||||||
|
elif tok.startswith("--port="):
|
||||||
|
try:
|
||||||
|
port = int(tok.split("=", 1)[1])
|
||||||
|
except ValueError:
|
||||||
|
printer.error(f"Invalid port: {tok}")
|
||||||
|
return
|
||||||
|
elif tok in ["--host", "-h"]:
|
||||||
|
idx += 1
|
||||||
|
if idx < len(mcp_args):
|
||||||
|
host = mcp_args[idx]
|
||||||
|
elif tok.startswith("--host="):
|
||||||
|
host = tok.split("=", 1)[1]
|
||||||
|
idx += 1
|
||||||
|
|
||||||
|
from ..mcp_server import ConnpyMCPServer
|
||||||
|
server = ConnpyMCPServer(config=self.app.config, services=self.app.services, trust=trust)
|
||||||
|
return server.run(transport=transport, host=host, port=port)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
printer.error(f"Unknown MCP action: {action}")
|
printer.error(f"Unknown MCP action: {action}")
|
||||||
printer.info("Available actions: list, add, remove, enable, disable")
|
printer.info("Available actions: list, add, remove, enable, disable, serve")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 2. Interactive Wizard Mode (if no arguments provided)
|
# 2. Interactive Wizard Mode (if no arguments provided)
|
||||||
@@ -309,15 +350,16 @@ el.replaceWith(d);
|
|||||||
self.app.services.ai.configure_mcp(result["name"], remove=True)
|
self.app.services.ai.configure_mcp(result["name"], remove=True)
|
||||||
printer.success(f"MCP server '{result['name']}' removed.")
|
printer.success(f"MCP server '{result['name']}' removed.")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))
|
printer.error(str(e))
|
||||||
|
|
||||||
def _parse_auth_value(self, value):
|
def _parse_auth_value(self, value):
|
||||||
if not value or value.lower() in ["none", "clear"]:
|
if not value or value.lower() in ["none", "clear"]:
|
||||||
return None
|
return None
|
||||||
import os
|
|
||||||
import yaml
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
import yaml
|
||||||
if os.path.exists(value):
|
if os.path.exists(value):
|
||||||
try:
|
try:
|
||||||
with open(value, "r") as f:
|
with open(value, "r") as f:
|
||||||
@@ -326,7 +368,7 @@ el.replaceWith(d);
|
|||||||
return json.loads(content)
|
return json.loads(content)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return yaml.safe_load(content)
|
return yaml.safe_load(content)
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(f"Failed to read/parse auth file '{value}': {e}")
|
printer.error(f"Failed to read/parse auth file '{value}': {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@@ -338,7 +380,7 @@ el.replaceWith(d);
|
|||||||
if isinstance(parsed, dict):
|
if isinstance(parsed, dict):
|
||||||
return parsed
|
return parsed
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
printer.error("Auth parameter must be a valid JSON/YAML string, or a path to a JSON/YAML file.")
|
printer.error("Auth parameter must be a valid JSON/YAML string, or a path to a JSON/YAML file.")
|
||||||
sys.exit(1)</code></pre>
|
sys.exit(1)</code></pre>
|
||||||
</details>
|
</details>
|
||||||
@@ -387,7 +429,7 @@ el.replaceWith(d);
|
|||||||
try:
|
try:
|
||||||
self.app.services.ai.configure_mcp(name, url=url, auto_load_on_os=os_filter)
|
self.app.services.ai.configure_mcp(name, url=url, auto_load_on_os=os_filter)
|
||||||
printer.success(f"MCP server '{name}' added/updated.")
|
printer.success(f"MCP server '{name}' added/updated.")
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))
|
printer.error(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -399,7 +441,7 @@ el.replaceWith(d);
|
|||||||
try:
|
try:
|
||||||
self.app.services.ai.configure_mcp(name, remove=True)
|
self.app.services.ai.configure_mcp(name, remove=True)
|
||||||
printer.success(f"MCP server '{name}' removed.")
|
printer.success(f"MCP server '{name}' removed.")
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))
|
printer.error(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -412,13 +454,54 @@ el.replaceWith(d);
|
|||||||
try:
|
try:
|
||||||
self.app.services.ai.configure_mcp(name, enabled=enabled)
|
self.app.services.ai.configure_mcp(name, enabled=enabled)
|
||||||
printer.success(f"MCP server '{name}' {'enabled' if enabled else 'disabled'}.")
|
printer.success(f"MCP server '{name}' {'enabled' if enabled else 'disabled'}.")
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))
|
printer.error(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
elif action == "serve":
|
||||||
|
transport = "stdio"
|
||||||
|
host = "127.0.0.1"
|
||||||
|
port = 8000
|
||||||
|
trust = getattr(args, "trust", False)
|
||||||
|
|
||||||
|
idx = 1
|
||||||
|
while idx < len(mcp_args):
|
||||||
|
tok = mcp_args[idx]
|
||||||
|
if tok in ["--sse", "sse"]:
|
||||||
|
transport = "sse"
|
||||||
|
elif tok in ["--stdio", "stdio"]:
|
||||||
|
transport = "stdio"
|
||||||
|
elif tok in ["--trust", "trust"]:
|
||||||
|
trust = True
|
||||||
|
elif tok in ["--port", "-p"]:
|
||||||
|
idx += 1
|
||||||
|
if idx < len(mcp_args):
|
||||||
|
try:
|
||||||
|
port = int(mcp_args[idx])
|
||||||
|
except ValueError:
|
||||||
|
printer.error(f"Invalid port: {mcp_args[idx]}")
|
||||||
|
return
|
||||||
|
elif tok.startswith("--port="):
|
||||||
|
try:
|
||||||
|
port = int(tok.split("=", 1)[1])
|
||||||
|
except ValueError:
|
||||||
|
printer.error(f"Invalid port: {tok}")
|
||||||
|
return
|
||||||
|
elif tok in ["--host", "-h"]:
|
||||||
|
idx += 1
|
||||||
|
if idx < len(mcp_args):
|
||||||
|
host = mcp_args[idx]
|
||||||
|
elif tok.startswith("--host="):
|
||||||
|
host = tok.split("=", 1)[1]
|
||||||
|
idx += 1
|
||||||
|
|
||||||
|
from ..mcp_server import ConnpyMCPServer
|
||||||
|
server = ConnpyMCPServer(config=self.app.config, services=self.app.services, trust=trust)
|
||||||
|
return server.run(transport=transport, host=host, port=port)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
printer.error(f"Unknown MCP action: {action}")
|
printer.error(f"Unknown MCP action: {action}")
|
||||||
printer.info("Available actions: list, add, remove, enable, disable")
|
printer.info("Available actions: list, add, remove, enable, disable, serve")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 2. Interactive Wizard Mode (if no arguments provided)
|
# 2. Interactive Wizard Mode (if no arguments provided)
|
||||||
@@ -460,7 +543,7 @@ el.replaceWith(d);
|
|||||||
self.app.services.ai.configure_mcp(result["name"], remove=True)
|
self.app.services.ai.configure_mcp(result["name"], remove=True)
|
||||||
printer.success(f"MCP server '{result['name']}' removed.")
|
printer.success(f"MCP server '{result['name']}' removed.")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))</code></pre>
|
printer.error(str(e))</code></pre>
|
||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Handle MCP server configuration via CLI tokens or interactive wizard.</p></div>
|
<div class="desc"><p>Handle MCP server configuration via CLI tokens or interactive wizard.</p></div>
|
||||||
@@ -497,7 +580,7 @@ el.replaceWith(d);
|
|||||||
try:
|
try:
|
||||||
self.app.services.ai.delete_session(args.delete_session[0])
|
self.app.services.ai.delete_session(args.delete_session[0])
|
||||||
printer.success(f"Session {args.delete_session[0]} deleted.")
|
printer.success(f"Session {args.delete_session[0]} deleted.")
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
printer.error(str(e))
|
printer.error(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,10 @@ el.replaceWith(d);
|
|||||||
path = args.data[0]
|
path = args.data[0]
|
||||||
try:
|
try:
|
||||||
with open(path, "r") as f:
|
with open(path, "r") as f:
|
||||||
playbook = yaml.load(f, Loader=yaml.FullLoader)
|
playbook = yaml.safe_load(f)
|
||||||
|
|
||||||
|
if not isinstance(playbook, dict):
|
||||||
|
raise TypeError("Invalid playbook format: expected a dictionary")
|
||||||
|
|
||||||
# Check preflight first before any task runs
|
# Check preflight first before any task runs
|
||||||
if getattr(args, "preflight_ai", False):
|
if getattr(args, "preflight_ai", False):
|
||||||
@@ -1021,7 +1024,10 @@ el.replaceWith(d);
|
|||||||
path = args.data[0]
|
path = args.data[0]
|
||||||
try:
|
try:
|
||||||
with open(path, "r") as f:
|
with open(path, "r") as f:
|
||||||
playbook = yaml.load(f, Loader=yaml.FullLoader)
|
playbook = yaml.safe_load(f)
|
||||||
|
|
||||||
|
if not isinstance(playbook, dict):
|
||||||
|
raise TypeError("Invalid playbook format: expected a dictionary")
|
||||||
|
|
||||||
# Check preflight first before any task runs
|
# Check preflight first before any task runs
|
||||||
if getattr(args, "preflight_ai", False):
|
if getattr(args, "preflight_ai", False):
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -1671,8 +1671,9 @@ def predict_execution_results(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -2371,8 +2372,9 @@ def revoke_api_token(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -2980,8 +2982,9 @@ def update_setting(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -3316,8 +3319,9 @@ def test_commands(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -3652,8 +3656,9 @@ def set_reserved_names(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -5080,8 +5085,9 @@ def validate_parent_folder(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -5598,8 +5604,9 @@ def list_plugins(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -6207,8 +6214,9 @@ def update_profile(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -6725,8 +6733,9 @@ def stop_api(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ el.replaceWith(d);
|
|||||||
<dl>
|
<dl>
|
||||||
<dt id="connpy.grpc_layer.remote_plugin_pb2.IdRequest.DESCRIPTOR"><code class="name">var <span class="ident">DESCRIPTOR</span></code></dt>
|
<dt id="connpy.grpc_layer.remote_plugin_pb2.IdRequest.DESCRIPTOR"><code class="name">var <span class="ident">DESCRIPTOR</span></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="desc"><p>The type of the None singleton.</p></div>
|
<div class="desc"></div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -81,7 +81,7 @@ el.replaceWith(d);
|
|||||||
<dl>
|
<dl>
|
||||||
<dt id="connpy.grpc_layer.remote_plugin_pb2.OutputChunk.DESCRIPTOR"><code class="name">var <span class="ident">DESCRIPTOR</span></code></dt>
|
<dt id="connpy.grpc_layer.remote_plugin_pb2.OutputChunk.DESCRIPTOR"><code class="name">var <span class="ident">DESCRIPTOR</span></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="desc"><p>The type of the None singleton.</p></div>
|
<div class="desc"></div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -100,7 +100,7 @@ el.replaceWith(d);
|
|||||||
<dl>
|
<dl>
|
||||||
<dt id="connpy.grpc_layer.remote_plugin_pb2.PluginInvokeRequest.DESCRIPTOR"><code class="name">var <span class="ident">DESCRIPTOR</span></code></dt>
|
<dt id="connpy.grpc_layer.remote_plugin_pb2.PluginInvokeRequest.DESCRIPTOR"><code class="name">var <span class="ident">DESCRIPTOR</span></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="desc"><p>The type of the None singleton.</p></div>
|
<div class="desc"></div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -119,7 +119,7 @@ el.replaceWith(d);
|
|||||||
<dl>
|
<dl>
|
||||||
<dt id="connpy.grpc_layer.remote_plugin_pb2.StringResponse.DESCRIPTOR"><code class="name">var <span class="ident">DESCRIPTOR</span></code></dt>
|
<dt id="connpy.grpc_layer.remote_plugin_pb2.StringResponse.DESCRIPTOR"><code class="name">var <span class="ident">DESCRIPTOR</span></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="desc"><p>The type of the None singleton.</p></div>
|
<div class="desc"></div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
|
|||||||
@@ -317,8 +317,9 @@ def invoke_plugin(request,
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
<div class="desc"><p>Missing associated documentation comment in .proto file.</p>
|
||||||
<p>Constructor.</p>
|
<p>Constructor.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>channel</code></strong></dt>
|
<dt><strong><code>channel</code></strong></dt>
|
||||||
<dd>A grpc.Channel.</dd>
|
<dd>A grpc.Channel.</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -604,7 +604,7 @@ def service(self):
|
|||||||
<dl>
|
<dl>
|
||||||
<dt id="connpy.grpc_layer.server.AuthInterceptor.OPEN_METHODS"><code class="name">var <span class="ident">OPEN_METHODS</span></code></dt>
|
<dt id="connpy.grpc_layer.server.AuthInterceptor.OPEN_METHODS"><code class="name">var <span class="ident">OPEN_METHODS</span></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="desc"><p>The type of the None singleton.</p></div>
|
<div class="desc"></div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<h3>Methods</h3>
|
<h3>Methods</h3>
|
||||||
@@ -648,8 +648,9 @@ contextvars.Context, and the same Context is used for downstream
|
|||||||
interceptors and for the final handler call. Note that there are no
|
interceptors and for the final handler call. Note that there are no
|
||||||
guarantees that interceptors and handlers will be called from the
|
guarantees that interceptors and handlers will be called from the
|
||||||
same thread.</p>
|
same thread.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>continuation</code></strong></dt>
|
<dt><strong><code>continuation</code></strong></dt>
|
||||||
<dd>A function that takes a HandlerCallDetails and
|
<dd>A function that takes a HandlerCallDetails and
|
||||||
proceeds to invoke the next interceptor in the chain, if any,
|
proceeds to invoke the next interceptor in the chain, if any,
|
||||||
@@ -659,8 +660,9 @@ the RPC is considered serviced, or None otherwise.</dd>
|
|||||||
<dt><strong><code>handler_call_details</code></strong></dt>
|
<dt><strong><code>handler_call_details</code></strong></dt>
|
||||||
<dd>A HandlerCallDetails describing the RPC.</dd>
|
<dd>A HandlerCallDetails describing the RPC.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<h2 id="returns">Returns</h2>
|
<p>Returns
|
||||||
<p>An RpcMethodHandler with which the RPC may be serviced if the
|
-----=
|
||||||
|
An RpcMethodHandler with which the RPC may be serviced if the
|
||||||
interceptor chooses to service this RPC, or None otherwise.</p></div>
|
interceptor chooses to service this RPC, or None otherwise.</p></div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -1213,7 +1215,7 @@ def service(self):
|
|||||||
if request.value.startswith("---YAML---\n"):
|
if request.value.startswith("---YAML---\n"):
|
||||||
import yaml
|
import yaml
|
||||||
content = request.value[len("---YAML---\n"):]
|
content = request.value[len("---YAML---\n"):]
|
||||||
data = yaml.load(content, Loader=yaml.FullLoader)
|
data = yaml.safe_load(content)
|
||||||
self.service.import_from_dict(data)
|
self.service.import_from_dict(data)
|
||||||
else:
|
else:
|
||||||
self.service.import_from_file(request.value)
|
self.service.import_from_file(request.value)
|
||||||
@@ -1340,8 +1342,9 @@ contextvars.Context, and the same Context is used for downstream
|
|||||||
interceptors and for the final handler call. Note that there are no
|
interceptors and for the final handler call. Note that there are no
|
||||||
guarantees that interceptors and handlers will be called from the
|
guarantees that interceptors and handlers will be called from the
|
||||||
same thread.</p>
|
same thread.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>continuation</code></strong></dt>
|
<dt><strong><code>continuation</code></strong></dt>
|
||||||
<dd>A function that takes a HandlerCallDetails and
|
<dd>A function that takes a HandlerCallDetails and
|
||||||
proceeds to invoke the next interceptor in the chain, if any,
|
proceeds to invoke the next interceptor in the chain, if any,
|
||||||
@@ -1351,8 +1354,9 @@ the RPC is considered serviced, or None otherwise.</dd>
|
|||||||
<dt><strong><code>handler_call_details</code></strong></dt>
|
<dt><strong><code>handler_call_details</code></strong></dt>
|
||||||
<dd>A HandlerCallDetails describing the RPC.</dd>
|
<dd>A HandlerCallDetails describing the RPC.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<h2 id="returns">Returns</h2>
|
<p>Returns
|
||||||
<p>An RpcMethodHandler with which the RPC may be serviced if the
|
-----=
|
||||||
|
An RpcMethodHandler with which the RPC may be serviced if the
|
||||||
interceptor chooses to service this RPC, or None otherwise.</p></div>
|
interceptor chooses to service this RPC, or None otherwise.</p></div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
+138
-13
@@ -41,7 +41,7 @@ el.replaceWith(d);
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://nginx.gederico.dynu.net/images/CONNPY-resized.png" alt="App Logo">
|
<img src="https://nginx.gederico.dynu.net/images/CONNPY-resized.png" alt="App Logo">
|
||||||
</p>
|
</p>
|
||||||
<h1 id="connpy-v640b3">Connpy (v6.4.0b3)</h1>
|
<h1 id="connpy-v640b4">Connpy (v6.4.0b4)</h1>
|
||||||
<p><a href="https://pypi.org/pypi/connpy/"><img alt="" src="https://img.shields.io/pypi/v/connpy.svg?style=flat-square"></a>
|
<p><a href="https://pypi.org/pypi/connpy/"><img alt="" src="https://img.shields.io/pypi/v/connpy.svg?style=flat-square"></a>
|
||||||
<a href="https://pypi.org/pypi/connpy/"><img alt="" src="https://img.shields.io/pypi/pyversions/connpy.svg?style=flat-square"></a>
|
<a href="https://pypi.org/pypi/connpy/"><img alt="" src="https://img.shields.io/pypi/pyversions/connpy.svg?style=flat-square"></a>
|
||||||
<a href="https://pypi.org/pypi/connpy/"><img alt="" src="https://img.shields.io/pypi/dm/connpy.svg?style=flat-square&cacheSeconds=86400"></a>
|
<a href="https://pypi.org/pypi/connpy/"><img alt="" src="https://img.shields.io/pypi/dm/connpy.svg?style=flat-square&cacheSeconds=86400"></a>
|
||||||
@@ -282,6 +282,10 @@ print(response)
|
|||||||
<dd>
|
<dd>
|
||||||
<div class="desc"></div>
|
<div class="desc"></div>
|
||||||
</dd>
|
</dd>
|
||||||
|
<dt><code class="name"><a title="connpy.mcp_server" href="mcp_server.html">connpy.mcp_server</a></code></dt>
|
||||||
|
<dd>
|
||||||
|
<div class="desc"></div>
|
||||||
|
</dd>
|
||||||
<dt><code class="name"><a title="connpy.proto" href="proto/index.html">connpy.proto</a></code></dt>
|
<dt><code class="name"><a title="connpy.proto" href="proto/index.html">connpy.proto</a></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="desc"></div>
|
<div class="desc"></div>
|
||||||
@@ -1676,7 +1680,7 @@ def getitems(self, uniques, extract = False):
|
|||||||
</dd>
|
</dd>
|
||||||
<dt id="connpy.node"><code class="flex name class">
|
<dt id="connpy.node"><code class="flex name class">
|
||||||
<span>class <span class="ident">node</span></span>
|
<span>class <span class="ident">node</span></span>
|
||||||
<span>(</span><span>unique,<br>host,<br>options='',<br>logs='',<br>password='',<br>port='',<br>protocol='',<br>user='',<br>config='',<br>tags='',<br>jumphost='')</span>
|
<span>(</span><span>unique,<br>host,<br>options='',<br>logs='',<br>password='',<br>port='',<br>protocol='',<br>user='',<br>config='',<br>tags='',<br>jumphost='',<br>allow_unsafe_options=None)</span>
|
||||||
</code></dt>
|
</code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<details class="source">
|
<details class="source">
|
||||||
@@ -1701,7 +1705,7 @@ class node:
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, unique, host, options='', logs='', password='', port='', protocol='', user='', config='', tags='', jumphost=''):
|
def __init__(self, unique, host, options='', logs='', password='', port='', protocol='', user='', config='', tags='', jumphost='', allow_unsafe_options=None):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
### Parameters:
|
### Parameters:
|
||||||
@@ -1736,14 +1740,22 @@ class node:
|
|||||||
like "os", "prompt" and "screenleght_command"
|
like "os", "prompt" and "screenleght_command"
|
||||||
|
|
||||||
- jumphost (str): Reference another node to be used as a jumphost
|
- jumphost (str): Reference another node to be used as a jumphost
|
||||||
|
|
||||||
|
- allow_unsafe_options (bool): Explicitly override safety restrictions.
|
||||||
'''
|
'''
|
||||||
self.config = config
|
self.config = config
|
||||||
if config == '':
|
if config == '':
|
||||||
self.idletime = 0
|
self.idletime = 0
|
||||||
self.key = None
|
self.key = None
|
||||||
else:
|
else:
|
||||||
self.idletime = config.config["idletime"]
|
self.idletime = config.config["idletime"] if (hasattr(config, "config") and isinstance(config.config, dict) and "idletime" in config.config) else 0
|
||||||
self.key = config.key
|
self.key = getattr(config, "key", None)
|
||||||
|
if allow_unsafe_options is not None:
|
||||||
|
self.allow_unsafe_options = bool(allow_unsafe_options)
|
||||||
|
elif config != '' and config is not None and hasattr(config, "config") and isinstance(config.config, dict):
|
||||||
|
self.allow_unsafe_options = bool(config.config.get("allow_unsafe_options", False))
|
||||||
|
else:
|
||||||
|
self.allow_unsafe_options = False
|
||||||
self.unique = unique
|
self.unique = unique
|
||||||
attr = {"host": host, "logs": logs, "options":options, "port": port, "protocol": protocol, "user": user, "tags": tags, "jumphost": jumphost}
|
attr = {"host": host, "logs": logs, "options":options, "port": port, "protocol": protocol, "user": user, "tags": tags, "jumphost": jumphost}
|
||||||
for key in attr:
|
for key in attr:
|
||||||
@@ -1814,6 +1826,79 @@ class node:
|
|||||||
jh_dict["password"] = [jh_dict["password"]]
|
jh_dict["password"] = [jh_dict["password"]]
|
||||||
return jh_dict
|
return jh_dict
|
||||||
|
|
||||||
|
def _is_unsafe_allowed(self) -> bool:
|
||||||
|
if getattr(self, "allow_unsafe_options", False):
|
||||||
|
return True
|
||||||
|
if hasattr(self, "config") and self.config and hasattr(self.config, "config") and isinstance(self.config.config, dict):
|
||||||
|
return bool(self.config.config.get("allow_unsafe_options", False))
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _validate_base_fields(self, check_port=True):
|
||||||
|
"""Sanitize host, user, and port against argument injection and shell metacharacters."""
|
||||||
|
host_s = str(self.host) if self.host is not None else ""
|
||||||
|
if not host_s:
|
||||||
|
raise ValueError("Host cannot be empty")
|
||||||
|
if host_s.startswith("-"):
|
||||||
|
raise ValueError(f"Host cannot start with '-': '{self.host}'")
|
||||||
|
host_bare = (
|
||||||
|
host_s[1:-1]
|
||||||
|
if (host_s.startswith("[") and host_s.endswith("]"))
|
||||||
|
else host_s
|
||||||
|
)
|
||||||
|
if not host_bare or host_bare.startswith("-"):
|
||||||
|
raise ValueError(f"Invalid characters in host: '{self.host}'")
|
||||||
|
if _LEGACY_SSH_UNSAFE_RE.search(host_bare):
|
||||||
|
raise ValueError(f"Invalid characters in host: '{self.host}'")
|
||||||
|
|
||||||
|
user_s = str(self.user) if self.user is not None else ""
|
||||||
|
if user_s:
|
||||||
|
if user_s.startswith("-"):
|
||||||
|
raise ValueError(f"User cannot start with '-': '{self.user}'")
|
||||||
|
if _LEGACY_SSH_UNSAFE_RE.search(user_s):
|
||||||
|
raise ValueError(f"Invalid characters in user: '{self.user}'")
|
||||||
|
|
||||||
|
if check_port and self.port != "" and self.port is not None:
|
||||||
|
if isinstance(self.port, (bool, float)):
|
||||||
|
raise ValueError(f"Invalid TCP SSH port '{self.port}'")
|
||||||
|
port_s = str(self.port).strip()
|
||||||
|
if port_s:
|
||||||
|
if (
|
||||||
|
not port_s.isascii()
|
||||||
|
or not re.fullmatch(r"[0-9]+", port_s, re.ASCII)
|
||||||
|
or not (1 <= int(port_s) <= 65535)
|
||||||
|
):
|
||||||
|
raise ValueError(f"Invalid TCP SSH port '{self.port}'")
|
||||||
|
|
||||||
|
def _validate_options_and_safety(self):
|
||||||
|
"""Validate options string for unbalanced quotes and dangerous control characters."""
|
||||||
|
if not self.options:
|
||||||
|
return
|
||||||
|
opts_str = str(self.options).strip()
|
||||||
|
if not opts_str:
|
||||||
|
return
|
||||||
|
if not self._is_unsafe_allowed():
|
||||||
|
if any(c in opts_str for c in ("\n", "\r", "\x00")):
|
||||||
|
raise ValueError("Options cannot contain newlines or null bytes")
|
||||||
|
try:
|
||||||
|
shlex.split(opts_str)
|
||||||
|
except ValueError as e:
|
||||||
|
raise ValueError(f"Invalid options: unbalanced quotes ({e})") from e
|
||||||
|
|
||||||
|
def _validate_ssh_options(self):
|
||||||
|
"""Sanitize SSH options against local command execution directives."""
|
||||||
|
self._validate_options_and_safety()
|
||||||
|
if not self.options:
|
||||||
|
return
|
||||||
|
opts_str = str(self.options).strip()
|
||||||
|
if not opts_str:
|
||||||
|
return
|
||||||
|
if not self._is_unsafe_allowed():
|
||||||
|
dangerous_directives = ("ProxyCommand", "LocalCommand", "PermitLocalCommand", "KnownHostsCommand")
|
||||||
|
pattern = r'(?:' + '|'.join(dangerous_directives) + r')'
|
||||||
|
match = re.search(pattern, opts_str, re.IGNORECASE)
|
||||||
|
if match:
|
||||||
|
raise ValueError(f"Disallowed SSH directive in options: '{match.group(0)}'")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _validate_legacy_ssh_hop_fields(host, user, port):
|
def _validate_legacy_ssh_hop_fields(host, user, port):
|
||||||
"""Minimal injection guard for legacy SSH jumphost fields (preserves DOMAIN\\user, %scope, etc.)."""
|
"""Minimal injection guard for legacy SSH jumphost fields (preserves DOMAIN\\user, %scope, etc.)."""
|
||||||
@@ -3040,10 +3125,13 @@ class node:
|
|||||||
|
|
||||||
@MethodHook
|
@MethodHook
|
||||||
def _generate_ssh_sftp_cmd(self, force_ssh=False, allow_reverse_tunnel_port=None):
|
def _generate_ssh_sftp_cmd(self, force_ssh=False, allow_reverse_tunnel_port=None):
|
||||||
|
self._validate_base_fields(check_port=True)
|
||||||
is_from_mosh = (
|
is_from_mosh = (
|
||||||
self.protocol == "mosh"
|
self.protocol == "mosh"
|
||||||
or getattr(self, "_orig_protocol", "") == "mosh"
|
or getattr(self, "_orig_protocol", "") == "mosh"
|
||||||
)
|
)
|
||||||
|
if not is_from_mosh:
|
||||||
|
self._validate_ssh_options()
|
||||||
proto = "ssh" if force_ssh else self.protocol
|
proto = "ssh" if force_ssh else self.protocol
|
||||||
cmd = proto
|
cmd = proto
|
||||||
if is_from_mosh:
|
if is_from_mosh:
|
||||||
@@ -3134,8 +3222,9 @@ class node:
|
|||||||
if isinstance(self.tags, dict) and self.tags.get("mosh_ssh_options"):
|
if isinstance(self.tags, dict) and self.tags.get("mosh_ssh_options"):
|
||||||
ssh_opts = str(self.tags["mosh_ssh_options"]).strip()
|
ssh_opts = str(self.tags["mosh_ssh_options"]).strip()
|
||||||
if ssh_opts:
|
if ssh_opts:
|
||||||
if re.search(r'(?:LocalCommand|ProxyCommand)', ssh_opts, re.IGNORECASE):
|
if not self._is_unsafe_allowed():
|
||||||
raise ValueError("mosh_ssh_options cannot contain LocalCommand or ProxyCommand")
|
if re.search(r'(?:LocalCommand|ProxyCommand|PermitLocalCommand|KnownHostsCommand)', ssh_opts, re.IGNORECASE):
|
||||||
|
raise ValueError("mosh_ssh_options cannot contain LocalCommand or ProxyCommand")
|
||||||
try:
|
try:
|
||||||
shlex.split(ssh_opts)
|
shlex.split(ssh_opts)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
@@ -3153,8 +3242,9 @@ class node:
|
|||||||
if opts:
|
if opts:
|
||||||
if re.search(r'--(?:ssh|server|client)(?:=|\s|$)', opts):
|
if re.search(r'--(?:ssh|server|client)(?:=|\s|$)', opts):
|
||||||
raise ValueError("Options cannot override --ssh, --server or --client for mosh")
|
raise ValueError("Options cannot override --ssh, --server or --client for mosh")
|
||||||
if re.search(r'(?:LocalCommand|ProxyCommand)', opts, re.IGNORECASE):
|
if not self._is_unsafe_allowed():
|
||||||
raise ValueError("Options cannot contain LocalCommand or ProxyCommand")
|
if re.search(r'(?:LocalCommand|ProxyCommand|PermitLocalCommand|KnownHostsCommand)', opts, re.IGNORECASE):
|
||||||
|
raise ValueError("Options cannot contain LocalCommand or ProxyCommand")
|
||||||
try:
|
try:
|
||||||
shlex.split(opts)
|
shlex.split(opts)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
@@ -3167,6 +3257,8 @@ class node:
|
|||||||
|
|
||||||
@MethodHook
|
@MethodHook
|
||||||
def _generate_telnet_cmd(self):
|
def _generate_telnet_cmd(self):
|
||||||
|
self._validate_base_fields(check_port=True)
|
||||||
|
self._validate_options_and_safety()
|
||||||
cmd = f"telnet {self.host}"
|
cmd = f"telnet {self.host}"
|
||||||
if self.port:
|
if self.port:
|
||||||
cmd += f" {self.port}"
|
cmd += f" {self.port}"
|
||||||
@@ -3176,22 +3268,52 @@ class node:
|
|||||||
|
|
||||||
@MethodHook
|
@MethodHook
|
||||||
def _generate_kube_cmd(self):
|
def _generate_kube_cmd(self):
|
||||||
cmd = f"kubectl exec {self.options} {self.host} -it --"
|
self._validate_base_fields(check_port=False)
|
||||||
|
self._validate_options_and_safety()
|
||||||
kube_command = self.tags.get("kube_command", "/bin/bash") if isinstance(self.tags, dict) else "/bin/bash"
|
kube_command = self.tags.get("kube_command", "/bin/bash") if isinstance(self.tags, dict) else "/bin/bash"
|
||||||
|
if not self._is_unsafe_allowed() and kube_command:
|
||||||
|
k_str = str(kube_command)
|
||||||
|
if any(c in k_str for c in ("\n", "\r", "\x00")):
|
||||||
|
raise ValueError("kube_command cannot contain newlines or null bytes")
|
||||||
|
try:
|
||||||
|
shlex.split(k_str)
|
||||||
|
except ValueError as e:
|
||||||
|
raise ValueError(f"Invalid kube_command: unbalanced quotes ({e})") from e
|
||||||
|
cmd = f"kubectl exec {self.options} {self.host} -it --"
|
||||||
cmd += f" {kube_command}"
|
cmd += f" {kube_command}"
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
@MethodHook
|
@MethodHook
|
||||||
def _generate_docker_cmd(self):
|
def _generate_docker_cmd(self):
|
||||||
cmd = f"docker {self.options} exec -it {self.host}"
|
self._validate_base_fields(check_port=False)
|
||||||
|
self._validate_options_and_safety()
|
||||||
docker_command = self.tags.get("docker_command", "/bin/bash") if isinstance(self.tags, dict) else "/bin/bash"
|
docker_command = self.tags.get("docker_command", "/bin/bash") if isinstance(self.tags, dict) else "/bin/bash"
|
||||||
|
if not self._is_unsafe_allowed() and docker_command:
|
||||||
|
d_str = str(docker_command)
|
||||||
|
if any(c in d_str for c in ("\n", "\r", "\x00")):
|
||||||
|
raise ValueError("docker_command cannot contain newlines or null bytes")
|
||||||
|
try:
|
||||||
|
shlex.split(d_str)
|
||||||
|
except ValueError as e:
|
||||||
|
raise ValueError(f"Invalid docker_command: unbalanced quotes ({e})") from e
|
||||||
|
cmd = f"docker {self.options} exec -it {self.host}"
|
||||||
cmd += f" {docker_command}"
|
cmd += f" {docker_command}"
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
@MethodHook
|
@MethodHook
|
||||||
def _generate_ssm_cmd(self):
|
def _generate_ssm_cmd(self):
|
||||||
|
self._validate_base_fields(check_port=False)
|
||||||
|
self._validate_options_and_safety()
|
||||||
region = self.tags.get("region", "") if isinstance(self.tags, dict) else ""
|
region = self.tags.get("region", "") if isinstance(self.tags, dict) else ""
|
||||||
profile = self.tags.get("profile", "") if isinstance(self.tags, dict) else ""
|
profile = self.tags.get("profile", "") if isinstance(self.tags, dict) else ""
|
||||||
|
if not self._is_unsafe_allowed():
|
||||||
|
for field_name, field_val in [("region", region), ("profile", profile)]:
|
||||||
|
if field_val:
|
||||||
|
f_str = str(field_val)
|
||||||
|
if f_str.startswith("-"):
|
||||||
|
raise ValueError(f"SSM tag '{field_name}' cannot start with '-': '{field_val}'")
|
||||||
|
if re.search(r'[\s\x00-\x1f\x7f;|&$`><"\']', f_str):
|
||||||
|
raise ValueError(f"Invalid characters in SSM tag '{field_name}': '{field_val}'")
|
||||||
cmd = f"aws ssm start-session --target {self.host}"
|
cmd = f"aws ssm start-session --target {self.host}"
|
||||||
if region:
|
if region:
|
||||||
cmd += f" --region {region}"
|
cmd += f" --region {region}"
|
||||||
@@ -3492,6 +3614,8 @@ class node:
|
|||||||
like "os", "prompt" and "screenleght_command"
|
like "os", "prompt" and "screenleght_command"
|
||||||
|
|
||||||
- jumphost (str): Reference another node to be used as a jumphost
|
- jumphost (str): Reference another node to be used as a jumphost
|
||||||
|
|
||||||
|
- allow_unsafe_options (bool): Explicitly override safety restrictions.
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
<h3>Methods</h3>
|
<h3>Methods</h3>
|
||||||
<dl>
|
<dl>
|
||||||
@@ -4606,11 +4730,11 @@ def test(self, commands, expected, vars = None,*, folder = None, prompt = None,
|
|||||||
<nav id="sidebar">
|
<nav id="sidebar">
|
||||||
<div class="toc">
|
<div class="toc">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#connpy-v640b3">Connpy (v6.4.0b3)</a><ul>
|
<li><a href="#connpy-v640b4">Connpy (v6.4.0b4)</a><ul>
|
||||||
<li><a href="#1-ai-system">1. 🤖 AI System</a><ul>
|
<li><a href="#1-ai-system">1. 🤖 AI System</a><ul>
|
||||||
<li><a href="#1a-terminal-copilot-ctrlspace">1a. Terminal Copilot (Ctrl+Space)</a></li>
|
<li><a href="#1a-terminal-copilot-ctrlspace">1a. Terminal Copilot (Ctrl+Space)</a></li>
|
||||||
<li><a href="#1b-ai-chat-conn-ai">1b. AI Chat (conn ai)</a></li>
|
<li><a href="#1b-ai-chat-conn-ai">1b. AI Chat (conn ai)</a></li>
|
||||||
<li><a href="#1c-mcp-integration">1c. MCP Integration</a></li>
|
<li><a href="#1c-mcp-integration-client-server">1c. MCP Integration (Client & Server)</a></li>
|
||||||
<li><a href="#1d-local-interactive-shell-conn-shell">1d. Local Interactive Shell (conn shell)</a></li>
|
<li><a href="#1d-local-interactive-shell-conn-shell">1d. Local Interactive Shell (conn shell)</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@@ -4667,6 +4791,7 @@ def test(self, commands, expected, vars = None,*, folder = None, prompt = None,
|
|||||||
<li><code><a title="connpy.cli" href="cli/index.html">connpy.cli</a></code></li>
|
<li><code><a title="connpy.cli" href="cli/index.html">connpy.cli</a></code></li>
|
||||||
<li><code><a title="connpy.grpc_layer" href="grpc_layer/index.html">connpy.grpc_layer</a></code></li>
|
<li><code><a title="connpy.grpc_layer" href="grpc_layer/index.html">connpy.grpc_layer</a></code></li>
|
||||||
<li><code><a title="connpy.mcp_client" href="mcp_client.html">connpy.mcp_client</a></code></li>
|
<li><code><a title="connpy.mcp_client" href="mcp_client.html">connpy.mcp_client</a></code></li>
|
||||||
|
<li><code><a title="connpy.mcp_server" href="mcp_server.html">connpy.mcp_server</a></code></li>
|
||||||
<li><code><a title="connpy.proto" href="proto/index.html">connpy.proto</a></code></li>
|
<li><code><a title="connpy.proto" href="proto/index.html">connpy.proto</a></code></li>
|
||||||
<li><code><a title="connpy.services" href="services/index.html">connpy.services</a></code></li>
|
<li><code><a title="connpy.services" href="services/index.html">connpy.services</a></code></li>
|
||||||
<li><code><a title="connpy.tunnels" href="tunnels.html">connpy.tunnels</a></code></li>
|
<li><code><a title="connpy.tunnels" href="tunnels.html">connpy.tunnels</a></code></li>
|
||||||
|
|||||||
+150
-61
@@ -58,29 +58,50 @@ el.replaceWith(d);
|
|||||||
<pre><code class="python">class MCPClientManager:
|
<pre><code class="python">class MCPClientManager:
|
||||||
"""Manages MCP SSE client connections for connpy."""
|
"""Manages MCP SSE client connections for connpy."""
|
||||||
|
|
||||||
_instance = None
|
_instances: ClassVar[dict[Any, "MCPClientManager"]] = {}
|
||||||
|
_instance: ClassVar["MCPClientManager | None"] = None
|
||||||
_lock = threading.Lock()
|
_lock = threading.Lock()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
@classmethod
|
||||||
|
def _resolve_scope_key(cls, config=None, *args, **kwargs) -> Any:
|
||||||
|
cfg = config
|
||||||
|
if cfg is None and "config" in kwargs:
|
||||||
|
cfg = kwargs["config"]
|
||||||
|
if cfg is not None:
|
||||||
|
defaultdir = getattr(cfg, "defaultdir", None)
|
||||||
|
if defaultdir:
|
||||||
|
return os.path.abspath(str(defaultdir))
|
||||||
|
return id(cfg)
|
||||||
|
return "default"
|
||||||
|
|
||||||
|
def __new__(cls, config=None, *args, **kwargs):
|
||||||
|
key = cls._resolve_scope_key(config, *args, **kwargs)
|
||||||
with cls._lock:
|
with cls._lock:
|
||||||
if cls._instance is None:
|
if cls._instance is None and cls._instances:
|
||||||
cls._instance = super(MCPClientManager, cls).__new__(cls)
|
cls._instances.clear()
|
||||||
cls._instance._initialized = False
|
if key not in cls._instances:
|
||||||
return cls._instance
|
instance = super().__new__(cls)
|
||||||
|
instance._initialized = False
|
||||||
|
instance._scope_key = key
|
||||||
|
cls._instances[key] = instance
|
||||||
|
cls._instance = cls._instances[key]
|
||||||
|
return cls._instances[key]
|
||||||
|
|
||||||
def __init__(self, config=None):
|
def __init__(self, config=None):
|
||||||
if self._initialized:
|
if config is not None:
|
||||||
|
self.config = config
|
||||||
|
if getattr(self, "_initialized", False):
|
||||||
return
|
return
|
||||||
self.config = config
|
if not hasattr(self, "config"):
|
||||||
self.sessions: Dict[str, Dict[str, Any]] = {} # name -> {session, stack}
|
self.config = config
|
||||||
self.tool_cache: Dict[str, List[Dict[str, Any]]] = {}
|
self.sessions: dict[str, dict[str, Any]] = {} # name -> {session, stack}
|
||||||
self._connecting: Dict[str, asyncio.Future] = {}
|
self.tool_cache: dict[str, list[dict[str, Any]]] = {}
|
||||||
|
self._server_configs: dict[str, dict[str, Any]] = {}
|
||||||
|
self._connecting: dict[str, asyncio.Future] = {}
|
||||||
self._initialized = True
|
self._initialized = True
|
||||||
|
|
||||||
async def get_tools_for_llm(self, os_filter: Optional[str] = None) -> List[Dict[str, Any]]:
|
async def get_tools_for_llm(self, os_filter: str | None = None) -> list[dict[str, Any]]:
|
||||||
"""
|
"""Fetches tools from enabled MCP servers that match the OS filter."""
|
||||||
Fetches tools from enabled MCP servers that match the OS filter.
|
|
||||||
"""
|
|
||||||
if not MCP_AVAILABLE:
|
if not MCP_AVAILABLE:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -90,29 +111,53 @@ el.replaceWith(d);
|
|||||||
mcp_config = self.config.get_effective_setting("ai", {}).get("mcp_servers", {})
|
mcp_config = self.config.get_effective_setting("ai", {}).get("mcp_servers", {})
|
||||||
else:
|
else:
|
||||||
mcp_config = self.config.config.get("ai", {}).get("mcp_servers", {}) if hasattr(self.config, "config") else {}
|
mcp_config = self.config.config.get("ai", {}).get("mcp_servers", {}) if hasattr(self.config, "config") else {}
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
if not isinstance(mcp_config, dict):
|
||||||
|
mcp_config = {}
|
||||||
|
|
||||||
|
# Invalidate cache and reconnect if server configuration changed or server was removed
|
||||||
|
current_names = set(mcp_config.keys())
|
||||||
|
for old_name in list(self._server_configs.keys()):
|
||||||
|
if old_name not in current_names:
|
||||||
|
self.tool_cache.pop(old_name, None)
|
||||||
|
old_data = self.sessions.pop(old_name, None)
|
||||||
|
if old_data and old_data.get("stack"):
|
||||||
|
with suppress(Exception):
|
||||||
|
await old_data["stack"].aclose()
|
||||||
|
self._server_configs.pop(old_name, None)
|
||||||
|
|
||||||
|
for name, cfg in mcp_config.items():
|
||||||
|
cached_cfg = self._server_configs.get(name)
|
||||||
|
if cached_cfg is not None and cached_cfg != cfg:
|
||||||
|
self.tool_cache.pop(name, None)
|
||||||
|
old_data = self.sessions.pop(name, None)
|
||||||
|
if old_data and old_data.get("stack"):
|
||||||
|
with suppress(Exception):
|
||||||
|
await old_data["stack"].aclose()
|
||||||
|
self._server_configs[name] = dict(cfg) if isinstance(cfg, dict) else cfg
|
||||||
|
|
||||||
async def _fetch(name, cfg):
|
async def _fetch(name, cfg):
|
||||||
if not cfg.get("enabled", True): return []
|
if not isinstance(cfg, dict) or not cfg.get("enabled", True):
|
||||||
|
return []
|
||||||
|
|
||||||
# Filter by OS if specified in config (primarily used for copilot strict matching)
|
# Filter by OS if specified in config (primarily used for copilot strict matching)
|
||||||
auto_os = cfg.get("auto_load_on_os")
|
auto_os = cfg.get("auto_load_on_os")
|
||||||
if os_filter is not None and auto_os and os_filter.lower() != auto_os.lower():
|
if os_filter is not None and auto_os and os_filter.lower() != auto_os.lower():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
try:
|
with suppress(Exception):
|
||||||
session = await self._ensure_connected(name, cfg)
|
session = await self._ensure_connected(name, cfg)
|
||||||
if session:
|
if session:
|
||||||
if name in self.tool_cache: return self.tool_cache[name]
|
if name in self.tool_cache:
|
||||||
|
return self.tool_cache[name]
|
||||||
llm_tools = await self._fetch_tools_as_openai(name, session)
|
llm_tools = await self._fetch_tools_as_openai(name, session)
|
||||||
self.tool_cache[name] = llm_tools
|
self.tool_cache[name] = llm_tools
|
||||||
return llm_tools
|
return llm_tools
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
tasks = [ _fetch(name, cfg) for name, cfg in mcp_config.items() ]
|
tasks = [_fetch(name, cfg) for name, cfg in mcp_config.items()]
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
results = await asyncio.gather(*tasks)
|
results = await asyncio.gather(*tasks)
|
||||||
@@ -121,8 +166,9 @@ el.replaceWith(d);
|
|||||||
|
|
||||||
return all_llm_tools
|
return all_llm_tools
|
||||||
|
|
||||||
async def _ensure_connected(self, name: str, cfg: Dict[str, Any]) -> Optional[Any]:
|
async def _ensure_connected(self, name: str, cfg: dict[str, Any]) -> Any | None:
|
||||||
if not MCP_AVAILABLE: return None
|
if not MCP_AVAILABLE:
|
||||||
|
return None
|
||||||
|
|
||||||
if name in self.sessions and self.sessions[name].get("session"):
|
if name in self.sessions and self.sessions[name].get("session"):
|
||||||
return self.sessions[name]["session"]
|
return self.sessions[name]["session"]
|
||||||
@@ -134,7 +180,7 @@ el.replaceWith(d);
|
|||||||
if name in self._connecting:
|
if name in self._connecting:
|
||||||
try:
|
try:
|
||||||
return await asyncio.wait_for(asyncio.shield(self._connecting[name]), timeout=10.0)
|
return await asyncio.wait_for(asyncio.shield(self._connecting[name]), timeout=10.0)
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
return None
|
return None
|
||||||
|
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
@@ -155,33 +201,32 @@ el.replaceWith(d);
|
|||||||
self.sessions[name] = {"session": session, "stack": stack}
|
self.sessions[name] = {"session": session, "stack": stack}
|
||||||
fut.set_result(session)
|
fut.set_result(session)
|
||||||
return session
|
return session
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
fut.set_result(None)
|
fut.set_result(None)
|
||||||
return None
|
return None
|
||||||
finally:
|
finally:
|
||||||
if name in self._connecting:
|
if name in self._connecting:
|
||||||
del self._connecting[name]
|
del self._connecting[name]
|
||||||
|
|
||||||
async def _fetch_tools_as_openai(self, server_name: str, session: Any) -> List[Dict[str, Any]]:
|
async def _fetch_tools_as_openai(self, server_name: str, session: Any) -> list[dict[str, Any]]:
|
||||||
try:
|
try:
|
||||||
result = await asyncio.wait_for(session.list_tools(), timeout=5.0)
|
result = await asyncio.wait_for(session.list_tools(), timeout=5.0)
|
||||||
openai_tools = []
|
openai_tools = []
|
||||||
for tool in result.tools:
|
for tool in result.tools:
|
||||||
# Use mcp_ prefix to ensure valid function name for LiteLLM/Gemini
|
|
||||||
prefixed_name = f"mcp_{server_name}__{tool.name}"
|
prefixed_name = f"mcp_{server_name}__{tool.name}"
|
||||||
openai_tools.append({
|
openai_tools.append({
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"function": {
|
"function": {
|
||||||
"name": prefixed_name,
|
"name": prefixed_name,
|
||||||
"description": f"[{server_name}] {tool.description}",
|
"description": f"[{server_name}] {tool.description}",
|
||||||
"parameters": tool.inputSchema
|
"parameters": tool.inputSchema,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return openai_tools
|
return openai_tools
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
return []
|
return []
|
||||||
|
|
||||||
async def call_tool(self, full_tool_name: str, arguments: Dict[str, Any]) -> Any:
|
async def call_tool(self, full_tool_name: str, arguments: dict[str, Any]) -> Any:
|
||||||
"""Calls an MCP tool and returns text result."""
|
"""Calls an MCP tool and returns text result."""
|
||||||
if not MCP_AVAILABLE:
|
if not MCP_AVAILABLE:
|
||||||
return "Error: MCP SDK is not installed."
|
return "Error: MCP SDK is not installed."
|
||||||
@@ -189,7 +234,7 @@ el.replaceWith(d);
|
|||||||
if "__" not in full_tool_name:
|
if "__" not in full_tool_name:
|
||||||
return f"Error: Tool {full_tool_name} is not a valid MCP tool."
|
return f"Error: Tool {full_tool_name} is not a valid MCP tool."
|
||||||
|
|
||||||
clean_name = full_tool_name[4:] if full_tool_name.startswith("mcp_") else full_tool_name
|
clean_name = full_tool_name.removeprefix("mcp_")
|
||||||
server_name, tool_name = clean_name.split("__", 1)
|
server_name, tool_name = clean_name.split("__", 1)
|
||||||
|
|
||||||
if server_name not in self.sessions:
|
if server_name not in self.sessions:
|
||||||
@@ -200,29 +245,40 @@ el.replaceWith(d);
|
|||||||
result = await asyncio.wait_for(session.call_tool(tool_name, arguments), timeout=60.0)
|
result = await asyncio.wait_for(session.call_tool(tool_name, arguments), timeout=60.0)
|
||||||
text_outputs = [content.text for content in result.content if hasattr(content, "text")]
|
text_outputs = [content.text for content in result.content if hasattr(content, "text")]
|
||||||
return "\n".join(text_outputs) if text_outputs else str(result)
|
return "\n".join(text_outputs) if text_outputs else str(result)
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
return f"Error calling tool {tool_name} on {server_name}: {str(e)}"
|
return f"Error calling tool {tool_name} on {server_name}: {e!s}"
|
||||||
|
|
||||||
async def shutdown(self):
|
async def shutdown(self):
|
||||||
"""Close all SSE connections."""
|
"""Close all SSE connections and clean up resources."""
|
||||||
for name, data in self.sessions.items():
|
for data in list(self.sessions.values()):
|
||||||
stack = data.get("stack")
|
stack = data.get("stack")
|
||||||
if stack:
|
if stack:
|
||||||
await stack.aclose()
|
with suppress(Exception):
|
||||||
self.sessions = {}</code></pre>
|
await stack.aclose()
|
||||||
|
self.sessions.clear()
|
||||||
|
self.tool_cache.clear()
|
||||||
|
self._server_configs.clear()
|
||||||
|
for fut in list(self._connecting.values()):
|
||||||
|
if not fut.done():
|
||||||
|
fut.cancel()
|
||||||
|
self._connecting.clear()
|
||||||
|
with self._lock:
|
||||||
|
if hasattr(self, "_scope_key") and self._scope_key in self._instances:
|
||||||
|
del self._instances[self._scope_key]
|
||||||
|
self._initialized = False</code></pre>
|
||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Manages MCP SSE client connections for connpy.</p></div>
|
<div class="desc"><p>Manages MCP SSE client connections for connpy.</p></div>
|
||||||
<h3>Methods</h3>
|
<h3>Methods</h3>
|
||||||
<dl>
|
<dl>
|
||||||
<dt id="connpy.mcp_client.MCPClientManager.call_tool"><code class="name flex">
|
<dt id="connpy.mcp_client.MCPClientManager.call_tool"><code class="name flex">
|
||||||
<span>async def <span class="ident">call_tool</span></span>(<span>self, full_tool_name: str, arguments: Dict[str, Any]) ‑> Any</span>
|
<span>async def <span class="ident">call_tool</span></span>(<span>self, full_tool_name: str, arguments: dict[str, typing.Any]) ‑> Any</span>
|
||||||
</code></dt>
|
</code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<details class="source">
|
<details class="source">
|
||||||
<summary>
|
<summary>
|
||||||
<span>Expand source code</span>
|
<span>Expand source code</span>
|
||||||
</summary>
|
</summary>
|
||||||
<pre><code class="python">async def call_tool(self, full_tool_name: str, arguments: Dict[str, Any]) -> Any:
|
<pre><code class="python">async def call_tool(self, full_tool_name: str, arguments: dict[str, Any]) -> Any:
|
||||||
"""Calls an MCP tool and returns text result."""
|
"""Calls an MCP tool and returns text result."""
|
||||||
if not MCP_AVAILABLE:
|
if not MCP_AVAILABLE:
|
||||||
return "Error: MCP SDK is not installed."
|
return "Error: MCP SDK is not installed."
|
||||||
@@ -230,7 +286,7 @@ el.replaceWith(d);
|
|||||||
if "__" not in full_tool_name:
|
if "__" not in full_tool_name:
|
||||||
return f"Error: Tool {full_tool_name} is not a valid MCP tool."
|
return f"Error: Tool {full_tool_name} is not a valid MCP tool."
|
||||||
|
|
||||||
clean_name = full_tool_name[4:] if full_tool_name.startswith("mcp_") else full_tool_name
|
clean_name = full_tool_name.removeprefix("mcp_")
|
||||||
server_name, tool_name = clean_name.split("__", 1)
|
server_name, tool_name = clean_name.split("__", 1)
|
||||||
|
|
||||||
if server_name not in self.sessions:
|
if server_name not in self.sessions:
|
||||||
@@ -241,23 +297,21 @@ el.replaceWith(d);
|
|||||||
result = await asyncio.wait_for(session.call_tool(tool_name, arguments), timeout=60.0)
|
result = await asyncio.wait_for(session.call_tool(tool_name, arguments), timeout=60.0)
|
||||||
text_outputs = [content.text for content in result.content if hasattr(content, "text")]
|
text_outputs = [content.text for content in result.content if hasattr(content, "text")]
|
||||||
return "\n".join(text_outputs) if text_outputs else str(result)
|
return "\n".join(text_outputs) if text_outputs else str(result)
|
||||||
except Exception as e:
|
except Exception as e: # noqa: BLE001
|
||||||
return f"Error calling tool {tool_name} on {server_name}: {str(e)}"</code></pre>
|
return f"Error calling tool {tool_name} on {server_name}: {e!s}"</code></pre>
|
||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Calls an MCP tool and returns text result.</p></div>
|
<div class="desc"><p>Calls an MCP tool and returns text result.</p></div>
|
||||||
</dd>
|
</dd>
|
||||||
<dt id="connpy.mcp_client.MCPClientManager.get_tools_for_llm"><code class="name flex">
|
<dt id="connpy.mcp_client.MCPClientManager.get_tools_for_llm"><code class="name flex">
|
||||||
<span>async def <span class="ident">get_tools_for_llm</span></span>(<span>self, os_filter: str | None = None) ‑> List[Dict[str, Any]]</span>
|
<span>async def <span class="ident">get_tools_for_llm</span></span>(<span>self, os_filter: str | None = None) ‑> list[dict[str, typing.Any]]</span>
|
||||||
</code></dt>
|
</code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<details class="source">
|
<details class="source">
|
||||||
<summary>
|
<summary>
|
||||||
<span>Expand source code</span>
|
<span>Expand source code</span>
|
||||||
</summary>
|
</summary>
|
||||||
<pre><code class="python">async def get_tools_for_llm(self, os_filter: Optional[str] = None) -> List[Dict[str, Any]]:
|
<pre><code class="python">async def get_tools_for_llm(self, os_filter: str | None = None) -> list[dict[str, Any]]:
|
||||||
"""
|
"""Fetches tools from enabled MCP servers that match the OS filter."""
|
||||||
Fetches tools from enabled MCP servers that match the OS filter.
|
|
||||||
"""
|
|
||||||
if not MCP_AVAILABLE:
|
if not MCP_AVAILABLE:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -267,29 +321,53 @@ el.replaceWith(d);
|
|||||||
mcp_config = self.config.get_effective_setting("ai", {}).get("mcp_servers", {})
|
mcp_config = self.config.get_effective_setting("ai", {}).get("mcp_servers", {})
|
||||||
else:
|
else:
|
||||||
mcp_config = self.config.config.get("ai", {}).get("mcp_servers", {}) if hasattr(self.config, "config") else {}
|
mcp_config = self.config.config.get("ai", {}).get("mcp_servers", {}) if hasattr(self.config, "config") else {}
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
if not isinstance(mcp_config, dict):
|
||||||
|
mcp_config = {}
|
||||||
|
|
||||||
|
# Invalidate cache and reconnect if server configuration changed or server was removed
|
||||||
|
current_names = set(mcp_config.keys())
|
||||||
|
for old_name in list(self._server_configs.keys()):
|
||||||
|
if old_name not in current_names:
|
||||||
|
self.tool_cache.pop(old_name, None)
|
||||||
|
old_data = self.sessions.pop(old_name, None)
|
||||||
|
if old_data and old_data.get("stack"):
|
||||||
|
with suppress(Exception):
|
||||||
|
await old_data["stack"].aclose()
|
||||||
|
self._server_configs.pop(old_name, None)
|
||||||
|
|
||||||
|
for name, cfg in mcp_config.items():
|
||||||
|
cached_cfg = self._server_configs.get(name)
|
||||||
|
if cached_cfg is not None and cached_cfg != cfg:
|
||||||
|
self.tool_cache.pop(name, None)
|
||||||
|
old_data = self.sessions.pop(name, None)
|
||||||
|
if old_data and old_data.get("stack"):
|
||||||
|
with suppress(Exception):
|
||||||
|
await old_data["stack"].aclose()
|
||||||
|
self._server_configs[name] = dict(cfg) if isinstance(cfg, dict) else cfg
|
||||||
|
|
||||||
async def _fetch(name, cfg):
|
async def _fetch(name, cfg):
|
||||||
if not cfg.get("enabled", True): return []
|
if not isinstance(cfg, dict) or not cfg.get("enabled", True):
|
||||||
|
return []
|
||||||
|
|
||||||
# Filter by OS if specified in config (primarily used for copilot strict matching)
|
# Filter by OS if specified in config (primarily used for copilot strict matching)
|
||||||
auto_os = cfg.get("auto_load_on_os")
|
auto_os = cfg.get("auto_load_on_os")
|
||||||
if os_filter is not None and auto_os and os_filter.lower() != auto_os.lower():
|
if os_filter is not None and auto_os and os_filter.lower() != auto_os.lower():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
try:
|
with suppress(Exception):
|
||||||
session = await self._ensure_connected(name, cfg)
|
session = await self._ensure_connected(name, cfg)
|
||||||
if session:
|
if session:
|
||||||
if name in self.tool_cache: return self.tool_cache[name]
|
if name in self.tool_cache:
|
||||||
|
return self.tool_cache[name]
|
||||||
llm_tools = await self._fetch_tools_as_openai(name, session)
|
llm_tools = await self._fetch_tools_as_openai(name, session)
|
||||||
self.tool_cache[name] = llm_tools
|
self.tool_cache[name] = llm_tools
|
||||||
return llm_tools
|
return llm_tools
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
tasks = [ _fetch(name, cfg) for name, cfg in mcp_config.items() ]
|
tasks = [_fetch(name, cfg) for name, cfg in mcp_config.items()]
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
results = await asyncio.gather(*tasks)
|
results = await asyncio.gather(*tasks)
|
||||||
@@ -309,14 +387,25 @@ el.replaceWith(d);
|
|||||||
<span>Expand source code</span>
|
<span>Expand source code</span>
|
||||||
</summary>
|
</summary>
|
||||||
<pre><code class="python">async def shutdown(self):
|
<pre><code class="python">async def shutdown(self):
|
||||||
"""Close all SSE connections."""
|
"""Close all SSE connections and clean up resources."""
|
||||||
for name, data in self.sessions.items():
|
for data in list(self.sessions.values()):
|
||||||
stack = data.get("stack")
|
stack = data.get("stack")
|
||||||
if stack:
|
if stack:
|
||||||
await stack.aclose()
|
with suppress(Exception):
|
||||||
self.sessions = {}</code></pre>
|
await stack.aclose()
|
||||||
|
self.sessions.clear()
|
||||||
|
self.tool_cache.clear()
|
||||||
|
self._server_configs.clear()
|
||||||
|
for fut in list(self._connecting.values()):
|
||||||
|
if not fut.done():
|
||||||
|
fut.cancel()
|
||||||
|
self._connecting.clear()
|
||||||
|
with self._lock:
|
||||||
|
if hasattr(self, "_scope_key") and self._scope_key in self._instances:
|
||||||
|
del self._instances[self._scope_key]
|
||||||
|
self._initialized = False</code></pre>
|
||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Close all SSE connections.</p></div>
|
<div class="desc"><p>Close all SSE connections and clean up resources.</p></div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -427,8 +427,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for interacting with AI agents and LLM configurations.</p>
|
<div class="desc"><p>Business logic for interacting with AI agents and LLM configurations.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -89,8 +89,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Base class for all connpy services, providing common configuration access.</p>
|
<div class="desc"><p>Base class for all connpy services, providing common configuration access.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -133,8 +133,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for general application settings and state configuration.</p>
|
<div class="desc"><p>Business logic for general application settings and state configuration.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -139,8 +139,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for managing and applying regex-based contexts locally.</p>
|
<div class="desc"><p>Business logic for managing and applying regex-based contexts locally.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -160,8 +160,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for executing commands on nodes and running automation scripts.</p>
|
<div class="desc"><p>Business logic for executing commands on nodes and running automation scripts.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ el.replaceWith(d);
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r") as f:
|
||||||
data = yaml.load(f, Loader=yaml.FullLoader)
|
data = yaml.safe_load(f)
|
||||||
self.import_from_dict(data)
|
self.import_from_dict(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise InvalidConfigurationError(f"Failed to read/parse import file: {e}")
|
raise InvalidConfigurationError(f"Failed to read/parse import file: {e}")
|
||||||
@@ -165,8 +165,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for YAML/JSON inventory import and export.</p>
|
<div class="desc"><p>Business logic for YAML/JSON inventory import and export.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -314,7 +315,7 @@ el.replaceWith(d);
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r") as f:
|
||||||
data = yaml.load(f, Loader=yaml.FullLoader)
|
data = yaml.safe_load(f)
|
||||||
self.import_from_dict(data)
|
self.import_from_dict(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise InvalidConfigurationError(f"Failed to read/parse import file: {e}")</code></pre>
|
raise InvalidConfigurationError(f"Failed to read/parse import file: {e}")</code></pre>
|
||||||
|
|||||||
@@ -486,8 +486,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for interacting with AI agents and LLM configurations.</p>
|
<div class="desc"><p>Business logic for interacting with AI agents and LLM configurations.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -1078,8 +1079,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for general application settings and state configuration.</p>
|
<div class="desc"><p>Business logic for general application settings and state configuration.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -1397,8 +1399,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for executing commands on nodes and running automation scripts.</p>
|
<div class="desc"><p>Business logic for executing commands on nodes and running automation scripts.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -1622,7 +1625,7 @@ el.replaceWith(d);
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r") as f:
|
||||||
data = yaml.load(f, Loader=yaml.FullLoader)
|
data = yaml.safe_load(f)
|
||||||
self.import_from_dict(data)
|
self.import_from_dict(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise InvalidConfigurationError(f"Failed to read/parse import file: {e}")
|
raise InvalidConfigurationError(f"Failed to read/parse import file: {e}")
|
||||||
@@ -1667,8 +1670,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for YAML/JSON inventory import and export.</p>
|
<div class="desc"><p>Business logic for YAML/JSON inventory import and export.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -1816,7 +1820,7 @@ el.replaceWith(d);
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r") as f:
|
||||||
data = yaml.load(f, Loader=yaml.FullLoader)
|
data = yaml.safe_load(f)
|
||||||
self.import_from_dict(data)
|
self.import_from_dict(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise InvalidConfigurationError(f"Failed to read/parse import file: {e}")</code></pre>
|
raise InvalidConfigurationError(f"Failed to read/parse import file: {e}")</code></pre>
|
||||||
@@ -2176,8 +2180,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Base class for all connpy services, providing common configuration access.</p>
|
<div class="desc"><p>Base class for all connpy services, providing common configuration access.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -2965,8 +2970,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for enabling, disabling, and listing plugins.</p>
|
<div class="desc"><p>Business logic for enabling, disabling, and listing plugins.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -3542,8 +3548,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for node profiles management.</p>
|
<div class="desc"><p>Business logic for node profiles management.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -4140,8 +4147,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for Google Drive synchronization.</p>
|
<div class="desc"><p>Business logic for Google Drive synchronization.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
@@ -4740,8 +4748,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for application lifecycle (API, processes).</p>
|
<div class="desc"><p>Business logic for application lifecycle (API, processes).</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -326,8 +326,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Base class for all connpy services, providing common configuration access.</p>
|
<div class="desc"><p>Base class for all connpy services, providing common configuration access.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -411,8 +411,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for enabling, disabling, and listing plugins.</p>
|
<div class="desc"><p>Business logic for enabling, disabling, and listing plugins.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -188,8 +188,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for node profiles management.</p>
|
<div class="desc"><p>Business logic for node profiles management.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -435,8 +435,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for Google Drive synchronization.</p>
|
<div class="desc"><p>Business logic for Google Drive synchronization.</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
@@ -142,8 +142,9 @@ el.replaceWith(d);
|
|||||||
</details>
|
</details>
|
||||||
<div class="desc"><p>Business logic for application lifecycle (API, processes).</p>
|
<div class="desc"><p>Business logic for application lifecycle (API, processes).</p>
|
||||||
<p>Initialize the service.</p>
|
<p>Initialize the service.</p>
|
||||||
<h2 id="args">Args</h2>
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Args</dt>
|
||||||
|
<dt>-----=</dt>
|
||||||
<dt><strong><code>config</code></strong></dt>
|
<dt><strong><code>config</code></strong></dt>
|
||||||
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
<dd>An instance of configfile (or None to instantiate a new one/use global context).</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
|||||||
Reference in new issue
Block a user