Pivot persistent APIs to workspaces

Replace the public persistent-sandbox contract with workspace-first naming across CLI, SDK, MCP, payloads, and on-disk state.

Rename the task surface to workspace equivalents, switch create-time seeding to `seed_path`, and store records under `workspaces/<workspace_id>/workspace.json` without carrying legacy task aliases or migrating old local task state.

Keep `pyro run` and `vm_*` unchanged. Validation covered `uv lock`, focused public-contract/API/CLI/manager tests, `UV_CACHE_DIR=.uv-cache make check`, and `UV_CACHE_DIR=.uv-cache make dist-check`.
This commit is contained in:
Thales Maciel 2026-03-12 01:21:49 -03:00
parent f57454bcb4
commit 48b82d8386
13 changed files with 743 additions and 618 deletions

View file

@ -77,7 +77,7 @@ class Pyro:
def exec_vm(self, vm_id: str, *, command: str, timeout_seconds: int = 30) -> dict[str, Any]:
return self._manager.exec_vm(vm_id, command=command, timeout_seconds=timeout_seconds)
def create_task(
def create_workspace(
self,
*,
environment: str,
@ -86,44 +86,52 @@ class Pyro:
ttl_seconds: int = DEFAULT_TTL_SECONDS,
network: bool = False,
allow_host_compat: bool = DEFAULT_ALLOW_HOST_COMPAT,
source_path: str | Path | None = None,
seed_path: str | Path | None = None,
) -> dict[str, Any]:
return self._manager.create_task(
return self._manager.create_workspace(
environment=environment,
vcpu_count=vcpu_count,
mem_mib=mem_mib,
ttl_seconds=ttl_seconds,
network=network,
allow_host_compat=allow_host_compat,
source_path=source_path,
seed_path=seed_path,
)
def exec_task(
def exec_workspace(
self,
task_id: str,
workspace_id: str,
*,
command: str,
timeout_seconds: int = DEFAULT_TIMEOUT_SECONDS,
) -> dict[str, Any]:
return self._manager.exec_task(task_id, command=command, timeout_seconds=timeout_seconds)
return self._manager.exec_workspace(
workspace_id,
command=command,
timeout_seconds=timeout_seconds,
)
def status_task(self, task_id: str) -> dict[str, Any]:
return self._manager.status_task(task_id)
def status_workspace(self, workspace_id: str) -> dict[str, Any]:
return self._manager.status_workspace(workspace_id)
def push_task_sync(
def push_workspace_sync(
self,
task_id: str,
workspace_id: str,
source_path: str | Path,
*,
dest: str = "/workspace",
) -> dict[str, Any]:
return self._manager.push_task_sync(task_id, source_path=source_path, dest=dest)
return self._manager.push_workspace_sync(
workspace_id,
source_path=source_path,
dest=dest,
)
def logs_task(self, task_id: str) -> dict[str, Any]:
return self._manager.logs_task(task_id)
def logs_workspace(self, workspace_id: str) -> dict[str, Any]:
return self._manager.logs_workspace(workspace_id)
def delete_task(self, task_id: str) -> dict[str, Any]:
return self._manager.delete_task(task_id)
def delete_workspace(self, workspace_id: str) -> dict[str, Any]:
return self._manager.delete_workspace(workspace_id)
def stop_vm(self, vm_id: str) -> dict[str, Any]:
return self._manager.stop_vm(vm_id)
@ -249,57 +257,61 @@ class Pyro:
return self.reap_expired()
@server.tool()
async def task_create(
async def workspace_create(
environment: str,
vcpu_count: int = DEFAULT_VCPU_COUNT,
mem_mib: int = DEFAULT_MEM_MIB,
ttl_seconds: int = DEFAULT_TTL_SECONDS,
network: bool = False,
allow_host_compat: bool = DEFAULT_ALLOW_HOST_COMPAT,
source_path: str | None = None,
seed_path: str | None = None,
) -> dict[str, Any]:
"""Create and start a persistent task workspace."""
return self.create_task(
"""Create and start a persistent workspace."""
return self.create_workspace(
environment=environment,
vcpu_count=vcpu_count,
mem_mib=mem_mib,
ttl_seconds=ttl_seconds,
network=network,
allow_host_compat=allow_host_compat,
source_path=source_path,
seed_path=seed_path,
)
@server.tool()
async def task_exec(
task_id: str,
async def workspace_exec(
workspace_id: str,
command: str,
timeout_seconds: int = DEFAULT_TIMEOUT_SECONDS,
) -> dict[str, Any]:
"""Run one command inside an existing task workspace."""
return self.exec_task(task_id, command=command, timeout_seconds=timeout_seconds)
"""Run one command inside an existing persistent workspace."""
return self.exec_workspace(
workspace_id,
command=command,
timeout_seconds=timeout_seconds,
)
@server.tool()
async def task_sync_push(
task_id: str,
async def workspace_sync_push(
workspace_id: str,
source_path: str,
dest: str = "/workspace",
) -> dict[str, Any]:
"""Push host content into the persistent workspace of a started task."""
return self.push_task_sync(task_id, source_path=source_path, dest=dest)
"""Push host content into the persistent `/workspace` of a started workspace."""
return self.push_workspace_sync(workspace_id, source_path=source_path, dest=dest)
@server.tool()
async def task_status(task_id: str) -> dict[str, Any]:
"""Inspect task state and latest command metadata."""
return self.status_task(task_id)
async def workspace_status(workspace_id: str) -> dict[str, Any]:
"""Inspect workspace state and latest command metadata."""
return self.status_workspace(workspace_id)
@server.tool()
async def task_logs(task_id: str) -> dict[str, Any]:
"""Return persisted command history for one task."""
return self.logs_task(task_id)
async def workspace_logs(workspace_id: str) -> dict[str, Any]:
"""Return persisted command history for one workspace."""
return self.logs_workspace(workspace_id)
@server.tool()
async def task_delete(task_id: str) -> dict[str, Any]:
"""Delete a task workspace and its backing sandbox."""
return self.delete_task(task_id)
async def workspace_delete(workspace_id: str) -> dict[str, Any]:
"""Delete a persistent workspace and its backing sandbox."""
return self.delete_workspace(workspace_id)
return server