mindroot 9.22.0__py3-none-any.whl → 10.14.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/static/js/agent-form.js +26 -1
- mindroot/coreplugins/admin/static/js/persona-editor.js +14 -1
- mindroot/coreplugins/agent/agent.py +59 -18
- mindroot/coreplugins/agent/agent.py.bak +507 -0
- mindroot/coreplugins/agent/buagentz1.py +540 -0
- mindroot/coreplugins/agent/speech_to_speech.py +77 -0
- mindroot/coreplugins/agent/speech_to_speech.py.backup +46 -0
- mindroot/coreplugins/chat/buservices.py +625 -0
- mindroot/coreplugins/chat/buwidget_routes.py +287 -0
- mindroot/coreplugins/chat/commands.py +4 -0
- mindroot/coreplugins/chat/services.py +178 -8
- mindroot/coreplugins/chat/static/css/dark.css +90 -1
- mindroot/coreplugins/chat/static/css/default.css +90 -1
- mindroot/coreplugins/chat/static/css/light.css +724 -0
- mindroot/coreplugins/chat/static/css/mobile.css +37 -0
- mindroot/coreplugins/chat/static/js/chat.js +150 -89
- mindroot/coreplugins/chat/static/js/chatform.js +1 -1
- mindroot/coreplugins/chat/static/js/throttle.js +4 -2
- mindroot/coreplugins/chat/templates/chat.jinja2 +9 -1
- mindroot/coreplugins/chat/widget_routes.py +54 -10
- mindroot/coreplugins/check_list/helpers.py +221 -0
- mindroot/coreplugins/check_list/mod.py +435 -126
- mindroot/coreplugins/check_list/mod.py.backup +378 -0
- mindroot/coreplugins/check_list/mod.py.backup2 +506 -0
- mindroot/coreplugins/check_list/mod.py.backup3 +506 -0
- mindroot/coreplugins/check_list/mod_create_checklist_lol.py +756 -0
- mindroot/coreplugins/check_list/plugin_info.json +15 -0
- mindroot/coreplugins/jwt_auth/middleware.py +1 -1
- mindroot/docs/.env +1 -0
- mindroot/docs/.gitignore +1 -0
- mindroot/docs/_build/doctrees/chat_with_assistant.doctree +0 -0
- mindroot/docs/_build/doctrees/developer_documentation.doctree +0 -0
- mindroot/docs/_build/doctrees/embed_chat.doctree +0 -0
- mindroot/docs/_build/doctrees/environment.pickle +0 -0
- mindroot/docs/_build/doctrees/getting_started.doctree +0 -0
- mindroot/docs/_build/doctrees/index.doctree +0 -0
- mindroot/docs/_build/doctrees/install_plugins_with_tools.doctree +0 -0
- mindroot/docs/_build/doctrees/installation.doctree +0 -0
- mindroot/docs/_build/doctrees/llm_api_key.doctree +0 -0
- mindroot/docs/_build/doctrees/llm_plugin_installation.doctree +0 -0
- mindroot/docs/_build/doctrees/programming_task.doctree +0 -0
- mindroot/docs/_build/doctrees/source/ahp.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.admin.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.api_keys.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.chat.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.chat_avatar.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.check_list.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.credits.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.email.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.env_manager.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.events.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.index.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.index.handlers.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.jwt_auth.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.l8n.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.mcp_.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.persona.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.startup.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.subscriptions.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.usage.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.coreplugins.user_service.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.lib.auth.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.lib.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.lib.json_str_block.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.lib.plugins.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.lib.providers.backup.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.lib.providers.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mindroot.registry.doctree +0 -0
- mindroot/docs/_build/doctrees/source/modules.doctree +0 -0
- mindroot/docs/_build/doctrees/source/mr_agent_expert_instr.doctree +0 -0
- mindroot/docs/_build/doctrees/starting_mindroot.doctree +0 -0
- mindroot/docs/_build/doctrees/user_documentation.doctree +0 -0
- mindroot/docs/_build/html/_images/apikey.png +0 -0
- mindroot/docs/_build/html/_images/chatwidgetx.png +0 -0
- mindroot/docs/_build/html/_images/disablechatavatar.png +0 -0
- mindroot/docs/_build/html/_images/widgetform.png +0 -0
- mindroot/docs/_build/html/_images/widgetonpage.png +0 -0
- mindroot/docs/_build/html/_modules/index.html +1 -0
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/agent_importer.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/agent_router.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/asset_manager.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/command_router.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/mcp_catalog_routes.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/mcp_publish_routes.html +284 -91
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/mcp_registry_routes.html +284 -91
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/mcp_routes.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/mod.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/oauth_callback_router.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/persona_handler.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/persona_router.html +285 -89
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/plugin_manager.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/plugin_router.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/plugin_routes.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/registry_settings_routes.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/router.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/server_router.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/service_models.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/admin/settings_router.html +288 -89
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/api_keys/api_key_manager.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/api_keys/mod.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/api_keys/router.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/chat/commands.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/chat/mod.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/chat/models.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/chat/router.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/chat/services.html +283 -90
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/chat/widget_manager.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/chat/widget_routes.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/check_list/mod.html +669 -213
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/credits/conversion.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/credits/ledger.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/credits/mod.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/credits/models.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/credits/router.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/credits/storage.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/email/email_provider.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/email/imap_handler.html +284 -91
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/email/mod.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/email/services.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/email/smtp_handler.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/email/test_email_service.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/env_manager/mod.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/env_manager/router.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/events/router.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/index/handlers/agent_ops.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/index/handlers/index_ops.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/index/handlers/plugin_ops.html +284 -91
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/index/handlers/publish.html +281 -88
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/index/mod.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/index/models.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/index/router.html +284 -91
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/index/utils.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/jwt_auth/middleware.html +282 -89
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/jwt_auth/mod.html +279 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/jwt_auth/router.html +280 -87
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/l8n/language_detection.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/l8n/middleware.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/l8n/mod.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/l8n/test_enhanced.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/l8n/test_l8n_standalone.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/l8n/test_middleware.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/l8n/utils.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/mcp_/catalog_commands.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/mcp_/catalog_manager.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/mcp_/dynamic_commands.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/mcp_/mcp_manager.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/mcp_/mod.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/mcp_/oauth_storage.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/mcp_/server_installer.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/mcp_/testmcpclient.html +285 -89
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/persona/init_persona.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/persona/mod.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/startup/mod.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/subscriptions/credit_integration.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/subscriptions/mod.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/subscriptions/models.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/subscriptions/router.html +285 -89
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/subscriptions/storage.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/subscriptions/stripe_integration.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/subscriptions/subscription_manager.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/subscriptions/webhook_handler.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/usage/handlers.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/usage/mod.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/usage/models.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/usage/reporting.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/usage/router.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/usage/storage.html +285 -89
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/user_service/admin_init.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/user_service/email_service.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/user_service/mod.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/user_service/models.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/user_service/password_reset_service.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/user_service/role_service.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/coreplugins/user_service/router.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/auth/api_key.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/lib/auth/auth.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/buchatlog.html +285 -89
- mindroot/docs/_build/html/_modules/mindroot/lib/buchatlog2.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/butemplates.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/chatcontext.html +285 -89
- mindroot/docs/_build/html/_modules/mindroot/lib/chatlog.html +440 -91
- mindroot/docs/_build/html/_modules/mindroot/lib/chatlog_optimized.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/json_escape.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/lib/json_str_block/json_str_block.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/parent_templates.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/plugins/installation.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/lib/plugins/l8n_static_handler.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/lib/plugins/loader.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/plugins/loader_with_l8n.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/plugins/manifest.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/plugins/mapping.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/lib/plugins/paths.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/plugins_install.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/providers/commands.html +282 -87
- mindroot/docs/_build/html/_modules/mindroot/lib/providers/hooks.html +280 -85
- mindroot/docs/_build/html/_modules/mindroot/lib/providers/missing.html +282 -87
- mindroot/docs/_build/html/_modules/mindroot/lib/providers/model_preferences_v2.html +294 -91
- mindroot/docs/_build/html/_modules/mindroot/lib/providers/services.html +282 -87
- mindroot/docs/_build/html/_modules/mindroot/lib/providers.html +285 -89
- mindroot/docs/_build/html/_modules/mindroot/lib/route_decorators.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/session_files.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/streamcmd.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/lib/templates.html +343 -98
- mindroot/docs/_build/html/_modules/mindroot/lib/token_counter.html +280 -84
- mindroot/docs/_build/html/_modules/mindroot/migrate.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/registry/component_manager.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/registry/data_access.html +285 -89
- mindroot/docs/_build/html/_modules/mindroot/server.html +292 -87
- mindroot/docs/_build/html/_modules/mindroot/server_missing_normal_args.html +282 -86
- mindroot/docs/_build/html/_modules/mindroot/server_prev.html +282 -86
- mindroot/docs/_build/html/_sources/developer_documentation.rst.txt +21 -1
- mindroot/docs/_build/html/_sources/embed_chat.rst.txt +54 -0
- mindroot/docs/_build/html/_sources/user_documentation.rst.txt +6 -1
- mindroot/docs/_build/html/chat_with_assistant.html +1 -0
- mindroot/docs/_build/html/developer_documentation.html +45 -4
- mindroot/docs/_build/html/embed_chat.html +381 -0
- mindroot/docs/_build/html/genindex.html +9 -2
- mindroot/docs/_build/html/getting_started.html +19 -15
- mindroot/docs/_build/html/index.html +3 -0
- mindroot/docs/_build/html/install_plugins_with_tools.html +1 -0
- mindroot/docs/_build/html/installation.html +1 -0
- mindroot/docs/_build/html/llm_api_key.html +1 -0
- mindroot/docs/_build/html/llm_plugin_installation.html +1 -0
- mindroot/docs/_build/html/objects.inv +0 -0
- mindroot/docs/_build/html/programming_task.html +4 -3
- mindroot/docs/_build/html/py-modindex.html +2 -1
- mindroot/docs/_build/html/search.html +1 -0
- mindroot/docs/_build/html/searchindex.js +1 -1
- mindroot/docs/_build/html/source/ahp.html +1 -0
- mindroot/docs/_build/html/source/mindroot.coreplugins.admin.html +1 -0
- mindroot/docs/_build/html/source/mindroot.coreplugins.api_keys.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.chat.html +1 -0
- mindroot/docs/_build/html/source/mindroot.coreplugins.chat_avatar.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.check_list.html +91 -47
- mindroot/docs/_build/html/source/mindroot.coreplugins.credits.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.email.html +1 -0
- mindroot/docs/_build/html/source/mindroot.coreplugins.env_manager.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.events.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.html +3 -0
- mindroot/docs/_build/html/source/mindroot.coreplugins.index.handlers.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.index.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.jwt_auth.html +1 -0
- mindroot/docs/_build/html/source/mindroot.coreplugins.l8n.html +1 -0
- mindroot/docs/_build/html/source/mindroot.coreplugins.mcp_.html +1 -0
- mindroot/docs/_build/html/source/mindroot.coreplugins.persona.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.startup.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.subscriptions.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.usage.html +16 -2
- mindroot/docs/_build/html/source/mindroot.coreplugins.user_service.html +16 -2
- mindroot/docs/_build/html/source/mindroot.html +2 -0
- mindroot/docs/_build/html/source/mindroot.lib.auth.html +16 -2
- mindroot/docs/_build/html/source/mindroot.lib.html +36 -4
- mindroot/docs/_build/html/source/mindroot.lib.json_str_block.html +16 -2
- mindroot/docs/_build/html/source/mindroot.lib.plugins.html +16 -2
- mindroot/docs/_build/html/source/mindroot.lib.providers.backup.html +1 -0
- mindroot/docs/_build/html/source/mindroot.lib.providers.html +1 -0
- mindroot/docs/_build/html/source/mindroot.registry.html +16 -2
- mindroot/docs/_build/html/source/modules.html +16 -2
- mindroot/docs/_build/html/source/mr_agent_expert_instr.html +1 -0
- mindroot/docs/_build/html/starting_mindroot.html +1 -0
- mindroot/docs/_build/html/user_documentation.html +9 -0
- mindroot/docs/apikey.png +0 -0
- mindroot/docs/chatwidget1.png +0 -0
- mindroot/docs/chatwidgetx.png +0 -0
- mindroot/docs/developer_documentation.rst +21 -1
- mindroot/docs/disablechatavatar.png +0 -0
- mindroot/docs/embed_chat.rst +54 -0
- mindroot/docs/user_documentation.rst +6 -1
- mindroot/docs/widgetform.png +0 -0
- mindroot/docs/widgetonpage.png +0 -0
- mindroot/lib/buchatlog3.py +592 -0
- mindroot/lib/chatcontext.py +1 -0
- mindroot/lib/chatlog.py +195 -5
- mindroot/lib/logging/logfiles.py +1 -0
- {mindroot-9.22.0.dist-info → mindroot-10.14.0.dist-info}/METADATA +1 -1
- {mindroot-9.22.0.dist-info → mindroot-10.14.0.dist-info}/RECORD +282 -300
- mindroot/docs/_build/html/.buildinfo.bak +0 -4
- mindroot/docs/_build/html/_static/_sphinx_javascript_frameworks_compat.js +0 -123
- mindroot/docs/_build/html/_static/css/badge_only.css +0 -1
- mindroot/docs/_build/html/_static/css/fonts/Roboto-Slab-Bold.woff +0 -0
- mindroot/docs/_build/html/_static/css/fonts/Roboto-Slab-Bold.woff2 +0 -0
- mindroot/docs/_build/html/_static/css/fonts/Roboto-Slab-Regular.woff +0 -0
- mindroot/docs/_build/html/_static/css/fonts/Roboto-Slab-Regular.woff2 +0 -0
- mindroot/docs/_build/html/_static/css/fonts/fontawesome-webfont.eot +0 -0
- mindroot/docs/_build/html/_static/css/fonts/fontawesome-webfont.svg +0 -2671
- mindroot/docs/_build/html/_static/css/fonts/fontawesome-webfont.ttf +0 -0
- mindroot/docs/_build/html/_static/css/fonts/fontawesome-webfont.woff +0 -0
- mindroot/docs/_build/html/_static/css/fonts/fontawesome-webfont.woff2 +0 -0
- mindroot/docs/_build/html/_static/css/fonts/lato-bold-italic.woff +0 -0
- mindroot/docs/_build/html/_static/css/fonts/lato-bold-italic.woff2 +0 -0
- mindroot/docs/_build/html/_static/css/fonts/lato-bold.woff +0 -0
- mindroot/docs/_build/html/_static/css/fonts/lato-bold.woff2 +0 -0
- mindroot/docs/_build/html/_static/css/fonts/lato-normal-italic.woff +0 -0
- mindroot/docs/_build/html/_static/css/fonts/lato-normal-italic.woff2 +0 -0
- mindroot/docs/_build/html/_static/css/fonts/lato-normal.woff +0 -0
- mindroot/docs/_build/html/_static/css/fonts/lato-normal.woff2 +0 -0
- mindroot/docs/_build/html/_static/css/theme.css +0 -4
- mindroot/docs/_build/html/_static/fonts/Lato/lato-bold.eot +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-bold.ttf +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-bold.woff +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-bold.woff2 +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-bolditalic.eot +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-bolditalic.ttf +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-bolditalic.woff +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-bolditalic.woff2 +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-italic.eot +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-italic.ttf +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-italic.woff +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-italic.woff2 +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-regular.eot +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-regular.ttf +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-regular.woff +0 -0
- mindroot/docs/_build/html/_static/fonts/Lato/lato-regular.woff2 +0 -0
- mindroot/docs/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot +0 -0
- mindroot/docs/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf +0 -0
- mindroot/docs/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff +0 -0
- mindroot/docs/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2 +0 -0
- mindroot/docs/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot +0 -0
- mindroot/docs/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf +0 -0
- mindroot/docs/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff +0 -0
- mindroot/docs/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2 +0 -0
- mindroot/docs/_build/html/_static/jquery.js +0 -2
- mindroot/docs/_build/html/_static/js/badge_only.js +0 -1
- mindroot/docs/_build/html/_static/js/theme.js +0 -1
- mindroot/docs/_build/html/_static/js/versions.js +0 -228
- {mindroot-9.22.0.dist-info → mindroot-10.14.0.dist-info}/WHEEL +0 -0
- {mindroot-9.22.0.dist-info → mindroot-10.14.0.dist-info}/entry_points.txt +0 -0
- {mindroot-9.22.0.dist-info → mindroot-10.14.0.dist-info}/licenses/LICENSE +0 -0
- {mindroot-9.22.0.dist-info → mindroot-10.14.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
from fastapi import APIRouter, HTTPException, Request, Response
|
|
2
|
+
from fastapi.responses import HTMLResponse
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
from typing import Optional, List
|
|
5
|
+
from .widget_manager import widget_manager
|
|
6
|
+
from lib.auth.api_key import verify_api_key
|
|
7
|
+
from lib.providers.services import service_manager
|
|
8
|
+
from lib.route_decorators import public_route
|
|
9
|
+
import nanoid
|
|
10
|
+
from .services import init_chat_session
|
|
11
|
+
from lib.session_files import save_session_data
|
|
12
|
+
import traceback
|
|
13
|
+
|
|
14
|
+
router = APIRouter()
|
|
15
|
+
|
|
16
|
+
class WidgetTokenCreate(BaseModel):
|
|
17
|
+
api_key: str
|
|
18
|
+
agent_name: str
|
|
19
|
+
base_url: str
|
|
20
|
+
description: Optional[str] = ""
|
|
21
|
+
styling: Optional[dict] = None
|
|
22
|
+
|
|
23
|
+
class WidgetTokenResponse(BaseModel):
|
|
24
|
+
token: str
|
|
25
|
+
agent_name: str
|
|
26
|
+
base_url: str
|
|
27
|
+
description: str
|
|
28
|
+
created_at: str
|
|
29
|
+
created_by: str
|
|
30
|
+
styling: dict
|
|
31
|
+
|
|
32
|
+
@router.post("/widgets/create")
|
|
33
|
+
async def create_widget_token(request: Request, widget_request: WidgetTokenCreate):
|
|
34
|
+
"""Create a new widget token."""
|
|
35
|
+
try:
|
|
36
|
+
# Verify the API key is valid
|
|
37
|
+
api_key_data = await verify_api_key(widget_request.api_key)
|
|
38
|
+
if not api_key_data:
|
|
39
|
+
raise HTTPException(status_code=400, detail="Invalid API key")
|
|
40
|
+
|
|
41
|
+
# Verify the agent exists
|
|
42
|
+
try:
|
|
43
|
+
agent_data = await service_manager.get_agent_data(widget_request.agent_name)
|
|
44
|
+
if not agent_data:
|
|
45
|
+
raise HTTPException(status_code=400, detail="Agent not found")
|
|
46
|
+
except Exception:
|
|
47
|
+
raise HTTPException(status_code=400, detail="Agent not found")
|
|
48
|
+
|
|
49
|
+
# Get the current user
|
|
50
|
+
user = request.state.user
|
|
51
|
+
|
|
52
|
+
# Create the widget token
|
|
53
|
+
token = widget_manager.create_widget_token(
|
|
54
|
+
api_key=widget_request.api_key,
|
|
55
|
+
agent_name=widget_request.agent_name,
|
|
56
|
+
base_url=widget_request.base_url,
|
|
57
|
+
created_by=user.username,
|
|
58
|
+
description=widget_request.description,
|
|
59
|
+
styling=widget_request.styling
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
"success": True,
|
|
64
|
+
"token": token,
|
|
65
|
+
"embed_url": f"{widget_request.base_url}/chat/embed/{token}"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
except HTTPException:
|
|
69
|
+
raise
|
|
70
|
+
except Exception as e:
|
|
71
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
72
|
+
|
|
73
|
+
@router.get("/widgets/list")
|
|
74
|
+
async def list_widget_tokens(request: Request):
|
|
75
|
+
"""List widget tokens for the current user."""
|
|
76
|
+
try:
|
|
77
|
+
user = request.state.user
|
|
78
|
+
widgets = widget_manager.list_widget_tokens(created_by=user.username)
|
|
79
|
+
return {"success": True, "data": widgets}
|
|
80
|
+
except Exception as e:
|
|
81
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
82
|
+
|
|
83
|
+
@router.delete("/widgets/delete/{token}")
|
|
84
|
+
async def delete_widget_token(request: Request, token: str):
|
|
85
|
+
"""Delete a widget token."""
|
|
86
|
+
try:
|
|
87
|
+
# Verify the widget exists and belongs to the user
|
|
88
|
+
widget_config = widget_manager.get_widget_config(token)
|
|
89
|
+
if not widget_config:
|
|
90
|
+
raise HTTPException(status_code=404, detail="Widget token not found")
|
|
91
|
+
|
|
92
|
+
user = request.state.user
|
|
93
|
+
if widget_config.get("created_by") != user.username:
|
|
94
|
+
raise HTTPException(status_code=403, detail="Not authorized to delete this widget")
|
|
95
|
+
|
|
96
|
+
success = widget_manager.delete_widget_token(token)
|
|
97
|
+
if success:
|
|
98
|
+
return {"success": True, "message": "Widget token deleted successfully"}
|
|
99
|
+
else:
|
|
100
|
+
raise HTTPException(status_code=500, detail="Failed to delete widget token")
|
|
101
|
+
|
|
102
|
+
except HTTPException:
|
|
103
|
+
raise
|
|
104
|
+
except Exception as e:
|
|
105
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
106
|
+
|
|
107
|
+
@router.get("/chat/embed/{token}")
|
|
108
|
+
@public_route()
|
|
109
|
+
async def get_embed_script(token: str):
|
|
110
|
+
"""Generate the secure embed script for a widget token."""
|
|
111
|
+
try:
|
|
112
|
+
# Validate the widget token
|
|
113
|
+
widget_config = widget_manager.get_widget_config(token)
|
|
114
|
+
if not widget_config:
|
|
115
|
+
raise HTTPException(status_code=404, detail="Widget token not found")
|
|
116
|
+
|
|
117
|
+
# Generate the embed JavaScript
|
|
118
|
+
base_url = widget_config["base_url"]
|
|
119
|
+
styling = widget_config.get("styling", {})
|
|
120
|
+
|
|
121
|
+
# Create the embed script that doesn't expose the API key
|
|
122
|
+
embed_script = f'''
|
|
123
|
+
(function() {{
|
|
124
|
+
const config = {{
|
|
125
|
+
baseUrl: "{base_url}",
|
|
126
|
+
token: "{token}",
|
|
127
|
+
position: "{styling.get('position', 'bottom-right')}",
|
|
128
|
+
width: "{styling.get('width', '400px')}",
|
|
129
|
+
height: "{styling.get('height', '600px')}",
|
|
130
|
+
theme: "{styling.get('theme', 'dark')}"
|
|
131
|
+
}};
|
|
132
|
+
|
|
133
|
+
let chatContainer = null;
|
|
134
|
+
let chatIcon = null;
|
|
135
|
+
let isLoaded = false;
|
|
136
|
+
|
|
137
|
+
function createChatIcon() {{
|
|
138
|
+
if (chatIcon) return;
|
|
139
|
+
|
|
140
|
+
chatIcon = document.createElement("div");
|
|
141
|
+
chatIcon.id = "mindroot-chat-icon-" + config.token;
|
|
142
|
+
chatIcon.innerHTML = "💬";
|
|
143
|
+
|
|
144
|
+
const iconStyles = {{
|
|
145
|
+
position: "fixed",
|
|
146
|
+
bottom: "20px",
|
|
147
|
+
right: config.position.includes("left") ? "auto" : "20px",
|
|
148
|
+
left: config.position.includes("left") ? "20px" : "auto",
|
|
149
|
+
width: "60px",
|
|
150
|
+
height: "60px",
|
|
151
|
+
background: "#2196F3",
|
|
152
|
+
borderRadius: "50%",
|
|
153
|
+
display: "flex",
|
|
154
|
+
alignItems: "center",
|
|
155
|
+
justifyContent: "center",
|
|
156
|
+
cursor: "pointer",
|
|
157
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.3)",
|
|
158
|
+
zIndex: "10000",
|
|
159
|
+
fontSize: "24px",
|
|
160
|
+
color: "white",
|
|
161
|
+
transition: "all 0.3s ease"
|
|
162
|
+
}};
|
|
163
|
+
|
|
164
|
+
Object.assign(chatIcon.style, iconStyles);
|
|
165
|
+
chatIcon.addEventListener("click", toggleChat);
|
|
166
|
+
document.body.appendChild(chatIcon);
|
|
167
|
+
}}
|
|
168
|
+
|
|
169
|
+
function createChatContainer() {{
|
|
170
|
+
if (chatContainer) return;
|
|
171
|
+
|
|
172
|
+
chatContainer = document.createElement("div");
|
|
173
|
+
chatContainer.id = "mindroot-chat-container-" + config.token;
|
|
174
|
+
|
|
175
|
+
const containerStyles = {{
|
|
176
|
+
position: "fixed",
|
|
177
|
+
bottom: "90px",
|
|
178
|
+
right: config.position.includes("left") ? "auto" : "20px",
|
|
179
|
+
left: config.position.includes("left") ? "20px" : "auto",
|
|
180
|
+
width: config.width,
|
|
181
|
+
height: config.height,
|
|
182
|
+
background: "white",
|
|
183
|
+
borderRadius: "12px",
|
|
184
|
+
boxShadow: "0 8px 32px rgba(0, 0, 0, 0.3)",
|
|
185
|
+
zIndex: "10001",
|
|
186
|
+
display: "none",
|
|
187
|
+
overflow: "hidden"
|
|
188
|
+
}};
|
|
189
|
+
|
|
190
|
+
Object.assign(chatContainer.style, containerStyles);
|
|
191
|
+
document.body.appendChild(chatContainer);
|
|
192
|
+
}}
|
|
193
|
+
|
|
194
|
+
function toggleChat() {{
|
|
195
|
+
if (!chatContainer) createChatContainer();
|
|
196
|
+
|
|
197
|
+
const isVisible = chatContainer.style.display !== "none";
|
|
198
|
+
|
|
199
|
+
if (isVisible) {{
|
|
200
|
+
chatContainer.style.display = "none";
|
|
201
|
+
}} else {{
|
|
202
|
+
if (!isLoaded) {{
|
|
203
|
+
// Create iframe and load the secure session
|
|
204
|
+
const iframe = document.createElement("iframe");
|
|
205
|
+
iframe.style.cssText = "width: 100%; height: 100%; border: none; border-radius: 12px;";
|
|
206
|
+
iframe.src = config.baseUrl + "/chat/widget/" + config.token + "/session";
|
|
207
|
+
chatContainer.appendChild(iframe);
|
|
208
|
+
isLoaded = true;
|
|
209
|
+
}}
|
|
210
|
+
chatContainer.style.display = "block";
|
|
211
|
+
}}
|
|
212
|
+
}}
|
|
213
|
+
|
|
214
|
+
function init() {{
|
|
215
|
+
if (document.readyState === "loading") {{
|
|
216
|
+
document.addEventListener("DOMContentLoaded", function() {{
|
|
217
|
+
createChatIcon();
|
|
218
|
+
}});
|
|
219
|
+
}} else {{
|
|
220
|
+
createChatIcon();
|
|
221
|
+
}}
|
|
222
|
+
}}
|
|
223
|
+
|
|
224
|
+
init();
|
|
225
|
+
}})();
|
|
226
|
+
'''
|
|
227
|
+
|
|
228
|
+
return Response(
|
|
229
|
+
content=embed_script,
|
|
230
|
+
media_type="application/javascript",
|
|
231
|
+
headers={
|
|
232
|
+
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
233
|
+
"Pragma": "no-cache",
|
|
234
|
+
"Expires": "0"
|
|
235
|
+
}
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
except HTTPException:
|
|
239
|
+
raise
|
|
240
|
+
except Exception as e:
|
|
241
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
@router.get("/chat/widget/{token}/session")
|
|
245
|
+
@public_route()
|
|
246
|
+
async def create_widget_session(token: str):
|
|
247
|
+
"""Create a secure chat session for a widget token."""
|
|
248
|
+
try:
|
|
249
|
+
# Validate the widget token
|
|
250
|
+
widget_config = widget_manager.get_widget_config(token)
|
|
251
|
+
if not widget_config:
|
|
252
|
+
raise HTTPException(status_code=404, detail="Widget token not found")
|
|
253
|
+
|
|
254
|
+
# Verify the API key from the widget config
|
|
255
|
+
api_key_data = await verify_api_key(widget_config["api_key"])
|
|
256
|
+
if not api_key_data:
|
|
257
|
+
raise HTTPException(status_code=401, detail="Invalid API key in widget configuration")
|
|
258
|
+
|
|
259
|
+
# Create mock user and generate session ID
|
|
260
|
+
class MockUser:
|
|
261
|
+
def __init__(self, username):
|
|
262
|
+
self.username = username
|
|
263
|
+
user = MockUser(api_key_data['username'])
|
|
264
|
+
session_id = nanoid.generate()
|
|
265
|
+
agent_name = widget_config["agent_name"]
|
|
266
|
+
|
|
267
|
+
# Initialize the chat session (this was missing!)
|
|
268
|
+
await init_chat_session(user, agent_name, session_id)
|
|
269
|
+
|
|
270
|
+
# Create and save access token for authentication
|
|
271
|
+
from coreplugins.jwt_auth.middleware import create_access_token
|
|
272
|
+
token_data = create_access_token({"sub": api_key_data['username']})
|
|
273
|
+
await save_session_data(session_id, "access_token", token_data)
|
|
274
|
+
|
|
275
|
+
# Now redirect to the session WITHOUT exposing the API key
|
|
276
|
+
redirect_url = f"/session/{agent_name}/{session_id}?embed=true"
|
|
277
|
+
|
|
278
|
+
return Response(
|
|
279
|
+
status_code=302,
|
|
280
|
+
headers={"Location": redirect_url}
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
except Exception as e:
|
|
284
|
+
trace = traceback.format_exc()
|
|
285
|
+
print(e, trace)
|
|
286
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
287
|
+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from lib.providers.commands import command, command_manager
|
|
2
2
|
from lib.providers.services import service_manager
|
|
3
3
|
from lib.chatcontext import ChatContext
|
|
4
|
+
from lib.chatlog import ChatLog
|
|
4
5
|
from .services import init_chat_session, send_message_to_agent, subscribe_to_agent_messages
|
|
5
6
|
import asyncio
|
|
6
7
|
import json
|
|
@@ -150,6 +151,9 @@ async def delegate_task(instructions: str, agent_name, log_id=None, retries=3, c
|
|
|
150
151
|
(text, full_results, xx) = await service_manager.run_task(instructions, user=context.username, log_id=log_id,
|
|
151
152
|
parent_log_id = context.log_id,
|
|
152
153
|
llm=llm, agent_name=agent_name, retries=retries, context=None)
|
|
154
|
+
if text is None or text == "" or text == [] or text == '[]':
|
|
155
|
+
chatlog = ChatLog(log_id=context.log_id, user=context.username, agent=agent_name)
|
|
156
|
+
text = json.dumps(chatlog.messages)
|
|
153
157
|
return f"""<a href="/session/{agent_name}/{log_id}" target="_blank">Task completed with log ID: {log_id}</a>\nResults:\n\n{text}"""
|
|
154
158
|
|
|
155
159
|
|
|
@@ -8,6 +8,7 @@ from typing import List
|
|
|
8
8
|
from lib.utils.dataurl import dataurl_to_pil
|
|
9
9
|
from .models import MessageParts
|
|
10
10
|
from coreplugins.agent import agent
|
|
11
|
+
from coreplugins.agent.speech_to_speech import SpeechToSpeechAgent
|
|
11
12
|
from lib.utils.debug import debug_box
|
|
12
13
|
import os
|
|
13
14
|
import sys
|
|
@@ -22,6 +23,10 @@ from io import BytesIO
|
|
|
22
23
|
import base64
|
|
23
24
|
import nanoid
|
|
24
25
|
sse_clients = {}
|
|
26
|
+
from lib.chatcontext import get_context
|
|
27
|
+
|
|
28
|
+
# Track active processing tasks per session
|
|
29
|
+
active_tasks = {}
|
|
25
30
|
|
|
26
31
|
@service()
|
|
27
32
|
async def prompt(model: str, instructions: str, temperature=0, max_tokens=400, json=False, context=None):
|
|
@@ -67,7 +72,7 @@ def results_output(results):
|
|
|
67
72
|
text = ""
|
|
68
73
|
for result in results:
|
|
69
74
|
if 'output' in result['args']:
|
|
70
|
-
return result['args']['output']
|
|
75
|
+
return str(result['args']['output'])
|
|
71
76
|
|
|
72
77
|
def results_text_output(results):
|
|
73
78
|
text = ""
|
|
@@ -134,6 +139,9 @@ async def run_task(instructions: str, agent_name:str = None, user:str = None, lo
|
|
|
134
139
|
|
|
135
140
|
while retried < retries:
|
|
136
141
|
[results, full_results] = await send_message_to_agent(context.log_id, instructions, context=context)
|
|
142
|
+
print('#####################################################33')
|
|
143
|
+
print("Full results: ", full_results)
|
|
144
|
+
print("Results: ", results)
|
|
137
145
|
text = results_output(full_results)
|
|
138
146
|
if text == "":
|
|
139
147
|
retried += 1
|
|
@@ -164,6 +172,11 @@ async def init_chat_session(user:str, agent_name: str, log_id: str, context=None
|
|
|
164
172
|
print("context.agent_name: ", context.agent_name)
|
|
165
173
|
await context.save_context()
|
|
166
174
|
print("initiated_chat_session: ", log_id, agent_name, context.agent_name, context.agent)
|
|
175
|
+
|
|
176
|
+
if 'live' in context.agent['stream_chat'] or 'realtime' in context.agent['stream_chat']:
|
|
177
|
+
agent = SpeechToSpeechAgent(agent_name, context=context)
|
|
178
|
+
await agent.connect()
|
|
179
|
+
|
|
167
180
|
return log_id
|
|
168
181
|
|
|
169
182
|
@service()
|
|
@@ -216,13 +229,61 @@ def process_result(result, formatted_results):
|
|
|
216
229
|
|
|
217
230
|
return formatted_results
|
|
218
231
|
|
|
232
|
+
# Deprecated - use active_tasks instead
|
|
233
|
+
in_progress = {}
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
@service()
|
|
237
|
+
async def cancel_and_wait(session_id: str, user:str, context=None):
|
|
238
|
+
global in_progress, active_tasks
|
|
239
|
+
existing_task = active_tasks.get(session_id)
|
|
240
|
+
|
|
241
|
+
if not in_progress.get(session_id, False):
|
|
242
|
+
print(f"SEND_MESSAGE No active processing for session {session_id} to cancel.")
|
|
243
|
+
return
|
|
244
|
+
try:
|
|
245
|
+
print(f"SEND_MESSAGE Cancelling active task for session {session_id}...")
|
|
246
|
+
existing_context = await get_context(session_id, user)
|
|
247
|
+
existing_context.data['cancel_current_turn'] = True
|
|
248
|
+
existing_context.data['finished_conversation'] = True
|
|
249
|
+
existing_context.save_context()
|
|
250
|
+
# Cancel any active command task
|
|
251
|
+
if 'active_command_task' in existing_context.data:
|
|
252
|
+
cmd_task = existing_context.data['active_command_task']
|
|
253
|
+
if cmd_task and not cmd_task.done():
|
|
254
|
+
cmd_task.cancel()
|
|
255
|
+
|
|
256
|
+
await existing_context.save_context()
|
|
257
|
+
except Exception as e:
|
|
258
|
+
print(f"SEND_MESSAGE Error setting cancellation flags: {e}")
|
|
259
|
+
|
|
260
|
+
# Cancel the main task
|
|
261
|
+
existing_task.cancel()
|
|
262
|
+
|
|
263
|
+
# Wait for it to actually finish (with timeout)
|
|
264
|
+
try:
|
|
265
|
+
await asyncio.wait_for(existing_task, timeout=2.0)
|
|
266
|
+
except (asyncio.CancelledError, asyncio.TimeoutError):
|
|
267
|
+
pass # Expected
|
|
268
|
+
|
|
269
|
+
start_wait = time.time()
|
|
270
|
+
while in_progress.get(session_id, False) and (time.time() - start_wait) < 5.0:
|
|
271
|
+
print(f"SEND_MESSAGE Waiting for cancellation of session {session_id} to complete...")
|
|
272
|
+
await asyncio.sleep(0.025)
|
|
273
|
+
|
|
274
|
+
print(f"SEND_MESSAGE Cancellation complete for session {session_id}")
|
|
275
|
+
|
|
219
276
|
@service()
|
|
220
277
|
async def send_message_to_agent(session_id: str, message: str | List[MessageParts], max_iterations=35, context=None, user=None):
|
|
221
|
-
|
|
222
|
-
|
|
278
|
+
global in_progress, active_tasks
|
|
279
|
+
|
|
280
|
+
# Check if there's an active task for this session
|
|
281
|
+
existing_task = active_tasks.get(session_id)
|
|
282
|
+
|
|
223
283
|
if not user:
|
|
224
284
|
# check context
|
|
225
285
|
if not context.username:
|
|
286
|
+
print("SEND_MESSAGE No user provided and context has no username")
|
|
226
287
|
raise Exception("User required")
|
|
227
288
|
else:
|
|
228
289
|
user = {"user": context.username }
|
|
@@ -230,20 +291,46 @@ async def send_message_to_agent(session_id: str, message: str | List[MessagePart
|
|
|
230
291
|
if hasattr(user, "dict"):
|
|
231
292
|
user = user.dict()
|
|
232
293
|
|
|
294
|
+
context.data['cancel_current_turn'] = False
|
|
295
|
+
context.data['finished_conversation'] = False
|
|
296
|
+
await context.save_context()
|
|
297
|
+
|
|
298
|
+
in_progress[session_id] = True
|
|
299
|
+
await asyncio.sleep(0.05)
|
|
300
|
+
|
|
301
|
+
print('b')
|
|
302
|
+
if os.environ.get("MR_MAX_ITERATIONS") is not None:
|
|
303
|
+
max_iterations = int(os.environ.get("MR_MAX_ITERATIONS"))
|
|
233
304
|
try:
|
|
234
305
|
if type(message) is list:
|
|
235
306
|
message = [m.dict() for m in message]
|
|
236
307
|
|
|
237
308
|
if session_id is None or session_id == "" or message is None or message == "":
|
|
238
|
-
print("Invalid session_id or message")
|
|
309
|
+
print("SEND_MESSAGE Invalid session_id or message")
|
|
239
310
|
return []
|
|
240
311
|
|
|
312
|
+
# Create the main processing task and store it
|
|
313
|
+
processing_task = asyncio.current_task()
|
|
314
|
+
active_tasks[session_id] = processing_task
|
|
315
|
+
|
|
316
|
+
print("SEND_MESSAGE proceeding with message processing")
|
|
241
317
|
print("send_message_to_agent: ", session_id, message, max_iterations)
|
|
242
318
|
if context is None:
|
|
243
319
|
context = ChatContext(command_manager, service_manager, user)
|
|
244
320
|
await context.load_context(session_id)
|
|
245
321
|
|
|
246
|
-
|
|
322
|
+
if 'live' in context.agent['stream_chat'] or 'realtime' in context.agent['stream_chat']:
|
|
323
|
+
agent_ = SpeechToSpeechAgent(context.agent_name, context=context)
|
|
324
|
+
print('Using SpeechToSpeechAgent for live/realtime chat')
|
|
325
|
+
print()
|
|
326
|
+
print()
|
|
327
|
+
print()
|
|
328
|
+
print('message: ', message)
|
|
329
|
+
results = await agent_.send_message(message)
|
|
330
|
+
return results, []
|
|
331
|
+
else:
|
|
332
|
+
agent_ = agent.Agent(agent=context.agent)
|
|
333
|
+
|
|
247
334
|
if user is not None and hasattr(user, "keys"):
|
|
248
335
|
for key in user.keys():
|
|
249
336
|
context.data[key] = user[key]
|
|
@@ -297,8 +384,8 @@ async def send_message_to_agent(session_id: str, message: str | List[MessagePart
|
|
|
297
384
|
context.current_model = context.data['llm']
|
|
298
385
|
|
|
299
386
|
parse_error = False
|
|
300
|
-
|
|
301
|
-
results, full_cmds = await agent_.chat_commands(context.current_model, context, messages=context.chat_log.get_recent())
|
|
387
|
+
max_tokens = os.environ.get("MR_MAX_TOKENS", 4000)
|
|
388
|
+
results, full_cmds = await agent_.chat_commands(context.current_model, context, messages=context.chat_log.get_recent(), max_tokens=max_tokens)
|
|
302
389
|
if results is not None:
|
|
303
390
|
try:
|
|
304
391
|
for result in results:
|
|
@@ -372,9 +459,12 @@ async def send_message_to_agent(session_id: str, message: str | List[MessagePart
|
|
|
372
459
|
context.chat_log.add_message({"role": "user", "content": formatted_results})
|
|
373
460
|
results.append(out_results)
|
|
374
461
|
else:
|
|
375
|
-
print("Processing iteration: ", iterations, "no message added")
|
|
462
|
+
print("SEND_MESSAGE Processing iteration: ", iterations, "no message added")
|
|
376
463
|
if context.data.get('finished_conversation') is True:
|
|
377
464
|
termcolor.cprint("Finished conversation, exiting send_message_to_agent", "red")
|
|
465
|
+
if context.data.get('task_result') is not None:
|
|
466
|
+
task_result = context.data.get('task_result')
|
|
467
|
+
full_results.append({ "cmd": "task_result", "args": { "result": task_result } })
|
|
378
468
|
continue_processing = False
|
|
379
469
|
except Exception as e:
|
|
380
470
|
continue_processing = False
|
|
@@ -398,10 +488,23 @@ async def send_message_to_agent(session_id: str, message: str | List[MessagePart
|
|
|
398
488
|
print("Exiting send_message_to_agent: ", session_id, message, max_iterations)
|
|
399
489
|
|
|
400
490
|
await context.finished_chat()
|
|
491
|
+
in_progress.pop(session_id, None)
|
|
492
|
+
active_tasks.pop(session_id, None)
|
|
493
|
+
if len(results) == 0:
|
|
494
|
+
if context.data.get('task_result') is not None:
|
|
495
|
+
task_result = context.data.get('task_result')
|
|
496
|
+
results.append(task_result)
|
|
497
|
+
print("SEND_MESSAGE Done")
|
|
401
498
|
return [results, full_results]
|
|
499
|
+
except asyncio.CancelledError:
|
|
500
|
+
print(f"Task cancelled for session {session_id}")
|
|
501
|
+
in_progress.pop(session_id, None)
|
|
502
|
+
active_tasks.pop(session_id, None)
|
|
503
|
+
raise # Re-raise to properly handle cancellation
|
|
402
504
|
except Exception as e:
|
|
403
505
|
print("Error in send_message_to_agent: ", e)
|
|
404
506
|
print(traceback.format_exc())
|
|
507
|
+
in_progress.pop(session_id, None)
|
|
405
508
|
return []
|
|
406
509
|
|
|
407
510
|
@pipe(name='process_results', priority=5)
|
|
@@ -485,3 +588,70 @@ async def command_result(command: str, result, context=None):
|
|
|
485
588
|
agent_ = context.agent
|
|
486
589
|
await context.agent_output("command_result", { "command": command, "result": result, "persona": agent_['persona']['name'] })
|
|
487
590
|
|
|
591
|
+
@service()
|
|
592
|
+
async def backend_user_message(message: str, context=None):
|
|
593
|
+
"""
|
|
594
|
+
Signal the frontend to display a user message.
|
|
595
|
+
"""
|
|
596
|
+
agent_ = context.agent
|
|
597
|
+
persona = 'user'
|
|
598
|
+
await context.agent_output("backend_user_message", {
|
|
599
|
+
"content": message,
|
|
600
|
+
"sender": "user",
|
|
601
|
+
"persona": persona
|
|
602
|
+
})
|
|
603
|
+
|
|
604
|
+
@service()
|
|
605
|
+
async def cancel_active_response(log_id: str, context=None):
|
|
606
|
+
"""
|
|
607
|
+
Cancel active AI response for eager end of turn processing.
|
|
608
|
+
Sets the finished_conversation flag to stop the agent processing loop.
|
|
609
|
+
"""
|
|
610
|
+
if context is None:
|
|
611
|
+
# Get context from log_id - we need the username, but for SIP calls it might be 'system'
|
|
612
|
+
# Try to load context, fallback to system user if needed
|
|
613
|
+
try:
|
|
614
|
+
context = await get_context(log_id, 'system')
|
|
615
|
+
except Exception as e:
|
|
616
|
+
print(f"Error getting context for cancellation: {e}")
|
|
617
|
+
return {"status": "error", "message": f"Could not load context: {e}"}
|
|
618
|
+
|
|
619
|
+
# Set flag to stop current processing loop iteration
|
|
620
|
+
# But don't permanently mark conversation as finished - just this turn
|
|
621
|
+
context.data['cancel_current_turn'] = True
|
|
622
|
+
|
|
623
|
+
# DEBUG TRACE
|
|
624
|
+
print("\033[91;107m[DEBUG TRACE 5/6] Core cancel_active_response service executed.\033[0m")
|
|
625
|
+
|
|
626
|
+
# Cancel any active TTS streams (ElevenLabs)
|
|
627
|
+
try:
|
|
628
|
+
# Import here to avoid circular dependency
|
|
629
|
+
from mr_eleven_stream.mod import _active_tts_streams
|
|
630
|
+
for stream_id, stop_event in list(_active_tts_streams.items()):
|
|
631
|
+
stop_event.set()
|
|
632
|
+
logger.info(f"Cancelled TTS stream {stream_id}")
|
|
633
|
+
print("\033[91;107m[DEBUG TRACE 5.5/6] Cancelled active TTS stream.\033[0m")
|
|
634
|
+
except ImportError:
|
|
635
|
+
logger.debug("ElevenLabs TTS plugin not available for cancellation")
|
|
636
|
+
|
|
637
|
+
# Also, cancel any active command task (like speak())
|
|
638
|
+
if 'active_command_task' in context.data:
|
|
639
|
+
active_task = context.data['active_command_task']
|
|
640
|
+
if active_task and not active_task.done():
|
|
641
|
+
try:
|
|
642
|
+
active_task.cancel()
|
|
643
|
+
# DEBUG TRACE
|
|
644
|
+
print("\033[91;107m[DEBUG TRACE 6/6] Active command task found and cancelled.\033[0m")
|
|
645
|
+
print(f"Cancelled active command task for session {log_id}")
|
|
646
|
+
print(f"Removing last assistant message from chat log for session {log_id}")
|
|
647
|
+
await context.chat_log.drop_last('assistant')
|
|
648
|
+
|
|
649
|
+
except Exception as e:
|
|
650
|
+
print(f"Error cancelling active command task: {e}")
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
await context.save_context()
|
|
654
|
+
|
|
655
|
+
print(f"Cancelled active response for session {log_id}")
|
|
656
|
+
return {"status": "cancelled", "log_id": log_id}
|
|
657
|
+
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/* Import JetBrains Mono from Google Fonts */
|
|
2
|
+
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');
|
|
3
|
+
|
|
4
|
+
/* Base styles */
|
|
5
|
+
|
|
1
6
|
html, body {
|
|
2
7
|
background-color: #101020;
|
|
3
8
|
color: #f0f0f0;
|
|
@@ -16,7 +21,7 @@ input, * {
|
|
|
16
21
|
background-color: transparent;
|
|
17
22
|
color: #f0f0f0;
|
|
18
23
|
margin: 2px 2px;
|
|
19
|
-
font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, Helvetica, "Apple Color Emoji", Arial, "Segoe UI Emoji", "Segoe UI Symbol"
|
|
24
|
+
/*font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, Helvetica, "Apple Color Emoji", Arial, "Segoe UI Emoji", "Segoe UI Symbol";*/
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
p {
|
|
@@ -1020,3 +1025,87 @@ tbody tr {
|
|
|
1020
1025
|
.left-side {
|
|
1021
1026
|
overflow-y: auto;
|
|
1022
1027
|
}
|
|
1028
|
+
|
|
1029
|
+
/* Enhanced Shell/Terminal output styling */
|
|
1030
|
+
pre.shellout {
|
|
1031
|
+
background: linear-gradient(to bottom, #2d2d2d 0%, #1e1e1e 30px, #1a1a1a 100%);
|
|
1032
|
+
border: 1px solid #404040;
|
|
1033
|
+
border-radius: 12px;
|
|
1034
|
+
padding: 0;
|
|
1035
|
+
margin: 15px 0;
|
|
1036
|
+
overflow-x: auto;
|
|
1037
|
+
max-height: 50vh;
|
|
1038
|
+
overflow-y: auto;
|
|
1039
|
+
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4),
|
|
1040
|
+
0 0 0 1px rgba(255, 255, 255, 0.05) inset;
|
|
1041
|
+
position: relative;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/* Mock terminal title bar */
|
|
1045
|
+
pre.shellout::before {
|
|
1046
|
+
content: '';
|
|
1047
|
+
display: block;
|
|
1048
|
+
height: 30px;
|
|
1049
|
+
background: linear-gradient(to bottom, #3a3a3a, #2d2d2d);
|
|
1050
|
+
border-bottom: 1px solid #1a1a1a;
|
|
1051
|
+
border-radius: 12px 12px 0 0;
|
|
1052
|
+
position: sticky;
|
|
1053
|
+
top: 0;
|
|
1054
|
+
z-index: 1;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/* Terminal window controls (dots) */
|
|
1058
|
+
pre.shellout::after {
|
|
1059
|
+
content: '';
|
|
1060
|
+
position: absolute;
|
|
1061
|
+
top: 11px;
|
|
1062
|
+
left: 12px;
|
|
1063
|
+
width: 12px;
|
|
1064
|
+
height: 12px;
|
|
1065
|
+
background: #ff5f56;
|
|
1066
|
+
border-radius: 50%;
|
|
1067
|
+
box-shadow:
|
|
1068
|
+
20px 0 0 #ffbd2e,
|
|
1069
|
+
40px 0 0 #27c93f,
|
|
1070
|
+
0 0 0 1px rgba(0, 0, 0, 0.2);
|
|
1071
|
+
z-index: 2;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/* Code element inside shellout pre */
|
|
1075
|
+
pre.shellout code {
|
|
1076
|
+
background-color: transparent;
|
|
1077
|
+
color: #e8e8e8;
|
|
1078
|
+
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
1079
|
+
font-size: 14px;
|
|
1080
|
+
line-height: 1.6;
|
|
1081
|
+
padding: 15px 20px;
|
|
1082
|
+
padding-top: 10px;
|
|
1083
|
+
margin: 0;
|
|
1084
|
+
border: none;
|
|
1085
|
+
white-space: pre-wrap;
|
|
1086
|
+
display: block;
|
|
1087
|
+
font-weight: 400;
|
|
1088
|
+
letter-spacing: 0.02em;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/* Custom scrollbar for terminal */
|
|
1092
|
+
pre.shellout::-webkit-scrollbar {
|
|
1093
|
+
width: 10px;
|
|
1094
|
+
height: 10px;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
pre.shellout::-webkit-scrollbar-track {
|
|
1098
|
+
background: #1a1a1a;
|
|
1099
|
+
border-radius: 0 0 12px 0;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
pre.shellout::-webkit-scrollbar-thumb {
|
|
1103
|
+
background: #404040;
|
|
1104
|
+
border-radius: 5px;
|
|
1105
|
+
border: 2px solid #1a1a1a;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
pre.shellout::-webkit-scrollbar-thumb:hover {
|
|
1109
|
+
background: #4a4a4a;
|
|
1110
|
+
}
|
|
1111
|
+
|