@alchemy.run/daytona 0.0.0-stage → 2.0.0-beta.86

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 (274) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +80 -2
  3. package/lib/ApiKey.d.ts +99 -0
  4. package/lib/ApiKey.d.ts.map +1 -0
  5. package/lib/ApiKey.js +152 -0
  6. package/lib/ApiKey.js.map +1 -0
  7. package/lib/AuthProvider.d.ts +55 -0
  8. package/lib/AuthProvider.d.ts.map +1 -0
  9. package/lib/AuthProvider.js +280 -0
  10. package/lib/AuthProvider.js.map +1 -0
  11. package/lib/Bootstrap.d.ts +8 -0
  12. package/lib/Bootstrap.d.ts.map +1 -0
  13. package/lib/Bootstrap.js +28 -0
  14. package/lib/Bootstrap.js.map +1 -0
  15. package/lib/ConnectSandbox.d.ts +72 -0
  16. package/lib/ConnectSandbox.d.ts.map +1 -0
  17. package/lib/ConnectSandbox.js +3 -0
  18. package/lib/ConnectSandbox.js.map +1 -0
  19. package/lib/ConnectSandboxHttp.d.ts +5 -0
  20. package/lib/ConnectSandboxHttp.d.ts.map +1 -0
  21. package/lib/ConnectSandboxHttp.js +22 -0
  22. package/lib/ConnectSandboxHttp.js.map +1 -0
  23. package/lib/Contributions.d.ts +7 -0
  24. package/lib/Contributions.d.ts.map +1 -0
  25. package/lib/Contributions.js +6 -0
  26. package/lib/Contributions.js.map +1 -0
  27. package/lib/CreateSandbox.d.ts +86 -0
  28. package/lib/CreateSandbox.d.ts.map +1 -0
  29. package/lib/CreateSandbox.js +3 -0
  30. package/lib/CreateSandbox.js.map +1 -0
  31. package/lib/CreateSandboxHttp.d.ts +5 -0
  32. package/lib/CreateSandboxHttp.d.ts.map +1 -0
  33. package/lib/CreateSandboxHttp.js +65 -0
  34. package/lib/CreateSandboxHttp.js.map +1 -0
  35. package/lib/CreateSecret.d.ts +56 -0
  36. package/lib/CreateSecret.d.ts.map +1 -0
  37. package/lib/CreateSecret.js +3 -0
  38. package/lib/CreateSecret.js.map +1 -0
  39. package/lib/CreateSecretHttp.d.ts +5 -0
  40. package/lib/CreateSecretHttp.d.ts.map +1 -0
  41. package/lib/CreateSecretHttp.js +39 -0
  42. package/lib/CreateSecretHttp.js.map +1 -0
  43. package/lib/CreateSnapshot.d.ts +80 -0
  44. package/lib/CreateSnapshot.d.ts.map +1 -0
  45. package/lib/CreateSnapshot.js +3 -0
  46. package/lib/CreateSnapshot.js.map +1 -0
  47. package/lib/CreateSnapshotHttp.d.ts +5 -0
  48. package/lib/CreateSnapshotHttp.d.ts.map +1 -0
  49. package/lib/CreateSnapshotHttp.js +47 -0
  50. package/lib/CreateSnapshotHttp.js.map +1 -0
  51. package/lib/CreateVolume.d.ts +81 -0
  52. package/lib/CreateVolume.d.ts.map +1 -0
  53. package/lib/CreateVolume.js +10 -0
  54. package/lib/CreateVolume.js.map +1 -0
  55. package/lib/CreateVolumeHttp.d.ts +5 -0
  56. package/lib/CreateVolumeHttp.d.ts.map +1 -0
  57. package/lib/CreateVolumeHttp.js +31 -0
  58. package/lib/CreateVolumeHttp.js.map +1 -0
  59. package/lib/Credentials.d.ts +9 -0
  60. package/lib/Credentials.d.ts.map +1 -0
  61. package/lib/Credentials.js +18 -0
  62. package/lib/Credentials.js.map +1 -0
  63. package/lib/DaytonaBindings.d.ts +51 -0
  64. package/lib/DaytonaBindings.d.ts.map +1 -0
  65. package/lib/DaytonaBindings.js +61 -0
  66. package/lib/DaytonaBindings.js.map +1 -0
  67. package/lib/IdentityProvider.d.ts +80 -0
  68. package/lib/IdentityProvider.d.ts.map +1 -0
  69. package/lib/IdentityProvider.js +111 -0
  70. package/lib/IdentityProvider.js.map +1 -0
  71. package/lib/MountVolume.d.ts +86 -0
  72. package/lib/MountVolume.d.ts.map +1 -0
  73. package/lib/MountVolume.js +27 -0
  74. package/lib/MountVolume.js.map +1 -0
  75. package/lib/OAuthClient.d.ts +14 -0
  76. package/lib/OAuthClient.d.ts.map +1 -0
  77. package/lib/OAuthClient.js +23 -0
  78. package/lib/OAuthClient.js.map +1 -0
  79. package/lib/Organization.d.ts +40 -0
  80. package/lib/Organization.d.ts.map +1 -0
  81. package/lib/Organization.js +80 -0
  82. package/lib/Organization.js.map +1 -0
  83. package/lib/OrganizationInvitation.d.ts +70 -0
  84. package/lib/OrganizationInvitation.d.ts.map +1 -0
  85. package/lib/OrganizationInvitation.js +109 -0
  86. package/lib/OrganizationInvitation.js.map +1 -0
  87. package/lib/OrganizationMember.d.ts +86 -0
  88. package/lib/OrganizationMember.d.ts.map +1 -0
  89. package/lib/OrganizationMember.js +109 -0
  90. package/lib/OrganizationMember.js.map +1 -0
  91. package/lib/OrganizationOtelConfig.d.ts +59 -0
  92. package/lib/OrganizationOtelConfig.d.ts.map +1 -0
  93. package/lib/OrganizationOtelConfig.js +87 -0
  94. package/lib/OrganizationOtelConfig.js.map +1 -0
  95. package/lib/OrganizationRole.d.ts +66 -0
  96. package/lib/OrganizationRole.d.ts.map +1 -0
  97. package/lib/OrganizationRole.js +106 -0
  98. package/lib/OrganizationRole.js.map +1 -0
  99. package/lib/OrganizationSettings.d.ts +76 -0
  100. package/lib/OrganizationSettings.d.ts.map +1 -0
  101. package/lib/OrganizationSettings.js +107 -0
  102. package/lib/OrganizationSettings.js.map +1 -0
  103. package/lib/Providers.d.ts +14 -0
  104. package/lib/Providers.d.ts.map +1 -0
  105. package/lib/Providers.js +53 -0
  106. package/lib/Providers.js.map +1 -0
  107. package/lib/ReadAuditLogs.d.ts +30 -0
  108. package/lib/ReadAuditLogs.d.ts.map +1 -0
  109. package/lib/ReadAuditLogs.js +17 -0
  110. package/lib/ReadAuditLogs.js.map +1 -0
  111. package/lib/ReadOrganization.d.ts +39 -0
  112. package/lib/ReadOrganization.d.ts.map +1 -0
  113. package/lib/ReadOrganization.js +39 -0
  114. package/lib/ReadOrganization.js.map +1 -0
  115. package/lib/ReadUsage.d.ts +31 -0
  116. package/lib/ReadUsage.d.ts.map +1 -0
  117. package/lib/ReadUsage.js +17 -0
  118. package/lib/ReadUsage.js.map +1 -0
  119. package/lib/Region.d.ts +78 -0
  120. package/lib/Region.d.ts.map +1 -0
  121. package/lib/Region.js +169 -0
  122. package/lib/Region.js.map +1 -0
  123. package/lib/Registry.d.ts +84 -0
  124. package/lib/Registry.d.ts.map +1 -0
  125. package/lib/Registry.js +97 -0
  126. package/lib/Registry.js.map +1 -0
  127. package/lib/Runner.d.ts +66 -0
  128. package/lib/Runner.d.ts.map +1 -0
  129. package/lib/Runner.js +116 -0
  130. package/lib/Runner.js.map +1 -0
  131. package/lib/Sandbox.d.ts +376 -0
  132. package/lib/Sandbox.d.ts.map +1 -0
  133. package/lib/Sandbox.js +565 -0
  134. package/lib/Sandbox.js.map +1 -0
  135. package/lib/SandboxClient.d.ts +258 -0
  136. package/lib/SandboxClient.d.ts.map +1 -0
  137. package/lib/SandboxClient.js +233 -0
  138. package/lib/SandboxClient.js.map +1 -0
  139. package/lib/Secret.d.ts +93 -0
  140. package/lib/Secret.d.ts.map +1 -0
  141. package/lib/Secret.js +130 -0
  142. package/lib/Secret.js.map +1 -0
  143. package/lib/Snapshot.d.ts +327 -0
  144. package/lib/Snapshot.d.ts.map +1 -0
  145. package/lib/Snapshot.js +447 -0
  146. package/lib/Snapshot.js.map +1 -0
  147. package/lib/Volume.d.ts +99 -0
  148. package/lib/Volume.d.ts.map +1 -0
  149. package/lib/Volume.js +152 -0
  150. package/lib/Volume.js.map +1 -0
  151. package/lib/WarmPool.d.ts +61 -0
  152. package/lib/WarmPool.d.ts.map +1 -0
  153. package/lib/WarmPool.js +81 -0
  154. package/lib/WarmPool.js.map +1 -0
  155. package/lib/Webhooks.d.ts +58 -0
  156. package/lib/Webhooks.d.ts.map +1 -0
  157. package/lib/Webhooks.js +75 -0
  158. package/lib/Webhooks.js.map +1 -0
  159. package/lib/index.d.ts +37 -0
  160. package/lib/index.d.ts.map +1 -0
  161. package/lib/index.js +36 -0
  162. package/lib/index.js.map +1 -0
  163. package/lib/internal/BuildContext.d.ts +16 -0
  164. package/lib/internal/BuildContext.d.ts.map +1 -0
  165. package/lib/internal/BuildContext.js +50 -0
  166. package/lib/internal/BuildContext.js.map +1 -0
  167. package/lib/internal/Declared.d.ts +29 -0
  168. package/lib/internal/Declared.d.ts.map +1 -0
  169. package/lib/internal/Declared.js +31 -0
  170. package/lib/internal/Declared.js.map +1 -0
  171. package/lib/internal/Derived.d.ts +40 -0
  172. package/lib/internal/Derived.d.ts.map +1 -0
  173. package/lib/internal/Derived.js +64 -0
  174. package/lib/internal/Derived.js.map +1 -0
  175. package/lib/internal/Errors.d.ts +4 -0
  176. package/lib/internal/Errors.d.ts.map +1 -0
  177. package/lib/internal/Errors.js +1 -0
  178. package/lib/internal/Errors.js.map +1 -0
  179. package/lib/internal/Labels.d.ts +20 -0
  180. package/lib/internal/Labels.d.ts.map +1 -0
  181. package/lib/internal/Labels.js +22 -0
  182. package/lib/internal/Labels.js.map +1 -0
  183. package/lib/internal/Names.d.ts +18 -0
  184. package/lib/internal/Names.d.ts.map +1 -0
  185. package/lib/internal/Names.js +25 -0
  186. package/lib/internal/Names.js.map +1 -0
  187. package/lib/internal/Organization.d.ts +27 -0
  188. package/lib/internal/Organization.d.ts.map +1 -0
  189. package/lib/internal/Organization.js +32 -0
  190. package/lib/internal/Organization.js.map +1 -0
  191. package/lib/internal/Process.d.ts +14 -0
  192. package/lib/internal/Process.d.ts.map +1 -0
  193. package/lib/internal/Process.js +15 -0
  194. package/lib/internal/Process.js.map +1 -0
  195. package/lib/internal/Program.d.ts +83 -0
  196. package/lib/internal/Program.d.ts.map +1 -0
  197. package/lib/internal/Program.js +169 -0
  198. package/lib/internal/Program.js.map +1 -0
  199. package/lib/internal/Ref.d.ts +14 -0
  200. package/lib/internal/Ref.d.ts.map +1 -0
  201. package/lib/internal/Ref.js +7 -0
  202. package/lib/internal/Ref.js.map +1 -0
  203. package/lib/internal/Scoped.d.ts +31 -0
  204. package/lib/internal/Scoped.d.ts.map +1 -0
  205. package/lib/internal/Scoped.js +48 -0
  206. package/lib/internal/Scoped.js.map +1 -0
  207. package/lib/internal/Tar.d.ts +13 -0
  208. package/lib/internal/Tar.d.ts.map +1 -0
  209. package/lib/internal/Tar.js +62 -0
  210. package/lib/internal/Tar.js.map +1 -0
  211. package/lib/internal/Toolbox.d.ts +11 -0
  212. package/lib/internal/Toolbox.d.ts.map +1 -0
  213. package/lib/internal/Toolbox.js +20 -0
  214. package/lib/internal/Toolbox.js.map +1 -0
  215. package/lib/internal/Wait.d.ts +49 -0
  216. package/lib/internal/Wait.d.ts.map +1 -0
  217. package/lib/internal/Wait.js +57 -0
  218. package/lib/internal/Wait.js.map +1 -0
  219. package/package.json +79 -3
  220. package/src/ApiKey.ts +221 -0
  221. package/src/AuthProvider.ts +406 -0
  222. package/src/Bootstrap.ts +55 -0
  223. package/src/ConnectSandbox.ts +76 -0
  224. package/src/ConnectSandboxHttp.ts +26 -0
  225. package/src/Contributions.ts +9 -0
  226. package/src/CreateSandbox.ts +107 -0
  227. package/src/CreateSandboxHttp.ts +97 -0
  228. package/src/CreateSecret.ts +73 -0
  229. package/src/CreateSecretHttp.ts +58 -0
  230. package/src/CreateSnapshot.ts +133 -0
  231. package/src/CreateSnapshotHttp.ts +77 -0
  232. package/src/CreateVolume.ts +104 -0
  233. package/src/CreateVolumeHttp.ts +50 -0
  234. package/src/Credentials.ts +37 -0
  235. package/src/DaytonaBindings.ts +111 -0
  236. package/src/IdentityProvider.ts +181 -0
  237. package/src/MountVolume.ts +122 -0
  238. package/src/OAuthClient.ts +27 -0
  239. package/src/Organization.ts +121 -0
  240. package/src/OrganizationInvitation.ts +174 -0
  241. package/src/OrganizationMember.ts +174 -0
  242. package/src/OrganizationOtelConfig.ts +138 -0
  243. package/src/OrganizationRole.ts +167 -0
  244. package/src/OrganizationSettings.ts +187 -0
  245. package/src/Providers.ts +93 -0
  246. package/src/ReadAuditLogs.ts +50 -0
  247. package/src/ReadOrganization.ts +83 -0
  248. package/src/ReadUsage.ts +51 -0
  249. package/src/Region.ts +226 -0
  250. package/src/Registry.ts +164 -0
  251. package/src/Runner.ts +166 -0
  252. package/src/Sandbox.ts +927 -0
  253. package/src/SandboxClient.ts +625 -0
  254. package/src/Secret.ts +203 -0
  255. package/src/Snapshot.ts +685 -0
  256. package/src/Volume.ts +229 -0
  257. package/src/WarmPool.ts +128 -0
  258. package/src/Webhooks.ts +121 -0
  259. package/src/globals.d.ts +2 -0
  260. package/src/index.ts +46 -0
  261. package/src/internal/BuildContext.ts +62 -0
  262. package/src/internal/Declared.ts +80 -0
  263. package/src/internal/Derived.ts +97 -0
  264. package/src/internal/Errors.ts +4 -0
  265. package/src/internal/Labels.ts +39 -0
  266. package/src/internal/Names.ts +37 -0
  267. package/src/internal/Organization.ts +40 -0
  268. package/src/internal/Process.ts +25 -0
  269. package/src/internal/Program.ts +239 -0
  270. package/src/internal/Ref.ts +15 -0
  271. package/src/internal/Scoped.ts +102 -0
  272. package/src/internal/Tar.ts +72 -0
  273. package/src/internal/Toolbox.ts +27 -0
  274. package/src/internal/Wait.ts +105 -0
