@alchemy.run/e2b 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 (284) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +60 -2
  3. package/lib/ApiKey.d.ts +53 -0
  4. package/lib/ApiKey.d.ts.map +1 -0
  5. package/lib/ApiKey.js +107 -0
  6. package/lib/ApiKey.js.map +1 -0
  7. package/lib/AuthProvider.d.ts +60 -0
  8. package/lib/AuthProvider.d.ts.map +1 -0
  9. package/lib/AuthProvider.js +293 -0
  10. package/lib/AuthProvider.js.map +1 -0
  11. package/lib/Bootstrap.d.ts +7 -0
  12. package/lib/Bootstrap.d.ts.map +1 -0
  13. package/lib/Bootstrap.js +25 -0
  14. package/lib/Bootstrap.js.map +1 -0
  15. package/lib/ConnectSandbox.d.ts +67 -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 +22 -0
  20. package/lib/ConnectSandboxHttp.d.ts.map +1 -0
  21. package/lib/ConnectSandboxHttp.js +30 -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 +139 -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 +22 -0
  32. package/lib/CreateSandboxHttp.d.ts.map +1 -0
  33. package/lib/CreateSandboxHttp.js +99 -0
  34. package/lib/CreateSandboxHttp.js.map +1 -0
  35. package/lib/CreateSecret.d.ts +57 -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 +20 -0
  40. package/lib/CreateSecretHttp.d.ts.map +1 -0
  41. package/lib/CreateSecretHttp.js +64 -0
  42. package/lib/CreateSecretHttp.js.map +1 -0
  43. package/lib/CreateSnapshot.d.ts +53 -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 +20 -0
  48. package/lib/CreateSnapshotHttp.d.ts.map +1 -0
  49. package/lib/CreateSnapshotHttp.js +41 -0
  50. package/lib/CreateSnapshotHttp.js.map +1 -0
  51. package/lib/CreateTemplate.d.ts +96 -0
  52. package/lib/CreateTemplate.d.ts.map +1 -0
  53. package/lib/CreateTemplate.js +3 -0
  54. package/lib/CreateTemplate.js.map +1 -0
  55. package/lib/CreateTemplateHttp.d.ts +20 -0
  56. package/lib/CreateTemplateHttp.d.ts.map +1 -0
  57. package/lib/CreateTemplateHttp.js +99 -0
  58. package/lib/CreateTemplateHttp.js.map +1 -0
  59. package/lib/CreateVolume.d.ts +58 -0
  60. package/lib/CreateVolume.d.ts.map +1 -0
  61. package/lib/CreateVolume.js +3 -0
  62. package/lib/CreateVolume.js.map +1 -0
  63. package/lib/CreateVolumeHttp.d.ts +20 -0
  64. package/lib/CreateVolumeHttp.d.ts.map +1 -0
  65. package/lib/CreateVolumeHttp.js +51 -0
  66. package/lib/CreateVolumeHttp.js.map +1 -0
  67. package/lib/Credentials.d.ts +18 -0
  68. package/lib/Credentials.d.ts.map +1 -0
  69. package/lib/Credentials.js +55 -0
  70. package/lib/Credentials.js.map +1 -0
  71. package/lib/E2BBindings.d.ts +35 -0
  72. package/lib/E2BBindings.d.ts.map +1 -0
  73. package/lib/E2BBindings.js +127 -0
  74. package/lib/E2BBindings.js.map +1 -0
  75. package/lib/Errors.d.ts +61 -0
  76. package/lib/Errors.d.ts.map +1 -0
  77. package/lib/Errors.js +23 -0
  78. package/lib/Errors.js.map +1 -0
  79. package/lib/InferEnv.d.ts +26 -0
  80. package/lib/InferEnv.d.ts.map +1 -0
  81. package/lib/InferEnv.js +1 -0
  82. package/lib/InferEnv.js.map +1 -0
  83. package/lib/MountVolume.d.ts +86 -0
  84. package/lib/MountVolume.d.ts.map +1 -0
  85. package/lib/MountVolume.js +3 -0
  86. package/lib/MountVolume.js.map +1 -0
  87. package/lib/MountVolumeLive.d.ts +23 -0
  88. package/lib/MountVolumeLive.d.ts.map +1 -0
  89. package/lib/MountVolumeLive.js +41 -0
  90. package/lib/MountVolumeLive.js.map +1 -0
  91. package/lib/Providers.d.ts +14 -0
  92. package/lib/Providers.d.ts.map +1 -0
  93. package/lib/Providers.js +23 -0
  94. package/lib/Providers.js.map +1 -0
  95. package/lib/ReadTeam.d.ts +41 -0
  96. package/lib/ReadTeam.d.ts.map +1 -0
  97. package/lib/ReadTeam.js +3 -0
  98. package/lib/ReadTeam.js.map +1 -0
  99. package/lib/ReadTeamHttp.d.ts +20 -0
  100. package/lib/ReadTeamHttp.d.ts.map +1 -0
  101. package/lib/ReadTeamHttp.js +40 -0
  102. package/lib/ReadTeamHttp.js.map +1 -0
  103. package/lib/ReadVolume.d.ts +25 -0
  104. package/lib/ReadVolume.d.ts.map +1 -0
  105. package/lib/ReadVolume.js +3 -0
  106. package/lib/ReadVolume.js.map +1 -0
  107. package/lib/ReadVolumeHttp.d.ts +20 -0
  108. package/lib/ReadVolumeHttp.d.ts.map +1 -0
  109. package/lib/ReadVolumeHttp.js +27 -0
  110. package/lib/ReadVolumeHttp.js.map +1 -0
  111. package/lib/ReadWebhook.d.ts +32 -0
  112. package/lib/ReadWebhook.d.ts.map +1 -0
  113. package/lib/ReadWebhook.js +3 -0
  114. package/lib/ReadWebhook.js.map +1 -0
  115. package/lib/ReadWebhookHttp.d.ts +20 -0
  116. package/lib/ReadWebhookHttp.d.ts.map +1 -0
  117. package/lib/ReadWebhookHttp.js +31 -0
  118. package/lib/ReadWebhookHttp.js.map +1 -0
  119. package/lib/ReadWriteVolume.d.ts +26 -0
  120. package/lib/ReadWriteVolume.d.ts.map +1 -0
  121. package/lib/ReadWriteVolume.js +3 -0
  122. package/lib/ReadWriteVolume.js.map +1 -0
  123. package/lib/ReadWriteVolumeHttp.d.ts +20 -0
  124. package/lib/ReadWriteVolumeHttp.d.ts.map +1 -0
  125. package/lib/ReadWriteVolumeHttp.js +27 -0
  126. package/lib/ReadWriteVolumeHttp.js.map +1 -0
  127. package/lib/Sandbox.d.ts +295 -0
  128. package/lib/Sandbox.d.ts.map +1 -0
  129. package/lib/Sandbox.js +351 -0
  130. package/lib/Sandbox.js.map +1 -0
  131. package/lib/SandboxClient.d.ts +226 -0
  132. package/lib/SandboxClient.d.ts.map +1 -0
  133. package/lib/SandboxClient.js +1 -0
  134. package/lib/SandboxClient.js.map +1 -0
  135. package/lib/SandboxEvents.d.ts +87 -0
  136. package/lib/SandboxEvents.d.ts.map +1 -0
  137. package/lib/SandboxEvents.js +39 -0
  138. package/lib/SandboxEvents.js.map +1 -0
  139. package/lib/SandboxEventsLive.d.ts +13 -0
  140. package/lib/SandboxEventsLive.d.ts.map +1 -0
  141. package/lib/SandboxEventsLive.js +80 -0
  142. package/lib/SandboxEventsLive.js.map +1 -0
  143. package/lib/Secret.d.ts +105 -0
  144. package/lib/Secret.d.ts.map +1 -0
  145. package/lib/Secret.js +161 -0
  146. package/lib/Secret.js.map +1 -0
  147. package/lib/Snapshot.d.ts +118 -0
  148. package/lib/Snapshot.d.ts.map +1 -0
  149. package/lib/Snapshot.js +158 -0
  150. package/lib/Snapshot.js.map +1 -0
  151. package/lib/Template.d.ts +313 -0
  152. package/lib/Template.d.ts.map +1 -0
  153. package/lib/Template.js +421 -0
  154. package/lib/Template.js.map +1 -0
  155. package/lib/Volume.d.ts +88 -0
  156. package/lib/Volume.d.ts.map +1 -0
  157. package/lib/Volume.js +136 -0
  158. package/lib/Volume.js.map +1 -0
  159. package/lib/VolumeFiles.d.ts +39 -0
  160. package/lib/VolumeFiles.d.ts.map +1 -0
  161. package/lib/VolumeFiles.js +1 -0
  162. package/lib/VolumeFiles.js.map +1 -0
  163. package/lib/Webhook.d.ts +83 -0
  164. package/lib/Webhook.d.ts.map +1 -0
  165. package/lib/Webhook.js +138 -0
  166. package/lib/Webhook.js.map +1 -0
  167. package/lib/WriteSecret.d.ts +34 -0
  168. package/lib/WriteSecret.d.ts.map +1 -0
  169. package/lib/WriteSecret.js +3 -0
  170. package/lib/WriteSecret.js.map +1 -0
  171. package/lib/WriteSecretHttp.d.ts +20 -0
  172. package/lib/WriteSecretHttp.d.ts.map +1 -0
  173. package/lib/WriteSecretHttp.js +37 -0
  174. package/lib/WriteSecretHttp.js.map +1 -0
  175. package/lib/WriteVolume.d.ts +25 -0
  176. package/lib/WriteVolume.d.ts.map +1 -0
  177. package/lib/WriteVolume.js +3 -0
  178. package/lib/WriteVolume.js.map +1 -0
  179. package/lib/WriteVolumeHttp.d.ts +20 -0
  180. package/lib/WriteVolumeHttp.d.ts.map +1 -0
  181. package/lib/WriteVolumeHttp.js +27 -0
  182. package/lib/WriteVolumeHttp.js.map +1 -0
  183. package/lib/index.d.ts +43 -0
  184. package/lib/index.d.ts.map +1 -0
  185. package/lib/index.js +43 -0
  186. package/lib/index.js.map +1 -0
  187. package/lib/internal/Declared.d.ts +29 -0
  188. package/lib/internal/Declared.d.ts.map +1 -0
  189. package/lib/internal/Declared.js +31 -0
  190. package/lib/internal/Declared.js.map +1 -0
  191. package/lib/internal/Login.d.ts +45 -0
  192. package/lib/internal/Login.d.ts.map +1 -0
  193. package/lib/internal/Login.js +157 -0
  194. package/lib/internal/Login.js.map +1 -0
  195. package/lib/internal/Ownership.d.ts +29 -0
  196. package/lib/internal/Ownership.d.ts.map +1 -0
  197. package/lib/internal/Ownership.js +49 -0
  198. package/lib/internal/Ownership.js.map +1 -0
  199. package/lib/internal/Program.d.ts +31 -0
  200. package/lib/internal/Program.d.ts.map +1 -0
  201. package/lib/internal/Program.js +60 -0
  202. package/lib/internal/Program.js.map +1 -0
  203. package/lib/internal/SandboxHandle.d.ts +25 -0
  204. package/lib/internal/SandboxHandle.d.ts.map +1 -0
  205. package/lib/internal/SandboxHandle.js +316 -0
  206. package/lib/internal/SandboxHandle.js.map +1 -0
  207. package/lib/internal/SnapshotBuild.d.ts +19 -0
  208. package/lib/internal/SnapshotBuild.d.ts.map +1 -0
  209. package/lib/internal/SnapshotBuild.js +49 -0
  210. package/lib/internal/SnapshotBuild.js.map +1 -0
  211. package/lib/internal/Tar.d.ts +10 -0
  212. package/lib/internal/Tar.d.ts.map +1 -0
  213. package/lib/internal/Tar.js +61 -0
  214. package/lib/internal/Tar.js.map +1 -0
  215. package/lib/internal/TemplateBuild.d.ts +142 -0
  216. package/lib/internal/TemplateBuild.d.ts.map +1 -0
  217. package/lib/internal/TemplateBuild.js +220 -0
  218. package/lib/internal/TemplateBuild.js.map +1 -0
  219. package/lib/internal/TemplatePlan.d.ts +57 -0
  220. package/lib/internal/TemplatePlan.d.ts.map +1 -0
  221. package/lib/internal/TemplatePlan.js +185 -0
  222. package/lib/internal/TemplatePlan.js.map +1 -0
  223. package/lib/internal/VolumeHttp.d.ts +5 -0
  224. package/lib/internal/VolumeHttp.d.ts.map +1 -0
  225. package/lib/internal/VolumeHttp.js +46 -0
  226. package/lib/internal/VolumeHttp.js.map +1 -0
  227. package/package.json +78 -3
  228. package/src/ApiKey.ts +148 -0
  229. package/src/AuthProvider.ts +437 -0
  230. package/src/Bootstrap.ts +51 -0
  231. package/src/ConnectSandbox.ts +71 -0
  232. package/src/ConnectSandboxHttp.ts +38 -0
  233. package/src/Contributions.ts +9 -0
  234. package/src/CreateSandbox.ts +157 -0
  235. package/src/CreateSandboxHttp.ts +131 -0
  236. package/src/CreateSecret.ts +65 -0
  237. package/src/CreateSecretHttp.ts +94 -0
  238. package/src/CreateSnapshot.ts +64 -0
  239. package/src/CreateSnapshotHttp.ts +55 -0
  240. package/src/CreateTemplate.ts +135 -0
  241. package/src/CreateTemplateHttp.ts +152 -0
  242. package/src/CreateVolume.ts +65 -0
  243. package/src/CreateVolumeHttp.ts +80 -0
  244. package/src/Credentials.ts +81 -0
  245. package/src/E2BBindings.ts +160 -0
  246. package/src/Errors.ts +47 -0
  247. package/src/InferEnv.ts +27 -0
  248. package/src/MountVolume.ts +92 -0
  249. package/src/MountVolumeLive.ts +49 -0
  250. package/src/Providers.ts +48 -0
  251. package/src/ReadTeam.ts +55 -0
  252. package/src/ReadTeamHttp.ts +44 -0
  253. package/src/ReadVolume.ts +29 -0
  254. package/src/ReadVolumeHttp.ts +32 -0
  255. package/src/ReadWebhook.ts +41 -0
  256. package/src/ReadWebhookHttp.ts +42 -0
  257. package/src/ReadWriteVolume.ts +30 -0
  258. package/src/ReadWriteVolumeHttp.ts +32 -0
  259. package/src/Sandbox.ts +581 -0
  260. package/src/SandboxClient.ts +268 -0
  261. package/src/SandboxEvents.ts +101 -0
  262. package/src/SandboxEventsLive.ts +118 -0
  263. package/src/Secret.ts +229 -0
  264. package/src/Snapshot.ts +234 -0
  265. package/src/Template.ts +636 -0
  266. package/src/Volume.ts +173 -0
  267. package/src/VolumeFiles.ts +53 -0
  268. package/src/Webhook.ts +215 -0
  269. package/src/WriteSecret.ts +39 -0
  270. package/src/WriteSecretHttp.ts +43 -0
  271. package/src/WriteVolume.ts +29 -0
  272. package/src/WriteVolumeHttp.ts +32 -0
  273. package/src/globals.d.ts +2 -0
  274. package/src/index.ts +42 -0
  275. package/src/internal/Declared.ts +80 -0
  276. package/src/internal/Login.ts +210 -0
  277. package/src/internal/Ownership.ts +67 -0
  278. package/src/internal/Program.ts +75 -0
  279. package/src/internal/SandboxHandle.ts +534 -0
  280. package/src/internal/SnapshotBuild.ts +74 -0
  281. package/src/internal/Tar.ts +74 -0
  282. package/src/internal/TemplateBuild.ts +383 -0
  283. package/src/internal/TemplatePlan.ts +230 -0
  284. package/src/internal/VolumeHttp.ts +88 -0
