@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,127 @@
1
+ /**
2
+ * How E2B bindings reach E2B from any host.
3
+ *
4
+ * E2B authenticates with a team API key and has no identity federation or
5
+ * key scopes, so every host — a Cloudflare Worker, a Lambda, a container, an
6
+ * E2B sandbox — gets its own API key, minted at deploy as an `E2B.ApiKey` in
7
+ * the host's namespace and deleted with the host. The deployer's credentials
8
+ * never reach a host. Minting takes the deployer's access token. The binding
9
+ * captures the key (and the E2B domain) as named runtime Outputs; inside the
10
+ * deployed host they are read back from the host's env, still `Redacted`.
11
+ * Every runtime call provides `Credentials` from those accessors, so nothing
12
+ * reads `process.env`.
13
+ *
14
+ * Bindings that create sandboxes or secrets at run time tag them with the
15
+ * host's `alchemy::stack` / `alchemy::stage` / `alchemy::id`, computed at
16
+ * deploy and bound into the host (`bindOwnerTags`). Destroying the stack
17
+ * does not delete them.
18
+ */
19
+ import { ConfigError } from "@distilled.cloud/core/errors";
20
+ import { apiBaseUrlFor, Credentials, CredentialsFromEnv, DEFAULT_DOMAIN, } from "@distilled.cloud/e2b/Credentials";
21
+ import { orDieCredentialsUnavailable } from "alchemy/Auth/Resolve";
22
+ import * as Binding from "alchemy/Binding";
23
+ import * as Namespace from "alchemy/Namespace";
24
+ import * as Output from "alchemy/Output";
25
+ import { Stack } from "alchemy/Stack";
26
+ import { Stage } from "alchemy/Stage";
27
+ import * as Effect from "effect/Effect";
28
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
29
+ import * as Layer from "effect/Layer";
30
+ import * as Option from "effect/Option";
31
+ import * as Redacted from "effect/Redacted";
32
+ import { ApiKey } from "./ApiKey.js";
33
+ import { withTeamId } from "./Credentials.js";
34
+ /** A plain value as an Output with no requirements (`asOutput` leaves them `any`). */
35
+ const output = (value) => Output.asOutput(value);
36
+ /** E2B's `metadata` filter: `key=value&…`. */
37
+ export const metadataQuery = (metadata) => new URLSearchParams(Object.entries(metadata)).toString();
38
+ /** The deploying stack's credentials: the ambient profile-backed ones, else the env. */
39
+ const deployCredentials = Effect.gen(function* () {
40
+ const ambient = yield* Effect.serviceOption(Credentials);
41
+ const resolve = Option.isSome(ambient)
42
+ ? ambient.value
43
+ : yield* Credentials.pipe(Effect.provide(CredentialsFromEnv));
44
+ return yield* resolve;
45
+ });
46
+ const requireAccessToken = (config) => config.accessToken === undefined
47
+ ? Effect.fail(new ConfigError({
48
+ message: "E2B bindings mint an API key for each host, which takes an E2B access token: " +
49
+ "add accessToken to the E2B profile (alchemy profile edit --add E2B) or set E2B_ACCESS_TOKEN",
50
+ }))
51
+ : Effect.void;
52
+ /**
53
+ * Mints the current host's API key and binds it, the domain and the
54
+ * ownership stamp onto the host, and returns runtime accessors for them.
55
+ * Call it in a binding's construction; every binding on a host shares the
56
+ * one key.
57
+ */
58
+ export const bindE2B = Effect.gen(function* () {
59
+ // Yielding the resource class erases its `Providers` requirement; the
60
+ // stack satisfies it at plan time.
61
+ const makeKey = yield* ApiKey;
62
+ let apiKey = output(Redacted.make(""));
63
+ let domain = DEFAULT_DOMAIN;
64
+ let teamId = "";
65
+ if (!globalThis.__ALCHEMY_RUNTIME__) {
66
+ const config = yield* deployCredentials.pipe(orDieCredentialsUnavailable("E2B"));
67
+ yield* requireAccessToken(config).pipe(orDieCredentialsUnavailable("E2B"));
68
+ domain = config.domain;
69
+ teamId = (yield* withTeamId(config).pipe(orDieCredentialsUnavailable("E2B"))).teamId ?? "";
70
+ const host = yield* Binding.Host;
71
+ if (host !== undefined) {
72
+ const hostKey = yield* Namespace.push(host.LogicalId, makeKey("E2BHostKey", {}));
73
+ apiKey = hostKey.key;
74
+ }
75
+ }
76
+ const key = yield* Output.named(apiKey, "E2B_API_KEY").asEffect();
77
+ const boundDomain = yield* Output.named(output(domain), "E2B_DOMAIN").asEffect();
78
+ const boundTeamId = yield* Output.named(output(teamId), "E2B_TEAM_ID").asEffect();
79
+ const domainOf = Effect.map(boundDomain, (value) => value || DEFAULT_DOMAIN);
80
+ const credentials = Effect.gen(function* () {
81
+ const resolvedDomain = yield* domainOf;
82
+ return {
83
+ apiKey: yield* key,
84
+ domain: resolvedDomain,
85
+ apiBaseUrl: apiBaseUrlFor(resolvedDomain),
86
+ };
87
+ });
88
+ const services = Layer.mergeAll(Layer.succeed(Credentials, credentials), FetchHttpClient.layer);
89
+ return {
90
+ authorize: (effect) => effect.pipe(Effect.provide(services)),
91
+ domain: domainOf,
92
+ teamId: boundTeamId,
93
+ };
94
+ });
95
+ const parseOwnerTags = (json) => {
96
+ try {
97
+ return JSON.parse(json || "{}");
98
+ }
99
+ catch {
100
+ return {};
101
+ }
102
+ };
103
+ /**
104
+ * Binds the host's `alchemy::stack` / `alchemy::stage` / `alchemy::id` into
105
+ * it, and returns them at run time for `create` to put on what it makes.
106
+ * Without a host (a script) there are none.
107
+ */
108
+ export const bindOwnerTags = Effect.gen(function* () {
109
+ let tags = "{}";
110
+ if (!globalThis.__ALCHEMY_RUNTIME__) {
111
+ const host = yield* Binding.Host;
112
+ // The values `createInternalTags(host.LogicalId)` gives, read without
113
+ // adding `Stack` / `Stage` to the binding's requirements.
114
+ const stack = yield* Effect.serviceOption(Stack);
115
+ const stage = yield* Effect.serviceOption(Stage);
116
+ if (host !== undefined && Option.isSome(stack) && Option.isSome(stage)) {
117
+ tags = JSON.stringify({
118
+ "alchemy::stack": stack.value.name,
119
+ "alchemy::stage": stage.value,
120
+ "alchemy::id": host.LogicalId,
121
+ });
122
+ }
123
+ }
124
+ const bound = yield* Output.named(output(tags), "E2B_OWNER_TAGS").asEffect();
125
+ return Effect.map(bound, parseOwnerTags);
126
+ });
127
+ //# sourceMappingURL=E2BBindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"E2BBindings.js","sources":["../src/E2BBindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EACL,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,cAAc,GACf,MAAM,kCAAkC,CAAC;A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CAAC;IAC7E,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ declare const E2BUnexpectedResponse_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
2
+ readonly _tag: "E2B.UnexpectedResponse";
3
+ } & Readonly<A>;
4
+ /** E2B answered in a way a lifecycle step cannot continue from (e.g. a resource vanished right after create). */
5
+ export declare class E2BUnexpectedResponse extends E2BUnexpectedResponse_base<{
6
+ readonly message: string;
7
+ readonly cause?: unknown;
8
+ }> {
9
+ }
10
+ declare const TemplateBuildFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
11
+ readonly _tag: "E2B.TemplateBuildFailed";
12
+ } & Readonly<A>;
13
+ /** A template build finished in a failed state. */
14
+ export declare class TemplateBuildFailed extends TemplateBuildFailed_base<{
15
+ readonly message: string;
16
+ readonly templateId: string;
17
+ readonly buildId: string;
18
+ readonly reason?: string;
19
+ readonly logs?: ReadonlyArray<string>;
20
+ }> {
21
+ }
22
+ declare const UnsupportedDockerfileInstruction_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
23
+ readonly _tag: "E2B.UnsupportedDockerfileInstruction";
24
+ } & Readonly<A>;
25
+ /** A Dockerfile uses something E2B's builder does not support. Raised at plan time. */
26
+ export declare class UnsupportedDockerfileInstruction extends UnsupportedDockerfileInstruction_base<{
27
+ readonly message: string;
28
+ readonly line?: number;
29
+ }> {
30
+ }
31
+ declare const SnapshotSetupFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
32
+ readonly _tag: "E2B.SnapshotSetupFailed";
33
+ } & Readonly<A>;
34
+ /** A command run while building a snapshot exited non-zero. */
35
+ export declare class SnapshotSetupFailed extends SnapshotSetupFailed_base<{
36
+ readonly message: string;
37
+ readonly command: string;
38
+ readonly exitCode: number;
39
+ readonly stderr: string;
40
+ }> {
41
+ }
42
+ declare const SandboxBaseMissing_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
43
+ readonly _tag: "E2B.SandboxBaseMissing";
44
+ } & Readonly<A>;
45
+ /** `E2B.CreateSandbox()` was bound without a base and `create()` was called without `templateID`. */
46
+ export declare class SandboxBaseMissing extends SandboxBaseMissing_base<{
47
+ readonly message: string;
48
+ }> {
49
+ }
50
+ declare const ExecTimedOut_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
51
+ readonly _tag: "E2B.ExecTimedOut";
52
+ } & Readonly<A>;
53
+ /** `exec` killed a command that ran past its `timeout`. */
54
+ export declare class ExecTimedOut extends ExecTimedOut_base<{
55
+ readonly pid: number;
56
+ readonly timeoutMs: number;
57
+ }> {
58
+ get message(): string;
59
+ }
60
+ export {};
61
+ //# sourceMappingURL=Errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Errors.d.ts","sources":["../src/Errors.ts"],"names":[],"mappings":";;;AAEA,iHAAiH;AACjH,qBAAa,qBAAsB,SAAQ,2BAA2C;IACpF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;CAAG;;;;AAEL,mDAAmD;AACnD,qBAAa,mBAAoB,SAAQ,yBAA4C;IACnF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;CAAG;;;;AAEL,uFAAuF;AACvF,qBAAa,gCAAiC,SAAQ,sCAEpD;IACA,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;CAAG;;;;AAEL,+DAA+D;AAC/D,qBAAa,mBAAoB,SAAQ,yBAA4C;IACnF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;CAAG;;;;AAEL,qGAAqG;AACrG,qBAAa,kBAAmB,SAAQ,wBAA2C;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;CAAG;;;;AAEL,2DAA2D;AAC3D,qBAAa,YAAa,SAAQ,kBAAqC;IACrE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;IACA,IAAa,OAAO,WAEnB;CACF"}
package/lib/Errors.js ADDED
@@ -0,0 +1,23 @@
1
+ import * as Data from "effect/Data";
2
+ /** E2B answered in a way a lifecycle step cannot continue from (e.g. a resource vanished right after create). */
3
+ export class E2BUnexpectedResponse extends Data.TaggedError("E2B.UnexpectedResponse") {
4
+ }
5
+ /** A template build finished in a failed state. */
6
+ export class TemplateBuildFailed extends Data.TaggedError("E2B.TemplateBuildFailed") {
7
+ }
8
+ /** A Dockerfile uses something E2B's builder does not support. Raised at plan time. */
9
+ export class UnsupportedDockerfileInstruction extends Data.TaggedError("E2B.UnsupportedDockerfileInstruction") {
10
+ }
11
+ /** A command run while building a snapshot exited non-zero. */
12
+ export class SnapshotSetupFailed extends Data.TaggedError("E2B.SnapshotSetupFailed") {
13
+ }
14
+ /** `E2B.CreateSandbox()` was bound without a base and `create()` was called without `templateID`. */
15
+ export class SandboxBaseMissing extends Data.TaggedError("E2B.SandboxBaseMissing") {
16
+ }
17
+ /** `exec` killed a command that ran past its `timeout`. */
18
+ export class ExecTimedOut extends Data.TaggedError("E2B.ExecTimedOut") {
19
+ get message() {
20
+ return `process ${this.pid} ran longer than ${this.timeoutMs}ms and was killed`;
21
+ }
22
+ }
23
+ //# sourceMappingURL=Errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Errors.js","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,iHAAiH;AACjH,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAGlF;CAAG;AAEL,mDAAmD;AACnD,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAMjF;CAAG;AAEL,uFAAuF;AACvF,MAAM,OAAO,gCAAiC,SAAQ,IAAI,CAAC,WAAW,CACpE,sCAAsC,CAItC;CAAG;AAEL,+DAA+D;AAC/D,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAKjF;CAAG;AAEL,qGAAqG;AACrG,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAE/E;CAAG;AAEL,2DAA2D;AAC3D,MAAM,OAAO,YAAa,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAGnE;IACA,IAAa,OAAO;QAClB,OAAO,WAAW,IAAI,CAAC,GAAG,oBAAoB,IAAI,CAAC,SAAS,mBAAmB,CAAC;IAClF,CAAC;CACF"}
@@ -0,0 +1,26 @@
1
+ import type * as Effect from "effect/Effect";
2
+ /**
3
+ * Typed `env` for an async (non-Effect) {@link Template} program. A
4
+ * template program reads its bindings from environment variables, so every
5
+ * entry is a `string`: cast `process.env` to it.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * export const Worker = E2B.Template("Worker", {
10
+ * image: "node:22-bookworm",
11
+ * main: "./src/worker.mjs",
12
+ * env: { QUEUE_URL: queue.url },
13
+ * });
14
+ * export type WorkerEnv = E2B.InferEnv<typeof Worker>;
15
+ * ```
16
+ */
17
+ export type InferEnv<F> = F extends Effect.Effect<infer A, infer _E, infer _R> ? InferEnv<A> : F extends {
18
+ readonly Props: {
19
+ readonly env?: infer E;
20
+ };
21
+ } ? InferEnvRecord<Exclude<E, undefined>> : InferEnvRecord<F>;
22
+ type InferEnvRecord<E> = {
23
+ readonly [K in keyof E]: string;
24
+ };
25
+ export {};
26
+ //# sourceMappingURL=InferEnv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InferEnv.d.ts","sources":["../src/InferEnv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IACpB,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAChD,QAAQ,CAAC,CAAC,CAAC,GACX,CAAC,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;CAAE,GACtD,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,GACrC,cAAc,CAAC,CAAC,CAAC,CAAC;AAE1B,KAAK,cAAc,CAAC,CAAC,IAAI;IACvB,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM;CAChC,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=InferEnv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InferEnv.js","sources":["../src/InferEnv.ts"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ import type { RuntimeContext } from "alchemy/RuntimeContext";
3
+ import type * as Effect from "effect/Effect";
4
+ import type { Volume } from "./Volume.ts";
5
+ /**
6
+ * A volume to mount: a declared `E2B.Volume`, or a volume `CreateVolume`
7
+ * returned. E2B mounts volumes by name.
8
+ */
9
+ export interface MountableVolume {
10
+ readonly name: string;
11
+ }
12
+ /** A volume mounted into a sandbox at `path`. */
13
+ export interface VolumeMount {
14
+ readonly volume: MountableVolume;
15
+ /** Absolute path inside the sandbox. */
16
+ readonly path: string;
17
+ }
18
+ /**
19
+ * A volume bound to a host with `E2B.MountVolume`. Its name is read at
20
+ * runtime, so pass the whole reference to `mounts`.
21
+ */
22
+ export interface BoundVolumeMount {
23
+ readonly volume: {
24
+ readonly name: Effect.Effect<string, never, RuntimeContext>;
25
+ };
26
+ /** Absolute path inside the sandbox. */
27
+ readonly path: string;
28
+ }
29
+ export interface MountVolumeOptions {
30
+ /** Absolute path inside the sandbox. */
31
+ readonly path: string;
32
+ }
33
+ /**
34
+ * Mount a declared `E2B.Volume` at a path.
35
+ *
36
+ * In an `E2B.Template` program, the mount becomes part of the template:
37
+ * every sandbox created from it (with `CreateSandbox(template)` or
38
+ * `E2B.Sandbox({ template })`) mounts the volume, and the program finds its
39
+ * files at `path`. E2B attaches volumes when a sandbox is created, so a
40
+ * sandbox already running keeps the mounts it started with.
41
+ *
42
+ * Anywhere else (a Worker, a Function), it returns a reference to pass to
43
+ * `create({ mounts })`.
44
+ *
45
+ * E2B enables volumes per team; on a team without them, deploying the
46
+ * volume fails with `VolumesNotEnabled`.
47
+ *
48
+ * ### In a template program
49
+ * **Example:** A program that serves a volume's files
50
+ * ```typescript
51
+ * export default class Api extends E2B.Template<Api>()(
52
+ * "Api",
53
+ * { main: import.meta.url },
54
+ * Effect.gen(function* () {
55
+ * const data = yield* E2B.MountVolume(Data, { path: "/data" });
56
+ * const fs = yield* FileSystem.FileSystem;
57
+ * return {
58
+ * fetch: Effect.gen(function* () {
59
+ * const files = yield* fs.readDirectory(data.path);
60
+ * return yield* HttpServerResponse.json(files);
61
+ * }).pipe(Effect.orDie),
62
+ * };
63
+ * }).pipe(Effect.provide(E2B.MountVolumeLive)),
64
+ * ) {}
65
+ * ```
66
+ *
67
+ * ### From a Worker
68
+ * **Example:** Mount a shared volume and a per-user one
69
+ * ```typescript
70
+ * const data = yield* E2B.MountVolume(Data, { path: "/data" });
71
+ * const sandboxes = yield* E2B.CreateSandbox(Agent);
72
+ * const volumes = yield* E2B.CreateVolume();
73
+ * // in fetch:
74
+ * const home = yield* volumes.getOrCreate(`home-${user}`);
75
+ * const sandbox = yield* sandboxes.create({
76
+ * mounts: [data, { volume: home, path: "/home/user/work" }],
77
+ * });
78
+ * ```
79
+ *
80
+ * @binding
81
+ * @product Volume
82
+ */
83
+ export interface MountVolume extends Binding.Service<MountVolume, "E2B.MountVolume", (volume: Volume, options: MountVolumeOptions) => Effect.Effect<BoundVolumeMount>> {
84
+ }
85
+ export declare const MountVolume: MountVolume;
86
+ //# sourceMappingURL=MountVolume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MountVolume.d.ts","sources":["../src/MountVolume.ts"],"names":[],"mappings":"AAAA,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,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;KAAE,CAAC;IACjF,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,OAAO,CAClD,WAAW,EACX,iBAAiB,EACjB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACjF;CAAG;AAEJ,eAAO,MAAM,WAAW,aAAkD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ export const MountVolume = Binding.Service("E2B.MountVolume");
3
+ //# sourceMappingURL=MountVolume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MountVolume.js","sources":["../src/MountVolume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AA2F3C,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAc,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import * as Layer from "effect/Layer";
2
+ import { MountVolume } from "./MountVolume.ts";
3
+ /**
4
+ * The implementation of {@link MountVolume}. It makes no API call: E2B
5
+ * mounts a volume by name when a sandbox is created, so the binding binds
6
+ * the name onto the host and, in an `E2B.Template` program, adds the mount
7
+ * to the template.
8
+ *
9
+ * ### Provide the layer
10
+ * **Example:** On a Worker
11
+ * ```typescript
12
+ * Effect.gen(function* () {
13
+ * const data = yield* E2B.MountVolume(Data, { path: "/data" });
14
+ * // ...
15
+ * }).pipe(Effect.provide(E2B.MountVolumeLive))
16
+ * ```
17
+ *
18
+ * @layer
19
+ * @product Volume
20
+ * @provides E2B.MountVolume
21
+ */
22
+ export declare const MountVolumeLive: Layer.Layer<MountVolume, never, never>;
23
+ //# sourceMappingURL=MountVolumeLive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MountVolumeLive.d.ts","sources":["../src/MountVolumeLive.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,WAAW,EAAkD,MAAM,kBAAkB,CAAC;AAI/F;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,wCAqB3B,CAAC"}
@@ -0,0 +1,41 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ import * as Output from "alchemy/Output";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Layer from "effect/Layer";
5
+ import { MountVolume } from "./MountVolume.js";
6
+ /**
7
+ * The implementation of {@link MountVolume}. It makes no API call: E2B
8
+ * mounts a volume by name when a sandbox is created, so the binding binds
9
+ * the name onto the host and, in an `E2B.Template` program, adds the mount
10
+ * to the template.
11
+ *
12
+ * ### Provide the layer
13
+ * **Example:** On a Worker
14
+ * ```typescript
15
+ * Effect.gen(function* () {
16
+ * const data = yield* E2B.MountVolume(Data, { path: "/data" });
17
+ * // ...
18
+ * }).pipe(Effect.provide(E2B.MountVolumeLive))
19
+ * ```
20
+ *
21
+ * @layer
22
+ * @product Volume
23
+ * @provides E2B.MountVolume
24
+ */
25
+ export const MountVolumeLive = Layer.succeed(MountVolume, Effect.fn("E2B.MountVolume")(function* (volume, options) {
26
+ if (!globalThis.__ALCHEMY_RUNTIME__) {
27
+ const host = yield* Binding.Host;
28
+ // A mount is part of a template program's own sandboxes, so it is
29
+ // attached to the template itself. `Binding.Host` is typed as a bare
30
+ // `ResourceLike` (a host's binding contract is only known per type),
31
+ // hence the cast once the type is checked.
32
+ if (host?.Type === "E2B.Template") {
33
+ yield* host.bind `${volume}`({
34
+ volumes: [{ volume: { name: volume.name }, path: options.path }],
35
+ });
36
+ }
37
+ }
38
+ const name = yield* Output.named(volume.name, `E2B_VOLUME_${volume.LogicalId}`).asEffect();
39
+ return { volume: { name }, path: options.path };
40
+ }));
41
+ //# sourceMappingURL=MountVolumeLive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MountVolumeLive.js","sources":["../src/MountVolumeLive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,WAAW,EAAkD,MAAM,kBAAkB,CAAC;AAI/F;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAC1C,WAAW,EACX,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAc,EAAE,OAA2B;IACjF,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;QACjC,kEAAkE;QAClE,qEAAqE;QACrE,qEAAqE;QACrE,2CAA2C;QAC3C,IAAI,IAAI,EAAE,IAAI,KAAK,cAAc,EAAE,CAAC;YAClC,KAAK,CAAC,CAAE,IAA4B,CAAC,IAAI,CAAA,GAAG,MAAM,EAAE,CAAC;gBACnD,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;aACjE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAC9B,MAAM,CAAC,IAAoC,EAC3C,cAAc,MAAM,CAAC,SAAS,EAAE,CACjC,CAAC,QAAQ,EAAE,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAA6B,CAAC;AAC7E,CAAC,CAAC,CACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import * as Provider from "alchemy/Provider";
2
+ import * as Layer from "effect/Layer";
3
+ import * as Credentials from "./Credentials.ts";
4
+ export { Credentials } from "@distilled.cloud/e2b/Credentials";
5
+ declare const Providers_base: Provider.ProviderCollection<Providers, "E2B">;
6
+ export declare class Providers extends Providers_base {
7
+ }
8
+ export type ProviderRequirements = Layer.Services<ReturnType<typeof providers>>;
9
+ /**
10
+ * E2B providers and credentials. Wires up every E2B resource and registers
11
+ * the E2B AuthProvider so `alchemy profile edit --add E2B` can configure it.
12
+ */
13
+ export declare const providers: () => Layer.Layer<Credentials.Credentials | import("alchemy/Auth/Credentials").CredentialsStore | import("effect/http/HttpClient").HttpClient | import("alchemy/Auth/Profile").ProfileStore | Providers, never, import("alchemy/Auth/Registry").AuthProviders | import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("effect/crypto/SecureRandom").SecureRandom | import("alchemy/Stack").Stack | import("alchemy/Stage").Stage>;
14
+ //# sourceMappingURL=Providers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Providers.d.ts","sources":["../src/Providers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAQhD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;;AAE/D,qBAAa,SAAU,SAAQ,cAA+C;CAAG;AAEjF,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,SAAS,6fAsBnB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { CredentialsStoreLive } from "alchemy/Auth/Credentials";
2
+ import { ProfileStoreLive } from "alchemy/Auth/Profile";
3
+ import * as Provider from "alchemy/Provider";
4
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
5
+ import * as Layer from "effect/Layer";
6
+ import { ApiKey, ApiKeyProvider } from "./ApiKey.js";
7
+ import { E2BAuth } from "./AuthProvider.js";
8
+ import * as Credentials from "./Credentials.js";
9
+ import { Sandbox, SandboxProvider } from "./Sandbox.js";
10
+ import { Secret, SecretProvider } from "./Secret.js";
11
+ import { Snapshot, SnapshotProvider } from "./Snapshot.js";
12
+ import { Template, TemplateProvider } from "./Template.js";
13
+ import { Volume, VolumeProvider } from "./Volume.js";
14
+ import { Webhook, WebhookProvider } from "./Webhook.js";
15
+ export { Credentials } from "@distilled.cloud/e2b/Credentials";
16
+ export class Providers extends Provider.ProviderCollection()("E2B") {
17
+ }
18
+ /**
19
+ * E2B providers and credentials. Wires up every E2B resource and registers
20
+ * the E2B AuthProvider so `alchemy profile edit --add E2B` can configure it.
21
+ */
22
+ export const providers = () => Layer.effect(Providers, Provider.collection([ApiKey, Sandbox, Secret, Snapshot, Template, Volume, Webhook])).pipe(Layer.provide(Layer.mergeAll(ApiKeyProvider(), SandboxProvider(), SecretProvider(), SnapshotProvider(), TemplateProvider(), VolumeProvider(), WebhookProvider())), Layer.provideMerge(Credentials.fromAuthProvider()), Layer.provideMerge(FetchHttpClient.layer), Layer.provideMerge(E2BAuth), Layer.provideMerge(ProfileStoreLive), Layer.provideMerge(CredentialsStoreLive), Layer.orDie);
23
+ //# sourceMappingURL=Providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Providers.js","sources":["../src/Providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/D,MAAM,OAAO,SAAU,SAAQ,QAAQ,CAAC,kBAAkB,EAAa,CAAC,KAAK,CAAC;CAAG;AAIjF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAC5B,KAAK,CAAC,MAAM,CACV,SAAS,EACT,QAAQ,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CACpF,CAAC,IAAI,CACJ,KAAK,CAAC,OAAO,CACX,KAAK,CAAC,QAAQ,CACZ,cAAc,EAAE,EAChB,eAAe,EAAE,EACjB,cAAc,EAAE,EAChB,gBAAgB,EAAE,EAClB,gBAAgB,EAAE,EAClB,cAAc,EAAE,EAChB,eAAe,EAAE,CAClB,CACF,EACD,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC,EAClD,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,CAAC,EACzC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,EAC3B,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,EACpC,KAAK,CAAC,YAAY,CAAC,oBAAoB,CAAC,EACxC,KAAK,CAAC,KAAK,CACZ,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type * as auth from "@distilled.cloud/e2b/auth";
2
+ import type * as events from "@distilled.cloud/e2b/events";
3
+ import * as Binding from "alchemy/Binding";
4
+ import type { RuntimeContext } from "alchemy/RuntimeContext";
5
+ import type * as Effect from "effect/Effect";
6
+ import type { E2BError } from "./SandboxClient.ts";
7
+ /** Team usage and the sandbox lifecycle event log. */
8
+ export interface TeamClient {
9
+ /** The team's id: the deployer's team, which the host's key belongs to. */
10
+ readonly teamId: Effect.Effect<string, never, RuntimeContext>;
11
+ /** Concurrent sandboxes and sandbox start rate over time (unix seconds). */
12
+ metrics(options?: Omit<auth.ListTeamMetricsRequest, "teamID">): Effect.Effect<auth.ListTeamMetricsResponse, E2BError, RuntimeContext>;
13
+ /** The peak of one metric over a window. */
14
+ maxMetric(options: Omit<auth.GetTeamMetricsMaxRequest, "teamID">): Effect.Effect<auth.MaxTeamMetric, E2BError, RuntimeContext>;
15
+ /** Lifecycle events of every sandbox in the team, newest first by default. */
16
+ events(options?: events.ListTeamSandboxEventsRequest): Effect.Effect<events.ListTeamSandboxEventsResponse, E2BError, RuntimeContext>;
17
+ /** Lifecycle events of one sandbox. */
18
+ sandboxEvents(sandboxId: string, options?: Omit<events.ListSandboxEventsRequest, "sandboxID">): Effect.Effect<events.ListSandboxEventsResponse, E2BError, RuntimeContext>;
19
+ }
20
+ /**
21
+ * Read the team's sandbox usage and lifecycle event log: dashboards, quotas,
22
+ * auditing which sandboxes started, paused and were killed.
23
+ *
24
+ * To react to lifecycle events as they happen, use `E2B.SandboxEvents`.
25
+ *
26
+ * ### Reading usage
27
+ * **Example:** Concurrent sandboxes over the last hour
28
+ * ```typescript
29
+ * const team = yield* E2B.ReadTeam();
30
+ * // in fetch:
31
+ * const now = Math.floor(Date.now() / 1000);
32
+ * const metrics = yield* team.metrics({ start: now - 3600, end: now });
33
+ * ```
34
+ *
35
+ * @binding
36
+ * @product Team
37
+ */
38
+ export interface ReadTeam extends Binding.Service<ReadTeam, "E2B.ReadTeam", () => Effect.Effect<TeamClient>> {
39
+ }
40
+ export declare const ReadTeam: ReadTeam;
41
+ //# sourceMappingURL=ReadTeam.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadTeam.d.ts","sources":["../src/ReadTeam.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAC3D,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;AAEnD,sDAAsD;AACtD,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAC9D,4EAA4E;IAC5E,OAAO,CACL,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,GACpD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IACzE,4CAA4C;IAC5C,SAAS,CACP,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,QAAQ,CAAC,GACrD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC/D,8EAA8E;IAC9E,MAAM,CACJ,OAAO,CAAC,EAAE,MAAM,CAAC,4BAA4B,GAC5C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,6BAA6B,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IACjF,uCAAuC;IACvC,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,wBAAwB,EAAE,WAAW,CAAC,GAC3D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;CAC9E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,QAAS,SAAQ,OAAO,CAAC,OAAO,CAC/C,QAAQ,EACR,cAAc,EACd,MAAM,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAChC;CAAG;AAEJ,eAAO,MAAM,QAAQ,UAA4C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ export const ReadTeam = Binding.Service("E2B.ReadTeam");
3
+ //# sourceMappingURL=ReadTeam.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadTeam.js","sources":["../src/ReadTeam.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAoD3C,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAW,cAAc,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import * as Layer from "effect/Layer";
2
+ import { ReadTeam } from "./ReadTeam.ts";
3
+ /**
4
+ * HTTP implementation of {@link ReadTeam}. Works on any host.
5
+ *
6
+ * ### Provide the layer
7
+ * **Example:** On a Worker
8
+ * ```typescript
9
+ * Effect.gen(function* () {
10
+ * const team = yield* E2B.ReadTeam();
11
+ * // ...
12
+ * }).pipe(Effect.provide(E2B.ReadTeamHttp))
13
+ * ```
14
+ *
15
+ * @layer
16
+ * @product Team
17
+ * @provides E2B.ReadTeam
18
+ */
19
+ export declare const ReadTeamHttp: Layer.Layer<ReadTeam, never, never>;
20
+ //# sourceMappingURL=ReadTeamHttp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadTeamHttp.d.ts","sources":["../src/ReadTeamHttp.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY,qCAoBxB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import * as auth from "@distilled.cloud/e2b/auth";
2
+ import * as events from "@distilled.cloud/e2b/events";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Layer from "effect/Layer";
5
+ import { bindE2B } from "./E2BBindings.js";
6
+ import { ReadTeam } from "./ReadTeam.js";
7
+ /**
8
+ * HTTP implementation of {@link ReadTeam}. Works on any host.
9
+ *
10
+ * ### Provide the layer
11
+ * **Example:** On a Worker
12
+ * ```typescript
13
+ * Effect.gen(function* () {
14
+ * const team = yield* E2B.ReadTeam();
15
+ * // ...
16
+ * }).pipe(Effect.provide(E2B.ReadTeamHttp))
17
+ * ```
18
+ *
19
+ * @layer
20
+ * @product Team
21
+ * @provides E2B.ReadTeam
22
+ */
23
+ export const ReadTeamHttp = Layer.succeed(ReadTeam, Effect.fn("E2B.ReadTeam")(function* () {
24
+ const e2b = yield* bindE2B;
25
+ const client = {
26
+ teamId: e2b.teamId,
27
+ metrics: Effect.fn("E2B.ReadTeam.metrics")(function* (options) {
28
+ const teamID = yield* e2b.teamId;
29
+ return yield* e2b.authorize(auth.listTeamMetrics({ ...options, teamID }));
30
+ }),
31
+ maxMetric: Effect.fn("E2B.ReadTeam.maxMetric")(function* (options) {
32
+ const teamID = yield* e2b.teamId;
33
+ return yield* e2b.authorize(auth.getTeamMetricsMax({ ...options, teamID }));
34
+ }),
35
+ events: (options) => e2b.authorize(events.listTeamSandboxEvents({ ...options })),
36
+ sandboxEvents: (sandboxId, options) => e2b.authorize(events.listSandboxEvents({ ...options, sandboxID: sandboxId })),
37
+ };
38
+ return client;
39
+ }));
40
+ //# sourceMappingURL=ReadTeamHttp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadTeamHttp.js","sources":["../src/ReadTeamHttp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CACvC,QAAQ,EACR,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC;IACjC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC;IAC3B,MAAM,MAAM,GAAe;QACzB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,MAAM,CAAC,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