ppio-sandbox 2.1.1-a4 → 2.1.1-a6
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/{chunk-Q6PBUYGG.mjs → chunk-CMNTW7II.mjs} +2 -2
- package/dist/{chunk-6PRE7JOS.mjs → chunk-KWBEO77A.mjs} +268 -46
- package/dist/chunk-KWBEO77A.mjs.map +1 -0
- package/dist/{chunk-PYNTCKMS.mjs → chunk-UUSWCFXO.mjs} +2 -2
- package/dist/code-interpreter.d.mts +2 -2
- package/dist/code-interpreter.d.ts +2 -2
- package/dist/code-interpreter.js +268 -45
- package/dist/code-interpreter.js.map +1 -1
- package/dist/code-interpreter.mjs +4 -2
- package/dist/code-interpreter.mjs.map +1 -1
- package/dist/desktop.d.mts +1 -1
- package/dist/desktop.d.ts +1 -1
- package/dist/desktop.js +268 -45
- package/dist/desktop.js.map +1 -1
- package/dist/desktop.mjs +4 -2
- package/dist/{index-BmB5olHi.d.mts → index-DEcOTrq6.d.mts} +46 -32
- package/dist/{index-BmB5olHi.d.ts → index-DEcOTrq6.d.ts} +46 -32
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +268 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/sandbox-SEHZLHQY.mjs +8 -0
- package/dist/sandbox-T2TK45W6.mjs +8 -0
- package/package.json +1 -1
- package/dist/chunk-6PRE7JOS.mjs.map +0 -1
- package/dist/sandbox-IFBOTC7A.mjs +0 -8
- package/dist/sandbox-OAPKYDCZ.mjs +0 -8
- /package/dist/{chunk-Q6PBUYGG.mjs.map → chunk-CMNTW7II.mjs.map} +0 -0
- /package/dist/{chunk-PYNTCKMS.mjs.map → chunk-UUSWCFXO.mjs.map} +0 -0
- /package/dist/{sandbox-IFBOTC7A.mjs.map → sandbox-SEHZLHQY.mjs.map} +0 -0
- /package/dist/{sandbox-OAPKYDCZ.mjs.map → sandbox-T2TK45W6.mjs.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
__forAwait,
|
|
10
10
|
__spreadProps,
|
|
11
11
|
__spreadValues
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-KWBEO77A.mjs";
|
|
13
13
|
|
|
14
14
|
// src/code-interpreter/messaging.ts
|
|
15
15
|
async function extractError(res) {
|
|
@@ -465,4 +465,4 @@ Sandbox2.defaultTemplate = "code-interpreter-v1";
|
|
|
465
465
|
export {
|
|
466
466
|
Sandbox2 as Sandbox
|
|
467
467
|
};
|
|
468
|
-
//# sourceMappingURL=chunk-
|
|
468
|
+
//# sourceMappingURL=chunk-CMNTW7II.mjs.map
|
|
@@ -60,7 +60,7 @@ import createClient from "openapi-fetch";
|
|
|
60
60
|
import platform2 from "platform";
|
|
61
61
|
|
|
62
62
|
// package.json
|
|
63
|
-
var version = "2.1.1-
|
|
63
|
+
var version = "2.1.1-a6";
|
|
64
64
|
|
|
65
65
|
// src/core/utils.ts
|
|
66
66
|
import platform from "platform";
|
|
@@ -256,6 +256,8 @@ var FileUploadError = class extends BuildError {
|
|
|
256
256
|
this.name = "FileUploadError";
|
|
257
257
|
}
|
|
258
258
|
};
|
|
259
|
+
var ImageConfigError = class extends BuildError {
|
|
260
|
+
};
|
|
259
261
|
var VolumeError = class extends Error {
|
|
260
262
|
constructor(message) {
|
|
261
263
|
super(message);
|
|
@@ -3615,14 +3617,20 @@ var SandboxApi = class {
|
|
|
3615
3617
|
static async createSandbox(template, timeoutMs, opts) {
|
|
3616
3618
|
var _a3, _b, _c, _d, _e, _f, _g;
|
|
3617
3619
|
const config = new ConnectionConfig(opts);
|
|
3620
|
+
const longRunning = ((_a3 = opts == null ? void 0 : opts.metadata) == null ? void 0 : _a3.long_running) === "true";
|
|
3621
|
+
const metadata = longRunning ? __spreadValues({}, opts == null ? void 0 : opts.metadata) : opts == null ? void 0 : opts.metadata;
|
|
3622
|
+
if (longRunning) {
|
|
3623
|
+
metadata == null ? true : delete metadata.idle_timeout;
|
|
3624
|
+
}
|
|
3625
|
+
const timeout = longRunning ? void 0 : timeoutToSeconds(timeoutMs);
|
|
3618
3626
|
const lifecycle = getLifecycle(opts);
|
|
3619
3627
|
const autoPause = lifecycle.onTimeout === "pause";
|
|
3620
|
-
const autoResumeEnabled = lifecycle.onTimeout === "pause" ? (
|
|
3628
|
+
const autoResumeEnabled = lifecycle.onTimeout === "pause" ? (_b = lifecycle.autoResume) != null ? _b : false : void 0;
|
|
3621
3629
|
if (config.isLegacyDomain) {
|
|
3622
3630
|
if (opts == null ? void 0 : opts.mcp) {
|
|
3623
3631
|
raiseIfLegacy(config, "Sandbox.create mcp", SandboxError);
|
|
3624
3632
|
}
|
|
3625
|
-
const unsupportedNetworkOptions = Object.keys((
|
|
3633
|
+
const unsupportedNetworkOptions = Object.keys((_c = opts == null ? void 0 : opts.network) != null ? _c : {}).filter(
|
|
3626
3634
|
(key) => key !== "allowPublicTraffic"
|
|
3627
3635
|
);
|
|
3628
3636
|
if (unsupportedNetworkOptions.length > 0) {
|
|
@@ -3638,8 +3646,8 @@ var SandboxApi = class {
|
|
|
3638
3646
|
}
|
|
3639
3647
|
const body2 = __spreadValues(__spreadValues({
|
|
3640
3648
|
templateID: template,
|
|
3641
|
-
timeout
|
|
3642
|
-
metadata:
|
|
3649
|
+
timeout,
|
|
3650
|
+
metadata: metadata != null ? metadata : {},
|
|
3643
3651
|
envVars: (_d = opts == null ? void 0 : opts.envs) != null ? _d : {},
|
|
3644
3652
|
secure: (_e = opts == null ? void 0 : opts.secure) != null ? _e : false,
|
|
3645
3653
|
autoPause: autoPause != null ? autoPause : false
|
|
@@ -3673,10 +3681,10 @@ var SandboxApi = class {
|
|
|
3673
3681
|
const client = new ApiClient(config);
|
|
3674
3682
|
const body = __spreadValues(__spreadValues(__spreadValues({
|
|
3675
3683
|
templateID: template,
|
|
3676
|
-
metadata
|
|
3684
|
+
metadata,
|
|
3677
3685
|
mcp: opts == null ? void 0 : opts.mcp,
|
|
3678
3686
|
envVars: opts == null ? void 0 : opts.envs,
|
|
3679
|
-
timeout
|
|
3687
|
+
timeout,
|
|
3680
3688
|
secure: (_f = opts == null ? void 0 : opts.secure) != null ? _f : true,
|
|
3681
3689
|
allow_internet_access: (_g = opts == null ? void 0 : opts.allowInternetAccess) != null ? _g : true,
|
|
3682
3690
|
network: opts == null ? void 0 : opts.network
|
|
@@ -5640,6 +5648,7 @@ var SKIP_ENV = /* @__PURE__ */ new Set([
|
|
|
5640
5648
|
]);
|
|
5641
5649
|
var RETRY_STATUS = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
5642
5650
|
var READ_ATTEMPTS = 3;
|
|
5651
|
+
var TOKEN_CLIENT_ID = "ppio-sandbox";
|
|
5643
5652
|
var backoffBaseMs = 1e3;
|
|
5644
5653
|
function unsupportedBase(blob) {
|
|
5645
5654
|
var _a3, _b, _c, _d, _e;
|
|
@@ -5716,13 +5725,87 @@ function parseImageRef(image) {
|
|
|
5716
5725
|
return { host, repository, reference };
|
|
5717
5726
|
}
|
|
5718
5727
|
var RegistryHttpError = class extends Error {
|
|
5719
|
-
constructor(status, retryAfter, message) {
|
|
5728
|
+
constructor(status, retryAfter, message, challenge = null) {
|
|
5720
5729
|
super(message);
|
|
5721
5730
|
this.status = status;
|
|
5722
5731
|
this.retryAfter = retryAfter;
|
|
5732
|
+
this.challenge = challenge;
|
|
5723
5733
|
this.name = "RegistryHttpError";
|
|
5724
5734
|
}
|
|
5725
5735
|
};
|
|
5736
|
+
function parseChallenges(header) {
|
|
5737
|
+
const text = header != null ? header : "";
|
|
5738
|
+
const challenges = [];
|
|
5739
|
+
let index = 0;
|
|
5740
|
+
const skipSeparators = () => {
|
|
5741
|
+
while (index < text.length && " ,".includes(text[index])) {
|
|
5742
|
+
index++;
|
|
5743
|
+
}
|
|
5744
|
+
};
|
|
5745
|
+
const readToken = () => {
|
|
5746
|
+
const start = index;
|
|
5747
|
+
while (index < text.length && /[A-Za-z0-9\-_.:]/.test(text[index])) {
|
|
5748
|
+
index++;
|
|
5749
|
+
}
|
|
5750
|
+
return text.slice(start, index);
|
|
5751
|
+
};
|
|
5752
|
+
for (; ; ) {
|
|
5753
|
+
skipSeparators();
|
|
5754
|
+
const scheme = readToken();
|
|
5755
|
+
if (!scheme) {
|
|
5756
|
+
break;
|
|
5757
|
+
}
|
|
5758
|
+
const params = {};
|
|
5759
|
+
for (; ; ) {
|
|
5760
|
+
skipSeparators();
|
|
5761
|
+
if (index >= text.length) {
|
|
5762
|
+
break;
|
|
5763
|
+
}
|
|
5764
|
+
const keyStart = index;
|
|
5765
|
+
const key = readToken();
|
|
5766
|
+
if (!key) {
|
|
5767
|
+
break;
|
|
5768
|
+
}
|
|
5769
|
+
while (index < text.length && " ".includes(text[index])) {
|
|
5770
|
+
index++;
|
|
5771
|
+
}
|
|
5772
|
+
if (index >= text.length || text[index] !== "=") {
|
|
5773
|
+
index = keyStart;
|
|
5774
|
+
break;
|
|
5775
|
+
}
|
|
5776
|
+
index++;
|
|
5777
|
+
while (index < text.length && " ".includes(text[index])) {
|
|
5778
|
+
index++;
|
|
5779
|
+
}
|
|
5780
|
+
if (index < text.length && text[index] === '"') {
|
|
5781
|
+
index++;
|
|
5782
|
+
const chars = [];
|
|
5783
|
+
while (index < text.length) {
|
|
5784
|
+
if (text[index] === "\\" && index + 1 < text.length) {
|
|
5785
|
+
chars.push(text[index + 1]);
|
|
5786
|
+
index += 2;
|
|
5787
|
+
continue;
|
|
5788
|
+
}
|
|
5789
|
+
if (text[index] === '"') {
|
|
5790
|
+
index++;
|
|
5791
|
+
break;
|
|
5792
|
+
}
|
|
5793
|
+
chars.push(text[index]);
|
|
5794
|
+
index++;
|
|
5795
|
+
}
|
|
5796
|
+
params[key.toLowerCase()] = chars.join("");
|
|
5797
|
+
} else {
|
|
5798
|
+
const valueStart = index;
|
|
5799
|
+
while (index < text.length && text[index] !== ",") {
|
|
5800
|
+
index++;
|
|
5801
|
+
}
|
|
5802
|
+
params[key.toLowerCase()] = text.slice(valueStart, index).trim();
|
|
5803
|
+
}
|
|
5804
|
+
}
|
|
5805
|
+
challenges.push({ scheme, params });
|
|
5806
|
+
}
|
|
5807
|
+
return challenges;
|
|
5808
|
+
}
|
|
5726
5809
|
var UnusableImageError = class extends Error {
|
|
5727
5810
|
constructor(message) {
|
|
5728
5811
|
super(message);
|
|
@@ -5749,15 +5832,20 @@ async function registryGet(url, headers, options) {
|
|
|
5749
5832
|
);
|
|
5750
5833
|
}
|
|
5751
5834
|
try {
|
|
5752
|
-
const
|
|
5835
|
+
const init = {
|
|
5753
5836
|
headers,
|
|
5754
5837
|
signal: AbortSignal.timeout(timeoutMs)
|
|
5755
|
-
}
|
|
5838
|
+
};
|
|
5839
|
+
if ((options == null ? void 0 : options.dispatcher) !== void 0) {
|
|
5840
|
+
init.dispatcher = options.dispatcher;
|
|
5841
|
+
}
|
|
5842
|
+
const response = await fetch(url, init);
|
|
5756
5843
|
if (!response.ok) {
|
|
5757
5844
|
const error = new RegistryHttpError(
|
|
5758
5845
|
response.status,
|
|
5759
5846
|
response.headers.get("retry-after"),
|
|
5760
|
-
`HTTP ${response.status} ${response.statusText}
|
|
5847
|
+
`HTTP ${response.status} ${response.statusText}`,
|
|
5848
|
+
response.headers.get("www-authenticate")
|
|
5761
5849
|
);
|
|
5762
5850
|
if (!RETRY_STATUS.has(response.status)) {
|
|
5763
5851
|
throw error;
|
|
@@ -5775,14 +5863,10 @@ async function registryGet(url, headers, options) {
|
|
|
5775
5863
|
}
|
|
5776
5864
|
throw last;
|
|
5777
5865
|
}
|
|
5778
|
-
async function authHeaders(host, repository, credentials) {
|
|
5866
|
+
async function authHeaders(host, repository, credentials, dispatcher) {
|
|
5779
5867
|
const headers = { Accept: MANIFEST_TYPES };
|
|
5780
|
-
if (credentials) {
|
|
5781
|
-
|
|
5782
|
-
`${credentials.username}:${credentials.password}`,
|
|
5783
|
-
"utf8"
|
|
5784
|
-
).toString("base64");
|
|
5785
|
-
headers.Authorization = `Basic ${basic}`;
|
|
5868
|
+
if ((credentials == null ? void 0 : credentials.username) && credentials.password) {
|
|
5869
|
+
headers.Authorization = basicHeader(credentials);
|
|
5786
5870
|
}
|
|
5787
5871
|
const services = {
|
|
5788
5872
|
"registry-1.docker.io": ["auth.docker.io", "registry.docker.io"],
|
|
@@ -5796,9 +5880,9 @@ async function authHeaders(host, repository, credentials) {
|
|
|
5796
5880
|
const url = `https://${authHost}/token?service=${serviceName}&scope=repository:${repository}:pull`;
|
|
5797
5881
|
try {
|
|
5798
5882
|
const tokenHeaders = headers.Authorization ? { Authorization: headers.Authorization } : {};
|
|
5799
|
-
const body = await registryGet(url, tokenHeaders, {
|
|
5883
|
+
const body = await registryGet(url, tokenHeaders, __spreadValues({
|
|
5800
5884
|
attempts: 1
|
|
5801
|
-
});
|
|
5885
|
+
}, dispatcher === void 0 ? {} : { dispatcher }));
|
|
5802
5886
|
if (body.token) {
|
|
5803
5887
|
headers.Authorization = `Bearer ${body.token}`;
|
|
5804
5888
|
}
|
|
@@ -5806,6 +5890,79 @@ async function authHeaders(host, repository, credentials) {
|
|
|
5806
5890
|
}
|
|
5807
5891
|
return headers;
|
|
5808
5892
|
}
|
|
5893
|
+
var RegistrySession = class {
|
|
5894
|
+
constructor(repository, credentials, headers, dispatcher) {
|
|
5895
|
+
this.repository = repository;
|
|
5896
|
+
this.credentials = credentials;
|
|
5897
|
+
this.headers = headers;
|
|
5898
|
+
this.dispatcher = dispatcher;
|
|
5899
|
+
this.token = null;
|
|
5900
|
+
}
|
|
5901
|
+
/** GET `url`, resolving one Bearer challenge if the registry asks for it. */
|
|
5902
|
+
async get(url) {
|
|
5903
|
+
const headers = __spreadValues({}, this.headers);
|
|
5904
|
+
if (this.token) {
|
|
5905
|
+
headers.Authorization = `Bearer ${this.token}`;
|
|
5906
|
+
}
|
|
5907
|
+
try {
|
|
5908
|
+
return await registryGet(url, headers, __spreadValues({
|
|
5909
|
+
attempts: READ_ATTEMPTS
|
|
5910
|
+
}, this.dispatcher === void 0 ? {} : { dispatcher: this.dispatcher }));
|
|
5911
|
+
} catch (error) {
|
|
5912
|
+
if (!(error instanceof RegistryHttpError) || error.status !== 401) {
|
|
5913
|
+
throw error;
|
|
5914
|
+
}
|
|
5915
|
+
const token = await this.tokenFrom(error.challenge);
|
|
5916
|
+
if (token === null) {
|
|
5917
|
+
throw error;
|
|
5918
|
+
}
|
|
5919
|
+
this.token = token;
|
|
5920
|
+
headers.Authorization = `Bearer ${token}`;
|
|
5921
|
+
return registryGet(url, headers, __spreadValues({
|
|
5922
|
+
attempts: READ_ATTEMPTS
|
|
5923
|
+
}, this.dispatcher === void 0 ? {} : { dispatcher: this.dispatcher }));
|
|
5924
|
+
}
|
|
5925
|
+
}
|
|
5926
|
+
async tokenFrom(challenge) {
|
|
5927
|
+
for (const { scheme, params } of parseChallenges(challenge)) {
|
|
5928
|
+
if (scheme.toLowerCase() === "bearer") {
|
|
5929
|
+
return this.bearer(params);
|
|
5930
|
+
}
|
|
5931
|
+
}
|
|
5932
|
+
return null;
|
|
5933
|
+
}
|
|
5934
|
+
async bearer(params) {
|
|
5935
|
+
var _a3;
|
|
5936
|
+
const realm = params.realm;
|
|
5937
|
+
if (!realm || !/^https?:\/\//.test(realm)) {
|
|
5938
|
+
return null;
|
|
5939
|
+
}
|
|
5940
|
+
const url = new URL(realm);
|
|
5941
|
+
url.searchParams.set("client_id", TOKEN_CLIENT_ID);
|
|
5942
|
+
if (params.service) {
|
|
5943
|
+
url.searchParams.set("service", params.service);
|
|
5944
|
+
}
|
|
5945
|
+
url.searchParams.set("scope", params.scope || `repository:${this.repository}:pull`);
|
|
5946
|
+
const headers = {};
|
|
5947
|
+
if (((_a3 = this.credentials) == null ? void 0 : _a3.username) && this.credentials.password) {
|
|
5948
|
+
headers.Authorization = basicHeader(this.credentials);
|
|
5949
|
+
}
|
|
5950
|
+
const body = await registryGet(url.toString(), headers, __spreadValues({
|
|
5951
|
+
attempts: 1
|
|
5952
|
+
}, this.dispatcher === void 0 ? {} : { dispatcher: this.dispatcher }));
|
|
5953
|
+
if (body === null || typeof body !== "object") {
|
|
5954
|
+
return null;
|
|
5955
|
+
}
|
|
5956
|
+
return body.token || body.access_token || null;
|
|
5957
|
+
}
|
|
5958
|
+
};
|
|
5959
|
+
function basicHeader(credentials) {
|
|
5960
|
+
const encoded = Buffer.from(
|
|
5961
|
+
`${credentials.username}:${credentials.password}`,
|
|
5962
|
+
"utf8"
|
|
5963
|
+
).toString("base64");
|
|
5964
|
+
return `Basic ${encoded}`;
|
|
5965
|
+
}
|
|
5809
5966
|
function platformName(entry) {
|
|
5810
5967
|
var _a3, _b, _c;
|
|
5811
5968
|
const p = (_a3 = entry.platform) != null ? _a3 : {};
|
|
@@ -5850,41 +6007,53 @@ function describeFailure(error, image, host, repository, authenticated) {
|
|
|
5850
6007
|
const reason = `no such image: Docker Hub has no official image '${image}' (HTTP 401). The \`library/\` namespace has no private repositories, so this is a typo rather than a permissions problem`;
|
|
5851
6008
|
return __spreadProps(__spreadValues({}, empty), { error: reason, unusable: reason });
|
|
5852
6009
|
}
|
|
6010
|
+
if (error.status === 401) {
|
|
6011
|
+
const reason = authenticated ? `cannot read '${image}' (HTTP 401): the registry rejected the credentials. Check the username, the password, and the read permission on the repository` : `cannot read '${image}' (HTTP 401): the registry wants pull credentials for it. Pass the registry username and password, or check that the reference names an existing public image`;
|
|
6012
|
+
return __spreadProps(__spreadValues({}, empty), { error: reason });
|
|
6013
|
+
}
|
|
5853
6014
|
return __spreadProps(__spreadValues({}, empty), { error: `${error.name}: ${error.message}` });
|
|
5854
6015
|
}
|
|
5855
6016
|
const message = error instanceof Error ? error.message : String(error);
|
|
5856
6017
|
return __spreadProps(__spreadValues({}, empty), { error: message });
|
|
5857
6018
|
}
|
|
5858
|
-
async function fetchImageConfig(image, credentials) {
|
|
6019
|
+
async function fetchImageConfig(image, credentials, options) {
|
|
5859
6020
|
var _a3, _b, _c, _d, _e, _f, _g;
|
|
6021
|
+
const dispatcher = options == null ? void 0 : options.dispatcher;
|
|
6022
|
+
const cacheable = dispatcher === void 0;
|
|
5860
6023
|
const key = JSON.stringify([
|
|
5861
6024
|
image,
|
|
5862
6025
|
(_a3 = credentials == null ? void 0 : credentials.username) != null ? _a3 : null,
|
|
5863
6026
|
(_b = credentials == null ? void 0 : credentials.password) != null ? _b : null
|
|
5864
6027
|
]);
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
6028
|
+
if (cacheable) {
|
|
6029
|
+
const cached = CACHE.get(key);
|
|
6030
|
+
if (cached) {
|
|
6031
|
+
return copyConfig(cached);
|
|
6032
|
+
}
|
|
5868
6033
|
}
|
|
5869
6034
|
const { host, repository, reference } = parseImageRef(image);
|
|
5870
6035
|
let result;
|
|
5871
6036
|
try {
|
|
5872
|
-
const auth = await authHeaders(host, repository, credentials);
|
|
6037
|
+
const auth = await authHeaders(host, repository, credentials, dispatcher);
|
|
6038
|
+
const session = new RegistrySession(
|
|
6039
|
+
repository,
|
|
6040
|
+
credentials,
|
|
6041
|
+
auth,
|
|
6042
|
+
dispatcher
|
|
6043
|
+
);
|
|
5873
6044
|
const base = `https://${host}/v2/${repository}`;
|
|
5874
|
-
let manifest = await
|
|
5875
|
-
`${base}/manifests/${reference}
|
|
5876
|
-
auth
|
|
6045
|
+
let manifest = await session.get(
|
|
6046
|
+
`${base}/manifests/${reference}`
|
|
5877
6047
|
);
|
|
5878
6048
|
if (manifest.manifests) {
|
|
5879
6049
|
const digest = pickAmd64(manifest, image);
|
|
5880
|
-
manifest = await
|
|
6050
|
+
manifest = await session.get(`${base}/manifests/${digest}`);
|
|
5881
6051
|
}
|
|
5882
6052
|
if (!((_c = manifest.config) == null ? void 0 : _c.digest)) {
|
|
5883
6053
|
throw new Error(`${image}: manifest names no config blob`);
|
|
5884
6054
|
}
|
|
5885
|
-
const blob = await
|
|
5886
|
-
`${base}/blobs/${manifest.config.digest}
|
|
5887
|
-
auth
|
|
6055
|
+
const blob = await session.get(
|
|
6056
|
+
`${base}/blobs/${manifest.config.digest}`
|
|
5888
6057
|
);
|
|
5889
6058
|
const declared = (_d = blob.config) != null ? _d : {};
|
|
5890
6059
|
const env = {};
|
|
@@ -5911,10 +6080,14 @@ async function fetchImageConfig(image, credentials) {
|
|
|
5911
6080
|
image,
|
|
5912
6081
|
host,
|
|
5913
6082
|
repository,
|
|
5914
|
-
|
|
6083
|
+
// Both, because that is what the request actually carried: a lone username
|
|
6084
|
+
// is not a credential the registry could have rejected.
|
|
6085
|
+
Boolean((credentials == null ? void 0 : credentials.username) && (credentials == null ? void 0 : credentials.password))
|
|
5915
6086
|
);
|
|
5916
6087
|
}
|
|
5917
|
-
|
|
6088
|
+
if (cacheable) {
|
|
6089
|
+
CACHE.set(key, result);
|
|
6090
|
+
}
|
|
5918
6091
|
return copyConfig(result);
|
|
5919
6092
|
}
|
|
5920
6093
|
function effectiveStartCmd(entrypoint, cmd) {
|
|
@@ -6097,6 +6270,13 @@ var TemplateBase = class _TemplateBase {
|
|
|
6097
6270
|
// image's PATH -- the exact failure this reading exists to prevent.
|
|
6098
6271
|
this.imageConfigError = void 0;
|
|
6099
6272
|
this.imageUnusable = void 0;
|
|
6273
|
+
// What a failed read does. "warn" by default: one unreachable registry must not
|
|
6274
|
+
// abort a batch conversion, but a template silently missing the image's PATH is
|
|
6275
|
+
// the failure this reading exists to prevent, so it cannot pass unmentioned.
|
|
6276
|
+
this.imageOnConfigFailure = "warn";
|
|
6277
|
+
// Carries the TLS trust and proxy settings for a self-hosted registry, which
|
|
6278
|
+
// Node's fetch cannot be told about in any other per-request way.
|
|
6279
|
+
this.imageDispatcher = void 0;
|
|
6100
6280
|
this.fileContextPath = runtime === "browser" ? "." : (_a2 = getCallerDirectory(STACK_TRACE_DEPTH)) != null ? _a2 : ".";
|
|
6101
6281
|
this.fileIgnorePatterns = [];
|
|
6102
6282
|
this.logsRefreshFrequency = 200;
|
|
@@ -6323,12 +6503,40 @@ var TemplateBase = class _TemplateBase {
|
|
|
6323
6503
|
fromBaseImage() {
|
|
6324
6504
|
return this.fromImage(this.defaultBaseImage);
|
|
6325
6505
|
}
|
|
6506
|
+
/**
|
|
6507
|
+
* Build from a Docker image, restoring what the image declares.
|
|
6508
|
+
*
|
|
6509
|
+
* The image's ENV, WORKDIR and start command are read from its registry config
|
|
6510
|
+
* because the platform's own pull does not apply them. Reading is best-effort
|
|
6511
|
+
* and asynchronous, so it happens at build/serialize time.
|
|
6512
|
+
*
|
|
6513
|
+
* @param credentials registry username and password, for a private image.
|
|
6514
|
+
* @param options.inheritConfig restore the image's config (default true).
|
|
6515
|
+
* @param options.onConfigFailure what a failed read does — see
|
|
6516
|
+
* {@link ImageConfigFailureMode}. Defaults to `warn`.
|
|
6517
|
+
* @param options.dispatcher Node fetch `dispatcher` (an undici `Agent`), for a
|
|
6518
|
+
* self-hosted registry behind a private CA, a client certificate or a proxy.
|
|
6519
|
+
* For example, with a private CA:
|
|
6520
|
+
*
|
|
6521
|
+
* ```ts
|
|
6522
|
+
* import { Agent } from 'undici'
|
|
6523
|
+
* const dispatcher = new Agent({ connect: { ca: readFileSync('/ca.pem') } })
|
|
6524
|
+
* Template().fromImage('harbor.internal/app:1', undefined, { dispatcher })
|
|
6525
|
+
* ```
|
|
6526
|
+
*/
|
|
6326
6527
|
fromImage(baseImage, credentials, options) {
|
|
6327
|
-
var _a3;
|
|
6528
|
+
var _a3, _b;
|
|
6529
|
+
if ((options == null ? void 0 : options.onConfigFailure) !== void 0 && !["warn", "raise", "ignore"].includes(options.onConfigFailure)) {
|
|
6530
|
+
throw new InvalidArgumentError(
|
|
6531
|
+
'onConfigFailure must be "warn", "raise" or "ignore", got ' + String(options.onConfigFailure)
|
|
6532
|
+
);
|
|
6533
|
+
}
|
|
6328
6534
|
this.baseImage = baseImage;
|
|
6329
6535
|
this.baseTemplate = void 0;
|
|
6330
6536
|
this.inheritImageConfig = (_a3 = options == null ? void 0 : options.inheritConfig) != null ? _a3 : true;
|
|
6331
6537
|
this.imageCredentials = credentials;
|
|
6538
|
+
this.imageOnConfigFailure = (_b = options == null ? void 0 : options.onConfigFailure) != null ? _b : "warn";
|
|
6539
|
+
this.imageDispatcher = options == null ? void 0 : options.dispatcher;
|
|
6332
6540
|
if (credentials) {
|
|
6333
6541
|
this.registryConfig = {
|
|
6334
6542
|
type: "registry",
|
|
@@ -6743,23 +6951,35 @@ var TemplateBase = class _TemplateBase {
|
|
|
6743
6951
|
* restored config — but it is reported, since an image whose toolchain lives
|
|
6744
6952
|
* behind its ENV will otherwise look installed and behave as though it is not.
|
|
6745
6953
|
*/
|
|
6954
|
+
/** The one wording a failed read is reported with, on every channel. */
|
|
6955
|
+
configFailureMessage() {
|
|
6956
|
+
return `Could not read ${this.baseImage}: ${this.imageConfigError}. The template will build without the environment, working directory and start command the image declares.`;
|
|
6957
|
+
}
|
|
6746
6958
|
async resolveInheritedConfig(onBuildLogs) {
|
|
6747
6959
|
var _a3;
|
|
6960
|
+
if (this.imageOnConfigFailure === "raise" && this.imageConfigError !== void 0) {
|
|
6961
|
+
throw new ImageConfigError(this.configFailureMessage());
|
|
6962
|
+
}
|
|
6748
6963
|
if (!this.inheritImageConfig || this.baseImage === void 0) {
|
|
6749
6964
|
return;
|
|
6750
6965
|
}
|
|
6751
6966
|
this.inheritImageConfig = false;
|
|
6752
|
-
const config = await fetchImageConfig(
|
|
6967
|
+
const config = await fetchImageConfig(
|
|
6968
|
+
this.baseImage,
|
|
6969
|
+
this.imageCredentials,
|
|
6970
|
+
this.imageDispatcher === void 0 ? void 0 : { dispatcher: this.imageDispatcher }
|
|
6971
|
+
);
|
|
6753
6972
|
if (config.error) {
|
|
6754
6973
|
this.imageConfigError = config.error;
|
|
6755
6974
|
this.imageUnusable = config.unusable;
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
)
|
|
6762
|
-
|
|
6975
|
+
const message = this.configFailureMessage();
|
|
6976
|
+
if (this.imageOnConfigFailure === "raise") {
|
|
6977
|
+
throw new ImageConfigError(message);
|
|
6978
|
+
}
|
|
6979
|
+
if (this.imageOnConfigFailure !== "ignore") {
|
|
6980
|
+
console.warn(message);
|
|
6981
|
+
onBuildLogs == null ? void 0 : onBuildLogs(new LogEntry(/* @__PURE__ */ new Date(), "warn", message));
|
|
6982
|
+
}
|
|
6763
6983
|
return;
|
|
6764
6984
|
}
|
|
6765
6985
|
this.envs = __spreadValues(__spreadValues({}, config.env), this.envs);
|
|
@@ -7146,6 +7366,7 @@ Template.list = TemplateBase.list;
|
|
|
7146
7366
|
Template.delete = TemplateBase.delete;
|
|
7147
7367
|
Template.toJSON = TemplateBase.toJSON;
|
|
7148
7368
|
Template.toDockerfile = TemplateBase.toDockerfile;
|
|
7369
|
+
Template.imageConfigFailure = TemplateBase.imageConfigFailure;
|
|
7149
7370
|
|
|
7150
7371
|
// src/core/volume/index.ts
|
|
7151
7372
|
function quotaInodesForSize(quotaSizeGiB) {
|
|
@@ -7708,12 +7929,12 @@ var PPIO = class {
|
|
|
7708
7929
|
this.secret = new SecretNamespace(opts);
|
|
7709
7930
|
this.codeInterpreter = new RuntimeSandboxNamespace(
|
|
7710
7931
|
opts,
|
|
7711
|
-
() => import("./sandbox-
|
|
7932
|
+
() => import("./sandbox-SEHZLHQY.mjs")
|
|
7712
7933
|
);
|
|
7713
7934
|
this.code_interpreter = this.codeInterpreter;
|
|
7714
7935
|
this.desktop = new RuntimeSandboxNamespace(
|
|
7715
7936
|
opts,
|
|
7716
|
-
() => import("./sandbox-
|
|
7937
|
+
() => import("./sandbox-T2TK45W6.mjs")
|
|
7717
7938
|
);
|
|
7718
7939
|
}
|
|
7719
7940
|
async create(templateOrOpts, opts) {
|
|
@@ -7756,6 +7977,7 @@ export {
|
|
|
7756
7977
|
RateLimitError,
|
|
7757
7978
|
BuildError,
|
|
7758
7979
|
FileUploadError,
|
|
7980
|
+
ImageConfigError,
|
|
7759
7981
|
VolumeError,
|
|
7760
7982
|
SecretError,
|
|
7761
7983
|
ApiClient,
|
|
@@ -7791,4 +8013,4 @@ export {
|
|
|
7791
8013
|
ALL_TRAFFIC,
|
|
7792
8014
|
core_default
|
|
7793
8015
|
};
|
|
7794
|
-
//# sourceMappingURL=chunk-
|
|
8016
|
+
//# sourceMappingURL=chunk-KWBEO77A.mjs.map
|