@codexhost/cli-win32-x64 0.31.0 → 0.32.1
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 +225 -20
- package/app/console-web.js +285 -25
- package/app/desktop-controller.mjs +534 -143
- package/app/host-runtime.mjs +2651 -913
- package/app/plugins/antigravity/plugin.mjs +20 -22
- package/app/plugins/claude-code/plugin.mjs +21 -0
- package/app/plugins/codebuddy/plugin.mjs +29 -2
- package/app/plugins/codex-usage/plugin.mjs +18 -0
- package/app/plugins/copilot/plugin.mjs +18 -0
- package/app/plugins/cursor-cli/plugin.mjs +18 -0
- package/app/plugins/deepseek-harness/plugin.mjs +18 -0
- package/app/plugins/devin/plugin.mjs +18 -0
- package/app/plugins/grok/plugin.mjs +18 -0
- package/app/plugins/hermes/plugin.mjs +18 -0
- package/app/plugins/kimi-code/plugin.mjs +18 -0
- package/app/plugins/kiro-cli/plugin.mjs +18 -0
- package/app/plugins/omp/plugin.mjs +18 -0
- package/app/plugins/opencode/plugin.mjs +18 -0
- package/app/plugins/pi/plugin.mjs +18 -0
- package/app/plugins/qoder/plugin.mjs +18 -0
- package/app/plugins/qoder-cn/plugin.mjs +18 -0
- package/app/plugins/qwen-code/plugin.mjs +18 -0
- package/app/plugins/workbuddy/plugin.mjs +29 -2
- package/app/plugins/zcode/plugin.mjs +18 -0
- package/app/renderer-extension.js +424 -129
- package/app/web/assets/{abnfDiagram-XWFEHMT6-Bqy7uOSy.js → abnfDiagram-XWFEHMT6-7XITZmBH.js} +1 -1
- package/app/web/assets/{architectureDiagram-CSQXQB3N-6aaP1YoM.js → architectureDiagram-CSQXQB3N-C8Usdzd8.js} +1 -1
- package/app/web/assets/{blockDiagram-BEDRHYPZ-B4QSFXe0.js → blockDiagram-BEDRHYPZ-CyN9yE_Q.js} +1 -1
- package/app/web/assets/{c4Diagram-M2UUVUY5-BYE-C8Gq.js → c4Diagram-M2UUVUY5-CjhY1l3g.js} +1 -1
- package/app/web/assets/{chunk-2Q5K7J3B-CiEM-GTd.js → chunk-2Q5K7J3B-o24_rh4_.js} +1 -1
- package/app/web/assets/{chunk-3GCGMST5-hzY9BiB1.js → chunk-3GCGMST5-D7bw3E1a.js} +1 -1
- package/app/web/assets/{chunk-5VM5RSS4-DYXznY0H.js → chunk-5VM5RSS4-D0v4acf7.js} +1 -1
- package/app/web/assets/{chunk-7U7NFRK5-Bzw5MDPr.js → chunk-7U7NFRK5-CYJxP4rV.js} +1 -1
- package/app/web/assets/{chunk-CNRTWJTD-DMbxMfi3.js → chunk-CNRTWJTD-DTgCtcCl.js} +1 -1
- package/app/web/assets/{chunk-D5HYT7QG-By0ZVBtD.js → chunk-D5HYT7QG-qRNelehW.js} +1 -1
- package/app/web/assets/{chunk-EBZ3SEQC-Yyu_sMV7.js → chunk-EBZ3SEQC-BgJPPYdu.js} +2 -2
- package/app/web/assets/{chunk-JWPE2WC7-DDzqxIPT.js → chunk-JWPE2WC7-C50ZnSQQ.js} +1 -1
- package/app/web/assets/{chunk-KTR4FSNJ-GlKqhtpl.js → chunk-KTR4FSNJ-Cifh4XHc.js} +1 -1
- package/app/web/assets/{chunk-XXDRQBXY-DNc-CvYu.js → chunk-XXDRQBXY-D23WAHPW.js} +1 -1
- package/app/web/assets/{classDiagram-v2-KXABOMEV-4_PFS2N_.js → classDiagram-v2-KXABOMEV-B3cezFGj.js} +1 -1
- package/app/web/assets/{cose-bilkent-JH36ORCC-BE3foHUY.js → cose-bilkent-JH36ORCC-VSMi4La2.js} +1 -1
- package/app/web/assets/{cynefin-EF2NZ3EQ-D2PqrYZ3.js → cynefin-EF2NZ3EQ-qQnfHq16.js} +1 -1
- package/app/web/assets/{cynefinDiagram-NJNITYFG-DOObpTbq.js → cynefinDiagram-NJNITYFG-BJELApXD.js} +1 -1
- package/app/web/assets/{dagre-KIHZ2IZ3-Znm2jin9.js → dagre-KIHZ2IZ3-C8B5ZMVs.js} +1 -1
- package/app/web/assets/{diagram-7YQZDPLS-ByZMD-uA.js → diagram-7YQZDPLS-HIWoNpzV.js} +1 -1
- package/app/web/assets/{diagram-QBROCOUO-BiRShpnN.js → diagram-QBROCOUO-3_vS1jbp.js} +1 -1
- package/app/web/assets/{diagram-RJJCUUZO-D9wLVoK2.js → diagram-RJJCUUZO-C_Kndn_e.js} +1 -1
- package/app/web/assets/{diagram-WERXNKYE-BSbIh-yC.js → diagram-WERXNKYE-BLWdOwya.js} +1 -1
- package/app/web/assets/{diagram-YHHI257C-DMWrHMc8.js → diagram-YHHI257C-DJeOs6eS.js} +1 -1
- package/app/web/assets/{diagram-YR4HJLHV-C4sBAFb1.js → diagram-YR4HJLHV-BKNULu-g.js} +1 -1
- package/app/web/assets/{ebnfDiagram-N527522P-BZLloaoQ.js → ebnfDiagram-N527522P-Bu8aReoF.js} +1 -1
- package/app/web/assets/{elk-O5DQBFGD-Da3e5tn5.js → elk-O5DQBFGD-CIp7Z0ER.js} +1 -1
- package/app/web/assets/{erDiagram-K3K3BIDK-B2lKAIZF.js → erDiagram-K3K3BIDK-BTsor1Lp.js} +1 -1
- package/app/web/assets/{flowDiagram-Z6JWZHQI-q2EY_kmB.js → flowDiagram-Z6JWZHQI-p_h5PKQr.js} +1 -1
- package/app/web/assets/{ganttDiagram-3PRQTZWP-BGrNZ20b.js → ganttDiagram-3PRQTZWP-DKjfPPJ1.js} +1 -1
- package/app/web/assets/{gitGraphDiagram-VXDFKS5L-DIZNXREy.js → gitGraphDiagram-VXDFKS5L-RnPOf2fj.js} +1 -1
- package/app/web/assets/{grid-E2QIVN74-0cUkPG69.js → grid-E2QIVN74-C96GnBO1.js} +1 -1
- package/app/web/assets/{index-PN7K-15_.js → index-CDRWzs-u.js} +99 -99
- package/app/web/assets/index-Dwdnvinl.css +1 -0
- package/app/web/assets/{infoDiagram-EZ3ZOAHP-BHhUTQCn.js → infoDiagram-EZ3ZOAHP-B68eZHsb.js} +1 -1
- package/app/web/assets/{ishikawaDiagram-S3EKX5GW-DPOxtl4c.js → ishikawaDiagram-S3EKX5GW-BLj7PFLt.js} +1 -1
- package/app/web/assets/{journeyDiagram-POQNLL5X-D8RyXckG.js → journeyDiagram-POQNLL5X-Bo-_In0d.js} +1 -1
- package/app/web/assets/{kanban-definition-BH5XI6FM-COJv3Hyh.js → kanban-definition-BH5XI6FM-BpHvxprW.js} +1 -1
- package/app/web/assets/{mermaid.core-DYdcDKIt.js → mermaid.core-COb9i2Gl.js} +4 -4
- package/app/web/assets/{mindmap-definition-WVAN44T4-DnYIM4ja.js → mindmap-definition-WVAN44T4-DG15AlXd.js} +1 -1
- package/app/web/assets/{pegDiagram-D4NLKWP3-Ds3GAEJ6.js → pegDiagram-D4NLKWP3-GMBk8RM6.js} +1 -1
- package/app/web/assets/{pieDiagram-36ENHN4W-BhLUJGEB.js → pieDiagram-36ENHN4W-BzeJgVnn.js} +1 -1
- package/app/web/assets/{quadrantDiagram-ZQUDMS73-DwtX-IxK.js → quadrantDiagram-ZQUDMS73-C--Kif6a.js} +1 -1
- package/app/web/assets/{railroadDiagram-JIZHGYPL-D2vmTTnJ.js → railroadDiagram-JIZHGYPL-NPLVu_R7.js} +1 -1
- package/app/web/assets/{render-VIF2ZAQL-DGU1ql-Z.js → render-VIF2ZAQL-DdpQ8E0J.js} +2 -2
- package/app/web/assets/{requirementDiagram-AXW2TVFA-u3j1sKkI.js → requirementDiagram-AXW2TVFA-WWRwRbkA.js} +1 -1
- package/app/web/assets/{sankeyDiagram-FBCJTAIF-k-An9VHW.js → sankeyDiagram-FBCJTAIF-hBr6pZ0V.js} +1 -1
- package/app/web/assets/{sequenceDiagram-3LA2ROMG-DUjbYb4R.js → sequenceDiagram-3LA2ROMG-DvzZWy5J.js} +1 -1
- package/app/web/assets/{sizeCapture-2Q2CQKSF-DATTL7FZ.js → sizeCapture-2Q2CQKSF-C2B86W70.js} +1 -1
- package/app/web/assets/{stateDiagram-v2-ATKHQDJO-cCJX5M2u.js → stateDiagram-v2-ATKHQDJO-Jwj3XqMx.js} +1 -1
- package/app/web/assets/{swimlanes-YQL5WMAO-B7grWEWt.js → swimlanes-YQL5WMAO-DxI0hC09.js} +1 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-CR0nv8kJ.js +8 -0
- package/app/web/assets/{timeline-definition-7Z437IG3-BhsLa6l1.js → timeline-definition-7Z437IG3-m8Ew8iuN.js} +1 -1
- package/app/web/assets/{usecaseDiagram-RDK6N6HP-CkPQYmQw.js → usecaseDiagram-RDK6N6HP-BsiPSzIT.js} +1 -1
- package/app/web/assets/{vennDiagram-SHRQU5PJ-CufZSwvw.js → vennDiagram-SHRQU5PJ-yYfXhiGp.js} +1 -1
- package/app/web/assets/{wardleyDiagram-F3OXNVQS-CSkfpFOA.js → wardleyDiagram-F3OXNVQS-DHLEfnsg.js} +1 -1
- package/app/web/assets/{xychartDiagram-GDYJKCDI-BhZf9scK.js → xychartDiagram-GDYJKCDI-Drn_UxYt.js} +1 -1
- package/app/web/codexhost-settings.js +123 -55
- 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 +8 -8
- 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 +75 -75
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +65 -65
- 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 +18 -18
- 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 +18 -18
- 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 +1144 -185
- 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) {
|
|
@@ -72841,7 +72841,7 @@ var THREAD_TREE_MAX_NODES = 5e3, threadTreeStatusSchema = external_exports.enum(
|
|
|
72841
72841
|
|
|
72842
72842
|
// packages/shared-contracts/dist/host-extension-management.js
|
|
72843
72843
|
var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
|
|
72844
|
-
var HOST_EXTENSION_UPLOAD_PATH = "/api/extensions/upload", HOST_EXTENSION_CATALOG_ICON_PATH = "/api/extensions/catalog-icon", hostExtensionRevisionSchema = external_exports.int().nonnegative(), hostExtensionConfigurationSchema = external_exports.strictObject({
|
|
72844
|
+
var HOST_EXTENSION_UPLOAD_PATH = "/api/extensions/upload", HOST_EXTENSION_CATALOG_ICON_PATH = "/api/extensions/catalog-icon", HOST_EXTENSION_CATALOG_SCREENSHOT_PATH = "/api/extensions/catalog-screenshot", hostExtensionRevisionSchema = external_exports.int().nonnegative(), hostExtensionConfigurationSchema = external_exports.strictObject({
|
|
72845
72845
|
revision: hostExtensionRevisionSchema,
|
|
72846
72846
|
enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
|
|
72847
72847
|
}), hostExtensionDefaultSeedsSchema = external_exports.strictObject({
|
|
@@ -72954,6 +72954,7 @@ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
|
|
|
72954
72954
|
snapshot: "codexhost/extensions/snapshot",
|
|
72955
72955
|
catalog: "codexhost/extensions/catalog",
|
|
72956
72956
|
catalogIcon: "codexhost/extensions/catalogIcon",
|
|
72957
|
+
catalogScreenshot: "codexhost/extensions/catalogScreenshot",
|
|
72957
72958
|
install: "codexhost/extensions/install",
|
|
72958
72959
|
update: "codexhost/extensions/update",
|
|
72959
72960
|
enable: "codexhost/extensions/enable",
|
|
@@ -72983,6 +72984,9 @@ var noParams = external_exports.strictObject({}), expectedRevision = { expectedR
|
|
|
72983
72984
|
}), hostExtensionsCatalogIconResultSchema = external_exports.strictObject({
|
|
72984
72985
|
mimeType: external_exports.enum(["image/png", "image/jpeg", "image/webp"]),
|
|
72985
72986
|
base64: base643(DESKTOP_EXTENSION_ICON_MAX_BYTES)
|
|
72987
|
+
}), hostExtensionCatalogScreenshotIndexSchema = external_exports.int().min(0).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT - 1), hostExtensionsCatalogScreenshotResultSchema = external_exports.strictObject({
|
|
72988
|
+
mimeType: external_exports.enum(["image/png", "image/jpeg", "image/webp"]),
|
|
72989
|
+
base64: base643(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)
|
|
72986
72990
|
}), hostExtensionSettingsSchema = external_exports.strictObject({
|
|
72987
72991
|
settingsRevision: hostExtensionRevisionSchema,
|
|
72988
72992
|
values: jsonObjectSchema
|
|
@@ -73000,6 +73004,10 @@ var noParams = external_exports.strictObject({}), expectedRevision = { expectedR
|
|
|
73000
73004
|
params: external_exports.strictObject({ ...id }),
|
|
73001
73005
|
result: hostExtensionsCatalogIconResultSchema
|
|
73002
73006
|
},
|
|
73007
|
+
[HOST_EXTENSIONS_RPC.catalogScreenshot]: {
|
|
73008
|
+
params: external_exports.strictObject({ ...id, index: hostExtensionCatalogScreenshotIndexSchema }),
|
|
73009
|
+
result: hostExtensionsCatalogScreenshotResultSchema
|
|
73010
|
+
},
|
|
73003
73011
|
[HOST_EXTENSIONS_RPC.install]: {
|
|
73004
73012
|
params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
|
|
73005
73013
|
result: installationResult
|
|
@@ -73203,6 +73211,8 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73203
73211
|
"codexhost/harness/preferences/get",
|
|
73204
73212
|
"codexhost/harness/preferences/patch",
|
|
73205
73213
|
"experimentalFeature/list",
|
|
73214
|
+
"collaborationMode/list",
|
|
73215
|
+
"codexhost/thread/collaboration-mode/select",
|
|
73206
73216
|
"thread/list",
|
|
73207
73217
|
"thread/metadata/update",
|
|
73208
73218
|
"codexhost/thread/catalog/read",
|
|
@@ -73473,6 +73483,7 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73473
73483
|
nextCursor: external_exports.string().nullable()
|
|
73474
73484
|
}),
|
|
73475
73485
|
configuration: external_exports.object({
|
|
73486
|
+
codexCollaborationMode: external_exports.enum(["plan", "default"]).optional(),
|
|
73476
73487
|
/** Native Codex model names are not external Harness transport refs. */
|
|
73477
73488
|
native: external_exports.object({
|
|
73478
73489
|
model: external_exports.string().min(1).max(1024).optional(),
|
|
@@ -74145,7 +74156,11 @@ var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u
|
|
|
74145
74156
|
model: harnessModelRefSchema.optional(),
|
|
74146
74157
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
74147
74158
|
permissionModeId: harnessPermissionModeIdSchema.optional()
|
|
74148
|
-
}).refine((value) => !!(value.model || value.thinkingOptionId || value.permissionModeId), "A default configuration must contain a preference"),
|
|
74159
|
+
}).refine((value) => !!(value.model || value.thinkingOptionId || value.permissionModeId), "A default configuration must contain a preference"), projectHarnessSelectionSchema = external_exports.discriminatedUnion("mode", [
|
|
74160
|
+
external_exports.strictObject({ mode: external_exports.literal("global") }),
|
|
74161
|
+
external_exports.strictObject({ mode: external_exports.literal("last") }),
|
|
74162
|
+
external_exports.strictObject({ mode: external_exports.literal("manual"), harnessId: harnessIdSchema })
|
|
74163
|
+
]), newThreadDefaultsSchema = external_exports.strictObject({
|
|
74149
74164
|
lastHarness: harnessIdSchema.optional(),
|
|
74150
74165
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
|
|
74151
74166
|
}), harnessDelegationDefaultSchema = external_exports.strictObject({
|
|
@@ -77117,9 +77132,6 @@ var PeerChHostClient = class {
|
|
|
77117
77132
|
};
|
|
77118
77133
|
|
|
77119
77134
|
// 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
77135
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
77124
77136
|
|
|
77125
77137
|
// packages/web-server/src/peer-host-store.ts
|
|
@@ -77258,6 +77270,594 @@ var PeerHostStore = class {
|
|
|
77258
77270
|
}
|
|
77259
77271
|
};
|
|
77260
77272
|
|
|
77273
|
+
// packages/web-server/src/peer-outbound-proxy.ts
|
|
77274
|
+
import { lookup as osDnsLookup } from "node:dns/promises";
|
|
77275
|
+
import {
|
|
77276
|
+
Agent as HttpAgent,
|
|
77277
|
+
request as httpRequest
|
|
77278
|
+
} from "node:http";
|
|
77279
|
+
import {
|
|
77280
|
+
Agent as HttpsAgent,
|
|
77281
|
+
request as httpsRequest
|
|
77282
|
+
} from "node:https";
|
|
77283
|
+
import { BlockList, isIP as isIP2, isIPv4 as isIPv42 } from "node:net";
|
|
77284
|
+
import { Readable } from "node:stream";
|
|
77285
|
+
import { checkServerIdentity, connect as tlsConnect } from "node:tls";
|
|
77286
|
+
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([
|
|
77287
|
+
"ENOTFOUND",
|
|
77288
|
+
"EAI_AGAIN",
|
|
77289
|
+
"EAI_NONAME",
|
|
77290
|
+
"EAI_NODATA",
|
|
77291
|
+
"EAI_FAIL",
|
|
77292
|
+
"ESERVFAIL",
|
|
77293
|
+
"ETIMEOUT"
|
|
77294
|
+
]);
|
|
77295
|
+
function isDnsResolutionError(err5) {
|
|
77296
|
+
if (!(err5 instanceof Error) || err5 instanceof PeerHostPolicyError) return !1;
|
|
77297
|
+
if (err5.message === "Peer host address could not be resolved") return !0;
|
|
77298
|
+
let code = "code" in err5 && typeof err5.code == "string" ? err5.code : void 0;
|
|
77299
|
+
return code !== void 0 && DNS_RESOLUTION_ERROR_CODES.has(code);
|
|
77300
|
+
}
|
|
77301
|
+
var PeerProxyConfigError = class extends Error {
|
|
77302
|
+
constructor(message2) {
|
|
77303
|
+
super(message2), this.name = "PeerProxyConfigError";
|
|
77304
|
+
}
|
|
77305
|
+
};
|
|
77306
|
+
function toAbortError(signal) {
|
|
77307
|
+
let reason = signal?.reason;
|
|
77308
|
+
return reason instanceof Error ? reason : new DOMException("The operation was aborted.", "AbortError");
|
|
77309
|
+
}
|
|
77310
|
+
function stripBrackets(hostname5) {
|
|
77311
|
+
let bare = hostname5.startsWith("[") && hostname5.endsWith("]") ? hostname5.slice(1, -1) : hostname5.replace(/\.$/u, ""), zoneIndex = bare.indexOf("%");
|
|
77312
|
+
return (zoneIndex >= 0 ? bare.slice(0, zoneIndex) : bare).toLowerCase();
|
|
77313
|
+
}
|
|
77314
|
+
function normalizeIpv4Candidate(bare) {
|
|
77315
|
+
if (isIPv42(bare)) return bare;
|
|
77316
|
+
if (!bare.startsWith("::ffff:")) return;
|
|
77317
|
+
let suffix = bare.slice(7);
|
|
77318
|
+
if (isIPv42(suffix)) return suffix;
|
|
77319
|
+
let hex3 = /^([0-9a-f]{1,4}):([0-9a-f]{1,4})$/iu.exec(suffix);
|
|
77320
|
+
if (!hex3?.[1] || !hex3[2]) return;
|
|
77321
|
+
let hi = Number.parseInt(hex3[1], 16), lo = Number.parseInt(hex3[2], 16);
|
|
77322
|
+
return `${hi >> 8 & 255}.${hi & 255}.${lo >> 8 & 255}.${lo & 255}`;
|
|
77323
|
+
}
|
|
77324
|
+
function isLoopbackHost2(hostname5) {
|
|
77325
|
+
let bare = stripBrackets(hostname5);
|
|
77326
|
+
if (bare === "localhost" || bare.endsWith(".localhost") || bare === "::1" || bare === "0:0:0:0:0:0:0:1")
|
|
77327
|
+
return !0;
|
|
77328
|
+
let ipv43 = normalizeIpv4Candidate(bare);
|
|
77329
|
+
return ipv43 !== void 0 && ipv43.startsWith("127.");
|
|
77330
|
+
}
|
|
77331
|
+
function isAlwaysDirectPeerHost(hostname5) {
|
|
77332
|
+
let bare = stripBrackets(hostname5);
|
|
77333
|
+
if (isLoopbackHost2(bare) || bare.endsWith(".local"))
|
|
77334
|
+
return !0;
|
|
77335
|
+
let ipv43 = normalizeIpv4Candidate(bare);
|
|
77336
|
+
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));
|
|
77337
|
+
}
|
|
77338
|
+
function readEnvValue(env, lowerKey) {
|
|
77339
|
+
let upperKey = lowerKey.toUpperCase(), lower = env[lowerKey];
|
|
77340
|
+
if (lower !== void 0) return lower;
|
|
77341
|
+
let upper = env[upperKey];
|
|
77342
|
+
if (upper !== void 0) return upper;
|
|
77343
|
+
for (let [key, value] of Object.entries(env))
|
|
77344
|
+
if (value !== void 0 && key.toLowerCase() === lowerKey) return value;
|
|
77345
|
+
}
|
|
77346
|
+
function readNonEmptyEnvValue(env, lowerKey) {
|
|
77347
|
+
let upperKey = lowerKey.toUpperCase(), lower = env[lowerKey]?.trim();
|
|
77348
|
+
if (lower) return lower;
|
|
77349
|
+
let upper = env[upperKey]?.trim();
|
|
77350
|
+
if (upper) return upper;
|
|
77351
|
+
for (let [key, value] of Object.entries(env))
|
|
77352
|
+
if (key.toLowerCase() === lowerKey) {
|
|
77353
|
+
let trimmed = value?.trim();
|
|
77354
|
+
if (trimmed) return trimmed;
|
|
77355
|
+
}
|
|
77356
|
+
}
|
|
77357
|
+
function parseNoProxyBlockList(noProxyValue) {
|
|
77358
|
+
let list2;
|
|
77359
|
+
for (let rawToken of noProxyValue.split(/[,\s]+/u)) {
|
|
77360
|
+
let token = rawToken.trim(), slash = token.indexOf("/");
|
|
77361
|
+
if (slash <= 0) continue;
|
|
77362
|
+
let prefixText = token.slice(slash + 1);
|
|
77363
|
+
if (!/^\d+$/u.test(prefixText)) continue;
|
|
77364
|
+
let address = stripBrackets(token.slice(0, slash)), prefix = Number.parseInt(prefixText, 10), family = isIP2(address);
|
|
77365
|
+
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"));
|
|
77366
|
+
}
|
|
77367
|
+
return list2;
|
|
77368
|
+
}
|
|
77369
|
+
function matchesNoProxyCidr(hostname5, blockList) {
|
|
77370
|
+
if (!blockList) return !1;
|
|
77371
|
+
let bare = stripBrackets(hostname5), ipv43 = normalizeIpv4Candidate(bare);
|
|
77372
|
+
return ipv43 !== void 0 ? blockList.check(ipv43, "ipv4") : isIP2(bare) === 6 ? blockList.check(bare, "ipv6") : !1;
|
|
77373
|
+
}
|
|
77374
|
+
function parseNoProxyHostToken(token) {
|
|
77375
|
+
if (!token || token.includes("/")) return;
|
|
77376
|
+
if (token.startsWith("[")) {
|
|
77377
|
+
let bracketed = /^\[([^\]]+)\](?::(\d+))?$/u.exec(token);
|
|
77378
|
+
return bracketed?.[1] ? {
|
|
77379
|
+
host: stripBrackets(bracketed[1]),
|
|
77380
|
+
...bracketed[2] ? { port: Number.parseInt(bracketed[2], 10) } : {}
|
|
77381
|
+
} : void 0;
|
|
77382
|
+
}
|
|
77383
|
+
if (token.indexOf(":") !== token.lastIndexOf(":"))
|
|
77384
|
+
return { host: stripBrackets(token) };
|
|
77385
|
+
let hostPort = /^([^:]+):(\d+)$/u.exec(token);
|
|
77386
|
+
return hostPort?.[1] && hostPort[2] ? {
|
|
77387
|
+
host: stripBrackets(hostPort[1]),
|
|
77388
|
+
port: Number.parseInt(hostPort[2], 10)
|
|
77389
|
+
} : { host: stripBrackets(token) };
|
|
77390
|
+
}
|
|
77391
|
+
function matchesNoProxyHostname(target2, noProxyRaw) {
|
|
77392
|
+
if (!noProxyRaw) return !1;
|
|
77393
|
+
let bareTarget = stripBrackets(target2.hostname), targetIpv4 = normalizeIpv4Candidate(bareTarget), targetPort = Number(target2.port || defaultPort(target2.protocol));
|
|
77394
|
+
for (let rawToken of noProxyRaw.split(/[,\s]+/u)) {
|
|
77395
|
+
let token = rawToken.trim().toLowerCase();
|
|
77396
|
+
if (!token) continue;
|
|
77397
|
+
if (token === "*") return !0;
|
|
77398
|
+
let parsed = parseNoProxyHostToken(token);
|
|
77399
|
+
if (!(!parsed || !parsed.host) && !(parsed.port !== void 0 && parsed.port !== targetPort)) {
|
|
77400
|
+
if (parsed.host.startsWith("*") || parsed.host.startsWith(".")) {
|
|
77401
|
+
let suffix = parsed.host.startsWith("*") ? parsed.host.slice(1) : parsed.host;
|
|
77402
|
+
if (!suffix || bareTarget.endsWith(suffix)) return !0;
|
|
77403
|
+
continue;
|
|
77404
|
+
}
|
|
77405
|
+
if (bareTarget === parsed.host || targetIpv4 !== void 0 && normalizeIpv4Candidate(parsed.host) === targetIpv4)
|
|
77406
|
+
return !0;
|
|
77407
|
+
}
|
|
77408
|
+
}
|
|
77409
|
+
return !1;
|
|
77410
|
+
}
|
|
77411
|
+
function resolveRawEnvProxy(target2, env, noProxyRaw) {
|
|
77412
|
+
if (target2.protocol !== "http:" && target2.protocol !== "https:" || matchesNoProxyHostname(target2, noProxyRaw)) return "";
|
|
77413
|
+
let protoKey = target2.protocol === "https:" ? "https_proxy" : "http_proxy";
|
|
77414
|
+
return readNonEmptyEnvValue(env, protoKey) ?? readNonEmptyEnvValue(env, "all_proxy") ?? "";
|
|
77415
|
+
}
|
|
77416
|
+
var SCHEMELESS_PROXY_HOST_PORT = /^(?:[^/@\s]+@)?(?:\[[^\]]+\]|[^:/@\s]+):(\d{1,5})\/?$/u;
|
|
77417
|
+
function parseConfiguredProxyUrl(rawProxy) {
|
|
77418
|
+
let candidate = rawProxy;
|
|
77419
|
+
if (!rawProxy.includes("://")) {
|
|
77420
|
+
let match = SCHEMELESS_PROXY_HOST_PORT.exec(rawProxy), portNum = match?.[1] ? Number.parseInt(match[1], 10) : 0;
|
|
77421
|
+
if (!match || portNum < 1 || portNum > 65535)
|
|
77422
|
+
throw new PeerProxyConfigError("Invalid outbound proxy URL configured in environment");
|
|
77423
|
+
candidate = `http://${rawProxy}`;
|
|
77424
|
+
}
|
|
77425
|
+
let parsed = URL.parse(candidate);
|
|
77426
|
+
if (!parsed || !parsed.hostname || parsed.port === "0")
|
|
77427
|
+
throw new PeerProxyConfigError("Invalid outbound proxy URL configured in environment");
|
|
77428
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
77429
|
+
throw new PeerProxyConfigError(`Unsupported outbound proxy protocol: ${parsed.protocol}`);
|
|
77430
|
+
try {
|
|
77431
|
+
parsed.username && decodeURIComponent(parsed.username), parsed.password && decodeURIComponent(parsed.password);
|
|
77432
|
+
} catch {
|
|
77433
|
+
throw new PeerProxyConfigError("Invalid percent-encoding in outbound proxy credentials");
|
|
77434
|
+
}
|
|
77435
|
+
return parsed;
|
|
77436
|
+
}
|
|
77437
|
+
function resolvePeerProxyUrl(target2, options = {}) {
|
|
77438
|
+
let env = options.env ?? process.env;
|
|
77439
|
+
if (readEnvValue(env, "node_use_env_proxy")?.trim() === "0" || isAlwaysDirectPeerHost(target2.hostname)) return;
|
|
77440
|
+
let noProxyRaw = readNonEmptyEnvValue(env, "no_proxy") ?? "", cidrBlockList = noProxyRaw ? parseNoProxyBlockList(noProxyRaw) : void 0;
|
|
77441
|
+
if (matchesNoProxyCidr(target2.hostname, cidrBlockList)) return;
|
|
77442
|
+
if (options.resolvedAddresses) {
|
|
77443
|
+
for (let entry of options.resolvedAddresses)
|
|
77444
|
+
if (isAlwaysDirectPeerHost(entry.address) || matchesNoProxyCidr(entry.address, cidrBlockList))
|
|
77445
|
+
return;
|
|
77446
|
+
}
|
|
77447
|
+
let rawProxy = resolveRawEnvProxy(target2, env, noProxyRaw);
|
|
77448
|
+
if (rawProxy)
|
|
77449
|
+
return parseConfiguredProxyUrl(rawProxy);
|
|
77450
|
+
}
|
|
77451
|
+
function createPinnedLookup(addresses) {
|
|
77452
|
+
return (_hostname, lookupOptions, callback) => {
|
|
77453
|
+
let opts = typeof lookupOptions == "object" && lookupOptions !== null ? lookupOptions : {};
|
|
77454
|
+
if (opts.all) {
|
|
77455
|
+
callback(
|
|
77456
|
+
null,
|
|
77457
|
+
addresses.map((entry) => ({ address: entry.address, family: entry.family }))
|
|
77458
|
+
);
|
|
77459
|
+
return;
|
|
77460
|
+
}
|
|
77461
|
+
let family = typeof lookupOptions == "number" ? lookupOptions : opts.family, match = family === 4 || family === 6 ? addresses.find((entry) => entry.family === family) : addresses[0];
|
|
77462
|
+
if (!match) {
|
|
77463
|
+
callback(
|
|
77464
|
+
Object.assign(new Error("No verified address matches requested IP family"), {
|
|
77465
|
+
code: "ENOTFOUND"
|
|
77466
|
+
}),
|
|
77467
|
+
"",
|
|
77468
|
+
4
|
|
77469
|
+
);
|
|
77470
|
+
return;
|
|
77471
|
+
}
|
|
77472
|
+
callback(null, match.address, match.family);
|
|
77473
|
+
};
|
|
77474
|
+
}
|
|
77475
|
+
function proxyAuthorizationHeader(proxy) {
|
|
77476
|
+
if (!proxy.username && !proxy.password) return;
|
|
77477
|
+
let credentials;
|
|
77478
|
+
try {
|
|
77479
|
+
credentials = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
|
77480
|
+
} catch {
|
|
77481
|
+
throw new PeerProxyConfigError("Invalid percent-encoding in outbound proxy credentials");
|
|
77482
|
+
}
|
|
77483
|
+
return `Basic ${Buffer.from(credentials, "utf8").toString("base64")}`;
|
|
77484
|
+
}
|
|
77485
|
+
function httpsProxyTlsOptions(bareProxy) {
|
|
77486
|
+
return {
|
|
77487
|
+
// Explicit empty string prevents Node from deriving outer TLS SNI from the inner target Host header.
|
|
77488
|
+
servername: isIP2(bareProxy) === 0 ? bareProxy : "",
|
|
77489
|
+
checkServerIdentity: (_host, cert) => checkServerIdentity(bareProxy, cert)
|
|
77490
|
+
};
|
|
77491
|
+
}
|
|
77492
|
+
function defaultPort(protocol) {
|
|
77493
|
+
return protocol === "https:" ? 443 : 80;
|
|
77494
|
+
}
|
|
77495
|
+
var ProxyHttpsAgent = class extends HttpsAgent {
|
|
77496
|
+
constructor(proxy, keepAlive = !0) {
|
|
77497
|
+
super({ keepAlive, autoSelectFamilyAttemptTimeout: 2e3, proxyEnv: {} });
|
|
77498
|
+
this.proxy = proxy;
|
|
77499
|
+
}
|
|
77500
|
+
proxy;
|
|
77501
|
+
createConnection(options, callback) {
|
|
77502
|
+
let connectSignal = options[CONNECT_SIGNAL];
|
|
77503
|
+
if (connectSignal?.aborted) {
|
|
77504
|
+
callback?.(toAbortError(connectSignal), void 0);
|
|
77505
|
+
return;
|
|
77506
|
+
}
|
|
77507
|
+
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;
|
|
77508
|
+
try {
|
|
77509
|
+
proxyAuth = proxyAuthorizationHeader(this.proxy);
|
|
77510
|
+
} catch (err5) {
|
|
77511
|
+
callback?.(
|
|
77512
|
+
err5 instanceof Error ? err5 : new Error(String(err5)),
|
|
77513
|
+
void 0
|
|
77514
|
+
);
|
|
77515
|
+
return;
|
|
77516
|
+
}
|
|
77517
|
+
let bareProxy = stripBrackets(this.proxy.hostname), connectReq = (this.proxy.protocol === "https:" ? httpsRequest : httpRequest)({
|
|
77518
|
+
protocol: this.proxy.protocol,
|
|
77519
|
+
hostname: bareProxy,
|
|
77520
|
+
port: Number(this.proxy.port || defaultPort(this.proxy.protocol)),
|
|
77521
|
+
method: "CONNECT",
|
|
77522
|
+
path: authority,
|
|
77523
|
+
agent: this.proxy.protocol === "https:" ? directNoKeepAliveHttpsAgent : directNoKeepAliveHttpAgent,
|
|
77524
|
+
headers: {
|
|
77525
|
+
host: authority,
|
|
77526
|
+
...proxyAuth ? { "proxy-authorization": proxyAuth } : {}
|
|
77527
|
+
},
|
|
77528
|
+
...this.proxy.protocol === "https:" ? httpsProxyTlsOptions(bareProxy) : {},
|
|
77529
|
+
timeout: connectTimeoutMs
|
|
77530
|
+
}), settled2 = !1, activeTlsSocket, connectTimer, handshakeTimer, clearConnectTimer = () => {
|
|
77531
|
+
connectTimer !== void 0 && (clearTimeout(connectTimer), connectTimer = void 0);
|
|
77532
|
+
}, cleanup = () => {
|
|
77533
|
+
clearConnectTimer(), handshakeTimer !== void 0 && (clearTimeout(handshakeTimer), handshakeTimer = void 0), connectSignal?.removeEventListener("abort", onAbort);
|
|
77534
|
+
}, fail = (err5) => {
|
|
77535
|
+
settled2 || (settled2 = !0, cleanup(), activeTlsSocket?.destroy(), connectReq.destroy(), callback?.(err5, void 0));
|
|
77536
|
+
}, onAbort = () => {
|
|
77537
|
+
fail(toAbortError(connectSignal));
|
|
77538
|
+
};
|
|
77539
|
+
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) => {
|
|
77540
|
+
if (clearConnectTimer(), settled2) {
|
|
77541
|
+
socket.destroy();
|
|
77542
|
+
return;
|
|
77543
|
+
}
|
|
77544
|
+
if (res.statusCode !== 200) {
|
|
77545
|
+
socket.destroy(), fail(new Error(`Proxy CONNECT returned HTTP ${res.statusCode ?? 0}`));
|
|
77546
|
+
return;
|
|
77547
|
+
}
|
|
77548
|
+
connectReq.setTimeout(0), socket.setTimeout(0), head.length > 0 && socket.unshift(head);
|
|
77549
|
+
let isIpTarget = isIP2(bareTarget) !== 0, customCheck = options.checkServerIdentity, tlsSocket = tlsConnect({
|
|
77550
|
+
socket,
|
|
77551
|
+
...isIpTarget ? {
|
|
77552
|
+
host: bareTarget,
|
|
77553
|
+
checkServerIdentity: (_host, cert) => customCheck ? customCheck(bareTarget, cert) : checkServerIdentity(bareTarget, cert)
|
|
77554
|
+
} : {
|
|
77555
|
+
servername: options.servername || bareTarget,
|
|
77556
|
+
...customCheck ? {
|
|
77557
|
+
checkServerIdentity: (host, cert) => customCheck(host, cert)
|
|
77558
|
+
} : {}
|
|
77559
|
+
},
|
|
77560
|
+
...options.rejectUnauthorized === void 0 ? {} : { rejectUnauthorized: options.rejectUnauthorized }
|
|
77561
|
+
});
|
|
77562
|
+
activeTlsSocket = tlsSocket, handshakeTimer = setTimeout(
|
|
77563
|
+
() => tlsSocket.destroy(new Error("Proxy TLS handshake timed out")),
|
|
77564
|
+
connectTimeoutMs
|
|
77565
|
+
), tlsSocket.once("error", (err5) => {
|
|
77566
|
+
fail(err5);
|
|
77567
|
+
}), tlsSocket.once("secureConnect", () => {
|
|
77568
|
+
if (settled2 || connectSignal?.aborted) {
|
|
77569
|
+
tlsSocket.destroy(), settled2 || fail(toAbortError(connectSignal));
|
|
77570
|
+
return;
|
|
77571
|
+
}
|
|
77572
|
+
settled2 = !0, cleanup(), tlsSocket.setTimeout(0), callback?.(null, tlsSocket);
|
|
77573
|
+
});
|
|
77574
|
+
}), connectReq.end();
|
|
77575
|
+
}
|
|
77576
|
+
};
|
|
77577
|
+
function getProxyHttpsAgent(proxy) {
|
|
77578
|
+
let key = proxy.href, agent = proxyHttpsAgents.get(key);
|
|
77579
|
+
if (!agent) {
|
|
77580
|
+
if (proxyHttpsAgents.size >= MAX_CACHED_PROXY_AGENTS) {
|
|
77581
|
+
let oldest = proxyHttpsAgents.keys().next().value;
|
|
77582
|
+
oldest !== void 0 && (proxyHttpsAgents.get(oldest)?.destroy(), proxyHttpsAgents.delete(oldest));
|
|
77583
|
+
}
|
|
77584
|
+
agent = new ProxyHttpsAgent(proxy, !0), proxyHttpsAgents.set(key, agent);
|
|
77585
|
+
}
|
|
77586
|
+
return agent;
|
|
77587
|
+
}
|
|
77588
|
+
function openPeerHttpRequest(target2, options) {
|
|
77589
|
+
let bareTarget = stripBrackets(target2.hostname), targetPort = Number(target2.port || defaultPort(target2.protocol)), proxy = options.proxy;
|
|
77590
|
+
if (proxy && target2.protocol === "http:") {
|
|
77591
|
+
let proxyAuth = proxyAuthorizationHeader(proxy), bareProxy = stripBrackets(proxy.hostname);
|
|
77592
|
+
return (proxy.protocol === "https:" ? httpsRequest : httpRequest)({
|
|
77593
|
+
protocol: proxy.protocol,
|
|
77594
|
+
hostname: bareProxy,
|
|
77595
|
+
port: Number(proxy.port || defaultPort(proxy.protocol)),
|
|
77596
|
+
method: options.method,
|
|
77597
|
+
path: target2.href,
|
|
77598
|
+
headers: {
|
|
77599
|
+
...options.headers,
|
|
77600
|
+
host: target2.host,
|
|
77601
|
+
...proxyAuth ? { "proxy-authorization": proxyAuth } : {}
|
|
77602
|
+
},
|
|
77603
|
+
agent: options.keepAlive === !1 ? proxy.protocol === "https:" ? directNoKeepAliveHttpsAgent : directNoKeepAliveHttpAgent : proxy.protocol === "https:" ? directHttpsAgent : directHttpAgent,
|
|
77604
|
+
...proxy.protocol === "https:" ? httpsProxyTlsOptions(bareProxy) : {},
|
|
77605
|
+
...options.signal ? { signal: options.signal } : {}
|
|
77606
|
+
});
|
|
77607
|
+
}
|
|
77608
|
+
if (proxy && target2.protocol === "https:") {
|
|
77609
|
+
let ephemeralAgent = options.keepAlive === !1 ? new ProxyHttpsAgent(proxy, !1) : void 0, reqOptions = {
|
|
77610
|
+
protocol: "https:",
|
|
77611
|
+
hostname: bareTarget,
|
|
77612
|
+
port: targetPort,
|
|
77613
|
+
method: options.method,
|
|
77614
|
+
path: `${target2.pathname}${target2.search}`,
|
|
77615
|
+
headers: {
|
|
77616
|
+
...options.headers,
|
|
77617
|
+
host: target2.host
|
|
77618
|
+
},
|
|
77619
|
+
agent: ephemeralAgent ?? getProxyHttpsAgent(proxy),
|
|
77620
|
+
...isIP2(bareTarget) === 0 ? { servername: bareTarget } : {},
|
|
77621
|
+
...options.signal ? { signal: options.signal, [CONNECT_SIGNAL]: options.signal } : {},
|
|
77622
|
+
...options.connectTimeoutMs !== void 0 ? { [CONNECT_TIMEOUT]: options.connectTimeoutMs } : {}
|
|
77623
|
+
}, req = httpsRequest(reqOptions);
|
|
77624
|
+
return ephemeralAgent && (req.once("error", () => ephemeralAgent.destroy()), req.once("response", (res) => {
|
|
77625
|
+
res.once("close", () => ephemeralAgent.destroy());
|
|
77626
|
+
})), req;
|
|
77627
|
+
}
|
|
77628
|
+
let useNoKeepAlive = !!options.lookup || options.keepAlive === !1, directOptions = {
|
|
77629
|
+
protocol: target2.protocol,
|
|
77630
|
+
hostname: bareTarget,
|
|
77631
|
+
port: targetPort,
|
|
77632
|
+
method: options.method,
|
|
77633
|
+
path: `${target2.pathname}${target2.search}`,
|
|
77634
|
+
headers: {
|
|
77635
|
+
...options.headers,
|
|
77636
|
+
host: target2.host
|
|
77637
|
+
},
|
|
77638
|
+
agent: useNoKeepAlive ? target2.protocol === "https:" ? directNoKeepAliveHttpsAgent : directNoKeepAliveHttpAgent : target2.protocol === "https:" ? directHttpsAgent : directHttpAgent,
|
|
77639
|
+
...options.lookup ? { lookup: options.lookup } : {},
|
|
77640
|
+
...options.signal ? { signal: options.signal } : {}
|
|
77641
|
+
};
|
|
77642
|
+
return target2.protocol === "https:" ? httpsRequest({
|
|
77643
|
+
...directOptions,
|
|
77644
|
+
...isIP2(bareTarget) === 0 ? { servername: bareTarget } : {}
|
|
77645
|
+
}) : httpRequest(directOptions);
|
|
77646
|
+
}
|
|
77647
|
+
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
77648
|
+
async function prepareFetchBody(body) {
|
|
77649
|
+
if (body == null) return { kind: "empty" };
|
|
77650
|
+
if (typeof body == "string") return { kind: "buffer", buffer: Buffer.from(body, "utf8") };
|
|
77651
|
+
if (body instanceof URLSearchParams)
|
|
77652
|
+
return {
|
|
77653
|
+
kind: "buffer",
|
|
77654
|
+
buffer: Buffer.from(body.toString(), "utf8"),
|
|
77655
|
+
contentType: "application/x-www-form-urlencoded;charset=UTF-8"
|
|
77656
|
+
};
|
|
77657
|
+
if (body instanceof FormData) {
|
|
77658
|
+
let encoded = new Response(body), contentType = encoded.headers.get("content-type") ?? void 0;
|
|
77659
|
+
return { kind: "buffer", buffer: Buffer.from(await encoded.arrayBuffer()), ...contentType ? { contentType } : {} };
|
|
77660
|
+
}
|
|
77661
|
+
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 ? {
|
|
77662
|
+
kind: "buffer",
|
|
77663
|
+
buffer: Buffer.from(await body.arrayBuffer()),
|
|
77664
|
+
...body.type ? { contentType: body.type } : {}
|
|
77665
|
+
} : { kind: "stream", stream: body };
|
|
77666
|
+
}
|
|
77667
|
+
function toFetchResponse(res, method2, signal) {
|
|
77668
|
+
let status = res.statusCode;
|
|
77669
|
+
if (typeof status != "number" || !Number.isInteger(status) || status < 200 || status > 599)
|
|
77670
|
+
throw new RangeError(
|
|
77671
|
+
`The status provided (${String(status)}) is outside the range [200, 599].`
|
|
77672
|
+
);
|
|
77673
|
+
let headers2 = new Headers();
|
|
77674
|
+
for (let [key, value] of Object.entries(res.headers))
|
|
77675
|
+
if (value !== void 0)
|
|
77676
|
+
if (Array.isArray(value))
|
|
77677
|
+
for (let item of value) headers2.append(key, item);
|
|
77678
|
+
else
|
|
77679
|
+
headers2.set(key, value);
|
|
77680
|
+
if (method2.toUpperCase() === "HEAD" || status === 204 || status === 205 || status === 304) {
|
|
77681
|
+
let response2 = new Response(null, { status, statusText: res.statusMessage ?? "", headers: headers2 });
|
|
77682
|
+
return res.resume(), response2;
|
|
77683
|
+
}
|
|
77684
|
+
let response = new Response(Readable.toWeb(res), {
|
|
77685
|
+
status,
|
|
77686
|
+
statusText: res.statusMessage ?? "",
|
|
77687
|
+
headers: headers2
|
|
77688
|
+
});
|
|
77689
|
+
if (signal) {
|
|
77690
|
+
let onAbort = () => res.destroy(signal.reason instanceof Error ? signal.reason : void 0);
|
|
77691
|
+
signal.aborted ? onAbort() : (signal.addEventListener("abort", onAbort, { once: !0 }), res.once("close", () => signal.removeEventListener("abort", onAbort)));
|
|
77692
|
+
}
|
|
77693
|
+
return response;
|
|
77694
|
+
}
|
|
77695
|
+
function waitForDrain(req, signal) {
|
|
77696
|
+
return req.destroyed || req.writableEnded || signal?.aborted ? Promise.resolve(!1) : new Promise((resolve26) => {
|
|
77697
|
+
let cleanup = () => {
|
|
77698
|
+
req.off("drain", onDrain), req.off("close", onStop), req.off("error", onStop), signal?.removeEventListener("abort", onStop);
|
|
77699
|
+
}, onDrain = () => {
|
|
77700
|
+
cleanup(), resolve26(!0);
|
|
77701
|
+
}, onStop = () => {
|
|
77702
|
+
cleanup(), resolve26(!1);
|
|
77703
|
+
};
|
|
77704
|
+
req.once("drain", onDrain), req.once("close", onStop), req.once("error", onStop), signal?.addEventListener("abort", onStop, { once: !0 });
|
|
77705
|
+
});
|
|
77706
|
+
}
|
|
77707
|
+
async function resolveHostAddresses(bareHost, dnsLookup2, signal) {
|
|
77708
|
+
if (signal?.aborted)
|
|
77709
|
+
throw toAbortError(signal);
|
|
77710
|
+
let lookupPromise = (dnsLookup2 ? dnsLookup2(bareHost) : osDnsLookup(bareHost, { all: !0, verbatim: !0 }).then(
|
|
77711
|
+
(entries) => entries.map((entry) => ({
|
|
77712
|
+
address: entry.address,
|
|
77713
|
+
family: entry.family === 6 ? 6 : 4
|
|
77714
|
+
}))
|
|
77715
|
+
)).then((entries) => {
|
|
77716
|
+
let validated = [];
|
|
77717
|
+
for (let entry of entries) {
|
|
77718
|
+
let family = typeof entry?.address == "string" ? isIP2(entry.address) : 0;
|
|
77719
|
+
if (family !== 4 && family !== 6)
|
|
77720
|
+
throw new PeerHostPolicyError("Peer host address is not allowed");
|
|
77721
|
+
validated.push({ address: entry.address, family });
|
|
77722
|
+
}
|
|
77723
|
+
if (validated.length === 0)
|
|
77724
|
+
throw new Error("Peer host address could not be resolved");
|
|
77725
|
+
return validated;
|
|
77726
|
+
});
|
|
77727
|
+
return signal ? await new Promise((resolve26, reject) => {
|
|
77728
|
+
let onAbort = () => reject(toAbortError(signal));
|
|
77729
|
+
signal.addEventListener("abort", onAbort, { once: !0 }), lookupPromise.then(
|
|
77730
|
+
(resolved) => {
|
|
77731
|
+
signal.removeEventListener("abort", onAbort), resolve26(resolved);
|
|
77732
|
+
},
|
|
77733
|
+
(err5) => {
|
|
77734
|
+
signal.removeEventListener("abort", onAbort), signal.aborted ? reject(toAbortError(signal)) : reject(err5);
|
|
77735
|
+
}
|
|
77736
|
+
);
|
|
77737
|
+
}) : await lookupPromise;
|
|
77738
|
+
}
|
|
77739
|
+
async function resolvePeerOutboundRoute(target2, options = {}) {
|
|
77740
|
+
let effectiveAllowLoopback = options.allowLoopback ?? isLoopbackHost2(target2.hostname);
|
|
77741
|
+
assertAllowedPeerHost(target2.hostname, { allowLoopback: effectiveAllowLoopback });
|
|
77742
|
+
let candidateProxy = resolvePeerProxyUrl(target2), bareTarget = stripBrackets(target2.hostname);
|
|
77743
|
+
if (isIP2(bareTarget) !== 0)
|
|
77744
|
+
return candidateProxy ? { proxy: candidateProxy } : {};
|
|
77745
|
+
let resolvedAddresses = options.resolvedAddresses;
|
|
77746
|
+
if (resolvedAddresses === void 0)
|
|
77747
|
+
try {
|
|
77748
|
+
resolvedAddresses = await resolveHostAddresses(bareTarget, options.dnsLookup, options.signal);
|
|
77749
|
+
} catch (err5) {
|
|
77750
|
+
if (candidateProxy && isDnsResolutionError(err5))
|
|
77751
|
+
return { proxy: candidateProxy };
|
|
77752
|
+
throw err5;
|
|
77753
|
+
}
|
|
77754
|
+
for (let entry of resolvedAddresses)
|
|
77755
|
+
assertAllowedPeerHost(entry.address, { allowLoopback: effectiveAllowLoopback });
|
|
77756
|
+
let finalProxy = candidateProxy ? resolvePeerProxyUrl(target2, { resolvedAddresses }) : void 0;
|
|
77757
|
+
return finalProxy ? { proxy: finalProxy } : resolvedAddresses.length > 0 ? { lookup: createPinnedLookup(resolvedAddresses) } : {};
|
|
77758
|
+
}
|
|
77759
|
+
function cancelUploadBodyIfStream(body, reason) {
|
|
77760
|
+
body instanceof ReadableStream && body.cancel(reason).catch(() => {
|
|
77761
|
+
});
|
|
77762
|
+
}
|
|
77763
|
+
async function nodeFetchViaAdapter(target2, init, route) {
|
|
77764
|
+
let signal = init?.signal ?? void 0;
|
|
77765
|
+
if (signal?.aborted)
|
|
77766
|
+
throw await cancelUploadBodyIfStream(init?.body, signal.reason), toAbortError(signal);
|
|
77767
|
+
let method2 = init?.method ?? "GET", headersObj = {};
|
|
77768
|
+
init?.headers && new Headers(init.headers).forEach((value, key) => {
|
|
77769
|
+
headersObj[key] = value;
|
|
77770
|
+
});
|
|
77771
|
+
let preparedBody = await prepareFetchBody(init?.body);
|
|
77772
|
+
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)
|
|
77773
|
+
throw preparedBody.kind === "stream" && await preparedBody.stream.cancel(signal.reason).catch(() => {
|
|
77774
|
+
}), toAbortError(signal);
|
|
77775
|
+
return new Promise((resolve26, reject) => {
|
|
77776
|
+
let settled2 = !1, fail = (err5) => {
|
|
77777
|
+
settled2 || (settled2 = !0, reject(err5 instanceof Error ? err5 : new Error(String(err5))));
|
|
77778
|
+
}, req = openPeerHttpRequest(target2, {
|
|
77779
|
+
method: method2,
|
|
77780
|
+
headers: headersObj,
|
|
77781
|
+
...route.proxy ? { proxy: route.proxy } : {},
|
|
77782
|
+
...!route.proxy && route.lookup ? { lookup: route.lookup } : {},
|
|
77783
|
+
...signal ? { signal } : {}
|
|
77784
|
+
});
|
|
77785
|
+
if (req.once("error", fail), req.once("upgrade", (_res, socket) => {
|
|
77786
|
+
socket.destroy(), req.destroy(), fail(new Error("Unexpected HTTP protocol upgrade response"));
|
|
77787
|
+
}), req.once("response", (res) => {
|
|
77788
|
+
let status = res.statusCode ?? 0;
|
|
77789
|
+
if (init?.redirect === "error" && REDIRECT_STATUSES.has(status)) {
|
|
77790
|
+
res.resume(), req.destroy(), fail(new TypeError("redirect mode is set to error"));
|
|
77791
|
+
return;
|
|
77792
|
+
}
|
|
77793
|
+
if (settled2) {
|
|
77794
|
+
res.destroy();
|
|
77795
|
+
return;
|
|
77796
|
+
}
|
|
77797
|
+
let response;
|
|
77798
|
+
try {
|
|
77799
|
+
response = toFetchResponse(res, method2, signal);
|
|
77800
|
+
} catch (err5) {
|
|
77801
|
+
res.destroy(), req.destroy(), fail(err5);
|
|
77802
|
+
return;
|
|
77803
|
+
}
|
|
77804
|
+
settled2 = !0, resolve26(response);
|
|
77805
|
+
}), preparedBody.kind === "empty")
|
|
77806
|
+
req.end();
|
|
77807
|
+
else if (preparedBody.kind === "buffer")
|
|
77808
|
+
req.end(preparedBody.buffer);
|
|
77809
|
+
else {
|
|
77810
|
+
let reader = preparedBody.stream.getReader(), streamDone = !1, cancelUpload = (reason) => {
|
|
77811
|
+
streamDone || (streamDone = !0, reader.cancel(reason).catch(() => {
|
|
77812
|
+
}));
|
|
77813
|
+
}, onReqClose = () => cancelUpload(signal?.aborted ? signal.reason : void 0), onReqError = (err5) => cancelUpload(err5), onSignalAbort = () => cancelUpload(signal?.reason);
|
|
77814
|
+
req.once("close", onReqClose), req.once("error", onReqError), signal?.addEventListener("abort", onSignalAbort, { once: !0 }), (async () => {
|
|
77815
|
+
try {
|
|
77816
|
+
for (; !(req.destroyed || signal?.aborted); ) {
|
|
77817
|
+
let { done, value } = await reader.read();
|
|
77818
|
+
if (done) {
|
|
77819
|
+
streamDone = !0;
|
|
77820
|
+
break;
|
|
77821
|
+
}
|
|
77822
|
+
if (req.destroyed || signal?.aborted || !req.write(value) && !await waitForDrain(req, signal))
|
|
77823
|
+
break;
|
|
77824
|
+
}
|
|
77825
|
+
!req.destroyed && !req.writableEnded && !signal?.aborted && req.end();
|
|
77826
|
+
} catch (err5) {
|
|
77827
|
+
streamDone = !0, req.destroy(), fail(err5);
|
|
77828
|
+
} finally {
|
|
77829
|
+
streamDone || (streamDone = !0, await reader.cancel(signal?.aborted ? signal.reason : void 0).catch(() => {
|
|
77830
|
+
})), reader.releaseLock(), req.off("close", onReqClose), req.off("error", onReqError), signal?.removeEventListener("abort", onSignalAbort);
|
|
77831
|
+
}
|
|
77832
|
+
})();
|
|
77833
|
+
}
|
|
77834
|
+
});
|
|
77835
|
+
}
|
|
77836
|
+
async function peerOutboundFetch(input3, init) {
|
|
77837
|
+
if (globalThis.fetch !== BUILTIN_FETCH) {
|
|
77838
|
+
if (!init) return globalThis.fetch(input3);
|
|
77839
|
+
let {
|
|
77840
|
+
allowLoopback: _allowLoopback,
|
|
77841
|
+
dnsLookup: _dnsLookup,
|
|
77842
|
+
resolvedAddresses: _resolvedAddresses,
|
|
77843
|
+
...fetchInit
|
|
77844
|
+
} = init;
|
|
77845
|
+
return globalThis.fetch(input3, fetchInit);
|
|
77846
|
+
}
|
|
77847
|
+
let target2, route;
|
|
77848
|
+
try {
|
|
77849
|
+
target2 = typeof input3 == "string" ? new URL(input3) : input3, route = await resolvePeerOutboundRoute(target2, {
|
|
77850
|
+
allowLoopback: init?.allowLoopback,
|
|
77851
|
+
dnsLookup: init?.dnsLookup,
|
|
77852
|
+
resolvedAddresses: init?.resolvedAddresses,
|
|
77853
|
+
signal: init?.signal ?? void 0
|
|
77854
|
+
});
|
|
77855
|
+
} catch (err5) {
|
|
77856
|
+
throw cancelUploadBodyIfStream(init?.body, init?.signal?.aborted ? init.signal.reason : err5), err5;
|
|
77857
|
+
}
|
|
77858
|
+
return nodeFetchViaAdapter(target2, init, route);
|
|
77859
|
+
}
|
|
77860
|
+
|
|
77261
77861
|
// packages/web-server/src/peer-request-error.ts
|
|
77262
77862
|
var TIMEOUT_CODES = /* @__PURE__ */ new Set([
|
|
77263
77863
|
"ETIMEDOUT",
|
|
@@ -77353,8 +77953,11 @@ async function peerFetch(record6, path7, init = {}) {
|
|
|
77353
77953
|
headers: headers2,
|
|
77354
77954
|
...requestBody === void 0 ? {} : { body: requestBody },
|
|
77355
77955
|
...init.duplex === void 0 ? {} : { duplex: init.duplex },
|
|
77356
|
-
...signal === void 0 ? {} : { signal }
|
|
77357
|
-
|
|
77956
|
+
...signal === void 0 ? {} : { signal },
|
|
77957
|
+
...init.allowLoopback === void 0 ? {} : { allowLoopback: init.allowLoopback },
|
|
77958
|
+
...init.dnsLookup === void 0 ? {} : { dnsLookup: init.dnsLookup },
|
|
77959
|
+
...init.resolvedAddresses === void 0 ? {} : { resolvedAddresses: init.resolvedAddresses }
|
|
77960
|
+
}, res = await peerOutboundFetch(record6.origin + path7, requestInit);
|
|
77358
77961
|
if (res.ok || res.status === 304 && headers2.has("if-none-match")) return res;
|
|
77359
77962
|
let failure3 = await res.json().then((payload) => {
|
|
77360
77963
|
if (!payload || typeof payload != "object" || !("error" in payload)) return;
|
|
@@ -77405,54 +78008,33 @@ async function pinnedPeerGetJson(record6, path7, options = {}) {
|
|
|
77405
78008
|
if (!record6.enabled) throw new SessionRuntimeError("remote/offline", "Remote peer is disabled");
|
|
77406
78009
|
let url2 = parsePeerUrl(record6.origin + path7, {
|
|
77407
78010
|
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
|
-
};
|
|
78011
|
+
}), candidateProxy = resolvePeerProxyUrl(url2), verified;
|
|
78012
|
+
try {
|
|
78013
|
+
verified = await resolveAndValidatePeerHost(url2, {
|
|
78014
|
+
allowLoopback: options.allowLoopback === !0,
|
|
78015
|
+
dnsLookup: options.dnsLookup
|
|
78016
|
+
});
|
|
78017
|
+
} catch (err5) {
|
|
78018
|
+
if (err5 instanceof PeerHostPolicyError || !candidateProxy || options.dnsLookup !== void 0 || !isDnsResolutionError(err5))
|
|
78019
|
+
throw err5;
|
|
78020
|
+
}
|
|
78021
|
+
options.onResolved?.(verified);
|
|
78022
|
+
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
78023
|
return await new Promise((resolve26, reject) => {
|
|
77434
78024
|
let settled2 = !1, fail = (err5) => {
|
|
77435
78025
|
settled2 || (settled2 = !0, reject(err5));
|
|
77436
78026
|
}, succeed = (value) => {
|
|
77437
78027
|
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}`,
|
|
78028
|
+
}, req = openPeerHttpRequest(url2, {
|
|
77443
78029
|
method: "GET",
|
|
77444
78030
|
headers: {
|
|
77445
|
-
host: url2.host,
|
|
77446
78031
|
authorization: "Bearer " + record6.token,
|
|
77447
78032
|
"content-type": "application/json"
|
|
77448
78033
|
},
|
|
77449
|
-
|
|
77450
|
-
lookup: pinnedLookup,
|
|
78034
|
+
...proxy ? { proxy } : {},
|
|
78035
|
+
...!proxy && pinnedLookup ? { lookup: pinnedLookup } : {},
|
|
77451
78036
|
signal
|
|
77452
|
-
}
|
|
77453
|
-
...requestOptions,
|
|
77454
|
-
...isIP2(bareHostname) === 0 ? { servername: bareHostname } : {}
|
|
77455
|
-
}) : httpRequest(requestOptions);
|
|
78037
|
+
});
|
|
77456
78038
|
req.on("error", () => {
|
|
77457
78039
|
fail(new SessionRuntimeError("remote/offline", "Remote peer is unreachable"));
|
|
77458
78040
|
}), req.on("response", (res) => {
|
|
@@ -77533,6 +78115,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77533
78115
|
rejectNodeId;
|
|
77534
78116
|
allowLoopback;
|
|
77535
78117
|
dnsLookup;
|
|
78118
|
+
probedAddresses;
|
|
77536
78119
|
fullKnownTurns = /* @__PURE__ */ new Map();
|
|
77537
78120
|
truncatedKnownTurns = /* @__PURE__ */ new Map();
|
|
77538
78121
|
knownTurnsEpoch;
|
|
@@ -77641,11 +78224,18 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77641
78224
|
manifest: () => this.manifest
|
|
77642
78225
|
};
|
|
77643
78226
|
}
|
|
78227
|
+
outboundFetchOptions() {
|
|
78228
|
+
return {
|
|
78229
|
+
allowLoopback: this.allowLoopback,
|
|
78230
|
+
...this.probedAddresses !== void 0 ? { resolvedAddresses: this.probedAddresses } : this.dnsLookup !== void 0 ? { dnsLookup: this.dnsLookup } : {}
|
|
78231
|
+
};
|
|
78232
|
+
}
|
|
77644
78233
|
fetch(path7, method2 = "GET", body, streamSignal) {
|
|
77645
78234
|
return peerFetch(this.record, path7, {
|
|
77646
78235
|
method: method2,
|
|
77647
78236
|
...body === void 0 ? {} : { body },
|
|
77648
|
-
...streamSignal ? { stream: !0, signal: AbortSignal.any([streamSignal, this.life.signal]) } : { signal: this.life.signal }
|
|
78237
|
+
...streamSignal ? { stream: !0, signal: AbortSignal.any([streamSignal, this.life.signal]) } : { signal: this.life.signal },
|
|
78238
|
+
...this.outboundFetchOptions()
|
|
77649
78239
|
});
|
|
77650
78240
|
}
|
|
77651
78241
|
async waitForInitialConnection() {
|
|
@@ -77663,18 +78253,21 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77663
78253
|
async probe() {
|
|
77664
78254
|
let start = Date.now();
|
|
77665
78255
|
try {
|
|
77666
|
-
let manifest2 = remotePeerManifestSchema.parse(
|
|
78256
|
+
let resolvedAddresses, manifest2 = remotePeerManifestSchema.parse(
|
|
77667
78257
|
await pinnedPeerGetJson(this.record, "/api/peer/v1/manifest", {
|
|
77668
78258
|
allowLoopback: this.allowLoopback,
|
|
77669
78259
|
dnsLookup: this.dnsLookup,
|
|
77670
|
-
signal: this.life.signal
|
|
78260
|
+
signal: this.life.signal,
|
|
78261
|
+
onResolved: (addresses) => {
|
|
78262
|
+
resolvedAddresses = addresses;
|
|
78263
|
+
}
|
|
77671
78264
|
})
|
|
77672
78265
|
);
|
|
77673
78266
|
if (this.rejectNodeId !== void 0 && manifest2.nodeId === this.rejectNodeId)
|
|
77674
78267
|
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";
|
|
78268
|
+
this.probedAddresses = resolvedAddresses, this.manifest = manifest2, this.manifestVerified = !0, this.latencyMs = Date.now() - start, delete this.lastError, this.state = this.streamOnline ? "connected" : "connecting";
|
|
77676
78269
|
} catch (e) {
|
|
77677
|
-
if (this.manifestVerified = !1, e instanceof PeerHostPolicyError || e instanceof Error && e.message === SELF_PAIR_ERROR)
|
|
78270
|
+
if (this.manifestVerified = !1, this.probedAddresses = void 0, e instanceof PeerHostPolicyError || e instanceof PeerProxyConfigError || e instanceof Error && e.message === SELF_PAIR_ERROR)
|
|
77678
78271
|
throw delete this.manifest, this.state = "offline", this.lastError = e.message, this.setStreamOffline(), this.initialConnection.resolve(void 0), e;
|
|
77679
78272
|
this.state = e instanceof SessionRuntimeError && e.code === "remote/auth-error" ? "auth-error" : "offline";
|
|
77680
78273
|
let message2 = this.state === "auth-error" ? "Remote peer rejected the access token" : "Remote peer manifest unavailable";
|
|
@@ -77750,7 +78343,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77750
78343
|
}
|
|
77751
78344
|
}
|
|
77752
78345
|
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;
|
|
78346
|
+
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
78347
|
}
|
|
77755
78348
|
async introduce(params) {
|
|
77756
78349
|
if (!this.isHttpReady)
|
|
@@ -77761,7 +78354,8 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77761
78354
|
method: "POST",
|
|
77762
78355
|
body: params,
|
|
77763
78356
|
timeoutMs: 15e3,
|
|
77764
|
-
signal: this.life.signal
|
|
78357
|
+
signal: this.life.signal,
|
|
78358
|
+
...this.outboundFetchOptions()
|
|
77765
78359
|
}), result = remotePeerIntroduceResultSchema.safeParse(
|
|
77766
78360
|
await response.json().catch(() => {
|
|
77767
78361
|
})
|
|
@@ -77817,7 +78411,8 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77817
78411
|
sourceId: request3.sourceId ?? this.record.peerId
|
|
77818
78412
|
},
|
|
77819
78413
|
signal,
|
|
77820
|
-
timeoutMs: options.timeoutMs ?? defaultTimeoutMs
|
|
78414
|
+
timeoutMs: options.timeoutMs ?? defaultTimeoutMs,
|
|
78415
|
+
...this.outboundFetchOptions()
|
|
77821
78416
|
}), payload;
|
|
77822
78417
|
try {
|
|
77823
78418
|
payload = await res.json();
|
|
@@ -78508,9 +79103,9 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
78508
79103
|
}
|
|
78509
79104
|
return inspection;
|
|
78510
79105
|
}
|
|
78511
|
-
async models(refresh = !1, harnessId, preferences2) {
|
|
79106
|
+
async models(refresh = !1, harnessId, preferences2, projectHarnessId2) {
|
|
78512
79107
|
if (!refresh)
|
|
78513
|
-
return await Promise.allSettled(this.refreshing.values()), this.readModels(!1, void 0, preferences2);
|
|
79108
|
+
return await Promise.allSettled(this.refreshing.values()), this.readModels(!1, void 0, preferences2, projectHarnessId2);
|
|
78514
79109
|
let pending = this.refreshing.get(harnessId);
|
|
78515
79110
|
if (pending) return pending;
|
|
78516
79111
|
let operation = this.readModels(!0, harnessId).finally(() => {
|
|
@@ -78559,7 +79154,7 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
78559
79154
|
}
|
|
78560
79155
|
)), id2 === "codex" ? void 0 : timedOutInspection();
|
|
78561
79156
|
}
|
|
78562
|
-
async readModels(refresh, harnessId, preferences2) {
|
|
79157
|
+
async readModels(refresh, harnessId, preferences2, projectHarnessId2) {
|
|
78563
79158
|
let shouldRefresh = (id2) => refresh && (harnessId === void 0 || harnessId === id2), plugins2 = await this.list(), values2 = (await Promise.all(
|
|
78564
79159
|
plugins2.map(async ({ id: id2, name: name2, links }) => ({
|
|
78565
79160
|
id: id2,
|
|
@@ -78585,9 +79180,9 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
78585
79180
|
}
|
|
78586
79181
|
let groups = values2.flatMap(
|
|
78587
79182
|
({ id: id2, name: name2, inspection }) => inspection.status === "ready" ? [groupOf(id2, name2, inspection)] : []
|
|
78588
|
-
),
|
|
79183
|
+
), ready = values2.filter(
|
|
78589
79184
|
(value) => value.inspection.status === "ready" && value.inspection.catalog.models.length
|
|
78590
|
-
), failures = values2.flatMap(
|
|
79185
|
+
), projectHarness = ready.find((value) => value.id === projectHarnessId2), first = projectHarness ?? ready[0], failures = values2.flatMap(
|
|
78591
79186
|
({ id: id2, name: name2, inspection }) => inspection.status !== "ready" && inspection.status !== "notInstalled" ? [
|
|
78592
79187
|
{
|
|
78593
79188
|
id: id2,
|
|
@@ -78617,7 +79212,11 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
78617
79212
|
},
|
|
78618
79213
|
await this.displayEntries()
|
|
78619
79214
|
);
|
|
78620
|
-
return this.preferences && selection2 ? this.preferences.decorate(
|
|
79215
|
+
return this.preferences && selection2 ? this.preferences.decorate(
|
|
79216
|
+
{ ...catalog, default: selection2 },
|
|
79217
|
+
preferences2,
|
|
79218
|
+
projectHarness?.id
|
|
79219
|
+
) : catalog;
|
|
78621
79220
|
}
|
|
78622
79221
|
async name(id2) {
|
|
78623
79222
|
return id2 === "codex" ? "Codex" : (await this.list()).find((plugin) => plugin.id === id2)?.name ?? id2;
|
|
@@ -78643,6 +79242,10 @@ var permissionCommand = {
|
|
|
78643
79242
|
name: "permission",
|
|
78644
79243
|
description: "Select a native permission mode",
|
|
78645
79244
|
input: { hint: "<mode>" }
|
|
79245
|
+
}, codexPlanCommand = {
|
|
79246
|
+
definitionId: "@deepseek-ai/dsh-plan-mode",
|
|
79247
|
+
name: "plan",
|
|
79248
|
+
description: "Enter or leave native Codex Plan Mode"
|
|
78646
79249
|
};
|
|
78647
79250
|
function requireDirectCommand(catalog, commandId) {
|
|
78648
79251
|
let command = catalog.commands.find((item) => item.id === commandId);
|
|
@@ -80313,6 +80916,8 @@ function markdownImageAlt(path7) {
|
|
|
80313
80916
|
function itemOf(item, reasoningPreviewIds, projectImage, projectionKey, projectText) {
|
|
80314
80917
|
let itemId = item.id;
|
|
80315
80918
|
switch (item.type) {
|
|
80919
|
+
case "plan":
|
|
80920
|
+
return typeof item.text != "string" || !item.text.trim() ? void 0 : { type: "agentMessage", itemId, text: projectText(item.text) };
|
|
80316
80921
|
case "agentMessage":
|
|
80317
80922
|
return {
|
|
80318
80923
|
type: "agentMessage",
|
|
@@ -83575,7 +84180,16 @@ import { dirname as dirname5, isAbsolute as isAbsolute6, join as join9, parse as
|
|
|
83575
84180
|
// packages/web-server/src/compression.ts
|
|
83576
84181
|
import { promisify as promisify2 } from "node:util";
|
|
83577
84182
|
import { brotliCompress, constants as constants3, gzip } from "node:zlib";
|
|
83578
|
-
var COMPRESSION_THRESHOLD = 1024, brotliAsync = promisify2(brotliCompress), gzipAsync = promisify2(gzip), compressedAssets = /* @__PURE__ */ new Map();
|
|
84183
|
+
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;
|
|
84184
|
+
function cacheCompressedAsset(key, buffer3) {
|
|
84185
|
+
if (buffer3.byteLength > MAX_COMPRESSED_CACHE_BYTES) return;
|
|
84186
|
+
let existing = compressedAssets.get(key);
|
|
84187
|
+
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; ) {
|
|
84188
|
+
let oldest = compressedAssets.entries().next().value;
|
|
84189
|
+
if (!oldest) break;
|
|
84190
|
+
compressedAssets.delete(oldest[0]), compressedAssetBytes -= oldest[1].byteLength;
|
|
84191
|
+
}
|
|
84192
|
+
}
|
|
83579
84193
|
function isCompressible(contentType) {
|
|
83580
84194
|
let type2 = contentType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
83581
84195
|
return type2.startsWith("text/") || [
|
|
@@ -83598,12 +84212,27 @@ async function compressResponse(body, contentType, acceptEncoding, cacheKey) {
|
|
|
83598
84212
|
headers2.vary = "Accept-Encoding";
|
|
83599
84213
|
let encoding = negotiate(acceptEncoding);
|
|
83600
84214
|
if (encoding === void 0 || body.length < COMPRESSION_THRESHOLD) return { body, headers: headers2 };
|
|
83601
|
-
let key = cacheKey === void 0 ? void 0 : `${encoding}:${cacheKey}
|
|
83602
|
-
|
|
84215
|
+
let key = cacheKey === void 0 ? void 0 : `${encoding}:${cacheKey}`;
|
|
84216
|
+
if (key !== void 0) {
|
|
84217
|
+
let cached3 = compressedAssets.get(key);
|
|
84218
|
+
if (cached3 !== void 0)
|
|
84219
|
+
return compressedAssets.delete(key), compressedAssets.set(key, cached3), headers2["content-encoding"] = encoding, { body: cached3, headers: headers2 };
|
|
84220
|
+
}
|
|
84221
|
+
let compressed = key === void 0 ? void 0 : inFlightCompressed.get(key);
|
|
84222
|
+
if (compressed === void 0) {
|
|
84223
|
+
let shouldCache = key !== void 0 && body.byteLength <= MAX_CACHED_UNCOMPRESSED_BYTES;
|
|
84224
|
+
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) {
|
|
84225
|
+
let pending = compressed, cleanup = () => {
|
|
84226
|
+
inFlightCompressed.get(key) === pending && inFlightCompressed.delete(key);
|
|
84227
|
+
};
|
|
84228
|
+
inFlightCompressed.set(key, pending), pending.then(cleanup, cleanup);
|
|
84229
|
+
}
|
|
84230
|
+
}
|
|
84231
|
+
return headers2["content-encoding"] = encoding, { body: await compressed, headers: headers2 };
|
|
83603
84232
|
}
|
|
83604
84233
|
|
|
83605
84234
|
// packages/web-server/src/peer-image-http.ts
|
|
83606
|
-
import { Readable } from "node:stream";
|
|
84235
|
+
import { Readable as Readable2 } from "node:stream";
|
|
83607
84236
|
import { pipeline } from "node:stream/promises";
|
|
83608
84237
|
|
|
83609
84238
|
// packages/web-server/src/http-content-length.ts
|
|
@@ -83689,7 +84318,7 @@ async function servePeerImageBody(upstream, response, etag, length) {
|
|
|
83689
84318
|
async function* body() {
|
|
83690
84319
|
yield* parts, yield* chunks;
|
|
83691
84320
|
}
|
|
83692
|
-
await pipeline(
|
|
84321
|
+
await pipeline(Readable2.from(body(), { objectMode: !1 }), response);
|
|
83693
84322
|
return;
|
|
83694
84323
|
}
|
|
83695
84324
|
for await (let chunk of chunks) parts.push(chunk);
|
|
@@ -84543,7 +85172,7 @@ async function startPeerDelegationBridge(options) {
|
|
|
84543
85172
|
|
|
84544
85173
|
// packages/web-server/src/peer-workspace-files-http.ts
|
|
84545
85174
|
import { extname as extname6, posix as posix3, win32 as win327 } from "node:path";
|
|
84546
|
-
import { Readable as
|
|
85175
|
+
import { Readable as Readable5 } from "node:stream";
|
|
84547
85176
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
84548
85177
|
|
|
84549
85178
|
// apps/web-ui/packages/host/dsh-web-backend/src/index.ts
|
|
@@ -89660,7 +90289,7 @@ var clientRequestSchema = external_exports.object({
|
|
|
89660
90289
|
]);
|
|
89661
90290
|
|
|
89662
90291
|
// apps/web-ui/packages/client/connection/src/http-bridge.ts
|
|
89663
|
-
import { Readable as
|
|
90292
|
+
import { Readable as Readable3 } from "node:stream";
|
|
89664
90293
|
var DEFAULT_MAX_REQUEST_BODY_BYTES = 300 * 1024 * 1024;
|
|
89665
90294
|
async function bridge(req, res, apiHandler, maxRequestBodyBytes = DEFAULT_MAX_REQUEST_BODY_BYTES) {
|
|
89666
90295
|
let abort = new AbortController();
|
|
@@ -89695,7 +90324,7 @@ async function bridge(req, res, apiHandler, maxRequestBodyBytes = DEFAULT_MAX_RE
|
|
|
89695
90324
|
request3 = new Request(url2, {
|
|
89696
90325
|
method: method2,
|
|
89697
90326
|
headers: headers2,
|
|
89698
|
-
body:
|
|
90327
|
+
body: Readable3.toWeb(req),
|
|
89699
90328
|
signal: abort.signal,
|
|
89700
90329
|
duplex: "half"
|
|
89701
90330
|
});
|
|
@@ -89987,7 +90616,7 @@ import * as sysPath2 from "path";
|
|
|
89987
90616
|
|
|
89988
90617
|
// node_modules/readdirp/esm/index.js
|
|
89989
90618
|
import { stat as stat4, lstat as lstat4, readdir as readdir3, realpath as realpath3 } from "node:fs/promises";
|
|
89990
|
-
import { Readable as
|
|
90619
|
+
import { Readable as Readable4 } from "node:stream";
|
|
89991
90620
|
import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from "node:path";
|
|
89992
90621
|
var EntryTypes = {
|
|
89993
90622
|
FILE_TYPE: "files",
|
|
@@ -90032,7 +90661,7 @@ var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR", NORMAL_FLOW_ERRORS = /* @
|
|
|
90032
90661
|
return (entry) => trItems.some((f) => entry.basename === f);
|
|
90033
90662
|
}
|
|
90034
90663
|
return emptyFn;
|
|
90035
|
-
}, ReaddirpStream = class extends
|
|
90664
|
+
}, ReaddirpStream = class extends Readable4 {
|
|
90036
90665
|
constructor(options = {}) {
|
|
90037
90666
|
super({
|
|
90038
90667
|
objectMode: !0,
|
|
@@ -101463,39 +102092,64 @@ function waitForPromise(promise2, signal) {
|
|
|
101463
102092
|
function errorReason(reason, fallback) {
|
|
101464
102093
|
return reason instanceof Error ? reason : new Error(fallback, { cause: reason });
|
|
101465
102094
|
}
|
|
101466
|
-
var DEFAULT_CACHE_MAX_ROOTS =
|
|
102095
|
+
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
102096
|
searches = /* @__PURE__ */ new Map();
|
|
101468
102097
|
maxRoots;
|
|
101469
102098
|
refreshIntervalMs;
|
|
102099
|
+
idleTtlMs;
|
|
101470
102100
|
config;
|
|
102101
|
+
sweepTimer;
|
|
101471
102102
|
disposed = !1;
|
|
101472
102103
|
constructor(options = {}) {
|
|
101473
|
-
this.maxRoots = options.maxRoots ?? DEFAULT_CACHE_MAX_ROOTS, this.refreshIntervalMs = options.refreshIntervalMs ?? DEFAULT_CACHE_REFRESH_INTERVAL_MS, this.config = options.config ?? {
|
|
102104
|
+
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
102105
|
maxResults: DEFAULT_FILE_SEARCH_MAX_RESULTS,
|
|
101475
102106
|
maxEntries: DEFAULT_FILE_SEARCH_MAX_ENTRIES,
|
|
101476
102107
|
excludedDirectories: DEFAULT_FILE_SEARCH_EXCLUDED_DIRECTORIES
|
|
101477
102108
|
};
|
|
101478
102109
|
}
|
|
102110
|
+
ensureSweepTimer() {
|
|
102111
|
+
if (this.sweepTimer || this.disposed || this.idleTtlMs <= 0) return;
|
|
102112
|
+
let intervalMs = Math.min(DEFAULT_CACHE_SWEEP_INTERVAL_MS, Math.max(1e3, this.idleTtlMs));
|
|
102113
|
+
this.sweepTimer = setInterval(() => {
|
|
102114
|
+
this.sweepIdle(Date.now());
|
|
102115
|
+
}, intervalMs), this.sweepTimer.unref();
|
|
102116
|
+
}
|
|
102117
|
+
stopSweepTimer() {
|
|
102118
|
+
this.sweepTimer && (clearInterval(this.sweepTimer), this.sweepTimer = void 0);
|
|
102119
|
+
}
|
|
102120
|
+
sweepIdle(now) {
|
|
102121
|
+
if (!(this.idleTtlMs <= 0)) {
|
|
102122
|
+
for (let [root, entry] of this.searches)
|
|
102123
|
+
entry.inFlight === 0 && now - entry.lastAccessedAt >= this.idleTtlMs && (entry.search.dispose(), this.searches.delete(root));
|
|
102124
|
+
this.searches.size === 0 && this.stopSweepTimer();
|
|
102125
|
+
}
|
|
102126
|
+
}
|
|
102127
|
+
evictOverflow() {
|
|
102128
|
+
for (let [candidateRoot, candidate] of this.searches) {
|
|
102129
|
+
if (this.searches.size <= this.maxRoots) break;
|
|
102130
|
+
candidate.inFlight > 0 || (candidate.search.dispose(), this.searches.delete(candidateRoot));
|
|
102131
|
+
}
|
|
102132
|
+
}
|
|
101479
102133
|
async list(root, query, signal) {
|
|
101480
102134
|
if (signal.throwIfAborted(), this.disposed) return [];
|
|
101481
|
-
let now = Date.now()
|
|
101482
|
-
|
|
101483
|
-
|
|
101484
|
-
|
|
101485
|
-
|
|
101486
|
-
|
|
101487
|
-
|
|
101488
|
-
|
|
101489
|
-
|
|
101490
|
-
|
|
101491
|
-
|
|
101492
|
-
|
|
102135
|
+
let now = Date.now();
|
|
102136
|
+
this.sweepIdle(now);
|
|
102137
|
+
let entry = this.searches.get(root);
|
|
102138
|
+
entry ? (now - entry.refreshedAt >= this.refreshIntervalMs && (entry.search.invalidate(), entry.refreshedAt = now), entry.lastAccessedAt = now) : entry = {
|
|
102139
|
+
search: new WorkspaceFileSearch(root, this.config),
|
|
102140
|
+
refreshedAt: now,
|
|
102141
|
+
lastAccessedAt: now,
|
|
102142
|
+
inFlight: 0
|
|
102143
|
+
}, this.searches.delete(root), this.searches.set(root, entry), entry.inFlight += 1, this.evictOverflow(), this.ensureSweepTimer();
|
|
102144
|
+
try {
|
|
102145
|
+
return await entry.search.list(query, signal);
|
|
102146
|
+
} finally {
|
|
102147
|
+
entry.inFlight -= 1, entry.lastAccessedAt = Date.now(), this.searches.size > this.maxRoots && this.evictOverflow();
|
|
101493
102148
|
}
|
|
101494
|
-
return this.searches.delete(root), this.searches.set(root, entry), entry.search.list(query, signal);
|
|
101495
102149
|
}
|
|
101496
102150
|
close() {
|
|
101497
102151
|
if (!this.disposed) {
|
|
101498
|
-
this.disposed = !0;
|
|
102152
|
+
this.disposed = !0, this.stopSweepTimer();
|
|
101499
102153
|
for (let { search } of this.searches.values()) search.dispose();
|
|
101500
102154
|
this.searches.clear();
|
|
101501
102155
|
}
|
|
@@ -101509,7 +102163,11 @@ var PEER_WORKSPACE_FILES_HEADER = "x-codexhost-peer-workspace-files", MAX_PEER_S
|
|
|
101509
102163
|
"workspaceFiles/stat",
|
|
101510
102164
|
"workspaceFiles/list",
|
|
101511
102165
|
"officeToPdf/render"
|
|
101512
|
-
]), defaultPeerSearchCache
|
|
102166
|
+
]), defaultPeerSearchCache;
|
|
102167
|
+
function getDefaultPeerSearchCache() {
|
|
102168
|
+
return defaultPeerSearchCache ??= new WorkspaceFileSearchCache();
|
|
102169
|
+
}
|
|
102170
|
+
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
102171
|
"Cache-Control": "private, no-store",
|
|
101514
102172
|
"X-Content-Type-Options": "nosniff",
|
|
101515
102173
|
"Content-Security-Policy": "sandbox; default-src 'none'",
|
|
@@ -101576,7 +102234,7 @@ async function sendTypertMultipart(response, rpcId, value, bytes, signal) {
|
|
|
101576
102234
|
response.end();
|
|
101577
102235
|
return;
|
|
101578
102236
|
}
|
|
101579
|
-
await pipeline2(
|
|
102237
|
+
await pipeline2(Readable5.fromWeb(encoded.body), response);
|
|
101580
102238
|
}
|
|
101581
102239
|
function sendPlain2(response, status, message2, isHead = !1) {
|
|
101582
102240
|
response.destroyed || response.writableEnded || response.headersSent || response.writeHead(status, {
|
|
@@ -101989,7 +102647,7 @@ async function handleSearch(request3, response, deps, signal) {
|
|
|
101989
102647
|
);
|
|
101990
102648
|
return;
|
|
101991
102649
|
}
|
|
101992
|
-
let cache2 = deps.searchCache ??
|
|
102650
|
+
let cache2 = deps.searchCache ?? getDefaultPeerSearchCache();
|
|
101993
102651
|
try {
|
|
101994
102652
|
let items = await cache2.list(validated.realRoot, query, signal);
|
|
101995
102653
|
if (signal.aborted || response.destroyed) return;
|
|
@@ -102145,7 +102803,8 @@ var RemotePeerAttachments = class {
|
|
|
102145
102803
|
},
|
|
102146
102804
|
body: toReadableStream(chunks),
|
|
102147
102805
|
duplex: "half",
|
|
102148
|
-
timeoutMs: this.uploadTimeoutMs
|
|
102806
|
+
timeoutMs: this.uploadTimeoutMs,
|
|
102807
|
+
...activePeer.outboundFetchOptions?.()
|
|
102149
102808
|
}
|
|
102150
102809
|
), payload = await readPeerJson(
|
|
102151
102810
|
response,
|
|
@@ -102237,7 +102896,8 @@ var RemotePeerAttachments = class {
|
|
|
102237
102896
|
try {
|
|
102238
102897
|
response = await peerFetch(activePeer.record, `/api/peer/v1/file?${query.toString()}`, {
|
|
102239
102898
|
method: "GET",
|
|
102240
|
-
timeoutMs: this.requestTimeoutMs
|
|
102899
|
+
timeoutMs: this.requestTimeoutMs,
|
|
102900
|
+
...activePeer.outboundFetchOptions?.()
|
|
102241
102901
|
});
|
|
102242
102902
|
} catch (error62) {
|
|
102243
102903
|
if (error62 instanceof SessionRuntimeError) {
|
|
@@ -102317,7 +102977,8 @@ var RemotePeerAttachments = class {
|
|
|
102317
102977
|
...condition === void 0 ? {} : { "if-none-match": condition }
|
|
102318
102978
|
},
|
|
102319
102979
|
signal: abort.signal,
|
|
102320
|
-
timeoutMs: this.requestTimeoutMs
|
|
102980
|
+
timeoutMs: this.requestTimeoutMs,
|
|
102981
|
+
...peer.outboundFetchOptions?.()
|
|
102321
102982
|
}), etag = peerImageETag(upstream.headers.get("etag"));
|
|
102322
102983
|
if (upstream.status === 304 && etag && matchesImageETag(condition, etag)) {
|
|
102323
102984
|
response.writeHead(304, peerImageCacheHeaders(etag)).end();
|
|
@@ -106104,13 +106765,14 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106104
106765
|
this.searchTimeoutMs
|
|
106105
106766
|
), combinedSignal = signal ? AbortSignal.any([signal, timeoutController.signal]) : timeoutController.signal, params = new URLSearchParams({ threadId: resolved.threadId, q: query });
|
|
106106
106767
|
try {
|
|
106107
|
-
let upstream = await
|
|
106768
|
+
let upstream = await peerOutboundFetch(
|
|
106108
106769
|
`${resolved.peer.record.origin}/api/peer/v1/workspace-files/search?${params.toString()}`,
|
|
106109
106770
|
{
|
|
106110
106771
|
method: "GET",
|
|
106111
106772
|
redirect: "error",
|
|
106112
106773
|
headers: { authorization: `Bearer ${resolved.peer.record.token}` },
|
|
106113
|
-
signal: combinedSignal
|
|
106774
|
+
signal: combinedSignal,
|
|
106775
|
+
...resolved.peer.outboundFetchOptions?.()
|
|
106114
106776
|
}
|
|
106115
106777
|
);
|
|
106116
106778
|
if (upstream.status === 401)
|
|
@@ -106209,7 +106871,7 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106209
106871
|
idleController.signal
|
|
106210
106872
|
]);
|
|
106211
106873
|
try {
|
|
106212
|
-
let upstream = await
|
|
106874
|
+
let upstream = await peerOutboundFetch(
|
|
106213
106875
|
`${resolved.peer.record.origin}/api/peer/v1/workspace-files/rpc`,
|
|
106214
106876
|
{
|
|
106215
106877
|
method: "POST",
|
|
@@ -106219,7 +106881,8 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106219
106881
|
"content-type": "application/json"
|
|
106220
106882
|
},
|
|
106221
106883
|
body: rewrittenBody,
|
|
106222
|
-
signal
|
|
106884
|
+
signal,
|
|
106885
|
+
...resolved.peer.outboundFetchOptions?.()
|
|
106223
106886
|
}
|
|
106224
106887
|
);
|
|
106225
106888
|
if (browserAbort.signal.aborted || response.destroyed)
|
|
@@ -106340,13 +107003,14 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106340
107003
|
return writePlainError(response, 429, "too many concurrent remote file requests"), !0;
|
|
106341
107004
|
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
107005
|
try {
|
|
106343
|
-
let upstream = await
|
|
107006
|
+
let upstream = await peerOutboundFetch(
|
|
106344
107007
|
`${resolved.peer.record.origin}/api/peer/v1/workspace-files/download?${query.toString()}`,
|
|
106345
107008
|
{
|
|
106346
107009
|
method: "HEAD",
|
|
106347
107010
|
redirect: "error",
|
|
106348
107011
|
headers: { authorization: `Bearer ${resolved.peer.record.token}` },
|
|
106349
|
-
signal
|
|
107012
|
+
signal,
|
|
107013
|
+
...resolved.peer.outboundFetchOptions?.()
|
|
106350
107014
|
}
|
|
106351
107015
|
);
|
|
106352
107016
|
if (browserAbort.signal.aborted || response.destroyed) return !0;
|
|
@@ -106396,13 +107060,14 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
106396
107060
|
return writePlainError(response, 429, "too many concurrent remote file requests", isHead), !0;
|
|
106397
107061
|
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
107062
|
try {
|
|
106399
|
-
let upstream = await
|
|
107063
|
+
let upstream = await peerOutboundFetch(
|
|
106400
107064
|
`${resolved.peer.record.origin}/api/peer/v1/workspace-files/download?${query.toString()}`,
|
|
106401
107065
|
{
|
|
106402
107066
|
method: isHead ? "HEAD" : "GET",
|
|
106403
107067
|
redirect: "error",
|
|
106404
107068
|
headers: { authorization: `Bearer ${resolved.peer.record.token}` },
|
|
106405
|
-
signal
|
|
107069
|
+
signal,
|
|
107070
|
+
...resolved.peer.outboundFetchOptions?.()
|
|
106406
107071
|
}
|
|
106407
107072
|
);
|
|
106408
107073
|
if (clearTimeout(timer), browserAbort.signal.aborted || response.destroyed)
|
|
@@ -106480,7 +107145,8 @@ async function serveWorkspaceVideo(request3, response, url2, workspace) {
|
|
|
106480
107145
|
}
|
|
106481
107146
|
let mediaType = VIDEO_TYPES[extname7(path7).toLowerCase()], file3;
|
|
106482
107147
|
try {
|
|
106483
|
-
|
|
107148
|
+
let nativePath = process.platform === "win32" ? path7.replace(/^\/(?=[a-z]:[/\\])/iu, "") : path7;
|
|
107149
|
+
file3 = await open9(resolve11(root, nativePath), constants9.O_RDONLY | constants9.O_NONBLOCK);
|
|
106484
107150
|
let meta3 = await file3.stat();
|
|
106485
107151
|
if (!meta3.isFile()) throw new Error("not a regular file");
|
|
106486
107152
|
if (mediaType === void 0) {
|
|
@@ -106562,6 +107228,13 @@ async function sendAsset(request3, response, asset, cacheControl = "no-cache", r
|
|
|
106562
107228
|
...compressed.headers
|
|
106563
107229
|
}).end(compressed.body);
|
|
106564
107230
|
}
|
|
107231
|
+
async function sendShellIndex(request3, response, sources) {
|
|
107232
|
+
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 : {
|
|
107233
|
+
...rendered,
|
|
107234
|
+
body: Buffer.from(String(rendered.body).replace("<head>", `<head>${sources.headScript}`))
|
|
107235
|
+
};
|
|
107236
|
+
await sendAsset(request3, response, document2, void 0, !0);
|
|
107237
|
+
}
|
|
106565
107238
|
|
|
106566
107239
|
// packages/web-server/src/tailscale-serve.ts
|
|
106567
107240
|
import { execFile as execFile3 } from "node:child_process";
|
|
@@ -106950,7 +107623,7 @@ var updateParams = hostExtensionsRpcSchemas[HOST_EXTENSIONS_RPC.update].params.o
|
|
|
106950
107623
|
source: !0
|
|
106951
107624
|
});
|
|
106952
107625
|
function isHostExtensionHttpPath(pathname) {
|
|
106953
|
-
return pathname === HOST_EXTENSION_UPLOAD_PATH || pathname === HOST_EXTENSION_CATALOG_ICON_PATH || pathname.startsWith(HOST_EXTENSION_ASSETS_PREFIX);
|
|
107626
|
+
return pathname === HOST_EXTENSION_UPLOAD_PATH || pathname === HOST_EXTENSION_CATALOG_ICON_PATH || pathname === HOST_EXTENSION_CATALOG_SCREENSHOT_PATH || pathname.startsWith(HOST_EXTENSION_ASSETS_PREFIX);
|
|
106954
107627
|
}
|
|
106955
107628
|
function parseAssetPath(pathname) {
|
|
106956
107629
|
let [id2, activationId, digest2, ...parts] = pathname.slice(HOST_EXTENSION_ASSETS_PREFIX.length).split("/"), segments = parts.map(decodeURIComponent);
|
|
@@ -107075,8 +107748,36 @@ async function serveCatalogIcon(channel, request3, response) {
|
|
|
107075
107748
|
"Cache-Control": "private, max-age=86400"
|
|
107076
107749
|
}).end(request3.method === "HEAD" ? void 0 : bytes);
|
|
107077
107750
|
}
|
|
107751
|
+
async function serveCatalogScreenshot(channel, request3, response) {
|
|
107752
|
+
let url2 = request3.url ?? "", queryStart = url2.indexOf("?"), query = new URLSearchParams(queryStart === -1 ? "" : url2.slice(queryStart + 1)), ids = query.getAll("id"), indexes = query.getAll("index"), parsedId = ids.length === 1 ? hostExtensionIdSchema.safeParse(ids[0]) : null, rawIndex = indexes.length === 1 ? indexes[0] : void 0, parsedIndex = rawIndex !== void 0 && /^\d+$/u.test(rawIndex) ? hostExtensionCatalogScreenshotIndexSchema.safeParse(Number(rawIndex)) : null;
|
|
107753
|
+
if (!parsedId?.success || !parsedIndex?.success) {
|
|
107754
|
+
response.writeHead(400).end();
|
|
107755
|
+
return;
|
|
107756
|
+
}
|
|
107757
|
+
let result;
|
|
107758
|
+
try {
|
|
107759
|
+
result = await channel.request(HOST_EXTENSIONS_RPC.catalogScreenshot, {
|
|
107760
|
+
id: parsedId.data,
|
|
107761
|
+
index: parsedIndex.data
|
|
107762
|
+
});
|
|
107763
|
+
} catch {
|
|
107764
|
+
response.writeHead(404).end();
|
|
107765
|
+
return;
|
|
107766
|
+
}
|
|
107767
|
+
let screenshot = hostExtensionsCatalogScreenshotResultSchema.safeParse(result);
|
|
107768
|
+
if (!screenshot.success) {
|
|
107769
|
+
response.writeHead(502).end();
|
|
107770
|
+
return;
|
|
107771
|
+
}
|
|
107772
|
+
let bytes = Buffer.from(screenshot.data.base64, "base64");
|
|
107773
|
+
response.writeHead(200, {
|
|
107774
|
+
"Content-Type": screenshot.data.mimeType,
|
|
107775
|
+
"Content-Length": bytes.length,
|
|
107776
|
+
"Cache-Control": "private, max-age=86400"
|
|
107777
|
+
}).end(request3.method === "HEAD" ? void 0 : bytes);
|
|
107778
|
+
}
|
|
107078
107779
|
async function serveHostExtensionHttp(host, trust2, request3, response, pathname, { requestAuth, safeMode = !1 }) {
|
|
107079
|
-
let upload = pathname === HOST_EXTENSION_UPLOAD_PATH, catalogIcon = pathname === HOST_EXTENSION_CATALOG_ICON_PATH;
|
|
107780
|
+
let upload = pathname === HOST_EXTENSION_UPLOAD_PATH, catalogIcon = pathname === HOST_EXTENSION_CATALOG_ICON_PATH, catalogScreenshot = pathname === HOST_EXTENSION_CATALOG_SCREENSHOT_PATH;
|
|
107080
107781
|
if (response.setHeader("Cache-Control", "private, no-store"), response.setHeader("X-Content-Type-Options", "nosniff"), upload || response.setHeader("Cross-Origin-Resource-Policy", "same-origin"), requestAuth === void 0 || safeMode || !trust2.sameOrigin(request3)) {
|
|
107081
107782
|
response.writeHead(403).end();
|
|
107082
107783
|
return;
|
|
@@ -107090,7 +107791,7 @@ async function serveHostExtensionHttp(host, trust2, request3, response, pathname
|
|
|
107090
107791
|
response.writeHead(503).end();
|
|
107091
107792
|
return;
|
|
107092
107793
|
}
|
|
107093
|
-
upload ? await serveUpload(channel, request3, response) : catalogIcon ? await serveCatalogIcon(channel, request3, response) : await serveAsset(channel, request3, response, pathname);
|
|
107794
|
+
upload ? await serveUpload(channel, request3, response) : catalogIcon ? await serveCatalogIcon(channel, request3, response) : catalogScreenshot ? await serveCatalogScreenshot(channel, request3, response) : await serveAsset(channel, request3, response, pathname);
|
|
107094
107795
|
}
|
|
107095
107796
|
|
|
107096
107797
|
// packages/web-server/src/workspace-file-actions.ts
|
|
@@ -108375,7 +109076,7 @@ var VIRTUAL_INTERFACE = /^(?:docker|br-|virbr|vmnet|vboxnet|veth|lxcbr|cni|flann
|
|
|
108375
109076
|
function isWildcardHost(host) {
|
|
108376
109077
|
return host === "0.0.0.0" || host === "::";
|
|
108377
109078
|
}
|
|
108378
|
-
function
|
|
109079
|
+
function isLoopbackHost3(host) {
|
|
108379
109080
|
return host === "localhost" || host === "::1" || host.startsWith("127.");
|
|
108380
109081
|
}
|
|
108381
109082
|
function kindOf(address, interfaceName) {
|
|
@@ -108384,7 +109085,7 @@ function kindOf(address, interfaceName) {
|
|
|
108384
109085
|
function networkAccessUrls(host, port, interfaces = networkInterfaces()) {
|
|
108385
109086
|
return (isWildcardHost(host) ? Object.entries(interfaces).flatMap(
|
|
108386
109087
|
([name2, entries]) => (entries ?? []).filter((entry) => entry.family === "IPv4" && !entry.internal).map((entry) => ({ address: entry.address, name: name2 }))
|
|
108387
|
-
) :
|
|
109088
|
+
) : isLoopbackHost3(host) ? [] : [{ address: host }]).map(({ address, name: name2 }) => ({
|
|
108388
109089
|
kind: kindOf(address, name2),
|
|
108389
109090
|
url: `http://${address}:${String(port)}/`
|
|
108390
109091
|
})).sort((a, b) => KIND_ORDER[a.kind] - KIND_ORDER[b.kind]);
|
|
@@ -109807,7 +110508,7 @@ import { promisify as promisify6 } from "node:util";
|
|
|
109807
110508
|
import { randomBytes as randomBytes32, sign as sign2 } from "node:crypto";
|
|
109808
110509
|
import { randomBytes as randomBytes42 } from "crypto";
|
|
109809
110510
|
import { createHash as createHash22, randomUUID as randomUUID22 } from "crypto";
|
|
109810
|
-
import { isIPv4 as
|
|
110511
|
+
import { isIPv4 as isIPv43 } from "net";
|
|
109811
110512
|
import * as timers2 from "node:timers/promises";
|
|
109812
110513
|
import { randomBytes as randomBytes7 } from "crypto";
|
|
109813
110514
|
import { isIPv4 as isIPv44, isIPv6 as isIPv64 } from "net";
|
|
@@ -109817,7 +110518,7 @@ import { isIPv4 as isIPv422, isIPv6 } from "node:net";
|
|
|
109817
110518
|
import { createSocket as createSocket3 } from "node:dgram";
|
|
109818
110519
|
import * as dns from "node:dns/promises";
|
|
109819
110520
|
import { isIP as isIP22, isIPv6 as isIPv62 } from "node:net";
|
|
109820
|
-
import { isIPv4 as
|
|
110521
|
+
import { isIPv4 as isIPv432, isIPv6 as isIPv63 } from "node:net";
|
|
109821
110522
|
import { promises as dns2 } from "node:dns";
|
|
109822
110523
|
import { isIP as isIP32, SocketAddress } from "node:net";
|
|
109823
110524
|
import { connect as connect32, createServer as createServer4 } from "node:net";
|
|
@@ -116089,7 +116790,7 @@ var log18 = debug("werift-dtls : packages/dtls/src/server.ts : log"), DtlsServer
|
|
|
116089
116790
|
);
|
|
116090
116791
|
}
|
|
116091
116792
|
canPairWith(other) {
|
|
116092
|
-
let a =
|
|
116793
|
+
let a = isIPv43(this.host), b = isIPv43(other.host);
|
|
116093
116794
|
return this.component === other.component && this.transport.toLowerCase() === other.transport.toLowerCase() && canPairTcpCandidates(this, other) && a === b;
|
|
116094
116795
|
}
|
|
116095
116796
|
toSdp() {
|
|
@@ -117106,7 +117807,7 @@ var HostAddressBind = {
|
|
|
117106
117807
|
let normalized = normalizeIp(address);
|
|
117107
117808
|
return normalized === "0.0.0.0" || normalized === "::";
|
|
117108
117809
|
};
|
|
117109
|
-
function
|
|
117810
|
+
function resolveHostAddresses2({
|
|
117110
117811
|
enumerated,
|
|
117111
117812
|
assigned = [],
|
|
117112
117813
|
interfaceAddresses,
|
|
@@ -117127,7 +117828,7 @@ function resolveHostAddresses({
|
|
|
117127
117828
|
map3.has(key) || map3.set(key, { address, bindAddress, costly });
|
|
117128
117829
|
}
|
|
117129
117830
|
return map3;
|
|
117130
|
-
}, locals = toMap(enumerated), assignedLocals = toMap(assigned), udp4 = interfaceAddresses?.udp4, udp6 = interfaceAddresses?.udp6, explicitOf = (address) =>
|
|
117831
|
+
}, 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
117832
|
let key = normalizeIp(host.address);
|
|
117132
117833
|
resolved.has(key) || resolved.set(key, host);
|
|
117133
117834
|
}, localOrWildcard = (address) => {
|
|
@@ -118443,12 +119144,12 @@ async function createStunOverTurnClient(config2, options = {}) {
|
|
|
118443
119144
|
return new StunOverTurnProtocol(turn);
|
|
118444
119145
|
}
|
|
118445
119146
|
function alternateTlsOptions(configured, alternateDomain, tlsOptions = {}) {
|
|
118446
|
-
let identity2 = alternateDomain ?? tlsOptions.servername ?? configured[0],
|
|
119147
|
+
let identity2 = alternateDomain ?? tlsOptions.servername ?? configured[0], checkServerIdentity22 = tlsOptions.checkServerIdentity ?? tls2.checkServerIdentity;
|
|
118447
119148
|
return {
|
|
118448
119149
|
...tlsOptions,
|
|
118449
119150
|
// SNI cannot carry an IP literal.
|
|
118450
119151
|
servername: isIP42(identity2) ? void 0 : identity2,
|
|
118451
|
-
checkServerIdentity: (_host, cert) =>
|
|
119152
|
+
checkServerIdentity: (_host, cert) => checkServerIdentity22(identity2, cert)
|
|
118452
119153
|
};
|
|
118453
119154
|
}
|
|
118454
119155
|
function tryAlternateOf(error62, addressFamily) {
|
|
@@ -120266,7 +120967,7 @@ var log26 = debug(
|
|
|
120266
120967
|
) ?? [])
|
|
120267
120968
|
this.appendLocalCandidate(this.withGeneration(reflexive));
|
|
120268
120969
|
}
|
|
120269
|
-
let address =
|
|
120970
|
+
let address = resolveHostAddresses2({
|
|
120270
120971
|
enumerated: getHostInterfaceAddresses(
|
|
120271
120972
|
this.options.useIpv4,
|
|
120272
120973
|
this.options.useIpv6,
|
|
@@ -123429,7 +124130,7 @@ function parseIceServerUrl(url2) {
|
|
|
123429
124130
|
let matched = /^(stun|stuns|turn|turns):(.+)$/i.exec(url2.trim());
|
|
123430
124131
|
if (!matched)
|
|
123431
124132
|
return;
|
|
123432
|
-
let [, rawScheme, rawRest] = matched, scheme = rawScheme.toLowerCase(), [authority] = rawRest.split("?", 1), [, query = ""] = rawRest.split("?"), address = parseAddress(authority,
|
|
124133
|
+
let [, rawScheme, rawRest] = matched, scheme = rawScheme.toLowerCase(), [authority] = rawRest.split("?", 1), [, query = ""] = rawRest.split("?"), address = parseAddress(authority, defaultPort2(scheme));
|
|
123433
124134
|
if (!address)
|
|
123434
124135
|
return;
|
|
123435
124136
|
if (scheme === "stun" || scheme === "stuns")
|
|
@@ -123451,7 +124152,7 @@ function resolveParsedTurnTransport({
|
|
|
123451
124152
|
}) {
|
|
123452
124153
|
return transportParam == null ? scheme === "turns" ? "tls" : void 0 : transportParam === "udp" ? scheme === "turns" ? "invalid" : "udp" : transportParam === "tcp" ? scheme === "turns" ? "tls" : "tcp" : "invalid";
|
|
123453
124154
|
}
|
|
123454
|
-
function
|
|
124155
|
+
function defaultPort2(scheme) {
|
|
123455
124156
|
return scheme === "stuns" || scheme === "turns" ? 5349 : 3478;
|
|
123456
124157
|
}
|
|
123457
124158
|
function parseAddress(value, fallbackPort) {
|
|
@@ -139501,6 +140202,33 @@ var CLIENT_PLUGINS = [
|
|
|
139501
140202
|
}
|
|
139502
140203
|
};
|
|
139503
140204
|
|
|
140205
|
+
// packages/web-server/src/project-harness-default.ts
|
|
140206
|
+
function projectHarnessId(workspaces2, workspaceId) {
|
|
140207
|
+
let { selection: selection2, lastHarnessId } = workspaces2.harnessPreference(workspaceId);
|
|
140208
|
+
return selection2.mode === "manual" ? selection2.harnessId : selection2.mode === "last" ? lastHarnessId : void 0;
|
|
140209
|
+
}
|
|
140210
|
+
function registerProjectHarnessDefault(rpc2, workspaces2, catalog) {
|
|
140211
|
+
rpc2.register("workspace/defaultHarness", async (args) => {
|
|
140212
|
+
let request3 = requestOf(args);
|
|
140213
|
+
if (typeof request3?.workspaceId != "string" || !request3.workspaceId)
|
|
140214
|
+
throw new SessionRuntimeError("workspace/invalid-request", "Choose a project.");
|
|
140215
|
+
let { workspaceId } = request3, current = workspaces2.harnessPreference(workspaceId), harnesses = (await catalog.models().catch((error62) => {
|
|
140216
|
+
if (!(error62 instanceof SessionRuntimeError && error62.code === "host/no-harness"))
|
|
140217
|
+
throw error62;
|
|
140218
|
+
}))?.groups.filter((group) => group.models.length > 0).map(({ id: id2, name: name2 }) => ({ id: id2, name: name2 })) ?? [];
|
|
140219
|
+
if (request3.selection !== void 0) {
|
|
140220
|
+
let selection2 = projectHarnessSelectionSchema.safeParse(request3.selection);
|
|
140221
|
+
if (!selection2.success)
|
|
140222
|
+
throw new SessionRuntimeError("workspace/invalid-request", "Choose a valid project default.");
|
|
140223
|
+
let next = selection2.data;
|
|
140224
|
+
if (next.mode === "manual" && !harnesses.some(({ id: id2 }) => id2 === next.harnessId))
|
|
140225
|
+
throw new SessionRuntimeError("workspace/harness-unavailable", "This Harness is unavailable.");
|
|
140226
|
+
return workspaces2.setHarnessSelection(workspaceId, next), {};
|
|
140227
|
+
}
|
|
140228
|
+
return { selection: current.selection, harnesses };
|
|
140229
|
+
});
|
|
140230
|
+
}
|
|
140231
|
+
|
|
139504
140232
|
// packages/web-server/src/draft-configuration.ts
|
|
139505
140233
|
function draftPermissionMode(harnessId, inspection, preferred) {
|
|
139506
140234
|
if (inspection.status !== "ready") return;
|
|
@@ -139550,8 +140278,9 @@ import { randomUUID as randomUUID19 } from "node:crypto";
|
|
|
139550
140278
|
import { existsSync as existsSync12, mkdirSync as mkdirSync7, statSync as statSync8 } from "node:fs";
|
|
139551
140279
|
import { basename as basename11, isAbsolute as isAbsolute20, join as join26, relative as relative11, resolve as resolve16, sep as sep9 } from "node:path";
|
|
139552
140280
|
import { homedir as homedir6 } from "node:os";
|
|
140281
|
+
var NATIVE_PROJECT_WORKSPACE_PREFIX = "codex-project:";
|
|
139553
140282
|
function nativeProjectWorkspaceId(projectId) {
|
|
139554
|
-
return
|
|
140283
|
+
return `${NATIVE_PROJECT_WORKSPACE_PREFIX}${projectId}`;
|
|
139555
140284
|
}
|
|
139556
140285
|
function insertSessionId(ids, sessionId, beforeId) {
|
|
139557
140286
|
let rest = ids.filter((id2) => id2 !== sessionId), index = beforeId === void 0 ? rest.length : rest.indexOf(beforeId);
|
|
@@ -139841,7 +140570,19 @@ var Workspaces = class {
|
|
|
139841
140570
|
updatedAt: previous.get(project2.id)?.updatedAt ?? now,
|
|
139842
140571
|
origin: "codexhost"
|
|
139843
140572
|
};
|
|
139844
|
-
})
|
|
140573
|
+
});
|
|
140574
|
+
let registeredNative = new Set(this.nativeWorkspaces.map((item) => item.workspaceId)), existingPreferences = this.harnessPreferencesRecord();
|
|
140575
|
+
if (Object.keys(existingPreferences).some(
|
|
140576
|
+
(id2) => id2.startsWith(NATIVE_PROJECT_WORKSPACE_PREFIX) && !registeredNative.has(id2)
|
|
140577
|
+
)) {
|
|
140578
|
+
let remaining = Object.fromEntries(
|
|
140579
|
+
Object.entries(existingPreferences).filter(
|
|
140580
|
+
([id2]) => !id2.startsWith(NATIVE_PROJECT_WORKSPACE_PREFIX) || registeredNative.has(id2)
|
|
140581
|
+
)
|
|
140582
|
+
);
|
|
140583
|
+
this.saveHarnessPreferences(remaining);
|
|
140584
|
+
}
|
|
140585
|
+
this.publishWorkspaceChanges(before), this.publishPinnedWorkspaces();
|
|
139845
140586
|
}
|
|
139846
140587
|
updateNativeProjectMember(sessionId, projectId) {
|
|
139847
140588
|
if (!this.nativeWorkspaces || !projectId) return;
|
|
@@ -140175,10 +140916,80 @@ var Workspaces = class {
|
|
|
140175
140916
|
(item) => item.workspaceId === workspaceId
|
|
140176
140917
|
);
|
|
140177
140918
|
}
|
|
140919
|
+
harnessPreference(workspaceId) {
|
|
140920
|
+
this.require(workspaceId);
|
|
140921
|
+
let raw = this.harnessPreferencesRecord();
|
|
140922
|
+
return Object.hasOwn(raw, workspaceId) ? this.parseHarnessPreference(raw[workspaceId]) : { selection: { mode: "global" } };
|
|
140923
|
+
}
|
|
140924
|
+
setHarnessSelection(workspaceId, selection2) {
|
|
140925
|
+
let current = this.harnessPreference(workspaceId);
|
|
140926
|
+
this.saveHarnessPreference(workspaceId, { ...current, selection: selection2 });
|
|
140927
|
+
}
|
|
140928
|
+
rememberHarness(workspaceId, harnessId) {
|
|
140929
|
+
let current = this.harnessPreference(workspaceId);
|
|
140930
|
+
current.lastHarnessId !== harnessId && this.saveHarnessPreference(workspaceId, { ...current, lastHarnessId: harnessId });
|
|
140931
|
+
}
|
|
140932
|
+
removeHarnessPreference(workspaceId) {
|
|
140933
|
+
let existing = this.harnessPreferencesRecord();
|
|
140934
|
+
if (!Object.hasOwn(existing, workspaceId)) return;
|
|
140935
|
+
let preferences2 = Object.fromEntries(
|
|
140936
|
+
Object.entries(existing).filter(([id2]) => id2 !== workspaceId)
|
|
140937
|
+
);
|
|
140938
|
+
this.saveHarnessPreferences(preferences2);
|
|
140939
|
+
}
|
|
140940
|
+
harnessPreferencesRecord() {
|
|
140941
|
+
let raw = this.state.harnessPreferences;
|
|
140942
|
+
return !raw || typeof raw != "object" || Array.isArray(raw) ? {} : raw;
|
|
140943
|
+
}
|
|
140944
|
+
parseHarnessPreference(raw) {
|
|
140945
|
+
if (!raw || typeof raw != "object" || Array.isArray(raw))
|
|
140946
|
+
return { selection: { mode: "global" } };
|
|
140947
|
+
let record6 = raw, selection2 = projectHarnessSelectionSchema.safeParse(record6.selection);
|
|
140948
|
+
if (!selection2.success) return { selection: { mode: "global" } };
|
|
140949
|
+
let lastHarnessId = harnessIdSchema.safeParse(record6.lastHarnessId);
|
|
140950
|
+
return lastHarnessId.success ? { selection: selection2.data, lastHarnessId: String(lastHarnessId.data) } : { selection: selection2.data };
|
|
140951
|
+
}
|
|
140952
|
+
saveHarnessPreferences(preferences2) {
|
|
140953
|
+
let state2 = { ...this.state };
|
|
140954
|
+
Object.keys(preferences2).length > 0 ? state2.harnessPreferences = preferences2 : delete state2.harnessPreferences, this.data.writeJson(FILE2, state2), this.state = state2;
|
|
140955
|
+
}
|
|
140956
|
+
saveHarnessPreference(workspaceId, preference) {
|
|
140957
|
+
this.saveHarnessPreferences({ ...this.harnessPreferencesRecord(), [workspaceId]: preference });
|
|
140958
|
+
}
|
|
140959
|
+
byExactPath(path7) {
|
|
140960
|
+
if (this.nativeWorkspaces) {
|
|
140961
|
+
let multiRootMatch;
|
|
140962
|
+
for (let item of this.nativeWorkspaces) {
|
|
140963
|
+
if (!item.projectId) continue;
|
|
140964
|
+
let roots = this.nativeRoots.get(item.projectId);
|
|
140965
|
+
if (roots?.includes(path7)) {
|
|
140966
|
+
if (roots.length === 1) return item;
|
|
140967
|
+
multiRootMatch ??= item;
|
|
140968
|
+
}
|
|
140969
|
+
}
|
|
140970
|
+
return multiRootMatch;
|
|
140971
|
+
}
|
|
140972
|
+
return this.state.items.find((item) => item.path === path7);
|
|
140973
|
+
}
|
|
140178
140974
|
byPath(path7) {
|
|
140179
|
-
|
|
140180
|
-
(
|
|
140181
|
-
|
|
140975
|
+
if (this.nativeWorkspaces) {
|
|
140976
|
+
let key = desktopProjectPathKey(path7), owner = this.nativeRootOwners.get(key);
|
|
140977
|
+
if (owner) return this.byProjectId(owner.projectId);
|
|
140978
|
+
if (this.nativeRootOwners.size > 0) return;
|
|
140979
|
+
let fallback = nativeProjectRootOwners(
|
|
140980
|
+
this.nativeWorkspaces.flatMap(
|
|
140981
|
+
(item) => item.projectId ? [
|
|
140982
|
+
{
|
|
140983
|
+
id: item.projectId,
|
|
140984
|
+
name: item.title,
|
|
140985
|
+
rootPaths: this.nativeRoots.get(item.projectId) ?? []
|
|
140986
|
+
}
|
|
140987
|
+
] : []
|
|
140988
|
+
)
|
|
140989
|
+
).get(key);
|
|
140990
|
+
return fallback ? this.byProjectId(fallback.projectId) : void 0;
|
|
140991
|
+
}
|
|
140992
|
+
return this.state.items.find((item) => item.path === path7);
|
|
140182
140993
|
}
|
|
140183
140994
|
/**
|
|
140184
140995
|
* The folder whose Threads a local Workspace lists, without the folders of nested local
|
|
@@ -140202,6 +141013,10 @@ var Workspaces = class {
|
|
|
140202
141013
|
ownerOf(sessionId) {
|
|
140203
141014
|
return this.list().find((item) => item.sessionIds.includes(sessionId));
|
|
140204
141015
|
}
|
|
141016
|
+
/** The native-project Workspace of a Thread whose sidebar membership has not caught up. */
|
|
141017
|
+
byProjectId(projectId) {
|
|
141018
|
+
return projectId == null ? void 0 : this.nativeWorkspaces?.find((item) => item.projectId === projectId);
|
|
141019
|
+
}
|
|
140205
141020
|
isArchived(sessionId) {
|
|
140206
141021
|
return this.archivedSessionIds().includes(sessionId);
|
|
140207
141022
|
}
|
|
@@ -140382,17 +141197,23 @@ var Workspaces = class {
|
|
|
140382
141197
|
let workspace = this.require(request3.workspaceId), {
|
|
140383
141198
|
displayOrder: currentDisplayOrder,
|
|
140384
141199
|
pinnedWorkspaceOverrides: currentPinnedOverrides,
|
|
141200
|
+
harnessPreferences: currentHarnessPreferences,
|
|
140385
141201
|
...stateWithoutOrderOrPins
|
|
140386
141202
|
} = this.state, nextDisplayOrder = currentDisplayOrder?.filter((id2) => id2 !== request3.workspaceId), nextPinnedOverrides = Object.fromEntries(
|
|
140387
141203
|
Object.entries(this.pinnedWorkspaceOverrides()).filter(
|
|
140388
141204
|
([id2]) => id2 !== request3.workspaceId
|
|
140389
141205
|
)
|
|
141206
|
+
), nextHarnessPreferences = Object.fromEntries(
|
|
141207
|
+
Object.entries(this.harnessPreferencesRecord()).filter(
|
|
141208
|
+
([id2]) => id2 !== request3.workspaceId
|
|
141209
|
+
)
|
|
140390
141210
|
), state2 = {
|
|
140391
141211
|
...stateWithoutOrderOrPins,
|
|
140392
141212
|
items: this.state.items.filter((item) => item.workspaceId !== request3.workspaceId),
|
|
140393
141213
|
deletedPaths: [...this.state.deletedPaths ?? [], workspace.path],
|
|
140394
141214
|
...nextDisplayOrder && nextDisplayOrder.length > 0 ? { displayOrder: nextDisplayOrder } : {},
|
|
140395
|
-
...Object.keys(nextPinnedOverrides).length > 0 ? { pinnedWorkspaceOverrides: nextPinnedOverrides } : {}
|
|
141215
|
+
...Object.keys(nextPinnedOverrides).length > 0 ? { pinnedWorkspaceOverrides: nextPinnedOverrides } : {},
|
|
141216
|
+
...Object.keys(nextHarnessPreferences).length > 0 ? { harnessPreferences: nextHarnessPreferences } : {}
|
|
140396
141217
|
};
|
|
140397
141218
|
return this.data.writeJson(FILE2, state2), this.state = state2, this.broadcast({ type: "remove", workspaceId: request3.workspaceId }), this.publishPinnedWorkspaces(), this.officialThreadSections?.some(
|
|
140398
141219
|
({ workspaceIds }) => workspaceIds?.includes(workspace.workspaceId)
|
|
@@ -141106,13 +141927,15 @@ ${request3}`
|
|
|
141106
141927
|
|
|
141107
141928
|
// packages/web-server/src/file-references.ts
|
|
141108
141929
|
var WebFileReferences = class {
|
|
141109
|
-
constructor(workspace, remoteSearch) {
|
|
141930
|
+
constructor(workspace, remoteSearch, cache2) {
|
|
141110
141931
|
this.workspace = workspace;
|
|
141111
141932
|
this.remoteSearch = remoteSearch;
|
|
141933
|
+
this.cache = cache2 ?? new WorkspaceFileSearchCache(), this.ownsCache = cache2 === void 0;
|
|
141112
141934
|
}
|
|
141113
141935
|
workspace;
|
|
141114
141936
|
remoteSearch;
|
|
141115
|
-
cache
|
|
141937
|
+
cache;
|
|
141938
|
+
ownsCache;
|
|
141116
141939
|
lifetime = new AbortController();
|
|
141117
141940
|
setRemoteSearch(search) {
|
|
141118
141941
|
this.remoteSearch = search;
|
|
@@ -141138,7 +141961,7 @@ var WebFileReferences = class {
|
|
|
141138
141961
|
});
|
|
141139
141962
|
}
|
|
141140
141963
|
close() {
|
|
141141
|
-
this.lifetime.abort(), this.cache.close();
|
|
141964
|
+
this.lifetime.abort(), this.ownsCache && this.cache.close();
|
|
141142
141965
|
}
|
|
141143
141966
|
};
|
|
141144
141967
|
|
|
@@ -141356,7 +142179,7 @@ function globalProjectionValues(values2) {
|
|
|
141356
142179
|
);
|
|
141357
142180
|
}
|
|
141358
142181
|
var ChSessions = class {
|
|
141359
|
-
constructor(host, workspaces2, events2, images2, files2, displayEntries2, preferences2, harnesses, openFile) {
|
|
142182
|
+
constructor(host, workspaces2, events2, images2, files2, displayEntries2, preferences2, harnesses, openFile, fileSearchCache) {
|
|
141360
142183
|
this.host = host;
|
|
141361
142184
|
this.workspaces = workspaces2;
|
|
141362
142185
|
this.events = events2;
|
|
@@ -141364,7 +142187,11 @@ var ChSessions = class {
|
|
|
141364
142187
|
this.files = files2;
|
|
141365
142188
|
this.preferences = preferences2;
|
|
141366
142189
|
this.openFile = openFile;
|
|
141367
|
-
this.
|
|
142190
|
+
this.fileReferences = new WebFileReferences(
|
|
142191
|
+
(id2) => this.fileWorkspaceRoot(id2),
|
|
142192
|
+
void 0,
|
|
142193
|
+
fileSearchCache
|
|
142194
|
+
), 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
142195
|
if (id2 = this.id(id2), this.closed) throw new SessionRuntimeError("host/offline", "The Web connection is closed.");
|
|
141369
142196
|
if (this.drafts.has(id2)) return id2;
|
|
141370
142197
|
await this.owner(id2), this.rows.has(id2) || await this.refresh();
|
|
@@ -141436,7 +142263,7 @@ var ChSessions = class {
|
|
|
141436
142263
|
files;
|
|
141437
142264
|
preferences;
|
|
141438
142265
|
openFile;
|
|
141439
|
-
fileReferences
|
|
142266
|
+
fileReferences;
|
|
141440
142267
|
catalog;
|
|
141441
142268
|
editing = new ChThreadEditing();
|
|
141442
142269
|
pins;
|
|
@@ -141451,6 +142278,7 @@ var ChSessions = class {
|
|
|
141451
142278
|
nativeGoals;
|
|
141452
142279
|
drafts = /* @__PURE__ */ new Map();
|
|
141453
142280
|
controls = /* @__PURE__ */ new Set();
|
|
142281
|
+
planChanges = /* @__PURE__ */ new Set();
|
|
141454
142282
|
refreshing;
|
|
141455
142283
|
refreshingCatalog = !1;
|
|
141456
142284
|
refreshingArchives = !1;
|
|
@@ -141990,13 +142818,20 @@ var ChSessions = class {
|
|
|
141990
142818
|
}
|
|
141991
142819
|
if (this.threads.view(id2) !== view)
|
|
141992
142820
|
throw new SessionRuntimeError("host/resync", "Host snapshot was superseded by a new generation");
|
|
141993
|
-
view.log.setProjection(
|
|
142821
|
+
if (view.log.setProjection(
|
|
141994
142822
|
"archiveForkParent",
|
|
141995
142823
|
this.archiveForkParent(this.rows.get(id2) ?? view.thread)
|
|
141996
142824
|
), view.log.setProjection(
|
|
141997
142825
|
"nativeDiscovery",
|
|
141998
142826
|
!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),
|
|
142827
|
+
), 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) {
|
|
142828
|
+
let mode = view.ownerSnapshot?.configuration.codexCollaborationMode;
|
|
142829
|
+
this.projectCodexPlanMode(
|
|
142830
|
+
view,
|
|
142831
|
+
harnessId === "codex" && !view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1 && mode !== void 0 ? mode === "plan" : null
|
|
142832
|
+
);
|
|
142833
|
+
}
|
|
142834
|
+
view.ownerSnapshot && this.hostOnline && !this.closed && (this.syncedRunningInteractions.add(id2), this.interactions?.update(view.ownerSnapshot)), this.realtime && view.log.setProjection("nativeConnection", {
|
|
142000
142835
|
state: this.hostOnline ? "connected" : "reconnecting"
|
|
142001
142836
|
}), this.threads.ensure(id2).historyReadAt = Date.now();
|
|
142002
142837
|
let name2 = await this.catalog.name(harnessId);
|
|
@@ -142101,8 +142936,56 @@ var ChSessions = class {
|
|
|
142101
142936
|
projections: { kind: "cached", asOfSeq: 0, values: values2 }
|
|
142102
142937
|
};
|
|
142103
142938
|
}
|
|
142939
|
+
async supportsCodexPlanMode() {
|
|
142940
|
+
if (!this.realtime) return !1;
|
|
142941
|
+
let result = await this.host.request("collaborationMode/list", {}).catch(() => {
|
|
142942
|
+
});
|
|
142943
|
+
return Array.isArray(result?.data) && result.data.some((entry) => entry?.mode === "plan") && result.data.some((entry) => entry?.mode === "default");
|
|
142944
|
+
}
|
|
142945
|
+
codexPlanSelection(sessionId) {
|
|
142946
|
+
let draft = this.drafts.get(sessionId);
|
|
142947
|
+
if (draft && !draft.canonicalId)
|
|
142948
|
+
return draft.selection.provider === "codex" ? draft.codexPlanMode === !0 : void 0;
|
|
142949
|
+
let projected = this.threads.view(this.id(sessionId))?.log.projections.codexPlanMode;
|
|
142950
|
+
return typeof projected == "boolean" ? projected : void 0;
|
|
142951
|
+
}
|
|
142952
|
+
projectCodexPlanMode(view, active3) {
|
|
142953
|
+
let previous = view.log.projections.codexPlanMode;
|
|
142954
|
+
view.log.setProjection("codexPlanMode", active3), previous !== void 0 && typeof previous == "boolean" != (active3 !== null) && this.events.emit("commands/change", view.thread.id);
|
|
142955
|
+
}
|
|
142956
|
+
async selectCodexPlanMode(id2, active3) {
|
|
142957
|
+
let mode = active3 ? "plan" : "default";
|
|
142958
|
+
if (this.planChanges.has(id2))
|
|
142959
|
+
throw new SessionRuntimeError("session/busy", "Codex is already changing plan mode.");
|
|
142960
|
+
this.planChanges.add(id2);
|
|
142961
|
+
let epoch = this.hostEpoch;
|
|
142962
|
+
try {
|
|
142963
|
+
let confirmed = await this.host.request(
|
|
142964
|
+
"codexhost/thread/collaboration-mode/select",
|
|
142965
|
+
{ threadId: id2, mode }
|
|
142966
|
+
);
|
|
142967
|
+
if (this.closed || epoch !== this.hostEpoch || confirmed?.mode !== mode)
|
|
142968
|
+
throw new SessionRuntimeError(
|
|
142969
|
+
"session/plan-unconfirmed",
|
|
142970
|
+
"Codex did not confirm the mode. Refresh the conversation."
|
|
142971
|
+
);
|
|
142972
|
+
let state2 = this.threads.ensure(id2);
|
|
142973
|
+
state2.configurationRevision = (state2.configurationRevision ?? 0) + 1, state2.view && this.projectCodexPlanMode(state2.view, active3);
|
|
142974
|
+
} finally {
|
|
142975
|
+
this.planChanges.delete(id2), this.realtime?.invalidate(id2);
|
|
142976
|
+
}
|
|
142977
|
+
}
|
|
142104
142978
|
async draftSummary(draft, includeControls = !0) {
|
|
142105
|
-
let
|
|
142979
|
+
let controls;
|
|
142980
|
+
do {
|
|
142981
|
+
let provider = draft.selection.provider, [inspection2, supportsPlan2, name3] = await Promise.all([
|
|
142982
|
+
includeControls ? this.catalog.inspect(provider, draft.cwd) : void 0,
|
|
142983
|
+
includeControls && provider === "codex" ? this.supportsCodexPlanMode() : !1,
|
|
142984
|
+
this.catalog.name(provider)
|
|
142985
|
+
]);
|
|
142986
|
+
controls = { provider, inspection: inspection2, supportsPlan: supportsPlan2, name: name3 };
|
|
142987
|
+
} while (controls.provider !== draft.selection.provider);
|
|
142988
|
+
let { inspection, supportsPlan, name: name2 } = controls;
|
|
142106
142989
|
return {
|
|
142107
142990
|
sessionId: draft.id,
|
|
142108
142991
|
cwd: draft.cwd,
|
|
@@ -142120,11 +143003,12 @@ var ChSessions = class {
|
|
|
142120
143003
|
attachmentInput: this.files ? WEB_FILE_INPUT : WEB_IMAGE_INPUT,
|
|
142121
143004
|
imageLimits: WEB_IMAGE_LIMITS
|
|
142122
143005
|
} : {},
|
|
142123
|
-
modelSelection: { lastUsed: null, next: draft.selection }
|
|
143006
|
+
modelSelection: { lastUsed: null, next: draft.selection },
|
|
143007
|
+
codexPlanMode: draft.selection.provider === "codex" && supportsPlan ? draft.codexPlanMode === !0 : null
|
|
142124
143008
|
} : {},
|
|
142125
143009
|
harnessIdentity: {
|
|
142126
143010
|
id: draft.selection.provider,
|
|
142127
|
-
name:
|
|
143011
|
+
name: name2
|
|
142128
143012
|
},
|
|
142129
143013
|
...inspection ? {
|
|
142130
143014
|
nativePermissions: nativePermissionView(
|
|
@@ -142141,16 +143025,36 @@ var ChSessions = class {
|
|
|
142141
143025
|
};
|
|
142142
143026
|
}
|
|
142143
143027
|
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.
|
|
143028
|
+
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
143029
|
if ((request3.workspaceId !== void 0 || request3.cwd !== void 0) && !cwd)
|
|
142146
143030
|
throw new SessionRuntimeError("workspace/invalid-path", "Choose a valid computer working directory.");
|
|
142147
143031
|
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)
|
|
143032
|
+
if (existing && !existing.canonicalId && !existing.creating && !existing.started && existing.cwd === cwd && existing.projectId === projectId) {
|
|
143033
|
+
if (!configuration && request3.matchProjectDefault) {
|
|
143034
|
+
if (existing.projectHarnessId !== projectHarnessId2)
|
|
143035
|
+
throw new SessionRuntimeError("session/writer-held", "Start a new draft with the project default.", {
|
|
143036
|
+
sessionId: id2
|
|
143037
|
+
});
|
|
143038
|
+
if (projectHarnessId2 !== void 0) {
|
|
143039
|
+
let preferences3 = this.preferences?.get().catch(() => {
|
|
143040
|
+
}), expected = (await this.catalog.models(!1, void 0, preferences3, projectHarnessId2)).default;
|
|
143041
|
+
if (this.closed) throw new SessionRuntimeError("session/closed", "Web sessions are closing.");
|
|
143042
|
+
if (this.drafts.get(id2) !== existing || existing.canonicalId || existing.creating || existing.started)
|
|
143043
|
+
throw new SessionRuntimeError("session/busy", "This Session already exists; start a new draft.");
|
|
143044
|
+
if ((project2 ? projectHarnessId(this.workspaces, project2.workspaceId) : void 0) !== projectHarnessId2 || existing.selection.provider !== expected?.provider)
|
|
143045
|
+
throw new SessionRuntimeError(
|
|
143046
|
+
"session/writer-held",
|
|
143047
|
+
"Start a new draft with the project default.",
|
|
143048
|
+
{ sessionId: id2 }
|
|
143049
|
+
);
|
|
143050
|
+
}
|
|
143051
|
+
}
|
|
142149
143052
|
return { sessionId: id2, agentPreset: "standard" };
|
|
143053
|
+
}
|
|
142150
143054
|
if (existing || this.rows.has(id2))
|
|
142151
143055
|
throw new SessionRuntimeError("session/busy", "This Session already exists; start a new draft.");
|
|
142152
143056
|
let preferences2 = configuration ? void 0 : this.preferences?.get().catch(() => {
|
|
142153
|
-
}), selection2 = configuration?.selection ?? (await this.catalog.models(!1, void 0, preferences2)).default;
|
|
143057
|
+
}), selection2 = configuration?.selection ?? (await this.catalog.models(!1, void 0, preferences2, projectHarnessId2)).default;
|
|
142154
143058
|
if (!selection2)
|
|
142155
143059
|
throw new SessionRuntimeError(
|
|
142156
143060
|
"host/no-harness",
|
|
@@ -142160,6 +143064,7 @@ var ChSessions = class {
|
|
|
142160
143064
|
id: id2,
|
|
142161
143065
|
...cwd ? { cwd } : {},
|
|
142162
143066
|
...projectId ? { projectId } : {},
|
|
143067
|
+
...projectHarnessId2 ? { projectHarnessId: projectHarnessId2 } : {},
|
|
142163
143068
|
selection: selection2,
|
|
142164
143069
|
createdAt: Date.now()
|
|
142165
143070
|
};
|
|
@@ -142242,7 +143147,7 @@ var ChSessions = class {
|
|
|
142242
143147
|
);
|
|
142243
143148
|
thread3.projectId = updated.thread.projectId, this.refreshingProjectAssignments?.set(thread3.id, draft.projectId);
|
|
142244
143149
|
}
|
|
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;
|
|
143150
|
+
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
143151
|
}
|
|
142247
143152
|
/**
|
|
142248
143153
|
* Working directory of one Host-confirmed local Thread.
|
|
@@ -142346,7 +143251,7 @@ var ChSessions = class {
|
|
|
142346
143251
|
}
|
|
142347
143252
|
syncBackgroundRunningInteractions() {
|
|
142348
143253
|
for (let row of this.rows.values())
|
|
142349
|
-
row.status.type === "active" ? !this.syncedRunningInteractions.has(row.id) && !this.interactionReads.has(row.id) && !this.threads.view(row.id) && this.reconcileBackgroundInteractions(row.id) :
|
|
143254
|
+
row.status.type === "active" ? !this.syncedRunningInteractions.has(row.id) && !this.interactionReads.has(row.id) && !this.threads.view(row.id) && this.reconcileBackgroundInteractions(row.id) : this.syncedRunningInteractions.delete(row.id) && this.interactions?.hasPending(row.id) && !this.threads.view(row.id) && this.reconcileBackgroundInteractions(row.id);
|
|
142350
143255
|
}
|
|
142351
143256
|
forgetDeleted(id2) {
|
|
142352
143257
|
this.refreshingDeletedIds?.add(id2), this.archiveOperations.delete(id2), this.queueOperations.delete(id2), this.titleRequests.delete(id2), this.syncedRunningInteractions.delete(id2);
|
|
@@ -142575,7 +143480,7 @@ var ChSessions = class {
|
|
|
142575
143480
|
archivedSessionIds,
|
|
142576
143481
|
nextCursor: page ? nextCatalogCursor(page, includeArchived) : null
|
|
142577
143482
|
};
|
|
142578
|
-
}), rpc2.register("session/create", (args) => this.create(args)), rpc2.register("session/fork", async (args) => {
|
|
143483
|
+
}), rpc2.register("session/create", (args) => this.create(args)), registerProjectHarnessDefault(rpc2, this.workspaces, this.catalog), rpc2.register("session/fork", async (args) => {
|
|
142579
143484
|
let request3 = requestOf(args);
|
|
142580
143485
|
if (typeof request3.sessionId != "string" || !request3.sessionId || request3.atSeq !== void 0 && (!Number.isSafeInteger(request3.atSeq) || request3.atSeq < 0))
|
|
142581
143486
|
throw new SessionRuntimeError("session/fork-invalid", "Invalid fork request.");
|
|
@@ -142631,9 +143536,9 @@ var ChSessions = class {
|
|
|
142631
143536
|
inspection,
|
|
142632
143537
|
config2?.permissionModeId
|
|
142633
143538
|
);
|
|
142634
|
-
delete draft.permissionModeId, permissionModeId && (draft.permissionModeId = permissionModeId);
|
|
143539
|
+
delete draft.codexPlanMode, delete draft.permissionModeId, permissionModeId && (draft.permissionModeId = permissionModeId);
|
|
142635
143540
|
}
|
|
142636
|
-
draft.selection = request3, await this.preferences?.remember(request3.provider, {
|
|
143541
|
+
draft.selection = request3, before.provider !== request3.provider && this.events.emit("commands/change"), await this.preferences?.remember(request3.provider, {
|
|
142637
143542
|
model: model2,
|
|
142638
143543
|
thinkingOptionId: request3.reasoningEffort,
|
|
142639
143544
|
permissionModeId: draft.permissionModeId
|
|
@@ -142703,6 +143608,8 @@ var ChSessions = class {
|
|
|
142703
143608
|
"goal/command-required",
|
|
142704
143609
|
"Submit /goal as a command on a local Codex Thread with native goals enabled."
|
|
142705
143610
|
);
|
|
143611
|
+
if (this.planChanges.has(this.id(request3.sessionId)))
|
|
143612
|
+
throw new SessionRuntimeError("session/busy", "Wait for Codex to confirm plan mode before sending.");
|
|
142706
143613
|
let existingOwner = !draft || draft.canonicalId ? await this.owner(request3.sessionId) : void 0, steerTurnId;
|
|
142707
143614
|
if (request3.mode === "steer") {
|
|
142708
143615
|
let view = existingOwner && await this.view(request3.sessionId, !0), activeTurnId = view ? view.log.projections[WEB_ACTIVE_TURN_PROJECTION] : null;
|
|
@@ -142725,7 +143632,9 @@ var ChSessions = class {
|
|
|
142725
143632
|
request3.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
|
|
142726
143633
|
`)
|
|
142727
143634
|
) : this.id(request3.sessionId), owner = existingOwner ?? await this.owner(threadId);
|
|
142728
|
-
if (
|
|
143635
|
+
if (this.planChanges.has(threadId))
|
|
143636
|
+
throw new SessionRuntimeError("session/busy", "Wait for Codex to confirm plan mode before sending.");
|
|
143637
|
+
steerTurnId ? await this.host.request("turn/steer", {
|
|
142729
143638
|
threadId,
|
|
142730
143639
|
expectedTurnId: steerTurnId,
|
|
142731
143640
|
input: input3,
|
|
@@ -142736,16 +143645,27 @@ var ChSessions = class {
|
|
|
142736
143645
|
input: input3,
|
|
142737
143646
|
...request3.mode === "queue" ? { delivery: "queue", presentationInput: presentation2 } : {},
|
|
142738
143647
|
...request3.requestId ? { clientUserMessageId: request3.requestId } : {}
|
|
142739
|
-
})
|
|
143648
|
+
});
|
|
143649
|
+
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);
|
|
143650
|
+
if (project2)
|
|
143651
|
+
try {
|
|
143652
|
+
this.workspaces.rememberHarness(project2.workspaceId, owner.harnessId);
|
|
143653
|
+
} catch {
|
|
143654
|
+
this.events.emit(
|
|
143655
|
+
"codexhost/preferences-error",
|
|
143656
|
+
"The project's last Harness could not be saved."
|
|
143657
|
+
);
|
|
143658
|
+
}
|
|
143659
|
+
if (draft && !draft.titleRequested) {
|
|
142740
143660
|
draft.titleRequested = !0;
|
|
142741
|
-
let
|
|
142742
|
-
if (
|
|
143661
|
+
let row2 = this.rows.get(threadId);
|
|
143662
|
+
if (row2) {
|
|
142743
143663
|
this.titleRequests.add(threadId);
|
|
142744
143664
|
let prompt = request3.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
|
|
142745
143665
|
`);
|
|
142746
143666
|
tryGenerateThreadTitle(
|
|
142747
143667
|
this.host,
|
|
142748
|
-
|
|
143668
|
+
row2,
|
|
142749
143669
|
prompt,
|
|
142750
143670
|
owner.owner === "external",
|
|
142751
143671
|
() => !this.closed && this.titleRequests.has(threadId)
|
|
@@ -143099,23 +144019,61 @@ var ChSessions = class {
|
|
|
143099
144019
|
defaultOptions: [],
|
|
143100
144020
|
defaultPreset: ""
|
|
143101
144021
|
})), rpc2.register("commands/list", async (args) => {
|
|
143102
|
-
let id2 = String(args.agentId ?? "");
|
|
144022
|
+
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
144023
|
try {
|
|
143104
144024
|
let scope2 = await this.goalScope(id2);
|
|
143105
144025
|
if (scope2 === "draft" && await this.supportsDraftGoals() && await this.goalScope(id2) === "draft")
|
|
143106
|
-
return [
|
|
144026
|
+
return [...commands, goalCommand];
|
|
143107
144027
|
if (scope2 === "local" && nativeCodexGoalResultSchema.safeParse(
|
|
143108
144028
|
await this.host.request(NATIVE_CODEX_GOAL_METHOD, {
|
|
143109
144029
|
threadId: this.id(id2),
|
|
143110
144030
|
action: "get"
|
|
143111
144031
|
})
|
|
143112
144032
|
).success)
|
|
143113
|
-
return [
|
|
144033
|
+
return [...commands, goalCommand];
|
|
143114
144034
|
} catch {
|
|
143115
144035
|
}
|
|
143116
|
-
return
|
|
144036
|
+
return commands;
|
|
143117
144037
|
}), rpc2.register("commands/execute", async (args) => {
|
|
143118
|
-
let id2 = String(args.agentId ?? ""), line = String(args.line ?? "").trim();
|
|
144038
|
+
let id2 = String(args.agentId ?? ""), line = String(args.line ?? "").trim(), draft = this.drafts.get(id2), plan = /^\/plan(?:\s+([\s\S]*))?$/u.exec(line.trim());
|
|
144039
|
+
if (plan) {
|
|
144040
|
+
let threadId = this.id(id2), unboundDraft = draft && !draft.canonicalId ? draft : void 0, current = this.codexPlanSelection(id2);
|
|
144041
|
+
if (current === void 0) return;
|
|
144042
|
+
if (Array.isArray(args.submittedAttachments) && args.submittedAttachments.length > 0)
|
|
144043
|
+
throw new SessionRuntimeError("session/plan-attachments", "Remove attachments before using /plan.");
|
|
144044
|
+
if (!this.realtime || this.closed || !this.hostOnline)
|
|
144045
|
+
throw new SessionRuntimeError(
|
|
144046
|
+
"session/plan-unavailable",
|
|
144047
|
+
"The native Codex connection is unavailable."
|
|
144048
|
+
);
|
|
144049
|
+
let action = plan[1];
|
|
144050
|
+
if (action !== void 0 && action !== "on" && action !== "off")
|
|
144051
|
+
throw new SessionRuntimeError("session/plan-argument", "Use /plan, /plan on, or /plan off.");
|
|
144052
|
+
if (unboundDraft) {
|
|
144053
|
+
if (!await this.supportsCodexPlanMode())
|
|
144054
|
+
throw new SessionRuntimeError(
|
|
144055
|
+
"session/plan-unavailable",
|
|
144056
|
+
"This Codex version does not support plan mode."
|
|
144057
|
+
);
|
|
144058
|
+
if (this.drafts.get(id2) !== unboundDraft || this.closed || !this.hostOnline || unboundDraft.creating || unboundDraft.canonicalId || unboundDraft.selection.provider !== "codex")
|
|
144059
|
+
throw new SessionRuntimeError("session/busy", "Draft selection changed.");
|
|
144060
|
+
let active3 = action === void 0 ? !unboundDraft.codexPlanMode : action === "on";
|
|
144061
|
+
unboundDraft.codexPlanMode = active3;
|
|
144062
|
+
for (let sink of this.controls)
|
|
144063
|
+
sink.push({
|
|
144064
|
+
type: "projection",
|
|
144065
|
+
sessionId: id2,
|
|
144066
|
+
key: "codexPlanMode",
|
|
144067
|
+
value: active3,
|
|
144068
|
+
seq: 0
|
|
144069
|
+
});
|
|
144070
|
+
} else
|
|
144071
|
+
await this.selectCodexPlanMode(
|
|
144072
|
+
threadId,
|
|
144073
|
+
action === void 0 ? !current : action === "on"
|
|
144074
|
+
);
|
|
144075
|
+
return { commandId: randomUUID23(), result: { kind: "success" } };
|
|
144076
|
+
}
|
|
143119
144077
|
if (nativeCodexGoalInvocation.test(line)) {
|
|
143120
144078
|
let scope2 = await this.goalScope(id2);
|
|
143121
144079
|
if (scope2 === "other") return;
|
|
@@ -143162,7 +144120,7 @@ var ChSessions = class {
|
|
|
143162
144120
|
}
|
|
143163
144121
|
let match = /^\/permission\s+(.+)$/u.exec(line);
|
|
143164
144122
|
if (!match) return;
|
|
143165
|
-
let modeId = match[1] ?? "",
|
|
144123
|
+
let modeId = match[1] ?? "", harnessId = draft && !draft.canonicalId ? draft.selection.provider : (await this.owner(id2)).harnessId, inspection = await this.catalog.inspect(
|
|
143166
144124
|
harnessId,
|
|
143167
144125
|
draft?.cwd ?? this.rows.get(this.id(id2))?.cwd
|
|
143168
144126
|
), mode = inspection.status === "ready" ? inspection.permissionModes?.modes.find((value) => value.id === modeId) : void 0;
|
|
@@ -143396,10 +144354,12 @@ var WebHarnessPreferences = class {
|
|
|
143396
144354
|
await this.patch([operation]), await this.patch([{ kind: "newThread", lastHarness: id2 }]);
|
|
143397
144355
|
}
|
|
143398
144356
|
async decorate(catalog, snapshot = this.get().catch(() => {
|
|
143399
|
-
})) {
|
|
144357
|
+
}), projectHarnessId2) {
|
|
143400
144358
|
let external = await snapshot;
|
|
143401
144359
|
if (external) {
|
|
143402
|
-
let favorites = external.values.favorites, configurationFor = (harnessId) => external.values.newThread?.byHarness[harnessId], preferred = catalog.groups.find(
|
|
144360
|
+
let favorites = external.values.favorites, configurationFor = (harnessId) => external.values.newThread?.byHarness[harnessId], preferred = catalog.groups.find(
|
|
144361
|
+
(group) => group.id === (projectHarnessId2 ?? external.values.newThread?.lastHarness)
|
|
144362
|
+
) ?? catalog.groups.find((group) => group.id === catalog.default.provider), selectionFor = (group, fallbackModelId) => {
|
|
143403
144363
|
let configuration = configurationFor(group.id), modelRef = configuration?.model, model2 = (
|
|
143404
144364
|
// A remembered speed variant restores its base Model.
|
|
143405
144365
|
group.models.find(
|
|
@@ -144947,7 +145907,7 @@ function nativeProjectCommands(host, workspaces2, refresh, assignSession) {
|
|
|
144947
145907
|
throw new SessionRuntimeError("workspace/invalid-path", "Choose an existing absolute folder.", {
|
|
144948
145908
|
path: path7
|
|
144949
145909
|
});
|
|
144950
|
-
let absolute2 = resolve23(expanded), existing = workspaces2.
|
|
145910
|
+
let absolute2 = resolve23(expanded), existing = workspaces2.byExactPath(absolute2);
|
|
144951
145911
|
if (existing) return { workspace: existing, created: !1 };
|
|
144952
145912
|
let { project: project2 } = await host.request("project/create", {
|
|
144953
145913
|
name: basename14(absolute2) || absolute2,
|
|
@@ -144976,7 +145936,7 @@ function nativeProjectCommands(host, workspaces2, refresh, assignSession) {
|
|
|
144976
145936
|
"workspace/refresh-failed",
|
|
144977
145937
|
"Codex confirmed the removal. Refresh the project list."
|
|
144978
145938
|
);
|
|
144979
|
-
return workspaces2.removeFromDisplayOrder(workspaceId), workspaces2.removePinnedWorkspaceOverride(workspaceId), { deleted: !0 };
|
|
145939
|
+
return workspaces2.removeFromDisplayOrder(workspaceId), workspaces2.removePinnedWorkspaceOverride(workspaceId), workspaces2.removeHarnessPreference(workspaceId), { deleted: !0 };
|
|
144980
145940
|
}),
|
|
144981
145941
|
insertBefore: (workspaceId, beforeWorkspaceId) => mutate(async () => {
|
|
144982
145942
|
if (!(workspaces2.isRemote(workspaceId) || beforeWorkspaceId !== void 0 && workspaces2.isRemote(beforeWorkspaceId)))
|
|
@@ -145174,7 +146134,7 @@ async function snapshotPackagedHost(distribution, data2) {
|
|
|
145174
146134
|
|
|
145175
146135
|
// packages/web-server/src/main.ts
|
|
145176
146136
|
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.
|
|
146137
|
+
"0.32.1",
|
|
145178
146138
|
[join36(DISTRIBUTION_ROOT, "package.json"), join36(REPO_ROOT, "package.json")]
|
|
145179
146139
|
);
|
|
145180
146140
|
if (PACKED) {
|
|
@@ -145267,7 +146227,7 @@ var publicUrl = background ? background.publicUrl : values["public-url"] ?? proc
|
|
|
145267
146227
|
chHost,
|
|
145268
146228
|
displayDirectory,
|
|
145269
146229
|
events
|
|
145270
|
-
), preferences = new WebHarnessPreferences(chHost, events), images = new WebImages(data), files = new WebFiles(data, images), sessions = new ChSessions(
|
|
146230
|
+
), preferences = new WebHarnessPreferences(chHost, events), images = new WebImages(data), files = new WebFiles(data, images), sharedWorkspaceSearchCache = new WorkspaceFileSearchCache(), sessions = new ChSessions(
|
|
145271
146231
|
chHost,
|
|
145272
146232
|
workspaces,
|
|
145273
146233
|
events,
|
|
@@ -145276,7 +146236,8 @@ var publicUrl = background ? background.publicUrl : values["public-url"] ?? proc
|
|
|
145276
146236
|
displayEntries,
|
|
145277
146237
|
preferences,
|
|
145278
146238
|
enabledHarnesses,
|
|
145279
|
-
(path7, action) => openWorkspaceFile(launcher, path7, action)
|
|
146239
|
+
(path7, action) => openWorkspaceFile(launcher, path7, action),
|
|
146240
|
+
sharedWorkspaceSearchCache
|
|
145280
146241
|
), dsh = await DshWebServices.open({
|
|
145281
146242
|
workspaceRoot: resolve25(values.workspace),
|
|
145282
146243
|
threadWorkspace: (id2) => sessions.terminalWorkspaceRoot(id2),
|
|
@@ -145311,7 +146272,7 @@ var broadcastNotification = (message2) => {
|
|
|
145311
146272
|
plugins: CLIENT_PLUGINS,
|
|
145312
146273
|
globals: { ...CLIENT_GLOBALS, __CODEXHOST_DEV_WEB_UI__: devWebUi !== void 0 },
|
|
145313
146274
|
title: "CodexHost"
|
|
145314
|
-
}, builtInAssets = new WebAssets(assetOptions),
|
|
146275
|
+
}, builtInAssets = values["safe-mode"] ? void 0 : new WebAssets(assetOptions), cachedRecoveryAssets, getRecoveryAssets = () => cachedRecoveryAssets ??= new WebAssets({
|
|
145315
146276
|
...assetOptions,
|
|
145316
146277
|
plugins: CLIENT_PLUGINS.filter((id2) => id2 !== HMR_CLIENT_PLUGIN)
|
|
145317
146278
|
}), extensions2 = new WebUiExtensions(data, {
|
|
@@ -145325,7 +146286,7 @@ var broadcastNotification = (message2) => {
|
|
|
145325
146286
|
}
|
|
145326
146287
|
});
|
|
145327
146288
|
await extensions2.cleanup();
|
|
145328
|
-
var assets = values["safe-mode"] ?
|
|
146289
|
+
var assets = values["safe-mode"] ? getRecoveryAssets() : builtInAssets, pluginRuntime, listeningPort = Number(values.port);
|
|
145329
146290
|
if (!values["safe-mode"])
|
|
145330
146291
|
try {
|
|
145331
146292
|
if (dsh === void 0) throw new Error("The DSH Web backend is unavailable");
|
|
@@ -145354,7 +146315,9 @@ if (!values["safe-mode"])
|
|
|
145354
146315
|
SIDEBAR_BROWSER_PATH
|
|
145355
146316
|
].map((path7) => ({ kind: "exact", path: path7 }))
|
|
145356
146317
|
]
|
|
145357
|
-
}), assets = new WebAssets({ ...assetOptions, clients: pluginRuntime.clients }),
|
|
146318
|
+
}), assets = new WebAssets({ ...assetOptions, clients: pluginRuntime.clients }), builtInAssets = void 0;
|
|
146319
|
+
let savedExternalPlugins = extensions2.plugins();
|
|
146320
|
+
savedExternalPlugins.length > 0 && new WebAssets({ ...assetOptions, externalPlugins: savedExternalPlugins }), await extensions2.restore();
|
|
145358
146321
|
} catch (error62) {
|
|
145359
146322
|
extensions2.composed(
|
|
145360
146323
|
[],
|
|
@@ -145453,7 +146416,7 @@ peerManager.onPeerRemoved = (hostId2) => {
|
|
|
145453
146416
|
workspaces.removeRemoteHostOrder(hostId2);
|
|
145454
146417
|
};
|
|
145455
146418
|
remoteSessions.install(rpc, streams);
|
|
145456
|
-
var remoteWorkspaceFiles = new RemotePeerWorkspaceFiles(remoteSessions)
|
|
146419
|
+
var remoteWorkspaceFiles = new RemotePeerWorkspaceFiles(remoteSessions);
|
|
145457
146420
|
sessions.setRemoteFileSearch(
|
|
145458
146421
|
(sessionId, query, signal) => remoteWorkspaceFiles.searchFiles(sessionId, query, signal)
|
|
145459
146422
|
);
|
|
@@ -145664,7 +146627,7 @@ var server = createWebServer((request3, response) => {
|
|
|
145664
146627
|
await servePeerWorkspaceFiles(request3, response, peerRoute === "workspace-files/rpc" ? "rpc" : peerRoute === "workspace-files/download" ? "download" : "search", {
|
|
145665
146628
|
resolveWorkspaceRoot: (threadId, signal) => sessions.ensureLocalWorkspaceRoot(threadId, signal),
|
|
145666
146629
|
...dsh ? { dsh } : {},
|
|
145667
|
-
searchCache:
|
|
146630
|
+
searchCache: sharedWorkspaceSearchCache
|
|
145668
146631
|
});
|
|
145669
146632
|
return;
|
|
145670
146633
|
}
|
|
@@ -145796,17 +146759,13 @@ var server = createWebServer((request3, response) => {
|
|
|
145796
146759
|
return;
|
|
145797
146760
|
}
|
|
145798
146761
|
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
|
-
);
|
|
146762
|
+
await sendShellIndex(request3, response, {
|
|
146763
|
+
url: url2,
|
|
146764
|
+
assets,
|
|
146765
|
+
recoveryAssets: { index: () => getRecoveryAssets().index() },
|
|
146766
|
+
...pluginRuntime === void 0 ? {} : { renderIndex: (html) => pluginRuntime.renderIndex(html) },
|
|
146767
|
+
...auth === void 0 ? {} : { headScript: SWITCH_TOKEN_SCRIPT }
|
|
146768
|
+
});
|
|
145810
146769
|
return;
|
|
145811
146770
|
}
|
|
145812
146771
|
if (pathname === "/plugins/events" && pluginRuntime !== void 0) {
|
|
@@ -145821,7 +146780,7 @@ var server = createWebServer((request3, response) => {
|
|
|
145821
146780
|
await sendAsset(
|
|
145822
146781
|
request3,
|
|
145823
146782
|
response,
|
|
145824
|
-
assets.plugin(url2) ??
|
|
146783
|
+
assets.plugin(url2) ?? cachedRecoveryAssets?.plugin(url2),
|
|
145825
146784
|
url2.includes("rev=") ? IMMUTABLE_CACHE : void 0
|
|
145826
146785
|
);
|
|
145827
146786
|
return;
|
|
@@ -145870,7 +146829,7 @@ var server = createWebServer((request3, response) => {
|
|
|
145870
146829
|
response,
|
|
145871
146830
|
assets.dist(pathname),
|
|
145872
146831
|
pathname.startsWith("/assets/") ? IMMUTABLE_CACHE : void 0,
|
|
145873
|
-
pathname === "/codexhost-settings.js"
|
|
146832
|
+
pathname === "/sw.js" || pathname === "/manifest.webmanifest" || pathname === "/codexhost-settings.js"
|
|
145874
146833
|
);
|
|
145875
146834
|
})().catch((error62) => {
|
|
145876
146835
|
console.error("[http] request failed", error62), response.headersSent ? response.destroy() : response.writeHead(500).end("internal error");
|
|
@@ -145914,7 +146873,7 @@ background && server.once("error", (error62) => {
|
|
|
145914
146873
|
server.listen(Number(values.port), values.host, async () => {
|
|
145915
146874
|
let port = server.address().port;
|
|
145916
146875
|
listeningPort = port;
|
|
145917
|
-
let host = values.host, wildcard = isWildcardHost(host), local = wildcard ||
|
|
146876
|
+
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
146877
|
if (background) {
|
|
145919
146878
|
let readyFile = values["ready-file"];
|
|
145920
146879
|
readyFile !== void 0 && new DataDir(dirname19(readyFile)).writeJson(
|
|
@@ -145952,7 +146911,7 @@ var shuttingDown;
|
|
|
145952
146911
|
function shutdown(exitCode = 0) {
|
|
145953
146912
|
return shuttingDown ??= (async () => {
|
|
145954
146913
|
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(),
|
|
146914
|
+
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
146915
|
} catch (error62) {
|
|
145957
146916
|
console.error("[web] shutdown failed", error62), exitCode ||= 1;
|
|
145958
146917
|
} finally {
|