feat(agent-office): youtube_publisher 에이전트 + 30s 폴링

- YoutubePublisherAgent: 음악 파이프라인의 *_pending 상태를 폴링하여
  텔레그램 단일 채널로 단계별 검토 요청 발송, reply 수신 시 의도 분류
  후 music-lab에 feedback POST
- service_proxy: pipeline list/get/feedback/telegram-msg/lookup-by-msg
  헬퍼 5종 추가 (MUSIC_LAB_URL 사용)
- scheduler: 30초 interval로 poll_state_changes 실행
- telegram webhook: reply_to_message 가 파이프라인 메시지면
  youtube_publisher 로 라우팅 (슬래시 명령보다 우선)
- 테스트 4종 추가 (4 PASS)
This commit is contained in:
2026-05-07 17:20:21 +09:00
parent 17034ea6ea
commit 7552ce4263
7 changed files with 302 additions and 0 deletions

View File

@@ -103,6 +103,34 @@ def _build_messages(history: list, user_text: str) -> list:
return msgs
async def maybe_route_to_pipeline(message: dict) -> bool:
"""파이프라인 텔레그램 메시지에 대한 reply 인 경우 youtube_publisher 로 라우팅.
Returns True if message was routed (caller should stop further processing).
"""
reply_to = message.get("reply_to_message") or {}
msg_id = reply_to.get("message_id")
if not msg_id:
return False
from .. import service_proxy
try:
link = await service_proxy.lookup_pipeline_by_msg(msg_id)
except Exception:
return False
if not link:
return False
from ..agents import AGENT_REGISTRY
agent = AGENT_REGISTRY.get("youtube_publisher")
if not agent:
return False
pipeline_id = link.get("pipeline_id")
step = link.get("step")
if pipeline_id is None or not step:
return False
await agent.on_telegram_reply(pipeline_id, step, message.get("text", ""))
return True
async def respond_to_message(chat_id: str, user_text: str) -> Optional[str]:
"""자연어 메시지에 응답. 실패 시 사용자에게 돌려줄 문자열 반환(또는 None = 무시)."""
if not ANTHROPIC_API_KEY:

View File

@@ -102,6 +102,11 @@ async def _handle_message(message: dict, agent_dispatcher) -> Optional[dict]:
from .router import parse_command, resolve_agent_command, HELP_TEXT
from .messaging import send_raw, send_agent_message
from .agent_registry import AGENT_META
from .conversational import maybe_route_to_pipeline
# 파이프라인 메시지에 대한 reply라면 youtube_publisher 로 라우팅
if await maybe_route_to_pipeline(message):
return {"handled": "pipeline_reply"}
text = message.get("text", "")
parsed = parse_command(text)