agentic-os/agents/trigger_bernard.py

42 lines
1.2 KiB
Python

"""Trigger Bernard workflows from local machine."""
from __future__ import annotations
import asyncio
import sys
from temporalio.client import Client
async def trigger_pr_review():
client = await Client.connect("localhost:7233", namespace="default")
handle = await client.start_workflow(
"PRReviewWorkflow",
id="bernard-pr-review-run-1",
task_queue="bernard",
)
print(f"PRReviewWorkflow started — ID: {handle.id}")
print("Waiting for result...")
result = await handle.result()
print(f"\n--- Result ---\n{result}")
async def trigger_monitor():
client = await Client.connect("localhost:7233", namespace="default")
handle = await client.start_workflow(
"TemporalMonitorWorkflow",
id="bernard-monitor-run-1",
task_queue="bernard",
)
print(f"TemporalMonitorWorkflow started — ID: {handle.id}")
print("Waiting for result...")
result = await handle.result()
print(f"\n--- Result ---\n{result}")
if __name__ == "__main__":
mode = sys.argv[1] if len(sys.argv) > 1 else "pr"
if mode == "monitor":
asyncio.run(trigger_monitor())
else:
asyncio.run(trigger_pr_review())