@enclave-run/sdk 0.0.0-dev.5 → 0.1.0
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/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +93 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -24
package/dist/index.d.mts
CHANGED
|
@@ -4130,6 +4130,14 @@ declare class OutcomeUnknownError extends SandboxError {
|
|
|
4130
4130
|
readonly cause?: unknown;
|
|
4131
4131
|
constructor(message: string, recovery: SandboxCreateRecovery, cause?: unknown);
|
|
4132
4132
|
}
|
|
4133
|
+
/**
|
|
4134
|
+
* The durable create operation reached an authoritative failed state after
|
|
4135
|
+
* admission. The recovery identity remains available for audit and support.
|
|
4136
|
+
*/
|
|
4137
|
+
declare class SandboxCreateFailedError extends SandboxError {
|
|
4138
|
+
readonly recovery: SandboxCreateRecovery;
|
|
4139
|
+
constructor(message: string, recovery: SandboxCreateRecovery);
|
|
4140
|
+
}
|
|
4133
4141
|
/**
|
|
4134
4142
|
* The selected region explicitly rejected the request before admission.
|
|
4135
4143
|
*/
|
|
@@ -10383,4 +10391,4 @@ declare namespace Template {
|
|
|
10383
10391
|
var toDockerfile: typeof TemplateBase.toDockerfile;
|
|
10384
10392
|
}
|
|
10385
10393
|
|
|
10386
|
-
export { ALL_TRAFFIC, ApiClient, AuthenticationError, BuildError, type BuildInfo, type BuildOptions, type BuildStatusReason, type CommandConnectOpts, CommandExitError, CommandHandle, type CommandRequestOpts, type CommandResult, type CommandStartOpts, Commands, ConnectionConfig, type ConnectionOpts, type CopyItem, type CredentialAuditEvent, type DeactivateTemplateOptions, type EntryInfo, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOptions, type GetTemplateActivationOptions, Git, type GitAddOpts, GitAuthError, type GitBranches, type GitCloneOpts, type GitCommitOpts, type GitConfigOpts, type GitConfigScope, type GitDangerouslyAuthenticateOpts, type GitDeleteBranchOpts, type GitFileStatus, GitHubApp, type GitHubAuditQuery, type GitHubCredentialGrant, type GitHubGrantScope, type GitHubInstallation, type GitHubInstallationCallback, type GitHubInstallationLink, type GitHubRepositoryBinding, type GitHubRepositoryBindingOpts, type GitHubRepositoryPermissions, type GitInitOpts, type GitPullOpts, type GitPushOpts, type GitRemoteAddOpts, type GitRequestOpts, type GitStatus, GitUpstreamError, IdempotencyMismatchError, InvalidArgumentError, LogEntry, LogEntryEnd, type LogEntryLevel, LogEntryStart, type Logger, type McpServer$1 as McpServer, type McpServerName, NotEnoughSpaceError, NotFoundError, OutcomeUnknownError, type ProcessInfo, Pty, type PtyOutput, RateLimitError, ReadyCmd, RegionCapacityError, Sandbox, type SandboxApiOpts, type SandboxConnectOpts, type SandboxCreateRecovery, SandboxCreateRejectedError, type SandboxCreateRejectionReason, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxListOpts, type SandboxMetrics, type SandboxMetricsOpts, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxRef, SandboxRegionScope, type SandboxState, type SandboxTarget, type SnapshotInfo, type SnapshotListOpts, SnapshotPaginator, type Stderr, type Stdout, Template, type TemplateActivationOptions, TemplateBase, type TemplateBuildStatus, type TemplateBuildStatusResponse, type TemplateBuilder, type TemplateClass, TemplateError, type TemplateRegionActivation, type TemplateTag, TemplateTagConflictError, type TemplateTagConflictReason, type TemplateTagHead, type TemplateTagHeadExpectation, type TemplateTagInfo, TimeoutError, type Username, WatchHandle, type WriteInfo, type components, Sandbox as default, defaultBuildLogger, getSignature, type paths, waitForFile, waitForPort, waitForProcess, waitForTimeout, waitForURL };
|
|
10394
|
+
export { ALL_TRAFFIC, ApiClient, AuthenticationError, BuildError, type BuildInfo, type BuildOptions, type BuildStatusReason, type CommandConnectOpts, CommandExitError, CommandHandle, type CommandRequestOpts, type CommandResult, type CommandStartOpts, Commands, ConnectionConfig, type ConnectionOpts, type CopyItem, type CredentialAuditEvent, type DeactivateTemplateOptions, type EntryInfo, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOptions, type GetTemplateActivationOptions, Git, type GitAddOpts, GitAuthError, type GitBranches, type GitCloneOpts, type GitCommitOpts, type GitConfigOpts, type GitConfigScope, type GitDangerouslyAuthenticateOpts, type GitDeleteBranchOpts, type GitFileStatus, GitHubApp, type GitHubAuditQuery, type GitHubCredentialGrant, type GitHubGrantScope, type GitHubInstallation, type GitHubInstallationCallback, type GitHubInstallationLink, type GitHubRepositoryBinding, type GitHubRepositoryBindingOpts, type GitHubRepositoryPermissions, type GitInitOpts, type GitPullOpts, type GitPushOpts, type GitRemoteAddOpts, type GitRequestOpts, type GitStatus, GitUpstreamError, IdempotencyMismatchError, InvalidArgumentError, LogEntry, LogEntryEnd, type LogEntryLevel, LogEntryStart, type Logger, type McpServer$1 as McpServer, type McpServerName, NotEnoughSpaceError, NotFoundError, OutcomeUnknownError, type ProcessInfo, Pty, type PtyOutput, RateLimitError, ReadyCmd, RegionCapacityError, Sandbox, type SandboxApiOpts, type SandboxConnectOpts, SandboxCreateFailedError, type SandboxCreateRecovery, SandboxCreateRejectedError, type SandboxCreateRejectionReason, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxListOpts, type SandboxMetrics, type SandboxMetricsOpts, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxRef, SandboxRegionScope, type SandboxState, type SandboxTarget, type SnapshotInfo, type SnapshotListOpts, SnapshotPaginator, type Stderr, type Stdout, Template, type TemplateActivationOptions, TemplateBase, type TemplateBuildStatus, type TemplateBuildStatusResponse, type TemplateBuilder, type TemplateClass, TemplateError, type TemplateRegionActivation, type TemplateTag, TemplateTagConflictError, type TemplateTagConflictReason, type TemplateTagHead, type TemplateTagHeadExpectation, type TemplateTagInfo, TimeoutError, type Username, WatchHandle, type WriteInfo, type components, Sandbox as default, defaultBuildLogger, getSignature, type paths, waitForFile, waitForPort, waitForProcess, waitForTimeout, waitForURL };
|
package/dist/index.d.ts
CHANGED
|
@@ -4130,6 +4130,14 @@ declare class OutcomeUnknownError extends SandboxError {
|
|
|
4130
4130
|
readonly cause?: unknown;
|
|
4131
4131
|
constructor(message: string, recovery: SandboxCreateRecovery, cause?: unknown);
|
|
4132
4132
|
}
|
|
4133
|
+
/**
|
|
4134
|
+
* The durable create operation reached an authoritative failed state after
|
|
4135
|
+
* admission. The recovery identity remains available for audit and support.
|
|
4136
|
+
*/
|
|
4137
|
+
declare class SandboxCreateFailedError extends SandboxError {
|
|
4138
|
+
readonly recovery: SandboxCreateRecovery;
|
|
4139
|
+
constructor(message: string, recovery: SandboxCreateRecovery);
|
|
4140
|
+
}
|
|
4133
4141
|
/**
|
|
4134
4142
|
* The selected region explicitly rejected the request before admission.
|
|
4135
4143
|
*/
|
|
@@ -10383,4 +10391,4 @@ declare namespace Template {
|
|
|
10383
10391
|
var toDockerfile: typeof TemplateBase.toDockerfile;
|
|
10384
10392
|
}
|
|
10385
10393
|
|
|
10386
|
-
export { ALL_TRAFFIC, ApiClient, AuthenticationError, BuildError, type BuildInfo, type BuildOptions, type BuildStatusReason, type CommandConnectOpts, CommandExitError, CommandHandle, type CommandRequestOpts, type CommandResult, type CommandStartOpts, Commands, ConnectionConfig, type ConnectionOpts, type CopyItem, type CredentialAuditEvent, type DeactivateTemplateOptions, type EntryInfo, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOptions, type GetTemplateActivationOptions, Git, type GitAddOpts, GitAuthError, type GitBranches, type GitCloneOpts, type GitCommitOpts, type GitConfigOpts, type GitConfigScope, type GitDangerouslyAuthenticateOpts, type GitDeleteBranchOpts, type GitFileStatus, GitHubApp, type GitHubAuditQuery, type GitHubCredentialGrant, type GitHubGrantScope, type GitHubInstallation, type GitHubInstallationCallback, type GitHubInstallationLink, type GitHubRepositoryBinding, type GitHubRepositoryBindingOpts, type GitHubRepositoryPermissions, type GitInitOpts, type GitPullOpts, type GitPushOpts, type GitRemoteAddOpts, type GitRequestOpts, type GitStatus, GitUpstreamError, IdempotencyMismatchError, InvalidArgumentError, LogEntry, LogEntryEnd, type LogEntryLevel, LogEntryStart, type Logger, type McpServer$1 as McpServer, type McpServerName, NotEnoughSpaceError, NotFoundError, OutcomeUnknownError, type ProcessInfo, Pty, type PtyOutput, RateLimitError, ReadyCmd, RegionCapacityError, Sandbox, type SandboxApiOpts, type SandboxConnectOpts, type SandboxCreateRecovery, SandboxCreateRejectedError, type SandboxCreateRejectionReason, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxListOpts, type SandboxMetrics, type SandboxMetricsOpts, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxRef, SandboxRegionScope, type SandboxState, type SandboxTarget, type SnapshotInfo, type SnapshotListOpts, SnapshotPaginator, type Stderr, type Stdout, Template, type TemplateActivationOptions, TemplateBase, type TemplateBuildStatus, type TemplateBuildStatusResponse, type TemplateBuilder, type TemplateClass, TemplateError, type TemplateRegionActivation, type TemplateTag, TemplateTagConflictError, type TemplateTagConflictReason, type TemplateTagHead, type TemplateTagHeadExpectation, type TemplateTagInfo, TimeoutError, type Username, WatchHandle, type WriteInfo, type components, Sandbox as default, defaultBuildLogger, getSignature, type paths, waitForFile, waitForPort, waitForProcess, waitForTimeout, waitForURL };
|
|
10394
|
+
export { ALL_TRAFFIC, ApiClient, AuthenticationError, BuildError, type BuildInfo, type BuildOptions, type BuildStatusReason, type CommandConnectOpts, CommandExitError, CommandHandle, type CommandRequestOpts, type CommandResult, type CommandStartOpts, Commands, ConnectionConfig, type ConnectionOpts, type CopyItem, type CredentialAuditEvent, type DeactivateTemplateOptions, type EntryInfo, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOptions, type GetTemplateActivationOptions, Git, type GitAddOpts, GitAuthError, type GitBranches, type GitCloneOpts, type GitCommitOpts, type GitConfigOpts, type GitConfigScope, type GitDangerouslyAuthenticateOpts, type GitDeleteBranchOpts, type GitFileStatus, GitHubApp, type GitHubAuditQuery, type GitHubCredentialGrant, type GitHubGrantScope, type GitHubInstallation, type GitHubInstallationCallback, type GitHubInstallationLink, type GitHubRepositoryBinding, type GitHubRepositoryBindingOpts, type GitHubRepositoryPermissions, type GitInitOpts, type GitPullOpts, type GitPushOpts, type GitRemoteAddOpts, type GitRequestOpts, type GitStatus, GitUpstreamError, IdempotencyMismatchError, InvalidArgumentError, LogEntry, LogEntryEnd, type LogEntryLevel, LogEntryStart, type Logger, type McpServer$1 as McpServer, type McpServerName, NotEnoughSpaceError, NotFoundError, OutcomeUnknownError, type ProcessInfo, Pty, type PtyOutput, RateLimitError, ReadyCmd, RegionCapacityError, Sandbox, type SandboxApiOpts, type SandboxConnectOpts, SandboxCreateFailedError, type SandboxCreateRecovery, SandboxCreateRejectedError, type SandboxCreateRejectionReason, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxListOpts, type SandboxMetrics, type SandboxMetricsOpts, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxRef, SandboxRegionScope, type SandboxState, type SandboxTarget, type SnapshotInfo, type SnapshotListOpts, SnapshotPaginator, type Stderr, type Stdout, Template, type TemplateActivationOptions, TemplateBase, type TemplateBuildStatus, type TemplateBuildStatusResponse, type TemplateBuilder, type TemplateClass, TemplateError, type TemplateRegionActivation, type TemplateTag, TemplateTagConflictError, type TemplateTagConflictReason, type TemplateTagHead, type TemplateTagHeadExpectation, type TemplateTagInfo, TimeoutError, type Username, WatchHandle, type WriteInfo, type components, Sandbox as default, defaultBuildLogger, getSignature, type paths, waitForFile, waitForPort, waitForProcess, waitForTimeout, waitForURL };
|
package/dist/index.js
CHANGED
|
@@ -101,6 +101,7 @@ __export(src_exports, {
|
|
|
101
101
|
ReadyCmd: () => ReadyCmd,
|
|
102
102
|
RegionCapacityError: () => RegionCapacityError,
|
|
103
103
|
Sandbox: () => Sandbox,
|
|
104
|
+
SandboxCreateFailedError: () => SandboxCreateFailedError,
|
|
104
105
|
SandboxCreateRejectedError: () => SandboxCreateRejectedError,
|
|
105
106
|
SandboxError: () => SandboxError,
|
|
106
107
|
SandboxRegionScope: () => SandboxRegionScope,
|
|
@@ -127,7 +128,7 @@ var import_openapi_fetch = __toESM(require("openapi-fetch"));
|
|
|
127
128
|
var import_platform2 = __toESM(require("platform"));
|
|
128
129
|
|
|
129
130
|
// package.json
|
|
130
|
-
var version = "0.
|
|
131
|
+
var version = "0.1.0";
|
|
131
132
|
|
|
132
133
|
// src/utils.ts
|
|
133
134
|
var import_platform = __toESM(require("platform"));
|
|
@@ -169,12 +170,6 @@ async function sha256(data) {
|
|
|
169
170
|
function timeoutToSeconds(timeout) {
|
|
170
171
|
return Math.ceil(timeout / 1e3);
|
|
171
172
|
}
|
|
172
|
-
async function dynamicImport(module2) {
|
|
173
|
-
if (runtime === "browser") {
|
|
174
|
-
throw new Error("Browser runtime is not supported for dynamic import");
|
|
175
|
-
}
|
|
176
|
-
return await import(module2);
|
|
177
|
-
}
|
|
178
173
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
179
174
|
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
180
175
|
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
|
|
@@ -239,6 +234,13 @@ var OutcomeUnknownError = class extends SandboxError {
|
|
|
239
234
|
this.cause = cause;
|
|
240
235
|
}
|
|
241
236
|
};
|
|
237
|
+
var SandboxCreateFailedError = class extends SandboxError {
|
|
238
|
+
constructor(message, recovery) {
|
|
239
|
+
super(message);
|
|
240
|
+
this.name = "SandboxCreateFailedError";
|
|
241
|
+
this.recovery = recovery;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
242
244
|
var SandboxCreateRejectedError = class extends SandboxError {
|
|
243
245
|
constructor(message, recovery, reason, spilloverAllowed = false, capacityTier = "shared") {
|
|
244
246
|
super(message);
|
|
@@ -353,11 +355,11 @@ function formatLog(log) {
|
|
|
353
355
|
return JSON.parse(JSON.stringify(log));
|
|
354
356
|
}
|
|
355
357
|
function createRpcLogger(logger) {
|
|
356
|
-
function logEach(
|
|
358
|
+
function logEach(stream2) {
|
|
357
359
|
return __asyncGenerator(this, null, function* () {
|
|
358
360
|
var _a3;
|
|
359
361
|
try {
|
|
360
|
-
for (var iter = __forAwait(
|
|
362
|
+
for (var iter = __forAwait(stream2), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
361
363
|
const m = temp.value;
|
|
362
364
|
(_a3 = logger.debug) == null ? void 0 : _a3.call(logger, "Response stream:", formatLog(m));
|
|
363
365
|
yield m;
|
|
@@ -3584,8 +3586,9 @@ var SandboxApi = class {
|
|
|
3584
3586
|
return operation.sandbox;
|
|
3585
3587
|
}
|
|
3586
3588
|
if (operation.state === "failed") {
|
|
3587
|
-
throw new
|
|
3588
|
-
(_b = (_a3 = operation.error) == null ? void 0 : _a3.message) != null ? _b : "Sandbox create failed after admission"
|
|
3589
|
+
throw new SandboxCreateFailedError(
|
|
3590
|
+
(_b = (_a3 = operation.error) == null ? void 0 : _a3.message) != null ? _b : "Sandbox create failed after admission",
|
|
3591
|
+
recovery
|
|
3589
3592
|
);
|
|
3590
3593
|
}
|
|
3591
3594
|
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
@@ -4479,6 +4482,10 @@ var SandboxRegionScope = class {
|
|
|
4479
4482
|
}
|
|
4480
4483
|
};
|
|
4481
4484
|
|
|
4485
|
+
// src/template/buildApi.ts
|
|
4486
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
4487
|
+
var import_node_stream = __toESM(require("stream"));
|
|
4488
|
+
|
|
4482
4489
|
// src/template/logger.ts
|
|
4483
4490
|
var import_chalk = __toESM(require("chalk"));
|
|
4484
4491
|
var LogEntry = class {
|
|
@@ -4600,16 +4607,30 @@ function defaultBuildLogger(options) {
|
|
|
4600
4607
|
// src/template/utils.ts
|
|
4601
4608
|
var import_node_crypto = __toESM(require("crypto"));
|
|
4602
4609
|
var import_node_fs = __toESM(require("fs"));
|
|
4610
|
+
var import_node_os = __toESM(require("os"));
|
|
4603
4611
|
var import_node_path = __toESM(require("path"));
|
|
4604
4612
|
var import_node_url = __toESM(require("url"));
|
|
4605
4613
|
|
|
4606
4614
|
// src/template/consts.ts
|
|
4607
4615
|
var FINALIZE_STEP_NAME = "finalize";
|
|
4616
|
+
var FILE_UPLOAD_TIMEOUT_MS = 36e5;
|
|
4608
4617
|
var BASE_STEP_NAME = "base";
|
|
4609
4618
|
var STACK_TRACE_DEPTH = 3;
|
|
4610
4619
|
var RESOLVE_SYMLINKS = false;
|
|
4611
4620
|
|
|
4612
4621
|
// src/template/utils.ts
|
|
4622
|
+
async function loadGlob() {
|
|
4623
|
+
if (runtime === "browser") {
|
|
4624
|
+
throw new Error("Browser runtime is not supported for local file copies");
|
|
4625
|
+
}
|
|
4626
|
+
return await import("glob");
|
|
4627
|
+
}
|
|
4628
|
+
async function loadTar() {
|
|
4629
|
+
if (runtime === "browser") {
|
|
4630
|
+
throw new Error("Browser runtime is not supported for local file copies");
|
|
4631
|
+
}
|
|
4632
|
+
return await import("tar");
|
|
4633
|
+
}
|
|
4613
4634
|
function validateRelativePath(src, stackTrace) {
|
|
4614
4635
|
if (import_node_path.default.isAbsolute(src)) {
|
|
4615
4636
|
const error = new TemplateError(
|
|
@@ -4640,7 +4661,7 @@ function normalizePath(path2) {
|
|
|
4640
4661
|
return path2.replace(/\\/g, "/");
|
|
4641
4662
|
}
|
|
4642
4663
|
async function getAllFilesInPath(src, contextPath, ignorePatterns, includeDirectories = true) {
|
|
4643
|
-
const { glob } = await
|
|
4664
|
+
const { glob } = await loadGlob();
|
|
4644
4665
|
const files = /* @__PURE__ */ new Map();
|
|
4645
4666
|
const globFiles = await glob(src, {
|
|
4646
4667
|
ignore: ignorePatterns,
|
|
@@ -4756,32 +4777,48 @@ function getCallerDirectory(depth) {
|
|
|
4756
4777
|
function padOctal(mode) {
|
|
4757
4778
|
return mode.toString(8).padStart(4, "0");
|
|
4758
4779
|
}
|
|
4759
|
-
async function
|
|
4760
|
-
const { create } = await
|
|
4780
|
+
async function getTarArchiveInputs(fileName, fileContextPath, ignorePatterns) {
|
|
4781
|
+
const { create } = await loadTar();
|
|
4761
4782
|
const allFiles = await getAllFilesInPath(
|
|
4762
4783
|
fileName,
|
|
4763
4784
|
fileContextPath,
|
|
4764
4785
|
ignorePatterns,
|
|
4765
4786
|
true
|
|
4766
4787
|
);
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
cwd: fileContextPath,
|
|
4772
|
-
follow: resolveSymlinks,
|
|
4773
|
-
noDirRecurse: true
|
|
4774
|
-
},
|
|
4775
|
-
filePaths
|
|
4776
|
-
);
|
|
4788
|
+
return {
|
|
4789
|
+
create,
|
|
4790
|
+
filePaths: allFiles.map((file) => file.relativePosix())
|
|
4791
|
+
};
|
|
4777
4792
|
}
|
|
4778
|
-
async function
|
|
4779
|
-
|
|
4793
|
+
async function spoolTarArchive(fileName, fileContextPath, ignorePatterns, resolveSymlinks) {
|
|
4794
|
+
const { create, filePaths } = await getTarArchiveInputs(
|
|
4780
4795
|
fileName,
|
|
4781
4796
|
fileContextPath,
|
|
4782
|
-
ignorePatterns
|
|
4783
|
-
resolveSymlinks
|
|
4797
|
+
ignorePatterns
|
|
4784
4798
|
);
|
|
4799
|
+
const tmpDir = await import_node_fs.default.promises.mkdtemp(
|
|
4800
|
+
import_node_path.default.join(import_node_os.default.tmpdir(), "enclave-template-")
|
|
4801
|
+
);
|
|
4802
|
+
const tarPath = import_node_path.default.join(tmpDir, "context.tar.gz");
|
|
4803
|
+
const cleanup = () => import_node_fs.default.promises.rm(tmpDir, { recursive: true, force: true }).catch(() => {
|
|
4804
|
+
});
|
|
4805
|
+
try {
|
|
4806
|
+
await create(
|
|
4807
|
+
{
|
|
4808
|
+
gzip: true,
|
|
4809
|
+
cwd: fileContextPath,
|
|
4810
|
+
follow: resolveSymlinks,
|
|
4811
|
+
noDirRecurse: true,
|
|
4812
|
+
file: tarPath
|
|
4813
|
+
},
|
|
4814
|
+
filePaths
|
|
4815
|
+
);
|
|
4816
|
+
const { size } = await import_node_fs.default.promises.stat(tarPath);
|
|
4817
|
+
return { path: tarPath, size, cleanup };
|
|
4818
|
+
} catch (error) {
|
|
4819
|
+
await cleanup();
|
|
4820
|
+
throw error;
|
|
4821
|
+
}
|
|
4785
4822
|
}
|
|
4786
4823
|
function getBuildStepIndex(step, stackTracesLength) {
|
|
4787
4824
|
if (step === BASE_STEP_NAME) {
|
|
@@ -4841,22 +4878,34 @@ async function getFileUploadLink(client, { templateID, filesHash }, stackTrace)
|
|
|
4841
4878
|
}
|
|
4842
4879
|
async function uploadFile(options, stackTrace) {
|
|
4843
4880
|
const { fileName, url: url2, fileContextPath, ignorePatterns, resolveSymlinks } = options;
|
|
4881
|
+
let cleanup;
|
|
4882
|
+
let bodyStream;
|
|
4844
4883
|
try {
|
|
4845
|
-
const
|
|
4884
|
+
const archive = await spoolTarArchive(
|
|
4846
4885
|
fileName,
|
|
4847
4886
|
fileContextPath,
|
|
4848
4887
|
ignorePatterns,
|
|
4849
4888
|
resolveSymlinks
|
|
4850
4889
|
);
|
|
4890
|
+
cleanup = archive.cleanup;
|
|
4891
|
+
bodyStream = import_node_fs2.default.createReadStream(archive.path);
|
|
4851
4892
|
const res = await fetch(url2, {
|
|
4852
4893
|
method: "PUT",
|
|
4853
|
-
|
|
4854
|
-
|
|
4894
|
+
body: import_node_stream.default.Readable.toWeb(bodyStream),
|
|
4895
|
+
headers: {
|
|
4896
|
+
"Content-Length": archive.size.toString()
|
|
4897
|
+
},
|
|
4898
|
+
signal: AbortSignal.timeout(FILE_UPLOAD_TIMEOUT_MS),
|
|
4899
|
+
// Node fetch requires duplex for a streaming request body, but the DOM
|
|
4900
|
+
// RequestInit type does not expose it.
|
|
4901
|
+
// @ts-expect-error Node fetch extension
|
|
4855
4902
|
duplex: "half"
|
|
4856
4903
|
});
|
|
4857
4904
|
if (!res.ok) {
|
|
4905
|
+
const responseDetails = (await res.text().catch(() => "")).slice(0, 4096);
|
|
4906
|
+
const status = `${res.status} ${res.statusText}`.trim();
|
|
4858
4907
|
throw new FileUploadError(
|
|
4859
|
-
`Failed to upload file: ${
|
|
4908
|
+
`Failed to upload file: ${status}${responseDetails ? ` - ${responseDetails}` : ""}`,
|
|
4860
4909
|
stackTrace
|
|
4861
4910
|
);
|
|
4862
4911
|
}
|
|
@@ -4865,6 +4914,14 @@ async function uploadFile(options, stackTrace) {
|
|
|
4865
4914
|
throw error;
|
|
4866
4915
|
}
|
|
4867
4916
|
throw new FileUploadError(`Failed to upload file: ${error}`, stackTrace);
|
|
4917
|
+
} finally {
|
|
4918
|
+
if (bodyStream && !bodyStream.closed) {
|
|
4919
|
+
await new Promise((resolve) => {
|
|
4920
|
+
bodyStream == null ? void 0 : bodyStream.once("close", resolve);
|
|
4921
|
+
bodyStream == null ? void 0 : bodyStream.destroy();
|
|
4922
|
+
});
|
|
4923
|
+
}
|
|
4924
|
+
await (cleanup == null ? void 0 : cleanup());
|
|
4868
4925
|
}
|
|
4869
4926
|
}
|
|
4870
4927
|
async function triggerBuild(client, { templateID, buildID, template }) {
|
|
@@ -5051,7 +5108,7 @@ async function getTemplateTags(client, { templateID }) {
|
|
|
5051
5108
|
|
|
5052
5109
|
// src/template/dockerfileParser.ts
|
|
5053
5110
|
var import_dockerfile_ast = require("dockerfile-ast");
|
|
5054
|
-
var
|
|
5111
|
+
var import_node_fs3 = __toESM(require("fs"));
|
|
5055
5112
|
|
|
5056
5113
|
// src/template/readycmd.ts
|
|
5057
5114
|
var ReadyCmd = class {
|
|
@@ -5088,8 +5145,8 @@ function waitForTimeout(timeout) {
|
|
|
5088
5145
|
function parseDockerfile(dockerfileContentOrPath, templateBuilder) {
|
|
5089
5146
|
let dockerfileContent;
|
|
5090
5147
|
try {
|
|
5091
|
-
if (
|
|
5092
|
-
dockerfileContent =
|
|
5148
|
+
if (import_node_fs3.default.existsSync(dockerfileContentOrPath) && import_node_fs3.default.statSync(dockerfileContentOrPath).isFile()) {
|
|
5149
|
+
dockerfileContent = import_node_fs3.default.readFileSync(dockerfileContentOrPath, "utf-8");
|
|
5093
5150
|
} else {
|
|
5094
5151
|
dockerfileContent = dockerfileContentOrPath;
|
|
5095
5152
|
}
|
|
@@ -6456,6 +6513,7 @@ var src_default = Sandbox;
|
|
|
6456
6513
|
ReadyCmd,
|
|
6457
6514
|
RegionCapacityError,
|
|
6458
6515
|
Sandbox,
|
|
6516
|
+
SandboxCreateFailedError,
|
|
6459
6517
|
SandboxCreateRejectedError,
|
|
6460
6518
|
SandboxError,
|
|
6461
6519
|
SandboxRegionScope,
|