Ship trust-first CLI and runtime defaults
This commit is contained in:
parent
fb718af154
commit
5d63e4c16e
26 changed files with 894 additions and 134 deletions
|
|
@ -6,6 +6,13 @@ import json
|
|||
from typing import Any
|
||||
|
||||
from pyro_mcp import Pyro
|
||||
from pyro_mcp.vm_manager import (
|
||||
DEFAULT_ALLOW_HOST_COMPAT,
|
||||
DEFAULT_MEM_MIB,
|
||||
DEFAULT_TIMEOUT_SECONDS,
|
||||
DEFAULT_TTL_SECONDS,
|
||||
DEFAULT_VCPU_COUNT,
|
||||
)
|
||||
|
||||
VM_RUN_TOOL: dict[str, Any] = {
|
||||
"name": "vm_run",
|
||||
|
|
@ -20,8 +27,9 @@ VM_RUN_TOOL: dict[str, Any] = {
|
|||
"timeout_seconds": {"type": "integer", "default": 30},
|
||||
"ttl_seconds": {"type": "integer", "default": 600},
|
||||
"network": {"type": "boolean", "default": False},
|
||||
"allow_host_compat": {"type": "boolean", "default": False},
|
||||
},
|
||||
"required": ["environment", "command", "vcpu_count", "mem_mib"],
|
||||
"required": ["environment", "command"],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -31,11 +39,12 @@ def call_vm_run(arguments: dict[str, Any]) -> dict[str, Any]:
|
|||
return pyro.run_in_vm(
|
||||
environment=str(arguments["environment"]),
|
||||
command=str(arguments["command"]),
|
||||
vcpu_count=int(arguments["vcpu_count"]),
|
||||
mem_mib=int(arguments["mem_mib"]),
|
||||
timeout_seconds=int(arguments.get("timeout_seconds", 30)),
|
||||
ttl_seconds=int(arguments.get("ttl_seconds", 600)),
|
||||
vcpu_count=int(arguments.get("vcpu_count", DEFAULT_VCPU_COUNT)),
|
||||
mem_mib=int(arguments.get("mem_mib", DEFAULT_MEM_MIB)),
|
||||
timeout_seconds=int(arguments.get("timeout_seconds", DEFAULT_TIMEOUT_SECONDS)),
|
||||
ttl_seconds=int(arguments.get("ttl_seconds", DEFAULT_TTL_SECONDS)),
|
||||
network=bool(arguments.get("network", False)),
|
||||
allow_host_compat=bool(arguments.get("allow_host_compat", DEFAULT_ALLOW_HOST_COMPAT)),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -43,8 +52,6 @@ def main() -> None:
|
|||
tool_arguments: dict[str, Any] = {
|
||||
"environment": "debian:12",
|
||||
"command": "git --version",
|
||||
"vcpu_count": 1,
|
||||
"mem_mib": 1024,
|
||||
"timeout_seconds": 30,
|
||||
"network": False,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,13 @@ import json
|
|||
from typing import Any, Callable, TypeVar, cast
|
||||
|
||||
from pyro_mcp import Pyro
|
||||
from pyro_mcp.vm_manager import (
|
||||
DEFAULT_ALLOW_HOST_COMPAT,
|
||||
DEFAULT_MEM_MIB,
|
||||
DEFAULT_TIMEOUT_SECONDS,
|
||||
DEFAULT_TTL_SECONDS,
|
||||
DEFAULT_VCPU_COUNT,
|
||||
)
|
||||
|
||||
F = TypeVar("F", bound=Callable[..., Any])
|
||||
|
||||
|
|
@ -21,11 +28,12 @@ def run_vm_run_tool(
|
|||
*,
|
||||
environment: str,
|
||||
command: str,
|
||||
vcpu_count: int,
|
||||
mem_mib: int,
|
||||
timeout_seconds: int = 30,
|
||||
ttl_seconds: int = 600,
|
||||
vcpu_count: int = DEFAULT_VCPU_COUNT,
|
||||
mem_mib: int = DEFAULT_MEM_MIB,
|
||||
timeout_seconds: int = DEFAULT_TIMEOUT_SECONDS,
|
||||
ttl_seconds: int = DEFAULT_TTL_SECONDS,
|
||||
network: bool = False,
|
||||
allow_host_compat: bool = DEFAULT_ALLOW_HOST_COMPAT,
|
||||
) -> str:
|
||||
pyro = Pyro()
|
||||
result = pyro.run_in_vm(
|
||||
|
|
@ -36,6 +44,7 @@ def run_vm_run_tool(
|
|||
timeout_seconds=timeout_seconds,
|
||||
ttl_seconds=ttl_seconds,
|
||||
network=network,
|
||||
allow_host_compat=allow_host_compat,
|
||||
)
|
||||
return json.dumps(result, sort_keys=True)
|
||||
|
||||
|
|
@ -55,12 +64,13 @@ def build_langchain_vm_run_tool() -> Any:
|
|||
def vm_run(
|
||||
environment: str,
|
||||
command: str,
|
||||
vcpu_count: int,
|
||||
mem_mib: int,
|
||||
timeout_seconds: int = 30,
|
||||
ttl_seconds: int = 600,
|
||||
vcpu_count: int = DEFAULT_VCPU_COUNT,
|
||||
mem_mib: int = DEFAULT_MEM_MIB,
|
||||
timeout_seconds: int = DEFAULT_TIMEOUT_SECONDS,
|
||||
ttl_seconds: int = DEFAULT_TTL_SECONDS,
|
||||
network: bool = False,
|
||||
) -> str:
|
||||
allow_host_compat: bool = DEFAULT_ALLOW_HOST_COMPAT,
|
||||
) -> str:
|
||||
"""Run one command in an ephemeral Firecracker VM and clean it up."""
|
||||
return run_vm_run_tool(
|
||||
environment=environment,
|
||||
|
|
@ -70,6 +80,7 @@ def build_langchain_vm_run_tool() -> Any:
|
|||
timeout_seconds=timeout_seconds,
|
||||
ttl_seconds=ttl_seconds,
|
||||
network=network,
|
||||
allow_host_compat=allow_host_compat,
|
||||
)
|
||||
|
||||
return vm_run
|
||||
|
|
|
|||
|
|
@ -15,6 +15,13 @@ import os
|
|||
from typing import Any
|
||||
|
||||
from pyro_mcp import Pyro
|
||||
from pyro_mcp.vm_manager import (
|
||||
DEFAULT_ALLOW_HOST_COMPAT,
|
||||
DEFAULT_MEM_MIB,
|
||||
DEFAULT_TIMEOUT_SECONDS,
|
||||
DEFAULT_TTL_SECONDS,
|
||||
DEFAULT_VCPU_COUNT,
|
||||
)
|
||||
|
||||
DEFAULT_MODEL = "gpt-5"
|
||||
|
||||
|
|
@ -33,8 +40,9 @@ OPENAI_VM_RUN_TOOL: dict[str, Any] = {
|
|||
"timeout_seconds": {"type": "integer"},
|
||||
"ttl_seconds": {"type": "integer"},
|
||||
"network": {"type": "boolean"},
|
||||
"allow_host_compat": {"type": "boolean"},
|
||||
},
|
||||
"required": ["environment", "command", "vcpu_count", "mem_mib"],
|
||||
"required": ["environment", "command"],
|
||||
"additionalProperties": False,
|
||||
},
|
||||
}
|
||||
|
|
@ -45,11 +53,12 @@ def call_vm_run(arguments: dict[str, Any]) -> dict[str, Any]:
|
|||
return pyro.run_in_vm(
|
||||
environment=str(arguments["environment"]),
|
||||
command=str(arguments["command"]),
|
||||
vcpu_count=int(arguments["vcpu_count"]),
|
||||
mem_mib=int(arguments["mem_mib"]),
|
||||
timeout_seconds=int(arguments.get("timeout_seconds", 30)),
|
||||
ttl_seconds=int(arguments.get("ttl_seconds", 600)),
|
||||
vcpu_count=int(arguments.get("vcpu_count", DEFAULT_VCPU_COUNT)),
|
||||
mem_mib=int(arguments.get("mem_mib", DEFAULT_MEM_MIB)),
|
||||
timeout_seconds=int(arguments.get("timeout_seconds", DEFAULT_TIMEOUT_SECONDS)),
|
||||
ttl_seconds=int(arguments.get("ttl_seconds", DEFAULT_TTL_SECONDS)),
|
||||
network=bool(arguments.get("network", False)),
|
||||
allow_host_compat=bool(arguments.get("allow_host_compat", DEFAULT_ALLOW_HOST_COMPAT)),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -88,7 +97,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:12` environment with 1 vCPU and 1024 MiB of memory. "
|
||||
"Use the `debian:12` environment. "
|
||||
"Do not use networking for this request."
|
||||
)
|
||||
print(run_openai_vm_run_example(prompt=prompt, model=model))
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ def main() -> None:
|
|||
pyro = Pyro()
|
||||
created = pyro.create_vm(
|
||||
environment="debian:12",
|
||||
vcpu_count=1,
|
||||
mem_mib=1024,
|
||||
ttl_seconds=600,
|
||||
network=False,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ def main() -> None:
|
|||
result = pyro.run_in_vm(
|
||||
environment="debian:12",
|
||||
command="git --version",
|
||||
vcpu_count=1,
|
||||
mem_mib=1024,
|
||||
timeout_seconds=30,
|
||||
network=False,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue