opencomputer-sdk 0.6.1__tar.gz → 0.6.2__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.
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/PKG-INFO +1 -1
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/sandbox.py +41 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/pyproject.toml +1 -1
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/.gitignore +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/README.md +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/run_all_tests.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/stream_demo.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_commands.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_concurrent.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_declarative_images.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_default_template.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_disk_size.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_domain_tls.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_environment.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_exec.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_file_ops.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_large_files.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_multi_template.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_python_sdk.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_reconnect.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_secret_store_fork.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_secretstore.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_shell.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/examples/test_timeout.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/__init__.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/agent.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/commands.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/exec.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/filesystem.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/image.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/mounts.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/project.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/pty.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/shell.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/snapshot.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/sse.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/template.py +0 -0
- {opencomputer_sdk-0.6.1 → opencomputer_sdk-0.6.2}/opencomputer/usage.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opencomputer-sdk
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: Python SDK for OpenComputer - cloud sandbox platform
|
|
5
5
|
Project-URL: Homepage, https://github.com/diggerhq/opensandbox
|
|
6
6
|
Project-URL: Repository, https://github.com/diggerhq/opensandbox
|
|
@@ -70,6 +70,12 @@ class Sandbox:
|
|
|
70
70
|
sandbox_id: str
|
|
71
71
|
status: str = "running"
|
|
72
72
|
template: str = ""
|
|
73
|
+
#: Plaintext preview-URL bearer token, available immediately after a
|
|
74
|
+
#: ``Sandbox.create(preview_auth=...)`` call. Read it once and store
|
|
75
|
+
#: it somewhere durable — the server will not return it again. After
|
|
76
|
+
#: a successful ``rotate_preview_auth_token()`` this value is replaced
|
|
77
|
+
#: with the new token. Empty string when not enabled or when reconnecting.
|
|
78
|
+
preview_auth_token: str = ""
|
|
73
79
|
_api_url: str = ""
|
|
74
80
|
_api_key: str = ""
|
|
75
81
|
_connect_url: str = ""
|
|
@@ -94,6 +100,7 @@ class Sandbox:
|
|
|
94
100
|
image: Image | None = None,
|
|
95
101
|
snapshot: str | None = None,
|
|
96
102
|
on_build_log: Callable[[str], None] | None = None,
|
|
103
|
+
preview_auth: dict[str, str] | None = None,
|
|
97
104
|
) -> Sandbox:
|
|
98
105
|
"""Create a new sandbox instance.
|
|
99
106
|
|
|
@@ -121,6 +128,15 @@ class Sandbox:
|
|
|
121
128
|
image: Declarative Image definition. The server builds and caches it as a checkpoint.
|
|
122
129
|
snapshot: Name of a pre-built snapshot to create the sandbox from.
|
|
123
130
|
on_build_log: Callback for build log streaming when using image/snapshot.
|
|
131
|
+
preview_auth: Require a bearer token on the sandbox's preview URLs.
|
|
132
|
+
When set, every request to ``https://sb-{id}-p{port}.<domain>``
|
|
133
|
+
must include the token in an ``Authorization: Bearer <token>``
|
|
134
|
+
or ``X-OC-Preview-Token`` header. The check happens at the edge
|
|
135
|
+
before traffic reaches the VM. Pass ``{"token": "auto"}`` (or
|
|
136
|
+
omit the key) to have the server generate a 256-bit random
|
|
137
|
+
token; pass an explicit string (>=16 chars) to bring your own.
|
|
138
|
+
The plaintext is returned exactly once and assigned to
|
|
139
|
+
``sandbox.preview_auth_token``.
|
|
124
140
|
"""
|
|
125
141
|
url = api_url or os.environ.get("OPENCOMPUTER_API_URL", "https://app.opencomputer.dev")
|
|
126
142
|
url = url.rstrip("/")
|
|
@@ -165,6 +181,11 @@ class Sandbox:
|
|
|
165
181
|
body["image"] = image.to_dict()
|
|
166
182
|
if snapshot is not None:
|
|
167
183
|
body["snapshot"] = snapshot
|
|
184
|
+
if preview_auth is not None:
|
|
185
|
+
body["previewAuth"] = {
|
|
186
|
+
"scheme": preview_auth.get("scheme", "bearer"),
|
|
187
|
+
"token": preview_auth.get("token", "auto"),
|
|
188
|
+
}
|
|
168
189
|
|
|
169
190
|
if use_sse:
|
|
170
191
|
data = await cls._create_with_sse(client, body, on_build_log)
|
|
@@ -189,6 +210,7 @@ class Sandbox:
|
|
|
189
210
|
sandbox_id=data["sandboxID"],
|
|
190
211
|
status=data.get("status", "running"),
|
|
191
212
|
template=template,
|
|
213
|
+
preview_auth_token=data.get("previewAuthToken", ""),
|
|
192
214
|
_api_url=url,
|
|
193
215
|
_api_key=key,
|
|
194
216
|
_connect_url=connect_url,
|
|
@@ -809,6 +831,25 @@ class Sandbox:
|
|
|
809
831
|
if resp.status_code != 404:
|
|
810
832
|
resp.raise_for_status()
|
|
811
833
|
|
|
834
|
+
async def rotate_preview_auth_token(self) -> str:
|
|
835
|
+
"""Issue a new preview-URL bearer token; invalidate the previous one.
|
|
836
|
+
|
|
837
|
+
The old token stops working immediately — there is no zero-downtime
|
|
838
|
+
dual-token mode in v1, so coordinate the rollover with whoever is
|
|
839
|
+
calling your preview URL. If the sandbox was created without
|
|
840
|
+
``preview_auth``, calling this enables the auth gate from now on.
|
|
841
|
+
|
|
842
|
+
Returns the new plaintext token (also written to
|
|
843
|
+
``self.preview_auth_token``).
|
|
844
|
+
"""
|
|
845
|
+
resp = await self._client.post(
|
|
846
|
+
f"/sandboxes/{self.sandbox_id}/preview/rotate",
|
|
847
|
+
)
|
|
848
|
+
resp.raise_for_status()
|
|
849
|
+
data = resp.json()
|
|
850
|
+
self.preview_auth_token = data["previewAuthToken"]
|
|
851
|
+
return self.preview_auth_token
|
|
852
|
+
|
|
812
853
|
async def create_preview_url(self, port: int, domain: str | None = None, auth_config: dict | None = None) -> dict:
|
|
813
854
|
"""Create a preview URL targeting a specific container port.
|
|
814
855
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|