@codexhost/cli-win32-x64 0.31.0 → 0.32.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/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +8 -0
- package/app/console-web.js +162 -23
- package/app/desktop-controller.mjs +8 -0
- package/app/host-runtime.mjs +2286 -814
- package/app/plugins/antigravity/plugin.mjs +10 -22
- package/app/plugins/claude-code/plugin.mjs +8 -0
- package/app/plugins/codebuddy/plugin.mjs +8 -0
- package/app/plugins/codex-usage/plugin.mjs +8 -0
- package/app/plugins/copilot/plugin.mjs +8 -0
- package/app/plugins/cursor-cli/plugin.mjs +8 -0
- package/app/plugins/deepseek-harness/plugin.mjs +8 -0
- package/app/plugins/devin/plugin.mjs +8 -0
- package/app/plugins/grok/plugin.mjs +8 -0
- package/app/plugins/hermes/plugin.mjs +8 -0
- package/app/plugins/kimi-code/plugin.mjs +8 -0
- package/app/plugins/kiro-cli/plugin.mjs +8 -0
- package/app/plugins/omp/plugin.mjs +8 -0
- package/app/plugins/opencode/plugin.mjs +8 -0
- package/app/plugins/pi/plugin.mjs +8 -0
- package/app/plugins/qoder/plugin.mjs +8 -0
- package/app/plugins/qoder-cn/plugin.mjs +8 -0
- package/app/plugins/qwen-code/plugin.mjs +8 -0
- package/app/plugins/workbuddy/plugin.mjs +8 -0
- package/app/plugins/zcode/plugin.mjs +8 -0
- package/app/renderer-extension.js +300 -125
- package/app/web/assets/{abnfDiagram-XWFEHMT6-Bqy7uOSy.js → abnfDiagram-XWFEHMT6-CnJyN70L.js} +1 -1
- package/app/web/assets/{architectureDiagram-CSQXQB3N-6aaP1YoM.js → architectureDiagram-CSQXQB3N-DH0ITYVE.js} +1 -1
- package/app/web/assets/{blockDiagram-BEDRHYPZ-B4QSFXe0.js → blockDiagram-BEDRHYPZ-WL3ZKoKg.js} +1 -1
- package/app/web/assets/{c4Diagram-M2UUVUY5-BYE-C8Gq.js → c4Diagram-M2UUVUY5-XwSPKj5H.js} +1 -1
- package/app/web/assets/{chunk-2Q5K7J3B-CiEM-GTd.js → chunk-2Q5K7J3B-CKEzexjg.js} +1 -1
- package/app/web/assets/{chunk-3GCGMST5-hzY9BiB1.js → chunk-3GCGMST5-BdEgLpab.js} +1 -1
- package/app/web/assets/{chunk-5VM5RSS4-DYXznY0H.js → chunk-5VM5RSS4-DyxL5-Ts.js} +1 -1
- package/app/web/assets/{chunk-7U7NFRK5-Bzw5MDPr.js → chunk-7U7NFRK5-FXLb4tYa.js} +1 -1
- package/app/web/assets/{chunk-CNRTWJTD-DMbxMfi3.js → chunk-CNRTWJTD-DcdC1OYr.js} +1 -1
- package/app/web/assets/{chunk-D5HYT7QG-By0ZVBtD.js → chunk-D5HYT7QG-BOz9vBX9.js} +1 -1
- package/app/web/assets/{chunk-EBZ3SEQC-Yyu_sMV7.js → chunk-EBZ3SEQC-Dmc_Z53x.js} +2 -2
- package/app/web/assets/{chunk-JWPE2WC7-DDzqxIPT.js → chunk-JWPE2WC7-CrFwSwYi.js} +1 -1
- package/app/web/assets/{chunk-KTR4FSNJ-GlKqhtpl.js → chunk-KTR4FSNJ-BY3AzFaI.js} +1 -1
- package/app/web/assets/{chunk-XXDRQBXY-DNc-CvYu.js → chunk-XXDRQBXY-CHgNy82n.js} +1 -1
- package/app/web/assets/{classDiagram-v2-KXABOMEV-4_PFS2N_.js → classDiagram-v2-KXABOMEV-ClM3-y5Z.js} +1 -1
- package/app/web/assets/{cose-bilkent-JH36ORCC-BE3foHUY.js → cose-bilkent-JH36ORCC-I7nd8GgO.js} +1 -1
- package/app/web/assets/{cynefin-EF2NZ3EQ-D2PqrYZ3.js → cynefin-EF2NZ3EQ-DzsXmyBH.js} +1 -1
- package/app/web/assets/{cynefinDiagram-NJNITYFG-DOObpTbq.js → cynefinDiagram-NJNITYFG-DLHq6igy.js} +1 -1
- package/app/web/assets/{dagre-KIHZ2IZ3-Znm2jin9.js → dagre-KIHZ2IZ3-BK991Mno.js} +1 -1
- package/app/web/assets/{diagram-7YQZDPLS-ByZMD-uA.js → diagram-7YQZDPLS-C4qiWdQU.js} +1 -1
- package/app/web/assets/{diagram-QBROCOUO-BiRShpnN.js → diagram-QBROCOUO-C_ZyBohC.js} +1 -1
- package/app/web/assets/{diagram-RJJCUUZO-D9wLVoK2.js → diagram-RJJCUUZO-C5Aezm94.js} +1 -1
- package/app/web/assets/{diagram-WERXNKYE-BSbIh-yC.js → diagram-WERXNKYE-Ckc_umlF.js} +1 -1
- package/app/web/assets/{diagram-YHHI257C-DMWrHMc8.js → diagram-YHHI257C-BHjReoZZ.js} +1 -1
- package/app/web/assets/{diagram-YR4HJLHV-C4sBAFb1.js → diagram-YR4HJLHV-DVTGi_y9.js} +1 -1
- package/app/web/assets/{ebnfDiagram-N527522P-BZLloaoQ.js → ebnfDiagram-N527522P-getuz1AR.js} +1 -1
- package/app/web/assets/{elk-O5DQBFGD-Da3e5tn5.js → elk-O5DQBFGD-C7mhTIuK.js} +1 -1
- package/app/web/assets/{erDiagram-K3K3BIDK-B2lKAIZF.js → erDiagram-K3K3BIDK-sV-HZvUV.js} +1 -1
- package/app/web/assets/{flowDiagram-Z6JWZHQI-q2EY_kmB.js → flowDiagram-Z6JWZHQI-D0L4wXUs.js} +1 -1
- package/app/web/assets/{ganttDiagram-3PRQTZWP-BGrNZ20b.js → ganttDiagram-3PRQTZWP-BNt9Bjjo.js} +1 -1
- package/app/web/assets/{gitGraphDiagram-VXDFKS5L-DIZNXREy.js → gitGraphDiagram-VXDFKS5L-BABZzhHw.js} +1 -1
- package/app/web/assets/{grid-E2QIVN74-0cUkPG69.js → grid-E2QIVN74-DLe2FQ_d.js} +1 -1
- package/app/web/assets/{index-PN7K-15_.js → index-BLmkBEoq.js} +99 -99
- package/app/web/assets/index-Dwdnvinl.css +1 -0
- package/app/web/assets/{infoDiagram-EZ3ZOAHP-BHhUTQCn.js → infoDiagram-EZ3ZOAHP-BKDuUqcr.js} +1 -1
- package/app/web/assets/{ishikawaDiagram-S3EKX5GW-DPOxtl4c.js → ishikawaDiagram-S3EKX5GW-C75EGghg.js} +1 -1
- package/app/web/assets/{journeyDiagram-POQNLL5X-D8RyXckG.js → journeyDiagram-POQNLL5X-q7Obruqa.js} +1 -1
- package/app/web/assets/{kanban-definition-BH5XI6FM-COJv3Hyh.js → kanban-definition-BH5XI6FM-CzAqhFED.js} +1 -1
- package/app/web/assets/{mermaid.core-DYdcDKIt.js → mermaid.core-Bysx44LR.js} +4 -4
- package/app/web/assets/{mindmap-definition-WVAN44T4-DnYIM4ja.js → mindmap-definition-WVAN44T4-Ds5rXTrF.js} +1 -1
- package/app/web/assets/{pegDiagram-D4NLKWP3-Ds3GAEJ6.js → pegDiagram-D4NLKWP3-hmdERwtT.js} +1 -1
- package/app/web/assets/{pieDiagram-36ENHN4W-BhLUJGEB.js → pieDiagram-36ENHN4W-DfTnyG8D.js} +1 -1
- package/app/web/assets/{quadrantDiagram-ZQUDMS73-DwtX-IxK.js → quadrantDiagram-ZQUDMS73-CreQWjZQ.js} +1 -1
- package/app/web/assets/{railroadDiagram-JIZHGYPL-D2vmTTnJ.js → railroadDiagram-JIZHGYPL-Bhc_eO9G.js} +1 -1
- package/app/web/assets/{render-VIF2ZAQL-DGU1ql-Z.js → render-VIF2ZAQL-BS1Zgk8K.js} +2 -2
- package/app/web/assets/{requirementDiagram-AXW2TVFA-u3j1sKkI.js → requirementDiagram-AXW2TVFA-Dlp7d6QT.js} +1 -1
- package/app/web/assets/{sankeyDiagram-FBCJTAIF-k-An9VHW.js → sankeyDiagram-FBCJTAIF-DGBchL30.js} +1 -1
- package/app/web/assets/{sequenceDiagram-3LA2ROMG-DUjbYb4R.js → sequenceDiagram-3LA2ROMG-DauFg5_R.js} +1 -1
- package/app/web/assets/{sizeCapture-2Q2CQKSF-DATTL7FZ.js → sizeCapture-2Q2CQKSF-DR-zy7an.js} +1 -1
- package/app/web/assets/{stateDiagram-v2-ATKHQDJO-cCJX5M2u.js → stateDiagram-v2-ATKHQDJO-BSRBSGUi.js} +1 -1
- package/app/web/assets/{swimlanes-YQL5WMAO-B7grWEWt.js → swimlanes-YQL5WMAO-BwzOr5Dv.js} +1 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-CNV63-us.js +8 -0
- package/app/web/assets/{timeline-definition-7Z437IG3-BhsLa6l1.js → timeline-definition-7Z437IG3-BoZ-mNKc.js} +1 -1
- package/app/web/assets/{usecaseDiagram-RDK6N6HP-CkPQYmQw.js → usecaseDiagram-RDK6N6HP-DikhgH2m.js} +1 -1
- package/app/web/assets/{vennDiagram-SHRQU5PJ-CufZSwvw.js → vennDiagram-SHRQU5PJ-DY_oIxwl.js} +1 -1
- package/app/web/assets/{wardleyDiagram-F3OXNVQS-CSkfpFOA.js → wardleyDiagram-F3OXNVQS-DrRIiB_M.js} +1 -1
- package/app/web/assets/{xychartDiagram-GDYJKCDI-BhZf9scK.js → xychartDiagram-GDYJKCDI-CzSPgHV7.js} +1 -1
- package/app/web/codexhost-settings.js +118 -50
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +71 -71
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +16 -16
- package/app/web/plugins/deepseek-ai__dsh-client-ui-commands/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +5 -5
- package/app/web/plugins/deepseek-ai__dsh-client-ui-plan/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +7 -7
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +69 -69
- package/app/web/sw.js +230 -16
- package/app/web-modules/node_modules/@deepseek-ai/dsh-client-modules/index.js +7 -7
- package/app/web-modules/server.mjs +1101 -179
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-screenshot.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
- package/app/web/assets/index-BbmB5VLj.css +0 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-B8Jem9gq.js +0 -8
|
@@ -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: Readable6 } = __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,
|
|
@@ -2093,8 +2093,8 @@ var require_websocket = __commonJS({
|
|
|
2093
2093
|
emitErrorAndClose(websocket, err5);
|
|
2094
2094
|
return;
|
|
2095
2095
|
}
|
|
2096
|
-
let
|
|
2097
|
-
if (opts.createConnection = opts.createConnection || (isSecure ?
|
|
2096
|
+
let defaultPort3 = isSecure ? 443 : 80, key = randomBytes12(16).toString("base64"), request3 = isSecure ? https.request : http.request, protocolSet = /* @__PURE__ */ new Set(), perMessageDeflate;
|
|
2097
|
+
if (opts.createConnection = opts.createConnection || (isSecure ? tlsConnect2 : netConnect), opts.defaultPort = opts.defaultPort || defaultPort3, opts.port = parsedUrl.port || defaultPort3, opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname, opts.headers = {
|
|
2098
2098
|
...opts.headers,
|
|
2099
2099
|
"Sec-WebSocket-Version": opts.protocolVersion,
|
|
2100
2100
|
"Sec-WebSocket-Key": key,
|
|
@@ -2222,7 +2222,7 @@ var require_websocket = __commonJS({
|
|
|
2222
2222
|
function netConnect(options) {
|
|
2223
2223
|
return options.path = options.socketPath, net2.connect(options);
|
|
2224
2224
|
}
|
|
2225
|
-
function
|
|
2225
|
+
function tlsConnect2(options) {
|
|
2226
2226
|
return options.path = void 0, !options.servername && options.servername !== "" && (options.servername = net2.isIP(options.host) ? "" : options.host), tls3.connect(options);
|
|
2227
2227
|
}
|
|
2228
2228
|
function abortHandshake(websocket, stream, message2) {
|
|
@@ -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: Readable6 } = __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,
|
|
@@ -5828,8 +5828,8 @@ var require_websocket2 = __commonJS({
|
|
|
5828
5828
|
emitErrorAndClose(websocket, err5);
|
|
5829
5829
|
return;
|
|
5830
5830
|
}
|
|
5831
|
-
let
|
|
5832
|
-
if (opts.createConnection = opts.createConnection || (isSecure ?
|
|
5831
|
+
let defaultPort3 = isSecure ? 443 : 80, key = randomBytes12(16).toString("base64"), request3 = isSecure ? https.request : http.request, protocolSet = /* @__PURE__ */ new Set(), perMessageDeflate;
|
|
5832
|
+
if (opts.createConnection = opts.createConnection || (isSecure ? tlsConnect2 : netConnect), opts.defaultPort = opts.defaultPort || defaultPort3, opts.port = parsedUrl.port || defaultPort3, opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname, opts.headers = {
|
|
5833
5833
|
...opts.headers,
|
|
5834
5834
|
"Sec-WebSocket-Version": opts.protocolVersion,
|
|
5835
5835
|
"Sec-WebSocket-Key": key,
|
|
@@ -5957,7 +5957,7 @@ var require_websocket2 = __commonJS({
|
|
|
5957
5957
|
function netConnect(options) {
|
|
5958
5958
|
return options.path = options.socketPath, net2.connect(options);
|
|
5959
5959
|
}
|
|
5960
|
-
function
|
|
5960
|
+
function tlsConnect2(options) {
|
|
5961
5961
|
return options.path = void 0, !options.servername && options.servername !== "" && (options.servername = net2.isIP(options.host) ? "" : options.host), tls3.connect(options);
|
|
5962
5962
|
}
|
|
5963
5963
|
function abortHandshake(websocket, stream, message2) {
|
|
@@ -73203,6 +73203,8 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73203
73203
|
"codexhost/harness/preferences/get",
|
|
73204
73204
|
"codexhost/harness/preferences/patch",
|
|
73205
73205
|
"experimentalFeature/list",
|
|
73206
|
+
"collaborationMode/list",
|
|
73207
|
+
"codexhost/thread/collaboration-mode/select",
|
|
73206
73208
|
"thread/list",
|
|
73207
73209
|
"thread/metadata/update",
|
|
73208
73210
|
"codexhost/thread/catalog/read",
|
|
@@ -73473,6 +73475,7 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73473
73475
|
nextCursor: external_exports.string().nullable()
|
|
73474
73476
|
}),
|
|
73475
73477
|
configuration: external_exports.object({
|
|
73478
|
+
codexCollaborationMode: external_exports.enum(["plan", "default"]).optional(),
|
|
73476
73479
|
/** Native Codex model names are not external Harness transport refs. */
|
|
73477
73480
|
native: external_exports.object({
|
|
73478
73481
|
model: external_exports.string().min(1).max(1024).optional(),
|
|
@@ -74145,7 +74148,11 @@ var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u
|
|
|
74145
74148
|
model: harnessModelRefSchema.optional(),
|
|
74146
74149
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
74147
74150
|
permissionModeId: harnessPermissionModeIdSchema.optional()
|
|
74148
|
-
}).refine((value) => !!(value.model || value.thinkingOptionId || value.permissionModeId), "A default configuration must contain a preference"),
|
|
74151
|
+
}).refine((value) => !!(value.model || value.thinkingOptionId || value.permissionModeId), "A default configuration must contain a preference"), projectHarnessSelectionSchema = external_exports.discriminatedUnion("mode", [
|
|
74152
|
+
external_exports.strictObject({ mode: external_exports.literal("global") }),
|
|
74153
|
+
external_exports.strictObject({ mode: external_exports.literal("last") }),
|
|
74154
|
+
external_exports.strictObject({ mode: external_exports.literal("manual"), harnessId: harnessIdSchema })
|
|
74155
|
+
]), newThreadDefaultsSchema = external_exports.strictObject({
|
|
74149
74156
|
lastHarness: harnessIdSchema.optional(),
|
|
74150
74157
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
|
|
74151
74158
|
}), harnessDelegationDefaultSchema = external_exports.strictObject({
|
|
@@ -77117,9 +77124,6 @@ var PeerChHostClient = class {
|
|
|
77117
77124
|
};
|
|
77118
77125
|
|
|
77119
77126
|
// packages/web-server/src/peer-host-client.ts
|
|
77120
|
-
import { request as httpRequest } from "node:http";
|
|
77121
|
-
import { request as httpsRequest } from "node:https";
|
|
77122
|
-
import { isIP as isIP2 } from "node:net";
|
|
77123
77127
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
77124
77128
|
|
|
77125
77129
|
// packages/web-server/src/peer-host-store.ts
|
|
@@ -77258,6 +77262,594 @@ var PeerHostStore = class {
|
|
|
77258
77262
|
}
|
|
77259
77263
|
};
|
|
77260
77264
|
|
|
77265
|
+
// packages/web-server/src/peer-outbound-proxy.ts
|
|
77266
|
+
import { lookup as osDnsLookup } from "node:dns/promises";
|
|
77267
|
+
import {
|
|
77268
|
+
Agent as HttpAgent,
|
|
77269
|
+
request as httpRequest
|
|
77270
|
+
} from "node:http";
|
|
77271
|
+
import {
|
|
77272
|
+
Agent as HttpsAgent,
|
|
77273
|
+
request as httpsRequest
|
|
77274
|
+
} from "node:https";
|
|
77275
|
+
import { BlockList, isIP as isIP2, isIPv4 as isIPv42 } from "node:net";
|
|
77276
|
+
import { Readable } from "node:stream";
|
|
77277
|
+
import { checkServerIdentity, connect as tlsConnect } from "node:tls";
|
|
77278
|
+
var BUILTIN_FETCH = globalThis.fetch, CONNECT_TIMEOUT_MS = 15e3, MAX_CACHED_PROXY_AGENTS = 16, CONNECT_SIGNAL = /* @__PURE__ */ Symbol("peerConnectSignal"), CONNECT_TIMEOUT = /* @__PURE__ */ Symbol("peerConnectTimeoutMs"), directHttpAgent = new HttpAgent({ keepAlive: !0, proxyEnv: {} }), directHttpsAgent = new HttpsAgent({ keepAlive: !0, proxyEnv: {} }), directNoKeepAliveHttpAgent = new HttpAgent({ keepAlive: !1, proxyEnv: {} }), directNoKeepAliveHttpsAgent = new HttpsAgent({ keepAlive: !1, proxyEnv: {} }), proxyHttpsAgents = /* @__PURE__ */ new Map(), DNS_RESOLUTION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
77279
|
+
"ENOTFOUND",
|
|
77280
|
+
"EAI_AGAIN",
|
|
77281
|
+
"EAI_NONAME",
|
|
77282
|
+
"EAI_NODATA",
|
|
77283
|
+
"EAI_FAIL",
|
|
77284
|
+
"ESERVFAIL",
|
|
77285
|
+
"ETIMEOUT"
|
|
77286
|
+
]);
|
|
77287
|
+
function isDnsResolutionError(err5) {
|
|
77288
|
+
if (!(err5 instanceof Error) || err5 instanceof PeerHostPolicyError) return !1;
|
|
77289
|
+
if (err5.message === "Peer host address could not be resolved") return !0;
|
|
77290
|
+
let code = "code" in err5 && typeof err5.code == "string" ? err5.code : void 0;
|
|
77291
|
+
return code !== void 0 && DNS_RESOLUTION_ERROR_CODES.has(code);
|
|
77292
|
+
}
|
|
77293
|
+
var PeerProxyConfigError = class extends Error {
|
|
77294
|
+
constructor(message2) {
|
|
77295
|
+
super(message2), this.name = "PeerProxyConfigError";
|
|
77296
|
+
}
|
|
77297
|
+
};
|
|
77298
|
+
function toAbortError(signal) {
|
|
77299
|
+
let reason = signal?.reason;
|
|
77300
|
+
return reason instanceof Error ? reason : new DOMException("The operation was aborted.", "AbortError");
|
|
77301
|
+
}
|
|
77302
|
+
function stripBrackets(hostname5) {
|
|
77303
|
+
let bare = hostname5.startsWith("[") && hostname5.endsWith("]") ? hostname5.slice(1, -1) : hostname5.replace(/\.$/u, ""), zoneIndex = bare.indexOf("%");
|
|
77304
|
+
return (zoneIndex >= 0 ? bare.slice(0, zoneIndex) : bare).toLowerCase();
|
|
77305
|
+
}
|
|
77306
|
+
function normalizeIpv4Candidate(bare) {
|
|
77307
|
+
if (isIPv42(bare)) return bare;
|
|
77308
|
+
if (!bare.startsWith("::ffff:")) return;
|
|
77309
|
+
let suffix = bare.slice(7);
|
|
77310
|
+
if (isIPv42(suffix)) return suffix;
|
|
77311
|
+
let hex3 = /^([0-9a-f]{1,4}):([0-9a-f]{1,4})$/iu.exec(suffix);
|
|
77312
|
+
if (!hex3?.[1] || !hex3[2]) return;
|
|
77313
|
+
let hi = Number.parseInt(hex3[1], 16), lo = Number.parseInt(hex3[2], 16);
|
|
77314
|
+
return `${hi >> 8 & 255}.${hi & 255}.${lo >> 8 & 255}.${lo & 255}`;
|
|
77315
|
+
}
|
|
77316
|
+
function isLoopbackHost2(hostname5) {
|
|
77317
|
+
let bare = stripBrackets(hostname5);
|
|
77318
|
+
if (bare === "localhost" || bare.endsWith(".localhost") || bare === "::1" || bare === "0:0:0:0:0:0:0:1")
|
|
77319
|
+
return !0;
|
|
77320
|
+
let ipv43 = normalizeIpv4Candidate(bare);
|
|
77321
|
+
return ipv43 !== void 0 && ipv43.startsWith("127.");
|
|
77322
|
+
}
|
|
77323
|
+
function isAlwaysDirectPeerHost(hostname5) {
|
|
77324
|
+
let bare = stripBrackets(hostname5);
|
|
77325
|
+
if (isLoopbackHost2(bare) || bare.endsWith(".local"))
|
|
77326
|
+
return !0;
|
|
77327
|
+
let ipv43 = normalizeIpv4Candidate(bare);
|
|
77328
|
+
return !!(ipv43 !== void 0 && /^100\.(?:6[4-9]|[7-9]\d|1[01]\d|12[0-7])\./u.test(ipv43) || bare.startsWith("fd7a:115c:a1e0:") || /^fe[89ab][0-9a-f]:/iu.test(bare));
|
|
77329
|
+
}
|
|
77330
|
+
function readEnvValue(env, lowerKey) {
|
|
77331
|
+
let upperKey = lowerKey.toUpperCase(), lower = env[lowerKey];
|
|
77332
|
+
if (lower !== void 0) return lower;
|
|
77333
|
+
let upper = env[upperKey];
|
|
77334
|
+
if (upper !== void 0) return upper;
|
|
77335
|
+
for (let [key, value] of Object.entries(env))
|
|
77336
|
+
if (value !== void 0 && key.toLowerCase() === lowerKey) return value;
|
|
77337
|
+
}
|
|
77338
|
+
function readNonEmptyEnvValue(env, lowerKey) {
|
|
77339
|
+
let upperKey = lowerKey.toUpperCase(), lower = env[lowerKey]?.trim();
|
|
77340
|
+
if (lower) return lower;
|
|
77341
|
+
let upper = env[upperKey]?.trim();
|
|
77342
|
+
if (upper) return upper;
|
|
77343
|
+
for (let [key, value] of Object.entries(env))
|
|
77344
|
+
if (key.toLowerCase() === lowerKey) {
|
|
77345
|
+
let trimmed = value?.trim();
|
|
77346
|
+
if (trimmed) return trimmed;
|
|
77347
|
+
}
|
|
77348
|
+
}
|
|
77349
|
+
function parseNoProxyBlockList(noProxyValue) {
|
|
77350
|
+
let list2;
|
|
77351
|
+
for (let rawToken of noProxyValue.split(/[,\s]+/u)) {
|
|
77352
|
+
let token = rawToken.trim(), slash = token.indexOf("/");
|
|
77353
|
+
if (slash <= 0) continue;
|
|
77354
|
+
let prefixText = token.slice(slash + 1);
|
|
77355
|
+
if (!/^\d+$/u.test(prefixText)) continue;
|
|
77356
|
+
let address = stripBrackets(token.slice(0, slash)), prefix = Number.parseInt(prefixText, 10), family = isIP2(address);
|
|
77357
|
+
family === 4 && prefix >= 0 && prefix <= 32 ? (list2 ??= new BlockList(), list2.addSubnet(address, prefix, "ipv4")) : family === 6 && prefix >= 0 && prefix <= 128 && (list2 ??= new BlockList(), list2.addSubnet(address, prefix, "ipv6"));
|
|
77358
|
+
}
|
|
77359
|
+
return list2;
|
|
77360
|
+
}
|
|
77361
|
+
function matchesNoProxyCidr(hostname5, blockList) {
|
|
77362
|
+
if (!blockList) return !1;
|
|
77363
|
+
let bare = stripBrackets(hostname5), ipv43 = normalizeIpv4Candidate(bare);
|
|
77364
|
+
return ipv43 !== void 0 ? blockList.check(ipv43, "ipv4") : isIP2(bare) === 6 ? blockList.check(bare, "ipv6") : !1;
|
|
77365
|
+
}
|
|
77366
|
+
function parseNoProxyHostToken(token) {
|
|
77367
|
+
if (!token || token.includes("/")) return;
|
|
77368
|
+
if (token.startsWith("[")) {
|
|
77369
|
+
let bracketed = /^\[([^\]]+)\](?::(\d+))?$/u.exec(token);
|
|
77370
|
+
return bracketed?.[1] ? {
|
|
77371
|
+
host: stripBrackets(bracketed[1]),
|
|
77372
|
+
...bracketed[2] ? { port: Number.parseInt(bracketed[2], 10) } : {}
|
|
77373
|
+
} : void 0;
|
|
77374
|
+
}
|
|
77375
|
+
if (token.indexOf(":") !== token.lastIndexOf(":"))
|
|
77376
|
+
return { host: stripBrackets(token) };
|
|
77377
|
+
let hostPort = /^([^:]+):(\d+)$/u.exec(token);
|
|
77378
|
+
return hostPort?.[1] && hostPort[2] ? {
|
|
77379
|
+
host: stripBrackets(hostPort[1]),
|
|
77380
|
+
port: Number.parseInt(hostPort[2], 10)
|
|
77381
|
+
} : { host: stripBrackets(token) };
|
|
77382
|
+
}
|
|
77383
|
+
function matchesNoProxyHostname(target2, noProxyRaw) {
|
|
77384
|
+
if (!noProxyRaw) return !1;
|
|
77385
|
+
let bareTarget = stripBrackets(target2.hostname), targetIpv4 = normalizeIpv4Candidate(bareTarget), targetPort = Number(target2.port || defaultPort(target2.protocol));
|
|
77386
|
+
for (let rawToken of noProxyRaw.split(/[,\s]+/u)) {
|
|
77387
|
+
let token = rawToken.trim().toLowerCase();
|
|
77388
|
+
if (!token) continue;
|
|
77389
|
+
if (token === "*") return !0;
|
|
77390
|
+
let parsed = parseNoProxyHostToken(token);
|
|
77391
|
+
if (!(!parsed || !parsed.host) && !(parsed.port !== void 0 && parsed.port !== targetPort)) {
|
|
77392
|
+
if (parsed.host.startsWith("*") || parsed.host.startsWith(".")) {
|
|
77393
|
+
let suffix = parsed.host.startsWith("*") ? parsed.host.slice(1) : parsed.host;
|
|
77394
|
+
if (!suffix || bareTarget.endsWith(suffix)) return !0;
|
|
77395
|
+
continue;
|
|
77396
|
+
}
|
|
77397
|
+
if (bareTarget === parsed.host || targetIpv4 !== void 0 && normalizeIpv4Candidate(parsed.host) === targetIpv4)
|
|
77398
|
+
return !0;
|
|
77399
|
+
}
|
|
77400
|
+
}
|
|
77401
|
+
return !1;
|
|
77402
|
+
}
|
|
77403
|
+
function resolveRawEnvProxy(target2, env, noProxyRaw) {
|
|
77404
|
+
if (target2.protocol !== "http:" && target2.protocol !== "https:" || matchesNoProxyHostname(target2, noProxyRaw)) return "";
|
|
77405
|
+
let protoKey = target2.protocol === "https:" ? "https_proxy" : "http_proxy";
|
|
77406
|
+
return readNonEmptyEnvValue(env, protoKey) ?? readNonEmptyEnvValue(env, "all_proxy") ?? "";
|
|
77407
|
+
}
|
|
77408
|
+
var SCHEMELESS_PROXY_HOST_PORT = /^(?:[^/@\s]+@)?(?:\[[^\]]+\]|[^:/@\s]+):(\d{1,5})\/?$/u;
|
|
77409
|
+
function parseConfiguredProxyUrl(rawProxy) {
|
|
77410
|
+
let candidate = rawProxy;
|
|
77411
|
+
if (!rawProxy.includes("://")) {
|
|
77412
|
+
let match = SCHEMELESS_PROXY_HOST_PORT.exec(rawProxy), portNum = match?.[1] ? Number.parseInt(match[1], 10) : 0;
|
|
77413
|
+
if (!match || portNum < 1 || portNum > 65535)
|
|
77414
|
+
throw new PeerProxyConfigError("Invalid outbound proxy URL configured in environment");
|
|
77415
|
+
candidate = `http://${rawProxy}`;
|
|
77416
|
+
}
|
|
77417
|
+
let parsed = URL.parse(candidate);
|
|
77418
|
+
if (!parsed || !parsed.hostname || parsed.port === "0")
|
|
77419
|
+
throw new PeerProxyConfigError("Invalid outbound proxy URL configured in environment");
|
|
77420
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
77421
|
+
throw new PeerProxyConfigError(`Unsupported outbound proxy protocol: ${parsed.protocol}`);
|
|
77422
|
+
try {
|
|
77423
|
+
parsed.username && decodeURIComponent(parsed.username), parsed.password && decodeURIComponent(parsed.password);
|
|
77424
|
+
} catch {
|
|
77425
|
+
throw new PeerProxyConfigError("Invalid percent-encoding in outbound proxy credentials");
|
|
77426
|
+
}
|
|
77427
|
+
return parsed;
|
|
77428
|
+
}
|
|
77429
|
+
function resolvePeerProxyUrl(target2, options = {}) {
|
|
77430
|
+
let env = options.env ?? process.env;
|
|
77431
|
+
if (readEnvValue(env, "node_use_env_proxy")?.trim() === "0" || isAlwaysDirectPeerHost(target2.hostname)) return;
|
|
77432
|
+
let noProxyRaw = readNonEmptyEnvValue(env, "no_proxy") ?? "", cidrBlockList = noProxyRaw ? parseNoProxyBlockList(noProxyRaw) : void 0;
|
|
77433
|
+
if (matchesNoProxyCidr(target2.hostname, cidrBlockList)) return;
|
|
77434
|
+
if (options.resolvedAddresses) {
|
|
77435
|
+
for (let entry of options.resolvedAddresses)
|
|
77436
|
+
if (isAlwaysDirectPeerHost(entry.address) || matchesNoProxyCidr(entry.address, cidrBlockList))
|
|
77437
|
+
return;
|
|
77438
|
+
}
|
|
77439
|
+
let rawProxy = resolveRawEnvProxy(target2, env, noProxyRaw);
|
|
77440
|
+
if (rawProxy)
|
|
77441
|
+
return parseConfiguredProxyUrl(rawProxy);
|
|
77442
|
+
}
|
|
77443
|
+
function createPinnedLookup(addresses) {
|
|
77444
|
+
return (_hostname, lookupOptions, callback) => {
|
|
77445
|
+
let opts = typeof lookupOptions == "object" && lookupOptions !== null ? lookupOptions : {};
|
|
77446
|
+
if (opts.all) {
|
|
77447
|
+
callback(
|
|
77448
|
+
null,
|
|
77449
|
+
addresses.map((entry) => ({ address: entry.address, family: entry.family }))
|
|
77450
|
+
);
|
|
77451
|
+
return;
|
|
77452
|
+
}
|
|
77453
|
+
let family = typeof lookupOptions == "number" ? lookupOptions : opts.family, match = family === 4 || family === 6 ? addresses.find((entry) => entry.family === family) : addresses[0];
|
|
77454
|
+
if (!match) {
|
|
77455
|
+
callback(
|
|
77456
|
+
Object.assign(new Error("No verified address matches requested IP family"), {
|
|
77457
|
+
code: "ENOTFOUND"
|
|
77458
|
+
}),
|
|
77459
|
+
"",
|
|
77460
|
+
4
|
|
77461
|
+
);
|
|
77462
|
+
return;
|
|
77463
|
+
}
|
|
77464
|
+
callback(null, match.address, match.family);
|
|
77465
|
+
};
|
|
77466
|
+
}
|
|
77467
|
+
function proxyAuthorizationHeader(proxy) {
|
|
77468
|
+
if (!proxy.username && !proxy.password) return;
|
|
77469
|
+
let credentials;
|
|
77470
|
+
try {
|
|
77471
|
+
credentials = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
|
77472
|
+
} catch {
|
|
77473
|
+
throw new PeerProxyConfigError("Invalid percent-encoding in outbound proxy credentials");
|
|
77474
|
+
}
|
|
77475
|
+
return `Basic ${Buffer.from(credentials, "utf8").toString("base64")}`;
|
|
77476
|
+
}
|
|
77477
|
+
function httpsProxyTlsOptions(bareProxy) {
|
|
77478
|
+
return {
|
|
77479
|
+
// Explicit empty string prevents Node from deriving outer TLS SNI from the inner target Host header.
|
|
77480
|
+
servername: isIP2(bareProxy) === 0 ? bareProxy : "",
|
|
77481
|
+
checkServerIdentity: (_host, cert) => checkServerIdentity(bareProxy, cert)
|
|
77482
|
+
};
|
|
77483
|
+
}
|
|
77484
|
+
function defaultPort(protocol) {
|
|
77485
|
+
return protocol === "https:" ? 443 : 80;
|
|
77486
|
+
}
|
|
77487
|
+
var ProxyHttpsAgent = class extends HttpsAgent {
|
|
77488
|
+
constructor(proxy, keepAlive = !0) {
|
|
77489
|
+
super({ keepAlive, autoSelectFamilyAttemptTimeout: 2e3, proxyEnv: {} });
|
|
77490
|
+
this.proxy = proxy;
|
|
77491
|
+
}
|
|
77492
|
+
proxy;
|
|
77493
|
+
createConnection(options, callback) {
|
|
77494
|
+
let connectSignal = options[CONNECT_SIGNAL];
|
|
77495
|
+
if (connectSignal?.aborted) {
|
|
77496
|
+
callback?.(toAbortError(connectSignal), void 0);
|
|
77497
|
+
return;
|
|
77498
|
+
}
|
|
77499
|
+
let connectTimeoutMs = options[CONNECT_TIMEOUT] ?? CONNECT_TIMEOUT_MS, targetHost = String(options.hostname || options.host || "localhost"), targetPort = Number(options.port || 443), bareTarget = stripBrackets(targetHost), authority = bareTarget.includes(":") ? `[${bareTarget}]:${targetPort}` : `${bareTarget}:${targetPort}`, proxyAuth;
|
|
77500
|
+
try {
|
|
77501
|
+
proxyAuth = proxyAuthorizationHeader(this.proxy);
|
|
77502
|
+
} catch (err5) {
|
|
77503
|
+
callback?.(
|
|
77504
|
+
err5 instanceof Error ? err5 : new Error(String(err5)),
|
|
77505
|
+
void 0
|
|
77506
|
+
);
|
|
77507
|
+
return;
|
|
77508
|
+
}
|
|
77509
|
+
let bareProxy = stripBrackets(this.proxy.hostname), connectReq = (this.proxy.protocol === "https:" ? httpsRequest : httpRequest)({
|
|
77510
|
+
protocol: this.proxy.protocol,
|
|
77511
|
+
hostname: bareProxy,
|
|
77512
|
+
port: Number(this.proxy.port || defaultPort(this.proxy.protocol)),
|
|
77513
|
+
method: "CONNECT",
|
|
77514
|
+
path: authority,
|
|
77515
|
+
agent: this.proxy.protocol === "https:" ? directNoKeepAliveHttpsAgent : directNoKeepAliveHttpAgent,
|
|
77516
|
+
headers: {
|
|
77517
|
+
host: authority,
|
|
77518
|
+
...proxyAuth ? { "proxy-authorization": proxyAuth } : {}
|
|
77519
|
+
},
|
|
77520
|
+
...this.proxy.protocol === "https:" ? httpsProxyTlsOptions(bareProxy) : {},
|
|
77521
|
+
timeout: connectTimeoutMs
|
|
77522
|
+
}), settled2 = !1, activeTlsSocket, connectTimer, handshakeTimer, clearConnectTimer = () => {
|
|
77523
|
+
connectTimer !== void 0 && (clearTimeout(connectTimer), connectTimer = void 0);
|
|
77524
|
+
}, cleanup = () => {
|
|
77525
|
+
clearConnectTimer(), handshakeTimer !== void 0 && (clearTimeout(handshakeTimer), handshakeTimer = void 0), connectSignal?.removeEventListener("abort", onAbort);
|
|
77526
|
+
}, fail = (err5) => {
|
|
77527
|
+
settled2 || (settled2 = !0, cleanup(), activeTlsSocket?.destroy(), connectReq.destroy(), callback?.(err5, void 0));
|
|
77528
|
+
}, onAbort = () => {
|
|
77529
|
+
fail(toAbortError(connectSignal));
|
|
77530
|
+
};
|
|
77531
|
+
connectTimer = setTimeout(() => fail(new Error("Proxy CONNECT timed out")), connectTimeoutMs), connectSignal?.addEventListener("abort", onAbort, { once: !0 }), connectReq.once("close", clearConnectTimer), connectReq.once("timeout", () => fail(new Error("Proxy CONNECT timed out"))), connectReq.once("error", fail), connectReq.once("connect", (res, socket, head) => {
|
|
77532
|
+
if (clearConnectTimer(), settled2) {
|
|
77533
|
+
socket.destroy();
|
|
77534
|
+
return;
|
|
77535
|
+
}
|
|
77536
|
+
if (res.statusCode !== 200) {
|
|
77537
|
+
socket.destroy(), fail(new Error(`Proxy CONNECT returned HTTP ${res.statusCode ?? 0}`));
|
|
77538
|
+
return;
|
|
77539
|
+
}
|
|
77540
|
+
connectReq.setTimeout(0), socket.setTimeout(0), head.length > 0 && socket.unshift(head);
|
|
77541
|
+
let isIpTarget = isIP2(bareTarget) !== 0, customCheck = options.checkServerIdentity, tlsSocket = tlsConnect({
|
|
77542
|
+
socket,
|
|
77543
|
+
...isIpTarget ? {
|
|
77544
|
+
host: bareTarget,
|
|
77545
|
+
checkServerIdentity: (_host, cert) => customCheck ? customCheck(bareTarget, cert) : checkServerIdentity(bareTarget, cert)
|
|
77546
|
+
} : {
|
|
77547
|
+
servername: options.servername || bareTarget,
|
|
77548
|
+
...customCheck ? {
|
|
77549
|
+
checkServerIdentity: (host, cert) => customCheck(host, cert)
|
|
77550
|
+
} : {}
|
|
77551
|
+
},
|
|
77552
|
+
...options.rejectUnauthorized === void 0 ? {} : { rejectUnauthorized: options.rejectUnauthorized }
|
|
77553
|
+
});
|
|
77554
|
+
activeTlsSocket = tlsSocket, handshakeTimer = setTimeout(
|
|
77555
|
+
() => tlsSocket.destroy(new Error("Proxy TLS handshake timed out")),
|
|
77556
|
+
connectTimeoutMs
|
|
77557
|
+
), tlsSocket.once("error", (err5) => {
|
|
77558
|
+
fail(err5);
|
|
77559
|
+
}), tlsSocket.once("secureConnect", () => {
|
|
77560
|
+
if (settled2 || connectSignal?.aborted) {
|
|
77561
|
+
tlsSocket.destroy(), settled2 || fail(toAbortError(connectSignal));
|
|
77562
|
+
return;
|
|
77563
|
+
}
|
|
77564
|
+
settled2 = !0, cleanup(), tlsSocket.setTimeout(0), callback?.(null, tlsSocket);
|
|
77565
|
+
});
|
|
77566
|
+
}), connectReq.end();
|
|
77567
|
+
}
|
|
77568
|
+
};
|
|
77569
|
+
function getProxyHttpsAgent(proxy) {
|
|
77570
|
+
let key = proxy.href, agent = proxyHttpsAgents.get(key);
|
|
77571
|
+
if (!agent) {
|
|
77572
|
+
if (proxyHttpsAgents.size >= MAX_CACHED_PROXY_AGENTS) {
|
|
77573
|
+
let oldest = proxyHttpsAgents.keys().next().value;
|
|
77574
|
+
oldest !== void 0 && (proxyHttpsAgents.get(oldest)?.destroy(), proxyHttpsAgents.delete(oldest));
|
|
77575
|
+
}
|
|
77576
|
+
agent = new ProxyHttpsAgent(proxy, !0), proxyHttpsAgents.set(key, agent);
|
|
77577
|
+
}
|
|
77578
|
+
return agent;
|
|
77579
|
+
}
|
|
77580
|
+
function openPeerHttpRequest(target2, options) {
|
|
77581
|
+
let bareTarget = stripBrackets(target2.hostname), targetPort = Number(target2.port || defaultPort(target2.protocol)), proxy = options.proxy;
|
|
77582
|
+
if (proxy && target2.protocol === "http:") {
|
|
77583
|
+
let proxyAuth = proxyAuthorizationHeader(proxy), bareProxy = stripBrackets(proxy.hostname);
|
|
77584
|
+
return (proxy.protocol === "https:" ? httpsRequest : httpRequest)({
|
|
77585
|
+
protocol: proxy.protocol,
|
|
77586
|
+
hostname: bareProxy,
|
|
77587
|
+
port: Number(proxy.port || defaultPort(proxy.protocol)),
|
|
77588
|
+
method: options.method,
|
|
77589
|
+
path: target2.href,
|
|
77590
|
+
headers: {
|
|
77591
|
+
...options.headers,
|
|
77592
|
+
host: target2.host,
|
|
77593
|
+
...proxyAuth ? { "proxy-authorization": proxyAuth } : {}
|
|
77594
|
+
},
|
|
77595
|
+
agent: options.keepAlive === !1 ? proxy.protocol === "https:" ? directNoKeepAliveHttpsAgent : directNoKeepAliveHttpAgent : proxy.protocol === "https:" ? directHttpsAgent : directHttpAgent,
|
|
77596
|
+
...proxy.protocol === "https:" ? httpsProxyTlsOptions(bareProxy) : {},
|
|
77597
|
+
...options.signal ? { signal: options.signal } : {}
|
|
77598
|
+
});
|
|
77599
|
+
}
|
|
77600
|
+
if (proxy && target2.protocol === "https:") {
|
|
77601
|
+
let ephemeralAgent = options.keepAlive === !1 ? new ProxyHttpsAgent(proxy, !1) : void 0, reqOptions = {
|
|
77602
|
+
protocol: "https:",
|
|
77603
|
+
hostname: bareTarget,
|
|
77604
|
+
port: targetPort,
|
|
77605
|
+
method: options.method,
|
|
77606
|
+
path: `${target2.pathname}${target2.search}`,
|
|
77607
|
+
headers: {
|
|
77608
|
+
...options.headers,
|
|
77609
|
+
host: target2.host
|
|
77610
|
+
},
|
|
77611
|
+
agent: ephemeralAgent ?? getProxyHttpsAgent(proxy),
|
|
77612
|
+
...isIP2(bareTarget) === 0 ? { servername: bareTarget } : {},
|
|
77613
|
+
...options.signal ? { signal: options.signal, [CONNECT_SIGNAL]: options.signal } : {},
|
|
77614
|
+
...options.connectTimeoutMs !== void 0 ? { [CONNECT_TIMEOUT]: options.connectTimeoutMs } : {}
|
|
77615
|
+
}, req = httpsRequest(reqOptions);
|
|
77616
|
+
return ephemeralAgent && (req.once("error", () => ephemeralAgent.destroy()), req.once("response", (res) => {
|
|
77617
|
+
res.once("close", () => ephemeralAgent.destroy());
|
|
77618
|
+
})), req;
|
|
77619
|
+
}
|
|
77620
|
+
let useNoKeepAlive = !!options.lookup || options.keepAlive === !1, directOptions = {
|
|
77621
|
+
protocol: target2.protocol,
|
|
77622
|
+
hostname: bareTarget,
|
|
77623
|
+
port: targetPort,
|
|
77624
|
+
method: options.method,
|
|
77625
|
+
path: `${target2.pathname}${target2.search}`,
|
|
77626
|
+
headers: {
|
|
77627
|
+
...options.headers,
|
|
77628
|
+
host: target2.host
|
|
77629
|
+
},
|
|
77630
|
+
agent: useNoKeepAlive ? target2.protocol === "https:" ? directNoKeepAliveHttpsAgent : directNoKeepAliveHttpAgent : target2.protocol === "https:" ? directHttpsAgent : directHttpAgent,
|
|
77631
|
+
...options.lookup ? { lookup: options.lookup } : {},
|
|
77632
|
+
...options.signal ? { signal: options.signal } : {}
|
|
77633
|
+
};
|
|
77634
|
+
return target2.protocol === "https:" ? httpsRequest({
|
|
77635
|
+
...directOptions,
|
|
77636
|
+
...isIP2(bareTarget) === 0 ? { servername: bareTarget } : {}
|
|
77637
|
+
}) : httpRequest(directOptions);
|
|
77638
|
+
}
|
|
77639
|
+
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
77640
|
+
async function prepareFetchBody(body) {
|
|
77641
|
+
if (body == null) return { kind: "empty" };
|
|
77642
|
+
if (typeof body == "string") return { kind: "buffer", buffer: Buffer.from(body, "utf8") };
|
|
77643
|
+
if (body instanceof URLSearchParams)
|
|
77644
|
+
return {
|
|
77645
|
+
kind: "buffer",
|
|
77646
|
+
buffer: Buffer.from(body.toString(), "utf8"),
|
|
77647
|
+
contentType: "application/x-www-form-urlencoded;charset=UTF-8"
|
|
77648
|
+
};
|
|
77649
|
+
if (body instanceof FormData) {
|
|
77650
|
+
let encoded = new Response(body), contentType = encoded.headers.get("content-type") ?? void 0;
|
|
77651
|
+
return { kind: "buffer", buffer: Buffer.from(await encoded.arrayBuffer()), ...contentType ? { contentType } : {} };
|
|
77652
|
+
}
|
|
77653
|
+
return body instanceof Uint8Array ? { kind: "buffer", buffer: Buffer.from(body.buffer, body.byteOffset, body.byteLength) } : body instanceof ArrayBuffer ? { kind: "buffer", buffer: Buffer.from(body) } : ArrayBuffer.isView(body) ? { kind: "buffer", buffer: Buffer.from(body.buffer, body.byteOffset, body.byteLength) } : body instanceof Blob ? {
|
|
77654
|
+
kind: "buffer",
|
|
77655
|
+
buffer: Buffer.from(await body.arrayBuffer()),
|
|
77656
|
+
...body.type ? { contentType: body.type } : {}
|
|
77657
|
+
} : { kind: "stream", stream: body };
|
|
77658
|
+
}
|
|
77659
|
+
function toFetchResponse(res, method2, signal) {
|
|
77660
|
+
let status = res.statusCode;
|
|
77661
|
+
if (typeof status != "number" || !Number.isInteger(status) || status < 200 || status > 599)
|
|
77662
|
+
throw new RangeError(
|
|
77663
|
+
`The status provided (${String(status)}) is outside the range [200, 599].`
|
|
77664
|
+
);
|
|
77665
|
+
let headers2 = new Headers();
|
|
77666
|
+
for (let [key, value] of Object.entries(res.headers))
|
|
77667
|
+
if (value !== void 0)
|
|
77668
|
+
if (Array.isArray(value))
|
|
77669
|
+
for (let item of value) headers2.append(key, item);
|
|
77670
|
+
else
|
|
77671
|
+
headers2.set(key, value);
|
|
77672
|
+
if (method2.toUpperCase() === "HEAD" || status === 204 || status === 205 || status === 304) {
|
|
77673
|
+
let response2 = new Response(null, { status, statusText: res.statusMessage ?? "", headers: headers2 });
|
|
77674
|
+
return res.resume(), response2;
|
|
77675
|
+
}
|
|
77676
|
+
let response = new Response(Readable.toWeb(res), {
|
|
77677
|
+
status,
|
|
77678
|
+
statusText: res.statusMessage ?? "",
|
|
77679
|
+
headers: headers2
|
|
77680
|
+
});
|
|
77681
|
+
if (signal) {
|
|
77682
|
+
let onAbort = () => res.destroy(signal.reason instanceof Error ? signal.reason : void 0);
|
|
77683
|
+
signal.aborted ? onAbort() : (signal.addEventListener("abort", onAbort, { once: !0 }), res.once("close", () => signal.removeEventListener("abort", onAbort)));
|
|
77684
|
+
}
|
|
77685
|
+
return response;
|
|
77686
|
+
}
|
|
77687
|
+
function waitForDrain(req, signal) {
|
|
77688
|
+
return req.destroyed || req.writableEnded || signal?.aborted ? Promise.resolve(!1) : new Promise((resolve26) => {
|
|
77689
|
+
let cleanup = () => {
|
|
77690
|
+
req.off("drain", onDrain), req.off("close", onStop), req.off("error", onStop), signal?.removeEventListener("abort", onStop);
|
|
77691
|
+
}, onDrain = () => {
|
|
77692
|
+
cleanup(), resolve26(!0);
|
|
77693
|
+
}, onStop = () => {
|
|
77694
|
+
cleanup(), resolve26(!1);
|
|
77695
|
+
};
|
|
77696
|
+
req.once("drain", onDrain), req.once("close", onStop), req.once("error", onStop), signal?.addEventListener("abort", onStop, { once: !0 });
|
|
77697
|
+
});
|
|
77698
|
+
}
|
|
77699
|
+
async function resolveHostAddresses(bareHost, dnsLookup2, signal) {
|
|
77700
|
+
if (signal?.aborted)
|
|
77701
|
+
throw toAbortError(signal);
|
|
77702
|
+
let lookupPromise = (dnsLookup2 ? dnsLookup2(bareHost) : osDnsLookup(bareHost, { all: !0, verbatim: !0 }).then(
|
|
77703
|
+
(entries) => entries.map((entry) => ({
|
|
77704
|
+
address: entry.address,
|
|
77705
|
+
family: entry.family === 6 ? 6 : 4
|
|
77706
|
+
}))
|
|
77707
|
+
)).then((entries) => {
|
|
77708
|
+
let validated = [];
|
|
77709
|
+
for (let entry of entries) {
|
|
77710
|
+
let family = typeof entry?.address == "string" ? isIP2(entry.address) : 0;
|
|
77711
|
+
if (family !== 4 && family !== 6)
|
|
77712
|
+
throw new PeerHostPolicyError("Peer host address is not allowed");
|
|
77713
|
+
validated.push({ address: entry.address, family });
|
|
77714
|
+
}
|
|
77715
|
+
if (validated.length === 0)
|
|
77716
|
+
throw new Error("Peer host address could not be resolved");
|
|
77717
|
+
return validated;
|
|
77718
|
+
});
|
|
77719
|
+
return signal ? await new Promise((resolve26, reject) => {
|
|
77720
|
+
let onAbort = () => reject(toAbortError(signal));
|
|
77721
|
+
signal.addEventListener("abort", onAbort, { once: !0 }), lookupPromise.then(
|
|
77722
|
+
(resolved) => {
|
|
77723
|
+
signal.removeEventListener("abort", onAbort), resolve26(resolved);
|
|
77724
|
+
},
|
|
77725
|
+
(err5) => {
|
|
77726
|
+
signal.removeEventListener("abort", onAbort), signal.aborted ? reject(toAbortError(signal)) : reject(err5);
|
|
77727
|
+
}
|
|
77728
|
+
);
|
|
77729
|
+
}) : await lookupPromise;
|
|
77730
|
+
}
|
|
77731
|
+
async function resolvePeerOutboundRoute(target2, options = {}) {
|
|
77732
|
+
let effectiveAllowLoopback = options.allowLoopback ?? isLoopbackHost2(target2.hostname);
|
|
77733
|
+
assertAllowedPeerHost(target2.hostname, { allowLoopback: effectiveAllowLoopback });
|
|
77734
|
+
let candidateProxy = resolvePeerProxyUrl(target2), bareTarget = stripBrackets(target2.hostname);
|
|
77735
|
+
if (isIP2(bareTarget) !== 0)
|
|
77736
|
+
return candidateProxy ? { proxy: candidateProxy } : {};
|
|
77737
|
+
let resolvedAddresses = options.resolvedAddresses;
|
|
77738
|
+
if (resolvedAddresses === void 0)
|
|
77739
|
+
try {
|
|
77740
|
+
resolvedAddresses = await resolveHostAddresses(bareTarget, options.dnsLookup, options.signal);
|
|
77741
|
+
} catch (err5) {
|
|
77742
|
+
if (candidateProxy && isDnsResolutionError(err5))
|
|
77743
|
+
return { proxy: candidateProxy };
|
|
77744
|
+
throw err5;
|
|
77745
|
+
}
|
|
77746
|
+
for (let entry of resolvedAddresses)
|
|
77747
|
+
assertAllowedPeerHost(entry.address, { allowLoopback: effectiveAllowLoopback });
|
|
77748
|
+
let finalProxy = candidateProxy ? resolvePeerProxyUrl(target2, { resolvedAddresses }) : void 0;
|
|
77749
|
+
return finalProxy ? { proxy: finalProxy } : resolvedAddresses.length > 0 ? { lookup: createPinnedLookup(resolvedAddresses) } : {};
|
|
77750
|
+
}
|
|
77751
|
+
function cancelUploadBodyIfStream(body, reason) {
|
|
77752
|
+
body instanceof ReadableStream && body.cancel(reason).catch(() => {
|
|
77753
|
+
});
|
|
77754
|
+
}
|
|
77755
|
+
async function nodeFetchViaAdapter(target2, init, route) {
|
|
77756
|
+
let signal = init?.signal ?? void 0;
|
|
77757
|
+
if (signal?.aborted)
|
|
77758
|
+
throw await cancelUploadBodyIfStream(init?.body, signal.reason), toAbortError(signal);
|
|
77759
|
+
let method2 = init?.method ?? "GET", headersObj = {};
|
|
77760
|
+
init?.headers && new Headers(init.headers).forEach((value, key) => {
|
|
77761
|
+
headersObj[key] = value;
|
|
77762
|
+
});
|
|
77763
|
+
let preparedBody = await prepareFetchBody(init?.body);
|
|
77764
|
+
if (preparedBody.kind === "buffer" && (preparedBody.contentType && headersObj["content-type"] === void 0 && (headersObj["content-type"] = preparedBody.contentType), headersObj["content-length"] === void 0 && headersObj["transfer-encoding"] === void 0 && (headersObj["content-length"] = String(preparedBody.buffer.byteLength))), signal?.aborted)
|
|
77765
|
+
throw preparedBody.kind === "stream" && await preparedBody.stream.cancel(signal.reason).catch(() => {
|
|
77766
|
+
}), toAbortError(signal);
|
|
77767
|
+
return new Promise((resolve26, reject) => {
|
|
77768
|
+
let settled2 = !1, fail = (err5) => {
|
|
77769
|
+
settled2 || (settled2 = !0, reject(err5 instanceof Error ? err5 : new Error(String(err5))));
|
|
77770
|
+
}, req = openPeerHttpRequest(target2, {
|
|
77771
|
+
method: method2,
|
|
77772
|
+
headers: headersObj,
|
|
77773
|
+
...route.proxy ? { proxy: route.proxy } : {},
|
|
77774
|
+
...!route.proxy && route.lookup ? { lookup: route.lookup } : {},
|
|
77775
|
+
...signal ? { signal } : {}
|
|
77776
|
+
});
|
|
77777
|
+
if (req.once("error", fail), req.once("upgrade", (_res, socket) => {
|
|
77778
|
+
socket.destroy(), req.destroy(), fail(new Error("Unexpected HTTP protocol upgrade response"));
|
|
77779
|
+
}), req.once("response", (res) => {
|
|
77780
|
+
let status = res.statusCode ?? 0;
|
|
77781
|
+
if (init?.redirect === "error" && REDIRECT_STATUSES.has(status)) {
|
|
77782
|
+
res.resume(), req.destroy(), fail(new TypeError("redirect mode is set to error"));
|
|
77783
|
+
return;
|
|
77784
|
+
}
|
|
77785
|
+
if (settled2) {
|
|
77786
|
+
res.destroy();
|
|
77787
|
+
return;
|
|
77788
|
+
}
|
|
77789
|
+
let response;
|
|
77790
|
+
try {
|
|
77791
|
+
response = toFetchResponse(res, method2, signal);
|
|
77792
|
+
} catch (err5) {
|
|
77793
|
+
res.destroy(), req.destroy(), fail(err5);
|
|
77794
|
+
return;
|
|
77795
|
+
}
|
|
77796
|
+
settled2 = !0, resolve26(response);
|
|
77797
|
+
}), preparedBody.kind === "empty")
|
|
77798
|
+
req.end();
|
|
77799
|
+
else if (preparedBody.kind === "buffer")
|
|
77800
|
+
req.end(preparedBody.buffer);
|
|
77801
|
+
else {
|
|
77802
|
+
let reader = preparedBody.stream.getReader(), streamDone = !1, cancelUpload = (reason) => {
|
|
77803
|
+
streamDone || (streamDone = !0, reader.cancel(reason).catch(() => {
|
|
77804
|
+
}));
|
|
77805
|
+
}, onReqClose = () => cancelUpload(signal?.aborted ? signal.reason : void 0), onReqError = (err5) => cancelUpload(err5), onSignalAbort = () => cancelUpload(signal?.reason);
|
|
77806
|
+
req.once("close", onReqClose), req.once("error", onReqError), signal?.addEventListener("abort", onSignalAbort, { once: !0 }), (async () => {
|
|
77807
|
+
try {
|
|
77808
|
+
for (; !(req.destroyed || signal?.aborted); ) {
|
|
77809
|
+
let { done, value } = await reader.read();
|
|
77810
|
+
if (done) {
|
|
77811
|
+
streamDone = !0;
|
|
77812
|
+
break;
|
|
77813
|
+
}
|
|
77814
|
+
if (req.destroyed || signal?.aborted || !req.write(value) && !await waitForDrain(req, signal))
|
|
77815
|
+
break;
|
|
77816
|
+
}
|
|
77817
|
+
!req.destroyed && !req.writableEnded && !signal?.aborted && req.end();
|
|
77818
|
+
} catch (err5) {
|
|
77819
|
+
streamDone = !0, req.destroy(), fail(err5);
|
|
77820
|
+
} finally {
|
|
77821
|
+
streamDone || (streamDone = !0, await reader.cancel(signal?.aborted ? signal.reason : void 0).catch(() => {
|
|
77822
|
+
})), reader.releaseLock(), req.off("close", onReqClose), req.off("error", onReqError), signal?.removeEventListener("abort", onSignalAbort);
|
|
77823
|
+
}
|
|
77824
|
+
})();
|
|
77825
|
+
}
|
|
77826
|
+
});
|
|
77827
|
+
}
|
|
77828
|
+
async function peerOutboundFetch(input3, init) {
|
|
77829
|
+
if (globalThis.fetch !== BUILTIN_FETCH) {
|
|
77830
|
+
if (!init) return globalThis.fetch(input3);
|
|
77831
|
+
let {
|
|
77832
|
+
allowLoopback: _allowLoopback,
|
|
77833
|
+
dnsLookup: _dnsLookup,
|
|
77834
|
+
resolvedAddresses: _resolvedAddresses,
|
|
77835
|
+
...fetchInit
|
|
77836
|
+
} = init;
|
|
77837
|
+
return globalThis.fetch(input3, fetchInit);
|
|
77838
|
+
}
|
|
77839
|
+
let target2, route;
|
|
77840
|
+
try {
|
|
77841
|
+
target2 = typeof input3 == "string" ? new URL(input3) : input3, route = await resolvePeerOutboundRoute(target2, {
|
|
77842
|
+
allowLoopback: init?.allowLoopback,
|
|
77843
|
+
dnsLookup: init?.dnsLookup,
|
|
77844
|
+
resolvedAddresses: init?.resolvedAddresses,
|
|
77845
|
+
signal: init?.signal ?? void 0
|
|
77846
|
+
});
|
|
77847
|
+
} catch (err5) {
|
|
77848
|
+
throw cancelUploadBodyIfStream(init?.body, init?.signal?.aborted ? init.signal.reason : err5), err5;
|
|
77849
|
+
}
|
|
77850
|
+
return nodeFetchViaAdapter(target2, init, route);
|
|
77851
|
+
}
|
|
77852
|
+
|
|
77261
77853
|
// packages/web-server/src/peer-request-error.ts
|
|
77262
77854
|
var TIMEOUT_CODES = /* @__PURE__ */ new Set([
|
|
77263
77855
|
"ETIMEDOUT",
|
|
@@ -77353,8 +77945,11 @@ async function peerFetch(record6, path7, init = {}) {
|
|
|
77353
77945
|
headers: headers2,
|
|
77354
77946
|
...requestBody === void 0 ? {} : { body: requestBody },
|
|
77355
77947
|
...init.duplex === void 0 ? {} : { duplex: init.duplex },
|
|
77356
|
-
...signal === void 0 ? {} : { signal }
|
|
77357
|
-
|
|
77948
|
+
...signal === void 0 ? {} : { signal },
|
|
77949
|
+
...init.allowLoopback === void 0 ? {} : { allowLoopback: init.allowLoopback },
|
|
77950
|
+
...init.dnsLookup === void 0 ? {} : { dnsLookup: init.dnsLookup },
|
|
77951
|
+
...init.resolvedAddresses === void 0 ? {} : { resolvedAddresses: init.resolvedAddresses }
|
|
77952
|
+
}, res = await peerOutboundFetch(record6.origin + path7, requestInit);
|
|
77358
77953
|
if (res.ok || res.status === 304 && headers2.has("if-none-match")) return res;
|
|
77359
77954
|
let failure3 = await res.json().then((payload) => {
|
|
77360
77955
|
if (!payload || typeof payload != "object" || !("error" in payload)) return;
|
|
@@ -77405,54 +78000,33 @@ async function pinnedPeerGetJson(record6, path7, options = {}) {
|
|
|
77405
78000
|
if (!record6.enabled) throw new SessionRuntimeError("remote/offline", "Remote peer is disabled");
|
|
77406
78001
|
let url2 = parsePeerUrl(record6.origin + path7, {
|
|
77407
78002
|
allowLoopback: options.allowLoopback === !0
|
|
77408
|
-
}),
|
|
77409
|
-
|
|
77410
|
-
|
|
77411
|
-
|
|
77412
|
-
|
|
77413
|
-
|
|
77414
|
-
|
|
77415
|
-
|
|
77416
|
-
|
|
77417
|
-
|
|
77418
|
-
|
|
77419
|
-
|
|
77420
|
-
let family = typeof lookupOptions == "number" ? lookupOptions : opts.family, match = family === 4 || family === 6 ? verified.find((entry) => entry.family === family) : verified[0];
|
|
77421
|
-
if (!match) {
|
|
77422
|
-
callback(
|
|
77423
|
-
Object.assign(new Error("No verified address matches requested IP family"), {
|
|
77424
|
-
code: "ENOTFOUND"
|
|
77425
|
-
}),
|
|
77426
|
-
"",
|
|
77427
|
-
4
|
|
77428
|
-
);
|
|
77429
|
-
return;
|
|
77430
|
-
}
|
|
77431
|
-
callback(null, match.address, match.family);
|
|
77432
|
-
};
|
|
78003
|
+
}), candidateProxy = resolvePeerProxyUrl(url2), verified;
|
|
78004
|
+
try {
|
|
78005
|
+
verified = await resolveAndValidatePeerHost(url2, {
|
|
78006
|
+
allowLoopback: options.allowLoopback === !0,
|
|
78007
|
+
dnsLookup: options.dnsLookup
|
|
78008
|
+
});
|
|
78009
|
+
} catch (err5) {
|
|
78010
|
+
if (err5 instanceof PeerHostPolicyError || !candidateProxy || options.dnsLookup !== void 0 || !isDnsResolutionError(err5))
|
|
78011
|
+
throw err5;
|
|
78012
|
+
}
|
|
78013
|
+
options.onResolved?.(verified);
|
|
78014
|
+
let proxy = verified ? resolvePeerProxyUrl(url2, { resolvedAddresses: verified }) : candidateProxy, timeoutSignal = AbortSignal.timeout(options.timeoutMs ?? 8e3), signal = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal, pinnedLookup = verified ? createPinnedLookup(verified) : void 0;
|
|
77433
78015
|
return await new Promise((resolve26, reject) => {
|
|
77434
78016
|
let settled2 = !1, fail = (err5) => {
|
|
77435
78017
|
settled2 || (settled2 = !0, reject(err5));
|
|
77436
78018
|
}, succeed = (value) => {
|
|
77437
78019
|
settled2 || (settled2 = !0, resolve26(value));
|
|
77438
|
-
},
|
|
77439
|
-
protocol: url2.protocol,
|
|
77440
|
-
hostname: bareHostname,
|
|
77441
|
-
...url2.port ? { port: Number(url2.port) } : {},
|
|
77442
|
-
path: `${url2.pathname}${url2.search}`,
|
|
78020
|
+
}, req = openPeerHttpRequest(url2, {
|
|
77443
78021
|
method: "GET",
|
|
77444
78022
|
headers: {
|
|
77445
|
-
host: url2.host,
|
|
77446
78023
|
authorization: "Bearer " + record6.token,
|
|
77447
78024
|
"content-type": "application/json"
|
|
77448
78025
|
},
|
|
77449
|
-
|
|
77450
|
-
lookup: pinnedLookup,
|
|
78026
|
+
...proxy ? { proxy } : {},
|
|
78027
|
+
...!proxy && pinnedLookup ? { lookup: pinnedLookup } : {},
|
|
77451
78028
|
signal
|
|
77452
|
-
}
|
|
77453
|
-
...requestOptions,
|
|
77454
|
-
...isIP2(bareHostname) === 0 ? { servername: bareHostname } : {}
|
|
77455
|
-
}) : httpRequest(requestOptions);
|
|
78029
|
+
});
|
|
77456
78030
|
req.on("error", () => {
|
|
77457
78031
|
fail(new SessionRuntimeError("remote/offline", "Remote peer is unreachable"));
|
|
77458
78032
|
}), req.on("response", (res) => {
|
|
@@ -77533,6 +78107,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77533
78107
|
rejectNodeId;
|
|
77534
78108
|
allowLoopback;
|
|
77535
78109
|
dnsLookup;
|
|
78110
|
+
probedAddresses;
|
|
77536
78111
|
fullKnownTurns = /* @__PURE__ */ new Map();
|
|
77537
78112
|
truncatedKnownTurns = /* @__PURE__ */ new Map();
|
|
77538
78113
|
knownTurnsEpoch;
|
|
@@ -77641,11 +78216,18 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77641
78216
|
manifest: () => this.manifest
|
|
77642
78217
|
};
|
|
77643
78218
|
}
|
|
78219
|
+
outboundFetchOptions() {
|
|
78220
|
+
return {
|
|
78221
|
+
allowLoopback: this.allowLoopback,
|
|
78222
|
+
...this.probedAddresses !== void 0 ? { resolvedAddresses: this.probedAddresses } : this.dnsLookup !== void 0 ? { dnsLookup: this.dnsLookup } : {}
|
|
78223
|
+
};
|
|
78224
|
+
}
|
|
77644
78225
|
fetch(path7, method2 = "GET", body, streamSignal) {
|
|
77645
78226
|
return peerFetch(this.record, path7, {
|
|
77646
78227
|
method: method2,
|
|
77647
78228
|
...body === void 0 ? {} : { body },
|
|
77648
|
-
...streamSignal ? { stream: !0, signal: AbortSignal.any([streamSignal, this.life.signal]) } : { signal: this.life.signal }
|
|
78229
|
+
...streamSignal ? { stream: !0, signal: AbortSignal.any([streamSignal, this.life.signal]) } : { signal: this.life.signal },
|
|
78230
|
+
...this.outboundFetchOptions()
|
|
77649
78231
|
});
|
|
77650
78232
|
}
|
|
77651
78233
|
async waitForInitialConnection() {
|
|
@@ -77663,18 +78245,21 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77663
78245
|
async probe() {
|
|
77664
78246
|
let start = Date.now();
|
|
77665
78247
|
try {
|
|
77666
|
-
let manifest2 = remotePeerManifestSchema.parse(
|
|
78248
|
+
let resolvedAddresses, manifest2 = remotePeerManifestSchema.parse(
|
|
77667
78249
|
await pinnedPeerGetJson(this.record, "/api/peer/v1/manifest", {
|
|
77668
78250
|
allowLoopback: this.allowLoopback,
|
|
77669
78251
|
dnsLookup: this.dnsLookup,
|
|
77670
|
-
signal: this.life.signal
|
|
78252
|
+
signal: this.life.signal,
|
|
78253
|
+
onResolved: (addresses) => {
|
|
78254
|
+
resolvedAddresses = addresses;
|
|
78255
|
+
}
|
|
77671
78256
|
})
|
|
77672
78257
|
);
|
|
77673
78258
|
if (this.rejectNodeId !== void 0 && manifest2.nodeId === this.rejectNodeId)
|
|
77674
78259
|
throw Error(SELF_PAIR_ERROR);
|
|
77675
|
-
this.manifest = manifest2, this.manifestVerified = !0, this.latencyMs = Date.now() - start, delete this.lastError, this.state = this.streamOnline ? "connected" : "connecting";
|
|
78260
|
+
this.probedAddresses = resolvedAddresses, this.manifest = manifest2, this.manifestVerified = !0, this.latencyMs = Date.now() - start, delete this.lastError, this.state = this.streamOnline ? "connected" : "connecting";
|
|
77676
78261
|
} catch (e) {
|
|
77677
|
-
if (this.manifestVerified = !1, e instanceof PeerHostPolicyError || e instanceof Error && e.message === SELF_PAIR_ERROR)
|
|
78262
|
+
if (this.manifestVerified = !1, this.probedAddresses = void 0, e instanceof PeerHostPolicyError || e instanceof PeerProxyConfigError || e instanceof Error && e.message === SELF_PAIR_ERROR)
|
|
77678
78263
|
throw delete this.manifest, this.state = "offline", this.lastError = e.message, this.setStreamOffline(), this.initialConnection.resolve(void 0), e;
|
|
77679
78264
|
this.state = e instanceof SessionRuntimeError && e.code === "remote/auth-error" ? "auth-error" : "offline";
|
|
77680
78265
|
let message2 = this.state === "auth-error" ? "Remote peer rejected the access token" : "Remote peer manifest unavailable";
|
|
@@ -77750,7 +78335,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77750
78335
|
}
|
|
77751
78336
|
}
|
|
77752
78337
|
close() {
|
|
77753
|
-
this.life.abort(), this.manifestVerified = !1, this.record = { ...this.record, token: "" }, this.initialConnection.resolve(void 0), this.setStreamOffline(), this.listeners.clear(), this.fullKnownTurns.clear(), this.truncatedKnownTurns.clear(), this.knownTurnsEpoch = void 0;
|
|
78338
|
+
this.life.abort(), this.manifestVerified = !1, this.probedAddresses = void 0, this.record = { ...this.record, token: "" }, this.initialConnection.resolve(void 0), this.setStreamOffline(), this.listeners.clear(), this.fullKnownTurns.clear(), this.truncatedKnownTurns.clear(), this.knownTurnsEpoch = void 0;
|
|
77754
78339
|
}
|
|
77755
78340
|
async introduce(params) {
|
|
77756
78341
|
if (!this.isHttpReady)
|
|
@@ -77761,7 +78346,8 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77761
78346
|
method: "POST",
|
|
77762
78347
|
body: params,
|
|
77763
78348
|
timeoutMs: 15e3,
|
|
77764
|
-
signal: this.life.signal
|
|
78349
|
+
signal: this.life.signal,
|
|
78350
|
+
...this.outboundFetchOptions()
|
|
77765
78351
|
}), result = remotePeerIntroduceResultSchema.safeParse(
|
|
77766
78352
|
await response.json().catch(() => {
|
|
77767
78353
|
})
|
|
@@ -77817,7 +78403,8 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77817
78403
|
sourceId: request3.sourceId ?? this.record.peerId
|
|
77818
78404
|
},
|
|
77819
78405
|
signal,
|
|
77820
|
-
timeoutMs: options.timeoutMs ?? defaultTimeoutMs
|
|
78406
|
+
timeoutMs: options.timeoutMs ?? defaultTimeoutMs,
|
|
78407
|
+
...this.outboundFetchOptions()
|
|
77821
78408
|
}), payload;
|
|
77822
78409
|
try {
|
|
77823
78410
|
payload = await res.json();
|
|
@@ -78508,9 +79095,9 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
78508
79095
|
}
|
|
78509
79096
|
return inspection;
|
|
78510
79097
|
}
|
|
78511
|
-
async models(refresh = !1, harnessId, preferences2) {
|
|
79098
|
+
async models(refresh = !1, harnessId, preferences2, projectHarnessId2) {
|
|
78512
79099
|
if (!refresh)
|
|
78513
|
-
return await Promise.allSettled(this.refreshing.values()), this.readModels(!1, void 0, preferences2);
|
|
79100
|
+
return await Promise.allSettled(this.refreshing.values()), this.readModels(!1, void 0, preferences2, projectHarnessId2);
|
|
78514
79101
|
let pending = this.refreshing.get(harnessId);
|
|
78515
79102
|
if (pending) return pending;
|
|
78516
79103
|
let operation = this.readModels(!0, harnessId).finally(() => {
|
|
@@ -78559,7 +79146,7 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
78559
79146
|
}
|
|
78560
79147
|
)), id2 === "codex" ? void 0 : timedOutInspection();
|
|
78561
79148
|
}
|
|
78562
|
-
async readModels(refresh, harnessId, preferences2) {
|
|
79149
|
+
async readModels(refresh, harnessId, preferences2, projectHarnessId2) {
|
|
78563
79150
|
let shouldRefresh = (id2) => refresh && (harnessId === void 0 || harnessId === id2), plugins2 = await this.list(), values2 = (await Promise.all(
|
|
78564
79151
|
plugins2.map(async ({ id: id2, name: name2, links }) => ({
|
|
78565
79152
|
id: id2,
|
|
@@ -78585,9 +79172,9 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
78585
79172
|
}
|
|
78586
79173
|
let groups = values2.flatMap(
|
|
78587
79174
|
({ id: id2, name: name2, inspection }) => inspection.status === "ready" ? [groupOf(id2, name2, inspection)] : []
|
|
78588
|
-
),
|
|
79175
|
+
), ready = values2.filter(
|
|
78589
79176
|
(value) => value.inspection.status === "ready" && value.inspection.catalog.models.length
|
|
78590
|
-
), failures = values2.flatMap(
|
|
79177
|
+
), projectHarness = ready.find((value) => value.id === projectHarnessId2), first = projectHarness ?? ready[0], failures = values2.flatMap(
|
|
78591
79178
|
({ id: id2, name: name2, inspection }) => inspection.status !== "ready" && inspection.status !== "notInstalled" ? [
|
|
78592
79179
|
{
|
|
78593
79180
|
id: id2,
|
|
@@ -78617,7 +79204,11 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
78617
79204
|
},
|
|
78618
79205
|
await this.displayEntries()
|
|
78619
79206
|
);
|
|
78620
|
-
return this.preferences && selection2 ? this.preferences.decorate(
|
|
79207
|
+
return this.preferences && selection2 ? this.preferences.decorate(
|
|
79208
|
+
{ ...catalog, default: selection2 },
|
|
79209
|
+
preferences2,
|
|
79210
|
+
projectHarness?.id
|
|
79211
|
+
) : catalog;
|
|
78621
79212
|
}
|
|
78622
79213
|
async name(id2) {
|
|
78623
79214
|
return id2 === "codex" ? "Codex" : (await this.list()).find((plugin) => plugin.id === id2)?.name ?? id2;
|
|
@@ -78643,6 +79234,10 @@ var permissionCommand = {
|
|
|
78643
79234
|
name: "permission",
|
|
78644
79235
|
description: "Select a native permission mode",
|
|
78645
79236
|
input: { hint: "<mode>" }
|
|
79237
|
+
}, codexPlanCommand = {
|
|
79238
|
+
definitionId: "@deepseek-ai/dsh-plan-mode",
|
|
79239
|
+
name: "plan",
|
|
79240
|
+
description: "Enter or leave native Codex Plan Mode"
|
|
78646
79241
|
};
|
|
78647
79242
|
function requireDirectCommand(catalog, commandId) {
|
|
78648
79243
|
let command = catalog.commands.find((item) => item.id === commandId);
|
|
@@ -80313,6 +80908,8 @@ function markdownImageAlt(path7) {
|
|
|
80313
80908
|
function itemOf(item, reasoningPreviewIds, projectImage, projectionKey, projectText) {
|
|
80314
80909
|
let itemId = item.id;
|
|
80315
80910
|
switch (item.type) {
|
|
80911
|
+
case "plan":
|
|
80912
|
+
return typeof item.text != "string" || !item.text.trim() ? void 0 : { type: "agentMessage", itemId, text: projectText(item.text) };
|
|
80316
80913
|
case "agentMessage":
|
|
80317
80914
|
return {
|
|
80318
80915
|
type: "agentMessage",
|
|
@@ -83575,7 +84172,16 @@ import { dirname as dirname5, isAbsolute as isAbsolute6, join as join9, parse as
|
|
|
83575
84172
|
// packages/web-server/src/compression.ts
|
|
83576
84173
|
import { promisify as promisify2 } from "node:util";
|
|
83577
84174
|
import { brotliCompress, constants as constants3, gzip } from "node:zlib";
|
|
83578
|
-
var COMPRESSION_THRESHOLD = 1024, brotliAsync = promisify2(brotliCompress), gzipAsync = promisify2(gzip), compressedAssets = /* @__PURE__ */ new Map();
|
|
84175
|
+
var COMPRESSION_THRESHOLD = 1024, brotliAsync = promisify2(brotliCompress), gzipAsync = promisify2(gzip), MAX_COMPRESSED_CACHE_ENTRIES = 64, MAX_COMPRESSED_CACHE_BYTES = 8 * 1024 * 1024, MAX_CACHED_UNCOMPRESSED_BYTES = 512 * 1024, compressedAssets = /* @__PURE__ */ new Map(), inFlightCompressed = /* @__PURE__ */ new Map(), compressedAssetBytes = 0;
|
|
84176
|
+
function cacheCompressedAsset(key, buffer3) {
|
|
84177
|
+
if (buffer3.byteLength > MAX_COMPRESSED_CACHE_BYTES) return;
|
|
84178
|
+
let existing = compressedAssets.get(key);
|
|
84179
|
+
for (existing !== void 0 && (compressedAssetBytes -= existing.byteLength, compressedAssets.delete(key)), compressedAssets.set(key, buffer3), compressedAssetBytes += buffer3.byteLength; compressedAssets.size > MAX_COMPRESSED_CACHE_ENTRIES || compressedAssetBytes > MAX_COMPRESSED_CACHE_BYTES; ) {
|
|
84180
|
+
let oldest = compressedAssets.entries().next().value;
|
|
84181
|
+
if (!oldest) break;
|
|
84182
|
+
compressedAssets.delete(oldest[0]), compressedAssetBytes -= oldest[1].byteLength;
|
|
84183
|
+
}
|
|
84184
|
+
}
|
|
83579
84185
|
function isCompressible(contentType) {
|
|
83580
84186
|
let type2 = contentType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
83581
84187
|
return type2.startsWith("text/") || [
|
|
@@ -83598,12 +84204,27 @@ async function compressResponse(body, contentType, acceptEncoding, cacheKey) {
|
|
|
83598
84204
|
headers2.vary = "Accept-Encoding";
|
|
83599
84205
|
let encoding = negotiate(acceptEncoding);
|
|
83600
84206
|
if (encoding === void 0 || body.length < COMPRESSION_THRESHOLD) return { body, headers: headers2 };
|
|
83601
|
-
let key = cacheKey === void 0 ? void 0 : `${encoding}:${cacheKey}
|
|
83602
|
-
|
|
84207
|
+
let key = cacheKey === void 0 ? void 0 : `${encoding}:${cacheKey}`;
|
|
84208
|
+
if (key !== void 0) {
|
|
84209
|
+
let cached3 = compressedAssets.get(key);
|
|
84210
|
+
if (cached3 !== void 0)
|
|
84211
|
+
return compressedAssets.delete(key), compressedAssets.set(key, cached3), headers2["content-encoding"] = encoding, { body: cached3, headers: headers2 };
|
|
84212
|
+
}
|
|
84213
|
+
let compressed = key === void 0 ? void 0 : inFlightCompressed.get(key);
|
|
84214
|
+
if (compressed === void 0) {
|
|
84215
|
+
let shouldCache = key !== void 0 && body.byteLength <= MAX_CACHED_UNCOMPRESSED_BYTES;
|
|
84216
|
+
if (compressed = (encoding === "br" ? brotliAsync(body, { params: { [constants3.BROTLI_PARAM_QUALITY]: 5 } }) : gzipAsync(body, { level: 6 })).then((result) => (shouldCache && key !== void 0 && cacheCompressedAsset(key, result), result)), key !== void 0) {
|
|
84217
|
+
let pending = compressed, cleanup = () => {
|
|
84218
|
+
inFlightCompressed.get(key) === pending && inFlightCompressed.delete(key);
|
|
84219
|
+
};
|
|
84220
|
+
inFlightCompressed.set(key, pending), pending.then(cleanup, cleanup);
|
|
84221
|
+
}
|
|
84222
|
+
}
|
|
84223
|
+
return headers2["content-encoding"] = encoding, { body: await compressed, headers: headers2 };
|
|
83603
84224
|
}
|
|
83604
84225
|
|
|
83605
84226
|
// packages/web-server/src/peer-image-http.ts
|
|
83606
|
-
import { Readable } from "node:stream";
|
|
84227
|
+
import { Readable as Readable2 } from "node:stream";
|
|
83607
84228
|
import { pipeline } from "node:stream/promises";
|
|
83608
84229
|
|
|
83609
84230
|
// packages/web-server/src/http-content-length.ts
|
|
@@ -83689,7 +84310,7 @@ async function servePeerImageBody(upstream, response, etag, length) {
|
|
|
83689
84310
|
async function* body() {
|
|
83690
84311
|
yield* parts, yield* chunks;
|
|
83691
84312
|
}
|
|
83692
|
-
await pipeline(
|
|
84313
|
+
await pipeline(Readable2.from(body(), { objectMode: !1 }), response);
|
|
83693
84314
|
return;
|
|
83694
84315
|
}
|
|
83695
84316
|
for await (let chunk of chunks) parts.push(chunk);
|
|
@@ -84543,7 +85164,7 @@ async function startPeerDelegationBridge(options) {
|
|
|
84543
85164
|
|
|
84544
85165
|
// packages/web-server/src/peer-workspace-files-http.ts
|
|
84545
85166
|
import { extname as extname6, posix as posix3, win32 as win327 } from "node:path";
|
|
84546
|
-
import { Readable as
|
|
85167
|
+
import { Readable as Readable5 } from "node:stream";
|
|
84547
85168
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
84548
85169
|
|
|
84549
85170
|
// apps/web-ui/packages/host/dsh-web-backend/src/index.ts
|
|
@@ -89660,7 +90281,7 @@ var clientRequestSchema = external_exports.object({
|
|
|
89660
90281
|
]);
|
|
89661
90282
|
|
|
89662
90283
|
// apps/web-ui/packages/client/connection/src/http-bridge.ts
|
|
89663
|
-
import { Readable as
|
|
90284
|
+
import { Readable as Readable3 } from "node:stream";
|
|
89664
90285
|
var DEFAULT_MAX_REQUEST_BODY_BYTES = 300 * 1024 * 1024;
|
|
89665
90286
|
async function bridge(req, res, apiHandler, maxRequestBodyBytes = DEFAULT_MAX_REQUEST_BODY_BYTES) {
|
|
89666
90287
|
let abort = new AbortController();
|
|
@@ -89695,7 +90316,7 @@ async function bridge(req, res, apiHandler, maxRequestBodyBytes = DEFAULT_MAX_RE
|
|
|
89695
90316
|
request3 = new Request(url2, {
|
|
89696
90317
|
method: method2,
|
|
89697
90318
|
headers: headers2,
|
|
89698
|
-
body:
|
|
90319
|
+
body: Readable3.toWeb(req),
|
|
89699
90320
|
signal: abort.signal,
|
|
89700
90321
|
duplex: "half"
|
|
89701
90322
|
});
|
|
@@ -89987,7 +90608,7 @@ import * as sysPath2 from "path";
|
|
|
89987
90608
|
|
|
89988
90609
|
// node_modules/readdirp/esm/index.js
|
|
89989
90610
|
import { stat as stat4, lstat as lstat4, readdir as readdir3, realpath as realpath3 } from "node:fs/promises";
|
|
89990
|
-
import { Readable as
|
|
90611
|
+
import { Readable as Readable4 } from "node:stream";
|
|
89991
90612
|
import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from "node:path";
|
|
89992
90613
|
var EntryTypes = {
|
|
89993
90614
|
FILE_TYPE: "files",
|
|
@@ -90032,7 +90653,7 @@ var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR", NORMAL_FLOW_ERRORS = /* @
|
|
|
90032
90653
|
return (entry) => trItems.some((f) => entry.basename === f);
|
|
90033
90654
|
}
|
|
90034
90655
|
return emptyFn;
|
|
90035
|
-
}, ReaddirpStream = class extends
|
|
90656
|
+
}, ReaddirpStream = class extends Readable4 {
|
|
90036
90657
|
constructor(options = {}) {
|
|
90037
90658
|
super({
|
|
90038
90659
|
objectMode: !0,
|
|
@@ -101463,39 +102084,64 @@ function waitForPromise(promise2, signal) {
|
|
|
101463
102084
|
function errorReason(reason, fallback) {
|
|
101464
102085
|
return reason instanceof Error ? reason : new Error(fallback, { cause: reason });
|
|
101465
102086
|
}
|
|
101466
|
-
var DEFAULT_CACHE_MAX_ROOTS =
|
|
102087
|
+
var DEFAULT_CACHE_MAX_ROOTS = 8, DEFAULT_CACHE_REFRESH_INTERVAL_MS = 2e3, DEFAULT_CACHE_IDLE_TTL_MS = 10 * 6e4, DEFAULT_CACHE_SWEEP_INTERVAL_MS = 6e4, WorkspaceFileSearchCache = class {
|
|
101467
102088
|
searches = /* @__PURE__ */ new Map();
|
|
101468
102089
|
maxRoots;
|
|
101469
102090
|
refreshIntervalMs;
|
|
102091
|
+
idleTtlMs;
|
|
101470
102092
|
config;
|
|
102093
|
+
sweepTimer;
|
|
101471
102094
|
disposed = !1;
|
|
101472
102095
|
constructor(options = {}) {
|
|
101473
|
-
this.maxRoots = options.maxRoots ?? DEFAULT_CACHE_MAX_ROOTS, this.refreshIntervalMs = options.refreshIntervalMs ?? DEFAULT_CACHE_REFRESH_INTERVAL_MS, this.config = options.config ?? {
|
|
102096
|
+
this.maxRoots = options.maxRoots ?? DEFAULT_CACHE_MAX_ROOTS, this.refreshIntervalMs = options.refreshIntervalMs ?? DEFAULT_CACHE_REFRESH_INTERVAL_MS, this.idleTtlMs = options.idleTtlMs ?? DEFAULT_CACHE_IDLE_TTL_MS, this.config = options.config ?? {
|
|
101474
102097
|
maxResults: DEFAULT_FILE_SEARCH_MAX_RESULTS,
|
|
101475
102098
|
maxEntries: DEFAULT_FILE_SEARCH_MAX_ENTRIES,
|
|
101476
102099
|
excludedDirectories: DEFAULT_FILE_SEARCH_EXCLUDED_DIRECTORIES
|
|
101477
102100
|
};
|
|
101478
102101
|
}
|
|
102102
|
+
ensureSweepTimer() {
|
|
102103
|
+
if (this.sweepTimer || this.disposed || this.idleTtlMs <= 0) return;
|
|
102104
|
+
let intervalMs = Math.min(DEFAULT_CACHE_SWEEP_INTERVAL_MS, Math.max(1e3, this.idleTtlMs));
|
|
102105
|
+
this.sweepTimer = setInterval(() => {
|
|
102106
|
+
this.sweepIdle(Date.now());
|
|
102107
|
+
}, intervalMs), this.sweepTimer.unref();
|
|
102108
|
+
}
|
|
102109
|
+
stopSweepTimer() {
|
|
102110
|
+
this.sweepTimer && (clearInterval(this.sweepTimer), this.sweepTimer = void 0);
|
|
102111
|
+
}
|
|
102112
|
+
sweepIdle(now) {
|
|
102113
|
+
if (!(this.idleTtlMs <= 0)) {
|
|
102114
|
+
for (let [root, entry] of this.searches)
|
|
102115
|
+
entry.inFlight === 0 && now - entry.lastAccessedAt >= this.idleTtlMs && (entry.search.dispose(), this.searches.delete(root));
|
|
102116
|
+
this.searches.size === 0 && this.stopSweepTimer();
|
|
102117
|
+
}
|
|
102118
|
+
}
|
|
102119
|
+
evictOverflow() {
|
|
102120
|
+
for (let [candidateRoot, candidate] of this.searches) {
|
|
102121
|
+
if (this.searches.size <= this.maxRoots) break;
|
|
102122
|
+
candidate.inFlight > 0 || (candidate.search.dispose(), this.searches.delete(candidateRoot));
|
|
102123
|
+
}
|
|
102124
|
+
}
|
|
101479
102125
|
async list(root, query, signal) {
|
|
101480
102126
|
if (signal.throwIfAborted(), this.disposed) return [];
|
|
101481
|
-
let now = Date.now()
|
|
101482
|
-
|
|
101483
|
-
|
|
101484
|
-
|
|
101485
|
-
|
|
101486
|
-
|
|
101487
|
-
|
|
101488
|
-
|
|
101489
|
-
|
|
101490
|
-
|
|
101491
|
-
|
|
101492
|
-
|
|
102127
|
+
let now = Date.now();
|
|
102128
|
+
this.sweepIdle(now);
|
|
102129
|
+
let entry = this.searches.get(root);
|
|
102130
|
+
entry ? (now - entry.refreshedAt >= this.refreshIntervalMs && (entry.search.invalidate(), entry.refreshedAt = now), entry.lastAccessedAt = now) : entry = {
|
|
102131
|
+
search: new WorkspaceFileSearch(root, this.config),
|
|
102132
|
+
refreshedAt: now,
|
|
102133
|
+
lastAccessedAt: now,
|
|
102134
|
+
inFlight: 0
|
|
102135
|
+
}, this.searches.delete(root), this.searches.set(root, entry), entry.inFlight += 1, this.evictOverflow(), this.ensureSweepTimer();
|
|
102136
|
+
try {
|
|
102137
|
+
return await entry.search.list(query, signal);
|
|
102138
|
+
} finally {
|
|
102139
|
+
entry.inFlight -= 1, entry.lastAccessedAt = Date.now(), this.searches.size > this.maxRoots && this.evictOverflow();
|
|
101493
102140
|
}
|
|
101494
|
-
return this.searches.delete(root), this.searches.set(root, entry), entry.search.list(query, signal);
|
|
101495
102141
|
}
|
|
101496
102142
|
close() {
|
|
101497
102143
|
if (!this.disposed) {
|
|
101498
|
-
this.disposed = !0;
|
|
102144
|
+
this.disposed = !0, this.stopSweepTimer();
|
|
101499
102145
|
for (let { search } of this.searches.values()) search.dispose();
|
|
101500
102146
|
this.searches.clear();
|
|
101501
102147
|
}
|
|
@@ -101509,7 +102155,11 @@ var PEER_WORKSPACE_FILES_HEADER = "x-codexhost-peer-workspace-files", MAX_PEER_S
|
|
|
101509
102155
|
"workspaceFiles/stat",
|
|
101510
102156
|
"workspaceFiles/list",
|
|
101511
102157
|
"officeToPdf/render"
|
|
101512
|
-
]), defaultPeerSearchCache
|
|
102158
|
+
]), defaultPeerSearchCache;
|
|
102159
|
+
function getDefaultPeerSearchCache() {
|
|
102160
|
+
return defaultPeerSearchCache ??= new WorkspaceFileSearchCache();
|
|
102161
|
+
}
|
|
102162
|
+
var MAX_RPC_BODY_BYTES = 1024 * 1024, MAX_OFFICE_INPUT_BYTES = 50 * 1024 * 1024, OFFICE_EXTENSIONS = /* @__PURE__ */ new Set(["doc", "docx", "xls", "xlsx", "ppt", "pptx"]), SAFE_DOWNLOAD_HEADERS = {
|
|
101513
102163
|
"Cache-Control": "private, no-store",
|
|
101514
102164
|
"X-Content-Type-Options": "nosniff",
|
|
101515
102165
|
"Content-Security-Policy": "sandbox; default-src 'none'",
|
|
@@ -101576,7 +102226,7 @@ async function sendTypertMultipart(response, rpcId, value, bytes, signal) {
|
|
|
101576
102226
|
response.end();
|
|
101577
102227
|
return;
|
|
101578
102228
|
}
|
|
101579
|
-
await pipeline2(
|
|
102229
|
+
await pipeline2(Readable5.fromWeb(encoded.body), response);
|
|
101580
102230
|
}
|
|
101581
102231
|
function sendPlain2(response, status, message2, isHead = !1) {
|
|
101582
102232
|
response.destroyed || response.writableEnded || response.headersSent || response.writeHead(status, {
|
|
@@ -101989,7 +102639,7 @@ async function handleSearch(request3, response, deps, signal) {
|
|
|
101989
102639
|
);
|
|
101990
102640
|
return;
|
|
101991
102641
|
}
|
|
101992
|
-
let cache2 = deps.searchCache ??
|
|
102642
|
+
let cache2 = deps.searchCache ?? getDefaultPeerSearchCache();
|
|
101993
102643
|
try {
|
|
101994
102644
|
let items = await cache2.list(validated.realRoot, query, signal);
|
|
101995
102645
|
if (signal.aborted || response.destroyed) return;
|
|
@@ -102145,7 +102795,8 @@ var RemotePeerAttachments = class {
|
|
|
102145
102795
|
},
|
|
102146
102796
|
body: toReadableStream(chunks),
|
|
102147
102797
|
duplex: "half",
|
|
102148
|
-
timeoutMs: this.uploadTimeoutMs
|
|
102798
|
+
timeoutMs: this.uploadTimeoutMs,
|
|
102799
|
+
...activePeer.outboundFetchOptions?.()
|
|
102149
102800
|
}
|
|
102150
102801
|
), payload = await readPeerJson(
|
|
102151
102802
|
response,
|
|
@@ -102237,7 +102888,8 @@ var RemotePeerAttachments = class {
|
|
|
102237
102888
|
try {
|
|
102238
102889
|
response = await peerFetch(activePeer.record, `/api/peer/v1/file?${query.toString()}`, {
|
|
102239
102890
|
method: "GET",
|
|
102240
|
-
timeoutMs: this.requestTimeoutMs
|
|
102891
|
+
timeoutMs: this.requestTimeoutMs,
|
|
102892
|
+
...activePeer.outboundFetchOptions?.()
|
|
102241
102893
|
});
|
|
102242
102894
|
} catch (error62) {
|
|
102243
102895
|
if (error62 instanceof SessionRuntimeError) {
|
|
@@ -102317,7 +102969,8 @@ var RemotePeerAttachments = class {
|
|
|
102317
102969
|
...condition === void 0 ? {} : { "if-none-match": condition }
|
|
102318
102970
|
},
|
|
102319
102971
|
signal: abort.signal,
|
|
102320
|
-
timeoutMs: this.requestTimeoutMs
|
|
102972
|
+
timeoutMs: this.requestTimeoutMs,
|
|
102973
|
+
...peer.outboundFetchOptions?.()
|
|
102321
102974
|
}), etag = peerImageETag(upstream.headers.get("etag"));
|
|
102322
102975
|
if (upstream.status === 304 && etag && matchesImageETag(condition, etag)) {
|
|
102323
102976
|
response.writeHead(304, peerImageCacheHeaders(etag)).end();
|
|
@@ -106104,13 +106757,14 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106104
106757
|
this.searchTimeoutMs
|
|
106105
106758
|
), combinedSignal = signal ? AbortSignal.any([signal, timeoutController.signal]) : timeoutController.signal, params = new URLSearchParams({ threadId: resolved.threadId, q: query });
|
|
106106
106759
|
try {
|
|
106107
|
-
let upstream = await
|
|
106760
|
+
let upstream = await peerOutboundFetch(
|
|
106108
106761
|
`${resolved.peer.record.origin}/api/peer/v1/workspace-files/search?${params.toString()}`,
|
|
106109
106762
|
{
|
|
106110
106763
|
method: "GET",
|
|
106111
106764
|
redirect: "error",
|
|
106112
106765
|
headers: { authorization: `Bearer ${resolved.peer.record.token}` },
|
|
106113
|
-
signal: combinedSignal
|
|
106766
|
+
signal: combinedSignal,
|
|
106767
|
+
...resolved.peer.outboundFetchOptions?.()
|
|
106114
106768
|
}
|
|
106115
106769
|
);
|
|
106116
106770
|
if (upstream.status === 401)
|
|
@@ -106209,7 +106863,7 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106209
106863
|
idleController.signal
|
|
106210
106864
|
]);
|
|
106211
106865
|
try {
|
|
106212
|
-
let upstream = await
|
|
106866
|
+
let upstream = await peerOutboundFetch(
|
|
106213
106867
|
`${resolved.peer.record.origin}/api/peer/v1/workspace-files/rpc`,
|
|
106214
106868
|
{
|
|
106215
106869
|
method: "POST",
|
|
@@ -106219,7 +106873,8 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106219
106873
|
"content-type": "application/json"
|
|
106220
106874
|
},
|
|
106221
106875
|
body: rewrittenBody,
|
|
106222
|
-
signal
|
|
106876
|
+
signal,
|
|
106877
|
+
...resolved.peer.outboundFetchOptions?.()
|
|
106223
106878
|
}
|
|
106224
106879
|
);
|
|
106225
106880
|
if (browserAbort.signal.aborted || response.destroyed)
|
|
@@ -106340,13 +106995,14 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106340
106995
|
return writePlainError(response, 429, "too many concurrent remote file requests"), !0;
|
|
106341
106996
|
let query = new URLSearchParams({ threadId: resolved.threadId, path: path7 }), { controller: browserAbort, detach } = attachBrowserDisconnectAbort(response, request3), timeoutController = new AbortController(), timer = setTimeout(() => timeoutController.abort(), this.downloadHandshakeTimeoutMs), signal = AbortSignal.any([browserAbort.signal, timeoutController.signal]);
|
|
106342
106997
|
try {
|
|
106343
|
-
let upstream = await
|
|
106998
|
+
let upstream = await peerOutboundFetch(
|
|
106344
106999
|
`${resolved.peer.record.origin}/api/peer/v1/workspace-files/download?${query.toString()}`,
|
|
106345
107000
|
{
|
|
106346
107001
|
method: "HEAD",
|
|
106347
107002
|
redirect: "error",
|
|
106348
107003
|
headers: { authorization: `Bearer ${resolved.peer.record.token}` },
|
|
106349
|
-
signal
|
|
107004
|
+
signal,
|
|
107005
|
+
...resolved.peer.outboundFetchOptions?.()
|
|
106350
107006
|
}
|
|
106351
107007
|
);
|
|
106352
107008
|
if (browserAbort.signal.aborted || response.destroyed) return !0;
|
|
@@ -106396,13 +107052,14 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106396
107052
|
return writePlainError(response, 429, "too many concurrent remote file requests", isHead), !0;
|
|
106397
107053
|
let { controller: browserAbort, detach } = attachBrowserDisconnectAbort(response, request3), handshakeAbort = new AbortController(), idleAbort = new AbortController(), timer = setTimeout(() => handshakeAbort.abort(), this.downloadHandshakeTimeoutMs), signal = AbortSignal.any([browserAbort.signal, handshakeAbort.signal, idleAbort.signal]), query = new URLSearchParams({ threadId: resolved.threadId, path: path7 });
|
|
106398
107054
|
try {
|
|
106399
|
-
let upstream = await
|
|
107055
|
+
let upstream = await peerOutboundFetch(
|
|
106400
107056
|
`${resolved.peer.record.origin}/api/peer/v1/workspace-files/download?${query.toString()}`,
|
|
106401
107057
|
{
|
|
106402
107058
|
method: isHead ? "HEAD" : "GET",
|
|
106403
107059
|
redirect: "error",
|
|
106404
107060
|
headers: { authorization: `Bearer ${resolved.peer.record.token}` },
|
|
106405
|
-
signal
|
|
107061
|
+
signal,
|
|
107062
|
+
...resolved.peer.outboundFetchOptions?.()
|
|
106406
107063
|
}
|
|
106407
107064
|
);
|
|
106408
107065
|
if (clearTimeout(timer), browserAbort.signal.aborted || response.destroyed)
|
|
@@ -106562,6 +107219,13 @@ async function sendAsset(request3, response, asset, cacheControl = "no-cache", r
|
|
|
106562
107219
|
...compressed.headers
|
|
106563
107220
|
}).end(compressed.body);
|
|
106564
107221
|
}
|
|
107222
|
+
async function sendShellIndex(request3, response, sources) {
|
|
107223
|
+
let builtInOnly = new URL(sources.url, "http://localhost").searchParams.get("extensions") === "off", source = (builtInOnly ? sources.recoveryAssets : sources.assets).index(), rendered = !builtInOnly && sources.renderIndex !== void 0 ? { ...source, body: Buffer.from(sources.renderIndex(source.body.toString())) } : source, document2 = sources.headScript === void 0 ? rendered : {
|
|
107224
|
+
...rendered,
|
|
107225
|
+
body: Buffer.from(String(rendered.body).replace("<head>", `<head>${sources.headScript}`))
|
|
107226
|
+
};
|
|
107227
|
+
await sendAsset(request3, response, document2, void 0, !0);
|
|
107228
|
+
}
|
|
106565
107229
|
|
|
106566
107230
|
// packages/web-server/src/tailscale-serve.ts
|
|
106567
107231
|
import { execFile as execFile3 } from "node:child_process";
|
|
@@ -108375,7 +109039,7 @@ var VIRTUAL_INTERFACE = /^(?:docker|br-|virbr|vmnet|vboxnet|veth|lxcbr|cni|flann
|
|
|
108375
109039
|
function isWildcardHost(host) {
|
|
108376
109040
|
return host === "0.0.0.0" || host === "::";
|
|
108377
109041
|
}
|
|
108378
|
-
function
|
|
109042
|
+
function isLoopbackHost3(host) {
|
|
108379
109043
|
return host === "localhost" || host === "::1" || host.startsWith("127.");
|
|
108380
109044
|
}
|
|
108381
109045
|
function kindOf(address, interfaceName) {
|
|
@@ -108384,7 +109048,7 @@ function kindOf(address, interfaceName) {
|
|
|
108384
109048
|
function networkAccessUrls(host, port, interfaces = networkInterfaces()) {
|
|
108385
109049
|
return (isWildcardHost(host) ? Object.entries(interfaces).flatMap(
|
|
108386
109050
|
([name2, entries]) => (entries ?? []).filter((entry) => entry.family === "IPv4" && !entry.internal).map((entry) => ({ address: entry.address, name: name2 }))
|
|
108387
|
-
) :
|
|
109051
|
+
) : isLoopbackHost3(host) ? [] : [{ address: host }]).map(({ address, name: name2 }) => ({
|
|
108388
109052
|
kind: kindOf(address, name2),
|
|
108389
109053
|
url: `http://${address}:${String(port)}/`
|
|
108390
109054
|
})).sort((a, b) => KIND_ORDER[a.kind] - KIND_ORDER[b.kind]);
|
|
@@ -109807,7 +110471,7 @@ import { promisify as promisify6 } from "node:util";
|
|
|
109807
110471
|
import { randomBytes as randomBytes32, sign as sign2 } from "node:crypto";
|
|
109808
110472
|
import { randomBytes as randomBytes42 } from "crypto";
|
|
109809
110473
|
import { createHash as createHash22, randomUUID as randomUUID22 } from "crypto";
|
|
109810
|
-
import { isIPv4 as
|
|
110474
|
+
import { isIPv4 as isIPv43 } from "net";
|
|
109811
110475
|
import * as timers2 from "node:timers/promises";
|
|
109812
110476
|
import { randomBytes as randomBytes7 } from "crypto";
|
|
109813
110477
|
import { isIPv4 as isIPv44, isIPv6 as isIPv64 } from "net";
|
|
@@ -109817,7 +110481,7 @@ import { isIPv4 as isIPv422, isIPv6 } from "node:net";
|
|
|
109817
110481
|
import { createSocket as createSocket3 } from "node:dgram";
|
|
109818
110482
|
import * as dns from "node:dns/promises";
|
|
109819
110483
|
import { isIP as isIP22, isIPv6 as isIPv62 } from "node:net";
|
|
109820
|
-
import { isIPv4 as
|
|
110484
|
+
import { isIPv4 as isIPv432, isIPv6 as isIPv63 } from "node:net";
|
|
109821
110485
|
import { promises as dns2 } from "node:dns";
|
|
109822
110486
|
import { isIP as isIP32, SocketAddress } from "node:net";
|
|
109823
110487
|
import { connect as connect32, createServer as createServer4 } from "node:net";
|
|
@@ -116089,7 +116753,7 @@ var log18 = debug("werift-dtls : packages/dtls/src/server.ts : log"), DtlsServer
|
|
|
116089
116753
|
);
|
|
116090
116754
|
}
|
|
116091
116755
|
canPairWith(other) {
|
|
116092
|
-
let a =
|
|
116756
|
+
let a = isIPv43(this.host), b = isIPv43(other.host);
|
|
116093
116757
|
return this.component === other.component && this.transport.toLowerCase() === other.transport.toLowerCase() && canPairTcpCandidates(this, other) && a === b;
|
|
116094
116758
|
}
|
|
116095
116759
|
toSdp() {
|
|
@@ -117106,7 +117770,7 @@ var HostAddressBind = {
|
|
|
117106
117770
|
let normalized = normalizeIp(address);
|
|
117107
117771
|
return normalized === "0.0.0.0" || normalized === "::";
|
|
117108
117772
|
};
|
|
117109
|
-
function
|
|
117773
|
+
function resolveHostAddresses2({
|
|
117110
117774
|
enumerated,
|
|
117111
117775
|
assigned = [],
|
|
117112
117776
|
interfaceAddresses,
|
|
@@ -117127,7 +117791,7 @@ function resolveHostAddresses({
|
|
|
117127
117791
|
map3.has(key) || map3.set(key, { address, bindAddress, costly });
|
|
117128
117792
|
}
|
|
117129
117793
|
return map3;
|
|
117130
|
-
}, locals = toMap(enumerated), assignedLocals = toMap(assigned), udp4 = interfaceAddresses?.udp4, udp6 = interfaceAddresses?.udp6, explicitOf = (address) =>
|
|
117794
|
+
}, locals = toMap(enumerated), assignedLocals = toMap(assigned), udp4 = interfaceAddresses?.udp4, udp6 = interfaceAddresses?.udp6, explicitOf = (address) => isIPv432(address) ? udp4 : udp6, resolved = /* @__PURE__ */ new Map(), add = (host) => {
|
|
117131
117795
|
let key = normalizeIp(host.address);
|
|
117132
117796
|
resolved.has(key) || resolved.set(key, host);
|
|
117133
117797
|
}, localOrWildcard = (address) => {
|
|
@@ -118443,12 +119107,12 @@ async function createStunOverTurnClient(config2, options = {}) {
|
|
|
118443
119107
|
return new StunOverTurnProtocol(turn);
|
|
118444
119108
|
}
|
|
118445
119109
|
function alternateTlsOptions(configured, alternateDomain, tlsOptions = {}) {
|
|
118446
|
-
let identity2 = alternateDomain ?? tlsOptions.servername ?? configured[0],
|
|
119110
|
+
let identity2 = alternateDomain ?? tlsOptions.servername ?? configured[0], checkServerIdentity22 = tlsOptions.checkServerIdentity ?? tls2.checkServerIdentity;
|
|
118447
119111
|
return {
|
|
118448
119112
|
...tlsOptions,
|
|
118449
119113
|
// SNI cannot carry an IP literal.
|
|
118450
119114
|
servername: isIP42(identity2) ? void 0 : identity2,
|
|
118451
|
-
checkServerIdentity: (_host, cert) =>
|
|
119115
|
+
checkServerIdentity: (_host, cert) => checkServerIdentity22(identity2, cert)
|
|
118452
119116
|
};
|
|
118453
119117
|
}
|
|
118454
119118
|
function tryAlternateOf(error62, addressFamily) {
|
|
@@ -120266,7 +120930,7 @@ var log26 = debug(
|
|
|
120266
120930
|
) ?? [])
|
|
120267
120931
|
this.appendLocalCandidate(this.withGeneration(reflexive));
|
|
120268
120932
|
}
|
|
120269
|
-
let address =
|
|
120933
|
+
let address = resolveHostAddresses2({
|
|
120270
120934
|
enumerated: getHostInterfaceAddresses(
|
|
120271
120935
|
this.options.useIpv4,
|
|
120272
120936
|
this.options.useIpv6,
|
|
@@ -123429,7 +124093,7 @@ function parseIceServerUrl(url2) {
|
|
|
123429
124093
|
let matched = /^(stun|stuns|turn|turns):(.+)$/i.exec(url2.trim());
|
|
123430
124094
|
if (!matched)
|
|
123431
124095
|
return;
|
|
123432
|
-
let [, rawScheme, rawRest] = matched, scheme = rawScheme.toLowerCase(), [authority] = rawRest.split("?", 1), [, query = ""] = rawRest.split("?"), address = parseAddress(authority,
|
|
124096
|
+
let [, rawScheme, rawRest] = matched, scheme = rawScheme.toLowerCase(), [authority] = rawRest.split("?", 1), [, query = ""] = rawRest.split("?"), address = parseAddress(authority, defaultPort2(scheme));
|
|
123433
124097
|
if (!address)
|
|
123434
124098
|
return;
|
|
123435
124099
|
if (scheme === "stun" || scheme === "stuns")
|
|
@@ -123451,7 +124115,7 @@ function resolveParsedTurnTransport({
|
|
|
123451
124115
|
}) {
|
|
123452
124116
|
return transportParam == null ? scheme === "turns" ? "tls" : void 0 : transportParam === "udp" ? scheme === "turns" ? "invalid" : "udp" : transportParam === "tcp" ? scheme === "turns" ? "tls" : "tcp" : "invalid";
|
|
123453
124117
|
}
|
|
123454
|
-
function
|
|
124118
|
+
function defaultPort2(scheme) {
|
|
123455
124119
|
return scheme === "stuns" || scheme === "turns" ? 5349 : 3478;
|
|
123456
124120
|
}
|
|
123457
124121
|
function parseAddress(value, fallbackPort) {
|
|
@@ -139501,6 +140165,33 @@ var CLIENT_PLUGINS = [
|
|
|
139501
140165
|
}
|
|
139502
140166
|
};
|
|
139503
140167
|
|
|
140168
|
+
// packages/web-server/src/project-harness-default.ts
|
|
140169
|
+
function projectHarnessId(workspaces2, workspaceId) {
|
|
140170
|
+
let { selection: selection2, lastHarnessId } = workspaces2.harnessPreference(workspaceId);
|
|
140171
|
+
return selection2.mode === "manual" ? selection2.harnessId : selection2.mode === "last" ? lastHarnessId : void 0;
|
|
140172
|
+
}
|
|
140173
|
+
function registerProjectHarnessDefault(rpc2, workspaces2, catalog) {
|
|
140174
|
+
rpc2.register("workspace/defaultHarness", async (args) => {
|
|
140175
|
+
let request3 = requestOf(args);
|
|
140176
|
+
if (typeof request3?.workspaceId != "string" || !request3.workspaceId)
|
|
140177
|
+
throw new SessionRuntimeError("workspace/invalid-request", "Choose a project.");
|
|
140178
|
+
let { workspaceId } = request3, current = workspaces2.harnessPreference(workspaceId), harnesses = (await catalog.models().catch((error62) => {
|
|
140179
|
+
if (!(error62 instanceof SessionRuntimeError && error62.code === "host/no-harness"))
|
|
140180
|
+
throw error62;
|
|
140181
|
+
}))?.groups.filter((group) => group.models.length > 0).map(({ id: id2, name: name2 }) => ({ id: id2, name: name2 })) ?? [];
|
|
140182
|
+
if (request3.selection !== void 0) {
|
|
140183
|
+
let selection2 = projectHarnessSelectionSchema.safeParse(request3.selection);
|
|
140184
|
+
if (!selection2.success)
|
|
140185
|
+
throw new SessionRuntimeError("workspace/invalid-request", "Choose a valid project default.");
|
|
140186
|
+
let next = selection2.data;
|
|
140187
|
+
if (next.mode === "manual" && !harnesses.some(({ id: id2 }) => id2 === next.harnessId))
|
|
140188
|
+
throw new SessionRuntimeError("workspace/harness-unavailable", "This Harness is unavailable.");
|
|
140189
|
+
return workspaces2.setHarnessSelection(workspaceId, next), {};
|
|
140190
|
+
}
|
|
140191
|
+
return { selection: current.selection, harnesses };
|
|
140192
|
+
});
|
|
140193
|
+
}
|
|
140194
|
+
|
|
139504
140195
|
// packages/web-server/src/draft-configuration.ts
|
|
139505
140196
|
function draftPermissionMode(harnessId, inspection, preferred) {
|
|
139506
140197
|
if (inspection.status !== "ready") return;
|
|
@@ -139550,8 +140241,9 @@ import { randomUUID as randomUUID19 } from "node:crypto";
|
|
|
139550
140241
|
import { existsSync as existsSync12, mkdirSync as mkdirSync7, statSync as statSync8 } from "node:fs";
|
|
139551
140242
|
import { basename as basename11, isAbsolute as isAbsolute20, join as join26, relative as relative11, resolve as resolve16, sep as sep9 } from "node:path";
|
|
139552
140243
|
import { homedir as homedir6 } from "node:os";
|
|
140244
|
+
var NATIVE_PROJECT_WORKSPACE_PREFIX = "codex-project:";
|
|
139553
140245
|
function nativeProjectWorkspaceId(projectId) {
|
|
139554
|
-
return
|
|
140246
|
+
return `${NATIVE_PROJECT_WORKSPACE_PREFIX}${projectId}`;
|
|
139555
140247
|
}
|
|
139556
140248
|
function insertSessionId(ids, sessionId, beforeId) {
|
|
139557
140249
|
let rest = ids.filter((id2) => id2 !== sessionId), index = beforeId === void 0 ? rest.length : rest.indexOf(beforeId);
|
|
@@ -139841,7 +140533,19 @@ var Workspaces = class {
|
|
|
139841
140533
|
updatedAt: previous.get(project2.id)?.updatedAt ?? now,
|
|
139842
140534
|
origin: "codexhost"
|
|
139843
140535
|
};
|
|
139844
|
-
})
|
|
140536
|
+
});
|
|
140537
|
+
let registeredNative = new Set(this.nativeWorkspaces.map((item) => item.workspaceId)), existingPreferences = this.harnessPreferencesRecord();
|
|
140538
|
+
if (Object.keys(existingPreferences).some(
|
|
140539
|
+
(id2) => id2.startsWith(NATIVE_PROJECT_WORKSPACE_PREFIX) && !registeredNative.has(id2)
|
|
140540
|
+
)) {
|
|
140541
|
+
let remaining = Object.fromEntries(
|
|
140542
|
+
Object.entries(existingPreferences).filter(
|
|
140543
|
+
([id2]) => !id2.startsWith(NATIVE_PROJECT_WORKSPACE_PREFIX) || registeredNative.has(id2)
|
|
140544
|
+
)
|
|
140545
|
+
);
|
|
140546
|
+
this.saveHarnessPreferences(remaining);
|
|
140547
|
+
}
|
|
140548
|
+
this.publishWorkspaceChanges(before), this.publishPinnedWorkspaces();
|
|
139845
140549
|
}
|
|
139846
140550
|
updateNativeProjectMember(sessionId, projectId) {
|
|
139847
140551
|
if (!this.nativeWorkspaces || !projectId) return;
|
|
@@ -140175,10 +140879,80 @@ var Workspaces = class {
|
|
|
140175
140879
|
(item) => item.workspaceId === workspaceId
|
|
140176
140880
|
);
|
|
140177
140881
|
}
|
|
140882
|
+
harnessPreference(workspaceId) {
|
|
140883
|
+
this.require(workspaceId);
|
|
140884
|
+
let raw = this.harnessPreferencesRecord();
|
|
140885
|
+
return Object.hasOwn(raw, workspaceId) ? this.parseHarnessPreference(raw[workspaceId]) : { selection: { mode: "global" } };
|
|
140886
|
+
}
|
|
140887
|
+
setHarnessSelection(workspaceId, selection2) {
|
|
140888
|
+
let current = this.harnessPreference(workspaceId);
|
|
140889
|
+
this.saveHarnessPreference(workspaceId, { ...current, selection: selection2 });
|
|
140890
|
+
}
|
|
140891
|
+
rememberHarness(workspaceId, harnessId) {
|
|
140892
|
+
let current = this.harnessPreference(workspaceId);
|
|
140893
|
+
current.lastHarnessId !== harnessId && this.saveHarnessPreference(workspaceId, { ...current, lastHarnessId: harnessId });
|
|
140894
|
+
}
|
|
140895
|
+
removeHarnessPreference(workspaceId) {
|
|
140896
|
+
let existing = this.harnessPreferencesRecord();
|
|
140897
|
+
if (!Object.hasOwn(existing, workspaceId)) return;
|
|
140898
|
+
let preferences2 = Object.fromEntries(
|
|
140899
|
+
Object.entries(existing).filter(([id2]) => id2 !== workspaceId)
|
|
140900
|
+
);
|
|
140901
|
+
this.saveHarnessPreferences(preferences2);
|
|
140902
|
+
}
|
|
140903
|
+
harnessPreferencesRecord() {
|
|
140904
|
+
let raw = this.state.harnessPreferences;
|
|
140905
|
+
return !raw || typeof raw != "object" || Array.isArray(raw) ? {} : raw;
|
|
140906
|
+
}
|
|
140907
|
+
parseHarnessPreference(raw) {
|
|
140908
|
+
if (!raw || typeof raw != "object" || Array.isArray(raw))
|
|
140909
|
+
return { selection: { mode: "global" } };
|
|
140910
|
+
let record6 = raw, selection2 = projectHarnessSelectionSchema.safeParse(record6.selection);
|
|
140911
|
+
if (!selection2.success) return { selection: { mode: "global" } };
|
|
140912
|
+
let lastHarnessId = harnessIdSchema.safeParse(record6.lastHarnessId);
|
|
140913
|
+
return lastHarnessId.success ? { selection: selection2.data, lastHarnessId: String(lastHarnessId.data) } : { selection: selection2.data };
|
|
140914
|
+
}
|
|
140915
|
+
saveHarnessPreferences(preferences2) {
|
|
140916
|
+
let state2 = { ...this.state };
|
|
140917
|
+
Object.keys(preferences2).length > 0 ? state2.harnessPreferences = preferences2 : delete state2.harnessPreferences, this.data.writeJson(FILE2, state2), this.state = state2;
|
|
140918
|
+
}
|
|
140919
|
+
saveHarnessPreference(workspaceId, preference) {
|
|
140920
|
+
this.saveHarnessPreferences({ ...this.harnessPreferencesRecord(), [workspaceId]: preference });
|
|
140921
|
+
}
|
|
140922
|
+
byExactPath(path7) {
|
|
140923
|
+
if (this.nativeWorkspaces) {
|
|
140924
|
+
let multiRootMatch;
|
|
140925
|
+
for (let item of this.nativeWorkspaces) {
|
|
140926
|
+
if (!item.projectId) continue;
|
|
140927
|
+
let roots = this.nativeRoots.get(item.projectId);
|
|
140928
|
+
if (roots?.includes(path7)) {
|
|
140929
|
+
if (roots.length === 1) return item;
|
|
140930
|
+
multiRootMatch ??= item;
|
|
140931
|
+
}
|
|
140932
|
+
}
|
|
140933
|
+
return multiRootMatch;
|
|
140934
|
+
}
|
|
140935
|
+
return this.state.items.find((item) => item.path === path7);
|
|
140936
|
+
}
|
|
140178
140937
|
byPath(path7) {
|
|
140179
|
-
|
|
140180
|
-
(
|
|
140181
|
-
|
|
140938
|
+
if (this.nativeWorkspaces) {
|
|
140939
|
+
let key = desktopProjectPathKey(path7), owner = this.nativeRootOwners.get(key);
|
|
140940
|
+
if (owner) return this.byProjectId(owner.projectId);
|
|
140941
|
+
if (this.nativeRootOwners.size > 0) return;
|
|
140942
|
+
let fallback = nativeProjectRootOwners(
|
|
140943
|
+
this.nativeWorkspaces.flatMap(
|
|
140944
|
+
(item) => item.projectId ? [
|
|
140945
|
+
{
|
|
140946
|
+
id: item.projectId,
|
|
140947
|
+
name: item.title,
|
|
140948
|
+
rootPaths: this.nativeRoots.get(item.projectId) ?? []
|
|
140949
|
+
}
|
|
140950
|
+
] : []
|
|
140951
|
+
)
|
|
140952
|
+
).get(key);
|
|
140953
|
+
return fallback ? this.byProjectId(fallback.projectId) : void 0;
|
|
140954
|
+
}
|
|
140955
|
+
return this.state.items.find((item) => item.path === path7);
|
|
140182
140956
|
}
|
|
140183
140957
|
/**
|
|
140184
140958
|
* The folder whose Threads a local Workspace lists, without the folders of nested local
|
|
@@ -140202,6 +140976,10 @@ var Workspaces = class {
|
|
|
140202
140976
|
ownerOf(sessionId) {
|
|
140203
140977
|
return this.list().find((item) => item.sessionIds.includes(sessionId));
|
|
140204
140978
|
}
|
|
140979
|
+
/** The native-project Workspace of a Thread whose sidebar membership has not caught up. */
|
|
140980
|
+
byProjectId(projectId) {
|
|
140981
|
+
return projectId == null ? void 0 : this.nativeWorkspaces?.find((item) => item.projectId === projectId);
|
|
140982
|
+
}
|
|
140205
140983
|
isArchived(sessionId) {
|
|
140206
140984
|
return this.archivedSessionIds().includes(sessionId);
|
|
140207
140985
|
}
|
|
@@ -140382,17 +141160,23 @@ var Workspaces = class {
|
|
|
140382
141160
|
let workspace = this.require(request3.workspaceId), {
|
|
140383
141161
|
displayOrder: currentDisplayOrder,
|
|
140384
141162
|
pinnedWorkspaceOverrides: currentPinnedOverrides,
|
|
141163
|
+
harnessPreferences: currentHarnessPreferences,
|
|
140385
141164
|
...stateWithoutOrderOrPins
|
|
140386
141165
|
} = this.state, nextDisplayOrder = currentDisplayOrder?.filter((id2) => id2 !== request3.workspaceId), nextPinnedOverrides = Object.fromEntries(
|
|
140387
141166
|
Object.entries(this.pinnedWorkspaceOverrides()).filter(
|
|
140388
141167
|
([id2]) => id2 !== request3.workspaceId
|
|
140389
141168
|
)
|
|
141169
|
+
), nextHarnessPreferences = Object.fromEntries(
|
|
141170
|
+
Object.entries(this.harnessPreferencesRecord()).filter(
|
|
141171
|
+
([id2]) => id2 !== request3.workspaceId
|
|
141172
|
+
)
|
|
140390
141173
|
), state2 = {
|
|
140391
141174
|
...stateWithoutOrderOrPins,
|
|
140392
141175
|
items: this.state.items.filter((item) => item.workspaceId !== request3.workspaceId),
|
|
140393
141176
|
deletedPaths: [...this.state.deletedPaths ?? [], workspace.path],
|
|
140394
141177
|
...nextDisplayOrder && nextDisplayOrder.length > 0 ? { displayOrder: nextDisplayOrder } : {},
|
|
140395
|
-
...Object.keys(nextPinnedOverrides).length > 0 ? { pinnedWorkspaceOverrides: nextPinnedOverrides } : {}
|
|
141178
|
+
...Object.keys(nextPinnedOverrides).length > 0 ? { pinnedWorkspaceOverrides: nextPinnedOverrides } : {},
|
|
141179
|
+
...Object.keys(nextHarnessPreferences).length > 0 ? { harnessPreferences: nextHarnessPreferences } : {}
|
|
140396
141180
|
};
|
|
140397
141181
|
return this.data.writeJson(FILE2, state2), this.state = state2, this.broadcast({ type: "remove", workspaceId: request3.workspaceId }), this.publishPinnedWorkspaces(), this.officialThreadSections?.some(
|
|
140398
141182
|
({ workspaceIds }) => workspaceIds?.includes(workspace.workspaceId)
|
|
@@ -141106,13 +141890,15 @@ ${request3}`
|
|
|
141106
141890
|
|
|
141107
141891
|
// packages/web-server/src/file-references.ts
|
|
141108
141892
|
var WebFileReferences = class {
|
|
141109
|
-
constructor(workspace, remoteSearch) {
|
|
141893
|
+
constructor(workspace, remoteSearch, cache2) {
|
|
141110
141894
|
this.workspace = workspace;
|
|
141111
141895
|
this.remoteSearch = remoteSearch;
|
|
141896
|
+
this.cache = cache2 ?? new WorkspaceFileSearchCache(), this.ownsCache = cache2 === void 0;
|
|
141112
141897
|
}
|
|
141113
141898
|
workspace;
|
|
141114
141899
|
remoteSearch;
|
|
141115
|
-
cache
|
|
141900
|
+
cache;
|
|
141901
|
+
ownsCache;
|
|
141116
141902
|
lifetime = new AbortController();
|
|
141117
141903
|
setRemoteSearch(search) {
|
|
141118
141904
|
this.remoteSearch = search;
|
|
@@ -141138,7 +141924,7 @@ var WebFileReferences = class {
|
|
|
141138
141924
|
});
|
|
141139
141925
|
}
|
|
141140
141926
|
close() {
|
|
141141
|
-
this.lifetime.abort(), this.cache.close();
|
|
141927
|
+
this.lifetime.abort(), this.ownsCache && this.cache.close();
|
|
141142
141928
|
}
|
|
141143
141929
|
};
|
|
141144
141930
|
|
|
@@ -141356,7 +142142,7 @@ function globalProjectionValues(values2) {
|
|
|
141356
142142
|
);
|
|
141357
142143
|
}
|
|
141358
142144
|
var ChSessions = class {
|
|
141359
|
-
constructor(host, workspaces2, events2, images2, files2, displayEntries2, preferences2, harnesses, openFile) {
|
|
142145
|
+
constructor(host, workspaces2, events2, images2, files2, displayEntries2, preferences2, harnesses, openFile, fileSearchCache) {
|
|
141360
142146
|
this.host = host;
|
|
141361
142147
|
this.workspaces = workspaces2;
|
|
141362
142148
|
this.events = events2;
|
|
@@ -141364,7 +142150,11 @@ var ChSessions = class {
|
|
|
141364
142150
|
this.files = files2;
|
|
141365
142151
|
this.preferences = preferences2;
|
|
141366
142152
|
this.openFile = openFile;
|
|
141367
|
-
this.
|
|
142153
|
+
this.fileReferences = new WebFileReferences(
|
|
142154
|
+
(id2) => this.fileWorkspaceRoot(id2),
|
|
142155
|
+
void 0,
|
|
142156
|
+
fileSearchCache
|
|
142157
|
+
), this.nativeGoals = new ChNativeGoals(host), this.catalog = new ChHarnessCatalog(host, events2, displayEntries2, preferences2, harnesses), this.attachments = images2 ? new ChAttachments(images2, files2) : void 0, this.fileInputs = files2 && images2 ? new ChFileInputs(files2, images2, async (id2) => {
|
|
141368
142158
|
if (id2 = this.id(id2), this.closed) throw new SessionRuntimeError("host/offline", "The Web connection is closed.");
|
|
141369
142159
|
if (this.drafts.has(id2)) return id2;
|
|
141370
142160
|
await this.owner(id2), this.rows.has(id2) || await this.refresh();
|
|
@@ -141436,7 +142226,7 @@ var ChSessions = class {
|
|
|
141436
142226
|
files;
|
|
141437
142227
|
preferences;
|
|
141438
142228
|
openFile;
|
|
141439
|
-
fileReferences
|
|
142229
|
+
fileReferences;
|
|
141440
142230
|
catalog;
|
|
141441
142231
|
editing = new ChThreadEditing();
|
|
141442
142232
|
pins;
|
|
@@ -141451,6 +142241,7 @@ var ChSessions = class {
|
|
|
141451
142241
|
nativeGoals;
|
|
141452
142242
|
drafts = /* @__PURE__ */ new Map();
|
|
141453
142243
|
controls = /* @__PURE__ */ new Set();
|
|
142244
|
+
planChanges = /* @__PURE__ */ new Set();
|
|
141454
142245
|
refreshing;
|
|
141455
142246
|
refreshingCatalog = !1;
|
|
141456
142247
|
refreshingArchives = !1;
|
|
@@ -141990,13 +142781,20 @@ var ChSessions = class {
|
|
|
141990
142781
|
}
|
|
141991
142782
|
if (this.threads.view(id2) !== view)
|
|
141992
142783
|
throw new SessionRuntimeError("host/resync", "Host snapshot was superseded by a new generation");
|
|
141993
|
-
view.log.setProjection(
|
|
142784
|
+
if (view.log.setProjection(
|
|
141994
142785
|
"archiveForkParent",
|
|
141995
142786
|
this.archiveForkParent(this.rows.get(id2) ?? view.thread)
|
|
141996
142787
|
), view.log.setProjection(
|
|
141997
142788
|
"nativeDiscovery",
|
|
141998
142789
|
!view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1
|
|
141999
|
-
), view.ownerSnapshot ? (this.handoffs.set(id2, view.ownerSnapshot.handoff ?? null), view.log.setProjection(WEB_HANDOFF_PROJECTION, view.ownerSnapshot.handoff ?? null)) : this.handoffs.has(id2) && view.log.setProjection(WEB_HANDOFF_PROJECTION, this.handoffs.get(id2) ?? null),
|
|
142790
|
+
), view.ownerSnapshot ? (this.handoffs.set(id2, view.ownerSnapshot.handoff ?? null), view.log.setProjection(WEB_HANDOFF_PROJECTION, view.ownerSnapshot.handoff ?? null)) : this.handoffs.has(id2) && view.log.setProjection(WEB_HANDOFF_PROJECTION, this.handoffs.get(id2) ?? null), (this.threads.get(id2)?.configurationRevision ?? 0) === configurationRevision) {
|
|
142791
|
+
let mode = view.ownerSnapshot?.configuration.codexCollaborationMode;
|
|
142792
|
+
this.projectCodexPlanMode(
|
|
142793
|
+
view,
|
|
142794
|
+
harnessId === "codex" && !view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1 && mode !== void 0 ? mode === "plan" : null
|
|
142795
|
+
);
|
|
142796
|
+
}
|
|
142797
|
+
view.ownerSnapshot && this.hostOnline && !this.closed && (this.syncedRunningInteractions.add(id2), this.interactions?.update(view.ownerSnapshot)), this.realtime && view.log.setProjection("nativeConnection", {
|
|
142000
142798
|
state: this.hostOnline ? "connected" : "reconnecting"
|
|
142001
142799
|
}), this.threads.ensure(id2).historyReadAt = Date.now();
|
|
142002
142800
|
let name2 = await this.catalog.name(harnessId);
|
|
@@ -142101,8 +142899,56 @@ var ChSessions = class {
|
|
|
142101
142899
|
projections: { kind: "cached", asOfSeq: 0, values: values2 }
|
|
142102
142900
|
};
|
|
142103
142901
|
}
|
|
142902
|
+
async supportsCodexPlanMode() {
|
|
142903
|
+
if (!this.realtime) return !1;
|
|
142904
|
+
let result = await this.host.request("collaborationMode/list", {}).catch(() => {
|
|
142905
|
+
});
|
|
142906
|
+
return Array.isArray(result?.data) && result.data.some((entry) => entry?.mode === "plan") && result.data.some((entry) => entry?.mode === "default");
|
|
142907
|
+
}
|
|
142908
|
+
codexPlanSelection(sessionId) {
|
|
142909
|
+
let draft = this.drafts.get(sessionId);
|
|
142910
|
+
if (draft && !draft.canonicalId)
|
|
142911
|
+
return draft.selection.provider === "codex" ? draft.codexPlanMode === !0 : void 0;
|
|
142912
|
+
let projected = this.threads.view(this.id(sessionId))?.log.projections.codexPlanMode;
|
|
142913
|
+
return typeof projected == "boolean" ? projected : void 0;
|
|
142914
|
+
}
|
|
142915
|
+
projectCodexPlanMode(view, active3) {
|
|
142916
|
+
let previous = view.log.projections.codexPlanMode;
|
|
142917
|
+
view.log.setProjection("codexPlanMode", active3), previous !== void 0 && typeof previous == "boolean" != (active3 !== null) && this.events.emit("commands/change", view.thread.id);
|
|
142918
|
+
}
|
|
142919
|
+
async selectCodexPlanMode(id2, active3) {
|
|
142920
|
+
let mode = active3 ? "plan" : "default";
|
|
142921
|
+
if (this.planChanges.has(id2))
|
|
142922
|
+
throw new SessionRuntimeError("session/busy", "Codex is already changing plan mode.");
|
|
142923
|
+
this.planChanges.add(id2);
|
|
142924
|
+
let epoch = this.hostEpoch;
|
|
142925
|
+
try {
|
|
142926
|
+
let confirmed = await this.host.request(
|
|
142927
|
+
"codexhost/thread/collaboration-mode/select",
|
|
142928
|
+
{ threadId: id2, mode }
|
|
142929
|
+
);
|
|
142930
|
+
if (this.closed || epoch !== this.hostEpoch || confirmed?.mode !== mode)
|
|
142931
|
+
throw new SessionRuntimeError(
|
|
142932
|
+
"session/plan-unconfirmed",
|
|
142933
|
+
"Codex did not confirm the mode. Refresh the conversation."
|
|
142934
|
+
);
|
|
142935
|
+
let state2 = this.threads.ensure(id2);
|
|
142936
|
+
state2.configurationRevision = (state2.configurationRevision ?? 0) + 1, state2.view && this.projectCodexPlanMode(state2.view, active3);
|
|
142937
|
+
} finally {
|
|
142938
|
+
this.planChanges.delete(id2), this.realtime?.invalidate(id2);
|
|
142939
|
+
}
|
|
142940
|
+
}
|
|
142104
142941
|
async draftSummary(draft, includeControls = !0) {
|
|
142105
|
-
let
|
|
142942
|
+
let controls;
|
|
142943
|
+
do {
|
|
142944
|
+
let provider = draft.selection.provider, [inspection2, supportsPlan2, name3] = await Promise.all([
|
|
142945
|
+
includeControls ? this.catalog.inspect(provider, draft.cwd) : void 0,
|
|
142946
|
+
includeControls && provider === "codex" ? this.supportsCodexPlanMode() : !1,
|
|
142947
|
+
this.catalog.name(provider)
|
|
142948
|
+
]);
|
|
142949
|
+
controls = { provider, inspection: inspection2, supportsPlan: supportsPlan2, name: name3 };
|
|
142950
|
+
} while (controls.provider !== draft.selection.provider);
|
|
142951
|
+
let { inspection, supportsPlan, name: name2 } = controls;
|
|
142106
142952
|
return {
|
|
142107
142953
|
sessionId: draft.id,
|
|
142108
142954
|
cwd: draft.cwd,
|
|
@@ -142120,11 +142966,12 @@ var ChSessions = class {
|
|
|
142120
142966
|
attachmentInput: this.files ? WEB_FILE_INPUT : WEB_IMAGE_INPUT,
|
|
142121
142967
|
imageLimits: WEB_IMAGE_LIMITS
|
|
142122
142968
|
} : {},
|
|
142123
|
-
modelSelection: { lastUsed: null, next: draft.selection }
|
|
142969
|
+
modelSelection: { lastUsed: null, next: draft.selection },
|
|
142970
|
+
codexPlanMode: draft.selection.provider === "codex" && supportsPlan ? draft.codexPlanMode === !0 : null
|
|
142124
142971
|
} : {},
|
|
142125
142972
|
harnessIdentity: {
|
|
142126
142973
|
id: draft.selection.provider,
|
|
142127
|
-
name:
|
|
142974
|
+
name: name2
|
|
142128
142975
|
},
|
|
142129
142976
|
...inspection ? {
|
|
142130
142977
|
nativePermissions: nativePermissionView(
|
|
@@ -142141,16 +142988,36 @@ var ChSessions = class {
|
|
|
142141
142988
|
};
|
|
142142
142989
|
}
|
|
142143
142990
|
async create(args, configuration) {
|
|
142144
|
-
let request3 = requestOf(args), workspace = request3.workspaceId ? this.workspaces.get(request3.workspaceId) : void 0, cwd = request3.cwd ?? workspace?.path, projectId = workspace?.projectId ?? (cwd && this.workspaces.usesNativeProjects ? this.workspaces.
|
|
142991
|
+
let request3 = requestOf(args), workspace = request3.workspaceId ? this.workspaces.get(request3.workspaceId) : void 0, cwd = request3.cwd ?? workspace?.path, byCwd = cwd ? this.workspaces.byPath(resolve19(cwd)) : void 0, projectId = workspace?.projectId ?? (cwd && this.workspaces.usesNativeProjects ? byCwd?.projectId : void 0), project2 = workspace ?? byCwd, projectHarnessId2 = !configuration && project2 ? projectHarnessId(this.workspaces, project2.workspaceId) : void 0;
|
|
142145
142992
|
if ((request3.workspaceId !== void 0 || request3.cwd !== void 0) && !cwd)
|
|
142146
142993
|
throw new SessionRuntimeError("workspace/invalid-path", "Choose a valid computer working directory.");
|
|
142147
142994
|
let id2 = request3.sessionId ?? `draft-${randomUUID23()}`, existing = this.drafts.get(id2);
|
|
142148
|
-
if (existing && !existing.canonicalId && !existing.creating && !existing.started && existing.cwd === cwd && existing.projectId === projectId)
|
|
142995
|
+
if (existing && !existing.canonicalId && !existing.creating && !existing.started && existing.cwd === cwd && existing.projectId === projectId) {
|
|
142996
|
+
if (!configuration && request3.matchProjectDefault) {
|
|
142997
|
+
if (existing.projectHarnessId !== projectHarnessId2)
|
|
142998
|
+
throw new SessionRuntimeError("session/writer-held", "Start a new draft with the project default.", {
|
|
142999
|
+
sessionId: id2
|
|
143000
|
+
});
|
|
143001
|
+
if (projectHarnessId2 !== void 0) {
|
|
143002
|
+
let preferences3 = this.preferences?.get().catch(() => {
|
|
143003
|
+
}), expected = (await this.catalog.models(!1, void 0, preferences3, projectHarnessId2)).default;
|
|
143004
|
+
if (this.closed) throw new SessionRuntimeError("session/closed", "Web sessions are closing.");
|
|
143005
|
+
if (this.drafts.get(id2) !== existing || existing.canonicalId || existing.creating || existing.started)
|
|
143006
|
+
throw new SessionRuntimeError("session/busy", "This Session already exists; start a new draft.");
|
|
143007
|
+
if ((project2 ? projectHarnessId(this.workspaces, project2.workspaceId) : void 0) !== projectHarnessId2 || existing.selection.provider !== expected?.provider)
|
|
143008
|
+
throw new SessionRuntimeError(
|
|
143009
|
+
"session/writer-held",
|
|
143010
|
+
"Start a new draft with the project default.",
|
|
143011
|
+
{ sessionId: id2 }
|
|
143012
|
+
);
|
|
143013
|
+
}
|
|
143014
|
+
}
|
|
142149
143015
|
return { sessionId: id2, agentPreset: "standard" };
|
|
143016
|
+
}
|
|
142150
143017
|
if (existing || this.rows.has(id2))
|
|
142151
143018
|
throw new SessionRuntimeError("session/busy", "This Session already exists; start a new draft.");
|
|
142152
143019
|
let preferences2 = configuration ? void 0 : this.preferences?.get().catch(() => {
|
|
142153
|
-
}), selection2 = configuration?.selection ?? (await this.catalog.models(!1, void 0, preferences2)).default;
|
|
143020
|
+
}), selection2 = configuration?.selection ?? (await this.catalog.models(!1, void 0, preferences2, projectHarnessId2)).default;
|
|
142154
143021
|
if (!selection2)
|
|
142155
143022
|
throw new SessionRuntimeError(
|
|
142156
143023
|
"host/no-harness",
|
|
@@ -142160,6 +143027,7 @@ var ChSessions = class {
|
|
|
142160
143027
|
id: id2,
|
|
142161
143028
|
...cwd ? { cwd } : {},
|
|
142162
143029
|
...projectId ? { projectId } : {},
|
|
143030
|
+
...projectHarnessId2 ? { projectHarnessId: projectHarnessId2 } : {},
|
|
142163
143031
|
selection: selection2,
|
|
142164
143032
|
createdAt: Date.now()
|
|
142165
143033
|
};
|
|
@@ -142242,7 +143110,7 @@ var ChSessions = class {
|
|
|
142242
143110
|
);
|
|
142243
143111
|
thread3.projectId = updated.thread.projectId, this.refreshingProjectAssignments?.set(thread3.id, draft.projectId);
|
|
142244
143112
|
}
|
|
142245
|
-
return draft.canonicalId = thread3.id, this.files?.bind(draft.id, thread3.id), this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId), this.workspaces.detachSession(draft.id), this.workspaces.usesNativeProjects ? this.workspaces.updateNativeProjectMember(thread3.id, draft.projectId) : draft.cwd ? (this.workspaces.selectReferenceWorkspace(draft.cwd), this.workspaces.attachReferencedSession(thread3.id, thread3.cwd), this.workspaces.addDraftReference(thread3.id, draft.cwd)) : this.workspaces.addDraftReference(thread3.id, void 0), this.events.emit("api-session/added", await this.summary(thread3)), this.workspaces.isArchived(thread3.id) || this.publishedCatalog?.set(thread3.id, this.catalogKey(thread3)), this.events.emit("codexhost/session-bound", draft.id, thread3.id), this.events.emit("api-session/removed", draft.id), thread3.id;
|
|
143113
|
+
return draft.codexPlanMode !== void 0 && (await this.selectCodexPlanMode(thread3.id, draft.codexPlanMode), delete draft.codexPlanMode), draft.canonicalId = thread3.id, this.files?.bind(draft.id, thread3.id), this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId), this.workspaces.detachSession(draft.id), this.workspaces.usesNativeProjects ? this.workspaces.updateNativeProjectMember(thread3.id, draft.projectId) : draft.cwd ? (this.workspaces.selectReferenceWorkspace(draft.cwd), this.workspaces.attachReferencedSession(thread3.id, thread3.cwd), this.workspaces.addDraftReference(thread3.id, draft.cwd)) : this.workspaces.addDraftReference(thread3.id, void 0), this.events.emit("api-session/added", await this.summary(thread3)), this.workspaces.isArchived(thread3.id) || this.publishedCatalog?.set(thread3.id, this.catalogKey(thread3)), this.events.emit("codexhost/session-bound", draft.id, thread3.id), this.events.emit("api-session/removed", draft.id), thread3.id;
|
|
142246
143114
|
}
|
|
142247
143115
|
/**
|
|
142248
143116
|
* Working directory of one Host-confirmed local Thread.
|
|
@@ -142575,7 +143443,7 @@ var ChSessions = class {
|
|
|
142575
143443
|
archivedSessionIds,
|
|
142576
143444
|
nextCursor: page ? nextCatalogCursor(page, includeArchived) : null
|
|
142577
143445
|
};
|
|
142578
|
-
}), rpc2.register("session/create", (args) => this.create(args)), rpc2.register("session/fork", async (args) => {
|
|
143446
|
+
}), rpc2.register("session/create", (args) => this.create(args)), registerProjectHarnessDefault(rpc2, this.workspaces, this.catalog), rpc2.register("session/fork", async (args) => {
|
|
142579
143447
|
let request3 = requestOf(args);
|
|
142580
143448
|
if (typeof request3.sessionId != "string" || !request3.sessionId || request3.atSeq !== void 0 && (!Number.isSafeInteger(request3.atSeq) || request3.atSeq < 0))
|
|
142581
143449
|
throw new SessionRuntimeError("session/fork-invalid", "Invalid fork request.");
|
|
@@ -142631,9 +143499,9 @@ var ChSessions = class {
|
|
|
142631
143499
|
inspection,
|
|
142632
143500
|
config2?.permissionModeId
|
|
142633
143501
|
);
|
|
142634
|
-
delete draft.permissionModeId, permissionModeId && (draft.permissionModeId = permissionModeId);
|
|
143502
|
+
delete draft.codexPlanMode, delete draft.permissionModeId, permissionModeId && (draft.permissionModeId = permissionModeId);
|
|
142635
143503
|
}
|
|
142636
|
-
draft.selection = request3, await this.preferences?.remember(request3.provider, {
|
|
143504
|
+
draft.selection = request3, before.provider !== request3.provider && this.events.emit("commands/change"), await this.preferences?.remember(request3.provider, {
|
|
142637
143505
|
model: model2,
|
|
142638
143506
|
thinkingOptionId: request3.reasoningEffort,
|
|
142639
143507
|
permissionModeId: draft.permissionModeId
|
|
@@ -142703,6 +143571,8 @@ var ChSessions = class {
|
|
|
142703
143571
|
"goal/command-required",
|
|
142704
143572
|
"Submit /goal as a command on a local Codex Thread with native goals enabled."
|
|
142705
143573
|
);
|
|
143574
|
+
if (this.planChanges.has(this.id(request3.sessionId)))
|
|
143575
|
+
throw new SessionRuntimeError("session/busy", "Wait for Codex to confirm plan mode before sending.");
|
|
142706
143576
|
let existingOwner = !draft || draft.canonicalId ? await this.owner(request3.sessionId) : void 0, steerTurnId;
|
|
142707
143577
|
if (request3.mode === "steer") {
|
|
142708
143578
|
let view = existingOwner && await this.view(request3.sessionId, !0), activeTurnId = view ? view.log.projections[WEB_ACTIVE_TURN_PROJECTION] : null;
|
|
@@ -142725,7 +143595,9 @@ var ChSessions = class {
|
|
|
142725
143595
|
request3.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
|
|
142726
143596
|
`)
|
|
142727
143597
|
) : this.id(request3.sessionId), owner = existingOwner ?? await this.owner(threadId);
|
|
142728
|
-
if (
|
|
143598
|
+
if (this.planChanges.has(threadId))
|
|
143599
|
+
throw new SessionRuntimeError("session/busy", "Wait for Codex to confirm plan mode before sending.");
|
|
143600
|
+
steerTurnId ? await this.host.request("turn/steer", {
|
|
142729
143601
|
threadId,
|
|
142730
143602
|
expectedTurnId: steerTurnId,
|
|
142731
143603
|
input: input3,
|
|
@@ -142736,16 +143608,27 @@ var ChSessions = class {
|
|
|
142736
143608
|
input: input3,
|
|
142737
143609
|
...request3.mode === "queue" ? { delivery: "queue", presentationInput: presentation2 } : {},
|
|
142738
143610
|
...request3.requestId ? { clientUserMessageId: request3.requestId } : {}
|
|
142739
|
-
})
|
|
143611
|
+
});
|
|
143612
|
+
let row = this.rows.get(threadId), confirmedProjectId = row?.projectId, project2 = row?.workspaceKind === "projectless" ? void 0 : (this.workspaces.usesNativeProjects && confirmedProjectId ? this.workspaces.byProjectId(confirmedProjectId) : void 0) ?? this.workspaces.ownerOf(threadId);
|
|
143613
|
+
if (project2)
|
|
143614
|
+
try {
|
|
143615
|
+
this.workspaces.rememberHarness(project2.workspaceId, owner.harnessId);
|
|
143616
|
+
} catch {
|
|
143617
|
+
this.events.emit(
|
|
143618
|
+
"codexhost/preferences-error",
|
|
143619
|
+
"The project's last Harness could not be saved."
|
|
143620
|
+
);
|
|
143621
|
+
}
|
|
143622
|
+
if (draft && !draft.titleRequested) {
|
|
142740
143623
|
draft.titleRequested = !0;
|
|
142741
|
-
let
|
|
142742
|
-
if (
|
|
143624
|
+
let row2 = this.rows.get(threadId);
|
|
143625
|
+
if (row2) {
|
|
142743
143626
|
this.titleRequests.add(threadId);
|
|
142744
143627
|
let prompt = request3.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
|
|
142745
143628
|
`);
|
|
142746
143629
|
tryGenerateThreadTitle(
|
|
142747
143630
|
this.host,
|
|
142748
|
-
|
|
143631
|
+
row2,
|
|
142749
143632
|
prompt,
|
|
142750
143633
|
owner.owner === "external",
|
|
142751
143634
|
() => !this.closed && this.titleRequests.has(threadId)
|
|
@@ -143099,23 +143982,61 @@ var ChSessions = class {
|
|
|
143099
143982
|
defaultOptions: [],
|
|
143100
143983
|
defaultPreset: ""
|
|
143101
143984
|
})), rpc2.register("commands/list", async (args) => {
|
|
143102
|
-
let id2 = String(args.agentId ?? "");
|
|
143985
|
+
let id2 = String(args.agentId ?? ""), commands = this.codexPlanSelection(id2) !== void 0 && !this.closed && this.hostOnline && await this.supportsCodexPlanMode() && this.codexPlanSelection(id2) !== void 0 ? [permissionCommand, codexPlanCommand] : [permissionCommand];
|
|
143103
143986
|
try {
|
|
143104
143987
|
let scope2 = await this.goalScope(id2);
|
|
143105
143988
|
if (scope2 === "draft" && await this.supportsDraftGoals() && await this.goalScope(id2) === "draft")
|
|
143106
|
-
return [
|
|
143989
|
+
return [...commands, goalCommand];
|
|
143107
143990
|
if (scope2 === "local" && nativeCodexGoalResultSchema.safeParse(
|
|
143108
143991
|
await this.host.request(NATIVE_CODEX_GOAL_METHOD, {
|
|
143109
143992
|
threadId: this.id(id2),
|
|
143110
143993
|
action: "get"
|
|
143111
143994
|
})
|
|
143112
143995
|
).success)
|
|
143113
|
-
return [
|
|
143996
|
+
return [...commands, goalCommand];
|
|
143114
143997
|
} catch {
|
|
143115
143998
|
}
|
|
143116
|
-
return
|
|
143999
|
+
return commands;
|
|
143117
144000
|
}), rpc2.register("commands/execute", async (args) => {
|
|
143118
|
-
let id2 = String(args.agentId ?? ""), line = String(args.line ?? "").trim();
|
|
144001
|
+
let id2 = String(args.agentId ?? ""), line = String(args.line ?? "").trim(), draft = this.drafts.get(id2), plan = /^\/plan(?:\s+([\s\S]*))?$/u.exec(line.trim());
|
|
144002
|
+
if (plan) {
|
|
144003
|
+
let threadId = this.id(id2), unboundDraft = draft && !draft.canonicalId ? draft : void 0, current = this.codexPlanSelection(id2);
|
|
144004
|
+
if (current === void 0) return;
|
|
144005
|
+
if (Array.isArray(args.submittedAttachments) && args.submittedAttachments.length > 0)
|
|
144006
|
+
throw new SessionRuntimeError("session/plan-attachments", "Remove attachments before using /plan.");
|
|
144007
|
+
if (!this.realtime || this.closed || !this.hostOnline)
|
|
144008
|
+
throw new SessionRuntimeError(
|
|
144009
|
+
"session/plan-unavailable",
|
|
144010
|
+
"The native Codex connection is unavailable."
|
|
144011
|
+
);
|
|
144012
|
+
let action = plan[1];
|
|
144013
|
+
if (action !== void 0 && action !== "on" && action !== "off")
|
|
144014
|
+
throw new SessionRuntimeError("session/plan-argument", "Use /plan, /plan on, or /plan off.");
|
|
144015
|
+
if (unboundDraft) {
|
|
144016
|
+
if (!await this.supportsCodexPlanMode())
|
|
144017
|
+
throw new SessionRuntimeError(
|
|
144018
|
+
"session/plan-unavailable",
|
|
144019
|
+
"This Codex version does not support plan mode."
|
|
144020
|
+
);
|
|
144021
|
+
if (this.drafts.get(id2) !== unboundDraft || this.closed || !this.hostOnline || unboundDraft.creating || unboundDraft.canonicalId || unboundDraft.selection.provider !== "codex")
|
|
144022
|
+
throw new SessionRuntimeError("session/busy", "Draft selection changed.");
|
|
144023
|
+
let active3 = action === void 0 ? !unboundDraft.codexPlanMode : action === "on";
|
|
144024
|
+
unboundDraft.codexPlanMode = active3;
|
|
144025
|
+
for (let sink of this.controls)
|
|
144026
|
+
sink.push({
|
|
144027
|
+
type: "projection",
|
|
144028
|
+
sessionId: id2,
|
|
144029
|
+
key: "codexPlanMode",
|
|
144030
|
+
value: active3,
|
|
144031
|
+
seq: 0
|
|
144032
|
+
});
|
|
144033
|
+
} else
|
|
144034
|
+
await this.selectCodexPlanMode(
|
|
144035
|
+
threadId,
|
|
144036
|
+
action === void 0 ? !current : action === "on"
|
|
144037
|
+
);
|
|
144038
|
+
return { commandId: randomUUID23(), result: { kind: "success" } };
|
|
144039
|
+
}
|
|
143119
144040
|
if (nativeCodexGoalInvocation.test(line)) {
|
|
143120
144041
|
let scope2 = await this.goalScope(id2);
|
|
143121
144042
|
if (scope2 === "other") return;
|
|
@@ -143162,7 +144083,7 @@ var ChSessions = class {
|
|
|
143162
144083
|
}
|
|
143163
144084
|
let match = /^\/permission\s+(.+)$/u.exec(line);
|
|
143164
144085
|
if (!match) return;
|
|
143165
|
-
let modeId = match[1] ?? "",
|
|
144086
|
+
let modeId = match[1] ?? "", harnessId = draft && !draft.canonicalId ? draft.selection.provider : (await this.owner(id2)).harnessId, inspection = await this.catalog.inspect(
|
|
143166
144087
|
harnessId,
|
|
143167
144088
|
draft?.cwd ?? this.rows.get(this.id(id2))?.cwd
|
|
143168
144089
|
), mode = inspection.status === "ready" ? inspection.permissionModes?.modes.find((value) => value.id === modeId) : void 0;
|
|
@@ -143396,10 +144317,12 @@ var WebHarnessPreferences = class {
|
|
|
143396
144317
|
await this.patch([operation]), await this.patch([{ kind: "newThread", lastHarness: id2 }]);
|
|
143397
144318
|
}
|
|
143398
144319
|
async decorate(catalog, snapshot = this.get().catch(() => {
|
|
143399
|
-
})) {
|
|
144320
|
+
}), projectHarnessId2) {
|
|
143400
144321
|
let external = await snapshot;
|
|
143401
144322
|
if (external) {
|
|
143402
|
-
let favorites = external.values.favorites, configurationFor = (harnessId) => external.values.newThread?.byHarness[harnessId], preferred = catalog.groups.find(
|
|
144323
|
+
let favorites = external.values.favorites, configurationFor = (harnessId) => external.values.newThread?.byHarness[harnessId], preferred = catalog.groups.find(
|
|
144324
|
+
(group) => group.id === (projectHarnessId2 ?? external.values.newThread?.lastHarness)
|
|
144325
|
+
) ?? catalog.groups.find((group) => group.id === catalog.default.provider), selectionFor = (group, fallbackModelId) => {
|
|
143403
144326
|
let configuration = configurationFor(group.id), modelRef = configuration?.model, model2 = (
|
|
143404
144327
|
// A remembered speed variant restores its base Model.
|
|
143405
144328
|
group.models.find(
|
|
@@ -144947,7 +145870,7 @@ function nativeProjectCommands(host, workspaces2, refresh, assignSession) {
|
|
|
144947
145870
|
throw new SessionRuntimeError("workspace/invalid-path", "Choose an existing absolute folder.", {
|
|
144948
145871
|
path: path7
|
|
144949
145872
|
});
|
|
144950
|
-
let absolute2 = resolve23(expanded), existing = workspaces2.
|
|
145873
|
+
let absolute2 = resolve23(expanded), existing = workspaces2.byExactPath(absolute2);
|
|
144951
145874
|
if (existing) return { workspace: existing, created: !1 };
|
|
144952
145875
|
let { project: project2 } = await host.request("project/create", {
|
|
144953
145876
|
name: basename14(absolute2) || absolute2,
|
|
@@ -144976,7 +145899,7 @@ function nativeProjectCommands(host, workspaces2, refresh, assignSession) {
|
|
|
144976
145899
|
"workspace/refresh-failed",
|
|
144977
145900
|
"Codex confirmed the removal. Refresh the project list."
|
|
144978
145901
|
);
|
|
144979
|
-
return workspaces2.removeFromDisplayOrder(workspaceId), workspaces2.removePinnedWorkspaceOverride(workspaceId), { deleted: !0 };
|
|
145902
|
+
return workspaces2.removeFromDisplayOrder(workspaceId), workspaces2.removePinnedWorkspaceOverride(workspaceId), workspaces2.removeHarnessPreference(workspaceId), { deleted: !0 };
|
|
144980
145903
|
}),
|
|
144981
145904
|
insertBefore: (workspaceId, beforeWorkspaceId) => mutate(async () => {
|
|
144982
145905
|
if (!(workspaces2.isRemote(workspaceId) || beforeWorkspaceId !== void 0 && workspaces2.isRemote(beforeWorkspaceId)))
|
|
@@ -145174,7 +146097,7 @@ async function snapshotPackagedHost(distribution, data2) {
|
|
|
145174
146097
|
|
|
145175
146098
|
// packages/web-server/src/main.ts
|
|
145176
146099
|
var RELEASE_WEB = !0, DISTRIBUTION_ROOT = resolve25(import.meta.dirname, ".."), PACKED_WEB = join36(DISTRIBUTION_ROOT, "web"), PACKED = existsSync16(join36(PACKED_WEB, "plugins.json")), REPO_ROOT = resolve25(import.meta.dirname, "../../.."), SERVER_VERSION = resolveServerVersion(
|
|
145177
|
-
"0.
|
|
146100
|
+
"0.32.0",
|
|
145178
146101
|
[join36(DISTRIBUTION_ROOT, "package.json"), join36(REPO_ROOT, "package.json")]
|
|
145179
146102
|
);
|
|
145180
146103
|
if (PACKED) {
|
|
@@ -145267,7 +146190,7 @@ var publicUrl = background ? background.publicUrl : values["public-url"] ?? proc
|
|
|
145267
146190
|
chHost,
|
|
145268
146191
|
displayDirectory,
|
|
145269
146192
|
events
|
|
145270
|
-
), preferences = new WebHarnessPreferences(chHost, events), images = new WebImages(data), files = new WebFiles(data, images), sessions = new ChSessions(
|
|
146193
|
+
), preferences = new WebHarnessPreferences(chHost, events), images = new WebImages(data), files = new WebFiles(data, images), sharedWorkspaceSearchCache = new WorkspaceFileSearchCache(), sessions = new ChSessions(
|
|
145271
146194
|
chHost,
|
|
145272
146195
|
workspaces,
|
|
145273
146196
|
events,
|
|
@@ -145276,7 +146199,8 @@ var publicUrl = background ? background.publicUrl : values["public-url"] ?? proc
|
|
|
145276
146199
|
displayEntries,
|
|
145277
146200
|
preferences,
|
|
145278
146201
|
enabledHarnesses,
|
|
145279
|
-
(path7, action) => openWorkspaceFile(launcher, path7, action)
|
|
146202
|
+
(path7, action) => openWorkspaceFile(launcher, path7, action),
|
|
146203
|
+
sharedWorkspaceSearchCache
|
|
145280
146204
|
), dsh = await DshWebServices.open({
|
|
145281
146205
|
workspaceRoot: resolve25(values.workspace),
|
|
145282
146206
|
threadWorkspace: (id2) => sessions.terminalWorkspaceRoot(id2),
|
|
@@ -145311,7 +146235,7 @@ var broadcastNotification = (message2) => {
|
|
|
145311
146235
|
plugins: CLIENT_PLUGINS,
|
|
145312
146236
|
globals: { ...CLIENT_GLOBALS, __CODEXHOST_DEV_WEB_UI__: devWebUi !== void 0 },
|
|
145313
146237
|
title: "CodexHost"
|
|
145314
|
-
}, builtInAssets = new WebAssets(assetOptions),
|
|
146238
|
+
}, builtInAssets = values["safe-mode"] ? void 0 : new WebAssets(assetOptions), cachedRecoveryAssets, getRecoveryAssets = () => cachedRecoveryAssets ??= new WebAssets({
|
|
145315
146239
|
...assetOptions,
|
|
145316
146240
|
plugins: CLIENT_PLUGINS.filter((id2) => id2 !== HMR_CLIENT_PLUGIN)
|
|
145317
146241
|
}), extensions2 = new WebUiExtensions(data, {
|
|
@@ -145325,7 +146249,7 @@ var broadcastNotification = (message2) => {
|
|
|
145325
146249
|
}
|
|
145326
146250
|
});
|
|
145327
146251
|
await extensions2.cleanup();
|
|
145328
|
-
var assets = values["safe-mode"] ?
|
|
146252
|
+
var assets = values["safe-mode"] ? getRecoveryAssets() : builtInAssets, pluginRuntime, listeningPort = Number(values.port);
|
|
145329
146253
|
if (!values["safe-mode"])
|
|
145330
146254
|
try {
|
|
145331
146255
|
if (dsh === void 0) throw new Error("The DSH Web backend is unavailable");
|
|
@@ -145354,7 +146278,9 @@ if (!values["safe-mode"])
|
|
|
145354
146278
|
SIDEBAR_BROWSER_PATH
|
|
145355
146279
|
].map((path7) => ({ kind: "exact", path: path7 }))
|
|
145356
146280
|
]
|
|
145357
|
-
}), assets = new WebAssets({ ...assetOptions, clients: pluginRuntime.clients }),
|
|
146281
|
+
}), assets = new WebAssets({ ...assetOptions, clients: pluginRuntime.clients }), builtInAssets = void 0;
|
|
146282
|
+
let savedExternalPlugins = extensions2.plugins();
|
|
146283
|
+
savedExternalPlugins.length > 0 && new WebAssets({ ...assetOptions, externalPlugins: savedExternalPlugins }), await extensions2.restore();
|
|
145358
146284
|
} catch (error62) {
|
|
145359
146285
|
extensions2.composed(
|
|
145360
146286
|
[],
|
|
@@ -145453,7 +146379,7 @@ peerManager.onPeerRemoved = (hostId2) => {
|
|
|
145453
146379
|
workspaces.removeRemoteHostOrder(hostId2);
|
|
145454
146380
|
};
|
|
145455
146381
|
remoteSessions.install(rpc, streams);
|
|
145456
|
-
var remoteWorkspaceFiles = new RemotePeerWorkspaceFiles(remoteSessions)
|
|
146382
|
+
var remoteWorkspaceFiles = new RemotePeerWorkspaceFiles(remoteSessions);
|
|
145457
146383
|
sessions.setRemoteFileSearch(
|
|
145458
146384
|
(sessionId, query, signal) => remoteWorkspaceFiles.searchFiles(sessionId, query, signal)
|
|
145459
146385
|
);
|
|
@@ -145664,7 +146590,7 @@ var server = createWebServer((request3, response) => {
|
|
|
145664
146590
|
await servePeerWorkspaceFiles(request3, response, peerRoute === "workspace-files/rpc" ? "rpc" : peerRoute === "workspace-files/download" ? "download" : "search", {
|
|
145665
146591
|
resolveWorkspaceRoot: (threadId, signal) => sessions.ensureLocalWorkspaceRoot(threadId, signal),
|
|
145666
146592
|
...dsh ? { dsh } : {},
|
|
145667
|
-
searchCache:
|
|
146593
|
+
searchCache: sharedWorkspaceSearchCache
|
|
145668
146594
|
});
|
|
145669
146595
|
return;
|
|
145670
146596
|
}
|
|
@@ -145796,17 +146722,13 @@ var server = createWebServer((request3, response) => {
|
|
|
145796
146722
|
return;
|
|
145797
146723
|
}
|
|
145798
146724
|
if (pathname === "/" || pathname === "/index.html") {
|
|
145799
|
-
|
|
145800
|
-
|
|
145801
|
-
|
|
145802
|
-
|
|
145803
|
-
|
|
145804
|
-
|
|
145805
|
-
|
|
145806
|
-
String(index.body).replace("<head>", `<head>${SWITCH_TOKEN_SCRIPT}`)
|
|
145807
|
-
)
|
|
145808
|
-
}
|
|
145809
|
-
);
|
|
146725
|
+
await sendShellIndex(request3, response, {
|
|
146726
|
+
url: url2,
|
|
146727
|
+
assets,
|
|
146728
|
+
recoveryAssets: { index: () => getRecoveryAssets().index() },
|
|
146729
|
+
...pluginRuntime === void 0 ? {} : { renderIndex: (html) => pluginRuntime.renderIndex(html) },
|
|
146730
|
+
...auth === void 0 ? {} : { headScript: SWITCH_TOKEN_SCRIPT }
|
|
146731
|
+
});
|
|
145810
146732
|
return;
|
|
145811
146733
|
}
|
|
145812
146734
|
if (pathname === "/plugins/events" && pluginRuntime !== void 0) {
|
|
@@ -145821,7 +146743,7 @@ var server = createWebServer((request3, response) => {
|
|
|
145821
146743
|
await sendAsset(
|
|
145822
146744
|
request3,
|
|
145823
146745
|
response,
|
|
145824
|
-
assets.plugin(url2) ??
|
|
146746
|
+
assets.plugin(url2) ?? cachedRecoveryAssets?.plugin(url2),
|
|
145825
146747
|
url2.includes("rev=") ? IMMUTABLE_CACHE : void 0
|
|
145826
146748
|
);
|
|
145827
146749
|
return;
|
|
@@ -145870,7 +146792,7 @@ var server = createWebServer((request3, response) => {
|
|
|
145870
146792
|
response,
|
|
145871
146793
|
assets.dist(pathname),
|
|
145872
146794
|
pathname.startsWith("/assets/") ? IMMUTABLE_CACHE : void 0,
|
|
145873
|
-
pathname === "/codexhost-settings.js"
|
|
146795
|
+
pathname === "/sw.js" || pathname === "/manifest.webmanifest" || pathname === "/codexhost-settings.js"
|
|
145874
146796
|
);
|
|
145875
146797
|
})().catch((error62) => {
|
|
145876
146798
|
console.error("[http] request failed", error62), response.headersSent ? response.destroy() : response.writeHead(500).end("internal error");
|
|
@@ -145914,7 +146836,7 @@ background && server.once("error", (error62) => {
|
|
|
145914
146836
|
server.listen(Number(values.port), values.host, async () => {
|
|
145915
146837
|
let port = server.address().port;
|
|
145916
146838
|
listeningPort = port;
|
|
145917
|
-
let host = values.host, wildcard = isWildcardHost(host), local = wildcard ||
|
|
146839
|
+
let host = values.host, wildcard = isWildcardHost(host), local = wildcard || isLoopbackHost3(host), query = accessTokens !== void 0 && local ? `?token=${accessTokens.localToken}` : "", localUrl = `http://${wildcard ? "127.0.0.1" : host}:${String(port)}/${query}`;
|
|
145918
146840
|
if (background) {
|
|
145919
146841
|
let readyFile = values["ready-file"];
|
|
145920
146842
|
readyFile !== void 0 && new DataDir(dirname19(readyFile)).writeJson(
|
|
@@ -145952,7 +146874,7 @@ var shuttingDown;
|
|
|
145952
146874
|
function shutdown(exitCode = 0) {
|
|
145953
146875
|
return shuttingDown ??= (async () => {
|
|
145954
146876
|
try {
|
|
145955
|
-
stopEpoch?.(), webTelemetry.close(), await peerDelegationBridge?.close(), peerManager.close(), relay.close(), shellReload?.close(), accessTokens?.close(), server.close(), desktopScreenshots.close(), await sidebarBrowser.close(), await dsh?.close(), await extensions2.cleanup(!0), pushNotifications?.close(), await sessions.close(),
|
|
146877
|
+
stopEpoch?.(), webTelemetry.close(), await peerDelegationBridge?.close(), peerManager.close(), relay.close(), shellReload?.close(), accessTokens?.close(), server.close(), desktopScreenshots.close(), await sidebarBrowser.close(), await dsh?.close(), await extensions2.cleanup(!0), pushNotifications?.close(), await sessions.close(), sharedWorkspaceSearchCache.close(), remoteSessions.close(), await preferences?.close(), displaySettings.close();
|
|
145956
146878
|
} catch (error62) {
|
|
145957
146879
|
console.error("[web] shutdown failed", error62), exitCode ||= 1;
|
|
145958
146880
|
} finally {
|