freestyle-sandboxes 0.1.41 → 0.1.42
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/index.cjs +34 -3
- package/index.d.cts +20 -0
- package/index.d.mts +20 -0
- package/index.mjs +34 -3
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -5648,6 +5648,7 @@ function composeCreateVmOptions(arr) {
|
|
|
5648
5648
|
result.activityThresholdBytes = options.activityThresholdBytes;
|
|
5649
5649
|
if (options.discriminator !== void 0)
|
|
5650
5650
|
result.discriminator = options.discriminator;
|
|
5651
|
+
if (options.skipCache !== void 0) result.skipCache = options.skipCache;
|
|
5651
5652
|
if (options.persistence !== void 0)
|
|
5652
5653
|
result.persistence = options.persistence;
|
|
5653
5654
|
if (options.ports !== void 0) {
|
|
@@ -5795,6 +5796,7 @@ function composeCreateVmOptions(arr) {
|
|
|
5795
5796
|
aptDeps: newTemplate.aptDeps ?? baseTemplate.aptDeps,
|
|
5796
5797
|
vcpuCount: newTemplate.vcpuCount !== void 0 ? newTemplate.vcpuCount : baseTemplate.vcpuCount,
|
|
5797
5798
|
discriminator: newTemplate.discriminator ?? baseTemplate.discriminator,
|
|
5799
|
+
skipCache: newTemplate.skipCache ?? baseTemplate.skipCache,
|
|
5798
5800
|
workdir: newTemplate.workdir !== void 0 ? newTemplate.workdir : baseTemplate.workdir,
|
|
5799
5801
|
idleTimeoutSeconds: newTemplate.idleTimeoutSeconds !== void 0 ? newTemplate.idleTimeoutSeconds : baseTemplate.idleTimeoutSeconds,
|
|
5800
5802
|
waitForReadySignal: newTemplate.waitForReadySignal !== void 0 ? newTemplate.waitForReadySignal : baseTemplate.waitForReadySignal,
|
|
@@ -6545,7 +6547,10 @@ class VmSpec {
|
|
|
6545
6547
|
}
|
|
6546
6548
|
ensureSnapshot() {
|
|
6547
6549
|
if (!isVmSpecLike$1(this.raw.snapshot)) {
|
|
6548
|
-
this.raw.snapshot =
|
|
6550
|
+
this.raw.snapshot = new VmSpec({
|
|
6551
|
+
discriminator: this.raw.discriminator,
|
|
6552
|
+
skipCache: this.raw.skipCache
|
|
6553
|
+
});
|
|
6549
6554
|
}
|
|
6550
6555
|
return this.raw.snapshot;
|
|
6551
6556
|
}
|
|
@@ -6574,6 +6579,9 @@ class VmSpec {
|
|
|
6574
6579
|
discriminator(value) {
|
|
6575
6580
|
return this.mergeRaw({ discriminator: value });
|
|
6576
6581
|
}
|
|
6582
|
+
skipCache() {
|
|
6583
|
+
return this.mergeRaw({ skipCache: true });
|
|
6584
|
+
}
|
|
6577
6585
|
workdir(path) {
|
|
6578
6586
|
return this.mergeRaw({ workdir: path });
|
|
6579
6587
|
}
|
|
@@ -6800,7 +6808,10 @@ async function processOuterSpecBuilders(spec) {
|
|
|
6800
6808
|
snapshotSpec = spec.raw.snapshot;
|
|
6801
6809
|
} else {
|
|
6802
6810
|
const inheritedDiscriminator = spec.getBuilderDiscriminator(key) ?? spec.raw.discriminator;
|
|
6803
|
-
snapshotSpec =
|
|
6811
|
+
snapshotSpec = new VmSpec({
|
|
6812
|
+
discriminator: inheritedDiscriminator,
|
|
6813
|
+
skipCache: spec.raw.skipCache
|
|
6814
|
+
});
|
|
6804
6815
|
spec.raw.snapshot = snapshotSpec;
|
|
6805
6816
|
}
|
|
6806
6817
|
spec.raw.snapshot = await builder.configureSnapshotSpec(snapshotSpec);
|
|
@@ -6827,7 +6838,10 @@ async function processSpecTree(spec) {
|
|
|
6827
6838
|
snapshotSpec = spec.raw.snapshot;
|
|
6828
6839
|
} else {
|
|
6829
6840
|
const inheritedDiscriminator = spec.getBuilderDiscriminator(key) ?? spec.raw.discriminator;
|
|
6830
|
-
snapshotSpec =
|
|
6841
|
+
snapshotSpec = new VmSpec({
|
|
6842
|
+
discriminator: inheritedDiscriminator,
|
|
6843
|
+
skipCache: spec.raw.skipCache
|
|
6844
|
+
});
|
|
6831
6845
|
spec.raw.snapshot = snapshotSpec;
|
|
6832
6846
|
}
|
|
6833
6847
|
spec.raw.snapshot = await builder.configureSnapshotSpec(snapshotSpec);
|
|
@@ -6995,6 +7009,12 @@ class VmsNamespace {
|
|
|
6995
7009
|
template: _template,
|
|
6996
7010
|
...requestConfig
|
|
6997
7011
|
} = config;
|
|
7012
|
+
let slowPathTimeout;
|
|
7013
|
+
slowPathTimeout = setTimeout(() => {
|
|
7014
|
+
console.log(
|
|
7015
|
+
"VM creation is taking longer than expected. This usually happens when there's a cache miss on your vm's base snapshot. Subsequent vm creations with this configuration will likely be much faster."
|
|
7016
|
+
);
|
|
7017
|
+
}, 5e3);
|
|
6998
7018
|
const response = await this.freestyle._apiClient.post("/v1/vms", {
|
|
6999
7019
|
body: {
|
|
7000
7020
|
...requestConfig,
|
|
@@ -7005,9 +7025,11 @@ class VmsNamespace {
|
|
|
7005
7025
|
git: normalizeGitOptions(config.git)
|
|
7006
7026
|
}
|
|
7007
7027
|
}).catch((e) => {
|
|
7028
|
+
if (slowPathTimeout) clearTimeout(slowPathTimeout);
|
|
7008
7029
|
enhanceError(e);
|
|
7009
7030
|
throw e;
|
|
7010
7031
|
});
|
|
7032
|
+
if (slowPathTimeout) clearTimeout(slowPathTimeout);
|
|
7011
7033
|
const vmId = response.id;
|
|
7012
7034
|
const vm = new Vm({ vmId, freestyle: this.freestyle });
|
|
7013
7035
|
for (const key in builders) {
|
|
@@ -7211,6 +7233,7 @@ class VmSnapshotsNamespace {
|
|
|
7211
7233
|
"snapshots.ensure requires a template or spec to build a snapshot"
|
|
7212
7234
|
);
|
|
7213
7235
|
}
|
|
7236
|
+
const startTime = Date.now();
|
|
7214
7237
|
return this.apiClient.post("/v1/vms/snapshots", {
|
|
7215
7238
|
body: {
|
|
7216
7239
|
...requestOptions,
|
|
@@ -7218,6 +7241,14 @@ class VmSnapshotsNamespace {
|
|
|
7218
7241
|
isVmTemplateLike$1(requestOptions.template) ? requestOptions.template.raw : requestOptions.template
|
|
7219
7242
|
)
|
|
7220
7243
|
}
|
|
7244
|
+
}).then((response) => {
|
|
7245
|
+
const elapsedTime = Date.now() - startTime;
|
|
7246
|
+
if (elapsedTime > 5e3) {
|
|
7247
|
+
console.log(
|
|
7248
|
+
"Snapshot creation took longer than expected (> 5 seconds). This is slower because caches weren't available, but subsequent operations will be much faster."
|
|
7249
|
+
);
|
|
7250
|
+
}
|
|
7251
|
+
return response;
|
|
7221
7252
|
}).catch((e) => {
|
|
7222
7253
|
enhanceError(e);
|
|
7223
7254
|
throw e;
|
package/index.d.cts
CHANGED
|
@@ -4467,6 +4467,12 @@ interface PostV1VmsRequestBody {
|
|
|
4467
4467
|
* These packages will be installed using `apt-get install` on VM startup.
|
|
4468
4468
|
*/
|
|
4469
4469
|
aptDeps?: string[] | null;
|
|
4470
|
+
/**
|
|
4471
|
+
* When true, bypasses the snapshot cache and always creates a new snapshot.
|
|
4472
|
+
* The new snapshot still stores the template hash, so it becomes the updated
|
|
4473
|
+
* cache entry for future requests that do not set skipCache.
|
|
4474
|
+
*/
|
|
4475
|
+
skipCache?: boolean | null;
|
|
4470
4476
|
};
|
|
4471
4477
|
/**
|
|
4472
4478
|
* @deprecated
|
|
@@ -4883,6 +4889,12 @@ interface PostV1VmsSnapshotsRequestBody {
|
|
|
4883
4889
|
* These packages will be installed using `apt-get install` on VM startup.
|
|
4884
4890
|
*/
|
|
4885
4891
|
aptDeps?: string[] | null;
|
|
4892
|
+
/**
|
|
4893
|
+
* When true, bypasses the snapshot cache and always creates a new snapshot.
|
|
4894
|
+
* The new snapshot still stores the template hash, so it becomes the updated
|
|
4895
|
+
* cache entry for future requests that do not set skipCache.
|
|
4896
|
+
*/
|
|
4897
|
+
skipCache?: boolean | null;
|
|
4886
4898
|
};
|
|
4887
4899
|
persistence?: null | ({
|
|
4888
4900
|
priority?: number | null;
|
|
@@ -11909,6 +11921,12 @@ interface CreateSnapshotRequest {
|
|
|
11909
11921
|
* These packages will be installed using `apt-get install` on VM startup.
|
|
11910
11922
|
*/
|
|
11911
11923
|
aptDeps?: string[] | null;
|
|
11924
|
+
/**
|
|
11925
|
+
* When true, bypasses the snapshot cache and always creates a new snapshot.
|
|
11926
|
+
* The new snapshot still stores the template hash, so it becomes the updated
|
|
11927
|
+
* cache entry for future requests that do not set skipCache.
|
|
11928
|
+
*/
|
|
11929
|
+
skipCache?: boolean | null;
|
|
11912
11930
|
};
|
|
11913
11931
|
persistence?: null | ({
|
|
11914
11932
|
priority?: number | null;
|
|
@@ -12496,6 +12514,7 @@ declare class VmSpec<T extends Record<string, VmWithLike> = {}> {
|
|
|
12496
12514
|
readySignalTimeoutSeconds(value: number): this;
|
|
12497
12515
|
waitForReadySignal(value: boolean): this;
|
|
12498
12516
|
discriminator(value: string): this;
|
|
12517
|
+
skipCache(): this;
|
|
12499
12518
|
workdir(path: string): this;
|
|
12500
12519
|
aptDeps(...deps: string[]): this;
|
|
12501
12520
|
users(users: NonNullable<CreateVmOptions["users"]>): this;
|
|
@@ -12595,6 +12614,7 @@ type CreateVmOptions = Omit<PostV1VmsRequestBody, "template" | "systemd" | "git"
|
|
|
12595
12614
|
};
|
|
12596
12615
|
git?: null | GitOptions;
|
|
12597
12616
|
discriminator?: CreateSnapshotRequest["template"]["discriminator"];
|
|
12617
|
+
skipCache?: CreateSnapshotRequest["template"]["skipCache"];
|
|
12598
12618
|
};
|
|
12599
12619
|
|
|
12600
12620
|
type CronSchedule = {
|
package/index.d.mts
CHANGED
|
@@ -4467,6 +4467,12 @@ interface PostV1VmsRequestBody {
|
|
|
4467
4467
|
* These packages will be installed using `apt-get install` on VM startup.
|
|
4468
4468
|
*/
|
|
4469
4469
|
aptDeps?: string[] | null;
|
|
4470
|
+
/**
|
|
4471
|
+
* When true, bypasses the snapshot cache and always creates a new snapshot.
|
|
4472
|
+
* The new snapshot still stores the template hash, so it becomes the updated
|
|
4473
|
+
* cache entry for future requests that do not set skipCache.
|
|
4474
|
+
*/
|
|
4475
|
+
skipCache?: boolean | null;
|
|
4470
4476
|
};
|
|
4471
4477
|
/**
|
|
4472
4478
|
* @deprecated
|
|
@@ -4883,6 +4889,12 @@ interface PostV1VmsSnapshotsRequestBody {
|
|
|
4883
4889
|
* These packages will be installed using `apt-get install` on VM startup.
|
|
4884
4890
|
*/
|
|
4885
4891
|
aptDeps?: string[] | null;
|
|
4892
|
+
/**
|
|
4893
|
+
* When true, bypasses the snapshot cache and always creates a new snapshot.
|
|
4894
|
+
* The new snapshot still stores the template hash, so it becomes the updated
|
|
4895
|
+
* cache entry for future requests that do not set skipCache.
|
|
4896
|
+
*/
|
|
4897
|
+
skipCache?: boolean | null;
|
|
4886
4898
|
};
|
|
4887
4899
|
persistence?: null | ({
|
|
4888
4900
|
priority?: number | null;
|
|
@@ -11909,6 +11921,12 @@ interface CreateSnapshotRequest {
|
|
|
11909
11921
|
* These packages will be installed using `apt-get install` on VM startup.
|
|
11910
11922
|
*/
|
|
11911
11923
|
aptDeps?: string[] | null;
|
|
11924
|
+
/**
|
|
11925
|
+
* When true, bypasses the snapshot cache and always creates a new snapshot.
|
|
11926
|
+
* The new snapshot still stores the template hash, so it becomes the updated
|
|
11927
|
+
* cache entry for future requests that do not set skipCache.
|
|
11928
|
+
*/
|
|
11929
|
+
skipCache?: boolean | null;
|
|
11912
11930
|
};
|
|
11913
11931
|
persistence?: null | ({
|
|
11914
11932
|
priority?: number | null;
|
|
@@ -12496,6 +12514,7 @@ declare class VmSpec<T extends Record<string, VmWithLike> = {}> {
|
|
|
12496
12514
|
readySignalTimeoutSeconds(value: number): this;
|
|
12497
12515
|
waitForReadySignal(value: boolean): this;
|
|
12498
12516
|
discriminator(value: string): this;
|
|
12517
|
+
skipCache(): this;
|
|
12499
12518
|
workdir(path: string): this;
|
|
12500
12519
|
aptDeps(...deps: string[]): this;
|
|
12501
12520
|
users(users: NonNullable<CreateVmOptions["users"]>): this;
|
|
@@ -12595,6 +12614,7 @@ type CreateVmOptions = Omit<PostV1VmsRequestBody, "template" | "systemd" | "git"
|
|
|
12595
12614
|
};
|
|
12596
12615
|
git?: null | GitOptions;
|
|
12597
12616
|
discriminator?: CreateSnapshotRequest["template"]["discriminator"];
|
|
12617
|
+
skipCache?: CreateSnapshotRequest["template"]["skipCache"];
|
|
12598
12618
|
};
|
|
12599
12619
|
|
|
12600
12620
|
type CronSchedule = {
|
package/index.mjs
CHANGED
|
@@ -5646,6 +5646,7 @@ function composeCreateVmOptions(arr) {
|
|
|
5646
5646
|
result.activityThresholdBytes = options.activityThresholdBytes;
|
|
5647
5647
|
if (options.discriminator !== void 0)
|
|
5648
5648
|
result.discriminator = options.discriminator;
|
|
5649
|
+
if (options.skipCache !== void 0) result.skipCache = options.skipCache;
|
|
5649
5650
|
if (options.persistence !== void 0)
|
|
5650
5651
|
result.persistence = options.persistence;
|
|
5651
5652
|
if (options.ports !== void 0) {
|
|
@@ -5793,6 +5794,7 @@ function composeCreateVmOptions(arr) {
|
|
|
5793
5794
|
aptDeps: newTemplate.aptDeps ?? baseTemplate.aptDeps,
|
|
5794
5795
|
vcpuCount: newTemplate.vcpuCount !== void 0 ? newTemplate.vcpuCount : baseTemplate.vcpuCount,
|
|
5795
5796
|
discriminator: newTemplate.discriminator ?? baseTemplate.discriminator,
|
|
5797
|
+
skipCache: newTemplate.skipCache ?? baseTemplate.skipCache,
|
|
5796
5798
|
workdir: newTemplate.workdir !== void 0 ? newTemplate.workdir : baseTemplate.workdir,
|
|
5797
5799
|
idleTimeoutSeconds: newTemplate.idleTimeoutSeconds !== void 0 ? newTemplate.idleTimeoutSeconds : baseTemplate.idleTimeoutSeconds,
|
|
5798
5800
|
waitForReadySignal: newTemplate.waitForReadySignal !== void 0 ? newTemplate.waitForReadySignal : baseTemplate.waitForReadySignal,
|
|
@@ -6543,7 +6545,10 @@ class VmSpec {
|
|
|
6543
6545
|
}
|
|
6544
6546
|
ensureSnapshot() {
|
|
6545
6547
|
if (!isVmSpecLike$1(this.raw.snapshot)) {
|
|
6546
|
-
this.raw.snapshot =
|
|
6548
|
+
this.raw.snapshot = new VmSpec({
|
|
6549
|
+
discriminator: this.raw.discriminator,
|
|
6550
|
+
skipCache: this.raw.skipCache
|
|
6551
|
+
});
|
|
6547
6552
|
}
|
|
6548
6553
|
return this.raw.snapshot;
|
|
6549
6554
|
}
|
|
@@ -6572,6 +6577,9 @@ class VmSpec {
|
|
|
6572
6577
|
discriminator(value) {
|
|
6573
6578
|
return this.mergeRaw({ discriminator: value });
|
|
6574
6579
|
}
|
|
6580
|
+
skipCache() {
|
|
6581
|
+
return this.mergeRaw({ skipCache: true });
|
|
6582
|
+
}
|
|
6575
6583
|
workdir(path) {
|
|
6576
6584
|
return this.mergeRaw({ workdir: path });
|
|
6577
6585
|
}
|
|
@@ -6798,7 +6806,10 @@ async function processOuterSpecBuilders(spec) {
|
|
|
6798
6806
|
snapshotSpec = spec.raw.snapshot;
|
|
6799
6807
|
} else {
|
|
6800
6808
|
const inheritedDiscriminator = spec.getBuilderDiscriminator(key) ?? spec.raw.discriminator;
|
|
6801
|
-
snapshotSpec =
|
|
6809
|
+
snapshotSpec = new VmSpec({
|
|
6810
|
+
discriminator: inheritedDiscriminator,
|
|
6811
|
+
skipCache: spec.raw.skipCache
|
|
6812
|
+
});
|
|
6802
6813
|
spec.raw.snapshot = snapshotSpec;
|
|
6803
6814
|
}
|
|
6804
6815
|
spec.raw.snapshot = await builder.configureSnapshotSpec(snapshotSpec);
|
|
@@ -6825,7 +6836,10 @@ async function processSpecTree(spec) {
|
|
|
6825
6836
|
snapshotSpec = spec.raw.snapshot;
|
|
6826
6837
|
} else {
|
|
6827
6838
|
const inheritedDiscriminator = spec.getBuilderDiscriminator(key) ?? spec.raw.discriminator;
|
|
6828
|
-
snapshotSpec =
|
|
6839
|
+
snapshotSpec = new VmSpec({
|
|
6840
|
+
discriminator: inheritedDiscriminator,
|
|
6841
|
+
skipCache: spec.raw.skipCache
|
|
6842
|
+
});
|
|
6829
6843
|
spec.raw.snapshot = snapshotSpec;
|
|
6830
6844
|
}
|
|
6831
6845
|
spec.raw.snapshot = await builder.configureSnapshotSpec(snapshotSpec);
|
|
@@ -6993,6 +7007,12 @@ class VmsNamespace {
|
|
|
6993
7007
|
template: _template,
|
|
6994
7008
|
...requestConfig
|
|
6995
7009
|
} = config;
|
|
7010
|
+
let slowPathTimeout;
|
|
7011
|
+
slowPathTimeout = setTimeout(() => {
|
|
7012
|
+
console.log(
|
|
7013
|
+
"VM creation is taking longer than expected. This usually happens when there's a cache miss on your vm's base snapshot. Subsequent vm creations with this configuration will likely be much faster."
|
|
7014
|
+
);
|
|
7015
|
+
}, 5e3);
|
|
6996
7016
|
const response = await this.freestyle._apiClient.post("/v1/vms", {
|
|
6997
7017
|
body: {
|
|
6998
7018
|
...requestConfig,
|
|
@@ -7003,9 +7023,11 @@ class VmsNamespace {
|
|
|
7003
7023
|
git: normalizeGitOptions(config.git)
|
|
7004
7024
|
}
|
|
7005
7025
|
}).catch((e) => {
|
|
7026
|
+
if (slowPathTimeout) clearTimeout(slowPathTimeout);
|
|
7006
7027
|
enhanceError(e);
|
|
7007
7028
|
throw e;
|
|
7008
7029
|
});
|
|
7030
|
+
if (slowPathTimeout) clearTimeout(slowPathTimeout);
|
|
7009
7031
|
const vmId = response.id;
|
|
7010
7032
|
const vm = new Vm({ vmId, freestyle: this.freestyle });
|
|
7011
7033
|
for (const key in builders) {
|
|
@@ -7209,6 +7231,7 @@ class VmSnapshotsNamespace {
|
|
|
7209
7231
|
"snapshots.ensure requires a template or spec to build a snapshot"
|
|
7210
7232
|
);
|
|
7211
7233
|
}
|
|
7234
|
+
const startTime = Date.now();
|
|
7212
7235
|
return this.apiClient.post("/v1/vms/snapshots", {
|
|
7213
7236
|
body: {
|
|
7214
7237
|
...requestOptions,
|
|
@@ -7216,6 +7239,14 @@ class VmSnapshotsNamespace {
|
|
|
7216
7239
|
isVmTemplateLike$1(requestOptions.template) ? requestOptions.template.raw : requestOptions.template
|
|
7217
7240
|
)
|
|
7218
7241
|
}
|
|
7242
|
+
}).then((response) => {
|
|
7243
|
+
const elapsedTime = Date.now() - startTime;
|
|
7244
|
+
if (elapsedTime > 5e3) {
|
|
7245
|
+
console.log(
|
|
7246
|
+
"Snapshot creation took longer than expected (> 5 seconds). This is slower because caches weren't available, but subsequent operations will be much faster."
|
|
7247
|
+
);
|
|
7248
|
+
}
|
|
7249
|
+
return response;
|
|
7219
7250
|
}).catch((e) => {
|
|
7220
7251
|
enhanceError(e);
|
|
7221
7252
|
throw e;
|