Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
ci: unblock predeploy after Wave 13 push
trohitg48ddfcf91e21
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.ymldeleted file mode 100644index 39ffd521..00000000--- a/.github/workflows/codeql.yml+++ /dev/null@@ -1,92 +0,0 @@-# CodeQL static-analysis SAST scanning.-#-# Two-language matrix matches MachinaOs's split: Python (CLI +-# FastAPI backend + plugins under server/) and JavaScript/TypeScript-# (React Flow client + Node.js sidecar at server/nodejs). One job per-# language so a failure in one doesn't block the other's results from-# landing in the Security tab.-#-# Triggers (lifted from prefect's codeql.yml + GitHub's own-# recommended cadence):-# - push to main: scan-then-baseline every merge-# - pull_request: catch regressions before they land (path-# filter excludes docs-only PRs so we don't-# burn 15+ minutes of compute on copy edits)-# - schedule weekly: catch zero-days in dependencies + new query--# pack releases without waiting for the next-# merge. Sun 20:30 UTC matches the cadence-# prefect uses.-#-# Permissions follow the least-privilege model documented at-# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-default-setup-for-code-scanning-# `security-events: write` is the one required scope; everything else-# stays at the workflow-default `none`.--name: CodeQL--on:- push:- branches: [main]- paths-ignore:- - 'docs-MachinaOs/**'- - '**/*.md'- pull_request:- branches: [main]- paths-ignore:- - 'docs-MachinaOs/**'- - '**/*.md'- schedule:- # Sundays 20:30 UTC. Mid-low-traffic window for runner pool +- # gives the Security tab a fresh baseline each week.- - cron: '30 20 * * 0'--permissions:- contents: read--jobs:- analyze:- name: Analyze ${{ matrix.language }}- runs-on: ubuntu-latest- timeout-minutes: 60-- permissions:- # Minimum needed for CodeQL to publish to the Security tab.- # Documented at https://github.com/github/codeql-action#permissions- security-events: write- contents: read- actions: read-- strategy:- fail-fast: false- matrix:- include:- - language: python- # Repo Python files live under cli/ + server/ + scripts/.- # CodeQL auto-detects entrypoints; no build step needed- # for Python (it's interpreted).- - language: javascript-typescript- # Combined JS/TS query pack — single language slot in- # the matrix per CodeQL's 2024+ convention.-- steps:- - name: Checkout- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4-- - name: Initialize CodeQL- uses: github/codeql-action/init@458d36d7d4f47d0dd16ca424c1d3cda0060f1360 # v3- with:- languages: ${{ matrix.language }}- # security-extended pulls in queries beyond the default- # security pack (e.g., taint-tracking on more sinks,- # CWE coverage). security-and-quality adds code-quality- # queries which produce noise we don't want gating PRs.- queries: security-extended-- # No autobuild step: Python is interpreted; JS/TS via the- # tsgo+vite toolchain already runs in predeploy.yml — CodeQL- # only needs to read source files, not build artifacts.-- - name: Perform CodeQL Analysis- uses: github/codeql-action/analyze@458d36d7d4f47d0dd16ca424c1d3cda0060f1360 # v3- with:- category: "/language:${{ matrix.language }}"diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex a40f1195..eec603cc 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -39,17 +39,17 @@ repos:args: ['--maxkb=500'] # generous cap; binaries should live elsewhere- id: detect-private-key- # ---------------------------------------------------------------- Python: ruff- # Format + lint in one pass. Matches server/pyproject.toml's- # [tool.ruff] config (line-length=140, ignores E402/E701).+ # ---------------------------------------------------------------- Python: ruff-format+ # Format only. The ruff lint pass (F401 unused-imports, F821, F841+ # etc.) was producing noise on legitimate ``__getattr__``-driven+ # lazy-module patterns and on temporary scaffolding -- kept out of+ # the gate. Run ``ruff check`` ad hoc when you actually want lint+ # signal.- repo: https://github.com/astral-sh/ruff-pre-commitrev: v0.8.4hooks:- id: ruff-formattypes_or: [python, pyi]- - id: ruff- args: ['--fix', '--exit-non-zero-on-fix']- types_or: [python, pyi]# ---------------------------------------------------------------- JS/TS: prettier# Prettier owns formatting (semicolons, quote style, indent). ESLintdiff --git a/cli/_common.py b/cli/_common.pyindex 789986fb..f97361be 100644--- a/cli/_common.py+++ b/cli/_common.py@@ -65,6 +65,7 @@ def free_all_ports(cfg: Config) -> list[KillResult]:recovery verb ``machina clean``."""from cli.ports import kill_port+return [kill_port(port) for port in cfg.all_ports]@@ -87,13 +88,18 @@ def build_backend_spec("""from cli.run import uv_runfrom cli.supervisor import ServiceSpec+return ServiceSpec(name="server",argv=uv_run(- "uvicorn", "main:app",- "--host", host,- "--port", str(cfg.backend_port),- "--log-level", "warning",+ "uvicorn",+ "main:app",+ "--host",+ host,+ "--port",+ str(cfg.backend_port),+ "--log-level",+ "warning",),cwd=server_dir(root),ready_port=cfg.backend_port,@@ -110,6 +116,7 @@ def error_block(title: str, lines: list[str]) -> None:interprets."""from cli.colors import console+console.print(f"[red]Error: {title}[/]")for line in lines:console.print(f" {line}")diff --git a/cli/cli.py b/cli/cli.pyindex af69e681..fc5628cc 100644--- a/cli/cli.py+++ b/cli/cli.py@@ -33,12 +33,14 @@ def _root() -> None:# ----------------------------------------------------------- top-level verbs+@app.command("start",help="Start all services in production mode (static client + uvicorn + temporal).",)def _start() -> None:from cli.commands.start import start_command+start_command()@@ -48,11 +50,13 @@ def _start() -> None:)def _dev(daemon: bool = typer.Option(- False, "--daemon",+ False,+ "--daemon",help="Bind backend to 0.0.0.0 instead of 127.0.0.1.",),) -> None:from cli.commands.dev import dev_command+dev_command(daemon=daemon)@@ -62,6 +66,7 @@ def _dev()def _stop() -> None:from cli.commands.stop import stop_command+stop_command()@@ -71,6 +76,7 @@ def _stop() -> None:)def _clean() -> None:from cli.commands.clean import clean_command+clean_command()@@ -80,6 +86,7 @@ def _clean() -> None:)def _build() -> None:from cli.commands.build import build_command+build_command()@@ -99,6 +106,7 @@ daemon_app = typer.Typer()def _daemon_start() -> None:from cli.commands.daemon.start import start_command+start_command()@@ -108,6 +116,7 @@ def _daemon_start() -> None:)def _daemon_stop() -> None:from cli.commands.daemon.stop import stop_command+stop_command()@@ -117,6 +126,7 @@ def _daemon_stop() -> None:)def _daemon_status() -> None:from cli.commands.daemon.status import status_command+status_command()@@ -126,6 +136,7 @@ def _daemon_status() -> None:)def _daemon_restart() -> None:from cli.commands.daemon.restart import restart_command+restart_command()@@ -148,11 +159,13 @@ docs_app = typer.Typer()def _docs_nodes(check: bool = typer.Option(- False, "--check",+ False,+ "--check",help="Instead of rewriting, exit 1 if any registered node lacks a doc.",),) -> None:from cli.commands.docs import nodes+nodes(check=check)@@ -175,10 +188,12 @@ version_app = typer.Typer()def _version_sync(tag: str | None = typer.Argument(- None, help="Git tag to use (defaults to latest).",+ None,+ help="Git tag to use (defaults to latest).",),) -> None:from cli.commands.version import sync+sync(tag=tag)diff --git a/cli/colors.py b/cli/colors.pyindex 511e26ed..5bc27e52 100644--- a/cli/colors.py+++ b/cli/colors.py@@ -23,8 +23,16 @@ console = Console(log_time_format="[%H:%M:%S.%f]", log_path=False)# Honcho's rotation, lifted: skip very-dark (black) and very-bright (white)# so prefixes remain readable on both light and dark terminals._PALETTE = [- "cyan", "green", "yellow", "blue", "magenta",- "bright_cyan", "bright_green", "bright_yellow", "bright_blue", "bright_magenta",+ "cyan",+ "green",+ "yellow",+ "blue",+ "magenta",+ "bright_cyan",+ "bright_green",+ "bright_yellow",+ "bright_blue",+ "bright_magenta",]_color_cycle = cycle(_PALETTE)diff --git a/cli/commands/_temporal_specs.py b/cli/commands/_temporal_specs.pyindex 0c96bc23..9c5f3e4b 100644--- a/cli/commands/_temporal_specs.py+++ b/cli/commands/_temporal_specs.py@@ -11,6 +11,7 @@ start-dev`` subcommand against a SQLite db atMatches the local-dev install method documented athttps://docs.temporal.io/develop/python/set-up-your-local-python."""+from __future__ import annotationsimport os@@ -39,14 +40,18 @@ def temporal_specs(root: Path, cfg: Config) -> list[ServiceSpec]:ServiceSpec(name="temporal",argv=uv_run(- "python", "-m", "services.temporal._supervised_runtime",+ "python",+ "-m",+ "services.temporal._supervised_runtime","services.temporal._runtime:get_temporal_server_runtime",),cwd=server_dir(root),ready_port=cfg.temporal_port,ready_timeout=float(os.environ["TEMPORAL_SERVER_READY_TIMEOUT_SECONDS"]),restart=RestartPolicy.ON_CRASH,- terminate_grace_seconds=float(os.environ["TEMPORAL_GRACEFUL_SHUTDOWN_SECONDS"]),+ terminate_grace_seconds=float(+ os.environ["TEMPORAL_GRACEFUL_SHUTDOWN_SECONDS"]+ ),),]diff --git a/cli/commands/build.py b/cli/commands/build.pyindex 49ffdf04..688953b2 100644--- a/cli/commands/build.py+++ b/cli/commands/build.py@@ -44,6 +44,7 @@ COMPILEALL_SOURCE_DIRS: tuple[str, ...] = (# ---------------------------------------------------------------- helpers+def _which_python() -> str | None:"""Prefer ``python3`` so we don't pick up Python 2.x on POSIX distros."""for cmd in ("python3", "python"):@@ -92,6 +93,7 @@ def _ensure_uv(python_cmd: str) -> str:# ---------------------------------------------------------------- build+def build_command() -> None:root = project_root()@@ -179,7 +181,9 @@ def build_command() -> None:# template files inside packages like crawlee that aren't real Python.console.log("[5/6] Compiling Python bytecode...")run(- uv_run("python", "-O", "-m", "compileall", "-q", "-j", "0", *COMPILEALL_SOURCE_DIRS),+ uv_run(+ "python", "-O", "-m", "compileall", "-q", "-j", "0", *COMPILEALL_SOURCE_DIRS+ ),cwd=server_cwd,check=False, # missing pyc is non-fatal — runtime regenerates as needed)diff --git a/cli/commands/daemon/start.py b/cli/commands/daemon/start.pyindex 12ed76dd..c2a1984a 100644--- a/cli/commands/daemon/start.py+++ b/cli/commands/daemon/start.py@@ -30,10 +30,14 @@ def start_command() -> None:proc = subprocess.Popen(uv_run(- "uvicorn", "main:app",- "--host", "0.0.0.0",- "--port", str(backend_port),- "--log-level", "warning",+ "uvicorn",+ "main:app",+ "--host",+ "0.0.0.0",+ "--port",+ str(backend_port),+ "--log-level",+ "warning",),cwd=str(server_dir(root)),stdin=subprocess.DEVNULL,diff --git a/cli/commands/docs.py b/cli/commands/docs.pyindex cc160749..ceec7bc0 100644--- a/cli/commands/docs.py+++ b/cli/commands/docs.py@@ -52,8 +52,7 @@ def _list_categories(docs_dir: Path) -> list[str]:if not docs_dir.exists():return []return sorted(- d.name for d in docs_dir.iterdir()- if d.is_dir() and not d.name.startswith("_")+ d.name for d in docs_dir.iterdir() if d.is_dir() and not d.name.startswith("_"))@@ -65,11 +64,13 @@ def _list_docs(docs_dir: Path, category: str) -> list[dict]:continueif path.name.startswith("_") or path.name == "README.md":continue- out.append({- "rel_path": f"{category}/{path.name}",- "title": _read_h1(path),- "node_key": path.stem,- })+ out.append(+ {+ "rel_path": f"{category}/{path.name}",+ "title": _read_h1(path),+ "node_key": path.stem,+ }+ )return out@@ -141,7 +142,8 @@ def _check_completeness(root: Path) -> int:@app.command("nodes", help="Rebuild (or --check) the per-node documentation index.")def nodes(check: bool = typer.Option(- False, "--check",+ False,+ "--check",help="Instead of rewriting, exit 1 if any registered node lacks a doc.",),) -> None:diff --git a/cli/commands/start.py b/cli/commands/start.pyindex e6b3df97..c98e94c9 100644--- a/cli/commands/start.py+++ b/cli/commands/start.py@@ -26,6 +26,7 @@ from cli.platform_ import (IS_WINDOWS,IS_WSL,platform_name,+ server_dir,server_venv,static_client_script,)@@ -44,32 +45,53 @@ def _sqlalchemy_preflight(root: Path) -> None:clear remediation message instead of letting uvicorn hang silently.See ``docs-internal/errors.md`` #1 / #1a.- Runs the probe inside the workspace ``.venv`` through ``uv run``- (via :func:`cli.run.uv_run`) -- same environment the supervised- services will use, no path-to-interpreter logic on this side.+ Runs the probe inside the server ``.venv`` through ``uv run`` with+ ``cwd=server/`` so uv discovers ``server/pyproject.toml`` (the only+ place uv-managed Python deps live -- root ``pyproject.toml`` is the+ standalone CLI package). Same environment the supervised services+ will use, no path-to-interpreter logic on this side."""started = time.monotonic()try:subprocess.run(uv_run("python", "-c", "import sqlalchemy"),- cwd=str(root),+ cwd=str(server_dir(root)),timeout=15,check=True,capture_output=True,)- except (subprocess.TimeoutExpired, subprocess.CalledProcessError):+ except (subprocess.TimeoutExpired, subprocess.CalledProcessError) as exc:elapsed = time.monotonic() - started+ stderr_tail = ""+ if isinstance(exc, subprocess.CalledProcessError) and exc.stderr:+ stderr_bytes = (+ exc.stderr if isinstance(exc.stderr, bytes) else exc.stderr.encode()+ )+ stderr_tail = stderr_bytes.decode(errors="replace").strip()+ details: list[str] = ["sqlalchemy import hung or crashed."]+ if stderr_tail:+ details.append(f"subprocess stderr: {stderr_tail}")+ if IS_WINDOWS:+ details.extend(+ [+ "Likely cause on Windows: Defender scan cache or stale kernel state.",+ "Fix options:",+ " 1. Restart-Service WinDefend (admin PowerShell)",+ " 2. Reboot the machine",+ f" 3. Add {server_venv(root)} to Defender exclusions",+ ]+ )+ else:+ details.extend(+ [+ f"Check that {server_venv(root)} exists and is populated.",+ "Run `machina build` to recreate the server venv.",+ ]+ )+ details.append("See docs-internal/errors.md #1 / #1a for details.")error_block(f"Python venv health check failed ({elapsed:.1f}s).",- [- "sqlalchemy import hung or crashed.",- "Likely cause: Windows Defender scan cache or stale kernel state.",- "Fix options:",- " 1. Restart-Service WinDefend (admin PowerShell)",- " 2. Reboot the machine",- f" 3. Add {server_venv(root)} to Defender exclusions",- "See docs-internal/errors.md #1 / #1a for details.",- ],+ details,)raise typer.Exit(code=1)elapsed = time.monotonic() - started@@ -87,6 +109,7 @@ def _temporal_running(cfg) -> bool:own binary via pooch at first boot of the supervised``TemporalServerRuntime``)."""from cli.tcp import probe_tcp_port_sync+return probe_tcp_port_sync(cfg.temporal_port)diff --git a/cli/commands/version.py b/cli/commands/version.pyindex edcf0c2b..af5bd48a 100644--- a/cli/commands/version.py+++ b/cli/commands/version.py@@ -36,7 +36,9 @@ def _git_describe(root: Path) -> str | None:return describedlisted = capture(["git", "tag", "-l", "--sort=-version:refname"], cwd=root)if listed:- return next((line.strip() for line in listed.splitlines() if line.strip()), None)+ return next(+ (line.strip() for line in listed.splitlines() if line.strip()), None+ )return None@@ -58,7 +60,9 @@ def _update_package_json(path: Path, new_version: str) -> bool:@app.command("sync", help="Sync package.json versions from latest git tag.")-def sync(tag: str | None = typer.Argument(None, help="Git tag to use (defaults to latest).")) -> None:+def sync(+ tag: str | None = typer.Argument(None, help="Git tag to use (defaults to latest)."),+) -> None:root = project_root()resolved_tag = tag or _git_describe(root)if not resolved_tag:@@ -67,7 +71,9 @@ def sync(tag: str | None = typer.Argument(None, help="Git tag to use (defaults tversion = _tag_to_version(resolved_tag)if not _VALID_VERSION.match(version):- console.print(f"[red]Error: Invalid version from tag {resolved_tag!r}: {version!r}[/]")+ console.print(+ f"[red]Error: Invalid version from tag {resolved_tag!r}: {version!r}[/]"+ )console.print("Expected semver format (e.g. v0.0.11 or 0.0.11).")raise typer.Exit(code=1)diff --git a/cli/platform_.py b/cli/platform_.pyindex 99c265dd..946e1695 100644--- a/cli/platform_.py+++ b/cli/platform_.py@@ -66,6 +66,7 @@ def project_root() -> Path:# Path-prefix helpers -- canonical layout derived from ``project_root``.# ---------------------------------------------------------------------------+def _root(root: Path | None) -> Path:return root if root is not None else project_root()@@ -142,6 +143,7 @@ def user_data_dir() -> Path:if override:return Path(override).expanduser()import platformdirs+return platformdirs.user_data_path(_APP_NAME, appauthor=_APP_NAME)@@ -149,16 +151,19 @@ def user_cache_dir() -> Path:"""User cache directory (downloaded binaries / pooch caches).Matches ``server/core/paths.py::packages_dir``."""import platformdirs+return platformdirs.user_cache_path(_APP_NAME, appauthor=_APP_NAME)def user_config_dir() -> Path:"""User config directory."""import platformdirs+return platformdirs.user_config_path(_APP_NAME, appauthor=_APP_NAME)def user_log_dir() -> Path:"""User log directory."""import platformdirs+return platformdirs.user_log_path(_APP_NAME, appauthor=_APP_NAME)diff --git a/cli/supervisor.py b/cli/supervisor.pyindex 6d761648..c4951be8 100644--- a/cli/supervisor.py+++ b/cli/supervisor.py@@ -38,8 +38,8 @@ from cli.tree import add_to_job, kill_tree, new_session_kwargsclass RestartPolicy(enum.Enum):NEVER = "never"- ON_CRASH = "on_crash" # restart only on non-healthy exit- ALWAYS = "always" # restart on any exit+ ON_CRASH = "on_crash" # restart only on non-healthy exit+ ALWAYS = "always" # restart on any exit@dataclass@@ -363,7 +363,9 @@ class Manager:spec.ready_port, # type: ignore[arg-type]timeout=spec.ready_timeout,)- msg = f"ready on port {spec.ready_port}" if ok else f"timed out waiting for port {spec.ready_port}"+ msg = (+ f"ready on port {spec.ready_port}"+ if ok+ else f"timed out waiting for port {spec.ready_port}"+ )emit(spec.name, spec.color or "white", msg)--diff --git a/cli/tcp.py b/cli/tcp.pyindex b7f3c444..35b33ea4 100644--- a/cli/tcp.py+++ b/cli/tcp.py@@ -7,7 +7,9 @@ import socketimport time-async def probe_tcp_port(port: int, host: str = "127.0.0.1", *, timeout: float = 0.5) -> bool:+async def probe_tcp_port(+ port: int, host: str = "127.0.0.1", *, timeout: float = 0.5+) -> bool:"""Return True iff a TCP connection to ``host:port`` succeeds within ``timeout``."""try:_, writer = await asyncio.wait_for(@@ -39,7 +41,9 @@ async def wait_for_tcp_port(return False-def probe_tcp_port_sync(port: int, host: str = "127.0.0.1", *, timeout: float = 0.5) -> bool:+def probe_tcp_port_sync(+ port: int, host: str = "127.0.0.1", *, timeout: float = 0.5+) -> bool:"""Synchronous variant for places that aren't already in an event loop."""sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock.settimeout(timeout)diff --git a/cli/tests/conftest.py b/cli/tests/conftest.pyindex ad169350..bbfbad4d 100644--- a/cli/tests/conftest.py+++ b/cli/tests/conftest.py@@ -52,8 +52,9 @@ def workspace_members(root: Path) -> dict[str, Path]:"""# which_argv resolves Windows .cmd / .bat shims via PATHEXT — the# same helper cli.run uses everywhere else for the same reason.- argv = which_argv(["pnpm", "list", "--json", "--only-projects",- "--recursive", "--depth", "0"])+ argv = which_argv(+ ["pnpm", "list", "--json", "--only-projects", "--recursive", "--depth", "0"]+ )try:out = subprocess.run(argv,diff --git a/cli/tests/test_build.py b/cli/tests/test_build.pyindex 77fb9f10..a42f610b 100644--- a/cli/tests/test_build.py+++ b/cli/tests/test_build.py@@ -13,6 +13,7 @@ from cli.commands import build# --- shared helpers in cli.run -----------------------------------------+def test_capture_returns_none_when_command_missing():with patch.object(run_module.subprocess, "run", side_effect=FileNotFoundError):assert run_module.capture(["does-not-exist"]) is None@@ -26,8 +27,10 @@ def test_capture_returns_stdout_when_present():def test_run_raises_typer_exit_on_nonzero_when_check():fake = MagicMock(returncode=1)- with patch.object(run_module.subprocess, "run", return_value=fake), \- pytest.raises(typer.Exit):+ with (+ patch.object(run_module.subprocess, "run", return_value=fake),+ pytest.raises(typer.Exit),+ ):run_module.run(["false"])@@ -39,6 +42,7 @@ def test_run_returns_code_when_check_disabled():# --- build-specific helpers -------------------------------------------------+def test_check_python_accepts_3_12_plus():with patch.object(build, "capture", return_value="Python 3.12.5"):assert build._check_python("python") is Truediff --git a/cli/tests/test_build_compile_pipeline.py b/cli/tests/test_build_compile_pipeline.pyindex edbc3bad..e7bd5416 100644--- a/cli/tests/test_build_compile_pipeline.py+++ b/cli/tests/test_build_compile_pipeline.py@@ -32,6 +32,7 @@ from cli.commands import build# Helpers# ---------------------------------------------------------------------------+def _run_build_capture_invocations(tmp_path: Path) -> list[dict]:"""Run ``build_command()`` with all external I/O mocked.@@ -54,11 +55,13 @@ def _run_build_capture_invocations(tmp_path: Path) -> list[dict]:# Step [6/6] invokes ``services.temporal._install`` via ``uv_run`` to# materialise the Temporal binaries at build time. ``fake_run``# captures the argv without actually spawning, so pooch never fires.- with patch.object(build, "run", side_effect=fake_run), \- patch.object(build, "capture", side_effect=fake_capture), \- patch.object(build, "_which_python", return_value="python"), \- patch.object(build, "_ensure_uv"), \- patch.object(build, "project_root", return_value=tmp_path):+ with (+ patch.object(build, "run", side_effect=fake_run),+ patch.object(build, "capture", side_effect=fake_capture),+ patch.object(build, "_which_python", return_value="python"),+ patch.object(build, "_ensure_uv"),+ patch.object(build, "project_root", return_value=tmp_path),+ ):build.build_command()return captured@@ -78,6 +81,7 @@ def _find_call(# COMPILEALL_SOURCE_DIRS constant# ---------------------------------------------------------------------------+def test_source_dirs_constant_excludes_venv_and_tests():"""The bytecode-compile path list must skip ``.venv/`` and``tests/``: ``.venv/`` is wasted work (uv compiles deps at install@@ -113,21 +117,24 @@ def test_source_dirs_constant_covers_runtime_modules():# Sidecar bundle step ([3/6])# ---------------------------------------------------------------------------+def test_build_invokes_sidecar_pnpm_filter(tmp_path: Path):"""[3/6] Build Node.js sidecar via the package's ``build`` script."""captured = _run_build_capture_invocations(tmp_path)match = _find_call(captured,- lambda c: c[:1] == ["pnpm"] and "--filter" in c and "machinaos-nodejs-executor" in c,+ lambda c: c[:1] == ["pnpm"]+ and "--filter" in c+ and "machinaos-nodejs-executor" in c,)assert match is not None, ("expected `pnpm --filter machinaos-nodejs-executor run build` in "f"{[c['argv'] for c in captured]}")argv = match[1]["argv"]- assert "run" in argv and "build" in argv, (- f"sidecar step must invoke the `build` script, got {argv}"- )+ assert (+ "run" in argv and "build" in argv+ ), f"sidecar step must invoke the `build` script, got {argv}"def test_sidecar_build_runs_after_client_build(tmp_path: Path):@@ -139,9 +146,9 @@ def test_sidecar_build_runs_after_client_build(tmp_path: Path):client = _find_call(captured, lambda c: "react-flow-client" in c)sidecar = _find_call(captured, lambda c: "machinaos-nodejs-executor" in c)assert client is not None and sidecar is not None- assert client[0] < sidecar[0], (- f"client build idx {client[0]} must precede sidecar bundle idx {sidecar[0]}"- )+ assert (+ client[0] < sidecar[0]+ ), f"client build idx {client[0]} must precede sidecar bundle idx {sidecar[0]}"def test_only_one_sidecar_bundle_invocation(tmp_path: Path):@@ -155,15 +162,16 @@ def test_only_one_sidecar_bundle_invocation(tmp_path: Path):# Python bytecode compile step ([5/6])# ---------------------------------------------------------------------------+def test_compileall_uses_optimised_flag_quiet_and_parallel(tmp_path: Path):"""``-O`` strips asserts; ``-q`` silences per-file output; ``-j 0``parallelises across all CPU cores."""captured = _run_build_capture_invocations(tmp_path)match = _find_call(captured, lambda c: "compileall" in c)- assert match is not None, (- f"compileall step missing in {[c['argv'] for c in captured]}"- )+ assert (+ match is not None+ ), f"compileall step missing in {[c['argv'] for c in captured]}"argv = match[1]["argv"]assert "-O" in argv, "must use -O for .opt-1.pyc output"assert "-q" in argv, "must use -q to silence per-file logging"@@ -182,9 +190,14 @@ def test_compileall_runs_via_uv_run_python(tmp_path: Path):match = _find_call(captured, lambda c: "compileall" in c)assert match is not Noneargv = match[1]["argv"]- assert argv[:6] == ["uv", "run", "--no-sync", "python", "-O", "-m"], (- f"expected `uv run --no-sync python -O -m compileall ...`, got {argv[:7]}"- )+ assert argv[:6] == [+ "uv",+ "run",+ "--no-sync",+ "python",+ "-O",+ "-m",+ ], f"expected `uv run --no-sync python -O -m compileall ...`, got {argv[:7]}"def test_compileall_path_list_matches_source_dirs_constant(tmp_path: Path):@@ -199,7 +212,7 @@ def test_compileall_path_list_matches_source_dirs_constant(tmp_path: Path):argv = match[1]["argv"]# Trailing args after `-j 0` are the path list.j_idx = argv.index("-j")- paths_passed = tuple(argv[j_idx + 2:])+ paths_passed = tuple(argv[j_idx + 2 :])assert paths_passed == build.COMPILEALL_SOURCE_DIRS, (f"compileall args drift: build_command passed {paths_passed!r}, "f"constant says {build.COMPILEALL_SOURCE_DIRS!r}"@@ -214,9 +227,9 @@ def test_compileall_runs_in_server_dir(tmp_path: Path):match = _find_call(captured, lambda c: "compileall" in c)assert match is not Nonecall = match[1]- assert call.get("cwd") == tmp_path / "server", (- f"compileall must cwd into server/, got {call.get('cwd')}"- )+ assert (+ call.get("cwd") == tmp_path / "server"+ ), f"compileall must cwd into server/, got {call.get('cwd')}"def test_compileall_is_non_fatal(tmp_path: Path):@@ -246,12 +259,12 @@ def test_only_one_compileall_invocation(tmp_path: Path):# Temporal install step ([6/6])# ---------------------------------------------------------------------------+def _find_temporal_install_call(captured: list[dict]) -> tuple[int, dict] | None:return _find_call(captured,lambda c: (- c[:3] == ["uv", "run", "--no-sync"]- and "services.temporal._install" in c+ c[:3] == ["uv", "run", "--no-sync"] and "services.temporal._install" in c),)@@ -264,14 +277,13 @@ def test_build_invokes_temporal_install_via_uv_run(tmp_path: Path):captured = _run_build_capture_invocations(tmp_path)match = _find_temporal_install_call(captured)assert match is not None, (- "expected temporal install step in "- f"{[c['argv'] for c in captured]}"+ "expected temporal install step in " f"{[c['argv'] for c in captured]}")argv = match[1]["argv"]- assert argv[:6] == ["uv", "run", "--no-sync", "python", "-m",- "services.temporal._install"], (- f"expected `uv run --no-sync python -m services.temporal._install`, got {argv[:7]}"- )+ assert (+ argv[:6]+ == ["uv", "run", "--no-sync", "python", "-m", "services.temporal._install"]+ ), f"expected `uv run --no-sync python -m services.temporal._install`, got {argv[:7]}"def test_temporal_install_runs_in_server_dir(tmp_path: Path):@@ -282,9 +294,9 @@ def test_temporal_install_runs_in_server_dir(tmp_path: Path):match = _find_temporal_install_call(captured)assert match is not Nonecall = match[1]- assert call.get("cwd") == tmp_path / "server", (- f"temporal install must cwd into server/, got {call.get('cwd')}"- )+ assert (+ call.get("cwd") == tmp_path / "server"+ ), f"temporal install must cwd into server/, got {call.get('cwd')}"def test_temporal_install_is_fatal_on_failure(tmp_path: Path):@@ -298,9 +310,9 @@ def test_temporal_install_is_fatal_on_failure(tmp_path: Path):assert match is not Nonecall = match[1]# ``check`` defaults to True in ``cli.run.run`` — assert no override.- assert call.get("check", True) is True, (- "temporal install must keep check=True so build aborts on fetch failure"- )+ assert (+ call.get("check", True) is True+ ), "temporal install must keep check=True so build aborts on fetch failure"def test_temporal_install_runs_after_uv_sync(tmp_path: Path):@@ -312,24 +324,25 @@ def test_temporal_install_runs_after_uv_sync(tmp_path: Path):uv_sync = _find_call(captured, lambda c: c[:2] == ["uv", "sync"])temporal = _find_temporal_install_call(captured)assert uv_sync is not None and temporal is not None- assert uv_sync[0] < temporal[0], (- f"uv_sync idx {uv_sync[0]} must precede temporal install idx {temporal[0]}"- )+ assert (+ uv_sync[0] < temporal[0]+ ), f"uv_sync idx {uv_sync[0]} must precede temporal install idx {temporal[0]}"def test_only_one_temporal_install_invocation(tmp_path: Path):"""Temporal install must fire exactly once per build."""captured = _run_build_capture_invocations(tmp_path)matches = [c for c in captured if "services.temporal._install" in c["argv"]]- assert len(matches) == 1, (- f"expected exactly 1 temporal install call, got {len(matches)}"- )+ assert (+ len(matches) == 1+ ), f"expected exactly 1 temporal install call, got {len(matches)}"# ---------------------------------------------------------------------------# Step ordering invariants# ---------------------------------------------------------------------------+def test_pipeline_order_client_then_sidecar_then_uv_then_compileall(tmp_path: Path):"""Full ordering invariant for the new pipeline:@@ -346,8 +359,12 @@ def test_pipeline_order_client_then_sidecar_then_uv_then_compileall(tmp_path: Pasidecar = _find_call(captured, lambda c: "machinaos-nodejs-executor" in c)uv_sync = _find_call(captured, lambda c: c[:2] == ["uv", "sync"])compileall = _find_call(captured, lambda c: "compileall" in c)- for label, match in (("client", client), ("sidecar", sidecar),- ("uv_sync", uv_sync), ("compileall", compileall)):+ for label, match in (+ ("client", client),+ ("sidecar", sidecar),+ ("uv_sync", uv_sync),+ ("compileall", compileall),+ ):assert match is not None, f"missing pipeline step: {label}"indices = [client[0], sidecar[0], uv_sync[0], compileall[0]]assert indices == sorted(indices), (diff --git a/cli/tests/test_daemon.py b/cli/tests/test_daemon.pyindex 71fdd979..1c8cecc1 100644--- a/cli/tests/test_daemon.py+++ b/cli/tests/test_daemon.py@@ -27,6 +27,7 @@ from cli.commands.daemon import _state, status, stop# ---------------------------------------------------------------- helpers+def test_detached_kwargs_windows_uses_creationflags():# subprocess.DETACHED_PROCESS and CREATE_NEW_PROCESS_GROUP are only# defined on Windows. Patching them in with ``create=True`` lets the@@ -36,9 +37,13 @@ def test_detached_kwargs_windows_uses_creationflags():# Real values from windows.h: DETACHED_PROCESS=0x08, GROUP=0x200.fake_detached = 0x00000008fake_new_group = 0x00000200- with patch.object(_state, "IS_WINDOWS", True), \- patch.object(subprocess, "DETACHED_PROCESS", fake_detached, create=True), \- patch.object(subprocess, "CREATE_NEW_PROCESS_GROUP", fake_new_group, create=True):+ with (+ patch.object(_state, "IS_WINDOWS", True),+ patch.object(subprocess, "DETACHED_PROCESS", fake_detached, create=True),+ patch.object(+ subprocess, "CREATE_NEW_PROCESS_GROUP", fake_new_group, create=True+ ),+ ):kw = _state.detached_kwargs()assert "creationflags" in kwassert kw["creationflags"] == fake_detached | fake_new_group@@ -66,21 +71,26 @@ def test_read_pid_returns_none_for_corrupt_pid_file(tmp_path: Path):def test_read_pid_returns_none_when_process_no_longer_exists(tmp_path: Path):pid_path = tmp_path / "cli.pid"pid_path.write_text("999999")- with patch.object(_state, "pid_file", return_value=pid_path), \- patch.object(_state.psutil, "pid_exists", return_value=False):+ with (+ patch.object(_state, "pid_file", return_value=pid_path),+ patch.object(_state.psutil, "pid_exists", return_value=False),+ ):assert _state.read_pid() is Nonedef test_read_pid_returns_pid_when_alive(tmp_path: Path):pid_path = tmp_path / "cli.pid"pid_path.write_text("1234\n")- with patch.object(_state, "pid_file", return_value=pid_path), \- patch.object(_state.psutil, "pid_exists", return_value=True):+ with (+ patch.object(_state, "pid_file", return_value=pid_path),+ patch.object(_state.psutil, "pid_exists", return_value=True),+ ):assert _state.read_pid() == 1234# ---------------------------------------------------------------- kill_tree+def test_kill_tree_terminates_children_and_parent():parent = MagicMock()child1 = MagicMock()@@ -111,6 +121,7 @@ def test_kill_tree_no_such_process_is_noop():# ---------------------------------------------------------------- verbs+def test_stop_command_clears_pid_file_when_not_running(tmp_path: Path):# ``stop`` module imports ``pid_file`` / ``read_pid`` by name from# ``_state``, so the patches must target the consumer's namespace@@ -119,15 +130,20 @@ def test_stop_command_clears_pid_file_when_not_running(tmp_path: Path):# https://docs.python.org/3/library/unittest.mock.html#where-to-patch.pid_path = tmp_path / "cli.pid"pid_path.write_text("999999")- with patch.object(stop, "pid_file", return_value=pid_path), \- patch.object(stop, "read_pid", return_value=None):+ with (+ patch.object(stop, "pid_file", return_value=pid_path),+ patch.object(stop, "read_pid", return_value=None),+ ):stop.stop_command()assert not pid_path.exists()def test_status_command_exits_1_when_not_running():import typer- with patch.object(status, "read_pid", return_value=None), \- pytest.raises(typer.Exit) as exc:++ with (+ patch.object(status, "read_pid", return_value=None),+ pytest.raises(typer.Exit) as exc,+ ):status.status_command()assert exc.value.exit_code == 1diff --git a/cli/tests/test_docs.py b/cli/tests/test_docs.pyindex 68ca55d1..058fa9bd 100644--- a/cli/tests/test_docs.py+++ b/cli/tests/test_docs.py@@ -59,9 +59,7 @@ def test_collect_registry_keys_scrapes_type_attribute(tmp_path: Path):plugin = tmp_path / "category" / "node.py"plugin.parent.mkdir(parents=True)plugin.write_text(- 'class FooNode:\n'- ' type: str = "fooNode"\n'- ' other = "ignored"\n',+ "class FooNode:\n" ' type: str = "fooNode"\n' ' other = "ignored"\n',encoding="utf-8",)keys = docs._collect_registry_keys(tmp_path)diff --git a/cli/tests/test_ports.py b/cli/tests/test_ports.pyindex 93eedadb..7412d369 100644--- a/cli/tests/test_ports.py+++ b/cli/tests/test_ports.py@@ -34,6 +34,7 @@ def test_kill_pid_force_kills_on_timeout():def test_kill_port_excludes_self():"""The function must never kill its own PID."""import os+my_pid = os.getpid()with patch.object(ports, "find_pids_by_port", side_effect=[{my_pid}, set()]):result = ports.kill_port(9999)diff --git a/cli/tests/test_release_pipeline_config.py b/cli/tests/test_release_pipeline_config.pyindex 21b28c93..d5822113 100644--- a/cli/tests/test_release_pipeline_config.py+++ b/cli/tests/test_release_pipeline_config.py@@ -88,15 +88,16 @@ def install_js_src(root: Path) -> str:# Node.js sidecar — package.json & .gitignore# ---------------------------------------------------------------------------+def test_sidecar_start_runs_compiled_bundle(sidecar_pkg: dict):"""``npm start`` runs the esbuild-bundled output, not interpretedTypeScript via tsx. tsx adds ~500ms-1s of interpreter startup thatthe bundle eliminates."""start = sidecar_pkg["scripts"]["start"]- assert start == "node dist/index.js", (- f"sidecar start must be `node dist/index.js`, got {start!r}"- )+ assert (+ start == "node dist/index.js"+ ), f"sidecar start must be `node dist/index.js`, got {start!r}"assert "tsx" not in start@@ -108,17 +109,22 @@ def test_sidecar_dev_keeps_tsx_for_hot_reload(sidecar_pkg: dict):assert "tsx" in dev and "watch" in dev[email protected]("flag", [- "esbuild",- "src/index.ts",- "--bundle",- "--platform=node",- "--target=node22",- "--format=esm",- "--packages=external",- "--outfile=dist/index.js",-])-def test_sidecar_build_script_carries_required_esbuild_flag(sidecar_pkg: dict, flag: str):+ "flag",+ [+ "esbuild",+ "src/index.ts",+ "--bundle",+ "--platform=node",+ "--target=node22",+ "--format=esm",+ "--packages=external",+ "--outfile=dist/index.js",+ ],+)+def test_sidecar_build_script_carries_required_esbuild_flag(+ sidecar_pkg: dict, flag: str+):"""Each esbuild flag in the sidecar build script is load-bearing.- ``--bundle`` — concat the executor's own TS into one file.@@ -167,15 +173,17 @@ def test_sidecar_dist_is_gitignored(sidecar_dir: Path):"""gitignore = (sidecar_dir / ".gitignore").read_text(encoding="utf-8")lines = {line.strip() for line in gitignore.splitlines()}- assert {"dist/", "dist"} & lines, (- f"sidecar .gitignore must list dist/, got:\n{gitignore}"- )+ assert {+ "dist/",+ "dist",+ } & lines, f"sidecar .gitignore must list dist/, got:\n{gitignore}"# ---------------------------------------------------------------------------# Client TypeScript / Vite# ---------------------------------------------------------------------------+def test_client_typecheck_uses_tsgo(client_pkg: dict):"""The fast type-check (``pnpm run typecheck``) goes through tsgo(Microsoft's Go-port of tsc, ~5x faster). The slower tsc fallback@@ -183,9 +191,9 @@ def test_client_typecheck_uses_tsgo(client_pkg: dict):dev release."""scripts = client_pkg["scripts"]- assert scripts.get("typecheck") == "tsgo --noEmit", (- f"client typecheck must be tsgo, got {scripts.get('typecheck')!r}"- )+ assert (+ scripts.get("typecheck") == "tsgo --noEmit"+ ), f"client typecheck must be tsgo, got {scripts.get('typecheck')!r}"assert scripts.get("typecheck:tsc") == "tsc --noEmit", ("tsc fallback (typecheck:tsc) must remain available so a tsgo ""regression has a one-line revert path"@@ -198,22 +206,25 @@ def test_tsgo_devdependency_is_pinned_exactly(client_pkg: dict):install. Pin the exact version so upgrades are explicit."""version = client_pkg.get("devDependencies", {}).get("@typescript/native-preview")- assert version is not None, (- "@typescript/native-preview must be in client devDependencies"- )- assert not version.startswith(("^", "~", ">=", ">", "<")), (- f"tsgo must be pinned exactly (no range prefix), got {version!r}"- )--[email protected]("chunk_name", [- "vendor-react",- "vendor-flow",- "vendor-radix",- "vendor-icons",- "vendor-query",- "vendor-markdown",-])+ assert (+ version is not None+ ), "@typescript/native-preview must be in client devDependencies"+ assert not version.startswith(+ ("^", "~", ">=", ">", "<")+ ), f"tsgo must be pinned exactly (no range prefix), got {version!r}"+++ "chunk_name",+ [+ "vendor-react",+ "vendor-flow",+ "vendor-radix",+ "vendor-icons",+ "vendor-query",+ "vendor-markdown",+ ],+)def test_vite_config_declares_required_vendor_chunk(client_dir: Path, chunk_name: str):"""Vite must split the heavy npm libs into named vendor chunks sothe main bundle stays lean and dep churn doesn't bust the user's@@ -238,9 +249,9 @@ def test_vite_config_targets_es2022(client_dir: Path):Safari 15.4+ — within React 19 / Tailwind 4's baseline)."""src = (client_dir / "vite.config.js").read_text(encoding="utf-8")- assert re.search(r"target:\s*['\"]es2022['\"]", src), (- "vite.config.js must declare `target: 'es2022'` in build options"- )+ assert re.search(+ r"target:\s*['\"]es2022['\"]", src+ ), "vite.config.js must declare `target: 'es2022'` in build options"def test_vite_config_chunk_warning_below_one_megabyte(client_dir: Path):@@ -272,9 +283,9 @@ def test_tsconfig_drops_baseurl_and_sets_typeroots(client_dir: Path):src,), "typeRoots must point at ./node_modules/@types for tsgo + pnpm"# The path alias must survive the baseUrl removal.- assert re.search(r'"@/\*":\s*\["\./src/\*"\]', src), (- "the `@/*` -> `./src/*` alias must remain configured"- )+ assert re.search(+ r'"@/\*":\s*\["\./src/\*"\]', src+ ), "the `@/*` -> `./src/*` alias must remain configured"def test_vite_env_dts_references_google_maps(client_dir: Path):@@ -299,15 +310,16 @@ def test_test_setup_intersection_observer_has_scroll_margin(client_dir: Path):"""src = (client_dir / "src" / "test" / "setup.ts").read_text(encoding="utf-8")assert "IntersectionObserverStub" in src- assert re.search(r"scrollMargin\s*=\s*['\"]['\"]", src), (- "IntersectionObserverStub must set scrollMargin to satisfy TS 7"- )+ assert re.search(+ r"scrollMargin\s*=\s*['\"]['\"]", src+ ), "IntersectionObserverStub must set scrollMargin to satisfy TS 7"# ---------------------------------------------------------------------------# CI gate — predeploy.yml# ---------------------------------------------------------------------------+def _step_by_name(job: dict, step_name: str) -> dict | None:for step in job.get("steps", []):if step.get("name") == step_name:@@ -325,12 +337,12 @@ def test_predeploy_typecheck_step_routes_through_pnpm_script(predeploy_yml: dictstep = _step_by_name(job, "TypeScript check")assert step is not None, "predeploy.yml must define a `TypeScript check` step"cmd = step.get("run", "")- assert "run typecheck" in cmd, (- f"predeploy.yml typecheck step must call `pnpm ... run typecheck`, got {cmd!r}"- )- assert CLIENT_PKG_NAME in cmd, (- f"predeploy.yml typecheck step must filter to {CLIENT_PKG_NAME}, got {cmd!r}"- )+ assert (+ "run typecheck" in cmd+ ), f"predeploy.yml typecheck step must call `pnpm ... run typecheck`, got {cmd!r}"+ assert (+ CLIENT_PKG_NAME in cmd+ ), f"predeploy.yml typecheck step must filter to {CLIENT_PKG_NAME}, got {cmd!r}"assert "tsc --noEmit" not in cmd, ("predeploy.yml still calls `tsc --noEmit` directly — switch to ""the typecheck script so tsgo is used"@@ -355,9 +367,9 @@ def test_install_js_compileall_command_shape(install_js_src: str):``uv run python -O -m compileall -q -j 0`` — so cold-start gainsapply to the npm-tarball path too."""- assert _INSTALL_JS_COMPILEALL_RE.search(install_js_src) is not None, (- "install.js must run `uv run python -O -m compileall -q -j 0 ...`"- )+ assert (+ _INSTALL_JS_COMPILEALL_RE.search(install_js_src) is not None+ ), "install.js must run `uv run python -O -m compileall -q -j 0 ...`"def test_install_js_compileall_paths_match_source_dirs_constant(install_js_src: str):diff --git a/cli/tests/test_supervisor.py b/cli/tests/test_supervisor.pyindex fed95c28..441d1fc4 100644--- a/cli/tests/test_supervisor.py+++ b/cli/tests/test_supervisor.py@@ -38,6 +38,7 @@ def test_service_spec_defaults_safe():def test_crash_window_logic():"""Sliding-window detection: 5 deaths within window => give up."""import time+crashes = deque(maxlen=5)spec = ServiceSpec(name="x", argv=["true"])now = time.monotonic()@@ -53,6 +54,7 @@ def test_crash_window_logic():async def test_manager_runs_clean_exit_service():"""A NEVER-restart service that exits 0 should let the manager finish cleanly."""import sys+m = Manager()m.add(ServiceSpec(diff --git a/cli/tree.py b/cli/tree.pyindex 55ffa621..de51c6d1 100644--- a/cli/tree.py+++ b/cli/tree.py@@ -41,6 +41,7 @@ import psutil# ---------------------------------------------------------------- POSIX / Windows spawn kwargs+def new_session_kwargs() -> dict:"""``Popen``/``open_process`` kwargs to spawn the child in its own group.@@ -71,6 +72,7 @@ def signal_group(pid: int, sig: signal.Signals = signal.SIGTERM) -> None:# ---------------------------------------------------------------- Windows Job Object+class _JobObject:"""Lazy-imported wrapper around a Windows Job Object.@@ -178,6 +180,7 @@ def add_to_job(pid: int) -> bool:# --------------------------------------------------------------- Tree kill+def kill_tree(pid: int) -> None:"""Cross-platform tree-kill via psutil. Defensive against races."""try:diff --git a/scripts/migrate_icons.py b/scripts/migrate_icons.pyindex 94d99ede..2ceddc24 100644--- a/scripts/migrate_icons.py+++ b/scripts/migrate_icons.py@@ -135,7 +135,9 @@ def main() -> int:print(f" migrated {rel} -> lucide:{used}")else:skipped += 1- print(f"\n {migrated} files migrated, {skipped} skipped (no emoji icon to migrate).")+ print(+ f"\n {migrated} files migrated, {skipped} skipped (no emoji icon to migrate)."+ )return 0diff --git a/scripts/migrate_skill_icons.py b/scripts/migrate_skill_icons.pyindex 36728ffd..ed95b521 100644--- a/scripts/migrate_skill_icons.py+++ b/scripts/migrate_skill_icons.py@@ -87,8 +87,8 @@ EMOJI_TO_LUCIDE: dict[str, str] = {"🔄": "RotateCw","🔀": "Shuffle","📜": "Scroll",- "🐧": "Terminal", # bash skill (Linux penguin -> terminal)- "🐍": "Code2", # python skill default; ASSET_OVERRIDES wins+ "🐧": "Terminal", # bash skill (Linux penguin -> terminal)+ "🐍": "Code2", # python skill default; ASSET_OVERRIDES wins"📅": "Calendar",# User-typed library identifier without the prefix:"brain": "Brain",@@ -159,10 +159,7 @@ def main() -> int:decoded = m.group("value")if decoded.startswith(("asset:", "lobehub:", "lucide:")):continue- if (- f.parent.name not in ASSET_OVERRIDES- and decoded not in EMOJI_TO_LUCIDE- ):+ if f.parent.name not in ASSET_OVERRIDES and decoded not in EMOJI_TO_LUCIDE:unmapped.append((f, decoded))changed, used = migrate_file(f)@@ -173,7 +170,9 @@ def main() -> int:else:skipped += 1- print(f"\n {migrated} files migrated, {skipped} skipped (no emoji icon to migrate).")+ print(+ f"\n {migrated} files migrated, {skipped} skipped (no emoji icon to migrate)."+ )if unmapped:print("\nUNMAPPED (please add to mapping):")for f, val in unmapped:diff --git a/server/config/model_registry.json b/server/config/model_registry.jsonindex 7c139767..df10b06c 100644--- a/server/config/model_registry.json+++ b/server/config/model_registry.json@@ -1,17 +1,137 @@{- "_generated": "2026-05-11T09:41:56.766905+00:00",+ "_generated": "2026-05-21T10:40:49.693780+00:00","_source": "openrouter",- "_model_count": 365,+ "_model_count": 358,"models": {- "inclusionai/ring-2.6-1t:free": {- "id": "inclusionai/ring-2.6-1t:free",- "name": "inclusionAI: Ring-2.6-1T (free)",+ "xai/grok-build-0.1": {+ "id": "x-ai/grok-build-0.1",+ "name": "xAI: Grok Build 0.1",+ "provider": "xai",+ "local_id": "grok-build-0.1",+ "context_length": 256000,+ "max_output_tokens": 0,+ "input_price_per_mtok": 1.0,+ "output_price_per_mtok": 2.0,+ "supports_thinking": false,+ "thinking_type": "none",+ "temperature_range": [+ 0.0,+ 2.0+ ],+ "is_reasoning_model": false,+ "supported_parameters": [+ "frequency_penalty",+ "include_reasoning",+ "logprobs",+ "max_tokens",+ "presence_penalty",+ "reasoning",+ "response_format",+ "seed",+ "stop",+ "structured_outputs",+ "temperature",+ "tool_choice",+ "tools",+ "top_logprobs",+ "top_p"+ ]+ },+ "gemini/gemini-3.5-flash": {+ "id": "google/gemini-3.5-flash",+ "name": "Google: Gemini 3.5 Flash",+ "provider": "gemini",+ "local_id": "gemini-3.5-flash",+ "context_length": 1048576,+ "max_output_tokens": 65536,+ "input_price_per_mtok": 1.5,+ "output_price_per_mtok": 9.0,+ "supports_thinking": true,+ "thinking_type": "budget",+ "temperature_range": [+ 0.0,+ 2.0+ ],+ "is_reasoning_model": false,+ "supported_parameters": [+ "include_reasoning",+ "max_tokens",+ "reasoning",+ "response_format",+ "seed",+ "stop",+ "structured_outputs",+ "temperature",+ "tool_choice",+ "tools",+ "top_p"+ ]+ },+ "anthropic/claude-opus-4.7-fast": {+ "id": "anthropic/claude-opus-4.7-fast",+ "name": "Anthropic: Claude Opus 4.7 (Fast)",+ "provider": "anthropic",+ "local_id": "claude-opus-4.7-fast",+ "context_length": 1000000,+ "max_output_tokens": 128000,+ "input_price_per_mtok": 30.0,+ "output_price_per_mtok": 150.0,+ "supports_thinking": true,+ "thinking_type": "budget",+ "temperature_range": [+ 0.0,+ 1.0+ ],+ "is_reasoning_model": false,+ "supported_parameters": [+ "include_reasoning",+ "max_tokens",+ "reasoning",+ "response_format",+ "stop",+ "structured_outputs",+ "tool_choice",+ "tools",+ "verbosity"+ ]+ },+ "perceptron/perceptron-mk1": {+ "id": "perceptron/perceptron-mk1",+ "name": "Perceptron: Perceptron Mk1",+ "provider": "perceptron",+ "local_id": "perceptron-mk1",+ "context_length": 32768,+ "max_output_tokens": 8192,+ "input_price_per_mtok": 0.15,+ "output_price_per_mtok": 1.5,+ "supports_thinking": false,+ "thinking_type": "none",+ "temperature_range": [+ 0.0,+ 2.0+ ],+ "is_reasoning_model": false,+ "supported_parameters": [+ "frequency_penalty",+ "include_reasoning",+ "max_tokens",+ "presence_penalty",+ "reasoning",+ "structured_outputs",+ "temperature",+ "top_k",+ "top_p"+ ]+ },+ "inclusionai/ring-2.6-1t": {+ "id": "inclusionai/ring-2.6-1t",+ "name": "inclusionAI: Ring-2.6-1T","provider": "inclusionai",- "local_id": "ring-2.6-1t:free",+ "local_id": "ring-2.6-1t","context_length": 262144,"max_output_tokens": 65536,- "input_price_per_mtok": 0.0,- "output_price_per_mtok": 0.0,+ "input_price_per_mtok": 0.075,+ "output_price_per_mtok": 0.625,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -26,6 +146,7 @@"presence_penalty","reasoning","repetition_penalty",+ "response_format","seed","stop","temperature",@@ -421,9 +542,9 @@"provider": "~moonshotai","local_id": "kimi-latest","context_length": 262144,- "max_output_tokens": 16384,- "input_price_per_mtok": 0.75,- "output_price_per_mtok": 3.5,+ "max_output_tokens": 262142,+ "input_price_per_mtok": 0.73,+ "output_price_per_mtok": 3.49,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -462,8 +583,8 @@"local_id": "gemini-flash-latest","context_length": 1048576,"max_output_tokens": 65536,- "input_price_per_mtok": 0.5,- "output_price_per_mtok": 3.0,+ "input_price_per_mtok": 1.5,+ "output_price_per_mtok": 9.0,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -552,8 +673,8 @@"local_id": "qwen3.5-plus-20260420","context_length": 1000000,"max_output_tokens": 65536,- "input_price_per_mtok": 0.4,- "output_price_per_mtok": 2.4,+ "input_price_per_mtok": 0.3,+ "output_price_per_mtok": 1.8,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -582,8 +703,8 @@"local_id": "qwen3.6-flash","context_length": 1000000,"max_output_tokens": 65536,- "input_price_per_mtok": 0.25,- "output_price_per_mtok": 1.5,+ "input_price_per_mtok": 0.1875,+ "output_price_per_mtok": 1.125,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -611,8 +732,8 @@"provider": "qwen","local_id": "qwen3.6-35b-a3b","context_length": 262144,- "max_output_tokens": 262144,- "input_price_per_mtok": 0.15,+ "max_output_tokens": 0,+ "input_price_per_mtok": 0.149,"output_price_per_mtok": 1.0,"supports_thinking": false,"thinking_type": "none",@@ -625,6 +746,7 @@"frequency_penalty","include_reasoning","logit_bias",+ "logprobs","max_tokens","min_p","presence_penalty",@@ -638,6 +760,7 @@"tool_choice","tools","top_k",+ "top_logprobs","top_p"]},@@ -804,15 +927,38 @@"top_p"]},+ "deepseek/deepseek-v4-flash:free": {+ "id": "deepseek/deepseek-v4-flash:free",+ "name": "DeepSeek: DeepSeek V4 Flash (free)",+ "provider": "deepseek",+ "local_id": "deepseek-v4-flash:free",+ "context_length": 1048576,+ "max_output_tokens": 384000,+ "input_price_per_mtok": 0.0,+ "output_price_per_mtok": 0.0,+ "supports_thinking": false,+ "thinking_type": "none",+ "temperature_range": [+ 0.0,+ 2.0+ ],+ "is_reasoning_model": false,+ "supported_parameters": [+ "include_reasoning",+ "reasoning",+ "tool_choice",+ "tools"+ ]+ },"deepseek/deepseek-v4-flash": {"id": "deepseek/deepseek-v4-flash","name": "DeepSeek: DeepSeek V4 Flash","provider": "deepseek","local_id": "deepseek-v4-flash","context_length": 1048576,- "max_output_tokens": 384000,- "input_price_per_mtok": 0.14,- "output_price_per_mtok": 0.28,+ "max_output_tokens": 0,+ "input_price_per_mtok": 0.112,+ "output_price_per_mtok": 0.224,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -849,8 +995,8 @@"local_id": "ling-2.6-1t","context_length": 262144,"max_output_tokens": 32768,- "input_price_per_mtok": 0.3,- "output_price_per_mtok": 2.5,+ "input_price_per_mtok": 0.075,+ "output_price_per_mtok": 0.625,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -1008,8 +1154,8 @@"local_id": "ling-2.6-flash","context_length": 262144,"max_output_tokens": 32768,- "input_price_per_mtok": 0.08,- "output_price_per_mtok": 0.24,+ "input_price_per_mtok": 0.01,+ "output_price_per_mtok": 0.03,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -1079,15 +1225,15 @@"is_reasoning_model": false,"supported_parameters": []},- "baidu/qianfan-ocr-fast:free": {- "id": "baidu/qianfan-ocr-fast:free",- "name": "Baidu: Qianfan-OCR-Fast (free)",+ "baidu/qianfan-ocr-fast": {+ "id": "baidu/qianfan-ocr-fast",+ "name": "Baidu: Qianfan-OCR-Fast","provider": "baidu",- "local_id": "qianfan-ocr-fast:free",+ "local_id": "qianfan-ocr-fast","context_length": 65536,"max_output_tokens": 28672,- "input_price_per_mtok": 0.0,- "output_price_per_mtok": 0.0,+ "input_price_per_mtok": 0.68,+ "output_price_per_mtok": 2.81,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -1114,9 +1260,9 @@"provider": "moonshotai","local_id": "kimi-k2.6","context_length": 262144,- "max_output_tokens": 16384,- "input_price_per_mtok": 0.75,- "output_price_per_mtok": 3.5,+ "max_output_tokens": 262142,+ "input_price_per_mtok": 0.73,+ "output_price_per_mtok": 3.49,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -1211,10 +1357,10 @@"name": "Z.ai: GLM 5.1","provider": "z-ai","local_id": "glm-5.1",- "context_length": 202752,- "max_output_tokens": 65535,- "input_price_per_mtok": 1.05,- "output_price_per_mtok": 3.5,+ "context_length": 202800,+ "max_output_tokens": 202800,+ "input_price_per_mtok": 0.0,+ "output_price_per_mtok": 0.0,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -1347,8 +1493,8 @@"local_id": "gemma-4-31b-it","context_length": 262144,"max_output_tokens": 16384,- "input_price_per_mtok": 0.13,- "output_price_per_mtok": 0.38,+ "input_price_per_mtok": 0.12,+ "output_price_per_mtok": 0.37,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -1435,6 +1581,33 @@"top_p"]},+ "arcee-ai/trinity-large-thinking:free": {+ "id": "arcee-ai/trinity-large-thinking:free",+ "name": "Arcee AI: Trinity Large Thinking (free)",+ "provider": "arcee-ai",+ "local_id": "trinity-large-thinking:free",+ "context_length": 262144,+ "max_output_tokens": 80000,+ "input_price_per_mtok": 0.0,+ "output_price_per_mtok": 0.0,+ "supports_thinking": false,+ "thinking_type": "none",+ "temperature_range": [+ 0.0,+ 2.0+ ],+ "is_reasoning_model": false,+ "supported_parameters": [+ "include_reasoning",+ "max_tokens",+ "reasoning",+ "temperature",+ "tool_choice",+ "tools",+ "top_k",+ "top_p"+ ]+ },"arcee-ai/trinity-large-thinking": {"id": "arcee-ai/trinity-large-thinking","name": "Arcee AI: Trinity Large Thinking",@@ -1707,9 +1880,9 @@"name": "MiniMax: MiniMax M2.7","provider": "minimax","local_id": "minimax-m2.7",- "context_length": 196608,+ "context_length": 204800,"max_output_tokens": 131072,- "input_price_per_mtok": 0.299,+ "input_price_per_mtok": 0.279,"output_price_per_mtok": 1.2,"supports_thinking": false,"thinking_type": "none",@@ -1869,7 +2042,7 @@"name": "NVIDIA: Nemotron 3 Super (free)","provider": "nvidia","local_id": "nemotron-3-super-120b-a12b:free",- "context_length": 262144,+ "context_length": 1000000,"max_output_tokens": 262144,"input_price_per_mtok": 0.0,"output_price_per_mtok": 0.0,@@ -1898,7 +2071,7 @@"name": "NVIDIA: Nemotron 3 Super","provider": "nvidia","local_id": "nemotron-3-super-120b-a12b",- "context_length": 262144,+ "context_length": 1000000,"max_output_tokens": 0,"input_price_per_mtok": 0.09,"output_price_per_mtok": 0.45,@@ -2173,7 +2346,7 @@"name": "Google: Nano Banana 2 (Gemini 3.1 Flash Image Preview)","provider": "gemini","local_id": "gemini-3.1-flash-image-preview",- "context_length": 65536,+ "context_length": 131072,"max_output_tokens": 65536,"input_price_per_mtok": 0.5,"output_price_per_mtok": 3.0,@@ -2202,8 +2375,8 @@"provider": "qwen","local_id": "qwen3.5-35b-a3b","context_length": 262144,- "max_output_tokens": 81920,- "input_price_per_mtok": 0.14,+ "max_output_tokens": 0,+ "input_price_per_mtok": 0.139,"output_price_per_mtok": 1.0,"supports_thinking": false,"thinking_type": "none",@@ -2345,7 +2518,7 @@"name": "LiquidAI: LFM2-24B-A2B","provider": "liquid","local_id": "lfm-2-24b-a2b",- "context_length": 32768,+ "context_length": 128000,"max_output_tokens": 0,"input_price_per_mtok": 0.03,"output_price_per_mtok": 0.12,@@ -2374,7 +2547,7 @@"name": "Google: Gemini 3.1 Pro Preview Custom Tools","provider": "gemini","local_id": "gemini-3.1-pro-preview-customtools",- "context_length": 1048576,+ "context_length": 1048756,"max_output_tokens": 65536,"input_price_per_mtok": 2.0,"output_price_per_mtok": 12.0,@@ -2586,7 +2759,7 @@"name": "MiniMax: MiniMax M2.5 (free)","provider": "minimax","local_id": "minimax-m2.5:free",- "context_length": 196608,+ "context_length": 204800,"max_output_tokens": 8192,"input_price_per_mtok": 0.0,"output_price_per_mtok": 0.0,@@ -2613,7 +2786,7 @@"name": "MiniMax: MiniMax M2.5","provider": "minimax","local_id": "minimax-m2.5",- "context_length": 196608,+ "context_length": 204800,"max_output_tokens": 196608,"input_price_per_mtok": 0.15,"output_price_per_mtok": 1.15,@@ -2668,7 +2841,6 @@"frequency_penalty","include_reasoning","logit_bias",- "logprobs","max_tokens","min_p","presence_penalty",@@ -2682,7 +2854,6 @@"tool_choice","tools","top_k",- "top_logprobs","top_p"]},@@ -2823,8 +2994,8 @@"provider": "stepfun","local_id": "step-3.5-flash","context_length": 262144,- "max_output_tokens": 65536,- "input_price_per_mtok": 0.1,+ "max_output_tokens": 16384,+ "input_price_per_mtok": 0.09,"output_price_per_mtok": 0.3,"supports_thinking": false,"thinking_type": "none",@@ -2886,7 +3057,7 @@"context_length": 262144,"max_output_tokens": 262144,"input_price_per_mtok": 0.4,- "output_price_per_mtok": 1.98,+ "output_price_per_mtok": 1.9,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -3244,7 +3415,7 @@"name": "MiniMax: MiniMax M2.1","provider": "minimax","local_id": "minimax-m2.1",- "context_length": 196608,+ "context_length": 204800,"max_output_tokens": 196608,"input_price_per_mtok": 0.29,"output_price_per_mtok": 0.95,@@ -3598,6 +3769,7 @@"presence_penalty","reasoning","repetition_penalty",+ "response_format","seed","stop","temperature",@@ -4094,37 +4266,6 @@"top_p"]},- "xai/grok-4.1-fast": {- "id": "x-ai/grok-4.1-fast",- "name": "xAI: Grok 4.1 Fast",- "provider": "xai",- "local_id": "grok-4.1-fast",- "context_length": 2000000,- "max_output_tokens": 30000,- "input_price_per_mtok": 0.2,- "output_price_per_mtok": 0.5,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "include_reasoning",- "logprobs",- "max_tokens",- "reasoning",- "response_format",- "seed",- "structured_outputs",- "temperature",- "tool_choice",- "tools",- "top_logprobs",- "top_p"- ]- },"deepcogito/cogito-v2.1-671b": {"id": "deepcogito/cogito-v2.1-671b","name": "Deep Cogito: Cogito v2.1 671B",@@ -4449,7 +4590,7 @@"name": "MiniMax: MiniMax M2","provider": "minimax","local_id": "minimax-m2",- "context_length": 196608,+ "context_length": 204800,"max_output_tokens": 196608,"input_price_per_mtok": 0.255,"output_price_per_mtok": 1.0,@@ -4485,7 +4626,7 @@"name": "Qwen: Qwen3 VL 32B Instruct","provider": "qwen","local_id": "qwen3-vl-32b-instruct",- "context_length": 131072,+ "context_length": 262144,"max_output_tokens": 32768,"input_price_per_mtok": 0.104,"output_price_per_mtok": 0.416,@@ -4513,9 +4654,9 @@"provider": "ibm-granite","local_id": "granite-4.0-h-micro","context_length": 131000,- "max_output_tokens": 0,+ "max_output_tokens": 131000,"input_price_per_mtok": 0.017,- "output_price_per_mtok": 0.11,+ "output_price_per_mtok": 0.112,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -4525,10 +4666,13 @@"is_reasoning_model": false,"supported_parameters": ["frequency_penalty",+ "logit_bias","max_tokens",+ "min_p","presence_penalty","repetition_penalty","seed",+ "stop","temperature","top_k","top_p"@@ -4539,7 +4683,7 @@"name": "Microsoft: Phi 4 Mini Instruct","provider": "microsoft","local_id": "phi-4-mini-instruct",- "context_length": 128000,+ "context_length": 131072,"max_output_tokens": 128000,"input_price_per_mtok": 0.08,"output_price_per_mtok": 0.35,@@ -4632,7 +4776,7 @@"name": "Qwen: Qwen3 VL 8B Thinking","provider": "qwen","local_id": "qwen3-vl-8b-thinking",- "context_length": 131072,+ "context_length": 256000,"max_output_tokens": 32768,"input_price_per_mtok": 0.117,"output_price_per_mtok": 1.365,@@ -4662,7 +4806,7 @@"name": "Qwen: Qwen3 VL 8B Instruct","provider": "qwen","local_id": "qwen3-vl-8b-instruct",- "context_length": 131072,+ "context_length": 256000,"max_output_tokens": 32768,"input_price_per_mtok": 0.08,"output_price_per_mtok": 0.5,@@ -4924,7 +5068,7 @@"name": "Qwen: Qwen3 VL 30B A3B Instruct","provider": "qwen","local_id": "qwen3-vl-30b-a3b-instruct",- "context_length": 131072,+ "context_length": 262144,"max_output_tokens": 32768,"input_price_per_mtok": 0.13,"output_price_per_mtok": 0.52,@@ -4985,10 +5129,10 @@"name": "Z.ai: GLM 4.6","provider": "z-ai","local_id": "glm-4.6",- "context_length": 204800,- "max_output_tokens": 204800,- "input_price_per_mtok": 0.39,- "output_price_per_mtok": 1.9,+ "context_length": 202752,+ "max_output_tokens": 131072,+ "input_price_per_mtok": 0.43,+ "output_price_per_mtok": 1.74,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -5348,37 +5492,6 @@"top_p"]},- "xai/grok-4-fast": {- "id": "x-ai/grok-4-fast",- "name": "xAI: Grok 4 Fast",- "provider": "xai",- "local_id": "grok-4-fast",- "context_length": 2000000,- "max_output_tokens": 30000,- "input_price_per_mtok": 0.2,- "output_price_per_mtok": 0.5,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "include_reasoning",- "logprobs",- "max_tokens",- "reasoning",- "response_format",- "seed",- "structured_outputs",- "temperature",- "tool_choice",- "tools",- "top_logprobs",- "top_p"- ]- },"alibaba/tongyi-deepresearch-30b-a3b": {"id": "alibaba/tongyi-deepresearch-30b-a3b","name": "Tongyi DeepResearch 30B A3B",@@ -5447,7 +5560,7 @@"name": "Qwen: Qwen3 Next 80B A3B Thinking","provider": "qwen","local_id": "qwen3-next-80b-a3b-thinking",- "context_length": 131072,+ "context_length": 262144,"max_output_tokens": 32768,"input_price_per_mtok": 0.0975,"output_price_per_mtok": 0.78,@@ -5671,8 +5784,8 @@"local_id": "kimi-k2-0905","context_length": 262144,"max_output_tokens": 262144,- "input_price_per_mtok": 0.4,- "output_price_per_mtok": 2.0,+ "input_price_per_mtok": 0.6,+ "output_price_per_mtok": 2.5,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -5734,38 +5847,6 @@"top_p"]},- "xai/grok-code-fast-1": {- "id": "x-ai/grok-code-fast-1",- "name": "xAI: Grok Code Fast 1",- "provider": "xai",- "local_id": "grok-code-fast-1",- "context_length": 256000,- "max_output_tokens": 10000,- "input_price_per_mtok": 0.2,- "output_price_per_mtok": 1.5,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "include_reasoning",- "logprobs",- "max_tokens",- "reasoning",- "response_format",- "seed",- "stop",- "structured_outputs",- "temperature",- "tool_choice",- "tools",- "top_logprobs",- "top_p"- ]- },"nousresearch/hermes-4-70b": {"id": "nousresearch/hermes-4-70b","name": "Nous: Hermes 4 70B",@@ -5829,10 +5910,10 @@"name": "DeepSeek: DeepSeek V3.1","provider": "deepseek","local_id": "deepseek-chat-v3.1",- "context_length": 32768,- "max_output_tokens": 7168,- "input_price_per_mtok": 0.15,- "output_price_per_mtok": 0.75,+ "context_length": 163840,+ "max_output_tokens": 32768,+ "input_price_per_mtok": 0.21,+ "output_price_per_mtok": 0.79,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -5844,7 +5925,6 @@"frequency_penalty","include_reasoning","logit_bias",- "logprobs","max_tokens","min_p","presence_penalty",@@ -5858,7 +5938,6 @@"tool_choice","tools","top_k",- "top_logprobs","top_p"]},@@ -5930,7 +6009,7 @@"name": "Baidu: ERNIE 4.5 21B A3B","provider": "baidu","local_id": "ernie-4.5-21b-a3b",- "context_length": 120000,+ "context_length": 131072,"max_output_tokens": 8000,"input_price_per_mtok": 0.07,"output_price_per_mtok": 0.28,@@ -5960,7 +6039,7 @@"name": "Baidu: ERNIE 4.5 VL 28B A3B","provider": "baidu","local_id": "ernie-4.5-vl-28b-a3b",- "context_length": 30000,+ "context_length": 131072,"max_output_tokens": 8000,"input_price_per_mtok": 0.14,"output_price_per_mtok": 0.56,@@ -6010,6 +6089,7 @@"presence_penalty","reasoning","repetition_penalty",+ "response_format","seed","stop","temperature",@@ -6504,7 +6584,7 @@"name": "Qwen: Qwen3 235B A22B Thinking 2507","provider": "qwen","local_id": "qwen3-235b-a22b-thinking-2507",- "context_length": 131072,+ "context_length": 262144,"max_output_tokens": 0,"input_price_per_mtok": 0.1495,"output_price_per_mtok": 1.495,@@ -6564,7 +6644,7 @@"name": "Qwen: Qwen3 Coder 480B A35B (free)","provider": "qwen","local_id": "qwen3-coder:free",- "context_length": 262000,+ "context_length": 1048576,"max_output_tokens": 262000,"input_price_per_mtok": 0.0,"output_price_per_mtok": 0.0,@@ -6592,7 +6672,7 @@"name": "Qwen: Qwen3 Coder 480B A35B","provider": "qwen","local_id": "qwen3-coder",- "context_length": 262144,+ "context_length": 1048576,"max_output_tokens": 65536,"input_price_per_mtok": 0.22,"output_price_per_mtok": 1.8,@@ -6861,37 +6941,6 @@"top_p"]},- "xai/grok-4": {- "id": "x-ai/grok-4",- "name": "xAI: Grok 4",- "provider": "xai",- "local_id": "grok-4",- "context_length": 256000,- "max_output_tokens": 0,- "input_price_per_mtok": 3.0,- "output_price_per_mtok": 15.0,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "include_reasoning",- "logprobs",- "max_tokens",- "reasoning",- "response_format",- "seed",- "structured_outputs",- "temperature",- "tool_choice",- "tools",- "top_logprobs",- "top_p"- ]- },"tencent/hunyuan-a13b-instruct": {"id": "tencent/hunyuan-a13b-instruct","name": "Tencent: Hunyuan A13B Instruct",@@ -6969,7 +7018,7 @@"name": "Baidu: ERNIE 4.5 VL 424B A47B ","provider": "baidu","local_id": "ernie-4.5-vl-424b-a47b",- "context_length": 123000,+ "context_length": 131072,"max_output_tokens": 16000,"input_price_per_mtok": 0.42,"output_price_per_mtok": 1.25,@@ -6999,7 +7048,7 @@"name": "Baidu: ERNIE 4.5 300B A47B ","provider": "baidu","local_id": "ernie-4.5-300b-a47b",- "context_length": 123000,+ "context_length": 131072,"max_output_tokens": 12000,"input_price_per_mtok": 0.28,"output_price_per_mtok": 1.1,@@ -7015,6 +7064,7 @@"max_tokens","presence_penalty","repetition_penalty",+ "response_format","seed","stop","temperature",@@ -7175,70 +7225,6 @@"tools"]},- "xai/grok-3-mini": {- "id": "x-ai/grok-3-mini",- "name": "xAI: Grok 3 Mini",- "provider": "xai",- "local_id": "grok-3-mini",- "context_length": 131072,- "max_output_tokens": 0,- "input_price_per_mtok": 0.3,- "output_price_per_mtok": 0.5,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "include_reasoning",- "logprobs",- "max_tokens",- "reasoning",- "response_format",- "seed",- "stop",- "structured_outputs",- "temperature",- "tool_choice",- "tools",- "top_logprobs",- "top_p"- ]- },- "xai/grok-3": {- "id": "x-ai/grok-3",- "name": "xAI: Grok 3",- "provider": "xai",- "local_id": "grok-3",- "context_length": 131072,- "max_output_tokens": 0,- "input_price_per_mtok": 3.0,- "output_price_per_mtok": 15.0,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "frequency_penalty",- "logprobs",- "max_tokens",- "presence_penalty",- "response_format",- "seed",- "stop",- "structured_outputs",- "temperature",- "tool_choice",- "tools",- "top_logprobs",- "top_p"- ]- },"gemini/gemini-2.5-pro-preview": {"id": "google/gemini-2.5-pro-preview","name": "Google: Gemini 2.5 Pro Preview 06-05",@@ -7604,7 +7590,7 @@"name": "Qwen: Qwen3 30B A3B","provider": "qwen","local_id": "qwen3-30b-a3b",- "context_length": 40960,+ "context_length": 131072,"max_output_tokens": 20000,"input_price_per_mtok": 0.09,"output_price_per_mtok": 0.45,@@ -7642,7 +7628,7 @@"name": "Qwen: Qwen3 8B","provider": "qwen","local_id": "qwen3-8b",- "context_length": 40960,+ "context_length": 131072,"max_output_tokens": 8192,"input_price_per_mtok": 0.05,"output_price_per_mtok": 0.4,@@ -7678,9 +7664,9 @@"name": "Qwen: Qwen3 14B","provider": "qwen","local_id": "qwen3-14b",- "context_length": 40960,+ "context_length": 131702,"max_output_tokens": 40960,- "input_price_per_mtok": 0.06,+ "input_price_per_mtok": 0.1,"output_price_per_mtok": 0.24,"supports_thinking": false,"thinking_type": "none",@@ -7716,7 +7702,7 @@"name": "Qwen: Qwen3 32B","provider": "qwen","local_id": "qwen3-32b",- "context_length": 40960,+ "context_length": 131072,"max_output_tokens": 16384,"input_price_per_mtok": 0.08,"output_price_per_mtok": 0.28,@@ -7970,68 +7956,6 @@"top_p"]},- "xai/grok-3-mini-beta": {- "id": "x-ai/grok-3-mini-beta",- "name": "xAI: Grok 3 Mini Beta",- "provider": "xai",- "local_id": "grok-3-mini-beta",- "context_length": 131072,- "max_output_tokens": 0,- "input_price_per_mtok": 0.3,- "output_price_per_mtok": 0.5,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "include_reasoning",- "logprobs",- "max_tokens",- "reasoning",- "response_format",- "seed",- "stop",- "temperature",- "tool_choice",- "tools",- "top_logprobs",- "top_p"- ]- },- "xai/grok-3-beta": {- "id": "x-ai/grok-3-beta",- "name": "xAI: Grok 3 Beta",- "provider": "xai",- "local_id": "grok-3-beta",- "context_length": 131072,- "max_output_tokens": 0,- "input_price_per_mtok": 3.0,- "output_price_per_mtok": 15.0,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "frequency_penalty",- "logprobs",- "max_tokens",- "presence_penalty",- "response_format",- "seed",- "stop",- "temperature",- "tool_choice",- "tools",- "top_logprobs",- "top_p"- ]- },"meta/llama-4-maverick": {"id": "meta-llama/llama-4-maverick","name": "Meta: Llama 4 Maverick",@@ -8069,7 +7993,7 @@"name": "Meta: Llama 4 Scout","provider": "meta","local_id": "llama-4-scout",- "context_length": 327680,+ "context_length": 10000000,"max_output_tokens": 16384,"input_price_per_mtok": 0.08,"output_price_per_mtok": 0.3,@@ -8163,9 +8087,9 @@"provider": "mistralai","local_id": "mistral-small-3.1-24b-instruct","context_length": 128000,- "max_output_tokens": 0,- "input_price_per_mtok": 0.35,- "output_price_per_mtok": 0.56,+ "max_output_tokens": 128000,+ "input_price_per_mtok": 0.351,+ "output_price_per_mtok": 0.555,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -8175,10 +8099,13 @@"is_reasoning_model": false,"supported_parameters": ["frequency_penalty",+ "logit_bias","max_tokens",+ "min_p","presence_penalty","repetition_penalty","seed",+ "stop","temperature","top_k","top_p"@@ -8563,8 +8490,8 @@"provider": "meta","local_id": "llama-guard-3-8b","context_length": 131072,- "max_output_tokens": 0,- "input_price_per_mtok": 0.48,+ "max_output_tokens": 131072,+ "input_price_per_mtok": 0.484,"output_price_per_mtok": 0.03,"supports_thinking": false,"thinking_type": "none",@@ -8575,10 +8502,13 @@"is_reasoning_model": false,"supported_parameters": ["frequency_penalty",+ "logit_bias","max_tokens",+ "min_p","presence_penalty","repetition_penalty","seed",+ "stop","temperature","top_k","top_p"@@ -8639,31 +8569,6 @@"top_p"]},- "qwen/qwen-vl-plus": {- "id": "qwen/qwen-vl-plus",- "name": "Qwen: Qwen VL Plus",- "provider": "qwen",- "local_id": "qwen-vl-plus",- "context_length": 131072,- "max_output_tokens": 8192,- "input_price_per_mtok": 0.1365,- "output_price_per_mtok": 0.4095,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "max_tokens",- "presence_penalty",- "response_format",- "seed",- "temperature",- "top_p"- ]- },"aion-labs/aion-1.0": {"id": "aion-labs/aion-1.0","name": "AionLabs: Aion-1.0",@@ -8734,69 +8639,15 @@"top_p"]},- "qwen/qwen-vl-max": {- "id": "qwen/qwen-vl-max",- "name": "Qwen: Qwen VL Max",+ "qwen/qwen2.5-vl-72b-instruct": {+ "id": "qwen/qwen2.5-vl-72b-instruct",+ "name": "Qwen: Qwen2.5 VL 72B Instruct","provider": "qwen",- "local_id": "qwen-vl-max",+ "local_id": "qwen2.5-vl-72b-instruct","context_length": 131072,- "max_output_tokens": 32768,- "input_price_per_mtok": 0.52,- "output_price_per_mtok": 2.08,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "max_tokens",- "presence_penalty",- "response_format",- "seed",- "temperature",- "tool_choice",- "tools",- "top_p"- ]- },- "qwen/qwen-turbo": {- "id": "qwen/qwen-turbo",- "name": "Qwen: Qwen-Turbo",- "provider": "qwen",- "local_id": "qwen-turbo",- "context_length": 131072,- "max_output_tokens": 8192,- "input_price_per_mtok": 0.0325,- "output_price_per_mtok": 0.13,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "max_tokens",- "presence_penalty",- "response_format",- "seed",- "temperature",- "tool_choice",- "tools",- "top_p"- ]- },- "qwen/qwen2.5-vl-72b-instruct": {- "id": "qwen/qwen2.5-vl-72b-instruct",- "name": "Qwen: Qwen2.5 VL 72B Instruct",- "provider": "qwen",- "local_id": "qwen2.5-vl-72b-instruct",- "context_length": 32000,- "max_output_tokens": 0,- "input_price_per_mtok": 0.25,- "output_price_per_mtok": 0.75,+ "max_output_tokens": 0,+ "input_price_per_mtok": 0.25,+ "output_price_per_mtok": 0.75,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -8846,33 +8697,6 @@"top_p"]},- "qwen/qwen-max": {- "id": "qwen/qwen-max",- "name": "Qwen: Qwen-Max ",- "provider": "qwen",- "local_id": "qwen-max",- "context_length": 32768,- "max_output_tokens": 8192,- "input_price_per_mtok": 1.04,- "output_price_per_mtok": 4.16,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "max_tokens",- "presence_penalty",- "response_format",- "seed",- "temperature",- "tool_choice",- "tools",- "top_p"- ]- },"openai/o3-mini": {"id": "openai/o3-mini","name": "OpenAI: o3 Mini",@@ -8937,7 +8761,7 @@"name": "DeepSeek: R1 Distill Qwen 32B","provider": "deepseek","local_id": "deepseek-r1-distill-qwen-32b",- "context_length": 32768,+ "context_length": 128000,"max_output_tokens": 32768,"input_price_per_mtok": 0.29,"output_price_per_mtok": 0.29,@@ -9029,7 +8853,7 @@"name": "DeepSeek: R1","provider": "deepseek","local_id": "deepseek-r1",- "context_length": 64000,+ "context_length": 163840,"max_output_tokens": 16000,"input_price_per_mtok": 0.7,"output_price_per_mtok": 2.5,@@ -9048,8 +8872,10 @@"presence_penalty","reasoning","repetition_penalty",+ "response_format","seed","stop",+ "structured_outputs","temperature","tool_choice","tools",@@ -9269,7 +9095,7 @@"name": "Meta: Llama 3.3 70B Instruct (free)","provider": "meta","local_id": "llama-3.3-70b-instruct:free",- "context_length": 65536,+ "context_length": 131072,"max_output_tokens": 0,"input_price_per_mtok": 0.0,"output_price_per_mtok": 0.0,@@ -9530,8 +9356,8 @@"name": "Qwen2.5 Coder 32B Instruct","provider": "qwen","local_id": "qwen-2.5-coder-32b-instruct",- "context_length": 32768,- "max_output_tokens": 0,+ "context_length": 128000,+ "max_output_tokens": 32768,"input_price_per_mtok": 0.66,"output_price_per_mtok": 1.0,"supports_thinking": false,@@ -9543,10 +9369,13 @@"is_reasoning_model": false,"supported_parameters": ["frequency_penalty",+ "logit_bias","max_tokens",+ "min_p","presence_penalty","repetition_penalty","seed",+ "stop","temperature","top_k","top_p"@@ -9616,7 +9445,7 @@"name": "Magnum v4 72B","provider": "anthracite-org","local_id": "magnum-v4-72b",- "context_length": 16384,+ "context_length": 32768,"max_output_tokens": 2048,"input_price_per_mtok": 3.0,"output_price_per_mtok": 5.0,@@ -9650,7 +9479,7 @@"name": "Qwen: Qwen2.5 7B Instruct","provider": "qwen","local_id": "qwen-2.5-7b-instruct",- "context_length": 32768,+ "context_length": 131072,"max_output_tokens": 32768,"input_price_per_mtok": 0.04,"output_price_per_mtok": 0.1,@@ -9678,11 +9507,11 @@"top_p"]},- "inflection/inflection-3-pi": {- "id": "inflection/inflection-3-pi",- "name": "Inflection: Inflection 3 Pi",+ "inflection/inflection-3-productivity": {+ "id": "inflection/inflection-3-productivity",+ "name": "Inflection: Inflection 3 Productivity","provider": "inflection",- "local_id": "inflection-3-pi",+ "local_id": "inflection-3-productivity","context_length": 8000,"max_output_tokens": 1024,"input_price_per_mtok": 2.5,@@ -9701,11 +9530,11 @@"top_p"]},- "inflection/inflection-3-productivity": {- "id": "inflection/inflection-3-productivity",- "name": "Inflection: Inflection 3 Productivity",+ "inflection/inflection-3-pi": {+ "id": "inflection/inflection-3-pi",+ "name": "Inflection: Inflection 3 Pi","provider": "inflection",- "local_id": "inflection-3-productivity",+ "local_id": "inflection-3-pi","context_length": 8000,"max_output_tokens": 1024,"input_price_per_mtok": 2.5,@@ -9760,15 +9589,15 @@"top_p"]},- "meta/llama-3.2-3b-instruct:free": {- "id": "meta-llama/llama-3.2-3b-instruct:free",- "name": "Meta: Llama 3.2 3B Instruct (free)",+ "meta/llama-3.2-11b-vision-instruct": {+ "id": "meta-llama/llama-3.2-11b-vision-instruct",+ "name": "Meta: Llama 3.2 11B Vision Instruct","provider": "meta",- "local_id": "llama-3.2-3b-instruct:free",+ "local_id": "llama-3.2-11b-vision-instruct","context_length": 131072,- "max_output_tokens": 0,- "input_price_per_mtok": 0.0,- "output_price_per_mtok": 0.0,+ "max_output_tokens": 16384,+ "input_price_per_mtok": 0.245,+ "output_price_per_mtok": 0.245,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -9778,23 +9607,28 @@"is_reasoning_model": false,"supported_parameters": ["frequency_penalty",+ "logit_bias","max_tokens",+ "min_p","presence_penalty",+ "repetition_penalty",+ "response_format",+ "seed","stop","temperature","top_k","top_p"]},- "meta/llama-3.2-3b-instruct": {- "id": "meta-llama/llama-3.2-3b-instruct",- "name": "Meta: Llama 3.2 3B Instruct",+ "meta/llama-3.2-1b-instruct": {+ "id": "meta-llama/llama-3.2-1b-instruct",+ "name": "Meta: Llama 3.2 1B Instruct","provider": "meta",- "local_id": "llama-3.2-3b-instruct",- "context_length": 80000,- "max_output_tokens": 0,- "input_price_per_mtok": 0.051,- "output_price_per_mtok": 0.34,+ "local_id": "llama-3.2-1b-instruct",+ "context_length": 131072,+ "max_output_tokens": 60000,+ "input_price_per_mtok": 0.027,+ "output_price_per_mtok": 0.201,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -9804,24 +9638,27 @@"is_reasoning_model": false,"supported_parameters": ["frequency_penalty",+ "logit_bias","max_tokens",+ "min_p","presence_penalty","repetition_penalty","seed",+ "stop","temperature","top_k","top_p"]},- "meta/llama-3.2-1b-instruct": {- "id": "meta-llama/llama-3.2-1b-instruct",- "name": "Meta: Llama 3.2 1B Instruct",+ "meta/llama-3.2-3b-instruct:free": {+ "id": "meta-llama/llama-3.2-3b-instruct:free",+ "name": "Meta: Llama 3.2 3B Instruct (free)","provider": "meta",- "local_id": "llama-3.2-1b-instruct",- "context_length": 60000,+ "local_id": "llama-3.2-3b-instruct:free",+ "context_length": 131072,"max_output_tokens": 0,- "input_price_per_mtok": 0.027,- "output_price_per_mtok": 0.2,+ "input_price_per_mtok": 0.0,+ "output_price_per_mtok": 0.0,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -9833,22 +9670,21 @@"frequency_penalty","max_tokens","presence_penalty",- "repetition_penalty",- "seed",+ "stop","temperature","top_k","top_p"]},- "meta/llama-3.2-11b-vision-instruct": {- "id": "meta-llama/llama-3.2-11b-vision-instruct",- "name": "Meta: Llama 3.2 11B Vision Instruct",+ "meta/llama-3.2-3b-instruct": {+ "id": "meta-llama/llama-3.2-3b-instruct",+ "name": "Meta: Llama 3.2 3B Instruct","provider": "meta",- "local_id": "llama-3.2-11b-vision-instruct",+ "local_id": "llama-3.2-3b-instruct","context_length": 131072,- "max_output_tokens": 16384,- "input_price_per_mtok": 0.245,- "output_price_per_mtok": 0.245,+ "max_output_tokens": 80000,+ "input_price_per_mtok": 0.0509,+ "output_price_per_mtok": 0.335,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -9863,7 +9699,6 @@"min_p","presence_penalty","repetition_penalty",- "response_format","seed","stop","temperature",@@ -9876,7 +9711,7 @@"name": "Qwen2.5 72B Instruct","provider": "qwen","local_id": "qwen-2.5-72b-instruct",- "context_length": 32768,+ "context_length": 131072,"max_output_tokens": 16384,"input_price_per_mtok": 0.36,"output_price_per_mtok": 0.4,@@ -10197,7 +10032,7 @@"name": "Meta: Llama 3.1 8B Instruct","provider": "meta","local_id": "llama-3.1-8b-instruct",- "context_length": 16384,+ "context_length": 131072,"max_output_tokens": 16384,"input_price_per_mtok": 0.02,"output_price_per_mtok": 0.05,@@ -10247,7 +10082,6 @@"supported_parameters": ["frequency_penalty","logit_bias",- "logprobs","max_tokens","min_p","presence_penalty",@@ -10260,7 +10094,6 @@"tool_choice","tools","top_k",- "top_logprobs","top_p"]},@@ -10422,15 +10255,15 @@"top_p"]},- "openai/gpt-4o-2024-05-13": {- "id": "openai/gpt-4o-2024-05-13",- "name": "OpenAI: GPT-4o (2024-05-13)",+ "openai/gpt-4o": {+ "id": "openai/gpt-4o",+ "name": "OpenAI: GPT-4o","provider": "openai",- "local_id": "gpt-4o-2024-05-13",+ "local_id": "gpt-4o","context_length": 128000,- "max_output_tokens": 4096,- "input_price_per_mtok": 5.0,- "output_price_per_mtok": 15.0,+ "max_output_tokens": 16384,+ "input_price_per_mtok": 2.5,+ "output_price_per_mtok": 10.0,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -10457,15 +10290,15 @@"web_search_options"]},- "openai/gpt-4o": {- "id": "openai/gpt-4o",- "name": "OpenAI: GPT-4o",+ "openai/gpt-4o-2024-05-13": {+ "id": "openai/gpt-4o-2024-05-13",+ "name": "OpenAI: GPT-4o (2024-05-13)","provider": "openai",- "local_id": "gpt-4o",+ "local_id": "gpt-4o-2024-05-13","context_length": 128000,- "max_output_tokens": 16384,- "input_price_per_mtok": 2.5,- "output_price_per_mtok": 10.0,+ "max_output_tokens": 4096,+ "input_price_per_mtok": 5.0,+ "output_price_per_mtok": 15.0,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -10492,15 +10325,15 @@"web_search_options"]},- "meta/llama-3-8b-instruct": {- "id": "meta-llama/llama-3-8b-instruct",- "name": "Meta: Llama 3 8B Instruct",+ "meta/llama-3-70b-instruct": {+ "id": "meta-llama/llama-3-70b-instruct",+ "name": "Meta: Llama 3 70B Instruct","provider": "meta",- "local_id": "llama-3-8b-instruct",+ "local_id": "llama-3-70b-instruct","context_length": 8192,- "max_output_tokens": 8192,- "input_price_per_mtok": 0.04,- "output_price_per_mtok": 0.04,+ "max_output_tokens": 8000,+ "input_price_per_mtok": 0.51,+ "output_price_per_mtok": 0.74,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -10510,27 +10343,26 @@"is_reasoning_model": false,"supported_parameters": ["frequency_penalty",- "logit_bias","max_tokens",- "min_p","presence_penalty","repetition_penalty","seed","stop",+ "structured_outputs","temperature","top_k","top_p"]},- "meta/llama-3-70b-instruct": {- "id": "meta-llama/llama-3-70b-instruct",- "name": "Meta: Llama 3 70B Instruct",+ "meta/llama-3-8b-instruct": {+ "id": "meta-llama/llama-3-8b-instruct",+ "name": "Meta: Llama 3 8B Instruct","provider": "meta",- "local_id": "llama-3-70b-instruct",+ "local_id": "llama-3-8b-instruct","context_length": 8192,- "max_output_tokens": 8000,- "input_price_per_mtok": 0.51,- "output_price_per_mtok": 0.74,+ "max_output_tokens": 8192,+ "input_price_per_mtok": 0.04,+ "output_price_per_mtok": 0.04,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -10540,9 +10372,12 @@"is_reasoning_model": false,"supported_parameters": ["frequency_penalty",+ "logit_bias","max_tokens",+ "min_p","presence_penalty","repetition_penalty",+ "response_format","seed","stop","temperature",@@ -10585,7 +10420,7 @@"name": "WizardLM-2 8x22B","provider": "microsoft","local_id": "wizardlm-2-8x22b",- "context_length": 65535,+ "context_length": 65536,"max_output_tokens": 8000,"input_price_per_mtok": 0.62,"output_price_per_mtok": 0.62,@@ -10601,6 +10436,7 @@"max_tokens","presence_penalty","repetition_penalty",+ "response_format","seed","stop","temperature",@@ -10763,40 +10599,6 @@"top_p"]},- "alpindale/goliath-120b": {- "id": "alpindale/goliath-120b",- "name": "Goliath 120B",- "provider": "alpindale",- "local_id": "goliath-120b",- "context_length": 6144,- "max_output_tokens": 1024,- "input_price_per_mtok": 3.75,- "output_price_per_mtok": 7.5,- "supports_thinking": false,- "thinking_type": "none",- "temperature_range": [- 0.0,- 2.0- ],- "is_reasoning_model": false,- "supported_parameters": [- "frequency_penalty",- "logit_bias",- "logprobs",- "max_tokens",- "min_p",- "presence_penalty",- "repetition_penalty",- "response_format",- "seed",- "stop",- "temperature",- "top_a",- "top_k",- "top_logprobs",- "top_p"- ]- },"openrouter/auto": {"id": "openrouter/auto","name": "Auto Router",@@ -10870,15 +10672,15 @@"top_p"]},- "openai/gpt-3.5-turbo-instruct": {- "id": "openai/gpt-3.5-turbo-instruct",- "name": "OpenAI: GPT-3.5 Turbo Instruct",- "provider": "openai",- "local_id": "gpt-3.5-turbo-instruct",- "context_length": 4095,- "max_output_tokens": 4096,- "input_price_per_mtok": 1.5,- "output_price_per_mtok": 2.0,+ "mistralai/mistral-7b-instruct-v0.1": {+ "id": "mistralai/mistral-7b-instruct-v0.1",+ "name": "Mistral: Mistral 7B Instruct v0.1",+ "provider": "mistralai",+ "local_id": "mistral-7b-instruct-v0.1",+ "context_length": 4096,+ "max_output_tokens": 2824,+ "input_price_per_mtok": 0.11,+ "output_price_per_mtok": 0.19,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -10889,27 +10691,26 @@"supported_parameters": ["frequency_penalty","logit_bias",- "logprobs","max_tokens",+ "min_p","presence_penalty",- "response_format",+ "repetition_penalty","seed","stop",- "structured_outputs","temperature",- "top_logprobs",+ "top_k","top_p"]},- "mistralai/mistral-7b-instruct-v0.1": {- "id": "mistralai/mistral-7b-instruct-v0.1",- "name": "Mistral: Mistral 7B Instruct v0.1",- "provider": "mistralai",- "local_id": "mistral-7b-instruct-v0.1",- "context_length": 2824,- "max_output_tokens": 0,- "input_price_per_mtok": 0.11,- "output_price_per_mtok": 0.19,+ "openai/gpt-3.5-turbo-instruct": {+ "id": "openai/gpt-3.5-turbo-instruct",+ "name": "OpenAI: GPT-3.5 Turbo Instruct",+ "provider": "openai",+ "local_id": "gpt-3.5-turbo-instruct",+ "context_length": 4095,+ "max_output_tokens": 4096,+ "input_price_per_mtok": 1.5,+ "output_price_per_mtok": 2.0,"supports_thinking": false,"thinking_type": "none","temperature_range": [@@ -10919,12 +10720,16 @@"is_reasoning_model": false,"supported_parameters": ["frequency_penalty",+ "logit_bias",+ "logprobs","max_tokens","presence_penalty",- "repetition_penalty",+ "response_format","seed",+ "stop",+ "structured_outputs","temperature",- "top_k",+ "top_logprobs","top_p"]},@@ -11066,11 +10871,11 @@"top_p"]},- "openai/gpt-4": {- "id": "openai/gpt-4",- "name": "OpenAI: GPT-4",+ "openai/gpt-4-0314": {+ "id": "openai/gpt-4-0314",+ "name": "OpenAI: GPT-4 (older v0314)","provider": "openai",- "local_id": "gpt-4",+ "local_id": "gpt-4-0314","context_length": 8191,"max_output_tokens": 4096,"input_price_per_mtok": 30.0,@@ -11086,7 +10891,6 @@"frequency_penalty","logit_bias","logprobs",- "max_completion_tokens","max_tokens","presence_penalty","response_format",@@ -11133,11 +10937,11 @@"top_p"]},- "openai/gpt-4-0314": {- "id": "openai/gpt-4-0314",- "name": "OpenAI: GPT-4 (older v0314)",+ "openai/gpt-4": {+ "id": "openai/gpt-4",+ "name": "OpenAI: GPT-4","provider": "openai",- "local_id": "gpt-4-0314",+ "local_id": "gpt-4","context_length": 8191,"max_output_tokens": 4096,"input_price_per_mtok": 30.0,@@ -11153,6 +10957,7 @@"frequency_penalty","logit_bias","logprobs",+ "max_completion_tokens","max_tokens","presence_penalty","response_format",diff --git a/server/constants.py b/server/constants.pyindex 0d22cecf..d12a0adb 100644--- a/server/constants.py+++ b/server/constants.py@@ -10,69 +10,81 @@ from typing import FrozenSet# AI NODE TYPES# =============================================================================-AI_CHAT_MODEL_TYPES: FrozenSet[str] = frozenset([- 'openaiChatModel',- 'anthropicChatModel',- 'geminiChatModel',- 'openrouterChatModel',- 'groqChatModel',- 'cerebrasChatModel',- 'deepseekChatModel',- 'kimiChatModel',- 'mistralChatModel',- # Local-server providers (Phase 1 of the LiteLLM adoption — see- # plans/i-plan-to-implement-nested-orbit.md).- 'ollamaChatModel',- 'lmstudioChatModel',-])--AI_AGENT_TYPES: FrozenSet[str] = frozenset([- 'aiAgent',- 'chatAgent',- 'android_agent',- 'coding_agent',- 'web_agent',- 'task_agent',- 'social_agent',- 'travel_agent',- 'tool_agent',- 'productivity_agent',- 'payments_agent',- 'consumer_agent',- 'autonomous_agent',- 'orchestrator_agent',- 'ai_employee',- 'rlm_agent',- 'claude_code_agent',-])--AI_MEMORY_TYPES: FrozenSet[str] = frozenset([- 'simpleMemory',-])+AI_CHAT_MODEL_TYPES: FrozenSet[str] = frozenset(+ [+ "openaiChatModel",+ "anthropicChatModel",+ "geminiChatModel",+ "openrouterChatModel",+ "groqChatModel",+ "cerebrasChatModel",+ "deepseekChatModel",+ "kimiChatModel",+ "mistralChatModel",+ # Local-server providers (Phase 1 of the LiteLLM adoption — see+ # plans/i-plan-to-implement-nested-orbit.md).+ "ollamaChatModel",+ "lmstudioChatModel",+ ]+)++AI_AGENT_TYPES: FrozenSet[str] = frozenset(+ [+ "aiAgent",+ "chatAgent",+ "android_agent",+ "coding_agent",+ "web_agent",+ "task_agent",+ "social_agent",+ "travel_agent",+ "tool_agent",+ "productivity_agent",+ "payments_agent",+ "consumer_agent",+ "autonomous_agent",+ "orchestrator_agent",+ "ai_employee",+ "rlm_agent",+ "claude_code_agent",+ ]+)++AI_MEMORY_TYPES: FrozenSet[str] = frozenset(+ [+ "simpleMemory",+ ]+)# Tool node types (connect to AI Agent's input-tools handle)-AI_TOOL_TYPES: FrozenSet[str] = frozenset([- 'calculatorTool',- 'currentTimeTool',- 'duckduckgoSearch',- 'androidTool',- 'writeTodos',- 'processManager',-])+AI_TOOL_TYPES: FrozenSet[str] = frozenset(+ [+ "calculatorTool",+ "currentTimeTool",+ "duckduckgoSearch",+ "androidTool",+ "writeTodos",+ "processManager",+ ]+)# Skill node types (connect to Zeenie's input-skill handle)# Skills provide SKILL.md context/instructions, not executed as workflow nodes# masterSkill: Aggregates built-in skills and user-created skills with inline editing-SKILL_NODE_TYPES: FrozenSet[str] = frozenset([- 'masterSkill',-])+SKILL_NODE_TYPES: FrozenSet[str] = frozenset(+ [+ "masterSkill",+ ]+)# Toolkit node types (aggregate sub-nodes, n8n Sub-Node pattern)# Sub-nodes connected to toolkits should not execute independently -# they only execute when called via the toolkit's tool interface-TOOLKIT_NODE_TYPES: FrozenSet[str] = frozenset([- 'androidTool', # Aggregates Android service nodes (batteryMonitor, location, etc.)-])+TOOLKIT_NODE_TYPES: FrozenSet[str] = frozenset(+ [+ "androidTool", # Aggregates Android service nodes (batteryMonitor, location, etc.)+ ]+)# All AI-related node types (for API key injection)AI_MODEL_TYPES: FrozenSet[str] = AI_AGENT_TYPES | AI_CHAT_MODEL_TYPES@@ -85,225 +97,271 @@ AI_MODEL_TYPES: FrozenSet[str] = AI_AGENT_TYPES | AI_CHAT_MODEL_TYPES# (input-memory, input-tools, input-model, input-skill).# They don't execute independently - they're used by their parent nodes.CONFIG_NODE_TYPES: FrozenSet[str] = (- AI_MEMORY_TYPES | # Memory nodes (connect to input-memory)- AI_TOOL_TYPES | # Tool nodes (connect to AI Agent's input-tools)- AI_CHAT_MODEL_TYPES | # Model config nodes (connect to input-model)- SKILL_NODE_TYPES # Skill nodes (connect to Zeenie's input-skill)+ AI_MEMORY_TYPES # Memory nodes (connect to input-memory)+ | AI_TOOL_TYPES # Tool nodes (connect to AI Agent's input-tools)+ | AI_CHAT_MODEL_TYPES # Model config nodes (connect to input-model)+ | SKILL_NODE_TYPES # Skill nodes (connect to Zeenie's input-skill))# =============================================================================# PROXY NODE TYPES# =============================================================================-PROXY_NODE_TYPES: FrozenSet[str] = frozenset([- 'proxyRequest',- 'proxyConfig',- 'proxyStatus',-])+PROXY_NODE_TYPES: FrozenSet[str] = frozenset(+ [+ "proxyRequest",+ "proxyConfig",+ "proxyStatus",+ ]+)# Dual-purpose proxy nodes (workflow node + AI tool)-PROXY_TOOL_TYPES: FrozenSet[str] = frozenset([- 'proxyRequest',- 'proxyConfig',- 'proxyStatus',-])+PROXY_TOOL_TYPES: FrozenSet[str] = frozenset(+ [+ "proxyRequest",+ "proxyConfig",+ "proxyStatus",+ ]+)# =============================================================================# BROWSER NODE TYPES# =============================================================================-BROWSER_NODE_TYPES: FrozenSet[str] = frozenset([- 'browser',-])+BROWSER_NODE_TYPES: FrozenSet[str] = frozenset(+ [+ "browser",+ ]+)-BROWSER_TOOL_TYPES: FrozenSet[str] = frozenset([- 'browser',-])+BROWSER_TOOL_TYPES: FrozenSet[str] = frozenset(+ [+ "browser",+ ]+)# =============================================================================# SEARCH NODE TYPES# =============================================================================-SEARCH_NODE_TYPES: FrozenSet[str] = frozenset([- 'braveSearch',- 'serperSearch',- 'perplexitySearch',-])+SEARCH_NODE_TYPES: FrozenSet[str] = frozenset(+ [+ "braveSearch",+ "serperSearch",+ "perplexitySearch",+ ]+)# Dual-purpose search nodes (workflow node + AI tool)-SEARCH_TOOL_TYPES: FrozenSet[str] = frozenset([- 'braveSearch',- 'serperSearch',- 'perplexitySearch',-])+SEARCH_TOOL_TYPES: FrozenSet[str] = frozenset(+ [+ "braveSearch",+ "serperSearch",+ "perplexitySearch",+ ]+)# =============================================================================# GOOGLE MAPS NODE TYPES# =============================================================================-GOOGLE_MAPS_TYPES: FrozenSet[str] = frozenset([- 'gmaps_create',- 'gmaps_locations',- 'gmaps_nearby_places',-])+GOOGLE_MAPS_TYPES: FrozenSet[str] = frozenset(+ [+ "gmaps_create",+ "gmaps_locations",+ "gmaps_nearby_places",+ ]+)# =============================================================================# ANDROID NODE TYPES# =============================================================================# System monitoring nodes-ANDROID_MONITORING_TYPES: FrozenSet[str] = frozenset([- 'batteryMonitor',- 'networkMonitor',- 'systemInfo',- 'location',-])+ANDROID_MONITORING_TYPES: FrozenSet[str] = frozenset(+ [+ "batteryMonitor",+ "networkMonitor",+ "systemInfo",+ "location",+ ]+)# App management nodes-ANDROID_APP_TYPES: FrozenSet[str] = frozenset([- 'appLauncher',- 'appList',-])+ANDROID_APP_TYPES: FrozenSet[str] = frozenset(+ [+ "appLauncher",+ "appList",+ ]+)# Device automation nodes-ANDROID_AUTOMATION_TYPES: FrozenSet[str] = frozenset([- 'wifiAutomation',- 'bluetoothAutomation',- 'audioAutomation',- 'deviceStateAutomation',- 'screenControlAutomation',- 'airplaneModeControl',-])+ANDROID_AUTOMATION_TYPES: FrozenSet[str] = frozenset(+ [+ "wifiAutomation",+ "bluetoothAutomation",+ "audioAutomation",+ "deviceStateAutomation",+ "screenControlAutomation",+ "airplaneModeControl",+ ]+)# Sensor nodes-ANDROID_SENSOR_TYPES: FrozenSet[str] = frozenset([- 'motionDetection',- 'environmentalSensors',-])+ANDROID_SENSOR_TYPES: FrozenSet[str] = frozenset(+ [+ "motionDetection",+ "environmentalSensors",+ ]+)# Media nodes-ANDROID_MEDIA_TYPES: FrozenSet[str] = frozenset([- 'cameraControl',- 'mediaControl',-])+ANDROID_MEDIA_TYPES: FrozenSet[str] = frozenset(+ [+ "cameraControl",+ "mediaControl",+ ]+)# All Android service node types (combined)ANDROID_SERVICE_NODE_TYPES: FrozenSet[str] = (- ANDROID_MONITORING_TYPES |- ANDROID_APP_TYPES |- ANDROID_AUTOMATION_TYPES |- ANDROID_SENSOR_TYPES |- ANDROID_MEDIA_TYPES+ ANDROID_MONITORING_TYPES | ANDROID_APP_TYPES | ANDROID_AUTOMATION_TYPES | ANDROID_SENSOR_TYPES | ANDROID_MEDIA_TYPES)# =============================================================================# WHATSAPP NODE TYPES# =============================================================================-WHATSAPP_TYPES: FrozenSet[str] = frozenset([- 'whatsappSend',- 'whatsappReceive',- 'whatsappDb',-])+WHATSAPP_TYPES: FrozenSet[str] = frozenset(+ [+ "whatsappSend",+ "whatsappReceive",+ "whatsappDb",+ ]+)# =============================================================================# TWITTER NODE TYPES# =============================================================================-TWITTER_TYPES: FrozenSet[str] = frozenset([- 'twitterSend',- 'twitterReceive',- 'twitterSearch',- 'twitterUser',-])+TWITTER_TYPES: FrozenSet[str] = frozenset(+ [+ "twitterSend",+ "twitterReceive",+ "twitterSearch",+ "twitterUser",+ ]+)# Dual-purpose Twitter nodes (workflow node + AI tool)-TWITTER_TOOL_TYPES: FrozenSet[str] = frozenset([- 'twitterSend',- 'twitterSearch',- 'twitterUser',-])+TWITTER_TOOL_TYPES: FrozenSet[str] = frozenset(+ [+ "twitterSend",+ "twitterSearch",+ "twitterUser",+ ]+)# =============================================================================# SOCIAL NODE TYPES (unified messaging)# =============================================================================-SOCIAL_NODE_TYPES: FrozenSet[str] = frozenset([- 'socialReceive',- 'socialSend',-])+SOCIAL_NODE_TYPES: FrozenSet[str] = frozenset(+ [+ "socialReceive",+ "socialSend",+ ]+)# Dual-purpose social nodes (workflow node + AI tool)-SOCIAL_TOOL_TYPES: FrozenSet[str] = frozenset([- 'socialSend', # Can be used as AI Agent tool-])+SOCIAL_TOOL_TYPES: FrozenSet[str] = frozenset(+ [+ "socialSend", # Can be used as AI Agent tool+ ]+)# =============================================================================# EMAIL NODE TYPES (Himalaya CLI-based IMAP/SMTP)# =============================================================================-EMAIL_TYPES: FrozenSet[str] = frozenset([- 'emailSend',- 'emailRead',- 'emailReceive',-])+EMAIL_TYPES: FrozenSet[str] = frozenset(+ [+ "emailSend",+ "emailRead",+ "emailReceive",+ ]+)# Dual-purpose email nodes (workflow node + AI tool)-EMAIL_TOOL_TYPES: FrozenSet[str] = frozenset([- 'emailSend',- 'emailRead',-])+EMAIL_TOOL_TYPES: FrozenSet[str] = frozenset(+ [+ "emailSend",+ "emailRead",+ ]+)# =============================================================================# CHAT NODE TYPES# =============================================================================-CHAT_TYPES: FrozenSet[str] = frozenset([- 'chatSend',- 'chatHistory',-])+CHAT_TYPES: FrozenSet[str] = frozenset(+ [+ "chatSend",+ "chatHistory",+ ]+)# =============================================================================# UTILITY NODE TYPES# =============================================================================-CODE_EXECUTOR_TYPES: FrozenSet[str] = frozenset([- 'pythonExecutor',- 'javascriptExecutor',-])+CODE_EXECUTOR_TYPES: FrozenSet[str] = frozenset(+ [+ "pythonExecutor",+ "javascriptExecutor",+ ]+)-HTTP_TYPES: FrozenSet[str] = frozenset([- 'httpRequest',- 'webhookResponse',-])+HTTP_TYPES: FrozenSet[str] = frozenset(+ [+ "httpRequest",+ "webhookResponse",+ ]+)-TEXT_TYPES: FrozenSet[str] = frozenset([- 'textGenerator',- 'fileHandler',-])+TEXT_TYPES: FrozenSet[str] = frozenset(+ [+ "textGenerator",+ "fileHandler",+ ]+)# =============================================================================# WORKFLOW CONTROL NODE TYPES# =============================================================================-WORKFLOW_CONTROL_TYPES: FrozenSet[str] = frozenset([- 'start',- 'cronScheduler',-])+WORKFLOW_CONTROL_TYPES: FrozenSet[str] = frozenset(+ [+ "start",+ "cronScheduler",+ ]+)# =============================================================================# TRIGGER NODE TYPES (handled by event_waiter)# =============================================================================# Event-driven triggers that wait for external events-EVENT_TRIGGER_TYPES: FrozenSet[str] = frozenset([- 'webhookTrigger',- 'whatsappReceive',- 'twitterReceive',- 'workflowTrigger',- 'chatTrigger',- 'taskTrigger',-])+EVENT_TRIGGER_TYPES: FrozenSet[str] = frozenset(+ [+ "webhookTrigger",+ "whatsappReceive",+ "twitterReceive",+ "workflowTrigger",+ "chatTrigger",+ "taskTrigger",+ ]+)# Legacy alias for backwards compatibilityTRIGGER_TYPES: FrozenSet[str] = EVENT_TRIGGER_TYPES@@ -315,11 +373,13 @@ TRIGGER_TYPES: FrozenSet[str] = EVENT_TRIGGER_TYPES# Polling triggers need to actively poll an external API for new data,# unlike push-based triggers (WhatsApp, Webhook) that receive events externally.# In deployment mode, these get a dedicated polling loop instead of event_waiter.-POLLING_TRIGGER_TYPES: FrozenSet[str] = frozenset([- 'googleGmailReceive',- 'twitterReceive',- 'emailReceive',-])+POLLING_TRIGGER_TYPES: FrozenSet[str] = frozenset(+ [+ "googleGmailReceive",+ "twitterReceive",+ "emailReceive",+ ]+)# =============================================================================# ALL TRIGGER NODE TYPES (starting points for workflow graphs)@@ -327,27 +387,30 @@ POLLING_TRIGGER_TYPES: FrozenSet[str] = frozenset([# Combined set of all trigger node types that can start a workflow# These nodes have no input handles and serve as entry points-WORKFLOW_TRIGGER_TYPES: FrozenSet[str] = frozenset([- # Manual start- 'start',- # Scheduled triggers- 'cronScheduler',- # Event-driven triggers- 'webhookTrigger',- 'whatsappReceive',- 'workflowTrigger',- 'chatTrigger',- 'taskTrigger',- 'twitterReceive',- 'googleGmailReceive',- 'telegramReceive',- 'emailReceive',-])+WORKFLOW_TRIGGER_TYPES: FrozenSet[str] = frozenset(+ [+ # Manual start+ "start",+ # Scheduled triggers+ "cronScheduler",+ # Event-driven triggers+ "webhookTrigger",+ "whatsappReceive",+ "workflowTrigger",+ "chatTrigger",+ "taskTrigger",+ "twitterReceive",+ "googleGmailReceive",+ "telegramReceive",+ "emailReceive",+ ]+)# =============================================================================# AI PROVIDER DETECTION# =============================================================================+def detect_ai_provider(node_type: str, parameters: dict = None) -> str:"""Detect AI provider from node type or parameters.@@ -368,33 +431,33 @@ def detect_ai_provider(node_type: str, parameters: dict = None) -> str:"""# AI Agent types get provider from parametersif node_type in AI_AGENT_TYPES:- return (parameters or {}).get('provider', 'openai')+ return (parameters or {}).get("provider", "openai")nt = node_type.lower()# Order matters: more-specific tokens first, so e.g. `lm_studio` /# `lmstudio` / `lm-studio` all classify before any future generic# `openai`-prefixed match could shadow them.- if 'deepseek' in nt:- return 'deepseek'- if 'kimi' in nt:- return 'kimi'- if 'mistral' in nt:- return 'mistral'- if 'cerebras' in nt:- return 'cerebras'- if 'groq' in nt:- return 'groq'- if 'openrouter' in nt:- return 'openrouter'- if 'anthropic' in nt:- return 'anthropic'- if 'gemini' in nt:- return 'gemini'+ if "deepseek" in nt:+ return "deepseek"+ if "kimi" in nt:+ return "kimi"+ if "mistral" in nt:+ return "mistral"+ if "cerebras" in nt:+ return "cerebras"+ if "groq" in nt:+ return "groq"+ if "openrouter" in nt:+ return "openrouter"+ if "anthropic" in nt:+ return "anthropic"+ if "gemini" in nt:+ return "gemini"# Local-server providers — match the LMStudioChatModelNode /# OllamaChatModelNode plugin types so the runtime path reads the# correct {provider}_proxy credential and the openai SDK is pointed# at the user's local server, not api.openai.com.- if 'lmstudio' in nt or 'lm_studio' in nt or 'lm-studio' in nt:- return 'lmstudio'- if 'ollama' in nt:- return 'ollama'- return 'openai'+ if "lmstudio" in nt or "lm_studio" in nt or "lm-studio" in nt:+ return "lmstudio"+ if "ollama" in nt:+ return "ollama"+ return "openai"diff --git a/server/core/__init__.py b/server/core/__init__.pyindex 712fd97f..304369a9 100644--- a/server/core/__init__.py+++ b/server/core/__init__.py@@ -1 +1 @@-# Core framework components\ No newline at end of file+# Core framework componentsdiff --git a/server/core/cache.py b/server/core/cache.pyindex daef4a8a..6142c261 100644--- a/server/core/cache.py+++ b/server/core/cache.py@@ -9,6 +9,7 @@ from typing import Any, Dict, Optional, List, TYPE_CHECKINGtry:import redis.asyncio as redis+REDIS_AVAILABLE = Trueexcept ImportError:redis = None@@ -51,7 +52,7 @@ class CacheService:decode_responses=True,socket_timeout=5,socket_connect_timeout=5,- retry_on_timeout=True+ retry_on_timeout=True,)# Test connection@@ -73,9 +74,7 @@ class CacheService:if self.use_sqlite:logger.info("Using SQLite cache (n8n pattern - no Redis required for single-process)")else:- logger.info("Using in-memory cache",- redis_enabled=self.settings.redis_enabled,- redis_available=REDIS_AVAILABLE)+ logger.info("Using in-memory cache", redis_enabled=self.settings.redis_enabled, redis_available=REDIS_AVAILABLE)async def _check_streams_support(self):"""Check if Redis supports Streams (XADD/XREAD commands).@@ -273,8 +272,7 @@ class CacheService:async def cache_models(self, provider: str, models: List[str]) -> bool:"""Cache available models for provider."""cache_key = f"models:{provider}"- return await self.set(cache_key, {"models": models, "cached_at": "now"},- ttl=3600) # 1 hour+ return await self.set(cache_key, {"models": models, "cached_at": "now"}, ttl=3600) # 1 hourasync def get_cached_models(self, provider: str) -> Optional[List[str]]:"""Get cached models for provider."""@@ -313,12 +311,7 @@ class CacheService:logger.error(f"Stream add failed: {stream}", error=str(e))return None- async def stream_read(- self,- streams: Dict[str, str],- count: int = 1,- block: Optional[int] = None- ) -> Optional[List[Any]]:+ async def stream_read(self, streams: Dict[str, str], count: int = 1, block: Optional[int] = None) -> Optional[List[Any]]:"""Read from Redis Streams.Args:@@ -338,12 +331,7 @@ class CacheService:logger.error(f"Stream read failed: {streams.keys()}", error=str(e))return None- async def stream_create_group(- self,- stream: str,- group: str,- start_id: str = '$'- ) -> bool:+ async def stream_create_group(self, stream: str, group: str, start_id: str = "$") -> bool:"""Create consumer group for stream.Args:@@ -371,12 +359,7 @@ class CacheService:return Falseasync def stream_read_group(- self,- group: str,- consumer: str,- streams: Dict[str, str],- count: int = 1,- block: Optional[int] = None+ self, group: str, consumer: str, streams: Dict[str, str], count: int = 1, block: Optional[int] = None) -> Optional[List[Any]]:"""Read from streams using consumer group.@@ -392,10 +375,7 @@ class CacheService:"""try:if self.use_redis and self.redis and self._streams_available:- result = await self.redis.xreadgroup(- group, consumer, streams,- count=count, block=block- )+ result = await self.redis.xreadgroup(group, consumer, streams, count=count, block=block)return resultreturn Noneexcept Exception as e:@@ -456,4 +436,4 @@ class CacheService:Returns True only if Redis is connected AND supports Streams commands.This is checked once during startup to avoid runtime failures."""- return self.use_redis and self.redis is not None and self._streams_available\ No newline at end of file+ return self.use_redis and self.redis is not None and self._streams_availablediff --git a/server/core/cleanup.py b/server/core/cleanup.pyindex c29b4db5..ae402581 100644--- a/server/core/cleanup.py+++ b/server/core/cleanup.py@@ -3,6 +3,7 @@Follows the RecoverySweeper pattern from execution/recovery.py.All configuration from Settings (environment variables)."""+import asyncioimport gcfrom typing import Optional, TYPE_CHECKING@@ -27,12 +28,7 @@ class CleanupService:- Forces garbage collection"""- def __init__(- self,- database: "Database",- cache: "CacheService",- settings: "Settings"- ):+ def __init__(self, database: "Database", cache: "CacheService", settings: "Settings"):self.database = databaseself.cache = cacheself.settings = settings@@ -49,7 +45,7 @@ class CleanupService:"Cleanup service started",interval=self.settings.cleanup_interval,logs_max=self.settings.cleanup_logs_max_count,- cache_max_age_hours=self.settings.cleanup_cache_max_age_hours+ cache_max_age_hours=self.settings.cleanup_cache_max_age_hours,)async def stop(self) -> None:@@ -78,28 +74,24 @@ class CleanupService:# 1. Expired cache entries (TTL-based)try:- results['expired_cache'] = await self.database.cleanup_expired_cache()+ results["expired_cache"] = await self.database.cleanup_expired_cache()except Exception as e:logger.warning("Failed to cleanup expired cache", error=str(e))- results['expired_cache'] = 0+ results["expired_cache"] = 0# 2. Old console logs (keep last N)try:- results['old_logs'] = await self.database.cleanup_old_console_logs(- keep=self.settings.cleanup_logs_max_count- )+ results["old_logs"] = await self.database.cleanup_old_console_logs(keep=self.settings.cleanup_logs_max_count)except Exception as e:logger.warning("Failed to cleanup old console logs", error=str(e))- results['old_logs'] = 0+ results["old_logs"] = 0# 3. Old cache entries by agetry:- results['old_cache'] = await self.database.cleanup_old_cache(- max_age_hours=self.settings.cleanup_cache_max_age_hours- )+ results["old_cache"] = await self.database.cleanup_old_cache(max_age_hours=self.settings.cleanup_cache_max_age_hours)except Exception as e:logger.warning("Failed to cleanup old cache", error=str(e))- results['old_cache'] = 0+ results["old_cache"] = 0# 4. Force garbage collectiongc.collect()@@ -112,12 +104,8 @@ class CleanupService:async def run_once(self) -> dict:"""Run cleanup once and return results. Useful for testing."""results = {}- results['expired_cache'] = await self.database.cleanup_expired_cache()- results['old_logs'] = await self.database.cleanup_old_console_logs(- keep=self.settings.cleanup_logs_max_count- )- results['old_cache'] = await self.database.cleanup_old_cache(- max_age_hours=self.settings.cleanup_cache_max_age_hours- )+ results["expired_cache"] = await self.database.cleanup_expired_cache()+ results["old_logs"] = await self.database.cleanup_old_console_logs(keep=self.settings.cleanup_logs_max_count)+ results["old_cache"] = await self.database.cleanup_old_cache(max_age_hours=self.settings.cleanup_cache_max_age_hours)gc.collect()return resultsdiff --git a/server/core/container.py b/server/core/container.pyindex 39cee4c2..fa47e23b 100644--- a/server/core/container.py+++ b/server/core/container.py@@ -21,15 +21,19 @@ from core.database import Databasefrom core.cache import CacheServicefrom core.encryption import EncryptionServicefrom core.credentials_database import CredentialsDatabase+_clog("core imports done")from services.ai import AIService+_clog("AIService imported")from services.workflow import WorkflowService+_clog("WorkflowService imported")from services.auth import AuthServicefrom services.text import TextServicefrom services.user_auth import UserAuthServicefrom services.compaction import init_compaction_service+_clog("all service imports done")from services.temporal import TemporalClientWrapper@@ -94,28 +98,17 @@ class Container(containers.DeclarativeContainer):)# Database (needed by CacheService for SQLite fallback)- database = providers.Singleton(- Database,- settings=settings- )+ database = providers.Singleton(Database, settings=settings)# Cache service (uses Redis when available, SQLite otherwise)- cache = providers.Singleton(- CacheService,- settings=settings,- database=database- )+ cache = providers.Singleton(CacheService, settings=settings, database=database)# Encryption service for credentials (initialized on user login)- encryption_service = providers.Singleton(- EncryptionService- )+ encryption_service = providers.Singleton(EncryptionService)# Credentials database (separate encrypted database for API keys and OAuth tokens)credentials_database = providers.Singleton(- CredentialsDatabase,- db_path=settings.provided.credentials_db_resolved,- encryption=encryption_service+ CredentialsDatabase, db_path=settings.provided.credentials_db_resolved, encryption=encryption_service)# Temporal client@@ -126,49 +119,21 @@ class Container(containers.DeclarativeContainer):)# Services- auth_service = providers.Singleton(- AuthService,- credentials_db=credentials_database,- cache=cache,- database=database,- settings=settings- )+ auth_service = providers.Singleton(AuthService, credentials_db=credentials_database, cache=cache, database=database, settings=settings)user_auth_service = providers.Factory(- UserAuthService,- database=database,- settings=settings,- encryption=encryption_service,- credentials_db=credentials_database+ UserAuthService, database=database, settings=settings, encryption=encryption_service, credentials_db=credentials_database)- ai_service = providers.Singleton(- AIService,- auth_service=auth_service,- database=database,- cache=cache,- settings=settings- )+ ai_service = providers.Singleton(AIService, auth_service=auth_service, database=database, cache=cache, settings=settings)- maps_service = providers.Factory(- _build_maps_service,- auth_service=auth_service,- settings=settings- )+ maps_service = providers.Factory(_build_maps_service, auth_service=auth_service, settings=settings)- text_service = providers.Factory(- TextService- )+ text_service = providers.Factory(TextService)- android_service = providers.Factory(- _build_android_service- )+ android_service = providers.Factory(_build_android_service)- compaction_service = providers.Singleton(- init_compaction_service,- database=database,- settings=settings- )+ compaction_service = providers.Singleton(init_compaction_service, database=database, settings=settings)workflow_service = providers.Singleton(WorkflowService,@@ -178,9 +143,9 @@ class Container(containers.DeclarativeContainer):text_service=text_service,android_service=android_service,cache=cache,- settings=settings+ settings=settings,)# Global container instance-container = Container()\ No newline at end of file+container = Container()diff --git a/server/core/credential_backends.py b/server/core/credential_backends.pyindex 4a1bea7e..16010177 100644--- a/server/core/credential_backends.py+++ b/server/core/credential_backends.py@@ -158,6 +158,7 @@ class KeyringBackend(CredentialBackend):self._available = Falsetry:import keyring+self._keyring = keyring# Test if keyring is workingself._keyring.get_password(self.SERVICE_NAME, "__test__")@@ -177,11 +178,7 @@ class KeyringBackend(CredentialBackend):self._keyring.set_password(self.SERVICE_NAME, key, value)# Store metadata separately if providedif metadata:- self._keyring.set_password(- self.SERVICE_NAME,- f"{key}__metadata",- json.dumps(metadata)- )+ self._keyring.set_password(self.SERVICE_NAME, f"{key}__metadata", json.dumps(metadata))return Trueexcept Exception as e:logger.error(f"KeyringBackend store failed: {e}")@@ -243,6 +240,7 @@ class AWSSecretsBackend(CredentialBackend):try:import boto3+self._client = boto3.client("secretsmanager", region_name=self._region)# Test connectionself._client.describe_secret(SecretId=self._secret_arn)@@ -267,10 +265,7 @@ class AWSSecretsBackend(CredentialBackend):current[f"{key}__metadata"] = json.dumps(metadata)# Put updated secret- self._client.put_secret_value(- SecretId=self._secret_arn,- SecretString=json.dumps(current)- )+ self._client.put_secret_value(SecretId=self._secret_arn, SecretString=json.dumps(current))# Update cacheself._cache[key] = value@@ -310,10 +305,7 @@ class AWSSecretsBackend(CredentialBackend):current.pop(f"{key}__metadata", None)# Put updated secret- self._client.put_secret_value(- SecretId=self._secret_arn,- SecretString=json.dumps(current)- )+ self._client.put_secret_value(SecretId=self._secret_arn, SecretString=json.dumps(current))# Update cacheself._cache.pop(key, None)diff --git a/server/core/credentials_database.py b/server/core/credentials_database.pyindex 22c143f8..1645bec6 100644--- a/server/core/credentials_database.py+++ b/server/core/credentials_database.py@@ -50,9 +50,7 @@ class EncryptedAPIKey(SQLModel, table=True):key_hash: str = Field(max_length=64, index=True) # SHA256[:16] for lookupmodels: Optional[Dict[str, Any]] = Field(default=None, sa_column=Column(JSON))is_valid: bool = Field(default=True)- last_validated: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc)- )+ last_validated: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))updated_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))@@ -162,18 +160,14 @@ class CredentialsDatabase:async def _get_metadata(self, key: str) -> Optional[str]:"""Get metadata value by key."""async with self.get_session() as session:- result = await session.execute(- select(CredentialsMetadata).where(CredentialsMetadata.key == key)- )+ result = await session.execute(select(CredentialsMetadata).where(CredentialsMetadata.key == key))row = result.scalars().first()return row.value if row else Noneasync def _set_metadata(self, key: str, value: str) -> None:"""Set metadata value."""async with self.get_session() as session:- existing = await session.execute(- select(CredentialsMetadata).where(CredentialsMetadata.key == key)- )+ existing = await session.execute(select(CredentialsMetadata).where(CredentialsMetadata.key == key))row = existing.scalars().first()if row:row.value = value@@ -244,9 +238,7 @@ class CredentialsDatabase:await session.commit()logger.debug(f"Saved encrypted API key for provider: {provider}")- async def get_api_key_model_params(- self, provider: str, session_id: str = "default"- ) -> Dict[str, Dict[str, Any]]:+ async def get_api_key_model_params(self, provider: str, session_id: str = "default") -> Dict[str, Dict[str, Any]]:"""Return the per-model param map stored alongside the model list.Empty dict if the provider has no entry, no params were stored,@@ -263,9 +255,7 @@ class CredentialsDatabase:params = row.models.get("model_params") or {}return params if isinstance(params, dict) else {}- async def get_api_key(- self, provider: str, session_id: str = "default"- ) -> Optional[str]:+ async def get_api_key(self, provider: str, session_id: str = "default") -> Optional[str]:"""Get decrypted API key.@@ -287,9 +277,7 @@ class CredentialsDatabase:logger.error(f"Failed to decrypt API key for {provider}: {e}")return None- async def get_api_key_info(- self, provider: str, session_id: str = "default"- ) -> Optional[Dict[str, Any]]:+ async def get_api_key_info(self, provider: str, session_id: str = "default") -> Optional[Dict[str, Any]]:"""Get API key metadata (without decrypting the key).@@ -312,9 +300,7 @@ class CredentialsDatabase:"last_validated": row.last_validated,}- async def delete_api_key(- self, provider: str, session_id: str = "default"- ) -> bool:+ async def delete_api_key(self, provider: str, session_id: str = "default") -> bool:"""Delete API key.@@ -346,16 +332,10 @@ class CredentialsDatabase:List of provider names"""async with self.get_session() as session:- result = await session.execute(- select(EncryptedAPIKey.provider).where(- EncryptedAPIKey.session_id == session_id- )- )+ result = await session.execute(select(EncryptedAPIKey.provider).where(EncryptedAPIKey.session_id == session_id))return [row[0] for row in result.all()]- async def get_api_key_models(- self, provider: str, session_id: str = "default"- ) -> List[str]:+ async def get_api_key_models(self, provider: str, session_id: str = "default") -> List[str]:"""Get stored models for an API key.@@ -436,9 +416,7 @@ class CredentialsDatabase:await session.commit()logger.debug(f"Saved encrypted OAuth tokens for provider: {provider}")- async def get_oauth_tokens(- self, provider: str, customer_id: str = "owner"- ) -> Optional[Dict[str, Any]]:+ async def get_oauth_tokens(self, provider: str, customer_id: str = "owner") -> Optional[Dict[str, Any]]:"""Get decrypted OAuth tokens.@@ -464,9 +442,7 @@ class CredentialsDatabase:try:return {"access_token": self.encryption.decrypt(row.access_token_encrypted),- "refresh_token": self.encryption.decrypt(- row.refresh_token_encrypted- ),+ "refresh_token": self.encryption.decrypt(row.refresh_token_encrypted),"email": row.email,"name": row.name,"token_expiry": row.token_expiry,@@ -476,9 +452,7 @@ class CredentialsDatabase:logger.error(f"Failed to decrypt OAuth tokens for {provider}: {e}")return None- async def delete_oauth_tokens(- self, provider: str, customer_id: str = "owner"- ) -> bool:+ async def delete_oauth_tokens(self, provider: str, customer_id: str = "owner") -> bool:"""Delete OAuth tokens.@@ -515,9 +489,5 @@ class CredentialsDatabase:List of provider names"""async with self.get_session() as session:- result = await session.execute(- select(EncryptedOAuthToken.provider).where(- EncryptedOAuthToken.customer_id == customer_id- )- )+ result = await session.execute(select(EncryptedOAuthToken.provider).where(EncryptedOAuthToken.customer_id == customer_id))return [row[0] for row in result.all()]diff --git a/server/core/database.py b/server/core/database.pyindex 95ae9db1..34ffbe59 100644--- a/server/core/database.py+++ b/server/core/database.py@@ -10,11 +10,28 @@ from contextlib import asynccontextmanagerfrom core.config import Settingsfrom models.database import (- NodeParameter, Workflow, Execution, APIKey, APIKeyValidation, NodeOutput,- ConversationMessage, ToolSchema, UserSkill, ChatMessage, UserSettings,- TokenUsageMetric, CompactionEvent, SessionTokenState, ProviderDefaults,- AgentTeam, TeamMember, TeamTask, AgentMessage, GoogleConnection,- ProxyProviderConfig, ProxyRoutingRule+ NodeParameter,+ Workflow,+ Execution,+ APIKey,+ APIKeyValidation,+ NodeOutput,+ ConversationMessage,+ ToolSchema,+ UserSkill,+ ChatMessage,+ UserSettings,+ TokenUsageMetric,+ CompactionEvent,+ SessionTokenState,+ ProviderDefaults,+ AgentTeam,+ TeamMember,+ TeamTask,+ AgentMessage,+ GoogleConnection,+ ProxyProviderConfig,+ ProxyRoutingRule,)from models.cache import CacheEntry # SQLite-backed cache for Redis alternativefrom core.logging import get_logger@@ -35,6 +52,7 @@ class Database:try:# Disable verbose database and asyncio loggingimport logging+logging.getLogger("aiosqlite").setLevel(logging.WARNING)logging.getLogger("sqlalchemy.engine").setLevel(logging.WARNING)logging.getLogger("sqlalchemy.dialects").setLevel(logging.WARNING)@@ -46,15 +64,11 @@ class Database:echo=self.settings.database_echo,pool_size=self.settings.database_pool_size,max_overflow=self.settings.database_max_overflow,- future=True+ future=True,)# Create session factory- self.async_session = async_sessionmaker(- bind=self.engine,- class_=AsyncSession,- expire_on_commit=False- )+ self.async_session = async_sessionmaker(bind=self.engine, class_=AsyncSession, expire_on_commit=False)# Create tablesasync with self.engine.begin() as conn:@@ -78,61 +92,41 @@ class Database:columns = {row[1] for row in result.fetchall()}if "console_panel_default_open" not in columns:- await conn.execute(text(- "ALTER TABLE user_settings ADD COLUMN console_panel_default_open BOOLEAN DEFAULT 0"- ))+ await conn.execute(text("ALTER TABLE user_settings ADD COLUMN console_panel_default_open BOOLEAN DEFAULT 0"))logger.info("Added console_panel_default_open column to user_settings")if "examples_loaded" not in columns:- await conn.execute(text(- "ALTER TABLE user_settings ADD COLUMN examples_loaded BOOLEAN DEFAULT 0"- ))+ await conn.execute(text("ALTER TABLE user_settings ADD COLUMN examples_loaded BOOLEAN DEFAULT 0"))logger.info("Added examples_loaded column to user_settings")if "onboarding_completed" not in columns:- await conn.execute(text(- "ALTER TABLE user_settings ADD COLUMN onboarding_completed BOOLEAN DEFAULT 0"- ))+ await conn.execute(text("ALTER TABLE user_settings ADD COLUMN onboarding_completed BOOLEAN DEFAULT 0"))# Existing users (examples_loaded=1) skip onboarding- await conn.execute(text(- "UPDATE user_settings SET onboarding_completed = 1 WHERE examples_loaded = 1"- ))+ await conn.execute(text("UPDATE user_settings SET onboarding_completed = 1 WHERE examples_loaded = 1"))logger.info("Added onboarding_completed column to user_settings")if "onboarding_step" not in columns:- await conn.execute(text(- "ALTER TABLE user_settings ADD COLUMN onboarding_step INTEGER DEFAULT 0"- ))+ await conn.execute(text("ALTER TABLE user_settings ADD COLUMN onboarding_step INTEGER DEFAULT 0"))logger.info("Added onboarding_step column to user_settings")if "memory_window_size" not in columns:- await conn.execute(text(- "ALTER TABLE user_settings ADD COLUMN memory_window_size INTEGER DEFAULT 100"- ))+ await conn.execute(text("ALTER TABLE user_settings ADD COLUMN memory_window_size INTEGER DEFAULT 100"))logger.info("Added memory_window_size column to user_settings")if "compaction_ratio" not in columns:- await conn.execute(text(- "ALTER TABLE user_settings ADD COLUMN compaction_ratio REAL DEFAULT 0.5"- ))+ await conn.execute(text("ALTER TABLE user_settings ADD COLUMN compaction_ratio REAL DEFAULT 0.5"))logger.info("Added compaction_ratio column to user_settings")if "default_llm_provider" not in columns:- await conn.execute(text(- "ALTER TABLE user_settings ADD COLUMN default_llm_provider VARCHAR(50)"- ))+ await conn.execute(text("ALTER TABLE user_settings ADD COLUMN default_llm_provider VARCHAR(50)"))logger.info("Added default_llm_provider column to user_settings")if "default_llm_model" not in columns:- await conn.execute(text(- "ALTER TABLE user_settings ADD COLUMN default_llm_model VARCHAR(200)"- ))+ await conn.execute(text("ALTER TABLE user_settings ADD COLUMN default_llm_model VARCHAR(200)"))logger.info("Added default_llm_model column to user_settings")if "auto_add_skill_for_tools" not in columns:- await conn.execute(text(- "ALTER TABLE user_settings ADD COLUMN auto_add_skill_for_tools BOOLEAN DEFAULT 1"- ))+ await conn.execute(text("ALTER TABLE user_settings ADD COLUMN auto_add_skill_for_tools BOOLEAN DEFAULT 1"))logger.info("Added auto_add_skill_for_tools column to user_settings")# Migrate token_usage_metrics table - add cost columns@@ -141,9 +135,7 @@ class Database:for col in ["input_cost", "output_cost", "cache_cost", "total_cost"]:if col not in columns:- await conn.execute(text(- f"ALTER TABLE token_usage_metrics ADD COLUMN {col} REAL DEFAULT 0.0"- ))+ await conn.execute(text(f"ALTER TABLE token_usage_metrics ADD COLUMN {col} REAL DEFAULT 0.0"))logger.info(f"Added {col} column to token_usage_metrics")# Migrate session_token_states table - add cumulative cost columns@@ -152,22 +144,19 @@ class Database:for col in ["cumulative_input_cost", "cumulative_output_cost", "cumulative_total_cost"]:if col not in columns:- await conn.execute(text(- f"ALTER TABLE session_token_states ADD COLUMN {col} REAL DEFAULT 0.0"- ))+ await conn.execute(text(f"ALTER TABLE session_token_states ADD COLUMN {col} REAL DEFAULT 0.0"))logger.info(f"Added {col} column to session_token_states")# Migrate provider_defaults table - add default_model columnresult = await conn.execute(text("PRAGMA table_info(provider_defaults)"))columns = {row[1] for row in result.fetchall()}if columns and "default_model" not in columns:- await conn.execute(text(- "ALTER TABLE provider_defaults ADD COLUMN default_model TEXT DEFAULT ''"- ))+ await conn.execute(text("ALTER TABLE provider_defaults ADD COLUMN default_model TEXT DEFAULT ''"))logger.info("Added default_model column to provider_defaults")# Create api_usage_metrics table if not exists- await conn.execute(text("""+ await conn.execute(+ text("""CREATE TABLE IF NOT EXISTS api_usage_metrics (id INTEGER PRIMARY KEY AUTOINCREMENT,timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,@@ -180,31 +169,22 @@ class Database:resource_count INTEGER DEFAULT 1,cost REAL DEFAULT 0.0)- """))- await conn.execute(text(- "CREATE INDEX IF NOT EXISTS idx_api_usage_session ON api_usage_metrics(session_id)"- ))- await conn.execute(text(- "CREATE INDEX IF NOT EXISTS idx_api_usage_service ON api_usage_metrics(service)"- ))+ """)+ )+ await conn.execute(text("CREATE INDEX IF NOT EXISTS idx_api_usage_session ON api_usage_metrics(session_id)"))+ await conn.execute(text("CREATE INDEX IF NOT EXISTS idx_api_usage_service ON api_usage_metrics(service)"))logger.info("Ensured api_usage_metrics table exists")# Migrate gmail_connections to google_connections# Check if old table exists and new table doesn't- result = await conn.execute(text(- "SELECT name FROM sqlite_master WHERE type='table' AND name='gmail_connections'"- ))+ result = await conn.execute(text("SELECT name FROM sqlite_master WHERE type='table' AND name='gmail_connections'"))old_table_exists = result.fetchone() is not None- result = await conn.execute(text(- "SELECT name FROM sqlite_master WHERE type='table' AND name='google_connections'"- ))+ result = await conn.execute(text("SELECT name FROM sqlite_master WHERE type='table' AND name='google_connections'"))new_table_exists = result.fetchone() is not Noneif old_table_exists and not new_table_exists:- await conn.execute(text(- "ALTER TABLE gmail_connections RENAME TO google_connections"- ))+ await conn.execute(text("ALTER TABLE gmail_connections RENAME TO google_connections"))logger.info("Migrated gmail_connections table to google_connections")except Exception as e:@@ -247,10 +227,7 @@ class Database:if existing:existing.parameters = parameterselse:- existing = NodeParameter(- node_id=node_id,- parameters=parameters- )+ existing = NodeParameter(node_id=node_id, parameters=parameters)session.add(existing)await session.commit()@@ -296,8 +273,7 @@ class Database:# Workflows# ============================================================================- async def save_workflow(self, workflow_id: str, name: str, data: Dict[str, Any],- description: Optional[str] = None) -> bool:+ async def save_workflow(self, workflow_id: str, name: str, data: Dict[str, Any], description: Optional[str] = None) -> bool:"""Save or update workflow."""try:async with self.get_session() as session:@@ -310,12 +286,7 @@ class Database:existing.description = descriptionexisting.data = dataelse:- existing = Workflow(- id=workflow_id,- name=name,- description=description,- data=data- )+ existing = Workflow(id=workflow_id, name=name, description=description, data=data)session.add(existing)await session.commit()@@ -371,9 +342,16 @@ class Database:# Executions# ============================================================================- async def save_execution(self, execution_id: str, workflow_id: str, node_id: str,- status: str, result: Optional[Dict[str, Any]] = None,- error: Optional[str] = None, execution_time: Optional[float] = None) -> bool:+ async def save_execution(+ self,+ execution_id: str,+ workflow_id: str,+ node_id: str,+ status: str,+ result: Optional[Dict[str, Any]] = None,+ error: Optional[str] = None,+ execution_time: Optional[float] = None,+ ) -> bool:"""Save execution result."""try:async with self.get_session() as session:@@ -384,7 +362,7 @@ class Database:status=status,result=result,error=error,- execution_time=execution_time+ execution_time=execution_time,)session.add(execution)await session.commit()@@ -410,9 +388,9 @@ class Database:# API Keys# ============================================================================- async def save_api_key(self, key_id: str, provider: str, session_id: str,- key_encrypted: str, key_hash: str,- models: Optional[List[str]] = None) -> bool:+ async def save_api_key(+ self, key_id: str, provider: str, session_id: str, key_encrypted: str, key_hash: str, models: Optional[List[str]] = None+ ) -> bool:"""Save encrypted API key."""logger.info(f"Database save_api_key called with key_id: {key_id}, provider: {provider}")@@ -425,7 +403,7 @@ class Database:key_encrypted=key_encrypted,key_hash=key_hash,models={"models": models} if models else None,- last_validated=datetime.now(timezone.utc)+ last_validated=datetime.now(timezone.utc),)session.add(api_key)await session.commit()@@ -460,6 +438,7 @@ class Database:except Exception as e:logger.error("Failed to save API key", provider=provider, error=str(e))import traceback+logger.error("Full traceback", traceback=traceback.format_exc())return False@@ -479,11 +458,7 @@ class Database:"""Get API key by provider and session."""try:async with self.get_session() as session:- stmt = select(APIKey).where(- APIKey.provider == provider,- APIKey.session_id == session_id,- APIKey.is_valid- )+ stmt = select(APIKey).where(APIKey.provider == provider, APIKey.session_id == session_id, APIKey.is_valid)result = await session.execute(stmt)return result.scalar_one_or_none()@@ -495,10 +470,7 @@ class Database:"""Delete API key."""try:async with self.get_session() as session:- stmt = select(APIKey).where(- APIKey.provider == provider,- APIKey.session_id == session_id- )+ stmt = select(APIKey).where(APIKey.provider == provider, APIKey.session_id == session_id)result = await session.execute(stmt)api_key = result.scalar_one_or_none()@@ -521,10 +493,7 @@ class Database:"""Save API key validation status."""try:async with self.get_session() as session:- validation = APIKeyValidation(- key_hash=key_hash,- validated=True- )+ validation = APIKeyValidation(key_hash=key_hash, validated=True)session.add(validation)await session.commit()return True@@ -563,16 +532,13 @@ class Database:# Node Outputs# ============================================================================- async def save_node_output(self, node_id: str, session_id: str, output_name: str,- data: Dict[str, Any]) -> bool:+ async def save_node_output(self, node_id: str, session_id: str, output_name: str, data: Dict[str, Any]) -> bool:"""Save or update node output."""try:async with self.get_session() as session:# Try to get existing outputstmt = select(NodeOutput).where(- NodeOutput.node_id == node_id,- NodeOutput.session_id == session_id,- NodeOutput.output_name == output_name+ NodeOutput.node_id == node_id, NodeOutput.session_id == session_id, NodeOutput.output_name == output_name)result = await session.execute(stmt)existing = result.scalar_one_or_none()@@ -582,12 +548,7 @@ class Database:existing.data = dataelse:action = "inserted"- existing = NodeOutput(- node_id=node_id,- session_id=session_id,- output_name=output_name,- data=data- )+ existing = NodeOutput(node_id=node_id, session_id=session_id, output_name=output_name, data=data)session.add(existing)await session.commit()@@ -597,18 +558,16 @@ class Database:except Exception as e:logger.error("Failed to save node output", node_id=node_id, error=str(e))import traceback+traceback.print_exc()return False- async def get_node_output(self, node_id: str, session_id: str = "default",- output_name: str = "output_0") -> Optional[Dict[str, Any]]:+ async def get_node_output(self, node_id: str, session_id: str = "default", output_name: str = "output_0") -> Optional[Dict[str, Any]]:"""Get node output data."""try:async with self.get_session() as session:stmt = select(NodeOutput).where(- NodeOutput.node_id == node_id,- NodeOutput.session_id == session_id,- NodeOutput.output_name == output_name+ NodeOutput.node_id == node_id, NodeOutput.session_id == session_id, NodeOutput.output_name == output_name)result = await session.execute(stmt)output = result.scalar_one_or_none()@@ -619,18 +578,14 @@ class Database:logger.error("Failed to get node output", node_id=node_id, error=str(e))return None- async def get_node_output_by_session(self, session_id: str,- output_name: str = "output_0") -> Optional[Dict[str, Any]]:+ async def get_node_output_by_session(self, session_id: str, output_name: str = "output_0") -> Optional[Dict[str, Any]]:"""Get node output by session_id only (for delegation result lookup).Used when node_id is unknown but session_id encodes the lookup key."""try:async with self.get_session() as session:- stmt = select(NodeOutput).where(- NodeOutput.session_id == session_id,- NodeOutput.output_name == output_name- )+ stmt = select(NodeOutput).where(NodeOutput.session_id == session_id, NodeOutput.output_name == output_name)result = await session.execute(stmt)output = result.scalar_one_or_none()@@ -688,11 +643,7 @@ class Database:"""Add a message to conversation history."""try:async with self.get_session() as session:- message = ConversationMessage(- session_id=session_id,- role=role,- content=content- )+ message = ConversationMessage(session_id=session_id, role=role, content=content)session.add(message)await session.commit()logger.info(f"[Memory] Added {role} message to session '{session_id}'")@@ -706,9 +657,11 @@ class Database:"""Get conversation messages, optionally limited to last N."""try:async with self.get_session() as session:- stmt = select(ConversationMessage).where(- ConversationMessage.session_id == session_id- ).order_by(ConversationMessage.created_at.asc())+ stmt = (+ select(ConversationMessage)+ .where(ConversationMessage.session_id == session_id)+ .order_by(ConversationMessage.created_at.asc())+ )result = await session.execute(stmt)messages = result.scalars().all()@@ -717,14 +670,7 @@ class Database:if window_size and window_size > 0:messages = messages[-window_size:]- return [- {- "role": m.role,- "content": m.content,- "timestamp": m.created_at.isoformat()- }- for m in messages- ]+ return [{"role": m.role, "content": m.content, "timestamp": m.created_at.isoformat()} for m in messages]except Exception as e:logger.error("Failed to get conversation messages", session_id=session_id, error=str(e))@@ -734,9 +680,7 @@ class Database:"""Clear all messages in a conversation session. Returns count deleted."""try:async with self.get_session() as session:- stmt = select(ConversationMessage).where(- ConversationMessage.session_id == session_id- )+ stmt = select(ConversationMessage).where(ConversationMessage.session_id == session_id)result = await session.execute(stmt)messages = result.scalars().all()@@ -758,10 +702,11 @@ class Database:async with self.get_session() as session:# Get distinct session IDs with message countfrom sqlalchemy import func as sql_func+stmt = select(ConversationMessage.session_id,- sql_func.count(ConversationMessage.id).label('message_count'),- sql_func.min(ConversationMessage.created_at).label('created_at')+ sql_func.count(ConversationMessage.id).label("message_count"),+ sql_func.min(ConversationMessage.created_at).label("created_at"),).group_by(ConversationMessage.session_id)result = await session.execute(stmt)@@ -771,7 +716,7 @@ class Database:{"session_id": row.session_id,"message_count": row.message_count,- "created_at": row.created_at.isoformat() if row.created_at else None+ "created_at": row.created_at.isoformat() if row.created_at else None,}for row in rows]@@ -788,11 +733,7 @@ class Database:"""Add a chat message to the console panel history."""try:async with self.get_session() as session:- chat_msg = ChatMessage(- session_id=session_id,- role=role,- message=message- )+ chat_msg = ChatMessage(session_id=session_id, role=role, message=message)session.add(chat_msg)await session.commit()logger.debug(f"[Chat] Added {role} message to session '{session_id}'")@@ -806,9 +747,7 @@ class Database:"""Get chat messages for a session, optionally limited to last N."""try:async with self.get_session() as session:- stmt = select(ChatMessage).where(- ChatMessage.session_id == session_id- ).order_by(ChatMessage.created_at.asc())+ stmt = select(ChatMessage).where(ChatMessage.session_id == session_id).order_by(ChatMessage.created_at.asc())result = await session.execute(stmt)messages = result.scalars().all()@@ -817,14 +756,7 @@ class Database:if limit and limit > 0:messages = messages[-limit:]- return [- {- "role": m.role,- "message": m.message,- "timestamp": m.created_at.isoformat()- }- for m in messages- ]+ return [{"role": m.role, "message": m.message, "timestamp": m.created_at.isoformat()} for m in messages]except Exception as e:logger.error("Failed to get chat messages", session_id=session_id, error=str(e))@@ -834,9 +766,7 @@ class Database:"""Clear all chat messages for a session. Returns count deleted."""try:async with self.get_session() as session:- stmt = select(ChatMessage).where(- ChatMessage.session_id == session_id- )+ stmt = select(ChatMessage).where(ChatMessage.session_id == session_id)result = await session.execute(stmt)messages = result.scalars().all()@@ -857,11 +787,16 @@ class Database:try:async with self.get_session() as session:from sqlalchemy import func as sa_func- stmt = select(- ChatMessage.session_id,- sa_func.count(ChatMessage.id).label('message_count'),- sa_func.max(ChatMessage.created_at).label('last_message_at')- ).group_by(ChatMessage.session_id).order_by(sa_func.max(ChatMessage.created_at).desc())++ stmt = (+ select(+ ChatMessage.session_id,+ sa_func.count(ChatMessage.id).label("message_count"),+ sa_func.max(ChatMessage.created_at).label("last_message_at"),+ )+ .group_by(ChatMessage.session_id)+ .order_by(sa_func.max(ChatMessage.created_at).desc())+ )result = await session.execute(stmt)rows = result.all()@@ -870,7 +805,7 @@ class Database:{"session_id": row.session_id,"message_count": row.message_count,- "last_message_at": row.last_message_at.isoformat() if row.last_message_at else None+ "last_message_at": row.last_message_at.isoformat() if row.last_message_at else None,}for row in rows]@@ -910,9 +845,7 @@ class Database:logger.error("Failed to add console log", error=str(e))return False- async def get_console_logs(- self, limit: int = 100, workflow_id: Optional[str] = None- ) -> List[Dict[str, Any]]:+ async def get_console_logs(self, limit: int = 100, workflow_id: Optional[str] = None) -> List[Dict[str, Any]]:"""Get console logs, optionally limited and scoped to a workflow.``workflow_id=None`` returns the global stream (legacy behavior, used@@ -976,10 +909,7 @@ class Database:await session.delete(log)await session.commit()- logger.info(- f"[Console] Cleared {count} console logs"- + (f" (workflow={workflow_id})" if workflow_id else " (all)")- )+ logger.info(f"[Console] Cleared {count} console logs" + (f" (workflow={workflow_id})" if workflow_id else " (all)"))return countexcept Exception as e:@@ -1001,11 +931,7 @@ class Database:return 0# Get IDs of logs to keep (most recent)- keep_stmt = (- select(ConsoleLog.id)- .order_by(ConsoleLog.created_at.desc())- .limit(keep)- )+ keep_stmt = select(ConsoleLog.id).order_by(ConsoleLog.created_at.desc()).limit(keep)keep_result = await session.execute(keep_stmt)keep_ids = {row[0] for row in keep_result.fetchall()}@@ -1034,6 +960,7 @@ class Database:async def get_cache_entry(self, key: str) -> Optional[str]:"""Get cache value by key. Returns None if expired or not found."""import time+try:async with self.get_session() as session:stmt = select(CacheEntry).where(CacheEntry.key == key)@@ -1059,6 +986,7 @@ class Database:async def set_cache_entry(self, key: str, value: str, ttl: Optional[int] = None) -> bool:"""Set cache value with optional TTL in seconds."""import time+try:expires_at = time.time() + ttl if ttl else None@@ -1073,12 +1001,7 @@ class Database:existing.expires_at = expires_atexisting.created_at = time.time()else:- entry = CacheEntry(- key=key,- value=value,- expires_at=expires_at,- created_at=time.time()- )+ entry = CacheEntry(key=key, value=value, expires_at=expires_at, created_at=time.time())session.add(entry)await session.commit()@@ -1132,12 +1055,10 @@ class Database:async def cleanup_expired_cache(self) -> int:"""Remove all expired cache entries. Returns count deleted."""import time+try:async with self.get_session() as session:- stmt = select(CacheEntry).where(- CacheEntry.expires_at.isnot(None),- CacheEntry.expires_at < time.time()- )+ stmt = select(CacheEntry).where(CacheEntry.expires_at.isnot(None), CacheEntry.expires_at < time.time())result = await session.execute(stmt)entries = result.scalars().all()@@ -1157,6 +1078,7 @@ class Database:async def cleanup_old_cache(self, max_age_hours: int = 24) -> int:"""Remove cache entries older than max_age_hours. Returns count deleted."""import time+try:async with self.get_session() as session:cutoff_time = time.time() - (max_age_hours * 3600)@@ -1180,6 +1102,7 @@ class Database:async def cache_exists(self, key: str) -> bool:"""Check if cache key exists and is not expired."""import time+try:async with self.get_session() as session:stmt = select(CacheEntry).where(CacheEntry.key == key)@@ -1203,9 +1126,14 @@ class Database:# Tool Schemas (Source of truth for tool node configurations)# ============================================================================- async def save_tool_schema(self, node_id: str, tool_name: str, tool_description: str,- schema_config: Dict[str, Any],- connected_services: Optional[Dict[str, Any]] = None) -> bool:+ async def save_tool_schema(+ self,+ node_id: str,+ tool_name: str,+ tool_description: str,+ schema_config: Dict[str, Any],+ connected_services: Optional[Dict[str, Any]] = None,+ ) -> bool:"""Save or update tool schema for a node."""try:async with self.get_session() as session:@@ -1227,7 +1155,7 @@ class Database:tool_name=tool_name,tool_description=tool_description,schema_config=schema_config,- connected_services=connected_services+ connected_services=connected_services,)session.add(existing)@@ -1257,7 +1185,7 @@ class Database:"schema_config": schema.schema_config,"connected_services": schema.connected_services,"created_at": schema.created_at.isoformat() if schema.created_at else None,- "updated_at": schema.updated_at.isoformat() if schema.updated_at else None+ "updated_at": schema.updated_at.isoformat() if schema.updated_at else None,}except Exception as e:@@ -1298,7 +1226,7 @@ class Database:"tool_description": s.tool_description,"schema_config": s.schema_config,"connected_services": s.connected_services,- "updated_at": s.updated_at.isoformat() if s.updated_at else None+ "updated_at": s.updated_at.isoformat() if s.updated_at else None,}for s in schemas]@@ -1312,12 +1240,7 @@ class Database:# ============================================================================async def save_android_relay_session(- self,- relay_url: str,- api_key: str,- device_id: str,- device_name: Optional[str] = None,- session_token: Optional[str] = None+ self, relay_url: str, api_key: str, device_id: str, device_name: Optional[str] = None, session_token: Optional[str] = None) -> bool:"""Save Android relay pairing session for auto-reconnect on server restart.@@ -1329,14 +1252,17 @@ class Database:session_token: Relay session token"""import json+try:- session_data = json.dumps({- "relay_url": relay_url,- "api_key": api_key,- "device_id": device_id,- "device_name": device_name,- "session_token": session_token- })+ session_data = json.dumps(+ {+ "relay_url": relay_url,+ "api_key": api_key,+ "device_id": device_id,+ "device_name": device_name,+ "session_token": session_token,+ }+ )# No TTL - session persists until explicitly clearedreturn await self.set_cache_entry("android_relay_session", session_data)except Exception as e:@@ -1350,6 +1276,7 @@ class Database:Session data dict or None if not found"""import json+try:value = await self.get_cache_entry("android_relay_session")if value:@@ -1382,7 +1309,7 @@ class Database:icon: str = "star",color: str = "#6366F1",metadata_json: Optional[Dict[str, Any]] = None,- created_by: Optional[int] = None+ created_by: Optional[int] = None,) -> Optional[Dict[str, Any]]:"""Create a new user skill."""try:@@ -1397,7 +1324,7 @@ class Database:icon=icon,color=color,metadata_json=metadata_json,- created_by=created_by+ created_by=created_by,)session.add(skill)await session.commit()@@ -1470,7 +1397,7 @@ class Database:icon: Optional[str] = None,color: Optional[str] = None,metadata_json: Optional[Dict[str, Any]] = None,- is_active: Optional[bool] = None+ is_active: Optional[bool] = None,) -> Optional[Dict[str, Any]]:"""Update an existing user skill."""try:@@ -1549,7 +1476,7 @@ class Database:"is_active": skill.is_active,"created_by": skill.created_by,"created_at": skill.created_at.isoformat() if skill.created_at else None,- "updated_at": skill.updated_at.isoformat() if skill.updated_at else None+ "updated_at": skill.updated_at.isoformat() if skill.updated_at else None,}# ============================================================================@@ -1583,7 +1510,7 @@ class Database:"default_llm_model": settings.default_llm_model,"auto_add_skill_for_tools": settings.auto_add_skill_for_tools,"created_at": settings.created_at.isoformat() if settings.created_at else None,- "updated_at": settings.updated_at.isoformat() if settings.updated_at else None+ "updated_at": settings.updated_at.isoformat() if settings.updated_at else None,}except Exception as e:@@ -1710,7 +1637,7 @@ class Database:reasoning_effort=defaults.get("reasoning_effort", "medium"),reasoning_format=defaults.get("reasoning_format", "parsed"),created_at=now,- updated_at=now+ updated_at=now,)session.add(record)@@ -1749,7 +1676,7 @@ class Database:input_cost=metric.get("input_cost", 0.0),output_cost=metric.get("output_cost", 0.0),cache_cost=metric.get("cache_cost", 0.0),- total_cost=metric.get("total_cost", 0.0)+ total_cost=metric.get("total_cost", 0.0),)session.add(entry)await session.commit()@@ -1758,9 +1685,7 @@ class Database:logger.error("Failed to save token metric", error=str(e))return False- async def get_session_token_metrics(- self, session_id: str, limit: int = 100- ) -> List[Dict[str, Any]]:+ async def get_session_token_metrics(self, session_id: str, limit: int = 100) -> List[Dict[str, Any]]:"""Get token metrics for a session."""try:async with self.get_session() as session:@@ -1787,7 +1712,7 @@ class Database:"cache_read_tokens": m.cache_read_tokens,"reasoning_tokens": m.reasoning_tokens,"iteration": m.iteration,- "created_at": m.created_at.isoformat() if m.created_at else None+ "created_at": m.created_at.isoformat() if m.created_at else None,}for m in metrics]@@ -1825,7 +1750,7 @@ class Database:func.sum(TokenUsageMetric.output_cost).label("output_cost"),func.sum(TokenUsageMetric.cache_cost).label("cache_cost"),func.sum(TokenUsageMetric.total_cost).label("total_cost"),- func.count().label("execution_count")+ func.count().label("execution_count"),).group_by(TokenUsageMetric.provider, TokenUsageMetric.model).order_by(TokenUsageMetric.provider, TokenUsageMetric.model)@@ -1848,7 +1773,7 @@ class Database:"total_cache_cost": 0.0,"total_cost": 0.0,"execution_count": 0,- "models": []+ "models": [],}p = providers[provider]@@ -1861,17 +1786,19 @@ class Database:p["total_cost"] += float(row.total_cost or 0)p["execution_count"] += row.execution_count or 0- p["models"].append({- "model": row.model,- "input_tokens": row.input_tokens or 0,- "output_tokens": row.output_tokens or 0,- "total_tokens": row.total_tokens or 0,- "input_cost": round(float(row.input_cost or 0), 6),- "output_cost": round(float(row.output_cost or 0), 6),- "cache_cost": round(float(row.cache_cost or 0), 6),- "total_cost": round(float(row.total_cost or 0), 6),- "execution_count": row.execution_count or 0- })+ p["models"].append(+ {+ "model": row.model,+ "input_tokens": row.input_tokens or 0,+ "output_tokens": row.output_tokens or 0,+ "total_tokens": row.total_tokens or 0,+ "input_cost": round(float(row.input_cost or 0), 6),+ "output_cost": round(float(row.output_cost or 0), 6),+ "cache_cost": round(float(row.cache_cost or 0), 6),+ "total_cost": round(float(row.total_cost or 0), 6),+ "execution_count": row.execution_count or 0,+ }+ )# Round provider totalsfor p in providers.values():@@ -1908,7 +1835,7 @@ class Database:operation=metric.get("operation", ""),endpoint=metric.get("endpoint", ""),resource_count=metric.get("resource_count", 1),- cost=metric.get("cost", 0.0)+ cost=metric.get("cost", 0.0),)session.add(entry)await session.commit()@@ -1941,7 +1868,7 @@ class Database:APIUsageMetric.operation,func.sum(APIUsageMetric.resource_count).label("resource_count"),func.sum(APIUsageMetric.cost).label("cost"),- func.count().label("execution_count")+ func.count().label("execution_count"),).group_by(APIUsageMetric.service, APIUsageMetric.operation)if service:@@ -1956,25 +1883,21 @@ class Database:for row in rows:svc = row.service or "unknown"if svc not in services:- services[svc] = {- "service": svc,- "total_resources": 0,- "total_cost": 0.0,- "execution_count": 0,- "operations": []- }+ services[svc] = {"service": svc, "total_resources": 0, "total_cost": 0.0, "execution_count": 0, "operations": []}s = services[svc]s["total_resources"] += row.resource_count or 0s["total_cost"] += float(row.cost or 0)s["execution_count"] += row.execution_count or 0- s["operations"].append({- "operation": row.operation,- "resource_count": row.resource_count or 0,- "total_cost": round(float(row.cost or 0), 6),- "execution_count": row.execution_count or 0- })+ s["operations"].append(+ {+ "operation": row.operation,+ "resource_count": row.resource_count or 0,+ "total_cost": round(float(row.cost or 0), 6),+ "execution_count": row.execution_count or 0,+ }+ )# Round service totalsfor s in services.values():@@ -1990,27 +1913,20 @@ class Database:# Session Token State# ============================================================================- async def get_or_create_session_token_state(- self, session_id: str- ) -> Dict[str, Any]:+ async def get_or_create_session_token_state(self, session_id: str) -> Dict[str, Any]:"""Get or create token state for a session.Handles race conditions when multiple requests try to create the same session."""try:async with self.get_session() as session:- stmt = select(SessionTokenState).where(- SessionTokenState.session_id == session_id- )+ stmt = select(SessionTokenState).where(SessionTokenState.session_id == session_id)result = await session.execute(stmt)state = result.scalar_one_or_none()if not state:try:- state = SessionTokenState(- session_id=session_id,- updated_at=datetime.now(timezone.utc)- )+ state = SessionTokenState(session_id=session_id, updated_at=datetime.now(timezone.utc))session.add(state)await session.commit()await session.refresh(state)@@ -2032,7 +1948,7 @@ class Database:"last_compaction_at": None,"compaction_count": 0,"custom_threshold": None,- "compaction_enabled": True+ "compaction_enabled": True,}return {@@ -2045,25 +1961,17 @@ class Database:"last_compaction_at": state.last_compaction_at.isoformat() if state.last_compaction_at else None,"compaction_count": state.compaction_count,"custom_threshold": state.custom_threshold,- "compaction_enabled": state.compaction_enabled+ "compaction_enabled": state.compaction_enabled,}except Exception as e:logger.error("Failed to get session token state", error=str(e))- return {- "session_id": session_id,- "cumulative_total": 0,- "compaction_enabled": True- }+ return {"session_id": session_id, "cumulative_total": 0, "compaction_enabled": True}- async def update_session_token_state(- self, session_id: str, updates: Dict[str, Any]- ) -> bool:+ async def update_session_token_state(self, session_id: str, updates: Dict[str, Any]) -> bool:"""Update session token state."""try:async with self.get_session() as session:- stmt = select(SessionTokenState).where(- SessionTokenState.session_id == session_id- )+ stmt = select(SessionTokenState).where(SessionTokenState.session_id == session_id)result = await session.execute(stmt)state = result.scalar_one_or_none()@@ -2084,14 +1992,17 @@ class Database:async def reset_session_token_state(self, session_id: str) -> bool:"""Reset token state after compaction."""- return await self.update_session_token_state(session_id, {- "cumulative_input_tokens": 0,- "cumulative_output_tokens": 0,- "cumulative_cache_tokens": 0,- "cumulative_reasoning_tokens": 0,- "cumulative_total": 0,- "last_compaction_at": datetime.now(timezone.utc)- })+ return await self.update_session_token_state(+ session_id,+ {+ "cumulative_input_tokens": 0,+ "cumulative_output_tokens": 0,+ "cumulative_cache_tokens": 0,+ "cumulative_reasoning_tokens": 0,+ "cumulative_total": 0,+ "last_compaction_at": datetime.now(timezone.utc),+ },+ )# ============================================================================# Compaction Events@@ -2116,7 +2027,7 @@ class Database:success=event.get("success", True),error_message=event.get("error_message"),summary_content=event.get("summary_content"),- created_at=datetime.now(timezone.utc)+ created_at=datetime.now(timezone.utc),)session.add(entry)await session.commit()@@ -2125,9 +2036,7 @@ class Database:logger.error("Failed to save compaction event", error=str(e))return False- async def get_compaction_history(- self, session_id: str, limit: int = 50- ) -> List[Dict[str, Any]]:+ async def get_compaction_history(self, session_id: str, limit: int = 50) -> List[Dict[str, Any]]:"""Get compaction history for a session."""try:async with self.get_session() as session:@@ -2152,7 +2061,7 @@ class Database:"messages_after": e.messages_after,"success": e.success,"error_message": e.error_message,- "created_at": e.created_at.isoformat() if e.created_at else None+ "created_at": e.created_at.isoformat() if e.created_at else None,}for e in events]@@ -2164,14 +2073,18 @@ class Database:# Agent Teams - CRUD Operations# ============================================================================- async def create_team(self, team_id: str, workflow_id: str, team_lead_node_id: str,- config: Optional[Dict[str, Any]] = None) -> Optional[Dict[str, Any]]:+ async def create_team(+ self, team_id: str, workflow_id: str, team_lead_node_id: str, config: Optional[Dict[str, Any]] = None+ ) -> Optional[Dict[str, Any]]:"""Create a new agent team."""try:async with self.get_session() as session:team = AgentTeam(- id=team_id, workflow_id=workflow_id, team_lead_node_id=team_lead_node_id,- config=config or {}, created_at=datetime.now(timezone.utc)+ id=team_id,+ workflow_id=workflow_id,+ team_lead_node_id=team_lead_node_id,+ config=config or {},+ created_at=datetime.now(timezone.utc),)session.add(team)await session.commit()@@ -2190,9 +2103,12 @@ class Database:if not team:return Nonereturn {- "id": team.id, "workflow_id": team.workflow_id, "team_lead_node_id": team.team_lead_node_id,- "status": team.status, "config": team.config,- "created_at": team.created_at.isoformat() if team.created_at else None+ "id": team.id,+ "workflow_id": team.workflow_id,+ "team_lead_node_id": team.team_lead_node_id,+ "status": team.status,+ "config": team.config,+ "created_at": team.created_at.isoformat() if team.created_at else None,}except Exception as e:logger.error(f"Failed to get team: {e}")@@ -2215,14 +2131,19 @@ class Database:logger.error(f"Failed to update team status: {e}")return False- async def add_team_member(self, team_id: str, agent_node_id: str, agent_type: str,- role: str = "teammate", agent_label: Optional[str] = None) -> Optional[Dict[str, Any]]:+ async def add_team_member(+ self, team_id: str, agent_node_id: str, agent_type: str, role: str = "teammate", agent_label: Optional[str] = None+ ) -> Optional[Dict[str, Any]]:"""Add member to team."""try:async with self.get_session() as session:member = TeamMember(- team_id=team_id, agent_node_id=agent_node_id, agent_type=agent_type,- agent_label=agent_label, role=role, joined_at=datetime.now(timezone.utc)+ team_id=team_id,+ agent_node_id=agent_node_id,+ agent_type=agent_type,+ agent_label=agent_label,+ role=role,+ joined_at=datetime.now(timezone.utc),)session.add(member)await session.commit()@@ -2235,12 +2156,16 @@ class Database:"""Get all team members."""try:async with self.get_session() as session:- result = await session.execute(- select(TeamMember).where(TeamMember.team_id == team_id)- )+ result = await session.execute(select(TeamMember).where(TeamMember.team_id == team_id))return [- {"id": m.id, "agent_node_id": m.agent_node_id, "agent_type": m.agent_type,- "agent_label": m.agent_label, "role": m.role, "status": m.status}+ {+ "id": m.id,+ "agent_node_id": m.agent_node_id,+ "agent_type": m.agent_type,+ "agent_label": m.agent_label,+ "role": m.role,+ "status": m.status,+ }for m in result.scalars().all()]except Exception as e:@@ -2252,9 +2177,7 @@ class Database:try:async with self.get_session() as session:result = await session.execute(- select(TeamMember).where(- TeamMember.team_id == team_id, TeamMember.agent_node_id == agent_node_id- )+ select(TeamMember).where(TeamMember.team_id == team_id, TeamMember.agent_node_id == agent_node_id))member = result.scalar_one_or_none()if not member:@@ -2266,17 +2189,28 @@ class Database:logger.error(f"Failed to update member status: {e}")return False- async def add_team_task(self, task_id: str, team_id: str, title: str, created_by: str,- description: Optional[str] = None, priority: int = 3,- depends_on: Optional[List[str]] = None) -> Optional[Dict[str, Any]]:+ async def add_team_task(+ self,+ task_id: str,+ team_id: str,+ title: str,+ created_by: str,+ description: Optional[str] = None,+ priority: int = 3,+ depends_on: Optional[List[str]] = None,+ ) -> Optional[Dict[str, Any]]:"""Add task to team's shared list."""try:async with self.get_session() as session:task = TeamTask(- id=task_id, team_id=team_id, title=title, description=description,- priority=priority, created_by=created_by,+ id=task_id,+ team_id=team_id,+ title=title,+ description=description,+ priority=priority,+ created_by=created_by,depends_on={"task_ids": depends_on} if depends_on else None,- created_at=datetime.now(timezone.utc)+ created_at=datetime.now(timezone.utc),)session.add(task)await session.commit()@@ -2295,9 +2229,16 @@ class Database:query = query.order_by(TeamTask.priority.asc(), TeamTask.created_at.asc())result = await session.execute(query)return [- {"id": t.id, "title": t.title, "description": t.description, "status": t.status,- "priority": t.priority, "assigned_to": t.assigned_to, "progress": t.progress,- "depends_on": t.depends_on.get("task_ids", []) if t.depends_on else []}+ {+ "id": t.id,+ "title": t.title,+ "description": t.description,+ "status": t.status,+ "priority": t.priority,+ "assigned_to": t.assigned_to,+ "progress": t.progress,+ "depends_on": t.depends_on.get("task_ids", []) if t.depends_on else [],+ }for t in result.scalars().all()]except Exception as e:@@ -2309,9 +2250,7 @@ class Database:try:async with self.get_session() as session:result = await session.execute(- select(TeamTask).where(- TeamTask.id == task_id, TeamTask.status == "pending", TeamTask.assigned_to.is_(None)- )+ select(TeamTask).where(TeamTask.id == task_id, TeamTask.status == "pending", TeamTask.assigned_to.is_(None)))task = result.scalar_one_or_none()if not task:@@ -2384,14 +2323,19 @@ class Database:logger.error(f"Failed to get claimable tasks: {e}")return []- async def add_agent_message(self, team_id: str, from_agent: str, content: str,- message_type: str = "direct", to_agent: Optional[str] = None) -> Optional[Dict[str, Any]]:+ async def add_agent_message(+ self, team_id: str, from_agent: str, content: str, message_type: str = "direct", to_agent: Optional[str] = None+ ) -> Optional[Dict[str, Any]]:"""Add message between agents."""try:async with self.get_session() as session:msg = AgentMessage(- team_id=team_id, from_agent=from_agent, to_agent=to_agent,- message_type=message_type, content=content, created_at=datetime.now(timezone.utc)+ team_id=team_id,+ from_agent=from_agent,+ to_agent=to_agent,+ message_type=message_type,+ content=content,+ created_at=datetime.now(timezone.utc),)session.add(msg)await session.commit()@@ -2400,26 +2344,31 @@ class Database:logger.error(f"Failed to add agent message: {e}")return None- async def get_agent_messages(self, team_id: str, agent_node_id: Optional[str] = None,- unread_only: bool = False) -> List[Dict[str, Any]]:+ async def get_agent_messages(+ self, team_id: str, agent_node_id: Optional[str] = None, unread_only: bool = False+ ) -> List[Dict[str, Any]]:"""Get messages for team or specific agent."""try:async with self.get_session() as session:from sqlalchemy import or_+query = select(AgentMessage).where(AgentMessage.team_id == team_id)if agent_node_id:- query = query.where(or_(- AgentMessage.to_agent == agent_node_id,- AgentMessage.to_agent.is_(None)- ))+ query = query.where(or_(AgentMessage.to_agent == agent_node_id, AgentMessage.to_agent.is_(None)))if unread_only:query = query.where(not AgentMessage.read)query = query.order_by(AgentMessage.created_at.asc()).limit(100)result = await session.execute(query)return [- {"id": m.id, "from_agent": m.from_agent, "to_agent": m.to_agent,- "message_type": m.message_type, "content": m.content, "read": m.read,- "created_at": m.created_at.isoformat() if m.created_at else None}+ {+ "id": m.id,+ "from_agent": m.from_agent,+ "to_agent": m.to_agent,+ "message_type": m.message_type,+ "content": m.content,+ "read": m.read,+ "created_at": m.created_at.isoformat() if m.created_at else None,+ }for m in result.scalars().all()]except Exception as e:@@ -2431,11 +2380,12 @@ class Database:try:async with self.get_session() as session:from sqlalchemy import or_+result = await session.execute(select(AgentMessage).where(AgentMessage.team_id == team_id,not AgentMessage.read,- or_(AgentMessage.to_agent == agent_node_id, AgentMessage.to_agent.is_(None))+ or_(AgentMessage.to_agent == agent_node_id, AgentMessage.to_agent.is_(None)),))messages = result.scalars().all()@@ -2473,8 +2423,11 @@ class Database:"task_completed": sum(1 for t in tasks if t.status == "completed"),"task_failed": sum(1 for t in tasks if t.status == "failed"),"members": [{"id": m.agent_node_id, "type": m.agent_type, "status": m.status} for m in members],- "active_tasks": [{"id": t.id, "title": t.title, "assigned_to": t.assigned_to, "progress": t.progress}- for t in tasks if t.status == "in_progress"]+ "active_tasks": [+ {"id": t.id, "title": t.title, "assigned_to": t.assigned_to, "progress": t.progress}+ for t in tasks+ if t.status == "in_progress"+ ],}except Exception as e:logger.error(f"Failed to get team stats: {e}")@@ -2497,9 +2450,7 @@ class Database:try:async with self.get_session() as session:# Check if connection exists- result = await session.execute(- select(GoogleConnection).where(GoogleConnection.customer_id == customer_id)- )+ result = await session.execute(select(GoogleConnection).where(GoogleConnection.customer_id == customer_id))existing = result.scalar_one_or_none()now = datetime.now(timezone.utc)@@ -2539,10 +2490,7 @@ class Database:try:async with self.get_session() as session:result = await session.execute(- select(GoogleConnection).where(- GoogleConnection.customer_id == customer_id,- GoogleConnection.is_active- )+ select(GoogleConnection).where(GoogleConnection.customer_id == customer_id, GoogleConnection.is_active))return result.scalar_one_or_none()except Exception as e:@@ -2553,9 +2501,7 @@ class Database:"""Delete Google Workspace connection for a customer."""try:async with self.get_session() as session:- result = await session.execute(- select(GoogleConnection).where(GoogleConnection.customer_id == customer_id)- )+ result = await session.execute(select(GoogleConnection).where(GoogleConnection.customer_id == customer_id))connection = result.scalar_one_or_none()if connection:await session.delete(connection)@@ -2571,10 +2517,7 @@ class Database:try:async with self.get_session() as session:result = await session.execute(- select(GoogleConnection)- .where(GoogleConnection.is_active)- .order_by(GoogleConnection.connected_at.desc())- .limit(limit)+ select(GoogleConnection).where(GoogleConnection.is_active).order_by(GoogleConnection.connected_at.desc()).limit(limit))connections = result.scalars().all()return [@@ -2600,9 +2543,7 @@ class Database:"""Update tokens for a Google Workspace connection (after refresh)."""try:async with self.get_session() as session:- result = await session.execute(- select(GoogleConnection).where(GoogleConnection.customer_id == customer_id)- )+ result = await session.execute(select(GoogleConnection).where(GoogleConnection.customer_id == customer_id))connection = result.scalar_one_or_none()if connection:connection.access_token = access_token@@ -2620,9 +2561,7 @@ class Database:"""Update last_used_at timestamp for a Google Workspace connection."""try:async with self.get_session() as session:- result = await session.execute(- select(GoogleConnection).where(GoogleConnection.customer_id == customer_id)- )+ result = await session.execute(select(GoogleConnection).where(GoogleConnection.customer_id == customer_id))connection = result.scalar_one_or_none()if connection:connection.last_used_at = datetime.now(timezone.utc)@@ -2814,4 +2753,4 @@ class Database:except Exception as e:logger.error(f"Failed to delete proxy routing rule: {e}")- return False\ No newline at end of file+ return Falsediff --git a/server/core/health.py b/server/core/health.pyindex a1ae2d4b..f9c9a9ef 100644--- a/server/core/health.py+++ b/server/core/health.py@@ -2,11 +2,13 @@Provides uptime tracking and comprehensive health status for /health endpoint."""+import timefrom typing import Dict, Any, TYPE_CHECKINGtry:import psutil+PSUTIL_AVAILABLE = Trueexcept ImportError:PSUTIL_AVAILABLE = False@@ -66,6 +68,7 @@ async def check_database(database: "Database") -> bool:try:async with database.get_session() as session:from sqlalchemy import text+await session.execute(text("SELECT 1"))return Trueexcept Exception:@@ -84,11 +87,7 @@ async def check_cache(cache: "CacheService") -> bool:return False-async def get_health_status(- database: "Database",- cache: "CacheService",- settings: "Settings"-) -> Dict[str, Any]:+async def get_health_status(database: "Database", cache: "CacheService", settings: "Settings") -> Dict[str, Any]:"""Get comprehensive health status for /health endpoint.Returns:diff --git a/server/core/logging.py b/server/core/logging.pyindex 8e1d78f7..46bc8f38 100644--- a/server/core/logging.py+++ b/server/core/logging.py@@ -49,24 +49,23 @@ from core.config import Settings_LOG_SOURCE_TAGS: Dict[str, str] = {# Cross-cutting service short tags. Longer prefixes must precede# shorter parents — Python ≥3.7 preserves dict-insertion order.- 'services.workflow_validator': 'validator',- 'services.workflow_import': 'wf_import',- 'services.parameter_resolver': 'params',- 'services.node_executor': 'executor',- 'services.status_broadcaster': 'broadcaster',- 'services.ws_handler_registry': 'ws_registry',- 'services.credential_registry': 'credentials',- 'services.user_auth': 'auth',- 'services.model_registry': 'models',- 'services.node_output_schemas': 'schemas',- 'services.markdown_formatter': 'markdown',- 'services.example_loader': 'examples',- 'services.skill_loader': 'skills',- 'services.event_waiter': 'waiter',-+ "services.workflow_validator": "validator",+ "services.workflow_import": "wf_import",+ "services.parameter_resolver": "params",+ "services.node_executor": "executor",+ "services.status_broadcaster": "broadcaster",+ "services.ws_handler_registry": "ws_registry",+ "services.credential_registry": "credentials",+ "services.user_auth": "auth",+ "services.model_registry": "models",+ "services.node_output_schemas": "schemas",+ "services.markdown_formatter": "markdown",+ "services.example_loader": "examples",+ "services.skill_loader": "skills",+ "services.event_waiter": "waiter",# Core-infra short tags.- 'core.credentials_database': 'credentials',- 'core.credential_backends': 'credentials',+ "core.credentials_database": "credentials",+ "core.credential_backends": "credentials",}@@ -126,7 +125,7 @@ class WebSocketLogHandler(logging.Handler):A background thread processes the queue and uses asyncio to broadcast."""- _instance: Optional['WebSocketLogHandler'] = None+ _instance: Optional["WebSocketLogHandler"] = Nonedef __init__(self, level: int = logging.INFO):super().__init__(level)@@ -136,7 +135,7 @@ class WebSocketLogHandler(logging.Handler):self._loop: Optional[asyncio.AbstractEventLoop] = None@classmethod- def get_instance(cls) -> Optional['WebSocketLogHandler']:+ def get_instance(cls) -> Optional["WebSocketLogHandler"]:"""Get the singleton instance."""return cls._instance@@ -156,29 +155,48 @@ class WebSocketLogHandler(logging.Handler):# Extract structured key-value pairs from structlogdetails = None- if hasattr(record, '_logger') or hasattr(record, 'positional_args'):+ if hasattr(record, "_logger") or hasattr(record, "positional_args"):# Try to get extra kwargs from structlogextra_keys = set(record.__dict__.keys()) - {- 'name', 'msg', 'args', 'created', 'filename', 'funcName',- 'levelname', 'levelno', 'lineno', 'module', 'msecs',- 'pathname', 'process', 'processName', 'relativeCreated',- 'stack_info', 'exc_info', 'exc_text', 'thread', 'threadName',- 'message', 'asctime', 'positional_args', '_logger'+ "name",+ "msg",+ "args",+ "created",+ "filename",+ "funcName",+ "levelname",+ "levelno",+ "lineno",+ "module",+ "msecs",+ "pathname",+ "process",+ "processName",+ "relativeCreated",+ "stack_info",+ "exc_info",+ "exc_text",+ "thread",+ "threadName",+ "message",+ "asctime",+ "positional_args",+ "_logger",}if extra_keys:- details = {k: record.__dict__[k] for k in extra_keys if not k.startswith('_')}+ details = {k: record.__dict__[k] for k in extra_keys if not k.startswith("_")}# Create log entrylog_data = {- 'timestamp': datetime.now().isoformat(),- 'level': record.levelname.lower(),- 'message': message,- 'source': source,+ "timestamp": datetime.now().isoformat(),+ "level": record.levelname.lower(),+ "message": message,+ "source": source,}# Add details if presentif details:- log_data['details'] = details+ log_data["details"] = details# Non-blocking put - drop if queue is fulltry:@@ -219,10 +237,7 @@ class WebSocketLogHandler(logging.Handler):# Schedule async broadcast on the event loopif self._loop and self._running:- asyncio.run_coroutine_threadsafe(- self._broadcast(log_data),- self._loop- )+ asyncio.run_coroutine_threadsafe(self._broadcast(log_data), self._loop)except Exception:pass # Never fail in background thread@@ -231,6 +246,7 @@ class WebSocketLogHandler(logging.Handler):"""Broadcast log to WebSocket clients."""try:from services.status_broadcaster import get_status_broadcaster+broadcaster = get_status_broadcaster()await broadcaster.broadcast_terminal_log(log_data)except Exception:@@ -272,11 +288,7 @@ def configure_logging(settings: Settings) -> None:console_handler.setLevel(log_level_value)# Configure root logger- logging.basicConfig(- level=log_level_value,- handlers=[console_handler, file_handler],- format="%(message)s"- )+ logging.basicConfig(level=log_level_value, handlers=[console_handler, file_handler], format="%(message)s")else:# Console onlylogging.basicConfig(@@ -310,11 +322,13 @@ def configure_logging(settings: Settings) -> None:processors.insert(0, structlog.stdlib.add_logger_name)processors.append(structlog.processors.JSONRenderer())else:- processors.append(structlog.dev.ConsoleRenderer(- colors=False, # No ANSI colors for cleaner output- pad_event=35,- exception_formatter=structlog.dev.plain_traceback- ))+ processors.append(+ structlog.dev.ConsoleRenderer(+ colors=False, # No ANSI colors for cleaner output+ pad_event=35,+ exception_formatter=structlog.dev.plain_traceback,+ )+ )structlog.configure(processors=processors,@@ -379,39 +393,20 @@ def log_context_sync(**fields: Any) -> Iterator[None]:structlog.contextvars.unbind_contextvars(*fields.keys())-def log_execution_time(logger: structlog.BoundLogger, operation: str,- start_time: float, end_time: float, **kwargs) -> None:+def log_execution_time(logger: structlog.BoundLogger, operation: str, start_time: float, end_time: float, **kwargs) -> None:"""Log execution time with additional context."""execution_time = end_time - start_time- logger.info(- "Operation completed",- operation=operation,- execution_time_seconds=round(execution_time, 4),- **kwargs- )+ logger.info("Operation completed", operation=operation, execution_time_seconds=round(execution_time, 4), **kwargs)-def log_api_call(logger: structlog.BoundLogger, provider: str, model: str,- operation: str, success: bool, **kwargs) -> None:+def log_api_call(logger: structlog.BoundLogger, provider: str, model: str, operation: str, success: bool, **kwargs) -> None:"""Log API calls with standardized format."""- logger.info(- "API call completed",- provider=provider,- model=model,- operation=operation,- success=success,- **kwargs- )+ logger.info("API call completed", provider=provider, model=model, operation=operation, success=success, **kwargs)-def log_cache_operation(logger: structlog.BoundLogger, operation: str,- key: str, hit: bool = None, **kwargs) -> None:+def log_cache_operation(logger: structlog.BoundLogger, operation: str, key: str, hit: bool = None, **kwargs) -> None:"""Log cache operations."""- log_data = {- "operation": operation,- "cache_key": key,- **kwargs- }+ log_data = {"operation": operation, "cache_key": key, **kwargs}if hit is not None:log_data["cache_hit"] = hit@@ -475,4 +470,4 @@ def shutdown_websocket_logging() -> None:def get_websocket_log_handler() -> Optional[WebSocketLogHandler]:"""Get the current WebSocket log handler instance."""- return _ws_log_handler\ No newline at end of file+ return _ws_log_handlerdiff --git a/server/core/tracing.py b/server/core/tracing.pyindex 0143f9f1..39e9718b 100644--- a/server/core/tracing.py+++ b/server/core/tracing.py@@ -68,15 +68,9 @@ def init_tracing(service_name: str = "machinaos-backend") -> None:if _INITIALIZED:return- provider = TracerProvider(- resource=Resource.create({SERVICE_NAME: service_name})- )+ provider = TracerProvider(resource=Resource.create({SERVICE_NAME: service_name}))# Compact one-line console output instead of the default 30-line# JSON dump per span — keeps interactive logs readable.- provider.add_span_processor(- BatchSpanProcessor(- ConsoleSpanExporter(formatter=_compact_span_formatter)- )- )+ provider.add_span_processor(BatchSpanProcessor(ConsoleSpanExporter(formatter=_compact_span_formatter)))trace.set_tracer_provider(provider)_INITIALIZED = Truediff --git a/server/gunicorn.conf.py b/server/gunicorn.conf.pyindex d0f6f426..a0be8ae3 100644--- a/server/gunicorn.conf.py+++ b/server/gunicorn.conf.py@@ -6,6 +6,7 @@ No hardcoded values - everything from .env file.Usage:gunicorn main:app -c gunicorn.conf.py"""+import osimport multiprocessingdiff --git a/server/main.py b/server/main.pyindex 4b5d2f33..cf3e838b 100644--- a/server/main.py+++ b/server/main.py@@ -20,6 +20,7 @@ def _startup_log(msg):# Performance: Install uvloop if available (Linux/macOS only)try:import uvloop+uvloop.install()except ImportError:pass # Windows - uvloop not available, use default asyncio@@ -48,6 +49,7 @@ _startup_log("Importing settings + logging...")from core.config import Settingsfrom core.logging import configure_logging, get_logger, setup_websocket_logging, shutdown_websocket_loggingfrom core.tracing import init_tracing+settings = Settings()configure_logging(settings)init_tracing()@@ -55,12 +57,15 @@ logger = get_logger(__name__)_startup_log("Importing DI container + all services...")from core.container import container+_startup_log("Importing routers...")from routers import workflow, database, nodejs_compat, websocket, webhook, auth, credentials, schemas+_startup_log("All imports complete")# Suppress noisy loggersimport logging+logging.getLogger("apscheduler").setLevel(logging.WARNING)logging.getLogger("apscheduler.scheduler").setLevel(logging.WARNING)logging.getLogger("apscheduler.executors").setLevel(logging.WARNING)@@ -115,15 +120,18 @@ async def lifespan(app: FastAPI):# get_api_usage_summary). Flat module (sibling to services/pricing.py)# to avoid renaming the existing `services.pricing` import path.import services.pricing_handlers # noqa: F401- container.wire(modules=[- "routers.workflow",- "routers.database",- "routers.nodejs_compat",- "routers.websocket",- "routers.webhook",- "routers.auth",- "middleware.auth"- ])++ container.wire(+ modules=[+ "routers.workflow",+ "routers.database",+ "routers.nodejs_compat",+ "routers.websocket",+ "routers.webhook",+ "routers.auth",+ "middleware.auth",+ ]+ )# Start servicesawait container.database().startup()@@ -145,10 +153,12 @@ async def lifespan(app: FastAPI):# Initialize event waiter with cache service for Redis Streams supportfrom services import event_waiter+event_waiter.set_cache_service(container.cache())# Start APScheduler for cron jobsfrom services.scheduler import start_scheduler, shutdown_scheduler+start_scheduler()# Initialize execution engine recovery sweeper@@ -157,6 +167,7 @@ async def lifespan(app: FastAPI):RecoverySweeper,set_recovery_sweeper,)+execution_cache = ExecutionCache(container.cache())recovery_sweeper = RecoverySweeper(execution_cache)set_recovery_sweeper(recovery_sweeper)@@ -165,9 +176,7 @@ async def lifespan(app: FastAPI):if settings.redis_enabled:incomplete = await recovery_sweeper.scan_on_startup()if incomplete:- logger.info("Found incomplete executions on startup",- count=len(incomplete),- execution_ids=incomplete)+ logger.info("Found incomplete executions on startup", count=len(incomplete), execution_ids=incomplete)# Start background recovery sweeperawait recovery_sweeper.start()@@ -181,13 +190,10 @@ async def lifespan(app: FastAPI):# Start cleanup service for long-running daemonfrom core.cleanup import CleanupServicefrom core.health import set_startup_time+cleanup_service = Noneif settings.cleanup_enabled:- cleanup_service = CleanupService(- database=container.database(),- cache=container.cache(),- settings=settings- )+ cleanup_service = CleanupService(database=container.database(), cache=container.cache(), settings=settings)await cleanup_service.start()# Initialize compaction service and wire AI service@@ -198,27 +204,32 @@ async def lifespan(app: FastAPI):# Initialize model registry servicefrom services.model_registry import get_model_registry+model_registry = get_model_registry()model_registry.startup()logger.info("Model registry initialized")# Background refresh if cache is staleif model_registry.is_stale():+async def _refresh_registry():try:count = await model_registry.refresh()logger.info(f"Model registry refreshed: {count} models")except Exception as e:logger.warning(f"Model registry refresh failed (offline?): {e}")+asyncio.create_task(_refresh_registry())# Initialize agent team servicefrom services.agent_team import init_agent_team_servicefrom services.status_broadcaster import get_status_broadcaster+init_agent_team_service(container.database(), get_status_broadcaster())# Wire process service to broadcaster for Terminal tab streamingfrom services.process_service import get_process_service+proc_svc = get_process_service()proc_svc.set_broadcaster(get_status_broadcaster())# Load max_processes from user settings if configured@@ -232,6 +243,7 @@ async def lifespan(app: FastAPI):# Initialize proxy service (loads providers from DB, reads credentials)from services.proxy.service import init_proxy_service+proxy_svc = init_proxy_service(auth_service=container.auth_service(),database=container.database(),@@ -301,8 +313,7 @@ async def lifespan(app: FastAPI):terminated = await temporal_client_wrapper.terminate_running_workflows()if terminated:_startup_log(- f"[Temporal] Terminated {terminated} running workflow(s) "- "at startup (history preserved)"+ f"[Temporal] Terminated {terminated} running workflow(s) " "at startup (history preserved)")except Exception as term_exc: # noqa: BLE001 — non-fatallogger.warning(@@ -322,18 +333,14 @@ async def lifespan(app: FastAPI):await worker_manager.start()app.state.temporal_worker_manager = worker_manager- _startup_log(- f"[Temporal] Worker started, execution engine ready (attempt {attempt})"- )+ _startup_log(f"[Temporal] Worker started, execution engine ready (attempt {attempt})")logger.info("Temporal integration initialized successfully",attempts=attempt,)returnexcept Exception as exc:- _startup_log(- f"[Temporal] Executor/worker setup failed (attempt {attempt}): {exc}; will retry"- )+ _startup_log(f"[Temporal] Executor/worker setup failed (attempt {attempt}): {exc}; will retry")logger.error("Temporal executor/worker setup failed; will retry",error=str(exc),@@ -342,9 +349,7 @@ async def lifespan(app: FastAPI):await temporal_client_wrapper.disconnect()await asyncio.sleep(3.0)- temporal_init_task = asyncio.create_task(- _init_temporal_background(), name="temporal-init"- )+ temporal_init_task = asyncio.create_task(_init_temporal_background(), name="temporal-init")else:_startup_log("[Temporal] Disabled")@@ -355,6 +360,7 @@ async def lifespan(app: FastAPI):cli_mcp_lifespan_ctx = Nonetry:from services.cli_agent.mcp_server import get_mcp_app as _get_cli_mcp_app+_cli_mcp_app = _get_cli_mcp_app()cli_mcp_lifespan_ctx = _cli_mcp_app.router.lifespan_context(_cli_mcp_app)await cli_mcp_lifespan_ctx.__aenter__()@@ -413,6 +419,7 @@ async def lifespan(app: FastAPI):# Shutdown proxy servicefrom services.proxy.service import get_proxy_service+_proxy_svc = get_proxy_service()if _proxy_svc:await _proxy_svc.shutdown()@@ -424,16 +431,19 @@ async def lifespan(app: FastAPI):# New plugins with cleanup needs register a hook from their# __init__.py — main.py never edits.from services.plugin.shutdown_hooks import run_shutdown_hooks+await run_shutdown_hooks()# Kill all managed processes (process manager node)from services.process_service import shutdown_process_service+await shutdown_process_service()# Stop every plugin supervisor that registered itself via# services._supervisor.register_supervisor() (currently: WhatsApp;# other plugins migrate in PR 2).from services._supervisor import shutdown_all_supervisors+await shutdown_all_supervisors()# Stop cleanup service@@ -473,33 +483,31 @@ from fastapi import Request, statusfrom fastapi.responses import JSONResponsefrom starlette.middleware.base import BaseHTTPMiddleware+class CatchAllExceptionsMiddleware(BaseHTTPMiddleware):async def dispatch(self, request: Request, call_next):try:return await call_next(request)except Exception as e:import traceback+traceback.print_exc()logger.error(f"Unhandled exception: {type(e).__name__}: {str(e)}", exc_info=True)return JSONResponse(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,- content={- "success": False,- "error": f"{type(e).__name__}: {str(e)}",- "detail": "Internal server error"- }+ content={"success": False, "error": f"{type(e).__name__}: {str(e)}", "detail": "Internal server error"},)+app.add_middleware(CatchAllExceptionsMiddleware)# Add Auth middleware (checks JWT cookie for protected routes)from middleware.auth import AuthMiddleware+app.add_middleware(AuthMiddleware)# Add CORS middleware (must be AFTER exception middleware)-logger.info("Configuring CORS middleware",- origins_count=len(settings.cors_origins),- origins=settings.cors_origins)+logger.info("Configuring CORS middleware", origins_count=len(settings.cors_origins), origins=settings.cors_origins)app.add_middleware(CORSMiddleware,allow_origins=settings.cors_origins,@@ -536,6 +544,7 @@ app.include_router(webhook.router)# the node-discovery walk on app startup; iterating here picks up# anything that registered.from services.ws_handler_registry import get_routers as _get_plugin_routers+for _plugin_router in _get_plugin_routers():app.include_router(_plugin_router)@@ -550,6 +559,7 @@ for _plugin_router in _get_plugin_routers():# Bearer-token auth scoped per batch (see services/cli_agent/mcp_server.py).try:from services.cli_agent.mcp_server import get_mcp_app as _get_cli_mcp_app+_cli_mcp_app = _get_cli_mcp_app()app.mount("/mcp/ide", _cli_mcp_app)logger.info("[main] mounted CLI agent MCP server at /mcp/ide")@@ -565,6 +575,7 @@ async def _sweep_cli_lockfiles_on_startup() -> None:from services.cli_agent.config import list_provider_namesfrom services.cli_agent.factory import create_cli_providerfrom services.cli_agent.lockfile import sweep_stale_lockfiles+# Ask the provider class for its lockfile dir rather than the# raw JSON config — the provider is the source of truth (e.g.# the claude provider derives its dir from@@ -592,11 +603,7 @@ async def health_check():sweeper = get_recovery_sweeper()# Get comprehensive health status- health = await get_health_status(- database=container.database(),- cache=container.cache(),- settings=settings- )+ health = await get_health_status(database=container.database(), cache=container.cache(), settings=settings)# Check Temporal statustemporal_status = {@@ -633,14 +640,14 @@ async def health_check():"recovery_sweeper": sweeper is not None and sweeper._running,},"temporal": temporal_status,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}if __name__ == "__main__":import uvicorn- logger.info("Starting React Flow Python Services",- host=settings.host, port=settings.port, debug=settings.debug)++ logger.info("Starting React Flow Python Services", host=settings.host, port=settings.port, debug=settings.debug)uvicorn.run("main:app",host=settings.host,@@ -648,5 +655,5 @@ if __name__ == "__main__":reload=settings.debug,reload_dirs=["."] if settings.debug else None,reload_excludes=["*.pyc", "__pycache__", "*.log", "*.db"] if settings.debug else None,- workers=1 if settings.debug else settings.workers- )\ No newline at end of file+ workers=1 if settings.debug else settings.workers,+ )diff --git a/server/middleware/auth.py b/server/middleware/auth.pyindex 19ba4a17..98198915 100644--- a/server/middleware/auth.py+++ b/server/middleware/auth.py@@ -10,22 +10,22 @@ from core.container import containerlogger = logging.getLogger(__name__)# Public routes that don't require authentication-PUBLIC_PATHS = frozenset([- "/health",- "/docs",- "/openapi.json",- "/redoc",- "/api/auth/status",- "/api/auth/login",- "/api/auth/register",- "/api/auth/logout",- "/ws/internal", # Internal WebSocket for Temporal workers-])+PUBLIC_PATHS = frozenset(+ [+ "/health",+ "/docs",+ "/openapi.json",+ "/redoc",+ "/api/auth/status",+ "/api/auth/login",+ "/api/auth/register",+ "/api/auth/logout",+ "/ws/internal", # Internal WebSocket for Temporal workers+ ]+)# Path prefixes that are public-PUBLIC_PREFIXES = (- "/webhook/",-)+PUBLIC_PREFIXES = ("/webhook/",)class AuthMiddleware(BaseHTTPMiddleware):@@ -42,10 +42,10 @@ class AuthMiddleware(BaseHTTPMiddleware):settings = container.settings()# Check if auth is disabled (VITE_AUTH_ENABLED=false)- if settings.vite_auth_enabled and settings.vite_auth_enabled.lower() == 'false':+ if settings.vite_auth_enabled and settings.vite_auth_enabled.lower() == "false":# Auth disabled - set anonymous user and allow requestrequest.state.user_id = 0- request.state.user_email = 'anonymous'+ request.state.user_email = "anonymous"request.state.is_owner = Truereturn await call_next(request)@@ -53,20 +53,14 @@ class AuthMiddleware(BaseHTTPMiddleware):token = request.cookies.get(settings.jwt_cookie_name)if not token:- return JSONResponse(- status_code=401,- content={"detail": "Not authenticated"}- )+ return JSONResponse(status_code=401, content={"detail": "Not authenticated"})# Verify tokenuser_auth = container.user_auth_service()payload = user_auth.verify_token(token)if not payload:- return JSONResponse(- status_code=401,- content={"detail": "Invalid or expired session"}- )+ return JSONResponse(status_code=401, content={"detail": "Invalid or expired session"})# Attach user info to request state for downstream handlersrequest.state.user_id = payload.get("sub")diff --git a/server/models/__init__.py b/server/models/__init__.pyindex ffa92f95..cede0cd4 100644--- a/server/models/__init__.py+++ b/server/models/__init__.py@@ -1 +1 @@-# Database models\ No newline at end of file+# Database modelsdiff --git a/server/models/auth.py b/server/models/auth.pyindex c91811b3..02a4070c 100644--- a/server/models/auth.py+++ b/server/models/auth.py@@ -19,25 +19,18 @@ class User(SQLModel, table=True):is_owner: bool = Field(default=False) # First user in single-owner modeis_active: bool = Field(default=True)created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())- )- last_login: Optional[datetime] = Field(- default=None,- sa_column=Column(DateTime(timezone=True), nullable=True)+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))+ last_login: Optional[datetime] = Field(default=None, sa_column=Column(DateTime(timezone=True), nullable=True))def set_password(self, password: str) -> None:"""Hash and set password using bcrypt."""salt = bcrypt.gensalt()- self.password_hash = bcrypt.hashpw(password.encode('utf-8'), salt).decode('utf-8')+ self.password_hash = bcrypt.hashpw(password.encode("utf-8"), salt).decode("utf-8")def verify_password(self, password: str) -> bool:"""Verify password against stored hash."""- return bcrypt.checkpw(- password.encode('utf-8'),- self.password_hash.encode('utf-8')- )+ return bcrypt.checkpw(password.encode("utf-8"), self.password_hash.encode("utf-8"))@classmethoddef create(cls, email: str, password: str, display_name: str, is_owner: bool = False) -> "User":@@ -46,7 +39,7 @@ class User(SQLModel, table=True):email=email.lower().strip(),password_hash="", # Will be set belowdisplay_name=display_name.strip(),- is_owner=is_owner+ is_owner=is_owner,)user.set_password(password)return userdiff --git a/server/models/database.py b/server/models/database.pyindex a79780c4..42f9b566 100644--- a/server/models/database.py+++ b/server/models/database.py@@ -15,12 +15,10 @@ class NodeParameter(SQLModel, table=True):node_id: str = Field(index=True, unique=True, max_length=255)parameters: Dict[str, Any] = Field(sa_column=Column(JSON))created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now()))@@ -34,12 +32,10 @@ class Workflow(SQLModel, table=True):description: Optional[str] = Field(default=None, max_length=1000)data: Dict[str, Any] = Field(sa_column=Column(JSON))created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now()))@@ -56,8 +52,7 @@ class Execution(SQLModel, table=True):error: Optional[str] = Field(default=None, max_length=2000)execution_time: Optional[float] = Field(default=None)created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))@@ -73,17 +68,12 @@ class APIKey(SQLModel, table=True):key_hash: str = Field(max_length=64, index=True)models: Optional[Dict[str, Any]] = Field(default=None, sa_column=Column(JSON))is_valid: bool = Field(default=True)- last_validated: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True))- )+ last_validated: datetime = Field(default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True)))created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now()))@@ -96,8 +86,7 @@ class APIKeyValidation(SQLModel, table=True):key_hash: str = Field(unique=True, max_length=64, index=True)validated: bool = Field(default=True)timestamp: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))@@ -112,12 +101,10 @@ class NodeOutput(SQLModel, table=True):output_name: str = Field(default="output_0", max_length=100)data: Dict[str, Any] = Field(sa_column=Column(JSON))created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now()))@@ -131,8 +118,7 @@ class ConversationMessage(SQLModel, table=True):role: str = Field(max_length=20) # 'human' or 'ai'content: str = Field(max_length=50000) # Large content supportcreated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))@@ -152,12 +138,10 @@ class ToolSchema(SQLModel, table=True):schema_config: Dict[str, Any] = Field(sa_column=Column(JSON)) # Schema fields and typesconnected_services: Optional[Dict[str, Any]] = Field(default=None, sa_column=Column(JSON)) # For toolkit nodescreated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now()))@@ -175,8 +159,7 @@ class ChatMessage(SQLModel, table=True):role: str = Field(max_length=20) # 'user' or 'assistant'message: str = Field(max_length=50000) # Large content supportcreated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))@@ -200,8 +183,7 @@ class ConsoleLog(SQLModel, table=True):source_node_type: Optional[str] = Field(default=None, max_length=100)source_node_label: Optional[str] = Field(default=None, max_length=255)created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))@@ -227,12 +209,10 @@ class UserSkill(SQLModel, table=True):is_active: bool = Field(default=True) # Whether skill is availablecreated_by: Optional[int] = Field(default=None) # User ID who created itcreated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now()))@@ -259,14 +239,14 @@ class UserSettings(SQLModel, table=True):onboarding_step: int = Field(default=0) # Last completed onboarding step (for resuming)default_llm_provider: Optional[str] = Field(default=None, max_length=50) # Global default AI providerdefault_llm_model: Optional[str] = Field(default=None, max_length=200) # Global default AI model- auto_add_skill_for_tools: bool = Field(default=True) # When a tool node connects to an AI agent's input-tools, auto-enable the matching skill+ auto_add_skill_for_tools: bool = Field(+ default=True+ ) # When a tool node connects to an AI agent's input-tools, auto-enable the matching skillcreated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now()))@@ -289,12 +269,10 @@ class ProviderDefaults(SQLModel, table=True):reasoning_effort: str = Field(default="medium", max_length=20) # low, medium, highreasoning_format: str = Field(default="parsed", max_length=20) # parsed, hiddencreated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now()))@@ -383,8 +361,7 @@ class APIUsageMetric(SQLModel, table=True):id: Optional[int] = Field(default=None, primary_key=True)timestamp: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))session_id: str = Field(index=True, max_length=255)node_id: str = Field(max_length=255)@@ -422,8 +399,7 @@ class AgentTeam(SQLModel, table=True):status: str = Field(default="active", max_length=20) # active, completed, failed, dissolvedconfig: Dict[str, Any] = Field(default_factory=dict, sa_column=Column(JSON))created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))completed_at: Optional[datetime] = Field(default=None)@@ -445,8 +421,7 @@ class TeamMember(SQLModel, table=True):status: str = Field(default="idle", max_length=20) # idle, working, offlinecapabilities: Optional[Dict[str, Any]] = Field(default=None, sa_column=Column(JSON))joined_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))@@ -474,8 +449,7 @@ class TeamTask(SQLModel, table=True):max_retries: int = Field(default=3)progress: int = Field(default=0) # 0-100 percentagecreated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))started_at: Optional[datetime] = Field(default=None)completed_at: Optional[datetime] = Field(default=None)@@ -498,8 +472,7 @@ class AgentMessage(SQLModel, table=True):extra_data: Optional[Dict[str, Any]] = Field(default=None, sa_column=Column(JSON))read: bool = Field(default=False)created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))@@ -521,12 +494,10 @@ class ProxyProviderConfig(SQLModel, table=True):gateway_port: int = Field(default=0)url_template: str = Field(default="{}", max_length=5000) # JSON template configcreated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now()))@@ -545,8 +516,7 @@ class ProxyRoutingRule(SQLModel, table=True):required_country: str = Field(default="", max_length=10)session_type: str = Field(default="rotating", max_length=20)created_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))@@ -574,10 +544,8 @@ class GoogleConnection(SQLModel, table=True):is_active: bool = Field(default=True) # Whether connection is activelast_used_at: Optional[datetime] = Field(default=None) # Last API call timestampconnected_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), server_default=func.now())+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), server_default=func.now()))updated_at: datetime = Field(- default_factory=lambda: datetime.now(timezone.utc),- sa_column=Column(DateTime(timezone=True), onupdate=func.now())- )\ No newline at end of file+ default_factory=lambda: datetime.now(timezone.utc), sa_column=Column(DateTime(timezone=True), onupdate=func.now())+ )diff --git a/server/models/node_metadata.py b/server/models/node_metadata.pyindex 9551b7c5..8a6a4e4f 100644--- a/server/models/node_metadata.py+++ b/server/models/node_metadata.py@@ -20,18 +20,18 @@ class NodeHandle(TypedDict, total=False):frontend-hardcoded `AGENT_CONFIGS` handle topology."""- name: str # "input-skill", "output-top", ...+ name: str # "input-skill", "output-top", ...kind: Literal["input", "output"]position: Literal["top", "bottom", "left", "right"]- offset: str # CSS % e.g. "25%"; optional- label: str # tooltip- role: str # "main" / "skill" / "tools" / "memory" / "task" / "teammates" / "model"+ offset: str # CSS % e.g. "25%"; optional+ label: str # tooltip+ role: str # "main" / "skill" / "tools" / "memory" / "task" / "teammates" / "model"class NodeMetadata(TypedDict, total=False):# Existing (Wave 6):displayName: str- icon: str # emoji | "asset:<key>" | SVG data URI+ icon: str # emoji | "asset:<key>" | SVG data URIgroup: list[str]subtitle: strdescription: str@@ -41,16 +41,23 @@ class NodeMetadata(TypedDict, total=False):uiHints: dict[str, object]# Wave 10.A — full visual contract:- color: str # hex or dracula token e.g. "#bd93f9"- componentKind: Literal[ # frontend component dispatch key- "square", "circle", "trigger", "start",- "agent", "chat", "tool", "model", "generic",+ color: str # hex or dracula token e.g. "#bd93f9"+ componentKind: Literal[ # frontend component dispatch key+ "square",+ "circle",+ "trigger",+ "start",+ "agent",+ "chat",+ "tool",+ "model",+ "generic",]- handles: list[NodeHandle] # replaces AGENT_CONFIGS topology- credentials: list[str] # provider keys- hideOutputHandle: bool # replaces NO_OUTPUT_NODE_TYPES- hideInputHandle: bool # auto-derived for usable_as_tool=True nodes- visibility: Literal["all", "normal", "dev"] # replaces SIMPLE_MODE_CATEGORIES+ handles: list[NodeHandle] # replaces AGENT_CONFIGS topology+ credentials: list[str] # provider keys+ hideOutputHandle: bool # replaces NO_OUTPUT_NODE_TYPES+ hideInputHandle: bool # auto-derived for usable_as_tool=True nodes+ visibility: Literal["all", "normal", "dev"] # replaces SIMPLE_MODE_CATEGORIES# Seeded incrementally per Wave 6 Phase 3 sub-commit. Sub-commit 3a@@ -75,9 +82,9 @@ class GroupMetadata(TypedDict, total=False):`/api/schemas/nodes/groups`."""- label: str # e.g. "AI Agents"- icon: str # emoji | "asset:<key>"- color: str # hex / dracula token+ label: str # e.g. "AI Agents"+ icon: str # emoji | "asset:<key>"+ color: str # hex / dracula tokenvisibility: Literal["all", "normal", "dev"]diff --git a/server/nodes/__init__.py b/server/nodes/__init__.pyindex 80b11990..845a5830 100644--- a/server/nodes/__init__.py+++ b/server/nodes/__init__.py@@ -98,7 +98,7 @@ def _discover() -> list[str]:for module_info in pkgutil.walk_packages(__path__, prefix=f"{__name__}."):# Skip private modules and private subpackages anywhere in the path.parts = module_info.name.split(".")- if any(part.startswith("_") for part in parts[len(__name__.split(".")):]):+ if any(part.startswith("_") for part in parts[len(__name__.split(".")) :]):continuetry:importlib.import_module(module_info.name)diff --git a/server/nodes/agent/_handles.py b/server/nodes/agent/_handles.pyindex 89df3cd1..924037be 100644--- a/server/nodes/agent/_handles.py+++ b/server/nodes/agent/_handles.py@@ -16,13 +16,13 @@ def std_agent_handles() -> tuple:of the 20 agent variants. Returned as a tuple so the BaseNode`handles` class attribute is immutable."""return (- {"name": "input-skill", "kind": "input", "position": "bottom", "offset": "25%", "label": "Skill", "role": "skill"},- {"name": "input-tools", "kind": "input", "position": "bottom", "offset": "75%", "label": "Tool", "role": "tools"},- {"name": "input-main", "kind": "input", "position": "left", "offset": "25%", "label": "Input", "role": "main"},- {"name": "input-memory", "kind": "input", "position": "left", "offset": "50%", "label": "Memory", "role": "memory"},- {"name": "input-task", "kind": "input", "position": "left", "offset": "75%", "label": "Task", "role": "task"},- {"name": "output-main", "kind": "output", "position": "right", "offset": "50%", "label": "Output", "role": "main"},- {"name": "output-top", "kind": "output", "position": "top", "label": "Output", "role": "main"},+ {"name": "input-skill", "kind": "input", "position": "bottom", "offset": "25%", "label": "Skill", "role": "skill"},+ {"name": "input-tools", "kind": "input", "position": "bottom", "offset": "75%", "label": "Tool", "role": "tools"},+ {"name": "input-main", "kind": "input", "position": "left", "offset": "25%", "label": "Input", "role": "main"},+ {"name": "input-memory", "kind": "input", "position": "left", "offset": "50%", "label": "Memory", "role": "memory"},+ {"name": "input-task", "kind": "input", "position": "left", "offset": "75%", "label": "Task", "role": "task"},+ {"name": "output-main", "kind": "output", "position": "right", "offset": "50%", "label": "Output", "role": "main"},+ {"name": "output-top", "kind": "output", "position": "top", "label": "Output", "role": "main"},)@@ -30,14 +30,12 @@ def team_lead_agent_handles() -> tuple:"""Skill / Tool / Teammates bottom + Memory/Task/Input left + Outputs.Used by orchestrator_agent and ai_employee."""return (- {"name": "input-skill", "kind": "input", "position": "bottom", "offset": "20%", "label": "Skill", "role": "skill"},- {"name": "input-tools", "kind": "input", "position": "bottom", "offset": "50%", "label": "Tool", "role": "tools"},- {"name": "input-teammates", "kind": "input", "position": "bottom", "offset": "80%", "label": "Team", "role": "teammates"},- {"name": "input-main", "kind": "input", "position": "left", "offset": "25%", "label": "Input", "role": "main"},- {"name": "input-memory", "kind": "input", "position": "left", "offset": "50%", "label": "Memory","role": "memory"},- {"name": "input-task", "kind": "input", "position": "left", "offset": "75%", "label": "Task", "role": "task"},- {"name": "output-main", "kind": "output", "position": "right", "offset": "50%", "label": "Output","role": "main"},- {"name": "output-top", "kind": "output", "position": "top", "label": "Output","role": "main"},+ {"name": "input-skill", "kind": "input", "position": "bottom", "offset": "20%", "label": "Skill", "role": "skill"},+ {"name": "input-tools", "kind": "input", "position": "bottom", "offset": "50%", "label": "Tool", "role": "tools"},+ {"name": "input-teammates", "kind": "input", "position": "bottom", "offset": "80%", "label": "Team", "role": "teammates"},+ {"name": "input-main", "kind": "input", "position": "left", "offset": "25%", "label": "Input", "role": "main"},+ {"name": "input-memory", "kind": "input", "position": "left", "offset": "50%", "label": "Memory", "role": "memory"},+ {"name": "input-task", "kind": "input", "position": "left", "offset": "75%", "label": "Task", "role": "task"},+ {"name": "output-main", "kind": "output", "position": "right", "offset": "50%", "label": "Output", "role": "main"},+ {"name": "output-top", "kind": "output", "position": "top", "label": "Output", "role": "main"},)--diff --git a/server/nodes/agent/_inline.py b/server/nodes/agent/_inline.pyindex caa1bd50..21bb310f 100644--- a/server/nodes/agent/_inline.py+++ b/server/nodes/agent/_inline.py@@ -60,7 +60,10 @@ async def prepare_agent_call(parameters = {**parameters, "api_key": raw_params["api_key"]}memory_data, skill_data, tool_data, input_data, task_data = await collect_agent_connections(- node_id, context, database, log_prefix=log_prefix,+ node_id,+ context,+ database,+ log_prefix=log_prefix,)# Step 1: task-context injection + tool-strip.@@ -76,8 +79,7 @@ async def prepare_agent_call(original_tool_count = len(tool_data)tool_data = []logger.info(- f"{log_prefix} Stripped ALL {original_tool_count} tools for "- "task completion handling",+ f"{log_prefix} Stripped ALL {original_tool_count} tools for " "task completion handling",)# Step 2: auto-prompt fallback.@@ -113,31 +115,34 @@ async def prepare_agent_call(tm_id = tm["node_id"]child_tools = []for child_edge in all_edges:- if (- child_edge.get("target") != tm_id- or child_edge.get("targetHandle") != "input-tools"- ):+ if child_edge.get("target") != tm_id or child_edge.get("targetHandle") != "input-tools":continuechild_id = child_edge.get("source")child_node = next(- (n for n in all_nodes if n.get("id") == child_id), None,+ (n for n in all_nodes if n.get("id") == child_id),+ None,)if not child_node:continue- child_tools.append({- "node_id": child_id,- "node_type": child_node.get("type"),- "label": child_node.get("data", {}).get(- "label", child_node.get("type"),- ),- })- tool_data.append({- "node_id": tm_id,- "node_type": tm["node_type"],- "label": tm["label"],- "parameters": tm.get("parameters", {}),- "child_tools": child_tools,- })+ child_tools.append(+ {+ "node_id": child_id,+ "node_type": child_node.get("type"),+ "label": child_node.get("data", {}).get(+ "label",+ child_node.get("type"),+ ),+ }+ )+ tool_data.append(+ {+ "node_id": tm_id,+ "node_type": tm["node_type"],+ "label": tm["label"],+ "parameters": tm.get("parameters", {}),+ "child_tools": child_tools,+ }+ )logger.info(f"[Teams] Added {len(teammates)} teammates as delegation tools")from services.status_broadcaster import get_status_broadcaster@@ -152,5 +157,3 @@ async def prepare_agent_call("context": context,"database": database,}--diff --git a/server/nodes/agent/_specialized.py b/server/nodes/agent/_specialized.pyindex 994231a4..5f6f6364 100644--- a/server/nodes/agent/_specialized.py+++ b/server/nodes/agent/_specialized.py@@ -36,14 +36,23 @@ class SpecializedAgentParams(BaseModel):},)provider: Literal[- "openai", "anthropic", "gemini", "openrouter",- "groq", "cerebras", "deepseek", "kimi", "mistral",+ "openai",+ "anthropic",+ "gemini",+ "openrouter",+ "groq",+ "cerebras",+ "deepseek",+ "kimi",+ "mistral",# Local-server providers — see ai_agent.Params for the proxy_url# rationale. Same fix; same reason.- "ollama", "lmstudio",+ "ollama",+ "lmstudio",] = "openai"model: str = Field(- default="", json_schema_extra={"placeholder": "Select a model..."},+ default="",+ json_schema_extra={"placeholder": "Select a model..."},)system_message: Optional[str] = Field(default="You are a helpful assistant",@@ -54,14 +63,18 @@ class SpecializedAgentParams(BaseModel):# default=None so an unset value falls through to ``agent.default_temperature``# in server/config/llm_defaults.json (resolved by _resolve_temperature).temperature: Optional[float] = Field(- default=None, ge=0.0, le=2.0,+ default=None,+ ge=0.0,+ le=2.0,json_schema_extra={"group": "options"},)# default=None so an unset value is absent from the dumped dict and the# backend (_resolve_max_tokens) falls through to the per-model default# in server/config/llm_defaults.json instead of being silently capped.max_tokens: Optional[int] = Field(- default=None, ge=1, le=200000,+ default=None,+ ge=1,+ le=200000,json_schema_extra={"group": "options"},)@@ -117,9 +130,11 @@ class SpecializedAgentBase(ActionNode, abstract=True):ai_service = get_ai_service()database = get_database()kwargs = await prepare_agent_call(- node_id=ctx.node_id, node_type=self.type,+ node_id=ctx.node_id,+ node_type=self.type,parameters=params.model_dump(),- context=ctx.raw, database=database,+ context=ctx.raw,+ database=database,log_prefix=f"[{self.type}]",)response = await ai_service.execute_chat_agent(ctx.node_id, **kwargs)diff --git a/server/nodes/agent/ai_agent/__init__.py b/server/nodes/agent/ai_agent/__init__.pyindex 4d2262b3..f09113ca 100644--- a/server/nodes/agent/ai_agent/__init__.py+++ b/server/nodes/agent/ai_agent/__init__.py@@ -39,17 +39,26 @@ class AIAgentParams(BaseModel):},)provider: Literal[- "openai", "anthropic", "gemini", "openrouter",- "groq", "cerebras", "deepseek", "kimi", "mistral",+ "openai",+ "anthropic",+ "gemini",+ "openrouter",+ "groq",+ "cerebras",+ "deepseek",+ "kimi",+ "mistral",# Local-server providers — agent execution reads# ``{provider}_proxy`` to point the LangChain client at the# user's localhost server. Without these entries the dropdown# silently falls back to ``"openai"`` and execute_agent ends# up calling api.openai.com instead.- "ollama", "lmstudio",+ "ollama",+ "lmstudio",] = "openai"model: str = Field(- default="", json_schema_extra={"placeholder": "Select a model..."},+ default="",+ json_schema_extra={"placeholder": "Select a model..."},)system_message: Optional[str] = Field(default="You are a helpful assistant",@@ -60,14 +69,18 @@ class AIAgentParams(BaseModel):# default=None so an unset value falls through to ``agent.default_temperature``# in server/config/llm_defaults.json (resolved by _resolve_temperature).temperature: Optional[float] = Field(- default=None, ge=0.0, le=2.0,+ default=None,+ ge=0.0,+ le=2.0,json_schema_extra={"numberStepSize": 0.1, "group": "options"},)# default=None so an unset value is absent from the dumped dict and the# backend (_resolve_max_tokens) falls through to the per-model default# in server/config/llm_defaults.json instead of being silently capped.max_tokens: Optional[int] = Field(- default=None, ge=1, le=200000,+ default=None,+ ge=1,+ le=200000,json_schema_extra={"group": "options"},)@@ -128,9 +141,11 @@ class AIAgentNode(ActionNode):ai_service = get_ai_service()database = get_database()kwargs = await prepare_agent_call(- node_id=ctx.node_id, node_type=self.type,+ node_id=ctx.node_id,+ node_type=self.type,parameters=params.model_dump(),- context=ctx.raw, database=database,+ context=ctx.raw,+ database=database,log_prefix="[AI Agent]",)# ``execute_agent`` raises ``NodeUserError`` directly for typeddiff --git a/server/nodes/agent/ai_employee/__init__.py b/server/nodes/agent/ai_employee/__init__.pyindex f35fa0d9..14be1785 100644--- a/server/nodes/agent/ai_employee/__init__.py+++ b/server/nodes/agent/ai_employee/__init__.py@@ -9,4 +9,6 @@ class AIEmployeeNode(SpecializedAgentBase):group = ("agent",)description = "Team lead for multi-agent coordination"handles = team_lead_agent_handles()- tool_description = "ONE-SHOT delegation to AI Employee. Call ONCE per task, returns task_id. Coordinates multiple agents - do NOT re-call."+ tool_description = (+ "ONE-SHOT delegation to AI Employee. Call ONCE per task, returns task_id. Coordinates multiple agents - do NOT re-call."+ )diff --git a/server/nodes/agent/chat_agent/__init__.py b/server/nodes/agent/chat_agent/__init__.pyindex 4786b736..b91baccc 100644--- a/server/nodes/agent/chat_agent/__init__.py+++ b/server/nodes/agent/chat_agent/__init__.py@@ -26,14 +26,23 @@ class ChatAgentParams(BaseModel):"""provider: Literal[- "openai", "anthropic", "gemini", "openrouter",- "groq", "cerebras", "deepseek", "kimi", "mistral",+ "openai",+ "anthropic",+ "gemini",+ "openrouter",+ "groq",+ "cerebras",+ "deepseek",+ "kimi",+ "mistral",# Local-server providers — see ai_agent.Params for the proxy_url# rationale. Same fix; same reason.- "ollama", "lmstudio",+ "ollama",+ "lmstudio",] = "openai"model: str = Field(- default="", json_schema_extra={"placeholder": "Select a model..."},+ default="",+ json_schema_extra={"placeholder": "Select a model..."},)prompt: str = Field(default="",@@ -43,21 +52,26 @@ class ChatAgentParams(BaseModel):},)system_message: Optional[str] = Field(- default="", json_schema_extra={"rows": 3},+ default="",+ json_schema_extra={"rows": 3},)# ---- "Options" group (collapsed by default in the parameter panel) ----# default=None so an unset value falls through to ``agent.default_temperature``# in server/config/llm_defaults.json (resolved by _resolve_temperature).temperature: Optional[float] = Field(- default=None, ge=0.0, le=2.0,+ default=None,+ ge=0.0,+ le=2.0,json_schema_extra={"group": "options"},)# default=None so an unset value is absent from the dumped dict and the# backend (_resolve_max_tokens) falls through to the per-model default# in server/config/llm_defaults.json instead of being silently capped.max_tokens: Optional[int] = Field(- default=None, ge=1, le=200000,+ default=None,+ ge=1,+ le=200000,json_schema_extra={"group": "options"},)@@ -111,9 +125,11 @@ class ChatAgentNode(ActionNode):ai_service = get_ai_service()database = get_database()kwargs = await prepare_agent_call(- node_id=ctx.node_id, node_type=self.type,+ node_id=ctx.node_id,+ node_type=self.type,parameters=params.model_dump(),- context=ctx.raw, database=database,+ context=ctx.raw,+ database=database,log_prefix="[Chat Agent]",)response = await ai_service.execute_chat_agent(ctx.node_id, **kwargs)diff --git a/server/nodes/agent/claude_code_agent/__init__.py b/server/nodes/agent/claude_code_agent/__init__.pyindex 3e9b3286..c55309f8 100644--- a/server/nodes/agent/claude_code_agent/__init__.py+++ b/server/nodes/agent/claude_code_agent/__init__.py@@ -124,8 +124,7 @@ class ClaudeCodeAgentParams(BaseModel):# --- Hidden: advanced multi-task batch ---tasks: List[ClaudeTaskSpec] = Field(default_factory=list,- description="Advanced: list of Claude tasks to run in parallel "- "(max 5 concurrent). Use ``prompt`` for the common case.",+ description="Advanced: list of Claude tasks to run in parallel " "(max 5 concurrent). Use ``prompt`` for the common case.",json_schema_extra={"hidden": True, "rows": 1},)@@ -149,7 +148,9 @@ class ClaudeCodeAgentParams(BaseModel):json_schema_extra={"hidden": True},)max_parallel: int = Field(- default=5, ge=1, le=20,+ default=5,+ ge=1,+ le=20,description="Concurrency cap.",json_schema_extra={"hidden": True},)@@ -163,17 +164,13 @@ class ClaudeCodeAgentParams(BaseModel):effort: Optional[ClaudeCodeEffort] = Field(default=None,description=(- "Reasoning-effort level passed via ``--effort``. Applies to "- "thinking-capable models (Opus / Sonnet); ignored by Haiku."+ "Reasoning-effort level passed via ``--effort``. Applies to " "thinking-capable models (Opus / Sonnet); ignored by Haiku."),json_schema_extra={"hidden": True},)fallback_model: Optional[ClaudeCodeModel] = Field(default=None,- description=(- "Model to fall back to when the primary is overloaded. "- "Passed via ``--fallback-model``."- ),+ description=("Model to fall back to when the primary is overloaded. " "Passed via ``--fallback-model``."),json_schema_extra={"hidden": True},)@@ -211,6 +208,7 @@ class ClaudeCodeAgentParams(BaseModel):class ClaudeCodeAgentOutput(BaseModel):"""Aggregated batch output."""+success: bool = Truen_tasks: int = 0n_succeeded: int = 0@@ -235,10 +233,7 @@ class ClaudeCodeAgentNode(ActionNode):display_name = "Claude Code"subtitle = "Agentic Coding"group = ("agent",)- description = (- "Run N parallel Claude Code CLI sessions over a list of tasks. "- "Each task is isolated in its own git worktree."- )+ description = "Run N parallel Claude Code CLI sessions over a list of tasks. " "Each task is isolated in its own git worktree."component_kind = "agent"tool_description = "ONE-SHOT delegation to Claude Code Agent. Call ONCE per task, returns task_id. Agentic coding with file reading, editing, and command execution - do NOT re-call."handles = std_agent_handles()@@ -254,7 +249,9 @@ class ClaudeCodeAgentNode(ActionNode):cost={"service": "claude_code_agent", "action": "run", "count": 1},)async def execute_op(- self, ctx: NodeContext, params: ClaudeCodeAgentParams,+ self,+ ctx: NodeContext,+ params: ClaudeCodeAgentParams,) -> Any:from services.cli_agent.service import get_ai_cli_servicefrom services.cli_agent.types import session_result_to_model@@ -267,7 +264,8 @@ class ClaudeCodeAgentNode(ActionNode):node_id = ctx.node_idawait broadcaster.update_node_status(- node_id, "executing",+ node_id,+ "executing",{"message": "Starting Claude Code batch..."},workflow_id=workflow_id,)@@ -278,16 +276,13 @@ class ClaudeCodeAgentNode(ActionNode):# read from `input_data` exactly the way `nodes/agent/_inline.py`# does for the standard agent path.database = get_database()- memory_data, skill_data, tool_data, input_data, _ = (- await collect_agent_connections(- node_id, ctx.raw, database, log_prefix="[Claude Code]",- )+ memory_data, skill_data, tool_data, input_data, _ = await collect_agent_connections(+ node_id,+ ctx.raw,+ database,+ log_prefix="[Claude Code]",)- connected_skills = [- s.get("skill_name") or s.get("label")- for s in skill_data- if s.get("skill_name") or s.get("label")- ]+ connected_skills = [s.get("skill_name") or s.get("label") for s in skill_data if s.get("skill_name") or s.get("label")]# Memory bridge: claude maintains its own session JSONL on disk# under `<CLAUDE_CONFIG_DIR>/projects/<cwd-encoded>/<UUID>.jsonl`.@@ -312,8 +307,7 @@ class ClaudeCodeAgentNode(ActionNode):continue_session = bool(memory_data)if memory_data:logger.info(- "[Claude Code memory] memory_node=%s -> --continue "- "(claude auto-finds latest session under cwd)",+ "[Claude Code memory] memory_node=%s -> --continue " "(claude auto-finds latest session under cwd)",memory_data.get("node_id"),)@@ -361,11 +355,7 @@ class ClaudeCodeAgentNode(ActionNode):changed["fallback_model"] = params.fallback_model# Only auto-enable --continue when memory is wired AND# the task didn't explicitly opt in/out or pick a UUID.- if (- continue_session- and not t.continue_session- and not t.resume_session_id- ):+ if continue_session and not t.continue_session and not t.resume_session_id:changed["continue_session"] = Trueif changed:tasks[i] = t.model_copy(update=changed)@@ -374,23 +364,18 @@ class ClaudeCodeAgentNode(ActionNode):# `--resume` against one session JSONL would corrupt it.if memory_data and len(tasks) > 1:raise NodeUserError(- "Memory-bound batches must run one task at a time. "- "Reduce Tasks to a single entry, or disconnect the "- "memory node."+ "Memory-bound batches must run one task at a time. " "Reduce Tasks to a single entry, or disconnect the " "memory node.")# Workspace dir — workflow.py injects this into contextworkspace_dir = ctx.raw.get("workspace_dir") or params.working_directoryif workspace_dir is None:from core.config import Settings- workspace_dir = Path(Settings().workspace_base_resolved) / (- workflow_id or "default"- )++ workspace_dir = Path(Settings().workspace_base_resolved) / (workflow_id or "default")workspace_dir = Path(workspace_dir)- repo_root = (- Path(params.working_directory) if params.working_directory else None- )+ repo_root = Path(params.working_directory) if params.working_directory else Nonesvc = get_ai_cli_service()result = await svc.run_batch(@@ -411,16 +396,18 @@ class ClaudeCodeAgentNode(ActionNode):elapsed = time.time() - start_timelogger.debug("[claude_code_agent] node=%s tasks=%d ok=%d fail=%d elapsed=%.2fs",- node_id, result.n_tasks, result.n_succeeded, result.n_failed, elapsed,+ node_id,+ result.n_tasks,+ result.n_succeeded,+ result.n_failed,+ elapsed,)await broadcaster.update_node_status(- node_id, "success" if result.n_failed == 0 else "warning",+ node_id,+ "success" if result.n_failed == 0 else "warning",{- "message": (- f"Batch complete: {result.n_succeeded}/{result.n_tasks} "- f"succeeded"- ),+ "message": (f"Batch complete: {result.n_succeeded}/{result.n_tasks} " f"succeeded"),"n_tasks": result.n_tasks,"n_succeeded": result.n_succeeded,"n_failed": result.n_failed,@@ -453,4 +440,3 @@ class ClaudeCodeAgentNode(ActionNode):"session_id": legacy_session_id,"cost_usd": legacy_cost,}-diff --git a/server/nodes/agent/claude_code_agent/_handlers.py b/server/nodes/agent/claude_code_agent/_handlers.pyindex 98fc5e91..ec5b079f 100644--- a/server/nodes/agent/claude_code_agent/_handlers.py+++ b/server/nodes/agent/claude_code_agent/_handlers.py@@ -76,8 +76,8 @@ async def _finalize_claude_login() -> None:info = await claude_auth_status_info()if not info.get("loggedIn"):logger.warning(- "[claude_code_login] CLI exited cleanly but auth status "- "reports not logged in: %s", info,+ "[claude_code_login] CLI exited cleanly but auth status " "reports not logged in: %s",+ info,)return@@ -85,7 +85,8 @@ async def _finalize_claude_login() -> None:org_name = info.get("orgName")await mark_logged_in(_CATALOGUE_KEY, email=email, name=org_name)await broadcast_credential_event(- "credential.oauth.connected", provider=_CATALOGUE_KEY,+ "credential.oauth.connected",+ provider=_CATALOGUE_KEY,)logger.info("[claude_code_login] connected as %s (%s · %s)",@@ -115,7 +116,8 @@ async def handle_claude_code_login(name=info.get("orgName"),)await broadcast_credential_event(- "credential.oauth.connected", provider=_CATALOGUE_KEY,+ "credential.oauth.connected",+ provider=_CATALOGUE_KEY,)except Exception as exc:logger.warning("[claude_code_login] mark/broadcast failed: %s", exc)@@ -145,7 +147,8 @@ async def handle_claude_code_logout(await claude_auth_logout()await mark_logged_out(_CATALOGUE_KEY)await broadcast_credential_event(- "credential.oauth.disconnected", provider=_CATALOGUE_KEY,+ "credential.oauth.disconnected",+ provider=_CATALOGUE_KEY,)except Exception as exc:logger.warning("[claude_code_logout] failed: %s", exc)diff --git a/server/nodes/agent/claude_code_agent/_pool.py b/server/nodes/agent/claude_code_agent/_pool.pyindex b6534756..793290bc 100644--- a/server/nodes/agent/claude_code_agent/_pool.py+++ b/server/nodes/agent/claude_code_agent/_pool.py@@ -204,7 +204,8 @@ class ClaudeSessionPool:returnself._shutdown.clear()self._reaper_task = asyncio.create_task(- self._reaper_loop(), name="ClaudeSessionPool.reaper",+ self._reaper_loop(),+ name="ClaudeSessionPool.reaper",)def peek(self, memory_node_id: str) -> Optional[PooledClaudeSession]:@@ -250,9 +251,9 @@ class ClaudeSessionPool:crashed_uuid = ""if existing is not None and existing.process.returncode is not None:logger.info(- "[ClaudeSessionPool] dropping dead session "- "memory_node=%s pid=%s exit=%s — will respawn",- memory_node_id, existing.process.pid,+ "[ClaudeSessionPool] dropping dead session " "memory_node=%s pid=%s exit=%s — will respawn",+ memory_node_id,+ existing.process.pid,existing.process.returncode,)crashed_uuid = existing.current_session_uuid@@ -276,14 +277,13 @@ class ClaudeSessionPool:# T_warm (the argv-baked one), then drop T_new — it# would otherwise sit orphaned in ``_active_tokens``# until app shutdown.- if (- existing.batch_token- and mcp_bearer_token- and mcp_bearer_token != existing.batch_token- ):+ if existing.batch_token and mcp_bearer_token and mcp_bearer_token != existing.batch_token:from services.cli_agent.mcp_server import (- lookup_batch, rebind_batch, unregister_batch,+ lookup_batch,+ rebind_batch,+ unregister_batch,)+new_ctx = lookup_batch(mcp_bearer_token)if new_ctx is not None:rebind_batch(@@ -305,6 +305,7 @@ class ClaudeSessionPool:# the delta on disk.if existing.workspace_dir is not None:from ._skills import materialise_skills+new_set = frozenset(connected_skill_names or [])added, removed = await materialise_skills(existing.workspace_dir,@@ -314,14 +315,17 @@ class ClaudeSessionPool:)if added or removed:logger.info(- "[ClaudeSessionPool] skill diff "- "memory_node=%s +%d -%d (now %d wired)",- memory_node_id, added, removed, len(new_set),+ "[ClaudeSessionPool] skill diff " "memory_node=%s +%d -%d (now %d wired)",+ memory_node_id,+ added,+ removed,+ len(new_set),)existing.materialised_skills = new_setlogger.info("[ClaudeSessionPool] warm reuse memory_node=%s pid=%s uuid=%s",- memory_node_id, existing.process.pid,+ memory_node_id,+ existing.process.pid,existing.current_session_uuid or "(unresolved)",)return existing@@ -357,9 +361,7 @@ class ClaudeSessionPool:# paths know where to materialise live updates and what# the prior set was for the diff.session.workspace_dir = workspace_dir- session.materialised_skills = frozenset(- connected_skill_names or []- )+ session.materialised_skills = frozenset(connected_skill_names or [])if crashed_uuid:# The new subprocess is resuming the prior session; pre-seed# the UUID so the first turn's emitted CloudEvents carry@@ -368,7 +370,8 @@ class ClaudeSessionPool:self._pool[memory_node_id] = sessionlogger.info("[ClaudeSessionPool] spawned new session memory_node=%s pid=%s",- memory_node_id, session.process.pid,+ memory_node_id,+ session.process.pid,)await self._emit_event("spawned",@@ -462,10 +465,7 @@ class ClaudeSessionPool:events=[],prompt=prompt,success=False,- error=(- f"claude subprocess exited (code "- f"{session.process.returncode}) before turn"- ),+ error=(f"claude subprocess exited (code " f"{session.process.returncode}) before turn"),)session.result_event.clear()@@ -498,9 +498,9 @@ class ClaudeSessionPool:)except asyncio.TimeoutError:logger.warning(- "[ClaudeSessionPool] turn timeout memory_node=%s "- "prompt_len=%d",- session.memory_node_id, len(prompt),+ "[ClaudeSessionPool] turn timeout memory_node=%s " "prompt_len=%d",+ session.memory_node_id,+ len(prompt),)return self._build_result_from_events(session=session,@@ -573,9 +573,11 @@ class ClaudeSessionPool:# provided (defensive — every production caller passes one).if connected_skill_names:from ._skills import materialise_skills+target_dir = workspace_dir or cwdawait materialise_skills(- target_dir, connected_skill_names,+ target_dir,+ connected_skill_names,previous_skill_names=None, # cold spawn: no prior setlog_label=f"pool {memory_node_id}",)@@ -632,25 +634,26 @@ class ClaudeSessionPool:event = json.loads(line)except json.JSONDecodeError:logger.debug(- "[ClaudeSessionPool] stdout non-JSON line "- "memory_node=%s line=%r",- memory_node_id, line[:200],+ "[ClaudeSessionPool] stdout non-JSON line " "memory_node=%s line=%r",+ memory_node_id,+ line[:200],)continuetry:await self._handle_stream_event(session, event)except Exception as exc: # pragma: no coverlogger.warning(- "[ClaudeSessionPool] handler raised "- "memory_node=%s exc=%s",- memory_node_id, exc,+ "[ClaudeSessionPool] handler raised " "memory_node=%s exc=%s",+ memory_node_id,+ exc,)except (asyncio.CancelledError, ConnectionError):returnexcept Exception as exc: # pragma: no cover — defensivelogger.debug("[ClaudeSessionPool] stdout reader memory_node=%s exc=%s",- memory_node_id, exc,+ memory_node_id,+ exc,)async def _drain_stderr() -> None:@@ -663,16 +666,18 @@ class ClaudeSessionPool:line = raw.decode("utf-8", errors="replace").rstrip()if line:logger.warning(- "[ClaudeSessionPool] claude stderr "- "memory_node=%s pid=%s: %s",- memory_node_id, process.pid, line,+ "[ClaudeSessionPool] claude stderr " "memory_node=%s pid=%s: %s",+ memory_node_id,+ process.pid,+ line,)except (asyncio.CancelledError, ConnectionError):returnexcept Exception as exc: # pragma: no cover — defensivelogger.debug("[ClaudeSessionPool] stderr drain memory_node=%s exc=%s",- memory_node_id, exc,+ memory_node_id,+ exc,)session.stdout_reader_task = asyncio.create_task(@@ -691,7 +696,9 @@ class ClaudeSessionPool:# ------------------------------------------------------------------async def _handle_stream_event(- self, session: PooledClaudeSession, event: Dict[str, Any],+ self,+ session: PooledClaudeSession,+ event: Dict[str, Any],) -> None:"""Per-event dispatcher for stream-json lines on ``proc.stdout``.@@ -712,15 +719,13 @@ class ClaudeSessionPool:session.events_this_turn.append(event)if self._provider.is_final_event(event):session.result_event.set()- if (- event.get("type") == "system"- and event.get("subtype") == "compact_boundary"- ):+ if event.get("type") == "system" and event.get("subtype") == "compact_boundary":await self._record_native_compaction(session, event)@staticmethodasync def _record_native_compaction(- session: PooledClaudeSession, event: Dict[str, Any],+ session: PooledClaudeSession,+ event: Dict[str, Any],) -> None:"""Forward a ``system/compact_boundary`` event to:class:`CompactionService` so the local-threshold path doesn't@@ -745,14 +750,15 @@ class ClaudeSessionPool:summary=None,)logger.info(- "[ClaudeSessionPool] native compaction recorded "- "memory_node=%s pre_tokens=%d trigger=%s",- session.memory_node_id, pre_tokens,+ "[ClaudeSessionPool] native compaction recorded " "memory_node=%s pre_tokens=%d trigger=%s",+ session.memory_node_id,+ pre_tokens,metadata.get("trigger", "unknown"),)except Exception as exc: # pragma: no coverlogger.debug(- "[ClaudeSessionPool] compaction.record failed: %s", exc,+ "[ClaudeSessionPool] compaction.record failed: %s",+ exc,)def _build_result_from_events(@@ -766,14 +772,15 @@ class ClaudeSessionPool:) -> SessionResult:"""Translate per-turn JSONL events to a :class:`SessionResult`."""provider_result = self._provider.event_to_session_result(- events, stderr="", exit_code=0 if success else -1,+ events,+ stderr="",+ exit_code=0 if success else -1,)final_success = success and provider_result.get("success", True)final_error = error or provider_result.get("error")return SessionResult(task_id=f"pooled_{uuid.uuid4().hex[:8]}",- session_id=provider_result.get("session_id")- or session.current_session_uuid,+ session_id=provider_result.get("session_id") or session.current_session_uuid,provider=self._provider.name,prompt=prompt,worktree_path=str(session.cwd),@@ -784,7 +791,8 @@ class ClaudeSessionPool:tool_calls=int(provider_result.get("tool_calls", 0)),canonical_usage=provider_result.get("canonical_usage",- ) or self._provider.canonical_usage(events),+ )+ or self._provider.canonical_usage(events),provider_data=dict(provider_result.get("provider_data") or {}),success=final_success,error=final_error if not final_success else None,@@ -817,11 +825,13 @@ class ClaudeSessionPool:if session.batch_token:try:from services.cli_agent.mcp_server import unregister_batch+unregister_batch(session.batch_token)except Exception as exc: # pragma: no cover — defensivelogger.debug(- "[ClaudeSessionPool] unregister_batch on terminate "- "memory_node=%s exc=%s", memory_node_id, exc,+ "[ClaudeSessionPool] unregister_batch on terminate " "memory_node=%s exc=%s",+ memory_node_id,+ exc,)# 1. Close stdin so claude can exit gracefully.@@ -849,7 +859,8 @@ class ClaudeSessionPool:except Exception as exc: # pragma: no coverlogger.debug("[ClaudeSessionPool] kill memory_node=%s exc=%s",- memory_node_id, exc,+ memory_node_id,+ exc,)# 4. Cancel reader/drain tasks (they'll exit on their own when@@ -864,7 +875,9 @@ class ClaudeSessionPool:logger.info("[ClaudeSessionPool] terminated memory_node=%s pid=%s reason=%s",- memory_node_id, process.pid, reason,+ memory_node_id,+ process.pid,+ reason,)await self._emit_event("terminated",@@ -876,10 +889,7 @@ class ClaudeSessionPool:async def _evict_lru_locked(self) -> None:"""Caller holds ``self._pool_lock``. Evicts the least-recently-used non-in-flight entry."""- idle_entries = [- (key, sess) for key, sess in self._pool.items()- if not sess.lock.locked()- ]+ idle_entries = [(key, sess) for key, sess in self._pool.items() if not sess.lock.locked()]if not idle_entries:logger.info("[ClaudeSessionPool] all %d entries in-flight; pool over cap",@@ -887,10 +897,12 @@ class ClaudeSessionPool:)returnoldest_key, _ = min(- idle_entries, key=lambda kv: kv[1].last_used_at,+ idle_entries,+ key=lambda kv: kv[1].last_used_at,)logger.info(- "[ClaudeSessionPool] evicting LRU memory_node=%s", oldest_key,+ "[ClaudeSessionPool] evicting LRU memory_node=%s",+ oldest_key,)await self._terminate_locked(oldest_key, reason="evicted")@@ -914,6 +926,7 @@ class ClaudeSessionPool:"""try:from services.status_broadcaster import get_status_broadcaster+broadcaster = get_status_broadcaster()except Exception: # pragma: no coverreturn@@ -947,10 +960,12 @@ class ClaudeSessionPool:input_tokens=payload.get("input_tokens", 0),output_tokens=payload.get("output_tokens", 0),cache_read_input_tokens=payload.get(- "cache_read_input_tokens", 0,+ "cache_read_input_tokens",+ 0,),cache_creation_input_tokens=payload.get(- "cache_creation_input_tokens", 0,+ "cache_creation_input_tokens",+ 0,),duration_ms=payload.get("duration_ms"),num_turns=payload.get("num_turns"),@@ -958,7 +973,9 @@ class ClaudeSessionPool:)except Exception as exc: # pragma: no coverlogger.debug(- "[ClaudeSessionPool] _emit_event(%s) failed: %s", kind, exc,+ "[ClaudeSessionPool] _emit_event(%s) failed: %s",+ kind,+ exc,)async def _reaper_loop(self) -> None:@@ -975,15 +992,13 @@ class ClaudeSessionPool:now = time.monotonic()async with self._pool_lock:expired_keys = [- key for key, sess in self._pool.items()- if not sess.lock.locked()- and now - sess.last_used_at >= self._idle_ttl+ key for key, sess in self._pool.items() if not sess.lock.locked() and now - sess.last_used_at >= self._idle_ttl]for key in expired_keys:logger.info(- "[ClaudeSessionPool] reaping idle session "- "memory_node=%s age=%.1fs",- key, now - self._pool[key].last_used_at,+ "[ClaudeSessionPool] reaping idle session " "memory_node=%s age=%.1fs",+ key,+ now - self._pool[key].last_used_at,)await self._terminate_locked(key, reason="idle")except asyncio.CancelledError:diff --git a/server/nodes/agent/claude_code_agent/_provider.py b/server/nodes/agent/claude_code_agent/_provider.pyindex 9babfc56..f1173544 100644--- a/server/nodes/agent/claude_code_agent/_provider.py+++ b/server/nodes/agent/claude_code_agent/_provider.py@@ -76,9 +76,7 @@ class AnthropicClaudeProvider:def __init__(self) -> None:cfg = get_provider_config(NAME)if cfg is None:- raise RuntimeError(- f"Provider config missing for {NAME!r}. Check ai_cli_providers.json."- )+ raise RuntimeError(f"Provider config missing for {NAME!r}. Check ai_cli_providers.json.")self.name = NAMEself.package_name = cfg.package_nameself.binary_name = cfg.binary_name@@ -160,10 +158,7 @@ class AnthropicClaudeProvider:``<cwd>/.claude/skills/`` is unchanged."""if not isinstance(task, ClaudeTaskSpec):- raise TypeError(- "AnthropicClaudeProvider.interactive_argv requires ClaudeTaskSpec, "- f"got {type(task).__name__}"- )+ raise TypeError("AnthropicClaudeProvider.interactive_argv requires ClaudeTaskSpec, " f"got {type(task).__name__}")argv: List[str] = [str(self.binary_path())]@@ -178,8 +173,10 @@ class AnthropicClaudeProvider:# ``<CLAUDE_CONFIG_DIR>/ide/<pid>.lock`` for auto-connection to# MachinaOs's MCP server.argv += [- "--output-format", "stream-json",- "--input-format", "stream-json",+ "--output-format",+ "stream-json",+ "--input-format",+ "stream-json","--verbose","--ide",]@@ -193,26 +190,24 @@ class AnthropicClaudeProvider:# session start instead of waiting for a `ToolSearch` call# the agent often doesn't make# (https://code.claude.com/docs/en/mcp#scale-with-mcp-tool-search).- mcp_payload = json.dumps({- "mcpServers": {- "machinaos": {- "type": "http",- "url": mcp_endpoint_url,- "headers": {- "Authorization": f"Bearer {mcp_bearer_token}",- },- "alwaysLoad": True,+ mcp_payload = json.dumps(+ {+ "mcpServers": {+ "machinaos": {+ "type": "http",+ "url": mcp_endpoint_url,+ "headers": {+ "Authorization": f"Bearer {mcp_bearer_token}",+ },+ "alwaysLoad": True,+ }}}- })+ )argv += ["--mcp-config", mcp_payload, "--strict-mcp-config"]# Model- model = (- task.model- or defaults.get("default_model")- or self._defaults.get("default_model", "claude-sonnet-4-6")- )+ model = task.model or defaults.get("default_model") or self._defaults.get("default_model", "claude-sonnet-4-6")argv += ["--model", model]# Session continuity. Three valid states, mutually exclusive:@@ -258,14 +253,9 @@ class AnthropicClaudeProvider:"default_allowed_tools",self._defaults.get("default_allowed_tools", ""),)- allowed_list: List[str] = (- [t.strip() for t in allowed_extra.split(",") if t.strip()]- if allowed_extra else []- )+ allowed_list: List[str] = [t.strip() for t in allowed_extra.split(",") if t.strip()] if allowed_extra else []if connected_tool_names:- allowed_list += [- f"mcp__machinaos__{name}" for name in connected_tool_names- ]+ allowed_list += [f"mcp__machinaos__{name}" for name in connected_tool_names]# Conditionally enable claude's built-in ``Skill`` tool ONLY# when at least one skill is wired through ``input-skill``.# The spawn path (pool + non-pool) materialises connected@@ -316,9 +306,9 @@ class AnthropicClaudeProvider:if task.system_prompt:argv += ["--append-system-prompt", task.system_prompt]logger.info(- "[CC-Agent argv] --append-system-prompt (task) "- "length=%d preview=%r",- len(task.system_prompt), task.system_prompt[:200],+ "[CC-Agent argv] --append-system-prompt (task) " "length=%d preview=%r",+ len(task.system_prompt),+ task.system_prompt[:200],)# Optional per-task overrides (work in interactive mode per@@ -402,9 +392,7 @@ class AnthropicClaudeProvider:breaktool_calls = sum(- 1 for evt in events- if evt.get("type") == "tool_use"- or (evt.get("type") == "assistant" and self._has_tool_use(evt))+ 1 for evt in events if evt.get("type") == "tool_use" or (evt.get("type") == "assistant" and self._has_tool_use(evt)))provider_data: Dict[str, Any] = {}@@ -499,10 +487,7 @@ class AnthropicClaudeProvider:return CanonicalUsage()usage = final.get("usage") or {}- request_count = (- int(final.get("num_turns") or 0)- or sum(1 for e in events if e.get("type") == "assistant")- )+ request_count = int(final.get("num_turns") or 0) or sum(1 for e in events if e.get("type") == "assistant")return CanonicalUsage(input_tokens=int(usage.get("input_tokens", 0)),output_tokens=int(usage.get("output_tokens", 0)),@@ -524,8 +509,5 @@ class AnthropicClaudeProvider:msg = event.get("message") or {}content = msg.get("content")if isinstance(content, list):- return any(- isinstance(blk, dict) and blk.get("type") == "tool_use"- for blk in content- )+ return any(isinstance(blk, dict) and blk.get("type") == "tool_use" for blk in content)return Falsediff --git a/server/nodes/agent/claude_code_agent/_skills.py b/server/nodes/agent/claude_code_agent/_skills.pyindex bc96ffdc..b2714426 100644--- a/server/nodes/agent/claude_code_agent/_skills.py+++ b/server/nodes/agent/claude_code_agent/_skills.py@@ -107,9 +107,7 @@ async def materialise_skills(bookkeeping."""new_set: FrozenSet[str] = frozenset(s for s in skill_names if s)- prev_set: FrozenSet[str] = frozenset(- s for s in (previous_skill_names or ()) if s- )+ prev_set: FrozenSet[str] = frozenset(s for s in (previous_skill_names or ()) if s)added = new_set - prev_setremoved = prev_set - new_set@@ -123,7 +121,9 @@ async def materialise_skills(except OSError as exc:logger.warning("[%s] cannot create skills dir %s: %s — skipping all changes",- log_label, skills_dir, exc,+ log_label,+ skills_dir,+ exc,)return (0, 0)@@ -139,12 +139,18 @@ async def materialise_skills(await asyncio.to_thread(shutil.rmtree, dest, ignore_errors=False)removed_count += 1logger.info(- "[%s] removed skill %r from %s", log_label, name, dest,+ "[%s] removed skill %r from %s",+ log_label,+ name,+ dest,)except OSError as exc:logger.warning("[%s] failed to remove skill %r at %s: %s — leaving",- log_label, name, dest, exc,+ log_label,+ name,+ dest,+ exc,)if not added:@@ -185,13 +191,16 @@ async def _materialise_one(except Exception as exc:logger.warning("[%s] load_skill_async(%r) failed: %s — skipping",- log_label, name, exc,+ log_label,+ name,+ exc,)return Falseif skill is None:logger.warning("[%s] skill %r not found in registry — skipping materialisation",- log_label, name,+ log_label,+ name,)return False@@ -202,7 +211,9 @@ async def _materialise_one(# scripts/ + references/ + templates/ atomically.await asyncio.to_thread(shutil.copytree,- skill.metadata.path, dest, dirs_exist_ok=True,+ skill.metadata.path,+ dest,+ dirs_exist_ok=True,)else:# DB skill: reconstruct frontmatter from metadata@@ -215,20 +226,20 @@ async def _materialise_one("allowed-tools": " ".join(skill.metadata.allowed_tools),"metadata": skill.metadata.metadata,}- body = (- f"---\n"- f"{yaml.safe_dump(frontmatter, sort_keys=False)}"- f"---\n\n"- f"{skill.instructions}"- )+ body = f"---\n" f"{yaml.safe_dump(frontmatter, sort_keys=False)}" f"---\n\n" f"{skill.instructions}"await asyncio.to_thread(- (dest / "SKILL.md").write_text, body, encoding="utf-8",+ (dest / "SKILL.md").write_text,+ body,+ encoding="utf-8",)logger.info("[%s] materialised skill %r -> %s", log_label, name, dest)return Trueexcept OSError as exc:logger.warning("[%s] failed to materialise skill %r at %s: %s",- log_label, name, dest, exc,+ log_label,+ name,+ dest,+ exc,)return Falsediff --git a/server/nodes/agent/codex_agent/__init__.py b/server/nodes/agent/codex_agent/__init__.pyindex 1462086c..3ed18de7 100644--- a/server/nodes/agent/codex_agent/__init__.py+++ b/server/nodes/agent/codex_agent/__init__.py@@ -38,8 +38,7 @@ class CodexAgentParams(BaseModel):)prompt: str = Field(default="",- description="Legacy: single-prompt fallback used only when "- "`tasks` is empty.",+ description="Legacy: single-prompt fallback used only when " "`tasks` is empty.",json_schema_extra={"rows": 4, "placeholder": "Or use the tasks array..."},)model: str = Field(@@ -48,8 +47,7 @@ class CodexAgentParams(BaseModel):)sandbox: str = Field(default="workspace-write",- description="Default sandbox for tasks that don't override it. "- "One of: read-only | workspace-write | danger-full-access.",+ description="Default sandbox for tasks that don't override it. " "One of: read-only | workspace-write | danger-full-access.",)ask_for_approval: str = Field(default="never",@@ -82,10 +80,7 @@ class CodexAgentNode(ActionNode):display_name = "Codex"subtitle = "Sandboxed Coding"group = ("agent",)- description = (- "Run N parallel OpenAI Codex CLI sessions. Sandbox enforced "- "by Codex itself; per-task git worktree isolation."- )+ description = "Run N parallel OpenAI Codex CLI sessions. Sandbox enforced " "by Codex itself; per-task git worktree isolation."component_kind = "agent"handles = std_agent_handles()ui_hints = STD_AGENT_HINTS@@ -100,7 +95,9 @@ class CodexAgentNode(ActionNode):cost={"service": "codex_agent", "action": "run", "count": 1},)async def execute_op(- self, ctx: NodeContext, params: CodexAgentParams,+ self,+ ctx: NodeContext,+ params: CodexAgentParams,) -> Any:from services.cli_agent.service import get_ai_cli_servicefrom services.cli_agent.types import session_result_to_model@@ -113,7 +110,8 @@ class CodexAgentNode(ActionNode):node_id = ctx.node_idawait broadcaster.update_node_status(- node_id, "executing",+ node_id,+ "executing",{"message": "Starting Codex batch..."},workflow_id=workflow_id,)@@ -122,9 +120,7 @@ class CodexAgentNode(ActionNode):if not tasks:prompt = params.prompt or self._infer_prompt_from_inputs(ctx, node_id)if not prompt:- raise RuntimeError(- "codex_agent: provide either `tasks` or `prompt`"- )+ raise RuntimeError("codex_agent: provide either `tasks` or `prompt`")tasks = [CodexTaskSpec(prompt=prompt,@@ -146,25 +142,20 @@ class CodexAgentNode(ActionNode):database = get_database()_, skill_data, _, _, _ = await collect_agent_connections(- node_id, ctx.raw, database,+ node_id,+ ctx.raw,+ database,)- connected_skills = [- s.get("skill_name") or s.get("label")- for s in skill_data- if s.get("skill_name") or s.get("label")- ]+ connected_skills = [s.get("skill_name") or s.get("label") for s in skill_data if s.get("skill_name") or s.get("label")]workspace_dir = ctx.raw.get("workspace_dir") or params.working_directoryif workspace_dir is None:from core.config import Settings- workspace_dir = Path(Settings().workspace_base_resolved) / (- workflow_id or "default"- )++ workspace_dir = Path(Settings().workspace_base_resolved) / (workflow_id or "default")workspace_dir = Path(workspace_dir)- repo_root = (- Path(params.working_directory) if params.working_directory else None- )+ repo_root = Path(params.working_directory) if params.working_directory else Nonesvc = get_ai_cli_service()result = await svc.run_batch(@@ -183,16 +174,18 @@ class CodexAgentNode(ActionNode):elapsed = time.time() - start_timelogger.debug("[codex_agent] node=%s tasks=%d ok=%d fail=%d elapsed=%.2fs",- node_id, result.n_tasks, result.n_succeeded, result.n_failed, elapsed,+ node_id,+ result.n_tasks,+ result.n_succeeded,+ result.n_failed,+ elapsed,)await broadcaster.update_node_status(- node_id, "success" if result.n_failed == 0 else "warning",+ node_id,+ "success" if result.n_failed == 0 else "warning",{- "message": (- f"Batch complete: {result.n_succeeded}/{result.n_tasks} "- f"succeeded"- ),+ "message": (f"Batch complete: {result.n_succeeded}/{result.n_tasks} " f"succeeded"),"n_tasks": result.n_tasks,"n_succeeded": result.n_succeeded,"n_failed": result.n_failed,@@ -202,9 +195,7 @@ class CodexAgentNode(ActionNode):task_models = [session_result_to_model(t).model_dump() for t in result.tasks]- legacy_response = (- result.tasks[0].response if len(result.tasks) == 1 else None- )+ legacy_response = result.tasks[0].response if len(result.tasks) == 1 else Nonereturn {"success": result.n_failed == 0,diff --git a/server/nodes/agent/orchestrator_agent/__init__.py b/server/nodes/agent/orchestrator_agent/__init__.pyindex 03524e9f..a1811aa8 100644--- a/server/nodes/agent/orchestrator_agent/__init__.py+++ b/server/nodes/agent/orchestrator_agent/__init__.py@@ -9,4 +9,6 @@ class OrchestratorAgentNode(SpecializedAgentBase):group = ("agent",)description = "Team lead that delegates to connected specialized agents"handles = team_lead_agent_handles()- tool_description = "ONE-SHOT delegation to Orchestrator Agent. Call ONCE per task, returns task_id. Coordinates multiple agents - do NOT re-call."+ tool_description = (+ "ONE-SHOT delegation to Orchestrator Agent. Call ONCE per task, returns task_id. Coordinates multiple agents - do NOT re-call."+ )diff --git a/server/nodes/agent/rlm_agent/__init__.py b/server/nodes/agent/rlm_agent/__init__.pyindex eacc848c..dc021fb7 100644--- a/server/nodes/agent/rlm_agent/__init__.py+++ b/server/nodes/agent/rlm_agent/__init__.py@@ -12,7 +12,8 @@ from typing import Anyfrom core.logging import get_loggerfrom services.plugin import ActionNode, NodeContext, Operation, TaskQueuefrom services.plugin.edge_walker import (- collect_agent_connections, format_task_context,+ collect_agent_connections,+ format_task_context,)from .._handles import STD_AGENT_HINTS, std_agent_handles@@ -50,42 +51,41 @@ class RLMAgentNode(ActionNode):# 1. Edge-walk for memory / skill / tool / input / task connections.memory_data, skill_data, tool_data, input_data, task_data = await collect_agent_connections(- node_id, ctx.raw, database, log_prefix="[RLM Agent]",+ node_id,+ ctx.raw,+ database,+ log_prefix="[RLM Agent]",)# 2. Inject task-completion context into the prompt.if task_data:payload = {**payload,- 'prompt': f"{format_task_context(task_data)}\n\n{payload.get('prompt', '')}",+ "prompt": f"{format_task_context(task_data)}\n\n{payload.get('prompt', '')}",}logger.info("[RLM Agent] Task context injected for task_id=%s",- task_data.get('task_id'),+ task_data.get("task_id"),)# 3. Strip tools when the agent is being asked to react to a# completed/errored task — there's nothing to invoke.- if task_data.get('status') in ('completed', 'error') and tool_data:+ if task_data.get("status") in ("completed", "error") and tool_data:tool_data = []logger.info("[RLM Agent] Stripped tools for task completion handling")# 4. Auto-prompt fallback: if no prompt + an input is connected,# use the input's text-shaped field.- if not payload.get('prompt') and input_data:+ if not payload.get("prompt") and input_data:payload = {**payload,- 'prompt': (- input_data.get('message')- or input_data.get('text')- or input_data.get('content')- or str(input_data)- ),+ "prompt": (input_data.get("message") or input_data.get("text") or input_data.get("content") or str(input_data)),}logger.info("[RLM Agent] Auto-using input as prompt")# 5. Delegate to the RLM service.response = await ai_service.rlm_service.execute(- node_id, payload,+ node_id,+ payload,memory_data=memory_data,skill_data=skill_data if skill_data else None,tool_data=tool_data if tool_data else None,diff --git a/server/nodes/android/_base.py b/server/nodes/android/_base.pyindex 73d81b4e..8c801e5e 100644--- a/server/nodes/android/_base.py+++ b/server/nodes/android/_base.py@@ -23,22 +23,22 @@ logger = get_logger(__name__)# Maps camelCase node types to snake_case service IDs.# Same map is mirrored in services/handlers/tools.py for the AI-tool path.SERVICE_ID_MAP: Dict[str, str] = {- 'batteryMonitor': 'battery',- 'networkMonitor': 'network',- 'systemInfo': 'system_info',- 'location': 'location',- 'appLauncher': 'app_launcher',- 'appList': 'app_list',- 'wifiAutomation': 'wifi_automation',- 'bluetoothAutomation': 'bluetooth_automation',- 'audioAutomation': 'audio_automation',- 'deviceStateAutomation': 'device_state',- 'screenControlAutomation': 'screen_control',- 'airplaneModeControl': 'airplane_mode',- 'motionDetection': 'motion_detection',- 'environmentalSensors': 'environmental_sensors',- 'cameraControl': 'camera_control',- 'mediaControl': 'media_control',+ "batteryMonitor": "battery",+ "networkMonitor": "network",+ "systemInfo": "system_info",+ "location": "location",+ "appLauncher": "app_launcher",+ "appList": "app_list",+ "wifiAutomation": "wifi_automation",+ "bluetoothAutomation": "bluetooth_automation",+ "audioAutomation": "audio_automation",+ "deviceStateAutomation": "device_state",+ "screenControlAutomation": "screen_control",+ "airplaneModeControl": "airplane_mode",+ "motionDetection": "motion_detection",+ "environmentalSensors": "environmental_sensors",+ "cameraControl": "camera_control",+ "mediaControl": "media_control",}@@ -100,10 +100,8 @@ class AndroidServiceBase(ActionNode, abstract=True):group = ("android", "service")component_kind = "square"handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}task_queue = TaskQueue.ANDROID@@ -121,11 +119,11 @@ class AndroidServiceBase(ActionNode, abstract=True):# Derive service_id from the registered node type (battery etc.) —# hidden params may not be in the DB so the type is the source of truth.- service_id = SERVICE_ID_MAP.get(self.type, payload.get('service_id', 'battery'))- action = payload.get('action', 'status')- service_params = payload.get('parameters', {})- android_host = payload.get('android_host', 'localhost')- android_port = payload.get('android_port', 8888)+ service_id = SERVICE_ID_MAP.get(self.type, payload.get("service_id", "battery"))+ action = payload.get("action", "status")+ service_params = payload.get("parameters", {})+ android_host = payload.get("android_host", "localhost")+ android_port = payload.get("android_port", 8888)# Parse JSON-string parameters defensively.if isinstance(service_params, str):@@ -136,13 +134,18 @@ class AndroidServiceBase(ActionNode, abstract=True):# Hoist root-level additional properties (e.g. package_name from# appLauncher's additionalProperties UI) into service_params.- for key in ('package_name',):+ for key in ("package_name",):if payload.get(key):service_params[key] = payload[key]logger.debug("[Android] node_type=%s -> service_id=%s action=%s host=%s:%s params=%s",- self.type, service_id, action, android_host, android_port, service_params,+ self.type,+ service_id,+ action,+ android_host,+ android_port,+ service_params,)result = await android_service.execute_service(@@ -173,9 +176,15 @@ class AndroidServiceBase(ActionNode, abstract=True):async def _execute_with_broadcast(- *, target_node_id: Optional[str], workflow_id: Optional[str],- service_id: str, action: str, parameters: Dict[str, Any],- host: str, port: int, log_label: str,+ *,+ target_node_id: Optional[str],+ workflow_id: Optional[str],+ service_id: str,+ action: str,+ parameters: Dict[str, Any],+ host: str,+ port: int,+ log_label: str,) -> Dict[str, Any]:"""Run an Android service call with broadcast status for the UI node."""from ._dispatcher import AndroidService@@ -184,14 +193,15 @@ async def _execute_with_broadcast(broadcaster = get_status_broadcaster()if target_node_id:await broadcaster.update_node_status(- target_node_id, "executing",+ target_node_id,+ "executing",{"message": f"Executing {action} via {log_label}"},workflow_id=workflow_id,)try:result = await AndroidService().execute_service(- node_id=target_node_id or 'tool',+ node_id=target_node_id or "tool",service_id=service_id,action=action,parameters=parameters,@@ -200,28 +210,30 @@ async def _execute_with_broadcast()if target_node_id:- if result.get('success'):+ if result.get("success"):await broadcaster.update_node_status(- target_node_id, "success",- {"message": f"{action} completed", "result": result.get('result', {})},+ target_node_id,+ "success",+ {"message": f"{action} completed", "result": result.get("result", {})},workflow_id=workflow_id,)else:await broadcaster.update_node_status(- target_node_id, "error",- {"message": result.get('error', 'Unknown error')},+ target_node_id,+ "error",+ {"message": result.get("error", "Unknown error")},workflow_id=workflow_id,)- if result.get('success'):+ if result.get("success"):return {"success": True,"service": service_id,"action": action,- "data": result.get('result', {}).get('data', result.get('result', {})),+ "data": result.get("result", {}).get("data", result.get("result", {})),}return {- "error": result.get('error', 'Unknown error'),+ "error": result.get("error", "Unknown error"),"service": service_id,"action": action,}@@ -229,7 +241,8 @@ async def _execute_with_broadcast(logger.error(f"[{log_label}] Unexpected error: {e}")if target_node_id:await broadcaster.update_node_status(- target_node_id, "error",+ target_node_id,+ "error",{"message": str(e)},workflow_id=workflow_id,)@@ -237,55 +250,53 @@ async def _execute_with_broadcast(async def execute_android_toolkit(- args: Dict[str, Any], config: Dict[str, Any],+ args: Dict[str, Any],+ config: Dict[str, Any],) -> Dict[str, Any]:"""Route an LLM tool call through the Android toolkit aggregator.Looks up the connected service in ``config['connected_services']``by ``service_id``, then executes through the broadcast helper."""- service_id = args.get('service_id', '')- action = args.get('action', '')- parameters = args.get('parameters') or {}+ service_id = args.get("service_id", "")+ action = args.get("action", "")+ parameters = args.get("parameters") or {}- connected_services = config.get('connected_services', [])+ connected_services = config.get("connected_services", [])if not service_id:- available = [s.get('service_id') or s.get('node_type') for s in connected_services]+ available = [s.get("service_id") or s.get("node_type") for s in connected_services]return {"error": "No service_id provided",- "hint": (- f"Available services: {', '.join(available)}"- if available else "No services connected"- ),+ "hint": (f"Available services: {', '.join(available)}" if available else "No services connected"),}target_service = next(- (- s for s in connected_services- if (s.get('service_id') or s.get('node_type')) == service_id- ),+ (s for s in connected_services if (s.get("service_id") or s.get("node_type")) == service_id),None,)if not target_service:- available = [s.get('service_id') or s.get('node_type') for s in connected_services]+ available = [s.get("service_id") or s.get("node_type") for s in connected_services]return {"error": f"Service '{service_id}' not connected to toolkit","available_services": available,}- svc_params = target_service.get('parameters', {})- host = svc_params.get('android_host', 'localhost')- port = int(svc_params.get('android_port', 8888))+ svc_params = target_service.get("parameters", {})+ host = svc_params.get("android_host", "localhost")+ port = int(svc_params.get("android_port", 8888))if not action:- action = svc_params.get('action') or target_service.get('action', 'status')+ action = svc_params.get("action") or target_service.get("action", "status")- target_node_id = target_service.get('node_id')- workflow_id = config.get('workflow_id')+ target_node_id = target_service.get("node_id")+ workflow_id = config.get("workflow_id")logger.info("[Android Toolkit] Executing %s.%s via '%s' (node: %s, workflow: %s)",- service_id, action, target_service.get('label'),- target_node_id, workflow_id,+ service_id,+ action,+ target_service.get("label"),+ target_node_id,+ workflow_id,)return await _execute_with_broadcast(@@ -294,33 +305,38 @@ async def execute_android_toolkit(service_id=service_id,action=action,parameters=parameters,- host=host, port=port,+ host=host,+ port=port,log_label="Android Toolkit",)async def execute_android_service_tool(- args: Dict[str, Any], config: Dict[str, Any],+ args: Dict[str, Any],+ config: Dict[str, Any],) -> Dict[str, Any]:"""Route an LLM tool call to a directly-connected Android service node.Uses ``SERVICE_ID_MAP[node_type]`` instead of the synthetic toolkitindirection — the LLM addresses each service node by its own type."""- node_type = config.get('node_type', '')- node_id = config.get('node_id', '')- node_params = config.get('parameters', {})- workflow_id = config.get('workflow_id')+ node_type = config.get("node_type", "")+ node_id = config.get("node_id", "")+ node_params = config.get("parameters", {})+ workflow_id = config.get("workflow_id")service_id = SERVICE_ID_MAP.get(node_type, node_type)- action = args.get('action') or node_params.get('action', 'status')- parameters = args.get('parameters') or {}- host = node_params.get('android_host', 'localhost')- port = int(node_params.get('android_port', 8888))+ action = args.get("action") or node_params.get("action", "status")+ parameters = args.get("parameters") or {}+ host = node_params.get("android_host", "localhost")+ port = int(node_params.get("android_port", 8888))logger.info("[Android Service] Executing %s.%s (node: %s, workflow: %s)",- service_id, action, node_id, workflow_id,+ service_id,+ action,+ node_id,+ workflow_id,)return await _execute_with_broadcast(@@ -329,6 +345,7 @@ async def execute_android_service_tool(service_id=service_id,action=action,parameters=parameters,- host=host, port=port,+ host=host,+ port=port,log_label="Android Service",)diff --git a/server/nodes/android/_dispatcher.py b/server/nodes/android/_dispatcher.pyindex 7110b56c..fcbde765 100644--- a/server/nodes/android/_dispatcher.py+++ b/server/nodes/android/_dispatcher.py@@ -11,122 +11,106 @@ logger = get_logger(__name__)# Default parameters for service actions (based on web_tester DEFAULTS)SERVICE_DEFAULT_PARAMETERS = {- ('app_launcher', 'launch'): '{"package_name": "com.android.settings"}',- ('wifi_automation', 'enable'): '{}',- ('wifi_automation', 'disable'): '{}',- ('wifi_automation', 'status'): '{}',- ('wifi_automation', 'scan'): '{}',- ('bluetooth_automation', 'enable'): '{}',- ('bluetooth_automation', 'disable'): '{}',- ('bluetooth_automation', 'status'): '{}',- ('audio_automation', 'get_volume'): '{}',- ('audio_automation', 'set_volume'): '{"volume": 50}',- ('audio_automation', 'mute'): '{}',- ('audio_automation', 'unmute'): '{}',- ('media_control', 'volume_control'): '{"action": "get_volume"}',- ('media_control', 'media_control'): '{"action": "play"}',- ('media_control', 'play_media'): '{"url": "https://www.soundjay.com/misc/bell-ringing-05.wav"}',- ('camera_control', 'camera_info'): '{}',- ('camera_control', 'take_photo'): '{"filename": "test_photo.jpg"}',- ('motion_detection', 'current_motion'): '{}',- ('motion_detection', 'shake_detection'): '{}',- ('environmental_sensors', 'ambient_conditions'): '{}',- ('environmental_sensors', 'proximity'): '{}',- ('location', 'current'): '{}',- ('location', 'start_tracking'): '{}',- ('location', 'stop_tracking'): '{}',- ('device_state_automation', 'airplane_mode'): '{"enabled": true}',- ('device_state_automation', 'screen_on'): '{}',- ('device_state_automation', 'screen_off'): '{}',- ('device_state_automation', 'status'): '{}',- ('screen_control_automation', 'brightness'): '{"level": 150}',- ('screen_control_automation', 'wake'): '{}',- ('screen_control_automation', 'status'): '{}',- ('app_list', 'list'): '{"include_system": false, "include_disabled": false}',- ('app_killer', 'kill'): '{"package_name": "com.example.app"}',- ('app_usage', 'stats'): '{}',- ('battery', 'status'): '{}',- ('network', 'status'): '{}',- ('system_info', 'info'): '{}',- ('airplane_mode_control', 'status'): '{}'+ ("app_launcher", "launch"): '{"package_name": "com.android.settings"}',+ ("wifi_automation", "enable"): "{}",+ ("wifi_automation", "disable"): "{}",+ ("wifi_automation", "status"): "{}",+ ("wifi_automation", "scan"): "{}",+ ("bluetooth_automation", "enable"): "{}",+ ("bluetooth_automation", "disable"): "{}",+ ("bluetooth_automation", "status"): "{}",+ ("audio_automation", "get_volume"): "{}",+ ("audio_automation", "set_volume"): '{"volume": 50}',+ ("audio_automation", "mute"): "{}",+ ("audio_automation", "unmute"): "{}",+ ("media_control", "volume_control"): '{"action": "get_volume"}',+ ("media_control", "media_control"): '{"action": "play"}',+ ("media_control", "play_media"): '{"url": "https://www.soundjay.com/misc/bell-ringing-05.wav"}',+ ("camera_control", "camera_info"): "{}",+ ("camera_control", "take_photo"): '{"filename": "test_photo.jpg"}',+ ("motion_detection", "current_motion"): "{}",+ ("motion_detection", "shake_detection"): "{}",+ ("environmental_sensors", "ambient_conditions"): "{}",+ ("environmental_sensors", "proximity"): "{}",+ ("location", "current"): "{}",+ ("location", "start_tracking"): "{}",+ ("location", "stop_tracking"): "{}",+ ("device_state_automation", "airplane_mode"): '{"enabled": true}',+ ("device_state_automation", "screen_on"): "{}",+ ("device_state_automation", "screen_off"): "{}",+ ("device_state_automation", "status"): "{}",+ ("screen_control_automation", "brightness"): '{"level": 150}',+ ("screen_control_automation", "wake"): "{}",+ ("screen_control_automation", "status"): "{}",+ ("app_list", "list"): '{"include_system": false, "include_disabled": false}',+ ("app_killer", "kill"): '{"package_name": "com.example.app"}',+ ("app_usage", "stats"): "{}",+ ("battery", "status"): "{}",+ ("network", "status"): "{}",+ ("system_info", "info"): "{}",+ ("airplane_mode_control", "status"): "{}",}# Service action mappings based on Android service schemasSERVICE_ACTIONS = {- 'battery': [- {'name': 'Status', 'value': 'status', 'description': 'Get battery status information'}+ "battery": [{"name": "Status", "value": "status", "description": "Get battery status information"}],+ "network": [{"name": "Status", "value": "status", "description": "Get network connectivity status"}],+ "system_info": [{"name": "Info", "value": "info", "description": "Get system and device information"}],+ "location": [+ {"name": "Current", "value": "current", "description": "Get current location"},+ {"name": "Start Tracking", "value": "start_tracking", "description": "Start location tracking"},+ {"name": "Stop Tracking", "value": "stop_tracking", "description": "Stop location tracking"},],- 'network': [- {'name': 'Status', 'value': 'status', 'description': 'Get network connectivity status'}+ "app_launcher": [{"name": "Launch", "value": "launch", "description": "Launch an application"}],+ "app_list": [{"name": "List", "value": "list", "description": "Get list of installed apps"}],+ "app_killer": [{"name": "Kill", "value": "kill", "description": "Force stop an application"}],+ "app_usage": [{"name": "Stats", "value": "stats", "description": "Get app usage statistics"}],+ "wifi_automation": [+ {"name": "Enable", "value": "enable", "description": "Enable WiFi"},+ {"name": "Disable", "value": "disable", "description": "Disable WiFi"},+ {"name": "Status", "value": "status", "description": "Get WiFi status"},+ {"name": "Scan", "value": "scan", "description": "Scan for networks"},],- 'system_info': [- {'name': 'Info', 'value': 'info', 'description': 'Get system and device information'}+ "bluetooth_automation": [+ {"name": "Enable", "value": "enable", "description": "Enable Bluetooth"},+ {"name": "Disable", "value": "disable", "description": "Disable Bluetooth"},+ {"name": "Status", "value": "status", "description": "Get Bluetooth status"},],- 'location': [- {'name': 'Current', 'value': 'current', 'description': 'Get current location'},- {'name': 'Start Tracking', 'value': 'start_tracking', 'description': 'Start location tracking'},- {'name': 'Stop Tracking', 'value': 'stop_tracking', 'description': 'Stop location tracking'}+ "audio_automation": [+ {"name": "Get Volume", "value": "get_volume", "description": "Get current volume"},+ {"name": "Set Volume", "value": "set_volume", "description": "Set volume level"},+ {"name": "Mute", "value": "mute", "description": "Mute audio"},+ {"name": "Unmute", "value": "unmute", "description": "Unmute audio"},],- 'app_launcher': [- {'name': 'Launch', 'value': 'launch', 'description': 'Launch an application'}+ "device_state_automation": [+ {"name": "Airplane Mode", "value": "airplane_mode", "description": "Toggle airplane mode"},+ {"name": "Screen On", "value": "screen_on", "description": "Turn screen on"},+ {"name": "Screen Off", "value": "screen_off", "description": "Turn screen off"},+ {"name": "Status", "value": "status", "description": "Get device state"},],- 'app_list': [- {'name': 'List', 'value': 'list', 'description': 'Get list of installed apps'}+ "screen_control_automation": [+ {"name": "Brightness", "value": "brightness", "description": "Set brightness level"},+ {"name": "Wake", "value": "wake", "description": "Wake up screen"},+ {"name": "Status", "value": "status", "description": "Get screen status"},],- 'app_killer': [- {'name': 'Kill', 'value': 'kill', 'description': 'Force stop an application'}+ "motion_detection": [+ {"name": "Current Motion", "value": "current_motion", "description": "Get current motion data"},+ {"name": "Shake Detection", "value": "shake_detection", "description": "Detect shake gesture"},],- 'app_usage': [- {'name': 'Stats', 'value': 'stats', 'description': 'Get app usage statistics'}+ "environmental_sensors": [+ {"name": "Ambient Conditions", "value": "ambient_conditions", "description": "Get temperature, humidity, pressure"},+ {"name": "Proximity", "value": "proximity", "description": "Get proximity sensor data"},],- 'wifi_automation': [- {'name': 'Enable', 'value': 'enable', 'description': 'Enable WiFi'},- {'name': 'Disable', 'value': 'disable', 'description': 'Disable WiFi'},- {'name': 'Status', 'value': 'status', 'description': 'Get WiFi status'},- {'name': 'Scan', 'value': 'scan', 'description': 'Scan for networks'}+ "camera_control": [+ {"name": "Camera Info", "value": "camera_info", "description": "Get camera information"},+ {"name": "Take Photo", "value": "take_photo", "description": "Capture a photo"},],- 'bluetooth_automation': [- {'name': 'Enable', 'value': 'enable', 'description': 'Enable Bluetooth'},- {'name': 'Disable', 'value': 'disable', 'description': 'Disable Bluetooth'},- {'name': 'Status', 'value': 'status', 'description': 'Get Bluetooth status'}- ],- 'audio_automation': [- {'name': 'Get Volume', 'value': 'get_volume', 'description': 'Get current volume'},- {'name': 'Set Volume', 'value': 'set_volume', 'description': 'Set volume level'},- {'name': 'Mute', 'value': 'mute', 'description': 'Mute audio'},- {'name': 'Unmute', 'value': 'unmute', 'description': 'Unmute audio'}- ],- 'device_state_automation': [- {'name': 'Airplane Mode', 'value': 'airplane_mode', 'description': 'Toggle airplane mode'},- {'name': 'Screen On', 'value': 'screen_on', 'description': 'Turn screen on'},- {'name': 'Screen Off', 'value': 'screen_off', 'description': 'Turn screen off'},- {'name': 'Status', 'value': 'status', 'description': 'Get device state'}- ],- 'screen_control_automation': [- {'name': 'Brightness', 'value': 'brightness', 'description': 'Set brightness level'},- {'name': 'Wake', 'value': 'wake', 'description': 'Wake up screen'},- {'name': 'Status', 'value': 'status', 'description': 'Get screen status'}- ],- 'motion_detection': [- {'name': 'Current Motion', 'value': 'current_motion', 'description': 'Get current motion data'},- {'name': 'Shake Detection', 'value': 'shake_detection', 'description': 'Detect shake gesture'}- ],- 'environmental_sensors': [- {'name': 'Ambient Conditions', 'value': 'ambient_conditions', 'description': 'Get temperature, humidity, pressure'},- {'name': 'Proximity', 'value': 'proximity', 'description': 'Get proximity sensor data'}- ],- 'camera_control': [- {'name': 'Camera Info', 'value': 'camera_info', 'description': 'Get camera information'},- {'name': 'Take Photo', 'value': 'take_photo', 'description': 'Capture a photo'}- ],- 'media_control': [- {'name': 'Volume Control', 'value': 'volume_control', 'description': 'Control media volume'},- {'name': 'Media Control', 'value': 'media_control', 'description': 'Control playback'},- {'name': 'Play Media', 'value': 'play_media', 'description': 'Play media file'}- ],- 'airplane_mode_control': [- {'name': 'Status', 'value': 'status', 'description': 'Get airplane mode status'}+ "media_control": [+ {"name": "Volume Control", "value": "volume_control", "description": "Control media volume"},+ {"name": "Media Control", "value": "media_control", "description": "Control playback"},+ {"name": "Play Media", "value": "play_media", "description": "Play media file"},],+ "airplane_mode_control": [{"name": "Status", "value": "status", "description": "Get airplane mode status"}],# Unavailable services on current device (emulator-5554)# These services returned "Service not available" errors during testing# 'notification_sender': [@@ -193,15 +177,10 @@ class AndroidService:Returns:Default parameters as JSON string"""- return SERVICE_DEFAULT_PARAMETERS.get((service_id, action), '{}')+ return SERVICE_DEFAULT_PARAMETERS.get((service_id, action), "{}")async def _execute_via_relay(- self,- node_id: str,- service_id: str,- action: str,- parameters: Dict[str, Any],- start_time: float+ self, node_id: str, service_id: str, action: str, parameters: Dict[str, Any], start_time: float) -> Dict[str, Any]:"""Execute Android service via Relay WebSocket (remote device).@@ -235,7 +214,7 @@ class AndroidService:service_id=service_id,action=action,device_id=device_id,- device_name=device_name+ device_name=device_name,)# Send service request via relay@@ -243,37 +222,32 @@ class AndroidService:service_id=service_id,action=action,parameters=parameters,- timeout=30.0 # Increased timeout for relay communication+ timeout=30.0, # Increased timeout for relay communication)if not response:- raise Exception(- "No response from Android device (timeout). "- "Ensure the Android app is running and paired."- )+ raise Exception("No response from Android device (timeout). " "Ensure the Android app is running and paired.")# Parse response - Android device may return:# 1. {"success": true, "data": {...}}# 2. {"data": {...}} (success implied)# 3. {"success": false, "error": "..."}# 4. Raw data object without wrapper- logger.debug("[Android Service] Raw relay response",- response_keys=list(response.keys()) if isinstance(response, dict) else "not_dict")+ logger.debug(+ "[Android Service] Raw relay response", response_keys=list(response.keys()) if isinstance(response, dict) else "not_dict"+ )# Check for explicit success field, otherwise infer from data presence- if 'success' in response:- success = response.get('success', False)+ if "success" in response:+ success = response.get("success", False)else:# No explicit success field - if we got data, consider it success- success = 'data' in response or ('error' not in response and response)+ success = "data" in response or ("error" not in response and response)- data = response.get('data', response if 'success' not in response and 'error' not in response else {})- error_msg = response.get('error')+ data = response.get("data", response if "success" not in response and "error" not in response else {})+ error_msg = response.get("error")- logger.debug("[Android Service] Relay response parsed",- success=success,- has_data=bool(data),- error=error_msg)+ logger.debug("[Android Service] Relay response parsed", success=success, has_data=bool(data), error=error_msg)if success:result = {@@ -288,10 +262,10 @@ class AndroidService:"connection_type": "relay","device_id": device_id,"device_name": device_name,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}else:result = {@@ -305,46 +279,31 @@ class AndroidService:"data": data,"connection_type": "relay","device_id": device_id,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}log_execution_time(logger, f"android_service_{service_id}_{action}_relay", start_time, time.time())logger.debug(- "[Android Service] Relay execution completed",- node_id=node_id,- service_id=service_id,- action=action,- success=success+ "[Android Service] Relay execution completed", node_id=node_id, service_id=service_id, action=action, success=success)return resultexcept Exception as e:- logger.error(- "[Android Service] Relay execution failed",- node_id=node_id,- service_id=service_id,- action=action,- error=str(e)- )+ logger.error("[Android Service] Relay execution failed", node_id=node_id, service_id=service_id, action=action, error=str(e))return {"success": False,"node_id": node_id,"node_type": "androidService","error": str(e),- "result": {- "service_id": service_id,- "action": action,- "connection_type": "relay",- "timestamp": datetime.now().isoformat()- },+ "result": {"service_id": service_id, "action": action, "connection_type": "relay", "timestamp": datetime.now().isoformat()},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def execute_service(@@ -354,7 +313,7 @@ class AndroidService:action: str,parameters: Dict[str, Any],android_host: str = "localhost",- android_port: int = 8888+ android_port: int = 8888,) -> Dict[str, Any]:"""Execute an Android system service action.@@ -374,19 +333,13 @@ class AndroidService:try:# Check if relay connection is available (remote device)from ._relay import get_current_relay_client+relay_client = get_current_relay_client()if relay_client and relay_client.is_paired():# Use relay for remote Android device- logger.debug(- "[Android Service] Using relay connection",- node_id=node_id,- service_id=service_id,- action=action- )- return await self._execute_via_relay(- node_id, service_id, action, parameters, start_time- )+ logger.debug("[Android Service] Using relay connection", node_id=node_id, service_id=service_id, action=action)+ return await self._execute_via_relay(node_id, service_id, action, parameters, start_time)else:# Use local HTTP connectionbase_url = f"http://{android_host}:{android_port}/api"@@ -395,28 +348,22 @@ class AndroidService:node_id=node_id,service_id=service_id,action=action,- base_url=base_url+ base_url=base_url,)# Build request payload- request_payload = {- "action": action,- "parameters": parameters- }+ request_payload = {"action": action, "parameters": parameters}# Make request to Android device APIasync with httpx.AsyncClient(timeout=self.default_timeout) as client:- response = await client.post(- f"{base_url}/{service_id}",- json=request_payload- )+ response = await client.post(f"{base_url}/{service_id}", json=request_payload)# Parse responseif response.status_code == 200:response_data = response.json()# Check if Android service returned success- service_success = response_data.get('success', True)+ service_success = response_data.get("success", True)result = {"success": service_success,@@ -425,18 +372,18 @@ class AndroidService:"result": {"service_id": service_id,"action": action,- "data": response_data.get('data', response_data),+ "data": response_data.get("data", response_data),"response_time": response.elapsed.total_seconds(),"android_host": android_host,"android_port": android_port,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}if not service_success:- result["result"]["error"] = response_data.get('error', 'Service execution failed')+ result["result"]["error"] = response_data.get("error", "Service execution failed")log_execution_time(logger, f"android_service_{service_id}_{action}", start_time, time.time())@@ -445,7 +392,7 @@ class AndroidService:node_id=node_id,service_id=service_id,action=action,- success=service_success+ success=service_success,)return result@@ -458,7 +405,7 @@ class AndroidService:node_id=node_id,service_id=service_id,status_code=response.status_code,- error=error_msg+ error=error_msg,)return {@@ -470,10 +417,10 @@ class AndroidService:"service_id": service_id,"action": action,"status_code": response.status_code,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except httpx.ConnectError as e:@@ -484,7 +431,7 @@ class AndroidService:service_id=service_id,error=str(e),android_host=android_host,- android_port=android_port+ android_port=android_port,)return {@@ -492,24 +439,14 @@ class AndroidService:"node_id": node_id,"node_type": "androidService","error": error_msg,- "result": {- "service_id": service_id,- "action": action,- "connection_error": str(e),- "timestamp": datetime.now().isoformat()- },+ "result": {"service_id": service_id, "action": action, "connection_error": str(e), "timestamp": datetime.now().isoformat()},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except httpx.TimeoutException:error_msg = f"Request timeout after {self.default_timeout}s"- logger.error(- "[Android Service] Timeout",- node_id=node_id,- service_id=service_id,- timeout=self.default_timeout- )+ logger.error("[Android Service] Timeout", node_id=node_id, service_id=service_id, timeout=self.default_timeout)return {"success": False,@@ -520,40 +457,26 @@ class AndroidService:"service_id": service_id,"action": action,"timeout": self.default_timeout,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:- logger.error(- "[Android Service] Unexpected error",- node_id=node_id,- service_id=service_id,- error=str(e),- exc_info=True- )+ logger.error("[Android Service] Unexpected error", node_id=node_id, service_id=service_id, error=str(e), exc_info=True)return {"success": False,"node_id": node_id,"node_type": "androidService","error": str(e),- "result": {- "service_id": service_id,- "action": action,- "timestamp": datetime.now().isoformat()- },+ "result": {"service_id": service_id, "action": action, "timestamp": datetime.now().isoformat()},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}- async def check_device_status(- self,- android_host: str = "localhost",- android_port: int = 8888- ) -> Dict[str, Any]:+ async def check_device_status(self, android_host: str = "localhost", android_port: int = 8888) -> Dict[str, Any]:"""Check if Android device API is reachable.Returns:@@ -568,18 +491,8 @@ class AndroidService:"online": response.status_code == 200,"data": response.json() if response.status_code == 200 else None,"android_host": android_host,- "android_port": android_port+ "android_port": android_port,}except Exception as e:- logger.warning(- "[Android Service] Device offline",- android_host=android_host,- android_port=android_port,- error=str(e)- )- return {- "online": False,- "error": str(e),- "android_host": android_host,- "android_port": android_port- }+ logger.warning("[Android Service] Device offline", android_host=android_host, android_port=android_port, error=str(e))+ return {"online": False, "error": str(e), "android_host": android_host, "android_port": android_port}diff --git a/server/nodes/android/_events.py b/server/nodes/android/_events.pyindex a0f3c475..39187a19 100644--- a/server/nodes/android/_events.py+++ b/server/nodes/android/_events.py@@ -74,11 +74,7 @@ def android_connection_status("""return WorkflowEvent(source="machinaos://nodes/android",- type=(- "com.machinaos.android.connection.opened"- if connected- else "com.machinaos.android.connection.closed"- ),+ type=("com.machinaos.android.connection.opened" if connected else "com.machinaos.android.connection.closed"),subject=device_id,data={"connected": connected,@@ -144,10 +140,12 @@ async def broadcast_android_status(qr_data=qr_data,session_token=session_token,)- await broadcaster.broadcast({- "type": _TYPED_WIRE_KEY,- "data": event.model_dump(mode="json"),- })+ await broadcaster.broadcast(+ {+ "type": _TYPED_WIRE_KEY,+ "data": event.model_dump(mode="json"),+ }+ )__all__ = [diff --git a/server/nodes/android/_handlers.py b/server/nodes/android/_handlers.pyindex 06ec2adf..2b819de0 100644--- a/server/nodes/android/_handlers.py+++ b/server/nodes/android/_handlers.py@@ -55,16 +55,16 @@ async def handle_execute_android_action(data: Dict[str, Any], websocket: WebSockawait broadcaster.update_node_status(node_id, "executing")result = await android_service.execute_service(- node_id=node_id, service_id=service_id, action=action,+ node_id=node_id,+ service_id=service_id,+ action=action,parameters=data.get("parameters", {}),android_host=data.get("android_host", "localhost"),- android_port=data.get("android_port", 8888)+ android_port=data.get("android_port", 8888),)status = "success" if result.get("success") else "error"- await broadcaster.update_node_status(- node_id, status, result.get("result") or {"error": result.get("error")}- )+ await broadcaster.update_node_status(node_id, status, result.get("result") or {"error": result.get("error")})return result@@ -90,8 +90,7 @@ async def handle_android_relay_connect(data: Dict[str, Any], websocket: WebSockeclient, error = await get_relay_client(url, api_key)if client:logger.info(- f"[WebSocket] Android relay connect success, qr_data present: "- f"{bool(client.qr_data)}, session_token: {client.session_token}"+ f"[WebSocket] Android relay connect success, qr_data present: " f"{bool(client.qr_data)}, session_token: {client.session_token}")return {"success": True,diff --git a/server/nodes/android/_option_loaders.py b/server/nodes/android/_option_loaders.pyindex 77168832..f2c9158f 100644--- a/server/nodes/android/_option_loaders.py+++ b/server/nodes/android/_option_loaders.py@@ -36,9 +36,6 @@ async def load_service_actions(params: Dict[str, Any]) -> List[Dict[str, Any]]:android_svc = get_android_service()actions = await android_svc.list_actions(service_id) # type: ignore[attr-defined]- return [- {"value": a, "label": a.replace("_", " ").title()}- for a in actions or []- ]+ return [{"value": a, "label": a.replace("_", " ").title()} for a in actions or []]except Exception:return []diff --git a/server/nodes/android/_refresh.py b/server/nodes/android/_refresh.pyindex cdb0b22b..72543658 100644--- a/server/nodes/android/_refresh.py+++ b/server/nodes/android/_refresh.py@@ -77,9 +77,7 @@ async def _auto_reconnect_body(broadcaster: "StatusBroadcaster", span) -> None:if not relay_url or not api_key:span.set_attribute("path", "session_missing_creds")- logger.debug(- "[StatusBroadcaster] Stored session missing relay URL or API key"- )+ logger.debug("[StatusBroadcaster] Stored session missing relay URL or API key")returnspan.set_attribute("path", "auto_reconnect")@@ -111,13 +109,9 @@ async def _auto_reconnect_body(broadcaster: "StatusBroadcaster", span) -> None:span.set_attribute("reconnect_ok", True)else:span.set_attribute("reconnect_ok", False)- logger.warning(- "[StatusBroadcaster] Failed to reconnect Android relay: %s", error- )+ logger.warning("[StatusBroadcaster] Failed to reconnect Android relay: %s", error)# Stored session is stale; drop it.await database.clear_android_relay_session()except Exception as exc: # noqa: BLE001 -- mirror pre-migration behaviourspan.record_exception(exc)- logger.debug(- "[StatusBroadcaster] Could not auto-reconnect Android relay: %s", exc- )+ logger.debug("[StatusBroadcaster] Could not auto-reconnect Android relay: %s", exc)diff --git a/server/nodes/android/_relay/broadcaster.py b/server/nodes/android/_relay/broadcaster.pyindex aeb0423e..c713f1c2 100644--- a/server/nodes/android/_relay/broadcaster.py+++ b/server/nodes/android/_relay/broadcaster.py@@ -8,6 +8,7 @@ B1 — the actual broadcast emission moved into:mod:`nodes.android._events` (plugin-owned). This file just adaptsrelay-state to that shape."""+from typing import Optional, Setimport structlog@@ -21,7 +22,7 @@ async def _emit_relay_status(device_name: Optional[str] = None,devices: Optional[Set[str]] = None,qr_data: Optional[str] = None,- session_token: Optional[str] = None+ session_token: Optional[str] = None,):"""Translate relay-shaped args and route to the canonicalplugin-owned broadcaster (``nodes.android._events``)."""@@ -47,19 +48,11 @@ async def _emit_relay_status(async def broadcast_connected(device_id: str, device_name: Optional[str] = None):"""Broadcast that Android device is paired"""await _emit_relay_status(- connected=True,- paired=True,- device_id=device_id,- device_name=device_name,- devices={device_id} if device_id else set()+ connected=True, paired=True, device_id=device_id, device_name=device_name, devices={device_id} if device_id else set())-async def broadcast_device_disconnected(- relay_connected: bool = True,- qr_data: Optional[str] = None,- session_token: Optional[str] = None-):+async def broadcast_device_disconnected(relay_connected: bool = True, qr_data: Optional[str] = None, session_token: Optional[str] = None):"""Broadcast that Android device is disconnected (but relay may still be connected).This is called when the Android device unpairs. The relay connection may still be active.@@ -77,19 +70,13 @@ async def broadcast_device_disconnected(device_name=None,devices=set(),qr_data=qr_data, # Keep QR data for re-pairing- session_token=session_token+ session_token=session_token,)async def broadcast_relay_disconnected():"""Broadcast that relay connection is closed (fully disconnected)"""- await _emit_relay_status(- connected=False,- paired=False,- device_id=None,- device_name=None,- devices=set()- )+ await _emit_relay_status(connected=False, paired=False, device_id=None, device_name=None, devices=set())# Legacy alias for backwards compatibility@@ -107,5 +94,5 @@ async def broadcast_qr_code(qr_data: str, session_token: Optional[str] = None):device_name=None,devices=set(),qr_data=qr_data,- session_token=session_token+ session_token=session_token,)diff --git a/server/nodes/android/_relay/client.py b/server/nodes/android/_relay/client.pyindex 624df1bc..91037476 100644--- a/server/nodes/android/_relay/client.py+++ b/server/nodes/android/_relay/client.py@@ -10,6 +10,7 @@ Connection flow:4. Receive pairing.connected when Android pairs5. Exchange messages via relay.send / relay.message"""+import asyncioimport jsonimport uuid@@ -18,12 +19,7 @@ from typing import Optional, Dict, Any, Set, Callableimport structlogfrom .protocol import RPCResponse, RPCRequestTracker, is_response-from .broadcaster import (- broadcast_connected,- broadcast_device_disconnected,- broadcast_relay_disconnected,- broadcast_qr_code-)+from .broadcaster import broadcast_connected, broadcast_device_disconnected, broadcast_relay_disconnected, broadcast_qr_codelogger = structlog.get_logger()@@ -90,7 +86,7 @@ class RelayWebSocketClient:self.url,heartbeat=30,autoping=True,- ssl=True # Explicit SSL for wss://+ ssl=True, # Explicit SSL for wss://)self.connected = Trueself._running = True@@ -111,9 +107,7 @@ class RelayWebSocketClient:self.session_token = params.get("session_token")self.qr_data = params.get("qr_data")- logger.info("[Relay] Connection established",- session_token=self.session_token,- has_qr=bool(self.qr_data))+ logger.info("[Relay] Connection established", session_token=self.session_token, has_qr=bool(self.qr_data))# Broadcast QR data to frontendif self.qr_data:@@ -208,6 +202,7 @@ class RelayWebSocketClient:"""Clear stored pairing session from database."""try:from services.plugin.deps import get_database+database = get_database()await database.clear_android_relay_session()@@ -277,11 +272,7 @@ class RelayWebSocketClient:await asyncio.sleep(25)if self._running and self.ws and not self.ws.closed:try:- await self.ws.send_json({- "jsonrpc": "2.0",- "method": "ping",- "params": {}- })+ await self.ws.send_json({"jsonrpc": "2.0", "method": "ping", "params": {}})except Exception as e:logger.error("[Relay] Keepalive error", error=str(e))self._running = False@@ -335,9 +326,7 @@ class RelayWebSocketClient:self.paired_device_id = params.get("device_id")self.paired_device_name = params.get("device_name")- logger.info("[Relay] Android paired",- device_id=self.paired_device_id,- device_name=self.paired_device_name)+ logger.info("[Relay] Android paired", device_id=self.paired_device_id, device_name=self.paired_device_name)await broadcast_connected(self.paired_device_id, self.paired_device_name)@@ -353,9 +342,9 @@ class RelayWebSocketClient:self.paired_device_id = params.get("device_id")self.paired_device_name = params.get("device_name")- logger.info("[Relay] Android pairing restored (auto-reconnect)",- device_id=self.paired_device_id,- device_name=self.paired_device_name)+ logger.info(+ "[Relay] Android pairing restored (auto-reconnect)", device_id=self.paired_device_id, device_name=self.paired_device_name+ )await broadcast_connected(self.paired_device_id, self.paired_device_name)@@ -369,6 +358,7 @@ class RelayWebSocketClient:"""Save pairing session to database for auto-reconnect."""try:from services.plugin.deps import get_database+database = get_database()await database.save_android_relay_session(@@ -376,7 +366,7 @@ class RelayWebSocketClient:api_key=self.api_key,device_id=self.paired_device_id,device_name=self.paired_device_name,- session_token=self.session_token+ session_token=self.session_token,)logger.debug("[Relay] Pairing session saved for auto-reconnect")except Exception as e:@@ -396,11 +386,7 @@ class RelayWebSocketClient:self.paired_device_name = None# Broadcast device disconnection - relay is still connected, pass QR data for re-pairing- await broadcast_device_disconnected(- relay_connected=self.is_connected(),- qr_data=self.qr_data,- session_token=self.session_token- )+ await broadcast_device_disconnected(relay_connected=self.is_connected(), qr_data=self.qr_data, session_token=self.session_token)if self.on_pairing_disconnected:await self.on_pairing_disconnected(params)@@ -414,8 +400,7 @@ class RelayWebSocketClient:# Schema: params = {"data": {...}}data = params.get("data", {})- logger.debug("[Relay] relay.message received",- data_keys=list(data.keys()) if isinstance(data, dict) else "not_dict")+ logger.debug("[Relay] relay.message received", data_keys=list(data.keys()) if isinstance(data, dict) else "not_dict")# Route to service response queue if matching request_id# Android app uses "request_id" (underscore), not "requestId" (camelCase)@@ -505,7 +490,7 @@ class RelayWebSocketClient:action: str,parameters: Dict[str, Any] = None,target_id: Optional[str] = None, # Ignored, kept for compatibility- timeout: float = 30.0+ timeout: float = 30.0,) -> Optional[Dict[str, Any]]:"""Send service request to paired Android device.@@ -535,17 +520,11 @@ class RelayWebSocketClient:# - action# - request_id (not requestId)# - params (not parameters)- await self.relay_send({- "service": service_id,- "action": action,- "request_id": request_id,- "params": parameters or {}- }, timeout=5.0)-- logger.debug("[Relay] Sent service request",- request_id=request_id,- service_id=service_id,- action=action)+ await self.relay_send(+ {"service": service_id, "action": action, "request_id": request_id, "params": parameters or {}}, timeout=5.0+ )++ logger.debug("[Relay] Sent service request", request_id=request_id, service_id=service_id, action=action)# Wait for responselogger.debug("[Relay] Waiting for response", request_id=request_id, timeout=timeout)@@ -554,7 +533,9 @@ class RelayWebSocketClient:return responseexcept asyncio.TimeoutError:- logger.warning("[Relay] Service response timeout", request_id=request_id, timeout=timeout, pending_queues=list(self._service_queues.keys()))+ logger.warning(+ "[Relay] Service response timeout", request_id=request_id, timeout=timeout, pending_queues=list(self._service_queues.keys())+ )return Noneexcept Exception as e:logger.error("[Relay] Service request error", error=str(e))diff --git a/server/nodes/android/_relay/manager.py b/server/nodes/android/_relay/manager.pyindex 6dbd197d..7955f40e 100644--- a/server/nodes/android/_relay/manager.py+++ b/server/nodes/android/_relay/manager.py@@ -4,6 +4,7 @@ Android Relay Client ManagerGlobal instance management for persistent WebSocket connection.Provides singleton pattern for reusing connection across API requests."""+from typing import Optionalimport structlogdiff --git a/server/nodes/android/_relay/protocol.py b/server/nodes/android/_relay/protocol.pyindex f773aa85..bfedf745 100644--- a/server/nodes/android/_relay/protocol.py+++ b/server/nodes/android/_relay/protocol.py@@ -15,6 +15,7 @@ Error codes:- -32002: Pairing failed- -32003: Relay error"""+import asynciofrom dataclasses import dataclass, fieldfrom typing import Dict, Any, Optional@@ -23,6 +24,7 @@ from enum import Enumclass RPCErrorCode(Enum):"""JSON-RPC 2.0 error codes"""+INVALID_REQUEST = -32600METHOD_NOT_FOUND = -32601INVALID_PARAMS = -32602@@ -34,6 +36,7 @@ class RPCErrorCode(Enum):@dataclassclass RPCRequest:"""JSON-RPC 2.0 request"""+method: strparams: Dict[str, Any] = field(default_factory=dict)id: Optional[int] = None@@ -52,6 +55,7 @@ class RPCRequest:@dataclassclass RPCResponse:"""JSON-RPC 2.0 response"""+id: intresult: Optional[Any] = Noneerror: Optional[Dict[str, Any]] = None@@ -72,6 +76,7 @@ class RPCResponse:@dataclassclass RPCEvent:"""JSON-RPC 2.0 server event (notification without id)"""+method: strparams: Dict[str, Any] = field(default_factory=dict)@@ -142,6 +147,7 @@ class RPCRequestTracker:class RPCError(Exception):"""JSON-RPC error"""+def __init__(self, message: str, code: int = None):super().__init__(message)self.code = codediff --git a/server/nodes/android/_router.py b/server/nodes/android/_router.pyindex 20152e4c..d498028d 100644--- a/server/nodes/android/_router.py+++ b/server/nodes/android/_router.py@@ -30,6 +30,7 @@ def _validate_device_id(device_id: str) -> str:class AndroidServiceRequest(BaseModel):"""Request model for Android service execution."""+service_id: str = Field(..., description="Android service ID (e.g., 'battery', 'network', 'app_launcher')")action: str = Field(..., description="Service action to perform (e.g., 'status', 'launch', 'list')")parameters: Dict[str, Any] = Field(default_factory=dict, description="Action-specific parameters")@@ -38,10 +39,7 @@ class AndroidServiceRequest(BaseModel):@router.post("/execute")-async def execute_android_service(- request: AndroidServiceRequest,- android_service: AndroidService = Depends(get_android_service)-):+async def execute_android_service(request: AndroidServiceRequest, android_service: AndroidService = Depends(get_android_service)):"""Execute an Android system service action.Examples:@@ -54,7 +52,7 @@ async def execute_android_service(service_id=request.service_id,action=request.action,android_host=request.android_host,- android_port=request.android_port+ android_port=request.android_port,)result = await android_service.execute_service(@@ -63,7 +61,7 @@ async def execute_android_service(action=request.action,parameters=request.parameters,android_host=request.android_host,- android_port=request.android_port+ android_port=request.android_port,)return result@@ -71,30 +69,18 @@ async def execute_android_service(@router.get("/status")async def check_device_status(- android_host: str = "localhost",- android_port: int = 8888,- android_service: AndroidService = Depends(get_android_service)+ android_host: str = "localhost", android_port: int = 8888, android_service: AndroidService = Depends(get_android_service)):"""Check if Android device API is reachable."""- logger.info(- "[Android API] Checking device status",- android_host=android_host,- android_port=android_port- )+ logger.info("[Android API] Checking device status", android_host=android_host, android_port=android_port)- status = await android_service.check_device_status(- android_host=android_host,- android_port=android_port- )+ status = await android_service.check_device_status(android_host=android_host, android_port=android_port)return status@router.get("/services/{service_id}/actions")-async def get_service_actions(- service_id: str,- android_service: AndroidService = Depends(get_android_service)-):+async def get_service_actions(service_id: str, android_service: AndroidService = Depends(get_android_service)):"""Get available actions for a specific Android service.Returns list of action options that can be performed on the service.@@ -104,25 +90,13 @@ async def get_service_actions(actions = android_service.get_service_actions(service_id)if not actions:- return {- "success": False,- "error": f"Unknown service: {service_id}",- "actions": []- }+ return {"success": False, "error": f"Unknown service: {service_id}", "actions": []}- return {- "success": True,- "service_id": service_id,- "actions": actions- }+ return {"success": True, "service_id": service_id, "actions": actions}@router.get("/services/{service_id}/actions/{action}/parameters")-async def get_action_parameters(- service_id: str,- action: str,- android_service: AndroidService = Depends(get_android_service)-):+async def get_action_parameters(service_id: str, action: str, android_service: AndroidService = Depends(get_android_service)):"""Get default parameters for a specific service action.Returns default parameter template that can be used as a starting point.@@ -131,31 +105,20 @@ async def get_action_parameters(default_params = android_service.get_default_parameters(service_id, action)- return {- "success": True,- "service_id": service_id,- "action": action,- "default_parameters": default_params- }+ return {"success": True, "service_id": service_id, "action": action, "default_parameters": default_params}@router.get("/devices")async def list_android_devices():"""List all connected Android devices via ADB."""import subprocess+try:# Run adb devices command- result = subprocess.run(- ["adb", "devices", "-l"],- capture_output=True,- text=True,- encoding="utf-8",- errors="replace",- timeout=5- )+ result = subprocess.run(["adb", "devices", "-l"], capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=5)devices = []- lines = result.stdout.strip().split('\n')[1:] # Skip header "List of devices attached"+ lines = result.stdout.strip().split("\n")[1:] # Skip header "List of devices attached"for line in lines:if not line.strip():@@ -176,97 +139,56 @@ async def list_android_devices():elif part.startswith("device:"):pass # Can use this for device codename- devices.append({- "id": device_id,- "state": state,- "model": model,- "android_version": android_version- })-- return {- "success": True,- "devices": devices,- "count": len(devices)- }+ devices.append({"id": device_id, "state": state, "model": model, "android_version": android_version})++ return {"success": True, "devices": devices, "count": len(devices)}except FileNotFoundError:logger.error("[Android] ADB not found in PATH")- return {- "success": False,- "error": "ADB not found. Please install Android SDK Platform Tools",- "devices": []- }+ return {"success": False, "error": "ADB not found. Please install Android SDK Platform Tools", "devices": []}except Exception as e:logger.error(f"[Android] Failed to list devices: {e}")- return {- "success": False,- "error": str(e),- "devices": []- }+ return {"success": False, "error": str(e), "devices": []}@router.post("/port-forward")-async def setup_port_forwarding(- device_id: str,- local_port: int = 8888,- device_port: int = 8888-):+async def setup_port_forwarding(device_id: str, local_port: int = 8888, device_port: int = 8888):"""Setup ADB port forwarding for Android device communication."""device_id = _validate_device_id(device_id)import subprocess+try:# Setup port forwarding: adb -s device_id forward tcp:local_port tcp:device_port# device_id passes _DEVICE_ID_PATTERN above; subprocess.run is called# with an argv list (no shell), so no further interpolation risk.cmd = ["adb", "-s", device_id, "forward", f"tcp:{local_port}", f"tcp:{device_port}"]- result = subprocess.run(- cmd,- capture_output=True,- text=True,- encoding="utf-8",- errors="replace",- timeout=5- )+ result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=5)if result.returncode == 0:- logger.info(- f"[Android] Port forwarding setup: {device_id} tcp:{local_port} -> tcp:{device_port}"- )+ logger.info(f"[Android] Port forwarding setup: {device_id} tcp:{local_port} -> tcp:{device_port}")return {"success": True,"device_id": device_id,"local_port": local_port,"device_port": device_port,- "message": f"Port forwarding active: localhost:{local_port} -> device:{device_port}"+ "message": f"Port forwarding active: localhost:{local_port} -> device:{device_port}",}else:error_msg = result.stderr.strip() or result.stdout.strip()logger.error(f"[Android] Port forwarding failed: {error_msg}")- return {- "success": False,- "error": error_msg- }+ return {"success": False, "error": error_msg}except FileNotFoundError:logger.error("[Android] ADB not found in PATH")- return {- "success": False,- "error": "ADB not found. Please install Android SDK Platform Tools"- }+ return {"success": False, "error": "ADB not found. Please install Android SDK Platform Tools"}except Exception as e:logger.error(f"[Android] Port forwarding error: {e}")- return {- "success": False,- "error": str(e)- }+ return {"success": False, "error": str(e)}@router.get("/health")async def android_health_check():"""Android service health check."""- return {- "status": "OK",- "service": "android"- }+ return {"status": "OK", "service": "android"}@router.get("/relay-status")@@ -291,7 +213,7 @@ async def get_relay_connection_status():"device_name": relay_client.paired_device_name,"session_token": relay_client.session_token,"qr_data": relay_client.qr_data if not relay_client.is_paired() else None,- "status": "paired" if relay_client.is_paired() else "waiting_for_pairing"+ "status": "paired" if relay_client.is_paired() else "waiting_for_pairing",}else:return {@@ -301,13 +223,8 @@ async def get_relay_connection_status():"connection_type": None,"device_id": None,"device_name": None,- "status": "disconnected"+ "status": "disconnected",}except Exception as e:logger.error(f"[Android] Failed to get relay status: {e}")- return {- "success": False,- "connected": False,- "error": str(e),- "status": "error"- }+ return {"success": False, "connected": False, "error": str(e), "status": "error"}diff --git a/server/nodes/browser/_install.py b/server/nodes/browser/_install.pyindex f75b7860..c16aadda 100644--- a/server/nodes/browser/_install.py+++ b/server/nodes/browser/_install.py@@ -39,7 +39,8 @@ def agent_browser_binary_path() -> Optional[str]:npm_root.mkdir(parents=True, exist_ok=True)result = subprocess.run([npm_cmd, "install", _NPM_SPEC, "--prefix", str(npm_root), "--no-audit", "--no-fund"],- capture_output=True, text=True,+ capture_output=True,+ text=True,)if result.returncode != 0 or not bin_path.exists():logger.error("[browser] npm install failed: %s", result.stderr.strip())@@ -49,7 +50,8 @@ def agent_browser_binary_path() -> Optional[str]:# post-install step — downloads ~150MB chromium on first use).runtime = subprocess.run([str(bin_path), "install"],- capture_output=True, text=True,+ capture_output=True,+ text=True,)if runtime.returncode != 0:logger.warning("[browser] chromium runtime install failed: %s", runtime.stderr.strip())diff --git a/server/nodes/browser/_service.py b/server/nodes/browser/_service.pyindex c5d17a3b..4b910d27 100644--- a/server/nodes/browser/_service.py+++ b/server/nodes/browser/_service.py@@ -67,7 +67,8 @@ class BrowserService:"""argv = [*self._prefix,- "--session", session,+ "--session",+ session,"--json",]if headed:diff --git a/server/nodes/browser/browser/__init__.py b/server/nodes/browser/browser/__init__.pyindex 0e13c6c9..291f106c 100644--- a/server/nodes/browser/browser/__init__.py+++ b/server/nodes/browser/browser/__init__.py@@ -45,6 +45,7 @@ def _find_browser_via_registry(exe_name: str) -> Optional[str]:"""try:import winreg+for hive in (winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER):try:key = winreg.OpenKey(@@ -152,15 +153,24 @@ class BrowserParams(BaseModel):"""operation: Literal[- "navigate", "click", "type", "fill", "screenshot", "snapshot",- "get_text", "get_html", "eval", "wait", "scroll", "select",- "console", "errors", "batch",+ "navigate",+ "click",+ "type",+ "fill",+ "screenshot",+ "snapshot",+ "get_text",+ "get_html",+ "eval",+ "wait",+ "scroll",+ "select",+ "console",+ "errors",+ "batch",] = Field(default="navigate",- description=(- "Browser operation. Typical flow: navigate -> snapshot -> "- "interact using @eN refs -> snapshot."- ),+ description=("Browser operation. Typical flow: navigate -> snapshot -> " "interact using @eN refs -> snapshot."),)# Operation-scoped fields@@ -173,9 +183,19 @@ class BrowserParams(BaseModel):default="",description="CSS selector or @eN ref from snapshot.",json_schema_extra={- "displayOptions": {"show": {"operation": [- "click", "type", "fill", "get_text", "get_html", "wait", "select",- ]}},+ "displayOptions": {+ "show": {+ "operation": [+ "click",+ "type",+ "fill",+ "get_text",+ "get_html",+ "wait",+ "select",+ ]+ }+ },},)text: str = Field(@@ -201,7 +221,9 @@ class BrowserParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"operation": ["scroll"]}}},)amount: int = Field(- default=500, ge=1, le=20000,+ default=500,+ ge=1,+ le=20000,description="Pixels to scroll.",json_schema_extra={"displayOptions": {"show": {"operation": ["scroll"]}}},)@@ -230,12 +252,17 @@ class BrowserParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"operation": ["screenshot"]}}},)screenshot_quality: int = Field(- default=85, ge=1, le=100,+ default=85,+ ge=1,+ le=100,description="JPEG quality (1-100).",json_schema_extra={- "displayOptions": {"show": {- "operation": ["screenshot"], "screenshot_format": ["jpeg"],- }},+ "displayOptions": {+ "show": {+ "operation": ["screenshot"],+ "screenshot_format": ["jpeg"],+ }+ },},)@@ -279,11 +306,15 @@ class BrowserParams(BaseModel):description="Proxy URL (e.g. http://user:pass@host:port).",)action_delay: int = Field(- default=0, ge=0, le=60000,+ default=0,+ ge=0,+ le=60000,description="Delay before each action in milliseconds (for stealth).",)timeout: int = Field(- default=30, ge=1, le=600,+ default=30,+ ge=1,+ le=600,description="Per-action timeout in seconds.",)@@ -329,10 +360,7 @@ class BrowserNode(ActionNode):)op = params.operation- session = (- params.session.strip()- or f"machina_{ctx.raw.get('execution_id', 'default')}"- )+ session = params.session.strip() or f"machina_{ctx.raw.get('execution_id', 'default')}"timeout = params.timeoutbrowser_sel = params.browser or "chrome"if browser_sel == "bundled":@@ -357,7 +385,9 @@ class BrowserNode(ActionNode):if op == "batch":cmds = json.loads(params.commands or "[]")data = await svc.run(- ["batch", "--json"], session, timeout,+ ["batch", "--json"],+ session,+ timeout,stdin=json.dumps(cmds).encode(),**run_kw,)diff --git a/server/nodes/chat/chat_history/__init__.py b/server/nodes/chat/chat_history/__init__.pyindex ef317108..9b84dff8 100644--- a/server/nodes/chat/chat_history/__init__.py+++ b/server/nodes/chat/chat_history/__init__.py@@ -38,10 +38,8 @@ class ChatHistoryNode(ActionNode):description = "Retrieve chat conversation history"component_kind = "square"handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": True, "open_world": True}task_queue = TaskQueue.DEFAULTdiff --git a/server/nodes/chat/chat_send/__init__.py b/server/nodes/chat/chat_send/__init__.pyindex 8adc68c5..226a1b81 100644--- a/server/nodes/chat/chat_send/__init__.py+++ b/server/nodes/chat/chat_send/__init__.py@@ -42,10 +42,8 @@ class ChatSendNode(ActionNode):description = "Send messages to chat conversations"component_kind = "square"handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}task_queue = TaskQueue.DEFAULTdiff --git a/server/nodes/code/javascript_executor/__init__.py b/server/nodes/code/javascript_executor/__init__.pyindex 32d16104..5991452b 100644--- a/server/nodes/code/javascript_executor/__init__.py+++ b/server/nodes/code/javascript_executor/__init__.py@@ -50,9 +50,7 @@ class JavaScriptExecutorNode(CodeExecutorBase):) from excif not result.get("success"):- raise NodeUserError(- result.get("error") or "JavaScript executor failed"- )+ raise NodeUserError(result.get("error") or "JavaScript executor failed")return {"output": result.get("output"),"console_output": result.get("console_output", ""),diff --git a/server/nodes/code/python_executor/__init__.py b/server/nodes/code/python_executor/__init__.pyindex 5146fe9c..e4522085 100644--- a/server/nodes/code/python_executor/__init__.py+++ b/server/nodes/code/python_executor/__init__.py@@ -12,9 +12,7 @@ from .._base import CodeExecutorBase, CodeExecutorParams# Names available in the sandbox namespace -- kept here so the# error-handler can list them when the LLM tries `import X` and hits# the "no __import__" wall.-_SANDBOX_NAMES = (- "math, json, datetime, timedelta, re, random, Counter, defaultdict"-)+_SANDBOX_NAMES = "math, json, datetime, timedelta, re, random, Counter, defaultdict"class PythonExecutorNode(CodeExecutorBase):@@ -54,13 +52,33 @@ class PythonExecutorNode(CodeExecutorBase):print(*args, **kwargs)safe_builtins = {- "abs": abs, "all": all, "any": any, "bool": bool,- "dict": dict, "enumerate": enumerate, "filter": filter,- "float": float, "int": int, "len": len, "list": list,- "map": map, "max": max, "min": min, "print": captured_print,- "range": range, "round": round, "set": set, "sorted": sorted,- "str": str, "sum": sum, "tuple": tuple, "type": type, "zip": zip,- "True": True, "False": False, "None": None,+ "abs": abs,+ "all": all,+ "any": any,+ "bool": bool,+ "dict": dict,+ "enumerate": enumerate,+ "filter": filter,+ "float": float,+ "int": int,+ "len": len,+ "list": list,+ "map": map,+ "max": max,+ "min": min,+ "print": captured_print,+ "range": range,+ "round": round,+ "set": set,+ "sorted": sorted,+ "str": str,+ "sum": sum,+ "tuple": tuple,+ "type": type,+ "zip": zip,+ "True": True,+ "False": False,+ "None": None,# Pre-injected modules — match the documented sandbox contract# (skill docs, CLAUDE.md). No __import__: callers reference these# by name, e.g. ``datetime.datetime.now()`` not ``import datetime``.@@ -115,9 +133,7 @@ class PythonExecutorNode(CodeExecutorBase):captured = stdout_capture.getvalue()suffix = f"\n\nstdout before error:\n{captured}" if captured else ""- raise NodeUserError(- f"{err_type}{line_info}: {err_msg}{suffix}"- ) from exc+ raise NodeUserError(f"{err_type}{line_info}: {err_msg}{suffix}") from excreturn {"output": namespace.get("output"),diff --git a/server/nodes/code/typescript_executor/__init__.py b/server/nodes/code/typescript_executor/__init__.pyindex f6f79189..0fe0d182 100644--- a/server/nodes/code/typescript_executor/__init__.py+++ b/server/nodes/code/typescript_executor/__init__.py@@ -46,9 +46,7 @@ class TypeScriptExecutorNode(CodeExecutorBase):) from excif not result.get("success"):- raise NodeUserError(- result.get("error") or "TypeScript executor failed"- )+ raise NodeUserError(result.get("error") or "TypeScript executor failed")return {"output": result.get("output"),"console_output": result.get("console_output", ""),diff --git a/server/nodes/document/document_parser/__init__.py b/server/nodes/document/document_parser/__init__.pyindex 5dc7cf53..021407a7 100644--- a/server/nodes/document/document_parser/__init__.py+++ b/server/nodes/document/document_parser/__init__.py@@ -16,24 +16,28 @@ logger = get_logger(__name__)def _parse_file_sync(path: Path, parser: str) -> str:"""Synchronous file parsing — runs in thread pool."""- if parser == 'pypdf':+ if parser == "pypdf":from pypdf import PdfReader- return "\n\n".join(p.extract_text() or '' for p in PdfReader(str(path)).pages)- if parser == 'marker':++ return "\n\n".join(p.extract_text() or "" for p in PdfReader(str(path)).pages)+ if parser == "marker":from marker.converters.pdf import PdfConverterfrom marker.models import create_model_dict+converter = PdfConverter(artifact_dict=create_model_dict())result = converter(str(path))- return result.markdown if hasattr(result, 'markdown') else str(result)- if parser == 'unstructured':+ return result.markdown if hasattr(result, "markdown") else str(result)+ if parser == "unstructured":from unstructured.partition.auto import partition+return "\n\n".join(str(el) for el in partition(str(path)))- if parser == 'beautifulsoup':+ if parser == "beautifulsoup":from bs4 import BeautifulSoup- soup = BeautifulSoup(path.read_text(errors='ignore'), 'html.parser')++ soup = BeautifulSoup(path.read_text(errors="ignore"), "html.parser")for s in soup(["script", "style"]):s.decompose()- return soup.get_text(separator='\n')+ return soup.get_text(separator="\n")raise ValueError(f"Unknown parser: {parser}")@@ -88,7 +92,7 @@ class DocumentParserNode(ActionNode):parser = params.parserexplicit_path = params.file_pathinput_dir = params.input_dir- file_pattern = params.file_pattern or '*.pdf'+ file_pattern = params.file_pattern or "*.pdf"paths: list[Path] = []if explicit_path:@@ -103,13 +107,20 @@ class DocumentParserNode(ActionNode):for path in paths:try:content = await asyncio.to_thread(_parse_file_sync, path, parser)- documents.append({- 'source': str(path), 'filename': path.name,- 'content': content, 'length': len(content), 'parser': parser,- })+ documents.append(+ {+ "source": str(path),+ "filename": path.name,+ "content": content,+ "length": len(content),+ "parser": parser,+ }+ )except Exception as e:- failed.append({'file': str(path), 'error': str(e)})+ failed.append({"file": str(path), "error": str(e)})return DocumentParserOutput(- documents=documents, parsed_count=len(documents), failed=failed,+ documents=documents,+ parsed_count=len(documents),+ failed=failed,)diff --git a/server/nodes/document/embedding_generator/__init__.py b/server/nodes/document/embedding_generator/__init__.pyindex aacdf68d..783c33f3 100644--- a/server/nodes/document/embedding_generator/__init__.py+++ b/server/nodes/document/embedding_generator/__init__.py@@ -21,7 +21,9 @@ class EmbeddingGeneratorParams(BaseModel):description="Model name (provider-specific). HuggingFace: BAAI/bge-*. OpenAI: text-embedding-3-small.",)batch_size: int = Field(- default=32, ge=1, le=256,+ default=32,+ ge=1,+ le=256,description="Number of texts per embedding batch.",)api_key: str = Field(@@ -73,26 +75,31 @@ class EmbeddingGeneratorNode(ActionNode):if not chunks:return EmbeddingGeneratorOutput(- embeddings=[], embedding_count=0, dimensions=0, chunks=[],- provider=provider, model=model,+ embeddings=[],+ embedding_count=0,+ dimensions=0,+ chunks=[],+ provider=provider,+ model=model,)- texts = [c.get('content', '') if isinstance(c, dict) else str(c) for c in chunks]+ texts = [c.get("content", "") if isinstance(c, dict) else str(c) for c in chunks]- if provider == 'huggingface':+ if provider == "huggingface":try:from langchain_huggingface import HuggingFaceEmbeddingsexcept ImportError:raise NodeUserError(- "HuggingFace embeddings unavailable. "- "pip install langchain-huggingface sentence-transformers",+ "HuggingFace embeddings unavailable. " "pip install langchain-huggingface sentence-transformers",)embedder = HuggingFaceEmbeddings(model_name=model)- elif provider == 'openai':+ elif provider == "openai":from langchain_openai import OpenAIEmbeddings+embedder = OpenAIEmbeddings(model=model, api_key=api_key)- elif provider == 'ollama':+ elif provider == "ollama":from langchain_ollama import OllamaEmbeddings+embedder = OllamaEmbeddings(model=model)else:raise NodeUserError(f"Unknown provider: {provider}")diff --git a/server/nodes/document/file_downloader/__init__.py b/server/nodes/document/file_downloader/__init__.pyindex b7b250ef..9c42b377 100644--- a/server/nodes/document/file_downloader/__init__.py+++ b/server/nodes/document/file_downloader/__init__.py@@ -56,17 +56,21 @@ class FileDownloaderNode(ActionNode):@Operation("download")async def download(self, ctx: NodeContext, params: FileDownloaderParams) -> FileDownloaderOutput:p = params.model_dump()- items = p.get('items') or [{'url': u} for u in p.get('urls', [])]- workspace_dir = ctx.raw.get('workspace_dir', '')- default_dir = str(Path(workspace_dir) / 'downloads') if workspace_dir else p.get('outputDir', 'downloads')- output_dir = Path(p.get('outputDir') or default_dir)- max_workers = int(p.get('maxWorkers', 8))- skip_existing = p.get('skipExisting', True)- timeout = float(p.get('timeout', 60))+ items = p.get("items") or [{"url": u} for u in p.get("urls", [])]+ workspace_dir = ctx.raw.get("workspace_dir", "")+ default_dir = str(Path(workspace_dir) / "downloads") if workspace_dir else p.get("outputDir", "downloads")+ output_dir = Path(p.get("outputDir") or default_dir)+ max_workers = int(p.get("maxWorkers", 8))+ skip_existing = p.get("skipExisting", True)+ timeout = float(p.get("timeout", 60))if not items:return FileDownloaderOutput(- downloaded=0, skipped=0, failed=0, files=[], output_dir=str(output_dir),+ downloaded=0,+ skipped=0,+ failed=0,+ files=[],+ output_dir=str(output_dir),)output_dir.mkdir(parents=True, exist_ok=True)@@ -74,38 +78,44 @@ class FileDownloaderNode(ActionNode):async def dl(item):async with semaphore:- url = item.get('url', '') if isinstance(item, dict) else str(item)+ url = item.get("url", "") if isinstance(item, dict) else str(item)if not url:- return {'status': 'failed', 'error': 'Empty URL'}- filename = unquote(Path(urlparse(url).path).name or 'download')+ return {"status": "failed", "error": "Empty URL"}+ filename = unquote(Path(urlparse(url).path).name or "download")file_path = output_dir / filenameif skip_existing and file_path.exists():- return {'status': 'skipped', 'path': str(file_path), 'url': url}+ return {"status": "skipped", "path": str(file_path), "url": url}try:async with httpx.AsyncClient(timeout=timeout, follow_redirects=True) as client:resp = await client.get(url)resp.raise_for_status()file_path.write_bytes(resp.content)return {- 'status': 'downloaded', 'path': str(file_path),- 'url': url, 'size': len(resp.content), 'filename': filename,+ "status": "downloaded",+ "path": str(file_path),+ "url": url,+ "size": len(resp.content),+ "filename": filename,}except Exception as e:- return {'status': 'failed', 'url': url, 'error': str(e)}+ return {"status": "failed", "url": url, "error": str(e)}results = await asyncio.gather(*[dl(i) for i in items], return_exceptions=True)downloaded, skipped, failed = [], [], []for r in results:if isinstance(r, Exception):- failed.append({'error': str(r)})- elif r.get('status') == 'downloaded':+ failed.append({"error": str(r)})+ elif r.get("status") == "downloaded":downloaded.append(r)- elif r.get('status') == 'skipped':+ elif r.get("status") == "skipped":skipped.append(r)else:failed.append(r)return FileDownloaderOutput(- downloaded=len(downloaded), skipped=len(skipped), failed=len(failed),- files=downloaded, output_dir=str(output_dir),+ downloaded=len(downloaded),+ skipped=len(skipped),+ failed=len(failed),+ files=downloaded,+ output_dir=str(output_dir),)diff --git a/server/nodes/document/http_scraper/__init__.py b/server/nodes/document/http_scraper/__init__.pyindex 84ecd5fa..51ef0b01 100644--- a/server/nodes/document/http_scraper/__init__.py+++ b/server/nodes/document/http_scraper/__init__.py@@ -58,17 +58,21 @@ class HttpScraperParams(BaseModel):# Page-mode fieldsstart_page: int = Field(- default=1, ge=1,+ default=1,+ ge=1,description="First page number.",json_schema_extra={"displayOptions": {"show": {"iteration_mode": ["page"]}}},)end_page: int = Field(- default=10, ge=1,+ default=10,+ ge=1,description="Last page number (inclusive).",json_schema_extra={"displayOptions": {"show": {"iteration_mode": ["page"]}}},)max_pages: int = Field(- default=10, ge=1, le=1000,+ default=10,+ ge=1,+ le=1000,description="Safety cap on pages fetched.",)@@ -92,7 +96,8 @@ class HttpScraperParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"use_proxy": [True]}}},)sticky_duration: int = Field(- default=600, ge=1,+ default=600,+ ge=1,json_schema_extra={"displayOptions": {"show": {"use_proxy": [True], "session_type": ["sticky"]}},},@@ -134,26 +139,28 @@ class HttpScraperNode(ActionNode):iteration_mode = params.iteration_modelink_selector = params.link_selector or 'a[href$=".pdf"]'- headers_str = params.headers or '{}'+ headers_str = params.headers or "{}"headers = json.loads(headers_str) if isinstance(headers_str, str) and headers_str else {}urls_to_fetch = []- if iteration_mode == 'date':+ if iteration_mode == "date":if not params.start_date or not params.end_date:raise NodeUserError("start_date/end_date required for date mode")- placeholder = params.date_placeholder or '{date}'+ placeholder = params.date_placeholder or "{date}"start = datetime.strptime(params.start_date, "%Y-%m-%d")end = datetime.strptime(params.end_date, "%Y-%m-%d")current = startwhile current <= end:- urls_to_fetch.append((- url.replace(placeholder, current.strftime("%Y-%m-%d")),- {'date': current.isoformat()},- ))+ urls_to_fetch.append(+ (+ url.replace(placeholder, current.strftime("%Y-%m-%d")),+ {"date": current.isoformat()},+ )+ )current += timedelta(days=1)- elif iteration_mode == 'page':+ elif iteration_mode == "page":for page in range(params.start_page, params.end_page + 1):- urls_to_fetch.append((url.replace('{page}', str(page)), {'page': page}))+ urls_to_fetch.append((url.replace("{page}", str(page)), {"page": page}))else:urls_to_fetch.append((url, {}))@@ -161,6 +168,7 @@ class HttpScraperNode(ActionNode):if params.use_proxy:try:from services.proxy.service import get_proxy_service+proxy_svc = get_proxy_service()if proxy_svc and proxy_svc.is_enabled():proxy_url = await proxy_svc.get_proxy_url(url, params.model_dump())@@ -177,16 +185,18 @@ class HttpScraperNode(ActionNode):try:response = await client.get(fetch_url, headers=headers)response.raise_for_status()- soup = BeautifulSoup(response.text, 'html.parser')+ soup = BeautifulSoup(response.text, "html.parser")for el in soup.select(link_selector):- href = el.get('href', '')+ href = el.get("href", "")if href:- items.append({- 'url': urljoin(fetch_url, href),- 'text': el.get_text(strip=True),- 'source_url': fetch_url,- **meta,- })+ items.append(+ {+ "url": urljoin(fetch_url, href),+ "text": el.get_text(strip=True),+ "source_url": fetch_url,+ **meta,+ }+ )except Exception as e:errors.append(f"{fetch_url}: {e}")diff --git a/server/nodes/document/text_chunker/__init__.py b/server/nodes/document/text_chunker/__init__.pyindex 1d00730d..8ff98bd1 100644--- a/server/nodes/document/text_chunker/__init__.py+++ b/server/nodes/document/text_chunker/__init__.py@@ -45,33 +45,38 @@ class TextChunkerNode(ActionNode):@Operation("chunk")async def chunk(self, ctx: NodeContext, params: TextChunkerParams) -> TextChunkerOutput:from langchain_text_splitters import (- MarkdownTextSplitter, RecursiveCharacterTextSplitter,+ MarkdownTextSplitter,+ RecursiveCharacterTextSplitter,)p = params.model_dump()- documents = p.get('documents') or ([{'content': p.get('text', '')}] if p.get('text') else [])- chunk_size = int(p.get('chunkSize', 1000))- chunk_overlap = int(p.get('chunkOverlap') or p.get('overlap', 200))- strategy = p.get('strategy', 'recursive')+ documents = p.get("documents") or ([{"content": p.get("text", "")}] if p.get("text") else [])+ chunk_size = int(p.get("chunkSize", 1000))+ chunk_overlap = int(p.get("chunkOverlap") or p.get("overlap", 200))+ strategy = p.get("strategy", "recursive")if not documents:return TextChunkerOutput(chunks=[], chunk_count=0)- if strategy == 'markdown':+ if strategy == "markdown":splitter = MarkdownTextSplitter(chunk_size=chunk_size, chunk_overlap=chunk_overlap)else:splitter = RecursiveCharacterTextSplitter(chunk_size=chunk_size, chunk_overlap=chunk_overlap)chunks = []for doc in documents:- content = doc.get('content', '') if isinstance(doc, dict) else str(doc)- source = doc.get('source', 'input') if isinstance(doc, dict) else 'input'+ content = doc.get("content", "") if isinstance(doc, dict) else str(doc)+ source = doc.get("source", "input") if isinstance(doc, dict) else "input"if not content:continuefor i, chunk_text in enumerate(splitter.split_text(content)):- chunks.append({- 'source': source, 'chunk_index': i,- 'content': chunk_text, 'length': len(chunk_text),- })+ chunks.append(+ {+ "source": source,+ "chunk_index": i,+ "content": chunk_text,+ "length": len(chunk_text),+ }+ )return TextChunkerOutput(chunks=chunks, chunk_count=len(chunks))diff --git a/server/nodes/document/vector_store/__init__.py b/server/nodes/document/vector_store/__init__.pyindex 47db7f57..1aad6ea3 100644--- a/server/nodes/document/vector_store/__init__.py+++ b/server/nodes/document/vector_store/__init__.py@@ -30,7 +30,9 @@ class VectorStoreParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"operation": ["query"]}}},)top_k: int = Field(- default=5, ge=1, le=100,+ default=5,+ ge=1,+ le=100,json_schema_extra={"displayOptions": {"show": {"operation": ["query"]}}},)ids: Optional[list] = Field(@@ -72,48 +74,51 @@ async def _chroma_op(operation: str, params: Dict[str, Any], collection: str) ->except ImportError:raise NodeUserError("ChromaDB unavailable. pip install chromadb")- persist_dir = params.get('persist_dir', './data/vectors')+ persist_dir = params.get("persist_dir", "./data/vectors")client = chromadb.PersistentClient(path=persist_dir)coll = client.get_or_create_collection(name=collection)- if operation == 'store':- embeddings = params.get('embeddings', [])- chunks = params.get('chunks', [])+ if operation == "store":+ embeddings = params.get("embeddings", [])+ chunks = params.get("chunks", [])if not embeddings:return {"stored_count": 0, "collection_count": coll.count()}ids = [str(uuid.uuid4()) for _ in embeddings]- docs = [c.get('content', '') if isinstance(c, dict) else str(c) for c in chunks]+ docs = [c.get("content", "") if isinstance(c, dict) else str(c) for c in chunks]while len(docs) < len(embeddings):- docs.append('')+ docs.append("")metas = [- {'source': c.get('source', 'unknown'), 'chunk_index': c.get('chunk_index', i)}- if isinstance(c, dict) else {'source': 'input', 'chunk_index': i}+ {"source": c.get("source", "unknown"), "chunk_index": c.get("chunk_index", i)}+ if isinstance(c, dict)+ else {"source": "input", "chunk_index": i}for i, c in enumerate(chunks)]while len(metas) < len(embeddings):- metas.append({'source': 'unknown', 'chunk_index': len(metas)})+ metas.append({"source": "unknown", "chunk_index": len(metas)})await asyncio.to_thread(coll.add, ids=ids, embeddings=embeddings, documents=docs, metadatas=metas)return {"stored_count": len(embeddings), "collection_count": coll.count()}- if operation == 'query':- query_emb = params.get('query_embedding', [])- top_k = int(params.get('top_k', 5))+ if operation == "query":+ query_emb = params.get("query_embedding", [])+ top_k = int(params.get("top_k", 5))if not query_emb:return {"matches": []}results = coll.query(query_embeddings=[query_emb], n_results=top_k)matches = []- if results['ids'] and results['ids'][0]:- for i in range(len(results['ids'][0])):- matches.append({- 'id': results['ids'][0][i],- 'document': results['documents'][0][i] if results['documents'] else '',- 'metadata': results['metadatas'][0][i] if results['metadatas'] else {},- 'distance': results['distances'][0][i] if results.get('distances') else None,- })+ if results["ids"] and results["ids"][0]:+ for i in range(len(results["ids"][0])):+ matches.append(+ {+ "id": results["ids"][0][i],+ "document": results["documents"][0][i] if results["documents"] else "",+ "metadata": results["metadatas"][0][i] if results["metadatas"] else {},+ "distance": results["distances"][0][i] if results.get("distances") else None,+ }+ )return {"matches": matches}- if operation == 'delete':- ids = params.get('ids', [])+ if operation == "delete":+ ids = params.get("ids", [])if ids:await asyncio.to_thread(coll.delete, ids=ids)return {"deleted": True, "count": len(ids)}@@ -128,12 +133,12 @@ async def _qdrant_op(operation: str, params: Dict[str, Any], collection: str) ->except ImportError:raise NodeUserError("Qdrant client unavailable. pip install qdrant-client")- url = params.get('qdrant_url', 'http://localhost:6333')+ url = params.get("qdrant_url", "http://localhost:6333")client = QdrantClient(url=url)- if operation == 'store':- embeddings = params.get('embeddings', [])- chunks = params.get('chunks', [])+ if operation == "store":+ embeddings = params.get("embeddings", [])+ chunks = params.get("chunks", [])if not embeddings:return {"stored_count": 0}vec_size = len(embeddings[0])@@ -150,32 +155,35 @@ async def _qdrant_op(operation: str, params: Dict[str, Any], collection: str) ->c = chunks[i]if isinstance(c, dict):payload = {- 'content': c.get('content', ''),- 'source': c.get('source', 'unknown'),- 'chunk_index': c.get('chunk_index', i),+ "content": c.get("content", ""),+ "source": c.get("source", "unknown"),+ "chunk_index": c.get("chunk_index", i),}else:- payload = {'content': str(c), 'source': 'input', 'chunk_index': i}+ payload = {"content": str(c), "source": "input", "chunk_index": i}points.append(PointStruct(id=str(uuid.uuid4()), vector=emb, payload=payload))await asyncio.to_thread(client.upsert, collection_name=collection, points=points)return {"stored_count": len(embeddings)}- if operation == 'query':- query_emb = params.get('query_embedding', [])- top_k = int(params.get('top_k', 5))+ if operation == "query":+ query_emb = params.get("query_embedding", [])+ top_k = int(params.get("top_k", 5))if not query_emb:return {"matches": []}results = await asyncio.to_thread(- client.search, collection_name=collection, query_vector=query_emb, limit=top_k,+ client.search,+ collection_name=collection,+ query_vector=query_emb,+ limit=top_k,)- return {"matches": [- {'id': str(r.id), 'document': r.payload.get('content', ''),- 'metadata': r.payload, 'score': r.score}- for r in results- ]}-- if operation == 'delete':- ids = params.get('ids', [])+ return {+ "matches": [+ {"id": str(r.id), "document": r.payload.get("content", ""), "metadata": r.payload, "score": r.score} for r in results+ ]+ }++ if operation == "delete":+ ids = params.get("ids", [])if ids:await asyncio.to_thread(client.delete, collection_name=collection, points_selector=ids)return {"deleted": True, "count": len(ids)}@@ -186,16 +194,16 @@ async def _qdrant_op(operation: str, params: Dict[str, Any], collection: str) ->async def _pinecone_op(operation: str, params: Dict[str, Any], collection: str) -> Dict[str, Any]:from pinecone import Pinecone- api_key = params.get('pinecone_api_key', '')+ api_key = params.get("pinecone_api_key", "")if not api_key:raise NodeUserError("Pinecone API key required")pc = Pinecone(api_key=api_key)index = pc.Index(collection)- if operation == 'store':- embeddings = params.get('embeddings', [])- chunks = params.get('chunks', [])+ if operation == "store":+ embeddings = params.get("embeddings", [])+ chunks = params.get("chunks", [])if not embeddings:return {"stored_count": 0}vectors = []@@ -205,33 +213,41 @@ async def _pinecone_op(operation: str, params: Dict[str, Any], collection: str)c = chunks[i]if isinstance(c, dict):meta = {- 'content': c.get('content', ''),- 'source': c.get('source', 'unknown'),- 'chunk_index': c.get('chunk_index', i),+ "content": c.get("content", ""),+ "source": c.get("source", "unknown"),+ "chunk_index": c.get("chunk_index", i),}else:- meta = {'content': str(c), 'source': 'input', 'chunk_index': i}- vectors.append({'id': str(uuid.uuid4()), 'values': emb, 'metadata': meta})+ meta = {"content": str(c), "source": "input", "chunk_index": i}+ vectors.append({"id": str(uuid.uuid4()), "values": emb, "metadata": meta})await asyncio.to_thread(index.upsert, vectors=vectors)return {"stored_count": len(embeddings)}- if operation == 'query':- query_emb = params.get('query_embedding', [])- top_k = int(params.get('top_k', 5))+ if operation == "query":+ query_emb = params.get("query_embedding", [])+ top_k = int(params.get("top_k", 5))if not query_emb:return {"matches": []}results = await asyncio.to_thread(- index.query, vector=query_emb, top_k=top_k, include_metadata=True,+ index.query,+ vector=query_emb,+ top_k=top_k,+ include_metadata=True,)- return {"matches": [- {'id': m.id,- 'document': m.metadata.get('content', '') if m.metadata else '',- 'metadata': m.metadata or {}, 'score': m.score}- for m in results.matches- ]}-- if operation == 'delete':- ids = params.get('ids', [])+ return {+ "matches": [+ {+ "id": m.id,+ "document": m.metadata.get("content", "") if m.metadata else "",+ "metadata": m.metadata or {},+ "score": m.score,+ }+ for m in results.matches+ ]+ }++ if operation == "delete":+ ids = params.get("ids", [])if ids:await asyncio.to_thread(index.delete, ids=ids)return {"deleted": True, "count": len(ids)}@@ -261,19 +277,19 @@ class VectorStoreNode(ActionNode):p = params.model_dump()operation = params.operationbackend_raw = params.backend- backend = 'chroma' if backend_raw in ('chroma', 'chromadb') else backend_raw+ backend = "chroma" if backend_raw in ("chroma", "chromadb") else backend_rawcollection = params.collection_name- if backend == 'chroma':+ if backend == "chroma":result = await _chroma_op(operation, p, collection)- elif backend == 'qdrant':+ elif backend == "qdrant":result = await _qdrant_op(operation, p, collection)- elif backend == 'pinecone':+ elif backend == "pinecone":result = await _pinecone_op(operation, p, collection)else:raise NodeUserError(f"Unknown backend: {backend_raw}")- result['backend'] = backend- result['collection_name'] = collection- result['operation'] = operation+ result["backend"] = backend+ result["collection_name"] = collection+ result["operation"] = operationreturn VectorStoreOutput(**result)diff --git a/server/nodes/email/_filters.py b/server/nodes/email/_filters.pyindex 28086ae5..98fa9c9a 100644--- a/server/nodes/email/_filters.py+++ b/server/nodes/email/_filters.py@@ -10,11 +10,11 @@ from typing import Callable, Dictdef build_filter(params: Dict) -> Callable[[Dict], bool]:"""Build filter for email events (Himalaya IMAP polling)."""- folder_filter = params.get('folder', 'INBOX')+ folder_filter = params.get("folder", "INBOX")def matches(data: Dict) -> bool:- if folder_filter and folder_filter != 'all':- if data.get('folder', '') != folder_filter:+ if folder_filter and folder_filter != "all":+ if data.get("folder", "") != folder_filter:return Falsereturn Truediff --git a/server/nodes/email/_himalaya.py b/server/nodes/email/_himalaya.pyindex 044d15c4..8c2db956 100644--- a/server/nodes/email/_himalaya.py+++ b/server/nodes/email/_himalaya.py@@ -60,35 +60,39 @@ class HimalayaService(ServiceSingleton):smtp_encryption = credentials.get("smtp_encryption", "tls")lines = [- f'[accounts.{account_name}]',+ f"[accounts.{account_name}]",f'email = "{email}"',]if display_name:lines.append(f'display-name = "{display_name}"')# IMAP backend- lines.extend([- '',- 'backend.type = "imap"',- f'backend.host = "{imap_host}"',- f'backend.port = {imap_port}',- f'backend.encryption = "{imap_encryption}"',- f'backend.login = "{email}"',- 'backend.auth.type = "password"',- f'backend.auth.raw = "{password}"',- ])+ lines.extend(+ [+ "",+ 'backend.type = "imap"',+ f'backend.host = "{imap_host}"',+ f"backend.port = {imap_port}",+ f'backend.encryption = "{imap_encryption}"',+ f'backend.login = "{email}"',+ 'backend.auth.type = "password"',+ f'backend.auth.raw = "{password}"',+ ]+ )# SMTP sender- lines.extend([- '',- 'message.send.backend.type = "smtp"',- f'message.send.backend.host = "{smtp_host}"',- f'message.send.backend.port = {smtp_port}',- f'message.send.backend.encryption = "{smtp_encryption}"',- f'message.send.backend.login = "{email}"',- 'message.send.backend.auth.type = "password"',- f'message.send.backend.auth.raw = "{password}"',- ])+ lines.extend(+ [+ "",+ 'message.send.backend.type = "smtp"',+ f'message.send.backend.host = "{smtp_host}"',+ f"message.send.backend.port = {smtp_port}",+ f'message.send.backend.encryption = "{smtp_encryption}"',+ f'message.send.backend.login = "{email}"',+ 'message.send.backend.auth.type = "password"',+ f'message.send.backend.auth.raw = "{password}"',+ ]+ )return "\n".join(lines)@@ -103,9 +107,7 @@ class HimalayaService(ServiceSingleton):binary = await self.ensure_binary()config_content = self._generate_config(account_name, credentials)- tmp = tempfile.NamedTemporaryFile(- mode="w", suffix=".toml", prefix="himalaya_", delete=False- )+ tmp = tempfile.NamedTemporaryFile(mode="w", suffix=".toml", prefix="himalaya_", delete=False)try:tmp.write(config_content)tmp.flush()@@ -113,9 +115,12 @@ class HimalayaService(ServiceSingleton):cmd = [binary,- "-c", tmp.name,- "-a", account_name,- "--output", "json",+ "-c",+ tmp.name,+ "-a",+ account_name,+ "--output",+ "json",] + argslogger.debug(f"[Himalaya] Executing: himalaya {' '.join(args)}")@@ -157,9 +162,14 @@ class HimalayaService(ServiceSingleton):# =========================================================================async def send_email(- self, credentials: dict,- to: str, subject: str, body: str,- cc: str = "", bcc: str = "", body_type: str = "text",+ self,+ credentials: dict,+ to: str,+ subject: str,+ body: str,+ cc: str = "",+ bcc: str = "",+ body_type: str = "text",) -> dict:"""Send an email via SMTP. Composes RFC 2822 and pipes to himalaya."""account = self._account_name(credentials)@@ -179,72 +189,107 @@ class HimalayaService(ServiceSingleton):msg["Bcc"] = bccreturn await self.execute(- account, credentials,+ account,+ credentials,["message", "send"],stdin_data=msg.as_string(),)async def list_envelopes(- self, credentials: dict,- folder: str = "INBOX", page: int = 1, page_size: int = 20,+ self,+ credentials: dict,+ folder: str = "INBOX",+ page: int = 1,+ page_size: int = 20,) -> dict:"""List email envelopes in a folder."""account = self._account_name(credentials)- return await self.execute(account, credentials, [- "envelope", "list", "-f", folder,- "--page", str(page), "--page-size", str(page_size),- ])+ return await self.execute(+ account,+ credentials,+ [+ "envelope",+ "list",+ "-f",+ folder,+ "--page",+ str(page),+ "--page-size",+ str(page_size),+ ],+ )async def search_envelopes(- self, credentials: dict, query: str, folder: str = "INBOX",+ self,+ credentials: dict,+ query: str,+ folder: str = "INBOX",) -> dict:"""Search email envelopes by query."""account = self._account_name(credentials)return await self.execute(- account, credentials,+ account,+ credentials,["envelope", "list", "-f", folder, "--query", query],)async def read_message(- self, credentials: dict, message_id: str, folder: str = "INBOX",+ self,+ credentials: dict,+ message_id: str,+ folder: str = "INBOX",) -> dict:"""Read full message content."""account = self._account_name(credentials)return await self.execute(- account, credentials,+ account,+ credentials,["message", "read", message_id, "-f", folder],)async def move_message(- self, credentials: dict,- message_id: str, target_folder: str, folder: str = "INBOX",+ self,+ credentials: dict,+ message_id: str,+ target_folder: str,+ folder: str = "INBOX",) -> dict:"""Move a message to another folder."""account = self._account_name(credentials)return await self.execute(- account, credentials,+ account,+ credentials,["message", "move", message_id, target_folder, "-f", folder],)async def delete_message(- self, credentials: dict, message_id: str, folder: str = "INBOX",+ self,+ credentials: dict,+ message_id: str,+ folder: str = "INBOX",) -> dict:"""Delete a message."""account = self._account_name(credentials)return await self.execute(- account, credentials,+ account,+ credentials,["message", "delete", message_id, "-f", folder],)async def flag_message(- self, credentials: dict,- message_id: str, flag: str, action: str = "add", folder: str = "INBOX",+ self,+ credentials: dict,+ message_id: str,+ flag: str,+ action: str = "add",+ folder: str = "INBOX",) -> dict:"""Add or remove a flag on a message."""account = self._account_name(credentials)flag_cmd = "add" if action == "add" else "remove"return await self.execute(- account, credentials,+ account,+ credentials,["flag", flag_cmd, message_id, "--flag", flag, "-f", folder],)diff --git a/server/nodes/email/_service.py b/server/nodes/email/_service.pyindex dded6d15..811055e1 100644--- a/server/nodes/email/_service.py+++ b/server/nodes/email/_service.py@@ -43,6 +43,7 @@ class EmailService(ServiceSingleton):@propertydef himalaya(self):from ._himalaya import get_himalaya_service+return get_himalaya_service()def _provider_preset(self, name: str) -> Dict:@@ -58,6 +59,7 @@ class EmailService(ServiceSingleton):the provider is 'custom' or when a preset field is empty."""from services.plugin.deps import get_auth_service+auth = get_auth_service()provider = params.get("provider") or await auth.get_api_key("email_provider") or self.defaults.get("provider")@@ -132,19 +134,27 @@ class EmailService(ServiceSingleton):folder = params.get("folder", d.get("folder"))router = {- "list": ("list_envelopes", {"folder": folder,- "page": params.get("page", 1),- "page_size": params.get("page_size", d.get("page_size"))}),- "search": ("search_envelopes", {"query": params.get("query", ""), "folder": folder}),- "read": ("read_message", {"message_id": params.get("message_id", ""), "folder": folder}),- "folders": ("list_folders", {}),- "move": ("move_message", {"message_id": params.get("message_id", ""),- "target_folder": params.get("target_folder", ""), "folder": folder}),- "delete": ("delete_message", {"message_id": params.get("message_id", ""), "folder": folder}),- "flag": ("flag_message", {"message_id": params.get("message_id", ""),- "flag": params.get("flag", d.get("flag")),- "action": params.get("flag_action", d.get("flag_action")),- "folder": folder}),+ "list": (+ "list_envelopes",+ {"folder": folder, "page": params.get("page", 1), "page_size": params.get("page_size", d.get("page_size"))},+ ),+ "search": ("search_envelopes", {"query": params.get("query", ""), "folder": folder}),+ "read": ("read_message", {"message_id": params.get("message_id", ""), "folder": folder}),+ "folders": ("list_folders", {}),+ "move": (+ "move_message",+ {"message_id": params.get("message_id", ""), "target_folder": params.get("target_folder", ""), "folder": folder},+ ),+ "delete": ("delete_message", {"message_id": params.get("message_id", ""), "folder": folder}),+ "flag": (+ "flag_message",+ {+ "message_id": params.get("message_id", ""),+ "flag": params.get("flag", d.get("flag")),+ "action": params.get("flag_action", d.get("flag_action")),+ "folder": folder,+ },+ ),}if op not in router:diff --git a/server/nodes/email/email_read/__init__.py b/server/nodes/email/email_read/__init__.pyindex f8b617df..636bbafb 100644--- a/server/nodes/email/email_read/__init__.py+++ b/server/nodes/email/email_read/__init__.py@@ -11,8 +11,13 @@ from services.plugin import ActionNode, NodeContext, Operation, TaskQueueclass EmailReadParams(BaseModel):provider: Literal[- "gmail", "outlook", "yahoo", "icloud",- "protonmail", "fastmail", "custom",+ "gmail",+ "outlook",+ "yahoo",+ "icloud",+ "protonmail",+ "fastmail",+ "custom",] = Field(default="gmail", description="IMAP provider preset.")operation: Literal["list", "search", "read", "folders", "move", "delete", "flag"] = Field(default="list",@@ -57,28 +62,34 @@ class EmailReadParams(BaseModel):# Pagination (list / search)limit: int = Field(- default=20, ge=1, le=500,+ default=20,+ ge=1,+ le=500,description="Max envelopes per page.",json_schema_extra={"displayOptions": {"show": {"operation": ["list", "search"]}},},)page: int = Field(- default=1, ge=1,+ default=1,+ ge=1,description="Page number (1-indexed).",json_schema_extra={"displayOptions": {"show": {"operation": ["list", "search"]}},},)page_size: int = Field(- default=20, ge=1, le=500,+ default=20,+ ge=1,+ le=500,description="Items per page (overrides limit when paginating).",json_schema_extra={"displayOptions": {"show": {"operation": ["list", "search"]}},},)offset: int = Field(- default=0, ge=0,+ default=0,+ ge=0,description="Alternative to page-based pagination — skip this many messages.",json_schema_extra={"displayOptions": {"show": {"operation": ["list", "search"]}},@@ -107,10 +118,8 @@ class EmailReadNode(ActionNode):tool_name = "email_read"tool_description = "Read and manage emails via IMAP. Operations: list (envelopes), search (query), read (message by ID), folders (list), move, delete, flag."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}task_queue = TaskQueue.MESSAGING@@ -123,4 +132,5 @@ class EmailReadNode(ActionNode):async def query(self, ctx: NodeContext, params: EmailReadParams) -> Any:# Body inlined from handlers/email.py (Wave 11.D.1).from .._service import get_email_service+return await get_email_service().read(params.model_dump())diff --git a/server/nodes/email/email_receive/__init__.py b/server/nodes/email/email_receive/__init__.pyindex 99454a94..3426d1fe 100644--- a/server/nodes/email/email_receive/__init__.py+++ b/server/nodes/email/email_receive/__init__.py@@ -11,14 +11,22 @@ from typing import Any, Dict, Literal, Optional, Setfrom pydantic import BaseModel, ConfigDict, Fieldfrom services.plugin import (- NodeContext, Operation, PollingTriggerNode, TaskQueue,+ NodeContext,+ Operation,+ PollingTriggerNode,+ TaskQueue,)class EmailReceiveParams(BaseModel):provider: Literal[- "gmail", "outlook", "yahoo", "icloud",- "protonmail", "fastmail", "custom",+ "gmail",+ "outlook",+ "yahoo",+ "icloud",+ "protonmail",+ "fastmail",+ "custom",] = "gmail"folder: str = Field(default="INBOX")poll_interval: int = Field(default=60, ge=30, le=3600)@@ -48,10 +56,7 @@ class EmailReceiveNode(PollingTriggerNode):# ``event_waiter._auto_populate_from_plugins`` backfill# TRIGGER_REGISTRY without a hardcoded entry in event_waiter.event_type = "email_received"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)task_queue = TaskQueue.TRIGGERS_POLL# Email keeps its 30s lower bound (legacy floor in# config/email_providers.json). Gmail uses the default (10, 3600).@@ -81,22 +86,22 @@ class EmailReceiveNode(PollingTriggerNode):svc, creds, folder, _mark = servicereturn await svc.poll_ids(creds, folder)- async def fetch_detail(- self, service: Any, msg_id: str, params: Dict[str, Any]- ) -> Dict[str, Any]:+ async def fetch_detail(self, service: Any, msg_id: str, params: Dict[str, Any]) -> Dict[str, Any]:svc, creds, folder, _mark = servicereturn await svc.fetch_detail(creds, msg_id, folder)- async def post_emit(- self, service: Any, msg_id: str, params: Dict[str, Any]- ) -> None:+ async def post_emit(self, service: Any, msg_id: str, params: Dict[str, Any]) -> None:svc, creds, folder, mark = serviceif not mark:returntry:d = svc.defaultsawait svc.himalaya.flag_message(- creds, msg_id, d.get("flag"), d.get("flag_action"), folder,+ creds,+ msg_id,+ d.get("flag"),+ d.get("flag_action"),+ folder,)except Exception:pass@@ -128,7 +133,8 @@ class EmailReceiveNode(PollingTriggerNode):poll = svc.resolve_poll_params(raw_params)await get_status_broadcaster().update_node_status(- node_id, "waiting",+ node_id,+ "waiting",{"message": f"Waiting for email (every {poll['interval']}s)...","event_type": "email_received",@@ -138,6 +144,7 @@ class EmailReceiveNode(PollingTriggerNode):seen = await svc.poll_ids(creds, poll["folder"])from core.logging import get_logger+get_logger(__name__).info(f"[EmailReceive] Baseline: {len(seen)} emails in {poll['folder']}",)@@ -155,7 +162,10 @@ class EmailReceiveNode(PollingTriggerNode):if poll["mark_as_read"]:d = svc.defaultsawait svc.himalaya.flag_message(- creds, msg_id, d.get("flag"), d.get("flag_action"),+ creds,+ msg_id,+ d.get("flag"),+ d.get("flag_action"),poll["folder"],)@@ -167,7 +177,9 @@ class EmailReceiveNode(PollingTriggerNode):await dispatch_email_received(email_data)return {- "success": True, "node_id": node_id, "node_type": self.type,+ "success": True,+ "node_id": node_id,+ "node_type": self.type,"result": email_data,"execution_time": time.time() - start_time,"timestamp": datetime.now().isoformat(),@@ -175,16 +187,21 @@ class EmailReceiveNode(PollingTriggerNode):except asyncio.CancelledError:return {- "success": False, "node_id": node_id, "node_type": self.type,+ "success": False,+ "node_id": node_id,+ "node_type": self.type,"error": "Cancelled by user","execution_time": time.time() - start_time,"timestamp": datetime.now().isoformat(),}except Exception as e:from core.logging import get_logger+get_logger(__name__).error(f"[EmailReceive] {e}")return {- "success": False, "node_id": node_id, "node_type": self.type,+ "success": False,+ "node_id": node_id,+ "node_type": self.type,"error": str(e),"execution_time": time.time() - start_time,"timestamp": datetime.now().isoformat(),diff --git a/server/nodes/email/email_send/__init__.py b/server/nodes/email/email_send/__init__.pyindex e542c6bc..eea05ed3 100644--- a/server/nodes/email/email_send/__init__.py+++ b/server/nodes/email/email_send/__init__.py@@ -11,8 +11,13 @@ from services.plugin import ActionNode, NodeContext, Operation, TaskQueueclass EmailSendParams(BaseModel):provider: Literal[- "gmail", "outlook", "yahoo", "icloud",- "protonmail", "fastmail", "custom",+ "gmail",+ "outlook",+ "yahoo",+ "icloud",+ "protonmail",+ "fastmail",+ "custom",] = "gmail"to: str = Field(...)subject: str = Field(...)@@ -41,10 +46,8 @@ class EmailSendNode(ActionNode):tool_name = "email_send"tool_description = "Send email via SMTP. Specify to, subject, body. Optional: cc, bcc, body_type (text/html)."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}task_queue = TaskQueue.MESSAGING@@ -57,4 +60,5 @@ class EmailSendNode(ActionNode):async def send(self, ctx: NodeContext, params: EmailSendParams) -> Any:# Body inlined from handlers/email.py (Wave 11.D.1).from .._service import get_email_service+return await get_email_service().send(params.model_dump(by_alias=False))diff --git a/server/nodes/filesystem/_backend.py b/server/nodes/filesystem/_backend.pyindex 24aacc04..94261dae 100644--- a/server/nodes/filesystem/_backend.py+++ b/server/nodes/filesystem/_backend.py@@ -174,11 +174,7 @@ def get_backend(param_dir = parameters.get("working_directory")ctx_dir = context.get("workspace_dir") if context else None- root = (- param_dir- or ctx_dir- or os.path.join(Settings().workspace_base_resolved, "default")- )+ root = param_dir or ctx_dir or os.path.join(Settings().workspace_base_resolved, "default")os.makedirs(root, exist_ok=True)get_logger(__name__).info("[Filesystem] root=%s", root)# ``inherit_env=True`` makes the host PATH available so the agent candiff --git a/server/nodes/filesystem/file_modify/__init__.py b/server/nodes/filesystem/file_modify/__init__.pyindex 3a878e4c..0d9e7972 100644--- a/server/nodes/filesystem/file_modify/__init__.py+++ b/server/nodes/filesystem/file_modify/__init__.py@@ -38,7 +38,9 @@ class FileModifyNode(ActionNode):group = ("filesystem", "tool")description = "Write new files or edit existing files"tool_name = "file_modify"- tool_description = "Write a new file or edit an existing file with string replacement. Operations: write (create/overwrite), edit (find and replace)."+ tool_description = (+ "Write a new file or edit an existing file with string replacement. Operations: write (create/overwrite), edit (find and replace)."+ )component_kind = "square"handles = ({"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},@@ -71,9 +73,7 @@ class FileModifyNode(ActionNode):resolved = backend._resolve_path(file_path)if resolved.exists():if resolved.is_dir():- raise IsADirectoryError(- f"Cannot write to {file_path}: path is a directory"- )+ raise IsADirectoryError(f"Cannot write to {file_path}: path is a directory")resolved.unlink()return backend.write(file_path, params.content)@@ -89,7 +89,10 @@ class FileModifyNode(ActionNode):if not params.old_string:raise NodeUserError("old_string is required for edit")result = await asyncio.to_thread(- backend.edit, file_path, params.old_string, params.new_string,+ backend.edit,+ file_path,+ params.old_string,+ params.new_string,replace_all=params.replace_all,)if result.error:diff --git a/server/nodes/filesystem/file_read/__init__.py b/server/nodes/filesystem/file_read/__init__.pyindex 960e0794..09caa7cf 100644--- a/server/nodes/filesystem/file_read/__init__.py+++ b/server/nodes/filesystem/file_read/__init__.py@@ -56,8 +56,10 @@ class FileReadNode(ActionNode):file_path = normalize_virtual_path(params.file_path)try:content = await asyncio.to_thread(- backend.read, file_path,- offset=params.offset, limit=params.limit,+ backend.read,+ file_path,+ offset=params.offset,+ limit=params.limit,)except (FileNotFoundError, IsADirectoryError, ValueError) as e:# File doesn't exist / is a directory / bad offset — thediff --git a/server/nodes/filesystem/fs_search/__init__.py b/server/nodes/filesystem/fs_search/__init__.pyindex 457a9d94..5366bfdc 100644--- a/server/nodes/filesystem/fs_search/__init__.py+++ b/server/nodes/filesystem/fs_search/__init__.py@@ -31,7 +31,9 @@ class FsSearchNode(ActionNode):group = ("filesystem", "tool")description = "Search the filesystem (ls, glob, grep)"tool_name = "fs_search"- tool_description = "Search the filesystem. Modes: ls (list directory), glob (pattern match files), grep (search file contents for text)."+ tool_description = (+ "Search the filesystem. Modes: ls (list directory), glob (pattern match files), grep (search file contents for text)."+ )component_kind = "square"handles = ({"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},@@ -65,7 +67,9 @@ class FsSearchNode(ActionNode):if not params.pattern:raise NodeUserError("pattern is required for glob mode")matches = await asyncio.to_thread(- backend.glob_info, params.pattern, path=path,+ backend.glob_info,+ params.pattern,+ path=path,)return {"path": path,@@ -78,7 +82,9 @@ class FsSearchNode(ActionNode):if not params.pattern:raise NodeUserError("pattern is required for grep mode")result = await asyncio.to_thread(- backend.grep_raw, params.pattern, path=path,+ backend.grep_raw,+ params.pattern,+ path=path,)if isinstance(result, str):raise NodeUserError(result)diff --git a/server/nodes/filesystem/shell/__init__.py b/server/nodes/filesystem/shell/__init__.pyindex 9ba7d512..875b988f 100644--- a/server/nodes/filesystem/shell/__init__.py+++ b/server/nodes/filesystem/shell/__init__.py@@ -68,7 +68,7 @@ class ShellNode(ActionNode):# Nushell's parser does, so the LLM sees an actionable hint instead# of ``nu::parser::shell_andand``. Documented in# ``server/skills/terminal/shell-skill/SKILL.md``.- if (m := _BASH_CHAIN_RE.search(params.command)):+ if m := _BASH_CHAIN_RE.search(params.command):op = m.group(1)replacement = "; (sequential)" if op == "&&" else "try { … } catch { … }"raise NodeUserError(@@ -85,17 +85,22 @@ class ShellNode(ActionNode):# misleading users into thinking shell runs daemons.log.info("[Shell] Executing: %s (timeout=%ds)",- params.command[:200], params.timeout,+ params.command[:200],+ params.timeout,)result = await asyncio.to_thread(- backend.execute, params.command, timeout=params.timeout,+ backend.execute,+ params.command,+ timeout=params.timeout,)if result.exit_code == 124:log.warning("[Shell] Timed out after %ds: %s", params.timeout, params.command[:100])elif result.exit_code != 0:log.warning("[Shell] Non-zero exit (%d): %s -> %s",- result.exit_code, params.command[:100], result.output[:300],+ result.exit_code,+ params.command[:100],+ result.output[:300],)else:log.info("[Shell] Completed: exit=%d len=%d", result.exit_code, len(result.output))diff --git a/server/nodes/google/_auth_helper.py b/server/nodes/google/_auth_helper.pyindex fafa9208..68edd3b6 100644--- a/server/nodes/google/_auth_helper.py+++ b/server/nodes/google/_auth_helper.py@@ -39,11 +39,11 @@ async def get_google_credentials("""from services.plugin.deps import get_auth_service, get_database- account_mode = parameters.get('account_mode', 'owner')+ account_mode = parameters.get("account_mode", "owner")customer_id = "owner"- if account_mode == 'customer':- customer_id = parameters.get('customer_id')+ if account_mode == "customer":+ customer_id = parameters.get("customer_id")if not customer_id:raise ValueError("customer_id required for customer mode")@@ -65,15 +65,11 @@ async def get_google_credentials(tokens = await auth_service.get_oauth_tokens("google", customer_id="owner")if not tokens or not tokens.get("access_token"):- raise ValueError(- "Google Workspace not connected. Please authenticate via Credentials."- )+ raise ValueError("Google Workspace not connected. Please authenticate via Credentials.")access_token = tokens["access_token"]# refresh_token is read from DB directly (RFC 9700; not cached).- refresh_token = await auth_service.get_oauth_refresh_token(- "google", customer_id="owner"- )+ refresh_token = await auth_service.get_oauth_refresh_token("google", customer_id="owner")auth_service = get_auth_service()client_id = await auth_service.get_api_key("google_client_id") or ""@@ -94,9 +90,7 @@ async def get_google_credentials(# best-effort optimization that persists the new token to the DB.if refresh_token and client_id and client_secret:try:- await _try_refresh_and_persist(- creds, auth_service, customer_id, account_mode- )+ await _try_refresh_and_persist(creds, auth_service, customer_id, account_mode)except Exception as e:# Non-fatal: the Credentials object will auto-refresh on 401 anywaylogger.debug(f"Proactive token refresh skipped: {e}")@@ -132,7 +126,7 @@ async def _try_refresh_and_persist(return# Persist refreshed token back to the correct store- if account_mode == 'owner':+ if account_mode == "owner":tokens = await auth_service.get_oauth_tokens("google", customer_id="owner")await auth_service.store_oauth_tokens(provider="google",diff --git a/server/nodes/google/_base.py b/server/nodes/google/_base.pyindex 7c6187c6..f99f6049 100644--- a/server/nodes/google/_base.py+++ b/server/nodes/google/_base.py@@ -41,7 +41,8 @@ async def build_google_service(creds = await GoogleCredential.build_credentials(parameters, context)loop = asyncio.get_event_loop()return await loop.run_in_executor(- None, lambda: build(api_name, api_version, credentials=creds),+ None,+ lambda: build(api_name, api_version, credentials=creds),)@@ -65,16 +66,18 @@ async def track_google_usage(cost_data = pricing.calculate_api_cost(service, action, resource_count)db = get_database()- await db.save_api_usage_metric({- 'session_id': context.get('session_id', 'default'),- 'node_id': node_id,- 'workflow_id': context.get('workflow_id'),- 'service': service,- 'operation': cost_data.get('operation', action),- 'endpoint': action,- 'resource_count': resource_count,- 'cost': cost_data.get('total_cost', 0.0),- })+ await db.save_api_usage_metric(+ {+ "session_id": context.get("session_id", "default"),+ "node_id": node_id,+ "workflow_id": context.get("workflow_id"),+ "service": service,+ "operation": cost_data.get("operation", action),+ "endpoint": action,+ "resource_count": resource_count,+ "cost": cost_data.get("total_cost", 0.0),+ }+ )return cost_datadiff --git a/server/nodes/google/_credentials.py b/server/nodes/google/_credentials.pyindex 65bfdd8d..b7707c7d 100644--- a/server/nodes/google/_credentials.py+++ b/server/nodes/google/_credentials.py@@ -38,6 +38,7 @@ class GoogleCredential(OAuth2Credential):"""Return the live scope list (lazy import)."""if not cls.scopes:from nodes.google._oauth import GOOGLE_WORKSPACE_SCOPES+cls.scopes = tuple(GOOGLE_WORKSPACE_SCOPES)return cls.scopes@@ -57,4 +58,5 @@ class GoogleCredential(OAuth2Credential):policy."""from nodes.google._auth_helper import get_google_credentials+return await get_google_credentials(parameters, context)diff --git a/server/nodes/google/_filters.py b/server/nodes/google/_filters.pyindex e613a919..99de889f 100644--- a/server/nodes/google/_filters.py+++ b/server/nodes/google/_filters.py@@ -13,11 +13,11 @@ from typing import Callable, Dictdef build_gmail_filter(params: Dict) -> Callable[[Dict], bool]:"""Build filter function for Gmail email events."""- label_filter = params.get('label_filter', 'INBOX')+ label_filter = params.get("label_filter", "INBOX")def matches(data: Dict) -> bool:- if label_filter and label_filter != 'all':- labels = data.get('labels', [])+ if label_filter and label_filter != "all":+ labels = data.get("labels", [])if label_filter not in labels:return Falsereturn Truediff --git a/server/nodes/google/_gmail.py b/server/nodes/google/_gmail.pyindex 3d576d1b..98ec00c7 100644--- a/server/nodes/google/_gmail.py+++ b/server/nodes/google/_gmail.py@@ -15,74 +15,95 @@ from ._base import run_syncasync def poll_gmail_ids(service, query: str, max_results: int = 20) -> Set[str]:"""Fetch message IDs matching a Gmail query."""- result = await run_sync(lambda: service.users().messages().list(- userId='me', q=query, maxResults=max_results,- ).execute())- return {m.get('id') for m in result.get('messages', []) if m.get('id')}+ result = await run_sync(+ lambda: service.users()+ .messages()+ .list(+ userId="me",+ q=query,+ maxResults=max_results,+ )+ .execute()+ )+ return {m.get("id") for m in result.get("messages", []) if m.get("id")}async def fetch_email_details(service, message_id: str) -> Dict[str, Any]:"""Fetch full email message + format it for output."""- result = await run_sync(lambda: service.users().messages().get(- userId='me', id=message_id, format='full',- metadataHeaders=['From', 'To', 'Subject', 'Date', 'Cc', 'Bcc'],- ).execute())+ result = await run_sync(+ lambda: service.users()+ .messages()+ .get(+ userId="me",+ id=message_id,+ format="full",+ metadataHeaders=["From", "To", "Subject", "Date", "Cc", "Bcc"],+ )+ .execute()+ )return format_message(result, include_body=True)async def mark_email_as_read(service, message_id: str) -> None:"""Remove the UNREAD label from a message."""- await run_sync(lambda: service.users().messages().modify(- userId='me', id=message_id, body={'removeLabelIds': ['UNREAD']},- ).execute())+ await run_sync(+ lambda: service.users()+ .messages()+ .modify(+ userId="me",+ id=message_id,+ body={"removeLabelIds": ["UNREAD"]},+ )+ .execute()+ )def format_message(message: Dict[str, Any], include_body: bool = False) -> Dict[str, Any]:"""Convert a raw Gmail message payload into a flat, LLM-friendly dict."""headers: Dict[str, str] = {}- payload = message.get('payload', {})- for header in payload.get('headers', []):- name = header.get('name', '').lower()- if name in ('from', 'to', 'subject', 'date', 'cc', 'bcc'):- headers[name] = header.get('value', '')+ payload = message.get("payload", {})+ for header in payload.get("headers", []):+ name = header.get("name", "").lower()+ if name in ("from", "to", "subject", "date", "cc", "bcc"):+ headers[name] = header.get("value", "")formatted: Dict[str, Any] = {- 'message_id': message.get('id'),- 'thread_id': message.get('threadId'),- 'from': headers.get('from', ''),- 'to': headers.get('to', ''),- 'cc': headers.get('cc', ''),- 'subject': headers.get('subject', ''),- 'date': headers.get('date', ''),- 'snippet': message.get('snippet', ''),- 'labels': message.get('labelIds', []),- 'size_estimate': message.get('sizeEstimate', 0),+ "message_id": message.get("id"),+ "thread_id": message.get("threadId"),+ "from": headers.get("from", ""),+ "to": headers.get("to", ""),+ "cc": headers.get("cc", ""),+ "subject": headers.get("subject", ""),+ "date": headers.get("date", ""),+ "snippet": message.get("snippet", ""),+ "labels": message.get("labelIds", []),+ "size_estimate": message.get("sizeEstimate", 0),}if include_body:- formatted['body'] = _extract_body(payload)+ formatted["body"] = _extract_body(payload)attachments = _extract_attachments(payload)if attachments:- formatted['attachments'] = attachments+ formatted["attachments"] = attachmentsreturn formatteddef _extract_body(payload: Dict[str, Any]) -> str:"""Extract text body from a (possibly multipart) Gmail payload."""- if payload.get('body', {}).get('data'):- return base64.urlsafe_b64decode(payload['body']['data']).decode('utf-8', errors='ignore')+ if payload.get("body", {}).get("data"):+ return base64.urlsafe_b64decode(payload["body"]["data"]).decode("utf-8", errors="ignore")body = ""- for part in payload.get('parts', []):- mime = part.get('mimeType', '')- data = part.get('body', {}).get('data')- if mime == 'text/plain' and data:- return base64.urlsafe_b64decode(data).decode('utf-8', errors='ignore')- if mime == 'text/html' and data and not body:- body = base64.urlsafe_b64decode(data).decode('utf-8', errors='ignore')- elif mime.startswith('multipart/'):+ for part in payload.get("parts", []):+ mime = part.get("mimeType", "")+ data = part.get("body", {}).get("data")+ if mime == "text/plain" and data:+ return base64.urlsafe_b64decode(data).decode("utf-8", errors="ignore")+ if mime == "text/html" and data and not body:+ body = base64.urlsafe_b64decode(data).decode("utf-8", errors="ignore")+ elif mime.startswith("multipart/"):nested = _extract_body(part)if nested:return nested@@ -92,15 +113,17 @@ def _extract_body(payload: Dict[str, Any]) -> str:def _extract_attachments(payload: Dict[str, Any]) -> List[Dict[str, Any]]:"""Flatten attachment metadata from a multipart payload."""attachments: List[Dict[str, Any]] = []- for part in payload.get('parts', []):- filename = part.get('filename', '')+ for part in payload.get("parts", []):+ filename = part.get("filename", "")if filename:- attachments.append({- 'filename': filename,- 'mime_type': part.get('mimeType', ''),- 'size': part.get('body', {}).get('size', 0),- 'attachment_id': part.get('body', {}).get('attachmentId', ''),- })- if part.get('parts'):+ attachments.append(+ {+ "filename": filename,+ "mime_type": part.get("mimeType", ""),+ "size": part.get("body", {}).get("size", 0),+ "attachment_id": part.get("body", {}).get("attachmentId", ""),+ }+ )+ if part.get("parts"):attachments.extend(_extract_attachments(part))return attachmentsdiff --git a/server/nodes/google/_handlers.py b/server/nodes/google/_handlers.pyindex c82e5265..39e94090 100644--- a/server/nodes/google/_handlers.py+++ b/server/nodes/google/_handlers.py@@ -22,7 +22,9 @@ from ._oauth import GoogleOAuthasync def _google_oauth_factory(- *, redirect_uri: Optional[str] = None, **_kwargs,+ *,+ redirect_uri: Optional[str] = None,+ **_kwargs,) -> GoogleOAuth:"""Build a :class:`GoogleOAuth` from stored client credentials."""from services.plugin.deps import get_auth_servicediff --git a/server/nodes/google/_oauth.py b/server/nodes/google/_oauth.pyindex 3fe801b4..fe6695ed 100644--- a/server/nodes/google/_oauth.py+++ b/server/nodes/google/_oauth.py@@ -215,26 +215,34 @@ class GoogleOAuth:}self.token_uri = oauth_endpoints["token_uri"]self.revoke_uri = oauth_endpoints.get(- "revoke_uri", "https://oauth2.googleapis.com/revoke",+ "revoke_uri",+ "https://oauth2.googleapis.com/revoke",)def generate_authorization_url(- self, *, state_data: Optional[Dict[str, Any]] = None,+ self,+ *,+ state_data: Optional[Dict[str, Any]] = None,) -> Dict[str, str]:"""Build the Google authorization URL + register state."""flow = Flow.from_client_config(- self.client_config, scopes=self.scopes, redirect_uri=self.redirect_uri,+ self.client_config,+ scopes=self.scopes,+ redirect_uri=self.redirect_uri,)authorization_url, state = flow.authorization_url(access_type="offline",include_granted_scopes="true",prompt="consent", # force consent to get refresh token)- self.state_store.put(state, {- "data": state_data or {"mode": "owner"},- "redirect_uri": self.redirect_uri,- "code_verifier": getattr(flow, "code_verifier", None),- })+ self.state_store.put(+ state,+ {+ "data": state_data or {"mode": "owner"},+ "redirect_uri": self.redirect_uri,+ "code_verifier": getattr(flow, "code_verifier", None),+ },+ )return {"url": authorization_url, "state": state}async def exchange_code(self, code: str, state: str) -> Dict[str, Any]:@@ -302,11 +310,16 @@ class GoogleOAuth:"""Async wrapper around :meth:`refresh_credentials`."""return await asyncio.to_thread(self.refresh_credentials,- refresh_token, self.client_id, self.client_secret, self.token_uri,+ refresh_token,+ self.client_id,+ self.client_secret,+ self.token_uri,)async def revoke_token(- self, token: str, token_type: str = "access_token",+ self,+ token: str,+ token_type: str = "access_token",) -> Dict[str, Any]:"""Best-effort token revocation via Google's revoke endpoint."""try:@@ -324,7 +337,8 @@ class GoogleOAuth:return {"success": False,"error": (response.json() if response.text else {}).get(- "error_description", "Revocation failed",+ "error_description",+ "Revocation failed",),}diff --git a/server/nodes/google/_option_loaders.py b/server/nodes/google/_option_loaders.pyindex f3470566..42d2dfe1 100644--- a/server/nodes/google/_option_loaders.py+++ b/server/nodes/google/_option_loaders.py@@ -24,9 +24,7 @@ async def _google_service(api: str, version: str, params: Dict[str, Any]):"""Build a googleapiclient service under the right OAuth credentials."""creds = await get_google_credentials(params, {})loop = asyncio.get_event_loop()- return await loop.run_in_executor(- None, lambda: build(api, version, credentials=creds)- )+ return await loop.run_in_executor(None, lambda: build(api, version, credentials=creds))async def load_gmail_labels(params: Dict[str, Any]) -> List[Dict[str, Any]]:@@ -34,9 +32,7 @@ async def load_gmail_labels(params: Dict[str, Any]) -> List[Dict[str, Any]]:gmail (search)."""service = await _google_service("gmail", "v1", params)loop = asyncio.get_event_loop()- response = await loop.run_in_executor(- None, lambda: service.users().labels().list(userId="me").execute()- )+ response = await loop.run_in_executor(None, lambda: service.users().labels().list(userId="me").execute())labels = response.get("labels", [])# Stable sort: system labels alphabetical first, then user labels.labels.sort(@@ -45,24 +41,17 @@ async def load_gmail_labels(params: Dict[str, Any]) -> List[Dict[str, Any]]:(label.get("name") or "").lower(),))- return [- {"value": label["id"], "label": label.get("name") or label["id"]}- for label in labels- ]+ return [{"value": label["id"], "label": label.get("name") or label["id"]} for label in labels]async def load_calendar_list(params: Dict[str, Any]) -> List[Dict[str, Any]]:"""Calendar list for the calendarId picker on calendar CRUD."""service = await _google_service("calendar", "v3", params)loop = asyncio.get_event_loop()- response = await loop.run_in_executor(- None, lambda: service.calendarList().list().execute()- )+ response = await loop.run_in_executor(None, lambda: service.calendarList().list().execute())entries = response.get("items", [])# Primary first, rest alphabetised.- entries.sort(- key=lambda c: (not c.get("primary", False), (c.get("summary") or "").lower())- )+ entries.sort(key=lambda c: (not c.get("primary", False), (c.get("summary") or "").lower()))return [{"value": c.get("id", ""),@@ -80,28 +69,18 @@ async def load_drive_folders(params: Dict[str, Any]) -> List[Dict[str, Any]]:query = "mimeType='application/vnd.google-apps.folder' and trashed=false"response = await loop.run_in_executor(None,- lambda: service.files()- .list(q=query, fields="files(id, name, parents)", pageSize=200)- .execute(),+ lambda: service.files().list(q=query, fields="files(id, name, parents)", pageSize=200).execute(),)folders = response.get("files", [])folders.sort(key=lambda f: (f.get("name") or "").lower())- return [- {"value": f.get("id", ""), "label": f.get("name") or f.get("id", "")}- for f in folders- ]+ return [{"value": f.get("id", ""), "label": f.get("name") or f.get("id", "")} for f in folders]async def load_tasklists(params: Dict[str, Any]) -> List[Dict[str, Any]]:"""Task lists for the tasklistId picker on tasks CRUD."""service = await _google_service("tasks", "v1", params)loop = asyncio.get_event_loop()- response = await loop.run_in_executor(- None, lambda: service.tasklists().list().execute()- )+ response = await loop.run_in_executor(None, lambda: service.tasklists().list().execute())lists = response.get("items", [])lists.sort(key=lambda label: (label.get("title") or "").lower())- return [- {"value": label.get("id", ""), "label": label.get("title") or label.get("id", "")}- for label in lists- ]+ return [{"value": label.get("id", ""), "label": label.get("title") or label.get("id", "")} for label in lists]diff --git a/server/nodes/google/_refresh.py b/server/nodes/google/_refresh.pyindex 8703a7ff..3b80da02 100644--- a/server/nodes/google/_refresh.py+++ b/server/nodes/google/_refresh.py@@ -32,9 +32,7 @@ async def refresh_google_status(broadcaster: "StatusBroadcaster") -> None:from services.plugin.deps import get_auth_serviceauth_service = get_auth_service()- tokens = await auth_service.get_oauth_tokens(- "google", customer_id="owner"- )+ tokens = await auth_service.get_oauth_tokens("google", customer_id="owner")if not tokens or not tokens.get("access_token"):broadcaster._status["google"] = {"connected": False,@@ -52,15 +50,13 @@ async def refresh_google_status(broadcaster: "StatusBroadcaster") -> None:tokens.get("email"),)- await broadcaster.broadcast({- "type": "google_status",- "data": broadcaster._status["google"],- })- span.set_attribute(- "connected", bool(broadcaster._status["google"]["connected"])+ await broadcaster.broadcast(+ {+ "type": "google_status",+ "data": broadcaster._status["google"],+ })+ span.set_attribute("connected", bool(broadcaster._status["google"]["connected"]))except Exception as exc: # noqa: BLE001span.record_exception(exc)- logger.debug(- "[StatusBroadcaster] Could not refresh Google status: %s", exc- )+ logger.debug("[StatusBroadcaster] Could not refresh Google status: %s", exc)diff --git a/server/nodes/google/_router.py b/server/nodes/google/_router.pyindex 8badb61e..c8691442 100644--- a/server/nodes/google/_router.py+++ b/server/nodes/google/_router.py@@ -60,10 +60,7 @@ async def _customer_mode_handler(overrides: Dict[str, Any] = {"customer_id": customer_id}if redirect_after:- overrides["redirect_after"] = (- f"{redirect_after}?google_connected=true"- f"&customer={customer_id}&email={email}"- )+ overrides["redirect_after"] = f"{redirect_after}?google_connected=true" f"&customer={customer_id}&email={email}"return overrides@@ -82,7 +79,9 @@ router: APIRouter = make_oauth_callback_router(@router.post("/customer-auth-url")async def generate_customer_auth_url(- request: Request, customer_id: str, redirect_after: Optional[str] = None,+ request: Request,+ customer_id: str,+ redirect_after: Optional[str] = None,):"""Generate OAuth URL for a customer to connect their Google account."""from services.oauth_utils import get_redirect_uridiff --git a/server/nodes/google/calendar/__init__.py b/server/nodes/google/calendar/__init__.pyindex f50afa5c..bed282ec 100644--- a/server/nodes/google/calendar/__init__.py+++ b/server/nodes/google/calendar/__init__.py@@ -47,7 +47,8 @@ class CalendarParams(BaseModel):# Update + deletesend_updates: Literal["all", "externalOnly", "none"] = Field(- default="all", json_schema_extra=_UPDATE_OR_DELETE,+ default="all",+ json_schema_extra=_UPDATE_OR_DELETE,)# Update-only fields@@ -81,7 +82,11 @@ class CalendarOutput(BaseModel):def _iso_or_shortcut(value: Optional[str], default_offset_days: int = 0) -> str:now = datetime.utcnow()if not value or value.lower() == "today":- base = now.replace(hour=0, minute=0, second=0, microsecond=0) if default_offset_days == 0 else now + timedelta(days=default_offset_days)+ base = (+ now.replace(hour=0, minute=0, second=0, microsecond=0)+ if default_offset_days == 0+ else now + timedelta(days=default_offset_days)+ )return base.isoformat() + "Z"if value.startswith("today+"):days = int(value.replace("today+", "").replace("d", ""))@@ -99,10 +104,8 @@ class CalendarNode(ActionNode):tool_name = "google_calendar"tool_description = "Manage Google Calendar events. Operations: create (new event), list (events in date range), update (modify event), delete (remove event)."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}credentials = (GoogleCredential,)@@ -126,37 +129,41 @@ class CalendarNode(ActionNode):raise RuntimeError("Start time and end time are required")event = {- 'summary': params.title,- 'start': {'dateTime': params.start_time, 'timeZone': params.timezone},- 'end': {'dateTime': params.end_time, 'timeZone': params.timezone},+ "summary": params.title,+ "start": {"dateTime": params.start_time, "timeZone": params.timezone},+ "end": {"dateTime": params.end_time, "timeZone": params.timezone},}if params.description:- event['description'] = params.description+ event["description"] = params.descriptionif params.location:- event['location'] = params.location+ event["location"] = params.locationif params.attendees:- att = [{'email': e.strip()} for e in params.attendees.split(',') if e.strip()]+ att = [{"email": e.strip()} for e in params.attendees.split(",") if e.strip()]if att:- event['attendees'] = att+ event["attendees"] = attif params.reminder_minutes:- event['reminders'] = {- 'useDefault': False,- 'overrides': [{'method': 'popup', 'minutes': int(params.reminder_minutes)}],+ event["reminders"] = {+ "useDefault": False,+ "overrides": [{"method": "popup", "minutes": int(params.reminder_minutes)}],}- result = await run_sync(lambda: events_svc.insert(- calendarId=cal_id, body=event, sendUpdates=params.send_updates,- ).execute())+ result = await run_sync(+ lambda: events_svc.insert(+ calendarId=cal_id,+ body=event,+ sendUpdates=params.send_updates,+ ).execute()+ )await track_google_usage("google_calendar", ctx.node_id, "create", 1, ctx.raw)return CalendarOutput(operation="create",- event_id=result.get('id'),- title=result.get('summary'),- start=result.get('start', {}).get('dateTime'),- end=result.get('end', {}).get('dateTime'),- html_link=result.get('htmlLink'),- status=result.get('status'),- created=result.get('created'),+ event_id=result.get("id"),+ title=result.get("summary"),+ start=result.get("start", {}).get("dateTime"),+ end=result.get("end", {}).get("dateTime"),+ html_link=result.get("htmlLink"),+ status=result.get("status"),+ created=result.get("created"),)if op == "list":@@ -164,25 +171,31 @@ class CalendarNode(ActionNode):time_max = _iso_or_shortcut(params.end_date, default_offset_days=7)single = params.single_eventskwargs = dict(- calendarId=cal_id, timeMin=time_min, timeMax=time_max,- maxResults=min(params.max_results, 250), singleEvents=single,+ calendarId=cal_id,+ timeMin=time_min,+ timeMax=time_max,+ maxResults=min(params.max_results, 250),+ singleEvents=single,)if single:- kwargs['orderBy'] = params.order_by+ kwargs["orderBy"] = params.order_byresult = await run_sync(lambda: events_svc.list(**kwargs).execute())- raw = result.get('items', [])- formatted = [{- "event_id": e.get('id'),- "title": e.get('summary', 'No Title'),- "start": e.get('start', {}).get('dateTime', e.get('start', {}).get('date')),- "end": e.get('end', {}).get('dateTime', e.get('end', {}).get('date')),- "description": e.get('description', ''),- "location": e.get('location', ''),- "status": e.get('status'),- "html_link": e.get('htmlLink'),- "attendees": [a.get('email') for a in e.get('attendees', [])],- } for e in raw]+ raw = result.get("items", [])+ formatted = [+ {+ "event_id": e.get("id"),+ "title": e.get("summary", "No Title"),+ "start": e.get("start", {}).get("dateTime", e.get("start", {}).get("date")),+ "end": e.get("end", {}).get("dateTime", e.get("end", {}).get("date")),+ "description": e.get("description", ""),+ "location": e.get("location", ""),+ "status": e.get("status"),+ "html_link": e.get("htmlLink"),+ "attendees": [a.get("email") for a in e.get("attendees", [])],+ }+ for e in raw+ ]await track_google_usage("google_calendar", ctx.node_id, "list", len(formatted), ctx.raw)return CalendarOutput(operation="list",@@ -196,9 +209,13 @@ class CalendarNode(ActionNode):raise RuntimeError("Event ID is required")if op == "delete":- await run_sync(lambda: events_svc.delete(- calendarId=cal_id, eventId=params.event_id, sendUpdates=params.send_updates,- ).execute())+ await run_sync(+ lambda: events_svc.delete(+ calendarId=cal_id,+ eventId=params.event_id,+ sendUpdates=params.send_updates,+ ).execute()+ )await track_google_usage("google_calendar", ctx.node_id, "delete", 1, ctx.raw)return CalendarOutput(operation="delete", deleted=True, event_id=params.event_id)@@ -210,31 +227,35 @@ class CalendarNode(ActionNode):loc = params.update_location if params.update_location is not None else params.locationif title:- event['summary'] = title+ event["summary"] = titleif start:- tz = event.get('start', {}).get('timeZone', 'UTC')- event['start'] = {'dateTime': start, 'timeZone': tz}+ tz = event.get("start", {}).get("timeZone", "UTC")+ event["start"] = {"dateTime": start, "timeZone": tz}if end:- tz = event.get('end', {}).get('timeZone', 'UTC')- event['end'] = {'dateTime': end, 'timeZone': tz}+ tz = event.get("end", {}).get("timeZone", "UTC")+ event["end"] = {"dateTime": end, "timeZone": tz}if desc is not None:- event['description'] = desc+ event["description"] = descif loc is not None:- event['location'] = loc-- result = await run_sync(lambda: events_svc.update(- calendarId=cal_id, eventId=params.event_id, body=event,- sendUpdates=params.send_updates,- ).execute())+ event["location"] = loc++ result = await run_sync(+ lambda: events_svc.update(+ calendarId=cal_id,+ eventId=params.event_id,+ body=event,+ sendUpdates=params.send_updates,+ ).execute()+ )await track_google_usage("google_calendar", ctx.node_id, "update", 1, ctx.raw)return CalendarOutput(operation="update",- event_id=result.get('id'),- title=result.get('summary'),- start=result.get('start', {}).get('dateTime'),- end=result.get('end', {}).get('dateTime'),- updated=result.get('updated'),- html_link=result.get('htmlLink'),+ event_id=result.get("id"),+ title=result.get("summary"),+ start=result.get("start", {}).get("dateTime"),+ end=result.get("end", {}).get("dateTime"),+ updated=result.get("updated"),+ html_link=result.get("htmlLink"),)raise RuntimeError(f"Unknown Calendar operation: {op}")diff --git a/server/nodes/google/contacts/__init__.py b/server/nodes/google/contacts/__init__.pyindex ad3009ef..3d883d13 100644--- a/server/nodes/google/contacts/__init__.py+++ b/server/nodes/google/contacts/__init__.py@@ -41,8 +41,10 @@ class ContactsParams(BaseModel):page_size: int = Field(default=100, ge=1, le=1000, json_schema_extra=_LIST_OR_SEARCH)page_token: Optional[str] = Field(default=None, json_schema_extra=_LIST)sort_order: Literal[- "LAST_MODIFIED_ASCENDING", "LAST_MODIFIED_DESCENDING",- "FIRST_NAME_ASCENDING", "LAST_NAME_ASCENDING",+ "LAST_MODIFIED_ASCENDING",+ "LAST_MODIFIED_DESCENDING",+ "FIRST_NAME_ASCENDING",+ "LAST_NAME_ASCENDING",] = Field(default="LAST_MODIFIED_DESCENDING", json_schema_extra=_LIST)# Update-only@@ -70,30 +72,30 @@ class ContactsOutput(BaseModel):def _format_contact(person: Dict[str, Any]) -> Dict[str, Any]:- names = person.get('names', [{}])- emails = person.get('emailAddresses', [])- phones = person.get('phoneNumbers', [])- orgs = person.get('organizations', [])- photos = person.get('photos', [])+ names = person.get("names", [{}])+ emails = person.get("emailAddresses", [])+ phones = person.get("phoneNumbers", [])+ orgs = person.get("organizations", [])+ photos = person.get("photos", [])primary_name = names[0] if names else {}- primary_email = next((e for e in emails if e.get('metadata', {}).get('primary')), emails[0] if emails else {})- primary_phone = next((p for p in phones if p.get('metadata', {}).get('primary')), phones[0] if phones else {})+ primary_email = next((e for e in emails if e.get("metadata", {}).get("primary")), emails[0] if emails else {})+ primary_phone = next((p for p in phones if p.get("metadata", {}).get("primary")), phones[0] if phones else {})primary_org = orgs[0] if orgs else {}- primary_photo = next((p for p in photos if p.get('metadata', {}).get('primary')), photos[0] if photos else {})+ primary_photo = next((p for p in photos if p.get("metadata", {}).get("primary")), photos[0] if photos else {})return {- 'resource_name': person.get('resourceName'),- 'display_name': primary_name.get('displayName', ''),- 'given_name': primary_name.get('givenName', ''),- 'family_name': primary_name.get('familyName', ''),- 'email': primary_email.get('value', ''),- 'phone': primary_phone.get('value', ''),- 'company': primary_org.get('name', ''),- 'job_title': primary_org.get('title', ''),- 'photo_url': primary_photo.get('url', ''),- 'emails': [e.get('value') for e in emails],- 'phones': [p.get('value') for p in phones],+ "resource_name": person.get("resourceName"),+ "display_name": primary_name.get("displayName", ""),+ "given_name": primary_name.get("givenName", ""),+ "family_name": primary_name.get("familyName", ""),+ "email": primary_email.get("value", ""),+ "phone": primary_phone.get("value", ""),+ "company": primary_org.get("name", ""),+ "job_title": primary_org.get("title", ""),+ "photo_url": primary_photo.get("url", ""),+ "emails": [e.get("value") for e in emails],+ "phones": [p.get("value") for p in phones],}@@ -107,10 +109,8 @@ class ContactsNode(ActionNode):tool_name = "google_contacts"tool_description = "Manage Google Contacts. Operations: create (new contact), list (browse), search (find by name/email/phone), get (details by resource name), update (modify), delete (remove)."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}credentials = (GoogleCredential,)@@ -130,16 +130,16 @@ class ContactsNode(ActionNode):if not params.first_name:raise RuntimeError("First name is required")body: Dict[str, Any] = {- 'names': [{'givenName': params.first_name, 'familyName': params.last_name or ''}],+ "names": [{"givenName": params.first_name, "familyName": params.last_name or ""}],}if params.email:- body['emailAddresses'] = [{'value': params.email}]+ body["emailAddresses"] = [{"value": params.email}]if params.phone:- body['phoneNumbers'] = [{'value': params.phone}]+ body["phoneNumbers"] = [{"value": params.phone}]if params.company or params.job_title:- body['organizations'] = [{'name': params.company or '', 'title': params.job_title or ''}]+ body["organizations"] = [{"name": params.company or "", "title": params.job_title or ""}]if params.notes:- body['biographies'] = [{'value': params.notes, 'contentType': 'TEXT_PLAIN'}]+ body["biographies"] = [{"value": params.notes, "contentType": "TEXT_PLAIN"}]result = await run_sync(lambda: people_svc.createContact(body=body).execute())await track_google_usage("google_contacts", ctx.node_id, "create", 1, ctx.raw)@@ -147,44 +147,48 @@ class ContactsNode(ActionNode):if op == "list":list_kwargs = {- 'resourceName': 'people/me',- 'pageSize': params.page_size,- 'personFields': 'names,emailAddresses,phoneNumbers,organizations,photos,biographies',- 'sortOrder': params.sort_order,+ "resourceName": "people/me",+ "pageSize": params.page_size,+ "personFields": "names,emailAddresses,phoneNumbers,organizations,photos,biographies",+ "sortOrder": params.sort_order,}if params.page_token:- list_kwargs['pageToken'] = params.page_token+ list_kwargs["pageToken"] = params.page_tokenresult = await run_sync(lambda: people_svc.connections().list(**list_kwargs).execute())- connections = result.get('connections', [])+ connections = result.get("connections", [])contacts = [_format_contact(p) for p in connections]await track_google_usage("google_contacts", ctx.node_id, "list", len(contacts), ctx.raw)return ContactsOutput(operation="list",contacts=contacts,count=len(contacts),- total_people=result.get('totalPeople', 0),- next_page_token=result.get('nextPageToken'),+ total_people=result.get("totalPeople", 0),+ next_page_token=result.get("nextPageToken"),)if op == "search":if not params.query:raise RuntimeError("Search query is required")- result = await run_sync(lambda: people_svc.searchContacts(- query=params.query,- pageSize=min(params.page_size, 30),- readMask='names,emailAddresses,phoneNumbers,organizations,photos',- ).execute())- contacts = [_format_contact(r.get('person', {})) for r in result.get('results', [])]+ result = await run_sync(+ lambda: people_svc.searchContacts(+ query=params.query,+ pageSize=min(params.page_size, 30),+ readMask="names,emailAddresses,phoneNumbers,organizations,photos",+ ).execute()+ )+ contacts = [_format_contact(r.get("person", {})) for r in result.get("results", [])]await track_google_usage("google_contacts", ctx.node_id, "search", len(contacts), ctx.raw)return ContactsOutput(operation="search", contacts=contacts, count=len(contacts))if op == "get":if not params.resource_name:raise RuntimeError("Resource name is required")- result = await run_sync(lambda: people_svc.get(- resourceName=params.resource_name,- personFields='names,emailAddresses,phoneNumbers,organizations,photos,biographies,addresses',- ).execute())+ result = await run_sync(+ lambda: people_svc.get(+ resourceName=params.resource_name,+ personFields="names,emailAddresses,phoneNumbers,organizations,photos,biographies,addresses",+ ).execute()+ )await track_google_usage("google_contacts", ctx.node_id, "get", 1, ctx.raw)return ContactsOutput(operation="get", contact=_format_contact(result))@@ -199,10 +203,12 @@ class ContactsNode(ActionNode):if not params.resource_name:raise RuntimeError("Resource name is required")- current = await run_sync(lambda: people_svc.get(- resourceName=params.resource_name,- personFields='names,emailAddresses,phoneNumbers,organizations,metadata',- ).execute())+ current = await run_sync(+ lambda: people_svc.get(+ resourceName=params.resource_name,+ personFields="names,emailAddresses,phoneNumbers,organizations,metadata",+ ).execute()+ )first = params.update_first_name or params.first_namelast = params.update_last_name or params.last_name@@ -211,34 +217,38 @@ class ContactsNode(ActionNode):company = params.update_company or params.companyjob_title = params.update_job_title or params.job_title- body: Dict[str, Any] = {'etag': current.get('etag')}+ body: Dict[str, Any] = {"etag": current.get("etag")}update_fields: List[str] = []if first or last:- cur_names = current.get('names', [{}])[0]- body['names'] = [{- 'givenName': first or cur_names.get('givenName', ''),- 'familyName': last or cur_names.get('familyName', ''),- }]- update_fields.append('names')+ cur_names = current.get("names", [{}])[0]+ body["names"] = [+ {+ "givenName": first or cur_names.get("givenName", ""),+ "familyName": last or cur_names.get("familyName", ""),+ }+ ]+ update_fields.append("names")if email:- body['emailAddresses'] = [{'value': email}]- update_fields.append('emailAddresses')+ body["emailAddresses"] = [{"value": email}]+ update_fields.append("emailAddresses")if phone:- body['phoneNumbers'] = [{'value': phone}]- update_fields.append('phoneNumbers')+ body["phoneNumbers"] = [{"value": phone}]+ update_fields.append("phoneNumbers")if company or job_title:- body['organizations'] = [{'name': company or '', 'title': job_title or ''}]- update_fields.append('organizations')+ body["organizations"] = [{"name": company or "", "title": job_title or ""}]+ update_fields.append("organizations")if not update_fields:raise RuntimeError("At least one field to update is required")- result = await run_sync(lambda: people_svc.updateContact(- resourceName=params.resource_name,- body=body,- updatePersonFields=','.join(update_fields),- ).execute())+ result = await run_sync(+ lambda: people_svc.updateContact(+ resourceName=params.resource_name,+ body=body,+ updatePersonFields=",".join(update_fields),+ ).execute()+ )await track_google_usage("google_contacts", ctx.node_id, "update", 1, ctx.raw)return ContactsOutput(operation="update", contact=_format_contact(result))diff --git a/server/nodes/google/drive/__init__.py b/server/nodes/google/drive/__init__.pyindex bff98351..addc04b0 100644--- a/server/nodes/google/drive/__init__.py+++ b/server/nodes/google/drive/__init__.py@@ -86,10 +86,10 @@ class DriveOutput(BaseModel):_FILE_TYPE_QUERY = {- 'folder': "mimeType = 'application/vnd.google-apps.folder'",- 'document': "mimeType = 'application/vnd.google-apps.document'",- 'spreadsheet': "mimeType = 'application/vnd.google-apps.spreadsheet'",- 'image': "mimeType contains 'image/'",+ "folder": "mimeType = 'application/vnd.google-apps.folder'",+ "document": "mimeType = 'application/vnd.google-apps.document'",+ "spreadsheet": "mimeType = 'application/vnd.google-apps.spreadsheet'",+ "image": "mimeType contains 'image/'",}@@ -103,10 +103,8 @@ class DriveNode(ActionNode):tool_name = "google_drive"tool_description = "Manage Google Drive files. Operations: upload (add file from URL), download (get file by ID), list (find files), share (share with user)."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}credentials = (GoogleCredential,)@@ -128,11 +126,11 @@ class DriveNode(ActionNode):if not params.file_url and not params.file_content:raise RuntimeError("Either file_url or file_content is required")- metadata = {'name': params.filename}+ metadata = {"name": params.filename}if params.folder_id:- metadata['parents'] = [params.folder_id]+ metadata["parents"] = [params.folder_id]if params.description:- metadata['description'] = params.description+ metadata["description"] = params.descriptionmime_type = params.mime_typeif params.file_url:@@ -140,47 +138,52 @@ class DriveNode(ActionNode):resp = await client.get(params.file_url, timeout=60.0)resp.raise_for_status()file_bytes = resp.content- if mime_type == 'application/octet-stream' and 'content-type' in resp.headers:- mime_type = resp.headers['content-type'].split(';')[0]+ if mime_type == "application/octet-stream" and "content-type" in resp.headers:+ mime_type = resp.headers["content-type"].split(";")[0]else:file_bytes = base64.b64decode(params.file_content)media = MediaIoBaseUpload(io.BytesIO(file_bytes), mimetype=mime_type, resumable=True)- result = await run_sync(lambda: files_svc.create(- body=metadata, media_body=media,- fields='id, name, mimeType, size, webViewLink, webContentLink, createdTime',- ).execute())+ result = await run_sync(+ lambda: files_svc.create(+ body=metadata,+ media_body=media,+ fields="id, name, mimeType, size, webViewLink, webContentLink, createdTime",+ ).execute()+ )await track_google_usage("google_drive", ctx.node_id, "upload", 1, ctx.raw)return DriveOutput(operation="upload",- file_id=result.get('id'),- name=result.get('name'),- mime_type=result.get('mimeType'),- size=int(result.get('size')) if result.get('size') else None,- web_link=result.get('webViewLink'),- download_link=result.get('webContentLink'),- created_time=result.get('createdTime'),+ file_id=result.get("id"),+ name=result.get("name"),+ mime_type=result.get("mimeType"),+ size=int(result.get("size")) if result.get("size") else None,+ web_link=result.get("webViewLink"),+ download_link=result.get("webContentLink"),+ created_time=result.get("createdTime"),)if op == "download":if not params.file_id:raise RuntimeError("File ID is required")- metadata = await run_sync(lambda: files_svc.get(- fileId=params.file_id,- fields='id, name, mimeType, size, webViewLink, webContentLink',- ).execute())+ metadata = await run_sync(+ lambda: files_svc.get(+ fileId=params.file_id,+ fields="id, name, mimeType, size, webViewLink, webContentLink",+ ).execute()+ )if params.output_format == "url":await track_google_usage("google_drive", ctx.node_id, "download", 1, ctx.raw)return DriveOutput(operation="download",- file_id=metadata.get('id'),- name=metadata.get('name'),- mime_type=metadata.get('mimeType'),- size=int(metadata.get('size')) if metadata.get('size') else None,- download_url=metadata.get('webContentLink'),- web_link=metadata.get('webViewLink'),+ file_id=metadata.get("id"),+ name=metadata.get("name"),+ mime_type=metadata.get("mimeType"),+ size=int(metadata.get("size")) if metadata.get("size") else None,+ download_url=metadata.get("webContentLink"),+ web_link=metadata.get("webViewLink"),)def _download():@@ -196,11 +199,11 @@ class DriveNode(ActionNode):await track_google_usage("google_drive", ctx.node_id, "download", 1, ctx.raw)return DriveOutput(operation="download",- file_id=metadata.get('id'),- name=metadata.get('name'),- mime_type=metadata.get('mimeType'),+ file_id=metadata.get("id"),+ name=metadata.get("name"),+ mime_type=metadata.get("mimeType"),size=len(file_bytes),- content_base64=base64.b64encode(file_bytes).decode('utf-8'),+ content_base64=base64.b64encode(file_bytes).decode("utf-8"),)if op == "list":@@ -212,36 +215,39 @@ class DriveNode(ActionNode):if params.file_types in _FILE_TYPE_QUERY:query_parts.append(_FILE_TYPE_QUERY[params.file_types])query_parts.append("trashed = false")- full_query = ' and '.join(query_parts)+ full_query = " and ".join(query_parts)list_kwargs = {- 'pageSize': min(params.max_results, 1000),- 'fields': 'nextPageToken, files(id, name, mimeType, size, webViewLink, webContentLink, createdTime, modifiedTime, parents, owners)',- 'orderBy': params.order_by,+ "pageSize": min(params.max_results, 1000),+ "fields": "nextPageToken, files(id, name, mimeType, size, webViewLink, webContentLink, createdTime, modifiedTime, parents, owners)",+ "orderBy": params.order_by,}if full_query:- list_kwargs['q'] = full_query+ list_kwargs["q"] = full_queryresult = await run_sync(lambda: files_svc.list(**list_kwargs).execute())- raw = result.get('files', [])- formatted = [{- "file_id": f.get('id'),- "name": f.get('name'),- "mime_type": f.get('mimeType'),- "size": f.get('size'),- "web_link": f.get('webViewLink'),- "download_link": f.get('webContentLink'),- "created_time": f.get('createdTime'),- "modified_time": f.get('modifiedTime'),- "parent_ids": f.get('parents', []),- "owner": f.get('owners', [{}])[0].get('emailAddress') if f.get('owners') else None,- } for f in raw]+ raw = result.get("files", [])+ formatted = [+ {+ "file_id": f.get("id"),+ "name": f.get("name"),+ "mime_type": f.get("mimeType"),+ "size": f.get("size"),+ "web_link": f.get("webViewLink"),+ "download_link": f.get("webContentLink"),+ "created_time": f.get("createdTime"),+ "modified_time": f.get("modifiedTime"),+ "parent_ids": f.get("parents", []),+ "owner": f.get("owners", [{}])[0].get("emailAddress") if f.get("owners") else None,+ }+ for f in raw+ ]await track_google_usage("google_drive", ctx.node_id, "list", len(formatted), ctx.raw)return DriveOutput(operation="list",files=formatted,count=len(formatted),- next_page_token=result.get('nextPageToken'),+ next_page_token=result.get("nextPageToken"),)if op == "share":@@ -250,25 +256,32 @@ class DriveNode(ActionNode):if not params.email:raise RuntimeError("Email address is required")- perm = await run_sync(lambda: svc.permissions().create(- fileId=params.file_id,- body={'type': 'user', 'role': params.role, 'emailAddress': params.email},- sendNotificationEmail=params.send_notification,- emailMessage=params.message or None,- fields='id, type, role, emailAddress',- ).execute())- file_info = await run_sync(lambda: files_svc.get(- fileId=params.file_id, fields='id, name, webViewLink',- ).execute())+ perm = await run_sync(+ lambda: svc.permissions()+ .create(+ fileId=params.file_id,+ body={"type": "user", "role": params.role, "emailAddress": params.email},+ sendNotificationEmail=params.send_notification,+ emailMessage=params.message or None,+ fields="id, type, role, emailAddress",+ )+ .execute()+ )+ file_info = await run_sync(+ lambda: files_svc.get(+ fileId=params.file_id,+ fields="id, name, webViewLink",+ ).execute()+ )await track_google_usage("google_drive", ctx.node_id, "share", 1, ctx.raw)return DriveOutput(operation="share",- permission_id=perm.get('id'),+ permission_id=perm.get("id"),file_id=params.file_id,- file_name=file_info.get('name'),+ file_name=file_info.get("name"),shared_with=params.email,role=params.role,- web_link=file_info.get('webViewLink'),+ web_link=file_info.get("webViewLink"),)raise RuntimeError(f"Unknown Drive operation: {op}")diff --git a/server/nodes/google/gmail/__init__.py b/server/nodes/google/gmail/__init__.pyindex 4a72e3f6..88633545 100644--- a/server/nodes/google/gmail/__init__.py+++ b/server/nodes/google/gmail/__init__.py@@ -51,7 +51,9 @@ class GmailParams(BaseModel):},)max_results: int = Field(- default=10, ge=1, le=100,+ default=10,+ ge=1,+ le=100,json_schema_extra={"displayOptions": {"show": {"operation": ["search"]}}},)include_body: bool = Field(@@ -100,12 +102,12 @@ class GmailNode(ActionNode):description = "Google Gmail send / search / read (dual-purpose workflow + AI tool)"component_kind = "square"tool_name = "google_gmail"- tool_description = "Send, search, and read emails via Gmail. Operations: send (compose email), search (find emails by query), read (get email by ID)."+ tool_description = (+ "Send, search, and read emails via Gmail. Operations: send (compose email), search (find emails by query), read (get email by ID)."+ )handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)credentials = (GoogleCredential,)annotations = {"destructive": False, "readonly": False, "open_world": True}@@ -117,7 +119,10 @@ class GmailNode(ActionNode):async def _service(self, ctx: NodeContext, params: GmailParams):return await build_google_service(- "gmail", "v1", params.model_dump(), ctx.raw,+ "gmail",+ "v1",+ params.model_dump(),+ ctx.raw,)@Operation("send", cost={"service": "gmail", "action": "send", "count": 1})@@ -130,28 +135,34 @@ class GmailNode(ActionNode):raise RuntimeError("Email body is required")if params.body_type == "html":- message = MIMEMultipart('alternative')- message.attach(MIMEText(params.body, 'html'))+ message = MIMEMultipart("alternative")+ message.attach(MIMEText(params.body, "html"))else:- message = MIMEText(params.body, 'plain')- message['to'] = params.to- message['subject'] = params.subject+ message = MIMEText(params.body, "plain")+ message["to"] = params.to+ message["subject"] = params.subjectif params.cc:- message['cc'] = params.cc+ message["cc"] = params.ccif params.bcc:- message['bcc'] = params.bcc+ message["bcc"] = params.bcc- raw = base64.urlsafe_b64encode(message.as_bytes()).decode('utf-8')+ raw = base64.urlsafe_b64encode(message.as_bytes()).decode("utf-8")svc = await self._service(ctx, params)- result = await run_sync(lambda: svc.users().messages().send(- userId='me', body={'raw': raw},- ).execute())+ result = await run_sync(+ lambda: svc.users()+ .messages()+ .send(+ userId="me",+ body={"raw": raw},+ )+ .execute()+ )await track_google_usage("gmail", ctx.node_id, "send", 1, ctx.raw)return GmailOutput(operation="send",- message_id=result.get('id'),- thread_id=result.get('threadId'),- label_ids=result.get('labelIds', []),+ message_id=result.get("id"),+ thread_id=result.get("threadId"),+ label_ids=result.get("labelIds", []),to=params.to,subject=params.subject,)@@ -161,19 +172,33 @@ class GmailNode(ActionNode):if not params.query:raise RuntimeError("Search query is required")svc = await self._service(ctx, params)- listing = await run_sync(lambda: svc.users().messages().list(- userId='me', q=params.query, maxResults=min(params.max_results, 100),- ).execute())+ listing = await run_sync(+ lambda: svc.users()+ .messages()+ .list(+ userId="me",+ q=params.query,+ maxResults=min(params.max_results, 100),+ )+ .execute()+ )- messages = listing.get('messages', [])+ messages = listing.get("messages", [])formatted = []- fmt = 'full' if params.include_body else 'metadata'+ fmt = "full" if params.include_body else "metadata"for msg in messages:- mid = msg.get('id')- detail = await run_sync(lambda m=mid: svc.users().messages().get(- userId='me', id=m, format=fmt,- metadataHeaders=['From', 'To', 'Subject', 'Date'],- ).execute())+ mid = msg.get("id")+ detail = await run_sync(+ lambda m=mid: svc.users()+ .messages()+ .get(+ userId="me",+ id=m,+ format=fmt,+ metadataHeaders=["From", "To", "Subject", "Date"],+ )+ .execute()+ )formatted.append(format_message(detail, include_body=params.include_body))await track_google_usage("gmail", ctx.node_id, "search", len(formatted), ctx.raw)@@ -182,7 +207,7 @@ class GmailNode(ActionNode):messages=formatted,count=len(formatted),query=params.query,- result_size_estimate=listing.get('resultSizeEstimate', 0),+ result_size_estimate=listing.get("resultSizeEstimate", 0),)@Operation("read", cost={"service": "gmail", "action": "read", "count": 1})@@ -190,9 +215,16 @@ class GmailNode(ActionNode):if not params.message_id:raise RuntimeError("message_id is required")svc = await self._service(ctx, params)- result = await run_sync(lambda: svc.users().messages().get(- userId='me', id=params.message_id, format=params.format,- ).execute())+ result = await run_sync(+ lambda: svc.users()+ .messages()+ .get(+ userId="me",+ id=params.message_id,+ format=params.format,+ )+ .execute()+ )await track_google_usage("gmail", ctx.node_id, "read", 1, ctx.raw)- formatted = format_message(result, include_body=(params.format == 'full'))- return GmailOutput(operation="read", **{k: v for k, v in formatted.items() if k != 'size_estimate'})+ formatted = format_message(result, include_body=(params.format == "full"))+ return GmailOutput(operation="read", **{k: v for k, v in formatted.items() if k != "size_estimate"})diff --git a/server/nodes/google/gmail_receive/__init__.py b/server/nodes/google/gmail_receive/__init__.pyindex 1356df31..52074b72 100644--- a/server/nodes/google/gmail_receive/__init__.py+++ b/server/nodes/google/gmail_receive/__init__.py@@ -11,7 +11,10 @@ from pydantic import BaseModel, ConfigDict, Fieldfrom core.logging import get_loggerfrom services.plugin import (- NodeContext, Operation, PollingTriggerNode, TaskQueue,+ NodeContext,+ Operation,+ PollingTriggerNode,+ TaskQueue,)from .._credentials import GoogleCredential@@ -69,10 +72,7 @@ class GmailReceiveNode(PollingTriggerNode):group = ("google", "trigger")description = "Polling trigger for incoming Gmail emails"component_kind = "trigger"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)credentials = (GoogleCredential,)task_queue = TaskQueue.TRIGGERS_POLLdefault_poll_interval = 60@@ -94,14 +94,10 @@ class GmailReceiveNode(PollingTriggerNode):async def fetch_ids(self, service: Any, params: Dict[str, Any]) -> Set[str]:return await poll_gmail_ids(service, self._build_query(params))- async def fetch_detail(- self, service: Any, msg_id: str, params: Dict[str, Any]- ) -> Dict[str, Any]:+ async def fetch_detail(self, service: Any, msg_id: str, params: Dict[str, Any]) -> Dict[str, Any]:return await fetch_email_details(service, msg_id)- async def post_emit(- self, service: Any, msg_id: str, params: Dict[str, Any]- ) -> None:+ async def post_emit(self, service: Any, msg_id: str, params: Dict[str, Any]) -> None:if params.get("mark_as_read"):try:await mark_email_as_read(service, msg_id)@@ -130,7 +126,8 @@ class GmailReceiveNode(PollingTriggerNode):query = f"label:{label_filter} {query}"await get_status_broadcaster().update_node_status(- node_id, "waiting",+ node_id,+ "waiting",{"message": f"Waiting for Gmail email (polling every {poll_interval}s)...","event_type": "gmail_email_received",@@ -166,7 +163,10 @@ class GmailReceiveNode(PollingTriggerNode):logger.warning(f"[GmailReceive] Failed to mark as read: {e}")await track_google_usage(- "gmail", node_id, "receive", 1,+ "gmail",+ node_id,+ "receive",+ 1,{"workflow_id": context.workflow_id, "session_id": context.session_id},)# Inline Run path: the node returns ``email_data`` as@@ -178,7 +178,9 @@ class GmailReceiveNode(PollingTriggerNode):f"[GmailReceive] New email: {email_data.get('subject', 'no subject')}",)return {- "success": True, "node_id": node_id, "node_type": self.type,+ "success": True,+ "node_id": node_id,+ "node_type": self.type,"result": email_data,"execution_time": time.time() - start_time,"timestamp": datetime.now().isoformat(),@@ -191,7 +193,9 @@ class GmailReceiveNode(PollingTriggerNode):except asyncio.CancelledError:logger.info(f"[GmailReceive] Cancelled by user: node_id={node_id}")return {- "success": False, "node_id": node_id, "node_type": self.type,+ "success": False,+ "node_id": node_id,+ "node_type": self.type,"error": "Cancelled by user","execution_time": time.time() - start_time,"timestamp": datetime.now().isoformat(),@@ -199,7 +203,9 @@ class GmailReceiveNode(PollingTriggerNode):except Exception as e:logger.error(f"[GmailReceive] Error: {e}")return {- "success": False, "node_id": node_id, "node_type": self.type,+ "success": False,+ "node_id": node_id,+ "node_type": self.type,"error": str(e),"execution_time": time.time() - start_time,"timestamp": datetime.now().isoformat(),@@ -207,6 +213,4 @@ class GmailReceiveNode(PollingTriggerNode):@Operation("wait")async def wait(self, ctx: NodeContext, params: GmailReceiveParams) -> GmailReceiveOutput:- raise NotImplementedError(- "googleGmailReceive uses execute() override (Wave 11.D.5 inlined)."- )+ raise NotImplementedError("googleGmailReceive uses execute() override (Wave 11.D.5 inlined).")diff --git a/server/nodes/google/sheets/__init__.py b/server/nodes/google/sheets/__init__.pyindex 6eb9f79d..4cd4252f 100644--- a/server/nodes/google/sheets/__init__.py+++ b/server/nodes/google/sheets/__init__.py@@ -86,10 +86,8 @@ class SheetsNode(ActionNode):tool_name = "google_sheets"tool_description = "Read and write Google Sheets data. Operations: read (get range), write (set range), append (add rows)."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}credentials = (GoogleCredential,)@@ -111,21 +109,23 @@ class SheetsNode(ActionNode):op = params.operationif op == "read":- result = await run_sync(lambda: values_svc.get(- spreadsheetId=params.spreadsheet_id,- range=params.range,- valueRenderOption=params.value_render_option,- majorDimension=params.major_dimension,- ).execute())- rows = result.get('values', [])+ result = await run_sync(+ lambda: values_svc.get(+ spreadsheetId=params.spreadsheet_id,+ range=params.range,+ valueRenderOption=params.value_render_option,+ majorDimension=params.major_dimension,+ ).execute()+ )+ rows = result.get("values", [])await track_google_usage("google_sheets", ctx.node_id, "read", len(rows), ctx.raw)return SheetsOutput(operation="read",values=rows,- range=result.get('range'),+ range=result.get("range"),rows=len(rows),columns=len(rows[0]) if rows else 0,- major_dimension=result.get('majorDimension'),+ major_dimension=result.get("majorDimension"),)if op in ("write", "append"):@@ -134,43 +134,53 @@ class SheetsNode(ActionNode):raise RuntimeError("Values are required")if op == "write":- result = await run_sync(lambda: values_svc.update(- spreadsheetId=params.spreadsheet_id,- range=params.range,- valueInputOption=params.value_input_option,- body={'values': values},- ).execute())+ result = await run_sync(+ lambda: values_svc.update(+ spreadsheetId=params.spreadsheet_id,+ range=params.range,+ valueInputOption=params.value_input_option,+ body={"values": values},+ ).execute()+ )await track_google_usage(- "google_sheets", ctx.node_id, "write",- result.get('updatedCells', 0), ctx.raw,+ "google_sheets",+ ctx.node_id,+ "write",+ result.get("updatedCells", 0),+ ctx.raw,)return SheetsOutput(operation="write",- updated_range=result.get('updatedRange'),- updated_rows=result.get('updatedRows'),- updated_columns=result.get('updatedColumns'),- updated_cells=result.get('updatedCells'),+ updated_range=result.get("updatedRange"),+ updated_rows=result.get("updatedRows"),+ updated_columns=result.get("updatedColumns"),+ updated_cells=result.get("updatedCells"),)- result = await run_sync(lambda: values_svc.append(- spreadsheetId=params.spreadsheet_id,- range=params.range,- valueInputOption=params.value_input_option,- insertDataOption=params.insert_data_option,- body={'values': values},- ).execute())- updates = result.get('updates', {})+ result = await run_sync(+ lambda: values_svc.append(+ spreadsheetId=params.spreadsheet_id,+ range=params.range,+ valueInputOption=params.value_input_option,+ insertDataOption=params.insert_data_option,+ body={"values": values},+ ).execute()+ )+ updates = result.get("updates", {})await track_google_usage(- "google_sheets", ctx.node_id, "append",- updates.get('updatedCells', 0), ctx.raw,+ "google_sheets",+ ctx.node_id,+ "append",+ updates.get("updatedCells", 0),+ ctx.raw,)return SheetsOutput(operation="append",- updated_range=updates.get('updatedRange'),- updated_rows=updates.get('updatedRows'),- updated_columns=updates.get('updatedColumns'),- updated_cells=updates.get('updatedCells'),- table_range=result.get('tableRange'),+ updated_range=updates.get("updatedRange"),+ updated_rows=updates.get("updatedRows"),+ updated_columns=updates.get("updatedColumns"),+ updated_cells=updates.get("updatedCells"),+ table_range=result.get("tableRange"),)raise RuntimeError(f"Unknown Sheets operation: {op}. Supported: read, write, append")diff --git a/server/nodes/google/tasks/__init__.py b/server/nodes/google/tasks/__init__.pyindex 7241687f..01372db2 100644--- a/server/nodes/google/tasks/__init__.py+++ b/server/nodes/google/tasks/__init__.py@@ -14,7 +14,7 @@ from .._base import build_google_service, run_sync, track_google_usagedef _ensure_rfc3339(due: str) -> str:- return due if 'T' in due else f"{due}T00:00:00.000Z"+ return due if "T" in due else f"{due}T00:00:00.000Z"_CREATE = {"displayOptions": {"show": {"operation": ["create"]}}}@@ -77,10 +77,8 @@ class TasksNode(ActionNode):tool_name = "google_tasks"tool_description = "Manage Google Tasks. Operations: create (new task), list (find tasks), complete (mark done), update (modify task), delete (remove task)."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}credentials = (GoogleCredential,)@@ -100,36 +98,45 @@ class TasksNode(ActionNode):if op == "create":if not params.title:raise RuntimeError("Task title is required")- body = {'title': params.title}+ body = {"title": params.title}if params.notes:- body['notes'] = params.notes+ body["notes"] = params.notesif params.due_date:- body['due'] = _ensure_rfc3339(params.due_date)+ body["due"] = _ensure_rfc3339(params.due_date)result = await run_sync(lambda: tasks_svc.insert(tasklist=tasklist, body=body).execute())await track_google_usage("google_tasks", ctx.node_id, "create", 1, ctx.raw)return TasksOutput(operation="create",- task_id=result.get('id'),- title=result.get('title'),- notes=result.get('notes'),- due=result.get('due'),- status=result.get('status'),- self_link=result.get('selfLink'),+ task_id=result.get("id"),+ title=result.get("title"),+ notes=result.get("notes"),+ due=result.get("due"),+ status=result.get("status"),+ self_link=result.get("selfLink"),)if op == "list":- result = await run_sync(lambda: tasks_svc.list(- tasklist=tasklist,- showCompleted=params.show_completed,- showHidden=params.show_hidden,- maxResults=params.max_results,- ).execute())- items = result.get('items', [])- formatted = [{- 'task_id': t.get('id'), 'title': t.get('title'), 'notes': t.get('notes'),- 'due': t.get('due'), 'status': t.get('status'),- 'completed': t.get('completed'), 'position': t.get('position'),- } for t in items]+ result = await run_sync(+ lambda: tasks_svc.list(+ tasklist=tasklist,+ showCompleted=params.show_completed,+ showHidden=params.show_hidden,+ maxResults=params.max_results,+ ).execute()+ )+ items = result.get("items", [])+ formatted = [+ {+ "task_id": t.get("id"),+ "title": t.get("title"),+ "notes": t.get("notes"),+ "due": t.get("due"),+ "status": t.get("status"),+ "completed": t.get("completed"),+ "position": t.get("position"),+ }+ for t in items+ ]await track_google_usage("google_tasks", ctx.node_id, "list", len(formatted), ctx.raw)return TasksOutput(operation="list", tasks=formatted, count=len(formatted))@@ -145,33 +152,37 @@ class TasksNode(ActionNode):current = await run_sync(lambda: tasks_svc.get(tasklist=tasklist, task=params.task_id).execute())if op == "complete":- current['status'] = 'completed'+ current["status"] = "completed"else:title = params.update_title or params.titlenotes = params.update_notes or params.notesdue = params.update_due_date or params.due_datestatus = params.update_status or params.statusif title:- current['title'] = title+ current["title"] = titleif notes:- current['notes'] = notes+ current["notes"] = notesif due:- current['due'] = _ensure_rfc3339(due)+ current["due"] = _ensure_rfc3339(due)if status:- current['status'] = status-- result = await run_sync(lambda: tasks_svc.update(- tasklist=tasklist, task=params.task_id, body=current,- ).execute())+ current["status"] = status++ result = await run_sync(+ lambda: tasks_svc.update(+ tasklist=tasklist,+ task=params.task_id,+ body=current,+ ).execute()+ )await track_google_usage("google_tasks", ctx.node_id, op, 1, ctx.raw)return TasksOutput(operation=op,- task_id=result.get('id'),- title=result.get('title'),- notes=result.get('notes'),- due=result.get('due'),- status=result.get('status'),- completed=result.get('completed'),+ task_id=result.get("id"),+ title=result.get("title"),+ notes=result.get("notes"),+ due=result.get("due"),+ status=result.get("status"),+ completed=result.get("completed"),)raise RuntimeError(f"Unknown Tasks operation: {op}")diff --git a/server/nodes/groups.py b/server/nodes/groups.pyindex bd70e069..0ad96ad9 100644--- a/server/nodes/groups.py+++ b/server/nodes/groups.py@@ -22,37 +22,37 @@ from services.node_registry import register_group# Normal-mode groups (visible in simple mode — the core agent building blocks)# ----------------------------------------------------------------------------register_group(key="agent", metadata={"label": "AI Agents", "icon": "🤖", "color": "#bd93f9", "visibility": "normal"})-register_group(key="model", metadata={"label": "AI Models", "icon": "🧬", "color": "#8be9fd", "visibility": "normal"})-register_group(key="skill", metadata={"label": "AI Skills", "icon": "🎯", "color": "#50fa7b", "visibility": "normal"})-register_group(key="tool", metadata={"label": "AI Tools", "icon": "🛠️", "color": "#50fa7b", "visibility": "normal"})+register_group(key="agent", metadata={"label": "AI Agents", "icon": "🤖", "color": "#bd93f9", "visibility": "normal"})+register_group(key="model", metadata={"label": "AI Models", "icon": "🧬", "color": "#8be9fd", "visibility": "normal"})+register_group(key="skill", metadata={"label": "AI Skills", "icon": "🎯", "color": "#50fa7b", "visibility": "normal"})+register_group(key="tool", metadata={"label": "AI Tools", "icon": "🛠️", "color": "#50fa7b", "visibility": "normal"})# ---------------------------------------------------------------------------# Dev-mode groups (shown when pro/dev mode is toggled on)# ----------------------------------------------------------------------------register_group(key="workflow", metadata={"label": "Workflows", "icon": "⚡", "color": "#ffb86c", "visibility": "dev"})-register_group(key="trigger", metadata={"label": "Triggers", "icon": "🕐", "color": "#ff79c6", "visibility": "dev"})-register_group(key="ai", metadata={"label": "AI", "icon": "🤖", "color": "#bd93f9", "visibility": "dev"})-register_group(key="location", metadata={"label": "Location", "icon": "📍", "color": "#ff5555", "visibility": "dev"})-register_group(key="social", metadata={"label": "Social", "icon": "📱", "color": "#50fa7b", "visibility": "dev"})-register_group(key="android", metadata={"label": "Android", "icon": "📱", "color": "#8be9fd", "visibility": "dev"})-register_group(key="chat", metadata={"label": "Chat", "icon": "💭", "color": "#f1fa8c", "visibility": "dev"})-register_group(key="code", metadata={"label": "Code", "icon": "💻", "color": "#ffb86c", "visibility": "dev"})-register_group(key="document", metadata={"label": "Documents", "icon": "🗄️", "color": "#ff79c6", "visibility": "dev"})-register_group(key="utility", metadata={"label": "Utilities", "icon": "🔧", "color": "#bd93f9", "visibility": "dev"})-register_group(key="api", metadata={"label": "API & Scraping", "icon": "🕷️", "color": "#ffb86c", "visibility": "dev"})-register_group(key="search", metadata={"label": "Search", "icon": "🔍", "color": "#8be9fd", "visibility": "dev"})-register_group(key="google", metadata={"label": "Google Workspace", "icon": "asset:google", "color": "#4285F4", "visibility": "dev"})-register_group(key="scheduler", metadata={"label": "Schedulers", "icon": "📅", "color": "#ff79c6", "visibility": "dev"})-register_group(key="proxy", metadata={"label": "Proxy", "icon": "🛡", "color": "#bd93f9", "visibility": "dev"})-register_group(key="whatsapp", metadata={"label": "WhatsApp", "icon": "💬", "color": "#25D366", "visibility": "dev"})-register_group(key="email", metadata={"label": "Email", "icon": "✉️", "color": "#8be9fd", "visibility": "dev"})-register_group(key="payments", metadata={"label": "Payments", "icon": "asset:stripe", "color": "#635BFF", "visibility": "dev"})-register_group(key="browser", metadata={"label": "Browser", "icon": "🌐", "color": "#ff79c6", "visibility": "dev"})-register_group(key="scraper", metadata={"label": "Scrapers", "icon": "🕸", "color": "#ff79c6", "visibility": "dev"})-register_group(key="filesystem", metadata={"label": "Filesystem", "icon": "📁", "color": "#8be9fd", "visibility": "dev"})-register_group(key="service", metadata={"label": "Services", "icon": "⚙️", "color": "#50fa7b", "visibility": "dev"})-register_group(key="text", metadata={"label": "Text", "icon": "📝", "color": "#bd93f9", "visibility": "dev"})-register_group(key="memory", metadata={"label": "Memory", "icon": "💾", "color": "#f1fa8c", "visibility": "dev"})+register_group(key="workflow", metadata={"label": "Workflows", "icon": "⚡", "color": "#ffb86c", "visibility": "dev"})+register_group(key="trigger", metadata={"label": "Triggers", "icon": "🕐", "color": "#ff79c6", "visibility": "dev"})+register_group(key="ai", metadata={"label": "AI", "icon": "🤖", "color": "#bd93f9", "visibility": "dev"})+register_group(key="location", metadata={"label": "Location", "icon": "📍", "color": "#ff5555", "visibility": "dev"})+register_group(key="social", metadata={"label": "Social", "icon": "📱", "color": "#50fa7b", "visibility": "dev"})+register_group(key="android", metadata={"label": "Android", "icon": "📱", "color": "#8be9fd", "visibility": "dev"})+register_group(key="chat", metadata={"label": "Chat", "icon": "💭", "color": "#f1fa8c", "visibility": "dev"})+register_group(key="code", metadata={"label": "Code", "icon": "💻", "color": "#ffb86c", "visibility": "dev"})+register_group(key="document", metadata={"label": "Documents", "icon": "🗄️", "color": "#ff79c6", "visibility": "dev"})+register_group(key="utility", metadata={"label": "Utilities", "icon": "🔧", "color": "#bd93f9", "visibility": "dev"})+register_group(key="api", metadata={"label": "API & Scraping", "icon": "🕷️", "color": "#ffb86c", "visibility": "dev"})+register_group(key="search", metadata={"label": "Search", "icon": "🔍", "color": "#8be9fd", "visibility": "dev"})+register_group(key="google", metadata={"label": "Google Workspace", "icon": "asset:google", "color": "#4285F4", "visibility": "dev"})+register_group(key="scheduler", metadata={"label": "Schedulers", "icon": "📅", "color": "#ff79c6", "visibility": "dev"})+register_group(key="proxy", metadata={"label": "Proxy", "icon": "🛡", "color": "#bd93f9", "visibility": "dev"})+register_group(key="whatsapp", metadata={"label": "WhatsApp", "icon": "💬", "color": "#25D366", "visibility": "dev"})+register_group(key="email", metadata={"label": "Email", "icon": "✉️", "color": "#8be9fd", "visibility": "dev"})+register_group(key="payments", metadata={"label": "Payments", "icon": "asset:stripe", "color": "#635BFF", "visibility": "dev"})+register_group(key="browser", metadata={"label": "Browser", "icon": "🌐", "color": "#ff79c6", "visibility": "dev"})+register_group(key="scraper", metadata={"label": "Scrapers", "icon": "🕸", "color": "#ff79c6", "visibility": "dev"})+register_group(key="filesystem", metadata={"label": "Filesystem", "icon": "📁", "color": "#8be9fd", "visibility": "dev"})+register_group(key="service", metadata={"label": "Services", "icon": "⚙️", "color": "#50fa7b", "visibility": "dev"})+register_group(key="text", metadata={"label": "Text", "icon": "📝", "color": "#bd93f9", "visibility": "dev"})+register_group(key="memory", metadata={"label": "Memory", "icon": "💾", "color": "#f1fa8c", "visibility": "dev"})diff --git a/server/nodes/location/_credentials.py b/server/nodes/location/_credentials.pyindex 78a2f656..bf449286 100644--- a/server/nodes/location/_credentials.py+++ b/server/nodes/location/_credentials.py@@ -56,9 +56,5 @@ class GoogleMapsCredential(ApiKeyCredential):)return ProbeResult(valid=True,- message=(- "Google Maps API key is valid"- if status == "OK"- else f"API key is valid (status: {status})"- ),+ message=("Google Maps API key is valid" if status == "OK" else f"API key is valid (status: {status})"),)diff --git a/server/nodes/location/_service.py b/server/nodes/location/_service.pyindex 8976c1b6..8613456d 100644--- a/server/nodes/location/_service.py+++ b/server/nodes/location/_service.py@@ -29,11 +29,7 @@ logger = get_logger(__name__)async def _track_maps_usage(- node_id: str,- action: str,- resource_count: int = 1,- workflow_id: str = None,- session_id: str = "default"+ node_id: str, action: str, resource_count: int = 1, workflow_id: str = None, session_id: str = "default") -> Dict[str, float]:"""Track Google Maps API usage for cost calculation.@@ -50,20 +46,22 @@ async def _track_maps_usage(from services.plugin.deps import get_databasepricing = get_pricing_service()- cost_data = pricing.calculate_api_cost('google_maps', action, resource_count)+ cost_data = pricing.calculate_api_cost("google_maps", action, resource_count)# Save to databasedb = get_database()- await db.save_api_usage_metric({- 'session_id': session_id,- 'node_id': node_id,- 'workflow_id': workflow_id,- 'service': 'google_maps',- 'operation': cost_data.get('operation', action),- 'endpoint': action,- 'resource_count': resource_count,- 'cost': cost_data.get('total_cost', 0.0)- })+ await db.save_api_usage_metric(+ {+ "session_id": session_id,+ "node_id": node_id,+ "workflow_id": workflow_id,+ "service": "google_maps",+ "operation": cost_data.get("operation", action),+ "endpoint": action,+ "resource_count": resource_count,+ "cost": cost_data.get("total_cost", 0.0),+ }+ )logger.debug(f"[Maps] Tracked usage: {action} x{resource_count} = ${cost_data.get('total_cost', 0):.6f}")return cost_data@@ -90,38 +88,31 @@ class MapsService:context = context or {}try:- api_key = parameters.get('api_key') or self.settings.google_maps_api_key+ api_key = parameters.get("api_key") or self.settings.google_maps_api_keyif not api_key:raise ValueError("Google Maps API key is required")# Extract and validate parameters (snake_case)- lat = float(parameters.get('lat', 40.7128))- lng = float(parameters.get('lng', -74.0060))- zoom = int(parameters.get('zoom', 13))- map_type = parameters.get('map_type_id', 'ROADMAP')+ lat = float(parameters.get("lat", 40.7128))+ lng = float(parameters.get("lng", -74.0060))+ zoom = int(parameters.get("zoom", 13))+ map_type = parameters.get("map_type_id", "ROADMAP")if not self.validate_coordinates(lat, lng):raise ValueError("Invalid coordinates")if not self.validate_zoom_level(zoom):raise ValueError("Invalid zoom level")- if map_type not in ['ROADMAP', 'SATELLITE', 'HYBRID', 'TERRAIN']:+ if map_type not in ["ROADMAP", "SATELLITE", "HYBRID", "TERRAIN"]:raise ValueError("Invalid map type")result = {- "map_config": {- "center": {"lat": lat, "lng": lng},- "zoom": zoom,- "mapTypeId": map_type- },+ "map_config": {"center": {"lat": lat, "lng": lng}, "zoom": zoom, "mapTypeId": map_type},"static_map_url": f"https://maps.googleapis.com/maps/api/staticmap?center={lat},{lng}&zoom={zoom}&size=600x400&maptype={map_type.lower()}&key={api_key}",- "status": "OK"+ "status": "OK",}# Track: static_map $0.002- await _track_maps_usage(- node_id, 'static_map', 1,- context.get('workflow_id'), context.get('session_id', 'default')- )+ await _track_maps_usage(node_id, "static_map", 1, context.get("workflow_id"), context.get("session_id", "default"))log_execution_time(logger, "create_map", start_time, time.time())@@ -132,7 +123,7 @@ class MapsService:"operation": "map_initialization","result": result,"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:@@ -143,7 +134,7 @@ class MapsService:"node_type": "gmaps_create","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def geocode_location(self, node_id: str, parameters: Dict[str, Any], context: Dict[str, Any] = None) -> Dict[str, Any]:@@ -152,15 +143,15 @@ class MapsService:context = context or {}try:- api_key = parameters.get('api_key') or self.settings.google_maps_api_key+ api_key = parameters.get("api_key") or self.settings.google_maps_api_keyif not api_key:raise ValueError("Google Maps API key is required")gmaps = googlemaps.Client(key=api_key)- service_type = parameters.get('service_type', 'geocode')+ service_type = parameters.get("service_type", "geocode")- if service_type == 'geocode':- address = parameters.get('address', '')+ if service_type == "geocode":+ address = parameters.get("address", "")if not address:raise ValueError("Address is required for geocoding")@@ -169,17 +160,14 @@ class MapsService:"service_type": "geocoding","input": {"address": address},"results": geocode_result,- "status": "OK" if geocode_result else "ZERO_RESULTS"+ "status": "OK" if geocode_result else "ZERO_RESULTS",}# Track: geocode $0.005- await _track_maps_usage(- node_id, 'geocode', 1,- context.get('workflow_id'), context.get('session_id', 'default')- )+ await _track_maps_usage(node_id, "geocode", 1, context.get("workflow_id"), context.get("session_id", "default"))- elif service_type == 'reverse_geocode':- lat = float(parameters.get('lat', 0))- lng = float(parameters.get('lng', 0))+ elif service_type == "reverse_geocode":+ lat = float(parameters.get("lat", 0))+ lng = float(parameters.get("lng", 0))if not self.validate_coordinates(lat, lng):raise ValueError("Invalid coordinates")@@ -189,13 +177,10 @@ class MapsService:"service_type": "reverse_geocoding","input": {"lat": lat, "lng": lng},"results": reverse_result,- "status": "OK" if reverse_result else "ZERO_RESULTS"+ "status": "OK" if reverse_result else "ZERO_RESULTS",}# Track: reverse_geocode $0.005- await _track_maps_usage(- node_id, 'reverse_geocode', 1,- context.get('workflow_id'), context.get('session_id', 'default')- )+ await _track_maps_usage(node_id, "reverse_geocode", 1, context.get("workflow_id"), context.get("session_id", "default"))else:raise ValueError(f"Unsupported service type: {service_type}")@@ -209,7 +194,7 @@ class MapsService:"operation": service_type,"result": result,"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except googlemaps.exceptions.ApiError as e:@@ -220,7 +205,7 @@ class MapsService:"node_type": "gmaps_locations","error": f"Google Maps API error: {str(e)}","execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:@@ -231,7 +216,7 @@ class MapsService:"node_type": "gmaps_locations","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def find_nearby_places(self, node_id: str, parameters: Dict[str, Any], context: Dict[str, Any] = None) -> Dict[str, Any]:@@ -240,16 +225,16 @@ class MapsService:context = context or {}try:- api_key = parameters.get('api_key') or self.settings.google_maps_api_key+ api_key = parameters.get("api_key") or self.settings.google_maps_api_keyif not api_key:raise ValueError("Google Maps API key is required")gmaps = googlemaps.Client(key=api_key)# Extract and validate parameters- lat = float(parameters.get('lat', 40.7484))- lng = float(parameters.get('lng', -73.9857))- radius = int(parameters.get('radius', 500))+ lat = float(parameters.get("lat", 40.7484))+ lng = float(parameters.get("lng", -73.9857))+ radius = int(parameters.get("radius", 500))if not self.validate_coordinates(lat, lng):raise ValueError("Invalid coordinates")@@ -257,83 +242,79 @@ class MapsService:raise ValueError("Radius must be between 1 and 50000 meters")# Optional parameters (snake_case)- place_type = parameters.get('type', 'restaurant')- page_size = min(int(parameters.get('page_size', 20)), 20)+ place_type = parameters.get("type", "restaurant")+ page_size = min(int(parameters.get("page_size", 20)), 20)# Extract options (may contain keyword, name, min_price, max_price, open_now, language, rank_by)- options = parameters.get('options', {})+ options = parameters.get("options", {})# Support both nested options and top-level parameters (snake_case)- keyword = options.get('keyword', '') if isinstance(options, dict) else parameters.get('keyword', '')- name_filter = options.get('name', '') if isinstance(options, dict) else parameters.get('name', '')- min_price = options.get('min_price') if isinstance(options, dict) else parameters.get('min_price')- max_price = options.get('max_price') if isinstance(options, dict) else parameters.get('max_price')- open_now = options.get('open_now', False) if isinstance(options, dict) else parameters.get('open_now', False)- language = options.get('language', 'en') if isinstance(options, dict) else parameters.get('language', 'en')- rank_by = options.get('rank_by', 'prominence') if isinstance(options, dict) else parameters.get('rank_by', 'prominence')-- logger.debug("[Nearby Places] Extracted parameters",- keyword=keyword,- name_filter=name_filter,- min_price=min_price,- max_price=max_price,- open_now=open_now,- language=language,- rank_by=rank_by,- place_type=place_type)+ keyword = options.get("keyword", "") if isinstance(options, dict) else parameters.get("keyword", "")+ name_filter = options.get("name", "") if isinstance(options, dict) else parameters.get("name", "")+ min_price = options.get("min_price") if isinstance(options, dict) else parameters.get("min_price")+ max_price = options.get("max_price") if isinstance(options, dict) else parameters.get("max_price")+ open_now = options.get("open_now", False) if isinstance(options, dict) else parameters.get("open_now", False)+ language = options.get("language", "en") if isinstance(options, dict) else parameters.get("language", "en")+ rank_by = options.get("rank_by", "prominence") if isinstance(options, dict) else parameters.get("rank_by", "prominence")++ logger.debug(+ "[Nearby Places] Extracted parameters",+ keyword=keyword,+ name_filter=name_filter,+ min_price=min_price,+ max_price=max_price,+ open_now=open_now,+ language=language,+ rank_by=rank_by,+ place_type=place_type,+ )# Build search request- search_params = {- 'location': (lat, lng),- 'type': place_type- }+ search_params = {"location": (lat, lng), "type": place_type}# Add radius unless ranking by distance- if rank_by != 'distance':- search_params['radius'] = radius+ if rank_by != "distance":+ search_params["radius"] = radiuselse:- search_params['rank_by'] = rank_by+ search_params["rank_by"] = rank_by# Add optional parametersif keyword:- search_params['keyword'] = keyword+ search_params["keyword"] = keywordif name_filter:- search_params['name'] = name_filter- if min_price is not None and min_price != '':- search_params['min_price'] = int(min_price)- if max_price is not None and max_price != '':- search_params['max_price'] = int(max_price)+ search_params["name"] = name_filter+ if min_price is not None and min_price != "":+ search_params["min_price"] = int(min_price)+ if max_price is not None and max_price != "":+ search_params["max_price"] = int(max_price)if open_now:- search_params['open_now'] = True+ search_params["open_now"] = Trueif language:- search_params['language'] = language+ search_params["language"] = languagenearby_result = gmaps.places_nearby(**search_params)- results = nearby_result.get('results', [])[:page_size]+ results = nearby_result.get("results", [])[:page_size]# Track: nearby_search $0.032- await _track_maps_usage(- node_id, 'nearby_search', 1,- context.get('workflow_id'), context.get('session_id', 'default')- )+ await _track_maps_usage(node_id, "nearby_search", 1, context.get("workflow_id"), context.get("session_id", "default"))result = {"search_parameters": {"location": {"lat": lat, "lng": lng},- "radius": radius if rank_by != 'distance' else None,+ "radius": radius if rank_by != "distance" else None,"type": place_type,"keyword": keyword or None,"name_filter": name_filter or None,- "min_price": min_price if min_price not in [None, ''] else None,- "max_price": max_price if max_price not in [None, ''] else None,+ "min_price": min_price if min_price not in [None, ""] else None,+ "max_price": max_price if max_price not in [None, ""] else None,"open_now": open_now,"language": language,"rank_by": rank_by,- "page_size": page_size+ "page_size": page_size,},"results": results,"total_results": len(results),- "status": nearby_result.get('status', 'OK')+ "status": nearby_result.get("status", "OK"),}log_execution_time(logger, "nearby_places", start_time, time.time())@@ -345,7 +326,7 @@ class MapsService:"operation": "nearby_search","result": result,"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except googlemaps.exceptions.ApiError as e:@@ -356,7 +337,7 @@ class MapsService:"node_type": "gmaps_nearby_places","error": f"Google Places API error: {str(e)}","execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:@@ -367,5 +348,5 @@ class MapsService:"node_type": "gmaps_nearby_places","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()- }\ No newline at end of file+ "timestamp": datetime.now().isoformat(),+ }diff --git a/server/nodes/location/gmaps_create/__init__.py b/server/nodes/location/gmaps_create/__init__.pyindex 84b0a4d7..0617523d 100644--- a/server/nodes/location/gmaps_create/__init__.py+++ b/server/nodes/location/gmaps_create/__init__.py@@ -46,10 +46,8 @@ class GmapsCreateNode(ActionNode):description = "Google Maps creation with center, zoom, and map type"component_kind = "square"handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)ui_hints = {"showLocationPanel": True}annotations = {"destructive": False, "readonly": True, "open_world": False}@@ -65,7 +63,9 @@ class GmapsCreateNode(ActionNode):maps_service = get_maps_service()response = await maps_service.create_map(- ctx.node_id, params.model_dump(), ctx.raw,+ ctx.node_id,+ params.model_dump(),+ ctx.raw,)if response.get("success"):return response.get("result") or responsediff --git a/server/nodes/location/gmaps_locations/__init__.py b/server/nodes/location/gmaps_locations/__init__.pyindex 1db8ec6e..58f91b9e 100644--- a/server/nodes/location/gmaps_locations/__init__.py+++ b/server/nodes/location/gmaps_locations/__init__.py@@ -59,10 +59,8 @@ class GmapsLocationsNode(ActionNode):tool_name = "geocode"tool_description = "Geocode addresses to coordinates or reverse geocode coordinates to addresses using Google Maps."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": True, "open_world": True}credentials = (GoogleMapsCredential,)@@ -78,7 +76,9 @@ class GmapsLocationsNode(ActionNode):maps_service = get_maps_service()response = await maps_service.geocode_location(- ctx.node_id, params.model_dump(), ctx.raw,+ ctx.node_id,+ params.model_dump(),+ ctx.raw,)if response.get("success"):return response.get("result") or responsediff --git a/server/nodes/location/gmaps_nearby_places/__init__.py b/server/nodes/location/gmaps_nearby_places/__init__.pyindex 5ea66dfa..7f79a0f8 100644--- a/server/nodes/location/gmaps_nearby_places/__init__.py+++ b/server/nodes/location/gmaps_nearby_places/__init__.py@@ -38,10 +38,8 @@ class GmapsNearbyPlacesNode(ActionNode):tool_name = "nearby_places"tool_description = "Search for nearby places (restaurants, hospitals, banks, etc.) using Google Maps Places API."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": True, "open_world": True}credentials = (GoogleMapsCredential,)@@ -57,7 +55,9 @@ class GmapsNearbyPlacesNode(ActionNode):maps_service = get_maps_service()response = await maps_service.find_nearby_places(- ctx.node_id, params.model_dump(), ctx.raw,+ ctx.node_id,+ params.model_dump(),+ ctx.raw,)if response.get("success"):return response.get("result") or responsediff --git a/server/nodes/model/_base.py b/server/nodes/model/_base.pyindex a0d2a34a..90fdc3d2 100644--- a/server/nodes/model/_base.py+++ b/server/nodes/model/_base.py@@ -42,7 +42,9 @@ class ChatModelParams(BaseModel):# default=None so an unset value falls through to ``agent.default_temperature``# in server/config/llm_defaults.json (resolved by _resolve_temperature).temperature: Optional[float] = Field(- default=None, ge=0.0, le=2.0,+ default=None,+ ge=0.0,+ le=2.0,json_schema_extra={"numberStepSize": 0.1},)# default=None so an unset value is absent from the dumped dict and the@@ -58,7 +60,9 @@ class ChatModelParams(BaseModel):json_schema_extra={"password": True},)top_p: Optional[float] = Field(- default=1.0, ge=0.0, le=1.0,+ default=1.0,+ ge=0.0,+ le=1.0,json_schema_extra={"numberStepSize": 0.1},)thinking_enabled: bool = Field(default=False)@@ -85,10 +89,7 @@ class ChatModelBase(ActionNode, abstract=True):Override Params to add provider-specific tuning fields."""component_kind = "model"- handles = (- {"name": "output-model", "kind": "output", "position": "right",- "label": "Model", "role": "model"},- )+ handles = ({"name": "output-model", "kind": "output", "position": "right", "label": "Model", "role": "model"},)annotations = {"destructive": False, "readonly": False, "open_world": True}task_queue = TaskQueue.AI_HEAVY@@ -106,7 +107,9 @@ class ChatModelBase(ActionNode, abstract=True):# ``RuntimeError`` here only fires for "success=False" responses# that aren't typed SDK errors (real bugs worth a stacktrace).response = await ai_service.execute_chat(- ctx.node_id, self.type, params.model_dump(),+ ctx.node_id,+ self.type,+ params.model_dump(),)if response.get("success"):return response.get("result") or responsediff --git a/server/nodes/model/_local_validator.py b/server/nodes/model/_local_validator.pyindex a78f8606..7b4fbe4e 100644--- a/server/nodes/model/_local_validator.py+++ b/server/nodes/model/_local_validator.py@@ -65,8 +65,7 @@ def _classify_http_error(provider: str, base_url: str, exc: BaseException) -> Tureturn ("timeout", f"Request to {base_url} timed out — server may be overloaded or unreachable")if isinstance(exc, httpx.ConnectError):- return ("connect-refused",- f"Could not reach {display} at {base_url}. Is the server running?")+ return ("connect-refused", f"Could not reach {display} at {base_url}. Is the server running?")if isinstance(exc, httpx.HTTPStatusError):status = exc.response.status_code@@ -106,12 +105,19 @@ async def _fail(the "Base URL required" early-exit today)."""await get_status_broadcaster().update_api_key_status(- provider=provider, valid=False, message=message,- has_key=has_key, models=[],+ provider=provider,+ valid=False,+ message=message,+ has_key=has_key,+ models=[],)return {- "provider": provider, "success": True, "valid": False,- "message": message, "models": [], "timestamp": time.time(),+ "provider": provider,+ "success": True,+ "valid": False,+ "message": message,+ "models": [],+ "timestamp": time.time(),}@@ -203,8 +209,7 @@ async def _fetch_lmstudio_models(base_url: str) -> List[Dict[str, Any]]:try:info = await handle.get_info()except Exception as e:- logger.info("[lmstudio] get_info skipped for %s: %s",- getattr(handle, "identifier", "<unknown>"), type(e).__name__)+ logger.info("[lmstudio] get_info skipped for %s: %s", getattr(handle, "identifier", "<unknown>"), type(e).__name__)continuemid = info.identifier or info.model_keyif not mid:@@ -277,8 +282,7 @@ async def validate_local_llm(data: Dict[str, Any]) -> Dict[str, Any]:return await _fail(provider, user_msg, has_key=True)except Exception as e:log_summary, user_msg = _classify_http_error(provider, base_url, e)- logger.warning("[%s] model probe unexpected error (%s) at %s: %s",- provider, log_summary, base_url, e)+ logger.warning("[%s] model probe unexpected error (%s) at %s: %s", provider, log_summary, base_url, e)return await _fail(provider, user_msg, has_key=True)if not entries:@@ -299,9 +303,7 @@ async def validate_local_llm(data: Dict[str, Any]) -> Dict[str, Any]:# consumes these directly to populate ``ModelInfo``.models = [e["id"] for e in entries]model_params: Dict[str, Dict[str, Any]] = {- e["id"]: {k: v for k, v in e.items() if k != "id"}- for e in entries- if any(k != "id" for k in e)+ e["id"]: {k: v for k, v in e.items() if k != "id"} for e in entries if any(k != "id" for k in e)}# Store placeholder api_key + the real model list + per-model params.@@ -323,23 +325,25 @@ async def validate_local_llm(data: Dict[str, Any]) -> Dict[str, Any]:# call. Also keeps the runtime path branchless — local and cloud# models share the same ``provider/model_id`` registry key.from services.model_registry import get_model_registry+registry = get_model_registry()for mid, params in model_params.items():registry.register_local_model(provider, mid, params)await get_status_broadcaster().update_api_key_status(- provider=provider, valid=True,+ provider=provider,+ valid=True,message=f"{len(models)} model(s) discovered at {base_url}",- has_key=True, models=models,+ has_key=True,+ models=models,)- ctx_summary = ", ".join(- f"{mid}={p['context_length']}"- for mid, p in model_params.items()- ) or "no per-model context info"- logger.info("[%s] discovered %d model(s) at %s (%s)",- provider, len(models), base_url, ctx_summary)+ ctx_summary = ", ".join(f"{mid}={p['context_length']}" for mid, p in model_params.items()) or "no per-model context info"+ logger.info("[%s] discovered %d model(s) at %s (%s)", provider, len(models), base_url, ctx_summary)return {- "provider": provider, "success": True, "valid": True,- "models": models, "message": f"Connected to {provider} at {base_url}",+ "provider": provider,+ "success": True,+ "valid": True,+ "models": models,+ "message": f"Connected to {provider} at {base_url}","timestamp": time.time(),}diff --git a/server/nodes/model/anthropic_chat_model/__init__.py b/server/nodes/model/anthropic_chat_model/__init__.pyindex 6948296c..e1eb837a 100644--- a/server/nodes/model/anthropic_chat_model/__init__.py+++ b/server/nodes/model/anthropic_chat_model/__init__.py@@ -11,7 +11,9 @@ class AnthropicChatModelParams(ChatModelParams):top_k: Optional[int] = Field(default=40, ge=1, le=100)thinking_enabled: bool = Field(default=False)thinking_budget: Optional[int] = Field(- default=2048, ge=1024, le=16000,+ default=2048,+ ge=1024,+ le=16000,json_schema_extra={"displayOptions": {"show": {"thinking_enabled": [True]}}},)diff --git a/server/nodes/model/cerebras_chat_model/__init__.py b/server/nodes/model/cerebras_chat_model/__init__.pyindex 5621b2e4..8d23af6e 100644--- a/server/nodes/model/cerebras_chat_model/__init__.py+++ b/server/nodes/model/cerebras_chat_model/__init__.py@@ -10,7 +10,9 @@ from .._credentials import CerebrasCredentialclass CerebrasChatModelParams(ChatModelParams):thinking_enabled: bool = Field(default=False)thinking_budget: Optional[int] = Field(- default=2048, ge=1024, le=16000,+ default=2048,+ ge=1024,+ le=16000,json_schema_extra={"displayOptions": {"show": {"thinking_enabled": [True]}}},)diff --git a/server/nodes/model/deepseek_chat_model/__init__.py b/server/nodes/model/deepseek_chat_model/__init__.pyindex 717e6eb2..21c006a0 100644--- a/server/nodes/model/deepseek_chat_model/__init__.py+++ b/server/nodes/model/deepseek_chat_model/__init__.py@@ -9,10 +9,14 @@ from .._credentials import DeepSeekCredentialclass DeepseekChatModelParams(ChatModelParams):frequency_penalty: Optional[float] = Field(- default=0.0, ge=-2.0, le=2.0,+ default=0.0,+ ge=-2.0,+ le=2.0,)presence_penalty: Optional[float] = Field(- default=0.0, ge=-2.0, le=2.0,+ default=0.0,+ ge=-2.0,+ le=2.0,)diff --git a/server/nodes/model/gemini_chat_model/__init__.py b/server/nodes/model/gemini_chat_model/__init__.pyindex 659eab8c..deb85e31 100644--- a/server/nodes/model/gemini_chat_model/__init__.py+++ b/server/nodes/model/gemini_chat_model/__init__.py@@ -12,7 +12,9 @@ class GeminiChatModelParams(ChatModelParams):safety_settings: Literal["default", "strict", "permissive"] = Field(default="default")thinking_enabled: bool = Field(default=False)thinking_budget: Optional[int] = Field(- default=2048, ge=1024, le=16000,+ default=2048,+ ge=1024,+ le=16000,json_schema_extra={"displayOptions": {"show": {"thinking_enabled": [True]}}},)diff --git a/server/nodes/model/openai_chat_model/__init__.py b/server/nodes/model/openai_chat_model/__init__.pyindex c34e6bea..b7beb2cf 100644--- a/server/nodes/model/openai_chat_model/__init__.py+++ b/server/nodes/model/openai_chat_model/__init__.py@@ -9,11 +9,15 @@ from .._credentials import OpenAICredentialclass OpenAIChatModelParams(ChatModelParams):frequency_penalty: Optional[float] = Field(- default=0.0, ge=-2.0, le=2.0,+ default=0.0,+ ge=-2.0,+ le=2.0,json_schema_extra={"numberStepSize": 0.1},)presence_penalty: Optional[float] = Field(- default=0.0, ge=-2.0, le=2.0,+ default=0.0,+ ge=-2.0,+ le=2.0,json_schema_extra={"numberStepSize": 0.1},)response_format: Optional[Literal["text", "json_object"]] = Field(default="text")diff --git a/server/nodes/model/openrouter_chat_model/__init__.py b/server/nodes/model/openrouter_chat_model/__init__.pyindex 219a046d..d1250516 100644--- a/server/nodes/model/openrouter_chat_model/__init__.py+++ b/server/nodes/model/openrouter_chat_model/__init__.py@@ -9,10 +9,14 @@ from .._credentials import OpenRouterCredentialclass OpenRouterChatModelParams(ChatModelParams):frequency_penalty: Optional[float] = Field(- default=0.0, ge=-2.0, le=2.0,+ default=0.0,+ ge=-2.0,+ le=2.0,)presence_penalty: Optional[float] = Field(- default=0.0, ge=-2.0, le=2.0,+ default=0.0,+ ge=-2.0,+ le=2.0,)diff --git a/server/nodes/proxy/_usage.py b/server/nodes/proxy/_usage.pyindex f1600184..f715c799 100644--- a/server/nodes/proxy/_usage.py+++ b/server/nodes/proxy/_usage.py@@ -31,22 +31,21 @@ async def track_proxy_usage(provider_pricing = proxy_pricing.get(provider_name, {})cost_per_gb = provider_pricing.get("cost_per_gb", 0.0)- gb = bytes_transferred / (1024 ** 3)+ gb = bytes_transferred / (1024**3)total_cost = round(gb * cost_per_gb, 8)db = get_database()- await db.save_api_usage_metric({- "session_id": session_id,- "node_id": node_id,- "workflow_id": workflow_id,- "service": f"proxy_{provider_name}" if provider_name else "proxy",- "operation": "proxy_request",- "endpoint": "proxy",- "resource_count": 1,- "cost": total_cost,- })- logger.debug(- f"[Proxy] Tracked {provider_name} usage: {bytes_transferred} bytes "- f"= ${total_cost:.8f}"+ await db.save_api_usage_metric(+ {+ "session_id": session_id,+ "node_id": node_id,+ "workflow_id": workflow_id,+ "service": f"proxy_{provider_name}" if provider_name else "proxy",+ "operation": "proxy_request",+ "endpoint": "proxy",+ "resource_count": 1,+ "cost": total_cost,+ })+ logger.debug(f"[Proxy] Tracked {provider_name} usage: {bytes_transferred} bytes " f"= ${total_cost:.8f}")return {"cost_per_gb": cost_per_gb, "bytes": bytes_transferred, "total_cost": total_cost}diff --git a/server/nodes/proxy/proxy_config/__init__.py b/server/nodes/proxy/proxy_config/__init__.pyindex eb9f9edf..f62892ba 100644--- a/server/nodes/proxy/proxy_config/__init__.py+++ b/server/nodes/proxy/proxy_config/__init__.py@@ -29,9 +29,16 @@ _ROUTING_REMOVE_OPS = ["remove_routing_rule"]class ProxyConfigParams(BaseModel):operation: Literal[- "list_providers", "add_provider", "update_provider", "remove_provider",- "set_credentials", "test_provider", "get_stats",- "add_routing_rule", "list_routing_rules", "remove_routing_rule",+ "list_providers",+ "add_provider",+ "update_provider",+ "remove_provider",+ "set_credentials",+ "test_provider",+ "get_stats",+ "add_routing_rule",+ "list_routing_rules",+ "remove_routing_rule",] = Field(default="list_providers",description="Proxy management operation. list_providers / get_stats / list_routing_rules need no extra params.",@@ -57,7 +64,7 @@ class ProxyConfigParams(BaseModel):)url_template: Any = Field(default="{}",- description="JSON template for proxy URL formatting (e.g. {\"username\": \"{user}-country-{country}\"}).",+ description='JSON template for proxy URL formatting (e.g. {"username": "{user}-country-{country}"}).',json_schema_extra={"rows": 4,"displayOptions": {"show": {"operation": _PROVIDER_EDIT_OPS}},@@ -75,7 +82,8 @@ class ProxyConfigParams(BaseModel):)priority: int = Field(default=50,- ge=0, le=100,+ ge=0,+ le=100,description="Selection priority (higher ranks first).",json_schema_extra={"displayOptions": {"show": {"operation": _PROVIDER_EDIT_OPS}}},)@@ -170,22 +178,22 @@ async def _add_provider(p: Dict[str, Any], proxy_svc) -> Dict[str, Any]:url_template_raw = p.get("url_template", "{}")try:- url_template = (- json.loads(url_template_raw) if isinstance(url_template_raw, str) else url_template_raw- )+ url_template = json.loads(url_template_raw) if isinstance(url_template_raw, str) else url_template_rawexcept json.JSONDecodeError:return {"success": False, "error": f"Invalid url_template JSON: {url_template_raw}"}db = get_database()- await db.save_proxy_provider({- "name": name,- "enabled": p.get("enabled", True),- "priority": int(p.get("priority", 50)),- "cost_per_gb": float(p.get("cost_per_gb", 0)),- "gateway_host": p.get("gateway_host", ""),- "gateway_port": int(p.get("gateway_port", 0)),- "url_template": json.dumps(url_template),- })+ await db.save_proxy_provider(+ {+ "name": name,+ "enabled": p.get("enabled", True),+ "priority": int(p.get("priority", 50)),+ "cost_per_gb": float(p.get("cost_per_gb", 0)),+ "gateway_host": p.get("gateway_host", ""),+ "gateway_port": int(p.get("gateway_port", 0)),+ "url_template": json.dumps(url_template),+ }+ )if proxy_svc:await proxy_svc.reload_providers()return {"success": True, "name": name}@@ -210,9 +218,7 @@ async def _update_provider(p: Dict[str, Any], proxy_svc) -> Dict[str, Any]:url_template_raw = p.get("url_template")if url_template_raw:try:- url_template = (- json.loads(url_template_raw) if isinstance(url_template_raw, str) else url_template_raw- )+ url_template = json.loads(url_template_raw) if isinstance(url_template_raw, str) else url_template_rawupdates["url_template"] = json.dumps(url_template)except json.JSONDecodeError:return {"success": False, "error": "Invalid url_template JSON"}@@ -264,7 +270,8 @@ async def _test_provider(p: Dict[str, Any], proxy_svc) -> Dict[str, Any]:try:proxy_url = await proxy_svc.get_proxy_url(- "https://httpbin.org/ip", {"proxyProvider": name},+ "https://httpbin.org/ip",+ {"proxyProvider": name},)if not proxy_url:return {"success": False, "error": f"Could not get proxy URL for '{name}'"}@@ -299,19 +306,19 @@ async def _add_routing_rule(p: Dict[str, Any], proxy_svc) -> Dict[str, Any]:preferred_raw = p.get("preferred_providers", "[]")try:- preferred = (- json.loads(preferred_raw) if isinstance(preferred_raw, str) else preferred_raw- )+ preferred = json.loads(preferred_raw) if isinstance(preferred_raw, str) else preferred_rawexcept json.JSONDecodeError:preferred = []db = get_database()- await db.save_proxy_routing_rule({- "domain_pattern": domain_pattern,- "preferred_providers": json.dumps(preferred),- "required_country": p.get("required_country", ""),- "session_type": p.get("session_type", "rotating"),- })+ await db.save_proxy_routing_rule(+ {+ "domain_pattern": domain_pattern,+ "preferred_providers": json.dumps(preferred),+ "required_country": p.get("required_country", ""),+ "session_type": p.get("session_type", "rotating"),+ }+ )if proxy_svc:await proxy_svc.reload_providers()return {"success": True, "domain_pattern": domain_pattern}diff --git a/server/nodes/proxy/proxy_request/__init__.py b/server/nodes/proxy/proxy_request/__init__.pyindex 3ecaba86..41e33019 100644--- a/server/nodes/proxy/proxy_request/__init__.py+++ b/server/nodes/proxy/proxy_request/__init__.py@@ -81,8 +81,7 @@ class ProxyRequestNode(ActionNode):svc = get_proxy_service()if not svc or not svc.is_enabled():raise NodeUserError(- "Proxy service not initialized. Use proxy_config tool to add a "- "provider first.",+ "Proxy service not initialized. Use proxy_config tool to add a " "provider first.",)raw = params.model_dump()@@ -118,15 +117,21 @@ class ProxyRequestNode(ActionNode):latency_ms = (time.monotonic() - req_start) * 1000bytes_transferred = len(response.content) if response.content else 0- svc.report_result(provider_name, ProxyResult(- success=response.status_code < 400,- latency_ms=latency_ms,- bytes_transferred=bytes_transferred,- status_code=response.status_code,- ))+ svc.report_result(+ provider_name,+ ProxyResult(+ success=response.status_code < 400,+ latency_ms=latency_ms,+ bytes_transferred=bytes_transferred,+ status_code=response.status_code,+ ),+ )await track_proxy_usage(- ctx.node_id, provider_name, bytes_transferred,- workflow_id=ctx.workflow_id, session_id=ctx.session_id,+ ctx.node_id,+ provider_name,+ bytes_transferred,+ workflow_id=ctx.workflow_id,+ session_id=ctx.session_id,)try:response_data = response.json()@@ -150,13 +155,20 @@ class ProxyRequestNode(ActionNode):except Exception as e:latency_ms = (time.monotonic() - req_start) * 1000last_error = str(e)- svc.report_result(provider_name, ProxyResult(- success=False, latency_ms=latency_ms, error=last_error,- ))+ svc.report_result(+ provider_name,+ ProxyResult(+ success=False,+ latency_ms=latency_ms,+ error=last_error,+ ),+ )log.warning("Proxy request attempt failed",- node_id=ctx.node_id, attempt=attempt + 1,- max_retries=max_retries, error=last_error,+ node_id=ctx.node_id,+ attempt=attempt + 1,+ max_retries=max_retries,+ error=last_error,)if not failover or attempt >= max_retries:breakdiff --git a/server/nodes/scheduler/cron_scheduler/__init__.py b/server/nodes/scheduler/cron_scheduler/__init__.pyindex 42e380fa..38693ac3 100644--- a/server/nodes/scheduler/cron_scheduler/__init__.py+++ b/server/nodes/scheduler/cron_scheduler/__init__.py@@ -39,9 +39,7 @@ from ._workflow import CronTriggerWorkflowlogger = get_logger(__name__)-register_temporal_plugin(- SimplePlugin(name="cron-scheduler", workflows=[CronTriggerWorkflow])-)+register_temporal_plugin(SimplePlugin(name="cron-scheduler", workflows=[CronTriggerWorkflow]))register_canary_trigger_type("cronScheduler", "com.machinaos.cron.tick")@@ -104,30 +102,45 @@ def _get_schedule_description(p: Dict[str, Any]) -> str:class CronSchedulerParams(BaseModel):- frequency: Literal[- "seconds", "minutes", "hours", "days", "weeks", "months", "once"- ] = Field(+ frequency: Literal["seconds", "minutes", "hours", "days", "weeks", "months", "once"] = Field(default="minutes",description="How often the schedule fires",)interval: int = Field(- default=30, ge=5, le=59,+ default=30,+ ge=5,+ le=59,description="Seconds between fires (5-59)",json_schema_extra={"displayOptions": {"show": {"frequency": ["seconds"]}}},)interval_minutes: int = Field(- default=5, ge=1, le=59,+ default=5,+ ge=1,+ le=59,description="Minutes between fires (1-59)",json_schema_extra={"displayOptions": {"show": {"frequency": ["minutes"]}}},)interval_hours: int = Field(- default=1, ge=1, le=23,+ default=1,+ ge=1,+ le=23,description="Hours between fires (1-23)",json_schema_extra={"displayOptions": {"show": {"frequency": ["hours"]}}},)daily_time: Literal[- "00:00", "02:00", "04:00", "06:00", "08:00", "09:00",- "10:00", "12:00", "14:00", "16:00", "18:00", "20:00", "22:00",+ "00:00",+ "02:00",+ "04:00",+ "06:00",+ "08:00",+ "09:00",+ "10:00",+ "12:00",+ "14:00",+ "16:00",+ "18:00",+ "20:00",+ "22:00",] = Field(default="09:00",description="Time of day (HH:MM) for daily schedule",@@ -139,17 +152,54 @@ class CronSchedulerParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"frequency": ["weeks"]}}},)weekly_time: Literal[- "00:00", "02:00", "04:00", "06:00", "08:00", "09:00",- "10:00", "12:00", "14:00", "16:00", "18:00", "20:00", "22:00",+ "00:00",+ "02:00",+ "04:00",+ "06:00",+ "08:00",+ "09:00",+ "10:00",+ "12:00",+ "14:00",+ "16:00",+ "18:00",+ "20:00",+ "22:00",] = Field(default="09:00",description="Time of day for weekly schedule",json_schema_extra={"displayOptions": {"show": {"frequency": ["weeks"]}}},)month_day: Literal[- "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",- "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",- "21", "22", "23", "24", "25", "26", "27", "28", "L",+ "1",+ "2",+ "3",+ "4",+ "5",+ "6",+ "7",+ "8",+ "9",+ "10",+ "11",+ "12",+ "13",+ "14",+ "15",+ "16",+ "17",+ "18",+ "19",+ "20",+ "21",+ "22",+ "23",+ "24",+ "25",+ "26",+ "27",+ "28",+ "L",] = Field(default="1",description="Day of month (1-28, or 'L' for last day)",@@ -198,10 +248,7 @@ class CronSchedulerNode(ActionNode):component_kind = "trigger"tool_name = "cron_scheduler"tool_description = "Schedule a delayed or recurring execution. Supports seconds, minutes, hours, daily, weekly, monthly frequencies with timezone. Use frequency to set schedule type, then set the relevant interval/time parameters."- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": True, "open_world": False}task_queue = TaskQueue.TRIGGERS_POLLusable_as_tool = True@@ -225,7 +272,8 @@ class CronSchedulerNode(ActionNode):trigger_time = now + timedelta(seconds=wait_seconds)await get_status_broadcaster().update_node_status(- ctx.node_id, "waiting",+ ctx.node_id,+ "waiting",{"message": f"Waiting {schedule_desc}...","trigger_time": trigger_time.isoformat(),@@ -236,7 +284,8 @@ class CronSchedulerNode(ActionNode):logger.info(f"[CronScheduler] Waiting {wait_seconds}s for trigger",- node_id=ctx.node_id, trigger_time=trigger_time.isoformat(),+ node_id=ctx.node_id,+ trigger_time=trigger_time.isoformat(),)try:@@ -259,8 +308,5 @@ class CronSchedulerNode(ActionNode):output.message = f"Triggered after waiting {_format_wait_time(wait_seconds)}"else:output.next_run = schedule_desc- output.message = (- f"Triggered after {_format_wait_time(wait_seconds)}, "- f"will repeat: {schedule_desc}"- )+ output.message = f"Triggered after {_format_wait_time(wait_seconds)}, " f"will repeat: {schedule_desc}"return outputdiff --git a/server/nodes/scheduler/cron_scheduler/_workflow.py b/server/nodes/scheduler/cron_scheduler/_workflow.pyindex 4c0b7e21..ef8a6468 100644--- a/server/nodes/scheduler/cron_scheduler/_workflow.py+++ b/server/nodes/scheduler/cron_scheduler/_workflow.py@@ -102,13 +102,15 @@ class CronTriggerWorkflow:await workflow.start_child_workflow("MachinaWorkflow",- args=[{- "nodes": filtered_nodes,- "edges": filtered_edges,- "session_id": session_id,- "workflow_id": deployment_workflow_id,- "tenant_id": tenant_id,- }],+ args=[+ {+ "nodes": filtered_nodes,+ "edges": filtered_edges,+ "session_id": session_id,+ "workflow_id": deployment_workflow_id,+ "tenant_id": tenant_id,+ }+ ],id=child_id,parent_close_policy=ParentClosePolicy.ABANDON,id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE_FAILED_ONLY,@@ -116,10 +118,7 @@ class CronTriggerWorkflow:run_timeout=timedelta(hours=1),)- workflow.logger.info(- f"CronTriggerWorkflow spawned child run: child_id={child_id} "- f"timestamp={firing_iso}"- )+ workflow.logger.info(f"CronTriggerWorkflow spawned child run: child_id={child_id} " f"timestamp={firing_iso}")return {"spawned_child_id": child_id,diff --git a/server/nodes/scheduler/timer/__init__.py b/server/nodes/scheduler/timer/__init__.pyindex 648cdc84..30aabd12 100644--- a/server/nodes/scheduler/timer/__init__.py+++ b/server/nodes/scheduler/timer/__init__.py@@ -37,10 +37,8 @@ class TimerNode(ActionNode):tool_name = "timer"tool_description = "Wait/sleep for a specified duration. Specify duration (1-3600) and unit (seconds, minutes, or hours). Returns timestamp and elapsed time after waiting."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": True, "open_world": False}task_queue = TaskQueue.DEFAULT@@ -70,7 +68,8 @@ class TimerNode(ActionNode):complete_time = datetime.now() + timedelta(seconds=wait_seconds)await get_status_broadcaster().update_node_status(- ctx.node_id, "waiting",+ ctx.node_id,+ "waiting",{"message": f"Waiting {duration} {unit}...","complete_time": complete_time.isoformat(),diff --git a/server/nodes/scraper/apify_actor/__init__.py b/server/nodes/scraper/apify_actor/__init__.pyindex ee42072b..24b35c9e 100644--- a/server/nodes/scraper/apify_actor/__init__.py+++ b/server/nodes/scraper/apify_actor/__init__.py@@ -24,6 +24,7 @@ async def _get_apify_client():"""Return an authenticated Apify client, or None if no token saved."""from apify_client import ApifyClientAsync # lazy — optional depfrom services.plugin.deps import get_auth_service+auth_service = get_auth_service()api_token = await auth_service.get_api_key("apify", "default")if not api_token:@@ -37,11 +38,11 @@ def _build_actor_input(parameters: Dict[str, Any]) -> Dict[str, Any]:Apify actors expect camelCase keys in their run input (that's theSDK contract). The plugin Params are snake_case; we translate here."""- actor_id = parameters.get('actor_id', '')- if actor_id == 'custom':- actor_id = parameters.get('custom_actor_id', '')+ actor_id = parameters.get("actor_id", "")+ if actor_id == "custom":+ actor_id = parameters.get("custom_actor_id", "")- actor_input = parameters.get('actor_input', {})+ actor_input = parameters.get("actor_input", {})if isinstance(actor_input, str):try:actor_input = json.loads(actor_input) if actor_input.strip() else {}@@ -50,38 +51,38 @@ def _build_actor_input(parameters: Dict[str, Any]) -> Dict[str, Any]:elif not isinstance(actor_input, dict):actor_input = {}- if actor_id == 'apify/instagram-scraper':- urls = parameters.get('instagram_urls', '')+ if actor_id == "apify/instagram-scraper":+ urls = parameters.get("instagram_urls", "")if urls:- actor_input['directUrls'] = [u.strip() for u in urls.split(',') if u.strip()]- elif actor_id == 'clockworks/tiktok-scraper':- profiles = parameters.get('tiktok_profiles', '')- hashtags = parameters.get('tiktok_hashtags', '')+ actor_input["directUrls"] = [u.strip() for u in urls.split(",") if u.strip()]+ elif actor_id == "clockworks/tiktok-scraper":+ profiles = parameters.get("tiktok_profiles", "")+ hashtags = parameters.get("tiktok_hashtags", "")if profiles:- actor_input['profiles'] = [p.strip() for p in profiles.split(',') if p.strip()]+ actor_input["profiles"] = [p.strip() for p in profiles.split(",") if p.strip()]if hashtags:- actor_input['hashtags'] = [h.strip() for h in hashtags.split(',') if h.strip()]- elif actor_id == 'apidojo/tweet-scraper':- search_terms = parameters.get('twitter_search_terms', '')- handles = parameters.get('twitter_handles', '')+ actor_input["hashtags"] = [h.strip() for h in hashtags.split(",") if h.strip()]+ elif actor_id == "apidojo/tweet-scraper":+ search_terms = parameters.get("twitter_search_terms", "")+ handles = parameters.get("twitter_handles", "")if search_terms:- actor_input['searchTerms'] = [t.strip() for t in search_terms.split(',') if t.strip()]+ actor_input["searchTerms"] = [t.strip() for t in search_terms.split(",") if t.strip()]if handles:- actor_input['twitterHandles'] = [h.strip() for h in handles.split(',') if h.strip()]- elif actor_id == 'apify/google-search-scraper':- query = parameters.get('google_search_query', '')- pages = parameters.get('google_search_pages', 1)+ actor_input["twitterHandles"] = [h.strip() for h in handles.split(",") if h.strip()]+ elif actor_id == "apify/google-search-scraper":+ query = parameters.get("google_search_query", "")+ pages = parameters.get("google_search_pages", 1)if query:- actor_input['searchQuery'] = query- actor_input['maxPagesPerQuery'] = pages- elif actor_id == 'apify/website-content-crawler':- start_urls = parameters.get('crawler_start_urls', '')- max_depth = parameters.get('crawler_max_depth', 2)- max_pages = parameters.get('crawler_max_pages', 50)+ actor_input["searchQuery"] = query+ actor_input["maxPagesPerQuery"] = pages+ elif actor_id == "apify/website-content-crawler":+ start_urls = parameters.get("crawler_start_urls", "")+ max_depth = parameters.get("crawler_max_depth", 2)+ max_pages = parameters.get("crawler_max_pages", 50)if start_urls:- actor_input['startUrls'] = [{'url': u.strip()} for u in start_urls.split(',') if u.strip()]- actor_input['maxCrawlDepth'] = max_depth- actor_input['maxCrawlPages'] = max_pages+ actor_input["startUrls"] = [{"url": u.strip()} for u in start_urls.split(",") if u.strip()]+ actor_input["maxCrawlDepth"] = max_depth+ actor_input["maxCrawlPages"] = max_pagesreturn actor_input@@ -95,6 +96,7 @@ async def validate_apify_token(api_token: str) -> Dict[str, Any]:"""try:from apify_client import ApifyClientAsync # lazy — optional dep+client = ApifyClientAsync(api_token)user_info = await client.user("me").get()if not user_info:@@ -189,7 +191,9 @@ class ApifyActorParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"actor_id": ["apify/google-search-scraper"]}}},)google_search_pages: int = Field(- default=1, ge=1, le=100,+ default=1,+ ge=1,+ le=100,description="Max pages per query.",json_schema_extra={"displayOptions": {"show": {"actor_id": ["apify/google-search-scraper"]}}},)@@ -199,12 +203,16 @@ class ApifyActorParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"actor_id": ["apify/website-content-crawler"]}}},)crawler_max_depth: int = Field(- default=2, ge=0, le=20,+ default=2,+ ge=0,+ le=20,description="Max crawl depth.",json_schema_extra={"displayOptions": {"show": {"actor_id": ["apify/website-content-crawler"]}}},)crawler_max_pages: int = Field(- default=50, ge=1, le=10000,+ default=50,+ ge=1,+ le=10000,description="Max pages to crawl.",json_schema_extra={"displayOptions": {"show": {"actor_id": ["apify/website-content-crawler"]}}},)@@ -274,8 +282,7 @@ class ApifyActorNode(ActionNode):memory_mbytes = int(params.memory)logger.info(- f"[Apify] Running actor {actor_id} "- f"timeout={timeout_secs}s memory={memory_mbytes}MB",+ f"[Apify] Running actor {actor_id} " f"timeout={timeout_secs}s memory={memory_mbytes}MB",)run_info = await client.actor(actor_id).call(run_input=actor_input,diff --git a/server/nodes/scraper/crawlee_scraper/__init__.py b/server/nodes/scraper/crawlee_scraper/__init__.pyindex eafb79e6..c39a1d56 100644--- a/server/nodes/scraper/crawlee_scraper/__init__.py+++ b/server/nodes/scraper/crawlee_scraper/__init__.py@@ -24,15 +24,17 @@ _MAX_CONTENT_LENGTH = 100_000async def _get_proxy_config(parameters: Dict[str, Any], url: str):"""Bridge MachinaOs ProxyService to Crawlee ProxyConfiguration."""- if not parameters.get('use_proxy', False):+ if not parameters.get("use_proxy", False):return Nonetry:from services.proxy import get_proxy_service+proxy_svc = get_proxy_service()proxy_url = await proxy_svc.get_proxy_url(url, parameters)if not proxy_url:return Nonefrom crawlee.proxy_configuration import ProxyConfiguration+return ProxyConfiguration(proxy_urls=[proxy_url])except Exception as e:logger.warning(f"[Crawlee] Proxy setup failed, proceeding without: {e}")@@ -41,19 +43,20 @@ async def _get_proxy_config(parameters: Dict[str, Any], url: str):def _extract_text(soup, css_selector: str, output_format: str) -> str:target = soup.select(css_selector) if css_selector else [soup]- if output_format == 'html':+ if output_format == "html":parts = [str(el) for el in target]else:- parts = [el.get_text(separator='\n', strip=True) for el in target]- text = '\n\n'.join(parts)- if output_format == 'markdown':+ parts = [el.get_text(separator="\n", strip=True) for el in target]+ text = "\n\n".join(parts)+ if output_format == "markdown":try:import html2text+h = html2text.HTML2Text()h.ignore_links = Falseh.ignore_images = Falseh.body_width = 0- raw_html = '\n\n'.join(str(el) for el in target)+ raw_html = "\n\n".join(str(el) for el in target)text = h.handle(raw_html)except ImportError:pass@@ -61,19 +64,19 @@ def _extract_text(soup, css_selector: str, output_format: str) -> str:def _extract_links(soup, base_url: str) -> List[str]:- return [urljoin(base_url, a['href']) for a in soup.find_all('a', href=True)]+ return [urljoin(base_url, a["href"]) for a in soup.find_all("a", href=True)]-async def _run_beautifulsoup(url, pages, p, proxy_config, css_selector, extract_links,- output_format, mode, max_pages, max_depth,- max_concurrency, timeout_secs):+async def _run_beautifulsoup(+ url, pages, p, proxy_config, css_selector, extract_links, output_format, mode, max_pages, max_depth, max_concurrency, timeout_secs+):from crawlee import ConcurrencySettingsfrom crawlee.crawlers import BeautifulSoupCrawler, BeautifulSoupCrawlingContextfrom crawlee.storage_clients import MemoryStorageClientcrawler = BeautifulSoupCrawler(max_requests_per_crawl=max_pages,- max_crawl_depth=max_depth if mode == 'crawl' else 0,+ max_crawl_depth=max_depth if mode == "crawl" else 0,request_handler_timeout=timedelta(seconds=timeout_secs),concurrency_settings=ConcurrencySettings(max_concurrency=max_concurrency,@@ -83,47 +86,51 @@ async def _run_beautifulsoup(url, pages, p, proxy_config, css_selector, extract_proxy_configuration=proxy_config,configure_logging=False,)- link_selector = p.get('link_selector', '') or 'a[href]'- url_pattern = p.get('url_pattern', '')+ link_selector = p.get("link_selector", "") or "a[href]"+ url_pattern = p.get("url_pattern", "")@crawler.router.default_handlerasync def handler(ctx: BeautifulSoupCrawlingContext) -> None:- title = ctx.soup.title.string if ctx.soup.title else ''+ title = ctx.soup.title.string if ctx.soup.title else ""content = _extract_text(ctx.soup, css_selector, output_format)page_data: Dict[str, Any] = {- 'url': ctx.request.url, 'title': title, 'content': content,+ "url": ctx.request.url,+ "title": title,+ "content": content,}if extract_links:- page_data['links'] = _extract_links(ctx.soup, ctx.request.url)+ page_data["links"] = _extract_links(ctx.soup, ctx.request.url)pages.append(page_data)- if mode == 'crawl':- kwargs: Dict[str, Any] = {'selector': link_selector}+ if mode == "crawl":+ kwargs: Dict[str, Any] = {"selector": link_selector}if url_pattern:import refrom fnmatch import translate- kwargs['include'] = [re.compile(translate(url_pattern))]++ kwargs["include"] = [re.compile(translate(url_pattern))]await ctx.enqueue_links(**kwargs)await asyncio.wait_for(crawler.run([url]), timeout=timeout_secs)-async def _run_playwright(url, pages, p, proxy_config, css_selector, extract_links,- output_format, mode, max_pages, max_depth,- max_concurrency, timeout_secs):+async def _run_playwright(+ url, pages, p, proxy_config, css_selector, extract_links, output_format, mode, max_pages, max_depth, max_concurrency, timeout_secs+):from crawlee import ConcurrencySettingsfrom crawlee.crawlers import PlaywrightCrawler, PlaywrightCrawlingContextfrom crawlee.storage_clients import MemoryStorageClient- browser_type = p.get('browser_type', 'chromium')- wait_for_selector = p.get('wait_for_selector', '')- wait_timeout = p.get('wait_timeout', 30000)- take_screenshot = p.get('screenshot', False) or p.get('take_screenshot', False)+ browser_type = p.get("browser_type", "chromium")+ wait_for_selector = p.get("wait_for_selector", "")+ wait_timeout = p.get("wait_timeout", 30000)+ take_screenshot = p.get("screenshot", False) or p.get("take_screenshot", False)crawler = PlaywrightCrawler(- browser_type=browser_type, headless=True,+ browser_type=browser_type,+ headless=True,max_requests_per_crawl=max_pages,- max_crawl_depth=max_depth if mode == 'crawl' else 0,+ max_crawl_depth=max_depth if mode == "crawl" else 0,request_handler_timeout=timedelta(seconds=timeout_secs),concurrency_settings=ConcurrencySettings(max_concurrency=max_concurrency,@@ -133,8 +140,8 @@ async def _run_playwright(url, pages, p, proxy_config, css_selector, extract_linproxy_configuration=proxy_config,configure_logging=False,)- link_selector = p.get('link_selector', '') or 'a[href]'- url_pattern = p.get('url_pattern', '')+ link_selector = p.get("link_selector", "") or "a[href]"+ url_pattern = p.get("url_pattern", "")@crawler.router.default_handlerasync def handler(ctx: PlaywrightCrawlingContext) -> None:@@ -144,25 +151,30 @@ async def _run_playwright(url, pages, p, proxy_config, css_selector, extract_lintitle = await page.title()html = await page.content()from bs4 import BeautifulSoup- soup = BeautifulSoup(html, 'html.parser')++ soup = BeautifulSoup(html, "html.parser")content = _extract_text(soup, css_selector, output_format)page_data: Dict[str, Any] = {- 'url': ctx.request.url, 'title': title, 'content': content,+ "url": ctx.request.url,+ "title": title,+ "content": content,}if extract_links:- page_data['links'] = _extract_links(soup, ctx.request.url)+ page_data["links"] = _extract_links(soup, ctx.request.url)if take_screenshot:import base64- screenshot_bytes = await page.screenshot(type='png')- page_data['screenshot'] = base64.b64encode(screenshot_bytes).decode()++ screenshot_bytes = await page.screenshot(type="png")+ page_data["screenshot"] = base64.b64encode(screenshot_bytes).decode()pages.append(page_data)- if mode == 'crawl':- kwargs: Dict[str, Any] = {'selector': link_selector}+ if mode == "crawl":+ kwargs: Dict[str, Any] = {"selector": link_selector}if url_pattern:import refrom fnmatch import translate- kwargs['include'] = [re.compile(translate(url_pattern))]++ kwargs["include"] = [re.compile(translate(url_pattern))]await ctx.enqueue_links(**kwargs)await asyncio.wait_for(crawler.run([url]), timeout=timeout_secs)@@ -209,7 +221,9 @@ class CrawleeScraperParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"mode": ["crawl"]}}},)max_depth: int = Field(- default=2, ge=0, le=50,+ default=2,+ ge=0,+ le=50,description="Max link-following depth.",json_schema_extra={"displayOptions": {"show": {"mode": ["crawl"]}}},)@@ -225,7 +239,9 @@ class CrawleeScraperParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"crawler_type": ["playwright"]}}},)wait_timeout: int = Field(- default=30000, ge=0, le=600000,+ default=30000,+ ge=0,+ le=600000,description="Wait-for-selector timeout in milliseconds.",json_schema_extra={"displayOptions": {"show": {"crawler_type": ["playwright"]}}},)@@ -255,7 +271,8 @@ class CrawleeScraperParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"use_proxy": [True]}}},)sticky_duration: int = Field(- default=600, ge=1,+ default=600,+ ge=1,json_schema_extra={"displayOptions": {"show": {"use_proxy": [True], "session_type": ["sticky"]}},},@@ -305,8 +322,8 @@ class CrawleeScraperNode(ActionNode):css_selector = params.css_selectorextract_links = params.extract_linksoutput_format = params.output_format- max_pages = params.max_pages if mode == 'crawl' else 1- max_depth = params.max_depth if mode == 'crawl' else 0+ max_pages = params.max_pages if mode == "crawl" else 1+ max_depth = params.max_depth if mode == "crawl" else 0max_concurrency = params.max_concurrencytimeout_secs = params.timeout@@ -315,28 +332,45 @@ class CrawleeScraperNode(ActionNode):proxy_config = await _get_proxy_config(p, url)try:- if crawler_type in ('beautifulsoup', 'adaptive'):+ if crawler_type in ("beautifulsoup", "adaptive"):await _run_beautifulsoup(- url, pages, p, proxy_config, css_selector, extract_links,- output_format, mode, max_pages, max_depth,- max_concurrency, timeout_secs,+ url,+ pages,+ p,+ proxy_config,+ css_selector,+ extract_links,+ output_format,+ mode,+ max_pages,+ max_depth,+ max_concurrency,+ timeout_secs,)- elif crawler_type == 'playwright':+ elif crawler_type == "playwright":await _run_playwright(- url, pages, p, proxy_config, css_selector, extract_links,- output_format, mode, max_pages, max_depth,- max_concurrency, timeout_secs,+ url,+ pages,+ p,+ proxy_config,+ css_selector,+ extract_links,+ output_format,+ mode,+ max_pages,+ max_depth,+ max_concurrency,+ timeout_secs,)else:raise NodeUserError(f"Unknown crawler type: {crawler_type}")except ImportError as e:msg = str(e).lower()- if 'playwright' in msg:+ if "playwright" in msg:raise NodeUserError(- "Playwright not installed. Run: "- "pip install 'crawlee[playwright]' && playwright install chromium",+ "Playwright not installed. Run: " "pip install 'crawlee[playwright]' && playwright install chromium",)- if 'crawlee' in msg:+ if "crawlee" in msg:raise NodeUserError("Crawlee not installed. Run: pip install 'crawlee[beautifulsoup]'",)@@ -344,6 +378,9 @@ class CrawleeScraperNode(ActionNode):logger.info(f"[Crawlee] Scraped {len(pages)} page(s) from {url}")return CrawleeScraperOutput(- pages=pages, page_count=len(pages),- crawler_type=crawler_type, mode=mode, proxied=proxy_config is not None,+ pages=pages,+ page_count=len(pages),+ crawler_type=crawler_type,+ mode=mode,+ proxied=proxy_config is not None,)diff --git a/server/nodes/search/brave_search/__init__.py b/server/nodes/search/brave_search/__init__.pyindex d095e8bf..06ceee8a 100644--- a/server/nodes/search/brave_search/__init__.py+++ b/server/nodes/search/brave_search/__init__.py@@ -68,9 +68,7 @@ class BraveSearchParams(BaseModel):max_results: int = Field(default=10, ge=1, le=20)country: str = Field(default="", description="ISO country code (e.g. US, GB)")search_lang: str = Field(default="en")- safe_search: Literal["off", "moderate", "strict"] = Field(- default="moderate"- )+ safe_search: Literal["off", "moderate", "strict"] = Field(default="moderate")model_config = {"extra": "ignore"}@@ -125,5 +123,7 @@ class BraveSearchNode(ActionNode):for item in web_results[: params.max_results]]return BraveSearchOutput(- query=params.query, results=items, result_count=len(items),+ query=params.query,+ results=items,+ result_count=len(items),)diff --git a/server/nodes/search/duckduckgo_search/__init__.py b/server/nodes/search/duckduckgo_search/__init__.pyindex 5dbf052f..c53c2402 100644--- a/server/nodes/search/duckduckgo_search/__init__.py+++ b/server/nodes/search/duckduckgo_search/__init__.py@@ -46,10 +46,8 @@ class DuckDuckGoSearchNode(ToolNode):tool_name = "web_search"tool_description = "Search the web for information using DuckDuckGo. Returns relevant search results. Free, no API key required."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-tool", "kind": "output", "position": "top",- "label": "Tool", "role": "tools"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-tool", "kind": "output", "position": "top", "label": "Tool", "role": "tools"},)ui_hints = {"isToolPanel": True, "hideRunButton": True}annotations = {"destructive": False, "readonly": True, "open_world": True}@@ -60,7 +58,9 @@ class DuckDuckGoSearchNode(ToolNode):@Operation("search")async def search(- self, ctx: NodeContext, params: DuckDuckGoSearchParams,+ self,+ ctx: NodeContext,+ params: DuckDuckGoSearchParams,) -> DuckDuckGoSearchOutput:from ddgs import DDGSfrom ddgs.exceptions import DDGSExceptiondiff --git a/server/nodes/search/perplexity_search/__init__.py b/server/nodes/search/perplexity_search/__init__.pyindex dd00c206..b35b955c 100644--- a/server/nodes/search/perplexity_search/__init__.py+++ b/server/nodes/search/perplexity_search/__init__.py@@ -86,10 +86,8 @@ class PerplexitySearchNode(ActionNode):tool_name = "perplexity_search"tool_description = "Search the web using Perplexity Sonar AI. Returns an AI-generated answer with citations and source URLs."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)credentials = (PerplexityCredential,)annotations = {"destructive": False, "readonly": True, "open_world": True}diff --git a/server/nodes/search/serper_search/__init__.py b/server/nodes/search/serper_search/__init__.pyindex 9e6e2649..3fea2f1f 100644--- a/server/nodes/search/serper_search/__init__.py+++ b/server/nodes/search/serper_search/__init__.py@@ -66,7 +66,7 @@ class SerperSearchParams(BaseModel):_ENDPOINTS = {"search": "https://google.serper.dev/search",- "news": "https://google.serper.dev/news",+ "news": "https://google.serper.dev/news","images": "https://google.serper.dev/images","places": "https://google.serper.dev/places",}@@ -82,10 +82,8 @@ class SerperSearchNode(ActionNode):tool_name = "serper_search"tool_description = "Search the web using Google via Serper API. Returns web results with titles, snippets, and URLs."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)credentials = (SerperCredential,)annotations = {"destructive": False, "readonly": True, "open_world": True}@@ -115,31 +113,39 @@ class SerperSearchNode(ActionNode):results: List[SerperSearchResult] = []if params.search_type == "search":for item in (data.get("organic") or [])[: params.max_results]:- results.append(SerperSearchResult(- title=item.get("title", ""),- snippet=item.get("snippet", ""),- url=item.get("link", ""),- position=item.get("position"),- ))+ results.append(+ SerperSearchResult(+ title=item.get("title", ""),+ snippet=item.get("snippet", ""),+ url=item.get("link", ""),+ position=item.get("position"),+ )+ )elif params.search_type == "news":for item in (data.get("news") or [])[: params.max_results]:- results.append(SerperSearchResult(- title=item.get("title", ""),- snippet=item.get("snippet", ""),- url=item.get("link", ""),- ))+ results.append(+ SerperSearchResult(+ title=item.get("title", ""),+ snippet=item.get("snippet", ""),+ url=item.get("link", ""),+ )+ )elif params.search_type == "images":for item in (data.get("images") or [])[: params.max_results]:- results.append(SerperSearchResult(- title=item.get("title", ""),- url=item.get("imageUrl") or item.get("link", ""),- ))+ results.append(+ SerperSearchResult(+ title=item.get("title", ""),+ url=item.get("imageUrl") or item.get("link", ""),+ )+ )elif params.search_type == "places":for item in (data.get("places") or [])[: params.max_results]:- results.append(SerperSearchResult(- title=item.get("title", ""),- url=item.get("website", ""),- ))+ results.append(+ SerperSearchResult(+ title=item.get("title", ""),+ url=item.get("website", ""),+ )+ )return SerperSearchOutput(query=params.query,results=results,diff --git a/server/nodes/skill/_expander.py b/server/nodes/skill/_expander.pyindex 60522bfa..af2001af 100644--- a/server/nodes/skill/_expander.py+++ b/server/nodes/skill/_expander.py@@ -59,13 +59,15 @@ async def expand_master_skill(except Exception as exc: # noqa: BLE001 -- log + skiplogger.warning(f"[MasterSkill] Failed to load skill {skill_key}: {exc}")- entries.append({- "node_id": f"{source_node_id}_{skill_key}",- "node_type": "masterSkill",- "skill_name": skill_key,- "parameters": {"instructions": instructions, "skillName": skill_key},- "label": skill_key,- })+ entries.append(+ {+ "node_id": f"{source_node_id}_{skill_key}",+ "node_type": "masterSkill",+ "skill_name": skill_key,+ "parameters": {"instructions": instructions, "skillName": skill_key},+ "label": skill_key,+ }+ )return entriesdiff --git a/server/nodes/skill/master_skill/__init__.py b/server/nodes/skill/master_skill/__init__.pyindex ce6bb6eb..c460dbb9 100644--- a/server/nodes/skill/master_skill/__init__.py+++ b/server/nodes/skill/master_skill/__init__.py@@ -37,10 +37,7 @@ class MasterSkillNode(ActionNode):group = ("tool",)description = "Aggregate multiple skills with enable/disable toggles"component_kind = "tool"- handles = (- {"name": "output-skill", "kind": "output", "position": "top",- "label": "Skill", "role": "skill"},- )+ handles = ({"name": "output-skill", "kind": "output", "position": "top", "label": "Skill", "role": "skill"},)ui_hints = {"isToolPanel": True,"isMasterSkillEditor": True,@@ -57,8 +54,5 @@ class MasterSkillNode(ActionNode):@Operation("noop")async def noop(self, ctx: NodeContext, params: MasterSkillParams) -> MasterSkillOutput:# Passive node — agent reads skillsConfig during execution.- active = sum(- 1 for cfg in (params.skills_config or {}).values()- if isinstance(cfg, dict) and cfg.get("enabled")- )+ active = sum(1 for cfg in (params.skills_config or {}).values() if isinstance(cfg, dict) and cfg.get("enabled"))return MasterSkillOutput(skills_active=active)diff --git a/server/nodes/skill/master_skill/_events.py b/server/nodes/skill/master_skill/_events.pyindex 47390586..320b5ac1 100644--- a/server/nodes/skill/master_skill/_events.py+++ b/server/nodes/skill/master_skill/_events.py@@ -69,10 +69,12 @@ async def broadcast_skill_lifecycle(broadcaster = get_status_broadcaster()event = skill_lifecycle_event(stage, name=name, data=data_extra or None)- await broadcaster.broadcast({- "type": _WIRE_KEY,- "data": event.model_dump(mode="json"),- })+ await broadcaster.broadcast(+ {+ "type": _WIRE_KEY,+ "data": event.model_dump(mode="json"),+ }+ )__all__ = [diff --git a/server/nodes/skill/simple_memory/__init__.py b/server/nodes/skill/simple_memory/__init__.pyindex cd418f08..89c5566b 100644--- a/server/nodes/skill/simple_memory/__init__.py+++ b/server/nodes/skill/simple_memory/__init__.py@@ -29,10 +29,7 @@ class SimpleMemoryParams(BaseModel):session_id: str = Field(default="",title="Session ID (Override)",- description=(- "Leave empty to auto-use connected agent ID. "- "Set manually to share memory across agents."- ),+ description=("Leave empty to auto-use connected agent ID. " "Set manually to share memory across agents."),json_schema_extra={"placeholder": "Auto (uses agent ID)"},)window_size: int = Field(@@ -40,10 +37,7 @@ class SimpleMemoryParams(BaseModel):ge=1,le=100,title="Window Size",- description=(- "Number of message pairs to keep in short-term memory "- "(uses global default from Settings)"- ),+ description=("Number of message pairs to keep in short-term memory " "(uses global default from Settings)"),)memory_content: str = Field(default="# Conversation History\n\n*No messages yet.*\n",@@ -102,10 +96,7 @@ class SimpleMemoryNode(ActionNode):group = ("tool", "memory")description = "Markdown-based conversation memory with optional vector DB"component_kind = "model"- handles = (- {"name": "output-memory", "kind": "output", "position": "top",- "label": "Memory", "role": "memory"},- )+ handles = ({"name": "output-memory", "kind": "output", "position": "top", "label": "Memory", "role": "memory"},)ui_hints = {"isMemoryPanel": True, "hasCodeEditor": True, "hideRunButton": True}annotations = {"destructive": False, "readonly": True, "open_world": False}task_queue = TaskQueue.DEFAULTdiff --git a/server/nodes/social/_base.py b/server/nodes/social/_base.pyindex 8db5cd1c..7d872b2f 100644--- a/server/nodes/social/_base.py+++ b/server/nodes/social/_base.py@@ -20,35 +20,32 @@ logger = get_logger(__name__)# Platform-specific field mappings to unified formatPLATFORM_FIELD_MAPPINGS = {- 'whatsapp': {- 'sender': 'sender',- 'sender_phone': 'sender_phone',- 'sender_name': 'push_name',- 'chat_id': 'chat_id',- 'text': 'text',- 'message_type': 'message_type',- 'is_group': 'is_group',- 'is_from_me': 'is_from_me',- 'timestamp': 'timestamp',- 'message_id': 'message_id',+ "whatsapp": {+ "sender": "sender",+ "sender_phone": "sender_phone",+ "sender_name": "push_name",+ "chat_id": "chat_id",+ "text": "text",+ "message_type": "message_type",+ "is_group": "is_group",+ "is_from_me": "is_from_me",+ "timestamp": "timestamp",+ "message_id": "message_id",},# Add more platform mappings as they are integrated- 'telegram': {},- 'discord': {},- 'slack': {},- 'signal': {},- 'sms': {},- 'webchat': {},- 'email': {},- 'matrix': {},- 'teams': {},+ "telegram": {},+ "discord": {},+ "slack": {},+ "signal": {},+ "sms": {},+ "webchat": {},+ "email": {},+ "matrix": {},+ "teams": {},}-def _normalize_to_unified_format(- input_data: Dict[str, Any],- source_channel: str-) -> Dict[str, Any]:+def _normalize_to_unified_format(input_data: Dict[str, Any], source_channel: str) -> Dict[str, Any]:"""Normalize platform-specific message data to unified social format.Args:@@ -61,88 +58,85 @@ def _normalize_to_unified_format(import uuid# Generate message_id if not present (e.g., chatTrigger doesn't have one)- message_id = input_data.get('message_id') or str(uuid.uuid4())[:8]+ message_id = input_data.get("message_id") or str(uuid.uuid4())[:8]# For webchat, use session_id as sender/chat_id if not provided- session_id = input_data.get('session_id', 'default')- default_sender = f"webchat_{session_id}" if source_channel == 'webchat' else ''- default_chat_id = session_id if source_channel == 'webchat' else ''+ session_id = input_data.get("session_id", "default")+ default_sender = f"webchat_{session_id}" if source_channel == "webchat" else ""+ default_chat_id = session_id if source_channel == "webchat" else ""# Start with unified structureunified = {- 'message_id': message_id,- 'channel': source_channel,- 'sender': input_data.get('sender') or default_sender,- 'sender_phone': input_data.get('sender_phone', ''),- 'sender_name': input_data.get('sender_name') or input_data.get('push_name') or ('User' if source_channel == 'webchat' else ''),- 'sender_username': input_data.get('sender_username', ''),- 'chat_id': input_data.get('chat_id') or default_chat_id,- 'chat_title': input_data.get('chat_title', ''),- 'chat_type': _determine_chat_type(input_data),- 'message_type': input_data.get('message_type', 'text'),- 'text': input_data.get('text') or input_data.get('message', ''),- 'timestamp': input_data.get('timestamp', datetime.now().isoformat()),- 'is_group': input_data.get('is_group', False),- 'is_from_me': input_data.get('is_from_me', False),- 'is_forwarded': input_data.get('is_forwarded', False),- 'is_bot': input_data.get('is_bot', False),- 'is_admin': input_data.get('is_admin', False),- 'thread_id': input_data.get('thread_id'),- 'account_id': input_data.get('account_id'),- 'session_id': input_data.get('session_id'),+ "message_id": message_id,+ "channel": source_channel,+ "sender": input_data.get("sender") or default_sender,+ "sender_phone": input_data.get("sender_phone", ""),+ "sender_name": input_data.get("sender_name") or input_data.get("push_name") or ("User" if source_channel == "webchat" else ""),+ "sender_username": input_data.get("sender_username", ""),+ "chat_id": input_data.get("chat_id") or default_chat_id,+ "chat_title": input_data.get("chat_title", ""),+ "chat_type": _determine_chat_type(input_data),+ "message_type": input_data.get("message_type", "text"),+ "text": input_data.get("text") or input_data.get("message", ""),+ "timestamp": input_data.get("timestamp", datetime.now().isoformat()),+ "is_group": input_data.get("is_group", False),+ "is_from_me": input_data.get("is_from_me", False),+ "is_forwarded": input_data.get("is_forwarded", False),+ "is_bot": input_data.get("is_bot", False),+ "is_admin": input_data.get("is_admin", False),+ "thread_id": input_data.get("thread_id"),+ "account_id": input_data.get("account_id"),+ "session_id": input_data.get("session_id"),}# Copy group_info if present- if input_data.get('group_info'):- unified['group_info'] = input_data['group_info']+ if input_data.get("group_info"):+ unified["group_info"] = input_data["group_info"]# Copy media if present- if input_data.get('media'):- unified['media'] = input_data['media']+ if input_data.get("media"):+ unified["media"] = input_data["media"]# Copy location if present- if input_data.get('location'):- unified['location'] = input_data['location']+ if input_data.get("location"):+ unified["location"] = input_data["location"]# Copy contact if present- if input_data.get('contact'):- unified['contact'] = input_data['contact']+ if input_data.get("contact"):+ unified["contact"] = input_data["contact"]# Copy poll if present- if input_data.get('poll'):- unified['poll'] = input_data['poll']+ if input_data.get("poll"):+ unified["poll"] = input_data["poll"]# Copy reaction if present- if input_data.get('reaction'):- unified['reaction'] = input_data['reaction']+ if input_data.get("reaction"):+ unified["reaction"] = input_data["reaction"]# Copy reply_to if present- if input_data.get('reply_to'):- unified['reply_to'] = input_data['reply_to']+ if input_data.get("reply_to"):+ unified["reply_to"] = input_data["reply_to"]# Copy mentions if present- if input_data.get('mentions'):- unified['mentions'] = input_data['mentions']+ if input_data.get("mentions"):+ unified["mentions"] = input_data["mentions"]# Keep raw data for platform-specific access- unified['raw'] = input_data.get('raw', input_data)+ unified["raw"] = input_data.get("raw", input_data)return unifieddef _determine_chat_type(data: Dict[str, Any]) -> str:"""Determine chat type from message data."""- if data.get('chat_type'):- return data['chat_type']- if data.get('is_group'):- return 'group'- return 'dm'+ if data.get("chat_type"):+ return data["chat_type"]+ if data.get("is_group"):+ return "group"+ return "dm"-def _apply_filters(- message: Dict[str, Any],- parameters: Dict[str, Any]-) -> bool:+def _apply_filters(message: Dict[str, Any], parameters: Dict[str, Any]) -> bool:"""Check if message passes configured filters.Args:@@ -153,50 +147,50 @@ def _apply_filters(True if message passes all filters"""# Channel filter- channel_filter = parameters.get('channel_filter', 'all')- if channel_filter != 'all' and message.get('channel') != channel_filter:+ channel_filter = parameters.get("channel_filter", "all")+ if channel_filter != "all" and message.get("channel") != channel_filter:return False# Message type filter- type_filter = parameters.get('message_type_filter', 'all')- if type_filter != 'all' and message.get('message_type') != type_filter:+ type_filter = parameters.get("message_type_filter", "all")+ if type_filter != "all" and message.get("message_type") != type_filter:return False# Sender filter- sender_filter = parameters.get('sender_filter', 'all')+ sender_filter = parameters.get("sender_filter", "all")- if sender_filter == 'any_contact':+ if sender_filter == "any_contact":# Non-group messages only- if message.get('is_group'):+ if message.get("is_group"):return False- elif sender_filter == 'contact':+ elif sender_filter == "contact":# Specific contact- contact_phone = parameters.get('contact_phone', '')- if contact_phone and message.get('sender_phone') != contact_phone:+ contact_phone = parameters.get("contact_phone", "")+ if contact_phone and message.get("sender_phone") != contact_phone:return False- elif sender_filter == 'group':+ elif sender_filter == "group":# Specific group- group_id = parameters.get('group_id', '')- if group_id and message.get('chat_id') != group_id:+ group_id = parameters.get("group_id", "")+ if group_id and message.get("chat_id") != group_id:return False- elif sender_filter == 'keywords':+ elif sender_filter == "keywords":# Keyword matching- keywords_str = parameters.get('keywords', '')+ keywords_str = parameters.get("keywords", "")if keywords_str:- keywords = [k.strip().lower() for k in keywords_str.split(',')]- text = (message.get('text') or '').lower()+ keywords = [k.strip().lower() for k in keywords_str.split(",")]+ text = (message.get("text") or "").lower()if not any(kw in text for kw in keywords):return False# Ignore own messages- if parameters.get('ignore_own_messages', True) and message.get('is_from_me'):+ if parameters.get("ignore_own_messages", True) and message.get("is_from_me"):return False# Ignore bots- if parameters.get('ignore_bots', False) and message.get('is_bot'):+ if parameters.get("ignore_bots", False) and message.get("is_bot"):return Falsereturn True@@ -208,7 +202,7 @@ async def handle_social_receive(parameters: Dict[str, Any],context: Dict[str, Any],outputs: Dict[str, Any] = None,- source_nodes: list = None+ source_nodes: list = None,) -> Dict[str, Any]:"""Handle Social Receive node - normalizes and filters incoming messages.@@ -230,7 +224,7 @@ async def handle_social_receive(# Use outputs passed from node_executor, fall back to context for backwards compatibilityif outputs is None:- outputs = context.get('outputs', {})+ outputs = context.get("outputs", {})if source_nodes is None:source_nodes = []@@ -238,31 +232,31 @@ async def handle_social_receive(try:input_data = None- source_channel = 'unknown'+ source_channel = "unknown"# Find message data from connected outputs# Outputs are keyed by node type (e.g., 'whatsappReceive') and contain raw data directlyfor source_node in source_nodes:- source_type = source_node.get('type', '')+ source_type = source_node.get("type", "")source_output = outputs.get(source_type)if source_output and isinstance(source_output, dict):# Check if this output has message data (message_id, text, or message field)- if source_output.get('message_id') or source_output.get('text') or source_output.get('message'):+ if source_output.get("message_id") or source_output.get("text") or source_output.get("message"):input_data = source_output# Detect source channel from node type- if 'whatsapp' in source_type.lower():- source_channel = 'whatsapp'- elif 'telegram' in source_type.lower():- source_channel = 'telegram'- elif 'discord' in source_type.lower():- source_channel = 'discord'- elif 'slack' in source_type.lower():- source_channel = 'slack'- elif 'chat' in source_type.lower():- source_channel = 'webchat'- elif source_output.get('channel'):- source_channel = source_output['channel']+ if "whatsapp" in source_type.lower():+ source_channel = "whatsapp"+ elif "telegram" in source_type.lower():+ source_channel = "telegram"+ elif "discord" in source_type.lower():+ source_channel = "discord"+ elif "slack" in source_type.lower():+ source_channel = "slack"+ elif "chat" in source_type.lower():+ source_channel = "webchat"+ elif source_output.get("channel"):+ source_channel = source_output["channel"]logger.debug(f"[handle_social_receive] Found message from {source_type}, channel={source_channel}")break@@ -270,27 +264,29 @@ async def handle_social_receive(if not input_data:for upstream_key, upstream_output in outputs.items():if isinstance(upstream_output, dict):- if upstream_output.get('message_id') or upstream_output.get('text') or upstream_output.get('message'):+ if upstream_output.get("message_id") or upstream_output.get("text") or upstream_output.get("message"):input_data = upstream_output# Detect source channel from key or data- if 'whatsapp' in upstream_key.lower() or upstream_output.get('sender', '').endswith('@s.whatsapp.net'):- source_channel = 'whatsapp'- elif 'chat' in upstream_key.lower():- source_channel = 'webchat'- elif upstream_output.get('channel'):- source_channel = upstream_output['channel']+ if "whatsapp" in upstream_key.lower() or upstream_output.get("sender", "").endswith("@s.whatsapp.net"):+ source_channel = "whatsapp"+ elif "chat" in upstream_key.lower():+ source_channel = "webchat"+ elif upstream_output.get("channel"):+ source_channel = upstream_output["channel"]logger.debug(f"[handle_social_receive] Found message via fallback from key={upstream_key}")breakif not input_data:- logger.warning(f"[handle_social_receive] No message data found. outputs keys={list(outputs.keys())}, source_nodes={source_nodes}")+ logger.warning(+ f"[handle_social_receive] No message data found. outputs keys={list(outputs.keys())}, source_nodes={source_nodes}"+ )return {"success": False,"node_id": node_id,"node_type": "socialReceive","error": f"No message data received from upstream trigger. Available sources: {list(outputs.keys())}","execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}# Normalize to unified format@@ -306,7 +302,7 @@ async def handle_social_receive("filtered": True,"reason": "Message did not pass filters","execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}# Build result with four outputs:@@ -314,48 +310,46 @@ async def handle_social_receive(# - media: Media data and metadata# - contact: Sender/contact info# - metadata: Message-related metadata- media_data = unified_message.get('media', {})+ media_data = unified_message.get("media", {})result = {# Output 1: Just the text message- "message": unified_message.get('text', ''),-+ "message": unified_message.get("text", ""),# Output 2: Media data and related metadata"media": {- "url": media_data.get('url', '') if media_data else '',- "type": media_data.get('type', '') if media_data else '',- "mimetype": media_data.get('mimetype', '') if media_data else '',- "caption": media_data.get('caption', '') if media_data else '',- "size": media_data.get('size', 0) if media_data else 0,- "thumbnail": media_data.get('thumbnail', '') if media_data else '',- "filename": media_data.get('filename', '') if media_data else '',- } if media_data else {},-+ "url": media_data.get("url", "") if media_data else "",+ "type": media_data.get("type", "") if media_data else "",+ "mimetype": media_data.get("mimetype", "") if media_data else "",+ "caption": media_data.get("caption", "") if media_data else "",+ "size": media_data.get("size", 0) if media_data else 0,+ "thumbnail": media_data.get("thumbnail", "") if media_data else "",+ "filename": media_data.get("filename", "") if media_data else "",+ }+ if media_data+ else {},# Output 3: Contact/sender info"contact": {- "sender": unified_message.get('sender'),- "sender_phone": unified_message.get('sender_phone'),- "sender_name": unified_message.get('sender_name'),- "sender_username": unified_message.get('sender_username'),- "channel": unified_message.get('channel'),- "is_group": unified_message.get('is_group'),- "group_info": unified_message.get('group_info'),- "chat_title": unified_message.get('chat_title'),+ "sender": unified_message.get("sender"),+ "sender_phone": unified_message.get("sender_phone"),+ "sender_name": unified_message.get("sender_name"),+ "sender_username": unified_message.get("sender_username"),+ "channel": unified_message.get("channel"),+ "is_group": unified_message.get("is_group"),+ "group_info": unified_message.get("group_info"),+ "chat_title": unified_message.get("chat_title"),},-# Output 4: Message-related metadata"metadata": {- "message_id": unified_message.get('message_id'),- "chat_id": unified_message.get('chat_id'),- "timestamp": unified_message.get('timestamp'),- "message_type": unified_message.get('message_type'),- "is_from_me": unified_message.get('is_from_me'),- "is_forwarded": unified_message.get('is_forwarded'),- "reply_to": unified_message.get('reply_to'),- "thread_id": unified_message.get('thread_id'),+ "message_id": unified_message.get("message_id"),+ "chat_id": unified_message.get("chat_id"),+ "timestamp": unified_message.get("timestamp"),+ "message_type": unified_message.get("message_type"),+ "is_from_me": unified_message.get("is_from_me"),+ "is_forwarded": unified_message.get("is_forwarded"),+ "reply_to": unified_message.get("reply_to"),+ "thread_id": unified_message.get("thread_id"),},-# Backwards compatibility: include full data at top level- **unified_message+ **unified_message,}return {@@ -364,7 +358,7 @@ async def handle_social_receive("node_type": "socialReceive","result": result,"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:@@ -375,16 +369,11 @@ async def handle_social_receive("node_type": "socialReceive","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}-async def handle_social_send(- node_id: str,- node_type: str,- parameters: Dict[str, Any],- context: Dict[str, Any]-) -> Dict[str, Any]:+async def handle_social_send(node_id: str, node_type: str, parameters: Dict[str, Any], context: Dict[str, Any]) -> Dict[str, Any]:"""Handle Social Send node - routes outbound messages to platform.This node sends messages to the configured platform (WhatsApp, Telegram, etc.)@@ -402,39 +391,35 @@ async def handle_social_send(start_time = time.time()try:- channel = parameters.get('channel', 'whatsapp')- recipient_type = parameters.get('recipient_type', 'phone')- message_type = parameters.get('message_type', 'text')+ channel = parameters.get("channel", "whatsapp")+ recipient_type = parameters.get("recipient_type", "phone")+ message_type = parameters.get("message_type", "text")# Get recipient based on typerecipient = None- if recipient_type == 'phone':- recipient = parameters.get('phone')- elif recipient_type == 'group':- recipient = parameters.get('group_id')- elif recipient_type == 'channel':- recipient = parameters.get('channel_id')- elif recipient_type == 'user':- recipient = parameters.get('user_id')- elif recipient_type == 'chat':- recipient = parameters.get('chat_id')+ if recipient_type == "phone":+ recipient = parameters.get("phone")+ elif recipient_type == "group":+ recipient = parameters.get("group_id")+ elif recipient_type == "channel":+ recipient = parameters.get("channel_id")+ elif recipient_type == "user":+ recipient = parameters.get("user_id")+ elif recipient_type == "chat":+ recipient = parameters.get("chat_id")if not recipient:raise ValueError(f"Recipient ({recipient_type}) is required")# Route to platform-specific handler- if channel == 'whatsapp':+ if channel == "whatsapp":result = await _send_via_whatsapp(parameters, recipient, recipient_type, message_type)else:# Stub for other platforms - will be implemented as they are integrated- result = {- "success": False,- "error": f"Platform '{channel}' is not yet implemented",- "message_id": None- }+ result = {"success": False, "error": f"Platform '{channel}' is not yet implemented", "message_id": None}- if not result.get('success'):- raise Exception(result.get('error', 'Send failed'))+ if not result.get("success"):+ raise Exception(result.get("error", "Send failed"))return {"success": True,@@ -442,15 +427,15 @@ async def handle_social_send("node_type": "socialSend","result": {"success": True,- "message_id": result.get('message_id'),+ "message_id": result.get("message_id"),"channel": channel,"recipient": recipient,"recipient_type": recipient_type,"message_type": message_type,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:@@ -461,16 +446,11 @@ async def handle_social_send("node_type": "socialSend","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}-async def _send_via_whatsapp(- parameters: Dict[str, Any],- recipient: str,- recipient_type: str,- message_type: str-) -> Dict[str, Any]:+async def _send_via_whatsapp(parameters: Dict[str, Any], recipient: str, recipient_type: str, message_type: str) -> Dict[str, Any]:"""Route message to WhatsApp via the social-provider registry.Maps socialSend parameters to whatsappSend parameters, then@@ -491,52 +471,52 @@ async def _send_via_whatsapp(# Map socialSend params to whatsappSend formatwhatsapp_params = {- 'recipient_type': recipient_type,- 'message_type': message_type,+ "recipient_type": recipient_type,+ "message_type": message_type,}# Set recipient- if recipient_type == 'phone':- whatsapp_params['phone'] = recipient+ if recipient_type == "phone":+ whatsapp_params["phone"] = recipientelse:- whatsapp_params['group_id'] = recipient+ whatsapp_params["group_id"] = recipient# Map message content based on type- if message_type == 'text':- whatsapp_params['message'] = parameters.get('message', '')-- elif message_type in ('image', 'video', 'audio', 'document', 'sticker'):- media_source = parameters.get('media_source', 'url')- whatsapp_params['media_source'] = media_source-- if media_source == 'url':- whatsapp_params['media_url'] = parameters.get('media_url', '')- elif media_source == 'base64':- whatsapp_params['media_data'] = parameters.get('media_data', '')- elif media_source == 'file':- whatsapp_params['file_path'] = parameters.get('file_path', '')-- if parameters.get('mime_type'):- whatsapp_params['mime_type'] = parameters['mime_type']- if parameters.get('caption'):- whatsapp_params['caption'] = parameters['caption']- if parameters.get('filename'):- whatsapp_params['filename'] = parameters['filename']-- elif message_type == 'location':- whatsapp_params['latitude'] = parameters.get('latitude', 0)- whatsapp_params['longitude'] = parameters.get('longitude', 0)- whatsapp_params['location_name'] = parameters.get('location_name', '')- whatsapp_params['address'] = parameters.get('address', '')-- elif message_type == 'contact':- whatsapp_params['contact_name'] = parameters.get('contact_name', '')- whatsapp_params['vcard'] = parameters.get('vcard', '')+ if message_type == "text":+ whatsapp_params["message"] = parameters.get("message", "")++ elif message_type in ("image", "video", "audio", "document", "sticker"):+ media_source = parameters.get("media_source", "url")+ whatsapp_params["media_source"] = media_source++ if media_source == "url":+ whatsapp_params["media_url"] = parameters.get("media_url", "")+ elif media_source == "base64":+ whatsapp_params["media_data"] = parameters.get("media_data", "")+ elif media_source == "file":+ whatsapp_params["file_path"] = parameters.get("file_path", "")++ if parameters.get("mime_type"):+ whatsapp_params["mime_type"] = parameters["mime_type"]+ if parameters.get("caption"):+ whatsapp_params["caption"] = parameters["caption"]+ if parameters.get("filename"):+ whatsapp_params["filename"] = parameters["filename"]++ elif message_type == "location":+ whatsapp_params["latitude"] = parameters.get("latitude", 0)+ whatsapp_params["longitude"] = parameters.get("longitude", 0)+ whatsapp_params["location_name"] = parameters.get("location_name", "")+ whatsapp_params["address"] = parameters.get("address", "")++ elif message_type == "contact":+ whatsapp_params["contact_name"] = parameters.get("contact_name", "")+ whatsapp_params["vcard"] = parameters.get("vcard", "")# Reply options- if parameters.get('reply_to_message'):- whatsapp_params['is_reply'] = True- whatsapp_params['reply_message_id'] = parameters.get('reply_message_id', '')+ if parameters.get("reply_to_message"):+ whatsapp_params["is_reply"] = True+ whatsapp_params["reply_message_id"] = parameters.get("reply_message_id", "")# Call WhatsApp handlerreturn await whatsapp_send_handler(whatsapp_params)diff --git a/server/nodes/social/social_receive/__init__.py b/server/nodes/social/social_receive/__init__.pyindex dc0e0fe8..737c352e 100644--- a/server/nodes/social/social_receive/__init__.py+++ b/server/nodes/social/social_receive/__init__.py@@ -28,21 +28,43 @@ class SocialReceiveParams(BaseModel):"""channel_filter: Literal[- "all", "whatsapp", "telegram", "discord", "slack", "signal",- "sms", "webchat", "email", "matrix", "teams",+ "all",+ "whatsapp",+ "telegram",+ "discord",+ "slack",+ "signal",+ "sms",+ "webchat",+ "email",+ "matrix",+ "teams",] = Field(default="all",description="Filter by source platform",)message_type_filter: Literal[- "all", "text", "image", "video", "audio", "document",- "sticker", "location", "contact", "poll", "reaction",+ "all",+ "text",+ "image",+ "video",+ "audio",+ "document",+ "sticker",+ "location",+ "contact",+ "poll",+ "reaction",] = Field(default="all",description="Filter by content type",)sender_filter: Literal[- "all", "any_contact", "contact", "group", "keywords",+ "all",+ "any_contact",+ "contact",+ "group",+ "keywords",] = Field(default="all",description="Filter which messages pass through",@@ -99,11 +121,11 @@ class SocialReceiveNode(ActionNode):subtitle = "Normalize Message"group = ("social",)description = "Normalizes messages from platform triggers into unified format"- component_kind = "agent" # multi-handle layout uses AIAgentNode+ component_kind = "agent" # multi-handle layout uses AIAgentNodehandles = (- {"name": "output-message", "kind": "output", "position": "right", "offset": "20%", "label": "Message", "role": "main"},- {"name": "output-media", "kind": "output", "position": "right", "offset": "40%", "label": "Media", "role": "main"},- {"name": "output-contact", "kind": "output", "position": "right", "offset": "60%", "label": "Contact", "role": "main"},+ {"name": "output-message", "kind": "output", "position": "right", "offset": "20%", "label": "Message", "role": "main"},+ {"name": "output-media", "kind": "output", "position": "right", "offset": "40%", "label": "Media", "role": "main"},+ {"name": "output-contact", "kind": "output", "position": "right", "offset": "60%", "label": "Contact", "role": "main"},{"name": "output-metadata", "kind": "output", "position": "right", "offset": "80%", "label": "Metadata", "role": "main"},)ui_hints = _SOCIAL_SIZE@@ -138,9 +160,12 @@ class SocialReceiveNode(ActionNode):outputs = context.raw.get("connected_outputs") or {}source_nodes = context.raw.get("source_nodes") or []response = await handle_social_receive(- node_id=node_id, node_type=self.type,- parameters=params_obj.model_dump(), context=context.raw,- outputs=outputs, source_nodes=source_nodes,+ node_id=node_id,+ node_type=self.type,+ parameters=params_obj.model_dump(),+ context=context.raw,+ outputs=outputs,+ source_nodes=source_nodes,)return responsediff --git a/server/nodes/social/social_send/__init__.py b/server/nodes/social/social_send/__init__.pyindex efd409f8..bf994306 100644--- a/server/nodes/social/social_send/__init__.py+++ b/server/nodes/social/social_send/__init__.py@@ -25,8 +25,16 @@ class SocialSendParams(BaseModel):# ===== CHANNEL / PLATFORM =====channel: Literal[- "whatsapp", "telegram", "discord", "slack", "signal",- "sms", "webchat", "email", "matrix", "teams",+ "whatsapp",+ "telegram",+ "discord",+ "slack",+ "signal",+ "sms",+ "webchat",+ "email",+ "matrix",+ "teams",] = Field(default="whatsapp",description="Target chat platform",@@ -79,8 +87,17 @@ class SocialSendParams(BaseModel):# ===== MESSAGE TYPE =====message_type: Literal[- "text", "image", "video", "audio", "document",- "sticker", "location", "contact", "poll", "buttons", "list",+ "text",+ "image",+ "video",+ "audio",+ "document",+ "sticker",+ "location",+ "contact",+ "poll",+ "buttons",+ "list",] = Field(default="text")# ===== TEXT =====@@ -105,19 +122,29 @@ class SocialSendParams(BaseModel):default="url",description="Source of media data",json_schema_extra={- "displayOptions": {"show": {"message_type": [- "image", "video", "audio", "document", "sticker",- ]}},+ "displayOptions": {+ "show": {+ "message_type": [+ "image",+ "video",+ "audio",+ "document",+ "sticker",+ ]+ }+ },},)media_url: str = Field(default="",description="URL to download media from",json_schema_extra={- "displayOptions": {"show": {- "message_type": ["image", "video", "audio", "document", "sticker"],- "media_source": ["url"],- }},+ "displayOptions": {+ "show": {+ "message_type": ["image", "video", "audio", "document", "sticker"],+ "media_source": ["url"],+ }+ },},)media_data: str = Field(@@ -125,29 +152,41 @@ class SocialSendParams(BaseModel):description="Base64-encoded media data",json_schema_extra={"rows": 3,- "displayOptions": {"show": {- "message_type": ["image", "video", "audio", "document", "sticker"],- "media_source": ["base64"],- }},+ "displayOptions": {+ "show": {+ "message_type": ["image", "video", "audio", "document", "sticker"],+ "media_source": ["base64"],+ }+ },},)file_path: str = Field(default="",description="Server file path",json_schema_extra={- "displayOptions": {"show": {- "message_type": ["image", "video", "audio", "document", "sticker"],- "media_source": ["file"],- }},+ "displayOptions": {+ "show": {+ "message_type": ["image", "video", "audio", "document", "sticker"],+ "media_source": ["file"],+ }+ },},)mime_type: str = Field(default="",description="MIME type (auto-detected if empty)",json_schema_extra={- "displayOptions": {"show": {"message_type": [- "image", "video", "audio", "document", "sticker",- ]}},+ "displayOptions": {+ "show": {+ "message_type": [+ "image",+ "video",+ "audio",+ "document",+ "sticker",+ ]+ }+ },},)caption: str = Field(@@ -344,11 +383,11 @@ class SocialSendNode(ActionNode):subtitle = "Send Message"group = ("social", "tool")description = "Unified send action for any social platform"- component_kind = "agent" # multi-handle layout uses AIAgentNode component+ component_kind = "agent" # multi-handle layout uses AIAgentNode componenthandles = (- {"name": "input-message", "kind": "input", "position": "left", "offset": "15%", "label": "Message", "role": "main"},- {"name": "input-media", "kind": "input", "position": "left", "offset": "35%", "label": "Media", "role": "main"},- {"name": "input-contact", "kind": "input", "position": "left", "offset": "55%", "label": "Contact", "role": "main"},+ {"name": "input-message", "kind": "input", "position": "left", "offset": "15%", "label": "Message", "role": "main"},+ {"name": "input-media", "kind": "input", "position": "left", "offset": "35%", "label": "Media", "role": "main"},+ {"name": "input-contact", "kind": "input", "position": "left", "offset": "55%", "label": "Contact", "role": "main"},{"name": "input-metadata", "kind": "input", "position": "left", "offset": "75%", "label": "Metadata", "role": "main"},)ui_hints = _SOCIAL_SIZE@@ -362,9 +401,12 @@ class SocialSendNode(ActionNode):@Operation("send", cost={"service": "social", "action": "send", "count": 1})async def send(self, ctx: NodeContext, params: SocialSendParams) -> Any:from .._base import handle_social_send+response = await handle_social_send(- node_id=ctx.node_id, node_type=self.type,- parameters=params.model_dump(), context=ctx.raw,+ node_id=ctx.node_id,+ node_type=self.type,+ parameters=params.model_dump(),+ context=ctx.raw,)if response.get("success"):return response.get("result") or responsediff --git a/server/nodes/stripe/__init__.py b/server/nodes/stripe/__init__.pyindex b4afd27f..d1ce8240 100644--- a/server/nodes/stripe/__init__.py+++ b/server/nodes/stripe/__init__.py@@ -29,9 +29,13 @@ from .stripe_receive import StripeReceiveNode, StripeReceiveOutputregister_ws_handlers(WS_HANDLERS)register_webhook_source(get_webhook_source())-register_service_refresh(make_status_refresh(- get_listen_source(), status_key="stripe", broadcast_type="stripe_status",-))+register_service_refresh(+ make_status_refresh(+ get_listen_source(),+ status_key="stripe",+ broadcast_type="stripe_status",+ )+)register_output_schema("stripeReceive", StripeReceiveOutput)register_output_schema("stripeAction", StripeActionOutput)diff --git a/server/nodes/stripe/_handlers.py b/server/nodes/stripe/_handlers.pyindex 7597d6bc..69497c46 100644--- a/server/nodes/stripe/_handlers.py+++ b/server/nodes/stripe/_handlers.py@@ -79,6 +79,7 @@ _MARKER_TOKEN = "cli-managed"async def _mark_logged_in() -> None:from services.plugin.deps import get_auth_service+await get_auth_service().store_oauth_tokens(provider="stripe",access_token=_MARKER_TOKEN,@@ -88,6 +89,7 @@ async def _mark_logged_in() -> None:async def _mark_logged_out() -> None:from services.plugin.deps import get_auth_service+await get_auth_service().remove_oauth_tokens("stripe")@@ -102,8 +104,10 @@ async def _broadcast_credential_event(event_type: str) -> None:helper's outer wire-format type) and invalidates the catalogue query."""from services.status_broadcaster import get_status_broadcaster+await get_status_broadcaster().broadcast_credential_event(- event_type, provider="stripe",+ event_type,+ provider="stripe",)@@ -130,12 +134,15 @@ async def handle_stripe_login(data: Dict[str, Any], websocket: WebSocket) -> Dic}logger.info("[Stripe] using binary: %s", binary)result = await run_cli_command(- binary=binary, argv=["login", "--non-interactive"], timeout=10.0,+ binary=binary,+ argv=["login", "--non-interactive"],+ timeout=10.0,)if not result["success"]:logger.warning("[Stripe] login step 1 CLI failure: %s | stderr=%r",- result.get("error"), (result.get("stderr") or "")[:300],+ result.get("error"),+ (result.get("stderr") or "")[:300],)return resulttry:@@ -171,7 +178,8 @@ async def handle_stripe_login(data: Dict[str, Any], websocket: WebSocket) -> Diclogger.info("[Stripe] login step 1 ok: code=%s, browser_url issued — opening on frontend; ""spawning step 2 (--complete) in background (timeout=%ss)",- info.get("verification_code"), _LOGIN_TIMEOUT_SECONDS,+ info.get("verification_code"),+ _LOGIN_TIMEOUT_SECONDS,)asyncio.create_task(_complete_login(binary, complete_url))return {@@ -190,7 +198,8 @@ async def _complete_login(binary: str, next_step: str) -> None:logger.info("[Stripe] login step 2/2 polling for browser confirmation")try:result = await run_cli_command(- binary=binary, argv=["login", "--complete", next_step],+ binary=binary,+ argv=["login", "--complete", next_step],timeout=_LOGIN_TIMEOUT_SECONDS,)except Exception as e:@@ -202,7 +211,8 @@ async def _complete_login(binary: str, next_step: str) -> None:if not result.get("success"):logger.warning("[Stripe] login step 2 CLI failure: %s | stderr=%r",- result.get("error"), (result.get("stderr") or "")[:300],+ result.get("error"),+ (result.get("stderr") or "")[:300],)if not is_logged_in():@@ -245,7 +255,8 @@ async def handle_stripe_logout(data: Dict[str, Any], websocket: WebSocket) -> Diresult = await run_cli_command(binary=str(cached), argv=["logout", "--all"], timeout=10.0)logger.info("[Stripe] logout CLI result: success=%s err=%s",- result.get("success"), result.get("error"),+ result.get("success"),+ result.get("error"),)await _mark_logged_out()await _broadcast_credential_event("credential.oauth.disconnected")diff --git a/server/nodes/stripe/_install.py b/server/nodes/stripe/_install.pyindex b98494a1..bdd9422e 100644--- a/server/nodes/stripe/_install.py+++ b/server/nodes/stripe/_install.py@@ -35,12 +35,12 @@ _RELEASE_BASE = f"https://github.com/stripe/stripe-cli/releases/download/v{_VERS# (system, machine) → (asset filename, archive type, member name to extract)_ASSETS: dict[Tuple[str, str], Tuple[str, str, str]] = {- ("Windows", "AMD64"): (f"stripe_{_VERSION}_windows_x86_64.zip", "zip", "stripe.exe"),- ("Linux", "x86_64"): (f"stripe_{_VERSION}_linux_x86_64.tar.gz", "tar", "stripe"),- ("Linux", "aarch64"): (f"stripe_{_VERSION}_linux_arm64.tar.gz", "tar", "stripe"),- ("Linux", "arm64"): (f"stripe_{_VERSION}_linux_arm64.tar.gz", "tar", "stripe"),- ("Darwin", "x86_64"): (f"stripe_{_VERSION}_mac-os_x86_64.tar.gz", "tar", "stripe"),- ("Darwin", "arm64"): (f"stripe_{_VERSION}_mac-os_arm64.tar.gz", "tar", "stripe"),+ ("Windows", "AMD64"): (f"stripe_{_VERSION}_windows_x86_64.zip", "zip", "stripe.exe"),+ ("Linux", "x86_64"): (f"stripe_{_VERSION}_linux_x86_64.tar.gz", "tar", "stripe"),+ ("Linux", "aarch64"): (f"stripe_{_VERSION}_linux_arm64.tar.gz", "tar", "stripe"),+ ("Linux", "arm64"): (f"stripe_{_VERSION}_linux_arm64.tar.gz", "tar", "stripe"),+ ("Darwin", "x86_64"): (f"stripe_{_VERSION}_mac-os_x86_64.tar.gz", "tar", "stripe"),+ ("Darwin", "arm64"): (f"stripe_{_VERSION}_mac-os_arm64.tar.gz", "tar", "stripe"),}@@ -50,6 +50,7 @@ _install_lock = asyncio.Lock()def _bin_dir() -> Path:from core.paths import package_dir+p = package_dir("stripe") / "bin"p.mkdir(parents=True, exist_ok=True)return p@@ -100,10 +101,7 @@ async def _download_release(target: Path) -> None:key = (platform.system(), platform.machine())asset = _ASSETS.get(key)if asset is None:- raise RuntimeError(- f"No prebuilt Stripe CLI for {key}. Install manually from "- "https://stripe.com/docs/stripe-cli#install"- )+ raise RuntimeError(f"No prebuilt Stripe CLI for {key}. Install manually from " "https://stripe.com/docs/stripe-cli#install")asset_name, kind, member = asseturl = f"{_RELEASE_BASE}/{asset_name}"logger.info("[Stripe] downloading CLI v%s from %s", _VERSION, url)diff --git a/server/nodes/stripe/_source.py b/server/nodes/stripe/_source.pyindex ef3bff0c..725898bb 100644--- a/server/nodes/stripe/_source.py+++ b/server/nodes/stripe/_source.py@@ -89,15 +89,13 @@ class StripeListenSource(DaemonEventSource):port = int(Settings().port)binary = shlex.quote(str(stripe_cli_path() or "stripe"))- return (- f"{binary} listen --forward-to http://localhost:{port}/webhook/stripe "- f"--print-secret"- )+ return f"{binary} listen --forward-to http://localhost:{port}/webhook/stripe " f"--print-secret"async def start(self) -> Dict[str, Any]:"""Ensure the CLI binary is downloaded before delegating to theframework's daemon-start path (which calls ``build_command``)."""from ._install import ensure_stripe_cli+try:path = await ensure_stripe_cli()logger.info("[Stripe] daemon start: CLI binary resolved at %s", path)@@ -121,10 +119,12 @@ class StripeListenSource(DaemonEventSource):async def _persist_secret(self, secret: str) -> None:try:from services.plugin.deps import get_auth_service+await get_auth_service().store_api_key(_SECRET_FIELD, secret, models=[])logger.info("[Stripe] webhook signing secret persisted (key=%s, len=%d)",- _SECRET_FIELD, len(secret),+ _SECRET_FIELD,+ len(secret),)except Exception as e:logger.warning("[Stripe] persist secret failed: %s", e)diff --git a/server/nodes/stripe/stripe_action.py b/server/nodes/stripe/stripe_action.pyindex 14546713..3d0d3362 100644--- a/server/nodes/stripe/stripe_action.py+++ b/server/nodes/stripe/stripe_action.py@@ -46,10 +46,8 @@ class StripeActionNode(ActionNode):tool_name = "stripe_action"tool_description = "Run any Stripe CLI command and return the parsed JSON response. Pass a 'command' field exactly as you would type after 'stripe ' (e.g. 'customers create --email [email protected]', 'charges list --limit 10', 'payment_intents create --amount 2000 --currency usd', 'refunds create --payment-intent pi_xxx', 'trigger charge.succeeded'). Covers every Stripe resource: customers, charges, payment_intents, refunds, invoices, products, prices, subscriptions, payment_methods, setup_intents, transfers, payouts, plus 'trigger <event>' for synthetic test events."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}credentials = (StripeCredential,)diff --git a/server/nodes/stripe/stripe_receive.py b/server/nodes/stripe/stripe_receive.pyindex 2340456a..c6689834 100644--- a/server/nodes/stripe/stripe_receive.py+++ b/server/nodes/stripe/stripe_receive.py@@ -43,10 +43,7 @@ class StripeReceiveNode(WebhookTriggerNode):group = ("payments", "trigger")description = "Trigger workflow when Stripe webhook event arrives"component_kind = "trigger"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)credentials = (StripeCredential,)webhook_source = StripeWebhookSourceevent_type_prefix = _PREFIX@@ -54,7 +51,8 @@ class StripeReceiveNode(WebhookTriggerNode):Output = StripeReceiveOutputdef _extra_filter(- self, params: StripeReceiveParams,+ self,+ params: StripeReceiveParams,) -> Optional[Callable[[WorkflowEvent], bool]]:if params.livemode_filter == "all":return None@@ -68,13 +66,14 @@ class StripeReceiveNode(WebhookTriggerNode):async def _check_precondition(self) -> Optional[str]:from ._source import get_listen_source+if not get_listen_source()._started:return "Stripe daemon not running. Add Stripe API key in Credentials and connect."return Nonedef shape_output(self, event: WorkflowEvent) -> Dict:payload = event.data if isinstance(event.data, dict) else {}- stripe_type = event.type[len(_PREFIX):] if event.type.startswith(_PREFIX) else event.type+ stripe_type = event.type[len(_PREFIX) :] if event.type.startswith(_PREFIX) else event.typerequest = payload.get("request")request_id = request.get("id") if isinstance(request, dict) else requestnested = payload.get("data")@@ -85,8 +84,6 @@ class StripeReceiveNode(WebhookTriggerNode):"livemode": payload.get("livemode"),"api_version": payload.get("api_version"),"request_id": request_id,- "account": payload.get("account") or (- event.source.split("://", 1)[1] if "://" in event.source else None- ),+ "account": payload.get("account") or (event.source.split("://", 1)[1] if "://" in event.source else None),"data": nested if isinstance(nested, dict) else payload,}diff --git a/server/nodes/telegram/_credentials.py b/server/nodes/telegram/_credentials.pyindex 629bd327..889741d3 100644--- a/server/nodes/telegram/_credentials.py+++ b/server/nodes/telegram/_credentials.py@@ -56,11 +56,7 @@ class TelegramCredential(ApiKeyCredential):username = bot.get("username")return ProbeResult(valid=True,- message=(- f"Telegram bot token is valid (@{username})"- if username- else "Telegram bot token is valid"- ),+ message=(f"Telegram bot token is valid (@{username})" if username else "Telegram bot token is valid"),extra={"bot_id": bot.get("id"),"bot_username": username,diff --git a/server/nodes/telegram/_events.py b/server/nodes/telegram/_events.pyindex e539437c..0580040c 100644--- a/server/nodes/telegram/_events.py+++ b/server/nodes/telegram/_events.py@@ -71,11 +71,7 @@ def telegram_connection_status(data["has_stored_token"] = has_stored_tokenreturn WorkflowEvent(source="machinaos://nodes/telegram",- type=(- "com.machinaos.telegram.connection.opened"- if connected- else "com.machinaos.telegram.connection.closed"- ),+ type=("com.machinaos.telegram.connection.opened" if connected else "com.machinaos.telegram.connection.closed"),subject=bot_username,data=data,)@@ -138,10 +134,12 @@ async def broadcast_telegram_status(owner_chat_id=owner_chat_id,has_stored_token=has_stored_token,)- await broadcaster.broadcast({- "type": _STATUS_TYPED_WIRE_KEY,- "data": event.model_dump(mode="json"),- })+ await broadcaster.broadcast(+ {+ "type": _STATUS_TYPED_WIRE_KEY,+ "data": event.model_dump(mode="json"),+ }+ )async def dispatch_telegram_message_received(event_data: Mapping[str, Any]) -> None:diff --git a/server/nodes/telegram/_filters.py b/server/nodes/telegram/_filters.pyindex 1e6a61bc..ac2b3a1d 100644--- a/server/nodes/telegram/_filters.py+++ b/server/nodes/telegram/_filters.py@@ -55,16 +55,11 @@ def build_telegram_filter(params: Dict) -> Callable[[Dict], bool]:content_type_filter = params.get("content_type_filter", "all")chat_id_filter = params.get("chat_id", "")from_user_filter = params.get("from_user", "")- keywords = [- k.strip().lower() for k in params.get("keywords", "").split(",") if k.strip()- ]+ keywords = [k.strip().lower() for k in params.get("keywords", "").split(",") if k.strip()]ignore_bots = params.get("ignore_bots", True)owner_chat_id = params.get("_owner_chat_id")- logger.debug(- f"[TelegramFilter] Built: sender={sender_filter}, "- f"content_type={content_type_filter}, owner_chat_id={owner_chat_id}"- )+ logger.debug(f"[TelegramFilter] Built: sender={sender_filter}, " f"content_type={content_type_filter}, owner_chat_id={owner_chat_id}")def _get_owner_chat_id() -> object:"""Lazy lookup from the local service -- handles owner detected@@ -113,10 +108,7 @@ def build_telegram_filter(params: Dict) -> Callable[[Dict], bool]:if sender_filter != "self" and ignore_bots and m.get("is_bot", False):return False- logger.debug(- f"[TelegramFilter] Matched message from "- f"{m.get('from_username', m.get('from_id'))}"- )+ logger.debug(f"[TelegramFilter] Matched message from " f"{m.get('from_username', m.get('from_id'))}")return Truereturn matchesdiff --git a/server/nodes/telegram/_handlers.py b/server/nodes/telegram/_handlers.pyindex a0155edd..589dd797 100644--- a/server/nodes/telegram/_handlers.py+++ b/server/nodes/telegram/_handlers.py@@ -38,7 +38,9 @@ def _send_text(svc, data, parse_mode):if not text:return None, "text required for text message"return svc.send_message(- chat_id=data["chat_id"], text=text, parse_mode=parse_mode,+ chat_id=data["chat_id"],+ text=text,+ parse_mode=parse_mode,), None@@ -47,8 +49,10 @@ def _send_photo(svc, data, parse_mode):if not photo_url:return None, "media_url required for photo"return svc.send_photo(- chat_id=data["chat_id"], photo=photo_url,- caption=data.get("caption"), parse_mode=parse_mode,+ chat_id=data["chat_id"],+ photo=photo_url,+ caption=data.get("caption"),+ parse_mode=parse_mode,), None@@ -57,8 +61,10 @@ def _send_document(svc, data, parse_mode):if not doc_url:return None, "media_url required for document"return svc.send_document(- chat_id=data["chat_id"], document=doc_url,- caption=data.get("caption"), parse_mode=parse_mode,+ chat_id=data["chat_id"],+ document=doc_url,+ caption=data.get("caption"),+ parse_mode=parse_mode,), None@@ -67,7 +73,9 @@ def _send_location(svc, data, parse_mode):if lat is None or lon is None:return None, "latitude and longitude required"return svc.send_location(- chat_id=data["chat_id"], latitude=float(lat), longitude=float(lon),+ chat_id=data["chat_id"],+ latitude=float(lat),+ longitude=float(lon),), None@@ -76,7 +84,9 @@ def _send_contact(svc, data, parse_mode):if not phone or not first_name:return None, "phone_number and first_name required"return svc.send_contact(- chat_id=data["chat_id"], phone_number=phone, first_name=first_name,+ chat_id=data["chat_id"],+ phone_number=phone,+ first_name=first_name,last_name=data.get("last_name"),), Nonediff --git a/server/nodes/telegram/_refresh.py b/server/nodes/telegram/_refresh.pyindex e118eef2..13415683 100644--- a/server/nodes/telegram/_refresh.py+++ b/server/nodes/telegram/_refresh.py@@ -70,18 +70,11 @@ async def refresh_telegram_status(broadcaster: "StatusBroadcaster") -> None:span.set_attribute("reconnect_ok", ok)if ok:bot_username = broadcaster._status["telegram"].get("bot_username")- logger.info(- f"[StatusBroadcaster] Telegram auto-reconnected: @{bot_username}"- )+ logger.info(f"[StatusBroadcaster] Telegram auto-reconnected: @{bot_username}")else:- logger.warning(- f"[StatusBroadcaster] Telegram auto-reconnect failed: "- f"{result.get('error')}"- )-- span.set_attribute(- "connected", bool(broadcaster._status["telegram"]["connected"])- )+ logger.warning(f"[StatusBroadcaster] Telegram auto-reconnect failed: " f"{result.get('error')}")++ span.set_attribute("connected", bool(broadcaster._status["telegram"]["connected"]))except Exception as e:span.record_exception(e)logger.debug(f"[StatusBroadcaster] Could not refresh Telegram status: {e}")@@ -99,9 +92,5 @@ async def precheck_telegram_trigger(parameters: Dict) -> str | None:if not service.connected:return "Telegram bot not connected. Add bot token in Credentials."sender_filter = parameters.get("sender_filter", "all")- logger.info(- "[TelegramTrigger] starting "- f"sender_filter={sender_filter} "- f"owner_detected={service.owner_chat_id is not None}"- )+ logger.info("[TelegramTrigger] starting " f"sender_filter={sender_filter} " f"owner_detected={service.owner_chat_id is not None}")return Nonediff --git a/server/nodes/telegram/_service.py b/server/nodes/telegram/_service.pyindex 1e0b8ff6..2218322f 100644--- a/server/nodes/telegram/_service.py+++ b/server/nodes/telegram/_service.py@@ -203,15 +203,12 @@ class TelegramService(ServiceSingleton):# tasks fired on overlapping WebSocket connects.if self._connected:logger.debug(- "[Telegram] connect() called while already connected to "- f"@{self._bot_info.get('username')}, returning success",+ "[Telegram] connect() called while already connected to " f"@{self._bot_info.get('username')}, returning success",)return {"success": True,"bot": self._bot_info,- "message": (- f"Already connected to @{self._bot_info.get('username')}"- ),+ "message": (f"Already connected to @{self._bot_info.get('username')}"),}try:@@ -240,9 +237,7 @@ class TelegramService(ServiceSingleton):)self._bot = self._application.botself._token = token- self._application.add_handler(- MessageHandler(filters.ALL, self._on_message_received)- )+ self._application.add_handler(MessageHandler(filters.ALL, self._on_message_received))await self._application.initialize()@@ -264,9 +259,7 @@ class TelegramService(ServiceSingleton):saved_owner = secrets.get("telegram_owner_chat_id")if saved_owner is None:try:- saved_owner = (await TelegramCredential.resolve()).get(- "telegram_owner_chat_id"- )+ saved_owner = (await TelegramCredential.resolve()).get("telegram_owner_chat_id")except PermissionError:saved_owner = Noneif saved_owner:@@ -410,6 +403,7 @@ class TelegramService(ServiceSingleton):captured_id = m.from_user.idtry:from services.plugin.deps import get_auth_service+await get_auth_service().store_api_key("telegram_owner_chat_id",str(captured_id),@@ -424,10 +418,7 @@ class TelegramService(ServiceSingleton):)returnself._owner_chat_id = captured_id- logger.info(- f"[Telegram] Owner retroactively captured from pending "- f"updates: @{m.from_user.username} (ID: {captured_id})"- )+ logger.info(f"[Telegram] Owner retroactively captured from pending " f"updates: @{m.from_user.username} (ID: {captured_id})")returnasync def _on_message_received(self, update: Update, context: ContextTypes.DEFAULT_TYPE):@@ -448,15 +439,12 @@ class TelegramService(ServiceSingleton):# what went wrong. The new order preserves the invariant# "in-memory has owner => DB has owner" so a restart can# always re-capture from the next inbound private message.- if (- self._owner_chat_id is None- and msg.chat.type == "private"- and msg.from_user- ):+ if self._owner_chat_id is None and msg.chat.type == "private" and msg.from_user:captured_id = msg.from_user.idpersist_ok = Falsetry:from services.plugin.deps import get_auth_service+await get_auth_service().store_api_key("telegram_owner_chat_id",str(captured_id),@@ -480,10 +468,7 @@ class TelegramService(ServiceSingleton):)if persist_ok:self._owner_chat_id = captured_id- logger.info(- f"[Telegram] Owner detected and persisted: "- f"@{msg.from_user.username} (ID: {captured_id})"- )+ logger.info(f"[Telegram] Owner detected and persisted: " f"@{msg.from_user.username} (ID: {captured_id})")await self._broadcast_status()event_data = self._format_message(msg)@@ -603,12 +588,11 @@ class TelegramService(ServiceSingleton):if not text:return text, "HTML"from services.markdown_formatter import to_telegram_html+return to_telegram_html(text), "HTML"@classmethod- def _resolve_body(- cls, body: Optional[str], parse_mode: Optional[str]- ) -> tuple[Optional[str], Optional[str]]:+ def _resolve_body(cls, body: Optional[str], parse_mode: Optional[str]) -> tuple[Optional[str], Optional[str]]:"""Apply parse-mode preprocessing to a text/caption. Returns``(body, effective_parse_mode)``."""if parse_mode == "Auto":@@ -638,10 +622,7 @@ class TelegramService(ServiceSingleton):)except BadRequest as e:if "can't parse entities" in str(e).lower() and effective_pm:- logger.warning(- f"[Telegram] Parse mode {effective_pm} failed for "- f"{method.__name__}, sending as plain text"- )+ logger.warning(f"[Telegram] Parse mode {effective_pm} failed for " f"{method.__name__}, sending as plain text")return await method(**{body_kw: body},parse_mode=None,@@ -672,7 +653,8 @@ class TelegramService(ServiceSingleton):if len(chunks) > 1:logger.info("[Telegram] Splitting %d-char message into %d parts",- len(text), len(chunks),+ len(text),+ len(chunks),)first_msg: Any = Nonediff --git a/server/nodes/telegram/telegram_receive.py b/server/nodes/telegram/telegram_receive.pyindex face27a4..6aaffe73 100644--- a/server/nodes/telegram/telegram_receive.py+++ b/server/nodes/telegram/telegram_receive.py@@ -23,15 +23,31 @@ class TelegramReceiveParams(BaseModel):"""content_type_filter: Literal[- "all", "text", "photo", "video", "audio", "voice", "document",- "sticker", "location", "contact", "poll",+ "all",+ "text",+ "photo",+ "video",+ "audio",+ "voice",+ "document",+ "sticker",+ "location",+ "contact",+ "poll",] = Field(default="all",description="Filter by message content type",)sender_filter: Literal[- "all", "self", "private", "group", "supergroup", "channel",- "specific_chat", "specific_user", "keywords",+ "all",+ "self",+ "private",+ "group",+ "supergroup",+ "channel",+ "specific_chat",+ "specific_user",+ "keywords",] = Field(default="all",description="Filter which messages trigger the workflow",@@ -61,10 +77,20 @@ class TelegramReceiveParams(BaseModel):default=True,description="Do not trigger on messages from other bots",json_schema_extra={- "displayOptions": {"show": {"sender_filter": [- "all", "private", "group", "supergroup", "channel",- "specific_chat", "specific_user", "keywords",- ]}},+ "displayOptions": {+ "show": {+ "sender_filter": [+ "all",+ "private",+ "group",+ "supergroup",+ "channel",+ "specific_chat",+ "specific_user",+ "keywords",+ ]+ }+ },},)@@ -100,10 +126,7 @@ class TelegramReceiveNode(TriggerNode):group = ("social", "trigger")description = "Trigger workflow when Telegram message is received"component_kind = "trigger"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)credentials = (TelegramCredential,)task_queue = TaskQueue.TRIGGERS_EVENTmode = "event"@@ -116,6 +139,7 @@ class TelegramReceiveNode(TriggerNode):# Delegate to legacy filter builder for full feature parity —# 11.F ports the body and removes the legacy registry entry.from services.event_waiter import build_telegram_filter+return build_telegram_filter(params.model_dump())async def execute(@@ -136,14 +160,10 @@ class TelegramReceiveNode(TriggerNode):if not getattr(svc, "connected", False):return self._wrap_error(start_time=time.time(),- error=(- "Telegram bot not connected. Add bot token in Credentials."- ),+ error=("Telegram bot not connected. Add bot token in Credentials."),)return await super().execute(node_id, parameters, context)@Operation("wait")async def wait(self, ctx: NodeContext, params: TelegramReceiveParams) -> TelegramReceiveOutput:- raise NotImplementedError(- "Event triggers return via TriggerNode.execute, not the op body"- )+ raise NotImplementedError("Event triggers return via TriggerNode.execute, not the op body")diff --git a/server/nodes/telegram/telegram_send.py b/server/nodes/telegram/telegram_send.pyindex 449acdeb..4515805e 100644--- a/server/nodes/telegram/telegram_send.py+++ b/server/nodes/telegram/telegram_send.py@@ -117,10 +117,7 @@ class TelegramSendParams(BaseModel):# ===== OPTIONS =====parse_mode: Literal["Auto", "", "HTML", "Markdown", "MarkdownV2"] = Field(default="Auto",- description=(- "Auto converts LLM markdown to Telegram HTML. "- "Empty string = no parse mode (raw text)."- ),+ description=("Auto converts LLM markdown to Telegram HTML. " "Empty string = no parse mode (raw text)."),json_schema_extra={"displayOptions": {"show": {"message_type": ["text", "photo", "document"]}},},@@ -153,10 +150,8 @@ class TelegramSendNode(ActionNode):description = "Send text, photo, document, location, or contact via Telegram bot"component_kind = "square"handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}credentials = (TelegramCredential,)@@ -184,6 +179,7 @@ class TelegramSendNode(ActionNode):if not chat_id:try:from services.plugin.deps import get_auth_service+saved = await get_auth_service().get_api_key("telegram_owner_chat_id")if saved:owner_id = int(saved)@@ -217,21 +213,27 @@ class TelegramSendNode(ActionNode):if not params.text:raise RuntimeError("text is required for text message")result = await service.send_message(- text=params.text, parse_mode=parse_mode, **common,+ text=params.text,+ parse_mode=parse_mode,+ **common,)elif mt == "photo":if not params.media_url:raise RuntimeError("media_url is required for photo message")result = await service.send_photo(- photo=params.media_url, caption=params.caption or None,- parse_mode=parse_mode, **common,+ photo=params.media_url,+ caption=params.caption or None,+ parse_mode=parse_mode,+ **common,)elif mt == "document":if not params.media_url:raise RuntimeError("media_url is required for document message")result = await service.send_document(- document=params.media_url, caption=params.caption or None,- parse_mode=parse_mode, **common,+ document=params.media_url,+ caption=params.caption or None,+ parse_mode=parse_mode,+ **common,)elif mt == "location":if params.latitude is None or params.longitude is None:@@ -258,8 +260,7 @@ class TelegramSendNode(ActionNode):raise RuntimeError(f"Unsupported message type: {mt}")log.info(- f"[Telegram] Message sent: type={mt}, chat={chat_id}, "- f"msg_id={result.get('message_id')}",+ f"[Telegram] Message sent: type={mt}, chat={chat_id}, " f"msg_id={result.get('message_id')}",)return {"message_id": result.get("message_id"),diff --git a/server/nodes/text/file_handler/__init__.py b/server/nodes/text/file_handler/__init__.pyindex 76b155cd..89ec34b0 100644--- a/server/nodes/text/file_handler/__init__.py+++ b/server/nodes/text/file_handler/__init__.py@@ -17,7 +17,13 @@ from services.plugin import ActionNode, NodeContext, Operation, TaskQueueclass FileHandlerParams(BaseModel):file_type: Literal[- "generic", "markdown", "text", "json", "csv", "html", "xml",+ "generic",+ "markdown",+ "text",+ "json",+ "csv",+ "html",+ "xml",] = Field(default="generic",description="Content type tag used for downstream processing hints.",diff --git a/server/nodes/text/text_generator/__init__.py b/server/nodes/text/text_generator/__init__.pyindex b255d2e6..248da18e 100644--- a/server/nodes/text/text_generator/__init__.py+++ b/server/nodes/text/text_generator/__init__.py@@ -48,7 +48,8 @@ class TextGeneratorNode(ActionNode):text_service = get_text_service()response = await text_service.execute_text_generator(- ctx.node_id, params.model_dump(),+ ctx.node_id,+ params.model_dump(),)if response.get("success"):return response.get("result") or responsediff --git a/server/nodes/tool/agent_builder/__init__.py b/server/nodes/tool/agent_builder/__init__.pyindex 8d381e3b..497ae348 100644--- a/server/nodes/tool/agent_builder/__init__.py+++ b/server/nodes/tool/agent_builder/__init__.py@@ -85,9 +85,10 @@ async def _broadcast(workflow_id: Optional[str], caller_id: str, ops: List[Dict[operations=ops,)logger.info(- "[agentBuilder] broadcast workflow_ops_apply: workflow_id=%s "- "caller=%s ops=%s",- workflow_id, caller_id, [op.get("type") for op in ops],+ "[agentBuilder] broadcast workflow_ops_apply: workflow_id=%s " "caller=%s ops=%s",+ workflow_id,+ caller_id,+ [op.get("type") for op in ops],)except Exception as exc:logger.warning(f"[agentBuilder] broadcast failed: {exc}", exc_info=True)@@ -96,17 +97,14 @@ async def _broadcast(workflow_id: Optional[str], caller_id: str, ops: List[Dict[def _allowed_tool_types() -> set[str]:"""Tool nodes the LLM may spawn -- excludes the builder + masterSkill."""return {- ntype for ntype, cls in registered_node_classes().items()- if getattr(cls, "component_kind", "") == "tool"- and ntype not in _DENIED_TOOL_TYPES+ ntype+ for ntype, cls in registered_node_classes().items()+ if getattr(cls, "component_kind", "") == "tool" and ntype not in _DENIED_TOOL_TYPES}def _allowed_subagent_types() -> set[str]:- return {- ntype for ntype, cls in registered_node_classes().items()- if getattr(cls, "component_kind", "") == "agent"- }+ return {ntype for ntype, cls in registered_node_classes().items() if getattr(cls, "component_kind", "") == "agent"}def _is_team_lead(node_type: str) -> bool:@@ -154,21 +152,20 @@ def _resolve_caller(ctx: NodeContext) -> str:"""self_id = ctx.node_idfor edge in ctx.edges or []:- if (- edge.get("source") == self_id- and edge.get("targetHandle") == _TOOL_HANDLE- ):+ if edge.get("source") == self_id and edge.get("targetHandle") == _TOOL_HANDLE:target = edge.get("target")if target:logger.info(- "[agentBuilder] caller resolved via input-tools edge: "- "self=%s -> agent=%s", self_id, target,+ "[agentBuilder] caller resolved via input-tools edge: " "self=%s -> agent=%s",+ self_id,+ target,)return targetlogger.info(- "[agentBuilder] no input-tools edge found from %s; "- "falling back to self as caller (canvas: %d nodes, %d edges)",- self_id, len(ctx.nodes or []), len(ctx.edges or []),+ "[agentBuilder] no input-tools edge found from %s; " "falling back to self as caller (canvas: %d nodes, %d edges)",+ self_id,+ len(ctx.nodes or []),+ len(ctx.edges or []),)return self_id@@ -183,10 +180,12 @@ def _log_op_entry(op: str, ctx: NodeContext, **fields: Any) -> None:edges = ctx.edges or []extra = " ".join(f"{k}={v!r}" for k, v in fields.items() if v not in (None, ""))logger.info(- "[agentBuilder.%s] workflow_id=%s self=%s nodes=%d edges=%d "- "raw_keys=%s%s",- op, ctx.workflow_id, ctx.node_id,- len(nodes), len(edges),+ "[agentBuilder.%s] workflow_id=%s self=%s nodes=%d edges=%d " "raw_keys=%s%s",+ op,+ ctx.workflow_id,+ ctx.node_id,+ len(nodes),+ len(edges),sorted((ctx.raw or {}).keys()),f" {extra}" if extra else "",)@@ -231,10 +230,7 @@ class AgentBuilderParams(BaseModel):# add_skillskill_folder: str = Field(default="",- description=(- "For add_skill: skill folder name under server/skills/** "- "(e.g. 'http-request-skill', 'memory-skill')."- ),+ description=("For add_skill: skill folder name under server/skills/** " "(e.g. 'http-request-skill', 'memory-skill')."),json_schema_extra={"displayOptions": {"show": {"operation": ["add_skill"]}}},)@@ -303,10 +299,8 @@ class AgentBuilderNode(ToolNode):tool_name = "agent_builder"tool_description = "Inspect and modify the workflow canvas at runtime. Operations: inspect_canvas (read current nodes/edges), spawn_tool (add a tool node + wire it), enable_skill (add a skill folder to a connected masterSkill), add_delegate_agent (add a specialized agent), create_workflow (spawn a brand-new workflow)."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-tool", "kind": "output", "position": "top",- "label": "Tool", "role": "tools"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-tool", "kind": "output", "position": "top", "label": "Tool", "role": "tools"},)ui_hints = {"isToolPanel": True, "hideRunButton": True}annotations = {"destructive": False, "readonly": False, "open_world": True}@@ -319,7 +313,9 @@ class AgentBuilderNode(ToolNode):@Operation("inspect_canvas")async def inspect_canvas(- self, ctx: NodeContext, params: AgentBuilderParams,+ self,+ ctx: NodeContext,+ params: AgentBuilderParams,) -> AgentBuilderOutput:_log_op_entry("inspect_canvas", ctx)nodes = list(ctx.nodes or [])@@ -351,7 +347,8 @@ class AgentBuilderNode(ToolNode):"source_type": type_by_id.get(e.get("source")),"target_handle": e.get("targetHandle"),}- for e in edges if e.get("target") == caller_id+ for e in edges+ if e.get("target") == caller_id]outgoing = [{@@ -359,7 +356,8 @@ class AgentBuilderNode(ToolNode):"target_type": type_by_id.get(e.get("target")),"source_handle": e.get("sourceHandle"),}- for e in edges if e.get("source") == caller_id+ for e in edges+ if e.get("source") == caller_id]tools = [c for c in incoming if c["target_handle"] == _TOOL_HANDLE]@@ -386,7 +384,9 @@ class AgentBuilderNode(ToolNode):@Operation("add_tool")async def add_tool(- self, ctx: NodeContext, params: AgentBuilderParams,+ self,+ ctx: NodeContext,+ params: AgentBuilderParams,) -> AgentBuilderOutput:_log_op_entry("add_tool", ctx, node_type=params.node_type)node_type = (params.node_type or "").strip()@@ -401,10 +401,7 @@ class AgentBuilderNode(ToolNode):sample = ", ".join(sorted(allowed)[:10])return AgentBuilderOutput(operation="add_tool",- summary=(- f"add_tool: '{node_type}' is not an allowed tool type. "- f"Examples of allowed types: {sample}..."- ),+ summary=(f"add_tool: '{node_type}' is not an allowed tool type. " f"Examples of allowed types: {sample}..."),operations=[],)@@ -412,13 +409,17 @@ class AgentBuilderNode(ToolNode):client_ref = f"new_{node_type}"ops = [workflow_ops.add_node(- client_ref, node_type, {},+ client_ref,+ node_type,+ {},label=node_type,position=workflow_ops.anchored(caller_id, offset_x=200, offset_y=80),),workflow_ops.add_edge(- {"client_ref": client_ref}, caller_id,- source_handle=_TOOL_OUTPUT_HANDLE, target_handle=_TOOL_HANDLE,+ {"client_ref": client_ref},+ caller_id,+ source_handle=_TOOL_OUTPUT_HANDLE,+ target_handle=_TOOL_HANDLE,),]await _broadcast(ctx.workflow_id, caller_id, ops)@@ -432,7 +433,9 @@ class AgentBuilderNode(ToolNode):@Operation("add_skill")async def add_skill(- self, ctx: NodeContext, params: AgentBuilderParams,+ self,+ ctx: NodeContext,+ params: AgentBuilderParams,) -> AgentBuilderOutput:_log_op_entry("add_skill", ctx, skill_folder=params.skill_folder)skill = (params.skill_folder or "").strip()@@ -454,27 +457,25 @@ class AgentBuilderNode(ToolNode):caller_id = _resolve_caller(ctx)skill_edge = next(- (e for e in edges if e.get("target") == caller_id- and e.get("targetHandle") == _SKILL_HANDLE),+ (e for e in edges if e.get("target") == caller_id and e.get("targetHandle") == _SKILL_HANDLE),None,)master_skill = Noneif skill_edge:master_skill = next(- (n for n in nodes if n.get("id") == skill_edge.get("source")- and n.get("type") == _MASTER_SKILL_TYPE),+ (n for n in nodes if n.get("id") == skill_edge.get("source") and n.get("type") == _MASTER_SKILL_TYPE),None,)if master_skill:- existing = (- ((master_skill.get("data") or {}).get("parameters") or {})- .get("skills_config") or {}- )+ existing = ((master_skill.get("data") or {}).get("parameters") or {}).get("skills_config") or {}new_config = _toggle_skill(existing, skill, True)- ops = [workflow_ops.set_node_parameters(- master_skill["id"], {"skills_config": new_config},- )]+ ops = [+ workflow_ops.set_node_parameters(+ master_skill["id"],+ {"skills_config": new_config},+ )+ ]await _broadcast(ctx.workflow_id, caller_id, ops)return AgentBuilderOutput(operation="add_skill",@@ -486,23 +487,23 @@ class AgentBuilderNode(ToolNode):client_ref = "new_master_skill"ops = [workflow_ops.add_node(- client_ref, _MASTER_SKILL_TYPE,+ client_ref,+ _MASTER_SKILL_TYPE,{"skills_config": new_config},label=_MASTER_SKILL_LABEL,position=workflow_ops.anchored(caller_id, offset_x=-60, offset_y=220),),workflow_ops.add_edge(- {"client_ref": client_ref}, caller_id,- source_handle=_SKILL_OUTPUT_HANDLE, target_handle=_SKILL_HANDLE,+ {"client_ref": client_ref},+ caller_id,+ source_handle=_SKILL_OUTPUT_HANDLE,+ target_handle=_SKILL_HANDLE,),]await _broadcast(ctx.workflow_id, caller_id, ops)return AgentBuilderOutput(operation="add_skill",- summary=(- f"Created Master Skill node and enabled '{skill}'. "- "Available on your next turn."- ),+ summary=(f"Created Master Skill node and enabled '{skill}'. " "Available on your next turn."),operations=ops,)@@ -510,7 +511,9 @@ class AgentBuilderNode(ToolNode):@Operation("add_subagent")async def add_subagent(- self, ctx: NodeContext, params: AgentBuilderParams,+ self,+ ctx: NodeContext,+ params: AgentBuilderParams,) -> AgentBuilderOutput:_log_op_entry("add_subagent", ctx, agent_type=params.agent_type)agent_type = (params.agent_type or "").strip()@@ -530,10 +533,7 @@ class AgentBuilderNode(ToolNode):leads = ", ".join(sorted(_TEAM_LEAD_TYPES))return AgentBuilderOutput(operation="add_subagent",- summary=(- f"add_subagent: only team-lead agents ({leads}) can spawn "- f"delegates. This agent is '{caller_type}'."- ),+ summary=(f"add_subagent: only team-lead agents ({leads}) can spawn " f"delegates. This agent is '{caller_type}'."),operations=[],)allowed = _allowed_subagent_types()@@ -541,41 +541,36 @@ class AgentBuilderNode(ToolNode):sample = ", ".join(sorted(allowed)[:10])return AgentBuilderOutput(operation="add_subagent",- summary=(- f"add_subagent: '{agent_type}' is not an allowed agent "- f"type. Examples: {sample}..."- ),+ summary=(f"add_subagent: '{agent_type}' is not an allowed agent " f"type. Examples: {sample}..."),operations=[],)if _is_team_lead(agent_type):return AgentBuilderOutput(operation="add_subagent",- summary=(- f"add_subagent: cannot spawn another team-lead "- f"('{agent_type}'); pick a specialized agent instead."- ),+ summary=(f"add_subagent: cannot spawn another team-lead " f"('{agent_type}'); pick a specialized agent instead."),operations=[],)client_ref = f"new_{agent_type}"ops = [workflow_ops.add_node(- client_ref, agent_type, {},+ client_ref,+ agent_type,+ {},label=agent_type,position=workflow_ops.anchored(caller_id, offset_x=300, offset_y=200),),workflow_ops.add_edge(- {"client_ref": client_ref}, caller_id,- source_handle=_TEAMMATES_OUTPUT_HANDLE, target_handle=_TEAMMATES_HANDLE,+ {"client_ref": client_ref},+ caller_id,+ source_handle=_TEAMMATES_OUTPUT_HANDLE,+ target_handle=_TEAMMATES_HANDLE,),]await _broadcast(ctx.workflow_id, caller_id, ops)return AgentBuilderOutput(operation="add_subagent",- summary=(- f"Added '{agent_type}' as a teammate. Available on your "- "next turn (configure provider/model first)."- ),+ summary=(f"Added '{agent_type}' as a teammate. Available on your " "next turn (configure provider/model first)."),operations=ops,)@@ -583,10 +578,13 @@ class AgentBuilderNode(ToolNode):@Operation("create_workflow")async def create_workflow(- self, ctx: NodeContext, params: AgentBuilderParams,+ self,+ ctx: NodeContext,+ params: AgentBuilderParams,) -> AgentBuilderOutput:_log_op_entry(- "create_workflow", ctx,+ "create_workflow",+ ctx,workflow_name=params.workflow_name,workflow_description=params.workflow_description,)@@ -617,9 +615,13 @@ class AgentBuilderNode(ToolNode):}from services.plugin.deps import get_database+database = get_database()ok = await database.save_workflow(- workflow_id, name, workflow_data, description=description or None,+ workflow_id,+ name,+ workflow_data,+ description=description or None,)if not ok:return AgentBuilderOutput(@@ -628,9 +630,6 @@ class AgentBuilderNode(ToolNode):)return AgentBuilderOutput(operation="create_workflow",- summary=(- f"Created workflow '{name}' (id: {workflow_id}). "- "User can switch to it from the toast notification."- ),+ summary=(f"Created workflow '{name}' (id: {workflow_id}). " "User can switch to it from the toast notification."),workflow_id=workflow_id,)diff --git a/server/nodes/tool/agent_builder/_events.py b/server/nodes/tool/agent_builder/_events.pyindex 94cd3049..e3261459 100644--- a/server/nodes/tool/agent_builder/_events.py+++ b/server/nodes/tool/agent_builder/_events.py@@ -77,10 +77,12 @@ async def broadcast_workflow_ops(caller_node_id=caller_node_id,operations=operations,)- await broadcaster.broadcast({- "type": _WIRE_ROUTING_KEY,- "data": payload,- })+ await broadcaster.broadcast(+ {+ "type": _WIRE_ROUTING_KEY,+ "data": payload,+ }+ )__all__ = [diff --git a/server/nodes/tool/calculator_tool/__init__.py b/server/nodes/tool/calculator_tool/__init__.pyindex c405557e..4415246f 100644--- a/server/nodes/tool/calculator_tool/__init__.py+++ b/server/nodes/tool/calculator_tool/__init__.py@@ -26,7 +26,14 @@ class CalculatorParams(BaseModel):the function-calling model reads these."""operation: Literal[- "add", "subtract", "multiply", "divide", "power", "sqrt", "mod", "abs",+ "add",+ "subtract",+ "multiply",+ "divide",+ "power",+ "sqrt",+ "mod",+ "abs",] = Field(..., description="Math operation to perform.")a: float = Field(..., description="First operand (or the sole input for sqrt/abs).")b: Optional[float] = Field(@@ -64,10 +71,8 @@ class CalculatorToolNode(ToolNode):tool_name = "calculator"tool_description = "Perform mathematical calculations. Operations: add, subtract, multiply, divide, power, sqrt, mod, abs"handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-tool", "kind": "output", "position": "top",- "label": "Tool", "role": "tools"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-tool", "kind": "output", "position": "top", "label": "Tool", "role": "tools"},)ui_hints = {"isToolPanel": True, "hideRunButton": True}annotations = {"destructive": False, "readonly": True, "open_world": False}@@ -77,11 +82,16 @@ class CalculatorToolNode(ToolNode):@Operation("calculate")async def calculate(- self, ctx: NodeContext, params: CalculatorParams,+ self,+ ctx: NodeContext,+ params: CalculatorParams,) -> CalculatorOutput:fn = _OPERATIONS[params.operation]b_value = params.b if params.b is not None else 0.0result = fn(params.a, b_value)return CalculatorOutput(- operation=params.operation, a=params.a, b=params.b, result=result,+ operation=params.operation,+ a=params.a,+ b=params.b,+ result=result,)diff --git a/server/nodes/tool/current_time_tool/__init__.py b/server/nodes/tool/current_time_tool/__init__.pyindex 43552b4f..aee295b5 100644--- a/server/nodes/tool/current_time_tool/__init__.py+++ b/server/nodes/tool/current_time_tool/__init__.py@@ -33,10 +33,8 @@ class CurrentTimeToolNode(ToolNode):tool_name = "get_current_time"tool_description = "Get the current date and time. Optionally specify timezone."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-tool", "kind": "output", "position": "top",- "label": "Tool", "role": "tools"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-tool", "kind": "output", "position": "top", "label": "Tool", "role": "tools"},)ui_hints = {"isToolPanel": True, "hideRunButton": True}annotations = {"destructive": False, "readonly": True, "open_world": False}@@ -49,9 +47,11 @@ class CurrentTimeToolNode(ToolNode):async def now(self, ctx: NodeContext, params: CurrentTimeParams) -> CurrentTimeOutput:try:from zoneinfo import ZoneInfo+tz = ZoneInfo(params.timezone)except Exception:from zoneinfo import ZoneInfo+tz = ZoneInfo("UTC")now = datetime.now(tz)return CurrentTimeOutput(diff --git a/server/nodes/tool/task_manager/__init__.py b/server/nodes/tool/task_manager/__init__.pyindex 9bebd770..b5341015 100644--- a/server/nodes/tool/task_manager/__init__.py+++ b/server/nodes/tool/task_manager/__init__.py@@ -49,10 +49,8 @@ class TaskManagerNode(ToolNode):tool_name = "task_manager"tool_description = "Track delegated sub-agent tasks. Operations: list_tasks (see all tasks), get_task (check specific task status/result), mark_done (cleanup completed tasks)."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-tool", "kind": "output", "position": "top",- "label": "Tool", "role": "tools"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-tool", "kind": "output", "position": "top", "label": "Tool", "role": "tools"},)ui_hints = {"isToolPanel": True, "hideRunButton": True}annotations = {"destructive": True, "readonly": False, "open_world": False}@@ -64,7 +62,8 @@ class TaskManagerNode(ToolNode):@Operation("manage")async def manage(self, ctx: NodeContext, params: TaskManagerParams) -> Any:return await _execute_task_manager(- params.model_dump(), {"node_id": ctx.node_id, "workspace_dir": ctx.workspace_dir or ""},+ params.model_dump(),+ {"node_id": ctx.node_id, "workspace_dir": ctx.workspace_dir or ""},)@@ -98,9 +97,7 @@ async def _execute_task_manager(status_filter = tool_args.get("status_filter") or params.get("status_filter")database = config.get("database")- logger.debug(- f"[TaskManager] Operation: {operation}, task_id: {task_id}, filter: {status_filter}"- )+ logger.debug(f"[TaskManager] Operation: {operation}, task_id: {task_id}, filter: {status_filter}")if operation == "list_tasks":tasks = []@@ -125,13 +122,15 @@ async def _execute_task_manager(# Completed tasks from in-memory cache.for tid, result in _delegation_results.items():if tid not in [t["task_id"] for t in tasks]:- tasks.append({- "task_id": tid,- "status": result.get("status", "completed"),- "agent_name": result.get("agent_name"),- "result_summary": str(result.get("result", ""))[:200],- "active": False,- })+ tasks.append(+ {+ "task_id": tid,+ "status": result.get("status", "completed"),+ "agent_name": result.get("agent_name"),+ "result_summary": str(result.get("result", ""))[:200],+ "active": False,+ }+ )if status_filter:tasks = [t for t in tasks if t.get("status") == status_filter]@@ -190,9 +189,7 @@ async def _execute_task_manager("task_id": task_id,"removed": removed,"message": (- f"Task {task_id} marked as done and removed from tracking"- if removed- else f"Task {task_id} was not in active tracking"+ f"Task {task_id} marked as done and removed from tracking" if removed else f"Task {task_id} was not in active tracking"),}diff --git a/server/nodes/tool/write_todos/__init__.py b/server/nodes/tool/write_todos/__init__.pyindex f2460f44..74482ed3 100644--- a/server/nodes/tool/write_todos/__init__.py+++ b/server/nodes/tool/write_todos/__init__.py@@ -49,10 +49,8 @@ class WriteTodosNode(ToolNode):"complex tasks into smaller steps.")handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-tool", "kind": "output", "position": "top",- "label": "Tool", "role": "tools"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-tool", "kind": "output", "position": "top", "label": "Tool", "role": "tools"},)ui_hints = {"isToolPanel": True, "hideRunButton": True}annotations = {"destructive": False, "readonly": False, "open_world": False}@@ -75,13 +73,16 @@ class WriteTodosNode(ToolNode):broadcaster = ctx.raw.get("broadcaster")if broadcaster:await broadcaster.update_node_status(- ctx.node_id, "executing",+ ctx.node_id,+ "executing",{"phase": "todo_update", "todos": stored},workflow_id=ctx.workflow_id,)get_logger(__name__).info(- "[WriteTodos] Updated %d todos (session=%s)", len(stored), session_key,+ "[WriteTodos] Updated %d todos (session=%s)",+ len(stored),+ session_key,)return {"message": f"Updated todo list ({len(stored)} items)",diff --git a/server/nodes/trigger/chat_trigger/__init__.py b/server/nodes/trigger/chat_trigger/__init__.pyindex 9058e295..b860b0a4 100644--- a/server/nodes/trigger/chat_trigger/__init__.py+++ b/server/nodes/trigger/chat_trigger/__init__.py@@ -43,10 +43,7 @@ class ChatTriggerNode(TriggerNode):group = ("utility", "trigger")description = "Trigger workflow when user sends a chat message from the console input"component_kind = "trigger"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)ui_hints = {"isChatTrigger": True}task_queue = TaskQueue.TRIGGERS_EVENTmode = "event"@@ -67,9 +64,7 @@ class ChatTriggerNode(TriggerNode):@Operation("wait")async def wait(self, ctx: NodeContext, params: ChatTriggerParams) -> ChatTriggerOutput:- raise NotImplementedError(- "Event triggers return via TriggerNode.execute, not the op body"- )+ raise NotImplementedError("Event triggers return via TriggerNode.execute, not the op body")# Wave 12 C1 rollout #1: opt this trigger into the TriggerListenerWorkflowdiff --git a/server/nodes/trigger/task_trigger/__init__.py b/server/nodes/trigger/task_trigger/__init__.pyindex 4a40f5ca..35edc058 100644--- a/server/nodes/trigger/task_trigger/__init__.py+++ b/server/nodes/trigger/task_trigger/__init__.py@@ -44,10 +44,7 @@ class TaskTriggerNode(TriggerNode):group = ("trigger", "workflow")description = "Triggers when a delegated child agent completes its task (success or error)"component_kind = "trigger"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)task_queue = TaskQueue.TRIGGERS_EVENTmode = "event"event_type = "task_completed"@@ -76,9 +73,7 @@ class TaskTriggerNode(TriggerNode):@Operation("wait")async def wait(self, ctx: NodeContext, params: TaskTriggerParams) -> TaskTriggerOutput:- raise NotImplementedError(- "Event triggers return via TriggerNode.execute, not the op body"- )+ raise NotImplementedError("Event triggers return via TriggerNode.execute, not the op body")# Wave 12 C1 rollout #2: opt this trigger into the TriggerListenerWorkflowdiff --git a/server/nodes/trigger/webhook_trigger/__init__.py b/server/nodes/trigger/webhook_trigger/__init__.pyindex 7365a609..e4cc2d07 100644--- a/server/nodes/trigger/webhook_trigger/__init__.py+++ b/server/nodes/trigger/webhook_trigger/__init__.py@@ -79,10 +79,7 @@ class WebhookTriggerNode(TriggerNode):group = ("trigger",)description = "Start workflow when HTTP request is received"component_kind = "trigger"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)task_queue = TaskQueue.TRIGGERS_EVENTmode = "event"event_type = "webhook_received"@@ -106,9 +103,7 @@ class WebhookTriggerNode(TriggerNode):# stub operation so invariants see it.@Operation("wait")async def wait(self, ctx: NodeContext, params: WebhookTriggerParams) -> WebhookTriggerOutput:- raise NotImplementedError(- "Event triggers return via TriggerNode.execute, not the op body"- )+ raise NotImplementedError("Event triggers return via TriggerNode.execute, not the op body")# Wave 12 C1 canary: opt this trigger type into TriggerListenerWorkflow.diff --git a/server/nodes/twitter/_base.py b/server/nodes/twitter/_base.pyindex 37a9abfc..ba741505 100644--- a/server/nodes/twitter/_base.py+++ b/server/nodes/twitter/_base.py@@ -25,25 +25,30 @@ def _is_auth_error(e: Exception) -> bool:async def track_twitter_usage(- node_id: str, action: str, resource_count: int, context: Dict[str, Any],+ node_id: str,+ action: str,+ resource_count: int,+ context: Dict[str, Any],) -> Dict[str, float]:"""Record a Twitter API call in ``api_usage_metrics``."""from services.plugin.deps import get_databasepricing = get_pricing_service()- cost_data = pricing.calculate_api_cost('twitter', action, resource_count)+ cost_data = pricing.calculate_api_cost("twitter", action, resource_count)db = get_database()- await db.save_api_usage_metric({- 'session_id': context.get('session_id', 'default'),- 'node_id': node_id,- 'workflow_id': context.get('workflow_id'),- 'service': 'twitter',- 'operation': cost_data.get('operation', action),- 'endpoint': action,- 'resource_count': resource_count,- 'cost': cost_data.get('total_cost', 0.0),- })+ await db.save_api_usage_metric(+ {+ "session_id": context.get("session_id", "default"),+ "node_id": node_id,+ "workflow_id": context.get("workflow_id"),+ "service": "twitter",+ "operation": cost_data.get("operation", action),+ "endpoint": action,+ "resource_count": resource_count,+ "cost": cost_data.get("total_cost", 0.0),+ }+ )return cost_data@@ -118,12 +123,12 @@ async def get_my_user_id(client) -> str:def format_response(response) -> Dict[str, Any]:- if hasattr(response, 'data'):+ if hasattr(response, "data"):data = response.dataif isinstance(data, dict):return data- if hasattr(data, '__dict__'):- return {k: v for k, v in data.__dict__.items() if not k.startswith('_')}+ if hasattr(data, "__dict__"):+ return {k: v for k, v in data.__dict__.items() if not k.startswith("_")}return {"data": str(data)}return {"response": str(response)}@@ -133,6 +138,7 @@ def format_user(user) -> Dict[str, Any]:if isinstance(user, dict):return user.get(attr, default)return getattr(user, attr, default)+return {"id": g("id"),"username": g("username"),@@ -158,14 +164,14 @@ def format_tweet(def g(obj, key, default=None):return obj.get(key, default) if isinstance(obj, dict) else getattr(obj, key, default)- tweet_id = g(tweet, 'id')- author_id = g(tweet, 'author_id')- text = g(tweet, 'text', '')+ tweet_id = g(tweet, "id")+ author_id = g(tweet, "author_id")+ text = g(tweet, "text", "")- entities = g(tweet, 'entities') or {}+ entities = g(tweet, "entities") or {}if isinstance(entities, dict):- urls_list = entities.get('urls', [])- elif hasattr(entities, 'urls'):+ urls_list = entities.get("urls", [])+ elif hasattr(entities, "urls"):urls_list = entities.urls or []else:urls_list = []@@ -174,48 +180,56 @@ def format_tweet(display_text = textfor u in urls_list:if isinstance(u, dict):- short = u.get('url', ''); expanded = u.get('expanded_url', ''); display = u.get('display_url', '')+ short = u.get("url", "")+ expanded = u.get("expanded_url", "")+ display = u.get("display_url", "")else:- short = getattr(u, 'url', ''); expanded = getattr(u, 'expanded_url', ''); display = getattr(u, 'display_url', '')+ short = getattr(u, "url", "")+ expanded = getattr(u, "expanded_url", "")+ display = getattr(u, "display_url", "")if short and expanded:expanded_urls.append({"url": short, "expanded_url": expanded, "display_url": display})display_text = display_text.replace(short, expanded)- note_tweet = g(tweet, 'note_tweet')+ note_tweet = g(tweet, "note_tweet")if note_tweet:- note_text = note_tweet.get('text', '') if isinstance(note_tweet, dict) else getattr(note_tweet, 'text', '')+ note_text = note_tweet.get("text", "") if isinstance(note_tweet, dict) else getattr(note_tweet, "text", "")if note_text:text = note_textdisplay_text = note_textauthor_info = users_by_id.get(str(author_id)) if author_id else None- attachments = g(tweet, 'attachments') or {}+ attachments = g(tweet, "attachments") or {}if isinstance(attachments, dict):- media_keys = attachments.get('media_keys', [])- elif hasattr(attachments, 'media_keys'):+ media_keys = attachments.get("media_keys", [])+ elif hasattr(attachments, "media_keys"):media_keys = attachments.media_keys or []else:media_keys = []media_list = [media_by_key[k] for k in media_keys if k in media_by_key]- ref_raw = g(tweet, 'referenced_tweets') or []+ ref_raw = g(tweet, "referenced_tweets") or []referenced = []for ref in ref_raw:if isinstance(ref, dict):- ref_type = ref.get('type', ''); ref_id = ref.get('id', '')+ ref_type = ref.get("type", "")+ ref_id = ref.get("id", "")else:- ref_type = getattr(ref, 'type', ''); ref_id = getattr(ref, 'id', '')+ ref_type = getattr(ref, "type", "")+ ref_id = getattr(ref, "id", "")ref_data = tweets_by_id.get(str(ref_id))- referenced.append({- "type": ref_type,- "id": ref_id,- "text": ref_data.get("text", "") if ref_data else None,- "author_id": ref_data.get("author_id") if ref_data else None,- })-- metrics = g(tweet, 'public_metrics') or {}- if not isinstance(metrics, dict) and hasattr(metrics, 'model_dump'):+ referenced.append(+ {+ "type": ref_type,+ "id": ref_id,+ "text": ref_data.get("text", "") if ref_data else None,+ "author_id": ref_data.get("author_id") if ref_data else None,+ }+ )++ metrics = g(tweet, "public_metrics") or {}+ if not isinstance(metrics, dict) and hasattr(metrics, "model_dump"):metrics = metrics.model_dump()elif not isinstance(metrics, dict):metrics = {}@@ -225,12 +239,12 @@ def format_tweet("text": text,"display_text": display_text,"author_id": author_id,- "created_at": str(g(tweet, 'created_at', '')),- "lang": g(tweet, 'lang'),- "source": g(tweet, 'source'),- "conversation_id": g(tweet, 'conversation_id'),- "in_reply_to_user_id": g(tweet, 'in_reply_to_user_id'),- "possibly_sensitive": g(tweet, 'possibly_sensitive', False),+ "created_at": str(g(tweet, "created_at", "")),+ "lang": g(tweet, "lang"),+ "source": g(tweet, "source"),+ "conversation_id": g(tweet, "conversation_id"),+ "in_reply_to_user_id": g(tweet, "in_reply_to_user_id"),+ "possibly_sensitive": g(tweet, "possibly_sensitive", False),"public_metrics": metrics,}if author_info:@@ -247,7 +261,7 @@ def format_tweet(def _includes_to_dict(raw) -> Dict[str, Any]:if not raw:return {}- if hasattr(raw, 'model_dump'):+ if hasattr(raw, "model_dump"):try:return raw.model_dump()except Exception:@@ -260,50 +274,61 @@ def _includes_to_dict(raw) -> Dict[str, Any]:def sync_search_recent(client, query: str, max_results: int) -> Dict[str, Any]:"""Run ``posts.search_recent`` synchronously; returns {tweets, includes}."""for page in client.posts.search_recent(- query=query, max_results=max_results,+ query=query,+ max_results=max_results,tweet_fields=[- "author_id", "created_at", "entities", "public_metrics",- "possibly_sensitive", "lang", "source",- "conversation_id", "in_reply_to_user_id", "referenced_tweets",+ "author_id",+ "created_at",+ "entities",+ "public_metrics",+ "possibly_sensitive",+ "lang",+ "source",+ "conversation_id",+ "in_reply_to_user_id",+ "referenced_tweets","note_tweet",],expansions=[- "author_id", "attachments.media_keys",- "referenced_tweets.id", "referenced_tweets.id.author_id",+ "author_id",+ "attachments.media_keys",+ "referenced_tweets.id",+ "referenced_tweets.id.author_id",],media_fields=["url", "preview_image_url", "type", "alt_text", "variants"],user_fields=["username", "name", "profile_image_url"],):return {- "tweets": getattr(page, 'data', []) or [],- "includes": _includes_to_dict(getattr(page, 'includes', None)),+ "tweets": getattr(page, "data", []) or [],+ "includes": _includes_to_dict(getattr(page, "includes", None)),}return {"tweets": [], "includes": {}}def includes_lookups(includes: Dict[str, Any]):"""Build {users_by_id, media_by_key, tweets_by_id} from a search-includes dict."""+def _as_dict(obj):if isinstance(obj, dict):return obj- if hasattr(obj, '__dict__'):- return {k: v for k, v in obj.__dict__.items() if not k.startswith('_')}+ if hasattr(obj, "__dict__"):+ return {k: v for k, v in obj.__dict__.items() if not k.startswith("_")}return {}users_by_id = {}- for u in (includes.get("users") or []):+ for u in includes.get("users") or []:uid = u.get("id") if isinstance(u, dict) else getattr(u, "id", None)if uid:users_by_id[str(uid)] = _as_dict(u)media_by_key = {}- for m in (includes.get("media") or []):+ for m in includes.get("media") or []:mk = m.get("media_key") if isinstance(m, dict) else getattr(m, "media_key", None)if mk:media_by_key[mk] = _as_dict(m)tweets_by_id = {}- for t in (includes.get("tweets") or []):+ for t in includes.get("tweets") or []:tid = t.get("id") if isinstance(t, dict) else getattr(t, "id", None)if tid:tweets_by_id[str(tid)] = _as_dict(t)diff --git a/server/nodes/twitter/_credentials.py b/server/nodes/twitter/_credentials.pyindex 8405565a..9a66a225 100644--- a/server/nodes/twitter/_credentials.py+++ b/server/nodes/twitter/_credentials.py@@ -25,9 +25,13 @@ class TwitterCredential(OAuth2Credential):client_id_api_key = "twitter_client_id"client_secret_api_key = "twitter_client_secret"scopes = (- "tweet.read", "tweet.write", "users.read",- "follows.read", "follows.write",- "like.read", "like.write",+ "tweet.read",+ "tweet.write",+ "users.read",+ "follows.read",+ "follows.write",+ "like.read",+ "like.write","offline.access",)docs_url = "https://developer.x.com/en/docs/authentication/oauth-2-0"diff --git a/server/nodes/twitter/_events.py b/server/nodes/twitter/_events.pyindex 6ffac61f..29b04371 100644--- a/server/nodes/twitter/_events.py+++ b/server/nodes/twitter/_events.py@@ -53,11 +53,7 @@ def twitter_event_received(event_data: Mapping[str, Any]) -> WorkflowEvent:given tweet is until the downstream filter runs."""payload = dict(event_data)- subject = (- payload.get("tweet_id")- or payload.get("id")- or payload.get("dm_id")- )+ subject = payload.get("tweet_id") or payload.get("id") or payload.get("dm_id")return WorkflowEvent(source="machinaos://nodes/twitter",type="com.machinaos.twitter.event.received",diff --git a/server/nodes/twitter/_filters.py b/server/nodes/twitter/_filters.pyindex 27f7e902..f6a88d04 100644--- a/server/nodes/twitter/_filters.py+++ b/server/nodes/twitter/_filters.py@@ -17,20 +17,20 @@ def build_filter(params: Dict) -> Callable[[Dict], bool]:- ``search_query`` -- search query for ``search``- ``user_id`` -- user ID for ``user_timeline``"""- trigger_type = params.get('trigger_type', 'mentions')- search_query = params.get('search_query', '')- user_id = params.get('user_id', '')+ trigger_type = params.get("trigger_type", "mentions")+ search_query = params.get("search_query", "")+ user_id = params.get("user_id", "")def matches(data: Dict) -> bool:- event_type = data.get('trigger_type', '')- if trigger_type != 'all' and event_type != trigger_type:+ event_type = data.get("trigger_type", "")+ if trigger_type != "all" and event_type != trigger_type:return False- if trigger_type == 'search' and search_query:- event_query = data.get('query', '')+ if trigger_type == "search" and search_query:+ event_query = data.get("query", "")if search_query.lower() not in event_query.lower():return False- if trigger_type == 'user_timeline' and user_id:- if data.get('user_id') != user_id:+ if trigger_type == "user_timeline" and user_id:+ if data.get("user_id") != user_id:return Falsereturn Truediff --git a/server/nodes/twitter/_handlers.py b/server/nodes/twitter/_handlers.pyindex 5c90bd41..dac44eee 100644--- a/server/nodes/twitter/_handlers.py+++ b/server/nodes/twitter/_handlers.py@@ -25,7 +25,9 @@ from ._oauth import TwitterOAuthasync def _twitter_oauth_factory(- *, redirect_uri: Optional[str] = None, **_kwargs,+ *,+ redirect_uri: Optional[str] = None,+ **_kwargs,) -> TwitterOAuth:"""Build a :class:`TwitterOAuth` from stored client credentials."""from services.plugin.deps import get_auth_servicediff --git a/server/nodes/twitter/_oauth.py b/server/nodes/twitter/_oauth.pyindex 3275900c..c05611ea 100644--- a/server/nodes/twitter/_oauth.py+++ b/server/nodes/twitter/_oauth.py@@ -94,8 +94,7 @@ class TwitterOAuth(OAuth2PKCEClient):error_data = response.json() if response.text else {}return {"success": False,- "error": error_data.get("detail")- or error_data.get("title", "Failed to get user info"),+ "error": error_data.get("detail") or error_data.get("title", "Failed to get user info"),}user = response.json().get("data", {})diff --git a/server/nodes/twitter/_refresh.py b/server/nodes/twitter/_refresh.pyindex 13e7caa6..fe48196d 100644--- a/server/nodes/twitter/_refresh.py+++ b/server/nodes/twitter/_refresh.py@@ -35,9 +35,7 @@ async def refresh_twitter_status(broadcaster: "StatusBroadcaster") -> None:from services.plugin.deps import get_auth_serviceauth_service = get_auth_service()- tokens = await auth_service.get_oauth_tokens(- "twitter", customer_id="owner"- )+ tokens = await auth_service.get_oauth_tokens("twitter", customer_id="owner")if not tokens or not tokens.get("access_token"):broadcaster._status["twitter"] = {"connected": False,@@ -64,15 +62,13 @@ async def refresh_twitter_status(broadcaster: "StatusBroadcaster") -> None:username,)- await broadcaster.broadcast({- "type": "twitter_status",- "data": broadcaster._status["twitter"],- })- span.set_attribute(- "connected", bool(broadcaster._status["twitter"]["connected"])+ await broadcaster.broadcast(+ {+ "type": "twitter_status",+ "data": broadcaster._status["twitter"],+ })+ span.set_attribute("connected", bool(broadcaster._status["twitter"]["connected"]))except Exception as exc: # noqa: BLE001 -- mirror pre-migration behaviourspan.record_exception(exc)- logger.debug(- "[StatusBroadcaster] Could not refresh Twitter status: %s", exc- )+ logger.debug("[StatusBroadcaster] Could not refresh Twitter status: %s", exc)diff --git a/server/nodes/twitter/twitter_receive/__init__.py b/server/nodes/twitter/twitter_receive/__init__.pyindex 886f513a..72b8a484 100644--- a/server/nodes/twitter/twitter_receive/__init__.py+++ b/server/nodes/twitter/twitter_receive/__init__.py@@ -43,10 +43,7 @@ class TwitterReceiveNode(TriggerNode):# ``event_waiter._auto_populate_from_plugins`` backfill# TRIGGER_REGISTRY without a hardcoded entry in event_waiter.event_type = "twitter_event_received"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)credentials = (TwitterCredential,)task_queue = TaskQueue.TRIGGERS_POLLmode = "polling"@@ -62,9 +59,12 @@ class TwitterReceiveNode(TriggerNode):context: NodeContext,) -> Dict[str, Any]:from services.handlers.triggers import handle_trigger_node+return await handle_trigger_node(- node_id=node_id, node_type=self.type,- parameters=parameters, context=context.raw,+ node_id=node_id,+ node_type=self.type,+ parameters=parameters,+ context=context.raw,)@Operation("wait")diff --git a/server/nodes/twitter/twitter_search/__init__.py b/server/nodes/twitter/twitter_search/__init__.pyindex 1f82109a..2ab91637 100644--- a/server/nodes/twitter/twitter_search/__init__.py+++ b/server/nodes/twitter/twitter_search/__init__.py@@ -12,8 +12,11 @@ from services.plugin import ActionNode, NodeContext, Operation, TaskQueuefrom .._credentials import TwitterCredentialfrom .._base import (- call_with_retry, format_tweet, includes_lookups,- sync_search_recent, track_twitter_usage,+ call_with_retry,+ format_tweet,+ includes_lookups,+ sync_search_recent,+ track_twitter_usage,)@@ -25,7 +28,7 @@ class TwitterSearchParams(BaseModel):description=("X / Twitter search query for /2/tweets/search/recent. ""MUST include at least one STANDALONE term: a keyword, "- "quoted \"phrase\", #hashtag, @mention, from:user, to:user, "+ 'quoted "phrase", #hashtag, @mention, from:user, to:user, '"or url:domain. ""Operators like lang:, -is:retweet, is:reply, has:media, ""has:links are CONJUNCTION-REQUIRED -- they only work when "@@ -36,7 +39,9 @@ class TwitterSearchParams(BaseModel):),)max_results: int = Field(- default=10, ge=10, le=100,+ default=10,+ ge=10,+ le=100,description="Number of results (X API minimum 10, max 100)",)sort_order: Literal["recency", "relevancy"] = Field(@@ -90,10 +95,8 @@ class TwitterSearchNode(ActionNode):tool_name = "twitter_search"tool_description = "Search recent tweets on Twitter/X. Returns enriched tweets with expanded URLs, author profile, public_metrics, media, referenced_tweets, note_tweet. Supports query operators: keywords, #hashtags, @mentions, from:user, to:user, -exclude, OR, lang:, has:links/media/images/videos, is:retweet/reply/quote, url:."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": True, "open_world": True}credentials = (TwitterCredential,)diff --git a/server/nodes/twitter/twitter_send/__init__.py b/server/nodes/twitter/twitter_send/__init__.pyindex 6205b77c..b5997dd5 100644--- a/server/nodes/twitter/twitter_send/__init__.py+++ b/server/nodes/twitter/twitter_send/__init__.py@@ -12,7 +12,10 @@ from services.plugin import ActionNode, NodeContext, Operation, TaskQueuefrom .._credentials import TwitterCredentialfrom .._base import (- call_with_retry, format_response, get_my_user_id, track_twitter_usage,+ call_with_retry,+ format_response,+ get_my_user_id,+ track_twitter_usage,)@@ -21,8 +24,15 @@ class TwitterSendParams(BaseModel):no aliases. ``reply`` action uses ``tweet_id`` as the target (unifiedwith other id-based actions) — baseline behaviour."""+action: Literal[- "tweet", "reply", "retweet", "quote", "like", "unlike", "delete",+ "tweet",+ "reply",+ "retweet",+ "quote",+ "like",+ "unlike",+ "delete",] = Field(default="tweet", description="Action to perform")text: str = Field(default="",@@ -36,9 +46,18 @@ class TwitterSendParams(BaseModel):default="",description="Target tweet ID (for reply/retweet/quote/like/unlike/delete)",json_schema_extra={- "displayOptions": {"show": {"action": [- "reply", "retweet", "quote", "like", "unlike", "delete",- ]}},+ "displayOptions": {+ "show": {+ "action": [+ "reply",+ "retweet",+ "quote",+ "like",+ "unlike",+ "delete",+ ]+ }+ },},)include_media: bool = Field(@@ -52,10 +71,12 @@ class TwitterSendParams(BaseModel):default="",description="Comma-separated URLs; max 4 images or 1 video",json_schema_extra={- "displayOptions": {"show": {- "action": ["tweet", "reply", "quote"],- "include_media": [True],- }},+ "displayOptions": {+ "show": {+ "action": ["tweet", "reply", "quote"],+ "include_media": [True],+ }+ },},)include_poll: bool = Field(@@ -69,20 +90,26 @@ class TwitterSendParams(BaseModel):default="",description="Comma-separated options (2-4 items, 25 chars each)",json_schema_extra={- "displayOptions": {"show": {- "action": ["tweet"],- "include_poll": [True],- }},+ "displayOptions": {+ "show": {+ "action": ["tweet"],+ "include_poll": [True],+ }+ },},)poll_duration: int = Field(- default=1440, ge=5, le=10080,+ default=1440,+ ge=5,+ le=10080,description="Poll duration in minutes (5 min - 7 days)",json_schema_extra={- "displayOptions": {"show": {- "action": ["tweet"],- "include_poll": [True],- }},+ "displayOptions": {+ "show": {+ "action": ["tweet"],+ "include_poll": [True],+ }+ },},)@@ -136,7 +163,9 @@ async def _do_send(client, action: str, p: dict, node_id: str, ctx_raw: dict) ->if action == "retweet":user_id = await get_my_user_id(client)result = await asyncio.to_thread(- client.users.repost_post, user_id, body={"tweet_id": tweet_id},+ client.users.repost_post,+ user_id,+ body={"tweet_id": tweet_id},)await track_twitter_usage(node_id, "retweet", 1, ctx_raw)return TwitterSendOutput(action="retweeted", data=format_response(result))@@ -144,7 +173,9 @@ async def _do_send(client, action: str, p: dict, node_id: str, ctx_raw: dict) ->if action == "like":user_id = await get_my_user_id(client)result = await asyncio.to_thread(- client.users.like_post, user_id, body={"tweet_id": tweet_id},+ client.users.like_post,+ user_id,+ body={"tweet_id": tweet_id},)await track_twitter_usage(node_id, "like", 1, ctx_raw)return TwitterSendOutput(action="liked", data=format_response(result))@@ -152,7 +183,9 @@ async def _do_send(client, action: str, p: dict, node_id: str, ctx_raw: dict) ->if action == "unlike":user_id = await get_my_user_id(client)result = await asyncio.to_thread(- client.users.unlike_post, user_id, tweet_id=tweet_id,+ client.users.unlike_post,+ user_id,+ tweet_id=tweet_id,)await track_twitter_usage(node_id, "unlike", 1, ctx_raw)return TwitterSendOutput(action="unliked", data=format_response(result))@@ -175,10 +208,8 @@ class TwitterSendNode(ActionNode):tool_name = "twitter_send"tool_description = "Post, reply, retweet, like, unlike, or delete tweets on Twitter/X. Actions: tweet, reply, retweet, like, unlike, delete. Specify text (280 char max), tweet_id, reply_to_id as needed."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}credentials = (TwitterCredential,)diff --git a/server/nodes/twitter/twitter_user/__init__.py b/server/nodes/twitter/twitter_user/__init__.pyindex 82fc4ae5..858d3227 100644--- a/server/nodes/twitter/twitter_user/__init__.py+++ b/server/nodes/twitter/twitter_user/__init__.py@@ -33,13 +33,21 @@ class TwitterUserParams(BaseModel):default="",description="Twitter user ID (numeric)",json_schema_extra={- "displayOptions": {"show": {"operation": [- "by_id", "followers", "following",- ]}},+ "displayOptions": {+ "show": {+ "operation": [+ "by_id",+ "followers",+ "following",+ ]+ }+ },},)max_results: int = Field(- default=100, ge=1, le=1000,+ default=100,+ ge=1,+ le=1000,description="Number of users to return (1-1000)",json_schema_extra={"displayOptions": {"show": {"operation": ["followers", "following"]}},@@ -60,24 +68,29 @@ class TwitterUserOutput(BaseModel):def _sync_followers(client, user_id, max_results):for page in client.users.get_followers(- user_id, max_results=max_results, user_fields=["created_at"],+ user_id,+ max_results=max_results,+ user_fields=["created_at"],):- return list(getattr(page, 'data', []) or [])+ return list(getattr(page, "data", []) or [])return []def _sync_following(client, user_id, max_results):for page in client.users.get_following(- user_id, max_results=max_results, user_fields=["created_at"],+ user_id,+ max_results=max_results,+ user_fields=["created_at"],):- return list(getattr(page, 'data', []) or [])+ return list(getattr(page, "data", []) or [])return []async def _do_lookup(client, op: str, p: dict, node_id: str, ctx_raw: dict) -> TwitterUserOutput:if op == "me":result = await asyncio.to_thread(- client.users.get_me, user_fields=["created_at", "description"],+ client.users.get_me,+ user_fields=["created_at", "description"],)await track_twitter_usage(node_id, "me", 1, ctx_raw)return TwitterUserOutput(operation="me", user=format_user(result.data))@@ -87,10 +100,11 @@ async def _do_lookup(client, op: str, p: dict, node_id: str, ctx_raw: dict) -> Tif not username:raise RuntimeError("Username is required")result = await asyncio.to_thread(- client.users.get_by_usernames, usernames=[username],+ client.users.get_by_usernames,+ usernames=[username],user_fields=["description", "created_at"],)- users = getattr(result, 'data', []) or []+ users = getattr(result, "data", []) or []if not users:raise RuntimeError(f"User @{username} not found")await track_twitter_usage(node_id, "by_username", 1, ctx_raw)@@ -101,10 +115,11 @@ async def _do_lookup(client, op: str, p: dict, node_id: str, ctx_raw: dict) -> Tif not user_id:raise RuntimeError("User ID is required")result = await asyncio.to_thread(- client.users.get_by_ids, ids=[user_id],+ client.users.get_by_ids,+ ids=[user_id],user_fields=["description", "created_at"],)- users = getattr(result, 'data', []) or []+ users = getattr(result, "data", []) or []if not users:raise RuntimeError(f"User ID {user_id} not found")await track_twitter_usage(node_id, "by_id", 1, ctx_raw)@@ -133,10 +148,8 @@ class TwitterUserNode(ActionNode):tool_name = "twitter_user"tool_description = "Look up Twitter/X user profiles with description and created_at. Operations: me (authenticated user), by_username, by_id, followers (max_results 1-1000), following (max_results 1-1000)."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": True, "open_world": True}credentials = (TwitterCredential,)diff --git a/server/nodes/utility/console/__init__.py b/server/nodes/utility/console/__init__.pyindex 55337f45..c9e26e9c 100644--- a/server/nodes/utility/console/__init__.py+++ b/server/nodes/utility/console/__init__.py@@ -72,14 +72,10 @@ def _format_console_output(data: Any, format_type: str) -> str:if isinstance(data, list) and data and isinstance(data[0], dict):headers = list(data[0].keys())rows = [[str(r.get(h, "")) for h in headers] for r in data]- widths = [max(len(h), max((len(r[i]) for r in rows), default=0))- for i, h in enumerate(headers)]+ widths = [max(len(h), max((len(r[i]) for r in rows), default=0)) for i, h in enumerate(headers)]header_line = " | ".join(h.ljust(widths[i]) for i, h in enumerate(headers))sep = "-+-".join("-" * w for w in widths)- body = ["\n" .join(- " | ".join(r[i].ljust(widths[i]) for i in range(len(headers)))- for r in rows- )]+ body = ["\n".join(" | ".join(r[i].ljust(widths[i]) for i in range(len(headers))) for r in rows)]return "\n".join([header_line, sep, *body])return json.dumps(data, indent=2, default=str, ensure_ascii=False)case _:@@ -119,10 +115,7 @@ class ConsoleNode(ActionNode):group = ("utility",)description = "Log data to console panel for debugging during execution"component_kind = "square"- handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- )+ handles = ({"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},)hide_output_handle = Trueui_hints = {"isConsoleSink": True}annotations = {"destructive": False, "readonly": True, "open_world": False}@@ -183,18 +176,20 @@ class ConsoleNode(ActionNode):formatted_output = _format_console_output(log_value, format_type)- await get_status_broadcaster().broadcast_console_log({- "node_id": ctx.node_id,- "label": label or f"Console ({ctx.node_id[:8]})",- "timestamp": datetime.now().isoformat(),- "data": log_value,- "formatted": formatted_output,- "format": format_type,- "workflow_id": ctx.workflow_id,- "source_node_id": source_info.get("id") if source_info else None,- "source_node_type": source_info.get("type") if source_info else None,- "source_node_label": source_info.get("label") if source_info else None,- })+ await get_status_broadcaster().broadcast_console_log(+ {+ "node_id": ctx.node_id,+ "label": label or f"Console ({ctx.node_id[:8]})",+ "timestamp": datetime.now().isoformat(),+ "data": log_value,+ "formatted": formatted_output,+ "format": format_type,+ "workflow_id": ctx.workflow_id,+ "source_node_id": source_info.get("id") if source_info else None,+ "source_node_type": source_info.get("type") if source_info else None,+ "source_node_label": source_info.get("label") if source_info else None,+ }+ )# Pass through original input for downstream nodes; explicit keys# take precedence over upstream keys of the same name.diff --git a/server/nodes/utility/http_request/__init__.py b/server/nodes/utility/http_request/__init__.pyindex ddda4c23..a7a7ef62 100644--- a/server/nodes/utility/http_request/__init__.py+++ b/server/nodes/utility/http_request/__init__.py@@ -47,7 +47,8 @@ class HttpRequestParams(BaseModel):json_schema_extra={"displayOptions": {"show": {"use_proxy": [True]}}},)sticky_duration: int = Field(- default=600, ge=1,+ default=600,+ ge=1,description="Sticky session duration in seconds.",json_schema_extra={"displayOptions": {"show": {"use_proxy": [True], "session_type": ["sticky"]}},@@ -101,10 +102,8 @@ class HttpRequestNode(ActionNode):if not params.url:raise RuntimeError("URL is required")- proxy_url = await _resolve_proxy_url(params.url, params.use_proxy,- params.model_dump())- log.info("[HTTP Request] Executing", node_id=ctx.node_id,- method=params.method, url=params.url, proxy=bool(proxy_url))+ proxy_url = await _resolve_proxy_url(params.url, params.use_proxy, params.model_dump())+ log.info("[HTTP Request] Executing", node_id=ctx.node_id, method=params.method, url=params.url, proxy=bool(proxy_url))client_kwargs: dict = {"timeout": float(params.timeout)}if proxy_url:@@ -155,12 +154,14 @@ async def _resolve_proxy_url(url: str, use_proxy: bool, parameters: dict) -> Anyreturn Nonetry:from services.proxy.service import get_proxy_service+svc = get_proxy_service()if not svc or not svc.is_enabled():return Nonereturn await svc.get_proxy_url(url, parameters)except Exception as e:get_logger(__name__).warning(- "Proxy URL lookup failed, proceeding without proxy", error=str(e),+ "Proxy URL lookup failed, proceeding without proxy",+ error=str(e),)return Nonediff --git a/server/nodes/utility/process_manager/__init__.py b/server/nodes/utility/process_manager/__init__.pyindex 5c9cd057..d2659e0c 100644--- a/server/nodes/utility/process_manager/__init__.py+++ b/server/nodes/utility/process_manager/__init__.py@@ -87,12 +87,14 @@ class ProcessManagerNode(ActionNode):return responseif op == "start":- return _unwrap(await svc.start(- name=name,- command=_clean(params.command),- workflow_id=workflow_id,- working_directory=_clean(params.cwd) or agent_dir,- ))+ return _unwrap(+ await svc.start(+ name=name,+ command=_clean(params.command),+ workflow_id=workflow_id,+ working_directory=_clean(params.cwd) or agent_dir,+ )+ )if op == "stop":return _unwrap(await svc.stop(name, workflow_id))if op == "restart":diff --git a/server/nodes/utility/webhook_response/__init__.py b/server/nodes/utility/webhook_response/__init__.pyindex 41b23bfd..98a1b69f 100644--- a/server/nodes/utility/webhook_response/__init__.py+++ b/server/nodes/utility/webhook_response/__init__.py@@ -68,15 +68,20 @@ class WebhookResponseNode(ActionNode):body_text = body if isinstance(body, str) else json_module.dumps(body, default=str)log.info(- "[Webhook Response] Sending", node_id=ctx.node_id,- status_code=params.status_code, content_type=params.content_type,+ "[Webhook Response] Sending",+ node_id=ctx.node_id,+ status_code=params.status_code,+ content_type=params.content_type,body_length=len(body_text),)- resolve_webhook_response(ctx.node_id, {- "statusCode": params.status_code,- "body": body_text,- "contentType": params.content_type,- })+ resolve_webhook_response(+ ctx.node_id,+ {+ "statusCode": params.status_code,+ "body": body_text,+ "contentType": params.content_type,+ },+ )return {"sent": True,"statusCode": params.status_code,diff --git a/server/nodes/whatsapp/_base.py b/server/nodes/whatsapp/_base.pyindex 5730cd32..0cf39978 100644--- a/server/nodes/whatsapp/_base.py+++ b/server/nodes/whatsapp/_base.py@@ -17,7 +17,7 @@ logger = get_logger(__name__)def _is_invite_link(value: str) -> bool:"""Check if a channel identifier is an invite link URL."""- return value.strip().startswith('http://') or value.strip().startswith('https://')+ return value.strip().startswith("http://") or value.strip().startswith("https://")def _resolve_channel_identifier(value: str) -> Dict[str, str]:@@ -30,8 +30,8 @@ def _resolve_channel_identifier(value: str) -> Dict[str, str]:return {}value = value.strip()if _is_invite_link(value):- return {'invite': value}- return {'jid': value}+ return {"invite": value}+ return {"jid": value}async def _resolve_to_jid(value: str, rpc_call) -> str:@@ -48,44 +48,40 @@ async def _resolve_to_jid(value: str, rpc_call) -> str:if not _is_invite_link(value):return value# Resolve invite link to JID via newsletter_info- data = await rpc_call('newsletter_info', {'invite': value})+ data = await rpc_call("newsletter_info", {"invite": value})if isinstance(data, dict):- result = data.get('result', data)- jid = result.get('jid') or result.get('id')+ result = data.get("result", data)+ jid = result.get("jid") or result.get("id")if jid:return jidraise ValueError(f"Could not resolve invite link to channel JID: {value}")# Media types that can be downloaded via the media RPC-MEDIA_MESSAGE_TYPES = frozenset({'image', 'video', 'audio', 'document', 'sticker'})+MEDIA_MESSAGE_TYPES = frozenset({"image", "video", "audio", "document", "sticker"})async def _download_single_media(message: Dict[str, Any], rpc_call) -> None:"""Download media for a single message in-place. Mutates the message dict."""- message_id = message.get('message_id') or message.get('id')+ message_id = message.get("message_id") or message.get("id")if not message_id:returntry:- data = await rpc_call('media', {'message_id': message_id})+ data = await rpc_call("media", {"message_id": message_id})if isinstance(data, dict):- result = data.get('result', data)- if result.get('data'):- message['media_data'] = result['data']- message['media_mime_type'] = result.get('mime_type', '')+ result = data.get("result", data)+ if result.get("data"):+ message["media_data"] = result["data"]+ message["media_mime_type"] = result.get("mime_type", "")else:- message['media_error'] = result.get('error', 'No media data returned')+ message["media_error"] = result.get("error", "No media data returned")else:- message['media_error'] = 'Unexpected response format'+ message["media_error"] = "Unexpected response format"except Exception as e:- message['media_error'] = str(e)+ message["media_error"] = str(e)-async def _enrich_messages_with_media(- messages: List[Dict[str, Any]],- rpc_call,- max_concurrent: int = 5-) -> List[Dict[str, Any]]:+async def _enrich_messages_with_media(messages: List[Dict[str, Any]], rpc_call, max_concurrent: int = 5) -> List[Dict[str, Any]]:"""Download media for messages that contain media types.Uses asyncio.Semaphore for concurrency control and asyncio.gather@@ -106,30 +102,19 @@ async def _enrich_messages_with_media(await _download_single_media(msg, rpc_call)# Filter to only media messages- media_messages = [- msg for msg in messages- if msg.get('message_type', msg.get('type', '')) in MEDIA_MESSAGE_TYPES- ]+ media_messages = [msg for msg in messages if msg.get("message_type", msg.get("type", "")) in MEDIA_MESSAGE_TYPES]if not media_messages:return messageslogger.info(f"Downloading media for {len(media_messages)} messages (max concurrent: {max_concurrent})")- await asyncio.gather(- *(download_with_semaphore(msg) for msg in media_messages),- return_exceptions=True- )+ await asyncio.gather(*(download_with_semaphore(msg) for msg in media_messages), return_exceptions=True)return messages-async def handle_whatsapp_send(- node_id: str,- node_type: str,- parameters: Dict[str, Any],- context: Dict[str, Any]-) -> Dict[str, Any]:+async def handle_whatsapp_send(node_id: str, node_type: str, parameters: Dict[str, Any], context: Dict[str, Any]) -> Dict[str, Any]:"""Handle WhatsApp send message node via Go RPC service.Supports all message types: text, image, video, audio, document, sticker, location, contact@@ -146,49 +131,51 @@ async def handle_whatsapp_send(Execution result dict"""from nodes.whatsapp._service import handle_whatsapp_send as whatsapp_send_handler+start_time = time.time()try:# Determine recipient (snake_case parameters)- recipient_type = parameters.get('recipient_type', 'self')- message_type = parameters.get('message_type', 'text')+ recipient_type = parameters.get("recipient_type", "self")+ message_type = parameters.get("message_type", "text")# Determine recipient based on type- if recipient_type == 'self':+ if recipient_type == "self":# Self will be resolved by the router using connected phone- recipient = 'self'- elif recipient_type == 'channel':- recipient = parameters.get('channel_jid')+ recipient = "self"+ elif recipient_type == "channel":+ recipient = parameters.get("channel_jid")if not recipient:raise ValueError("Channel JID is required")# Validate channel-supported message types- channel_types = {'text', 'image', 'video', 'audio', 'document'}+ channel_types = {"text", "image", "video", "audio", "document"}if message_type not in channel_types:raise ValueError(f"Channels only support: {', '.join(sorted(channel_types))}. Got: {message_type}")- elif recipient_type == 'group':- recipient = parameters.get('group_id')+ elif recipient_type == "group":+ recipient = parameters.get("group_id")if not recipient:raise ValueError("Group ID is required")else: # phone- recipient = parameters.get('phone')+ recipient = parameters.get("phone")if not recipient:raise ValueError("Phone number is required")# For text messages, validate message content- if message_type == 'text' and not parameters.get('message'):+ if message_type == "text" and not parameters.get("message"):raise ValueError("Message content is required for text messages")# Convert GFM markdown to WhatsApp-native formatting if enabled- if message_type == 'text' and parameters.get('format_markdown', False):+ if message_type == "text" and parameters.get("format_markdown", False):from services.markdown_formatter import to_whatsapp- parameters['message'] = to_whatsapp(parameters['message'])++ parameters["message"] = to_whatsapp(parameters["message"])# Call WhatsApp Go RPC service via handler - pass full paramsdata = await whatsapp_send_handler(parameters)- success = data.get('success', False)+ success = data.get("success", False)if not success:- raise Exception(data.get('error', 'Send failed'))+ raise Exception(data.get("error", "Send failed"))# Build informative result based on message type (snake_case output)result = {@@ -196,37 +183,37 @@ async def handle_whatsapp_send("recipient": recipient,"recipient_type": recipient_type,"message_type": message_type,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}# Add type-specific details using match statementmatch message_type:- case 'text':- msg_content = parameters.get('message', '')+ case "text":+ msg_content = parameters.get("message", "")result["preview"] = msg_content[:100] + "..." if len(msg_content) > 100 else msg_content- case 'image' | 'video' | 'audio' | 'document' | 'sticker':- media_source = parameters.get('media_source', 'base64')+ case "image" | "video" | "audio" | "document" | "sticker":+ media_source = parameters.get("media_source", "base64")result["media_source"] = media_source- if parameters.get('caption'):- result["caption"] = parameters.get('caption')- if parameters.get('filename'):- result["filename"] = parameters.get('filename')- if parameters.get('mime_type'):- result["mime_type"] = parameters.get('mime_type')+ if parameters.get("caption"):+ result["caption"] = parameters.get("caption")+ if parameters.get("filename"):+ result["filename"] = parameters.get("filename")+ if parameters.get("mime_type"):+ result["mime_type"] = parameters.get("mime_type")# For file uploads, include the uploaded filename- file_param = parameters.get('file_path')- if isinstance(file_param, dict) and file_param.get('type') == 'upload':- result["uploaded_file"] = file_param.get('filename')- result["mime_type"] = file_param.get('mimeType')- case 'location':+ file_param = parameters.get("file_path")+ if isinstance(file_param, dict) and file_param.get("type") == "upload":+ result["uploaded_file"] = file_param.get("filename")+ result["mime_type"] = file_param.get("mimeType")+ case "location":result["location"] = {- "latitude": parameters.get('latitude'),- "longitude": parameters.get('longitude'),- "name": parameters.get('location_name'),- "address": parameters.get('address')+ "latitude": parameters.get("latitude"),+ "longitude": parameters.get("longitude"),+ "name": parameters.get("location_name"),+ "address": parameters.get("address"),}- case 'contact':- result["contact_name"] = parameters.get('contact_name')+ case "contact":+ result["contact_name"] = parameters.get("contact_name")return {"success": success,@@ -234,7 +221,7 @@ async def handle_whatsapp_send("node_type": "whatsappSend","result": result,"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:@@ -245,16 +232,11 @@ async def handle_whatsapp_send("node_type": "whatsappSend","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}-async def handle_whatsapp_db(- node_id: str,- node_type: str,- parameters: Dict[str, Any],- context: Dict[str, Any]-) -> Dict[str, Any]:+async def handle_whatsapp_db(node_id: str, node_type: str, parameters: Dict[str, Any], context: Dict[str, Any]) -> Dict[str, Any]:"""Handle WhatsApp DB node - query contacts, groups, messages.Operations:@@ -289,105 +271,103 @@ async def handle_whatsapp_db(Returns:Execution result dict"""- from nodes.whatsapp._service import (- handle_whatsapp_chat_history as whatsapp_chat_history_handler,- whatsapp_rpc_call- )+ from nodes.whatsapp._service import handle_whatsapp_chat_history as whatsapp_chat_history_handler, whatsapp_rpc_call+start_time = time.time()try:- operation = parameters.get('operation', 'chat_history')+ operation = parameters.get("operation", "chat_history")- if operation == 'chat_history':+ if operation == "chat_history":return await _handle_chat_history(node_id, parameters, start_time, whatsapp_chat_history_handler, whatsapp_rpc_call)- elif operation == 'search_groups':+ elif operation == "search_groups":return await _handle_search_groups(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'get_group_info':+ elif operation == "get_group_info":return await _handle_get_group_info(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'get_contact_info':+ elif operation == "get_contact_info":return await _handle_get_contact_info(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'list_contacts':+ elif operation == "list_contacts":return await _handle_list_contacts(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'check_contacts':+ elif operation == "check_contacts":return await _handle_check_contacts(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'list_channels':+ elif operation == "list_channels":return await _handle_list_channels(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'get_channel_info':+ elif operation == "get_channel_info":return await _handle_get_channel_info(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'channel_messages':+ elif operation == "channel_messages":return await _handle_channel_messages(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'channel_stats':+ elif operation == "channel_stats":return await _handle_channel_stats(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'channel_follow':+ elif operation == "channel_follow":return await _handle_channel_follow(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'channel_unfollow':+ elif operation == "channel_unfollow":return await _handle_channel_unfollow(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'channel_create':+ elif operation == "channel_create":return await _handle_channel_create(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'channel_mute':+ elif operation == "channel_mute":return await _handle_channel_mute(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'channel_mark_viewed':+ elif operation == "channel_mark_viewed":return await _handle_channel_mark_viewed(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'newsletter_react':+ elif operation == "newsletter_react":return await _handle_newsletter_react(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'newsletter_live_updates':+ elif operation == "newsletter_live_updates":return await _handle_newsletter_live_updates(node_id, parameters, start_time, whatsapp_rpc_call)- elif operation == 'contact_profile_pic':+ elif operation == "contact_profile_pic":return await _handle_contact_profile_pic(node_id, parameters, start_time, whatsapp_rpc_call)else:raise ValueError(f"Unknown operation: {operation}")except Exception as e:- logger.error("WhatsApp DB failed", node_id=node_id, operation=parameters.get('operation'), error=str(e))+ logger.error("WhatsApp DB failed", node_id=node_id, operation=parameters.get("operation"), error=str(e))return {"success": False,"node_id": node_id,"node_type": "whatsappDb","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_chat_history(node_id: str, parameters: Dict[str, Any], start_time: float, handler, rpc_call=None) -> Dict[str, Any]:"""Handle chat_history operation."""- chat_type = parameters.get('chat_type', 'individual')+ chat_type = parameters.get("chat_type", "individual")rpc_params: Dict[str, Any] = {}- if chat_type == 'individual':- phone = parameters.get('phone')+ if chat_type == "individual":+ phone = parameters.get("phone")if not phone:raise ValueError("Phone number is required for individual chats")- rpc_params['phone'] = phone+ rpc_params["phone"] = phoneelse:- group_id = parameters.get('group_id')+ group_id = parameters.get("group_id")if not group_id:raise ValueError("Group ID is required for group chats")- rpc_params['group_id'] = group_id+ rpc_params["group_id"] = group_id- group_filter = parameters.get('group_filter', 'all')- if group_filter == 'contact':- sender_phone = parameters.get('sender_phone')+ group_filter = parameters.get("group_filter", "all")+ if group_filter == "contact":+ sender_phone = parameters.get("sender_phone")if sender_phone:- rpc_params['sender_phone'] = sender_phone+ rpc_params["sender_phone"] = sender_phone- message_filter = parameters.get('message_filter', 'all')- rpc_params['text_only'] = message_filter == 'text_only'- rpc_params['limit'] = parameters.get('limit', 50)- rpc_params['offset'] = parameters.get('offset', 0)+ message_filter = parameters.get("message_filter", "all")+ rpc_params["text_only"] = message_filter == "text_only"+ rpc_params["limit"] = parameters.get("limit", 50)+ rpc_params["offset"] = parameters.get("offset", 0)data = await handler(rpc_params)- if not data.get('success', False):- raise Exception(data.get('error', 'Failed to retrieve chat history'))+ if not data.get("success", False):+ raise Exception(data.get("error", "Failed to retrieve chat history"))- messages = data.get('messages', [])- base_offset = rpc_params.get('offset', 0)+ messages = data.get("messages", [])+ base_offset = rpc_params.get("offset", 0)for i, msg in enumerate(messages):- msg['index'] = base_offset + i + 1+ msg["index"] = base_offset + i + 1# Enrich with media data if requested- if parameters.get('include_media_data') and rpc_call and messages:+ if parameters.get("include_media_data") and rpc_call and messages:await _enrich_messages_with_media(messages, rpc_call)return {@@ -397,41 +377,38 @@ async def _handle_chat_history(node_id: str, parameters: Dict[str, Any], start_t"result": {"operation": "chat_history","messages": messages,- "total": data.get('total', 0),- "has_more": data.get('has_more', False),+ "total": data.get("total", 0),+ "has_more": data.get("has_more", False),"count": len(messages),"chat_type": chat_type,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_search_groups(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle search_groups operation."""- query = parameters.get('query', '')- limit = parameters.get('limit', 20) # Default limit to prevent context overflow- data = await rpc_call('groups', {})+ query = parameters.get("query", "")+ limit = parameters.get("limit", 20) # Default limit to prevent context overflow+ data = await rpc_call("groups", {})- if not data.get('success', True):- raise Exception(data.get('error', 'Failed to get groups'))+ if not data.get("success", True):+ raise Exception(data.get("error", "Failed to get groups"))- groups = data if isinstance(data, list) else data.get('result', [])+ groups = data if isinstance(data, list) else data.get("result", [])# Filter by query if providedif query:query_lower = query.lower()- groups = [g for g in groups if query_lower in g.get('name', '').lower()]+ groups = [g for g in groups if query_lower in g.get("name", "").lower()]total_found = len(groups)# Apply limit to prevent context overflow (51 groups * ~4KB = 200KB+ tokens)# Only return essential fields: jid and name- groups_limited = [- {"jid": g.get("jid", ""), "name": g.get("name", "")}- for g in groups[:limit]- ]+ groups_limited = [{"jid": g.get("jid", ""), "name": g.get("name", "")} for g in groups[:limit]]return {"success": True,@@ -444,31 +421,33 @@ async def _handle_search_groups(node_id: str, parameters: Dict[str, Any], start_"returned": len(groups_limited),"has_more": total_found > limit,"query": query,- "hint": f"Showing {len(groups_limited)} of {total_found} groups. Use a more specific query or get_group_info for details." if total_found > limit else None,- "timestamp": datetime.now().isoformat()+ "hint": f"Showing {len(groups_limited)} of {total_found} groups. Use a more specific query or get_group_info for details."+ if total_found > limit+ else None,+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_get_group_info(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle get_group_info operation."""- group_id = parameters.get('group_id_for_info') or parameters.get('group_id')+ group_id = parameters.get("group_id_for_info") or parameters.get("group_id")if not group_id:raise ValueError("Group ID is required")- participant_limit = parameters.get('participant_limit', 50) # Limit participants to prevent overflow+ participant_limit = parameters.get("participant_limit", 50) # Limit participants to prevent overflow- data = await rpc_call('group_info', {'group_id': group_id})+ data = await rpc_call("group_info", {"group_id": group_id})- if not data.get('success', True) if isinstance(data, dict) else True:- raise Exception(data.get('error', 'Failed to get group info') if isinstance(data, dict) else 'Failed')+ if not data.get("success", True) if isinstance(data, dict) else True:+ raise Exception(data.get("error", "Failed to get group info") if isinstance(data, dict) else "Failed")- result = data if not isinstance(data, dict) or 'result' not in data else data.get('result', data)+ result = data if not isinstance(data, dict) or "result" not in data else data.get("result", data)# Limit participants and return only essential fields- participants = result.get('participants', [])+ participants = result.get("participants", [])total_participants = len(participants)participants_limited = [{"phone": p.get("phone", ""), "name": p.get("name", ""), "is_admin": p.get("is_admin", False)}@@ -491,63 +470,52 @@ async def _handle_get_group_info(node_id: str, parameters: Dict[str, Any], start"success": True,"node_id": node_id,"node_type": "whatsappDb",- "result": {- "operation": "get_group_info",- **limited_result,- "timestamp": datetime.now().isoformat()- },+ "result": {"operation": "get_group_info", **limited_result, "timestamp": datetime.now().isoformat()},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_get_contact_info(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle get_contact_info operation."""- phone = parameters.get('contact_phone') or parameters.get('phone')+ phone = parameters.get("contact_phone") or parameters.get("phone")if not phone:raise ValueError("Phone number is required")- data = await rpc_call('contact_info', {'phone': phone})+ data = await rpc_call("contact_info", {"phone": phone})- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to get contact info'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to get contact info"))- result = data if not isinstance(data, dict) or 'result' not in data else data.get('result', data)+ result = data if not isinstance(data, dict) or "result" not in data else data.get("result", data)return {"success": True,"node_id": node_id,"node_type": "whatsappDb",- "result": {- "operation": "get_contact_info",- **result,- "timestamp": datetime.now().isoformat()- },+ "result": {"operation": "get_contact_info", **result, "timestamp": datetime.now().isoformat()},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_list_contacts(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle list_contacts operation."""- query = parameters.get('query', '')- limit = parameters.get('limit', 50) # Default limit to prevent context overflow+ query = parameters.get("query", "")+ limit = parameters.get("limit", 50) # Default limit to prevent context overflow- data = await rpc_call('contacts', {'query': query})+ data = await rpc_call("contacts", {"query": query})- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to list contacts'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to list contacts"))- result = data if not isinstance(data, dict) or 'result' not in data else data.get('result', data)- contacts = result.get('contacts', []) if isinstance(result, dict) else result+ result = data if not isinstance(data, dict) or "result" not in data else data.get("result", data)+ contacts = result.get("contacts", []) if isinstance(result, dict) else resulttotal_found = len(contacts)# Apply limit and return only essential fields: phone, name, jid- contacts_limited = [- {"phone": c.get("phone", ""), "name": c.get("name", ""), "jid": c.get("jid", "")}- for c in contacts[:limit]- ]+ contacts_limited = [{"phone": c.get("phone", ""), "name": c.get("name", ""), "jid": c.get("jid", "")} for c in contacts[:limit]]return {"success": True,@@ -560,64 +528,61 @@ async def _handle_list_contacts(node_id: str, parameters: Dict[str, Any], start_"returned": len(contacts_limited),"has_more": total_found > limit,"query": query,- "hint": f"Showing {len(contacts_limited)} of {total_found} contacts. Use a more specific query to narrow results." if total_found > limit else None,- "timestamp": datetime.now().isoformat()+ "hint": f"Showing {len(contacts_limited)} of {total_found} contacts. Use a more specific query to narrow results."+ if total_found > limit+ else None,+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_check_contacts(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle check_contacts operation."""- phones_str = parameters.get('phones', '')+ phones_str = parameters.get("phones", "")if not phones_str:raise ValueError("Phone numbers are required")# Parse comma-separated phones- phones = [p.strip() for p in phones_str.split(',') if p.strip()]+ phones = [p.strip() for p in phones_str.split(",") if p.strip()]if not phones:raise ValueError("At least one phone number is required")- data = await rpc_call('contact_check', {'phones': phones})+ data = await rpc_call("contact_check", {"phones": phones})- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to check contacts'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to check contacts"))- results = data if isinstance(data, list) else data.get('result', [])+ results = data if isinstance(data, list) else data.get("result", [])return {"success": True,"node_id": node_id,"node_type": "whatsappDb",- "result": {- "operation": "check_contacts",- "results": results,- "total": len(results),- "timestamp": datetime.now().isoformat()- },+ "result": {"operation": "check_contacts", "results": results, "total": len(results), "timestamp": datetime.now().isoformat()},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_contact_profile_pic(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle contact_profile_pic operation - get profile picture for a contact/group."""- jid = parameters.get('profile_pic_jid') or parameters.get('phone')+ jid = parameters.get("profile_pic_jid") or parameters.get("phone")if not jid:raise ValueError("JID or phone number is required")- rpc_params: Dict[str, Any] = {'jid': jid}- preview = parameters.get('preview', False)+ rpc_params: Dict[str, Any] = {"jid": jid}+ preview = parameters.get("preview", False)if preview:- rpc_params['preview'] = True+ rpc_params["preview"] = True- data = await rpc_call('contact_profile_pic', rpc_params)+ data = await rpc_call("contact_profile_pic", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to get profile picture'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to get profile picture"))- result = data if not isinstance(data, dict) or 'result' not in data else data.get('result', data)+ result = data if not isinstance(data, dict) or "result" not in data else data.get("result", data)return {"success": True,@@ -626,34 +591,33 @@ async def _handle_contact_profile_pic(node_id: str, parameters: Dict[str, Any],"result": {"operation": "contact_profile_pic",**(result if isinstance(result, dict) else {"url": result}),- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_list_channels(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle list_channels operation - list subscribed newsletter channels."""- refresh = parameters.get('refresh', False)- limit = parameters.get('limit', 20)+ refresh = parameters.get("refresh", False)+ limit = parameters.get("limit", 20)rpc_params: Dict[str, Any] = {}if refresh:- rpc_params['refresh'] = True+ rpc_params["refresh"] = True- data = await rpc_call('newsletters', rpc_params)+ data = await rpc_call("newsletters", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to list channels'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to list channels"))- channels = data if isinstance(data, list) else data.get('result', [])+ channels = data if isinstance(data, list) else data.get("result", [])total_found = len(channels)# Return essential fields onlychannels_limited = [- {"jid": c.get("jid", ""), "name": c.get("name", ""), "subscriber_count": c.get("subscriber_count", 0)}- for c in channels[:limit]+ {"jid": c.get("jid", ""), "name": c.get("name", ""), "subscriber_count": c.get("subscriber_count", 0)} for c in channels[:limit]]return {@@ -667,41 +631,37 @@ async def _handle_list_channels(node_id: str, parameters: Dict[str, Any], start_"returned": len(channels_limited),"has_more": total_found > limit,"hint": f"Showing {len(channels_limited)} of {total_found} channels." if total_found > limit else None,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_get_channel_info(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle get_channel_info operation - get channel details."""- channel_jid = parameters.get('channel_jid')+ channel_jid = parameters.get("channel_jid")if not channel_jid:raise ValueError("Channel JID is required")rpc_params: Dict[str, Any] = _resolve_channel_identifier(channel_jid)- if parameters.get('refresh'):- rpc_params['refresh'] = True+ if parameters.get("refresh"):+ rpc_params["refresh"] = True- data = await rpc_call('newsletter_info', rpc_params)+ data = await rpc_call("newsletter_info", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to get channel info'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to get channel info"))- result = data if not isinstance(data, dict) or 'result' not in data else data.get('result', data)+ result = data if not isinstance(data, dict) or "result" not in data else data.get("result", data)return {"success": True,"node_id": node_id,"node_type": "whatsappDb",- "result": {- "operation": "get_channel_info",- **result,- "timestamp": datetime.now().isoformat()- },+ "result": {"operation": "get_channel_info", **result, "timestamp": datetime.now().isoformat()},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}@@ -711,53 +671,53 @@ async def _handle_channel_messages(node_id: str, parameters: Dict[str, Any], staSchema params (newsletter_messages RPC):jid (required), count, offset, before, since, until, media_type, search, refresh"""- channel_jid = parameters.get('channel_jid')+ channel_jid = parameters.get("channel_jid")jid = await _resolve_to_jid(channel_jid, rpc_call)- count = parameters.get('channel_count', 20)- rpc_params: Dict[str, Any] = {'jid': jid, 'count': count}+ count = parameters.get("channel_count", 20)+ rpc_params: Dict[str, Any] = {"jid": jid, "count": count}- before_server_id = parameters.get('before_server_id')+ before_server_id = parameters.get("before_server_id")if before_server_id:- rpc_params['before'] = int(before_server_id)+ rpc_params["before"] = int(before_server_id)# Pagination offset- msg_offset = parameters.get('message_offset')+ msg_offset = parameters.get("message_offset")if msg_offset:- rpc_params['offset'] = int(msg_offset)+ rpc_params["offset"] = int(msg_offset)# Date range filters (unix timestamps as strings)- since = parameters.get('since')+ since = parameters.get("since")if since:- rpc_params['since'] = str(since)+ rpc_params["since"] = str(since)- until = parameters.get('until')+ until = parameters.get("until")if until:- rpc_params['until'] = str(until)+ rpc_params["until"] = str(until)# Media type filter- media_type = parameters.get('media_type')- if media_type and media_type != 'all':- rpc_params['media_type'] = media_type+ media_type = parameters.get("media_type")+ if media_type and media_type != "all":+ rpc_params["media_type"] = media_type# Text search- search = parameters.get('search')+ search = parameters.get("search")if search:- rpc_params['search'] = search+ rpc_params["search"] = search# Force refresh bypassing cache- if parameters.get('refresh'):- rpc_params['refresh'] = True+ if parameters.get("refresh"):+ rpc_params["refresh"] = True- data = await rpc_call('newsletter_messages', rpc_params)+ data = await rpc_call("newsletter_messages", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to get channel messages'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to get channel messages"))- messages = data if isinstance(data, list) else data.get('result', [])+ messages = data if isinstance(data, list) else data.get("result", [])# Enrich with media data if requested- if parameters.get('include_media_data') and messages:+ if parameters.get("include_media_data") and messages:await _enrich_messages_with_media(messages, rpc_call)return {@@ -769,53 +729,48 @@ async def _handle_channel_messages(node_id: str, parameters: Dict[str, Any], sta"messages": messages,"count": len(messages),"channel_jid": channel_jid,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_channel_stats(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle channel_stats operation - get channel subscriber/view stats."""- channel_jid = parameters.get('channel_jid')+ channel_jid = parameters.get("channel_jid")if not channel_jid:raise ValueError("Channel JID is required")- count = parameters.get('channel_count', 10)- rpc_params: Dict[str, Any] = {**_resolve_channel_identifier(channel_jid), 'count': count}+ count = parameters.get("channel_count", 10)+ rpc_params: Dict[str, Any] = {**_resolve_channel_identifier(channel_jid), "count": count}- data = await rpc_call('newsletter_stats', rpc_params)+ data = await rpc_call("newsletter_stats", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to get channel stats'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to get channel stats"))- result = data if not isinstance(data, dict) or 'result' not in data else data.get('result', data)+ result = data if not isinstance(data, dict) or "result" not in data else data.get("result", data)return {"success": True,"node_id": node_id,"node_type": "whatsappDb",- "result": {- "operation": "channel_stats",- **result,- "channel_jid": channel_jid,- "timestamp": datetime.now().isoformat()- },+ "result": {"operation": "channel_stats", **result, "channel_jid": channel_jid, "timestamp": datetime.now().isoformat()},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_channel_follow(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle channel_follow operation - follow/subscribe to a channel."""- channel_jid = parameters.get('channel_jid')+ channel_jid = parameters.get("channel_jid")jid = await _resolve_to_jid(channel_jid, rpc_call)- data = await rpc_call('newsletter_follow', {'jid': jid})+ data = await rpc_call("newsletter_follow", {"jid": jid})- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to follow channel'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to follow channel"))return {"success": True,@@ -825,22 +780,22 @@ async def _handle_channel_follow(node_id: str, parameters: Dict[str, Any], start"operation": "channel_follow","channel_jid": channel_jid,"status": "followed",- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_channel_unfollow(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle channel_unfollow operation - unfollow/unsubscribe from a channel."""- channel_jid = parameters.get('channel_jid')+ channel_jid = parameters.get("channel_jid")jid = await _resolve_to_jid(channel_jid, rpc_call)- data = await rpc_call('newsletter_unfollow', {'jid': jid})+ data = await rpc_call("newsletter_unfollow", {"jid": jid})- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to unfollow channel'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to unfollow channel"))return {"success": True,@@ -850,60 +805,56 @@ async def _handle_channel_unfollow(node_id: str, parameters: Dict[str, Any], sta"operation": "channel_unfollow","channel_jid": channel_jid,"status": "unfollowed",- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_channel_create(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle channel_create operation - create a new newsletter channel."""- channel_name = parameters.get('channel_name')+ channel_name = parameters.get("channel_name")if not channel_name:raise ValueError("Channel name is required")- rpc_params: Dict[str, Any] = {'name': channel_name}- description = parameters.get('channel_description')+ rpc_params: Dict[str, Any] = {"name": channel_name}+ description = parameters.get("channel_description")if description:- rpc_params['description'] = description- picture = parameters.get('picture')+ rpc_params["description"] = description+ picture = parameters.get("picture")if picture:- rpc_params['picture'] = picture+ rpc_params["picture"] = picture- data = await rpc_call('newsletter_create', rpc_params)+ data = await rpc_call("newsletter_create", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to create channel'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to create channel"))- result = data if not isinstance(data, dict) or 'result' not in data else data.get('result', data)+ result = data if not isinstance(data, dict) or "result" not in data else data.get("result", data)return {"success": True,"node_id": node_id,"node_type": "whatsappDb",- "result": {- "operation": "channel_create",- **result,- "timestamp": datetime.now().isoformat()- },+ "result": {"operation": "channel_create", **result, "timestamp": datetime.now().isoformat()},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_channel_mute(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle channel_mute operation - mute/unmute a newsletter channel."""- channel_jid = parameters.get('channel_jid')+ channel_jid = parameters.get("channel_jid")jid = await _resolve_to_jid(channel_jid, rpc_call)- mute = parameters.get('mute', True)- rpc_params = {'jid': jid, 'mute': bool(mute)}+ mute = parameters.get("mute", True)+ rpc_params = {"jid": jid, "mute": bool(mute)}- data = await rpc_call('newsletter_mute', rpc_params)+ data = await rpc_call("newsletter_mute", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to mute/unmute channel'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to mute/unmute channel"))return {"success": True,@@ -914,32 +865,32 @@ async def _handle_channel_mute(node_id: str, parameters: Dict[str, Any], start_t"channel_jid": channel_jid,"muted": mute,"status": "muted" if mute else "unmuted",- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_channel_mark_viewed(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle channel_mark_viewed operation - mark channel messages as viewed."""- channel_jid = parameters.get('channel_jid')+ channel_jid = parameters.get("channel_jid")jid = await _resolve_to_jid(channel_jid, rpc_call)- server_ids_raw = parameters.get('server_ids', '')+ server_ids_raw = parameters.get("server_ids", "")if not server_ids_raw:raise ValueError("server_ids is required (comma-separated message IDs)")- server_ids = [int(sid.strip()) for sid in str(server_ids_raw).split(',') if sid.strip()]+ server_ids = [int(sid.strip()) for sid in str(server_ids_raw).split(",") if sid.strip()]if not server_ids:raise ValueError("At least one server_id is required")- rpc_params = {'jid': jid, 'server_ids': server_ids}+ rpc_params = {"jid": jid, "server_ids": server_ids}- data = await rpc_call('newsletter_mark_viewed', rpc_params)+ data = await rpc_call("newsletter_mark_viewed", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to mark channel as viewed'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to mark channel as viewed"))return {"success": True,@@ -948,36 +899,32 @@ async def _handle_channel_mark_viewed(node_id: str, parameters: Dict[str, Any],"result": {"operation": "channel_mark_viewed","channel_jid": channel_jid,- "server_ids": ','.join(str(s) for s in server_ids),+ "server_ids": ",".join(str(s) for s in server_ids),"status": "marked_viewed",- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_newsletter_react(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle newsletter_react operation - react to a channel message."""- channel_jid = parameters.get('channel_jid')+ channel_jid = parameters.get("channel_jid")jid = await _resolve_to_jid(channel_jid, rpc_call)- server_id = parameters.get('react_server_id')+ server_id = parameters.get("react_server_id")if not server_id:raise ValueError("Message server ID is required")- reaction = parameters.get('reaction', '')+ reaction = parameters.get("reaction", "")- rpc_params: Dict[str, Any] = {- 'jid': jid,- 'server_id': int(server_id),- 'reaction': reaction- }+ rpc_params: Dict[str, Any] = {"jid": jid, "server_id": int(server_id), "reaction": reaction}- data = await rpc_call('newsletter_react', rpc_params)+ data = await rpc_call("newsletter_react", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to react to channel message'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to react to channel message"))return {"success": True,@@ -988,34 +935,34 @@ async def _handle_newsletter_react(node_id: str, parameters: Dict[str, Any], sta"channel_jid": channel_jid,"server_id": int(server_id),"reaction": reaction,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _handle_newsletter_live_updates(node_id: str, parameters: Dict[str, Any], start_time: float, rpc_call) -> Dict[str, Any]:"""Handle newsletter_live_updates operation - subscribe to live view/reaction counts."""- channel_jid = parameters.get('channel_jid')+ channel_jid = parameters.get("channel_jid")jid = await _resolve_to_jid(channel_jid, rpc_call)- server_ids_raw = parameters.get('server_ids', '')+ server_ids_raw = parameters.get("server_ids", "")if not server_ids_raw:raise ValueError("server_ids is required (comma-separated message IDs)")- server_ids = [int(sid.strip()) for sid in str(server_ids_raw).split(',') if sid.strip()]+ server_ids = [int(sid.strip()) for sid in str(server_ids_raw).split(",") if sid.strip()]if not server_ids:raise ValueError("At least one server_id is required")- rpc_params = {'jid': jid, 'server_ids': server_ids}+ rpc_params = {"jid": jid, "server_ids": server_ids}- data = await rpc_call('newsletter_live_updates', rpc_params)+ data = await rpc_call("newsletter_live_updates", rpc_params)- if isinstance(data, dict) and not data.get('success', True):- raise Exception(data.get('error', 'Failed to subscribe to live updates'))+ if isinstance(data, dict) and not data.get("success", True):+ raise Exception(data.get("error", "Failed to subscribe to live updates"))- result = data if not isinstance(data, dict) or 'result' not in data else data.get('result', data)+ result = data if not isinstance(data, dict) or "result" not in data else data.get("result", data)return {"success": True,@@ -1025,10 +972,8 @@ async def _handle_newsletter_live_updates(node_id: str, parameters: Dict[str, An"operation": "newsletter_live_updates","channel_jid": channel_jid,**(result if isinstance(result, dict) else {}),- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),},"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}--diff --git a/server/nodes/whatsapp/_events.py b/server/nodes/whatsapp/_events.pyindex 1dd78d52..3b8d965d 100644--- a/server/nodes/whatsapp/_events.py+++ b/server/nodes/whatsapp/_events.py@@ -70,11 +70,7 @@ def whatsapp_connection_status(FE can route per-device updates."""return WorkflowEvent(source="machinaos://nodes/whatsapp",- type=(- "com.machinaos.whatsapp.connection.opened"- if connected- else "com.machinaos.whatsapp.connection.closed"- ),+ type=("com.machinaos.whatsapp.connection.opened" if connected else "com.machinaos.whatsapp.connection.closed"),subject=device_id,data={"connected": connected,@@ -94,11 +90,7 @@ def whatsapp_message_event("""Message envelope (sent or received). Subject auto-extractedfrom the params payload (chat_id / sender / from)."""payload = dict(params)- subject = (- payload.get("chat_id")- or payload.get("sender")- or payload.get("from")- )+ subject = payload.get("chat_id") or payload.get("sender") or payload.get("from")return WorkflowEvent(source="machinaos://nodes/whatsapp",type=f"com.machinaos.whatsapp.message.{direction}",@@ -178,10 +170,12 @@ async def broadcast_whatsapp_status(device_id=device_id,qr=qr,)- await broadcaster.broadcast({- "type": _STATUS_TYPED_WIRE_KEY,- "data": event.model_dump(mode="json"),- })+ await broadcaster.broadcast(+ {+ "type": _STATUS_TYPED_WIRE_KEY,+ "data": event.model_dump(mode="json"),+ }+ )async def broadcast_whatsapp_message(@@ -213,20 +207,24 @@ async def broadcast_whatsapp_message(# migrates to envelope-shape (Wave 12 D4 follow-up).from services.events.dispatch import emit- await broadcaster.broadcast({- "type": _MESSAGE_RECEIVED_WIRE_KEY,- "data": payload,- })+ await broadcaster.broadcast(+ {+ "type": _MESSAGE_RECEIVED_WIRE_KEY,+ "data": payload,+ }+ )await emit(whatsapp_message_event("received", payload),wire_routing_key=_MESSAGE_RECEIVED_WIRE_KEY,)else:# Outbound observation only — direct legacy raw broadcast.- await broadcaster.broadcast({- "type": _MESSAGE_SENT_WIRE_KEY,- "data": payload,- })+ await broadcaster.broadcast(+ {+ "type": _MESSAGE_SENT_WIRE_KEY,+ "data": payload,+ }+ )async def broadcast_whatsapp_newsletter(@@ -243,10 +241,12 @@ async def broadcast_whatsapp_newsletter(from services.status_broadcaster import get_status_broadcasterbroadcaster = get_status_broadcaster()- await broadcaster.broadcast({- "type": _NEWSLETTER_WIRE_KEYS[verb],- "data": dict(params),- })+ await broadcaster.broadcast(+ {+ "type": _NEWSLETTER_WIRE_KEYS[verb],+ "data": dict(params),+ }+ )async def broadcast_whatsapp_history_synced(params: Mapping[str, Any]) -> None:@@ -257,10 +257,12 @@ async def broadcast_whatsapp_history_synced(params: Mapping[str, Any]) -> None:from services.status_broadcaster import get_status_broadcasterbroadcaster = get_status_broadcaster()- await broadcaster.broadcast({- "type": _HISTORY_SYNCED_WIRE_KEY,- "data": dict(params),- })+ await broadcaster.broadcast(+ {+ "type": _HISTORY_SYNCED_WIRE_KEY,+ "data": dict(params),+ }+ )__all__ = [diff --git a/server/nodes/whatsapp/_filters.py b/server/nodes/whatsapp/_filters.pyindex 6ced9feb..479894d4 100644--- a/server/nodes/whatsapp/_filters.py+++ b/server/nodes/whatsapp/_filters.py@@ -40,66 +40,65 @@ def build_filter(params: Dict) -> Callable[[Dict], bool]:- ``group_info`` -- present for group messages, with ``group_jid``/ ``sender_jid`` / ``sender_phone`` / ``sender_name``"""- msg_type = params.get('message_type_filter', 'all')- sender_filter = params.get('filter', 'all')- contact_phone = params.get('phone_number', '')- group_id = params.get('group_id', '')- sender_number = params.get('sender_number', '')- keywords = [- k.strip().lower()- for k in params.get('keywords', '').split(',')- if k.strip()- ]- ignore_own = params.get('ignore_own_messages', True)- forwarded_filter = params.get('forwarded_filter', 'all')+ msg_type = params.get("message_type_filter", "all")+ sender_filter = params.get("filter", "all")+ contact_phone = params.get("phone_number", "")+ group_id = params.get("group_id", "")+ sender_number = params.get("sender_number", "")+ keywords = [k.strip().lower() for k in params.get("keywords", "").split(",") if k.strip()]+ ignore_own = params.get("ignore_own_messages", True)+ forwarded_filter = params.get("forwarded_filter", "all")logger.debug("[WhatsAppFilter] Built: type=%s, filter=%s, group_id=%r, forwarded=%s",- msg_type, sender_filter, group_id, forwarded_filter,+ msg_type,+ sender_filter,+ group_id,+ forwarded_filter,)def matches(m: Dict) -> bool:- msg_chat_id = m.get('chat_id', '')- is_group = m.get('is_group', False)- group_info = m.get('group_info', {})+ msg_chat_id = m.get("chat_id", "")+ is_group = m.get("is_group", False)+ group_info = m.get("group_info", {})# Use sender_phone directly -- Go RPC already resolves LIDs.# For group messages, prefer group_info.sender_phone, fall back# to root sender_phone.if is_group:- sender_phone = group_info.get('sender_phone', '') or m.get('sender_phone', '')+ sender_phone = group_info.get("sender_phone", "") or m.get("sender_phone", "")else:- sender_phone = m.get('sender_phone', '')+ sender_phone = m.get("sender_phone", "")# Fallback: extract phone from sender JID if sender_phone absent.if not sender_phone:- sender = m.get('sender', '')- sender_phone = sender.split('@')[0] if '@' in sender else sender+ sender = m.get("sender", "")+ sender_phone = sender.split("@")[0] if "@" in sender else sender# Message type filter (schema field: message_type).- if msg_type != 'all' and m.get('message_type') != msg_type:+ if msg_type != "all" and m.get("message_type") != msg_type:return False# Sender filter -- for ``contact`` filter, use actual phone.- if sender_filter == 'self':+ if sender_filter == "self":# Self-chat (notes-to-self) only -- must be from me AND in# a chat with myself.- if not m.get('is_from_me'):+ if not m.get("is_from_me"):return False- chat_id = m.get('chat_id', '')- sender = m.get('sender', '')+ chat_id = m.get("chat_id", "")+ sender = m.get("sender", "")if chat_id != sender:return False- if sender_filter == 'any_contact':+ if sender_filter == "any_contact":if is_group:return False- if sender_filter == 'contact':+ if sender_filter == "contact":if contact_phone not in sender_phone:return False- if sender_filter == 'group':+ if sender_filter == "group":if not is_group:return Falseif msg_chat_id != group_id:@@ -109,26 +108,26 @@ def build_filter(params: Dict) -> Callable[[Dict], bool]:if sender_number not in sender_phone:return False- if sender_filter == 'channel':- if not msg_chat_id.endswith('@newsletter'):+ if sender_filter == "channel":+ if not msg_chat_id.endswith("@newsletter"):return False- channel_jid = params.get('channel_jid', '')+ channel_jid = params.get("channel_jid", "")if channel_jid and msg_chat_id != channel_jid:return False- if sender_filter == 'keywords':- text = (m.get('text') or '').lower()+ if sender_filter == "keywords":+ text = (m.get("text") or "").lower()if not any(kw in text for kw in keywords):return False# Ignore own messages -- but not when filtering for ``self``.- if ignore_own and sender_filter != 'self' and m.get('is_from_me'):+ if ignore_own and sender_filter != "self" and m.get("is_from_me"):return False- is_forwarded = m.get('is_forwarded', False)- if forwarded_filter == 'only_forwarded' and not is_forwarded:+ is_forwarded = m.get("is_forwarded", False)+ if forwarded_filter == "only_forwarded" and not is_forwarded:return False- if forwarded_filter == 'ignore_forwarded' and is_forwarded:+ if forwarded_filter == "ignore_forwarded" and is_forwarded:return Falselogger.debug("[WhatsAppFilter] Matched message from %s", sender_phone)diff --git a/server/nodes/whatsapp/_handlers.py b/server/nodes/whatsapp/_handlers.pyindex cd1dfc9f..9cff904d 100644--- a/server/nodes/whatsapp/_handlers.py+++ b/server/nodes/whatsapp/_handlers.py@@ -80,6 +80,7 @@ async def handle_whatsapp_chat_history(data: Dict[str, Any], websocket: WebSocke# ---- Rate-limit RPC passthroughs ----+async def handle_whatsapp_rate_limit_get(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Get rate-limit config and current stats."""return await _wa_rpc_call("rate_limit_get", {})@@ -102,6 +103,7 @@ async def handle_whatsapp_rate_limit_unpause(data: Dict[str, Any], websocket: We# ---- Lightweight RPC passthroughs ----+async def handle_whatsapp_mark_read(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Mark messages as read. Schema: mark_read({message_ids, chat_jid, sender_jid?})."""message_ids = data.get("message_ids", [])diff --git a/server/nodes/whatsapp/_option_loaders.py b/server/nodes/whatsapp/_option_loaders.pyindex 6f7c64b8..7f7ffa6a 100644--- a/server/nodes/whatsapp/_option_loaders.py+++ b/server/nodes/whatsapp/_option_loaders.py@@ -56,9 +56,7 @@ async def load_group_members(params: Dict[str, Any]) -> List[Dict[str, Any]]:if not group_id:return []response = await handle_whatsapp_group_info(group_id)- participants = (- response.get("participants", []) if isinstance(response, dict) else []- )+ participants = response.get("participants", []) if isinstance(response, dict) else []return [{"value": p.get("phone") or p.get("jid") or "",diff --git a/server/nodes/whatsapp/_refresh.py b/server/nodes/whatsapp/_refresh.pyindex 6b1fa9f8..5741ea62 100644--- a/server/nodes/whatsapp/_refresh.py+++ b/server/nodes/whatsapp/_refresh.py@@ -54,6 +54,4 @@ async def refresh_whatsapp_status(broadcaster: "StatusBroadcaster") -> None:span.set_attribute("connected", bool(status_data.get("connected", False)))except Exception as exc: # noqa: BLE001span.record_exception(exc)- logger.debug(- "[StatusBroadcaster] Could not refresh WhatsApp status: %s", exc- )+ logger.debug("[StatusBroadcaster] Could not refresh WhatsApp status: %s", exc)diff --git a/server/nodes/whatsapp/_service.py b/server/nodes/whatsapp/_service.pyindex 3a2b5ab7..1886a073 100644--- a/server/nodes/whatsapp/_service.py+++ b/server/nodes/whatsapp/_service.py@@ -48,9 +48,9 @@ def extract_phone_from_jid(jid: str | None) -> str | None:if not jid:return None# Remove the @s.whatsapp.net or @c.us suffix- phone_part = jid.split('@')[0]+ phone_part = jid.split("@")[0]# Handle device ID suffix like '1234567890:0'- phone = phone_part.split(':')[0]+ phone = phone_part.split(":")[0]# Return only if it looks like a phone number (digits only)if phone.isdigit():return phone@@ -85,18 +85,17 @@ class RPCClient:# The WebSocket handshake to the Go service can take 2-3s on Windows,# especially on cold start when Defender is scanning the binary.logger.info(f"[WhatsApp RPC] Connecting to {self.url}...")- self.ws = await asyncio.wait_for(- websockets.connect(self.url, ping_interval=30, max_size=100*1024*1024),- timeout=5.0- )+ self.ws = await asyncio.wait_for(websockets.connect(self.url, ping_interval=30, max_size=100 * 1024 * 1024), timeout=5.0)self._connected = Truelogger.info("[WhatsApp RPC] WebSocket connected, starting receive loop")self._task = asyncio.create_task(self._recv())async def close(self):self._connected = False- if self._task: self._task.cancel()- if self.ws: await self.ws.close()+ if self._task:+ self._task.cancel()+ if self.ws:+ await self.ws.close()async def _recv(self):try:@@ -286,6 +285,7 @@ class RPCClient:finally:self.pending.pop(req_id, None)+_client: Optional[RPCClient] = None_lock = asyncio.Lock()_send_lock = asyncio.Lock() # Serialize sends - Go service processes sequentially@@ -310,6 +310,7 @@ async def get_client(force_reconnect: bool = False) -> RPCClient:# under <data_dir>/whatsapp/ instead of the pnpm package directory.# Idempotent: no-op if already running or disabled via settings.from nodes.whatsapp import get_whatsapp_runtime+try:# `start()` is idempotent (BaseSupervisor takes a lock and no-ops# if already running) so calling it from every get_client() is safe.@@ -352,6 +353,7 @@ async def get_client(force_reconnect: bool = False) -> RPCClient:# WebSocket Handlers - used by websocket.py# ============================================================================+async def handle_whatsapp_status() -> dict:"""Get WhatsApp connection status via direct RPC and broadcast to all clients."""try:@@ -379,19 +381,13 @@ async def handle_whatsapp_status() -> dict:"connected": status_data.get("connected", False),"device_id": device_id,"connected_phone": connected_phone,- "timestamp": time.time()+ "timestamp": time.time(),}except Exception as e:logger.error(f"WhatsApp status check failed: {e}")# Return error response immediately - don't broadcast here to avoid race conditions# The client will update its local state based on the error response- return {- "success": False,- "error": str(e),- "connected": False,- "running": False,- "timestamp": time.time()- }+ return {"success": False, "error": str(e), "connected": False, "running": False, "timestamp": time.time()}async def handle_whatsapp_connected_phone() -> dict:@@ -405,30 +401,15 @@ async def handle_whatsapp_connected_phone() -> dict:status_data = await client.call("status")if not status_data.get("connected"):- return {- "success": False,- "error": "WhatsApp not connected",- "connected_phone": None,- "timestamp": time.time()- }+ return {"success": False, "error": "WhatsApp not connected", "connected_phone": None, "timestamp": time.time()}device_id = status_data.get("device_id")connected_phone = extract_phone_from_jid(device_id)- return {- "success": True,- "connected_phone": connected_phone,- "device_id": device_id,- "timestamp": time.time()- }+ return {"success": True, "connected_phone": connected_phone, "device_id": device_id, "timestamp": time.time()}except Exception as e:logger.error(f"WhatsApp connected phone check failed: {e}")- return {- "success": False,- "error": str(e),- "connected_phone": None,- "timestamp": time.time()- }+ return {"success": False, "error": str(e), "connected_phone": None, "timestamp": time.time()}async def handle_whatsapp_qr() -> dict:@@ -438,40 +419,17 @@ async def handle_whatsapp_qr() -> dict:status = await client.call("status")if status.get("connected") and status.get("has_session"):- return {- "success": True,- "connected": True,- "message": "Already connected with active session",- "timestamp": time.time()- }+ return {"success": True, "connected": True, "message": "Already connected with active session", "timestamp": time.time()}try:result = await client.call("qr")code = result.get("code")if code:qr_image = qr_code_to_base64(code)- return {- "success": True,- "connected": False,- "qr": qr_image,- "message": "QR code available",- "timestamp": time.time()- }- return {- "success": True,- "connected": False,- "qr": None,- "message": "No QR code available",- "timestamp": time.time()- }+ return {"success": True, "connected": False, "qr": qr_image, "message": "QR code available", "timestamp": time.time()}+ return {"success": True, "connected": False, "qr": None, "message": "No QR code available", "timestamp": time.time()}except Exception as qr_err:- return {- "success": True,- "connected": False,- "qr": None,- "message": str(qr_err),- "timestamp": time.time()- }+ return {"success": True, "connected": False, "qr": None, "message": str(qr_err), "timestamp": time.time()}except Exception as e:logger.error(f"WhatsApp QR fetch failed: {e}")return {"success": False, "connected": False, "error": str(e)}@@ -561,6 +519,7 @@ async def handle_whatsapp_send(params: dict) -> dict:filename = filename or file_param.get("filename")elif file_param:import base64 as b64+try:with open(file_param, "rb") as f:media_data = b64.b64encode(f.read()).decode("utf-8")@@ -571,6 +530,7 @@ async def handle_whatsapp_send(params: dict) -> dict:if media_url:import httpximport base64 as b64+try:async with httpx.AsyncClient() as http:resp = await http.get(media_url, timeout=30)@@ -581,10 +541,7 @@ async def handle_whatsapp_send(params: dict) -> dict:if not media_data:return {"success": False, "error": f"media data is required for {msg_type} type"}- rpc_params["media_data"] = {- "data": media_data,- "mime_type": mime_type or _guess_mime_type(msg_type)- }+ rpc_params["media_data"] = {"data": media_data, "mime_type": mime_type or _guess_mime_type(msg_type)}if params.get("caption"):rpc_params["media_data"]["caption"] = params["caption"]final_filename = filename or params.get("filename")@@ -614,11 +571,7 @@ async def handle_whatsapp_send(params: dict) -> dict:reply_id = params.get("reply_message_id")reply_sender = params.get("reply_sender")if reply_id and reply_sender:- rpc_params["reply"] = {- "message_id": reply_id,- "sender": reply_sender,- "content": params.get("reply_content", "")- }+ rpc_params["reply"] = {"message_id": reply_id, "sender": reply_sender, "content": params.get("reply_content", "")}if params.get("metadata"):rpc_params["metadata"] = params["metadata"]@@ -627,12 +580,7 @@ async def handle_whatsapp_send(params: dict) -> dict:# Use newsletter_send for channel recipients, regular send for othersrpc_method = "newsletter_send" if recipient_type == "channel" else "send"result = await client.call(rpc_method, rpc_params)- return {- "success": True,- "message_id": result.get("message_id"),- "message_type": msg_type,- "timestamp": time.time()- }+ return {"success": True, "message_id": result.get("message_id"), "message_type": msg_type, "timestamp": time.time()}except Exception as e:logger.error(f"WhatsApp send failed: {e}")return {"success": False, "error": str(e)}@@ -645,7 +593,7 @@ def _guess_mime_type(msg_type: str) -> str:"video": "video/mp4","audio": "audio/ogg","document": "application/octet-stream",- "sticker": "image/webp"+ "sticker": "image/webp",}return defaults.get(msg_type, "application/octet-stream")@@ -668,12 +616,7 @@ async def handle_whatsapp_start() -> dict:qr=None,)- return {- "success": True,- "message": "WhatsApp connection started",- "data": result,- "timestamp": time.time()- }+ return {"success": True, "message": "WhatsApp connection started", "data": result, "timestamp": time.time()}except Exception as e:logger.error(f"WhatsApp start failed: {e}")return {"success": False, "error": str(e)}@@ -704,12 +647,7 @@ async def handle_whatsapp_restart() -> dict:# Call restart RPC methodresult = await client.call("restart")- return {- "success": True,- "message": "WhatsApp connection restarted",- "data": result,- "timestamp": time.time()- }+ return {"success": True, "message": "WhatsApp connection restarted", "data": result, "timestamp": time.time()}except HTTPException as e:logger.error(f"WhatsApp restart failed: {e.detail}")return {"success": False, "error": e.detail}@@ -724,11 +662,7 @@ async def handle_whatsapp_groups() -> dict:client = await get_client()groups = await client.call("groups")- return {- "success": True,- "groups": groups or [],- "timestamp": time.time()- }+ return {"success": True, "groups": groups or [], "timestamp": time.time()}except Exception as e:logger.error(f"WhatsApp groups fetch failed: {e}")return {"success": False, "error": str(e), "groups": []}@@ -755,28 +689,30 @@ async def handle_whatsapp_group_info(group_id: str) -> dict:# Extract participants with phone numbersparticipants = []- for p in result.get('participants', []):- jid = p.get('jid', '')- phone = p.get('phone', '')- name = p.get('name', '')+ for p in result.get("participants", []):+ jid = p.get("jid", "")+ phone = p.get("phone", "")+ name = p.get("name", "")# Only include participants with resolved phone numbersif phone:- participants.append({- "jid": jid,- "phone": phone,- "name": name or phone, # Use phone as fallback name- "is_admin": p.get('is_admin', False),- "is_super_admin": p.get('is_super_admin', False)- })+ participants.append(+ {+ "jid": jid,+ "phone": phone,+ "name": name or phone, # Use phone as fallback name+ "is_admin": p.get("is_admin", False),+ "is_super_admin": p.get("is_super_admin", False),+ }+ )return {"success": True,"group_id": group_id,- "name": result.get('name', ''),+ "name": result.get("name", ""),"participants": participants,"participant_count": len(participants),- "timestamp": time.time()+ "timestamp": time.time(),}except Exception as e:logger.error(f"WhatsApp group_info fetch failed for {group_id}: {e}")@@ -847,7 +783,7 @@ async def handle_whatsapp_chat_history(params: dict) -> dict:"messages": result.get("messages", []),"total": result.get("total", 0),"has_more": result.get("has_more", False),- "timestamp": time.time()+ "timestamp": time.time(),}except Exception as e:logger.error(f"WhatsApp chat_history fetch failed: {e}")@@ -892,11 +828,7 @@ async def handle_whatsapp_newsletters() -> dict:client = await get_client()channels = await client.call("newsletters")- return {- "success": True,- "channels": channels or [],- "timestamp": time.time()- }+ return {"success": True, "channels": channels or [], "timestamp": time.time()}except Exception as e:logger.error(f"WhatsApp newsletters fetch failed: {e}")return {"success": False, "error": str(e), "channels": []}diff --git a/server/nodes/whatsapp/whatsapp_db.py b/server/nodes/whatsapp/whatsapp_db.pyindex fa47205c..06f469e4 100644--- a/server/nodes/whatsapp/whatsapp_db.py+++ b/server/nodes/whatsapp/whatsapp_db.py@@ -21,12 +21,23 @@ class WhatsAppDbParams(BaseModel):"""operation: Literal[- "chat_history", "search_groups", "get_group_info",- "get_contact_info", "list_contacts", "check_contacts",- "list_channels", "get_channel_info", "channel_messages",- "channel_stats", "channel_follow", "channel_unfollow",- "channel_create", "channel_mute", "channel_mark_viewed",- "newsletter_react", "newsletter_live_updates",+ "chat_history",+ "search_groups",+ "get_group_info",+ "get_contact_info",+ "list_contacts",+ "check_contacts",+ "list_channels",+ "get_channel_info",+ "channel_messages",+ "channel_stats",+ "channel_follow",+ "channel_unfollow",+ "channel_create",+ "channel_mute",+ "channel_mark_viewed",+ "newsletter_react",+ "newsletter_live_updates","contact_profile_pic",] = Field(default="chat_history", description="Operation to perform")@@ -42,9 +53,12 @@ class WhatsAppDbParams(BaseModel):default="",description="Contact phone number (no + prefix)",json_schema_extra={- "displayOptions": {"show": {- "operation": ["chat_history"], "chat_type": ["individual"],- }},+ "displayOptions": {+ "show": {+ "operation": ["chat_history"],+ "chat_type": ["individual"],+ }+ },},)group_id: str = Field(@@ -52,30 +66,37 @@ class WhatsAppDbParams(BaseModel):description="Group JID (format: [email protected])",json_schema_extra={"component": "GroupIdSelector",- "displayOptions": {"show": {- "operation": ["chat_history", "get_group_info"],- "chat_type": ["group"],- }},+ "displayOptions": {+ "show": {+ "operation": ["chat_history", "get_group_info"],+ "chat_type": ["group"],+ }+ },},)group_filter: Literal["all", "contact"] = Field(default="all",description="Filter messages in group",json_schema_extra={- "displayOptions": {"show": {- "operation": ["chat_history"], "chat_type": ["group"],- }},+ "displayOptions": {+ "show": {+ "operation": ["chat_history"],+ "chat_type": ["group"],+ }+ },},)sender_phone: str = Field(default="",description="Filter to messages from specific group member",json_schema_extra={- "displayOptions": {"show": {- "operation": ["chat_history"],- "chat_type": ["group"],- "group_filter": ["contact"],- }},+ "displayOptions": {+ "show": {+ "operation": ["chat_history"],+ "chat_type": ["group"],+ "group_filter": ["contact"],+ }+ },},)message_filter: Literal["all", "text_only"] = Field(@@ -86,14 +107,17 @@ class WhatsAppDbParams(BaseModel):},)limit: int = Field(- default=50, ge=1, le=500,+ default=50,+ ge=1,+ le=500,description="Maximum number of messages (1-500)",json_schema_extra={"displayOptions": {"show": {"operation": ["chat_history"]}},},)offset: int = Field(- default=0, ge=0,+ default=0,+ ge=0,description="Number of messages to skip",json_schema_extra={"displayOptions": {"show": {"operation": ["chat_history"]}},@@ -105,9 +129,11 @@ class WhatsAppDbParams(BaseModel):default=False,description="Download base64 media data (may be slow for many messages)",json_schema_extra={- "displayOptions": {"show": {- "operation": ["chat_history", "channel_messages"],- }},+ "displayOptions": {+ "show": {+ "operation": ["chat_history", "channel_messages"],+ }+ },},)@@ -116,9 +142,11 @@ class WhatsAppDbParams(BaseModel):default="",description="Search query (leave empty for all)",json_schema_extra={- "displayOptions": {"show": {- "operation": ["search_groups", "list_contacts"],- }},+ "displayOptions": {+ "show": {+ "operation": ["search_groups", "list_contacts"],+ }+ },},)@@ -155,42 +183,67 @@ class WhatsAppDbParams(BaseModel):description="Newsletter JID or invite link",json_schema_extra={"component": "ChannelJidSelector",- "displayOptions": {"show": {"operation": [- "get_channel_info", "channel_messages", "channel_stats",- "channel_follow", "channel_unfollow", "channel_mute",- "channel_mark_viewed", "newsletter_react", "newsletter_live_updates",- ]}},+ "displayOptions": {+ "show": {+ "operation": [+ "get_channel_info",+ "channel_messages",+ "channel_stats",+ "channel_follow",+ "channel_unfollow",+ "channel_mute",+ "channel_mark_viewed",+ "newsletter_react",+ "newsletter_live_updates",+ ]+ }+ },},)refresh: bool = Field(default=False,description="Bypass 24h cache and fetch fresh data",json_schema_extra={- "displayOptions": {"show": {"operation": [- "list_channels", "get_channel_info", "channel_messages",- ]}},+ "displayOptions": {+ "show": {+ "operation": [+ "list_channels",+ "get_channel_info",+ "channel_messages",+ ]+ }+ },},)# ===== CHANNEL MESSAGES / STATS =====channel_count: int = Field(- default=10, ge=1, le=100,+ default=10,+ ge=1,+ le=100,description="Number of messages to retrieve (1-100)",json_schema_extra={- "displayOptions": {"show": {"operation": [- "channel_messages", "channel_stats",- ]}},+ "displayOptions": {+ "show": {+ "operation": [+ "channel_messages",+ "channel_stats",+ ]+ }+ },},)before_server_id: int = Field(- default=0, ge=0,+ default=0,+ ge=0,description="Pagination: get messages before this server ID (0 = latest)",json_schema_extra={"displayOptions": {"show": {"operation": ["channel_messages"]}},},)message_offset: int = Field(- default=0, ge=0,+ default=0,+ ge=0,description="Skip this many messages",json_schema_extra={"displayOptions": {"show": {"operation": ["channel_messages"]}},@@ -264,15 +317,21 @@ class WhatsAppDbParams(BaseModel):default="",description="Comma-separated message server IDs",json_schema_extra={- "displayOptions": {"show": {"operation": [- "channel_mark_viewed", "newsletter_live_updates",- ]}},+ "displayOptions": {+ "show": {+ "operation": [+ "channel_mark_viewed",+ "newsletter_live_updates",+ ]+ }+ },},)# ===== NEWSLETTER REACT =====react_server_id: int = Field(- default=0, ge=0,+ default=0,+ ge=0,description="Server ID of the message to react to",json_schema_extra={"displayOptions": {"show": {"operation": ["newsletter_react"]}},@@ -326,10 +385,8 @@ class WhatsAppDbNode(ActionNode):tool_name = "whatsapp_db"tool_description = "Query WhatsApp database - list contacts, search groups, get contact/group info, retrieve chat history."handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": True, "open_world": True}task_queue = TaskQueue.MESSAGING@@ -341,9 +398,12 @@ class WhatsAppDbNode(ActionNode):@Operation("query", cost={"service": "whatsapp", "action": "db_query", "count": 1})async def query(self, ctx: NodeContext, params: WhatsAppDbParams) -> Any:from ._base import handle_whatsapp_db+response = await handle_whatsapp_db(- node_id=ctx.node_id, node_type=self.type,- parameters=params.model_dump(), context=ctx.raw,+ node_id=ctx.node_id,+ node_type=self.type,+ parameters=params.model_dump(),+ context=ctx.raw,)if response.get("success"):return response.get("result") or responsediff --git a/server/nodes/whatsapp/whatsapp_receive.py b/server/nodes/whatsapp/whatsapp_receive.pyindex e3940532..00006f08 100644--- a/server/nodes/whatsapp/whatsapp_receive.py+++ b/server/nodes/whatsapp/whatsapp_receive.py@@ -21,11 +21,23 @@ class WhatsAppReceiveParams(BaseModel):"""message_type_filter: Literal[- "all", "text", "image", "video", "audio",- "document", "location", "contact",+ "all",+ "text",+ "image",+ "video",+ "audio",+ "document",+ "location",+ "contact",] = Field(default="all")filter: Literal[- "all", "self", "any_contact", "contact", "group", "channel", "keywords",+ "all",+ "self",+ "any_contact",+ "contact",+ "group",+ "channel",+ "keywords",] = "all"phone_number: str = Field(default="",@@ -66,9 +78,18 @@ class WhatsAppReceiveParams(BaseModel):ignore_own_messages: bool = Field(default=True,json_schema_extra={- "displayOptions": {"show": {"filter": [- "all", "any_contact", "contact", "group", "channel", "keywords",- ]}},+ "displayOptions": {+ "show": {+ "filter": [+ "all",+ "any_contact",+ "contact",+ "group",+ "channel",+ "keywords",+ ]+ }+ },},)include_media_data: bool = Field(default=False)@@ -99,10 +120,7 @@ class WhatsAppReceiveNode(TriggerNode):group = ("whatsapp", "trigger")description = "Trigger workflow when WhatsApp message is received"component_kind = "trigger"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)task_queue = TaskQueue.TRIGGERS_EVENTmode = "event"event_type = "whatsapp_message_received"@@ -112,10 +130,9 @@ class WhatsAppReceiveNode(TriggerNode):def build_filter(self, params: WhatsAppReceiveParams) -> Callable[[Dict[str, Any]], bool]:from services.event_waiter import build_whatsapp_filter+return build_whatsapp_filter(params.model_dump())@Operation("wait")async def wait(self, ctx: NodeContext, params: WhatsAppReceiveParams) -> WhatsAppReceiveOutput:- raise NotImplementedError(- "Event triggers return via TriggerNode.execute, not the op body"- )+ raise NotImplementedError("Event triggers return via TriggerNode.execute, not the op body")diff --git a/server/nodes/whatsapp/whatsapp_send.py b/server/nodes/whatsapp/whatsapp_send.pyindex b50b6d9c..c7edecc4 100644--- a/server/nodes/whatsapp/whatsapp_send.py+++ b/server/nodes/whatsapp/whatsapp_send.py@@ -45,10 +45,7 @@ class WhatsAppSendParams(BaseModel):)channel_jid: str = Field(default="",- description=(- "Newsletter channel JID (format: 120363...@newsletter). "- "Admin/owner role required to send."- ),+ description=("Newsletter channel JID (format: 120363...@newsletter). " "Admin/owner role required to send."),json_schema_extra={"component": "ChannelJidSelector","loadOptionsMethod": "whatsappChannels",@@ -58,13 +55,17 @@ class WhatsAppSendParams(BaseModel):# ===== MESSAGE TYPE =====message_type: Literal[- "text", "image", "video", "audio", "document",- "sticker", "location", "contact",+ "text",+ "image",+ "video",+ "audio",+ "document",+ "sticker",+ "location",+ "contact",] = Field(default="text",- description=(- "Type of message. Channels only support: text, image, video, audio, document."- ),+ description=("Type of message. Channels only support: text, image, video, audio, document."),)# ===== TEXT =====@@ -78,9 +79,7 @@ class WhatsAppSendParams(BaseModel):)format_markdown: bool = Field(default=True,- description=(- "Convert LLM markdown (bold, italic, code, lists) to WhatsApp-native formatting"- ),+ description=("Convert LLM markdown (bold, italic, code, lists) to WhatsApp-native formatting"),json_schema_extra={"displayOptions": {"show": {"message_type": ["text"]}},},@@ -91,9 +90,17 @@ class WhatsAppSendParams(BaseModel):default="base64",description="Source of media data",json_schema_extra={- "displayOptions": {"show": {"message_type": [- "image", "video", "audio", "document", "sticker",- ]}},+ "displayOptions": {+ "show": {+ "message_type": [+ "image",+ "video",+ "audio",+ "document",+ "sticker",+ ]+ }+ },},)media_data: str = Field(@@ -101,10 +108,12 @@ class WhatsAppSendParams(BaseModel):description="Base64-encoded media data",json_schema_extra={"rows": 3,- "displayOptions": {"show": {- "message_type": ["image", "video", "audio", "document", "sticker"],- "media_source": ["base64"],- }},+ "displayOptions": {+ "show": {+ "message_type": ["image", "video", "audio", "document", "sticker"],+ "media_source": ["base64"],+ }+ },},)file_path: str = Field(@@ -113,29 +122,41 @@ class WhatsAppSendParams(BaseModel):json_schema_extra={"widget": "file","accept": "*/*",- "displayOptions": {"show": {- "message_type": ["image", "video", "audio", "document", "sticker"],- "media_source": ["file"],- }},+ "displayOptions": {+ "show": {+ "message_type": ["image", "video", "audio", "document", "sticker"],+ "media_source": ["file"],+ }+ },},)media_url: str = Field(default="",description="HTTPS URL to download media from",json_schema_extra={- "displayOptions": {"show": {- "message_type": ["image", "video", "audio", "document", "sticker"],- "media_source": ["url"],- }},+ "displayOptions": {+ "show": {+ "message_type": ["image", "video", "audio", "document", "sticker"],+ "media_source": ["url"],+ }+ },},)mime_type: str = Field(default="",description="MIME type (auto-detected if empty). e.g. image/jpeg, video/mp4",json_schema_extra={- "displayOptions": {"show": {"message_type": [- "image", "video", "audio", "document", "sticker",- ]}},+ "displayOptions": {+ "show": {+ "message_type": [+ "image",+ "video",+ "audio",+ "document",+ "sticker",+ ]+ }+ },},)caption: str = Field(@@ -247,10 +268,8 @@ class WhatsAppSendNode(ActionNode):component_kind = "square"tool_name = "whatsapp_send"handles = (- {"name": "input-main", "kind": "input", "position": "left",- "label": "Input", "role": "main"},- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)annotations = {"destructive": False, "readonly": False, "open_world": True}task_queue = TaskQueue.MESSAGING@@ -262,9 +281,12 @@ class WhatsAppSendNode(ActionNode):@Operation("send", cost={"service": "whatsapp", "action": "send", "count": 1})async def send(self, ctx: NodeContext, params: WhatsAppSendParams) -> Any:from ._base import handle_whatsapp_send+response = await handle_whatsapp_send(- node_id=ctx.node_id, node_type=self.type,- parameters=params.model_dump(by_alias=False), context=ctx.raw,+ node_id=ctx.node_id,+ node_type=self.type,+ parameters=params.model_dump(by_alias=False),+ context=ctx.raw,)if response.get("success"):return response.get("result") or responsediff --git a/server/nodes/workflow/start/__init__.py b/server/nodes/workflow/start/__init__.pyindex 73ec98c6..2f47a128 100644--- a/server/nodes/workflow/start/__init__.py+++ b/server/nodes/workflow/start/__init__.py@@ -34,10 +34,7 @@ class StartNode(ActionNode):group = ("workflow",)description = "Starting point for workflow execution. Provides initial data to connected nodes."component_kind = "start"- handles = (- {"name": "output-main", "kind": "output", "position": "right",- "label": "Output", "role": "main"},- )+ handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)ui_hints = {"hideInputSection": True,"hideOutputSection": True,diff --git a/server/routers/__init__.py b/server/routers/__init__.pyindex 4e602c7f..6b03adad 100644--- a/server/routers/__init__.py+++ b/server/routers/__init__.py@@ -1 +1 @@-# FastAPI route modules\ No newline at end of file+# FastAPI route modulesdiff --git a/server/routers/auth.py b/server/routers/auth.pyindex b639f64d..4893e122 100644--- a/server/routers/auth.py+++ b/server/routers/auth.py@@ -45,9 +45,7 @@ def get_auth_service() -> AuthService:@router.get("/status")async def get_auth_status(- request: Request,- user_auth: UserAuthService = Depends(get_user_auth_service),- settings: Settings = Depends(get_settings)+ request: Request, user_auth: UserAuthService = Depends(get_user_auth_service), settings: Settings = Depends(get_settings)):"""Get authentication status.@@ -62,19 +60,14 @@ async def get_auth_status(if token:user = await user_auth.get_current_user(token)if user:- current_user = {- "id": user.id,- "email": user.email,- "display_name": user.display_name,- "is_owner": user.is_owner- }+ current_user = {"id": user.id, "email": user.email, "display_name": user.display_name, "is_owner": user.is_owner}# Check if registration is availablecan_register = await user_auth.can_register()# Determine if auth is enabled from server configauth_enabled = True- if settings.vite_auth_enabled and settings.vite_auth_enabled.lower() == 'false':+ if settings.vite_auth_enabled and settings.vite_auth_enabled.lower() == "false":auth_enabled = Falsereturn {@@ -82,7 +75,7 @@ async def get_auth_status("auth_mode": status["auth_mode"],"authenticated": current_user is not None,"user": current_user,- "can_register": can_register+ "can_register": can_register,}@@ -91,18 +84,14 @@ async def register(request: RegisterRequest,response: Response,user_auth: UserAuthService = Depends(get_user_auth_service),- settings: Settings = Depends(get_settings)+ settings: Settings = Depends(get_settings),):"""Register a new user.In single-owner mode, only the first user can register.In multi-user mode, anyone can register."""- user, error = await user_auth.register(- email=request.email,- password=request.password,- display_name=request.display_name- )+ user, error = await user_auth.register(email=request.email, password=request.password, display_name=request.display_name)if error:raise HTTPException(status_code=400, detail=error)@@ -115,18 +104,10 @@ async def register(httponly=True,secure=settings.jwt_cookie_secure,samesite=settings.jwt_cookie_samesite,- max_age=settings.jwt_expire_minutes * 60+ max_age=settings.jwt_expire_minutes * 60,)- return {- "success": True,- "user": {- "id": user.id,- "email": user.email,- "display_name": user.display_name,- "is_owner": user.is_owner- }- }+ return {"success": True, "user": {"id": user.id, "email": user.email, "display_name": user.display_name, "is_owner": user.is_owner}}@router.post("/login")@@ -134,16 +115,13 @@ async def login(request: LoginRequest,response: Response,user_auth: UserAuthService = Depends(get_user_auth_service),- settings: Settings = Depends(get_settings)+ settings: Settings = Depends(get_settings),):"""Login with email and password.Sets HttpOnly cookie with JWT token."""- user, error = await user_auth.login(- email=request.email,- password=request.password- )+ user, error = await user_auth.login(email=request.email, password=request.password)if error:raise HTTPException(status_code=401, detail=error)@@ -156,18 +134,10 @@ async def login(httponly=True,secure=settings.jwt_cookie_secure,samesite=settings.jwt_cookie_samesite,- max_age=settings.jwt_expire_minutes * 60+ max_age=settings.jwt_expire_minutes * 60,)- return {- "success": True,- "user": {- "id": user.id,- "email": user.email,- "display_name": user.display_name,- "is_owner": user.is_owner- }- }+ return {"success": True, "user": {"id": user.id, "email": user.email, "display_name": user.display_name, "is_owner": user.is_owner}}@router.post("/logout")@@ -175,7 +145,7 @@ async def logout(response: Response,user_auth: UserAuthService = Depends(get_user_auth_service),auth_service: AuthService = Depends(get_auth_service),- settings: Settings = Depends(get_settings)+ settings: Settings = Depends(get_settings),):"""Logout by clearing the auth cookie, encryption key, and memory caches.@@ -193,19 +163,14 @@ async def logout(# Delete auth cookieresponse.delete_cookie(- key=settings.jwt_cookie_name,- httponly=True,- secure=settings.jwt_cookie_secure,- samesite=settings.jwt_cookie_samesite+ key=settings.jwt_cookie_name, httponly=True, secure=settings.jwt_cookie_secure, samesite=settings.jwt_cookie_samesite)return {"success": True}@router.get("/me")async def get_current_user(- request: Request,- user_auth: UserAuthService = Depends(get_user_auth_service),- settings: Settings = Depends(get_settings)+ request: Request, user_auth: UserAuthService = Depends(get_user_auth_service), settings: Settings = Depends(get_settings)):"""Get current authenticated user.@@ -219,9 +184,4 @@ async def get_current_user(if not user:raise HTTPException(status_code=401, detail="Invalid or expired session")- return {- "id": user.id,- "email": user.email,- "display_name": user.display_name,- "is_owner": user.is_owner- }+ return {"id": user.id, "email": user.email, "display_name": user.display_name, "is_owner": user.is_owner}diff --git a/server/routers/database.py b/server/routers/database.pyindex 4369d1ba..ac202bc9 100644--- a/server/routers/database.py+++ b/server/routers/database.py@@ -25,10 +25,7 @@ class WorkflowSaveRequest(BaseModel):@router.post("/node-parameters")-async def save_node_parameters(- request: NodeParameterRequest,- database: Database = Depends(lambda: container.database())-):+async def save_node_parameters(request: NodeParameterRequest, database: Database = Depends(lambda: container.database())):"""Save node parameters (replaces frontend Dexie)."""try:success = await database.save_node_parameters(request.node_id, request.parameters)@@ -39,10 +36,7 @@ async def save_node_parameters(@router.get("/node-parameters/{node_id}")-async def get_node_parameters(- node_id: str,- database: Database = Depends(lambda: container.database())-):+async def get_node_parameters(node_id: str, database: Database = Depends(lambda: container.database())):"""Get node parameters (replaces frontend Dexie)."""try:parameters = await database.get_node_parameters(node_id)@@ -53,10 +47,7 @@ async def get_node_parameters(@router.delete("/node-parameters/{node_id}")-async def delete_node_parameters(- node_id: str,- database: Database = Depends(lambda: container.database())-):+async def delete_node_parameters(node_id: str, database: Database = Depends(lambda: container.database())):"""Delete node parameters (replaces frontend Dexie)."""try:success = await database.delete_node_parameters(node_id)@@ -70,18 +61,12 @@ async def delete_node_parameters(# Workflow Operations# ============================================================================+@router.post("/workflows")-async def save_workflow(- request: WorkflowSaveRequest,- database: Database = Depends(lambda: container.database())-):+async def save_workflow(request: WorkflowSaveRequest, database: Database = Depends(lambda: container.database())):"""Save workflow to database."""try:- success = await database.save_workflow(- workflow_id=request.workflow_id,- name=request.name,- data=request.data- )+ success = await database.save_workflow(workflow_id=request.workflow_id, name=request.name, data=request.data)return {"success": success, "workflow_id": request.workflow_id}except Exception as e:logger.error("Failed to save workflow", error=str(e))@@ -89,9 +74,7 @@ async def save_workflow(@router.get("/workflows")-async def get_all_workflows(- database: Database = Depends(lambda: container.database())-):+async def get_all_workflows(database: Database = Depends(lambda: container.database())):"""Get all workflows."""try:# Auto-load example workflows on first fetch@@ -118,10 +101,10 @@ async def get_all_workflows("name": w.name,"nodeCount": len(w.data.get("nodes", [])) if w.data else 0,"createdAt": w.created_at.isoformat() if w.created_at else None,- "lastModified": w.updated_at.isoformat() if w.updated_at else None+ "lastModified": w.updated_at.isoformat() if w.updated_at else None,}for w in workflows- ]+ ],}except Exception as e:logger.error("Failed to get workflows", error=str(e))@@ -129,10 +112,7 @@ async def get_all_workflows(@router.get("/workflows/{workflow_id}")-async def get_workflow(- workflow_id: str,- database: Database = Depends(lambda: container.database())-):+async def get_workflow(workflow_id: str, database: Database = Depends(lambda: container.database())):"""Get workflow by ID."""try:workflow = await database.get_workflow(workflow_id)@@ -144,8 +124,8 @@ async def get_workflow("name": workflow.name,"data": workflow.data,"createdAt": workflow.created_at.isoformat() if workflow.created_at else None,- "lastModified": workflow.updated_at.isoformat() if workflow.updated_at else None- }+ "lastModified": workflow.updated_at.isoformat() if workflow.updated_at else None,+ },}return {"success": False, "error": "Workflow not found"}except Exception as e:@@ -154,14 +134,11 @@ async def get_workflow(@router.delete("/workflows/{workflow_id}")-async def delete_workflow(- workflow_id: str,- database: Database = Depends(lambda: container.database())-):+async def delete_workflow(workflow_id: str, database: Database = Depends(lambda: container.database())):"""Delete workflow."""try:success = await database.delete_workflow(workflow_id)return {"success": success, "workflow_id": workflow_id}except Exception as e:logger.error("Failed to delete workflow", error=str(e))- return {"success": False, "error": str(e)}\ No newline at end of file+ return {"success": False, "error": str(e)}diff --git a/server/routers/nodejs_compat.py b/server/routers/nodejs_compat.pyindex f0533398..f62dabf8 100644--- a/server/routers/nodejs_compat.py+++ b/server/routers/nodejs_compat.py@@ -37,28 +37,16 @@ async def root():"message": "React Flow Project API Server","status": "running","version": "2.0.0-python",- "endpoints": {- "health": "/api/health",- "workflows": "/api/workflows",- "nodes": "/api/nodes",- "execute": "/api/nodes/execute"- },- "services": {- "main": "http://localhost:3010",- "python": "http://localhost:3010"- },- "timestamp": datetime.now().isoformat()+ "endpoints": {"health": "/api/health", "workflows": "/api/workflows", "nodes": "/api/nodes", "execute": "/api/nodes/execute"},+ "services": {"main": "http://localhost:3010", "python": "http://localhost:3010"},+ "timestamp": datetime.now().isoformat(),}@router.get("/api/health")async def health_check():"""Node.js compatible health check."""- return {- "status": "OK",- "message": "React Flow Server is running",- "timestamp": datetime.now().isoformat()- }+ return {"status": "OK", "message": "React Flow Server is running", "timestamp": datetime.now().isoformat()}# Workflow management endpoints@@ -74,25 +62,14 @@ async def get_workflows(database: Database = Depends(lambda: container.database(@router.post("/api/workflows")-async def save_workflow(- request: WorkflowSaveRequest,- database: Database = Depends(lambda: container.database())-):+async def save_workflow(request: WorkflowSaveRequest, database: Database = Depends(lambda: container.database())):"""Save workflow (Node.js compatible)."""try:workflow_id = str(int(datetime.now().timestamp() * 1000)) # Node.js style ID- success = await database.save_workflow(- workflow_id=workflow_id,- name=request.name,- data=request.data- )+ success = await database.save_workflow(workflow_id=workflow_id, name=request.name, data=request.data)if success:- return {- "success": True,- "id": workflow_id,- "message": "Workflow saved successfully"- }+ return {"success": True, "id": workflow_id, "message": "Workflow saved successfully"}else:raise HTTPException(status_code=500, detail="Failed to save workflow")@@ -102,42 +79,24 @@ async def save_workflow(@router.get("/api/workflows/{workflow_id}")-async def get_workflow(- workflow_id: str,- database: Database = Depends(lambda: container.database())-):+async def get_workflow(workflow_id: str, database: Database = Depends(lambda: container.database())):"""Get workflow by ID (Node.js compatible)."""try:workflow = await database.get_workflow(workflow_id)if workflow:- return {- "id": workflow.id,- "name": workflow.name,- "data": workflow.data- }+ return {"id": workflow.id, "name": workflow.name, "data": workflow.data}else:- return {- "id": workflow_id,- "name": "Sample Workflow",- "data": {"nodes": [], "edges": []}- }+ return {"id": workflow_id, "name": "Sample Workflow", "data": {"nodes": [], "edges": []}}except Exception as e:logger.error("Failed to get workflow", workflow_id=workflow_id, error=str(e))- return {- "id": workflow_id,- "name": "Sample Workflow",- "data": {"nodes": [], "edges": []}- }+ return {"id": workflow_id, "name": "Sample Workflow", "data": {"nodes": [], "edges": []}}# Main execution endpoint - Node.js compatible@router.post("/api/nodes/execute")-async def execute_node(- request: NodeExecuteRequest,- workflow_service: WorkflowService = Depends(lambda: container.workflow_service())-):+async def execute_node(request: NodeExecuteRequest, workflow_service: WorkflowService = Depends(lambda: container.workflow_service())):"""Execute a single node (Node.js compatible)."""try:if not request.nodeId or not request.nodeType:@@ -153,7 +112,7 @@ async def execute_node(parameters=request.parameters or {},nodes=request.nodes or [],edges=request.edges or [],- session_id="default"+ session_id="default",)# Transform result to match Node.js format@@ -165,7 +124,7 @@ async def execute_node("nodeType": request.nodeType,"result": result.get("result", {}),"executionTime": result.get("execution_time", 0),- "timestamp": result.get("timestamp", datetime.now().isoformat())+ "timestamp": result.get("timestamp", datetime.now().isoformat()),}else:return {@@ -175,7 +134,7 @@ async def execute_node("nodeType": request.nodeType,"error": result.get("error", "Unknown error"),"executionTime": result.get("execution_time", 0),- "timestamp": result.get("timestamp", datetime.now().isoformat())+ "timestamp": result.get("timestamp", datetime.now().isoformat()),}except Exception as e:@@ -189,35 +148,19 @@ async def get_execution_status(execution_id: str):"""Get execution status (Node.js compatible)."""# For simplicity, return success status# In a full implementation, you'd track execution status- return {- "success": True,- "executionId": execution_id,- "status": "completed",- "timestamp": datetime.now().isoformat()- }+ return {"success": True, "executionId": execution_id, "status": "completed", "timestamp": datetime.now().isoformat()}@router.get("/api/nodes/{node_id}/output")-async def get_node_output(- node_id: str,- workflow_service: WorkflowService = Depends(lambda: container.workflow_service())-):+async def get_node_output(node_id: str, workflow_service: WorkflowService = Depends(lambda: container.workflow_service())):"""Get node output data (Node.js compatible)."""try:result = await workflow_service.get_workflow_node_output(node_id)if result.get("success"):- return {- "success": True,- "nodeId": node_id,- "output": result.get("data", {})- }+ return {"success": True, "nodeId": node_id, "output": result.get("data", {})}else:- return {- "success": False,- "nodeId": node_id,- "error": result.get("error", "Node output not found")- }+ return {"success": False, "nodeId": node_id, "error": result.get("error", "Node output not found")}except Exception as e:logger.error("Get node output error", node_id=node_id, error=str(e))@@ -229,10 +172,7 @@ async def clear_execution_cache():"""Clear execution cache (Node.js compatible)."""try:# Clear workflow service cache if implemented- return {- "success": True,- "message": "Execution cache cleared"- }+ return {"success": True, "message": "Execution cache cleared"}except Exception as e:logger.error("Clear cache error", error=str(e))raise HTTPException(status_code=500, detail=str(e))@@ -241,9 +181,7 @@ async def clear_execution_cache():# Legacy endpoint for backwards compatibility@router.post("/api/execute/{node_id}")async def legacy_execute_node(- node_id: str,- request: Dict[str, Any],- workflow_service: WorkflowService = Depends(lambda: container.workflow_service())+ node_id: str, request: Dict[str, Any], workflow_service: WorkflowService = Depends(lambda: container.workflow_service())):"""Legacy execution endpoint (Node.js compatible)."""try:@@ -259,7 +197,7 @@ async def legacy_execute_node(parameters=request.get("parameters", {}),nodes=request.get("nodes", []),edges=request.get("edges", []),- session_id="default"+ session_id="default",)# Return in Node.js format@@ -271,7 +209,7 @@ async def legacy_execute_node("nodeType": node_type,"result": result.get("result", {}),"executionTime": result.get("execution_time", 0),- "timestamp": result.get("timestamp", datetime.now().isoformat())+ "timestamp": result.get("timestamp", datetime.now().isoformat()),}else:return {@@ -281,9 +219,9 @@ async def legacy_execute_node("nodeType": node_type,"error": result.get("error", "Unknown error"),"executionTime": result.get("execution_time", 0),- "timestamp": result.get("timestamp", datetime.now().isoformat())+ "timestamp": result.get("timestamp", datetime.now().isoformat()),}except Exception as e:logger.error("Legacy execution error", node_id=node_id, error=str(e))- raise HTTPException(status_code=500, detail=str(e))\ No newline at end of file+ raise HTTPException(status_code=500, detail=str(e))diff --git a/server/routers/webhook.py b/server/routers/webhook.pyindex 120c79f6..659390e4 100644--- a/server/routers/webhook.py+++ b/server/routers/webhook.py@@ -11,6 +11,7 @@ Two dispatch paths:``broadcaster.send_custom_event("webhook_received", …)`` so existing``webhookTrigger`` nodes keep working untouched."""+from fastapi import APIRouter, HTTPException, Requestfrom fastapi.responses import JSONResponsefrom typing import Dict@@ -79,8 +80,8 @@ async def handle_webhook(path: str, request: Request):"path": path,"headers": dict(request.headers),"query": dict(request.query_params),- "body": body.decode('utf-8') if isinstance(body, bytes) else (body if body else ""),- "json": json_body+ "body": body.decode("utf-8") if isinstance(body, bytes) else (body if body else ""),+ "json": json_body,}logger.info(f"[Webhook] Received: {request.method} /webhook/{path}")@@ -91,12 +92,7 @@ async def handle_webhook(path: str, request: Request):await broadcast_webhook_received(webhook_data)return JSONResponse(- content={- "status": "received",- "path": path,- "message": "Webhook received and dispatched to workflow"- },- status_code=200+ content={"status": "received", "path": path, "message": "Webhook received and dispatched to workflow"}, status_code=200)@@ -107,5 +103,5 @@ async def list_info():"endpoint": "/webhook/{path}","description": "Send HTTP requests to trigger webhookTrigger nodes","usage": "Deploy a workflow with webhookTrigger node, then send requests to /webhook/{path}",- "example": "POST /webhook/my-webhook with JSON body"+ "example": "POST /webhook/my-webhook with JSON body",}diff --git a/server/routers/websocket.py b/server/routers/websocket.pyindex 33150f84..a5b75ab5 100644--- a/server/routers/websocket.py+++ b/server/routers/websocket.py@@ -27,6 +27,7 @@ def get_auth_service():"""Get auth service from DI container."""return container.auth_service()+logger = get_logger(__name__)router = APIRouter(tags=["websocket"])@@ -77,7 +78,9 @@ def ws_handler(*required_fields: str):except Exception as e:logger.error(f"Handler error: {e}", exc_info=True)return {"success": False, "error": str(e)}+return wrapper+return decorator@@ -85,6 +88,7 @@ def ws_handler(*required_fields: str):# Message Handlers# ============================================================================+async def handle_ping(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Handle ping request."""return {"type": "pong", "timestamp": time.time()}@@ -123,6 +127,7 @@ async def handle_get_variable(data: Dict[str, Any], websocket: WebSocket) -> Dic# Node Parameters Handlers# ============================================================================+@ws_handler("node_id")async def handle_get_node_parameters(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Get parameters for a specific node."""@@ -154,13 +159,17 @@ async def handle_save_node_parameters(data: Dict[str, Any], websocket: WebSocketbroadcaster = get_status_broadcaster()node_id, parameters = data["node_id"], data.get("parameters", {})- logger.debug(f"[SAVE_PARAMS] Node ID: {node_id}, has_code: {'code' in parameters}, code_len: {len(parameters.get('code', '')) if 'code' in parameters else 0}")+ logger.debug(+ f"[SAVE_PARAMS] Node ID: {node_id}, has_code: {'code' in parameters}, code_len: {len(parameters.get('code', '')) if 'code' in parameters else 0}"+ )await database.save_node_parameters(node_id, parameters)# CloudEvents v1.0 envelope (RFC §6.4) — type is# ``com.machinaos.node.parameters.updated``; ``source_hint="user"``# because this handler fires from the parameter-panel save flow.await broadcaster.broadcast_node_parameters_updated(- node_id, parameters=parameters, source_hint="user",+ node_id,+ parameters=parameters,+ source_hint="user",)return {"node_id": node_id, "parameters": parameters, "version": 1, "timestamp": time.time()}@@ -177,6 +186,7 @@ async def handle_delete_node_parameters(data: Dict[str, Any], websocket: WebSock# Tool Schema Handlers (Source of truth for tool node configurations)# ============================================================================+@ws_handler("node_id")async def handle_get_tool_schema(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Get tool schema for a node."""@@ -202,23 +212,14 @@ async def handle_save_tool_schema(data: Dict[str, Any], websocket: WebSocket) ->tool_name=tool_name,tool_description=tool_description,schema_config=schema_config,- connected_services=connected_services+ connected_services=connected_services,)if success:# Broadcast schema update to all clients- await broadcaster.broadcast({- "type": "tool_schema_updated",- "node_id": node_id,- "tool_name": tool_name,- "timestamp": time.time()- })+ await broadcaster.broadcast({"type": "tool_schema_updated", "node_id": node_id, "tool_name": tool_name, "timestamp": time.time()})- return {- "node_id": node_id,- "tool_name": tool_name,- "saved": success- }+ return {"node_id": node_id, "tool_name": tool_name, "saved": success}@ws_handler("node_id")@@ -244,9 +245,7 @@ async def handle_get_all_tool_schemas(data: Dict[str, Any], websocket: WebSocket@ws_handler("node_type")-async def handle_get_node_output_schema(- data: Dict[str, Any], websocket: WebSocket-) -> Dict[str, Any]:+async def handle_get_node_output_schema(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Return the JSON Schema for a node type's runtime output, or``{schema: null}`` when no schema is declared. Frontend caches theresult per node type in-memory (mirrors n8n's schemaPreview.store)."""@@ -257,9 +256,7 @@ async def handle_get_node_output_schema(@ws_handler("node_type")-async def handle_get_node_spec(- data: Dict[str, Any], websocket: WebSocket-) -> Dict[str, Any]:+async def handle_get_node_spec(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Return the unified NodeSpec (input schema + output schema +display metadata) for a node type, or ``{spec: null}`` when thetype is unknown. Wave 6 Phase 2 WS mirror of the REST endpoint@@ -271,9 +268,7 @@ async def handle_get_node_spec(@ws_handler()-async def handle_list_node_specs(- data: Dict[str, Any], websocket: WebSocket-) -> Dict[str, Any]:+async def handle_list_node_specs(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Return the sorted list of node types that have a NodeSpec, plusa content-hash revision the editor uses to invalidate its persistedspec cache when the backend catalogue changes between deploys."""@@ -286,9 +281,7 @@ async def handle_list_node_specs(@ws_handler("method")-async def handle_load_options(- data: Dict[str, Any], websocket: WebSocket-) -> Dict[str, Any]:+async def handle_load_options(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Wave 6 Phase 4: unified loadOptionsMethod dispatcher.Replaces the per-method WS handlers (whatsapp_groups, whatsapp_newsletters,@@ -306,9 +299,7 @@ async def handle_load_options(@ws_handler()-async def handle_list_load_options_methods(- data: Dict[str, Any], websocket: WebSocket-) -> Dict[str, Any]:+async def handle_list_load_options_methods(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Return registered loadOptionsMethod names. Editor uses this toknow which dynamic-option loaders are wired."""from services.ws_handler_registry import list_load_options_methods@@ -317,9 +308,7 @@ async def handle_list_load_options_methods(@ws_handler()-async def handle_get_node_groups(- data: Dict[str, Any], websocket: WebSocket-) -> Dict[str, Any]:+async def handle_get_node_groups(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Wave 6 Phase 5: {group_name: [node_type, ...]} index derived fromevery NodeSpec's ``group`` array. Replaces the 34 hand-rolled``*_NODE_TYPES`` arrays scattered across the frontend."""@@ -332,6 +321,7 @@ async def handle_get_node_groups(# Credential Registry Handler (Nango-style bulk fetch for 20 -> 5000 providers)# ============================================================================+@ws_handler()async def handle_get_credential_catalogue(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Return the full credential provider catalogue with live stored-key status.@@ -405,6 +395,7 @@ async def handle_get_credential_catalogue(data: Dict[str, Any], websocket: WebSo# Node Execution Handlers# ============================================================================+@ws_handler("node_id", "node_type")async def handle_execute_node(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Execute a workflow node with per-workflow status scoping (n8n pattern).@@ -423,7 +414,10 @@ async def handle_execute_node(data: Dict[str, Any], websocket: WebSocket) -> Dicexecution_id = uuid.uuid4().hexawait broadcaster.update_node_status(- node_id, "executing", {"execution_id": execution_id}, workflow_id=workflow_id,+ node_id,+ "executing",+ {"execution_id": execution_id},+ workflow_id=workflow_id,)# Mark this workflow active so the toolbar Start->Stop reflects ad-hoc runs.# finally: ensures the counter rolls back even on crash.@@ -431,9 +425,11 @@ async def handle_execute_node(data: Dict[str, Any], websocket: WebSocket) -> Dicresult: Dict[str, Any]try:result = await workflow_service.execute_node(- node_id=node_id, node_type=node_type,+ node_id=node_id,+ node_type=node_type,parameters=data.get("parameters", {}),- nodes=data.get("nodes", []), edges=data.get("edges", []),+ nodes=data.get("nodes", []),+ edges=data.get("edges", []),session_id=data.get("session_id", "default"),workflow_id=workflow_id,outputs=data.get("outputs", {}), # Upstream node outputs for data flow@@ -446,16 +442,23 @@ async def handle_execute_node(data: Dict[str, Any], websocket: WebSocket) -> Dicelif result.get("error") == "Cancelled by user":# Cancelled trigger nodes go back to idle, not errorawait broadcaster.update_node_status(- node_id, "idle", {"message": "Cancelled", "execution_id": execution_id}, workflow_id=workflow_id,+ node_id,+ "idle",+ {"message": "Cancelled", "execution_id": execution_id},+ workflow_id=workflow_id,)else:await broadcaster.update_node_status(- node_id, "error", {"error": result.get("error"), "execution_id": execution_id}, workflow_id=workflow_id,+ node_id,+ "error",+ {"error": result.get("error"), "execution_id": execution_id},+ workflow_id=workflow_id,)except Exception:# Mark the node as errored so the UI doesn't keep glowing on crashawait broadcaster.update_node_status(- node_id, "error",+ node_id,+ "error",{"error": "execution crashed", "execution_id": execution_id},workflow_id=workflow_id,)@@ -471,11 +474,13 @@ async def handle_execute_node(data: Dict[str, Any], websocket: WebSocket) -> Dic"result": result.get("result"),"error": result.get("error"),"execution_time": result.get("execution_time"),- "timestamp": time.time()+ "timestamp": time.time(),}# Debug: Log what we're returning to WebSocketresult_data = result.get("result")- logger.debug(f"[WS execute_node] Returning: success={ws_result['success']}, result.response={repr(result_data.get('response', 'MISSING')[:100] if result_data and result_data.get('response') else 'None')}")+ logger.debug(+ f"[WS execute_node] Returning: success={ws_result['success']}, result.response={repr(result_data.get('response', 'MISSING')[:100] if result_data and result_data.get('response') else 'None')}"+ )return ws_result@@ -509,7 +514,8 @@ async def handle_cancel_execution(data: Dict[str, Any], websocket: WebSocket) -># indicator go quiet. (Default sweep on run-end skips `waiting` to# protect deployment trigger listeners.)cleared = await broadcaster._clear_stuck_node_statuses(- workflow_id, include_waiting=True,+ workflow_id,+ include_waiting=True,)return {@@ -560,6 +566,7 @@ async def handle_cancel_event_wait(data: Dict[str, Any], websocket: WebSocket) -async def handle_get_active_waiters(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Get list of active event waiters (for debugging/UI)."""from services import event_waiter+return {"waiters": event_waiter.get_active_waiters()}@@ -567,6 +574,7 @@ async def handle_get_active_waiters(data: Dict[str, Any], websocket: WebSocket)# Dead Letter Queue (DLQ) Handlers# ============================================================================+@ws_handler()async def handle_get_dlq_entries(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Get DLQ entries with optional filtering.@@ -580,20 +588,15 @@ async def handle_get_dlq_entries(data: Dict[str, Any], websocket: WebSocket) ->List of DLQ entries"""from services.execution import ExecutionCache+cache_service = container.cache()execution_cache = ExecutionCache(cache_service)entries = await execution_cache.get_dlq_entries(- workflow_id=data.get("workflow_id"),- node_type=data.get("node_type"),- limit=data.get("limit", 100)+ workflow_id=data.get("workflow_id"), node_type=data.get("node_type"), limit=data.get("limit", 100))- return {- "entries": [entry.to_dict() for entry in entries],- "count": len(entries),- "timestamp": time.time()- }+ return {"entries": [entry.to_dict() for entry in entries], "count": len(entries), "timestamp": time.time()}@ws_handler("entry_id")@@ -607,6 +610,7 @@ async def handle_get_dlq_entry(data: Dict[str, Any], websocket: WebSocket) -> DiDLQ entry details"""from services.execution import ExecutionCache+cache_service = container.cache()execution_cache = ExecutionCache(cache_service)@@ -626,6 +630,7 @@ async def handle_get_dlq_stats(data: Dict[str, Any], websocket: WebSocket) -> DiTotal count, breakdown by node type and workflow"""from services.execution import ExecutionCache+cache_service = container.cache()execution_cache = ExecutionCache(cache_service)@@ -646,6 +651,7 @@ async def handle_replay_dlq_entry(data: Dict[str, Any], websocket: WebSocket) ->Replay execution result"""from services.execution import ExecutionCache, WorkflowExecutor+cache_service = container.cache()execution_cache = ExecutionCache(cache_service)workflow_service = container.workflow_service()@@ -661,9 +667,7 @@ async def handle_replay_dlq_entry(data: Dict[str, Any], websocket: WebSocket) ->return {"success": False, "error": "DLQ entry not found"}# Update status- await broadcaster.update_node_status(entry.node_id, "executing", {- "message": "Replaying from DLQ"- })+ await broadcaster.update_node_status(entry.node_id, "executing", {"message": "Replaying from DLQ"})# Create executor with node adapterasync def node_executor(node_id: str, node_type: str, params: dict, context: dict) -> dict:@@ -674,7 +678,7 @@ async def handle_replay_dlq_entry(data: Dict[str, Any], websocket: WebSocket) ->nodes=context.get("nodes", []),edges=context.get("edges", []),session_id=context.get("session_id", "dlq_replay"),- execution_id=context.get("execution_id")+ execution_id=context.get("execution_id"),)async def status_callback(node_id: str, status: str, status_data: dict):@@ -683,10 +687,7 @@ async def handle_replay_dlq_entry(data: Dict[str, Any], websocket: WebSocket) -># DLQ replay needs DLQ enabled to re-add on failuresettings = container.settings()executor = WorkflowExecutor(- cache=execution_cache,- node_executor=node_executor,- status_callback=status_callback,- dlq_enabled=settings.dlq_enabled+ cache=execution_cache, node_executor=node_executor, status_callback=status_callback, dlq_enabled=settings.dlq_enabled)result = await executor.replay_dlq_entry(entry_id, nodes, edges)@@ -711,6 +712,7 @@ async def handle_remove_dlq_entry(data: Dict[str, Any], websocket: WebSocket) ->Success status"""from services.execution import ExecutionCache+cache_service = container.cache()execution_cache = ExecutionCache(cache_service)@@ -731,6 +733,7 @@ async def handle_purge_dlq(data: Dict[str, Any], websocket: WebSocket) -> Dict[sNumber of entries purged"""from services.execution import ExecutionCache+cache_service = container.cache()execution_cache = ExecutionCache(cache_service)@@ -738,11 +741,7 @@ async def handle_purge_dlq(data: Dict[str, Any], websocket: WebSocket) -> Dict[sif data.get("older_than_hours"):older_than = time.time() - (data["older_than_hours"] * 3600)- purged = await execution_cache.purge_dlq(- workflow_id=data.get("workflow_id"),- node_type=data.get("node_type"),- older_than=older_than- )+ purged = await execution_cache.purge_dlq(workflow_id=data.get("workflow_id"), node_type=data.get("node_type"), older_than=older_than)return {"purged": purged, "timestamp": time.time()}@@ -778,11 +777,21 @@ async def handle_clear_node_output(data: Dict[str, Any], websocket: WebSocket) -# Clear from broadcaster's status cache (prevents reload from showing old data)broadcaster_cleared = await broadcaster.clear_node_status(node_id)- logger.info("Cleared node output", node_id=node_id, memory_cleared=memory_cleared,- db_cleared=db_cleared, broadcaster_cleared=broadcaster_cleared)+ logger.info(+ "Cleared node output",+ node_id=node_id,+ memory_cleared=memory_cleared,+ db_cleared=db_cleared,+ broadcaster_cleared=broadcaster_cleared,+ )- return {"node_id": node_id, "cleared": True, "memory_cleared": memory_cleared,- "db_cleared": db_cleared, "broadcaster_cleared": broadcaster_cleared}+ return {+ "node_id": node_id,+ "cleared": True,+ "memory_cleared": memory_cleared,+ "db_cleared": db_cleared,+ "broadcaster_cleared": broadcaster_cleared,+ }@ws_handler()@@ -803,6 +812,7 @@ async def handle_validate_workflow(data: Dict[str, Any], websocket: WebSocket) -``{"success": True, "report": {"errors": [...], "warnings": [...]}}``."""from services.workflow_validator import validate_workflow+report = await validate_workflow(nodes=data.get("nodes", []),edges=data.get("edges", []),@@ -843,8 +853,10 @@ async def handle_execute_workflow(data: Dict[str, Any], websocket: WebSocket) -># "Run anyway" UX in Windmill); warnings never block.if not force:from services.workflow_validator import validate_workflow+report = await validate_workflow(- nodes=nodes, edges=edges,+ nodes=nodes,+ edges=edges,parameters_by_id=data.get("parameters_by_id"),)if report["errors"]:@@ -894,7 +906,7 @@ async def handle_execute_workflow(data: Dict[str, Any], websocket: WebSocket) ->"total_nodes": result.get("total_nodes", 0),"completed_nodes": result.get("completed_nodes", 0),"execution_time": result.get("execution_time", 0),- "timestamp": time.time()+ "timestamp": time.time(),}@@ -910,6 +922,7 @@ async def handle_execute_workflow(data: Dict[str, Any], websocket: WebSocket) -># AI Handlers# ============================================================================+@ws_handler("node_id", "node_type")async def handle_execute_ai_node(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Execute an AI node (chat model or agent)."""@@ -923,9 +936,11 @@ async def handle_execute_ai_node(data: Dict[str, Any], websocket: WebSocket) ->result: Dict[str, Any]try:result = await workflow_service.execute_node(- node_id=node_id, node_type=node_type,+ node_id=node_id,+ node_type=node_type,parameters=data.get("parameters", {}),- nodes=data.get("nodes", []), edges=data.get("edges", []),+ nodes=data.get("nodes", []),+ edges=data.get("edges", []),session_id=data.get("session_id", "default"),workflow_id=workflow_id,)@@ -941,8 +956,14 @@ async def handle_execute_ai_node(data: Dict[str, Any], websocket: WebSocket) ->finally:await broadcaster.workflow_run_ended(workflow_id)- return {"success": result.get("success", False), "node_id": node_id, "result": result.get("result"), "error": result.get("error"),- "execution_time": result.get("execution_time"), "timestamp": time.time()}+ return {+ "success": result.get("success", False),+ "node_id": node_id,+ "result": result.get("result"),+ "error": result.get("error"),+ "execution_time": result.get("execution_time"),+ "timestamp": time.time(),+ }@ws_handler("provider", "api_key")@@ -972,6 +993,7 @@ async def handle_get_ai_models(data: Dict[str, Any], websocket: WebSocket) -> Di# Chat Message Handler (for chatTrigger nodes)# ============================================================================+@ws_handler("message")async def handle_send_chat_message(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Handle chat message from console panel - dispatches to chatTrigger nodes.@@ -995,11 +1017,7 @@ async def handle_send_chat_message(data: Dict[str, Any], websocket: WebSocket) -await database.add_chat_message(session_id, role, message)# Build event data matching chatTrigger output schema- event_data = {- "message": message,- "timestamp": timestamp,- "session_id": session_id- }+ event_data = {"message": message, "timestamp": timestamp, "session_id": session_id}# Dispatch via canary CloudEvents path — Visibility-query Signal# fan-out to running TriggerListenerWorkflow consumers + in-process@@ -1008,11 +1026,7 @@ async def handle_send_chat_message(data: Dict[str, Any], websocket: WebSocket) -logger.info(f"[ChatMessage] Dispatched canary event for session={session_id}")- return {- "success": True,- "message": "Chat message sent",- "timestamp": timestamp- }+ return {"success": True, "message": "Chat message sent", "timestamp": timestamp}@ws_handler()@@ -1024,11 +1038,7 @@ async def handle_get_chat_messages(data: Dict[str, Any], websocket: WebSocket) -database = container.database()messages = await database.get_chat_messages(session_id, limit)- return {- "success": True,- "messages": messages,- "session_id": session_id- }+ return {"success": True, "messages": messages, "session_id": session_id}@ws_handler()@@ -1039,11 +1049,7 @@ async def handle_clear_chat_messages(data: Dict[str, Any], websocket: WebSocket)database = container.database()count = await database.clear_chat_messages(session_id)- return {- "success": True,- "message": f"Cleared {count} chat messages",- "cleared_count": count- }+ return {"success": True, "message": f"Cleared {count} chat messages", "cleared_count": count}@ws_handler()@@ -1082,17 +1088,18 @@ async def handle_clear_console_logs(data: Dict[str, Any], websocket: WebSocket)if "console_logs" in broadcaster._status:if workflow_id:broadcaster._status["console_logs"] = [- log for log in broadcaster._status["console_logs"]- if log.get("workflow_id") != workflow_id+ log for log in broadcaster._status["console_logs"] if log.get("workflow_id") != workflow_id]else:broadcaster._status["console_logs"] = []# Tell connected clients to drop their local copy for this scope.- await broadcaster.broadcast({- "type": "console_logs_cleared",- "workflow_id": workflow_id,- })+ await broadcaster.broadcast(+ {+ "type": "console_logs_cleared",+ "workflow_id": workflow_id,+ }+ )return {"success": True,@@ -1112,10 +1119,7 @@ async def handle_save_chat_message(data: Dict[str, Any], websocket: WebSocket) -database = container.database()success = await database.add_chat_message(session_id, role, message)- return {- "success": success,- "message": "Chat message saved" if success else "Failed to save chat message"- }+ return {"success": success, "message": "Chat message saved" if success else "Failed to save chat message"}@ws_handler()@@ -1124,16 +1128,14 @@ async def handle_get_chat_sessions(data: Dict[str, Any], websocket: WebSocket) -database = container.database()sessions = await database.get_chat_sessions()- return {- "success": True,- "sessions": sessions- }+ return {"success": True, "sessions": sessions}# ============================================================================# Terminal Logs Handlers# ============================================================================+@ws_handler()async def handle_get_terminal_logs(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Get terminal log history."""@@ -1154,10 +1156,12 @@ async def handle_clear_terminal_logs(data: Dict[str, Any], websocket: WebSocket)# Process Manager Handlers# =============================================================================+@ws_handler()async def handle_process_list(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""List running processes."""from services.process_service import get_process_service+svc = get_process_service()workflow_id = data.get("workflow_id", "default")return {"success": True, "processes": svc.list_processes(workflow_id), "max_processes": svc.max_processes}@@ -1167,6 +1171,7 @@ async def handle_process_list(data: Dict[str, Any], websocket: WebSocket) -> Dicasync def handle_process_get_output(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Get output from a process's log file."""from services.process_service import get_process_service+name = data["name"]workflow_id = data.get("workflow_id", "default")stream = data.get("stream", "stdout")@@ -1179,6 +1184,7 @@ async def handle_process_get_output(data: Dict[str, Any], websocket: WebSocket)async def handle_process_send_input(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Send stdin text to a running process."""from services.process_service import get_process_service+name = data["name"]text = data["text"]workflow_id = data.get("workflow_id", "default")@@ -1217,6 +1223,7 @@ async def handle_process_send_input(data: Dict[str, Any], websocket: WebSocket)async def handle_get_node_allowlist(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Return the node allowlist that controls which nodes appear in the palette."""from services.node_allowlist import get_node_allowlist_service+return get_node_allowlist_service().get_config()@@ -1240,10 +1247,12 @@ async def handle_get_node_allowlist(data: Dict[str, Any], websocket: WebSocket)# Model Registry Handlers# ============================================================================+@ws_handler()async def handle_get_model_constraints(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Get model constraints (max_output_tokens, temperature range, thinking support, etc.)."""from services.model_registry import get_model_registry+registry = get_model_registry()model = data.get("model", "")provider = data.get("provider", "")@@ -1257,6 +1266,7 @@ async def handle_get_model_constraints(data: Dict[str, Any], websocket: WebSockeasync def handle_refresh_model_registry(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Force refresh model registry from OpenRouter."""from services.model_registry import get_model_registry+registry = get_model_registry()try:count = await registry.refresh()@@ -1297,19 +1307,16 @@ MESSAGE_HANDLERS: Dict[str, MessageHandler] = {# get_android_status moved to nodes/android/_handlers.py (Wave 13.9)"get_node_status": handle_get_node_status,"get_variable": handle_get_variable,-# Node parameters"get_node_parameters": handle_get_node_parameters,"get_all_node_parameters": handle_get_all_node_parameters,"save_node_parameters": handle_save_node_parameters,"delete_node_parameters": handle_delete_node_parameters,-# Tool schemas (source of truth for tool configurations)"get_tool_schema": handle_get_tool_schema,"save_tool_schema": handle_save_tool_schema,"delete_tool_schema": handle_delete_tool_schema,"get_all_tool_schemas": handle_get_all_tool_schemas,-# Node output schemas (Pydantic-backed registry; see# docs-internal/schema_source_of_truth_rfc.md)."get_node_output_schema": handle_get_node_output_schema,@@ -1321,10 +1328,8 @@ MESSAGE_HANDLERS: Dict[str, MessageHandler] = {"list_load_options_methods": handle_list_load_options_methods,# Wave 6 Phase 5: node-groups index (replaces *_NODE_TYPES helpers)."get_node_groups": handle_get_node_groups,-# Credential registry (Nango-style bulk catalogue for credentials panel)"get_credential_catalogue": handle_get_credential_catalogue,-# Node execution"execute_node": handle_execute_node,"execute_workflow": handle_execute_workflow,@@ -1333,11 +1338,9 @@ MESSAGE_HANDLERS: Dict[str, MessageHandler] = {"get_workflow_status": handle_get_workflow_status,"get_node_output": handle_get_node_output,"clear_node_output": handle_clear_node_output,-# Trigger/event waiting"cancel_event_wait": handle_cancel_event_wait,"get_active_waiters": handle_get_active_waiters,-# Dead Letter Queue (DLQ) operations"get_dlq_entries": handle_get_dlq_entries,"get_dlq_entry": handle_get_dlq_entry,@@ -1345,17 +1348,13 @@ MESSAGE_HANDLERS: Dict[str, MessageHandler] = {"replay_dlq_entry": handle_replay_dlq_entry,"remove_dlq_entry": handle_remove_dlq_entry,"purge_dlq": handle_purge_dlq,-# Deployment operations — extracted to services/deployment/handlers.py# (Wave 13.2); registered via ws_handler_registry on package import.-# AI operations"execute_ai_node": handle_execute_ai_node,"get_ai_models": handle_get_ai_models,-# API key operations — extracted to services/credentials/handlers.py# (Wave 13.5); registered via ws_handler_registry on package import.-# Claude/Codex login handlers live in the plugin folders + framework:# - ``claude_code_login`` / ``claude_code_logout`` registered by# ``nodes/agent/claude_code_agent/__init__.py``.@@ -1363,88 +1362,61 @@ MESSAGE_HANDLERS: Dict[str, MessageHandler] = {# ``services/cli_agent/__init__.py``.# Both go through ``services.ws_handler_registry``; nothing to# mount in MESSAGE_HANDLERS here.-# Twitter OAuth operations-# Google Workspace OAuth operations-# Android operations-# Maps + Apify validation now flow through ``handle_validate_api_key``# (which dispatches via ``CREDENTIAL_REGISTRY`` to# ``GoogleMapsCredential._probe`` / ``ApifyCredential._probe``).# The legacy ``validate_maps_key`` / ``validate_apify_key`` WS message# types are no longer needed — the frontend already uses# ``validate_api_key`` for all providers.-# WhatsApp operations-# Telegram operations live in nodes/telegram/_handlers.py and# self-register via services.ws_handler_registry. Dispatch hits them# via _resolve_handler() defined above.-# Workflow storage operations — extracted to services/workflow_storage/handlers.py# (Wave 13.7); registered via ws_handler_registry on package import.-# Chat message (for chatTrigger nodes)"send_chat_message": handle_send_chat_message,"get_chat_messages": handle_get_chat_messages,"clear_chat_messages": handle_clear_chat_messages,"save_chat_message": handle_save_chat_message,-# Console logs (for Console nodes)"get_console_logs": handle_get_console_logs,"clear_console_logs": handle_clear_console_logs,-# Terminal logs"get_terminal_logs": handle_get_terminal_logs,"clear_terminal_logs": handle_clear_terminal_logs,-# Process Manager"process_list": handle_process_list,"process_get_output": handle_process_get_output,"process_send_input": handle_process_send_input,-# User Skills + Built-in Skill Content + Memory/Reset — extracted to# services/skills/handlers.py (Wave 13.1); register via the shared# ws_handler_registry on package import. No entries below.-# User Settings + Provider Defaults + Compaction + Provider Usage Summary# — extracted to services/settings/handlers.py (Wave 13.3); register# via ws_handler_registry on package import.-# Pricing Config — extracted to services/pricing_handlers.py (Wave 13.8);# registered via ws_handler_registry on package import.-# Node Allowlist (UI palette filter)"get_node_allowlist": handle_get_node_allowlist,-# Model Registry"get_model_constraints": handle_get_model_constraints,"refresh_model_registry": handle_refresh_model_registry,-# Agent Teams — extracted to services/agent_teams/handlers.py (Wave 13.4);# registered via ws_handler_registry on package import.}-async def _execute_handler(- handler: MessageHandler,- data: Dict[str, Any],- websocket: WebSocket,- msg_type: str,- request_id: Optional[str]-):+async def _execute_handler(handler: MessageHandler, data: Dict[str, Any], websocket: WebSocket, msg_type: str, request_id: Optional[str]):"""Execute handler and send response using safe send."""try:result = await handler(data, websocket)if request_id:- await _safe_send(websocket, {- "type": f"{msg_type}_result",- "request_id": request_id,- **result- })+ await _safe_send(websocket, {"type": f"{msg_type}_result", "request_id": request_id, **result})else:await _safe_send(websocket, result)@@ -1455,12 +1427,7 @@ async def _execute_handler(except Exception as e:logger.error("Handler error", msg_type=msg_type, error=str(e))if request_id:- await _safe_send(websocket, {- "type": f"{msg_type}_result",- "request_id": request_id,- "success": False,- "error": str(e)- })+ await _safe_send(websocket, {"type": f"{msg_type}_result", "request_id": request_id, "success": False, "error": str(e)})@router.websocket("/ws/status")@@ -1482,7 +1449,7 @@ async def websocket_status_endpoint(websocket: WebSocket):settings = container.settings()# Check if auth is disabled (VITE_AUTH_ENABLED=false)- auth_disabled = settings.vite_auth_enabled and settings.vite_auth_enabled.lower() == 'false'+ auth_disabled = settings.vite_auth_enabled and settings.vite_auth_enabled.lower() == "false"if not auth_disabled:# Auth enabled - verify token@@ -1546,20 +1513,21 @@ async def websocket_status_endpoint(websocket: WebSocket):if handler:# Run handler as task so it doesn't block queue processing# This allows cancel_event_wait to be processed while execute_node is waiting- task = asyncio.create_task(- _execute_handler(handler, data, websocket, msg_type, request_id)- )+ task = asyncio.create_task(_execute_handler(handler, data, websocket, msg_type, request_id))handler_tasks.add(task)task.add_done_callback(handler_tasks.discard)else:logger.warning("Unknown message type", msg_type=msg_type)if request_id:- await _safe_send(websocket, {- "type": "error",- "request_id": request_id,- "code": "UNKNOWN_MESSAGE_TYPE",- "message": f"Unknown message type: {msg_type}"- })+ await _safe_send(+ websocket,+ {+ "type": "error",+ "request_id": request_id,+ "code": "UNKNOWN_MESSAGE_TYPE",+ "message": f"Unknown message type: {msg_type}",+ },+ )try:# Run receive and process loops concurrently using TaskGroup (Python 3.11+)@@ -1642,20 +1610,21 @@ async def websocket_internal_endpoint(websocket: WebSocket):handler = _resolve_handler(msg_type)if handler:- task = asyncio.create_task(- _execute_handler(handler, data, websocket, msg_type, request_id)- )+ task = asyncio.create_task(_execute_handler(handler, data, websocket, msg_type, request_id))handler_tasks.add(task)task.add_done_callback(handler_tasks.discard)else:logger.warning(f"[WebSocket Internal] Unknown message type: {msg_type}")if request_id:- await _safe_send(websocket, {- "type": "error",- "request_id": request_id,- "code": "UNKNOWN_MESSAGE_TYPE",- "message": f"Unknown message type: {msg_type}"- })+ await _safe_send(+ websocket,+ {+ "type": "error",+ "request_id": request_id,+ "code": "UNKNOWN_MESSAGE_TYPE",+ "message": f"Unknown message type: {msg_type}",+ },+ )try:async with asyncio.TaskGroup() as tg:@@ -1689,7 +1658,5 @@ async def websocket_info():"endpoint": "/ws/status","connected_clients": broadcaster.connection_count,"current_status": broadcaster.get_status(),- "supported_message_types": sorted(- set(MESSAGE_HANDLERS.keys()) | set(get_ws_handlers().keys())- ),+ "supported_message_types": sorted(set(MESSAGE_HANDLERS.keys()) | set(get_ws_handlers().keys())),}diff --git a/server/routers/workflow.py b/server/routers/workflow.pyindex ad1bd2c4..41e5a5b6 100644--- a/server/routers/workflow.py+++ b/server/routers/workflow.py@@ -24,19 +24,14 @@ class WorkflowExecutionRequest(BaseModel):@router.post("/execute-node")async def execute_workflow_node(- request: WorkflowExecutionRequest,- workflow_service: WorkflowService = Depends(lambda: container.workflow_service())+ request: WorkflowExecutionRequest, workflow_service: WorkflowService = Depends(lambda: container.workflow_service())):"""Execute a single node in a workflow with parameter resolution."""logger.debug(f"[DEBUG ROUTER] Received execution request: node_id={request.node_id}, node_type={request.node_type}")# Get broadcaster and send "executing" statusbroadcaster = get_status_broadcaster()- await broadcaster.update_node_status(- node_id=request.node_id,- status="executing",- data={"node_type": request.node_type}- )+ await broadcaster.update_node_status(node_id=request.node_id, status="executing", data={"node_type": request.node_type})try:result = await workflow_service.execute_node(@@ -45,7 +40,7 @@ async def execute_workflow_node(parameters=request.parameters,nodes=request.nodes,edges=request.edges,- session_id=request.session_id+ session_id=request.session_id,)# Broadcast completion status based on result@@ -53,26 +48,14 @@ async def execute_workflow_node(await broadcaster.update_node_status(node_id=request.node_id,status="success",- data={- "node_type": request.node_type,- "execution_time": result.get("execution_time"),- "result": result.get("result")- }+ data={"node_type": request.node_type, "execution_time": result.get("execution_time"), "result": result.get("result")},)# Also broadcast the outputif result.get("result"):- await broadcaster.update_node_output(- node_id=request.node_id,- output=result.get("result")- )+ await broadcaster.update_node_output(node_id=request.node_id, output=result.get("result"))else:await broadcaster.update_node_status(- node_id=request.node_id,- status="error",- data={- "node_type": request.node_type,- "error": result.get("error")- }+ node_id=request.node_id, status="error", data={"node_type": request.node_type, "error": result.get("error")})return result@@ -80,12 +63,7 @@ async def execute_workflow_node(except Exception as e:# Broadcast error statusawait broadcaster.update_node_status(- node_id=request.node_id,- status="error",- data={- "node_type": request.node_type,- "error": str(e)- }+ node_id=request.node_id, status="error", data={"node_type": request.node_type, "error": str(e)})raise@@ -95,7 +73,7 @@ async def get_workflow_node_output(node_id: str,output_name: str = "output_0",session_id: str = "default",- workflow_service: WorkflowService = Depends(lambda: container.workflow_service())+ workflow_service: WorkflowService = Depends(lambda: container.workflow_service()),):"""Get stored output data for a node."""return await workflow_service.get_workflow_node_output(node_id, output_name, session_id)@@ -103,35 +81,26 @@ async def get_workflow_node_output(@router.delete("/clear-outputs")async def clear_workflow_outputs(- session_id: str = "default",- workflow_service: WorkflowService = Depends(lambda: container.workflow_service())+ session_id: str = "default", workflow_service: WorkflowService = Depends(lambda: container.workflow_service())):"""Clear all stored node outputs for a session."""try:await workflow_service.clear_all_outputs(session_id)- return {- "success": True,- "message": f"Cleared all outputs for session: {session_id}"- }+ return {"success": True, "message": f"Cleared all outputs for session: {session_id}"}except Exception as e:logger.error("Failed to clear outputs", session_id=session_id, error=str(e))- return {- "success": False,- "error": str(e)- }+ return {"success": False, "error": str(e)}@router.get("/health")async def workflow_health_check():"""Workflow service health check."""- return {- "status": "OK",- "service": "workflow"- }+ return {"status": "OK", "service": "workflow"}class TemporalNodeExecuteRequest(BaseModel):"""Request from Temporal service to execute a single node."""+node_id: strnode_type: strdata: Dict[str, Any] = {}@@ -140,6 +109,7 @@ class TemporalNodeExecuteRequest(BaseModel):class BroadcastStatusRequest(BaseModel):"""Request to broadcast node status from Temporal activity."""+node_id: strstatus: strdata: Dict[str, Any] = {}@@ -168,8 +138,7 @@ async def broadcast_status_for_temporal(request: BroadcastStatusRequest):@router.post("/node/execute")async def execute_node_for_temporal(- request: TemporalNodeExecuteRequest,- workflow_service: WorkflowService = Depends(lambda: container.workflow_service())+ request: TemporalNodeExecuteRequest, workflow_service: WorkflowService = Depends(lambda: container.workflow_service())):"""Execute a single node - called by Temporal service.@@ -201,4 +170,4 @@ async def execute_node_for_temporal("Temporal endpoint node execution failed",node_id=request.node_id,)- raise\ No newline at end of file+ raisediff --git a/server/scripts/smoke_test_skills.py b/server/scripts/smoke_test_skills.pyindex 9f82a828..494aefef 100644--- a/server/scripts/smoke_test_skills.py+++ b/server/scripts/smoke_test_skills.py@@ -56,7 +56,8 @@ async def main() -> int:# Step 1 — materialise the skill into the workspace.added, removed = await materialise_skills(- workspace, [skill_under_test],+ workspace,+ [skill_under_test],previous_skill_names=None,log_label="smoke",)@@ -67,6 +68,7 @@ async def main() -> int:# Step 2 — build argv and check Skill is in --allowedTools.from services.cli_agent.factory import create_cli_provider+provider = create_cli_provider("claude")spec = ClaudeTaskSpec(prompt="Use the humanify-skill to format this list nicely: apples, bananas, cherries.",@@ -85,9 +87,7 @@ async def main() -> int:allowed_idx = argv.index("--allowedTools")allowed = argv[allowed_idx + 1].split(",")assert "Skill" in allowed, f"Skill missing from allowlist: {allowed}"- assert "--add-dir" in argv and str(workspace) in argv, (- f"workspace not in --add-dir argv: {argv}"- )+ assert "--add-dir" in argv and str(workspace) in argv, f"workspace not in --add-dir argv: {argv}"print(f"[smoke] step 2 PASS — argv has Skill in allowlist + --add-dir {workspace.name}")# Step 3 — spawn via the pool (cold spawn). Pool uses@@ -114,9 +114,11 @@ async def main() -> int:workspace_dir=workspace,workflow_id=workflow_id,)- print(f"[smoke] step 3 PASS — claude pid={pooled.process.pid}, "- f"workspace_dir bound, materialised_skills="- f"{set(pooled.materialised_skills)}")+ print(+ f"[smoke] step 3 PASS — claude pid={pooled.process.pid}, "+ f"workspace_dir bound, materialised_skills="+ f"{set(pooled.materialised_skills)}"+ )assert skill_under_test in pooled.materialised_skills# Step 4 — send a turn that should activate the skill.@@ -131,9 +133,11 @@ async def main() -> int:workflow_id=workflow_id,)assert result.success, f"turn failed: {result.error}"- print(f"[smoke] step 4 PASS — session_id={result.session_id}, "- f"cost=${result.cost_usd}, num_turns={result.num_turns}, "- f"duration_ms={result.duration_ms}")+ print(+ f"[smoke] step 4 PASS — session_id={result.session_id}, "+ f"cost=${result.cost_usd}, num_turns={result.num_turns}, "+ f"duration_ms={result.duration_ms}"+ )print("[smoke] response (first 400 chars):")print(f" {result.response[:400]!r}")@@ -157,8 +161,7 @@ async def main() -> int:response_lc = result.response.lower()for marker in error_markers:assert marker not in response_lc, (- f"response indicates skill not loaded: matched marker {marker!r}\n"- f"full response: {result.response[:1000]!r}"+ f"response indicates skill not loaded: matched marker {marker!r}\n" f"full response: {result.response[:1000]!r}")print("[smoke] step 5 PASS — response present, no 'skill not found' markers")diff --git a/server/services/__init__.py b/server/services/__init__.pyindex fea2895e..6203184d 100644--- a/server/services/__init__.py+++ b/server/services/__init__.py@@ -1 +1 @@-# Business logic services\ No newline at end of file+# Business logic servicesdiff --git a/server/services/_supervisor/process.py b/server/services/_supervisor/process.pyindex 942b1dc0..e20e9b53 100644--- a/server/services/_supervisor/process.py+++ b/server/services/_supervisor/process.py@@ -96,7 +96,9 @@ class BaseProcessSupervisor(BaseSupervisor):self._proc = await anyio.open_process(argv, **kwargs)self._logger.info("[%s] spawned pid=%s binary=%s",- self.label, self._proc.pid, binary,+ self.label,+ self._proc.pid,+ binary,)if self.pipe_streams:diff --git a/server/services/_supervisor/registry.py b/server/services/_supervisor/registry.pyindex 715a87e2..78c54202 100644--- a/server/services/_supervisor/registry.py+++ b/server/services/_supervisor/registry.py@@ -30,8 +30,7 @@ def register_supervisor(supervisor: BaseSupervisor) -> None:returnif existing is not None:raise ValueError(- f"Supervisor label '{label}' already registered "- f"({existing.__class__.__name__} vs {supervisor.__class__.__name__})"+ f"Supervisor label '{label}' already registered " f"({existing.__class__.__name__} vs {supervisor.__class__.__name__})")_SUPERVISORS[label] = supervisor@@ -54,7 +53,8 @@ async def shutdown_all_supervisors() -> None:except Exception as exc:logger.warning("[supervisor] %s shutdown failed: %s",- supervisor.label, exc,+ supervisor.label,+ exc,)diff --git a/server/services/agent_team.py b/server/services/agent_team.pyindex debde760..7b7c3cfa 100644--- a/server/services/agent_team.py+++ b/server/services/agent_team.py@@ -29,11 +29,7 @@ class AgentTeamService:# -------------------------------------------------------------------------async def create_team(- self,- team_lead_node_id: str,- teammate_node_ids: List[Dict[str, Any]],- workflow_id: str,- config: Optional[Dict[str, Any]] = None+ self, team_lead_node_id: str, teammate_node_ids: List[Dict[str, Any]], workflow_id: str, config: Optional[Dict[str, Any]] = None) -> Optional[Dict[str, Any]]:"""Create a team with lead and teammates.@@ -50,20 +46,14 @@ class AgentTeamService:# Create teamteam = await self.database.create_team(- team_id=team_id,- workflow_id=workflow_id,- team_lead_node_id=team_lead_node_id,- config=config or {"mode": "parallel"}+ team_id=team_id, workflow_id=workflow_id, team_lead_node_id=team_lead_node_id, config=config or {"mode": "parallel"})if not team:return None# Add team lead as memberawait self.database.add_team_member(- team_id=team_id,- agent_node_id=team_lead_node_id,- agent_type="orchestrator_agent",- role="team_lead"+ team_id=team_id, agent_node_id=team_lead_node_id, agent_type="orchestrator_agent", role="team_lead")# Add teammates@@ -73,16 +63,14 @@ class AgentTeamService:agent_node_id=teammate["node_id"],agent_type=teammate.get("node_type", "agent"),agent_label=teammate.get("label"),- role="teammate"+ role="teammate",)# Broadcast team creationif self.broadcaster:- await self.broadcaster.broadcast_team_event(team_id, "team_created", {- "team_id": team_id,- "workflow_id": workflow_id,- "member_count": len(teammate_node_ids) + 1- })+ await self.broadcaster.broadcast_team_event(+ team_id, "team_created", {"team_id": team_id, "workflow_id": workflow_id, "member_count": len(teammate_node_ids) + 1}+ )# Track active team for this workflowself._active_teams[workflow_id] = team_id@@ -120,7 +108,7 @@ class AgentTeamService:created_by: str,description: Optional[str] = None,priority: int = 3,- depends_on: Optional[List[str]] = None+ depends_on: Optional[List[str]] = None,) -> Optional[Dict[str, Any]]:"""Add a task to the shared task list."""task_id = f"task_{uuid.uuid4().hex[:12]}"@@ -132,7 +120,7 @@ class AgentTeamService:created_by=created_by,description=description,priority=priority,- depends_on=depends_on+ depends_on=depends_on,)if task and self.broadcaster:@@ -148,9 +136,7 @@ class AgentTeamService:task = await self.database.claim_task(task_id, agent_node_id)if task and self.broadcaster:- await self.broadcaster.broadcast_team_event(team_id, "task_claimed", {- **task, "claimed_by": agent_node_id- })+ await self.broadcaster.broadcast_team_event(team_id, "task_claimed", {**task, "claimed_by": agent_node_id})return task@@ -168,9 +154,7 @@ class AgentTeamService:await self.database.update_member_status(team_id, task["assigned_to"], "idle")if self.broadcaster:- await self.broadcaster.broadcast_team_event(team_id, "task_completed", {- "task_id": task_id, "result": result- })+ await self.broadcaster.broadcast_team_event(team_id, "task_completed", {"task_id": task_id, "result": result})return success@@ -186,9 +170,7 @@ class AgentTeamService:await self.database.update_member_status(team_id, task["assigned_to"], "idle")if self.broadcaster:- await self.broadcaster.broadcast_team_event(team_id, "task_failed", {- "task_id": task_id, "error": error- })+ await self.broadcaster.broadcast_team_event(team_id, "task_failed", {"task_id": task_id, "error": error})return success@@ -208,12 +190,7 @@ class AgentTeamService:# -------------------------------------------------------------------------async def send_message(- self,- team_id: str,- from_agent: str,- content: str,- to_agent: Optional[str] = None,- message_type: str = "direct"+ self, team_id: str, from_agent: str, content: str, to_agent: Optional[str] = None, message_type: str = "direct") -> Optional[Dict[str, Any]]:"""Send a message to a specific agent or broadcast."""msg = await self.database.add_agent_message(@@ -221,7 +198,7 @@ class AgentTeamService:from_agent=from_agent,content=content,message_type=message_type if to_agent else "broadcast",- to_agent=to_agent+ to_agent=to_agent,)if msg and self.broadcaster:@@ -233,12 +210,7 @@ class AgentTeamService:"""Broadcast message to all team members."""return await self.send_message(team_id, from_agent, content, to_agent=None)- async def get_messages(- self,- team_id: str,- agent_node_id: Optional[str] = None,- unread_only: bool = False- ) -> List[Dict[str, Any]]:+ async def get_messages(self, team_id: str, agent_node_id: Optional[str] = None, unread_only: bool = False) -> List[Dict[str, Any]]:"""Get messages for a team or specific agent."""return await self.database.get_agent_messages(team_id, agent_node_id, unread_only)diff --git a/server/services/ai.py b/server/services/ai.pyindex 4b09face..a58f4c38 100644--- a/server/services/ai.py+++ b/server/services/ai.py@@ -56,6 +56,7 @@ if TYPE_CHECKING:def _get_chat_anthropic() -> Type:"""Lazy import: ``langchain_anthropic`` is ~800ms cold."""from langchain_anthropic import ChatAnthropic+return ChatAnthropic@@ -63,6 +64,7 @@ def _get_chat_anthropic() -> Type:def _get_chat_groq() -> Type:"""Lazy import: ``langchain_groq`` adds ~270ms cold."""from langchain_groq import ChatGroq+return ChatGroq@@ -75,6 +77,7 @@ def _get_chat_cerebras() -> Optional[Type]:"""try:from langchain_cerebras import ChatCerebras+return ChatCerebrasexcept ImportError:return None@@ -84,6 +87,7 @@ def _get_chat_cerebras() -> Optional[Type]:@functools.cachedef _get_google_genai_class() -> Type:from langchain_google_genai import ChatGoogleGenerativeAI+return ChatGoogleGenerativeAI@@ -119,6 +123,7 @@ def __getattr__(name: str):return get_provider_configs()raise AttributeError(f"module {__name__!r} has no attribute {name!r}")+from core.config import Settingsfrom core.logging import get_logger, log_execution_time, log_api_callfrom services.auth import AuthService@@ -144,6 +149,7 @@ from services.llm.config import (# MARKDOWN MEMORY HELPERS - Parse/append/trim conversation markdown# =============================================================================+def _parse_memory_markdown(content: str) -> List[BaseMessage]:"""Parse markdown memory content into LangChain messages.@@ -155,12 +161,13 @@ def _parse_memory_markdown(content: str) -> List[BaseMessage]:response content"""from langchain_core.messages import HumanMessage, AIMessage+messages = []- pattern = r'### \*\*(Human|Assistant)\*\*[^\n]*\n(.*?)(?=\n### \*\*|$)'+ pattern = r"### \*\*(Human|Assistant)\*\*[^\n]*\n(.*?)(?=\n### \*\*|$)"for role, text in re.findall(pattern, content, re.DOTALL):text = text.strip()if text:- msg_class = HumanMessage if role == 'Human' else AIMessage+ msg_class = HumanMessage if role == "Human" else AIMessagemessages.append(msg_class(content=text))return messages@@ -184,19 +191,19 @@ def _trim_markdown_window(content: str, window_size: int) -> tuple:Returns:Tuple of (trimmed markdown, list of removed message texts for archival)"""- pattern = r'(### \*\*(Human|Assistant)\*\*[^\n]*\n.*?)(?=\n### \*\*|$)'+ pattern = r"(### \*\*(Human|Assistant)\*\*[^\n]*\n.*?)(?=\n### \*\*|$)"blocks = [m[0] for m in re.findall(pattern, content, re.DOTALL)]if len(blocks) <= window_size * 2:return content, []- keep = blocks[-(window_size * 2):]- removed = blocks[:-(window_size * 2)]+ keep = blocks[-(window_size * 2) :]+ removed = blocks[: -(window_size * 2)]# Extract text from removed blocks for vector storageremoved_texts = []for block in removed:- match = re.search(r'\n(.*)$', block, re.DOTALL)+ match = re.search(r"\n(.*)$", block, re.DOTALL)if match:removed_texts.append(match.group(1).strip())@@ -227,9 +234,11 @@ def _get_memory_vector_store(session_id: str):# AI PROVIDER REGISTRY - Single source of truth for provider configurations# =============================================================================+@dataclassclass ProviderConfig:"""Configuration for an AI provider."""+name: strmodel_class: Optional[Type]api_key_param: str # Parameter name for API key in model constructor@@ -238,7 +247,7 @@ class ProviderConfig:default_model: str # Default model when none specifiedmodels_endpoint: str # API endpoint to fetch modelsmodels_header_fn: Callable[[str], dict] # Function to create headers- base_url: str = '' # Custom base URL for OpenAI-compatible providers+ base_url: str = "" # Custom base URL for OpenAI-compatible providersextra_headers: Optional[Dict[str, str]] = None # Default headers for API callssupported_params: Optional[List[str]] = None # API-supported params (from llm_defaults.json)@@ -254,19 +263,20 @@ class ThinkingConfig:- Gemini 2.5: thinking_budget (int tokens)- Groq: reasoning_format ('parsed', 'hidden')"""+enabled: bool = False- budget: int = 2048 # Token budget (Claude, Gemini 2.5)- effort: str = 'medium' # Effort level: 'minimal', 'low', 'medium', 'high' (OpenAI o-series)- level: str = 'medium' # Thinking level: 'low', 'medium', 'high' (Gemini 3+)- format: str = 'parsed' # Output format: 'parsed', 'hidden' (Groq)+ budget: int = 2048 # Token budget (Claude, Gemini 2.5)+ effort: str = "medium" # Effort level: 'minimal', 'low', 'medium', 'high' (OpenAI o-series)+ level: str = "medium" # Thinking level: 'low', 'medium', 'high' (Gemini 3+)+ format: str = "parsed" # Output format: 'parsed', 'hidden' (Groq)def _openai_headers(api_key: str) -> dict:- return {'Authorization': f'Bearer {api_key}'}+ return {"Authorization": f"Bearer {api_key}"}def _anthropic_headers(api_key: str) -> dict:- return {'x-api-key': api_key, 'anthropic-version': '2023-06-01'}+ return {"x-api-key": api_key, "anthropic-version": "2023-06-01"}def _gemini_headers(api_key: str) -> dict:@@ -274,24 +284,20 @@ def _gemini_headers(api_key: str) -> dict:def _openrouter_headers(api_key: str) -> dict:- return {- 'Authorization': f'Bearer {api_key}',- 'HTTP-Referer': 'http://localhost:3000',- 'X-Title': 'MachinaOS'- }+ return {"Authorization": f"Bearer {api_key}", "HTTP-Referer": "http://localhost:3000", "X-Title": "MachinaOS"}def _groq_headers(api_key: str) -> dict:- return {'Authorization': f'Bearer {api_key}'}+ return {"Authorization": f"Bearer {api_key}"}def _cerebras_headers(api_key: str) -> dict:- return {'Authorization': f'Bearer {api_key}'}+ return {"Authorization": f"Bearer {api_key}"}def _bearer_headers(api_key: str) -> dict:"""Generic Bearer auth headers for OpenAI-compatible providers."""- return {'Authorization': f'Bearer {api_key}'}+ return {"Authorization": f"Bearer {api_key}"}# Map of provider -> (model_class_factory, header_fn) for providers with custom@@ -302,16 +308,17 @@ def _bearer_headers(api_key: str) -> dict:# (or None for gemini, whose lazy resolver lives at the call site).def _build_provider_class_map() -> Dict[str, tuple]:from langchain_openai import ChatOpenAI+mapping: Dict[str, tuple] = {- 'openai': (ChatOpenAI, _openai_headers),- 'anthropic': (_get_chat_anthropic(), _anthropic_headers),- 'gemini': (None, _gemini_headers), # resolved via _get_google_genai_class()- 'openrouter': (ChatOpenAI, _openrouter_headers),- 'groq': (_get_chat_groq(), _groq_headers),+ "openai": (ChatOpenAI, _openai_headers),+ "anthropic": (_get_chat_anthropic(), _anthropic_headers),+ "gemini": (None, _gemini_headers), # resolved via _get_google_genai_class()+ "openrouter": (ChatOpenAI, _openrouter_headers),+ "groq": (_get_chat_groq(), _groq_headers),}cerebras_class = _get_chat_cerebras()if cerebras_class is not None:- mapping['cerebras'] = (cerebras_class, _cerebras_headers)+ mapping["cerebras"] = (cerebras_class, _cerebras_headers)return mapping@@ -319,9 +326,11 @@ def _build_provider_class_map() -> Dict[str, tuple]:# LLM DEFAULTS CONFIGURATION - Load from config/llm_defaults.json# =============================================================================+def _load_llm_defaults() -> Dict[str, Any]:"""Load LLM provider defaults from config/llm_defaults.json."""from pathlib import Path+config_path = Path(__file__).parent.parent / "config" / "llm_defaults.json"try:with open(config_path, encoding="utf-8") as f:@@ -347,10 +356,11 @@ def _resolve_max_tokens(flattened: dict, model: str, provider: str) -> int:When user doesn't set it, use the provider's default from llm_defaults.json."""from services.model_registry import get_model_registry+registry = get_model_registry()model_max = registry.get_max_output_tokens(model, provider)- user_val = flattened.get('max_tokens')+ user_val = flattened.get("max_tokens")if user_val:user_int = int(user_val)if user_int > model_max:@@ -372,9 +382,10 @@ def _resolve_temperature(flattened: dict, model: str, provider: str, thinking_en- Range clamping per provider"""from services.model_registry import get_model_registry+registry = get_model_registry()- user_val = flattened.get('temperature')+ user_val = flattened.get("temperature")if user_val is None:user_val = registry.get_agent_defaults()["default_temperature"]user_temp = float(user_val)@@ -386,7 +397,7 @@ def _resolve_temperature(flattened: dict, model: str, provider: str, thinking_enreturn 1.0# Claude thinking mode requires temperature=1- if thinking_enabled and provider == 'anthropic':+ if thinking_enabled and provider == "anthropic":if user_temp != 1:logger.info(f"[AI] Claude thinking mode: forcing temperature to 1 (was {user_temp})")return 1.0@@ -404,6 +415,7 @@ def _resolve_temperature(flattened: dict, model: str, provider: str, thinking_endef _build_provider_configs() -> Dict[str, ProviderConfig]:"""Build PROVIDER_CONFIGS from llm_defaults.json + provider-class map."""from langchain_openai import ChatOpenAI+providers = _LLM_DEFAULTS.get("providers", {})configs: Dict[str, ProviderConfig] = {}class_map = _build_provider_class_map()@@ -411,7 +423,7 @@ def _build_provider_configs() -> Dict[str, ProviderConfig]:for name, prov in providers.items():# Skip cerebras if not available- if name == 'cerebras' and not cerebras_available:+ if name == "cerebras" and not cerebras_available:logger.warning("Cerebras provider not available: langchain-cerebras package not installed (Python <3.13 only)")continue@@ -419,15 +431,15 @@ def _build_provider_configs() -> Dict[str, ProviderConfig]:configs[name] = ProviderConfig(name=name,model_class=model_class,- api_key_param=prov.get('api_key_param', 'api_key'),- max_tokens_param=prov.get('max_tokens_param', 'max_tokens'),- detection_patterns=tuple(prov.get('detection_patterns', [name])),- default_model=prov.get('default_model', ''),- models_endpoint=prov.get('models_endpoint', ''),+ api_key_param=prov.get("api_key_param", "api_key"),+ max_tokens_param=prov.get("max_tokens_param", "max_tokens"),+ detection_patterns=tuple(prov.get("detection_patterns", [name])),+ default_model=prov.get("default_model", ""),+ models_endpoint=prov.get("models_endpoint", ""),models_header_fn=header_fn,- base_url=prov.get('base_url', ''),- extra_headers=prov.get('extra_headers'),- supported_params=prov.get('supported_params'),+ base_url=prov.get("base_url", ""),+ extra_headers=prov.get("extra_headers"),+ supported_params=prov.get("supported_params"),)return configs@@ -450,7 +462,7 @@ def detect_provider_from_model(model: str) -> str:for provider_name, config in get_provider_configs().items():if any(pattern in model_lower for pattern in config.detection_patterns):return provider_name- return 'openai' # default+ return "openai" # defaultdef is_model_valid_for_provider(model: str, provider: str) -> bool:@@ -471,7 +483,7 @@ def is_model_valid_for_provider(model: str, provider: str) -> bool:as always-valid; the local-server SDK will reject genuinely missingmodels at request time with a clear 404."""- if provider in ('openrouter', 'ollama', 'lmstudio'):+ if provider in ("openrouter", "ollama", "lmstudio"):return Trueconfig = get_provider_configs().get(provider)if not config:@@ -483,7 +495,7 @@ def is_model_valid_for_provider(model: str, provider: str) -> bool:def get_default_model(provider: str) -> str:"""Get default model for a provider from JSON config."""config = get_provider_configs().get(provider)- return config.default_model if config else 'gpt-4o-mini'+ return config.default_model if config else "gpt-4o-mini"async def get_default_model_async(provider: str, database) -> str:@@ -508,6 +520,7 @@ async def get_default_model_async(provider: str, database) -> str:# MESSAGE FILTERING UTILITIES - Standardized for all providers# =============================================================================+def is_valid_message_content(content: Any) -> bool:"""Check if message content is valid (non-empty) for API calls.@@ -528,9 +541,7 @@ def is_valid_message_content(content: Any) -> bool:# Handle list content format (Gemini returns [{"type": "text", "text": "..."}])if isinstance(content, list):return any(- (isinstance(block, dict) and block.get('text', '').strip()) or- (isinstance(block, str) and block.strip())- for block in content+ (isinstance(block, dict) and block.get("text", "").strip()) or (isinstance(block, str) and block.strip()) for block in content)# Handle string content (most common)@@ -565,6 +576,7 @@ def filter_empty_messages(messages: List[BaseMessage]) -> List[BaseMessage]:Filtered list of messages with empty content removed"""from langchain_core.messages import AIMessage, SystemMessage, ToolMessage+filtered = []for m in messages:@@ -575,25 +587,24 @@ def filter_empty_messages(messages: List[BaseMessage]) -> List[BaseMessage]:# AIMessage with tool_calls - keep even if content is empty# (the tool calls themselves are the meaningful content)- if isinstance(m, AIMessage) and hasattr(m, 'tool_calls') and m.tool_calls:+ if isinstance(m, AIMessage) and hasattr(m, "tool_calls") and m.tool_calls:filtered.append(m)continue# SystemMessage - keep only if has non-empty contentif isinstance(m, SystemMessage):- if hasattr(m, 'content') and m.content and str(m.content).strip():+ if hasattr(m, "content") and m.content and str(m.content).strip():filtered.append(m)continue# HumanMessage and other message types - filter out empty content- if hasattr(m, 'content'):+ if hasattr(m, "content"):content = m.content# Handle list content format (Gemini returns [{"type": "text", "text": "..."}])if isinstance(content, list):has_content = any(- (isinstance(block, dict) and block.get('text', '').strip()) or- (isinstance(block, str) and block.strip())+ (isinstance(block, dict) and block.get("text", "").strip()) or (isinstance(block, str) and block.strip())for block in content)if has_content:@@ -629,13 +640,19 @@ def extract_thinking_from_response(response) -> tuple:thinking_parts = []logger.debug(f"[extract_thinking] Starting extraction, response type: {type(response).__name__}")- logger.debug(f"[extract_thinking] has content_blocks: {hasattr(response, 'content_blocks')}, value: {getattr(response, 'content_blocks', None)}")+ logger.debug(+ f"[extract_thinking] has content_blocks: {hasattr(response, 'content_blocks')}, value: {getattr(response, 'content_blocks', None)}"+ )logger.debug(f"[extract_thinking] has content: {hasattr(response, 'content')}, type: {type(getattr(response, 'content', None))}")- logger.debug(f"[extract_thinking] has additional_kwargs: {hasattr(response, 'additional_kwargs')}, value: {getattr(response, 'additional_kwargs', None)}")- logger.debug(f"[extract_thinking] has response_metadata: {hasattr(response, 'response_metadata')}, keys: {list(getattr(response, 'response_metadata', {}).keys()) if hasattr(response, 'response_metadata') else None}")+ logger.debug(+ f"[extract_thinking] has additional_kwargs: {hasattr(response, 'additional_kwargs')}, value: {getattr(response, 'additional_kwargs', None)}"+ )+ logger.debug(+ f"[extract_thinking] has response_metadata: {hasattr(response, 'response_metadata')}, keys: {list(getattr(response, 'response_metadata', {}).keys()) if hasattr(response, 'response_metadata') else None}"+ )# Use content_blocks API (LangChain 1.0+) for Claude/Gemini- if hasattr(response, 'content_blocks') and response.content_blocks:+ if hasattr(response, "content_blocks") and response.content_blocks:for block in response.content_blocks:if isinstance(block, dict):block_type = block.get("type", "")@@ -647,32 +664,32 @@ def extract_thinking_from_response(response) -> tuple:text_parts.append(block.get("text", ""))# Check additional_kwargs for reasoning_content (Groq, older OpenAI responses)- if not thinking_parts and hasattr(response, 'additional_kwargs'):- reasoning = response.additional_kwargs.get('reasoning_content')+ if not thinking_parts and hasattr(response, "additional_kwargs"):+ reasoning = response.additional_kwargs.get("reasoning_content")if reasoning:thinking_parts.append(reasoning)# Check response_metadata for OpenAI o-series reasoning (responses/v1 format)# The output array contains reasoning items with summaries- if not thinking_parts and hasattr(response, 'response_metadata'):+ if not thinking_parts and hasattr(response, "response_metadata"):metadata = response.response_metadata- output = metadata.get('output', [])+ output = metadata.get("output", [])if isinstance(output, list):for item in output:- if isinstance(item, dict) and item.get('type') == 'reasoning':- summary = item.get('summary', [])+ if isinstance(item, dict) and item.get("type") == "reasoning":+ summary = item.get("summary", [])if isinstance(summary, list):for s in summary:if isinstance(s, dict):# Handle both summary_text and text types- text = s.get('text', '')+ text = s.get("text", "")if text:thinking_parts.append(text)elif isinstance(s, str):thinking_parts.append(s)# Check raw content for OpenAI responses/v1 format and other list formats- if hasattr(response, 'content'):+ if hasattr(response, "content"):content = response.contentif isinstance(content, str):if not text_parts:@@ -680,39 +697,41 @@ def extract_thinking_from_response(response) -> tuple:elif isinstance(content, list):for block in content:if isinstance(block, dict):- block_type = block.get('type', '')- if block_type == 'text' or block_type == 'output_text':+ block_type = block.get("type", "")+ if block_type == "text" or block_type == "output_text":# Handle both 'text' and 'output_text' (responses/v1 format)if not text_parts: # Only add if not already extracted- text_parts.append(block.get('text', ''))- elif block_type == 'reasoning':+ text_parts.append(block.get("text", ""))+ elif block_type == "reasoning":# OpenAI responses/v1 format: reasoning block with summary array# Format: {"type": "reasoning", "summary": [{"type": "text", "text": "..."}, {"type": "summary_text", "text": "..."}]}- summary = block.get('summary', [])+ summary = block.get("summary", [])if isinstance(summary, list):for s in summary:if isinstance(s, dict):- s_type = s.get('type', '')- if s_type in ('text', 'summary_text'):- thinking_parts.append(s.get('text', ''))+ s_type = s.get("type", "")+ if s_type in ("text", "summary_text"):+ thinking_parts.append(s.get("text", ""))elif isinstance(s, str):thinking_parts.append(s)elif isinstance(summary, str):thinking_parts.append(summary)# Also check direct reasoning field- if block.get('reasoning'):- thinking_parts.append(block.get('reasoning', ''))- elif block_type == 'thinking':- thinking_parts.append(block.get('thinking', ''))+ if block.get("reasoning"):+ thinking_parts.append(block.get("reasoning", ""))+ elif block_type == "thinking":+ thinking_parts.append(block.get("thinking", ""))elif isinstance(block, str) and not text_parts:text_parts.append(block)- text = '\n'.join(filter(None, text_parts))- thinking = '\n'.join(filter(None, thinking_parts)) if thinking_parts else None+ text = "\n".join(filter(None, text_parts))+ thinking = "\n".join(filter(None, thinking_parts)) if thinking_parts else Nonelogger.debug(f"[extract_thinking] Final text_parts: {text_parts}")logger.debug(f"[extract_thinking] Final thinking_parts: {thinking_parts}")- logger.debug(f"[extract_thinking] Returning text={repr(text[:100] if text else None)}, thinking={repr(thinking[:100] if thinking else None)}")+ logger.debug(+ f"[extract_thinking] Returning text={repr(text[:100] if text else None)}, thinking={repr(thinking[:100] if thinking else None)}"+ )return text, thinking@@ -775,9 +794,7 @@ async def _run_agent_loop(_, new_thinking = extract_thinking_from_response(response)if new_thinking:if thinking_accumulated:- thinking_accumulated = (- f"{thinking_accumulated}\n\n--- Iteration {iteration} ---\n{new_thinking}"- )+ thinking_accumulated = f"{thinking_accumulated}\n\n--- Iteration {iteration} ---\n{new_thinking}"else:thinking_accumulated = new_thinking@@ -801,8 +818,7 @@ async def _run_agent_loop(if tool_executor is None:logger.warning(- "[Agent loop] LLM emitted %d tool_call(s) but no tool_executor "- "configured; treating response as final",+ "[Agent loop] LLM emitted %d tool_call(s) but no tool_executor " "configured; treating response as final",len(tool_calls),)return {@@ -821,24 +837,27 @@ async def _run_agent_loop(except Exception as e:logger.error(f"[Agent loop] Tool {tool_name!r} raised: {e}")result = {"error": str(e)}- messages.append(ToolMessage(- content=json.dumps(result, default=str),- tool_call_id=tool_id,- name=tool_name,- ))+ messages.append(+ ToolMessage(+ content=json.dumps(result, default=str),+ tool_call_id=tool_id,+ name=tool_name,+ )+ )# Loop exited without returning -- hit max_iterations. Append a# terminal AIMessage so downstream extraction (and post-loop token# tracking / memory persistence) still have a usable state.- messages.append(AIMessage(content=(- f"[Recursion limit reached: {max_iterations} iterations. "- f"Adjust agent.recursion_limit in llm_defaults.json or "- f"simplify the task.]"- )))- logger.warning(- f"[Agent loop] max_iterations hit ({max_iterations}); "- f"returning partial response with {len(messages)} message(s)"+ messages.append(+ AIMessage(+ content=(+ f"[Recursion limit reached: {max_iterations} iterations. "+ f"Adjust agent.recursion_limit in llm_defaults.json or "+ f"simplify the task.]"+ )+ ))+ logger.warning(f"[Agent loop] max_iterations hit ({max_iterations}); " f"returning partial response with {len(messages)} message(s)")return {"messages": messages,"iteration": iteration,@@ -874,12 +893,12 @@ def _build_skill_system_prompt(skill_data: List[Dict[str, Any]], log_prefix: strnon_personality_names = []for skill_info in skill_data:- skill_name = skill_info.get('skill_name') or skill_info.get('node_type', '').replace('Skill', '-skill').lower()- if skill_name.endswith('skill') and '-' not in skill_name:- skill_name = skill_name[:-5] + '-skill'+ skill_name = skill_info.get("skill_name") or skill_info.get("node_type", "").replace("Skill", "-skill").lower()+ if skill_name.endswith("skill") and "-" not in skill_name:+ skill_name = skill_name[:-5] + "-skill"- if skill_name.endswith('-personality'):- instructions = skill_info.get('parameters', {}).get('instructions', '')+ if skill_name.endswith("-personality"):+ instructions = skill_info.get("parameters", {}).get("instructions", "")if instructions:personality_blocks.append(instructions)logger.debug(f"{log_prefix} Personality skill injected (full): {skill_name}")@@ -900,7 +919,9 @@ def _build_skill_system_prompt(skill_data: List[Dict[str, Any]], log_prefix: strparts.append(registry_prompt)if parts:- logger.debug(f"{log_prefix} Enhanced system message: {len(personality_blocks)} personality, {len(non_personality_names)} standard skills")+ logger.debug(+ f"{log_prefix} Enhanced system message: {len(personality_blocks)} personality, {len(non_personality_names)} standard skills"+ )return "\n\n".join(parts), len(personality_blocks) > 0@@ -915,6 +936,7 @@ class AIService:self.settings = settings# RLM service (lazy import to avoid circular deps)from services.rlm import RLMService+self.rlm_service = RLMService(auth=self.auth)def detect_provider(self, model: str) -> str:@@ -944,13 +966,13 @@ class AIService:text_parts = []for block in content:if isinstance(block, dict):- if block.get('type') == 'text' and block.get('text'):- text_parts.append(block['text'])- elif 'text' in block:- text_parts.append(str(block['text']))+ if block.get("type") == "text" and block.get("text"):+ text_parts.append(block["text"])+ elif "text" in block:+ text_parts.append(str(block["text"]))elif isinstance(block, str):text_parts.append(block)- extracted = '\n'.join(text_parts)+ extracted = "\n".join(text_parts)if extracted.strip():return extracted# List was present but no text extracted@@ -961,51 +983,53 @@ class AIService:return content# LangChain standard: use content_blocks property for typed content extraction- if ai_response and hasattr(ai_response, 'content_blocks') and ai_response.content_blocks:+ if ai_response and hasattr(ai_response, "content_blocks") and ai_response.content_blocks:text_parts = []for block in ai_response.content_blocks:- if isinstance(block, dict) and block.get('type') == 'text':- text_parts.append(block.get('text', ''))- extracted = '\n'.join(filter(None, text_parts))+ if isinstance(block, dict) and block.get("type") == "text":+ text_parts.append(block.get("text", ""))+ extracted = "\n".join(filter(None, text_parts))if extracted.strip():return extracted# Content is empty - try to get error details from metadataerror_details = []- if ai_response and hasattr(ai_response, 'response_metadata'):+ if ai_response and hasattr(ai_response, "response_metadata"):meta = ai_response.response_metadata- finish_reason = meta.get('finish_reason', '')+ finish_reason = meta.get("finish_reason", "")- if finish_reason == 'SAFETY':+ if finish_reason == "SAFETY":error_details.append("Content blocked by safety filters")# Try to get specific blocked categories- safety_ratings = meta.get('safety_ratings', [])- blocked = [r.get('category') for r in safety_ratings if r.get('blocked')]+ safety_ratings = meta.get("safety_ratings", [])+ blocked = [r.get("category") for r in safety_ratings if r.get("blocked")]if blocked:error_details.append(f"Blocked categories: {', '.join(blocked)}")- elif finish_reason in ('MAX_TOKENS', 'length'):+ elif finish_reason in ("MAX_TOKENS", "length"):# Check if reasoning consumed all tokens (OpenAI o-series models)# OpenAI path: token_usage.completion_tokens_details.reasoning_tokens- token_usage = meta.get('token_usage', {})- completion_details = token_usage.get('completion_tokens_details', {})- reasoning_tokens = completion_details.get('reasoning_tokens', 0)- completion_tokens = token_usage.get('completion_tokens', 0)+ token_usage = meta.get("token_usage", {})+ completion_details = token_usage.get("completion_tokens_details", {})+ reasoning_tokens = completion_details.get("reasoning_tokens", 0)+ completion_tokens = token_usage.get("completion_tokens", 0)# Also check Gemini path: output_token_detailsif not reasoning_tokens:- token_details = meta.get('output_token_details', {})- reasoning_tokens = token_details.get('reasoning', 0)+ token_details = meta.get("output_token_details", {})+ reasoning_tokens = token_details.get("reasoning", 0)if reasoning_tokens > 0 and reasoning_tokens >= completion_tokens:- error_details.append(f"Model used all {reasoning_tokens} tokens for reasoning, none left for response. Increase max_tokens (current response used {completion_tokens} total).")+ error_details.append(+ f"Model used all {reasoning_tokens} tokens for reasoning, none left for response. Increase max_tokens (current response used {completion_tokens} total)."+ )else:error_details.append("Response truncated due to max_tokens limit")- elif finish_reason == 'MALFORMED_FUNCTION_CALL':+ elif finish_reason == "MALFORMED_FUNCTION_CALL":error_details.append("Model returned malformed function call. Tool schema may be incompatible.")- if meta.get('block_reason'):+ if meta.get("block_reason"):error_details.append(f"Block reason: {meta.get('block_reason')}")if error_details:@@ -1015,7 +1039,7 @@ class AIService:if ai_response:logger.warning(f"[Agent] Empty response debug - content_blocks: {getattr(ai_response, 'content_blocks', None)}")logger.warning(f"[Agent] Empty response debug - additional_kwargs: {getattr(ai_response, 'additional_kwargs', {})}")- if hasattr(ai_response, 'response_metadata'):+ if hasattr(ai_response, "response_metadata"):meta = ai_response.response_metadatalogger.warning(f"[Agent] Empty response debug - finish_reason: {meta.get('finish_reason')}")logger.warning(f"[Agent] Empty response debug - token_usage: {meta.get('token_usage')}")@@ -1065,30 +1089,26 @@ class AIService:# Extract usage_metadata from AIMessage (LangChain standardizes this)usage = None- if hasattr(ai_response, 'usage_metadata') and ai_response.usage_metadata:+ if hasattr(ai_response, "usage_metadata") and ai_response.usage_metadata:usage = ai_response.usage_metadata- elif hasattr(ai_response, 'response_metadata'):+ elif hasattr(ai_response, "response_metadata"):# Fallback: check response_metadata for usage infometa = ai_response.response_metadata- if 'usage' in meta:- usage = meta['usage']- elif 'token_usage' in meta:- usage = meta['token_usage']+ if "usage" in meta:+ usage = meta["usage"]+ elif "token_usage" in meta:+ usage = meta["token_usage"]if not usage:# Aggregate usage from all AI messages if single message has no usagetotal_input = 0total_output = 0for msg in all_messages:- if hasattr(msg, 'usage_metadata') and msg.usage_metadata:- total_input += msg.usage_metadata.get('input_tokens', 0)- total_output += msg.usage_metadata.get('output_tokens', 0)+ if hasattr(msg, "usage_metadata") and msg.usage_metadata:+ total_input += msg.usage_metadata.get("input_tokens", 0)+ total_output += msg.usage_metadata.get("output_tokens", 0)if total_input > 0 or total_output > 0:- usage = {- 'input_tokens': total_input,- 'output_tokens': total_output,- 'total_tokens': total_input + total_output- }+ usage = {"input_tokens": total_input, "output_tokens": total_output, "total_tokens": total_input + total_output}if not usage:logger.debug(f"[TokenTracking] No usage_metadata available for {provider}/{model}")@@ -1096,59 +1116,43 @@ class AIService:# Normalize usage dict (handle both dict and TypedDict formats)usage_dict = {- 'input_tokens': usage.get('input_tokens', 0) if isinstance(usage, dict) else getattr(usage, 'input_tokens', 0),- 'output_tokens': usage.get('output_tokens', 0) if isinstance(usage, dict) else getattr(usage, 'output_tokens', 0),- 'total_tokens': usage.get('total_tokens', 0) if isinstance(usage, dict) else getattr(usage, 'total_tokens', 0)+ "input_tokens": usage.get("input_tokens", 0) if isinstance(usage, dict) else getattr(usage, "input_tokens", 0),+ "output_tokens": usage.get("output_tokens", 0) if isinstance(usage, dict) else getattr(usage, "output_tokens", 0),+ "total_tokens": usage.get("total_tokens", 0) if isinstance(usage, dict) else getattr(usage, "total_tokens", 0),}try:- tracking = await svc.track(- session_id=session_id,- node_id=node_id,- provider=provider,- model=model,- usage=usage_dict- )+ tracking = await svc.track(session_id=session_id, node_id=node_id, provider=provider, model=model, usage=usage_dict)logger.debug(f"[TokenTracking] Tracked {usage_dict['total_tokens']} tokens for session {session_id}, total={tracking['total']}")# Broadcast token updateif broadcaster:- await broadcaster.broadcast({- "type": "token_usage_update",- "session_id": session_id,- "workflow_id": workflow_id,- "data": tracking- })+ await broadcaster.broadcast(+ {"type": "token_usage_update", "session_id": session_id, "workflow_id": workflow_id, "data": tracking}+ )# Trigger compaction if threshold exceeded- if tracking.get('needs_compaction') and memory_content and api_key:+ if tracking.get("needs_compaction") and memory_content and api_key:logger.info(f"[Compaction] Threshold exceeded for session {session_id}, triggering compaction")if broadcaster:- await broadcaster.broadcast({- "type": "compaction_starting",- "session_id": session_id,- "node_id": node_id- })+ await broadcaster.broadcast({"type": "compaction_starting", "session_id": session_id, "node_id": node_id})result = await svc.compact_context(- session_id=session_id,- node_id=node_id,- memory_content=memory_content,- provider=provider,- api_key=api_key,- model=model+ session_id=session_id, node_id=node_id, memory_content=memory_content, provider=provider, api_key=api_key, model=model)if broadcaster:- await broadcaster.broadcast({- "type": "compaction_completed",- "session_id": session_id,- "success": result.get("success", False),- "tokens_before": result.get("tokens_before", 0),- "tokens_after": result.get("tokens_after", 0),- "error": result.get("error")- })+ await broadcaster.broadcast(+ {+ "type": "compaction_completed",+ "session_id": session_id,+ "success": result.get("success", False),+ "tokens_before": result.get("tokens_before", 0),+ "tokens_after": result.get("tokens_after", 0),+ "error": result.get("error"),+ }+ )return result@@ -1157,10 +1161,16 @@ class AIService:return None- def create_model(self, provider: str, api_key: str, model: str,- temperature: float, max_tokens: int,- thinking: Optional[ThinkingConfig] = None,- proxy_url: Optional[str] = None):+ def create_model(+ self,+ provider: str,+ api_key: str,+ model: str,+ temperature: float,+ max_tokens: int,+ thinking: Optional[ThinkingConfig] = None,+ proxy_url: Optional[str] = None,+ ):"""Create LangChain model instance using provider registry.Args:@@ -1176,53 +1186,49 @@ class AIService:Configured LangChain chat model instance"""from langchain_openai import ChatOpenAI+config = get_provider_configs().get(provider)if not config:# Provide helpful error for Cerebras if import failed- if provider == 'cerebras' and not CEREBRAS_AVAILABLE:+ if provider == "cerebras" and not CEREBRAS_AVAILABLE:error_msg = f"Cerebras provider not available: {CEREBRAS_IMPORT_ERROR or 'langchain-cerebras package not installed'}"logger.error(error_msg)raise ValueError(error_msg)raise ValueError(f"Unsupported provider: {provider}")# Strip [FREE] prefix if present (added by OpenRouter model list for display)- if model.startswith('[FREE] '):+ if model.startswith("[FREE] "):model = model[7:]# Strip owner prefix for non-OpenRouter providers (e.g. "openai/gpt-oss-120b" → "gpt-oss-120b")- if provider != 'openrouter' and '/' in model:- model = model.split('/', 1)[-1]+ if provider != "openrouter" and "/" in model:+ model = model.split("/", 1)[-1]# Build kwargs dynamically from registry config- kwargs = {- config.api_key_param: api_key,- 'model': model,- 'temperature': temperature,- config.max_tokens_param: max_tokens- }+ kwargs = {config.api_key_param: api_key, "model": model, "temperature": temperature, config.max_tokens_param: max_tokens}# Proxy mode: route through local proxy that handles auth (Ollama pattern)# Proxy URL stored as {provider}_proxy credentialif proxy_url:- kwargs['base_url'] = proxy_url+ kwargs["base_url"] = proxy_urlkwargs[config.api_key_param] = "ollama" # Ollama-style tokenlogger.info(f"[AI] Using proxy for {provider}: {proxy_url}")# OpenAI-compatible providers: apply base_url + pass only supported params- elif config.base_url and config.model_class == ChatOpenAI and provider != 'openai':- kwargs['base_url'] = config.base_url+ elif config.base_url and config.model_class == ChatOpenAI and provider != "openai":+ kwargs["base_url"] = config.base_urlif config.extra_headers:- kwargs['default_headers'] = config.extra_headers+ kwargs["default_headers"] = config.extra_headers# LangChain ChatOpenAI converts max_tokens -> max_completion_tokens (OpenAI-specific).# Non-OpenAI providers reject this, so pass supported params via extra_body.del kwargs[config.max_tokens_param]- extra_body: Dict[str, Any] = {'max_tokens': max_tokens}+ extra_body: Dict[str, Any] = {"max_tokens": max_tokens}if config.supported_params:- if 'temperature' not in config.supported_params:- kwargs.pop('temperature', None)- if 'frequency_penalty' not in config.supported_params:- kwargs.pop('frequency_penalty', None)- if 'presence_penalty' not in config.supported_params:- kwargs.pop('presence_penalty', None)+ if "temperature" not in config.supported_params:+ kwargs.pop("temperature", None)+ if "frequency_penalty" not in config.supported_params:+ kwargs.pop("frequency_penalty", None)+ if "presence_penalty" not in config.supported_params:+ kwargs.pop("presence_penalty", None)# Handle provider-specific constraints from llm_defaults.jsonprov_json = _LLM_DEFAULTS.get("providers", {}).get(provider, {})@@ -1239,11 +1245,12 @@ class AIService:kwargs["temperature"] = fixed_tempbreak- kwargs['extra_body'] = extra_body+ kwargs["extra_body"] = extra_body# Apply thinking/reasoning configuration using model registry# The registry determines thinking_type based on model metadatafrom services.model_registry import get_model_registry+registry = get_model_registry()# Reasoning models (listed in ``reasoning_models`` per provider in@@ -1251,40 +1258,42 @@ class AIService:# the API rejects requests that send any value, including 1. Drop# it entirely rather than pass an explicit value.if registry.is_reasoning_model(model, provider):- if 'temperature' in kwargs:+ if "temperature" in kwargs:logger.info(f"[AI] Reasoning model '{model}': omitting temperature param")- kwargs.pop('temperature', None)+ kwargs.pop("temperature", None)if thinking and thinking.enabled:thinking_type = registry.get_thinking_type(model, provider)- if thinking_type == 'budget':+ if thinking_type == "budget":# Claude, Gemini, Cerebras: budget_tokens approachbudget = max(1024, thinking.budget)- if provider == 'anthropic':+ if provider == "anthropic":# Claude: max_tokens must be > budget_tokensif max_tokens <= budget:kwargs[config.max_tokens_param] = budget + max(1024, max_tokens)- logger.info(f"[AI] Claude thinking: adjusted max_tokens from {max_tokens} to {kwargs[config.max_tokens_param]} (budget={budget})")- kwargs['thinking'] = {"type": "enabled", "budget_tokens": budget}- kwargs['temperature'] = 1- elif provider == 'gemini':- kwargs['thinking_budget'] = thinking.budget- kwargs['include_thoughts'] = True+ logger.info(+ f"[AI] Claude thinking: adjusted max_tokens from {max_tokens} to {kwargs[config.max_tokens_param]} (budget={budget})"+ )+ kwargs["thinking"] = {"type": "enabled", "budget_tokens": budget}+ kwargs["temperature"] = 1+ elif provider == "gemini":+ kwargs["thinking_budget"] = thinking.budget+ kwargs["include_thoughts"] = Truelogger.info(f"[AI] Gemini thinking: budget={thinking.budget}")- elif provider == 'cerebras':- kwargs['thinking_budget'] = thinking.budget+ elif provider == "cerebras":+ kwargs["thinking_budget"] = thinking.budgetlogger.info(f"[AI] Cerebras thinking: budget={thinking.budget}")- elif thinking_type == 'effort':+ elif thinking_type == "effort":# OpenAI o-series: reasoning_effort parameter- kwargs['reasoning_effort'] = thinking.effort- kwargs['temperature'] = 1+ kwargs["reasoning_effort"] = thinking.effort+ kwargs["temperature"] = 1logger.info(f"[AI] OpenAI reasoning: effort={thinking.effort}, temperature=1")- elif thinking_type == 'format':+ elif thinking_type == "format":# Groq Qwen/QwQ: reasoning_format parameter- format_val = thinking.format if thinking.format in ('parsed', 'hidden') else 'parsed'- kwargs['reasoning_format'] = format_val- elif thinking_type == 'none':+ format_val = thinking.format if thinking.format in ("parsed", "hidden") else "parsed"+ kwargs["reasoning_format"] = format_val+ elif thinking_type == "none":logger.warning(f"[AI] Model '{model}' ({provider}) may not support thinking mode")# Resolve lazy-loaded model class (gemini)@@ -1318,7 +1327,7 @@ class AIService:return await native_provider.fetch_models(api_key)# --- LangChain fallback (groq, cerebras) ---- if provider == 'cerebras' and not CEREBRAS_AVAILABLE:+ if provider == "cerebras" and not CEREBRAS_AVAILABLE:raise ValueError(f"Cerebras provider not available: {CEREBRAS_IMPORT_ERROR or 'langchain-cerebras package not installed'}")config = get_provider_configs().get(provider)@@ -1339,10 +1348,7 @@ class AIService:# Their API may return owner-prefixed IDs (e.g. "openai/gpt-oss-120b")# but their chat API expects flat IDs (e.g. "gpt-oss-120b"), so strip prefixes.raw_ids = [m["id"] for m in data.get("data", []) if m.get("id")]- api_models = sorted(set(- mid.split("/", 1)[-1] if "/" in mid else mid- for mid in raw_ids- ))+ api_models = sorted(set(mid.split("/", 1)[-1] if "/" in mid else mid for mid in raw_ids))if api_models:return api_modelsexcept Exception as e:@@ -1363,21 +1369,21 @@ class AIService:try:# Flatten options collection from frontend- options = parameters.get('options', {})+ options = parameters.get("options", {})flattened = {**parameters, **options}# Extract parameters with camelCase/snake_case support for LangChain- api_key = flattened.get('api_key')- model = flattened.get('model', 'gpt-3.5-turbo')+ api_key = flattened.get("api_key")+ model = flattened.get("model", "gpt-3.5-turbo")# Strip [FREE] prefix if present (added by OpenRouter model list for display)- if model.startswith('[FREE] '):+ if model.startswith("[FREE] "):model = model[7:]- prompt = flattened.get('prompt', 'Hello')+ prompt = flattened.get("prompt", "Hello")# Schema-canonical name on chat-model `_base.py` is# `system_prompt`; agent paths use `system_message` and are# handled separately in execute_agent / execute_chat_agent.- system_prompt = flattened.get('system_prompt', '')+ system_prompt = flattened.get("system_prompt", "")if not api_key:raise ValueError("API key is required")@@ -1388,22 +1394,23 @@ class AIService:# Determine provider from node_type (more reliable than model name detection)from constants import detect_ai_provider+provider = detect_ai_provider(node_type, flattened)# Some APIs return owner-prefixed model IDs (e.g. "openai/gpt-oss-120b")# but chat API expects flat IDs — strip prefix for non-OpenRouter providers- if provider != 'openrouter' and '/' in model:- model = model.split('/', 1)[-1]+ if provider != "openrouter" and "/" in model:+ model = model.split("/", 1)[-1]# Build thinking config from parametersthinking_config = None- if flattened.get('thinking_enabled'):+ if flattened.get("thinking_enabled"):thinking_config = NativeThinkingConfig(enabled=True,- budget=int(flattened.get('thinking_budget', 2048)),- effort=flattened.get('reasoning_effort', 'medium'),- level=flattened.get('thinking_level', 'medium'),- format=flattened.get('reasoning_format', 'parsed'),+ budget=int(flattened.get("thinking_budget", 2048)),+ effort=flattened.get("reasoning_effort", "medium"),+ level=flattened.get("thinking_level", "medium"),+ format=flattened.get("reasoning_format", "parsed"),)# Check for proxy URL (stored as {provider}_proxy credential)@@ -1413,7 +1420,9 @@ class AIService:if is_native_provider(provider):max_tokens = native_resolve_max_tokens(flattened, model, provider)temperature = native_resolve_temperature(- flattened, model, provider,+ flattened,+ model,+ provider,bool(thinking_config and thinking_config.enabled),)@@ -1440,9 +1449,12 @@ class AIService:# --- LangChain fallback path (groq, cerebras) ---else:from langchain_core.messages import HumanMessage, SystemMessage+max_tokens = _resolve_max_tokens(flattened, model, provider)temperature = _resolve_temperature(- flattened, model, provider,+ flattened,+ model,+ provider,bool(thinking_config and thinking_config.enabled),)@@ -1457,9 +1469,7 @@ class AIService:format=thinking_config.format,)- chat_model = self.create_model(- provider, api_key, model, temperature, max_tokens, lc_thinking, proxy_url- )+ chat_model = self.create_model(provider, api_key, model, temperature, max_tokens, lc_thinking, proxy_url)messages = []if system_prompt and is_valid_message_content(system_prompt):@@ -1484,7 +1494,7 @@ class AIService:"input": {"prompt": prompt,"system_prompt": system_prompt,- }+ },}log_execution_time(logger, "ai_chat", start_time, time.time())@@ -1495,7 +1505,7 @@ class AIService:"node_id": node_id,"node_type": node_type,"result": result,- "execution_time": time.time() - start_time+ "execution_time": time.time() - start_time,}except openai.OpenAIError as e:@@ -1504,14 +1514,26 @@ class AIService:# server unreachable (APIConnectionError), etc. All# user-correctable. Propagate as NodeUserError so BaseNode.execute()# logs at WARN with no traceback.- log_api_call(logger, provider if 'provider' in locals() else 'unknown',- model if 'model' in locals() else 'unknown', "chat", False, error=str(e))+ log_api_call(+ logger,+ provider if "provider" in locals() else "unknown",+ model if "model" in locals() else "unknown",+ "chat",+ False,+ error=str(e),+ )raise NodeUserError(str(e)) from eexcept Exception as e:logger.error("AI execution failed", node_id=node_id, error=str(e))- log_api_call(logger, provider if 'provider' in locals() else 'unknown',- model if 'model' in locals() else 'unknown', "chat", False, error=str(e))+ log_api_call(+ logger,+ provider if "provider" in locals() else "unknown",+ model if "model" in locals() else "unknown",+ "chat",+ False,+ error=str(e),+ )return {"success": False,@@ -1519,17 +1541,21 @@ class AIService:"node_type": node_type,"error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}- async def execute_agent(self, node_id: str, parameters: Dict[str, Any],- memory_data: Optional[Dict[str, Any]] = None,- skill_data: Optional[List[Dict[str, Any]]] = None,- tool_data: Optional[List[Dict[str, Any]]] = None,- broadcaster = None,- workflow_id: Optional[str] = None,- context: Optional[Dict[str, Any]] = None,- database = None) -> Dict[str, Any]:+ async def execute_agent(+ self,+ node_id: str,+ parameters: Dict[str, Any],+ memory_data: Optional[Dict[str, Any]] = None,+ skill_data: Optional[List[Dict[str, Any]]] = None,+ tool_data: Optional[List[Dict[str, Any]]] = None,+ broadcaster=None,+ workflow_id: Optional[str] = None,+ context: Optional[Dict[str, Any]] = None,+ database=None,+ ) -> Dict[str, Any]:"""Execute AI Agent via the plain-async agent loop.Drives :func:`_run_agent_loop` with the LangChain chat model returned by@@ -1553,12 +1579,15 @@ class AIService:context: Optional execution context with nodes, edges for nested agent delegation"""from langchain_core.messages import HumanMessage, SystemMessage+start_time = time.time()- provider = 'unknown'- model = 'unknown'+ provider = "unknown"+ model = "unknown"# EARLY LOG: Entry point for debugging- logger.debug(f"[AIAgent] execute_agent called: node_id={node_id}, workflow_id={workflow_id}, skill_count={len(skill_data) if skill_data else 0}, tool_count={len(tool_data) if tool_data else 0}")+ logger.debug(+ f"[AIAgent] execute_agent called: node_id={node_id}, workflow_id={workflow_id}, skill_count={len(skill_data) if skill_data else 0}, tool_count={len(tool_data) if tool_data else 0}"+ )if skill_data:for i, sd in enumerate(skill_data):logger.debug(f"[AIAgent] Skill {i}: type={sd.get('node_type')}, label={sd.get('label')}")@@ -1569,16 +1598,14 @@ class AIService:# Helper to broadcast status updates with workflow_id for proper scopingasync def broadcast_status(phase: str, details: Dict[str, Any] = None):if broadcaster:- await broadcaster.update_node_status(node_id, "executing", {- "phase": phase,- "agent_type": "loop",- **(details or {})- }, workflow_id=workflow_id)+ await broadcaster.update_node_status(+ node_id, "executing", {"phase": phase, "agent_type": "loop", **(details or {})}, workflow_id=workflow_id+ )try:# Extract top-level parameters (always visible in UI)- prompt = parameters.get('prompt', 'Hello')- system_message = parameters.get('system_message', 'You are a helpful assistant')+ prompt = parameters.get("prompt", "Hello")+ system_message = parameters.get("system_message", "You are a helpful assistant")# Inject skills: personality skills get full instructions, others get brief descriptionsskill_prompt, has_personality = _build_skill_system_prompt(skill_data, log_prefix="[AIAgent]")@@ -1589,14 +1616,14 @@ class AIService:system_message = f"{system_message}\n\n{skill_prompt}"# Flatten options collection from frontend- options = parameters.get('options', {})+ options = parameters.get("options", {})flattened = {**parameters, **options}- api_key = flattened.get('api_key')- provider = parameters.get('provider', 'openai')- model = parameters.get('model', '')+ api_key = flattened.get("api_key")+ provider = parameters.get("provider", "openai")+ model = parameters.get("model", "")# Strip [FREE] prefix if present (added by OpenRouter model list for display)- if model.startswith('[FREE] '):+ if model.startswith("[FREE] "):model = model[7:]logger.debug(f"[Agent] Agent: {provider}/{model}, tools={len(tool_data) if tool_data else 0}")@@ -1618,24 +1645,20 @@ class AIService:# Build thinking config from parametersthinking_config = None- if flattened.get('thinking_enabled'):+ if flattened.get("thinking_enabled"):thinking_config = ThinkingConfig(enabled=True,- budget=int(flattened.get('thinking_budget', 2048)),- effort=flattened.get('reasoning_effort', 'medium'),- level=flattened.get('thinking_level', 'medium'),- format=flattened.get('reasoning_format', 'parsed'),+ budget=int(flattened.get("thinking_budget", 2048)),+ effort=flattened.get("reasoning_effort", "medium"),+ level=flattened.get("thinking_level", "medium"),+ format=flattened.get("reasoning_format", "parsed"),)logger.debug(f"[Agent] Thinking enabled: budget={thinking_config.budget}, effort={thinking_config.effort}")temperature = _resolve_temperature(flattened, model, provider, bool(thinking_config and thinking_config.enabled))# Broadcast: Initializing model- await broadcast_status("initializing", {- "message": f"Initializing {provider} model...",- "provider": provider,- "model": model- })+ await broadcast_status("initializing", {"message": f"Initializing {provider} model...", "provider": provider, "model": model})# Check for proxy URL (stored as {provider}_proxy credential)proxy_url = await self.auth.get_api_key(f"{provider}_proxy")@@ -1659,27 +1682,25 @@ class AIService:# Add memory history from connected simpleMemory node (markdown-based)session_id = Nonehistory_count = 0- if memory_data and memory_data.get('session_id'):- session_id = memory_data['session_id']- memory_content = memory_data.get('memory_content', '')+ if memory_data and memory_data.get("session_id"):+ session_id = memory_data["session_id"]+ memory_content = memory_data.get("memory_content", "")# Broadcast: Loading memory- await broadcast_status("loading_memory", {- "message": "Loading conversation history...",- "session_id": session_id,- "has_memory": True- })+ await broadcast_status(+ "loading_memory", {"message": "Loading conversation history...", "session_id": session_id, "has_memory": True}+ )# Parse short-term memory from markdownhistory_messages = _parse_memory_markdown(memory_content)history_count = len(history_messages)# If long-term memory enabled, retrieve relevant context- if memory_data.get('long_term_enabled'):+ if memory_data.get("long_term_enabled"):store = _get_memory_vector_store(session_id)if store:try:- k = memory_data.get('retrieval_count', 3)+ k = memory_data.get("retrieval_count", 3)docs = store.similarity_search(prompt, k=k)if docs:context = "\n---\n".join(d.page_content for d in docs)@@ -1694,11 +1715,10 @@ class AIService:logger.info(f"[Agent Memory] Loaded {history_count} messages from markdown")# Broadcast: Memory loaded- await broadcast_status("memory_loaded", {- "message": f"Loaded {history_count} messages from memory",- "session_id": session_id,- "history_count": history_count- })+ await broadcast_status(+ "memory_loaded",+ {"message": f"Loaded {history_count} messages from memory", "session_id": session_id, "history_count": history_count},+ )# Add current user promptinitial_messages.append(HumanMessage(content=prompt))@@ -1708,10 +1728,7 @@ class AIService:tool_configs = {}if tool_data:- await broadcast_status("building_tools", {- "message": f"Building {len(tool_data)} tool(s)...",- "tool_count": len(tool_data)- })+ await broadcast_status("building_tools", {"message": f"Building {len(tool_data)} tool(s)...", "tool_count": len(tool_data)})for tool_info in tool_data:tool, config = await self._build_tool_from_node(tool_info)@@ -1723,12 +1740,12 @@ class AIService:logger.debug(f"[Agent] Built {len(tools)} tools")# Auto-inject check_delegated_tasks tool when delegation tools present- if any(name.startswith('delegate_to_') for name in tool_configs):+ if any(name.startswith("delegate_to_") for name in tool_configs):check_info = {- 'node_type': '_builtin_check_delegated_tasks',- 'node_id': f'{node_id}_check_tasks',- 'parameters': {},- 'label': 'Check Delegated Tasks',+ "node_type": "_builtin_check_delegated_tasks",+ "node_id": f"{node_id}_check_tasks",+ "parameters": {},+ "label": "Check Delegated Tasks",}check_tool, check_config = await self._build_tool_from_node(check_info)if check_tool:@@ -1737,7 +1754,7 @@ class AIService:logger.debug("[Agent] Auto-injected check_delegated_tasks tool")# Add delegation guidance to system message- delegate_names = [n for n in tool_configs if n.startswith('delegate_to_')]+ delegate_names = [n for n in tool_configs if n.startswith("delegate_to_")]system_message += ("\n\n## Agent Delegation\n""When delegating to sub-agents, use 'task' for the mission directive "@@ -1761,37 +1778,34 @@ class AIService:from services.handlers.tools import execute_toolconfig = tool_configs.get(tool_name, {})- tool_node_id = config.get('node_id')+ tool_node_id = config.get("node_id")logger.debug(f"[Agent] Executing tool: {tool_name} (args={tool_args})")logger.debug(f"[Agent] Tool node_id={tool_node_id}, workflow_id={workflow_id}")# Parent-agent phase broadcast (does not touch tool node).- await broadcast_status("executing_tool", {- "message": f"Executing tool: {tool_name}",- "tool_name": tool_name,- "tool_args": tool_args- })+ await broadcast_status(+ "executing_tool", {"message": f"Executing tool: {tool_name}", "tool_name": tool_name, "tool_args": tool_args}+ )# Inject services + graph context so execute_tool can scope its# broadcasts and nested agents can execute with their own tools.- config['workflow_id'] = workflow_id- config['ai_service'] = self- config['database'] = self.database- config['parent_node_id'] = node_id+ config["workflow_id"] = workflow_id+ config["ai_service"] = self+ config["database"] = self.database+ config["parent_node_id"] = node_idif context:- config['nodes'] = context.get('nodes', [])- config['edges'] = context.get('edges', [])- config['workspace_dir'] = context.get('workspace_dir', '')+ config["nodes"] = context.get("nodes", [])+ config["edges"] = context.get("edges", [])+ config["workspace_dir"] = context.get("workspace_dir", "")try:result = await execute_tool(tool_name, tool_args, config)- await broadcast_status("tool_completed", {- "message": f"Tool completed: {tool_name}",- "tool_name": tool_name,- "result_preview": str(result)[:100]- })+ await broadcast_status(+ "tool_completed",+ {"message": f"Tool completed: {tool_name}", "tool_name": tool_name, "result_preview": str(result)[:100]},+ )return result@@ -1803,23 +1817,29 @@ class AIService:raise# Broadcast: Building agent- await broadcast_status("building_graph", {- "message": "Building agent...",- "message_count": len(initial_messages),- "has_memory": bool(session_id),- "history_count": history_count,- "tool_count": len(tools)- })+ await broadcast_status(+ "building_graph",+ {+ "message": "Building agent...",+ "message_count": len(initial_messages),+ "has_memory": bool(session_id),+ "history_count": history_count,+ "tool_count": len(tools),+ },+ )# Broadcast: Invoking LLM- await broadcast_status("invoking_llm", {- "message": f"Invoking {provider} LLM...",- "provider": provider,- "model": model,- "iteration": 1,- "has_memory": bool(session_id),- "history_count": history_count- })+ await broadcast_status(+ "invoking_llm",+ {+ "message": f"Invoking {provider} LLM...",+ "provider": provider,+ "model": model,+ "iteration": 1,+ "has_memory": bool(session_id),+ "history_count": history_count,+ },+ )# Run the agent loop. ``recursion_limit`` (read from# llm_defaults.json:agent.recursion_limit) is the hard cap on@@ -1829,6 +1849,7 @@ class AIService:# appends a synthetic terminal AIMessage so downstream# extraction returns a usable partial response.from services.model_registry import get_model_registry+recursion_limit = int(get_model_registry().get_agent_defaults()["recursion_limit"])async def _emit_progress(iter_count: int) -> None:@@ -1853,7 +1874,7 @@ class AIService:all_messages = final_state["messages"]ai_response = all_messages[-1] if all_messages else None- if not ai_response or not hasattr(ai_response, 'content'):+ if not ai_response or not hasattr(ai_response, "content"):raise ValueError("No response generated from agent")# Handle different content formats (Gemini can return list of content blocks)@@ -1879,41 +1900,49 @@ class AIService:all_messages=all_messages,broadcaster=broadcaster,workflow_id=workflow_id,- memory_content=memory_data.get('memory_content', '') if memory_data else None,+ memory_content=memory_data.get("memory_content", "") if memory_data else None,api_key=api_key,- memory_node_id=memory_data.get('node_id') if memory_data else None+ memory_node_id=memory_data.get("node_id") if memory_data else None,)# Save to memory if connected (markdown-based with optional vector DB)# Only save non-empty messages using standardized validation- if memory_data and memory_data.get('node_id') and is_valid_message_content(prompt) and is_valid_message_content(response_content):+ if (+ memory_data+ and memory_data.get("node_id")+ and is_valid_message_content(prompt)+ and is_valid_message_content(response_content)+ ):# Broadcast: Saving to memory- await broadcast_status("saving_memory", {- "message": "Saving to conversation memory...",- "session_id": session_id,- "has_memory": True,- "history_count": history_count- })+ await broadcast_status(+ "saving_memory",+ {+ "message": "Saving to conversation memory...",+ "session_id": session_id,+ "has_memory": True,+ "history_count": history_count,+ },+ )# If compaction happened, use compacted summary as base- if compaction_result and compaction_result.get('success') and compaction_result.get('summary'):+ if compaction_result and compaction_result.get("success") and compaction_result.get("summary"):# Start fresh with compacted summary, then add current exchange- updated_content = compaction_result['summary']- updated_content = _append_to_memory_markdown(updated_content, 'human', prompt)- updated_content = _append_to_memory_markdown(updated_content, 'ai', response_content)+ updated_content = compaction_result["summary"]+ updated_content = _append_to_memory_markdown(updated_content, "human", prompt)+ updated_content = _append_to_memory_markdown(updated_content, "ai", response_content)logger.info("[Agent Memory] Using compacted summary as new base")else:# Normal flow: append to existing memory- updated_content = memory_data.get('memory_content', '# Conversation History\n\n*No messages yet.*\n')- updated_content = _append_to_memory_markdown(updated_content, 'human', prompt)- updated_content = _append_to_memory_markdown(updated_content, 'ai', response_content)+ updated_content = memory_data.get("memory_content", "# Conversation History\n\n*No messages yet.*\n")+ updated_content = _append_to_memory_markdown(updated_content, "human", prompt)+ updated_content = _append_to_memory_markdown(updated_content, "ai", response_content)# Trim to window size, archive removed to vector DB- window_size = memory_data.get('window_size', 10)+ window_size = memory_data.get("window_size", 10)updated_content, removed_texts = _trim_markdown_window(updated_content, window_size)# Store removed messages in long-term vector DB- if removed_texts and memory_data.get('long_term_enabled'):+ if removed_texts and memory_data.get("long_term_enabled"):store = _get_memory_vector_store(session_id)if store:try:@@ -1925,10 +1954,10 @@ class AIService:# Save updated markdown to node parameters. Schema-# canonical key is snake_case; drop any pre-migration# camelCase mirror so the saved params stay clean.- memory_node_id = memory_data['node_id']+ memory_node_id = memory_data["node_id"]current_params = await self.database.get_node_parameters(memory_node_id) or {}- current_params['memory_content'] = updated_content- current_params.pop('memoryContent', None)+ current_params["memory_content"] = updated_content+ current_params.pop("memoryContent", None)await self.database.save_node_parameters(memory_node_id, current_params)logger.info(f"[Agent Memory] Saved markdown to memory node '{memory_node_id}'")@@ -1945,15 +1974,12 @@ class AIService:"input": {"prompt": prompt,"system_message": system_message,- }+ },}# Add memory info if usedif session_id:- result["memory"] = {- "session_id": session_id,- "history_loaded": history_count- }+ result["memory"] = {"session_id": session_id, "history_loaded": history_count}log_execution_time(logger, "ai_agent_loop", start_time, time.time())log_api_call(logger, provider, model, "agent", True)@@ -1963,7 +1989,7 @@ class AIService:"node_id": node_id,"node_type": "aiAgent","result": result,- "execution_time": time.time() - start_time+ "execution_time": time.time() - start_time,}except openai.OpenAIError as e:@@ -1983,17 +2009,21 @@ class AIService:"node_type": "aiAgent","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}- async def execute_chat_agent(self, node_id: str, parameters: Dict[str, Any],- memory_data: Optional[Dict[str, Any]] = None,- skill_data: Optional[List[Dict[str, Any]]] = None,- tool_data: Optional[List[Dict[str, Any]]] = None,- broadcaster=None,- workflow_id: Optional[str] = None,- context: Optional[Dict[str, Any]] = None,- database=None) -> Dict[str, Any]:+ async def execute_chat_agent(+ self,+ node_id: str,+ parameters: Dict[str, Any],+ memory_data: Optional[Dict[str, Any]] = None,+ skill_data: Optional[List[Dict[str, Any]]] = None,+ tool_data: Optional[List[Dict[str, Any]]] = None,+ broadcaster=None,+ workflow_id: Optional[str] = None,+ context: Optional[Dict[str, Any]] = None,+ database=None,+ ) -> Dict[str, Any]:"""Execute Chat Agent - conversational AI with memory, skills, and tool calling.Chat Agent supports:@@ -2012,24 +2042,28 @@ class AIService:context: Optional execution context with nodes, edges for nested agent delegation"""from langchain_core.messages import HumanMessage, SystemMessage+start_time = time.time()- provider = 'unknown'- model = 'unknown'+ provider = "unknown"+ model = "unknown"- logger.debug(f"[ChatAgent] execute_chat_agent called: node_id={node_id}, workflow_id={workflow_id}, skill_count={len(skill_data) if skill_data else 0}, tool_count={len(tool_data) if tool_data else 0}")+ logger.debug(+ f"[ChatAgent] execute_chat_agent called: node_id={node_id}, workflow_id={workflow_id}, skill_count={len(skill_data) if skill_data else 0}, tool_count={len(tool_data) if tool_data else 0}"+ )async def broadcast_status(phase: str, details: Dict[str, Any] = None):if broadcaster:- await broadcaster.update_node_status(node_id, "executing", {- "phase": phase,- "agent_type": "chat_with_skills" if skill_data else "chat",- **(details or {})- }, workflow_id=workflow_id)+ await broadcaster.update_node_status(+ node_id,+ "executing",+ {"phase": phase, "agent_type": "chat_with_skills" if skill_data else "chat", **(details or {})},+ workflow_id=workflow_id,+ )try:# Extract parameters- prompt = parameters.get('prompt', 'Hello')- system_message = parameters.get('system_message', 'You are a helpful assistant')+ prompt = parameters.get("prompt", "Hello")+ system_message = parameters.get("system_message", "You are a helpful assistant")# Inject skills: personality skills get full instructions, others get brief descriptionsskill_prompt, has_personality = _build_skill_system_prompt(skill_data, log_prefix="[ChatAgent]")@@ -2044,10 +2078,7 @@ class AIService:all_tools = []tool_node_configs = {} # Map tool name to node config (same as AI Agent's tool_configs)if tool_data:- await broadcast_status("building_tools", {- "message": f"Building {len(tool_data)} tool(s)...",- "tool_count": len(tool_data)- })+ await broadcast_status("building_tools", {"message": f"Building {len(tool_data)} tool(s)...", "tool_count": len(tool_data)})for tool_info in tool_data:# Use AI Agent's _build_tool_from_node for all tool types@@ -2055,17 +2086,19 @@ class AIService:if tool:all_tools.append(tool)tool_node_configs[tool.name] = config- logger.debug(f"[ChatAgent] Built tool: {tool.name} (type={config.get('node_type')}, node_id={config.get('node_id')})")+ logger.debug(+ f"[ChatAgent] Built tool: {tool.name} (type={config.get('node_type')}, node_id={config.get('node_id')})"+ )logger.debug(f"[ChatAgent] Built {len(all_tools)} tools from tool_data")# Auto-inject check_delegated_tasks tool when delegation tools present- if any(name.startswith('delegate_to_') for name in tool_node_configs):+ if any(name.startswith("delegate_to_") for name in tool_node_configs):check_info = {- 'node_type': '_builtin_check_delegated_tasks',- 'node_id': f'{node_id}_check_tasks',- 'parameters': {},- 'label': 'Check Delegated Tasks',+ "node_type": "_builtin_check_delegated_tasks",+ "node_id": f"{node_id}_check_tasks",+ "parameters": {},+ "label": "Check Delegated Tasks",}check_tool, check_config = await self._build_tool_from_node(check_info)if check_tool:@@ -2074,7 +2107,7 @@ class AIService:logger.debug("[ChatAgent] Auto-injected check_delegated_tasks tool")# Add delegation guidance to system message- delegate_names = [n for n in tool_node_configs if n.startswith('delegate_to_')]+ delegate_names = [n for n in tool_node_configs if n.startswith("delegate_to_")]system_message += ("\n\n## Agent Delegation\n""When delegating to sub-agents, use 'task' for the mission directive "@@ -2089,14 +2122,14 @@ class AIService:logger.debug(f"[ChatAgent] Tool '{t.name}' schema: {schema}")# Flatten options collection from frontend- options = parameters.get('options', {})+ options = parameters.get("options", {})flattened = {**parameters, **options}- api_key = flattened.get('api_key')- provider = parameters.get('provider', 'openai')- model = parameters.get('model', '')+ api_key = flattened.get("api_key")+ provider = parameters.get("provider", "openai")+ model = parameters.get("model", "")# Strip [FREE] prefix if present (added by OpenRouter model list for display)- if model.startswith('[FREE] '):+ if model.startswith("[FREE] "):model = model[7:]logger.debug(f"[ChatAgent] Provider: {provider}, Model: {model}")@@ -2118,23 +2151,19 @@ class AIService:# Build thinking config from parametersthinking_config = None- if flattened.get('thinking_enabled'):+ if flattened.get("thinking_enabled"):thinking_config = ThinkingConfig(enabled=True,- budget=int(flattened.get('thinking_budget', 2048)),- effort=flattened.get('reasoning_effort', 'medium'),- level=flattened.get('thinking_level', 'medium'),- format=flattened.get('reasoning_format', 'parsed'),+ budget=int(flattened.get("thinking_budget", 2048)),+ effort=flattened.get("reasoning_effort", "medium"),+ level=flattened.get("thinking_level", "medium"),+ format=flattened.get("reasoning_format", "parsed"),)temperature = _resolve_temperature(flattened, model, provider, bool(thinking_config and thinking_config.enabled))# Broadcast: Initializing- await broadcast_status("initializing", {- "message": f"Initializing {provider} model...",- "provider": provider,- "model": model- })+ await broadcast_status("initializing", {"message": f"Initializing {provider} model...", "provider": provider, "model": model})# Check for proxy URL (stored as {provider}_proxy credential)proxy_url = await self.auth.get_api_key(f"{provider}_proxy")@@ -2151,26 +2180,24 @@ class AIService:session_id = Nonehistory_count = 0memory_content = None- if memory_data and memory_data.get('node_id'):- session_id = memory_data.get('session_id', 'default')- memory_content = memory_data.get('memory_content', '# Conversation History\n\n*No messages yet.*\n')+ if memory_data and memory_data.get("node_id"):+ session_id = memory_data.get("session_id", "default")+ memory_content = memory_data.get("memory_content", "# Conversation History\n\n*No messages yet.*\n")- await broadcast_status("loading_memory", {- "message": "Loading conversation history...",- "session_id": session_id,- "has_memory": True- })+ await broadcast_status(+ "loading_memory", {"message": "Loading conversation history...", "session_id": session_id, "has_memory": True}+ )# Parse short-term memory from markdownhistory_messages = _parse_memory_markdown(memory_content)history_count = len(history_messages)# If long-term memory enabled, retrieve relevant context- if memory_data.get('long_term_enabled'):+ if memory_data.get("long_term_enabled"):store = _get_memory_vector_store(session_id)if store:try:- k = memory_data.get('retrieval_count', 3)+ k = memory_data.get("retrieval_count", 3)docs = store.similarity_search(prompt, k=k)if docs:context = "\n---\n".join(d.page_content for d in docs)@@ -2184,22 +2211,24 @@ class AIService:logger.info(f"[ChatAgent Memory] Loaded {history_count} messages from markdown")- await broadcast_status("memory_loaded", {- "message": f"Loaded {history_count} messages from memory",- "session_id": session_id,- "history_count": history_count- })+ await broadcast_status(+ "memory_loaded",+ {"message": f"Loaded {history_count} messages from memory", "session_id": session_id, "history_count": history_count},+ )# Add current promptmessages.append(HumanMessage(content=prompt))# Broadcast: Invoking LLM- await broadcast_status("invoking_llm", {- "message": "Generating response...",- "has_memory": session_id is not None,- "history_count": history_count,- "skill_count": len(skill_data) if skill_data else 0- })+ await broadcast_status(+ "invoking_llm",+ {+ "message": "Generating response...",+ "has_memory": session_id is not None,+ "history_count": history_count,+ "skill_count": len(skill_data) if skill_data else 0,+ },+ )# Execute with or without toolsthinking_content = None@@ -2219,19 +2248,21 @@ class AIService:logger.debug(f"[ChatAgent] Executing tool: {tool_name}, args={tool_args}")config = tool_node_configs.get(tool_name, {})- tool_node_id = config.get('node_id')- logger.debug(f"[ChatAgent] Tool config: node_id={tool_node_id}, node_type={config.get('node_type')}, workflow_id={workflow_id}")+ tool_node_id = config.get("node_id")+ logger.debug(+ f"[ChatAgent] Tool config: node_id={tool_node_id}, node_type={config.get('node_type')}, workflow_id={workflow_id}"+ )# Inject services + graph context so execute_tool can scope its# broadcasts and nested agents can execute with their own tools.- config['workflow_id'] = workflow_id- config['ai_service'] = self- config['database'] = self.database- config['parent_node_id'] = node_id+ config["workflow_id"] = workflow_id+ config["ai_service"] = self+ config["database"] = self.database+ config["parent_node_id"] = node_idif context:- config['nodes'] = context.get('nodes', [])- config['edges'] = context.get('edges', [])- config['workspace_dir'] = context.get('workspace_dir', '')+ config["nodes"] = context.get("nodes", [])+ config["edges"] = context.get("edges", [])+ config["workspace_dir"] = context.get("workspace_dir", "")try:result = await execute_tool(tool_name, tool_args, config)@@ -2245,9 +2276,8 @@ class AIService:# rationale on ``recursion_limit`` + the truncation# behaviour on hit.from services.model_registry import get_model_registry- recursion_limit = int(- get_model_registry().get_agent_defaults()["recursion_limit"]- )++ recursion_limit = int(get_model_registry().get_agent_defaults()["recursion_limit"])async def _emit_progress(iter_count: int) -> None:if broadcaster:@@ -2271,7 +2301,7 @@ class AIService:all_messages = final_state["messages"]ai_response = all_messages[-1] if all_messages else None- if not ai_response or not hasattr(ai_response, 'content'):+ if not ai_response or not hasattr(ai_response, "content"):raise ValueError("No response generated from agent")raw_content = ai_response.content@@ -2308,35 +2338,38 @@ class AIService:workflow_id=workflow_id,memory_content=memory_content,api_key=api_key,- memory_node_id=memory_data.get('node_id') if memory_data else None+ memory_node_id=memory_data.get("node_id") if memory_data else None,)# Save to memory if connected (markdown-based like AI Agent)- if memory_data and memory_data.get('node_id') and is_valid_message_content(prompt) and is_valid_message_content(response_content):- await broadcast_status("saving_memory", {- "message": "Saving to conversation memory...",- "session_id": session_id,- "has_memory": True- })+ if (+ memory_data+ and memory_data.get("node_id")+ and is_valid_message_content(prompt)+ and is_valid_message_content(response_content)+ ):+ await broadcast_status(+ "saving_memory", {"message": "Saving to conversation memory...", "session_id": session_id, "has_memory": True}+ )# If compaction happened, use compacted summary as base- if compaction_result and compaction_result.get('success') and compaction_result.get('summary'):- updated_content = compaction_result['summary']- updated_content = _append_to_memory_markdown(updated_content, 'human', prompt)- updated_content = _append_to_memory_markdown(updated_content, 'ai', response_content)+ if compaction_result and compaction_result.get("success") and compaction_result.get("summary"):+ updated_content = compaction_result["summary"]+ updated_content = _append_to_memory_markdown(updated_content, "human", prompt)+ updated_content = _append_to_memory_markdown(updated_content, "ai", response_content)logger.info("[ChatAgent Memory] Using compacted summary as new base")else:# Normal flow: append to existing memory- updated_content = memory_content or '# Conversation History\n\n*No messages yet.*\n'- updated_content = _append_to_memory_markdown(updated_content, 'human', prompt)- updated_content = _append_to_memory_markdown(updated_content, 'ai', response_content)+ updated_content = memory_content or "# Conversation History\n\n*No messages yet.*\n"+ updated_content = _append_to_memory_markdown(updated_content, "human", prompt)+ updated_content = _append_to_memory_markdown(updated_content, "ai", response_content)# Trim to window size, archive removed to vector DB- window_size = memory_data.get('window_size', 10)+ window_size = memory_data.get("window_size", 10)updated_content, removed_texts = _trim_markdown_window(updated_content, window_size)# Store removed messages in long-term vector DB- if removed_texts and memory_data.get('long_term_enabled'):+ if removed_texts and memory_data.get("long_term_enabled"):store = _get_memory_vector_store(session_id)if store:try:@@ -2348,10 +2381,10 @@ class AIService:# Save updated markdown to node parameters. Schema-# canonical key is snake_case; drop any pre-migration# camelCase mirror so the saved params stay clean.- memory_node_id = memory_data['node_id']+ memory_node_id = memory_data["node_id"]current_params = await self.database.get_node_parameters(memory_node_id) or {}- current_params['memory_content'] = updated_content- current_params.pop('memoryContent', None)+ current_params["memory_content"] = updated_content+ current_params.pop("memoryContent", None)await self.database.save_node_parameters(memory_node_id, current_params)logger.info(f"[ChatAgent Memory] Saved markdown to memory node '{memory_node_id}'")@@ -2377,26 +2410,20 @@ class AIService:"input": {"prompt": prompt,"system_message": system_message,- }+ },}if session_id:- result["memory"] = {- "session_id": session_id,- "history_loaded": history_count- }+ result["memory"] = {"session_id": session_id, "history_loaded": history_count}if skill_data:result["skills"] = {- "connected": [s.get('skill_name', s.get('node_type', '')) for s in skill_data],- "count": len(skill_data)+ "connected": [s.get("skill_name", s.get("node_type", "")) for s in skill_data],+ "count": len(skill_data),}if all_tools:- result["tools"] = {- "connected": [t.name for t in all_tools],- "count": len(all_tools)- }+ result["tools"] = {"connected": [t.name for t in all_tools], "count": len(all_tools)}log_execution_time(logger, "chat_agent", start_time, time.time())log_api_call(logger, provider, model, "chat_agent", True)@@ -2406,7 +2433,7 @@ class AIService:"node_id": node_id,"node_type": "chatAgent","result": result,- "execution_time": time.time() - start_time+ "execution_time": time.time() - start_time,}except openai.OpenAIError as e:@@ -2424,7 +2451,7 @@ class AIService:"node_type": "chatAgent","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def _build_tool_from_node(self, tool_info: Dict[str, Any]) -> tuple:@@ -2453,16 +2480,17 @@ class AIService:Tuple of (StructuredTool, config_dict) or (None, None) on failure"""from langchain_core.tools import StructuredTool+# Built-in / aggregator pseudo-types — no plugin class, no ClassVar.# These must stay as an explicit fallback dict (Wave 12 D5)._PSEUDO_TOOL_FALLBACK = {- '_builtin_check_delegated_tasks': (- 'check_delegated_tasks',- 'Check status and retrieve results of previously delegated tasks.',+ "_builtin_check_delegated_tasks": (+ "check_delegated_tasks",+ "Check status and retrieve results of previously delegated tasks.",),- 'androidTool': (- 'android_device',- 'Control Android device. Available services are determined by connected nodes.',+ "androidTool": (+ "android_device",+ "Control Android device. Available services are determined by connected nodes.",),}@@ -2480,26 +2508,27 @@ class AIService:callers fall through to ``node_params`` then ``f"tool_{label}"``."""from services.node_registry import get_node_class+node_cls = get_node_class(node_type)if node_cls is not None:- cv_name = (getattr(node_cls, 'tool_name', '') or '').strip()- cv_desc = (getattr(node_cls, 'tool_description', '') or '').strip()+ cv_name = (getattr(node_cls, "tool_name", "") or "").strip()+ cv_desc = (getattr(node_cls, "tool_description", "") or "").strip()if cv_name:# tool_description falls back to the plugin's regular# ``description`` ClassVar (avoids duplicating the same# text in two ClassVars on most plugins).- return cv_name, cv_desc or (getattr(node_cls, 'description', '') or '').strip() or None+ return cv_name, cv_desc or (getattr(node_cls, "description", "") or "").strip() or Nonepseudo = _PSEUDO_TOOL_FALLBACK.get(node_type)if pseudo is not None:return pseudoreturn None, Nonetry:- node_type = tool_info.get('node_type', '')- node_params = tool_info.get('parameters', {})- node_label = tool_info.get('label', node_type)- node_id = tool_info.get('node_id', '')- connected_services = tool_info.get('connected_services', [])+ node_type = tool_info.get("node_type", "")+ node_params = tool_info.get("parameters", {})+ node_label = tool_info.get("label", node_type)+ node_id = tool_info.get("node_id", "")+ connected_services = tool_info.get("connected_services", [])default_tool_name, default_tool_description = _resolve_default_tool_name_description(node_type)@@ -2509,40 +2538,35 @@ class AIService:if db_schema:# Use database schema as source of truthlogger.debug(f"[Agent] Using DB schema for tool node {node_id}")- tool_name = db_schema.get('tool_name', default_tool_name or f"tool_{node_label}")- tool_description = db_schema.get('tool_description', default_tool_description or f"Execute {node_label}")+ tool_name = db_schema.get("tool_name", default_tool_name or f"tool_{node_label}")+ tool_description = db_schema.get("tool_description", default_tool_description or f"Execute {node_label}")# Use stored connected_services if available (for toolkit nodes)- if db_schema.get('connected_services'):- connected_services = db_schema['connected_services']+ if db_schema.get("connected_services"):+ connected_services = db_schema["connected_services"]else:# Fall back to dynamic generation from node paramstool_name = (- node_params.get('tool_name') or- default_tool_name or- f"tool_{node_label}".replace(' ', '_').replace('-', '_').lower()- )- tool_description = (- node_params.get('tool_description') or- default_tool_description or- f"Execute {node_label} node"+ node_params.get("tool_name") or default_tool_name or f"tool_{node_label}".replace(" ", "_").replace("-", "_").lower())+ tool_description = node_params.get("tool_description") or default_tool_description or f"Execute {node_label} node"# For androidTool, enhance description with connected services- if node_type == 'androidTool' and connected_services:- service_names = [s.get('label') or s.get('service_id', 'unknown') for s in connected_services]+ if node_type == "androidTool" and connected_services:+ service_names = [s.get("label") or s.get("service_id", "unknown") for s in connected_services]tool_description = f"{tool_description} Connected: {', '.join(service_names)}"# For AI Agent nodes, enhance description with child agent's tool capabilities# This allows parent agent to know what the child agent can dofrom constants import AI_AGENT_TYPES+if node_type in AI_AGENT_TYPES:- child_tools = tool_info.get('child_tools', [])+ child_tools = tool_info.get("child_tools", [])if child_tools:# Build capability description from child's connected toolscapability_descriptions = []for child_tool in child_tools:- child_type = child_tool.get('node_type', '')- child_label = child_tool.get('label', child_type)+ child_type = child_tool.get("node_type", "")+ child_label = child_tool.get("label", child_type)# Resolve via the post-D5 chain (ClassVar → pseudo → legacy)_, child_desc = _resolve_default_tool_name_description(child_type)if not child_desc:@@ -2559,35 +2583,31 @@ class AIService:# Clean tool name (LangChain requires alphanumeric + underscores)import re- tool_name = re.sub(r'[^a-zA-Z0-9_]', '_', tool_name)++ tool_name = re.sub(r"[^a-zA-Z0-9_]", "_", tool_name)# Build schema based on node type - pass connected_services for androidTool# If DB has schema_config, use it to build custom schema, otherwise use dynamicschema_params = dict(node_params)if connected_services:- schema_params['connected_services'] = connected_services- if db_schema and db_schema.get('schema_config'):- schema_params['db_schema_config'] = db_schema['schema_config']+ schema_params["connected_services"] = connected_services+ if db_schema and db_schema.get("schema_config"):+ schema_params["db_schema_config"] = db_schema["schema_config"]schema = self._get_tool_schema(node_type, schema_params)# Create StructuredTool - the func is a placeholder, actual execution via tool_executordef placeholder_func(**kwargs):return kwargs- tool = StructuredTool.from_function(- name=tool_name,- description=tool_description,- func=placeholder_func,- args_schema=schema- )+ tool = StructuredTool.from_function(name=tool_name, description=tool_description, func=placeholder_func, args_schema=schema)# Build config dict - include connected_services for toolkit nodesconfig = {- 'node_type': node_type,- 'node_id': node_id,- 'parameters': node_params,- 'label': node_label,- 'connected_services': connected_services # Pass through for execution+ "node_type": node_type,+ "node_id": node_id,+ "parameters": node_params,+ "label": node_label,+ "connected_services": connected_services, # Pass through for execution}logger.debug(f"[Agent] Built tool '{tool_name}' with node_id={node_id}")@@ -2611,8 +2631,9 @@ class AIService:Pydantic BaseModel class for the tool's arguments"""from pydantic import BaseModel, Field+# Check if we have a database-stored schema config (source of truth)- db_schema_config = params.get('db_schema_config')+ db_schema_config = params.get("db_schema_config")if db_schema_config:return self._build_schema_from_config(db_schema_config)@@ -2621,14 +2642,26 @@ class AIService:# expose a (task, context) schema for delegation rather than the agent's# own Params (which would leak provider/model/prompt into the parent LLM)._AGENT_DELEGATION_TYPES = (- 'aiAgent', 'chatAgent', 'android_agent', 'coding_agent', 'web_agent',- 'task_agent', 'social_agent', 'travel_agent', 'tool_agent',- 'productivity_agent', 'payments_agent', 'consumer_agent',- 'autonomous_agent', 'orchestrator_agent', 'ai_employee',- 'rlm_agent', 'claude_code_agent',+ "aiAgent",+ "chatAgent",+ "android_agent",+ "coding_agent",+ "web_agent",+ "task_agent",+ "social_agent",+ "travel_agent",+ "tool_agent",+ "productivity_agent",+ "payments_agent",+ "consumer_agent",+ "autonomous_agent",+ "orchestrator_agent",+ "ai_employee",+ "rlm_agent",+ "claude_code_agent",)if node_type in _AGENT_DELEGATION_TYPES:- agent_label = params.get('label', node_type)+ agent_label = params.get("label", node_type)class DelegateToAgentSchema(BaseModel):"""Delegate a task to another AI Agent (non-blocking).@@ -2639,27 +2672,29 @@ class AIService:Returns a task_id immediately. Use 'check_delegated_tasks'tool to check status and retrieve results when ready."""+task: str = Field(description=f"The mission directive for '{agent_label}'. Describe the role and goal clearly, e.g. 'You are a coding assistant. Write a Python script that processes the given CSV data.'")context: Optional[str] = Field(default=None,- description="Input data or specific details the agent needs to work with, e.g. file contents, user requirements, or parameters"+ description="Input data or specific details the agent needs to work with, e.g. file contents, user requirements, or parameters",)return DelegateToAgentSchema# Built-in check tool for delegation result retrieval (no plugin).- if node_type == '_builtin_check_delegated_tasks':+ if node_type == "_builtin_check_delegated_tasks":+class CheckDelegatedTasksSchema(BaseModel):"""Check on previously delegated tasks and retrieve their results.Call this to see if delegated agents have completed their work.Returns status and results for each task."""+task_ids: Optional[List[str]] = Field(- default=None,- description="Specific task IDs to check. Omit to get ALL delegated tasks."+ default=None, description="Specific task IDs to check. Omit to get ALL delegated tasks.")return CheckDelegatedTasksSchema@@ -2670,47 +2705,45 @@ class AIService:# test_fast_path_covers_every_plugin_tool). Wave 11.D.13 stripped the# per-type ad-hoc schemas that used to live below this gate.from services.node_registry import get_node_class+plugin_cls = get_node_class(node_type)- if plugin_cls is not None and hasattr(plugin_cls, 'Params'):+ if plugin_cls is not None and hasattr(plugin_cls, "Params"):return plugin_cls.Params# androidTool aggregator — dynamic schema derived from the set of# Android service nodes connected to its toolkit handle. No plugin# class, so it stays here.- if node_type == 'androidTool':- connected_services = params.get('connected_services', [])+ if node_type == "androidTool":+ connected_services = params.get("connected_services", [])if not connected_services:+class EmptyAndroidSchema(BaseModel):"""Android toolkit with no connected services."""- query: str = Field(- default="status",- description="No Android services connected. Connect Android nodes to the toolkit."- )++ query: str = Field(default="status", description="No Android services connected. Connect Android nodes to the toolkit.")+return EmptyAndroidSchemafrom nodes.android._dispatcher import SERVICE_ACTIONSservice_info = []for svc in connected_services:- svc_id = svc.get('service_id') or svc.get('node_type', 'unknown')+ svc_id = svc.get("service_id") or svc.get("node_type", "unknown")actions = SERVICE_ACTIONS.get(svc_id, [])- action_list = [a['value'] for a in actions] if actions else ['status']+ action_list = [a["value"] for a in actions] if actions else ["status"]service_info.append(f"{svc_id}: {'/'.join(action_list)}")services_description = "; ".join(service_info)class AndroidToolSchema(BaseModel):"""Schema for Android device control via connected services."""- service_id: str = Field(- description=f"Service to use. Connected: {services_description}"- )- action: str = Field(- description="Action to perform (see service list for available actions)"- )++ service_id: str = Field(description=f"Service to use. Connected: {services_description}")+ action: str = Field(description="Action to perform (see service list for available actions)")parameters: Optional[Dict[str, Any]] = Field(default=None,- description="Action parameters. Examples: {package_name: 'com.app'} for app_launcher, {volume: 50} for audio"+ description="Action parameters. Examples: {package_name: 'com.app'} for app_launcher, {volume: 50} for audio",)return AndroidToolSchema@@ -2718,6 +2751,7 @@ class AIService:# Generic schema for other nodesclass GenericToolSchema(BaseModel):"""Generic schema for tool arguments."""+input: str = Field(description="Input data for the tool")return GenericToolSchema@@ -2740,29 +2774,30 @@ class AIService:}"""from pydantic import Field, create_model- fields_config = schema_config.get('fields', {})- schema_description = schema_config.get('description', 'Tool arguments schema')++ fields_config = schema_config.get("fields", {})+ schema_description = schema_config.get("description", "Tool arguments schema")# Build field annotations and defaultsannotations = {}field_defaults = {}TYPE_MAP = {- 'string': str,- 'number': float,- 'integer': int,- 'boolean': bool,- 'object': Dict[str, Any],- 'array': list,+ "string": str,+ "number": float,+ "integer": int,+ "boolean": bool,+ "object": Dict[str, Any],+ "array": list,}for field_name, field_config in fields_config.items():- field_type_str = field_config.get('type', 'string')+ field_type_str = field_config.get("type", "string")field_type = TYPE_MAP.get(field_type_str, str)- field_description = field_config.get('description', '')- is_required = field_config.get('required', True)- default_value = field_config.get('default')- enum_values = field_config.get('enum')+ field_description = field_config.get("description", "")+ is_required = field_config.get("required", True)+ default_value = field_config.get("default")+ enum_values = field_config.get("enum")# Handle optional fieldsif not is_required:@@ -2771,10 +2806,10 @@ class AIService:annotations[field_name] = field_type# Build Field with description and enum if provided- field_kwargs = {'description': field_description}+ field_kwargs = {"description": field_description}if enum_values:# For enums, include in description since Pydantic Field doesn't support enum directly- field_kwargs['description'] = f"{field_description} Options: {', '.join(str(v) for v in enum_values)}"+ field_kwargs["description"] = f"{field_description} Options: {', '.join(str(v) for v in enum_values)}"if default_value is not None:field_defaults[field_name] = Field(default=default_value, **field_kwargs)@@ -2785,9 +2820,7 @@ class AIService:# Create dynamic Pydantic modelDynamicSchema = create_model(- 'DynamicToolSchema',- __doc__=schema_description,- **{name: (annotations[name], field_defaults[name]) for name in annotations}+ "DynamicToolSchema", __doc__=schema_description, **{name: (annotations[name], field_defaults[name]) for name in annotations})- return DynamicSchema\ No newline at end of file+ return DynamicSchemadiff --git a/server/services/auth.py b/server/services/auth.pyindex 876c0ac0..a80ec288 100644--- a/server/services/auth.py+++ b/server/services/auth.py@@ -59,13 +59,7 @@ class AuthService:Decrypted keys are cached in memory only (not Redis) for security."""- def __init__(- self,- credentials_db: CredentialsDatabase,- cache: CacheService,- database: Database,- settings: Settings- ):+ def __init__(self, credentials_db: CredentialsDatabase, cache: CacheService, database: Database, settings: Settings):self.credentials_db = credentials_dbself.cache = cache # Kept for backward compatibility, not used for API keysself.database = database # Kept for backward compatibility@@ -167,9 +161,7 @@ class AuthService:logger.error("Failed to store API key", provider=provider, error=str(e))return False- async def get_model_params(- self, provider: str, session_id: str = "default"- ) -> Dict[str, Dict[str, Any]]:+ async def get_model_params(self, provider: str, session_id: str = "default") -> Dict[str, Dict[str, Any]]:"""Return per-model params (context_length etc.) for the provider.Reads straight from the credentials DB — there's no in-memory@@ -180,9 +172,7 @@ class AuthService:been validated yet."""try:- return await self.credentials_db.get_api_key_model_params(- provider, session_id- )+ return await self.credentials_db.get_api_key_model_params(provider, session_id)except Exception as e:logger.error("Failed to get model_params", provider=provider, error=str(e))return {}@@ -212,9 +202,7 @@ class AuthService:# second roundtrip on the next get_stored_models() call.api_key = await self.credentials_db.get_api_key(provider, session_id)if api_key:- models = await self.credentials_db.get_api_key_models(- provider, session_id- ) or []+ models = await self.credentials_db.get_api_key_models(provider, session_id) or []self._api_key_cache[cache_key] = ApiKeyCacheEntry(key=api_key,models=models,@@ -326,7 +314,7 @@ class AuthService:email: Optional[str] = None,name: Optional[str] = None,scopes: Optional[str] = None,- customer_id: str = "owner"+ customer_id: str = "owner",) -> bool:"""Store OAuth tokens in encrypted credentials database.@@ -353,7 +341,7 @@ class AuthService:email=email,name=name,scopes=scopes,- customer_id=customer_id+ customer_id=customer_id,)# 2. Cache only the access token + display fields. Refresh@@ -379,11 +367,7 @@ class AuthService:logger.error("Failed to store OAuth tokens", provider=provider, error=str(e))return False- async def get_oauth_tokens(- self,- provider: str,- customer_id: str = "owner"- ) -> Optional[Dict[str, Any]]:+ async def get_oauth_tokens(self, provider: str, customer_id: str = "owner") -> Optional[Dict[str, Any]]:"""Get OAuth display tokens from cache or encrypted database.Returns ``{access_token, email, name, scopes}`` only — the@@ -454,9 +438,7 @@ class AuthService:return tokens.get("refresh_token")return Noneexcept Exception as e:- logger.error(- "Failed to get OAuth refresh token", provider=provider, error=str(e)- )+ logger.error("Failed to get OAuth refresh token", provider=provider, error=str(e))return Noneasync def refresh_oauth_tokens_with_breaker(@@ -516,9 +498,7 @@ class AuthService:# in this codebase return {"success": False, "error": "..."}# instead of raising.if isinstance(result, dict) and result.get("success") is False:- raise RuntimeError(- result.get("error") or "oauth refresh reported failure"- )+ raise RuntimeError(result.get("error") or "oauth refresh reported failure")return resulttry:@@ -545,11 +525,7 @@ class AuthService:"needs_reauth": True,}- async def remove_oauth_tokens(- self,- provider: str,- customer_id: str = "owner"- ) -> bool:+ async def remove_oauth_tokens(self, provider: str, customer_id: str = "owner") -> bool:"""Remove OAuth tokens from storage and cache.Args:diff --git a/server/services/chat_client.py b/server/services/chat_client.pyindex 38110828..c129379a 100644--- a/server/services/chat_client.py+++ b/server/services/chat_client.py@@ -16,13 +16,7 @@ logger = structlog.get_logger()async def send_chat_message(- host: str,- port: int,- session_id: str,- api_key: str,- content: str,- metadata: Optional[Dict[str, Any]] = None,- timeout: float = 10.0+ host: str, port: int, session_id: str, api_key: str, content: str, metadata: Optional[Dict[str, Any]] = None, timeout: float = 10.0) -> Dict[str, Any]:"""Send a chat message via JSON-RPC 2.0 WebSocket.@@ -41,12 +35,7 @@ async def send_chat_message(url = f"ws://{host}:{port}/ws/{session_id}?api_key={api_key}&client_type=web"request_id = str(uuid.uuid4())- request = {- "jsonrpc": "2.0",- "method": "chat.sendMessage",- "params": {"content": content, **(metadata or {})},- "id": request_id- }+ request = {"jsonrpc": "2.0", "method": "chat.sendMessage", "params": {"content": content, **(metadata or {})}, "id": request_id}try:async with aiohttp.ClientSession() as session:@@ -74,14 +63,7 @@ async def send_chat_message(return {"success": False, "error": str(e)}-async def get_chat_history(- host: str,- port: int,- session_id: str,- api_key: str,- limit: int = 50,- timeout: float = 10.0-) -> Dict[str, Any]:+async def get_chat_history(host: str, port: int, session_id: str, api_key: str, limit: int = 50, timeout: float = 10.0) -> Dict[str, Any]:"""Get chat history via JSON-RPC 2.0 WebSocket.Args:@@ -98,12 +80,7 @@ async def get_chat_history(url = f"ws://{host}:{port}/ws/{session_id}?api_key={api_key}&client_type=web"request_id = str(uuid.uuid4())- request = {- "jsonrpc": "2.0",- "method": "chat.getHistory",- "params": {"limit": limit},- "id": request_id- }+ request = {"jsonrpc": "2.0", "method": "chat.getHistory", "params": {"limit": limit}, "id": request_id}try:async with aiohttp.ClientSession() as session:@@ -130,13 +107,7 @@ async def get_chat_history(return {"success": False, "error": str(e)}-async def ping_chat_server(- host: str,- port: int,- session_id: str,- api_key: str,- timeout: float = 5.0-) -> bool:+async def ping_chat_server(host: str, port: int, session_id: str, api_key: str, timeout: float = 5.0) -> bool:"""Ping chat server to check connectivity."""url = f"ws://{host}:{port}/ws/{session_id}?api_key={api_key}&client_type=web"request_id = str(uuid.uuid4())diff --git a/server/services/circuit_breaker.py b/server/services/circuit_breaker.pyindex 01fb0a6a..db3ee668 100644--- a/server/services/circuit_breaker.py+++ b/server/services/circuit_breaker.py@@ -75,9 +75,7 @@ class CircuitBreakerOpen(RuntimeError):"""Raised when a call short-circuits because the breaker is open."""def __init__(self, scope: str, retry_after_seconds: float) -> None:- super().__init__(- f"circuit breaker {scope!r} is open; retry after ~{retry_after_seconds:.0f}s"- )+ super().__init__(f"circuit breaker {scope!r} is open; retry after ~{retry_after_seconds:.0f}s")self.scope = scopeself.retry_after_seconds = retry_after_seconds@@ -173,9 +171,7 @@ class CircuitBreaker:if now - self._state.opened_at < self._cooldown:return# Cooldown elapsed → allow one probe call.- logger.info(- "circuit_breaker[%s]: cooldown elapsed, moving to half_open", self._scope- )+ logger.info("circuit_breaker[%s]: cooldown elapsed, moving to half_open", self._scope)self._state.state = CircuitState.HALF_OPENdef _record_failure(self, now: float, exc: BaseException) -> None:diff --git a/server/services/cli_agent/__init__.py b/server/services/cli_agent/__init__.pyindex fd1be9fb..5c66e030 100644--- a/server/services/cli_agent/__init__.py+++ b/server/services/cli_agent/__init__.py@@ -70,6 +70,7 @@ def _register_builtin_providers() -> None:moved yet."""from services.cli_agent.providers.openai_codex import OpenAICodexProvider+register_provider("codex", OpenAICodexProvider)diff --git a/server/services/cli_agent/_cli_auth.py b/server/services/cli_agent/_cli_auth.pyindex b9cc0768..fd58b95b 100644--- a/server/services/cli_agent/_cli_auth.py+++ b/server/services/cli_agent/_cli_auth.py@@ -33,6 +33,7 @@ async def mark_logged_in(Lazy-imports the container so this module stays a leaf service."""from core.container import container+await container.auth_service().store_oauth_tokens(provider=catalogue_key,access_token=MARKER_TOKEN,@@ -45,6 +46,7 @@ async def mark_logged_in(async def mark_logged_out(catalogue_key: str) -> None:"""Drop the cli-managed marker for ``catalogue_key``."""from core.container import container+await container.auth_service().remove_oauth_tokens(catalogue_key)@@ -52,6 +54,8 @@ async def broadcast_credential_event(event_type: str, provider: str) -> None:"""Fire a CloudEvents-shaped catalogue-invalidation. Frontend listensvia ``WebSocketContext`` and re-fetches the catalogue."""from services.status_broadcaster import get_status_broadcaster+await get_status_broadcaster().broadcast_credential_event(- event_type, provider=provider,+ event_type,+ provider=provider,)diff --git a/server/services/cli_agent/_handlers.py b/server/services/cli_agent/_handlers.pyindex 0fcb5046..8f164d84 100644--- a/server/services/cli_agent/_handlers.py+++ b/server/services/cli_agent/_handlers.py@@ -33,6 +33,7 @@ logger = get_logger(__name__)# Codex — login flow not yet wired; logout works for marker cleanup# ---------------------------------------------------------------------------+async def handle_codex_cli_login(data: Dict[str, Any], # noqa: ARG001websocket: WebSocket, # noqa: ARG001@@ -55,7 +56,8 @@ async def handle_codex_cli_logout(try:await mark_logged_out("codex_cli")await broadcast_credential_event(- "credential.oauth.disconnected", provider="codex_cli",+ "credential.oauth.disconnected",+ provider="codex_cli",)except Exception as exc:logger.warning("[codex_cli_logout] failed: %s", exc)diff --git a/server/services/cli_agent/config.py b/server/services/cli_agent/config.pyindex 4e212005..a79e98f8 100644--- a/server/services/cli_agent/config.py+++ b/server/services/cli_agent/config.py@@ -24,9 +24,11 @@ logger = get_logger(__name__)# Provider config dataclass# ---------------------------------------------------------------------------+@dataclassclass CliProviderConfig:"""Per-provider config from `ai_cli_providers.json`."""+name: strpackage_name: strbinary_name: str@@ -42,6 +44,7 @@ class CliProviderConfig:# Load config once at import time# ---------------------------------------------------------------------------+def _config_path() -> Path:return Path(__file__).parent.parent.parent / "config" / "ai_cli_providers.json"@@ -74,19 +77,13 @@ def _build_configs() -> Dict[str, CliProviderConfig]:for name, prov in raw.items():# Pull known fields out; everything else lives in `defaults` so# provider impls can read e.g. `default_model`, `default_max_turns`.- defaults = {- k: v for k, v in prov.items()- if k.startswith("default_")- }+ defaults = {k: v for k, v in prov.items() if k.startswith("default_")}configs[name] = CliProviderConfig(name=name,package_name=prov.get("package_name", ""),binary_name=prov.get("binary_name", name),login_argv=tuple(prov.get("login_argv", [])),- auth_status_argv=(- tuple(prov["auth_status_argv"])- if prov.get("auth_status_argv") else None- ),+ auth_status_argv=(tuple(prov["auth_status_argv"]) if prov.get("auth_status_argv") else None),ide_lock_env_var=prov.get("ide_lock_env_var"),ide_lockfile_dir=_expand_lockfile_dir(prov.get("ide_lockfile_dir")),defaults=defaults,diff --git a/server/services/cli_agent/factory.py b/server/services/cli_agent/factory.pyindex 3584ae60..e839f4c1 100644--- a/server/services/cli_agent/factory.py+++ b/server/services/cli_agent/factory.py@@ -71,10 +71,7 @@ def register_provider("""existing = _PROVIDER_REGISTRY.get(name)if existing is not None and existing is not provider_factory:- raise ValueError(- f"CLI provider {name!r} already registered with {existing!r}; "- f"refusing to overwrite with {provider_factory!r}"- )+ raise ValueError(f"CLI provider {name!r} already registered with {existing!r}; " f"refusing to overwrite with {provider_factory!r}")_PROVIDER_REGISTRY[name] = provider_factorylogger.debug("[cli_agent] registered provider %r -> %r", name, provider_factory)@@ -101,15 +98,11 @@ def create_cli_provider(name: str) -> AICliProvider:# implementation is in flight. Surface a clean ``NotImplementedError``# so factory consumers can detect the deferred state.if name == "gemini":- raise NotImplementedError(- "gemini provider deferred to v2. Use 'claude' or 'codex' in v1."- )+ raise NotImplementedError("gemini provider deferred to v2. Use 'claude' or 'codex' in v1.")registered = sorted(_PROVIDER_REGISTRY.keys())raise ValueError(- f"Unknown CLI provider: {name!r}. "- f"Registered: {registered}. "- f"Did the plugin's ``__init__.py`` call register_provider()?"+ f"Unknown CLI provider: {name!r}. " f"Registered: {registered}. " f"Did the plugin's ``__init__.py`` call register_provider()?")@@ -127,6 +120,7 @@ def registered_provider_names() -> frozenset[str]:# Session-pool registry — paired with provider registry above# ---------------------------------------------------------------------------+def register_session_pool(provider_name: str,pool_getter: Callable[[], Any],@@ -144,13 +138,13 @@ def register_session_pool(existing = _POOL_REGISTRY.get(provider_name)if existing is not None and existing is not pool_getter:raise ValueError(- f"Session pool for {provider_name!r} already registered "- f"({existing!r}); refusing to overwrite with {pool_getter!r}"+ f"Session pool for {provider_name!r} already registered " f"({existing!r}); refusing to overwrite with {pool_getter!r}")_POOL_REGISTRY[provider_name] = pool_getterlogger.debug("[cli_agent] registered session pool %r -> %r",- provider_name, pool_getter,+ provider_name,+ pool_getter,)@@ -170,6 +164,7 @@ def get_session_pool(provider_name: str) -> Optional[Any]:# Skill-materialiser registry# ---------------------------------------------------------------------------+def register_skill_materialiser(provider_name: str,materialiser: Callable[..., Any],@@ -184,13 +179,13 @@ def register_skill_materialiser(existing = _SKILL_MATERIALISER_REGISTRY.get(provider_name)if existing is not None and existing is not materialiser:raise ValueError(- f"Skill materialiser for {provider_name!r} already registered "- f"({existing!r}); refusing to overwrite with {materialiser!r}"+ f"Skill materialiser for {provider_name!r} already registered " f"({existing!r}); refusing to overwrite with {materialiser!r}")_SKILL_MATERIALISER_REGISTRY[provider_name] = materialiserlogger.debug("[cli_agent] registered skill materialiser %r -> %r",- provider_name, materialiser,+ provider_name,+ materialiser,)diff --git a/server/services/cli_agent/jsonl_watcher.py b/server/services/cli_agent/jsonl_watcher.pyindex 09723ecb..1393b4e9 100644--- a/server/services/cli_agent/jsonl_watcher.py+++ b/server/services/cli_agent/jsonl_watcher.py@@ -66,8 +66,12 @@ class JsonlWatcher:"""__slots__ = (- "_path", "_on_event", "_poll_interval", "_start_from_end",- "_task", "_stopped",+ "_path",+ "_on_event",+ "_poll_interval",+ "_start_from_end",+ "_task",+ "_stopped",)def __init__(@@ -113,7 +117,8 @@ class JsonlWatcher:except Exception as exc: # pragma: no cover — defensivelogger.debug("[JsonlWatcher] task exit error path=%s exc=%s",- self._path.name, exc,+ self._path.name,+ exc,)self._task = None@@ -134,7 +139,8 @@ class JsonlWatcher:except OSError as exc:logger.warning("[JsonlWatcher] open failed path=%s exc=%s",- self._path, exc,+ self._path,+ exc,)return@@ -166,7 +172,8 @@ class JsonlWatcher:except Exception as exc: # pragma: no cover — defensivelogger.warning("[JsonlWatcher] read loop ended unexpectedly path=%s exc=%s",- self._path.name, exc,+ self._path.name,+ exc,)finally:# Flush any final no-newline bytes (claude generally writes@@ -193,7 +200,8 @@ class JsonlWatcher:except Exception as exc: # pragma: no cover — handler isolationlogger.warning("[JsonlWatcher] on_event handler raised path=%s exc=%s",- self._path.name, exc,+ self._path.name,+ exc,)@@ -214,8 +222,12 @@ class JsonlDirWatcher:"""__slots__ = (- "_dir", "_on_new_file", "_poll_interval",- "_task", "_stopped", "_baseline",+ "_dir",+ "_on_new_file",+ "_poll_interval",+ "_task",+ "_stopped",+ "_baseline",)def __init__(@@ -266,16 +278,14 @@ class JsonlDirWatcher:"""Return the set of ``.jsonl`` filenames currently in thedirectory. Empty set if the directory doesn't exist yet."""try:- return {- entry.name for entry in self._dir.iterdir()- if entry.is_file() and entry.suffix == ".jsonl"- }+ return {entry.name for entry in self._dir.iterdir() if entry.is_file() and entry.suffix == ".jsonl"}except (FileNotFoundError, NotADirectoryError):return set()except OSError as exc:logger.debug("[JsonlDirWatcher] snapshot failed dir=%s exc=%s",- self._dir, exc,+ self._dir,+ exc,)return set()@@ -309,9 +319,10 @@ class JsonlDirWatcher:raiseexcept Exception as exc: # pragma: no coverlogger.warning(- "[JsonlDirWatcher] on_new_file handler raised "- "dir=%s file=%s exc=%s",- self._dir.name, name, exc,+ "[JsonlDirWatcher] on_new_file handler raised " "dir=%s file=%s exc=%s",+ self._dir.name,+ name,+ exc,)try:diff --git a/server/services/cli_agent/lockfile.py b/server/services/cli_agent/lockfile.pyindex e38436f1..dee6ba08 100644--- a/server/services/cli_agent/lockfile.py+++ b/server/services/cli_agent/lockfile.py@@ -25,7 +25,11 @@ logger = logging.getLogger(__name__)def _lockfile_path(- *, ide_lockfile_dir: Path, pid: int, port: int, ide_name: str,+ *,+ ide_lockfile_dir: Path,+ pid: int,+ port: int,+ ide_name: str,) -> Path:if ide_name == "gemini":return ide_lockfile_dir / f"gemini-ide-server-{pid}-{port}.json"@@ -51,7 +55,10 @@ def write_ide_lockfile("""Write a VSCode-style IDE lockfile (mode 0600 on POSIX)."""ide_lockfile_dir.mkdir(parents=True, exist_ok=True)path = _lockfile_path(- ide_lockfile_dir=ide_lockfile_dir, pid=pid, port=port, ide_name=ide_name,+ ide_lockfile_dir=ide_lockfile_dir,+ pid=pid,+ port=port,+ ide_name=ide_name,)# FastMCP's ``streamable_http_app()`` registers the JSON-RPC route atdiff --git a/server/services/cli_agent/mcp_server.py b/server/services/cli_agent/mcp_server.pyindex b02ec10d..10e17620 100644--- a/server/services/cli_agent/mcp_server.py+++ b/server/services/cli_agent/mcp_server.py@@ -44,6 +44,7 @@ logger = get_logger(__name__)# BatchContext + token registry# ---------------------------------------------------------------------------+@dataclassclass BatchContext:"""Scoping data attached to one batch's bearer token.@@ -52,6 +53,7 @@ class BatchContext:``finally`` block. Tools dereference the calling batch via thebearer token in `Authorization` header."""+workflow_id: strnode_id: strworkspace_dir: Path@@ -89,15 +91,18 @@ def register_batch(token: str, ctx: BatchContext) -> None:_active_tokens[token] = ctxtool_names = [t.get("node_type") for t in ctx.connected_tools]logger.info(- "[CC-Agent MCP register_batch] node=%s wf=%s token=%s... "- "skills=%d tools=%d creds=%d %s",- ctx.node_id, ctx.workflow_id, token[:8],- len(ctx.connected_skill_names), len(ctx.connected_tools),+ "[CC-Agent MCP register_batch] node=%s wf=%s token=%s... " "skills=%d tools=%d creds=%d %s",+ ctx.node_id,+ ctx.workflow_id,+ token[:8],+ len(ctx.connected_skill_names),+ len(ctx.connected_tools),len(ctx.allowed_credentials),f"tools={tool_names}" if tool_names else "(no tools wired)",)# Per-batch workflow-tool exposure lives in workflow_tools.py.from services.cli_agent.workflow_tools import expose_workflow_tools+expose_workflow_tools(ctx.connected_tools)@@ -109,6 +114,7 @@ def unregister_batch(token: str) -> None:returnlogger.debug("[CC-Agent MCP] unregistered batch token=%s...", token[:8])from services.cli_agent.workflow_tools import unexpose_workflow_tools+unexpose_workflow_tools(ctx.connected_tools)@@ -153,14 +159,9 @@ def rebind_batch(expose_workflow_tools,unexpose_workflow_tools,)- old_by_type = {- t.get("node_type"): t for t in ctx.connected_tools- if t.get("node_type")- }- new_by_type = {- t.get("node_type"): t for t in connected_tools- if t.get("node_type")- }++ old_by_type = {t.get("node_type"): t for t in ctx.connected_tools if t.get("node_type")}+ new_by_type = {t.get("node_type"): t for t in connected_tools if t.get("node_type")}added = [v for k, v in new_by_type.items() if k not in old_by_type]removed = [v for k, v in old_by_type.items() if k not in new_by_type]if removed:@@ -169,10 +170,12 @@ def rebind_batch(expose_workflow_tools(added)ctx.connected_tools = list(connected_tools)logger.info(- "[CC-Agent MCP rebind_batch] node=%s wf=%s token=%s... "- "+%d -%d kept=%d (now %d tools)",- ctx.node_id, ctx.workflow_id, token[:8],- len(added), len(removed),+ "[CC-Agent MCP rebind_batch] node=%s wf=%s token=%s... " "+%d -%d kept=%d (now %d tools)",+ ctx.node_id,+ ctx.workflow_id,+ token[:8],+ len(added),+ len(removed),len(old_by_type.keys() & new_by_type.keys()),len(ctx.connected_tools),)@@ -193,18 +196,13 @@ def active_batch_count() -> int:# ContextVar — thread/task-local handle to the current batch# ----------------------------------------------------------------------------_current_batch: contextvars.ContextVar[Optional[BatchContext]] = (- contextvars.ContextVar("machina_current_batch", default=None)-)+_current_batch: contextvars.ContextVar[Optional[BatchContext]] = contextvars.ContextVar("machina_current_batch", default=None)def _require_batch() -> BatchContext:ctx = _current_batch.get()if ctx is None:- raise RuntimeError(- "MCP tool called without an active batch context. "- "This indicates the auth middleware was bypassed."- )+ raise RuntimeError("MCP tool called without an active batch context. " "This indicates the auth middleware was bypassed.")return ctx@@ -219,6 +217,7 @@ def _require_batch() -> BatchContext:# Auth middleware# ---------------------------------------------------------------------------+class _BearerAuthMiddleware(BaseHTTPMiddleware):"""Validate `Authorization: Bearer <token>` against the registry.@@ -240,9 +239,7 @@ class _BearerAuthMiddleware(BaseHTTPMiddleware):if path.endswith("/healthz"):return await call_next(request)- auth = request.headers.get("authorization") or request.headers.get(- "Authorization"- )+ auth = request.headers.get("authorization") or request.headers.get("Authorization")token: Optional[str] = Noneif auth and auth.lower().startswith("bearer "):token = auth[7:].strip() or None@@ -253,7 +250,10 @@ class _BearerAuthMiddleware(BaseHTTPMiddleware):"[CC-Agent MCP auth] %s %s -> 401 (no Bearer token; ""auth_header=%r ua=%r) — claude CLI either didn't read the ""lockfile or is hitting the wrong URL.",- method, path, auth, ua,+ method,+ path,+ auth,+ ua,)return JSONResponse({"error": "missing or malformed Authorization header"},@@ -263,9 +263,10 @@ class _BearerAuthMiddleware(BaseHTTPMiddleware):ctx = lookup_batch(token)if ctx is None:logger.warning(- "[CC-Agent MCP auth] %s %s -> 401 (token=%s... not in "- "active registry — batch may have ended)",- method, path, token[:8],+ "[CC-Agent MCP auth] %s %s -> 401 (token=%s... not in " "active registry — batch may have ended)",+ method,+ path,+ token[:8],)return JSONResponse({"error": "invalid or expired token"},@@ -274,7 +275,11 @@ class _BearerAuthMiddleware(BaseHTTPMiddleware):logger.info("[CC-Agent MCP auth] %s %s -> OK (node=%s wf=%s token=%s...)",- method, path, ctx.node_id, ctx.workflow_id, token[:8],+ method,+ path,+ ctx.node_id,+ ctx.workflow_id,+ token[:8],)reset_token = _current_batch.set(ctx)@@ -288,6 +293,7 @@ class _BearerAuthMiddleware(BaseHTTPMiddleware):# Tool registration helper — defers FastMCP import so module import is cheap# ---------------------------------------------------------------------------+def _build_tools(mcp: Any) -> None: # FastMCP type"""Register the 5 v1 tools on a `FastMCP` instance."""@@ -339,9 +345,7 @@ def _build_tools(mcp: Any) -> None: # FastMCP type}if read and p.stat().st_size <= max_bytes:try:- info["content"] = p.read_text(- encoding="utf-8", errors="replace"- )+ info["content"] = p.read_text(encoding="utf-8", errors="replace")except OSError as exc:info["read_error"] = str(exc)entries.append(info)@@ -368,6 +372,7 @@ def _build_tools(mcp: Any) -> None: # FastMCP typectx = _require_batch()try:from services.skill_loader import get_skill_loader+loader = get_skill_loader()registry = loader.scan_skills()results = []@@ -375,15 +380,14 @@ def _build_tools(mcp: Any) -> None: # FastMCP typemeta = registry.get(name)if meta is None:continue- results.append({- "name": meta.name,- "description": meta.description,- "allowed_tools": list(meta.allowed_tools),- "category": (- meta.metadata.get("category")- if isinstance(meta.metadata, dict) else None- ),- })+ results.append(+ {+ "name": meta.name,+ "description": meta.description,+ "allowed_tools": list(meta.allowed_tools),+ "category": (meta.metadata.get("category") if isinstance(meta.metadata, dict) else None),+ }+ )return {"skills": results}except Exception as exc: # pragma: no coverlogger.exception("[CC-Agent MCP] listSkills failed")@@ -406,6 +410,7 @@ def _build_tools(mcp: Any) -> None: # FastMCP type}try:from services.skill_loader import get_skill_loader+loader = get_skill_loader()skill = loader.load_skill(name)if skill is None:@@ -442,6 +447,7 @@ def _build_tools(mcp: Any) -> None: # FastMCP type}try:from core.container import container+auth = container.auth_service()value = await auth.get_api_key(name)if not value:@@ -480,6 +486,7 @@ def _build_tools(mcp: Any) -> None: # FastMCP typebroadcaster = ctx.broadcasterif broadcaster is None:from services.status_broadcaster import get_status_broadcaster+broadcaster = get_status_broadcaster()payload = {"source": source or f"mcp:{ctx.node_id}",@@ -499,7 +506,7 @@ def _build_tools(mcp: Any) -> None: # FastMCP type_app_singleton: Optional[Any] = None # Starlette app_mcp_singleton: Optional[Any] = None # FastMCP instance — used by per-batch- # dynamic tool (un)registration.+# dynamic tool (un)registration.def get_mcp_app() -> Any:@@ -538,6 +545,7 @@ def get_mcp_app() -> Any:# Test/diagnostic helpers (used by tests + verification step #11/#12)# ---------------------------------------------------------------------------+def _reset_for_tests() -> None: # pragma: no cover"""Wipe the token registry + per-batch workflow-tool refcounts.ONLY use in tests."""@@ -546,4 +554,5 @@ def _reset_for_tests() -> None: # pragma: no cover_app_singleton = None_mcp_singleton = Nonefrom services.cli_agent.workflow_tools import _reset_for_tests as _wt_reset+_wt_reset()diff --git a/server/services/cli_agent/protocol.py b/server/services/cli_agent/protocol.pyindex ae100529..cdd38e3b 100644--- a/server/services/cli_agent/protocol.py+++ b/server/services/cli_agent/protocol.py@@ -25,6 +25,7 @@ from typing import Any, Dict, List, Optional, Protocol, runtime_checkable# Shared data types# ---------------------------------------------------------------------------+@dataclassclass CanonicalUsage:"""Vendor-normalised token counts.@@ -34,6 +35,7 @@ class CanonicalUsage:differently) maps into this so the existing `services/pricing.py`can compute USD without per-vendor branches."""+input_tokens: int = 0output_tokens: int = 0cache_read: int = 0@@ -48,6 +50,7 @@ class SessionResult:Shared keys are the schema; vendor extras live in `provider_data`."""+task_id: strsession_id: Optional[str] = Noneprovider: str = ""@@ -68,6 +71,7 @@ class SessionResult:@dataclassclass BatchResult:"""Aggregated result returned by `AICliService.run_batch()`."""+tasks: List[SessionResult] = field(default_factory=list)n_tasks: int = 0n_succeeded: int = 0@@ -83,6 +87,7 @@ class BatchResult:# Provider protocol (structural typing)# ---------------------------------------------------------------------------+@runtime_checkableclass AICliProvider(Protocol):"""Structural Protocol for an AI CLI provider.@@ -93,21 +98,23 @@ class AICliProvider(Protocol):- `providers.google_gemini.GoogleGeminiProvider` (v2 stub)"""- name: str # "claude" | "codex" | "gemini"- package_name: str # npm package- binary_name: str # "claude" | "codex" | "gemini"- ide_lock_env_var: Optional[str] # CLAUDE_IDE_LOCK | GEMINI_IDE_LOCK | None- ide_lockfile_dir: Optional[Path] # <MACHINA_CLAUDE_DIR>/ide | <tmpdir>/gemini/ide+ name: str # "claude" | "codex" | "gemini"+ package_name: str # npm package+ binary_name: str # "claude" | "codex" | "gemini"+ ide_lock_env_var: Optional[str] # CLAUDE_IDE_LOCK | GEMINI_IDE_LOCK | None+ ide_lockfile_dir: Optional[Path] # <MACHINA_CLAUDE_DIR>/ide | <tmpdir>/gemini/ide# ---- spawn surface ---------------------------------------------------- def binary_path(self) -> Path: ...+ def binary_path(self) -> Path:+ ...# Resolve the CLI binary. Resolution chain (Composio pattern):# 1) shutil.which(<binary_name>)# 2) `npx --yes <package_name>` shim path# Raises FileNotFoundError if neither is available.- def interactive_argv(self, task: Any, *, defaults: Dict[str, Any]) -> List[str]: ...+ def interactive_argv(self, task: Any, *, defaults: Dict[str, Any]) -> List[str]:+ ...# Build the full argv (binary + flags) for spawning a session# over `task` (a `<Provider>TaskSpec` Pydantic model). For# Claude, this is the interactive-TUI shape (no `-p`, prompt as@@ -117,17 +124,20 @@ class AICliProvider(Protocol):# ---- native auth (no token wrapping) --------------------------------- def login_argv(self) -> List[str]: ...+ def login_argv(self) -> List[str]:+ ...# CLI's own login command, e.g. ["claude", "login"]. Spawned# interactively from the Credentials Modal. CLI stores its own# credentials in `~/.claude/`, `~/.codex/`, `~/.gemini/`.- def auth_status_argv(self) -> Optional[List[str]]: ...+ def auth_status_argv(self) -> Optional[List[str]]:+ ...# No-op invocation to verify auth, e.g. ["claude", "--print", "-p", "ok"].# Returns None if no cheap probe exists; in that case the framework# infers from the first session's stderr.- def detect_auth_error(self, stderr: str, exit_code: int) -> bool: ...+ def detect_auth_error(self, stderr: str, exit_code: int) -> bool:+ ...# Match "not logged in" patterns:# Claude: "Please run 'claude login'"# Codex: HTTP 401 / "OPENAI_API_KEY not set"@@ -135,11 +145,13 @@ class AICliProvider(Protocol):# ---- streaming output parsing ---------------------------------------- def parse_event(self, line: str) -> Optional[Dict[str, Any]]: ...+ def parse_event(self, line: str) -> Optional[Dict[str, Any]]:+ ...# Parse a single NDJSON line from stdout. Return None for# un-parseable garbage.- def is_final_event(self, event: Dict[str, Any]) -> bool: ...+ def is_final_event(self, event: Dict[str, Any]) -> bool:+ ...# True if this event marks end-of-task. For Claude: `type=="result"`.# For Gemini: `type=="result"`. For Codex: `type=="complete"` or# heuristic fallback.@@ -149,7 +161,8 @@ class AICliProvider(Protocol):events: List[Dict[str, Any]],stderr: str,exit_code: int,- ) -> Dict[str, Any]: ...+ ) -> Dict[str, Any]:+ ...# Reconstruct a partial dict of `SessionResult` fields from the# event stream. Returns:# {@@ -164,13 +177,15 @@ class AICliProvider(Protocol):# bloating the shared schema. Pattern from# Hermes agent/transports/types.py NormalizedResponse.- def canonical_usage(self, events: List[Dict[str, Any]]) -> CanonicalUsage: ...+ def canonical_usage(self, events: List[Dict[str, Any]]) -> CanonicalUsage:+ ...# Normalise vendor token-counting into the shared `CanonicalUsage`# shape. Pattern from Hermes agent/usage_pricing.py.# ---- feature gating --------------------------------------------------- def supports(self, feature: str) -> bool: ...+ def supports(self, feature: str) -> bool:+ ...# Feature flags consulted by the session/service layer.# Recognised: "max_budget", "max_turns", "session_id", "resume",# "mcp_runtime", "json_cost", "ide_lockfile", "sandbox".diff --git a/server/services/cli_agent/providers/google_gemini.py b/server/services/cli_agent/providers/google_gemini.pyindex eaeac5be..45ca4304 100644--- a/server/services/cli_agent/providers/google_gemini.py+++ b/server/services/cli_agent/providers/google_gemini.py@@ -30,10 +30,7 @@ class GoogleGeminiProvider:name = "gemini"def __init__(self) -> None:- raise NotImplementedError(- "GoogleGeminiProvider is a v2 stub. The factory raises "- "NotImplementedError for 'gemini' in v1."- )+ raise NotImplementedError("GoogleGeminiProvider is a v2 stub. The factory raises " "NotImplementedError for 'gemini' in v1.")# The Protocol surface below is declared so static type-checkers see# the class as a complete `AICliProvider`. None of these are reachablediff --git a/server/services/cli_agent/providers/openai_codex.py b/server/services/cli_agent/providers/openai_codex.pyindex 5c6e3a9e..7055023d 100644--- a/server/services/cli_agent/providers/openai_codex.py+++ b/server/services/cli_agent/providers/openai_codex.py@@ -46,9 +46,15 @@ NAME = "codex"# Best-effort markers for Codex's "stream-end" / "task complete" event.# Update if/when OpenAI publishes a stable schema.-_FINAL_EVENT_TYPES = frozenset({- "complete", "task_complete", "done", "finished", "result",-})+_FINAL_EVENT_TYPES = frozenset(+ {+ "complete",+ "task_complete",+ "done",+ "finished",+ "result",+ }+)_AUTH_ERROR_MARKERS = ("OPENAI_API_KEY not set",@@ -68,9 +74,7 @@ class OpenAICodexProvider:def __init__(self) -> None:cfg = get_provider_config(NAME)if cfg is None:- raise RuntimeError(- f"Provider config missing for {NAME!r}. Check ai_cli_providers.json."- )+ raise RuntimeError(f"Provider config missing for {NAME!r}. Check ai_cli_providers.json.")self.name = NAMEself.package_name = cfg.package_nameself.binary_name = cfg.binary_name@@ -93,8 +97,7 @@ class OpenAICodexProvider:return Path(npx)raise FileNotFoundError(- f"Neither {self.binary_name!r} nor 'npx' found in PATH. "- f"Install with: npm install -g {self.package_name}"+ f"Neither {self.binary_name!r} nor 'npx' found in PATH. " f"Install with: npm install -g {self.package_name}")def interactive_argv(@@ -116,10 +119,7 @@ class OpenAICodexProvider:session pool can spawn without an initial prompt."""_ = (mcp_endpoint_url, mcp_bearer_token, connected_tool_names)if not isinstance(task, CodexTaskSpec):- raise TypeError(- "OpenAICodexProvider.interactive_argv requires CodexTaskSpec, "- f"got {type(task).__name__}"- )+ raise TypeError("OpenAICodexProvider.interactive_argv requires CodexTaskSpec, " f"got {type(task).__name__}")which_codex = shutil.which(self.binary_name)if which_codex:@@ -127,18 +127,12 @@ class OpenAICodexProvider:else:npx = shutil.which("npx")if not npx:- raise FileNotFoundError(- f"Neither {self.binary_name!r} nor 'npx' found in PATH"- )+ raise FileNotFoundError(f"Neither {self.binary_name!r} nor 'npx' found in PATH")argv = [npx, "--yes", self.package_name]argv += ["exec", "--json"]- model = (- task.model- or defaults.get("default_model")- or self._defaults.get("default_model", "gpt-5.2-codex")- )+ model = task.model or defaults.get("default_model") or self._defaults.get("default_model", "gpt-5.2-codex")argv += ["--model", model]sandbox = task.sandbox or defaults.get(@@ -207,10 +201,7 @@ class OpenAICodexProvider:response = self._extract_response(events)provider_data = self._extract_provider_data(events)- tool_calls = sum(- 1 for e in events- if e.get("type") in ("tool_call", "tool_use", "function_call")- )+ tool_calls = sum(1 for e in events if e.get("type") in ("tool_call", "tool_use", "function_call"))success = exit_code == 0error: Optional[str] = None@@ -252,10 +243,7 @@ class OpenAICodexProvider:def canonical_usage(self, events: List[Dict[str, Any]]) -> CanonicalUsage:# Codex doesn't expose token counts in `--json` output. Return zeros.# If a future Codex schema adds usage, extract here.- request_count = sum(- 1 for e in events- if e.get("type") in ("assistant", "message", "response")- )+ request_count = sum(1 for e in events if e.get("type") in ("assistant", "message", "response"))return CanonicalUsage(request_count=request_count)# ---- feature gating --------------------------------------------------diff --git a/server/services/cli_agent/service.py b/server/services/cli_agent/service.pyindex bbbde35d..b9e0aac6 100644--- a/server/services/cli_agent/service.py+++ b/server/services/cli_agent/service.py@@ -124,26 +124,31 @@ class AICliService:)tool_names = [t.get("node_type") for t in (connected_tools or [])]- memory_node = (- connected_memory.get("node_id") if connected_memory else None- )+ memory_node = connected_memory.get("node_id") if connected_memory else Nonelogger.info(- "[CC-Agent run_batch] enter provider=%s node=%s wf=%s tasks=%d "- "skills=%s tools=%s creds=%s memory=%s workspace=%s",- provider_name, node_id, workflow_id, len(task_list),- connected_skill_names or [], tool_names,- allowed_credentials or [], memory_node, workspace_dir,+ "[CC-Agent run_batch] enter provider=%s node=%s wf=%s tasks=%d " "skills=%s tools=%s creds=%s memory=%s workspace=%s",+ provider_name,+ node_id,+ workflow_id,+ len(task_list),+ connected_skill_names or [],+ tool_names,+ allowed_credentials or [],+ memory_node,+ workspace_dir,)# Verify the working directory is under a git repo.resolved_repo_root = await self._resolve_repo_root(- workspace_dir=workspace_dir, override=repo_root,+ workspace_dir=workspace_dir,+ override=repo_root,)if resolved_repo_root is None:logger.warning("[CC-Agent run_batch] aborting: workspace=%s is not inside a git ""repo (run `git init` there or set `working_directory` to "- "an existing repo).", workspace_dir,+ "an existing repo).",+ workspace_dir,)return self._abort_not_git_repo(provider_name=provider_name,@@ -151,7 +156,8 @@ class AICliService:)logger.info("[CC-Agent run_batch] resolved repo_root=%s for workspace=%s",- resolved_repo_root, workspace_dir,+ resolved_repo_root,+ workspace_dir,)# Per-batch bearer token + MCP context@@ -175,7 +181,8 @@ class AICliService:async with self._lock:if key in self._active_sessions:logger.warning(- "[CC-Agent service] replacing stale session list for %s", key,+ "[CC-Agent service] replacing stale session list for %s",+ key,)# Cancel anything previously left dangling.for sess in self._active_sessions[key]:@@ -186,27 +193,35 @@ class AICliService:self._active_sessions[key] = []start = time.monotonic()- await self._broadcast_phase(broadcaster, node_id, workflow_id, "batch_started", {- "provider": provider_name,- "n_tasks": len(task_list),- "max_parallel": max_parallel,- "isolation": "worktree",- })+ await self._broadcast_phase(+ broadcaster,+ node_id,+ workflow_id,+ "batch_started",+ {+ "provider": provider_name,+ "n_tasks": len(task_list),+ "max_parallel": max_parallel,+ "isolation": "worktree",+ },+ )sem = asyncio.Semaphore(max(1, int(max_parallel)))async def run_one(task: BaseAICliTaskSpec) -> SessionResult:async with sem:session = AICliSession(- provider=provider, task=task,- repo_root=resolved_repo_root, workspace_dir=workspace_dir,- node_id=node_id, workflow_id=workflow_id,- broadcaster=broadcaster, defaults=defaults,- mcp_port=port, batch_token=token,- connected_tool_names=[- t.get("node_type") for t in (connected_tools or [])- if t.get("node_type")- ],+ provider=provider,+ task=task,+ repo_root=resolved_repo_root,+ workspace_dir=workspace_dir,+ node_id=node_id,+ workflow_id=workflow_id,+ broadcaster=broadcaster,+ defaults=defaults,+ mcp_port=port,+ batch_token=token,+ connected_tool_names=[t.get("node_type") for t in (connected_tools or []) if t.get("node_type")],connected_skill_names=list(connected_skill_names or []),memory_bound=bool(connected_memory),)@@ -216,16 +231,13 @@ class AICliService:try:await session.start()except FileNotFoundError as exc:- return self._fail_result(provider_name, task, session.task_id,- f"cli_not_installed: {exc}")+ return self._fail_result(provider_name, task, session.task_id, f"cli_not_installed: {exc}")except RuntimeError as exc:# `_pre_spawn` raises on git-worktree failure.- return self._fail_result(provider_name, task, session.task_id,- f"worktree_setup_failed: {exc}")+ return self._fail_result(provider_name, task, session.task_id, f"worktree_setup_failed: {exc}")except Exception as exc:logger.exception("[CC-Agent service] start failed")- return self._fail_result(provider_name, task, session.task_id,- f"start_failed: {exc}")+ return self._fail_result(provider_name, task, session.task_id, f"start_failed: {exc}")return await session.wait_for_completion(task.timeout_seconds)finally:try:@@ -246,26 +258,24 @@ class AICliService:# owns the PTY lifetime; the bearer token stays embedded in the# spawned claude's argv across batches (CLI handles its own MCP# auth — we don't issue/unregister per turn).- use_pool = (- bool(connected_memory)- and provider_name == "claude"- and len(task_list) == 1- )+ use_pool = bool(connected_memory) and provider_name == "claude" and len(task_list) == 1results: List[SessionResult]try:if use_pool:- results = [await self._run_pooled_turn(- task=task_list[0],- memory_node_id=connected_memory["node_id"],- cwd=resolved_repo_root,- workspace_dir=Path(workspace_dir).resolve(),- defaults=defaults,- mcp_port=port,- mcp_bearer_token=token,- connected_tools=connected_tools or [],- connected_skill_names=list(connected_skill_names or []),- workflow_id=workflow_id,- )]+ results = [+ await self._run_pooled_turn(+ task=task_list[0],+ memory_node_id=connected_memory["node_id"],+ cwd=resolved_repo_root,+ workspace_dir=Path(workspace_dir).resolve(),+ defaults=defaults,+ mcp_port=port,+ mcp_bearer_token=token,+ connected_tools=connected_tools or [],+ connected_skill_names=list(connected_skill_names or []),+ workflow_id=workflow_id,+ )+ ]else:results = await asyncio.gather(*(run_one(t) for t in task_list),@@ -300,7 +310,9 @@ class AICliService:if connected_memory:try:await self._persist_memory(- connected_memory, results, broadcaster=broadcaster,+ connected_memory,+ results,+ broadcaster=broadcaster,)except Exception as exc: # pragma: no cover — best-effortlogger.warning(@@ -324,9 +336,7 @@ class AICliService:r.cost_usd = derivedcosts = [r.cost_usd for r in results]- total_cost = (- None if any(c is None for c in costs) else round(sum(c or 0 for c in costs), 6)- )+ total_cost = None if any(c is None for c in costs) else round(sum(c or 0 for c in costs), 6)result = BatchResult(tasks=results,@@ -340,13 +350,19 @@ class AICliService:timestamp=datetime.now(timezone.utc).isoformat(),)- await self._broadcast_phase(broadcaster, node_id, workflow_id, "batch_complete", {- "provider": provider_name,- "n_succeeded": n_succeeded,- "n_failed": n_failed,- "total_cost_usd": total_cost,- "wall_clock_ms": elapsed_ms,- })+ await self._broadcast_phase(+ broadcaster,+ node_id,+ workflow_id,+ "batch_complete",+ {+ "provider": provider_name,+ "n_succeeded": n_succeeded,+ "n_failed": n_failed,+ "total_cost_usd": total_cost,+ "wall_clock_ms": elapsed_ms,+ },+ )return resultasync def cancel_workflow(self, workflow_id: str) -> int:@@ -415,10 +431,7 @@ class AICliService:from services.cli_agent.factory import get_session_poolif not isinstance(task, ClaudeTaskSpec):- raise TypeError(- "Pooled turns require ClaudeTaskSpec, got "- f"{type(task).__name__}"- )+ raise TypeError("Pooled turns require ClaudeTaskSpec, got " f"{type(task).__name__}")pool = get_session_pool("claude")if pool is None:@@ -430,22 +443,16 @@ class AICliService:)await pool.start_reaper()- mcp_endpoint_url = (- f"http://127.0.0.1:{mcp_port}/mcp/ide/mcp"- )- tool_names = [- t.get("node_type") for t in (connected_tools or [])- if t.get("node_type")- ]+ mcp_endpoint_url = f"http://127.0.0.1:{mcp_port}/mcp/ide/mcp"+ tool_names = [t.get("node_type") for t in (connected_tools or []) if t.get("node_type")]env = {**os.environ, "PYTHONUNBUFFERED": "1"}# Project-local claude auth dir — same as ``AICliSession.env``.from nodes.agent.claude_code_agent._oauth import MACHINA_CLAUDE_DIR+env["CLAUDE_CONFIG_DIR"] = str(MACHINA_CLAUDE_DIR)# Composio-style parent-run-ID for MCP correlation.- env["MACHINA_PARENT_RUN_ID"] = (- f"{workflow_id}:{memory_node_id}:{mcp_bearer_token[:8]}"- )+ env["MACHINA_PARENT_RUN_ID"] = f"{workflow_id}:{memory_node_id}:{mcp_bearer_token[:8]}"pooled = await pool.acquire(memory_node_id,@@ -462,7 +469,8 @@ class AICliService:)try:return await pool.send_turn(- pooled, task.prompt,+ pooled,+ task.prompt,timeout_seconds=task.timeout_seconds,workflow_id=workflow_id,)@@ -495,7 +503,8 @@ class AICliService:"[CC-Agent _persist_memory] cleared stale last_session_id=%s ""from memory_node=%s; next run will spawn a fresh claude ""session and persist its new UUID.",- prior, memory_node_id,+ prior,+ memory_node_id,)@staticmethod@@ -512,8 +521,7 @@ class AICliService:"""successful = [r for r in results if r.success]logger.info(- "[CC-Agent _persist_memory] memory_node=%s results=%d "- "successful=%d session_ids=%s",+ "[CC-Agent _persist_memory] memory_node=%s results=%d " "successful=%d session_ids=%s",connected_memory.get("node_id"),len(results),len(successful),@@ -521,14 +529,9 @@ class AICliService:)if not successful:logger.warning(- "[CC-Agent _persist_memory] no successful runs; skipping "- "save (memory_node=%s). Per-result: %s",+ "[CC-Agent _persist_memory] no successful runs; skipping " "save (memory_node=%s). Per-result: %s",connected_memory.get("node_id"),- [- {"success": r.success, "session_id": r.session_id,- "error": (r.error or "")[:80]}- for r in results- ],+ [{"success": r.success, "session_id": r.session_id, "error": (r.error or "")[:80]} for r in results],)# Auto-recovery: claude returns# ``No conversation found with session ID: <UUID>`` when the@@ -539,10 +542,7 @@ class AICliService:# would re-fire on every retry and lock the user out# forever. The next run after this point will spawn a# fresh session and `_persist_memory` will save its UUID.- stale = any(- r.error and "No conversation found with session ID" in r.error- for r in results- )+ stale = any(r.error and "No conversation found with session ID" in r.error for r in results)if stale:await AICliService._clear_stale_session_id(connected_memory)return@@ -565,13 +565,13 @@ class AICliService:params["last_session_id"] = last_run.session_id# 2. Update the user-visible markdown mirror.- content = params.get("memory_content") or (- "# Conversation History\n\n*No messages yet.*\n"- )+ content = params.get("memory_content") or ("# Conversation History\n\n*No messages yet.*\n")for r in successful:content = append_to_memory_markdown(content, "human", r.prompt)content = append_to_memory_markdown(- content, "ai", r.response or "",+ content,+ "ai",+ r.response or "",)window = int(connected_memory.get("window_size") or 100)@@ -583,8 +583,11 @@ class AICliService:"[CC-Agent _persist_memory] saved memory_node=%s ""last_session_id=%s appended_turns=%d archived_blocks=%d ""content_length=%d",- memory_node_id, params.get("last_session_id"),- len(successful), len(removed_texts), len(content),+ memory_node_id,+ params.get("last_session_id"),+ len(successful),+ len(removed_texts),+ len(content),)# Broadcast `node_parameters_updated` so the simpleMemory's@@ -602,7 +605,8 @@ class AICliService:)except Exception as exc:logger.warning(- "[CC-Agent _persist_memory] broadcast failed: %s", exc,+ "[CC-Agent _persist_memory] broadcast failed: %s",+ exc,)if connected_memory.get("long_term_enabled") and removed_texts:@@ -670,6 +674,7 @@ class AICliService:try:from services.pricing import get_pricing_service+pricing = get_pricing_service()breakdown = pricing.calculate_cost(provider=result.provider,diff --git a/server/services/cli_agent/session.py b/server/services/cli_agent/session.pyindex 4b7377e8..2858a1ac 100644--- a/server/services/cli_agent/session.py+++ b/server/services/cli_agent/session.py@@ -106,9 +106,7 @@ class AICliSession(BaseProcessSupervisor):# (per-workflow isolation; ``cwd`` for memory-bound runs is# ``repo_root`` which would otherwise be shared across workflows).self._workspace_dir = Path(workspace_dir).resolve()- self._worktree_dir = (- self._workspace_dir / node_id / f"wt_{self._task_id}"- )+ self._worktree_dir = self._workspace_dir / node_id / f"wt_{self._task_id}"self._branch = task.branch or f"machina/{self._task_id}"self._broadcaster = broadcasterself._defaults = defaults@@ -208,13 +206,12 @@ class AICliSession(BaseProcessSupervisor):e: Dict[str, str] = {**os.environ, "PYTHONUNBUFFERED": "1"}if self._provider.name == "claude":from nodes.agent.claude_code_agent._oauth import MACHINA_CLAUDE_DIR+e["CLAUDE_CONFIG_DIR"] = str(MACHINA_CLAUDE_DIR)if self._lockfile_path and self._provider.ide_lock_env_var:e[self._provider.ide_lock_env_var] = str(self._lockfile_path)# Composio-style parent-run-ID for MCP correlation- e["MACHINA_PARENT_RUN_ID"] = (- f"{self._workflow_id}:{self._node_id}:{self._batch_token[:8]}"- )+ e["MACHINA_PARENT_RUN_ID"] = f"{self._workflow_id}:{self._node_id}:{self._batch_token[:8]}"return easync def _pre_spawn(self) -> None:@@ -227,30 +224,38 @@ class AICliSession(BaseProcessSupervisor):self._worktree_dir.parent.mkdir(parents=True, exist_ok=True)wt_proc = await anyio.run_process([- "git", "-C", str(self._repo_root),- "worktree", "add",+ "git",+ "-C",+ str(self._repo_root),+ "worktree",+ "add",str(self._worktree_dir),- "-b", self._branch,+ "-b",+ self._branch,],check=False,)if wt_proc.returncode != 0:- err = (wt_proc.stderr or b"").decode(- "utf-8", errors="replace",- ).strip()+ err = (+ (wt_proc.stderr or b"")+ .decode(+ "utf-8",+ errors="replace",+ )+ .strip()+ )raise RuntimeError(f"git worktree add failed: {err}")else:logger.info("[%s] memory-bound: skipping worktree, using cwd=%s",- self.label, self._repo_root,+ self.label,+ self._repo_root,)# 2. IDE lockfile (VSCode pattern) — providers that support it.# `workspace_dir` in the lockfile points at whatever cwd will# actually be — repo_root for memory-bound runs, else worktree.- lockfile_workspace = (- self._repo_root if self._memory_bound else self._worktree_dir- )+ lockfile_workspace = self._repo_root if self._memory_bound else self._worktree_dirif self._provider.supports("ide_lockfile") and self._provider.ide_lockfile_dir:try:self._lockfile_path = write_ide_lockfile(@@ -264,7 +269,8 @@ class AICliSession(BaseProcessSupervisor):except OSError as exc:logger.warning("[%s] IDE lockfile write failed (%s) — continuing without MCP tools",- self.label, exc,+ self.label,+ exc,)# 3. Materialise connected skills under the workspace's@@ -282,6 +288,7 @@ class AICliSession(BaseProcessSupervisor):# Gemini don't register one → call is a no-op.if self._connected_skill_names:from services.cli_agent.factory import get_skill_materialiser+materialiser = get_skill_materialiser(self._provider.name)if materialiser is not None:await materialiser(@@ -328,7 +335,9 @@ class AICliSession(BaseProcessSupervisor):except OSError as exc:self._logger.warning("[%s] could not create project dir %s: %s",- self.label, project_dir, exc,+ self.label,+ project_dir,+ exc,)resume_uuid = getattr(self._task, "resume_session_id", None)@@ -358,8 +367,11 @@ class AICliSession(BaseProcessSupervisor):self._logger.info("[%s] spawned pid=%s task=%s branch=%s cwd=%s",- self.label, self._pty_handle.pid, self._task_id,- self._branch, self.cwd(),+ self.label,+ self._pty_handle.pid,+ self._task_id,+ self._branch,+ self.cwd(),)# Resolve the JSONL path. For known-UUID `--resume` runs the@@ -371,7 +383,8 @@ class AICliSession(BaseProcessSupervisor):if self._session_jsonl_path is None:try:self._session_jsonl_path = await self._wait_for_session_jsonl(- project_dir, baseline_sizes,+ project_dir,+ baseline_sizes,)except TimeoutError as exc:# Surface a clean error envelope rather than letting the@@ -380,7 +393,8 @@ class AICliSession(BaseProcessSupervisor):self._logger.info("[%s] watching session JSONL: %s",- self.label, self._session_jsonl_path,+ self.label,+ self._session_jsonl_path,)# Start the JSONL tail-f. Events flow into `_on_event` which@@ -416,7 +430,9 @@ class AICliSession(BaseProcessSupervisor):return Path(MACHINA_CLAUDE_DIR) / "projects" / project_keyasync def _wait_for_session_jsonl(- self, project_dir: Path, baseline: Dict[str, int],+ self,+ project_dir: Path,+ baseline: Dict[str, int],) -> Path:"""Find the JSONL claude is using post-spawn via size-diff vs baseline.@@ -460,10 +476,7 @@ class AICliSession(BaseProcessSupervisor):await self._on_event(event)if self._provider.is_final_event(event):self._result_event.set()- if (- event.get("type") == "system"- and event.get("subtype") == "compact_boundary"- ):+ if event.get("type") == "system" and event.get("subtype") == "compact_boundary":await self._record_native_compaction(event)async def _record_native_compaction(self, event: Dict[str, Any]) -> None:@@ -487,11 +500,7 @@ class AICliSession(BaseProcessSupervisor):# Session-id for the compaction store: prefer the memory bridge# session_id (stable across `--resume`), fall back to the# current task's resume_session_id or the node id.- session_id = (- getattr(self._task, "resume_session_id", None)- or getattr(self._task, "session_id", None)- or self._node_id- )+ session_id = getattr(self._task, "resume_session_id", None) or getattr(self._task, "session_id", None) or self._node_idmodel = getattr(self._task, "model", "") or ""try:await svc.record(@@ -505,11 +514,15 @@ class AICliSession(BaseProcessSupervisor):)self._logger.info("[%s] native compaction recorded pre_tokens=%d trigger=%s",- self.label, pre_tokens, metadata.get("trigger", "unknown"),+ self.label,+ pre_tokens,+ metadata.get("trigger", "unknown"),)except Exception as exc: # pragma: no cover — best-effortself._logger.debug(- "[%s] compaction.record failed: %s", self.label, exc,+ "[%s] compaction.record failed: %s",+ self.label,+ exc,)# ------------------------------------------------------------------@@ -536,12 +549,7 @@ class AICliSession(BaseProcessSupervisor):payload[k] = vawait self._safe_node_status("executing", payload)else:- msg = (- event.get("message")- or event.get("text")- or event.get("delta")- or json.dumps(event)- )+ msg = event.get("message") or event.get("text") or event.get("delta") or json.dumps(event)text = msg if isinstance(msg, str) else json.dumps(msg)await self._safe_terminal_log(text[:500], level="info")@@ -554,34 +562,28 @@ class AICliSession(BaseProcessSupervisor):tools = event.get("tools") or []mcp_servers = event.get("mcp_servers") or []self._logger.info(- "[CC-Agent stream] system.init tools=%d (sample=%s) "- "mcp_servers=%s",- len(tools), tools[:8],+ "[CC-Agent stream] system.init tools=%d (sample=%s) " "mcp_servers=%s",+ len(tools),+ tools[:8],[s.get("name") for s in mcp_servers if isinstance(s, dict)],)elif etype == "assistant":msg = event.get("message") or {}content = msg.get("content") or []- tool_uses = [- c for c in content- if isinstance(c, dict) and c.get("type") == "tool_use"- ]- texts = [- c.get("text", "") for c in content- if isinstance(c, dict) and c.get("type") == "text"- ]+ tool_uses = [c for c in content if isinstance(c, dict) and c.get("type") == "tool_use"]+ texts = [c.get("text", "") for c in content if isinstance(c, dict) and c.get("type") == "text"]if tool_uses:for tu in tool_uses:self._logger.info(- "[CC-Agent stream] assistant->tool_use name=%s "- "input_keys=%s",+ "[CC-Agent stream] assistant->tool_use name=%s " "input_keys=%s",tu.get("name"),list((tu.get("input") or {}).keys()),)elif texts:sample = " ".join(t for t in texts if isinstance(t, str))[:300]self._logger.info(- "[CC-Agent stream] assistant.text: %r", sample,+ "[CC-Agent stream] assistant.text: %r",+ sample,)elif etype == "tool_use":self._logger.info(@@ -594,7 +596,8 @@ class AICliSession(BaseProcessSupervisor):preview = content if isinstance(content, str) else json.dumps(content)self._logger.info("[CC-Agent stream] tool_result is_error=%s content=%r",- event.get("is_error", False), preview[:300],+ event.get("is_error", False),+ preview[:300],)elif etype == "hook":self._logger.info(@@ -603,11 +606,12 @@ class AICliSession(BaseProcessSupervisor):)elif etype == "result":self._logger.info(- "[CC-Agent stream] result is_error=%s subtype=%s "- "session_id=%s duration_ms=%s num_turns=%s cost=%s",- event.get("is_error", False), event.get("subtype"),+ "[CC-Agent stream] result is_error=%s subtype=%s " "session_id=%s duration_ms=%s num_turns=%s cost=%s",+ event.get("is_error", False),+ event.get("subtype"),event.get("session_id"),- event.get("duration_ms"), event.get("num_turns"),+ event.get("duration_ms"),+ event.get("num_turns"),event.get("total_cost_usd"),)except Exception:@@ -617,11 +621,13 @@ class AICliSession(BaseProcessSupervisor):if not self._broadcaster:returntry:- await self._broadcaster.broadcast_terminal_log({- "source": f"{self._provider.name}:{self._task_id}",- "level": level,- "message": message,- })+ await self._broadcaster.broadcast_terminal_log(+ {+ "source": f"{self._provider.name}:{self._task_id}",+ "level": level,+ "message": message,+ }+ )except Exception:pass@@ -630,7 +636,9 @@ class AICliSession(BaseProcessSupervisor):returntry:await self._broadcaster.update_node_status(- self._node_id, status, data,+ self._node_id,+ status,+ data,workflow_id=self._workflow_id,)except Exception:@@ -656,7 +664,9 @@ class AICliSession(BaseProcessSupervisor):await watcher.stop()except Exception as exc: # pragma: no cover — defensiveself._logger.debug(- "[%s] watcher stop: %s", self.label, exc,+ "[%s] watcher stop: %s",+ self.label,+ exc,)handle = self._pty_handle@@ -667,7 +677,9 @@ class AICliSession(BaseProcessSupervisor):await handle.kill()except Exception as exc: # pragma: no cover — defensiveself._logger.debug(- "[%s] PTY kill: %s", self.label, exc,+ "[%s] PTY kill: %s",+ self.label,+ exc,)self._logger.info("[%s] stopped pid=%s", self.label, pid)@@ -686,12 +698,14 @@ class AICliSession(BaseProcessSupervisor):"""if self._pty_handle is None:return self._build_result(- success=False, error="session never started",+ success=False,+ error="session never started",)try:await asyncio.wait_for(- self._result_event.wait(), timeout=timeout_seconds,+ self._result_event.wait(),+ timeout=timeout_seconds,)# The result event fired; claude wrote `result` on the JSONL.# The subprocess is still alive (interactive TUI stays@@ -725,8 +739,12 @@ class AICliSession(BaseProcessSupervisor):try:await anyio.run_process([- "git", "-C", str(self._repo_root),- "worktree", "remove", "--force",+ "git",+ "-C",+ str(self._repo_root),+ "worktree",+ "remove",+ "--force",str(self._worktree_dir),],check=False,diff --git a/server/services/cli_agent/transports/__init__.py b/server/services/cli_agent/transports/__init__.pyindex c474a96d..0ad6ea91 100644--- a/server/services/cli_agent/transports/__init__.py+++ b/server/services/cli_agent/transports/__init__.py@@ -40,6 +40,8 @@ def get_pty_transport() -> PtyTransport:"""if sys.platform == "win32":from .windows import WindowsPtyTransport+return WindowsPtyTransport()from .posix import PosixPtyTransport+return PosixPtyTransport()diff --git a/server/services/cli_agent/transports/posix.py b/server/services/cli_agent/transports/posix.pyindex 3043d066..8b89c717 100644--- a/server/services/cli_agent/transports/posix.py+++ b/server/services/cli_agent/transports/posix.py@@ -72,9 +72,7 @@ class PosixPtyHandle:# EIO = the slave end closed (process exited). Surface as a# clean ConnectionError so callers can distinguish from a# genuine permission / FD-leak bug.- raise ConnectionError(- f"PTY write failed (pid={self.pid}): {exc}"- ) from exc+ raise ConnectionError(f"PTY write failed (pid={self.pid}): {exc}") from excasync def kill(self, signal_: int = signal.SIGTERM) -> None:"""SIGTERM, wait briefly, escalate to SIGKILL if still alive.@@ -93,7 +91,9 @@ class PosixPtyHandle:# call signal helpers directly.try:await loop.run_in_executor(- None, self._proc.kill, signal_, # type: ignore[attr-defined]+ None,+ self._proc.kill,+ signal_, # type: ignore[attr-defined])except (ProcessLookupError, OSError) as exc:logger.debug("PTY first-stage signal raced exit: %s", exc)@@ -111,7 +111,9 @@ class PosixPtyHandle:# Escalate. ``kill(SIGKILL)`` is the documented force-quit path.try:await loop.run_in_executor(- None, self._proc.kill, signal.SIGKILL, # type: ignore[attr-defined]+ None,+ self._proc.kill,+ signal.SIGKILL, # type: ignore[attr-defined])except (ProcessLookupError, OSError):pass@@ -187,6 +189,8 @@ class PosixPtyTransport(PtyTransport):)logger.info("[PtyTransport posix] spawned pid=%s cwd=%s argv0=%s",- getattr(proc, "pid", "?"), cwd, binary,+ getattr(proc, "pid", "?"),+ cwd,+ binary,)return PosixPtyHandle(proc)diff --git a/server/services/cli_agent/transports/windows.py b/server/services/cli_agent/transports/windows.pyindex 0d99316e..f1c669ec 100644--- a/server/services/cli_agent/transports/windows.py+++ b/server/services/cli_agent/transports/windows.py@@ -71,18 +71,16 @@ class WindowsPtyHandle:try:text = data.decode("utf-8")except UnicodeDecodeError as exc:- raise ConnectionError(- f"PTY write failed (pid={self.pid}): non-UTF-8 payload: {exc}"- ) from exc+ raise ConnectionError(f"PTY write failed (pid={self.pid}): non-UTF-8 payload: {exc}") from excloop = asyncio.get_running_loop()try:await loop.run_in_executor(- None, self._proc.write, text, # type: ignore[attr-defined]+ None,+ self._proc.write,+ text, # type: ignore[attr-defined])except OSError as exc:- raise ConnectionError(- f"PTY write failed (pid={self.pid}): {exc}"- ) from exc+ raise ConnectionError(f"PTY write failed (pid={self.pid}): {exc}") from excasync def kill(self, signal_: int = signal.SIGTERM) -> None:"""First-stage WM_CLOSE / SIGTERM equivalent, wait briefly,@@ -101,7 +99,9 @@ class WindowsPtyHandle:try:await loop.run_in_executor(- None, self._proc.kill, signal_, # type: ignore[attr-defined]+ None,+ self._proc.kill,+ signal_, # type: ignore[attr-defined])except (ProcessLookupError, OSError) as exc:logger.debug("ConPTY first-stage signal raced exit: %s", exc)@@ -182,6 +182,8 @@ class WindowsPtyTransport(PtyTransport):)logger.info("[PtyTransport windows] spawned pid=%s cwd=%s argv0=%s",- getattr(proc, "pid", "?"), cwd, binary,+ getattr(proc, "pid", "?"),+ cwd,+ binary,)return WindowsPtyHandle(proc)diff --git a/server/services/cli_agent/types.py b/server/services/cli_agent/types.pyindex dd0fe69a..2aedf922 100644--- a/server/services/cli_agent/types.py+++ b/server/services/cli_agent/types.py@@ -18,13 +18,14 @@ from typing import Annotated, Any, Dict, List, Literal, Optional, Unionfrom pydantic import BaseModel, ConfigDict, Field-# ---------------------------------------------------------------------------# Task specs (discriminated union)# ---------------------------------------------------------------------------+class BaseAICliTaskSpec(BaseModel):"""Shared fields for every CLI task."""+task_id: Optional[str] = Field(default=None,description="Auto-assigned `t_<8hex>` if omitted.",@@ -36,15 +37,16 @@ class BaseAICliTaskSpec(BaseModel):)branch: Optional[str] = Field(default=None,- description="Branch name for the per-task git worktree. "- "Auto-named `machina/<task_id>` if omitted.",+ description="Branch name for the per-task git worktree. " "Auto-named `machina/<task_id>` if omitted.",)model: Optional[str] = Field(default=None)timeout_seconds: int = Field(- default=600, ge=10, le=3600,+ default=600,+ ge=10,+ le=3600,description="Hard timeout per task. On expiry the session is "- "terminate_then_kill'd and a diagnostic dump is "- "written to ~/.claude-machina/logs/.",+ "terminate_then_kill'd and a diagnostic dump is "+ "written to ~/.claude-machina/logs/.",)system_prompt: Optional[str] = Field(default=None,@@ -60,46 +62,49 @@ class BaseAICliTaskSpec(BaseModel):class ClaudeTaskSpec(BaseAICliTaskSpec):"""Claude Code CLI task. Full feature set: sessions, resume, budget,turns, allowed_tools, permission_mode."""+provider: Literal["claude"] = "claude"session_id: Optional[str] = Field(default=None,description="Start a named session. Pair with `resume_session_id` "- "to chain conversations. Note: silently dropped in "- "interactive mode (claude assigns its own UUID); "- "kept for back-compat.",+ "to chain conversations. Note: silently dropped in "+ "interactive mode (claude assigns its own UUID); "+ "kept for back-compat.",)resume_session_id: Optional[str] = Field(default=None,description="Resume from a specific prior session UUID. Mutually "- "exclusive with `continue_session`. Generally unset by "- "claude_code_agent — set `continue_session=True` for "- "memory-bound runs and let claude find its own latest.",+ "exclusive with `continue_session`. Generally unset by "+ "claude_code_agent — set `continue_session=True` for "+ "memory-bound runs and let claude find its own latest.",)continue_session: bool = Field(default=False,description="Emit `--continue` so claude auto-loads the most "- "recent conversation under the current cwd (per "- "code.claude.com/docs/en/cli-reference). The cleaner "- "alternative to passing a specific UUID via "- "`resume_session_id` — claude handles session "- "tracking itself, no UUID round-trip through the "- "memory node's params required.",+ "recent conversation under the current cwd (per "+ "code.claude.com/docs/en/cli-reference). The cleaner "+ "alternative to passing a specific UUID via "+ "`resume_session_id` — claude handles session "+ "tracking itself, no UUID round-trip through the "+ "memory node's params required.",)max_turns: Optional[int] = Field(- default=None, ge=1,+ default=None,+ ge=1,description="Per-task turn cap. Defaults to provider config.",)max_budget_usd: Optional[float] = Field(- default=None, ge=0,+ default=None,+ ge=0,description="Per-task USD budget. Defaults to provider config.",)allowed_tools: Optional[str] = Field(default=None,description="Comma-separated tool list. Default is empty — "- "claude built-ins (Read/Edit/Bash/Glob/Grep/Write/"- "Skill/WebSearch/WebFetch) are intentionally NOT in "- "the allowlist; the agent only gets connected MCP "- "tools + MachinaOs's own MCP infrastructure tools.",+ "claude built-ins (Read/Edit/Bash/Glob/Grep/Write/"+ "Skill/WebSearch/WebFetch) are intentionally NOT in "+ "the allowlist; the agent only gets connected MCP "+ "tools + MachinaOs's own MCP infrastructure tools.",)permission_mode: Literal["default", "acceptEdits", "plan", "auto", "dontAsk", "bypassPermissions"] = "dontAsk"@@ -128,10 +133,9 @@ class ClaudeTaskSpec(BaseAICliTaskSpec):class CodexTaskSpec(BaseAICliTaskSpec):"""OpenAI Codex CLI task. Sandbox-first; no session/resume/budget/turns."""+provider: Literal["codex"] = "codex"- sandbox: Literal["read-only", "workspace-write", "danger-full-access"] = (- "workspace-write"- )+ sandbox: Literal["read-only", "workspace-write", "danger-full-access"] = "workspace-write"ask_for_approval: Literal["untrusted", "on-request", "never"] = "never"@@ -141,6 +145,7 @@ class GeminiTaskSpec(BaseAICliTaskSpec):Schema lives in v1 so the discriminated union JSON Schema for theLLM tool fast-path doesn't change when v2 lands."""+provider: Literal["gemini"] = "gemini"session_id: Optional[str] = Noneresume: Optional[str] = Field(@@ -161,8 +166,10 @@ AICliTaskSpec = Annotated[# Result models (Pydantic for serialisation; mirror dataclasses in protocol.py)# ---------------------------------------------------------------------------+class CanonicalUsagePydantic(BaseModel):"""Pydantic mirror of `protocol.CanonicalUsage` for output serialisation."""+input_tokens: int = 0output_tokens: int = 0cache_read: int = 0@@ -173,6 +180,7 @@ class CanonicalUsagePydantic(BaseModel):class SessionResultModel(BaseModel):"""Per-task result, JSON-serialisable."""+task_id: strsession_id: Optional[str] = Noneprovider: str = ""@@ -194,6 +202,7 @@ class SessionResultModel(BaseModel):class BatchSummary(BaseModel):"""Aggregated batch summary."""+n_tasks: int = 0n_succeeded: int = 0n_failed: int = 0@@ -204,6 +213,7 @@ class BatchSummary(BaseModel):class BatchResultModel(BaseModel):"""Top-level batch result returned by `run_batch()`."""+tasks: List[SessionResultModel] = Field(default_factory=list)summary: BatchSummary = Field(default_factory=BatchSummary)provider: str = ""@@ -214,6 +224,7 @@ class BatchResultModel(BaseModel):# Helpers# ---------------------------------------------------------------------------+def session_result_to_model(sr: Any) -> SessionResultModel:"""Convert a `protocol.SessionResult` dataclass to its Pydantic mirror."""cu = CanonicalUsagePydantic(diff --git a/server/services/cli_agent/workflow_tools.py b/server/services/cli_agent/workflow_tools.pyindex 611a187a..00126d3d 100644--- a/server/services/cli_agent/workflow_tools.py+++ b/server/services/cli_agent/workflow_tools.py@@ -63,9 +63,9 @@ def expose_workflow_tools(connected_tools: List[Dict[str, Any]]) -> None:try:handler = _build_handler(node_type, cls.Params)mcp.add_tool(- handler, name=node_type,- description=(getattr(cls, "description", None)- or f"MachinaOs workflow tool: {node_type}"),+ handler,+ name=node_type,+ description=(getattr(cls, "description", None) or f"MachinaOs workflow tool: {node_type}"),)logger.info("[CC-Agent MCP] exposed mcp__machinaos__%s", node_type)except Exception as exc: # pragma: no cover@@ -99,9 +99,11 @@ def unexpose_workflow_tools(connected_tools: List[Dict[str, Any]]) -> None:# Internals# ---------------------------------------------------------------------------+def _get_mcp() -> Optional[Any]:"""Late import to avoid a circular import with ``mcp_server``."""from services.cli_agent import mcp_server+return mcp_server._mcp_singleton@@ -130,10 +132,7 @@ def _schedule_list_changed_notify() -> None:async def _do_notify() -> None:try:- session = (- getattr(mcp, "session", None)- or getattr(getattr(mcp, "_mcp_server", None), "session", None)- )+ session = getattr(mcp, "session", None) or getattr(getattr(mcp, "_mcp_server", None), "session", None)if session is not None and hasattr(session, "send_tool_list_changed"):await session.send_tool_list_changed()except Exception as exc:@@ -168,13 +167,18 @@ def _build_handler(node_type: str, params_cls: type):default = Noneelse:default = finfo.default- parameters.append(inspect.Parameter(- fname, inspect.Parameter.KEYWORD_ONLY,- annotation=finfo.annotation, default=default,- ))+ parameters.append(+ inspect.Parameter(+ fname,+ inspect.Parameter.KEYWORD_ONLY,+ annotation=finfo.annotation,+ default=default,+ )+ )async def _handler(**kwargs: Any) -> Dict[str, Any]:from services.cli_agent.mcp_server import _require_batch+ctx = _require_batch()entry = next((t for t in ctx.connected_tools if t.get("node_type") == node_type),@@ -195,9 +199,13 @@ def _build_handler(node_type: str, params_cls: type):args = dict(kwargs)logger.info("[CC-Agent MCP %s] node=%s wf=%s args_keys=%s",- node_type, ctx.node_id, ctx.workflow_id, list(args.keys()),+ node_type,+ ctx.node_id,+ ctx.workflow_id,+ list(args.keys()),)from services.handlers.tools import execute_tool+config: Dict[str, Any] = {"node_type": node_type,"node_id": entry.get("node_id"),@@ -211,19 +219,24 @@ def _build_handler(node_type: str, params_cls: type):if "error" in result:logger.warning("[CC-Agent MCP %s] node=%s ERROR: %s",- node_type, entry.get("node_id"), result.get("error"),+ node_type,+ entry.get("node_id"),+ result.get("error"),)else:logger.info("[CC-Agent MCP %s] node=%s OK (result_keys=%s)",- node_type, entry.get("node_id"), list(result.keys())[:8],+ node_type,+ entry.get("node_id"),+ list(result.keys())[:8],)return result_handler.__name__ = node_type_handler.__annotations__ = annotations_handler.__signature__ = inspect.Signature( # type: ignore[attr-defined]- parameters, return_annotation=Dict[str, Any],+ parameters,+ return_annotation=Dict[str, Any],)return _handlerdiff --git a/server/services/compaction.py b/server/services/compaction.pyindex c502e474..5af131af 100644--- a/server/services/compaction.py+++ b/server/services/compaction.py@@ -39,13 +39,13 @@ def _extract_text_from_response(content) -> str:text_parts = []for block in content:if isinstance(block, dict):- if block.get('type') == 'text' and block.get('text'):- text_parts.append(block['text'])- elif 'text' in block:- text_parts.append(str(block['text']))+ if block.get("type") == "text" and block.get("text"):+ text_parts.append(block["text"])+ elif "text" in block:+ text_parts.append(str(block["text"]))elif isinstance(block, str):text_parts.append(block)- return '\n'.join(text_parts)+ return "\n".join(text_parts)# Handle string contentif isinstance(content, str):@@ -57,6 +57,7 @@ def _extract_text_from_response(content) -> str:class CompactionConfig(BaseModel):"""Provider-agnostic compaction configuration."""+enabled: bool = True@@ -76,6 +77,7 @@ class CompactionService:"""Per-user override from ``user_settings.compaction_ratio``, fallingback to ``agent.compaction.ratio`` in ``llm_defaults.json``."""from services.model_registry import get_model_registry+try:settings = await self._db.get_user_settings("default")if settings and "compaction_ratio" in settings:@@ -95,6 +97,7 @@ class CompactionService:wins over the value returned here."""from services.model_registry import get_model_registry+registry = get_model_registry()if ratio is None:ratio = float(registry.get_agent_defaults()["compaction"]["ratio"])@@ -108,10 +111,7 @@ class CompactionService:if not threshold:ratio = await self._get_compaction_ratio()threshold = self.get_model_threshold(model, provider, ratio=ratio)- return {- "enabled": self._config.enabled,- "context_token_threshold": threshold- }+ return {"enabled": self._config.enabled, "context_token_threshold": threshold}async def anthropic_api_config(self, threshold: Optional[int] = None, model: str = "", provider: str = "anthropic") -> Dict[str, Any]:"""Anthropic Messages API context_management config."""@@ -120,12 +120,7 @@ class CompactionService:threshold = self.get_model_threshold(model, provider, ratio=ratio)return {"betas": ["compact-2026-01-12"],- "context_management": {- "edits": [{- "type": "compact_20260112",- "trigger": {"type": "input_tokens", "value": threshold}- }]- }+ "context_management": {"edits": [{"type": "compact_20260112", "trigger": {"type": "input_tokens", "value": threshold}}]},}async def openai_config(self, threshold: Optional[int] = None, model: str = "", provider: str = "openai") -> Dict[str, Any]:@@ -146,35 +141,40 @@ class CompactionService:output_tokens=usage.get("output_tokens", 0),cache_read_tokens=usage.get("cache_read_tokens", 0),cache_creation_tokens=usage.get("cache_creation_tokens", 0),- reasoning_tokens=usage.get("reasoning_tokens", 0)+ reasoning_tokens=usage.get("reasoning_tokens", 0),)# Save token metric with cost fields- await self._db.save_token_metric({- "session_id": session_id,- "node_id": node_id,- "provider": provider,- "model": model,- **usage,- "input_cost": cost["input_cost"],- "output_cost": cost["output_cost"],- "cache_cost": cost["cache_cost"],- "total_cost": cost["total_cost"]- })+ await self._db.save_token_metric(+ {+ "session_id": session_id,+ "node_id": node_id,+ "provider": provider,+ "model": model,+ **usage,+ "input_cost": cost["input_cost"],+ "output_cost": cost["output_cost"],+ "cache_cost": cost["cache_cost"],+ "total_cost": cost["total_cost"],+ }+ )state = await self._db.get_or_create_session_token_state(session_id)new_total = state["cumulative_total"] + usage.get("total_tokens", 0)new_total_cost = state.get("cumulative_total_cost", 0.0) + cost["total_cost"]# Update cumulative state with cost- await self._db.update_session_token_state(session_id, {- "cumulative_input_tokens": state["cumulative_input_tokens"] + usage.get("input_tokens", 0),- "cumulative_output_tokens": state["cumulative_output_tokens"] + usage.get("output_tokens", 0),- "cumulative_total": new_total,- "cumulative_input_cost": state.get("cumulative_input_cost", 0.0) + cost["input_cost"],- "cumulative_output_cost": state.get("cumulative_output_cost", 0.0) + cost["output_cost"],- "cumulative_total_cost": new_total_cost- })+ await self._db.update_session_token_state(+ session_id,+ {+ "cumulative_input_tokens": state["cumulative_input_tokens"] + usage.get("input_tokens", 0),+ "cumulative_output_tokens": state["cumulative_output_tokens"] + usage.get("output_tokens", 0),+ "cumulative_total": new_total,+ "cumulative_input_cost": state.get("cumulative_input_cost", 0.0) + cost["input_cost"],+ "cumulative_output_cost": state.get("cumulative_output_cost", 0.0) + cost["output_cost"],+ "cumulative_total_cost": new_total_cost,+ },+ )# Priority: per-session custom > model-aware (with user ratio) > global defaultcustom = state.get("custom_threshold")@@ -186,6 +186,7 @@ class CompactionService:# Get the model's full context window size for frontend displayfrom services.model_registry import get_model_registry+registry = get_model_registry()context_length = registry.get_context_length(model, provider)@@ -195,22 +196,35 @@ class CompactionService:"cost": cost,"threshold": threshold,"context_length": context_length,- "needs_compaction": self._config.enabled and new_total >= threshold+ "needs_compaction": self._config.enabled and new_total >= threshold,}- async def record(self, session_id: str, node_id: str, provider: str, model: str, tokens_before: int, tokens_after: int, summary: Optional[str] = None) -> None:+ async def record(+ self, session_id: str, node_id: str, provider: str, model: str, tokens_before: int, tokens_after: int, summary: Optional[str] = None+ ) -> None:"""Record compaction event after native API handles it."""state = await self._db.get_or_create_session_token_state(session_id)- await self._db.save_compaction_event({- "session_id": session_id, "node_id": node_id, "trigger_reason": "native",- "tokens_before": tokens_before, "tokens_after": tokens_after,- "summary_model": model, "summary_provider": provider, "success": True, "summary_content": summary- })- await self._db.update_session_token_state(session_id, {- "cumulative_total": tokens_after,- "last_compaction_at": datetime.now(timezone.utc),- "compaction_count": state["compaction_count"] + 1- })+ await self._db.save_compaction_event(+ {+ "session_id": session_id,+ "node_id": node_id,+ "trigger_reason": "native",+ "tokens_before": tokens_before,+ "tokens_after": tokens_after,+ "summary_model": model,+ "summary_provider": provider,+ "success": True,+ "summary_content": summary,+ }+ )+ await self._db.update_session_token_state(+ session_id,+ {+ "cumulative_total": tokens_after,+ "last_compaction_at": datetime.now(timezone.utc),+ "compaction_count": state["compaction_count"] + 1,+ },+ )async def stats(self, session_id: str, model: str = "", provider: str = "") -> Dict[str, Any]:"""Get session statistics.@@ -229,6 +243,7 @@ class CompactionService:context_length = 0if model and provider:from services.model_registry import get_model_registry+registry = get_model_registry()context_length = registry.get_context_length(model, provider)@@ -299,17 +314,16 @@ Provide a concise but complete summary."""# Use a reasonable summary size: min(4096, model's max output)from services.model_registry import get_model_registry+model_max = get_model_registry().get_max_output_tokens(model, provider)summary_tokens = min(4096, model_max)- llm = self._ai_service.create_model(- provider=provider, api_key=api_key, model=model,- temperature=0.3, max_tokens=summary_tokens- )+ llm = self._ai_service.create_model(provider=provider, api_key=api_key, model=model, temperature=0.3, max_tokens=summary_tokens)from langchain_core.messages import HumanMessage+response = await llm.ainvoke([HumanMessage(content=prompt)])- raw_content = response.content if hasattr(response, 'content') else str(response)+ raw_content = response.content if hasattr(response, "content") else str(response)summary = _extract_text_from_response(raw_content)new_memory = f"# Conversation Summary (Compacted)\n*Generated: {datetime.now(timezone.utc).isoformat()}*\n\n{summary}"@@ -326,9 +340,11 @@ Provide a concise but complete summary."""_service: Optional[CompactionService] = None+def get_compaction_service() -> Optional[CompactionService]:return _service+def init_compaction_service(database: "Database", settings: "Settings") -> CompactionService:global _service_service = CompactionService(database, settings)diff --git a/server/services/credential_registry.py b/server/services/credential_registry.pyindex 0cd65e8f..7d3122e7 100644--- a/server/services/credential_registry.py+++ b/server/services/credential_registry.py@@ -64,13 +64,9 @@ class CredentialRegistry:with _CONFIG_PATH.open(encoding="utf-8") as f:self._raw = json.load(f)except FileNotFoundError as e:- raise CredentialRegistryError(- f"credential_providers.json not found at {_CONFIG_PATH}"- ) from e+ raise CredentialRegistryError(f"credential_providers.json not found at {_CONFIG_PATH}") from eexcept json.JSONDecodeError as e:- raise CredentialRegistryError(- f"credential_providers.json is not valid JSON: {e}"- ) from e+ raise CredentialRegistryError(f"credential_providers.json is not valid JSON: {e}") from ereturn self._rawdef _resolve_all(self) -> Dict[str, Dict[str, Any]]:@@ -98,13 +94,10 @@ class CredentialRegistry:"""Walk the extends chain, deep-merge parent then child overrides."""if provider_id in visiting:raise CredentialRegistryError(- f"extends cycle detected involving provider {provider_id!r}: "- f"{' -> '.join(sorted(visiting))} -> {provider_id}"+ f"extends cycle detected involving provider {provider_id!r}: " f"{' -> '.join(sorted(visiting))} -> {provider_id}")if provider_id not in raw:- raise CredentialRegistryError(- f"provider {provider_id!r} referenced via extends but not defined"- )+ raise CredentialRegistryError(f"provider {provider_id!r} referenced via extends but not defined")entry = raw[provider_id]extends = entry.get("extends")@@ -158,10 +151,7 @@ class CredentialRegistry:categories = raw.get("categories", {})if not isinstance(categories, dict):return []- out = [- {"key": key, "label": cfg.get("label", key), "order": cfg.get("order", 0)}- for key, cfg in categories.items()- ]+ out = [{"key": key, "label": cfg.get("label", key), "order": cfg.get("order", 0)} for key, cfg in categories.items()]out.sort(key=lambda c: (c["order"], c["key"]))return out@@ -238,11 +228,7 @@ def _deep_merge(parent: Dict[str, Any], child: Dict[str, Any]) -> Dict[str, Any]parent_value = result.get(key)if isinstance(parent_value, dict) and isinstance(child_value, dict):result[key] = _deep_merge(parent_value, child_value)- elif (- key in _MERGE_BY_KEY_ARRAYS- and isinstance(parent_value, list)- and isinstance(child_value, list)- ):+ elif key in _MERGE_BY_KEY_ARRAYS and isinstance(parent_value, list) and isinstance(child_value, list):result[key] = _merge_array_by_key(parent_value, child_value)else:result[key] = copy.deepcopy(child_value)diff --git a/server/services/credentials/handlers.py b/server/services/credentials/handlers.pyindex efa6e88a..a0300e30 100644--- a/server/services/credentials/handlers.py+++ b/server/services/credentials/handlers.py@@ -76,7 +76,7 @@ def _lookup_credential_default(storage_key: str) -> Optional[str]:registry = get_credential_registry()for provider in registry.get_all_providers():provider_id = provider.get("id") or provider.get("name", "").lower()- for field in (provider.get("fields") or []):+ for field in provider.get("fields") or []:field_key = field.get("key")if not field_key:continue@@ -164,7 +164,11 @@ async def handle_delete_api_key(data: Dict[str, Any], websocket: WebSocket) -> Dbroadcaster = get_status_broadcaster()await auth_service.remove_api_key(provider, data.get("session_id", "default"))await broadcaster.update_api_key_status(- provider, valid=False, has_key=False, message="deleted", models=[],+ provider,+ valid=False,+ has_key=False,+ message="deleted",+ models=[],)await broadcaster.broadcast_credential_event("credential.api_key.deleted",diff --git a/server/services/deployment/canary_registry.py b/server/services/deployment/canary_registry.pyindex e769c6c7..ee867a8d 100644--- a/server/services/deployment/canary_registry.py+++ b/server/services/deployment/canary_registry.py@@ -82,8 +82,7 @@ def register_canary_trigger_type(node_type: str, cloudevent_type: str) -> None:"""if not isinstance(node_type, str) or not node_type:raise TypeError(- f"register_canary_trigger_type expected a non-empty str for "- f"node_type, got {type(node_type).__name__}: {node_type!r}"+ f"register_canary_trigger_type expected a non-empty str for " f"node_type, got {type(node_type).__name__}: {node_type!r}")if not isinstance(cloudevent_type, str) or not cloudevent_type:raise TypeError(diff --git a/server/services/deployment/handlers.py b/server/services/deployment/handlers.pyindex 9f722fae..72d46f20 100644--- a/server/services/deployment/handlers.py+++ b/server/services/deployment/handlers.py@@ -72,11 +72,11 @@ async def handle_deploy_workflow(data: Dict[str, Any], websocket: WebSocket) ->logger.debug(f"[Deploy] Received {len(edges)} edges for workflow {workflow_id}")for e in edges:- target_handle = e.get('targetHandle')- if target_handle and target_handle.startswith('input-') and target_handle != 'input-main':+ target_handle = e.get("targetHandle")+ if target_handle and target_handle.startswith("input-") and target_handle != "input-main":logger.debug(f"[Deploy] Config edge: {e.get('source')} -> {e.get('target')} (handle={target_handle})")- tool_edges = [e for e in edges if e.get('targetHandle') == 'input-tools']+ tool_edges = [e for e in edges if e.get("targetHandle") == "input-tools"]if tool_edges:logger.debug(f"[Deploy] Tool edges found: {len(tool_edges)}")for te in tool_edges:@@ -94,8 +94,10 @@ async def handle_deploy_workflow(data: Dict[str, Any], websocket: WebSocket) -># a broken workflow running on a schedule is far worse than a failed# one-shot manual run.from services.workflow_validator import validate_workflow+deploy_report = await validate_workflow(- nodes=nodes, edges=edges,+ nodes=nodes,+ edges=edges,parameters_by_id=data.get("parameters_by_id"),)if deploy_report["errors"]:@@ -321,7 +323,8 @@ async def handle_get_workflow_lock(data: Dict[str, Any], websocket: WebSocket) -@ws_handler()async def handle_update_deployment_settings(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:"""Update deployment settings (can be called during active deployment)."""from core.container import container@@ -341,12 +344,14 @@ async def handle_update_deployment_settings(updated_settings = await workflow_service.update_deployment_settings(settings_to_update)status = workflow_service.get_deployment_status()- await broadcaster.broadcast({- "type": "deployment_settings_updated",- "settings": updated_settings,- "is_running": workflow_service.is_deployment_running(),- "run_counter": status.get("run_counter", 0),- })+ await broadcaster.broadcast(+ {+ "type": "deployment_settings_updated",+ "settings": updated_settings,+ "is_running": workflow_service.is_deployment_running(),+ "run_counter": status.get("run_counter", 0),+ }+ )return {"success": True,diff --git a/server/services/deployment/manager.py b/server/services/deployment/manager.pyindex d3f271d9..6a1958be 100644--- a/server/services/deployment/manager.py+++ b/server/services/deployment/manager.py@@ -81,11 +81,7 @@ class DeploymentManager:self._cron_iterations: Dict[str, int] = {} # node_id -> iteration countself._main_loop: Optional[asyncio.AbstractEventLoop] = None- self._settings = {- "stop_on_error": False,- "max_concurrent_runs": 100,- "use_parallel_executor": True- }+ self._settings = {"stop_on_error": False, "max_concurrent_runs": 100, "use_parallel_executor": True}@propertydef is_running(self) -> bool:@@ -132,7 +128,7 @@ class DeploymentManager:"success": False,"error": f"Workflow {workflow_id} is already deployed","workflow_id": workflow_id,- "deployment_id": self._deployments[workflow_id].deployment_id+ "deployment_id": self._deployments[workflow_id].deployment_id,}# Setup@@ -163,7 +159,7 @@ class DeploymentManager:nodes=nodes,edges=edges,session_id=session_id,- settings=self._settings.copy()+ settings=self._settings.copy(),)logger.info("Deployment starting", deployment_id=deployment_id, workflow_id=workflow_id, nodes=len(nodes))@@ -190,18 +186,16 @@ class DeploymentManager:triggers_setup.append(info.to_dict())# Notify started- await self._notify("started", {- "deployment_id": deployment_id,- "workflow_id": workflow_id,- "triggers": triggers_setup- }, workflow_id)+ await self._notify(+ "started", {"deployment_id": deployment_id, "workflow_id": workflow_id, "triggers": triggers_setup}, workflow_id+ )return {"success": True,"deployment_id": deployment_id,"workflow_id": workflow_id,"message": "Workflow deployed",- "triggers_setup": triggers_setup+ "triggers_setup": triggers_setup,}except Exception as e:@@ -271,7 +265,7 @@ class DeploymentManager:# Cancel event waiters for nodes in this workflowwaiter_count = 0for node in state.nodes:- waiter_count += event_waiter.cancel_for_node(node['id'])+ waiter_count += event_waiter.cancel_for_node(node["id"])# Wave 12 C1 canary: cancel Temporal-durable listeners for this# deployment. Visibility-query-based; no local handle dict.@@ -294,7 +288,8 @@ class DeploymentManager:# delegation guard inside ``_clear_stuck_node_statuses`` still# protects in-flight fire-and-forget child agents.await self._broadcaster._clear_stuck_node_statuses(- workflow_id, include_waiting=True,+ workflow_id,+ include_waiting=True,)# And broadcast a final ``executing=False`` for the deployment@@ -305,7 +300,8 @@ class DeploymentManager:# the terminal state directly to avoid a stuck ``executing=True``# on the FE toolbar.await self._broadcaster.update_workflow_status(- executing=False, workflow_id=workflow_id,+ executing=False,+ workflow_id=workflow_id,)# Clear cron iteration counters for this workflow's cron nodes@@ -329,7 +325,7 @@ class DeploymentManager:"waiters_cancelled": waiter_count,"canary_listeners_cancelled": canary_count,"canary_cron_schedules_cancelled": cron_schedule_count,- "cancelled_listener_node_ids": listener_nodes+ "cancelled_listener_node_ids": listener_nodes,}def get_status(self, workflow_id: Optional[str] = None) -> Dict[str, Any]:@@ -353,7 +349,7 @@ class DeploymentManager:"active_runs": len(execution_runs),"active_listeners": len(workflow_runs) - len(execution_runs),"run_counter": self._run_counters.get(workflow_id, 0),- "deployed_at": state.deployed_at+ "deployed_at": state.deployed_at,}# Global status (backward compatibility)@@ -380,7 +376,7 @@ class DeploymentManager:"deployed_workflows": deployed_workflows,"active_runs": total_runs,"active_listeners": total_listeners,- "run_counter": total_run_counter+ "run_counter": total_run_counter,}# =========================================================================@@ -401,31 +397,38 @@ class DeploymentManager:in-process tick callback. Dies on process restart — kept asthe default while the canary stabilises."""- node_id = node['id']- node_type = node.get('type', 'cronScheduler')+ node_id = node["id"]+ node_type = node.get("type", "cronScheduler")params = await self.database.get_node_parameters(node_id) or {}cron_expr = TriggerManager.build_cron_expression(params)- timezone = params.get('timezone', 'UTC')- frequency = params.get('frequency', 'minutes')+ timezone = params.get("timezone", "UTC")+ frequency = params.get("frequency", "minutes")schedule_desc = self._get_schedule_description(params)# Path 1: Wave 12 C3 canary — Temporal Schedule.if await self._canary_listener_enabled_for(node_type):schedule_id = await self._start_canary_cron_schedule(- node, workflow_id, params,+ node,+ workflow_id,+ params,cron_expr=cron_expr,timezone=timezone,frequency=frequency,schedule_desc=schedule_desc,)if schedule_id is not None:- await self._broadcaster.update_node_status(node_id, "waiting", {- "message": f"Waiting for schedule: {cron_expr} (Temporal-durable)",- "cron_expression": cron_expr,- "timezone": timezone,- "schedule_id": schedule_id,- }, workflow_id=workflow_id)+ await self._broadcaster.update_node_status(+ node_id,+ "waiting",+ {+ "message": f"Waiting for schedule: {cron_expr} (Temporal-durable)",+ "cron_expression": cron_expr,+ "timezone": timezone,+ "schedule_id": schedule_id,+ },+ workflow_id=workflow_id,+ )return TriggerInfo(node_id, "cron", job_id=schedule_id)# Fall through to legacy path if Temporal unavailable# (already logged inside _start_canary_cron_schedule).@@ -440,22 +443,19 @@ class DeploymentManager:iteration = self._cron_iterations[node_id]trigger_data = {- 'node_id': node_id,- 'timestamp': datetime.now().isoformat(),- 'trigger_type': 'cron',- 'event_data': {- 'timestamp': datetime.now().isoformat(),- 'iteration': iteration,- 'frequency': frequency,- 'timezone': timezone,- 'schedule': schedule_desc,- 'cron_expression': cron_expr- }+ "node_id": node_id,+ "timestamp": datetime.now().isoformat(),+ "trigger_type": "cron",+ "event_data": {+ "timestamp": datetime.now().isoformat(),+ "iteration": iteration,+ "frequency": frequency,+ "timezone": timezone,+ "schedule": schedule_desc,+ "cron_expression": cron_expr,+ },}- asyncio.run_coroutine_threadsafe(- self._spawn_run(node_id, trigger_data, workflow_id=workflow_id),- self._main_loop- )+ asyncio.run_coroutine_threadsafe(self._spawn_run(node_id, trigger_data, workflow_id=workflow_id), self._main_loop)trigger_manager = self._trigger_managers.get(workflow_id)if not trigger_manager:@@ -464,32 +464,27 @@ class DeploymentManager:job_id = trigger_manager.setup_cron(node_id, cron_expr, timezone, on_tick)# Broadcast waiting status for cron trigger (like event triggers do)- await self._broadcaster.update_node_status(node_id, "waiting", {- "message": f"Waiting for schedule: {cron_expr}",- "cron_expression": cron_expr,- "timezone": timezone,- "job_id": job_id- }, workflow_id=workflow_id)+ await self._broadcaster.update_node_status(+ node_id,+ "waiting",+ {"message": f"Waiting for schedule: {cron_expr}", "cron_expression": cron_expr, "timezone": timezone, "job_id": job_id},+ workflow_id=workflow_id,+ )return TriggerInfo(node_id, "cron", job_id=job_id)async def _fire_start_trigger(self, node: Dict, workflow_id: str) -> TriggerInfo:"""Fire a start trigger immediately."""- node_id = node['id']+ node_id = node["id"]params = await self.database.get_node_parameters(node_id) or {}- initial_data_str = params.get('initial_data', '{}')+ initial_data_str = params.get("initial_data", "{}")try:initial_data = json.loads(initial_data_str) if initial_data_str else {}except json.JSONDecodeError:initial_data = {}- trigger_data = {- 'node_id': node_id,- 'timestamp': datetime.now().isoformat(),- 'trigger_type': 'start',- 'event_data': initial_data- }+ trigger_data = {"node_id": node_id, "timestamp": datetime.now().isoformat(), "trigger_type": "start", "event_data": initial_data}await self._spawn_run(node_id, trigger_data, workflow_id=workflow_id)return TriggerInfo(node_id, "start", fired=True)@@ -514,8 +509,8 @@ class DeploymentManager:restart — pre-Wave-12 behaviour, kept for triggers not yeton the canary list."""- node_id = node['id']- node_type = node.get('type', '')+ node_id = node["id"]+ node_type = node.get("type", "")params = await self.database.get_node_parameters(node_id) or {}# Path 1: Wave 12 C1 canary — Temporal-durable listener.@@ -528,10 +523,10 @@ class DeploymentManager:async def on_event(event_data: Dict):trigger_data = {- 'node_id': node_id,- 'timestamp': datetime.now().isoformat(),- 'trigger_type': node_type,- 'event_data': event_data+ "node_id": node_id,+ "timestamp": datetime.now().isoformat(),+ "trigger_type": node_type,+ "event_data": event_data,}await self._spawn_run(node_id, trigger_data, wait=True, workflow_id=workflow_id)@@ -552,17 +547,13 @@ class DeploymentManager:if factory is not None:poll_coroutine = factory(node_id, params)await trigger_manager.setup_polling_trigger(- node_id, node_type, params, poll_coroutine, on_event,- self._broadcaster, workflow_id=workflow_id+ node_id, node_type, params, poll_coroutine, on_event, self._broadcaster, workflow_id=workflow_id)return TriggerInfo(node_id, node_type)# Fall through to event_waiter if no polling factory registeredlogger.warning("No polling factory registered for trigger", node_type=node_type)- await trigger_manager.setup_event_trigger(- node_id, node_type, params, on_event, self._broadcaster,- workflow_id=workflow_id- )+ await trigger_manager.setup_event_trigger(node_id, node_type, params, on_event, self._broadcaster, workflow_id=workflow_id)return TriggerInfo(node_id, node_type)# =========================================================================@@ -690,9 +681,10 @@ class DeploymentManager:wrapper = container.temporal_client()if wrapper is None or wrapper.client is None:logger.warning(- "Canary listener requested but Temporal not connected; "- "falling back to legacy collector/processor path",- node_id=node_id, workflow_id=workflow_id, node_type=node_type,+ "Canary listener requested but Temporal not connected; " "falling back to legacy collector/processor path",+ node_id=node_id,+ workflow_id=workflow_id,+ node_type=node_type,)return None@@ -727,7 +719,9 @@ class DeploymentManager:"falling back to legacy event_type for EventType SA. This will ""silently fail dispatch.emit fan-out — register cloudevent_type ""in the plugin's __init__.py.",- node_id=node_id, workflow_id=workflow_id, node_type=node_type,+ node_id=node_id,+ workflow_id=workflow_id,+ node_type=node_type,)cloudevent_type = event_type@@ -735,10 +729,7 @@ class DeploymentManager:# the "polling" classification for ops dashboards independent# of the per-plugin kind (gmail / twitter / ...).is_polling = self._is_polling_trigger_class(node_type)- workflow_type_name = (- _POLLING_LISTENER_WORKFLOW_TYPE if is_polling- else _PUSH_LISTENER_WORKFLOW_TYPE- )+ workflow_type_name = _POLLING_LISTENER_WORKFLOW_TYPE if is_polling else _PUSH_LISTENER_WORKFLOW_TYPEtrigger_kind = "polling" if is_polling else self._trigger_kind_for(node_type)listener_id = self._listener_workflow_id(workflow_id, node_id)@@ -782,20 +773,23 @@ class DeploymentManager:id=listener_id,task_queue="machina-tasks",id_conflict_policy=WorkflowIDConflictPolicy.USE_EXISTING,- search_attributes=TypedSearchAttributes([- # MUST be the CloudEvents type the producer emits on- # outgoing envelopes — dispatch.emit's Visibility query- # substitutes ``event.type`` into the EventType filter.- SearchAttributePair(event_type_key, cloudevent_type),- SearchAttributePair(trigger_node_id_key, node_id),- SearchAttributePair(event_workflow_id_key, workflow_id),- SearchAttributePair(event_trigger_kind_key, trigger_kind),- ]),+ search_attributes=TypedSearchAttributes(+ [+ # MUST be the CloudEvents type the producer emits on+ # outgoing envelopes — dispatch.emit's Visibility query+ # substitutes ``event.type`` into the EventType filter.+ SearchAttributePair(event_type_key, cloudevent_type),+ SearchAttributePair(trigger_node_id_key, node_id),+ SearchAttributePair(event_workflow_id_key, workflow_id),+ SearchAttributePair(event_trigger_kind_key, trigger_kind),+ ]+ ),)# Broadcast waiting status (parity with legacy path).await self._broadcaster.update_node_status(- node_id, "waiting",+ node_id,+ "waiting",{"message": f"Waiting for {config.display_name if config else node_type} (Temporal-durable)...","event_type": event_type,@@ -832,7 +826,8 @@ class DeploymentManager:return 0return await delete_cron_schedules_for_deployment(- wrapper.client, workflow_id,+ wrapper.client,+ workflow_id,)async def _start_canary_cron_schedule(@@ -864,9 +859,9 @@ class DeploymentManager:wrapper = container.temporal_client()if wrapper is None or wrapper.client is None:logger.warning(- "Canary cron Schedule requested but Temporal not connected; "- "falling back to APScheduler",- node_id=node_id, workflow_id=workflow_id,+ "Canary cron Schedule requested but Temporal not connected; " "falling back to APScheduler",+ node_id=node_id,+ workflow_id=workflow_id,)return None@@ -931,11 +926,7 @@ class DeploymentManager:# (TriggerListenerWorkflow) and polling (PollingTriggerWorkflow)# listeners drain in one sweep.wf_types_in = ", ".join(f"'{t}'" for t in _LISTENER_WORKFLOW_TYPES)- query = (- f"EventWorkflowId='{workflow_id}' "- f"AND WorkflowType IN ({wf_types_in}) "- f"AND ExecutionStatus='Running'"- )+ query = f"EventWorkflowId='{workflow_id}' " f"AND WorkflowType IN ({wf_types_in}) " f"AND ExecutionStatus='Running'"cancelled = 0try:@@ -951,8 +942,7 @@ class DeploymentManager:)except Exception as exc: # noqa: BLE001logger.warning(- f"Visibility query for canary listeners failed: {exc} "- f"(query={query!r})",+ f"Visibility query for canary listeners failed: {exc} " f"(query={query!r})",workflow_id=workflow_id,)@@ -969,17 +959,13 @@ class DeploymentManager:# =========================================================================async def _spawn_run(- self,- trigger_node_id: str,- trigger_data: Dict[str, Any],- wait: bool = False,- workflow_id: Optional[str] = None+ self, trigger_node_id: str, trigger_data: Dict[str, Any], wait: bool = False, workflow_id: Optional[str] = None) -> Optional[asyncio.Task]:"""Spawn a new execution run for a specific workflow."""if not workflow_id:# Backward compatibility: find workflow for this trigger nodefor wid, state in self._deployments.items():- if state.is_running and any(n['id'] == trigger_node_id for n in state.nodes):+ if state.is_running and any(n["id"] == trigger_node_id for n in state.nodes):workflow_id = widbreak@@ -1000,24 +986,25 @@ class DeploymentManager:self._run_counters[workflow_id] = self._run_counters.get(workflow_id, 0) + 1run_id = f"run_{state.deployment_id}_{self._run_counters[workflow_id]}"- await self._notify("run_started", {- "run_id": run_id,- "workflow_id": workflow_id,- "trigger_node_id": trigger_node_id,- "active_runs": active_count + 1- }, workflow_id)+ await self._notify(+ "run_started",+ {"run_id": run_id, "workflow_id": workflow_id, "trigger_node_id": trigger_node_id, "active_runs": active_count + 1},+ workflow_id,+ )async def execute():try:- result = await self._execute_from_trigger(- run_id, trigger_node_id, trigger_data, workflow_id+ result = await self._execute_from_trigger(run_id, trigger_node_id, trigger_data, workflow_id)+ await self._notify(+ "run_completed",+ {+ "run_id": run_id,+ "workflow_id": workflow_id,+ "success": result.get("success", False),+ "execution_time": result.get("execution_time"),+ },+ workflow_id,)- await self._notify("run_completed", {- "run_id": run_id,- "workflow_id": workflow_id,- "success": result.get("success", False),- "execution_time": result.get("execution_time")- }, workflow_id)except asyncio.CancelledError:logger.debug("Run cancelled", run_id=run_id, workflow_id=workflow_id)except Exception as e:@@ -1042,11 +1029,7 @@ class DeploymentManager:return taskasync def _execute_from_trigger(- self,- run_id: str,- trigger_node_id: str,- trigger_data: Dict[str, Any],- workflow_id: str+ self, run_id: str, trigger_node_id: str, trigger_data: Dict[str, Any], workflow_id: str) -> Dict[str, Any]:"""Execute workflow from a trigger node."""state = self._deployments.get(workflow_id)@@ -1057,15 +1040,11 @@ class DeploymentManager:run_session_id = f"{state.session_id}_{run_id}"# Store trigger output- trigger_output = trigger_data.get('event_data', trigger_data)+ trigger_output = trigger_data.get("event_data", trigger_data)await self._store_output(run_session_id, trigger_node_id, "output_0", trigger_output)# Get downstream nodes- downstream = self._get_downstream_nodes(- trigger_node_id,- state.nodes,- state.edges- )+ downstream = self._get_downstream_nodes(trigger_node_id, state.nodes, state.edges)if not downstream:return {@@ -1074,33 +1053,30 @@ class DeploymentManager:"workflow_id": workflow_id,"nodes_executed": [trigger_node_id],"execution_time": time.time() - start_time,- "message": "No downstream nodes"+ "message": "No downstream nodes",}# Build filtered graph- run_filter = {trigger_node_id} | {n['id'] for n in downstream}+ run_filter = {trigger_node_id} | {n["id"] for n in downstream}logger.debug(f"[Run] run_filter has {len(run_filter)} nodes")filtered_nodes = []for node in state.nodes:- if node['id'] not in run_filter:+ if node["id"] not in run_filter:continuenode_copy = node.copy()- node_type = node.get('type', '')- if node['id'] == trigger_node_id:- node_copy['_pre_executed'] = True- node_copy['_trigger_output'] = trigger_output+ node_type = node.get("type", "")+ if node["id"] == trigger_node_id:+ node_copy["_pre_executed"] = True+ node_copy["_trigger_output"] = trigger_outputelif node_type in WORKFLOW_TRIGGER_TYPES:# Non-firing triggers: pre-execute to prevent blocking as event waiters- node_copy['_pre_executed'] = True- node_copy['_trigger_output'] = {'not_triggered': True}+ node_copy["_pre_executed"] = True+ node_copy["_trigger_output"] = {"not_triggered": True}logger.debug(f"[Run] Marking non-firing trigger as pre-executed: {node['id']} ({node_type})")filtered_nodes.append(node_copy)- filtered_edges = [- e for e in state.edges- if e.get('source') in run_filter and e.get('target') in run_filter- ]+ filtered_edges = [e for e in state.edges if e.get("source") in run_filter and e.get("target") in run_filter]logger.debug(f"[Run] filtered_edges: {len(filtered_edges)} edges")# Execute filtered graph with deployment's workflow_id for scoped status@@ -1121,26 +1097,21 @@ class DeploymentManager:result["trigger_node_id"] = trigger_node_idreturn result- def _get_downstream_nodes(- self,- node_id: str,- nodes: List[Dict],- edges: List[Dict]- ) -> List[Dict]:+ def _get_downstream_nodes(self, node_id: str, nodes: List[Dict], edges: List[Dict]) -> List[Dict]:"""Get all downstream nodes from a trigger."""downstream_ids = set()- node_types = {n['id']: n.get('type', '') for n in nodes}- nodes_with_inputs = {e.get('target') for e in edges if e.get('target')}+ node_types = {n["id"]: n.get("type", "") for n in nodes}+ nodes_with_inputs = {e.get("target") for e in edges if e.get("target")}def collect(current_id: str):for edge in edges:- if edge.get('source') != current_id:+ if edge.get("source") != current_id:continue- target_id = edge.get('target')+ target_id = edge.get("target")if not target_id or target_id in downstream_ids:continue- target_type = node_types.get(target_id, '')+ target_type = node_types.get(target_id, "")is_trigger = target_type in WORKFLOW_TRIGGER_TYPES# Stop at trigger nodes — they are independent event listeners,@@ -1156,15 +1127,15 @@ class DeploymentManager:# Include config nodes connected to downstream nodesfor edge in edges:- target = edge.get('target')- source = edge.get('source')- handle = edge.get('targetHandle', '')+ target = edge.get("target")+ source = edge.get("source")+ handle = edge.get("targetHandle", "")- is_config = handle and handle.startswith('input-') and handle != 'input-main'+ is_config = handle and handle.startswith("input-") and handle != "input-main"if is_config and target in downstream_ids and source not in downstream_ids:# Never include trigger nodes as config dependencies -# they are event listeners, not configuration providers- source_type = node_types.get(source, '')+ source_type = node_types.get(source, "")if source_type in WORKFLOW_TRIGGER_TYPES:continuedownstream_ids.add(source)@@ -1174,10 +1145,10 @@ class DeploymentManager:# handle) and need to be included so the toolkit can discover# them. ``TOOLKIT_NODE_TYPES`` is the canonical set; today only# ``androidTool`` is in it.- toolkit_node_ids = {n['id'] for n in nodes if n.get('type') in TOOLKIT_NODE_TYPES and n['id'] in downstream_ids}+ toolkit_node_ids = {n["id"] for n in nodes if n.get("type") in TOOLKIT_NODE_TYPES and n["id"] in downstream_ids}for edge in edges:- target = edge.get('target')- source = edge.get('source')+ target = edge.get("target")+ source = edge.get("source")# Include nodes that connect to toolkit nodesif target in toolkit_node_ids and source not in downstream_ids:downstream_ids.add(source)@@ -1187,17 +1158,18 @@ class DeploymentManager:# When a child agent is included, we need its connected tools so the parent# can discover what capabilities the child hasfrom constants import AI_AGENT_TYPES- agent_node_ids = {n['id'] for n in nodes if n.get('type') in AI_AGENT_TYPES and n['id'] in downstream_ids}++ agent_node_ids = {n["id"] for n in nodes if n.get("type") in AI_AGENT_TYPES and n["id"] in downstream_ids}for edge in edges:- target = edge.get('target')- source = edge.get('source')- target_handle = edge.get('targetHandle', '')+ target = edge.get("target")+ source = edge.get("source")+ target_handle = edge.get("targetHandle", "")# Include tool nodes connected to agent's input-tools handle- if target in agent_node_ids and target_handle == 'input-tools' and source not in downstream_ids:+ if target in agent_node_ids and target_handle == "input-tools" and source not in downstream_ids:downstream_ids.add(source)logger.debug(f"[Deployment] Including tool node {source} connected to agent {target}")- return [n for n in nodes if n['id'] in downstream_ids]+ return [n for n in nodes if n["id"] in downstream_ids]# =========================================================================# HELPERS@@ -1219,11 +1191,13 @@ class DeploymentManager:try:db_settings = await self.database.get_deployment_settings()if db_settings:- self._settings.update({- "stop_on_error": db_settings.get("stop_on_error", False),- "max_concurrent_runs": db_settings.get("max_concurrent_runs", 100),- "use_parallel_executor": db_settings.get("use_parallel_executor", True)- })+ self._settings.update(+ {+ "stop_on_error": db_settings.get("stop_on_error", False),+ "max_concurrent_runs": db_settings.get("max_concurrent_runs", 100),+ "use_parallel_executor": db_settings.get("use_parallel_executor", True),+ }+ )except Exception:pass@@ -1243,43 +1217,39 @@ class DeploymentManager:returntry:- await status_callback("__deployment__", event, {- **data,- "workflow_id": workflow_id,- "timestamp": datetime.now().isoformat()- })+ await status_callback("__deployment__", event, {**data, "workflow_id": workflow_id, "timestamp": datetime.now().isoformat()})except Exception as e:logger.warning("Status callback failed", workflow_id=workflow_id, error=str(e))@staticmethoddef _get_schedule_description(params: Dict[str, Any]) -> str:"""Get human-readable schedule description from parameters."""- frequency = params.get('frequency', 'minutes')+ frequency = params.get("frequency", "minutes")match frequency:- case 'seconds':- interval = params.get('interval', 30)+ case "seconds":+ interval = params.get("interval", 30)return f"Every {interval} seconds"- case 'minutes':- interval = params.get('interval_minutes', 5)+ case "minutes":+ interval = params.get("interval_minutes", 5)return f"Every {interval} minutes"- case 'hours':- interval = params.get('interval_hours', 1)+ case "hours":+ interval = params.get("interval_hours", 1)return f"Every {interval} hours"- case 'days':- time_str = params.get('daily_time', '09:00')+ case "days":+ time_str = params.get("daily_time", "09:00")return f"Daily at {time_str}"- case 'weeks':- weekday = params.get('weekday', '1')- time_str = params.get('weekly_time', '09:00')- days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']+ case "weeks":+ weekday = params.get("weekday", "1")+ time_str = params.get("weekly_time", "09:00")+ days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]day_name = days[int(weekday)] if str(weekday).isdigit() else weekdayreturn f"Weekly on {day_name} at {time_str}"- case 'months':- day = params.get('month_day', '1')- time_str = params.get('monthly_time', '09:00')+ case "months":+ day = params.get("month_day", "1")+ time_str = params.get("monthly_time", "09:00")return f"Monthly on day {day} at {time_str}"- case 'once':+ case "once":return "Once (no repeat)"case _:return "Unknown schedule"diff --git a/server/services/deployment/poll_registry.py b/server/services/deployment/poll_registry.pyindex c80661eb..5a225a2f 100644--- a/server/services/deployment/poll_registry.py+++ b/server/services/deployment/poll_registry.py@@ -37,14 +37,10 @@ PollCoroutine = Callable[[asyncio.Queue, Callable[[], bool]], Awaitable[None]]PollCoroutineFactory = Callable[[str, Dict[str, Any]], PollCoroutine]-_REGISTRY: IdempotentRegistry[str, PollCoroutineFactory] = IdempotentRegistry(- "poll_coroutine_factory"-)+_REGISTRY: IdempotentRegistry[str, PollCoroutineFactory] = IdempotentRegistry("poll_coroutine_factory")-def register_poll_coroutine_factory(- node_type: str, factory: PollCoroutineFactory-) -> None:+def register_poll_coroutine_factory(node_type: str, factory: PollCoroutineFactory) -> None:"""Publish a polling-coroutine factory for a trigger node type.Idempotent on re-import (same callable for the same key is adiff --git a/server/services/deployment/state.py b/server/services/deployment/state.pyindex 544d7375..58a75c0b 100644--- a/server/services/deployment/state.py+++ b/server/services/deployment/state.py@@ -8,6 +8,7 @@ from typing import Dict, Any, List, Optional@dataclassclass DeploymentState:"""Immutable deployment state."""+deployment_id: strworkflow_id: stris_running: bool@@ -33,6 +34,7 @@ class DeploymentState:@dataclassclass TriggerInfo:"""Info about a registered trigger."""+node_id: strnode_type: strjob_id: Optional[str] = None # For cron triggersdiff --git a/server/services/deployment/triggers.py b/server/services/deployment/triggers.pyindex cf1f1ba6..b4eddcf4 100644--- a/server/services/deployment/triggers.py+++ b/server/services/deployment/triggers.py@@ -33,8 +33,7 @@ class TriggerManager:# CRON TRIGGERS# =========================================================================- def setup_cron(self, node_id: str, cron_expr: str, timezone: str,- on_tick: Callable[[], None]) -> str:+ def setup_cron(self, node_id: str, cron_expr: str, timezone: str, on_tick: Callable[[], None]) -> str:"""Setup a cron trigger that calls on_tick on schedule."""job_id = f"cron_{node_id}"@@ -43,12 +42,7 @@ class TriggerManager:returnon_tick()- cron_scheduler.register_cron_job(- job_id=job_id,- cron_expression=cron_expr,- callback=tick_callback,- timezone=timezone- )+ cron_scheduler.register_cron_job(job_id=job_id, cron_expression=cron_expr, callback=tick_callback, timezone=timezone)self._active_cron_jobs[node_id] = job_idlogger.info("Cron trigger setup", job_id=job_id, expr=cron_expr)@@ -81,11 +75,15 @@ class TriggerManager:# EVENT TRIGGERS (Webhook, WhatsApp, etc.)# =========================================================================- async def setup_event_trigger(self, node_id: str, node_type: str,- parameters: Dict[str, Any],- on_event: Callable[[Dict], Any],- broadcaster: Any,- workflow_id: Optional[str] = None) -> None:+ async def setup_event_trigger(+ self,+ node_id: str,+ node_type: str,+ parameters: Dict[str, Any],+ on_event: Callable[[Dict], Any],+ broadcaster: Any,+ workflow_id: Optional[str] = None,+ ) -> None:"""Setup an event-based trigger with queue-based sequential processing.Args:@@ -111,12 +109,12 @@ class TriggerManager:msg = f"Waiting for {config.display_name}..."if queue_size > 0:msg = f"Waiting... ({queue_size} queued)"- await broadcaster.update_node_status(node_id, "waiting", {- "message": msg,- "event_type": config.event_type,- "waiter_id": waiter.id,- "queue_size": queue_size- }, workflow_id=workflow_id)+ await broadcaster.update_node_status(+ node_id,+ "waiting",+ {"message": msg, "event_type": config.event_type, "waiter_id": waiter.id, "queue_size": queue_size},+ workflow_id=workflow_id,+ )event_data = await event_waiter.wait_for_event(waiter)if self._is_running:@@ -143,10 +141,9 @@ class TriggerManager:config = event_waiter.get_trigger_config(node_type)# Clear waiting indicator during execution- await broadcaster.update_node_status(node_id, "idle", {- "message": "Graph executing...",- "is_processing": True- }, workflow_id=workflow_id)+ await broadcaster.update_node_status(+ node_id, "idle", {"message": "Graph executing...", "is_processing": True}, workflow_id=workflow_id+ )try:await on_event(event_data)@@ -159,11 +156,9 @@ class TriggerManager:queue_size = event_queue.qsize()name = config.display_name if config else node_typemsg = f"Waiting for {name}..." if queue_size == 0 else f"Processing next... ({queue_size} queued)"- await broadcaster.update_node_status(node_id, "waiting", {- "message": msg,- "queue_size": queue_size,- "is_processing": False- }, workflow_id=workflow_id)+ await broadcaster.update_node_status(+ node_id, "waiting", {"message": msg, "queue_size": queue_size, "is_processing": False}, workflow_id=workflow_id+ )except asyncio.CancelledError:break@@ -184,12 +179,16 @@ class TriggerManager:task = asyncio.create_task(combined())self._active_listeners[node_id] = task- async def setup_polling_trigger(self, node_id: str, node_type: str,- parameters: Dict[str, Any],- poll_coroutine: Callable,- on_event: Callable[[Dict], Any],- broadcaster: Any,- workflow_id: Optional[str] = None) -> None:+ async def setup_polling_trigger(+ self,+ node_id: str,+ node_type: str,+ parameters: Dict[str, Any],+ poll_coroutine: Callable,+ on_event: Callable[[Dict], Any],+ broadcaster: Any,+ workflow_id: Optional[str] = None,+ ) -> None:"""Setup a polling-based trigger with queue-based sequential processing.Unlike event triggers that wait for externally dispatched events via@@ -211,10 +210,9 @@ class TriggerManager:# Broadcast initial "waiting" status immediatelyconfig = event_waiter.get_trigger_config(node_type)display_name = config.display_name if config else node_type- await broadcaster.update_node_status(node_id, "waiting", {- "message": f"Waiting for {display_name} (polling)...",- "is_processing": False- }, workflow_id=workflow_id)+ await broadcaster.update_node_status(+ node_id, "waiting", {"message": f"Waiting for {display_name} (polling)...", "is_processing": False}, workflow_id=workflow_id+ )async def poller():"""Run the polling coroutine to collect events."""@@ -238,10 +236,9 @@ class TriggerManager:is_executing = Trueconfig = event_waiter.get_trigger_config(node_type)- await broadcaster.update_node_status(node_id, "idle", {- "message": "Graph executing...",- "is_processing": True- }, workflow_id=workflow_id)+ await broadcaster.update_node_status(+ node_id, "idle", {"message": "Graph executing...", "is_processing": True}, workflow_id=workflow_id+ )try:await on_event(event_data)@@ -253,11 +250,9 @@ class TriggerManager:queue_size = event_queue.qsize()name = config.display_name if config else node_typemsg = f"Waiting for {name} (polling)..." if queue_size == 0 else f"Processing next... ({queue_size} queued)"- await broadcaster.update_node_status(node_id, "waiting", {- "message": msg,- "queue_size": queue_size,- "is_processing": False- }, workflow_id=workflow_id)+ await broadcaster.update_node_status(+ node_id, "waiting", {"message": msg, "queue_size": queue_size, "is_processing": False}, workflow_id=workflow_id+ )except asyncio.CancelledError:break@@ -303,48 +298,48 @@ class TriggerManager:@staticmethoddef build_cron_expression(parameters: Dict[str, Any]) -> Optional[str]:"""Build cron expression from user-friendly parameters."""- frequency = parameters.get('frequency', 'minutes')-- second, minute, hour = '0', '*/5', '*'- day, month, weekday = '*', '*', '*'-- if frequency == 'seconds':- interval = str(parameters.get('interval', 30))- second, minute = f'*/{interval}', '*'-- elif frequency == 'minutes':- interval = str(parameters.get('interval_minutes', 5))- minute = f'*/{interval}' if interval != '1' else '*'-- elif frequency == 'hours':- interval = str(parameters.get('interval_hours', 1))- minute = '0'- hour = f'*/{interval}' if interval != '1' else '*'-- elif frequency == 'days':- time_str = parameters.get('daily_time', '09:00')- parts = time_str.split(':')- hour = parts[0] if parts else '9'- minute = parts[1] if len(parts) > 1 else '0'-- elif frequency == 'weeks':- time_str = parameters.get('weekly_time', '09:00')- parts = time_str.split(':')- hour = parts[0] if parts else '9'- minute = parts[1] if len(parts) > 1 else '0'- weekday = parameters.get('weekday', '1')-- elif frequency == 'months':- time_str = parameters.get('monthly_time', '09:00')- parts = time_str.split(':')- hour = parts[0] if parts else '9'- minute = parts[1] if len(parts) > 1 else '0'- day = parameters.get('month_day', '1')-- elif frequency == 'once':+ frequency = parameters.get("frequency", "minutes")++ second, minute, hour = "0", "*/5", "*"+ day, month, weekday = "*", "*", "*"++ if frequency == "seconds":+ interval = str(parameters.get("interval", 30))+ second, minute = f"*/{interval}", "*"++ elif frequency == "minutes":+ interval = str(parameters.get("interval_minutes", 5))+ minute = f"*/{interval}" if interval != "1" else "*"++ elif frequency == "hours":+ interval = str(parameters.get("interval_hours", 1))+ minute = "0"+ hour = f"*/{interval}" if interval != "1" else "*"++ elif frequency == "days":+ time_str = parameters.get("daily_time", "09:00")+ parts = time_str.split(":")+ hour = parts[0] if parts else "9"+ minute = parts[1] if len(parts) > 1 else "0"++ elif frequency == "weeks":+ time_str = parameters.get("weekly_time", "09:00")+ parts = time_str.split(":")+ hour = parts[0] if parts else "9"+ minute = parts[1] if len(parts) > 1 else "0"+ weekday = parameters.get("weekday", "1")++ elif frequency == "months":+ time_str = parameters.get("monthly_time", "09:00")+ parts = time_str.split(":")+ hour = parts[0] if parts else "9"+ minute = parts[1] if len(parts) > 1 else "0"+ day = parameters.get("month_day", "1")++ elif frequency == "once":return None- return f'{second} {minute} {hour} {day} {month} {weekday}'+ return f"{second} {minute} {hour} {day} {month} {weekday}"@staticmethoddef find_trigger_nodes(nodes: list, edges: list) -> tuple:@@ -355,16 +350,15 @@ class TriggerManager:after an AI agent). Each trigger listens for its event type and, when fired,executes its downstream subgraph independently."""- trigger_types_no_cron = WORKFLOW_TRIGGER_TYPES - {'cronScheduler'}- triggers = [n for n in nodes- if n.get('type') in trigger_types_no_cron]+ trigger_types_no_cron = WORKFLOW_TRIGGER_TYPES - {"cronScheduler"}+ triggers = [n for n in nodes if n.get("type") in trigger_types_no_cron]- start_nodes = [n for n in triggers if n.get('type') == 'start']- event_triggers = [n for n in triggers if n.get('type') != 'start']+ start_nodes = [n for n in triggers if n.get("type") == "start"]+ event_triggers = [n for n in triggers if n.get("type") != "start"]return start_nodes, event_triggers@staticmethoddef find_cron_nodes(nodes: list) -> list:"""Find all cron scheduler nodes."""- return [n for n in nodes if n.get('type') == 'cronScheduler']+ return [n for n in nodes if n.get("type") == "cronScheduler"]diff --git a/server/services/event_waiter.py b/server/services/event_waiter.pyindex d096aba2..ba4018aa 100644--- a/server/services/event_waiter.py+++ b/server/services/event_waiter.py@@ -7,6 +7,7 @@ Architecture:- Redis mode: Events stored in Redis Streams, waiters poll streams with blocking XREAD- Memory mode: Events dispatched to in-memory asyncio.Future waiters"""+import asyncioimport jsonimport uuid@@ -74,9 +75,11 @@ def is_redis_mode() -> bool:# TRIGGER CONFIGURATION REGISTRY# =============================================================================+@dataclassclass TriggerConfig:"""Configuration for a trigger node type."""+node_type: strevent_type: str # Event to wait for (e.g., 'whatsapp_message_received')display_name: str@@ -86,26 +89,10 @@ class TriggerConfig:# Note: cronScheduler is NOT an event-based trigger - it uses APScheduler directlyTRIGGER_REGISTRY: Dict[str, TriggerConfig] = {# Framework-level triggers — not owned by any plugin domain.- 'start': TriggerConfig(- node_type='start',- event_type='deploy_triggered',- display_name='Deploy Start'- ),- 'webhookTrigger': TriggerConfig(- node_type='webhookTrigger',- event_type='webhook_received',- display_name='Webhook Request'- ),- 'chatTrigger': TriggerConfig(- node_type='chatTrigger',- event_type='chat_message_received',- display_name='Chat Message'- ),- 'taskTrigger': TriggerConfig(- node_type='taskTrigger',- event_type='task_completed',- display_name='Task Completed'- ),+ "start": TriggerConfig(node_type="start", event_type="deploy_triggered", display_name="Deploy Start"),+ "webhookTrigger": TriggerConfig(node_type="webhookTrigger", event_type="webhook_received", display_name="Webhook Request"),+ "chatTrigger": TriggerConfig(node_type="chatTrigger", event_type="chat_message_received", display_name="Chat Message"),+ "taskTrigger": TriggerConfig(node_type="taskTrigger", event_type="task_completed", display_name="Task Completed"),# Plugin-owned trigger entries (whatsappReceive, twitterReceive,# telegramReceive, emailReceive, googleGmailReceive) live in their# plugin folders' ``_filters.py`` and are backfilled here from each@@ -175,6 +162,7 @@ def is_trigger_node(node_type: str) -> bool:This includes all trigger types: start, cronScheduler, and event-based triggers."""from constants import WORKFLOW_TRIGGER_TYPES+return node_type in WORKFLOW_TRIGGER_TYPES@@ -199,6 +187,7 @@ def get_trigger_config(node_type: str) -> Optional[TriggerConfig]:# FILTER BUILDERS - One per trigger type# =============================================================================+def build_webhook_filter(params: Dict) -> Callable[[Dict], bool]:"""Build filter function for webhook requests.@@ -210,10 +199,10 @@ def build_webhook_filter(params: Dict) -> Callable[[Dict], bool]:Returns:Filter function that checks if event path matches"""- webhook_path = params.get('path', '')+ webhook_path = params.get("path", "")def matches(data: Dict) -> bool:- event_path = data.get('path', '')+ event_path = data.get("path", "")if webhook_path and event_path != webhook_path:return Falsereturn True@@ -231,11 +220,11 @@ def build_chat_filter(params: Dict) -> Callable[[Dict], bool]:Returns:Filter function that checks if event session_id matches"""- session_id = params.get('session_id', 'default')+ session_id = params.get("session_id", "default")def matches(data: Dict) -> bool:- event_session = data.get('session_id', 'default')- if session_id != 'default' and event_session != session_id:+ event_session = data.get("session_id", "default")+ if session_id != "default" and event_session != session_id:return Falsereturn True@@ -257,33 +246,33 @@ def build_task_completed_filter(params: Dict) -> Callable[[Dict], bool]:Returns:Filter function that checks if event matches criteria"""- task_id_filter = params.get('task_id', '')- agent_name_filter = params.get('agent_name', '')- status_filter = params.get('status_filter', 'all') # all, completed, error- parent_node_id = params.get('parent_node_id', '')+ task_id_filter = params.get("task_id", "")+ agent_name_filter = params.get("agent_name", "")+ status_filter = params.get("status_filter", "all") # all, completed, error+ parent_node_id = params.get("parent_node_id", "")def matches(data: Dict) -> bool:# Task ID filter (exact match if specified)if task_id_filter:- if data.get('task_id') != task_id_filter:+ if data.get("task_id") != task_id_filter:return False# Agent name filter (contains match)if agent_name_filter:- event_agent = data.get('agent_name', '')+ event_agent = data.get("agent_name", "")if agent_name_filter.lower() not in event_agent.lower():return False# Status filter- event_status = data.get('status', '')- if status_filter == 'completed' and event_status != 'completed':+ event_status = data.get("status", "")+ if status_filter == "completed" and event_status != "completed":return False- if status_filter == 'error' and event_status != 'error':+ if status_filter == "error" and event_status != "error":return False# Parent node filter (for scoping to specific parent agent)if parent_node_id:- if data.get('parent_node_id') != parent_node_id:+ if data.get("parent_node_id") != parent_node_id:return Falsereturn True@@ -301,17 +290,17 @@ def build_task_completed_filter(params: Dict) -> Callable[[Dict], bool]:# googleGmailReceive, emailReceive) live in their plugin folders'# ``_filters.py`` and self-register at import time.FILTER_BUILDERS: Dict[str, Callable[[Dict], Callable[[Dict], bool]]] = {- 'webhookTrigger': build_webhook_filter,- 'chatTrigger': build_chat_filter,- 'taskTrigger': build_task_completed_filter,+ "webhookTrigger": build_webhook_filter,+ "chatTrigger": build_chat_filter,+ "taskTrigger": build_task_completed_filter,}from services.plugin.registry import IdempotentRegistry as _IdempotentRegistry # noqa: E402# Backed by the module-level FILTER_BUILDERS dict so existing readers# (e.g. build_filter, _ensure_populated, tests) keep working.-_FILTER_REGISTRY: _IdempotentRegistry[str, Callable[[Dict], Callable[[Dict], bool]]] = (- _IdempotentRegistry("filter_builder", items=FILTER_BUILDERS)+_FILTER_REGISTRY: _IdempotentRegistry[str, Callable[[Dict], Callable[[Dict], bool]]] = _IdempotentRegistry(+ "filter_builder", items=FILTER_BUILDERS)@@ -361,9 +350,7 @@ import inspect as _inspect_TriggerPrecheck = Callable[[Dict[str, Any]], Any]_TRIGGER_PRECHECKS: Dict[str, _TriggerPrecheck] = {}-_TRIGGER_PRECHECK_REGISTRY: _IdempotentRegistry[str, _TriggerPrecheck] = (- _IdempotentRegistry("trigger_precheck", items=_TRIGGER_PRECHECKS)-)+_TRIGGER_PRECHECK_REGISTRY: _IdempotentRegistry[str, _TriggerPrecheck] = _IdempotentRegistry("trigger_precheck", items=_TRIGGER_PRECHECKS)def register_trigger_precheck(node_type: str, fn: _TriggerPrecheck) -> None:@@ -394,6 +381,7 @@ async def run_trigger_precheck(node_type: str, parameters: Dict) -> Any:# WAITER DATA STRUCTURES# =============================================================================+@dataclassclass Waiter:"""Single event waiter.@@ -401,6 +389,7 @@ class Waiter:In memory mode: uses asyncio.FutureIn Redis mode: uses stream polling with stored metadata"""+id: str = field(default_factory=lambda: str(uuid.uuid4()))node_id: str = ""node_type: str = ""@@ -433,6 +422,7 @@ def _get_stream_name(event_type: str) -> str:# WAITER REGISTRATION# =============================================================================+async def register(node_type: str, node_id: str, params: Dict) -> Waiter:"""Register a waiter for a trigger node.@@ -480,7 +470,7 @@ async def register(node_type: str, node_id: str, params: Dict) -> Waiter:# Create unique consumer group for this waiter# start_id='$' means only new messages from this point forwardstream_name = _get_stream_name(config.event_type)- await cache.stream_create_group(stream_name, consumer_group, start_id='$')+ await cache.stream_create_group(stream_name, consumer_group, start_id="$")logger.debug(f"[EventWaiter] Registered {node_type} waiter {waiter.id} (Redis)")else:@@ -560,9 +550,9 @@ async def _wait_redis(waiter: Waiter, timeout: Optional[float]) -> Dict:result = await cache.stream_read_group(consumer_group, # Each waiter has its own groupconsumer_name,- {stream_name: '>'}, # '>' = new messages for this consumer+ {stream_name: ">"}, # '>' = new messages for this consumercount=10,- block=block_ms+ block=block_ms,)if not result:@@ -616,6 +606,7 @@ def _cleanup_waiter(waiter_id: str) -> None:# EVENT DISPATCH# =============================================================================+def _unpack_event(event: "Any",data: Optional[Dict] = None,@@ -638,10 +629,7 @@ def _unpack_event(return event.type, event.data if isinstance(event.data, dict) else {"data": event.data}if isinstance(event, str):return event, data or {}- raise TypeError(- f"dispatch expects a WorkflowEvent or (event_type: str, data: Dict); "- f"got {type(event).__name__}"- )+ raise TypeError(f"dispatch expects a WorkflowEvent or (event_type: str, data: Dict); " f"got {type(event).__name__}")async def dispatch_async(@@ -713,14 +701,17 @@ def dispatch(resolved = 0to_remove = []- matching_waiters = [(wid, w) for wid, w in _waiters.items()- if w.event_type == event_type and w.future and not w.future.done()]+ matching_waiters = [(wid, w) for wid, w in _waiters.items() if w.event_type == event_type and w.future and not w.future.done()]if not matching_waiters:logger.debug(f"[EventWaiter] No active waiters for {event_type} (total waiters: {len(_waiters)})")else:- logger.info(f"[EventWaiter] Dispatching {event_type} to {len(matching_waiters)} waiter(s)",- event_type=event_type, from_id=data.get('from_id'), text=str(data.get('text', ''))[:50])+ logger.info(+ f"[EventWaiter] Dispatching {event_type} to {len(matching_waiters)} waiter(s)",+ event_type=event_type,+ from_id=data.get("from_id"),+ text=str(data.get("text", ""))[:50],+ )for wid, w in matching_waiters:try:@@ -744,6 +735,7 @@ def dispatch(# WAITER CANCELLATION# =============================================================================+def cancel(waiter_id: str) -> bool:"""Cancel a waiter by ID."""if w := _waiters.pop(waiter_id, None):@@ -776,6 +768,7 @@ def cancel_for_node(node_id: str) -> int:# UTILITY FUNCTIONS# =============================================================================+def get_active_waiters() -> List[Dict[str, Any]]:"""Get info about active waiters (for debugging/UI)."""return [diff --git a/server/services/events/admin_handlers.py b/server/services/events/admin_handlers.pyindex 8749f378..35a3c13a 100644--- a/server/services/events/admin_handlers.py+++ b/server/services/events/admin_handlers.py@@ -51,7 +51,8 @@ _LISTENER_WORKFLOW_TYPES: tuple[str, ...] = (@ws_responseasync def handle_list_canary_listeners(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:"""List Temporal-durable canary listener workflows.@@ -82,15 +83,10 @@ async def handle_list_canary_listeners(wrapper = container.temporal_client()if wrapper is None or wrapper.client is None:- return {"success": True, "listeners": [], "count": 0,- "note": "Temporal not connected"}+ return {"success": True, "listeners": [], "count": 0, "note": "Temporal not connected"}wf_types_in = ", ".join(f"'{t}'" for t in _LISTENER_WORKFLOW_TYPES)- query = (- f"EventWorkflowId='{workflow_id}' "- f"AND WorkflowType IN ({wf_types_in}) "- f"AND ExecutionStatus='Running'"- )+ query = f"EventWorkflowId='{workflow_id}' " f"AND WorkflowType IN ({wf_types_in}) " f"AND ExecutionStatus='Running'"listeners: List[Dict[str, Any]] = []try:@@ -98,8 +94,7 @@ async def handle_list_canary_listeners(listeners.append(_describe_workflow(wf))except Exception as exc: # noqa: BLE001logger.warning(- f"list_canary_listeners Visibility query failed: {exc} "- f"(query={query!r})",+ f"list_canary_listeners Visibility query failed: {exc} " f"(query={query!r})",workflow_id=workflow_id,)return {"success": False, "error": str(exc), "query": query}@@ -109,7 +104,8 @@ async def handle_list_canary_listeners(@ws_responseasync def handle_list_canary_schedules(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:"""List Temporal Schedules created by this deployment's cron triggers.@@ -136,13 +132,9 @@ async def handle_list_canary_schedules(wrapper = container.temporal_client()if wrapper is None or wrapper.client is None:- return {"success": True, "schedules": [], "count": 0,- "note": "Temporal not connected"}+ return {"success": True, "schedules": [], "count": 0, "note": "Temporal not connected"}- query = (- f"EventWorkflowId='{workflow_id}' "- f"AND EventTriggerKind='cron'"- )+ query = f"EventWorkflowId='{workflow_id}' " f"AND EventTriggerKind='cron'"schedules: List[Dict[str, Any]] = []try:@@ -155,8 +147,7 @@ async def handle_list_canary_schedules(schedules.append(_describe_schedule(desc))except Exception as exc: # noqa: BLE001logger.warning(- f"list_canary_schedules Visibility query failed: {exc} "- f"(query={query!r})",+ f"list_canary_schedules Visibility query failed: {exc} " f"(query={query!r})",workflow_id=workflow_id,)return {"success": False, "error": str(exc), "query": query}@@ -166,7 +157,8 @@ async def handle_list_canary_schedules(@ws_responseasync def handle_get_workflow_failure_history(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:"""Return ActivityTaskFailed events from a workflow's Event History.@@ -210,7 +202,8 @@ async def handle_get_workflow_failure_history(run_id: Optional[str] = data.get("run_id")try:handle = wrapper.client.get_workflow_handle(- target_workflow_id, run_id=run_id,+ target_workflow_id,+ run_id=run_id,)except Exception as exc: # noqa: BLE001return {"success": False, "error": f"workflow lookup failed: {exc}"}@@ -329,10 +322,7 @@ def _search_attributes_dict(raw: Any) -> Dict[str, Any]:return resultif isinstance(raw, dict):# Untyped search-attribute map from older SDK: name -> [value, ...]- return {- k: (v[0] if isinstance(v, list) and v else v)- for k, v in raw.items()- }+ return {k: (v[0] if isinstance(v, list) and v else v) for k, v in raw.items()}return {}diff --git a/server/services/events/daemon.py b/server/services/events/daemon.pyindex 07979d60..dd37bf50 100644--- a/server/services/events/daemon.py+++ b/server/services/events/daemon.py@@ -71,6 +71,7 @@ class DaemonEventSource(EventSource):def workdir(self) -> Path:from core.config import Settings+cwd = Path(Settings().workspace_base_resolved).resolve() / self.workflow_namespacecwd.mkdir(parents=True, exist_ok=True)return cwd@@ -140,7 +141,8 @@ class DaemonEventSource(EventSource):async with self._lock:self._stopped = Trueawait get_process_service().stop(- name=self.process_name, workflow_id=self.workflow_namespace,+ name=self.process_name,+ workflow_id=self.workflow_namespace,)self._started = Falseself._pid = Nonediff --git a/server/services/events/dispatch.py b/server/services/events/dispatch.pyindex 2a959025..ec84cd45 100644--- a/server/services/events/dispatch.py+++ b/server/services/events/dispatch.py@@ -78,8 +78,7 @@ async def emit("""if not Settings().event_framework_enabled:logger.debug(- f"event-framework disabled — emit no-op for event.id={event.id} "- f"type={event.type}",+ f"event-framework disabled — emit no-op for event.id={event.id} " f"type={event.type}",)return event@@ -113,8 +112,7 @@ async def _signal_running_consumers(event: WorkflowEvent) -> None:if wrapper is None or wrapper.client is None:logger.debug(- f"emit: Temporal not connected — skipping consumer fan-out for "- f"event.id={event.id}",+ f"emit: Temporal not connected — skipping consumer fan-out for " f"event.id={event.id}",)return@@ -126,15 +124,12 @@ async def _signal_running_consumers(event: WorkflowEvent) -> None:async for wf in client.list_workflows(query=query):consumers.append(wf)except Exception as exc: # noqa: BLE001- logger.warning(- f"emit: Visibility query failed (query={query!r}): {exc}"- )+ logger.warning(f"emit: Visibility query failed (query={query!r}): {exc}")returnif not consumers:logger.debug(- f"emit: 0 consumers for event.type={event.type!r} "- f"(event.id={event.id})",+ f"emit: 0 consumers for event.type={event.type!r} " f"(event.id={event.id})",)return@@ -142,18 +137,14 @@ async def _signal_running_consumers(event: WorkflowEvent) -> None:# block other consumers (return_exceptions=True surfaces failures# as exceptions in the result list).signal_results = await asyncio.gather(- *[- _signal_one(client, wf.id, event)- for wf in consumers- ],+ *[_signal_one(client, wf.id, event) for wf in consumers],return_exceptions=True,)delivered = sum(1 for r in signal_results if not isinstance(r, Exception))failed = len(signal_results) - deliveredlogger.info(- f"emit: signalled {delivered}/{len(consumers)} consumers for "- f"event.type={event.type!r} (failed={failed}, event.id={event.id})",+ f"emit: signalled {delivered}/{len(consumers)} consumers for " f"event.type={event.type!r} (failed={failed}, event.id={event.id})",)@@ -184,14 +175,14 @@ async def _broadcast_in_process(event: WorkflowEvent, wire_routing_key: str) ->returntry:- await broadcaster.broadcast({- "type": wire_routing_key,- "data": event.model_dump(mode="json"),- })- except Exception as exc: # noqa: BLE001- logger.warning(- f"emit: WS broadcast failed (wire_key={wire_routing_key!r}): {exc}"+ await broadcaster.broadcast(+ {+ "type": wire_routing_key,+ "data": event.model_dump(mode="json"),+ })+ except Exception as exc: # noqa: BLE001+ logger.warning(f"emit: WS broadcast failed (wire_key={wire_routing_key!r}): {exc}")__all__ = ["emit"]diff --git a/server/services/events/oauth_lifecycle.py b/server/services/events/oauth_lifecycle.pyindex c868bf4d..b49e0f0b 100644--- a/server/services/events/oauth_lifecycle.py+++ b/server/services/events/oauth_lifecycle.py@@ -59,7 +59,9 @@ class OAuthLike(Protocol):"""def generate_authorization_url(- self, *, state_data: Optional[Dict[str, Any]] = None,+ self,+ *,+ state_data: Optional[Dict[str, Any]] = None,) -> Dict[str, str]: ...async def exchange_code(self, code: str, state: str) -> Dict[str, Any]: ...@@ -69,7 +71,9 @@ class OAuthLike(Protocol):async def refresh_access_token(self, refresh_token: str) -> Dict[str, Any]: ...async def revoke_token(- self, token: str, token_type: str = "access_token",+ self,+ token: str,+ token_type: str = "access_token",) -> Dict[str, Any]: ...@@ -136,10 +140,7 @@ def make_oauth_lifecycle_handlers(if not client_id:return {"success": False,- "error": (- f"{provider.capitalize()} Client ID not configured. "- f"Add your {provider.capitalize()} API credentials first."- ),+ "error": (f"{provider.capitalize()} Client ID not configured. " f"Add your {provider.capitalize()} API credentials first."),}redirect_uri = get_redirect_uri(websocket, provider)@@ -177,7 +178,8 @@ def make_oauth_lifecycle_handlers(# cached in memory; pull from DB on demand).if not user_info.get("success"):refresh_token = await auth_service.get_oauth_refresh_token(- provider, customer_id="owner",+ provider,+ customer_id="owner",)if refresh_token:refresh = await oauth.refresh_access_token(refresh_token)@@ -216,10 +218,7 @@ def make_oauth_lifecycle_handlers(auth_service = container.auth_service()tokens = await auth_service.get_oauth_tokens(provider, customer_id="owner")access_token = tokens.get("access_token") if tokens else None- refresh_token = (- await auth_service.get_oauth_refresh_token(provider, customer_id="owner")- if tokens else None- )+ refresh_token = await auth_service.get_oauth_refresh_token(provider, customer_id="owner") if tokens else Noneif access_token or refresh_token:redirect_uri = get_redirect_uri(websocket, provider)@@ -254,12 +253,14 @@ def make_oauth_lifecycle_handlers(async def _maybe_legacy_broadcast(- broadcast_type: Optional[str], payload: Dict[str, Any],+ broadcast_type: Optional[str],+ payload: Dict[str, Any],) -> None:"""Optional legacy status broadcast (Google's ``google_status`` frame)."""if not broadcast_type:returnfrom services.status_broadcaster import get_status_broadcaster+await get_status_broadcaster().broadcast({"type": broadcast_type, "data": payload})@@ -333,8 +334,10 @@ def make_oauth_callback_router(logger.warning(f"{provider} OAuth denied: {error} - {error_description}")return HTMLResponse(content=render_oauth_callback_html(- provider, status="error",- message=error_description or error, color_hex=color_hex,+ provider,+ status="error",+ message=error_description or error,+ color_hex=color_hex,),status_code=200,)@@ -342,7 +345,8 @@ def make_oauth_callback_router(if not code or not state:return HTMLResponse(content=render_oauth_callback_html(- provider, status="error",+ provider,+ status="error",message="Missing authorization code or state parameter",color_hex=color_hex,),@@ -365,7 +369,8 @@ def make_oauth_callback_router(if not result.get("success"):return HTMLResponse(content=render_oauth_callback_html(- provider, status="error",+ provider,+ status="error",message=result.get("error", "Token exchange failed"),color_hex=color_hex,),@@ -384,10 +389,13 @@ def make_oauth_callback_router(store_overrides: Dict[str, Any] = {}redirect_after: Optional[str] = Noneif extra_state_handler is not None:- override = await extra_state_handler({- "state_data": state_data, "user_info": user_info,- "tokens": result,- })+ override = await extra_state_handler(+ {+ "state_data": state_data,+ "user_info": user_info,+ "tokens": result,+ }+ )if override:redirect_after = override.pop("redirect_after", None)store_overrides.update(override)@@ -411,13 +419,15 @@ def make_oauth_callback_router(from services.status_broadcaster import get_status_broadcasterbroadcaster = get_status_broadcaster()- await broadcaster.broadcast({- "type": f"{provider}_oauth_complete",- "data": {- "success": True,- **{k: v for k, v in user_info.items() if k != "success"},- },- })+ await broadcaster.broadcast(+ {+ "type": f"{provider}_oauth_complete",+ "data": {+ "success": True,+ **{k: v for k, v in user_info.items() if k != "success"},+ },+ }+ )await broadcaster.broadcast_credential_event("credential.oauth.connected",provider=provider,@@ -426,12 +436,15 @@ def make_oauth_callback_router(if redirect_after:from fastapi.responses import RedirectResponse+return RedirectResponse(url=redirect_after, status_code=302)return HTMLResponse(content=render_oauth_callback_html(- provider, status="success",- message=f"Successfully connected as {email}!", color_hex=color_hex,+ provider,+ status="success",+ message=f"Successfully connected as {email}!",+ color_hex=color_hex,),status_code=200,)@@ -491,8 +504,7 @@ _HTML_TEMPLATE = """<!DOCTYPE html></html>"""_SUCCESS_ICON = (- "<path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' "- "d='M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'/>"+ "<path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' " "d='M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'/>")_ERROR_ICON = ("<path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' "@@ -501,7 +513,11 @@ _ERROR_ICON = (def render_oauth_callback_html(- provider: str, *, status: str, message: str, color_hex: str,+ provider: str,+ *,+ status: str,+ message: str,+ color_hex: str,) -> str:"""Render the small auto-closing callback page.@@ -510,10 +526,7 @@ def render_oauth_callback_html(popup's parent) and auto-closes after 2 seconds."""is_success = status == "success"- title = (- f"{provider.capitalize()} Connected" if is_success- else "Connection Failed"- )+ title = f"{provider.capitalize()} Connected" if is_success else "Connection Failed"return _HTML_TEMPLATE.format(title=title,message=message,diff --git a/server/services/events/triggers.py b/server/services/events/triggers.pyindex 6a5536ce..0a5e703c 100644--- a/server/services/events/triggers.py+++ b/server/services/events/triggers.py@@ -35,10 +35,7 @@ class BaseTriggerParams(BaseModel):event_type_filter: str = Field(default="all",- description=(- "Event type to match. 'all' for every event, exact name, "- "or wildcard prefix (e.g. 'foo.*')."- ),+ description=("Event type to match. 'all' for every event, exact name, " "or wildcard prefix (e.g. 'foo.*')."),)model_config = ConfigDict(extra="ignore")@@ -66,12 +63,7 @@ class WebhookTriggerNode(TriggerNode):def build_filter(self, params: BaseModel) -> Callable[[Any], bool]:type_filter = (getattr(params, "event_type_filter", "") or "all").strip()- if (- type_filter- and type_filter != "all"- and self.event_type_prefix- and not type_filter.startswith(self.event_type_prefix)- ):+ if type_filter and type_filter != "all" and self.event_type_prefix and not type_filter.startswith(self.event_type_prefix):type_filter = self.event_type_prefix + type_filterextras = self._extra_filter(params)@@ -113,6 +105,4 @@ class WebhookTriggerNode(TriggerNode):@Operation("wait")async def wait(self, ctx: NodeContext, params: BaseModel):- raise NotImplementedError(- "Event triggers return via TriggerNode.execute, not the op body"- )+ raise NotImplementedError("Event triggers return via TriggerNode.execute, not the op body")diff --git a/server/services/events/verifiers/hmac_basic.py b/server/services/events/verifiers/hmac_basic.pyindex e66ccbce..19fe1783 100644--- a/server/services/events/verifiers/hmac_basic.py+++ b/server/services/events/verifiers/hmac_basic.py@@ -26,7 +26,7 @@ class HmacVerifier(WebhookVerifier):raise ValueError(f"{cls.header_name} header missing")if cls.signature_prefix and not sig.startswith(cls.signature_prefix):raise ValueError(f"{cls.header_name} missing prefix {cls.signature_prefix!r}")- provided = sig[len(cls.signature_prefix):]+ provided = sig[len(cls.signature_prefix) :]expected = hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()if not hmac.compare_digest(expected, provided):raise ValueError(f"{cls.header_name} mismatch")diff --git a/server/services/events/verifiers/standard_webhooks.py b/server/services/events/verifiers/standard_webhooks.pyindex 6b3b0931..4925bfd6 100644--- a/server/services/events/verifiers/standard_webhooks.py+++ b/server/services/events/verifiers/standard_webhooks.py@@ -29,14 +29,12 @@ class StandardWebhooksVerifier(WebhookVerifier):raise ValueError("Standard Webhooks headers missing")if secret.startswith("whsec_"):- key = base64.b64decode(secret[len("whsec_"):])+ key = base64.b64decode(secret[len("whsec_") :])else:key = secret.encode()signed = f"{msg_id}.{timestamp}.".encode() + body- expected = base64.b64encode(- hmac.new(key, signed, hashlib.sha256).digest()- ).decode()+ expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()candidates: list[str] = []for part in sig_header.split():diff --git a/server/services/events/webhook.py b/server/services/events/webhook.pyindex c06ae516..5c795e03 100644--- a/server/services/events/webhook.py+++ b/server/services/events/webhook.py@@ -37,9 +37,7 @@ def register_webhook_source(source: "WebhookSource") -> None:"""Idempotent: same instance for the same path is a no-op; conflicts raise."""existing = WEBHOOK_SOURCES.get(source.path)if existing is not None and existing is not source:- raise ValueError(- f"Webhook path {source.path!r} already registered to {type(existing).__name__}"- )+ raise ValueError(f"Webhook path {source.path!r} already registered to {type(existing).__name__}")WEBHOOK_SOURCES[source.path] = source@@ -101,5 +99,6 @@ class WebhookSource(PushEventSource):await self.receive(event)from services import event_waiter+event_waiter.dispatch(self.type, event)return eventdiff --git a/server/services/example_loader.py b/server/services/example_loader.pyindex adda70d7..b6136830 100644--- a/server/services/example_loader.py+++ b/server/services/example_loader.py@@ -5,6 +5,7 @@ extraction, credential cross-check, name conflict) lives in``services.workflow_import`` and is shared with the WS ``import_workflow``handler. This module is the first-launch-only convenience wrapper."""+import jsonimport loggingfrom typing import List, Dict, Any@@ -75,20 +76,23 @@ async def import_examples_for_user(database) -> int:# of empty dicts.try:report = await validate_workflow(- nodes=nodes, edges=edges,+ nodes=nodes,+ edges=edges,parameters_by_id=node_parameters,)except Exception as exc:logger.warning("Skipping example %r: validator raised %s",- example.get("name"), exc,+ example.get("name"),+ exc,)continueif report["errors"]:logger.warning("Skipping example %r: %d validation errors %s",- example.get("name"), len(report["errors"]),+ example.get("name"),+ len(report["errors"]),[iss.get("code") for iss in report["errors"]],)continue@@ -96,7 +100,8 @@ async def import_examples_for_user(database) -> int:# Expected on first launch — credentials not yet configured.logger.info("Example %r has %d warnings (likely first-launch credential gaps)",- example.get("name"), len(report["warnings"]),+ example.get("name"),+ len(report["warnings"]),)# Reuse existing save_workflow methoddiff --git a/server/services/execution/cache.py b/server/services/execution/cache.pyindex 7b703477..251bddb9 100644--- a/server/services/execution/cache.py+++ b/server/services/execution/cache.py@@ -30,7 +30,7 @@ def ensure_str(value: Union[str, bytes, None]) -> Optional[str]:if value is None:return Noneif isinstance(value, bytes):- return value.decode('utf-8')+ return value.decode("utf-8")return value@@ -71,15 +71,11 @@ class ExecutionCache:# Use Redis HSET for structured storageif self.cache.is_redis_available():- mapping = {- k: json.dumps(v) if isinstance(v, (dict, list)) else str(v)- for k, v in data.items()- }+ mapping = {k: json.dumps(v) if isinstance(v, (dict, list)) else str(v) for k, v in data.items()}if mapping: # Only call hset if mapping is not emptyawait self.cache.redis.hset(key, mapping=mapping)# Set TTL (24 hours for completed, no TTL for active)- if ctx.status in (WorkflowStatus.COMPLETED, WorkflowStatus.FAILED,- WorkflowStatus.CANCELLED):+ if ctx.status in (WorkflowStatus.COMPLETED, WorkflowStatus.FAILED, WorkflowStatus.CANCELLED):await self.cache.redis.expire(key, 86400)# Track active executions@@ -88,8 +84,7 @@ class ExecutionCache:else:await self.cache.redis.srem("executions:active", ctx.execution_id)- logger.debug("Saved execution state", execution_id=ctx.execution_id,- status=ctx.status.value)+ logger.debug("Saved execution state", execution_id=ctx.execution_id, status=ctx.status.value)return Trueelse:# Fallback to simple key-value@@ -97,13 +92,12 @@ class ExecutionCache:return Trueexcept Exception as e:- logger.error("Failed to save execution state", execution_id=ctx.execution_id,- error=str(e))+ logger.error("Failed to save execution state", execution_id=ctx.execution_id, error=str(e))return False- async def load_execution_state(self, execution_id: str,- nodes: List[Dict] = None,- edges: List[Dict] = None) -> Optional[ExecutionContext]:+ async def load_execution_state(+ self, execution_id: str, nodes: List[Dict] = None, edges: List[Dict] = None+ ) -> Optional[ExecutionContext]:"""Load execution context from Redis.Args:@@ -142,8 +136,7 @@ class ExecutionCache:return Noneexcept Exception as e:- logger.error("Failed to load execution state", execution_id=execution_id,- error=str(e))+ logger.error("Failed to load execution state", execution_id=execution_id, error=str(e))return Noneasync def get_active_executions(self) -> Set[str]:@@ -180,16 +173,14 @@ class ExecutionCache:await self.cache.redis.srem("executions:active", execution_id)return Trueexcept Exception as e:- logger.error("Failed to delete execution state", execution_id=execution_id,- error=str(e))+ logger.error("Failed to delete execution state", execution_id=execution_id, error=str(e))return False# =========================================================================# RESULT CACHING (Prefect pattern)# =========================================================================- async def get_cached_result(self, execution_id: str, node_id: str,- inputs: Dict[str, Any]) -> Optional[Dict[str, Any]]:+ async def get_cached_result(self, execution_id: str, node_id: str, inputs: Dict[str, Any]) -> Optional[Dict[str, Any]]:"""Get cached result for node execution (Prefect pattern).Args:@@ -211,9 +202,9 @@ class ExecutionCache:logger.error("Failed to get cached result", node_id=node_id, error=str(e))return None- async def set_cached_result(self, execution_id: str, node_id: str,- inputs: Dict[str, Any], result: Dict[str, Any],- ttl: int = 3600) -> bool:+ async def set_cached_result(+ self, execution_id: str, node_id: str, inputs: Dict[str, Any], result: Dict[str, Any], ttl: int = 3600+ ) -> bool:"""Cache node execution result (Prefect pattern).Args:@@ -265,18 +256,16 @@ class ExecutionCache:if self.cache.is_redis_available():# Redis SETNX with expiryacquired = await self.cache.redis.set(- lock_key, lock_token,+ lock_key,+ lock_token,ex=timeout,- nx=True # Only set if not exists+ nx=True, # Only set if not exists)else:# Fallback to local asyncio lockif lock_name not in self._local_locks:self._local_locks[lock_name] = asyncio.Lock()- await asyncio.wait_for(- self._local_locks[lock_name].acquire(),- timeout=timeout- )+ await asyncio.wait_for(self._local_locks[lock_name].acquire(), timeout=timeout)acquired = Trueif not acquired:@@ -352,8 +341,7 @@ class ExecutionCache:# EVENT HISTORY (for debugging and recovery)# =========================================================================- async def add_event(self, execution_id: str, event_type: str,- data: Dict[str, Any]) -> Optional[str]:+ async def add_event(self, execution_id: str, event_type: str, data: Dict[str, Any]) -> Optional[str]:"""Add event to execution history stream.Args:@@ -366,11 +354,7 @@ class ExecutionCache:"""try:stream_key = f"execution:{execution_id}:events"- event_data = {- "type": event_type,- "timestamp": time.time(),- **data- }+ event_data = {"type": event_type, "timestamp": time.time(), **data}return await self.cache.stream_add(stream_key, event_data, maxlen=1000)except Exception as e:logger.error("Failed to add event", execution_id=execution_id, error=str(e))@@ -392,10 +376,7 @@ class ExecutionCache:return []# Read from stream- result = await self.cache.stream_read(- {stream_key: "0"},- count=count- )+ result = await self.cache.stream_read({stream_key: "0"}, count=count)events = []if result:@@ -421,8 +402,7 @@ class ExecutionCache:# TRANSACTION CHECKPOINTS (Prefect pattern)# =========================================================================- async def checkpoint_transaction(self, transaction_id: str, node_id: str,- result: Dict[str, Any]) -> bool:+ async def checkpoint_transaction(self, transaction_id: str, node_id: str, result: Dict[str, Any]) -> bool:"""Save transaction checkpoint (Prefect pattern).Args:@@ -435,11 +415,7 @@ class ExecutionCache:"""try:key = f"txn:{transaction_id}:checkpoints"- checkpoint = {- "node_id": node_id,- "result": result,- "timestamp": time.time()- }+ checkpoint = {"node_id": node_id, "result": result, "timestamp": time.time()}if self.cache.is_redis_available():await self.cache.redis.rpush(key, json.dumps(checkpoint))await self.cache.redis.expire(key, 86400) # 24 hour TTL@@ -512,10 +488,7 @@ class ExecutionCache:if self.cache.is_redis_available():# Store entry dataentry_key = f"dlq:entries:{entry.id}"- mapping = {- k: json.dumps(v) if isinstance(v, (dict, list)) else str(v)- for k, v in entry_data.items()- }+ mapping = {k: json.dumps(v) if isinstance(v, (dict, list)) else str(v) for k, v in entry_data.items()}if mapping: # Only call hset if mapping is not emptyawait self.cache.redis.hset(entry_key, mapping=mapping)# Set TTL (7 days for DLQ entries)@@ -534,8 +507,7 @@ class ExecutionCache:# Add to global setawait self.cache.redis.sadd("dlq:all", entry.id)- logger.info("Added to DLQ", entry_id=entry.id, node_id=entry.node_id,- node_type=entry.node_type, error=entry.error[:100])+ logger.info("Added to DLQ", entry_id=entry.id, node_id=entry.node_id, node_type=entry.node_type, error=entry.error[:100])return Trueelse:# Fallback to simple key-value@@ -584,9 +556,7 @@ class ExecutionCache:logger.error("Failed to get DLQ entry", entry_id=entry_id, error=str(e))return None- async def get_dlq_entries(self, workflow_id: Optional[str] = None,- node_type: Optional[str] = None,- limit: int = 100) -> List[DLQEntry]:+ async def get_dlq_entries(self, workflow_id: Optional[str] = None, node_type: Optional[str] = None, limit: int = 100) -> List[DLQEntry]:"""Get DLQ entries with optional filtering.Args:@@ -668,8 +638,7 @@ class ExecutionCache:logger.error("Failed to remove from DLQ", entry_id=entry_id, error=str(e))return False- async def update_dlq_entry(self, entry_id: str, retry_count: int,- error: str) -> bool:+ async def update_dlq_entry(self, entry_id: str, retry_count: int, error: str) -> bool:"""Update DLQ entry after failed retry attempt.Args:@@ -685,11 +654,9 @@ class ExecutionCache:return Falseentry_key = f"dlq:entries:{entry_id}"- await self.cache.redis.hset(entry_key, mapping={- "retry_count": str(retry_count),- "error": error,- "last_error_at": str(time.time())- })+ await self.cache.redis.hset(+ entry_key, mapping={"retry_count": str(retry_count), "error": error, "last_error_at": str(time.time())}+ )logger.debug("Updated DLQ entry", entry_id=entry_id, retry_count=retry_count)return True@@ -720,19 +687,15 @@ class ExecutionCache:by_node_type[entry.node_type] = by_node_type.get(entry.node_type, 0) + 1by_workflow[entry.workflow_id] = by_workflow.get(entry.workflow_id, 0) + 1- return {- "total": total,- "by_node_type": by_node_type,- "by_workflow": by_workflow- }+ return {"total": total, "by_node_type": by_node_type, "by_workflow": by_workflow}except Exception as e:logger.error("Failed to get DLQ stats", error=str(e))return {"total": 0, "by_node_type": {}, "by_workflow": {}}- async def purge_dlq(self, workflow_id: Optional[str] = None,- node_type: Optional[str] = None,- older_than: Optional[float] = None) -> int:+ async def purge_dlq(+ self, workflow_id: Optional[str] = None, node_type: Optional[str] = None, older_than: Optional[float] = None+ ) -> int:"""Purge entries from DLQ.Args:@@ -747,9 +710,7 @@ class ExecutionCache:if not self.cache.is_redis_available():return 0- entries = await self.get_dlq_entries(workflow_id=workflow_id,- node_type=node_type,- limit=10000)+ entries = await self.get_dlq_entries(workflow_id=workflow_id, node_type=node_type, limit=10000)purged = 0for entry in entries:@@ -760,8 +721,7 @@ class ExecutionCache:if await self.remove_from_dlq(entry.id):purged += 1- logger.info("Purged DLQ entries", count=purged, workflow_id=workflow_id,- node_type=node_type)+ logger.info("Purged DLQ entries", count=purged, workflow_id=workflow_id, node_type=node_type)return purgedexcept Exception as e:diff --git a/server/services/execution/conditions.py b/server/services/execution/conditions.pyindex 7b5596dc..3f3b207b 100644--- a/server/services/execution/conditions.py+++ b/server/services/execution/conditions.py@@ -54,7 +54,7 @@ def get_nested_value(data: Dict[str, Any], field_path: str) -> Any:if not data or not field_path:return None- parts = field_path.split('.')+ parts = field_path.split(".")current = datafor part in parts:@@ -102,21 +102,14 @@ def evaluate_condition(condition: ConditionDict, output: Dict[str, Any]) -> bool# Get the actual value from outputactual_value = get_nested_value(output, field)- logger.debug("Evaluating condition",- field=field,- operator=operator,- target=target_value,- actual=actual_value)+ logger.debug("Evaluating condition", field=field, operator=operator, target=target_value, actual=actual_value)try:result = _evaluate_operator(operator, actual_value, target_value)logger.debug("Condition result", result=result)return resultexcept Exception as e:- logger.warning("Condition evaluation error",- field=field,- operator=operator,- error=str(e))+ logger.warning("Condition evaluation error", field=field, operator=operator, error=str(e))return False@@ -269,8 +262,7 @@ def _safe_compare(actual: Any, target: Any, comparator) -> bool:return False-def evaluate_conditions(conditions: List[ConditionDict], output: Dict[str, Any],- logic: str = "and") -> bool:+def evaluate_conditions(conditions: List[ConditionDict], output: Dict[str, Any], logic: str = "and") -> bool:"""Evaluate multiple conditions with AND/OR logic.Args:@@ -292,8 +284,7 @@ def evaluate_conditions(conditions: List[ConditionDict], output: Dict[str, Any],return all(results)-def decide_next_edges(edges: List[Dict[str, Any]], source_node_id: str,- output: Dict[str, Any]) -> List[str]:+def decide_next_edges(edges: List[Dict[str, Any]], source_node_id: str, output: Dict[str, Any]) -> List[str]:"""Determine which edges to follow based on conditions.Args:@@ -325,15 +316,11 @@ def decide_next_edges(edges: List[Dict[str, Any]], source_node_id: str,condition = edge.get("data", {}).get("condition")if evaluate_condition(condition, output):next_nodes.append(edge["target"])- logger.info("Conditional edge matched",- source=source_node_id,- target=edge["target"],- condition=condition)+ logger.info("Conditional edge matched", source=source_node_id, target=edge["target"], condition=condition)# If no conditional edges matched, fall through to unconditionalif not next_nodes and unconditional_edges:- logger.info("No conditional edges matched, using unconditional",- source=source_node_id)+ logger.info("No conditional edges matched, using unconditional", source=source_node_id)for edge in unconditional_edges:next_nodes.append(edge["target"])else:diff --git a/server/services/execution/dlq.py b/server/services/execution/dlq.pyindex c7faf46e..77c6ca21 100644--- a/server/services/execution/dlq.py+++ b/server/services/execution/dlq.py@@ -27,8 +27,7 @@ logger = get_logger(__name__)class DLQHandlerProtocol(Protocol):"""Protocol for DLQ handlers (enables duck typing)."""- async def add_failed_node(self, ctx: ExecutionContext, node: NodeExecution,- inputs: Dict[str, Any], error: str) -> bool:+ async def add_failed_node(self, ctx: ExecutionContext, node: NodeExecution, inputs: Dict[str, Any], error: str) -> bool:"""Add a failed node to the DLQ."""...@@ -48,11 +47,9 @@ class NullDLQHandler:def enabled(self) -> bool:return False- async def add_failed_node(self, ctx: ExecutionContext, node: NodeExecution,- inputs: Dict[str, Any], error: str) -> bool:+ async def add_failed_node(self, ctx: ExecutionContext, node: NodeExecution, inputs: Dict[str, Any], error: str) -> bool:"""No-op: silently succeed without storing anything."""- logger.debug("DLQ disabled, skipping failed node storage",- node_id=node.node_id, error=error)+ logger.debug("DLQ disabled, skipping failed node storage", node_id=node.node_id, error=error)return True@@ -75,8 +72,7 @@ class DLQHandler:def enabled(self) -> bool:return True- async def add_failed_node(self, ctx: ExecutionContext, node: NodeExecution,- inputs: Dict[str, Any], error: str) -> bool:+ async def add_failed_node(self, ctx: ExecutionContext, node: NodeExecution, inputs: Dict[str, Any], error: str) -> bool:"""Add a failed node to the Dead Letter Queue.Args:@@ -93,27 +89,27 @@ class DLQHandler:success = await self.cache.add_to_dlq(dlq_entry)if success:- logger.info("Node added to DLQ",- entry_id=dlq_entry.id,- node_id=node.node_id,- node_type=node.node_type,- retry_count=node.retry_count)-- await self.cache.add_event(ctx.execution_id, "node_dlq", {- "node_id": node.node_id,- "dlq_entry_id": dlq_entry.id,- "error": error,- "retry_count": node.retry_count,- })+ logger.info(+ "Node added to DLQ", entry_id=dlq_entry.id, node_id=node.node_id, node_type=node.node_type, retry_count=node.retry_count+ )++ await self.cache.add_event(+ ctx.execution_id,+ "node_dlq",+ {+ "node_id": node.node_id,+ "dlq_entry_id": dlq_entry.id,+ "error": error,+ "retry_count": node.retry_count,+ },+ )return Trueelse:- logger.error("Failed to add node to DLQ",- node_id=node.node_id, error=error)+ logger.error("Failed to add node to DLQ", node_id=node.node_id, error=error)return Falseexcept Exception as e:- logger.error("Exception adding node to DLQ",- node_id=node.node_id, error=str(e))+ logger.error("Exception adding node to DLQ", node_id=node.node_id, error=str(e))return Falsediff --git a/server/services/execution/executor.py b/server/services/execution/executor.pyindex 9a2bec12..bcd3e4a5 100644--- a/server/services/execution/executor.py+++ b/server/services/execution/executor.py@@ -57,10 +57,13 @@ class WorkflowExecutor:- Event history for debugging and recovery"""- def __init__(self, cache: ExecutionCache,- node_executor: Callable[[str, str, Dict, Dict], Awaitable[Dict]],- status_callback: Callable[[str, str, Dict], Awaitable[None]] = None,- dlq_enabled: bool = False):+ def __init__(+ self,+ cache: ExecutionCache,+ node_executor: Callable[[str, str, Dict, Dict], Awaitable[Dict]],+ status_callback: Callable[[str, str, Dict], Awaitable[None]] = None,+ dlq_enabled: bool = False,+ ):"""Initialize executor.Args:@@ -85,9 +88,9 @@ class WorkflowExecutor:# EXECUTION ENTRY POINTS# =========================================================================- async def execute_workflow(self, workflow_id: str, nodes: List[Dict],- edges: List[Dict], session_id: str = "default",- enable_caching: bool = True) -> Dict[str, Any]:+ async def execute_workflow(+ self, workflow_id: str, nodes: List[Dict], edges: List[Dict], session_id: str = "default", enable_caching: bool = True+ ) -> Dict[str, Any]:"""Execute a workflow with parallel node execution.Args:@@ -113,11 +116,13 @@ class WorkflowExecutor:# Compute execution layers (for parallel batches)ctx.execution_order = self._compute_execution_layers(nodes, edges)- logger.info("Starting workflow execution",- execution_id=ctx.execution_id,- workflow_id=workflow_id,- node_count=len(nodes),- layers=len(ctx.execution_order))+ logger.info(+ "Starting workflow execution",+ execution_id=ctx.execution_id,+ workflow_id=workflow_id,+ node_count=len(nodes),+ layers=len(ctx.execution_order),+ )# Track in memoryself._active_contexts[ctx.execution_id] = ctx@@ -128,10 +133,14 @@ class WorkflowExecutor:await self.cache.save_execution_state(ctx)# Add workflow_started event- await self.cache.add_event(ctx.execution_id, "workflow_started", {- "workflow_id": workflow_id,- "node_count": len(nodes),- })+ await self.cache.add_event(+ ctx.execution_id,+ "workflow_started",+ {+ "workflow_id": workflow_id,+ "node_count": len(nodes),+ },+ )try:# Run the decide loop@@ -147,11 +156,15 @@ class WorkflowExecutor:await self.cache.save_execution_state(ctx)# Add workflow_completed event- await self.cache.add_event(ctx.execution_id, "workflow_completed", {- "status": ctx.status.value,- "completed_nodes": len(ctx.get_completed_nodes()),- "execution_time": ctx.completed_at - ctx.started_at,- })+ await self.cache.add_event(+ ctx.execution_id,+ "workflow_completed",+ {+ "status": ctx.status.value,+ "completed_nodes": len(ctx.get_completed_nodes()),+ "execution_time": ctx.completed_at - ctx.started_at,+ },+ )return {"success": ctx.status == WorkflowStatus.COMPLETED,@@ -178,14 +191,17 @@ class WorkflowExecutor:}except Exception as e:- logger.error("Workflow execution failed", execution_id=ctx.execution_id,- error=str(e))+ logger.error("Workflow execution failed", execution_id=ctx.execution_id, error=str(e))ctx.status = WorkflowStatus.FAILEDctx.errors.append({"error": str(e), "timestamp": time.time()})await self.cache.save_execution_state(ctx)- await self.cache.add_event(ctx.execution_id, "workflow_failed", {- "error": str(e),- })+ await self.cache.add_event(+ ctx.execution_id,+ "workflow_failed",+ {+ "error": str(e),+ },+ )return {"success": False,"execution_id": ctx.execution_id,@@ -211,8 +227,7 @@ class WorkflowExecutor:if ctx:ctx.status = WorkflowStatus.CANCELLEDfor node_exec in ctx.node_executions.values():- if node_exec.status in (TaskStatus.PENDING, TaskStatus.SCHEDULED,- TaskStatus.RUNNING, TaskStatus.WAITING):+ if node_exec.status in (TaskStatus.PENDING, TaskStatus.SCHEDULED, TaskStatus.RUNNING, TaskStatus.WAITING):node_exec.status = TaskStatus.CANCELLEDawait self.cache.save_execution_state(ctx)logger.info("Execution cancelled", execution_id=execution_id)@@ -223,8 +238,7 @@ class WorkflowExecutor:# CONDUCTOR DECIDE PATTERN# =========================================================================- async def _workflow_decide(self, ctx: ExecutionContext,- enable_caching: bool = True) -> None:+ async def _workflow_decide(self, ctx: ExecutionContext, enable_caching: bool = True) -> None:"""Core orchestration loop - Conductor's decide pattern.Evaluates current state, finds ready nodes, executes them in parallel,@@ -236,19 +250,15 @@ class WorkflowExecutor:"""# Distributed lock prevents concurrent decides for same executiontry:- async with self.cache.distributed_lock(- f"execution:{ctx.execution_id}:decide", timeout=60- ):+ async with self.cache.distributed_lock(f"execution:{ctx.execution_id}:decide", timeout=60):await self._decide_iteration(ctx, enable_caching)except TimeoutError:- logger.warning("Could not acquire decide lock",- execution_id=ctx.execution_id)+ logger.warning("Could not acquire decide lock", execution_id=ctx.execution_id)# Retry after short delayawait asyncio.sleep(0.5)await self._workflow_decide(ctx, enable_caching)- async def _decide_iteration(self, ctx: ExecutionContext,- enable_caching: bool) -> None:+ async def _decide_iteration(self, ctx: ExecutionContext, enable_caching: bool) -> None:"""Continuous scheduling loop - Temporal/Conductor pattern.When any node completes, immediately check for newly-ready dependents@@ -270,15 +280,15 @@ class WorkflowExecutor:else:pending = ctx.get_pending_nodes()if pending:- logger.warning("Stuck: pending nodes with unsatisfied deps",- execution_id=ctx.execution_id,- pending=pending)+ logger.warning("Stuck: pending nodes with unsatisfied deps", execution_id=ctx.execution_id, pending=pending)return- logger.info("Starting continuous execution",- execution_id=ctx.execution_id,- initial_batch=len(ready_nodes),- nodes=[n.node_id for n in ready_nodes])+ logger.info(+ "Starting continuous execution",+ execution_id=ctx.execution_id,+ initial_batch=len(ready_nodes),+ nodes=[n.node_id for n in ready_nodes],+ )# Execute with continuous scheduling - new patternawait self._execute_with_continuous_scheduling(ctx, ready_nodes, enable_caching)@@ -291,10 +301,7 @@ class WorkflowExecutor:# =========================================================================async def _execute_with_continuous_scheduling(- self,- ctx: ExecutionContext,- initial_nodes: List[NodeExecution],- enable_caching: bool+ self, ctx: ExecutionContext, initial_nodes: List[NodeExecution], enable_caching: bool) -> None:"""Execute workflow with continuous scheduling.@@ -317,10 +324,7 @@ class WorkflowExecutor:def create_node_task(node: NodeExecution) -> asyncio.Task:"""Create and track a task for node execution."""node.status = TaskStatus.SCHEDULED- task = asyncio.create_task(- self._execute_node_with_retry(ctx, node, enable_caching),- name=f"node_{node.node_id}"- )+ task = asyncio.create_task(self._execute_node_with_retry(ctx, node, enable_caching), name=f"node_{node.node_id}")task_to_node[task] = nodepending_tasks.add(task)return task@@ -340,10 +344,7 @@ class WorkflowExecutor:break# Wait for ANY task to complete- done, pending_tasks = await asyncio.wait(- pending_tasks,- return_when=asyncio.FIRST_COMPLETED- )+ done, pending_tasks = await asyncio.wait(pending_tasks, return_when=asyncio.FIRST_COMPLETED)# Process each completed taskfor task in done:@@ -357,11 +358,13 @@ class WorkflowExecutor:node.status = TaskStatus.FAILEDnode.error = str(result)node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": str(result),- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": str(result),+ "timestamp": time.time(),+ }+ )await self._notify_status(node.node_id, "error", {"error": str(result)})logger.error("Node failed", node_id=node.node_id, error=str(result))workflow_failed = True@@ -370,23 +373,27 @@ class WorkflowExecutor:node.status = TaskStatus.FAILEDnode.error = result.get("error", "Unknown error")node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": node.error,- "retries_exhausted": True,- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": node.error,+ "retries_exhausted": True,+ "timestamp": time.time(),+ }+ )workflow_failed = Trueelif not result.get("success"):node.status = TaskStatus.FAILEDnode.error = result.get("error", "Unknown error")node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": node.error,- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": node.error,+ "timestamp": time.time(),+ }+ )await self._notify_status(node.node_id, "error", {"error": node.error})logger.error("Node failed", node_id=node.node_id, error=node.error)workflow_failed = True@@ -408,11 +415,13 @@ class WorkflowExecutor:node.status = TaskStatus.FAILEDnode.error = str(e)node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": str(e),- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": str(e),+ "timestamp": time.time(),+ }+ )await self._notify_status(node.node_id, "error", {"error": str(e)})logger.error("Node exception", node_id=node.node_id, error=str(e))workflow_failed = True@@ -422,27 +431,21 @@ class WorkflowExecutor:for ready_node in newly_ready:create_node_task(ready_node)await self._notify_status(ready_node.node_id, "scheduled", {})- logger.info("Scheduled dependent node",- node_id=ready_node.node_id,- triggered_by=node.node_id)+ logger.info("Scheduled dependent node", node_id=ready_node.node_id, triggered_by=node.node_id)# Periodic state saveawait self.cache.save_execution_state(ctx)# Handle workflow failure - cancel remaining tasksif workflow_failed and pending_tasks:- logger.info("Workflow failed, cancelling remaining tasks",- pending_count=len(pending_tasks))+ logger.info("Workflow failed, cancelling remaining tasks", pending_count=len(pending_tasks))for task in pending_tasks:task.cancel()# Wait for cancelled tasksif pending_tasks:- cancelled_done, _ = await asyncio.wait(- pending_tasks,- return_when=asyncio.ALL_COMPLETED- )+ cancelled_done, _ = await asyncio.wait(pending_tasks, return_when=asyncio.ALL_COMPLETED)for task in cancelled_done:node = task_to_node.get(task)@@ -456,9 +459,7 @@ class WorkflowExecutor:# PARALLEL EXECUTION (Legacy - Fork/Join with FIRST_COMPLETED pattern)# =========================================================================- async def _execute_parallel_nodes(self, ctx: ExecutionContext,- nodes: List[NodeExecution],- enable_caching: bool) -> None:+ async def _execute_parallel_nodes(self, ctx: ExecutionContext, nodes: List[NodeExecution], enable_caching: bool) -> None:"""Execute multiple nodes in parallel using asyncio.wait with FIRST_COMPLETED.Uses the standard asyncio pattern for mixed task types:@@ -485,10 +486,7 @@ class WorkflowExecutor:task_to_node: Dict[asyncio.Task, NodeExecution] = {}for node in nodes:- task = asyncio.create_task(- self._execute_node_with_retry(ctx, node, enable_caching),- name=f"node_{node.node_id}"- )+ task = asyncio.create_task(self._execute_node_with_retry(ctx, node, enable_caching), name=f"node_{node.node_id}")node_to_task[node.node_id] = tasktask_to_node[task] = node@@ -498,10 +496,7 @@ class WorkflowExecutor:# Process tasks as they complete using FIRST_COMPLETED patternwhile pending:# Wait for any task to complete- done, pending = await asyncio.wait(- pending,- return_when=asyncio.FIRST_COMPLETED- )+ done, pending = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED)# Process completed tasksfor task in done:@@ -515,14 +510,15 @@ class WorkflowExecutor:node.status = TaskStatus.FAILEDnode.error = str(result)node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": str(result),- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": str(result),+ "timestamp": time.time(),+ }+ )await self._notify_status(node.node_id, "error", {"error": str(result)})- logger.error("Parallel node failed",- node_id=node.node_id, error=str(result))+ logger.error("Parallel node failed", node_id=node.node_id, error=str(result))workflow_failed = Trueelif result.get("retries_exhausted"):@@ -530,12 +526,14 @@ class WorkflowExecutor:node.status = TaskStatus.FAILEDnode.error = result.get("error", "Unknown error")node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": node.error,- "retries_exhausted": True,- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": node.error,+ "retries_exhausted": True,+ "timestamp": time.time(),+ }+ )workflow_failed = Trueelif not result.get("success"):@@ -543,14 +541,15 @@ class WorkflowExecutor:node.status = TaskStatus.FAILEDnode.error = result.get("error", "Unknown error")node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": node.error,- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": node.error,+ "timestamp": time.time(),+ }+ )await self._notify_status(node.node_id, "error", {"error": node.error})- logger.error("Parallel node failed",- node_id=node.node_id, error=node.error)+ logger.error("Parallel node failed", node_id=node.node_id, error=node.error)workflow_failed = Trueexcept asyncio.CancelledError:@@ -564,31 +563,28 @@ class WorkflowExecutor:node.status = TaskStatus.FAILEDnode.error = str(e)node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": str(e),- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": str(e),+ "timestamp": time.time(),+ }+ )await self._notify_status(node.node_id, "error", {"error": str(e)})- logger.error("Parallel node exception",- node_id=node.node_id, error=str(e))+ logger.error("Parallel node exception", node_id=node.node_id, error=str(e))workflow_failed = True# If workflow failed, cancel remaining pending tasks# This prevents trigger nodes from blocking forever when a regular node failsif workflow_failed and pending:- logger.info("Workflow failed, cancelling remaining tasks",- pending_count=len(pending))+ logger.info("Workflow failed, cancelling remaining tasks", pending_count=len(pending))for task in pending:task.cancel()# Wait for cancelled tasks to finishif pending:- cancelled_done, _ = await asyncio.wait(- pending,- return_when=asyncio.ALL_COMPLETED- )+ cancelled_done, _ = await asyncio.wait(pending, return_when=asyncio.ALL_COMPLETED)# Mark cancelled nodesfor task in cancelled_done:@@ -604,9 +600,7 @@ class WorkflowExecutor:if workflow_failed:ctx.status = WorkflowStatus.FAILED- async def _execute_single_node(self, ctx: ExecutionContext,- node: NodeExecution,- enable_caching: bool) -> None:+ async def _execute_single_node(self, ctx: ExecutionContext, node: NodeExecution, enable_caching: bool) -> None:"""Execute a single node with retry logic.Args:@@ -625,23 +619,27 @@ class WorkflowExecutor:node.status = TaskStatus.FAILEDnode.error = result.get("error", "Unknown error")node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": node.error,- "retries_exhausted": True,- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": node.error,+ "retries_exhausted": True,+ "timestamp": time.time(),+ }+ )ctx.status = WorkflowStatus.FAILEDexcept Exception as e:node.status = TaskStatus.FAILEDnode.error = str(e)node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": str(e),- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": str(e),+ "timestamp": time.time(),+ }+ )await self._notify_status(node.node_id, "error", {"error": str(e)})ctx.status = WorkflowStatus.FAILED@@ -649,9 +647,7 @@ class WorkflowExecutor:# RETRY LOGIC# =========================================================================- async def _execute_node_with_retry(self, ctx: ExecutionContext,- node: NodeExecution,- enable_caching: bool) -> Dict[str, Any]:+ async def _execute_node_with_retry(self, ctx: ExecutionContext, node: NodeExecution, enable_caching: bool) -> Dict[str, Any]:"""Execute node with retry logic and DLQ on final failure.Uses exponential backoff retry policy based on node type.@@ -689,19 +685,25 @@ class WorkflowExecutor:# Check if we should retryif retry_policy.should_retry(error, attempt + 1):delay = retry_policy.calculate_delay(attempt)- logger.info("Retrying node after failure",- node_id=node.node_id,- attempt=attempt + 1,- max_attempts=retry_policy.max_attempts,- delay=delay,- error=error[:100])-- await self._notify_status(node.node_id, "retrying", {- "attempt": attempt + 1,- "max_attempts": retry_policy.max_attempts,- "delay": delay,- "error": error,- })+ logger.info(+ "Retrying node after failure",+ node_id=node.node_id,+ attempt=attempt + 1,+ max_attempts=retry_policy.max_attempts,+ delay=delay,+ error=error[:100],+ )++ await self._notify_status(+ node.node_id,+ "retrying",+ {+ "attempt": attempt + 1,+ "max_attempts": retry_policy.max_attempts,+ "delay": delay,+ "error": error,+ },+ )await asyncio.sleep(delay)@@ -717,18 +719,12 @@ class WorkflowExecutor:raise # Propagate cancellationexcept Exception as e:last_error = str(e)- logger.warning("Node execution exception",- node_id=node.node_id,- attempt=attempt + 1,- error=last_error)+ logger.warning("Node execution exception", node_id=node.node_id, attempt=attempt + 1, error=last_error)# Check if we should retryif retry_policy.should_retry(last_error, attempt + 1):delay = retry_policy.calculate_delay(attempt)- logger.info("Retrying node after exception",- node_id=node.node_id,- attempt=attempt + 1,- delay=delay)+ logger.info("Retrying node after exception", node_id=node.node_id, attempt=attempt + 1, delay=delay)await asyncio.sleep(delay)node.status = TaskStatus.PENDING@@ -752,9 +748,7 @@ class WorkflowExecutor:# CACHED NODE EXECUTION (Prefect pattern)# =========================================================================- async def _execute_node_with_caching(self, ctx: ExecutionContext,- node: NodeExecution,- enable_caching: bool) -> Dict[str, Any]:+ async def _execute_node_with_caching(self, ctx: ExecutionContext, node: NodeExecution, enable_caching: bool) -> Dict[str, Any]:"""Execute node with result caching (Prefect pattern).Args:@@ -771,9 +765,7 @@ class WorkflowExecutor:# Check cache first (Prefect pattern)if enable_caching:- cached_result = await self.cache.get_cached_result(- ctx.execution_id, node.node_id, inputs- )+ cached_result = await self.cache.get_cached_result(ctx.execution_id, node.node_id, inputs)if cached_result:logger.info("Cache hit", node_id=node.node_id)node.status = TaskStatus.CACHED@@ -781,11 +773,14 @@ class WorkflowExecutor:node.input_hash = hash_inputs(inputs)node.completed_at = time.time()ctx.outputs[node.node_id] = cached_result- await self._notify_status(node.node_id, "success",- {"cached": True, **cached_result})- await self.cache.add_event(ctx.execution_id, "node_cached", {- "node_id": node.node_id,- })+ await self._notify_status(node.node_id, "success", {"cached": True, **cached_result})+ await self.cache.add_event(+ ctx.execution_id,+ "node_cached",+ {+ "node_id": node.node_id,+ },+ )return cached_result# Execute node@@ -793,10 +788,14 @@ class WorkflowExecutor:node.started_at = time.time()node.input_hash = hash_inputs(inputs)await self._notify_status(node.node_id, "executing", {})- await self.cache.add_event(ctx.execution_id, "node_started", {- "node_id": node.node_id,- "node_type": node.node_type,- })+ await self.cache.add_event(+ ctx.execution_id,+ "node_started",+ {+ "node_id": node.node_id,+ "node_type": node.node_type,+ },+ )# Update heartbeat (for crash detection)await self.cache.update_heartbeat(ctx.execution_id, node.node_id)@@ -816,12 +815,7 @@ class WorkflowExecutor:logger.info(f"[Executor] exec_context['outputs'] keys: {list(exec_context['outputs'].keys())}")# Call the actual node executor- result = await self.node_executor(- node.node_id,- node.node_type,- node_data.get("parameters", {}),- exec_context- )+ result = await self.node_executor(node.node_id, node.node_type, node_data.get("parameters", {}), exec_context)# Process resultif result.get("success"):@@ -832,30 +826,38 @@ class WorkflowExecutor:# Cache result (Prefect pattern)if enable_caching:- await self.cache.set_cached_result(- ctx.execution_id, node.node_id, inputs, node.output- )+ await self.cache.set_cached_result(ctx.execution_id, node.node_id, inputs, node.output)await self._notify_status(node.node_id, "success", node.output)- await self.cache.add_event(ctx.execution_id, "node_completed", {- "node_id": node.node_id,- "execution_time": node.completed_at - node.started_at,- })+ await self.cache.add_event(+ ctx.execution_id,+ "node_completed",+ {+ "node_id": node.node_id,+ "execution_time": node.completed_at - node.started_at,+ },+ )else:node.status = TaskStatus.FAILEDnode.error = result.get("error", "Unknown error")node.completed_at = time.time()- ctx.errors.append({- "node_id": node.node_id,- "error": node.error,- "timestamp": time.time(),- })+ ctx.errors.append(+ {+ "node_id": node.node_id,+ "error": node.error,+ "timestamp": time.time(),+ }+ )await self._notify_status(node.node_id, "error", {"error": node.error})- await self.cache.add_event(ctx.execution_id, "node_failed", {- "node_id": node.node_id,- "error": node.error,- })+ await self.cache.add_event(+ ctx.execution_id,+ "node_failed",+ {+ "node_id": node.node_id,+ "error": node.error,+ },+ )# Mark workflow as failedctx.status = WorkflowStatus.FAILED@@ -866,8 +868,7 @@ class WorkflowExecutor:# DAG ANALYSIS# =========================================================================- def _compute_execution_layers(self, nodes: List[Dict],- edges: List[Dict]) -> List[List[str]]:+ def _compute_execution_layers(self, nodes: List[Dict], edges: List[Dict]) -> List[List[str]]:"""Compute execution layers for parallel execution.Nodes in the same layer have no dependencies on each other@@ -891,9 +892,7 @@ class WorkflowExecutor:from constants import CONFIG_NODE_TYPES, TOOLKIT_NODE_TYPES, AI_AGENT_TYPES# Build node type lookup for trigger detection- node_types: Dict[str, str] = {- node["id"]: node.get("type", "unknown") for node in nodes- }+ node_types: Dict[str, str] = {node["id"]: node.get("type", "unknown") for node in nodes}# Find toolkit sub-nodes (nodes that connect TO a toolkit)toolkit_node_ids = {n.get("id") for n in nodes if n.get("type") in TOOLKIT_NODE_TYPES}@@ -914,7 +913,7 @@ class WorkflowExecutor:# Nodes connected to AI Agent config handles are sub-nodes# These handles: input-memory, input-tools, input-skill, input-teammatesif target in ai_agent_node_ids and source and target_handle:- if target_handle in ('input-memory', 'input-tools', 'input-skill', 'input-teammates'):+ if target_handle in ("input-memory", "input-tools", "input-skill", "input-teammates"):subnode_ids.add(source)# Filter out config nodes and sub-nodes from execution@@ -949,15 +948,11 @@ class WorkflowExecutor:while remaining:# Find all nodes with in-degree 0 (no dependencies)- layer = [- node_id for node_id in remaining- if in_degree[node_id] == 0- ]+ layer = [node_id for node_id in remaining if in_degree[node_id] == 0]if not layer:# Cycle detected or stuck- logger.warning("Cycle detected or no start nodes",- remaining=list(remaining))+ logger.warning("Cycle detected or no start nodes", remaining=list(remaining))# Add remaining as single layer to avoid infinite looplayers.append(list(remaining))break@@ -977,7 +972,7 @@ class WorkflowExecutor:"Non-trigger node found at graph entry point",node_id=node_id,node_type=node_type,- expected_types=list(WORKFLOW_TRIGGER_TYPES)+ expected_types=list(WORKFLOW_TRIGGER_TYPES),)# Log trigger node identification@@ -985,10 +980,7 @@ class WorkflowExecutor:logger.info("Identified trigger nodes as workflow starting points",trigger_count=len(trigger_nodes),- trigger_nodes=[- f"{nid[:8]}({node_types.get(nid)})"- for nid in trigger_nodes- ]+ trigger_nodes=[f"{nid[:8]}({node_types.get(nid)})" for nid in trigger_nodes],)is_first_layer = False@@ -1001,9 +993,7 @@ class WorkflowExecutor:for successor in adjacency[node_id]:in_degree[successor] -= 1- logger.debug("Computed execution layers",- layer_count=len(layers),- layers=[[n[:8] for n in layer] for layer in layers])+ logger.debug("Computed execution layers", layer_count=len(layers), layers=[[n[:8] for n in layer] for layer in layers])return layers@@ -1077,22 +1067,18 @@ class WorkflowExecutor:# Check conditional edges for this nodeif node_id in conditional_edges:# Has conditional incoming edges - evaluate them- conditions_met = self._evaluate_incoming_conditions(- ctx, node_id, conditional_edges[node_id]- )+ conditions_met = self._evaluate_incoming_conditions(ctx, node_id, conditional_edges[node_id])if not conditions_met:# Mark as SKIPPED if conditions not met and all deps donenode_exec.status = TaskStatus.SKIPPED- logger.info("Node skipped due to unmet conditions",- node_id=node_id)+ logger.info("Node skipped due to unmet conditions", node_id=node_id)continueready.append(node_exec)return ready- def _evaluate_incoming_conditions(self, ctx: ExecutionContext, target_node_id: str,- edges: List[Dict]) -> bool:+ def _evaluate_incoming_conditions(self, ctx: ExecutionContext, target_node_id: str, edges: List[Dict]) -> bool:"""Evaluate conditions on incoming edges to determine if node should run.Args:@@ -1115,16 +1101,11 @@ class WorkflowExecutor:# Evaluate conditionif evaluate_condition(condition, source_output):- logger.debug("Conditional edge matched",- source=source_id,- target=target_node_id,- condition=condition)+ logger.debug("Conditional edge matched", source=source_id, target=target_node_id, condition=condition)return True# No conditions matched- logger.debug("No conditional edges matched",- target=target_node_id,- edge_count=len(edges))+ logger.debug("No conditional edges matched", target=target_node_id, edge_count=len(edges))return Falsedef _get_node_data(self, ctx: ExecutionContext, node_id: str) -> Dict[str, Any]:@@ -1167,8 +1148,7 @@ class WorkflowExecutor:# STATUS NOTIFICATIONS# =========================================================================- async def _notify_status(self, node_id: str, status: str,- data: Dict[str, Any]) -> None:+ async def _notify_status(self, node_id: str, status: str, data: Dict[str, Any]) -> None:"""Send status notification via callback.Args:@@ -1186,9 +1166,7 @@ class WorkflowExecutor:# RECOVERY# =========================================================================- async def recover_execution(self, execution_id: str,- nodes: List[Dict],- edges: List[Dict]) -> Optional[Dict[str, Any]]:+ async def recover_execution(self, execution_id: str, nodes: List[Dict], edges: List[Dict]) -> Optional[Dict[str, Any]]:"""Recover and resume an interrupted execution.Args:@@ -1205,8 +1183,7 @@ class WorkflowExecutor:return Noneif ctx.status != WorkflowStatus.RUNNING:- logger.info("Execution already complete", execution_id=execution_id,- status=ctx.status.value)+ logger.info("Execution already complete", execution_id=execution_id, status=ctx.status.value)return {"success": ctx.status == WorkflowStatus.COMPLETED,"execution_id": execution_id,@@ -1214,9 +1191,7 @@ class WorkflowExecutor:"recovered": False,}- logger.info("Recovering execution",- execution_id=execution_id,- checkpoints=ctx.checkpoints)+ logger.info("Recovering execution", execution_id=execution_id, checkpoints=ctx.checkpoints)# Reset any RUNNING nodes to PENDING (they were interrupted)for node_exec in ctx.node_executions.values():@@ -1262,9 +1237,7 @@ class WorkflowExecutor:# DLQ REPLAY# =========================================================================- async def replay_dlq_entry(self, entry_id: str,- nodes: List[Dict],- edges: List[Dict]) -> Dict[str, Any]:+ async def replay_dlq_entry(self, entry_id: str, nodes: List[Dict], edges: List[Dict]) -> Dict[str, Any]:"""Replay a failed node from the Dead Letter Queue.Creates a new execution context and attempts to re-execute the failed node.@@ -1285,11 +1258,13 @@ class WorkflowExecutor:"error": f"DLQ entry not found: {entry_id}",}- logger.info("Replaying DLQ entry",- entry_id=entry_id,- node_id=entry.node_id,- node_type=entry.node_type,- original_execution=entry.execution_id)+ logger.info(+ "Replaying DLQ entry",+ entry_id=entry_id,+ node_id=entry.node_id,+ node_type=entry.node_type,+ original_execution=entry.execution_id,+ )# Create new execution context for replayctx = ExecutionContext.create(@@ -1321,9 +1296,7 @@ class WorkflowExecutor:if node_exec.status == TaskStatus.COMPLETED:# Success - remove from DLQawait self.cache.remove_from_dlq(entry_id)- logger.info("DLQ replay succeeded",- entry_id=entry_id,- node_id=entry.node_id)+ logger.info("DLQ replay succeeded", entry_id=entry_id, node_id=entry.node_id)return {"success": True,@@ -1334,11 +1307,7 @@ class WorkflowExecutor:}else:# Still failing - update DLQ entry- await self.cache.update_dlq_entry(- entry_id,- entry.retry_count + 1,- node_exec.error or "Unknown error"- )+ await self.cache.update_dlq_entry(entry_id, entry.retry_count + 1, node_exec.error or "Unknown error")return {"success": False,diff --git a/server/services/execution/models.py b/server/services/execution/models.pyindex 36f5812d..421d9297 100644--- a/server/services/execution/models.py+++ b/server/services/execution/models.py@@ -26,25 +26,27 @@ class TaskStatus(str, Enum):-> CANCELLEDCACHED (Prefect pattern - result from cache, no execution)"""- PENDING = "pending" # Created, not yet scheduled- SCHEDULED = "scheduled" # In task queue, waiting for worker- RUNNING = "running" # Worker executing- COMPLETED = "completed" # Success, result cached- FAILED = "failed" # Error, may retry- CACHED = "cached" # Result from cache (Prefect pattern)- CANCELLED = "cancelled" # User cancelled- WAITING = "waiting" # Waiting for external event (triggers)- SKIPPED = "skipped" # Skipped due to condition++ PENDING = "pending" # Created, not yet scheduled+ SCHEDULED = "scheduled" # In task queue, waiting for worker+ RUNNING = "running" # Worker executing+ COMPLETED = "completed" # Success, result cached+ FAILED = "failed" # Error, may retry+ CACHED = "cached" # Result from cache (Prefect pattern)+ CANCELLED = "cancelled" # User cancelled+ WAITING = "waiting" # Waiting for external event (triggers)+ SKIPPED = "skipped" # Skipped due to conditionclass WorkflowStatus(str, Enum):"""Workflow execution states."""- PENDING = "pending" # Created, not started- RUNNING = "running" # At least one node executing- PAUSED = "paused" # User paused- COMPLETED = "completed" # All nodes completed successfully- FAILED = "failed" # Execution failed- CANCELLED = "cancelled" # User cancelled++ PENDING = "pending" # Created, not started+ RUNNING = "running" # At least one node executing+ PAUSED = "paused" # User paused+ COMPLETED = "completed" # All nodes completed successfully+ FAILED = "failed" # Execution failed+ CANCELLED = "cancelled" # User cancelled@dataclass@@ -54,9 +56,10 @@ class RetryPolicy:Implements exponential backoff with configurable limits.Delay formula: min(initial_delay * (backoff_multiplier ^ attempt), max_delay)"""+max_attempts: int = 3- initial_delay: float = 1.0 # seconds- max_delay: float = 60.0 # seconds+ initial_delay: float = 1.0 # seconds+ max_delay: float = 60.0 # secondsbackoff_multiplier: float = 2.0retry_on_timeout: bool = Trueretry_on_connection_error: bool = True@@ -71,7 +74,7 @@ class RetryPolicy:Returns:Delay in seconds before next attempt"""- delay = self.initial_delay * (self.backoff_multiplier ** attempt)+ delay = self.initial_delay * (self.backoff_multiplier**attempt)return min(delay, self.max_delay)def should_retry(self, error: str, attempt: int) -> bool:@@ -157,6 +160,7 @@ class DLQEntry:Stores failed execution details for manual review and replay."""+id: strexecution_id: strworkflow_id: str@@ -200,8 +204,7 @@ class DLQEntry:)@classmethod- def create(cls, ctx: "ExecutionContext", node_exec: "NodeExecution",- inputs: Dict[str, Any]) -> "DLQEntry":+ def create(cls, ctx: "ExecutionContext", node_exec: "NodeExecution", inputs: Dict[str, Any]) -> "DLQEntry":"""Factory method to create DLQ entry from failed execution."""return cls(id=str(uuid.uuid4()),@@ -221,6 +224,7 @@ class NodeExecution:Prefect-style: includes input hash for cache lookup."""+node_id: strnode_type: strstatus: TaskStatus = TaskStatus.PENDING@@ -271,6 +275,7 @@ class ExecutionContext:Conductor pattern: workflow_id identifies the workflow definition,execution_id identifies this specific run."""+execution_id: strworkflow_id: strstatus: WorkflowStatus = WorkflowStatus.PENDING@@ -299,8 +304,9 @@ class ExecutionContext:errors: List[Dict[str, Any]] = field(default_factory=list)@classmethod- def create(cls, workflow_id: str, session_id: str = "default",- nodes: List[Dict] = None, edges: List[Dict] = None) -> "ExecutionContext":+ def create(+ cls, workflow_id: str, session_id: str = "default", nodes: List[Dict] = None, edges: List[Dict] = None+ ) -> "ExecutionContext":"""Factory method to create new execution context.Supports pre-executed nodes (marked with _pre_executed=True) for@@ -331,7 +337,7 @@ class ExecutionContext:ai_agent_node_ids = {n.get("id") for n in (nodes or []) if n.get("type") in AI_AGENT_TYPES}subnode_ids: set = set()- for edge in (edges or []):+ for edge in edges or []:source = edge.get("source")target = edge.get("target")target_handle = edge.get("targetHandle")@@ -343,11 +349,11 @@ class ExecutionContext:# Nodes connected to AI Agent config handles are sub-nodes# These handles: input-memory, input-tools, input-skill, input-teammatesif target in ai_agent_node_ids and source and target_handle:- if target_handle in ('input-memory', 'input-tools', 'input-skill', 'input-teammates'):+ if target_handle in ("input-memory", "input-tools", "input-skill", "input-teammates"):subnode_ids.add(source)# Initialize node executions for all nodes (excluding config nodes and sub-nodes)- for node in (nodes or []):+ for node in nodes or []:node_id = node.get("id")node_type = node.get("type", "unknown")@@ -392,8 +398,7 @@ class ExecutionContext:node_exec = self.node_executions.get(node_id)return node_exec.status if node_exec else None- def set_node_status(self, node_id: str, status: TaskStatus,- output: Dict = None, error: str = None) -> None:+ def set_node_status(self, node_id: str, status: TaskStatus, output: Dict = None, error: str = None) -> None:"""Update node execution status."""if node_id not in self.node_executions:return@@ -416,11 +421,7 @@ class ExecutionContext:node_exec.completed_at = time.time()if error:node_exec.error = error- self.errors.append({- "node_id": node_id,- "error": error,- "timestamp": time.time()- })+ self.errors.append({"node_id": node_id, "error": error, "timestamp": time.time()})def add_checkpoint(self, node_id: str) -> None:"""Add checkpoint after node completion (for recovery)."""@@ -430,22 +431,19 @@ class ExecutionContext:def get_completed_nodes(self) -> List[str]:"""Get list of completed node IDs."""return [- node_id for node_id, node_exec in self.node_executions.items()+ node_id+ for node_id, node_exec in self.node_executions.items()if node_exec.status in (TaskStatus.COMPLETED, TaskStatus.CACHED, TaskStatus.SKIPPED)]def get_pending_nodes(self) -> List[str]:"""Get list of pending node IDs."""- return [- node_id for node_id, node_exec in self.node_executions.items()- if node_exec.status == TaskStatus.PENDING- ]+ return [node_id for node_id, node_exec in self.node_executions.items() if node_exec.status == TaskStatus.PENDING]def all_nodes_complete(self) -> bool:"""Check if all nodes are complete."""for node_exec in self.node_executions.values():- if node_exec.status not in (TaskStatus.COMPLETED, TaskStatus.CACHED,- TaskStatus.SKIPPED, TaskStatus.CANCELLED):+ if node_exec.status not in (TaskStatus.COMPLETED, TaskStatus.CACHED, TaskStatus.SKIPPED, TaskStatus.CANCELLED):return Falsereturn True@@ -456,9 +454,7 @@ class ExecutionContext:"workflow_id": self.workflow_id,"status": self.status.value,"session_id": self.session_id,- "node_executions": {- k: v.to_dict() for k, v in self.node_executions.items()- },+ "node_executions": {k: v.to_dict() for k, v in self.node_executions.items()},"outputs": self.outputs,"execution_order": self.execution_order,"current_layer": self.current_layer,@@ -474,8 +470,7 @@ class ExecutionContext:}@classmethod- def from_dict(cls, data: Dict[str, Any], nodes: List[Dict] = None,- edges: List[Dict] = None) -> "ExecutionContext":+ def from_dict(cls, data: Dict[str, Any], nodes: List[Dict] = None, edges: List[Dict] = None) -> "ExecutionContext":"""Create from dict (Redis deserialization)."""ctx = cls(execution_id=data["execution_id"],@@ -508,8 +503,7 @@ class ExecutionContext:return json.dumps(self.to_dict())@classmethod- def from_json(cls, json_str: str, nodes: List[Dict] = None,- edges: List[Dict] = None) -> "ExecutionContext":+ def from_json(cls, json_str: str, nodes: List[Dict] = None, edges: List[Dict] = None) -> "ExecutionContext":"""Deserialize from JSON string."""data = json.loads(json_str)return cls.from_dict(data, nodes, edges)diff --git a/server/services/execution/recovery.py b/server/services/execution/recovery.pyindex 16faf778..d679edd9 100644--- a/server/services/execution/recovery.py+++ b/server/services/execution/recovery.py@@ -27,10 +27,13 @@ class RecoverySweeper:- Triggers workflow_decide to resume"""- def __init__(self, cache: ExecutionCache,- heartbeat_timeout: int = 300, # 5 minutes- sweep_interval: int = 60, # 1 minute- max_retries: int = 3):+ def __init__(+ self,+ cache: ExecutionCache,+ heartbeat_timeout: int = 300, # 5 minutes+ sweep_interval: int = 60, # 1 minute+ max_retries: int = 3,+ ):"""Initialize recovery sweeper.Args:@@ -65,9 +68,7 @@ class RecoverySweeper:self._running = Trueself._task = asyncio.create_task(self._sweep_loop())- logger.info("Recovery sweeper started",- heartbeat_timeout=self.heartbeat_timeout,- sweep_interval=self.sweep_interval)+ logger.info("Recovery sweeper started", heartbeat_timeout=self.heartbeat_timeout, sweep_interval=self.sweep_interval)async def stop(self) -> None:"""Stop the recovery sweeper."""@@ -105,8 +106,7 @@ class RecoverySweeper:try:await self._check_execution(execution_id)except Exception as e:- logger.error("Failed to check execution",- execution_id=execution_id, error=str(e))+ logger.error("Failed to check execution", execution_id=execution_id, error=str(e))async def _check_execution(self, execution_id: str) -> None:"""Check single execution for stuck nodes.@@ -118,15 +118,13 @@ class RecoverySweeper:ctx = await self.cache.load_execution_state(execution_id)if not ctx:# Execution not found - remove from active set- logger.warning("Orphan execution in active set",- execution_id=execution_id)+ logger.warning("Orphan execution in active set", execution_id=execution_id)if self.cache.cache.is_redis_available():await self.cache.cache.redis.srem("executions:active", execution_id)return# Check if already complete- if ctx.status in (WorkflowStatus.COMPLETED, WorkflowStatus.FAILED,- WorkflowStatus.CANCELLED):+ if ctx.status in (WorkflowStatus.COMPLETED, WorkflowStatus.FAILED, WorkflowStatus.CANCELLED):# Should not be in active setif self.cache.cache.is_redis_available():await self.cache.cache.redis.srem("executions:active", execution_id)@@ -145,18 +143,19 @@ class RecoverySweeper:# No heartbeat - node is stuckstuck_duration = current_time - (node_exec.started_at or current_time)if stuck_duration > self.heartbeat_timeout:- logger.warning("Node stuck (no heartbeat)",- execution_id=execution_id,- node_id=node_id,- stuck_seconds=stuck_duration)+ logger.warning(+ "Node stuck (no heartbeat)", execution_id=execution_id, node_id=node_id, stuck_seconds=stuck_duration+ )needs_recovery = Trueelif current_time - last_heartbeat > self.heartbeat_timeout:# Heartbeat too old- logger.warning("Node stuck (stale heartbeat)",- execution_id=execution_id,- node_id=node_id,- heartbeat_age=current_time - last_heartbeat)+ logger.warning(+ "Node stuck (stale heartbeat)",+ execution_id=execution_id,+ node_id=node_id,+ heartbeat_age=current_time - last_heartbeat,+ )needs_recovery = Trueif needs_recovery and self._on_recovery:@@ -164,8 +163,7 @@ class RecoverySweeper:try:await self._on_recovery(execution_id)except Exception as e:- logger.error("Recovery callback failed",- execution_id=execution_id, error=str(e))+ logger.error("Recovery callback failed", execution_id=execution_id, error=str(e))async def scan_on_startup(self) -> List[str]:"""Scan for executions that need recovery on server startup.@@ -178,8 +176,7 @@ class RecoverySweeper:# Get all active executionsactive_ids = await self.cache.get_active_executions()- logger.info("Startup scan for incomplete executions",- active_count=len(active_ids))+ logger.info("Startup scan for incomplete executions", active_count=len(active_ids))for execution_id in active_ids:ctx = await self.cache.load_execution_state(execution_id)@@ -192,9 +189,7 @@ class RecoverySweeper:if ctx.updated_at:age = time.time() - ctx.updated_atif age > self.heartbeat_timeout:- logger.info("Found interrupted execution",- execution_id=execution_id,- age_seconds=age)+ logger.info("Found interrupted execution", execution_id=execution_id, age_seconds=age)needs_recovery.append(execution_id)return needs_recoverydiff --git a/server/services/handlers/todo.py b/server/services/handlers/todo.pyindex 0fe729a5..43ae6ae6 100644--- a/server/services/handlers/todo.py+++ b/server/services/handlers/todo.py@@ -24,11 +24,7 @@ async def execute_write_todos((matches pre-refactor handler precedence)."""config = config or {}- session_key = (- config.get("workflow_id")- or config.get("node_id")- or "default"- )+ session_key = config.get("workflow_id") or config.get("node_id") or "default"todos = args.get("todos", [])service = get_todo_service()stored = service.write(session_key, todos)@@ -37,7 +33,8 @@ async def execute_write_todos(node_id = config.get("node_id")if broadcaster and node_id:await broadcaster.update_node_status(- node_id, "executing",+ node_id,+ "executing",{"phase": "todo_update", "todos": stored},workflow_id=config.get("workflow_id"),)diff --git a/server/services/handlers/tools.py b/server/services/handlers/tools.pyindex 43ddda45..63b91511 100644--- a/server/services/handlers/tools.py+++ b/server/services/handlers/tools.py@@ -18,6 +18,7 @@ if TYPE_CHECKING:logger = get_logger(__name__)+def _plugin_connection_factory(plugin_cls, context):"""Build a per-call :class:`Connection` factory bound to a pluginclass's declared credentials. Mirrors@@ -33,10 +34,7 @@ def _plugin_connection_factory(plugin_cls, context):def factory(credential_id: str):cred_cls = creds_by_id.get(credential_id)if cred_cls is None:- raise RuntimeError(- f"Plugin {plugin_cls.type} did not declare credential "- f"'{credential_id}' but tried to use it."- )+ raise RuntimeError(f"Plugin {plugin_cls.type} did not declare credential " f"'{credential_id}' but tried to use it.")return Connection(cred_cls, user_id=user_id, session_id=session_id)return factory@@ -68,8 +66,7 @@ def is_node_in_active_delegation(node_id: str) -> bool:return _active_delegated_nodes.get(node_id, 0) > 0-async def execute_tool(tool_name: str, tool_args: Dict[str, Any],- config: Dict[str, Any]) -> Dict[str, Any]:+async def execute_tool(tool_name: str, tool_args: Dict[str, Any], config: Dict[str, Any]) -> Dict[str, Any]:"""Execute a tool by name and own the tool node's status lifecycle.This is the single source of truth for the tool node's@@ -98,12 +95,13 @@ async def execute_tool(tool_name: str, tool_args: Dict[str, Any],from services.status_broadcaster import get_status_broadcasterbroadcaster = get_status_broadcaster()- node_id = config.get('node_id')- workflow_id = config.get('workflow_id')+ node_id = config.get("node_id")+ workflow_id = config.get("workflow_id")if node_id and broadcaster:await broadcaster.update_node_status(- node_id, "executing",+ node_id,+ "executing",{"message": f"Executing {tool_name}"},workflow_id=workflow_id,)@@ -114,34 +112,32 @@ async def execute_tool(tool_name: str, tool_args: Dict[str, Any],logger.error("[Tool] Execution failed: %s", tool_name, exc_info=True)if node_id and broadcaster:await broadcaster.update_node_status(- node_id, "error",+ node_id,+ "error",{"message": f"{tool_name} failed", "error": str(e)},workflow_id=workflow_id,)raise- handler_owns_lifecycle = (- isinstance(result, dict)- and result.get("status") in ("delegated", "ALREADY_DELEGATED")- )+ handler_owns_lifecycle = isinstance(result, dict) and result.get("status") in ("delegated", "ALREADY_DELEGATED")if node_id and broadcaster and not handler_owns_lifecycle:await broadcaster.update_node_status(- node_id, "success",+ node_id,+ "success",{"message": f"{tool_name} completed", "result": result},workflow_id=workflow_id,)return result-async def _dispatch_tool(tool_name: str, tool_args: Dict[str, Any],- config: Dict[str, Any]) -> Dict[str, Any]:+async def _dispatch_tool(tool_name: str, tool_args: Dict[str, Any], config: Dict[str, Any]) -> Dict[str, Any]:"""Route a tool call to the right handler based on ``node_type``.Pure dispatch — no broadcasting. Lifecycle is owned by:func:`execute_tool`."""- node_type = config.get('node_type', '')- node_params = config.get('parameters', {})+ node_type = config.get("node_type", "")+ node_params = config.get("parameters", {})# Execution context for tool handlers. Includes canvas state# (nodes/edges/workflow_id) that callers (chat_tool_executor in@@ -150,14 +146,14 @@ async def _dispatch_tool(tool_name: str, tool_args: Dict[str, Any],# read these via NodeContext.nodes / .edges / .workflow_id; tools# that don't simply ignore them.context = {- 'workspace_dir': config.get('workspace_dir', ''),- 'nodes': config.get('nodes', []),- 'edges': config.get('edges', []),- 'workflow_id': config.get('workflow_id'),- 'parent_node_id': config.get('parent_node_id'),+ "workspace_dir": config.get("workspace_dir", ""),+ "nodes": config.get("nodes", []),+ "edges": config.get("edges", []),+ "workflow_id": config.get("workflow_id"),+ "parent_node_id": config.get("parent_node_id"),}- logger.info("[Tool] Executing '%s' (node_type=%s, workspace=%s)", tool_name, node_type, context['workspace_dir'])+ logger.info("[Tool] Executing '%s' (node_type=%s, workspace=%s)", tool_name, node_type, context["workspace_dir"])# ----------------------------------------------------------------# Plugin fast-path (Wave 11.B.1): if this node_type is a@@ -175,17 +171,16 @@ async def _dispatch_tool(tool_name: str, tool_args: Dict[str, Any],# prompt) expect for delegation tools.# ----------------------------------------------------------------from services.node_registry import get_node_class- plugin_cls = (- None if node_type in AI_AGENT_TYPES- else get_node_class(node_type)- )++ plugin_cls = None if node_type in AI_AGENT_TYPES else get_node_class(node_type)if plugin_cls is not None:from services.plugin import NodeContext+instance = plugin_cls()ctx = NodeContext.from_legacy(- node_id=config.get('node_id', f'tool_{node_type}'),+ node_id=config.get("node_id", f"tool_{node_type}"),node_type=node_type,- context={**context, 'parameters': node_params},+ context={**context, "parameters": node_params},connection_factory=_plugin_connection_factory(plugin_cls, context),)return await instance.execute_as_tool(tool_args, node_params, ctx)@@ -203,31 +198,35 @@ async def _dispatch_tool(tool_name: str, tool_args: Dict[str, Any],# also need LLM-arg translation that doesn't fit the plugin Params# shape. Both dispatchers live with their domain on# nodes/android/_base.py (Wave 11.E.3 move).- if node_type == 'androidTool':+ if node_type == "androidTool":from nodes.android._base import execute_android_toolkit+return await execute_android_toolkit(tool_args, config)if node_type in ANDROID_SERVICE_NODE_TYPES:from nodes.android._base import execute_android_service_tool+return await execute_android_service_tool(tool_args, config)# taskManager: dispatcher reads through to the agent-delegation# tracking dicts (_delegated_tasks / _delegation_results) defined# below in this module. The operation matrix moved to the plugin# (Wave 11.I, milestone O).- if node_type == 'taskManager':+ if node_type == "taskManager":from nodes.tool.task_manager import _execute_task_manager+return await _execute_task_manager(tool_args, config)# proxyConfig: 10-operation matrix lives on the plugin# (nodes/proxy/proxy_config.execute_proxy_config). Plugin params win.- if node_type == 'proxyConfig':+ if node_type == "proxyConfig":from nodes.proxy.proxy_config import execute_proxy_config- merged = {**config.get('parameters', {}), **tool_args}++ merged = {**config.get("parameters", {}), **tool_args}return await execute_proxy_config(merged)# Built-in: Check delegated task results# Auto-injected when parent has delegation tools- if node_type == '_builtin_check_delegated_tasks':+ if node_type == "_builtin_check_delegated_tasks":return await _execute_check_delegated_tasks(tool_args, config)# AI Agent delegation (fire-and-forget async delegation).@@ -246,14 +245,6 @@ async def _dispatch_tool(tool_name: str, tool_args: Dict[str, Any],# nodes/tool/calculator_tool.py CalculatorToolNode.calculate().--------# _execute_duckduckgo_search: Wave 11.C moved logic to# nodes/search/duckduckgo_search.py DuckDuckGoSearchNode.search(). Wave# 11.I milestone O moved the flat (args, config) -> dict shim used by@@ -264,10 +255,6 @@ async def _dispatch_tool(tool_name: str, tool_args: Dict[str, Any],# now routes through the plugin fast-path (nodes/whatsapp/*.py).----# Wave 11.D.10: _execute_geocoding / _execute_nearby_places deleted.# gmaps_locations + gmaps_nearby_places now route through the plugin# fast-path (nodes/location/*.py).@@ -282,16 +269,7 @@ async def _dispatch_tool(tool_name: str, tool_args: Dict[str, Any],# (nodes/google/*.py). These functions were defined but unreferenced.---------async def _execute_generic(args: Dict[str, Any],- config: Dict[str, Any]) -> Dict[str, Any]:+async def _execute_generic(args: Dict[str, Any], config: Dict[str, Any]) -> Dict[str, Any]:"""Execute a generic tool (fallback handler).For node types without specific handlers, this returns the input@@ -305,15 +283,14 @@ async def _execute_generic(args: Dict[str, Any],Dict with input echoed and node info"""return {- "input": args.get('input', ''),- "node_type": config.get('node_type'),- "node_id": config.get('node_id'),- "message": "Generic tool executed - no specific handler for this node type"+ "input": args.get("input", ""),+ "node_type": config.get("node_type"),+ "node_id": config.get("node_id"),+ "message": "Generic tool executed - no specific handler for this node type",}-async def _execute_delegated_agent(args: Dict[str, Any],- config: Dict[str, Any]) -> Dict[str, Any]:+async def _execute_delegated_agent(args: Dict[str, Any], config: Dict[str, Any]) -> Dict[str, Any]:"""Delegate a task to a child AI Agent (fire-and-forget pattern).This spawns the child agent as an asyncio background task and returns@@ -329,26 +306,26 @@ async def _execute_delegated_agent(args: Dict[str, Any],"""from services.status_broadcaster import get_status_broadcaster- node_id = config.get('node_id')- node_type = config.get('node_type')- workflow_id = config.get('workflow_id')- task_description = args.get('task', '')- task_context = args.get('context', '')+ node_id = config.get("node_id")+ node_type = config.get("node_type")+ workflow_id = config.get("workflow_id")+ task_description = args.get("task", "")+ task_context = args.get("context", "")# Get injected services- ai_service = config.get('ai_service')- database = config.get('database')- nodes = config.get('nodes', [])- edges = config.get('edges', [])+ ai_service = config.get("ai_service")+ database = config.get("database")+ nodes = config.get("nodes", [])+ edges = config.get("edges", [])if not ai_service or not database:return {"error": "Agent delegation requires ai_service and database in config",- "hint": "Ensure nodes/edges are passed to tool config"+ "hint": "Ensure nodes/edges are passed to tool config",}# Get parent node ID for duplicate tracking- parent_node_id = config.get('parent_node_id', '')+ parent_node_id = config.get("parent_node_id", "")# Generate hash of task to detect duplicate delegation attemptstask_hash = hashlib.md5(f"{task_description}:{task_context}".encode()).hexdigest()[:16]@@ -362,7 +339,7 @@ async def _execute_delegated_agent(args: Dict[str, Any],"success": True,"status": "ALREADY_DELEGATED","task_id": existing_task_id,- "agent_name": config.get('parameters', {}).get('label', node_type),+ "agent_name": config.get("parameters", {}).get("label", node_type),"result": (f"This task was ALREADY delegated (task_id: {existing_task_id}). "f"Do NOT call this tool again. Use 'check_delegated_tasks' to check status."@@ -388,44 +365,41 @@ async def _execute_delegated_agent(args: Dict[str, Any],# Inject API key - delegated agents bypass NodeExecutor._inject_api_keys,# so we must resolve the key here from the credential store- if not child_params.get('api_key'):+ if not child_params.get("api_key"):from constants import detect_ai_provider+provider = detect_ai_provider(node_type, child_params)key = await ai_service.auth.get_api_key(provider, "default")if key:- child_params['api_key'] = key+ child_params["api_key"] = keylogger.debug(f"[Delegated Agent] Injected API key for provider={provider}")# Inject default model if not set- if not child_params.get('model'):+ if not child_params.get("model"):from constants import detect_ai_provider+provider = detect_ai_provider(node_type, child_params)models = await ai_service.auth.get_stored_models(provider, "default")if models:- child_params['model'] = models[0]+ child_params["model"] = models[0]# Task goes into system_message (directive), context data goes into prompt.# Schema-canonical key is snake_case; drop any pre-migration camelCase# mirror so the saved-params dict downstream uses the canonical key.- child_params['system_message'] = task_description- child_params.pop('systemMessage', None)- child_params['prompt'] = task_context if task_context else task_description+ child_params["system_message"] = task_description+ child_params.pop("systemMessage", None)+ child_params["prompt"] = task_context if task_context else task_description# Create execution context for child agent- child_context = {- 'nodes': nodes,- 'edges': edges,- 'workflow_id': workflow_id,- 'outputs': {},- 'parent_task_id': task_id- }+ child_context = {"nodes": nodes, "edges": edges, "workflow_id": workflow_id, "outputs": {}, "parent_task_id": task_id}broadcaster = get_status_broadcaster()- agent_label = child_params.get('label', node_type)+ agent_label = child_params.get("label", node_type)logger.info(f"[Delegated Agent] Starting task {task_id} for '{agent_label}' (node: {node_id})")- logger.debug(f"[Delegated Agent] Context: {len(nodes)} nodes, {len(edges)} edges, "- f"edge_targets={set(e.get('target') for e in edges)}")+ logger.debug(+ f"[Delegated Agent] Context: {len(nodes)} nodes, {len(edges)} edges, " f"edge_targets={set(e.get('target') for e in edges)}"+ )# Define the background coroutineasync def run_child_agent():@@ -434,12 +408,8 @@ async def _execute_delegated_agent(args: Dict[str, Any],await broadcaster.update_node_status(node_id,"executing",- {- "phase": "delegated_task",- "task_id": task_id,- "message": f"Working on: {task_description[:100]}..."- },- workflow_id=workflow_id+ {"phase": "delegated_task", "task_id": task_id, "message": f"Working on: {task_description[:100]}..."},+ workflow_id=workflow_id,)# Execute the child agent via its own plugin class.@@ -455,27 +425,22 @@ async def _execute_delegated_agent(args: Dict[str, Any],raise RuntimeError(f"Unknown delegated agent type: {node_type}")instance = plugin_cls()child_ctx = NodeContext.from_legacy(- node_id=node_id, node_type=node_type, context=child_context,+ node_id=node_id,+ node_type=node_type,+ context=child_context,)result = await instance.execute(node_id, child_params, child_ctx)logger.info(f"[Delegated Agent] Task {task_id} completed: success={result.get('success')}")# Check if child agent actually succeeded- if not result.get('success'):+ if not result.get("success"):# Child agent returned failure - treat as error- error_msg = result.get('error', 'Child agent returned failure')+ error_msg = result.get("error", "Child agent returned failure")logger.warning(f"[Delegated Agent] Task {task_id} returned success=False: {error_msg}")await broadcaster.update_node_status(- node_id,- "error",- {- "phase": "delegated_error",- "task_id": task_id,- "error": error_msg- },- workflow_id=workflow_id+ node_id, "error", {"phase": "delegated_error", "task_id": task_id, "error": error_msg}, workflow_id=workflow_id)# Cache error for parent retrieval@@ -496,11 +461,11 @@ async def _execute_delegated_agent(args: Dict[str, Any],output_name="delegation_result",data={"task_id": task_id,- "parent_node_id": config.get('parent_node_id', ''),+ "parent_node_id": config.get("parent_node_id", ""),"agent_name": agent_label,"status": "error","error": error_msg,- }+ },)# Dispatch error event for trigger nodes — Wave 12 B8.@@ -510,7 +475,7 @@ async def _execute_delegated_agent(args: Dict[str, Any],task_id=task_id,agent_name=agent_label,agent_node_id=node_id,- parent_node_id=config.get('parent_node_id', ''),+ parent_node_id=config.get("parent_node_id", ""),workflow_id=workflow_id,error=error_msg,)@@ -518,22 +483,18 @@ async def _execute_delegated_agent(args: Dict[str, Any],return result# Success case - extract response properly- response_text = result.get('result', {}).get('response', '')+ response_text = result.get("result", {}).get("response", "")if not response_text:# Fallback: try to stringify the result dict- response_text = str(result.get('result', '')) if result.get('result') else 'No response generated'+ response_text = str(result.get("result", "")) if result.get("result") else "No response generated"# Broadcast completion- response_preview = response_text[:200] if response_text else ''+ response_preview = response_text[:200] if response_text else ""await broadcaster.update_node_status(node_id,"success",- {- "phase": "delegated_complete",- "task_id": task_id,- "result_summary": response_preview- },- workflow_id=workflow_id+ {"phase": "delegated_complete", "task_id": task_id, "result_summary": response_preview},+ workflow_id=workflow_id,)# Cache result for parent retrieval (Layer 2: in-memory)@@ -554,11 +515,11 @@ async def _execute_delegated_agent(args: Dict[str, Any],output_name="delegation_result",data={"task_id": task_id,- "parent_node_id": config.get('parent_node_id', ''),+ "parent_node_id": config.get("parent_node_id", ""),"agent_name": agent_label,"status": "completed","result": response_text,- }+ },)# Dispatch task_completed event for trigger nodes — Wave 12 B8.@@ -568,7 +529,7 @@ async def _execute_delegated_agent(args: Dict[str, Any],task_id=task_id,agent_name=agent_label,agent_node_id=node_id,- parent_node_id=config.get('parent_node_id', ''),+ parent_node_id=config.get("parent_node_id", ""),workflow_id=workflow_id,result=response_text,)@@ -578,14 +539,7 @@ async def _execute_delegated_agent(args: Dict[str, Any],except Exception as e:logger.error(f"[Delegated Agent] Task {task_id} failed: {e}")await broadcaster.update_node_status(- node_id,- "error",- {- "phase": "delegated_error",- "task_id": task_id,- "error": str(e)- },- workflow_id=workflow_id+ node_id, "error", {"phase": "delegated_error", "task_id": task_id, "error": str(e)}, workflow_id=workflow_id)# Cache error for parent retrieval (Layer 2: in-memory)@@ -606,11 +560,11 @@ async def _execute_delegated_agent(args: Dict[str, Any],output_name="delegation_result",data={"task_id": task_id,- "parent_node_id": config.get('parent_node_id', ''),+ "parent_node_id": config.get("parent_node_id", ""),"agent_name": agent_label,"status": "error","error": str(e),- }+ },)# Dispatch task_completed event for trigger nodes (error case) — Wave 12 B8.@@ -620,7 +574,7 @@ async def _execute_delegated_agent(args: Dict[str, Any],task_id=task_id,agent_name=agent_label,agent_node_id=node_id,- parent_node_id=config.get('parent_node_id', ''),+ parent_node_id=config.get("parent_node_id", ""),workflow_id=workflow_id,error=str(e),)@@ -661,8 +615,7 @@ async def _execute_delegated_agent(args: Dict[str, Any],}-async def get_delegated_task_status(task_ids: Optional[List[str]] = None,- database=None) -> Dict[str, Any]:+async def get_delegated_task_status(task_ids: Optional[List[str]] = None, database=None) -> Dict[str, Any]:"""Check status and retrieve results of delegated tasks.3-layer lookup: live tasks -> memory cache -> DB (NodeOutput).@@ -677,9 +630,7 @@ async def get_delegated_task_status(task_ids: Optional[List[str]] = None,"""if not task_ids:# Return all known from memory- task_ids = list(set(- list(_delegated_tasks.keys()) + list(_delegation_results.keys())- ))+ task_ids = list(set(list(_delegated_tasks.keys()) + list(_delegation_results.keys())))tasks = []db_lookup_ids = []@@ -694,7 +645,7 @@ async def get_delegated_task_status(task_ids: Optional[List[str]] = None,# Task finished -- extract result via task.result()try:result = live_task.result()- response = result.get('result', {}).get('response', str(result.get('result', '')))+ response = result.get("result", {}).get("response", str(result.get("result", "")))tasks.append({"task_id": tid, "status": "completed", "result": response})except Exception as e:tasks.append({"task_id": tid, "status": "error", "error": str(e)})@@ -712,21 +663,20 @@ async def get_delegated_task_status(task_ids: Optional[List[str]] = None,# DB fallback for results not in memory (cross-restart)if db_lookup_ids and database:for tid in list(db_lookup_ids):- db_result = await database.get_node_output_by_session(- session_id=f"delegation_{tid}",- output_name="delegation_result"- )+ db_result = await database.get_node_output_by_session(session_id=f"delegation_{tid}", output_name="delegation_result")if db_result:- data = db_result.get('data', {})+ data = db_result.get("data", {})result_data = data.get("result", {})response_text = result_data.get("response", str(result_data)) if isinstance(result_data, dict) else str(result_data)- tasks.append({- "task_id": tid,- "status": data.get("status", "completed"),- "agent_name": data.get("agent_name", ""),- "result": response_text,- "error": data.get("error"),- })+ tasks.append(+ {+ "task_id": tid,+ "status": data.get("status", "completed"),+ "agent_name": data.get("agent_name", ""),+ "result": response_text,+ "error": data.get("error"),+ }+ )db_lookup_ids.remove(tid)# Remaining IDs not found anywhere@@ -736,15 +686,14 @@ async def get_delegated_task_status(task_ids: Optional[List[str]] = None,return {"tasks": tasks}-async def _execute_check_delegated_tasks(args: Dict[str, Any],- config: Dict[str, Any]) -> Dict[str, Any]:+async def _execute_check_delegated_tasks(args: Dict[str, Any], config: Dict[str, Any]) -> Dict[str, Any]:"""LLM-callable tool: check on delegated child agents.Returns status and results for previously delegated tasks.Follows Celery AsyncResult / Ray ObjectRef patterns."""- task_ids = args.get('task_ids')- database = config.get('database')+ task_ids = args.get("task_ids")+ database = config.get("database")result = await get_delegated_task_status(task_ids=task_ids, database=database)formatted = []@@ -788,6 +737,3 @@ async def _execute_check_delegated_tasks(args: Dict[str, Any],# now route through the plugin fast-path in execute_tool which calls# the BaseNode.execute_as_tool method on the plugin class.# _execute_serper_search_tool stays until serperSearch is migrated.---diff --git a/server/services/handlers/triggers.py b/server/services/handlers/triggers.pyindex 93e2e8fe..b2e56e62 100644--- a/server/services/handlers/triggers.py+++ b/server/services/handlers/triggers.py@@ -10,12 +10,7 @@ from services import event_waiterlogger = get_logger(__name__)-async def handle_trigger_node(- node_id: str,- node_type: str,- parameters: Dict[str, Any],- context: Dict[str, Any]-) -> Dict[str, Any]:+async def handle_trigger_node(node_id: str, node_type: str, parameters: Dict[str, Any], context: Dict[str, Any]) -> Dict[str, Any]:"""Handle trigger node execution (webhook, whatsapp, etc.).Uses event_waiter module to register waiter and await matching event.@@ -31,8 +26,9 @@ async def handle_trigger_node(Execution result dict with event data"""from services.status_broadcaster import get_status_broadcaster+start_time = time.time()- execution_id = context.get('execution_id', 'unknown')+ execution_id = context.get("execution_id", "unknown")# Get trigger configurationconfig = event_waiter.get_trigger_config(node_type)@@ -44,7 +40,7 @@ async def handle_trigger_node("node_type": node_type,"error": f"Unknown trigger type: {node_type}","execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}try:@@ -67,20 +63,26 @@ async def handle_trigger_node(waiter = await event_waiter.register(node_type, node_id, parameters)# Get workflow_id from context for per-workflow status scoping (n8n pattern)- workflow_id = context.get('workflow_id')+ workflow_id = context.get("workflow_id")# Broadcast waiting status to frontendbroadcaster = get_status_broadcaster()logger.info("Broadcasting waiting status", node_id=node_id, execution_id=execution_id)- await broadcaster.update_node_status(node_id, "waiting", {- "message": f"Waiting for {config.display_name}...",- "event_type": config.event_type,- "waiter_id": waiter.id- }, workflow_id=workflow_id)-- logger.info("Trigger waiting for event", node_id=node_id, node_type=node_type,- event_type=config.event_type, execution_id=execution_id,- backend_mode=event_waiter.get_backend_mode())+ await broadcaster.update_node_status(+ node_id,+ "waiting",+ {"message": f"Waiting for {config.display_name}...", "event_type": config.event_type, "waiter_id": waiter.id},+ workflow_id=workflow_id,+ )++ logger.info(+ "Trigger waiting for event",+ node_id=node_id,+ node_type=node_type,+ event_type=config.event_type,+ execution_id=execution_id,+ backend_mode=event_waiter.get_backend_mode(),+ )# Wait for event indefinitely (user cancels via cancel_event_wait)# Uses wait_for_event which handles both Redis Streams and asyncio.Future modes@@ -95,7 +97,7 @@ async def handle_trigger_node("node_type": node_type,"result": event_data,"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except asyncio.CancelledError:@@ -106,17 +108,16 @@ async def handle_trigger_node("node_type": node_type,"error": "Cancelled by user","execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:- logger.error("Trigger execution failed", node_id=node_id, node_type=node_type,- execution_id=execution_id, error=str(e))+ logger.error("Trigger execution failed", node_id=node_id, node_type=node_type, execution_id=execution_id, error=str(e))return {"success": False,"node_id": node_id,"node_type": node_type,"error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}diff --git a/server/services/llm/config.py b/server/services/llm/config.pyindex 045fddb8..924ce641 100644--- a/server/services/llm/config.py+++ b/server/services/llm/config.py@@ -18,9 +18,11 @@ logger = get_logger(__name__)# Provider config dataclass# ---------------------------------------------------------------------------+@dataclassclass ProviderConfig:"""Metadata for a single LLM provider."""+name: strdefault_model: strdetection_patterns: Tuple[str, ...]@@ -35,6 +37,7 @@ class ProviderConfig:# Load config/llm_defaults.json once at import time# ---------------------------------------------------------------------------+def _load_llm_defaults() -> Dict[str, Any]:config_path = Path(__file__).parent.parent.parent / "config" / "llm_defaults.json"try:@@ -68,6 +71,7 @@ _AUTH_OVERRIDES: Dict[str, Dict[str, str]] = {# Provider registry -- built dynamically from llm_defaults.json# ---------------------------------------------------------------------------+def _build_provider_configs() -> Dict[str, ProviderConfig]:"""Build ProviderConfig entries from llm_defaults.json."""providers = LLM_DEFAULTS.get("providers", {})@@ -100,6 +104,7 @@ def get_provider_config(provider: str) -> Optional[ProviderConfig]:# Provider detection from model name# ---------------------------------------------------------------------------+def detect_provider_from_model(model: str) -> str:model_lower = model.lower()for name, cfg in PROVIDER_CONFIGS.items():@@ -114,7 +119,7 @@ def is_model_valid_for_provider(model: str, provider: str) -> bool:# match any "lmstudio"/"ollama" substring. Treat as always-valid;# the upstream API will 404 a genuinely missing model. See the# mirror in services/ai.py for the full rationale.- if provider in ('openrouter', 'ollama', 'lmstudio'):+ if provider in ("openrouter", "ollama", "lmstudio"):return Truecfg = PROVIDER_CONFIGS.get(provider)if not cfg:@@ -127,6 +132,7 @@ def is_model_valid_for_provider(model: str, provider: str) -> bool:# Default model helpers# ---------------------------------------------------------------------------+def get_default_model(provider: str) -> str:cfg = PROVIDER_CONFIGS.get(provider)return cfg.default_model if cfg else "gpt-5.2"@@ -148,9 +154,11 @@ async def get_default_model_async(provider: str, database) -> str:# Max-tokens / temperature resolution# ---------------------------------------------------------------------------+def resolve_max_tokens(params: dict, model: str, provider: str) -> int:"""Resolve max_tokens: user param -> model registry -> llm_defaults -> 4096."""from services.model_registry import get_model_registry+registry = get_model_registry()model_max = registry.get_max_output_tokens(model, provider)@@ -167,6 +175,7 @@ def resolve_max_tokens(params: dict, model: str, provider: str) -> int:def resolve_temperature(params: dict, model: str, provider: str, thinking_enabled: bool) -> float:"""Resolve temperature with model-specific constraints."""from services.model_registry import get_model_registry+registry = get_model_registry()user_temp = float(params.get("temperature", 0.7))diff --git a/server/services/llm/factory.py b/server/services/llm/factory.pyindex a649ac73..4440db8c 100644--- a/server/services/llm/factory.py+++ b/server/services/llm/factory.py@@ -16,10 +16,16 @@ _DEDICATED_PROVIDERS = frozenset({"anthropic", "openai", "gemini", "openrouter"}# Local servers (ollama, lmstudio) expose OpenAI-compatible /v1 endpoints, so they fall# through to OpenAIProvider with base_url from llm_defaults.json — same path as deepseek/# kimi/mistral. The user's custom URL rides via the existing {provider}_proxy credential.-NATIVE_PROVIDERS = _DEDICATED_PROVIDERS | frozenset({- "xai", "deepseek", "kimi", "mistral",- "ollama", "lmstudio",-})+NATIVE_PROVIDERS = _DEDICATED_PROVIDERS | frozenset(+ {+ "xai",+ "deepseek",+ "kimi",+ "mistral",+ "ollama",+ "lmstudio",+ }+)def create_provider(@@ -35,25 +41,31 @@ def create_provider("""if provider == "anthropic":from services.llm.providers.anthropic import AnthropicProvider+return AnthropicProvider(api_key, proxy_url=proxy_url)if provider == "openai":from services.llm.providers.openai import OpenAIProvider+return OpenAIProvider(api_key, proxy_url=proxy_url)if provider == "gemini":from services.llm.providers.gemini import GeminiProvider+return GeminiProvider(api_key, proxy_url=proxy_url)if provider == "openrouter":from services.llm.providers.openrouter import OpenRouterProvider+return OpenRouterProvider(api_key, proxy_url=proxy_url)# OpenAI-compatible providers: use OpenAIProvider with base_url from configfrom services.llm.config import get_provider_config+config = get_provider_config(provider)if config and config.base_url:from services.llm.providers.openai import OpenAIProvider+return OpenAIProvider(api_key, base_url=config.base_url, proxy_url=proxy_url)raise ValueError(f"Unknown provider: {provider}")diff --git a/server/services/llm/messages.py b/server/services/llm/messages.pyindex 40659d49..ace1c757 100644--- a/server/services/llm/messages.py+++ b/server/services/llm/messages.py@@ -11,11 +11,7 @@ def is_valid_message_content(content: Any) -> bool:if content is None:return Falseif isinstance(content, list):- return any(- (isinstance(b, dict) and b.get("text", "").strip())- or (isinstance(b, str) and b.strip())- for b in content- )+ return any((isinstance(b, dict) and b.get("text", "").strip()) or (isinstance(b, str) and b.strip()) for b in content)if isinstance(content, str):return bool(content.strip())return bool(content)diff --git a/server/services/llm/protocol.py b/server/services/llm/protocol.pyindex 1a3bfb6f..428986e4 100644--- a/server/services/llm/protocol.py+++ b/server/services/llm/protocol.py@@ -13,6 +13,7 @@ from typing import Any, Dict, List, Optional, Protocol, runtime_checkable# Shared data types# ---------------------------------------------------------------------------+@dataclassclass ThinkingConfig:"""Unified thinking/reasoning configuration.@@ -23,16 +24,18 @@ class ThinkingConfig:- Gemini 3+: thinking_level (low/medium/high)- Groq Qwen3: reasoning_format (parsed/hidden)"""+enabled: bool = Falsebudget: int = 2048effort: str = "medium"- level: str = "medium" # Gemini 3+ thinking_level+ level: str = "medium" # Gemini 3+ thinking_levelformat: str = "parsed"@dataclassclass ToolDef:"""Tool definition passed to the LLM."""+name: strdescription: strparameters: Dict[str, Any] # JSON Schema@@ -41,6 +44,7 @@ class ToolDef:@dataclassclass ToolCall:"""A tool invocation returned by the LLM."""+id: strname: strargs: Dict[str, Any]@@ -49,6 +53,7 @@ class ToolCall:@dataclassclass Message:"""Normalized chat message."""+role: str # system | user | assistant | toolcontent: str = ""tool_calls: List[ToolCall] = field(default_factory=list)@@ -59,6 +64,7 @@ class Message:@dataclassclass Usage:"""Token usage metrics."""+input_tokens: int = 0output_tokens: int = 0total_tokens: int = 0@@ -70,6 +76,7 @@ class Usage:@dataclassclass LLMResponse:"""Normalized response from any LLM provider."""+content: str = ""thinking: Optional[str] = Nonetool_calls: List[ToolCall] = field(default_factory=list)@@ -83,6 +90,7 @@ class LLMResponse:# Provider protocol (structural typing)# ---------------------------------------------------------------------------+@runtime_checkableclass LLMProvider(Protocol):provider_name: strdiff --git a/server/services/llm/providers/anthropic.py b/server/services/llm/providers/anthropic.pyindex d1dc4a37..5c769fb9 100644--- a/server/services/llm/providers/anthropic.py+++ b/server/services/llm/providers/anthropic.py@@ -7,7 +7,12 @@ from typing import Any, Dict, List, Optionalfrom core.logging import get_loggerfrom services.llm.protocol import (- LLMResponse, Message, ThinkingConfig, ToolCall, ToolDef, Usage,+ LLMResponse,+ Message,+ ThinkingConfig,+ ToolCall,+ ToolDef,+ Usage,)logger = get_logger(__name__)@@ -18,6 +23,7 @@ class AnthropicProvider:def __init__(self, api_key: str, *, proxy_url: Optional[str] = None):import anthropic+kwargs: Dict[str, Any] = {"api_key": api_key}if proxy_url:kwargs["base_url"] = proxy_url@@ -71,6 +77,7 @@ class AnthropicProvider:async def fetch_models(self, api_key: str) -> List[str]:import httpx+async with httpx.AsyncClient() as client:r = await client.get("https://api.anthropic.com/v1/models",@@ -117,12 +124,14 @@ class AnthropicProvider:if m.content:content.append({"type": "text", "text": m.content})for tc in m.tool_calls:- content.append({- "type": "tool_use",- "id": tc.id,- "name": tc.name,- "input": tc.args,- })+ content.append(+ {+ "type": "tool_use",+ "id": tc.id,+ "name": tc.name,+ "input": tc.args,+ }+ )return {"role": "assistant", "content": content}return {"role": role, "content": m.content}@@ -146,11 +155,13 @@ class AnthropicProvider:elif block.type == "thinking":thinking_parts.append(block.thinking)elif block.type == "tool_use":- tool_calls.append(ToolCall(- id=block.id,- name=block.name,- args=block.input if isinstance(block.input, dict) else json.loads(block.input),- ))+ tool_calls.append(+ ToolCall(+ id=block.id,+ name=block.name,+ args=block.input if isinstance(block.input, dict) else json.loads(block.input),+ )+ )usage = Usage(input_tokens=getattr(resp.usage, "input_tokens", 0),diff --git a/server/services/llm/providers/gemini.py b/server/services/llm/providers/gemini.pyindex abba94f5..b277df3b 100644--- a/server/services/llm/providers/gemini.py+++ b/server/services/llm/providers/gemini.py@@ -6,7 +6,12 @@ from typing import Any, Dict, List, Optionalfrom core.logging import get_loggerfrom services.llm.protocol import (- LLMResponse, Message, ThinkingConfig, ToolCall, ToolDef, Usage,+ LLMResponse,+ Message,+ ThinkingConfig,+ ToolCall,+ ToolDef,+ Usage,)logger = get_logger(__name__)@@ -17,6 +22,7 @@ class GeminiProvider:def __init__(self, api_key: str, *, proxy_url: Optional[str] = None):from google import genai+kwargs: Dict[str, Any] = {"api_key": api_key}if proxy_url:kwargs["http_options"] = {"base_url": proxy_url}@@ -74,6 +80,7 @@ class GeminiProvider:async def fetch_models(self, api_key: str) -> List[str]:import httpx+async with httpx.AsyncClient() as client:r = await client.get(f"https://generativelanguage.googleapis.com/v1beta/models?key={api_key}",@@ -103,13 +110,19 @@ class GeminiProvider:continueif m.role == "tool":- contents.append({- "role": "function",- "parts": [{"function_response": {- "name": m.name or "",- "response": {"result": m.content},- }}],- })+ contents.append(+ {+ "role": "function",+ "parts": [+ {+ "function_response": {+ "name": m.name or "",+ "response": {"result": m.content},+ }+ }+ ],+ }+ )continueif m.role == "assistant" and m.tool_calls:@@ -117,10 +130,14 @@ class GeminiProvider:if m.content:parts.append({"text": m.content})for tc in m.tool_calls:- parts.append({"function_call": {- "name": tc.name,- "args": tc.args,- }})+ parts.append(+ {+ "function_call": {+ "name": tc.name,+ "args": tc.args,+ }+ }+ )contents.append({"role": "model", "parts": parts})continue@@ -133,11 +150,13 @@ class GeminiProvider:@staticmethoddef _to_api_tool(tool: ToolDef) -> Dict[str, Any]:return {- "function_declarations": [{- "name": tool.name,- "description": tool.description,- "parameters": tool.parameters,- }]+ "function_declarations": [+ {+ "name": tool.name,+ "description": tool.description,+ "parameters": tool.parameters,+ }+ ]}def _normalize(self, resp: Any, model: str) -> LLMResponse:@@ -152,11 +171,13 @@ class GeminiProvider:elif hasattr(part, "function_call") and part.function_call:fc = part.function_callargs = dict(fc.args) if fc.args else {}- tool_calls.append(ToolCall(- id=fc.name, # Gemini doesn't have separate IDs- name=fc.name,- args=args,- ))+ tool_calls.append(+ ToolCall(+ id=fc.name, # Gemini doesn't have separate IDs+ name=fc.name,+ args=args,+ )+ )elif hasattr(part, "text") and part.text:text_parts.append(part.text)diff --git a/server/services/llm/providers/openai.py b/server/services/llm/providers/openai.pyindex 84490fed..cf332ebb 100644--- a/server/services/llm/providers/openai.py+++ b/server/services/llm/providers/openai.py@@ -11,7 +11,12 @@ from typing import Any, Dict, List, Optionalfrom core.logging import get_loggerfrom services.llm.protocol import (- LLMResponse, Message, ThinkingConfig, ToolCall, ToolDef, Usage,+ LLMResponse,+ Message,+ ThinkingConfig,+ ToolCall,+ ToolDef,+ Usage,)logger = get_logger(__name__)@@ -22,6 +27,7 @@ class OpenAIProvider:def __init__(self, api_key: str, *, proxy_url: Optional[str] = None, base_url: Optional[str] = None):import openai+kwargs: Dict[str, Any] = {"api_key": api_key}url = proxy_url or base_urlif url:@@ -143,11 +149,13 @@ class OpenAIProvider:if msg.tool_calls:for tc in msg.tool_calls:args = tc.function.arguments- tool_calls.append(ToolCall(- id=tc.id,- name=tc.function.name,- args=json.loads(args) if isinstance(args, str) else args,- ))+ tool_calls.append(+ ToolCall(+ id=tc.id,+ name=tc.function.name,+ args=json.loads(args) if isinstance(args, str) else args,+ )+ )u = resp.usageusage = Usage(diff --git a/server/services/llm/providers/openrouter.py b/server/services/llm/providers/openrouter.pyindex 5e93966f..6d4e8748 100644--- a/server/services/llm/providers/openrouter.py+++ b/server/services/llm/providers/openrouter.py@@ -6,7 +6,10 @@ from typing import Any, Dict, List, Optionalfrom core.logging import get_loggerfrom services.llm.protocol import (- LLMResponse, Message, ThinkingConfig, ToolDef,+ LLMResponse,+ Message,+ ThinkingConfig,+ ToolDef,)from services.llm.providers.openai import OpenAIProvider@@ -18,6 +21,7 @@ class OpenRouterProvider(OpenAIProvider):def __init__(self, api_key: str, *, proxy_url: Optional[str] = None):import openai+kwargs: Dict[str, Any] = {"api_key": api_key,"base_url": proxy_url or "https://openrouter.ai/api/v1",@@ -51,6 +55,7 @@ class OpenRouterProvider(OpenAIProvider):async def fetch_models(self, api_key: str) -> List[str]:import httpx+async with httpx.AsyncClient() as client:r = await client.get("https://openrouter.ai/api/v1/models",diff --git a/server/services/markdown_formatter.py b/server/services/markdown_formatter.pyindex f34f6a36..be946f5f 100644--- a/server/services/markdown_formatter.py+++ b/server/services/markdown_formatter.py@@ -215,8 +215,7 @@ def _walk_tokens(tokens: list, result: list, depth: int = 0) -> None:if table_row:table_rows.append(table_row)table_row = []- elif ttype in ("thead_open", "thead_close", "tbody_open", "tbody_close",- "th_open", "th_close", "td_open", "td_close"):+ elif ttype in ("thead_open", "thead_close", "tbody_open", "tbody_close", "th_open", "th_close", "td_open", "td_close"):pass # Handled via tr_open/close and inline collectionelif ttype == "html_block" or ttype == "html_inline":result.append(token.content)diff --git a/server/services/memory/jsonl.py b/server/services/memory/jsonl.pyindex 683a17a2..fc57663f 100644--- a/server/services/memory/jsonl.py+++ b/server/services/memory/jsonl.py@@ -51,7 +51,10 @@ def parse_jsonl(text: str) -> List[BaseMessage]:def append_message(- text: str, role: str, content: str, **metadata: Any,+ text: str,+ role: str,+ content: str,+ **metadata: Any,) -> str:"""Append one Anthropic Messages-format line to a JSONL string.@@ -59,7 +62,8 @@ def append_message(a trailing newline so successive appends concatenate cleanly."""line = json.dumps(- {"role": role, "content": content, **metadata}, ensure_ascii=False,+ {"role": role, "content": content, **metadata},+ ensure_ascii=False,)if text and not text.endswith("\n"):text = text + "\n"diff --git a/server/services/memory/markdown.py b/server/services/memory/markdown.pyindex 54a8c1ee..2d0b6d46 100644--- a/server/services/memory/markdown.py+++ b/server/services/memory/markdown.py@@ -25,7 +25,7 @@ def parse_memory_markdown(content: str) -> List[BaseMessage]:response content"""messages: List[BaseMessage] = []- pattern = r'### \*\*(Human|Assistant)\*\*[^\n]*\n(.*?)(?=\n### \*\*|$)'+ pattern = r"### \*\*(Human|Assistant)\*\*[^\n]*\n(.*?)(?=\n### \*\*|$)"for role, text in re.findall(pattern, content, re.DOTALL):text = text.strip()if text:@@ -47,14 +47,14 @@ def trim_markdown_window(content: str, window_size: int) -> tuple:"""Keep the last ``window_size`` message PAIRS; return``(trimmed_content, removed_texts)``. Removed texts are returnedso callers can hand them to the long-term vector store."""- pattern = r'(### \*\*(Human|Assistant)\*\*[^\n]*\n.*?)(?=\n### \*\*|$)'+ pattern = r"(### \*\*(Human|Assistant)\*\*[^\n]*\n.*?)(?=\n### \*\*|$)"blocks = [m[0] for m in re.findall(pattern, content, re.DOTALL)]if len(blocks) <= window_size * 2:return content, []- keep = blocks[-(window_size * 2):]- removed = blocks[:-(window_size * 2)]+ keep = blocks[-(window_size * 2) :]+ removed = blocks[: -(window_size * 2)]removed_texts: List[str] = []for block in removed:diff --git a/server/services/memory/state.py b/server/services/memory/state.pyindex e05bc280..ab2252cb 100644--- a/server/services/memory/state.py+++ b/server/services/memory/state.py@@ -93,15 +93,16 @@ async def clear_agent_session_state(await db.save_node_parameters(memory_node_id, params)cleared_memory_node = Truelogger.info(- "[Memory] Cleared simpleMemory node fields memory_node=%s "- "(memory_content reset + last_session_id wiped)",+ "[Memory] Cleared simpleMemory node fields memory_node=%s " "(memory_content reset + last_session_id wiped)",memory_node_id,)logger.info(- "[Memory] Cleared agent session state session=%s workflow_id=%s "- "vector_store=%s todo_keys=%s memory_node=%s",- session_id, workflow_id, cleared_vector_store, cleared_todo_keys,+ "[Memory] Cleared agent session state session=%s workflow_id=%s " "vector_store=%s todo_keys=%s memory_node=%s",+ session_id,+ workflow_id,+ cleared_vector_store,+ cleared_todo_keys,cleared_memory_node,)diff --git a/server/services/memory_store.py b/server/services/memory_store.pyindex e2f78c5c..7ef66cf8 100644--- a/server/services/memory_store.py+++ b/server/services/memory_store.py@@ -3,6 +3,7 @@Uses standard Python data structures with LangChain message compatibility.No deprecated APIs - follows LangChain 0.3+ recommendations."""+from typing import Dict, List, Optionalfrom dataclasses import dataclass, fieldfrom datetime import datetime@@ -14,6 +15,7 @@ logger = logging.getLogger(__name__)@dataclassclass Message:"""Single conversation message."""+role: str # 'human' or 'ai'content: strtimestamp: str = field(default_factory=lambda: datetime.now().isoformat())@@ -22,6 +24,7 @@ class Message:@dataclassclass ConversationSession:"""Conversation session with message history."""+session_id: strmessages: List[Message] = field(default_factory=list)created_at: str = field(default_factory=lambda: datetime.now().isoformat())@@ -76,14 +79,7 @@ def delete_session(session_id: str) -> bool:def get_all_sessions() -> List[Dict]:"""Get info about all sessions."""- return [- {- "session_id": s.session_id,- "message_count": len(s.messages),- "created_at": s.created_at- }- for s in _sessions.values()- ]+ return [{"session_id": s.session_id, "message_count": len(s.messages), "created_at": s.created_at} for s in _sessions.values()]def get_langchain_messages(session_id: str, window_size: Optional[int] = None):@@ -96,8 +92,8 @@ def get_langchain_messages(session_id: str, window_size: Optional[int] = None):messages = get_messages(session_id, window_size)lc_messages = []for m in messages:- if m['role'] == 'human':- lc_messages.append(HumanMessage(content=m['content']))- elif m['role'] == 'ai':- lc_messages.append(AIMessage(content=m['content']))+ if m["role"] == "human":+ lc_messages.append(HumanMessage(content=m["content"]))+ elif m["role"] == "ai":+ lc_messages.append(AIMessage(content=m["content"]))return lc_messagesdiff --git a/server/services/model_registry.py b/server/services/model_registry.pyindex 958fbbc7..6b841f88 100644--- a/server/services/model_registry.py+++ b/server/services/model_registry.py@@ -34,9 +34,7 @@ PROVIDER_MAP = {}# Known reasoning models (always temperature=1, no user override)-REASONING_MODEL_PATTERNS = re.compile(- r"^(o1|o3|o4|o3-mini|o4-mini)(-|$)", re.IGNORECASE-)+REASONING_MODEL_PATTERNS = re.compile(r"^(o1|o3|o4|o3-mini|o4-mini)(-|$)", re.IGNORECASE)# Known thinking model patterns -> thinking_typeTHINKING_PATTERNS: List[Tuple[str, str, str]] = [@@ -44,7 +42,7 @@ THINKING_PATTERNS: List[Tuple[str, str, str]] = [("anthropic", r"claude-(opus|sonnet|haiku)-(4|5|6)", "budget"),("anthropic", r"claude-3[\.\-]5", "budget"),("openai", r"^(o1|o3|o4)", "effort"),- ("openai", r"^gpt-5", "effort"), # GPT-5 hybrid reasoning+ ("openai", r"^gpt-5", "effort"), # GPT-5 hybrid reasoning("gemini", r"gemini-(2\.5|3)", "budget"),("groq", r"qwen3", "format"),("cerebras", r"qwen", "budget"),@@ -68,19 +66,21 @@ DEFAULT_TEMP_RANGES = {# DATA STRUCTURES# =============================================================================+@dataclassclass ModelInfo:"""Comprehensive model metadata."""- id: str # "openai/gpt-5.2"- name: str # "OpenAI: GPT-5.2"- provider: str # "openai" (MachinaOs-normalized)- local_id: str # "gpt-5.2"++ id: str # "openai/gpt-5.2"+ name: str # "OpenAI: GPT-5.2"+ provider: str # "openai" (MachinaOs-normalized)+ local_id: str # "gpt-5.2"context_length: int = 128000max_output_tokens: int = 4096input_price_per_mtok: float = 0.0output_price_per_mtok: float = 0.0supports_thinking: bool = False- thinking_type: str = "none" # "budget" | "effort" | "format" | "none"+ thinking_type: str = "none" # "budget" | "effort" | "format" | "none"temperature_range: tuple = (0.0, 2.0)is_reasoning_model: bool = Falsesupported_parameters: list = field(default_factory=list)@@ -104,6 +104,7 @@ class ModelInfo:# SERVICE# =============================================================================+class ModelRegistryService:"""Centralized model parameter management.@@ -113,7 +114,7 @@ class ModelRegistryService:"""def __init__(self):- self._models: Dict[str, ModelInfo] = {} # keyed by "provider/local_id"+ self._models: Dict[str, ModelInfo] = {} # keyed by "provider/local_id"self._cache_timestamp: Optional[datetime] = Noneself._llm_defaults: Dict[str, Any] = {}@@ -184,11 +185,11 @@ class ModelRegistryService:"""variants = [model]# digit-hyphen-digit -> digit.digit (e.g., claude-sonnet-4-6 -> claude-sonnet-4.6)- dot_variant = re.sub(r'(\d)-(\d)', r'\1.\2', model)+ dot_variant = re.sub(r"(\d)-(\d)", r"\1.\2", model)if dot_variant != model:variants.append(dot_variant)# digit.digit -> digit-digit (e.g., claude-sonnet-4.6 -> claude-sonnet-4-6)- hyphen_variant = re.sub(r'(\d)\.(\d)', r'\1-\2', model)+ hyphen_variant = re.sub(r"(\d)\.(\d)", r"\1-\2", model)if hyphen_variant != model:variants.append(hyphen_variant)return variants@@ -301,15 +302,18 @@ class ModelRegistryService:self._models[f"{provider}/{model_id}"] = infologger.info("[%s] registered model %s (ctx=%s, max_out=%s, tools=%s, vision=%s)",- provider, model_id, ctx, max_out,- params.get("supports_tools", False), params.get("vision", False),+ provider,+ model_id,+ ctx,+ max_out,+ params.get("supports_tools", False),+ params.get("vision", False),)# Persist so the entry survives process restart.try:self._save_cache()except Exception as e: # noqa: BLE001 — best-effort persistence- logger.warning("Failed to persist local model entry %s/%s: %s",- provider, model_id, e)+ logger.warning("Failed to persist local model entry %s/%s: %s", provider, model_id, e)def get_max_output_tokens(self, model: str, provider: str) -> int:"""Get max output tokens: registry -> llm_defaults -> 4096."""@@ -531,9 +535,7 @@ class ModelRegistryService:"_generated": self._cache_timestamp.isoformat() if self._cache_timestamp else None,"_source": "openrouter","_model_count": len(self._models),- "models": {- key: info.to_dict() for key, info in self._models.items()- }+ "models": {key: info.to_dict() for key, info in self._models.items()},}CACHE_FILE.parent.mkdir(parents=True, exist_ok=True)diff --git a/server/services/node_executor.py b/server/services/node_executor.pyindex c8e06b9d..316fd4db 100644--- a/server/services/node_executor.py+++ b/server/services/node_executor.py@@ -40,6 +40,7 @@ logger = get_logger(__name__)@dataclassclass ExecutionResult:"""Standardized execution result."""+success: boolnode_id: strnode_type: str@@ -98,6 +99,7 @@ class NodeExecutor:is needed here."""from services.node_registry import _HANDLER_REGISTRY as _PLUGIN_HANDLERS+registry = {# Workflow control# start / cronScheduler / timer — migrated to nodes/{workflow,scheduler}/*.py (Wave 11.C).@@ -133,17 +135,19 @@ class NodeExecutor:) -> Dict[str, Any]:"""Execute a single workflow node."""start_time = time.time()- session_id = context.get('session_id', 'default')- execution_id = context.get('execution_id') or str(uuid.uuid4())[:8]+ session_id = context.get("session_id", "default")+ execution_id = context.get("execution_id") or str(uuid.uuid4())[:8]try:# Load, validate, enhance parametersparams = await self._prepare_parameters(node_id, node_type, parameters, session_id)# Resolve templates if resolver provided- nodes = context.get('nodes')- edges = context.get('edges')- logger.debug(f"[NodeExecutor] Template resolution check: resolve_fn={resolve_params_fn is not None}, nodes={len(nodes) if nodes else 'None'}, edges={len(edges) if edges else 'None'}")+ nodes = context.get("nodes")+ edges = context.get("edges")+ logger.debug(+ f"[NodeExecutor] Template resolution check: resolve_fn={resolve_params_fn is not None}, nodes={len(nodes) if nodes else 'None'}, edges={len(edges) if edges else 'None'}"+ )if resolve_params_fn and nodes is not None and edges is not None:logger.debug(f"[NodeExecutor] Before resolution: params={list(params.keys())}")@@ -156,21 +160,21 @@ class NodeExecutor:"start_time": start_time,"execution_id": execution_id,}- logger.info("NodeExecutor context", node_id=node_id, workflow_id=context.get('workflow_id'))+ logger.info("NodeExecutor context", node_id=node_id, workflow_id=context.get("workflow_id"))# Execute via registry or special handlersresult = await self._dispatch(node_id, node_type, params, handler_ctx)- result['execution_id'] = execution_id+ result["execution_id"] = execution_id# Store output if successful- if result.get('success') and self._output_store:- output_data = result.get('result', {})+ if result.get("success") and self._output_store:+ output_data = result.get("result", {})# For Android service nodes, extract the nested 'data' field for cleaner template access# This allows {{batterymonitor.battery_level}} instead of {{batterymonitor.data.battery_level}}if node_type in ANDROID_SERVICE_NODE_TYPES and isinstance(output_data, dict):# Flatten: promote 'data' contents to top level while preserving metadata- nested_data = output_data.get('data', {})+ nested_data = output_data.get("data", {})if isinstance(nested_data, dict):# Merge nested data with metadata (service_id, action, timestamp, etc.)output_data = {**output_data, **nested_data}@@ -181,11 +185,11 @@ class NodeExecutor:# - output_media: Media data# - output_contact: Sender/contact info# - output_metadata: Message metadata- if node_type == 'socialReceive' and isinstance(output_data, dict):- await self._output_store(session_id, node_id, "output_message", output_data.get('message', ''))- await self._output_store(session_id, node_id, "output_media", output_data.get('media', {}))- await self._output_store(session_id, node_id, "output_contact", output_data.get('contact', {}))- await self._output_store(session_id, node_id, "output_metadata", output_data.get('metadata', {}))+ if node_type == "socialReceive" and isinstance(output_data, dict):+ await self._output_store(session_id, node_id, "output_message", output_data.get("message", ""))+ await self._output_store(session_id, node_id, "output_media", output_data.get("media", {}))+ await self._output_store(session_id, node_id, "output_contact", output_data.get("contact", {}))+ await self._output_store(session_id, node_id, "output_metadata", output_data.get("metadata", {}))# Store with multiple keys for different handle IDs used by frontend components:# - output_main: SquareNode, GenericNode, TriggerNode, StartNode@@ -198,12 +202,14 @@ class NodeExecutor:return resultexcept asyncio.CancelledError:- return ExecutionResult(False, node_id, node_type, error="Cancelled",- execution_id=execution_id, execution_time=time.time()-start_time).to_dict()+ return ExecutionResult(+ False, node_id, node_type, error="Cancelled", execution_id=execution_id, execution_time=time.time() - start_time+ ).to_dict()except Exception as e:logger.error("Node execution error", node_id=node_id, error=str(e))- return ExecutionResult(False, node_id, node_type, error=str(e),- execution_id=execution_id, execution_time=time.time()-start_time).to_dict()+ return ExecutionResult(+ False, node_id, node_type, error=str(e), execution_id=execution_id, execution_time=time.time() - start_time+ ).to_dict()async def _prepare_parameters(self, node_id: str, node_type: str, params: Dict, session_id: str) -> Dict:"""Load from DB, validate, inject API keys."""@@ -230,23 +236,23 @@ class NodeExecutor:if node_type in AI_MODEL_TYPES:provider = detect_ai_provider(node_type, params)- if not result.get('api_key'):+ if not result.get("api_key"):key = await self.ai_service.auth.get_api_key(provider, "default")if key:- result['api_key'] = key- if not result.get('model'):+ result["api_key"] = key+ if not result.get("model"):models = await self.ai_service.auth.get_stored_models(provider, "default")if models:- result['model'] = models[0]+ result["model"] = models[0]elif node_type in GOOGLE_MAPS_TYPES:- if not result.get('api_key'):+ if not result.get("api_key"):# Try database first, then fall back to environment variablekey = await self.ai_service.auth.get_api_key("google_maps", "default")if key:- result['api_key'] = key+ result["api_key"] = keyelif self.settings.google_maps_api_key:- result['api_key'] = self.settings.google_maps_api_key+ result["api_key"] = self.settings.google_maps_api_keyreturn result@@ -254,10 +260,16 @@ class NodeExecutor:# Computed once so plugin handlers (registered via @register_node)# can read context['connected_outputs'] / context['source_nodes']# without re-implementing the graph walk.- _NEEDS_CONNECTED_OUTPUTS = frozenset({- 'pythonExecutor', 'javascriptExecutor', 'typescriptExecutor',- 'webhookResponse', 'console', 'socialReceive',- })+ _NEEDS_CONNECTED_OUTPUTS = frozenset(+ {+ "pythonExecutor",+ "javascriptExecutor",+ "typescriptExecutor",+ "webhookResponse",+ "console",+ "socialReceive",+ }+ )async def _dispatch(self, node_id: str, node_type: str, params: Dict, context: Dict) -> Dict:"""Dispatch to handler from registry or special handlers."""@@ -266,7 +278,7 @@ class NodeExecutor:# Both plugin handlers and legacy handlers can read these keys.if node_type in self._NEEDS_CONNECTED_OUTPUTS:outputs, source_nodes = await self._get_connected_outputs_with_info(context, node_id)- context = {**context, 'connected_outputs': outputs, 'source_nodes': source_nodes}+ context = {**context, "connected_outputs": outputs, "source_nodes": source_nodes}# Check registry first (plugin handlers win — they were merged in# via _build_handler_registry's registry.update(_PLUGIN_HANDLERS)).@@ -284,29 +296,29 @@ class NodeExecutor:"node_id": node_id,"node_type": node_type,"result": {"message": f"Node {node_id} executed", "parameters": params},- "execution_time": time.time() - context.get('start_time', time.time()),- "timestamp": datetime.now().isoformat()+ "execution_time": time.time() - context.get("start_time", time.time()),+ "timestamp": datetime.now().isoformat(),}async def _get_connected_outputs(self, context: Dict, node_id: str) -> Dict[str, Any]:"""Get outputs from connected upstream nodes with handle-aware routing."""- get_output = context.get('get_output_fn')+ get_output = context.get("get_output_fn")if not get_output:return {}- nodes = context.get('nodes', [])- edges = context.get('edges', [])- session_id = context.get('session_id', 'default')+ nodes = context.get("nodes", [])+ edges = context.get("edges", [])+ session_id = context.get("session_id", "default")result = {}for edge in edges:- if edge.get('target') == node_id:- source_id = edge.get('source')- source_handle = edge.get('sourceHandle')+ if edge.get("target") == node_id:+ source_id = edge.get("source")+ source_handle = edge.get("sourceHandle")# Map sourceHandle to output key- if source_handle and source_handle.startswith('output-'):- handle_name = source_handle.replace('output-', '')+ if source_handle and source_handle.startswith("output-"):+ handle_name = source_handle.replace("output-", "")output_key = f"output_{handle_name}"else:output_key = "output_0"@@ -318,8 +330,8 @@ class NodeExecutor:output = await get_output(session_id, source_id, "output_0")if output:- source = next((n for n in nodes if n.get('id') == source_id), {})- result[source.get('type', 'unknown')] = output+ source = next((n for n in nodes if n.get("id") == source_id), {})+ result[source.get("type", "unknown")] = outputreturn result@@ -329,22 +341,18 @@ class NodeExecutor:This is used for display purposes (e.g., showing source in Console panel).Does NOT filter by output availability - just returns edge source info."""- nodes = context.get('nodes', [])- edges = context.get('edges', [])+ nodes = context.get("nodes", [])+ edges = context.get("edges", [])source_nodes = []for edge in edges:- if edge.get('target') == node_id:- source_id = edge.get('source')- source = next((n for n in nodes if n.get('id') == source_id), {})- source_type = source.get('type', 'unknown')- source_data = source.get('data', {})- source_label = source_data.get('label') or source_type- source_nodes.append({- 'id': source_id,- 'type': source_type,- 'label': source_label- })+ if edge.get("target") == node_id:+ source_id = edge.get("source")+ source = next((n for n in nodes if n.get("id") == source_id), {})+ source_type = source.get("type", "unknown")+ source_data = source.get("data", {})+ source_label = source_data.get("label") or source_type+ source_nodes.append({"id": source_id, "type": source_type, "label": source_label})return source_nodes@@ -354,34 +362,38 @@ class NodeExecutor:Returns:Tuple of (outputs dict, source_nodes list with id/type/label info)"""- get_output = context.get('get_output_fn')+ get_output = context.get("get_output_fn")if not get_output:logger.warning(f"[_get_connected_outputs_with_info] No get_output_fn in context for {node_id}")return {}, []- nodes = context.get('nodes', [])- edges = context.get('edges', [])- session_id = context.get('session_id', 'default')+ nodes = context.get("nodes", [])+ edges = context.get("edges", [])+ session_id = context.get("session_id", "default")outputs = {}source_nodes = []logger.debug(f"[_get_connected_outputs_with_info] node_id={node_id}, edges={len(edges)}, session={session_id}")for edge in edges:- logger.debug(f"[_get_connected_outputs_with_info] Checking edge: source={edge.get('source')}, target={edge.get('target')}, sourceHandle={edge.get('sourceHandle')}, targetHandle={edge.get('targetHandle')}")- if edge.get('target') == node_id:- source_id = edge.get('source')- source_handle = edge.get('sourceHandle')+ logger.debug(+ f"[_get_connected_outputs_with_info] Checking edge: source={edge.get('source')}, target={edge.get('target')}, sourceHandle={edge.get('sourceHandle')}, targetHandle={edge.get('targetHandle')}"+ )+ if edge.get("target") == node_id:+ source_id = edge.get("source")+ source_handle = edge.get("sourceHandle")# Map sourceHandle to output key# Frontend uses "output-<name>", backend stores as "output_<name>"- if source_handle and source_handle.startswith('output-'):- handle_name = source_handle.replace('output-', '')+ if source_handle and source_handle.startswith("output-"):+ handle_name = source_handle.replace("output-", "")output_key = f"output_{handle_name}"else:output_key = "output_0"- logger.debug(f"[_get_connected_outputs_with_info] Found edge from {source_id} to {node_id}, sourceHandle={source_handle}, using output_key={output_key}")+ logger.debug(+ f"[_get_connected_outputs_with_info] Found edge from {source_id} to {node_id}, sourceHandle={source_handle}, using output_key={output_key}"+ )output = await get_output(session_id, source_id, output_key)logger.debug(f"[_get_connected_outputs_with_info] First lookup (key={output_key}): {'FOUND' if output else 'NOT_FOUND'}")@@ -393,17 +405,13 @@ class NodeExecutor:logger.debug(f"[_get_connected_outputs_with_info] Final output from {source_id}: {'FOUND' if output else 'NOT FOUND'}")if output:- source = next((n for n in nodes if n.get('id') == source_id), {})- source_type = source.get('type', 'unknown')+ source = next((n for n in nodes if n.get("id") == source_id), {})+ source_type = source.get("type", "unknown")outputs[source_type] = output# Get label from node data if available- source_data = source.get('data', {})- source_label = source_data.get('label') or source_type- source_nodes.append({- 'id': source_id,- 'type': source_type,- 'label': source_label- })+ source_data = source.get("data", {})+ source_label = source_data.get("label") or source_type+ source_nodes.append({"id": source_id, "type": source_type, "label": source_label})logger.debug(f"[_get_connected_outputs_with_info] Returning {len(outputs)} outputs, {len(source_nodes)} source_nodes")return outputs, source_nodesdiff --git a/server/services/node_output_schemas.py b/server/services/node_output_schemas.pyindex 48068275..2ce9b81d 100644--- a/server/services/node_output_schemas.py+++ b/server/services/node_output_schemas.py@@ -876,12 +876,10 @@ def _bust_schema_cache(node_type: str, _model_class: type[BaseModel]) -> None:# Backed by the module-level NODE_OUTPUT_SCHEMAS dict so existing# readers (e.g. get_output_schema, list_node_types_with_schema, tests)# keep working.-_OUTPUT_SCHEMA_REGISTRY: _IdempotentRegistry[str, type[BaseModel]] = (- _IdempotentRegistry(- "output_schema",- items=NODE_OUTPUT_SCHEMAS,- on_register=_bust_schema_cache,- )+_OUTPUT_SCHEMA_REGISTRY: _IdempotentRegistry[str, type[BaseModel]] = _IdempotentRegistry(+ "output_schema",+ items=NODE_OUTPUT_SCHEMAS,+ on_register=_bust_schema_cache,)diff --git a/server/services/node_registry.py b/server/services/node_registry.pyindex e3827b29..c44d61ee 100644--- a/server/services/node_registry.py+++ b/server/services/node_registry.py@@ -73,8 +73,10 @@ def register_node(# is the whole point of the strangler-fig migration, so caches must# re-compute.from services.node_spec import _spec_cache # local import to avoid cycle+_spec_cache.pop(type, None)from services.node_input_schemas import _schema_cache # local import+_schema_cache.pop(type, None)@@ -148,10 +150,7 @@ def iter_tool_node_classes():ui_hints = getattr(node_cls, "ui_hints", {}) or {}if ui_hints.get("isMasterSkillEditor") is True:continue- if (- component_kind in ("tool", "agent")- or getattr(node_cls, "usable_as_tool", False)- ):+ if component_kind in ("tool", "agent") or getattr(node_cls, "usable_as_tool", False):yield node_type, node_clsdiff --git a/server/services/node_spec.py b/server/services/node_spec.pyindex cbdb0d5f..4e9e31ae 100644--- a/server/services/node_spec.py+++ b/server/services/node_spec.py@@ -84,8 +84,7 @@ def get_node_spec(node_type: str) -> Optional[dict[str, Any]]:# Wave 10.A — full visual contract. Only emit fields when seeded so the# wire format stays compact and unseeded types keep the pre-10 shape.- for key in ("color", "componentKind", "handles", "credentials",- "hideOutputHandle", "hideInputHandle", "visibility"):+ for key in ("color", "componentKind", "handles", "credentials", "hideOutputHandle", "hideInputHandle", "visibility"):if key in meta:spec[key] = meta[key]@@ -101,11 +100,8 @@ def list_node_types_with_spec() -> list[str]:but no Pydantic schemas)."""from models.node_metadata import NODE_METADATA- return sorted(- set(NODE_INPUT_MODELS.keys())- | set(NODE_OUTPUT_SCHEMAS.keys())- | set(NODE_METADATA.keys())- )++ return sorted(set(NODE_INPUT_MODELS.keys()) | set(NODE_OUTPUT_SCHEMAS.keys()) | set(NODE_METADATA.keys()))def node_spec_revision() -> str:diff --git a/server/services/nodejs_client.py b/server/services/nodejs_client.pyindex c2ffb484..a31c0b1e 100644--- a/server/services/nodejs_client.py+++ b/server/services/nodejs_client.py@@ -17,7 +17,7 @@ class NodeJSClient:base_url: Base URL of Node.js server (e.g., http://127.0.0.1:3020)timeout: Default request timeout in seconds"""- self._base_url = base_url.rstrip('/')+ self._base_url = base_url.rstrip("/")self._timeout = aiohttp.ClientTimeout(total=timeout)async def health_check(self) -> Dict[str, Any]:@@ -31,11 +31,7 @@ class NodeJSClient:return await response.json()async def execute(- self,- code: str,- input_data: Optional[Dict[str, Any]] = None,- timeout: Optional[int] = None,- language: str = "javascript"+ self, code: str, input_data: Optional[Dict[str, Any]] = None, timeout: Optional[int] = None, language: str = "javascript") -> Dict[str, Any]:"""Execute JavaScript/TypeScript code.@@ -57,10 +53,7 @@ class NodeJSClient:payload["timeout"] = timeoutasync with aiohttp.ClientSession(timeout=self._timeout) as session:- async with session.post(- f"{self._base_url}/execute",- json=payload- ) as response:+ async with session.post(f"{self._base_url}/execute", json=payload) as response:return await response.json()async def install_packages(self, packages: List[str]) -> Dict[str, Any]:@@ -73,10 +66,7 @@ class NodeJSClient:Result with success and message"""async with aiohttp.ClientSession(timeout=self._timeout) as session:- async with session.post(- f"{self._base_url}/packages/install",- json={"packages": packages}- ) as response:+ async with session.post(f"{self._base_url}/packages/install", json={"packages": packages}) as response:return await response.json()async def list_packages(self) -> Dict[str, Any]:diff --git a/server/services/parameter_resolver.py b/server/services/parameter_resolver.pyindex 8f1e1f58..64f3e03f 100644--- a/server/services/parameter_resolver.py+++ b/server/services/parameter_resolver.py@@ -14,7 +14,7 @@ if TYPE_CHECKING:logger = get_logger(__name__)# Compiled regex for template matching-TEMPLATE_PATTERN = re.compile(r'\{\{([^}]+)\}\}')+TEMPLATE_PATTERN = re.compile(r"\{\{([^}]+)\}\}")class ParameterResolver:@@ -31,12 +31,7 @@ class ParameterResolver:self.get_output = get_output_fnasync def resolve(- self,- parameters: Dict[str, Any],- node_id: str,- nodes: List[Dict],- edges: List[Dict],- session_id: str+ self, parameters: Dict[str, Any], node_id: str, nodes: List[Dict], edges: List[Dict], session_id: str) -> Dict[str, Any]:"""Resolve all template variables in parameters."""# Build connected data map from upstream nodes@@ -45,13 +40,7 @@ class ParameterResolver:# Resolve templatesreturn self._resolve_templates(parameters, connected_data)- async def _gather_connected_outputs(- self,- node_id: str,- nodes: List[Dict],- edges: List[Dict],- session_id: str- ) -> Dict[str, Any]:+ async def _gather_connected_outputs(self, node_id: str, nodes: List[Dict], edges: List[Dict], session_id: str) -> Dict[str, Any]:"""Gather outputs from all nodes in the workflow that have executed.n8n pattern: Template variables can reference ANY node's output in the workflow,@@ -66,26 +55,30 @@ class ParameterResolver:# Gather outputs from ALL nodes (not just directly connected)# This allows {{nodeName.field}} to reference any previously executed nodefor source_node in nodes:- source_id = source_node.get('id')+ source_id = source_node.get("id")if source_id == node_id:continue # Skip self- node_type = source_node.get('type', '')- node_label = source_node.get('data', {}).get('label', 'NO_LABEL')+ node_type = source_node.get("type", "")+ node_label = source_node.get("data", {}).get("label", "NO_LABEL")node_key = self._get_template_key(source_node)logger.debug(f"[ParameterResolver] Processing node: id={source_id}, type={node_type}, label={node_label}, key={node_key}")# Special handling for start nodes- if node_type == 'start':+ if node_type == "start":data = await self._get_start_node_data(source_id)else:data = await self.get_output(session_id, source_id, "output_0")- logger.debug(f"[ParameterResolver] Output lookup: session={session_id}, node={source_id}, result={'FOUND' if data else 'NOT_FOUND'}")+ logger.debug(+ f"[ParameterResolver] Output lookup: session={session_id}, node={source_id}, result={'FOUND' if data else 'NOT_FOUND'}"+ )if data:connected[node_key] = data- logger.debug(f"[ParameterResolver] Stored output for key '{node_key}' (type={node_type}): keys={list(data.keys()) if isinstance(data, dict) else type(data)}")+ logger.debug(+ f"[ParameterResolver] Stored output for key '{node_key}' (type={node_type}): keys={list(data.keys()) if isinstance(data, dict) else type(data)}"+ )logger.debug(f"[ParameterResolver] Available data keys for resolution: {list(connected.keys())}")return connected@@ -93,11 +86,12 @@ class ParameterResolver:async def _get_start_node_data(self, node_id: str) -> Optional[Dict]:"""Get initial data from start node parameters."""import json+params = await self.database.get_node_parameters(node_id)- if not params or 'initial_data' not in params:+ if not params or "initial_data" not in params:return {}- initial_data = params.get('initial_data', '{}')+ initial_data = params.get("initial_data", "{}")try:return json.loads(initial_data) if isinstance(initial_data, str) else initial_dataexcept Exception:@@ -113,22 +107,22 @@ class ParameterResolver:4. node.id (fallback)"""# Priority 1: User-defined label- label = node.get('data', {}).get('label')+ label = node.get("data", {}).get("label")if label:- return re.sub(r'\s+', '', label.lower())+ return re.sub(r"\s+", "", label.lower())# Priority 2: displayName from node definition (passed in node.data)- display_name = node.get('data', {}).get('displayName')+ display_name = node.get("data", {}).get("displayName")if display_name:- return re.sub(r'\s+', '', display_name.lower())+ return re.sub(r"\s+", "", display_name.lower())# Priority 3: node type- node_type = node.get('type', '')+ node_type = node.get("type", "")if node_type:return node_type.lower()# Priority 4: node id- return node.get('id', 'unknown').lower()+ return node.get("id", "unknown").lower()def _resolve_templates(self, parameters: Dict[str, Any], connected_data: Dict[str, Any]) -> Dict[str, Any]:"""Resolve {{variable}} templates in parameters recursively."""@@ -142,9 +136,7 @@ class ParameterResolver:# resolution with AttributeError (bubbled up as a node execution# failure), which is how any node with a dynamic parameter# started returning null-ish envelopes.- template_params = {- k: v for k, v in parameters.items() if isinstance(v, str) and '{{' in v- }+ template_params = {k: v for k, v in parameters.items() if isinstance(v, str) and "{{" in v}if template_params:logger.debug("[ParameterResolver] Resolving templates",@@ -152,7 +144,7 @@ class ParameterResolver:)def resolve(value: Any) -> Any:- if isinstance(value, str) and '{{' in value:+ if isinstance(value, str) and "{{" in value:return self._resolve_string(value, data_lower)if isinstance(value, dict):return {k: resolve(v) for k, v in value.items()}@@ -168,14 +160,16 @@ class ParameterResolver:for match in TEMPLATE_PATTERN.finditer(value):full_match = match.group(0)- path = match.group(1).split('.')+ path = match.group(1).split(".")node_name = path[0].lower()property_path = path[1:]node_data = data.get(node_name)resolved_value = self._navigate_path(node_data, property_path)- logger.debug(f"[ParameterResolver] Resolving '{full_match}': node_name={node_name}, path={property_path}, found_data={node_data is not None}, resolved={resolved_value is not None}")+ logger.debug(+ f"[ParameterResolver] Resolving '{full_match}': node_name={node_name}, path={property_path}, found_data={node_data is not None}, resolved={resolved_value is not None}"+ )if resolved_value is not None:# If entire value is just the template, preserve type@@ -185,7 +179,7 @@ class ParameterResolver:else:# Log missing resolution for debugginglogger.debug(f"[ParameterResolver] Could not resolve '{full_match}': available keys={list(data.keys())}")- result = result.replace(full_match, '')+ result = result.replace(full_match, "")return result@@ -203,7 +197,7 @@ class ParameterResolver:return None# Check for array index notation: field[index]- bracket_match = re.match(r'^(\w+)\[(\d+)\]$', part)+ bracket_match = re.match(r"^(\w+)\[(\d+)\]$", part)if bracket_match:field_name = bracket_match.group(1)index = int(bracket_match.group(2))diff --git a/server/services/plugin/base.py b/server/services/plugin/base.pyindex b8cbc19a..2dabe63d 100644--- a/server/services/plugin/base.py+++ b/server/services/plugin/base.py@@ -187,9 +187,7 @@ class BaseNode:# the canvas.# Subclasses opt out by explicitly setting either flag to False# on the class.- is_tool_oriented = (- cls.usable_as_tool or cls.component_kind == "tool"- )+ is_tool_oriented = cls.usable_as_tool or cls.component_kind == "tool"if is_tool_oriented:if "hide_input_handle" not in cls.__dict__:cls.hide_input_handle = True@@ -221,6 +219,7 @@ class BaseNode:# to visuals.json — defeating the per-plugin icon.svg endpoint# (RFC §6.5 / Phase 6).from services.node_registry import register_node, register_node_class+register_node_class(cls)register_node(type=cls.type,@@ -297,6 +296,7 @@ class BaseNode:(redundant — class is already the dispatch target) and routethrough :meth:`execute`."""+async def _legacy(node_id: str,node_type: str,@@ -311,7 +311,8 @@ class BaseNode:connection_factory=_make_connection_factory(cls, context),)return await instance.execute(node_id, parameters, ctx)- _legacy.__node_class__ = cls # type: ignore[attr-defined]++ _legacy.__node_class__ = cls # type: ignore[attr-defined]_legacy.__qualname__ = f"{cls.__qualname__}._legacy_handler"return _legacy@@ -431,6 +432,7 @@ class BaseNode:if provider:try:from services.status_broadcaster import get_status_broadcaster+broadcaster = get_status_broadcaster()await broadcaster.broadcast_credential_event(event_type=f"credential.{auth_kind}.runtime_failed",@@ -444,7 +446,9 @@ class BaseNode:# Broadcast failure must never mask the original error.logger.debug("[%s] failed to broadcast credential runtime failure for %s",- self.type, provider, exc_info=True,+ self.type,+ provider,+ exc_info=True,)extra: Optional[Dict[str, Any]] = Noneif provider:@@ -467,9 +471,7 @@ class BaseNode:# LLM gets the message in the structured response and can# retry with corrected input.logger.warning("[%s] %s op %s: %s", self.type, op_name, type(e).__name__, e)- return self._wrap_error(- start_time=start_time, error=str(e), error_type="NodeUserError"- )+ return self._wrap_error(start_time=start_time, error=str(e), error_type="NodeUserError")except Exception as e:logger.exception("[%s] operation %s failed", self.type, op_name)return self._wrap_error(start_time=start_time, error=str(e), error_type=type(e).__name__)@@ -538,14 +540,15 @@ class BaseNode:# is expected to be empty.if not self.credentials:raise RuntimeError(- f"Node {self.type} op {spec.name} has routing but no "- "credentials declared — routing needs a Connection."+ f"Node {self.type} op {spec.name} has routing but no " "credentials declared — routing needs a Connection.")cred = self.credentials[0]conn = ctx.connection(cred.id)try:return await execute_routing(- spec.routing, params=params_obj.model_dump(), connection=conn,+ spec.routing,+ params=params_obj.model_dump(),+ connection=conn,)finally:await conn.aclose()@@ -631,7 +634,10 @@ class BaseNode:"timestamp": datetime.now().isoformat(),}await broadcaster.update_node_status(- node_id, "success", result, workflow_id=workflow_id,+ node_id,+ "success",+ result,+ workflow_id=workflow_id,)return result@@ -648,13 +654,19 @@ class BaseNode:"timestamp": datetime.now().isoformat(),}await broadcaster.update_node_status(- node_id, "skipped", {"disabled": True}, workflow_id=workflow_id,+ node_id,+ "skipped",+ {"disabled": True},+ workflow_id=workflow_id,)return result# Broadcast executing — UI cyan-glow.await broadcaster.update_node_status(- node_id, "executing", {"node_type": cls.type}, workflow_id=workflow_id,+ node_id,+ "executing",+ {"node_type": cls.type},+ workflow_id=workflow_id,)try:@@ -685,18 +697,21 @@ class BaseNode:if result.get("success"):activity.logger.info(f"Node {node_id} succeeded")await broadcaster.update_node_status(- node_id, "success", result.get("result", {}),+ node_id,+ "success",+ result.get("result", {}),workflow_id=workflow_id,)await broadcaster.update_node_output(- node_id, result.get("result", {}), workflow_id=workflow_id,+ node_id,+ result.get("result", {}),+ workflow_id=workflow_id,)else:- activity.logger.warning(- f"Node {node_id} failed: {result.get('error')}"- )+ activity.logger.warning(f"Node {node_id} failed: {result.get('error')}")await broadcaster.update_node_status(- node_id, "error",+ node_id,+ "error",{"error": result.get("error")},workflow_id=workflow_id,)@@ -708,7 +723,9 @@ class BaseNode:error_msg = f"{type(e).__name__}: {e}"activity.logger.error(f"Node {node_id} crashed: {error_msg}")await broadcaster.update_node_status(- node_id, "error", {"error": error_msg},+ node_id,+ "error",+ {"error": error_msg},workflow_id=workflow_id,)raise@@ -719,6 +736,7 @@ class BaseNode:# ---------------------------------------------------------------------------# Connection factory — avoids circular import with NodeContext.+def _make_connection_factory(node_cls: Type[BaseNode],context: Dict[str, Any],@@ -737,7 +755,10 @@ def _make_connection_factory(f"but tried to use it. Add it to the `credentials` class attribute.")return Connection(- cred_cls, user_id=user_id, session_id=session_id, node_id=node_id,+ cred_cls,+ user_id=user_id,+ session_id=session_id,+ node_id=node_id,)return factorydiff --git a/server/services/plugin/connection.py b/server/services/plugin/connection.pyindex 7cfacbd3..054efc59 100644--- a/server/services/plugin/connection.py+++ b/server/services/plugin/connection.py@@ -106,16 +106,21 @@ class Connection:if _retry_on_auth and response.status_code in (401, 403):logger.debug("[Connection] auth retry for %s (%s) status=%s",- self.credential_id, method, response.status_code,+ self.credential_id,+ method,+ response.status_code,)await self.refresh()secrets = await self.credentials()- req_retry = self._cred_cls.inject(secrets, {- "headers": dict(headers or {}),- "params": dict(params or {}),- **({"json": json} if json is not None else {}),- **({"data": data} if data is not None else {}),- })+ req_retry = self._cred_cls.inject(+ secrets,+ {+ "headers": dict(headers or {}),+ "params": dict(params or {}),+ **({"json": json} if json is not None else {}),+ **({"data": data} if data is not None else {}),+ },+ )response = await client.request(method, url, **req_retry)return responsediff --git a/server/services/plugin/credential.py b/server/services/plugin/credential.pyindex 73fb9c4e..25ececa7 100644--- a/server/services/plugin/credential.py+++ b/server/services/plugin/credential.py@@ -62,9 +62,7 @@ class ProbeResult:extra: Dict[str, Any] = field(default_factory=dict)-def classify_credential_error(- exc: BaseException, *, display_name: str-) -> ProbeResult:+def classify_credential_error(exc: BaseException, *, display_name: str) -> ProbeResult:"""Map a transport / SDK exception to a typed ``ProbeResult``.Single source of truth for credential-error → user-message mapping.@@ -169,10 +167,7 @@ class Credential:# Idempotent on re-import — only warn on genuine conflict.existing = CREDENTIAL_REGISTRY[cls.id]if existing.__qualname__ != cls.__qualname__:- raise ValueError(- f"Credential id '{cls.id}' registered by "- f"{existing.__qualname__} and now by {cls.__qualname__}"- )+ raise ValueError(f"Credential id '{cls.id}' registered by " f"{existing.__qualname__} and now by {cls.__qualname__}")CREDENTIAL_REGISTRY[cls.id] = cls@classmethod@@ -343,9 +338,7 @@ class Credential:``openai.OpenAIError`` to let the base map them to a typedmessage via :func:`classify_credential_error`."""- raise NotImplementedError(- f"Credential subclass {cls.__name__} must override _probe()"- )+ raise NotImplementedError(f"Credential subclass {cls.__name__} must override _probe()")class OAuth2Credential(Credential):@@ -364,8 +357,8 @@ class OAuth2Credential(Credential):token_header: ClassVar[str] = "Authorization"token_prefix: ClassVar[str] = "Bearer "# Keys the user enters in credentials modal (API-key style rows)- client_id_api_key: ClassVar[str] = "" # e.g. "google_client_id"- client_secret_api_key: ClassVar[str] = "" # e.g. "google_client_secret"+ client_id_api_key: ClassVar[str] = "" # e.g. "google_client_id"+ client_secret_api_key: ClassVar[str] = "" # e.g. "google_client_secret"@classmethodasync def resolve(cls, *, user_id: str = "owner") -> Dict[str, Any]:@@ -379,9 +372,7 @@ class OAuth2Credential(Credential):# CloudEvents-typed broadcast (credential.oauth.runtime_failed)# via broadcast_credential_event. Plain attribute assignment —# no new exception class.- err = PermissionError(- f"No OAuth tokens for '{cls.id}'. Connect via Credentials modal."- )+ err = PermissionError(f"No OAuth tokens for '{cls.id}'. Connect via Credentials modal.")err.provider = cls.iderr.reason = "missing"err.auth = cls.auth # "oauth2"@@ -426,7 +417,7 @@ class ApiKeyCredential(Credential):auth: ClassVar[Literal["api_key"]] = "api_key"# Where the key goes- key_name: ClassVar[str] = "" # header name or query-string key+ key_name: ClassVar[str] = "" # header name or query-string keykey_location: ClassVar[Literal["header", "query", "bearer"]] = "header"# Extra fields stored alongside (e.g. "apify_account_id" for Apify)extra_fields: ClassVar[Sequence[str]] = ()@@ -439,7 +430,7 @@ class ApiKeyCredential(Credential):# ``httpx.HTTPStatusError`` / ``TimeoutException`` / ``ConnectError``# propagate to :meth:`Credential.validate`, where# :func:`classify_credential_error` produces the user-facing message.- probe_url: ClassVar[str] = "" # set to enable the default probe+ probe_url: ClassVar[str] = "" # set to enable the default probeprobe_method: ClassVar[str] = "GET"probe_params: ClassVar[Dict[str, Any]] = {}probe_json: ClassVar[Optional[Dict[str, Any]]] = None@@ -452,9 +443,7 @@ class ApiKeyCredential(Credential):auth_service = container.auth_service()api_key = await auth_service.get_api_key(cls.id)if not api_key:- err = PermissionError(- f"No API key for '{cls.id}'. Add via Credentials modal."- )+ err = PermissionError(f"No API key for '{cls.id}'. Add via Credentials modal.")err.provider = cls.iderr.reason = "missing"err.auth = cls.auth # "api_key"@@ -497,8 +486,7 @@ class ApiKeyCredential(Credential):"""if not cls.probe_url:raise NotImplementedError(- f"Credential subclass {cls.__name__} must override _probe() "- f"or set the `probe_url` class attribute"+ f"Credential subclass {cls.__name__} must override _probe() " f"or set the `probe_url` class attribute")request = cls.inject(diff --git a/server/services/plugin/edge_walker.py b/server/services/plugin/edge_walker.pyindex 09885051..5264d5c1 100644--- a/server/services/plugin/edge_walker.py+++ b/server/services/plugin/edge_walker.py@@ -68,10 +68,7 @@ def register_master_skill_expander(fn: MasterSkillExpander) -> None:"""global _MASTER_SKILL_EXPANDERif _MASTER_SKILL_EXPANDER is not None and _MASTER_SKILL_EXPANDER != fn:- raise ValueError(- "register_master_skill_expander: callback already registered "- "by a different callable; refusing to overwrite"- )+ raise ValueError("register_master_skill_expander: callback already registered " "by a different callable; refusing to overwrite")_MASTER_SKILL_EXPANDER = fn@@ -88,11 +85,11 @@ async def collect_agent_connections(database: "Database",log_prefix: str = "[Agent]",) -> Tuple[- Optional[Dict[str, Any]], # memory_data- List[Dict[str, Any]], # skill_data- List[Dict[str, Any]], # tool_data- Optional[Dict[str, Any]], # input_data- Optional[Dict[str, Any]], # task_data+ Optional[Dict[str, Any]], # memory_data+ List[Dict[str, Any]], # skill_data+ List[Dict[str, Any]], # tool_data+ Optional[Dict[str, Any]], # input_data+ Optional[Dict[str, Any]], # task_data]:"""Walk edges targeting ``node_id`` and collect everything an agentneeds from its connected nodes.@@ -126,10 +123,7 @@ async def collect_agent_connections(edge_targets = set(e.get("target") for e in edges)logger.debug(f"{log_prefix} All edge targets in graph: {edge_targets}")for e in incoming_edges:- logger.debug(- f"{log_prefix} Edge: source={e.get('source')}, "- f"targetHandle={e.get('targetHandle')}"- )+ logger.debug(f"{log_prefix} Edge: source={e.get('source')}, " f"targetHandle={e.get('targetHandle')}")tool_incoming = [e for e in incoming_edges if e.get("targetHandle") == "input-tools"]logger.info(f"{log_prefix} Tool edges (input-tools handle): {len(tool_incoming)}")@@ -147,18 +141,30 @@ async def collect_agent_connections(if target_handle == "input-memory":if source_node.get("type") == "simpleMemory":memory_data = await _build_memory_entry(- node_id, source_node_id, database, log_prefix,+ node_id,+ source_node_id,+ database,+ log_prefix,)elif target_handle == "input-skill":await _append_skill_entries(- source_node, source_node_id, database, skill_data, log_prefix,+ source_node,+ source_node_id,+ database,+ skill_data,+ log_prefix,)elif target_handle == "input-tools":await _append_tool_entry(- source_node, source_node_id, edges, nodes, database,- tool_data, log_prefix,+ source_node,+ source_node_id,+ edges,+ nodes,+ database,+ tool_data,+ log_prefix,)elif target_handle in ("input-main", "input-chat") or target_handle is None:@@ -172,7 +178,10 @@ async def collect_agent_connections(elif target_handle == "input-task":task_data = await _resolve_task_payload(- source_node_id, source_node, context, log_prefix,+ source_node_id,+ source_node,+ context,+ log_prefix,)logger.info(@@ -210,7 +219,8 @@ async def _build_memory_entry("session_id": session_id,"window_size": int(memory_params.get("window_size", 10)),"memory_content": memory_params.get(- "memory_content", "# Conversation History\n\n*No messages yet.*\n",+ "memory_content",+ "# Conversation History\n\n*No messages yet.*\n",),"long_term_enabled": memory_params.get("long_term_enabled", False),"retrieval_count": int(memory_params.get("retrieval_count", 3)),@@ -221,9 +231,10 @@ async def _build_memory_entry("last_session_id": memory_params.get("last_session_id"),}logger.info(- "%s Connected memory node: node=%s session=%s (auto=%s) "- "content_length=%d last_session_id=%s",- log_prefix, memory_node_id, session_id,+ "%s Connected memory node: node=%s session=%s (auto=%s) " "content_length=%d last_session_id=%s",+ log_prefix,+ memory_node_id,+ session_id,not configured_session or configured_session == "default",len(entry["memory_content"]),entry["last_session_id"],@@ -252,21 +263,21 @@ async def _append_skill_entries(returnskills_config = skill_params.get("skills_config", {})- logger.debug(- f"{log_prefix} Master Skill found with {len(skills_config)} configured skills"- )+ logger.debug(f"{log_prefix} Master Skill found with {len(skills_config)} configured skills")entries = await expander(source_node_id, skills_config)skill_data.extend(entries)for entry in entries:logger.debug(f"{log_prefix} Master Skill enabled: {entry['skill_name']}")else:- skill_data.append({- "node_id": source_node_id,- "node_type": skill_type,- "skill_name": skill_params.get("skill_name", skill_type),- "parameters": skill_params,- "label": source_node.get("data", {}).get("label", skill_type),- })+ skill_data.append(+ {+ "node_id": source_node_id,+ "node_type": skill_type,+ "skill_name": skill_params.get("skill_name", skill_type),+ "parameters": skill_params,+ "label": source_node.get("data", {}).get("label", skill_type),+ }+ )logger.debug(f"{log_prefix} Connected skill: {skill_type}")@@ -297,27 +308,23 @@ async def _append_tool_entry(continueservice_target_handle = service_edge.get("targetHandle")if service_target_handle is not None and service_target_handle != "input-main":- logger.debug(- f"{log_prefix} Android Toolkit: Skipping edge with "- f"targetHandle: {service_target_handle}"- )+ logger.debug(f"{log_prefix} Android Toolkit: Skipping edge with " f"targetHandle: {service_target_handle}")continueandroid_node_id = service_edge.get("source")android_node = next((n for n in nodes if n.get("id") == android_node_id), None)if android_node and android_node.get("type") in ANDROID_SERVICE_NODE_TYPES:android_params = await database.get_node_parameters(android_node_id) or {}- connected_services.append({- "node_id": android_node_id,- "node_type": android_node.get("type"),- "service_id": android_params.get("service_id"),- "action": android_params.get("action"),- "parameters": android_params,- "label": android_node.get("data", {}).get("label", android_node.get("type")),- })- logger.debug(- f"{log_prefix} Android toolkit connected service: "- f"{android_params.get('service_id')}"+ connected_services.append(+ {+ "node_id": android_node_id,+ "node_type": android_node.get("type"),+ "service_id": android_params.get("service_id"),+ "action": android_params.get("action"),+ "parameters": android_params,+ "label": android_node.get("data", {}).get("label", android_node.get("type")),+ })+ logger.debug(f"{log_prefix} Android toolkit connected service: " f"{android_params.get('service_id')}")tool_entry["connected_services"] = connected_serviceslogger.debug(f"{log_prefix} Android toolkit has {len(connected_services)} connected services")@@ -341,8 +348,7 @@ async def _append_tool_entry(child_tool_id = child_edge.get("source")child_tool_node = next((n for n in nodes if n.get("id") == child_tool_id), None)logger.debug(- f"{log_prefix} Child agent {source_node_id}: "- f"tool edge from {child_tool_id}, node found: {child_tool_node is not None}"+ f"{log_prefix} Child agent {source_node_id}: " f"tool edge from {child_tool_id}, node found: {child_tool_node is not None}")if child_tool_node:child_tool_type = child_tool_node.get("type", "")@@ -350,10 +356,7 @@ async def _append_tool_entry(child_tools.append({"node_type": child_tool_type, "label": child_tool_label})if child_tools:tool_entry["child_tools"] = child_tools- logger.debug(- f"{log_prefix} Child agent {source_node_id} has tools: "- f"{[t['label'] for t in child_tools]}"- )+ logger.debug(f"{log_prefix} Child agent {source_node_id} has tools: " f"{[t['label'] for t in child_tools]}")tool_data.append(tool_entry)logger.debug(f"{log_prefix} Connected tool: {tool_type}")@@ -368,9 +371,7 @@ async def _resolve_task_payload(logger.info(f"{log_prefix} Found input-task edge from {source_node_id} (type={source_node.get('type')})")source_output = context.get("outputs", {}).get(source_node_id)- logger.info(- f"{log_prefix} Context outputs check for {source_node_id}: {source_output is not None}"- )+ logger.info(f"{log_prefix} Context outputs check for {source_node_id}: {source_output is not None}")if not source_output:get_output_fn = context.get("get_output_fn")@@ -382,9 +383,7 @@ async def _resolve_task_payload(except Exception as e:logger.warning(f"{log_prefix} Failed to get output from DB: {e}")else:- logger.warning(- f"{log_prefix} No get_output_fn in context, cannot retrieve task output"- )+ logger.warning(f"{log_prefix} No get_output_fn in context, cannot retrieve task output")logger.info(f"{log_prefix} Source output for {source_node_id}: {source_output is not None}, "@@ -393,11 +392,7 @@ async def _resolve_task_payload(if not source_output:return None- if (- isinstance(source_output, dict)- and "result" in source_output- and isinstance(source_output.get("result"), dict)- ):+ if isinstance(source_output, dict) and "result" in source_output and isinstance(source_output.get("result"), dict):task_data = source_output.get("result")logger.info(f"{log_prefix} Extracted nested task_data from result key")else:@@ -434,12 +429,14 @@ async def collect_teammate_connections(if node_type not in AI_AGENT_TYPES:continueparams = await database.get_node_parameters(source_id) or {}- teammates.append({- "node_id": source_id,- "node_type": node_type,- "label": source_node.get("data", {}).get("label", node_type),- "parameters": params,- })+ teammates.append(+ {+ "node_id": source_id,+ "node_type": node_type,+ "label": source_node.get("data", {}).get("label", node_type),+ "parameters": params,+ }+ )logger.debug(f"[Teams] Found teammate: {node_type} ({source_id})")return teammates@@ -479,10 +476,4 @@ def format_task_context(task_data: Dict[str, Any]) -> str:"Report this error to the user and suggest next steps if appropriate.")- return (- f"Task update received:\n"- f"- Agent: {agent_name}\n"- f"- Task ID: {task_id}\n"- f"- Status: {status}\n"- f"- Data: {task_data}"- )+ return f"Task update received:\n" f"- Agent: {agent_name}\n" f"- Task ID: {task_id}\n" f"- Status: {status}\n" f"- Data: {task_data}"diff --git a/server/services/plugin/interceptor.py b/server/services/plugin/interceptor.pyindex 1352aea8..fdba55bb 100644--- a/server/services/plugin/interceptor.py+++ b/server/services/plugin/interceptor.py@@ -22,7 +22,7 @@ class InterceptorInput:node_id: strnode_type: strparameters: Dict[str, Any]- context: Any # NodeContext (avoid cycle in type hint)+ context: Any # NodeContext (avoid cycle in type hint)class Interceptor(ABC):diff --git a/server/services/plugin/oauth.py b/server/services/plugin/oauth.pyindex 81ecd843..2bd75389 100644--- a/server/services/plugin/oauth.py+++ b/server/services/plugin/oauth.py@@ -98,11 +98,7 @@ class OAuthStateStore:def cleanup_expired(self) -> int:"""Remove states older than ``ttl_seconds``. Returns count removed."""now = time.time()- expired = [- state- for state, record in self._states.items()- if now - record.get("created_at", 0) > self.ttl_seconds- ]+ expired = [state for state, record in self._states.items() if now - record.get("created_at", 0) > self.ttl_seconds]for state in expired:self._states.pop(state, None)if expired:@@ -180,9 +176,7 @@ class OAuth2PKCEClient(ABC):scopes: Optional[List[str]] = None,) -> None:if not self.provider:- raise ValueError(- f"{type(self).__name__} must set the ``provider`` ClassVar"- )+ raise ValueError(f"{type(self).__name__} must set the ``provider`` ClassVar")self.client_id = client_idself.client_secret = client_secretself.redirect_uri = redirect_uri@@ -207,11 +201,14 @@ class OAuth2PKCEClient(ABC):code_verifier = _generate_code_verifier()code_challenge = _generate_code_challenge(code_verifier)- self.state_store.put(state, {- "code_verifier": code_verifier,- "redirect_uri": self.redirect_uri,- "data": state_data or {},- })+ self.state_store.put(+ state,+ {+ "code_verifier": code_verifier,+ "redirect_uri": self.redirect_uri,+ "data": state_data or {},+ },+ )params = {"response_type": "code",@@ -240,9 +237,7 @@ class OAuth2PKCEClient(ABC):in the header. Public clients put ``client_id`` in the body."""if self.client_secret:- credentials = base64.b64encode(- f"{self.client_id}:{self.client_secret}".encode()- ).decode()+ credentials = base64.b64encode(f"{self.client_id}:{self.client_secret}".encode()).decode()return {}, {"Authorization": f"Basic {credentials}"}return {"client_id": self.client_id}, {}@@ -266,7 +261,9 @@ class OAuth2PKCEClient(ABC):try:async with httpx.AsyncClient(timeout=30.0) as client:response = await client.post(- self.token_endpoint, data=body, headers=headers,+ self.token_endpoint,+ data=body,+ headers=headers,)except httpx.HTTPError as exc:logger.error(f"[{self.provider}] HTTP error during token exchange: {exc}")@@ -276,7 +273,8 @@ class OAuth2PKCEClient(ABC):error_data = response.json() if response.text else {}logger.error(f"[{self.provider}] Token exchange failed",- status=response.status_code, error=error_data,+ status=response.status_code,+ error=error_data,)return {"success": False,@@ -306,7 +304,9 @@ class OAuth2PKCEClient(ABC):try:async with httpx.AsyncClient(timeout=30.0) as client:response = await client.post(- self.token_endpoint, data=body, headers=headers,+ self.token_endpoint,+ data=body,+ headers=headers,)except httpx.HTTPError as exc:logger.error(f"[{self.provider}] HTTP error during token refresh: {exc}")@@ -329,7 +329,9 @@ class OAuth2PKCEClient(ABC):}async def revoke_token(- self, token: str, token_type: str = "access_token",+ self,+ token: str,+ token_type: str = "access_token",) -> Dict[str, Any]:"""Revoke an access or refresh token (best-effort).@@ -348,7 +350,9 @@ class OAuth2PKCEClient(ABC):try:async with httpx.AsyncClient(timeout=30.0) as client:response = await client.post(- self.revocation_endpoint, data=body, headers=headers,+ self.revocation_endpoint,+ data=body,+ headers=headers,)except httpx.HTTPError as exc:logger.error(f"[{self.provider}] HTTP error during token revoke: {exc}")diff --git a/server/services/plugin/operation.py b/server/services/plugin/operation.pyindex 0ce02183..a3600073 100644--- a/server/services/plugin/operation.py+++ b/server/services/plugin/operation.py@@ -32,7 +32,7 @@ class OperationSpec:name: strmethod: Callable[..., Awaitable[Any]]routing: Optional[Routing] = None- cost: Optional[Dict[str, Any]] = None # {"usage": "gmail_send", "count": 1}+ cost: Optional[Dict[str, Any]] = None # {"usage": "gmail_send", "count": 1}annotations: Dict[str, Any] = field(default_factory=dict)diff --git a/server/services/plugin/polling.py b/server/services/plugin/polling.pyindex c1a9ff84..1d19ee10 100644--- a/server/services/plugin/polling.py+++ b/server/services/plugin/polling.py@@ -97,9 +97,7 @@ class PollingTriggerNode(TriggerNode, abstract=True):"""raise NotImplementedError- async def fetch_ids(- self, service: Any, params: Dict[str, Any]- ) -> Set[str]:+ async def fetch_ids(self, service: Any, params: Dict[str, Any]) -> Set[str]:"""Return the current set of visible IDs for one poll cycle.Called once for the baseline pass at loop start, then once per@@ -108,9 +106,7 @@ class PollingTriggerNode(TriggerNode, abstract=True):"""raise NotImplementedError- async def fetch_detail(- self, service: Any, msg_id: str, params: Dict[str, Any]- ) -> Dict[str, Any]:+ async def fetch_detail(self, service: Any, msg_id: str, params: Dict[str, Any]) -> Dict[str, Any]:"""Fetch the full event payload for one ID.Called once per new ID per cycle. The returned dict goes@@ -119,9 +115,7 @@ class PollingTriggerNode(TriggerNode, abstract=True):"""raise NotImplementedError- async def post_emit(- self, service: Any, msg_id: str, params: Dict[str, Any]- ) -> None:+ async def post_emit(self, service: Any, msg_id: str, params: Dict[str, Any]) -> None:"""Optional side effect AFTER the payload was enqueued.Default no-op. Override for "mark-as-read" or similar@@ -222,7 +216,9 @@ class PollingTriggerNode(TriggerNode, abstract=True):except Exception as exc: # noqa: BLE001logger.error("Polling activity setup failed",- node_id=node_id, node_type=cls.type, error=str(exc),+ node_id=node_id,+ node_type=cls.type,+ error=str(exc),)raise@@ -242,8 +238,10 @@ class PollingTriggerNode(TriggerNode, abstract=True):except Exception as exc: # noqa: BLE001logger.warning("Polling activity fetch_detail failed; skipping id",- node_id=node_id, node_type=cls.type,- msg_id=msg_id, error=str(exc),+ node_id=node_id,+ node_type=cls.type,+ msg_id=msg_id,+ error=str(exc),)continue# The workflow needs a stable event.id for cross-cycle@@ -273,22 +271,20 @@ class PollingTriggerNode(TriggerNode, abstract=True):return _poll_cycle_activity- def _build_poll_coroutine(- self, node_id: str, params: Dict[str, Any]- ) -> Callable[[asyncio.Queue, Callable[[], bool]], Any]:+ def _build_poll_coroutine(self, node_id: str, params: Dict[str, Any]) -> Callable[[asyncio.Queue, Callable[[], bool]], Any]:"""Return the bound poll coroutine the deployment managerconsumes. Closes over ``self``, ``node_id``, and ``params``."""- async def poll(- queue: asyncio.Queue, is_running_fn: Callable[[], bool]- ) -> None:+ async def poll(queue: asyncio.Queue, is_running_fn: Callable[[], bool]) -> None:try:service = await self.setup_service(params)except Exception as exc: # noqa: BLE001 -- single setup failurelogger.error("Polling trigger setup failed",- node_id=node_id, node_type=self.type, error=str(exc),+ node_id=node_id,+ node_type=self.type,+ error=str(exc),)return@@ -304,12 +300,16 @@ class PollingTriggerNode(TriggerNode, abstract=True):seen = await self.fetch_ids(service, params)logger.info("Polling trigger baseline established",- node_id=node_id, node_type=self.type, seen=len(seen),+ node_id=node_id,+ node_type=self.type,+ seen=len(seen),)except Exception as exc: # noqa: BLE001logger.warning("Polling trigger baseline failed; treating all as new",- node_id=node_id, node_type=self.type, error=str(exc),+ node_id=node_id,+ node_type=self.type,+ error=str(exc),)cycle = 0@@ -330,14 +330,15 @@ class PollingTriggerNode(TriggerNode, abstract=True):continuelogger.debug("Polling trigger cycle",- node_id=node_id, node_type=self.type, cycle=cycle,- current=len(current), seen=len(seen),+ node_id=node_id,+ node_type=self.type,+ cycle=cycle,+ current=len(current),+ seen=len(seen),new=len(new_ids),)for msg_id in new_ids:- payload = await self.fetch_detail(- service, msg_id, params- )+ payload = await self.fetch_detail(service, msg_id, params)await queue.put(payload)# post_emit failure must NOT block the next emit# nor kill the loop; mirrors pre-migration@@ -363,7 +364,8 @@ class PollingTriggerNode(TriggerNode, abstract=True):except Exception as exc: # noqa: BLE001 -- per-cycle isolationlogger.error("Polling trigger cycle error; retrying next interval",- node_id=node_id, node_type=self.type,+ node_id=node_id,+ node_type=self.type,error=str(exc),)diff --git a/server/services/plugin/registry.py b/server/services/plugin/registry.pyindex 0d8d14ea..6a3c69b6 100644--- a/server/services/plugin/registry.py+++ b/server/services/plugin/registry.py@@ -102,8 +102,7 @@ class IdempotentRegistry(Generic[K, V]):existing = self._items.get(key)if existing is not None and not self._values_equivalent(existing, value):raise ValueError(- f"{self._name}: {key!r} is already registered by "- f"{_qual(existing)}; refusing to overwrite with {_qual(value)}"+ f"{self._name}: {key!r} is already registered by " f"{_qual(existing)}; refusing to overwrite with {_qual(value)}")self._items[key] = valueif self._on_register is not None:diff --git a/server/services/plugin/routing.py b/server/services/plugin/routing.pyindex 4b06836a..5b485683 100644--- a/server/services/plugin/routing.py+++ b/server/services/plugin/routing.py@@ -61,6 +61,7 @@ class Routing(BaseModel):# ---------------------------------------------------------------------------# Template interpolation+def _resolve_template(value: Any, env: Dict[str, Any]) -> Any:"""Resolve ``={{expr}}`` templates against ``env``. Non-string valuespass through. Supports dotted paths — ``params.maxResults``."""@@ -94,6 +95,7 @@ def _resolve_dict(d: Dict[str, Any], env: Dict[str, Any]) -> Dict[str, Any]:# ---------------------------------------------------------------------------# post_receive strategies+def _strategy_root_property(data: Any, action: PostReceiveAction) -> Any:if not action.property or not isinstance(data, dict):return data@@ -114,9 +116,7 @@ def _strategy_limit(data: Any, action: PostReceiveAction) -> Any:def _strategy_filter(data: Any, action: PostReceiveAction) -> Any:if not isinstance(data, list) or not action.where:return data- return [item for item in data if all(- isinstance(item, dict) and item.get(k) == v for k, v in action.where.items()- )]+ return [item for item in data if all(isinstance(item, dict) and item.get(k) == v for k, v in action.where.items())]def _strategy_set(data: Any, action: PostReceiveAction) -> Any:@@ -125,8 +125,7 @@ def _strategy_set(data: Any, action: PostReceiveAction) -> Any:if isinstance(data, dict):return {**data, **action.set_fields}if isinstance(data, list):- return [{**item, **action.set_fields} if isinstance(item, dict) else item- for item in data]+ return [{**item, **action.set_fields} if isinstance(item, dict) else item for item in data]return data@@ -141,6 +140,7 @@ POST_RECEIVE_STRATEGIES = {# ---------------------------------------------------------------------------# Execution+async def execute_routing(routing: Routing,*,@@ -164,10 +164,7 @@ async def execute_routing(kwargs: Dict[str, Any] = {"headers": headers, "params": qs}if req.body is not None:- body_resolved = (- _resolve_dict(req.body, env) if isinstance(req.body, dict) else- _resolve_template(req.body, env)- )+ body_resolved = _resolve_dict(req.body, env) if isinstance(req.body, dict) else _resolve_template(req.body, env)if req.body_encoding == "form":kwargs["data"] = body_resolvedelse:diff --git a/server/services/plugin/scaling.py b/server/services/plugin/scaling.pyindex 3032a78b..ac57ff33 100644--- a/server/services/plugin/scaling.py+++ b/server/services/plugin/scaling.py@@ -20,20 +20,29 @@ class TaskQueue:and provision a worker pool in ``services/temporal/worker.py``."""- DEFAULT = "machina-default" # catch-all- REST_API = "rest-api" # lightweight HTTP calls (gmail, brave, twitter)- AI_HEAVY = "ai-heavy" # long-running LLM + agent loops- CODE_EXEC = "code-exec" # python/js/ts sandboxed execution- TRIGGERS_POLL = "triggers-poll" # polling triggers (long-lived)+ DEFAULT = "machina-default" # catch-all+ REST_API = "rest-api" # lightweight HTTP calls (gmail, brave, twitter)+ AI_HEAVY = "ai-heavy" # long-running LLM + agent loops+ CODE_EXEC = "code-exec" # python/js/ts sandboxed execution+ TRIGGERS_POLL = "triggers-poll" # polling triggers (long-lived)TRIGGERS_EVENT = "triggers-event" # event-waiter triggers (long-lived)- ANDROID = "android" # ADB / relay ops- BROWSER = "browser" # agent-browser, Playwright- MESSAGING = "messaging" # whatsapp / telegram / twitter send+ ANDROID = "android" # ADB / relay ops+ BROWSER = "browser" # agent-browser, Playwright+ MESSAGING = "messaging" # whatsapp / telegram / twitter send- ALL = frozenset({- DEFAULT, REST_API, AI_HEAVY, CODE_EXEC,- TRIGGERS_POLL, TRIGGERS_EVENT, ANDROID, BROWSER, MESSAGING,- })+ ALL = frozenset(+ {+ DEFAULT,+ REST_API,+ AI_HEAVY,+ CODE_EXEC,+ TRIGGERS_POLL,+ TRIGGERS_EVENT,+ ANDROID,+ BROWSER,+ MESSAGING,+ }+ )@dataclass(frozen=True)@@ -47,18 +56,20 @@ class RetryPolicy:backoff_coefficient: float = 2.0maximum_interval: timedelta = timedelta(seconds=60)maximum_attempts: int = 3- non_retryable_error_types: Sequence[str] = field(default_factory=lambda: (- "ValidationError",- "PermissionDeniedError",- "InvalidParametersError",- # Wave 12 A2: NodeUserError is the canonical "user-correctable- # failure" exception (missing input, missing credential, API- # rejected the payload). Retrying it just burns attempts since- # the underlying input won't fix itself. Plugins that raise- # NodeUserError fail fast; the framework surfaces the message- # to the user / agent loop without traceback noise.- "NodeUserError",- ))+ non_retryable_error_types: Sequence[str] = field(+ default_factory=lambda: (+ "ValidationError",+ "PermissionDeniedError",+ "InvalidParametersError",+ # Wave 12 A2: NodeUserError is the canonical "user-correctable+ # failure" exception (missing input, missing credential, API+ # rejected the payload). Retrying it just burns attempts since+ # the underlying input won't fix itself. Plugins that raise+ # NodeUserError fail fast; the framework surfaces the message+ # to the user / agent loop without traceback noise.+ "NodeUserError",+ )+ )def to_temporal(self):"""Lazy import — only called inside the Temporal worker."""@@ -81,5 +92,5 @@ DEFAULT_RETRY = RetryPolicy()# Kind-specific defaults — picked up when a subclass doesn't override.ACTION_START_TO_CLOSE = timedelta(minutes=10)AI_START_TO_CLOSE = timedelta(minutes=30)-TRIGGER_START_TO_CLOSE = timedelta(hours=24) # long-lived+TRIGGER_START_TO_CLOSE = timedelta(hours=24) # long-livedCODE_START_TO_CLOSE = timedelta(minutes=5)diff --git a/server/services/plugin/service_factories.py b/server/services/plugin/service_factories.pyindex 790916de..62cf4d97 100644--- a/server/services/plugin/service_factories.py+++ b/server/services/plugin/service_factories.py@@ -51,9 +51,7 @@ from services.plugin.registry import IdempotentRegistryServiceFactory = Callable[..., Any]-_REGISTRY: IdempotentRegistry[str, ServiceFactory] = IdempotentRegistry(- "service_factory"-)+_REGISTRY: IdempotentRegistry[str, ServiceFactory] = IdempotentRegistry("service_factory")def register_service_factory(name: str, factory: ServiceFactory) -> None:diff --git a/server/services/plugin/shutdown_hooks.py b/server/services/plugin/shutdown_hooks.pyindex e989a88e..4423c27b 100644--- a/server/services/plugin/shutdown_hooks.py+++ b/server/services/plugin/shutdown_hooks.py@@ -46,9 +46,7 @@ ShutdownHook = Callable[[], Awaitable[None]]# (CPython 3.7+ dict ordering guarantee) which gives deterministic# shutdown ordering. Plugins that need ordering invariants should# document them via their label naming.-_REGISTRY: IdempotentRegistry[str, ShutdownHook] = IdempotentRegistry(- "plugin_shutdown_hook"-)+_REGISTRY: IdempotentRegistry[str, ShutdownHook] = IdempotentRegistry("plugin_shutdown_hook")def register_shutdown_hook(label: str, hook: ShutdownHook) -> None:@@ -86,8 +84,7 @@ async def run_shutdown_hooks() -> None:if not hooks:return- logger.info(f"Running {len(hooks)} plugin shutdown hook(s): "- f"{[label for label, _ in hooks]}")+ logger.info(f"Running {len(hooks)} plugin shutdown hook(s): " f"{[label for label, _ in hooks]}")for label, hook in hooks:try:await hook()diff --git a/server/services/plugin/social_provider_registry.py b/server/services/plugin/social_provider_registry.pyindex 99fdd345..ecf53a83 100644--- a/server/services/plugin/social_provider_registry.py+++ b/server/services/plugin/social_provider_registry.py@@ -35,9 +35,7 @@ from services.plugin.registry import IdempotentRegistrySocialSendHandler = Callable[[Dict[str, Any]], Awaitable[Dict[str, Any]]]-_REGISTRY: IdempotentRegistry[str, SocialSendHandler] = IdempotentRegistry(- "social_send_handler"-)+_REGISTRY: IdempotentRegistry[str, SocialSendHandler] = IdempotentRegistry("social_send_handler")def register_social_send_handler(platform: str, handler: SocialSendHandler) -> None:diff --git a/server/services/plugin/ws.py b/server/services/plugin/ws.pyindex 8658a6dd..d7d29b98 100644--- a/server/services/plugin/ws.py+++ b/server/services/plugin/ws.py@@ -64,7 +64,8 @@ def ws_response(handler: WSHandlerFn) -> WSHandlerFn:@wraps(handler)async def wrapper(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:try:return await handler(data, websocket)diff --git a/server/services/pricing.py b/server/services/pricing.pyindex 2a1e0b8d..ee4d0a65 100644--- a/server/services/pricing.py+++ b/server/services/pricing.py@@ -26,10 +26,11 @@ CONFIG_PATH = Path(__file__).parent.parent / "config" / "pricing.json"@dataclassclass ModelPricing:"""Pricing for a specific LLM model."""- input_per_mtok: float # USD per 1M input tokens++ input_per_mtok: float # USD per 1M input tokensoutput_per_mtok: float # USD per 1M output tokenscache_read_per_mtok: Optional[float] = None # USD per 1M cache read tokens (Anthropic)- reasoning_per_mtok: Optional[float] = None # USD per 1M reasoning tokens (OpenAI o-series)+ reasoning_per_mtok: Optional[float] = None # USD per 1M reasoning tokens (OpenAI o-series)class PricingService:@@ -44,7 +45,7 @@ class PricingService:"""Load pricing config from JSON file."""if CONFIG_PATH.exists():try:- with open(CONFIG_PATH, 'r', encoding='utf-8') as f:+ with open(CONFIG_PATH, "r", encoding="utf-8") as f:self._config = json.load(f)self._build_llm_registry()logger.info(f"[Pricing] Loaded pricing config v{self._config.get('version', 'unknown')}")@@ -97,7 +98,7 @@ class PricingService:# Ensure config directory existsCONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)- with open(CONFIG_PATH, 'w', encoding='utf-8') as f:+ with open(CONFIG_PATH, "w", encoding="utf-8") as f:json.dump(config, f, indent=2)# Reload the config into memory@@ -128,7 +129,7 @@ class PricingService:ModelPricing with rates per million tokens"""provider_lower = provider.lower()- model_lower = model.lower() if model else ''+ model_lower = model.lower() if model else ""provider_pricing = self._llm_registry.get(provider_lower, {})@@ -138,16 +139,16 @@ class PricingService:# Try partial match (model name starts with a known key)for model_key, pricing in provider_pricing.items():- if model_key != '_default' and model_lower.startswith(model_key):+ if model_key != "_default" and model_lower.startswith(model_key):return pricing# Try if any key is contained in the model namefor model_key, pricing in provider_pricing.items():- if model_key != '_default' and model_key in model_lower:+ if model_key != "_default" and model_key in model_lower:return pricing# Fall back to provider default- default_pricing = provider_pricing.get('_default')+ default_pricing = provider_pricing.get("_default")if default_pricing:return default_pricing@@ -163,7 +164,7 @@ class PricingService:output_tokens: int,cache_read_tokens: int = 0,cache_creation_tokens: int = 0,- reasoning_tokens: int = 0+ reasoning_tokens: int = 0,) -> Dict[str, float]:"""Calculate cost for LLM token usage.@@ -206,11 +207,11 @@ class PricingService:total_cost = input_cost + output_cost + cache_cost + reasoning_costreturn {- 'input_cost': round(input_cost, 6),- 'output_cost': round(output_cost, 6),- 'cache_cost': round(cache_cost, 6),- 'reasoning_cost': round(reasoning_cost, 6),- 'total_cost': round(total_cost, 6),+ "input_cost": round(input_cost, 6),+ "output_cost": round(output_cost, 6),+ "cache_cost": round(cache_cost, 6),+ "reasoning_cost": round(reasoning_cost, 6),+ "total_cost": round(total_cost, 6),}def get_all_pricing(self) -> Dict[str, Dict[str, Dict[str, float]]]:@@ -224,10 +225,10 @@ class PricingService:result[provider] = {}for model, pricing in models.items():result[provider][model] = {- 'input': pricing.input_per_mtok,- 'output': pricing.output_per_mtok,- 'cache_read': pricing.cache_read_per_mtok,- 'reasoning': pricing.reasoning_per_mtok,+ "input": pricing.input_per_mtok,+ "output": pricing.output_per_mtok,+ "cache_read": pricing.cache_read_per_mtok,+ "reasoning": pricing.reasoning_per_mtok,}return result@@ -245,7 +246,7 @@ class PricingService:Returns:USD cost per resource/request"""- api_config = self._config.get('api', {})+ api_config = self._config.get("api", {})service_config = api_config.get(service, {})return service_config.get(operation, 0.0)@@ -258,10 +259,10 @@ class PricingService:Returns:Dict of {operation: price} for the service"""- api_config = self._config.get('api', {})+ api_config = self._config.get("api", {})service_config = api_config.get(service, {})# Filter out metadata keys starting with _- return {k: v for k, v in service_config.items() if not k.startswith('_') and isinstance(v, (int, float))}+ return {k: v for k, v in service_config.items() if not k.startswith("_") and isinstance(v, (int, float))}def map_action_to_operation(self, service: str, action: str) -> Optional[str]:"""Map handler action to pricing operation.@@ -273,16 +274,11 @@ class PricingService:Returns:Pricing operation key or None if no mapping"""- operation_map = self._config.get('operation_map', {})+ operation_map = self._config.get("operation_map", {})service_map = operation_map.get(service, {})return service_map.get(action)- def calculate_api_cost(- self,- service: str,- action: str,- resource_count: int = 1- ) -> Dict[str, Any]:+ def calculate_api_cost(self, service: str, action: str, resource_count: int = 1) -> Dict[str, Any]:"""Calculate cost for API usage.Args:@@ -299,22 +295,12 @@ class PricingService:"""operation = self.map_action_to_operation(service, action)if not operation:- return {- 'operation': action,- 'unit_cost': 0.0,- 'resource_count': resource_count,- 'total_cost': 0.0- }+ return {"operation": action, "unit_cost": 0.0, "resource_count": resource_count, "total_cost": 0.0}unit_cost = self.get_api_price(service, operation)total_cost = unit_cost * resource_count- return {- 'operation': operation,- 'unit_cost': unit_cost,- 'resource_count': resource_count,- 'total_cost': round(total_cost, 6)- }+ return {"operation": operation, "unit_cost": unit_cost, "resource_count": resource_count, "total_cost": round(total_cost, 6)}# Singleton instancediff --git a/server/services/pricing_handlers.py b/server/services/pricing_handlers.pyindex 2ed39d09..ed5aed72 100644--- a/server/services/pricing_handlers.py+++ b/server/services/pricing_handlers.py@@ -32,7 +32,8 @@ logger = get_logger(__name__)@ws_handler()async def handle_get_pricing_config(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:"""Get full pricing configuration for display/editing."""from services.pricing import get_pricing_service@@ -43,7 +44,8 @@ async def handle_get_pricing_config(@ws_handler()async def handle_save_pricing_config(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:"""Save updated pricing configuration."""from services.pricing import get_pricing_service@@ -59,7 +61,8 @@ async def handle_save_pricing_config(@ws_handler()async def handle_get_api_usage_summary(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:"""Get aggregated API usage and cost by service (Twitter, Maps, etc.)."""database = container.database()diff --git a/server/services/process_service.py b/server/services/process_service.pyindex f7c2b4ff..e7a703c4 100644--- a/server/services/process_service.py+++ b/server/services/process_service.py@@ -96,15 +96,24 @@ class ProcessService:# Block destructive commands -- file ops should use the sandboxed shell nodecmd_lower = command.lower().strip()blocked = (- "rm ", "rm\t", "rmdir", "del ", "rd ", "remove-item",- "format ", "mkfs", "dd if=", "shred",- "> /dev/", "chmod 777", "chmod -r",+ "rm ",+ "rm\t",+ "rmdir",+ "del ",+ "rd ",+ "remove-item",+ "format ",+ "mkfs",+ "dd if=",+ "shred",+ "> /dev/",+ "chmod 777",+ "chmod -r",)if any(cmd_lower.startswith(b) or f" {b}" in f" {cmd_lower}" for b in blocked):return {"success": False,- "error": "Destructive commands blocked in process_manager. "- "Use shell_execute for file operations (sandboxed, no PATH).",+ "error": "Destructive commands blocked in process_manager. " "Use shell_execute for file operations (sandboxed, no PATH).",}name = name or f"proc_{id(command) % 100000}"@@ -132,18 +141,16 @@ class ProcessService:if resolved is None:return {"success": False,- "error": (- f"Command not found: '{argv[0] if argv else ''}'. "- "Check spelling or ensure the binary is on PATH."- ),+ "error": (f"Command not found: '{argv[0] if argv else ''}'. " "Check spelling or ensure the binary is on PATH."),}argv[0] = resolvedenv = {**os.environ, "PYTHONUNBUFFERED": "1"}from core.config import Settings+workspace_base = Path(Settings().workspace_base_resolved).resolve()if not working_directory:- working_directory = str(workspace_base / 'default')+ working_directory = str(workspace_base / "default")os.makedirs(working_directory, exist_ok=True)cwd = working_directory@@ -232,9 +239,7 @@ class ProcessService:result = self._info(managed)# Schedule cleanup after 60s to allow output reading- asyncio.get_event_loop().call_later(- 60, lambda: self._cleanup_completed(workflow_id, name)- )+ asyncio.get_event_loop().call_later(60, lambda: self._cleanup_completed(workflow_id, name))return {"success": True, "result": result}@@ -272,11 +277,7 @@ class ProcessService:def list_processes(self, workflow_id: str = "default") -> List[Dict[str, Any]]:"""List all processes for a workflow."""- return [- self._info(m)- for (wid, _), m in self._processes.items()- if wid == workflow_id- ]+ return [self._info(m) for (wid, _), m in self._processes.items() if wid == workflow_id]def get_output(self,@@ -378,9 +379,7 @@ class ProcessService:shutil.rmtree(managed.log_dir, ignore_errors=True)self._processes.clear()- async def _read_stream(- self, managed: ManagedProcess, stream: asyncio.StreamReader, stream_name: str- ) -> None:+ async def _read_stream(self, managed: ManagedProcess, stream: asyncio.StreamReader, stream_name: str) -> None:"""Background task: read lines, write to log file, broadcast to Terminal."""level = "info" if stream_name == "stdout" else "error"source = f"process:{managed.name}"@@ -405,12 +404,14 @@ class ProcessService:# Broadcast to Terminal tabif self._broadcaster:- await self._broadcaster.broadcast_terminal_log({- "timestamp": datetime.now().isoformat(),- "level": level,- "message": text,- "source": source,- })+ await self._broadcaster.broadcast_terminal_log(+ {+ "timestamp": datetime.now().isoformat(),+ "level": level,+ "message": text,+ "source": source,+ }+ )# Optional framework-level subscriber.if managed.line_handler is not None:@@ -419,7 +420,9 @@ class ProcessService:except Exception as cb_err:logger.debug("[Process] line_handler %s/%s raised: %s",- managed.name, stream_name, cb_err,+ managed.name,+ stream_name,+ cb_err,)except asyncio.CancelledError:pass@@ -436,9 +439,7 @@ class ProcessService:logger.info("[Process] Exited: %s (exit=%s)", managed.name, managed.exit_code)# Schedule auto-cleanup of log files and process entry after delay- asyncio.get_event_loop().call_later(- 60, lambda: self._cleanup_completed(managed.workflow_id, managed.name)- )+ asyncio.get_event_loop().call_later(60, lambda: self._cleanup_completed(managed.workflow_id, managed.name))@staticmethoddef _info(m: ManagedProcess) -> Dict[str, Any]:diff --git a/server/services/proxy/models.py b/server/services/proxy/models.pyindex 476fb9bf..5fdfacdb 100644--- a/server/services/proxy/models.py+++ b/server/services/proxy/models.py@@ -7,12 +7,14 @@ from pydantic import BaseModel, Fieldclass SessionType(str, Enum):"""Proxy session type controlling IP rotation behavior."""- ROTATING = "rotating" # New IP per request (default)- STICKY = "sticky" # Same IP for duration++ ROTATING = "rotating" # New IP per request (default)+ STICKY = "sticky" # Same IP for durationclass GeoTarget(BaseModel):"""Geographic targeting for proxy requests."""+country: Optional[str] = Field(default=None, description="ISO 3166-1 alpha-2 country code")city: Optional[str] = Field(default=None, description="City name")state: Optional[str] = Field(default=None, description="State/region name")@@ -20,11 +22,12 @@ class GeoTarget(BaseModel):class ProviderConfig(BaseModel):"""Configuration for a proxy provider loaded from database."""+name: strenabled: bool = True- priority: int = 50 # Lower = preferred- weight: float = 1.0 # For weighted random selection- cost_per_gb: float = 0.0 # USD per GB+ priority: int = 50 # Lower = preferred+ weight: float = 1.0 # For weighted random selection+ cost_per_gb: float = 0.0 # USD per GBgateway_host: str = ""gateway_port: int = 0geo_coverage: List[str] = Field(default_factory=list) # ISO country codes@@ -36,9 +39,10 @@ class ProviderConfig(BaseModel):class ProviderStats(BaseModel):"""Runtime health statistics for a proxy provider."""+name: str- score: float = 1.0 # 0.0 - 1.0 composite score- success_rate: float = 1.0 # 0.0 - 1.0+ score: float = 1.0 # 0.0 - 1.0 composite score+ success_rate: float = 1.0 # 0.0 - 1.0avg_latency_ms: float = 0.0total_requests: int = 0total_bytes: int = 0@@ -47,8 +51,9 @@ class ProviderStats(BaseModel):class RoutingRule(BaseModel):"""Domain-based routing rule for proxy selection."""+id: Optional[int] = None- domain_pattern: str # fnmatch glob: "*.linkedin.com", "*"+ domain_pattern: str # fnmatch glob: "*.linkedin.com", "*"preferred_providers: List[str] = Field(default_factory=list)required_country: Optional[str] = Nonesession_type: SessionType = SessionType.ROTATING@@ -56,11 +61,12 @@ class RoutingRule(BaseModel):max_retries: int = 3failover: bool = Truemin_success_rate: float = 0.7- priority: int = 0 # Lower = evaluated first+ priority: int = 0 # Lower = evaluated firstclass ProxyResult(BaseModel):"""Result of a proxied HTTP request, reported back for scoring."""+success: boollatency_ms: float = 0.0bytes_transferred: int = 0diff --git a/server/services/proxy/service.py b/server/services/proxy/service.pyindex e354223e..4f7ee7d4 100644--- a/server/services/proxy/service.py+++ b/server/services/proxy/service.py@@ -85,10 +85,10 @@ class _ProviderRuntime:freshness_score = min(1.0, len(results) / 10)score = (- _WEIGHT_SUCCESS * success_rate +- _WEIGHT_LATENCY * latency_score +- _WEIGHT_COST * cost_score +- _WEIGHT_FRESHNESS * freshness_score+ _WEIGHT_SUCCESS * success_rate+ + _WEIGHT_LATENCY * latency_score+ + _WEIGHT_COST * cost_score+ + _WEIGHT_FRESHNESS * freshness_score)return round(max(0.0, min(1.0, score)), 4)@@ -153,9 +153,7 @@ class ProxyService:self._initialized = Trueprovider_names = [p.config.name for p in self._providers.values() if p.config.enabled]- logger.info("Proxy service started",- providers=provider_names,- rules=len(self._routing_rules))+ logger.info("Proxy service started", providers=provider_names, rules=len(self._routing_rules))except Exception as e:logger.error("Failed to start proxy service", error=str(e))@@ -228,9 +226,7 @@ class ProxyService:# None unless a caller hand-passes them via the same# snake_case convention as the rest of the schema.geo = GeoTarget(- country=parameters.get("proxy_country") or- (rule.required_country if rule else None) or- self._settings.proxy_default_country,+ country=parameters.get("proxy_country") or (rule.required_country if rule else None) or self._settings.proxy_default_country,city=parameters.get("proxy_city"),state=parameters.get("proxy_state"),)@@ -254,10 +250,7 @@ class ProxyService:session_id=session_id,)- logger.debug("Proxy URL generated",- provider=runtime.config.name,- domain=domain,- country=geo.country)+ logger.debug("Proxy URL generated", provider=runtime.config.name, domain=domain, country=geo.country)return proxy_url@@ -278,7 +271,7 @@ class ProxyService:# Track daily spendif result.bytes_transferred > 0 and runtime.config.cost_per_gb > 0:- gb = result.bytes_transferred / (1024 ** 3)+ gb = result.bytes_transferred / (1024**3)self._daily_spend_usd += gb * runtime.config.cost_per_gbdef get_providers(self) -> List[ProviderStats]:@@ -355,10 +348,7 @@ class ProxyService:"daily_budget_usd": self._settings.proxy_budget_daily_usd,"total_requests": sum(p.total_requests for p in self._providers.values()),"total_bytes": sum(p.total_bytes for p in self._providers.values()),- "providers": {- name: rt.to_stats().model_dump()- for name, rt in self._providers.items()- },+ "providers": {name: rt.to_stats().model_dump() for name, rt in self._providers.items()},}def reset_daily_spend(self) -> None:@@ -369,8 +359,7 @@ class ProxyService:"""Reload provider configs from database (called after tool/UI changes)."""db_providers = await self._database.get_proxy_providers()await self._load_providers(db_providers)- logger.info("Proxy providers reloaded",- count=len(self._providers))+ logger.info("Proxy providers reloaded", count=len(self._providers))async def _load_providers(self, db_providers: list) -> None:"""Build _ProviderRuntime instances from database rows."""@@ -404,8 +393,7 @@ class ProxyService:runtime.username = usernameruntime.password = passwordelse:- logger.warning("No credentials for proxy provider",- name=config.name)+ logger.warning("No credentials for proxy provider", name=config.name)self._providers[config.name] = runtime@@ -440,10 +428,7 @@ class ProxyService:def _pick_best_provider(self) -> Optional[_ProviderRuntime]:"""Pick the best healthy provider by composite score."""- candidates = [- rt for rt in self._providers.values()- if rt.config.enabled and rt.has_credentials and rt.is_healthy()- ]+ candidates = [rt for rt in self._providers.values() if rt.config.enabled and rt.has_credentials and rt.is_healthy()]if not candidates:return None@@ -457,18 +442,20 @@ class ProxyService:db_rules = await self._database.get_proxy_routing_rules()self._routing_rules = []for row in db_rules:- self._routing_rules.append(RoutingRule(- id=row.get("id"),- domain_pattern=row["domain_pattern"],- preferred_providers=json.loads(row.get("preferred_providers", "[]")),- required_country=row.get("required_country"),- session_type=SessionType(row.get("session_type", "rotating")),- sticky_duration_seconds=row.get("sticky_duration_seconds", 300),- max_retries=row.get("max_retries", 3),- failover=row.get("failover", True),- min_success_rate=row.get("min_success_rate", 0.7),- priority=row.get("priority", 0),- ))+ self._routing_rules.append(+ RoutingRule(+ id=row.get("id"),+ domain_pattern=row["domain_pattern"],+ preferred_providers=json.loads(row.get("preferred_providers", "[]")),+ required_country=row.get("required_country"),+ session_type=SessionType(row.get("session_type", "rotating")),+ sticky_duration_seconds=row.get("sticky_duration_seconds", 300),+ max_retries=row.get("max_retries", 3),+ failover=row.get("failover", True),+ min_success_rate=row.get("min_success_rate", 0.7),+ priority=row.get("priority", 0),+ )+ )self._routing_rules.sort(key=lambda r: r.priority)diff --git a/server/services/rlm/adapters.py b/server/services/rlm/adapters.pyindex d65f6dba..b50ce766 100644--- a/server/services/rlm/adapters.py+++ b/server/services/rlm/adapters.py@@ -20,7 +20,7 @@ class BackendAdapter:@staticmethoddef adapt(provider: str, model: str, api_key: str) -> Tuple[str, Dict[str, Any]]:- backend = PROVIDER_TO_BACKEND.get(provider, 'openai')+ backend = PROVIDER_TO_BACKEND.get(provider, "openai")kwargs = {"model_name": model, "api_key": api_key}if provider in PROVIDER_BASE_URLS:kwargs["base_url"] = PROVIDER_BASE_URLS[provider]@@ -37,20 +37,21 @@ class ChatModelExtractor:@staticmethodasync def extract(tool_data: Optional[List[Dict[str, Any]]], auth) -> Tuple[List[str], List[Dict]]:from constants import AI_CHAT_MODEL_TYPES+backends, kwargs_list = [], []if not tool_data:return backends, kwargs_listfor tool_info in tool_data:- node_type = tool_info.get('node_type', '')+ node_type = tool_info.get("node_type", "")if node_type not in AI_CHAT_MODEL_TYPES:continue- params = tool_info.get('parameters', {})- provider = params.get('provider', '')- model = params.get('model', '')- api_key = params.get('api_key')+ params = tool_info.get("parameters", {})+ provider = params.get("provider", "")+ model = params.get("model", "")+ api_key = params.get("api_key")if not api_key and auth:api_key = await auth.get_api_key(provider)@@ -77,28 +78,30 @@ class ToolBridgeAdapter:# Brief descriptions for common tool types (used in RLM REPL context)TOOL_DESCRIPTIONS = {- 'calculatorTool': 'Math operations: add, subtract, multiply, divide, power, sqrt, mod, abs. Args: operation, a, b',- 'currentTimeTool': 'Get current date/time. Args: timezone (optional)',- 'duckduckgoSearch': 'Web search via DuckDuckGo. Args: query, max_results (optional)',- 'pythonExecutor': 'Execute Python code. Args: code (must set output variable)',- 'httpRequest': 'HTTP request. Args: url, method (GET/POST/PUT/DELETE), body (optional)',- 'httpRequestTool': 'HTTP request. Args: url, method (GET/POST/PUT/DELETE), body (optional)',- 'braveSearch': 'Web search via Brave. Args: query',- 'serperSearch': 'Web search via Google/Serper. Args: query',- 'perplexitySearch': 'AI-powered web search via Perplexity. Args: query',- 'crawleeScraper': 'Read/extract content from web pages. Args: url',- 'gmail': 'Send/search/read emails. Args: operation, ...',- 'calendar': 'Manage Google Calendar events. Args: operation, ...',- 'drive': 'Manage Google Drive files. Args: operation, ...',- 'sheets': 'Read/write Google Sheets. Args: operation, ...',- 'tasks': 'Manage Google Tasks. Args: operation, ...',- 'contacts': 'Manage Google Contacts. Args: operation, ...',- 'taskManager': 'Track delegated tasks. Args: operation',- 'timer': 'Wait for duration. Args: duration, unit',+ "calculatorTool": "Math operations: add, subtract, multiply, divide, power, sqrt, mod, abs. Args: operation, a, b",+ "currentTimeTool": "Get current date/time. Args: timezone (optional)",+ "duckduckgoSearch": "Web search via DuckDuckGo. Args: query, max_results (optional)",+ "pythonExecutor": "Execute Python code. Args: code (must set output variable)",+ "httpRequest": "HTTP request. Args: url, method (GET/POST/PUT/DELETE), body (optional)",+ "httpRequestTool": "HTTP request. Args: url, method (GET/POST/PUT/DELETE), body (optional)",+ "braveSearch": "Web search via Brave. Args: query",+ "serperSearch": "Web search via Google/Serper. Args: query",+ "perplexitySearch": "AI-powered web search via Perplexity. Args: query",+ "crawleeScraper": "Read/extract content from web pages. Args: url",+ "gmail": "Send/search/read emails. Args: operation, ...",+ "calendar": "Manage Google Calendar events. Args: operation, ...",+ "drive": "Manage Google Drive files. Args: operation, ...",+ "sheets": "Read/write Google Sheets. Args: operation, ...",+ "tasks": "Manage Google Tasks. Args: operation, ...",+ "contacts": "Manage Google Contacts. Args: operation, ...",+ "taskManager": "Track delegated tasks. Args: operation",+ "timer": "Wait for duration. Args: duration, unit",}@staticmethod- def bridge(tool_data: Optional[List[Dict[str, Any]]], context: Optional[Dict] = None, loop: Optional[asyncio.AbstractEventLoop] = None) -> Dict[str, Dict]:+ def bridge(+ tool_data: Optional[List[Dict[str, Any]]], context: Optional[Dict] = None, loop: Optional[asyncio.AbstractEventLoop] = None+ ) -> Dict[str, Dict]:from constants import AI_AGENT_TYPES, AI_CHAT_MODEL_TYPESfrom services.handlers.tools import execute_tool@@ -109,38 +112,38 @@ class ToolBridgeAdapter:tools = {}for tool_info in tool_data:- node_type = tool_info.get('node_type', '')+ node_type = tool_info.get("node_type", "")# Skip agents (delegation) and chat models (handled by ChatModelExtractor)if node_type in AI_AGENT_TYPES or node_type in AI_CHAT_MODEL_TYPES:continue- node_id = tool_info.get('node_id', '')- label = tool_info.get('label', node_type)- params = tool_info.get('parameters', {})+ node_id = tool_info.get("node_id", "")+ label = tool_info.get("label", node_type)+ params = tool_info.get("parameters", {})def _make_sync_wrapper(t_type, t_id, t_params, t_label):def wrapper(**kwargs):config = {- 'node_type': t_type,- 'node_id': t_id,- 'parameters': t_params,- 'label': t_label,+ "node_type": t_type,+ "node_id": t_id,+ "parameters": t_params,+ "label": t_label,}if context:- config['nodes'] = context.get('nodes', [])- config['edges'] = context.get('edges', [])+ config["nodes"] = context.get("nodes", [])+ config["edges"] = context.get("edges", [])future = asyncio.run_coroutine_threadsafe(- execute_tool(t_label, kwargs, config), main_loop,+ execute_tool(t_label, kwargs, config),+ main_loop,)return future.result(timeout=60)+return wrapper# Clean tool name (same pattern as _build_tool_from_node ai.py:2567)- tool_name = re.sub(r'[^a-zA-Z0-9_]', '_', label.lower().replace(' ', '_'))- description = ToolBridgeAdapter.TOOL_DESCRIPTIONS.get(- node_type, f"Execute {label} ({node_type})"- )+ tool_name = re.sub(r"[^a-zA-Z0-9_]", "_", label.lower().replace(" ", "_"))+ description = ToolBridgeAdapter.TOOL_DESCRIPTIONS.get(node_type, f"Execute {label} ({node_type})")tools[tool_name] = {"tool": _make_sync_wrapper(node_type, node_id, params, label),diff --git a/server/services/rlm/constants.py b/server/services/rlm/constants.pyindex b7d7958c..21734291 100644--- a/server/services/rlm/constants.py+++ b/server/services/rlm/constants.py@@ -2,19 +2,19 @@# MachinaOS provider -> RLM backend mappingPROVIDER_TO_BACKEND = {- 'openai': 'openai',- 'anthropic': 'anthropic',- 'gemini': 'gemini',- 'groq': 'openai',- 'openrouter': 'openrouter',- 'cerebras': 'openai',+ "openai": "openai",+ "anthropic": "anthropic",+ "gemini": "gemini",+ "groq": "openai",+ "openrouter": "openrouter",+ "cerebras": "openai",}# Base URLs for OpenAI-compatible providersPROVIDER_BASE_URLS = {- 'groq': 'https://api.groq.com/openai/v1',- 'openrouter': 'https://openrouter.ai/api/v1',- 'cerebras': 'https://api.cerebras.ai/v1',+ "groq": "https://api.groq.com/openai/v1",+ "openrouter": "https://openrouter.ai/api/v1",+ "cerebras": "https://api.cerebras.ai/v1",}# Default RLM execution parametersdiff --git a/server/services/rlm/service.py b/server/services/rlm/service.pyindex 182b471c..835f96e7 100644--- a/server/services/rlm/service.py+++ b/server/services/rlm/service.py@@ -46,34 +46,34 @@ class RLMService:async def broadcast_status(phase: str, details: Dict[str, Any] = None):if broadcaster:- await broadcaster.update_node_status(node_id, "executing", {- "phase": phase, "agent_type": "rlm", **(details or {})- }, workflow_id=workflow_id)+ await broadcaster.update_node_status(+ node_id, "executing", {"phase": phase, "agent_type": "rlm", **(details or {})}, workflow_id=workflow_id+ )try:# === Parameter extraction (same pattern as execute_chat_agent) ===- prompt = parameters.get('prompt', '')- system_message = parameters.get('system_message', '')+ prompt = parameters.get("prompt", "")+ system_message = parameters.get("system_message", "")# Skill injection (reuse ai.py:833 _build_skill_system_prompt)# Collected as supplementary context -- appended to RLM prompt, never replaces itfrom services.ai import _build_skill_system_prompt+supplementary_context = ""- skill_prompt, has_personality = _build_skill_system_prompt(- skill_data, log_prefix="[RLM]"- )+ skill_prompt, has_personality = _build_skill_system_prompt(skill_data, log_prefix="[RLM]")if skill_prompt:supplementary_context += f"\n\n## Skill Instructions\n{skill_prompt}"# Options flattening (same as execute_chat_agent line 1995)- options = parameters.get('options', {})+ options = parameters.get("options", {})flattened = {**parameters, **options}# Provider/model/API key resolution (same as lines 1998-2014)from services.ai import is_model_valid_for_provider, get_default_model_async- api_key = flattened.get('api_key')- provider = parameters.get('provider', 'openai')- model = parameters.get('model', '')++ api_key = flattened.get("api_key")+ provider = parameters.get("provider", "openai")+ model = parameters.get("model", "")if not model or not is_model_valid_for_provider(model, provider):model = await get_default_model_async(provider, database)@@ -83,45 +83,49 @@ class RLMService:if not api_key:raise ValueError(f"API key required for RLM Agent (provider: {provider})")- await broadcast_status("initializing", {- "message": f"Initializing RLM with {provider}/{model}",- "provider": provider, "model": model,- })+ await broadcast_status(+ "initializing",+ {+ "message": f"Initializing RLM with {provider}/{model}",+ "provider": provider,+ "model": model,+ },+ )# === Memory injection (appended to supplementary context, not system prompt) ===- if memory_data and memory_data.get('memory_content'):- memory_text = memory_data['memory_content']+ if memory_data and memory_data.get("memory_content"):+ memory_text = memory_data["memory_content"]supplementary_context += f"\n\n## Conversation History\n{memory_text}"# === Adapter: Map provider to RLM backend ===backend, backend_kwargs = BackendAdapter.adapt(provider, model, api_key)# === Adapter: Extract chat model nodes as other_backends ===- other_backends, other_backend_kwargs = await ChatModelExtractor.extract(- tool_data, self.auth- )+ other_backends, other_backend_kwargs = await ChatModelExtractor.extract(tool_data, self.auth)# === Adapter: Bridge tool nodes as RLM custom_tools ===- await broadcast_status("building_tools", {- "message": "Bridging connected tools..."- })+ await broadcast_status("building_tools", {"message": "Bridging connected tools..."})running_loop = asyncio.get_running_loop()custom_tools = ToolBridgeAdapter.bridge(tool_data, context, loop=running_loop)# === RLM-specific parameters ===- max_iterations = int(flattened.get('max_iterations', DEFAULT_MAX_ITERATIONS))- max_depth = int(flattened.get('max_depth', DEFAULT_MAX_DEPTH))- max_budget = flattened.get('max_budget')- max_timeout = flattened.get('max_timeout')- max_tokens = flattened.get('max_tokens')- verbose = flattened.get('verbose', DEFAULT_VERBOSE)+ max_iterations = int(flattened.get("max_iterations", DEFAULT_MAX_ITERATIONS))+ max_depth = int(flattened.get("max_depth", DEFAULT_MAX_DEPTH))+ max_budget = flattened.get("max_budget")+ max_timeout = flattened.get("max_timeout")+ max_tokens = flattened.get("max_tokens")+ verbose = flattened.get("verbose", DEFAULT_VERBOSE)# === Run RLM in thread pool (RLM is synchronous) ===- await broadcast_status("executing", {- "message": f"RLM executing (max {max_iterations} iterations)...",- "max_iterations": max_iterations, "max_depth": max_depth,- "tool_count": len(custom_tools),- })+ await broadcast_status(+ "executing",+ {+ "message": f"RLM executing (max {max_iterations} iterations)...",+ "max_iterations": max_iterations,+ "max_depth": max_depth,+ "tool_count": len(custom_tools),+ },+ )# Build augmented prompt: MachinaOS context prepended to user prompt.# We do NOT pass custom_system_prompt to RLM because RLM_SYSTEM_PROMPT@@ -140,36 +144,44 @@ class RLMService:def _run_rlm():from rlm import RLMfrom rlm.logger import RLMLogger+rlm_instance = RLM(- backend=backend, backend_kwargs=backend_kwargs,+ backend=backend,+ backend_kwargs=backend_kwargs,environment="local",other_backends=other_backends if other_backends else None,other_backend_kwargs=other_backend_kwargs if other_backend_kwargs else None,- max_iterations=max_iterations, max_depth=max_depth,+ max_iterations=max_iterations,+ max_depth=max_depth,max_budget=float(max_budget) if max_budget else None,max_timeout=float(max_timeout) if max_timeout else None,max_tokens=int(max_tokens) if max_tokens else None,custom_tools=custom_tools if custom_tools else None,- logger=RLMLogger(), verbose=verbose,+ logger=RLMLogger(),+ verbose=verbose,)return rlm_instance.completion(augmented_prompt)result = await asyncio.to_thread(_run_rlm)# === Memory save (same pattern as execute_chat_agent) ===- if memory_data and memory_data.get('node_id'):+ if memory_data and memory_data.get("node_id"):from services.memory_store import add_message- session_id = memory_data.get('session_id', 'default')++ session_id = memory_data.get("session_id", "default")add_message(session_id, "user", prompt)add_message(session_id, "assistant", result.response or "")execution_time = time.time() - start_timeiterations = len(result.metadata.get("iterations", [])) if result.metadata else 0- await broadcast_status("completed", {- "message": f"RLM completed in {execution_time:.1f}s",- "iterations": iterations,- })+ await broadcast_status(+ "completed",+ {+ "message": f"RLM completed in {execution_time:.1f}s",+ "iterations": iterations,+ },+ )return {"success": True,diff --git a/server/services/scheduler.py b/server/services/scheduler.pyindex faf4277d..d10c730e 100644--- a/server/services/scheduler.py+++ b/server/services/scheduler.py@@ -2,6 +2,7 @@Cron Scheduler Service using APScheduler.Manages scheduled jobs for workflow automation."""+from apscheduler.schedulers.asyncio import AsyncIOSchedulerfrom apscheduler.triggers.cron import CronTriggerfrom apscheduler.jobstores.base import JobLookupError@@ -37,13 +38,7 @@ def shutdown_scheduler():logger.info("[Scheduler] Shutdown")-def register_cron_job(- job_id: str,- cron_expression: str,- callback: Callable,- timezone: str = "UTC",- **kwargs-) -> str:+def register_cron_job(job_id: str, cron_expression: str, callback: Callable, timezone: str = "UTC", **kwargs) -> str:"""Register a cron job with the scheduler.@@ -66,35 +61,17 @@ def register_cron_job(if len(parts) >= 6:# 6-field format: second minute hour day month weekdaytrigger = CronTrigger(- second=parts[0],- minute=parts[1],- hour=parts[2],- day=parts[3],- month=parts[4],- day_of_week=parts[5],- timezone=timezone+ second=parts[0], minute=parts[1], hour=parts[2], day=parts[3], month=parts[4], day_of_week=parts[5], timezone=timezone)else:# 5-field format: minute hour day month weekday (default second=0)if len(parts) < 5:- parts.extend(['*'] * (5 - len(parts)))+ parts.extend(["*"] * (5 - len(parts)))trigger = CronTrigger(- second='0',- minute=parts[0],- hour=parts[1],- day=parts[2],- month=parts[3],- day_of_week=parts[4],- timezone=timezone+ second="0", minute=parts[0], hour=parts[1], day=parts[2], month=parts[3], day_of_week=parts[4], timezone=timezone)- scheduler.add_job(- callback,- trigger=trigger,- id=job_id,- replace_existing=True,- kwargs=kwargs- )+ scheduler.add_job(callback, trigger=trigger, id=job_id, replace_existing=True, kwargs=kwargs)logger.info(f"[Scheduler] Registered cron job: {job_id} with expression: {cron_expression}")return job_id@@ -133,11 +110,7 @@ def get_job_info(job_id: str) -> Optional[Dict]:scheduler = get_scheduler()job = scheduler.get_job(job_id)if job:- return {- "id": job.id,- "next_run_time": job.next_run_time.isoformat() if job.next_run_time else None,- "trigger": str(job.trigger)- }+ return {"id": job.id, "next_run_time": job.next_run_time.isoformat() if job.next_run_time else None, "trigger": str(job.trigger)}return None@@ -146,10 +119,6 @@ def get_all_jobs() -> list:scheduler = get_scheduler()jobs = scheduler.get_jobs()return [- {- "id": job.id,- "next_run_time": job.next_run_time.isoformat() if job.next_run_time else None,- "trigger": str(job.trigger)- }+ {"id": job.id, "next_run_time": job.next_run_time.isoformat() if job.next_run_time else None, "trigger": str(job.trigger)}for job in jobs]diff --git a/server/services/settings/handlers.py b/server/services/settings/handlers.pyindex 742ea35b..9c382d23 100644--- a/server/services/settings/handlers.py+++ b/server/services/settings/handlers.py@@ -61,6 +61,7 @@ async def handle_save_user_settings(data: Dict[str, Any], websocket: WebSocket)if success:if "max_processes" in settings_data:from services.process_service import get_process_service+get_process_service().max_processes = int(settings_data["max_processes"])settings = await database.get_user_settings(user_id)@@ -117,7 +118,8 @@ async def handle_save_provider_defaults(data: Dict[str, Any], websocket: WebSock@ws_handler()async def handle_get_validated_ai_providers(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:"""Get all AI providers with stored API keys and their popular models.@@ -133,6 +135,7 @@ async def handle_get_validated_ai_providers(database = container.database()from services.ai import PROVIDER_CONFIGS+AI_PROVIDERS = list(PROVIDER_CONFIGS.keys())defaults_path = Path(__file__).parent.parent.parent / "config" / "llm_defaults.json"@@ -152,21 +155,20 @@ async def handle_get_validated_ai_providers(provider_config = llm_defaults.get("providers", {}).get(provider, {})default_model = provider_config.get("default_model", "")- popular_models = [- m for m in provider_config.get("max_output_tokens", {}).keys()- if m != "_default"- ]+ popular_models = [m for m in provider_config.get("max_output_tokens", {}).keys() if m != "_default"]provider_defaults = await database.get_provider_defaults(provider)if provider_defaults and provider_defaults.get("default_model"):default_model = provider_defaults["default_model"]- providers.append({- "provider": provider,- "models": stored_models or [],- "popular_models": popular_models,- "default_model": default_model,- })+ providers.append(+ {+ "provider": provider,+ "models": stored_models or [],+ "popular_models": popular_models,+ "default_model": default_model,+ }+ )user_id = data.get("user_id", "default")settings = await database.get_user_settings(user_id)@@ -190,10 +192,13 @@ async def handle_save_global_model(data: Dict[str, Any], websocket: WebSocket) -model = data.get("model", "")user_id = data.get("user_id", "default")- success = await database.save_user_settings({- "default_llm_provider": provider,- "default_llm_model": model,- }, user_id)+ success = await database.save_user_settings(+ {+ "default_llm_provider": provider,+ "default_llm_model": model,+ },+ user_id,+ )return {"success": success, "provider": provider, "model": model}diff --git a/server/services/skill_loader.py b/server/services/skill_loader.pyindex d22fd2ff..0755ce6d 100644--- a/server/services/skill_loader.py+++ b/server/services/skill_loader.py@@ -18,6 +18,7 @@ logger = get_logger(__name__)@dataclassclass SkillMetadata:"""Metadata from SKILL.md frontmatter (loaded at startup for all skills)."""+name: strdescription: strallowed_tools: List[str] = field(default_factory=list)@@ -28,6 +29,7 @@ class SkillMetadata:@dataclassclass Skill:"""Full skill content (loaded on-demand when activated)."""+metadata: SkillMetadatainstructions: str # Markdown body after frontmatterscripts: Dict[str, str] = field(default_factory=dict) # filename -> content@@ -103,11 +105,12 @@ class SkillLoader:for skill in user_skills:allowed_tools = []if skill.allowed_tools:- allowed_tools = [t.strip() for t in skill.allowed_tools.split(',')]+ allowed_tools = [t.strip() for t in skill.allowed_tools.split(",")]metadata_dict = {}if skill.metadata_json:import json+metadata_dict = json.loads(skill.metadata_json)self._registry[skill.name] = SkillMetadata(@@ -115,7 +118,7 @@ class SkillLoader:description=skill.description,allowed_tools=allowed_tools,metadata=metadata_dict,- path=None # Database skills have no path+ path=None, # Database skills have no path)logger.info(f"[SkillLoader] Loaded {len(user_skills)} skills from database")except Exception as e:@@ -133,10 +136,10 @@ class SkillLoader:becomes the visual source. This guarantees skills mirrortheir teaching node's icon / color without per-file drift."""- content = skill_md_path.read_text(encoding='utf-8')+ content = skill_md_path.read_text(encoding="utf-8")# Parse YAML frontmatter (between --- markers)- frontmatter_match = re.match(r'^---\s*\n(.*?)\n---\s*\n', content, re.DOTALL)+ frontmatter_match = re.match(r"^---\s*\n(.*?)\n---\s*\n", content, re.DOTALL)if not frontmatter_match:logger.warning(f"[SkillLoader] No frontmatter in {skill_md_path}")return None@@ -148,22 +151,22 @@ class SkillLoader:return None# Validate required fields- name = frontmatter.get('name')- description = frontmatter.get('description')+ name = frontmatter.get("name")+ description = frontmatter.get("description")if not name or not description:logger.warning(f"[SkillLoader] Missing name or description in {skill_md_path}")return None# Validate name format (lowercase, hyphens, no consecutive hyphens)- if not re.match(r'^[a-z0-9]+(-[a-z0-9]+)*$', name):+ if not re.match(r"^[a-z0-9]+(-[a-z0-9]+)*$", name):logger.warning(f"[SkillLoader] Invalid skill name format: {name}")return None# Parse allowed-tools (space-delimited)allowed_tools = []- if 'allowed-tools' in frontmatter:- allowed_tools = frontmatter['allowed-tools'].split()+ if "allowed-tools" in frontmatter:+ allowed_tools = frontmatter["allowed-tools"].split()# Resolve icon + color from the target node, mirroring# ``BaseNode._metadata_dict``'s chain so skills inherit whichever@@ -175,13 +178,15 @@ class SkillLoader:# Color: ``<plugin>/meta.json`` first, then ``visuals.json``.# ``allowed-tools`` uses snake_case; node ``type`` is camelCase.from nodes._visuals import (- get_color, get_icon, get_plugin_icon_path, get_plugin_meta,+ get_color,+ get_icon,+ get_plugin_icon_path,+ get_plugin_meta,)- meta_in = dict(frontmatter.get('metadata') or {})++ meta_in = dict(frontmatter.get("metadata") or {})for tok in allowed_tools:- cam = tok if "_" not in tok else (- tok.split("_")[0] + "".join(p.title() for p in tok.split("_")[1:])- )+ cam = tok if "_" not in tok else (tok.split("_")[0] + "".join(p.title() for p in tok.split("_")[1:]))for candidate in (cam, tok):if get_plugin_icon_path(candidate) is not None:icon = f"/api/schemas/nodes/{candidate}/icon"@@ -190,9 +195,9 @@ class SkillLoader:color = get_plugin_meta(candidate, "color") or get_color(candidate)if icon or color:if icon:- meta_in['icon'] = icon+ meta_in["icon"] = iconif color:- meta_in['color'] = color+ meta_in["color"] = colorbreakelse:continue@@ -238,12 +243,12 @@ class SkillLoader:return None# Parse full content- content = skill_md.read_text(encoding='utf-8')+ content = skill_md.read_text(encoding="utf-8")# Extract body (after frontmatter)- frontmatter_match = re.match(r'^---\s*\n.*?\n---\s*\n', content, re.DOTALL)+ frontmatter_match = re.match(r"^---\s*\n.*?\n---\s*\n", content, re.DOTALL)if frontmatter_match:- instructions = content[frontmatter_match.end():]+ instructions = content[frontmatter_match.end() :]else:instructions = content@@ -254,7 +259,7 @@ class SkillLoader:for script_file in scripts_dir.iterdir():if script_file.is_file():try:- scripts[script_file.name] = script_file.read_text(encoding='utf-8')+ scripts[script_file.name] = script_file.read_text(encoding="utf-8")except Exception as e:logger.warning(f"[SkillLoader] Failed to read script {script_file}: {e}")@@ -263,18 +268,13 @@ class SkillLoader:refs_dir = skill_path / "references"if refs_dir.exists():for ref_file in refs_dir.iterdir():- if ref_file.is_file() and ref_file.suffix in ['.md', '.txt', '.json']:+ if ref_file.is_file() and ref_file.suffix in [".md", ".txt", ".json"]:try:- references[ref_file.name] = ref_file.read_text(encoding='utf-8')+ references[ref_file.name] = ref_file.read_text(encoding="utf-8")except Exception as e:logger.warning(f"[SkillLoader] Failed to read reference {ref_file}: {e}")- skill = Skill(- metadata=metadata,- instructions=instructions,- scripts=scripts,- references=references- )+ skill = Skill(metadata=metadata, instructions=instructions, scripts=scripts, references=references)# Cache the loaded skillself._cache[name] = skill@@ -312,32 +312,28 @@ class SkillLoader:user_skill = await self._database.get_user_skill(name)if user_skill:# user_skill is a dict from _skill_to_dict()- allowed_tools = user_skill.get('allowed_tools', [])+ allowed_tools = user_skill.get("allowed_tools", [])if isinstance(allowed_tools, str):- allowed_tools = [t.strip() for t in allowed_tools.split(',') if t.strip()]+ allowed_tools = [t.strip() for t in allowed_tools.split(",") if t.strip()]- metadata_dict = user_skill.get('metadata', {})+ metadata_dict = user_skill.get("metadata", {})if isinstance(metadata_dict, str):import json+try:metadata_dict = json.loads(metadata_dict) if metadata_dict else {}except json.JSONDecodeError:metadata_dict = {}metadata = SkillMetadata(- name=user_skill.get('name', name),- description=user_skill.get('description', ''),+ name=user_skill.get("name", name),+ description=user_skill.get("description", ""),allowed_tools=allowed_tools,metadata=metadata_dict,- path=None+ path=None,)- skill = Skill(- metadata=metadata,- instructions=user_skill.get('instructions', ''),- scripts={},- references={}- )+ skill = Skill(metadata=metadata, instructions=user_skill.get("instructions", ""), scripts={}, references={})logger.info(f"[SkillLoader] Loaded user skill from database: {name}")self._cache[name] = skill@@ -403,7 +399,7 @@ class SkillLoader:"description": metadata.description,"allowed_tools": metadata.allowed_tools,"metadata": metadata.metadata,- "is_builtin": metadata.path is not None+ "is_builtin": metadata.path is not None,}for metadata in self._registry.values()]diff --git a/server/services/skill_prompt.py b/server/services/skill_prompt.pyindex 6a21c30d..986ebf93 100644--- a/server/services/skill_prompt.py+++ b/server/services/skill_prompt.py@@ -39,12 +39,12 @@ def build_skill_system_prompt(skill_data: List[Dict[str, Any]], log_prefix: strnon_personality_names = []for skill_info in skill_data:- skill_name = skill_info.get('skill_name') or skill_info.get('node_type', '').replace('Skill', '-skill').lower()- if skill_name.endswith('skill') and '-' not in skill_name:- skill_name = skill_name[:-5] + '-skill'+ skill_name = skill_info.get("skill_name") or skill_info.get("node_type", "").replace("Skill", "-skill").lower()+ if skill_name.endswith("skill") and "-" not in skill_name:+ skill_name = skill_name[:-5] + "-skill"- if skill_name.endswith('-personality'):- instructions = skill_info.get('parameters', {}).get('instructions', '')+ if skill_name.endswith("-personality"):+ instructions = skill_info.get("parameters", {}).get("instructions", "")if instructions:personality_blocks.append(instructions)logger.debug(f"{log_prefix} Personality skill injected (full): {skill_name}")@@ -65,6 +65,8 @@ def build_skill_system_prompt(skill_data: List[Dict[str, Any]], log_prefix: strparts.append(registry_prompt)if parts:- logger.debug(f"{log_prefix} Enhanced system message: {len(personality_blocks)} personality, {len(non_personality_names)} standard skills")+ logger.debug(+ f"{log_prefix} Enhanced system message: {len(personality_blocks)} personality, {len(non_personality_names)} standard skills"+ )return "\n\n".join(parts), len(personality_blocks) > 0diff --git a/server/services/skills/handlers.py b/server/services/skills/handlers.pyindex a8c77fb7..babf13e6 100644--- a/server/services/skills/handlers.py+++ b/server/services/skills/handlers.py@@ -95,8 +95,11 @@ async def handle_save_skill_content(data: Dict[str, Any], websocket: WebSocket)skill_loader.clear_cache()from nodes.skill.master_skill._events import broadcast_skill_lifecycle+await broadcast_skill_lifecycle(- "content_saved", name=skill_name, is_builtin=True,+ "content_saved",+ name=skill_name,+ is_builtin=True,)logger.info(f"[Skills] Updated built-in skill: {skill_name}")return {@@ -116,8 +119,11 @@ async def handle_save_skill_content(data: Dict[str, Any], websocket: WebSocket))if updated:from nodes.skill.master_skill._events import broadcast_skill_lifecycle+await broadcast_skill_lifecycle(- "content_saved", name=skill_name, is_builtin=False,+ "content_saved",+ name=skill_name,+ is_builtin=False,)logger.info(f"[Skills] Updated user skill: {skill_name}")return {@@ -171,10 +177,12 @@ async def handle_list_skill_folders(data: Dict[str, Any], websocket: WebSocket)for item in sorted(skills_dir.iterdir()):if item.is_dir() and not item.name.startswith("."):skill_count = len(list(item.rglob("SKILL.md")))- folders.append({- "name": item.name,- "skill_count": skill_count,- })+ folders.append(+ {+ "name": item.name,+ "skill_count": skill_count,+ }+ )return {"success": True, "folders": folders}@@ -205,18 +213,21 @@ async def handle_scan_skill_folder(data: Dict[str, Any], websocket: WebSocket) -metadata.path = skill_md.parentskill_loader._registry[metadata.name] = metadata- skills.append({- "name": metadata.name,- "description": metadata.description,- "metadata": metadata.metadata,- })+ skills.append(+ {+ "name": metadata.name,+ "description": metadata.description,+ "metadata": metadata.metadata,+ }+ )return {"success": True, "skills": skills, "folder": folder}@ws_handler()async def handle_lookup_skill_metadata(- data: Dict[str, Any], websocket: WebSocket,+ data: Dict[str, Any],+ websocket: WebSocket,) -> Dict[str, Any]:"""Look up SKILL.md metadata for a list of skill names across everyfolder (and the user-skills DB).@@ -241,11 +252,13 @@ async def handle_lookup_skill_metadata(for name in names:meta = skill_loader._registry.get(name)if meta:- skills.append({- "name": meta.name,- "description": meta.description,- "metadata": meta.metadata,- })+ skills.append(+ {+ "name": meta.name,+ "description": meta.description,+ "metadata": meta.metadata,+ }+ )return {"success": True, "skills": skills}@@ -409,7 +422,7 @@ async def handle_reset_skill(data: Dict[str, Any], websocket: WebSocket) -> Dictfrontmatter_match = re.match(r"^---\s*\n.*?\n---\s*\n", content, re.DOTALL)if frontmatter_match:- original_instructions = content[frontmatter_match.end():]+ original_instructions = content[frontmatter_match.end() :]else:original_instructions = contentdiff --git a/server/services/status_broadcaster.py b/server/services/status_broadcaster.pyindex 597db624..8a50dc06 100644--- a/server/services/status_broadcaster.py+++ b/server/services/status_broadcaster.py@@ -44,53 +44,22 @@ class StatusBroadcaster:"connected_devices": [],"connection_type": None,"qr_data": None,- "session_token": None- },- "whatsapp": {- "connected": False,- "has_session": False,- "running": False,- "pairing": False,- "device_id": None,- "qr": None- },- "twitter": {- "connected": False,- "username": None,- "user_id": None,- "name": None,- "profile_image_url": None+ "session_token": None,},+ "whatsapp": {"connected": False, "has_session": False, "running": False, "pairing": False, "device_id": None, "qr": None},+ "twitter": {"connected": False, "username": None, "user_id": None, "name": None, "profile_image_url": None},"google": {"connected": False,"email": None,"name": None,},- "telegram": {- "connected": False,- "bot_id": None,- "bot_username": None,- "bot_name": None- },+ "telegram": {"connected": False, "bot_id": None, "bot_username": None, "bot_name": None},"api_keys": {}, # provider -> validation status"nodes": {}, # node_id -> node status"variables": {}, # variable_name -> value- "workflow": {- "executing": False,- "current_node": None- },- "workflow_lock": {- "locked": False,- "workflow_id": None,- "locked_at": None,- "reason": None- },- "deployment": {- "isRunning": False,- "activeRuns": 0,- "status": "idle",- "workflow_id": None- }+ "workflow": {"executing": False, "current_node": None},+ "workflow_lock": {"locked": False, "workflow_id": None, "locked_at": None, "reason": None},+ "deployment": {"isRunning": False, "activeRuns": 0, "status": "idle", "workflow_id": None},}async def connect(self, websocket: WebSocket):@@ -113,10 +82,7 @@ class StatusBroadcaster:logger.info(f"[StatusBroadcaster] Client connected. Total: {len(self._connections)}")try:- await websocket.send_json({- "type": "initial_status",- "data": self._status- })+ await websocket.send_json({"type": "initial_status", "data": self._status})except Exception as e:logger.error(f"[StatusBroadcaster] Failed to send initial status: {e}")@@ -155,10 +121,12 @@ class StatusBroadcaster:returnevent = WorkflowEvent.deployment_snapshot(running_ids)- await websocket.send_json({- "type": "deployment_snapshot",- "data": event.model_dump(mode="json"),- })+ await websocket.send_json(+ {+ "type": "deployment_snapshot",+ "data": event.model_dump(mode="json"),+ }+ )async def disconnect(self, websocket: WebSocket):"""Remove a WebSocket connection."""@@ -244,12 +212,7 @@ class StatusBroadcaster:# =========================================================================async def update_api_key_status(- self,- provider: str,- valid: bool,- message: Optional[str] = None,- has_key: bool = True,- models: Optional[List[str]] = None+ self, provider: str, valid: bool, message: Optional[str] = None, has_key: bool = True, models: Optional[List[str]] = None):"""Update API key validation status and broadcast."""self._status["api_keys"][provider] = {@@ -257,14 +220,10 @@ class StatusBroadcaster:"hasKey": has_key,"message": message,"models": models or [],- "timestamp": asyncio.get_event_loop().time()+ "timestamp": asyncio.get_event_loop().time(),}- await self.broadcast({- "type": "api_key_status",- "provider": provider,- "data": self._status["api_keys"][provider]- })+ await self.broadcast({"type": "api_key_status", "provider": provider, "data": self._status["api_keys"][provider]})def get_api_key_status(self, provider: str) -> Optional[Dict[str, Any]]:"""Get API key validation status for a provider."""@@ -323,10 +282,12 @@ class StatusBroadcaster:},)- await self.broadcast({- "type": "credential_catalogue_updated",- "data": event.model_dump(mode="json"),- })+ await self.broadcast(+ {+ "type": "credential_catalogue_updated",+ "data": event.model_dump(mode="json"),+ }+ )async def broadcast_workflow_lifecycle(self,@@ -351,10 +312,12 @@ class StatusBroadcaster:workflow_id=workflow_id,data=data_extra or None,)- await self.broadcast({- "type": "workflow_lifecycle",- "data": event.model_dump(mode="json"),- })+ await self.broadcast(+ {+ "type": "workflow_lifecycle",+ "data": event.model_dump(mode="json"),+ }+ )async def broadcast_node_parameters_updated(self,@@ -391,10 +354,12 @@ class StatusBroadcaster:version=version,source_hint=source_hint,)- await self.broadcast({- "type": "node_parameters_updated",- "data": event.model_dump(mode="json"),- })+ await self.broadcast(+ {+ "type": "node_parameters_updated",+ "data": event.model_dump(mode="json"),+ }+ )async def broadcast_agent_progress(self,@@ -424,10 +389,12 @@ class StatusBroadcaster:phase=phase,)- await self.broadcast({- "type": "agent_progress",- "data": event.model_dump(mode="json"),- })+ await self.broadcast(+ {+ "type": "agent_progress",+ "data": event.model_dump(mode="json"),+ }+ )async def broadcast_claude_session_spawned(self,@@ -449,10 +416,12 @@ class StatusBroadcaster:pid=pid,workflow_id=workflow_id,)- await self.broadcast({- "type": "claude_session_event",- "data": event.model_dump(mode="json"),- })+ await self.broadcast(+ {+ "type": "claude_session_event",+ "data": event.model_dump(mode="json"),+ }+ )async def broadcast_claude_session_cleared(self,@@ -473,10 +442,12 @@ class StatusBroadcaster:new_session_uuid=new_session_uuid,workflow_id=workflow_id,)- await self.broadcast({- "type": "claude_session_event",- "data": event.model_dump(mode="json"),- })+ await self.broadcast(+ {+ "type": "claude_session_event",+ "data": event.model_dump(mode="json"),+ }+ )async def broadcast_claude_session_terminated(self,@@ -498,10 +469,12 @@ class StatusBroadcaster:session_uuid=session_uuid,workflow_id=workflow_id,)- await self.broadcast({- "type": "claude_session_event",- "data": event.model_dump(mode="json"),- })+ await self.broadcast(+ {+ "type": "claude_session_event",+ "data": event.model_dump(mode="json"),+ }+ )async def broadcast_claude_session_usage(self,@@ -535,10 +508,12 @@ class StatusBroadcaster:num_turns=num_turns,workflow_id=workflow_id,)- await self.broadcast({- "type": "claude_session_usage",- "data": event.model_dump(mode="json"),- })+ await self.broadcast(+ {+ "type": "claude_session_usage",+ "data": event.model_dump(mode="json"),+ }+ )# =========================================================================# Android Status Updates@@ -586,7 +561,7 @@ class StatusBroadcaster:node_id: str,status: str, # "idle", "executing", "waiting", "success", "error"data: Optional[Dict[str, Any]] = None,- workflow_id: Optional[str] = None+ workflow_id: Optional[str] = None,):"""Update a specific node's status and broadcast.@@ -596,27 +571,21 @@ class StatusBroadcaster:data: Optional status dataworkflow_id: Optional workflow ID to scope the status update (n8n pattern)"""- logger.debug(f"[BROADCAST] update_node_status: node={node_id}, status={status}, workflow={workflow_id}, connections={len(self._connections)}")+ logger.debug(+ f"[BROADCAST] update_node_status: node={node_id}, status={status}, workflow={workflow_id}, connections={len(self._connections)}"+ )self._status["nodes"][node_id] = {"status": status,"data": data or {},"timestamp": asyncio.get_event_loop().time(),- "workflow_id": workflow_id+ "workflow_id": workflow_id,}- await self.broadcast({- "type": "node_status",- "node_id": node_id,- "workflow_id": workflow_id,- "data": self._status["nodes"][node_id]- })+ await self.broadcast(+ {"type": "node_status", "node_id": node_id, "workflow_id": workflow_id, "data": self._status["nodes"][node_id]}+ )- async def update_node_output(- self,- node_id: str,- output: Any,- workflow_id: Optional[str] = None- ):+ async def update_node_output(self, node_id: str, output: Any, workflow_id: Optional[str] = None):"""Update a node's output data and broadcast."""if node_id not in self._status["nodes"]:self._status["nodes"][node_id] = {"status": "idle", "data": {}}@@ -625,12 +594,7 @@ class StatusBroadcaster:if workflow_id:self._status["nodes"][node_id]["workflow_id"] = workflow_id- await self.broadcast({- "type": "node_output",- "node_id": node_id,- "workflow_id": workflow_id,- "output": output- })+ await self.broadcast({"type": "node_output", "node_id": node_id, "workflow_id": workflow_id, "output": output})# =========================================================================# Variable Updates@@ -640,20 +604,13 @@ class StatusBroadcaster:"""Update a workflow variable and broadcast."""self._status["variables"][name] = value- await self.broadcast({- "type": "variable_update",- "name": name,- "value": value- })+ await self.broadcast({"type": "variable_update", "name": name, "value": value})async def update_variables(self, variables: Dict[str, Any]):"""Update multiple variables at once and broadcast."""self._status["variables"].update(variables)- await self.broadcast({- "type": "variables_update",- "variables": variables- })+ await self.broadcast({"type": "variables_update", "variables": variables})# =========================================================================# Workflow Status Updates@@ -692,11 +649,13 @@ class StatusBroadcaster:"progress": progress,}- await self.broadcast({- "type": "workflow_status",- "workflow_id": workflow_id,- "data": payload,- })+ await self.broadcast(+ {+ "type": "workflow_status",+ "workflow_id": workflow_id,+ "data": payload,+ }+ )async def workflow_run_started(self, workflow_id: Optional[str]) -> bool:"""Mark a new active run for `workflow_id`.@@ -714,7 +673,8 @@ class StatusBroadcaster:went_active = prev == 0if went_active:await self.update_workflow_status(- executing=True, workflow_id=workflow_id,+ executing=True,+ workflow_id=workflow_id,)return went_active@@ -751,7 +711,8 @@ class StatusBroadcaster:went_idle = prev > 0 and new_count == 0if went_idle:await self.update_workflow_status(- executing=False, workflow_id=workflow_id,+ executing=False,+ workflow_id=workflow_id,)if clear_stuck_nodes:# include_waiting=False (default) -- don't touch deployment@@ -791,10 +752,9 @@ class StatusBroadcaster:statuses = ("executing", "waiting") if include_waiting else ("executing",)stuck = [- (nid, info) for nid, info in self._status["nodes"].items()- if info.get("workflow_id") == workflow_id- and info.get("status") in statuses- and not is_node_in_active_delegation(nid)+ (nid, info)+ for nid, info in self._status["nodes"].items()+ if info.get("workflow_id") == workflow_id and info.get("status") in statuses and not is_node_in_active_delegation(nid)]for node_id, _info in stuck:try:@@ -802,7 +762,8 @@ class StatusBroadcaster:except Exception as e:logger.warning("[StatusBroadcaster] Failed to clear stuck node %s: %s",- node_id, e,+ node_id,+ e,)return len(stuck)@@ -825,7 +786,7 @@ class StatusBroadcaster:active_runs: int = 0,workflow_id: Optional[str] = None,data: Optional[Dict[str, Any]] = None,- error: Optional[str] = None+ error: Optional[str] = None,):"""Update deployment status and broadcast.@@ -840,31 +801,16 @@ class StatusBroadcaster:data: Optional additional data (e.g., run_id, trigger info)error: Optional error message if status is 'error'"""- self._status["deployment"] = {- "isRunning": is_running,- "activeRuns": active_runs,- "status": status,- "workflow_id": workflow_id- }+ self._status["deployment"] = {"isRunning": is_running, "activeRuns": active_runs, "status": status, "workflow_id": workflow_id}# Broadcast deployment_status message (matches frontend handler)- await self.broadcast({- "type": "deployment_status",- "status": status,- "workflow_id": workflow_id,- "data": data,- "error": error- })+ await self.broadcast({"type": "deployment_status", "status": status, "workflow_id": workflow_id, "data": data, "error": error})# =========================================================================# Workflow Lock Management (Per-Workflow Locks - n8n pattern)# =========================================================================- async def lock_workflow(- self,- workflow_id: str,- reason: str = "deployment"- ) -> bool:+ async def lock_workflow(self, workflow_id: str, reason: str = "deployment") -> bool:"""Lock a specific workflow to prevent concurrent modifications.Per-workflow locking (n8n pattern): Each workflow has its own independent lock.@@ -887,29 +833,17 @@ class StatusBroadcaster:if workflow_id in self._status["workflow_locks"]:existing_lock = self._status["workflow_locks"][workflow_id]if existing_lock.get("locked"):- logger.warning(- f"[WorkflowLock] Workflow {workflow_id} is already locked "- f"for {existing_lock.get('reason')}"- )+ logger.warning(f"[WorkflowLock] Workflow {workflow_id} is already locked " f"for {existing_lock.get('reason')}")return False# Lock this specific workflow- lock_info = {- "locked": True,- "workflow_id": workflow_id,- "locked_at": time.time(),- "reason": reason- }+ lock_info = {"locked": True, "workflow_id": workflow_id, "locked_at": time.time(), "reason": reason}self._status["workflow_locks"][workflow_id] = lock_info# Also update legacy single lock for backward compatibilityself._status["workflow_lock"] = lock_info.copy()- await self.broadcast({- "type": "workflow_lock",- "workflow_id": workflow_id,- "data": lock_info- })+ await self.broadcast({"type": "workflow_lock", "workflow_id": workflow_id, "data": lock_info})logger.info(f"[WorkflowLock] Locked workflow {workflow_id} for {reason}")return True@@ -942,23 +876,15 @@ class StatusBroadcaster:# Update legacy single lock if it was for this workflowif self._status["workflow_lock"].get("workflow_id") == workflow_id:- self._status["workflow_lock"] = {- "locked": False,- "workflow_id": None,- "locked_at": None,- "reason": None- }+ self._status["workflow_lock"] = {"locked": False, "workflow_id": None, "locked_at": None, "reason": None}- await self.broadcast({- "type": "workflow_lock",- "workflow_id": workflow_id,- "data": {- "locked": False,+ await self.broadcast(+ {+ "type": "workflow_lock","workflow_id": workflow_id,- "locked_at": None,- "reason": None+ "data": {"locked": False, "workflow_id": workflow_id, "locked_at": None, "reason": None},}- })+ )logger.info(f"[WorkflowLock] Unlocked workflow {workflow_id}")return True@@ -978,10 +904,7 @@ class StatusBroadcaster:if workflow_id is None:# Check if ANY workflow is locked- return any(- lock.get("locked", False)- for lock in self._status["workflow_locks"].values()- )+ return any(lock.get("locked", False) for lock in self._status["workflow_locks"].values())# Check specific workflowlock = self._status["workflow_locks"].get(workflow_id, {})@@ -1006,7 +929,7 @@ class StatusBroadcaster:"locked": lock.get("locked", False),"workflow_id": workflow_id,"locked_at": lock.get("locked_at"),- "reason": lock.get("reason")+ "reason": lock.get("reason"),}# Return legacy single lock for backward compatibility@@ -1016,11 +939,7 @@ class StatusBroadcaster:"""Get all active workflow locks."""if "workflow_locks" not in self._status:return {}- return {- wid: lock.copy()- for wid, lock in self._status["workflow_locks"].items()- if lock.get("locked")- }+ return {wid: lock.copy() for wid, lock in self._status["workflow_locks"].items() if lock.get("locked")}# =========================================================================# Console Log Updates@@ -1053,16 +972,14 @@ class StatusBroadcaster:# Save to database for persistencetry:from core.container import container+database = container.database()await database.add_console_log(log_data)except Exception as e:logger.warning(f"[StatusBroadcaster] Failed to persist console log: {e}")# Broadcast to all clients- await self.broadcast({- "type": "console_log",- "data": log_data- })+ await self.broadcast({"type": "console_log", "data": log_data})logger.debug(f"[StatusBroadcaster] Console log broadcast: label={log_data.get('label')}")@@ -1072,10 +989,7 @@ class StatusBroadcaster:return []if workflow_id:- return [- log for log in self._status["console_logs"]- if log.get("workflow_id") == workflow_id- ]+ return [log for log in self._status["console_logs"] if log.get("workflow_id") == workflow_id]return list(self._status["console_logs"])async def clear_console_logs(self, workflow_id: Optional[str] = None):@@ -1085,17 +999,11 @@ class StatusBroadcaster:returnif workflow_id:- self._status["console_logs"] = [- log for log in self._status["console_logs"]- if log.get("workflow_id") != workflow_id- ]+ self._status["console_logs"] = [log for log in self._status["console_logs"] if log.get("workflow_id") != workflow_id]else:self._status["console_logs"] = []- await self.broadcast({- "type": "console_logs_cleared",- "workflow_id": workflow_id- })+ await self.broadcast({"type": "console_logs_cleared", "workflow_id": workflow_id})# =========================================================================# Terminal Log Updates@@ -1124,10 +1032,7 @@ class StatusBroadcaster:self._status["terminal_logs"] = self._status["terminal_logs"][-200:]# Broadcast to all clients- await self.broadcast({- "type": "terminal_log",- "data": log_data- })+ await self.broadcast({"type": "terminal_log", "data": log_data})def get_terminal_logs(self) -> List[Dict[str, Any]]:"""Get terminal log history."""@@ -1138,9 +1043,7 @@ class StatusBroadcaster:async def clear_terminal_logs(self):"""Clear terminal log history."""self._status["terminal_logs"] = []- await self.broadcast({- "type": "terminal_logs_cleared"- })+ await self.broadcast({"type": "terminal_logs_cleared"})# =========================================================================# Agent Team Updates@@ -1154,12 +1057,7 @@ class StatusBroadcaster:event_type: Event type (team_created, task_added, task_claimed, etc.)data: Event data"""- await self.broadcast({- "type": "team_event",- "team_id": team_id,- "event_type": event_type,- "data": data- })+ await self.broadcast({"type": "team_event", "team_id": team_id, "event_type": event_type, "data": data})# =========================================================================# Generic Updates@@ -1173,15 +1071,13 @@ class StatusBroadcaster:See DESIGN.md section "Cross-Thread Event Dispatch" for pattern details."""# Broadcast to all WebSocket clients- await self.broadcast({- "type": event_type,- "data": data- })+ await self.broadcast({"type": event_type, "data": data})# Dispatch to event waiters (for trigger nodes)# Use dispatch_async directly - we're in async contexttry:from services import event_waiter+event_data = data if isinstance(data, dict) else {"data": data}resolved_count = await event_waiter.dispatch_async(event_type, event_data)if resolved_count > 0:@@ -1217,9 +1113,7 @@ class StatusBroadcaster:clearing the visible state."""had_status = node_id in self._status["nodes"]- previous_workflow = (- self._status["nodes"][node_id].get("workflow_id") if had_status else None- )+ previous_workflow = self._status["nodes"][node_id].get("workflow_id") if had_status else Noneself._status["nodes"][node_id] = {"status": "idle","data": {},@@ -1228,11 +1122,13 @@ class StatusBroadcaster:"cleared": True,}logger.info(f"[StatusBroadcaster] Reset node status to idle: {node_id}")- await self.broadcast({- "type": "node_status_cleared",- "node_id": node_id,- "workflow_id": previous_workflow,- })+ await self.broadcast(+ {+ "type": "node_status_cleared",+ "node_id": node_id,+ "workflow_id": previous_workflow,+ }+ )return had_statusdef get_variable(self, name: str) -> Any:@@ -1256,9 +1152,7 @@ class StatusBroadcaster:import typing as _typing # local alias to avoid shadowing module-level name-_ServiceRefreshCallback = _typing.Callable[- ["StatusBroadcaster"], _typing.Awaitable[None]-]+_ServiceRefreshCallback = _typing.Callable[["StatusBroadcaster"], _typing.Awaitable[None]]_SERVICE_REFRESH_CALLBACKS: _typing.List[_ServiceRefreshCallback] = []from services.plugin.registry import IdempotentList as _IdempotentList # noqa: E402@@ -1266,9 +1160,7 @@ from services.plugin.registry import IdempotentList as _IdempotentList # noqa:# Backed by the module-level _SERVICE_REFRESH_CALLBACKS list so the# existing iterator at line 153 (``for callback in list(_SERVICE_REFRESH_CALLBACKS)``)# keeps working unchanged.-_SERVICE_REFRESH_FANOUT: _IdempotentList[_ServiceRefreshCallback] = _IdempotentList(- "service_refresh", items=_SERVICE_REFRESH_CALLBACKS-)+_SERVICE_REFRESH_FANOUT: _IdempotentList[_ServiceRefreshCallback] = _IdempotentList("service_refresh", items=_SERVICE_REFRESH_CALLBACKS)def register_service_refresh(callback: _ServiceRefreshCallback) -> None:diff --git a/server/services/temporal/_handlers.py b/server/services/temporal/_handlers.pyindex 93b580c3..877766e1 100644--- a/server/services/temporal/_handlers.py+++ b/server/services/temporal/_handlers.py@@ -11,6 +11,7 @@ All three share the snapshot shape fromsingle source of truth for the ``{temporal}`` payload that theWS-connect refresh callback also emits."""+from __future__ import annotationsfrom typing import Any@@ -24,14 +25,16 @@ logger = get_logger(__name__)async def handle_temporal_status(- data: dict[str, Any], websocket: WebSocket,+ data: dict[str, Any],+ websocket: WebSocket,) -> dict[str, Any]:"""Return the status snapshot for the Temporal runtime."""return temporal_status_snapshot()async def handle_temporal_start(- data: dict[str, Any], websocket: WebSocket,+ data: dict[str, Any],+ websocket: WebSocket,) -> dict[str, Any]:"""Start Temporal. Idempotent — ``.start()`` returns immediately ifthe runtime is already running."""@@ -42,7 +45,8 @@ async def handle_temporal_start(async def handle_temporal_stop(- data: dict[str, Any], websocket: WebSocket,+ data: dict[str, Any],+ websocket: WebSocket,) -> dict[str, Any]:"""Stop Temporal. Idempotent."""from services.temporal._runtime import get_temporal_server_runtimediff --git a/server/services/temporal/_install.py b/server/services/temporal/_install.pyindex 7a74aa18..e62029d3 100644--- a/server/services/temporal/_install.py+++ b/server/services/temporal/_install.py@@ -14,6 +14,7 @@ The downloaded ``temporal`` CLI powers ``temporal server start-dev``(the SQLite/in-memory dev server) and ad-hoc workflow / operatorcommands."""+from __future__ import annotationsimport asyncio@@ -92,10 +93,7 @@ def _fetch_cli_sync() -> Path:"""key = (platform.system(), platform.machine())if key not in _CLI_PLATFORM_MAP:- raise RuntimeError(- f"[Temporal install] Unsupported platform for CLI: {key}. "- f"Supported: {sorted(_CLI_PLATFORM_MAP.keys())}"- )+ raise RuntimeError(f"[Temporal install] Unsupported platform for CLI: {key}. " f"Supported: {sorted(_CLI_PLATFORM_MAP.keys())}")url_platform, url_arch = _CLI_PLATFORM_MAP[key]url = f"{_CLI_BASE_URL}?platform={url_platform}&arch={url_arch}"@@ -116,8 +114,7 @@ def _fetch_cli_sync() -> Path:match = next((Path(p) for p in extracted if Path(p).name == target), None)if match is None:raise RuntimeError(- f"[Temporal install] CLI binary {target!r} not found in archive. "- f"Extracted files: {[Path(p).name for p in extracted]}"+ f"[Temporal install] CLI binary {target!r} not found in archive. " f"Extracted files: {[Path(p).name for p in extracted]}")if not is_windows:mode = match.stat().st_modediff --git a/server/services/temporal/_refresh.py b/server/services/temporal/_refresh.pyindex 6d1dd8d0..47b52183 100644--- a/server/services/temporal/_refresh.py+++ b/server/services/temporal/_refresh.py@@ -9,6 +9,7 @@ Also exposes :func:`temporal_status_snapshot` — the single source oftruth for the ``{temporal}`` status shape consumed by both this refreshcallback and ``_handlers.py``'s WS commands."""+from __future__ import annotationsfrom typing import TYPE_CHECKING, Any@@ -45,10 +46,12 @@ async def refresh_temporal_status(broadcaster: "StatusBroadcaster") -> None:framework's ``TaskGroup`` swallows a ``TypeError: takes 0 positionalarguments but 1 was given`` on every server boot."""- await broadcaster.broadcast({- "type": "temporal_status",- "data": temporal_status_snapshot(),- })+ await broadcaster.broadcast(+ {+ "type": "temporal_status",+ "data": temporal_status_snapshot(),+ }+ )__all__ = ["refresh_temporal_status", "temporal_status_snapshot"]diff --git a/server/services/temporal/_runtime.py b/server/services/temporal/_runtime.pyindex bfa57a97..5f9ff39e 100644--- a/server/services/temporal/_runtime.py+++ b/server/services/temporal/_runtime.py@@ -11,6 +11,7 @@ Uses the singleton accessor pattern (``Class.get_instance()``) from``BaseSupervisor`` — same idiom :mod:`nodes.whatsapp._runtime` uses for``WhatsAppRuntime``."""+from __future__ import annotationsimport asyncio@@ -99,10 +100,7 @@ class TemporalServerRuntime(BaseProcessSupervisor):# ``_pre_spawn`` (called by ``BaseProcessSupervisor._do_start``# before this method) populates ``self._binaries`` via the# pooch downloader. Loud failure if that contract regresses.- assert self._binaries is not None, (- f"[{self.label}] binary_path() called before _pre_spawn() "- "populated self._binaries"- )+ assert self._binaries is not None, f"[{self.label}] binary_path() called before _pre_spawn() " "populated self._binaries"return self._binaries["temporal"]def argv(self) -> list[str]:@@ -121,13 +119,21 @@ class TemporalServerRuntime(BaseProcessSupervisor):# --log-level warn keeps the supervisor log readable# --namespace default namespace bootstrapped at startreturn [- str(self.binary_path()), "server", "start-dev",- "--port", str(self.settings.temporal_frontend_grpc_port),- "--ui-port", str(self.settings.temporal_ui_port),- "--db-filename", str(self._sqlite_path),- "--metrics-port", "0",- "--log-level", "warn",- "--namespace", self.settings.temporal_namespace,+ str(self.binary_path()),+ "server",+ "start-dev",+ "--port",+ str(self.settings.temporal_frontend_grpc_port),+ "--ui-port",+ str(self.settings.temporal_ui_port),+ "--db-filename",+ str(self._sqlite_path),+ "--metrics-port",+ "0",+ "--log-level",+ "warn",+ "--namespace",+ self.settings.temporal_namespace,]def cwd(self) -> Path:@@ -161,6 +167,7 @@ class TemporalServerRuntime(BaseProcessSupervisor):# ---- module-level singleton accessor ------------------------------------+def get_temporal_server_runtime(settings: Optional[Settings] = None,) -> TemporalServerRuntime:diff --git a/server/services/temporal/_supervised_runtime.py b/server/services/temporal/_supervised_runtime.pyindex 2b6911d7..0fb9d69e 100644--- a/server/services/temporal/_supervised_runtime.py+++ b/server/services/temporal/_supervised_runtime.py@@ -33,6 +33,7 @@ Equivalent to (Python idiom):await runtime.start()await asyncio.Event().wait() # block on signal"""+from __future__ import annotationsimport asyncio@@ -87,8 +88,7 @@ async def _run(factory_dotted: str) -> int:def main() -> int:if len(sys.argv) != 2:print(- "usage: python -m services.temporal._supervised_runtime "- "<module.path:factory>",+ "usage: python -m services.temporal._supervised_runtime " "<module.path:factory>",file=sys.stderr,)return 2diff --git a/server/services/temporal/activities.py b/server/services/temporal/activities.pyindex 9d595db9..406986ae 100644--- a/server/services/temporal/activities.py+++ b/server/services/temporal/activities.py@@ -24,13 +24,21 @@ from core.config import Settingslogger = get_logger(__name__)-# Load settings to get the correct server port-_settings = Settings()-MACHINA_URL = f"http://{_settings.host}:{_settings.port}"-WS_URL = f"ws://{_settings.host}:{_settings.port}/ws/internal"-logger.debug(f"MACHINA_URL configured: {MACHINA_URL}")-logger.debug(f"WS_URL configured: {WS_URL}")+def _resolve_urls() -> tuple[str, str]:+ """Resolve ``(http_base, ws_url)`` from current ``Settings``.++ Deferred to first call so module import doesn't require the full env+ surface (``HOST``, ``PORT``, ``JWT_SECRET_KEY``, ...). Module-level+ ``Settings()`` made the temporal package un-importable in any test+ process that hadn't loaded ``.env`` -- conftest stubs got wiped by+ sibling test suites and the validation error masked real bugs.+ """+ settings = Settings()+ return (+ f"http://{settings.host}:{settings.port}",+ f"ws://{settings.host}:{settings.port}/ws/internal",+ )class NodeExecutionActivities:@@ -51,9 +59,10 @@ class NodeExecutionActivities:session: aiohttp.ClientSession with connection pooling configured"""self.session = session- self.ws_url = WS_URL- self.http_url = f"{MACHINA_URL}/api/workflow/node/execute"- self.broadcast_url = f"{MACHINA_URL}/api/workflow/broadcast-status"+ http_base, ws_url = _resolve_urls()+ self.ws_url = ws_url+ self.http_url = f"{http_base}/api/workflow/node/execute"+ self.broadcast_url = f"{http_base}/api/workflow/broadcast-status"@activity.defnasync def execute_node_activity(self, context: Dict[str, Any]) -> Dict[str, Any]:@@ -277,6 +286,7 @@ class NodeExecutionActivities:# Factory function for creating activity instance with session# =============================================================================+def create_node_activities(session: aiohttp.ClientSession) -> NodeExecutionActivities:"""Factory function to create activity instance with shared session.@@ -333,6 +343,7 @@ async def create_shared_session(pool_size: int = 100) -> aiohttp.ClientSession:# start_to_close_timeout=timedelta(seconds=2))``. Defaults are not# hardcoded here.+@activity.defnasync def emit_event_activity(event_payload: Dict[str, Any]) -> Dict[str, Any]:"""Re-enter :func:`services.events.dispatch.emit` from a workflow context.@@ -356,9 +367,7 @@ async def emit_event_activity(event_payload: Dict[str, Any]) -> Dict[str, Any]:try:event = WorkflowEvent.model_validate(event_payload)except Exception as exc: # noqa: BLE001- activity.logger.warning(- f"emit_event_activity: envelope rejected: {exc}"- )+ activity.logger.warning(f"emit_event_activity: envelope rejected: {exc}")return {"delivered": False,"event_id": event_payload.get("id", "?"),@@ -387,6 +396,7 @@ async def emit_event_activity(event_payload: Dict[str, Any]) -> Dict[str, Any]:# Without this, the canary path would keep the trigger node visually# stuck on "waiting" with no firing pulse — a UX regression vs legacy.+@activity.defnasync def store_node_output_activity(payload: Dict[str, Any]) -> None:"""Persist a node's output to the workflow output store so@@ -425,13 +435,13 @@ async def store_node_output_activity(payload: Dict[str, Any]) -> None:for output_name in ("output_main", "output_top", "output_0"):try:await workflow_service.store_node_output(- session_id, node_id, output_name, data,+ session_id,+ node_id,+ output_name,+ data,)except Exception as exc: # noqa: BLE001 — non-fatal- activity.logger.warning(- f"store_node_output_activity failed for "- f"node={node_id!r} handle={output_name!r}: {exc}"- )+ activity.logger.warning(f"store_node_output_activity failed for " f"node={node_id!r} handle={output_name!r}: {exc}")@activity.defn@@ -462,7 +472,4 @@ async def broadcast_trigger_status_activity(payload: Dict[str, Any]) -> None:workflow_id=payload.get("workflow_id"),)except Exception as exc: # noqa: BLE001 — non-fatal- activity.logger.warning(- f"broadcast_trigger_status_activity failed for "- f"node={payload.get('node_id')!r}: {exc}"- )+ activity.logger.warning(f"broadcast_trigger_status_activity failed for " f"node={payload.get('node_id')!r}: {exc}")diff --git a/server/services/temporal/agent_activities.py b/server/services/temporal/agent_activities.pyindex b211d8b4..1bf2fd46 100644--- a/server/services/temporal/agent_activities.py+++ b/server/services/temporal/agent_activities.py@@ -83,8 +83,7 @@ async def execute_llm_step(payload: Dict[str, Any]) -> Dict[str, Any]:``heartbeat_timeout``."""activity.logger.info(- f"Agent LLM step: provider={payload.get('provider')} "- f"model={payload.get('model')} messages={len(payload.get('messages', []))}"+ f"Agent LLM step: provider={payload.get('provider')} " f"model={payload.get('model')} messages={len(payload.get('messages', []))}")activity.heartbeat(f"LLM step starting: {payload.get('model')}")@@ -160,6 +159,7 @@ async def execute_llm_step(payload: Dict[str, Any]) -> Dict[str, Any]:# cache metadata, etc.). The workflow extracts ``tool_calls`` from# ``response.tool_calls`` separately for scheduling.from langchain_core.messages import messages_to_dict+assistant_dict = messages_to_dict([response])[0]if hasattr(response, "tool_calls") and response.tool_calls:@@ -242,6 +242,7 @@ async def persist_agent_turn(payload: Dict[str, Any]) -> Dict[str, Any]:# container) — same pattern handlers/tools.py / handlers/triggers.py# use. ``container.status_broadcaster()`` does NOT exist.from services.status_broadcaster import get_status_broadcaster+broadcaster = get_status_broadcaster()await broadcaster.broadcast_node_parameters_updated(memory_node_id,@@ -442,10 +443,7 @@ async def prepare_agent_payload(context: Dict[str, Any]) -> Dict[str, Any]:connected tools / skills / memory still produce a valid payloadthat AgentWorkflow can run."""- activity.logger.info(- f"Preparing AgentWorkflow payload for {context.get('node_type')!r} "- f"node_id={context.get('node_id')!r}"- )+ activity.logger.info(f"Preparing AgentWorkflow payload for {context.get('node_type')!r} " f"node_id={context.get('node_id')!r}")# Lazy imports — keep agent_activities.py top-level light so the# worker can register this activity without dragging the whole@@ -482,7 +480,11 @@ async def prepare_agent_payload(context: Dict[str, Any]) -> Dict[str, Any]:edges = context.get("edges") or []if nodes and edges:parameters = await workflow_service._param_resolver.resolve(- parameters, node_id, nodes, edges, session_id,+ parameters,+ node_id,+ nodes,+ edges,+ session_id,)options = parameters.get("options") or {}@@ -506,8 +508,7 @@ async def prepare_agent_payload(context: Dict[str, Any]) -> Dict[str, Any]:api_key = await auth.get_api_key(provider) or await auth.get_api_key(f"{provider}_api_key")if not api_key:raise RuntimeError(- f"API key for provider {provider!r} required for AgentWorkflow "- f"node {node_id!r}; configure it in the Credentials Modal."+ f"API key for provider {provider!r} required for AgentWorkflow " f"node {node_id!r}; configure it in the Credentials Modal.")max_tokens = _resolve_max_tokens(flattened, model, provider)@@ -531,7 +532,9 @@ async def prepare_agent_payload(context: Dict[str, Any]) -> Dict[str, Any]:}temperature = _resolve_temperature(- flattened, model, provider,+ flattened,+ model,+ provider,bool(thinking_config_obj and thinking_config_obj.enabled),)@@ -541,16 +544,19 @@ async def prepare_agent_payload(context: Dict[str, Any]) -> Dict[str, Any]:"edges": context.get("edges") or [],"workflow_id": workflow_id,}- memory_data, skill_data, tool_data, input_data, _task_data = (- await collect_agent_connections(- node_id, walk_context, database, log_prefix=f"[AgentWorkflow:{node_type}]",- )+ memory_data, skill_data, tool_data, input_data, _task_data = await collect_agent_connections(+ node_id,+ walk_context,+ database,+ log_prefix=f"[AgentWorkflow:{node_type}]",)# ---- Skill prompt injection ----------------------------------------from services.ai import _build_skill_system_prompt+skill_prompt, has_personality = _build_skill_system_prompt(- skill_data, log_prefix=f"[AgentWorkflow:{node_type}]",+ skill_data,+ log_prefix=f"[AgentWorkflow:{node_type}]",)if skill_prompt:system_message = skill_prompt if has_personality else f"{system_message}\n\n{skill_prompt}"@@ -580,31 +586,32 @@ async def prepare_agent_payload(context: Dict[str, Any]) -> Dict[str, Any]:try:tool, _config = await ai_service._build_tool_from_node(tool_info)except Exception as e: # noqa: BLE001 — defensive: skip a broken tool- activity.logger.warning(- f"prepare_payload: failed to build tool {tool_info.get('node_type')!r}: {e}"- )+ activity.logger.warning(f"prepare_payload: failed to build tool {tool_info.get('node_type')!r}: {e}")continueif tool is None:continue# Look up plugin class for activity-dispatch metadata.from services.node_registry import get_node_class+cls = get_node_class(tool_info.get("node_type", ""))version = getattr(cls, "version", 1) if cls else 1task_queue = getattr(cls, "task_queue", "machina-default") if cls else "machina-default"- tools_payload.append({- "name": tool.name,- "node_type": tool_info.get("node_type", ""),- "version": version,- "task_queue": task_queue,- "tool_node_id": tool_info.get("node_id", ""),- "parameters": tool_info.get("parameters") or {},- # Raw tool_info — what ``collect_agent_connections`` returned- # and what ``_build_tool_from_node`` accepts as input. Passed- # through the workflow verbatim so ``execute_llm_step`` can- # rebuild the real StructuredTool inside the activity.- "tool_info": tool_info,- })+ tools_payload.append(+ {+ "name": tool.name,+ "node_type": tool_info.get("node_type", ""),+ "version": version,+ "task_queue": task_queue,+ "tool_node_id": tool_info.get("node_id", ""),+ "parameters": tool_info.get("parameters") or {},+ # Raw tool_info — what ``collect_agent_connections`` returned+ # and what ``_build_tool_from_node`` accepts as input. Passed+ # through the workflow verbatim so ``execute_llm_step`` can+ # rebuild the real StructuredTool inside the activity.+ "tool_info": tool_info,+ }+ )# ---- Compaction threshold ------------------------------------------# Model-aware threshold (50% of context window per agent.compaction.ratio@@ -615,6 +622,7 @@ async def prepare_agent_payload(context: Dict[str, Any]) -> Dict[str, Any]:compaction_threshold: int | None = Nonetry:from services.compaction import get_compaction_service+svc = get_compaction_service()if svc is not None:cfg = await svc.anthropic_config(model=model, provider=provider)diff --git a/server/services/temporal/agent_workflow.py b/server/services/temporal/agent_workflow.pyindex 27a6688b..64dc448f 100644--- a/server/services/temporal/agent_workflow.py+++ b/server/services/temporal/agent_workflow.py@@ -179,10 +179,12 @@ class AgentWorkflow:# current markdown content seeds the conversation here.memory_markdown = payload.get("memory_content") or ""if memory_markdown:- messages.append({- "type": "system",- "data": {"content": f"## Prior conversation:\n{memory_markdown}"},- })+ messages.append(+ {+ "type": "system",+ "data": {"content": f"## Prior conversation:\n{memory_markdown}"},+ }+ )user_prompt = payload.get("user_prompt") or ""if user_prompt:@@ -192,9 +194,7 @@ class AgentWorkflow:# parameters} so the workflow can schedule the right activity# when the LLM emits a tool_call.tools = payload.get("tools") or []- tool_index: Dict[str, Dict[str, Any]] = {- t["name"]: t for t in tools- }+ tool_index: Dict[str, Dict[str, Any]] = {t["name"]: t for t in tools}max_iterations = int(payload.get("max_iterations") or DEFAULT_MAX_ITERATIONS)token_total = 0@@ -212,23 +212,27 @@ class AgentWorkflow:# canvas glow). Mirrors what F4.A's _node_activity wrapper# does for non-agent plugins.await self._emit_phase(- agent_node_id, agent_workflow_id, 0, max_iterations,- phase="starting", status="executing",+ agent_node_id,+ agent_workflow_id,+ 0,+ max_iterations,+ phase="starting",+ status="executing",)# ---- Main loop --------------------------------------------------for iteration in range(max_iterations):- workflow.logger.info(- f"AgentWorkflow iteration {iteration} "- f"(messages={len(messages)} tools={len(tools)})"- )+ workflow.logger.info(f"AgentWorkflow iteration {iteration} " f"(messages={len(messages)} tools={len(tools)})")# CloudEvents-shaped agent_progress per LLM turn. Mirrors the# the in-process agent loop's per-turn broadcast (RFC §6.4).# FE consumes the typed envelope and updates the canvas# node's "N / max" iteration badge live.await self._emit_phase(- agent_node_id, agent_workflow_id, iteration, max_iterations,+ agent_node_id,+ agent_workflow_id,+ iteration,+ max_iterations,phase="llm_step",)@@ -264,10 +268,7 @@ class AgentWorkflow:usage_total[k] = usage_total.get(k, 0) + vif step_result.get("thinking"):if thinking_accumulated:- thinking_accumulated += (- f"\n\n--- Iteration {iteration + 1} ---\n"- + step_result["thinking"]- )+ thinking_accumulated += f"\n\n--- Iteration {iteration + 1} ---\n" + step_result["thinking"]else:thinking_accumulated = step_result["thinking"]@@ -284,15 +285,11 @@ class AgentWorkflow:if kind == "final":final_content = step_result.get("content", "")- await self._persist_turn(- payload, human_text=user_prompt, assistant_text=final_content- )+ await self._persist_turn(payload, human_text=user_prompt, assistant_text=final_content)breakif kind != "tool_calls":- workflow.logger.error(- f"AgentWorkflow: unexpected LLM step kind={kind!r}"- )+ workflow.logger.error(f"AgentWorkflow: unexpected LLM step kind={kind!r}")break# ---- Schedule tool activities -------------------------------@@ -302,21 +299,17 @@ class AgentWorkflow:for call in calls:tool_info = tool_index.get(call.get("name", ""))if tool_info is None:- workflow.logger.warning(- f"AgentWorkflow: LLM called unknown tool {call.get('name')!r}; "- "returning error to model"+ workflow.logger.warning(f"AgentWorkflow: LLM called unknown tool {call.get('name')!r}; " "returning error to model")+ messages.append(+ {+ "type": "tool",+ "data": {+ "content": (f"Error: tool {call.get('name')!r} is not " "connected to this agent."),+ "tool_call_id": call.get("id", ""),+ "name": call.get("name", ""),+ },+ })- messages.append({- "type": "tool",- "data": {- "content": (- f"Error: tool {call.get('name')!r} is not "- "connected to this agent."- ),- "tool_call_id": call.get("id", ""),- "name": call.get("name", ""),- },- })continue# Delegation tools (``delegate_to_<child>``) need different@@ -358,7 +351,7 @@ class AgentWorkflow:**(tool_info.get("parameters") or {}),**call_args,}- child_nodes = [] # regular tool activity doesn't need full canvas+ child_nodes = [] # regular tool activity doesn't need full canvaschild_edges = []tool_payload = {@@ -372,12 +365,13 @@ class AgentWorkflow:"edges": child_edges,}- tool_activity_name = (- f"node.{tool_info['node_type']}.v{tool_info['version']}"- )+ tool_activity_name = f"node.{tool_info['node_type']}.v{tool_info['version']}"await self._emit_phase(- agent_node_id, agent_workflow_id, iteration, max_iterations,+ agent_node_id,+ agent_workflow_id,+ iteration,+ max_iterations,phase="executing_tool",extra={"tool_name": call.get("name", ""), "tool_node_id": tool_info["tool_node_id"]},)@@ -391,7 +385,10 @@ class AgentWorkflow:)tool_content = _serialise_tool_result(tool_result)await self._emit_phase(- agent_node_id, agent_workflow_id, iteration, max_iterations,+ agent_node_id,+ agent_workflow_id,+ iteration,+ max_iterations,phase="tool_completed",extra={"tool_name": call.get("name", "")},)@@ -399,21 +396,19 @@ class AgentWorkflow:# After all retries exhausted, surface the error to# the LLM (per user decision: LLM sees error and# continues — matches the in-process agent loop).- workflow.logger.warning(- f"AgentWorkflow tool {tool_info['node_type']!r} failed: {e}"- )- tool_content = (- f'{{"error": "{type(e).__name__}: {e}"}}'- )+ workflow.logger.warning(f"AgentWorkflow tool {tool_info['node_type']!r} failed: {e}")+ tool_content = f'{{"error": "{type(e).__name__}: {e}"}}'- messages.append({- "type": "tool",- "data": {- "content": tool_content,- "tool_call_id": call.get("id", ""),- "name": call.get("name", ""),- },- })+ messages.append(+ {+ "type": "tool",+ "data": {+ "content": tool_content,+ "tool_call_id": call.get("id", ""),+ "name": call.get("name", ""),+ },+ }+ )# ---- Persist this turn (append-per-turn) -------------------# Snapshot the most recent user/assistant pair into memory.@@ -425,28 +420,21 @@ class AgentWorkflow:)# ---- Compaction check --------------------------------------- token_total = sum(- v for k, v in usage_total.items()- if k in ("input_tokens", "output_tokens")- )- if (- compaction_threshold- and token_total >= compaction_threshold- and memory_markdown- ):- workflow.logger.info(- f"AgentWorkflow compaction triggered: {token_total} tokens"- )+ token_total = sum(v for k, v in usage_total.items() if k in ("input_tokens", "output_tokens"))+ if compaction_threshold and token_total >= compaction_threshold and memory_markdown:+ workflow.logger.info(f"AgentWorkflow compaction triggered: {token_total} tokens")compact_result = await workflow.execute_activity("agent.compact_memory.v1",- args=[{- "session_id": payload.get("session_id", "default"),- "node_id": payload["node_id"],- "memory_content": memory_markdown,- "provider": payload["provider"],- "api_key": payload["api_key"],- "model": payload["model"],- }],+ args=[+ {+ "session_id": payload.get("session_id", "default"),+ "node_id": payload["node_id"],+ "memory_content": memory_markdown,+ "provider": payload["provider"],+ "api_key": payload["api_key"],+ "model": payload["model"],+ }+ ],start_to_close_timeout=COMPACT_MEMORY_TIMEOUT,retry_policy=AGENT_ACTIVITY_RETRY,)@@ -457,8 +445,7 @@ class AgentWorkflow:# workflow crash.if not compact_result.get("success"):workflow.logger.warning(- "AgentWorkflow compaction failed (%s); continuing "- "with un-compacted history",+ "AgentWorkflow compaction failed (%s); continuing " "with un-compacted history",compact_result.get("error", "no error reported"),)else:@@ -477,12 +464,9 @@ class AgentWorkflow:else:# Loop exited without break -- hit max_iterations.- workflow.logger.warning(- f"AgentWorkflow hit max_iterations={max_iterations}; truncating"- )+ workflow.logger.warning(f"AgentWorkflow hit max_iterations={max_iterations}; truncating")final_content = final_content or (- "[AgentWorkflow truncated after max_iterations; "- "the model did not produce a final response]"+ "[AgentWorkflow truncated after max_iterations; " "the model did not produce a final response]")result_payload = {@@ -500,11 +484,13 @@ class AgentWorkflow:# bypass NodeExecutor entirely.await workflow.execute_activity("agent.store_output.v1",- args=[{- "node_id": agent_node_id,- "session_id": payload.get("session_id", "default"),- "result": result_payload,- }],+ args=[+ {+ "node_id": agent_node_id,+ "session_id": payload.get("session_id", "default"),+ "result": result_payload,+ }+ ],start_to_close_timeout=PERSIST_TURN_TIMEOUT,retry_policy=AGENT_ACTIVITY_RETRY,)@@ -512,8 +498,12 @@ class AgentWorkflow:# Final lifecycle broadcast — canvas glow goes green + FE# consumers of com.machinaos.agent.progress see phase="completed".await self._emit_phase(- agent_node_id, agent_workflow_id, max_iterations, max_iterations,- phase="completed", status="success",+ agent_node_id,+ agent_workflow_id,+ max_iterations,+ max_iterations,+ phase="completed",+ status="success",)return {"success": True, "result": result_payload}@@ -537,15 +527,17 @@ class AgentWorkflow:glows accordingly (executing / success / error)."""await workflow.execute_activity("agent.broadcast_progress.v1",- args=[{- "node_id": node_id,- "workflow_id": workflow_id,- "iteration": iteration,- "max_iterations": max_iterations,- "phase": phase,- **({"status": status} if status else {}),- **(extra or {}),- }],+ args=[+ {+ "node_id": node_id,+ "workflow_id": workflow_id,+ "iteration": iteration,+ "max_iterations": max_iterations,+ "phase": phase,+ **({"status": status} if status else {}),+ **(extra or {}),+ }+ ],start_to_close_timeout=PERSIST_TURN_TIMEOUT,retry_policy=AGENT_ACTIVITY_RETRY,)@@ -572,12 +564,14 @@ class AgentWorkflow:returnawait workflow.execute_activity("agent.persist_turn.v1",- args=[{- "memory_node_id": memory_node_id,- "human_text": human_text,- "assistant_text": assistant_text,- "window_size": int(payload.get("memory_window_size") or 10),- }],+ args=[+ {+ "memory_node_id": memory_node_id,+ "human_text": human_text,+ "assistant_text": assistant_text,+ "window_size": int(payload.get("memory_window_size") or 10),+ }+ ],start_to_close_timeout=PERSIST_TURN_TIMEOUT,retry_policy=AGENT_ACTIVITY_RETRY,)diff --git a/server/services/temporal/client.py b/server/services/temporal/client.pyindex ba01444f..bc905181 100644--- a/server/services/temporal/client.py+++ b/server/services/temporal/client.py@@ -65,9 +65,7 @@ class TemporalClientWrapper:)# Verify namespace is ready (gRPC port may accept connections# before the server finishes registering namespaces)- await client.service_client.workflow_service.describe_namespace(- DescribeNamespaceRequest(namespace=self.namespace)- )+ await client.service_client.workflow_service.describe_namespace(DescribeNamespaceRequest(namespace=self.namespace))self._client = clientlogger.info(f"Connected to Temporal server at {self.server_address}")# Wave 12 A4: idempotently register the event-framework@@ -79,22 +77,17 @@ class TemporalClientWrapper:from services.temporal.search_attributes import (register_search_attributes,)+await register_search_attributes(self._client, self.namespace)except Exception as sa_exc: # noqa: BLE001 — non-fatal- logger.warning(- f"Search-attribute registration failed (non-fatal): {sa_exc}"- )+ logger.warning(f"Search-attribute registration failed (non-fatal): {sa_exc}")return self._clientexcept Exception as e:- logger.warning(- f"Temporal connection attempt {attempt}/{retries} failed: {e}"- )+ logger.warning(f"Temporal connection attempt {attempt}/{retries} failed: {e}")if attempt < retries:await asyncio.sleep(delay)- logger.error(- f"Failed to connect to Temporal server at {self.server_address} after {retries} attempts"- )+ logger.error(f"Failed to connect to Temporal server at {self.server_address} after {retries} attempts")return Noneasync def disconnect(self) -> None:@@ -104,7 +97,9 @@ class TemporalClientWrapper:logger.info("Disconnected from Temporal server")async def terminate_running_workflows(- self, *, reason: str = "MachinaOS startup: auto-resumption disabled",+ self,+ *,+ reason: str = "MachinaOS startup: auto-resumption disabled",) -> int:"""Terminate every workflow in ``Running`` state in our namespace.@@ -122,9 +117,7 @@ class TemporalClientWrapper:race that produces ``WorkflowNotFoundError``."""if self._client is None:- logger.warning(- "terminate_running_workflows called before connect; no-op"- )+ logger.warning("terminate_running_workflows called before connect; no-op")return 0count = 0@@ -133,18 +126,13 @@ class TemporalClientWrapper:):try:handle = self._client.get_workflow_handle(- wf.id, run_id=wf.run_id,+ wf.id,+ run_id=wf.run_id,)await handle.terminate(reason=reason)count += 1except Exception as exc: # noqa: BLE001 — best-effort sweep- logger.debug(- f"Failed to terminate workflow id={wf.id} "- f"run_id={wf.run_id}: {exc}"- )+ logger.debug(f"Failed to terminate workflow id={wf.id} " f"run_id={wf.run_id}: {exc}")if count:- logger.info(- f"Terminated {count} running workflow(s) at startup "- "(history preserved; resumption disabled)"- )+ logger.info(f"Terminated {count} running workflow(s) at startup " "(history preserved; resumption disabled)")return countdiff --git a/server/services/temporal/executor.py b/server/services/temporal/executor.pyindex 0d4658f9..353bb47f 100644--- a/server/services/temporal/executor.py+++ b/server/services/temporal/executor.py@@ -98,9 +98,7 @@ class TemporalExecutor:result.get("outputs", {}).get(node_id, {}),)except Exception as e:- logger.warning(- f"Status callback error for node {node_id}: {e}"- )+ logger.warning(f"Status callback error for node {node_id}: {e}")logger.info("Temporal workflow completed",@@ -124,6 +122,7 @@ class TemporalExecutor:except Exception as e:import traceback+execution_time = time.time() - start_timeerror_details = f"{type(e).__name__}: {str(e)}"tb = traceback.format_exc()diff --git a/server/services/temporal/plugin_activities.py b/server/services/temporal/plugin_activities.pyindex 9b2c13f6..0ea84cf2 100644--- a/server/services/temporal/plugin_activities.py+++ b/server/services/temporal/plugin_activities.py@@ -69,7 +69,9 @@ def collect_plugin_activities(activity_fn = cls.as_activity()except Exception as e:logger.warning(- "Failed to build activity for %s: %s", node_type, e,+ "Failed to build activity for %s: %s",+ node_type,+ e,)continueactivities.append(activity_fn)@@ -111,7 +113,9 @@ def collect_polling_activities() -> List[Callable]:activities.append(cls.as_poll_activity())except Exception as exc: # noqa: BLE001logger.warning(- "Failed to build poll activity for %s: %s", node_type, exc,+ "Failed to build poll activity for %s: %s",+ node_type,+ exc,)logger.info("Collected %d polling activities", len(activities))diff --git a/server/services/temporal/plugin_registry.py b/server/services/temporal/plugin_registry.pyindex 80f74fd0..82a76301 100644--- a/server/services/temporal/plugin_registry.py+++ b/server/services/temporal/plugin_registry.py@@ -40,9 +40,7 @@ from services.plugin.registry import IdempotentRegistry# plugins both declaring ``name="cron-scheduler"`` would surface a# namespace clash). SimplePlugin instances are content-comparable via# the IdempotentRegistry's qualname check (reload safe).-_REGISTRY: IdempotentRegistry[str, SimplePlugin] = IdempotentRegistry(- "temporal_plugin"-)+_REGISTRY: IdempotentRegistry[str, SimplePlugin] = IdempotentRegistry("temporal_plugin")def register_temporal_plugin(plugin: SimplePlugin) -> None:diff --git a/server/services/temporal/polling_trigger_workflow.py b/server/services/temporal/polling_trigger_workflow.pyindex 772bc318..d03b7414 100644--- a/server/services/temporal/polling_trigger_workflow.py+++ b/server/services/temporal/polling_trigger_workflow.py@@ -153,9 +153,7 @@ class PollingTriggerWorkflow:# Activity exhausted its RetryPolicy. Log + continue —# don't terminate the listener over one bad cycle.# Workflow Event History records the failure for ops.- workflow.logger.error(- f"PollingTriggerWorkflow cycle failed (will retry next interval): {exc}"- )+ workflow.logger.error(f"PollingTriggerWorkflow cycle failed (will retry next interval): {exc}")continueseen_ids = set(result.get("seen_ids") or [])@@ -172,15 +170,11 @@ class PollingTriggerWorkflow:# Per-event spawn failure logged; subsequent events# still try. Same isolation contract as the push# listener.- workflow.logger.error(- f"PollingTriggerWorkflow spawn failed for event.id={event_id}: {spawn_exc}"- )+ workflow.logger.error(f"PollingTriggerWorkflow spawn failed for event.id={event_id}: {spawn_exc}")self._processed_count += 1if self._processed_count >= _MAX_EVENTS_BEFORE_CONTINUE_AS_NEW:- workflow.logger.info(- f"PollingTriggerWorkflow continue_as_new: processed={self._processed_count}"- )+ workflow.logger.info(f"PollingTriggerWorkflow continue_as_new: processed={self._processed_count}")# Carry seen_ids forward so the new run doesn't re-emit# what's already been seen by the provider.listener_data["seen_ids"] = list(seen_ids)@@ -244,13 +238,15 @@ class PollingTriggerWorkflow:await workflow.start_child_workflow("MachinaWorkflow",- args=[{- "nodes": filtered_nodes,- "edges": filtered_edges,- "session_id": session_id,- "workflow_id": workflow_id,- "tenant_id": tenant_id,- }],+ args=[+ {+ "nodes": filtered_nodes,+ "edges": filtered_edges,+ "session_id": session_id,+ "workflow_id": workflow_id,+ "tenant_id": tenant_id,+ }+ ],id=child_id,parent_close_policy=ParentClosePolicy.ABANDON,id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE_FAILED_ONLY,@@ -258,10 +254,7 @@ class PollingTriggerWorkflow:run_timeout=timedelta(hours=1),)- workflow.logger.info(- f"PollingTriggerWorkflow spawned child run: child_id={child_id} "- f"event.id={event.get('id')}"- )+ workflow.logger.info(f"PollingTriggerWorkflow spawned child run: child_id={child_id} " f"event.id={event.get('id')}")await _broadcast_trigger_waiting(node_id=trigger_node_id,diff --git a/server/services/temporal/schedules.py b/server/services/temporal/schedules.pyindex 03cf57eb..0014f1fb 100644--- a/server/services/temporal/schedules.py+++ b/server/services/temporal/schedules.py@@ -122,20 +122,22 @@ async def create_cron_schedule(# ``search_attributes`` is a ``client.create_schedule`` kwarg, not# a field on the ``Schedule`` dataclass itself (per the Temporal# SDK API).- schedule_search_attributes = TypedSearchAttributes([- SearchAttributePair(- SearchAttributeKey.for_keyword("EventWorkflowId"),- deployment_workflow_id,- ),- SearchAttributePair(- SearchAttributeKey.for_keyword("TriggerNodeId"),- node_id,- ),- SearchAttributePair(- SearchAttributeKey.for_keyword("EventTriggerKind"),- "cron",- ),- ])+ schedule_search_attributes = TypedSearchAttributes(+ [+ SearchAttributePair(+ SearchAttributeKey.for_keyword("EventWorkflowId"),+ deployment_workflow_id,+ ),+ SearchAttributePair(+ SearchAttributeKey.for_keyword("TriggerNodeId"),+ node_id,+ ),+ SearchAttributePair(+ SearchAttributeKey.for_keyword("EventTriggerKind"),+ "cron",+ ),+ ]+ )try:await client.create_schedule(@@ -173,10 +175,7 @@ async def delete_cron_schedules_for_deployment(Returns count of Schedules deleted."""- query = (- f"EventWorkflowId='{deployment_workflow_id}' "- f"AND EventTriggerKind='cron'"- )+ query = f"EventWorkflowId='{deployment_workflow_id}' " f"AND EventTriggerKind='cron'"deleted = 0try:@@ -201,8 +200,7 @@ async def delete_cron_schedules_for_deployment()except Exception as exc: # noqa: BLE001logger.warning(- f"Visibility query for cron Schedules failed: {exc} "- f"(query={query!r})",+ f"Visibility query for cron Schedules failed: {exc} " f"(query={query!r})",deployment_workflow_id=deployment_workflow_id,)diff --git a/server/services/temporal/search_attributes.py b/server/services/temporal/search_attributes.pyindex cdc8fc36..fc2d9e49 100644--- a/server/services/temporal/search_attributes.py+++ b/server/services/temporal/search_attributes.py@@ -140,17 +140,14 @@ async def register_search_attributes(client: Client, namespace: str) -> dict:status: dict[str, str] = {}to_register: dict[str, IndexedValueType] = {- spec.name: spec.indexed_type- for spec in EVENT_SEARCH_ATTRIBUTES- if spec.name not in existing_names+ spec.name: spec.indexed_type for spec in EVENT_SEARCH_ATTRIBUTES if spec.name not in existing_names}for name in existing_names & {s.name for s in EVENT_SEARCH_ATTRIBUTES}:status[name] = "already_exists"if not to_register:logger.info(- f"All {len(EVENT_SEARCH_ATTRIBUTES)} event-framework Search Attributes "- f"already registered on namespace={namespace!r}",+ f"All {len(EVENT_SEARCH_ATTRIBUTES)} event-framework Search Attributes " f"already registered on namespace={namespace!r}",)return status@@ -175,7 +172,6 @@ async def register_search_attributes(client: Client, namespace: str) -> dict:status[name] = "registered"logger.info(- f"Registered {len(to_register)} event-framework Search Attributes on "- f"namespace={namespace!r}: {list(to_register.keys())}",+ f"Registered {len(to_register)} event-framework Search Attributes on " f"namespace={namespace!r}: {list(to_register.keys())}",)return statusdiff --git a/server/services/temporal/trigger_listener_workflow.py b/server/services/temporal/trigger_listener_workflow.pyindex 37ccd403..5ea95653 100644--- a/server/services/temporal/trigger_listener_workflow.py+++ b/server/services/temporal/trigger_listener_workflow.py@@ -73,14 +73,10 @@ class TriggerListenerWorkflow:"""event_id = event_payload.get("id")if not event_id:- workflow.logger.warning(- "TriggerListener.on_event: skipping malformed envelope without 'id'"- )+ workflow.logger.warning("TriggerListener.on_event: skipping malformed envelope without 'id'")returnif event_id in self._seen_event_ids:- workflow.logger.debug(- f"TriggerListener.on_event: dedup hit for event.id={event_id}"- )+ workflow.logger.debug(f"TriggerListener.on_event: dedup hit for event.id={event_id}")returnself._seen_event_ids.add(event_id)self._matched_events.append(event_payload)@@ -126,15 +122,11 @@ class TriggerListenerWorkflow:# "seen" so a producer retry with the same id won't# re-fire (correct: server-side dedup applies even on# downstream failure).- workflow.logger.error(- f"TriggerListener spawn failed for event.id={event.get('id')}: {exc}"- )+ workflow.logger.error(f"TriggerListener spawn failed for event.id={event.get('id')}: {exc}")self._processed_count += 1if self._processed_count >= _MAX_EVENTS_BEFORE_CONTINUE_AS_NEW:- workflow.logger.info(- f"TriggerListener continue_as_new: processed={self._processed_count}"- )+ workflow.logger.info(f"TriggerListener continue_as_new: processed={self._processed_count}")workflow.continue_as_new(args=[listener_data])async def _spawn_child_run(@@ -195,13 +187,15 @@ class TriggerListenerWorkflow:await workflow.start_child_workflow("MachinaWorkflow",- args=[{- "nodes": filtered_nodes,- "edges": filtered_edges,- "session_id": session_id,- "workflow_id": workflow_id,- "tenant_id": tenant_id,- }],+ args=[+ {+ "nodes": filtered_nodes,+ "edges": filtered_edges,+ "session_id": session_id,+ "workflow_id": workflow_id,+ "tenant_id": tenant_id,+ }+ ],id=child_id,parent_close_policy=ParentClosePolicy.ABANDON,id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE_FAILED_ONLY,@@ -210,8 +204,7 @@ class TriggerListenerWorkflow:)workflow.logger.info(- f"TriggerListener spawned child run: child_id={child_id} "- f"event.id={event.get('id')} event.type={event.get('type')}"+ f"TriggerListener spawned child run: child_id={child_id} " f"event.id={event.get('id')} event.type={event.get('type')}")await _broadcast_trigger_waiting(@@ -347,10 +340,7 @@ def _build_run_graph(downstream_ids.add(source)# Sub-nodes connected to toolkit nodes (n8n Sub-Node pattern).- toolkit_ids = {- n["id"] for n in nodes- if n.get("type") in TOOLKIT_NODE_TYPES and n["id"] in downstream_ids- }+ toolkit_ids = {n["id"] for n in nodes if n.get("type") in TOOLKIT_NODE_TYPES and n["id"] in downstream_ids}for edge in edges:target = edge.get("target")source = edge.get("source")@@ -358,18 +348,11 @@ def _build_run_graph(downstream_ids.add(source)# Tool nodes connected to AI Agent's input-tools handle.- agent_ids = {- n["id"] for n in nodes- if n.get("type") in AI_AGENT_TYPES and n["id"] in downstream_ids- }+ agent_ids = {n["id"] for n in nodes if n.get("type") in AI_AGENT_TYPES and n["id"] in downstream_ids}for edge in edges:target = edge.get("target")source = edge.get("source")- if (- target in agent_ids- and edge.get("targetHandle", "") == "input-tools"- and source not in downstream_ids- ):+ if target in agent_ids and edge.get("targetHandle", "") == "input-tools" and source not in downstream_ids:downstream_ids.add(source)run_filter = {trigger_node_id} | downstream_ids@@ -387,10 +370,7 @@ def _build_run_graph(node_copy["_trigger_output"] = {"not_triggered": True}filtered_nodes.append(node_copy)- filtered_edges = [- e for e in edges- if e.get("source") in run_filter and e.get("target") in run_filter- ]+ filtered_edges = [e for e in edges if e.get("source") in run_filter and e.get("target") in run_filter]return filtered_nodes, filtered_edgesdiff --git a/server/services/temporal/worker.py b/server/services/temporal/worker.pyindex e7ba6bdc..953157b4 100644--- a/server/services/temporal/worker.py+++ b/server/services/temporal/worker.py@@ -319,10 +319,7 @@ class TemporalWorkerPool:task = asyncio.create_task(worker.run(), name=f"worker-{queue}")self._workers.append(worker)self._tasks.append(task)- logger.info(- f"[Pool] Started worker queue={queue!r} "- f"activities={len(activities)} concurrency={concurrency}"- )+ logger.info(f"[Pool] Started worker queue={queue!r} " f"activities={len(activities)} concurrency={concurrency}")async def stop(self) -> None:for task in self._tasks:diff --git a/server/services/temporal/workflow.py b/server/services/temporal/workflow.pyindex 07d00430..8f05c67e 100644--- a/server/services/temporal/workflow.py+++ b/server/services/temporal/workflow.py@@ -48,25 +48,28 @@ SKILL_NODE_TYPES = {# state (RLM REPL / Claude CLI --resume with stable cwd) requires# single-process continuity and breaks across activity boundaries. They# continue via F4.A per-type activities.-AGENT_WORKFLOW_TYPES = frozenset([- "aiAgent",- "chatAgent",- # Specialized agents (12)- "android_agent",- "coding_agent",- "web_agent",- "task_agent",- "social_agent",- "travel_agent",- "tool_agent",- "productivity_agent",- "payments_agent",- "consumer_agent",- "autonomous_agent",- # Team leads (2)- "orchestrator_agent",- "ai_employee",-])+AGENT_WORKFLOW_TYPES = frozenset(+ [+ "aiAgent",+ "chatAgent",+ # Specialized agents (12)+ "android_agent",+ "coding_agent",+ "web_agent",+ "task_agent",+ "social_agent",+ "travel_agent",+ "tool_agent",+ "productivity_agent",+ "payments_agent",+ "consumer_agent",+ "autonomous_agent",+ # Team leads (2)+ "orchestrator_agent",+ "ai_employee",+ ]+)+@workflow.defn(sandboxed=False)class MachinaWorkflow:@@ -109,21 +112,15 @@ class MachinaWorkflow:"""event_id = event_payload.get("id")if not event_id:- workflow.logger.warning(- "on_event: skipping malformed envelope without 'id'"- )+ workflow.logger.warning("on_event: skipping malformed envelope without 'id'")returnif event_id in self._seen_event_ids:- workflow.logger.debug(- f"on_event: dedup hit for event.id={event_id}"- )+ workflow.logger.debug(f"on_event: dedup hit for event.id={event_id}")returnself._seen_event_ids.add(event_id)self._matched_events.append(event_payload)workflow.logger.info(- f"on_event: queued event.id={event_id} "- f"type={event_payload.get('type', '?')} "- f"(matched={len(self._matched_events)})"+ f"on_event: queued event.id={event_id} " f"type={event_payload.get('type', '?')} " f"(matched={len(self._matched_events)})")def _has_event_matching(self, predicate=None) -> bool:@@ -196,9 +193,7 @@ class MachinaWorkflow:workflow_id = workflow_data.get("workflow_id")tenant_id = workflow_data.get("tenant_id")- workflow.logger.info(- f"Starting workflow orchestration: {len(nodes)} nodes, {len(edges)} edges"- )+ workflow.logger.info(f"Starting workflow orchestration: {len(nodes)} nodes, {len(edges)} edges")if not nodes:return {@@ -212,8 +207,7 @@ class MachinaWorkflow:exec_nodes, exec_edges = self._filter_executable_graph(nodes, edges)workflow.logger.info(- f"After filtering: {len(exec_nodes)} executable nodes "- f"(filtered {len(nodes) - len(exec_nodes)} config nodes)"+ f"After filtering: {len(exec_nodes)} executable nodes " f"(filtered {len(nodes) - len(exec_nodes)} config nodes)")# 2. Build dependency maps@@ -289,9 +283,7 @@ class MachinaWorkflow:# Trigger nodes are event listeners - scheduling them as activities# would block indefinitely waiting for external events.if node_type in TRIGGER_NODE_TYPES and not node.get("_pre_executed"):- workflow.logger.warning(- f"Skipping non-pre-executed trigger: {node_id} ({node_type})"- )+ workflow.logger.warning(f"Skipping non-pre-executed trigger: {node_id} ({node_type})")outputs[node_id] = {"success": True,"result": {"not_triggered": True},@@ -338,10 +330,7 @@ class MachinaWorkflow:run_timeout=timedelta(hours=1),)running[node_id] = handle- workflow.logger.info(- f"Scheduled child workflow for node: {node_id} "- f"(workflow={dispatch['name']})"- )+ workflow.logger.info(f"Scheduled child workflow for node: {node_id} " f"(workflow={dispatch['name']})")else:# F4.A activity path: per-type when the plugin class is# registered AND the per-type flag is on; legacy@@ -390,10 +379,7 @@ class MachinaWorkflow:# Build final resultsuccess = len(errors) == 0 and len(completed) == len(node_map)- workflow.logger.info(- f"Workflow complete: success={success}, "- f"executed={len(execution_trace)}/{len(node_map)}"- )+ workflow.logger.info(f"Workflow complete: success={success}, " f"executed={len(execution_trace)}/{len(node_map)}")return {"success": success,@@ -432,10 +418,7 @@ class MachinaWorkflow:from core.config import Settingssettings = Settings()- if (- getattr(settings, "temporal_agent_workflow_enabled", False)- and node_type in AGENT_WORKFLOW_TYPES- ):+ if getattr(settings, "temporal_agent_workflow_enabled", False) and node_type in AGENT_WORKFLOW_TYPES:return {"kind": "child_workflow", "name": "AgentWorkflow"}name, queue = self._resolve_activity(node_type)@@ -499,9 +482,7 @@ class MachinaWorkflow:[h for _, h in items]# Use asyncio.wait pattern via workflow.wait- await workflow.wait_condition(- lambda: any(h.done() for _, h in items)- )+ await workflow.wait_condition(lambda: any(h.done() for _, h in items))# Find the completed onefor node_id, handle in items:@@ -552,10 +533,9 @@ class MachinaWorkflow:# Filter nodes and edgesexec_nodes = [n for n in nodes if n["id"] not in config_ids]exec_edges = [- e for e in edges- if e.get("source") not in config_ids- and e.get("target") not in config_ids- and e.get("targetHandle", "") not in CONFIG_HANDLES+ e+ for e in edges+ if e.get("source") not in config_ids and e.get("target") not in config_ids and e.get("targetHandle", "") not in CONFIG_HANDLES]return exec_nodes, exec_edgesdiff --git a/server/services/temporal/ws_client.py b/server/services/temporal/ws_client.pyindex c05733d2..6cb2c460 100644--- a/server/services/temporal/ws_client.py+++ b/server/services/temporal/ws_client.py@@ -22,11 +22,15 @@ from core.config import Settingslogger = get_logger(__name__)-# Load settings-_settings = Settings()-WS_URL = f"ws://{_settings.host}:{_settings.port}/ws/internal"-logger.info("WebSocket URL configured", url=WS_URL)+def _default_ws_url() -> str:+ """Resolve the activity-side WS URL from current ``Settings``.++ Deferred to first call so module import doesn't require the full env+ surface — same rationale as ``activities._resolve_urls``.+ """+ settings = Settings()+ return f"ws://{settings.host}:{settings.port}/ws/internal"class WSConnectionPool:@@ -41,8 +45,8 @@ class WSConnectionPool:avoiding the ConcurrencyError that occurs when sharing a single connection."""- def __init__(self, url: str = WS_URL, pool_size: int = 100):- self.url = url+ def __init__(self, url: Optional[str] = None, pool_size: int = 100):+ self.url = url if url is not None else _default_ws_url()self.pool_size = pool_sizeself._session: Optional[aiohttp.ClientSession] = Noneself._lock = asyncio.Lock()@@ -213,7 +217,7 @@ async def close_ws_client() -> None:class TemporalWSClient:"""Backwards compatibility wrapper around WSConnectionPool."""- def __init__(self, url: str = WS_URL):+ def __init__(self, url: Optional[str] = None):self._pool = WSConnectionPool(url=url)@propertydiff --git a/server/services/text.py b/server/services/text.pyindex cd19a4b8..f98bdf4d 100644--- a/server/services/text.py+++ b/server/services/text.py@@ -20,24 +20,15 @@ class TextService:start_time = time.time()try:- text = parameters.get('text', 'Hello World')- include_timestamp = parameters.get('include_timestamp', True)+ text = parameters.get("text", "Hello World")+ include_timestamp = parameters.get("include_timestamp", True)- result_data = {- "text": text,- "length": len(text),- "nodeId": node_id- }+ result_data = {"text": text, "length": len(text), "nodeId": node_id}if include_timestamp:result_data["timestamp"] = datetime.now().isoformat()- result = {- "type": "text",- "data": result_data,- "nodeId": node_id,- "timestamp": datetime.now().isoformat()- }+ result = {"type": "text", "data": result_data, "nodeId": node_id, "timestamp": datetime.now().isoformat()}log_execution_time(logger, "text_generator", start_time, time.time())@@ -47,7 +38,7 @@ class TextService:"node_type": "textGenerator","result": result,"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:@@ -58,7 +49,7 @@ class TextService:"node_type": "textGenerator","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}async def execute_file_handler(self, node_id: str, parameters: Dict[str, Any]) -> Dict[str, Any]:@@ -66,9 +57,9 @@ class TextService:start_time = time.time()try:- file_type = parameters.get('file_type', 'generic')- file_content = parameters.get('content', '')- file_name = parameters.get('file_name', 'untitled.txt')+ file_type = parameters.get("file_type", "generic")+ file_content = parameters.get("content", "")+ file_name = parameters.get("file_name", "untitled.txt")# Basic file processingresult_data = {@@ -78,16 +69,11 @@ class TextService:"size": len(file_content),"processed": True,"processingType": file_type,- "nodeId": node_id- }-- result = {- "type": "file",- "data": result_data,"nodeId": node_id,- "timestamp": datetime.now().isoformat()}+ result = {"type": "file", "data": result_data, "nodeId": node_id, "timestamp": datetime.now().isoformat()}+log_execution_time(logger, "file_handler", start_time, time.time())return {@@ -96,7 +82,7 @@ class TextService:"node_type": "fileHandler","result": result,"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()+ "timestamp": datetime.now().isoformat(),}except Exception as e:@@ -107,5 +93,5 @@ class TextService:"node_type": "fileHandler","error": str(e),"execution_time": time.time() - start_time,- "timestamp": datetime.now().isoformat()- }\ No newline at end of file+ "timestamp": datetime.now().isoformat(),+ }diff --git a/server/services/tracked_http.py b/server/services/tracked_http.pyindex d45c0eee..fc14ccbd 100644--- a/server/services/tracked_http.py+++ b/server/services/tracked_http.py@@ -14,6 +14,7 @@ Usage:client = get_tracked_client()response = await client.post("https://api.twitter.com/2/tweets", json={...})"""+import reimport asyncioimport contextvars@@ -30,22 +31,12 @@ logger = get_logger(__name__)# Context Variables (thread-safe tracking metadata)# ============================================================================-_tracking_ctx: contextvars.ContextVar[Dict[str, Any]] = contextvars.ContextVar(- 'api_tracking', default={}-)+_tracking_ctx: contextvars.ContextVar[Dict[str, Any]] = contextvars.ContextVar("api_tracking", default={})-def set_tracking_context(- node_id: str,- session_id: str = "default",- workflow_id: Optional[str] = None-):+def set_tracking_context(node_id: str, session_id: str = "default", workflow_id: Optional[str] = None):"""Set tracking context for current async task."""- _tracking_ctx.set({- 'node_id': node_id,- 'session_id': session_id,- 'workflow_id': workflow_id- })+ _tracking_ctx.set({"node_id": node_id, "session_id": session_id, "workflow_id": workflow_id})def clear_tracking_context():@@ -74,7 +65,7 @@ def _load_url_patterns():try:pricing = get_pricing_service()- _url_patterns = pricing.get_config().get('url_patterns', {})+ _url_patterns = pricing.get_config().get("url_patterns", {})_patterns_loaded = Truelogger.debug(f"[APITracker] Loaded URL patterns for {len(_url_patterns)} services")except Exception as e:@@ -103,11 +94,11 @@ def _match_url(url: str, method: str) -> Optional[Tuple[str, str, Optional[str]]_load_url_patterns()for service, config in _url_patterns.items():- base = config.get('base', '')+ base = config.get("base", "")if not base or not re.search(base, url):continue- for pattern, action_info in config.get('actions', {}).items():+ for pattern, action_info in config.get("actions", {}).items():if not re.search(pattern, url):continue@@ -116,13 +107,9 @@ def _match_url(url: str, method: str) -> Optional[Tuple[str, str, Optional[str]]return (service, action_info, None)# Dict with action, method, count_path- expected_method = action_info.get('method', '*')- if expected_method == '*' or expected_method.upper() == method.upper():- return (- service,- action_info.get('action', 'unknown'),- action_info.get('count_path')- )+ expected_method = action_info.get("method", "*")+ if expected_method == "*" or expected_method.upper() == method.upper():+ return (service, action_info.get("action", "unknown"), action_info.get("count_path"))return None@@ -142,8 +129,8 @@ def _extract_count(data: Any, path: Optional[str]) -> int:return 1try:- for part in path.split('.'):- if part == 'length' and isinstance(data, list):+ for part in path.split("."):+ if part == "length" and isinstance(data, list):return len(data)elif isinstance(data, dict):data = data.get(part)@@ -163,6 +150,7 @@ def _extract_count(data: Any, path: Optional[str]) -> int:# HTTPX Event Hook (the magic happens here)# ============================================================================+async def _on_response(response: httpx.Response):"""HTTPX response event hook - tracks API calls automatically.@@ -204,34 +192,28 @@ async def _on_response(response: httpx.Response):logger.error(f"[APITracker] Error in response hook: {e}")-async def _save_metric(- service: str,- action: str,- count: int,- ctx: Dict[str, Any]-):+async def _save_metric(service: str, action: str, count: int, ctx: Dict[str, Any]):"""Save metric to database (non-blocking)."""try:pricing = get_pricing_service()cost = pricing.calculate_api_cost(service, action, count)db = container.database()- await db.save_api_usage_metric({- 'session_id': ctx.get('session_id', 'default'),- 'node_id': ctx.get('node_id', ''),- 'workflow_id': ctx.get('workflow_id'),- 'service': service,- 'operation': cost.get('operation', action),- 'endpoint': action,- 'resource_count': count,- 'cost': cost.get('total_cost', 0.0)- })-- logger.debug(- f"[APITracker] Tracked {service}/{action}: "- f"{count} resources, ${cost.get('total_cost', 0):.6f}"+ await db.save_api_usage_metric(+ {+ "session_id": ctx.get("session_id", "default"),+ "node_id": ctx.get("node_id", ""),+ "workflow_id": ctx.get("workflow_id"),+ "service": service,+ "operation": cost.get("operation", action),+ "endpoint": action,+ "resource_count": count,+ "cost": cost.get("total_cost", 0.0),+ })+ logger.debug(f"[APITracker] Tracked {service}/{action}: " f"{count} resources, ${cost.get('total_cost', 0):.6f}")+except Exception as e:logger.error(f"[APITracker] Failed to save metric: {e}")@@ -240,6 +222,7 @@ async def _save_metric(# Tracked Client Factory# ============================================================================+def create_tracked_client(**kwargs) -> httpx.AsyncClient:"""Create an httpx.AsyncClient with tracking enabled.@@ -256,10 +239,7 @@ def create_tracked_client(**kwargs) -> httpx.AsyncClient:Returns:httpx.AsyncClient with tracking event hook"""- return httpx.AsyncClient(- event_hooks={'response': [_on_response]},- **kwargs- )+ return httpx.AsyncClient(event_hooks={"response": [_on_response]}, **kwargs)# Shared singleton client (for performance)diff --git a/server/services/user_auth.py b/server/services/user_auth.pyindex bffccb46..9a51be6f 100644--- a/server/services/user_auth.py+++ b/server/services/user_auth.py@@ -41,9 +41,7 @@ class UserAuthService:async def get_user_by_email(self, email: str) -> Optional[User]:"""Get user by email address."""async with self.database.get_session() as session:- result = await session.execute(- select(User).where(User.email == email.lower().strip())- )+ result = await session.execute(select(User).where(User.email == email.lower().strip()))return result.scalars().first()async def get_user_by_id(self, user_id: int) -> Optional[User]:@@ -60,9 +58,7 @@ class UserAuthService:count = await self.get_user_count()return count == 0- async def register(- self, email: str, password: str, display_name: str- ) -> tuple[Optional[User], Optional[str]]:+ async def register(self, email: str, password: str, display_name: str) -> tuple[Optional[User], Optional[str]]:"""Register a new user.Returns (user, None) on success, (None, error_message) on failure.@@ -83,9 +79,7 @@ class UserAuthService:return None, "Password must be at least 8 characters"# Determine if this is the owner (first user in single-owner mode)- is_owner = (- self.settings.auth_mode == "single" and await self.get_user_count() == 0- )+ is_owner = self.settings.auth_mode == "single" and await self.get_user_count() == 0# Create useruser = User.create(@@ -104,9 +98,7 @@ class UserAuthService:return user, None- async def login(- self, email: str, password: str- ) -> tuple[Optional[User], Optional[str]]:+ async def login(self, email: str, password: str) -> tuple[Optional[User], Optional[str]]:"""Authenticate user and return user object.Returns (user, None) on success, (None, error_message) on failure.@@ -138,9 +130,7 @@ class UserAuthService:def create_access_token(self, user: User) -> str:"""Create JWT access token for user."""- expire = datetime.now(timezone.utc) + timedelta(- minutes=self.settings.jwt_expire_minutes- )+ expire = datetime.now(timezone.utc) + timedelta(minutes=self.settings.jwt_expire_minutes)payload = {"sub": str(user.id),"email": user.email,@@ -149,9 +139,7 @@ class UserAuthService:"exp": expire,"iat": datetime.now(timezone.utc),}- return jwt.encode(- payload, self.settings.jwt_secret_key, algorithm=self._algorithm- )+ return jwt.encode(payload, self.settings.jwt_secret_key, algorithm=self._algorithm)def verify_token(self, token: str) -> Optional[Dict[str, Any]]:"""@@ -159,9 +147,7 @@ class UserAuthService:Returns None if token is invalid or expired."""try:- payload = jwt.decode(- token, self.settings.jwt_secret_key, algorithms=[self._algorithm]- )+ payload = jwt.decode(token, self.settings.jwt_secret_key, algorithms=[self._algorithm])return payloadexcept JWTError as e:logger.debug(f"Token verification failed: {e}")diff --git a/server/services/workflow.py b/server/services/workflow.pyindex cd28d0cf..7c62220b 100644--- a/server/services/workflow.py+++ b/server/services/workflow.py@@ -114,6 +114,7 @@ class WorkflowService:"""Get or create DeploymentManager."""if self._deployment_manager is None:from services.status_broadcaster import get_status_broadcaster+self._broadcaster = get_status_broadcaster()self._deployment_manager = DeploymentManager(database=self.database,@@ -260,10 +261,12 @@ class WorkflowService:else:chosen = "sequential"logger.info(- "[execute_workflow] routing decision: %s "- "(temporal_enabled=%s, executor_wired=%s, parallel=%s, redis=%s)",- chosen, use_temporal, executor_wired,- use_parallel, self.settings.redis_enabled,+ "[execute_workflow] routing decision: %s " "(temporal_enabled=%s, executor_wired=%s, parallel=%s, redis=%s)",+ chosen,+ use_temporal,+ executor_wired,+ use_parallel,+ self.settings.redis_enabled,extra={"workflow_id": workflow_id},)@@ -370,16 +373,16 @@ class WorkflowService:executed = []for node in execution_order:- node_id = node['id']- node_type = node.get('type', 'unknown')+ node_id = node["id"]+ node_type = node.get("type", "unknown")# Skip pre-executed trigger nodes- if node.get('_pre_executed'):+ if node.get("_pre_executed"):executed.append(node_id)continue# Skip disabled nodes (n8n-style disable)- if node.get('data', {}).get('disabled'):+ if node.get("data", {}).get("disabled"):logger.debug(f"Skipping disabled node: {node_id}")executed.append(node_id)if status_callback:@@ -469,12 +472,14 @@ class WorkflowService:if workflow_id:try:from services.cli_agent.service import get_ai_cli_service+cli_svc = get_ai_cli_service()cancelled = await cli_svc.cancel_workflow(workflow_id)if cancelled:logger.info("[workflow] cancelled %d CLI agent session(s) for workflow %s",- cancelled, workflow_id,+ cancelled,+ workflow_id,)except Exception as exc:logger.debug("[workflow] CLI agent cancel: %s", exc)@@ -527,7 +532,9 @@ class WorkflowService:# ops that are individually atomic and together race-free since# there is no await between them.self._outputs.setdefault(key, {})[output_name] = data- logger.debug(f"[store_node_output] Stored in memory: key={key}, output_name={output_name}, _outputs keys={list(self._outputs.keys())}")+ logger.debug(+ f"[store_node_output] Stored in memory: key={key}, output_name={output_name}, _outputs keys={list(self._outputs.keys())}"+ )await self.database.save_node_output(node_id, session_id, output_name, data)async def get_node_output(@@ -555,12 +562,13 @@ class WorkflowService:output = self._outputs[key][output_name]# Special handling for start nodes- if output is None and node_id.startswith('start-'):+ if output is None and node_id.startswith("start-"):import json+params = await self.database.get_node_parameters(node_id)- if params and 'initial_data' in params:+ if params and "initial_data" in params:try:- output = json.loads(params.get('initial_data', '{}'))+ output = json.loads(params.get("initial_data", "{}"))except Exception:output = {}@@ -593,13 +601,13 @@ class WorkflowService:"""Find workflow entry point."""# Priority: start > cronScheduler > other triggersfor node in nodes:- if node.get('type') == 'start':+ if node.get("type") == "start":return nodefor node in nodes:- if node.get('type') == 'cronScheduler':+ if node.get("type") == "cronScheduler":return nodefor node in nodes:- if node.get('type') in WORKFLOW_TRIGGER_TYPES:+ if node.get("type") in WORKFLOW_TRIGGER_TYPES:return nodereturn None@@ -607,16 +615,16 @@ class WorkflowService:"""Build BFS execution order from start node."""visited = set()order = []- queue = [start['id']]+ queue = [start["id"]]# Build adjacency mapadj = {}for e in edges:- src = e.get('source')+ src = e.get("source")if src:- adj.setdefault(src, []).append(e.get('target'))+ adj.setdefault(src, []).append(e.get("target"))- node_map = {n['id']: n for n in nodes}+ node_map = {n["id"]: n for n in nodes}while queue:nid = queue.pop(0)diff --git a/server/services/workflow_import.py b/server/services/workflow_import.pyindex f640859c..b095c772 100644--- a/server/services/workflow_import.py+++ b/server/services/workflow_import.py@@ -78,21 +78,20 @@ def remap_node_ids(if old_id:id_map[old_id] = f"{prefix}-{now}{index}-{salt}"- new_nodes = [- {**node, "id": id_map.get(node.get("id"), node.get("id"))}- for node in nodes- ]+ new_nodes = [{**node, "id": id_map.get(node.get("id"), node.get("id"))} for node in nodes]new_edges: List[Dict[str, Any]] = []for edge in edges:src = id_map.get(edge.get("source"), edge.get("source"))tgt = id_map.get(edge.get("target"), edge.get("target"))- new_edges.append({- **edge,- "source": src,- "target": tgt,- "id": f"e-{src}-{tgt}-{now}-{salt}",- })+ new_edges.append(+ {+ **edge,+ "source": src,+ "target": tgt,+ "id": f"e-{src}-{tgt}-{now}-{salt}",+ }+ )new_params: Dict[str, Dict[str, Any]] = {}for old_id, params in node_parameters.items():@@ -133,9 +132,7 @@ def extract_requirements(nodes: List[Dict[str, Any]]) -> Dict[str, Any]:}-async def cross_check_credentials(- requirements: Dict[str, Any], auth_service-) -> List[Dict[str, Any]]:+async def cross_check_credentials(requirements: Dict[str, Any], auth_service) -> List[Dict[str, Any]]:"""For each credential in the manifest, ask ``auth_service`` whetherit's stored. Returns the MISSING ones with display info pulled from``CREDENTIAL_REGISTRY`` so the frontend can render a friendly list.@@ -154,17 +151,21 @@ async def cross_check_credentials(stored = await auth_service.has_valid_key(pid)except Exception:logger.debug(- "[workflow_import] has_valid_key failed for %s", pid, exc_info=True,+ "[workflow_import] has_valid_key failed for %s",+ pid,+ exc_info=True,)stored = Falseif stored:continuecred_cls = CREDENTIAL_REGISTRY.get(pid)- missing.append({- "provider_id": pid,- "display_name": getattr(cred_cls, "display_name", pid) if cred_cls else pid,- "kind": getattr(cred_cls, "auth", "api_key") if cred_cls else "api_key",- })+ missing.append(+ {+ "provider_id": pid,+ "display_name": getattr(cred_cls, "display_name", pid) if cred_cls else pid,+ "kind": getattr(cred_cls, "auth", "api_key") if cred_cls else "api_key",+ }+ )return missing@@ -250,7 +251,9 @@ async def import_workflow(# 1. Validate. Errors block the import; warnings flow through.report = await validate_workflow(- nodes=nodes, edges=edges, parameters_by_id=node_parameters,+ nodes=nodes,+ edges=edges,+ parameters_by_id=node_parameters,)if report["errors"]:return {@@ -269,9 +272,7 @@ async def import_workflow(name_check = await check_name_conflict(proposed_name, database)# 5. If anything needs user confirmation, return preview without saving.- needs_preview = (- bool(missing_credentials) and not force_credentials- ) or name_check["has_conflict"]+ needs_preview = (bool(missing_credentials) and not force_credentials) or name_check["has_conflict"]if needs_preview:return {"success": True,@@ -286,7 +287,9 @@ async def import_workflow(# 6. Remap node ids — protects the node_parameters table from# duplicate-id collisions across imports.remapped_nodes, remapped_edges, remapped_params = remap_node_ids(- nodes, edges, node_parameters,+ nodes,+ edges,+ node_parameters,)# 7. Save. Workflow id format matches the frontend's generateWorkflowId.@@ -311,7 +314,8 @@ async def import_workflow(except Exception as e:logger.error("[workflow_import] save_node_parameters failed for %s: %s",- node_id, e,+ node_id,+ e,)# 9. CloudEvents broadcast — ``workflow.imported`` envelope. Other@@ -321,6 +325,7 @@ async def import_workflow(# import — the workflow IS saved either way.try:from services.status_broadcaster import get_status_broadcaster+await get_status_broadcaster().broadcast_workflow_lifecycle("imported",workflow_id=workflow_id,diff --git a/server/services/workflow_ops.py b/server/services/workflow_ops.pyindex 8a3cc7b8..e5011c7f 100644--- a/server/services/workflow_ops.py+++ b/server/services/workflow_ops.py@@ -37,6 +37,7 @@ from typing import Any, Dict, List, Literal, Optional, TypedDict, Union# Position spec# ---------------------------------------------------------------------------+class AbsolutePosition(TypedDict):x: floaty: float@@ -62,6 +63,7 @@ PositionSpec = Union[AbsolutePosition, AnchoredPosition]# Node references# ---------------------------------------------------------------------------+class _ClientRef(TypedDict):client_ref: str@@ -76,6 +78,7 @@ NodeRef = Union[str, _ClientRef]# Operation TypedDicts# ---------------------------------------------------------------------------+class AddNodeOp(TypedDict, total=False):type: Literal["add_node"]client_ref: str@@ -139,6 +142,7 @@ WorkflowOperation = Union[# Builder helpers# ---------------------------------------------------------------------------+def add_node(client_ref: str,node_type: str,diff --git a/server/services/workflow_validator.py b/server/services/workflow_validator.pyindex 1b721636..96e20d0b 100644--- a/server/services/workflow_validator.py+++ b/server/services/workflow_validator.py@@ -75,17 +75,21 @@ async def validate_workflow(src = e.get("source")tgt = e.get("target")if src and src not in node_by_id:- errors.append({- "code": "DANGLING_EDGE",- "node_id": None,- "message": f"Edge source {src!r} does not match any node",- })+ errors.append(+ {+ "code": "DANGLING_EDGE",+ "node_id": None,+ "message": f"Edge source {src!r} does not match any node",+ }+ )if tgt and tgt not in node_by_id:- errors.append({- "code": "DANGLING_EDGE",- "node_id": None,- "message": f"Edge target {tgt!r} does not match any node",- })+ errors.append(+ {+ "code": "DANGLING_EDGE",+ "node_id": None,+ "message": f"Edge target {tgt!r} does not match any node",+ }+ )# 2. Unknown node types — plugin not installed on this instance. Errors.# 3. Per-node Pydantic param validation. Warnings (matches runtime@@ -102,12 +106,14 @@ async def validate_workflow(cls = get_node_class(node_type)if cls is None:- errors.append({- "code": "UNKNOWN_NODE_TYPE",- "node_id": node_id,- "node_type": node_type,- "message": f"Plugin type {node_type!r} is not installed",- })+ errors.append(+ {+ "code": "UNKNOWN_NODE_TYPE",+ "node_id": node_id,+ "node_type": node_type,+ "message": f"Plugin type {node_type!r} is not installed",+ }+ )continue# Param validation — prefer caller-supplied params, fall back to@@ -127,18 +133,16 @@ async def validate_workflow(first_err = errs[0]except Exception:pass- msg = (- first_err.get("msg")- if isinstance(first_err, dict) and first_err.get("msg")- else str(exc)+ msg = first_err.get("msg") if isinstance(first_err, dict) and first_err.get("msg") else str(exc)+ warnings.append(+ {+ "code": "INVALID_PARAM",+ "node_id": node_id,+ "node_type": node_type,+ "message": msg,+ "path": list(first_err.get("loc", ())) if isinstance(first_err, dict) else [],+ })- warnings.append({- "code": "INVALID_PARAM",- "node_id": node_id,- "node_type": node_type,- "message": msg,- "path": list(first_err.get("loc", ())) if isinstance(first_err, dict) else [],- })# Credential presence — for each Credential subclass declared on# the plugin, ask AuthService whether a key/token is stored.@@ -149,24 +153,28 @@ async def validate_workflow(# fake auth_service injected via the parameter — see# tests/test_workflow_validator.py).from core.container import container+auth_service = container.auth_service()try:stored = await auth_service.has_valid_key(cred_cls.id)except Exception:logger.debug("[workflow_validator] has_valid_key failed for %s",- cred_cls.id, exc_info=True,+ cred_cls.id,+ exc_info=True,)stored = Falseif not stored:- warnings.append({- "code": "MISSING_CREDENTIAL",- "node_id": node_id,- "node_type": node_type,- "provider_id": cred_cls.id,- "message": f"Credential {cred_cls.id!r} is not configured",- "remediation": "add_key",- })+ warnings.append(+ {+ "code": "MISSING_CREDENTIAL",+ "node_id": node_id,+ "node_type": node_type,+ "provider_id": cred_cls.id,+ "message": f"Credential {cred_cls.id!r} is not configured",+ "remediation": "add_key",+ }+ )# 5. Cycle detection via Kahn's algorithm. Errors when unresolved nodes# remain after the topological pass. Mirrors the warn-and-continue@@ -189,11 +197,13 @@ async def validate_workflow(queue.append(e["target"])if seen < len(in_degree):unresolved = sorted(nid for nid, d in in_degree.items() if d > 0)- errors.append({- "code": "CYCLE",- "node_id": None,- "message": f"Cycle detected involving nodes: {unresolved}",- "nodes": unresolved,- })+ errors.append(+ {+ "code": "CYCLE",+ "node_id": None,+ "message": f"Cycle detected involving nodes: {unresolved}",+ "nodes": unresolved,+ }+ )return {"errors": errors, "warnings": warnings}diff --git a/server/services/ws_handler_registry.py b/server/services/ws_handler_registry.pyindex 432a3d63..25487034 100644--- a/server/services/ws_handler_registry.py+++ b/server/services/ws_handler_registry.py@@ -59,6 +59,7 @@ def ws_handler(*required_fields: str):under ``services/`` can decorate their own handlers without acircular import on the router."""+def decorator(func: WSHandler) -> WSHandler:@functools.wraps(func)async def wrapper(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:@@ -73,21 +74,21 @@ def ws_handler(*required_fields: str):except Exception as e:logger.error(f"Handler error: {e}", exc_info=True)return {"success": False, "error": str(e)}+return wrapper+return decorator+_WS_REGISTRY: IdempotentRegistry[str, WSHandler] = IdempotentRegistry("ws_handler")_ROUTER_REGISTRY: IdempotentRegistry[str, APIRouter] = IdempotentRegistry("router")-_OPTION_LOADER_REGISTRY: IdempotentRegistry[str, LoadOptionsFn] = IdempotentRegistry(- "option_loader"-)-_OAUTH_CALLBACK_PATHS: IdempotentRegistry[str, str] = IdempotentRegistry(- "oauth_callback_path"-)+_OPTION_LOADER_REGISTRY: IdempotentRegistry[str, LoadOptionsFn] = IdempotentRegistry("option_loader")+_OAUTH_CALLBACK_PATHS: IdempotentRegistry[str, str] = IdempotentRegistry("oauth_callback_path")# ---- WebSocket handlers --------------------------------------------------+def register_ws_handlers(handlers: Dict[str, WSHandler]) -> None:"""Publish a batch of ``message_type -> handler`` mappings.@@ -115,6 +116,7 @@ def list_registered_types() -> list[str]:# ---- HTTP routers --------------------------------------------------------+def register_router(router: APIRouter, *, name: str) -> None:"""Publish a plugin-owned ``APIRouter`` for inclusion at app startup.@@ -139,6 +141,7 @@ def list_registered_routers() -> List[str]:# ---- Option loaders ------------------------------------------------------+def register_option_loader(method_name: str, fn: LoadOptionsFn) -> None:"""Publish a ``loadOptionsMethod`` async loader.@@ -162,9 +165,7 @@ def list_registered_option_methods() -> List[str]:return sorted(_OPTION_LOADER_REGISTRY.keys())-async def dispatch_load_options(- method: str, params: Dict[str, Any] | None = None-) -> List[Dict[str, Any]]:+async def dispatch_load_options(method: str, params: Dict[str, Any] | None = None) -> List[Dict[str, Any]]:"""Look up and invoke a registered loader.Returns an empty list when the method isn't registered (matches@@ -186,6 +187,7 @@ def list_load_options_methods() -> List[str]:# ---- OAuth callback paths -----------------------------------------------+def register_oauth_callback_path(provider: str, path: str) -> None:"""Publish a plugin's OAuth callback path (``/api/<provider>/callback``).diff --git a/server/tests/conftest.py b/server/tests/conftest.pyindex 0d196c40..160c2351 100644--- a/server/tests/conftest.py+++ b/server/tests/conftest.py@@ -56,6 +56,8 @@ def _stub_log_execution_time(*_args, **_kwargs):# real submodule attributes so imports resolve without touching the real# heavy deps (dependency_injector, cryptography, ...)._core_pkg = _make_package("core")++def _stub_log_context(**_fields):"""Stub for ``core.logging.log_context`` (async ctx manager) and``log_context_sync``. Both are no-ops under test."""@@ -102,19 +104,23 @@ _make_submodule("core", "cache", {"CacheService": MagicMock})# locally; the stub just keeps import-time ``MACHINA_CLAUDE_DIR =# claude_config_dir()`` calls from blowing up._TEST_MACHINA_ROOT = Path(__file__).parent / "_test_machina_root"-_make_submodule("core", "paths", {- "project_root": lambda: _TEST_MACHINA_ROOT.parent,- "machina_root": lambda: _TEST_MACHINA_ROOT,- "packages_dir": lambda: _TEST_MACHINA_ROOT / "packages",- "package_dir": lambda name: _TEST_MACHINA_ROOT / "packages" / name,- "claude_config_dir": lambda: _TEST_MACHINA_ROOT / "claude",- "claude_npm_dir": lambda: _TEST_MACHINA_ROOT / "claude" / "npm",- "workspaces_dir": lambda: _TEST_MACHINA_ROOT / "workspaces",- "workspace_dir": lambda wf: _TEST_MACHINA_ROOT / "workspaces" / wf,- "example_workflows_dir": lambda: _TEST_MACHINA_ROOT / "workflows",- "whatsapp_dir": lambda: _TEST_MACHINA_ROOT / "whatsapp",- "credentials_db_path": lambda: _TEST_MACHINA_ROOT / "credentials.db",-})+_make_submodule(+ "core",+ "paths",+ {+ "project_root": lambda: _TEST_MACHINA_ROOT.parent,+ "machina_root": lambda: _TEST_MACHINA_ROOT,+ "packages_dir": lambda: _TEST_MACHINA_ROOT / "packages",+ "package_dir": lambda name: _TEST_MACHINA_ROOT / "packages" / name,+ "claude_config_dir": lambda: _TEST_MACHINA_ROOT / "claude",+ "claude_npm_dir": lambda: _TEST_MACHINA_ROOT / "claude" / "npm",+ "workspaces_dir": lambda: _TEST_MACHINA_ROOT / "workspaces",+ "workspace_dir": lambda wf: _TEST_MACHINA_ROOT / "workspaces" / wf,+ "example_workflows_dir": lambda: _TEST_MACHINA_ROOT / "workflows",+ "whatsapp_dir": lambda: _TEST_MACHINA_ROOT / "whatsapp",+ "credentials_db_path": lambda: _TEST_MACHINA_ROOT / "credentials.db",+ },+)# services.pricing -- pre-stub the singleton so handler modules that do@@ -123,9 +129,7 @@ _make_submodule("core", "paths", {# config/pricing.json and is irrelevant to handler contract tests).def _make_pricing_stub():pricing = MagicMock(name="StubPricingService")- pricing.calculate_api_cost = MagicMock(- return_value={"operation": "stub", "total_cost": 0.0}- )+ pricing.calculate_api_cost = MagicMock(return_value={"operation": "stub", "total_cost": 0.0})pricing.calculate_cost = MagicMock(return_value={"input_cost": 0.0,diff --git a/server/tests/credentials/test_auth_service.py b/server/tests/credentials/test_auth_service.pyindex 4b21612e..8ad7fa14 100644--- a/server/tests/credentials/test_auth_service.py+++ b/server/tests/credentials/test_auth_service.py@@ -28,9 +28,7 @@ class TestApiKeyOps:async def test_store_with_empty_models_for_non_llm_keys(self, auth_service):# Pattern C: save-only API keys (telegram, android_remote, etc.)- ok = await auth_service.store_api_key(- "telegram", "123:abc", models=[]- )+ ok = await auth_service.store_api_key("telegram", "123:abc", models=[])assert ok is Trueassert await auth_service.get_api_key("telegram") == "123:abc"assert await auth_service.get_stored_models("telegram") == []@@ -53,12 +51,8 @@ class TestApiKeyOps:assert await auth_service.has_valid_key("openai") is Trueasync def test_session_isolation(self, auth_service):- await auth_service.store_api_key(- "openai", "sk-default", models=[], session_id="default"- )- await auth_service.store_api_key(- "openai", "sk-other", models=[], session_id="other"- )+ await auth_service.store_api_key("openai", "sk-default", models=[], session_id="default")+ await auth_service.store_api_key("openai", "sk-other", models=[], session_id="other")assert await auth_service.get_api_key("openai", "default") == "sk-default"assert await auth_service.get_api_key("openai", "other") == "sk-other"@@ -87,9 +81,7 @@ class TestMemoryCache:await auth_service.get_api_key("openai")assert call_count["n"] == 0- async def test_get_falls_back_to_db_when_cache_missing(- self, auth_service, monkeypatch- ):+ async def test_get_falls_back_to_db_when_cache_missing(self, auth_service, monkeypatch):await auth_service.store_api_key("openai", "sk-foo", models=[])# Wipe memory cache to simulate fresh process@@ -156,9 +148,7 @@ class TestOAuthOps:# The refresh token is reachable through the dedicated helper# that always reads from the encrypted DB (no in-memory cache).- assert (- await auth_service.get_oauth_refresh_token("google") == "refresh-1"- )+ assert await auth_service.get_oauth_refresh_token("google") == "refresh-1"async def test_remove_oauth_tokens(self, auth_service):await auth_service.store_oauth_tokens("google", "a", "r")@@ -169,9 +159,7 @@ class TestOAuthOps:async def test_oauth_cache_isolated_from_api_key_cache(self, auth_service):# Invariants 3 and 8: same provider name in both caches must not collideawait auth_service.store_api_key("google", "api-key-value", models=[])- await auth_service.store_oauth_tokens(- "google", "oauth-access", "oauth-refresh"- )+ await auth_service.store_oauth_tokens("google", "oauth-access", "oauth-refresh")assert await auth_service.get_api_key("google") == "api-key-value"diff --git a/server/tests/credentials/test_credential_broadcasts.py b/server/tests/credentials/test_credential_broadcasts.pyindex df8469ea..553ebab1 100644--- a/server/tests/credentials/test_credential_broadcasts.py+++ b/server/tests/credentials/test_credential_broadcasts.py@@ -35,9 +35,7 @@ pytestmark = pytest.mark.credentials# broadcaster.broadcast_credential_event("credential.<anything>", ...)# Anchor on `.update_api_key_status(` or `.broadcast_credential_event(`# so renames force a test update (intentional).-_BROADCAST_PATTERN = re.compile(- r"\.(?:update_api_key_status|broadcast_credential_event)\s*\("-)+_BROADCAST_PATTERN = re.compile(r"\.(?:update_api_key_status|broadcast_credential_event)\s*\(")def _handler_source(handler) -> str:@@ -69,8 +67,7 @@ class TestCredentialMutationHandlersBroadcast:src = inspect.getsource(Credential.validate)assert _BROADCAST_PATTERN.search(src), (- "Credential.validate must broadcast via update_api_key_status — "- "every credential mutation must surface to connected clients."+ "Credential.validate must broadcast via update_api_key_status — " "every credential mutation must surface to connected clients.")def test_save_api_key_broadcasts(self):@@ -106,17 +103,13 @@ class TestCredentialMutationHandlersBroadcast:from nodes.twitter._handlers import handle_twitter_logoutsrc = _handler_source(handle_twitter_logout)- assert _BROADCAST_PATTERN.search(src), (- "handle_twitter_logout must broadcast credential.oauth.disconnected"- )+ assert _BROADCAST_PATTERN.search(src), "handle_twitter_logout must broadcast credential.oauth.disconnected"def test_google_logout_broadcasts(self):from nodes.google._handlers import handle_google_logoutsrc = _handler_source(handle_google_logout)- assert _BROADCAST_PATTERN.search(src), (- "handle_google_logout must broadcast credential.oauth.disconnected"- )+ assert _BROADCAST_PATTERN.search(src), "handle_google_logout must broadcast credential.oauth.disconnected"class TestCredentialEventCloudEventsShape:@@ -209,12 +202,8 @@ class TestAuthServiceDbCanonicalInvariant:body = match.group(0)# Find the cache-write block. It assigns to self._oauth_cache[...].- cache_block = re.search(- r"self\._oauth_cache\[\w+\]\s*=\s*\{[^}]+\}", body, re.DOTALL- )- assert cache_block, (- "AuthService.store_oauth_tokens must populate _oauth_cache"- )+ cache_block = re.search(r"self\._oauth_cache\[\w+\]\s*=\s*\{[^}]+\}", body, re.DOTALL)+ assert cache_block, "AuthService.store_oauth_tokens must populate _oauth_cache"assert '"refresh_token"' not in cache_block.group(0), ("RFC 9700 violation: _oauth_cache entry must not carry ""refresh_token. Use get_oauth_refresh_token() helper that "@@ -246,12 +235,10 @@ class TestCredentialRuntimeFailureBroadcast:for label, src in (("OAuth2Credential", oauth_src), ("ApiKeyCredential", apikey_src)):assert "err.provider" in src, (- f"{label}.resolve must annotate PermissionError with .provider "- "so BaseNode.execute can surface the failing credential."+ f"{label}.resolve must annotate PermissionError with .provider " "so BaseNode.execute can surface the failing credential.")assert "err.reason" in src, (- f"{label}.resolve must annotate PermissionError with .reason "- "('missing' / 'expired' / 'invalid')."+ f"{label}.resolve must annotate PermissionError with .reason " "('missing' / 'expired' / 'invalid').")assert "err.auth" in src, (f"{label}.resolve must annotate PermissionError with .auth "@@ -271,10 +258,7 @@ class TestCredentialRuntimeFailureBroadcast:"""from services.plugin import base as base_module- src = (- inspect.getsource(base_module.BaseNode.execute)- + inspect.getsource(base_module.BaseNode._execute_body)- )+ src = inspect.getsource(base_module.BaseNode.execute) + inspect.getsource(base_module.BaseNode._execute_body)assert _BROADCAST_PATTERN.search(src), ("BaseNode must broadcast on PermissionError so missing ""credentials surface to the Credentials modal. Reuses the "@@ -282,8 +266,7 @@ class TestCredentialRuntimeFailureBroadcast:)# Type string convention: credential.<auth>.runtime_failedassert "runtime_failed" in src, (- "BaseNode should emit credential.<auth>.runtime_failed "- "(matches the credential.oauth.connected naming convention)."+ "BaseNode should emit credential.<auth>.runtime_failed " "(matches the credential.oauth.connected naming convention).")def test_broadcast_credential_event_carries_workflow_id_and_extras(self):diff --git a/server/tests/credentials/test_credentials_database.py b/server/tests/credentials/test_credentials_database.pyindex 2140063d..303e7c31 100644--- a/server/tests/credentials/test_credentials_database.py+++ b/server/tests/credentials/test_credentials_database.py@@ -51,9 +51,7 @@ class TestApiKeyCrud:assert deleted is Trueassert await credentials_db.get_api_key("openai") is None- async def test_delete_nonexistent_returns_false(- self, credentials_db: CredentialsDatabase- ):+ async def test_delete_nonexistent_returns_false(self, credentials_db: CredentialsDatabase):assert await credentials_db.delete_api_key("nonexistent") is Falseasync def test_session_isolation(self, credentials_db: CredentialsDatabase):@@ -63,9 +61,7 @@ class TestApiKeyCrud:assert await credentials_db.get_api_key("openai", "default") == "sk-default"assert await credentials_db.get_api_key("openai", "bob") == "sk-bob"- async def test_list_api_keys_returns_providers_only_for_session(- self, credentials_db: CredentialsDatabase- ):+ async def test_list_api_keys_returns_providers_only_for_session(self, credentials_db: CredentialsDatabase):await credentials_db.save_api_key("openai", "k1")await credentials_db.save_api_key("anthropic", "k2")await credentials_db.save_api_key("openai", "k3", session_id="other")@@ -73,12 +69,8 @@ class TestApiKeyCrud:listed = await credentials_db.list_api_keys()assert sorted(listed) == ["anthropic", "openai"]- async def test_get_api_key_info_does_not_decrypt(- self, credentials_db: CredentialsDatabase- ):- await credentials_db.save_api_key(- "openai", "sk-secret", models=["gpt-4", "gpt-3.5"]- )+ async def test_get_api_key_info_does_not_decrypt(self, credentials_db: CredentialsDatabase):+ await credentials_db.save_api_key("openai", "sk-secret", models=["gpt-4", "gpt-3.5"])info = await credentials_db.get_api_key_info("openai")assert info is not Noneassert info["provider"] == "openai"@@ -115,19 +107,13 @@ class TestOAuthCrud:)async with credentials_db.get_session() as session:- result = await session.execute(- select(EncryptedOAuthToken).where(- EncryptedOAuthToken.provider == "twitter"- )- )+ result = await session.execute(select(EncryptedOAuthToken).where(EncryptedOAuthToken.provider == "twitter"))row = result.scalars().first()assert row is not Noneassert "plaintext-access" not in row.access_token_encryptedassert "plaintext-refresh" not in row.refresh_token_encrypted- async def test_save_overwrites_existing_for_provider(- self, credentials_db: CredentialsDatabase- ):+ async def test_save_overwrites_existing_for_provider(self, credentials_db: CredentialsDatabase):await credentials_db.save_oauth_tokens("google", "a1", "r1", email="[email protected]")await credentials_db.save_oauth_tokens("google", "a2", "r2", email="[email protected]")@@ -141,18 +127,12 @@ class TestOAuthCrud:assert await credentials_db.delete_oauth_tokens("google") is Trueassert await credentials_db.get_oauth_tokens("google") is None- async def test_delete_nonexistent_returns_false(- self, credentials_db: CredentialsDatabase- ):+ async def test_delete_nonexistent_returns_false(self, credentials_db: CredentialsDatabase):assert await credentials_db.delete_oauth_tokens("nonexistent") is Falseasync def test_customer_id_isolation(self, credentials_db: CredentialsDatabase):- await credentials_db.save_oauth_tokens(- "google", "a-owner", "r-owner", customer_id="owner"- )- await credentials_db.save_oauth_tokens(- "google", "a-cust", "r-cust", customer_id="cust-1"- )+ await credentials_db.save_oauth_tokens("google", "a-owner", "r-owner", customer_id="owner")+ await credentials_db.save_oauth_tokens("google", "a-cust", "r-cust", customer_id="cust-1")owner = await credentials_db.get_oauth_tokens("google", "owner")cust = await credentials_db.get_oauth_tokens("google", "cust-1")@@ -170,24 +150,18 @@ class TestOAuthCrud:class TestTwoTableSeparation:"""Invariants 3 and 8 -- the two storage systems must not bleed into each other."""- async def test_oauth_tokens_invisible_via_get_api_key(- self, credentials_db: CredentialsDatabase- ):+ async def test_oauth_tokens_invisible_via_get_api_key(self, credentials_db: CredentialsDatabase):await credentials_db.save_oauth_tokens("google", "access", "refresh")# An API-key lookup for the same provider name finds nothingassert await credentials_db.get_api_key("google") is None- async def test_api_key_invisible_via_get_oauth_tokens(- self, credentials_db: CredentialsDatabase- ):+ async def test_api_key_invisible_via_get_oauth_tokens(self, credentials_db: CredentialsDatabase):# google_client_id is stored as an API key (Pattern C)await credentials_db.save_api_key("google_client_id", "client-abc")# Looking it up as an OAuth token finds nothingassert await credentials_db.get_oauth_tokens("google_client_id") is None- async def test_provider_can_have_both_api_key_and_oauth_tokens(- self, credentials_db: CredentialsDatabase- ):+ async def test_provider_can_have_both_api_key_and_oauth_tokens(self, credentials_db: CredentialsDatabase):# Real-world: google_client_id (API key) AND google OAuth tokens coexistawait credentials_db.save_api_key("google_client_id", "client-id")await credentials_db.save_api_key("google_client_secret", "client-sec")diff --git a/server/tests/credentials/test_encryption.py b/server/tests/credentials/test_encryption.pyindex 92a3d1c2..084a818c 100644--- a/server/tests/credentials/test_encryption.py+++ b/server/tests/credentials/test_encryption.py@@ -46,15 +46,11 @@ class TestRoundTrip:class TestErrorPaths:- def test_uninitialized_encrypt_raises_runtime_error(- self, uninitialized_encryption: EncryptionService- ):+ def test_uninitialized_encrypt_raises_runtime_error(self, uninitialized_encryption: EncryptionService):with pytest.raises(RuntimeError, match="not initialized"):uninitialized_encryption.encrypt("data")- def test_uninitialized_decrypt_raises_runtime_error(- self, uninitialized_encryption: EncryptionService- ):+ def test_uninitialized_decrypt_raises_runtime_error(self, uninitialized_encryption: EncryptionService):with pytest.raises(RuntimeError, match="not initialized"):uninitialized_encryption.decrypt("anything")@@ -92,9 +88,7 @@ class TestSalt:class TestState:- def test_is_initialized_false_before_initialize(- self, uninitialized_encryption: EncryptionService- ):+ def test_is_initialized_false_before_initialize(self, uninitialized_encryption: EncryptionService):assert uninitialized_encryption.is_initialized() is Falsedef test_is_initialized_true_after_initialize(self, encryption: EncryptionService):diff --git a/server/tests/credentials/test_google_oauth.py b/server/tests/credentials/test_google_oauth.pyindex 9060e7b7..579b03b8 100644--- a/server/tests/credentials/test_google_oauth.py+++ b/server/tests/credentials/test_google_oauth.py@@ -74,9 +74,7 @@ class TestAuthorizationUrl:assert stored["data"] == {"mode": "owner"}def test_state_data_passes_through(self, oauth):- result = oauth.generate_authorization_url(- state_data={"customer_id": "cust-1", "mode": "customer"}- )+ result = oauth.generate_authorization_url(state_data={"customer_id": "cust-1", "mode": "customer"})stored = google_oauth._oauth_states[result["state"]]assert stored["data"]["customer_id"] == "cust-1"assert stored["data"]["mode"] == "customer"diff --git a/server/tests/credentials/test_oauth_utils.py b/server/tests/credentials/test_oauth_utils.pyindex e3f2d986..c25f0f00 100644--- a/server/tests/credentials/test_oauth_utils.py+++ b/server/tests/credentials/test_oauth_utils.py@@ -27,16 +27,10 @@ class TestGetBaseUrl:assert get_base_url(_conn("ws://localhost:3010/ws/status")) == "http://localhost:3010"def test_wss_scheme_becomes_https(self):- assert (- get_base_url(_conn("wss://flow.zeenie.xyz/ws/status"))- == "https://flow.zeenie.xyz"- )+ assert get_base_url(_conn("wss://flow.zeenie.xyz/ws/status")) == "https://flow.zeenie.xyz"def test_http_scheme_preserved(self):- assert (- get_base_url(_conn("http://localhost:3010/api/google"))- == "http://localhost:3010"- )+ assert get_base_url(_conn("http://localhost:3010/api/google")) == "http://localhost:3010"def test_https_scheme_preserved(self):assert get_base_url(_conn("https://example.com/anything")) == "https://example.com"@@ -45,10 +39,7 @@ class TestGetBaseUrl:assert get_base_url(_conn("http://localhost:3010/")) == "http://localhost:3010"def test_preserves_non_default_port(self):- assert (- get_base_url(_conn("http://localhost:8080/anything"))- == "http://localhost:8080"- )+ assert get_base_url(_conn("http://localhost:8080/anything")) == "http://localhost:8080"class TestGetRedirectUri:@@ -75,9 +66,7 @@ class TestGetRedirectUri:"""`get_oauth_callback_path` (the real one, not mocked) fallsback to ``/api/<provider>/callback`` for any unregisteredprovider. Test the integrated path end-to-end."""- uri = get_redirect_uri(- _conn("http://localhost:3010/anything"), "newprovider"- )+ uri = get_redirect_uri(_conn("http://localhost:3010/anything"), "newprovider")assert uri == "http://localhost:3010/api/newprovider/callback"def test_paths_registered_by_plugins(self):diff --git a/server/tests/credentials/test_twitter_oauth.py b/server/tests/credentials/test_twitter_oauth.pyindex 8af2a2f8..e1cf0ce0 100644--- a/server/tests/credentials/test_twitter_oauth.py+++ b/server/tests/credentials/test_twitter_oauth.py@@ -61,9 +61,7 @@ class TestAuthorizationUrl:assert params["code_challenge_method"] == ["S256"]assert params["response_type"] == ["code"]assert params["client_id"] == ["test-client-id"]- assert (- params["redirect_uri"] == ["http://localhost:3010/api/twitter/callback"]- )+ assert params["redirect_uri"] == ["http://localhost:3010/api/twitter/callback"]assert "code_challenge" in paramsassert "state" in paramsdiff --git a/server/tests/credentials/test_websocket_handlers.py b/server/tests/credentials/test_websocket_handlers.pyindex 549c2f52..cfa0ee22 100644--- a/server/tests/credentials/test_websocket_handlers.py+++ b/server/tests/credentials/test_websocket_handlers.py@@ -50,9 +50,7 @@ def fake_ws():@pytest.fixturedef patched_container(monkeypatch, auth_service):"""Wire the real auth_service fixture into the container singleton."""- monkeypatch.setattr(- ws_module.container, "auth_service", lambda: auth_service- )+ monkeypatch.setattr(ws_module.container, "auth_service", lambda: auth_service)# ai_service.fetch_models is called by handle_validate_api_key for LLM providers.fake_ai = MagicMock()@@ -93,9 +91,7 @@ async def _call(handler, data, ws):class TestValidateApiKey:@patch("services.ai.PROVIDER_CONFIGS", {"openai": object()})- async def test_validate_stores_key_with_models(- self, patched_container, fake_ws- ):+ async def test_validate_stores_key_with_models(self, patched_container, fake_ws):result = await _call(ws_module.handle_validate_api_key,{"provider": "OpenAI", "api_key": " sk-foo "},@@ -117,9 +113,7 @@ class TestValidateApiKey:# Broadcaster notified with hasKey + modelspatched_container.broadcaster.update_api_key_status.assert_awaited_once()- async def test_validate_unknown_provider_returns_error(- self, patched_container, fake_ws- ):+ async def test_validate_unknown_provider_returns_error(self, patched_container, fake_ws):# ``handle_validate_api_key`` dispatches via# ``CREDENTIAL_REGISTRY``; a provider without a registered# ``Credential`` subclass is an explicit error (no fall-through@@ -136,37 +130,23 @@ class TestValidateApiKey:assert "anonymous_provider" in result["error"]patched_container.ai.fetch_models.assert_not_called()- async def test_missing_required_fields_returns_error(- self, patched_container, fake_ws- ):- result = await _call(- ws_module.handle_validate_api_key, {"provider": "openai"}, fake_ws- )+ async def test_missing_required_fields_returns_error(self, patched_container, fake_ws):+ result = await _call(ws_module.handle_validate_api_key, {"provider": "openai"}, fake_ws)assert result["success"] is Falseassert "api_key" in result["error"]class TestGetStoredApiKey:- async def test_returns_has_key_false_when_absent(- self, patched_container, fake_ws- ):- result = await _call(- ws_module.handle_get_stored_api_key, {"provider": "openai"}, fake_ws- )+ async def test_returns_has_key_false_when_absent(self, patched_container, fake_ws):+ result = await _call(ws_module.handle_get_stored_api_key, {"provider": "openai"}, fake_ws)assert result["success"] is Trueassert result["hasKey"] is Falseassert "apiKey" not in result- async def test_returns_key_and_models_when_present(- self, patched_container, fake_ws- ):- await patched_container.auth.store_api_key(- "openai", "sk-stored", models=["gpt-4", "gpt-3.5"]- )+ async def test_returns_key_and_models_when_present(self, patched_container, fake_ws):+ await patched_container.auth.store_api_key("openai", "sk-stored", models=["gpt-4", "gpt-3.5"])- result = await _call(- ws_module.handle_get_stored_api_key, {"provider": "OpenAI"}, fake_ws- )+ result = await _call(ws_module.handle_get_stored_api_key, {"provider": "OpenAI"}, fake_ws)assert result["hasKey"] is Trueassert result["apiKey"] == "sk-stored"@@ -175,9 +155,7 @@ class TestGetStoredApiKey:class TestSaveApiKey:- async def test_save_persists_without_validation(- self, patched_container, fake_ws- ):+ async def test_save_persists_without_validation(self, patched_container, fake_ws):result = await _call(ws_module.handle_save_api_key,{@@ -195,25 +173,19 @@ class TestSaveApiKey:stored = await patched_container.auth.get_api_key("telegram")assert stored == "123:abc"- async def test_save_strips_whitespace_and_lowercases_provider(- self, patched_container, fake_ws- ):+ async def test_save_strips_whitespace_and_lowercases_provider(self, patched_container, fake_ws):await _call(ws_module.handle_save_api_key,{"provider": "ANTHROPIC", "api_key": " sk-ant-foo \n"},fake_ws,)- assert (- await patched_container.auth.get_api_key("anthropic") == "sk-ant-foo"- )+ assert await patched_container.auth.get_api_key("anthropic") == "sk-ant-foo"class TestDeleteApiKey:async def test_delete_removes_stored_key(self, patched_container, fake_ws):await patched_container.auth.store_api_key("openai", "sk-x", models=[])- result = await _call(- ws_module.handle_delete_api_key, {"provider": "openai"}, fake_ws- )+ result = await _call(ws_module.handle_delete_api_key, {"provider": "openai"}, fake_ws)assert result["success"] is Trueassert await patched_container.auth.get_api_key("openai") is None@@ -230,20 +202,16 @@ class TestTwitterOAuthHandlers:async def test_login_fails_without_client_id(self, patched_container, fake_ws):from nodes.twitter._handlers import handle_twitter_oauth_login+result = await _call(handle_twitter_oauth_login, {}, fake_ws)assert result["success"] is Falseassert "Client ID" in result["error"]- async def test_login_returns_authorization_url(- self, patched_container, fake_ws- ):+ async def test_login_returns_authorization_url(self, patched_container, fake_ws):from nodes.twitter._handlers import handle_twitter_oauth_login- await patched_container.auth.store_api_key(- "twitter_client_id", "ci-test", models=[]- )- await patched_container.auth.store_api_key(- "twitter_client_secret", "cs-test", models=[]- )++ await patched_container.auth.store_api_key("twitter_client_id", "ci-test", models=[])+ await patched_container.auth.store_api_key("twitter_client_secret", "cs-test", models=[])result = await _call(handle_twitter_oauth_login, {}, fake_ws)@@ -253,15 +221,15 @@ class TestTwitterOAuthHandlers:async def test_status_when_disconnected(self, patched_container, fake_ws):from nodes.twitter._handlers import handle_twitter_oauth_status+result = await _call(handle_twitter_oauth_status, {}, fake_ws)assert result["connected"] is Falseassert result["username"] is Noneasync def test_logout_clears_oauth_tokens(self, patched_container, fake_ws):from nodes.twitter._handlers import handle_twitter_logout- await patched_container.auth.store_oauth_tokens(- "twitter", "access", "refresh"- )++ await patched_container.auth.store_oauth_tokens("twitter", "access", "refresh")with patch("nodes.twitter._oauth.TwitterOAuth.revoke_token",new=AsyncMock(return_value={"success": True}),@@ -278,24 +246,18 @@ class TestGoogleOAuthHandlers:# the plugin folder; the dispatch contract is exercised by# ``test_plugin_self_containment.py``.- async def test_login_fails_without_client_credentials(- self, patched_container, fake_ws- ):+ async def test_login_fails_without_client_credentials(self, patched_container, fake_ws):from nodes.google._handlers import handle_google_oauth_login+result = await _call(handle_google_oauth_login, {}, fake_ws)assert result["success"] is Falseassert "Client ID" in result["error"]- async def test_login_returns_authorization_url(- self, patched_container, fake_ws- ):+ async def test_login_returns_authorization_url(self, patched_container, fake_ws):from nodes.google._handlers import handle_google_oauth_login- await patched_container.auth.store_api_key(- "google_client_id", "ci.apps.googleusercontent.com", models=[]- )- await patched_container.auth.store_api_key(- "google_client_secret", "cs-test", models=[]- )++ await patched_container.auth.store_api_key("google_client_id", "ci.apps.googleusercontent.com", models=[])+ await patched_container.auth.store_api_key("google_client_secret", "cs-test", models=[])result = await _call(handle_google_oauth_login, {}, fake_ws)@@ -306,15 +268,15 @@ class TestGoogleOAuthHandlers:async def test_status_when_disconnected(self, patched_container, fake_ws):from nodes.google._handlers import handle_google_oauth_status+result = await _call(handle_google_oauth_status, {}, fake_ws)assert result["connected"] is Falseassert result["email"] is Noneasync def test_logout_removes_oauth_tokens(self, patched_container, fake_ws):from nodes.google._handlers import handle_google_logout- await patched_container.auth.store_oauth_tokens(- "google", "access", "refresh", email="[email protected]"- )++ await patched_container.auth.store_oauth_tokens("google", "access", "refresh", email="[email protected]")result = await _call(handle_google_logout, {}, fake_ws)assert result["success"] is Trueassert await patched_container.auth.get_oauth_tokens("google") is Nonediff --git a/server/tests/llm/test_factory.py b/server/tests/llm/test_factory.pyindex 20a07270..795e771d 100644--- a/server/tests/llm/test_factory.py+++ b/server/tests/llm/test_factory.py@@ -9,9 +9,16 @@ from services.llm.protocol import LLMProviderdef test_native_providers_set():assert NATIVE_PROVIDERS == {- "anthropic", "openai", "gemini", "openrouter", "xai",- "deepseek", "kimi", "mistral",- "ollama", "lmstudio",+ "anthropic",+ "openai",+ "gemini",+ "openrouter",+ "xai",+ "deepseek",+ "kimi",+ "mistral",+ "ollama",+ "lmstudio",}@@ -58,6 +65,7 @@ def test_create_xai_uses_openai_with_base_url():def test_create_unknown_raises():import pytest+with pytest.raises(ValueError, match="Unknown provider"):create_provider("nonexistent", "key")diff --git a/server/tests/llm/test_providers.py b/server/tests/llm/test_providers.pyindex 32b61591..f4d12d29 100644--- a/server/tests/llm/test_providers.py+++ b/server/tests/llm/test_providers.py@@ -15,12 +15,13 @@ from services.llm.protocol import Message, ThinkingConfig, ToolCall, ToolDef# Anthropic: message formatting + response normalization# ----------------------------------------------------------------------------class TestAnthropicProvider:+class TestAnthropicProvider:@pytest.fixturedef provider(self):with patch("anthropic.AsyncAnthropic"):from services.llm.providers.anthropic import AnthropicProvider+return AnthropicProvider("sk-test")def test_system_extracted_from_messages(self, provider):@@ -49,8 +50,7 @@ class TestAnthropicProvider:def test_normalize_text_response(self, provider):resp = MagicMock()resp.content = [MagicMock(type="text", text="Hello")]- resp.usage = MagicMock(input_tokens=10, output_tokens=5,- cache_creation_input_tokens=0, cache_read_input_tokens=0)+ resp.usage = MagicMock(input_tokens=10, output_tokens=5, cache_creation_input_tokens=0, cache_read_input_tokens=0)resp.stop_reason = "end_turn"result = provider._normalize(resp, "claude-sonnet-4-6")@@ -63,8 +63,7 @@ class TestAnthropicProvider:thinking_block = MagicMock(type="thinking", thinking="Let me think...")text_block = MagicMock(type="text", text="Answer")resp.content = [thinking_block, text_block]- resp.usage = MagicMock(input_tokens=50, output_tokens=30,- cache_creation_input_tokens=0, cache_read_input_tokens=0)+ resp.usage = MagicMock(input_tokens=50, output_tokens=30, cache_creation_input_tokens=0, cache_read_input_tokens=0)resp.stop_reason = "end_turn"result = provider._normalize(resp, "claude-sonnet-4-6")@@ -76,15 +75,15 @@ class TestAnthropicProvider:"""When thinking enabled, budget_tokens and temperature=1 are set."""mock_resp = MagicMock()mock_resp.content = [MagicMock(type="text", text="ok")]- mock_resp.usage = MagicMock(input_tokens=5, output_tokens=2,- cache_creation_input_tokens=0, cache_read_input_tokens=0)+ mock_resp.usage = MagicMock(input_tokens=5, output_tokens=2, cache_creation_input_tokens=0, cache_read_input_tokens=0)mock_resp.stop_reason = "end_turn"provider._client.messages.create = AsyncMock(return_value=mock_resp)thinking = ThinkingConfig(enabled=True, budget=4096)await provider.chat([Message(role="user", content="test")],- model="claude-sonnet-4-6", thinking=thinking,+ model="claude-sonnet-4-6",+ thinking=thinking,)call_kwargs = provider._client.messages.create.call_args[1]@@ -96,12 +95,13 @@ class TestAnthropicProvider:# OpenAI: message formatting + response normalization# ----------------------------------------------------------------------------class TestOpenAIProvider:+class TestOpenAIProvider:@pytest.fixturedef provider(self):with patch("openai.AsyncOpenAI"):from services.llm.providers.openai import OpenAIProvider+return OpenAIProvider("sk-test")def test_user_message_format(self, provider):@@ -133,8 +133,7 @@ class TestOpenAIProvider:resp = MagicMock()resp.choices = [choice]- resp.usage = MagicMock(prompt_tokens=10, completion_tokens=5, total_tokens=15,- completion_tokens_details=None)+ resp.usage = MagicMock(prompt_tokens=10, completion_tokens=5, total_tokens=15, completion_tokens_details=None)result = provider._normalize(resp, "gpt-5.2")assert result.content == "Hello"@@ -150,8 +149,9 @@ class TestOpenAIProvider:resp = MagicMock()resp.choices = [choice]- resp.usage = MagicMock(prompt_tokens=10, completion_tokens=5, total_tokens=15,- completion_tokens_details=MagicMock(reasoning_tokens=20))+ resp.usage = MagicMock(+ prompt_tokens=10, completion_tokens=5, total_tokens=15, completion_tokens_details=MagicMock(reasoning_tokens=20)+ )result = provider._normalize(resp, "o3-mini")assert result.thinking == "Thinking..."@@ -160,12 +160,8 @@ class TestOpenAIProvider:@pytest.mark.asyncioasync def test_chat_reasoning_model_uses_max_completion_tokens(self, provider):mock_resp = MagicMock()- mock_resp.choices = [MagicMock(- message=MagicMock(content="ok", reasoning_content=None, tool_calls=None),- finish_reason="stop"- )]- mock_resp.usage = MagicMock(prompt_tokens=5, completion_tokens=2, total_tokens=7,- completion_tokens_details=None)+ mock_resp.choices = [MagicMock(message=MagicMock(content="ok", reasoning_content=None, tool_calls=None), finish_reason="stop")]+ mock_resp.usage = MagicMock(prompt_tokens=5, completion_tokens=2, total_tokens=7, completion_tokens_details=None)provider._client.chat.completions.create = AsyncMock(return_value=mock_resp)await provider.chat(@@ -182,12 +178,13 @@ class TestOpenAIProvider:# Gemini: message formatting + thinking config# ----------------------------------------------------------------------------class TestGeminiProvider:+class TestGeminiProvider:@pytest.fixturedef provider(self):with patch("google.genai.Client"):from services.llm.providers.gemini import GeminiProvider+return GeminiProvider("key")def test_split_system_and_contents(self, provider):@@ -218,9 +215,7 @@ class TestGeminiProvider:resp = MagicMock()resp.candidates = [candidate]- resp.usage_metadata = MagicMock(- prompt_token_count=10, candidates_token_count=5, total_token_count=15- )+ resp.usage_metadata = MagicMock(prompt_token_count=10, candidates_token_count=5, total_token_count=15)result = provider._normalize(resp, "gemini-2.5-flash")assert result.content == "Hello"@@ -255,7 +250,8 @@ class TestGeminiProvider:thinking = ThinkingConfig(enabled=True, budget=4096, level="high")await provider.chat([Message(role="user", content="test")],- model="gemini-2.5-flash", thinking=thinking,+ model="gemini-2.5-flash",+ thinking=thinking,)call_kwargs = mock_types.ThinkingConfig.call_args[1]@@ -284,23 +280,20 @@ class TestGeminiProvider:# OpenRouter: [FREE] prefix handling# ----------------------------------------------------------------------------class TestOpenRouterProvider:+class TestOpenRouterProvider:@pytest.fixturedef provider(self):with patch("openai.AsyncOpenAI"):from services.llm.providers.openrouter import OpenRouterProvider+return OpenRouterProvider("or-key")@pytest.mark.asyncioasync def test_strips_free_prefix(self, provider):mock_resp = MagicMock()- mock_resp.choices = [MagicMock(- message=MagicMock(content="ok", reasoning_content=None, tool_calls=None),- finish_reason="stop"- )]- mock_resp.usage = MagicMock(prompt_tokens=5, completion_tokens=2, total_tokens=7,- completion_tokens_details=None)+ mock_resp.choices = [MagicMock(message=MagicMock(content="ok", reasoning_content=None, tool_calls=None), finish_reason="stop")]+ mock_resp.usage = MagicMock(prompt_tokens=5, completion_tokens=2, total_tokens=7, completion_tokens_details=None)provider._client.chat.completions.create = AsyncMock(return_value=mock_resp)await provider.chat(diff --git a/server/tests/llm/test_wiring.py b/server/tests/llm/test_wiring.pyindex 4c12bce0..f8358d5a 100644--- a/server/tests/llm/test_wiring.py+++ b/server/tests/llm/test_wiring.py@@ -15,9 +15,13 @@ def ai_service():# Stub all modules that ai.py imports at top level_stubs = [- "core.config", "core.container",- "services.model_registry", "services.compaction", "services.pricing",- "services.auth", "services.status_broadcaster",+ "core.config",+ "core.container",+ "services.model_registry",+ "services.compaction",+ "services.pricing",+ "services.auth",+ "services.status_broadcaster","constants",]for mod in _stubs:@@ -47,11 +51,12 @@ async def test_execute_chat_uses_native_openai(ai_service):finish_reason="stop",)- with patch("services.ai.create_provider") as mock_factory, \- patch("services.ai.native_resolve_max_tokens", return_value=4096), \- patch("services.ai.native_resolve_temperature", return_value=0.7), \- patch("services.ai.is_native_provider", return_value=True):-+ with (+ patch("services.ai.create_provider") as mock_factory,+ patch("services.ai.native_resolve_max_tokens", return_value=4096),+ patch("services.ai.native_resolve_temperature", return_value=0.7),+ patch("services.ai.is_native_provider", return_value=True),+ ):mock_provider = AsyncMock()mock_provider.chat = AsyncMock(return_value=fake_resp)mock_factory.return_value = mock_provider@@ -75,12 +80,13 @@ async def test_execute_chat_uses_langchain_for_groq(ai_service):mock_response = MagicMock()mock_response.content = "Hello from groq"- with patch("services.ai.is_native_provider", return_value=False), \- patch.object(ai_service, "create_model", return_value=MagicMock(invoke=MagicMock(return_value=mock_response))), \- patch("services.ai.extract_thinking_from_response", return_value=("Hello from groq", None)), \- patch("services.ai._resolve_max_tokens", return_value=4096), \- patch("services.ai._resolve_temperature", return_value=0.7):-+ with (+ patch("services.ai.is_native_provider", return_value=False),+ patch.object(ai_service, "create_model", return_value=MagicMock(invoke=MagicMock(return_value=mock_response))),+ patch("services.ai.extract_thinking_from_response", return_value=("Hello from groq", None)),+ patch("services.ai._resolve_max_tokens", return_value=4096),+ patch("services.ai._resolve_temperature", return_value=0.7),+ ):result = await ai_service.execute_chat(node_id="test-2",node_type="groqChatModel",@@ -97,9 +103,7 @@ async def test_fetch_models_uses_native_for_anthropic(ai_service):"""fetch_models for anthropic delegates to native provider."""expected_models = ["claude-sonnet-4-6", "claude-opus-4-6"]- with patch("services.ai.is_native_provider", return_value=True), \- patch("services.ai.create_provider") as mock_factory:-+ with patch("services.ai.is_native_provider", return_value=True), patch("services.ai.create_provider") as mock_factory:mock_provider = AsyncMock()mock_provider.fetch_models = AsyncMock(return_value=expected_models)mock_factory.return_value = mock_provider@@ -125,11 +129,12 @@ async def test_execute_chat_native_with_thinking(ai_service):finish_reason="stop",)- with patch("services.ai.create_provider") as mock_factory, \- patch("services.ai.native_resolve_max_tokens", return_value=4096), \- patch("services.ai.native_resolve_temperature", return_value=1.0), \- patch("services.ai.is_native_provider", return_value=True):-+ with (+ patch("services.ai.create_provider") as mock_factory,+ patch("services.ai.native_resolve_max_tokens", return_value=4096),+ patch("services.ai.native_resolve_temperature", return_value=1.0),+ patch("services.ai.is_native_provider", return_value=True),+ ):mock_provider = AsyncMock()mock_provider.chat = AsyncMock(return_value=fake_resp)mock_factory.return_value = mock_providerdiff --git a/server/tests/nodes/_compat.py b/server/tests/nodes/_compat.pyindex 4638107d..aaacdcd7 100644--- a/server/tests/nodes/_compat.py+++ b/server/tests/nodes/_compat.py@@ -28,10 +28,7 @@ async def _execute_calculator(args: Dict[str, Any]) -> Dict[str, Any]:supported = {"add", "subtract", "multiply", "divide", "power", "sqrt", "mod", "abs"}if op not in supported:return {- "error": (- f"Unsupported operation '{op}'. "- f"Supported: {sorted(supported)}"- ),+ "error": (f"Unsupported operation '{op}'. " f"Supported: {sorted(supported)}"),"supported_operations": sorted(supported),}@@ -108,6 +105,7 @@ async def _execute_duckduckgo_search(max_results = int(config.get("max_results", args.get("max_results", 5)))provider = config.get("provider", "duckduckgo")from ddgs import DDGS+raw = list(DDGS().text(query, max_results=max_results))results = [{@@ -139,7 +137,8 @@ async def handle_write_todos(broadcaster = context.get("broadcaster")if broadcaster:await broadcaster.update_node_status(- node_id, "executing",+ node_id,+ "executing",{"phase": "todo_update", "todos": stored},workflow_id=context.get("workflow_id"),)diff --git a/server/tests/nodes/_harness.py b/server/tests/nodes/_harness.pyindex 3ea7780b..39f9b26b 100644--- a/server/tests/nodes/_harness.py+++ b/server/tests/nodes/_harness.py@@ -176,10 +176,7 @@ class NodeTestHarness:assert isinstance(result["error"], str), "envelope 'error' must be str"if success is not None:- assert result["success"] is success, (- f"expected success={success}, got {result['success']} "- f"(error={result.get('error')})"- )+ assert result["success"] is success, f"expected success={success}, got {result['success']} " f"(error={result.get('error')})"@staticmethoddef assert_output_shape(result: Dict[str, Any], expected_keys: List[str]) -> None:@@ -219,18 +216,24 @@ def _build_mock_ai_service() -> MagicMock:svc.auth.get_api_key = AsyncMock(return_value="test-api-key")svc.auth.get_stored_models = AsyncMock(return_value=["test-model"])svc.auth.get_oauth_tokens = AsyncMock(return_value=None)- svc.execute_chat = AsyncMock(return_value={- "success": True,- "result": {"response": "mocked response", "model": "test-model", "provider": "test"},- })- svc.execute_agent = AsyncMock(return_value={- "success": True,- "result": {"response": "mocked agent response", "model": "test-model"},- })- svc.execute_chat_agent = AsyncMock(return_value={- "success": True,- "result": {"response": "mocked chat agent response", "model": "test-model"},- })+ svc.execute_chat = AsyncMock(+ return_value={+ "success": True,+ "result": {"response": "mocked response", "model": "test-model", "provider": "test"},+ }+ )+ svc.execute_agent = AsyncMock(+ return_value={+ "success": True,+ "result": {"response": "mocked agent response", "model": "test-model"},+ }+ )+ svc.execute_chat_agent = AsyncMock(+ return_value={+ "success": True,+ "result": {"response": "mocked chat agent response", "model": "test-model"},+ }+ )svc.fetch_models = AsyncMock(return_value=["test-model-1", "test-model-2"])return svc@@ -247,14 +250,18 @@ def _build_mock_text_service() -> MagicMock:svc.generate_text = AsyncMock(return_value="mocked text")# Plugin paths for text generator / file handler now call these names# directly on the TextService singleton.- svc.execute_text_generator = AsyncMock(return_value={- "success": True,- "text": "mocked text",- })- svc.execute_file_handler = AsyncMock(return_value={- "success": True,- "content": "mocked content",- })+ svc.execute_text_generator = AsyncMock(+ return_value={+ "success": True,+ "text": "mocked text",+ }+ )+ svc.execute_file_handler = AsyncMock(+ return_value={+ "success": True,+ "content": "mocked content",+ }+ )return svcdiff --git a/server/tests/nodes/_mocks.py b/server/tests/nodes/_mocks.pyindex 9129bb08..3a40ba1c 100644--- a/server/tests/nodes/_mocks.py+++ b/server/tests/nodes/_mocks.py@@ -76,9 +76,7 @@ def patched_container(auth_service = MagicMock(name="AuthService")auth_service.get_api_key = AsyncMock(side_effect=lambda provider, *a, **kw: api_keys.get(provider))- auth_service.get_oauth_tokens = AsyncMock(- side_effect=lambda provider, *a, **kw: oauth_tokens.get(provider)- )+ auth_service.get_oauth_tokens = AsyncMock(side_effect=lambda provider, *a, **kw: oauth_tokens.get(provider))auth_service.get_stored_models = AsyncMock(return_value=[])# Awaitable async writes (handlers like Twitter call these in refresh paths)auth_service.store_api_key = AsyncMock(return_value=True)@@ -133,9 +131,7 @@ def patched_container(def patched_pricing(total_cost: float = 0.001) -> Iterator[MagicMock]:"""Patch `services.pricing.get_pricing_service` to return canned cost data."""pricing = MagicMock(name="PricingService")- pricing.calculate_api_cost = MagicMock(- return_value={"operation": "test", "total_cost": total_cost}- )+ pricing.calculate_api_cost = MagicMock(return_value={"operation": "test", "total_cost": total_cost})pricing.calculate_cost = MagicMock(return_value={"input_cost": 0.0,diff --git a/server/tests/nodes/test_agent_builder.py b/server/tests/nodes/test_agent_builder.pyindex d5da61c5..82cea13f 100644--- a/server/tests/nodes/test_agent_builder.py+++ b/server/tests/nodes/test_agent_builder.py@@ -77,14 +77,18 @@ def _registry(**type_to_kind) -> dict:class TestRegistration:def test_node_is_registered(self):from services.node_registry import get_node_class+cls = get_node_class("agentBuilder")assert cls is ab.AgentBuilderNodedef test_has_five_operations(self):ops = set(ab.AgentBuilderNode._operations.keys())assert ops == {- "inspect_canvas", "add_tool", "add_skill",- "add_subagent", "create_workflow",+ "inspect_canvas",+ "add_tool",+ "add_skill",+ "add_subagent",+ "create_workflow",}def test_default_operation_is_inspect_canvas(self):@@ -97,6 +101,7 @@ class TestRegistration:contract for nodes that exist solely to be invoked by an LLMthrough an agent's input-tools handle."""from services.plugin import ToolNode+assert issubclass(ab.AgentBuilderNode, ToolNode)def test_handle_topology_matches_canonical_tool_shape(self):@@ -127,8 +132,7 @@ class TestInspectCanvas:nodes = [_agent_node("agent-1"),{"id": "ab-1", "type": "agentBuilder", "data": {"label": "AB"}},- {"id": "tool-1", "type": "httpRequest",- "data": {"label": "HTTP", "parameters": {"url": "https://x"}}},+ {"id": "tool-1", "type": "httpRequest", "data": {"label": "HTTP", "parameters": {"url": "https://x"}}},]edges = [_edge("ab-1", "agent-1", "input-tools"),@@ -179,8 +183,7 @@ class TestAddTool:ctx = _make_ctx()params = ab.AgentBuilderParams(operation="add_tool", node_type="unknownTool")- with patch.object(ab, "registered_node_classes",- return_value=_registry(httpRequest="tool")):+ with patch.object(ab, "registered_node_classes", return_value=_registry(httpRequest="tool")):result = await node.add_tool(ctx, params)assert result.operations == []@@ -190,10 +193,9 @@ class TestAddTool:node = ab.AgentBuilderNode()ctx = _make_ctx()- with patch.object(ab, "registered_node_classes",- return_value=_registry(- agentBuilder="tool", masterSkill="tool",- httpRequest="tool")):+ with patch.object(+ ab, "registered_node_classes", return_value=_registry(agentBuilder="tool", masterSkill="tool", httpRequest="tool")+ ):for forbidden in ("agentBuilder", "masterSkill"):params = ab.AgentBuilderParams(operation="add_tool", node_type=forbidden)result = await node.add_tool(ctx, params)@@ -206,9 +208,10 @@ class TestAddTool:ctx = _make_ctx(edges=edges)params = ab.AgentBuilderParams(operation="add_tool", node_type="httpRequest")- with patch.object(ab, "registered_node_classes",- return_value=_registry(httpRequest="tool")), \- patch.object(ab, "_broadcast", new_callable=AsyncMock) as mock_bcast:+ with (+ patch.object(ab, "registered_node_classes", return_value=_registry(httpRequest="tool")),+ patch.object(ab, "_broadcast", new_callable=AsyncMock) as mock_bcast,+ ):result = await node.add_tool(ctx, params)assert len(result.operations) == 2@@ -241,7 +244,8 @@ class TestAddSkill:node = ab.AgentBuilderNode()ctx = _make_ctx()params = ab.AgentBuilderParams(- operation="add_skill", skill_folder="nonexistent-skill",+ operation="add_skill",+ skill_folder="nonexistent-skill",)with patch.object(ab, "_skill_folder_exists", return_value=False):@@ -252,7 +256,8 @@ class TestAddSkill:async def test_toggles_on_existing_master_skill(self):master = {- "id": "ms-1", "type": "masterSkill",+ "id": "ms-1",+ "type": "masterSkill","data": {"parameters": {"skills_config": {"old-skill": {"enabled": True}}}},}agent = _agent_node("agent-1")@@ -263,11 +268,11 @@ class TestAddSkill:node = ab.AgentBuilderNode()ctx = _make_ctx(nodes=[agent, master], edges=edges)params = ab.AgentBuilderParams(- operation="add_skill", skill_folder="http-request-skill",+ operation="add_skill",+ skill_folder="http-request-skill",)- with patch.object(ab, "_skill_folder_exists", return_value=True), \- patch.object(ab, "_broadcast", new_callable=AsyncMock):+ with patch.object(ab, "_skill_folder_exists", return_value=True), patch.object(ab, "_broadcast", new_callable=AsyncMock):result = await node.add_skill(ctx, params)assert len(result.operations) == 1@@ -284,11 +289,11 @@ class TestAddSkill:node = ab.AgentBuilderNode()ctx = _make_ctx(nodes=[agent], edges=edges)params = ab.AgentBuilderParams(- operation="add_skill", skill_folder="memory-skill",+ operation="add_skill",+ skill_folder="memory-skill",)- with patch.object(ab, "_skill_folder_exists", return_value=True), \- patch.object(ab, "_broadcast", new_callable=AsyncMock):+ with patch.object(ab, "_skill_folder_exists", return_value=True), patch.object(ab, "_broadcast", new_callable=AsyncMock):result = await node.add_skill(ctx, params)assert len(result.operations) == 2@@ -321,11 +326,11 @@ class TestAddSubagent:node = ab.AgentBuilderNode()ctx = _make_ctx(nodes=[agent], edges=edges)params = ab.AgentBuilderParams(- operation="add_subagent", agent_type="coding_agent",+ operation="add_subagent",+ agent_type="coding_agent",)- with patch.object(ab, "registered_node_classes",- return_value=_registry(coding_agent="agent")):+ with patch.object(ab, "registered_node_classes", return_value=_registry(coding_agent="agent")):result = await node.add_subagent(ctx, params)assert result.operations == []@@ -337,11 +342,11 @@ class TestAddSubagent:node = ab.AgentBuilderNode()ctx = _make_ctx(nodes=[agent], edges=edges)params = ab.AgentBuilderParams(- operation="add_subagent", agent_type="not_a_real_agent",+ operation="add_subagent",+ agent_type="not_a_real_agent",)- with patch.object(ab, "registered_node_classes",- return_value=_registry(coding_agent="agent")):+ with patch.object(ab, "registered_node_classes", return_value=_registry(coding_agent="agent")):result = await node.add_subagent(ctx, params)assert result.operations == []@@ -353,11 +358,11 @@ class TestAddSubagent:node = ab.AgentBuilderNode()ctx = _make_ctx(nodes=[agent], edges=edges)params = ab.AgentBuilderParams(- operation="add_subagent", agent_type="ai_employee",+ operation="add_subagent",+ agent_type="ai_employee",)- with patch.object(ab, "registered_node_classes",- return_value=_registry(ai_employee="agent")):+ with patch.object(ab, "registered_node_classes", return_value=_registry(ai_employee="agent")):result = await node.add_subagent(ctx, params)assert result.operations == []@@ -369,12 +374,14 @@ class TestAddSubagent:node = ab.AgentBuilderNode()ctx = _make_ctx(nodes=[agent], edges=edges)params = ab.AgentBuilderParams(- operation="add_subagent", agent_type="coding_agent",+ operation="add_subagent",+ agent_type="coding_agent",)- with patch.object(ab, "registered_node_classes",- return_value=_registry(coding_agent="agent")), \- patch.object(ab, "_broadcast", new_callable=AsyncMock):+ with (+ patch.object(ab, "registered_node_classes", return_value=_registry(coding_agent="agent")),+ patch.object(ab, "_broadcast", new_callable=AsyncMock),+ ):result = await node.add_subagent(ctx, params)assert len(result.operations) == 2@@ -424,7 +431,8 @@ class TestCreateWorkflow:node = ab.AgentBuilderNode()ctx = _make_ctx()params = ab.AgentBuilderParams(- operation="create_workflow", workflow_name="Doomed Workflow",+ operation="create_workflow",+ workflow_name="Doomed Workflow",)mock_db = MagicMock()diff --git a/server/tests/nodes/test_ai_agents.py b/server/tests/nodes/test_ai_agents.pyindex e10899fe..9514e888 100644--- a/server/tests/nodes/test_ai_agents.py+++ b/server/tests/nodes/test_ai_agents.py@@ -82,7 +82,7 @@ class TestAIAgent:harness.database.get_node_parameters = AsyncMock(return_value={- "session_id": "", # triggers auto-derivation+ "session_id": "", # triggers auto-derivation"window_size": 7,"memory_content": "# Conversation History\n\n### **Human** (t)\nhi\n","long_term_enabled": True,@@ -106,7 +106,7 @@ class TestAIAgent:mem = kwargs["memory_data"]assert mem is not Noneassert mem["node_id"] == mem_id- assert mem["session_id"] == agent_id # auto-derived+ assert mem["session_id"] == agent_id # auto-derivedassert mem["window_size"] == 7assert mem["long_term_enabled"] is Trueassert mem["retrieval_count"] == 5@@ -123,8 +123,11 @@ class TestAIAgent:edges = [_edge(mem_id, agent_id, "input-memory")]await harness.execute(- "aiAgent", {"prompt": "p"},- node_id=agent_id, nodes=nodes, edges=edges,+ "aiAgent",+ {"prompt": "p"},+ node_id=agent_id,+ nodes=nodes,+ edges=edges,)_, kwargs = harness.ai_service.execute_agent.call_args@@ -135,9 +138,7 @@ class TestAIAgent:agent_id = "agent-2"tool_id = "calc-1"- harness.database.get_node_parameters = AsyncMock(- return_value={"tool_name": "calculator"}- )+ harness.database.get_node_parameters = AsyncMock(return_value={"tool_name": "calculator"})nodes = [_node(agent_id, "aiAgent"), _node(tool_id, "calculatorTool", "Calc")]edges = [_edge(tool_id, agent_id, "input-tools")]@@ -145,7 +146,9 @@ class TestAIAgent:await harness.execute("aiAgent",{"prompt": "compute", "model": "m"},- node_id=agent_id, nodes=nodes, edges=edges,+ node_id=agent_id,+ nodes=nodes,+ edges=edges,)_, kwargs = harness.ai_service.execute_agent.call_args@@ -183,14 +186,17 @@ class TestAIAgent:with patch.dict(sys.modules, {"services.skill_loader": fake_loader_mod}):await harness.execute(- "aiAgent", {"prompt": "p"},- node_id=agent_id, nodes=nodes, edges=edges,+ "aiAgent",+ {"prompt": "p"},+ node_id=agent_id,+ nodes=nodes,+ edges=edges,)_, kwargs = harness.ai_service.execute_agent.call_argsskill_data = kwargs["skill_data"]assert skill_data is not None- assert len(skill_data) == 1 # shell-skill disabled -> skipped+ assert len(skill_data) == 1 # shell-skill disabled -> skippedassert skill_data[0]["skill_name"] == "python-skill"assert skill_data[0]["parameters"]["instructions"] == "Use python."@@ -251,12 +257,11 @@ class TestAIAgent:async def test_service_error_propagates_through_envelope(self, harness):"""execute_agent can return a failure envelope; handler must pass it through."""- harness.ai_service.execute_agent = AsyncMock(- return_value={"success": False, "error": "provider 429"}- )+ harness.ai_service.execute_agent = AsyncMock(return_value={"success": False, "error": "provider 429"})result = await harness.execute(- "aiAgent", {"prompt": "x", "model": "m"},+ "aiAgent",+ {"prompt": "x", "model": "m"},)harness.assert_envelope(result, success=False)@@ -312,9 +317,7 @@ class TestChatAgent:ctx = harness.build_context(nodes=nodes, edges=edges)# All three present - message must win- ctx["outputs"] = {- up_id: {"message": "via-message", "text": "via-text", "content": "via-content"}- }+ ctx["outputs"] = {up_id: {"message": "via-message", "text": "via-text", "content": "via-content"}}await harness.executor.execute(node_id=chat_id,@@ -337,7 +340,8 @@ class TestChatAgent:ctx["outputs"] = {up_id: {"message": "should-not-leak"}}await harness.executor.execute(- node_id=chat_id, node_type="chatAgent",+ node_id=chat_id,+ node_type="chatAgent",parameters={"prompt": "explicit"},context=ctx,)@@ -366,7 +370,9 @@ class TestChatAgent:await harness.execute("orchestrator_agent",{"prompt": "do a thing", "model": "m"},- node_id=lead_id, nodes=nodes, edges=edges,+ node_id=lead_id,+ nodes=nodes,+ edges=edges,)_, kwargs = harness.ai_service.execute_chat_agent.call_args@@ -399,12 +405,11 @@ class TestChatAgent:]ctx = harness.build_context(nodes=nodes, edges=edges)- ctx["outputs"] = {- trig_id: {"task_id": "x", "status": "error", "error": "boom", "agent_name": "web_agent"}- }+ ctx["outputs"] = {trig_id: {"task_id": "x", "status": "error", "error": "boom", "agent_name": "web_agent"}}await harness.executor.execute(- node_id=chat_id, node_type="chatAgent",+ node_id=chat_id,+ node_type="chatAgent",parameters={"prompt": "p", "model": "m"},context=ctx,)diff --git a/server/tests/nodes/test_ai_chat_models.py b/server/tests/nodes/test_ai_chat_models.pyindex 267774ec..5e1013a3 100644--- a/server/tests/nodes/test_ai_chat_models.py+++ b/server/tests/nodes/test_ai_chat_models.py@@ -76,9 +76,7 @@ class TestAllChatModelsHappyPath:"""The happy-path contract is identical for every chat-model node."""@pytest.mark.parametrize("node_type,provider", ALL_PROVIDERS)- async def test_dispatches_to_execute_chat_and_returns_envelope(- self, harness, node_type, provider- ):+ async def test_dispatches_to_execute_chat_and_returns_envelope(self, harness, node_type, provider):harness.ai_service.execute_chat = AsyncMock(return_value=_canned_success(provider))result = await harness.execute(@@ -102,9 +100,7 @@ class TestAllChatModelsHappyPath:assert params["model"] == "test-model"@pytest.mark.parametrize("node_type,provider", ALL_PROVIDERS)- async def test_api_key_auto_injected_by_executor(- self, harness, node_type, provider- ):+ async def test_api_key_auto_injected_by_executor(self, harness, node_type, provider):"""NodeExecutor._inject_api_keys must fetch 'api_key' per provider."""harness.ai_service.execute_chat = AsyncMock(return_value=_canned_success(provider))@@ -112,9 +108,7 @@ class TestAllChatModelsHappyPath:# auth.get_api_key was called with the provider derived from node_typecalls = [c.args for c in harness.ai_service.auth.get_api_key.await_args_list]- assert any(c[0] == provider for c in calls), (- f"expected get_api_key({provider}, ...) for {node_type}, got {calls}"- )+ assert any(c[0] == provider for c in calls), f"expected get_api_key({provider}, ...) for {node_type}, got {calls}"# Plugin Params use snake_case throughout; model_dump() preserves field names.params = harness.ai_service.execute_chat.await_args.args[2]diff --git a/server/tests/nodes/test_ai_tools.py b/server/tests/nodes/test_ai_tools.pyindex fb2e822e..2d292118 100644--- a/server/tests/nodes/test_ai_tools.py+++ b/server/tests/nodes/test_ai_tools.py@@ -83,8 +83,14 @@ class TestCalculatorTool:assert "quantum" in result["error"]supported = result["supported_operations"]assert set(supported) == {- "add", "subtract", "multiply", "divide",- "power", "sqrt", "mod", "abs",+ "add",+ "subtract",+ "multiply",+ "divide",+ "power",+ "sqrt",+ "mod",+ "abs",}async def test_non_numeric_operand_raises(self):@@ -119,8 +125,12 @@ class TestCurrentTimeTool:result = await _execute_current_time({"timezone": "UTC"}, {})assert set(result.keys()) == {- "datetime", "date", "time", "timezone",- "day_of_week", "timestamp",+ "datetime",+ "date",+ "time",+ "timezone",+ "day_of_week",+ "timestamp",}assert result["timezone"] == "UTC"assert isinstance(result["timestamp"], int)@@ -168,7 +178,6 @@ class TestDuckDuckGoSearch:"""ddgs-library wrapper; heavy mocking so no real network is touched."""async def test_happy_path_maps_ddgs_results_to_documented_shape(self):-fake_ddgs_instance = MagicMock()fake_ddgs_instance.text.return_value = [{"title": "A", "body": "snippet A", "href": "https://a.example"},@@ -180,6 +189,7 @@ class TestDuckDuckGoSearch:fake_module.DDGS = fake_ddgs_classfrom tests.nodes._compat import _execute_duckduckgo_search as _flat_search+with patch.dict("sys.modules", {"ddgs": fake_module}):result = await _flat_search({"query": "python"},@@ -267,9 +277,8 @@ class TestTaskManager:}from nodes.tool.task_manager import _execute_task_manager- result = await _execute_task_manager(- {"operation": "list_tasks"}, {"parameters": {}}- )++ result = await _execute_task_manager({"operation": "list_tasks"}, {"parameters": {}})assert result["success"] is Trueassert result["operation"] == "list_tasks"@@ -293,6 +302,7 @@ class TestTaskManager:tools_mod._delegation_results["c1"] = {"status": "completed"}from nodes.tool.task_manager import _execute_task_manager+result = await _execute_task_manager({"operation": "list_tasks", "status_filter": "running"},{"parameters": {}},@@ -305,9 +315,8 @@ class TestTaskManager:tools_mod = _reset_registryfrom nodes.tool.task_manager import _execute_task_manager- result = await _execute_task_manager(- {"operation": "get_task"}, {"parameters": {}}- )++ result = await _execute_task_manager({"operation": "get_task"}, {"parameters": {}})assert result["success"] is Falseassert "task_id is required" in result["error"]@@ -316,6 +325,7 @@ class TestTaskManager:tools_mod._delegation_results["gone"] = {"status": "completed"}from nodes.tool.task_manager import _execute_task_manager+result = await _execute_task_manager({"operation": "mark_done", "task_id": "gone"},{"parameters": {}},@@ -329,6 +339,7 @@ class TestTaskManager:tools_mod = _reset_registryfrom nodes.tool.task_manager import _execute_task_manager+result = await _execute_task_manager({"operation": "mark_done", "task_id": "never-seen"},{"parameters": {}},@@ -342,9 +353,8 @@ class TestTaskManager:tools_mod = _reset_registryfrom nodes.tool.task_manager import _execute_task_manager- result = await _execute_task_manager(- {"operation": "self_destruct"}, {"parameters": {}}- )++ result = await _execute_task_manager({"operation": "self_destruct"}, {"parameters": {}})assert result["success"] is Falseassert "Unknown operation" in result["error"]@@ -415,9 +425,9 @@ class TestWriteTodos:todos = [{"content": "valid", "status": "pending"},- {"content": " ", "status": "pending"}, # dropped (empty)- {"content": "bad-status", "status": "on_hold"}, # coerced to pending- "not a dict", # dropped+ {"content": " ", "status": "pending"}, # dropped (empty)+ {"content": "bad-status", "status": "on_hold"}, # coerced to pending+ "not a dict", # dropped]result = await handle_write_todos(@@ -446,9 +456,7 @@ class TestWriteTodos:)assert result["success"] is True- assert get_todo_service().get("default") == [- {"content": "x", "status": "pending"}- ]+ assert get_todo_service().get("default") == [{"content": "x", "status": "pending"}]async def test_empty_todos_list_yields_empty_stored_state(self):from tests.nodes._compat import handle_write_todos@@ -479,6 +487,4 @@ class TestWriteTodos:)assert result["success"] is True- assert get_todo_service().get("wf") == [- {"content": "x", "status": "pending"}- ]+ assert get_todo_service().get("wf") == [{"content": "x", "status": "pending"}]diff --git a/server/tests/nodes/test_android.py b/server/tests/nodes/test_android.pyindex 8b71cc42..ab6c8bae 100644--- a/server/tests/nodes/test_android.py+++ b/server/tests/nodes/test_android.py@@ -125,20 +125,24 @@ def _install_execute_service(harness, *, return_value=None, side_effect=None):if side_effect is not None:kwargs["side_effect"] = side_effectelse:- kwargs["return_value"] = return_value if return_value is not None else {- "success": True,- "result": {- "service_id": "unknown",- "action": "unknown",- "data": {},- "response_time": 0.01,- "android_host": "localhost",- "android_port": 8888,+ kwargs["return_value"] = (+ return_value+ if return_value is not None+ else {+ "success": True,+ "result": {+ "service_id": "unknown",+ "action": "unknown",+ "data": {},+ "response_time": 0.01,+ "android_host": "localhost",+ "android_port": 8888,+ "timestamp": datetime.now().isoformat(),+ },+ "execution_time": 0.01,"timestamp": datetime.now().isoformat(),- },- "execution_time": 0.01,- "timestamp": datetime.now().isoformat(),- }+ }+ )mock = AsyncMock(**kwargs)harness.android_service.execute_service = mockreturn mock@@ -153,13 +157,9 @@ class TestDispatch:"""All 16 Android node types share one handler; dispatch the right service_id."""@pytest.mark.parametrize("node_type,expected_service_id", list(SERVICE_ID_MAP.items()))- async def test_registry_routes_to_correct_service_id(- self, harness, node_type, expected_service_id- ):+ async def test_registry_routes_to_correct_service_id(self, harness, node_type, expected_service_id):action = DEFAULT_ACTIONS[node_type]- envelope = _build_service_envelope(- service_id=expected_service_id, action=action, data={"ok": True}- )+ envelope = _build_service_envelope(service_id=expected_service_id, action=action, data={"ok": True})mock = _install_execute_service(harness, return_value=envelope)result = await harness.execute(node_type, {"action": action})@@ -172,9 +172,7 @@ class TestDispatch:async def test_handler_ignores_frontend_service_id_param(self, harness):"""Frontend stores hidden `service_id` but handler's SERVICE_ID_MAP wins."""- envelope = _build_service_envelope(- service_id="device_state", action="status", data={}- )+ envelope = _build_service_envelope(service_id="device_state", action="status", data={})mock = _install_execute_service(harness, return_value=envelope)# Frontend sends the wrong snake_case value (matches factory output,@@ -188,9 +186,7 @@ class TestDispatch:assert kwargs["service_id"] == "device_state"async def test_default_host_and_port_used_when_absent(self, harness):- envelope = _build_service_envelope(- service_id="battery", action="status", data={}- )+ envelope = _build_service_envelope(service_id="battery", action="status", data={})mock = _install_execute_service(harness, return_value=envelope)await harness.execute("batteryMonitor", {"action": "status"})@@ -227,9 +223,7 @@ class TestDispatch:class TestParameterHandling:async def test_package_name_promoted_into_parameters_dict(self, harness):"""appLauncher: root-level package_name must end up inside parameters."""- envelope = _build_service_envelope(- service_id="app_launcher", action="launch", data={"launched": True}- )+ envelope = _build_service_envelope(service_id="app_launcher", action="launch", data={"launched": True})mock = _install_execute_service(harness, return_value=envelope)await harness.execute(@@ -242,9 +236,7 @@ class TestParameterHandling:async def test_empty_package_name_is_not_promoted(self, harness):"""Handler checks `if parameters[key]` - empty strings are skipped."""- envelope = _build_service_envelope(- service_id="app_launcher", action="launch", data={}- )+ envelope = _build_service_envelope(service_id="app_launcher", action="launch", data={})mock = _install_execute_service(harness, return_value=envelope)await harness.execute(@@ -256,9 +248,7 @@ class TestParameterHandling:assert kwargs["parameters"] == {}async def test_parameters_json_string_is_parsed(self, harness):- envelope = _build_service_envelope(- service_id="audio_automation", action="set_volume", data={}- )+ envelope = _build_service_envelope(service_id="audio_automation", action="set_volume", data={})mock = _install_execute_service(harness, return_value=envelope)await harness.execute(@@ -273,9 +263,7 @@ class TestParameterHandling:assert kwargs["parameters"] == {"stream": "music", "level": 5}async def test_parameters_invalid_json_becomes_empty_dict(self, harness):- envelope = _build_service_envelope(- service_id="audio_automation", action="set_volume", data={}- )+ envelope = _build_service_envelope(service_id="audio_automation", action="set_volume", data={})mock = _install_execute_service(harness, return_value=envelope)await harness.execute(@@ -287,9 +275,7 @@ class TestParameterHandling:assert kwargs["parameters"] == {}async def test_parameters_dict_passed_through(self, harness):- envelope = _build_service_envelope(- service_id="screen_control", action="set_brightness", data={}- )+ envelope = _build_service_envelope(service_id="screen_control", action="set_brightness", data={})mock = _install_execute_service(harness, return_value=envelope)await harness.execute(@@ -302,9 +288,7 @@ class TestParameterHandling:async def test_default_action_fallback(self, harness):"""Handler falls back to action='status' when param missing."""- envelope = _build_service_envelope(- service_id="battery", action="status", data={}- )+ envelope = _build_service_envelope(service_id="battery", action="status", data={})mock = _install_execute_service(harness, return_value=envelope)await harness.execute("batteryMonitor", {})@@ -321,9 +305,7 @@ class TestParameterHandling:class TestActionBranches:@pytest.mark.parametrize("action", ["status", "enable", "disable", "scan"])async def test_wifi_actions_pass_through(self, harness, action):- envelope = _build_service_envelope(- service_id="wifi_automation", action=action, data={"enabled": True}- )+ envelope = _build_service_envelope(service_id="wifi_automation", action=action, data={"enabled": True})mock = _install_execute_service(harness, return_value=envelope)result = await harness.execute("wifiAutomation", {"action": action})@@ -333,9 +315,7 @@ class TestActionBranches:@pytest.mark.parametrize("action", ["status", "enable", "disable"])async def test_airplane_mode_actions_pass_through(self, harness, action):- envelope = _build_service_envelope(- service_id="airplane_mode", action=action, data={}- )+ envelope = _build_service_envelope(service_id="airplane_mode", action=action, data={})mock = _install_execute_service(harness, return_value=envelope)await harness.execute("airplaneModeControl", {"action": action})@@ -362,9 +342,7 @@ class TestOutputFlatten:)_install_execute_service(harness, return_value=envelope)- result = await harness.execute(- "batteryMonitor", {"action": "status"}, node_id="battery_1"- )+ result = await harness.execute("batteryMonitor", {"action": "status"}, node_id="battery_1")harness.assert_envelope(result, success=True)# The output store receives the flattened payload@@ -393,9 +371,7 @@ class TestOutputFlatten:)_install_execute_service(harness, return_value=envelope)- result = await harness.execute(- "location", {"action": "current"}, node_id="loc_1"- )+ result = await harness.execute("location", {"action": "current"}, node_id="loc_1")harness.assert_envelope(result, success=True)stored = harness.output_for("loc_1", key="output_main")@@ -413,9 +389,7 @@ class TestOutputFlatten:)_install_execute_service(harness, return_value=envelope)- result = await harness.execute(- "appList", {"action": "list"}, node_id="app_list_1"- )+ result = await harness.execute("appList", {"action": "list"}, node_id="app_list_1")harness.assert_envelope(result, success=True)stored = harness.output_for("app_list_1", key="output_main")@@ -430,9 +404,7 @@ class TestOutputFlatten:class TestErrorPaths:- async def test_service_returns_success_false_surfaces_as_error_envelope(- self, harness- ):+ async def test_service_returns_success_false_surfaces_as_error_envelope(self, harness):envelope = _build_service_envelope(service_id="battery",action="status",@@ -453,9 +425,7 @@ class TestErrorPaths:If it does raise (e.g. during future refactors), NodeExecutor catchesit and returns a failure envelope via ExecutionResult."""- _install_execute_service(- harness, side_effect=RuntimeError("relay client crashed")- )+ _install_execute_service(harness, side_effect=RuntimeError("relay client crashed"))result = await harness.execute("batteryMonitor", {"action": "status"})diff --git a/server/tests/nodes/test_chat_utility.py b/server/tests/nodes/test_chat_utility.pyindex 592f3f02..d39b4c92 100644--- a/server/tests/nodes/test_chat_utility.py+++ b/server/tests/nodes/test_chat_utility.py@@ -324,6 +324,7 @@ class TestTextGenerator:harness.text_service = TextService()# Rebuild the executor with the new service instance.from services.node_executor import NodeExecutor+harness.executor = NodeExecutor(database=harness.database,ai_service=harness.ai_service,@@ -450,8 +451,7 @@ class TestGmapsCreate:"mapTypeId": "ROADMAP",},"static_map_url": (- "https://maps.googleapis.com/maps/api/staticmap?"- "center=37.7,-122.4&zoom=12&size=600x400&maptype=roadmap&key=tk"+ "https://maps.googleapis.com/maps/api/staticmap?" "center=37.7,-122.4&zoom=12&size=600x400&maptype=roadmap&key=tk"),"status": "OK",},diff --git a/server/tests/nodes/test_code_fs_process.py b/server/tests/nodes/test_code_fs_process.pyindex d0e9af30..fac3041a 100644--- a/server/tests/nodes/test_code_fs_process.py+++ b/server/tests/nodes/test_code_fs_process.py@@ -99,11 +99,7 @@ class TestPythonExecutor:{"source": "source_A", "target": "py1", "sourceHandle": "output-main"},]- code = (- "val = input_data.get('start', {}).get('n', 0)\n"- "print('doubled', val * 2)\n"- "output = {'doubled': val * 2}\n"- )+ code = "val = input_data.get('start', {}).get('n', 0)\n" "print('doubled', val * 2)\n" "output = {'doubled': val * 2}\n"result = await harness.execute("pythonExecutor",@@ -115,17 +111,13 @@ class TestPythonExecutor:)harness.assert_envelope(result, success=True)- harness.assert_output_shape(- result, ["output", "console_output"]- )+ harness.assert_output_shape(result, ["output", "console_output"])payload = result["result"]assert payload["output"] == {"doubled": 10}assert "doubled 10" in payload["console_output"]async def test_empty_code_short_circuits(self, harness):- result = await harness.execute(- "pythonExecutor", {"code": " \n\t"}- )+ result = await harness.execute("pythonExecutor", {"code": " \n\t"})harness.assert_envelope(result, success=False)assert "no code provided" in result["error"].lower()@@ -168,9 +160,7 @@ class TestJavascriptExecutor:)harness.assert_envelope(result, success=True)- harness.assert_output_shape(- result, ["output", "console_output"]- )+ harness.assert_output_shape(result, ["output", "console_output"])payload = result["result"]assert payload["output"] == {"v": 42}assert "running" in payload["console_output"]@@ -183,9 +173,7 @@ class TestJavascriptExecutor:assert "workspace_dir" in call_kwargs["input_data"]async def test_empty_code_short_circuits(self, harness):- result = await harness.execute(- "javascriptExecutor", {"code": ""}- )+ result = await harness.execute("javascriptExecutor", {"code": ""})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()@@ -205,9 +193,7 @@ class TestJavascriptExecutor:"nodes.code._nodejs.get_nodejs_client",return_value=fake_client,):- result = await harness.execute(- "javascriptExecutor", {"code": "oops"}- )+ result = await harness.execute("javascriptExecutor", {"code": "oops"})harness.assert_envelope(result, success=False)assert "syntaxerror" in result["error"].lower()@@ -215,17 +201,13 @@ class TestJavascriptExecutor:async def test_http_exception_wrapped_in_envelope(self, harness):_reset_nodejs_singleton()fake_client = MagicMock(name="NodeJSClient")- fake_client.execute = AsyncMock(- side_effect=ConnectionRefusedError("Cannot connect to host localhost:3020")- )+ fake_client.execute = AsyncMock(side_effect=ConnectionRefusedError("Cannot connect to host localhost:3020"))with patch("nodes.code._nodejs.get_nodejs_client",return_value=fake_client,):- result = await harness.execute(- "javascriptExecutor", {"code": "output = 1"}- )+ result = await harness.execute("javascriptExecutor", {"code": "output = 1"})harness.assert_envelope(result, success=False)assert "localhost:3020" in result["error"]@@ -263,9 +245,7 @@ class TestTypescriptExecutor:assert call_kwargs["language"] == "typescript"async def test_empty_code_short_circuits(self, harness):- result = await harness.execute(- "typescriptExecutor", {"code": ""}- )+ result = await harness.execute("typescriptExecutor", {"code": ""})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()@@ -285,9 +265,7 @@ class TestTypescriptExecutor:"nodes.code._nodejs.get_nodejs_client",return_value=fake_client,):- result = await harness.execute(- "typescriptExecutor", {"code": "output = foo"}- )+ result = await harness.execute("typescriptExecutor", {"code": "output = foo"})harness.assert_envelope(result, success=False)assert "ts2304" in result["error"].lower()@@ -330,9 +308,7 @@ class TestFileRead:backend.read = MagicMock(side_effect=FileNotFoundError("No such file: ../../etc/passwd"))with _patch_fs_backend(backend):- result = await harness.execute(- "fileRead", {"file_path": "../../etc/passwd"}- )+ result = await harness.execute("fileRead", {"file_path": "../../etc/passwd"})harness.assert_envelope(result, success=False)# ``normalize_virtual_path`` rejects ``..`` segments before the@@ -373,9 +349,7 @@ class TestFileModify:async def test_edit_happy_path_returns_occurrences(self, harness):backend = MagicMock(name="LocalShellBackend")- backend.edit = MagicMock(- return_value=_FakeWriteResult(path="README.md", occurrences=3)- )+ backend.edit = MagicMock(return_value=_FakeWriteResult(path="README.md", occurrences=3))with _patch_fs_backend(backend):result = await harness.execute(@@ -390,13 +364,9 @@ class TestFileModify:)harness.assert_envelope(result, success=True)- harness.assert_output_shape(- result, ["operation", "file_path", "occurrences"]- )+ harness.assert_output_shape(result, ["operation", "file_path", "occurrences"])assert result["result"]["occurrences"] == 3- backend.edit.assert_called_once_with(- "/README.md", "foo", "bar", replace_all=True- )+ backend.edit.assert_called_once_with("/README.md", "foo", "bar", replace_all=True)async def test_edit_missing_old_string_short_circuits(self, harness):backend = MagicMock(name="LocalShellBackend")@@ -417,9 +387,7 @@ class TestFileModify:async def test_backend_reports_error_in_result(self, harness):backend = MagicMock(name="LocalShellBackend")- backend.edit = MagicMock(- return_value=_FakeWriteResult(error="old_string found 2 times; need unique")- )+ backend.edit = MagicMock(return_value=_FakeWriteResult(error="old_string found 2 times; need unique"))with _patch_fs_backend(backend):result = await harness.execute(@@ -457,11 +425,7 @@ class TestFileModify:class TestShell:async def test_happy_path_returns_stdout_and_exit_code(self, harness):backend = MagicMock(name="LocalShellBackend")- backend.execute = MagicMock(- return_value=_FakeExecuteResult(- output="hello world\n", exit_code=0, truncated=False- )- )+ backend.execute = MagicMock(return_value=_FakeExecuteResult(output="hello world\n", exit_code=0, truncated=False))with _patch_fs_backend(backend):result = await harness.execute(@@ -470,9 +434,7 @@ class TestShell:)harness.assert_envelope(result, success=True)- harness.assert_output_shape(- result, ["stdout", "exit_code", "truncated", "command"]- )+ harness.assert_output_shape(result, ["stdout", "exit_code", "truncated", "command"])payload = result["result"]assert payload["stdout"] == "hello world\n"assert payload["exit_code"] == 0@@ -488,11 +450,7 @@ class TestShell:async def test_timeout_surfaces_exit_124(self, harness):backend = MagicMock(name="LocalShellBackend")- backend.execute = MagicMock(- return_value=_FakeExecuteResult(- output="partial...", exit_code=124, truncated=True- )- )+ backend.execute = MagicMock(return_value=_FakeExecuteResult(output="partial...", exit_code=124, truncated=True))with _patch_fs_backend(backend):result = await harness.execute(@@ -532,9 +490,7 @@ class TestFsSearch:backend.ls_info = MagicMock(return_value=entries)with _patch_fs_backend(backend):- result = await harness.execute(- "fsSearch", {"mode": "ls", "path": "."}- )+ result = await harness.execute("fsSearch", {"mode": "ls", "path": "."})harness.assert_envelope(result, success=True)harness.assert_output_shape(result, ["path", "entries", "count"])@@ -545,9 +501,7 @@ class TestFsSearch:backend = MagicMock(name="LocalShellBackend")with _patch_fs_backend(backend):- result = await harness.execute(- "fsSearch", {"mode": "glob", "path": ".", "pattern": ""}- )+ result = await harness.execute("fsSearch", {"mode": "glob", "path": ".", "pattern": ""})harness.assert_envelope(result, success=False)assert "pattern is required" in result["error"].lower()@@ -564,9 +518,7 @@ class TestFsSearch:)harness.assert_envelope(result, success=True)- harness.assert_output_shape(- result, ["path", "pattern", "matches", "count"]- )+ harness.assert_output_shape(result, ["path", "pattern", "matches", "count"])assert result["result"]["count"] == 1backend.glob_info.assert_called_once_with("**/*.py", path="/src")@@ -593,9 +545,7 @@ class TestFsSearch:backend = MagicMock(name="LocalShellBackend")with _patch_fs_backend(backend):- result = await harness.execute(- "fsSearch", {"mode": "teleport", "path": "."}- )+ result = await harness.execute("fsSearch", {"mode": "teleport", "path": "."})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()@@ -631,12 +581,8 @@ def _fake_process_service():"result": {"name": "my-server", "status": "stopped", "exit_code": 0},})- svc.restart = AsyncMock(- return_value={"success": True, "result": {"name": "my-server", "status": "running"}}- )- svc.send_input = AsyncMock(- return_value={"success": True, "result": {"sent": "hello"}}- )+ svc.restart = AsyncMock(return_value={"success": True, "result": {"name": "my-server", "status": "running"}})+ svc.send_input = AsyncMock(return_value={"success": True, "result": {"sent": "hello"}})svc.list_processes = MagicMock(return_value=[{"name": "my-server", "status": "running", "pid": 12345},@@ -704,9 +650,7 @@ class TestProcessManager:svc = _fake_process_service()with _patch_process_service(svc):- result = await harness.execute(- "processManager", {"operation": "list"}- )+ result = await harness.execute("processManager", {"operation": "list"})harness.assert_envelope(result, success=True)harness.assert_output_shape(result, ["processes"])@@ -756,9 +700,7 @@ class TestProcessManager:svc = _fake_process_service()with _patch_process_service(svc):- result = await harness.execute(- "processManager", {"operation": "teleport"}- )+ result = await harness.execute("processManager", {"operation": "teleport"})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()diff --git a/server/tests/nodes/test_document.py b/server/tests/nodes/test_document.pyindex 430f8323..d868bfdd 100644--- a/server/tests/nodes/test_document.py+++ b/server/tests/nodes/test_document.py@@ -45,9 +45,7 @@ class TestHttpScraper:<a href="/not-a-pdf.html">Skip</a></body></html>"""- respx.get("https://example.com/list").mock(- return_value=httpx.Response(200, text=html)- )+ respx.get("https://example.com/list").mock(return_value=httpx.Response(200, text=html))result = await harness.execute("httpScraper",@@ -75,9 +73,7 @@ class TestHttpScraper:async def test_per_url_http_error_collected_in_errors(self, harness):# Page iteration mode fetches two URLs; one 404s, the other succeeds.respx.get("https://example.com/p1").mock(return_value=httpx.Response(404))- respx.get("https://example.com/p2").mock(- return_value=httpx.Response(200, text='<a href="ok.pdf">OK</a>')- )+ respx.get("https://example.com/p2").mock(return_value=httpx.Response(200, text='<a href="ok.pdf">OK</a>'))result = await harness.execute("httpScraper",@@ -99,9 +95,7 @@ class TestHttpScraper:@respx.mockasync def test_date_mode_expands_range(self, harness):- respx.get(url__regex=r"https://example\.com/\?d=\d{4}-\d{2}-\d{2}").mock(- return_value=httpx.Response(200, text="<html></html>")- )+ respx.get(url__regex=r"https://example\.com/\?d=\d{4}-\d{2}-\d{2}").mock(return_value=httpx.Response(200, text="<html></html>"))result = await harness.execute("httpScraper",@@ -127,12 +121,8 @@ class TestHttpScraper:class TestFileDownloader:@respx.mockasync def test_happy_path_downloads_files(self, harness, tmp_path):- respx.get("https://example.com/a.pdf").mock(- return_value=httpx.Response(200, content=b"AAA")- )- respx.get("https://example.com/b.pdf").mock(- return_value=httpx.Response(200, content=b"BBBB")- )+ respx.get("https://example.com/a.pdf").mock(return_value=httpx.Response(200, content=b"AAA"))+ respx.get("https://example.com/b.pdf").mock(return_value=httpx.Response(200, content=b"BBBB"))result = await harness.execute("fileDownloader",@@ -147,9 +137,7 @@ class TestFileDownloader:)harness.assert_envelope(result, success=True)- harness.assert_output_shape(- result, ["downloaded", "skipped", "failed", "files", "output_dir"]- )+ harness.assert_output_shape(result, ["downloaded", "skipped", "failed", "files", "output_dir"])payload = result["result"]assert payload["downloaded"] == 2assert payload["failed"] == 0@@ -160,12 +148,16 @@ class TestFileDownloader:result = await harness.execute("fileDownloader", {"items": []})harness.assert_envelope(result, success=True)payload = result["result"]- assert payload == {- "downloaded": 0,- "skipped": 0,- "failed": 0,- "files": [],- } or payload["downloaded"] == 0+ assert (+ payload+ == {+ "downloaded": 0,+ "skipped": 0,+ "failed": 0,+ "files": [],+ }+ or payload["downloaded"] == 0+ )@respx.mockasync def test_skip_existing_does_not_refetch(self, harness, tmp_path):@@ -190,9 +182,7 @@ class TestFileDownloader:@respx.mockasync def test_http_error_counted_as_failed(self, harness, tmp_path):- respx.get("https://example.com/bad.pdf").mock(- return_value=httpx.Response(500, text="boom")- )+ respx.get("https://example.com/bad.pdf").mock(return_value=httpx.Response(500, text="boom"))result = await harness.execute("fileDownloader",@@ -214,13 +204,7 @@ class TestFileDownloader:class TestDocumentParser:async def test_beautifulsoup_parses_html_file(self, harness, tmp_path):- html = (- "<html><body>"- "<script>alert(1)</script>"- "<style>.x {color:red}</style>"- "<p>Hello <b>World</b></p>"- "</body></html>"- )+ html = "<html><body>" "<script>alert(1)</script>" "<style>.x {color:red}</style>" "<p>Hello <b>World</b></p>" "</body></html>"f = tmp_path / "page.html"f.write_text(html, encoding="utf-8")@@ -242,9 +226,7 @@ class TestDocumentParser:assert "Hello" in doc["content"] and "World" in doc["content"]async def test_no_files_returns_empty_documents(self, harness):- result = await harness.execute(- "documentParser", {"files": [], "inputDir": ""}- )+ result = await harness.execute("documentParser", {"files": [], "inputDir": ""})harness.assert_envelope(result, success=True)assert result["result"]["documents"] == []assert result["result"]["parsed_count"] == 0@@ -360,9 +342,7 @@ class TestEmbeddingGenerator:async def test_huggingface_happy_path_with_patched_embedder(self, harness):# Patch langchain_huggingface at its lazy import site.fake_embedder = MagicMock()- fake_embedder.embed_documents = MagicMock(- return_value=[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]]- )+ fake_embedder.embed_documents = MagicMock(return_value=[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]])fake_hf_mod = MagicMock()fake_hf_mod.HuggingFaceEmbeddings = MagicMock(return_value=fake_embedder)@@ -395,9 +375,7 @@ class TestEmbeddingGenerator:assert kwargs.get("model_name") == "BAAI/bge-small-en-v1.5"async def test_empty_chunks_short_circuits(self, harness):- result = await harness.execute(- "embeddingGenerator", {"chunks": [], "provider": "huggingface"}- )+ result = await harness.execute("embeddingGenerator", {"chunks": [], "provider": "huggingface"})harness.assert_envelope(result, success=True)payload = result["result"]assert payload["embedding_count"] == 0@@ -449,8 +427,7 @@ class _FakeChromaCollection:self._count = 0def add(self, ids, embeddings, documents, metadatas):- self.added.append({"ids": ids, "embeddings": embeddings,- "documents": documents, "metadatas": metadatas})+ self.added.append({"ids": ids, "embeddings": embeddings, "documents": documents, "metadatas": metadatas})self._count += len(ids)def count(self):diff --git a/server/tests/nodes/test_email.py b/server/tests/nodes/test_email.pyindex 740e49c7..f69fa31d 100644--- a/server/tests/nodes/test_email.py+++ b/server/tests/nodes/test_email.py@@ -69,8 +69,12 @@ class TestEmailSend:async def test_happy_path(self, harness):stdout = json.dumps({"status": "sent"}).encode()- with _patch_ensure_binary(), patched_subprocess(stdout=stdout, returncode=0) as proc, \- patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing():+ with (+ _patch_ensure_binary(),+ patched_subprocess(stdout=stdout, returncode=0) as proc,+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ ):result = await harness.execute("emailSend",_base_creds_params(@@ -90,10 +94,13 @@ class TestEmailSend:async def test_html_body_builds_multipart(self, harness):# Return empty JSON so himalaya "succeeds" with no extra fields- with _patch_ensure_binary(), patched_subprocess(stdout=b"{}", returncode=0), \- patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing(), \- patch("nodes.email._himalaya.HimalayaService.execute",- new=AsyncMock(return_value={})) as mock_exec:+ with (+ _patch_ensure_binary(),+ patched_subprocess(stdout=b"{}", returncode=0),+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ patch("nodes.email._himalaya.HimalayaService.execute", new=AsyncMock(return_value={})) as mock_exec,+ ):result = await harness.execute("emailSend",_base_creds_params(@@ -113,8 +120,7 @@ class TestEmailSend:async def test_missing_credentials_returns_error(self, harness):# No email/password in params AND no stored keys -> ValueError -> envelope- with _patch_ensure_binary(), patched_subprocess(), \- patched_container(auth_api_keys={}), patched_pricing():+ with _patch_ensure_binary(), patched_subprocess(), patched_container(auth_api_keys={}), patched_pricing():result = await harness.execute("emailSend",{"to": "[email protected]", "subject": "s", "body": "b"},@@ -125,9 +131,12 @@ class TestEmailSend:async def test_subprocess_failure_returns_error(self, harness):# Non-zero returncode -> HimalayaService raises RuntimeError -> envelope- with _patch_ensure_binary(), \- patched_subprocess(stdout=b"", stderr=b"auth failed", returncode=1), \- patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing():+ with (+ _patch_ensure_binary(),+ patched_subprocess(stdout=b"", stderr=b"auth failed", returncode=1),+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ ):result = await harness.execute("emailSend",_base_creds_params(to="[email protected]", subject="s", body="b"),@@ -149,10 +158,12 @@ class TestEmailRead:{"id": "2", "subject": "second", "from": "[email protected]"},]# Himalaya returns a list for envelope list -> wrapped in {data: ...}- with _patch_ensure_binary(), \- patch("nodes.email._himalaya.HimalayaService.execute",- new=AsyncMock(return_value=envelopes)), \- patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing():+ with (+ _patch_ensure_binary(),+ patch("nodes.email._himalaya.HimalayaService.execute", new=AsyncMock(return_value=envelopes)),+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ ):result = await harness.execute("emailRead",_base_creds_params(operation="list", folder="INBOX", page=1, page_size=20),@@ -166,10 +177,12 @@ class TestEmailRead:async def test_read_merges_dict_output(self, harness):message = {"subject": "hello", "body": "world", "from": "[email protected]"}- with _patch_ensure_binary(), \- patch("nodes.email._himalaya.HimalayaService.execute",- new=AsyncMock(return_value=message)), \- patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing():+ with (+ _patch_ensure_binary(),+ patch("nodes.email._himalaya.HimalayaService.execute", new=AsyncMock(return_value=message)),+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ ):result = await harness.execute("emailRead",_base_creds_params(operation="read", message_id="42", folder="INBOX"),@@ -183,8 +196,12 @@ class TestEmailRead:async def test_unknown_operation_returns_error(self, harness):# No subprocess should be spawned; router raises ValueError- with _patch_ensure_binary(), patched_subprocess(), \- patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing():+ with (+ _patch_ensure_binary(),+ patched_subprocess(),+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ ):result = await harness.execute("emailRead",_base_creds_params(operation="nonsense"),@@ -194,9 +211,12 @@ class TestEmailRead:assert "invalid parameters" in result["error"].lower()async def test_subprocess_failure_returns_error(self, harness):- with _patch_ensure_binary(), \- patched_subprocess(stdout=b"", stderr=b"folder not found", returncode=1), \- patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing():+ with (+ _patch_ensure_binary(),+ patched_subprocess(stdout=b"", stderr=b"folder not found", returncode=1),+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ ):result = await harness.execute("emailRead",_base_creds_params(operation="list", folder="DoesNotExist"),@@ -220,16 +240,23 @@ class TestEmailReceive:# poll_ids: first call returns baseline, second returns baseline+newpoll_ids_mock = AsyncMock(side_effect=[{"1"}, {"1", "2"}])- fetch_detail_mock = AsyncMock(return_value={- **email_detail, "message_id": "2", "folder": "INBOX",- })-- with patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing(), \- patch.object(EmailService, "poll_ids", poll_ids_mock), \- patch.object(EmailService, "fetch_detail", fetch_detail_mock), \- patch("asyncio.sleep", new=AsyncMock(return_value=None)), \- patch("services.status_broadcaster.get_status_broadcaster") as bcast, \- patch("services.events.dispatch.emit") as emit_mock:+ fetch_detail_mock = AsyncMock(+ return_value={+ **email_detail,+ "message_id": "2",+ "folder": "INBOX",+ }+ )++ with (+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ patch.object(EmailService, "poll_ids", poll_ids_mock),+ patch.object(EmailService, "fetch_detail", fetch_detail_mock),+ patch("asyncio.sleep", new=AsyncMock(return_value=None)),+ patch("services.status_broadcaster.get_status_broadcaster") as bcast,+ patch("services.events.dispatch.emit") as emit_mock,+ ):bcast.return_value.update_node_status = AsyncMock(return_value=None)emit_mock.return_value = None@@ -261,13 +288,16 @@ class TestEmailReceive:fetch_detail_mock = AsyncMock(return_value={"message_id": "42", "folder": "INBOX"})flag_mock = AsyncMock(return_value={})- with patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing(), \- patch.object(EmailService, "poll_ids", poll_ids_mock), \- patch.object(EmailService, "fetch_detail", fetch_detail_mock), \- patch.object(HimalayaService, "flag_message", flag_mock), \- patch("asyncio.sleep", new=AsyncMock(return_value=None)), \- patch("services.status_broadcaster.get_status_broadcaster") as bcast, \- patch("services.events.dispatch.emit"):+ with (+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ patch.object(EmailService, "poll_ids", poll_ids_mock),+ patch.object(EmailService, "fetch_detail", fetch_detail_mock),+ patch.object(HimalayaService, "flag_message", flag_mock),+ patch("asyncio.sleep", new=AsyncMock(return_value=None)),+ patch("services.status_broadcaster.get_status_broadcaster") as bcast,+ patch("services.events.dispatch.emit"),+ ):bcast.return_value.update_node_status = AsyncMock(return_value=None)result = await harness.execute(@@ -285,8 +315,7 @@ class TestEmailReceive:assert "Seen" in argsasync def test_missing_credentials_returns_error(self, harness):- with patched_container(auth_api_keys={}), patched_pricing(), \- patch("asyncio.sleep", new=AsyncMock(return_value=None)):+ with patched_container(auth_api_keys={}), patched_pricing(), patch("asyncio.sleep", new=AsyncMock(return_value=None)):result = await harness.execute("emailReceive",{"provider": "gmail", "folder": "INBOX"},@@ -301,11 +330,14 @@ class TestEmailReceive:poll_ids_mock = AsyncMock(side_effect=RuntimeError("himalaya error: connection refused"))- with patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}), patched_pricing(), \- patch.object(EmailService, "poll_ids", poll_ids_mock), \- patch("asyncio.sleep", new=AsyncMock(return_value=None)), \- patch("services.status_broadcaster.get_status_broadcaster") as bcast, \- patch("services.events.dispatch.emit"):+ with (+ patched_container(auth_api_keys={"email_address": "[email protected]", "email_password": "sekret", "email_provider": "gmail"}),+ patched_pricing(),+ patch.object(EmailService, "poll_ids", poll_ids_mock),+ patch("asyncio.sleep", new=AsyncMock(return_value=None)),+ patch("services.status_broadcaster.get_status_broadcaster") as bcast,+ patch("services.events.dispatch.emit"),+ ):bcast.return_value.update_node_status = AsyncMock(return_value=None)result = await harness.execute(diff --git a/server/tests/nodes/test_google_workspace.py b/server/tests/nodes/test_google_workspace.pyindex a73550d3..00c6910e 100644--- a/server/tests/nodes/test_google_workspace.py+++ b/server/tests/nodes/test_google_workspace.py@@ -125,6 +125,7 @@ class TestGmail:"messages": [{"id": "m1"}, {"id": "m2"}],"resultSizeEstimate": 2,}+# messages.get returns metadata for eachdef _make_msg(mid):return {@@ -176,9 +177,10 @@ class TestGmail:assert "invalid parameters" in result["error"].lower()async def test_missing_credentials_short_circuits(self, harness):- with _patch_creds(- "googleGmail", side_effect=ValueError("Google Workspace not connected")- ), _patch_build("googleGmail", MagicMock()):+ with (+ _patch_creds("googleGmail", side_effect=ValueError("Google Workspace not connected")),+ _patch_build("googleGmail", MagicMock()),+ ):result = await harness.execute("googleGmail",{@@ -226,10 +228,12 @@ class TestGmailReceive:async def _instant_sleep(_seconds):return None- with _patch_creds("googleGmail"), _patch_build("googleGmail", service), patch(- "asyncio.sleep", new=_instant_sleep- ), patch("services.status_broadcaster.get_status_broadcaster") as gsb, patch(- "services.event_waiter.dispatch", return_value=1+ with (+ _patch_creds("googleGmail"),+ _patch_build("googleGmail", service),+ patch("asyncio.sleep", new=_instant_sleep),+ patch("services.status_broadcaster.get_status_broadcaster") as gsb,+ patch("services.event_waiter.dispatch", return_value=1),):gsb.return_value = MagicMock(update_node_status=AsyncMock())result = await harness.execute(@@ -268,10 +272,12 @@ class TestGmailReceive:async def _instant_sleep(_seconds):return None- with _patch_creds("googleGmail"), _patch_build("googleGmail", service), patch(- "asyncio.sleep", new=_instant_sleep- ), patch("services.status_broadcaster.get_status_broadcaster") as gsb, patch(- "services.event_waiter.dispatch", return_value=1+ with (+ _patch_creds("googleGmail"),+ _patch_build("googleGmail", service),+ patch("asyncio.sleep", new=_instant_sleep),+ patch("services.status_broadcaster.get_status_broadcaster") as gsb,+ patch("services.event_waiter.dispatch", return_value=1),):gsb.return_value = MagicMock(update_node_status=AsyncMock())result = await harness.execute(@@ -292,9 +298,7 @@ class TestGmailReceive:assert modify_call.kwargs["body"] == {"removeLabelIds": ["UNREAD"]}async def test_missing_credentials_returns_error(self, harness):- with _patch_creds(- "googleGmail", side_effect=ValueError("Google Workspace not connected")- ):+ with _patch_creds("googleGmail", side_effect=ValueError("Google Workspace not connected")):result = await harness.execute("googleGmailReceive",{@@ -370,9 +374,10 @@ class TestCalendar:assert "invalid parameters" in result["error"].lower()async def test_missing_credentials_short_circuits(self, harness):- with _patch_creds(- "googleCalendar", side_effect=ValueError("Google Workspace not connected")- ), _patch_build("googleCalendar", MagicMock()):+ with (+ _patch_creds("googleCalendar", side_effect=ValueError("Google Workspace not connected")),+ _patch_build("googleCalendar", MagicMock()),+ ):result = await harness.execute("googleCalendar",{@@ -749,9 +754,10 @@ class TestContacts:assert "invalid parameters" in result["error"].lower()async def test_missing_credentials_short_circuits(self, harness):- with _patch_creds(- "googleContacts", side_effect=ValueError("Google Workspace not connected")- ), _patch_build("googleContacts", MagicMock()):+ with (+ _patch_creds("googleContacts", side_effect=ValueError("Google Workspace not connected")),+ _patch_build("googleContacts", MagicMock()),+ ):result = await harness.execute("googleContacts",{diff --git a/server/tests/nodes/test_http_proxy.py b/server/tests/nodes/test_http_proxy.pyindex 0517ca02..75d246fb 100644--- a/server/tests/nodes/test_http_proxy.py+++ b/server/tests/nodes/test_http_proxy.py@@ -63,9 +63,7 @@ class TestHttpRequest:@respx.mockasync def test_happy_path_no_proxy(self, harness):- respx.get(self.URL).mock(- return_value=httpx.Response(200, json={"ok": True, "value": 42})- )+ respx.get(self.URL).mock(return_value=httpx.Response(200, json={"ok": True, "value": 42}))result = await harness.execute("httpRequest",@@ -73,9 +71,7 @@ class TestHttpRequest:)harness.assert_envelope(result, success=True)- harness.assert_output_shape(- result, ["status", "data", "headers", "url", "method", "proxied"]- )+ harness.assert_output_shape(result, ["status", "data", "headers", "url", "method", "proxied"])payload = result["result"]assert payload["status"] == 200assert payload["method"] == "GET"@@ -93,26 +89,18 @@ class TestHttpRequest:@respx.mockasync def test_network_error_returns_envelope_not_raise(self, harness):- respx.get(self.URL).mock(- side_effect=httpx.ConnectError("connection refused")- )+ respx.get(self.URL).mock(side_effect=httpx.ConnectError("connection refused"))- result = await harness.execute(- "httpRequest", {"method": "GET", "url": self.URL}- )+ result = await harness.execute("httpRequest", {"method": "GET", "url": self.URL})harness.assert_envelope(result, success=False)assert "connection refused" in result["error"].lower()@respx.mockasync def test_non_json_response_falls_back_to_text(self, harness):- respx.get(self.URL).mock(- return_value=httpx.Response(200, text="<html>hi</html>")- )+ respx.get(self.URL).mock(return_value=httpx.Response(200, text="<html>hi</html>"))- result = await harness.execute(- "httpRequest", {"method": "GET", "url": self.URL}- )+ result = await harness.execute("httpRequest", {"method": "GET", "url": self.URL})harness.assert_envelope(result, success=True)assert result["result"]["data"] == "<html>hi</html>"@@ -169,11 +157,11 @@ class TestProxyRequest:proxy_svc = _make_proxy_service_mock()pricing = _pricing_with_proxy_config()- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patch(- "services.pricing.get_pricing_service", return_value=pricing- ), patched_container():+ with (+ patch("services.proxy.service.get_proxy_service", return_value=proxy_svc),+ patch("services.pricing.get_pricing_service", return_value=pricing),+ patched_container(),+ ):result = await harness.execute("proxyRequest",{@@ -213,12 +201,8 @@ class TestProxyRequest:async def test_service_disabled_short_circuits(self, harness):proxy_svc = _make_proxy_service_mock(enabled=False)- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patched_container():- result = await harness.execute(- "proxyRequest", {"method": "GET", "url": "https://x.test"}- )+ with patch("services.proxy.service.get_proxy_service", return_value=proxy_svc), patched_container():+ result = await harness.execute("proxyRequest", {"method": "GET", "url": "https://x.test"})harness.assert_envelope(result, success=False)assert "proxy service not initialized" in result["error"].lower()@@ -226,12 +210,8 @@ class TestProxyRequest:async def test_missing_url_returns_validation_error(self, harness):proxy_svc = _make_proxy_service_mock()- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patched_container():- result = await harness.execute(- "proxyRequest", {"method": "GET", "url": ""}- )+ with patch("services.proxy.service.get_proxy_service", return_value=proxy_svc), patched_container():+ result = await harness.execute("proxyRequest", {"method": "GET", "url": ""})harness.assert_envelope(result, success=False)err = result["error"].lower()@@ -240,12 +220,8 @@ class TestProxyRequest:async def test_no_provider_available_returns_envelope(self, harness):proxy_svc = _make_proxy_service_mock(proxy_url=None)- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patched_container():- result = await harness.execute(- "proxyRequest", {"method": "GET", "url": "https://x.test"}- )+ with patch("services.proxy.service.get_proxy_service", return_value=proxy_svc), patched_container():+ result = await harness.execute("proxyRequest", {"method": "GET", "url": "https://x.test"})harness.assert_envelope(result, success=False)assert "no proxy provider" in result["error"].lower()@@ -256,9 +232,7 @@ class TestProxyRequest:respx.get(self.URL).mock(side_effect=httpx.ConnectError("boom"))proxy_svc = _make_proxy_service_mock()- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patched_container():+ with patch("services.proxy.service.get_proxy_service", return_value=proxy_svc), patched_container():result = await harness.execute("proxyRequest",{@@ -287,22 +261,18 @@ class TestProxyRequest:class TestProxyConfig:async def test_list_providers_happy_path(self, harness):stub_provider = MagicMock()- stub_provider.model_dump = MagicMock(- return_value={"name": "p1", "enabled": True, "score": 0.9}- )+ stub_provider.model_dump = MagicMock(return_value={"name": "p1", "enabled": True, "score": 0.9})proxy_svc = _make_proxy_service_mock(providers=[stub_provider])# proxy.py imports get_proxy_service at module load (line 17),# so we must patch it in the handler module too. tools.py re-imports# it inside the function, so patching the source is sufficient there.- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patched_container():- result = await harness.execute(- "proxyConfig", {"operation": "list_providers"}- )+ with (+ patch("services.proxy.service.get_proxy_service", return_value=proxy_svc),+ patch("services.proxy.service.get_proxy_service", return_value=proxy_svc),+ patched_container(),+ ):+ result = await harness.execute("proxyConfig", {"operation": "list_providers"})harness.assert_envelope(result, success=True)# Node handler wraps the tool result under result={...} and copies@@ -310,21 +280,17 @@ class TestProxyConfig:tool_payload = result["result"]assert tool_payload["success"] is Trueassert tool_payload["operation"] == "list_providers"- assert tool_payload["providers"] == [- {"name": "p1", "enabled": True, "score": 0.9}- ]+ assert tool_payload["providers"] == [{"name": "p1", "enabled": True, "score": 0.9}]async def test_add_provider_missing_name_returns_validation_error(self, harness):proxy_svc = _make_proxy_service_mock()- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patched_container():- result = await harness.execute(- "proxyConfig", {"operation": "add_provider", "name": ""}- )+ with (+ patch("services.proxy.service.get_proxy_service", return_value=proxy_svc),+ patch("services.proxy.service.get_proxy_service", return_value=proxy_svc),+ patched_container(),+ ):+ result = await harness.execute("proxyConfig", {"operation": "add_provider", "name": ""})harness.assert_envelope(result, success=False)assert "provider name is required" in result["error"].lower()@@ -332,14 +298,12 @@ class TestProxyConfig:async def test_unknown_operation_returns_error(self, harness):proxy_svc = _make_proxy_service_mock()- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ), patched_container():- result = await harness.execute(- "proxyConfig", {"operation": "teleport_provider"}- )+ with (+ patch("services.proxy.service.get_proxy_service", return_value=proxy_svc),+ patch("services.proxy.service.get_proxy_service", return_value=proxy_svc),+ patched_container(),+ ):+ result = await harness.execute("proxyConfig", {"operation": "teleport_provider"})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()@@ -353,17 +317,11 @@ class TestProxyConfig:class TestProxyStatus:async def test_happy_path_returns_providers_and_stats(self, harness):stub_provider = MagicMock()- stub_provider.model_dump = MagicMock(- return_value={"name": "p1", "score": 0.75, "success_rate": 0.9}- )+ stub_provider.model_dump = MagicMock(return_value={"name": "p1", "score": 0.75, "success_rate": 0.9})stats = {"total_requests": 100, "total_bytes": 12345}- proxy_svc = _make_proxy_service_mock(- providers=[stub_provider], stats=stats- )+ proxy_svc = _make_proxy_service_mock(providers=[stub_provider], stats=stats)- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ):+ with patch("services.proxy.service.get_proxy_service", return_value=proxy_svc):result = await harness.execute("proxyStatus", {})harness.assert_envelope(result, success=True)@@ -376,9 +334,7 @@ class TestProxyStatus:async def test_disabled_service_returns_empty_success_envelope(self, harness):proxy_svc = _make_proxy_service_mock(enabled=False)- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ):+ with patch("services.proxy.service.get_proxy_service", return_value=proxy_svc):result = await harness.execute("proxyStatus", {})harness.assert_envelope(result, success=True)@@ -390,9 +346,7 @@ class TestProxyStatus:proxy_svc = _make_proxy_service_mock()proxy_svc.get_stats = MagicMock(side_effect=RuntimeError("kaboom"))- with patch(- "services.proxy.service.get_proxy_service", return_value=proxy_svc- ):+ with patch("services.proxy.service.get_proxy_service", return_value=proxy_svc):result = await harness.execute("proxyStatus", {})harness.assert_envelope(result, success=False)diff --git a/server/tests/nodes/test_search.py b/server/tests/nodes/test_search.pyindex d2a72319..45e94f4f 100644--- a/server/tests/nodes/test_search.py+++ b/server/tests/nodes/test_search.py@@ -149,9 +149,7 @@ class TestSerperSearch:)harness.assert_envelope(result, success=True)- harness.assert_output_shape(- result, ["query", "results", "result_count", "search_type", "provider", "knowledge_graph"]- )+ harness.assert_output_shape(result, ["query", "results", "result_count", "search_type", "provider", "knowledge_graph"])payload = result["result"]assert payload["search_type"] == "search"assert payload["results"][0]["url"] == "https://a.example"@@ -195,14 +193,10 @@ class TestSerperSearch:@respx.mockasync def test_unknown_search_type_falls_back_to_web_endpoint_but_returns_empty_results(self, harness):# Post-refactor: Params tightens search_type with Literal[...]; unknown value rejected.- respx.post(f"{self.BASE}/search").mock(- return_value=httpx.Response(200, json={"organic": [{"title": "x", "link": "y"}]})- )+ respx.post(f"{self.BASE}/search").mock(return_value=httpx.Response(200, json={"organic": [{"title": "x", "link": "y"}]}))with patched_container(auth_api_keys={"serper": "tk"}), patched_pricing():- result = await harness.execute(- "serperSearch", {"query": "x", "search_type": "nonsense"}- )+ result = await harness.execute("serperSearch", {"query": "x", "search_type": "nonsense"})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()diff --git a/server/tests/nodes/test_specialized_agents.py b/server/tests/nodes/test_specialized_agents.pyindex 57de5471..2073cf71 100644--- a/server/tests/nodes/test_specialized_agents.py+++ b/server/tests/nodes/test_specialized_agents.py@@ -102,9 +102,7 @@ class TestGenericSpecializedAgents:async def test_auto_prompt_fallback_from_input_main(self, harness):"""Empty prompt should fall back to connected input-main output."""- harness.ai_service.execute_chat_agent = AsyncMock(- return_value={"success": True, "result": {"response": "ok"}}- )+ harness.ai_service.execute_chat_agent = AsyncMock(return_value={"success": True, "result": {"response": "ok"}})nodes = [{"id": "trigger-1", "type": "chatTrigger"},@@ -132,9 +130,7 @@ class TestGenericSpecializedAgents:async def test_task_completion_strips_tools(self, harness):"""When task_data.status is completed, tool_data is stripped to []."""- harness.ai_service.execute_chat_agent = AsyncMock(- return_value={"success": True, "result": {"response": "done"}}- )+ harness.ai_service.execute_chat_agent = AsyncMock(return_value={"success": True, "result": {"response": "done"}})# Wire a tool and a task trigger to the agent.nodes = [@@ -176,9 +172,7 @@ class TestGenericSpecializedAgents:@pytest.mark.parametrize("node_type", TEAM_LEAD_AGENTS)async def test_team_lead_collects_teammates_as_tools(self, harness, node_type):"""orchestrator_agent / ai_employee append teammates to tool_data."""- harness.ai_service.execute_chat_agent = AsyncMock(- return_value={"success": True, "result": {"response": "team"}}- )+ harness.ai_service.execute_chat_agent = AsyncMock(return_value={"success": True, "result": {"response": "team"}})nodes = [{@@ -208,15 +202,12 @@ class TestGenericSpecializedAgents:_, kwargs = harness.ai_service.execute_chat_agent.await_argstool_data = kwargs.get("tool_data") or []assert any(- t.get("node_id") == "mate-1" and t.get("node_type") == "coding_agent"- for t in tool_data+ t.get("node_id") == "mate-1" and t.get("node_type") == "coding_agent" for t in tool_data), f"expected teammate in tool_data, got {tool_data}"async def test_non_team_lead_ignores_teammates_handle(self, harness):"""A non-team-lead (e.g. coding_agent) does not expand input-teammates."""- harness.ai_service.execute_chat_agent = AsyncMock(- return_value={"success": True, "result": {"response": "ok"}}- )+ harness.ai_service.execute_chat_agent = AsyncMock(return_value={"success": True, "result": {"response": "ok"}})nodes = [{"id": "mate-1", "type": "web_agent", "data": {"label": "mate"}},@@ -245,9 +236,7 @@ class TestGenericSpecializedAgents:assert not any(t.get("node_id") == "mate-1" for t in tool_data)async def test_failure_envelope_propagates(self, harness):- harness.ai_service.execute_chat_agent = AsyncMock(- return_value={"success": False, "error": "model unavailable"}- )+ harness.ai_service.execute_chat_agent = AsyncMock(return_value={"success": False, "error": "model unavailable"})with patched_container(auth_api_keys={"openai": "tk"}):result = await harness.execute(@@ -372,19 +361,21 @@ class TestClaudeCodeAgent:tasks_list = list(tasks)results = []for t in tasks_list:- results.append(SessionResult(- task_id=t.task_id or "t_test",- session_id=session_id,- provider=provider,- prompt=t.prompt,- response=response,- cost_usd=cost_usd,- duration_ms=1234,- num_turns=2,- canonical_usage=CanonicalUsage(input_tokens=10, output_tokens=5),- success=success,- error=error,- ))+ results.append(+ SessionResult(+ task_id=t.task_id or "t_test",+ session_id=session_id,+ provider=provider,+ prompt=t.prompt,+ response=response,+ cost_usd=cost_usd,+ duration_ms=1234,+ num_turns=2,+ canonical_usage=CanonicalUsage(input_tokens=10, output_tokens=5),+ success=success,+ error=error,+ )+ )n_succeeded = sum(1 for r in results if r.success)return BatchResult(tasks=results,@@ -406,9 +397,13 @@ class TestClaudeCodeAgent:async def test_happy_path_routes_through_run_batch(self, harness):svc = self._wire_cli_service()- with patched_container(auth_api_keys={}), patched_broadcaster(), patch(- "services.cli_agent.service.get_ai_cli_service",- return_value=svc,+ with (+ patched_container(auth_api_keys={}),+ patched_broadcaster(),+ patch(+ "services.cli_agent.service.get_ai_cli_service",+ return_value=svc,+ ),):result = await harness.execute("claude_code_agent",@@ -438,9 +433,13 @@ class TestClaudeCodeAgent:"""Per-task max_budget_usd must reach the ClaudeTaskSpec."""svc = self._wire_cli_service()- with patched_container(auth_api_keys={}), patched_broadcaster(), patch(- "services.cli_agent.service.get_ai_cli_service",- return_value=svc,+ with (+ patched_container(auth_api_keys={}),+ patched_broadcaster(),+ patch(+ "services.cli_agent.service.get_ai_cli_service",+ return_value=svc,+ ),):await harness.execute("claude_code_agent",@@ -459,9 +458,13 @@ class TestClaudeCodeAgent:"""No prompt + no tasks must short-circuit before constructing a batch."""svc = self._wire_cli_service()- with patched_container(auth_api_keys={}), patched_broadcaster(), patch(- "services.cli_agent.service.get_ai_cli_service",- return_value=svc,+ with (+ patched_container(auth_api_keys={}),+ patched_broadcaster(),+ patch(+ "services.cli_agent.service.get_ai_cli_service",+ return_value=svc,+ ),):result = await harness.execute("claude_code_agent",@@ -478,9 +481,13 @@ class TestClaudeCodeAgent:svc = MagicMock(name="AICliService")svc.run_batch = AsyncMock(side_effect=RuntimeError("cli exit 1: boom"))- with patched_container(auth_api_keys={}), patched_broadcaster(), patch(- "services.cli_agent.service.get_ai_cli_service",- return_value=svc,+ with (+ patched_container(auth_api_keys={}),+ patched_broadcaster(),+ patch(+ "services.cli_agent.service.get_ai_cli_service",+ return_value=svc,+ ),):result = await harness.execute("claude_code_agent",@@ -506,9 +513,13 @@ class TestClaudeCodeAgent:extra={"outputs": {"src-1": {"message": "upstream text"}}},)- with patched_container(auth_api_keys={}), patched_broadcaster(), patch(- "services.cli_agent.service.get_ai_cli_service",- return_value=svc,+ with (+ patched_container(auth_api_keys={}),+ patched_broadcaster(),+ patch(+ "services.cli_agent.service.get_ai_cli_service",+ return_value=svc,+ ),):await harness.execute("claude_code_agent",diff --git a/server/tests/nodes/test_stripe_plugin.py b/server/tests/nodes/test_stripe_plugin.pyindex f72a9778..3615de6b 100644--- a/server/tests/nodes/test_stripe_plugin.py+++ b/server/tests/nodes/test_stripe_plugin.py@@ -63,6 +63,7 @@ class TestStripeWebhookShape:def test_shape_extracts_stripe_fields(self):from nodes.stripe._source import get_webhook_source+src = get_webhook_source()payload = {"id": "evt_1",@@ -87,11 +88,11 @@ class TestStripeWebhookShape:def test_handle_dispatches_on_valid_signature(self):from nodes.stripe._source import get_webhook_source+src = get_webhook_source()body = json.dumps({"id": "evt_2", "type": "charge.succeeded", "data": {}}).encode()req = _fake_request(body, headers=_signed(body, self.SECRET))- with self._stub_secret_resolution(), \- patch("services.event_waiter.dispatch") as dispatch:+ with self._stub_secret_resolution(), patch("services.event_waiter.dispatch") as dispatch:ev = _run(src.handle(req))assert ev.type == "stripe.charge.succeeded"dispatch.assert_called_once()@@ -102,6 +103,7 @@ class TestStripeWebhookShape:def test_handle_rejects_tampered_signature(self):from fastapi import HTTPExceptionfrom nodes.stripe._source import get_webhook_source+src = get_webhook_source()body = json.dumps({"id": "evt_3", "type": "charge.succeeded"}).encode()req = _fake_request(body, headers=_signed(body, "whsec_other"))@@ -119,11 +121,13 @@ class TestStripeWebhookShape:class TestStripeReceiveFilter:def _filter(self, params: dict | None = None):from nodes.stripe.stripe_receive import StripeReceiveNode, StripeReceiveParams+node = StripeReceiveNode()return node.build_filter(StripeReceiveParams(**(params or {})))def _ev(self, stripe_type: str, livemode: bool = False):from services.events import WorkflowEvent+return WorkflowEvent(source="stripe://acct_1",type=f"stripe.{stripe_type}",@@ -159,6 +163,7 @@ class TestStripeReceiveReshape:def test_shape_output_extracts_stripe_fields(self):from nodes.stripe.stripe_receive import StripeReceiveNodefrom services.events import WorkflowEvent+ev = WorkflowEvent(id="evt_1",source="stripe://acct_42",@@ -200,6 +205,7 @@ class TestStripeActionPassthrough:captured, fake = cli_capturewith patch("nodes.stripe.stripe_action.run_cli_command", AsyncMock(side_effect=fake)):from nodes.stripe.stripe_action import StripeActionNode, StripeActionParams+node = StripeActionNode()result = _run(node.run(None, StripeActionParams(command="customers create --email [email protected]")))assert result["success"] is True@@ -209,12 +215,14 @@ class TestStripeActionPassthrough:captured, fake = cli_capturewith patch("nodes.stripe.stripe_action.run_cli_command", AsyncMock(side_effect=fake)):from nodes.stripe.stripe_action import StripeActionNode, StripeActionParams+node = StripeActionNode()_run(node.run(None, StripeActionParams(command="customers create --name 'Acme Inc'")))assert captured == [["customers", "create", "--name", "Acme Inc"]]def test_empty_command_raises(self):from nodes.stripe.stripe_action import StripeActionNode, StripeActionParams+node = StripeActionNode()with pytest.raises(RuntimeError, match="command is required"):_run(node.run(None, StripeActionParams(command=" ")))@@ -240,29 +248,37 @@ class TestStripePluginRegistration:def test_ws_handlers_registered(self):import nodes.stripe # noqa: F401from services.ws_handler_registry import get_ws_handlers+registered = get_ws_handlers()for name in (- "stripe_login", "stripe_logout",- "stripe_connect", "stripe_disconnect", "stripe_reconnect",- "stripe_status", "stripe_trigger",+ "stripe_login",+ "stripe_logout",+ "stripe_connect",+ "stripe_disconnect",+ "stripe_reconnect",+ "stripe_status",+ "stripe_trigger",):assert name in registered, f"WS handler '{name}' not registered"def test_webhook_source_registered(self):import nodes.stripe # noqa: F401from services.events import WEBHOOK_SOURCES+assert "stripe" in WEBHOOK_SOURCESassert WEBHOOK_SOURCES["stripe"].type == "stripe.webhook"def test_node_classes_registered(self):import nodes.stripe # noqa: F401from services.node_registry import get_node_class+assert get_node_class("stripeReceive").__name__ == "StripeReceiveNode"assert get_node_class("stripeAction").__name__ == "StripeActionNode"def test_credential_registered(self):import nodes.stripe # noqa: F401from services.plugin.credential import CREDENTIAL_REGISTRY+# Stripe CLI manages auth at ~/.config/stripe/config.toml; the# credential class is a thin marker keyed by "stripe" (no api_key).assert "stripe" in CREDENTIAL_REGISTRY@@ -270,19 +286,23 @@ class TestStripePluginRegistration:def test_output_schemas_registered(self):import nodes.stripe # noqa: F401from services.node_output_schemas import NODE_OUTPUT_SCHEMAS+assert "stripeReceive" in NODE_OUTPUT_SCHEMASassert "stripeAction" in NODE_OUTPUT_SCHEMASdef test_action_node_is_ai_tool(self):from nodes.stripe.stripe_action import StripeActionNode+assert StripeActionNode.usable_as_tool is Truedef test_receive_node_subscribes_to_stripe_webhook(self):from nodes.stripe.stripe_receive import StripeReceiveNode+assert StripeReceiveNode.event_type == "stripe.webhook"def test_listen_source_has_correct_namespace(self):from nodes.stripe._source import get_listen_source+src = get_listen_source()assert src.process_name == "stripe-listen"assert src.workflow_namespace == "_stripe"diff --git a/server/tests/nodes/test_telegram_social.py b/server/tests/nodes/test_telegram_social.pyindex c33bd789..bef95f84 100644--- a/server/tests/nodes/test_telegram_social.py+++ b/server/tests/nodes/test_telegram_social.py@@ -50,26 +50,16 @@ def _make_telegram_service(*, connected: bool = True, owner_chat_id=None):"text": "hi",})- svc.send_photo = AsyncMock(- return_value={"message_id": 43, "chat_id": 111, "date": "2026-04-15T00:00:00"}- )- svc.send_document = AsyncMock(- return_value={"message_id": 44, "chat_id": 111, "date": "2026-04-15T00:00:00"}- )- svc.send_location = AsyncMock(- return_value={"message_id": 45, "chat_id": 111, "date": "2026-04-15T00:00:00"}- )- svc.send_contact = AsyncMock(- return_value={"message_id": 46, "chat_id": 111, "date": "2026-04-15T00:00:00"}- )+ svc.send_photo = AsyncMock(return_value={"message_id": 43, "chat_id": 111, "date": "2026-04-15T00:00:00"})+ svc.send_document = AsyncMock(return_value={"message_id": 44, "chat_id": 111, "date": "2026-04-15T00:00:00"})+ svc.send_location = AsyncMock(return_value={"message_id": 45, "chat_id": 111, "date": "2026-04-15T00:00:00"})+ svc.send_contact = AsyncMock(return_value={"message_id": 46, "chat_id": 111, "date": "2026-04-15T00:00:00"})return svcdef _patch_telegram_service(svc):"""Patch the get_telegram_service accessor at its canonical path."""- return patch(- "nodes.telegram._service.get_telegram_service", return_value=svc- )+ return patch("nodes.telegram._service.get_telegram_service", return_value=svc)# ============================================================================@@ -114,9 +104,7 @@ class TestTelegramSend:# Service has no owner in memory, but credentials DB has one saved.svc = _make_telegram_service(connected=True, owner_chat_id=None)- with _patch_telegram_service(svc), patched_container(- auth_api_keys={"telegram_owner_chat_id": "7777"}- ):+ with _patch_telegram_service(svc), patched_container(auth_api_keys={"telegram_owner_chat_id": "7777"}):result = await harness.execute("telegramSend",{"recipient_type": "self", "message_type": "text", "text": "hi"},@@ -295,9 +283,7 @@ class TestTelegramReceive:svc = _make_telegram_service(connected=True, owner_chat_id=42)waiter = _make_waiter_stub(canned_event=self.CANNED)- with _patch_telegram_service(svc), patched_broadcaster(), patch(- "services.event_waiter", waiter- ):+ with _patch_telegram_service(svc), patched_broadcaster(), patch("services.event_waiter", waiter):result = await harness.execute("telegramReceive",{"sender_filter": "all", "content_type_filter": "all"},@@ -313,9 +299,7 @@ class TestTelegramReceive:svc = _make_telegram_service(connected=False)waiter = _make_waiter_stub(canned_event=self.CANNED)- with _patch_telegram_service(svc), patched_broadcaster(), patch(- "services.event_waiter", waiter- ):+ with _patch_telegram_service(svc), patched_broadcaster(), patch("services.event_waiter", waiter):result = await harness.execute("telegramReceive",{"sender_filter": "all"},@@ -332,9 +316,7 @@ class TestTelegramReceive:svc = _make_telegram_service(connected=True, owner_chat_id=1)waiter = _make_waiter_stub(wait_side_effect=asyncio.CancelledError())- with _patch_telegram_service(svc), patched_broadcaster(), patch(- "services.event_waiter", waiter- ):+ with _patch_telegram_service(svc), patched_broadcaster(), patch("services.event_waiter", waiter):result = await harness.execute("telegramReceive",{"sender_filter": "all"},@@ -351,9 +333,7 @@ class TestTelegramReceive:class TestSocialSend:async def test_whatsapp_text_happy_path(self, harness):- whatsapp_send = AsyncMock(- return_value={"success": True, "message_id": "wamid.xyz"}- )+ whatsapp_send = AsyncMock(return_value={"success": True, "message_id": "wamid.xyz"})# The social node resolves the platform handler via the# social_provider_registry (Wave 11.I plugin self-registration).@@ -426,13 +406,15 @@ class TestSocialSend:)harness.assert_envelope(result, success=False)- assert "discord" in result["error"].lower() or "not yet implemented" in result["error"].lower() or "not supported" in result["error"].lower()+ assert (+ "discord" in result["error"].lower()+ or "not yet implemented" in result["error"].lower()+ or "not supported" in result["error"].lower()+ )whatsapp_send.assert_not_awaited()async def test_whatsapp_failure_becomes_error_envelope(self, harness):- whatsapp_send = AsyncMock(- return_value={"success": False, "error": "rpc boom"}- )+ whatsapp_send = AsyncMock(return_value={"success": False, "error": "rpc boom"})# See test_whatsapp_text_happy_path: patch the registry lookup,# not the module attribute the registry already captured.diff --git a/server/tests/nodes/test_twitter.py b/server/tests/nodes/test_twitter.pyindex 20a34c10..49ecaf1f 100644--- a/server/tests/nodes/test_twitter.py+++ b/server/tests/nodes/test_twitter.py@@ -88,16 +88,10 @@ def _patch_client(stub_cls):class TestTwitterSend:async def test_tweet_happy_path(self, harness):posts = MagicMock(name="posts")- posts.create = MagicMock(- return_value=SimpleNamespace(- data={"id": "1999000000000000001", "text": "hello world"}- )- )+ posts.create = MagicMock(return_value=SimpleNamespace(data={"id": "1999000000000000001", "text": "hello world"}))stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():result = await harness.execute("twitterSend",{"action": "tweet", "text": "hello world"},@@ -115,18 +109,12 @@ class TestTwitterSend:async def test_tweet_truncates_to_280_chars(self, harness):posts = MagicMock(name="posts")- posts.create = MagicMock(- return_value=SimpleNamespace(data={"id": "1", "text": "t"})- )+ posts.create = MagicMock(return_value=SimpleNamespace(data={"id": "1", "text": "t"}))stub_cls = _make_client_class(posts=posts)long_text = "x" * 400- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterSend", {"action": "tweet", "text": long_text}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterSend", {"action": "tweet", "text": long_text})harness.assert_envelope(result, success=True)sent = posts.create.call_args.kwargs["body"]["text"]@@ -135,14 +123,10 @@ class TestTwitterSend:async def test_reply_happy_path(self, harness):posts = MagicMock(name="posts")- posts.create = MagicMock(- return_value=SimpleNamespace(data={"id": "r1", "text": "replying"})- )+ posts.create = MagicMock(return_value=SimpleNamespace(data={"id": "r1", "text": "replying"}))stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():result = await harness.execute("twitterSend",{@@ -164,12 +148,8 @@ class TestTwitterSend:posts.create = MagicMock()stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterSend", {"action": "reply", "text": "hi"}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterSend", {"action": "reply", "text": "hi"})harness.assert_envelope(result, success=False)assert "tweet_id" in result["error"].lower()@@ -179,12 +159,8 @@ class TestTwitterSend:posts = MagicMock(name="posts")stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterSend", {"action": "tweet", "text": ""}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterSend", {"action": "tweet", "text": ""})harness.assert_envelope(result, success=False)assert "text is required" in result["error"].lower()@@ -193,12 +169,8 @@ class TestTwitterSend:# Post-refactor: action is a Literal; unknown values rejected by Pydantic.stub_cls = _make_client_class()- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterSend", {"action": "mysterious", "text": "x", "tweet_id": "1"}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterSend", {"action": "mysterious", "text": "x", "tweet_id": "1"})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()@@ -206,12 +178,14 @@ class TestTwitterSend:async def test_missing_oauth_tokens_errors(self, harness):stub_cls = _make_client_class()- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens={} # no twitter entry- ), patched_pricing():- result = await harness.execute(- "twitterSend", {"action": "tweet", "text": "hi"}- )+ with (+ _patch_client(stub_cls),+ patched_container(+ auth_oauth_tokens={} # no twitter entry+ ),+ patched_pricing(),+ ):+ result = await harness.execute("twitterSend", {"action": "tweet", "text": "hi"})harness.assert_envelope(result, success=False)assert "not connected" in result["error"].lower()@@ -239,18 +213,17 @@ class TestTwitterSend:})- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing(), patch(- "nodes.twitter._oauth.TwitterOAuth"- ) as oauth_cls:+ with (+ _patch_client(stub_cls),+ patched_container(auth_oauth_tokens=_ok_tokens()),+ patched_pricing(),+ patch("nodes.twitter._oauth.TwitterOAuth") as oauth_cls,+ ):oauth_instance = MagicMock()oauth_instance.refresh_access_token = refresh_mockoauth_cls.return_value = oauth_instance- result = await harness.execute(- "twitterSend", {"action": "tweet", "text": "hi"}- )+ result = await harness.execute("twitterSend", {"action": "tweet", "text": "hi"})harness.assert_envelope(result, success=True)assert calls["n"] == 2 # original + retry@@ -313,25 +286,17 @@ class TestTwitterSearch:"profile_image_url": "https://example.com/a.jpg",}],- "media": [- {"media_key": "mk1", "type": "photo", "url": "https://example.com/m.jpg"}- ],- "tweets": [- {"id": "twQ", "text": "quoted body", "author_id": "userQ"}- ],+ "media": [{"media_key": "mk1", "type": "photo", "url": "https://example.com/m.jpg"}],+ "tweets": [{"id": "twQ", "text": "quoted body", "author_id": "userQ"}],}posts = MagicMock(name="posts")# search_recent is a generator; one page is enough per the handler's# "break after first page" contract.- posts.search_recent = MagicMock(- return_value=iter([self._search_page([raw_tweet], includes)])- )+ posts.search_recent = MagicMock(return_value=iter([self._search_page([raw_tweet], includes)]))stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():result = await harness.execute("twitterSearch",{"query": "hello", "max_results": 10},@@ -372,17 +337,11 @@ class TestTwitterSearch:"public_metrics": {},}posts = MagicMock(name="posts")- posts.search_recent = MagicMock(- return_value=iter([self._search_page([raw_tweet], {})])- )+ posts.search_recent = MagicMock(return_value=iter([self._search_page([raw_tweet], {})]))stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterSearch", {"query": "x"}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterSearch", {"query": "x"})harness.assert_envelope(result, success=True)tw = result["result"]["tweets"][0]@@ -394,12 +353,8 @@ class TestTwitterSearch:posts.search_recent = MagicMock(return_value=iter([self._search_page([], {})]))stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterSearch", {"query": "x", "max_results": 500}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterSearch", {"query": "x", "max_results": 500})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()@@ -409,12 +364,8 @@ class TestTwitterSearch:posts.search_recent = MagicMock(return_value=iter([self._search_page([], {})]))stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterSearch", {"query": "x", "max_results": 3}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterSearch", {"query": "x", "max_results": 3})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()@@ -424,12 +375,8 @@ class TestTwitterSearch:posts.search_recent = MagicMock()stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterSearch", {"query": " "}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterSearch", {"query": " "})# Handler checks "not query" i.e. falsy, so empty string fails.# Whitespace-only goes through but a strip-less empty check means@@ -442,9 +389,7 @@ class TestTwitterSearch:posts.search_recent = MagicMock()stub_cls = _make_client_class(posts=posts)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():result = await harness.execute("twitterSearch", {"query": ""})harness.assert_envelope(result, success=False)@@ -475,9 +420,7 @@ class TestTwitterUser:)stub_cls = _make_client_class(users=users)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():result = await harness.execute("twitterUser", {"operation": "me"})harness.assert_envelope(result, success=True)@@ -490,17 +433,11 @@ class TestTwitterUser:async def test_by_username_not_found(self, harness):users = MagicMock(name="users")- users.get_by_usernames = MagicMock(- return_value=SimpleNamespace(data=[])- )+ users.get_by_usernames = MagicMock(return_value=SimpleNamespace(data=[]))stub_cls = _make_client_class(users=users)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterUser", {"operation": "by_username", "username": "ghost"}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterUser", {"operation": "by_username", "username": "ghost"})harness.assert_envelope(result, success=False)assert "ghost" in result["error"]@@ -511,12 +448,8 @@ class TestTwitterUser:users.get_by_usernames = MagicMock()stub_cls = _make_client_class(users=users)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterUser", {"operation": "by_username"}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterUser", {"operation": "by_username"})harness.assert_envelope(result, success=False)assert "username" in result["error"].lower()@@ -524,16 +457,10 @@ class TestTwitterUser:async def test_followers_above_1000_rejected(self, harness):users = MagicMock(name="users")- users.get_followers = MagicMock(- return_value=iter(- [SimpleNamespace(data=[{"id": "u1", "username": "a", "name": "A"}])]- )- )+ users.get_followers = MagicMock(return_value=iter([SimpleNamespace(data=[{"id": "u1", "username": "a", "name": "A"}])]))stub_cls = _make_client_class(users=users)- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():result = await harness.execute("twitterUser",{"operation": "followers", "user_id": "x1", "max_results": 9999},@@ -545,12 +472,8 @@ class TestTwitterUser:async def test_unknown_operation(self, harness):stub_cls = _make_client_class()- with _patch_client(stub_cls), patched_container(- auth_oauth_tokens=_ok_tokens()- ), patched_pricing():- result = await harness.execute(- "twitterUser", {"operation": "mysterious"}- )+ with _patch_client(stub_cls), patched_container(auth_oauth_tokens=_ok_tokens()), patched_pricing():+ result = await harness.execute("twitterUser", {"operation": "mysterious"})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()@@ -597,9 +520,7 @@ class TestTwitterReceive:async def test_happy_path_returns_canned_event(self, harness):waiter = _make_waiter_stub(canned_event=self.CANNED)- with patched_broadcaster(), patch(- "services.handlers.triggers.event_waiter", waiter- ):+ with patched_broadcaster(), patch("services.handlers.triggers.event_waiter", waiter):result = await harness.execute("twitterReceive",{"trigger_type": "mentions", "poll_interval": 60},@@ -618,12 +539,8 @@ class TestTwitterReceive:waiter = _make_waiter_stub()waiter.wait_for_event = AsyncMock(side_effect=asyncio.CancelledError())- with patched_broadcaster(), patch(- "services.handlers.triggers.event_waiter", waiter- ):- result = await harness.execute(- "twitterReceive", {"trigger_type": "mentions"}- )+ with patched_broadcaster(), patch("services.handlers.triggers.event_waiter", waiter):+ result = await harness.execute("twitterReceive", {"trigger_type": "mentions"})harness.assert_envelope(result, success=False)assert "cancel" in result["error"].lower()@@ -633,12 +550,8 @@ class TestTwitterReceive:waiter = _make_waiter_stub()waiter.get_trigger_config = MagicMock(return_value=None)- with patched_broadcaster(), patch(- "services.handlers.triggers.event_waiter", waiter- ):- result = await harness.execute(- "twitterReceive", {"trigger_type": "mentions"}- )+ with patched_broadcaster(), patch("services.handlers.triggers.event_waiter", waiter):+ result = await harness.execute("twitterReceive", {"trigger_type": "mentions"})harness.assert_envelope(result, success=False)assert "unknown trigger" in result["error"].lower()@@ -648,12 +561,8 @@ class TestTwitterReceive:waiter = _make_waiter_stub()waiter.wait_for_event = AsyncMock(side_effect=RuntimeError("boom"))- with patched_broadcaster(), patch(- "services.handlers.triggers.event_waiter", waiter- ):- result = await harness.execute(- "twitterReceive", {"trigger_type": "mentions"}- )+ with patched_broadcaster(), patch("services.handlers.triggers.event_waiter", waiter):+ result = await harness.execute("twitterReceive", {"trigger_type": "mentions"})harness.assert_envelope(result, success=False)assert "boom" in result["error"]diff --git a/server/tests/nodes/test_web_automation.py b/server/tests/nodes/test_web_automation.pyindex 439065f2..f782c71b 100644--- a/server/tests/nodes/test_web_automation.py+++ b/server/tests/nodes/test_web_automation.py@@ -86,9 +86,7 @@ class TestBrowser:async def test_snapshot_uses_i_flag_and_session_fallback(self, harness):# Empty session -> handler must derive machina_<execution_id>.- fake = _FakeBrowserService(- canned={"success": True, "nodes": [{"ref": "@e1", "role": "button"}]}- )+ fake = _FakeBrowserService(canned={"success": True, "nodes": [{"ref": "@e1", "role": "button"}]})with _patch_browser_service(fake):result = await harness.execute(@@ -139,9 +137,7 @@ class TestBrowser:assert fake.calls == []async def test_service_not_installed(self, harness):- with patch(- "nodes.browser._service.get_browser_service", return_value=None- ):+ with patch("nodes.browser._service.get_browser_service", return_value=None):result = await harness.execute("browser", {"operation": "navigate", "url": "https://x"})harness.assert_envelope(result, success=False)@@ -151,9 +147,7 @@ class TestBrowser:fake = _FakeBrowserService(error=RuntimeError("agent-browser returned empty output"))with _patch_browser_service(fake):- result = await harness.execute(- "browser", {"operation": "navigate", "url": "https://x"}- )+ result = await harness.execute("browser", {"operation": "navigate", "url": "https://x"})harness.assert_envelope(result, success=False)assert "empty output" in result["error"].lower()@@ -201,12 +195,10 @@ class _FakeCrawler:class TestCrawleeScraper:async def test_beautifulsoup_single_happy_path(self, harness):fake_cls = _FakeCrawler # class is instantiated inside the handler- with patch(- "crawlee.crawlers.BeautifulSoupCrawler", fake_cls- ), patch(- "crawlee.storage_clients.MemoryStorageClient", MagicMock()- ), patch(- "crawlee.ConcurrencySettings", MagicMock()+ with (+ patch("crawlee.crawlers.BeautifulSoupCrawler", fake_cls),+ patch("crawlee.storage_clients.MemoryStorageClient", MagicMock()),+ patch("crawlee.ConcurrencySettings", MagicMock()),):result = await harness.execute("crawleeScraper",@@ -218,9 +210,7 @@ class TestCrawleeScraper:)harness.assert_envelope(result, success=True)- harness.assert_output_shape(- result, ["pages", "page_count", "crawler_type", "mode", "proxied"]- )+ harness.assert_output_shape(result, ["pages", "page_count", "crawler_type", "mode", "proxied"])payload = result["result"]assert payload["crawler_type"] == "beautifulsoup"assert payload["mode"] == "single"@@ -232,9 +222,7 @@ class TestCrawleeScraper:assert "hello" in page["content"]async def test_missing_url_returns_validation_error(self, harness):- result = await harness.execute(- "crawleeScraper", {"url": "", "crawler_type": "beautifulsoup"}- )+ result = await harness.execute("crawleeScraper", {"url": "", "crawler_type": "beautifulsoup"})harness.assert_envelope(result, success=False)assert "url is required" in result["error"].lower()@@ -271,12 +259,10 @@ class TestCrawleeScraper:async def run(self, urls):raise RuntimeError("crawler blew up")- with patch(- "crawlee.crawlers.BeautifulSoupCrawler", BrokenCrawler- ), patch(- "crawlee.storage_clients.MemoryStorageClient", MagicMock()- ), patch(- "crawlee.ConcurrencySettings", MagicMock()+ with (+ patch("crawlee.crawlers.BeautifulSoupCrawler", BrokenCrawler),+ patch("crawlee.storage_clients.MemoryStorageClient", MagicMock()),+ patch("crawlee.ConcurrencySettings", MagicMock()),):result = await harness.execute("crawleeScraper",@@ -330,9 +316,7 @@ class TestApifyActor:items = [{"url": "https://a.example"}, {"url": "https://b.example"}]fake_client = _make_fake_apify_client(run_info=run_info, items=items)- with patched_container(auth_api_keys={"apify": "tk_apify"}), patch(- "apify_client.ApifyClientAsync", return_value=fake_client- ):+ with patched_container(auth_api_keys={"apify": "tk_apify"}), patch("apify_client.ApifyClientAsync", return_value=fake_client):result = await harness.execute("apifyActor",{@@ -391,9 +375,7 @@ class TestApifyActor:async def test_missing_actor_id_returns_validation_error(self, harness):fake_client = _make_fake_apify_client(run_info={})- with patched_container(auth_api_keys={"apify": "tk"}), patch(- "apify_client.ApifyClientAsync", return_value=fake_client- ):+ with patched_container(auth_api_keys={"apify": "tk"}), patch("apify_client.ApifyClientAsync", return_value=fake_client):result = await harness.execute("apifyActor", {"actor_id": ""})harness.assert_envelope(result, success=False)@@ -408,27 +390,17 @@ class TestApifyActor:}fake_client = _make_fake_apify_client(run_info=run_info, items=[])- with patched_container(auth_api_keys={"apify": "tk"}), patch(- "apify_client.ApifyClientAsync", return_value=fake_client- ):- result = await harness.execute(- "apifyActor", {"actor_id": "apify/instagram-scraper"}- )+ with patched_container(auth_api_keys={"apify": "tk"}), patch("apify_client.ApifyClientAsync", return_value=fake_client):+ result = await harness.execute("apifyActor", {"actor_id": "apify/instagram-scraper"})harness.assert_envelope(result, success=False)assert "actor crashed at step 3" in result["error"].lower()async def test_unauthorized_exception_rewritten(self, harness):- fake_client = _make_fake_apify_client(- call_exc=RuntimeError("Request failed: 401 Unauthorized")- )+ fake_client = _make_fake_apify_client(call_exc=RuntimeError("Request failed: 401 Unauthorized"))- with patched_container(auth_api_keys={"apify": "tk"}), patch(- "apify_client.ApifyClientAsync", return_value=fake_client- ):- result = await harness.execute(- "apifyActor", {"actor_id": "apify/instagram-scraper"}- )+ with patched_container(auth_api_keys={"apify": "tk"}), patch("apify_client.ApifyClientAsync", return_value=fake_client):+ result = await harness.execute("apifyActor", {"actor_id": "apify/instagram-scraper"})harness.assert_envelope(result, success=False)assert "401" in result["error"].lower() or "unauthorized" in result["error"].lower()@@ -444,9 +416,7 @@ class TestApifyActor:}fake_client = _make_fake_apify_client(run_info=run_info, items=[])- with patched_container(auth_api_keys={"apify": "tk"}), patch(- "apify_client.ApifyClientAsync", return_value=fake_client- ):+ with patched_container(auth_api_keys={"apify": "tk"}), patch("apify_client.ApifyClientAsync", return_value=fake_client):result = await harness.execute("apifyActor",{diff --git a/server/tests/nodes/test_whatsapp.py b/server/tests/nodes/test_whatsapp.pyindex 7758b7a7..25eef783 100644--- a/server/tests/nodes/test_whatsapp.py+++ b/server/tests/nodes/test_whatsapp.py@@ -94,12 +94,15 @@ class TestWhatsappSend:captured["message"] = params.get("message")return {"success": True}- with patch(- "nodes.whatsapp._service.handle_whatsapp_send",- new=AsyncMock(side_effect=fake_send),- ), patch(- "services.markdown_formatter.to_whatsapp",- return_value="*bold*",+ with (+ patch(+ "nodes.whatsapp._service.handle_whatsapp_send",+ new=AsyncMock(side_effect=fake_send),+ ),+ patch(+ "services.markdown_formatter.to_whatsapp",+ return_value="*bold*",+ ),):result = await harness.execute("whatsappSend",@@ -211,10 +214,7 @@ class TestWhatsappDb:async def test_search_groups_truncates_and_shapes(self, harness):"""search_groups returns only {jid, name} and reports truncation."""- groups = [- {"jid": f"g{i}@g.us", "name": f"Group {i}", "extra_field": "noise"}- for i in range(5)- ]+ groups = [{"jid": f"g{i}@g.us", "name": f"Group {i}", "extra_field": "noise"} for i in range(5)]# Handler runs data.get('success', True) BEFORE isinstance(data, list)# (documented bug), so the RPC stub must return a dict envelope here.with _patch_rpc_call({"success": True, "result": groups}):@@ -387,9 +387,7 @@ class TestWhatsappReceive:async def test_happy_path_returns_canned_event(self, harness):waiter = _make_waiter_stub(canned_event=self.CANNED)- with patched_broadcaster(), patched_container(), patch(- "services.event_waiter", waiter- ):+ with patched_broadcaster(), patched_container(), patch("services.event_waiter", waiter):result = await harness.execute("whatsappReceive",{@@ -411,9 +409,7 @@ class TestWhatsappReceive:waiter = _make_waiter_stub(wait_side_effect=asyncio.CancelledError())- with patched_broadcaster(), patched_container(), patch(- "services.event_waiter", waiter- ):+ with patched_broadcaster(), patched_container(), patch("services.event_waiter", waiter):result = await harness.execute("whatsappReceive",{"filter": "all"},@@ -425,9 +421,7 @@ class TestWhatsappReceive:async def test_waiter_exception_surfaces_as_error(self, harness):waiter = _make_waiter_stub(wait_side_effect=RuntimeError("redis stream down"))- with patched_broadcaster(), patched_container(), patch(- "services.event_waiter", waiter- ):+ with patched_broadcaster(), patched_container(), patch("services.event_waiter", waiter):result = await harness.execute("whatsappReceive",{"filter": "keywords", "keywords": "urgent,fire"},diff --git a/server/tests/nodes/test_workflow_triggers.py b/server/tests/nodes/test_workflow_triggers.pyindex 5c72240d..cb765c39 100644--- a/server/tests/nodes/test_workflow_triggers.py+++ b/server/tests/nodes/test_workflow_triggers.py@@ -88,9 +88,7 @@ def patched_trigger_waiter(class TestStart:async def test_happy_path_returns_parsed_initial_data(self, harness):- result = await harness.execute(- "start", {"initial_data": '{"message": "hi", "n": 7}'}- )+ result = await harness.execute("start", {"initial_data": '{"message": "hi", "n": 7}'})harness.assert_envelope(result, success=True)payload = result["result"]assert payload == {"message": "hi", "n": 7}@@ -114,12 +112,8 @@ class TestStart:class TestTimer:async def test_happy_path_short_sleep(self, harness):- with patched_broadcaster() as broadcaster, patch(- "asyncio.sleep", new=AsyncMock()- ):- result = await harness.execute(- "timer", {"duration": 1, "unit": "seconds"}- )+ with patched_broadcaster() as broadcaster, patch("asyncio.sleep", new=AsyncMock()):+ result = await harness.execute("timer", {"duration": 1, "unit": "seconds"})harness.assert_envelope(result, success=True)harness.assert_output_shape(result,@@ -139,17 +133,13 @@ class TestTimer:async def test_unknown_unit_falls_back_to_raw_seconds(self, harness):# Post-refactor: unit is a Literal[...]; unknown value rejected by Pydantic.with patched_broadcaster():- result = await harness.execute(- "timer", {"duration": 1, "unit": "fortnights"}- )+ result = await harness.execute("timer", {"duration": 1, "unit": "fortnights"})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()async def test_non_numeric_duration_returns_error_envelope(self, harness):with patched_broadcaster():- result = await harness.execute(- "timer", {"duration": "abc", "unit": "seconds"}- )+ result = await harness.execute("timer", {"duration": "abc", "unit": "seconds"})harness.assert_envelope(result, success=False)@@ -161,9 +151,7 @@ class TestTimer:class TestCronScheduler:async def test_once_frequency_fires_immediately(self, harness):with patched_broadcaster() as broadcaster:- result = await harness.execute(- "cronScheduler", {"frequency": "once"}- )+ result = await harness.execute("cronScheduler", {"frequency": "once"})harness.assert_envelope(result, success=True)harness.assert_output_shape(result,@@ -184,16 +172,10 @@ class TestCronScheduler:assert payload.get("next_run") is Nonebroadcaster.update_node_status.assert_called()- async def test_recurring_frequency_adds_next_run_and_schedule_string(- self, harness- ):+ async def test_recurring_frequency_adds_next_run_and_schedule_string(self, harness):# Patch asyncio.sleep so the handler doesn't actually wait 30s.- with patched_broadcaster(), patch(- "asyncio.sleep", new=AsyncMock()- ) as sleep_mock:- result = await harness.execute(- "cronScheduler", {"frequency": "seconds", "interval": 30}- )+ with patched_broadcaster(), patch("asyncio.sleep", new=AsyncMock()) as sleep_mock:+ result = await harness.execute("cronScheduler", {"frequency": "seconds", "interval": 30})harness.assert_envelope(result, success=True)payload = result["result"]assert payload["frequency"] == "seconds"@@ -206,9 +188,7 @@ class TestCronScheduler:async def test_unknown_frequency_rejected(self, harness):# Post-refactor: frequency is a Literal; unknown value rejected at Params level.with patched_broadcaster():- result = await harness.execute(- "cronScheduler", {"frequency": "quantum"}- )+ result = await harness.execute("cronScheduler", {"frequency": "quantum"})harness.assert_envelope(result, success=False)assert "invalid parameters" in result["error"].lower()@@ -228,9 +208,7 @@ class TestWebhookTrigger:"json": {"hello": "world"},}with patched_trigger_waiter(canned), patched_broadcaster() as broadcaster:- result = await harness.execute(- "webhookTrigger", {"path": "my-hook", "method": "POST"}- )+ result = await harness.execute("webhookTrigger", {"path": "my-hook", "method": "POST"})harness.assert_envelope(result, success=True)assert result["result"] == canned@@ -262,9 +240,7 @@ class TestChatTrigger:"timestamp": "2026-04-15T10:00:00Z",}with patched_trigger_waiter(canned), patched_broadcaster():- result = await harness.execute(- "chatTrigger", {"sessionId": "default"}- )+ result = await harness.execute("chatTrigger", {"sessionId": "default"})harness.assert_envelope(result, success=True)payload = result["result"]assert payload["message"] == "hello agent"@@ -280,14 +256,13 @@ class TestChatTrigger:async def test_wait_failure_returns_error_envelope(self, harness):import asyncio as _asyncio+with patched_trigger_waiter() as ew, patched_broadcaster():# Plugin awaits waiter.future directly; replace it with a failing future.failing = _asyncio.get_event_loop().create_future()failing.set_exception(RuntimeError("boom"))ew.register.return_value.future = failing- result = await harness.execute(- "chatTrigger", {"sessionId": "default"}- )+ result = await harness.execute("chatTrigger", {"sessionId": "default"})harness.assert_envelope(result, success=False)assert "boom" in result["error"]@@ -309,9 +284,7 @@ class TestTaskTrigger:"workflow_id": "wf-1",}with patched_trigger_waiter(canned), patched_broadcaster():- result = await harness.execute(- "taskTrigger", {"status_filter": "completed"}- )+ result = await harness.execute("taskTrigger", {"status_filter": "completed"})harness.assert_envelope(result, success=True)assert result["result"]["status"] == "completed"assert result["result"]["task_id"] == "t-1"@@ -327,9 +300,7 @@ class TestTaskTrigger:"workflow_id": "wf-1",}with patched_trigger_waiter(canned), patched_broadcaster():- result = await harness.execute(- "taskTrigger", {"status_filter": "error"}- )+ result = await harness.execute("taskTrigger", {"status_filter": "error"})harness.assert_envelope(result, success=True)assert result["result"]["status"] == "error"assert result["result"]["error"] == "something failed"diff --git a/server/tests/services/cli_agent/test_claude_session_events.py b/server/tests/services/cli_agent/test_claude_session_events.pyindex c6364332..f2178385 100644--- a/server/tests/services/cli_agent/test_claude_session_events.py+++ b/server/tests/services/cli_agent/test_claude_session_events.py@@ -39,7 +39,9 @@ class TestClaudeSessionSpawned:def test_matches_type_glob(self):event = WorkflowEvent.claude_session_spawned(- memory_node_id="m", session_uuid="u", pid=1,+ memory_node_id="m",+ session_uuid="u",+ pid=1,)assert event.matches_type("claude.session.*")assert event.matches_type("claude.session.spawned")@@ -136,18 +138,36 @@ class TestCloudEventInvariants:"""Cross-cutting checks the four events all satisfy."""EVENTS = [- ("spawned", lambda: WorkflowEvent.claude_session_spawned(- memory_node_id="m", session_uuid="u", pid=1,- )),- ("cleared", lambda: WorkflowEvent.claude_session_cleared(- memory_node_id="m", old_session_uuid="a", new_session_uuid="b",- )),- ("terminated", lambda: WorkflowEvent.claude_session_terminated(- memory_node_id="m", reason="idle",- )),- ("usage", lambda: WorkflowEvent.claude_session_usage(- memory_node_id="m", session_uuid="u",- )),+ (+ "spawned",+ lambda: WorkflowEvent.claude_session_spawned(+ memory_node_id="m",+ session_uuid="u",+ pid=1,+ ),+ ),+ (+ "cleared",+ lambda: WorkflowEvent.claude_session_cleared(+ memory_node_id="m",+ old_session_uuid="a",+ new_session_uuid="b",+ ),+ ),+ (+ "terminated",+ lambda: WorkflowEvent.claude_session_terminated(+ memory_node_id="m",+ reason="idle",+ ),+ ),+ (+ "usage",+ lambda: WorkflowEvent.claude_session_usage(+ memory_node_id="m",+ session_uuid="u",+ ),+ ),]def test_all_share_source_uri(self):@@ -165,9 +185,7 @@ class TestCloudEventInvariants:for name, builder in self.EVENTS:event = builder()assert event.dataschema is not None- assert event.dataschema.startswith(- "machinaos://schemas/events/claude.session."- ), name+ assert event.dataschema.startswith("machinaos://schemas/events/claude.session."), nameassert event.dataschema.endswith(".json"), namedef test_all_carry_specversion_1(self):diff --git a/server/tests/services/cli_agent/test_mcp_server.py b/server/tests/services/cli_agent/test_mcp_server.pyindex 2764b65f..5f0e7a8c 100644--- a/server/tests/services/cli_agent/test_mcp_server.py+++ b/server/tests/services/cli_agent/test_mcp_server.py@@ -39,6 +39,7 @@ from services.cli_agent.mcp_server import (# Token registry# ---------------------------------------------------------------------------+class TestTokenRegistry:def setup_method(self):_reset_for_tests()@@ -53,7 +54,8 @@ class TestTokenRegistry:def test_register_lookup_unregister(self):token = issue_token()ctx = BatchContext(- workflow_id="wf", node_id="n",+ workflow_id="wf",+ node_id="n",workspace_dir=Path("."),)assert lookup_batch(token) is None@@ -80,6 +82,7 @@ class TestTokenRegistry:# ASGI auth middleware# ---------------------------------------------------------------------------+class TestAuthMiddleware:def setup_method(self):_reset_for_tests()@@ -120,9 +123,14 @@ class TestAuthMiddleware:async def test_expired_token_returns_401(self):"""Token registered then unregistered behaves as unknown."""token = issue_token()- register_batch(token, BatchContext(- workflow_id="wf", node_id="n", workspace_dir=Path("."),- ))+ register_batch(+ token,+ BatchContext(+ workflow_id="wf",+ node_id="n",+ workspace_dir=Path("."),+ ),+ )unregister_batch(token)app = get_mcp_app()async with AsyncClient(transport=ASGITransport(app=app), base_url="http://t") as c:@@ -138,6 +146,7 @@ class TestAuthMiddleware:# Lockfile format# ---------------------------------------------------------------------------+class TestLockfile:def test_claude_lockfile_path_pid_lock(self, tmp_path):path = lockfile_path(@@ -182,8 +191,11 @@ class TestLockfile:def test_default_url_constructed(self, tmp_path):path = write_ide_lockfile(ide_lockfile_dir=tmp_path,- pid=1, port=3010, token="t",- workspace_dir=tmp_path, ide_name="claude",+ pid=1,+ port=3010,+ token="t",+ workspace_dir=tmp_path,+ ide_name="claude",)payload = json.loads(path.read_text(encoding="utf-8"))# FastMCP serves at `/mcp` of the sub-app, mounted at `/mcp/ide`.@@ -200,6 +212,7 @@ class TestLockfile:# system idle process on Windows and the swapper on POSIX, so# `psutil.pid_exists(0)` returns True everywhere — DON'T use 0.import psutil+dead_pid = 99_999_999while psutil.pid_exists(dead_pid):dead_pid += 1@@ -207,13 +220,21 @@ class TestLockfile:pytest.skip("could not find a dead PID")write_ide_lockfile(- ide_lockfile_dir=tmp_path, pid=dead_pid, port=3010, token="t",- workspace_dir=tmp_path, ide_name="claude",+ ide_lockfile_dir=tmp_path,+ pid=dead_pid,+ port=3010,+ token="t",+ workspace_dir=tmp_path,+ ide_name="claude",)# Write one with the live PIDlive_path = write_ide_lockfile(- ide_lockfile_dir=tmp_path, pid=os.getpid(), port=3010, token="t",- workspace_dir=tmp_path, ide_name="claude",+ ide_lockfile_dir=tmp_path,+ pid=os.getpid(),+ port=3010,+ token="t",+ workspace_dir=tmp_path,+ ide_name="claude",)before = list_active_lockfiles(tmp_path)@@ -242,6 +263,7 @@ class TestLockfile:# JSON-RPC.# ---------------------------------------------------------------------------+class TestMachinaOsToolBridge:def setup_method(self):_reset_for_tests()@@ -250,12 +272,17 @@ class TestMachinaOsToolBridge:@staticmethoddef _ctx(node_type: str, label: str) -> BatchContext:return BatchContext(- workflow_id="wf_test", node_id="claude_code_agent_1",+ workflow_id="wf_test",+ node_id="claude_code_agent_1",workspace_dir=Path("."),- connected_tools=[{- "node_id": f"{node_type}_1", "node_type": node_type,- "label": label, "parameters": {},- }],+ connected_tools=[+ {+ "node_id": f"{node_type}_1",+ "node_type": node_type,+ "label": label,+ "parameters": {},+ }+ ],)@pytest.mark.asyncio@@ -264,8 +291,10 @@ class TestMachinaOsToolBridge:claude sees ``mcp__machinaos__<node_type>`` on first``tools/list``."""from services.cli_agent.mcp_server import get_mcp_app+get_mcp_app() # ensure FastMCP singleton builtfrom services.cli_agent.mcp_server import _mcp_singleton as mcp+assert mcp is not Nonectx = self._ctx("calculatorTool", "Calculator")@@ -278,9 +307,7 @@ class TestMachinaOsToolBridge:calc = next(t for t in tools if t.name == "calculatorTool")# FastMCP infers the inputSchema from the typed `params` arg# (Pydantic-v2 → JSON Schema 2020-12 wire format).- assert {"operation", "a", "b"}.issubset(- calc.inputSchema["properties"].keys()- )+ assert {"operation", "a", "b"}.issubset(calc.inputSchema["properties"].keys())finally:unregister_batch(token)@@ -294,8 +321,10 @@ class TestMachinaOsToolBridge:``services.handlers.tools.execute_tool`` and returns theplugin's result envelope."""from services.cli_agent.mcp_server import (- _current_batch, get_mcp_app,+ _current_batch,+ get_mcp_app,)+get_mcp_app()from services.cli_agent.mcp_server import _mcp_singleton as mcp@@ -324,18 +353,24 @@ class TestMachinaOsToolBridge:wired it) but the calling batch didn't, the per-handler``_require_batch`` check returns 403."""from services.cli_agent.mcp_server import _current_batch, get_mcp_app+get_mcp_app()from services.cli_agent.mcp_server import _mcp_singleton as mcp# Batch A wires both tools — registers them globally.token_a = issue_token()- register_batch(token_a, BatchContext(- workflow_id="wf_a", node_id="cc_a", workspace_dir=Path("."),- connected_tools=[- {"node_id": "c1", "node_type": "calculatorTool", "label": "C", "parameters": {}},- {"node_id": "h1", "node_type": "httpRequest", "label": "H", "parameters": {}},- ],- ))+ register_batch(+ token_a,+ BatchContext(+ workflow_id="wf_a",+ node_id="cc_a",+ workspace_dir=Path("."),+ connected_tools=[+ {"node_id": "c1", "node_type": "calculatorTool", "label": "C", "parameters": {}},+ {"node_id": "h1", "node_type": "httpRequest", "label": "H", "parameters": {}},+ ],+ ),+ )# Batch B wires only one. Even though `httpRequest` is exposed# globally (refcount=1), batch B's ctx forbids it.ctx_b = self._ctx("calculatorTool", "C")@@ -344,7 +379,8 @@ class TestMachinaOsToolBridge:reset = _current_batch.set(ctx_b)try:out = await mcp.call_tool(- "httpRequest", {"method": "GET", "url": "x"},+ "httpRequest",+ {"method": "GET", "url": "x"},)finally:_current_batch.reset(reset)@@ -359,6 +395,7 @@ class TestMachinaOsToolBridge:@pytest.mark.asyncioasync def test_currentTimeTool_real(self):from services.cli_agent.mcp_server import _current_batch, get_mcp_app+get_mcp_app()from services.cli_agent.mcp_server import _mcp_singleton as mcp@@ -380,6 +417,7 @@ class TestMachinaOsToolBridge:@pytest.mark.asyncioasync def test_duckduckgoSearch_real(self):from services.cli_agent.mcp_server import _current_batch, get_mcp_app+get_mcp_app()from services.cli_agent.mcp_server import _mcp_singleton as mcp@@ -407,6 +445,7 @@ class TestMachinaOsToolBridge:@pytest.mark.asyncioasync def test_httpRequest_real(self):from services.cli_agent.mcp_server import _current_batch, get_mcp_app+get_mcp_app()from services.cli_agent.mcp_server import _mcp_singleton as mcpdiff --git a/server/tests/services/cli_agent/test_providers.py b/server/tests/services/cli_agent/test_providers.pyindex dda3b242..9bbfa67b 100644--- a/server/tests/services/cli_agent/test_providers.py+++ b/server/tests/services/cli_agent/test_providers.py@@ -34,6 +34,7 @@ from services.cli_agent.protocol import AICliProvider, CanonicalUsage# Factory contract# ---------------------------------------------------------------------------+class TestFactory:def test_claude_creates_provider(self):p = create_cli_provider("claude")@@ -64,6 +65,7 @@ class TestFactory:# Claude provider# ---------------------------------------------------------------------------+@pytest.fixturedef claude_provider():return create_cli_provider("claude")@@ -130,13 +132,18 @@ class TestClaudeArgv:allowlist = argv[allowed_idx + 1]entries = [e.strip() for e in allowlist.split(",")]builtins = {- "Read", "Edit", "Bash", "Glob", "Grep", "Write",- "Skill", "WebSearch", "WebFetch",+ "Read",+ "Edit",+ "Bash",+ "Glob",+ "Grep",+ "Write",+ "Skill",+ "WebSearch",+ "WebFetch",}for entry in entries:- assert entry not in builtins, (- f"claude built-in {entry!r} leaked into default allowlist"- )+ assert entry not in builtins, f"claude built-in {entry!r} leaked into default allowlist"# MachinaOs MCP infrastructure must still be present so the# agent can read the workspace + invoke connected skills.assert "mcp__machinaos__getWorkspaceFiles" in entries@@ -164,9 +171,7 @@ class TestClaudeArgv:# No skills wired → Skill stays out.argv_no_skills = claude_provider.interactive_argv(task, defaults={})allowed_idx = argv_no_skills.index("--allowedTools")- entries_no_skills = [- e.strip() for e in argv_no_skills[allowed_idx + 1].split(",")- ]+ entries_no_skills = [e.strip() for e in argv_no_skills[allowed_idx + 1].split(",")]assert "Skill" not in entries_no_skills# Skills wired → Skill enters the allowlist.@@ -176,16 +181,20 @@ class TestClaudeArgv:connected_skill_names=["humanify-skill", "memory-skill"],)allowed_idx = argv_with_skills.index("--allowedTools")- entries_with_skills = [- e.strip() for e in argv_with_skills[allowed_idx + 1].split(",")- ]+ entries_with_skills = [e.strip() for e in argv_with_skills[allowed_idx + 1].split(",")]assert "Skill" in entries_with_skills# Other built-ins still stay out — only Skill is conditionally# enabled. The rest (Read, Edit, Bash, etc.) are never# auto-added by the allowlist builder.for forbidden in (- "Read", "Edit", "Bash", "Glob", "Grep", "Write",- "WebSearch", "WebFetch",+ "Read",+ "Edit",+ "Bash",+ "Glob",+ "Grep",+ "Write",+ "WebSearch",+ "WebFetch",):assert forbidden not in entries_with_skills@@ -257,10 +266,14 @@ class TestClaudeArgv:same argv shape: no ``--`` separator, no positional prompt."""task = ClaudeTaskSpec(prompt="will-be-piped-via-stdin")argv_true = claude_provider.interactive_argv(- task, defaults={}, include_prompt=True,+ task,+ defaults={},+ include_prompt=True,)argv_false = claude_provider.interactive_argv(- task, defaults={}, include_prompt=False,+ task,+ defaults={},+ include_prompt=False,)for argv in (argv_true, argv_false):assert "--" not in argv@@ -369,7 +382,9 @@ class TestClaudeEventToSessionResult:def test_failure_on_non_zero_exit(self, claude_provider, fixture_events):result = claude_provider.event_to_session_result(- fixture_events, "exploded", 1,+ fixture_events,+ "exploded",+ 1,)assert result["success"] is Falseassert "exploded" in (result["error"] or "")@@ -386,24 +401,37 @@ class TestClaudeEventToSessionResult:class TestClaudeAuthDetection:def test_logged_out_marker(self, claude_provider):- assert claude_provider.detect_auth_error(- "Please run 'claude login' first.", 1,- ) is True+ assert (+ claude_provider.detect_auth_error(+ "Please run 'claude login' first.",+ 1,+ )+ is True+ )def test_clean_run_not_auth_error(self, claude_provider):assert claude_provider.detect_auth_error("", 0) is Falsedef test_unrelated_stderr_not_auth_error(self, claude_provider):- assert claude_provider.detect_auth_error(- "git: pathspec 'x' did not match any files\n", 1,- ) is False+ assert (+ claude_provider.detect_auth_error(+ "git: pathspec 'x' did not match any files\n",+ 1,+ )+ is False+ )class TestClaudeSupports:def test_supports_full_feature_set(self, claude_provider):for feature in (- "max_budget", "max_turns", "session_id", "resume",- "mcp_runtime", "json_cost", "ide_lockfile",+ "max_budget",+ "max_turns",+ "session_id",+ "resume",+ "mcp_runtime",+ "json_cost",+ "ide_lockfile",):assert claude_provider.supports(feature), feature@@ -415,6 +443,7 @@ class TestClaudeSupports:# Codex provider# ---------------------------------------------------------------------------+@pytest.fixturedef codex_provider():return create_cli_provider("codex")@@ -492,9 +521,13 @@ class TestCodexEventReconstruction:class TestCodexAuthDetection:def test_openai_api_key_missing(self, codex_provider):- assert codex_provider.detect_auth_error(- "Error: OPENAI_API_KEY not set.\n", 1,- ) is True+ assert (+ codex_provider.detect_auth_error(+ "Error: OPENAI_API_KEY not set.\n",+ 1,+ )+ is True+ )def test_401_marker(self, codex_provider):assert codex_provider.detect_auth_error("HTTP 401 Unauthorized\n", 1) is True@@ -504,7 +537,11 @@ class TestCodexSupports:def test_supports_only_sandbox(self, codex_provider):assert codex_provider.supports("sandbox") is Truefor feature in (- "max_budget", "max_turns", "session_id", "resume",- "json_cost", "ide_lockfile",+ "max_budget",+ "max_turns",+ "session_id",+ "resume",+ "json_cost",+ "ide_lockfile",):assert codex_provider.supports(feature) is False, featurediff --git a/server/tests/services/cli_agent/test_service.py b/server/tests/services/cli_agent/test_service.pyindex 1386e596..ff0ceee3 100644--- a/server/tests/services/cli_agent/test_service.py+++ b/server/tests/services/cli_agent/test_service.py@@ -135,6 +135,7 @@ async def test_resolver_walks_upward_to_find_git():@pytest.mark.asyncioasync def test_resolver_returns_none_when_override_not_git():import tempfile+with tempfile.TemporaryDirectory() as tmp:root = await AICliService._resolve_repo_root(workspace_dir=Path(tmp), # ignored when override is set@@ -196,11 +197,13 @@ async def test_run_batch_emits_diagnostic_logs_when_workspace_not_git(monkeypatc# BoundLogger that has no `reset_mock`. Locally patching makes the test# robust to import-order pollution.from services.cli_agent import service as svc_mod+svc_logger = MagicMock()monkeypatch.setattr(svc_mod, "logger", svc_logger)svc = get_ai_cli_service() # DI singleton — same accessor production usesimport tempfile+with tempfile.TemporaryDirectory() as tmp:result = await svc.run_batch("claude",@@ -211,8 +214,7 @@ async def test_run_batch_emits_diagnostic_logs_when_workspace_not_git(monkeypatcbroadcaster=None,repo_root=Path(tmp),connected_tools=[- {"node_id": "ddg_1", "node_type": "duckduckgoSearch",- "label": "DDG", "parameters": {}},+ {"node_id": "ddg_1", "node_type": "duckduckgoSearch", "label": "DDG", "parameters": {}},],)@@ -254,9 +256,11 @@ async def test_run_batch_registers_mcp_batch_on_happy_path(monkeypatch):async def _fake_wait(self, timeout): # noqa: ANN001, ARG002return SessionResult(- task_id=self.task_id, provider=self._provider.name,+ task_id=self.task_id,+ provider=self._provider.name,prompt=getattr(self._task, "prompt", ""),- success=True, response="stub",+ success=True,+ response="stub",)async def _fake_cleanup(self): # noqa: ANN001@@ -277,8 +281,7 @@ async def test_run_batch_registers_mcp_batch_on_happy_path(monkeypatch):broadcaster=None,repo_root=None, # let the resolver find the parent .gitconnected_tools=[- {"node_id": "ddg_1", "node_type": "duckduckgoSearch",- "label": "DDG", "parameters": {}},+ {"node_id": "ddg_1", "node_type": "duckduckgoSearch", "label": "DDG", "parameters": {}},],connected_skill_names=["duckduckgo-search-skill"],)diff --git a/server/tests/services/memory/test_jsonl.py b/server/tests/services/memory/test_jsonl.pyindex 2bd91431..0dd255b1 100644--- a/server/tests/services/memory/test_jsonl.py+++ b/server/tests/services/memory/test_jsonl.py@@ -32,10 +32,7 @@ def test_parse_jsonl_empty_input_returns_empty_list():def test_parse_jsonl_basic_user_assistant_pair():- text = (- '{"role": "user", "content": "hi"}\n'- '{"role": "assistant", "content": "hello"}\n'- )+ text = '{"role": "user", "content": "hi"}\n' '{"role": "assistant", "content": "hello"}\n'msgs = parse_jsonl(text)assert len(msgs) == 2assert isinstance(msgs[0], HumanMessage) and msgs[0].content == "hi"@@ -43,11 +40,7 @@ def test_parse_jsonl_basic_user_assistant_pair():def test_parse_jsonl_skips_unparseable_lines_forward_compat():- text = (- '{"role": "user", "content": "ok"}\n'- "this is not json\n"- '{"role": "assistant", "content": "still ok"}\n'- )+ text = '{"role": "user", "content": "ok"}\n' "this is not json\n" '{"role": "assistant", "content": "still ok"}\n'msgs = parse_jsonl(text)assert [m.content for m in msgs] == ["ok", "still ok"]@@ -63,27 +56,37 @@ def test_parse_jsonl_skips_unknown_roles():def test_parse_jsonl_collapses_content_blocks_to_text():- text = json.dumps({- "role": "assistant",- "content": [- {"type": "text", "text": "Got it"},- {"type": "tool_use", "id": "tu_1", "name": "search", "input": {}},- {"type": "text", "text": "blue."},- ],- }) + "\n"+ text = (+ json.dumps(+ {+ "role": "assistant",+ "content": [+ {"type": "text", "text": "Got it"},+ {"type": "tool_use", "id": "tu_1", "name": "search", "input": {}},+ {"type": "text", "text": "blue."},+ ],+ }+ )+ + "\n"+ )msgs = parse_jsonl(text)assert len(msgs) == 1assert msgs[0].content == "Got it blue." # text blocks joined; tool_use droppeddef test_parse_jsonl_metadata_keys_are_ignored():- text = json.dumps({- "role": "user",- "content": "hi",- "timestamp": "2026-05-10T00:00:00Z",- "session_id": "abc-123",- "model": "claude",- }) + "\n"+ text = (+ json.dumps(+ {+ "role": "user",+ "content": "hi",+ "timestamp": "2026-05-10T00:00:00Z",+ "session_id": "abc-123",+ "model": "claude",+ }+ )+ + "\n"+ )msgs = parse_jsonl(text)assert len(msgs) == 1 and msgs[0].content == "hi"@@ -117,7 +120,9 @@ def test_append_message_normalises_missing_trailing_newline():def test_append_message_metadata_round_trips_via_parse_jsonl():text = append_message(- "", "assistant", "blue.",+ "",+ "assistant",+ "blue.",timestamp="2026-05-10T12:34:56+00:00",session_id="abc-123",model="claude",diff --git a/server/tests/services/test_events.py b/server/tests/services/test_events.pyindex f1f08808..c2f6bc42 100644--- a/server/tests/services/test_events.py+++ b/server/tests/services/test_events.py@@ -28,6 +28,7 @@ def _run(coro):class TestWorkflowEvent:def test_required_fields(self):from services.events import WorkflowEvent+ev = WorkflowEvent(source="stripe://acct_1", type="stripe.charge.succeeded")assert ev.specversion == "1.0"assert ev.id # uuid default@@ -35,8 +36,11 @@ class TestWorkflowEvent:def test_round_trip_json(self):from services.events import WorkflowEvent+ev = WorkflowEvent(- source="stripe://acct_1", type="stripe.charge.succeeded", data={"amount": 1000},+ source="stripe://acct_1",+ type="stripe.charge.succeeded",+ data={"amount": 1000},)restored = WorkflowEvent.model_validate(json.loads(ev.model_dump_json()))assert restored.type == ev.type@@ -45,6 +49,7 @@ class TestWorkflowEvent:def test_matches_type_glob(self):from services.events import WorkflowEvent+ev = WorkflowEvent(source="stripe://x", type="stripe.charge.succeeded")assert ev.matches_type("all") is Trueassert ev.matches_type("") is True@@ -55,6 +60,7 @@ class TestWorkflowEvent:def test_from_legacy(self):from services.events import WorkflowEvent+ev = WorkflowEvent.from_legacy("whatsapp_message_received", {"text": "hi"})assert ev.type == "whatsapp_message_received"assert ev.data == {"text": "hi"}@@ -77,11 +83,13 @@ class TestStripeVerifier:def test_valid_signature_passes(self):from services.events import StripeVerifier+body = b'{"id":"evt_1"}'StripeVerifier.verify(self._sign(body), body, self.SECRET)def test_tampered_body_rejected(self):from services.events import StripeVerifier+body = b'{"id":"evt_1"}'headers = self._sign(body)with pytest.raises(ValueError):@@ -89,18 +97,21 @@ class TestStripeVerifier:def test_missing_header_rejected(self):from services.events import StripeVerifier+with pytest.raises(ValueError, match="missing"):- StripeVerifier.verify({}, b'{}', self.SECRET)+ StripeVerifier.verify({}, b"{}", self.SECRET)def test_malformed_header_rejected(self):from services.events import StripeVerifier+with pytest.raises(ValueError):- StripeVerifier.verify({"Stripe-Signature": "garbage"}, b'{}', self.SECRET)+ StripeVerifier.verify({"Stripe-Signature": "garbage"}, b"{}", self.SECRET)class TestGitHubVerifier:def test_round_trip(self):from services.events import GitHubVerifier+secret = "shh"body = b'{"action":"opened"}'sig = "sha256=" + hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()@@ -108,13 +119,15 @@ class TestGitHubVerifier:def test_tampered_rejected(self):from services.events import GitHubVerifier+with pytest.raises(ValueError):- GitHubVerifier.verify({"X-Hub-Signature-256": "sha256=deadbeef"}, b'{}', "shh")+ GitHubVerifier.verify({"X-Hub-Signature-256": "sha256=deadbeef"}, b"{}", "shh")class TestStandardWebhooksVerifier:def test_round_trip(self):from services.events import StandardWebhooksVerifier+secret_raw = b"super-secret-key-bytes"secret = "whsec_" + base64.b64encode(secret_raw).decode()body = b'{"foo":"bar"}'@@ -131,16 +144,19 @@ class TestStandardWebhooksVerifier:def test_tampered_rejected(self):from services.events import StandardWebhooksVerifier+with pytest.raises(ValueError):StandardWebhooksVerifier.verify({"webhook-id": "1", "webhook-timestamp": "1", "webhook-signature": "v1,bad"},- b'{}', "whsec_AAAA",+ b"{}",+ "whsec_AAAA",)class TestHmacVerifier:def test_round_trip(self):from services.events import HmacVerifier+secret = "shh"body = b'{"x":1}'sig = hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()@@ -240,6 +256,7 @@ class TestWebhookSourceHandle:def test_tampered_signature_raises_400(self):from fastapi import HTTPException+src = self._build_source(secret_value="whsec_test")body = b'{"event":"payload"}'req = self._signed_request(body, "whsec_other") # signed with different secret@@ -285,8 +302,10 @@ class TestDaemonEventSource:return Noneasync def go():- with patch("services.events.daemon.shutil.which", return_value="/usr/bin/echo"), \- patch("services.events.daemon.get_process_service") as get_ps:+ with (+ patch("services.events.daemon.shutil.which", return_value="/usr/bin/echo"),+ patch("services.events.daemon.get_process_service") as get_ps,+ ):ps = get_ps.return_valueasync def fake_start(**kwargs):diff --git a/server/tests/services/test_identifiers.py b/server/tests/services/test_identifiers.pyindex ae88e21d..51c5a425 100644--- a/server/tests/services/test_identifiers.py+++ b/server/tests/services/test_identifiers.py@@ -56,30 +56,30 @@ def test_accepts_valid_identifiers(value: str) -> None:@pytest.mark.parametrize("value",[- "", # empty- "1leading_digit", # digit prefix- "with space", # whitespace- "with-hyphen", # hyphen (not a Python identifier char)- "with.dot", # dot (path separator on URLs)- "with/slash", # path separator- "with\\backslash", # Windows separator- "..", # parent-dir token- "../etc/passwd", # classic traversal- "..\\windows\\system32", # Windows traversal- "foo\x00bar", # null byte truncation- "foo\nbar", # newline / CRLF injection+ "", # empty+ "1leading_digit", # digit prefix+ "with space", # whitespace+ "with-hyphen", # hyphen (not a Python identifier char)+ "with.dot", # dot (path separator on URLs)+ "with/slash", # path separator+ "with\\backslash", # Windows separator+ "..", # parent-dir token+ "../etc/passwd", # classic traversal+ "..\\windows\\system32", # Windows traversal+ "foo\x00bar", # null byte truncation+ "foo\nbar", # newline / CRLF injection"foo\rbar",- "%2e%2e%2fetc", # URL-encoded traversal+ "%2e%2e%2fetc", # URL-encoded traversal" leading_space","trailing_space ","tab\there",- "foo;bar", # command separator- "foo|bar", # pipe- "$VAR", # shell expansion+ "foo;bar", # command separator+ "foo|bar", # pipe+ "$VAR", # shell expansion"${HOME}",- "foo'bar", # quote- "foo\"bar",- "foo`bar", # backtick (command substitution)+ "foo'bar", # quote+ 'foo"bar',+ "foo`bar", # backtick (command substitution)],)def test_rejects_traversal_and_injection_vectors(value: str) -> None:diff --git a/server/tests/services/test_process_lifecycle.py b/server/tests/services/test_process_lifecycle.pyindex 86ca2103..7561722f 100644--- a/server/tests/services/test_process_lifecycle.py+++ b/server/tests/services/test_process_lifecycle.py@@ -94,11 +94,14 @@ async def test_pre_spawn_runs_before_binary_existence_check(tmp_path):fake_proc.returncode = None# ``_do_stop`` tree-kills the pid via psutil; bypass that for the# fake pid so test teardown doesn't reach the real OS process table.- with patch(- "services._supervisor.process.anyio.open_process",- new=AsyncMock(return_value=fake_proc),- ), patch(- "services._supervisor.util.kill_tree",+ with (+ patch(+ "services._supervisor.process.anyio.open_process",+ new=AsyncMock(return_value=fake_proc),+ ),+ patch(+ "services._supervisor.util.kill_tree",+ ),):await sub.start()diff --git a/server/tests/temporal/test_agent_workflow.py b/server/tests/temporal/test_agent_workflow.pyindex a4a30425..c7bf1599 100644--- a/server/tests/temporal/test_agent_workflow.py+++ b/server/tests/temporal/test_agent_workflow.py@@ -17,7 +17,6 @@ canary agent migration lands. This file locks the static contracts:from __future__ import annotations-class TestAgentWorkflowDefinition:"""``AgentWorkflow`` must be a valid Temporal workflow definitionso workers can register it."""@@ -37,10 +36,7 @@ class TestAgentWorkflowDefinition:from services.temporal.agent_workflow import AgentWorkflowdefn = getattr(AgentWorkflow, "__temporal_workflow_definition")- assert defn.sandboxed is False, (- "AgentWorkflow must be sandboxed=False so it can read "- "services.node_registry deterministically"- )+ assert defn.sandboxed is False, "AgentWorkflow must be sandboxed=False so it can read " "services.node_registry deterministically"class TestAgentActivities:@@ -74,9 +70,7 @@ class TestAgentActivities:from services.temporal.agent_activities import collect_agent_activitiesactivities = collect_agent_activities()- names = sorted(- getattr(a, "__temporal_activity_definition").name for a in activities- )+ names = sorted(getattr(a, "__temporal_activity_definition").name for a in activities)assert names == ["agent.broadcast_progress.v1","agent.compact_memory.v1",diff --git a/server/tests/temporal/test_dispatch.py b/server/tests/temporal/test_dispatch.pyindex 50143215..df37b14c 100644--- a/server/tests/temporal/test_dispatch.py+++ b/server/tests/temporal/test_dispatch.py@@ -99,6 +99,7 @@ class TestResolveActivityFlagOn:assert name.startswith("node.coding_agent.v")# Extract version; should match the class's declared version.from services.node_registry import get_node_class+cls = get_node_class("coding_agent")assert name == f"node.coding_agent.v{cls.version}"@@ -136,9 +137,7 @@ class TestAgentWorkflowDispatch:for t in ("coding_agent", "web_agent", "orchestrator_agent", "ai_employee"):with self._set_flags(per_type=True, agent_wf=True):dispatch = workflow_instance._resolve_dispatch(t)- assert dispatch["kind"] == "child_workflow", (- f"{t} should route to AgentWorkflow when F4.B is on"- )+ assert dispatch["kind"] == "child_workflow", f"{t} should route to AgentWorkflow when F4.B is on"def test_excluded_agents_stay_on_activity_path(self, workflow_instance):"""rlm_agent / claude_code_agent are NOT migrated (externalised@@ -147,9 +146,7 @@ class TestAgentWorkflowDispatch:for t in ("rlm_agent", "claude_code_agent"):with self._set_flags(per_type=True, agent_wf=True):dispatch = workflow_instance._resolve_dispatch(t)- assert dispatch["kind"] == "activity", (- f"{t} must NOT migrate to AgentWorkflow (externalised session)"- )+ assert dispatch["kind"] == "activity", f"{t} must NOT migrate to AgentWorkflow (externalised session)"assert dispatch["name"] == f"node.{t}.v1"def test_agent_workflow_flag_off_falls_back_to_activity(self, workflow_instance):@@ -164,9 +161,7 @@ class TestAgentWorkflowDispatch:for t in ("pythonExecutor", "calculatorTool", "openaiChatModel"):with self._set_flags(per_type=True, agent_wf=True):dispatch = workflow_instance._resolve_dispatch(t)- assert dispatch["kind"] == "activity", (- f"{t} is not an agent type; must NOT route to AgentWorkflow"- )+ assert dispatch["kind"] == "activity", f"{t} is not an agent type; must NOT route to AgentWorkflow"class TestPerNodeTypeIconResolution:@@ -176,18 +171,21 @@ class TestPerNodeTypeIconResolution:def test_whatsapp_send_resolves_per_node_icon(self):from nodes._visuals import get_plugin_icon_path+path = get_plugin_icon_path("whatsappSend")assert path is not Noneassert path.name == "icon_whatsappSend.svg"def test_whatsapp_receive_resolves_per_node_icon(self):from nodes._visuals import get_plugin_icon_path+path = get_plugin_icon_path("whatsappReceive")assert path is not Noneassert path.name == "icon_whatsappReceive.svg"def test_whatsapp_db_resolves_per_node_icon(self):from nodes._visuals import get_plugin_icon_path+path = get_plugin_icon_path("whatsappDb")assert path is not Noneassert path.name == "icon_whatsappDb.svg"@@ -197,6 +195,7 @@ class TestPerNodeTypeIconResolution:per-node icons aren't required when the brand mark is thesame for both."""from nodes._visuals import get_plugin_icon_path+path = get_plugin_icon_path("telegramSend")assert path is not Noneassert path.name == "icon.svg"diff --git a/server/tests/test_admin_handlers.py b/server/tests/test_admin_handlers.pyindex 4b24bb67..37df9f43 100644--- a/server/tests/test_admin_handlers.py+++ b/server/tests/test_admin_handlers.py@@ -53,10 +53,12 @@ class TestListCanaryListeners:wrapper = MagicMock()wrapper.client = Nonefrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)result = await handle_list_canary_listeners(- {"workflow_id": "wf-1"}, MagicMock(),+ {"workflow_id": "wf-1"},+ MagicMock(),)assert result["success"] is Trueassert result["listeners"] == []@@ -87,10 +89,12 @@ class TestListCanaryListeners:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)result = await handle_list_canary_listeners(- {"workflow_id": "wf-1"}, MagicMock(),+ {"workflow_id": "wf-1"},+ MagicMock(),)assert result["success"] is Trueassert result["count"] == 1@@ -118,10 +122,12 @@ class TestListCanaryListeners:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)result = await handle_list_canary_listeners(- {"workflow_id": "wf-1"}, MagicMock(),+ {"workflow_id": "wf-1"},+ MagicMock(),)assert result["success"] is Falseassert "Visibility unavailable" in result["error"]@@ -179,10 +185,12 @@ class TestListCanarySchedules:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)result = await handle_list_canary_schedules(- {"workflow_id": "wf-1"}, MagicMock(),+ {"workflow_id": "wf-1"},+ MagicMock(),)assert result["success"] is Trueassert result["count"] == 2@@ -242,10 +250,12 @@ class TestGetWorkflowFailureHistory:wrapper.client = Nonefrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)result = await handle_get_workflow_failure_history(- {"workflow_id": "wf-1"}, MagicMock(),+ {"workflow_id": "wf-1"},+ MagicMock(),)assert result["success"] is False@@ -295,10 +305,12 @@ class TestGetWorkflowFailureHistory:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)result = await handle_get_workflow_failure_history(- {"workflow_id": "wf-temporal-1"}, MagicMock(),+ {"workflow_id": "wf-temporal-1"},+ MagicMock(),)assert result["success"] is Trueassert result["count"] == 1@@ -337,14 +349,18 @@ class TestSearchAttributesDict:TypedSearchAttributes,)- typed = TypedSearchAttributes([- SearchAttributePair(- SearchAttributeKey.for_keyword("EventWorkflowId"), "wf-1",- ),- SearchAttributePair(- SearchAttributeKey.for_keyword("EventTriggerKind"), "cron",- ),- ])+ typed = TypedSearchAttributes(+ [+ SearchAttributePair(+ SearchAttributeKey.for_keyword("EventWorkflowId"),+ "wf-1",+ ),+ SearchAttributePair(+ SearchAttributeKey.for_keyword("EventTriggerKind"),+ "cron",+ ),+ ]+ )view = _search_attributes_dict(typed)assert view == {"EventWorkflowId": "wf-1", "EventTriggerKind": "cron"}diff --git a/server/tests/test_auto_skill.py b/server/tests/test_auto_skill.pyindex e34023b4..6e765b88 100644--- a/server/tests/test_auto_skill.py+++ b/server/tests/test_auto_skill.py@@ -97,8 +97,10 @@ def test_non_agent_target_is_noop():def test_unknown_target_node_class_is_noop():"""get_node_class returns None when the type isn't registered -- treat as non-agent."""- with patch("services.auto_skill.get_skill", return_value="http-request-skill"), \- patch("services.auto_skill.get_node_class", return_value=None):+ with (+ patch("services.auto_skill.get_skill", return_value="http-request-skill"),+ patch("services.auto_skill.get_node_class", return_value=None),+ ):result = _evaluate()assert result == {"operations": []}diff --git a/server/tests/test_canary_registry.py b/server/tests/test_canary_registry.pyindex 9b7a266c..b6ac61b4 100644--- a/server/tests/test_canary_registry.py+++ b/server/tests/test_canary_registry.py@@ -79,9 +79,7 @@ class TestRegistryContract:producer envelope shape without coordinating with the listener."""fresh_registry.register_canary_trigger_type("chatTrigger", _CE_CHAT)with pytest.raises(ValueError, match="diverging"):- fresh_registry.register_canary_trigger_type(- "chatTrigger", "com.machinaos.chat.message.changed"- )+ fresh_registry.register_canary_trigger_type("chatTrigger", "com.machinaos.chat.message.changed")def test_multiple_types_coexist(self, fresh_registry):for t, ce in (@@ -90,9 +88,13 @@ class TestRegistryContract:("taskTrigger", _CE_TASK),):fresh_registry.register_canary_trigger_type(t, ce)- assert fresh_registry.canary_trigger_types() == frozenset({- "webhookTrigger", "chatTrigger", "taskTrigger",- })+ assert fresh_registry.canary_trigger_types() == frozenset(+ {+ "webhookTrigger",+ "chatTrigger",+ "taskTrigger",+ }+ )assert fresh_registry.cloudevent_type_for("taskTrigger") == _CE_TASKdef test_snapshot_is_immutable(self, fresh_registry):@@ -109,7 +111,7 @@ class TestRegistryContract:with pytest.raises(TypeError):fresh_registry.register_canary_trigger_type(None, _CE_WEBHOOK) # type: ignore[arg-type]with pytest.raises(TypeError):- fresh_registry.register_canary_trigger_type(123, _CE_WEBHOOK) # type: ignore[arg-type]+ fresh_registry.register_canary_trigger_type(123, _CE_WEBHOOK) # type: ignore[arg-type]def test_rejects_empty_node_type(self, fresh_registry):with pytest.raises(TypeError):@@ -186,14 +188,15 @@ class TestPluginSelfRegistration:rather than masking the import failure."""- @pytest.mark.parametrize("plugin_module,expected_type,expected_cloudevent_type", [- ("nodes.trigger.webhook_trigger", "webhookTrigger", "com.machinaos.webhook.received"),- ("nodes.trigger.chat_trigger", "chatTrigger", "com.machinaos.chat.message.received"),- ("nodes.trigger.task_trigger", "taskTrigger", "com.machinaos.agent.task.completed"),- ])- def test_plugin_import_registers_its_type(- self, plugin_module, expected_type, expected_cloudevent_type- ):+ @pytest.mark.parametrize(+ "plugin_module,expected_type,expected_cloudevent_type",+ [+ ("nodes.trigger.webhook_trigger", "webhookTrigger", "com.machinaos.webhook.received"),+ ("nodes.trigger.chat_trigger", "chatTrigger", "com.machinaos.chat.message.received"),+ ("nodes.trigger.task_trigger", "taskTrigger", "com.machinaos.agent.task.completed"),+ ],+ )+ def test_plugin_import_registers_its_type(self, plugin_module, expected_type, expected_cloudevent_type):from services.deployment import canary_registrytry:@@ -244,8 +247,7 @@ class TestCloudEventTypeMatchesSearchAttribute:for node_type in canary_registry.canary_trigger_types():ce_type = canary_registry.cloudevent_type_for(node_type)assert ce_type is not None, (- f"canary_trigger_types includes {node_type!r} but "- f"cloudevent_type_for() returned None — registry corrupted."+ f"canary_trigger_types includes {node_type!r} but " f"cloudevent_type_for() returned None — registry corrupted.")assert ce_type.startswith("com.machinaos."), (f"{node_type!r} registered with cloudevent_type={ce_type!r}; "@@ -266,8 +268,7 @@ class TestCloudEventTypeMatchesSearchAttribute:# The query template MUST format the CloudEvents type into the# EventType filter.assert "EventType=" in dispatch_mod._RUNNING_CONSUMERS_QUERY, (- "dispatch.emit's _RUNNING_CONSUMERS_QUERY no longer filters by "- "EventType — listener-side SA registration relies on this key."+ "dispatch.emit's _RUNNING_CONSUMERS_QUERY no longer filters by " "EventType — listener-side SA registration relies on this key.")assert "event.type" in src or "event_type=event.type" in src, ("dispatch.emit no longer substitutes event.type into the "@@ -298,8 +299,7 @@ class TestCloudEventTypeMatchesSearchAttribute:src,)assert pair_pattern is not None, (- "Couldn't find the SearchAttributePair(event_type_key, ...) "- "construction. Check _start_canary_listener for the SA wiring."+ "Couldn't find the SearchAttributePair(event_type_key, ...) " "construction. Check _start_canary_listener for the SA wiring.")sa_value_name = pair_pattern.group(1)assert sa_value_name == "cloudevent_type", (diff --git a/server/tests/test_chat_trigger_canary_producer.py b/server/tests/test_chat_trigger_canary_producer.pyindex 322ac109..9deb7415 100644--- a/server/tests/test_chat_trigger_canary_producer.py+++ b/server/tests/test_chat_trigger_canary_producer.py@@ -45,8 +45,7 @@ class TestChatTriggerProducerCanaryEmit:from nodes.trigger.chat_trigger._events import dispatch_chat_message_receivedassert inspect.iscoroutinefunction(dispatch_chat_message_received), (- "dispatch_chat_message_received must be async — it awaits "- "services.events.dispatch.emit."+ "dispatch_chat_message_received must be async — it awaits " "services.events.dispatch.emit.")def test_dispatcher_uses_canary_path_only(self):@@ -84,11 +83,13 @@ class TestChatTriggerProducerCanaryEmit:monkeypatch.setattr(dispatch_mod, "emit", fake_emit)- result = await _events.dispatch_chat_message_received({- "message": "hello",- "session_id": "sess-1",- "timestamp": "2026-05-14T00:00:00",- })+ result = await _events.dispatch_chat_message_received(+ {+ "message": "hello",+ "session_id": "sess-1",+ "timestamp": "2026-05-14T00:00:00",+ }+ )# No return value — canary-only emit doesn't carry a waiter count.assert result is Nonediff --git a/server/tests/test_cloudevents_node_parameters.py b/server/tests/test_cloudevents_node_parameters.pyindex 05c49240..2564666f 100644--- a/server/tests/test_cloudevents_node_parameters.py+++ b/server/tests/test_cloudevents_node_parameters.py@@ -25,7 +25,6 @@ from __future__ import annotationsimport inspect-class TestFactoryShape:def test_factory_exists_and_returns_workflow_event(self):from services.events import WorkflowEvent@@ -74,16 +73,12 @@ class TestBroadcasterWrapper:broadcasts when this method is rewritten."""from services.status_broadcaster import StatusBroadcaster- src = inspect.getsource(- StatusBroadcaster.broadcast_node_parameters_updated- )+ src = inspect.getsource(StatusBroadcaster.broadcast_node_parameters_updated)assert "WorkflowEvent" in src, (- "broadcast_node_parameters_updated must build a "- "WorkflowEvent envelope; raw-dict broadcasts violate RFC §6.4."+ "broadcast_node_parameters_updated must build a " "WorkflowEvent envelope; raw-dict broadcasts violate RFC §6.4.")assert "node_parameters_updated" in src, (- "Wire-format key node_parameters_updated must stay in "- "the broadcast payload (FE back-compat)."+ "Wire-format key node_parameters_updated must stay in " "the broadcast payload (FE back-compat).")diff --git a/server/tests/test_credential_icon.py b/server/tests/test_credential_icon.pyindex 166fe808..f89f9142 100644--- a/server/tests/test_credential_icon.py+++ b/server/tests/test_credential_icon.py@@ -100,8 +100,7 @@ class TestEndpointResolution:precondition without depending on exact registered count(which drifts when new credentials land)."""assert len(CREDENTIAL_REGISTRY) > 0, (- "CREDENTIAL_REGISTRY should be populated by nodes import "- "(triggers credential discovery via __init_subclass__)"+ "CREDENTIAL_REGISTRY should be populated by nodes import " "(triggers credential discovery via __init_subclass__)")def test_well_known_providers_registered(self):diff --git a/server/tests/test_cron_canary.py b/server/tests/test_cron_canary.pyindex e206c51b..f80d556c 100644--- a/server/tests/test_cron_canary.py+++ b/server/tests/test_cron_canary.py@@ -96,7 +96,8 @@ class TestPluginRegistryContract:fresh_plugin_registry.register_temporal_plugin(p1)fresh_plugin_registry.register_temporal_plugin(p2)assert {p.name() for p in fresh_plugin_registry.temporal_plugins()} == {- "plugin-1", "plugin-2",+ "plugin-1",+ "plugin-2",}@@ -117,7 +118,8 @@ class TestScheduleIdDerivation:from services.temporal.schedules import cron_schedule_idassert cron_schedule_id("wf-1", "cron-a") != cron_schedule_id(- "wf-1", "cron-b",+ "wf-1",+ "cron-b",)@@ -237,7 +239,8 @@ class TestDeleteCronSchedulesForDeployment:assert count == 2assert sorted(deleted_ids) == [- "cron-schedule-wf-1-a", "cron-schedule-wf-1-b",+ "cron-schedule-wf-1-a",+ "cron-schedule-wf-1-b",]# Filter on both deployment workflow_id AND the cron kind tag.assert len(recorded_queries) == 1@@ -259,12 +262,16 @@ class TestDeleteCronSchedulesForDeployment:def fake_get_handle(sid):handle = MagicMock()if "bad" in sid:+async def boom():raise RuntimeError("simulated delete failure")+handle.delete = boomelse:+async def ok():return None+handle.delete = okreturn handle@@ -355,24 +362,27 @@ class TestDeploymentCronCanaryRouting:recorded: List[Dict[str, Any]] = []- async def fake_create(client, *, deployment_workflow_id, node_id,- cron_expression, timezone, listener_data, **kw):- recorded.append({- "deployment_workflow_id": deployment_workflow_id,- "node_id": node_id,- "cron_expression": cron_expression,- "timezone": timezone,- "listener_data": listener_data,- })+ async def fake_create(client, *, deployment_workflow_id, node_id, cron_expression, timezone, listener_data, **kw):+ recorded.append(+ {+ "deployment_workflow_id": deployment_workflow_id,+ "node_id": node_id,+ "cron_expression": cron_expression,+ "timezone": timezone,+ "listener_data": listener_data,+ }+ )return f"cron-schedule-{deployment_workflow_id}-{node_id}"from services.temporal import schedules+monkeypatch.setattr(schedules, "create_cron_schedule", fake_create)wrapper = MagicMock()wrapper.client = MagicMock()from core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)result = await mgr._start_canary_cron_schedule(@@ -409,6 +419,7 @@ class TestDeploymentCronCanaryRouting:wrapper.client = Nonefrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)result = await mgr._start_canary_cron_schedule(@@ -434,6 +445,7 @@ class TestDeploymentCronCanaryRouting:return 3from services.temporal import schedules+monkeypatch.setattr(schedules,"delete_cron_schedules_for_deployment",@@ -444,6 +456,7 @@ class TestDeploymentCronCanaryRouting:wrapper.client = MagicMock()from core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)count = await mgr._cancel_canary_cron_schedules("wf-1")@@ -458,6 +471,7 @@ class TestDeploymentCronCanaryRouting:wrapper.client = Nonefrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)assert await mgr._cancel_canary_cron_schedules("wf-1") == 0@@ -493,6 +507,5 @@ class TestCronPluginSelfRegisters:from services.deployment import canary_registryassert canary_registry.is_canary_trigger_type("cronScheduler"), (- "Importing nodes.scheduler.cron_scheduler should call "- "register_canary_trigger_type('cronScheduler')."+ "Importing nodes.scheduler.cron_scheduler should call " "register_canary_trigger_type('cronScheduler').")diff --git a/server/tests/test_deployment_canary_listener.py b/server/tests/test_deployment_canary_listener.pyindex 2d4dd350..e0c73243 100644--- a/server/tests/test_deployment_canary_listener.py+++ b/server/tests/test_deployment_canary_listener.py@@ -139,14 +139,13 @@ class TestCanaryScope:async def test_disabled_when_flag_off(self, monkeypatch, fresh_canary_registry):from services.deployment.manager import DeploymentManager- fresh_canary_registry.register_canary_trigger_type(- "webhookTrigger", "com.machinaos.webhook.received"- )+ fresh_canary_registry.register_canary_trigger_type("webhookTrigger", "com.machinaos.webhook.received")class _Off:event_framework_enabled = Falseimport core.config+monkeypatch.setattr(core.config, "Settings", lambda: _Off())result = await DeploymentManager._canary_listener_enabled_for("webhookTrigger")@@ -163,6 +162,7 @@ class TestCanaryScope:event_framework_enabled = Trueimport core.config+monkeypatch.setattr(core.config, "Settings", lambda: _On())result = await DeploymentManager._canary_listener_enabled_for("whatsappReceive")@@ -172,17 +172,14 @@ class TestCanaryScope:async def test_enabled_when_registered_and_flag_on(self, monkeypatch, fresh_canary_registry):from services.deployment.manager import DeploymentManager- fresh_canary_registry.register_canary_trigger_type(- "webhookTrigger", "com.machinaos.webhook.received"- )- fresh_canary_registry.register_canary_trigger_type(- "chatTrigger", "com.machinaos.chat.message.received"- )+ fresh_canary_registry.register_canary_trigger_type("webhookTrigger", "com.machinaos.webhook.received")+ fresh_canary_registry.register_canary_trigger_type("chatTrigger", "com.machinaos.chat.message.received")class _On:event_framework_enabled = Trueimport core.config+monkeypatch.setattr(core.config, "Settings", lambda: _On())assert await DeploymentManager._canary_listener_enabled_for("webhookTrigger") is True@@ -230,9 +227,7 @@ class TestStartCanaryListener:WorkflowIDConflictPolicy.USE_EXISTING + TypedSearchAttributes."""@pytest.mark.asyncio- async def test_starts_with_deterministic_id_and_use_existing_policy(- self, monkeypatch- ):+ async def test_starts_with_deterministic_id_and_use_existing_policy(self, monkeypatch):from temporalio.common import WorkflowIDConflictPolicymgr, _ = _build_manager_with_state(@@ -254,12 +249,11 @@ class TestStartCanaryListener:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)node = _node("wh-1", "webhookTrigger")- listener_id = await mgr._start_canary_listener(- node, "wf-abc", params={"path": "hook"}- )+ listener_id = await mgr._start_canary_listener(node, "wf-abc", params={"path": "hook"})assert listener_id == "trigger-listener-wf-abc-wh-1"assert len(recorded_start) == 1@@ -294,11 +288,10 @@ class TestStartCanaryListener:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)- await mgr._start_canary_listener(- _node("wh-1", "webhookTrigger"), "wf-xyz", params={}- )+ await mgr._start_canary_listener(_node("wh-1", "webhookTrigger"), "wf-xyz", params={})sa = recorded[0]["search_attributes"]assert isinstance(sa, TypedSearchAttributes)@@ -341,11 +334,10 @@ class TestStartCanaryListener:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)- listener_id = await mgr._start_canary_listener(- _node("ct-1", "chatTrigger"), "wf-chat", params={"session_id": "default"}- )+ listener_id = await mgr._start_canary_listener(_node("ct-1", "chatTrigger"), "wf-chat", params={"session_id": "default"})assert listener_id == "trigger-listener-wf-chat-ct-1"sa = recorded[0]["search_attributes"]@@ -359,19 +351,16 @@ class TestStartCanaryListener:async def test_returns_none_when_temporal_not_connected(self, monkeypatch):"""Falls through to legacy path; doesn't raise."""- mgr, _ = _build_manager_with_state(- "wf-1", nodes=[_node("wh-1", "webhookTrigger")], edges=[]- )+ mgr, _ = _build_manager_with_state("wf-1", nodes=[_node("wh-1", "webhookTrigger")], edges=[])wrapper = MagicMock()wrapper.client = Nonefrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)- result = await mgr._start_canary_listener(- _node("wh-1", "webhookTrigger"), "wf-1", params={}- )+ result = await mgr._start_canary_listener(_node("wh-1", "webhookTrigger"), "wf-1", params={})assert result is None@@ -385,7 +374,6 @@ class TestCancelCanaryListeners:@pytest.mark.asyncioasync def test_query_filters_by_workflow_id_and_listener_type(self, monkeypatch):-mgr, _ = _build_manager_with_state("wf-1", nodes=[], edges=[])recorded_queries: List[str] = []@@ -416,6 +404,7 @@ class TestCancelCanaryListeners:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)cancelled = await mgr._cancel_canary_listeners("wf-1")@@ -455,6 +444,7 @@ class TestCancelCanaryListeners:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)cancelled = await mgr._cancel_canary_listeners("wf-1")@@ -476,12 +466,16 @@ class TestCancelCanaryListeners:def get_handle(wf_id):handle = MagicMock()if wf_id == "trigger-listener-wf-1-wh-1":+async def boom():raise RuntimeError("simulated handle.cancel failure")+handle.cancel = boomelse:+async def ok():cancelled_ids.append(wf_id)+handle.cancel = okreturn handle@@ -492,6 +486,7 @@ class TestCancelCanaryListeners:wrapper.client = clientfrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)cancelled = await mgr._cancel_canary_listeners("wf-1")@@ -501,13 +496,13 @@ class TestCancelCanaryListeners:@pytest.mark.asyncioasync def test_returns_zero_when_temporal_disconnected(self, monkeypatch):-mgr, _ = _build_manager_with_state("wf-1", nodes=[], edges=[])wrapper = MagicMock()wrapper.client = Nonefrom core import container as container_mod+monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)cancelled = await mgr._cancel_canary_listeners("wf-1")@@ -601,10 +596,13 @@ class TestCancelSweepsStuckNodeStatuses:side_effect=lambda **kw: status_calls.append(kw),)broadcaster._clear_stuck_node_statuses = AsyncMock(- side_effect=lambda workflow_id, include_waiting=False: sweep_calls.append({- "workflow_id": workflow_id,- "include_waiting": include_waiting,- }) or 0,+ side_effect=lambda workflow_id, include_waiting=False: sweep_calls.append(+ {+ "workflow_id": workflow_id,+ "include_waiting": include_waiting,+ }+ )+ or 0,)database = MagicMock()@@ -636,10 +634,7 @@ class TestCancelSweepsStuckNodeStatuses:# Sweep ran once with include_waiting=True (every indicator# goes quiet on explicit user cancel).- assert len(sweep_calls) == 1, (- f"Expected one stuck-node sweep on cancel, got "- f"{len(sweep_calls)}: {sweep_calls!r}"- )+ assert len(sweep_calls) == 1, f"Expected one stuck-node sweep on cancel, got " f"{len(sweep_calls)}: {sweep_calls!r}"assert sweep_calls[0] == {"workflow_id": "wf-1","include_waiting": True,@@ -647,8 +642,7 @@ class TestCancelSweepsStuckNodeStatuses:# Terminal executing=False broadcast for the toolbar.assert {"executing": False, "workflow_id": "wf-1"} in status_calls, (- f"Expected update_workflow_status(executing=False, "- f"workflow_id='wf-1') on cancel; got {status_calls!r}"+ f"Expected update_workflow_status(executing=False, " f"workflow_id='wf-1') on cancel; got {status_calls!r}")@@ -695,7 +689,4 @@ class TestNoInstanceStateForCanaryListeners:from services.deployment.manager import DeploymentManager# Both helpers can be called on the class without an instance.- assert (- DeploymentManager._listener_workflow_id("wf", "node")- == "trigger-listener-wf-node"- )+ assert DeploymentManager._listener_workflow_id("wf", "node") == "trigger-listener-wf-node"diff --git a/server/tests/test_event_framework_phase_a.py b/server/tests/test_event_framework_phase_a.pyindex fc0ef040..fd302f8c 100644--- a/server/tests/test_event_framework_phase_a.py+++ b/server/tests/test_event_framework_phase_a.py@@ -158,20 +158,32 @@ class TestEventFrameworkEnabledDefault:def test_event_framework_enabled_defaults_true(self):"""The ``Field(default=True, env="EVENT_FRAMEWORK_ENABLED")`` line- in core/config.py is the canary flag's production default."""+ in core/config.py is the canary flag's production default.++ Regex-based so the assertion tolerates ruff format's choice of+ single-line vs. multi-line ``Field(...)`` — both shapes are+ semantically equivalent.+ """+ import refrom pathlib import Pathconfig_src = (Path(__file__).parent.parent / "core" / "config.py").read_text(encoding="utf-8")- # The default-True declaration MUST be present.- assert 'default=True, env="EVENT_FRAMEWORK_ENABLED"' in config_src, (+ default_true = re.compile(+ r"default=True[\s,]+env=\"EVENT_FRAMEWORK_ENABLED\"",+ re.DOTALL,+ )+ default_false = re.compile(+ r"default=False[\s,]+env=\"EVENT_FRAMEWORK_ENABLED\"",+ re.DOTALL,+ )+ assert default_true.search(config_src) is not None, ("event_framework_enabled default flipped to True in Wave 12 ""(2026-05-15). The declaration "'``Field(default=True, env="EVENT_FRAMEWORK_ENABLED")`` is '"missing from core/config.py. Use EVENT_FRAMEWORK_ENABLED=false ""in .env to opt out — not by reverting the default.")- # And the legacy default-False must not be reintroduced.- assert 'default=False, env="EVENT_FRAMEWORK_ENABLED"' not in config_src, (+ assert default_false.search(config_src) is None, ("event_framework_enabled reverted to default=False. Wave 12 ""flipped the default to True on 2026-05-15. Use the env var ""(EVENT_FRAMEWORK_ENABLED=false) for opt-out, not a code revert."@@ -195,18 +207,20 @@ class TestCanaryRegistryCoverage:import nodes # noqa: F401from services.deployment.canary_registry import canary_trigger_types- expected = frozenset({- # Push triggers (Wave 12 C1)- "webhookTrigger",- "chatTrigger",- "taskTrigger",- "telegramReceive",- "whatsappReceive",- # Polling trigger (Wave 12 C2)- "googleGmailReceive",- # Cron trigger (Wave 12 C3)- "cronScheduler",- })+ expected = frozenset(+ {+ # Push triggers (Wave 12 C1)+ "webhookTrigger",+ "chatTrigger",+ "taskTrigger",+ "telegramReceive",+ "whatsappReceive",+ # Polling trigger (Wave 12 C2)+ "googleGmailReceive",+ # Cron trigger (Wave 12 C3)+ "cronScheduler",+ }+ )actual = canary_trigger_types()missing = expected - actualassert not missing, (@@ -321,22 +335,16 @@ class TestA7MachinaWorkflowSignalHandler:from services.temporal.workflow import MachinaWorkflowwf = MachinaWorkflow()- wf._matched_events.append(- {"id": "e1", "type": "com.machinaos.whatsapp.message.received"}- )+ wf._matched_events.append({"id": "e1", "type": "com.machinaos.whatsapp.message.received"})# No-predicate: any queued event matches.assert wf._has_event_matching() is True# Truthy predicate matches.- assert wf._has_event_matching(- lambda e: e["type"].endswith("message.received")- ) is True+ assert wf._has_event_matching(lambda e: e["type"].endswith("message.received")) is True# Falsy predicate doesn't match.- assert wf._has_event_matching(- lambda e: e["type"].endswith(".nope")- ) is False+ assert wf._has_event_matching(lambda e: e["type"].endswith(".nope")) is Falsedef test_pop_matching_event_empty_returns_none(self):from services.temporal.workflow import MachinaWorkflow@@ -366,9 +374,7 @@ class TestA7MachinaWorkflowSignalHandler:third = {"id": "e3", "type": "com.machinaos.x.delivered"}wf._matched_events.extend([first, second, third])- popped = wf._pop_matching_event(- lambda e: e["type"].startswith("com.machinaos.y")- )+ popped = wf._pop_matching_event(lambda e: e["type"].startswith("com.machinaos.y"))assert popped is second# Order preserved for non-matching siblings.assert wf._matched_events == [first, third]@@ -377,9 +383,7 @@ class TestA7MachinaWorkflowSignalHandler:from services.temporal.workflow import MachinaWorkflowwf = MachinaWorkflow()- wf._matched_events.append(- {"id": "e1", "type": "com.machinaos.x.received"}- )+ wf._matched_events.append({"id": "e1", "type": "com.machinaos.x.received"})result = wf._pop_matching_event(lambda e: e["type"].endswith(".nope"))assert result is None# Queue untouched on miss.@@ -449,8 +453,7 @@ class TestTriggerOutputPersistenceForTemplateResolution:from services.temporal.activities import store_node_output_activityassert inspect.iscoroutinefunction(store_node_output_activity), (- "store_node_output_activity must be async — workflow.execute_activity "- "awaits it."+ "store_node_output_activity must be async — workflow.execute_activity " "awaits it.")def test_machina_workflow_calls_persist_activity_for_pre_executed(self):@@ -493,25 +496,30 @@ class TestTriggerOutputPersistenceForTemplateResolution:class _StubWorkflowService:async def store_node_output(self, session_id, node_id, output_name, data):- calls.append({- "session_id": session_id,- "node_id": node_id,- "output_name": output_name,- "data": data,- })+ calls.append(+ {+ "session_id": session_id,+ "node_id": node_id,+ "output_name": output_name,+ "data": data,+ }+ )class _StubContainer:def workflow_service(self):return _StubWorkflowService()from core import container as container_mod+monkeypatch.setattr(container_mod, "container", _StubContainer())- await store_node_output_activity({- "node_id": "trig-1",- "session_id": "sess-1",- "result": {"message": "hello", "session_id": "sess-1"},- })+ await store_node_output_activity(+ {+ "node_id": "trig-1",+ "session_id": "sess-1",+ "result": {"message": "hello", "session_id": "sess-1"},+ }+ )# All three standard handles get the data — same write pattern# NodeExecutor uses for non-pre-executed nodes.diff --git a/server/tests/test_no_raw_prints.py b/server/tests/test_no_raw_prints.pyindex 0bd4eead..e29b5b08 100644--- a/server/tests/test_no_raw_prints.py+++ b/server/tests/test_no_raw_prints.py@@ -31,9 +31,9 @@ SERVER_ROOT = Path(__file__).resolve().parents[1]# Directories whose ``print()`` calls are out of scope._EXCLUDED_DIRS = {".venv",- "tests", # tests themselves can print freely- "scripts", # CLI smoke tests are intentional stdout tools- "skills", # SKILL.md markdown — not Python source+ "tests", # tests themselves can print freely+ "scripts", # CLI smoke tests are intentional stdout tools+ "skills", # SKILL.md markdown — not Python source"__pycache__",}@@ -45,6 +45,14 @@ _SANCTIONED: List[Tuple[str, str]] = [("main.py", "_startup_log"),("core/container.py", "_clog"),("nodes/code/python_executor/__init__.py", "captured_print"),+ # Temporal CLI shims — supervised subprocess + build-time installer.+ # These run BEFORE the structlog pipeline is configured in their own+ # subprocess (same role as ``_startup_log`` / ``_clog`` for the main+ # process). Stdout markers are consumed by the supervisor's+ # line-prefixer (``cli/colors.py``), which adds the timestamp tag.+ ("services/temporal/_supervised_runtime.py", "_run"),+ ("services/temporal/_supervised_runtime.py", "main"),+ ("services/temporal/_install.py", "_main"),]@@ -79,7 +87,11 @@ def _enclosing_function_name(tree: ast.AST, target: ast.AST) -> str:def test_no_raw_prints_in_server_code() -> None:"""Every ``print(`` call in server runtime code is in an allow-listed body."""- sanctioned_map = {rel.replace("\\", "/"): fn for rel, fn in _SANCTIONED}+ # Multimap: a single module may sanction multiple entry-point bodies+ # (e.g. ``_supervised_runtime`` has both ``_run`` and ``main``).+ sanctioned_map: dict[str, set[str]] = {}+ for rel, fn in _SANCTIONED:+ sanctioned_map.setdefault(rel.replace("\\", "/"), set()).add(fn)violations: List[str] = []for py in _iter_python_files():@@ -102,8 +114,8 @@ def test_no_raw_prints_in_server_code() -> None:continueenclosing = _enclosing_function_name(tree, node)- allowed_fn = sanctioned_map.get(rel)- if allowed_fn is not None and enclosing == allowed_fn:+ allowed_fns = sanctioned_map.get(rel)+ if allowed_fns is not None and enclosing in allowed_fns:continueviolations.append(@@ -115,6 +127,5 @@ def test_no_raw_prints_in_server_code() -> None:assert not violations, ("Raw ``print()`` calls bypass the structlog pipeline (no level tag, ""no contextvars, no file handler, no WS Terminal panel). Convert "- "to ``logger.<level>(...)`` or move into a sanctioned helper:\n\n"- + "\n".join(violations)+ "to ``logger.<level>(...)`` or move into a sanctioned helper:\n\n" + "\n".join(violations))diff --git a/server/tests/test_node_spec.py b/server/tests/test_node_spec.pyindex 5a69dc2a..1b21cab1 100644--- a/server/tests/test_node_spec.py+++ b/server/tests/test_node_spec.py@@ -121,23 +121,32 @@ class TestPhase3aCoverage:PHASE_3A_TYPES = [# utility- "httpRequest", "webhookTrigger", "webhookResponse",- "chatTrigger", "console", "teamMonitor",+ "httpRequest",+ "webhookTrigger",+ "webhookResponse",+ "chatTrigger",+ "console",+ "teamMonitor",# code- "pythonExecutor", "javascriptExecutor", "typescriptExecutor",+ "pythonExecutor",+ "javascriptExecutor",+ "typescriptExecutor",# process"processManager",# workflow- "start", "taskTrigger",+ "start",+ "taskTrigger",]def test_all_have_input_schema(self):from services.node_input_schemas import get_node_input_schema+missing = [t for t in self.PHASE_3A_TYPES if get_node_input_schema(t) is None]assert not missing, f"Phase 3a types missing input schema: {missing}"def test_all_have_metadata(self):from models.node_metadata import get_node_metadata+missing = [t for t in self.PHASE_3A_TYPES if get_node_metadata(t) is None]assert not missing, f"Phase 3a types missing display metadata: {missing}"@@ -166,19 +175,28 @@ class TestPhase3bCoverage:twitter, social) - 11 types."""PHASE_3B_TYPES = [- "whatsappSend", "whatsappReceive", "whatsappDb",- "telegramSend", "telegramReceive",- "twitterSend", "twitterReceive", "twitterSearch", "twitterUser",- "socialReceive", "socialSend",+ "whatsappSend",+ "whatsappReceive",+ "whatsappDb",+ "telegramSend",+ "telegramReceive",+ "twitterSend",+ "twitterReceive",+ "twitterSearch",+ "twitterUser",+ "socialReceive",+ "socialSend",]def test_all_have_input_schema(self):from services.node_input_schemas import get_node_input_schema+missing = [t for t in self.PHASE_3B_TYPES if get_node_input_schema(t) is None]assert not missing, f"Phase 3b types missing input schema: {missing}"def test_all_have_metadata(self):from models.node_metadata import get_node_metadata+missing = [t for t in self.PHASE_3B_TYPES if get_node_metadata(t) is None]assert not missing, f"Phase 3b types missing display metadata: {missing}"@@ -193,7 +211,13 @@ class TestPhase3bCoverage:spec = get_node_spec("twitterSend")action = spec["inputs"]["properties"]["action"]assert set(action["enum"]) >= {- "tweet", "reply", "retweet", "quote", "like", "unlike", "delete",+ "tweet",+ "reply",+ "retweet",+ "quote",+ "like",+ "unlike",+ "delete",}def test_telegram_send_parse_mode_enum(self):@@ -218,21 +242,40 @@ class TestPhase3cCoverage:PHASE_3C_TYPES = [# Base agents- "aiAgent", "chatAgent", "simpleMemory",+ "aiAgent",+ "chatAgent",+ "simpleMemory",# Specialized agents (16)- "android_agent", "coding_agent", "web_agent", "task_agent",- "social_agent", "travel_agent", "tool_agent", "productivity_agent",- "payments_agent", "consumer_agent", "autonomous_agent",- "orchestrator_agent", "ai_employee", "rlm_agent",+ "android_agent",+ "coding_agent",+ "web_agent",+ "task_agent",+ "social_agent",+ "travel_agent",+ "tool_agent",+ "productivity_agent",+ "payments_agent",+ "consumer_agent",+ "autonomous_agent",+ "orchestrator_agent",+ "ai_employee",+ "rlm_agent","claude_code_agent",# Chat models (9)- "openaiChatModel", "anthropicChatModel", "geminiChatModel",- "openrouterChatModel", "groqChatModel", "cerebrasChatModel",- "deepseekChatModel", "kimiChatModel", "mistralChatModel",+ "openaiChatModel",+ "anthropicChatModel",+ "geminiChatModel",+ "openrouterChatModel",+ "groqChatModel",+ "cerebrasChatModel",+ "deepseekChatModel",+ "kimiChatModel",+ "mistralChatModel",]def test_all_have_metadata(self):from models.node_metadata import get_node_metadata+missing = [t for t in self.PHASE_3C_TYPES if get_node_metadata(t) is None]assert not missing, f"Phase 3c types missing metadata: {missing}"@@ -264,21 +307,40 @@ class TestPhase3dCoverage:PHASE_3D_TYPES = [# Location- "gmaps_create", "gmaps_locations", "gmaps_nearby_places",+ "gmaps_create",+ "gmaps_locations",+ "gmaps_nearby_places",# Scheduler / triggers- "cronScheduler", "timer", "googleGmailReceive",+ "cronScheduler",+ "timer",+ "googleGmailReceive",# Chat / text- "chatSend", "chatHistory", "textGenerator", "fileHandler",+ "chatSend",+ "chatHistory",+ "textGenerator",+ "fileHandler",# Android (16)- "batteryMonitor", "networkMonitor", "systemInfo", "location",- "appLauncher", "appList", "wifiAutomation", "bluetoothAutomation",- "audioAutomation", "deviceStateAutomation", "screenControlAutomation",- "airplaneModeControl", "motionDetection", "environmentalSensors",- "cameraControl", "mediaControl",+ "batteryMonitor",+ "networkMonitor",+ "systemInfo",+ "location",+ "appLauncher",+ "appList",+ "wifiAutomation",+ "bluetoothAutomation",+ "audioAutomation",+ "deviceStateAutomation",+ "screenControlAutomation",+ "airplaneModeControl",+ "motionDetection",+ "environmentalSensors",+ "cameraControl",+ "mediaControl",]def test_all_have_metadata(self):from models.node_metadata import get_node_metadata+missing = [t for t in self.PHASE_3D_TYPES if get_node_metadata(t) is None]assert not missing, f"Phase 3d.i types missing metadata: {missing}"@@ -299,6 +361,7 @@ class TestPhase3dCoverage:display metadata. Phase 3d.i closes the input-model gap."""from services.node_input_schemas import NODE_INPUT_MODELSfrom models.node_metadata import NODE_METADATA+unseeded = [t for t in NODE_INPUT_MODELS if t not in NODE_METADATA]assert not unseeded, f"Input-modeled types still missing metadata: {unseeded}"@@ -311,29 +374,51 @@ class TestPhase3dIICoverage:PHASE_3D_II_TYPES = [# Search- "braveSearch", "serperSearch", "perplexitySearch",+ "braveSearch",+ "serperSearch",+ "perplexitySearch",# Browser / scraping- "browser", "crawleeScraper", "httpScraper", "apifyActor",+ "browser",+ "crawleeScraper",+ "httpScraper",+ "apifyActor",- "emailSend", "emailRead", "emailReceive",+ "emailSend",+ "emailRead",+ "emailReceive",# Google Workspace- "googleGmail", "googleCalendar", "googleDrive", "googleSheets", "googleTasks", "googleContacts",+ "googleGmail",+ "googleCalendar",+ "googleDrive",+ "googleSheets",+ "googleTasks",+ "googleContacts",# Document / RAG- "documentParser", "textChunker", "embeddingGenerator",- "vectorStore", "fileDownloader",+ "documentParser",+ "textChunker",+ "embeddingGenerator",+ "vectorStore",+ "fileDownloader",# Filesystem- "fileRead", "fileModify", "fsSearch", "shell",+ "fileRead",+ "fileModify",+ "fsSearch",+ "shell",# Proxy- "proxyRequest", "proxyConfig", "proxyStatus",+ "proxyRequest",+ "proxyConfig",+ "proxyStatus",]def test_all_have_input_schema(self):from services.node_input_schemas import get_node_input_schema+missing = [t for t in self.PHASE_3D_II_TYPES if get_node_input_schema(t) is None]assert not missing, f"Phase 3d.ii types missing input schema: {missing}"def test_all_have_metadata(self):from models.node_metadata import get_node_metadata+missing = [t for t in self.PHASE_3D_II_TYPES if get_node_metadata(t) is None]assert not missing, f"Phase 3d.ii types missing metadata: {missing}"@@ -371,15 +456,18 @@ class TestWave6FullCoverage:def test_input_models_have_metadata(self):from services.node_input_schemas import NODE_INPUT_MODELSfrom models.node_metadata import NODE_METADATA+gap = sorted(set(NODE_INPUT_MODELS.keys()) - set(NODE_METADATA.keys()))assert not gap, f"Input models without metadata: {gap}"def test_total_nodespec_count_at_least_110(self):from services.node_spec import list_node_types_with_spec+assert len(list_node_types_with_spec()) >= 110def test_input_model_count_at_least_100(self):from services.node_input_schemas import NODE_INPUT_MODELS+assert len(NODE_INPUT_MODELS) >= 100@@ -388,18 +476,21 @@ class TestPhase4LoadOptions:def test_registry_has_whatsapp_methods(self):from services.ws_handler_registry import list_load_options_methods+methods = list_load_options_methods()for method in ["whatsappGroups", "whatsappChannels", "whatsappGroupMembers"]:assert method in methodsdef test_registry_has_google_methods(self):from services.ws_handler_registry import list_load_options_methods+methods = list_load_options_methods()for method in ["gmailLabels", "googleCalendarList", "googleDriveFolders", "googleTasklists"]:assert method in methodsdef test_list_methods_sorted(self):from services.ws_handler_registry import list_load_options_methods+methods = list_load_options_methods()assert methods == sorted(methods)assert len(methods) >= 7@@ -407,6 +498,7 @@ class TestPhase4LoadOptions:@pytest.mark.asyncioasync def test_unknown_method_returns_empty(self):from services.ws_handler_registry import dispatch_load_options+result = await dispatch_load_options("nonExistentMethodXyz", {})assert result == []@@ -414,6 +506,7 @@ class TestPhase4LoadOptions:async def test_dispatch_passes_params(self):# Smoke test: unknown method tolerates arbitrary params, doesn't crashfrom services.ws_handler_registry import dispatch_load_options+result = await dispatch_load_options("unknown", {"group_id": "abc"})assert result == []@@ -424,30 +517,35 @@ class TestPhase5NodeGroups:def test_returns_dict(self):from services.node_spec import list_node_groups+groups = list_node_groups()assert isinstance(groups, dict)assert len(groups) > 0def test_known_groups_present(self):from services.node_spec import list_node_groups+groups = list_node_groups()for expected in ["agent", "trigger", "tool", "model", "android", "social"]:assert expected in groups, f"Missing group {expected!r}"def test_tool_group_includes_known_tools(self):from services.node_spec import list_node_groups+tools = set(list_node_groups()["tool"]["types"])for expected in ["pythonExecutor", "javascriptExecutor", "httpRequest"]:assert expected in toolsdef test_trigger_group_includes_known_triggers(self):from services.node_spec import list_node_groups+triggers = set(list_node_groups()["trigger"]["types"])for expected in ["webhookTrigger", "chatTrigger", "telegramReceive", "twitterReceive"]:assert expected in triggersdef test_each_group_alphabetised(self):from services.node_spec import list_node_groups+for group, entry in list_node_groups().items():types = entry["types"]assert types == sorted(types), f"Group {group!r} not sorted: {types}"@@ -458,12 +556,11 @@ class TestPhase5NodeGroups:via ``register_group`` in ``server/nodes/groups.py``. Preventsa new group key silently rendering unlabelled in the palette."""from services.node_spec import list_node_groups+for group, entry in list_node_groups().items():assert entry["label"], f"{group}: missing label"assert entry["icon"], f"{group}: missing icon"- assert entry["visibility"] in ("normal", "dev", "all"), (- f"{group}: visibility={entry['visibility']!r}"- )+ assert entry["visibility"] in ("normal", "dev", "all"), f"{group}: visibility={entry['visibility']!r}"class TestDisplayOptionsEnrichment:@@ -700,12 +797,14 @@ class TestNodeSpecContractInvariants:def _all_spec_types(self):from services.node_spec import list_node_types_with_spec+return list_node_types_with_spec()def test_every_spec_has_required_wire_fields(self):"""Every spec must have: type, displayName, group, version.Missing any of these would break the adapter's defaults()."""from services.node_spec import get_node_spec+for t in self._all_spec_types():spec = get_node_spec(t)assert spec is not None, f"No spec for {t}"@@ -719,6 +818,7 @@ class TestNodeSpecContractInvariants:object with properties dict. The adapter crashes if propertiesis missing."""from services.node_input_schemas import get_node_input_schema, NODE_INPUT_MODELS+for t in NODE_INPUT_MODELS:schema = get_node_input_schema(t)assert schema is not None, f"Input schema None for {t}"@@ -731,6 +831,7 @@ class TestNodeSpecContractInvariants:values are lists (the INodeProperties.displayOptions shape thefrontend evaluator expects)."""from services.node_input_schemas import get_node_input_schema, NODE_INPUT_MODELS+for t in NODE_INPUT_MODELS:schema = get_node_input_schema(t)for prop_name, prop in schema.get("properties", {}).items():@@ -741,9 +842,7 @@ class TestNodeSpecContractInvariants:continueassert isinstance(rule, dict), f"{t}.{prop_name}.displayOptions.{key} not dict"for ref_field, allowed in rule.items():- assert isinstance(allowed, list), (- f"{t}.{prop_name}.displayOptions.{key}[{ref_field!r}] must be list"- )+ assert isinstance(allowed, list), f"{t}.{prop_name}.displayOptions.{key}[{ref_field!r}] must be list"def test_load_options_methods_are_registered(self):"""Every Pydantic Field(loadOptionsMethod=X) must point at a@@ -752,6 +851,7 @@ class TestNodeSpecContractInvariants:forgotten loader registrations."""from services.node_input_schemas import get_node_input_schema, NODE_INPUT_MODELSfrom services.ws_handler_registry import list_load_options_methods+methods = set(list_load_options_methods())for t in NODE_INPUT_MODELS:schema = get_node_input_schema(t)@@ -759,9 +859,7 @@ class TestNodeSpecContractInvariants:method = prop.get("loadOptionsMethod")if method is None:continue- assert method in methods, (- f"{t}.{prop_name} references unknown loadOptionsMethod {method!r}"- )+ assert method in methods, f"{t}.{prop_name} references unknown loadOptionsMethod {method!r}"def test_every_enum_option_is_serialisable(self):"""Frontend options are {name, value} where value is scalar.@@ -769,6 +867,7 @@ class TestNodeSpecContractInvariants:non-serialisable types."""from services.node_input_schemas import get_node_input_schema, NODE_INPUT_MODELSimport json+for t in NODE_INPUT_MODELS:schema = get_node_input_schema(t)for prop_name, prop in schema.get("properties", {}).items():@@ -777,23 +876,31 @@ class TestNodeSpecContractInvariants:try:json.dumps(val)except (TypeError, ValueError) as e:- raise AssertionError(- f"{t}.{prop_name} enum value {val!r} not JSON-serialisable: {e}"- )+ raise AssertionError(f"{t}.{prop_name} enum value {val!r} not JSON-serialisable: {e}")def test_ui_hints_only_carry_known_flags(self):"""NODE_METADATA uiHints should only carry flags the frontendINodeUIHints knows about. New flag names without a frontendconsumer are dead weight."""from models.node_metadata import NODE_METADATA+known = {- "hideInputSection", "hideOutputSection", "hideRunButton",- "hasCodeEditor", "isMasterSkillEditor",- "isMemoryPanel", "isToolPanel", "isMonitorPanel",- "showLocationPanel", "isAndroidToolkit", "isChatTrigger",- "isConsoleSink", "hasSkills",+ "hideInputSection",+ "hideOutputSection",+ "hideRunButton",+ "hasCodeEditor",+ "isMasterSkillEditor",+ "isMemoryPanel",+ "isToolPanel",+ "isMonitorPanel",+ "showLocationPanel",+ "isAndroidToolkit",+ "isChatTrigger",+ "isConsoleSink",+ "hasSkills",# Wave 10.A: size hints carried by plugin registrations- "width", "height",+ "width",+ "height",# Wave 10.G.5: start-node's user-authored JSON blob marker"hasInitialDataBlob",# Auto-derived from group membership ('memory' / 'tool') by@@ -806,8 +913,7 @@ class TestNodeSpecContractInvariants:hints = meta.get("uiHints") or {}unknown = set(hints.keys()) - knownassert not unknown, (- f"{node_type}: NODE_METADATA['uiHints'] has unknown flags {unknown}. "- "Add to INodeUIHints + to the `known` set here."+ f"{node_type}: NODE_METADATA['uiHints'] has unknown flags {unknown}. " "Add to INodeUIHints + to the `known` set here.")@@ -818,8 +924,15 @@ class TestPluginContractInvariants:"""VALID_KINDS = {- "square", "circle", "trigger", "start",- "agent", "chat", "tool", "model", "generic",+ "square",+ "circle",+ "trigger",+ "start",+ "agent",+ "chat",+ "tool",+ "model",+ "generic",}VALID_POSITIONS = {"top", "bottom", "left", "right"}@@ -827,9 +940,11 @@ class TestPluginContractInvariants:# Types registered via services.node_registry.register_node (Wave 10.C).import nodes # noqa: F401 — import triggerfrom services.node_registry import registered_node_types+# Fall back to any metadata entry that carries componentKind, so the# test still passes for metadata-only registrations (no handler).from models.node_metadata import NODE_METADATA+explicit = {t for t, m in NODE_METADATA.items() if "componentKind" in m}return registered_node_types() | explicit@@ -837,9 +952,9 @@ class TestPluginContractInvariants:for t in self._plugin_types():spec = get_node_spec(t)assert spec is not None, f"{t}: no NodeSpec emitted"- assert spec.get("componentKind") in self.VALID_KINDS, (- f"{t}: componentKind={spec.get('componentKind')!r} not in {self.VALID_KINDS}"- )+ assert (+ spec.get("componentKind") in self.VALID_KINDS+ ), f"{t}: componentKind={spec.get('componentKind')!r} not in {self.VALID_KINDS}"def test_every_plugin_node_has_color(self):# Color is the brand/accent each node owns. Without it the frontend@@ -864,12 +979,8 @@ class TestPluginContractInvariants:spec = get_node_spec(t)for h in spec.get("handles") or []:assert "name" in h, f"{t}: handle missing name: {h}"- assert h.get("kind") in {"input", "output"}, (- f"{t}.{h.get('name')}: kind={h.get('kind')!r} not input/output"- )- assert h.get("position") in self.VALID_POSITIONS, (- f"{t}.{h.get('name')}: position={h.get('position')!r} invalid"- )+ assert h.get("kind") in {"input", "output"}, f"{t}.{h.get('name')}: kind={h.get('kind')!r} not input/output"+ assert h.get("position") in self.VALID_POSITIONS, f"{t}.{h.get('name')}: position={h.get('position')!r} invalid"def test_agent_kind_has_skill_tool_memory_handles(self):# Contract: anything registered as an agent must accept skill,@@ -886,9 +997,7 @@ class TestPluginContractInvariants:continuenames = {h.get("name") for h in spec.get("handles") or []}for required in ("input-skill", "input-tools", "input-memory", "input-task"):- assert required in names, (- f"{t}: componentKind=agent missing handle {required!r}; got {sorted(names)}"- )+ assert required in names, f"{t}: componentKind=agent missing handle {required!r}; got {sorted(names)}"def test_trigger_kind_emits_output(self):# Triggers without an output are useless — they emit events@@ -916,20 +1025,16 @@ class TestPluginContractInvariants:# be consistent" — auto-derived is not author intent, so skip# those nodes.from services.node_registry import get_node_class+for t in self._plugin_types():spec = get_node_spec(t)if not spec.get("hideOutputHandle"):continuecls = get_node_class(t)- if cls is not None and (- getattr(cls, "usable_as_tool", False)- or getattr(cls, "component_kind", "") == "tool"- ):+ if cls is not None and (getattr(cls, "usable_as_tool", False) or getattr(cls, "component_kind", "") == "tool"):continueouts = [h for h in spec.get("handles") or [] if h.get("kind") == "output"]- assert not outs, (- f"{t}: hideOutputHandle=True but handles declares output(s) {outs}"- )+ assert not outs, f"{t}: hideOutputHandle=True but handles declares output(s) {outs}"class TestWave10GContractInvariants:@@ -944,6 +1049,7 @@ class TestWave10GContractInvariants:import nodes # noqa: F401from services.node_registry import registered_node_typesfrom models.node_metadata import NODE_METADATA+explicit = {t for t, m in NODE_METADATA.items() if "componentKind" in m}return registered_node_types() | explicit@@ -959,9 +1065,7 @@ class TestWave10GContractInvariants:if t in self.AGENT_EXEMPT:continuehints = spec.get("uiHints") or {}- assert hints.get("hasSkills") is True, (- f"{t}: componentKind=agent must declare uiHints.hasSkills=True"- )+ assert hints.get("hasSkills") is True, f"{t}: componentKind=agent must declare uiHints.hasSkills=True"def test_every_tool_kind_declares_isToolPanel(self):"""Every dedicated tool node (componentKind='tool') must emit@@ -975,9 +1079,7 @@ class TestWave10GContractInvariants:if spec.get("componentKind") != "tool":continuehints = spec.get("uiHints") or {}- assert hints.get("isToolPanel") is True, (- f"{t}: componentKind=tool must declare uiHints.isToolPanel=True"- )+ assert hints.get("isToolPanel") is True, f"{t}: componentKind=tool must declare uiHints.isToolPanel=True"def test_google_workspace_nodes_have_operation_gating(self):"""Drive / Sheets / Tasks / Contacts / Gmail all have an@@ -985,31 +1087,25 @@ class TestWave10GContractInvariants:behind `displayOptions.show.operation` so the panel isn't aflat dump of every op's fields."""from services.node_input_schemas import get_node_input_schema+for t in ("googleGmail", "googleDrive", "googleSheets", "googleTasks", "googleContacts"):schema = get_node_input_schema(t)assert schema, f"{t}: no input schema"props = schema.get("properties") or {}- gated = [- name for name, p in props.items()- if (p.get("displayOptions") or {}).get("show", {}).get("operation")- ]- assert gated, (- f"{t}: no field declares displayOptions.show.operation; "- "every per-op field would render at once"- )+ gated = [name for name, p in props.items() if (p.get("displayOptions") or {}).get("show", {}).get("operation")]+ assert gated, f"{t}: no field declares displayOptions.show.operation; " "every per-op field would render at once"def test_code_executors_declare_code_editor(self):"""The ParameterRenderer `case 'code'` widget only fires whenthe Pydantic field emits `editor: 'code'`. Without this thecode executor falls back to a plain string input."""from services.node_input_schemas import get_node_input_schema+for t in ("pythonExecutor", "javascriptExecutor", "typescriptExecutor"):schema = get_node_input_schema(t)code_field = (schema.get("properties") or {}).get("code")assert code_field, f"{t}: `code` field missing from input schema"- assert code_field.get("editor") == "code", (- f"{t}.code: expected `editor: 'code'`, got {code_field.get('editor')!r}"- )+ assert code_field.get("editor") == "code", f"{t}.code: expected `editor: 'code'`, got {code_field.get('editor')!r}"def test_every_asset_icon_has_matching_svg(self):"""Wave 10.B: every ``asset:<key>`` string emitted by a plugin@@ -1036,8 +1132,7 @@ class TestWave10GContractInvariants:if m and m.group(1) not in svg_keys:missing.append(f"{node_type}.icon={icon!r}")assert not missing, (- f"asset:<key> references with no matching SVG: {missing}. "- f"Drop the file at client/src/assets/icons/<folder>/<key>.svg."+ f"asset:<key> references with no matching SVG: {missing}. " f"Drop the file at client/src/assets/icons/<folder>/<key>.svg.")def test_api_key_fields_are_password_masked(self):@@ -1046,6 +1141,7 @@ class TestWave10GContractInvariants:Tribal risk: a new node author forgets the hint and the keyrenders in plaintext."""from services.node_input_schemas import NODE_INPUT_MODELS, get_node_input_schema+offenders = []for t in NODE_INPUT_MODELS:schema = get_node_input_schema(t)@@ -1054,7 +1150,4 @@ class TestWave10GContractInvariants:for name, prop in (schema.get("properties") or {}).items():if name in ("api_key", "api_key") and prop.get("password") is not True:offenders.append(f"{t}.{name}")- assert not offenders, (- "API-key fields missing password:True — they would render in "- f"plaintext: {offenders}"- )+ assert not offenders, "API-key fields missing password:True — they would render in " f"plaintext: {offenders}"diff --git a/server/tests/test_parameter_resolver.py b/server/tests/test_parameter_resolver.pyindex 9d8d8750..a201a303 100644--- a/server/tests/test_parameter_resolver.py+++ b/server/tests/test_parameter_resolver.py@@ -35,9 +35,7 @@ async def test_resolves_whole_value_template_and_preserves_type():resolver = _make_resolver({"trigger_1": {"count": 5}})nodes = [{"id": "trigger_1", "type": "chatTrigger", "data": {"label": "Trigger"}}]edges = []- resolved = await resolver.resolve(- {"count": "{{trigger.count}}"}, "target", nodes, edges, "s1"- )+ resolved = await resolver.resolve({"count": "{{trigger.count}}"}, "target", nodes, edges, "s1")# Whole-value template preserves native type (int, not str).assert resolved["count"] == 5@@ -45,18 +43,14 @@ async def test_resolves_whole_value_template_and_preserves_type():async def test_resolves_interpolated_template_to_string():resolver = _make_resolver({"trigger_1": {"name": "world"}})nodes = [{"id": "trigger_1", "type": "chatTrigger", "data": {"label": "Trigger"}}]- resolved = await resolver.resolve(- {"greeting": "hello {{trigger.name}}!"}, "target", nodes, [], "s1"- )+ resolved = await resolver.resolve({"greeting": "hello {{trigger.name}}!"}, "target", nodes, [], "s1")assert resolved["greeting"] == "hello world!"async def test_missing_key_replaces_with_empty_string():resolver = _make_resolver({"trigger_1": {"text": "ok"}})nodes = [{"id": "trigger_1", "type": "chatTrigger", "data": {"label": "Trigger"}}]- resolved = await resolver.resolve(- {"value": "{{trigger.bogus}}"}, "target", nodes, [], "s1"- )+ resolved = await resolver.resolve({"value": "{{trigger.bogus}}"}, "target", nodes, [], "s1")assert resolved["value"] == ""@@ -68,20 +62,20 @@ async def test_structlog_isEnabledFor_regression():resolver = _make_resolver({"trigger_1": {"text": "hi"}})nodes = [{"id": "trigger_1", "type": "chatTrigger", "data": {"label": "Trigger"}}]# Forces entry into _resolve_templates with at least one {{}} param.- resolved = await resolver.resolve(- {"msg": "{{trigger.text}}"}, "target", nodes, [], "s1"- )+ resolved = await resolver.resolve({"msg": "{{trigger.text}}"}, "target", nodes, [], "s1")assert resolved["msg"] == "hi"async def test_nested_navigation_with_array_index():- resolver = _make_resolver({"upstream_1": {- "messages": [{"text": "first"}, {"text": "second"}],- }})- nodes = [{"id": "upstream_1", "type": "httpRequest", "data": {"label": "Upstream"}}]- resolved = await resolver.resolve(- {"pick": "{{upstream.messages[1].text}}"}, "target", nodes, [], "s1"+ resolver = _make_resolver(+ {+ "upstream_1": {+ "messages": [{"text": "first"}, {"text": "second"}],+ }+ })+ nodes = [{"id": "upstream_1", "type": "httpRequest", "data": {"label": "Upstream"}}]+ resolved = await resolver.resolve({"pick": "{{upstream.messages[1].text}}"}, "target", nodes, [], "s1")assert resolved["pick"] == "second"@@ -89,7 +83,10 @@ async def test_no_template_values_pass_through_unchanged():resolver = _make_resolver({})resolved = await resolver.resolve({"literal": "items.0.text", "flag": True, "n": 3},- "target", [], [], "s1",+ "target",+ [],+ [],+ "s1",)# No '{{' in value ⇒ resolver must not touch it.assert resolved == {"literal": "items.0.text", "flag": True, "n": 3}@@ -103,7 +100,10 @@ async def test_nested_dict_and_list_params_recurse():"config": {"greet": "hi {{src.name}}"},"people": ["{{src.name}}", "static"],},- "target", nodes, [], "s1",+ "target",+ nodes,+ [],+ "s1",)assert resolved["config"]["greet"] == "hi Alice"assert resolved["people"] == ["Alice", "static"]diff --git a/server/tests/test_plugin_contract.py b/server/tests/test_plugin_contract.pyindex 7cdac32a..8f735a78 100644--- a/server/tests/test_plugin_contract.py+++ b/server/tests/test_plugin_contract.py@@ -39,9 +39,7 @@ class TestBaseNodeDeclaration:def test_version_is_positive_int(self):for cls in _all_plugin_classes():- assert isinstance(cls.version, int) and cls.version >= 1, (- f"{cls.__qualname__} version must be a positive int"- )+ assert isinstance(cls.version, int) and cls.version >= 1, f"{cls.__qualname__} version must be a positive int"class TestParamsAndOutput:@@ -49,15 +47,11 @@ class TestParamsAndOutput:def test_params_is_basemodel(self):for cls in _all_plugin_classes():- assert issubclass(cls.Params, BaseModel), (- f"{cls.__qualname__}.Params must be a Pydantic BaseModel"- )+ assert issubclass(cls.Params, BaseModel), f"{cls.__qualname__}.Params must be a Pydantic BaseModel"def test_output_is_basemodel(self):for cls in _all_plugin_classes():- assert issubclass(cls.Output, BaseModel), (- f"{cls.__qualname__}.Output must be a Pydantic BaseModel"- )+ assert issubclass(cls.Output, BaseModel), f"{cls.__qualname__}.Output must be a Pydantic BaseModel"class TestCredentials:@@ -68,12 +62,8 @@ class TestCredentials:for cls in _all_plugin_classes():for cred in cls.credentials:- assert issubclass(cred, Credential), (- f"{cls.__qualname__}.credentials must be Credential subclasses"- )- assert cred.id in CREDENTIAL_REGISTRY, (- f"{cls.__qualname__} references unregistered credential '{cred.id}'"- )+ assert issubclass(cred, Credential), f"{cls.__qualname__}.credentials must be Credential subclasses"+ assert cred.id in CREDENTIAL_REGISTRY, f"{cls.__qualname__} references unregistered credential '{cred.id}'"class TestOperations:@@ -86,25 +76,18 @@ class TestOperations:# Pure-display plugins (no handler) are allowed — skip those.if cls.Params.__name__ == "_EmptyParams" and cls.Output is _EmptyOutput:continue- assert cls._operations, (- f"{cls.__qualname__} must declare at least one @Operation"- )+ assert cls._operations, f"{cls.__qualname__} must declare at least one @Operation"def test_operation_names_unique(self):for cls in _all_plugin_classes():names = [spec.name for spec in cls._operations.values()]- assert len(names) == len(set(names)), (- f"{cls.__qualname__} has duplicate operation names: {names}"- )+ assert len(names) == len(set(names)), f"{cls.__qualname__} has duplicate operation names: {names}"def test_routing_requires_credentials(self):for cls in _all_plugin_classes():for spec in cls._operations.values():if spec.routing is not None:- assert cls.credentials, (- f"{cls.__qualname__}.{spec.name} uses routing but no "- f"credentials declared"- )+ assert cls.credentials, f"{cls.__qualname__}.{spec.name} uses routing but no " f"credentials declared"class TestScalingKnobs:@@ -114,18 +97,13 @@ class TestScalingKnobs:from services.plugin.scaling import TaskQueuefor cls in _all_plugin_classes():- assert cls.task_queue in TaskQueue.ALL, (- f"{cls.__qualname__}.task_queue={cls.task_queue!r} "- f"not in TaskQueue.ALL"- )+ assert cls.task_queue in TaskQueue.ALL, f"{cls.__qualname__}.task_queue={cls.task_queue!r} " f"not in TaskQueue.ALL"def test_retry_policy_type(self):from services.plugin.scaling import RetryPolicyfor cls in _all_plugin_classes():- assert isinstance(cls.retry_policy, RetryPolicy), (- f"{cls.__qualname__}.retry_policy must be a RetryPolicy"- )+ assert isinstance(cls.retry_policy, RetryPolicy), f"{cls.__qualname__}.retry_policy must be a RetryPolicy"class TestStartToCloseTimeoutOverridesAreCommented:@@ -181,9 +159,7 @@ class TestStartToCloseTimeoutOverridesAreCommented:continueoverride_line = lines[override_idx]has_inline_comment = "#" in override_line.split("=", 1)[1]- has_preceding_comment = (- override_idx > 0 and lines[override_idx - 1].strip().startswith("#")- )+ has_preceding_comment = override_idx > 0 and lines[override_idx - 1].strip().startswith("#")assert has_inline_comment or has_preceding_comment, (f"{cls.__qualname__} overrides start_to_close_timeout away "f"from the kind-base default but has no explanatory comment. "@@ -203,10 +179,7 @@ class TestToolSchemaGeneration:continueschema = cls.as_tool_schema()params = schema["parameters"]- assert "$defs" not in params, (- f"{cls.__qualname__} tool schema contains $defs — LLM "- "function-calling rejects $ref"- )+ assert "$defs" not in params, f"{cls.__qualname__} tool schema contains $defs — LLM " "function-calling rejects $ref"assert "definitions" not in paramsassert schema.get("name") == cls.type@@ -227,13 +200,8 @@ class TestToolSchemaFastPath:if not is_tool:continueresolved = get_node_class(cls.type)- assert resolved is cls, (- f"{cls.__qualname__}: fast-path lookup by type '{cls.type}' "- f"returned {resolved}, expected {cls}"- )- assert hasattr(resolved, "Params"), (- f"{cls.__qualname__} has no Params — fast-path would miss it"- )+ assert resolved is cls, f"{cls.__qualname__}: fast-path lookup by type '{cls.type}' " f"returned {resolved}, expected {cls}"+ assert hasattr(resolved, "Params"), f"{cls.__qualname__} has no Params — fast-path would miss it"class TestTriggerRegistryAutoPopulate:@@ -250,8 +218,7 @@ class TestTriggerRegistryAutoPopulate:if getattr(cls, "mode", "event") != "event":continueassert cls.event_type, (- f"{cls.__qualname__} (TriggerNode, mode=event) is missing "- "event_type — event_waiter won't auto-populate for it"+ f"{cls.__qualname__} (TriggerNode, mode=event) is missing " "event_type — event_waiter won't auto-populate for it")def test_event_triggers_populate_registry(self):@@ -264,7 +231,5 @@ class TestTriggerRegistryAutoPopulate:if getattr(cls, "mode", "event") != "event" or not cls.event_type:continuecfg = event_waiter.get_trigger_config(cls.type)- assert cfg is not None, (- f"{cls.__qualname__}: get_trigger_config('{cls.type}') returned None"- )+ assert cfg is not None, f"{cls.__qualname__}: get_trigger_config('{cls.type}') returned None"assert cfg.event_type == cls.event_typediff --git a/server/tests/test_plugin_self_containment.py b/server/tests/test_plugin_self_containment.pyindex 0cf0ba40..708f27fc 100644--- a/server/tests/test_plugin_self_containment.py+++ b/server/tests/test_plugin_self_containment.py@@ -95,19 +95,19 @@ _FORBIDDEN_IMPORT_FRAGMENTS = ("services.whatsapp_service","services.twitter_oauth","services.google_oauth",- "services.android", # legacy relay sub-package+ "services.android", # legacy relay sub-package"services.android_service","services.browser_service","services.email_service","services.himalaya_service","services.claude_code_service",- "services.maps", # Wave 11.I, N: -> nodes/location/_service+ "services.maps", # Wave 11.I, N: -> nodes/location/_service"services.node_option_loaders", # Wave 11.I, M: -> nodes/<plugin>/_option_loaders"routers.twitter","routers.google","routers.android","routers.whatsapp",- "routers.maps", # Wave 11.I, N: deleted+ "routers.maps", # Wave 11.I, N: deleted)@@ -151,10 +151,7 @@ class TestNoPluginRouterOutsideNodes:def test_migrated_plugins_have_no_router_file_in_routers(self):routers_dir = _SERVER_ROOT / "routers"- present = [- name for name in self._MUST_NOT_EXIST- if (routers_dir / name).exists()- ]+ present = [name for name in self._MUST_NOT_EXIST if (routers_dir / name).exists()]assert not present, (f"server/routers/ contains files for migrated plugins: {present}. ""These belong under nodes/<plugin>/_router.py and mount via "@@ -182,8 +179,7 @@ class TestPluginInitSelfRegisters:init_path = plugin_dir / "__init__.py"assert handlers_path.exists(), (- f"nodes/{plugin}/_handlers.py missing -- remove {plugin!r} "- "from _PLUGINS_WITH_HANDLERS or restore the file."+ f"nodes/{plugin}/_handlers.py missing -- remove {plugin!r} " "from _PLUGINS_WITH_HANDLERS or restore the file.")assert init_path.exists(), f"nodes/{plugin}/__init__.py missing"@@ -202,8 +198,7 @@ class TestPluginInitSelfRegisters:init_path = plugin_dir / "__init__.py"assert router_path.exists(), (- f"nodes/{plugin}/_router.py missing -- remove {plugin!r} "- "from _PLUGINS_WITH_ROUTERS or restore the file."+ f"nodes/{plugin}/_router.py missing -- remove {plugin!r} " "from _PLUGINS_WITH_ROUTERS or restore the file.")assert init_path.exists(), f"nodes/{plugin}/__init__.py missing"@@ -221,14 +216,8 @@ class TestPluginInitSelfRegisters:Catches a new plugin that ships a handler / router but forgotto add itself to the parametrize list."""- actual_handlers = {- p for p in _MIGRATED_PLUGINS- if (_SERVER_ROOT / "nodes" / p / "_handlers.py").exists()- }- actual_routers = {- p for p in _MIGRATED_PLUGINS- if (_SERVER_ROOT / "nodes" / p / "_router.py").exists()- }+ actual_handlers = {p for p in _MIGRATED_PLUGINS if (_SERVER_ROOT / "nodes" / p / "_handlers.py").exists()}+ actual_routers = {p for p in _MIGRATED_PLUGINS if (_SERVER_ROOT / "nodes" / p / "_router.py").exists()}assert set(_PLUGINS_WITH_HANDLERS) == actual_handlers, (f"_PLUGINS_WITH_HANDLERS drifted from filesystem: "f"declared={sorted(_PLUGINS_WITH_HANDLERS)}, "@@ -268,19 +257,19 @@ _STALE_SERVICE_PATHS = ("services/twitter_oauth.py","services/google_oauth.py","services/handlers/google_auth.py",- "services/android", # the relay sub-package+ "services/android", # the relay sub-package"services/android_service.py","services/browser_service.py","services/email_service.py","services/himalaya_service.py","services/claude_code_service.py",- "services/websocket_client.py", # dead re-export shim, deleted in E- "services/maps.py", # Wave 11.I, N: -> nodes/location/_service.py- "services/node_option_loaders", # Wave 11.I, M: -> nodes/<plugin>/_option_loaders.py+ "services/websocket_client.py", # dead re-export shim, deleted in E+ "services/maps.py", # Wave 11.I, N: -> nodes/location/_service.py+ "services/node_option_loaders", # Wave 11.I, M: -> nodes/<plugin>/_option_loaders.py"routers/twitter.py","routers/google.py","routers/android.py",- "routers/maps.py", # Wave 11.I, N: deleted (all 4 endpoints dead)+ "routers/maps.py", # Wave 11.I, N: deleted (all 4 endpoints dead))@@ -320,10 +309,9 @@ class TestMainPyDoesNotMountPluginRouters:assert main_path.exists(), "server/main.py missing"src = main_path.read_text(encoding="utf-8")offenders = [- name for name in self._MIGRATED_ROUTER_NAMES- if f"app.include_router({name}.router)" in src- or f"from routers import {name}" in src- or f"from routers.{name}" in src+ name+ for name in self._MIGRATED_ROUTER_NAMES+ if f"app.include_router({name}.router)" in src or f"from routers import {name}" in src or f"from routers.{name}" in src]assert not offenders, (f"server/main.py explicitly mounts/imports migrated plugin routers: "@@ -338,10 +326,7 @@ class TestMainPyDoesNotMountPluginRouters:for absent modules raise at startup."""main_path = _SERVER_ROOT / "main.py"src = main_path.read_text(encoding="utf-8")- offenders = [- f"routers.{name}" for name in self._MIGRATED_ROUTER_NAMES- if f'"routers.{name}"' in src- ]+ offenders = [f"routers.{name}" for name in self._MIGRATED_ROUTER_NAMES if f'"routers.{name}"' in src]assert not offenders, (f"server/main.py container.wire(...) names removed plugin modules: "f"{offenders}. Drop these entries -- the plugin packages wire their "@@ -366,8 +351,7 @@ class TestPluginHandlersDictsArePopulated:def test_plugin_handlers_dict_non_empty(self, plugin: str):handlers_path = _SERVER_ROOT / "nodes" / plugin / "_handlers.py"assert handlers_path.exists(), (- f"nodes/{plugin}/_handlers.py missing -- remove {plugin!r} "- "from _PLUGINS_WITH_HANDLERS or restore the file."+ f"nodes/{plugin}/_handlers.py missing -- remove {plugin!r} " "from _PLUGINS_WITH_HANDLERS or restore the file.")src = handlers_path.read_text(encoding="utf-8")@@ -404,17 +388,11 @@ class TestPluginHandlersDictsArePopulated:# Underscore-prefixed siblings (``_service.py`` / ``_credentials.py``,# ``_relay/``, etc.) are package-private and skipped by the walker.def _public_plugin_files(plugin_dir: Path) -> list[Path]:- flat = [- p for p in plugin_dir.glob("*.py")- if not p.name.startswith("_") and p.name != "__init__.py"- ]+ flat = [p for p in plugin_dir.glob("*.py") if not p.name.startswith("_") and p.name != "__init__.py"]nested = [sub / "__init__.py"for sub in plugin_dir.iterdir()- if sub.is_dir()- and not sub.name.startswith("_")- and sub.name != "__pycache__"- and (sub / "__init__.py").exists()+ if sub.is_dir() and not sub.name.startswith("_") and sub.name != "__pycache__" and (sub / "__init__.py").exists()]return flat + nesteddiff --git a/server/tests/test_polling_trigger_workflow.py b/server/tests/test_polling_trigger_workflow.pyindex 316e93d7..21cda51d 100644--- a/server/tests/test_polling_trigger_workflow.py+++ b/server/tests/test_polling_trigger_workflow.py@@ -132,12 +132,14 @@ class TestAsPollActivity:activity_fn = cls.as_poll_activity()inner = self._underlying(activity_fn)- result = await inner({- "node_id": "n1",- "params": {},- "seen_ids": [],- "baseline_only": True,- })+ result = await inner(+ {+ "node_id": "n1",+ "params": {},+ "seen_ids": [],+ "baseline_only": True,+ }+ )assert result["events"] == []assert set(result["seen_ids"]) == {"a", "b", "c"}@@ -148,12 +150,14 @@ class TestAsPollActivity:activity_fn = cls.as_poll_activity()inner = self._underlying(activity_fn)- result = await inner({- "node_id": "n1",- "params": {},- "seen_ids": ["a", "b"], # b is seen; a/b not new; c/d new- "baseline_only": False,- })+ result = await inner(+ {+ "node_id": "n1",+ "params": {},+ "seen_ids": ["a", "b"], # b is seen; a/b not new; c/d new+ "baseline_only": False,+ }+ )new_ids = {e["id"] for e in result["events"]}assert new_ids == {"c", "d"}@@ -177,21 +181,20 @@ class TestAsPollActivity:activity_fn = cls.as_poll_activity()inner = self._underlying(activity_fn)- result = await inner({- "node_id": "n1",- "params": {},- # Carry-forward from an earlier cycle.- "seen_ids": ["a", "b", "c", "d", "e"],- "baseline_only": False,- })+ result = await inner(+ {+ "node_id": "n1",+ "params": {},+ # Carry-forward from an earlier cycle.+ "seen_ids": ["a", "b", "c", "d", "e"],+ "baseline_only": False,+ }+ )# Only the genuinely new id (``f``) emits — ``e`` was already# in prior_seen.new_ids = {ev["id"] for ev in result["events"]}- assert new_ids == {"f"}, (- "Only items in ``current`` that weren't in ``prior_seen`` "- "should emit."- )+ assert new_ids == {"f"}, "Only items in ``current`` that weren't in ``prior_seen`` " "should emit."# And the returned seen_ids must NOT contain a/b/c/d — those# are gone from the provider's window. If they linger, every# subsequent cycle pays Temporal-payload cost for IDs that will@@ -220,12 +223,14 @@ class TestAsPollActivity:activity_fn = cls.as_poll_activity()inner = self._underlying(activity_fn)- result = await inner({- "node_id": "n1",- "params": {},- "seen_ids": [],- "baseline_only": False,- })+ result = await inner(+ {+ "node_id": "n1",+ "params": {},+ "seen_ids": [],+ "baseline_only": False,+ }+ )assert len(result["events"]) == 1assert result["events"][0]["id"] == "x"@@ -244,12 +249,14 @@ class TestAsPollActivity:activity_fn = cls.as_poll_activity()inner = self._underlying(activity_fn)- result = await inner({- "node_id": "n1",- "params": {},- "seen_ids": [],- "baseline_only": False,- })+ result = await inner(+ {+ "node_id": "n1",+ "params": {},+ "seen_ids": [],+ "baseline_only": False,+ }+ )# Both events still came through even though post_emit raised.assert {e["id"] for e in result["events"]} == {"x", "y"}@@ -290,10 +297,17 @@ class TestPollCoroutineSeenSetBounded:type = "introspect.bound"display_name = "Introspect"- async def setup_service(self, params): return MagicMock()- async def fetch_ids(self, service, params): return set()- async def fetch_detail(self, service, msg_id, params): return {"id": msg_id}- async def post_emit(self, service, msg_id, params): pass+ async def setup_service(self, params):+ return MagicMock()++ async def fetch_ids(self, service, params):+ return set()++ async def fetch_detail(self, service, msg_id, params):+ return {"id": msg_id}++ async def post_emit(self, service, msg_id, params):+ pass# _build_poll_coroutine returns a closure; introspect the# MRO-resolved method body instead. Strip comments and@@ -333,20 +347,22 @@ class TestPollingTriggerWorkflowBody:from services.temporal import polling_trigger_workflow as pmod# Activity returns scripted responses per call.- responses = iter([- # Baseline cycle.- {"events": [], "seen_ids": ["a", "b"]},- # Second cycle: new id 'c'.- {"events": [{"id": "c", "payload": "hello"}], "seen_ids": ["a", "b", "c"]},- # Third cycle: same id 'c' (dedup test) + new 'd'.- {- "events": [- {"id": "c", "payload": "dup"},- {"id": "d", "payload": "fresh"},- ],- "seen_ids": ["a", "b", "c", "d"],- },- ])+ responses = iter(+ [+ # Baseline cycle.+ {"events": [], "seen_ids": ["a", "b"]},+ # Second cycle: new id 'c'.+ {"events": [{"id": "c", "payload": "hello"}], "seen_ids": ["a", "b", "c"]},+ # Third cycle: same id 'c' (dedup test) + new 'd'.+ {+ "events": [+ {"id": "c", "payload": "dup"},+ {"id": "d", "payload": "fresh"},+ ],+ "seen_ids": ["a", "b", "c", "d"],+ },+ ]+ )from temporalio import workflow as temporal_workflow@@ -540,17 +556,17 @@ class TestCollectPollingActivities:activities = collect_polling_activities()# Activity name format: "poll.{type}.v{version}"- names = {getattr(a, "__temporal_activity_definition", None) and- getattr(a, "__temporal_activity_definition").name- or getattr(a, "_name", None) for a in activities}+ names = {+ getattr(a, "__temporal_activity_definition", None)+ and getattr(a, "__temporal_activity_definition").name+ or getattr(a, "_name", None)+ for a in activities+ }# We can't always extract the activity name (Temporal stores# it on a metadata attribute that varies by SDK version) — at# minimum assert the gmail polling activity is present by# inspecting any name-like attribute.flat = " ".join(str(n) for n in names)- assert "poll.googleGmailReceive" in flat or any(- "googleGmailReceive" in str(n) for n in names- ), (- "collect_polling_activities() should include the gmail "- f"polling activity. Got names: {names}"+ assert "poll.googleGmailReceive" in flat or any("googleGmailReceive" in str(n) for n in names), (+ "collect_polling_activities() should include the gmail " f"polling activity. Got names: {names}")diff --git a/server/tests/test_retry_policies.py b/server/tests/test_retry_policies.pyindex 51c87a90..ad1708ba 100644--- a/server/tests/test_retry_policies.py+++ b/server/tests/test_retry_policies.py@@ -122,11 +122,14 @@ class TestWorkflowsImportSharedConstant:"""The three workflow files that execute activities must import theshared constant. Source-introspection only — no Temporal runtime."""- @pytest.mark.parametrize("module_path,expected_constant", [- ("services.temporal.workflow", "DEFAULT_ACTIVITY_RETRY"),- ("services.temporal.agent_workflow", "DEFAULT_ACTIVITY_RETRY"),- ("services.temporal.polling_trigger_workflow", "DEFAULT_ACTIVITY_RETRY"),- ])+ @pytest.mark.parametrize(+ "module_path,expected_constant",+ [+ ("services.temporal.workflow", "DEFAULT_ACTIVITY_RETRY"),+ ("services.temporal.agent_workflow", "DEFAULT_ACTIVITY_RETRY"),+ ("services.temporal.polling_trigger_workflow", "DEFAULT_ACTIVITY_RETRY"),+ ],+ )def test_imports_shared_constant(self, module_path, expected_constant):try:mod = __import__(module_path, fromlist=[expected_constant])diff --git a/server/tests/test_service_factories.py b/server/tests/test_service_factories.pyindex c4b78488..887a0475 100644--- a/server/tests/test_service_factories.py+++ b/server/tests/test_service_factories.py@@ -143,10 +143,13 @@ class TestContainerHasNoCrossPluginServiceImports:class TestPluginSelfRegistration:"""Smoke: importing each plugin populates the registry."""- @pytest.mark.parametrize("plugin_module,expected_name", [- ("nodes.location", "maps"),- ("nodes.android", "android"),- ])+ @pytest.mark.parametrize(+ "plugin_module,expected_name",+ [+ ("nodes.location", "maps"),+ ("nodes.android", "android"),+ ],+ )def test_plugin_import_registers_its_factory(self, plugin_module, expected_name):from services.plugin import service_factories as sfdiff --git a/server/tests/test_shutdown_hooks.py b/server/tests/test_shutdown_hooks.pyindex d58b4c7b..e5d536dc 100644--- a/server/tests/test_shutdown_hooks.py+++ b/server/tests/test_shutdown_hooks.py@@ -178,10 +178,13 @@ class TestNoCrossPluginShutdownReachesInMain:class TestPluginSelfRegistration:"""Smoke: importing each plugin populates the registry."""- @pytest.mark.parametrize("plugin_module,expected_label", [- ("nodes.android", "android_relay"),- ("nodes.browser", "browser_service"),- ])+ @pytest.mark.parametrize(+ "plugin_module,expected_label",+ [+ ("nodes.android", "android_relay"),+ ("nodes.browser", "browser_service"),+ ],+ )def test_plugin_import_registers_its_hook(self, plugin_module, expected_label):from services.plugin import shutdown_hooks as sh@@ -192,7 +195,5 @@ class TestPluginSelfRegistration:labels = sh.registered_labels()assert expected_label in labels, (- f"Importing {plugin_module} should call "- f"register_shutdown_hook({expected_label!r}, ...). "- f"Current labels: {labels}"+ f"Importing {plugin_module} should call " f"register_shutdown_hook({expected_label!r}, ...). " f"Current labels: {labels}")diff --git a/server/tests/test_social_provider_registry.py b/server/tests/test_social_provider_registry.pyindex d6f4acee..5c76926a 100644--- a/server/tests/test_social_provider_registry.py+++ b/server/tests/test_social_provider_registry.py@@ -103,9 +103,13 @@ class TestRegistryContract:for p in ("whatsapp", "telegram", "slack"):fresh_registry.register_social_send_handler(p, h)- assert fresh_registry.registered_platforms() == frozenset({- "whatsapp", "telegram", "slack",- })+ assert fresh_registry.registered_platforms() == frozenset(+ {+ "whatsapp",+ "telegram",+ "slack",+ }+ )class TestNoCrossPluginReachInSocialBase:diff --git a/server/tests/test_status_broadcasts.py b/server/tests/test_status_broadcasts.pyindex 8a3343f0..e53f1bdf 100644--- a/server/tests/test_status_broadcasts.py+++ b/server/tests/test_status_broadcasts.py@@ -53,40 +53,44 @@ import pytest# with ``credential_catalogue_updated`` in the credential mutation# path) so frontend listeners always have a typed channel available# for state changes.-_TELEMETRY_CARVE_OUT: FrozenSet[str] = frozenset({- "update_api_key_status", # paired-wire with credential_catalogue_updated- "update_node_status", # ~hundreds per workflow run- "update_node_output", # paired with update_node_status- "update_variable", # per-write- "update_variables", # batch per-write- "update_workflow_status", # lifecycle ticks- "update_deployment_status", # lifecycle ticks- "broadcast_console_log", # log stream- "broadcast_terminal_log", # log stream- # Pure dispatcher -- iterates plugin-registered callbacks via- # TaskGroup, does not emit any broadcast itself. Per-plugin- # refresh callbacks live in nodes/<plugin>/_refresh.py and are- # subject to their own typed-envelope migration tracked outside- # the StatusBroadcaster class.- "_refresh_all_services",-})+_TELEMETRY_CARVE_OUT: FrozenSet[str] = frozenset(+ {+ "update_api_key_status", # paired-wire with credential_catalogue_updated+ "update_node_status", # ~hundreds per workflow run+ "update_node_output", # paired with update_node_status+ "update_variable", # per-write+ "update_variables", # batch per-write+ "update_workflow_status", # lifecycle ticks+ "update_deployment_status", # lifecycle ticks+ "broadcast_console_log", # log stream+ "broadcast_terminal_log", # log stream+ # Pure dispatcher -- iterates plugin-registered callbacks via+ # TaskGroup, does not emit any broadcast itself. Per-plugin+ # refresh callbacks live in nodes/<plugin>/_refresh.py and are+ # subject to their own typed-envelope migration tracked outside+ # the StatusBroadcaster class.+ "_refresh_all_services",+ }+)# Plugin status updates that still emit raw ``{type: 'X_status', data:# {...}}`` frames. The frontend's per-plugin status panels listen for# these wire-frames directly today; switching to a CloudEvents-typed# envelope is a frontend change too. Migration is per-plugin, not# included in milestone U scope.-_LEGACY_RAW_DICT_BROADCASTS: FrozenSet[str] = frozenset({- # Wave 12 B1: ``update_android_status`` retired; moved to- # ``nodes/android/_events.py:broadcast_android_status``.- # Wave 12 B2: ``update_whatsapp_status`` retired; moved to- # ``nodes/whatsapp/_events.py:broadcast_whatsapp_status``.- # Wave 12 B3: ``update_telegram_status`` retired; moved to- # ``nodes/telegram/_events.py:broadcast_telegram_status``. The- # shared ``_emit_connection_typed`` helper retired alongside (no- # remaining callers). Allowlist now empty — all three plugin-named- # broadcast methods live in their plugin folders.-})+_LEGACY_RAW_DICT_BROADCASTS: FrozenSet[str] = frozenset(+ {+ # Wave 12 B1: ``update_android_status`` retired; moved to+ # ``nodes/android/_events.py:broadcast_android_status``.+ # Wave 12 B2: ``update_whatsapp_status`` retired; moved to+ # ``nodes/whatsapp/_events.py:broadcast_whatsapp_status``.+ # Wave 12 B3: ``update_telegram_status`` retired; moved to+ # ``nodes/telegram/_events.py:broadcast_telegram_status``. The+ # shared ``_emit_connection_typed`` helper retired alongside (no+ # remaining callers). Allowlist now empty — all three plugin-named+ # broadcast methods live in their plugin folders.+ }+)# ``send_custom_event`` callers that still pass raw dicts. Each entry# documents WHY. Per-plugin migration unlocks each one.@@ -202,23 +206,18 @@ class TestEventWaiterDispatchAcceptsEnvelope:def test_unpack_event_present(self, event_waiter_module):assert hasattr(event_waiter_module, "_unpack_event"), (- "event_waiter must expose _unpack_event -- the normalisation "- "helper that lets dispatch() accept a WorkflowEvent directly."+ "event_waiter must expose _unpack_event -- the normalisation " "helper that lets dispatch() accept a WorkflowEvent directly.")def test_dispatch_calls_unpack_event(self, event_waiter_module):src = inspect.getsource(event_waiter_module.dispatch)assert "_unpack_event" in src, (- "dispatch() must route through _unpack_event() so a "- "WorkflowEvent argument is normalised before the dispatch loop."+ "dispatch() must route through _unpack_event() so a " "WorkflowEvent argument is normalised before the dispatch loop.")def test_dispatch_async_calls_unpack_event(self, event_waiter_module):src = inspect.getsource(event_waiter_module.dispatch_async)- assert "_unpack_event" in src, (- "dispatch_async() must route through _unpack_event() for the "- "same reason as dispatch()."- )+ assert "_unpack_event" in src, "dispatch_async() must route through _unpack_event() for the " "same reason as dispatch()."def test_unpack_event_handles_workflow_event(self, event_waiter_module):"""Functional check: a WorkflowEvent input round-trips to@@ -238,7 +237,8 @@ class TestEventWaiterDispatchAcceptsEnvelope:def test_unpack_event_handles_legacy_tuple_form(self, event_waiter_module):event_type, data = event_waiter_module._unpack_event(- "legacy.event.type", {"k": "v"},+ "legacy.event.type",+ {"k": "v"},)assert event_type == "legacy.event.type"assert data == {"k": "v"}@@ -275,13 +275,11 @@ class TestStatusBroadcastsUseTypedBuilder:legacy-grandfathered. If it appears in both, one of the twolists is wrong."""overlap = _TELEMETRY_CARVE_OUT & _LEGACY_RAW_DICT_BROADCASTS- assert not overlap, (- f"Methods in both _TELEMETRY_CARVE_OUT and "- f"_LEGACY_RAW_DICT_BROADCASTS: {sorted(overlap)}. Pick one."- )+ assert not overlap, f"Methods in both _TELEMETRY_CARVE_OUT and " f"_LEGACY_RAW_DICT_BROADCASTS: {sorted(overlap)}. Pick one."def test_status_methods_use_typed_builder_or_listed(- self, broadcaster_methods,+ self,+ broadcaster_methods,):offenders = []for name, body in broadcaster_methods.items():@@ -358,7 +356,10 @@ class TestStatusBroadcastsAlsoEmitTypedEnvelope:ids=[row[0] for row in _PLUGIN_WRAPPERS],)def test_plugin_wrapper_emits_typed_only(- self, plugin: str, module_path: str, wrapper_name: str,+ self,+ plugin: str,+ module_path: str,+ wrapper_name: str,retired_legacy_key: str,):"""Each plugin's broadcaster wrapper emits ONLY the typed@@ -379,8 +380,7 @@ class TestStatusBroadcastsAlsoEmitTypedEnvelope:mod_src = inspect.getsource(mod)# Positive: typed envelope channel still emitted.assert "plugin_connection_status" in mod_src, (- f"{module_path} must emit a typed CloudEvents envelope on "- f"``plugin_connection_status`` (the cross-plugin typed channel)."+ f"{module_path} must emit a typed CloudEvents envelope on " f"``plugin_connection_status`` (the cross-plugin typed channel).")# Negative: legacy raw wire key retired in D4.legacy_double = f'"{retired_legacy_key}"'@@ -456,10 +456,7 @@ class TestSendCustomEventPayload:comment explaining why typed-envelope migration is deferred."""# The status broadcaster file owns the definition; not a "caller".- callers = {- f for f in callsite_files- if not f.endswith("status_broadcaster.py")- }+ callers = {f for f in callsite_files if not f.endswith("status_broadcaster.py")}unknown = callers - _LEGACY_RAW_DICT_CALLSITES# New callers must EITHER appear in the allowlist OR pass a# WorkflowEvent -- the next test verifies the envelope@@ -527,8 +524,10 @@ class TestServiceRefreshCallbackSignature:continueparams = [- p for p in sig.parameters.values()- if p.kind in (+ p+ for p in sig.parameters.values()+ if p.kind+ in (inspect.Parameter.POSITIONAL_ONLY,inspect.Parameter.POSITIONAL_OR_KEYWORD,)@@ -536,21 +535,13 @@ class TestServiceRefreshCallbackSignature:required = [p for p in params if p.default is inspect.Parameter.empty]# Must accept at least one positional arg (the broadcaster);# additional defaults are fine, varargs (*args) is fine.- accepts_one_positional = (- any(- p.kind == inspect.Parameter.VAR_POSITIONAL- for p in sig.parameters.values()- )- or len(params) >= 1- )+ accepts_one_positional = any(p.kind == inspect.Parameter.VAR_POSITIONAL for p in sig.parameters.values()) or len(params) >= 1# Must NOT require MORE than one positional — the framework# only supplies the broadcaster, nothing else.too_many_required = len(required) > 1if not accepts_one_positional or too_many_required:- offenders.append(- f"{cb.__module__}.{cb.__qualname__}{sig}"- )+ offenders.append(f"{cb.__module__}.{cb.__qualname__}{sig}")assert not offenders, (f"register_service_refresh callbacks must accept the "diff --git a/server/tests/test_telegram_trigger_canary_producer.py b/server/tests/test_telegram_trigger_canary_producer.pyindex b3317df9..548fee67 100644--- a/server/tests/test_telegram_trigger_canary_producer.py+++ b/server/tests/test_telegram_trigger_canary_producer.py@@ -76,12 +76,14 @@ class TestTelegramProducerCanaryEmit:monkeypatch.setattr(dispatch_mod, "emit", fake_emit)- result = await _events.dispatch_telegram_message_received({- "chat_id": 12345,- "text": "hello bot",- "from_id": 999,- "timestamp": "2026-05-14T00:00:00",- })+ result = await _events.dispatch_telegram_message_received(+ {+ "chat_id": 12345,+ "text": "hello bot",+ "from_id": 999,+ "timestamp": "2026-05-14T00:00:00",+ }+ )assert result is Nonediff --git a/server/tests/test_tool_registry.py b/server/tests/test_tool_registry.pyindex 860683d5..3113bb0c 100644--- a/server/tests/test_tool_registry.py+++ b/server/tests/test_tool_registry.py@@ -53,15 +53,9 @@ def test_legacy_tool_dicts_removed():"Wave 12 D5 migrated this data to per-plugin ClassVars; the legacy ""compat fallback was deleted.")- assert "_LEGACY_TOOL_DESCRIPTIONS = {" not in source, (- "_LEGACY_TOOL_DESCRIPTIONS dict reintroduced into services/ai.py."- )- assert "DEFAULT_TOOL_NAMES = {" not in source, (- "Pre-D5 DEFAULT_TOOL_NAMES dict reintroduced into services/ai.py."- )- assert "DEFAULT_TOOL_DESCRIPTIONS = {" not in source, (- "Pre-D5 DEFAULT_TOOL_DESCRIPTIONS dict reintroduced into services/ai.py."- )+ assert "_LEGACY_TOOL_DESCRIPTIONS = {" not in source, "_LEGACY_TOOL_DESCRIPTIONS dict reintroduced into services/ai.py."+ assert "DEFAULT_TOOL_NAMES = {" not in source, "Pre-D5 DEFAULT_TOOL_NAMES dict reintroduced into services/ai.py."+ assert "DEFAULT_TOOL_DESCRIPTIONS = {" not in source, "Pre-D5 DEFAULT_TOOL_DESCRIPTIONS dict reintroduced into services/ai.py."def test_pseudo_tool_fallback_has_two_entries():@@ -73,14 +67,15 @@ def test_pseudo_tool_fallback_has_two_entries():delegation-tracking surface in ``services/handlers/tools.py``.- ``androidTool`` — toolkit aggregator that fans out to connectedandroid service plugins at LLM-tool call time.++ Quote-agnostic so ruff format's choice of single vs. double quotes+ doesn't trip the substring check."""source = _ai_source()- assert "'_builtin_check_delegated_tasks'" in source, (- "_builtin_check_delegated_tasks missing from _PSEUDO_TOOL_FALLBACK"- )- assert "'androidTool'" in source, (- "androidTool missing from _PSEUDO_TOOL_FALLBACK"- )+ assert (+ "'_builtin_check_delegated_tasks'" in source or '"_builtin_check_delegated_tasks"' in source+ ), "_builtin_check_delegated_tasks missing from _PSEUDO_TOOL_FALLBACK"+ assert "'androidTool'" in source or '"androidTool"' in source, "androidTool missing from _PSEUDO_TOOL_FALLBACK"@pytest.mark.parametrize("node_type,expected_tool_name", list(_load_snapshot().items()))diff --git a/server/tests/test_workflow_ops.py b/server/tests/test_workflow_ops.pyindex 6eb9eef4..41d29414 100644--- a/server/tests/test_workflow_ops.py+++ b/server/tests/test_workflow_ops.py@@ -43,9 +43,7 @@ def test_add_node_with_label_and_parameters():label="Master Skill",)assert op["label"] == "Master Skill"- assert op["parameters"] == {- "skillsConfig": {"http-request-skill": {"enabled": True}}- }+ assert op["parameters"] == {"skillsConfig": {"http-request-skill": {"enabled": True}}}def test_add_node_with_anchored_position():diff --git a/server/tests/test_workflow_validator.py b/server/tests/test_workflow_validator.pyindex 6a655462..2bf30aa2 100644--- a/server/tests/test_workflow_validator.py+++ b/server/tests/test_workflow_validator.py@@ -139,9 +139,9 @@ async def test_invalid_param_is_warning(monkeypatch):)codes = [iss["code"] for iss in report["warnings"]]assert "INVALID_PARAM" in codes- assert all(iss["code"] != "INVALID_PARAM" for iss in report["errors"]), (- "INVALID_PARAM must not block execution; only deploy-time errors block."- )+ assert all(+ iss["code"] != "INVALID_PARAM" for iss in report["errors"]+ ), "INVALID_PARAM must not block execution; only deploy-time errors block."async def test_missing_credential_is_warning(monkeypatch):@@ -268,12 +268,10 @@ class TestExecuteAndDeployHandlersGate:src = self._handler_source(ws_module.handle_execute_workflow)assert "validate_workflow" in src, (- "handle_execute_workflow must call validate_workflow so "- "broken workflows are blocked at the gate (force=true overrides)."+ "handle_execute_workflow must call validate_workflow so " "broken workflows are blocked at the gate (force=true overrides).")assert "force" in src, (- "handle_execute_workflow must support the force=true override "- "so 'Run anyway' can bypass warnings (Windmill pattern)."+ "handle_execute_workflow must support the force=true override " "so 'Run anyway' can bypass warnings (Windmill pattern).")def test_deploy_workflow_calls_validator_unconditionally(self):@@ -292,8 +290,7 @@ class TestExecuteAndDeployHandlersGate:from routers import websocket as ws_moduleassert "validate_workflow" in ws_module.MESSAGE_HANDLERS, (- "validate_workflow message type must be in MESSAGE_HANDLERS "- "so the frontend live-lint and import dry-run paths can reach it."+ "validate_workflow message type must be in MESSAGE_HANDLERS " "so the frontend live-lint and import dry-run paths can reach it.")def test_example_loader_calls_validator(self):@@ -304,8 +301,7 @@ class TestExecuteAndDeployHandlersGate:src = inspect.getsource(example_loader.import_examples_for_user)assert "validate_workflow" in src, (- "import_examples_for_user must run validate_workflow before "- "save_workflow — broken examples shipped on disk are bugs."+ "import_examples_for_user must run validate_workflow before " "save_workflow — broken examples shipped on disk are bugs.")def test_example_loader_remaps_node_ids(self):@@ -319,8 +315,7 @@ class TestExecuteAndDeployHandlersGate:src = inspect.getsource(example_loader.import_examples_for_user)assert "remap_node_ids" in src, (- "import_examples_for_user must call workflow_import.remap_node_ids "- "before save_workflow / save_node_parameters."+ "import_examples_for_user must call workflow_import.remap_node_ids " "before save_workflow / save_node_parameters.")@@ -341,9 +336,7 @@ class TestRemapNodeIds:a_ids = {n["id"] for n in a_nodes}b_ids = {n["id"] for n in b_nodes}- assert a_ids.isdisjoint(b_ids), (- f"Remap must produce disjoint id sets, got overlap: {a_ids & b_ids}"- )+ assert a_ids.isdisjoint(b_ids), f"Remap must produce disjoint id sets, got overlap: {a_ids & b_ids}"def test_remap_rewrites_edge_refs(self):"""Edges must point at the new node ids; no dangling references."""@@ -366,9 +359,7 @@ class TestRemapNodeIds:from services.workflow_import import remap_node_idsnodes = [{"id": "orig-1", "type": "telegramSend", "data": {}}]- new_nodes, _, new_params = remap_node_ids(- nodes, [], {"orig-1": {"text": "hello"}}- )+ new_nodes, _, new_params = remap_node_ids(nodes, [], {"orig-1": {"text": "hello"}})assert "orig-1" not in new_paramsassert new_nodes[0]["id"] in new_paramsassert new_params[new_nodes[0]["id"]] == {"text": "hello"}@@ -410,10 +401,7 @@ class TestRemapNodeIds:all_ids[node["id"]].append(path)collisions = {k: v for k, v in all_ids.items() if len(v) > 1}- assert not collisions, (- f"Remap should produce disjoint ids across all example "- f"workflows; found collisions: {collisions}"- )+ assert not collisions, f"Remap should produce disjoint ids across all example " f"workflows; found collisions: {collisions}"# ---------------------------------------------------------------------------@@ -434,9 +422,7 @@ def _fake_database(existing_names: list[str] | None = None):saved_params: dict[str, dict] = {}db = MagicMock()- db.get_all_workflows = AsyncMock(- return_value=[_FakeWorkflow(n) for n in (existing_names or [])]- )+ db.get_all_workflows = AsyncMock(return_value=[_FakeWorkflow(n) for n in (existing_names or [])])async def save_workflow(**kwargs):saved_workflows.append(kwargs)@@ -610,19 +596,14 @@ class TestImportWorkflowOrchestrator:"nodeParameters": {"orig-1": {"x": 1}},}r1 = await import_workflow(payload, auth_service=auth, database=db)- r2 = await import_workflow(- {**payload, "name": "Remap B"}, auth_service=auth, database=db- )+ r2 = await import_workflow({**payload, "name": "Remap B"}, auth_service=auth, database=db)# Saved node ids must differ across the two imports.saved_a_nodes = db._saved_workflows[0]["data"]["nodes"]saved_b_nodes = db._saved_workflows[1]["data"]["nodes"]a_ids = {n["id"] for n in saved_a_nodes}b_ids = {n["id"] for n in saved_b_nodes}- assert a_ids.isdisjoint(b_ids), (- f"Two imports of the same JSON must produce disjoint node ids; "- f"overlap: {a_ids & b_ids}"- )+ assert a_ids.isdisjoint(b_ids), f"Two imports of the same JSON must produce disjoint node ids; " f"overlap: {a_ids & b_ids}"# Parameters saved under the NEW ids, not the original.assert "orig-1" not in db._saved_paramsassert len(db._saved_params) >= 2 # both r1 and r2 saved their params@@ -649,10 +630,7 @@ class TestImportWorkflowOrchestrator:auth_service=auth,database=db,)- assert len(calls) == 1, (- "import_workflow save path must call broadcast_workflow_lifecycle "- "exactly once on success."- )+ assert len(calls) == 1, "import_workflow save path must call broadcast_workflow_lifecycle " "exactly once on success."stage, kwargs = calls[0]assert stage == "imported"assert kwargs["workflow_id"].startswith("workflow-")@@ -685,7 +663,8 @@ def _patch_broadcaster(monkeypatch):stub = _StubBroadcaster()monkeypatch.setattr(- "services.status_broadcaster.get_status_broadcaster", lambda: stub,+ "services.status_broadcaster.get_status_broadcaster",+ lambda: stub,)return stub, calls@@ -707,10 +686,12 @@ class TestExtractRequirements:}.get(t),)- reqs = extract_requirements([- {"id": "n1", "type": "fakeNode"},- {"id": "n2", "type": "fakeNodeless"},- ])+ reqs = extract_requirements(+ [+ {"id": "n1", "type": "fakeNode"},+ {"id": "n2", "type": "fakeNodeless"},+ ]+ )cred_ids = [c["provider_id"] for c in reqs["credentials"]]types = [n["type"] for n in reqs["nodes"]]assert "fake_provider" in cred_ids@@ -738,9 +719,7 @@ class TestCrossCheckCredentials:)auth = _fake_auth(has_valid_key_return=False)- missing = await cross_check_credentials(- {"credentials": [{"provider_id": "fake_provider"}]}, auth- )+ missing = await cross_check_credentials({"credentials": [{"provider_id": "fake_provider"}]}, auth)assert len(missing) == 1assert missing[0]["provider_id"] == "fake_provider"assert "display_name" in missing[0]@@ -750,9 +729,7 @@ class TestCrossCheckCredentials:from services.workflow_import import cross_check_credentialsauth = _fake_auth(has_valid_key_return=True)- missing = await cross_check_credentials(- {"credentials": [{"provider_id": "x"}]}, auth- )+ missing = await cross_check_credentials({"credentials": [{"provider_id": "x"}]}, auth)assert missing == []@@ -797,8 +774,7 @@ class TestCloudEventsBroadcastShape:"are consistent with the rest of the CloudEvents surface.")assert '"workflow_lifecycle"' in src, (- "wire-format key must be 'workflow_lifecycle' so the frontend "- "WebSocketContext.tsx case statement routes correctly."+ "wire-format key must be 'workflow_lifecycle' so the frontend " "WebSocketContext.tsx case statement routes correctly.")def test_import_workflow_emits_imported_lifecycle(self):@@ -808,10 +784,8 @@ class TestCloudEventsBroadcastShape:src = inspect.getsource(workflow_import.import_workflow)assert "broadcast_workflow_lifecycle" in src, (- "import_workflow save path must broadcast via "- "broadcast_workflow_lifecycle so connected clients refresh."+ "import_workflow save path must broadcast via " "broadcast_workflow_lifecycle so connected clients refresh.")assert '"imported"' in src, (- "import_workflow must use the 'imported' lifecycle stage "- "(matches WorkflowEvent.workflow_lifecycle Literal)."+ "import_workflow must use the 'imported' lifecycle stage " "(matches WorkflowEvent.workflow_lifecycle Literal).")