feat(task-plane): add OpenClaw Codex Hermes adapters
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
"""Adapters for executing tasks via worker backends."""
|
||||
|
||||
from .base import WorkerAdapter
|
||||
from .openclaw import OpenClawAdapter
|
||||
from .codex import CodexAdapter
|
||||
from .hermes import HermesAdapter
|
||||
from .a2a import A2AAdapter
|
||||
from .systemd_worker import SystemdWorkerAdapter
|
||||
|
||||
__all__ = [
|
||||
"WorkerAdapter",
|
||||
"OpenClawAdapter",
|
||||
"CodexAdapter",
|
||||
"HermesAdapter",
|
||||
"A2AAdapter",
|
||||
"SystemdWorkerAdapter",
|
||||
]
|
||||
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import WorkerAdapter
|
||||
|
||||
|
||||
class A2AAdapter(WorkerAdapter):
|
||||
worker_name = "a2a"
|
||||
|
||||
def capabilities(self) -> list[str]:
|
||||
return ["task.exchange", "agent.handoff"]
|
||||
|
||||
def claim(self, task):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "claimed"}
|
||||
|
||||
def execute(self, task, claim):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "SHADOW_VERIFIED", "claim_id": claim.claim_id, "execution_mode": "shadow", "production_side_effects": False}
|
||||
|
||||
def heartbeat(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "alive"}
|
||||
|
||||
def report_progress(self, claim, progress):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "progress": progress}
|
||||
|
||||
def probe(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": claim.status}
|
||||
|
||||
def cancel(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "cancelled"}
|
||||
|
||||
def collect_result(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "result": "not_collected"}
|
||||
@@ -0,0 +1,41 @@
|
||||
"""Base worker adapter contract."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import abc
|
||||
|
||||
|
||||
class WorkerAdapter(abc.ABC):
|
||||
worker_name = "base"
|
||||
|
||||
@abc.abstractmethod
|
||||
def capabilities(self) -> list[str]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def claim(self, task):
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def execute(self, task, claim):
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def heartbeat(self, claim):
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def report_progress(self, claim, progress):
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def probe(self, claim):
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def cancel(self, claim):
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def collect_result(self, claim):
|
||||
raise NotImplementedError
|
||||
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import WorkerAdapter
|
||||
|
||||
|
||||
class CodexAdapter(WorkerAdapter):
|
||||
worker_name = "codex"
|
||||
|
||||
def capabilities(self) -> list[str]:
|
||||
return ["code.read", "code.write.patch", "test.python", "review.security"]
|
||||
|
||||
def claim(self, task):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "claimed"}
|
||||
|
||||
def execute(self, task, claim):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "SHADOW_VERIFIED", "claim_id": claim.claim_id, "execution_mode": "shadow", "production_side_effects": False}
|
||||
|
||||
def heartbeat(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "alive"}
|
||||
|
||||
def report_progress(self, claim, progress):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "progress": progress}
|
||||
|
||||
def probe(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": claim.status}
|
||||
|
||||
def cancel(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "cancelled"}
|
||||
|
||||
def collect_result(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "result": "not_collected"}
|
||||
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import WorkerAdapter
|
||||
|
||||
|
||||
class HermesAdapter(WorkerAdapter):
|
||||
worker_name = "hermes"
|
||||
|
||||
def capabilities(self) -> list[str]:
|
||||
return ["architecture.review", "policy.review", "threat.model"]
|
||||
|
||||
def claim(self, task):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "claimed"}
|
||||
|
||||
def execute(self, task, claim):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "SHADOW_VERIFIED", "claim_id": claim.claim_id, "execution_mode": "shadow", "production_side_effects": False}
|
||||
|
||||
def heartbeat(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "alive"}
|
||||
|
||||
def report_progress(self, claim, progress):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "progress": progress}
|
||||
|
||||
def probe(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": claim.status}
|
||||
|
||||
def cancel(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "cancelled"}
|
||||
|
||||
def collect_result(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "result": "not_collected"}
|
||||
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import WorkerAdapter
|
||||
|
||||
|
||||
class OpenClawAdapter(WorkerAdapter):
|
||||
worker_name = "openclaw"
|
||||
|
||||
def capabilities(self) -> list[str]:
|
||||
return ["code.read", "code.write.patch", "test.execute", "runtime.shadow"]
|
||||
|
||||
def claim(self, task):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "claimed"}
|
||||
|
||||
def execute(self, task, claim):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "SHADOW_VERIFIED", "claim_id": claim.claim_id, "execution_mode": "shadow", "production_side_effects": False}
|
||||
|
||||
def heartbeat(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "alive"}
|
||||
|
||||
def report_progress(self, claim, progress):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "progress": progress}
|
||||
|
||||
def probe(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": claim.status}
|
||||
|
||||
def cancel(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "cancelled"}
|
||||
|
||||
def collect_result(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "result": "not_collected"}
|
||||
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import WorkerAdapter
|
||||
|
||||
|
||||
class SystemdWorkerAdapter(WorkerAdapter):
|
||||
worker_name = "systemd_worker"
|
||||
|
||||
def capabilities(self) -> list[str]:
|
||||
return ["systemd.exec", "runtime.shell"]
|
||||
|
||||
def claim(self, task):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "claimed"}
|
||||
|
||||
def execute(self, task, claim):
|
||||
return {"worker": self.worker_name, "task_id": task.task_id, "status": "SHADOW_VERIFIED", "claim_id": claim.claim_id, "execution_mode": "shadow", "production_side_effects": False}
|
||||
|
||||
def heartbeat(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "alive"}
|
||||
|
||||
def report_progress(self, claim, progress):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "progress": progress}
|
||||
|
||||
def probe(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": claim.status}
|
||||
|
||||
def cancel(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "status": "cancelled"}
|
||||
|
||||
def collect_result(self, claim):
|
||||
return {"worker": self.worker_name, "claim_id": claim.claim_id, "result": "not_collected"}
|
||||
Reference in New Issue
Block a user