@alchemy.run/e2b 0.0.0 → 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 +56 -4
  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 +62 -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,25 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ import type * as Effect from "effect/Effect";
3
+ import type { Volume } from "./Volume.ts";
4
+ import type { ReadVolumeClient } from "./VolumeFiles.ts";
5
+ /**
6
+ * Read a {@link Volume}'s files from outside any sandbox: a report a sandbox wrote, a dataset to inspect.
7
+ *
8
+ * The client talks to E2B's volume content API with the volume's own token,
9
+ * looked up once through the host's API key.
10
+ *
11
+ * ### Using the client
12
+ * **Example:** In a Worker
13
+ * ```typescript
14
+ * const reports = yield* E2B.ReadVolume(Reports);
15
+ * // in fetch:
16
+ * const report = yield* reports.readText("/report.json");
17
+ * ```
18
+ *
19
+ * @binding
20
+ * @product Volume
21
+ */
22
+ export interface ReadVolume extends Binding.Service<ReadVolume, "E2B.ReadVolume", (volume: Volume) => Effect.Effect<ReadVolumeClient>> {
23
+ }
24
+ export declare const ReadVolume: ReadVolume;
25
+ //# sourceMappingURL=ReadVolume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadVolume.d.ts","sources":["../src/ReadVolume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,UAAW,SAAQ,OAAO,CAAC,OAAO,CACjD,UAAU,EACV,gBAAgB,EAChB,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACpD;CAAG;AAEJ,eAAO,MAAM,UAAU,YAAgD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ export const ReadVolume = Binding.Service("E2B.ReadVolume");
3
+ //# sourceMappingURL=ReadVolume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadVolume.js","sources":["../src/ReadVolume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AA4B3C,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAa,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import * as Layer from "effect/Layer";
2
+ import { ReadVolume } from "./ReadVolume.ts";
3
+ /**
4
+ * HTTP implementation of {@link ReadVolume}. Works on any host.
5
+ *
6
+ * ### Provide the layer
7
+ * **Example:** On a Worker
8
+ * ```typescript
9
+ * Effect.gen(function* () {
10
+ * const reports = yield* E2B.ReadVolume(Reports);
11
+ * // ...
12
+ * }).pipe(Effect.provide(E2B.ReadVolumeHttp))
13
+ * ```
14
+ *
15
+ * @layer
16
+ * @product Volume
17
+ * @provides E2B.ReadVolume
18
+ */
19
+ export declare const ReadVolumeHttp: Layer.Layer<ReadVolume, never, never>;
20
+ //# sourceMappingURL=ReadVolumeHttp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadVolumeHttp.d.ts","sources":["../src/ReadVolumeHttp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,uCAO1B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Layer from "effect/Layer";
3
+ import { bindE2B } from "./E2BBindings.js";
4
+ import { makeVolumeFiles } from "./internal/VolumeHttp.js";
5
+ import { ReadVolume } from "./ReadVolume.js";
6
+ /**
7
+ * HTTP implementation of {@link ReadVolume}. Works on any host.
8
+ *
9
+ * ### Provide the layer
10
+ * **Example:** On a Worker
11
+ * ```typescript
12
+ * Effect.gen(function* () {
13
+ * const reports = yield* E2B.ReadVolume(Reports);
14
+ * // ...
15
+ * }).pipe(Effect.provide(E2B.ReadVolumeHttp))
16
+ * ```
17
+ *
18
+ * @layer
19
+ * @product Volume
20
+ * @provides E2B.ReadVolume
21
+ */
22
+ export const ReadVolumeHttp = Layer.succeed(ReadVolume, Effect.fn("E2B.ReadVolume")(function* (volume) {
23
+ const auth = yield* bindE2B;
24
+ const volumeId = yield* volume.volumeId.asEffect();
25
+ return makeVolumeFiles(auth, volumeId);
26
+ }));
27
+ //# sourceMappingURL=ReadVolumeHttp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadVolumeHttp.js","sources":["../src/ReadVolumeHttp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CACzC,UAAU,EACV,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAc;IACnD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAE,MAAM,CAAC,QAAyC,CAAC,QAAQ,EAAE,CAAC;IACrF,OAAO,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACzC,CAAC,CAAC,CACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type * as webhooks from "@distilled.cloud/e2b/webhooks";
2
+ import * as Binding from "alchemy/Binding";
3
+ import type { RuntimeContext } from "alchemy/RuntimeContext";
4
+ import type * as Effect from "effect/Effect";
5
+ import type { E2BError } from "./SandboxClient.ts";
6
+ import type { Webhook } from "./Webhook.ts";
7
+ /** A webhook's delivery history and stats. */
8
+ export interface WebhookClient {
9
+ /** Deliveries grouped by event, newest first, with each attempt's request and response. */
10
+ deliveries(options?: Omit<webhooks.ListWebhookDeliveriesRequest, "webhookID">): Effect.Effect<webhooks.WebhookDeliveriesListPayload, E2BError, RuntimeContext>;
11
+ /** Delivery counts, failures and latency over time. */
12
+ stats(options?: Omit<webhooks.GetWebhookStatsRequest, "webhookID">): Effect.Effect<webhooks.WebhookDeliveryStats, E2BError, RuntimeContext>;
13
+ }
14
+ /**
15
+ * Read an E2B {@link Webhook}'s delivery history and stats: debug a failing
16
+ * endpoint, or alert on failed deliveries.
17
+ *
18
+ * ### Reading deliveries
19
+ * **Example:** Failed deliveries in the last hour
20
+ * ```typescript
21
+ * const hook = yield* E2B.ReadWebhook(Lifecycle);
22
+ * // in fetch:
23
+ * const failed = yield* hook.deliveries({ deliveryStatus: ["failed"] });
24
+ * ```
25
+ *
26
+ * @binding
27
+ * @product Webhook
28
+ */
29
+ export interface ReadWebhook extends Binding.Service<ReadWebhook, "E2B.ReadWebhook", (webhook: Webhook) => Effect.Effect<WebhookClient>> {
30
+ }
31
+ export declare const ReadWebhook: ReadWebhook;
32
+ //# sourceMappingURL=ReadWebhook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadWebhook.d.ts","sources":["../src/ReadWebhook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,2FAA2F;IAC3F,UAAU,CACR,OAAO,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,4BAA4B,EAAE,WAAW,CAAC,GACjE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IAClF,uDAAuD;IACvD,KAAK,CACH,OAAO,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,sBAAsB,EAAE,WAAW,CAAC,GAC3D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;CAC3E;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,OAAO,CAClD,WAAW,EACX,iBAAiB,EACjB,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CACnD;CAAG;AAEJ,eAAO,MAAM,WAAW,aAAkD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ export const ReadWebhook = Binding.Service("E2B.ReadWebhook");
3
+ //# sourceMappingURL=ReadWebhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadWebhook.js","sources":["../src/ReadWebhook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAuC3C,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAc,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import * as Layer from "effect/Layer";
2
+ import { ReadWebhook } from "./ReadWebhook.ts";
3
+ /**
4
+ * HTTP implementation of {@link ReadWebhook}. Works on any host.
5
+ *
6
+ * ### Provide the layer
7
+ * **Example:** On a Worker
8
+ * ```typescript
9
+ * Effect.gen(function* () {
10
+ * const hook = yield* E2B.ReadWebhook(Lifecycle);
11
+ * // ...
12
+ * }).pipe(Effect.provide(E2B.ReadWebhookHttp))
13
+ * ```
14
+ *
15
+ * @layer
16
+ * @product Webhook
17
+ * @provides E2B.ReadWebhook
18
+ */
19
+ export declare const ReadWebhookHttp: Layer.Layer<ReadWebhook, never, never>;
20
+ //# sourceMappingURL=ReadWebhookHttp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadWebhookHttp.d.ts","sources":["../src/ReadWebhookHttp.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AAGnE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,wCAiB3B,CAAC"}
@@ -0,0 +1,31 @@
1
+ import * as webhooks from "@distilled.cloud/e2b/webhooks";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import { bindE2B } from "./E2BBindings.js";
5
+ import { ReadWebhook } from "./ReadWebhook.js";
6
+ /**
7
+ * HTTP implementation of {@link ReadWebhook}. Works on any host.
8
+ *
9
+ * ### Provide the layer
10
+ * **Example:** On a Worker
11
+ * ```typescript
12
+ * Effect.gen(function* () {
13
+ * const hook = yield* E2B.ReadWebhook(Lifecycle);
14
+ * // ...
15
+ * }).pipe(Effect.provide(E2B.ReadWebhookHttp))
16
+ * ```
17
+ *
18
+ * @layer
19
+ * @product Webhook
20
+ * @provides E2B.ReadWebhook
21
+ */
22
+ export const ReadWebhookHttp = Layer.succeed(ReadWebhook, Effect.fn("E2B.ReadWebhook")(function* (webhook) {
23
+ const auth = yield* bindE2B;
24
+ const webhookId = yield* webhook.webhookId.asEffect();
25
+ const client = {
26
+ deliveries: (options) => Effect.flatMap(webhookId, (id) => auth.authorize(webhooks.listWebhookDeliveries({ ...options, webhookID: id }))),
27
+ stats: (options) => Effect.flatMap(webhookId, (id) => auth.authorize(webhooks.getWebhookStats({ ...options, webhookID: id }))),
28
+ };
29
+ return client;
30
+ }));
31
+ //# sour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1,26 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ import type * as Effect from "effect/Effect";
3
+ import type { Volume } from "./Volume.ts";
4
+ import type { ReadWriteVolumeClient } from "./VolumeFiles.ts";
5
+ /**
6
+ * Read and write a {@link Volume}'s files from outside any sandbox.
7
+ *
8
+ * The client talks to E2B's volume content API with the volume's own token,
9
+ * looked up once through the host's API key.
10
+ *
11
+ * ### Using the client
12
+ * **Example:** In a Worker
13
+ * ```typescript
14
+ * const cache = yield* E2B.ReadWriteVolume(Cache);
15
+ * // in fetch:
16
+ * yield* cache.write("/notes.md", "hello");
17
+ * const notes = yield* cache.readText("/notes.md");
18
+ * ```
19
+ *
20
+ * @binding
21
+ * @product Volume
22
+ */
23
+ export interface ReadWriteVolume extends Binding.Service<ReadWriteVolume, "E2B.ReadWriteVolume", (volume: Volume) => Effect.Effect<ReadWriteVolumeClient>> {
24
+ }
25
+ export declare const ReadWriteVolume: ReadWriteVolume;
26
+ //# sourceMappingURL=ReadWriteVolume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadWriteVolume.d.ts","sources":["../src/ReadWriteVolume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,eAAgB,SAAQ,OAAO,CAAC,OAAO,CACtD,eAAe,EACf,qBAAqB,EACrB,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CACzD;CAAG;AAEJ,eAAO,MAAM,eAAe,iBAA0D,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ export const ReadWriteVolume = Binding.Service("E2B.ReadWriteVolume");
3
+ //# sourceMappingURL=ReadWriteVolume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadWriteVolume.js","sources":["../src/ReadWriteVolume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AA6B3C,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAkB,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import * as Layer from "effect/Layer";
2
+ import { ReadWriteVolume } from "./ReadWriteVolume.ts";
3
+ /**
4
+ * HTTP implementation of {@link ReadWriteVolume}. Works on any host.
5
+ *
6
+ * ### Provide the layer
7
+ * **Example:** On a Worker
8
+ * ```typescript
9
+ * Effect.gen(function* () {
10
+ * const cache = yield* E2B.ReadWriteVolume(Cache);
11
+ * // ...
12
+ * }).pipe(Effect.provide(E2B.ReadWriteVolumeHttp))
13
+ * ```
14
+ *
15
+ * @layer
16
+ * @product Volume
17
+ * @provides E2B.ReadWriteVolume
18
+ */
19
+ export declare const ReadWriteVolumeHttp: Layer.Layer<ReadWriteVolume, never, never>;
20
+ //# sourceMappingURL=ReadWriteVolumeHttp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadWriteVolumeHttp.d.ts","sources":["../src/ReadWriteVolumeHttp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,4CAO/B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Layer from "effect/Layer";
3
+ import { bindE2B } from "./E2BBindings.js";
4
+ import { makeVolumeFiles } from "./internal/VolumeHttp.js";
5
+ import { ReadWriteVolume } from "./ReadWriteVolume.js";
6
+ /**
7
+ * HTTP implementation of {@link ReadWriteVolume}. Works on any host.
8
+ *
9
+ * ### Provide the layer
10
+ * **Example:** On a Worker
11
+ * ```typescript
12
+ * Effect.gen(function* () {
13
+ * const cache = yield* E2B.ReadWriteVolume(Cache);
14
+ * // ...
15
+ * }).pipe(Effect.provide(E2B.ReadWriteVolumeHttp))
16
+ * ```
17
+ *
18
+ * @layer
19
+ * @product Volume
20
+ * @provides E2B.ReadWriteVolume
21
+ */
22
+ export const ReadWriteVolumeHttp = Layer.succeed(ReadWriteVolume, Effect.fn("E2B.ReadWriteVolume")(function* (volume) {
23
+ const auth = yield* bindE2B;
24
+ const volumeId = yield* volume.volumeId.asEffect();
25
+ return makeVolumeFiles(auth, volumeId);
26
+ }));
27
+ //# sourceMappingURL=ReadWriteVolumeHttp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadWriteVolumeHttp.js","sources":["../src/ReadWriteVolumeHttp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAC9C,eAAe,EACf,MAAM,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAc;IACxD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAE,MAAM,CAAC,QAAyC,CAAC,QAAQ,EAAE,CAAC;IACrF,OAAO,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACzC,CAAC,CAAC,CACH,CAAC"}
@@ -0,0 +1,295 @@
1
+ import * as sandboxes from "@distilled.cloud/e2b/sandboxes";
2
+ import * as Provider from "alchemy/Provider";
3
+ import { Resource } from "alchemy/Resource";
4
+ import * as Duration from "effect/Duration";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Redacted from "effect/Redacted";
7
+ import type { VolumeMount } from "./MountVolume.ts";
8
+ import type { Providers } from "./Providers.ts";
9
+ /**
10
+ * A SOCKS5 proxy that carries a sandbox's outbound TCP. E2B applies the
11
+ * allow and deny rules first, then tunnels what's left through the proxy;
12
+ * code in the sandbox can't tell, and can't go around it. The proxy must
13
+ * accept TCP connections, so a Cloudflare Worker can't be one.
14
+ */
15
+ export interface SandboxEgressProxy {
16
+ /** The proxy's address, as `host:port`. */
17
+ address: string;
18
+ /** SOCKS5 username. */
19
+ username?: string;
20
+ /** SOCKS5 password. E2B never returns it. */
21
+ password?: string | Redacted.Redacted<string>;
22
+ /**
23
+ * Connect to the proxy over TLS, so the username and password aren't
24
+ * sent in the clear.
25
+ */
26
+ tls?: {
27
+ /** Whether to use TLS. */
28
+ enabled: boolean;
29
+ /** Name to check the proxy's certificate against. @default the host in `address` */
30
+ serverName?: string;
31
+ /** PEM certificates to trust instead of the system's, for a private CA. */
32
+ caCert?: string;
33
+ };
34
+ }
35
+ /** Egress rules for a declared sandbox, in E2B's shape. */
36
+ export interface SandboxNetwork {
37
+ /**
38
+ * Whether the sandbox's URLs accept requests without its traffic token.
39
+ * Changing it replaces the sandbox.
40
+ * @default true
41
+ */
42
+ allowPublicTraffic?: boolean;
43
+ /**
44
+ * The only destinations the sandbox may reach: CIDR blocks, IPs or
45
+ * domains (`*.example.com`). Everything else is denied unless `denyOut`
46
+ * says otherwise.
47
+ */
48
+ allowOut?: string[];
49
+ /** Denied CIDR blocks or IPs. Domains are not supported. */
50
+ denyOut?: string[];
51
+ /** DNS servers the sandbox may reach when `allowOut` lists a domain. @default ["8.8.8.8"] */
52
+ dnsServers?: string[];
53
+ /**
54
+ * Header rules for outbound HTTPS requests, by domain. Reference an
55
+ * `E2B.Secret`'s `ref` here to inject it at egress.
56
+ */
57
+ rules?: sandboxes.SandboxNetworkConfigRulesMap;
58
+ /**
59
+ * Send the sandbox's outbound TCP through a SOCKS5 proxy you run: a
60
+ * gateway that adds credentials, a static IP, or an audit log.
61
+ */
62
+ egressProxy?: SandboxEgressProxy;
63
+ /**
64
+ * The `Host` header requests to the sandbox's URLs arrive with, such as
65
+ * `localhost:${PORT}`. Changing it replaces the sandbox.
66
+ */
67
+ maskRequestHost?: string;
68
+ /**
69
+ * Ports where the sandbox serves HTTPS itself. E2B connects to them over
70
+ * TLS without checking the certificate. Changing them replaces the
71
+ * sandbox.
72
+ */
73
+ httpsPorts?: number[];
74
+ }
75
+ /**
76
+ * What a sandbox boots from: an `E2B.Template` or an `E2B.Snapshot`, declared
77
+ * or yielded.
78
+ */
79
+ export interface SandboxTemplate {
80
+ templateId: string;
81
+ /** A template's current build. A new build replaces the sandbox. */
82
+ buildId?: string;
83
+ /** A snapshot's setup hash. A new snapshot replaces the sandbox. */
84
+ setupHash?: string;
85
+ /** The volumes a template program mounts (`E2B.MountVolume`). */
86
+ mounts?: VolumeMount[];
87
+ }
88
+ export interface SandboxProps {
89
+ /**
90
+ * The `E2B.Template` or `E2B.Snapshot` the sandbox boots from. Changing
91
+ * it, or rebuilding it, replaces the sandbox so it boots the new build.
92
+ */
93
+ template: SandboxTemplate;
94
+ /**
95
+ * How long the sandbox runs after it starts or resumes before E2B pauses
96
+ * it. Changing it applies to the current run (and resumes a paused
97
+ * sandbox once to apply it).
98
+ * @default "5 minutes"
99
+ */
100
+ timeout?: Duration.Input;
101
+ /**
102
+ * Resume the paused sandbox on the next request: to one of its URLs, or
103
+ * a call into it from `E2B.ConnectSandbox`. Without it, calls into the
104
+ * paused sandbox fail with `SandboxNotRunning` until `resume()`. Needs
105
+ * `memory`. Changing it replaces the sandbox.
106
+ * @default true
107
+ */
108
+ autoResume?: boolean;
109
+ /**
110
+ * Keep memory as well as the filesystem when the sandbox pauses, so it
111
+ * resumes where it left off. `false` keeps only the filesystem and the
112
+ * sandbox reboots on resume. Changing it replaces the sandbox.
113
+ * @default true
114
+ */
115
+ memory?: boolean;
116
+ /** Environment variables for the sandbox. Changing them replaces the sandbox. */
117
+ env?: Record<string, string>;
118
+ /** Your own metadata. Changing it replaces the sandbox. */
119
+ metadata?: Record<string, string>;
120
+ /**
121
+ * Egress rules. `allowOut`, `denyOut`, `dnsServers`, `rules` and
122
+ * `egressProxy` update in place; `allowPublicTraffic`, `maskRequestHost`
123
+ * and `httpsPorts` replace the sandbox.
124
+ */
125
+ network?: SandboxNetwork;
126
+ /**
127
+ * Volumes to mount: `{ volume, path }`, where `volume` is an `E2B.Volume`.
128
+ * A template program's own mounts are added. E2B attaches volumes only
129
+ * when a sandbox is created, so changing them replaces the sandbox.
130
+ */
131
+ mounts?: VolumeMount[];
132
+ }
133
+ export interface SandboxAttributes {
134
+ /** E2B's sandbox id. */
135
+ sandboxId: string;
136
+ /** The template id the sandbox booted from. */
137
+ templateId: string;
138
+ /** The template build (or snapshot) the sandbox booted. */
139
+ templateBuild: string | undefined;
140
+ /** The volumes mounted into the sandbox: its own and its template program's. */
141
+ mounts: VolumeMount[];
142
+ /**
143
+ * The domain its ports are served under: port `p` answers at
144
+ * `https://<p>-<sandboxId>.<domain>`.
145
+ */
146
+ domain: string;
147
+ /**
148
+ * The token requests to the sandbox's URLs send in the
149
+ * `e2b-traffic-access-token` header when `allowPublicTraffic` is `false`.
150
+ */
151
+ trafficAccessToken: Redacted.Redacted<string> | undefined;
152
+ /** Your metadata, without Alchemy's ownership stamp. */
153
+ metadata: Record<string, string>;
154
+ /** CPU cores. */
155
+ cpuCount: number;
156
+ /** Memory in MiB. */
157
+ memoryMB: number;
158
+ }
159
+ export interface Sandbox extends Resource<"E2B.Sandbox", SandboxProps, SandboxAttributes, never, Providers, {
160
+ sandboxId: string;
161
+ }> {
162
+ }
163
+ /**
164
+ * An E2B sandbox the stack owns: one long-lived sandbox that pauses when it
165
+ * is idle and resumes when it is used, instead of one per request.
166
+ *
167
+ * Use it for a workspace that outlives requests (an agent's home, a dev
168
+ * box) or to serve a template program at a stable URL. The sandbox runs for
169
+ * `timeout` after it starts or resumes, then E2B pauses it with its memory
170
+ * and files. A request to one of its URLs resumes it (`autoResume`), and so
171
+ * does `resume()` on `E2B.ConnectSandbox`.
172
+ *
173
+ * Alchemy stamps its stack, stage and logical ID into the sandbox's
174
+ * metadata to recognise the sandboxes it owns.
175
+ *
176
+ * :::caution
177
+ * Replacing the sandbox (a new or rebuilt `template`, or new `env`,
178
+ * `metadata`, `mounts`, `memory`, `autoResume`, `allowPublicTraffic`,
179
+ * `maskRequestHost` or `httpsPorts`) starts a
180
+ * fresh sandbox and kills the old one with its files. If E2B no longer has
181
+ * the sandbox, the next deploy that updates it (or `alchemy drift`) creates
182
+ * a new one.
183
+ * :::
184
+ *
185
+ * ### Creating a Sandbox
186
+ * **Example:** A dev box from a template
187
+ * ```typescript
188
+ * import * as E2B from "@alchemy.run/e2b";
189
+ * import * as Effect from "effect/Effect";
190
+ *
191
+ * export const Node = E2B.Template("Node", { image: "node:22" });
192
+ *
193
+ * export const DevBox = E2B.Sandbox("DevBox", {
194
+ * template: Node,
195
+ * timeout: "10 minutes",
196
+ * });
197
+ * ```
198
+ *
199
+ * ### Serving a template program
200
+ * A template program starts when its sandbox boots. Declare one sandbox for
201
+ * it: each new build of the program replaces the sandbox, so it always runs
202
+ * the current one.
203
+ *
204
+ * **Example:** The program at a stable URL
205
+ * ```typescript
206
+ * import * as E2B from "@alchemy.run/e2b";
207
+ * import * as Output from "alchemy/Output";
208
+ * import * as Effect from "effect/Effect";
209
+ * import Api from "./src/api.ts";
210
+ *
211
+ * export const ApiSandbox = Effect.gen(function* () {
212
+ * const sandbox = yield* E2B.Sandbox("Api", { template: Api });
213
+ * return { url: Output.interpolate`https://3000-${sandbox.sandboxId}.${sandbox.domain}` };
214
+ * });
215
+ * ```
216
+ *
217
+ * ### Private URLs
218
+ * **Example:** Require the traffic token
219
+ * ```typescript
220
+ * const sandbox = yield* E2B.Sandbox("Private", {
221
+ * template: Node,
222
+ * network: { allowPublicTraffic: false },
223
+ * });
224
+ * // send sandbox.trafficAccessToken in the `e2b-traffic-access-token` header
225
+ * ```
226
+ *
227
+ * ### Egress through your own proxy
228
+ * E2B sends the sandbox's outbound TCP through a SOCKS5 proxy you run,
229
+ * after its allow and deny rules. Code in the sandbox can't tell, and
230
+ * can't go around it.
231
+ *
232
+ * **Example:** A proxy over TLS, with a password
233
+ * ```typescript
234
+ * import * as E2B from "@alchemy.run/e2b";
235
+ * import * as Config from "effect/Config";
236
+ * import { Node } from "./Node.ts";
237
+ *
238
+ * export const Proxied = E2B.Sandbox("Proxied", {
239
+ * template: Node,
240
+ * network: {
241
+ * egressProxy: {
242
+ * address: "proxy.example.com:1080",
243
+ * username: "sandbox",
244
+ * password: Config.Redacted("PROXY_PASSWORD"),
245
+ * tls: { enabled: true },
246
+ * },
247
+ * },
248
+ * });
249
+ * ```
250
+ *
251
+ * ### Using it at runtime
252
+ * **Example:** Run a command in it from a Worker
253
+ * ```typescript
254
+ * const devBox = yield* E2B.ConnectSandbox(DevBox);
255
+ * // in fetch:
256
+ * yield* devBox.resume();
257
+ * const result = yield* devBox.exec("git pull && npm test", { cwd: "/home/user/repo" });
258
+ * ```
259
+ *
260
+ * ### Mounting volumes
261
+ * **Example:** A shared cache volume
262
+ * ```typescript
263
+ * export const Cache = E2B.Volume("Cache", {});
264
+ *
265
+ * export const Builder = E2B.Sandbox("Builder", {
266
+ * template: Node,
267
+ * mounts: [{ volume: Cache, path: "/cache" }],
268
+ * });
269
+ * ```
270
+ *
271
+ * ### Referencing a sandbox the stack doesn't manage
272
+ * **Example:** Look one up by id
273
+ * ```typescript
274
+ * const shared = E2B.Sandbox.lookup({ sandboxId: "i1a2b3c4d5e6f7g8h9" });
275
+ * const box = yield* E2B.ConnectSandbox(shared);
276
+ * ```
277
+ *
278
+ * @resource
279
+ * @product Sandbox
280
+ */
281
+ export declare const Sandbox: import("alchemy/Resource").ResourceConstructor<Sandbox, Providers> & Effect.Effect<import("alchemy/Resource").ResourceConstructor<Sandbox, never>, never, never> & {
282
+ Self: import("alchemy/Self").Self<Sandbox>;
283
+ Provider: Provider.Provider<Sandbox>;
284
+ Aliases: readonly string[] | undefined;
285
+ ref(id: string, options?: {
286
+ stage?: string;
287
+ stack?: string;
288
+ }): Effect.Effect<Sandbox, never, never>;
289
+ } & {
290
+ lookup(props: {
291
+ sandboxId: import("alchemy/Input").Input<string>;
292
+ }): Sandbox;
293
+ } & ((id: string, props: import("./internal/Declared.ts").DeclaredProps<SandboxProps>) => Effect.Effect<Sandbox, never, Providers>);
294
+ export declare const SandboxProvider: () => import("effect/Layer").Layer<Provider.Provider<Sandbox>, never, import("alchemy/Stack").Stack | import("alchemy/Stage").Stage | sandboxes.E2BOpContext>;
295
+ //# sourceMappingURL=Sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sandbox.d.ts","sources":["../src/Sandbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,SAAS,MAAM,gCAAgC,CAAC;AAG5D,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAM5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,G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