Files
agentic-mobile-control/packages/cloud-platform/cloud/sdk/models.py
T
q792602257andClaude Opus 4.6 2169bb03d9 feat(cloud-console): task listing, attempt history, CORS, and console SPA
Implements the cloud-console OpenSpec change: adds GET /v1/tasks (filterable,
bounded pagination, tasks:read) and GET /v1/tasks/{id}/attempts (404 on unknown
task) to the platform SDK, with matching CloudClient methods and a closed-by-
default CLOUD_CONSOLE_CORS_ORIGINS allow-list wired through CloudControlConfig.
Ships an independent Vue 3 + Vite SPA at cloud-console/ that authenticates with
an operator-supplied bearer token held in sessionStorage, renders tasks with
attempt history, device pool, host registry, and the plugin registry with a
registration form.

Backend test suite: 438 passed (-m "not integration"); cloud-console typecheck
and production build both succeed. PostgreSQL-backed repository tests and
manual end-to-end verification remain pending external infrastructure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-07-13 14:00:23 +08:00

102 lines
2.2 KiB
Python

"""Pydantic request/response models for the platform SDK REST API."""
from __future__ import annotations
from datetime import datetime
from typing import Any, Literal
from pydantic import BaseModel, Field
class TaskConstraintsModel(BaseModel):
driver_type: str | None = None
capability_tags: list[str] = Field(default_factory=list)
class TaskSubmissionRequest(BaseModel):
goal: str | None = None
workflow_definition_id: str | None = None
constraints: TaskConstraintsModel = Field(default_factory=TaskConstraintsModel)
class TaskSubmissionResponse(BaseModel):
task_id: str
class TaskStatusResponse(BaseModel):
id: str
status: str
goal: str | None = None
workflow_definition_id: str | None = None
assigned_device_id: str | None = None
assigned_host_id: str | None = None
attempt_count: int = 0
lease_expires_at: datetime | None = None
failure_reason: str | None = None
class TaskListItem(BaseModel):
id: str
status: str
goal: str | None = None
workflow_definition_id: str | None = None
assigned_device_id: str | None = None
assigned_host_id: str | None = None
attempt_count: int = 0
failure_reason: str | None = None
created_at: datetime
class TaskListResponse(BaseModel):
items: list[TaskListItem]
total: int
limit: int
offset: int
class TaskAttemptResponse(BaseModel):
task_id: str
attempt: int
lease_id: str
host_id: str
device_id: str
status: str
lease_expires_at: datetime
created_at: datetime
completed_at: datetime | None = None
failure_reason: str | None = None
terminal_result: dict[str, Any] | None = None
class DeviceResponse(BaseModel):
device_id: str
host_id: str
driver_type: str
status: str
capability_tags: list[str] = Field(default_factory=list)
class HostResponse(BaseModel):
host_id: str
address: str | None = None
last_seen_at: str
class PluginRegistrationRequest(BaseModel):
name: str
version: str
entry_point_kind: Literal["driver", "tool", "skill"]
target: str
class PluginResponse(BaseModel):
name: str
version: str
entry_point_kind: str
target: str
wired: bool
class ErrorResponse(BaseModel):
detail: str