galaxis-agent/agent/tools/github_comment.py
2026-03-20 14:38:07 +09:00

29 lines
1.0 KiB
Python

import asyncio
from typing import Any
from langgraph.config import get_config
from ..utils.github_app import get_github_app_installation_token
from ..utils.github_comments import post_github_comment
def github_comment(message: str, issue_number: int) -> dict[str, Any]:
"""Post a comment to a GitHub issue or pull request."""
config = get_config()
configurable = config.get("configurable", {})
repo_config = configurable.get("repo", {})
if not issue_number:
return {"success": False, "error": "Missing issue_number argument"}
if not repo_config:
return {"success": False, "error": "No repo config found in config"}
if not message.strip():
return {"success": False, "error": "Message cannot be empty"}
token = asyncio.run(get_github_app_installation_token())
if not token:
return {"success": False, "error": "Failed to get GitHub App installation token"}
success = asyncio.run(post_github_comment(repo_config, issue_number, message, token=token))
return {"success": success}