withruntime 1.0.0__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- withruntime-1.2.0/PKG-INFO +146 -0
- withruntime-1.2.0/README.md +128 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/pyproject.toml +9 -1
- withruntime-1.2.0/withruntime/_version.py +1 -0
- withruntime-1.2.0/withruntime/e2b/__init__.py +3 -0
- withruntime-1.2.0/withruntime/e2b/code_interpreter.py +3 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/__init__.py +20 -11
- withruntime-1.2.0/withruntime/generated/_routes.py +8 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/_runtime.py +190 -16
- withruntime-1.2.0/withruntime/generated/agent_sessions.py +373 -0
- withruntime-1.2.0/withruntime/generated/agents.py +764 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/apps.py +333 -40
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/browsers.py +333 -40
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/builds.py +333 -40
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/ci.py +606 -41
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/containers.py +333 -40
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/desktops.py +338 -45
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/domains.py +178 -22
- withruntime-1.2.0/withruntime/generated/dropins/__init__.py +2 -0
- withruntime-1.2.0/withruntime/generated/dropins/_runtime.py +347 -0
- withruntime-1.2.0/withruntime/generated/dropins/e2b.py +690 -0
- withruntime-1.2.0/withruntime/generated/dropins/e2b_code_interpreter.py +690 -0
- withruntime-1.2.0/withruntime/generated/dropins/modal.py +971 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/egress_ips.py +8 -8
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/events.py +4 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/functions.py +333 -40
- withruntime-1.2.0/withruntime/generated/identities.py +242 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/images.py +248 -20
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/job_runs.py +4 -4
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/jobs.py +233 -17
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/keys.py +97 -11
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/me.py +1 -1
- withruntime-1.2.0/withruntime/generated/messages.py +178 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/networks.py +5 -5
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/notebooks.py +333 -40
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/ports.py +21 -17
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/previews.py +165 -27
- withruntime-1.2.0/withruntime/generated/projects.py +379 -0
- withruntime-1.2.0/withruntime/generated/roles.py +273 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/sandboxes.py +645 -98
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/secrets.py +169 -11
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/signing.py +4 -1
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/sites.py +333 -40
- withruntime-1.2.0/withruntime/generated/snapshots.py +333 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/tunnels.py +9 -9
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/usage.py +136 -7
- withruntime-1.2.0/withruntime/generated/volumes.py +438 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/workspaces.py +333 -40
- withruntime-1.2.0/withruntime.egg-info/PKG-INFO +146 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime.egg-info/SOURCES.txt +12 -1
- withruntime-1.0.0/PKG-INFO +0 -11
- withruntime-1.0.0/withruntime/_version.py +0 -1
- withruntime-1.0.0/withruntime/generated/_routes.py +0 -8
- withruntime-1.0.0/withruntime/generated/identities.py +0 -98
- withruntime-1.0.0/withruntime/generated/projects.py +0 -143
- withruntime-1.0.0/withruntime/generated/roles.py +0 -98
- withruntime-1.0.0/withruntime/generated/snapshots.py +0 -55
- withruntime-1.0.0/withruntime/generated/volumes.py +0 -90
- withruntime-1.0.0/withruntime.egg-info/PKG-INFO +0 -11
- {withruntime-1.0.0 → withruntime-1.2.0}/LICENSE +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/setup.cfg +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/__init__.py +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/audit.py +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/feedback.py +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/otel.py +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/sessions.py +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime/generated/webhooks.py +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime.egg-info/dependency_links.txt +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime.egg-info/requires.txt +0 -0
- {withruntime-1.0.0 → withruntime-1.2.0}/withruntime.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: withruntime
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: Runtime Cloud: Linux sandboxes for agents. The typed client for every verb of the API.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://withruntime.com
|
|
7
|
+
Project-URL: Documentation, https://withruntime.com/docs
|
|
8
|
+
Project-URL: Source, https://github.com/withruntime/runtime/tree/main/sdks/python
|
|
9
|
+
Project-URL: Changelog, https://github.com/withruntime/runtime/blob/main/sdks/python/CHANGELOG.md
|
|
10
|
+
Keywords: sandbox,cloud,agents,microvm,firecracker,code-execution,mcp,browser,desktop,jupyter
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: httpx<1,>=0.27
|
|
15
|
+
Provides-Extra: keypair
|
|
16
|
+
Requires-Dist: cryptography>=42; extra == "keypair"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# withruntime
|
|
20
|
+
|
|
21
|
+
The official client for [Runtime Cloud](https://withruntime.com): Linux machines for AI agents and apps, each a
|
|
22
|
+
microVM with its own kernel, disk and network, created in milliseconds and billed for the CPU it uses and the memory
|
|
23
|
+
it holds. The client is generated from the API's OpenAPI description, so every product and every operation of
|
|
24
|
+
`https://api.withruntime.com/v2` is here, typed.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install withruntime
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Python 3.9 or later. The one dependency is httpx; `pip install withruntime[keypair]` adds signing with a key pair.
|
|
33
|
+
|
|
34
|
+
## Authentication
|
|
35
|
+
|
|
36
|
+
The client reads your API key from `RUNTIME_API_KEY`, or else the key `npx withruntime login` saved on this computer
|
|
37
|
+
(it prints a link to approve in your browser, and no key is copied). On a server or in CI, create a key at
|
|
38
|
+
https://withruntime.com/account/keys and keep it in a secret manager, never in source code or a URL. A key pair's `rtsk_` secret also works: the client signs each
|
|
39
|
+
request with it and never sends it.
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from withruntime import Sandbox
|
|
45
|
+
|
|
46
|
+
with Sandbox.create() as sbx:
|
|
47
|
+
sbx.files.write("/workspace/invoice.py", "print(sum([125, 250, 375]))\n")
|
|
48
|
+
result = sbx.exec("python3 /workspace/invoice.py")
|
|
49
|
+
print(result.exit_code, result.stdout) # 0 750
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Leaving the `with` block deletes the sandbox. `AsyncRuntime`, `AsyncSandbox` and the other `Async` classes are the
|
|
53
|
+
same for asyncio, with `async with` and `await`.
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import os
|
|
59
|
+
from withruntime import Runtime
|
|
60
|
+
|
|
61
|
+
runtime = Runtime(
|
|
62
|
+
api_key=os.environ["RUNTIME_API_KEY"], # the default
|
|
63
|
+
project="prj_...", # default: RUNTIME_PROJECT
|
|
64
|
+
base_url="https://api.withruntime.com", # default: RUNTIME_API_URL
|
|
65
|
+
max_retries=3,
|
|
66
|
+
)
|
|
67
|
+
sbx = runtime.sandboxes.create(vcpu=4, memory_gb=8)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Products
|
|
71
|
+
|
|
72
|
+
| Class | Create one | What it is |
|
|
73
|
+
| --- | --- | --- |
|
|
74
|
+
| `Sandbox` | `Sandbox.create()` | A Linux machine with its own kernel, made in milliseconds, paused with its memory kept when idle and resumed where it was. |
|
|
75
|
+
| `FunctionMachine` | `FunctionMachine.create()` | A machine that answers HTTP with a handler in /app/index.ts (`export default { fetch(request) }`, as Cloudflare Workers and Vercel take one) on port 8080, reached at its preview. |
|
|
76
|
+
| `App` | `App.create()` | A machine that keeps a web app in /app running on port 8080 (its Procfile's `web:`, else `npm start`, else `python3 app.py`, as Render and Heroku start one), reached at its preview. |
|
|
77
|
+
| `Site` | `Site.create()` | A machine that serves the static files in /site on port 8080 (as Netlify and Vercel serve a build's output), reached at its preview. |
|
|
78
|
+
| `CiMachine` | `CiMachine.create()` | A machine that runs a repository's checks to their end (its `run`) with git, Docker, Node, Bun, Python and a compiler, and is stopped then. |
|
|
79
|
+
| `Browser` | `Browser.create()` | A machine running headless Chromium, driven over the Chrome DevTools Protocol at its preview on port 9222: one WebSocket address for Playwright's `connectOverCDP` and Puppeteer's `connect`, as Browserbase gives one. |
|
|
80
|
+
| `Desktop` | `Desktop.create()` | A machine running a Linux desktop with Chromium, for agents that use a computer: screenshot returns what its screen shows and act moves and clicks its mouse and types on its keyboard. |
|
|
81
|
+
| `Notebook` | `Notebook.create()` | A machine running JupyterLab on port 8888 over /workspace, with NumPy, pandas and matplotlib, reached at its private preview. |
|
|
82
|
+
| `Workspace` | `Workspace.create()` | A development environment: a machine running VS Code in the browser (code-server) on port 8080 over /workspace, reached at its private preview, as Codespaces and Gitpod give one. |
|
|
83
|
+
| `Container` | `Container.create()` | A machine that runs one OCI image from any registry under Docker on its own network (`start` `runtime-container <image>`), the port it listens on reached at its preview, as Cloud Run and Fly Machines run one. |
|
|
84
|
+
| `Build` | `Build.create()` | The machine an image's build runs on: Docker's own builder (BuildKit), its run `runtime-image-build`, deleted once its image is made. |
|
|
85
|
+
| `Job` | `Job.create()` | A command run in a fresh machine, once or on a cron schedule in a timezone. |
|
|
86
|
+
| `Image` | `Image.create()` | What a machine boots: a root filesystem, its environment and its start. |
|
|
87
|
+
| `Volume` | `Volume.create()` | A disk that outlives the machines it is attached to. |
|
|
88
|
+
| `Project` | `Project.create()` | A project: where machines, storage, addresses and keys sit, each in one. |
|
|
89
|
+
| `Domain` | `Domain.create()` | Your own hostname serving a machine's port, with HTTPS. |
|
|
90
|
+
|
|
91
|
+
Every machine (each class above with `files`) has `refresh`, `delete`, `pause`, `resume`, `exec`, `metrics`, `fork`, `snapshot`, `update`, `screenshot`, `act`, `run_code`, `spawn`, `files.read`, `files.write`, `files.remove`, `files.stat`, `files.list`, `files.download_folder`, `files.upload_folder`, `files.begin_folder_upload`, `files.write_folder_upload`, `files.commit_folder_upload`, `files.abort_folder_upload`, `files.mkdir`, `files.rename`, `files.link`, `files.revoke_links`, `processes.output`, `processes.write`, `processes.signal`, `processes.resize`, `processes.list`, `network.get`, `network.set`.
|
|
92
|
+
|
|
93
|
+
- `Sandbox` also has `exec_stream`, `previews.create`.
|
|
94
|
+
- `Job` also has `run`.
|
|
95
|
+
- `Image` also has `logs`.
|
|
96
|
+
- `Project` also has `limits`.
|
|
97
|
+
- `Domain` also has `verify`.
|
|
98
|
+
|
|
99
|
+
The API's other resources (keys, projects, roles, secrets, snapshots, webhooks, usage and more) are clients on the
|
|
100
|
+
runtime object. The [API reference](https://withruntime.com/docs/reference) lists every operation.
|
|
101
|
+
|
|
102
|
+
## Errors
|
|
103
|
+
|
|
104
|
+
Every error the API returns is raised as a `RuntimeApiError` with `code`, `message`, `status`, `request_id`,
|
|
105
|
+
`hint`, `param` and `retryable`. Each error family has its own subclass, such as `NotFoundError`,
|
|
106
|
+
`InvalidRequestError`, `RateLimitedError` and `CapacityUnavailableError`:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from withruntime import NotFoundError
|
|
110
|
+
|
|
111
|
+
try:
|
|
112
|
+
runtime.sandboxes.get("sbx_missing")
|
|
113
|
+
except NotFoundError as err:
|
|
114
|
+
print(err.code, err.request_id)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Retries and idempotency
|
|
118
|
+
|
|
119
|
+
The client retries a rate-limited (429) or unavailable (503) answer, and a lost connection on a call that is safe to send again, up to `max_retries` times (default 3). Every write sends an `Idempotency-Key` header, generated when you do not pass `idempotency_key`, so a retry never runs a write twice.
|
|
120
|
+
|
|
121
|
+
## Lists
|
|
122
|
+
|
|
123
|
+
A `list` call returns a page; iterating it yields every item across pages:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
for s in runtime.sandboxes.list(state="running"):
|
|
127
|
+
print(s.id)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Versioning
|
|
131
|
+
|
|
132
|
+
The package follows [Semantic Versioning](https://semver.org): a minor or patch release never breaks code written
|
|
133
|
+
for an earlier release of the same major version. Each request sends the API version the client was generated for in
|
|
134
|
+
the `Runtime-Version` header. Every release is listed in [CHANGELOG.md](CHANGELOG.md).
|
|
135
|
+
|
|
136
|
+
## Resources
|
|
137
|
+
|
|
138
|
+
- Guides: https://withruntime.com/docs
|
|
139
|
+
- API reference: https://withruntime.com/docs/reference
|
|
140
|
+
- Pricing: https://withruntime.com/pricing
|
|
141
|
+
- Status: https://status.withruntime.com
|
|
142
|
+
- Support: support@withruntime.com
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
Apache-2.0
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# withruntime
|
|
2
|
+
|
|
3
|
+
The official client for [Runtime Cloud](https://withruntime.com): Linux machines for AI agents and apps, each a
|
|
4
|
+
microVM with its own kernel, disk and network, created in milliseconds and billed for the CPU it uses and the memory
|
|
5
|
+
it holds. The client is generated from the API's OpenAPI description, so every product and every operation of
|
|
6
|
+
`https://api.withruntime.com/v2` is here, typed.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install withruntime
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Python 3.9 or later. The one dependency is httpx; `pip install withruntime[keypair]` adds signing with a key pair.
|
|
15
|
+
|
|
16
|
+
## Authentication
|
|
17
|
+
|
|
18
|
+
The client reads your API key from `RUNTIME_API_KEY`, or else the key `npx withruntime login` saved on this computer
|
|
19
|
+
(it prints a link to approve in your browser, and no key is copied). On a server or in CI, create a key at
|
|
20
|
+
https://withruntime.com/account/keys and keep it in a secret manager, never in source code or a URL. A key pair's `rtsk_` secret also works: the client signs each
|
|
21
|
+
request with it and never sends it.
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from withruntime import Sandbox
|
|
27
|
+
|
|
28
|
+
with Sandbox.create() as sbx:
|
|
29
|
+
sbx.files.write("/workspace/invoice.py", "print(sum([125, 250, 375]))\n")
|
|
30
|
+
result = sbx.exec("python3 /workspace/invoice.py")
|
|
31
|
+
print(result.exit_code, result.stdout) # 0 750
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Leaving the `with` block deletes the sandbox. `AsyncRuntime`, `AsyncSandbox` and the other `Async` classes are the
|
|
35
|
+
same for asyncio, with `async with` and `await`.
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import os
|
|
41
|
+
from withruntime import Runtime
|
|
42
|
+
|
|
43
|
+
runtime = Runtime(
|
|
44
|
+
api_key=os.environ["RUNTIME_API_KEY"], # the default
|
|
45
|
+
project="prj_...", # default: RUNTIME_PROJECT
|
|
46
|
+
base_url="https://api.withruntime.com", # default: RUNTIME_API_URL
|
|
47
|
+
max_retries=3,
|
|
48
|
+
)
|
|
49
|
+
sbx = runtime.sandboxes.create(vcpu=4, memory_gb=8)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Products
|
|
53
|
+
|
|
54
|
+
| Class | Create one | What it is |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| `Sandbox` | `Sandbox.create()` | A Linux machine with its own kernel, made in milliseconds, paused with its memory kept when idle and resumed where it was. |
|
|
57
|
+
| `FunctionMachine` | `FunctionMachine.create()` | A machine that answers HTTP with a handler in /app/index.ts (`export default { fetch(request) }`, as Cloudflare Workers and Vercel take one) on port 8080, reached at its preview. |
|
|
58
|
+
| `App` | `App.create()` | A machine that keeps a web app in /app running on port 8080 (its Procfile's `web:`, else `npm start`, else `python3 app.py`, as Render and Heroku start one), reached at its preview. |
|
|
59
|
+
| `Site` | `Site.create()` | A machine that serves the static files in /site on port 8080 (as Netlify and Vercel serve a build's output), reached at its preview. |
|
|
60
|
+
| `CiMachine` | `CiMachine.create()` | A machine that runs a repository's checks to their end (its `run`) with git, Docker, Node, Bun, Python and a compiler, and is stopped then. |
|
|
61
|
+
| `Browser` | `Browser.create()` | A machine running headless Chromium, driven over the Chrome DevTools Protocol at its preview on port 9222: one WebSocket address for Playwright's `connectOverCDP` and Puppeteer's `connect`, as Browserbase gives one. |
|
|
62
|
+
| `Desktop` | `Desktop.create()` | A machine running a Linux desktop with Chromium, for agents that use a computer: screenshot returns what its screen shows and act moves and clicks its mouse and types on its keyboard. |
|
|
63
|
+
| `Notebook` | `Notebook.create()` | A machine running JupyterLab on port 8888 over /workspace, with NumPy, pandas and matplotlib, reached at its private preview. |
|
|
64
|
+
| `Workspace` | `Workspace.create()` | A development environment: a machine running VS Code in the browser (code-server) on port 8080 over /workspace, reached at its private preview, as Codespaces and Gitpod give one. |
|
|
65
|
+
| `Container` | `Container.create()` | A machine that runs one OCI image from any registry under Docker on its own network (`start` `runtime-container <image>`), the port it listens on reached at its preview, as Cloud Run and Fly Machines run one. |
|
|
66
|
+
| `Build` | `Build.create()` | The machine an image's build runs on: Docker's own builder (BuildKit), its run `runtime-image-build`, deleted once its image is made. |
|
|
67
|
+
| `Job` | `Job.create()` | A command run in a fresh machine, once or on a cron schedule in a timezone. |
|
|
68
|
+
| `Image` | `Image.create()` | What a machine boots: a root filesystem, its environment and its start. |
|
|
69
|
+
| `Volume` | `Volume.create()` | A disk that outlives the machines it is attached to. |
|
|
70
|
+
| `Project` | `Project.create()` | A project: where machines, storage, addresses and keys sit, each in one. |
|
|
71
|
+
| `Domain` | `Domain.create()` | Your own hostname serving a machine's port, with HTTPS. |
|
|
72
|
+
|
|
73
|
+
Every machine (each class above with `files`) has `refresh`, `delete`, `pause`, `resume`, `exec`, `metrics`, `fork`, `snapshot`, `update`, `screenshot`, `act`, `run_code`, `spawn`, `files.read`, `files.write`, `files.remove`, `files.stat`, `files.list`, `files.download_folder`, `files.upload_folder`, `files.begin_folder_upload`, `files.write_folder_upload`, `files.commit_folder_upload`, `files.abort_folder_upload`, `files.mkdir`, `files.rename`, `files.link`, `files.revoke_links`, `processes.output`, `processes.write`, `processes.signal`, `processes.resize`, `processes.list`, `network.get`, `network.set`.
|
|
74
|
+
|
|
75
|
+
- `Sandbox` also has `exec_stream`, `previews.create`.
|
|
76
|
+
- `Job` also has `run`.
|
|
77
|
+
- `Image` also has `logs`.
|
|
78
|
+
- `Project` also has `limits`.
|
|
79
|
+
- `Domain` also has `verify`.
|
|
80
|
+
|
|
81
|
+
The API's other resources (keys, projects, roles, secrets, snapshots, webhooks, usage and more) are clients on the
|
|
82
|
+
runtime object. The [API reference](https://withruntime.com/docs/reference) lists every operation.
|
|
83
|
+
|
|
84
|
+
## Errors
|
|
85
|
+
|
|
86
|
+
Every error the API returns is raised as a `RuntimeApiError` with `code`, `message`, `status`, `request_id`,
|
|
87
|
+
`hint`, `param` and `retryable`. Each error family has its own subclass, such as `NotFoundError`,
|
|
88
|
+
`InvalidRequestError`, `RateLimitedError` and `CapacityUnavailableError`:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from withruntime import NotFoundError
|
|
92
|
+
|
|
93
|
+
try:
|
|
94
|
+
runtime.sandboxes.get("sbx_missing")
|
|
95
|
+
except NotFoundError as err:
|
|
96
|
+
print(err.code, err.request_id)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Retries and idempotency
|
|
100
|
+
|
|
101
|
+
The client retries a rate-limited (429) or unavailable (503) answer, and a lost connection on a call that is safe to send again, up to `max_retries` times (default 3). Every write sends an `Idempotency-Key` header, generated when you do not pass `idempotency_key`, so a retry never runs a write twice.
|
|
102
|
+
|
|
103
|
+
## Lists
|
|
104
|
+
|
|
105
|
+
A `list` call returns a page; iterating it yields every item across pages:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
for s in runtime.sandboxes.list(state="running"):
|
|
109
|
+
print(s.id)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Versioning
|
|
113
|
+
|
|
114
|
+
The package follows [Semantic Versioning](https://semver.org): a minor or patch release never breaks code written
|
|
115
|
+
for an earlier release of the same major version. Each request sends the API version the client was generated for in
|
|
116
|
+
the `Runtime-Version` header. Every release is listed in [CHANGELOG.md](CHANGELOG.md).
|
|
117
|
+
|
|
118
|
+
## Resources
|
|
119
|
+
|
|
120
|
+
- Guides: https://withruntime.com/docs
|
|
121
|
+
- API reference: https://withruntime.com/docs/reference
|
|
122
|
+
- Pricing: https://withruntime.com/pricing
|
|
123
|
+
- Status: https://status.withruntime.com
|
|
124
|
+
- Support: support@withruntime.com
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
Apache-2.0
|
|
@@ -4,8 +4,10 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "withruntime"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.2.0"
|
|
8
8
|
description = "Runtime Cloud: Linux sandboxes for agents. The typed client for every verb of the API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["sandbox", "cloud", "agents", "microvm", "firecracker", "code-execution", "mcp", "browser", "desktop", "jupyter"]
|
|
9
11
|
license = { text = "Apache-2.0" }
|
|
10
12
|
requires-python = ">=3.9"
|
|
11
13
|
dependencies = ["httpx>=0.27,<1"]
|
|
@@ -13,6 +15,12 @@ dependencies = ["httpx>=0.27,<1"]
|
|
|
13
15
|
[project.optional-dependencies]
|
|
14
16
|
keypair = ["cryptography>=42"]
|
|
15
17
|
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://withruntime.com"
|
|
20
|
+
Documentation = "https://withruntime.com/docs"
|
|
21
|
+
Source = "https://github.com/withruntime/runtime/tree/main/sdks/python"
|
|
22
|
+
Changelog = "https://github.com/withruntime/runtime/blob/main/sdks/python/CHANGELOG.md"
|
|
23
|
+
|
|
16
24
|
[tool.setuptools.packages.find]
|
|
17
25
|
where = ["."]
|
|
18
26
|
include = ["withruntime*"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "1.2.0"
|
|
@@ -11,14 +11,14 @@ from typing import Any, Dict, List, Optional, Union
|
|
|
11
11
|
|
|
12
12
|
from ._runtime import (API_VERSION, MAX_RETRIES, AsyncPage, AsyncStream, AsyncTransport, Page, RuntimeApiError, Stream,
|
|
13
13
|
Transport, route_call, routes_of)
|
|
14
|
-
from ._runtime import InvalidRequestError, UnauthorizedError, PaymentRequiredError, ForbiddenError, LimitExceededError, NotFoundError, AlreadyExistsError, ConflictError, TooLargeError, RateLimitedError, InternalError, ApiNotImplementedError, UnavailableError, CapacityUnavailableError, ApiTimeoutError
|
|
14
|
+
from ._runtime import InvalidRequestError, UnauthorizedError, PaymentRequiredError, CardRequiredError, ForbiddenError, LimitExceededError, NotFoundError, MethodNotAllowedError, AlreadyExistsError, ConflictError, TooLargeError, RateLimitedError, InternalError, ApiNotImplementedError, UnavailableError, CapacityUnavailableError, ApiTimeoutError
|
|
15
15
|
from ._routes import ROUTES
|
|
16
|
-
from .sandboxes import MachineStart, VolumeMount, SandboxRun, NetworkRules, SandboxSettings, SandboxCreate, MachineReady, SandboxInfo, Terminal, ExecRequest, Process, FileWritten, OutputChunk, ProcessOutput, ProcessInput, ProcessWritten, ProcessSignal, ProcessList, FileRemove, FileRemoved, FileInfo, FileList, FolderUnpacked, FolderUploadBegin, FolderUpload, FolderUploadReceived, FolderUploadAborted, FileMkdir, FileMade, FileRename, FileRenamed, FileLinkCreate, FileLink, FileLinksRevoked, SandboxNetwork, MetricPoint, MetricsBase, SandboxMetrics, ForkRequest, Forked, SnapshotRequest, Stored, MachineUpdate, Action, ActRequest, Point, ScreenSize, Acted, RunCode, CodeResult, CodeError, CodeRun, Sandboxes, Sandbox, AsyncSandboxes, AsyncSandbox
|
|
16
|
+
from .sandboxes import MachineStart, VolumeMount, SandboxRun, NetworkRules, SandboxSettings, SandboxCreate, MachineReady, SandboxInfo, Terminal, ExecRequest, Process, ExecEventError, ExecEvent, FileWritten, OutputChunk, ProcessOutput, ProcessInput, ProcessWritten, ProcessSignal, ProcessList, FileRemove, FileRemoved, FileInfo, FileList, FolderUnpacked, FolderUploadBegin, FolderUpload, FolderUploadReceived, FolderUploadAborted, FileMkdir, FileMade, FileRename, FileRenamed, FileLinkCreate, FileLink, FileLinksRevoked, SandboxNetwork, MetricPoint, MetricsBase, SandboxMetrics, ForkRequest, Forked, SnapshotRequest, SnapshotSchedule, Stored, MachineUpdate, Action, ActRequest, Point, ScreenSize, Acted, RunCode, CodeResult, CodeError, CodeRun, Sandboxes, Sandbox, AsyncSandboxes, AsyncSandbox
|
|
17
17
|
from .functions import Functions, FunctionMachine, AsyncFunctions, AsyncFunctionMachine
|
|
18
18
|
from .secrets import SecretScope, SecretRule, SecretGit, SecretGraphql, SecretApi, SecretPolicies, SecretSettings, SecretInfo, SecretSet, Secrets, Secret, AsyncSecrets, AsyncSecret
|
|
19
19
|
from .apps import Apps, App, AsyncApps, AsyncApp
|
|
20
20
|
from .sites import Sites, Site, AsyncSites, AsyncSite
|
|
21
|
-
from .ci import Ci, CiMachine, AsyncCi, AsyncCiMachine
|
|
21
|
+
from .ci import CiConnect, CiNextStep, CiPush, CiPullRequest, CiCheck, CiRunsOn, CiUsage, CiConnection, Ci, CiMachine, AsyncCi, AsyncCiMachine
|
|
22
22
|
from .browsers import Browsers, Browser, AsyncBrowsers, AsyncBrowser
|
|
23
23
|
from .desktops import Desktops, Desktop, AsyncDesktops, AsyncDesktop
|
|
24
24
|
from .notebooks import Notebooks, Notebook, AsyncNotebooks, AsyncNotebook
|
|
@@ -27,17 +27,20 @@ from .containers import Containers, Container, AsyncContainers, AsyncContainer
|
|
|
27
27
|
from .builds import Builds, Build, AsyncBuilds, AsyncBuild
|
|
28
28
|
from .jobs import JobSchedule, JobRetry, JobSecrets, JobSettings, JobCreate, JobError, JobInfo, Jobs, Job, AsyncJobs, AsyncJob
|
|
29
29
|
from .job_runs import JobRun, JobRunOutput, JobRuns, AsyncJobRuns
|
|
30
|
-
from .
|
|
30
|
+
from .agents import AgentTool, McpServer, AgentSettings, AgentCreate, AgentInfo, AgentStart, Agents, Agent, AsyncAgents, AsyncAgent
|
|
31
|
+
from .agent_sessions import AgentSessions, AsyncAgentSessions
|
|
32
|
+
from .messages import Message, SessionMessages, AskAnswer, MessageSend, Messages, AsyncMessages
|
|
33
|
+
from .snapshots import StoredUpdate, Snapshots, Snapshot, AsyncSnapshots, AsyncSnapshot
|
|
31
34
|
from .images import ContextAsked, ContextMissing, ChunkStored, ImageFile, ImageRecipe, ImageArchive, ImageContextFile, ImageContext, ImageBuild, ImageCreate, ImageLogLine, ImageLogs, Images, Image, AsyncImages, AsyncImage
|
|
32
|
-
from .volumes import VolumeCreate, Volumes, AsyncVolumes
|
|
35
|
+
from .volumes import VolumeSettings, VolumeCreate, VolumeUpdate, Volumes, Volume, AsyncVolumes, AsyncVolume
|
|
33
36
|
from .sessions import SessionCreate, Session, SessionCreated, Sessions, AsyncSessions
|
|
34
|
-
from .keys import Key, KeyAuthorization, KeyCreate, KeyCreated, KeyUpdate, Keys, AsyncKeys
|
|
35
|
-
from .projects import
|
|
36
|
-
from .identities import
|
|
37
|
-
from .roles import
|
|
37
|
+
from .keys import KeyGitHubTrust, Key, KeyAuthorization, KeyGitHub, KeyCreate, KeyCreated, KeyUpdate, Keys, AsyncKeys
|
|
38
|
+
from .projects import ProjectLimits, ProjectInfo, ProjectCreate, ProjectLimitsSet, Rename, Projects, Project, AsyncProjects, AsyncProject
|
|
39
|
+
from .identities import IdentityInfo, Identities, Identity, AsyncIdentities, AsyncIdentity
|
|
40
|
+
from .roles import RoleInfo, RoleActionsChange, Roles, Role, AsyncRoles, AsyncRole
|
|
38
41
|
from .audit import AuditLine, Audit, AsyncAudit
|
|
39
42
|
from .me import Me, MeClient, AsyncMeClient
|
|
40
|
-
from .usage import MeterUse, Limit, KeyUsage, KeySpendCap, Usage, UsageLine, UsageExport, UsageClient, AsyncUsageClient
|
|
43
|
+
from .usage import MeterUse, Limit, KeyUsage, KeySpendCap, UsageHour, ProductLine, KeySpend, Usage, UsageLine, UsageExport, UsageClient, AsyncUsageClient
|
|
41
44
|
from .previews import PreviewCreate, PreviewInfo, Previews, Preview, AsyncPreviews, AsyncPreview
|
|
42
45
|
from .domains import DomainCreate, DomainSettings, DomainInfo, Domains, Domain, AsyncDomains, AsyncDomain
|
|
43
46
|
from .ports import PortCreate, PortSettings, Port, Ports, AsyncPorts
|
|
@@ -69,6 +72,9 @@ class Runtime:
|
|
|
69
72
|
self.builds = Builds(self.transport)
|
|
70
73
|
self.jobs = Jobs(self.transport)
|
|
71
74
|
self.job_runs = JobRuns(self.transport)
|
|
75
|
+
self.agents = Agents(self.transport)
|
|
76
|
+
self.agent_sessions = AgentSessions(self.transport)
|
|
77
|
+
self.messages = Messages(self.transport)
|
|
72
78
|
self.snapshots = Snapshots(self.transport)
|
|
73
79
|
self.images = Images(self.transport)
|
|
74
80
|
self.volumes = Volumes(self.transport)
|
|
@@ -145,6 +151,9 @@ class AsyncRuntime:
|
|
|
145
151
|
self.builds = AsyncBuilds(self.transport)
|
|
146
152
|
self.jobs = AsyncJobs(self.transport)
|
|
147
153
|
self.job_runs = AsyncJobRuns(self.transport)
|
|
154
|
+
self.agents = AsyncAgents(self.transport)
|
|
155
|
+
self.agent_sessions = AsyncAgentSessions(self.transport)
|
|
156
|
+
self.messages = AsyncMessages(self.transport)
|
|
148
157
|
self.snapshots = AsyncSnapshots(self.transport)
|
|
149
158
|
self.images = AsyncImages(self.transport)
|
|
150
159
|
self.volumes = AsyncVolumes(self.transport)
|
|
@@ -202,4 +211,4 @@ class AsyncRuntime:
|
|
|
202
211
|
await self.call("sandboxes.delete", {"id": a0["id"]})
|
|
203
212
|
|
|
204
213
|
|
|
205
|
-
__all__ = ["API_VERSION", "AsyncPage", "AsyncRuntime", "AsyncStream", "Page", "Runtime", "RuntimeApiError", "Stream", "Transport", "AsyncTransport", "InvalidRequestError", "UnauthorizedError", "PaymentRequiredError", "ForbiddenError", "LimitExceededError", "NotFoundError", "AlreadyExistsError", "ConflictError", "TooLargeError", "RateLimitedError", "InternalError", "ApiNotImplementedError", "UnavailableError", "CapacityUnavailableError", "ApiTimeoutError", "MachineStart", "VolumeMount", "SandboxRun", "NetworkRules", "SandboxSettings", "SandboxCreate", "MachineReady", "SandboxInfo", "Terminal", "ExecRequest", "Process", "FileWritten", "OutputChunk", "ProcessOutput", "ProcessInput", "ProcessWritten", "ProcessSignal", "ProcessList", "FileRemove", "FileRemoved", "FileInfo", "FileList", "FolderUnpacked", "FolderUploadBegin", "FolderUpload", "FolderUploadReceived", "FolderUploadAborted", "FileMkdir", "FileMade", "FileRename", "FileRenamed", "FileLinkCreate", "FileLink", "FileLinksRevoked", "SandboxNetwork", "MetricPoint", "MetricsBase", "SandboxMetrics", "ForkRequest", "Forked", "SnapshotRequest", "Stored", "MachineUpdate", "Action", "ActRequest", "Point", "ScreenSize", "Acted", "RunCode", "CodeResult", "CodeError", "CodeRun", "Sandboxes", "Sandbox", "AsyncSandboxes", "AsyncSandbox", "Functions", "FunctionMachine", "AsyncFunctions", "AsyncFunctionMachine", "SecretScope", "SecretRule", "SecretGit", "SecretGraphql", "SecretApi", "SecretPolicies", "SecretSettings", "SecretInfo", "SecretSet", "Secrets", "Secret", "AsyncSecrets", "AsyncSecret", "Apps", "App", "AsyncApps", "AsyncApp", "Sites", "Site", "AsyncSites", "AsyncSite", "Ci", "CiMachine", "AsyncCi", "AsyncCiMachine", "Browsers", "Browser", "AsyncBrowsers", "AsyncBrowser", "Desktops", "Desktop", "AsyncDesktops", "AsyncDesktop", "Notebooks", "Notebook", "AsyncNotebooks", "AsyncNotebook", "Workspaces", "Workspace", "AsyncWorkspaces", "AsyncWorkspace", "Containers", "Container", "AsyncContainers", "AsyncContainer", "Builds", "Build", "AsyncBuilds", "AsyncBuild", "JobSchedule", "JobRetry", "JobSecrets", "JobSettings", "JobCreate", "JobError", "JobInfo", "Jobs", "Job", "AsyncJobs", "AsyncJob", "JobRun", "JobRunOutput", "JobRuns", "AsyncJobRuns", "Snapshots", "AsyncSnapshots", "ContextAsked", "ContextMissing", "ChunkStored", "ImageFile", "ImageRecipe", "ImageArchive", "ImageContextFile", "ImageContext", "ImageBuild", "ImageCreate", "ImageLogLine", "ImageLogs", "Images", "Image", "AsyncImages", "AsyncImage", "VolumeCreate", "Volumes", "AsyncVolumes", "SessionCreate", "Session", "SessionCreated", "Sessions", "AsyncSessions", "Key", "KeyAuthorization", "KeyCreate", "KeyCreated", "KeyUpdate", "Keys", "AsyncKeys", "
|
|
214
|
+
__all__ = ["API_VERSION", "AsyncPage", "AsyncRuntime", "AsyncStream", "Page", "Runtime", "RuntimeApiError", "Stream", "Transport", "AsyncTransport", "InvalidRequestError", "UnauthorizedError", "PaymentRequiredError", "CardRequiredError", "ForbiddenError", "LimitExceededError", "NotFoundError", "MethodNotAllowedError", "AlreadyExistsError", "ConflictError", "TooLargeError", "RateLimitedError", "InternalError", "ApiNotImplementedError", "UnavailableError", "CapacityUnavailableError", "ApiTimeoutError", "MachineStart", "VolumeMount", "SandboxRun", "NetworkRules", "SandboxSettings", "SandboxCreate", "MachineReady", "SandboxInfo", "Terminal", "ExecRequest", "Process", "ExecEventError", "ExecEvent", "FileWritten", "OutputChunk", "ProcessOutput", "ProcessInput", "ProcessWritten", "ProcessSignal", "ProcessList", "FileRemove", "FileRemoved", "FileInfo", "FileList", "FolderUnpacked", "FolderUploadBegin", "FolderUpload", "FolderUploadReceived", "FolderUploadAborted", "FileMkdir", "FileMade", "FileRename", "FileRenamed", "FileLinkCreate", "FileLink", "FileLinksRevoked", "SandboxNetwork", "MetricPoint", "MetricsBase", "SandboxMetrics", "ForkRequest", "Forked", "SnapshotRequest", "SnapshotSchedule", "Stored", "MachineUpdate", "Action", "ActRequest", "Point", "ScreenSize", "Acted", "RunCode", "CodeResult", "CodeError", "CodeRun", "Sandboxes", "Sandbox", "AsyncSandboxes", "AsyncSandbox", "Functions", "FunctionMachine", "AsyncFunctions", "AsyncFunctionMachine", "SecretScope", "SecretRule", "SecretGit", "SecretGraphql", "SecretApi", "SecretPolicies", "SecretSettings", "SecretInfo", "SecretSet", "Secrets", "Secret", "AsyncSecrets", "AsyncSecret", "Apps", "App", "AsyncApps", "AsyncApp", "Sites", "Site", "AsyncSites", "AsyncSite", "CiConnect", "CiNextStep", "CiPush", "CiPullRequest", "CiCheck", "CiRunsOn", "CiUsage", "CiConnection", "Ci", "CiMachine", "AsyncCi", "AsyncCiMachine", "Browsers", "Browser", "AsyncBrowsers", "AsyncBrowser", "Desktops", "Desktop", "AsyncDesktops", "AsyncDesktop", "Notebooks", "Notebook", "AsyncNotebooks", "AsyncNotebook", "Workspaces", "Workspace", "AsyncWorkspaces", "AsyncWorkspace", "Containers", "Container", "AsyncContainers", "AsyncContainer", "Builds", "Build", "AsyncBuilds", "AsyncBuild", "JobSchedule", "JobRetry", "JobSecrets", "JobSettings", "JobCreate", "JobError", "JobInfo", "Jobs", "Job", "AsyncJobs", "AsyncJob", "JobRun", "JobRunOutput", "JobRuns", "AsyncJobRuns", "AgentTool", "McpServer", "AgentSettings", "AgentCreate", "AgentInfo", "AgentStart", "Agents", "Agent", "AsyncAgents", "AsyncAgent", "AgentSessions", "AsyncAgentSessions", "Message", "SessionMessages", "AskAnswer", "MessageSend", "Messages", "AsyncMessages", "StoredUpdate", "Snapshots", "Snapshot", "AsyncSnapshots", "AsyncSnapshot", "ContextAsked", "ContextMissing", "ChunkStored", "ImageFile", "ImageRecipe", "ImageArchive", "ImageContextFile", "ImageContext", "ImageBuild", "ImageCreate", "ImageLogLine", "ImageLogs", "Images", "Image", "AsyncImages", "AsyncImage", "VolumeSettings", "VolumeCreate", "VolumeUpdate", "Volumes", "Volume", "AsyncVolumes", "AsyncVolume", "SessionCreate", "Session", "SessionCreated", "Sessions", "AsyncSessions", "KeyGitHubTrust", "Key", "KeyAuthorization", "KeyGitHub", "KeyCreate", "KeyCreated", "KeyUpdate", "Keys", "AsyncKeys", "ProjectLimits", "ProjectInfo", "ProjectCreate", "ProjectLimitsSet", "Rename", "Projects", "Project", "AsyncProjects", "AsyncProject", "IdentityInfo", "Identities", "Identity", "AsyncIdentities", "AsyncIdentity", "RoleInfo", "RoleActionsChange", "Roles", "Role", "AsyncRoles", "AsyncRole", "AuditLine", "Audit", "AsyncAudit", "Me", "MeClient", "AsyncMeClient", "MeterUse", "Limit", "KeyUsage", "KeySpendCap", "UsageHour", "ProductLine", "KeySpend", "Usage", "UsageLine", "UsageExport", "UsageClient", "AsyncUsageClient", "PreviewCreate", "PreviewInfo", "Previews", "Preview", "AsyncPreviews", "AsyncPreview", "DomainCreate", "DomainSettings", "DomainInfo", "Domains", "Domain", "AsyncDomains", "AsyncDomain", "PortCreate", "PortSettings", "Port", "Ports", "AsyncPorts", "EgressIpSettings", "EgressIp", "EgressIps", "AsyncEgressIps", "TunnelPeer", "TunnelMember", "TunnelSettings", "Tunnel", "Tunnels", "AsyncTunnels", "NetworkSettings", "Network", "Networks", "AsyncNetworks", "WebhookCreate", "Webhook", "Webhooks", "AsyncWebhooks", "Event", "Events", "AsyncEvents", "ExportCreate", "Export", "Otel", "AsyncOtel", "FeedbackCreate", "Feedback", "FeedbackClient", "AsyncFeedbackClient"]
|