Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions gateway/platforms/weixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,8 @@ async def disconnect(self) -> None:
logger.info("[%s] Disconnected", self.name)

async def _poll_loop(self) -> None:
assert self._poll_session is not None
if self._poll_session is None:
raise RuntimeError("poll session not initialized")
sync_buf = _load_sync_buf(self._hermes_home, self._account_id)
timeout_ms = LONG_POLL_TIMEOUT_MS
consecutive_failures = 0
Expand Down Expand Up @@ -1401,7 +1402,8 @@ async def _process_message_safe(self, message: Dict[str, Any]) -> None:
logger.error("[%s] unhandled inbound error from=%s: %s", self.name, _safe_id(message.get("from_user_id")), exc, exc_info=True)

async def _process_message(self, message: Dict[str, Any]) -> None:
assert self._poll_session is not None
if self._poll_session is None:
raise RuntimeError("poll session not initialized")
sender_id = str(message.get("from_user_id") or "").strip()
if not sender_id:
return
Expand Down Expand Up @@ -2088,7 +2090,8 @@ async def _download_remote_media(self, url: str) -> str:
if not is_safe_url(url):
raise ValueError(f"Blocked unsafe URL (SSRF protection): {url}")

assert self._send_session is not None
if self._send_session is None:
raise RuntimeError("send session not initialized")
# Use asyncio.wait_for() instead of aiohttp ClientTimeout to avoid
# "Timeout context manager should be used inside a task" errors.
async def _do_fetch():
Expand All @@ -2108,7 +2111,8 @@ async def _send_file(
caption: str,
force_file_attachment: bool = False,
) -> str:
assert self._send_session is not None and self._token is not None
if self._send_session is None or self._token is None:
raise RuntimeError("send session or token not initialized")
plaintext = Path(path).read_bytes()
media_type, item_builder = self._outbound_media_builder(path, force_file_attachment=force_file_attachment)
filekey = secrets.token_hex(16)
Expand Down
3 changes: 2 additions & 1 deletion gateway/relay/ws_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ async def _send(self, frame: Dict[str, Any]) -> None:
await self._ws.send(json.dumps(frame) + "\n")

async def _read_loop(self) -> None:
assert self._ws is not None
if self._ws is None:
raise RuntimeError("WebSocket not connected — _read_loop called before connect()")
buf = ""
try:
async for chunk in self._ws:
Expand Down
6 changes: 4 additions & 2 deletions plugins/google_meet/realtime/openai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,14 @@ def cancel_response(self) -> bool:
return False

def _send_json(self, payload: dict) -> None:
assert self._ws is not None
if self._ws is None:
raise RuntimeError("WebSocket not connected")
with self._send_lock:
self._ws.send(json.dumps(payload))

def _recv(self, timeout: Optional[float] = None):
assert self._ws is not None
if self._ws is None:
raise RuntimeError("WebSocket not connected")
try:
if timeout is None:
return self._ws.recv()
Expand Down
3 changes: 2 additions & 1 deletion tools/browser_supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,8 @@ async def _cdp(

async def _read_loop(self) -> None:
"""Continuously dispatch incoming CDP frames."""
assert self._ws is not None
if self._ws is None:
raise RuntimeError("WebSocket not connected — _read_loop called before connect()")
try:
async for raw in self._ws:
if self._stop_requested:
Expand Down
3 changes: 2 additions & 1 deletion tools/environments/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,8 @@ def _run_bash(self, cmd_string: str, *, login: bool = False,
timeout: int = 120,
stdin_data: str | None = None) -> subprocess.Popen:
"""Spawn a bash process inside the Docker container."""
assert self._container_id, "Container not started"
if not self._container_id:
raise RuntimeError("Container not started — call start() first")
cmd = [self._docker_exe, "exec"]
if stdin_data is not None:
cmd.append("-i")
Expand Down
9 changes: 6 additions & 3 deletions tools/skill_manager_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,8 @@ def _patch_skill(
target, err = _resolve_skill_target(skill_dir, file_path)
if err:
return {"success": False, "error": err}
assert target is not None
if target is None:
return {"success": False, "error": "Failed to resolve skill target"}
else:
# Patching SKILL.md
target = skill_dir / "SKILL.md"
Expand Down Expand Up @@ -1146,7 +1147,8 @@ def _write_file(name: str, file_path: str, file_content: str) -> Dict[str, Any]:
target, err = _resolve_skill_target(existing["path"], file_path)
if err:
return {"success": False, "error": err}
assert target is not None
if target is None:
return {"success": False, "error": "Failed to resolve skill target"}
if target.exists():
read_guard = _background_review_read_before_write_guard(
name, target, "write_file", file_path
Expand Down Expand Up @@ -1192,7 +1194,8 @@ def _remove_file(name: str, file_path: str) -> Dict[str, Any]:
target, err = _resolve_skill_target(skill_dir, file_path)
if err:
return {"success": False, "error": err}
assert target is not None
if target is None:
return {"success": False, "error": "Failed to resolve skill target"}
if not target.exists():
# List what's actually there for the model to see
available = []
Expand Down