@@ -0,0 +1,158 @@
1
+ import * as crypto from "node:crypto";
2
+ import * as templates from "@distilled.cloud/e2b/templates";
3
+ import { Unowned } from "alchemy/AdoptPolicy";
4
+ import { isResolved } from "alchemy/Diff";
5
+ import * as Provider from "alchemy/Provider";
6
+ import { Resource } from "alchemy/Resource";
7
+ import * as Effect from "effect/Effect";
8
+ import * as Stream from "effect/Stream";
9
+ import { declarable } from "./internal/Declared.js";
10
+ import { e2bName, isGeneratedName } from "./internal/Ownership.js";
11
+ import { takeSnapshot } from "./internal/SnapshotBuild.js";
12
+ /**
13
+ * A warm base to fork sandboxes from: a template booted, set up with your
14
+ * commands, and snapshotted — memory included, so sandboxes created from it
15
+ * start exactly where the setup left off.
16
+ *
17
+ * Use a snapshot for work that is too slow to repeat per sandbox and does
18
+ * not belong in an image: cloning a repository, installing its
19
+ * dependencies, starting a language server. A deploy re-runs the setup only
20
+ * when the template or the commands change. E2B stores a snapshot as a
21
+ * template, so it is created from with `E2B.CreateSandbox(snapshot)` and
22
+ * deleted with its template.
23
+ *
24
+ * ### Creating a Snapshot
25
+ * **Example:** A repository with its dependencies installed
26
+ * ```typescript
27
+ * export const Agent = E2B.Template("Agent", { image: "node:22-bookworm" });
28
+ *
29
+ * export const Warm = E2B.Snapshot("Warm", {
30
+ * template: Agent,
31
+ * run: [
32
+ * "git clone https://github.com/alchemy-run/alchemy /home/user/alchemy",
33
+ * "cd /home/user/alchemy && pnpm install",
34
+ * ],
35
+ * });
36
+ * ```
37
+ *
38
+ * ### Forking sandboxes from a Snapshot
39
+ * **Example:** Every sandbox starts from the warm base
40
+ * ```typescript
41
+ * const sandboxes = yield* E2B.CreateSandbox(Warm);
42
+ * const sandbox = yield* sandboxes.create({ timeout: 600 });
43
+ * yield* sandbox.exec("cd alchemy && pnpm test");
44
+ * ```
45
+ *
46
+ * ### Referencing a snapshot the stack doesn't manage
47
+ * `E2B.Snapshot.lookup` finds an existing snapshot by name. Nothing is created,
48
+ * adopted or deleted.
49
+ *
50
+ * **Example:** Look one up by name
51
+ * ```typescript
52
+ * const warm = E2B.Snapshot.lookup({ name: "warm-repo" });
53
+ * const sandboxes = yield* E2B.CreateSandbox(warm);
54
+ * ```
55
+ *
56
+ * @resource
57
+ * @product Snapshot
58
+ */
59
+ export const Snapshot = declarable()(Resource("E2B.Snapshot"));
60
+ const setupHashOf = (props) => crypto
61
+ .createHash("sha256")
62
+ .update(JSON.stringify({
63
+ template: props.template.templateId,
64
+ build: props.template.buildId ?? props.template.setupHash,
65
+ run: props.run,
66
+ envs: props.envs,
67
+ cwd: props.cwd,
68
+ memory: props.memory ?? true,
69
+ }))
70
+ .digest("hex");
71
+ /** The snapshot template, by alias. */
72
+ const observe = (name) => templates.getTemplateByAlias({ alias: name }).pipe(Effect.flatMap((alias) => templates.getTemplate({ templateID: alias.templateID })), Effect.map((template) => template), Effect.catchTag("NotFound", () => Effect.undefined));
73
+ export const SnapshotProvider = () => Provider.effect(Snapshot, Effect.gen(function* () {
74
+ return {
75
+ stables: ["name", "templateId"],
76
+ diff: Effect.fn(function* ({ id, olds, news, output }) {
77
+ if (!isResolved(news))
78
+ return undefined;
79
+ const name = output?.name ?? (yield* e2bName(id, olds?.name));
80
+ if (news.name !== undefined && news.name !== name)
81
+ return { action: "replace" };
82
+ if (output !== undefined && setupHashOf(news) !== output.setupHash) {
83
+ return { action: "update" };
84
+ }
85
+ return undefined;
86
+ }),
87
+ lookup: Effect.fn(function* ({ name }) {
88
+ const template = yield* observe(name);
89
+ if (template === undefined)
90
+ return undefined;
91
+ return {
92
+ snapshotId: template.names[0] ?? template.templateID,
93
+ name,
94
+ templateId: template.templateID,
95
+ names: [...template.names],
96
+ setupHash: "",
97
+ };
98
+ }),
99
+ read: Effect.fn(function* ({ id, olds, output }) {
100
+ const name = output?.name ?? (yield* e2bName(id, olds?.name));
101
+ const template = yield* observe(name);
102
+ if (template === undefined)
103
+ return undefined;
104
+ const attrs = {
105
+ snapshotId: output?.snapshotId ?? template.names[0] ?? template.templateID,
106
+ name,
107
+ templateId: template.templateID,
108
+ names: [...template.names],
109
+ setupHash: output?.setupHash ?? "",
110
+ };
111
+ return output !== undefined || olds?.name === undefined ? attrs : Unowned(attrs);
112
+ }),
113
+ reconcile: Effect.fn(function* ({ id, news, output, session }) {
114
+ const name = output?.name ?? (yield* e2bName(id, news.name));
115
+ const setupHash = setupHashOf(news);
116
+ // Observe — an existing ready snapshot of this exact setup is kept.
117
+ const observed = yield* observe(name);
118
+ if (observed !== undefined &&
119
+ observed.buildStatus === "ready" &&
120
+ output?.setupHash === setupHash) {
121
+ return { ...output, names: [...observed.names], templateId: observed.templateID };
122
+ }
123
+ // Ensure — snapshotting under an existing name adds a new build to
124
+ // the same template.
125
+ yield* session.note(`Snapshotting ${name}...`);
126
+ const snapshot = yield* takeSnapshot(name, {
127
+ ...news,
128
+ template: news.template.templateId,
129
+ });
130
+ const template = yield* observe(name);
131
+ return {
132
+ snapshotId: snapshot.snapshotID,
133
+ name,
134
+ templateId: template?.templateID ?? snapshot.snapshotID,
135
+ names: [...snapshot.names],
136
+ setupHash,
137
+ };
138
+ }),
139
+ delete: Effect.fn(function* ({ output }) {
140
+ yield* templates
141
+ .deleteTemplate({ templateID: output.templateId })
142
+ .pipe(Effect.catchTag("NotFound", () => Effect.void));
143
+ }),
144
+ list: Effect.fn(function* () {
145
+ const all = Array.from(yield* Stream.runCollect(templates.listTemplates.items({ limit: 100 })));
146
+ return all
147
+ .filter((template) => template.aliases.some(isGeneratedName))
148
+ .map((template) => ({
149
+ snapshotId: template.names[0] ?? template.templateID,
150
+ name: template.aliases.find(isGeneratedName) ?? template.templateID,
151
+ templateId: template.templateID,
152
+ names: [...template.names],
153
+ setupHash: "",
154
+ }));
155
+ }),
156
+ };
157
+ }));
158
+ //# sourceMappingURL=Snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Snapshot.js","sources":["../src/Snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAA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as templates from "@distilled.cloud/e2b/templates";
4
+ import type * as Bundle from "alchemy/Bundle/Bundle";
5
+ import { type MountCapability } from "alchemy/Mount";
6
+ import { Platform, type Main, type PlatformProps } from "alchemy/Platform";
7
+ import * as Provider from "alchemy/Provider";
8
+ import type { Resource } from "alchemy/Resource";
9
+ import { type HostRuntimeContext, type ServerHost } from "alchemy/Runtime/Process";
10
+ import * as Effect from "effect/Effect";
11
+ import { type TemplateSteps } from "./internal/TemplateBuild.ts";
12
+ import type { VolumeMount } from "./MountVolume.ts";
13
+ import type { Providers } from "./Providers.ts";
14
+ export type { TemplateFile, TemplateRegistry, TemplateSteps } from "./internal/TemplateBuild.ts";
15
+ export interface TemplateProps extends Omit<TemplateSteps, "env">, PlatformProps {
16
+ /**
17
+ * A Dockerfile: a path (relative to the working directory) or inline
18
+ * content (`Dockerfile.inline` from `@alchemy.run/docker`). Lowered to
19
+ * E2B build steps; see the resource docs for what E2B supports.
20
+ * Exclusive with `image` and `fromTemplate` unless `main` is set, where
21
+ * it is the program's environment.
22
+ */
23
+ dockerfile?: string | InlineDockerfile;
24
+ /**
25
+ * The directory `COPY` / `ADD` sources are relative to, for a Dockerfile
26
+ * path. An inline Dockerfile has no build context.
27
+ * @default the working directory
28
+ */
29
+ context?: string;
30
+ /**
31
+ * A program to run in every sandbox: a module entrypoint, typically
32
+ * `import.meta.url` in the class form. Alchemy bundles it, copies it into
33
+ * the template under `/app`, and starts it with Bun as the template's start
34
+ * command, so every sandbox boots with it already serving on {@link port}.
35
+ * `image` / `dockerfile` are then the program's environment, which must
36
+ * have Bun; the default is `oven/bun:1`.
37
+ * @default no program
38
+ */
39
+ main?: string;
40
+ /**
41
+ * Named export to load from `main`.
42
+ * @default "default"
43
+ */
44
+ handler?: string;
45
+ /**
46
+ * Port the program serves HTTP on, as `PORT`. A sandbox serves it at
47
+ * `(yield* sandbox.getTcpPort(port)).url`.
48
+ * @default 3000
49
+ */
50
+ port?: number;
51
+ /**
52
+ * Bundler configuration for `main`, and `args` for the Dockerfile's
53
+ * `ARG`s (like `docker build --build-arg`).
54
+ */
55
+ build?: Bundle.BundleConfig & Pick<DockerfileBuild, "args">;
56
+ /**
57
+ * Environment variables for the template. With a program, also the
58
+ * program's environment, after the values its bindings set.
59
+ *
60
+ * Values are written into the template, so every sandbox created from it
61
+ * can read them. A `Redacted` value is not exposed in Alchemy's state or
62
+ * logs, but code inside the sandbox can read it.
63
+ */
64
+ env?: Record<string, any>;
65
+ /**
66
+ * Template name, used to create sandboxes from it. Lowercase letters,
67
+ * digits, `-` and `_`. If omitted, a unique name is generated from the
68
+ * stack, stage and logical ID. Changing it replaces the template.
69
+ */
70
+ name?: string;
71
+ /** Tags assigned to each build, e.g. `["v1"]`. */
72
+ tags?: string[];
73
+ /**
74
+ * vCPUs of every sandbox created from the template.
75
+ * @default 2
76
+ */
77
+ cpuCount?: number;
78
+ /**
79
+ * Memory of every sandbox created from the template, in MiB.
80
+ * @default 512
81
+ */
82
+ memoryMB?: number;
83
+ /** Free disk space every sandbox starts with, in MiB. */
84
+ minFreeDiskMb?: number;
85
+ /**
86
+ * Whether other E2B teams can create sandboxes from the template.
87
+ * @default false
88
+ */
89
+ public?: boolean;
90
+ /** Rebuild every layer on the next deploy, ignoring E2B's cache. */
91
+ force?: boolean;
92
+ }
93
+ export interface TemplateAttributes {
94
+ /** E2B's template id. Sandboxes are created from it. */
95
+ templateId: string;
96
+ /** The template's name (alias). */
97
+ name: string;
98
+ /** The current build. */
99
+ buildId: string;
100
+ /** Content hash of the build inputs. A deploy rebuilds only when it changes. */
101
+ buildHash: string;
102
+ /** Content hash of the build inputs other than bindings' env, compared at plan time. */
103
+ sourceHash: string;
104
+ /** Fully qualified names, e.g. `my-team/my-template:default`. */
105
+ names: string[];
106
+ public: boolean;
107
+ cpuCount: number | undefined;
108
+ memoryMB: number | undefined;
109
+ /**
110
+ * Volumes the template's program mounts (`E2B.MountVolume`). E2B attaches
111
+ * volumes when a sandbox is created, so `CreateSandbox(template)` and
112
+ * `E2B.Sandbox({ template })` mount them on every sandbox.
113
+ */
114
+ mounts: VolumeMount[];
115
+ }
116
+ /** What bindings attach to a template program. */
117
+ export interface TemplateBinding {
118
+ /** The program's environment. */
119
+ env?: Record<string, any>;
120
+ /**
121
+ * Mount clients (`alchemy/Mount`) the program needs, installed into the
122
+ * template. E2B sandboxes have FUSE and NFS.
123
+ */
124
+ mounts?: ReadonlyArray<MountCapability>;
125
+ /** E2B volumes every sandbox from the template mounts (`E2B.MountVolume`). */
126
+ volumes?: VolumeMount[];
127
+ }
128
+ export interface Template extends Resource<"E2B.Template", TemplateProps, TemplateAttributes, TemplateBinding, Providers, {
129
+ name: string;
130
+ }> {
131
+ }
132
+ /**
133
+ * An E2B template: the image every sandbox boots from, built by E2B into a
134
+ * Firecracker snapshot.
135
+ *
136
+ * Build from a registry `image`, a `dockerfile` (a path or inline content),
137
+ * or another template (`fromTemplate`). E2B builds remotely, so a deploy
138
+ * needs no Docker daemon: Alchemy plans the Dockerfile with
139
+ * `@alchemy.run/docker`'s build plan, lowers it to E2B's build steps, and
140
+ * uploads only the `COPY` sources E2B has not seen, by content hash. A
141
+ * deploy starts a new build only when the inputs change.
142
+ *
143
+ * E2B's builder runs one stage for `linux/amd64`. A Dockerfile with several
144
+ * `FROM`s, `COPY --from`, `ADD <url>`, heredocs, `RUN --mount` or `SHELL`
145
+ * fails at plan time with `UnsupportedDockerfile`, listing the lines.
146
+ * `EXPOSE`, `LABEL`, `VOLUME`, `HEALTHCHECK` and `STOPSIGNAL` are ignored,
147
+ * as E2B ignores them. An `ARG` becomes an environment variable. `CMD` / `ENTRYPOINT`
148
+ * become the template's start command: it is captured running in the
149
+ * snapshot, so every sandbox starts with it already up.
150
+ *
151
+ * E2B templates carry no labels, so Alchemy recognises its templates by
152
+ * their generated name.
153
+ *
154
+ * ### Building a Template
155
+ * **Example:** From a registry image
156
+ * ```typescript
157
+ * export const Python = E2B.Template("Python", { image: "python:3.12-slim" });
158
+ * ```
159
+ *
160
+ * **Example:** From an inline Dockerfile
161
+ * ```typescript
162
+ * import * as Dockerfile from "@alchemy.run/docker/Dockerfile";
163
+ *
164
+ * export const Agent = E2B.Template("Agent", {
165
+ * dockerfile: Dockerfile.inline`
166
+ * FROM node:22-bookworm
167
+ * RUN apt-get update && apt-get install -y git ripgrep
168
+ * WORKDIR /work
169
+ * `,
170
+ * cpuCount: 2,
171
+ * memoryMB: 4096,
172
+ * });
173
+ * ```
174
+ *
175
+ * **Example:** From a Dockerfile and its build context
176
+ * ```typescript
177
+ * export const Repo = E2B.Template("Repo", {
178
+ * context: "./sandbox",
179
+ * dockerfile: "./sandbox/Dockerfile",
180
+ * build: { args: { NODE_VERSION: "22" } },
181
+ * });
182
+ * ```
183
+ *
184
+ * ### Starting a process in every sandbox
185
+ * **Example:** A dev server that is already running when a sandbox starts
186
+ * ```typescript
187
+ * export const Preview = E2B.Template("Preview", {
188
+ * image: "node:22-bookworm",
189
+ * run: ["npm create vite@latest app -- --template react", "cd app && npm install"],
190
+ * startCmd: "cd /home/user/app && npm run dev -- --host 0.0.0.0 --port 3000",
191
+ * readyCmd: "curl -sf http://localhost:3000",
192
+ * });
193
+ * ```
194
+ *
195
+ * ### Private base images
196
+ * **Example:** A base image in GHCR
197
+ * ```typescript
198
+ * export const Private = E2B.Template("Private", {
199
+ * image: "ghcr.io/my-org/base:1",
200
+ * registry: { username: "my-org", password: Config.Redacted("GHCR_TOKEN") },
201
+ * });
202
+ * ```
203
+ *
204
+ * ### Effect program
205
+ * Give the template a `main` and an Effect, and every sandbox from it boots
206
+ * with the program already serving HTTP on `port`. Alchemy bundles `main`,
207
+ * copies it into the template, and E2B snapshots the template once the
208
+ * program answers. The program runs with Bun; the image defaults to
209
+ * `oven/bun:1`.
210
+ *
211
+ * **Example:** A program in every sandbox
212
+ * ```typescript
213
+ * export default class Program extends E2B.Template<Program>()(
214
+ * "Program",
215
+ * { main: import.meta.url, port: 3000 },
216
+ * Effect.gen(function* () {
217
+ * return {
218
+ * fetch: Effect.succeed(HttpServerResponse.text("hello from a sandbox")),
219
+ * };
220
+ * }),
221
+ * ) {}
222
+ * ```
223
+ *
224
+ * **Example:** Call the program in a sandbox
225
+ * ```typescript
226
+ * const sandboxes = yield* E2B.CreateSandbox(Program);
227
+ * const sandbox = yield* sandboxes.create({ timeout: 300 });
228
+ * const port = yield* sandbox.getTcpPort(3000);
229
+ * const res = yield* port.fetch(HttpClientRequest.get("/"));
230
+ * ```
231
+ *
232
+ * ### Async program
233
+ * A `main` without an Effect is bundled and run with Bun as-is. It must
234
+ * listen on `PORT`. `E2B.InferEnv` types its `env`.
235
+ *
236
+ * **Example:** A plain server
237
+ * ```typescript
238
+ * export const Server = E2B.Template("Server", {
239
+ * main: "./src/server.mjs",
240
+ * env: { GREETING: "hi" },
241
+ * });
242
+ * export type ServerEnv = E2B.InferEnv<typeof Server>;
243
+ * ```
244
+ *
245
+ * ### Bindings in the sandbox
246
+ * Bindings work inside a template program like in any other host.
247
+ *
248
+ * :::caution[Values are part of the template]
249
+ * Config and binding values are written into the template, so code in a
250
+ * sandbox can read them, `Redacted` ones included. Use egress secrets for
251
+ * credentials untrusted code must not see.
252
+ * :::
253
+ *
254
+ * **Example:** Read a volume from the program
255
+ * ```typescript
256
+ * export default class Program extends E2B.Template<Program>()(
257
+ * "Program",
258
+ * { main: import.meta.url },
259
+ * Effect.gen(function* () {
260
+ * const reports = yield* E2B.ReadVolume(Reports);
261
+ * return {
262
+ * fetch: Effect.gen(function* () {
263
+ * return HttpServerResponse.text(yield* reports.readText("/latest.json"));
264
+ * }).pipe(Effect.orDie),
265
+ * };
266
+ * }).pipe(Effect.provide(E2B.ReadVolumeHttp)),
267
+ * ) {}
268
+ * ```
269
+ *
270
+ * ### Configuration
271
+ * **Example:** Size, image and port
272
+ * ```typescript
273
+ * export default class Program extends E2B.Template<Program>()(
274
+ * "Program",
275
+ * { main: import.meta.url, image: "oven/bun:1-debian", cpuCount: 4, memoryMB: 8192, port: 8080 },
276
+ * Effect.gen(function* () {
277
+ * return { fetch: Effect.succeed(HttpServerResponse.text("ok")) };
278
+ * }),
279
+ * ) {}
280
+ * ```
281
+ *
282
+ * **Example:** Sandboxes from the template, in a Worker
283
+ * ```typescript
284
+ * const sandboxes = yield* E2B.CreateSandbox(Agent);
285
+ * const sandbox = yield* sandboxes.create({ timeout: 600 });
286
+ * ```
287
+ *
288
+ * ### Referencing a template the stack doesn't manage
289
+ * `E2B.Template.lookup` finds an existing template by name. Nothing is created,
290
+ * adopted or deleted.
291
+ *
292
+ * **Example:** Look one up by name
293
+ * ```typescript
294
+ * const base = E2B.Template.lookup({ name: "my-team/base-image" });
295
+ * const sandboxes = yield* E2B.CreateSandbox(base);
296
+ * ```
297
+ *
298
+ * @resource
299
+ * @product Template
300
+ */
301
+ export declare const Template: Platform<Template, ServerHost, Main<ServerHost>, HostRuntimeContext> & {
302
+ /**
303
+ * Reference a template this stack doesn't manage (E2B's `base`, or one
304
+ * another stack builds) by name, without managing it.
305
+ */
306
+ lookup(props: {
307
+ name: string;
308
+ }): Template;
309
+ };
310
+ /** A template by id, or by name (alias). */
311
+ export declare const observeTemplate: (templateId: string | undefined, name: string) => Effect.Effect<templates.GetTemplateResponse | undefined, import("@distilled.cloud/e2b").BadRequest | import("@distilled.cloud/e2b").ConfigError | import("@distilled.cloud/e2b").Conflict | import("@distilled.cloud/e2b").Forbidden | import("effect/http/HttpClientError").HttpClientError | import("@distilled.cloud/core/protocol-http").InvalidInput | import("@distilled.cloud/e2b").Locked | import("@distilled.cloud/core/sdk-error").SdkError | import("@distilled.cloud/e2b").UnprocessableEntity | import("@distilled.cloud/e2b").ClientErrors | import("@distilled.cloud/core/errors").DefaultErrors, templates.E2BOpContext>;
312
+ export declare const TemplateProvider: () => import("effect/Layer").Layer<Provider.Provider<Template>, never, import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("alchemy/Stack").Stack | import("alchemy/Stage").Stage | templates.E2BOpContext>;
313
+ //# sourceMappingURL=Template.d.ts.map
@@ -0,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