重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。

同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。

Made-with: Cursor
This commit is contained in:
oliver 2026-04-26 08:34:33 +08:00
parent 4a23b715a2
commit dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions

View file

@ -0,0 +1,53 @@
from __future__ import annotations
import os
from typing import Any, Callable, Protocol
from .gmail_watcher import GmailWatcherResult, start_gmail_watcher
class GmailWatcherLog(Protocol):
def info(self, msg: str) -> None: ...
def warn(self, msg: str) -> None: ...
def error(self, msg: str) -> None: ...
def _is_truthy_env(value: str | None) -> bool:
return str(value or "").strip().lower() in {"1", "true", "yes", "on"}
def _skip_gmail_watcher_env() -> bool:
for key in ("OCLAW_SKIP_GMAIL_WATCHER", "OPENCLAW_SKIP_GMAIL_WATCHER"):
if _is_truthy_env(os.getenv(key)):
return True
return False
def start_gmail_watcher_with_logs(
*,
cfg: dict[str, Any] | None,
log: GmailWatcherLog,
on_skipped: Callable[[], None] | None = None,
starter: Callable[[dict[str, Any] | None], GmailWatcherResult] = start_gmail_watcher,
) -> None:
"""Skip entirely when ``OCLAW_SKIP_GMAIL_WATCHER`` or ``OPENCLAW_SKIP_GMAIL_WATCHER`` is truthy."""
if _skip_gmail_watcher_env():
if on_skipped:
on_skipped()
return
try:
res = starter(cfg)
if bool(res.started):
log.info("gmail watcher started")
return
reason = str(res.reason or "").strip()
if reason and reason not in {
"hooks not enabled",
"no gmail account configured",
"gmail watcher runtime not implemented (Python)",
}:
log.warn(f"gmail watcher not started: {reason}")
except Exception as exc:
log.error(f"gmail watcher failed to start: {exc}")