@alchemy.run/daytona 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.
- package/LICENSE +201 -0
- package/README.md +76 -4
- package/lib/ApiKey.d.ts +99 -0
- package/lib/ApiKey.d.ts.map +1 -0
- package/lib/ApiKey.js +152 -0
- package/lib/ApiKey.js.map +1 -0
- package/lib/AuthProvider.d.ts +55 -0
- package/lib/AuthProvider.d.ts.map +1 -0
- package/lib/AuthProvider.js +280 -0
- package/lib/AuthProvider.js.map +1 -0
- package/lib/Bootstrap.d.ts +8 -0
- package/lib/Bootstrap.d.ts.map +1 -0
- package/lib/Bootstrap.js +28 -0
- package/lib/Bootstrap.js.map +1 -0
- package/lib/ConnectSandbox.d.ts +72 -0
- package/lib/ConnectSandbox.d.ts.map +1 -0
- package/lib/ConnectSandbox.js +3 -0
- package/lib/ConnectSandbox.js.map +1 -0
- package/lib/ConnectSandboxHttp.d.ts +5 -0
- package/lib/ConnectSandboxHttp.d.ts.map +1 -0
- package/lib/ConnectSandboxHttp.js +22 -0
- package/lib/ConnectSandboxHttp.js.map +1 -0
- package/lib/Contributions.d.ts +7 -0
- package/lib/Contributions.d.ts.map +1 -0
- package/lib/Contributions.js +6 -0
- package/lib/Contributions.js.map +1 -0
- package/lib/CreateSandbox.d.ts +86 -0
- package/lib/CreateSandbox.d.ts.map +1 -0
- package/lib/CreateSandbox.js +3 -0
- package/lib/CreateSandbox.js.map +1 -0
- package/lib/CreateSandboxHttp.d.ts +5 -0
- package/lib/CreateSandboxHttp.d.ts.map +1 -0
- package/lib/CreateSandboxHttp.js +65 -0
- package/lib/CreateSandboxHttp.js.map +1 -0
- package/lib/CreateSecret.d.ts +56 -0
- package/lib/CreateSecret.d.ts.map +1 -0
- package/lib/CreateSecret.js +3 -0
- package/lib/CreateSecret.js.map +1 -0
- package/lib/CreateSecretHttp.d.ts +5 -0
- package/lib/CreateSecretHttp.d.ts.map +1 -0
- package/lib/CreateSecretHttp.js +39 -0
- package/lib/CreateSecretHttp.js.map +1 -0
- package/lib/CreateSnapshot.d.ts +80 -0
- package/lib/CreateSnapshot.d.ts.map +1 -0
- package/lib/CreateSnapshot.js +3 -0
- package/lib/CreateSnapshot.js.map +1 -0
- package/lib/CreateSnapshotHttp.d.ts +5 -0
- package/lib/CreateSnapshotHttp.d.ts.map +1 -0
- package/lib/CreateSnapshotHttp.js +47 -0
- package/lib/CreateSnapshotHttp.js.map +1 -0
- package/lib/CreateVolume.d.ts +81 -0
- package/lib/CreateVolume.d.ts.map +1 -0
- package/lib/CreateVolume.js +10 -0
- package/lib/CreateVolume.js.map +1 -0
- package/lib/CreateVolumeHttp.d.ts +5 -0
- package/lib/CreateVolumeHttp.d.ts.map +1 -0
- package/lib/CreateVolumeHttp.js +31 -0
- package/lib/CreateVolumeHttp.js.map +1 -0
- package/lib/Credentials.d.ts +9 -0
- package/lib/Credentials.d.ts.map +1 -0
- package/lib/Credentials.js +18 -0
- package/lib/Credentials.js.map +1 -0
- package/lib/DaytonaBindings.d.ts +51 -0
- package/lib/DaytonaBindings.d.ts.map +1 -0
- package/lib/DaytonaBindings.js +61 -0
- package/lib/DaytonaBindings.js.map +1 -0
- package/lib/IdentityProvider.d.ts +80 -0
- package/lib/IdentityProvider.d.ts.map +1 -0
- package/lib/IdentityProvider.js +111 -0
- package/lib/IdentityProvider.js.map +1 -0
- package/lib/MountVolume.d.ts +86 -0
- package/lib/MountVolume.d.ts.map +1 -0
- package/lib/MountVolume.js +27 -0
- package/lib/MountVolume.js.map +1 -0
- package/lib/OAuthClient.d.ts +14 -0
- package/lib/OAuthClient.d.ts.map +1 -0
- package/lib/OAuthClient.js +23 -0
- package/lib/OAuthClient.js.map +1 -0
- package/lib/Organization.d.ts +40 -0
- package/lib/Organization.d.ts.map +1 -0
- package/lib/Organization.js +80 -0
- package/lib/Organization.js.map +1 -0
- package/lib/OrganizationInvitation.d.ts +70 -0
- package/lib/OrganizationInvitation.d.ts.map +1 -0
- package/lib/OrganizationInvitation.js +109 -0
- package/lib/OrganizationInvitation.js.map +1 -0
- package/lib/OrganizationMember.d.ts +86 -0
- package/lib/OrganizationMember.d.ts.map +1 -0
- package/lib/OrganizationMember.js +109 -0
- package/lib/OrganizationMember.js.map +1 -0
- package/lib/OrganizationOtelConfig.d.ts +59 -0
- package/lib/OrganizationOtelConfig.d.ts.map +1 -0
- package/lib/OrganizationOtelConfig.js +87 -0
- package/lib/OrganizationOtelConfig.js.map +1 -0
- package/lib/OrganizationRole.d.ts +66 -0
- package/lib/OrganizationRole.d.ts.map +1 -0
- package/lib/OrganizationRole.js +106 -0
- package/lib/OrganizationRole.js.map +1 -0
- package/lib/OrganizationSettings.d.ts +76 -0
- package/lib/OrganizationSettings.d.ts.map +1 -0
- package/lib/OrganizationSettings.js +107 -0
- package/lib/OrganizationSettings.js.map +1 -0
- package/lib/Providers.d.ts +14 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +53 -0
- package/lib/Providers.js.map +1 -0
- package/lib/ReadAuditLogs.d.ts +30 -0
- package/lib/ReadAuditLogs.d.ts.map +1 -0
- package/lib/ReadAuditLogs.js +17 -0
- package/lib/ReadAuditLogs.js.map +1 -0
- package/lib/ReadOrganization.d.ts +39 -0
- package/lib/ReadOrganization.d.ts.map +1 -0
- package/lib/ReadOrganization.js +39 -0
- package/lib/ReadOrganization.js.map +1 -0
- package/lib/ReadUsage.d.ts +31 -0
- package/lib/ReadUsage.d.ts.map +1 -0
- package/lib/ReadUsage.js +17 -0
- package/lib/ReadUsage.js.map +1 -0
- package/lib/Region.d.ts +78 -0
- package/lib/Region.d.ts.map +1 -0
- package/lib/Region.js +169 -0
- package/lib/Region.js.map +1 -0
- package/lib/Registry.d.ts +84 -0
- package/lib/Registry.d.ts.map +1 -0
- package/lib/Registry.js +97 -0
- package/lib/Registry.js.map +1 -0
- package/lib/Runner.d.ts +66 -0
- package/lib/Runner.d.ts.map +1 -0
- package/lib/Runner.js +116 -0
- package/lib/Runner.js.map +1 -0
- package/lib/Sandbox.d.ts +376 -0
- package/lib/Sandbox.d.ts.map +1 -0
- package/lib/Sandbox.js +565 -0
- package/lib/Sandbox.js.map +1 -0
- package/lib/SandboxClient.d.ts +258 -0
- package/lib/SandboxClient.d.ts.map +1 -0
- package/lib/SandboxClient.js +233 -0
- package/lib/SandboxClient.js.map +1 -0
- package/lib/Secret.d.ts +93 -0
- package/lib/Secret.d.ts.map +1 -0
- package/lib/Secret.js +130 -0
- package/lib/Secret.js.map +1 -0
- package/lib/Snapshot.d.ts +327 -0
- package/lib/Snapshot.d.ts.map +1 -0
- package/lib/Snapshot.js +447 -0
- package/lib/Snapshot.js.map +1 -0
- package/lib/Volume.d.ts +99 -0
- package/lib/Volume.d.ts.map +1 -0
- package/lib/Volume.js +152 -0
- package/lib/Volume.js.map +1 -0
- package/lib/WarmPool.d.ts +61 -0
- package/lib/WarmPool.d.ts.map +1 -0
- package/lib/WarmPool.js +81 -0
- package/lib/WarmPool.js.map +1 -0
- package/lib/Webhooks.d.ts +58 -0
- package/lib/Webhooks.d.ts.map +1 -0
- package/lib/Webhooks.js +75 -0
- package/lib/Webhooks.js.map +1 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +36 -0
- package/lib/index.js.map +1 -0
- package/lib/internal/BuildContext.d.ts +16 -0
- package/lib/internal/BuildContext.d.ts.map +1 -0
- package/lib/internal/BuildContext.js +50 -0
- package/lib/internal/BuildContext.js.map +1 -0
- package/lib/internal/Declared.d.ts +29 -0
- package/lib/internal/Declared.d.ts.map +1 -0
- package/lib/internal/Declared.js +31 -0
- package/lib/internal/Declared.js.map +1 -0
- package/lib/internal/Derived.d.ts +40 -0
- package/lib/internal/Derived.d.ts.map +1 -0
- package/lib/internal/Derived.js +64 -0
- package/lib/internal/Derived.js.map +1 -0
- package/lib/internal/Errors.d.ts +4 -0
- package/lib/internal/Errors.d.ts.map +1 -0
- package/lib/internal/Errors.js +1 -0
- package/lib/internal/Errors.js.map +1 -0
- package/lib/internal/Labels.d.ts +20 -0
- package/lib/internal/Labels.d.ts.map +1 -0
- package/lib/internal/Labels.js +22 -0
- package/lib/internal/Labels.js.map +1 -0
- package/lib/internal/Names.d.ts +18 -0
- package/lib/internal/Names.d.ts.map +1 -0
- package/lib/internal/Names.js +25 -0
- package/lib/internal/Names.js.map +1 -0
- package/lib/internal/Organization.d.ts +27 -0
- package/lib/internal/Organization.d.ts.map +1 -0
- package/lib/internal/Organization.js +32 -0
- package/lib/internal/Organization.js.map +1 -0
- package/lib/internal/Process.d.ts +14 -0
- package/lib/internal/Process.d.ts.map +1 -0
- package/lib/internal/Process.js +15 -0
- package/lib/internal/Process.js.map +1 -0
- package/lib/internal/Program.d.ts +83 -0
- package/lib/internal/Program.d.ts.map +1 -0
- package/lib/internal/Program.js +169 -0
- package/lib/internal/Program.js.map +1 -0
- package/lib/internal/Ref.d.ts +14 -0
- package/lib/internal/Ref.d.ts.map +1 -0
- package/lib/internal/Ref.js +7 -0
- package/lib/internal/Ref.js.map +1 -0
- package/lib/internal/Scoped.d.ts +31 -0
- package/lib/internal/Scoped.d.ts.map +1 -0
- package/lib/internal/Scoped.js +48 -0
- package/lib/internal/Scoped.js.map +1 -0
- package/lib/internal/Tar.d.ts +13 -0
- package/lib/internal/Tar.d.ts.map +1 -0
- package/lib/internal/Tar.js +62 -0
- package/lib/internal/Tar.js.map +1 -0
- package/lib/internal/Toolbox.d.ts +11 -0
- package/lib/internal/Toolbox.d.ts.map +1 -0
- package/lib/internal/Toolbox.js +20 -0
- package/lib/internal/Toolbox.js.map +1 -0
- package/lib/internal/Wait.d.ts +49 -0
- package/lib/internal/Wait.d.ts.map +1 -0
- package/lib/internal/Wait.js +57 -0
- package/lib/internal/Wait.js.map +1 -0
- package/package.json +64 -3
- package/src/ApiKey.ts +221 -0
- package/src/AuthProvider.ts +406 -0
- package/src/Bootstrap.ts +55 -0
- package/src/ConnectSandbox.ts +76 -0
- package/src/ConnectSandboxHttp.ts +26 -0
- package/src/Contributions.ts +9 -0
- package/src/CreateSandbox.ts +107 -0
- package/src/CreateSandboxHttp.ts +97 -0
- package/src/CreateSecret.ts +73 -0
- package/src/CreateSecretHttp.ts +58 -0
- package/src/CreateSnapshot.ts +133 -0
- package/src/CreateSnapshotHttp.ts +77 -0
- package/src/CreateVolume.ts +104 -0
- package/src/CreateVolumeHttp.ts +50 -0
- package/src/Credentials.ts +37 -0
- package/src/DaytonaBindings.ts +111 -0
- package/src/IdentityProvider.ts +181 -0
- package/src/MountVolume.ts +122 -0
- package/src/OAuthClient.ts +27 -0
- package/src/Organization.ts +121 -0
- package/src/OrganizationInvitation.ts +174 -0
- package/src/OrganizationMember.ts +174 -0
- package/src/OrganizationOtelConfig.ts +138 -0
- package/src/OrganizationRole.ts +167 -0
- package/src/OrganizationSettings.ts +187 -0
- package/src/Providers.ts +93 -0
- package/src/ReadAuditLogs.ts +50 -0
- package/src/ReadOrganization.ts +83 -0
- package/src/ReadUsage.ts +51 -0
- package/src/Region.ts +226 -0
- package/src/Registry.ts +164 -0
- package/src/Runner.ts +166 -0
- package/src/Sandbox.ts +927 -0
- package/src/SandboxClient.ts +625 -0
- package/src/Secret.ts +203 -0
- package/src/Snapshot.ts +685 -0
- package/src/Volume.ts +229 -0
- package/src/WarmPool.ts +128 -0
- package/src/Webhooks.ts +121 -0
- package/src/globals.d.ts +2 -0
- package/src/index.ts +46 -0
- package/src/internal/BuildContext.ts +62 -0
- package/src/internal/Declared.ts +80 -0
- package/src/internal/Derived.ts +97 -0
- package/src/internal/Errors.ts +4 -0
- package/src/internal/Labels.ts +39 -0
- package/src/internal/Names.ts +37 -0
- package/src/internal/Organization.ts +40 -0
- package/src/internal/Process.ts +25 -0
- package/src/internal/Program.ts +239 -0
- package/src/internal/Ref.ts +15 -0
- package/src/internal/Scoped.ts +102 -0
- package/src/internal/Tar.ts +72 -0
- package/src/internal/Toolbox.ts +27 -0
- package/src/internal/Wait.ts +105 -0
package/lib/Secret.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import * as secrets from "@distilled.cloud/daytona/secret";
|
|
3
|
+
import { Unowned } from "alchemy/AdoptPolicy";
|
|
4
|
+
import { deepEqual, 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 Redacted from "effect/Redacted";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
10
|
+
import { isOwnedName, resolveName } from "./internal/Names.js";
|
|
11
|
+
/**
|
|
12
|
+
* A secret stored in Daytona. A sandbox gets a placeholder in place of
|
|
13
|
+
* the value, and Daytona's egress proxy substitutes the real value only on
|
|
14
|
+
* requests to the secret's `hosts`, so code in the sandbox (or an agent
|
|
15
|
+
* running there) can use a credential without being able to read it.
|
|
16
|
+
*
|
|
17
|
+
* Declare a secret here for credentials the whole app shares. For a secret
|
|
18
|
+
* per user, create it at runtime with {@link CreateSecret}.
|
|
19
|
+
* @see https://www.daytona.io/docs/en/secrets/
|
|
20
|
+
*
|
|
21
|
+
* ### Creating a Secret
|
|
22
|
+
* **Example:** An npm token only sent to the registry
|
|
23
|
+
* ```typescript
|
|
24
|
+
* export const NpmToken = Daytona.Secret("NpmToken", {
|
|
25
|
+
* value: Config.Redacted("NPM_TOKEN"),
|
|
26
|
+
* hosts: ["registry.npmjs.org"],
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ### Using a Secret in a Sandbox
|
|
31
|
+
* **Example:** Expose it to a sandbox as an environment variable
|
|
32
|
+
* ```typescript
|
|
33
|
+
* export const DevBox = Daytona.Sandbox("DevBox", {
|
|
34
|
+
* snapshot: Base,
|
|
35
|
+
* secrets: { NPM_TOKEN: NpmToken },
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @resource
|
|
40
|
+
* @product Secret
|
|
41
|
+
*/
|
|
42
|
+
export const Secret = Resource("Daytona.Secret");
|
|
43
|
+
export const hashSecretValue = (value) => Effect.sync(() => createHash("sha256")
|
|
44
|
+
.update(Redacted.isRedacted(value) ? Redacted.value(value) : value)
|
|
45
|
+
.digest("hex"));
|
|
46
|
+
export const toSecretAttributes = (s, valueHash) => ({
|
|
47
|
+
secretId: s.id,
|
|
48
|
+
name: s.name,
|
|
49
|
+
placeholder: s.placeholder,
|
|
50
|
+
hosts: s.hosts,
|
|
51
|
+
description: s.description,
|
|
52
|
+
valueHash,
|
|
53
|
+
});
|
|
54
|
+
export const getSecretById = (secretId) => secrets.getSecret({ secretId }).pipe(Effect.catchTag("SecretNotFound", () => Effect.undefined));
|
|
55
|
+
/** Exact-name lookup over the paginated list (its `name` filter is a substring match). */
|
|
56
|
+
export const findSecretByName = (name) => secrets.listSecretsPaginated.items({ name }).pipe(Stream.filter((s) => s.name === name), Stream.runHead, Effect.map((found) => (found._tag === "Some" ? found.value : undefined)));
|
|
57
|
+
export const ensureSecret = Effect.fn(function* (input) {
|
|
58
|
+
const valueHash = yield* hashSecretValue(input.value);
|
|
59
|
+
const existing = input.existing ?? (yield* findSecretByName(input.name));
|
|
60
|
+
if (existing === undefined) {
|
|
61
|
+
const created = yield* secrets
|
|
62
|
+
.createSecret({
|
|
63
|
+
name: input.name,
|
|
64
|
+
value: input.value,
|
|
65
|
+
description: input.description,
|
|
66
|
+
hosts: input.hosts,
|
|
67
|
+
})
|
|
68
|
+
.pipe(Effect.catchTag("SecretAlreadyExists", () => Effect.undefined));
|
|
69
|
+
if (created !== undefined)
|
|
70
|
+
return toSecretAttributes(created, valueHash);
|
|
71
|
+
}
|
|
72
|
+
const current = existing ?? (yield* findSecretByName(input.name));
|
|
73
|
+
if (current === undefined)
|
|
74
|
+
return yield* Effect.die(`Daytona secret ${input.name} vanished during create`);
|
|
75
|
+
// Sync — the value can't be observed, so it is rewritten unless the
|
|
76
|
+
// hash we last wrote matches. Description and hosts diff against cloud.
|
|
77
|
+
const hostsChanged = input.hosts !== undefined && !deepEqual([...input.hosts].sort(), [...current.hosts].sort());
|
|
78
|
+
const descriptionChanged = input.description !== undefined && input.description !== current.description;
|
|
79
|
+
const valueChanged = input.knownHash !== valueHash;
|
|
80
|
+
if (!hostsChanged && !descriptionChanged && !valueChanged)
|
|
81
|
+
return toSecretAttributes(current, valueHash);
|
|
82
|
+
const updated = yield* secrets.updateSecret({
|
|
83
|
+
secretId: current.id,
|
|
84
|
+
value: valueChanged ? input.value : undefined,
|
|
85
|
+
description: descriptionChanged ? input.description : undefined,
|
|
86
|
+
hosts: hostsChanged ? input.hosts : undefined,
|
|
87
|
+
});
|
|
88
|
+
return toSecretAttributes(updated, valueHash);
|
|
89
|
+
});
|
|
90
|
+
export const SecretProvider = () => Provider.effect(Secret, Effect.succeed({
|
|
91
|
+
stables: ["secretId", "placeholder"],
|
|
92
|
+
list: Effect.fn(function* () {
|
|
93
|
+
const all = yield* secrets.listSecretsPaginated.items({}).pipe(Stream.runCollect);
|
|
94
|
+
return Array.from(all).map((s) => toSecretAttributes(s, ""));
|
|
95
|
+
}),
|
|
96
|
+
diff: Effect.fn(function* ({ id, news, output }) {
|
|
97
|
+
if (!isResolved(news) || output === undefined)
|
|
98
|
+
return undefined;
|
|
99
|
+
const name = yield* resolveName(id, news.name, news.name === undefined ? output.name : undefined);
|
|
100
|
+
if (name !== output.name)
|
|
101
|
+
return { action: "replace", deleteFirst: true };
|
|
102
|
+
}),
|
|
103
|
+
read: Effect.fn(function* ({ id, olds, output }) {
|
|
104
|
+
const name = yield* resolveName(id, olds?.name, output?.name);
|
|
105
|
+
const found = (output ? yield* getSecretById(output.secretId) : undefined) ??
|
|
106
|
+
(yield* findSecretByName(name));
|
|
107
|
+
if (found === undefined)
|
|
108
|
+
return undefined;
|
|
109
|
+
const attrs = toSecretAttributes(found, output?.valueHash ?? "");
|
|
110
|
+
return (yield* isOwnedName(id, found.name, output !== undefined)) ? attrs : Unowned(attrs);
|
|
111
|
+
}),
|
|
112
|
+
reconcile: Effect.fn(function* ({ id, news, output }) {
|
|
113
|
+
const name = yield* resolveName(id, news.name, output?.name);
|
|
114
|
+
const byId = output ? yield* getSecretById(output.secretId) : undefined;
|
|
115
|
+
return yield* ensureSecret({
|
|
116
|
+
name,
|
|
117
|
+
value: news.value,
|
|
118
|
+
description: news.description,
|
|
119
|
+
hosts: news.hosts,
|
|
120
|
+
existing: byId?.name === name ? byId : undefined,
|
|
121
|
+
knownHash: byId?.name === name ? output?.valueHash : undefined,
|
|
122
|
+
});
|
|
123
|
+
}),
|
|
124
|
+
delete: Effect.fn(function* ({ output }) {
|
|
125
|
+
yield* secrets
|
|
126
|
+
.deleteSecret({ secretId: output.secretId })
|
|
127
|
+
.pipe(Effect.catchTag("SecretNotFound", () => Effect.void));
|
|
128
|
+
}),
|
|
129
|
+
}));
|
|
130
|
+
//# sourceMappingURL=Secret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Secret.js","sources":["../src/Secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AA8C/D;;;;;;;;;;;;;;;;;;;;;;;;;;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aAC3C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC,CAAC;CACH,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import * as BuildPlan from "@alchemy.run/docker/BuildPlan";
|
|
2
|
+
import type { InlineDockerfile } from "@alchemy.run/docker/Dockerfile";
|
|
3
|
+
import * as DockerfileParser from "@alchemy.run/docker/DockerfileParser";
|
|
4
|
+
import * as dockerRegistry from "@distilled.cloud/daytona/docker_registry";
|
|
5
|
+
import * as sandboxes from "@distilled.cloud/daytona/sandbox";
|
|
6
|
+
import * as snapshots from "@distilled.cloud/daytona/snapshots";
|
|
7
|
+
import * as Provider from "alchemy/Provider";
|
|
8
|
+
import { Resource } from "alchemy/Resource";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import type * as Redacted from "effect/Redacted";
|
|
11
|
+
import { type Ref } from "./internal/Ref.ts";
|
|
12
|
+
import type { Providers } from "./Providers.ts";
|
|
13
|
+
/** A snapshot, by name. Accepts a `Daytona.Snapshot` or `{ name }`. */
|
|
14
|
+
export type SnapshotRef = {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
};
|
|
17
|
+
/** A private registry. Accepts a `Daytona.Registry` or `{ registryId }`. */
|
|
18
|
+
export type SnapshotRegistry = {
|
|
19
|
+
readonly registryId: string;
|
|
20
|
+
};
|
|
21
|
+
export type GpuType = snapshots.GpuType;
|
|
22
|
+
export interface SnapshotBuild {
|
|
23
|
+
/** Build arguments, read by the Dockerfile's `ARG` instructions. */
|
|
24
|
+
args?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* BuildKit secrets, keyed by id; mount one in a `RUN` step with
|
|
27
|
+
* `--mount=type=secret,id=<id>`. They never enter the image or its hash.
|
|
28
|
+
* Daytona's builders can't receive secrets, so setting any builds locally.
|
|
29
|
+
*/
|
|
30
|
+
secrets?: Record<string, Redacted.Redacted<string>>;
|
|
31
|
+
/**
|
|
32
|
+
* Build on Daytona's builders (`true`), or with your local Docker
|
|
33
|
+
* (`false`), pushing the image to Daytona's registry. Build locally to use
|
|
34
|
+
* build secrets, base images only your machine can pull, or your local
|
|
35
|
+
* layer cache.
|
|
36
|
+
* @default true, unless `secrets` are set
|
|
37
|
+
*/
|
|
38
|
+
remote?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface SnapshotProps {
|
|
41
|
+
/**
|
|
42
|
+
* Snapshot name, unique in the organization. Sandboxes are created from
|
|
43
|
+
* it by name. If omitted, a unique name is generated from the stack,
|
|
44
|
+
* stage and logical ID. Changing it replaces the snapshot.
|
|
45
|
+
*/
|
|
46
|
+
name?: string;
|
|
47
|
+
/**
|
|
48
|
+
* An image to pull, with an explicit tag or digest (Daytona rejects
|
|
49
|
+
* `latest`, `lts` and `stable`). Pass a {@link Registry} as `registry`
|
|
50
|
+
* for private images. Exclusive with `dockerfile` and `from`.
|
|
51
|
+
*/
|
|
52
|
+
image?: string;
|
|
53
|
+
/**
|
|
54
|
+
* A Dockerfile to build: a path (relative to the cwd), or inline content
|
|
55
|
+
* (`Dockerfile.inline`). Daytona builds it on its own builders, uploading
|
|
56
|
+
* the files it `COPY`s from {@link context}; no local Docker is needed.
|
|
57
|
+
* Set `build.remote: false` to build it with your local Docker instead.
|
|
58
|
+
* Changing the Dockerfile or any file it copies replaces the snapshot.
|
|
59
|
+
* Exclusive with `image` and `from`.
|
|
60
|
+
* @default `${context}/Dockerfile` when `context` is set
|
|
61
|
+
*/
|
|
62
|
+
dockerfile?: string | InlineDockerfile;
|
|
63
|
+
/**
|
|
64
|
+
* Build context directory for a Dockerfile path. Only the files its
|
|
65
|
+
* `COPY`/`ADD` instructions reach are uploaded (after `.dockerignore`).
|
|
66
|
+
* Inline Dockerfiles have no context and can't `COPY` local files.
|
|
67
|
+
*/
|
|
68
|
+
context?: string;
|
|
69
|
+
/** How the Dockerfile is built. */
|
|
70
|
+
build?: SnapshotBuild;
|
|
71
|
+
/**
|
|
72
|
+
* Build a warm base from another snapshot: start a sandbox from `from`,
|
|
73
|
+
* run `run` in it, and capture its filesystem as this snapshot. Use it to
|
|
74
|
+
* bake a cloned repository and installed dependencies into the snapshot
|
|
75
|
+
* sandboxes fork from. Exclusive with `image` and `dockerfile`.
|
|
76
|
+
*/
|
|
77
|
+
from?: Ref<SnapshotRef>;
|
|
78
|
+
/**
|
|
79
|
+
* Shell commands run in order in the `from` sandbox before it is
|
|
80
|
+
* captured. A non-zero exit fails the deploy.
|
|
81
|
+
*/
|
|
82
|
+
run?: string[];
|
|
83
|
+
/** Private registry to pull `image` (or a Dockerfile's base) from. */
|
|
84
|
+
registry?: Ref<SnapshotRegistry>;
|
|
85
|
+
/** The command a sandbox from this snapshot runs. */
|
|
86
|
+
entrypoint?: string[];
|
|
87
|
+
/** vCPUs for sandboxes from this snapshot. */
|
|
88
|
+
cpu?: number;
|
|
89
|
+
/** Memory in GiB. */
|
|
90
|
+
memory?: number;
|
|
91
|
+
/** Disk in GiB. */
|
|
92
|
+
disk?: number;
|
|
93
|
+
/** GPUs per sandbox. Billed per hour while a sandbox runs. */
|
|
94
|
+
gpu?: number;
|
|
95
|
+
/** Acceptable GPU types, in order of preference. */
|
|
96
|
+
gpuType?: GpuType[];
|
|
97
|
+
/** Region to build the snapshot in. */
|
|
98
|
+
regionId?: string;
|
|
99
|
+
/** Sandbox class (`container`, `linux-vm`, …). Dockerfile builds need `container`. */
|
|
100
|
+
sandboxClass?: snapshots.SandboxClass;
|
|
101
|
+
}
|
|
102
|
+
export interface SnapshotAttributes {
|
|
103
|
+
/** Snapshot ID. */
|
|
104
|
+
snapshotId: string;
|
|
105
|
+
/** Snapshot name; what sandboxes are created from. */
|
|
106
|
+
name: string;
|
|
107
|
+
/** State (`active` once usable). */
|
|
108
|
+
state: snapshots.SnapshotState;
|
|
109
|
+
/** The pulled or built image. */
|
|
110
|
+
imageName: string | undefined;
|
|
111
|
+
/** Internal image reference. */
|
|
112
|
+
ref: string | undefined;
|
|
113
|
+
/** vCPUs. */
|
|
114
|
+
cpu: number;
|
|
115
|
+
/** Memory in GiB. */
|
|
116
|
+
memory: number;
|
|
117
|
+
/** Disk in GiB. */
|
|
118
|
+
disk: number;
|
|
119
|
+
/** GPUs. */
|
|
120
|
+
gpu: number;
|
|
121
|
+
/** The sandbox this snapshot was captured from, for `from` snapshots. */
|
|
122
|
+
sourceSandboxId: string | undefined;
|
|
123
|
+
/** Hash of everything the snapshot was built from. */
|
|
124
|
+
buildHash: string;
|
|
125
|
+
}
|
|
126
|
+
export type Snapshot = Resource<"Daytona.Snapshot", SnapshotProps, SnapshotAttributes, never, Providers, SnapshotLookup>;
|
|
127
|
+
/**
|
|
128
|
+
* Props for {@link Snapshot.lookup}: find a snapshot this stack
|
|
129
|
+
* doesn't manage by its name or id.
|
|
130
|
+
*/
|
|
131
|
+
export interface SnapshotLookup {
|
|
132
|
+
/** Snapshot name or id. */
|
|
133
|
+
name: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A Daytona snapshot: the image sandboxes boot from, with its default
|
|
137
|
+
* size. Pull one from a registry, build one from a Dockerfile on
|
|
138
|
+
* Daytona's builders, or capture one from a sandbox after running setup
|
|
139
|
+
* commands in it (a warm base to fork from).
|
|
140
|
+
*
|
|
141
|
+
* Snapshots are immutable: changing what one is built from replaces it.
|
|
142
|
+
* Daytona deactivates a snapshot after two weeks without use; deploy
|
|
143
|
+
* reactivates it.
|
|
144
|
+
* @see https://www.daytona.io/docs/en/snapshots/
|
|
145
|
+
*
|
|
146
|
+
* ### Pulling an Image
|
|
147
|
+
* **Example:** A public image with a size
|
|
148
|
+
* ```typescript
|
|
149
|
+
* export const Node = Daytona.Snapshot("Node", {
|
|
150
|
+
* image: "node:22-bookworm",
|
|
151
|
+
* cpu: 2,
|
|
152
|
+
* memory: 4,
|
|
153
|
+
* disk: 10,
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* ### Building from a Dockerfile
|
|
158
|
+
* **Example:** An inline Dockerfile built by Daytona
|
|
159
|
+
* ```typescript
|
|
160
|
+
* export const Base = Daytona.Snapshot("Base", {
|
|
161
|
+
* dockerfile: Dockerfile.inline`
|
|
162
|
+
* FROM node:22-bookworm
|
|
163
|
+
* RUN apt-get update && apt-get install -y git ripgrep
|
|
164
|
+
* `,
|
|
165
|
+
* cpu: 2,
|
|
166
|
+
* memory: 4,
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* ### Building a Directory
|
|
171
|
+
* **Example:** A Dockerfile and the files it copies
|
|
172
|
+
* ```typescript
|
|
173
|
+
* export const App = Daytona.Snapshot("App", {
|
|
174
|
+
* context: "./sandbox",
|
|
175
|
+
* build: { args: { NODE_ENV: "production" } },
|
|
176
|
+
* });
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* ### Building with Local Docker
|
|
180
|
+
* **Example:** A build that reads a private npm token
|
|
181
|
+
* ```typescript
|
|
182
|
+
* export const App = Daytona.Snapshot("App", {
|
|
183
|
+
* context: "./sandbox",
|
|
184
|
+
* build: {
|
|
185
|
+
* remote: false,
|
|
186
|
+
* secrets: { npmrc: Redacted.make(process.env.NPM_TOKEN!) },
|
|
187
|
+
* },
|
|
188
|
+
* });
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* ### A Warm Base to Fork From
|
|
192
|
+
* **Example:** Clone and install once, then start every sandbox from it
|
|
193
|
+
* ```typescript
|
|
194
|
+
* export const Warm = Daytona.Snapshot("Warm", {
|
|
195
|
+
* from: Base,
|
|
196
|
+
* run: [
|
|
197
|
+
* "git clone https://github.com/alchemy-run/alchemy /home/daytona/alchemy",
|
|
198
|
+
* "cd /home/daytona/alchemy && pnpm install",
|
|
199
|
+
* ],
|
|
200
|
+
* });
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* ### Looking up an existing snapshot
|
|
204
|
+
* `Snapshot.lookup` references a snapshot Alchemy doesn't manage (created in
|
|
205
|
+
* the Daytona dashboard or by another stack). It is read during plan/deploy,
|
|
206
|
+
* never created, updated or deleted.
|
|
207
|
+
* `buildHash` is empty: the image wasn't built by this stack.
|
|
208
|
+
*
|
|
209
|
+
* **Example:** Start a sandbox from an existing snapshot
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const base = Daytona.Snapshot.lookup({ name: "python-ml" });
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* @resource
|
|
215
|
+
* @product Snapshot
|
|
216
|
+
*/
|
|
217
|
+
export declare const Snapshot: import("alchemy/Resource").ResourceConstructor<Snapshot, Providers> & Effect.Effect<import("alchemy/Resource").ResourceConstructor<Snapshot, never>, never, never> & {
|
|
218
|
+
Self: import("alchemy/Self").Self<Snapshot>;
|
|
219
|
+
Provider: Provider.Provider<Snapshot>;
|
|
220
|
+
Aliases: readonly string[] | undefined;
|
|
221
|
+
ref(id: string, options?: {
|
|
222
|
+
stage?: string;
|
|
223
|
+
stack?: string;
|
|
224
|
+
}): Effect.Effect<Snapshot, never, never>;
|
|
225
|
+
} & {
|
|
226
|
+
lookup(props: {
|
|
227
|
+
name: import("alchemy/Input").Input<string>;
|
|
228
|
+
}): Snapshot;
|
|
229
|
+
} & ((id: string, props: import("./internal/Declared.ts").DeclaredProps<SnapshotProps>) => Effect.Effect<Snapshot, never, Providers>);
|
|
230
|
+
/**
|
|
231
|
+
* What Daytona's builders can build: any Dockerfile, for amd64. Daytona's
|
|
232
|
+
* build request has no field for build arguments, so the plan bakes them
|
|
233
|
+
* into `ARG` defaults, nor for BuildKit secrets, so the plan rejects them.
|
|
234
|
+
*/
|
|
235
|
+
export declare const capabilities: BuildPlan.Capabilities;
|
|
236
|
+
declare const SnapshotSourceInvalid_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 & {
|
|
237
|
+
readonly _tag: "Daytona.SnapshotSourceInvalid";
|
|
238
|
+
} & Readonly<A>;
|
|
239
|
+
/** The snapshot props name more than one of `image`, `dockerfile` and `from`, or none. */
|
|
240
|
+
export declare class SnapshotSourceInvalid extends SnapshotSourceInvalid_base<{
|
|
241
|
+
readonly message: string;
|
|
242
|
+
}> {
|
|
243
|
+
}
|
|
244
|
+
declare const SnapshotContextUnsupported_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 & {
|
|
245
|
+
readonly _tag: "Daytona.SnapshotContextUnsupported";
|
|
246
|
+
} & Readonly<A>;
|
|
247
|
+
/** A runtime build's Dockerfile copies local files, which only a deploy-time `context` can provide. */
|
|
248
|
+
export declare class SnapshotContextUnsupported extends SnapshotContextUnsupported_base<{
|
|
249
|
+
readonly line: string;
|
|
250
|
+
}> {
|
|
251
|
+
get message(): string;
|
|
252
|
+
}
|
|
253
|
+
declare const SnapshotRunFailed_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 & {
|
|
254
|
+
readonly _tag: "Daytona.SnapshotRunFailed";
|
|
255
|
+
} & Readonly<A>;
|
|
256
|
+
/** A `run` command exited non-zero while building a snapshot from a sandbox. */
|
|
257
|
+
export declare class SnapshotRunFailed extends SnapshotRunFailed_base<{
|
|
258
|
+
readonly command: string;
|
|
259
|
+
readonly exitCode: number;
|
|
260
|
+
readonly output: string;
|
|
261
|
+
}> {
|
|
262
|
+
get message(): string;
|
|
263
|
+
}
|
|
264
|
+
declare const SnapshotImageTagInvalid_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 & {
|
|
265
|
+
readonly _tag: "Daytona.SnapshotImageTagInvalid";
|
|
266
|
+
} & Readonly<A>;
|
|
267
|
+
/** The image has no tag, or a moving one Daytona rejects. */
|
|
268
|
+
export declare class SnapshotImageTagInvalid extends SnapshotImageTagInvalid_base<{
|
|
269
|
+
readonly image: string;
|
|
270
|
+
}> {
|
|
271
|
+
get message(): string;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Check Dockerfile content built at runtime (a Worker has no file system,
|
|
275
|
+
* so there is no context to copy from).
|
|
276
|
+
*/
|
|
277
|
+
export declare const checkRuntimeDockerfile: (content: string) => Effect.Effect<undefined, DockerfileParser.DockerfileSyntaxError | SnapshotContextUnsupported | BuildPlan.UnsupportedDockerfile, never>;
|
|
278
|
+
export declare const toSnapshotAttributes: (s: snapshots.SnapshotDto, buildHash: string) => SnapshotAttributes;
|
|
279
|
+
export declare const getSnapshot: (idOrName: string) => Effect.Effect<snapshots.SnapshotDto | undefined, dockerRegistry.DaytonaOpError, dockerRegistry.DaytonaOpContext>;
|
|
280
|
+
/** Wait for a snapshot to become usable, reactivating it when Daytona has deactivated it. */
|
|
281
|
+
export declare const waitForSnapshot: (idOrName: string) => Effect.Effect<snapshots.SnapshotDto, import("./internal/Wait.ts").StateFailed | import("./internal/Wait.ts").StateTimeout | snapshots.GetSnapshotError, dockerRegistry.DaytonaOpContext>;
|
|
282
|
+
/** Delete a snapshot by name (Daytona deletes by id). Deleting a missing one succeeds. */
|
|
283
|
+
export declare const deleteSnapshotByName: (name: string) => Effect.Effect<void, import("./internal/Wait.ts").StateTimeout | dockerRegistry.DaytonaOpError, dockerRegistry.DaytonaOpContext>;
|
|
284
|
+
export declare const deleteSnapshot: (idOrName: string) => Effect.Effect<void, import("./internal/Wait.ts").StateTimeout | dockerRegistry.DaytonaOpError, dockerRegistry.DaytonaOpContext>;
|
|
285
|
+
/**
|
|
286
|
+
* Start a sandbox from `from`, run the commands in it and capture it as a
|
|
287
|
+
* snapshot named `name`. The build sandbox is deleted whatever happens, and
|
|
288
|
+
* deletes itself after an hour if this process dies first.
|
|
289
|
+
*/
|
|
290
|
+
export declare const captureSnapshot: (input: {
|
|
291
|
+
readonly labels: Record<string, string>;
|
|
292
|
+
readonly name: string;
|
|
293
|
+
readonly from: string;
|
|
294
|
+
readonly run: readonly string[];
|
|
295
|
+
readonly note: (message: string) => Effect.Effect<void>;
|
|
296
|
+
}) => Effect.Effect<snapshots.SnapshotDto, import("@distilled.cloud/core/errors").BadGateway | import("@distilled.cloud/core/errors").BadRequest | import("@distilled.cloud/core/config").ConfigError | import("@distilled.cloud/core/errors").Conflict | import("@distilled.cloud/daytona/Errors").DaytonaParseError | import("@distilled.cloud/core/errors").Forbidden | import("@distilled.cloud/core/errors").GatewayTimeout | sandboxes.GpuCreditsRequired | sandboxes.GpuSandboxNotEphemeral | import("effect/http/HttpClientError").HttpClientError | import("@distilled.cloud/core/errors").InternalServerError | import("@distilled.cloud/core/protocol-http").InvalidInput | import("@distilled.cloud/core/errors").Locked | sandboxes.NetworkAccessRestricted | import("@distilled.cloud/core/errors").NotFound | sandboxes.QueueTimeoutNotEnabled | sandboxes.SandboxAlreadyExists | sandboxes.SandboxNotFound | sandboxes.SandboxResourcesFromSnapshot | import("@distilled.cloud/core/sdk-error").SdkError | import("@distilled.cloud/core/errors").ServiceUnavailable | snapshots.SnapshotNotFound | SnapshotRunFailed | import("./internal/Wait.ts").StateFailed | import("./internal/Wait.ts").StateTimeout | import("@distilled.cloud/core/errors").TooManyRequests | import("@distilled.cloud/core/errors").Unauthorized | import("@distilled.cloud/daytona/Errors").UnknownDaytonaError | import("@distilled.cloud/core/errors").UnprocessableEntity | sandboxes.WindowsSandboxesUnavailable, dockerRegistry.DaytonaOpContext>;
|
|
297
|
+
/** A snapshot's source with every input resolved (Dockerfile as content). */
|
|
298
|
+
export interface ResolvedSnapshotSource {
|
|
299
|
+
readonly image?: string | undefined;
|
|
300
|
+
readonly dockerfile?: string | undefined;
|
|
301
|
+
readonly from?: string | undefined;
|
|
302
|
+
readonly run?: readonly string[] | undefined;
|
|
303
|
+
readonly entrypoint?: string[] | undefined;
|
|
304
|
+
readonly cpu?: number | undefined;
|
|
305
|
+
readonly memory?: number | undefined;
|
|
306
|
+
readonly disk?: number | undefined;
|
|
307
|
+
readonly gpu?: number | undefined;
|
|
308
|
+
readonly gpuType?: GpuType[] | undefined;
|
|
309
|
+
readonly regionId?: string | undefined;
|
|
310
|
+
readonly sandboxClass?: snapshots.SandboxClass | undefined;
|
|
311
|
+
/** Uploaded build contexts the Dockerfile copies from (`buildInfo.contextHashes`). */
|
|
312
|
+
readonly contextHashes?: string[] | undefined;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Build a snapshot named `name` and wait until it is active: pull or
|
|
316
|
+
* build on Daytona's builders, or capture it from a `from` sandbox after
|
|
317
|
+
* running `run`. Shared by the resource and the runtime binding.
|
|
318
|
+
*/
|
|
319
|
+
export declare const buildSnapshot: (input: {
|
|
320
|
+
readonly name: string;
|
|
321
|
+
readonly source: ResolvedSnapshotSource;
|
|
322
|
+
readonly labels: Record<string, string>;
|
|
323
|
+
readonly note: (message: string) => Effect.Effect<void>;
|
|
324
|
+
}) => Effect.Effect<snapshots.SnapshotDto, sandboxes.GpuCreditsRequired | sandboxes.GpuSandboxNotEphemeral | sandboxes.NetworkAccessRestricted | sandboxes.QueueTimeoutNotEnabled | sandboxes.SandboxAlreadyExists | sandboxes.SandboxNotFound | sandboxes.SandboxResourcesFromSnapshot | SnapshotImageTagInvalid | snapshots.SnapshotNotFound | SnapshotRunFailed | import("./internal/Wait.ts").StateFailed | import("./internal/Wait.ts").StateTimeout | sandboxes.WindowsSandboxesUnavailable | dockerRegistry.DaytonaOpError, dockerRegistry.DaytonaOpContext>;
|
|
325
|
+
export declare const SnapshotProvider: () => import("effect/Layer").Layer<Provider.Provider<Snapshot>, never, import("alchemy/AlchemyContext").AlchemyContext | import("@alchemy.run/docker/Docker").Docker | import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("alchemy/Stack").Stack | import("alchemy/Stage").Stage | dockerRegistry.DaytonaOpContext>;
|
|
326
|
+
export {};
|
|
327
|
+
//# sourceMappingURL=Snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Snapshot.d.ts","sources":["../src/Snapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,gBAAgB,MAAM,sCAAsC,CAAC;AAOzE,OAAO,KAAK,cAAc,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,SAAS,MAAM,oCAAoC,CAAC;AAGhE,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAOjD,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,uEAAuE;AACvE,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD,4EAA4E;AAC5E,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EA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