v0.1.4-p5

main
mula.liu 2026-04-14 10:41:09 +08:00
parent fb461a7f5b
commit 4c99826863
1 changed files with 18 additions and 3 deletions

View File

@ -465,6 +465,10 @@ def serialize_bot_list_entry(bot: BotInstance) -> Dict[str, Any]:
}
def _has_bot_workspace_config(bot_id: str) -> bool:
return (Path(BOTS_WORKSPACE_ROOT) / bot_id / ".nanobot" / "config.json").is_file()
def sync_bot_workspace_channels(
session: Session,
bot_id: str,
@ -476,8 +480,14 @@ def sync_bot_workspace_channels(
if not bot:
raise RuntimeError(f"Bot not found: {bot_id}")
snapshot = read_bot_runtime_snapshot(bot)
bot_data: Dict[str, Any] = dict(snapshot)
has_existing_config = _has_bot_workspace_config(bot_id)
if has_existing_config:
snapshot = read_bot_runtime_snapshot(bot)
bot_data: Dict[str, Any] = dict(snapshot)
else:
if not isinstance(runtime_overrides, dict):
raise RuntimeError(f"Missing required bot config for workspace sync: {bot_id}")
bot_data = {}
if isinstance(runtime_overrides, dict):
bot_data.update(runtime_overrides)
@ -495,7 +505,12 @@ def sync_bot_workspace_channels(
if "sendToolHints" in global_delivery_override:
send_tool_hints = bool(global_delivery_override.get("sendToolHints"))
channels_data = channels_override if channels_override is not None else list_bot_channels_from_config(bot)
if channels_override is not None:
channels_data = channels_override
elif has_existing_config:
channels_data = list_bot_channels_from_config(bot)
else:
channels_data = []
bot_data["send_progress"] = send_progress
bot_data["send_tool_hints"] = send_tool_hints
normalized_channels: List[Dict[str, Any]] = []