runtimesdk 0.2.3__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.
Files changed (48) hide show
  1. runtimesdk-0.2.3/.gitignore +6 -0
  2. runtimesdk-0.2.3/.uv-cache/.gitignore +1 -0
  3. runtimesdk-0.2.3/.uv-cache/CACHEDIR.TAG +1 -0
  4. runtimesdk-0.2.3/.uv-cache/interpreter-v4/7e11d242fb84b9e8/02856d2beadce98a.msgpack +0 -0
  5. runtimesdk-0.2.3/.uv-cache/sdists-v9/.git +0 -0
  6. runtimesdk-0.2.3/.uv-cache/sdists-v9/.gitignore +0 -0
  7. runtimesdk-0.2.3/AGENTS.md +24 -0
  8. runtimesdk-0.2.3/PKG-INFO +54 -0
  9. runtimesdk-0.2.3/README.md +43 -0
  10. runtimesdk-0.2.3/pyproject.toml +47 -0
  11. runtimesdk-0.2.3/src/runtimesdk/AGENTS.md +13 -0
  12. runtimesdk-0.2.3/src/runtimesdk/__init__.py +122 -0
  13. runtimesdk-0.2.3/src/runtimesdk/constants.py +184 -0
  14. runtimesdk-0.2.3/src/runtimesdk/contracts.py +743 -0
  15. runtimesdk-0.2.3/src/workspace_runtime/AGENTS.md +9 -0
  16. runtimesdk-0.2.3/src/workspace_runtime/__init__.py +59 -0
  17. runtimesdk-0.2.3/src/workspace_runtime/__main__.py +4 -0
  18. runtimesdk-0.2.3/src/workspace_runtime/cli.py +13 -0
  19. runtimesdk-0.2.3/src/workspace_runtime/domain/AGENTS.md +11 -0
  20. runtimesdk-0.2.3/src/workspace_runtime/domain/__init__.py +35 -0
  21. runtimesdk-0.2.3/src/workspace_runtime/domain/errors.py +14 -0
  22. runtimesdk-0.2.3/src/workspace_runtime/domain/models.py +234 -0
  23. runtimesdk-0.2.3/src/workspace_runtime/domain/store.py +83 -0
  24. runtimesdk-0.2.3/src/workspace_runtime/errors.py +11 -0
  25. runtimesdk-0.2.3/src/workspace_runtime/interfaces/AGENTS.md +9 -0
  26. runtimesdk-0.2.3/src/workspace_runtime/interfaces/__init__.py +3 -0
  27. runtimesdk-0.2.3/src/workspace_runtime/interfaces/cli.py +222 -0
  28. runtimesdk-0.2.3/src/workspace_runtime/interfaces/sdk.py +182 -0
  29. runtimesdk-0.2.3/src/workspace_runtime/manager.py +3 -0
  30. runtimesdk-0.2.3/src/workspace_runtime/models.py +21 -0
  31. runtimesdk-0.2.3/src/workspace_runtime/providers/AGENTS.md +12 -0
  32. runtimesdk-0.2.3/src/workspace_runtime/providers/__init__.py +10 -0
  33. runtimesdk-0.2.3/src/workspace_runtime/providers/modal/__init__.py +13 -0
  34. runtimesdk-0.2.3/src/workspace_runtime/providers/modal/images.py +256 -0
  35. runtimesdk-0.2.3/src/workspace_runtime/providers/modal/provider.py +1183 -0
  36. runtimesdk-0.2.3/src/workspace_runtime/store/AGENTS.md +7 -0
  37. runtimesdk-0.2.3/src/workspace_runtime/store/__init__.py +10 -0
  38. runtimesdk-0.2.3/src/workspace_runtime/store/base.py +3 -0
  39. runtimesdk-0.2.3/src/workspace_runtime/store/postgres.py +212 -0
  40. runtimesdk-0.2.3/tests/AGENTS.md +10 -0
  41. runtimesdk-0.2.3/tests/conftest.py +42 -0
  42. runtimesdk-0.2.3/tests/test_cli.py +249 -0
  43. runtimesdk-0.2.3/tests/test_exports.py +62 -0
  44. runtimesdk-0.2.3/tests/test_modal_images.py +148 -0
  45. runtimesdk-0.2.3/tests/test_modal_provider.py +849 -0
  46. runtimesdk-0.2.3/tests/test_postgres_store.py +191 -0
  47. runtimesdk-0.2.3/tests/test_workspace_manager.py +382 -0
  48. runtimesdk-0.2.3/uv.lock +1095 -0
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ .pytest_cache/
3
+ .ruff_cache/
4
+ .venv/
5
+ __pycache__/
6
+ *.pyc
@@ -0,0 +1 @@
1
+ *
@@ -0,0 +1 @@
1
+ Signature: 8a477f597d28d172789f06886806bc55
File without changes
File without changes
@@ -0,0 +1,24 @@
1
+ # RuntimeSDK Package Guide
2
+
3
+ This package is the public Python package boundary for RuntimeComputer runtime
4
+ consumers.
5
+
6
+ ## Responsibilities
7
+ - shared constants and contracts used by backend and CLI
8
+ - provider abstraction
9
+ - workspace lifecycle
10
+ - persistent storage lifecycle
11
+ - one-shot exec
12
+ - interactive console primitives
13
+
14
+ ## Non-Responsibilities
15
+ - auth
16
+ - fixed-route product policy
17
+ - sharing
18
+ - billing
19
+ - backend HTTP concerns
20
+
21
+ ## Layout
22
+ - `src/runtimesdk/`: public package surface (`constants`, `contracts`, exports)
23
+ - `src/workspace_runtime/`: internal runtime engine implementation
24
+ - `tests/`: engine-level tests
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: runtimesdk
3
+ Version: 0.2.3
4
+ Summary: Provider-agnostic runtime engine and RuntimeComputer SDK surface.
5
+ Requires-Python: >=3.11
6
+ Provides-Extra: engine
7
+ Requires-Dist: modal<2,>=1.1; extra == 'engine'
8
+ Requires-Dist: psycopg<4,>=3.2; extra == 'engine'
9
+ Requires-Dist: typer<1,>=0.12; extra == 'engine'
10
+ Description-Content-Type: text/markdown
11
+
12
+ # runtimesdk
13
+
14
+ Provider-agnostic runtime engine backed by Modal.
15
+
16
+ Install surface:
17
+
18
+ ```bash
19
+ uv add runtimesdk
20
+ ```
21
+
22
+ The package exposes:
23
+
24
+ - domain models for workspace specs, records, ports, exec results, and
25
+ console-session requests/results
26
+ - RuntimeComputer contracts and enums under the same package boundary
27
+ - a `WorkspaceStore` protocol plus a PostgreSQL JSONB implementation for local
28
+ and compatibility CLI use
29
+ - a thin Modal client/provider layer built around documented Modal lookup and
30
+ sandbox primitives
31
+ - a `WorkspaceManager` facade for create, ensure-running, exec, console, ports,
32
+ stop, delete, reset, and clone flows
33
+
34
+ The old `workspace-runtime` naming still exists internally as a compatibility
35
+ module, but the intended public package boundary is `runtimesdk`.
36
+
37
+ The compatibility `workspace_runtime` CLI now persists workspace records in
38
+ PostgreSQL. It reads the same database env surface as the RuntimeComputer
39
+ backend:
40
+
41
+ - `RUNTIMECOMPUTER_DATABASE_URL`, or
42
+ - `RUNTIMECOMPUTER_DATABASE_NAME` / `USER` / `PASSWORD` / `HOST` / `PORT`, with
43
+ `PGDATABASE` / `PGUSER` / `PGPASSWORD` / `PGHOST` / `PGPORT` fallbacks
44
+
45
+ If a legacy SQLite store already exists at `.runtime/workspaces.db`, or at the
46
+ legacy `RUNTIMESDK_STORE_PATH` location, the compatibility CLI imports those
47
+ workspace records into PostgreSQL before serving the command.
48
+
49
+ `RUNTIMECOMPUTER_DATABASE_PATH` is no longer supported, and the package no
50
+ longer creates `.runtime/workspaces.db`.
51
+
52
+ `delete()` is intentionally conservative in this first cut: it removes local
53
+ state and terminates running sandboxes, but it does not attempt remote cleanup
54
+ of prior Modal volumes.
@@ -0,0 +1,43 @@
1
+ # runtimesdk
2
+
3
+ Provider-agnostic runtime engine backed by Modal.
4
+
5
+ Install surface:
6
+
7
+ ```bash
8
+ uv add runtimesdk
9
+ ```
10
+
11
+ The package exposes:
12
+
13
+ - domain models for workspace specs, records, ports, exec results, and
14
+ console-session requests/results
15
+ - RuntimeComputer contracts and enums under the same package boundary
16
+ - a `WorkspaceStore` protocol plus a PostgreSQL JSONB implementation for local
17
+ and compatibility CLI use
18
+ - a thin Modal client/provider layer built around documented Modal lookup and
19
+ sandbox primitives
20
+ - a `WorkspaceManager` facade for create, ensure-running, exec, console, ports,
21
+ stop, delete, reset, and clone flows
22
+
23
+ The old `workspace-runtime` naming still exists internally as a compatibility
24
+ module, but the intended public package boundary is `runtimesdk`.
25
+
26
+ The compatibility `workspace_runtime` CLI now persists workspace records in
27
+ PostgreSQL. It reads the same database env surface as the RuntimeComputer
28
+ backend:
29
+
30
+ - `RUNTIMECOMPUTER_DATABASE_URL`, or
31
+ - `RUNTIMECOMPUTER_DATABASE_NAME` / `USER` / `PASSWORD` / `HOST` / `PORT`, with
32
+ `PGDATABASE` / `PGUSER` / `PGPASSWORD` / `PGHOST` / `PGPORT` fallbacks
33
+
34
+ If a legacy SQLite store already exists at `.runtime/workspaces.db`, or at the
35
+ legacy `RUNTIMESDK_STORE_PATH` location, the compatibility CLI imports those
36
+ workspace records into PostgreSQL before serving the command.
37
+
38
+ `RUNTIMECOMPUTER_DATABASE_PATH` is no longer supported, and the package no
39
+ longer creates `.runtime/workspaces.db`.
40
+
41
+ `delete()` is intentionally conservative in this first cut: it removes local
42
+ state and terminates running sandboxes, but it does not attempt remote cleanup
43
+ of prior Modal volumes.
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "runtimesdk"
7
+ version = "0.2.3"
8
+ description = "Provider-agnostic runtime engine and RuntimeComputer SDK surface."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ dependencies = []
12
+
13
+ [project.optional-dependencies]
14
+ engine = [
15
+ "modal>=1.1,<2",
16
+ "psycopg>=3.2,<4",
17
+ "typer>=0.12,<1",
18
+ ]
19
+
20
+ [dependency-groups]
21
+ dev = [
22
+ "pytest>=8.3",
23
+ "ruff>=0.11",
24
+ "modal>=1.1,<2",
25
+ "psycopg>=3.2,<4",
26
+ "typer>=0.12,<1",
27
+ ]
28
+
29
+ [project.scripts]
30
+ runtimesdk = "workspace_runtime.cli:main"
31
+
32
+ [tool.hatch.build.targets.wheel]
33
+ packages = ["src/workspace_runtime", "src/runtimesdk"]
34
+
35
+ [tool.pytest.ini_options]
36
+ testpaths = ["tests"]
37
+
38
+ [tool.ruff]
39
+ target-version = "py311"
40
+ line-length = 100
41
+ src = ["src", "tests"]
42
+
43
+ [tool.ruff.lint]
44
+ select = ["B", "E", "F", "I", "UP"]
45
+
46
+ [tool.ruff.format]
47
+ quote-style = "double"
@@ -0,0 +1,13 @@
1
+ # RuntimeSDK Public Surface Guide
2
+
3
+ This package is the public surface consumers import.
4
+
5
+ ## Responsibilities
6
+ - expose shared constants and contracts
7
+ - re-export the engine types that are intentionally public
8
+ - keep install UX to a single package: `runtimesdk`
9
+
10
+ ## Rules
11
+ - keep backend/CLI shared defaults in `constants.py`
12
+ - keep DTO-like shared types in `contracts.py`
13
+ - avoid leaking product-specific backend modules into this package
@@ -0,0 +1,122 @@
1
+ from __future__ import annotations
2
+
3
+ from importlib import import_module
4
+
5
+ _EXPORT_MODULES = {
6
+ "ACCESS_COOKIE_NAME": "runtimesdk.constants",
7
+ "AuthSource": "runtimesdk.constants",
8
+ "AuthWhoamiSummary": "runtimesdk.contracts",
9
+ "BootstrapType": "runtimesdk.constants",
10
+ "BOOTSTRAP_QUERY_PARAM": "runtimesdk.constants",
11
+ "CliLoginConfirmRequest": "runtimesdk.contracts",
12
+ "CLI_TOKEN_PREFIX": "runtimesdk.constants",
13
+ "CLERK_JWT_ALGORITHMS": "runtimesdk.constants",
14
+ "CLERK_SESSION_COOKIE": "runtimesdk.constants",
15
+ "CLERK_SESSION_COOKIE_PREFIX": "runtimesdk.constants",
16
+ "ConsoleSessionRequest": "workspace_runtime",
17
+ "ConsoleSessionResult": "workspace_runtime",
18
+ "ConsoleTransport": "workspace_runtime",
19
+ "CONSOLE_SESSION_SIGNING_SALT": "runtimesdk.constants",
20
+ "CORS_MAX_AGE": "runtimesdk.constants",
21
+ "CREATOR_BOOTSTRAP_PATH": "runtimesdk.constants",
22
+ "DEFAULT_ACCESS_BOOTSTRAP_TTL_SECONDS": "runtimesdk.constants",
23
+ "DEFAULT_ACCESS_EMBED_TTL_SECONDS": "runtimesdk.constants",
24
+ "DEFAULT_ACCESS_SESSION_TTL_SECONDS": "runtimesdk.constants",
25
+ "DEFAULT_ACCESS_SHARE_LINK_TTL_SECONDS": "runtimesdk.constants",
26
+ "DEFAULT_BACKEND_PORT": "runtimesdk.constants",
27
+ "DEFAULT_BASE_DOMAIN": "runtimesdk.constants",
28
+ "DEFAULT_CLI_AUTH_CONFIRM_PATH": "runtimesdk.constants",
29
+ "DEFAULT_CLI_LOGIN_SESSION_TTL_SECONDS": "runtimesdk.constants",
30
+ "DEFAULT_CONSOLE_WEBSOCKET_PATH": "runtimesdk.constants",
31
+ "DEFAULT_CONSOLE_SESSION_TTL_SECONDS": "runtimesdk.constants",
32
+ "DEFAULT_EDGE_PORT": "runtimesdk.constants",
33
+ "DEFAULT_ENVIRONMENT": "runtimesdk.constants",
34
+ "DEFAULT_FRONTEND_PORT": "runtimesdk.constants",
35
+ "DEFAULT_LOCAL_HOST": "runtimesdk.constants",
36
+ "DEFAULT_MODAL_APP_NAME": "runtimesdk.constants",
37
+ "DEFAULT_MODAL_ENVIRONMENT": "runtimesdk.constants",
38
+ "DEFAULT_MODAL_VOLUME_PREFIX": "runtimesdk.constants",
39
+ "DEFAULT_PROVIDER_NAME": "runtimesdk.constants",
40
+ "DEFAULT_RESTART_POLICY": "runtimesdk.constants",
41
+ "DEFAULT_ROUTE_STARTUP_RETRY_AFTER_SECONDS": "runtimesdk.constants",
42
+ "DEFAULT_ROUTE_WAKE_THROTTLE_SECONDS": "runtimesdk.constants",
43
+ "DEFAULT_RUNTIME_DRIVER": "runtimesdk.constants",
44
+ "DEFAULT_PORT_VISIBILITY": "runtimesdk.constants",
45
+ "DEFAULT_SESSION_NAME": "runtimesdk.constants",
46
+ "DEFAULT_SIGN_IN_PATH": "runtimesdk.constants",
47
+ "DEFAULT_TARGET_SERVICE": "runtimesdk.constants",
48
+ "DEFAULT_TEMPLATE": "runtimesdk.constants",
49
+ "DEFAULT_WEB_PORT": "runtimesdk.constants",
50
+ "DEFAULT_WORKSPACE_IDLE_TIMEOUT_SECONDS": "runtimesdk.constants",
51
+ "DEFAULT_WORKSPACE_TIMEOUT_SECONDS": "runtimesdk.constants",
52
+ "DEFAULT_WORKSPACE_DIR": "runtimesdk.constants",
53
+ "EMBED_SESSION_SAMESITE": "runtimesdk.constants",
54
+ "ExecResult": "workspace_runtime",
55
+ "LOCAL_ENVIRONMENTS": "runtimesdk.constants",
56
+ "ModalWorkspaceProvider": "workspace_runtime",
57
+ "PortSpec": "workspace_runtime",
58
+ "PostgresWorkspaceStore": "workspace_runtime",
59
+ "RestartPolicy": "runtimesdk.constants",
60
+ "RUNTIME_SEED_ARCHIVE_ENV": "runtimesdk.constants",
61
+ "RUNTIME_SEED_MOUNT_PATH_ENV": "runtimesdk.constants",
62
+ "RUNTIME_SEED_PRESET_ENV": "runtimesdk.constants",
63
+ "RUNTIME_SEED_VERSION_ENV": "runtimesdk.constants",
64
+ "RouteAccessMode": "runtimesdk.constants",
65
+ "RouteAction": "runtimesdk.constants",
66
+ "RouteResolution": "runtimesdk.contracts",
67
+ "SHARE_QUERY_PARAM": "runtimesdk.constants",
68
+ "SHARE_LINK_SIGNING_SALT": "runtimesdk.constants",
69
+ "WS_CLOSE_FORBIDDEN": "runtimesdk.constants",
70
+ "WS_CLOSE_NORMAL": "runtimesdk.constants",
71
+ "WS_CLOSE_NOT_FOUND": "runtimesdk.constants",
72
+ "WS_CLOSE_UNAUTHORIZED": "runtimesdk.constants",
73
+ "WS_CLOSE_UNAVAILABLE": "runtimesdk.constants",
74
+ "WS_EOF_SENTINEL": "runtimesdk.constants",
75
+ "WS_MAX_CLOSE_REASON_LEN": "runtimesdk.constants",
76
+ "WorkspaceAlreadyExistsError": "workspace_runtime",
77
+ "WorkspaceConsoleRequest": "runtimesdk.contracts",
78
+ "WorkspaceConsoleSessionSummary": "runtimesdk.contracts",
79
+ "WorkspaceCreateRequest": "runtimesdk.contracts",
80
+ "WorkspaceEmbedGrantRequest": "runtimesdk.contracts",
81
+ "WorkspaceEmbedGrantSummary": "runtimesdk.contracts",
82
+ "WorkspaceError": "workspace_runtime",
83
+ "WorkspaceExecRequest": "runtimesdk.contracts",
84
+ "WorkspaceExecSummary": "runtimesdk.contracts",
85
+ "WorkspaceExecutionError": "workspace_runtime",
86
+ "WorkspaceIngressRuleSummary": "runtimesdk.contracts",
87
+ "WorkspaceIngressRuleUpsertRequest": "runtimesdk.contracts",
88
+ "WorkspaceManager": "workspace_runtime",
89
+ "WorkspaceNotFoundError": "workspace_runtime",
90
+ "WorkspaceProvider": "workspace_runtime",
91
+ "WorkspaceRecord": "workspace_runtime",
92
+ "WorkspaceRouteSummary": "runtimesdk.contracts",
93
+ "WorkspaceRouteUpdateRequest": "runtimesdk.contracts",
94
+ "WorkspaceServiceSummary": "runtimesdk.contracts",
95
+ "WorkspaceServiceUpsertRequest": "runtimesdk.contracts",
96
+ "WorkspaceShareLinkCreateRequest": "runtimesdk.contracts",
97
+ "WorkspaceShareLinkSummary": "runtimesdk.contracts",
98
+ "WorkspaceSpec": "workspace_runtime",
99
+ "WorkspaceStatus": "runtimesdk.constants",
100
+ "WorkspaceStore": "workspace_runtime",
101
+ "WorkspaceSummary": "runtimesdk.contracts",
102
+ "WorkspaceTemplateSummary": "runtimesdk.contracts",
103
+ "build_api_origin": "runtimesdk.constants",
104
+ "build_app_origin": "runtimesdk.constants",
105
+ "build_local_origin": "runtimesdk.constants",
106
+ "build_sign_in_url": "runtimesdk.constants",
107
+ }
108
+
109
+ __all__ = list(_EXPORT_MODULES)
110
+
111
+
112
+ def __getattr__(name: str):
113
+ module_name = _EXPORT_MODULES.get(name)
114
+ if module_name is None:
115
+ raise AttributeError(f"module 'runtimesdk' has no attribute {name!r}")
116
+ value = getattr(import_module(module_name), name)
117
+ globals()[name] = value
118
+ return value
119
+
120
+
121
+ def __dir__() -> list[str]:
122
+ return sorted(set(globals()) | set(__all__))
@@ -0,0 +1,184 @@
1
+ from __future__ import annotations
2
+
3
+ from enum import StrEnum
4
+
5
+
6
+ class WorkspaceStatus(StrEnum):
7
+ READY = "ready"
8
+ STOPPED = "stopped"
9
+ STARTING = "starting"
10
+
11
+
12
+ class RouteAccessMode(StrEnum):
13
+ CREATOR = "creator"
14
+ SHARED = "shared"
15
+ PUBLIC = "public"
16
+ INGRESS = "ingress"
17
+ EMBED = "embed"
18
+
19
+
20
+ class RouteAction(StrEnum):
21
+ PROXY = "proxy"
22
+ STARTING = "starting"
23
+ REDIRECT = "redirect"
24
+ DENY = "deny"
25
+
26
+
27
+ class BootstrapType(StrEnum):
28
+ CREATOR = "creator"
29
+ EMBED = "embed"
30
+
31
+
32
+ class RestartPolicy(StrEnum):
33
+ ALWAYS = "always"
34
+ MANUAL = "manual"
35
+
36
+
37
+ class AuthSource(StrEnum):
38
+ CLERK = "clerk"
39
+ RUNTIME_TOKEN = "runtime-token"
40
+
41
+
42
+ DEFAULT_ENVIRONMENT = "development"
43
+ LOCAL_ENVIRONMENTS = frozenset({"development", "dev", "local", "test"})
44
+ DEFAULT_LOCAL_HOST = "127.0.0.1"
45
+ DEFAULT_BACKEND_PORT = 8000
46
+ DEFAULT_FRONTEND_PORT = 5173
47
+ DEFAULT_EDGE_PORT = 8787
48
+ DEFAULT_SIGN_IN_PATH = "/sign-in"
49
+ DEFAULT_CLI_AUTH_CONFIRM_PATH = "/api/auth/cli/login-sessions"
50
+ DEFAULT_CONSOLE_WEBSOCKET_PATH = "/ws/console/"
51
+ DEFAULT_BASE_DOMAIN = "runruntime.dev"
52
+ DEFAULT_PROVIDER_NAME = "modal"
53
+ DEFAULT_MODAL_APP_NAME = "computer"
54
+ DEFAULT_MODAL_ENVIRONMENT = "runtime-staging"
55
+ DEFAULT_MODAL_VOLUME_PREFIX = "workspace-runtime-"
56
+ DEFAULT_RUNTIME_DRIVER = "modal"
57
+ DEFAULT_WORKSPACE_TIMEOUT_SECONDS = 86_400
58
+ DEFAULT_WORKSPACE_IDLE_TIMEOUT_SECONDS = 1_800
59
+ DEFAULT_PORT_VISIBILITY = "encrypted"
60
+ DEFAULT_TARGET_SERVICE = "web"
61
+ DEFAULT_WORKSPACE_DIR = "/workspace"
62
+ DEFAULT_WEB_PORT = 3000
63
+ DEFAULT_SESSION_NAME = "main"
64
+ DEFAULT_TEMPLATE = "base"
65
+ DEFAULT_RESTART_POLICY = RestartPolicy.ALWAYS.value
66
+ DEFAULT_CLI_LOGIN_SESSION_TTL_SECONDS = 900
67
+ DEFAULT_ROUTE_WAKE_THROTTLE_SECONDS = 15
68
+ DEFAULT_ROUTE_STARTUP_RETRY_AFTER_SECONDS = 3
69
+ DEFAULT_CONSOLE_SESSION_TTL_SECONDS = 60
70
+ DEFAULT_ACCESS_BOOTSTRAP_TTL_SECONDS = 300
71
+ DEFAULT_ACCESS_SESSION_TTL_SECONDS = 43200
72
+ DEFAULT_ACCESS_SHARE_LINK_TTL_SECONDS = 604800
73
+ DEFAULT_ACCESS_EMBED_TTL_SECONDS = 300
74
+
75
+ CLI_TOKEN_PREFIX = "rtc_"
76
+ CLERK_SESSION_COOKIE = "__session"
77
+ CLERK_SESSION_COOKIE_PREFIX = "__session_"
78
+ CLERK_JWT_ALGORITHMS = ("RS256", "RS384", "RS512")
79
+ WS_EOF_SENTINEL = "__EOF__"
80
+ WS_CLOSE_UNAUTHORIZED = 4401
81
+ WS_CLOSE_FORBIDDEN = 4403
82
+ WS_CLOSE_NOT_FOUND = 4404
83
+ WS_CLOSE_UNAVAILABLE = 4503
84
+ WS_CLOSE_NORMAL = 1000
85
+ WS_MAX_CLOSE_REASON_LEN = 123
86
+ ACCESS_COOKIE_NAME = "runtime_access"
87
+ SHARE_QUERY_PARAM = "runtime_share"
88
+ BOOTSTRAP_QUERY_PARAM = "runtime_bootstrap"
89
+ CREATOR_BOOTSTRAP_PATH = "/api/routes/creator-bootstrap/"
90
+ SHARE_LINK_SIGNING_SALT = "runtimecomputer.share-link"
91
+ CONSOLE_SESSION_SIGNING_SALT = "runtimecomputer.console-session"
92
+ EMBED_SESSION_SAMESITE = "None"
93
+ CORS_MAX_AGE = "600"
94
+
95
+ RUNTIME_SEED_MOUNT_PATH_ENV = "WORKSPACE_RUNTIME_MOUNT_PATH"
96
+ RUNTIME_SEED_ARCHIVE_ENV = "WORKSPACE_RUNTIME_SEED_ARCHIVE"
97
+ RUNTIME_SEED_PRESET_ENV = "WORKSPACE_RUNTIME_SEED_PRESET"
98
+ RUNTIME_SEED_VERSION_ENV = "WORKSPACE_RUNTIME_SEED_VERSION"
99
+
100
+
101
+ def build_api_origin(base_domain: str) -> str:
102
+ return f"https://api.{base_domain}"
103
+
104
+
105
+ def build_app_origin(base_domain: str) -> str:
106
+ return f"https://app.{base_domain}"
107
+
108
+
109
+ def build_local_origin(port: int, *, host: str = DEFAULT_LOCAL_HOST) -> str:
110
+ return f"http://{host}:{int(port)}"
111
+
112
+
113
+ def build_sign_in_url(frontend_origin: str, *, path: str = DEFAULT_SIGN_IN_PATH) -> str:
114
+ normalized_path = path if path.startswith("/") else f"/{path}"
115
+ return f"{frontend_origin.rstrip('/')}{normalized_path}"
116
+
117
+
118
+ __all__ = [
119
+ "ACCESS_COOKIE_NAME",
120
+ "AuthSource",
121
+ "BootstrapType",
122
+ "BOOTSTRAP_QUERY_PARAM",
123
+ "CLI_TOKEN_PREFIX",
124
+ "CLERK_JWT_ALGORITHMS",
125
+ "CLERK_SESSION_COOKIE",
126
+ "CLERK_SESSION_COOKIE_PREFIX",
127
+ "CONSOLE_SESSION_SIGNING_SALT",
128
+ "CORS_MAX_AGE",
129
+ "CREATOR_BOOTSTRAP_PATH",
130
+ "DEFAULT_ACCESS_BOOTSTRAP_TTL_SECONDS",
131
+ "DEFAULT_ACCESS_EMBED_TTL_SECONDS",
132
+ "DEFAULT_ACCESS_SESSION_TTL_SECONDS",
133
+ "DEFAULT_ACCESS_SHARE_LINK_TTL_SECONDS",
134
+ "DEFAULT_BACKEND_PORT",
135
+ "DEFAULT_BASE_DOMAIN",
136
+ "DEFAULT_CLI_AUTH_CONFIRM_PATH",
137
+ "DEFAULT_CLI_LOGIN_SESSION_TTL_SECONDS",
138
+ "DEFAULT_CONSOLE_WEBSOCKET_PATH",
139
+ "DEFAULT_CONSOLE_SESSION_TTL_SECONDS",
140
+ "DEFAULT_EDGE_PORT",
141
+ "DEFAULT_ENVIRONMENT",
142
+ "DEFAULT_FRONTEND_PORT",
143
+ "DEFAULT_LOCAL_HOST",
144
+ "DEFAULT_MODAL_APP_NAME",
145
+ "DEFAULT_MODAL_ENVIRONMENT",
146
+ "DEFAULT_MODAL_VOLUME_PREFIX",
147
+ "DEFAULT_PROVIDER_NAME",
148
+ "DEFAULT_RESTART_POLICY",
149
+ "DEFAULT_ROUTE_STARTUP_RETRY_AFTER_SECONDS",
150
+ "DEFAULT_ROUTE_WAKE_THROTTLE_SECONDS",
151
+ "DEFAULT_RUNTIME_DRIVER",
152
+ "DEFAULT_PORT_VISIBILITY",
153
+ "DEFAULT_SESSION_NAME",
154
+ "DEFAULT_SIGN_IN_PATH",
155
+ "DEFAULT_TARGET_SERVICE",
156
+ "DEFAULT_TEMPLATE",
157
+ "DEFAULT_WEB_PORT",
158
+ "DEFAULT_WORKSPACE_IDLE_TIMEOUT_SECONDS",
159
+ "DEFAULT_WORKSPACE_TIMEOUT_SECONDS",
160
+ "DEFAULT_WORKSPACE_DIR",
161
+ "EMBED_SESSION_SAMESITE",
162
+ "LOCAL_ENVIRONMENTS",
163
+ "RestartPolicy",
164
+ "RUNTIME_SEED_ARCHIVE_ENV",
165
+ "RUNTIME_SEED_MOUNT_PATH_ENV",
166
+ "RUNTIME_SEED_PRESET_ENV",
167
+ "RUNTIME_SEED_VERSION_ENV",
168
+ "RouteAccessMode",
169
+ "RouteAction",
170
+ "SHARE_QUERY_PARAM",
171
+ "SHARE_LINK_SIGNING_SALT",
172
+ "WS_CLOSE_FORBIDDEN",
173
+ "WS_CLOSE_NORMAL",
174
+ "WS_CLOSE_NOT_FOUND",
175
+ "WS_CLOSE_UNAUTHORIZED",
176
+ "WS_CLOSE_UNAVAILABLE",
177
+ "WS_EOF_SENTINEL",
178
+ "WS_MAX_CLOSE_REASON_LEN",
179
+ "WorkspaceStatus",
180
+ "build_api_origin",
181
+ "build_app_origin",
182
+ "build_local_origin",
183
+ "build_sign_in_url",
184
+ ]