sync update from LAN repo (source master-yx @ cf505220)

This commit is contained in:
gozeros committed 2026-10-21 15:11:11 +08:00
1 parent e243ec3a46
commit 19d3cb96dc
114 files changed
+14787 -451

No files matched your search

@@ -211,6 +211,7 @@ class AppConfig(BaseModel):
cls._check_config_version(config_data, resolved_path)
config_data = cls.resolve_env_variables(config_data)
cls._resolve_relative_mount_paths(config_data, resolved_path.parent)
cls._apply_database_defaults(config_data)
# Load title config if present
@@ -272,6 +273,36 @@ class AppConfig(BaseModel):
result = cls.model_validate(config_data)
return result
@classmethod
def _resolve_relative_mount_paths(
cls,
config_data: dict[str, Any],
config_dir: Path,
) -> None:
"""Resolve portable sandbox mount paths beside ``config.yaml``.
Deployment copies frequently live at different absolute paths. A
relative ``sandbox.mounts[*].host_path`` therefore means "relative to
the config file", never relative to the process working directory.
Providers continue to receive absolute paths, which keeps both the
local path mapper and Docker bind mounts deterministic.
"""
sandbox = config_data.get("sandbox")
if not isinstance(sandbox, dict):
return
mounts = sandbox.get("mounts")
if not isinstance(mounts, list):
return
for mount in mounts:
if not isinstance(mount, dict):
continue
raw_host_path = mount.get("host_path")
if not isinstance(raw_host_path, str) or not raw_host_path.strip():
continue
host_path = Path(raw_host_path)
if not host_path.is_absolute():
mount["host_path"] = str((config_dir / host_path).resolve())
@classmethod
def _apply_database_defaults(cls, config_data: dict[str, Any]) -> None:
"""Apply config.yaml defaults for persistence when the section is absent."""
@@ -77,6 +77,7 @@ class LocalWikiEmbeddingConfig(BaseModel):
base_url: str = ""
api_key: str = Field(default="", repr=False)
local_model_path: str = ""
local_model_revision: str = ""
local_cache_dir: str = ""
local_process_isolation: bool = True
local_threads: int = Field(default=2, ge=1, le=32)
@@ -508,11 +508,33 @@ class ModelConcurrencySettings(BaseModel):
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")
class StrategyProjectSettings(BaseModel):
"""Global visibility controls for the strategy-project experience."""
taiwan_strait_demo_enabled: bool = Field(
default=False,
description="Whether Taiwan Strait demo entry points are visible in My Projects.",
)
model_config = ConfigDict(extra="ignore")
@@ -532,6 +554,7 @@ class SystemSettings(BaseModel):
concurrency_monitor: ConcurrencyMonitorSettings = Field(default_factory=ConcurrencyMonitorSettings)
model_concurrency: ModelConcurrencySettings = Field(default_factory=ModelConcurrencySettings)
local_wiki_encoder: LocalWikiEncoderSettings = Field(default_factory=LocalWikiEncoderSettings)
strategy_projects: StrategyProjectSettings = Field(default_factory=StrategyProjectSettings)
llmwiki: LlmWikiRuntimeOverride = Field(default_factory=LlmWikiRuntimeOverride)
skill_knowledge_auto_sync: SkillKnowledgeAutoSyncSettings = Field(default_factory=SkillKnowledgeAutoSyncSettings)
knowledge_base_product_version: Literal["v1", "v2"] = Field(
@@ -596,7 +619,12 @@ def save_system_settings(settings: SystemSettings) -> SystemSettings:
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