@codexhost/cli-win32-x64 0.28.1 → 0.28.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/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +27 -27
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +91 -91
- package/app/web-modules/server.mjs +293 -147
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shell.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
|
@@ -1707,7 +1707,7 @@ var require_extension = __commonJS({
|
|
|
1707
1707
|
var require_websocket = __commonJS({
|
|
1708
1708
|
"node_modules/ws/lib/websocket.js"(exports, module) {
|
|
1709
1709
|
"use strict";
|
|
1710
|
-
var EventEmitter3 = __require("events"), https = __require("https"), http = __require("http"), net2 = __require("net"), tls3 = __require("tls"), { randomBytes: randomBytes12, createHash: createHash18 } = __require("crypto"), { Duplex, Readable:
|
|
1710
|
+
var EventEmitter3 = __require("events"), https = __require("https"), http = __require("http"), net2 = __require("net"), tls3 = __require("tls"), { randomBytes: randomBytes12, createHash: createHash18 } = __require("crypto"), { Duplex, Readable: Readable5 } = __require("stream"), { URL: URL2 } = __require("url"), PerMessageDeflate3 = require_permessage_deflate(), Receiver3 = require_receiver(), Sender3 = require_sender(), { isBlob } = require_validation(), {
|
|
1711
1711
|
BINARY_TYPES,
|
|
1712
1712
|
CLOSE_TIMEOUT,
|
|
1713
1713
|
EMPTY_BUFFER,
|
|
@@ -5442,7 +5442,7 @@ var require_extension2 = __commonJS({
|
|
|
5442
5442
|
var require_websocket2 = __commonJS({
|
|
5443
5443
|
"packages/web-server/node_modules/ws/lib/websocket.js"(exports, module) {
|
|
5444
5444
|
"use strict";
|
|
5445
|
-
var EventEmitter3 = __require("events"), https = __require("https"), http = __require("http"), net2 = __require("net"), tls3 = __require("tls"), { randomBytes: randomBytes12, createHash: createHash18 } = __require("crypto"), { Duplex, Readable:
|
|
5445
|
+
var EventEmitter3 = __require("events"), https = __require("https"), http = __require("http"), net2 = __require("net"), tls3 = __require("tls"), { randomBytes: randomBytes12, createHash: createHash18 } = __require("crypto"), { Duplex, Readable: Readable5 } = __require("stream"), { URL: URL2 } = __require("url"), PerMessageDeflate3 = require_permessage_deflate2(), Receiver3 = require_receiver2(), Sender3 = require_sender2(), { isBlob } = require_validation2(), {
|
|
5446
5446
|
BINARY_TYPES,
|
|
5447
5447
|
CLOSE_TIMEOUT,
|
|
5448
5448
|
EMPTY_BUFFER,
|
|
@@ -77007,6 +77007,82 @@ var PeerHostStore = class {
|
|
|
77007
77007
|
}
|
|
77008
77008
|
};
|
|
77009
77009
|
|
|
77010
|
+
// packages/web-server/src/peer-request-error.ts
|
|
77011
|
+
var TIMEOUT_CODES = /* @__PURE__ */ new Set([
|
|
77012
|
+
"ETIMEDOUT",
|
|
77013
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
77014
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
77015
|
+
"UND_ERR_BODY_TIMEOUT"
|
|
77016
|
+
]), UNREACHABLE_CODES = /* @__PURE__ */ new Set([
|
|
77017
|
+
"ECONNREFUSED",
|
|
77018
|
+
"ENETUNREACH",
|
|
77019
|
+
"EHOSTUNREACH",
|
|
77020
|
+
"ENOTFOUND",
|
|
77021
|
+
"EAI_AGAIN"
|
|
77022
|
+
]), OTHER_CODES = /* @__PURE__ */ new Set([
|
|
77023
|
+
"ABORT_ERR",
|
|
77024
|
+
"ECONNRESET",
|
|
77025
|
+
"EPIPE",
|
|
77026
|
+
"ERR_STREAM_PREMATURE_CLOSE",
|
|
77027
|
+
"UND_ERR_ABORTED",
|
|
77028
|
+
"UND_ERR_SOCKET",
|
|
77029
|
+
"UND_ERR_REQ_CONTENT_LENGTH_MISMATCH",
|
|
77030
|
+
"UND_ERR_RES_CONTENT_LENGTH_MISMATCH",
|
|
77031
|
+
"CERT_HAS_EXPIRED",
|
|
77032
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
77033
|
+
"ERR_TLS_CERT_ALTNAME_INVALID",
|
|
77034
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE"
|
|
77035
|
+
]), ERROR_TYPES = /* @__PURE__ */ new Set([
|
|
77036
|
+
"AbortError",
|
|
77037
|
+
"TimeoutError",
|
|
77038
|
+
"TypeError",
|
|
77039
|
+
"SyntaxError",
|
|
77040
|
+
"AggregateError",
|
|
77041
|
+
"Error"
|
|
77042
|
+
]), UPLOAD_REASONS = /* @__PURE__ */ new Set([
|
|
77043
|
+
"IMAGE_TOO_LARGE",
|
|
77044
|
+
"IMAGE_TOO_MANY_PIXELS",
|
|
77045
|
+
"IMAGE_TYPE_MISMATCH",
|
|
77046
|
+
"INVALID_IMAGE",
|
|
77047
|
+
"FILE_NOT_STAGED",
|
|
77048
|
+
"FILE_UNAVAILABLE"
|
|
77049
|
+
]);
|
|
77050
|
+
function safeCauseCode(code) {
|
|
77051
|
+
return typeof code == "string" && (TIMEOUT_CODES.has(code) || UNREACHABLE_CODES.has(code) || OTHER_CODES.has(code)) ? code : void 0;
|
|
77052
|
+
}
|
|
77053
|
+
function requestErrorDetails(error62) {
|
|
77054
|
+
let errorType = error62 instanceof Error && ERROR_TYPES.has(error62.name) ? error62.name : "Error", current = error62;
|
|
77055
|
+
for (let depth = 0; depth < 4 && current instanceof Error; depth++) {
|
|
77056
|
+
let causeCode = safeCauseCode("code" in current ? current.code : void 0);
|
|
77057
|
+
if (causeCode !== void 0) return { errorType, causeCode };
|
|
77058
|
+
current = current.cause;
|
|
77059
|
+
}
|
|
77060
|
+
return { errorType };
|
|
77061
|
+
}
|
|
77062
|
+
function peerRequestError(error62) {
|
|
77063
|
+
let details = requestErrorDetails(error62);
|
|
77064
|
+
return details.errorType === "TimeoutError" || details.errorType === "AbortError" || details.causeCode !== void 0 && TIMEOUT_CODES.has(details.causeCode) ? new SessionRuntimeError("remote/timeout", "Remote peer request timed out", details) : details.causeCode !== void 0 && UNREACHABLE_CODES.has(details.causeCode) ? new SessionRuntimeError("remote/offline", "Remote peer is unreachable", details) : new SessionRuntimeError("remote/request-failed", "Remote peer request failed", details);
|
|
77065
|
+
}
|
|
77066
|
+
async function readPeerJson(response, invalidCode, invalidMessage) {
|
|
77067
|
+
try {
|
|
77068
|
+
return await response.json();
|
|
77069
|
+
} catch (error62) {
|
|
77070
|
+
throw error62 instanceof SyntaxError ? new SessionRuntimeError(invalidCode, invalidMessage, { errorType: "SyntaxError" }) : peerRequestError(error62);
|
|
77071
|
+
}
|
|
77072
|
+
}
|
|
77073
|
+
function uploadErrorDetails(error62) {
|
|
77074
|
+
if (!(error62 instanceof SessionRuntimeError))
|
|
77075
|
+
return { errorCode: "gateway/internal", ...requestErrorDetails(error62) };
|
|
77076
|
+
let { errorType, causeCode, reason, httpStatus } = error62.details;
|
|
77077
|
+
return {
|
|
77078
|
+
errorCode: /^[a-z][a-z0-9-]{0,31}\/[a-z][a-z0-9-]{0,47}$/u.test(error62.code) ? error62.code : "gateway/internal",
|
|
77079
|
+
errorType: typeof errorType == "string" && ERROR_TYPES.has(errorType) ? errorType : "RpcError",
|
|
77080
|
+
causeCode: safeCauseCode(causeCode),
|
|
77081
|
+
...typeof reason == "string" && UPLOAD_REASONS.has(reason) ? { reason } : {},
|
|
77082
|
+
...typeof httpStatus == "number" && Number.isInteger(httpStatus) && httpStatus >= 400 && httpStatus <= 599 ? { httpStatus } : {}
|
|
77083
|
+
};
|
|
77084
|
+
}
|
|
77085
|
+
|
|
77010
77086
|
// packages/web-server/src/peer-host-client.ts
|
|
77011
77087
|
var DEFAULT_STREAM_IDLE_TIMEOUT_MS = 45e3;
|
|
77012
77088
|
function isRawBodyInit(body) {
|
|
@@ -77028,7 +77104,7 @@ async function peerFetch(record6, path7, init = {}) {
|
|
|
77028
77104
|
...init.duplex === void 0 ? {} : { duplex: init.duplex },
|
|
77029
77105
|
...signal === void 0 ? {} : { signal }
|
|
77030
77106
|
}, res = await fetch(record6.origin + path7, requestInit);
|
|
77031
|
-
if (res.ok) return res;
|
|
77107
|
+
if (res.ok || res.status === 304 && headers2.has("if-none-match")) return res;
|
|
77032
77108
|
let failure3 = await res.json().then((payload) => {
|
|
77033
77109
|
if (!payload || typeof payload != "object" || !("error" in payload)) return;
|
|
77034
77110
|
let err5 = payload.error;
|
|
@@ -77038,7 +77114,9 @@ async function peerFetch(record6, path7, init = {}) {
|
|
|
77038
77114
|
message: err5.message,
|
|
77039
77115
|
code: "code" in err5 && typeof err5.code == "number" ? err5.code : void 0
|
|
77040
77116
|
};
|
|
77041
|
-
}).catch(() => {
|
|
77117
|
+
}).catch((error62) => {
|
|
77118
|
+
if (!(error62 instanceof SyntaxError))
|
|
77119
|
+
throw error62;
|
|
77042
77120
|
});
|
|
77043
77121
|
throw res.status === 401 || res.status === 403 && !failure3?.message ? new SessionRuntimeError("remote/auth-error", "Remote peer rejected the access token", {
|
|
77044
77122
|
httpStatus: res.status
|
|
@@ -77051,7 +77129,7 @@ async function peerFetch(record6, path7, init = {}) {
|
|
|
77051
77129
|
}
|
|
77052
77130
|
);
|
|
77053
77131
|
} catch (err5) {
|
|
77054
|
-
throw err5 instanceof SessionRuntimeError ? err5 :
|
|
77132
|
+
throw err5 instanceof SessionRuntimeError ? err5 : peerRequestError(signal?.aborted ? signal.reason : err5);
|
|
77055
77133
|
} finally {
|
|
77056
77134
|
timer !== null && clearTimeout(timer);
|
|
77057
77135
|
}
|
|
@@ -77285,12 +77363,11 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77285
77363
|
async post(route, body) {
|
|
77286
77364
|
if (this.state !== "connected")
|
|
77287
77365
|
throw new SessionRuntimeError("remote/offline", "Remote peer is not connected");
|
|
77288
|
-
let res = await this.fetch(`/api/ch/v1/${route}`, "POST", body), payload
|
|
77289
|
-
|
|
77290
|
-
|
|
77291
|
-
|
|
77292
|
-
|
|
77293
|
-
}
|
|
77366
|
+
let res = await this.fetch(`/api/ch/v1/${route}`, "POST", body), payload = await readPeerJson(
|
|
77367
|
+
res,
|
|
77368
|
+
"remote/read-failed",
|
|
77369
|
+
"Remote peer returned invalid JSON"
|
|
77370
|
+
);
|
|
77294
77371
|
if (!payload || typeof payload != "object" || !("result" in payload))
|
|
77295
77372
|
throw new SessionRuntimeError("remote/read-failed", "Remote peer response missing result");
|
|
77296
77373
|
let result = payload.result;
|
|
@@ -81187,7 +81264,7 @@ function invalid(reason, message2) {
|
|
|
81187
81264
|
function digest(bytes) {
|
|
81188
81265
|
return createHash4("sha256").update(bytes).digest("hex");
|
|
81189
81266
|
}
|
|
81190
|
-
function
|
|
81267
|
+
function inspectImageHeader(bytes, mediaType) {
|
|
81191
81268
|
if (!bytes.length) return invalid("INVALID_IMAGE", "Image is empty.");
|
|
81192
81269
|
if (bytes.length > WEB_IMAGE_LIMITS.maxImageBytes)
|
|
81193
81270
|
return invalid("IMAGE_TOO_LARGE", "Image exceeds 50 MiB.");
|
|
@@ -81205,11 +81282,10 @@ function inspectImage(bytes, mediaType) {
|
|
|
81205
81282
|
if (mediaType && mediaType !== actual)
|
|
81206
81283
|
return invalid("IMAGE_TYPE_MISMATCH", "Image bytes do not match the declared type.");
|
|
81207
81284
|
let { width, height } = size;
|
|
81208
|
-
|
|
81209
|
-
|
|
81210
|
-
|
|
81211
|
-
|
|
81212
|
-
let leaf = `${digest(bytes)}.${size.type}`;
|
|
81285
|
+
return !Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width <= 0 || height <= 0 ? invalid("INVALID_IMAGE", "Image dimensions are invalid.") : width * height > WEB_IMAGE_LIMITS.maxImagePixels ? invalid("IMAGE_TOO_MANY_PIXELS", "Image exceeds 64 million pixels.") : { mediaType: actual, width, height, extension: size.type };
|
|
81286
|
+
}
|
|
81287
|
+
function inspectImage(bytes, mediaType) {
|
|
81288
|
+
let { mediaType: actual, width, height, extension: extension3 } = inspectImageHeader(bytes, mediaType), leaf = `${digest(bytes)}.${extension3}`;
|
|
81213
81289
|
return {
|
|
81214
81290
|
bytes,
|
|
81215
81291
|
leaf,
|
|
@@ -83076,6 +83152,109 @@ async function compressResponse(body, contentType, acceptEncoding, cacheKey) {
|
|
|
83076
83152
|
return compressed === void 0 && (compressed = encoding === "br" ? brotliAsync(body, { params: { [constants3.BROTLI_PARAM_QUALITY]: 5 } }) : gzipAsync(body, { level: 6 }), key !== void 0 && (compressedAssets.set(key, compressed), compressedAssets.size > 64 && compressedAssets.clear())), headers2["content-encoding"] = encoding, { body: await compressed, headers: headers2 };
|
|
83077
83153
|
}
|
|
83078
83154
|
|
|
83155
|
+
// packages/web-server/src/peer-image-http.ts
|
|
83156
|
+
import { Readable } from "node:stream";
|
|
83157
|
+
import { pipeline } from "node:stream/promises";
|
|
83158
|
+
|
|
83159
|
+
// packages/web-server/src/http-content-length.ts
|
|
83160
|
+
function parseContentLength(value) {
|
|
83161
|
+
if (value == null || !/^\d+$/u.test(value)) return;
|
|
83162
|
+
let length = Number(value);
|
|
83163
|
+
return Number.isSafeInteger(length) ? length : void 0;
|
|
83164
|
+
}
|
|
83165
|
+
|
|
83166
|
+
// packages/web-server/src/peer-image-http.ts
|
|
83167
|
+
var PEER_IMAGE_SECURITY_HEADERS = {
|
|
83168
|
+
"X-Content-Type-Options": "nosniff",
|
|
83169
|
+
"Content-Security-Policy": "sandbox; default-src 'none'"
|
|
83170
|
+
};
|
|
83171
|
+
function peerImageCacheHeaders(etag) {
|
|
83172
|
+
return {
|
|
83173
|
+
...PEER_IMAGE_SECURITY_HEADERS,
|
|
83174
|
+
"Cache-Control": "private, max-age=300, must-revalidate",
|
|
83175
|
+
Vary: "Authorization, Cookie",
|
|
83176
|
+
...etag === void 0 ? {} : { ETag: etag }
|
|
83177
|
+
};
|
|
83178
|
+
}
|
|
83179
|
+
function peerImageETag(value) {
|
|
83180
|
+
return value && /^(?:W\/)?"[a-z0-9._:-]{1,128}"$/iu.test(value) ? value : void 0;
|
|
83181
|
+
}
|
|
83182
|
+
function matchesImageETag(condition, etag) {
|
|
83183
|
+
let tag = etag.replace(/^W\//u, "");
|
|
83184
|
+
return condition?.trim() === "*" || condition?.split(",").some((value) => value.trim().replace(/^W\//u, "") === tag) === !0;
|
|
83185
|
+
}
|
|
83186
|
+
function imageTooLarge() {
|
|
83187
|
+
return new SessionRuntimeError("session/attachment-invalid", "Image exceeds 50 MiB.", {
|
|
83188
|
+
reason: "IMAGE_TOO_LARGE"
|
|
83189
|
+
});
|
|
83190
|
+
}
|
|
83191
|
+
function peerImageLength(response) {
|
|
83192
|
+
let value = response.headers.get("content-length");
|
|
83193
|
+
if (Number(value) > WEB_IMAGE_LIMITS.maxImageBytes) throw imageTooLarge();
|
|
83194
|
+
return parseContentLength(value);
|
|
83195
|
+
}
|
|
83196
|
+
async function* readImageChunks(response) {
|
|
83197
|
+
let reader = response.body?.getReader();
|
|
83198
|
+
if (!reader) return;
|
|
83199
|
+
let size = 0;
|
|
83200
|
+
try {
|
|
83201
|
+
for (peerImageLength(response); ; ) {
|
|
83202
|
+
let { done, value } = await reader.read();
|
|
83203
|
+
if (done) return;
|
|
83204
|
+
if (size += value.byteLength, size > WEB_IMAGE_LIMITS.maxImageBytes) throw imageTooLarge();
|
|
83205
|
+
yield Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
83206
|
+
}
|
|
83207
|
+
} finally {
|
|
83208
|
+
await reader.cancel().catch(() => {
|
|
83209
|
+
}), reader.releaseLock();
|
|
83210
|
+
}
|
|
83211
|
+
}
|
|
83212
|
+
async function readPeerImageBytes(response) {
|
|
83213
|
+
let parts = [];
|
|
83214
|
+
for await (let chunk of readImageChunks(response)) parts.push(chunk);
|
|
83215
|
+
return Buffer.concat(parts);
|
|
83216
|
+
}
|
|
83217
|
+
var IMAGE_PREFIX_BYTES = 64 * 1024;
|
|
83218
|
+
async function servePeerImageBody(upstream, response, etag, length) {
|
|
83219
|
+
let encoding = upstream.headers.get("content-encoding")?.toLowerCase(), canStream = length !== void 0 && length > IMAGE_PREFIX_BYTES && (!encoding || encoding === "identity"), chunks = readImageChunks(upstream), parts = [], size = 0;
|
|
83220
|
+
try {
|
|
83221
|
+
for (; ; ) {
|
|
83222
|
+
let next = await chunks.next();
|
|
83223
|
+
if (next.done) break;
|
|
83224
|
+
if (parts.push(next.value), size += next.value.length, !canStream || size < IMAGE_PREFIX_BYTES || size >= length) continue;
|
|
83225
|
+
let mediaType2;
|
|
83226
|
+
try {
|
|
83227
|
+
({ mediaType: mediaType2 } = inspectImageHeader(Buffer.concat(parts, size)));
|
|
83228
|
+
} catch (error62) {
|
|
83229
|
+
if (error62 instanceof SessionRuntimeError && "reason" in error62.details && error62.details.reason === "INVALID_IMAGE")
|
|
83230
|
+
break;
|
|
83231
|
+
throw error62;
|
|
83232
|
+
}
|
|
83233
|
+
if (response.destroyed) return;
|
|
83234
|
+
response.writeHead(200, {
|
|
83235
|
+
...peerImageCacheHeaders(etag),
|
|
83236
|
+
"Content-Type": mediaType2,
|
|
83237
|
+
"Content-Length": String(length)
|
|
83238
|
+
});
|
|
83239
|
+
async function* body() {
|
|
83240
|
+
yield* parts, yield* chunks;
|
|
83241
|
+
}
|
|
83242
|
+
await pipeline(Readable.from(body(), { objectMode: !1 }), response);
|
|
83243
|
+
return;
|
|
83244
|
+
}
|
|
83245
|
+
for await (let chunk of chunks) parts.push(chunk);
|
|
83246
|
+
let bytes = Buffer.concat(parts), { mediaType } = inspectImageHeader(bytes);
|
|
83247
|
+
if (response.destroyed) return;
|
|
83248
|
+
response.writeHead(200, {
|
|
83249
|
+
...peerImageCacheHeaders(etag),
|
|
83250
|
+
"Content-Type": mediaType,
|
|
83251
|
+
"Content-Length": String(bytes.length)
|
|
83252
|
+
}), response.end(bytes);
|
|
83253
|
+
} finally {
|
|
83254
|
+
await chunks.return(void 0);
|
|
83255
|
+
}
|
|
83256
|
+
}
|
|
83257
|
+
|
|
83079
83258
|
// packages/web-server/src/peer-attachments-http.ts
|
|
83080
83259
|
var MAX_PROMPT_BODY_BYTES = 16 * 1024 * 1024, PEER_UPLOAD_SCOPE_PREFIX = "peer-upload:";
|
|
83081
83260
|
async function sendJson(request3, response, status, body) {
|
|
@@ -83095,8 +83274,7 @@ function sendPlain(response, status, message2, isHead = !1) {
|
|
|
83095
83274
|
response.writeHead(status, {
|
|
83096
83275
|
"content-type": "text/plain; charset=utf-8",
|
|
83097
83276
|
"cache-control": "private, no-store",
|
|
83098
|
-
|
|
83099
|
-
"content-security-policy": "sandbox; default-src 'none'"
|
|
83277
|
+
...PEER_IMAGE_SECURITY_HEADERS
|
|
83100
83278
|
}).end(isHead ? void 0 : message2);
|
|
83101
83279
|
}
|
|
83102
83280
|
function isPlainObject2(value) {
|
|
@@ -83406,12 +83584,15 @@ async function handleFile(request3, response, deps) {
|
|
|
83406
83584
|
sendPlain(response, 404, "image unavailable", isHead);
|
|
83407
83585
|
return;
|
|
83408
83586
|
}
|
|
83587
|
+
let etag = `"${image.leaf}"`, headers2 = peerImageCacheHeaders(etag);
|
|
83588
|
+
if (matchesImageETag(request3.headers["if-none-match"], etag)) {
|
|
83589
|
+
response.writeHead(304, headers2).end();
|
|
83590
|
+
return;
|
|
83591
|
+
}
|
|
83409
83592
|
response.writeHead(200, {
|
|
83593
|
+
...headers2,
|
|
83410
83594
|
"Content-Type": image.ref.mediaType,
|
|
83411
|
-
"Content-Length": String(image.bytes.length)
|
|
83412
|
-
"Cache-Control": "private, no-store",
|
|
83413
|
-
"X-Content-Type-Options": "nosniff",
|
|
83414
|
-
"Content-Security-Policy": "sandbox; default-src 'none'"
|
|
83595
|
+
"Content-Length": String(image.bytes.length)
|
|
83415
83596
|
}), response.end(isHead ? void 0 : image.bytes);
|
|
83416
83597
|
}
|
|
83417
83598
|
async function servePeerAttachments(request3, response, route, deps) {
|
|
@@ -83912,8 +84093,8 @@ async function startPeerDelegationBridge(options) {
|
|
|
83912
84093
|
|
|
83913
84094
|
// packages/web-server/src/peer-workspace-files-http.ts
|
|
83914
84095
|
import { extname as extname6, posix as posix3, win32 as win327 } from "node:path";
|
|
83915
|
-
import { Readable as
|
|
83916
|
-
import { pipeline } from "node:stream/promises";
|
|
84096
|
+
import { Readable as Readable4 } from "node:stream";
|
|
84097
|
+
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
83917
84098
|
|
|
83918
84099
|
// apps/web-ui/packages/host/dsh-web-backend/src/index.ts
|
|
83919
84100
|
import { stat as stat9 } from "node:fs/promises";
|
|
@@ -89029,7 +89210,7 @@ var clientRequestSchema = external_exports.object({
|
|
|
89029
89210
|
]);
|
|
89030
89211
|
|
|
89031
89212
|
// apps/web-ui/packages/client/connection/src/http-bridge.ts
|
|
89032
|
-
import { Readable } from "node:stream";
|
|
89213
|
+
import { Readable as Readable2 } from "node:stream";
|
|
89033
89214
|
var DEFAULT_MAX_REQUEST_BODY_BYTES = 300 * 1024 * 1024;
|
|
89034
89215
|
async function bridge(req, res, apiHandler, maxRequestBodyBytes = DEFAULT_MAX_REQUEST_BODY_BYTES) {
|
|
89035
89216
|
let abort = new AbortController();
|
|
@@ -89064,7 +89245,7 @@ async function bridge(req, res, apiHandler, maxRequestBodyBytes = DEFAULT_MAX_RE
|
|
|
89064
89245
|
request3 = new Request(url2, {
|
|
89065
89246
|
method: method2,
|
|
89066
89247
|
headers: headers2,
|
|
89067
|
-
body:
|
|
89248
|
+
body: Readable2.toWeb(req),
|
|
89068
89249
|
signal: abort.signal,
|
|
89069
89250
|
duplex: "half"
|
|
89070
89251
|
});
|
|
@@ -89356,7 +89537,7 @@ import * as sysPath2 from "path";
|
|
|
89356
89537
|
|
|
89357
89538
|
// node_modules/readdirp/esm/index.js
|
|
89358
89539
|
import { stat as stat4, lstat as lstat4, readdir as readdir3, realpath as realpath3 } from "node:fs/promises";
|
|
89359
|
-
import { Readable as
|
|
89540
|
+
import { Readable as Readable3 } from "node:stream";
|
|
89360
89541
|
import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from "node:path";
|
|
89361
89542
|
var EntryTypes = {
|
|
89362
89543
|
FILE_TYPE: "files",
|
|
@@ -89401,7 +89582,7 @@ var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR", NORMAL_FLOW_ERRORS = /* @
|
|
|
89401
89582
|
return (entry) => trItems.some((f) => entry.basename === f);
|
|
89402
89583
|
}
|
|
89403
89584
|
return emptyFn;
|
|
89404
|
-
}, ReaddirpStream = class extends
|
|
89585
|
+
}, ReaddirpStream = class extends Readable3 {
|
|
89405
89586
|
constructor(options = {}) {
|
|
89406
89587
|
super({
|
|
89407
89588
|
objectMode: !0,
|
|
@@ -100945,7 +101126,7 @@ async function sendTypertMultipart(response, rpcId, value, bytes, signal) {
|
|
|
100945
101126
|
response.end();
|
|
100946
101127
|
return;
|
|
100947
101128
|
}
|
|
100948
|
-
await
|
|
101129
|
+
await pipeline2(Readable4.fromWeb(encoded.body), response);
|
|
100949
101130
|
}
|
|
100950
101131
|
function sendPlain2(response, status, message2, isHead = !1) {
|
|
100951
101132
|
response.destroyed || response.writableEnded || response.headersSent || response.writeHead(status, {
|
|
@@ -101295,7 +101476,7 @@ async function handleDownload(request3, response, deps, signal) {
|
|
|
101295
101476
|
response.end();
|
|
101296
101477
|
return;
|
|
101297
101478
|
}
|
|
101298
|
-
await
|
|
101479
|
+
await pipeline2(
|
|
101299
101480
|
opened.file.handle.createReadStream({
|
|
101300
101481
|
autoClose: !1,
|
|
101301
101482
|
end: Math.max(0, opened.file.size - 1)
|
|
@@ -101389,11 +101570,7 @@ async function servePeerWorkspaceFiles(request3, response, route, deps) {
|
|
|
101389
101570
|
// packages/web-server/src/remote-peer-attachments.ts
|
|
101390
101571
|
import { createHash as createHash8 } from "node:crypto";
|
|
101391
101572
|
import { posix as posix4 } from "node:path";
|
|
101392
|
-
var DEFAULT_REQUEST_TIMEOUT_MS = 6e4, DEFAULT_UPLOAD_TIMEOUT_MS = 12e4
|
|
101393
|
-
"Cache-Control": "private, no-store",
|
|
101394
|
-
"X-Content-Type-Options": "nosniff",
|
|
101395
|
-
"Content-Security-Policy": "sandbox; default-src 'none'"
|
|
101396
|
-
};
|
|
101573
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 6e4, DEFAULT_UPLOAD_TIMEOUT_MS = 12e4;
|
|
101397
101574
|
function sha256Hex(value) {
|
|
101398
101575
|
return createHash8("sha256").update(value).digest("hex");
|
|
101399
101576
|
}
|
|
@@ -101443,34 +101620,6 @@ function extractPeerHttpStatus(error62) {
|
|
|
101443
101620
|
let status = error62.details.httpStatus;
|
|
101444
101621
|
return typeof status == "number" && Number.isInteger(status) ? status : void 0;
|
|
101445
101622
|
}
|
|
101446
|
-
async function readBoundedBytes(response, maxBytes) {
|
|
101447
|
-
let contentLength = response.headers.get("content-length");
|
|
101448
|
-
if (contentLength !== null) {
|
|
101449
|
-
let declared = Number(contentLength);
|
|
101450
|
-
if (Number.isFinite(declared) && declared > maxBytes)
|
|
101451
|
-
throw await response.body?.cancel().catch(() => {
|
|
101452
|
-
}), new SessionRuntimeError("session/attachment-invalid", "Image exceeds 50 MiB.", {
|
|
101453
|
-
reason: "IMAGE_TOO_LARGE"
|
|
101454
|
-
});
|
|
101455
|
-
}
|
|
101456
|
-
if (!response.body) return Buffer.alloc(0);
|
|
101457
|
-
let reader = response.body.getReader(), parts = [], total = 0;
|
|
101458
|
-
try {
|
|
101459
|
-
for (; ; ) {
|
|
101460
|
-
let { done, value } = await reader.read();
|
|
101461
|
-
if (done) break;
|
|
101462
|
-
if (total += value.byteLength, total > maxBytes)
|
|
101463
|
-
throw await reader.cancel().catch(() => {
|
|
101464
|
-
}), new SessionRuntimeError("session/attachment-invalid", "Image exceeds 50 MiB.", {
|
|
101465
|
-
reason: "IMAGE_TOO_LARGE"
|
|
101466
|
-
});
|
|
101467
|
-
parts.push(Buffer.from(value));
|
|
101468
|
-
}
|
|
101469
|
-
} finally {
|
|
101470
|
-
reader.releaseLock();
|
|
101471
|
-
}
|
|
101472
|
-
return Buffer.concat(parts, total);
|
|
101473
|
-
}
|
|
101474
101623
|
function decodeDataImageUrl(url2) {
|
|
101475
101624
|
if (url2.length > Math.ceil(WEB_IMAGE_LIMITS.maxImageBytes / 3) * 4 + 64)
|
|
101476
101625
|
throw new SessionRuntimeError("session/attachment-invalid", "Image exceeds 50 MiB.", {
|
|
@@ -101485,14 +101634,17 @@ function decodeDataImageUrl(url2) {
|
|
|
101485
101634
|
return inspectImage(bytes, match[1]);
|
|
101486
101635
|
}
|
|
101487
101636
|
function writeProxyError(response, status, message2, isHead) {
|
|
101488
|
-
if (response.
|
|
101489
|
-
response.
|
|
101490
|
-
|
|
101637
|
+
if (!(response.destroyed || response.writableEnded)) {
|
|
101638
|
+
if (response.headersSent) {
|
|
101639
|
+
response.destroy();
|
|
101640
|
+
return;
|
|
101641
|
+
}
|
|
101642
|
+
response.writeHead(status, {
|
|
101643
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
101644
|
+
"Cache-Control": "private, no-store",
|
|
101645
|
+
...PEER_IMAGE_SECURITY_HEADERS
|
|
101646
|
+
}).end(isHead ? void 0 : message2);
|
|
101491
101647
|
}
|
|
101492
|
-
response.writeHead(status, {
|
|
101493
|
-
"Content-Type": "text/plain; charset=utf-8",
|
|
101494
|
-
...SAFE_PROXY_HEADERS
|
|
101495
|
-
}).end(isHead ? void 0 : message2);
|
|
101496
101648
|
}
|
|
101497
101649
|
function findProjectedAttachment(view, eventType, attachmentId) {
|
|
101498
101650
|
for (let event of view.log.events) {
|
|
@@ -101520,7 +101672,7 @@ var RemotePeerAttachments = class {
|
|
|
101520
101672
|
);
|
|
101521
101673
|
return peer;
|
|
101522
101674
|
}
|
|
101523
|
-
async upload(peer, target2, chunks, name2, imageMediaType) {
|
|
101675
|
+
async upload(peer, target2, chunks, name2, imageMediaType, contentLength) {
|
|
101524
101676
|
let activePeer = this.requireSupported(peer), query = new URLSearchParams();
|
|
101525
101677
|
if ("threadId" in target2) {
|
|
101526
101678
|
if (!target2.threadId)
|
|
@@ -101537,21 +101689,19 @@ var RemotePeerAttachments = class {
|
|
|
101537
101689
|
`/api/peer/v1/uploads?${query.toString()}`,
|
|
101538
101690
|
{
|
|
101539
101691
|
method: "POST",
|
|
101540
|
-
headers: {
|
|
101692
|
+
headers: {
|
|
101693
|
+
"content-type": "application/octet-stream",
|
|
101694
|
+
...contentLength === void 0 ? {} : { "content-length": String(contentLength) }
|
|
101695
|
+
},
|
|
101541
101696
|
body: toReadableStream(chunks),
|
|
101542
101697
|
duplex: "half",
|
|
101543
101698
|
timeoutMs: this.uploadTimeoutMs
|
|
101544
101699
|
}
|
|
101545
|
-
), payload
|
|
101546
|
-
|
|
101547
|
-
|
|
101548
|
-
|
|
101549
|
-
|
|
101550
|
-
"remote/request-failed",
|
|
101551
|
-
"Remote peer returned an invalid upload response"
|
|
101552
|
-
);
|
|
101553
|
-
}
|
|
101554
|
-
let parsed = remotePeerUploadResultSchema.safeParse(payload);
|
|
101700
|
+
), payload = await readPeerJson(
|
|
101701
|
+
response,
|
|
101702
|
+
"remote/request-failed",
|
|
101703
|
+
"Remote peer returned an invalid upload response"
|
|
101704
|
+
), parsed = remotePeerUploadResultSchema.safeParse(payload);
|
|
101555
101705
|
if (!parsed.success)
|
|
101556
101706
|
throw new SessionRuntimeError(
|
|
101557
101707
|
"remote/request-failed",
|
|
@@ -101582,16 +101732,11 @@ var RemotePeerAttachments = class {
|
|
|
101582
101732
|
method: "POST",
|
|
101583
101733
|
body: validated.data,
|
|
101584
101734
|
timeoutMs: this.requestTimeoutMs
|
|
101585
|
-
}), payload
|
|
101586
|
-
|
|
101587
|
-
|
|
101588
|
-
|
|
101589
|
-
|
|
101590
|
-
"remote/request-failed",
|
|
101591
|
-
"Remote peer returned an invalid prompt response"
|
|
101592
|
-
);
|
|
101593
|
-
}
|
|
101594
|
-
let parsed = remotePeerPromptResultSchema.safeParse(payload);
|
|
101735
|
+
}), payload = await readPeerJson(
|
|
101736
|
+
response,
|
|
101737
|
+
"remote/request-failed",
|
|
101738
|
+
"Remote peer returned an invalid prompt response"
|
|
101739
|
+
), parsed = remotePeerPromptResultSchema.safeParse(payload);
|
|
101595
101740
|
if (!parsed.success)
|
|
101596
101741
|
throw new SessionRuntimeError(
|
|
101597
101742
|
"remote/request-failed",
|
|
@@ -101659,7 +101804,7 @@ var RemotePeerAttachments = class {
|
|
|
101659
101804
|
}
|
|
101660
101805
|
throw error62;
|
|
101661
101806
|
}
|
|
101662
|
-
let bytes = await
|
|
101807
|
+
let bytes = await readPeerImageBytes(response), image;
|
|
101663
101808
|
try {
|
|
101664
101809
|
image = inspectImage(bytes);
|
|
101665
101810
|
} catch (error62) {
|
|
@@ -101713,63 +101858,49 @@ var RemotePeerAttachments = class {
|
|
|
101713
101858
|
response.writableEnded || abort.abort();
|
|
101714
101859
|
};
|
|
101715
101860
|
response.once("close", onClose);
|
|
101716
|
-
let query = new URLSearchParams({ threadId, path: path7 });
|
|
101861
|
+
let query = new URLSearchParams({ threadId, path: path7 }), condition = request3.headers["if-none-match"];
|
|
101717
101862
|
try {
|
|
101718
101863
|
let upstream = await peerFetch(peer.record, `/api/peer/v1/file?${query.toString()}`, {
|
|
101719
101864
|
method: isHead ? "HEAD" : "GET",
|
|
101865
|
+
headers: {
|
|
101866
|
+
"accept-encoding": "identity",
|
|
101867
|
+
...condition === void 0 ? {} : { "if-none-match": condition }
|
|
101868
|
+
},
|
|
101720
101869
|
signal: abort.signal,
|
|
101721
101870
|
timeoutMs: this.requestTimeoutMs
|
|
101722
|
-
}),
|
|
101723
|
-
if (
|
|
101871
|
+
}), etag = peerImageETag(upstream.headers.get("etag"));
|
|
101872
|
+
if (upstream.status === 304 && etag && matchesImageETag(condition, etag)) {
|
|
101873
|
+
response.writeHead(304, peerImageCacheHeaders(etag)).end();
|
|
101874
|
+
return;
|
|
101875
|
+
}
|
|
101876
|
+
let remoteType = upstream.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
101877
|
+
if (upstream.status !== 200 || !WEB_IMAGE_LIMITS.mediaTypes.includes(remoteType)) {
|
|
101724
101878
|
await upstream.body?.cancel().catch(() => {
|
|
101725
101879
|
}), writeProxyError(response, 502, "remote peer returned non-image response", isHead);
|
|
101726
101880
|
return;
|
|
101727
101881
|
}
|
|
101882
|
+
let length = peerImageLength(upstream);
|
|
101728
101883
|
if (isHead) {
|
|
101729
|
-
let rawLength = upstream.headers.get("content-length"), parsedLength = rawLength !== null ? Number(rawLength) : void 0;
|
|
101730
|
-
if (parsedLength !== void 0 && Number.isFinite(parsedLength) && parsedLength > WEB_IMAGE_LIMITS.maxImageBytes) {
|
|
101731
|
-
writeProxyError(response, 413, "image too large", !0);
|
|
101732
|
-
return;
|
|
101733
|
-
}
|
|
101734
101884
|
response.writeHead(200, {
|
|
101885
|
+
...peerImageCacheHeaders(etag),
|
|
101735
101886
|
"Content-Type": remoteType,
|
|
101736
|
-
...
|
|
101737
|
-
|
|
101738
|
-
}), response.end();
|
|
101887
|
+
...length === void 0 ? {} : { "Content-Length": String(length) }
|
|
101888
|
+
}).end();
|
|
101739
101889
|
return;
|
|
101740
101890
|
}
|
|
101741
|
-
|
|
101742
|
-
|
|
101743
|
-
|
|
101744
|
-
|
|
101745
|
-
|
|
101746
|
-
|
|
101891
|
+
await servePeerImageBody(upstream, response, etag, length);
|
|
101892
|
+
} catch (error62) {
|
|
101893
|
+
if (response.writableEnded || response.destroyed) return;
|
|
101894
|
+
if (error62 instanceof SessionRuntimeError) {
|
|
101895
|
+
let reason = "reason" in error62.details ? error62.details.reason : void 0;
|
|
101896
|
+
if (reason === "IMAGE_TOO_LARGE" || reason === "IMAGE_TOO_MANY_PIXELS") {
|
|
101897
|
+
writeProxyError(response, 413, "image too large", isHead);
|
|
101747
101898
|
return;
|
|
101748
101899
|
}
|
|
101749
|
-
|
|
101750
|
-
|
|
101751
|
-
}
|
|
101752
|
-
let image;
|
|
101753
|
-
try {
|
|
101754
|
-
image = inspectImage(bytes);
|
|
101755
|
-
} catch (error62) {
|
|
101756
|
-
let reason = error62 instanceof SessionRuntimeError && "reason" in error62.details ? error62.details.reason : void 0;
|
|
101757
|
-
if (reason === "IMAGE_TOO_LARGE" || reason === "IMAGE_TOO_MANY_PIXELS") {
|
|
101758
|
-
writeProxyError(response, 413, "image too large", !1);
|
|
101900
|
+
if (error62.code === "session/attachment-invalid") {
|
|
101901
|
+
writeProxyError(response, 502, "remote peer returned invalid image", isHead);
|
|
101759
101902
|
return;
|
|
101760
101903
|
}
|
|
101761
|
-
writeProxyError(response, 502, "remote peer returned invalid image", !1);
|
|
101762
|
-
return;
|
|
101763
|
-
}
|
|
101764
|
-
if (response.writableEnded || response.destroyed) return;
|
|
101765
|
-
response.writeHead(200, {
|
|
101766
|
-
"Content-Type": image.ref.mediaType,
|
|
101767
|
-
"Content-Length": String(image.bytes.length),
|
|
101768
|
-
...SAFE_PROXY_HEADERS
|
|
101769
|
-
}), response.end(image.bytes);
|
|
101770
|
-
} catch (error62) {
|
|
101771
|
-
if (response.writableEnded || response.destroyed) return;
|
|
101772
|
-
if (error62 instanceof SessionRuntimeError) {
|
|
101773
101904
|
let status = extractPeerHttpStatus(error62);
|
|
101774
101905
|
if (status !== void 0 && status >= 400 && status < 500) {
|
|
101775
101906
|
writeProxyError(response, status, status === 404 ? "image unavailable" : status === 413 ? "image too large" : "request rejected", isHead);
|
|
@@ -101778,7 +101909,7 @@ var RemotePeerAttachments = class {
|
|
|
101778
101909
|
}
|
|
101779
101910
|
writeProxyError(response, 502, "remote peer unavailable", isHead);
|
|
101780
101911
|
} finally {
|
|
101781
|
-
response.off("close", onClose);
|
|
101912
|
+
abort.abort(), response.off("close", onClose);
|
|
101782
101913
|
}
|
|
101783
101914
|
}
|
|
101784
101915
|
};
|
|
@@ -103038,7 +103169,7 @@ var RemoteSessions = class {
|
|
|
103038
103169
|
});
|
|
103039
103170
|
}
|
|
103040
103171
|
}
|
|
103041
|
-
async uploadFile(id2, chunks, name2, imageMediaType) {
|
|
103172
|
+
async uploadFile(id2, chunks, name2, imageMediaType, contentLength) {
|
|
103042
103173
|
if (this.closed) throw new SessionRuntimeError("remote/offline", "Remote session gateway is closed");
|
|
103043
103174
|
let draft = this.drafts.get(id2);
|
|
103044
103175
|
if (draft) {
|
|
@@ -103050,7 +103181,14 @@ var RemoteSessions = class {
|
|
|
103050
103181
|
"Remote peer does not support attachments."
|
|
103051
103182
|
);
|
|
103052
103183
|
let scope2 = draft.ensureUploadScope();
|
|
103053
|
-
return this.attachments.upload(
|
|
103184
|
+
return this.attachments.upload(
|
|
103185
|
+
peer2,
|
|
103186
|
+
{ scope: scope2 },
|
|
103187
|
+
chunks,
|
|
103188
|
+
name2,
|
|
103189
|
+
imageMediaType,
|
|
103190
|
+
contentLength
|
|
103191
|
+
);
|
|
103054
103192
|
}
|
|
103055
103193
|
id2 = draft.canonicalId;
|
|
103056
103194
|
}
|
|
@@ -103067,7 +103205,8 @@ var RemoteSessions = class {
|
|
|
103067
103205
|
{ threadId: identity2.threadId },
|
|
103068
103206
|
chunks,
|
|
103069
103207
|
name2,
|
|
103070
|
-
imageMediaType
|
|
103208
|
+
imageMediaType,
|
|
103209
|
+
contentLength
|
|
103071
103210
|
);
|
|
103072
103211
|
}
|
|
103073
103212
|
async servePeerFile(request3, response) {
|
|
@@ -104091,7 +104230,7 @@ var RemoteSessions = class {
|
|
|
104091
104230
|
}
|
|
104092
104231
|
return applyRemoteControls(current, history), current.epoch && this.loadUsage(id2, current, history, current.epoch), snapshot && !this.closed && current.online && current.view === history && this.peers?.source(current.identity.hostId) === source && (!current.epoch || current.epoch === snapshot.cursor.epoch) && (this.peerResetRevisions.get(current.identity.hostId) ?? 0) === startResetRevision && this.interactionsForPeer(current.identity.hostId, source).update(snapshot, id2), JSON.stringify(summary) !== before && this.events.emit("api-session/added", summary), this.events.emit("api-session/status", id2, summary.running), current.historyReadAt = Date.now(), history;
|
|
104093
104232
|
} catch (error62) {
|
|
104094
|
-
throw requireCurrent(),
|
|
104233
|
+
throw requireCurrent(), this.closed || (error62 instanceof SessionRuntimeError && error62.code === "remote/connection-changed" && this.clearPending(id2), current.historyError = {
|
|
104095
104234
|
code: error62 instanceof SessionRuntimeError ? error62.code : "remote/read-failed",
|
|
104096
104235
|
message: error62 instanceof Error ? error62.message : String(error62)
|
|
104097
104236
|
}, current.view?.log.setProjection("remoteHistoryError", current.historyError), this.events.emit("api-session/added", this.summary(id2, current))), error62;
|
|
@@ -104833,7 +104972,7 @@ var RemoteSessions = class {
|
|
|
104833
104972
|
};
|
|
104834
104973
|
|
|
104835
104974
|
// packages/web-server/src/remote-peer-workspace-files.ts
|
|
104836
|
-
var DEFAULT_RPC_TIMEOUT_MS = 3e4, DEFAULT_SEARCH_TIMEOUT_MS = 1e4, DEFAULT_OFFICE_RENDER_TIMEOUT_MS = 65e3, DEFAULT_DOWNLOAD_HANDSHAKE_TIMEOUT_MS = 3e4, DEFAULT_STREAM_IDLE_TIMEOUT_MS2 = 3e4, DEFAULT_MAX_JSON_RESPONSE_BYTES = 8 * 1024 * 1024, DEFAULT_MAX_SEARCH_RESPONSE_BYTES = 2 * 1024 * 1024, DEFAULT_MAX_CONCURRENT_PER_PEER = 8, DEFAULT_MAX_CONCURRENT_TOTAL = 24, REMOTE_SESSION_PREFIX = "web-remote:", REMOTE_CONTROL_PREFIX = "remote-control:",
|
|
104975
|
+
var DEFAULT_RPC_TIMEOUT_MS = 3e4, DEFAULT_SEARCH_TIMEOUT_MS = 1e4, DEFAULT_OFFICE_RENDER_TIMEOUT_MS = 65e3, DEFAULT_DOWNLOAD_HANDSHAKE_TIMEOUT_MS = 3e4, DEFAULT_STREAM_IDLE_TIMEOUT_MS2 = 3e4, DEFAULT_MAX_JSON_RESPONSE_BYTES = 8 * 1024 * 1024, DEFAULT_MAX_SEARCH_RESPONSE_BYTES = 2 * 1024 * 1024, DEFAULT_MAX_CONCURRENT_PER_PEER = 8, DEFAULT_MAX_CONCURRENT_TOTAL = 24, REMOTE_SESSION_PREFIX = "web-remote:", REMOTE_CONTROL_PREFIX = "remote-control:", SAFE_PROXY_HEADERS = {
|
|
104837
104976
|
"Cache-Control": "private, no-store",
|
|
104838
104977
|
"X-Content-Type-Options": "nosniff",
|
|
104839
104978
|
"Content-Security-Policy": "sandbox; default-src 'none'"
|
|
@@ -104879,7 +105018,7 @@ function writeTypertError(response, rpcId, code, message2, details = {}) {
|
|
|
104879
105018
|
function writePlainError(response, status, message2, isHead = !1) {
|
|
104880
105019
|
response.destroyed || response.writableEnded || response.headersSent || response.writeHead(status, {
|
|
104881
105020
|
"Content-Type": "text/plain; charset=utf-8",
|
|
104882
|
-
...
|
|
105021
|
+
...SAFE_PROXY_HEADERS
|
|
104883
105022
|
}).end(isHead ? void 0 : message2);
|
|
104884
105023
|
}
|
|
104885
105024
|
function isTypertServerResponseEnvelope(value) {
|
|
@@ -105451,7 +105590,7 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
105451
105590
|
"Content-Type": "application/octet-stream",
|
|
105452
105591
|
"Content-Disposition": encodeContentDisposition2(fileBaseName(path7)),
|
|
105453
105592
|
...parsedLength !== void 0 && Number.isSafeInteger(parsedLength) && parsedLength >= 0 ? { "Content-Length": String(parsedLength) } : {},
|
|
105454
|
-
...
|
|
105593
|
+
...SAFE_PROXY_HEADERS
|
|
105455
105594
|
};
|
|
105456
105595
|
return response.writeHead(200, headers2), isHead || upstream.body === null ? (response.end(), !0) : (await pipeWebStreamWithIdleTimeout(upstream.body, response, {
|
|
105457
105596
|
idleTimeoutMs: this.streamIdleTimeoutMs,
|
|
@@ -106039,7 +106178,7 @@ import { randomBytes as randomBytes4 } from "node:crypto";
|
|
|
106039
106178
|
import { constants as constants9 } from "node:fs";
|
|
106040
106179
|
import { open as open9, realpath as realpath6, stat as stat11 } from "node:fs/promises";
|
|
106041
106180
|
import { basename as basename10, isAbsolute as isAbsolute16, resolve as resolve11 } from "node:path";
|
|
106042
|
-
import { pipeline as
|
|
106181
|
+
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
106043
106182
|
var DOWNLOAD_TICKET_TTL_MS = 6e4, MAX_DOWNLOAD_TICKETS = 256, WorkspaceDownloadTickets = class {
|
|
106044
106183
|
constructor(now = Date.now) {
|
|
106045
106184
|
this.now = now;
|
|
@@ -106183,7 +106322,7 @@ async function downloadWorkspaceFile(request3, response, url2, workspace, grant,
|
|
|
106183
106322
|
"Content-Disposition": `attachment; filename="download"; filename*=UTF-8''${encoded}`,
|
|
106184
106323
|
"Content-Length": String(meta3.size),
|
|
106185
106324
|
"X-Content-Type-Options": "nosniff"
|
|
106186
|
-
}), request3.method === "HEAD" || meta3.size === 0 ? response.end() : await
|
|
106325
|
+
}), request3.method === "HEAD" || meta3.size === 0 ? response.end() : await pipeline3(
|
|
106187
106326
|
file3.createReadStream({ autoClose: !1, end: Math.max(0, meta3.size - 1) }),
|
|
106188
106327
|
response
|
|
106189
106328
|
);
|
|
@@ -143036,7 +143175,7 @@ function nativeProjectCommands(host, workspaces2, refresh, assignSession) {
|
|
|
143036
143175
|
// packages/web-server/src/ch-file-upload-http.ts
|
|
143037
143176
|
var REMOTE_SESSION_PREFIX2 = "web-remote:";
|
|
143038
143177
|
async function serveFileUpload(sessions2, request3, response, viaRelay = !1, remoteSessions2) {
|
|
143039
|
-
let started = performance.now(), timing = {}, sessionId, bytes = 0, firstByteMs, bodyEndMs, ok = !1, send = (status, body) => response.writeHead(status, {
|
|
143178
|
+
let started = performance.now(), timing = {}, sessionId, bytes = 0, firstByteMs, bodyEndMs, ok = !1, failure3, send = (status, body) => response.writeHead(status, {
|
|
143040
143179
|
"content-type": "application/json; charset=utf-8",
|
|
143041
143180
|
"cache-control": "no-store"
|
|
143042
143181
|
}).end(JSON.stringify(body));
|
|
@@ -143063,10 +143202,16 @@ async function serveFileUpload(sessions2, request3, response, viaRelay = !1, rem
|
|
|
143063
143202
|
for await (let chunk of request3.iterator({ destroyOnReturn: !1 }))
|
|
143064
143203
|
firstByteMs ??= performance.now() - started, bytes += chunk.byteLength, yield chunk;
|
|
143065
143204
|
bodyEndMs = performance.now() - started;
|
|
143066
|
-
}, name2 = url2.searchParams.get("name") ?? void 0, imageMediaType = url2.searchParams.get("imageMediaType") ?? void 0, value = isRemote ? await remoteSessions2?.uploadFile(
|
|
143205
|
+
}, name2 = url2.searchParams.get("name") ?? void 0, imageMediaType = url2.searchParams.get("imageMediaType") ?? void 0, value = isRemote ? await remoteSessions2?.uploadFile(
|
|
143206
|
+
id2,
|
|
143207
|
+
chunks(),
|
|
143208
|
+
name2,
|
|
143209
|
+
imageMediaType,
|
|
143210
|
+
parseContentLength(request3.headers["content-length"])
|
|
143211
|
+
) : await sessions2?.uploadFile(id2, chunks(), name2, imageMediaType, timing);
|
|
143067
143212
|
ok = !0, send(200, { ok: !0, value });
|
|
143068
143213
|
} catch (error62) {
|
|
143069
|
-
send(200, {
|
|
143214
|
+
failure3 = uploadErrorDetails(error62), send(200, {
|
|
143070
143215
|
ok: !1,
|
|
143071
143216
|
error: {
|
|
143072
143217
|
code: error62 instanceof SessionRuntimeError ? error62.code : "gateway/internal",
|
|
@@ -143084,6 +143229,7 @@ async function serveFileUpload(sessions2, request3, response, viaRelay = !1, rem
|
|
|
143084
143229
|
viaRelay,
|
|
143085
143230
|
httpVersion: request3.httpVersion,
|
|
143086
143231
|
ok,
|
|
143232
|
+
...failure3,
|
|
143087
143233
|
totalMs: rounded2(performance.now() - started),
|
|
143088
143234
|
firstByteMs: rounded2(firstByteMs),
|
|
143089
143235
|
bodyEndMs: rounded2(bodyEndMs),
|
|
@@ -143209,7 +143355,7 @@ async function snapshotPackagedHost(distribution, data2) {
|
|
|
143209
143355
|
|
|
143210
143356
|
// packages/web-server/src/main.ts
|
|
143211
143357
|
var RELEASE_WEB = !0, DISTRIBUTION_ROOT = resolve24(import.meta.dirname, ".."), PACKED_WEB = join36(DISTRIBUTION_ROOT, "web"), PACKED = existsSync16(join36(PACKED_WEB, "plugins.json")), REPO_ROOT = resolve24(import.meta.dirname, "../../.."), SERVER_VERSION = resolveServerVersion(
|
|
143212
|
-
"0.28.
|
|
143358
|
+
"0.28.2",
|
|
143213
143359
|
[join36(DISTRIBUTION_ROOT, "package.json"), join36(REPO_ROOT, "package.json")]
|
|
143214
143360
|
);
|
|
143215
143361
|
if (PACKED) {
|