mindroot 9.3.0__py3-none-any.whl → 9.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mindroot/coreplugins/admin/__init__.py +3 -1
- mindroot/coreplugins/admin/agent_router.py +250 -7
- mindroot/coreplugins/admin/asset_manager.py +164 -0
- mindroot/coreplugins/admin/command_router.py +236 -1
- mindroot/coreplugins/admin/mcp_catalog_routes.py +156 -0
- mindroot/coreplugins/admin/mcp_publish_routes.py +450 -0
- mindroot/coreplugins/admin/mcp_registry_routes.py +495 -0
- mindroot/coreplugins/admin/mcp_routes.py +216 -0
- mindroot/coreplugins/admin/mod.py +62 -0
- mindroot/coreplugins/admin/oauth_callback_router.py +84 -0
- mindroot/coreplugins/admin/persona_handler.py +15 -6
- mindroot/coreplugins/admin/persona_router.py +158 -2
- mindroot/coreplugins/admin/plugin_manager.py +105 -9
- mindroot/coreplugins/admin/plugin_router_fixed.py +23 -0
- mindroot/coreplugins/admin/plugin_router_new_not_working.py +145 -0
- mindroot/coreplugins/admin/plugin_routes.py +114 -0
- mindroot/coreplugins/admin/registry_settings_routes.py +140 -0
- mindroot/coreplugins/admin/router.py +116 -15
- mindroot/coreplugins/admin/service_models.py +1 -1
- mindroot/coreplugins/admin/settings_router.py +1 -0
- mindroot/coreplugins/admin/static/css/admin-custom.css +357 -2
- mindroot/coreplugins/admin/static/css/dark.css +1 -0
- mindroot/coreplugins/admin/static/css/default.css +4 -0
- mindroot/coreplugins/admin/static/js/about-info.js +367 -0
- mindroot/coreplugins/admin/static/js/agent-form.js +83 -3
- mindroot/coreplugins/admin/static/js/api-key-script.js +307 -0
- mindroot/coreplugins/admin/static/js/mcp-manager.js +348 -0
- mindroot/coreplugins/admin/static/js/mcp-publisher.js +780 -0
- mindroot/coreplugins/admin/static/js/persona-editor.js +34 -5
- mindroot/coreplugins/admin/static/js/plugin-toggle.js +1 -1
- mindroot/coreplugins/admin/static/js/recommended-plugin-install.js +63 -0
- mindroot/coreplugins/admin/static/js/registry-auth-section.js +132 -0
- mindroot/coreplugins/admin/static/js/registry-manager-base.js +613 -0
- mindroot/coreplugins/admin/static/js/registry-manager-publish-old-delete.js +166 -0
- mindroot/coreplugins/admin/static/js/registry-manager.js +351 -0
- mindroot/coreplugins/admin/static/js/registry-publish-section.js +377 -0
- mindroot/coreplugins/admin/static/js/registry-search-section.js +400 -0
- mindroot/coreplugins/admin/static/js/registry-search-section.js.bak +3 -0
- mindroot/coreplugins/admin/static/js/registry-settings.js +69 -0
- mindroot/coreplugins/admin/static/js/registry-shared-services.js +903 -0
- mindroot/coreplugins/admin/static/js/registry-simple-sections.js +85 -0
- mindroot/coreplugins/admin/static/js/secure-widget-manager.js +438 -0
- mindroot/coreplugins/admin/static/logo.png +0 -0
- mindroot/coreplugins/admin/templates/admin.jinja2 +275 -110
- mindroot/coreplugins/agent/Assistant/agent.json +27 -11
- mindroot/coreplugins/agent/agent.py +2 -2
- mindroot/coreplugins/agent/command_parser.py +25 -10
- mindroot/coreplugins/agent/templates/system.jinja2 +0 -12
- mindroot/coreplugins/chat/__init__.py +4 -1
- mindroot/coreplugins/chat/router.py +132 -20
- mindroot/coreplugins/chat/router_dedup_patch.py +20 -0
- mindroot/coreplugins/chat/services.py +31 -1
- mindroot/coreplugins/chat/static/css/action-fix.css +32 -0
- mindroot/coreplugins/chat/static/css/admin-custom.css +5 -3
- mindroot/coreplugins/chat/static/css/dark.css +24 -3
- mindroot/coreplugins/chat/static/css/default.css +24 -3
- mindroot/coreplugins/chat/static/css/main.css +1 -0
- mindroot/coreplugins/chat/static/js/action.js +137 -60
- mindroot/coreplugins/chat/static/js/chat-history.js +3 -0
- mindroot/coreplugins/chat/static/js/chat.js +59 -16
- mindroot/coreplugins/chat/static/js/chat.js.diff +221 -0
- mindroot/coreplugins/chat/static/js/chatform.js +2 -2
- mindroot/coreplugins/chat/static/site.webmanifest +1 -1
- mindroot/coreplugins/chat/templates/chat.jinja2 +3 -3
- mindroot/coreplugins/chat/widget_manager.py +139 -0
- mindroot/coreplugins/chat/widget_routes.py +287 -0
- mindroot/coreplugins/check_list/inject/admin.jinja2 +1 -1
- mindroot/coreplugins/email/__init__.py +2 -0
- mindroot/coreplugins/email/email_provider.py +2 -2
- mindroot/coreplugins/email/mod.py +100 -0
- mindroot/coreplugins/email/services.py +5 -3
- mindroot/coreplugins/email/smtp_handler.py +9 -3
- mindroot/coreplugins/email/test_email_service.py +75 -0
- mindroot/coreplugins/env_manager/mod.py +61 -25
- mindroot/coreplugins/home/router.py +37 -2
- mindroot/coreplugins/home/static/imgs/logo.png +0 -0
- mindroot/coreplugins/home/static/imgs/logo.png.bak +0 -0
- mindroot/coreplugins/home/static/imgs/logo_teal.png +0 -0
- mindroot/coreplugins/home/static/imgs/logo_teal2.png +0 -0
- mindroot/coreplugins/home/static/imgs/logo_teal_detailed.png +0 -0
- mindroot/coreplugins/home/static/imgs/logo_teal_python.png +0 -0
- mindroot/coreplugins/home/templates/home.jinja2 +15 -6
- mindroot/coreplugins/index/indices/default/index.json +39 -6
- mindroot/coreplugins/jwt_auth/middleware.py +47 -2
- mindroot/coreplugins/jwt_auth/mod.py +40 -17
- mindroot/coreplugins/l8n/__init__.py +6 -0
- mindroot/coreplugins/l8n/debug_loader.py +85 -0
- mindroot/coreplugins/l8n/debug_middleware.py +74 -0
- mindroot/coreplugins/l8n/l8n_constants.py +19 -0
- mindroot/coreplugins/l8n/language_detection.py +183 -0
- mindroot/coreplugins/l8n/middleware.py +151 -0
- mindroot/coreplugins/l8n/mod.py +277 -0
- mindroot/coreplugins/l8n/monkey_patch_to_delete.py +186 -0
- mindroot/coreplugins/l8n/test_enhanced.py +298 -0
- mindroot/coreplugins/l8n/test_l8n.py +95 -0
- mindroot/coreplugins/l8n/test_l8n_standalone.py +251 -0
- mindroot/coreplugins/l8n/test_middleware.py +272 -0
- mindroot/coreplugins/l8n/utils.py +232 -0
- mindroot/coreplugins/mcp_/__init__.py +14 -0
- mindroot/coreplugins/mcp_/catalog_commands.py +328 -0
- mindroot/coreplugins/mcp_/catalog_manager.py +263 -0
- mindroot/coreplugins/mcp_/dynamic_commands.py +154 -0
- mindroot/coreplugins/mcp_/mcp_manager.py +1031 -0
- mindroot/coreplugins/mcp_/mod.py +367 -0
- mindroot/coreplugins/mcp_/oauth_storage.py +144 -0
- mindroot/coreplugins/mcp_/server_installer.py +79 -0
- mindroot/coreplugins/mcp_/setup.py +26 -0
- mindroot/coreplugins/mcp_/test_dynamic_commands.py +134 -0
- mindroot/coreplugins/mcp_/testmcpclient.py +92 -0
- mindroot/coreplugins/persona/mod.py +12 -7
- mindroot/coreplugins/signup/templates/signup.jinja2 +1 -1
- mindroot/coreplugins/subscriptions/__init__.py +1 -0
- mindroot/coreplugins/subscriptions/mod.py +14 -3
- mindroot/coreplugins/subscriptions/router.py +3 -0
- mindroot/coreplugins/user_service/__init__.py +1 -2
- mindroot/coreplugins/user_service/admin_init.py +1 -0
- mindroot/coreplugins/user_service/email_service.py +72 -17
- mindroot/coreplugins/user_service/mod.py +10 -2
- mindroot/coreplugins/user_service/router.py +2 -0
- mindroot/lib/auth/api_key.py +28 -0
- mindroot/lib/cli/plugins.py +94 -0
- mindroot/lib/plugins/default_plugin_manifest.json +20 -0
- mindroot/lib/plugins/installation.py +5 -5
- mindroot/lib/plugins/l8n_static_handler.py +225 -0
- mindroot/lib/plugins/loader.py +33 -3
- mindroot/lib/plugins/loader_with_l8n.py +281 -0
- mindroot/lib/plugins/manifest.py +236 -24
- mindroot/lib/providers/commands.py +3 -1
- mindroot/lib/route_decorators.py +5 -5
- mindroot/lib/templates.py +183 -11
- mindroot/lib/utils/merge_arrays.py +1 -1
- mindroot/migrate.py +39 -20
- mindroot/registry/data_access.py +1 -1
- mindroot/server.py +42 -13
- mindroot/server_missing_normal_args.py +197 -0
- mindroot/server_prev.py +173 -0
- {mindroot-9.3.0.dist-info → mindroot-9.6.0.dist-info}/METADATA +7 -2
- {mindroot-9.3.0.dist-info → mindroot-9.6.0.dist-info}/RECORD +143 -113
- mindroot/coreplugins/admin/plugin_manager_backup.py +0 -615
- mindroot/coreplugins/admin/static/favicon/about.txt +0 -6
- mindroot/coreplugins/admin/static/favicon/android-chrome-512x512.png +0 -0
- mindroot/coreplugins/admin/static/favicon/apple-touch-icon.png +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon-16x16.png +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon-32x32.png +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon.ico +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon_io (1)/about.txt +0 -6
- mindroot/coreplugins/admin/static/favicon/favicon_io (1)/android-chrome-192x192.png +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon_io (1)/android-chrome-512x512.png +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon_io (1)/apple-touch-icon.png +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon_io (1)/favicon-16x16.png +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon_io (1)/favicon-32x32.png +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon_io (1)/favicon.ico +0 -0
- mindroot/coreplugins/admin/static/favicon/favicon_io (1)/site.webmanifest +0 -1
- mindroot/coreplugins/admin/static/favicon/logo.png +0 -0
- mindroot/coreplugins/admin/static/favicon/site.webmanifest +0 -1
- mindroot/coreplugins/admin/static/js/backup/agent-editor.js +0 -186
- mindroot/coreplugins/admin/static/js/backup/agent-form.js +0 -1133
- mindroot/coreplugins/admin/static/js/backup/agent-list.js +0 -94
- mindroot/coreplugins/chat/static/favicon/about.txt +0 -6
- mindroot/coreplugins/chat/static/favicon/android-chrome-192x192.png +0 -0
- mindroot/coreplugins/chat/static/favicon/android-chrome-512x512.png +0 -0
- mindroot/coreplugins/chat/static/favicon/apple-touch-icon.png +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon-16x16.png +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon-32x32.png +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon.ico +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon_io (1)/about.txt +0 -6
- mindroot/coreplugins/chat/static/favicon/favicon_io (1)/android-chrome-192x192.png +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon_io (1)/android-chrome-512x512.png +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon_io (1)/apple-touch-icon.png +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon_io (1)/favicon-16x16.png +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon_io (1)/favicon-32x32.png +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon_io (1)/favicon.ico +0 -0
- mindroot/coreplugins/chat/static/favicon/favicon_io (1)/site.webmanifest +0 -1
- mindroot/coreplugins/chat/static/favicon/logo.png +0 -0
- mindroot/coreplugins/chat/static/favicon/site.webmanifest +0 -1
- mindroot/coreplugins/index/default.json +0 -76
- mindroot/coreplugins/user_service/file_trigger_service.py +0 -12
- mindroot/coreplugins/user_service/hooks.py +0 -23
- /mindroot/coreplugins/{admin/static/favicon/android-chrome-192x192.png → home/static/imgs/backuplogo.png} +0 -0
- {mindroot-9.3.0.dist-info → mindroot-9.6.0.dist-info}/WHEEL +0 -0
- {mindroot-9.3.0.dist-info → mindroot-9.6.0.dist-info}/entry_points.txt +0 -0
- {mindroot-9.3.0.dist-info → mindroot-9.6.0.dist-info}/licenses/LICENSE +0 -0
- {mindroot-9.3.0.dist-info → mindroot-9.6.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
from typing import Dict, List, Any
|
|
2
|
+
import json
|
|
3
|
+
import inspect
|
|
4
|
+
from lib.providers.commands import command_manager
|
|
5
|
+
|
|
6
|
+
class MCPDynamicCommands:
|
|
7
|
+
"""Handles dynamic registration of MCP tools as MindRoot commands"""
|
|
8
|
+
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.registered_commands: Dict[str, str] = {} # cmd_name -> server_name
|
|
11
|
+
self.sessions: Dict[str, Any] = {} # Reference to sessions
|
|
12
|
+
|
|
13
|
+
def set_sessions(self, sessions: Dict[str, Any]):
|
|
14
|
+
"""Set reference to MCP sessions"""
|
|
15
|
+
self.sessions = sessions
|
|
16
|
+
|
|
17
|
+
async def register_tools(self, server_name: str, tools: List[Any]):
|
|
18
|
+
"""Register MCP tools as dynamic MindRoot commands"""
|
|
19
|
+
for tool in tools:
|
|
20
|
+
try:
|
|
21
|
+
tool_name = tool.name
|
|
22
|
+
#cmd_name = f"mcp_{server_name}_{tool_name}"
|
|
23
|
+
cmd_name = "mcp_"+tool_name
|
|
24
|
+
|
|
25
|
+
self.registered_commands[cmd_name] = server_name
|
|
26
|
+
|
|
27
|
+
# Create wrapper function with closure to capture current values
|
|
28
|
+
def create_wrapper(srv_name, tl_name):
|
|
29
|
+
async def mcp_tool_wrapper(*args, context=None, **kwargs):
|
|
30
|
+
if srv_name not in self.sessions:
|
|
31
|
+
return f"MCP server {srv_name} not connected"
|
|
32
|
+
|
|
33
|
+
session = self.sessions[srv_name]
|
|
34
|
+
|
|
35
|
+
# Convert arguments to MCP format
|
|
36
|
+
if len(args) == 1 and isinstance(args[0], dict):
|
|
37
|
+
arguments = args[0]
|
|
38
|
+
elif kwargs:
|
|
39
|
+
# Filter out context from kwargs
|
|
40
|
+
arguments = {k: v for k, v in kwargs.items() if k != 'context'}
|
|
41
|
+
else:
|
|
42
|
+
arguments = {}
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
result = await session.call_tool(tl_name, arguments)
|
|
46
|
+
|
|
47
|
+
# Extract content from CallToolResult object
|
|
48
|
+
if hasattr(result, 'content'):
|
|
49
|
+
if isinstance(result.content, list) and len(result.content) > 0:
|
|
50
|
+
# Return the text content of the first item
|
|
51
|
+
first_item = result.content[0]
|
|
52
|
+
return first_item.text if hasattr(first_item, 'text') else str(first_item)
|
|
53
|
+
else:
|
|
54
|
+
return str(result.content)
|
|
55
|
+
else:
|
|
56
|
+
return str(result)
|
|
57
|
+
except Exception as e:
|
|
58
|
+
return f"Error calling MCP tool {tl_name}: {str(e)}"
|
|
59
|
+
|
|
60
|
+
return mcp_tool_wrapper
|
|
61
|
+
|
|
62
|
+
wrapper = create_wrapper(server_name, tool_name)
|
|
63
|
+
|
|
64
|
+
# Create docstring with parameter information
|
|
65
|
+
description = getattr(tool, 'description', 'No description available')
|
|
66
|
+
|
|
67
|
+
# Extract parameter schema if available
|
|
68
|
+
param_info = ""
|
|
69
|
+
example_args = {}
|
|
70
|
+
|
|
71
|
+
if hasattr(tool, 'inputSchema') and tool.inputSchema:
|
|
72
|
+
schema = tool.inputSchema
|
|
73
|
+
if isinstance(schema, dict) and 'properties' in schema:
|
|
74
|
+
properties = schema['properties']
|
|
75
|
+
required = schema.get('required', [])
|
|
76
|
+
|
|
77
|
+
param_lines = []
|
|
78
|
+
for param_name, param_def in properties.items():
|
|
79
|
+
param_type = param_def.get('type', 'any')
|
|
80
|
+
param_desc = param_def.get('description', '')
|
|
81
|
+
is_required = param_name in required
|
|
82
|
+
req_text = ' (required)' if is_required else ' (optional)'
|
|
83
|
+
param_lines.append(f" {param_name} ({param_type}){req_text}: {param_desc}")
|
|
84
|
+
|
|
85
|
+
# Create example value based on type
|
|
86
|
+
if param_type == 'string':
|
|
87
|
+
example_args[param_name] = f"example_{param_name}"
|
|
88
|
+
elif param_type == 'number':
|
|
89
|
+
example_args[param_name] = 42
|
|
90
|
+
elif param_type == 'boolean':
|
|
91
|
+
example_args[param_name] = True
|
|
92
|
+
else:
|
|
93
|
+
example_args[param_name] = f"value_for_{param_name}"
|
|
94
|
+
|
|
95
|
+
if param_lines:
|
|
96
|
+
param_info = "\n\nParameters:\n" + "\n".join(param_lines)
|
|
97
|
+
|
|
98
|
+
# Use actual parameter names in example if available
|
|
99
|
+
example_json = json.dumps(example_args, indent=2) if example_args else '{"arg1": "value1"}'
|
|
100
|
+
|
|
101
|
+
docstring = f"""MCP Tool: {tool_name} from {server_name}
|
|
102
|
+
|
|
103
|
+
{description}{param_info}
|
|
104
|
+
|
|
105
|
+
{description}
|
|
106
|
+
|
|
107
|
+
Example:
|
|
108
|
+
{{ "{cmd_name}": {example_json} }}
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
# Register with command manager
|
|
112
|
+
try:
|
|
113
|
+
command_manager.register_function(
|
|
114
|
+
name=cmd_name,
|
|
115
|
+
provider="mcp",
|
|
116
|
+
implementation=wrapper,
|
|
117
|
+
signature=inspect.signature(wrapper),
|
|
118
|
+
docstring=docstring,
|
|
119
|
+
flags=[]
|
|
120
|
+
)
|
|
121
|
+
print(f"Registered MCP command: {cmd_name}")
|
|
122
|
+
|
|
123
|
+
# Verify registration
|
|
124
|
+
if cmd_name in command_manager.functions:
|
|
125
|
+
print(f" ✅ Verified: {cmd_name} is in command manager")
|
|
126
|
+
else:
|
|
127
|
+
print(f" ❌ Warning: {cmd_name} not found in command manager after registration")
|
|
128
|
+
except Exception as e:
|
|
129
|
+
print(f"Error registering {cmd_name}: {e}")
|
|
130
|
+
|
|
131
|
+
except Exception as e:
|
|
132
|
+
print(f"Error processing tool {getattr(tool, 'name', 'unknown')}: {e}")
|
|
133
|
+
continue
|
|
134
|
+
|
|
135
|
+
async def unregister_server_tools(self, server_name: str):
|
|
136
|
+
"""Unregister all tools for a server"""
|
|
137
|
+
commands_to_remove = []
|
|
138
|
+
for cmd_name, srv_name in self.registered_commands.items():
|
|
139
|
+
if srv_name == server_name:
|
|
140
|
+
commands_to_remove.append(cmd_name)
|
|
141
|
+
|
|
142
|
+
for cmd_name in commands_to_remove:
|
|
143
|
+
try:
|
|
144
|
+
if cmd_name in command_manager.functions:
|
|
145
|
+
del command_manager.functions[cmd_name]
|
|
146
|
+
del self.registered_commands[cmd_name]
|
|
147
|
+
print(f"Unregistered MCP command: {cmd_name}")
|
|
148
|
+
except Exception as e:
|
|
149
|
+
print(f"Error unregistering {cmd_name}: {e}")
|
|
150
|
+
|
|
151
|
+
def get_registered_commands(self) -> List[str]:
|
|
152
|
+
"""Get list of registered command names"""
|
|
153
|
+
return list(self.registered_commands.keys())
|
|
154
|
+
|