@sandbox-kit/daytona 0.1.1 → 0.1.2
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/package.json +4 -3
- package/dist/mappings.d.ts +0 -8
- package/dist/mappings.js +0 -332
- package/dist/provider.checks.gen.d.ts +0 -3
- package/dist/provider.checks.gen.js +0 -91
- package/dist/provider.config.gen.d.ts +0 -5
- package/dist/provider.config.gen.js +0 -36
- package/dist/provider.errors.gen.d.ts +0 -3
- package/dist/provider.errors.gen.js +0 -78
- package/dist/provider.gen.d.ts +0 -14
- package/dist/provider.gen.js +0 -11
- package/dist/provider.mappings.gen.d.ts +0 -12
- package/dist/provider.mappings.gen.js +0 -275
- package/dist/provider_checks.d.ts +0 -3
- package/dist/provider_checks.js +0 -137
- package/dist/provider_config.d.ts +0 -5
- package/dist/provider_config.js +0 -49
- package/dist/provider_mappings.d.ts +0 -15
- package/dist/provider_mappings.js +0 -274
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sandbox-kit/daytona",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "daytona provider for sandbox kit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sandbox-kit",
|
|
@@ -59,14 +59,15 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
|
+
"clean": "rm -rf dist",
|
|
62
63
|
"build": "tsc -p tsconfig.build.json",
|
|
63
|
-
"prepublishOnly": "npm run build",
|
|
64
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
64
65
|
"test": "tsc -p tsconfig.test.json && vitest run"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"@bufbuild/protobuf": "2.16.0",
|
|
68
69
|
"@daytona/sdk": "0.225.0",
|
|
69
|
-
"@sandbox-kit/sandbox": "0.1.
|
|
70
|
+
"@sandbox-kit/sandbox": "0.1.2"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@types/node": "24.10.1",
|
package/dist/mappings.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type Config, type CreateOptions, type SandboxInfo } from "@sandbox-kit/sandbox";
|
|
2
|
-
import { type CreateSandboxFromImageParams, type CreateSandboxFromSnapshotParams, type DaytonaConfig, type Sandbox as DaytonaSandbox } from "@daytona/sdk";
|
|
3
|
-
import { type Environment } from "./provider_config.js";
|
|
4
|
-
export type DaytonaCreateParams = CreateSandboxFromImageParams | CreateSandboxFromSnapshotParams;
|
|
5
|
-
export declare function mapClientConfig(config: Config, environment?: Environment): DaytonaConfig;
|
|
6
|
-
export declare function mapCreateRequest(request: CreateOptions): DaytonaCreateParams;
|
|
7
|
-
export declare function mapSandboxInfo(value: DaytonaSandbox, operation?: string): SandboxInfo;
|
|
8
|
-
//# sourceMappingURL=mappings.d.ts.map
|
package/dist/mappings.js
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
// Provider-specific orchestration around generated portable field mappings.
|
|
2
|
-
import { EgressMode, ErrorKind, IsolationKind, SandboxState, SecretInjection, SnapshotKind, ValueOrigin, WaitCondition, sandboxError } from "@sandbox-kit/sandbox";
|
|
3
|
-
import { metadataObjectFromMap, } from "@sandbox-kit/sandbox";
|
|
4
|
-
import {} from "@daytona/sdk";
|
|
5
|
-
import { mapAllocatedResources as generatedMapAllocatedResources, mapCommonCreateFields as generatedMapCommonCreateFields, mapLifetimePolicies as generatedMapLifetimePolicies, mapResources as generatedMapResources, mapSandboxInfo as generatedMapSandboxInfo, } from "./provider_mappings.js";
|
|
6
|
-
import { validateProviderCreate } from "./provider_checks.js";
|
|
7
|
-
import { mapGeneratedClientConfig } from "./provider_config.js";
|
|
8
|
-
export function mapClientConfig(config, environment) {
|
|
9
|
-
const result = mapGeneratedClientConfig(config, environment);
|
|
10
|
-
if (config.auth?.bearerToken !== undefined &&
|
|
11
|
-
config.scope?.organizationId === undefined)
|
|
12
|
-
configInvalid("scope.organizationId", "organization ID is required with bearer authentication");
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
|
-
export function mapCreateRequest(request) {
|
|
16
|
-
validateProviderCreate(request);
|
|
17
|
-
const base = generatedMapCommonCreateFields(request);
|
|
18
|
-
mapRuntime(request, base);
|
|
19
|
-
mapIsolation(request, base);
|
|
20
|
-
mapSecurity(request, base);
|
|
21
|
-
mapNetwork(request, base);
|
|
22
|
-
mapLifetime(request, base);
|
|
23
|
-
mapProvisioning(request, base);
|
|
24
|
-
mapObservability(request, base);
|
|
25
|
-
if (request.placement !== undefined)
|
|
26
|
-
unsupported("placement", "per-request Daytona placement is unsupported; use Config.region");
|
|
27
|
-
if (request.readiness !== undefined)
|
|
28
|
-
unsupported("readiness", "Daytona readiness probes are not mapped");
|
|
29
|
-
if (request.providerOptions !== undefined)
|
|
30
|
-
unsupported("providerOptions", "Daytona provider options are not mapped");
|
|
31
|
-
const source = request.source;
|
|
32
|
-
if (source?.warmPool !== undefined)
|
|
33
|
-
unsupported("source.warmPool", "explicit warm-pool creation mapping is unavailable");
|
|
34
|
-
if (source?.image !== undefined)
|
|
35
|
-
return {
|
|
36
|
-
...base,
|
|
37
|
-
image: nonblank(source.image.reference, "source.image.reference"),
|
|
38
|
-
...(request.resources === undefined ? {} : { resources: mapResources(request.resources) }),
|
|
39
|
-
};
|
|
40
|
-
if (request.resources !== undefined)
|
|
41
|
-
unsupported("resources", "Daytona resources require an image source");
|
|
42
|
-
if (source?.snapshot !== undefined) {
|
|
43
|
-
const snapshot = source.snapshot;
|
|
44
|
-
if ((snapshot.kind ?? SnapshotKind.Default) !== SnapshotKind.Default)
|
|
45
|
-
unsupported("source.snapshot.kind", "explicit snapshot-kind restore mapping is unavailable");
|
|
46
|
-
if (snapshot.providerKind !== undefined)
|
|
47
|
-
unsupported("source.snapshot.providerKind", "provider snapshot kind is unsupported");
|
|
48
|
-
return { ...base, snapshot: nonblank(snapshot.reference, "source.snapshot.reference") };
|
|
49
|
-
}
|
|
50
|
-
return { ...base };
|
|
51
|
-
}
|
|
52
|
-
function mapRuntime(request, target) {
|
|
53
|
-
const value = request.runtime;
|
|
54
|
-
if (value === undefined)
|
|
55
|
-
return;
|
|
56
|
-
if (value.language !== undefined)
|
|
57
|
-
target.language = value.language;
|
|
58
|
-
if (value.user !== undefined)
|
|
59
|
-
target.user = nonblank(value.user, "runtime.user");
|
|
60
|
-
if (value.version !== undefined ||
|
|
61
|
-
value.workingDirectory !== undefined ||
|
|
62
|
-
value.entrypoint !== undefined ||
|
|
63
|
-
value.pty !== undefined)
|
|
64
|
-
unsupported("runtime", "runtime version, working directory, entrypoint, and PTY are not mapped by Daytona");
|
|
65
|
-
}
|
|
66
|
-
function mapIsolation(request, target) {
|
|
67
|
-
const value = request.isolation;
|
|
68
|
-
if (value === undefined)
|
|
69
|
-
return;
|
|
70
|
-
if ((value.kind ?? IsolationKind.Default) !== IsolationKind.Default || value.providerKind !== undefined)
|
|
71
|
-
unsupported("isolation", "Daytona isolation class comes from the selected source");
|
|
72
|
-
if (value.nestedVirtualization !== undefined)
|
|
73
|
-
target.kvm = value.nestedVirtualization;
|
|
74
|
-
}
|
|
75
|
-
function mapSecurity(request, target) {
|
|
76
|
-
const value = request.security;
|
|
77
|
-
if (value === undefined)
|
|
78
|
-
return;
|
|
79
|
-
if (value.publicAccess !== undefined)
|
|
80
|
-
target.public = value.publicAccess;
|
|
81
|
-
if (value.workloadIdentity !== undefined)
|
|
82
|
-
unsupported("security.workloadIdentity", "Daytona workload identity is not mapped");
|
|
83
|
-
if (value.secrets !== undefined) {
|
|
84
|
-
const secrets = {};
|
|
85
|
-
for (const secret of value.secrets) {
|
|
86
|
-
const variable = secret.environmentVariable === undefined
|
|
87
|
-
? ""
|
|
88
|
-
: nonblank(secret.environmentVariable, "security.secrets.environmentVariable");
|
|
89
|
-
if (variable === "")
|
|
90
|
-
invalid("security.secrets.environmentVariable", "secret environment variable is required");
|
|
91
|
-
const injection = secret.injection ?? SecretInjection.Default;
|
|
92
|
-
if (injection !== SecretInjection.Default && injection !== SecretInjection.EgressPlaceholder)
|
|
93
|
-
unsupported("security.secrets.injection", "Daytona secrets require egress-placeholder injection");
|
|
94
|
-
if (Object.hasOwn(secrets, variable))
|
|
95
|
-
invalid("security.secrets.environmentVariable", "duplicate secret environment variable");
|
|
96
|
-
secrets[variable] = nonblank(secret.reference, "security.secrets.reference");
|
|
97
|
-
}
|
|
98
|
-
target.secrets = secrets;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function mapNetwork(request, target) {
|
|
102
|
-
const value = request.network;
|
|
103
|
-
if (value === undefined)
|
|
104
|
-
return;
|
|
105
|
-
if (value.linkedSandbox !== undefined && request.lifetime?.ephemeral !== true)
|
|
106
|
-
invalid("network.linkedSandbox", "linked sandboxes must be ephemeral");
|
|
107
|
-
const egress = value.egress ?? EgressMode.Default;
|
|
108
|
-
if (egress === EgressMode.BlockAll)
|
|
109
|
-
target.networkBlockAll = true;
|
|
110
|
-
else if (egress !== EgressMode.Default && egress !== EgressMode.AllowAll && egress !== EgressMode.Restricted)
|
|
111
|
-
invalid("network.egress", "unknown egress mode");
|
|
112
|
-
if (value.outboundCidrs !== undefined) {
|
|
113
|
-
if (!value.outboundCidrs.length)
|
|
114
|
-
unsupported("network.outboundCidrs", "empty CIDR allowlist mapping is not verified");
|
|
115
|
-
target.networkAllowList = value.outboundCidrs.join(",");
|
|
116
|
-
}
|
|
117
|
-
if (value.outboundDomains !== undefined) {
|
|
118
|
-
if (!value.outboundDomains.length)
|
|
119
|
-
unsupported("network.outboundDomains", "empty domain allowlist mapping is not verified");
|
|
120
|
-
target.domainAllowList = value.outboundDomains.join(",");
|
|
121
|
-
}
|
|
122
|
-
if (value.linkedSandbox !== undefined)
|
|
123
|
-
target.linkedSandbox = nonblank(value.linkedSandbox, "network.linkedSandbox");
|
|
124
|
-
if (value.outboundProxyUrl !== undefined)
|
|
125
|
-
target.outboundProxyUrl = value.outboundProxyUrl;
|
|
126
|
-
if (value.inboundCidrs !== undefined ||
|
|
127
|
-
value.privateNetwork !== undefined ||
|
|
128
|
-
value.proxyReference !== undefined ||
|
|
129
|
-
value.customDomain !== undefined ||
|
|
130
|
-
value.ports !== undefined)
|
|
131
|
-
unsupported("network", "one or more Daytona network fields are not mapped");
|
|
132
|
-
}
|
|
133
|
-
function mapLifetime(request, target) {
|
|
134
|
-
const value = request.lifetime;
|
|
135
|
-
if (value === undefined)
|
|
136
|
-
return;
|
|
137
|
-
Object.assign(target, generatedMapLifetimePolicies(value));
|
|
138
|
-
if (value.ephemeral !== undefined)
|
|
139
|
-
target.ephemeral = value.ephemeral;
|
|
140
|
-
if (value.maximumLifetime !== undefined)
|
|
141
|
-
target.ttlMinutes = wholeMinutes(value.maximumLifetime, "lifetime.maximumLifetime", true);
|
|
142
|
-
if (value.idleTerminate !== undefined)
|
|
143
|
-
unsupported("lifetime.idleTerminate", "Daytona idle termination is not mapped");
|
|
144
|
-
}
|
|
145
|
-
function mapProvisioning(request, target) {
|
|
146
|
-
const value = request.provisioning;
|
|
147
|
-
if (value === undefined)
|
|
148
|
-
return;
|
|
149
|
-
if (value.queueTimeout !== undefined)
|
|
150
|
-
target.queueTimeout = wholeMinutes(value.queueTimeout, "provisioning.queueTimeout", false);
|
|
151
|
-
const waitFor = value.waitFor ?? WaitCondition.Default;
|
|
152
|
-
if (waitFor !== WaitCondition.Default && waitFor !== WaitCondition.Started)
|
|
153
|
-
unsupported("provisioning.waitFor", "the Daytona TypeScript SDK only returns after startup");
|
|
154
|
-
}
|
|
155
|
-
function mapObservability(request, target) {
|
|
156
|
-
const value = request.observability;
|
|
157
|
-
if (value === undefined)
|
|
158
|
-
return;
|
|
159
|
-
if (value.telemetryEndpoint !== undefined)
|
|
160
|
-
target.otelEndpointOverride = nonblank(value.telemetryEndpoint, "observability.telemetryEndpoint");
|
|
161
|
-
if (value.verbose !== undefined)
|
|
162
|
-
unsupported("observability.verbose", "Daytona verbose creation is not mapped");
|
|
163
|
-
}
|
|
164
|
-
function mapResources(value) {
|
|
165
|
-
if (value.cpuCores !== undefined && value.cpuCores <= 0)
|
|
166
|
-
invalid("resources.cpuCores", "CPU must be positive");
|
|
167
|
-
if (value.cpuLimitCores !== undefined || value.memoryLimitMib !== undefined)
|
|
168
|
-
unsupported("resources", "Daytona resource limits are not mapped");
|
|
169
|
-
return generatedMapResources(value);
|
|
170
|
-
}
|
|
171
|
-
function wholeMinutes(value, field, zeroAllowed) {
|
|
172
|
-
if (!Number.isFinite(value) ||
|
|
173
|
-
value < 0 ||
|
|
174
|
-
value % 60_000 !== 0 ||
|
|
175
|
-
value / 60_000 > 2_147_483_647 ||
|
|
176
|
-
(!zeroAllowed && value === 0))
|
|
177
|
-
invalid(field, "duration must be representable in whole minutes");
|
|
178
|
-
return value / 60_000;
|
|
179
|
-
}
|
|
180
|
-
export function mapSandboxInfo(value, operation = "create") {
|
|
181
|
-
const mapped = generatedMapSandboxInfo(value, operation);
|
|
182
|
-
const origins = { ...(mapped.origins ?? {}) };
|
|
183
|
-
const state = mapState(value.state === undefined ? undefined : String(value.state));
|
|
184
|
-
const result = {
|
|
185
|
-
...mapped,
|
|
186
|
-
id: mapped.id ?? value.id,
|
|
187
|
-
provider: "daytona",
|
|
188
|
-
state,
|
|
189
|
-
labels: mapped.labels ?? {},
|
|
190
|
-
origins,
|
|
191
|
-
};
|
|
192
|
-
const resources = generatedMapAllocatedResources(value, operation);
|
|
193
|
-
if (Object.keys(resources).length > 0) {
|
|
194
|
-
resultMutable(result).resources = resources;
|
|
195
|
-
origins.resources = ValueOrigin.Provider;
|
|
196
|
-
}
|
|
197
|
-
if (value.sandboxClass !== undefined) {
|
|
198
|
-
const native = String(value.sandboxClass);
|
|
199
|
-
resultMutable(result).isolation =
|
|
200
|
-
native === "container"
|
|
201
|
-
? { kind: IsolationKind.Container }
|
|
202
|
-
: native === "linux-vm"
|
|
203
|
-
? { kind: IsolationKind.LinuxVm }
|
|
204
|
-
: { kind: IsolationKind.ProviderSpecific, providerKind: native };
|
|
205
|
-
origins.isolation = ValueOrigin.Provider;
|
|
206
|
-
}
|
|
207
|
-
if (state === SandboxState.Deleted) {
|
|
208
|
-
resultMutable(result).terminal = true;
|
|
209
|
-
origins.terminal = ValueOrigin.Provider;
|
|
210
|
-
}
|
|
211
|
-
const metadata = {};
|
|
212
|
-
if (value.gpu > 0)
|
|
213
|
-
metadata.gpu_count = value.gpu;
|
|
214
|
-
if (value.gpuType !== undefined)
|
|
215
|
-
metadata.gpu_type = String(value.gpuType);
|
|
216
|
-
if (value.desiredState !== undefined)
|
|
217
|
-
metadata.desired_state = String(value.desiredState);
|
|
218
|
-
if (value.errorReason !== undefined)
|
|
219
|
-
metadata.error_reason = value.errorReason;
|
|
220
|
-
if (value.recoverable !== undefined)
|
|
221
|
-
metadata.recoverable = value.recoverable;
|
|
222
|
-
if (value.spot === true)
|
|
223
|
-
metadata.spot = true;
|
|
224
|
-
for (const [key, entry] of [
|
|
225
|
-
["spot_evicted_at", value.spotEvictedAt],
|
|
226
|
-
["backup_state", value.backupState],
|
|
227
|
-
["backup_created_at", value.backupCreatedAt],
|
|
228
|
-
["updated_at", value.updatedAt],
|
|
229
|
-
["last_activity_at", value.lastActivityAt],
|
|
230
|
-
["auto_destroy_at", value.autoDestroyAt],
|
|
231
|
-
["queue_timed_out_at", value.queueTimedOutAt],
|
|
232
|
-
["snapshot", value.snapshot],
|
|
233
|
-
["warm_pool_id", value.warmPoolId],
|
|
234
|
-
])
|
|
235
|
-
if (entry !== undefined)
|
|
236
|
-
metadata[key] = String(entry);
|
|
237
|
-
for (const [key, entry] of [
|
|
238
|
-
["auto_stop_interval_minutes", value.autoStopInterval],
|
|
239
|
-
["auto_pause_interval_minutes", value.autoPauseInterval],
|
|
240
|
-
["auto_archive_interval_minutes", value.autoArchiveInterval],
|
|
241
|
-
["auto_delete_interval_minutes", value.autoDeleteInterval],
|
|
242
|
-
])
|
|
243
|
-
if (entry !== undefined)
|
|
244
|
-
metadata[key] = entry;
|
|
245
|
-
if (Object.keys(metadata).length > 0) {
|
|
246
|
-
const providerMetadata = metadataObjectFromMap(metadata);
|
|
247
|
-
if (providerMetadata !== undefined) {
|
|
248
|
-
resultMutable(result).providerMetadata = providerMetadata;
|
|
249
|
-
origins.provider_metadata = ValueOrigin.Provider;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (value.createdAt !== undefined) {
|
|
253
|
-
const date = new Date(value.createdAt);
|
|
254
|
-
if (!Number.isNaN(date.valueOf())) {
|
|
255
|
-
resultMutable(result).createdAt = date;
|
|
256
|
-
origins.created_at = ValueOrigin.Provider;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return result;
|
|
260
|
-
}
|
|
261
|
-
function resultMutable(value) {
|
|
262
|
-
return value;
|
|
263
|
-
}
|
|
264
|
-
function mapState(value) {
|
|
265
|
-
switch (value) {
|
|
266
|
-
case "creating":
|
|
267
|
-
case "restoring":
|
|
268
|
-
case "pending_build":
|
|
269
|
-
case "building_snapshot":
|
|
270
|
-
case "pulling_snapshot":
|
|
271
|
-
case "forking":
|
|
272
|
-
return SandboxState.Queued;
|
|
273
|
-
case "starting":
|
|
274
|
-
case "resuming":
|
|
275
|
-
return SandboxState.Starting;
|
|
276
|
-
case "started":
|
|
277
|
-
return SandboxState.Running;
|
|
278
|
-
case "stopping":
|
|
279
|
-
return SandboxState.Stopping;
|
|
280
|
-
case "stopped":
|
|
281
|
-
return SandboxState.Stopped;
|
|
282
|
-
case "pausing":
|
|
283
|
-
return SandboxState.Pausing;
|
|
284
|
-
case "paused":
|
|
285
|
-
return SandboxState.Paused;
|
|
286
|
-
case "archiving":
|
|
287
|
-
return SandboxState.Archiving;
|
|
288
|
-
case "archived":
|
|
289
|
-
return SandboxState.Archived;
|
|
290
|
-
case "destroying":
|
|
291
|
-
return SandboxState.Deleting;
|
|
292
|
-
case "destroyed":
|
|
293
|
-
return SandboxState.Deleted;
|
|
294
|
-
case "error":
|
|
295
|
-
case "build_failed":
|
|
296
|
-
return SandboxState.Error;
|
|
297
|
-
default:
|
|
298
|
-
return SandboxState.Unknown;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function nonblank(value, field) {
|
|
302
|
-
if (value.trim() === "")
|
|
303
|
-
invalid(field, "value must not be blank");
|
|
304
|
-
return value;
|
|
305
|
-
}
|
|
306
|
-
function invalid(field, message) {
|
|
307
|
-
throw sandboxError({
|
|
308
|
-
kind: ErrorKind.InvalidArgument,
|
|
309
|
-
provider: "daytona",
|
|
310
|
-
operation: "create",
|
|
311
|
-
field,
|
|
312
|
-
message: "sandbox-kit daytona: " + message,
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
function unsupported(field, message) {
|
|
316
|
-
throw sandboxError({
|
|
317
|
-
kind: ErrorKind.Unsupported,
|
|
318
|
-
provider: "daytona",
|
|
319
|
-
operation: "create",
|
|
320
|
-
field,
|
|
321
|
-
message: "sandbox-kit daytona: " + message,
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
function configInvalid(field, message) {
|
|
325
|
-
throw sandboxError({
|
|
326
|
-
kind: ErrorKind.InvalidArgument,
|
|
327
|
-
provider: "daytona",
|
|
328
|
-
operation: "initialize",
|
|
329
|
-
field,
|
|
330
|
-
message: "sandbox-kit daytona: " + message,
|
|
331
|
-
});
|
|
332
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// Code generated by protoc-gen-kit-typescript. DO NOT EDIT.
|
|
2
|
-
// source: kit/providers/daytona/v1/provider.proto + specs/providers/daytona.yaml
|
|
3
|
-
import { durationMs } from "@bufbuild/protobuf/wkt";
|
|
4
|
-
import { ErrorKind, PolicyMode, sandboxError } from "@sandbox-kit/sandbox";
|
|
5
|
-
export function validateProviderCreate(request) {
|
|
6
|
-
const value0_0 = request.runtime;
|
|
7
|
-
if (value0_0 !== undefined) {
|
|
8
|
-
const value0 = value0_0.language;
|
|
9
|
-
if (value0 !== undefined) {
|
|
10
|
-
if (value0 !== "python" && value0 !== "javascript" && value0 !== "typescript")
|
|
11
|
-
fail(ErrorKind.Unsupported, "runtime.language", "runtime.language is outside supported values");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const value1_0 = request.network;
|
|
15
|
-
if (value1_0 !== undefined) {
|
|
16
|
-
const value1 = value1_0.outboundProxyUrl;
|
|
17
|
-
if (value1 !== undefined) {
|
|
18
|
-
if (!validHttpUrl(value1))
|
|
19
|
-
fail(ErrorKind.InvalidArgument, "network.outboundProxyUrl", "network.outbound_proxy_url is outside supported values");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const value2_0 = request.network;
|
|
23
|
-
if (value2_0 !== undefined) {
|
|
24
|
-
const value2_1 = value2_0.outboundCidrs;
|
|
25
|
-
if (value2_1 !== undefined) {
|
|
26
|
-
for (const value2 of value2_1.entries ?? []) {
|
|
27
|
-
if (!validCidr(value2))
|
|
28
|
-
fail(ErrorKind.InvalidArgument, "network.outboundCidrs.entries", "network.outbound_cidrs.entries is outside supported values");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const value3_0 = request.network;
|
|
33
|
-
if (value3_0 !== undefined) {
|
|
34
|
-
const value3_1 = value3_0.outboundDomains;
|
|
35
|
-
if (value3_1 !== undefined) {
|
|
36
|
-
for (const value3 of value3_1.entries ?? []) {
|
|
37
|
-
if (!validDomain(value3))
|
|
38
|
-
fail(ErrorKind.InvalidArgument, "network.outboundDomains.entries", "network.outbound_domains.entries is outside supported values");
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const value4_0 = request.security;
|
|
43
|
-
if (value4_0 !== undefined) {
|
|
44
|
-
for (const item4_1 of value4_0.secrets ?? []) {
|
|
45
|
-
const value4 = item4_1.environmentVariable;
|
|
46
|
-
if (value4 !== undefined) {
|
|
47
|
-
if (!validEnvName(value4))
|
|
48
|
-
fail(ErrorKind.InvalidArgument, "security.secrets.environmentVariable", "security.secrets.environment_variable is outside supported values");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (delayed(request.lifetime?.idleStop) && delayed(request.lifetime?.idlePause))
|
|
53
|
-
invalid("lifetime", "incompatible lifetime policies");
|
|
54
|
-
if (delayed(request.lifetime?.idlePause) && request.lifetime?.ephemeral === true)
|
|
55
|
-
invalid("lifetime", "incompatible lifetime policies");
|
|
56
|
-
if (delayed(request.lifetime?.idlePause) && immediate(request.lifetime?.stoppedDelete))
|
|
57
|
-
invalid("lifetime", "incompatible lifetime policies");
|
|
58
|
-
if (delayed(request.lifetime?.stoppedDelete) && request.lifetime?.ephemeral === true)
|
|
59
|
-
invalid("lifetime", "incompatible lifetime policies");
|
|
60
|
-
if (delayed(request.lifetime?.stoppedArchive) && request.lifetime?.ephemeral === true)
|
|
61
|
-
invalid("lifetime", "incompatible lifetime policies");
|
|
62
|
-
}
|
|
63
|
-
function delayed(policy) { return (policy?.mode ?? PolicyMode.Default) === PolicyMode.After && policy?.after !== undefined && durationMs(policy.after) > 0; }
|
|
64
|
-
function immediate(policy) { return (policy?.mode ?? PolicyMode.Default) === PolicyMode.After && policy?.after !== undefined && durationMs(policy.after) === 0; }
|
|
65
|
-
function validEnvName(value) { return /^[A-Za-z_][A-Za-z0-9_]*$/.test(value); }
|
|
66
|
-
function validAbsolutePath(value) { return value.startsWith("/"); }
|
|
67
|
-
function validHttpUrl(value) { try {
|
|
68
|
-
const parsed = new URL(value);
|
|
69
|
-
return parsed.hostname !== "" && (parsed.protocol === "http:" || parsed.protocol === "https:");
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
return false;
|
|
73
|
-
} }
|
|
74
|
-
function validDomain(value) { const domain = value.startsWith("*.") ? value.slice(2) : value; return domain.length <= 253 && /^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.?$/i.test(domain); }
|
|
75
|
-
function validCidr(value) { const separator = value.lastIndexOf("/"); if (separator <= 0)
|
|
76
|
-
return false; const address = value.slice(0, separator); const prefix = Number(value.slice(separator + 1)); if (!Number.isInteger(prefix))
|
|
77
|
-
return false; return address.includes(":") ? prefix >= 0 && prefix <= 128 && validIpv6(address) : prefix >= 0 && prefix <= 32 && validIpv4(address); }
|
|
78
|
-
function validIpv4(value) { const parts = value.split("."); return parts.length === 4 && parts.every((part) => /^(0|[1-9][0-9]{0,2})$/.test(part) && Number(part) <= 255); }
|
|
79
|
-
function validIpv6(value) { if ((value.match(/::/g)?.length ?? 0) > 1)
|
|
80
|
-
return false; const halves = value.split("::"); if (halves.length > 2)
|
|
81
|
-
return false; const count = (part) => { if (part === "")
|
|
82
|
-
return 0; const groups = part.split(":"); let total = 0; for (const group of groups) {
|
|
83
|
-
if (/^[0-9a-f]{1,4}$/i.test(group))
|
|
84
|
-
total++;
|
|
85
|
-
else if (validIpv4(group))
|
|
86
|
-
total += 2;
|
|
87
|
-
else
|
|
88
|
-
return undefined;
|
|
89
|
-
} return total; }; const left = count(halves[0] ?? ""); const right = count(halves[1] ?? ""); return left !== undefined && right !== undefined && (halves.length === 2 ? left + right < 8 : left === 8); }
|
|
90
|
-
function invalid(field, message) { fail(ErrorKind.InvalidArgument, field, message); }
|
|
91
|
-
function fail(kind, field, message) { throw sandboxError({ kind, provider: "daytona", operation: "create", field, message: "sandbox-kit daytona: " + message }); }
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { DaytonaConfig as NativeClientConfig } from "@daytona/sdk";
|
|
2
|
-
import { type ConfigWire } from "@sandbox-kit/sandbox";
|
|
3
|
-
export type Environment = Readonly<Record<string, string | undefined>>;
|
|
4
|
-
export declare function mapGeneratedClientConfig(config: ConfigWire, environment?: Environment): NativeClientConfig;
|
|
5
|
-
//# sourceMappingURL=provider.config.gen.d.ts.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// Code generated by protoc-gen-kit-typescript. DO NOT EDIT.
|
|
2
|
-
// source: kit/providers/daytona/v1/provider.proto + specs/providers/daytona.yaml
|
|
3
|
-
import { ErrorKind, sandboxError, validateConfig } from "@sandbox-kit/sandbox";
|
|
4
|
-
import { mapAPIKeyCredentials, mapBearerAuth, mapClientSettings, mapScope } from "./provider.mappings.gen.js";
|
|
5
|
-
export function mapGeneratedClientConfig(config, environment = environmentVariables()) {
|
|
6
|
-
let source = config;
|
|
7
|
-
if (source.endpoint === undefined)
|
|
8
|
-
source = { ...source, endpoint: environment.DAYTONA_API_URL ?? environment.DAYTONA_SERVER_URL ?? "https://app.daytona.io/api" };
|
|
9
|
-
validateConfig(source, "daytona", "initialize");
|
|
10
|
-
const target = mapClientSettings(source, "initialize");
|
|
11
|
-
if (source.scope !== undefined) {
|
|
12
|
-
const mapped = mapScope(source.scope, "initialize");
|
|
13
|
-
Object.assign(target, mapped);
|
|
14
|
-
if (source.scope.appName !== undefined)
|
|
15
|
-
unsupported("scope.appName", "unsupported client configuration field");
|
|
16
|
-
if (source.scope.environment !== undefined)
|
|
17
|
-
unsupported("scope.environment", "unsupported client configuration field");
|
|
18
|
-
if (source.scope.projectId !== undefined)
|
|
19
|
-
unsupported("scope.projectId", "unsupported client configuration field");
|
|
20
|
-
}
|
|
21
|
-
const credentials = source.auth?.credentials;
|
|
22
|
-
if (credentials?.case === "apiKey") {
|
|
23
|
-
const mapped = mapAPIKeyCredentials(credentials.value, "initialize");
|
|
24
|
-
Object.assign(target, mapped);
|
|
25
|
-
}
|
|
26
|
-
else if (credentials?.case === "bearerToken") {
|
|
27
|
-
const mapped = mapBearerAuth(credentials.value, "initialize");
|
|
28
|
-
Object.assign(target, mapped);
|
|
29
|
-
}
|
|
30
|
-
else if (credentials?.case !== undefined) {
|
|
31
|
-
unsupported("auth", "unsupported authentication mode");
|
|
32
|
-
}
|
|
33
|
-
return target;
|
|
34
|
-
}
|
|
35
|
-
function environmentVariables() { return globalThis.process?.env ?? {}; }
|
|
36
|
-
function unsupported(field, message) { throw sandboxError({ kind: ErrorKind.Unsupported, provider: "daytona", operation: "initialize", field, message: "sandbox-kit daytona: " + message }); }
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// Code generated by protoc-gen-kit-typescript. DO NOT EDIT.
|
|
2
|
-
// source: kit/providers/daytona/v1/provider.proto + specs/providers/daytona.yaml
|
|
3
|
-
import { DaytonaError } from "@daytona/sdk";
|
|
4
|
-
import { ErrorKind, SandboxError, sandboxError } from "@sandbox-kit/sandbox";
|
|
5
|
-
export function mapDaytonaError(error, operation) {
|
|
6
|
-
if (error instanceof SandboxError)
|
|
7
|
-
return error;
|
|
8
|
-
if (error instanceof DOMException && error.name === "AbortError")
|
|
9
|
-
return create(ErrorKind.Canceled, error, operation);
|
|
10
|
-
if (error instanceof DOMException && error.name === "TimeoutError")
|
|
11
|
-
return create(ErrorKind.Timeout, error, operation);
|
|
12
|
-
let kind = ErrorKind.Unknown;
|
|
13
|
-
let statusCode;
|
|
14
|
-
let providerCode;
|
|
15
|
-
let providerSource;
|
|
16
|
-
if (error instanceof DaytonaError) {
|
|
17
|
-
statusCode = error.statusCode;
|
|
18
|
-
providerCode = error.code;
|
|
19
|
-
providerSource = error.source;
|
|
20
|
-
if (kind === ErrorKind.Unknown)
|
|
21
|
-
switch (error.code) {
|
|
22
|
-
case "SANDBOX_SPOT_EVICTED":
|
|
23
|
-
kind = ErrorKind.Unavailable;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
if (kind === ErrorKind.Unknown)
|
|
27
|
-
switch (error.statusCode) {
|
|
28
|
-
case 400:
|
|
29
|
-
kind = ErrorKind.InvalidArgument;
|
|
30
|
-
break;
|
|
31
|
-
case 401:
|
|
32
|
-
kind = ErrorKind.Authentication;
|
|
33
|
-
break;
|
|
34
|
-
case 403:
|
|
35
|
-
kind = ErrorKind.PermissionDenied;
|
|
36
|
-
break;
|
|
37
|
-
case 404:
|
|
38
|
-
kind = ErrorKind.NotFound;
|
|
39
|
-
break;
|
|
40
|
-
case 408:
|
|
41
|
-
kind = ErrorKind.Timeout;
|
|
42
|
-
break;
|
|
43
|
-
case 409:
|
|
44
|
-
kind = ErrorKind.Conflict;
|
|
45
|
-
break;
|
|
46
|
-
case 410:
|
|
47
|
-
kind = ErrorKind.NotFound;
|
|
48
|
-
break;
|
|
49
|
-
case 412:
|
|
50
|
-
kind = ErrorKind.FailedPrecondition;
|
|
51
|
-
break;
|
|
52
|
-
case 422:
|
|
53
|
-
kind = ErrorKind.InvalidArgument;
|
|
54
|
-
break;
|
|
55
|
-
case 429:
|
|
56
|
-
kind = ErrorKind.RateLimited;
|
|
57
|
-
break;
|
|
58
|
-
case 500:
|
|
59
|
-
kind = ErrorKind.Internal;
|
|
60
|
-
break;
|
|
61
|
-
case 502:
|
|
62
|
-
kind = ErrorKind.Unavailable;
|
|
63
|
-
break;
|
|
64
|
-
case 503:
|
|
65
|
-
kind = ErrorKind.Unavailable;
|
|
66
|
-
break;
|
|
67
|
-
case 504:
|
|
68
|
-
kind = ErrorKind.Timeout;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
if (kind === ErrorKind.Unknown && error.statusCode === 0 && !error.code)
|
|
72
|
-
kind = ErrorKind.Unavailable;
|
|
73
|
-
}
|
|
74
|
-
return create(kind, error, operation, statusCode, providerCode, providerSource);
|
|
75
|
-
}
|
|
76
|
-
function create(kind, error, operation, statusCode, providerCode, providerSource) {
|
|
77
|
-
return sandboxError({ kind, provider: "daytona", operation, field: "", message: error instanceof Error ? error.message : "sandbox-kit daytona: provider operation failed", ...(statusCode === undefined ? {} : { statusCode }), ...(providerCode === undefined ? {} : { providerCode }), ...(providerSource === undefined ? {} : { providerSource }) }, error);
|
|
78
|
-
}
|
package/dist/provider.gen.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Backend, ConfigWire, CreateOptionsWire, CreateResult, OperationOptions, Provider } from "@sandbox-kit/sandbox";
|
|
2
|
-
export declare const providerName: "daytona";
|
|
3
|
-
/** @internal Shared generated provider identity wiring. */
|
|
4
|
-
export declare abstract class ProviderBase implements Provider {
|
|
5
|
-
readonly name: "daytona";
|
|
6
|
-
abstract initialize(config: ConfigWire): Backend;
|
|
7
|
-
}
|
|
8
|
-
/** @internal Shared generated backend identity and required operation surface. */
|
|
9
|
-
export declare abstract class BackendBase implements Backend {
|
|
10
|
-
readonly name: "daytona";
|
|
11
|
-
abstract create(request: CreateOptionsWire, options: OperationOptions): Promise<CreateResult>;
|
|
12
|
-
abstract close(options: OperationOptions): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=provider.gen.d.ts.map
|
package/dist/provider.gen.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Code generated by protoc-gen-kit-typescript. DO NOT EDIT.
|
|
2
|
-
// source: kit/providers/daytona/v1/provider.proto + specs/providers/daytona.yaml
|
|
3
|
-
export const providerName = "daytona";
|
|
4
|
-
/** @internal Shared generated provider identity wiring. */
|
|
5
|
-
export class ProviderBase {
|
|
6
|
-
name = providerName;
|
|
7
|
-
}
|
|
8
|
-
/** @internal Shared generated backend identity and required operation surface. */
|
|
9
|
-
export class BackendBase {
|
|
10
|
-
name = providerName;
|
|
11
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type APIKeyCredentials, type BearerTokenCredentials, type ConfigWire, type CreateOptionsWire, type LifetimePolicy, type Resources, type SandboxInfo, type Scope } from "@sandbox-kit/sandbox";
|
|
2
|
-
import type { CreateSandboxBaseParams as NativeCreateSandboxBaseParams, DaytonaConfig as NativeDaytonaConfig, Resources as NativeResources, Sandbox as NativeSandbox } from "@daytona/sdk";
|
|
3
|
-
export declare function mapLifetimePolicies(source: LifetimePolicy | undefined, operation?: string): NativeCreateSandboxBaseParams;
|
|
4
|
-
export declare function mapCommonCreateFields(source: CreateOptionsWire | undefined, operation?: string): NativeCreateSandboxBaseParams;
|
|
5
|
-
export declare function mapResources(source: Resources | undefined, operation?: string): NativeResources;
|
|
6
|
-
export declare function mapSandboxInfo(source: NativeSandbox | undefined, operation?: string): Partial<SandboxInfo>;
|
|
7
|
-
export declare function mapAllocatedResources(source: NativeSandbox | undefined, operation?: string): Partial<Resources>;
|
|
8
|
-
export declare function mapClientSettings(source: ConfigWire | undefined, operation?: string): NativeDaytonaConfig;
|
|
9
|
-
export declare function mapAPIKeyCredentials(source: APIKeyCredentials | undefined, operation?: string): NativeDaytonaConfig;
|
|
10
|
-
export declare function mapBearerAuth(source: BearerTokenCredentials | undefined, operation?: string): NativeDaytonaConfig;
|
|
11
|
-
export declare function mapScope(source: Scope | undefined, operation?: string): NativeDaytonaConfig;
|
|
12
|
-
//# sourceMappingURL=provider.mappings.gen.d.ts.map
|