update and cleanup repo
This commit is contained in:
+8
-38
@@ -14,10 +14,8 @@ from SYS.database import LOG_DB_PATH, db
|
||||
from SYS.logger import log
|
||||
from SYS.plugin_config import (
|
||||
build_default_plugin_config,
|
||||
build_default_tool_config,
|
||||
get_configurable_plugin_types,
|
||||
get_configurable_store_types,
|
||||
get_configurable_tool_types,
|
||||
)
|
||||
from SYS import pipeline as ctx
|
||||
from SYS.result_table import Table
|
||||
@@ -32,19 +30,15 @@ from cmdnat._parsing import (
|
||||
|
||||
_PREFERENCES_BROWSE_PATH = "__preferences__"
|
||||
_PLUGINS_BROWSE_PATH = "__plugins__"
|
||||
_PLUGIN_CATEGORY_KEYS = ("plugin", "provider", "tool")
|
||||
_PLUGIN_CATEGORY_KEYS = ("plugin",)
|
||||
_CREATE_INSTANCE_FLAG = "-create-instance"
|
||||
_KNOWN_SECTION_LABELS = {
|
||||
"plugin": "Plugins",
|
||||
"provider": "Plugins",
|
||||
"tool": "Plugins",
|
||||
}
|
||||
_KNOWN_SECTION_DESCRIPTIONS = {
|
||||
_PREFERENCES_BROWSE_PATH: "Global preferences and simple values",
|
||||
_PLUGINS_BROWSE_PATH: "All configured plugins and plugin instances",
|
||||
"provider": "Plugin configuration",
|
||||
"plugin": "Plugin configuration",
|
||||
"tool": "Plugin configuration",
|
||||
}
|
||||
_SENSITIVE_CONFIG_KEYS = {
|
||||
"access_key",
|
||||
@@ -300,19 +294,6 @@ def _get_configurable_plugin_names() -> List[str]:
|
||||
]
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
|
||||
def _get_configurable_tool_names() -> List[str]:
|
||||
try:
|
||||
return [
|
||||
str(name).strip().lower()
|
||||
for name in (get_configurable_tool_types() or [])
|
||||
if str(name).strip()
|
||||
]
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
|
||||
def _get_multi_instance_plugin_names() -> set[str]:
|
||||
try:
|
||||
return {
|
||||
@@ -336,7 +317,7 @@ def _is_multi_instance_plugin_root_path(browse_path: Optional[str]) -> bool:
|
||||
parts = _split_config_path(browse_path)
|
||||
return (
|
||||
len(parts) == 2
|
||||
and parts[0] in {"plugin", "provider"}
|
||||
and parts[0] == "plugin"
|
||||
and _is_multi_instance_plugin_name(parts[1])
|
||||
)
|
||||
|
||||
@@ -397,10 +378,6 @@ def _build_synthetic_plugin_branch(category: str, name: str) -> Optional[Dict[st
|
||||
if not normalized_name:
|
||||
return None
|
||||
|
||||
if normalized_category == "tool":
|
||||
branch = build_default_tool_config(normalized_name)
|
||||
return dict(branch) if isinstance(branch, dict) else None
|
||||
|
||||
branch = build_default_plugin_config(normalized_name)
|
||||
if not isinstance(branch, dict):
|
||||
return None
|
||||
@@ -441,10 +418,7 @@ def _resolve_plugin_branch(
|
||||
if not normalized_name:
|
||||
return None
|
||||
|
||||
if normalized_category == "tool":
|
||||
if normalized_name not in _get_configurable_tool_names():
|
||||
return None
|
||||
elif normalized_name not in _get_configurable_plugin_names():
|
||||
if normalized_name not in _get_configurable_plugin_names():
|
||||
return None
|
||||
|
||||
synthetic = _build_synthetic_plugin_branch(normalized_category, normalized_name)
|
||||
@@ -557,7 +531,7 @@ def _resolve_config_branch(
|
||||
if resolved is None:
|
||||
return None
|
||||
_, current, _ = resolved
|
||||
if parts[0] in {"plugin", "provider"} and _is_multi_instance_plugin_name(parts[1]):
|
||||
if parts[0] == "plugin" and _is_multi_instance_plugin_name(parts[1]):
|
||||
current = _normalize_multi_instance_branch(parts[1], current)
|
||||
for part in parts[2:]:
|
||||
if not isinstance(current, dict):
|
||||
@@ -620,7 +594,7 @@ def _create_or_get_plugin_instance(
|
||||
instance_name: str,
|
||||
) -> tuple[str, bool]:
|
||||
parts = _split_config_path(instance_target)
|
||||
if len(parts) != 2 or parts[0] not in {"plugin", "provider"}:
|
||||
if len(parts) != 2 or parts[0] != "plugin":
|
||||
raise ValueError(f"Unsupported instance target '{instance_target}'")
|
||||
|
||||
category, plugin_name = parts
|
||||
@@ -663,7 +637,7 @@ def _resolve_update_key(config_data: Dict[str, Any], selection_key: str) -> str:
|
||||
parts = _split_config_path(selection_key)
|
||||
if (
|
||||
len(parts) >= 4
|
||||
and parts[0] in {"plugin", "provider"}
|
||||
and parts[0] == "plugin"
|
||||
and parts[2].lower() == "default"
|
||||
and _is_multi_instance_plugin_name(parts[1])
|
||||
):
|
||||
@@ -797,7 +771,7 @@ def _build_config_header_lines(browse_path: Optional[str]) -> List[str]:
|
||||
parts = _split_config_path(text)
|
||||
if (
|
||||
len(parts) == 3
|
||||
and parts[0] in {"plugin", "provider"}
|
||||
and parts[0] == "plugin"
|
||||
and _is_multi_instance_plugin_name(parts[1])
|
||||
):
|
||||
return [
|
||||
@@ -951,17 +925,13 @@ def _resolve_direct_browse_path(
|
||||
lowered = text.lower()
|
||||
if lowered in {"preferences", "prefs"}:
|
||||
return _PREFERENCES_BROWSE_PATH
|
||||
if lowered in {"plugins", "plugin", "providers", "provider", "tools", "tool"}:
|
||||
if lowered in {"plugins", "plugin"}:
|
||||
return _PLUGINS_BROWSE_PATH
|
||||
|
||||
plugin_branch = _resolve_plugin_branch(config_data, "plugin", lowered)
|
||||
if plugin_branch is not None:
|
||||
return f"plugin.{plugin_branch[0]}"
|
||||
|
||||
tool_branch = _resolve_plugin_branch(config_data, "tool", lowered)
|
||||
if tool_branch is not None:
|
||||
return f"tool.{tool_branch[0]}"
|
||||
|
||||
branch = _resolve_config_branch(config_data, text)
|
||||
if isinstance(branch, dict):
|
||||
return text
|
||||
|
||||
Reference in New Issue
Block a user