ErisPulse 2.11.1.dev1__tar.gz → 2.11.2__tar.gz
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.
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/PKG-INFO +1 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/pyproject.toml +1 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/cli.py +24 -6
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/i18n/locales/en.py +2 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/i18n/locales/ja.py +2 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/i18n/locales/ru.py +2 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/i18n/locales/zh_cn.py +2 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/i18n/locales/zh_tw.py +2 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/utils/display.py +28 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/utils/interactive.py +16 -5
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/utils/scaffold_text.py +5 -5
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/adapter.py +5 -26
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/client.py +1 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/config_schema.py +5 -3
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/module.py +23 -5
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/storage.py +16 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/base.py +60 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/adapter.py +27 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/constants.py +10 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/i18n/locales/en.py +13 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/i18n/locales/ja.py +13 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/i18n/locales/ru.py +13 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/i18n/locales/zh_cn.py +13 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/i18n/locales/zh_tw.py +13 -1
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/master.py +29 -15
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/module.py +37 -5
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/ownership.py +21 -5
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/shadow.py +2 -2
- erispulse-2.11.2/src/ErisPulse/__main__.py +44 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/loaders/module.py +91 -8
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/__init__.py +12 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/context.py +58 -1
- erispulse-2.11.2/src/ErisPulse/runtime/resource_track.py +195 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/tasks.py +68 -3
- erispulse-2.11.1.dev1/src/ErisPulse/__main__.py +0 -24
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/.gitignore +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/LICENSE +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/README.pypi.md +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/base.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/config.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/create.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/doctor.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/init.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/install.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/language.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/list.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/list_remote.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/run.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/runtime.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/self_update.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/types.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/uninstall.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/upgrade.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/commands/version.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/console.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/constants.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/hints.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/i18n/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/i18n/locales/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/registry.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/utils/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/utils/config_wizard.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/utils/package_manager.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/CLI/utils/runtime_state.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/adapter_patterns.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/api_dsl.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/converter.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/errors.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/i18n_schema.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/kv_builder.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/manager.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/model.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/router.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/send_builder.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/send_rules.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/sql_base.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Bases/websocket.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/command.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/command_args.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/command_flow.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/conversation.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/governance.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/interaction.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/message.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/message_builder.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/meta.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/notice.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/overrides.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/request.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/session_type.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/throttle.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/trace.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/Event/wrapper.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/assets/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/assets/error.css +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/assets/error.html +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/assets/root.css +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/assets/root.html +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/client.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/config.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/connections.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/di.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/i18n/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/i18n/constants.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/i18n/locales/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/lifecycle.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/logger.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/router.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/scope.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/storage/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/storage/mysql.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/storage/postgres.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/storage/sqlite.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/text_match.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/Core/transcript.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/finders/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/finders/adapter.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/finders/bases/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/finders/bases/finder.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/finders/module.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/loaders/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/loaders/_reload_utils.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/loaders/adapter.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/loaders/bases/__init__.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/loaders/bases/loader.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/loaders/plugin_folder.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/loaders/strategy.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/loaders/strict.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/py.typed +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/config_schema.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/diagnostics.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/example_config.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/exceptions.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/file_watcher.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/frame_config.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/hints.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/kernel.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/memory.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/owner_cleanup.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/plugin_reload.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/proactive_gc.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/process_state.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/reload_ops.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/sdk_initializer.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/troubleshoot.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/runtime/version.py +0 -0
- {erispulse-2.11.1.dev1 → erispulse-2.11.2}/src/ErisPulse/sdk.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: ErisPulse
|
|
3
|
-
Version: 2.11.
|
|
3
|
+
Version: 2.11.2
|
|
4
4
|
Summary: Event-driven modular async bot framework — write once, deploy to any platform | 事件驱动的模块化异步机器人框架,一次编写,多平台部署
|
|
5
5
|
Project-URL: Homepage, https://github.com/ErisPulse/ErisPulse
|
|
6
6
|
Project-URL: Documentation, https://www.erisdev.com#docs
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ErisPulse"
|
|
7
|
-
version = "2.11.
|
|
7
|
+
version = "2.11.2"
|
|
8
8
|
description = "Event-driven modular async bot framework — write once, deploy to any platform | 事件驱动的模块化异步机器人框架,一次编写,多平台部署"
|
|
9
9
|
readme = "README.pypi.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -139,8 +139,13 @@ class CLI:
|
|
|
139
139
|
)
|
|
140
140
|
|
|
141
141
|
except ImportError as e:
|
|
142
|
+
# commands 包导入失败意味着所有命令都不可用——显著报错并给诊断线索,
|
|
143
|
+
# 而不是静默降级成"无命令可用的 CLI"(此前用户只会看到莫名空 help)
|
|
142
144
|
console.print(
|
|
143
|
-
f"[
|
|
145
|
+
f"[error]{i18n.t('cli.discover.import_failed', error=e)}[/]"
|
|
146
|
+
)
|
|
147
|
+
console.print(
|
|
148
|
+
f"[hint]{i18n.t('cli.discover.import_failed_hint')}[/]"
|
|
144
149
|
)
|
|
145
150
|
|
|
146
151
|
def _register_builtin_commands(self):
|
|
@@ -296,12 +301,25 @@ class CLI:
|
|
|
296
301
|
# 仅规范命令名作为建议候选(不含短别名/缩写,避免扰民)
|
|
297
302
|
canonical_names = self.registry.list_all()
|
|
298
303
|
|
|
299
|
-
# 从 sys.argv
|
|
304
|
+
# 从 sys.argv 中找到第一个非选项参数(即命令名);
|
|
305
|
+
# 跳过带值的选项(如 --lang zh),避免把选项值误判成命令
|
|
306
|
+
options_with_value = {"--lang", "--language"}
|
|
300
307
|
cmd = None
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
308
|
+
argv = sys.argv[1:]
|
|
309
|
+
i = 0
|
|
310
|
+
while i < len(argv):
|
|
311
|
+
arg = argv[i]
|
|
312
|
+
if arg in options_with_value:
|
|
313
|
+
i += 2
|
|
314
|
+
continue
|
|
315
|
+
if arg.startswith("-"):
|
|
316
|
+
# -h/-help/--help 是帮助请求,交给 argparse,不当作命令做拼写检查
|
|
317
|
+
if arg in ("-h", "-help", "--help"):
|
|
318
|
+
return
|
|
319
|
+
i += 1
|
|
320
|
+
continue
|
|
321
|
+
cmd = arg
|
|
322
|
+
break
|
|
305
323
|
|
|
306
324
|
if not cmd or cmd in all_valid:
|
|
307
325
|
return
|
|
@@ -39,6 +39,7 @@ TRANSLATIONS = {
|
|
|
39
39
|
"cli.discover.instantiate_failed": "Failed to instantiate command {name}: {error}",
|
|
40
40
|
"cli.discover.load_failed": "Failed to load command module {name}: {error}",
|
|
41
41
|
"cli.discover.import_failed": "Cannot import commands package: {error}",
|
|
42
|
+
"cli.discover.import_failed_hint": "Check your Python environment and ErisPulse installation (pip install -U ErisPulse), or run epsdk doctor",
|
|
42
43
|
# ==================== create command ====================
|
|
43
44
|
"cli.create.description": "Create Module / Adapter project scaffold",
|
|
44
45
|
"cli.create.type_help": "Creation type: module / adapter / pack (plugin to project)",
|
|
@@ -511,7 +512,7 @@ TRANSLATIONS = {
|
|
|
511
512
|
"cli.package.alias_mapping": " Alias mapping: {alias} → {package}",
|
|
512
513
|
"cli.package.installed_package_found": " Found installed package: {package}",
|
|
513
514
|
"cli.package.uninstall_alias_not_found": " No alias found, attempting direct uninstall: {package}",
|
|
514
|
-
"cli.package.confirm_uninstall": "
|
|
515
|
+
"cli.package.confirm_uninstall": "Uninstall the following packages? (press Enter = cancel)\n{packages}",
|
|
515
516
|
"cli.package.operation_cancelled": " Operation cancelled",
|
|
516
517
|
"cli.package.uninstalling": "Uninstalling {package}",
|
|
517
518
|
"cli.package.uninstall_success": "[OK] Package {package} uninstalled successfully",
|
|
@@ -39,6 +39,7 @@ TRANSLATIONS = {
|
|
|
39
39
|
"cli.discover.instantiate_failed": "コマンド {name} のインスタンス化に失敗: {error}",
|
|
40
40
|
"cli.discover.load_failed": "コマンドモジュール {name} の読み込みに失敗: {error}",
|
|
41
41
|
"cli.discover.import_failed": "commands パッケージをインポートできません: {error}",
|
|
42
|
+
"cli.discover.import_failed_hint": "Python 環境と ErisPulse のインストールを確認してください(pip install -U ErisPulse)。epsdk doctor で診断もできます",
|
|
42
43
|
# ==================== create コマンド ====================
|
|
43
44
|
"cli.create.description": "Module / Adapter プロジェクトのスキャフォールドを作成",
|
|
44
45
|
"cli.create.type_help": "作成タイプ: module / adapter / pack(プラグインをプロジェクトへ)",
|
|
@@ -511,7 +512,7 @@ TRANSLATIONS = {
|
|
|
511
512
|
"cli.package.alias_mapping": " エイリアスマッピング: {alias} → {package}",
|
|
512
513
|
"cli.package.installed_package_found": " インストール済みパッケージが見つかりました: {package}",
|
|
513
514
|
"cli.package.uninstall_alias_not_found": " エイリアスが見つかりません。直接アンインストールを試みます: {package}",
|
|
514
|
-
"cli.package.confirm_uninstall": "
|
|
515
|
+
"cli.package.confirm_uninstall": "以下のパッケージをアンインストールしますか?(Enter でキャンセル)\n{packages}",
|
|
515
516
|
"cli.package.operation_cancelled": " 操作がキャンセルされました",
|
|
516
517
|
"cli.package.uninstalling": "アンインストール中 {package}",
|
|
517
518
|
"cli.package.uninstall_success": "[OK] パッケージ {package} のアンインストールに成功しました",
|
|
@@ -39,6 +39,7 @@ TRANSLATIONS = {
|
|
|
39
39
|
"cli.discover.instantiate_failed": "Не удалось создать экземпляр команды {name}: {error}",
|
|
40
40
|
"cli.discover.load_failed": "Не удалось загрузить модуль команды {name}: {error}",
|
|
41
41
|
"cli.discover.import_failed": "Невозможно импортировать пакет commands: {error}",
|
|
42
|
+
"cli.discover.import_failed_hint": "Проверьте окружение Python и целостность установки ErisPulse (pip install -U ErisPulse) или запустите epsdk doctor",
|
|
42
43
|
# ==================== команда create ====================
|
|
43
44
|
"cli.create.description": "Создать каркас проекта Module / Adapter",
|
|
44
45
|
"cli.create.type_help": "Тип создания: module / adapter / pack (плагин в проект)",
|
|
@@ -511,7 +512,7 @@ TRANSLATIONS = {
|
|
|
511
512
|
"cli.package.alias_mapping": " Сопоставление псевдонима: {alias} → {package}",
|
|
512
513
|
"cli.package.installed_package_found": " Найден установленный пакет: {package}",
|
|
513
514
|
"cli.package.uninstall_alias_not_found": " Псевдоним не найден, попытка прямого удаления: {package}",
|
|
514
|
-
"cli.package.confirm_uninstall": "
|
|
515
|
+
"cli.package.confirm_uninstall": "Удалить следующие пакеты? (Enter — отмена)\n{packages}",
|
|
515
516
|
"cli.package.operation_cancelled": " Операция отменена",
|
|
516
517
|
"cli.package.uninstalling": "Удаление {package}",
|
|
517
518
|
"cli.package.uninstall_success": "[OK] Пакет {package} успешно удалён",
|
|
@@ -39,6 +39,7 @@ TRANSLATIONS = {
|
|
|
39
39
|
"cli.discover.instantiate_failed": "实例化命令 {name} 失败: {error}",
|
|
40
40
|
"cli.discover.load_failed": "加载命令模块 {name} 失败: {error}",
|
|
41
41
|
"cli.discover.import_failed": "无法导入 commands 包: {error}",
|
|
42
|
+
"cli.discover.import_failed_hint": "检查 Python 环境与 ErisPulse 安装完整性(pip install -U ErisPulse),或运行 epsdk doctor 诊断",
|
|
42
43
|
# ==================== create 命令 ====================
|
|
43
44
|
"cli.create.description": "创建 Module / Adapter 项目脚手架",
|
|
44
45
|
"cli.create.type_help": "创建类型: module / adapter / pack(插件转项目)",
|
|
@@ -511,7 +512,7 @@ TRANSLATIONS = {
|
|
|
511
512
|
"cli.package.alias_mapping": " 别名映射: {alias} → {package}",
|
|
512
513
|
"cli.package.installed_package_found": " 找到已安装包: {package}",
|
|
513
514
|
"cli.package.uninstall_alias_not_found": " 未找到别名,将尝试直接卸载: {package}",
|
|
514
|
-
"cli.package.confirm_uninstall": "
|
|
515
|
+
"cli.package.confirm_uninstall": "确认卸载以下包吗?(直接回车 = 取消,不卸载)\n{packages}",
|
|
515
516
|
"cli.package.operation_cancelled": " 操作已取消",
|
|
516
517
|
"cli.package.uninstalling": "卸载 {package}",
|
|
517
518
|
"cli.package.uninstall_success": "[OK] 包 {package} 卸载成功",
|
|
@@ -39,6 +39,7 @@ TRANSLATIONS = {
|
|
|
39
39
|
"cli.discover.instantiate_failed": "實例化命令 {name} 失敗: {error}",
|
|
40
40
|
"cli.discover.load_failed": "載入命令模組 {name} 失敗: {error}",
|
|
41
41
|
"cli.discover.import_failed": "無法匯入 commands 套件: {error}",
|
|
42
|
+
"cli.discover.import_failed_hint": "檢查 Python 環境與 ErisPulse 安裝完整性(pip install -U ErisPulse),或執行 epsdk doctor 診斷",
|
|
42
43
|
# ==================== create 命令 ====================
|
|
43
44
|
"cli.create.description": "建立 Module / Adapter 專案脚手架",
|
|
44
45
|
"cli.create.type_help": "建立類型: module / adapter / pack(插件轉專案)",
|
|
@@ -511,7 +512,7 @@ TRANSLATIONS = {
|
|
|
511
512
|
"cli.package.alias_mapping": " 別名對映: {alias} → {package}",
|
|
512
513
|
"cli.package.installed_package_found": " 找到已安裝包: {package}",
|
|
513
514
|
"cli.package.uninstall_alias_not_found": " 未找到別名,將嘗試直接解除安裝: {package}",
|
|
514
|
-
"cli.package.confirm_uninstall": "
|
|
515
|
+
"cli.package.confirm_uninstall": "確認解除安裝以下包嗎?(直接 Enter = 取消,不解除安裝)\n{packages}",
|
|
515
516
|
"cli.package.operation_cancelled": " 操作已取消",
|
|
516
517
|
"cli.package.uninstalling": "解除安裝 {package}",
|
|
517
518
|
"cli.package.uninstall_success": "[OK] 包 {package} 解除安裝成功",
|
|
@@ -39,6 +39,34 @@ def _page_size() -> int:
|
|
|
39
39
|
return max(_terminal_height() - 6, 5)
|
|
40
40
|
|
|
41
41
|
|
|
42
|
+
def _flush_stdin_buffer() -> None:
|
|
43
|
+
"""清空 stdin 缓冲中已积压的按键(用户在耗时操作期间连敲的回车/数字)。
|
|
44
|
+
|
|
45
|
+
不清掉的话,这些残留输入会被紧随其后的 Confirm/Prompt 一次性吞掉:
|
|
46
|
+
用户只是想让表格快点出来,结果"替自己确认了卸载"。Windows 走 msvcrt,
|
|
47
|
+
POSIX 走 termios+select;任何失败静默跳过(能力探测,绝不因此报错)。
|
|
48
|
+
"""
|
|
49
|
+
try:
|
|
50
|
+
import sys as _sys
|
|
51
|
+
|
|
52
|
+
if not _sys.stdin or not hasattr(_sys.stdin, "isatty") or not _sys.stdin.isatty():
|
|
53
|
+
return
|
|
54
|
+
if _sys.platform == "win32":
|
|
55
|
+
import msvcrt
|
|
56
|
+
|
|
57
|
+
while msvcrt.kbhit():
|
|
58
|
+
msvcrt.getwch()
|
|
59
|
+
else:
|
|
60
|
+
import select
|
|
61
|
+
import termios
|
|
62
|
+
|
|
63
|
+
while select.select([_sys.stdin], [], [], 0)[0]:
|
|
64
|
+
termios.tcflush(_sys.stdin, termios.TCIFLUSH)
|
|
65
|
+
break
|
|
66
|
+
except Exception:
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
|
|
42
70
|
def _input(prompt_label: str = ">") -> str:
|
|
43
71
|
"""
|
|
44
72
|
读取用户输入,遇到EOF或中断时返回 "q"
|
|
@@ -81,23 +81,34 @@ def _require_interactive() -> None:
|
|
|
81
81
|
raise NonInteractiveError(i18n.t("cli.interactive.non_tty"))
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
def confirm(message: str, *, default: bool = False, **kwargs) -> bool:
|
|
84
|
+
def confirm(message: str, *, default: bool = False, show_default: bool = True, **kwargs) -> bool:
|
|
85
85
|
"""
|
|
86
86
|
yes/no 确认提示(统一入口)
|
|
87
87
|
|
|
88
88
|
assume-yes 模式(``--yes/-y``)下直接返回 True;非 TTY 且未启用
|
|
89
89
|
assume-yes 时抛出 :class:`NonInteractiveError`。
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
体验护栏(坑 6 反馈):调用前清空 stdin 缓冲——耗时表格/安装过程中
|
|
92
|
+
用户连敲的回车不会残留到本确认被一次吞掉(默认 N 时表现为"莫名取消");
|
|
93
|
+
提示文案自动带 ``(Y/n)`` / ``(y/N)`` 后缀,回车默认值一眼可见。
|
|
94
|
+
|
|
95
|
+
:param message: [str] 文案(可含 Rich 标记)
|
|
96
|
+
:param default: [bool] 用户直接回车时的默认取值
|
|
97
|
+
:param show_default: [bool] 是否在提示中显示默认值(默认 True)
|
|
93
98
|
:param kwargs: 其余参数透传 rich Confirm.ask
|
|
94
|
-
:return: 用户是否确认
|
|
99
|
+
:return: [bool] 用户是否确认
|
|
95
100
|
:raises NonInteractiveError: 非交互环境且未启用 ``--yes/-y``
|
|
96
101
|
"""
|
|
97
102
|
if _ASSUME_YES:
|
|
98
103
|
return True
|
|
99
104
|
_require_interactive()
|
|
100
|
-
|
|
105
|
+
try:
|
|
106
|
+
from .display import _flush_stdin_buffer
|
|
107
|
+
|
|
108
|
+
_flush_stdin_buffer()
|
|
109
|
+
except Exception:
|
|
110
|
+
pass
|
|
111
|
+
return Confirm.ask(message, default=default, show_default=show_default, **kwargs)
|
|
101
112
|
|
|
102
113
|
|
|
103
114
|
def select(
|
|
@@ -35,7 +35,7 @@ _EN_FALLBACK: dict[str, str] = {
|
|
|
35
35
|
"them. Keys referenced by config description / command help must be declared here.",
|
|
36
36
|
"module.config_updated_doc": "Called when module config hot-reloads",
|
|
37
37
|
"module.on_load_doc": "Called when the module is loaded",
|
|
38
|
-
"module.on_unload_doc": "Called when the module is unloaded",
|
|
38
|
+
"module.on_unload_doc": "Called when the module is unloaded (event['reason'] tells why: unload / reload / disable / cascade / dormant / load-failed)",
|
|
39
39
|
"module.log.init_done": "{name} initialized",
|
|
40
40
|
"module.log.loaded": "Module loaded: {event}",
|
|
41
41
|
"module.log.unloaded": "Module unloaded: {event}",
|
|
@@ -195,7 +195,7 @@ _TRANSLATIONS: dict[str, dict[str, str]] = {
|
|
|
195
195
|
"module.i18n_hint": "I18nClass 声明翻译键,框架自动注册;配置描述/命令帮助引用的键必须在此声明。",
|
|
196
196
|
"module.config_updated_doc": "模块配置热更新时调用",
|
|
197
197
|
"module.on_load_doc": "模块被加载时调用",
|
|
198
|
-
"module.on_unload_doc": "
|
|
198
|
+
"module.on_unload_doc": "模块被卸载时调用(event['reason'] 标明来意:unload / reload / disable / cascade / dormant / load-failed)",
|
|
199
199
|
"module.log.init_done": "{name} 初始化完成",
|
|
200
200
|
"module.log.loaded": "模块已加载: {event}",
|
|
201
201
|
"module.log.unloaded": "模块已卸载: {event}",
|
|
@@ -327,7 +327,7 @@ _TRANSLATIONS: dict[str, dict[str, str]] = {
|
|
|
327
327
|
"module.i18n_hint": "I18nClass 宣告翻譯鍵,框架自動註冊;設定描述/命令說明引用的鍵必須在此宣告。",
|
|
328
328
|
"module.config_updated_doc": "模組設定熱更新時呼叫",
|
|
329
329
|
"module.on_load_doc": "模組被載入時呼叫",
|
|
330
|
-
"module.on_unload_doc": "
|
|
330
|
+
"module.on_unload_doc": "模組被卸載時呼叫(event['reason'] 標明來意:unload / reload / disable / cascade / dormant / load-failed)",
|
|
331
331
|
"module.log.init_done": "{name} 初始化完成",
|
|
332
332
|
"module.log.loaded": "模組已載入: {event}",
|
|
333
333
|
"module.log.unloaded": "模組已卸載: {event}",
|
|
@@ -395,7 +395,7 @@ _TRANSLATIONS: dict[str, dict[str, str]] = {
|
|
|
395
395
|
"module.i18n_hint": "I18nClass で翻訳キーを宣言すると自動登録されます。設定説明/コマンドヘルプで参照するキーはここで宣言してください。",
|
|
396
396
|
"module.config_updated_doc": "モジュール設定のホットリロード時に呼び出されます",
|
|
397
397
|
"module.on_load_doc": "モジュール読み込み時に呼び出されます",
|
|
398
|
-
"module.on_unload_doc": "
|
|
398
|
+
"module.on_unload_doc": "モジュールアンロード時に呼び出されます(event['reason'] に理由:unload / reload / disable / cascade / dormant / load-failed)",
|
|
399
399
|
"module.log.init_done": "{name} の初期化が完了しました",
|
|
400
400
|
"module.log.loaded": "モジュールをロードしました: {event}",
|
|
401
401
|
"module.log.unloaded": "モジュールをアンロードしました: {event}",
|
|
@@ -464,7 +464,7 @@ _TRANSLATIONS: dict[str, dict[str, str]] = {
|
|
|
464
464
|
"module.i18n_hint": "Ключи переводов объявляются в I18nClass и регистрируются автоматически; ключи из описания/справки должны быть здесь.",
|
|
465
465
|
"module.config_updated_doc": "Вызывается при горячей перезагрузке конфигурации",
|
|
466
466
|
"module.on_load_doc": "Вызывается при загрузке модуля",
|
|
467
|
-
"module.on_unload_doc": "Вызывается при выгрузке модуля",
|
|
467
|
+
"module.on_unload_doc": "Вызывается при выгрузке модуля (event['reason'] указывает причину: unload / reload / disable / cascade / dormant / load-failed)",
|
|
468
468
|
"module.log.init_done": "{name} инициализирован",
|
|
469
469
|
"module.log.loaded": "Модуль загружен: {event}",
|
|
470
470
|
"module.log.unloaded": "Модуль выгружен: {event}",
|
|
@@ -1448,7 +1448,8 @@ class BaseAdapter(ABC):
|
|
|
1448
1448
|
if custom_cfg is not None:
|
|
1449
1449
|
self._config_instance = custom_cfg
|
|
1450
1450
|
if self.AccountConfigClass is not None:
|
|
1451
|
-
|
|
1451
|
+
# 不自动生成 "default" 账户:未添加账户时 accounts 为空字典,
|
|
1452
|
+
# 由用户在 Dashboard 账户向导中自行创建(避免默认连接静默建立)
|
|
1452
1453
|
# 向后兼容:子类可覆写 _load_accounts() 实现自定义加载
|
|
1453
1454
|
custom = self._load_accounts()
|
|
1454
1455
|
if custom is not None:
|
|
@@ -1585,11 +1586,9 @@ class BaseAdapter(ABC):
|
|
|
1585
1586
|
from .config_schema import dict_to_dataclass, validate_config
|
|
1586
1587
|
|
|
1587
1588
|
key = f"{self._get_config_key()}.accounts"
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
self._ensure_accounts_exist()
|
|
1592
|
-
data = config_mgr.getConfig(key) or {}
|
|
1589
|
+
# 未创建任何账户时返回空字典:账户由用户在 Dashboard 向导中自行添加,
|
|
1590
|
+
# 不再自动生成 "default" 账户模板(避免默认配置静默建立连接)
|
|
1591
|
+
data = config_mgr.getConfig(key) or {}
|
|
1593
1592
|
|
|
1594
1593
|
accounts = {}
|
|
1595
1594
|
for name, account_data in data.items():
|
|
@@ -1741,26 +1740,6 @@ class BaseAdapter(ABC):
|
|
|
1741
1740
|
exc_info=True,
|
|
1742
1741
|
)
|
|
1743
1742
|
|
|
1744
|
-
def _ensure_accounts_exist(self):
|
|
1745
|
-
"""
|
|
1746
|
-
确保多账户配置模板存在,不存在则生成默认账户配置
|
|
1747
|
-
|
|
1748
|
-
{!--< internal-use >!--}
|
|
1749
|
-
{!--< /internal-use >!--}
|
|
1750
|
-
"""
|
|
1751
|
-
if self.AccountConfigClass is None:
|
|
1752
|
-
return
|
|
1753
|
-
from .config_schema import dataclass_to_defaults_dict
|
|
1754
|
-
|
|
1755
|
-
key = f"{self._get_config_key()}.accounts"
|
|
1756
|
-
data = config_mgr.getConfig(key)
|
|
1757
|
-
|
|
1758
|
-
if data is None:
|
|
1759
|
-
default_account = dataclass_to_defaults_dict(self.AccountConfigClass)
|
|
1760
|
-
data = {"default": default_account}
|
|
1761
|
-
config_mgr.setConfig(key, data, immediate=True)
|
|
1762
|
-
self._get_logger().info(i18n.t("core.adapter.account_config_generated", key=key))
|
|
1763
|
-
|
|
1764
1743
|
def _resolve_account(self, account_id: str | None = None) -> tuple:
|
|
1765
1744
|
"""
|
|
1766
1745
|
解析目标账户
|
|
@@ -1058,9 +1058,11 @@ def _schema_fields(config_class: type) -> dict:
|
|
|
1058
1058
|
def _apply_ui_meta(field_schema: dict, ui_meta: dict) -> None:
|
|
1059
1059
|
"""{!--< internal-use >!--} 将 UI 元数据合并进字段 schema
|
|
1060
1060
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1061
|
+
键集合以框架规范《配置与 UI 元数据》为准
|
|
1062
|
+
(docs/zh-CN/developer-guide/configuration.md):widget / group / order /
|
|
1063
|
+
options / placeholder / min / max / step / rows / show_if / disabled_if /
|
|
1064
|
+
value_type / item。框架原样透传,语义(控件行为、值形态、条件算子、
|
|
1065
|
+
兼容性契约)由规范定义,消费方(Dashboard 等)实现。
|
|
1064
1066
|
"""
|
|
1065
1067
|
_UI_META_PASSTHROUGH_KEYS = (
|
|
1066
1068
|
"widget",
|
|
@@ -4,9 +4,16 @@ ErisPulse 模块基础模块
|
|
|
4
4
|
提供模块基类定义和标准接口
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
7
9
|
from abc import ABC, abstractmethod
|
|
8
10
|
from dataclasses import asdict, dataclass, field
|
|
9
|
-
from typing import Any, TypedDict
|
|
11
|
+
from typing import TYPE_CHECKING, Any, TypedDict
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
# NotRequired 仅在 3.11+ 的 typing 提供,3.10 需 typing_extensions 兜底;
|
|
15
|
+
# 本模块启用 PEP 563(字符串注解),运行时不解析该名字
|
|
16
|
+
from typing_extensions import NotRequired
|
|
10
17
|
|
|
11
18
|
from ...loaders.strategy import ModuleLoadStrategy
|
|
12
19
|
from ..config import config as config_mgr
|
|
@@ -50,7 +57,7 @@ class ModuleMeta:
|
|
|
50
57
|
group: str | None = None
|
|
51
58
|
tags: list[str] = field(default_factory=list)
|
|
52
59
|
commands: list[str] | None = None
|
|
53
|
-
services:
|
|
60
|
+
services: list[str | dict[str, Any]] | None = None
|
|
54
61
|
min_sdk_version: str | None = None
|
|
55
62
|
|
|
56
63
|
def to_dict(self) -> dict[str, Any]:
|
|
@@ -67,8 +74,12 @@ class ModuleEvent(TypedDict):
|
|
|
67
74
|
on_load / on_unload 事件数据
|
|
68
75
|
|
|
69
76
|
:ivar module_name: str 模块名称
|
|
77
|
+
:ivar reason: str 卸载来意,仅 on_unload 提供;``"unload"`` / ``"reload"`` /
|
|
78
|
+
``"disable"`` / ``"cascade"`` / ``"dormant"`` / ``"load-failed"`` /
|
|
79
|
+
``"rollback"``(``"rollback"`` 为热重载回滚后重放 on_load 的事件来意)
|
|
70
80
|
"""
|
|
71
81
|
module_name: str
|
|
82
|
+
reason: NotRequired[str]
|
|
72
83
|
|
|
73
84
|
|
|
74
85
|
class BaseModule(ABC):
|
|
@@ -91,7 +102,7 @@ class BaseModule(ABC):
|
|
|
91
102
|
I18nClass: type | None = None
|
|
92
103
|
|
|
93
104
|
@staticmethod
|
|
94
|
-
def get_meta() ->
|
|
105
|
+
def get_meta() -> ModuleMeta | dict[str, Any]:
|
|
95
106
|
"""
|
|
96
107
|
获取模块介绍元信息(描述这个模块是什么、属于哪一类等)
|
|
97
108
|
|
|
@@ -237,7 +248,14 @@ class BaseModule(ABC):
|
|
|
237
248
|
|
|
238
249
|
{!--< tips >!--}
|
|
239
250
|
其中,event事件内容为:
|
|
240
|
-
`{ "module_name": "模块名" }`
|
|
251
|
+
`{ "module_name": "模块名", "reason": "卸载来意" }`
|
|
252
|
+
|
|
253
|
+
reason 取值:``unload``(常规卸载)/ ``reload``(热重载,失败会回滚并
|
|
254
|
+
重放 on_load)/ ``disable``(禁用)/ ``cascade``(依赖级联)/
|
|
255
|
+
``dormant``(归眠)/ ``load-failed``(加载失败半卸载)。
|
|
256
|
+
|
|
257
|
+
需要跨重载存活的资源(连接池等)可据此区分来意:``reload`` 时可
|
|
258
|
+
推迟关闭,交由归属清理链或回滚重放兜底。
|
|
241
259
|
{!--< /tips >!--}
|
|
242
260
|
"""
|
|
243
261
|
raise NotImplementedError
|
|
@@ -271,7 +289,7 @@ class BaseModule(ABC):
|
|
|
271
289
|
return spawn_background(coro, owner=self._get_config_key())
|
|
272
290
|
|
|
273
291
|
@property
|
|
274
|
-
def state(self) ->
|
|
292
|
+
def state(self) -> BaseModule.ModuleState:
|
|
275
293
|
"""
|
|
276
294
|
模块级持久化状态(storage 的命名空间视图)
|
|
277
295
|
|
|
@@ -95,6 +95,22 @@ class AsyncBridge:
|
|
|
95
95
|
"""{!--< internal-use >!--} 桥接线程入口:启动常驻事件循环"""
|
|
96
96
|
self._loop = asyncio.new_event_loop()
|
|
97
97
|
asyncio.set_event_loop(self._loop)
|
|
98
|
+
# 桥接循环同样安装 owner 感知任务工厂:同步 API 经
|
|
99
|
+
# run_coroutine_threadsafe 携带的 owner 上下文在本循环内派生的
|
|
100
|
+
# 任务自动归属、卸载兜底取消——消除主循环外任务绕过归属表的
|
|
101
|
+
# 盲区(热重载跨 loop 残留的根因之一)。懒导入规避 Core.Bases
|
|
102
|
+
# 早期加载链与 runtime 包的循环引用;失败不阻塞桥接启动。
|
|
103
|
+
try:
|
|
104
|
+
from ...runtime.tasks import install_owner_task_factory
|
|
105
|
+
|
|
106
|
+
install_owner_task_factory(self._loop)
|
|
107
|
+
except Exception as e:
|
|
108
|
+
try:
|
|
109
|
+
from ..logger import logger
|
|
110
|
+
|
|
111
|
+
logger.warning(i18n.t("core.storage.bridge_factory_failed", error=e))
|
|
112
|
+
except Exception:
|
|
113
|
+
pass
|
|
98
114
|
self._ready.set()
|
|
99
115
|
try:
|
|
100
116
|
self._loop.run_forever()
|
|
@@ -367,6 +367,64 @@ class BaseEventHandler:
|
|
|
367
367
|
|
|
368
368
|
return decorator
|
|
369
369
|
|
|
370
|
+
def _bus_has_self(self) -> bool | None:
|
|
371
|
+
"""检查适配器总线上是否已挂本分发器;无法判定时返回 None。
|
|
372
|
+
|
|
373
|
+
adapter.on 的 wrapper 是 functools.wraps(_process_event) 的闭包:
|
|
374
|
+
__wrapped__ 与闭包 cell 都指向绑定方法,绑定方法 __func__ 即
|
|
375
|
+
self._process_event(未绑定函数对象)。
|
|
376
|
+
"""
|
|
377
|
+
try:
|
|
378
|
+
handlers = adapter._onebot_handlers.get(self.event_type) or []
|
|
379
|
+
except Exception:
|
|
380
|
+
return None
|
|
381
|
+
# _process_event 是绑定方法:每次属性访问生成新对象,is 比较必失败;
|
|
382
|
+
# 绑定方法对「同一实例 + 同一底层函数」相等(==),据此比对
|
|
383
|
+
target = self._process_event
|
|
384
|
+
for wrapper in handlers:
|
|
385
|
+
func = wrapper.get("func") if isinstance(wrapper, dict) else wrapper
|
|
386
|
+
if func is None:
|
|
387
|
+
continue
|
|
388
|
+
if func == target:
|
|
389
|
+
return True
|
|
390
|
+
wrapped = getattr(func, "__wrapped__", None)
|
|
391
|
+
if wrapped == target:
|
|
392
|
+
return True
|
|
393
|
+
for cell in getattr(func, "__closure__", None) or ():
|
|
394
|
+
if getattr(cell, "cell_contents", None) == target:
|
|
395
|
+
return True
|
|
396
|
+
return False
|
|
397
|
+
|
|
398
|
+
def ensure_bus_link(self) -> bool:
|
|
399
|
+
"""
|
|
400
|
+
开机自检自愈:WS 重连走适配器 shutdown 时总线被清空,
|
|
401
|
+
但本标记仍是 True、模块处理器列表非空——总线空了却无人重新挂载,
|
|
402
|
+
notice 等事件从此永久失聪(此前只有整机重启才会自愈)。
|
|
403
|
+
|
|
404
|
+
自检"有处理器但总线无本分发器"即重新挂载并返回 True(发生过自愈)。
|
|
405
|
+
开销:一次布尔判断 + 标记为真时的一次总线查表;在 _process_event 入口
|
|
406
|
+
与适配器 start 后调用均可。
|
|
407
|
+
"""
|
|
408
|
+
if not self.handlers or not self.event_type:
|
|
409
|
+
return False
|
|
410
|
+
if not self._linked_to_adapter_bus:
|
|
411
|
+
return self._ensure_bus_link_force()
|
|
412
|
+
state = self._bus_has_self()
|
|
413
|
+
if state is False:
|
|
414
|
+
return self._ensure_bus_link_force()
|
|
415
|
+
return False
|
|
416
|
+
|
|
417
|
+
def _ensure_bus_link_force(self) -> bool:
|
|
418
|
+
try:
|
|
419
|
+
adapter.on(self.event_type, scope_exempt=True)(self._process_event)
|
|
420
|
+
except Exception:
|
|
421
|
+
return False
|
|
422
|
+
self._linked_to_adapter_bus = True
|
|
423
|
+
logger.warning(
|
|
424
|
+
i18n.t("core.event.bus_link_restored", event_type=self.event_type)
|
|
425
|
+
)
|
|
426
|
+
return True
|
|
427
|
+
|
|
370
428
|
async def _process_event(self, event: dict[str, Any]):
|
|
371
429
|
"""
|
|
372
430
|
处理事件
|
|
@@ -377,6 +435,8 @@ class BaseEventHandler:
|
|
|
377
435
|
|
|
378
436
|
:param event: 事件数据
|
|
379
437
|
"""
|
|
438
|
+
# 自检自愈:总线被清空而标记未重置的场景,本调用点兜底恢复
|
|
439
|
+
self.ensure_bus_link()
|
|
380
440
|
if not isinstance(event, Event):
|
|
381
441
|
event = Event(event)
|
|
382
442
|
|
|
@@ -662,6 +662,21 @@ class AdapterManager(ManagerBase):
|
|
|
662
662
|
current_owner.reset(token)
|
|
663
663
|
self._started_instances.add(adapter)
|
|
664
664
|
|
|
665
|
+
# 自检自愈:start/shutdown 循环可能清空事件总线而
|
|
666
|
+
# Event 层的 _linked_to_adapter_bus 仍是 True(残留),
|
|
667
|
+
# 适配器重启后通知类事件将永久失聪。此处主动触发
|
|
668
|
+
# Event 层自检(内部有幂等保护),不依赖下一条事件才暴露
|
|
669
|
+
try:
|
|
670
|
+
from .Event import message as _ev_message
|
|
671
|
+
from .Event import meta as _ev_meta
|
|
672
|
+
from .Event import notice as _ev_notice
|
|
673
|
+
from .Event import request as _ev_request
|
|
674
|
+
|
|
675
|
+
for _handler in (_ev_message.handler, _ev_notice.handler, _ev_request.handler, _ev_meta.handler):
|
|
676
|
+
_handler.ensure_bus_link()
|
|
677
|
+
except Exception:
|
|
678
|
+
pass
|
|
679
|
+
|
|
665
680
|
# 提交适配器状态变化事件(started)
|
|
666
681
|
await lifecycle.submit_event(
|
|
667
682
|
"adapter.status.change",
|
|
@@ -1199,6 +1214,18 @@ class AdapterManager(ManagerBase):
|
|
|
1199
1214
|
current_owner.reset(token)
|
|
1200
1215
|
self._started_instances.add(adapter_instance)
|
|
1201
1216
|
|
|
1217
|
+
# 自检自愈(restart 路径):同主启动路径,总线被清空后主动重挂
|
|
1218
|
+
try:
|
|
1219
|
+
from .Event import message as _ev_message
|
|
1220
|
+
from .Event import meta as _ev_meta
|
|
1221
|
+
from .Event import notice as _ev_notice
|
|
1222
|
+
from .Event import request as _ev_request
|
|
1223
|
+
|
|
1224
|
+
for _handler in (_ev_message.handler, _ev_notice.handler, _ev_request.handler, _ev_meta.handler):
|
|
1225
|
+
_handler.ensure_bus_link()
|
|
1226
|
+
except Exception:
|
|
1227
|
+
pass
|
|
1228
|
+
|
|
1202
1229
|
await lifecycle.submit_event(
|
|
1203
1230
|
"adapter.status.change",
|
|
1204
1231
|
msg=i18n.t("core.adapter.state_started", platform=platform),
|
|
@@ -118,6 +118,7 @@ CONFIG_KEY_ROUTER_CORS: Final[str] = "ErisPulse.router.cors"
|
|
|
118
118
|
# 修改影响: 安全响应头配置的读取路径。
|
|
119
119
|
CONFIG_KEY_ROUTER_SECURITY: Final[str] = "ErisPulse.router.security"
|
|
120
120
|
|
|
121
|
+
|
|
121
122
|
# ==============================================================================
|
|
122
123
|
# 配置管理器
|
|
123
124
|
#
|
|
@@ -448,6 +449,7 @@ DEFAULT_EVENT_SOURCE: Final[str] = "ErisPulse"
|
|
|
448
449
|
# 改名只需动这里,但仍需同步文档(advanced/lifecycle.md)。
|
|
449
450
|
EVENT_CORE_INIT_STAGE: Final[str] = "core.init.stage"
|
|
450
451
|
EVENT_MODULE_RELOAD: Final[str] = "module.reload"
|
|
452
|
+
EVENT_MODULE_ROLLBACK: Final[str] = "module.rollback"
|
|
451
453
|
EVENT_ADAPTER_RELOAD: Final[str] = "adapter.reload"
|
|
452
454
|
EVENT_STORAGE_READY: Final[str] = "storage.ready"
|
|
453
455
|
EVENT_STORAGE_UNREACHABLE: Final[str] = "storage.unreachable"
|
|
@@ -1218,6 +1220,12 @@ DEFAULT_OWNER_CANCEL_TIMEOUT_SECS: Final[float] = 5.0
|
|
|
1218
1220
|
# 修改影响: 设大容忍慢清理(拖长卸载流程),设小加速卸载(超时钩子被放弃并告警)。
|
|
1219
1221
|
CLEANUP_CALLBACK_TIMEOUT_SECS: Final[float] = 10.0
|
|
1220
1222
|
|
|
1223
|
+
# 合作式登记资源(ownership.track)中单个异步 release() 的执行超时(秒)。
|
|
1224
|
+
# 使用位置: runtime/resource_track.py(release_owner_tracked 释放归属资源时,
|
|
1225
|
+
# 对返回 awaitable 的 release() 施加 wait_for 超时保护)。
|
|
1226
|
+
# 修改影响: 设大容忍慢释放(拖长卸载/重载流程),设小加速回收(超时资源被放弃并告警)。
|
|
1227
|
+
TRACKED_RELEASE_TIMEOUT_SECS: Final[float] = 10.0
|
|
1228
|
+
|
|
1221
1229
|
# 模块注册来源标识:本地插件文件夹(plugins/ 目录)。
|
|
1222
1230
|
# 使用位置: loaders/plugin_folder.py(构造 meta.source)与 Core/module.py
|
|
1223
1231
|
# (purge 卸载时仅对本地插件清理 sys.modules)。
|
|
@@ -1391,6 +1399,7 @@ __all__ = [
|
|
|
1391
1399
|
"BOT_STATUS_OFFLINE",
|
|
1392
1400
|
"BOT_STATUS_ONLINE",
|
|
1393
1401
|
"CLEANUP_CALLBACK_TIMEOUT_SECS",
|
|
1402
|
+
"TRACKED_RELEASE_TIMEOUT_SECS",
|
|
1394
1403
|
"COMMAND_ARG_DURATION_UNITS",
|
|
1395
1404
|
"GOVERNANCE_KEY_KINDS",
|
|
1396
1405
|
"GOVERNANCE_STATE_MAX_ENTRIES",
|
|
@@ -1463,6 +1472,7 @@ __all__ = [
|
|
|
1463
1472
|
"EVENT_I18N_LANGUAGE_CHANGED",
|
|
1464
1473
|
"EVENT_ADAPTER_RELOAD",
|
|
1465
1474
|
"EVENT_MODULE_RELOAD",
|
|
1475
|
+
"EVENT_MODULE_ROLLBACK",
|
|
1466
1476
|
"EVENT_STORAGE_READY",
|
|
1467
1477
|
"EVENT_STORAGE_RECOVERED",
|
|
1468
1478
|
"EVENT_STORAGE_UNREACHABLE",
|