Refactor public API around environments

This commit is contained in:
Thales Maciel 2026-03-08 16:02:02 -03:00
parent 57dae52cc2
commit 5d5243df23
41 changed files with 1301 additions and 459 deletions

View file

@ -13,7 +13,7 @@ VM_RUN_TOOL: dict[str, Any] = {
"input_schema": {
"type": "object",
"properties": {
"profile": {"type": "string"},
"environment": {"type": "string"},
"command": {"type": "string"},
"vcpu_count": {"type": "integer"},
"mem_mib": {"type": "integer"},
@ -21,7 +21,7 @@ VM_RUN_TOOL: dict[str, Any] = {
"ttl_seconds": {"type": "integer", "default": 600},
"network": {"type": "boolean", "default": False},
},
"required": ["profile", "command", "vcpu_count", "mem_mib"],
"required": ["environment", "command", "vcpu_count", "mem_mib"],
},
}
@ -29,7 +29,7 @@ VM_RUN_TOOL: dict[str, Any] = {
def call_vm_run(arguments: dict[str, Any]) -> dict[str, Any]:
pyro = Pyro()
return pyro.run_in_vm(
profile=str(arguments["profile"]),
environment=str(arguments["environment"]),
command=str(arguments["command"]),
vcpu_count=int(arguments["vcpu_count"]),
mem_mib=int(arguments["mem_mib"]),
@ -41,7 +41,7 @@ def call_vm_run(arguments: dict[str, Any]) -> dict[str, Any]:
def main() -> None:
tool_arguments: dict[str, Any] = {
"profile": "debian-git",
"environment": "debian:12",
"command": "git --version",
"vcpu_count": 1,
"mem_mib": 1024,

View file

@ -19,7 +19,7 @@ F = TypeVar("F", bound=Callable[..., Any])
def run_vm_run_tool(
*,
profile: str,
environment: str,
command: str,
vcpu_count: int,
mem_mib: int,
@ -29,7 +29,7 @@ def run_vm_run_tool(
) -> str:
pyro = Pyro()
result = pyro.run_in_vm(
profile=profile,
environment=environment,
command=command,
vcpu_count=vcpu_count,
mem_mib=mem_mib,
@ -53,17 +53,17 @@ def build_langchain_vm_run_tool() -> Any:
@decorator
def vm_run(
profile: str,
environment: str,
command: str,
vcpu_count: int,
mem_mib: int,
timeout_seconds: int = 30,
ttl_seconds: int = 600,
network: bool = False,
) -> str:
) -> str:
"""Run one command in an ephemeral Firecracker VM and clean it up."""
return run_vm_run_tool(
profile=profile,
environment=environment,
command=command,
vcpu_count=vcpu_count,
mem_mib=mem_mib,

View file

@ -36,5 +36,5 @@ Use lifecycle tools only when the agent needs persistent VM state across multipl
Concrete client-specific examples:
- Claude Desktop: [examples/claude_desktop_mcp_config.json](/home/thales/projects/personal/pyro/examples/claude_desktop_mcp_config.json)
- Cursor: [examples/cursor_mcp_config.json](/home/thales/projects/personal/pyro/examples/cursor_mcp_config.json)
- Claude Desktop: [examples/claude_desktop_mcp_config.json](claude_desktop_mcp_config.json)
- Cursor: [examples/cursor_mcp_config.json](cursor_mcp_config.json)

View file

@ -26,7 +26,7 @@ OPENAI_VM_RUN_TOOL: dict[str, Any] = {
"parameters": {
"type": "object",
"properties": {
"profile": {"type": "string"},
"environment": {"type": "string"},
"command": {"type": "string"},
"vcpu_count": {"type": "integer"},
"mem_mib": {"type": "integer"},
@ -34,7 +34,7 @@ OPENAI_VM_RUN_TOOL: dict[str, Any] = {
"ttl_seconds": {"type": "integer"},
"network": {"type": "boolean"},
},
"required": ["profile", "command", "vcpu_count", "mem_mib"],
"required": ["environment", "command", "vcpu_count", "mem_mib"],
"additionalProperties": False,
},
}
@ -43,7 +43,7 @@ OPENAI_VM_RUN_TOOL: dict[str, Any] = {
def call_vm_run(arguments: dict[str, Any]) -> dict[str, Any]:
pyro = Pyro()
return pyro.run_in_vm(
profile=str(arguments["profile"]),
environment=str(arguments["environment"]),
command=str(arguments["command"]),
vcpu_count=int(arguments["vcpu_count"]),
mem_mib=int(arguments["mem_mib"]),
@ -88,7 +88,7 @@ def main() -> None:
model = os.environ.get("OPENAI_MODEL", DEFAULT_MODEL)
prompt = (
"Use the vm_run tool to run `git --version` in an ephemeral VM. "
"Use the debian-git profile with 1 vCPU and 1024 MiB of memory. "
"Use the `debian:12` environment with 1 vCPU and 1024 MiB of memory. "
"Do not use networking for this request."
)
print(run_openai_vm_run_example(prompt=prompt, model=model))

View file

@ -10,7 +10,7 @@ from pyro_mcp import Pyro
def main() -> None:
pyro = Pyro()
created = pyro.create_vm(
profile="debian-git",
environment="debian:12",
vcpu_count=1,
mem_mib=1024,
ttl_seconds=600,

View file

@ -10,7 +10,7 @@ from pyro_mcp import Pyro
def main() -> None:
pyro = Pyro()
result = pyro.run_in_vm(
profile="debian-git",
environment="debian:12",
command="git --version",
vcpu_count=1,
mem_mib=1024,