fix: use shared bound cron predicate
maintainer edit: make gateway execution, WebUI automation listing, and delete protection agree on the new bound cron shape. Legacy delivery payloads that carry sessionKey are excluded from the WebUI-bound automation surface.
This commit is contained in:
@@ -4,6 +4,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Mapping
|
||||
|
||||
from nanobot.cron.types import CronJob
|
||||
|
||||
AUTOMATION_TRIGGER_META = "_automation_trigger"
|
||||
AUTOMATION_DEFER_UNTIL_IDLE_META = "_defer_until_session_idle"
|
||||
|
||||
@@ -31,3 +33,16 @@ def automation_run_id(metadata: Mapping[str, Any] | None) -> str | None:
|
||||
return None
|
||||
value = trigger.get("run_id")
|
||||
return value if isinstance(value, str) and value else None
|
||||
|
||||
|
||||
def is_bound_agent_job(job: CronJob) -> bool:
|
||||
"""True for new session-bound user automations, excluding legacy delivery payloads."""
|
||||
payload = job.payload
|
||||
if payload.kind != "agent_turn" or not payload.session_key:
|
||||
return False
|
||||
return not (
|
||||
payload.deliver
|
||||
or payload.channel
|
||||
or payload.to
|
||||
or payload.channel_meta
|
||||
)
|
||||
|
||||
@@ -14,6 +14,7 @@ from typing import Any, Callable, Coroutine, Literal
|
||||
from filelock import FileLock
|
||||
from loguru import logger
|
||||
|
||||
from nanobot.cron.automation import is_bound_agent_job
|
||||
from nanobot.cron.types import (
|
||||
CronJob,
|
||||
CronJobState,
|
||||
@@ -508,7 +509,7 @@ class CronService:
|
||||
return [
|
||||
job
|
||||
for job in self.list_jobs(include_disabled=include_disabled)
|
||||
if job.payload.kind == "agent_turn"
|
||||
if is_bound_agent_job(job)
|
||||
and job.payload.session_key == session_key
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user