@@ -0,0 +1,376 @@
1
+ import * as sandboxes from "@distilled.cloud/daytona/sandbox";
2
+ import type * as Bundle from "alchemy/Bundle/Bundle";
3
+ import type { MountCapability } from "alchemy/Mount";
4
+ import { Platform, type Main, type PlatformProps } from "alchemy/Platform";
5
+ import * as Provider from "alchemy/Provider";
6
+ import type { Resource, LookupMethod } from "alchemy/Resource";
7
+ import { type HostRuntimeContext, type ServerHost } from "alchemy/Runtime/Process";
8
+ import { Stack } from "alchemy/Stack";
9
+ import type * as Duration from "effect/Duration";
10
+ import * as Effect from "effect/Effect";
11
+ import { type ProgramState } from "./internal/Program.ts";
12
+ import { type Ref } from "./internal/Ref.ts";
13
+ import type { Providers } from "./Providers.ts";
14
+ /** A snapshot, by name. Accepts a `Daytona.Snapshot` or `{ name }`. */
15
+ export type SandboxSnapshot = {
16
+ readonly name: string;
17
+ };
18
+ /** A volume, by id. Accepts a `Daytona.Volume` or `{ volumeId }`. */
19
+ export type SandboxVolumeRef = {
20
+ readonly volumeId: string;
21
+ };
22
+ /** A secret, by name. Accepts a `Daytona.Secret` or `{ name }`. */
23
+ export type SandboxSecretRef = {
24
+ readonly name: string;
25
+ };
26
+ /** A volume mounted into a sandbox. */
27
+ export interface SandboxMount {
28
+ /** The volume to mount: a `Daytona.Volume`. */
29
+ volume: Ref<SandboxVolumeRef>;
30
+ /** Absolute path in the sandbox. */
31
+ path: string;
32
+ /** Mount only this directory of the volume. */
33
+ subpath?: string;
34
+ }
35
+ /** A volume a binding mounts into a sandbox (`Daytona.MountVolume`). */
36
+ export interface SandboxVolumeBinding {
37
+ volumeId: string;
38
+ path: string;
39
+ subpath?: string;
40
+ }
41
+ /**
42
+ * What bindings attach to a sandbox that runs a program: environment
43
+ * variables for the process, and `mounts`: volumes to mount
44
+ * (`Daytona.MountVolume`), or `alchemy/Mount` capabilities whose clients
45
+ * the sandbox's image needs (a derived snapshot installs them).
46
+ */
47
+ export interface SandboxBinding {
48
+ env?: Record<string, any>;
49
+ mounts?: ReadonlyArray<SandboxVolumeBinding | MountCapability>;
50
+ }
51
+ /** Another sandbox, by id. Accepts a `Daytona.Sandbox` or `{ sandboxId }`. */
52
+ export type SandboxLinkRef = {
53
+ readonly sandboxId: string;
54
+ };
55
+ /** Whether the sandbox should be running, stopped (disk kept) or archived (moved to object storage). */
56
+ export type SandboxRunState = "started" | "stopped" | "archived";
57
+ export interface SandboxProps extends PlatformProps {
58
+ /**
59
+ * Sandbox name, unique in the organization. If omitted, a unique name is
60
+ * generated from the stack, stage and logical ID. Changing it replaces
61
+ * the sandbox.
62
+ */
63
+ name?: string;
64
+ /**
65
+ * Snapshot to boot from. Defaults to Daytona's default snapshot. The
66
+ * snapshot sets the sandbox's CPU, memory, disk and GPUs: declare a
67
+ * `Daytona.Snapshot` with the size you want. Changing it replaces the
68
+ * sandbox.
69
+ */
70
+ snapshot?: Ref<SandboxSnapshot>;
71
+ /** OS user commands run as. Changing it replaces the sandbox. */
72
+ user?: string;
73
+ /**
74
+ * Environment variables. On a sandbox without `main` they are the
75
+ * sandbox's, and changing them replaces it. On a sandbox with `main`
76
+ * they are the program's, and changing them restarts it.
77
+ */
78
+ env?: Record<string, any>;
79
+ /**
80
+ * Secrets exposed as environment variables, keyed by variable name. The
81
+ * sandbox sees each secret's placeholder; Daytona swaps in the value only
82
+ * on requests to the secret's `hosts`. Updated in place.
83
+ */
84
+ secrets?: Record<string, Ref<SandboxSecretRef>>;
85
+ /** Labels. Updated in place. */
86
+ labels?: Record<string, string>;
87
+ /** Whether preview URLs work without a token. Updated in place. @default false */
88
+ public?: boolean;
89
+ /** Block all outbound traffic. Updated in place. @default false */
90
+ networkBlockAll?: boolean;
91
+ /** CIDR ranges outbound traffic may reach (at most 10). Updated in place. */
92
+ networkAllowList?: string[];
93
+ /** Domains outbound traffic may reach (at most 100). Updated in place. */
94
+ domainAllowList?: string[];
95
+ /**
96
+ * A forward proxy for the sandbox's HTTP(S) traffic, set as `HTTP_PROXY`
97
+ * and `HTTPS_PROXY` in the sandbox, and enforced at the network only with a
98
+ * `domainAllowList`. HTTPS reaches it as `CONNECT` tunnels, so a Cloudflare
99
+ * Worker can't serve it. The sandbox can read the URL. Changing it
100
+ * replaces the sandbox.
101
+ */
102
+ outboundProxyUrl?: string;
103
+ /** Region. Changing it replaces the sandbox. */
104
+ target?: string;
105
+ /**
106
+ * Run a GPU sandbox on spot capacity: cheaper, but Daytona can end it
107
+ * without notice. Changing it replaces the sandbox.
108
+ */
109
+ spot?: boolean;
110
+ /** Expose `/dev/kvm` (VM sandboxes). Changing it replaces the sandbox. */
111
+ kvm?: boolean;
112
+ /**
113
+ * Volumes to mount. A program's `Daytona.MountVolume` bindings add to
114
+ * them. Changing them replaces the sandbox.
115
+ */
116
+ mounts?: SandboxMount[];
117
+ /** Stop after this long without activity. `0` never stops. Updated in place. @default "15 minutes" */
118
+ autoStopInterval?: Duration.Input;
119
+ /**
120
+ * Pause (memory kept) after this long without activity. Only `linux-vm`
121
+ * and `windows` sandboxes can pause; a container fails with
122
+ * `AutoPauseNotSupported`. Updated in place.
123
+ */
124
+ autoPauseInterval?: Duration.Input;
125
+ /** Archive after being stopped this long. Updated in place. @default "7 days" */
126
+ autoArchiveInterval?: Duration.Input;
127
+ /** Delete after being stopped this long. Updated in place. */
128
+ autoDeleteInterval?: Duration.Input;
129
+ /**
130
+ * Destroy the sandbox this long after it is created (or after the deploy
131
+ * that last changed it), whatever its state. Changing it restarts the
132
+ * clock from now. `0` disables it, unless the region caps sandbox lifespan.
133
+ */
134
+ ttl?: Duration.Input;
135
+ /**
136
+ * Give up if no runner takes the sandbox within this long. The
137
+ * organization needs the queue-timeout feature; without it, creating the
138
+ * sandbox fails with `QueueTimeoutNotEnabled`. Only used when the sandbox
139
+ * is created.
140
+ */
141
+ queueTimeout?: Duration.Input;
142
+ /**
143
+ * Schedule the sandbox on the same runner as this one, so the two share
144
+ * a local network. Both must be ephemeral (`autoDeleteInterval: 0`), and
145
+ * neither can have GPUs. Changing it replaces the sandbox.
146
+ */
147
+ linkedSandbox?: Ref<SandboxLinkRef>;
148
+ /**
149
+ * Send the sandbox's OpenTelemetry data here instead of Daytona's
150
+ * collector. It then doesn't show in Daytona's dashboard or the
151
+ * telemetry API. Changing it replaces the sandbox.
152
+ */
153
+ otelEndpointOverride?: string;
154
+ /**
155
+ * Whether the sandbox should be running, stopped (disk kept) or archived
156
+ * (disk moved to object storage). Archiving can take many minutes, so a
157
+ * deploy returns once Daytona has started it. Updated in place.
158
+ * @default "started"
159
+ */
160
+ state?: SandboxRunState;
161
+ /**
162
+ * Module entrypoint of a program to run in the sandbox, typically
163
+ * `import.meta.url` in the class form. Alchemy bundles it, uploads it
164
+ * into the sandbox and runs it with Node; a code change uploads it again
165
+ * and restarts the process, without replacing the sandbox. The snapshot
166
+ * needs Node.js 20 or later (Daytona's default snapshot has Node 24).
167
+ */
168
+ main?: string;
169
+ /**
170
+ * Port the program listens on. Written to `PORT`; the sandbox's preview
171
+ * URL of this port is `url`.
172
+ * @default 3000
173
+ */
174
+ port?: number;
175
+ /**
176
+ * Named export to load from `main`.
177
+ * @default "default"
178
+ */
179
+ handler?: string;
180
+ /** Bundler configuration for `main`. */
181
+ build?: Bundle.BundleConfig;
182
+ }
183
+ export interface SandboxAttributes {
184
+ /** Sandbox ID. */
185
+ sandboxId: string;
186
+ /** Sandbox name. */
187
+ name: string;
188
+ /** Organization ID. */
189
+ organizationId: string;
190
+ /** Snapshot it booted from. */
191
+ snapshot: string | undefined;
192
+ /** Current state. */
193
+ state: sandboxes.SandboxState | undefined;
194
+ /** Region. */
195
+ target: string;
196
+ /** vCPUs. */
197
+ cpu: number;
198
+ /** Memory in GiB. */
199
+ memory: number;
200
+ /** Disk in GiB. */
201
+ disk: number;
202
+ /** GPUs. */
203
+ gpu: number;
204
+ /** Sandbox class: `container`, `linux-vm` or `windows`, set by the snapshot. */
205
+ sandboxClass: sandboxes.SandboxSandboxClass | undefined;
206
+ /** When the TTL destroys the sandbox, if one is set. */
207
+ autoDestroyAt: string | undefined;
208
+ /** ID of the sandbox it shares a runner with. */
209
+ linkedSandboxId: string | undefined;
210
+ /** Labels you set (alchemy's ownership labels excluded). */
211
+ labels: Record<string, string>;
212
+ /** Whether previews are public. */
213
+ public: boolean;
214
+ /** Base URL of the sandbox's toolbox proxy. */
215
+ toolboxProxyUrl: string;
216
+ /**
217
+ * Preview URL of the program's port, for a sandbox with `main`. It is
218
+ * open when the sandbox is `public`; otherwise send the preview token
219
+ * (`getPortPreviewUrl`) in `X-Daytona-Preview-Token`.
220
+ */
221
+ url: string | undefined;
222
+ /** The program the sandbox runs, for a sandbox with `main`. */
223
+ program: ProgramState | undefined;
224
+ /**
225
+ * The snapshot built for this sandbox when its bindings need clients
226
+ * installed (`alchemy/Mount` capabilities): `FROM` its snapshot plus their
227
+ * install lines. Deleted with the sandbox.
228
+ */
229
+ derivedSnapshot: string | undefined;
230
+ }
231
+ export type Sandbox = Resource<"Daytona.Sandbox", SandboxProps, SandboxAttributes, SandboxBinding, Providers, SandboxLookup>;
232
+ /**
233
+ * Props for {@link Sandbox.lookup}: find a sandbox this stack
234
+ * doesn't manage by its name or id.
235
+ */
236
+ export interface SandboxLookup {
237
+ /** Sandbox name or id. */
238
+ name: string;
239
+ }
240
+ export type SandboxServices = ServerHost;
241
+ /** A program's shape: a long-running server returning `{ fetch }`, or `host.run` loops. */
242
+ export type SandboxShape = Main<SandboxServices>;
243
+ export type SandboxRuntimeContext = HostRuntimeContext;
244
+ /**
245
+ * A long-lived Daytona sandbox: an isolated machine with its own
246
+ * filesystem, processes and network, for a dev box, a preview environment
247
+ * or a persistent agent workspace. Its disk survives stops; Daytona stops
248
+ * it when idle and archives it later, and deploy starts it again.
249
+ *
250
+ * The class form runs an Effect program in the sandbox: give it `main`
251
+ * and an implementation, and Alchemy bundles the program, uploads it and
252
+ * runs it with Node, served on the sandbox's preview URL (`url`). A code
253
+ * change uploads the new bundle and restarts the process; the sandbox and
254
+ * its URL stay the same. The process lives as long as the sandbox runs,
255
+ * so a sandbox with `main` never auto-stops unless `autoStopInterval` says
256
+ * so; if it stopped anyway, the next deploy starts it and the program.
257
+ *
258
+ * For sandboxes created per request or per task, use
259
+ * {@link CreateSandbox} at runtime instead; for one declared here, use
260
+ * {@link ConnectSandbox} to run commands in it from a Worker.
261
+ * @see https://www.daytona.io/docs/en/sandboxes/
262
+ *
263
+ * ### Creating a Sandbox
264
+ * **Example:** A dev box from a snapshot
265
+ * ```typescript
266
+ * export const DevBox = Daytona.Sandbox("DevBox", {
267
+ * snapshot: Base,
268
+ * autoStopInterval: "30 minutes",
269
+ * });
270
+ * ```
271
+ *
272
+ * ### Restricting the Network
273
+ * **Example:** Only GitHub and npm are reachable
274
+ * ```typescript
275
+ * export const Locked = Daytona.Sandbox("Locked", {
276
+ * snapshot: Base,
277
+ * domainAllowList: ["github.com", "registry.npmjs.org"],
278
+ * });
279
+ * ```
280
+ *
281
+ * ### Volumes and Secrets
282
+ * **Example:** A shared cache volume and an npm token only sent to npm
283
+ * ```typescript
284
+ * export const Builder = Daytona.Sandbox("Builder", {
285
+ * snapshot: Base,
286
+ * mounts: [{ volume: Cache, path: "/cache" }],
287
+ * secrets: { NPM_TOKEN: NpmToken },
288
+ * });
289
+ * ```
290
+ *
291
+ * ### Running a Program
292
+ * **Example:** An HTTP server with a mounted volume
293
+ * ```typescript
294
+ * export default class Agent extends Daytona.Sandbox<Agent>()(
295
+ * "Agent",
296
+ * { snapshot: Base, main: import.meta.url, public: true },
297
+ * Effect.gen(function* () {
298
+ * const data = yield* Daytona.MountVolume(Data, { path: "/data" });
299
+ * const fs = yield* FileSystem.FileSystem;
300
+ * return {
301
+ * fetch: Effect.gen(function* () {
302
+ * return yield* HttpServerResponse.json(yield* fs.readDirectory(data.path));
303
+ * }),
304
+ * };
305
+ * }).pipe(Effect.provide(Daytona.MountVolumeLive)),
306
+ * ) {}
307
+ * ```
308
+ *
309
+ * A mount binding that needs a client in the image (an `alchemy/Mount`
310
+ * capability) makes the sandbox boot from a derived snapshot: its snapshot
311
+ * plus the client's install lines, built on Daytona, named from a hash and
312
+ * deleted with the sandbox. Sandboxes provide FUSE; a client that needs
313
+ * NFS fails with `MountUnsupported`.
314
+ *
315
+ * The program reaches the internet as its sandbox does. Below Daytona's
316
+ * Tier 3, sandboxes reach only an allowlist of essential services
317
+ * (package registries, GitHub, AI APIs, Daytona's API), so bindings that
318
+ * manage sandboxes work but toolbox calls are refused.
319
+ *
320
+ * ### GPUs
321
+ * A GPU sandbox boots from a GPU snapshot, such as Daytona's `daytona-gpu`
322
+ * (one H100) in its `earth` region, and must be ephemeral. The
323
+ * organization needs GPU credits in its wallet.
324
+ *
325
+ * **Example:** An ephemeral H100 sandbox on spot capacity
326
+ * ```typescript
327
+ * export const Trainer = Daytona.Sandbox("Trainer", {
328
+ * snapshot: { name: "daytona-gpu" },
329
+ * target: "earth",
330
+ * autoDeleteInterval: 0,
331
+ * spot: true,
332
+ * });
333
+ * ```
334
+ *
335
+ * ### Limiting Its Lifetime
336
+ * **Example:** Destroyed two hours after it is created
337
+ * ```typescript
338
+ * export const Scratch = Daytona.Sandbox("Scratch", { ttl: "2 hours" });
339
+ * ```
340
+ *
341
+ * ### Sharing a Runner
342
+ * **Example:** A database and an app on one local network
343
+ * ```typescript
344
+ * export const Db = Daytona.Sandbox("Db", { autoDeleteInterval: 0 });
345
+ * export const App = Daytona.Sandbox("App", {
346
+ * autoDeleteInterval: 0,
347
+ * linkedSandbox: Db,
348
+ * });
349
+ * ```
350
+ *
351
+ * ### Looking up an existing sandbox
352
+ * `Sandbox.lookup` references a sandbox Alchemy doesn't manage (created in
353
+ * the Daytona dashboard or by another stack). It is read during plan/deploy,
354
+ * never created, updated or deleted.
355
+ * `url` and `program` are `undefined`: they come from the deploy that started
356
+ * the sandbox's program.
357
+ *
358
+ * **Example:** Reference an existing sandbox
359
+ * ```typescript
360
+ * const box = Daytona.Sandbox.lookup({ name: "research" });
361
+ * ```
362
+ *
363
+ * @resource
364
+ * @product Sandbox
365
+ */
366
+ export declare const Sandbox: Platform<Sandbox, SandboxServices, SandboxShape, SandboxRuntimeContext> & LookupMethod<Sandbox>;
367
+ /** What both `getSandbox` and the sandbox list return. */
368
+ export type SandboxInfo = Omit<sandboxes.Sandbox2, "env" | "kvm">;
369
+ export declare const toSandboxAttributes: (s: SandboxInfo) => SandboxAttributes;
370
+ export declare const getSandbox: (idOrName: string) => Effect.Effect<sandboxes.Sandbox2 | undefined, sandboxes.DaytonaOpError, sandboxes.DaytonaOpContext>;
371
+ export declare const waitForSandbox: (idOrName: string, want?: SandboxRunState | "paused") => Effect.Effect<sandboxes.Sandbox2, import("./internal/Wait.ts").StateFailed | import("./internal/Wait.ts").StateTimeout | sandboxes.GetSandboxError, sandboxes.DaytonaOpContext>;
372
+ /** Move a sandbox to the run state it should be in. */
373
+ export declare const syncRunState: (current: sandboxes.Sandbox2, want: SandboxRunState) => Effect.Effect<sandboxes.Sandbox2, import("./internal/Wait.ts").StateFailed | import("./internal/Wait.ts").StateTimeout | sandboxes.GetSandboxError, sandboxes.DaytonaOpContext>;
374
+ export declare const deleteSandboxById: (idOrName: string) => Effect.Effect<void, import("./internal/Wait.ts").StateTimeout | sandboxes.DaytonaOpError, sandboxes.DaytonaOpContext>;
375
+ export declare const SandboxProvider: () => import("effect/Layer").Layer<Provider.Provider<Sandbox>, never, import("effect/FileSystem").FileSystem | import("effect/Path").Path | Stack | import("alchemy/Stage").Stage | sandboxes.DaytonaOpContext>;
376
+ //# sourceMappingURL=Sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sandbox.d.ts","sources":["../src/Sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAC;AAE9D,OAAO,KAAK,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAmB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAiBxC,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,uEAAuE;AACvE,MAAM,MAAM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