sync update from LAN repo (source ji @ 85078a31)

This commit is contained in:
gozeros committed 2026-10-21 15:09:16 +08:00
1 parent 5d6627af50
commit e602d88695
864 files changed
+99150 -6346

No files matched your search

@@ -414,6 +414,22 @@ class AgentModuleSettings(BaseModel):
model_config = ConfigDict(extra="ignore")
class WxCommonAgentsSettings(BaseModel):
"""The gallery category shown in the wx chat route's common-agent panel.
``None`` keeps the original recommendation logic. ``mine`` and
``sentiment`` are built-in category values. Publish-square categories are
persisted as ``square:<square_id>`` so they cannot collide with the
built-ins.
"""
agent_type: str | None = Field(
default=None,
description="Selected gallery category; null retains the default recommendation logic",
)
model_config = ConfigDict(extra="ignore")
class PluginDomainAgentMapping(BaseModel):
"""One configured host -> agent mapping for iframe chat auto-selection."""
@@ -505,14 +521,41 @@ class ModelConcurrencySettings(BaseModel):
model_config = ConfigDict(extra="ignore")
class MemoryRuntimeSettings(BaseModel):
"""Deployment-wide switch for Q&A memory.
Memory is deliberately opt-in. When this setting is false the lead agent
does not mount memory middleware or memory tools, does not inject stored
memory into prompts, and does not enqueue background memory extraction.
"""
enabled: bool = Field(
default=False,
description="Whether Q&A memory recall, injection and persistence are enabled.",
)
model_config = ConfigDict(extra="ignore")
class LocalWikiEncoderSettings(BaseModel):
"""Runtime override for the administrator-managed offline Wiki encoder."""
mode: Literal["configured", "local"] = Field(
default="configured",
description=(
"Use the embedding provider from config.yaml, or explicitly override it "
"with the administrator-managed offline BGE-M3 encoder."
),
)
model_path: str = Field(
default="",
max_length=4096,
description="Absolute or project-relative directory containing the offline BGE-M3 ONNX model.",
)
model_revision: str = Field(
default="",
max_length=64,
description="Opaque revision changed whenever an offline model directory is activated.",
)
model_config = ConfigDict(extra="ignore")
@@ -539,8 +582,10 @@ class SystemSettings(BaseModel):
skill_compression: SkillCompressionSettings = Field(default_factory=SkillCompressionSettings)
plugin_management: PluginManagementSettings = Field(default_factory=PluginManagementSettings)
agent_modules: AgentModuleSettings = Field(default_factory=AgentModuleSettings)
wx_common_agents: WxCommonAgentsSettings = Field(default_factory=WxCommonAgentsSettings)
concurrency_monitor: ConcurrencyMonitorSettings = Field(default_factory=ConcurrencyMonitorSettings)
model_concurrency: ModelConcurrencySettings = Field(default_factory=ModelConcurrencySettings)
memory: MemoryRuntimeSettings = Field(default_factory=MemoryRuntimeSettings)
local_wiki_encoder: LocalWikiEncoderSettings = Field(default_factory=LocalWikiEncoderSettings)
strategy_projects: StrategyProjectSettings = Field(default_factory=StrategyProjectSettings)
llmwiki: LlmWikiRuntimeOverride = Field(default_factory=LlmWikiRuntimeOverride)
@@ -602,12 +647,26 @@ def get_model_concurrency_settings() -> ModelConcurrencySettings:
return ModelConcurrencySettings()
def get_memory_runtime_settings() -> MemoryRuntimeSettings:
"""Return the admin-controlled Q&A memory switch, failing closed."""
try:
return load_system_settings().memory
except Exception:
logger.debug("Failed to read memory runtime setting; keeping memory disabled", exc_info=True)
return MemoryRuntimeSettings()
def save_system_settings(settings: SystemSettings) -> SystemSettings:
"""Persist the settings document atomically, returning the saved value."""
path = _settings_path()
payload = settings.model_dump(mode="json")
with _lock:
tmp = path.with_suffix(path.suffix + ".tmp")
tmp.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
tmp.replace(path)
# Multiple Gateway workers share this file. A unique temporary name
# prevents their atomic replaces from racing over one common `.tmp`.
tmp = path.with_name(f".{path.name}.{uuid4().hex}.tmp")
try:
tmp.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
tmp.replace(path)
finally:
tmp.unlink(missing_ok=True)
return settings