feat(cloud): add targeted task governance foundation
Tests / Test passed: 659

This commit is contained in:
2026-07-13 22:21:12 +08:00
parent a3ba94be04
commit 2cd314b183
41 changed files with 2099 additions and 15 deletions
@@ -14,6 +14,7 @@ from cloud.internal_api.models import (
DeviceSnapshotModel,
HeartbeatResponse,
HostEnrollmentResponse,
HostTaskSubmissionResponse,
LeaseRenewalResponse,
TerminalResultResponse,
)
@@ -146,6 +147,7 @@ class HostAgentClient:
devices: list[DeviceSnapshotModel],
*,
address: str | None = None,
policy_revision: int = 0,
) -> HeartbeatResponse:
response = await self._request(
"PUT",
@@ -154,10 +156,28 @@ class HostAgentClient:
"host_id": self.config.host_id,
"address": address,
"devices": [device.model_dump(mode="json") for device in devices],
"policy_revision": policy_revision,
},
)
return HeartbeatResponse.model_validate(response.json())
async def submit_self_task(
self,
*,
goal: str,
device_id: str | None = None,
) -> HostTaskSubmissionResponse:
response = await self._request(
"POST",
f"/internal/v1/hosts/{self.config.host_id}/tasks",
json={
"host_id": self.config.host_id,
"goal": goal,
"device_id": device_id,
},
)
return HostTaskSubmissionResponse.model_validate(response.json())
async def claim(self) -> AssignmentModel | None:
response = await self._request(
"POST",