feat: colibri task poller — agents can check assigned tasks
- scripts/colibri_poll.py: poll Colibri board for tasks assigned to an agent - PR opened on colibri: feat/cli-register-agent (register-agent + list-agents CLI)
This commit is contained in:
parent
5ebcc66b13
commit
0f6b5c4438
1 changed files with 21 additions and 0 deletions
21
scripts/colibri_poll.py
Executable file
21
scripts/colibri_poll.py
Executable file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Colibri task poller — checks the board for tasks assigned to an agent."""
|
||||||
|
import json, subprocess, sys, argparse
|
||||||
|
|
||||||
|
def poll(agent_name, socket_path, colibri_bin="colibri"):
|
||||||
|
result = subprocess.run(
|
||||||
|
[colibri_bin, "--socket", socket_path, "list-tasks", "--status", "started"],
|
||||||
|
capture_output=True, text=True, timeout=10
|
||||||
|
)
|
||||||
|
tasks = json.loads(result.stdout)
|
||||||
|
mine = [t for t in tasks if t.get("agent_name") == agent_name or t.get("agent_id") == agent_name]
|
||||||
|
print(json.dumps(mine, indent=2))
|
||||||
|
return 0 if mine else 1
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
p = argparse.ArgumentParser()
|
||||||
|
p.add_argument("--agent", required=True)
|
||||||
|
p.add_argument("--socket", required=True)
|
||||||
|
p.add_argument("--colibri", default="colibri")
|
||||||
|
args = p.parse_args()
|
||||||
|
sys.exit(poll(args.agent, args.socket, args.colibri))
|
||||||
Loading…
Add table
Reference in a new issue