Build a Berth resident app in Python. It uses the same berth.yml manifest, RPC protocol and context bus as the TypeScript SDK, @berthos/sdk.
Berth runs an AI agent's tools in a sandbox. Each tool declares what it may touch in a berth.yml manifest, and the Linux kernel enforces it.
pip install berthos-sdkNeeds Python 3.11+. The import name is berth_sdk.
from berth_sdk import define_app
from pydantic import BaseModel
class GreetInput(BaseModel):
name: str
class GreetOutput(BaseModel):
message: str
def setup(app):
app.export(
"greet",
lambda inp: GreetOutput(message=f"hello {inp.name}"),
input_model=GreetInput,
output_model=GreetOutput,
)
app = define_app(setup)Declare greet under exports in berth.yml too. Without input_model, a handler receives the raw input dict. Run the app with berth dev from @berthos/cli; the hello-world-py app is a complete example.